Skip to content

fix(subagent): publish queued depth 0 after the last row is popped - #14878

Merged
iamwhatever merged 1 commit into
mainfrom
fix/queued-depth-popped-row
Sep 29, 2026
Merged

iamwhatever merged 1 commit into
mainfrom
fix/queued-depth-popped-row

Conversation

@chenmingwei23

@chenmingwei23 chenmingwei23 commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: The subagent progress bar clears its "waiting to start" count when the last queued subagent actually starts, so a finished wave no longer shows a phantom waiting agent.

After a turn that spawned a wave of subagents finishes, the subagent progress bar keeps showing "1 waiting to start - queued behind the concurrency limit" with 0 running and every card Complete. The spinner and the Stop all button stay until the page is reloaded. The Subagents panel shows the same phantom "1 waiting to start" row above the completed cards.

Why it matters

The bar says work is still pending when nothing is. A user watching a spawn_run wave cannot tell a finished turn from one with a stuck subagent, and the only way to clear it is a page reload.

Not a goal

  • Changing how the frontend reducer clears the count (it correctly clears on queued: 0; the backend never sent it).
  • Re-emitting the depth on reconnect or on a timer as a safety net.
  • Any change to admission, stagger, or capacity decisions; the pump picks and starts exactly the same rows.

What changed (motivation → approach → change)

Symptom to root cause:

  1. The frontend reducer sseSubagentQueued removes the waiting count only when it receives a subagent_queued event with queued: 0.
  2. The backend publishes that depth from _emit_queue_depth: rows in the in-memory window plus store.count_pending(...) for the parent, minus taskq_excluded_ids() (window rows, registered runs, rows still in spawn_async admission).
  3. The pump pops a row from the window and re-emits the depth before spawn claims it. Between pop and claim that row is still QUEUED in the durable store and is in none of the exclusion sets, so the store count includes it. Every emit in that window reads one higher than the window: a 5-spawn / cap-4 wave publishes 4, 3, 2, 1 and never 0.
  4. Once the claim lands nothing re-emits the depth for that parent, so the last value the client holds is 1.

The change gives the pump its own exclusion set. SubagentManager._dispatching_ids holds the id of a row for exactly one dispatch attempt: set when the pump pops it, cleared the moment spawn answers, whatever the answer is (started, re-queued, parked, refused, claim unavailable, or raised). A separate taskq_dispatch_excluded_ids() (the ownership set plus _dispatching_ids) is what the pump's own reads use: the window refill, and the depth the chip shows (taskq_overflow(..., for_dispatch=True)). Cancellation and every pending-work read (has_pending_work_for, queued_count_for, the reset-deferral guards) keep the unchanged taskq_excluded_ids(), so a parent's Stop still reaches a row in exactly this popped-unclaimed state, and a cron teardown still sees it as the parent's unfinished work. The emit right after the pop, and any refill or overflow read in the meantime, leave the popped row out, so the final emit reads 0. When the attempt does not take the row, the mark is dropped before that path's own depth emit, so a row that is still QUEUED is counted again immediately; a mark cannot outlive its pass (a finally on both pump paths and on the pass itself), so no durable row is ever hidden from refill.

Files: src/kiro_crew/subagent.py (the set), src/kiro_crew/subagent_manager/admission/pump.py (mark on pop, clear on every attempt exit), src/kiro_crew/subagent_manager/admission/gate.py (clear before the failed-claim emit), src/kiro_crew/subagent_manager/admission/taskq_bridge.py (the dispatch-only exclusion set; refill uses it, taskq_overflow* only under for_dispatch=True), src/kiro_crew/subagent_manager/run.py (only the depth emit asks for the dispatch reading).

Backwards compatibility

Compatible: no schema, event shape, or public method changes; the subagent_queued event carries the same fields with a corrected count.

Tests

  • New test/test_subagent_scale.py::TestQueuedDepthReachesZero::test_last_pop_publishes_zero_with_a_store_attached: a real SubagentManager with the durable store, cap 4, 5 spawns for one parent, _run patched to release its slot and drain. Asserts the recorded subagent_queued depths end at 0 and stay 0. Fails on origin/main with depth sequence never reached 0 and passes with the fix.
  • New test_dispatching_rows_are_excluded_from_dispatch_reads_only: a marked id is in taskq_dispatch_excluded_ids() and not in taskq_excluded_ids().
  • New test_a_popped_but_unclaimed_row_still_counts_as_pending_work: with the pump parked between pop and claim, has_pending_work_for_async is True and queued_count_for is 1 while the chip's depth is 0. Making taskq_overflow default to the dispatch set turns it red.
  • New test_a_raise_before_the_pick_is_logged_not_rethrown: a store error in the awaits ahead of the pick is logged by the pass's handler and the pass returns; the mark cleanup walks an empty pick. Moving the picked binding back inside the try turns it red with UnboundLocalError.
  • New test_stop_all_reaches_a_popped_but_unclaimed_row: the pump is parked between pop and claim (its off-loop policy read held) when cancel_for_parent runs; the store sweep stops the row and it never starts. Pointing the sweep at the dispatch set turns it red.
  • New test_an_unavailable_claim_publishes_the_row_as_waiting: the store's claim raises TaskStoreUnavailable for the popped row; the depth published by that path is 1 and no mark remains. Removing the gate-side discard turns it red.
  • New test_a_dispatch_that_raises_leaves_no_mark: spawn raises while dispatching the popped row; no mark remains and the row is not in taskq_excluded_ids(). Removing the finally on the inline pump turns it red.
  • test/test_queue_depth_after_deferred_start.py (the memory-deferral re-queue path) passes.
  • pid-reader ratchet, sizing, scale, deferred-start, startup-pressure, admission-gate, stop-kill-cancel files: 334 passed.

Manual verification

A standalone probe of the same shape (cap 4, 5 spawns, scratch KIROCREW_HOME) on both pump paths (off-loop and on-loop) publishes ... 1, 0 with the fix and ... 1 without. mypy clean on the two admission modules; comment-history gate passes.

Related Issues

Closes #14877

Pattern harvest

Rule candidate: review-prompt
Pattern: a count derived from a durable store must exclude every in-flight state the in-memory owner already accounts for; adding a new in-flight phase (popped-but-unclaimed) without adding it to the exclusion set silently double-counts.

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

@chenmingwei23
chenmingwei23 requested a review from a team as a code owner September 29, 2026 00:16
@chenmingwei23
chenmingwei23 force-pushed the fix/queued-depth-popped-row branch from e0a10e1 to b07956e Compare September 29, 2026 00:35
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Sep 29, 2026
@github-actions

github-actions Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

GPT 5.6 Review — ✅ no blocking findings

GPT 5.6 completed its review of 409aba3f25ae653831280494fb6d87f18c9e129b and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 409aba3

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 409aba3f25ae653831280494fb6d87f18c9e129b: <one-sentence reason>

@github-actions

github-actions Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Fable 5) — ✅ PASS

Design-level review of 409aba3f25ae653831280494fb6d87f18c9e129b — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

Design-Verdict: PASS

Verify fairness.py's store reads (lines 253/284/383/400) intentionally keep taskq_excluded_ids — the description's split names cancellation and pending-work reads, not lane-fairness counts.

[DESIGN-REVIEWED] 409aba3

Description read

[DESCRIPTION-READ] cc875115f5225ab47b696be5e854d2d8710020e42b4a304dce378b4532603c41

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 Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Fable 5) — 🟡 CONCERNS

Premise-level review of 409aba3f25ae653831280494fb6d87f18c9e129b — 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/CONCERNS are advisory.

First-Principles-Verdict: CONCERNS

taskq_overflow_async gains a for_dispatch parameter no caller ever passes — symmetry with its sync twin, not a consumer.

Not justified as shipped

  • Item 6 — zero consumers: for_dispatch on taskq_overflow_async (taskq_bridge.py:927) mirrors the sync method, but its only caller, _queued_depth_async_impl (run.py:829), never passes it — grep taskq_overflow_async counts 1 caller, 0 passing the flag; the off-loop emit path uses taskq_dispatch_excluded_ids() directly, and the async depth serves the pending-work reads that by the PR's own design must keep the full set.
    Subtraction: delete the for_dispatch parameter and its exclude branch from taskq_overflow_async only; the sync variant keeps it.
    Clears when: the parameter is removed, or a caller passing for_dispatch=True exists.

What this change ships

Inventory (7 items) — 6 justified

Intent: FIX — clear the phantom "1 waiting to start" the progress bar keeps after a subagent wave finishes (issue #14877; test fails on base).

  1. The waiting count now reaches 0 when the last queued subagent starts — justified
  2. Manager remembers rows popped but not yet claimed (_dispatching_ids) — justified
  3. A dispatch-only exclusion set (taskq_dispatch_excluded_ids) for the pump's own reads — justified
  4. Window refill no longer re-hydrates a row mid-dispatch — justified
  5. Sync depth reads can ask for the chip's reading (for_dispatch=True) — justified
  6. Async overflow read grew the same flag with no caller — zero consumers, symmetry with the sync twin
  7. A store error before the pick is logged, not an UnboundLocalError — justified

Stop/cancel and pending-work reads deliberately still count a popped-unclaimed row; not a change.

[FIRST-PRINCIPLES-REVIEWED] 409aba3

Description read

[DESCRIPTION-READ] fcde27fbe19242605e131262f728be6e48f7a7ee57eea980b79ce223fd7dc70d

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 Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5 Review — ✅ no blocking findings

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

Review details

Advisory only: no blocking defect — every leak/double-dispatch candidate died (the emit's store errors are all converted to TaskStoreUnavailable and caught, and the pump serializes passes through one _drain_task, so no second refill can re-hydrate an unmarked row).

FINDING — src/kiro_crew/subagent_manager/admission/taskq_bridge.py:1282 — the refill now excludes taskq_dispatch_excluded_ids() (window + live + admitting + _dispatching_ids), so a row with no live run is excluded too, while the owning specs still state the refill excludes only rows "with a live run in this process (taskq_excluded_ids)" (docs/system-specs/modules/taskq.md:1038, :628, docs/system-specs/modules/subagent.md:1522) and the new two-set split (Stop / pending-work reads keep the plain set, chip depth and refill take the dispatch set) is recorded nowhere → Fix: in this commit, amend those three passages to name taskq_dispatch_excluded_ids, the mark's one-attempt lifecycle, and which reads deliberately keep counting a popped-unclaimed row.

[OPUS-REVIEWED] 409aba3

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

False positive or not applicable? A repository writer can comment:
/ai-review override fable 409aba3f25ae653831280494fb6d87f18c9e129b: <one-sentence reason>

@chenmingwei23
chenmingwei23 force-pushed the fix/queued-depth-popped-row branch from b07956e to 41c5383 Compare September 29, 2026 01:08
@chenmingwei23

Copy link
Copy Markdown
Contributor Author

Round 2, head 41c5383 (rebased onto main at 9932337).

The two Windows shard reds on b07956e were: (1) the pid-reader ratchet, inherited from a base that predates #14883's repin; the rebase clears it. (2) test_queue_depth_after_deferred_start.py, a real interaction with this change: when the pump pops a memory-deferred row and the gate re-defers it, the deferral's depth emit ran while the row was still marked dispatching and read 0 instead of 1. The mark is now cleared as soon as spawn answers with anything but a claim, before finish_parked_defer publishes. Both depth tests pass 5/5 locally under a scratch home; ratchet, sizing, scale, startup-pressure and deferred-start files: 259 passed.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Sep 29, 2026
@chenmingwei23
chenmingwei23 force-pushed the fix/queued-depth-popped-row branch from 41c5383 to 91d7c25 Compare September 29, 2026 01:33
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Sep 29, 2026
@chenmingwei23
chenmingwei23 force-pushed the fix/queued-depth-popped-row branch from 91d7c25 to b059a22 Compare September 29, 2026 02:54
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Sep 29, 2026
@chenmingwei23
chenmingwei23 force-pushed the fix/queued-depth-popped-row branch from b059a22 to eccd969 Compare September 29, 2026 03:10
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Sep 29, 2026
The pump emits the parent's queued depth right after popping a row from
the window. With a durable store attached that row is still QUEUED until
its claim lands and is in none of the count's exclusion sets, so every
depth read between pop and claim counts it once more than the window
does: a 4-cap, 5-spawn wave publishes 4, 3, 2, 1 and never 0. The
dashboard chip clears its waiting count only on 0, so it keeps showing
one agent waiting under a finished turn.

Mark a popped row as dispatching until spawn has answered for it, and
exclude dispatching rows from the store-backed pending count.
@chenmingwei23
chenmingwei23 force-pushed the fix/queued-depth-popped-row branch from eccd969 to 409aba3 Compare September 29, 2026 03:50
@github-actions github-actions Bot removed the readiness: action required A blocking check or review needs attention label Sep 29, 2026
@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: checking Automated validation is still running labels Sep 29, 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.

Reviewed. The popped row is marked in _dispatching_ids before the depth emit, and the mark is cleared on every exit path (not-a-claim branch, non-registering claim, gate deferred emit, per-dispatch finally, pass-level finally), so a durable row cannot be hidden from refill. taskq_excluded_ids() is unchanged, so cancel and the counters still see the popped row. Moving picked/granting above the try also fixes a latent UnboundLocalError. Tests name a mutation each.

Non-blocking: test_last_pop_publishes_zero_with_a_store_attached polls with a 15s deadline plus fixed settle sleeps and may be slow-shard sensitive.

@iamwhatever
iamwhatever enabled auto-merge (squash) September 29, 2026 06:32
@iamwhatever
iamwhatever merged commit 0f785ef into main Sep 29, 2026
97 checks passed
@iamwhatever
iamwhatever deleted the fix/queued-depth-popped-row branch September 29, 2026 06:32
bolichen97 added a commit that referenced this pull request Oct 4, 2026
Four main fixes for what users on 0.8 hit with parallel subagents:

- #14878: a wave's "N waiting to start" count ends at "1 waiting" under
  a finished turn, because a popped but unclaimed row was counted once
  more than the window holds. A popped row is now marked dispatching
  and left out of the count, so the last pop publishes 0.
- #16191: the count is re-published after every terminal, Stop all and
  stage Cancel, coalesced per parent; a failed store read publishes
  nothing instead of a false 0; a resident resume entry and a deferred
  spawn_async row are counted correctly; the pump's idle wake no longer
  spins (carries Matt Cohen's #15376 commit).
- #15022: a subagent inside the wait tool is not reaped as stalled
  before its declared duration.
- #16012: a spawn the memory gate deferred exists only as a task-store
  row, so spawn_status answered 404, spawn_list left it out and
  spawn_sub_agents reported it as an error, which made the model
  dispatch the work again. These ids now answer as queued, and the
  sub-agent synthesis waits while a sibling is still queued.

Backport to release/0.8.0. #14878 and #15022 apply cleanly. #16012 is
applied before #16191, its order on main, because #16191 was built on
it. #16012's conflicts are resolved against 0.8 code:
- api_spawn_list has no persisted half and no per-row audit on 0.8, so
  the queued half is listed beside the live half only.
- The persistence fallback of GET /api/spawn/{id} keeps 0.8's shape (a
  run folder reads done); the "no recorded ending is not done" change
  needs main's ending classifier and is left out.
- The Slack gateway and chat runner keep 0.8's orchestrator mode, so
  the synthesis arm stays chat-mode only.
The tests that read main-only APIs are adapted to those shapes, and
test/conftest.py gains main's close_subagent_managers fixture, which
the new tests request. The subagent spec drops the sentences that
describe the main-only fallback and audit.

Backports the fixes for #14877, #15131, #15011 and #15045.

Co-authored-by: Raymond Chen <45910466+chenmingwei23@users.noreply.github.com>
Co-authored-by: Will Laws <will.laws@me.com>
Co-authored-by: Matt Cohen <mattcohe@amazon.com>
(cherry picked from commit 0f785ef)
(cherry picked from commit 4bb1d11)
(cherry picked from commit 6d99710)
(cherry picked from commit c759e04)
bolichen97 added a commit that referenced this pull request Oct 4, 2026
Four main fixes for what users on 0.8 hit with parallel subagents:

- #14878: a wave's "N waiting to start" count ends at "1 waiting" under
  a finished turn, because a popped but unclaimed row was counted once
  more than the window holds. A popped row is now marked dispatching
  and left out of the count, so the last pop publishes 0.
- #16191: the count is re-published after every terminal, Stop all and
  stage Cancel, coalesced per parent; a failed store read publishes
  nothing instead of a false 0; a resident resume entry and a deferred
  spawn_async row are counted correctly; the pump's idle wake no longer
  spins (carries Matt Cohen's #15376 commit).
- #15022: a subagent inside the wait tool is not reaped as stalled
  before its declared duration.
- #16012: a spawn the memory gate deferred exists only as a task-store
  row, so spawn_status answered 404, spawn_list left it out and
  spawn_sub_agents reported it as an error, which made the model
  dispatch the work again. These ids now answer as queued, and the
  sub-agent synthesis waits while a sibling is still queued.

Backport to release/0.8.0. #14878 and #15022 apply cleanly. #16012 is
applied before #16191, its order on main, because #16191 was built on
it. #16012's conflicts are resolved against 0.8 code:
- api_spawn_list has no persisted half and no per-row audit on 0.8, so
  the queued half is listed beside the live half only.
- The persistence fallback of GET /api/spawn/{id} keeps 0.8's shape (a
  run folder reads done); the "no recorded ending is not done" change
  needs main's ending classifier and is left out.
- The Slack gateway and chat runner keep 0.8's orchestrator mode, so
  the synthesis arm stays chat-mode only.
The tests that read main-only APIs are adapted to those shapes, and
test/conftest.py gains main's close_subagent_managers fixture, which
the new tests request. The subagent spec drops the sentences that
describe the main-only fallback and audit.

The rebase onto #16567 keeps main's memory_pressure entry in
QUEUED_KIND_TEXT, so a later read of a row the pressure hold keeps
still names the pressure instead of "waiting to start". The main
handle's trusted wait identity (#15022) gains a behavioural pin: an
identity that is not provenance-verified must not name kirocrew-core
on the dispatch snapshot.

Backports the fixes for #14877, #15131, #15011 and #15045.

Co-authored-by: Raymond Chen <45910466+chenmingwei23@users.noreply.github.com>
Co-authored-by: Will Laws <will.laws@me.com>
Co-authored-by: Matt Cohen <mattcohe@amazon.com>
(cherry picked from commit 0f785ef)
(cherry picked from commit 4bb1d11)
(cherry picked from commit 6d99710)
(cherry picked from commit c759e04)
bolichen97 added a commit that referenced this pull request Oct 4, 2026
Four main fixes for what users on 0.8 hit with parallel subagents:

- #14878: a wave's "N waiting to start" count ends at "1 waiting" under
  a finished turn, because a popped but unclaimed row was counted once
  more than the window holds. A popped row is now marked dispatching
  and left out of the count, so the last pop publishes 0.
- #16191: the count is re-published after every terminal, Stop all and
  stage Cancel, coalesced per parent; a failed store read publishes
  nothing instead of a false 0; a resident resume entry and a deferred
  spawn_async row are counted correctly; the pump's idle wake no longer
  spins (carries Matt Cohen's #15376 commit).
- #15022: a subagent inside the wait tool is not reaped as stalled
  before its declared duration.
- #16012: a spawn the memory gate deferred exists only as a task-store
  row, so spawn_status answered 404, spawn_list left it out and
  spawn_sub_agents reported it as an error, which made the model
  dispatch the work again. These ids now answer as queued, and the
  sub-agent synthesis waits while a sibling is still queued.

Backport to release/0.8.0. #14878 and #15022 apply cleanly. #16012 is
applied before #16191, its order on main, because #16191 was built on
it. #16012's conflicts are resolved against 0.8 code:
- api_spawn_list has no persisted half and no per-row audit on 0.8, so
  the queued half is listed beside the live half only.
- The persistence fallback of GET /api/spawn/{id} keeps 0.8's shape (a
  run folder reads done); the "no recorded ending is not done" change
  needs main's ending classifier and is left out.
- The Slack gateway and chat runner keep 0.8's orchestrator mode, so
  the synthesis arm stays chat-mode only.
The tests that read main-only APIs are adapted to those shapes, and
test/conftest.py gains main's close_subagent_managers fixture, which
the new tests request. The subagent spec drops the sentences that
describe the main-only fallback and audit.

The rebase onto #16567 keeps main's memory_pressure entry in
QUEUED_KIND_TEXT, so a later read of a row the pressure hold keeps
still names the pressure instead of "waiting to start". The main
handle's trusted wait identity (#15022) gains a behavioural pin: an
identity that is not provenance-verified must not name kirocrew-core
on the dispatch snapshot.

Backports the fixes for #14877, #15131, #15011 and #15045.

Co-authored-by: Raymond Chen <45910466+chenmingwei23@users.noreply.github.com>
Co-authored-by: Will Laws <will.laws@me.com>
Co-authored-by: Matt Cohen <mattcohe@amazon.com>
(cherry picked from commit 0f785ef)
(cherry picked from commit 4bb1d11)
(cherry picked from commit 6d99710)
(cherry picked from commit c759e04)
bolichen97 added a commit that referenced this pull request Oct 5, 2026
Four main fixes for what users on 0.8 hit with parallel subagents:

- #14878: a wave's "N waiting to start" count ends at "1 waiting" under
  a finished turn, because a popped but unclaimed row was counted once
  more than the window holds. A popped row is now marked dispatching
  and left out of the count, so the last pop publishes 0.
- #16191: the count is re-published after every terminal, Stop all and
  stage Cancel, coalesced per parent; a failed store read publishes
  nothing instead of a false 0; a resident resume entry and a deferred
  spawn_async row are counted correctly; the pump's idle wake no longer
  spins (carries Matt Cohen's #15376 commit).
- #15022: a subagent inside the wait tool is not reaped as stalled
  before its declared duration.
- #16012: a spawn the memory gate deferred exists only as a task-store
  row, so spawn_status answered 404, spawn_list left it out and
  spawn_sub_agents reported it as an error, which made the model
  dispatch the work again. These ids now answer as queued, and the
  sub-agent synthesis waits while a sibling is still queued.

Backport to release/0.8.0. #14878 and #15022 apply cleanly. #16012 is
applied before #16191, its order on main, because #16191 was built on
it. #16012's conflicts are resolved against 0.8 code:
- api_spawn_list has no persisted half and no per-row audit on 0.8, so
  the queued half is listed beside the live half only.
- The persistence fallback of GET /api/spawn/{id} keeps 0.8's shape (a
  run folder reads done); the "no recorded ending is not done" change
  needs main's ending classifier and is left out.
- The Slack gateway and chat runner keep 0.8's orchestrator mode, so
  the synthesis arm stays chat-mode only.
The tests that read main-only APIs are adapted to those shapes, and
test/conftest.py gains main's close_subagent_managers fixture, which
the new tests request. The subagent spec drops the sentences that
describe the main-only fallback and audit.

The rebase onto #16567 keeps main's memory_pressure entry in
QUEUED_KIND_TEXT, so a later read of a row the pressure hold keeps
still names the pressure instead of "waiting to start". The main
handle's trusted wait identity (#15022) gains a behavioural pin: an
identity that is not provenance-verified must not name kirocrew-core
on the dispatch snapshot.

Backports the fixes for #14877, #15131, #15011 and #15045.

Co-authored-by: Raymond Chen <45910466+chenmingwei23@users.noreply.github.com>
Co-authored-by: Will Laws <will.laws@me.com>
Co-authored-by: Matt Cohen <mattcohe@amazon.com>
(cherry picked from commit 0f785ef)
(cherry picked from commit 4bb1d11)
(cherry picked from commit 6d99710)
(cherry picked from commit c759e04)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

readiness: passed Eligible automated validation passed for the current revision

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Subagent bar keeps '1 waiting to start' after the wave finishes: queued depth never publishes 0

2 participants