Repository navigation
Description
Problem Description
Three tests of tests/roadmap/refine/test_roadmap_refine_failure_class.py wait for real on the retry backoff of the model client:
test_the_next_round_skips_the_item_until_the_time_passes_and_takes_the_others: 30.3 stest_a_timeout_records_class_step_and_time_and_does_not_mark_the_item_as_at_fault: 15.2 stest_a_success_clears_the_three_keys: 15.2 s
(GitHub runner, shard 2 of run 42938256840 on main, 2026-11-11.) The times are the same on a loaded local host (median 31.5 s, max 32.2 s for the first test over 8 local gate logs), so they are waits, not work.
The cause: the shared fixture scripted_gateway (tests/support/roadmap_refine.py) asks for the shared clock fixture (tests/support/fakes/clock.py, a ClockFake), and its docstring says "Retries wait no time: the clock fixture answers each wait". But the test module defines its own fixture with the same name clock, a bare time_machine.travel(START, tick=False). The module fixture shadows the shared one, so time.sleep and the clock seam are not replaced, and each failing round sleeps through the real backoff of the 5 attempts (about 15 s).
Reproduction Steps
- Run
uv run pytest tests/roadmap/refine/test_roadmap_refine_failure_class.py -n0 --durations=5. - Read the times of the three tests above.
Expected vs Actual Behavior
Expected: each test takes well under 1 s, because ClockFake answers each retry wait at once.
Actual: 15 s for each failing round, 60 s for the three tests together.
Proposed fix
Build the module fixture on the shared one: request the shared clock (ClockFake) and move it to START with ClockFake.move_to. ClockFake.shift takes the same timedelta the tests pass now. Then assert in one test that the retries recorded their waits in clock.waits, so the shadow cannot come back without a failure.
Environment Diagnostics
GitHub-hosted ubuntu-26.04 runners and the devcontainer on WSL2.
Logs, Traces, or Terminal Output
Found by the measurement of #4405.
Pre-Submission Checklist
- I have verified that no sensitive credentials, private keys, or internal tokens are contained in this issue report.
- I have checked existing issues and pull requests to ensure this is not a duplicate.
Proposed design
Problem statement
The three refine failure tests wait on the real retry backoff. A module clock fixture shadows the shared ClockFake fixture, so time.sleep is not replaced. Each failing round sleeps about 15 seconds, and the three tests take about 60 seconds together. The change makes the module use the shared fake clock and records the retry waits.
Acceptance criteria
Requirement: The module uses the shared fake clock
The failure-class module SHALL use the shared ClockFake fixture for its clock parameter and SHALL move that fake to START before each test.
Scenario: A test requests the module clock
- WHEN a test in the failure-class module requests the
clockfixture - THEN the test receives a
ClockFakewhose wall clock readsSTARTand whosewaitslist is empty.
Requirement: A failing round records retry waits
A refine round that exhausts the gateway retries SHALL append each retry wait to clock.waits and SHALL NOT call the real time.sleep.
Scenario: A gateway timeout exhausts the retries
- WHEN a test scripts
TIMEOUTfor one item and runs one refine round - THEN
clock.waitsis not empty after the round.
Requirement: The timeout test guards the fake clock
The timeout test SHALL assert that clock.waits is not empty after the failing round.
Scenario: The timeout test runs
- WHEN
test_a_timeout_records_class_step_and_time_and_does_not_mark_the_item_as_at_faultruns - THEN the test fails if the module shadows the shared
ClockFake.
Existing Tool Considered
No alternatives check has run. The open, maintained time-machine library, through the project's existing ClockFake fixture in tests/support/fakes/clock.py, covers the need. It lacks nothing for this test fix. The change writes no production code.
Key questions
- How should the module fixture use the shared
clockfixture without shadowing it?: Replace the moduleclockfixture with an autouse fixture that requests the sharedclock, moves it toSTART, and leaves the sharedClockFakefor the tests. (best practice) [sources: tests/support/fakes/clock.py, tests/roadmap/refine/test_roadmap_refine_failure_class.py, tests/support/roadmap_refine.py]- Chosen: Autouse wrapper over the shared clock. It moves the shared ClockFake to START and keeps the shared fake for every test.
- Rejected: Keep the module time_machine traveller. It shadows the shared ClockFake and leaves real retry sleeps in place.
- Rejected: Move the clock in every test. It repeats setup in each test and is easy to omit.
- How should one test prove that retries use the fake clock?: Add an assertion in the timeout test that
clock.waitsis not empty after the failing round. (best practice) [sources: .ast-grep/rules/test-elapsed-upper-bound.yml, tests/support/fakes/clock.py, tests/roadmap/refine/test_roadmap_refine_failure_class.py]- Chosen: Assert
clock.waitsis not empty. The shared fake records every retry wait, so a shadowed fixture fails the assertion. - Rejected: Assert an elapsed time upper bound. A loaded machine makes elapsed time longer, and the rule pack rejects this assertion.
- Rejected: Assert no clock use. It does not prove that retries pass through the fake clock.
- Chosen: Assert
- Does
ClockFake.shiftaccept thetimedeltavalues that the tests pass?: Yes.ClockFake.shiftacceptsfloat | timedeltaand advances both the wall and monotonic clocks. [sources: tests/support/fakes/clock.py] - Which type should the tests use for the
clockparameter?: UseClockFakefromtests.support.fakes.clock, because the shared fixture yields that type. [sources: tests/support/fakes/clock.py, tests/support/roadmap_refine.py]
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Activity
dan-petty commentedon Nov 11, 2026
Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.
fixprefix of the title gives the type.test, and .github/labels.yml declares no scope/test label. Add the label to the file to give the scope to this item.Wastes 60 s of CI time per run but does not block correctness.Saves CI wall-clock time and removes host-load dependency from three tests.Rebuild one module fixture on the shared ClockFake and add one assertion.Both address tests waiting on real time; #1320 is the system-wide refactor for time control, the candidate fixes one module's fixture shadowing.devops-cli-service commentedon Nov 11, 2026
Status set to Ready at c653bde (see proposed design in issue body).
dan-petty commentedon Nov 11, 2026
Scope from the CI audit (2026-11-11)
Another session works on this issue now. This comment only adds the measured cause.
tests/roadmap/refine/test_roadmap_refine_failure_class.pytake 30.53, 15.17 and 15.12 s in CI (measured). tenacity callsdevops_cli.core.clock.sleepfor real. The clock fixture of the file (lines 57-61) only moves the time.ClockFakefixture (tests/support/fakes/clock.py). It answerscore.clock.sleepandtime.sleep.