Skip to content

test(purge): let the drain-budget test outlast a slow first pass - #620

Merged
gloryfromca merged 1 commit into
mainfrom
test/purge-budget-slow-first-pass
Nov 23, 2026
Merged

gloryfromca merged 1 commit into
mainfrom
test/purge-budget-slow-first-pass

Conversation

@gloryfromca

Copy link
Copy Markdown
Member

Summary

test_drain_time_counts_toward_the_budget fails intermittently on the Windows runner with assert ('done', False) == ('failed', True). It failed on two unrelated branches: feat/hw-multi-speaker-optim (2026-11-19) and fix/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

  • Architecture method
  • Benchmark
  • Use case
  • Documentation
  • Developer experience
  • CI, build, or release

Verification

Reproduction: a scratch probe wraps PurgeRunner._step_sqlite with an extra delay and runs this test.

                      first pass +0 s    first pass +1.2 s
before (budget 1 s)   pass               FAILED ('done', False) == ('failed', True)  <- the Windows failure
after  (budget 3 s)   pass (3.3 s)       pass (3.1 s)

tests/unit/test_service/test_purge/test_runner.py: 28 passed
ruff check / format: clean

Checklist

  • I kept the change scoped to the relevant area.
  • I am opening this from a separate branch, not pushing directly to main.
  • I updated docs, examples, or setup notes when behavior changed.
  • I added or updated tests when the change affects behavior.
  • I did not commit secrets, .env files, dependency folders, or generated output.
  • Active relative links in Markdown files resolve.

Notes for Reviewers

  • The test now takes about 3 s instead of about 1 s.

By submitting this pull request, I agree that my contribution is licensed under
the Apache License 2.0.

🤖 Generated with Claude Code

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 gloryfromca left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

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 Kendrick-Song 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.

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.8 was sized for the 1 s budget. With 3 s, something like >= 2.4 would 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_step makes the same kind of assumption (a 0.5 s budget, expecting inbox and markdown done and lancedb blamed), so a slow pass one could fail it the same way. It is not touched here; I have not checked whether it has flaked.

@gloryfromca
gloryfromca merged commit e8549b9 into main Nov 23, 2026
11 checks passed
@gloryfromca
gloryfromca deleted the test/purge-budget-slow-first-pass branch November 23, 2026 02:34
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.

2 participants