Repository navigation
test(subagent): pin the startup-progress wake edge - #14367
Conversation
_note_startup_progress is the only edge that announces a non-terminal exit from the in-startup population, and none of its three call sites was driven to the start it exists to cause: the dedicated-process PID record in _run_inner could be deleted with the suite fully green, and the shared-runtime PID record and the first-frame exit in _leave_startup were pinned only by mocks asserting the call happens. One harness, three cases, each driving one transition through its real code path with a spawn queued behind a full startup bound: the queued spawn must start with no _drain_queue() call of the test's own, observed while the driven start is still mid-execution so a terminal's drain cannot be what moved it. Deleting any one call site turns exactly its own case red while the other two stay green.
Design Review (Fable 5) — ✅ PASSDesign-level review of Design-Verdict: PASS Verify the per-call-site deletion table was exercised at the pushed head, not only the pre-rebase commit — it is the PR's entire value claim. [DESIGN-REVIEWED] f3a9f54 |
GPT 5.6 Review — ✅ no blocking findingsGPT 5.6 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: |
Opus 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: |
|
Description gains the |
Problem / Motivation
Goal: The suite notices when one of the three lines of production code that wake a spawn the in-startup bound is holding is gone.
Three lines of production code wake a spawn that the in-startup bound is holding, and the suite did not notice when one of them was gone.
_note_startup_progressis called at the dedicated-process PID record in_run_inner, at the shared-runtime PID record in_bind_shared_handle(both insubagent_manager/run.py), and on the first frame of a run's own turn inSubagentManager._leave_startup(subagent.py). Deleting the dedicated PID-record call left every test green. The other two were pinned only by mocks that assert the call happens; nothing drove the queued spawn to the start the call exists to cause.Why it matters
That call is the only edge that announces a non-terminal exit from the in-startup population: the slot-release drain fires on a terminal and the pump does not poll. Lose one call site and a fan-out wider than
_startup_cap()(4 at the stockagent.session_start_concurrencyof 2) sits queued with free running slots until an unrelated terminal or a new arrival happens. That is a silent hang, and no test would go red.Not a goal
startup_full = Falsein_should_stagger_queue_implor the_gate_wait_startedstamp: both are left alone on purpose, already load-bearing per the issue's own verification.What changed (motivation → approach → change)
Test only. One new class in
test/test_subagent_startup_pressure.py,TestLeavingStartupStartsTheHeldSpawn, with one case per call site.test_the_dedicated_pid_record_starts_the_held_spawn_run_inner,get_pidanswers a PID, the stream is held open and silenttest_the_first_frame_of_its_own_turn_starts_the_held_spawn_run_inner,get_pidanswers nothing (a child created lazily fromstream()), one roster frame, then the stream is held opentest_the_shared_runtime_pid_record_starts_the_held_spawn_bind_shared_handlewithruntime.pidsetThe shape is the same in every case. Gate width 1 gives a bound of 2; a peer and the driven start fill it; one more spawn goes through the real
spawn()and queues with six free running slots. The test never calls_drain_queue()or_note_startup_progress()itself. It watches the queued spawn start while the driven start is still mid-execution, so a terminal's drain cannot be what moved it. Every wait isasyncio.wait_forwith a ceiling or the file's own_untilon observable state; every hold is released infinally. No production code, default or document changes.Backwards compatibility
Compatible: tests only, nothing that runs today changes.
Tests
Each call site deleted alone (the line replaced by
pass), thentest/test_subagent_startup_pressure.py test/test_subagent_startup_watchdog.py test/test_session_start_gate.pyrun with-n0:_run_inner,run.py)test_the_dedicated_pid_record_starts_the_held_spawnred; the other two new cases green_bind_shared_handle,run.py)_note_startup_progress:test_shared_start_is_out_of_startup_at_bind, the threetest_a_co_tenants_fanned_out_frame_neither_starts_nor_marks_the_runcasestest_the_shared_runtime_pid_record_starts_the_held_spawnred; the other two new cases green_leave_startup,subagent.py)_note_startup_progress:test_the_first_event_received_leaves_startup,test_a_completion_withheld_for_recovery_is_an_answer,test_a_routed_roster_frame_is_the_sessions_own_answertest_the_first_frame_of_its_own_turn_starts_the_held_spawnred; the other two new cases greenUnmodified code: the three files pass (95), the pressure file alone passes under
-n 4 --dist loadgroup, and the new class passes 8 consecutive isolated runs. Gates run from the worktree: black ratchet, subprocess-encoding check, isort, flake8, mypy (1734 files, no issues),scripts/local-gate.py(backend related set 59 passed; frontend related set 302 files, 9016 tests passed).Left alone on purpose, already load-bearing per the issue's own verification:
startup_full = Falsein_should_stagger_queue_impland the_gate_wait_startedstamp.Manual verification
N/A — unit coverage sufficient: test-only change with no product code and no UI.
Screenshots / video
Why no screenshot: test-only backend change; no rendered surface is touched.
Related Issues
Fixes #14023
Pattern harvest
Rule candidate: review-prompt
Pattern: a mock that asserts a wake or pump call was made pins the call, not the wake; the test must let the pump run for real, with the queue populated, and observe the consumer start before the driven run's terminal can stand in for the edge under test.
Local review
One local round, one lane at a time, each briefed from the contract CI reads on the base commit. The lanes judged the diff at
a7c4e00a2d; the pushed headf3a9f54116is that single commit replayed onto the moved basee4e6ed7c60, byte-identical (git diff --stat $(git merge-tree --write-tree a7c4e00a2d e4e6ed7c60) HEADis empty; the base's movement touched neither this file nor the code under test), with the static gates, the three test files, mypy and the local gate re-run on it.gpt-5.6-sol, codex-review contract): no findings, PASS.claude-opus-5, claude-review contract): discovery raised six candidates, validation kept none. It measured each call site deleted in its own process and saw exactly its own case go red, confirmed theAcpSessionProviderbuilt at bind creates no task, thread or timer, and readCapacityView.any_slotas a real property. PASS.claude-fable-5): no CONCERNS, PASS. It counted the three production call sites, confirmed no existing test drove a queued spawn to a start through a real call site, and asked that the red/green table be verified by execution, which the runs above and the Opus lane's own per-process measurement are.Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)