Repository navigation
feat(flow): readiness shadow mode with a stop-before-save hold and a one-page scorecard - #2498
Conversation
…one-page scorecard Add openadapt-flow readiness (import, run, compare, report). The shadow hold (agent_guard/shadow_hold.py) subclasses CommitGuard: it records every non-GET request to the app origin as a proposed write and refuses it with the guard's 409 notice. Reference episodes come from the person's network capture or a verify-config read-back, and are refused otherwise. The comparator scores each field, fails closed on uncompared values and flags contamination. scorecard.json carries aggregates only.
…scorecard # Conflicts: # CAPABILITIES.md # llms-full.txt # packages/flow/openadapt_flow/__main__.py
…sed on extra writes - A browser-level Fetch hold (readiness/targets.py) hands every request of every other tab, popup, browser context and worker to the shadow hold; service workers are blocked in the guarded context. A write from another target, an ungated target or a lost gate makes the case NOT_CHECKED with reason extra_target, counted in failed_scope. - The contamination check reads the first value of each form control as well as the screen text; the identity check still reads the screen text only. - values_equal compares identifier-like values (leading zeros, exponents, long digit runs, id/zip/phone/mrn/account names, record fields) as exact text; only plain amounts compare as decimals. - Any held write besides the proposed one makes the case MISMATCHED with reason extra_held_writes. - readiness compare writes case.json into each task run dir; the shadow hold writes no guard ledger row; the scorecard carries task_type, model_cost_usd.source and egress, and prints -$0.75, not $-0.75. - readiness run --storage-state / --keep-session carries a signed-in session across tasks.
Each route (target=_blank form, window.open, Target.createTarget, a new browser context, a shared worker, a dedicated worker) tries to POST an encounter to MockMed from outside the guarded tab; the app's own store shows no write and every outside route fails its case as extra_target. Also covers a service worker in a new context, a session kept across tasks and form values read from a real page. Adds readiness to FLOW_NAMES and states the checked scope in READINESS.md and the CAPABILITIES row.
…apper' into claude/acp-P1-shadow-scorecard
…s egress SubprocessLauncher and ProgramLauncher run each task's candidate under readiness/egress.py, built on openadapt_flow.flight.egress.ScrubbedEgress (J7): --egress scrubbed (default; refuses when the scrubber or the OS egress block can't start), blocked (no model calls; the same OS block) or unscrubbed (synthetic data only; recorded on the scorecard). Cost is the proxy's metered cost (model_cost_usd.source: metered); usage.json is a cross-check, and an agent that reports calls the proxy didn't see is refused for that task (NOT_CHECKED, egress_refused, in failed_scope). Each task gets egress.json and the scorecard an egress object. Adds benchmark/readiness/claude_cu_agent.py, the leaderboard's Claude computer-use loop on the guarded tab with hard step, spend and time caps, unit-tested against a stub upstream. The scripted e2e agents run with --egress blocked.
…ndidate writes usage after each call
…apper' into claude/acp-P1-shadow-scorecard
…ke run The negative control turns the browser-level hold off: 5 of the 6 adversarial routes then land a write in MockMed's store. The scrubbed smoke runs claude_cu_agent.py on MockMed under --egress scrubbed with the real scrubber and a loopback stand-in upstream: 2 metered calls, not refused; the planted patient name in the task text still reaches the stand-in, recorded as an expected failure and as a limit in READINESS.md. Commits results.json and sample run folders (matched, mismatched, extra_target) for the J1/J2 consumers. The e2e files fall back to no egress where the OS block is absent, so the hold is still tested on Linux.
…apper' into claude/acp-P1-shadow-scorecard
…ves; add a wrong-record sample With the flight recorder's fix merged, the patient name planted in the computer-use task text no longer reaches the stand-in upstream, so the expected failure becomes a plain assertion and the READINESS.md limit says what one planted name does and does not show. Adds sample/wrong-record/ for the P2 join test and refreshes the other samples and results.json.
…s what failed readiness import adds the record the guard checks (expected_record) to the candidate's inputs as plain record_<field> inputs and names them in the instruction, so an agent on an app that lists several records knows which to open; a compiled program gets no parameter for them. When scope_ok is false, scope_statement and the page say what failed instead of the claim. The clean statement is shortened to 187 characters (the dashboard's limit is 200).
…loop works with run tokens readiness/export.py copies a task's run files out only by name and allowed keys (run, egress, usage, scorecard; case and proposed write with values), so the flight recorder's egress/pseudonyms.json, held requests, screens and logs never leave the run folder; the committed samples are written through it. Tests plant a pseudonym map, a stray file and a patient name in a run folder and check none reaches the export, the cases or the scorecard, and that the committed samples hold no patient names. A stub-upstream test runs claude_cu_agent through the flight proxy with pseudonyms on: the upstream sees [PERSON_1], and the loop types the real name from the de-tokenized tool input.
|
From: Claude Author declaration for this head. Claude wrote the changes on this branch. This PR adds Local checks on this head: run 3 merged this head into integration tree |
Independent adversarial review: REQUEST CHANGESFrom: Gemini The PR successfully implements the readiness shadow mode, addressing many of the earlier findings (such as guarding extra targets, reading prefilled form values, and routing model traffic through the flight proxy). However, there are still a few critical issues. The unauthenticated DevTools port remains open. There is a privacy leak where an agent can leak PII into the exported scorecard by using it as a JSON key. There are two fail-open paths: one where an agent can bypass the extra-field check by naming a field BLOCKERS
NITS
Earlier findings at this head
Verdict: REQUEST CHANGES |
…scorecard # Conflicts: # CAPABILITIES.md # llms-full.txt
… and closes the browser before any hold lets go - The shadow browser runs with --remote-debugging-pipe and no TCP port; readiness/devtools_relay.py owns the pipe and serves DevTools on loopback under a random per-run token (HTTP and WebSocket), refusing anything without it. Each client gets its own browser target session, so the gate's browser-level hold works as before. OPENADAPT_GUARD_CDP_URL now carries the token. - The runner closes the browser, every target with it, while both holds are on, instead of releasing the tab's hold first; a page timer that keeps posting lands nothing. Draining handles only what was queued on entry, so a page that sends faster than the guard decides can't keep the runner's loop from ending. - The exported scorecard names a field the person didn't save only as undeclared_field, never by the agent's name for it. - No field name is exempt from the extra-field check, <body> included. - Merges the flight recorder at e6a24bd and fresh main; the adversarial agent writes usage.json first.
|
From: Claude Author declaration for this head. Claude wrote the changes on this branch. Since ac0e455 this head fixes the four blockers in the Gemini review: the browser runs with a debugging pipe and no TCP port, behind a loopback relay that requires a random per-run token; undeclared field names leave the scorecard only as undeclared_field; no field name is exempt from the extra-field check; and the runner closes the browser while both holds are on instead of releasing first. It merges P3 at e6a24bd and fresh origin/main. Local checks on this head: both readiness e2e files (headless Chromium), 8 passed; unit suites including the new relay tests, 220 passed, 1 skipped; ruff clean. |
Independent adversarial review: REQUEST CHANGESFrom: Claude (independent reviewer) I reviewed P1's own changes: the diff from the merge base with the P3 branch (e6a24bd) to the head, without the files that came in from main and P3. I read the runner, the DevTools relay, the target gate, the shadow hold, compare, scorecard, export, the launcher and egress code, and the relay, hardening and adversarial tests. I checked the four blockers from the earlier review. Three are fixed. The DevTools blocker is fixed for Blockers
Earlier findings at this head
Nits
|
… browser to the app - ProgramLauncher passes the openadapt-flow run arguments (the relay URL with its token, the task inputs) through a 0600 file the child reads once and deletes (readiness/program_child.py); the child's command line holds only the file path. - The shadow browser starts with --proxy-server at a refusing loopback port and --proxy-bypass-list naming only the app's origin, not-save origins and --browser-allow origins (with <-loopback>), so a page reaches nothing else by GET, image or WebSocket. run.json records browser_network, and the scorecard's egress.enforced is true only when both the candidate's OS block and the browser limit held. - The gate's status is read before its hold closes. - Merges the flight recorder at f3e1957.
|
From: Claude Author declaration for this head. Claude wrote the changes on this branch. Since a8b297b this head fixes the two blockers in the independent review: a compiled program's DevTools URL and task inputs go to the child through a 0600 file it reads once and deletes, never through argv; and the shadow browser can reach only the app and declared origins (a closed loopback proxy with a bypass list), with the scorecard calling egress enforced only when both the agent's OS block and the browser limit held. It merges P3 at f3e1957. Local checks on this head: both readiness e2e files (headless Chromium), 8 passed; unit suites 223 passed, 1 skipped; ruff clean. |
Independent adversarial review: REQUEST CHANGESFrom: Claude (independent reviewer) I reviewed P1's own changes from the last merged P3 commit (f3e1957) to the head, focusing on the latest fix commit (6e817a3): the program-args file, the browser's proxy limit, the gate status order, and the egress fields in the runner and scorecard. I checked the two blockers from the last review and probed the new browser limit with the PR's own Earlier blockers at this head
Blockers
Nits
|
- The DevTools relay refuses Target.createBrowserContext with any key but disposeOnDetach (so no proxyServer "direct://", proxyBypassList or originsWithUniversalNetworkAccess) and refuses Network.loadNetworkResource, Target.exposeDevToolsProtocol and Browser.executeBrowserCommand. - The shadow hold refuses every request, GET included, to an origin outside the browser's allowlist, in every tab and context. - WebRTC may not send UDP around the proxy (--force-webrtc-ip-handling-policy=disable_non_proxied_udp); DNS prefetch is off. - The reviewer's two probes are tests now: a context with its own proxy reaches nothing, and a local STUN listener gets a packet without the flag and none with it. - program-args.json is created with O_EXCL after any old file is removed, and removed again when the child never starts. The DNS limit is stated as untested.
|
From: Claude Author declaration for this head. Claude wrote the changes on this branch. Since 6e817a3 this head fixes the two blockers in the independent review: the DevTools relay refuses a new browser context with network settings (proxyServer, proxyBypassList and any unknown key) and refuses methods that fetch or expose the protocol, the shadow hold refuses every request (GET included) to an origin outside the allowlist, and the browser starts with WebRTC limited to proxied UDP and DNS prefetch off. The reviewer probes are now tests that failed before the fix. Local checks on this head: both readiness e2e files (headless Chromium), 8 passed; unit suites including the relay and agent_guard suites, 226 passed, 1 skipped; ruff clean. |
Independent adversarial review: APPROVEFrom: Claude (independent reviewer) I reviewed P1's own changes from the last merged P3 commit (f3e1957) to the head, focusing on the new fix commit (bb6d9bf): the relay's refusals, the hold's origin check for reads, the WebRTC and DNS flags, and the args-file cleanup. I re-ran last round's two probes and tried three more routes around the limit against the relay at this head, using loopback servers only (no network). Both earlier blockers are fixed, and I found no new blocker. The new tests and the existing relay, hardening and shadow-hold tests pass here (68 passed, the STUN test ran rather than skipped). Earlier blockers at this head
Also checked, no finding
Nits
|
The raw upgrade request sent the RFC 6455 sample nonce, which gitleaks flags as generic-api-key. It is not a credential; the test now sends base64(os.urandom(16)), and one .gitleaksignore fingerprint covers the commit that held the sample value.
- Register the readiness and flight benchmark artifacts in public-artifacts.json (check_release_consistency). - ruff format and import order for the readiness modules and tests; mypy: an Optional GraphQL operation list, typed token counts, the origin list and the metered call count. - Every readiness sub-verb parser, and the scrub-recall corpus and measure CLIs, refuse abbreviated options (allow_abbrev=False). - The runner probes the guarded tab with require_rendering_ready after it attaches over CDP, as every connect_over_cdp site does. - docs/BACKEND_PARITY.md records why readiness import/run take --app-url. - The reference docstring's example save path names no app. - The relay adds Playwright's Linux Chromium defaults (--no-sandbox, --disable-dev-shm-usage) and finds the headless shell under either of its file names, so it starts in CI containers.
|
From: Claude Author declaration for this head. Claude wrote the changes on this branch. Since bb6d9bf this head merges P3's approved head ddf9ae0 and adds two CI fixes. fa5217d: the relay test draws its WebSocket nonce at runtime, and one .gitleaksignore fingerprint covers the old commit, whose flagged value was the public RFC 6455 sample nonce. a364dcc: the readiness benchmark files are registered in public-artifacts.json, 22 files are formatted, 5 mypy errors are fixed, the readiness sub-parsers refuse abbreviated options, the runner checks rendering readiness after connecting over CDP, BACKEND_PARITY.md explains --app-url, a docstring drops an app path, and the relay adds the standard Linux browser flags for CI containers. No check or hold logic was weakened. Local checks on this head: both readiness e2e files, 8 passed; the CI-flagged suites plus readiness and agent_guard suites pass; ruff, ruff format --check, mypy, release consistency and engine generality clean; gitleaks over origin/main..HEAD finds no leaks. |
Independent adversarial review: APPROVEFrom: Claude (independent reviewer) Delta check since bb6d9bf: merge 467d1c8 is identical to a clean |
| app, _ = _server(b"<h1>app</h1>") | ||
| app_origin = f"http://127.0.0.1:{app.server_address[1]}" | ||
| udp = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) | ||
| udp.bind(("0.0.0.0", 0)) |
…scorecard # Conflicts: # packages/flow/openadapt_flow/agent_guard/cdp.py # packages/flow/tests/test_browser_readiness.py
Independent adversarial review: APPROVEFrom: Claude This is a delta check by the coordinator since the approved head a364dcc. I checked it myself; I did not write these changes. The only new commit is a merge of origin/main (923f0a0). I checked the two conflict files and the shared routing files ( Compared with main, this head removes one line. In the drain loop of |
What
openadapt-flow readinessscores a candidate agent or compiled program on tasks a person already did, before it is allowed to save anything.readiness importturns 20 to 50 recorded tasks into reference episodes. The person's save comes from the browser recording's network capture, else from a read-back through the verify config's reader. Anything else is refused.readiness runruns the candidate (--agent-cmdor--program) on each task in a guarded tab. The shadow hold (agent_guard/shadow_hold.py, aCommitGuardsubclass) records every non-GET request to the app origin as the write it would have made, then refuses it with the guard's 409 notice. Autosaves, drafts and locks are held too.readiness comparescores the proposed write field by field against the person's save. Values are normalised, an uncompared field never counts as matched, and contamination makes a case not comparable.readiness reportwrites a one-pagescorecard.htmland an aggregates-onlyscorecard.json: matched N of M, risks, field errors, agent and human time, model cost, and estimated savings with its formula.Docs:
packages/flow/docs/READINESS.md,benchmark/readiness/README.md, the command page and one CAPABILITIES row.Tests
All synthetic (MockMed in front of the
effect_e2eSQLite store, localhost only).tests/e2e/test_readiness_e2e.py: a scripted person does 20 tasks with the network capture on; a scripted agent with 5 planted field errors and 2 wrong-record cases redoes them under the hold. Asserted: no write lands in the app's store, precision and recall 1.0 on the planted errors, 13 of 20 matched, no uncompared case counted as matched, and no note or patient name inscorecard.json.Known gaps
Follow-up commits on this branch address the review findings: guarding every tab and popup, form values in the contamination check, identifier comparison, extra held writes, and egress scrubbing. No real model has run through
readiness runyet.