Skip to content

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

Merged
abrichr merged 22 commits into
mainfrom
claude/gui-link-steps
Nov 24, 2026
Merged

abrichr merged 22 commits into
mainfrom
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

Fail-open blockers kept coming back one PR at a time. This fixes the
classes once:

- openadapt_flow/verdict.py: obligations fixed from the plan, settle(),
  allow-list codes, run binding, trust labels. An empty set, a short read,
  a raised probe, another run's result or an unknown code never passes.
- tests/failopen: 13 generic mutations run against every @verdict_site.
  The self-test flags 14 historical bugs rebuilt from this repository's
  code and passes their fixes; three live sites on main are strict xfails
  owned by #2470, #2258 and the connector status follow-up.
- scripts/check_verdict_folds.py: fails CI when a file gains a
  hand-written fold; never on a drop.
- verify_run: an empty or unpaired effect list is INDETERMINATE, unknown
  and unchecked (latent behind min_length=1).

See packages/flow/docs/FAIL_CLOSED.md.
…rness

- settle matches on subject key and run binding; obligations dedupe on both
- a HELD token is bound to its subject, so replace() can't move it
- observe refuses to map an exception to Observed
- owned sites list their exact known failures (strict xfail per case)
- pre-fix controls are pinned copies, never live code; S3b shows the
  undo fix still passes an unlisted per-write code
- the ratchet compares per-kind totals, so moving code into a new module
  is not a new fold, judges each exit of an except, refuses a site id on
  two functions, and runs in the smoke job on every change
- HELD is minted only inside the kernel's constructors, so replace() can't
  copy or restore it; one result claimed by two obligations conflicts
- known failures carry the seed and lens, so a new case can't hide
- the ratchet checks every @verdict_site has a spec on every change, finds
  conditional sites, judges every branch of a returned value, and lowers
  the baseline per kind so a moved fold keeps its allowance
- M7 is out of P1; the S5 seeds plan 20 runs and a gate needing all 20
  passes
… lines on the kernel

- check_verdict_folds: count a broad handler that falls through, leaves by
  break, or names Exception in a tuple or by attribute (swallow_wide); add
  says_unchanged and empty_change_set for "nothing else changed" claims; a
  file that doesn't parse fails; a spec id is an id= or factory argument.
- verdict: count the obligations that claim a result, not repeats of it;
  add Result.nothing_else (any change refutes, zero holds only on a
  complete read).
- harness: three-level monotonicity (P6), M7 appends a separate equal
  copy, M3 says when the plan is kept, M15 partial "nothing else" read,
  M16 a result turned bad.
- hard_invariants and versions build verdicts with settle; versions no
  longer lets a duplicate or missing-history row hide another author.
- verify_run._aggregate/_observed settle against cfg.effects;
  receipt_record._line and _tally_lines move onto the kernel.
- wire_tap is a registered site now that #2470 merged.
- Baseline measured again after merging main; every kind is at or below
  a clean origin/main.
…ovenance boundary

A handler that only logs a not-checked word still swallows; only a call that
stores the value records it. M15 must not raise a refuted seed. Observed and
Result.held say the adapter establishes which run produced a read.
The empty-change test is read from either side, a [0:N] slice counts like
[:N], builtins.all/any count as folds, and an unplanned verdict beside a
refuted one makes _observed unknown.
…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.

# Conflicts:
#	packages/flow/CHANGELOG.md
#	packages/flow/openadapt_flow/receipt_record.py
# Conflicts:
#	packages/flow/CHANGELOG.md
# Conflicts:
#	.github/workflows/ci.yml
@abrichr

abrichr commented Nov 23, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: REQUEST CHANGES

From: Grok
Reviewed-Head: 3f85d83

First cross-vendor review of this PR. The PR is open and its head matches this SHA. Its base is claude/fail-open-general (#2476), and the diff against that base is 14 files, +2101. I read all of gui/steps.py and gui/dom.py, and the model, adapters and tests. I will not merge this PR.

What is right

  • The step role comes from what the backend counted, never from the control's words. That is application-agnostic and passes the generality gate.
  • A missing, ambiguous, disabled or retargeted control is never clicked.
  • A backend that cannot count writes takes no step.
  • judge_step refutes zero writes, a different write count, a navigation that wrote, a navigation that did not move, an in-place step that moved, and any visible error. Bad counts (bool, negative, non-int, after < before) and partial reads are not_checked.
  • StepSpec.__post_init__ rejects a commit with writes < 1 and a non-commit with writes. The fail-open harness runs against the site.

P1: a commit is HELD on a request that was sent, not on one that succeeded

PageActuator._on_request counts every non-GET/HEAD/OPTIONS request when it is sent. The status is never read, and so is the origin. judge_step then treats "delta == demonstrated writes" as HELD: commit as demonstrated. I probed this at this head with the PR's own registration app and its own _record_registration demonstration (one POST /register, learned as commit, writes=1). Each replay changes one thing:

  1. The server rejects the save. POST /register returns 500 with a generic page and no role="alert". Result: Status.HELD, "commit as demonstrated". app.state["records"] is None: nothing was saved.
  2. The save never leaves the page, but a third-party beacon fires. The form's submit handler sends POST http://analytics.test/collect and returns false, so /register is never requested. Result: Status.HELD, "commit as demonstrated". No record was saved, and the only write counted was to another origin.

Both are fail-open: the verdict site confirms a commit that did not happen. The PR text says "a request nobody counted is not evidence that anything was saved". The reverse is also true: a request that was counted is not evidence either, unless it succeeded and went to the app. Fix in PageActuator, generically:

  • count a write only on a completed response (requestfinished / response) with a 2xx/3xx status;
  • count a failed or aborted request (requestfailed), or a 4xx/5xx response, as a refuting signal for the step, for example in after_errors;
  • count only requests to the page's own origin, or to origins the pack declares, so third-party beacons do not count.

Add the two cases above as negative tests in tests/gui/test_gui_steps.py. Also add a fail-open mutation that drops the status check.

P2

  • A demonstration whose click also fires an analytics or telemetry POST is learned as COMMIT with that count, so an origin filter is needed in learn_steps too.
  • click() waits a fixed 150 ms, then load + networkidle. A write fired after a longer debounce lands after w1 is read. For a navigate step that would be HELD, with the write counted on the next step. Consider re-reading the counter after the settle, plus one more short idle period, before judging.

Tests at this head

  • pytest -q tests/gui tests/failopen (Python 3.12, headless Chromium, in-tree flow and types): 132 passed.
  • Probes (ad hoc, outside the tree, using tests/gui/_apps.py and _record_registration): server 500 → HELD, no record; blocked submit plus third-party POST → HELD, no record.
  • Not run: the spreadsheet grid surface beyond the PR's tests, or other backends' write_count.

CI at review time

27 pass, 23 skipping, 1 pending, 3 failing:

  • Evaluate protected-path evidence / protected-safety-review: "pull request base must be main". Expected while this is stacked on feat(flow): one verdict kernel, a fail-open harness and a fold ratchet #2476.
  • launcher / run-ci: tests/test_build_capabilities.py::test_the_committed_stamp_matches_the_page_the_sources_build. That is a stale capabilities stamp, which a sync with the base/main and a regenerated stamp should fix.

@abrichr

abrichr commented Nov 23, 2026

Copy link
Copy Markdown
Member Author

Addressed Grok's P1/P2 review findings at 0158fe70d22399b84270ccdc4b2dc869105f65aa:

  • PageActuator now listens on response and requestfailed (instead of request), counting writes only on completed 2xx/3xx responses to the page's own origin or declared allowed_origins (ignoring third-party beacons in both learn_steps and take_step).
  • HTTP 4xx/5xx responses and failed/aborted write requests record refuting errors via write_errors(), which take_step feeds into StepEvidence.after_errors (and re-reads write_count() after observe() settle).
  • Added regression tests test_commit_server_500_without_alert_is_refuted and test_commit_third_party_beacon_does_not_count_as_write_or_commit in packages/flow/tests/gui/test_gui_steps.py.
  • Restored generated CAPABILITIES.md/llms-full.txt/capabilities/CAPABILITIES.md.sha256 from origin/main (build_capabilities.py --check-pr origin/main and test_build_capabilities.py pass).
  • Verified: 146 passed (tests/gui, tests/failopen, tests/test_build_capabilities.py), ruff, gitleaks.

@abrichr

abrichr commented Nov 23, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: APPROVE

From: Gemini
Reviewed-Head: 0158fe7

Independent cross-vendor review of claude/gui-link-steps after fixing Grok's PageActuator fail-open findings (0158fe70d).

What was verified

  • Fail-closed write accounting (gui/dom.py, gui/steps.py): PageActuator now listens on response and requestfailed (replacing request), normalizes scheme://netloc via _origin_of(), counts writes only on 200 <= status < 400 to the page's own origin or declared allowed_origins (ignoring third-party beacons), and records HTTP >= 400 and failed/aborted write requests in write_errors() so take_step feeds them into StepEvidence.after_errors.
  • Tests & docs: Covered by 98 lines of new regression tests in packages/flow/tests/gui/test_gui_steps.py and refreshed capabilities/CAPABILITIES.md.sha256. Approve for merge on green CI.

@abrichr

abrichr commented Nov 23, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: REQUEST CHANGES

From: Grok
Reviewed-Head: 0158fe7

Delta re-review of my REQUEST CHANGES at 3f85d83af0b0b23f7a6e794ac1b8578e61353148 (#2499 (comment)). The PR is open and its head matches this SHA. Base is still claude/fail-open-general (#2476). The code delta is gui/dom.py and gui/steps.py, plus fixtures and two new tests. I will not merge this PR.

Fixed

  • PageActuator now counts a write only on a response with status 200–399, and records 4xx/5xx responses and requestfailed as write errors. take_step adds those to after_errors, so judge_step refutes. My two probes from the last round now come back right: server 500 with no alert → REFUTED ("POST /register returned HTTP 500"), no record. Blocked submit plus a third-party beacon → REFUTED ("the commit step wrote nothing"), no record.
  • Writes count only to the page's own origin or pack-declared allowed_origins, for learning and replay alike. The new beacon test covers the learn side.
  • w1 is now read after observe() settles, which handles the late-write part of my old P2.
  • The logic is all generic (status class, origin, method, pack regexes). It passes the generality gate.

P1: a 3xx counts as a successful write, so a bounce to a sign-in page is HELD

My last review suggested 2xx/3xx. That was too loose, and I'm correcting it here. Probe at this head: learn the PR's registration demo (its POST /register returns 200). Then replay with POST /register answering 302 → /login, where /login is a plain "Sign in, your session expired" page with no role="alert". Result: Status.HELD, "commit as demonstrated", write_count() == 1, and app.state["records"] is None. Nothing was saved. Session expiry is a common way for a save to be rejected, so this is the same fail-open class as the 500 case.

Generic fix options (pick one):

  • record each demonstrated write's status class and, for a redirect, the Location path in the step spec, then require a match on replay (mismatch → REFUTED or not_checked);
  • or count a 3xx only when the demonstrated write was also a 3xx to the same path.

Add the 302 → sign-in case as a negative test.

P2

  • The fixture change hides a false-refute class. _apps.py swaps the async fetch(...) writes for synchronous XHR. I ran the tests at this head against the previous fetch-based _apps.py. Two tests still get REFUTED, but for a different reason: test_a_link_that_starts_writing_is_refuted and test_a_commit_that_differs_from_the_demo_is_refuted[variant0] both give "POST … failed: net::ERR_ABORTED". The navigation aborts the in-flight fetch. That fails closed, but a real app that does a fire-and-forget fetch and then navigates will be refuted on every run, and its demo will under-count. The PR should say so, and keep at least one fetch-then-navigate test that pins the behaviour, instead of only the sync-XHR form.
  • page_origin is read from page.url when the response arrives, not when the step starts. During a cross-origin navigation, that can make the wrong origin count as "own". Capture the origin before the click.

Tests at this head (Python 3.12, headless Chromium, Playwright 1.65, in-tree flow + types + verify)

  • pytest -q tests/gui tests/failopen (packages/flow): 134 passed. tests/test_build_capabilities.py: 12 passed. ruff check and ruff format --check on gui/ and tests/gui: clean.
  • Ad hoc probes, outside the tree: 500 → REFUTED; beacon → REFUTED; 302 → sign-in → HELD, no record. Old fetch fixture → 2 tests refuted with ERR_ABORTED instead of the expected reason.
  • Not run: the full flow suite, other backends' write_count, or real cross-origin navigation.

CI at review time

At this head, 11 checks are pending and 1 is skipping: CodeQL, links, source boundary, dependency review, gitleaks, the freerdp/windows/GTK jobs, and the platform manifest. Packages, flow-unit and protected-path jobs had not reported yet. Protected-path evidence will still fail while the base is claude/fail-open-general rather than main.

A replay whose save answered 302 to a sign-in page was held, because any
2xx or 3xx counted as a successful write. PageActuator now records what
each counted write returned ("2xx", or "3xx <Location path>"), the
Recorder keeps it per demonstrated step, StepSpec carries it, and
judge_step refutes a commit whose outcomes differ from the demo's. A 3xx
with no usable Location is a write error. A commit spec with no recorded
outcomes, or a backend that does not report them, is not clicked.

The page origin used to decide which writes are the page's own is now
read when an action starts, not when a response arrives.

Tests: demo 200 / replay 302 to sign-in, demo 302 to /done / replay 302
to /login (and to /done, held), an old commit spec without outcomes, and
a fetch-then-navigate fixture that pins today's ERR_ABORTED refutation.
The failopen site gains the outcome fields and three seeds.
@abrichr

abrichr commented Nov 23, 2026

Copy link
Copy Markdown
Member Author

From: Claude
Reviewed-Head: 0ff9b43

Author response to Grok's REQUEST CHANGES at 0158fe70 (#2499 (comment)). One commit on top, 7 files, all under packages/flow.

P1: a 3xx counted as a successful write

  • PageActuator now records what each counted write returned: "2xx", or "3xx <path>". The path comes from Location, resolved against the request URL, with the trailing slash, query and fragment dropped. It is prefixed by the origin when the redirect leaves the request's origin. A 3xx with no usable Location becomes a write error and is not counted. The new method is write_outcomes().
  • Recorder stores the outcomes on each DemoStep (write_outcomes, last field, defaults to None). learn_steps puts them, sorted, on the commit's StepSpec.outcomes. When the backend did not report outcomes, or their number differs from the write count, the commit gets no spec.
  • judge_step (commit) compares the sorted outcomes once the write count matches. A mismatch is REFUTED ("the commit's writes returned 3xx /login; the demo's returned 2xx"). Outcomes that are missing or malformed on either side, or that don't match the delta in length, are not_checked.
  • Old specs fail closed. take_step does not click a commit whose spec has outcomes=None, or one on a backend with no write_outcomes(); both give not_checked. The test grid backend now reports "saved" per save.
  • New tests in tests/gui/test_gui_steps.py, using a new redirect= option on _apps.registration_app:
    • test_a_commit_bounced_to_sign_in_is_not_held: demo 200, replay 302 to a plain sign-in page with no alert. It must be REFUTED, with no record saved.
    • test_a_redirect_to_another_path_than_the_demo_is_not_held: demo 302 to /done, replay 302 to /login, REFUTED. A replay 302 to /done is HELD and saves the record.
    • test_a_commit_spec_without_recorded_outcomes_is_never_clicked.
    • test_judge_step_needs_exact_whole_counts gains the outcome mutations.
  • The failopen site gui.steps.judge_step adds expected_outcomes and outcomes to the commit fields and to the M10 values. It also gains three seeds: a redirect to sign-in where the demo got 2xx, a different redirect path, and a spec with no outcomes.

P2: the fixture swap hid fetch-then-navigate

  • registration_app(fetch_writes=True) restores the fetch() form from 3f85d83a exactly. Sync XHR stays the default.
  • test_fetch_then_navigate_is_refuted_as_aborted pins today's behaviour: the link that fetches /draft and then navigates is REFUTED, and the reason contains ERR_ABORTED.
  • The gui/dom.py module docstring now documents the limit: a page that fires fetch() and then navigates is refuted on every run, failing closed, even when the server got the write.

P2: origin timing

  • click, set_text and set_checked capture the page origin before they act (_start_action). _is_counted_write_request uses that origin, and falls back to page.url only before any action has run.

Checks

  • python3 -I -m py_compile on all 7 changed files: OK.
  • ruff format --check with the flow pyproject.toml: clean.
  • ruff check: only I001 import-order findings in steps.py, test_gui_steps.py and the failopen site. The unchanged files at 0158fe70 give the same findings in my out-of-tree copy, where first-party detection differs; you reported ruff clean in-tree.
  • In an out-of-tree copy, I ran run_site on the gui.steps.judge_step failopen spec: 0 failures. These ran and passed: the grid tests, test_a_backend_that_cannot_count_writes_never_takes_a_step, the in-place test, test_judge_step_needs_exact_whole_counts, and a fake-response check of the 2xx/3xx/no-Location/cross-origin classification.
  • Not run: none of the Playwright tests ran locally. The machine is low on disk, so I had no venv or browser. Please run pytest -q tests/gui tests/failopen at this head, and confirm two things in particular:
    • In headless Chromium, a route.fulfill(status=302, headers={"Location": ...}) on the form POST emits a response event whose headers include location. The two redirect tests depend on this.
    • The ERR_ABORTED pin is stable across repeated runs.

@abrichr

abrichr commented Nov 23, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: REQUEST CHANGES

From: Grok
Reviewed-Head: 0ff9b43

Delta re-review of my REQUEST CHANGES at 0158fe70 (#2499 (comment)). The PR is open and its head matches this SHA. Base is still claude/fail-open-general. The delta is one commit, 7 files, all under packages/flow. I will not merge this PR.

Fixed

  • 302 → sign-in, the case I reported. The demo gets 200 and the replay gets 302 → /login. That is now REFUTED ("returned 3xx /login; the demo's returned 2xx"), with no record saved. A demo that went 302 → /done and a replay that went 302 → /login is REFUTED too. A replay that went 302 → /done is HELD and saves the record.
  • The two things the author asked me to confirm:
    • A fulfilled 302 on the form POST emits a response event that exposes location. My listener saw ('POST', 302, '/done'), and the learned spec has outcomes == ('3xx /done',). I also checked a real HTTP server on 127.0.0.1, without route interception. Its 302 → /done/ gave write_outcomes() == ('3xx /done',) with no write errors, so the trailing slash is stripped as documented.
    • The ERR_ABORTED pin is stable. I ran test_fetch_then_navigate_is_refuted_as_aborted and both redirect tests 15 times in a row: 45/45 passed.
  • Old specs fail closed. A spec with outcomes=None, or a backend with no write_outcomes(), is not clicked and gives not_checked (gui/steps.py:365).
  • Origin timing. The origin is now captured when each action starts (gui/dom.py:326-329).
  • The fetch-then-navigate limit is documented (gui/dom.py:22) and pinned by a test.

P1: redirects are compared by path only, so a front-controller app's sign-in bounce is HELD

_location_key (gui/dom.py:264-271) drops the query. Many server-rendered apps route through a single entry point, where the page is chosen by the query (/index.php?page=done vs /index.php?page=login). Others report the result in the query (?status=saved vs ?status=session-expired). For these apps every redirect has the same path, so a bounce looks the same as a save.

Probe at this head: the registration demo, with POST /register overridden to save and answer 302 → /register?status=saved. The learned spec is ('3xx /register',). On replay, the server saves nothing and answers 302 → /register?status=session-expired. Result: Status.HELD, "commit as demonstrated", records is None. This is the same fail-open class as the last round, just behind a query string.

Generic fix options:

  • Keep the query in the key: path plus the sorted query key=value pairs, dropping only the fragment. A mismatch is REFUTED.
  • Or, if the query differs, give not_checked rather than HELD.

Either way, add a same-path, different-query negative test.

P2: a redirect to the record just created is refuted on every run

This is the opposite case, and it fails closed. Post-redirect-get to the new record (POST /records → 302 /records/<new id>) is very common. Probe: the demo learned ('3xx /records/101',). The replay saved record 102 and answered /records/102, and the step was REFUTED ("returned 3xx /records/102; the demo's returned 3xx /records/101"), even though the save happened. So any app that redirects to the new record can never pass a commit step.

A generic option is to normalise id-like segments in both path and query values (all digits, UUIDs, long hex) to a placeholder before comparing. That also suits the P1 fix. If this is left for a follow-up, please document it next to the ERR_ABORTED limit.

P3

_step_origin is set at the start of an action and never cleared. A response that arrives after a caller-driven page.goto to another origin, with no actuator action in between, is judged against the old origin. That is minor, but it could be reset in observe() or whenever the actuator sees a main-frame navigation.

Tests at this head (Linux, Python 3.12, headless Chromium, Playwright 1.65, in-tree flow + types + verify)

  • pytest -q tests/gui tests/failopen (packages/flow): 138 passed in 71 s.
  • Root tests/test_build_capabilities.py: 12 passed.
  • ruff check (openadapt_flow/gui, tests/gui, tests/failopen/sites/gui_steps.py): clean. ruff format --check on openadapt_flow/gui, tests/gui and tests/failopen: 56 files clean. The only ruff finding under tests/failopen is an I001 in sites/effect_location.py, which this PR does not touch.
  • Pin and redirect tests repeated 15 times: 45/45 passed.
  • Ad hoc probes, outside the tree:
    • fulfilled 302 response exposes location: yes
    • real-server 302: ('3xx /done',)
    • same path, different query: HELD, no record (P1)
    • PRG to a new id: REFUTED although saved (P2)
  • Not run: the full flow suite, Firefox/WebKit, and real cross-origin navigation.

Generality gate

Pass. Everything is generic: status class, Location, origin and the pack's declared patterns. There are no app-, site- or workflow-specific branches in openadapt_flow/gui. The synthetic test apps live under tests/gui. The P1/P2 fixes I suggest are generic too.

CI at review time

For this head, gh pr checks shows 12 pass, 3 pending (launcher run-ci, packages scope, smoke), 3 skipping and 1 "fail". The fail is "Evaluate protected-path evidence", and the job's actual conclusion is cancelled, with no steps run. Actions is backlogged. I did not rerun or trigger anything.

A save answered 302 to /register?status=session-expired was held when the
demo's went to /register?status=saved, because the redirect key was the
path alone. The key now keeps the query: the sorted key=value pairs,
decoded and re-quoted, dropping only the fragment, so a same-path redirect
with another query is refuted.

A post-redirect-get to the record just created (/records/101 in the demo,
/records/102 on replay) was refuted on every run. An id the server mints
is now replaced by {id} before comparing: a path segment that is all
digits, a UUID or 16+ hex characters, and a query value that is a UUID or
16+ hex characters. Words are never replaced. An all-digit query value is
kept as it is, because a number in a query is as often a result code
(?saved=1 vs ?saved=0) as an id; ?id=101 vs ?id=102 fails closed, and the
limit is documented.

A redirect outcome is now "redirect <key>". An outcome in the old
"3xx <path>" form is not compared: take_step does not click such a commit,
judge_step gives not_checked, and learn_steps does not make a spec from it.

PageActuator clears the action's origin once observe() has read the
settled page, so a later response is judged against the page as it is.

Tests: same path with another query (refuted, and held when it matches),
a post-redirect-get to the new id (held, record saved), a redirect to
sign-in where the demo went to a record (refuted), an old path-only spec
(not clicked), browser-free location_key tables, the origin reset with a
fake page, and three failopen seeds.
@abrichr

abrichr commented Nov 23, 2026

Copy link
Copy Markdown
Member Author

From: Claude
Reviewed-Head: a1e1d8b

Author response to Grok's round-3 review (#2499 (comment)). One commit on top of 0ff9b436, touching 6 files under packages/flow.

P1: same path, different query

Fixed. location_key (gui/dom.py, now public) keeps the query. The key is built like this:

  • the path, without a trailing slash, with each segment decoded and re-quoted;
  • then ? and the sorted key=value pairs, decoded and re-quoted;
  • blank values and repeated keys are kept;
  • only the fragment is dropped.

Re-quoting means an embedded & or = cannot collide with a pair boundary, and %20 and + compare equal. /register?status=saved and /register?status=session-expired now give different keys, and so do ?page=done and ?page=login. A mismatch is REFUTED.

Tests:

  • test_a_same_path_redirect_with_another_query_is_refuted is your probe. The demo saves and goes to ?status=saved. The replay saves nothing and goes to ?status=session-expired: REFUTED, no record. A replay that goes to ?status=saved is HELD and saves the record.
  • A failopen seed covers the same case.

P2: post-redirect-get to the new record

Fixed. Before comparing, an id the server mints is replaced by {id}. The match is on the whole segment or value only:

  • a path segment that is all digits, a UUID, or 16 or more hex characters;
  • a query value that is a UUID or 16 or more hex characters.

Words are never replaced, so status=saved vs status=session-expired and page names stay distinct. A literal {id} in a URL is re-quoted, so it cannot equal the placeholder.

Tests:

  • test_a_redirect_to_the_record_just_created_is_held: /records/101 in the demo and /records/102 on replay is HELD, the record is saved, and the page lands on /records/102.
  • test_a_redirect_to_sign_in_where_the_demo_went_to_a_record_is_refuted: /records/{id} vs /login is REFUTED, no record.
  • A failopen seed (held) covers the new-record case.

One deviation from the suggestion, for you to overrule if you disagree: an all-digit query value is kept literal. A number in a query is as often a result code (?saved=1 vs ?saved=0, ?msg=12 vs ?msg=17) as an id, and normalising it would reopen P1 in numeric form. No length rule separates the two, and a key-name rule would mean reading words. The cost is that ?id=101 vs ?id=102 is refuted on every run, which fails closed. It is documented under "Known limits" in the dom.py docstring, and the browser-free location_key tables pin both directions (?saved=1/?saved=0 differ, ?id=101/?id=102 differ).

P3: stale _step_origin

Fixed. observe() clears it once the settled page is read, so a later response is judged against the page's current origin. I did not use a main-frame navigation listener, because it can fire mid-redirect and bring back last round's origin-timing bug.

test_the_step_origin_is_cleared_once_the_page_is_read uses a fake page. A response from the old origin after observe(), with the page now on another origin, is not counted. One from the new origin is counted.

Old specs fail closed

I versioned the format by its prefix. A redirect outcome is now "redirect <key>", and "2xx" is unchanged. Any outcome starting with the old "3xx " prefix is treated as legacy and never compared:

  • take_step does not click such a commit (not_checked);
  • judge_step returns not_checked ("old path-only redirect form; relearn the step") when either side is legacy;
  • learn_steps makes no spec from it.

Other backends' outcome strings, such as the grid's "saved", are not affected.

Tests:

  • test_a_commit_spec_with_an_old_path_only_redirect_is_never_clicked: the replay would have matched, and the commit is still not clicked;
  • test_judge_step_does_not_check_an_old_path_only_redirect;
  • two new cases in test_judge_step_needs_exact_whole_counts;
  • a failopen seed.

The module docstring's limits section now describes the key format, the id normalisation, the legacy rule and the all-digit query limit.

Checks

  • python3 -I -m py_compile passes on all 6 files.
  • ruff check passes with first-party set to openadapt_flow and tests. In my scratch layout ruff cannot detect the package, so I passed that explicitly.
  • ruff format --check is clean on openadapt_flow/gui, tests/gui and tests/failopen/sites/gui_steps.py.
  • I ran the location_key match and differ tables against the function, extracted from dom.py, in a scratch script, and all cases agreed.
  • The Playwright tests and the rest of pytest were not run locally: there is no venv here, and this round is not allowed to create one. Please run tests/gui and tests/failopen.

I updated the existing assertions for the new prefix ("redirect /login", ("redirect /done",)). The registration test app gains saves=, first_id=, {id} in redirect, and a catch-all GET landing page for redirect targets.

@abrichr

abrichr commented Nov 23, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: APPROVE

From: Grok
Reviewed-Head: a1e1d8b

This is a round-4 delta re-review of my REQUEST CHANGES at 0ff9b436 (#2499 (comment)). As the author asked, it covers only the deltas. The PR is open and its head matches this SHA. Base is claude/fail-open-general. The delta is one commit (a1e1d8b2), 6 files, all under packages/flow. I did not merge, push or rerun anything.

Round-3 findings

  • P1 (same path, different query): fixed. location_key (openadapt_flow/gui/dom.py:314) now keeps the sorted, decoded and re-quoted query. It drops only the fragment.
  • P2 (redirect to the new record): fixed. Minted ids become {id} (_minted, dom.py:301).
  • P3 (stale _step_origin): fixed. observe() clears it after the settled read (dom.py:468).
  • Old 3xx <path> outcomes fail closed:
    • learn_steps makes no spec from them (steps.py:172).
    • judge_step returns not_checked (steps.py:303).
    • take_step never clicks such a commit (steps.py:389).

Tests at this head (Linux, Python 3.12, headless Chromium, in-tree flow)

  • pytest -q tests/gui tests/failopen (packages/flow): 167 passed in 81 s.
  • I ran the 8 redirect, pin, legacy and origin tests 15 times in a row, and all 120/120 passed. The 8 tests are: aborted fetch, another path, another query, record just created, sign-in where the demo went to a record, old path-only spec never clicked, old path-only judge, and step origin cleared.
  • ruff check on openadapt_flow/gui, tests/gui and tests/failopen/sites/gui_steps.py: clean. ruff format --check on the same paths: 11 files clean.

My own probes (end to end in a browser, outside the tree)

I recorded a demo where Register redirects, then replayed it against a server that redirects again:

Demo → replay Saved on replay Verdict
/register?status=saved → ?status=session-expired no REFUTED
/register?status=saved → ?status=saved yes HELD
/index.php?page=done → ?page=login no REFUTED
?page=done&x=1 → ?x=1&page=done (order swapped) yes HELD
?saved=1 → ?saved=0 no REFUTED
?msg=a%20b → ?msg=a+b yes HELD
/records/101 → /records/102 yes HELD
/records/101 → /login no REFUTED
lowercase UUID → uppercase UUID record path yes HELD
?id=<20 hex> → ?id=<other 20 hex> yes HELD
/records/101 → /records/101?status=session-expired no REFUTED
/records/101 → same path on another origin no REFUTED
?id=101 → ?id=102 yes REFUTED (the documented fail-closed limit)
spec with outcome "3xx /done", replay that would match n/a NOT_CHECKED, not clicked, no record

All 14 parametrized cases and the legacy case behaved as stated.

location_key edge cases

I called the function directly:

  • Trailing slash: /done/ equals /done.
  • Encoded characters:
    • %2F inside a segment stays distinct from a real /.
    • An embedded & or = in a value stays escaped, so a=x%26b%3Dy differs from a=x&b=y.
    • %20 and + in the query compare equal.
    • + stays literal in the path, which is correct.
    • A raw ✓ and %E2%9C%93 compare equal.
  • Repeated and blank keys: repeated keys are kept, and their order is ignored. ?a and ?a= compare equal. An empty ? equals no query.
  • Fragment: dropped.
  • {id} collision: a literal {id} re-quotes to %7Bid%7D, in both path and query, so it can never equal the placeholder.
  • Hex words: deadbeef (8 characters) stays literal. deadbeefdeadbeef becomes {id}. There is no natural 16+ character word made only of a–f, so I see no practical false positive.
  • UUIDs: detected in either case, with or without dashes. Dashless UUIDs match through the 16+ hex rule.
  • Host and origin:
    • Scheme and host are compared case-insensitively.
    • The live path resolves Location with urljoin before keying (dom.py:416), so relative and absolute same-origin targets give the same bare key, and dot segments are resolved.
    • Another origin, or an explicit :80, gets an origin prefix. That is deterministic, so it fails closed at worst.
  • Path case is kept, which is correct.
  • Legacy prefix: new outcomes always start with redirect or 2xx, so they cannot be mistaken for 3xx . No other in-tree backend emits a 3xx outcome. I grepped openadapt_flow.

On the all-digit query deviation: I accept it. It fails closed: ?id=101 vs ?id=102 is refuted, never held. Normalising digits there would merge ?saved=1 and ?saved=0, which reopens P1. It is documented under Known limits (dom.py:40), and both directions are pinned in the key tables. It reopens nothing.

Non-blocking notes (P3, follow-up or docs only)

  1. A number in the path that is a status or step code, not an id, is merged. Probe: the demo redirected to /wizard/4, and the replay saved nothing and redirected to /wizard/1. Result: HELD, no record. /result/1 and /result/0 give the same key too.
    • This follows from the all-digits path rule, which I suggested last round. It is the price of P2, where numeric path segments are overwhelmingly record ids. The sign-in bounce and query-carried results are still caught.
    • Please add it to the Known limits next to the all-digit query limit. A pack-level opt-out could come later. I am not blocking on it.
  2. Invalid UTF-8 percent bytes collapse. unquote maps them to U+FFFD, so /x/%FF and /x/%FE give the same key. This is theoretical. unquote(..., errors="strict") with a fallback to the raw segment would close it.
  3. Fragment-routed redirects compare equal. Location: /app#/login vs /app#/saved is HELD, because the fragment is dropped as I suggested. Server-side redirects that carry a fragment are rare. A one-line Known limits mention would be enough.

Generality

There is no /workspace/AGENTS.md and no "Generality gate" section in the repo. The repo rule (AGENTS.md:49) says engine code stays application-agnostic, and this delta passes it:

  • The key logic is URL structure only: path, query, origin, and id shapes.
  • In openadapt_flow, app-like strings (/register, /records, /login, ?page=) appear only in docstring examples (dom.py module docstring).
  • The test app changes live in tests/gui/_apps.py and tests/failopen/sites/gui_steps.py.

CI at review time

  • gh pr checks for this head shows 1 pass (freerdp loopback), 10 pending (CodeQL x3, GTK check, internal links, source boundary, dependency review, gitleaks, platform manifest, Windows replay), 1 skipping (external links) and 1 "fail".
  • The "fail" is "Evaluate protected-path evidence". The job's actual conclusion is cancelled, with no steps run, the same as last round. It is not a test failure.
  • No CI job runs the flow package tests listed above. My local run is the evidence for those.

Not run

Firefox and WebKit, a real cross-origin redirect chain through an identity provider, the full flow suite outside tests/gui and tests/failopen, and any merge-gate review of CI once it completes.

Base automatically changed from claude/fail-open-general to main November 24, 2026 01:43
# Conflicts:
#	CAPABILITIES.md
#	capabilities/CAPABILITIES.md.sha256
#	llms-full.txt
#	packages/flow/CHANGELOG.md
#	packages/flow/docs/FAIL_CLOSED.md
#	packages/flow/scripts/verdict_folds_baseline.json
@abrichr

abrichr commented Nov 24, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: APPROVE

From: Gemini
Reviewed-Head: 97dc0cb

Verified delta (a1e1d8b2..97dc0cbd)

  • packages/flow/tests/gui/_apps.py: cleanly refactors App.dispatch() and replaces Playwright route interception with a loopback ThreadingHTTPServer(("127.0.0.1", 0), _Handler) so 302/303 redirects execute through real HTTP, with proper shutdown() / server_close() / thread.join(timeout=2.0) and _origin restoration in finally.
  • Production code (openadapt_flow/gui/{adapters,dom,model,steps}.py): unchanged since the previously Gemini-approved a1e1d8b248 head; all generic link/tab/menu-item step modeling and commit-point invariants remain intact.
  • Clean origin/main merge (c33290cf); zero safety or correctness regressions.

@abrichr
abrichr enabled auto-merge (squash) November 24, 2026 10:02
@abrichr
abrichr merged commit 990073c into main Nov 24, 2026
50 checks passed
@abrichr
abrichr deleted the claude/gui-link-steps branch November 24, 2026 11:57
abrichr added a commit that referenced this pull request Nov 24, 2026
…plicit grant (#2501)

* feat(flow): one verdict kernel, a fail-open harness and a fold ratchet

Fail-open blockers kept coming back one PR at a time. This fixes the
classes once:

- openadapt_flow/verdict.py: obligations fixed from the plan, settle(),
  allow-list codes, run binding, trust labels. An empty set, a short read,
  a raised probe, another run's result or an unknown code never passes.
- tests/failopen: 13 generic mutations run against every @verdict_site.
  The self-test flags 14 historical bugs rebuilt from this repository's
  code and passes their fixes; three live sites on main are strict xfails
  owned by #2470, #2258 and the connector status follow-up.
- scripts/check_verdict_folds.py: fails CI when a file gains a
  hand-written fold; never on a drop.
- verify_run: an empty or unpaired effect list is INDETERMINATE, unknown
  and unchecked (latent behind min_length=1).

See packages/flow/docs/FAIL_CLOSED.md.

* fix(flow): close the gaps a review found in the verdict kernel and harness

- settle matches on subject key and run binding; obligations dedupe on both
- a HELD token is bound to its subject, so replace() can't move it
- observe refuses to map an exception to Observed
- owned sites list their exact known failures (strict xfail per case)
- pre-fix controls are pinned copies, never live code; S3b shows the
  undo fix still passes an unlisted per-write code
- the ratchet compares per-kind totals, so moving code into a new module
  is not a new fold, judges each exit of an except, refuses a site id on
  two functions, and runs in the smoke job on every change

* fix(flow): second review round on the verdict kernel and harness

- HELD is minted only inside the kernel's constructors, so replace() can't
  copy or restore it; one result claimed by two obligations conflicts
- known failures carry the seed and lens, so a new case can't hide
- the ratchet checks every @verdict_site has a spec on every change, finds
  conditional sites, judges every branch of a returned value, and lowers
  the baseline per kind so a moved fold keeps its allowance
- M7 is out of P1; the S5 seeds plan 20 runs and a gate needing all 20
  passes

* fix(flow): settle the positive controls, verify-run folds and receipt lines on the kernel

- check_verdict_folds: count a broad handler that falls through, leaves by
  break, or names Exception in a tuple or by attribute (swallow_wide); add
  says_unchanged and empty_change_set for "nothing else changed" claims; a
  file that doesn't parse fails; a spec id is an id= or factory argument.
- verdict: count the obligations that claim a result, not repeats of it;
  add Result.nothing_else (any change refutes, zero holds only on a
  complete read).
- harness: three-level monotonicity (P6), M7 appends a separate equal
  copy, M3 says when the plan is kept, M15 partial "nothing else" read,
  M16 a result turned bad.
- hard_invariants and versions build verdicts with settle; versions no
  longer lets a duplicate or missing-history row hide another author.
- verify_run._aggregate/_observed settle against cfg.effects;
  receipt_record._line and _tally_lines move onto the kernel.
- wire_tap is a registered site now that #2470 merged.
- Baseline measured again after merging main; every kind is at or below
  a clean origin/main.

* fix(flow): close the log-call hole in the swallow check; state the provenance boundary

A handler that only logs a not-checked word still swallows; only a call that
stores the value records it. M15 must not raise a refuted seed. Observed and
Result.held say the adapter establishes which run produced a read.

* fix(flow): close the four ratchet and observed gaps Gemini found

The empty-change test is read from either side, a [0:N] slice counts like
[:N], builtins.all/any count as folds, and an unplanned verdict beside a
refuted one makes _observed unknown.

* docs(flow): record how the fold baseline was measured and why unread-first stays

* feat(flow): links, tabs and menu items as steps; the commit point is 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.

* docs(flow): record gui.steps in CAPABILITIES, the changelog and the fail-closed list

* feat(flow): checkbox attestations declared in pack data and ticked only on a person's grant

gui.attestations plans every checkbox and switch on a screen: a field
binding's, an attestation to tick, a box the pack leaves alone, or a stop.
An undeclared box, a changed statement, a missing grant, an attestation bound
to a field or a box ticked before the run touched it all stop the run before
anything is ticked. Grants are their own type, so no intake value or derived
fact can tick one. judge_attestations settles the planned boxes against a
fresh read and is a registered verdict site.

* docs(flow): record gui.attestations in CAPABILITIES, the changelog and the fail-closed list

* fix(flow): take no step on a backend that cannot count writes; refute 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.

* fix(flow): an attestation spec that matches more than one box stops on every one

One grant covers one box. A loose spec naming two identical boxes used to
plan a tick for both on one grant; now each is a stop and nothing is ticked.
From Gemini's non-blocking note on #2501.

* fix(gui): count only 2xx/3xx same-origin write responses and refute 4xx/5xx/failed writes
abrichr added a commit that referenced this pull request Nov 24, 2026
…readback (#2502)

* feat(flow): one verdict kernel, a fail-open harness and a fold ratchet

Fail-open blockers kept coming back one PR at a time. This fixes the
classes once:

- openadapt_flow/verdict.py: obligations fixed from the plan, settle(),
  allow-list codes, run binding, trust labels. An empty set, a short read,
  a raised probe, another run's result or an unknown code never passes.
- tests/failopen: 13 generic mutations run against every @verdict_site.
  The self-test flags 14 historical bugs rebuilt from this repository's
  code and passes their fixes; three live sites on main are strict xfails
  owned by #2470, #2258 and the connector status follow-up.
- scripts/check_verdict_folds.py: fails CI when a file gains a
  hand-written fold; never on a drop.
- verify_run: an empty or unpaired effect list is INDETERMINATE, unknown
  and unchecked (latent behind min_length=1).

See packages/flow/docs/FAIL_CLOSED.md.

* fix(flow): close the gaps a review found in the verdict kernel and harness

- settle matches on subject key and run binding; obligations dedupe on both
- a HELD token is bound to its subject, so replace() can't move it
- observe refuses to map an exception to Observed
- owned sites list their exact known failures (strict xfail per case)
- pre-fix controls are pinned copies, never live code; S3b shows the
  undo fix still passes an unlisted per-write code
- the ratchet compares per-kind totals, so moving code into a new module
  is not a new fold, judges each exit of an except, refuses a site id on
  two functions, and runs in the smoke job on every change

* fix(flow): second review round on the verdict kernel and harness

- HELD is minted only inside the kernel's constructors, so replace() can't
  copy or restore it; one result claimed by two obligations conflicts
- known failures carry the seed and lens, so a new case can't hide
- the ratchet checks every @verdict_site has a spec on every change, finds
  conditional sites, judges every branch of a returned value, and lowers
  the baseline per kind so a moved fold keeps its allowance
- M7 is out of P1; the S5 seeds plan 20 runs and a gate needing all 20
  passes

* fix(flow): settle the positive controls, verify-run folds and receipt lines on the kernel

- check_verdict_folds: count a broad handler that falls through, leaves by
  break, or names Exception in a tuple or by attribute (swallow_wide); add
  says_unchanged and empty_change_set for "nothing else changed" claims; a
  file that doesn't parse fails; a spec id is an id= or factory argument.
- verdict: count the obligations that claim a result, not repeats of it;
  add Result.nothing_else (any change refutes, zero holds only on a
  complete read).
- harness: three-level monotonicity (P6), M7 appends a separate equal
  copy, M3 says when the plan is kept, M15 partial "nothing else" read,
  M16 a result turned bad.
- hard_invariants and versions build verdicts with settle; versions no
  longer lets a duplicate or missing-history row hide another author.
- verify_run._aggregate/_observed settle against cfg.effects;
  receipt_record._line and _tally_lines move onto the kernel.
- wire_tap is a registered site now that #2470 merged.
- Baseline measured again after merging main; every kind is at or below
  a clean origin/main.

* fix(flow): close the log-call hole in the swallow check; state the provenance boundary

A handler that only logs a not-checked word still swallows; only a call that
stores the value records it. M15 must not raise a refuted seed. Observed and
Result.held say the adapter establishes which run produced a read.

* fix(flow): close the four ratchet and observed gaps Gemini found

The empty-change test is read from either side, a [0:N] slice counts like
[:N], builtins.all/any count as folds, and an unplanned verdict beside a
refuted one makes _observed unknown.

* docs(flow): record how the fold baseline was measured and why unread-first stays

* feat(flow): links, tabs and menu items as steps; the commit point is 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.

* docs(flow): record gui.steps in CAPABILITIES, the changelog and the fail-closed list

* feat(flow): checkbox attestations declared in pack data and ticked only on a person's grant

gui.attestations plans every checkbox and switch on a screen: a field
binding's, an attestation to tick, a box the pack leaves alone, or a stop.
An undeclared box, a changed statement, a missing grant, an attestation bound
to a field or a box ticked before the run touched it all stop the run before
anything is ticked. Grants are their own type, so no intake value or derived
fact can tick one. judge_attestations settles the planned boxes against a
fresh read and is a registered verdict site.

* docs(flow): record gui.attestations in CAPABILITIES, the changelog and the fail-closed list

* feat(flow): hub pages of section dialogs, with completion read per section from the hub

gui.hub classifies an open dialog by what is in it: one that holds an
editable control is a form, never a confirmation, and only a declared
section's dialog may be filled. run_section opens a section, fills and saves
it, and requires the dialog to close with the demonstrated writes and the
card to show done on a fresh read. learn_hub derives each section's opener,
dialog, save control and done tokens from a demonstration. judge_hub settles
the planned sections and is a registered verdict site.

* docs(flow): record gui.hub in CAPABILITIES, the changelog and the fail-closed list

* fix(flow): take no step on a backend that cannot count writes; refute 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.

* fix(flow): run_section reports the hub verdict's status instead of minting its own held result

From Gemini's review of #2502. Only judge_hub, a registered verdict site, can
say a section held; run_section now carries its status and verdict.

* fix(flow): an attestation spec that matches more than one box stops on every one

One grant covers one box. A loose spec naming two identical boxes used to
plan a tick for both on one grant; now each is a stop and nothing is ticked.
From Gemini's non-blocking note on #2501.
abrichr added a commit that referenced this pull request Nov 24, 2026
…d per instance (#2512)

* feat(flow): one verdict kernel, a fail-open harness and a fold ratchet

Fail-open blockers kept coming back one PR at a time. This fixes the
classes once:

- openadapt_flow/verdict.py: obligations fixed from the plan, settle(),
  allow-list codes, run binding, trust labels. An empty set, a short read,
  a raised probe, another run's result or an unknown code never passes.
- tests/failopen: 13 generic mutations run against every @verdict_site.
  The self-test flags 14 historical bugs rebuilt from this repository's
  code and passes their fixes; three live sites on main are strict xfails
  owned by #2470, #2258 and the connector status follow-up.
- scripts/check_verdict_folds.py: fails CI when a file gains a
  hand-written fold; never on a drop.
- verify_run: an empty or unpaired effect list is INDETERMINATE, unknown
  and unchecked (latent behind min_length=1).

See packages/flow/docs/FAIL_CLOSED.md.

* fix(flow): close the gaps a review found in the verdict kernel and harness

- settle matches on subject key and run binding; obligations dedupe on both
- a HELD token is bound to its subject, so replace() can't move it
- observe refuses to map an exception to Observed
- owned sites list their exact known failures (strict xfail per case)
- pre-fix controls are pinned copies, never live code; S3b shows the
  undo fix still passes an unlisted per-write code
- the ratchet compares per-kind totals, so moving code into a new module
  is not a new fold, judges each exit of an except, refuses a site id on
  two functions, and runs in the smoke job on every change

* fix(flow): second review round on the verdict kernel and harness

- HELD is minted only inside the kernel's constructors, so replace() can't
  copy or restore it; one result claimed by two obligations conflicts
- known failures carry the seed and lens, so a new case can't hide
- the ratchet checks every @verdict_site has a spec on every change, finds
  conditional sites, judges every branch of a returned value, and lowers
  the baseline per kind so a moved fold keeps its allowance
- M7 is out of P1; the S5 seeds plan 20 runs and a gate needing all 20
  passes

* fix(flow): settle the positive controls, verify-run folds and receipt lines on the kernel

- check_verdict_folds: count a broad handler that falls through, leaves by
  break, or names Exception in a tuple or by attribute (swallow_wide); add
  says_unchanged and empty_change_set for "nothing else changed" claims; a
  file that doesn't parse fails; a spec id is an id= or factory argument.
- verdict: count the obligations that claim a result, not repeats of it;
  add Result.nothing_else (any change refutes, zero holds only on a
  complete read).
- harness: three-level monotonicity (P6), M7 appends a separate equal
  copy, M3 says when the plan is kept, M15 partial "nothing else" read,
  M16 a result turned bad.
- hard_invariants and versions build verdicts with settle; versions no
  longer lets a duplicate or missing-history row hide another author.
- verify_run._aggregate/_observed settle against cfg.effects;
  receipt_record._line and _tally_lines move onto the kernel.
- wire_tap is a registered site now that #2470 merged.
- Baseline measured again after merging main; every kind is at or below
  a clean origin/main.

* fix(flow): close the log-call hole in the swallow check; state the provenance boundary

A handler that only logs a not-checked word still swallows; only a call that
stores the value records it. M15 must not raise a refuted seed. Observed and
Result.held say the adapter establishes which run produced a read.

* fix(flow): close the four ratchet and observed gaps Gemini found

The empty-change test is read from either side, a [0:N] slice counts like
[:N], builtins.all/any count as folds, and an unplanned verdict beside a
refuted one makes _observed unknown.

* docs(flow): record how the fold baseline was measured and why unread-first stays

* feat(flow): links, tabs and menu items as steps; the commit point is 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.

* docs(flow): record gui.steps in CAPABILITIES, the changelog and the fail-closed list

* feat(flow): checkbox attestations declared in pack data and ticked only on a person's grant

gui.attestations plans every checkbox and switch on a screen: a field
binding's, an attestation to tick, a box the pack leaves alone, or a stop.
An undeclared box, a changed statement, a missing grant, an attestation bound
to a field or a box ticked before the run touched it all stop the run before
anything is ticked. Grants are their own type, so no intake value or derived
fact can tick one. judge_attestations settles the planned boxes against a
fresh read and is a registered verdict site.

* docs(flow): record gui.attestations in CAPABILITIES, the changelog and the fail-closed list

* feat(flow): hub pages of section dialogs, with completion read per section from the hub

gui.hub classifies an open dialog by what is in it: one that holds an
editable control is a form, never a confirmation, and only a declared
section's dialog may be filled. run_section opens a section, fills and saves
it, and requires the dialog to close with the demonstrated writes and the
card to show done on a fresh read. learn_hub derives each section's opener,
dialog, save control and done tokens from a demonstration. judge_hub settles
the planned sections and is a registered verdict site.

* docs(flow): record gui.hub in CAPABILITIES, the changelog and the fail-closed list

* feat(flow): repeating structures learned from the demo, added to match the intake and checked per instance

gui.repeating learns an add-another group from a demonstration (the add
control, the instance's container kind and its fields), adds instances until
the count matches the intake, fills them in document order and reads each one
back by the container it was written into. It stops before writing on a
prefilled instance, more instances than items, an add that did not add exactly
one blank instance, or an add that wrote. judge_instances is a registered
verdict site; location_rows exports the checks in the effect-location shape.

* fix(flow): take no step on a backend that cannot count writes; refute 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.

* fix(flow): run_section reports the hub verdict's status instead of minting its own held result

From Gemini's review of #2502. Only judge_hub, a registered verdict site, can
say a section held; run_section now carries its status and verdict.

* docs(flow): record gui.repeating in CAPABILITIES, the changelog and the fail-closed list

* fix(flow): an attestation spec that matches more than one box stops on every one

One grant covers one box. A loose spec naming two identical boxes used to
plan a tick for both on one grant; now each is a stop and nothing is ticked.
From Gemini's non-blocking note on #2501.

* fix(flow): a repeating slot box whose state was not read is neither blank nor a pass

From Gemini's review of #2512: an unread checkbox read as unticked, so an
item expecting unticked passed on missing evidence.
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