Repository navigation
feat(acp): onboard Pi as an enforced ACP backend via a gate extension - #10334
Conversation
Design Review (Fable 5) — ✅ PASSDesign-level review of Design review complete. The diff matches the description end-to-end: the gate extension, sealed digest-verified copy, run-dir refusal, nonce-keyed envelope, read-back against pi's command registry, and the completed-call tripwire are all present in the code, the resolver-ladder consolidation is a real simplification, and the specs ( Design-Verdict: PASS Fail-closed gate injection — sealed copy, read-back, nonce, tripwire — is the right shape for enforcing a harness that ships no gate of its own. [DESIGN-REVIEWED] d238d96 |
First Principles Review (Fable 5) — 🟡 CONCERNSPremise-level review of First-Principles-Verdict: CONCERNS
Not justified as shipped
What this change shipsInventory (10 items) — 9 justifiedIntent: let a user run the Pi coding agent (and a fully local model) through Kiro Crew with Crew's permission gate actually enforced — an ADDITION.
WatchThe Windows spawn path rests on an unmeasured adapter premise: Subtractions
[FIRST-PRINCIPLES-REVIEWED] d238d96 |
Opus 4.8 Review — ✅ no blocking findingsReviewed Review detailsI've examined the security-critical surface of this PR directly: the gate-extension envelope parsing with nonce+title verification ( No findings. [OPUS-REVIEWED] d238d96 Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
GPT 5.6 Review — ✅ human override acceptedHuman judgment by @iamwhatever overrides the GPT 5.6 finding for This comment is updated in place on each push. The model was not re-run because an authorized human decision supersedes it. False positive or not applicable? A repository writer can comment: |
Security Scope Review -- 🟡 CONCERNSWhich legitimate operations does Verdict basis: the reviewer's own judgement; no confirmed regression. Security scope review -- adjudicated candidates
No candidate flipped from allowed to refused. Scope-Verdict: CONCERNS TIGHTENING: the shared credential path fence ( ADJUDICATED: 16 candidates, 0 confirmed newly-refused PLATFORM COVERAGE: posix (8 rows: tilde spellings of the leaf's siblings and parents, UNADJUDICATED: the pi gate extension and its envelope path — guards the shell classifier cannot reach, all scoped to the new pi backend (every hook is gated on
[SCOPE-REVIEWED] d238d96 |
722e53c to
7b36ed0
Compare
GPT 5.6 Review —
|
1 similar comment
GPT 5.6 Review —
|
7b36ed0 to
207fe7f
Compare
207fe7f to
726c532
Compare
726c532 to
f2b63f8
Compare
|
/ai-review override gpt f2b63f8: adapter_own_leaves spares the harness its OWN token file, the identical carve-out codex (.codex/auth.json) and OpenCode (.local/share/opencode/auth.json) ship on main; masking it fails every hosted-model session at auth, and the shell-read exposure it carries is repo-wide for all three enforced harnesses, documented in bucket 3 and held for a single decision in #10438 rather than closed for one harness here. Drafted by an agent on the repository owner's instruction. |
Human judgment recorded@iamwhatever marked the gpt AI finding as false positive, not applicable, or explicitly accepted for
This decision applies only to this commit. A new push requires a new judgment. |
f2b63f8 to
ef71a38
Compare
|
/ai-review override gpt ef71a38: adapter_own_leaves spares the harness its OWN token file, the identical carve-out codex (.codex/auth.json) and OpenCode (.local/share/opencode/auth.json) ship on main; masking it fails every hosted-model session at auth, and the shell-read exposure it carries is repo-wide for all three enforced harnesses, documented in bucket 3 and held for a single decision in #10438 rather than closed for one harness here. Rebase-only head (main moved 36 commits; two doc tables and the MCP-array comments re-merged, no functional change since f2b63f8 which this same override cleared). Drafted by an agent on the repository owner's instruction. |
|
AI-review override not recorded: keep the reason to 500 characters or fewer. |
…sion Pi is the `pi` coding agent reached through `pi-acp`, a third-party Node stdio adapter that spawns `pi --mode rpc`. Two components, so the resolver, the install probe and the not-found message each name the half that is missing. Pi has no permission gate of its own: `pi` runs every tool call unasked, and `pi-acp` sends `session/request_permission` only when an extension inside `pi` raises a confirm dialog. So the session loads Kiro Crew's own gate extension into the harness, through a launcher the adapter is told to run in place of `pi`, and before the first prompt asks pi's own command registry whether the extension loaded from Kiro Crew's file, refusing the session otherwise. That is a new `Routing.VERIFIED_GATE_EXTENSION`, because neither existing member describes a harness with nothing to seed. The extension writes the tool call into the dialog as a JSON envelope, and the dispatch parser reads it back so the host gate judges the real tool name, kind and arguments. The adapter accepts the `session/new` MCP array and never forwards it to the agent, so Pi stays outside the session MCP array set and its mirror is recorded as a no-mirror entry with that reason. The frame corpus is live for all seven required classes, on pi-acp 0.0.33 over pi 0.85.1 driving a local Ollama model. The deny differential now derives the home-override variables it scrubs from the auth declarations module instead of a hand-kept list.
ef71a38 to
d238d96
Compare
|
/ai-review override gpt d238d96: adapter_own_leaves spares the harness its OWN token file, the identical carve-out codex (.codex/auth.json) and OpenCode (.local/share/opencode/auth.json) ship on main; masking it fails every hosted-model session at auth, and the shell-read exposure it carries is repo-wide for all three enforced harnesses, documented in bucket 3 and held for a single decision in #10438 rather than closed for one harness here. Drafted by an agent on the repository owner's instruction. |
Human judgment recorded@iamwhatever marked the gpt AI finding as false positive, not applicable, or explicitly accepted for
This decision applies only to this commit. A new push requires a new judgment. |
…sion (kirodotdev#10334) Pi is the `pi` coding agent reached through `pi-acp`, a third-party Node stdio adapter that spawns `pi --mode rpc`. Two components, so the resolver, the install probe and the not-found message each name the half that is missing. Pi has no permission gate of its own: `pi` runs every tool call unasked, and `pi-acp` sends `session/request_permission` only when an extension inside `pi` raises a confirm dialog. So the session loads Kiro Crew's own gate extension into the harness, through a launcher the adapter is told to run in place of `pi`, and before the first prompt asks pi's own command registry whether the extension loaded from Kiro Crew's file, refusing the session otherwise. That is a new `Routing.VERIFIED_GATE_EXTENSION`, because neither existing member describes a harness with nothing to seed. The extension writes the tool call into the dialog as a JSON envelope, and the dispatch parser reads it back so the host gate judges the real tool name, kind and arguments. The adapter accepts the `session/new` MCP array and never forwards it to the agent, so Pi stays outside the session MCP array set and its mirror is recorded as a no-mirror entry with that reason. The frame corpus is live for all seven required classes, on pi-acp 0.0.33 over pi 0.85.1 driving a local Ollama model. The deny differential now derives the home-override variables it scrubs from the auth declarations module instead of a hand-kept list. Co-authored-by: zejiangg <zejiangg@amazon.com>
Problem / Motivation
You cannot pick Pi in Kiro Crew today. Pi drives a local Ollama model from one
models.jsonentry, so selecting it lets a session run entirely on the user's ownmachine. It is also the second harness through the auth seam from #9616 and the first
one with a different shape: two components instead of one, and no permission gate of
its own at all.
That last part is the whole problem.
piruns every tool call without asking, bydesign.
pi-acpsendssession/request_permissiononly when an extension insidepiraises a confirm dialog. The prior research in #6307 recorded Pi as asking per tool
call; on the wire it does not, and the same command runs unasked. A backend offered in
that state would show a gate that gates nothing.
Why it matters
A user who wants a local model gets one, with the same checks every other backend gets.
Every Pi tool call now reaches
HookManager.on_tool_callwith its real name andarguments, or it does not run.
And the seam gets its second measurement, on a harness whose answer to "how is it made
to ask" was "it cannot be, unless we put the gate there ourselves". That measurement is
below, and the number went up.
What changed (motivation → approach → change)
Pi has nothing to seed, so Kiro Crew loads its own gate into it. A small pi extension
ships as package data (
agent_sdk/gate_extensions/pi/kiro_crew_tool_gate.ts). Itintercepts every
tool_callevent and raises pi's confirm dialog with the tool callwritten into the message as a JSON envelope;
pi-acpforwards that dialog assession/request_permission, and the call blocks until the client answers. A launcherin the sandbox run directory execs the resolved
piwith--extension <that file>, andthe adapter is told to run the launcher in place of
pithrough its ownPI_ACP_PI_COMMAND. Nothing is written into the work dir or the operator's pidirectory.
That is verified, not declared. The file the launcher names is a sealed copy: the
packaged bytes are checked against a digest pinned in the driver at every spawn and
written read-only into the sandbox run directory, so a package file an agent rewrote on
a source install is refused before any child starts. Before the first prompt the session
runs the launcher with the adapter's own arguments, asks pi's command registry
(
get_commands), and requires the extension's probe command to be present AND sourcedfrom that copy. An operator extension registering the same name, or the same bytes under
another path, is refused; the probe's source path and the sealed copy are compared as
the same FILE (realpath, case-normalized on both sides), since pi reports the path in its
own spelling. The run directory is a precondition, not a preference:
sandbox._ensure_run_dirfalls back to the system temp directory when
<config_dir>/runcannot be made — afallback that predates this PR and that every sandbox launcher tolerates as a liveness
matter — but this PR is the first to place a SECURITY artifact there, and a gate copy in a
shared directory can be re-chmodded and rewritten by any same-UID process between the
seal and the exec. So the pi spawn requires both artifacts to live under the real run
directory and refuses the session otherwise (
_pi_gate_run_dir), mirroring the posturethe sandbox floor takes when the credential mask cannot be applied; the shared helper is
not changed. And it is guarded in band after that: every call the extension asks about
leaves its
toolCallIdin the envelope — recorded on every reader that answers apermission frame, the auto-approve path included — so a
tool_call_updatereachingcompletedfor an id the gate never asked about kills the harness and fails the turn(
_tripwire_pi_gate) — an adapter release that stops honouringPI_ACP_PI_COMMANDorstops forwarding dialogs costs one tool call, never a silent session. The run-directory
sweep reclaims the gate artifacts of a dead gateway by owner PID (never by age: they are
written once per gateway process and reused). This is a new
Routing.VERIFIED_GATE_EXTENSION: neither existing memberdescribes a harness with no setting to read back. On the client side the dispatch
parser reads the envelope out of the permission frame, so the gate judges
bashwithits command rather than a dialog titled "confirm". It does so only for a session running
the extension and only under a per-session nonce the extension echoes, because on every
harness a permission frame's
rawInputis the model's own tool arguments. A shell commandand a document body (
write'scontent,edit's two halves) are forwarded WHOLE — thedeny rules read the command's text, and the host skips body keys in its command-line scan
only while the arguments are intact — while any other oversize string value is bounded with
pathintact and the call marked untrusted; only an envelope over 200k chars is refused.Two things this harness cannot do are recorded as facts, not gaps to paper over. Pi
accepts the
session/newMCP array and never forwards it to the agent, so it staysoutside
ACP_BACKENDS_SESSION_MCP_ARRAYand its projection is ano-channelentry withthat reason. And a bash result carries no stdout text on this adapter; the model sees
the output, the transcript pill shows the call and its exit code.
The measurement
Round 4 (#10006) touched 36 files: 33 onboarding, 3 seam-gap fixes. The pre-seam
baseline was 38. This PR touches 42 (39 at the first push; review rounds added
sandbox.py,test_sandbox_argv.py,.gitattributesand the standalone fence, andremoved
test_deny_diff.pywhen the AST parser came back out). It does not go down, and the table says why: aharness with no gate of its own pays for the mechanism that gates it, and this repo
keeps its ratchets as hard-coded literals in tests.
agent_sdk/backends.pyRoutingmember, the probe-command tableacp_backends.pyacp/types.pyPROVIDER_LABEL_PI+ id re-exportproviders/acp.pyagent_sdk/tool_gate.pyENFORCED_ROUTINGS, verdict, remedy,gate_extension_issue, labelacp_tool_gate.pyacp/client.pyacp/_dispatch.pyagent_sdk/gate_extensions/pi/kiro_crew_tool_gate.tssetup.cfg,MANIFEST.infixtures/acp_frames/pi/*(3.jsonl+ 3.expected.json+ README)fixtures/acp_frames/README.mdtest/acp_frame_replay_harness.py,test/test_acp_frame_replay.py,scripts/update_acp_frame_snapshots.pydocs/.../agent-host-contract.mddocs/.../harness-onboarding.mdagent_sdk/backend_install.pyagent_sdk/drivers/acp.pyagent_sdk/host_auth.pyproviders/mirrors/registry.pyno-channelprojectionscripts/deny_diff.pytest/test_acp_pi_backend.pytest/test_acp_tool_gate.pytest/test_acp_backend_kas.pytest/test_agent_backend_editable.pytest/test_agent_sdk_capabilities.pytest/test_acp_capability_sets_leaf.pytest/test_harness_parity.pytest/test_agent_sdk_backend_install.pytest/test_spawn_audit.pyBENIGN_SPAWNSentrysandbox.py,test/test_sandbox_argv.py.gitattributesapps/builtins/aws_control/crew/packaging/build.pyTotals. Files this PR touches: 42. Files a third provider touches again, minus
what was built once (
_dispatch.py,setup.cfg,MANIFEST.in, the threereplay-harness files,
sandbox.py,test_sandbox_argv.py,.gitattributes= 9), minuswhat only a new routing mechanism costs (
tool_gate.py,test_acp_tool_gate.py, the.ts= 3): 30. Against OpenCode's 33 (36 minus its 3 seam gaps) and the pre-seam38, the clean read is 30, of which 7 are the fixture files, 9 are test literals and 2
are hand-kept credential lists the seam cannot reach (
deny_diff.py, the standalonefence). The vocabulary and its ratchets are the floor; the seam did not
move that floor, it moved the auth cost to one literal and one doc column — plus, found
by running the whole suite rather than the ACP tests, one more literal below.
Auth-specific files: 3, not the 2 the seam promises —
agent_sdk/host_auth.py, thebucket 3 column, and
aws_control/.../packaging/build.py's_SENSITIVE_RELATIVE_DIRS.The third is a deliberate hand-kept mirror: that build runs standalone where
kiro_crew.securitycannot be imported, so its coarse fence cannot derive the leaf, andtest_the_local_subset_fences_every_foreign_credential_storeis the ratchet that caughtthe omission. Reported as seam gap 4 rather than tuned away.
Seam gaps found
scripts/deny_diff.pyspells every harness's home-override variable by hand.Round 4 added
XDG_DATA_HOME; this addsPI_CODING_AGENT_DIR. An earlier head ofthis PR replaced the list with an AST parse of
host_auth.py; the First Principleslane pointed out that
test_child_environment_scrubs_every_declared_home_overridealready forces the edit (it compares the tuple to the live declarations), so the
parser bought a second edit nobody has to make and cost sixty lines. Reverted to
the literal. A third provider pays one line, and the test tells them which.
parser before this one assumed
toolCallonsession/request_permissionnames thetool. A gate delivered through a harness's generic dialog does not, so the envelope
contract and its nonce are new dispatch vocabulary. Built once.
Routingenum needed a third member. Reported for the same reason round 4reported its second: the alternative was claiming an enforcement the existing
members document as absent.
aws_control's standalone packagingbuild keeps its own credential-leaf fence because it runs where the product cannot be
imported; a new
credential_leavesdeclaration is a second literal there, and only afull-suite run (not the ACP tests) surfaces it. Not fixed here — the fence is coarse
by design and the test pins parity — but it is a third auth file until that build can
read the declaration some other way.
adapter_own_leavesremoves
~/.pi/agent/auth.jsonfrom the OS mask for the whole sandboxed tree, and pi'sbashruns in that tree; the shell gate matches no paths by design, and the read gatecovers file tools only. This is the posture codex and OpenCode ship on
maintoday,and Pi ships it too by the owner's decision so the three stay one question, held in
adapter_own_leaves lets an enforced harness's shell read its own credential store (codex, OpenCode, Pi) #10438 with the measurements (Linux's empty-file mask keeps a keyless local model
working; macOS's deny makes pi-acp refuse
session/new). Stated in bucket 3 and theonboarding checklist rather than left implied safe.
launcher in
<config_dir>/runwas a liveness artifact; the pi gate copy is the firstwhose location is load-bearing. Answered narrowly here (refuse the pi spawn) rather
than by changing the shared helper; a second gate-extension harness inherits the check.
What #6307 recorded about Pi, checked
Three of its four facts were wrong.
PERMISSION_REQUESTrouting: false, Pi asks fornothing and the enum member no longer exists.
credential_leaves=(): false, Pi storesAPI keys and OAuth tokens in
~/.pi/agent/auth.json, relocated byPI_CODING_AGENT_DIR— verified on disk withpi auth check --credentials. MCP "may beinert": correct, and now verified live. Two components, no
pi acpsubcommand: correct.Local model
Pi drives Ollama through a
models.jsonprovider entry (openai-completions,baseUrl http://localhost:11434/v1); every capture here isllama3.2:3b. No sign-inis involved, which is why the auth remedy names an action and asserts no state.
Tests
test/test_acp_pi_backend.py(new): both resolver ladders, the launcher body onPOSIX and Windows, the read-back's failure modes and env scrub, the issue vocabulary,
the envelope (accepted, forged nonce, wrong title, no nonce, truncated), the
vocabulary sync between the
.tsand the Python, and a live test that drives thereal launcher against the real
piand refuses a copy of the extension elsewhere.for all seven required classes.
.ts, the source check ingate_extension_issue, envelope trust in_dispatch.py, and thedeny_diffparsereach break exactly the test meant to catch them.
flake8, mypy, docs lint — all clean. Both local review lanes returned no findings on
this head after two blocking findings on the first local head were fixed (envelope
forgery from other harnesses; oversize arguments dropping the path). The first PUSHED
head drew one GPT block (the gate loaded from an agent-writable package path) and a
design WATCH (the
PI_ACP_PI_COMMANDlink read from the adapter's source, no in-bandcheck); both are fixed here — the sealed digest-verified copy and the completed-call
tripwire — and the unused
_ENV_PI_CODING_AGENT_DIRconstant the first-principleslane named is gone.
comparison are each pinned by their own tests (
TestGateTripwire,TestSealedExtension,TestGateArtifactsRefuseASharedDirectory,TestTheReadBackComparesFilesNotStrings); the run-dir test makes the fallbackfire and asserts the session is refused with nothing written to the fallback.
fail-closed as above); the Security Scope concerns — the
.tsno longer refuses along shell command, it forwards it whole (verified under Node's type stripping: a
12k-char command arrives intact and unmarked, 250k is refused, a 9k
writebody isbounded with its path intact); the read-back compares files not strings; the
title-equality check stays because pi-acp copies the dialog title verbatim into
toolCall.title(the corpus shows it) and the nonce, not the title, is the trustanchor. First-principles: the three Node-adapter resolver ladders are one
_resolve_node_adapter_argvwith three thin wrappers;is_pi_backendstays becausethe one-identity-predicate ratchet in
test_acp_backend_kasrequires it. Windows CI:three reds, one cause — the pinned digest
2cb1…is the LF bytes and the Windowsdigest
d885…is the same file rewritten CRLF on checkout (verified by hashing bothrenderings), so every seal read the file as tampered. Fixed at both ends:
.gitattributespins the extension LF (the vendor-manifest pattern), and the driver hashes and seals the
LF form of the bytes it read in binary (
_pi_gate_extension_bytes), so the property doesnot rest on a repo-config line. Pinned by a test that hashes both renderings to the same
digest, seals a CRLF file end to end, and still refuses a one-byte edit that is not a line
ending. Without this a real Windows install would have refused every pi session. Full suite (not just ACP): two real failures fixed — the
governance chokepoint that builds an
AcpClientwithout__init__(nonce is now readcompat-shaped like the caches beside it) and the standalone credential fence above.
Local lanes on this head: Opus blocked the live test for leaving pi's TypeScript-loader
cache in the shared temp dir (now pinned to
tmp_path) and named the launcher leak andthe
deny_difffallback narrowing (both fixed: the sweep knows the family; a checkoutwithout readable declarations borrows this checkout's rather than scrubbing less); GPT's
advisory in-function imports are hoisted, and its dropped candidates — the auto-approve
path never recording asked ids, the text-only reader without the tripwire, an unreadable
.tsraising bareFileNotFoundError— are fixed anyway with tests, since each was areal gap in a security property even if unreachable today. A second local pass on the
fixed head was clean on both lanes; its two advisories are also taken: document bodies
are forwarded whole like the shell command (a cut body cleared
raw_params_trustedandhad a large write scanned as a command line).
table) and fix: recognise opencode's MCP tool spelling for directive tools #10331. First Principles: the
deny_diffAST parser is gone, the literalis back with one line added (subtraction taken);
is_pi_backendstays becausetest_exactly_one_predicate_holds_for_every_known_backendrequires exactly oneidentity predicate per known backend. Design: the completed-update tripwire now has
a handshake-time complement —
_note_pi_adapter_versionlogs any pi-acp release otherthan the one the gate contract was observed on (
PI_ACP_VERIFIED_VERSION, the corpusversion), so an adapter drift is named before the first tool call rather than after
the first one that ran unasked. The two live-host confirmations this host cannot
produce (a gateway turn under user namespaces; a Windows session start) are Pi: live-host verification (gateway turn on a userns host; Windows session start) #10439.
GPT's security block on the own-leaf carve-out is answered by the owner's override,
with the repo-wide question in adapter_own_leaves lets an enforced harness's shell read its own credential store (codex, OpenCode, Pi) #10438.
re-stated on behavioural evidence beside the new text) and the doctor test it added,
which pins the set of shipped
no-channelbackends: Pi is now the one named member,with a companion test that the doctor row renders for it. Design: the tripwire gains
its third link — a
completedupdate for a call the host DENIED (pi not honouring theextension's block) kills the harness like an unasked one, audited as
ran_despite_deny; the residual rows name all three links, and the digest-pin /LF-normalize / seal / read-back / nonce / tripwire sequence is now a numbered template
in the Stage 3 checklist, not only the worked example. First Principles: the adapter
version note stays (it is the Design lane's clearing condition for the tripwire watch)
but logs once per process per version rather than on every session.
main:test_agent_sdk_backend_install::test_owner_gets_one_row_per_backend_in_the_pinned_shapereads
codex-acpas installed because it is installed here.Manual verification
pi-acp0.0.33 /pi0.85.1 over stdio,llama3.2:3b: without the extension themodel's
echo gate-checkran with zero permission frames; with it,session/request_permissionarrived carrying the envelope and the command ran only after
yes. Captured verbatim intest/fixtures/acp_frames/pi/permission-request-live.jsonl.session/newarray produced no error and no tool.the sandbox floor refuses every enforced harness there, Pi included, as designed.
Screenshots / video
Not applicable — no frontend change; the option list is data-driven.
Related Issues
#9616 (the auth seam), #10006 (the OpenCode round and its 33/36 baseline), #6307
(prior research, read and checked, deliberately not built on).
Checklist
feat|fix|docs|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement