Skip to content

Own and bound managed pytest scratch - #4130

Merged
Sinity merged 3 commits into
masterfrom
feature/test/storage-budget
Aug 24, 2026
Merged

Sinity merged 3 commits into
masterfrom
feature/test/storage-budget

Conversation

@Sinity

@Sinity Sinity commented Aug 24, 2026

Copy link
Copy Markdown
Owner

Summary

  • give every managed pytest invocation a unique NVMe-backed scratch lease
  • measure apparent, allocated, file-count, high-water, and shared-extent usage in verification receipts
  • reclaim successful runs and retain bounded, ownership-safe failure evidence
  • terminate owned pytest process groups before releasing their scratch lease
  • fail closed on workstation /tmp fallback while preserving explicit cloud-sandbox behavior

Why

The prior shared scratch tree retained about 15.5 GB across runs and could not safely support tmpfs. A sampled recovery fixture was about 1.20 GB apparent/allocated with 1.12 GiB shared extents, so sparse-file assumptions were false and blindly copying fixtures would multiply storage. Managed per-run leases make cleanup deterministic without reducing test scope or fixture semantics.

The independent review found and fixed three high-severity lifecycle defects: interrupted runners could release a lease while pytest workers survived; concurrent stale cleanup could race PID reuse; and a missing NVMe root could silently spill onto /tmp tmpfs. It also bounded failure-artifact scanning/copying and made incomplete high-water scope explicit.

Verification

  • pytest -q tests/unit/devtools/test_pytest_progress_plugin.py tests/unit/devtools/test_pytest_scratch.py tests/unit/devtools/test_run_tests.py tests/unit/devtools/test_verify.py — 66 passed
  • pytest -q tests/unit/devtools/test_pytest_scratch.py — 11 passed after the type-safe test-double correction
  • pre-push maintained quick gate — green (Ruff format/check, mypy, render, layering, command/docs/schema/oracle/privacy gates)
  • independent Luna review commit — focused suite 66 passed; signed commits verified

The complete 16-worker suite will run once on merged master so it covers this storage lifecycle together with the just-merged shared-Chrome work.

Storage contract

  • test coverage and incident-fixture semantics are unchanged
  • old scratch is intentionally not deleted by this PR; it will be removed only after merged-master equivalence is green
  • retained failure artifacts are capped at 64 MiB and copied without following symlinks
  • raw test trees remain NVMe-backed; current evidence does not support tmpfs

Ref: polylogue-k1o3t.

Sinity added 3 commits August 24, 2026 04:29
Problem: managed pytest could retain a shared basetemp indefinitely, allowing one run to collide with another and leaving incident-scale trees behind.

What changed: allocate a measured per-run, per-lane scratch lease; retain bounded failure artifacts; reclaim dead and empty lease containers; and emit per-test and per-worker storage facts.

Compatibility: managed devtools pytest now owns --basetemp so callers cannot route it to a shared path.
Problem: managed pytest cancellation could leave a live child writing into a lease that a later run reclaimed, while failure diagnostics and high-water receipts were vulnerable to races or overstated their scope.

What changed: run pytest in an owned process group, serialize lease creation and pruning, bind cleanup to a lease token, bound no-follow diagnostic copies, preserve signal-specific cancellation, and expose explicitly scoped scratch metrics through the run receipt.

Compatibility: devtools test and devtools verify continue to own --basetemp; standalone coverage, SLO, CI, and benchmark workflows remain separate direct-run boundaries.
Patch subprocess and process-group calls through pytest's dotted-path API so the behavioral test does not expose private module imports as public attributes.

Verification: pytest tests/unit/devtools/test_pytest_scratch.py.
@coderabbitai

coderabbitai Bot commented Aug 24, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 62d8f2c1-8a6c-459e-8e58-3c4dc9669a92


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7e29bb1db9

ℹ️ 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".

Comment thread devtools/pytest_scratch.py Resolved
Comment thread devtools/run_tests.py Resolved
Comment thread devtools/pytest_scratch.py Resolved
Comment thread devtools/pytest_scratch.py Resolved
Comment thread devtools/pytest_scratch.py Resolved
@Sinity
Sinity merged commit 3b4ee25 into master Aug 24, 2026
3 checks passed
@Sinity
Sinity deleted the feature/test/storage-budget branch August 24, 2026 02:43
Sinity added a commit that referenced this pull request Aug 26, 2026
## Summary
Deletes the verifier's duplicate host-process, scratch, and worktree
authority (polylogue-agentctl.2.1): −1198 LOC of local supervision,
scratch leases/admission, resource placement, and stall detection. The
verifier keeps pytest semantics; process/resource/scratch governance
lives in the AgentCTL operation descriptors that already run every
corpus and lane verification.

## Problem
Two authorities governed the same execution: verifier-local
leases/supervision (transitional, #4130-era) and AgentCTL's declared
operations (pool, scratch, admission, timeouts). One canonical route per
the repo contract.

## Verification
- Focused verify/testmon suites updated for the reduced surface; deleted
tests belonged exclusively to deleted authority. Quick gate at harvest.
- Deliberate consequence: bare local `devtools verify --all` carries no
host supervision — the governed route is the declared `verify_all`
operation, as practiced.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_014BQsaB1NBY8mTR6yZByfMA
@Sinity

Sinity commented Sep 28, 2026

Copy link
Copy Markdown
Owner Author

Codex review threads on this PR whose cited code is gone (checked against master at 23f91a5):

Resolving these threads.

@Sinity

Sinity commented Sep 29, 2026

Copy link
Copy Markdown
Owner Author

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.

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.

1 participant