test: drain test waits via fetched recorder, not SQL poll#48
Merged
Conversation
Replaces SQL-poll wait helper in test_drain_finishes_inflight_rows_before_returning with recorder-based fetch observation, removing the 3.13/3.14 timing race that caused a 99.98% coverage miss on line 1125 of tests/test_integration.py. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Implementation plan for the recorder-based wait refactor of test_drain_finishes_inflight_rows_before_returning. Three tasks: baseline confirmation, the refactor itself (with deletion of _wait_until_claimed), and CI verification on both Python matrix legs. Spec: planning/specs/2026-06-09-drain-test-flaky-fetch-observation-design.md Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Removes _wait_until_claimed and migrates the lone caller (test_drain_finishes_inflight_rows_before_returning) to observe the broker's fetched recorder event. The SQL-poll variant had a Python 3.13/3.14 timing race that left tests/test_integration.py:1125 uncovered on 3.14, tripping the 100% fail-under gate. Spec: planning/specs/2026-06-09-drain-test-flaky-fetch-observation-design.md
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.
Summary
test_drain_finishes_inflight_rows_before_returningthat caused the 3.14 matrix leg to miss 1 line of coverage (tests/test_integration.py:1125, theawait asyncio.sleep(0.02)inside_wait_until_claimed).fetchedrecorder event. The single-caller helper_wait_until_claimedis deleted.Why
On Python 3.13 the test's first SQL poll observed some rows still unclaimed → loop iterated →
await asyncio.sleep(0.02)ran → 100% coverage. On 3.14 the worker reliably fetched before the first poll → loop returned on iteration 1 → sleep never ran → 99.98% → fail-under gate trips.The race is in the test (observation window between publish-commit and worker-fetch), not the package. Observing fetch progress through the broker's own recorder seam removes the race because the event fires at the fetch moment, with no separate observation window.
See
planning/specs/2026-06-09-drain-test-flaky-fetch-observation-design.mdfor the full rationale andplanning/plans/2026-06-09-drain-test-flaky-fetch-observation-plan.mdfor the executed plan.Test plan
just test tests/test_integration.py::test_drain_finishes_inflight_rows_before_returning -v --no-covpasses locally on 3.13just test tests/test_integration.py -vreportstests/test_integration.pyat 100% (806 stmts, 0 missed)just lintclean🤖 Generated with Claude Code