Repository navigation
fix(kas): six KAS harness and mcp.json reach fixes - #33510
Conversation
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Security Scope Review -- ✅ PASSWhich legitimate operations does Verdict basis: adjudicated, zero confirmed regressions. Security scope review -- adjudicated candidates
No candidate flipped from allowed to refused. Scope-Verdict: PASS Reason: The shell deny composite is not tightened. The TIGHTENING: settings-server injection in the gateway overlay rewriter ( ADJUDICATED: 17 candidates, 0 confirmed newly-refused PLATFORM COVERAGE: posix, windows and any.
UNADJUDICATED:
[SCOPE-REVIEWED] 029d9da |
Sensitive Change ReviewSensitive files changed:
|
a65fb65 to
309ea27
Compare
Sensitive change review
|
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: each of the six fixes changes the condition that owns its setting, and none of them widens a grant without a hook or a person still deciding. Notes
[DESIGN-REVIEWED] 029d9da Description read[DESCRIPTION-READ] 04438f539523355de7bd47c71bf9d8db7d2b4c91e73a6b0e06438fc744ebc0bd That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Each of the six fixes links an issue (#32973, #32923, #32896) and has counted consumers. Nothing blocks; one in-PR second spelling is noted. Notes
What this change shipsInventory (9 items) — 8 justifiedIntent: an agent spec gets on KAS and with the global
[FIRST-PRINCIPLES-REVIEWED] 029d9da Description read[DESCRIPTION-READ] 698dada67e86465c4310e1f9bc81e1a8e9e0c016db1f8a10fde5a886ef3a1cf4 That sha256 names the PR description this verdict read. Recompute it with |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
buluoray
left a comment
There was a problem hiding this comment.
Approving. Six KAS fixes: trustedAgents is judged per session; hook-held MCP grants are answered only where PreToolUse hooks still fire; mcp.json stubs follow tools and useLegacyMcpJson; the glibc floor is a final error; and a file:// doc. Each new grant is still bounded by the spec's own allow list, the deny tiers, governance and the hook (hook_runtime/gate_tiers.py:1632, platform/governance_profiles.py:1067-1103, platform/governance.py:843-870, mcp_gateway/rewriter_spec.py:436-459, 530-533, dashboard/chat_turn/tool_approval.py:739-741, 912-962). Tests are green and mutations turn them red.
309ea27 to
35ad16a
Compare
Sensitive change review
|
buluoray
left a comment
There was a problem hiding this comment.
Requesting changes at 35ad16a (security). We missed this when we approved 309ea27; the code is unchanged since then, and main has no _named_in_tools, so this PR introduces it.
The new _named_in_tools filter (src/kiro_crew/mcp_gateway/rewriter_spec.py:536) drops every settings server that tools does not name, including servers whose env carries a secret:// value. Those servers must stay wrapped by a refusing stub (_must_stay_wrapped, same file :658 and :834), so they never launch with a literal secret:// value. Once the stub is gone, kiro-cli merges mcp.json itself and launches the server as is.
Suggested fix: when an entry has _must_stay_wrapped true and tools does not name it, still emit the refusing stub instead of leaving it to the kiro-cli merge. Opus 5.5 flagged this at 14:55Z on this head, and we confirmed it in source.
35ad16a to
08c3064
Compare
|
self-added: yes
|
Sensitive change review
|
|
On the change request at 35ad16a (review 5827828909, the |
- trustedAgents on KAS: a trusted sub-agent allow is judged by the profiles that govern this session, so it is no longer dropped. - Hook-covered grants on KAS: Kiro Crew answers an allowedTools MCP grant a preToolUse hook holds at ask on the chat, subagent and task-runner turn loops, which tell the gate the hook runs on the request, so the chat stops waiting on a person. Any other surface keeps asking. - tools allowlist: mcp.json stubs and KAS includeMcpJson follow the agent's tools, so a narrow agent no longer gets every mcp.json tool. A routed mcp.json server whose env holds a secret:// reference that tools leaves out gets a refusing stub instead, which starts nothing and offers no tools, so the host's own mcp.json merge cannot start it with the literal reference. - useLegacyMcpJson: the rewriter reads kiro-cli's alias through the reader the KAS projection uses (mcp_cleanup.include_mcp_json), so an agent with useLegacyMcpJson: false gets no injected mcp.json stubs. - glibc floor: below the engine's glibc 2.28 (Amazon Linux 2) chat, dashboard and doctor name the cause and a newer image, not a retry. - file:// prompts: the spec reference states kiro-cli v3 refuses an absolute or ~ file:// prompt and why Kiro Crew keeps accepting it. Both rewriter changes share one move of the rewrite fingerprint schema to 14, so a kept overlay holding stale injected stubs is rebuilt. The app agent-turn SDK, which the meetings dispatch runs through, names its app at session allocation, and a reset or compaction successor keeps the app of the session it replaces, so those sessions judge the allow under that app. Fixes #32973 Fixes #32923 Fixes #32896
08c3064 to
029d9da
Compare
|
self-added: yes
|
Code change approver recommendation: A person should decideAutomated, not a person, and not a review: a maintainer still decides.
Why: the decider approves but is not confident enough to auto-approve (p_defect 0.2 > 0.12). Six bundled KAS/mcp.json fixes; I checked each against the code. (1) Hook-held MCP grants: the gate answers one only when pre_tool_hooks_fire is set, and only chat, subagent and task-runner set it. Chat fires PreToolUse hooks after an auto-approve and the subagent/task ladders run the SpecHooks floor before the gate, so a hook's exit 2 still blocks. Deny rows and governance still run first; child calls never carry the held set; the record key is in CREW_ONLY_ENTRY_KEYS so it is stripped from the wire. (2) The rewriter now pools only servers named in If this recommendation is wrong, reply here; the replies are how the approver is evaluated. |
Sensitive change review
|
…fixes (#33510) Backport of the parts of #33510 that release/0.12.0 can carry: - tools allowlist: mcp.json stubs and KAS includeMcpJson follow the agent's tools, so a narrow agent no longer gets every mcp.json tool. A routed mcp.json server whose env holds a secret:// reference that tools leaves out gets a refusing stub instead, which starts nothing and offers no tools, so the host's own mcp.json merge cannot start it with the literal reference. - useLegacyMcpJson: the rewriter reads kiro-cli's alias through the reader the KAS projection uses (mcp_cleanup.include_mcp_json), so an agent with useLegacyMcpJson: false gets no injected mcp.json stubs. - glibc floor: below the engine's glibc 2.28 (Amazon Linux 2) chat, dashboard and doctor name the cause and a newer image, not a retry. - file:// prompts: the spec reference states kiro-cli v3 refuses an absolute or ~ file:// prompt and why Kiro Crew keeps accepting it. Both rewriter changes share one move of the rewrite fingerprint schema to 14, so a kept overlay holding stale injected stubs is rebuilt. Fixes #32973 Fixes #32923 Fixes #32896 (cherry picked from commit d4f82fb) Backport note: left out the trustedAgents on KAS fix. Release has no canonical_tools_settings, trusted_agents_withheld or per-session governance (may_skip_gate_for_session, session_profiles_govern), so the governance_app and governance_scope plumbing and its test and governance.md hunks are not carried. Backport note: left out the hook-covered grants fix. Its only answerer is the batch-guard-grant gate row and batch_guard._auto_approved, which are not on release, so CREW_ANSWERED_HOOK_HELD_KEY, hook_held_grants, spec_hook_held, pre_tool_hooks_fire and their tests and docs are not carried. Backport note: dropped the app files (apps/agent_turn_sdk.py, parked_queue owning_app, auto_improvement runners and its test) as out of scope; src/kiro_crew/acp/harness/kas_cloud.py, test_kas_tools_settings_aliases.py and test_app_agent_turn_sdk.py stay deleted as on release. Backport note: kas_agents_registered.py (a pure move of the projected_* and switched_* readers) is not carried; they stay in kas_agents.py. Backport note: kas_agents.py keeps release's imports and to_client_custom_agent body, with only the includeMcpJson-true-stays-off -the-wire change and the resolve_prompt docstring applied. Backport note: agent-spec-fields.md and security.md take release's text plus the includeMcpJson, prompt and secret:// refusing stub hunks; the hooks row and the hook-held security paragraph are not carried.
Ports, with their tests, the fixes the Kiro Crew wheel copy took after the GitLab change: - kirodotdev/KiroCrew#33556: on Windows the dependency check resolves git, gh and glab from PATH's absolute entries only. - kirodotdev/KiroCrew#33565: pinning git attributes refuses a Windows directory junction as it refuses a symlink. - kirodotdev/KiroCrew#34238: a session key ending in a newline is refused. - kirodotdev/KiroCrew#33510: member and runner-built sessions name this app as their owning_app, so their governance reads are judged under the same app as their tool calls. - kirodotdev/KiroCrew#35779: the suite's git reads no host global config, so a host core.hooksPath cannot refuse a fixture commit. The runner coverage docstring drops its stale location claim (kirodotdev/KiroCrew#35994). Co-authored-by: KiroCrewCaptain <312312717+KiroCrewCaptain@users.noreply.github.com>
Problem / Motivation
Goal: An agent spec gets on Kiro Crew what its own settings say, on KAS and with the global
mcp.json: a trusted sub-agent and a hook-covered MCP grant run without a prompt, a narrowtoolslist oruseLegacyMcpJson: falsekeeps the othermcp.jsonservers out, a host below the KAS engine's glibc floor is told the real cause, and the agent-spec reference states kiro-cli v3'sfile://prompt rule as it is.This PR bundles six separate fixes, as the maintainer asked for larger grouped PRs. Each row is its own defect:
toolsSettings.subagent.trustedAgentssub-agent whenever any governance profile turned spawning off for another surface or app, and the chat said the setting had no effectallowedToolsgrant such as@docs/lookupmade every chat call show an approval card, and a subagent or task-runner turn waited on its approver or was refused; kiro-cli runs the same spec unpromptedtoolsandmcp.jsontoolslist was still offered every stubbed~/.kiro/settings/mcp.jsonserver, and on KAS it got every MCP tool of them throughincludeMcpJson: trueuseLegacyMcpJsonuseLegacyMcpJson: falsestill had the global servers injected and mountedkirocrew doctorsaid the engine downloads at the first chatfile://prompts (docs)~prompt unverified, and claimed kiro-cli parity for..and$VARWhy it matters
trustedAgentsgrant in every chat, and the chat told the user the setting does nothing.toolsanduseLegacyMcpJson: an author who kept write-capable servers out of an agent still had them mounted. A call to one prompts rather than being refused, so with slot trust or yolo on, it runs.file://prompts: a reader could not tell which agents fail on which route.Not a goal
web_fetch,web_search,use_subagent,disclose_context) still prompt when a hook covers them: their allow can be scoped bytoolsSettingsURL patterns, so answering them by name at the gate would widen a scoped grant.@server,@server/get_*) on a server the MCP probe cache lists no tools for still prompts.use_subagentinallowedTools, apermissionsallow) on KAS: still judged by every profile (KAS: an authored sub-agent allow (allowedTools use_subagent, a permissions allow) is withheld when any profile turns spawning off #32980).mcpServersbut leaves out oftools(An agent's tools allowlist does not narrow the pooled stubs of its own declared MCP servers #32912), and the two readings of a missingincludeMcpJson(Crew reads a missing includeMcpJson two ways (true in capability/materializer code, false in the KAS adapter) #30822).kiro-cli loginas a remedy on a host below the glibc floor: that route has not been checked end to end there. The installer's own exit code on such hosts is Too-old glibc (Amazon Linux 2): cli.sh exits 0 and prints the normal Next steps #31906.file://prompt: Kiro Crew's app bridge writes one for every app agent, so behaviour is unchanged.What changed (motivation → approach → change)
A trusted sub-agent and a hook-covered MCP grant run on KAS without a prompt, an agent's
toolslist anduseLegacyMcpJson: falsedecide whichmcp.jsonservers it gets, a host below the KAS engine's glibc floor gets a final error that names the cause, and the agent-spec reference states kiro-cli v3'sfile://prompt rule. In each case Kiro Crew read a different condition from the engine or the gate that owns the setting. The six share one commit because they meet in the KAS projection and the MCP gateway rewriter.may_skip_gate_now, which withholds when any configured profile governsuse_subagentmay_skip_gate_for_session(platform/governance.py,governance_profiles.session_profiles_govern); the notice inagent_sdk/spec_hooks.pyanddashboard/chat_turn/turn_spec_hooks.pyasks the sameaskbut recorded no MCP grant for the gate to answerkas_hook_coverage.hook_held_grantsrecords them under_crewAnsweredHookHeld(acp/kas_permissions.py), stripped from the wire; the session handle stamps them asAcpEvent.spec_hook_held, and thebatch-guard-grantrow inhook_runtime/gate_tiers.pyanswers them only for a surface that tells the gate it fires the PreToolUse hooks (pre_tool_hooks_fire, a gate argument inhooks.py)toolsandmcp.jsonmcp.json, and KAS gotincludeMcpJson: truerewriter_spec._rewrite_single_specinjects only a servertoolsnames, and gives a left-out server whose env holds asecret://reference a refusing stub (_refusing_stub_entry); KAS gets the flag only asfalse, and the opt-in rides the settings stampkas_settings_mcp.excluded_wholereadsuseLegacyMcpJsonincludeMcpJson: falseinclude_mcp_json, the reader the KAS projection already used, so either spelling opts out and both sides read a non-bool flag the same way; the reader moved unchanged tomcp_cleanup.py, becausemcp_gateway/may not importkiro_crew.acp, andacp/kas_settings_mcp.pyre-exports itinstall_pinnedfetched the manifest before the glibc check, and the installer wrapped the refusal as an offline failureacp/kas_bundle.py);kas_engine_install.pykeepsKasHostUnsupportedwith the cause alone; the harness raisesAcpKasHostUnsupportedfromacp/kas_host_unsupported.py; doctor (cli_doctor_parts/kas_relay.py) andkirocrew kas installrun the same three checks throughagent_sdk/kas_bundle.require_loadable_hostfile://promptssrc/kiro_crew/docs/agent-spec-fields.md§ Prompt and theacp/kas_prompt.pydocstrings state each route's ruleFor the trusted allow, the projection must know which session and app it serves. The provider hands its runtime its session key and
owning_app(providers/acp_runtime_start.py,acp/runtime_class.py), andacp/runtime_session_setup.pyand theacp/harness/files pass them to the projection. Any other session on that process gets the app as not known, which counts every app profile. Three in-process app paths hand their gate their own app: the app agent-turn SDK (apps/agent_turn_sdk.py, which the meetings dispatch runs through), the auto-improvement member runner (apps/builtins/auto_improvement/spine/crew_runner.py) and the provider the auto-improvement runner builds itself (spine/agent_runner.py). Each names that app on its session's provider, so the projection judges the allow under the profile the gate applies. A reset successor and a compaction restart keep the app of the session they replace (allocation_identityinsession_lifecycle_parts/parked_queue.py).On the hook-covered grants, only the chat, subagent and task-runner turn loops tell the gate they fire the PreToolUse hooks on the request (
dashboard/chat_turn/tool_approval.py,subagent_manager/run_turn.py,task_executor.py), so there a hook's exit 2 still blocks the call. Every other surface keeps asking, a channel bot's turn included: it runs the hooks too, but its gate is not told.Both rewriter changes share one move of the rewrite fingerprint schema to 14 (
mcp_gateway/rewriter.py), so a kept overlay holding stale stubs is rebuilt.acp/client_mcp_array.pystates the opt-in rule in its docstring.A routed
mcp.jsonserver whose env holds asecret://reference cannot just be left out: the host's own merge would start it with the literal reference (rewriter_env._must_stay_wrapped). An agent whosetoolsleaves one out gets a refusing stub under its name, sent atsession/newso it outranks that merge. It runsstub --refuse, which starts nothing, never reaches the gateway and answers as a server with no tools (stub_link._serve_refusal). It names no target, so no launch is approved for it. KAS gets it only for an agent opted in tomcp.json, and an opted-out agent gets none.On a host below the glibc floor,
transient = Falseon the refusal tells the retry layer not to retry. The chat, the dashboard and doctor show the engine's own glibc message, which suggests a newer base image.The specs (
governance.md,security.md,acp-client.md,agent-host-contract.md,app-kit-platform.md,docs/architecture/mcp.mdand the stub decoupling note) state each rule.These changes would take
acp/kas_agents.pypast the 2,000-line cap, so its registered-entry readers (projected_*,switched_*,active_registered_entry) move unchanged toacp/kas_agents_registered.py.kas_agentsimports each name back, so callers and tests keep that path.Backwards compatibility
Compatible: no spec is refused and no key changes meaning. A trusted sub-agent or a hook-covered MCP grant runs where it used to prompt; a narrowed or opted-out agent stops being offered
mcp.jsonservers it never named; a host the engine cannot run on gets a final error in place of a retry.Three behaviour changes to name:
owning_app, so its session setup and readmission judge it under that app's profile as well. This only narrows, and it matches what the gate already applied.kirocrew doctoron a host the engine publishes no build for (an architecture such asriscv64) names that cause on a failing row, where it said the first chat downloads the engine; every install refuses that host the same way.mcp.jsonserver that carries asecret://reference and that itstoolsleaves out as a server with no tools. Before, it got that server's tools through the gateway.Reader: src/kiro_crew/mcp_gateway/session_servers.py:pooled_session_servers -- chat -- reads the overlay, so it sends exactly the stubs the rewriter wrapped: test_only_the_named_settings_server_is_injected
Reader: src/kiro_crew/mcp_gateway/launch_resolve.py:resolve_launches -- crew page -- runs the same rewrite pass, so a stub toggle resolves a launch for a settings server some agent's
toolsnames; the launch-approval tests name their server intoolsReader: src/kiro_crew/acp/kas_settings_mcp.py:excluded_whole -- chat -- reads the opt-in from the settings stamp, not the sent flag, so an opted-in agent keeps its file servers: test_an_opted_in_spec_keeps_the_server_its_tools_names
Reader: src/kiro_crew/acp/runtime_session_create.py:without_excluded_stubs -- chat -- uses excluded_whole, so an opted-in agent keeps its pooled stubs: test_an_opted_in_agent_keeps_its_pooled_stubs
Reader: src/kiro_crew/acp/runtime_session_load.py:without_excluded_stubs -- chat -- a resumed session's
session/loadcalls the same helper on the same stamp, so an opted-in agent keeps its pooled stubs there too: test_an_opted_in_agent_keeps_its_pooled_stubsReader: src/kiro_crew/acp/harness/kas.py:excluded_whole -- chat -- stamps the spec's own opt-in, which the wire entry never carries, before it asks
excluded_wholewhich servers start: test_kas_stamps_the_specs_own_mcp_json_opt_inReader: src/kiro_crew/llm_helpers_parts/backend_errors.py:acp_error_is_transient -- chat -- reads
transient = Falseoff the refusal, so a host below the floor is not retried: test_a_host_that_cannot_run_the_engine_is_not_told_to_retryReader: src/kiro_crew/dashboard/handlers/kas_bundle.py:_install_task -- app -- catches
KasBundleError, whichKasHostUnsupportedsubclasses, and shows its text, which names the cause aloneTests
test_kas_trusted_agents_session_profile.py(new): the allow travels where no profile of the session governs and is withheld where one does, the notice agrees, the runtime, harness, provider and both app runners hand down the session and app, and a rebuilt session keeps its app (TestPlumbing::test_a_rebuilt_session_keeps_the_app_its_gate_judges);test_auto_improvement_members.py::test_member_session_runs_under_the_app_its_gate_judgesand::test_a_runner_built_session_runs_under_the_app_its_gate_judges;test_app_agent_turn_sdk.pyexpectsowning_appon a turn's allocationtest_kas_hook_reach.py: a hook-held grant is recorded apart from the other answered grants and stamped on the session's own request, the gate answers it without a prompt only for a surface that fires the hooks (test_a_surface_that_fires_no_hook_keeps_asking), only the chat, subagent and task-runner turn loops say they do, the task runner's ladder answers it, an authoredaskor an ungranted tool still prompts, and a real dashboard_run_chatturn runs the hook (exit 0 approves, exit 2 rejects);test_hooks.pypins the new event field and gate argumenttoolsandmcp.jsontest_mcp_gateway_settings_inject_tools.py(new);test_kas_agents.py::TestInclusionFlagProjection;test_kas_settings_mcp.py;test_acp_harness_contract.py::test_kas_stamps_the_specs_own_mcp_json_opt_in; intest_secret_uri_launch_paths.py, the refusing stub:test_a_settings_server_with_a_reference_gets_a_refusing_stub_when_tools_omits_it(toolsabsent,[]or["@other"], the command resolvable or not), none for either opt-out spelling, the stub in the session array, KAS excluding or outranking the file's server, and the stub run through its own entry point answering as a server with no toolsuseLegacyMcpJsontest_mcp_gateway_rewriter.py: both spellings,trueandfalse, andTestSettingsInjection::test_injection_reads_the_opt_in_the_kas_projection_reads, which checks the rewriter againstinclude_mcp_jsonon six spellings (a junk ornullincludeMcpJsonbeside the alias'sfalseortrue, both flags stated either way, junk alone)test_kas_bundle.py::test_install_pinned_refuses_an_old_glibc_host_before_the_manifest;test_kas_route.py(no retry advice, type kept);test_cli_doctor_agent_auth.py::test_a_host_below_the_glibc_floor_is_told_so_not_to_installand::test_a_host_with_no_engine_build_is_told_so_not_to_installfile://promptstest_agent_spec_fields_doc.py::test_prompt_section_states_the_v3_absolute_rule_crew_keeps_looserInjection fixtures whose specs carried no
toolsgrant["*"]or name their server, the brace-glob cases intest_kas_settings_mcp.pystate their opt-in through the stamp, andtest_runtime_bindings.pypins the new runtime field.Rebased onto main after review; patch unchanged. This head is 029d9da on main 51242a5.
git range-diffshows the same patch as 24e1b1e739 on main 11684ff, where the rest of this section ran, and main's 5 commits between the two touch no file this PR edits. At this head, the two backend test files main changed (test_acp_strands_backend.py,test_build_desktop_job_timeouts.py),test_acp_harness_contract.py,test_rewriter_facade.py,test_mcp_gateway_rewriter.pyandtest_kas_settings_mcp.pyran 426 passed, 2 skipped, 0 failed. Everything ran on a Linux DevSpace host (Amazon Linux 2023), except the glibc repro, which ran on an Amazon Linux 2 DevSpace host (glibc 2.26).Rebasing 08c3064 met one conflict, in the
hooksrow ofagent-spec-fields.md, and kept both sides: this PR's hook-held grant sentences stay, and main's (#34020) sentence that a channel-agent turn runs only the spec's PreToolUse hooks, on each permission request before any approval, replaces this PR's older one that said it runs none.channel.pypasses the gate nopre_tool_hooks_fire, so that turn keeps its own approval for a hook-held grant. Main's later commits touch no file this PR edits.The patch also answers the First Principles review of 08c3064: the rewriter reads the opt-in through
include_mcp_json, the KAS projection's reader, moved unchanged tomcp_cleanup.py, and_excludes_global_mcp_jsonis gone; the rewriter facade'sTYPE_CHECKINGblock names the new import (test_rewriter_facade.py).test_injection_reads_the_opt_in_the_kas_projection_readspasses its 6 cases; with only the rewriter's call site put back to the old reader,junk-then-falseandnull-then-falsefail on the assertion and the other 4 pass. The test passed 20 runs of 20 at-n0, and 10 of 10 at-n 4 --dist loadgroup --max-worker-restart=2besidetest_kas_settings_mcp.py, and the 109 tests oftest_mcp_gateway_rewriter.pypassed in a shuffled order (seed 4127: 107 passed, 2 skipped).The refusing stub, this PR's answer to the Opus review at 35ad16a, has 16 new and changed cases. At 08c3064, with its four production files reverted (
rewriter_spec.py,stub.py,stub_link.py,rewriter.py), 11 of them failed by name and the 5 controls passed. At 0e5ad530f0, an earlier head with the same refusing stub, those cases ran 20 times at-n0and 10 times at-n 4 --dist loadgroup --max-worker-restart=2besidetest_mcp_gateway_rewriter.pyandtest_kas_settings_mcp.py, all green, and the 94 tests of the two changed files passed in a shuffled order (seed 9234).At 24e1b1e739,
pytest -n 6 --dist loadgroup --max-worker-restart=2: 184 test files ran 10368 passed, 21 skipped, 0 failed. They are the 23 changed and added test files, every test file that importsmcp_cleanup,kas_settings_mcpor the rewriter's modules, test files that import another module or read a doc this PR changes (kas_agents,hooks.py, the KAS harness and permission modules,agent-spec-fields.md), the channel-turn, cron and messaging spec-hook tests beside the mergedhooksrow, and the ratchet, budget, contract and facade-mirror guards.Every profile gate exited 0 at 24e1b1e739: black, subprocess encoding, isort, flake8, mypy
--platform linux(4,421 files), comment history, brand name, the file line cap, harness parity (HARNESS_BASE_REFmain), the agent-SDK boundary, docs lint, the flake-pattern ratchet (68 passed) andsemgrep scan --config semgrep/against main (0 findings). The scoped backend and frontend suites and the Electron tests are not run locally: GitHub CI runs the full suites.Proof: PROVEN src/kiro_crew/apps/builtins/auto_improvement/tests/test_auto_improvement_members.py::test_member_session_runs_under_the_app_its_gate_judges, src/kiro_crew/apps/builtins/auto_improvement/tests/test_auto_improvement_members.py::test_a_runner_built_session_runs_under_the_app_its_gate_judges, test/test_agent_admission_paths_ratchet.py::test_every_agent_argv_site_is_classified, test/test_agent_spec_fields_doc.py::test_prompt_section_states_the_v3_absolute_rule_crew_keeps_looser, test/test_app_agent_turn_sdk.py::test_a_turn_carries_the_contexts_identity_and_the_hook_gate (head 24e1b1e739b8)
prove.py --base 11684ff344exited 0 at 24e1b1e739: with the production hunks reverted, tests of the changed test files fail on an assertion (the line names the first five). Each fix has at least one: the app-runner allocations, the runner-built provider, the SDK pins and the rebuilt session's app, the gate's new event field and the three turn loops that say they fire the hooks, thetoolsanduseLegacyMcpJsoninjection cases and the refusing stub's, the KAS flag and stamp, the glibc order, the harness and doctor wording (the architecture row included), and the prompt section's doc test. The projection cases inTestProjectionandTestNotice, and the hook-held record and gate cases, raise without the new code rather than assert, so the proof does not count them; they are the behaviour pins.Live repros, one per fix, fix side only, ran at 24e1b1e739; each exited 0 as in the table. Each starts a real
python -m kiro_crew gatewayor the real CLI from a fresh worktree, on its ownKIROCREW_HOME,HOMEand loopback port. Five ran on a Linux DevSpace host (Amazon Linux 2023), where the KAS engine and kiro-cli are Kiro Crew's packaged fake ACP backend wrapped to log frames, because the host has no model sign-in. The glibc repro ran on an Amazon Linux 2 DevSpace host (glibc 2.26). Server names are generalized.session/newcarries{capability: subagent, match: [helper], effect: allow}and notrustedAgentsnotice@docs/lookup; Kiro Crew answered the engine's request in 0.77 s after the hook ran once, the tool ran once, and no Kiro Crew-only key reached the wiretoolsandmcp.jsonacp --agent-engine v3) the narrow agent got only the server itstoolsnames, KAS saw noincludeMcpJson, and thetools: ["*"]control still got all three. This host's kiro-cli is 2.37.1, so the launcher replayed the--versionandacp --helpanswers of kiro-cli 3.1.0 from another DevSpace host; with the 2.37.1 answers Crew keeps the v2 launch for the KAS phase and the script exits 2 (inconclusive)useLegacyMcpJsonuseLegacyMcpJson: falseagent got no settings stubs and kept its own server; the no-flag control still got both, and theincludeMcpJson: falsecontrol got noneGET /api/kas-bundleerror and doctor'sbundle:row each name the glibc cause with no retry advice, and two offline chats made 0 connections to the manifest hostfile://prompts~prompt, expands no$VARand keeps the home-directory boundary, as the reference says; on KAS thesession/newforabs-promptcarries the file text inlined and the engine takes that mode; the Kiro CLI launch pins--agent-engine v2. Each turn then ends with the not-signed-in error, which the check does not judgeManual verification
The live repros under Tests drive a real gateway, its HTTP API, the gate, spec hooks and stdio MCP servers. Still to do by hand: one run against a signed-in KAS engine, and a hook-held grant on a channel bot's turn in interactive mode, which should still show its approval buttons.
Screenshots / video
N/A: the diff touches no frontend file. The user-visible effects are a prompt or a notice that no longer appears and an error text; the repro results under Tests show them.
Related Issues
Fixes #32973
Fixes #32923
Fixes #32896
Related: #30625, #30712, #30822, #31906, #32912, #32980
Sibling sweep
Swept: git grep -nE "ceiling_permits=|may_skip_gate_now(entry)" -- src/kiro_crew/acp/kas_agents.py (every KAS projection step that judges a spec's allow against the profiles;
_ceiling_permittedat :581 and the authoredpermissionsmerge at :1144 are the two left)Sibling: src/kiro_crew/acp/kas_agents.py:581 -- tracked in #32980
Swept: git grep -nE "get_or_create(" -- src/kiro_crew/apps/ (in-process app runners that hand their gate an app)
Sibling: src/kiro_crew/apps/agent_turn_sdk.py -- changed here
Sibling: src/kiro_crew/apps/builtins/auto_improvement/spine/crew_runner.py -- changed here
Sibling: src/kiro_crew/apps/builtins/issue_radar/backend/http_routes/ai.py:235 -- not affected -- a
kirocrew-litehelper turn underToolApprovalPolicy.REJECT_ALL, so no gate judges a spec allow thereSwept: git grep -nE 'owning_app ?=|"owning_app"] =' -- src/kiro_crew/apps src/kiro_crew/subagent_manager (every provider an app path names its gate's app on, including one built outside allocation;
subagent_manager/run_turn.py:311already hands the child its spawn's app asowning_app)Sibling: src/kiro_crew/apps/builtins/auto_improvement/spine/agent_runner.py -- changed here
Swept: git grep -nE 'allocation_identity(|get_or_create(key)' -- src/kiro_crew/session_lifecycle_parts src/kiro_crew/session_compaction.py (every allocation that replaces a session under its key;
hand_queue_to_successorin the same file serves a messaging channel's forced stop, whose gates judge with no app)Sibling: src/kiro_crew/session_lifecycle_parts/parked_queue.py:204 -- changed here
Sibling: src/kiro_crew/session_lifecycle_parts/turn_stop.py:588 -- not affected -- the hard stop's eager respawn rebuilds no identity at all (default agent, no cwd, model or app), a loss older than this change and wider than the app
Swept: git grep -nE 'spec_granted_builtins' -- src/kiro_crew/hook_runtime/gate_tiers.py (every gate row that answers a request the projection kept at
ask;spec-builtin-grantat :1571 answers the shell, filesystem and read-path built-ins KAS keeps ataskwith or without a hook)Sibling: src/kiro_crew/hook_runtime/gate_tiers.py:1638 -- changed here
Swept: git grep -nE "pre_tool_hooks_fire=True|permission_pre_tool_block(|.pre_tool_refusal(" -- src/kiro_crew (every turn loop that runs the PreToolUse hooks on a KAS permission request, and whether it tells the gate)
Sibling: src/kiro_crew/dashboard/chat_turn/tool_approval.py:769 -- changed here
Sibling: src/kiro_crew/subagent_manager/run_turn.py:596 -- changed here
Sibling: src/kiro_crew/task_executor.py:673 -- changed here
Sibling: src/kiro_crew/channel_spec_hooks.py:54 -- not affected -- a channel-agent turn (
channel.py) runs the spec's PreToolUse hooks before any approval but does not tell the gate, so a hook-held grant keeps that channel's own approvalSibling: src/kiro_crew/cron_service/turn_hooks.py:109 -- not affected -- a cron turn runs the spec's PreToolUse hooks on the request but does not tell the gate, so a hook-held grant still asks there, as before
Sibling: src/kiro_crew/messaging/driver.py:1184 -- not affected -- a channel bot's turn runs the hooks after its tool gate answers and does not tell the gate, so a hook-held grant keeps that channel's own approval, as before (named under Not a goal)
Swept: git grep -nE "def withhold_[a-z_]*|CREW_ANSWERED_[A-Z_]+_KEY = " -- src/kiro_crew/ (every projection step that turns a granted allow into ask, and every record the gate answers from)
Sibling: src/kiro_crew/acp/kas_hook_coverage.py -- changed here
Sibling: src/kiro_crew/acp/batch_guard.py -- not affected -- withhold_write_auto_approval records every MCP write it holds at ask under CREW_ANSWERED_WRITES_KEY, which the same gate row answers
Sibling: src/kiro_crew/acp/kas_spec_grants.py:34 -- not affected -- the read
allowedPathsrecord, which thespec-builtin-grantrow answers whether or not a hook covers the readSibling: src/kiro_crew/acp/kas_env_launch.py -- not affected -- a deliberate per-call hold: the gateway proxy forwards a tools/call only against an approval Kiro Crew's gate granted for those exact arguments
Swept: git grep -nE "inject_servers|pooled_session_servers(|includeMcpJson|useLegacyMcpJson|includePowers" -- src/kiro_crew/mcp_gateway/ src/kiro_crew/acp/ (
includePowers, forwarded at kas_agents.py:1343, has no kiro-cli reading to diverge from)Sibling: src/kiro_crew/mcp_gateway/rewriter_spec.py:588 -- tracked in #32912
Sibling: src/kiro_crew/acp/client_mcp_array.py:133 -- not affected --
spec_is_toollessfails closed: it needsincludeMcpJsonto be exactly false, so a spec that opts out only through the alias is read as not toolless and keeps its gateSibling: src/kiro_crew/acp/kas_mcp_json_legacy.py:57 -- not affected -- the one-time legacy list asks whether either key is stated at all, not what the opt-in says
Sibling: src/kiro_crew/acp/session_mcp.py:440 -- not affected -- the mirrors already drop a stub their ToolsAllowlist does not grant
Swept: git grep -nE '_must_stay_wrapped(' -- src/kiro_crew/mcp_gateway/ (every place that decides whether a routed server carrying a
secret://reference keeps an overlay entry, all inrewriter_spec.py::577is changed here;:701and:877keep a declared or a named server wrapped whether or not its launch is approved, and:1043keeps it in the injection set when its command does not resolve)Swept: git grep -nE "offline_install_message(|except .*KasBundleError" -- src/kiro_crew/
Sibling: src/kiro_crew/acp/harness/kas.py:789 -- changed here
Sibling: src/kiro_crew/cli_kas.py:385 -- not affected --
kirocrew kas installalready catches KasHostUnsupported first and exits with its own codeSibling: src/kiro_crew/dashboard/handlers/kas_bundle.py:147 -- not affected -- it catches the subclass and shows the text install_pinned_engine words without retry advice
Swept: git grep -nE 'require_loadable_host()|_require_loadable_glibc(None, None)' -- src/kiro_crew (every local host check that runs before an install)
Sibling: src/kiro_crew/agent_sdk/kas_bundle.py:173 -- changed here
Sibling: src/kiro_crew/agent_sdk/backend_install.py:240 -- not affected --
_engine_installable_herealready runs the glibc, platform and node checksPattern harvest
Rule candidate: review-prompt
Pattern: a Kiro Crew projection of an agent spec that judges a setting by a different condition than the engine or gate that owns it: one spelling of a kiro-cli alias, every profile instead of the session's, or a flag forwarded to a backend that reads it differently
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
Contributed under the project's Apache-2.0 license, per the Licensing section of CONTRIBUTING.md.