Repository navigation
test(dashboard): isolate the eager-spawn semaphore in the default-model tests - #22815
Conversation
…el tests _eager_spawn returns early when the module-global _eager_spawn_sem is already held, so this class silently depended on no sibling pre-warm being in flight in the same xdist worker.
First Principles Review (Opus 5.5, fork) — ⏭️ skippedRevision |
UX Review (Opus 5.5, fork) — ⏭️ skippedRevision |
Design Review (Opus 5.5, fork) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: it is a test-only change that gives the class its own copy of shared worker state, using the idiom [DESIGN-REVIEWED] 79386fc Description read[DESCRIPTION-READ] 9bd9c9798aae123d9a5f04a1c121381f081f2d677997e36fd33b3e4390a5ffe2 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 |
Opus 5.5 Review (fork) — ✅ no blocking findingsReviewed |
GPT 6.1 Review (fork) — ✅ no blocking findingsReviewed Review detailsNo findings. |
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
Tier 1 auto-approve: test (1 file). 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: gives the eager-spawn default-model test class its own semaphore, so those tests no longer share that state with other tests.
Problem / Motivation
Goal: Stop
TestEagerSpawnDefaultModelfrom failing for reasons that have nothing to do with the model it is asserting on._eager_spawnstands down when the module-global_eager_spawn_semis already held:src/kiro_crew/dashboard/chat_turn/eager_spawn.py:558, reached from the real_eager_spawnthe test calls directly.TestEagerSpawnDefaultModelisolates the debounce but not the semaphore, so it only passes while no sibling pre-warm holds a permit in the same xdist worker. When one does,_eager_spawnreturns having registered no session and the test fails attest/test_chat_send_agent_model_default.py:156withAttributeError: 'NoneType' object has no attribute 'kwargs'— a failure that names nothing about the real cause.test/test_chat_runner_composition_contract.py:551already lists_eager_spawn_semunder_RUNNER_STATE, whose comment says the single shared binding "holds only while no owner keeps a copy". This test keeps no copy.Why it matters
An intermittent failure whose message points at a
Nonereturn rather than at a held semaphore costs an investigation every time it fires, and the obvious readings are both wrong: it looks like a defect in the model-default path, or like an ordinary flake. It took measuring the semaphore directly to attribute it. Left alone, each recurrence pays that cost again, and a test that fails for an unrelated reason erodes trust in a red run.Not a goal
_eager_spawn's concurrency behaviour. Thelocked()stand-down is deliberate and stays exactly as it is._eager_spawnfor the same gap. This PR fixes the one class whose dependence was measured.What changed (motivation → approach → change)
Observed symptom:
test_eager_session_starts_on_the_global_defaultfails withAttributeError: 'NoneType' object has no attribute 'kwargs'when a sibling pre-warm holds the eager-spawn permit.Root cause: the class's
_no_debounceautouse fixture replaces_EAGER_SPAWN_DEBOUNCE_SECSbut leaves_eager_spawn_semshared, so the assertion depends on worker-wide state the test does not own.Change: the same fixture now also installs a fresh semaphore, copying the idiom already used at
test/test_session_capabilities.py:223:Patched on
chat_runnerrather than oneager_spawn, because that is where the name actually resolves.eager_spawn.pyimports it only underTYPE_CHECKING; at runtimechat_runner._eager_spawn.__globals__ischat_runner's module dict, andeager_spawncarries no_eager_spawn_semattribute at all. Verified by probing both module objects.asynciowas already imported in the file.Backwards compatibility
Compatible: the change is confined to one test class's own fixture and rejects, renames and removes nothing.
Removes nothing: the diff adds a single
monkeypatch.setattrline and deletes nothing, so no caller or reader loses a path.Tests
No new test. The change makes an existing assertion mean what it says, so the evidence is a control rather than a new case.
A negative control was loaded as a throwaway pytest plugin that installs
asyncio.Semaphore(0)onchat_runner(solocked()isTrue), standing in for a sibling pre-warm holding the only permit:The control is not in the diff. Without it the test passes either way, which is exactly why the gap survived.
Suites run in parallel on this branch, with the repo's default xdist settings:
test_chat_send_agent_model_default.py,test_chat_runner_composition_contract.py,test_session_capabilities.py,test_eager_spawn.py— 323 passed.Blocking gates:
mypy src/kiro_crew/→Success: no issues found in 3445 source files;black,isort,flake8all clean.Manual verification
N/A — the control above exercises the only behaviour that changed, and it fails for the intended reason before the fix.
Related Issues
None. Found while driving #12702, which a maintainer has since closed as no longer applicable; this fix is independent of that PR's design and is raised on its own.
Pattern harvest
Rule candidate: review-prompt
Pattern: a test monkeypatching one module-global of a group leaves its siblings shared, so the assertion silently depends on worker-wide state.
_RUNNER_STATEintest_chat_runner_composition_contract.pyalready enumerates that group, which makes the gap checkable: a test that patches any member and drives a function reading another is suspect.Checklist