Skip to content

feat(flow): links, tabs and menu items as steps; the commit point is the step the demo saw writing - #2499

Open
abrichr wants to merge 3 commits into
claude/fail-open-generalfrom
claude/gui-link-steps
Open

abrichr wants to merge 3 commits into
claude/fail-open-generalfrom
claude/gui-link-steps

Conversation

@abrichr

@abrichr abrichr commented Nov 22, 2026

Copy link
Copy Markdown
Member

What this adds

The Set 4 v2 held-out run (#2464) stopped one clean case because its next control was a link, and the packs could only name buttons. This change makes links, tabs and menu items steps in the core engine, and works out which step commits from what the demonstration showed it doing.

  • openadapt_flow.gui, a neutral view of a screen. Controls carry a role, a name, a value or checked state, and the containers they sit in. Adapters build that view from:
    • a browser page (gui.dom), where links are now included;
    • an accessibility tree (gui.adapters.screen_from_tree), for desktop apps and the spreadsheet test surface;
    • a form_tx snapshot (screen_from_form_snapshot), so the form layer can call this without a rewrite.
  • gui.steps.learn_steps. Each demonstrated click on a button, link, tab or menu item gets a role from what the backend counted. It is a commit when writes were counted, a navigation when the screen changed with no write, in place when neither happened, and unknown when the backend could not count writes. Its words are never read, and the engine adds no new "save" word list.
  • gui.steps.take_step and judge_step. A learned step is resolved on the live screen and clicked, then judged against the demonstration.
    • A missing control, an ambiguous one, or a link whose pinned target changed is never clicked.
    • A commit holds only on exactly the demonstrated number of writes.
    • A navigation that wrote, or that left the screen as it was, is refuted.
    • A backend that cannot count writes never attempts a commit.
  • judge_step is a @verdict_site with a fail-open spec (tests/failopen/sites/gui_steps.py).

A commit drawn as a plain GET link shows no write unless the pack declares its request path (PageActuator(write_get_paths=...)). Without that declaration the link is learned as a navigation, so the program has one commit point fewer and the caller's no-commit rule still stops the run. That is deliberate: a request nobody counted is not evidence that anything was saved.

Tests

tests/gui/test_gui_steps.py has 14 tests. Each app is recorded once through the backend a run uses, then replayed with other values. The negative cases change the app after the demonstration.

App kind What is checked
Web form (registration wizard) "Continue" is a link and learned as a navigation; "Register" commits. A replay with new values saves the new record. A link that starts posting is refuted. A commit with two writes, or with an error shown after it, is refuted. A renamed, doubled or retargeted link is never clicked.
EMR-like chart "Sign note" is a GET link. It is a commit only when its request path is declared; otherwise it is a navigation. With the path declared, the replay signs the new note.
SaaS settings Tabs are navigations; a "Publish changes" link that posts is the commit.
Spreadsheet-like grid (no browser, read as an accessibility tree) A sheet tab navigates and a Save menu item commits. A backend that cannot count writes never clicks Save.

The fail-open harness runs every generic mutation against judge_step. A hand-made fail-open copy, one that accepts >= the demonstrated writes and coerces counts, fails M5, M10, M15 and P0. The fold ratchet is unchanged.

Everything is synthetic, headless Chromium on the Mac, run single-process. No app is named in engine code, and no fixture copies a held-out portal.

Base and what is not here

…the step the demo saw writing

Adds openadapt_flow.gui, a neutral view of a screen (controls by role, name,
state and containers) with adapters for a browser page (links included), an
accessibility tree and a form_tx snapshot. gui.steps learns each clicked step's
role from what the backend counted in the demonstration (commit, navigate,
in place, unknown), never from its words, and judges a live step against it.
judge_step is a registered verdict site.
… an in-place step that moves the screen

From Gemini's review of #2499. A navigation must be shown not to write, so
without a write count no step is judged and none is clicked. An in-place step
that moved the screen did something the demo did not.
@abrichr

abrichr commented Nov 22, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: REQUEST CHANGES

From: Gemini
Reviewed-Head: c6d6cb1

Gemini run on c6d6cb1 (model gemini-3.1-pro-preview, finish reason STOP). It was sent the full diff against the base branch, every changed Python file at head, the verdict kernel, the harness and the PR description.

Blockers

  1. packages/flow/openadapt_flow/gui/steps.py:279: Actions taken before a stop is decided. If the backend cannot count writes (w0 is None), judge_step will unconditionally return NOT_CHECKED for all roles, because it requires write counting to prove that a step didn't write. However, take_step only prevents clicking if the role is COMMIT. For NAVIGATE or IN_PLACE, it proceeds to click the control and then returns NOT_CHECKED. Clicking a control when we already know the step cannot be verified and will fail the run is a violation.
    Fix: Change the condition to abort for all roles if writes cannot be counted:

        if w0 is None:
            return StepOutcome(
                Result.not_checked(subject, "this backend cannot count writes; no step can be judged"),
                False,
                ctrl,
            )
  2. packages/flow/openadapt_flow/gui/steps.py:214: A pass on mismatched evidence (false pass). An IN_PLACE step means the screen did not change in the demonstration. If it changes during replay (ev.moved is True), it is doing something different (e.g., navigating away instead of staying on the page) and must be refuted. Currently, judge_step only checks ev.moved for NAVIGATE and will return HELD for an IN_PLACE step that moved the screen.
    Fix: Add a check for ev.moved when the role is IN_PLACE:

        elif role is StepRole.IN_PLACE:
            if ev.moved is True:
                return Result.refuted(subject, obs, "an in_place step moved the screen")

    (Note: You will also need to add "moved" to RELEVANT["in_place"] and a negative seed in tests/failopen/sites/gui_steps.py to satisfy the fail-open harness).

Non-blocking

None.

@abrichr

abrichr commented Nov 22, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: APPROVE

From: Gemini
Reviewed-Head: f72b015

Gemini run on f72b015 (model gemini-3.1-pro-preview, finish reason STOP). It was sent the full diff against the base branch, every changed Python file at head, the verdict kernel, the harness, the PR description and the round-one findings (both fixed in f72b015).

Blockers

None.

Non-blocking

None.

@abrichr

abrichr commented Nov 22, 2026

Copy link
Copy Markdown
Member Author

From: Claude
Reviewed-Head: f72b015

Author declaration: Claude wrote the changes on this branch up to and including f72b015. The Gemini review above is the cross-vendor review for this head.

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