Repository navigation
fix(kernel): autopilot requires a signed VERIFIED_AUTOPILOT pack - #2779
Conversation
Autopilot read the pack's stage from unsigned JSON and never checked it, so a SHADOW pack could submit through run_portal_pack, the CLI and MCP. - run_portal_pack(mode="autopilot") now loads the pack through the registry's signature, digest and zero-PII check against a pinned key (trusted_pack_public_key / --trusted-pack-pub) and requires the signed stage to be VERIFIED_AUTOPILOT. Anything else returns ESCALATED before the browser opens. Draft mode still accepts flat or signed packs. - NonDomKernelExecutor: autonomy_stage can only lower the pack's stage. - Self-heal no longer promotes or publishes its own pack; it qualified the pack against the values it had just written. - MCP server: mode ceiling, keys and output root are server config (serve-mcp flags). Tool calls default to draft, cannot pass key paths or other undeclared arguments, and write only under the output root. - pull_verified_pack raises ValueError instead of relying on assert. - New publish-pack command; README drops the stale line-count claim. - Version 0.2.0.
A pack's signed VERIFIED_AUTOPILOT stage covers the pack as signed, not an in-memory repair from coding_agent_fn. Before this change: - When staging failed or the commit control was blocked, the model's unqualified repair was replayed on the live page and could click Save. A blocked Save behind an overlay ended VERIFIED. - When read-back refuted persistence after the commit click, the heal re-submitted. A dropped write was posted twice and reported VERIFIED. Now, in autopilot, the heal runs in the zero-PHI twin only and the run returns ESCALATED with heal_proposed=True and nothing clicked. A refuted read-back after the click escalates with readback_refuted_after_commit and adds a pending uncertain_write_reconcile obligation; it never heals, re-clicks or re-submits. Draft mode had no heal path and is unchanged.
Independent adversarial review: REQUEST CHANGESFrom: Grok The stage gate works as described. Each bypass in the PR body is closed at this head, and I found no exception path that falls through to a commit. Two gaps remain on the autopilot commit path. I reproduced both at this head, and both are small fixes. Blocking1. A signed pack does not bind the run to the pack's
2.
Checked and OK
Generality gate
Tests at this head (box, Linux, py3.12, Playwright Chromium)
Not run
CI at this headEvery job that ran passed, including To the PR author: please add the origin binding and the post-click obligation, with tests, and request a re-review on the new head. I didn't push to this branch. |
…lick uncertain write A signed VERIFIED_AUTOPILOT pack now approves its own portal_origin only. Autopilot returns ESCALATED (autopilot_origin_not_signed) unless the page has exactly that scheme, host and port: before the browser opens when url is elsewhere, after navigation, redirects or CDP attach, on any popup before it is staged, and right before the commit click. A pack without a valid http(s) origin cannot run autopilot. Every exit after the commit click that does not end VERIFIED now adds an uncertain_write_reconcile obligation to the ledger and signed receipt and sets RunResult.uncertain_write: commit_not_observed, read-back refutation, completion-closure failure, and an exception after the click (now ESCALATED post_commit_error:<type> instead of raising).
Independent adversarial review: APPROVEFrom: Grok Both blockers from my review of Prior blockers1. Origin binding: fixed.
2. Uncertain write after the click: fixed, as a class.
3. Evidence statement: the PR body now says the evidence is synthetic local fixtures only and that there is no held-out evidence. Non-blocking notes
Generality gate
Tests at this head (box, Linux, py3.12,
|
Problem
In
openadapt-kernel, autopilot did not check the pack's autonomy stage._load_portal_packreadstagefrom unsigned JSON, andrun_portal_packwent on to click the commit control without looking at it. So
openadapt-kernel run --mode autopilot --commit-selector ...submitted aSHADOWpack. The registry's Ed25519 verifier (pull_verified_pack) existed,but the runner never called it. Three more paths let a caller or a model widen
autonomy:
NonDomKernelExecutor.execute(autonomy_stage=...)replaced the pack's stageinstead of capping it.
written (
observed_readback=expected_vars), promoted it toVERIFIED_AUTOPILOTand published it.kernel_run_packlet the model choosemode: autopilot, thesigning key path and any output path.
portal_origin. A pack signed for one origin could submit a form on anotherthrough
urlorcdp_url, including over MCP with--allow-autopilot.readback_refuted_after_commit)recorded the possibly-landed write.
commit_not_observedand the others didnot.
Fix (fail closed)
Autopilot gate.
run_portal_pack(mode="autopilot")loads the pack onlythrough
pull_verified_packagainst a pinned key:trusted_pack_public_key,or
--trusted-pack-pubon the CLI. The signed stage must beVERIFIED_AUTOPILOT. A missing key, an unsigned file, a foreign key, anenvelope edited after signing, or any other stage returns
ESCALATEDwith areason, before the browser opens. Nothing is submitted. Draft mode still
accepts flat or signed packs.
Origin binding. The signed
portal_originis the only origin autopilotmay act on. Unless the page has exactly that scheme, host and port (default
ports 80 and 443), the run returns
ESCALATEDwithautopilot_origin_not_signed. The check runs at four points:urlis elsewhere;A signed pack without a valid http(s) origin cannot run autopilot. MCP tool
calls still choose
urlandcommit_selector, but they cannot move theclick off the signed origin.
Every post-click escalation records an uncertain write. Once the commit
control is clicked, any exit that does not end
VERIFIEDadds a pendinguncertain_write_reconcileobligation to the ledger and the signed receiptand sets
RunResult.uncertain_write. That covers:commit_not_observed;readback_refuted_after_commit;finish, even though the write was read back);
ESCALATEDwithpost_commit_error:<type>instead of raising without a receipt.One place in
_finishdoes this, so a new post-click exit cannot skip it.Nondom override.
autonomy_stagecan only lower the stage. An unknownstage string resolves to
SHADOW.Self-heal. The heal path no longer promotes or publishes the pack.
auto_publish_on_healandregistry_dirare still accepted but publishnothing. Promotion now happens only by signing outside the run.
Heal never repairs and commits in one run. The signed stage covers the
pack as signed, not an in-memory repair from
coding_agent_fn.a repair inside the zero-PHI twin. The run returns
ESCALATEDwithheal_proposed=True(reason suffixself_heal_proposed_not_applied) andclicks nothing on the live page. Before, the repair was replayed live; a
Save button behind an overlay was clicked and the run ended
VERIFIED.ESCALATEDwithreadback_refuted_after_commitand records an uncertainwrite (see above). It never heals, re-clicks or re-submits. Before, the heal re-submitted: a dropped
write was posted twice and reported
VERIFIED. This reason replacesreadback_refuted_persistence.MCP. The mode ceiling, trusted pack key, receipt key and output root are
server configuration:
McpServerConfig, set byserve-mcp --allow-autopilot --trusted-pack-pub --priv --output-root. Toolcalls work as follows:
allow it.
private_key_pathor any other undeclared argument.out_pathandreceipt_outonly under the output root(default
~/.openadapt/kernel/mcp).pull_verified_packnow raisesValueErrorfor non-envelope files,non-Ed25519 keys and bad signatures. It used to rely on
assert, whichpython -Ostrips.New
openadapt-kernel publish-pack. This wasn't in the original scope,but without it there was no CLI way to produce a signed pack for autopilot.
Whoever holds the pack key approves autopilot.
README. Dropped the "< 3,200 LOC" claim (
srcis about 16,500 lines) anddocumented the signing requirement and the MCP limits.
Version. Kernel goes to 0.2.0 (breaking: autopilot needs a signed pack)
and the CHANGELOG has an entry. The root
uv.lockpins the PyPI 0.1.0 and isunchanged.
Tests
New file
tests/test_autopilot_stage_gate.py, plus two tests intest_receipt_bridge_and_nondom.py. I ran each bypass test against theunmodified
srcfirst, and each one failed there. The two heal tests wererun against this PR's first commit,
7e87bad60, and the origin anduncertain-write tests against
0b879c8cb:VERIFIED_AUTOPILOTJSON in autopilotVERIFIED, form submittedESCALATED, nothing savedrun --mode autopiloton aSHADOWJSON packSHADOWpack, trusted keyautopilot_pack_stage_not_verified:SHADOWautopilot_pack_signature_invalidDRAFT_TO_COMMIT/SHADOW/unknown pack withautonomy_stage="VERIFIED_AUTOPILOT"READY_FOR_HUMAN_COMMIT, zero submit clicksmode: autopilot/ passesprivate_key_pathisError, nothing submitted, no receipt writtenout_pathoutside the output rootisError, not writtencoding_agent_fnsetVERIFIEDESCALATED, zero POSTscoding_agent_fnsetVERIFIEDreadback_refuted_after_commit, one POST, agent not called, uncertain write in receipturl, same host on the default port, a redirect to B, MCP withallow_autopilot=True)autopilot_origin_not_signed, zero POSTs to A or B; the same pack still submits on Acommit_not_observed, no obligation in receiptcommit_not_observed, one POST,uncertain_write_reconcilein the signed receiptpost_commit_error:RuntimeError, uncertain write in the signed receiptPositive controls: a trusted signed
VERIFIED_AUTOPILOTpack still submitsthrough the API, CLI and MCP (with the server configured for it), and a
signed pack runs in draft mode.
Existing tests changed. About 15 autopilot calls in 6 files ran on unsigned
packs, most with no stage or with
SHADOW. In other words, they relied on thebypass. They now sign a
VERIFIED_AUTOPILOTpack through a small helper(
tests/_signed_packs.py). The self-heal test's publish assertions areinverted: it now asserts that nothing is published. That test and the
bijective-symbols heal test used to assert a live heal ending
VERIFIED. Theynow assert
ESCALATEDwithheal_proposed=Trueand no commit. Two testssigned a pack for
http://127.0.0.1with no port and ran it on a server with arandom port; they now sign a pack for each server's own origin.
All evidence here comes from synthetic local fixtures: local HTTP servers and
headless Chromium on this machine. Nothing ran against a real portal, and there
is no held-out evidence.
Kernel results:
pytest testsgives 149 passed;ruff check .andmypy --ignore-missing-imports srcare clean.Not covered here
NonDomKernelExecutor.executestill trusts the stage on the in-memoryPortalPackit is handed. It can no longer be raised, but the caller's loaderdecides whether that stage was signed.
popup_submit_selectorin a childpopup before returning.
heal_proposedand theegress ledger hash. There is no step for a person to review and apply it
yet.
pack_path,evidence_path) are not sandboxed.origin check; there is no separate check right before that click.
copilot.pyreceipt signing and verification still useassert isinstance.