Repository navigation
feat(guard): approval card values beside the source, ReadbackProvider seam, per-save ledger row - #2492
Conversation
|
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). |
…rd-readback-ledger
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.
…rd-readback-ledger
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.
…rd-readback-ledger
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.
…rd-readback-ledger
… 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.
|
From: Claude 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 Local checks on this head: no test count is recorded for 6fa9c3a. The suites are |
Independent adversarial review: REQUEST CHANGESFrom: Claude (independent reviewer) I read the full diff against Blockers
Nits
|
…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.
…rd-readback-ledger
|
From: Claude 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. |
Independent adversarial review: REQUEST CHANGESFrom: Claude (independent reviewer) I read the full diff against Blockers
Nits
|
… 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.
|
From: Claude 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. |
Independent adversarial review: REQUEST CHANGESFrom: Claude (independent reviewer) I read the full diff against Blockers
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.
|
From: Claude 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). |
Independent adversarial review: APPROVEFrom: Claude (independent reviewer) I checked the fix for the last blocker (commit e7c774e) against what Flow 2.4.1's Blocker from the last review: fixed
Blockers None. Nits
|
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.
|
From: Claude 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. |
Independent adversarial review: APPROVEFrom: Claude (independent reviewer) Delta check since e7c774e: a pure move of |
…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.
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)item_approval.SaveField:beforeis the record's value now, read through theverify.yamlreader.afteris the value the held request sends, read by the app'swrite_adapter, the same reader the guard checks writes with. Without an adapter, or when it can't read the body,afterisnot read. It is never the task's value standing in for it.approval_sources.json(0600, bound to the request digest):intended: the task's value, withheld_differswhen the sent value differs.screen: with no write adapter, the value the form shows when the save is held, withscreen_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 oraria-hiddencontrols don't count.source: the provenance value, cross-checked against the source document.values_checkedfrom 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.values_unread, and the row is ESCALATEDvalues_unread.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 defaultVerifyRunReadbackwrapsGuard.confirmunchanged.rule()sets the final verdict:independent_readbackcan be VERIFIED.effect-receipt.override.jsonbeside it records the guard's verdict and the receipt digest.guard.jsonsaysoutcome: overridden.Ledger row (
agent_guard/ledger_row.py)guard_ledger_row.json(openadapt.guard-ledger-row/v1) holds no values. It addsguard_verdictandverdict_reasonto J3's keys, and P2 ignores both.verdictcomes only from summary.json's GuardVerdict, or from the block code when nothing was sent, using the run ledger's reason names:verdictverdict_reasonreadback_verifiedscreen_readback_only,completed_unverified,readback_fields_disagreereadback_refutedreconciliation_requiredsave_blocked_*person_declinedapproval_declinedvalues_unreadpolicy_rejected_no_writeunmapped_outcomeapprover_kindandapproval_decided_atcome 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_DIRwrites a salted, scrubbed copy.CommitGuardreadsstate_dirwithgetattr, so a guard with no store builds (J3).Desktop 0.31.0
exception_queue.py, plus edits tostop_queue.py,dispatch.pyandstops.js), moved from feat: exception queue for any agent (closed kinds, raise_exception MCP tool, detectors, local registry, Desktop cards) #2494. Card files must be owned by this user with no group or other permission bits. The scan stops at 200 cards in all.StopCard.kindincludes"exception".check_release_intent.pypasses on a simulated merge withorigin/main.Config and CLI
guard.yamlgainsreadback_provider:andapproval_fields: true.openadapt-flow guardgains--ledger-row/--no-ledger-row(default on).GUARD_AN_AGENT.md(approval card, ledger row, read-back),CAPABILITIES.md,llms-full.txt.Limits
beforeand the diff's saved value come from a fresh read through the same reader, just before the save is released.Tests (synthetic MockMed, headless)
tests/e2e/test_agent_guard_card_values_e2e.py):values_unread, 0 writes.portalShell;tsc.