Skip to content

fix(form-tx): read back summaries shown as page text - #2449

Closed
abrichr wants to merge 39 commits into
mainfrom
claude/form-gap-1-text-readback
Closed

abrichr wants to merge 39 commits into
mainfrom
claude/form-gap-1-text-readback

Conversation

@abrichr

@abrichr abrichr commented Nov 21, 2026

Copy link
Copy Markdown
Member

Stacked on #2429 (base claude/form-tx-weekend). First of five PRs that close the engine gaps found by the held-out quote-portal run.

Problem. A confirmation page that shows the stored quote as text, not in form controls, could not be read back. Every field ended not_checked, so no case could be verified.

Change.

  • The Playwright snapshot also collects label and value pairs from page text: definition lists, two-cell table rows, tables with one header row and one data row, and "Label: value" text. Open shadow roots are read; closed ones are not.
  • The pairs live in FormSnapshot.text_pairs, apart from controls, so the fill pass, required-field stops and anchor matching never use them.
  • When a read-back anchor finds no control, the judge falls back to the pairs, by label_patterns (and section_patterns) only:
    • a label shown twice is not_checked, even when the values agree;
    • an empty or placeholder value is failed;
    • a different value under the codec is failed;
    • the same value is passed, and the reason says it came from page text.
  • Outputs such as a quote number fall back the same way. A control always wins over page text.
  • Nothing is weakened: popup inputs re-read before apply stay not_checked.

One general mechanism; no application names in engine code.

API. New ObservedTextPair, FormSnapshot.text_pairs, match_text_pair_in_snapshot.

Tests. tests/test_form_tx_text_readback.py, headless Chromium against pages served through context.route: each of five layouts (definition list, table rows, header table, "Label: value" lines, definition list in a shadow root) verifies with a receipt when it matches, is refuted when it shows a different value, fails on an empty value, and is not_checked on a duplicated label; page text on a form page never becomes a control. 19 passed. All tests/test_form_tx_*.py on the lab: 250 passed, 1 failed (test_reference_human_solves_every_scored_case, the old portals' own reference driver, which fails the same way on the base branch). ruff clean.

Not measured yet on held-out portals; CAPABILITIES.md says only what the mechanism does.

…rest as not_checked

The judge covered pack bindings and facts, not what the run wrote. Fields
typed inside a popup estimator had no verdict at all, so a run could end
verified with a signed receipt while those fields were never checked.

- Record every write (auto fill, operator value, kept prefill, fixed on
  screen, popup return) in a per-session ledger; the judge gives each one a
  verdict.
- Add a third verdict status, not_checked, for a field with no declared
  read-back, a missing or ambiguous summary control, or a failed lookup. It
  is never passed.
- Add the readback_incomplete outcome: submitted, nothing contradicted, but
  at least one field unchecked. No receipt; receipts and verdict models
  refuse to pass with an unchecked field.
- Re-read popup inputs just before the popup's apply button, since the
  summary usually does not show them; a mismatch stops before apply.
- Side panel shows refuted and incomplete runs as needing action.
…apply

A re-read of the popup before its apply button guards the apply, but it is
not a read-back of what the application recorded. Report those fields as
not_checked. Key the write ledger by field, selector and popup so a popup
input never hides a main-form write of the same key. The historical
underwriting fixture now ends readback_incomplete: its estimator inputs are
never shown.
A confirmation page that shows the stored quote as text, not in form
controls, left every field not_checked. The snapshot now also collects label
and value pairs from definition lists, two-cell table rows, one-row header
tables and "Label: value" text, including inside open shadow roots. They are
kept out of the controls, so nothing fills or halts on them.

When a read-back anchor finds no control, the judge falls back to these
pairs by label: a label shown twice is not_checked, an empty or different
value is failed, the same value is passed. Outputs such as a quote number
are read the same way. Popup inputs re-read before apply stay not_checked.
@abrichr

abrichr commented Nov 21, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: REQUEST CHANGES

From: Grok
Reviewed-Head: 4a15620

Unique work versus #2429 (124db5c98): confirmation-page label/value pairs collected into FormSnapshot.text_pairs, judged only when a read-back or output anchor finds no control.

The judge policy is sound and fail-closed where it is specified. A label that matches twice is not_checked even if the values agree. An empty or placeholder value is failed. A codec mismatch is failed. A unique matching pair is passed, and the reason says it came from page text. A control always wins over page text. _read_text_pairs returns an empty tuple on evaluate failure, so those read-backs end not_checked, never passed. text_pairs are not consulted by match_anchor_in_snapshot, the fill pass, or required-field stops (only SummaryJudge and output extraction call match_text_pair_in_snapshot). Engine code has no application names. The Chromium tests cover the five layouts for match, mismatch, empty value, and (except the one-row header table) a duplicated label, plus a check that page text on a form page is not a fill target.

The extractor can still attribute the wrong value to a label, which the judge will then treat as a real unique pair.

In the definition-list walk, a dt/dd that is not isShown is skipped entirely and does not flush the pending labels. A hidden or display:none dd after a dt therefore leaves those labels open, and the next visible dd is joined onto them. Example:

<dt>Middle name</dt>
<dd style="display:none"></dd>
<dt>Last name</dt>
<dd>Smith</dd>

Both labels are emitted with value Smith. If a declared read-back for Middle name expected Smith (or any value equivalent under the codec), the judge would pass a unique pair that was never shown for that label. The same shift happens if a page omits an empty dd and the next dd is consumed while prior dts are still pending, but the hidden-dd case is the clear fail-open: isShown was written so empty values still count, yet a hidden empty dd does the opposite of counting as empty. A skipped dd after a dt has to count as an empty value (or otherwise flush) so a later dd cannot be inherited.

A lesser residual: the inline Label: value line rule only drops a value that starts with // (protocol-relative URLs). That is fail-closed for https://... text mistaken as a label, and is not the blocker.

The optional declared read-back with no expected fact and an empty/placeholder shown value still issues no verdict. That is the inherited #2429 hole; this change extends the same fact is None path to text pairs and does not close it.

No merge from me.

@abrichr

abrichr commented Nov 21, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: APPROVE

From: Grok
Reviewed-Head: 4a3bf0e

Re-review at the current head (moved since 4a156209, prior REQUEST CHANGES 7061370076). The unique commit 4a3bf0eb closes the hidden-dd pairing hole.

A dt/dd that is not shown is no longer skipped. A hidden dd after a dt is recorded as an empty value and flushes that group, so a later dd cannot be inherited. A hidden dt starts a group whose following dd values are dropped rather than joined onto a visible neighbour. The new Chromium test is the previously failing case (Middle name hidden-empty, Last name = Smith, hidden Suffix / Jr dropped, City intact). Duplicate-label not_checked now also covers the one-row header-table layout.

The earlier judge policy is unchanged and still fail-closed: a label shown twice is not_checked, empty or different is failed, a unique match is passed from page text, and a control still wins over page text. The optional declared read-back with no expected fact and an empty shown value still issues no verdict; that remains the inherited #2429 hole and does not flip this unique fix.

No merge from me.

…as key material

check_evidence_keys denies any tracked file named like a key, and
answer_key.json matched. The file is now answers.json and the manifest field
answers_sha256; contents and sha256 are unchanged. The four gitleaks
generic-api-key findings on the old manifest lines (digests, not keys) are
pinned in .gitleaksignore by commit, file and line.
…mary is not_checked

Grok and Gemini blocker on #2429: a field the run wrote, declared in
field_readbacks, with no expected fact, shown empty or as a placeholder and
not required_in_pack got no verdict, so a run could reach verified_done
with a receipt. It is now not_checked. Headless test included. RESULTS.md
points at the arm A rows in arm_A_full.log.
…by class

Codex's #2429 blockers and the database-access review, fixed as classes at
the single aggregation points, shaped for the coming verdict algebra
(claude/fail-open-general):

absent-evidence-as-success
- judge: every written, kept or operator-accepted control is a Subject keyed
  by where it is (popup, selector, entity row), never by dossier key. One
  verdict accounts for one subject; any subject left without a verdict is
  not_checked (read_subjects, uncovered_subject_verdicts). Covers two
  controls holding one key, an accepted entity row, and a popup input that
  already held its value (now recorded as kept_matching).
- receipt: the signer refuses verified_done without per-field verdicts, all
  passed, covering every bound field the dossier has a value for (one
  passing field is partial, never verified).
- reconciler: a single-screen form with no commit control finalizes only if
  the page saved something during the run; a run with an open stop does
  not move until apply_human_resolution decides it.
- e2e: uw_06 and the underwriting cases assert the saved record against the
  server oracle on its own.

partial-match-as-match
- judge: a radio option matches only when it is selected.

evidence labelling
- read-back is labelled by who produced it (readback_evidence:
  acting_session_reread, separate_session_read, operator_attested); the
  judge reads through the acting session, so nothing calls it independent.

compatibility
- v1 receipts signed before readback_not_checked_count/readback_evidence
  existed still verify, and form_tx_receipt_format labels them older.

docs
- RESULTS.md pins the engine-freeze diff to the measured commit 124db5c.
…-evidence-as-success, partial-match-as-match)

Codex's delta review at dd78df9:

absent-evidence-as-success
- Coverage counts distinct observations: two read-backs that resolve to the
  same summary control account for one subject, and the write ledger keys
  controls by screen too, so a selector reused on another screen is another
  subject.
- One subject per accepted entity row, not per table.
- A control that already held its value is recorded (kept_matching) under
  every prefill policy, an unchecked box meant as "no" included; the popup
  pre-apply check finds each write's binding by its selector, not its key.
- A commit click that sent no save request is delivery_uncertain, never
  finalized; a single-screen form with no commit control always stops.
- The signer refuses a verified receipt on the digest-only path, requires a
  passing verdict for operator-supplied keys too, and derives the signed
  count from the verdicts.
- A repeated call on an open stop is never more retryable than that stop.
- Receipt encodings follow field presence as signed: a later v1 field
  present on the wire is always encoded; one absent marks the older format;
  an older receipt's reader is reported as unknown.

partial-match-as-match
- A radio option matches in reconciliation only when it is selected, and
  an unselected option reads as empty.

docs
- The synthetic portal docstrings no longer call same-session reads
  independent.
…t-evidence-as-success)

Codex's review at be4ee06, items 5 and 6:
- A commit finalizes only with evidence of a save: a state-changing request
  the server answered with 2xx/3xx after the click (counted from responses,
  not request starts), and the page no longer on the uncommitted commit
  screen. Otherwise delivery_uncertain, never verified.
- The signer checks coverage of the individual subjects (every written,
  kept or accepted control, popup inputs included) with the same coverage
  pass as the judge, and refuses a verified receipt without the run's
  writes.
Follow-up, filed for the fail-open fuzzer (same class, not fixed here):
public serialization of an older receipt expands the defaulted reader
field and loses the field-presence information verification uses.
…and bind signer to auto-fill subjects and judge ledger
…subject source with exact auto-fill equality
# Conflicts:
#	.gitleaksignore
#	llms-full.txt
#	packages/flow/CHANGELOG.md
#	packages/flow/public-artifacts.json
026326e made save confirmation fail closed unless a pack declares
commit_url_patterns or a record-specific lookup. The two synthetic
portal packs and the copilot runtime test pack declared neither, so
every commit was refused as unconfirmed. Declare each fixture's commit
endpoint as pack data; the engine check is unchanged.
…ct coverage

The coverage check credits each subject only with a distinct observation.
Values shown as page text (not in a control) were never counted, so every
text read-back became not_checked. Two read-backs on the same shown pair
still count once; an ambiguous pair counts none.
…s read their reply

The weekend branch requires a pack to declare commit_url_patterns (or a
record lookup) before a save counts as confirmed. Fixture submit handlers
that navigated without reading the reply aborted the request after its
2xx, which the surface records as a failed save.
@abrichr

abrichr commented Nov 22, 2026

Copy link
Copy Markdown
Member Author

From: Claude
Reviewed-Head: a9a3fdf

@abrichr

abrichr commented Nov 22, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: APPROVE

From: Claude
Reviewed-Head: a9a3fdf

Delta check of the merge of claude/form-tx-weekend 0c61aaf and its follow-ups: OK. The merge had no conflicts. Follow-up: judge.py counts a page-text read-back pair as an observation for subject coverage (an ambiguous pair counts none; credit stays capped at the number of verdicts). The fixture declares its commit endpoint.

Local single-process runs (load under 15) passed on this head.

…e reply body

The surface marked a save as failed when the request failed after its
status arrived. That happens whenever a page does `await fetch(); location
= ...`: leaving cuts off the reply body. No save decision reads the body,
so the status and headers are the answer; a request that never got a
status still fails.
…nt fills from the ledger; a signer refusal is a stop

- Every control the reconciler actuates is noted apart from the write
  ledger. Before signing, each must be in the ledger (a radio option may
  be named by its group); otherwise the run ends readback_incomplete with
  no receipt.
- The receipt's fields_filled_auto is the number of distinct auto-filled
  controls in the ledger, so a control filled again after a sign-in or a
  re-render is one field.
- A signer refusal (ValueError) ends the run readback_incomplete instead
  of raising, including from apply_human_resolution.

Tests pin the await-fetch-then-leave pattern with a reply that is still
streaming, a save with no status, an actuation missing from the ledger,
a planted signer refusal after a human decision, and a re-filled control.
…a client abort; actuations keyed by popup and screen

Review follow-ups:
- The answered flag is keyed by the request's sequence number and cleared
  with the counter, so a reused object id cannot turn a later failed save
  into a cut-off reply. A request that failed after its status counts as a
  cut-off reply only when the browser reports a client abort; any other
  failure still vetoes the save.
- An actuation is covered only by a ledger entry in the same popup and on
  the same screen, as the ledger keys its subjects.

Tests: a later save with no status vetoes an earlier 2xx; a ledger entry
for the same selector in another popup does not cover an actuation.
# Conflicts:
#	packages/flow/openadapt_flow/form_tx/playwright_surface.py
# Conflicts:
#	packages/flow/CHANGELOG.md
@abrichr

abrichr commented Nov 23, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: APPROVE

From: Claude
Reviewed-Head: 247924d

Delta since a9a3fdf: the merges of 1067e97 (clean) and cfdb87b. The one conflict, in playwright_surface.py, keeps both module-level blocks, _TEXT_PAIRS_JS and _CLIENT_ABORT_MARKERS/_is_client_abort, with nothing dropped.

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 247924daa --stat gives 8 files, +891/-10, the same file set, and every file has the same line changes as before.

Tests: none were reported for this head, and I did not run any.

@abrichr

abrichr commented Nov 23, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: APPROVE

From: Grok
Reviewed-Head: 6506b15

Cross-vendor re-review at the current head. My last verdict was APPROVE at 4a3bf0eb976932af30c93f8ad458355bb92e969b (#2449 (comment)). The PR is open and its head matches this SHA. The base is claude/form-tx-weekend (#2429, at b813c508). Against that base the diff is 8 files, +891/−10. I will not merge this PR.

What changed since 4a3bf0e

Leaving aside merges, there are two PR commits:

  • 0a3b82e45 (judge.py, +11). A value shown as page text, matched by match_text_pair_in_snapshot, now counts as an observation for subject coverage. It is keyed text|source|section|label, so two read-backs on the same shown pair count once, and an ambiguous pair (AmbiguousAnchorError) counts none. This only affects how many distinct observations coverage credits. It does not create a passed verdict: each field still needs its own value comparison in the read-back loop, and passed still requires zero failed and zero not_checked. Without this change, every text read-back was not_checked, which failed closed but was useless. The change is not fail-open.
  • a9a3fdf8c: tests only. Each fixture declares its commit endpoint, and the submit handlers read their reply. No assertion was loosened.

Generality gate: matching is by anchor, section and label from the pack. Nothing is tied to an app or a fixture.

Tests at this head (Python 3.12, in-tree flow and types)

test_form_tx_text_readback.py, test_form_tx_fail_open_classes.py, test_form_tx_reconciler_and_receipts.py, test_form_tx_written_field_no_fact.py, test_form_tx_save_answer.py: 72 passed.

CI at review time

28 pass, 23 skipping, 1 pending (packages-gate), 2 failing: Evaluate protected-path evidence / protected-safety-review with "pull request base must be main". That is expected while this is stacked on #2429. After #2429 lands, the retargeted PR needs those to pass at its then-current head.

Base automatically changed from claude/form-tx-weekend to main November 23, 2026 22:25
@abrichr

abrichr commented Nov 24, 2026

Copy link
Copy Markdown
Member Author

Architectural pivot (founder Option 1, 2026-11-23): freezing the hand-written form-tx DOM heuristic and word-list stack to focus on openadapt wrap + demonstration-derived CheckpointSpec + Cross-Tab Entity Ledger + GUI-to-API/MCP promotion. Branch preserved for reference.

@abrichr abrichr closed this Nov 24, 2026
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