Repository navigation
Closed
Labels
Milestone
Description
Friction
- On 2026-10-18 one
uv run devops cisat for more than 68 minutes on a single stuck test and never finished. An xdist worker was blocked intests/test_release.py::test_release_cut_pushes_from_remote_release_tip_and_leaves_main_untouched, in thegit_release_repofixture'sgit push -u origin mainto a temporary local bare repository. - The child
git-receive-packwas single-threaded and parked in a futex wait with no CPU time used (utime 0, stime 0, two voluntary context switches). The host load average was about 30 to 50, and another worktree's run of the same test pushed at the same time. Its stack could not be read: the container does not allow ptrace. - Nothing bounds a test. pytest has no per-test timeout, so a hung child process holds the pre-push gate, and every 16-worker xdist process it owns, until a person kills it. The owner's rule is that CI gate speed is P0, with a 5-minute budget.
Evidence
Checked at release/v0.2.37 25e2cda.
[tool.pytest.ini_options](pyproject.toml:149-156) setsaddopts = "-n logical -p no:logfire -p no:pytest_logfire -p no:randomly"and no timeout. pytest-timeout is not inpyproject.tomloruv.lock; the loaded plugins are cov, anyio, hypothesis, mock, asyncio and xdist.- 173 of the 178
subprocess.run,check_output,check_callandPopencalls undertests/pass notimeout, across 33 files (counted with anastwalk). The fixture's calls attests/test_release.py:1916-1945are among them. - The hang outlived its session: the stuck process group was still running more than an hour later, with 17 processes.
Remedy
- Add pytest-timeout (a pytest-dev project) as a dev dependency and set a suite-wide
timeoutin[tool.pytest.ini_options], withtimeout_method = "signal"so a stuck test fails in its own worker,subprocess.runkills its child, and the rest of the run carries on. - Size the timeout from the suite's own data: the slowest tests take 22-50 s under heavy load (ci cache durations). Keep it well above that, as a hang bound, not a speed target. Any test that needs longer says so with
@pytest.mark.timeout(<seconds>). devops ci testand the full gate report a timed-out test as a failure that names the test, like any other failure. No retry is added.- Do not add per-call
timeout=to the 173 calls in this item: the suite-wide bound covers them, and it also covers hangs outside subprocess calls.
Acceptance criteria
- Tests first, offline:
- a
pytesterrun of a test that sleeps past a smalltimeoutfails with pytest-timeout's report, and a following test in the same run passes; - the same under
-n 2, so a timed-out test does not take its xdist worker down or stall the session; [tool.pytest.ini_options]declarestimeoutandtimeout_method = "signal"(read withtomllib).
- a
-
uv run devops cipasses with the timeout set; the summary line shows no test near the bound. -
deptryanduv auditstay green with the new dependency.
Proposed design
Problem statement
A test that hangs causes the CI pipeline to stall indefinitely, as pytest has no built-in per-test timeout mechanism. This leads to long wait times and resource waste when a subprocess call gets stuck, blocking all xdist workers until manually killed.
Acceptance criteria
- Criterion 1: A pytester run of a test that sleeps past a small timeout fails with pytest-timeout's report
Verification: Run a test using pytester that includes a sleep longer than the configured timeout, and verify it fails with pytest-timeout's specific error message - Criterion 2: The same test under -n 2 does not take down its xdist worker or stall the session
Verification: Execute the hanging test with pytest -n 2 and confirm that other tests in the session continue running and the hanging worker is isolated - Criterion 3: [tool.pytest.ini_options] declares timeout and timeout_method = "signal"
Verification: Read the pyproject.toml file and verify that [tool.pytest.ini_options] contains timeout and timeout_method = "signal" settings
Key questions
- What is the current timeout configuration in pytest?: pytest has no per-test timeout configured; it uses default behavior which allows tests to hang indefinitely. [sources: pyproject.toml:149-156]
- How many subprocess calls in the tests directory pass no timeout parameter?: 173 subprocess.run, check_output, check_call and Popen calls in tests/ pass no timeout across 33 files. [sources: tests/test_release.py:1916-1945]
- What are the requirements for adding pytest-timeout as a dev dependency?: pytest-timeout should be added to dev-dependencies and configured with timeout_method = "signal" in pyproject.toml. (proposed) [sources: pyproject.toml:149-156]
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
dan-petty commentedon Oct 18, 2026
Intake placed this item to the backlog: at intake only a critical fix goes into a release; a release start pulls Ready items in, P0 features first.
The change addresses CI infrastructure by adding a timeout mechanism to prevent hanging tests.CI gate speed is P0 priority, and this prevents indefinite hangs that stall the entire CI process.This fix prevents CI failures due to stuck processes, improving developer productivity and CI reliability.Requires adding a new dependency and configuring pytest-timeout, but does not require rewriting existing tests or logic.dan-petty commentedon Oct 18, 2026
Status set to Ready at 25e2cda (see proposed design in issue body).
dan-petty commentedon Oct 19, 2026
Amendment (2026-10-19): folded here by intake under the agent filing quota
The cycle's agent filing allowance (#1153) was used, so
devops roadmap intakefiled nothing and named this item as the nearest. The candidate below is in the same gate (devops ci test) and can land with this item or on its own in a later cycle. The hook-speed investigation of 2026-10-18 recommended it as P0, under the owner's rule that CI gate speed is P0. Candidate title: "fix(ci): devops ci test starts 16 xdist workers for a few covering tests, so each commit's test hook spends about 180 CPU-seconds and 13 s it does not need".Friction
devops ci test <staged paths>inherits-n logical, so even a few covering tests start 16 xdist workers. Each worker imports conftest, runs the session fixtures and collects the whole selection.uv run pytest tests/test_<feature>.pyas the targeted-test command, and about 25 agent worktrees ran such runs next to the gates on 2026-10-17.Evidence
Checked at release/v0.2.37 30b8fdd.
test()builds the pytest command with no-nunless the user passes one (src/devops_cli/commands/ci.py:1388-1399,:1484), soaddopts = "-n logical ..."(pyproject.toml:156) applies.src/devops_cli/security/sarif.py, selecting 264 tests, 3 interleaved runs at load 14-22:uv run devops ci test <file>took 49.8 / 22.5 / 28.0 s (median 28.0 s) and 221 / 201 / 196 CPU-s; with-n 0it took 32.5 / 15.4 / 14.6 s (median 15.4 s) and 33 / 20 / 20 CPU-s.-n 0, 50 s at-n 16and 44 s at-n 4, and-n 4used a third of the CPU of-n 16.devops ci testruns pytest through the syncrun_subprocess(_runatsrc/devops_cli/commands/ci.py:223), whosesubprocess.run(timeout=1800)(src/devops_cli/core/process.py:393-402) kills onlyuv, which left pytest orphaned. xdist kills workers stuck at teardown, so-n logicalhides such hangs.run_subprocess_async, which starts a new session and stops the whole process group on timeout with the guarded helper (src/devops_cli/core/process.py:506-527,:599; fix(security): the async process runner redacts telemetry and kills the process group on timeout #780).Remedy
test(), when paths are given and the user passed no-n, choose the worker count from the selection:-n 0up to a file count set insrc/devops_cli/config/defaults.py(for exampleDEFAULT_CI_TEST_SERIAL_MAX_FILES, calibrated between 5 and 19 files), and a small fixed cap above it (for exampleDEFAULT_CI_TEST_NARROWED_WORKERS = 4).devops cikeep-n logical. The same tests run, and no threshold changes.:108,:134) touv run devops ci test tests/test_<feature>.py, so direct runs get the same sizing.run_subprocess_async, as the gate's checks do, so a timeout stops its whole process group; write no new process-group code. And find the cause of the post-summary hang of a serial run before switching. One candidate is the atexitshutdown_tracertaking_client_lockin the pytest process (src/devops_cli/telemetry/tracer.py:839,:1411,:1634).Acceptance criteria
-n 0for a selection at or under the constant, the capped count above it, the user's-nkept when given, and no-nfor the full suite and the fallback.devops ci test.dan-petty commentedon Oct 19, 2026
Amendment (2026-10-19): folded here by intake under the agent filing quota
The cycle's agent filing allowance (#1153) was used, so
devops roadmap intakefiled nothing and named this item as the nearest. The candidate below is related CI-runner work: a test run that cannot start is reported as clean. It can land with this item or be filed on its own in a later cycle. Candidate title: "fix(ci): fail-to-pass reports a replay pytest could not start as could-not-run, not as zero failed and zero errored".Friction
When pytest cannot start on the replayed base tree,
devops ci fail-to-passreports "0 failed and 0 passed …; 0 errored" and treats that as an outcome. For example, the overlaidtests/import a name the basesrc/lacks, and pytest stops with an INTERNALERROR inpytest_configure.Evidence
At release/v0.2.37 3b70671, with #1312 PR 3 (
feat/1312-support-plugins), whosetests/support/bootstrap.pyimportsdefines_fixture_or_hook, new in that PR'ssrc/devops_cli/core/test_selection.py:tests/,python -m pytest -o addopts= -p no:cacheprovider -q tests/test_test_selection.py) exits 3 withINTERNALERROR> ImportError: cannot import name 'defines_fixture_or_hook'.uv run devops ci fail-to-pass --base origin/release/v0.2.37 --title "feat(test): …"exits 0 and prints "0 failed on base (0 failed and 0 passed in tests/test_analyze.py, … tests/test_test_selection.py; 0 errored)"._run_pytest_on_base(src/devops_cli/ci/fail_to_pass.py). It discards pytest's exit status and returns no outcomes when the JUnit report is missing, so an internal error, a usage error or an interrupted run reads as an empty, clean replay.Remedy
_run_pytest_on_basekeeps pytest's exit status.Fail-to-pass: not applicable: <reason>escape.Acceptance criteria
feattitle and for a defect title. The message names the exit status and the replay, not "at least one changed test to fail".uv run devops cipasses.fix(ci): a hanging test fails at a per-test timeout, and a narrowed d…
fix(ci): fail-to-pass reports a replay pytest could not start as coul…
dan-petty commentedon Oct 20, 2026
What changed
#1718, merged into
release/v0.2.37as f7aef65.12 file(s) changed.
How it was verified
Check runs at 2e3ebd2:
Acceptance Criteria of
docs/agent/tasks/task-1669-ci-runner-never-stalls.md:tests/test_per_test_timeout.py::test_a_hanging_test_fails_at_the_timeout_and_the_next_test_passes, apytesterrun in a subprocess under a 1 s signal timeout). It failed first because thepytest_timeoutplugin could not be imported.-n 2 --dist loadfile: the worker that ran the hanging test reports pytest-timeout's failure and runs the next test itself, so no worker went down (test_a_hanging_test_under_xdist_fails_without_taking_its_worker_down).[tool.pytest.ini_options]declarestimeout, aboveTHREAD_HANDOFF_BOUND_SECONDSand under halfDEFAULT_SUBPROCESS_TIMEOUT_SECONDS, andtimeout_method = "signal", read withtomllib, and the running session has the plugin loaded with those values (test_the_suite_bounds_every_test_with_a_signal_timeout_between_its_waits_and_its_run); with-p no:timeoutit fails.uv run devops cipasses with the timeout set, and its summary shows no test near the bound: the slowest took 19.3 s against 600 s.-ngets-n 0; the full suite and the fallback pass no-n; a given-n 3is kept (tests/test_test_selection.py::test_a_narrowed_run_chooses_its_workers_and_the_full_suite_keeps_addopts). A selection ofDEFAULT_CI_TEST_SERIAL_MAX_FILEStest modules runs serially and one more onDEFAULT_CI_TEST_NARROWED_WORKERSworkers (test_a_selection_past_the_serial_limit_runs_on_the_capped_workers). Both read-nfrom the argv the stdlib double received.devops ci test, narrowed or whole, starts pytest in a session of its own, never throughsubprocess.run, and leavesdevops_cli.commands.ciwith no runner name a later test's patch would miss (test_the_test_run_starts_pytest_in_a_session_of_its_own).tests/test_ci.py::test_a_test_run_past_its_timeout_fails_naming_its_command_and_timeout), and a hung run is stopped at its bound with its whole group, SIGTERM first, asdevops ci's checks were (tests/test_process.py::test_a_timed_out_check_is_stopped_with_sigterm_first_and_reports_as_before).devops ci test, and a fake pytest that prints its summary and then hangs with a grandchild is stopped with its whole group at its bound (test_a_run_that_hangs_after_its_summary_line_is_stopped_at_its_bound_with_its_group). No hang after the summary reproduced in 21 serial runs, and the tracer's client lock was ruled out as a cause.devops ci testforwards SIGINT to the run's group, whose fakeuvthen runs its teardown, stops the whole group and exits 130 (test_a_signal_to_devops_ci_test_lets_pytest_tear_down_then_stops_its_group); against the code before the stop sequence, the teardown never ran for any of the three.test_a_second_signal_to_devops_ci_test_cannot_skip_the_sigkill, and in-processtest_a_further_cancellation_during_the_stop_cannot_skip_its_sigkill); before, the group was left running, and a stop that absorbs the second cancellation and still sends SIGTERM fails them.test_a_cancelled_run_stops_its_whole_process_group,test_a_cancelled_run_sends_its_group_sigint_first_so_its_teardown_runs,test_a_cancellation_while_the_child_starts_still_stops_its_group,test_a_cancellation_after_the_child_exited_stays_a_cancellation,test_a_cancellation_after_the_child_exited_still_stops_the_members_left); the middle three failed against the earlier stop, and a stop skipped once the leader has exited fails the last. A child that leads no session of its own fails every one of them.test_a_run_takes_over_sigterm_and_sighup_and_hands_them_back,test_a_run_off_the_main_thread_sets_no_signal_handler,test_an_ignored_hangup_stays_ignored_through_a_run). Mutants that skip the hand-back or set handlers from any thread fail them.uv run devops ci test src/devops_cli/security/sarif.py(5 test modules, 264 tests), three runs each, interleaved, at a load average of 0.9-5.8: 10.6 s and 12.1 CPU-s against 17.7 s and 182.5 CPU-s with-n logical, a fifteenth of the CPU and faster.devops ci test: its verification step and its commands table giveuv run devops ci test tests/test_<feature>.py.deptryanduv auditstay green with the new dependency.tests/test_fail_to_pass.py:test_a_replay_pytest_could_not_start_fails_the_check_for_any_pull_requestreplays with a pytest that exits 3 with anINTERNALERROR>traceback and no JUnit report, for afeatand afixtitle. Before, the feature exited 0 with "0 failed on base (0 failed and 0 passed in tests/test_mod.py; 0 errored)." and the defect exited 1 with "Defect PR requires at least one changed test to fail"; both now exit 1 with the message naming status 3,tests/test_mod.pyand the traceback's last lines, the whole output checked against its snapshot.test_a_replay_that_stopped_or_wrote_no_report_could_not_runcompares the wholemodel_dump()and the report's snapshot for exit 2 with a report holding a passing test, exit 3 with pytest'spytest::internalreport, exit 4 with an empty report, a killed run with no report, and exit 1 with an empty and with a truncated report. The exit-2, exit-4 and killed cases failed before this PR (could_not_runabsent, the check satisfied). The empty and truncated reports failed before the parser tracked its root: the check satisfied,could_not_runNone, and the truncated report's passing test kept. Withfrozenset({2, 4})as the could-not-run statuses, the exit-3 case fails (satisfiedTrue), where every other test still passed.test_a_replay_that_could_not_run_keeps_the_last_whole_lines_within_the_boundkeeps the last 6 of 40 lines, the last 256 characters of one 315-character line, and all three of three lines that fill the 256 characters exactly; a slice one character short (printed[-256:]) keeps two of those and fails it.test_a_replay_that_could_not_run_prints_pytest_s_output_as_it_isprints a usage error's[options] [file_or_dir] [file_or_dir] [...]andPATH=src:x:tests and a:b:cas pytest wrote them. Before this PR it exited 0; withprint_error(..., safe=True)the second case failed, Rich printing an emoji for:x:, and withoutsafe=Truethe first did.test_a_replay_that_collects_and_runs_reports_its_outcomes), exit 5 stays an empty replay for a feature and a defect (test_a_replay_that_collects_no_tests_is_an_empty_replay), and the not-applicable line passes a replay whose pytest would exit 3 without starting it (test_the_not_applicable_line_wins_over_a_replay_that_could_not_run); each passed before and after.uv run devops ci fail-to-pass --base origin/release/v0.2.37 --head origin/feat/1312-support-plugins --title "feat(test): …"exits 1: "The fail-to-pass replay could not run on base: pytest exited with status 3 replaying tests/test_analyze.py, … tests/test_test_selection.py." and "pytest's last output: INTERNALERROR> ImportError: cannot import name 'defines_fixture_or_hook' …".uv run devops cipasses with PR 2's change on top of PR 1: every check green, coverage 92.6%, the run 2 m 47 s, its test step matching the 10 snapshots.fix(ci): the fail-to-pass check runs only on pull requests into a rel…
fix(ci): the fail-to-pass check runs only on pull requests into a rel…
perf(ci): the gate's test workers steal work and Bandit runs under ni…
feat(release): v0.2.38 (#1799)
feat(release): v0.2.38 (#1798)