Repository navigation
Conversation
test_whatever_lands_after_the_claim_the_run_is_completed_once holds the claimed result write with a gate, then asserts the run is not done yet. The write's drain has its own 5 s wall-clock bound. On a loaded runner that bound expires before the gate reports entered, so the run is already done when the test looks. Raise the bound past the gate's 15 s hold in this test, so only the gate decides when the write lands. Closes kirodotdev#28239 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
5 tasks done
5 tasks done
Contributor
Author
|
Closing as superseded: #31174 landed the same fix on main, and rebasing this PR leaves no change beyond what is already there. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem / Motivation
Goal: Stop
test_whatever_lands_after_the_claim_the_run_is_completed_oncefrom failing at random on a loaded CI runner.The test failed on an unrelated PR (#24788, Backend Tests (3.12, 6)). Its first check after the claimed result write is entered is
assert info._ending_claimed and not info.done, and that check failed. The captured log shows why:Why it matters
When this test fails at random, a backend shard goes red on PRs that never touch subagents. Each red shard costs a maintainer a re-run and an attribution comment. The failing line runs before any ending is applied, so all seven parametrized cases have the same exposure.
Not a goal
_STATE_DRAIN_TIMEOUTor the bounded-drain behaviour in production. The bound is correct; this test just was not meant to exercise it._GatedResultWriteor the other tests that use it.What changed (motivation → approach → change)
donewhen the test checks that the claimed write is still pending._GatedResultWriteholds the write, but the write's drain has its own wall-clock bound (_STATE_DRAIN_TIMEOUT, 5 s), which starts at the drain's first await. If the pool thread picks up the write late, or the loop is starved, the gate signalsenteredonly after the bound has expired. By then the run has left the write detached and finished.test_a_claimed_result_write_that_hangs_is_boundedin the same file already guards against this race with_HeldResultDrain(test: hold the claimed result write's drain until the test looks #19149).subagent._STATE_DRAIN_TIMEOUTto 60 s, which is past the gate's own 15 s hold. The gate alone now decides when the write lands, and the bound can no longer win a race the test never meant to run. I chose this over_HeldResultDrainbecause parking the drain before its real body would deliver the cancel-shaped endings to the park, not to the real drain those cases test. Test-only; one file.Backwards compatibility
Compatible: test-only change, no production code touched.
Removes nothing: only a test's local timing bound is raised.
Tests
Proof: not provable -- test-only change
I reproduced it locally by injecting a 6 s sleep into
_GatedResultWritebefore it signalsentered. That sleep was not committed. It stands in for a late pool pickup:assert (True and not True)at the same line as CIAlso run locally: black, isort, flake8,
check_comment_history.py,check_brand_name.py,test_flake_pattern_ratchet.py.Manual verification
N/A — test-only change; the delay-injection run above covers the race directly.
Related Issues
Closes #28239
Sibling sweep
Swept: git grep -n "_GatedResultWrite(" -- test/
Sibling: test/test_subagent_stop_reason_consistency.py:610 -- not affected -- already parks the drain with _HeldResultDrain and shrinks the bound on purpose
Sibling: test/test_subagent_stop_reason_consistency.py:653 -- not affected -- asserts info.done, which is true whether or not the bound expired
Sibling: test/test_subagent_stop_reason_consistency.py:1250 -- not affected -- asserts info.done, and its outcome is the same if the bound expired first
Pattern harvest
Rule candidate: review-prompt
Pattern: a test gates an operation that production code also bounds by wall-clock, then asserts it is still pending, without lifting or parking that bound
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
🤖 Generated with Claude Code