Repository navigation
test(purge): let the drain-budget test outlast a slow first pass - #620
Conversation
test_drain_time_counts_toward_the_budget gave the whole job a 1 s budget and expected it to run out in the drain wait. The budget is wall time from the start, so on the Windows runner a first pass near 1 s ran it out before the wait and the blame went to a first-pass step; the same test failed on two unrelated branches (11-19, 11-20). Delaying the first pass by 1.2 s reproduces it locally. A 3 s budget keeps the failure in the wait with that delay and without it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
gloryfromca
left a comment
There was a problem hiding this comment.
No blockers; this can merge as far as I am concerned.
The 3 s budget preserves the test's intended drain-timeout path while leaving margin for the observed slow first pass. The terminal status, budget error, elapsed-time, and second-pass store attribution assertions are unchanged, so this does not weaken the contract to obtain a green result.
Covered: repository guidance (CLAUDE.md, architecture/style/language/testing rules, and engineering guidance), the full diff, the purge runner and test harness callers, relevant file history/blame, backward compatibility and test-strength implications, and architecture constraints. There is no production/API compatibility or architecture impact.
Validation: the focused test passed; all 28 tests in tests/unit/test_service/test_purge/test_runner.py passed; Ruff check and format-check passed for the changed file.
Kendrick-Song
left a comment
There was a problem hiding this comment.
Approving. The cause matches the runner: _try_steps puts pass one, the drain wait and pass two under one asyncio.timeout and blames at_store when it expires, so a pass one slower than the budget blames a pass-one step. test_runner.py: 28 passed locally; this test now takes about 3.1 s.
Two non-blocking notes:
row.run_seconds >= 0.8was sized for the 1 s budget. With 3 s, something like>= 2.4would keep showing that the drain time was added; on a slow runner, pass one alone can reach 0.8 s.test_budget_timeout_fails_hung_stepmakes the same kind of assumption (a 0.5 s budget, expectinginboxandmarkdowndone andlancedbblamed), so a slow pass one could fail it the same way. It is not touched here; I have not checked whether it has flaked.
Summary
test_drain_time_counts_toward_the_budgetfails intermittently on the Windows runner withassert ('done', False) == ('failed', True). It failed on two unrelated branches:feat/hw-multi-speaker-optim(2026-11-19) andfix/async-failed-body-budget(#607, 2026-11-20).Cause: the test gives the whole job a 1 s budget and expects it to run out in the drain wait, so that the second pass's first store (
inbox) is blamed. The budget is wall time from the start of the job. When the first pass alone takes about 1 s, as it can on the Windows runner, the budget runs out before the wait begins, and the runner correctly blames the first-pass step that was running. The product behaves as designed; the test's timing assumption is wrong.Fix: a 3 s budget, which leaves room for a slow first pass. A fixed duration is the point of this test (it measures the budget itself). The docstring records why the margin is there.
Area
Verification
Checklist
main..envfiles, dependency folders, or generated output.Notes for Reviewers
By submitting this pull request, I agree that my contribution is licensed under
the Apache License 2.0.
🤖 Generated with Claude Code