Repository navigation
fix: inherit per-chat trust to subagents at every spawn depth - #13109
billygerhard wants to merge 2 commits into
Conversation
|
Intent: A chat's per-slot trust applies to every subagent in its spawn tree, at any depth, so nested subagents run unattended and any prompt that still needs a human lands in the root chat's tab. |
Design Review (Opus 5.5, fork) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks. Stamping the root key at admission fixes the cause, the contest rules follow the merged RFC (#15457), the description lists the tightened behaviour as breaking, and 12 rendered images cover the card change. Notes
[DESIGN-REVIEWED] c5d25fc Description read[DESCRIPTION-READ] 84f4bf8fb2b69040948ac65e1aaeb23040e503fe57b390f938fe8c9d2134a9bb 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 |
GPT 6.1 Review (fork) — 🔴 changes requested (blocking)Reviewed Adjudication upheld 2 of 2 blocking finding(s); those must be resolved before merging. BLOCKING -- src/kiro_crew/subagent_manager/admission/pump.py:788 -- A terminal memory record does not prove the refusal committed
BLOCKING -- src/kiro_crew/subagent_parts/admission_surface.py:1133 -- Descendants ignore their parent's captured tab root
[BLOCK-MERGE] c5d25fc Adjudication (Opus 5.5) — is blocking on each finding proportionate?Both findings keep blocking the merge. F1 ( |
First Principles Review (Opus 5.5, fork) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Every item traces to the depth-trust defect (#14110) or to the founder rule in the base RFC What this change shipsInventory (10 items) — 9 justifiedIntent: let a trusted chat's whole spawn tree run without prompts nobody can see, and stop a chat from lending its trust to another chat's conversation. A FIX, plus a recorded trust-narrowing decision.
[FIRST-PRINCIPLES-REVIEWED] c5d25fc Description read[DESCRIPTION-READ] 5b334aad03c324c6e4b92b1ddafe098403af0fc26dd744c49681c90f9621d6f0 That sha256 names the PR description this verdict read. Recompute it with |
Opus 5.5 Review (fork) — ✅ no blocking findingsReviewed |
0490d77 to
94708dd
Compare
|
span=35f75f1f3c22
mechanism: SubagentInfo.root_session_key stamped at admission; run loop reads the stamp, not a check-time walk
|
span=0d281b7e51fe
|
span=caea88dffaf6
|
94708dd to
cb5583c
Compare
|
span=6a3a78cb8f4d
self-added: yes
|
span=b17d2b91698e
|
|
span=ebc85bc0077e
self-added: yes
|
|
|
|
|
|
|
|
Rebased onto |
|
GPT F1 ( A release now resolves its id to the founder first ( Pin: F2 (tab routing after a later contested continuation) was downgraded by adjudication as disproportionate; the behaviour is unchanged in this push. |
|
Holding for human review. This PR changes which chat's approval policy a nested subagent inherits: runs at any depth under a trusted chat are approved automatically, and a conversation continued from another chat becomes contested and prompts every time. It also changes how continuations are released, which deletes session files. Under the review policy, a change to who is trusted and what an approval policy allows is reserved for a maintainer. Every lane is PASS and every check is green at Open points on this head for the human reviewer:
Reviewed head: — crew-pr-reviewer (r117) |
|
Answering the r117 open points and the advisory notes on GPT F1 ( GPT F2 (card misroute after a later contested continuation). Opened #22827 with the trigger, outcome and the reason it was not fixed here (a third routing root on every record for a cosmetic misroute). Linked from the description's release notes and Related Issues. Design. Note 1: agreed, the First Principles item 6. Declared: a release-notes bullet in Backwards compatibility now says that a nested run's card, frames, sidebar badge and reconnect replay move into the root chat's tab (previously drawn in no tab), with #13116 for depth-aware rendering and #22827 for the known misroute. UX. The two orders are deliberate and documented in What changed: the spawn feed card has no tool purpose, so it puts the remedy second so the excerpt reaches the safe verb before the cut; a tool prompt leads with the state, then the tool's own purpose, with the why and remedy whole in Review. "This run has no single owning chat" is the one sentence that is true for every case the marker covers (two chats, an unreadable or pre-stamp founder, a resumed admission without its stamp, a cron's or CLI's run a chat picked up), which is why it does not name "a different chat". If the maintainer would rather lead with the cause on the spawn card and accept the excerpt cut, say so and I will change the strings in a follow-up push.
|
iamwhatever
left a comment
There was a problem hiding this comment.
REQUEST_CHANGES -- reviewed 9cd0688 (same head as our r117 review).
Thanks for the replies. #22827 covers the card misroute, Closes #14110 is in the description, and the card move and the conversation_busy / _claimed refusals are now named in the release notes. The UX wording rationale holds.
One item is still untracked: you agreed with the Design note about folding the separate marker-to-slot guards (turn_approvals.py, subagent_wiring.py, ws.py) into one resolver and left it for a follow-up. Please open an issue for it and link it in the description, or say it is not planned.
After that, the PR still needs a maintainer. It changes which chat's Trust a nested subagent inherits, makes a conversation continued from another chat prompt every time, and changes a release path that deletes session files. The maintainer also picks the order with #18165 for the taskq_fail durability gap (#17397).
— crew-pr-reviewer (r118)
|
r118: the guard consolidation is now tracked as #22946 (one resolver for trust-root -> slot, replacing the separate checks in |
|
Housekeeping, no code change: readiness flipped to action required at 23:17Z because the disposition gate started admitting my 143 older |
|
Rebased 9cd0688 -> 3d3973d onto main f9e2e76. One import-line conflict in |
|
Re-rolled 3d3973d -> dc750f0: clean rebase onto main 3af84a4 (6 commits, no file overlap), content identical, maintainer commit patch-id unchanged. Reason: the Opus 5.5 Review lane on 3d3973d never ran -- its lane run failed at |
|
span=continuation-retained-hold
GPT on dc750f0:
|
|
Re-rolled 0819013 -> f7b43e1: clean rebase onto main db4f0a3 (6 upstream commits, no file overlap), content identical, maintainer commit untouched. The GPT fork lane on 0819013 ended "review incomplete" before any review step ran (the runner could not reach the OIDC token endpoint: |
|
🤖 Kiro Crew Auto-Pipeline [operator: buluoray#ce473fca]: for reference, the downgraded tab-routing finding from this PR's review is tracked in #22827. It is not a blocker here; it will be picked up after this PR merges. |
|
🤖 Kiro Crew Auto-Pipeline [operator: buluoray#ce473fca]: @billygerhard, checking in on this PR, which #13116 and #13244 point at. What blocks it today at Do you still plan to finish it? If there is no reply within 7 days, a maintainer may take the PR over to land the fix. |
|
Yes, still on it. At |
A trusted chat stores approval_policy="auto" on its own session key. A subagent's key is subagent:<id>, which the shared-runtime path never registers in the session store, so the spawn gate, the run loop's tool-permission branch and the interactive approver all read "" for a grandchild's parent and fell through to a prompt no tab could show. SubagentManager.root_session_key walks parent_session_key links to the chat that started the tree (stopping at a non-subagent key, an unknown id, an empty parent or a cycle); resolve_approval_policy reads the root's policy. The spawn gate and run loop use it, and the gateway resolves a subagent parent's approval slot from the root chat so the prompt lands in that tab and its slot trust applies. A continuation's start claims its conversation for the length of its awaits (_continuations_starting, keyed on the conversation rather than flagged on the founder's record, which may be evicted), and _conversation_busy answers the claim under the id the start will run as. Without it a rival continuation admitted while the start awaited could contest the conversation, finish and be evicted before the start committed, leaving the gate's commit-point check -- which adopts a contest from retained records -- nothing to adopt, and the founding root the start read before its awaits to grant a chat trust another chat had written past.
|
Rebased f7b43e1 -> 4642dd3 onto main 91d4998 to re-roll the two reds on the old head (Backend Tests (3.12, 4) and Coverage Gate). Clean rebase, no conflicts, content unchanged. The PR's own backend tests pass on the rebased tree (1292 passed). @iamwhatever could you re-review when you get a chance? The one open item from r118 (folding the marker-to-slot guards into one resolver) is tracked in #22946 and linked in the description. The remaining items, sign-off on the Trust-inheritance change and the ordering with #18165 for #17397, are maintainer decisions. |
|
span=contested-child-tab-root
span=legacy-alias-release-founder
Both blocking findings on 4642dd3 are accepted and fixed in dc5b80c (+112/-13, 6 files).
Both pins fail on the unfixed code. Gates: the PR's test files 1294 passed; release/sweep/routing callers 1585 passed; black, isort, flake8 and mypy clean on the changed files. |
…ion contested subagent_queued carries one parent's queue depth and the client stores it per slot as a value, so routing a nested parent's count to the root chat's tab overwrote the root chat's own wave count; it keeps its literal parent's slot. An in-memory queued continuation re-entered with its first entry's conversation stamp, so a contest a rival wrote while it waited was lost and it ran on the founding chat's trust; the gate's commit point now adopts a contest any retained record carries.
|
span=continuation-run-pin
GPT on dc5b80c:
Gates: the PR's test files 1298 passed; the 19 files that call |
bolichen97
left a comment
There was a problem hiding this comment.
Reviewed head c5d25fc5e7646dcef8d67740d0099bc90b020382.
No P0 found. I did not find a path where an untrusted chat's requests get auto-approved. I spot-checked the trust paths (trust_root_for, turn_approvals.py, the spawn gate, the retry path), not every line.
Both GPT 6.1 blockers on this head reproduce in the code:
src/kiro_crew/subagent_manager/admission/pump.py:788(P1)._ended_recordskips the give-back of a taken start because thefailedwrite was posted. That write only logs on failure, so under lock contention the row can staySTARTINGand a restart can run work the caller was told was refused. This is the base-level gap tracked in #17397. This PR now relies on it in a new place, so the merge order with #18165 matters.src/kiro_crew/subagent_parts/admission_surface.py_tab_root_below_contest(P2). The climb readstop.root_session_keybut never the capturedtop.tab_root_session_key. A grandchild spawned after another chat continues the ancestor conversation shows its cards in that other chat's tab. Display only, not trust, but a one-line fix: checktop.tab_root_session_keyat each hop before following the parent.
On size. The PR is +6138 lines: about 3760 tests, 1690 production, 406 for the screenshot script, 256 for the spec. Of the production lines, about 550 are # comments before docstrings, so the logic is about 1000 lines.
Most of that logic comes from the second goal, the contested-conversation marker, not from the first (trust reaching every spawn depth). The marker needs its own guard in card routing, the Slack DM path, retry, reconnect replay and the queue. Suggestion: split it. A PR that only carries trust down the spawn tree would be much smaller and easier to land. The contested marker can follow as its own PR under the RFC in #15457, with the three marker-to-slot guards (turn_approvals.py, subagent_wiring.py, ws.py) folded into one resolver there.
|
Closing this attempt. The scope grew well past the bug, and the reviewed direction is a much smaller change. The bug itself is filed as #28364 with the suggested minimal approach, so a maintainer can pick it up. Thanks to everyone who reviewed. |
Problem / Motivation
Closes #14110.
Goal: A chat's trust reaches every subagent in its spawn tree, so a trusted fan-out runs to completion without a prompt nobody can see -- and a chat that continues a conversation another chat started does not lend that conversation its trust, so every request such a continuation raises is asked of a person.
You trust a chat. Its subagents run without asking. But when one of those subagents spawns its own subagent, the grandchild stops and waits for permission. Nobody sees the prompt. It sits until the approval timeout, and the whole nested run hangs.
The decision behind the second half of the Goal -- a continuation from another chat no longer borrows that chat's trust -- is recorded as an RFC in #15457 (
docs/request-for-change/rfc-conversation-trust-follows-founder.md), merged to main inbeea9eac0fand on this branch's base.Why it matters
Anyone who trusts a chat and walks away from the keyboard expects the whole spawn tree to keep working. Today only the first level does. Any fan-out that goes two levels deep (a coordinator subagent that delegates) stalls for the full approval window and then dies, with no visible prompt to answer.
Not a goal
Backwards compatibility
Compatible: a non-subagent parent key is still one direct store read and its
root_session_keyequals its parent, an untrusted root still prompts at every depth, and every grant that is not chat-level trust (explicitapproval_mode, YOLO and--approval, the parentlessagent.approval_modefallback,auto_approve_sources, theauto_approve_subagent_*hooks) keeps its order and answers a contested run's prompts exactly as it would any other run's, as the RFC decides. What a contested marker withholds is chat-level trust alone:root_approval_policyrefuses it without a store read, the spawn gate'sparent_trustedand the run loop's chat-trust rung read""for it, and the interactive approver's slot trust does not answer a prompt keyed by it (the marker resolves to no slot, and a resolver that names a trusted slot is not consulted for it) -- pinned bytest_the_contested_refusal_outlives_the_records_that_established_itandtest_slot_trust_still_prompts. A run with no parent (a cron's or the CLI's spawn) is not a contested root: it founds its conversation in its own name, and a parentless continuation of it (the CLI's or a script'scontinue, with no chat behind it) inherits that founding root rather than contesting it, since no chat's trust is gained -- a parentless continuation of a CHAT-founded conversation is contested. Thehas_session(parent_session_key)liveness probe in the global-config fallback still reads the literal parent key. A record without a stamp (built outside admission) resolves its parent exactly as before.spawngains private_root_session_key/_conversation_root_session_keykwargs that only the queue drain passes.Behavior changes, for the release notes. Two things tighten, both deliberately and both permanent until #13244 ships a clearing affordance; two more are visible without trust being involved at all:
state.jsonwith noconversation_rootand asubagent:parent) has no readable founding root, so its first continuation after upgrade is contested and stays so; the depth-one case is spared (a pre-upgrade depth-one founder's chat parent is the root admission would have stamped). Start such a task again from one chat rather than continuing the old conversation. Recorded on dashboard: surface a contested subagent conversation instead of a bare global-feed prompt #13244 alongside the clearing affordance.conversation_busyat its commit point and refuses the rival; a continuation's start also claims its conversation for the length of its awaits (_claimed), so a secondcontinuearriving meanwhile is refused at its prelude rather than admitted and raced. Both refusals are typedconversation_busyand retryable.What changed (motivation → approach → change)
Trust is stored as
approval_policy="auto"on the chat's own session key. A subagent's key issubagent:<id>. On the shared-runtime path that key is never put in the session store, so three places that look up trust by the immediate parent key got""for a grandchild: the spawn gate insrc/kiro_crew/subagent_manager/admission/gate.py, the tool-permission branch insrc/kiro_crew/subagent_manager/run.py, and the interactive approver insrc/kiro_crew/slack/gateway.py. The approver also could not mapsubagent:<id>to a dashboard tab, so the prompt went only to the global feed.Every run now carries two keys stamped once, when it is admitted:
SubagentInfo.root_session_key, the chat, cron or channel key at the root of its spawn tree, andSubagentInfo.conversation_root_session_key, the root that governs every request keyed by its conversation.SubagentManager.root_session_keyinsrc/kiro_crew/subagent.pyfollowsparent_session_keylinks to the root, stopping at a non-subagent key, an unknown id, an empty parent, or a key already seen. Asubagent:<id>key names a conversation shared by the original run and each continuation, and a request under it cannot say which one sent it, so the answer never depends on which run is live (acontinuehanded a CONTINUATION's id is resolved to the founder first -- from the retained record, or from that run's ownstate.json-- byfounder_conversation_id, so the busy check, the root comparison and the contest write address one conversation rather than a second one keyed on the continuation over the same native session): the run that founds a conversation fixes its root, a continuation from the same root inherits it, and a continuation from a different root marks the conversation contested, after which it resolves to its own key. A contested conversation resolves tocontested:<key>, a marker that is no session key: the trust lookup (SubagentManager.root_approval_policy, used by the spawn gate and the run loop) refuses it outright and no tab shows it, and because runs admitted beneath the conversation carry the marker in their own stamps, the refusal outlives the records that established it. That marker is read as a TRUST stamp only (trust_root_for); for the TAB, a run below a contest belongs where its parent conversation's LIVE card is, soroot_session_key_forclimbs the retained ancestry to the first real key, consulting the newest active record under each conversation first (the founder's record, listed first, would otherwise own the card until it was evicted and then hand it to another tab mid-run, leaving the first tab a running card no frame clears), and answers"", the feed, when none is left, and its frames, the rooted listing behind the sidebar's count and the reconnect replay never key on a marker no tab reads. The founding root outlives them too: admission persists it in the run'sstate.json(conversation_root, written bycreate_agent_folder), a contested continuation writes the contest onto the founder's record before its turn runs (_write_state_off_loop, given the founder's id, throughupdate_state(durable=True), so a founder held live-only at that moment -- tightened into memory by an incognito or temporary continuation, where a plain merge reports success without touching the file -- still has itsstate.jsonstamped, and its in-memory record takes the marker only after the file holds it, so a failed write never leaves memory claiming a contest that a restart would undo; the switch is closed to the one provenance field,conversation_root, and refuses any other field on a live-only record, so no later caller can carry a turn's body to disk on it; the write is the contest's only durable carrier, so a skipped write -- the founder's record unreadable -- is retried once and then refuses the run rather than let a turn through whose contest a restart would forget; the retained founder record in memory takes the marker too), and a continuation that arrives when no in-memory record of the conversation remains (a gateway restart, or the founder evicted) compares against the founder's record -- read off the event loop byspawn_async(_durable_conversation_root, viaasyncio.to_thread) and handed to the gate as a value, the gate's resolver itself reading nothing and failing closed without one; a captured contest outranks every retained record, since the record that contested the conversation may be evicted while the founder's is still retained with its founding root -- instead of founding the conversation in its own name -- a matching root is inherited; a different root, a persisted contest, or no readable root at all (folder gone, or a nested record written before the stamp existed) leaves the conversation contested; a depth-one record written before the stamp existed still names its chat parent, which is the root admission would have stamped, so a same-chat continuation of a pre-upgrade run is spared a one-time lockout while a cross-chat one is contested as it would be with the stamp. A run with no parent (a cron's or the CLI's spawn) founds its conversation in its own name and resolves to its own key: nothing contests it, so its registered policy is read as before, and a chat that continues it contests the conversation rather than founding it. The gate captures both keys on the spawn's first entry and carries them in the queued parameters, so a member drained later keeps what it was requested with; the dashboard's retry of a failed run (api_spawn_retryinsrc/kiro_crew/dashboard/handlers/messaging.py) passes the failed run's stamped root the same way, so a retry is governed by the trust its original ran under rather than by a re-walk of a parent conversation that may since have been continued from a trusted chat. A durable queued row written before the stamp existed is the one re-entry with no captured root: it outlives a restart, itssubagent:caller is not rehydrated on boot, and a re-walk at refill would find whichever chat has since continued the caller's conversation. It is covered by the same rule, since every window entry re-enters through the drains with_from_queue=True, so the store's read side (_window_entryinsubagent_manager/admission/taskq_bridge.py) hands the row through as written rather than keeping a second copy of the rule. The two stamps part ways on that read side, though: the trust root stays on the row (a re-walk could only widen it), while the conversation root a row was written under is stripped (a replay could only widen it; a CONTESTED stamp is the one value kept, since it is a refusal rather than a grant and the dashboard retry of a failed contested continuation carries the marker as its only tie to the contest, with no conversation key to re-resolve it from) -- a store-only row is not in the in-memory queue, so it does not hold its conversation busy, and a continuation from another chat admitted while it waited on disk writes a contest onto the founder's record that the row's stamp predates; replayed, the stamp would run the refilled continuation, and every tool call in it, on the founding chat's auto-approval. A refilled row re-resolves at re-entry instead, and the pump (_dispatch_async_implinpump.py) reads the founder's durable record off the loop first, the wayspawn_asyncdoes for a first entry, since the in-memory record that contested the conversation may be gone while the founder's is still retained with its founding root. The gate enforces one structural rule for every resumed admission (_from_queue,_store_accepted): a nested caller arriving without the stamp resolves to a contested root there, so a future re-entry path that forgets the parameter costs an interactive prompt, never an escalation. The gate reads the root's trust, and the run loop reads its own stamp and hands the root key to the interactive approver, so a prompt that still needs a human lands in the root chat's tab. The run loop reads that stamp throughSubagentManager.trust_root_for, which has one exception: a continuation admitted into a contested conversation reads the conversation's marker rather than the chat that continued it, because the turn it runs was authored under the founding chat's key and the continuing chat's trust must not approve what that turn asks for -- its card still belongs to the continuing chat's tab, and its prompts reach the global feed labeled like every other contested prompt; a same-root continuation inherits normally. The spawn gate's trust check, the spawn prompt's address (pump.py) and the gateway's_spawn_approval_slotread the same trust root, so a run admitted into a contested conversation is interactive at admission as well as mid-run, and the dashboard retry of a failed contested continuation passes the marker as_conversation_root_session_keyso the retry is governed by it rather than founding a fresh conversation at the chat whose tab held its card (any other stamp is re-derived by the gate). The spawn gate (subagent_manager/admission/pump.py) raises its prompt under the root chat's key rather than the literalsubagent:<id>parent, so channel delivery, the tab and a Trust press all address the key the gate reads back. The gateway resolves a spawn approval's tab through_spawn_approval_slot, and a nested run's file card insrc/kiro_crew/dashboard/handlers/files.pyroutes to the same root tab instead of being suppressed, through the same tab accessor (root_session_key_for), so a run below a contested conversation lands its card in the ancestor's tab rather than being dropped on a marker whilefile_sendreports success. Depth is unbounded.docs/system-specs/modules/subagent.mddescribes the root resolution, the conversation root and the admission stamps.flowchart LR subgraph Before C1[chat: trusted]:::ctx --> A1[subagent A]:::ctx A1 --> B1[subagent B]:::ctx B1 -. "lookup subagent:A → ''" .-> P1[prompt to no tab, times out]:::removed end subgraph After C2[chat: trusted]:::ctx --> A2[subagent A]:::ctx A2 --> B2["subagent B<br/>root_session_key = chat"]:::changed B2 -- "read root's trust → auto" --> OK[auto-approved]:::added end classDef added fill:#DCFCE7,stroke:#16A34A classDef changed fill:#FEF3C7,stroke:#D97706 classDef removed fill:#FEE2E2,stroke:#DC2626,stroke-dasharray:4 3 classDef ctx fill:#E0F2FE,stroke:#0284C7 linkStyle 2 stroke:#DC2626,stroke-dasharray:4 3 linkStyle 5 stroke:#16A34A,stroke-width:2px🟩 added · 🟨 changed · 🟥 removed · 🟦 unchanged
A nested subagent now carries the key of the chat that started its tree, so it reads that chat's trust and runs unattended instead of hanging.
A nested run's per-run WS frames (
subagent_spawn/tool/chunk/done/snapshotfrom_subagent_eventinsrc/kiro_crew/slack/gateway.py) now carry the root chat's slot too, so the pending card the spawn prompt planted in that tab advances instead of sitting on "Starting" forever; the chip's 30-second reconcile (website/src/pages/chat/SubagentProgressBar.tsx) now matches live rows by run id alone (#20987 on main), so it neither evicts the nested card the frames just painted nor fails a live card in a cron- or channel-born tab, and this PR no longer touches it. The list-carryingsubagent_statusframe (_broadcast_subagent_status) addresses the same root tab and lists the tree rooted there (SubagentManager.running_agents_rooted_at): itsagentspayload replaces a slot's whole list and arunningof 0 evicts the slot's cards, so a parent-keyed frame would have wiped a live nested card the moment its coordinator finished; the done path hands the frame only a resolved injection slot, not the raw parent key. The reconnect replay (subagent_replay_slotinsrc/kiro_crew/dashboard/ws.py) names the same tab from the run's stamp, so a reconnect redraws the nested card where the live frames put it.running_agents_forstays parent-keyed: it answers the parent's own wave, the orchestration question. Depth-aware rendering of those cards is tracked in #13116. A contested conversation's prompts reach only the global approvals feed (_spawn_approval_slotanswers""for its marker rather than a phantom slot); its spawn prompts keep the ask as their title (spawn_run(...), as on every sibling card) and carry a second line written in the words of what the user did rather than the system's model -- the state first, so the card's two lines say what this prompt is, then the remedy, whose closing clause says an approval is not a fix (the contest is durable, so every later request asks again), then the why last, whole in Review -- a why that states only what every case the marker covers established (the chat that started the task was not confirmed as the one continuing it: two chats, an unreadable or pre-stamp founder, a resumed admission without its stamp, a cron's or the CLI's run a chat picked up), since the marker does not record which case minted it and the reader may be the very chat that started the task; in active voice with the product as the actor that failed to confirm, so the reader sees at a glance whether they caused the contest (This run has no single owning chat. Start this task again from a single chat, or approve this request (each request will ask again). Kiro Crew could not confirm that the chat continuing this task is the one that started it.;CONTESTED_PROMPT_STATE/CONTESTED_PROMPT_WHY/CONTESTED_PROMPT_REMEDYinsubagent.py, assembled bycontested_spawn_note) -- which the gateway's spawn approver (_spawn_approve) hands over as the prompt'stool_purpose: the feed card shows the ask in its title and the state and remedy in its body, and the Review panel shows everything; the remedy names no button, since the card offers Review and the panel Approve. A one-line description is unchanged. The run loop leads the purpose of every tool prompt a contested run raises with the same state and a one-clause why, a period before the tool's own purpose so the purpose does not read as a remedy clause (contested_tool_note, via_label_contested_prompt), and the why and remedy last -- after the tool's purpose, so the card's two lines carry the state and what the tool is for (a spawn prompt, which has no purpose to show, puts the remedy second so its card's excerpt reaches the safe verb before it is cut, and the why last), while a user who meets only tool prompts still reads the why and the way out in Review; the three are separate paragraphs and the run's own claim is set as a quote, which the Review panel renders as a distinct muted block, and attributed in words too (CONTESTED_RUN_ATTRIBUTION, "The run says:"), because the card's plain two-line excerpt strips the quote marker and that card is what a habituated approver reads -- so on the one surface that exists because the run is not trusted, its claim never reads with the authority of the system's sentences around it -- so a mid-runshell(...)on the feed says why it has no chat too; naming the asking run on nested prompts, a badge in the Subagents panel, and a clearing affordance for a contested conversation (the contest is durable and otherwise permanent; re-founding it under one chat is a human action for #13244 to design, including rewriting the founder record'sconversation_root) are tracked in #13244.Tests
test/test_subagent_nested_trust.py:"auto"; a cycle terminates and trusts nothing; an unknown id stops the walk without inventing a grantroot_session_keyon a depth-two run; a stamped run keeps its root after its parent is popped from the registry; an unstamped run under a missing parent stays interactive (documented fallback)spawn_steermode="follow_up") carries the stamp the run was admitted with (its chat root, or for a cron's or the CLI's run the conversation root it founded in its own name), so it inherits its root even after its parent has been evicted, or when it never had one, where a re-walk of the parent key would have falsely contested the run's own conversation and persisted that contest onto its founder (test_a_runs_own_follow_up_keeps_its_stamp_after_its_parent_is_evicted), and the gate'sparent_trusteddecides on that resolved root rather than the literalparent_session_key, so a parentless run's follow-up (empty parent, founding stamp presented) is admitted under the policy registered on the run's own key -- the same trust its children already resolve to, and the policy the run loop already runs that turn under -- instead of raising a prompt on the global feed that no chat's trust could answer, while the parentless original resolves to no root and a chat continuing its conversation is contested, neither auto-approved (test_a_parentless_runs_own_follow_up_is_admitted_under_its_registered_trust); two continuations of one conversation can never both be admitted -- the gate re-checks_conversation_busyat its commit point, with no await before the write to_agents, and refuses the rivalconversation_busy, since a same-root one registered first would otherwise run its whole turn under the founding root while a cross-root one registered second contested a conversation the first never re-reads (test_two_continuations_of_one_conversation_cannot_both_be_admitted, driven withasyncio.gather); a continuation's start also claims its conversation for the length of its awaits (_continuations_starting, keyed on the conversation rather than flagged on the founder's record, which may be evicted), and_conversation_busyanswers the claim under the id the start will run as, so a rival continuation arriving while the start awaits is refused at its prelude rather than admitted -- without it a rival could contest the conversation, finish and be evicted before the start committed, leaving the commit-point check, which adopts a contest from retained records, nothing to adopt, and the founding root the start read before its awaits to grant a chat trust another chat had written past (test_a_continuation_start_holds_its_conversation_through_its_awaits, the start parked inside its durable-root read while the rival is answered, then released and admitted under its own root, the claim gone with it), and the refused rival's committed store row getstaskq_fail'sfailedwrite in the same step, as every other refusal of a persisted row does, so a restart does not requeue work the caller was told was refused (test_the_refused_rivals_store_row_is_settled_failed, against the real store). Making that write's durability a precondition of publishing the refusal -- a settle retried until the row reads terminal, with the run's tombstone written first -- is a pre-existing refusal-durability gap shared by everytaskq_failcaller, not this change's, and is tracked in taskq_fail publishes a refusal before its failed write lands; a lost write leaves a claimed row for the boot reconcile to requeue #17397; a persisted contest survives a restart (the founding chat cannot reclaim the conversation) and outranks a retained founder whose contesting continuation was evicted (and, without the durable trace, the retained founder alone would have granted it), and a contested continuation's run writes the contest onto the founder's record before its turn runs and stamps the retained founder record in memory with the marker, while a same-root continuation leaves both in place; a same-root continuation inherits the founding root; a cross-root continuation marks the conversation contested (resolves to thecontested:marker, order-independent, and stays contested); an untrusted run's spawn admitted after a trusted chat continued its conversation is never auto-approved; the continuation's own tool prompts are likewise interactive and addressed to the contested marker rather than auto-approved on the continuing chat's trust (a same-root continuation still inherits), and a continuation whose contest write is skipped does not run (the writer is retried once, then the run is refused before any turn); the contest reaches the founder's durable file even when the founder is held live-only at that moment (a tightened, incognito-style record, where a plain merge would report success without touching the file), pinned bytest_a_contest_reaches_a_live_only_founders_durable_recordand byupdate_state(durable=True)'s own unit tests, which also pin that the live record is published only after the file write succeeds -- a skipped or failed write leaves memory on the old root (test_a_failed_durable_write_publishes_nothing_to_memory); a retry carrying the contested marker at a trusted routing root is interactive at the gate and its run's trust root is the marker;spawn_asyncreads the founder's record on a worker thread (never the loop thread) and the resolver fails closed rather than read when handed no value; a contested continuation's own spawn prompt names no slot even though its card's tab is the trusted chat, andapi_spawn_retrypasses the marker for a failed contested continuation and""otherwise; a contested conversation stays untrusted at the gate and in the run loop even when the store holds"auto"under its key, and a child admitted beneath it stays untrusted after the founder and the continuation are evicted, while a parentless run's own key still reads its registered policy and a trusted chat's continuation of a parentless original contests it instead of founding it (its in-flight spawn stays interactive); two independent founders with different roots (concurrent continuations after eviction) leave the conversation contested; hand-built unstamped records still terminate on a cycle/api/spawnentry names the root chat beside the literal parentapproval_policy="auto"to the grandchild's sessionsubagent:<id>, to the interactive approver on both the ordinary and the low-fidelity-child paths, with the ancestor already gonesubagent:<id>and unlabeled, while a contested conversation's spawn prompt carries the contested label; a cron/chat key reads the store directly_spawn_approval_slotresolves a nested spawn's card to the root chat's tab (and""for an unknown run, no manager, or a contested root -- never a phantom slot); a prompt addressed to the root chat is approved by that slot's trust; a nested run'ssubagent_spawnframe carries the root tab's slot; a nested run's file card resolves to the root tab, an unstamped record to its parent; a contested prompt goes to the dashboard feed alone, not the owner's Slack DM (the marker names no channel, and the DM card's Trust button would record the marker as a trusted session)The module is pinned with
healthy_host_memoryas the spawn-host ratchet requires. The exploration tests failed on unfixed code and pass after the fix; the preservation tests passed before and after.test_spawn_prompt_first_line_is_the_title_and_the_rest_its_purposedrives the real_spawn_approveclosure (captured through_init_subagents) with a two-line and a one-line description.test_status_frame_for_a_nested_run_refreshes_the_root_tabs_listdrives the realon_donefor a coordinator that finishes before its nested run (the root tab keepsrunning: 1and the nested row) and then for the nested run;test_reconnect_replay_slots_a_nested_run_to_the_root_tab,test_a_retried_terminal_report_keeps_the_root_stamp(ancestor evicted before the retry; the snapshot still finds the root tab) and the rooted-vs-wave list test pin the replay slot, the retry stamp andrunning_agents_rooted_at; the chip's reconcile is pinned by main's own vitest cases for #20987 (a nested or channel-rooted run is kept by id).test_a_resumed_admission_without_its_stamp_fails_closed_in_the_gatepins the gate's structural rule (a_from_queuenested caller without the stamp is contested even when the walk now finds a trusted chat; stamped and parentless re-entries unchanged) andtest_a_contested_runs_tool_prompt_says_why_it_has_no_chatpins the tool-prompt label through the real run loop (title intact, purpose = state (why) — the tool's own purpose, no remedy; a chat-rooted run's prompt is untouched).TestRecoveredRowsFailClosedpins the legacy-row path end to end: the read side hands a pre-stampsubagent:-keyed row through unstamped, and re-entering that entry the way the drains do (_from_queue=True) leaves the recovered run interactive even when a re-walk now finds a trusted chat;test_the_read_side_strips_the_conversation_root_a_row_was_written_underpins that the conversation-root stamp is stripped beside the two process-local grants while the trust-root stamp stays, andtest_a_refilled_continuation_reads_a_contest_written_while_it_waiteddrives the dispatcher against the real store with a row stamped under the founding chat, the founder retained in memory with its founding root, and a contest on the founder's durable record: the admitted continuation resolves to the marker and no chat's trust, where either the stamp replayed or the pump skipping the durable read hands it the founding chat's auto-approval.prove.py --per-hunkreverts every behavior hunk and a named test fails for each; the two hunks it reports uncaught are a comment-only edit and the one-line closure that delegates to_spawn_approval_slot.website/scripts/capture-nested-subagent-trust.mjsasserts the dashboard scenes shown under Manual verification (including the contested entry in both themes and the tool card leading with its state) against the built SPA (tsc, eslint and the chip's vitest file pass);approvalNotificationBody.test.tsxpins the purpose-first body for a chat-less prompt and the unchanged default order.test/test_queue_during_subagents.pyfollows the sidebar badge's move from the tab's own wave (running_agents_for) to the rooted tree:serialize_slotsresolves every live run's tab root ONCE per slots push (SubagentManager.live_root_session_keys, a set) and tests each tab for membership, rather than askingrunning_agents_rooted_atper tab, which would resolve every run once per tab and build a redacted summary list for a boolean; its doubles expose the set accessor, a new case pins that a live grandchild keeps the badge lit after the coordinator that spawned it finishes, and the true-flag case pins one resolution per push across two tabs; editing the file meant formatting it, so it comes off.github/black-baseline.txt(the baseline gate asks for exactly that when a listed file becomes clean).Manual verification
Captured against the built SPA by
website/scripts/capture-nested-subagent-trust.mjs(scripted Playwright; it driveswebsite/distwith the gateway's own WS frames and exits non-zero unless every scene asserts). The depth-one runc0ffee01is the coordinator;deadbe02is its child, whose literal parent issubagent:c0ffee01.The grandchild's spawn prompt, addressed to the root chat's tab, parks in the composer chip beside the running coordinator:
After approval the nested run's frames advance its row, and it is still there 33 seconds later, past the chip's 30-second reconcile whose
/api/spawnentry namesparent: subagent:c0ffee01butroot: dashboard:<slot>:While it runs, a
file_sendfrom the nested run raises its card in the same root tab (_subagent_parent_session_keyresolves the stamped root; before, the run's literal parentsubagent:c0ffee01named no tab and the card was suppressed):A tool call the nested run makes mid-run raises its permission prompt in the same tab (
run.pyhands the run's stamped root key to_on_tool_approval); the root chat is untrusted here, so the prompt is interactive:Its
subagent_doneframe then finishes the row, leaving the coordinator alone in the chip:A contested conversation's spawn prompt carries no slot and lands on the global feed. Its title is the ask, as on every sibling card, and its body is written in the words of what the user did -- the state first, so the card's two lines say what this prompt is, its why in a clause, then the remedy (whole in Review, where the decision is made):
Review opens the entry where the user decides, with the copy whole and Approve / Reject. The capture below shows it:
The same entry and panel in the light theme:
A tool prompt the contested run raises mid-run reaches the same feed with the tool as its title;
_label_contested_promptleads its purpose with the state and a one-clause why, a period separating them from the tool's own purpose, and closes with the remedy -- last, so the card's two lines stay the state and what the tool is for while the Review panel, where the user decides, still names the way out for someone who only ever meets tool prompts. A contested prompt is exactly this case, and the approval record says so explicitly (contested, set by the gateway from the trust root the callback is handed --_interactive_approvalingateway.py, carried on the record byinteraction_coordinator.pyand itsapprovalframe), so the feed card's body puts the purpose ahead of the command for it (approvalNotificationBody(..., { purposeFirst })); the reader never infers the case from an empty slot, since a subagent rooted in a cron, the CLI or a channel has no tab either and its purpose is the run's own words, which must not be promoted above the fenced command -- every other prompt keeps the command first. The card says why it has no chat before it is opened, and the whole label reads in Review:The same tool prompt's panel in the light theme, the run's claim set apart as a quote with a purple bar and muted italic:
Related Issues
Linked issue for the contested-conversation part: #14110 (a continuation from a second chat runs under that chat's Trust on
main; base-runnable probe attached there). No issue was filed upstream for nested-depth trust inheritance itself (#4751 is about routing subagent prompts interactively, not inheritance). Follow-ups: the tree-aware Subagents panel, #13116; re-founding or clearing a contested conversation, #13244; the card misroute after a later contested continuation, #22827; folding the three marker-to-slot guards (ws.py,subagent_wiring.py,turn_approvals.py) into one resolver, #22946.Pattern harvest
Rule candidate: review-prompt
Pattern: "policy or ownership looked up by the immediate parent key when the caller can itself be a child (subagent:) — resolve through the root of the tree, captured once at request time, never re-derived at a later stage"
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)