Repository navigation
fix: honour the parent agent spec's availableAgents at the spawn gate - #13683
Conversation
|
Intent: Make |
First Principles Review (Fable 5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Verify on a real install that a What this change shipsInventory (9 items) — 9 justifiedIntent: FIX — make the operator's
[FIRST-PRINCIPLES-REVIEWED] 061c206 |
GPT 5.6 Review — ✅ human override acceptedHuman judgment by @bolichen97 overrides the GPT 5.6 finding for [GPT-OVERRIDE] 061c206 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: |
Design Review (Fable 5) — 🟡 CONCERNSDesign-level review of Design-Verdict: CONCERNS PR description and the new taskq_bridge comment describe a carry-the-policy-with-the-row design the code deliberately doesn't implement. Watch
[DESIGN-REVIEWED] 061c206 |
Opus 5 Review — ✅ human override acceptedReviewed Human judgment by @bolichen97 overrides the Opus 5 finding for [OPUS-OVERRIDE] 061c206 Verdict recorded from an authorized human decision for commit False positive or not applicable? A repository writer can comment: |
b1c4aed to
5bc2d1d
Compare
|
self-added: yes
|
|
self-added: yes
|
|
self-added: yes
|
|
|
|
self-added: yes
|
|
|
|
|
5bc2d1d to
1e51e79
Compare
|
self-added: yes
|
|
|
self-added: yes
|
|
7d294e0 to
8fb2053
Compare
8fb2053 to
9af4cb8
Compare
9af4cb8 to
6b119b2
Compare
78c8148 to
f2406af
Compare
f2406af to
924e5d5
Compare
|
@buluoray -- thank you for the review; your reproduction was exactly right and it is fixed on 🔴 Plain non-spec Mutation-verified from both sides, as you asked:
The arms in your "Verified clean" section ( 🟡 Memo turns itself off above 4096 entries -- not fixed here, tracked in #14335 with your measurements. Both defeats ( Also in this push, unrelated to your review: GPT flagged that the refusal strings and the warning log in |
kiro-cli defines toolsSettings.subagent.availableAgents for its built-in subagent tool: the glob list of agents an agent may spawn, omit = allow all. Kiro Crew's sub-agents come through spawn_run / spawn_sub_agents, whose admission only checked that the target agent exists plus Kiro Crew's own governance scope, so an operator's declared allowlist was silently ignored and the spawn tools advertised every installed agent as valid (reproduced against main: an out-of-list agent was ADMITTED). The gate now resolves the calling session's template, reads its spec's availableAgents from the user-level agents directory, and refuses a target whose EFFECTIVE template (explicit, inherited or a member's) matches no glob, with error_code=agent_not_available. It runs right after the governance check and is an intersection with it. Only a spec that DECLARES the key changes anything: no parent, no spec or an omitted key is allow-all, so every existing session keeps its admission. trustedAgents keeps its upstream meaning and is not read as a list. spawn_run's "Valid names right now" roster and spawn_list drop the names the parent's declaration forbids and say so; the wave short-circuit recognises the new code.
…y at every drain; redact refusals Three review findings on the parent-spec allowlist gate. A frontmatter-less .md in ~/.kiro/agents (a README, a shared prompt fragment) is returned by iter_agent_spec_files and refused by the hardened reader, so _scan_parent_spawn_allowlists kept it as UNREADABLE and the fail-closed arm fired before the filename-stem fallback could run: a parent whose spec declares no name lost every spawn, and the refusal blamed a file that was never a spec. Such a file cannot carry a name kiro-cli would resolve, so it can hide no declaration; it is now skipped through plain_markdown_document, the same rule the KAS projection and the tool-policy read apply. A FENCED .md that fails to parse still refuses. Tests pin both sides with the planner.json + README.md reproduction. The queued entry no longer stores the policy it was admitted under. A row waits on capacity, so the wait is unbounded in time and the declaration may be tightened while it waits; the in-memory queue's synchronous drain re-entered with the stored copy and the gate re-reads only when none is passed, so a target the operator had since excluded still started. Every drain now reads the declaration fresh: the durable pump off-loop (unchanged) and the synchronous drain through the gate's inline fallback, a memo-pinned directory read. Test parks a spawn on capacity, tightens the declaration, drains, and asserts the refusal. _vet_parent_available_agents hands its refusal back to the caller through info.error before _validate_agent has vetted the target, so the agent and parent-template names get the same redact_via_context pass the glob roster next to them already had, in both refusals and the warning logged beside them. Tests pin each site with a credential-shaped name.
|
@buluoray -- ready for re-review at Your 🔴 (plain
Your 🟡 (memo defeats above 4096 / inside the racy window) -- tracked in #14335 with your measurements; not changed here, since the cap and the window belong to the shared One finding you did not raise, also closed: GPT flagged that the in-memory queue stored Also: the refusal strings and warning log in |
|
/ai-review override gpt 061c206: With one twin unreadable the gate answers exactly as agent_spec_path and spec_by_declared_name do -- the readable declaring twin is the spec kiro-cli resolves as live -- so honouring its declaration is not fail-open, and an actor able to corrupt the restrictive twin could equally rewrite it permissive. |
Human judgment recorded@bolichen97 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. |
|
@buluoray one more thing on the record for your re-review, since it touches a decision from your round. GPT raised a finding on We kept your shape and overrode the finding instead (override on If you want the wider refusal after all, it is your change and we implement it immediately -- say so and I will flip that test and the fail-closed branch. Nothing here touches your CHANGES_REQUESTED; that is still yours to clear. |
|
/ai-review override fable 061c206: The same site was downgraded as a disproportionate remedy in the GPT lane's own adjudication, and both proposed remedies are the queue_params staleness fail-open this PR deliberately removed and an off-loop dispatch redesign outside its scope -- the memo-pinned read is a scandir in the ordinary case, with the large-directory cost tracked in #14335. |
Human judgment recorded@bolichen97 marked the fable 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. |
Problem / Motivation
An operator wrote
toolsSettings.subagent.availableAgents(andtrustedAgents) on their custom agent spec to say "delegate only to these three agents", and a Kiro Crew session running that agent still spawned other installed agents. Reproduced againstmain: with anorchestratorspec declaringavailableAgents: [agent1, agent2, agent3],spawn_run(agent="rogue")was ADMITTED, and thespawn_runtool description listedrogueunder "Valid names right now".Why it matters
This is an authorization boundary, not a missing feature. A field that looks like a security control and does nothing is worse than no field: every configuration that relied on it for isolation was false safety. kiro-cli enforces the key for its own built-in
subagenttool, but Kiro Crew's sub-agents go throughspawn_run/spawn_sub_agents, whose admission never opened the parent's spec.What changed (motivation → approach → change)
src/kiro_crew/subagent.py(_vet_parent_available_agents,parent_spawn_allowlists,spawn_allowlist,agent_matches_allowlist)read_session_execution(...).template_id, resolved in~/.kiro/agentslikeagent_spec_pathdoes) and refuses a child whose effective template matches none of the declaredavailableAgentsglobssubagent_manager/admission/gate.py_vet_spawn_governance, before the row is persisted; refusal carrieserror_code=agent_not_available(subagent.AGENT_NOT_AVAILABLE_CODE) and is audited asdeniedsubagent.parent_spawn_policy,spawn_async,subagent_manager/admission/pump.py,dashboard/handlers/messaging.py(api_spawn)asyncio.to_threadand hands it tospawn_implas_parent_spawn_policy; the gate scans nothing on the loop.spawn_asyncderives the template from the parent record it already reads off-loop,/api/spawnfrom theparent_executionit admitted, the durable pump re-resolves before each drained row's re-check, and the in-memory queue's synchronous drain re-enters with the policy admitted with the row (stored inqueue_params, dropped from the durable row bytaskq_build_record); the synchronousspawn()computes it inline for callers that are not on the loopmcp_tools/spawn.pyspawn_list's roster drop the names the parent's declaration forbids and say why; the wave short-circuit recognises the new codedocs/system-specs/modules/subagent.md,governance.md,src/kiro_crew/docs/agent-spec-fields.mdRoot cause:
_validate_agentonly asked "does this agent exist" and_vet_spawn_governanceonly read Kiro Crew's owncapabilities.spawn.scopes.agents; nothing read the parent spec. The target checked is the EFFECTIVE child template (explicitagent, the inherited parent template, or acrew=member'skiro_agent), so the list cannot be routed around by omitting the name. Matching isfnmatchon the glob. Only when the VERIFIED calling app (execution.app) spawns its own<app>--<name>is the bare<name>tried too, the name the app's spec lists; a--inside any other installed name is just a name, sorogue--reviewernever satisfies areviewer-only list. The parent's spec is resolved the wayagent_spec_pathresolves a name: a spec whose declarednamematches wins, the filename stem is the fallback, and if two specs declare the same name both lists apply (tightest wins). If no readable spec declares the parent's name and its own<template>.json/.mdis present but unreadable (invalid JSON, oversized, symlink to a sensitive target), the answer is unknown and the gate refuses rather than failing open; a broken spec under any other filename refuses nothing. An agents directory that exists but cannot be scanned is unknown too (refused); an absent one declares nothing. The check is an intersection with governance: both gates must admit, and it never widens a governance denial.trustedAgentsis not read as an allowlist: upstream it means "run without permission prompts".Existing-user visible behaviour
toolsSettings.subagent.availableAgents: no parent, no spec, or an omitted key is "allow all" exactly as before. No shipped Kiro Crew agent spec declares the key (the twopptx_makerspecs that do use kiro-cli's ownuse_subagenttool, notspawn_run, and their bare name still matches). Thespawn_runroster andspawn_listoutput are byte-identical for those sessions.spawn_run/spawn_sub_agentstargeting an agent outside the globs is refused withagent_not_availableand a message naming the parent, the key and the allowed globs.agentinherits the parent's own template; if that template is not in the list, the spawn is refused too (the effective template is what is checked).spawn_listlist only the allowed names, with a note that the list is restricted.Backwards compatibility
Compatible: nothing that works today on a spec without the key stops working; the gate is a no-op unless
toolsSettings.subagent.availableAgentsis present, and no shipped spec presents it on aspawn_runpath.POST /api/spawngains one more value in the existingcodefield, which clients already treat as an open set (spawn_rejectedfor anything they do not know).Tests
test/test_spawn_parent_available_agents.py(all 35 fail onmain, pass here):orchestratordeclaringavailableAgents: [agent1, agent2, agent3]plusagent1..3, an out-of-listrogue, an undeclaredplainparent and atrust-onlyparent.roguerefused withAGENT_NOT_AVAILABLE_CODEthrough the realSubagentManager.spawn; no slot taken, no row persisted, onedeniedaudit record.agent1admitted; the inherited (omitted) template is vetted too.plainandtrust-onlyparents admitrogueexactly as before; an unknown parent and an empty parent admit everything.trustedAgentsalone is not an allowlist; omitted key isNone, malformed value is(); kiro-cli glob semantics;<app>--<agent>matches its bare name only for the verified app, never forrogue--reviewer.sprint-planner.jsonforplanner) or a declaring spec under another filename refuses nothing; queued params carry the admitted policy and the durable row does not; the roster announces an empty allowlist and leaves an unreadable parent alone._parent_spawn_policywithout an inline scan;spawn_asyncresolves the declaration on a worker thread, never on the loop thread.test/test_agent_spec_hardened_reads.py: theparsed_agent_specscall-site label ratchet lists the gate'sspawn_available_agents/subagentread.test/test_subagent_execution_capture_async.py: a caller supplying the execution supplies the policy beside it, so the parent record is still read once.Related existing suites (
test_agent_roster_shared,test_spawn_agent_roster,test_governance_chokepoints,test_subagent_cwd,test_subagent_continuable,test_error_code_contract) and the diff-related set (scripts/local-gate.py, 37,943 tests) pass.Manual verification
N/A — unit coverage sufficient: the gate test drives the real
SubagentManager.spawnadmission path with the same spec files kiro-cli would read.Related Issues
no linked issue: reported in an internal channel; there is no GitHub issue for this defect.
Pattern harvest
Rule candidate: review-prompt
Pattern: "a kiro-cli spec field that reads like a security control is silently unread on a Kiro Crew path that replaces the kiro-cli tool it configures" — when Kiro Crew replaces a kiro-cli built-in with its own MCP tool, list the
toolsSettings.<tool>keys of the replaced tool and decide each one explicitly (honour, or refuse loudly).Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)