Repository navigation
test: await the coalescer flush tick instead of a fixed sleep - #29617
Conversation
UX Review (Opus 5.5) — ⏭️ skippedRevision |
First Principles Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: the test now waits on the flush event itself (the coalescer's tick task finishing) instead of a fixed timer, and that is the actual fix for the flake. Product code is unchanged. Notes
[DESIGN-REVIEWED] 024d03a Description read[DESCRIPTION-READ] d58e21ad528bb6a61133ce9d1bd90d883ee19d4cedcfc16d7ef6215567da78aa 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 — ✅ no blocking findingsReviewed Review detailsI checked the change and found nothing that needs fixing. The previous review pass suggested no candidate issues, and the change itself holds up. The new helper waits on the coalescer's own flush task, which ends exactly when the flush has run. That makes the three old fixed 60 ms sleeps redundant, and No findings. [OPUS-REVIEWED] 024d03a Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 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: |
The three TestCoalescer tests slept 60 ms past a 20 ms flush tick and then read the frame list. On a slow runner the tick had not run yet, so test_tool_merge_clears_stale_retrying_attempt saw no frame. Await the scheduled tick task itself through testing.wait.await_until so the read happens after the flush on any runner. Fixes #29506
6c441b8 to
024d03a
Compare
|
CI note for head 024d03a: |
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
Tier 1 auto-approve: test (1 files). 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: coalescer tests await the flush tick task instead of a fixed sleep.
Problem / Motivation
Goal: Stop
test_tool_merge_clears_stale_retrying_attemptfrom failing on slow CI runners.The coalescer tests in
test/test_subagent_scale_batch.pysleep a fixed 60 ms past a 20 ms flush tick and then read the frame list. On a slow runner the tick has not run yet, so the list is empty and the test fails withValueError: not enough values to unpack (expected 1, got 0).Why it matters
The test goes red on unrelated PRs (seen on #29490, Backend Tests shard 3), which costs a rerun and a triage each time.
Not a goal
SubagentEventCoalesceritself.Intended? / Repro
test/test_subagent_scale_batch.py:78-81(sleep, then unpack), flush scheduled bySubagentEventCoalescer._ensure_tick/_tickinsrc/kiro_crew/subagent_scale.py. The line already carries aflake-oknote saying it is tracked for a de-flake pass.712e6f822c65, ubuntu, Python 3.12, shard 3):((etype, data),) = all_framesraisedValueError: not enough values to unpack (expected 1, got 0). The PR did not touch the coalescer.What changed (motivation → approach → change)
Symptom: empty frame list after a fixed sleep. Root cause: the test reads the result on a timer, not on the event that produces it. Change: a small helper
_wait_for_tick_flush(c)awaits the coalescer's scheduled tick task (throughkiro_crew.testing.wait.await_until, whose bound only names a hang). When that task finishes,_flush_if_pendinghas run, so the frame is there on any runner. The threeTestCoalescertests that used the 60 ms sleep now call the helper, and theirflake-ok/nosemgrepnotes go away.Alternative considered: poll
all_frameswith a deadline (the issue's suggestion). It lost because it still reads on a timer loop and needs a poll interval; awaiting the tick task is the exact signal and needs no interval.Backwards compatibility
Compatible: test-only change; no product code changes.
Removes nothing: only a test wait changes.
Tests
Updated
test_tool_merge_clears_stale_retrying_attempt,test_above_threshold_absorbs_and_flushes_one_frameandtest_chunks_concatenate_and_go_to_subscribersto wait on the flush tick task. Their assertions are unchanged.Proof: not provable -- test-only change
Manual verification
N/A — test-only change; CI runs the tests.
Related Issues
Fixes #29506
Sibling sweep
Swept: git grep -n "asyncio.sleep(0.0" -- test/test_subagent_scale_batch.py
Sibling: test/test_subagent_scale_batch.py -- changed here (the three coalescer tick waits)
Sibling: test/test_subagent_scale_batch.py -- not affected -- the 50 ms wait near the batch-identity test waits on the manager event task, not the coalescer tick; out of this PR's goal
Pattern harvest
Rule candidate: semgrep
Pattern: "fixed asyncio.sleep before reading a list a background task fills" — already covered by
kirocrew.test-sleep-as-barrier; these lines were suppressed with nosemgrep, and this PR removes the suppressions.Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
Contributions are accepted under the project's Apache-2.0 license.