Skip to content

test: wait for the retired lane to release its unit before the rebuilt writer's flush - #32813

Merged
KiroCrewCaptain merged 1 commit into
mainfrom
crew/bug-resolve/32634-rebuilt-writer-flake
Nov 8, 2026
Merged

KiroCrewCaptain merged 1 commit into
mainfrom
crew/bug-resolve/32634-rebuilt-writer-flake

Conversation

@CrysisDeu

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: Make test_a_rebuilt_writer_does_not_write_beside_a_retired_writers_stuck_lane deterministic so Backend Tests (Windows) stops going red on unrelated PRs.

The test fails on Windows shard 2 at test/test_crew_log_writer_lanes.py:522 (assert rebuilt.flush(timeout=default_timeout()) got False) on heads that do not touch the crew log writer (#32499, #32298, #26455).

Why it matters

Every backend PR can hit this red on the Windows shard, which costs a rerun and blocks PR Readiness for authors whose change has nothing to do with the crew log writer.

Not a goal

  • No change to CrewLogWriter or writer_groups.Holds: the product behavior the test pins is correct.
  • No change to the other assertions of the test.

What changed (motivation → approach → change)

  • Symptom: the second rebuilt.flush(...) returns False after wait_until(lambda: home.steps(unit) == [1]) succeeded.
  • Root cause: the retired lane's write of step 1 lands in the file inside _write_batch (src/kiro_crew/crew_log/writer.py:1760), but the lane gives the unit back to PROCESS_HOLDS only later, in the finally of _drain_once (src/kiro_crew/crew_log/writer.py:1746-1748), after the batch's bookkeeping. The rebuilt writer runs passes on the test thread on a fake clock its own sleep advances (_run_claimed_passes, writer.py:1549). While the unit is still held, _next_pass_delay_locked skips it and returns batch_deadline_seconds (0.02), so the whole 90 s budget is about 4,500 instant passes. If the retired lane has not released the hold by the time those passes finish (a slow Windows runner), flush returns False.
  • Change: the wait before the second flush now also waits until the unit is no longer in PROCESS_HOLDS.held() (the method is documented "for tests and diagnostics", and the same file already imports PROCESS_HOLDS in two other tests). This is a bounded wait_until on the real state, no sleep.

Alternative considered: make the rebuilt writer's flush wait in real time for a unit another writer holds. It lost because it changes product behavior the first half of the same test pins on purpose (a flush against a held unit returns False within its budget instead of writing beside it), and the race is only in the test's barrier.

Intended? / Repro

Intended? Yes for the product, no for the test. CrewLogWriter.close keeps process holds on purpose (src/kiro_crew/crew_log/writer.py:900-901: "a lane stuck in a write still holds its unit, and no lane or inline write of this or a rebuilt writer may write beside it"), and a fake-clock flush against a held unit returning False is what line 517 of the test asserts. The test's barrier at line 521 (home.steps(unit) == [1]) waits for the file, not for the hold release, which comes later (writer.py:1746-1748). Introduced with #31953.

Repro: CI only (host rule: no local test runs). Run https://github.com/kirodotdev/KiroCrew/actions/runs/42399858342/job/128486448508, Backend Tests (Windows) (2), PR #32499 head 837566e: FAILED test/test_crew_log_writer_lanes.py::test_a_rebuilt_writer_does_not_write_beside_a_retired_writers_stuck_lane - assert False (1 failed, 33725 passed). Same failure in runs 42396500729 (job 128476650590) and 42420640985 (job 128550333104).

Backwards compatibility

Compatible: test-only change; no product code touched.

Removes nothing: the diff only tightens one test's wait condition.

Tests

  • test/test_crew_log_writer_lanes.py::test_a_rebuilt_writer_does_not_write_beside_a_retired_writers_stuck_lane: the barrier before the second flush now waits for both step 1 in the file and the retired lane's release of the unit, so the flush runs only once the unit is free. All existing assertions stay.

Manual verification

Static gates only (black, isort, flake8 on the changed file); CI runs the test.

Screenshots / video

N/A — test-only change, no UI.

Related Issues

Fixes #32634

Sibling sweep

Swept: git grep -n "retired = _writer|rebuilt" -- test/ and git grep -n "wait_until(lambda: home.steps" -- test/
Siblings: none -- no other test flushes a second writer against a unit a retired writer's lane still holds

Pattern harvest

Rule candidate: review-prompt
Pattern: "a test barrier waits for a side effect (file content) that is published before the lock/hold the next step depends on is released"

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 8, 2026 01:07
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Nov 8, 2026
@github-actions

github-actions Bot commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision 2f599350ec67d2a4779fa0546e78ee2d41639512 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 8, 2026

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ⏭️ skipped

Revision 2f599350ec67d2a4779fa0546e78ee2d41639512 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 8, 2026

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

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

Design-Verdict: PASS

Nothing blocks: the test now waits for the hold to be released, the actual precondition of the next flush, rather than an earlier side effect. Product code is unchanged.

[DESIGN-REVIEWED] 2f59935

Description read

[DESCRIPTION-READ] d645d7102cef98d9f3a5a23dc7460459f1c263e1aea5118a5f9ce27839685571

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 8, 2026

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of 2f599350ec67d2a4779fa0546e78ee2d41639512 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 2f59935

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

@github-actions

github-actions Bot commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed 2f599350ec67d2a4779fa0546e78ee2d41639512 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 2f59935

Verdict parsed from the review's SHA-scoped output markers for commit 2f599350ec67d2a4779fa0546e78ee2d41639512.

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

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Nov 8, 2026
@KiroCrewCaptain
KiroCrewCaptain enabled auto-merge (squash) November 8, 2026 02:04

@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: test-only change in test/test_crew_log_writer_lanes.py; the wait now also waits for the retired lane to release its unit before the rebuilt writer's flush, so the flush does not spend its fake-clock budget against a held unit.

@KiroCrewCaptain
KiroCrewCaptain merged commit 64c9bf4 into main Nov 8, 2026
96 checks passed
@KiroCrewCaptain
KiroCrewCaptain deleted the crew/bug-resolve/32634-rebuilt-writer-flake branch November 8, 2026 02:04
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Nov 8, 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_a_rebuilt_writer_does_not_write_beside_a_retired_writers_stuck_lane on Windows

2 participants