Skip to content

feat(guard): approval card values beside the source, ReadbackProvider seam, per-save ledger row - #2492

Merged
abrichr merged 20 commits into
mainfrom
claude/acp-P5-gate-card-readback-ledger
Nov 22, 2026
Merged

abrichr merged 20 commits into
mainfrom
claude/acp-P5-gate-card-readback-ledger

Conversation

@abrichr

@abrichr abrichr commented Nov 22, 2026 •

Copy link
Copy Markdown
Member

Box 3 of the flight-recorder plan: the guard's approval card shows what a person needs to check, read-backs go through one provider seam, and every save gets a ledger row. It also carries Desktop's exception cards, moved here from #2494 so only this PR bumps Desktop.

Merge order: #2494 before this PR. Desktop 0.31.0 lists exception cards that Flow's exception registry in #2494 produces.

What changes

The approval card (agent_guard/approval_fields.py, agent_guard/screen_values.py)

  • Every intended field becomes an item_approval.SaveField:
    • before is the record's value now, read through the verify.yaml reader.
    • after is the value the held request sends, read by the app's write_adapter, the same reader the guard checks writes with. Without an adapter, or when it can't read the body, after is not read. It is never the task's value standing in for it.
  • Beside each field, in approval_sources.json (0600, bound to the request digest):
    • intended: the task's value, with held_differs when the sent value differs.
    • screen: with no write adapter, the value the form shows when the save is held, with screen_differs. It reads visible input, select, textarea and contenteditable controls only, and matches them to a field by id, name or label. Hidden, zero-size or aria-hidden controls don't count.
    • source: the provenance value, cross-checked against the source document.
  • The screenshot is taken at the same moment as the screen values.
  • Flow sets values_checked from the digest-bound fields. The card says "exactly what will be saved" only when every value came from the held request. Otherwise it says the values were not read and not checked, and asks the person to compare the screen with the task.
  • No value read and no readable screenshot: no approval request is opened, so no surface can approve. The guard blocks the save with values_unread, and the row is ESCALATED values_unread.
  • Phone (portal/shell/app.js): shows "On screen at the save", "Task says" and "Source", each with Differs flags.

ReadbackProvider (agent_guard/readback.py)

  • read(task, guard) -> ReadbackResult{tier, fields, evidence, verdict}. The default VerifyRunReadback wraps Guard.confirm unchanged.
  • rule() sets the final verdict:
    • Only independent_readback can be VERIFIED.
    • A field with another value than the task's is REFUTED.
    • A failed provider gives RECONCILIATION_REQUIRED.
  • A provider declares its own tier, so registering one means trusting its code.
  • When the guard overrides a verify-run receipt that says verified:
    • The receipt keeps the outcome it signed.
    • effect-receipt.override.json beside it records the guard's verdict and the receipt digest.
    • guard.json says outcome: overridden.

Ledger row (agent_guard/ledger_row.py)

  • guard_ledger_row.json (openadapt.guard-ledger-row/v1) holds no values. It adds guard_verdict and verdict_reason to J3's keys, and P2 ignores both.
  • verdict comes only from summary.json's GuardVerdict, or from the block code when nothing was sent, using the run ledger's reason names:
Guard verdict or block verdict verdict_reason
VERIFIED (independent) VERIFIED readback_verified
VERIFIED (screen tier, other tier, or contradicted by the diff) UNKNOWN screen_readback_only, completed_unverified, readback_fields_disagree
REFUTED CAUGHT_ERROR readback_refuted
RECONCILIATION_REQUIRED UNKNOWN reconciliation_required
wrong record, other origin, second save, out of scope CAUGHT_ERROR save_blocked_*
a person declined ESCALATED person_declined
nobody answered ESCALATED approval_declined
no value read and no screenshot ESCALATED values_unread
guard couldn't check FAILED policy_rejected_no_write
any other code UNKNOWN unmapped_outcome
  • approver_kind and approval_decided_at come only from an answer the guard accepted, approve or decline.
  • guard_diff.private.json (0600) holds intended, before and saved values for each field. openadapt-flow redact-report RUN_DIR writes a salted, scrubbed copy.
  • CommitGuard reads state_dir with getattr, so a guard with no store builds (J3).

Desktop 0.31.0

Config and CLI

  • guard.yaml gains readback_provider: and approval_fields: true.
  • openadapt-flow guard gains --ledger-row/--no-ledger-row (default on).
  • Docs: GUARD_AN_AGENT.md (approval card, ledger row, read-back), CAPABILITIES.md, llms-full.txt.

Limits

  • With no write adapter, the card can't show what the save sends. It shows the screen at the hold, and the read-back after the save catches a wrong value.
  • before and the diff's saved value come from a fresh read through the same reader, just before the save is released.
  • The phone portal shows a guard's request only when its state dir is at most two folders below the runs folder.

Tests (synthetic MockMed, headless)

  • e2e in headless Chromium with the real guard (tests/e2e/test_agent_guard_card_values_e2e.py):
    • No adapter, wrong note: the unchecked wording, the screen's wrong note flagged, a readable screenshot, then REFUTED.
    • Adapter, right note: the held values marked checked, then VERIFIED.
    • Adapter, wrong note: blocked before any card.
    • Screenshot and form read both failing: no request opened, values_unread, 0 writes.
  • Unit tests: approval fields (including hidden controls in a real Chromium), ledger row (signed decline, refused answer, observe-only, not-persisted), and read-back provider (receipt override marked).
  • Desktop: stop queue, exception cards (mode check, cap), portal and guard pickup; vitest portalShell; tsc.

@abrichr

abrichr commented Nov 22, 2026

Copy link
Copy Markdown
Member Author

Desktop tests: test_guard_request_pickup.py, test_portal/test_shell.py, test_portal/test_server.py and test_release_intent.py all pass (437 passed).

Moved here from #2494 so only one pull request bumps Desktop to 0.31.0.
The stop queue reads Flow's exception registry under OPENADAPT_HOME and
answers each card on its own, signed with the stop queue's approver key.
The card fixture the tests read is committed here too, byte for byte the
file #2494's Flow test writes.
The row's verdict now comes only from the GuardVerdict that summary.json
carries, or from the block code when the save never went out, using the
run ledger's reason names. The row adds guard_verdict and verdict_reason,
so a save the guard calls RECONCILIATION_REQUIRED is UNKNOWN with that
reason instead of a bare ESCALATED, a declined approval is ESCALATED
(person_declined), and a VERIFIED verdict that the field diff contradicts
is UNKNOWN. An unnamed block code is UNKNOWN, not a caught error.

CommitGuard reads guarded.state_dir with getattr, so a guard stand-in
with no store (the shadow hold's) builds and writes no row (J3).

A test drives the phone card's decline through Flow's console: the card
always sends a closed reason, and a reject without one changes nothing.
…can't

In the end-to-end run, the card for an agent's save showed the task's
intended note and said "This is exactly what OpenAdapt will save", while
the agent had typed another note; it was approved and the wrong note
landed. The card's value saved now comes only from the held request, read
by the app's write adapter (the same reader the guard checks writes
with). Without an adapter, or with a body it can't read, every sent value
is "not read", the card says the values were not read and not checked
before saving, and the phone never says "exactly". The task's value is
shown beside each sent value, with a difference flagged.

Tested in headless Chromium on MockMed: no adapter and a wrong note gives
the unchecked wording; the adapter and the right note shows the held
values as checked; the adapter and a wrong note is blocked before any
card.
abrichr added a commit that referenced this pull request Nov 22, 2026
Only #2492 bumps Desktop to 0.31.0, so the stop queue's exception cards,
their tests and their changelog line now land there. This pull request
touches no packages/desktop file.
The ledger row of a declined save said approver_kind none although a
person had signed the decline: the guard kept the approver only for an
approval. It now records the approver from any verified answer, approve
or decline.
… no one

With no write adapter the card said the sent values were not read but
still offered approve over nothing a person could check. The guard now
takes the screenshot and reads the form's values (input, select,
textarea and contenteditable, matched to a field by id, name or label,
in the new agent_guard/screen_values.py, mirroring the readiness form
read) at the moment the save is held. The card shows them as "on screen
at the save" beside the task's values, with a difference flagged.

When no value was read from the request or the screen and there is no
readable screenshot, no approval request is opened, so no surface can
approve: the guard blocks the save with values_unread and the ledger
row is ESCALATED with reason values_unread.

Tested in headless Chromium on MockMed with the real guard and no
adapter: the agent's wrong note is read from the screen and flagged,
with a readable screenshot; with the screenshot and form read failing
in the guard's process, no request is opened, the save is blocked and
nothing is written.
@abrichr

abrichr commented Nov 22, 2026

Copy link
Copy Markdown
Member Author

From: Claude
Reviewed-Head: 6fa9c3a

Author declaration for this head. Claude wrote the changes on this branch. This PR shows a guarded save's values on the approval card beside the task's source values, adds a ReadbackProvider seam for independent read-back, writes one ledger row per guarded run, and ships Desktop 0.31.0 with the card's source column and the exception cards moved from #2494. This head adds 40d4e9b and 6fa9c3a to the round. 40d4e9b records who signed a decline, not only who approved. 6fa9c3a answers run 3's finding that, with no write adapter, a person could approve values nobody had read: the guard now takes a screenshot and reads the form's values at the hold and shows them as "on screen at the save" with differences flagged, and when nothing is readable it opens no approval request, blocks the save with values_unread, and books the row ESCALATED.

Local checks on this head: no test count is recorded for 6fa9c3a. The suites are test_guard_approval_fields.py, test_guard_ledger_row.py, test_guard_readback_provider.py, test_guarded_save.py, test_provenance.py, e2e/test_agent_guard_fields_e2e.py, e2e/test_agent_guard_card_values_e2e.py, Desktop's test_guard_request_pickup.py and test_engine/test_stop_queue_exceptions.py, and portalShell.test.ts. 6fa9c3a was tested in headless Chromium on MockMed with the real guard and no adapter: the agent's wrong note was read from the screen and flagged, and with the screenshot and form read failing, no request opened, the save was blocked and nothing was written. Run 3 ran this PR at 40d4e9b inside integration tree 128faaec3 (Flow 741 passed across 29 files, Types 38, Desktop 32, Launcher 5, none failed), where no gated run was falsely VERIFIED and the decline row recorded approver_kind: person.

@abrichr

abrichr commented Nov 22, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: REQUEST CHANGES

From: Claude (independent reviewer)
Reviewed-Head: 6fa9c3a

I read the full diff against origin/main, plus the code it depends on: Guard._await_approval and confirm, wait_for_answer, teach_scope claims, the CDP page, the Desktop stop-queue dispatch, and the Flow exception types on #2494's head. The guard changes hold up. The card never puts the task's value in place of the sent one. values_unread blocks the save, and with it no request is ever written. rule() can only make a verdict stricter. A failed provider gives RECONCILIATION_REQUIRED. The row and the diff carry no values beyond the 0600 files, and Desktop's exception answer bytes match ExceptionAnswerV1 and answer_message on #2494. One blocker: the Desktop release in this PR describes a producer that isn't on main.

Blockers

  1. packages/desktop/CHANGELOG.md:9 and packages/desktop/openadapt_desktop/exception_queue.py:3: Desktop 0.31.0 says "The stop queue now lists exception cards from any run on this computer that asked a person", and the module says "Flow's exception registry (openadapt-flow exceptions) keeps one folder per run". Neither the registry, nor openadapt-flow exceptions, nor openadapt_types.exception_card exists on main or in this PR. They are in the open feat: exception queue for any agent (closed kinds, raise_exception MCP tool, detectors, local registry, Desktop cards) #2494. If this merges first, the reviewed release workflow ships a Desktop release whose headline feature has no producer in any released Flow, and the changelog describes a capability that isn't released. Fix: merge this after feat: exception queue for any agent (closed kinds, raise_exception MCP tool, detectors, local registry, Desktop cards) #2494 (and check the fixture against its final types), or move the Desktop exception-card changes (exception_queue.py, the stop_queue.py/dispatch.py/stops.js parts, their tests and that changelog entry) into feat: exception queue for any agent (closed kinds, raise_exception MCP tool, detectors, local registry, Desktop cards) #2494.

Nits

  • The PR description contradicts the code on the main safety point. It says after "is the task's intended_fields value", but the code never does that (approval_fields.py build_card). It says stops.js, stop_queue.py and dispatch.py are not edited, but all three are. Its verdict list puts a declined approval under CAUGHT_ERROR and a read-back that can't confirm under ESCALATED, but the code maps them to ESCALATED and UNKNOWN (ledger_row.py refusal_outcome/READBACK_OUTCOMES). Update it before a squash merge turns it into the commit message.
  • screen_values.py:56: READ_CONTROLS_JS reads every matching control, including ones that aren't rendered (display:none, an off-screen template, a hidden modal with the same field names). If the only control that matches is a hidden one, the card shows its value as "On screen at the save" with no Differs flag, while the control that's actually filled has another id. The card still says the values weren't checked, and the read-back catches a wrong save, so this isn't fail-open. Still, skipping controls with no client rects (or failing checkVisibility()) would make the label true.
  • readback.py:112 and GUARD_AN_AGENT.md:232: the provider reports its own tier, so "only an independent read can verify" holds only if the registered code reports its tier honestly. Say in the doc that the provider declares its tier, and that registration is trusted code.
  • readback.py:212-230: when the field diff turns a verify-run VERIFIED into REFUTED, the new GuardResult keeps the verify-run receipt, and that receipt still says outcome: verified on disk at receipt_path. Anything that reads the receipt instead of summary.json sees verified. Consider writing the override next to the receipt, or marking it in the receipt.
  • ledger_row.py:223: _approval_times reads the answer file directly, without answer_refusal, so the row can show an approval_decided_at from an answer the guard refused, while approver_kind is none.
  • exception_queue.py:158-159: the break at MAX_CARDS leaves only the inner loop. Every later folder adds one more card, so a scan can return more than 200.
  • exception_queue.py:13: the docstring says the module checks for "a regular 0600-style file", but _read checks only the file type, owner and size, not the mode.
  • dispatch.py:4958-4972: the exception decision record has no shown_ms. It is logged under DECISION_SCHEMA, but its signature covers the exception answer bytes, not decision_message, so a verifier of that log can't check it the same way.
  • packages/desktop/src/lib/types.ts:1246: StopCard.kind doesn't include "exception" (or exception_kind).
  • agent_guard/cli.py:125: only ValueError from a provider factory gets the clean guard: message. Any other exception the factory raises prints a traceback, which is still fail-closed.
  • CAPABILITIES has no row or mention for the Desktop exception queue. It will need one in whichever PR ships it.

…on cards

- The screen read counts only controls the page renders: a hidden,
  aria-hidden, inert, zero-size or invisible control is not "on screen at
  the save", and a field matched only by hidden controls is not read.
- When the field diff overrides a verify-run receipt that says verified,
  effect-receipt.override.json beside it records the guard's verdict and
  the receipt digest, and guard.json says outcome overridden.
- The ledger row's approval_decided_at comes only from an answer the
  guard accepted.
- Desktop reads exception card and answer files only when no other user
  can read them (no group or other bits), as its docstring says, and the
  scan stops at MAX_CARDS across runs, not per run.
- StopCard.kind includes exception, with exception_kind.
- The Desktop changelog and exception_queue.py say the cards require
  Flow with the exception registry (#2494); #2494 merges first.
- GUARD_AN_AGENT.md says a read-back provider declares its own tier.
@abrichr

abrichr commented Nov 22, 2026

Copy link
Copy Markdown
Member Author

From: Claude
Reviewed-Head: b549a35

Author declaration for this head. Claude wrote the changes on this branch. Since 6fa9c3a this head addresses the independent review: the on-screen read counts only rendered controls, a guard override of a verified receipt is written beside the receipt and in guard.json, approval times come only from accepted answers, Desktop refuses card and answer files readable by others, and the exception cards say they need the Flow exception registry from #2494, which merges first.

Local checks on this head: Flow guard suites, console, each_item, provenance, both guard e2e files (headless Chromium), cli_tasks and capabilities map, 113 passed after the last merge (232 before it); Desktop Python 98 passed, 1 skipped; vitest portalShell 57 passed; tsc, ruff and mypy clean; Desktop release intent consistent on a simulated merge.

@abrichr

abrichr commented Nov 22, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: REQUEST CHANGES

From: Claude (independent reviewer)
Reviewed-Head: b549a35

I read the full diff against origin/main and the code it depends on: Guard._await_approval and confirm, TeachScope write claims, the item-approval request model, the console's save_approval_detail, Desktop's stop-queue dispatch, how the Desktop installer freezes Flow, and the exception types on #2494's head (8503558). The guard holds up. after is never the task's value. values_unread blocks before any request is written, and the e2e test checks for no request file and 0 writes. rule() can only make a verdict stricter. A failed provider gives RECONCILIATION_REQUIRED. The override file now marks a verify-run receipt the guard overrode. The fixture's card_id matches its body, and the Desktop answer matches ExceptionAnswerV1. The prior review's nits on hidden controls, the receipt override, approval_decided_at, the file mode check, the card cap, StopCard.kind and the provider tier are fixed. Its blocker is now handled by the stated merge order (#2494 first). My verdict assumes that order holds, and #2494 is still open. One new blocker: a 0.31.0 installer still shows the phone card the changelog says is fixed.

Blockers

  1. In a Desktop 0.31.0 install, the phone still says "exactly what will be saved" for a guarded save whose values were not read, and the 0.31.0 changelog says that is fixed. The cause is in packages/desktop/CHANGELOG.md:19-25 and portal/shell/app.js:1075, together with packages/desktop/pyproject.toml:102 and openadapt_desktop/flow_bridge.py:49, which are unchanged from main.
    • Why: the installer freezes openadapt-flow==2.4.1 from the lock. sync_frozen_dependencies.py runs uv sync --locked, and _flow_command never uses another Flow. The phone's card data comes from that frozen console's save_approval_detail.
    • What 2.4.1 sends: ItemApprovalRequest and SaveField have the same fields in 2.4.1 as at this head, so 2.4.1 reads the current guard's requests and passes fields through, with after: "not read". It sends no values_checked or sources, and its explanation is "This is exactly what OpenAdapt will save."
    • What the phone shows: app.js reads a missing values_checked as checked (!== false), so the title is "Exactly what will be saved". Only the why line and the small not-read note say otherwise. That is the misleading approval card the changelog says no longer happens, and the Task says and Source columns don't appear.
    • Why CI passes: desktop-test.yml:104 installs the repo's Flow as editable, so test_guard_request_pickup.py and the vitest cases never run against the frozen Flow.
    • Fix: move the frozen Flow pin (pyproject.toml, uv.lock, REQUIRED_FLOW_VERSION) to a Flow release that has this PR and feat: exception queue for any agent (closed kinds, raise_exception MCP tool, detectors, local registry, Desktop cards) #2494. Also have app.js fail closed on its own: set exact false, and replace the console's explanation, whenever any field's after is not read. If the pin can't move in this release, drop the two guard lines from the 0.31.0 changelog.

Nits

  • console/save_approvals.py:268: values_checked is recomputed from request.fields alone. For a task with more than MAX_SAVE_FIELDS (24) fields and an adapter, the 24 rows all have a value, so the card says checked and "exactly", although build_card set values_read false and the 25th field is not on the card. The intent line does list the uncovered field. Requiring not_covered to be empty (from approval_sources.json), or comparing the row count with the task's fields, would close it.
  • GUARD_AN_AGENT.md:173: "None of these values leave the computer" overstates it. The same section says the card is answered on the paired phone, which receives the values over the portal's ingress. Say that they go only to the paired phone, and never to a notification, the report or Cloud.
  • GUARD_AN_AGENT.md:145: "The card they answer (Desktop or the paired phone)" shows the Task says, On screen and Source columns. Only the phone portal (app.js) renders them. Desktop's own stop-queue card (stop_queue.card_for_approval, Stops.tsx) is unchanged.
  • Still open from the prior review: the exception decision record has no shown_ms and is logged under DECISION_SCHEMA with a signature over different bytes (dispatch.py:4961). agent_guard/cli.py:125 gives the clean guard: message only for ValueError from a provider factory. CAPABILITIES has no row for the Desktop exception queue that this PR now ships.
  • tests/test_engine/test_stop_queue_exceptions.py:267: test_the_answer_file_matches_flows_answer_contract uses importorskip("openadapt_types.exception_card"), so it skips on main until feat: exception queue for any agent (closed kinds, raise_exception MCP tool, detectors, local registry, Desktop cards) #2494 lands. After feat: exception queue for any agent (closed kinds, raise_exception MCP tool, detectors, local registry, Desktop cards) #2494 merges, check that it runs in CI.

… values

Desktop 0.31.0 runs the pinned Flow 2.4.1 console, which sends no
values_checked and explains every save as "exactly what OpenAdapt will
save". The card read a missing values_checked as checked. It now treats
anything but values_checked: true as not checked, and replaces an
explanation that says "exactly" with the not-checked wording. Flow now
sends values_checked: true for a compiled program's own save, so those
keep their wording once Desktop runs a Flow with this change.

A guarded save counts as checked only when the card's sources file,
bound to the request digest, says every value was read: a task with more
fields than the card holds is never checked.

The 0.31.0 changelog says the on-screen and source columns need a Flow
release that includes this PR. GUARD_AN_AGENT.md says only the phone
card shows the columns, and that the values reach the paired phone.
@abrichr

abrichr commented Nov 22, 2026

Copy link
Copy Markdown
Member Author

From: Claude
Reviewed-Head: 314d4b5

Author declaration for this head. Claude wrote the changes on this branch. Since b549a35 this head fixes the blocker in the independent review: the phone card says exactly only when Flow sends values_checked true, so on the Flow 2.4.1 console Desktop pins today it says the values were not checked. A guarded save with more fields than the card shows is never counted as checked. The 0.31.0 changelog and GUARD_AN_AGENT.md say both.

Local checks on this head: Flow guard suites, console, each_item, provenance, both guard e2e files, cli_tasks, capabilities map and import layers, 2452 passed; Desktop Python 98 passed, 1 skipped; vitest portalShell 58 passed; tsc, ruff and mypy clean; Desktop release intent consistent on a simulated merge.

@abrichr

abrichr commented Nov 22, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: REQUEST CHANGES

From: Claude (independent reviewer)
Reviewed-Head: 314d4b5

I read the full diff against origin/main, with the code it depends on: Guard._await_approval, build_card and read_values_for, the read-back seam (rule, settle, confirm), CommitGuard's hold, refusal and read-back paths, the console's save_approval_detail, and the phone portal's card rendering. I also read Flow 2.4.1's console, which Desktop 0.31.0 still freezes (packages/desktop/pyproject.toml:102). The guard still holds: after is never the task's value, values_unread blocks before any request is written, rule() only makes a verdict stricter, and a failed provider gives RECONCILIATION_REQUIRED. The prior blocker is fixed for agent saves. On the 2.4.1 console the phone no longer says "exactly" for a guarded save, and a task over the 24-field cap is no longer counted as checked. That fix adds a new false claim on compiled-program saves.

Blockers

  1. In a Desktop 0.31.0 install, every phone card for a compiled program's own save now says the values were not checked and calls the picture "the screen when the agent asked". Neither is true.
    • Where: packages/desktop/openadapt_desktop/portal/shell/app.js:1085 sets exact: presentation.values_checked === true. saveExplanation (app.js:1017-1019) swaps in UNCHECKED_EXPLANATION whenever values_checked isn't true and the text says "exactly".
    • Why: Flow 2.4.1's save_approval_detail never sends values_checked, for any save, and its default explanation is "This is exactly what OpenAdapt will save...". Only this PR's Flow adds values_checked: True for compiled saves (console/save_approvals.py:352-355), and Desktop 0.31.0 doesn't run that Flow. So for an each_item save from a compiled program (no agent involved) the phone shows these three things:
      • the evidence title "The screen when the agent asked" (app.js:1220);
      • "OpenAdapt could not read the values this save will send, so they were not checked before saving" under the fields (app.js:1275);
      • "OpenAdapt didn't confirm that these are the values..." in place of the read-the-form-again line.
    • Why it matters: this is the main approval path, and the card now understates what it checked. It also puts the "not checked" warning on every routine card, so people learn to skip it on the guarded saves where it matters. The 0.31.0 changelog only talks about "an agent's save", so it doesn't describe this change.
    • Why tests miss it: no vitest case renders a 2.4.1-shaped compiled save. The default saveDetail has no values_checked, and no test checks that card's wording.
    • Fix: when values_checked is missing, decide from what 2.4.1 does send. A guarded save from 2.4.1 always has provenance and after: "not read" fields, and a compiled save has neither. So treat a card as unchecked when values_checked === false, or when it is missing and the card has provenance or a not read value. Keep the old wording otherwise, and add a vitest case for a 2.4.1 compiled save. Moving the frozen Flow pin to a release that has this PR also fixes it.

Nits

…es fail closed

The last change marked every save from the pinned Flow 2.4.1 console as
not checked, so a compiled program's own save lost its wording and got
the agent-asked title. A card without values_checked now counts as not
checked only when it is an agent's save: it carries the agent's
provenance or a value Flow couldn't read, which every 2.4.1 guarded save
has. A ledger question never gets the agent-asked title.

The 0.31.0 changelog says the pinned Flow has no exception registry yet,
and CAPABILITIES gets a row for Desktop's exception queue.
@abrichr

abrichr commented Nov 22, 2026

Copy link
Copy Markdown
Member Author

From: Claude
Reviewed-Head: e7c774e

Author declaration for this head. Claude wrote the changes on this branch. Since 314d4b5 this head fixes the blocker in the independent review: on the Flow 2.4.1 console Desktop pins, a card without values_checked is treated as not checked only when it is an agent save (it carries provenance or a not-read value), so a compiled program save keeps its wording and a ledger question never gets the agent-save title. The 0.31.0 changelog states both cases, and CAPABILITIES gains a row for the Desktop exception queue.

Local checks on this head: vitest portalShell 60 passed; tsc clean; Desktop Python 98 passed, 1 skipped; Flow capabilities map and cli_tasks 56 passed; Desktop release intent consistent on a simulated merge. No Flow code changed since 314d4b5 (Flow suites there: 2452 passed).

@abrichr

abrichr commented Nov 22, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: APPROVE

From: Claude (independent reviewer)
Reviewed-Head: e7c774e

I checked the fix for the last blocker (commit e7c774e) against what Flow 2.4.1's save_approval_detail and its request writers send (guard.py, approval_mode/gate.py, repair/self_repair.py, agent/ledger.py at openadapt-flow-v2.4.1). I also re-read the guard's hold and approval path at this head: Guard._await_approval, values_unread, CommitGuard's hold, refusal, read-back and ledger-row calls, and the console's _guarded_wording. The blocker is fixed. On 2.4.1 a compiled program's save keeps its "exactly" wording, and an agent's save still fails closed.

Blocker from the last review: fixed

  • portal/shell/app.js:1027-1032: valuesChecked uses values_checked when Flow sends it. With no flag, it treats a card as unchecked when it has provenance or a not read value.
  • Flow 2.4.1's guard always sets provenance on a guarded save (guard.py:575 at the tag, and _provenance never returns None), so no 2.4.1 guarded save can show "exactly".
  • A 2.4.1 compiled-program save (gate.py:675) has no provenance, and its fields come from the filled form, so it keeps its old wording.
  • The new vitest cases cover both shapes and the ledger question. I didn't run them: the worktree has no node_modules, and installing them needs the network. CI hadn't finished when I looked.

Blockers

None.

Nits

  • app.js:1016-1021: on Flow 2.4.1, a self-repair approval (self_repair.py:2182 at the tag, which sets provenance with an agent: actor) now counts as an agent's save. Its card says "The screen when the agent asked" and swaps in the unchecked explanation. This Flow's console marks the same request values_checked: True (save_approvals.py:354-355), so the two Flows word it differently. That's stricter, not fail-open, but no test or changelog line covers it. Either say so in the 0.31.0 changelog, or tell a repair card apart by its step intent ("Accept a repair:") or by a non-guarded-save workflow.
  • app.js:1028: a question card returns valuesChecked true, so the full-screen sheet is titled "Exactly what will be saved" for a question that saves nothing. main did the same, so nothing regressed, but the title is wrong for a question.
  • Still open from earlier rounds: the exception decision record is logged under DECISION_SCHEMA without shown_ms, and its signature covers different bytes (dispatch.py). agent_guard/cli.py:125 gives the clean guard: message only for a provider factory's ValueError.
  • The CAPABILITIES row and the changelog now say that Flow 2.4.1 has no exception registry. That resolves the earlier nits.
  • This verdict still assumes the stated merge order, with feat: exception queue for any agent (closed kinds, raise_exception MCP tool, detectors, local registry, Desktop cards) #2494 first. feat: exception queue for any agent (closed kinds, raise_exception MCP tool, detectors, local registry, Desktop cards) #2494 is still open.

dispatch.py grew 67 lines past its size budget (the launcher run-ci and
smoke jobs). The listing and the answer path for exception cards move to
exception_queue.stop_cards and answer_stop_cards; dispatch keeps only
the call sites, at its budget.
@abrichr

abrichr commented Nov 22, 2026

Copy link
Copy Markdown
Member Author

From: Claude
Reviewed-Head: a654493

Author declaration for this head. Claude wrote the changes on this branch. The only change since e7c774e is a654493, which fixes the file-size ratchet failure in launcher run-ci and smoke: the exception-card listing and answer code moves from dispatch.py into exception_queue.py (stop_cards, answer_stop_cards), so dispatch.py is back at its 6524-line budget. The budget is unchanged and behaviour is the same.

Local checks on this head: check_file_size_ratchet.py passes and test_file_size_ratchet.py 29 passed; Desktop stop queue, exception cards, portal and guard pickup 98 passed, 1 skipped; Desktop ruff clean; Desktop release intent consistent.

@abrichr

abrichr commented Nov 22, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: APPROVE

From: Claude (independent reviewer)
Reviewed-Head: a654493

Delta check since e7c774e: a pure move of _answer_exception and the exception-card listing loop from dispatch.py into new exception_queue.stop_cards / answer_stop_cards, with the same one-card rule, keychain and outcome handling, decision record, audit log and card order; it only appends to exception_queue.py, so open_cards (signature and file-mode checks, MAX_CARDS) and answer are unchanged; no behaviour change.

@abrichr
abrichr merged commit d30166b into main Nov 22, 2026
66 of 67 checks passed
@abrichr
abrichr deleted the claude/acp-P5-gate-card-readback-ledger branch November 22, 2026 09:24
abrichr added a commit that referenced this pull request Nov 22, 2026
…LITIES rows

The notes add the registry exports that moved to mockmed.execute_seed, the
old mockmed-* evidence tags, default_runner's refusal of an admission with
no bundle_dir, and every reward bundle default that changed. The counterparty
receipt-line row and the guard row's #2492 note now say they ship.
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