Repository navigation
test: stop three tests from racing a tiny real-clock budget - #22767
Merged
Merged
Conversation
#22758 moved five direct-delivery budget tests off a 0.05s real handler budget. test_terminal_cleanup_deferral_inherits_the_recovery_deadline still used it, and it stages its outcome by counting job reads (read 4 is the terminal one). An 80ms stall in the attempt's job read lets the budget expire before the pipeline runs. The recovery then never reaches its terminal read and the replacement enqueue is never called. Reproduced locally with that stall; with this change the test passes with the stall on reads 1-3. It now uses #22758's _pipeline_expiring_the_handler_budget, which keeps the production budget and expires it inside the pipeline stub. The inherited recovery deadline (now + the 0.2s cleanup timeout) is unchanged. The same class, in the opposite direction: two tests require healthy work to finish inside a tiny real budget. Parakeet pressure used a 20ms per-request timeout and daily summary a 50ms per-user budget. Both now use 0.5s; the hung or blocked case still times out. The other 0.05s handler-budget tests in test_sync_cloud_tasks.py stage only queued and processing reads, so where the expiry lands does not change their branch. They are left as they are; that file goes away with the legacy deletion (lane 10). Test-only; production code is unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
This was referenced Oct 20, 2026
Git-on-my-level
added a commit
that referenced
this pull request
Oct 20, 2026
* test(backend): ratchet tiny real-clock budgets in tests Three times on 2026-10-20 a backend unit test that shrank a production budget to tens of milliseconds raced a loaded CI runner (#22758, #22767, and the legacy-retire change C10). Add a static AST ratchet over backend/tests/**/*.py that flags budget/deadline/timeout names set to a literal in (0, 0.5) s via attribute assignment, setattr/patch.object/ patch, setenv/os.environ/patch.dict, or keyword arguments to code under test. Harness waits (wait_for, Event.wait, get, join, ...), mock call assertions, and functions that control the clock are excluded. The 100 current offenders are allowlisted with a blame owner and #22767; the test fails on new offenders and on stale entries so the list only shrinks. It is a codebase scan, so it is marked slow and listed in tests/slow_guardrail_manifest.txt (~0.45 s). Co-Authored-By: Claude Opus 5.5 <[email protected]> * test(backend): close real-clock ratchet gaps from review Grok review (FIX-FIRST) found four gaps: - `'monotonic': time.monotonic` counted as a fake clock and exempted six real-clock ack-budget tests in test_listen_pusher_session.py. Only a clock replaced by something other than time.* / None counts now, and decorators are part of the inspected source. The six sites are grandfathered (106 entries). - patch.object(obj, 'NAME', new=v) was not read. - The byte prefilter missed parenthesized, ' +0.05', and 1_0e-2 values. It is possessive now so whitespace runs cannot backtrack. - patch.dict('os.environ', ...), patch.dict(..., NAME='0.05') and values={...} were not read. Co-Authored-By: Claude Opus 5.5 <[email protected]> * test(backend): real clock passed via new= or parens is not a fake clock Grok r2: the optional `new=` introducer could be skipped so the lookahead tested `new`, and `(time.monotonic)` slipped past it, so `patch.object(obj, 'monotonic', new=time.monotonic)` still exempted the function. Introducers (`new=`/`value=`, parentheses, whitespace) are now consumed possessively and also rejected by the lookahead. Self-tests cover both real-clock spellings and a fake `new=` clock. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
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
Three backend unit tests depended on a tiny real wall-clock budget, so they flaked on loaded CI runners. This finishes the flake class that #22758 fixed for five sibling tests (lessons/batch-rollout-and-staging-traps.md #15).
test_terminal_cleanup_deferral_inherits_the_recovery_deadlineused a 0.05s handler budget and staged its outcome by counting job reads. An 80ms stall in the attempt's read let the budget expire before the pipeline ran, and the replacement enqueue was never called (reproduced locally). It now uses feat(deploy): build-only mode in gcp_backend.yml for listen-only rollouts #22758's_pipeline_expiring_the_handler_budget, which keeps the production budget and expires it inside the pipeline stub. It passes with an 80ms stall on each of reads 1–3. The inherited recovery deadline, which is what the test asserts, is unchanged.test_hung_fetch_has_own_deadline_and_other_results_survive(Parakeet pressure, 20ms) andtest_per_user_budget_exceeded_is_recorded_and_skipped(daily summary, 50ms) needed healthy work to finish inside the budget. Both now use 0.5s. The hung or blocked case still times out, and each test takes about 0.5s longer.test_sync_cloud_tasks.pystage only queued and processing reads, so where the expiry lands does not change their branch. They are left as they are.Test-only; production code is unchanged.
Lane / contract
lessons-audit (two-lane/legacy-retire lead). Not a swarm lane file.
integration/legacy-retirepicks this up at its next main sync.Product invariants affected
none
Verification
Unit layer, m5,
BACKEND_UNIT_TEST_FILE_LIST+backend/test.sh(nice 19):test_sync_cloud_tasks.py(186 passed),test_parakeet_batch_pressure.pyandtest_daily_summary_job_resilience.py(35 + 42 passed);Rollback
Revert the commit (tests only).
Failure-Class: none
🤖 Generated with Claude Code