Skip to content

fix(form-tx): treat session expiry as a sign-in wall and unchecked radios as empty - #2447

Closed
abrichr wants to merge 44 commits into
mainfrom
claude/form-gap-5-expiry-radios
Closed

abrichr wants to merge 44 commits into
mainfrom
claude/form-gap-5-expiry-radios

Conversation

@abrichr

@abrichr abrichr commented Nov 21, 2026 •

Copy link
Copy Markdown
Member

Stacked on #2429 (base claude/form-tx-weekend). This fixes two of the engine gaps that the held-out quote-portal run found (packages/flow/benchmark/form_tx_heldout_run/RESULTS.md, findings 5 and 7).

Session expiry is a sign-in wall

Before this change, a session that expired during a step showed an error banner, and the run reported it as a portal validation error. The operator policy then had no sign-in to do, so the case was escalated.

  • A screen is a sign-in wall if it shows any of these:
    • a configured auth-wall element;
    • an editable password or secret field;
    • no configured signed-in landmark;
    • an error banner or dialog whose text matches UIProfileSpec.session_expired_text_patterns.
  • The patterns are profile data. The English defaults cover "session expired" or "timed out", "signed out" and "sign in again".
  • The main loop and every post-action error path check for a sign-in wall first. Those paths are next, missing next or commit buttons, and commit. When the check matches, the run stops as auth_required. The operator signs in and marks it fixed on screen, and the run resumes. If the banner is still showing, "fixed on screen" is refused.
  • If the wall appears after the submit request went out, the outcome is delivery_uncertain, and the only choices are escalate or abort. Resuming there could submit the record twice.

Unchecked radios read as empty

Before this change, an unchecked native radio read as holding its value attribute. Every radio therefore looked prefilled, so packs had to work around it.

  • An unchecked radio now reads as empty. The new ObservedControl.radio_value holds the radio's own value, and options lists the group's values and labels.
  • In match_anchor_in_snapshot, an anchor that matches several radios of one group resolves to one field: the checked radio, or the first one when none is checked. It no longer raises an ambiguity error.
  • RADIO_GROUP actuation finds the radio to click by its own value.
  • A required group with no intake value stops once, not once per radio.
  • Bindings that treat each radio as a checkbox still work. The read-back compares the checked state for those bindings.

Tests

The new tests/test_form_tx_expiry_and_radios.py runs headless Chromium against a small stdlib portal served inside the test. It covers six cases:

  • an expiry redirect to sign-in, with a banner and a password field, stops as auth_required, and sign-in followed by "fixed on screen" resumes to verified_done;
  • a banner with no password field stops as auth_required;
  • an unchecked group reads as empty and resolves to one field;
  • a required group with no intake value stops once;
  • a prechecked radio that contradicts the intake stops as a prefill conflict;
  • a group set from the intake reads back as passed and gets a receipt.

On the zenbook lab, all 238 tests/test_form_tx_*.py tests ran. 237 passed. The one failure is test_reference_human_solves_every_scored_case: the old portals' own reference driver hit a TargetClosedError when a popup closed during a click. That driver does not use the form layer, and the same test fails the same way when run on its own. ruff check and format are clean.

Nothing here has been measured on held-out portals yet. CAPABILITIES.md says so.

Follow-up (a5a1615, 52c1183): checkboxes and radios are set by a click and then re-read by name and value, so a page that rebuilds the control on change works, and a state that did not take stops the run. A fill that rebuilds the form's controls makes the layer look again before the next field. ARIA radios named by their own text and native radios followed by bare text get labels, ARIA radiogroups get group options and a group label (also for fieldset legends), an option with an empty label but a real value is no longer dropped, and "Select one" and similar placeholders read as empty. Tests: tests/test_form_tx_radio_followups.py (headless Chromium).

…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.
…dios as empty

An error banner or dialog whose text says the session ended is now a sign-in
wall (auth_required), checked before any error is read as a validation
failure, on every post-action path. After a submit request went out it is
delivery_uncertain and cannot resume. Patterns are UI-profile data
(session_expired_text_patterns) with generic English defaults.

Native radios sharing a name are one field: an unchecked radio reads as
empty, keeps its own value in radio_value and lists its group in options; an
anchor matching a group resolves to the checked radio; a required group with
no intake value stops once.
@abrichr

abrichr commented Nov 21, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: REQUEST CHANGES

From: Grok
Reviewed-Head: 53d29dc

First review of this PR, at the requested head, unique against #2429 124db5c9. Author is GitHub abrichr, not Grok. Review only; I am not merging.

Several of the asked rules hold. Unchecked native radios now have an empty current_value and keep their own value in radio_value; collapse_radio_groups is used in match_anchor_in_snapshot and in the ungrounded-required check, so one group is one field. A prechecked radio that contradicts the intake still stops (test_prechecked_radio_that_contradicts_intake_stops). Checkbox-kind bindings read back through ctrl.checked for native radios as well as for empty-valued checkboxes. Expiry patterns are searched only in banners and open dialogs, case-insensitive, and the tests drive real headless Chromium.

The commit-path fail-closed rule does not hold. _emit_validation_blocked does pass delivery_uncertain=not safe_to_retry into _emit_auth_wall, but run_until_halt_or_done step 2 always calls _emit_auth_wall(..., delivery_uncertain=False). After the submit click the code sets _commit_in_progress, and if the post-commit snapshot has a modal it continues to the top of the loop. A session-expired dialog or sign-in wall on that iteration is therefore AUTH_REQUIRED with FIXED_ON_SCREEN allowed and safe_to_retry true, which can resume and submit twice. There is also no auth-wall check on the no-error post-commit path: a login form or missing signed-in landmark without a banner or field error goes to _finalize_commit instead of DELIVERY_UNCERTAIN. The tests only cover expiry before any save, with resume allowed.

A second, narrower hole: radio_group_key is only name plus sorted option values, so two same-named groups with the same choices on one page (two forms with Yes/No) collapse to one representative and can hide a prechecked conflict in the other group.

@abrichr

abrichr commented Nov 21, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: REQUEST CHANGES

From: Grok
Reviewed-Head: 950a75d

Re-review at the current head (the assigned 4ee5ce9e plus 3157013f7 and 950a75dce). Prior REQUEST CHANGES was at 53d29dc3. The unique work since then is checkbox/radio re-render, ARIA and bare-text labels, broader placeholders, and finding a redrawn control by section, labels, kind and value when its name or id changed. It does not fix the commit-path holes from the last review.

run_until_halt_or_done step 2 still calls _emit_auth_wall(..., delivery_uncertain=False) at the post-commit auth wall, so a continue after save can still be offered as FIXED_ON_SCREEN resume. A login form without banner errors can still reach _finalize_commit. Those still have to be closed.

The unique radio/checkbox work is mostly sound and fail-closed. set_checkbox_or_radio clicks instead of using Locator.check, then re-finds a native control by name plus value (or the original selector) and re-reads the state. If that selector is missing or ambiguous, it falls back to the one visible control whose section, group label, label, kind and radio_value still match; if that identity was unlabelled, missing, or not unique, or the state did not take, it raises SurfaceStateError, and the reconciler turns that (and CodecValueError) into a person stop. A fill that disappears a visible selector, or a binding marked triggers_re_render, now re-observes before the next field. ARIA radios get a radio_group from their radiogroup container (or parent) and can be matched by group_label. A radio whose label is a bare text node is no longer treated as a placeholder just because the label is empty. "Select one"-style placeholders are recognized by value, or by a non-empty label, which is the right split.

Two residuals, neither of which is the blocker. radio_group for a native group is still 'name:' + name plus the sorted option values, with no form identity, so two same-named groups with the same choices can still collapse. "Select" as a default placeholder string is broad: a real option whose label is Select would be dropped.

No merge from me.

@abrichr

abrichr commented Nov 21, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: REQUEST CHANGES

From: Grok
Reviewed-Head: 8c97227

Re-review at the current head (moved since 950a75dc, prior REQUEST CHANGES 7061377417). The unique commits are dcaa630a8 and 8c9722791: labels taken from the previous table cell when a control sits alone in its cell, and "Choose" / "-- Choose one --" treated as empty placeholders. The commit-path holes are still open.

run_until_halt_or_done step 2 still calls _emit_auth_wall(..., delivery_uncertain=False) at the post-commit auth wall, so a continue after save can still be offered as FIXED_ON_SCREEN resume. A login form without banner errors can still reach _finalize_commit. Those still have to be closed.

The unique table-label work is sound and fail-closed where it is specified. A radio or checkbox is not labelled this way. The control must be the only one in its cell, and the previous non-empty td/th must hold no control; two inputs that share a cell take no neighbouring text. "Choose" as a selected option value reads as empty, consistent with the other placeholder strings. Residual, not the blocker: "Choose" and "Select" as default placeholder labels remain broad.

No merge from me.

@abrichr

abrichr commented Nov 21, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: APPROVE

From: Grok
Reviewed-Head: 8f4070f

Re-review at the current head (moved since 8c972279, prior REQUEST CHANGES 7061734536). Commit 459a94b77 closes the two commit-path holes.

_commit_attempted is set when the commit control is clicked and is never cleared. Step 2 now passes delivery_uncertain=(session._commit_attempted or session._commit_in_progress) instead of hard-coded False, so a sign-in wall after the submit click is not offered as a FIXED_ON_SCREEN resume. _finalize_commit checks _auth_wall_reason first, with or without a banner, and emits that wall rather than treating the login page as a finished save. delivery_uncertain there is true when the commit was attempted or mutations rose after the pre-commit count. _emit_validation_blocked also treats a post-commit wall as uncertain.

Native radio groups are now keyed by name plus the owning form (or shadow root, or document), so two same-named groups in different forms stay apart. The overly broad "Select" placeholder string was removed. "Choose" remains as a default placeholder; that is a residual, not a blocker.

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.
# Conflicts:
#	packages/flow/openadapt_flow/form_tx/reconciler.py
…o-filled controls from the ledger

A radio group got one ledger subject per option it touched, leaving one
uncovered. Use the group's first option as its selector (as on
claude/form-tx-rework, 5798bbc). The signer requires fields_filled_auto
to equal the distinct auto_fill subjects; a control filled again after a
sign-in counted twice and made the signer raise. Derive the count from the
same ledger.
…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: 9912b15

@abrichr

abrichr commented Nov 22, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: APPROVE

From: Claude
Reviewed-Head: 9912b15

Delta check of the merge of claude/form-tx-weekend 0c61aaf and its follow-ups: OK. The conflict in reconciler.py was resolved keeping both the replaced-controls re-snapshot and kept_matching recording. Follow-ups: one subject per radio group (as on claude/form-tx-rework 5798bbc); the receipt's fields_filled_auto comes from distinct auto_fill ledger subjects; fixture packs declare commit endpoints. Non-blocking: that count is now tautological with the signer check on the reconciler path, so a reconciler-side assertion would restore an independent check.

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/CHANGELOG.md
# Conflicts:
#	packages/flow/openadapt_flow/form_tx/reconciler.py
@abrichr

abrichr commented Nov 23, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: APPROVE

From: Claude
Reviewed-Head: a8ad6fa

This head is a8ad6fa, a further merge of ef4f5cc on top of 4926431. Delta since 9912b15: two merges of claude/form-tx-weekend, with no new commits of this branch's own.

Conflicts:

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 ef4f5cc88 a8ad6faed --stat gives 12 files, +1679/-95. Apart from the absorbed change and the row move, the file set and line changes are the same 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: Gemini
Reviewed-Head: a8ad6fa

Independent cross-vendor review of claude/form-gap-5-expiry-radios (stacked on claude/form-tx-weekend).

What was verified

  • Pre- vs post-commit session expiry: _auth_wall_reason() evaluates configured auth-wall selectors, visible editable secret fields, missing authenticated landmarks, and UIProfileSpec.session_expired_text_patterns before reading banners/modals as validation errors. Sticky ReconcilerSession._commit_attempted = True ensures a sign-in wall after submit resolves to non-resumable delivery_uncertain rather than risking a duplicate write.
  • Radio groups & table labels: Native radio groups collapse into one subject (collapse_radio_groups, _subject_selector), unchecked radios read as empty instead of their value attribute, and judge.py handles radio boolean checks cleanly.
  • Tests & generality: All 4 flow unit shards pass in CI (test_form_tx_expiry_and_radios.py, test_form_tx_post_commit_auth.py, test_form_tx_radio_followups.py, test_form_tx_table_labels.py); zero per-app engine code; honestly notes in-test synthetic coverage (not yet measured on held-out portals).
  • CI note (merge blocker outside this PR's logic): launcher / run-ci fails only test_build_capabilities.py (stale CAPABILITIES.md.sha256 after editing 0115-*.md). Refresh capabilities stamp when syncing/retargeting to main.

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