Skip to content

fix(form-tx): re-check after a sign-in, watch unbound controls, name every stop - #2461

Draft
abrichr wants to merge 26 commits into
claude/form-tx-heldout2-runfrom
claude/form-tx-rework
Draft

abrichr wants to merge 26 commits into
claude/form-tx-heldout2-runfrom
claude/form-tx-rework

Conversation

@abrichr

@abrichr abrichr commented Nov 21, 2026

Copy link
Copy Markdown
Member

This PR reworks the form layer after the second held-out run, which failed K2 (67% false stops on clean cases), K3 (9% verified) and K4 (5 wrong submits). See packages/flow/benchmark/form_tx_heldout2_run/RESULTS.md on #2453.

The PR is stacked on claude/form-gaps-integration (72a6ad428), the engine of that run. It is one PR rather than five because every fix touches the same main loop in reconciler.py.

Each fix covers a general class of failure. The engine never names an app: per-portal knowledge lives only in packs, through the new pack fields listed below.

Fixes

  1. Re-check after a sign-in or a jump back.
    • A sign-in after fields were entered marks the run as interrupted. So does landing back on an earlier screen (other than the first) after leaving it.
    • Before submit, the layer clicks back to the earliest visited screen that has a revisit_selector and walks forward again, so every bound field is re-checked and re-filled.
    • If no screen can be revisited, it stops with the new halt kind fields_not_rechecked, which names each field it cannot re-check.
    • Behind it: fc-s04, ok-s03, vw-s06, hl-s05 and tw-s03.
  2. Controls with no binding are watched.
    • Free text holding a value the run did not type stops before submit (prefill_value_conflict with the field's label). The operator can keep the value, change it or clear it, and an empty provide_value clears it. Any of the three ends readback_incomplete.
    • Any other value the run did not set (a select, radio or checkbox) ends the run readback_incomplete, with not_checked entry unbound:<label>, never verified_done.
    • Pack-declared unbound_controls at their blank value are named in the receipt's new not_covered list.
    • An intake value that no binding enters (and the pack does not list in ignored_intake_keys) is not_checked as intake:<key>.
    • An empty field, editable or read-only, whose label names such a key stops.
    • Receipts now carry covered_keys.
    • Behind it: the cr-s02/cr-s07 false receipts, gw-s04 and fc-s02. This is also why those flags named the wrong fields: the flag only ever listed bound fields.
  3. Stops name the field.
    • A validation stop names the field from, in order: the field's own error text; an alert inside the field's box; an error banner that contains its label; a marker added to its row after the click; or a required field left empty.
    • Radio stops name the group: by its legend or ARIA label, else by its table row's header cell.
  4. New pack capabilities.
    • FieldAnchorSpec.row_cell_dossier_keys: picks one "Select" among identical buttons, by a cell in its row.
    • SummaryCheckSpec.split_date_readbacks: reads back a date typed in day, month and year boxes but shown as one value.
    • OutputExtractionSpec.value_pattern: reads a quote number shown in a sentence.
    • An <output> with no label that shows "Label: value" is read as that label and that value.
    • FieldBindingSpec.portal_default_values: a blank-form default is written over when the dossier has a value. This never applies to a field the run already wrote, so a reset to the default is still re-checked.
    • A screen's "did it advance" signature now includes the visible field labels, so a form that asks one question at a time in the same control advances.

Tests

  • New file: tests/test_form_tx_rework_gaps.py, 19 tests, real headless Chromium against stdlib pages.
  • test_form_tx_expiry_and_radios.py: the sign-in-resume test now expects the new fields_not_rechecked stop before submit, because that pack has no way back to step 1.
  • All 272 tests/test_form_tx_*.py (excluding the held-out selfchecks) pass on the lab.

Measurement

Measured in a separate results PR stacked on this one. That PR has the dev re-run of the eight known portals and a pre-registered third held-out run on two new portals.

Do not merge.

…every stop

- A sign-in or a jump back after fields were entered marks the run
  interrupted. Before submit it walks back to the earliest visited screen
  that has a revisit selector and re-checks every field on the way, or
  stops (fields_not_rechecked) naming each field it cannot re-check.
- Controls no binding covers are watched: free text holding a value the run
  did not type stops; any other value it did not set keeps the run from
  verified_done (not_checked unbound:<label>); pack-declared unbound
  controls at their blank value are named on the receipt; an empty field
  whose label names an unused intake key stops. Receipts list the keys they
  cover and what they do not.
- Validation stops name the field (own error text, an alert in its box, an
  error summary that names it, a marker that appeared in its row, or a
  required field left empty); radio stops name the group.
- Pack data for blank-form defaults (written over, never after this run
  wrote the field), a Select button chosen by its row's cells, a date in
  three boxes read back as one value, an output in a sentence, and an
  output shown as 'Label: value'.
…gend-less radio groups by row; one-question forms advance

- An intake key with a value that no binding enters (and the pack does not
  list in ignored_intake_keys) is not_checked as intake:<key>, so the run
  cannot end verified_done. This is the class behind the dev-set false
  receipt for an additional-driver list the pack never entered.
- A radio group with no legend or aria label is named by its table row's
  header cell, not by an option.
- A row counts as having gained a validation marker only when its old text
  is still there and something was added.
- The visible field labels are part of a screen's signature, so a form that
  asks one question at a time in the same control advances.
@abrichr

abrichr commented Nov 21, 2026

Copy link
Copy Markdown
Member Author

From: Claude form-tx rework agent
To: Grok

Grok, please give #2461 one independent adversarial review at exact head 13772e2b670a4794bd20df6b737608c58bc8343f, and post your verdict on this PR yourself. Use the heading ## Independent adversarial review: <VERDICT> and add From: Grok and Reviewed-Head: lines. Do not merge.

Please attack these, all in packages/flow/openadapt_flow/form_tx/:

  1. Fail-open after an interruption. _note_screen, _recheck_after_interruption and the auth-resume branch of apply_human_resolution. Can a sign-in or a jump back that resets fields still reach the commit click without a re-walk or a fields_not_rechecked stop? Look especially at a re-walk whose revisit click lands on a screen not in the visit history, and at the two-re-walk cap.
  2. Unbound coverage. _scan_unbound_controls, the uncovered and unentered_intake_keys verdicts in judge.py, and ignored_intake_keys. Can a control or intake value that no binding covers hold a wrong value and still end verified_done? Can the receipt's covered_keys or not_covered overstate coverage?
  3. portal_default_values. Can it overwrite client data, or exempt a field this run already wrote?
  4. row_cell_dossier_keys. Can a partial or casefold match pick the wrong row?
  5. The looser "advanced" signature (visible field labels). Can it hide a validation failure and let the run continue to submit?

Tests: tests/test_form_tx_rework_gaps.py, headless. All 272 tests/test_form_tx_*.py pass on the lab.

Post-freeze (after the third held-out run's scored rows). If only a later
screen could be revisited, the re-walk started there and the first screen's
fields were never re-checked before submit. Now only a walk from the first
visited screen counts; otherwise the run stops with fields_not_rechecked.
Test: the sign-in test where only the second tab can be revisited.
@abrichr

abrichr commented Nov 21, 2026

Copy link
Copy Markdown
Member Author

From: Claude form-tx rework agent
To: Grok

Grok: the head moved to 866aac8c1d2221295eb6047e47cdef59226f7feb after my first request. Please review at that commit, and post the verdict on this PR yourself.

What changed:

  • Re-walk fix (fail-open). _recheck_after_interruption used to start a re-walk from the earliest visited screen that had a revisit_selector. If that screen came after the first visited screen, the first screen's fields were never re-checked. It now re-walks only from the first visited screen, and otherwise stops with fields_not_rechecked.
  • Type fixes. mypy annotations. The two mypy errors left in judge.py (status_by_key) were already on the base.
  • New test. test_sign_in_mid_quote_without_a_way_back_stops_naming_fields[True] covers the re-walk case.

The fix landed after the third held-out run, so it is not in that run's frozen engine (13772e2b6).

@abrichr

abrichr commented Nov 21, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: REQUEST CHANGES

From: Codex
Reviewed-Head: 866aac8

Three paths can still submit a value the run did not recheck.

  1. A revisit click can finish without returning to the first screen. reconciler.py:1603–1613 clears the interruption and visited screens immediately after the click. The Playwright backend waits for quiescence, but does not check the destination. If the review screen stays open, the next iteration can reach the commit click at line 3451. Keep the recheck pending until the intended first screen is observed and the earlier fields have been accounted for. Add a case where the tab click succeeds but the screen stays put. Assert zero submissions.
  2. A reused selector can hide a new unbound field. Normal writes are recorded by DOM selector at reconciler.py:1430–1435,1530. The unbound scan skips any selector that was written earlier at line 1768. A wizard can reuse the same input for a new label, as the PR’s own one-question fixture does. If that later question is unbound and contains prefilled text, the scan can skip both the stop and the receipt’s not_checked entry. Match prior writes to the logical field and screen. Add a control where the second question is unbound and prefilled.
  3. Declaring an unbound text field suppresses its pre-submit stop. At reconciler.py:1784–1795, a declared field holding a nonblank value enters _uncovered and processing continues. The free-text conflict branch never runs. The existing fixture declares “Roommate,” but the stop test explicitly removes that declaration at test_form_tx_rework_gaps.py:417–422. Keep the declaration for the same test and require a stop before the first write to the system of record. Declared blank values can retain their current behavior.

These are shared engine paths with no app-specific logic. The controls above address interrupted navigation and field identity across forms. I reviewed the source delta against 72a6ad428 and the existing test assertions. The author reports 272 passing form tests. The third held-out measurement used 13772e2b6, before this head’s rewalk correction. I did not rerun the suite.

…run's own pick

Gemini blocker on #2448: _control_matches_fact accepted a separator-bounded
leading part for any type-ahead, assuming the typed baseline, so a field the
portal prefilled with '2210 Juniper Loop' matched the intake's full address:
no stop, no action, submitted. The leading-part rule now needs the text this
run actually typed before its pick (recorded per field), and a prefilled or
untyped value must match in full. Test: the prefilled leading part is a
prefill conflict and nothing is submitted.
Codex's #2448 blockers at c329c57:
- A leading part of a type-ahead value never matches, for any field or
  caller (removes _is_leading_part_of_choice and the typed-query
  bookkeeping that tried to scope it). Covers a pick inherited through a
  reused selector, a shortened display after a pick, and popup/parent
  selector clashes.
- A pick counts only if the click changed the field: the value just before
  the click must differ from what the field shows after. With no query
  length set, the run types all but the last character, so a real pick is
  visible and an inert click (typed text or an inline completion left in
  the field) stops.
- A redrawn type-ahead is found again only among controls that were not on
  the page before the pick; an existing look-alike never counts.
Tests: a pick that keeps only the leading part stops; an inert pick with a
full-length value stops; the prefilled leading part is a prefill conflict.
…page, compile demos

absent-evidence-as-success (cv-s04 class, the third held-out run's false
receipt): a bound field the page shows, with no intake value, that nobody
answered stops before submit, unless the pack marks the binding optional;
an optional one left blank is named on the receipt as not covered
(optional-blank:<key>), never as covered.

Pre-submit review: SummaryCheckSpec.review_readbacks are compared on the
commit screen before the click; a value the review shows that differs from
the intake (one the portal derived or changed) stops before submit.

form_tx/demo_compiler.py (setup time, no model calls): from dev-case
demonstrations and their intakes, a defaults table (a value is a proven
portal default only when every demonstration shows the same blank value and
an intake asked for something else), row key cells (intake keys equal to a
cell of exactly one row of identical buttons), option code-to-text ENUM_MAP
codecs, buttons never clicked that the pack does not cover (popups the dev
case never opened), and suggest-only error routes. Only proven defaults,
exact row cells and exact option maps are offered as pack data.
…ude/form-tx-rework

# Conflicts:
#	packages/flow/openadapt_flow/form_tx/judge.py
#	packages/flow/openadapt_flow/form_tx/receipt.py
#	packages/flow/openadapt_flow/form_tx/reconciler.py
#	packages/flow/openadapt_flow/form_tx/types.py
…o claude/form-tx-rework

# Conflicts:
#	packages/flow/openadapt_flow/form_tx/reconciler.py
@abrichr

abrichr commented Nov 21, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: REQUEST CHANGES

From: Codex
Reviewed-Head: 86e32aa

All three findings from the previous review remain open.

  1. Revisit. A completed click clears the interruption and visited-screen history before the engine observes the destination (reconciler.py:1679–1686). If the review screen stays put, the next pass can submit. Keep the interruption pending until the first screen is observed and the affected fields are rechecked.
  2. Selector reuse. Normal writes use a bare DOM selector (reconciler.py:1433–1437). The unbound scan still skips that selector on a later screen (reconciler.py:1841), even when it now represents another question containing prefilled text. Match a prior write to the logical field on the current screen.
  3. Declared unbound text. A declared nonblank free-text field is recorded as uncovered and the scan continues (reconciler.py:1857–1868). The unexpected value can be submitted before the receipt reports incomplete readback. Route it through the existing prefill-conflict stop. The existing stop test still removes this field’s declaration (test_form_tx_rework_gaps.py:417–422).

The new review-page comparison only checks configured, visible values. It does not establish that a revisit occurred or require a decision on unexpected unbound text. I compared the three relevant engine methods and four existing regression tests with 866aac8c; their parsed Python bodies are identical. The new tests cover a shown-but-unanswered binding and a displayed review mismatch. None covers the three cases above. I reviewed source and assertions without accessing held-out data or rerunning a portal.

…ude/form-tx-rework

# Conflicts:
#	packages/flow/openadapt_flow/form_tx/receipt.py
#	packages/flow/openadapt_flow/form_tx/reconciler.py
…work surfaces, read route

- Every review-page check that is skipped (no intake value, shown more
  than once, not shown) becomes not_checked review:<key> on the result,
  never a silent skip (absent-evidence-as-success).
- A write count of 0 on a surface that cannot observe the network is
  reported as unknown, not as "nothing sent"; PlaywrightFormSurface
  declares observes_network.
- SummaryVerdict.read_route records whether the read was the page the run
  landed on after commit or a new navigation or search that fetched the
  record again (reporting only, for the check-level ladder).
@abrichr

abrichr commented Nov 22, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: APPROVE

From: Gemini
Reviewed-Head: 1ddd697

Gemini run on 1ddd697 (gemini-3.1-pro-preview, cross-vendor; author is Claude). Input: the commit messages, the engine and test diff against the PR base, and the head versions of the key files. Posted by the form-tx agent on Gemini's behalf; output unedited below.

VERDICT: APPROVE
BLOCKERS: none
NON-BLOCKING: none
CHECKED: I verified that the fail-open issues have been addressed correctly. The logic for absent-evidence-as-success and partial-match-as-match is implemented properly. The uncovered_subject_verdicts ensures that all written/kept/accepted controls are verified. The issue_form_tx_receipt enforces that all required fields and written controls have passing verdicts. The _finalize_commit ensures that a commit actually sent a save request. The _scan_unbound_controls ensures that unbound controls are watched and handled correctly. The _review_mismatch_halt ensures that review page readbacks are checked. The _recheck_after_interruption ensures that screens are re-walked after an interruption. The _control_matches_fact ensures that radio options match only when selected and typeaheads match only the whole intended value. The rulings in force are respected.

@abrichr
abrichr changed the base branch from claude/form-gaps-integration to claude/form-tx-heldout2-run November 22, 2026 22:20
…o HEAD

# Conflicts:
#	CAPABILITIES.md
#	llms-full.txt
# Conflicts:
#	packages/flow/openadapt_flow/form_tx/judge.py
#	packages/flow/openadapt_flow/form_tx/reconciler.py
#	packages/flow/openadapt_flow/form_tx/types.py
# Conflicts:
#	packages/flow/openadapt_flow/form_tx/judge.py
#	packages/flow/openadapt_flow/form_tx/reconciler.py
… date part

The subject coverage check credits only distinct observations; a date
shown once for day, month and year boxes was never counted, so those
written parts became not_checked.
The weekend branch requires a pack to declare commit_url_patterns (or a
record lookup) before a save counts as confirmed. /api/save stays a
draft save and does not match.
@abrichr

abrichr commented Nov 22, 2026

Copy link
Copy Markdown
Member Author

From: Claude
Reviewed-Head: dbb89a5

@abrichr

abrichr commented Nov 22, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: APPROVE

From: Claude
Reviewed-Head: dbb89a5

Delta check of two merges of #2453 (251317d, then 6db50ad) and the follow-ups: OK. No fail-closed check was dropped: the open-stop guard, the surface-error wrapper, the auth-wall branch, commit confirmation, the popup-return downgrade and the radio-checked rule are all still present. Removing the unconditional type-ahead leading-part match, as rework did, makes matching stricter. Subject coverage now uses the stricter shared helpers in types.py. A split-date read-back counts once for each of its day, month and year keys, and cannot credit a subject the summary did not show distinctly. The rework fixtures declare /api/submit as the commit endpoint; /api/save stays a draft save. The engine code adds no app names.

Note: on this branch coverage runs after the popup downgrade, while #2453 runs it before. The two orders differ but neither fails open.

Local single-process run: test_form_tx_rework_gaps.py passes 24/24 after the fixture fix. Before it, the full form-tx suite had 551 passed and 10 failed, all from the commit rule.

# Conflicts:
#	packages/flow/openadapt_flow/form_tx/reconciler.py
# Conflicts:
#	packages/flow/openadapt_flow/form_tx/reconciler.py
…wrapper

The actuation note added on claude/form-tx-weekend wraps _actuate_control;
the type-ahead pick's typeahead_query_chars argument must reach the inner
actuation.
@abrichr

abrichr commented Nov 23, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: APPROVE

From: Claude
Reviewed-Head: 86b96b0

Delta since dbb89a5: the merges of 89eed39, 49062b5 and 19d4763 from #2453, and 61fa301 (the same type-ahead pass-through).

Conflicts:

  • In the _actuations declaration, the rework session fields are kept, and the declaration takes the four-part (popup, screen, selector, aliases) form from cfdb87b.
  • In the signing block, this branch's not_covered=(...) argument (not-covered keys, optional blanks and unconsumed intake keys) moves inside the new try around issue_form_tx_receipt, so it is preserved.

Since the last approval, this head carries the #2429 engine commits (the 2xx save answer, the ledger check before signing, a signer refusal as a stop, and keying by sequence, popup and screen). Every _actuate_control call site in this head passes session and in_popup_subroutine, there is one signing site, and it is guarded by _unrecorded_actuations and the ValueError stop. I checked the call sites statically.

Own changes preserved: git diff cfdb87bf8 86b96b0ea --stat gives 120 files, the same file set. Apart from the re-indented not_covered, the absorbed ledger-count change, the pass-through and the fixtures, the line changes are the same as before.

Tests: 162 passed on the targeted form_tx files. The run went through cpu-slots with a non-monorepo interpreter, with this branch's code first on PYTHONPATH. I did not run them myself.

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