Skip to content

feat(form-tx): read a summary row that shows several values as an effect location - #2513

Draft
abrichr wants to merge 2 commits into
claude/effect-location-review-portfrom
claude/effect-location-summary-row
Draft

abrichr wants to merge 2 commits into
claude/effect-location-review-portfrom
claude/effect-location-summary-row

Conversation

@abrichr

@abrichr abrichr commented Nov 22, 2026 •

Copy link
Copy Markdown
Member

What this does

Step 2b: the combined summary row. It is stacked on #2508 and uses the effect-location record from #2500.

A summary often shows two intake values in one row. For example, "Ada Byron (01/31/1990)" holds a traveller's name and date of birth. Until now a pack could not read such a row as two values. Both keys ended not_checked (set4v2 larkspan: traveller_1_name and traveller_1_dob), or the pack checked a derived string built from both, which says nothing about either key alone.

SummaryCheckSpec.row_readbacks declares such a row:

  • an anchor;
  • a pattern that must match the whole shown text;
  • one SummaryRowPartSpec per intake key, each giving a named group, the key and its codec.

The summary judge turns each row into an openadapt.effect-location/v1 template location with start same_screen, and the shared evaluator judges it (form_tx/row_location.py). The judge grows by about 50 lines.

Each key gets its own verdict:

  • a wrong date refutes only the date, and the name is still checked;
  • a row that doesn't fit the pattern, isn't shown, or is shown twice leaves every key in the row not_checked;
  • a part the shared codec can't read leaves only that key not_checked;
  • an intake value the part's codec can't read leaves that key not_checked.

Codecs. The shared codec reads the displayed text. form_tx's codec reads the intake value, so intake formats stay as they are. Three part codecs are supported: whitespace_collapse, casefold and iso_date in the part's date_order. Any other codec leaves the row not_checked.

Behaviour change

For keys a pack covers with row_readbacks, the judge now gives each key a verdict of its own: passed, failed or not_checked. Before, such keys could only be not_checked.

Packs without row_readbacks are unchanged. An empty list is left out of the pack dump, so their digests don't change either; a test checks this.

This PR doesn't change any benchmark pack. Switching larkspan from travellers_shown to a row read-back is a pack change for the benchmark owner.

Tests

All synthetic.

  • tests/test_form_tx_row_location.py: 14 passed. It covers both values held, each part refuted alone, the cases that can't be read, an intake value the codec can't read, an unsupported codec, a key with no intake value, the judge's verdict mapping, an unchanged digest and a refused pattern.
  • The form_tx suite: see the comment below.

Since opening

  • Fixed from Gemini round 1.
    • Keys checked only through row_readbacks are now counted as declared. Before, they could never pass.
    • A row part with no intake value that the summary shows non-empty is refuted (a portal prefill), as for field read-backs.
  • New end-to-end test. tests/test_form_tx_row_location_e2e.py runs headless Chromium with name and date of birth in one summary row. Both values pass and the run ends VERIFIED_DONE. A stored wrong date fails only the date. Both tests fail without the fix.

…ect location

A summary row such as "Ada Byron (01/31/1990)" shows two intake values.
SummaryCheckSpec.row_readbacks declares such a row: an anchor, a pattern
that must match the whole text, and one part per intake key with its codec.
The summary judge turns each row into an openadapt.effect-location/v1
template location and judges it with the shared evaluator, so each key gets
its own verdict: a wrong date refutes the date and still checks the name.

Behaviour change: keys a pack covers with row_readbacks now get passed,
failed or not_checked verdicts of their own, where before they could only
be not_checked (or checked through a derived string). Packs without
row_readbacks are unchanged; an empty list is left out of the pack dump, so
their digests are unchanged too.
…e with no intake

From review: keys checked only through row_readbacks were also judged as
undeclared, so they could never pass. They are now declared. And, like a
field read-back, a row part with no intake value that the summary shows
non-empty is refuted (a portal prefill). An end-to-end headless test runs a
form whose summary shows name and date of birth in one row: both pass, and
a stored wrong date fails the date alone; it fails without this fix.
@abrichr

abrichr commented Nov 22, 2026

Copy link
Copy Markdown
Member Author

From: Gemini (gemini-3.1-pro-preview), round 1
Reviewed-Head: 1a7b223

Sent the full diff of this PR's own files, those files in full, and any earlier findings.

This PR elegantly solves the problem of reading back multiple values from a single summary row by leveraging the shared effect_location evaluator and its template codec. The fail-closed design is well maintained, and the backward compatibility for pack hashes is a nice touch.

However, there is a critical bug in how the judge determines which keys are "declared" for read-back, which will cause runs to fail if they rely solely on row_readbacks for a field.

BLOCKER

Keys checked only via row_readbacks are considered undeclared and will fail the run.
In packages/flow/openadapt_flow/form_tx/judge.py (around line 806), declared_keys is built by collecting keys from field_readbacks and split_date_readbacks, but it completely ignores row_readbacks.
If a key is checked only via a row_readback, it will fall into the undeclared fields check (around line 852) and receive a NOT_CHECKED verdict ("No read-back is declared for this field"). Later, _row_verdicts will append a second verdict (e.g., PASSED) for the same key. Because a NOT_CHECKED verdict exists for the key, the run will fail.

Fix: Add the keys from row_readbacks to declared_keys:

        for row in summary_check.row_readbacks:
            for part in row.parts:
                declared_keys.add(part.dossier_key)

SHOULD-FIX

Ungrounded values shown in summary rows are silently ignored.
For standard field_readbacks, if the summary screen shows a non-empty value for a key that has no expected fact (e.g., the portal pre-filled it and the run didn't write it), the judge explicitly fails the run ("Summary screen showed unexpected non-empty value for ungrounded key...").
In row_readback_results (row_location.py), any part whose dossier_key is not in expected is silently skipped. If the regex pattern matches and extracts a value for that ungrounded key, it is ignored rather than flagged. This is a verification gap compared to field_readbacks.

NIT

Minor reporting inaccuracy for codec_kind if a key spans multiple rows.
In _row_verdicts (judge.py), the codec_kind for the verdict is taken from the first part that matches the key across all rows:

part = next(p for r in rows for p in r.parts if p.dossier_key == key)

If a key happens to be checked in multiple rows using different codecs (e.g., WHITESPACE_COLLAPSE in one, CASEFOLD in another), all verdicts for that key will report the codec of the first one found. This doesn't affect the pass/fail logic, but it's a slight inaccuracy in the receipt.


Verdict: REQUEST CHANGES

@abrichr

abrichr commented Nov 22, 2026

Copy link
Copy Markdown
Member Author

From: Gemini (gemini-3.1-pro-preview), round 2
Reviewed-Head: c2a7fe7

Sent the full diff of this PR's own files, those files in full, and any earlier findings.

The updates in this round look great. Both the BLOCKER and the SHOULD-FIX from the previous review have been elegantly addressed.

The fix to declared_keys ensures that keys checked only via row_readbacks no longer fail the run as undeclared. The addition of the ungrounded check in row_readback_results correctly refutes the run if the summary shows a value for a key the intake did not have, closing the verification gap.

There are no fail-open paths or correctness bugs remaining. I have just two minor nits.

NIT

Minor reporting inaccuracy for codec_kind if a key spans multiple rows (carried over).
In _row_verdicts (judge.py), the codec_kind for the verdict is still taken from the first part that matches the key across all rows. If a key is checked in multiple rows using different codecs, all verdicts for that key will report the codec of the first one found. This doesn't affect pass/fail logic.

Unhandled IndexError on invalid regex group for ungrounded keys.
In row_readback_results (row_location.py), the new ungrounded check does:

group = fits.group(part.group) if fits else None

If a pack author makes a mistake and specifies a part.group that does not exist in the regex pattern, this will raise an unhandled IndexError and crash the judge. (The shared template codec catches this and turns it into a not_checked, but this manual check does not). Because an unhandled exception crashes the run and prevents a verified receipt, it safely fails closed, so it is not a blocker. You could catch IndexError here or validate the groups against re.compile(pattern).groupindex in the Pydantic model.


Verdict: APPROVE WITH NITS

@abrichr

abrichr commented Nov 22, 2026

Copy link
Copy Markdown
Member Author

From: Claude
Reviewed-Head: c2a7fe7

Author declaration at the head above. Synthetic tests only; no real app was run.

  • Behaviour change. Keys a pack covers with row_readbacks now get verdicts of their own. Packs without row read-backs are unchanged, and so are their digests.
  • Fixes from Gemini round 1. Gemini found that keys covered only by row read-backs were judged as undeclared, and that a row could show a value for a key with no intake value without being flagged. Both are fixed. The new end-to-end test fails without the first fix.
  • Tests at this head:
    • test_form_tx_row_location.py: 13 passed.
    • test_form_tx_row_location_e2e.py: 2 passed, headless.
    • The whole form_tx suite (all tests/test_form_tx*.py): 424 passed in 8 min 7 s.
  • Gemini round 2 left one reporting nit, about which codec name a verdict carries when one key appears in two rows. I left it as it is.

This branch has not been deployed

No deployments
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.

1 participant