Repository navigation
Fix harness descriptor leak, slot deadlock, and corpus memory sizing - #4709
Conversation
`with sqlite3.connect(path) as conn` manages a transaction, not the connection: the descriptor survives the block until collection. Forty-seven production sites used that form, so a long process accumulated descriptors until it hit its limit, and the call that failed was whichever ran next. `sqlite_connection` keeps the commit-or-rollback semantics and closes. Measured on `initialize_active_archive_root`: 3 leaked descriptors per call before, 0 after. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01DNGJ3awfNrsLaMdHgQZvid
`devtools verify --all` inside the declared verify_all job enqueued a second pytest-group task and waited for it. The group runs one task at a time and the job held it, so nothing drained until the job was killed by hand. The queue runner exports no variable naming the job's pool, and the pool's systemd slice is not visible from every host configuration, so neither the environment nor the cgroup classified the process. The launch document does: the runner is an ancestor and carries the document's path as its final argument. Verified against two live queue tasks. Also: a red static gate no longer hides pytest state (pinned by test), and an absent .venv is reported as an unprovisioned environment with its remedy rather than as a missing ruff. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01DNGJ3awfNrsLaMdHgQZvid
Two full corpus runs were killed by the out-of-memory daemon at about 6.2 GB peak while the desktop and other lanes were resident. The width was fixed at eight regardless of what was free, so the run assumed memory that was not there; a killed run measures nothing. Width is now derived from MemAvailable at run start, using the workload's measured per-process peaks (worker 686 MiB, controller 1075 MiB) and a fifth left as headroom, floored at one worker and never above CORPUS_MAX_WORKERS. The basis is reported, so the width is evidence rather than a silent policy. Measured on this host under lane load: 4707 MiB available yields 3 workers; eight would have needed about 6.5 GiB, which is the peak that was killed. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01DNGJ3awfNrsLaMdHgQZvid
Counting around the teardown wrapper puts the check after fixture finalizers, so what remains is genuinely retained, and raising there marks the leaking item's teardown rather than the next test's setup. Verified against a live session: a test opening 30 unclosed connections is reported as ERROR on itself and the test after it passes. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01DNGJ3awfNrsLaMdHgQZvid
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01DNGJ3awfNrsLaMdHgQZvid
A per-test bound alone would not have caught the 2026-09-05 cascade: it retained about three descriptors per test across hundreds of tests, under any workable single-test threshold, and surfaced only as EMFILE in eleven unrelated victims. Exhaustion now reports the largest cumulative retainers alongside the victim, so the report points at the cause. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01DNGJ3awfNrsLaMdHgQZvid
A queued run can wait hours behind the single pytest slot, so a width chosen when the command was built describes memory that is no longer there. The sizing moves to devtools/worker_memory.py and is applied in the slot runner, where the workers actually start, and the narrowing is written to the run log. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01DNGJ3awfNrsLaMdHgQZvid
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01DNGJ3awfNrsLaMdHgQZvid
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Team Run ID: Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 03ecfe8904
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
## Summary Fixes the two reds in `tests/unit/devtools/test_verify.py`. One was a real defect (inherited, not from #4709); one was a stale expectation from #4709. ## Which was which Measured, not assumed. Both tests were run at `d430734f1`, the commit immediately before #4709 merged, with `devtools` and `tests` both checked out at that commit: - `test_accepted_flake_clears_both_recorded_exit_statuses` **fails identically there**. It is inherited and predates #4709. The `relative_to(ROOT)` call it trips over came from #4536. - `test_missing_checkout_venv_tool_is_a_typed_failure` **passes there**. That one is #4709's, and it is a stale expectation rather than a defect: an absent `.venv` now reports `gate_unprovisioned_environment` instead of `gate_missing_executable`, which is the intended distinction and is what the new test in #4709 asserts. So the rerun routing through `run_pytest` is not implicated; it arrived in #4581 and is unchanged here. ## Problem `_rerun_failed_once` formats its receipt with `rerun_report.relative_to(ROOT)`, which raises `ValueError` when the step directory is outside the checkout — a configured basetemp root, or any caller supplying its own artifact directory. A rerun that had already adjudicated its flakes correctly then died formatting its own path, and no rerun result was recorded at all. ## Solution Report the path relative to the checkout when it is inside one, absolute otherwise. Split the venv test into both conditions so the original coverage (a provisioned venv missing one tool) survives beside the new one (no venv at all). ## Verification `POLYLOGUE_ALLOW_BARE_PYTEST=1 POLYLOGUE_PYTEST_RUN_ID=x .venv/bin/python -m pytest tests/unit/devtools/test_verify.py -p no:randomly --override-ini=addopts=` — **41 passed**, redirected to a file and read, not piped. ## Residuals - A third red was reported in this file; only these two reproduce at master (`04e297bbc`). If the third is real it is ordering-dependent and not visible in a full run of the file. - The static quick gate ran green via the pre-push hook; the focused run above is the test evidence. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01DNGJ3awfNrsLaMdHgQZvid Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
…ugh agentctl (#4681) Slot ownership is the pytest pool, and a focused run enters it through the declared `pytest_focused` operation instead of a private pueue client. The descriptor gains the `verify` table and `publish` mode agentctl reads, and drops the keys it does not. Merged with master's pool-classification work rather than competing with it: ownership accepts the pool cgroup, the exported pool name, or the enclosing job's declared pool from the launch document, so the deadlock fix in #4709 survives here. Folds #4689 (descriptor cleanup) and #4686 (docs). Also stops the progress-plugin subprocess writing its pytest cache to /realm: its selection names a file under the temporary directory, so the child resolved rootdir to the lake root. ## Evidence Ran, on this head: - `tests/unit/devtools/test_pytest_slot.py`, `test_pytest_slot_pool_classification.py`, `test_agent_env.py`, `test_agentctl_service_context.py`: 76 passed. This is the changed mechanism, both sides of the merge. - `tests/unit/devtools`: 326 passed before stopping at the one failure below. - All thirteen static gates, through the commit hook. Did not run: the corpus, and the hosted `verify` check, which is disabled repository-wide since 21:06 on 2026-09-05. Four failures in `tests/unit/devtools` are master's, not this branch's, confirmed by running master's own `devtools/verify.py`, `run_tests.py`, `required_gate.py` and `worker_memory.py` inside this worktree and reproducing each one. Filed as polylogue-s9klx. This branch fixes three other failures that master's files show here. A second full `tests/unit/devtools` sweep under concurrent corpus load hit a thread-hang timeout and is not counted as evidence either way. --------- Co-authored-by: Claude Fable 5.1 <[email protected]>
|
Closing out open Codex review threads on this PR (evidence checked against master at ef10e59):
Resolving the fixed, stale and refuted threads; tracked threads stay open. |
|
Closing out open Codex review threads on this PR (evidence checked against master at 64a9bd0):
Resolving every thread listed; confirmed defects are fixed under the named bead. |
|
Closing out open Codex review threads on this PR (evidence checked against master at bf68918):
Resolving every thread listed; confirmed defects are fixed under the named bead. |
Summary
Four test-harness defects that slow every lane, fixed at their causes.
Problem
Descriptor leak (polylogue-uvx0q). Eleven tests in one xdist worker died
with
OSError: [Errno 24]andunable to open database file. None of themleaked:
with sqlite3.connect(path) as connmanages a transaction, not theconnection, so the descriptor survives the block until collection. Forty-seven
production sites used that form. Measured on
initialize_active_archive_root:3 leaked descriptors per call. The victim is whichever test runs when the table
fills.
Slot deadlock (polylogue-9dbqu). The declared
verify_alljob randevtools verify --all, whose pytest step enqueued a second pytest-group taskand waited for it. The group runs one task at a time and the job held it, so
nothing drained for 30 minutes. The queue runner exports no variable naming the
job's pool and the pytest slice is not visible from every host configuration,
so neither the environment nor the cgroup classified the process.
Gate independence (polylogue-w3at6). The abort-on-first-red behaviour was
already fixed by #4508; nothing pinned it, so it could regress silently.
Corpus killed (polylogue-b054.1.1.2). Width was fixed at 8 regardless of
free memory; two corpus runs were killed by systemd-oomd at ~6.2 GB peak.
Unprovisioned worktree (polylogue-8dfcy). A checkout with no
.venvreported
gate_missing_executablefor an installed ruff, naming neither causenor remedy.
Solution
sqlite_connectionkeeps commit-or-rollback semantics and closes; all 47sites converted.
exhaustion names the largest cumulative retainers. A per-test bound alone
would not have caught this cascade — it retained ~3 descriptors per test
across hundreds of tests — so the report points past the victim.
holds_pytest_slotreads the pool from the launch document carried by thequeue-runner ancestor. Verified against two live queue tasks.
MemAvailableusing the workload's measuredper-process peaks, decided inside the slot: a queued run can wait hours, so
a width chosen when the command was built describes memory that is gone.
.venvis reported asgate_unprovisioned_environmentwith thedevshell command, and explicitly warns against sharing another checkout's
venv (its editable install would run that tree's product).
Verification
devtools verify --quick— green, all 13 gates,exit_code: 0:devtools render all --check— noout of synclines.Leak fix measured directly:
initialize_active_archive_root× 10 leaks 30descriptors before, 0 after. Guard attribution verified in a live pytest
session: a test opening 30 unclosed connections is reported as
ERROR ...::test_leaksand the following test passes.Width sizing measured live: 4707 MiB available yields 3 workers, 5210 MiB
yields 4; eight would need ~6.5 GiB, the peak that was killed.
Residuals
lanes' jobs when this PR was opened; the required
verifycheck runs it.needs a full corpus run to confirm end to end; that has not been done here.
import baseline measures 137 MiB RSS, so import trimming could recover at
most ~1 GiB of a 6.2 GB peak and cannot by itself prevent the kill.
🤖 Generated with Claude Code
https://claude.ai/code/session_01DNGJ3awfNrsLaMdHgQZvid