Skip to content

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

Open
abrichr wants to merge 15 commits into
claude/form-tx-weekendfrom
claude/form-gap-5-expiry-radios
Open

abrichr wants to merge 15 commits into
claude/form-tx-weekendfrom
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).

…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.

# 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.

# 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.

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