Repository navigation
fix(test): credit busy-helper callers in the slot-reader tripwire - #12718
Conversation
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: |
Design Review (Fable 5) — ✅ PASSDesign-level review of Design-Verdict: PASS Verify shard 4 (Linux and Windows) is green on this PR's merge ref, since the failure it fixes only exists in a union of branches. Suggestions
[DESIGN-REVIEWED] 28fe818 |
Opus 4.8 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: |
The reader enumeration in test_pending_boundary_consumer_semantics only saw a slot predicate named directly inside a function, so extracting a guard into a shared helper dropped every caller out of the table. #11425 extracted _switch_target_busy out of the agent, model, reasoning-effort and workspace switch handlers; #11454 later added the tripwire with the table describing the pre-#11425 reader set. Each was green alone, so main holds the union and the test fails there, taking Backend Tests (3.12, 4) and Backend Tests (Windows) (4) red on every pull request. Credit a busy-helper's callers with the state the helper reads, rather than removing the four handlers from the table: they still depend on the reservation, and a naive table update would also stop the tripwire firing for the next handler wired to the same helper.
9f16e73 to
28fe818
Compare
bolichen97
left a comment
There was a problem hiding this comment.
Approving over #12715/#12716: those two drop the four switch handlers from the enumeration, which weakens the tripwire (a new handler wired through _switch_target_busy would go unenumerated) and breaks the precedent already set for _destructive_history_busy. This PR generalizes that precedent into a table and keeps every caller credited. Test passes locally on current main (9 passed).
…rodotdev#12718) The reader enumeration in test_pending_boundary_consumer_semantics only saw a slot predicate named directly inside a function, so extracting a guard into a shared helper dropped every caller out of the table. kirodotdev#11425 extracted _switch_target_busy out of the agent, model, reasoning-effort and workspace switch handlers; kirodotdev#11454 later added the tripwire with the table describing the pre-kirodotdev#11425 reader set. Each was green alone, so main holds the union and the test fails there, taking Backend Tests (3.12, 4) and Backend Tests (Windows) (4) red on every pull request. Credit a busy-helper's callers with the state the helper reads, rather than removing the four handlers from the table: they still depend on the reservation, and a naive table update would also stop the tripwire firing for the next handler wired to the same helper.
…rodotdev#12718) The reader enumeration in test_pending_boundary_consumer_semantics only saw a slot predicate named directly inside a function, so extracting a guard into a shared helper dropped every caller out of the table. kirodotdev#11425 extracted _switch_target_busy out of the agent, model, reasoning-effort and workspace switch handlers; kirodotdev#11454 later added the tripwire with the table describing the pre-kirodotdev#11425 reader set. Each was green alone, so main holds the union and the test fails there, taking Backend Tests (3.12, 4) and Backend Tests (Windows) (4) red on every pull request. Credit a busy-helper's callers with the state the helper reads, rather than removing the four handlers from the table: they still depend on the reservation, and a naive table update would also stop the tripwire firing for the next handler wired to the same helper.
What is the problem?
test/test_pending_boundary_consumer_semantics.py::test_running_and_turn_running_slot_readers_are_enumeratedfails on plainmain, with no pull request involved. Verified on a clean worktree atorigin/main0a80050938: 1 failed, 8 passed.The test is a source-scanning tripwire. It walks every
.pyundersrc/kiro_crew/dashboard/, usesastto find every function that readsslot.runningorslot.turn_running, builds{(file, symbol): frozenset(predicates)}, and asserts that equals a hardcodedexpectedmap. Its enumeration only saw a predicate named directly inside a function body, with one exception already carved out for_destructive_history_busy.Two changes that were each green alone produced a red union:
af0f186780(fix(dashboard): refuse a slot switch while a sibling alias cold-starts #11425) extracted_switch_target_busyout of four switch handlers:api_chat_slot_agent,api_chat_slot_model,api_chat_slot_reasoning_effort,api_chat_slot_workspace. All four stopped namingslot.runningthemselves, and the new helper started naming it.2515d7b07b(fix: advance Autopilot to the next stage after a completed stage #11454) landed later and created this test file, with anexpectedtable describing the reader set as it stood before fix(dashboard): refuse a slot switch while a sibling alias cold-starts #11425: the four handlers present, the helper absent.So the enumeration diff on
mainis exactly four stale entries and one unexpected one:chat_handlers.py::_switch_target_busyrunning)chat_handlers.py::api_chat_slot_agentchat_handlers.py::api_chat_slot_modelchat_handlers.py::api_chat_slot_reasoning_effortchat_handlers.py::api_chat_slot_workspaceThe
publishersassertion in the same test is unaffected and already matches.Why this issue matters to the user
Every pull request in the repository is blocked. The test runs in shard 4, so Backend Tests (3.12, 4) and Backend Tests (Windows) (4) go red on any head based on current
main, whatever the change touches. Confirmed on three unrelated pull requests whose diffs do not go nearsrc/kiro_crew/dashboard/at all, which is the only tree this test reads, so none of them can alter its enumeration. Pull requests on older bases still show both lanes green.Nobody can land anything, including the fix for whatever they were actually working on, until this is repaired.
How our fix solves it
Chaining back from the symptom: the red lane is one failing assertion; the assertion fails because
actual != expected;actualchanged because #11425 moved a guard from four callers into one helper; the enumeration treated that move as four readers disappearing, because it credits a reader only where the attribute is named.The straightforward repair would be to delete the four handlers from the table and add the helper. That restores green and is wrong in a way that matters: those four handlers still refuse a switch on the basis of reservation state, so dropping them stops the table from recording that dependency. Worse, it removes the tripwire's teeth for the next person, because a new handler wired to
_switch_target_busywould name no predicate, add no entry, and trip nothing.Instead, the helper's callers inherit what the helper reads. The test already did this for
_destructive_history_busy; this change turns that one-off carve-out into a small declared map and adds the second helper to it:The four handlers therefore stay in the table with their reservation declaration intact, and
expectedgains exactly one line for the helper itself. Net change to the table is one added entry.frozenset({"running"})is the correct declaration for_switch_target_busy, not a transcription of what it happens to read. Its own docstring gives the reason:slot.runningis set at dispatch, before the multi-secondprovider.start()registers a session, so a cold-starting first turn dispatched through that slot is visible in the reservation and in neither of the helper's other two signals. A pre-commit refusal on a switch wants the reservation. No reader was found using the wrong predicate, so #11425 is referenced here as the origin of the drift and not as a defect.No production code changes. No assertion was skipped, xfailed, deleted or loosened; the
rglobwas not narrowed; no allowlist was added.What tests we did
test/test_pending_boundary_consumer_semantics.py, run with an explicit-n0, on a clean worktree cut fromorigin/main0a80050938:mainwith no edits: 1 failed, 8 passed. The failure istest_running_and_turn_running_slot_readers_are_enumerated.flake8clean,isort --check-onlyclean,black --checkunchanged.Because a fix to a tripwire can quietly disarm it, the tripwire was also confirmed to still trip, by appending a throwaway function to
chat_handlers.pyand reverting it afterwards:slot.turn_runningdirectly: test fails, as it should._switch_target_busy: test fails, as it should. This is the case a plain table update would have let through silently.Any other suggestions on the work
This class of failure is worth addressing at its root, because the tripwire cannot see it coming. A table of expected source facts is a semantic merge conflict: two pull requests touch no common line, so git merges them without complaint, each one's CI is green against its own base, and the contradiction appears only in the union. Git's textual conflict detection is the wrong instrument, and adding more tables makes the exposure larger.
Three options, cheapest first:
Option 1 is worth doing regardless of the other two, since nothing about it is specific to this test.
Pattern harvest
Rule candidate: CI policy, not a code pattern. Re-run required checks against an up-to-date merge ref, or require a branch to be current before merge.
Pattern: a test that asserts a hardcoded table of facts derived from other source files can be satisfied by two pull requests independently and by neither of them together. One side changes the scanned population, the other side writes the table, the two share no line, git reports no conflict, and each side is green against its own base. Merge order decides nothing, so re-running the failing side is not a fix; the contradiction exists only in the union.
The narrower lesson for anyone adding such a test: an enumeration that credits a reader only where it names the attribute makes ordinary refactoring look like deletion. Credit the callers of a guard helper, so extracting a guard does not silently empty the table.
Not reachable by lint: the defect is an agreement between two files with no shared syntax, so there is no single code shape to match on.