Repository navigation
fix(spawn): admit the host operator's cli spawn without a session - #15593
koenvincent wants to merge 1 commit into
Conversation
|
👋 Hi! This PR's description is missing some required sections from our PR template. Workflow runs won't be auto-approved until the description is updated. Missing sections:
Please update your PR description to include these sections, then push or re-save the description. The workflows will be approved on the next cycle. |
GPT 6.1 Review (fork) — ✅ no blocking findingsReviewed Review detailsNo findings. |
Design Review (Opus 5.5, fork) — 🟡 CONCERNSDesign-level review of Design-Verdict: CONCERNS A CLI-auth fix also tightens spawn governance and changes which agent runs on every surface. That should be its own PR, and the fix still leaves Windows broken. Watch
Suggestions
[DESIGN-REVIEWED] 502e9ad Description read[DESCRIPTION-READ] f92df90c1f013d0a2d086f5f5472e9056ba28a953e2ae2feb480f44dda2a08cb 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, fork) — 🔴 BLOCKPremise-level review of First-Principles-Verdict: BLOCK product-shape change without accepted RFC: on every surface, a spawn that names no agent now runs Not justified as shipped
What this change shipsInventory (10 items) — 5 justifiedIntent: let the host operator start a subagent from the terminal. FIX.
Blockersproduct-shape change without accepted RFC: the default agent for nameless spawns. The description says "The agent that answers changes too". [FIRST-PRINCIPLES-REVIEWED] 502e9ad Description read[DESCRIPTION-READ] c1182493d0034a1c3af70740970d11150fa9c1ff9fa2f7a22adc91602947a468 That sha256 names the PR description this verdict read. Recompute it with |
Opus 5.5 Review (fork) — ✅ no blocking findingsReviewed |
82ca209 to
f3a2a49
Compare
|
Thanks @koenvincent. The root-cause analysis ( What it changes. The no-session exemption now needs the CLI's whole shape AND a host peer process (
Tests. A non-host peer, a session-unbound MCP caller, and a caller with a session key but no parent each stay 409 Not changed here, will track separately:
A backport to |
f3a2a49 to
581cbba
Compare
581cbba to
14cdba7
Compare
|
Pushed What this push covers:
Below are dispositions for the findings the lanes posted on |
|
|
|
|
|
|
|
|
|
|
|
Maintainer rebase pushed: 37e4d64 -> ddd2cd7, onto main aee834c. It applied cleanly with no conflicts, so no code changed and the route-table pin did not need a new digest. It is still one commit, authored by Koen Vincent, with the Co-authored-by trailer. Why: on 37e4d64 the only reds were Checked locally on the new head: black, isort, flake8 and mypy are clean. The targeted suites pass ( |
|
|
|
|
|
|
|
|
|
|
|
|
|
/ai-review override first-principles ddd2cd7: Maintainer decisions are already recorded (5964017525, 5964899894, 5977964351, 5988267324, 6007795939, 6038349655, 6048628725). A nameless spawn runs kirocrew on every surface, CLI spawns are governed as surface cli, and the app mint fold is deferred to #16350. This head rebases 37e4d64 onto main with no code change. Every FP item repeats one already ruled on. |
Human judgment recorded@bolichen97 marked the first-principles 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. |
|
This makes |
|
@bolichen97 Rebased onto current main to resolve the conflict; the only change beyond the base is the MCP route-table fingerprint in |
|
@bolichen97 Rebased onto current Beyond the rebase:
The other red shards on the previous head ( The First Principles findings should match the ones you already ruled on. Could you re-record the override for e889fde? |
|
Rebased onto current
The First Principles override was recorded for an older head, so it has to be recorded again for this one. Since #18468 now admits the session-less internal caller, a maintainer may also want to confirm that the owner-token path here is still the route they want for |
|
Follow-up at 8243257: This is worth a maintainer's look before reviewing further: with #18468 merged, |
kirocrew spawn run posted /api/spawn with the internal secret and no session. api_spawn claimed the body default "" while the verified scope had session None, so every CLI spawn got 409 member_identity_unavailable, and a headless gateway could not start a subagent at all. The CLI is the dashboard owner at a terminal, so it now authenticates as the owner principal: it mints a short-lived owner token from /api/token/local with the local secret, over the dashboard unix socket only, and sends it on every spawn call. The owner arm of the spawn routes admits it as it admits the owner's browser; the shared identity check for internal callers is unchanged. The spawn carries origin "cli", accepted from the owner principal only and kept on the task row. Nothing inherits it: a run that run spawns and a schedule it creates do not carry it. Such a run is governed as surface cli on every agent name it answers to, the explicit template and the agent it resolves to, at admission and at the run-time re-check, and faces the ordinary spawn prompt like any other caller's. A continuation of it that names a parent session is governed under that session. An internal caller with no session now owns no run, parentless ones included, and its refused spawn is audited as before. A spawn that names no agent is checked as kirocrew and runs kirocrew by name, so the agent checked is the one that runs. The run-time re-check now covers a run that names its agent too, so a scope tightened while it waited for approval still binds it. The warm pool matches on the agent that runs, so a pool filled for no agent still serves a spawn that asks for kirocrew by name. The poll asks again, a bounded number of times and after Retry-After, when the gateway answers a 5xx or the answer to a poll is lost; any other failure ends it with the gateway's or the transport's error. It exits nonzero for any ending but completed: a stopped run, and a run whose ending nothing recorded, are not reported as a success. A gateway older than the CLI sends no outcome, and there an error still fails and anything else prints the result. Both servers name the unix socket for the bound port, so --port auto works. Co-authored-by: Bolin Chen <bolichen@amazon.com>
|
Rebased onto main c46a1dc (new head 502e9ad, one commit, verified).
The scope question from my earlier comment still stands. Since #18468 merged, |
|
Closing this in favour of #18468, which merged on 2026-10-13. With it, What is left here does not stand on its own. First Principles is blocking on the nameless-spawn default agent (a product-shape change without an RFC). The remaining items are a second token-mint path next to |
Problem / Motivation
Goal:
kirocrew spawn runstarts a subagent again instead of always failing.On a 0.8.0rc1 gateway, every
kirocrew spawn run '<task>'fails with409 member_identity_unavailable("The execution identity is unavailable; Global memory was not used."). No run is created.Why it matters
On a headless gateway (no dashboard attached) the CLI is the only local way to start a subagent, so there is no way to start one at all. Scripts and SSM-driven automation that call
kirocrew spawn runare hit every time, with an error that points at memory identity rather than at the CLI.Not a goal
auto_approve_subagent_spawnor a dashboard to approve it. Whether the owner's terminal may skip the prompt is #16313.What changed (motivation → approach → change)
api_spawnclaimed the body default"", the verified scope hadsession=None, andinternal_memory_scopecompared"" == None, so every CLI spawn got the 409.internal_memory_scope) is unchanged, so directives, keepalive, tool policy and workflows keep their behaviour. Normalising""toNonethere was rejected: it would widen exactly those routes.kirocrew spawnauthenticates as the dashboard owner (newowner_gateway_client), not as an anonymous internal-secret callerGET /api/token/local?origin=cli, over the dashboard unix socket only (no TCP path), after the CLI checks that the socket's peer is the gateway recorded for the port (run/gateway-<port>.pidand its start identity)origin: "cli"claim (read with the newtoken_auth.validated_token_origin), for the owner principal only, recorded on the run'sExecutionContext.origin; a CLI spawn that names aparent_sessionis 400invalid_origincli(cli_chat,subagent.spawn_governance_key) on every agent name it answers to (subagent.spawn_policy_agents), at admission and at the run-time re-check; a spawn that names no agent is checked askirocrewand runskirocrewby name (run.pyclaims it explicitly), so the warm pool'ssession.pool_agent/agent.default_agentcannot run in its placeauto_approve_subagent_spawnor Trust it waits for approval or is refused, and the poll says so. Skipping it for the owner's terminal is a separate decision (#16313, RFC then opt-in)derive_executionclearsorigin) and a schedule it creates (bind_cron_memory)_run_belongs_to_caller, list included)taskq_unavailable"retry shortly") or a poll whose answer was lost is asked again up to_SPAWN_POLL_RETRIEStimes, afterRetry-After; any other failure ends it with the gateway's or the transport's error and says the run may still be going; exits nonzero for any ending butcompleted(a stopped run, and a run whose ending nothing recorded, are not a success); hints at spawn and tool promptskirocrew spawn list?queued=1), over the owner transport, every field confined to its line/api/token/localregisters with the routes both servers share, so a headless--slack-onlygateway serves it; both servers name the unix socket for the bound port, so--port autoworks;GET /api/spawn/{id}done answers carryoutcome, and both read paths reportawaiting_tool_approvalBackwards compatibility
Breaking:
X-Session-Keycan no longer start, list, read, steer, release, retry or delete a parentless run. Writer sweep on origin/main @ 3d465a6: the only such callers were the oldkirocrew spawn(replaced here), an MCP stdio server that lost its session (now refused with the existing identity-gap message) and code_review_sage's_probe, which only checks that a gateway answers.kirocrew spawnis POSIX-only for now.kirocrew spawn run/listhas no TCP path. Where the gateway serves no dashboard socket (Windows, or a socket bind that failed, for example a data-home path too long forsun_path), the CLI says so and points at the dashboard.spawn listworked over TCP on main; an owner transport for socketless gateways is #16314.cli.mdandsubagent.mdstate it.capabilities.spawn.scopes.agentsaskirocrewat admission and at the run-time re-check, and runskirocrewby name. On main it was checked at neither, and it ran whatever the session claim picked for no agent (the warm pool'ssession.pool_agentoragent.default_agenton a pool hit,kirocrewon a cold start). So a profile whosecapabilities.spawn.scopes.agentsis an allow-list withoutkirocrewrefuses it at admission (agent 'kirocrew' not permitted by spawn policy); remedy: addkirocrewto the allow-list. The agent that answers changes too: an operator who setagent.default_agent(orsession.pool_agent) no longer gets that agent for a nameless subagent spawn on a warm-pool hit; it runskirocrewand starts cold, because the agent governance checked must be the agent that runs. Remedy: name the agent explicitly on the spawn (agent=). Pinned bytest_a_spawn_that_names_no_agent_is_checked_as_the_default_agentandtest_a_run_naming_no_agent_runs_the_agent_its_scope_checked;governance.mdstates it.kirocrew spawn runexits 1 for a stopped run, which main reported as a success.--port autothe dashboard socket is named for the bound port (dashboard-<port>.sock), notdashboard-0.sock.Tests
test/test_spawn_cli_owner.py(new): the CLI mints anorigin=cliowner token over the checked socket and never uses TCP (test_spawn_run_mints_a_cli_owner_token_over_the_checked_socket,test_a_gateway_with_no_socket_is_named_and_tcp_is_never_tried); each mint refusal names its remedy; the POST and mint timeouts say whether anything was sent; a 503 withRetry-After, a read timeout and a cut-off answer are asked again (test_the_poll_asks_again_after_a_transient_failure) and give up after the bounded retries (test_the_poll_gives_up_after_its_retries); a poll that never reached the gateway, a gone socket, a listener that is not the gateway, or a 4xx ends it and says the run may still be going (test_a_lost_poll_ends_and_says_the_run_may_still_be_going); a stopped run and an unrecorded ending exit 1 (test_a_stopped_run_is_not_reported_as_success,test_an_ending_nothing_recorded_is_not_reported_as_success); a 403 earns one fresh mint; a clock jump renews the token; a listener that is not the gateway receives no credential; only the CLI token marks a CLI run and it carries no link nonce; a CLI spawn naming a parent is refused; a session-less internal caller starts and controls no parentless run, and the shared identity check keeps its 409; a CLI spawn faces the ordinary spawn prompt (test_a_cli_spawn_faces_the_spawn_prompt); a child and a schedule do not inherit the origin; asurface:cliprofile governs the CLI spawn, a retry of it and the run-time re-check; a spawn naming no agent is checked askirocrewon any surface; a spawn that names its agent is checked again when its run starts, so a scope tightened while it waited for approval stops it (test_a_named_agent_is_rechecked_when_its_run_starts; the run-time re-check used to cover only inherited names); the warm pool matches on the agent that runs, so a pool filled for no agent serves a nameless spawn (test_the_default_agent_by_name_claims_a_pool_filled_for_no_agent,session_pool._claim_from_pool); both servers serve the mint.test_kirocrew_spawn_end_to_endruns the real CLI against the real middleware, owner bootstrap and peer check, through a clock jump and a logout, and sends the old internal-secret shape, which gets the 409.test_dashboard_server_startup_coverage.py::TestStartDashboardWiring::test_backends_spawn_with_the_reserved_ports_evidence_exportedandtest_dashboard_server_coverage.py::TestStartApiServerResidualPaths::test_the_unix_socket_is_named_for_the_bound_port: both entrypoints name the unix socket for the bound port.test_taskq_admission_integration.py::test_a_cli_origin_row_keeps_its_origin_and_faces_the_prompt.test_member_memory_api.py(test_run_controls_fail_closed_for_a_caller_with_no_session_identity,test_spawn_list_shows_an_identity_less_caller_nothing),test_subagent_continuable.py(the inherited-template refusal lands at admission; a continuation of a default-template run claimskirocrewby name),test_subagent_spawn_approval_parked_6484.py,test_cli.pyandtest_cli_commands_coverage.py(owner-token flow, shared fake intest/spawn_cli_fakes.py).Manual verification
Observed the 409 from
kirocrew spawn run --asyncon a 0.8.0rc1 gateway.test_kirocrew_spawn_end_to_enddrives the real CLI code against a real unix site; a live gateway run with this build is still to do.Not built here:
cli_serverandpod/runtime_clientkeep their own mints; withagent.approval_mode: interactiveand no dashboard open, a mid-run tool prompt waits silently up to 2 h apart from the CLI's hint; the dashboard Spawn button keeps its empty-key governance; no prompt waiver for the CLI (#16313); no CLI spawn path on Windows (#16314); with the sandbox off, or on Windows, there is no agent/operator boundary for this path, as elsewhere in those modes.Related Issues
Part of #16480
No linked issue: the bug was reported on 0.8.0rc1. The earlier 0.8 backport, #15824, is merged.
Pattern harvest
Rule candidate: review-prompt
Pattern: a terminal command that acts for the owner should present the owner's credential, not ask the gateway to infer identity from the absence of one.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)subagent.md§ CLI states the rule;dashboard-token-auth.mddocuments the shared mint route and theorigin=clitoken;security.md,governance.md,taskq.md,learn-cron-dashboard.mdandslack-gateway.mdlink to it;code-style.mdlists the two newconstants.pynames; thekirocrew-commandsskill notes the commands are the owner's