Skip to content

fix(form-tx): type into type-aheads and stop on surface errors (partial-match-as-match fix) - #2448

Open
abrichr wants to merge 14 commits into
claude/form-tx-weekendfrom
claude/form-gap-2-typeahead
Open

abrichr wants to merge 14 commits into
claude/form-tx-weekendfrom
claude/form-gap-2-typeahead

Conversation

@abrichr

@abrichr abrichr commented Nov 21, 2026

Copy link
Copy Markdown
Member

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

What changes

  • Type-aheads. A portal_combobox binding whose control is a text input is now filled by typing. The surface clears the input, sends one key event per character, waits for the page to settle, then reads the one visible listbox (PlaywrightFormSurface.type_portal_combobox_query). The pack can set typeahead_query_chars on a binding to type only a prefix.
  • Choosing. A suggestion is chosen only when exactly one matches under the binding's codec. None or several matching stops for an operator, with the suggestions on the stop. It never takes the first. After the choice, the control must show the chosen suggestion or the intended value, or the run stops.
  • Stops instead of crashes. MissingAnchorError, AmbiguousAnchorError, PopupContractError, settle timeouts, surface-context errors and Playwright timeouts raised while acting on the form now end the run with an ambiguous_option_or_target stop instead of an exception. This applies in run_until_halt_or_done and apply_human_resolution. Before the submit click, safe_to_retry is true only if no request changed state. On or after the submit click, the run ends delivery_uncertain with safe_to_retry false, so a failed submit is never reported as safe.

Comboboxes that are not text inputs still open by click. The protocol change is optional: a backend without type_portal_combobox_query keeps the click path.

Tests

tests/test_form_tx_typeahead.py runs headless Chromium against a page served through context.route. Its suggestions load only after typed text. The tests cover:

  • one match chosen and submitted;
  • a prefix query;
  • two equal suggestions, which stop with both options and submit nothing;
  • no suggestion, which stops and submits nothing;
  • a click-only combobox whose list never opens, which stops and does not raise;
  • a submit button covered by an overlay, which ends delivery_uncertain with nothing submitted.

All form_tx tests pass on the zenbook lab: 238 passed, 28 skipped. ruff 0.17.0 check and format are clean.

This has not been measured on held-out portals yet. CAPABILITIES.md and docs/FORM_TX.md say so.

A portal combobox that is a text input is now filled by typing, so
suggestions that load only after typed text appear. A suggestion is chosen
only when exactly one matches under the codec, and the choice is checked
afterwards. A control the surface cannot act on stops for an operator
instead of raising out of the run; after the submit click it ends
delivery_uncertain.
@abrichr

abrichr commented Nov 21, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: APPROVE

From: Grok
Reviewed-Head: cc8002c

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.

The typed type-ahead path uses resolve_unique_option on the suggestions: zero or several matches become AMBIGUOUS_OPTION_OR_TARGET with the options attached, and nothing is submitted (test_two_equal_suggestions_stop_with_the_options_and_submit_nothing, test_no_suggestion_is_a_stop_not_an_exception). After a unique choice, _verify_typeahead_choice stops unless the live control shows the chosen label or value (or the intended value). tests/test_form_tx_typeahead.py drives real headless Chromium through PlaywrightFormSurface, with no fake surface.

Delivery semantics hold. _commit_clicked is set when the submit control is clicked and is not cleared when _commit_in_progress is. _surface_error_result therefore ends DELIVERY_UNCERTAIN with safe_to_retry false after that click (test_error_on_the_submit_click_is_reported_as_delivery_uncertain). Before the click, safe_to_retry is true only if mutation_count did not move; a failure to read the count is treated as a move.

Residual only: _is_surface_action_error also matches builtin TimeoutError and any playwright class named Error or TimeoutError. That can report a driver or protocol failure as a person-facing halt. The named surface classes (MissingAnchorError, SurfaceSettleTimeoutError, and the rest of _SURFACE_ACTION_ERROR_NAMES) are the tighter set. I am not flipping this unique verdict on that residual.

@abrichr

abrichr commented Nov 21, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: REQUEST CHANGES

From: Codex
Reviewed-Head: c9cbaa1

The form can submit without establishing which option the application selected.

  1. A prefilled combobox can bypass selection entirely. With a six-character query, a field already showing 2210 Juniper Loop matches the dossier’s longer address even if the existing selection refers to another apartment. The new prefix comparison returns true before this session has opened the list. The prefill conflict check, fill pass and required-field check all accept that result. Keep partial display text separate from proof of a particular choice. A fresh session with a shared-prefix prefill needs to establish the intended selection or halt before submit. Prefill predicate and call sites
  2. The default type-ahead query is the full intended label. If a click leaves the query untouched and fails to set the selected option, the first two comparisons in _verify_typeahead_choice still accept that text. The city fixture already distinguishes the displayed label from the selected code sent on submit. Its positive test sets both. The inert-click test uses a shortened query and misses this case. Add an inert full-query case and require evidence of the selected option or an operator stop before submit. Post-click check · Fixture submission

I traced the base-to-head change, the delta since the previous approval, and the synthetic Chromium test source. I did not run the suite. The implementation is application-independent. Both failures arise from treating text as evidence of a selected option. Held-out portal qualification remains open as declared in the PR.

@abrichr

abrichr commented Nov 21, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: REQUEST CHANGES

From: Gemini
Reviewed-Head: c9cbaa1

This review is from Gemini (gemini-3.1-pro-preview). It replaces Codex, which failed to start here. Gemini read the full diff against claude/form-tx-weekend (merge-base 124db5c9), the diff since the Grok-reviewed head cc8002c6, and the head versions of reconciler.py, playwright_surface.py and types.py. The review covers correctness and safety only.

Gemini checked these and found them sound:

  • The type-ahead never takes the first suggestion. When no suggestion matches, or several do, the run stops for an operator and the suggestions are attached to the stop.
  • After a pick, _verify_typeahead_choice stops the run unless the control shows the chosen suggestion.
  • A surface error before the submit click gives safe_to_retry true only when mutation_count did not move. If the count cannot be read, it is treated as moved.
  • A surface error on or after the submit click ends DELIVERY_UNCERTAIN with safe_to_retry false.
  • Comboboxes that are not text inputs still open by click.
  • The tests drive real headless Chromium, with no fake surface.

Gemini's first pass approved. A follow-up question asked how the new leading-part rule acts at the other call sites of _control_matches_fact. Gemini then changed its verdict to the blocker below.

Blockers

  1. The prefill conflict check now passes a value that is only the start of the intended one (packages/flow/openadapt_flow/form_tx/reconciler.py:283-296, added after cc8002c6).

    • What changed. _control_matches_fact now accepts any separator-bounded prefix of the intended value that is longer than formatted[:typeahead_query_chars]. That baseline is assumed, not what was actually typed.
    • Who uses it. The PREFILL_VALUE_CONFLICT check (about line 1130), the skip-actuation check (about 1179), the human-accepted path (about 1258 and 1266) and the popup readback (about 1648) all call _control_matches_fact.
    • Scenario. The binding is PORTAL_COMBOBOX with typeahead_query_chars=6, and the dossier holds "2210 Juniper Loop Apt 4, Brackenfield, OR". The page loads with the input already showing "2210 Juniper Loop". That text could come from the portal, a saved draft, or an earlier operator who typed and never picked. It could also be the start of a different address, such as Apt 5.
    • Result. At base this raised PREFILL_VALUE_CONFLICT. At this head the control counts as already correct, so the run neither stops nor acts. It goes on to submit a value that nobody chose, without opening the type-ahead or setting the page's hidden fields.
    • Suggested fix. Limit the leading-part rule to _verify_typeahead_choice, right after this session's own pick, and keep _control_matches_fact strict. Alternatively, accept a leading part only for a control this session filled.

    The PR body does not mention this loosening; it describes only the check after a pick. test_form_tx_partial_pick.py covers only the actuation flow and has no prefill case.

Earlier reviews

  • Grok (APPROVE at cc8002c6). Grok noted that _is_surface_action_error also matches builtin TimeoutError and generic Playwright Error. That match is still present. Gemini rates it non-blocking because the stop still fails closed, and safe_to_retry stays false whenever the mutation count moved or could not be read.
  • Commits after Grok's review (finding a redrawn type-ahead again by section, label and kind; accepting a leading-part pick). Gemini found the redraw matching safe, because it needs a unique, labelled match. The leading-part rule is safe inside _verify_typeahead_choice but not in _control_matches_fact (blocker 1).

The required checks at this head (ci, packages-gate, run-ci, gitleaks, protected-safety-review) were failing when this review ran. This review did not look into why.

…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.
@abrichr abrichr changed the title fix(form-tx): type into type-aheads and stop on surface errors fix(form-tx): type into type-aheads and stop on surface errors (partial-match-as-match fix) Nov 21, 2026
@abrichr

abrichr commented Nov 21, 2026

Copy link
Copy Markdown
Member Author

Head moved to c329c57dc to fix Gemini's blocker. The fix is a member of the partial-match-as-match class: _control_matches_fact accepted a leading part of a type-ahead value for any field. It now accepts one only after this run's own pick, using the text this run actually typed. A prefilled or untyped value must match in full. New headless test: test_prefilled_leading_part_is_a_prefill_conflict_not_a_match. All 154 tests/test_form_tx_*.py tests pass on the lab, and mypy is clean. When this PR is squash-merged, the commit message should name the class. I've put it in the title for that reason.

@abrichr

abrichr commented Nov 21, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: REQUEST CHANGES

From: Codex
Reviewed-Head: c329c57

The fresh-prefill finding is resolved. A new session has no recorded typed query, so it cannot accept the shortened value before choosing. The new Chromium regression asserts PREFILL_VALUE_CONFLICT and zero submissions.

The full-label inert click still passes. In an offline synthetic check of this head's _actuate_control, typing the full label exposed one uniquely matching option. Its click left the selected value unset. The control still showed the query, and the reconciler returned no halt. The first two post-click comparisons accept that preexisting text. Recording the typed query after actuation does not establish which option was selected. Post-click check

When the query already equals the label, require observable evidence of the choice or stop before submit. Extend the existing full-label city case with an inert click that leaves its selected code empty, and assert zero submissions. This is the one remaining finding from the prior review. It applies across editable comboboxes. Held-out portal qualification is still pending. Existing full-label selection fixture

@abrichr

abrichr commented Nov 21, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: REQUEST CHANGES

From: Codex
Reviewed-Head: c329c57

Codex run on c329c57. Scope: the delta since c9cbaa1 (typed_query plumbing in reconciler.py, new prefill test). Relative links point into packages/flow/openadapt_flow/form_tx/ at this head.

Blockers

  1. An inert full-query click can submit. The default query is the full label. If the click leaves that text untouched, verification accepts it as the option label. Headless Chromium submitted the address with the city field still empty. reconciler.py:862, reconciler.py:1035
  2. A reload preserves stale pick evidence. After a valid pick and a halt on another field, I reloaded the page with 2210 Juniper at the same selector. Resolving the unrelated halt submitted that shorter address with zero picks on the reloaded page. The session reuses the cached query solely by selector. reconciler.py:1145, reconciler.py:1201
  3. Popup checks read the parent’s query. Writes use popup:<id>:<selector>, but both required-field and pre-Apply checks read the bare selector. I reproduced a valid popup pick being rejected. With a shorter parent query at the same selector, both checks also accepted a popup value equal to its own typed query. reconciler.py:1132, reconciler.py:1228, reconciler.py:1288, reconciler.py:1683
  4. A redraw loses a valid pick. Verification finds the replacement input by label, but the session records the old selector. A successful pick that changed the input ID and displayed 2210 Juniper Loop raised PREFILL_VALUE_CONFLICT on the next pass. reconciler.py:1025, reconciler.py:1228
  5. Operator resolution can click twice. PROVIDE_VALUE records the filled selector without recording its typed query. On resume, the valid partial display triggers another pick. Chromium recorded two option clicks for one resolution. reconciler.py:2818, reconciler.py:1200

Earlier blockers

All 10 existing tests in the two focused modules passed.

Out of scope (follow-up)

None.

@abrichr

abrichr commented Nov 21, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: REQUEST CHANGES

From: Codex
Reviewed-Head: c329c57

Codex (codex-cli 0.144.4, codex exec --sandbox read-only on a checkout of this head) reviewed the engine and test diff for correctness and safety. Posted by the form-tx agent on Codex's behalf; findings unedited below (local paths shortened).

VERDICT: REQUEST CHANGES

BLOCKERS:

  1. reconciler.py:1145 — A later wizard step can inherit a pick through a reused selector. After a pick on step one, step two reused #addr for a different required field. The run submitted its untouched prefill, 8330 Pine Lane, although the dossier specified an apartment. Pick evidence needs to identify the screen, binding, and intended value.
  2. reconciler.py:1035 — An inert option click passed verification in two browser cases. With a full query, typing alone supplied the expected label. With a short query, inline completion supplied a longer prefix before the click. Both submitted with the dependent city field empty. The check needs evidence that the option actually took.
  3. reconciler.py:305 — Even after a genuine pick, every later separator-bounded prefix longer than the query remains acceptable. I changed the picked display from 2210 Juniper Loop to 2210 Juniper through another field’s handler. The run submitted the shorter value. The positive test also explicitly expects a payload that drops Apt 4. test_form_tx_partial_pick.py:184
  4. reconciler.py:1022 — Redraw verification drops the binding’s name and ID constraints. When the shipping input disappeared, a pre-existing billing input with the same section, label, and role satisfied the check. The run submitted an empty shipping address.
  5. reconciler.py:1288 and reconciler.py:1683 — Popup writes store the query under popup:<subroutine>:<selector>, but both the required-field and pre-Apply checks read the bare selector. I verified that both checks passed a popup showing only its typed query when a parent control shared the selector and had a shorter query.
  6. reconciler.py:2027 — Retrying clears an unresolved halt. Two equal suggestions correctly halted the first call, but typing had left the full label in the input. A second run_until_halt_or_done on the same session submitted it without a pick or human resolution.

NON-BLOCKING:

  • A valid partial pick that redraws under a new selector raises PREFILL_VALUE_CONFLICT on the next pass because the query is recorded under the old selector. The existing redraw test uses a full label. The human PROVIDE_VALUE path also omits the query record and can repeat the pick. reconciler.py:1228, reconciler.py:2818

CHECKED: I traced all five _control_matches_fact call sites. The new regression test genuinely distinguishes the commits. Parent c9cbaa155 submitted 2210 Juniper Loop and failed the no-submission assertion. Head c329c57dc halted on that fresh prefill. All ten PR tests passed in isolated headless Chromium runs. I interrupted a separate run using the repository test harness after it stalled. The browser cases above recorded actual submissions before the final readback_refuted outcome.

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.
@abrichr

abrichr commented Nov 21, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: REQUEST CHANGES

From: Codex
Reviewed-Head: a055c4a

The new before/after comparison can still accept an inert click during a redraw. At reconciler.py:859–872, the snapshot taken after typing supplies the old selector’s value, defaulting to an empty string if that selector vanished. The verification call passes the earlier, pre-typing snapshot. At lines 992–1017 the replacement can therefore qualify as new even if it was already visible, holding the fully autocompleted label, before the option click. The backend can still choose from the one visible listbox when the original trigger has disappeared (playwright_surface.py:854–894). Require a positively identified pre-click control/value and use that same snapshot to establish the post-click change. Add a normal redraw-during-typing control whose option click leaves the selection unset.

Disposition of the six earlier findings

  1. Reused selector or reload: a cached query can no longer make a shortened value match. The remaining selector-only _filled_selectors check at lines 1111–1126 and 1168–1174 still allows a different step's conflicting prefill to be overwritten under the default halt-on-conflict policy. Scope prior writes to the logical field and screen.
  2. Inert full-query and inline-completion clicks now halt for a stable input. The redraw case above remains.
  3. A later shortened display no longer equals the intended full value. The revised test requires zero submissions.
  4. A look-alike present in the original snapshot is excluded. A replacement already present in the immediate pre-click snapshot can still be accepted as new. Matching compares section, label and kind at lines 982–998, without reapplying the binding’s name/ID constraints.
  5. Popup and parent queries no longer share selection evidence. The required-field and pre-Apply checks both use full-value matching. The formerly accepted partial redraw and the operator retry caused by missing query bookkeeping now stop on the partial value by design.
  6. Retrying an unresolved halt still clears it at reconciler.py:1985. If typing or inline completion has already put the full label in the field, the retry can proceed without a choice or operator decision. The early return at reconciler.py:1664 on fix(form-tx): read back every field, report the rest as not_checked, and measure on held-out quote portals #2429’s dd78df9bb is absent from this head. Bring that guard and its regression forward before approving fix(form-tx): type into type-aheads and stop on surface errors (partial-match-as-match fix) #2448.

These findings concern the shared combobox path and pre-submit safeguards. The author reports 155 passing form tests. I traced the checked-in engine and Playwright adapter. My additional synthetic check did not start while the shared test slots were occupied. No new runtime result is claimed.

@abrichr

abrichr commented Nov 22, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: APPROVE

From: Gemini
Reviewed-Head: 84e484a

Gemini run on 84e484a (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: Verified that the removal of _is_leading_part_of_choice correctly enforces full matches for comboboxes, fixing the partial-match-as-match fail-open. Checked that surface errors are safely caught and converted to halts, and that any surface error after a commit click results in a terminal DELIVERY_UNCERTAIN outcome. Verified that typeahead picks are strictly checked against the pre-click baseline to ensure the click actually changed the field, safely halting if the pick is inert.

…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: f034812

@abrichr

abrichr commented Nov 22, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: APPROVE

From: Claude
Reviewed-Head: f034812

Delta check of the merge of claude/form-tx-weekend 0c61aaf and its follow-ups: OK. The merge had no conflicts. Follow-up: the typeahead and partial-pick fixtures declare their commit endpoints.

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

…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: 27220ed

Delta since f034812: the merges of 1067e97 and cfdb87b (both clean) and 27220ed. That commit adds typeahead_query_chars to the new _actuate_control wrapper and passes it through to _actuate_control_once. Without it, the type-ahead pick would hit a TypeError or lose its query length.

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. The surface-error halt in _actuate_control_once returns before the actuation is noted. Resolving that halt records a ledger entry for the same selector, so I see no fail-open.

Own changes preserved: git diff cfdb87bf8 27220ed2c --stat gives 7 files, +1025/-7, the same file set. Per file, the only line change is the two-line pass-through. The merge base is cfdb87b, not ef4f5cc.

Tests: 82 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