Skip to content

feat(dashboard): name what keeps a slot attached in its 409 - #22272

Merged
iamwhatever merged 1 commit into
mainfrom
feat/22248-slot-409-names-attached
Oct 25, 2026
Merged

iamwhatever merged 1 commit into
mainfrom
feat/22248-slot-409-names-attached

Conversation

@cruisercohen

@cruisercohen cruisercohen commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: The slot_subagents_running 409 says which runs and task rows keep the slot attached, so a user whose slot keeps refusing can see what to stop.

Every guarded slot action (Continue, reload, agent, model, effort and workspace switches, reset conversation, edit-resend) answers 409 {"error": "sub-agents are running", "code": "slot_subagents_running"} while the session has children. The body names nothing. When the guard holds because of a row that will never finish (#17158: a stopped sub-agent parked in retry_wait), the user cannot tell which of the session's runs or rows is responsible, and kirocrew spawn has only run and list.

Why it matters

A slot that refuses forever with no name attached leaves the user guessing, or editing the task store by hand.

Not a goal

What changed (motivation → approach → change)

Gap: the refusal is built from a boolean, so it has nothing to name. Approach: after the verdict, read each of the three sources the predicate itself reads and put them in the body, reusing the reads that already exist.

  • dashboard/chat_api/slot_guards.py: _subagents_attached_response keeps error and code and adds the result of a new _subagents_attached_detail:
    • runs: the unfinished in-memory runs from running_agents_for (the summary the guard already reads), as {id, state} with state running or stalled; null when that probe could not answer, the case the guard fails closed on.
    • queued: the accepted spawns with no run yet, read through handlers.messaging._queued_runs (the helper GET /api/spawn?queued=1 already serves the listing with: task-store rows plus window entries with no row), as {id, state}.
    • queued_partial: that listing's own flag, true when it is capped or its read failed.
    • deliveries_inflight: the slot's _subagent_deliveries_inflight.
  • subagent_manager/admission/types.py / taskq_bridge_reads.py: QueuedRun gains state, the task-store state of the row it was read from (queued, retry_wait, recovering, admitted), empty for a window entry with no row (the 409 shows that as queued). GET /api/spawn builds its payload field by field, so its wire shape is unchanged.
  • dashboard/chat_api/continue_turn.py: Continue turned the guard's response into a SlotContinueRefusal(message, code) and rebuilt a two-field body, which dropped any extra field. SlotContinueRefusal now carries the guard's own response (response=), and the Continue endpoint returns it as is. Session-control's retry_target still reads only message, code and status.
  • Both 409 bodies stay dict literals with a literal code, the shape the error-code contract ratchet (test_error_code_contract.py) requires.
  • dashboard/chat_handlers.py imports _subagents_attached_detail beside the other slot_guards names: composed owner functions read the facade's globals, so _subagents_attached_response resolves it there.
  • dashboard/chat_utils_completion.py: the subagents_attached docstring says a new probe needs a field in _subagents_attached_detail too.
  • docs/system-specs/modules/session.md describes the body.

The body carries ids and states only: no task text, agent name or result. It is read after the verdict, so a run that ended in between is simply absent, and a read that raises costs its own field, never the 409.

Exposure: no route, listener or auth check changes. The fields go only to a caller that already passed the route's own auth and slot/app ownership checks, and they name only that slot's session's children.

Backwards compatibility

Compatible: error, code and the 409 status are unchanged, and the new fields are additions a client that reads only code (the dashboard, session-control) never sees.

Removes nothing: QueuedRun gains a defaulted field and SlotContinueRefusal a keyword-only response; no key, field, function or validator is removed or tightened.

Tests

Failing first on origin/main de80cdc (all six red), passing with the change (test/test_slot_subagents_running_detail.py):

  • test_the_409_names_each_unfinished_run_and_its_state: two running runs, one stalled, through POST /api/chat/slots/{slot}/continue; the body names both with their state, error and code are unchanged, and the runs' task text and agent name are not in the body.
  • test_the_409_names_each_queued_row_with_its_store_state: a retry_wait row and a window entry come back as retry_wait and queued, with the listing's partial flag.
  • test_the_409_counts_the_deliveries_still_in_flight: no runs, no rows, two deliveries in flight.
  • test_an_unanswered_probe_reads_as_unknown_and_still_refuses: a failed running probe gives runs: null, and a registry whose listing read fails gives queued_partial: true.
  • test_a_listing_that_raises_costs_its_field_not_the_refusal.
  • TestAgainstARealStore::test_a_parked_row_with_no_run_is_named_with_its_store_state: a real SubagentManager and task store; a row claimed, started and released to retry_wait with no registered run is named {"id": "parked0", "state": "retry_wait"}.

Run locally: every test file that names slot_subagents_running, _subagents_attached_response, SlotContinueRefusal, QueuedRun, queued_runs_async or the queued-run reads, plus the chat-handlers, chat-utils, handlers-messaging and subagent-parts composition contracts, the taskq bridge bindings, the store-off-loop glue suite and the Static Ratchet Gate's files (1795 passed). black, isort, flake8 and mypy on the touched files; the comment-history, brand, feature-map, harness-parity, memory-store-seam, loop-bound-locks, testpaths-coverage and docs-lint gates.

Manual verification

N/A: unit coverage sufficient. The endpoint tests drive the real Continue route through aiohttp's test server, and one test reads a real task store through the real registry.

Related Issues

Fixes #22248

Follow-up: #22357 (show these fields to the user in the dashboard and session-control).

Pattern harvest

Not generalizable: one refusal body gains the facts its own guard already reads.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

Contribution License Agreement

Contributed under the project's Apache-2.0 license.

@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Oct 19, 2026
@github-actions

github-actions Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision bda92200c0bfc54789e236778f2189abaf7fc91a touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Does not block merge.

@github-actions

github-actions Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of bda92200c0bfc54789e236778f2189abaf7fc91a and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] bda9220

False positive or not applicable? A repository writer can comment:
/ai-review override gpt bda92200c0bfc54789e236778f2189abaf7fc91a false-positive: <reason, 20 to 500 characters>

@github-actions

github-actions Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of bda92200c0bfc54789e236778f2189abaf7fc91a — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

Nothing blocks: the change only adds fields to the existing 409 body, read after the verdict, and each read fails on its own field without changing the refusal.

Notes

[DESIGN-REVIEWED] bda9220

Description read

[DESCRIPTION-READ] 18ea0904890ed8de82d9bb9689375bdda3da8781fb1b5c30b7f27b63390644de

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 .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of bda92200c0bfc54789e236778f2189abaf7fc91a — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

First-Principles-Verdict: PASS

Nothing blocks. The new 409 fields have no reader in the code yet, but the description says so and defers rendering to #22357. The fields are additive and easy to remove.

Notes

What this change ships

Inventory (8 items) — 7 justified

Intent: a user whose slot keeps refusing with "sub-agents are running" can see which run or row is holding it. This is an ADDITION (diagnostic detail on an existing refusal).

  1. The 409 lists each unfinished run as running or stalled, or null if the check failed — zero consumers (in code, until Show what keeps a slot attached when a guarded action is refused (dashboard and session-control) #22357)
  2. The 409 lists each queued spawn with its task-store state (e.g. retry_wait) — justified
  3. The 409 flags when the queued list is capped or could not be read — justified
  4. The 409 reports how many results are still being delivered to the slot — justified
  5. Continue's 409 now carries the guard's full body instead of a rebuilt two-field one — justified
  6. A queued-run record now carries its task-store state; the GET /api/spawn wire shape is unchanged — justified
  7. SlotContinueRefusal accepts a keyword-only response — justified
  8. The session spec and the subagents_attached docstring describe the new body — justified

[FIRST-PRINCIPLES-REVIEWED] bda9220

Description read

[DESCRIPTION-READ] 303b6df6dbabcc501836b7cf7b68ff6ba8f64a0b16d9fc4d79962a0190a01c4e

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed bda92200c0bfc54789e236778f2189abaf7fc91a — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] bda9220

Verdict parsed from the review's SHA-scoped output markers for commit bda92200c0bfc54789e236778f2189abaf7fc91a.

False positive or not applicable? A repository writer can comment:
/ai-review override fable bda92200c0bfc54789e236778f2189abaf7fc91a false-positive: <reason, 20 to 500 characters>

@cruisercohen
cruisercohen force-pushed the feat/22248-slot-409-names-attached branch from b3fc518 to 69a9433 Compare October 19, 2026 20:01
@cruisercohen

Copy link
Copy Markdown
Contributor Author

Dispositions for the advisory findings on b3fc518; addressed in 69a9433 (the branch is squashed to one commit, per the two-commit gate).

First Principles, item 3 (the queued read duplicated messaging_api/run_control._queued_runs): fixed. _subagents_attached_detail now reads the queued list through that helper, imported from its facade kiro_crew.dashboard.handlers.messaging, so the 409 and GET /api/spawn?queued=1 share one read and one rule (a failed read is a partial listing). The "registry has none" branch is gone.

First Principles, item 6 (the chat_handlers re-export has no consumer): kept, because it is the binding the guard runs on. _facade_compose.compose runs every chat_api owner function on the facade globals, so _subagents_attached_response resolves _subagents_attached_detail in chat_handlers. With the import line removed, test_slot_subagents_running_detail.py fails with NameError: name _subagents_attached_detail is not defined.

Design Review (a fourth source added to the predicate would refuse while naming nothing): the subagents_attached docstring in chat_utils_completion.py now says a new probe needs a field in _subagents_attached_detail, and that function names the rule too.

@cruisercohen

Copy link
Copy Markdown
Contributor Author

Dispositions for the advisory notes on 69a9433 (Design PASS, First Principles CONCERNS):

First Principles, item 1 (no in-repo reader of the new fields): not changed. #22248 asks for exactly this body ("Done when: the 409 body carries these beside the existing error and code fields"), for the callers that read the raw 409 today: scripts and agents driving the chat-slot routes, and a user reading the response in the browser. Rendering the fields in the dashboard is this PR stated non-goal; it is a UI choice for a separate change, and the fields it would read are now there.

First Principles, item 2 (kirocrew spawn list already lists queued rows): not changed. That listing answers "what is queued for this parent" once the user knows the session key and thinks to ask. The 409 answers "why was this action refused", at the moment of refusal, for the session it refused on, and it also names what the listing does not: the unfinished runs with their stalled state and the deliveries still in flight. Both read the same helper (_queued_runs), so they cannot disagree about the queued half.

Design Review (a stopped retry_wait row is named but stays stuck until #22252 lands): agreed, and intended. This PR makes the row visible; #22252 (for #22244) settles it at boot. The two are independent and either can land first.

@cruisercohen
cruisercohen marked this pull request as ready for review October 19, 2026 20:56
@cruisercohen
cruisercohen requested review from a team and KiroCrewCaptain as code owners October 19, 2026 20:56
@cruisercohen
cruisercohen requested a review from buluoray October 19, 2026 20:56
@cruisercohen
cruisercohen enabled auto-merge (squash) October 19, 2026 20:56
@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Oct 19, 2026

@iamwhatever iamwhatever left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

REQUEST_CHANGES (tracking issue needed) at 69a9433.

The change is safe. The detail is read only after the unchanged verdict (slot_guards.py L62). It carries ids and states only. A failing read degrades its own field, because _queued_runs already returns a partial listing on error. Continue passes the guard's response through unchanged. CI is green, and the AI items have reasoned replies.

One deferred item has no issue. The Goal says a user whose slot keeps refusing can see what to stop, but nothing in the product shows the new fields: the dashboard only checks the code string (useSessionActions.ts L391), and session-control maps the refusal to target_busy. Your reply calls rendering them "a UI choice for a separate change", but I found no open issue for it. Please open one for showing these fields to the user, and link it in the PR description.

— crew-pr-reviewer (r113)

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: passed Eligible automated validation passed for the current revision labels Oct 20, 2026
@cruisercohen

Copy link
Copy Markdown
Contributor Author

Thanks. Opened #22357 for showing the new 409 fields to the user: in the dashboard (the session reload error handler in useSessionActions.ts checks only the code) and in session-control (which maps the refusal to target_busy). It is linked in the description, under "Not a goal" and "Related Issues". No code change; the head is still 69a9433.

@iamwhatever
iamwhatever force-pushed the feat/22248-slot-409-names-attached branch from 69a9433 to bda9220 Compare October 25, 2026 02:58
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Oct 25, 2026

@iamwhatever iamwhatever left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

APPROVE at bda9220.

The r113 item is cleared: showing the new fields to the user is tracked in #22357, which covers both the dashboard handler and session-control, and it is linked in the description. This head is a rebase of 69a9433 with an identical patch.

The change is safe. The detail is read only after the unchanged verdict (slot_guards.py L61-L75), carries ids and states only, and a failing queued read becomes a partial listing (run_control.py L81-L96). Continue passes the guard's response through unchanged. Every AI lane on this head is clean or answered, and all checks are green.

— crew-pr-reviewer (r125)

@iamwhatever
iamwhatever merged commit bab8df2 into main Oct 25, 2026
106 checks passed
@iamwhatever
iamwhatever deleted the feat/22248-slot-409-names-attached branch October 25, 2026 07:40
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Oct 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

slot_subagents_running 409: name what keeps the slot attached

2 participants