Skip to content

fix(tx): learn NULL versus empty string per field as a codec - #2402

Merged
abrichr merged 3 commits into
mainfrom
claude/tx-null-empty-2391
Nov 22, 2026
Merged

abrichr merged 3 commits into
mainfrom
claude/tx-null-empty-2391

Conversation

@abrichr

@abrichr abrichr commented Nov 21, 2026

Copy link
Copy Markdown
Member

Fixes #2391.

Problem

The judge compared the frame with strict equality. An app that keeps an untouched optional field NULL until a form save sends '' back gets every correct save called a clobber. This was one of the benchmark's false REFUTEDs on OpenEMR.

Reproduced on a local OpenEMR 7.0.3 with a headless browser: one demographics-form save of phone_home rewrote occupation from NULL to ''. The judge failed the save with clobbered_fields=('occupation',).

Change

  • New field codec null_empty: None and '' are one value for that field. It never equates 0, False, [] or any non-empty value, and it applies only to the fields it is declared on. There is no global rule.
  • It is learned from what the server did, never assumed:
    • learn_null_empty_codecs(before, after, written) returns the fields that moved only between the two empty spellings and were not written.
    • The sandbox probe applies it after its merged write, which sends every untouched field back unchanged.
    • HAR induction learns it from snapshots. Before this change it could read the same change as a replace-mode clobber.
  • FrameAndIntentJudge and the engine's fallback judge both honour it in the frame comparison. The engine normalizer maps None to '' for it.

No engine code names an app.

Tests

  • tests/test_tx_null_empty.py (CI): codec truth table; both judges without the codec (clobber) and with a learned codec (pass); a non-empty change on a learned field and a change on another field are still clobbers; the learner skips written fields and non-empty changes; a codec on one field doesn't cover another; HAR induction learns the codec and stays in patch mode.
  • tests/test_tx_null_empty_live.py (lab only; needs OAFLOW_TX_LIVE_OPENEMR_URL and _SQL, headless Chromium, the fixture account from benchmark/openemr_live). All 4 pass on a local OpenEMR 7.0.3:
    • the form save rewrites a NULL field to '';
    • the judge fails the correct save without a codec;
    • with the learned codec it passes;
    • a clobber on the learned field and on lname is still caught (the read-back row is edited by the test as a control).
  • tx suites on the lab's WSL: 238 passed. Two timing assertions failed there (a 50k-row seed time budget and a background-writer count). They fail the same way on unchanged code under load.

Coordination

The false-stop agent's open PR (#2377) changes openadapt_flow/verifier.py rechecks and doesn't touch the tx judge, so this doesn't duplicate it.

The judge compared the frame with strict equality. An app that keeps an
untouched optional field NULL until a form save sends '' back for it got
every correct save called a clobber. Reproduced on a local OpenEMR 7.0.3
with a headless browser: one demographics save of phone_home rewrote
occupation from NULL to '', and the judge failed the save with
clobbered_fields=('occupation',).

A new field codec, null_empty, makes None and '' one value for one field.
It never equates 0, False, [] or any non-empty value, and it covers only
the fields it is declared on. It is learned, not assumed:

- learn_null_empty_codecs(before, after, written) returns the fields that
  moved only between the two empty spellings and were not written;
- the sandbox probe applies it after the merged write that sends every
  untouched field back unchanged;
- HAR induction learns it from snapshots instead of reading the change as
  a replace-mode clobber.

Both judges (FrameAndIntentJudge and the engine's fallback) honour it in
the frame comparison. Live tests reproduce the rewrite, show the judge
failing without the codec and passing with it, and show that a real
clobber on the learned field and on another field is still caught.

Signed-off-by: abrichr <richard.abrich@mldsai.com>
@abrichr

abrichr commented Nov 21, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: APPROVE

From: Grok
Reviewed-Head: 9ddbc9f

null_empty is a per-field codec, never a global rule, and it equates only None and "" — not 0, False, [], or any non-empty value. It is learned only from fields that moved between those two empty spellings and were not written. Both FrameAndIntentJudge and the fallback judge honour it; a non-empty change on a learned field, or a change on any other field, is still a clobber. Induction and the sandbox probe learn it from what the server did, and skip treating that rewrite as a replace-mode clobber. Merge-tree versus main is clean. Not merged, as requested.

Pointer: openadapt-internal#211

# Conflicts:
#	CAPABILITIES.md
#	llms-full.txt
@abrichr

abrichr commented Nov 21, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: APPROVE

From: Grok
Reviewed-Head: 440a5a2

Delta re-review after the approved head 9ddbc9f3adcf763f840d62617c0047f38206f8d2. Author is still GitHub abrichr, not Grok. I will not merge.

The only unique commit is a merge of origin/main (dc5de98cb). The conflicts were in CAPABILITIES.md and generated llms-full.txt. The transaction-lens row keeps this PR's wording and inserts main's #2392 sentence immediately before "Not checked:". I did not find a code-file conflict in this merge.

Review only; I am not merging.

# Conflicts:
#	CAPABILITIES.md
#	llms-full.txt
#	packages/flow/openadapt_flow/tx/induce.py
@abrichr

abrichr commented Nov 22, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: APPROVE

From: Claude (independent reviewer)
Reviewed-Head: c27012b

No blockers.

  • The only new commit since 440a5a2 is c27012b, a merge of origin/main (e754d56). Its only code conflict is in packages/flow/openadapt_flow/tx/induce.py, in induce_lens_from_har. git show --remerge-diff shows the resolution kept both sides' declarations: this PR's null_empty_paths list and main's (fix(flow): bind null SQL verification read params as IS NULL (fail closed) #2489) requested_values set, built from every POST, PUT or PATCH body (induce.py:1180-1185). It dropped nothing else.
  • The PR's net diff under packages/ against main is identical to the approved head's net diff. The only differences are the surrounding context lines that main's change introduced. Main's requested_values guard on the volatile check is intact (induce.py:1205-1215).
  • Order of the null/empty skip and the requested-values check (induce.py:1199-1215): the None/"" skip still runs first and continues, as it did at the approved head. The requested_values condition only narrows when a changed field is marked volatile. Neither branch changes the other's inputs. So the combined code behaves like the approved head's logic plus main's narrowing:
    • A None/"" flip gets a null_empty codec. It is never marked volatile or used as evidence of a replace write.
    • Any other change follows main's rule: a value some write asked for never makes its field volatile.
    • Putting the volatile check first would not be better. It could mark a metadata-named field volatile, which would mask every later change on it, when the change was only an empty-spelling flip.
  • Not new in this merge: the HAR path does not skip paths that the write itself carried, while learn_null_empty_codecs in the probe path does. I see no harm, because a null_empty codec only equates None and "" on that field. I mention it only for completeness.
  • In CAPABILITIES.md and llms-full.txt, the PR only adds its null_empty codec sentence. Every sentence on main's version of that row is still there.
  • Tests at c27012b: tests/ -k tx gives 448 passed, 30 skipped.

@abrichr
abrichr merged commit 69aaf85 into main Nov 22, 2026
56 of 57 checks passed
@abrichr
abrichr deleted the claude/tx-null-empty-2391 branch November 22, 2026 03:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tx judge: treat NULL and empty string as equal on first save

1 participant