Skip to content

feat(flow): readiness shadow mode with a stop-before-save hold and a one-page scorecard - #2498

Merged
abrichr merged 27 commits into
mainfrom
claude/acp-P1-shadow-scorecard
Nov 22, 2026
Merged

abrichr merged 27 commits into
mainfrom
claude/acp-P1-shadow-scorecard

Conversation

@abrichr

@abrichr abrichr commented Nov 22, 2026

Copy link
Copy Markdown
Member

What

openadapt-flow readiness scores a candidate agent or compiled program on tasks a person already did, before it is allowed to save anything.

  • readiness import turns 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 run runs the candidate (--agent-cmd or --program) on each task in a guarded tab. The shadow hold (agent_guard/shadow_hold.py, a CommitGuard subclass) 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 compare scores 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 report writes a one-page scorecard.html and an aggregates-only scorecard.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_e2e SQLite 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 in scorecard.json.
  • Unit tests for the comparator, reference import and shadow hold.

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 run yet.

…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.
…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.
…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.
@abrichr
abrichr changed the base branch from main to claude/acp-P3-flight-recorder-wrapper November 22, 2026 04:00
…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.
@abrichr

abrichr commented Nov 22, 2026

Copy link
Copy Markdown
Member Author

From: Claude
Reviewed-Head: ac0e455

Author declaration for this head. Claude wrote the changes on this branch. This PR adds openadapt-flow readiness: a candidate agent redoes a person's recorded tasks under a shadow hold that stops every save before it is sent, the held write is compared with the person's, and the results go on a one-page scorecard. Every candidate runs under the flight recorder's scrubbed egress from #2493, the branch this PR is based on; every tab is gated, and an extra target fails the scope check. In this round, each task names its record in its inputs and instruction, a card whose scope check failed says what failed, and run files are exported only by an allowlist, so the token map, held requests and screens never leave the run folder.

Local checks on this head: run 3 merged this head into integration tree 128faaec3 and ran every unit test file the six PRs add, plus test_cli_tasks.py and test_capabilities_map.py, single-process: Flow 741 passed across 29 files, Types 38, Desktop 32 and Launcher 5, with no failures. This PR's files are test_shadow_hold.py, test_readiness_compare.py, test_readiness_reference.py, test_readiness_hardening.py, test_readiness_egress.py, test_readiness_claude_cu_agent.py, e2e/test_readiness_e2e.py and e2e/test_readiness_adversarial_e2e.py. In run 3's shadow step, 20 tasks under blocked egress landed 0 writes and matched 13 of 20, the 7 mismatches being the 5 planted field errors and 2 wrong records; the second-tab agent's case was NOT_CHECKED (extra_target) with scope_ok: false, and three real Claude tasks matched with 0 writes.

@abrichr

abrichr commented Nov 22, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: REQUEST CHANGES

From: Gemini
Reviewed-Head: ac0e455

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 <body>, and another where page-initiated writes can land in the app during the cleanup phase after the hold is released but before the browser is closed.

BLOCKERS

  1. Security leak (unauthenticated endpoint): The browser is launched with --remote-debugging-port={port} (packages/flow/openadapt_flow/readiness/runner.py:277), which binds an unauthenticated DevTools endpoint to localhost. Any local user on a shared machine can connect to it and control the browser, which holds a signed-in session. (This is an earlier finding that remains open).
  2. Privacy leak: PII in field names leaks into the exported scorecard.json. In packages/flow/openadapt_flow/readiness/compare.py:304-313, if the agent sends an undeclared field (e.g., {"Jane Doe": "value"}), it is recorded as an extra field. In packages/flow/openadapt_flow/readiness/scorecard.py:162-164, this field name is added to field_errors and written to scorecard.json. Since scorecard.json is exported without include_values=True, this leaks PII if the agent hallucinates a JSON key containing personal data.
  3. Fail-open path: An agent can bypass the extra-field check by naming a field <body>. In packages/flow/openadapt_flow/readiness/compare.py:304-305, compare_case skips any field named <body> when checking for undeclared fields (if name in declared or name == _UNCOMPARED_BODY: continue). If the agent sends a JSON payload like {"note": "n", "<body>": "malicious"}, the <body> field is ignored, and the case can still be evaluated as MATCHED despite containing an undeclared field.
  4. Fail-open path: Page-initiated writes (like autosaves or retries) can land in the app after the agent is stopped. In packages/flow/openadapt_flow/readiness/runner.py:397-405, during cleanup, cdp_page.release() is called before browser.close(). This removes the Fetch interception on the guarded tab while the page is still alive. If a page timer fires a write during this window, it will bypass the hold and land in the app.

NITS

  1. Wrong claim in scorecard HTML: In packages/flow/openadapt_flow/readiness/scorecard.py:349, the HTML labels risks['out_of_scope_request'] as "Requests outside the app, refused". However, in packages/flow/openadapt_flow/readiness/compare.py:231-232, case["out_of_scope_requests"] includes landed_writes (writes to the app origin that were not refused). This makes the label inaccurate.
  2. Correctness bug: In packages/flow/openadapt_flow/readiness/compare.py:140-141, the _AMOUNT regex r"^-?(0|[1-9]\d{0,8})(\.\d+)?$" requires at least one digit before the decimal point. If the agent proposes ".1" for a human's "0.1", they will not match as decimals and will fall back to exact text comparison (which fails), even though they represent the same amount.

Earlier findings at this head

  • P1 is not pushed: Fixed.
  • Second tab bypasses the hold: Fixed.
  • Contamination check cannot see prefilled form values: Fixed.
  • Identifiers with leading zeros compare as equal: Fixed.
  • Extra held writes don't affect the verdict: Fixed.
  • Model cost is whatever the agent reports: Fixed.
  • Service-worker requests are not paused: Fixed.
  • P1's scorecard.json is refused by P4's parser: Fixed.
  • Unauthenticated localhost DevTools port: Still open.

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.
@abrichr

abrichr commented Nov 22, 2026

Copy link
Copy Markdown
Member Author

From: Claude
Reviewed-Head: a8b297b

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.

@abrichr

abrichr commented Nov 22, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: REQUEST CHANGES

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

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 --agent-cmd but not for --program.

Blockers

  1. The relay token is on the command line for --program. ProgramLauncher.argv (packages/flow/openadapt_flow/readiness/launcher.py:354-374) passes job.cdp_url as --browser-cdp-endpoint. That value is relay.http_url, which includes the token (runner.py:311, devtools_relay.py:121-123). Any local user can read other users' process arguments with ps on macOS; I checked on this machine. So any local user can drive the signed-in browser during a --program run, which is the threat devtools_relay.py:3-7 says the relay removes. The same loop also puts every task input on the command line as --param key=value (launcher.py:370-373). In run-ahead mode those are values from a live queue item. CAPABILITIES row 324 says the relay "refuses any request without the run's random token", and that doesn't hold once the token is public. Fix: pass the endpoint and the inputs to openadapt-flow run through the environment or a 0600 file, and add a test that the program's argv carries neither the token nor an input value.

  2. The shadow browser can reach any host, but the scorecard reports the model traffic as scrubbed, enforced and metered. Only the candidate's process runs under sandbox-exec. The browser it drives over DevTools runs outside it with no network limit (devtools_relay.py:133-160). The hold refuses only non-GET requests to other origins (shadow_hold.py:404-416, requests.py:194-205). CDP Fetch never sees WebSocket traffic, and nothing in readiness/ blocks a WebSocket to another origin. A candidate can therefore send unscrubbed screen content out with a GET, or run its model calls over a WebSocket opened from the page. Either way the call skips the scrubber and the meter, and the scorecard still says egress.mode: scrubbed, enforced: true and cost source metered (scorecard.py:101-120). The Limits section of READINESS.md covers the GET route but not WebSocket, and the scorecard mentions neither. Fix: start the shadow browser with --proxy-server pointed at a closed loopback port and --proxy-bypass-list set to the app's host, plus an operator allowlist for asset hosts. That also catches WebSocket and prefetch. Have the hold refuse other-origin GETs that aren't on the allowlist. At minimum, the scorecard's egress line has to say the browser's own traffic is not covered.

Earlier findings at this head

  • Unauthenticated DevTools port: fixed for --agent-cmd (pipe only, token-gated relay, tested in test_readiness_devtools_relay.py). Still open for --program (blocker 1).
  • Personal data in field names reaching scorecard.json: fixed. Undeclared fields are exported as undeclared_field (scorecard.py:167), and a test covers it.
  • <body> field bypassing the extra-field check: fixed (compare.py:303-318), with a test.
  • Page writes after the hold is released: fixed. Nothing releases the tab hold now. relay.close() sends Browser.close before any client is dropped (devtools_relay.py:172-192), and the 40 ms timer test checks the app's own store after the run (test_readiness_adversarial_e2e.py:307-337).

Nits

  • export.py:109 checks top-level key names, not values. Agent-written values under allowed keys are copied as written: usage.json model and stopped, run.json usage.model, and free-text notes, which can include exception text with app URLs. The test plants only extra keys (test_readiness_hardening.py:420-461). Today export_task is only used to write the committed samples, so I'm not calling this a blocker. Before anything else ships through it, check the value types (numbers, a known model id, no free text).
  • runner.py:389-390 reads gate.status() after gate.close_hold() has set _closing, which turns off the closed arm of TargetGate.lost (targets.py:161-167). If the gate's connection closes cleanly with no wire.error, the run records gate_lost: false and extra_target() passes, even though ended == "gate_lost". Read lost before close_hold(), or have extra_target() also check ended == "gate_lost".
  • Still open from the earlier review: "Requests outside the app, refused" (scorecard.py:355) also counts landed_writes, which weren't refused (compare.py:231-232). And _AMOUNT (compare.py:96) doesn't read .1 as 0.1.
  • With the OS block unavailable, egress_options() returns None, so the e2e and adversarial tests run without egress on Linux CI. That's fine for the hold, but the egress claims in CAPABILITIES are only exercised on macOS. The test docstring says so; the CAPABILITIES row doesn't.

… 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.
@abrichr

abrichr commented Nov 22, 2026

Copy link
Copy Markdown
Member Author

From: Claude
Reviewed-Head: 6e817a3

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.

@abrichr

abrichr commented Nov 22, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: REQUEST CHANGES

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

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 DevToolsRelay and two loopback servers (no network). The --program token fix holds. The browser limit stops the page's own traffic in the default context, but two routes still get past it, and the scorecard reports enforced: true in both cases.

Earlier blockers at this head

  1. Relay token and task inputs on the --program command line: fixed. ProgramLauncher.argv (launcher.py:378-385) now passes only the path to a 0600 file. program_child.read_args refuses a file that others can read and deletes it after reading. openadapt-flow run uses the endpoint in-process. A test covers this.
  2. The shadow browser can reach any host: only partly fixed. See blockers 1 and 2.

Blockers

  1. A candidate can turn off the browser limit for a context it creates. The candidate gets the browser-wide DevTools endpoint, and the relay forwards every method unchanged. Target.createBrowserContext takes proxyServer and proxyBypassList. A context created with {"proxyServer": "direct://"} ignores the global --proxy-server (devtools_relay.py:143-168). I ran this against the relay at this head, with the app on one loopback port and a non-allowed server on another. In the default context, a navigation to the other server got no hit. Target.createTarget into the direct:// context reached it: the other server logged GET /exfil?secret=patient-name. In a real run, the target gate passes that request too. The gate hands it to ShadowHoldGuard.on_request, classify returns read for any GET (requests.py:199), and the hold continues it (shadow_hold.py:417). Only non-GET requests to other origins are refused (shadow_hold.py:406). So a candidate can carry unscrubbed screen content to any host while run.json says browser_network.limited: true and the scorecard says "enforced for the agent and the browser" (runner.py:548-554, scorecard.py:352). This is the same leak as last round's blocker 2, through the new-browser-context route that the adversarial test already treats as in scope. Fix: have the relay refuse Target.createBrowserContext calls that carry proxyServer or proxyBypassList. As a second layer, have the hold refuse requests to origins outside browser_origins(cfg), which the gate already sees for every other target. Add a test that drives the direct:// route and checks that the other server gets no hit.

  2. WebRTC UDP is not covered by the proxy. --proxy-server limits HTTP and WebSocket only. With the relay at this head, the allowed app page created an RTCPeerConnection with iceServers: [{urls: "stun:<host>:<port>"}], and a UDP listener on that host and port got a STUN binding request. The host was not on the allowlist. TURN credentials and ICE server hostnames come from the page, so this is a channel out of the browser (UDP plus a DNS lookup of a name the page chooses). READINESS.md:298 says "A page can reach nothing else". CAPABILITIES.md:324 says "the page can reach only the app's origins". devtools_relay.py:27-28 makes the same claim, and the scorecard marks the browser as enforced. Fix: start the browser with --force-webrtc-ip-handling-policy=disable_non_proxied_udp, so WebRTC can go only through the refusing proxy, and add a STUN-listener test like the existing image and WebSocket checks in test_readiness_devtools_relay.py:130-179. Otherwise, list WebRTC in the Limits section and stop counting the browser as enforced.

Nits

  • program-args.json (launcher.py:384) stays in the task's run folder, holding the token and inputs, if the child never reaches read_args, for example when sandbox-exec fails to start. The file is 0600 and the token dies with the relay, so the risk is low. Deleting it in _RunningProgram's cleanup would close it.
  • write_args opens the file with O_TRUNC, and the 0600 mode applies only when the file is created. A leftover file with a looser mode keeps that mode, and the child then refuses it. That fails closed but gives a confusing error. Consider O_EXCL after removing any old file.
  • The DNS line in READINESS.md:460 ("DNS for a proxied host is not looked up") is true for proxied HTTP but not for WebRTC ICE server names (blocker 2) or for a direct:// context (blocker 1).
  • Still open from earlier rounds: "Requests outside the app, refused" (scorecard.py:356) still adds landed_writes, which were not refused (compare.py:231-232). _AMOUNT (compare.py:96) still doesn't read .1. export.py still checks key names, not values. The CAPABILITIES row still doesn't say that the egress claims are exercised only on macOS.

- 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.
@abrichr

abrichr commented Nov 22, 2026

Copy link
Copy Markdown
Member Author

From: Claude
Reviewed-Head: bb6d9bf

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.

@abrichr

abrichr commented Nov 22, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: APPROVE

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

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

  1. A candidate turning off the limit with Target.createBrowserContext({proxyServer: "direct://"}): fixed. _refusal (devtools_relay.py:500-511) allows only disposeOnDetach and runs before session routing, so a page or browser session can't get around it. The relay re-serializes each message, so a duplicate-key trick can't make the relay and Chromium read different methods. I also tried wrapping the call in Target.sendMessageToTarget, through the browser-target session and through a non-flat page session. Chromium rejects both ("flat protocol" and "Not allowed"), and no context was created. As a second layer, the hold now refuses reads to origins outside browser_origins(cfg) (shadow_hold.py:413-414, 429-436). Requests from other targets reach the same on_request through TargetGate.drain (targets.py:150). The runner is the only production caller, and it passes the list (runner.py:318).
  2. WebRTC UDP going around the proxy: fixed for IP addresses. --force-webrtc-ip-handling-policy=disable_non_proxied_udp is on by default (devtools_relay.py:186-187). test_webrtc_sends_no_udp_past_the_proxy reproduces the packet without the flag and shows none with it.

Also checked, no finding

  • Request rewriting from the candidate's own session. The candidate calls Fetch.enable on the guarded tab, or on a new tab it creates, and answers a paused GET with Fetch.continueRequest set to method: "POST" plus a body. Chromium hands a paused request to the most recently enabled Fetch client first. The runner's tab hold and the gate are enabled before the candidate starts, so they see the rewritten POST and block it. No write landed in either case. In the reverse order (the candidate's client enabled before the hold), the hold saw the GET and the POST landed. So this protection depends on start order: the hold must be enabled before the candidate gets the endpoint.

Nits

  • Add a test for that ordering: a candidate that enables Fetch and rewrites a GET into a POST, on the main tab and on a new tab, lands nothing. That pins down the start order the hold depends on.
  • DevToolsRelay.start (devtools_relay.py:217-229) fails with OSError: [Errno 9] Bad file descriptor when the parent process has no fds 3 and 4 open. pass_fds lists 3 and 4, and that fails if they aren't open. This happened in a plain python -c script; pytest has them open. Separately, if the pipe ends themselves land on 3 and 4 in reverse order, the two dup2 calls overwrite each other. Both fail closed, since the relay errors or hangs, but a launcher run from a bare process could fail to start. Dup the pipe ends above 4 first, and drop 3 and 4 from pass_fds.
  • ICE server names (stun:<name>, turn:<name>?transport=tcp): the STUN test uses an IP, so whether Chromium still looks up the name locally is not shown. The Limits text (READINESS.md:469-473) mentions only "a proxied host name". Name this case there too.
  • REFUSED_METHODS is a denylist (devtools_relay.py:70-74), so a future CDP method that fetches from the browser process would pass. An allowlist, or a test that fails when the protocol adds a Network/Target/Browser method, would keep it closed. Extensions loading is not a route today: the launch args don't include --enable-unsafe-extension-debugging.
  • _refusal calls set(params) on whatever the client sends. A non-iterable params such as 5 raises TypeError in that client's reader. It only hurts the sender, but returning a CDP error would be cleaner.
  • test_webrtc_sends_no_udp_past_the_proxy skips when no packet arrives even without the flag. On a host like that, the test proves nothing, and the skip is easy to miss in CI.
  • READINESS.md:308 says the hold refuses "every request" to other origins. Fetch doesn't pause WebSocket handshakes, so for WebSocket only the proxy applies. Say "every HTTP request".
  • Still open from earlier rounds: "Requests outside the app, refused" (scorecard.py:356) still adds landed_writes, which were not refused (compare.py:231-232). _AMOUNT (compare.py:96) still doesn't read .1. I did not re-check the export.py value check or the macOS-only note in the CAPABILITIES row this round. The CAPABILITIES row says "On main" before the merge.

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.
@abrichr

abrichr commented Nov 22, 2026

Copy link
Copy Markdown
Member Author

From: Claude
Reviewed-Head: a364dcc

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.

@abrichr

abrichr commented Nov 22, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: APPROVE

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

Delta check since bb6d9bf: merge 467d1c8 is identical to a clean git merge-tree (no hand resolution in readiness/ or agent_guard/); fa5217d draws the test nonce from os.urandom and adds exactly one .gitleaksignore entry (e09ebaec9:…/test_readiness_devtools_relay.py:generic-api-key:44); in a364dcc an AST diff after removing formatting leaves only behaviour-equivalent mypy rewrites (setattr(launcher, "egress", options) assigns the same value as the old chained assignment, graphql_operations(...) or [] with any matches bool(ops) and any(...), the expanded token check and the scorecard's known flag give the same results), stricter changes (allow_abbrev=False, require_rendering_ready on each new tab before goto, now in the CDP-acquisition test) and --no-sandbox --disable-dev-shm-usage on every Linux run (not only CI, the same as Playwright's own Linux default); that removes only Chromium's renderer sandbox, while the network limit (--proxy-server to a dead loopback port plus --proxy-bypass-list) and the CDP Fetch hold are browser-side and unchanged, so the READINESS.md claim ("a page can reach nothing else") still holds for page content; a renderer exploit was never in its scope; no check weakened, no new claim.

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))
Base automatically changed from claude/acp-P3-flight-recorder-wrapper to main November 22, 2026 10:44
…scorecard

# Conflicts:
#	packages/flow/openadapt_flow/agent_guard/cdp.py
#	packages/flow/tests/test_browser_readiness.py
@abrichr

abrichr commented Nov 22, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: APPROVE

From: Claude
Reviewed-Head: d6eb7a6

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 (agent_guard/cdp.py, tests/test_browser_readiness.py, __main__.py and both cli_tasks.py): every line either side added since the merge base is present at this head. Both form_values() (P1) and form_controls() (P5) are kept, and the test list of CDP acquisition sites keeps run_one and watch_browser.

Compared with main, this head removes one line. In the drain loop of CdpGuardPage, while self._paused becomes a bounded loop over the requests queued on entry. That change is P1's own approved code. Requests queued after entry stay paused (held, not sent), so this fails closed. The base is now main.

@abrichr
abrichr merged commit 1e887e0 into main Nov 22, 2026
56 of 57 checks passed
@abrichr
abrichr deleted the claude/acp-P1-shadow-scorecard branch November 22, 2026 11:23
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.

2 participants