Repository navigation
fix(dashboard): answer a spawn stopped before its claim as stopped, not spawned - #24763
Conversation
UX Review (Opus 5.5) — ⏭️ skippedRevision |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS The fix is at mechanism level and has a linked issue. Nothing in the inventory lacks a named harm. The root cause sits upstream in the placeholder itself, which the Goal deliberately leaves untouched. Notes
What this change shipsInventory (7 items) — 5 justifiedIntent: callers are never told that a run stopped before it started was started. FIX.
[FIRST-PRINCIPLES-REVIEWED] b240dcf Description read[DESCRIPTION-READ] 66b321b255645a36aade877f599407eea8bab4967f822f60d3ad60488342522a 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: |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: one record predicate, read by all five start sites, matching how the existing typed rejections answer. Notes
[DESIGN-REVIEWED] b240dcf Description read[DESCRIPTION-READ] 507dd0b5f194a9358614a53ccc5b4b143537ba20aedbf561a3cb6969cca03135 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 — ✅ 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: |
1938f99 to
23eb632
Compare
|
Replies to the non-blocking notes on
The red backend shard 2 (Linux and Windows) comes from |
23eb632 to
b240dcf
Compare
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
Tier 1 auto-approve: fix (10 files). Criteria: no conflict, no requested changes, security path denylist clean, design-doc gate clean, security checklist all-NO, no reviewer-lane findings, readiness signal fresh for this head SHA, declared category matches the diff. Category: answers a spawn stopped before its claim with a coded 409 or a SpawnError instead of 'spawned', on every surface that starts a run; with tests. Spec files changed as a ride-along (a minority of the diff on both file count and changed lines), not reviewed as a design decision: docs/system-specs/modules/subagent.md.
Problem / Motivation
Goal: A run that was stopped before it started is never reported as started.
SubagentManager.spawn/spawn_asynccan accept a row and then have its claim refused, because the run was stopped while it waited (CLAIM_REFUSED). The manager then returns a terminal placeholder:queued=True, done=True, user_stopped=True, with an emptyerror. Every surface that starts a run tests only fordonewith anerror, so that placeholder fell through to its success answer.Why it matters
The caller is told a run started, under an id that never produces a card or a completion event. A person,
spawn_run, a channel user or an app waits on, or retries, something that already ended.Not a goal
SubagentManager._settle_continuation(see Sibling sweep).Intended? / Repro
Intended? No. Nothing in the spec says a refused claim should read as started.
docs/system-specs/modules/subagent.md(theCLAIM_REFUSEDbullet) says spawn "returns aqueued+done+user_stoppedinfo without registering and the drain takes the next row", so nothing will run. The "Typed rejections" section of the same file gives every other non-start a typedcode. No test pins a started answer for this placeholder.Repro (code read on current main):
src/kiro_crew/subagent_manager/admission/gate.py:1408-1423:if not proceed:returnsSubagentInfo(..., queued=True, done=True, user_stopped=True)with noerror.src/kiro_crew/subagent_manager/admission/taskq_bridge_accept.py:343:_replace(point.queued, done=True, user_stopped=True), the same shape.dashboard/messaging_api/spawn.pyapi_spawn:if info.done and info.error:is false for that info, so the route answers{"id": ..., "status": "spawned"}.dashboard/messaging_api/spawn.pyapi_spawn_continue: the same check, thenstatus: "spawned".dashboard/messaging_api/run_control.py_retry_failed_run: the same check, thensettle_retry(old, info.id)andstatus: "spawned". That also records the dead id as the failed run's successor, so a second retry is refusedretry_superseded.messaging/commands.pyspawn_task_reply(the channelspawncommand): the same check, then a "Spawned" reply.apps/spawn_sdk.pybuild_spawn_impl: tests onlyerror, then returns the dead id to the app.Input: any of those starts while the manager returns the placeholder. Seen: a started answer (HTTP 200
spawned, a "Spawned" reply, or an id) for a run that never starts.What changed (motivation → approach → change)
Symptom: a stopped-before-start row is reported as started. Cause: each surface checks only for
donewith anerror. Change: one test for the record, read by every surface that starts a run.subagent_wait_reasons.py(the leaf module the channel command layer already reads):stopped_before_start(info). It is True only whenqueued,doneanduser_stoppedare allTrueanderroris empty.queuedis part of it: a registered run stopped during its start's last await isdoneanduser_stoppedbut notqueued, and it ran, so it keeps its id.dashboard/messaging_api/spawn.py:STOPPED_BEFORE_START_CODE = "stopped_before_start"and_stopped_before_start(info, *, counted=False), a409with thatcodewhen the test holds.api_spawncalls it withcounted=Trueafter the typed-rejection branch, becausespawn()already counted the submission (the same reason the 400 and 429 answers carry it), sospawn_rundoes not reconcile it as lost.api_spawn_continuecalls it after its typed-failure branch.dashboard/messaging_api/run_control.py_retry_failed_runcalls it beforesettle_retry(old, info.id). The claim stays pending and the route's existingfinallyreleases it (settle_retry(old, None)), so the failed run stays retryable.messaging/commands.pyspawn_task_reply: replies "Subagent<id>was stopped before it started; nothing ran." instead of announcing a start.apps/spawn_sdk.pybuild_spawn_impl: raisesSpawnError(not a host decline) instead of returning the id.dashboard/handlers/messaging.py: binds the new names on the facade the composed owners run on.docs/system-specs/modules/subagent.md: a "Stopped before it started" paragraph under Typed rejections.Backwards compatibility
Compatible: only the refused-claim placeholder, which was reported as a started run that never existed, now gets a not-started answer. Every other answer is unchanged.
spawn_runalready treats anerrorbody as a refusal and readscountedto skip the lost-submission reconcile; an app already handlesSpawnErrorfromspawn.run.Removes nothing: no key, field, route or function is removed; the change only gives a no-run answer its own typed answer.
Tests
test/test_handlers_messaging_coverage.py:TestApiSpawn::test_a_row_stopped_before_its_claim_is_not_answered_spawned:409,code == "stopped_before_start",counted is True, nostatus.TestApiSpawn::test_a_run_stopped_after_it_started_keeps_its_spawned_answer:done+user_stoppedwithoutqueuedstill answers200with its id.TestApiSpawnContinue::test_a_continuation_stopped_before_its_claim_is_not_answered_spawned:409with the code.TestApiSpawnRetry::test_a_retry_stopped_before_its_claim_releases_the_claim:409with the code, and the claim is released (settle_retry(old, None)only), not settled with the dead id.test/test_messaging_commands.py::...::test_a_spawn_stopped_before_it_started_is_not_announced: the exact not-started reply.test/test_app_spawn_capability.py::TestSpawnSDK::test_a_spawn_stopped_before_it_started_raises:SpawnError,declined is False.On main the four stopped-before-start tests get a started answer (
200 spawned, the "Spawned" reply, or the id).Proof: not provable -- other: this host runs no local tests; CI runs the new tests
Manual verification
N/A: unit coverage is enough. The change is one pure check on the record the manager returns, read at five start sites.
Static gates run locally on the changed files: black, isort, flake8,
scripts/check_file_line_cap.py,scripts/docs_lint.py, and the error-code ratchet scan (no newopaque_bodyormissing_code). mypy and the test suite run in CI.Related Issues
Fixes #15821
Sibling sweep
Swept: git grep -nE ".done and [a-z_]+.error" -- src/ ; git grep -nE "spawn_async|.spawn(" -- src/kiro_crew/messaging src/kiro_crew/apps
Sibling: src/kiro_crew/dashboard/messaging_api/spawn.py -- changed here (api_spawn and api_spawn_continue)
Sibling: src/kiro_crew/dashboard/messaging_api/run_control.py -- changed here (_retry_failed_run)
Sibling: src/kiro_crew/messaging/commands.py -- changed here (spawn_task_reply)
Sibling: src/kiro_crew/apps/spawn_sdk.py -- changed here (build_spawn_impl)
Sibling: src/kiro_crew/subagent_parts/continuation_surface.py:156 -- not affected -- it records which start took the conversation, not an answer to a caller
Pattern harvest
Rule candidate: review-prompt
Pattern: a start site that tests only
done and errorreads a terminal no-error placeholder as success.Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
Contributed under the project's Apache-2.0 license.