Repository navigation
fix(tx): learn NULL versus empty string per field as a codec - #2402
Conversation
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>
Independent adversarial review: APPROVEFrom: Grok
Pointer: openadapt-internal#211 |
# Conflicts: # CAPABILITIES.md # llms-full.txt
Independent adversarial review: APPROVEFrom: Grok Delta re-review after the approved head The only unique commit is a merge of Review only; I am not merging. |
# Conflicts: # CAPABILITIES.md # llms-full.txt # packages/flow/openadapt_flow/tx/induce.py
Independent adversarial review: APPROVEFrom: Claude (independent reviewer) No blockers.
|
Fixes #2391.
Problem
The judge compared the frame with strict equality. An app that keeps an untouched optional field
NULLuntil 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_homerewroteoccupationfromNULLto''. The judge failed the save withclobbered_fields=('occupation',).Change
null_empty:Noneand''are one value for that field. It never equates0,False,[]or any non-empty value, and it applies only to the fields it is declared on. There is no global rule.learn_null_empty_codecs(before, after, written)returns the fields that moved only between the two empty spellings and were not written.FrameAndIntentJudgeand the engine's fallback judge both honour it in the frame comparison. The engine normalizer mapsNoneto''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; needsOAFLOW_TX_LIVE_OPENEMR_URLand_SQL, headless Chromium, the fixture account frombenchmark/openemr_live). All 4 pass on a local OpenEMR 7.0.3:'';lnameis still caught (the read-back row is edited by the test as a control).Coordination
The false-stop agent's open PR (#2377) changes
openadapt_flow/verifier.pyrechecks and doesn't touch the tx judge, so this doesn't duplicate it.