Skip to content

test: await the coalescer flush tick instead of a fixed sleep - #29617

Merged
KiroCrewCaptain merged 1 commit into
mainfrom
crew/bug-resolve/29506
Nov 5, 2026
Merged

KiroCrewCaptain merged 1 commit into
mainfrom
crew/bug-resolve/29506

Conversation

@CrysisDeu

@CrysisDeu CrysisDeu commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: Stop test_tool_merge_clears_stale_retrying_attempt from failing on slow CI runners.

The coalescer tests in test/test_subagent_scale_batch.py sleep 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 with ValueError: 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

  • Changing SubagentEventCoalescer itself.
  • De-flaking other fixed sleeps in this file that wait on a different mechanism (the manager's fire-and-forget event task).

Intended? / Repro

  • Intended? No. The test means "after the flush tick, exactly one frame". The fixed 60 ms is only a guess at when the tick has run. Code path on main: test/test_subagent_scale_batch.py:78-81 (sleep, then unpack), flush scheduled by SubagentEventCoalescer._ensure_tick / _tick in src/kiro_crew/subagent_scale.py. The line already carries a flake-ok note saying it is tracked for a de-flake pass.
  • Repro: CI run 41797479802 job 126467561880 (PR feat(mate-worker): run a crewmate's worker chats on codex #29490, head 712e6f822c65, ubuntu, Python 3.12, shard 3): ((etype, data),) = all_frames raised ValueError: 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 (through kiro_crew.testing.wait.await_until, whose bound only names a hang). When that task finishes, _flush_if_pending has run, so the frame is there on any runner. The three TestCoalescer tests that used the 60 ms sleep now call the helper, and their flake-ok / nosemgrep notes go away.

Alternative considered: poll all_frames with 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_frame and test_chunks_concatenate_and_go_to_subscribers to 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

  • 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

Contribution License Agreement

Contributions are accepted under the project's Apache-2.0 license.

@CrysisDeu
CrysisDeu requested review from a team and KiroCrewCaptain as code owners November 4, 2026 13:05
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Nov 4, 2026
@github-actions

github-actions Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision 024d03ac5af78c5053d113985eb245667987ce8f touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Does not block merge.

@github-actions

github-actions Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ⏭️ skipped

Revision 024d03ac5af78c5053d113985eb245667987ce8f ships no reviewable capability (docs, tests or generated files only), so there is nothing to inventory. Does not block merge.

@github-actions

github-actions Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of 024d03ac5af78c5053d113985eb245667987ce8f — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

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

  • _wait_for_tick_flush reads the private c._tick_task. If the coalescer's scheduling changes, update this helper first. That coupling is fine for a test.

[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 .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 Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed 024d03ac5af78c5053d113985eb245667987ce8f — this comment is updated in place on each push.

Review details

I 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 await_until accepts a task like this one.

No findings.

[OPUS-REVIEWED] 024d03a

Verdict parsed from the review's SHA-scoped output markers for commit 024d03ac5af78c5053d113985eb245667987ce8f.

False positive or not applicable? A repository writer can comment:
/ai-review override fable 024d03ac5af78c5053d113985eb245667987ce8f false-positive: <reason, 20 to 500 characters>

@github-actions

github-actions Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of 024d03ac5af78c5053d113985eb245667987ce8f and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 024d03a

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 024d03ac5af78c5053d113985eb245667987ce8f false-positive: <reason, 20 to 500 characters>

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
@CrysisDeu
CrysisDeu force-pushed the crew/bug-resolve/29506 branch from 6c441b8 to 024d03a Compare November 4, 2026 14:19
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running and removed readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention labels Nov 4, 2026
@CrysisDeu

Copy link
Copy Markdown
Contributor Author

CI note for head 024d03a: Backend Tests (3.12, 7) was cancelled at the 65-minute job limit twice (attempt 1 and the one rerun), so Coverage Gate fails closed. This is the leaf-mode limit in #23450: a test-only diff runs all 807 corpus gate files once per shard before the changed file (fix pending in #23461). The changed file passed 3/3 repeats on each of the other 7 shards (39 passed per pass). All AI review lanes, PR Hygiene and Sensitive Change Review are green.

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: action required A blocking check or review needs attention labels Nov 5, 2026
@KiroCrewCaptain
KiroCrewCaptain enabled auto-merge (squash) November 5, 2026 01:05

@KiroCrewCaptain KiroCrewCaptain left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@KiroCrewCaptain
KiroCrewCaptain merged commit dd8e9c7 into main Nov 5, 2026
202 of 216 checks passed
@KiroCrewCaptain
KiroCrewCaptain deleted the crew/bug-resolve/29506 branch November 5, 2026 01:06
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Nov 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Flaky: test_tool_merge_clears_stale_retrying_attempt (fixed 60 ms sleep before reading flushed frame)

2 participants