Skip to content

fix: budget pytest tmpfs from measured cgroup overhead - #3948

Merged
Sinity merged 21 commits into
masterfrom
feature/fix/tmpfs-resource-budget
Aug 11, 2026
Merged

fix: budget pytest tmpfs from measured cgroup overhead#3948
Sinity merged 21 commits into
masterfrom
feature/fix/tmpfs-resource-budget

Conversation

@Sinity

@Sinity Sinity commented Aug 11, 2026

Copy link
Copy Markdown
Owner

Summary

Make the managed pytest harness select, supervise, and reclaim test storage from measured process, cgroup-overhead, basetemp, host-headroom, and filesystem envelopes.

Problem

The previous policy could admit a tmpfs cap from predicted demand while ignoring the larger allowed cap, and it could double-count or omit the cgroup charge around tmpfs pages. Broad suites then either filled shared memory or refused under misleading arithmetic. Real xdist progress was also written to per-worker event files that the live stall supervisor did not read, while nested benchmark pytest could consume tmpfs without that supervisor enforcing the cap. Explicit basetemp roots below /dev/shm bypassed the common budget, and legacy read-only fixture trees could survive the stale-directory sweep indefinitely.

Solution

Use the observed 6,278,623,232-byte cgroup peak, separate fixed process/cgroup overhead from adjustable tmpfs demand, and cap host capacity by the smallest remaining ancestor cgroup allowance. Worker-memory admission remains active for explicit scratch roots. Focused tests retain bounded tmpfs by default. Full-suite and seed-testmon runs default to NVMe scratch because the fixture tree can exceed the supervised 2 GiB tmpfs ceiling; an explicit tmpfs broad run remains bounded.

The live supervisor reads both per-worker event files and the merged event artifact, so flowing controller output cannot mask wedged workers. Nested benchmark pytest preserves managed admission and run identity while using scratch because its parent is not a pytest supervisor. Explicit /dev/shm roots now use the same cap and cleanup path. Stale basetemp ownership binds PID plus process-start identity, and stale read-only fixture publications are made owner-writable only after liveness adjudication so cleanup can finish.

The full-suite diagnostic also exposed a test fixture that created current durable tier files without fresh-bootstrap authority. The mutation-actuator fixture now initializes the active archive through the production bootstrap route.

Verification

  • direnv exec . devtools test tests/unit/devtools/test_verify.py tests/unit/test_pytest_temp_policy.py tests/unit/operations/test_mutation_actuators.py: 216 passed in 28.12s
  • direnv exec . devtools test -k managed_pytest_policy_bounds_explicit_tmpfs_root: 1 passed, 21,312 deselected
  • direnv exec . devtools test tests/unit/devtools/test_run_tests.py tests/unit/test_pytest_temp_policy.py: 33 passed in 1.91s
  • direnv exec . devtools verify --quick: all 25 steps passed in 108.08s at a0da69269458fdd7c90b717109434f05df8ac603
  • A scratch-backed seed-testmon diagnostic collected 21,313 nodes and ran for 1,492 seconds without tmpfs termination. It exposed 125 genuine failed calls before intentional termination because the branch had changed and the 45-minute cap could not produce an exact-head terminal receipt. Those reds remain repair work; they were not silenced or treated as a passing baseline.
  • The real-process progress-stall regression writes only gw0.jsonl while continuously emitting output; it is terminated by the progress timeout rather than the output-silence timeout.
  • Exact-head automated review is requested for a0da69269458fdd7c90b717109434f05df8ac603.

@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Pytest verification now parses all supported xdist worker forms, applies measured resource budgets, selects basetemp storage from demand, manages nested benchmark runs, and reads progress artifacts from repository-anchored configurable paths.

Changes

Pytest resource policy

Layer / File(s) Summary
Worker requests and artifact flow
devtools/verify.py, devtools/run_tests.py, tests/unit/devtools/test_run_tests.py, tests/unit/devtools/test_verify.py
Worker parsing supports all listed xdist forms. Parsed concurrency and suite scope reach runtime policy and workload receipts. Progress readers and writers use configured event paths rooted at the checkout.
Cgroup memory headroom
polylogue/core/metrics.py, tests/unit/core/test_metrics_cgroup_memory_limits.py
The new reader calculates finite cgroup headroom across hierarchy levels and returns zero when finite-limit usage cannot be read.
Measured runtime budgeting
devtools/verify_runs.py, tests/unit/devtools/test_verify.py
Runtime policy uses measured memory envelopes and worker-aware reserves. It computes worker capacity and predicted tmpfs demand, validates explicit worker counts, and serializes the prediction.
Managed basetemp and nested runs
devtools/verify_runs.py, devtools/verify_slos.py, tests/conftest.py, tests/unit/test_pytest_temp_policy.py, TESTING.md, CLAUDE.md, tests/unit/operations/test_mutation_actuators.py
Managed policy selects scratch or tmpfs from configured and predicted demand. Bare pytest runs normalize leaked settings. Stale cleanup validates process identity and removes read-only trees. Benchmark children receive managed policy settings.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant PytestCommand
  participant Verify
  participant RuntimePolicy
  participant CgroupMetrics
  participant BasetempPlacement
  PytestCommand->>Verify: provide worker options and suite scope
  Verify->>RuntimePolicy: pass policy overrides
  RuntimePolicy->>CgroupMetrics: read cgroup memory headroom
  CgroupMetrics-->>RuntimePolicy: available memory
  RuntimePolicy-->>Verify: worker count and predicted demand
  Verify->>BasetempPlacement: evaluate configured and predicted demand
  BasetempPlacement-->>Verify: select tmpfs or scratch
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 17.72% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly identifies the primary change: budgeting pytest tmpfs using measured cgroup overhead.
Description check ✅ Passed The description includes the required summary, problem, solution, verification, and bead disposition details; omitted optional sections are not needed.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/fix/tmpfs-resource-budget

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: 90af040608

ℹ️ 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/verify_runs.py Outdated
Comment thread devtools/verify_runs.py Outdated
Comment thread devtools/verify_runs.py Outdated
Comment thread devtools/verify_runs.py Outdated

@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: 17703e74be

ℹ️ 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/verify.py
Sinity added 5 commits August 11, 2026 11:07
Problem: the ce4dd62 full suite had 15,190 MiB available but the 10 percent tmpfs heuristic imposed a 1,519 MiB cap and terminated the run at 1,521.6 MiB.

What changed: reserve host and command-worker headroom before deriving the bounded tmpfs cap, and pass the parsed pytest concurrency into that admission decision. The monitor remains active and low-headroom commands fail before launch.
Problem: xdist option parsing under-reserved several production command forms, and a 768 MiB per-worker estimate admitted a four-worker run on a 4 GiB host despite the measured process, tmpfs, and cgroup envelope.

What changed: parse all supported xdist spellings, reserve logical CPU concurrency for auto, and derive admission from the measured four-worker envelope. The cgroup measurement already includes tmpfs charging, so admission uses it as a composite bound while separately constraining a proposed tmpfs cap.
Problem: the four-worker resource measurements were divided into worker-only
costs, so default selection, low-worker admission, and basetemp placement
could disagree at launch.

What changed: retain fixed controller and cgroup components, scale only the
marginal worker cost, reserve the full-run basetemp as aggregate demand, and
compare inherited tmpfs caps before selecting the basetemp root.

The default selector now uses the same envelope as launch admission, including
the conservative ceiling of the observed 1,521.6 MiB basetemp peak.
@Sinity
Sinity force-pushed the feature/fix/tmpfs-resource-budget branch from 17703e7 to fb74235 Compare August 11, 2026 09:16
@Sinity

Sinity commented Aug 11, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@devtools/verify_runs.py`:
- Around line 677-680: Remove the unconditional PytestResourceError for a
missing or unreadable /dev/shm in the resource-admission flow, while preserving
worker-memory checks and disabling tmpfs usage. Ensure
apply_managed_pytest_runtime_policy continues to resolve placement through
resolve_pytest_basetemp_root so scratch is selected when capacity permits, and
add coverage for this unavailable-tmpfs path.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 4ef9c4b0-a766-4938-bde5-07df2b93d056

📥 Commits

Reviewing files that changed from the base of the PR and between 9510463 and fb74235.

📒 Files selected for processing (4)
  • devtools/verify.py
  • devtools/verify_runs.py
  • tests/unit/devtools/test_run_tests.py
  • tests/unit/devtools/test_verify.py

Comment thread devtools/verify_runs.py Outdated

@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: fb74235e0f

ℹ️ 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/verify_runs.py Outdated
Comment thread devtools/verify.py
@Sinity

Sinity commented Aug 11, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@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: efe9b8f282

ℹ️ 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/verify_runs.py Outdated
@Sinity

Sinity commented Aug 11, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@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: 8e7b431a3b

ℹ️ 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/verify_runs.py
Comment thread devtools/verify_runs.py Outdated
Sinity added 2 commits August 11, 2026 11:41
Clamp inherited tmpfs limits to the measured host-safe policy, account serial pytest runs without inventing an xdist worker, and route unsupervised bare pytest basetemps to NVMe scratch.\n\nAdd production-route regression coverage for each admission boundary.\n\nCo-Authored-By: OpenAI Codex <noreply@openai.com>
Cap pytest admission by the smallest remaining ancestor cgroup allowance, keep worker-memory checks active for explicit basetemp roots, and reserve the measured full-suite basetemp only for broad runs.\n\nExercise the hierarchy reader, explicit-root refusal, focused placement, and runner scope propagation through production policy paths.\n\nCo-Authored-By: OpenAI Codex <noreply@openai.com>
@Sinity

Sinity commented Aug 11, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@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: 8647d622e7

ℹ️ 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/verify.py Outdated
Reserve the measured full-suite basetemp only for seed, full, load-sensitive, and broad-testmon steps. Ordinary affected testmon runs retain the focused disk requirement.\n\nCover every managed pytest label class through the production runner.\n\nCo-Authored-By: OpenAI Codex <noreply@openai.com>
@Sinity

Sinity commented Aug 11, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@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: c74810e0dd

ℹ️ 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/verify_runs.py
Comment thread tests/conftest.py Outdated
Comment thread devtools/verify_runs.py Outdated
Use the focused controller and proportional cgroup envelope for non-broad runs, preserve measured full-suite disk demand on explicit scratch roots, and normalize leaked cloud basetemp configuration before bare pytest selects storage.

Cover low-memory focused admission, explicit-root disk refusal, and workstation cloud-default normalization.

Co-Authored-By: OpenAI Codex <noreply@openai.com>
@Sinity

Sinity commented Aug 11, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Already looking forward to the next diff.

Reviewed commit: 2c11231da2

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

@coderabbitai coderabbitai 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.

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@devtools/run_tests.py`:
- Line 50: Update _subprocess_env in devtools/run_tests.py to construct pytest
artifact paths from ROOT instead of Path.cwd(), matching the checkout-root
behavior already used by _managed_env and ensuring paths remain correct when
devtools test runs from a subdirectory.

In `@devtools/verify.py`:
- Around line 1727-1730: In the concurrency argument, remove the unreachable
None fallback and use the already-assigned pytest_concurrency value directly,
while preserving the minimum concurrency of 1 via max. Do not call
_pytest_command_concurrency again or read the policy-mutated env.

In `@tests/conftest.py`:
- Around line 105-114: Update devtools/verify_slos.py so _run_benchmarks()
launches pytest with the managed pytest environment, preserving
POLYLOGUE_VERIFY_RUN_ID, POLYLOGUE_PYTEST_BASETEMP_ROOT, and
POLYLOGUE_PYTEST_TMPFS from the parent managed step. Ensure the nested pytest
receives the configured tmpfs budget instead of triggering the bare-pytest
fallback in tests/conftest.py.

In `@tests/unit/devtools/test_verify.py`:
- Around line 1917-1930: Patch verify_runs.read_cgroup_memory_headroom_bytes in
test_managed_policy_uses_scratch_when_tmpfs_is_unavailable to return an
effectively unlimited memory headroom value, matching the other tests in this
file. Keep the existing _meminfo, _pressure, os.cpu_count, and _fs_usage patches
unchanged so the policy assertions are independent of the host cgroup
configuration.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 1c5dd074-09db-4006-a3e6-054e865b1224

📥 Commits

Reviewing files that changed from the base of the PR and between fb74235 and 2c11231.

📒 Files selected for processing (9)
  • devtools/run_tests.py
  • devtools/verify.py
  • devtools/verify_runs.py
  • polylogue/core/metrics.py
  • tests/conftest.py
  • tests/unit/core/test_metrics_cgroup_memory_limits.py
  • tests/unit/devtools/test_run_tests.py
  • tests/unit/devtools/test_verify.py
  • tests/unit/test_pytest_temp_policy.py
💤 Files with no reviewable changes (1)
  • tests/unit/devtools/test_run_tests.py

Comment thread devtools/run_tests.py
Comment thread devtools/verify.py Outdated
Comment thread tests/conftest.py
Comment thread tests/unit/devtools/test_verify.py
Problem: focused and nested benchmark pytest launches could lose checkout-scoped artifacts or managed tmpfs context when invoked from a subdirectory.\n\nWhat changed: anchor inherited artifact paths to the checkout, pass managed policy and run markers through the SLO parent and child, and make the supervisor read the event ledger supplied to pytest. The concurrency receipt now uses its already-parsed value, and the scratch fallback test isolates cgroup state.
@Sinity

Sinity commented Aug 11, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@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: 16d1cb7e3c

ℹ️ 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/verify.py
Give the output-stall and progress-stall supervisor tests independent VerifyRun artifact directories. This prevents one invocation's event stream from changing another invocation's termination classification while preserving the real process-control route.\n\nCo-Authored-By: OpenAI Codex <noreply@openai.com>
@Sinity

Sinity commented Aug 11, 2026

Copy link
Copy Markdown
Owner Author

@codex review

Please review exact head 4f671d8ad, including the test-only per-run event-artifact isolation added after a 194-pass/1-fail parallel gate exposed shared legacy event state.

@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: 4f671d8ad2

ℹ️ 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/verify.py

@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: 7f8c57d9a8

ℹ️ 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/verify.py
) -> dict[str, Any] | None:
"""Return the latest valid pytest event from the live JSONL ledger."""
if events_dir is not None:
return latest_event_from_paths(events_dir, path)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Tail worker ledgers instead of rereading them

During broad seed/full xdist runs, every output chunk now reaches this branch—twice via _refresh_progress_marker() and _write_pytest_progress()—and latest_event_from_paths() calls _read_last_jsonl() for every worker file; that helper uses read_text().splitlines(), so it rereads each entire, continually growing event ledger merely to obtain its final row. Since the plugin emits several rows per test, this makes live progress monitoring approach quadratic I/O and allocation across the roughly 16K-node suite and can substantially slow or exhaust memory during the verification run it is supervising. Tail a bounded byte range, or retain per-file offsets/latest records, rather than materializing every ledger on each poll.

Useful? React with 👍 / 👎.

Comment thread devtools/verify_runs.py
None,
)

workers = largest_with(PYTEST_BASETEMP_PEAK_KB)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Size default workers for the actual test scope

When no worker override is set for the ordinary affected-testmon path, _pytest_worker_args() calls adaptive_pytest_worker_count(), which invokes the policy with its default full_suite=True, so this line reserves the 1,522 MiB full-suite basetemp and broad controller envelope even though _run() later classifies pytest testmon with full_suite=False. On a 6 GiB/24-CPU host this selects 3 workers although the focused envelope admits 6, and around 2 GiB it refuses during step construction although a one-worker focused run fits. Fresh evidence beyond the resolved focused-admission thread is that only launch admission was scoped; default worker selection still uses the broad envelope. Pass the actual verification scope into adaptive worker selection.

AGENTS.md reference: AGENTS.md:L323-L328

Useful? React with 👍 / 👎.

@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: 72dfe5e3b7

ℹ️ 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/verify_runs.py
default_full_suite_scratch = (
full_suite
and not normalized.get("POLYLOGUE_PYTEST_BASETEMP_ROOT")
and "POLYLOGUE_PYTEST_TMPFS" not in normalized

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Treat blank tmpfs settings as unset

When the environment contains POLYLOGUE_PYTEST_TMPFS="" (or any value other than 0/1), this key-presence check disables the broad-suite scratch default; manages_tmpfs then treats the value as enabled and rewrites it to 1. On a host whose computed cap accommodates the measured peak, seed, full, and broad-testmon runs consequently stay on /dev/shm, although only an explicit value of 1 is documented to override their scratch placement. Parse the opt-in by value, treating blank as unset and rejecting other values.

AGENTS.md reference: AGENTS.md:L510-L517

Useful? React with 👍 / 👎.

Comment thread tests/conftest.py
Comment on lines 102 to 104
)

if config.option.basetemp is None:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Route explicit tmpfs roots away from bare pytest

For a direct pytest invocation with POLYLOGUE_PYTEST_BASETEMP_ROOT=/dev/shm/... and no verify-run marker, this condition skips the scratch fallback because the normalized root remains configured; resolution then accepts that root, while configured roots receive no pytest_tmpfs_budget_kb cap and there is no external supervisor. An interrupted or broad run can therefore consume the shared tmpfs without the bounded behavior promised for /dev/shm. Fresh evidence beyond the resolved cloud-default case is that a genuine configured root beneath /dev/shm survives normalization; detect such roots and force scratch or reject them for bare pytest.

AGENTS.md reference: AGENTS.md:L510-L517

Useful? React with 👍 / 👎.

Comment thread devtools/verify_runs.py
full_suite=full_suite,
)
if full_suite and policy.tmpfs_predicted_mb is not None:
normalized.setdefault(PYTEST_BASETEMP_REQUIRED_MB_ENV, str(policy.tmpfs_predicted_mb))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Keep measured full-suite demand as a floor

When a full-suite process inherits POLYLOGUE_PYTEST_BASETEMP_REQUIRED_MB=0 (or any value below 1522), setdefault preserves that smaller declaration instead of applying the measured peak. Scratch admission then falls back to the ordinary 1 GiB floor, so a filesystem with, for example, 1.2 GiB free is accepted even though the measured suite tree requires 1.522 GiB and can exhaust it mid-run. Fresh evidence beyond the earlier larger-demand case is that smaller declarations suppress the new measured requirement; take the maximum of the configured and measured values while continuing to honor larger declarations.

AGENTS.md reference: AGENTS.md:L510-L521

Useful? React with 👍 / 👎.

@Sinity

Sinity commented Aug 11, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@coderabbitai coderabbitai 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.

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@CLAUDE.md`:
- Around line 516-517: Update the documentation sentence describing
POLYLOGUE_PYTEST_TMPFS=1 to state that it requests bounded tmpfs, but is honored
only when the effective budget satisfies the declared basetemp requirement;
retain the existing POLYLOGUE_PYTEST_BASETEMP_MIN_FREE_MB override description.

In `@devtools/verify.py`:
- Around line 1817-1819: Update _subprocess_env in devtools/verify.py to export
POLYLOGUE_PYTEST_EVENTS_DIR rooted at ROOT / PYTEST_EVENTS_DIR, alongside the
existing rooted pytest paths. In tests/unit/devtools/test_run_tests.py lines
58-65, extend the environment assertions to verify this variable resolves under
the checkout root.

In `@tests/conftest.py`:
- Around line 192-212: Update _remove_stale_basetemp in tests/conftest.py to
return immediately when the top-level entry is a symbolic link, before os.walk
or any permission changes. In tests/unit/test_pytest_temp_policy.py lines
289-303, add coverage for a stale top-level symbolic link and verify the linked
target tree’s permissions remain unchanged.

In `@tests/unit/test_pytest_temp_policy.py`:
- Around line 273-303: Update both stale-cleanup tests, especially
test_sweep_stale_polylogue_basetemps_reclaims_reused_pid_identity and
test_sweep_stale_polylogue_basetemps_reclaims_read_only_fixture_tree, to accept
the frozen_clock fixture and derive each entry’s mtime relative to its frozen
timestamp instead of using the hard-coded old = 1.0 value. Keep the existing
stale-reclamation assertions unchanged.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 478f1985-4e38-4a74-8095-e9b94f7a901e

📥 Commits

Reviewing files that changed from the base of the PR and between 2c11231 and 5e3c097.

📒 Files selected for processing (11)
  • CLAUDE.md
  • TESTING.md
  • devtools/verify.py
  • devtools/verify_runs.py
  • devtools/verify_slos.py
  • tests/conftest.py
  • tests/unit/devtools/test_run_tests.py
  • tests/unit/devtools/test_slo_catalog.py
  • tests/unit/devtools/test_verify.py
  • tests/unit/operations/test_mutation_actuators.py
  • tests/unit/test_pytest_temp_policy.py

Comment thread CLAUDE.md Outdated
Comment thread devtools/verify.py
Comment thread tests/conftest.py
Comment thread tests/unit/test_pytest_temp_policy.py

@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: 5e3c097539

ℹ️ 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/verify_runs.py
and effective_tmpfs_budget_kb is not None
and effective_tmpfs_budget_kb < required_basetemp_kb
):
normalized["POLYLOGUE_PYTEST_TMPFS"] = "0"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Keep the cap active for configured tmpfs roots

When a managed full-suite run uses POLYLOGUE_PYTEST_BASETEMP_ROOT beneath /dev/shm and its effective cap is below the declared demand (for example, a 512 MiB cap versus the 1,522 MiB estimate), this assignment disables tmpfs supervision but leaves the configured root intact. resolve_pytest_basetemp_root() then selects that root before consulting POLYLOGUE_PYTEST_TMPFS, and pytest_tmpfs_budget_kb() returns None, so the run can consume the shared tmpfs without any cap instead of routing to scratch. Clear/reroute the configured tmpfs root when disabling tmpfs, or keep the supervisor cap active.

AGENTS.md reference: AGENTS.md:L510-L517

Useful? React with 👍 / 👎.

@Sinity

Sinity commented Aug 11, 2026

Copy link
Copy Markdown
Owner Author

@codex review

Please review exact head 5d479aa057bb21ef6d45f48eae76da18e4ada0c7, including the rooted worker-event directory and stale top-level symlink refusal added after exact-head review.

@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: 5d479aa057

ℹ️ 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/verify_runs.py
Comment on lines +770 to +772
configured_root = normalized.get("POLYLOGUE_PYTEST_BASETEMP_ROOT")
configured_tmpfs = configured_root is not None and _is_beneath(Path(configured_root), PYTEST_TMPFS_ROOT)
manages_tmpfs = configured_tmpfs or (configured_root is None and normalized.get("POLYLOGUE_PYTEST_TMPFS") != "0")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Reserve headroom for configured tmpfs roots

When POLYLOGUE_PYTEST_BASETEMP_ROOT points beneath /dev/shm, this new classification enables a cap but leaves resolve_pytest_basetemp_root() on its configured-root branch, which admits using only max(min_free, declared_demand) rather than the ordinary tmpfs requirement of min_free + max(declared_demand, cap). For example, a focused run with 2.5 GiB free can receive a 2 GiB cap and be admitted, allowing it to leave only 0.5 GiB instead of the promised 1 GiB headroom and potentially strand other shared-tmpfs users. Apply the tmpfs headroom calculation to configured roots beneath /dev/shm as well.

AGENTS.md reference: AGENTS.md:L510-L519

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Addressed in a0da692. Configured tmpfs roots now require the configured free-space floor plus the larger of declared demand and the effective supervisor cap; a 2.5 GiB fixture is refused against the 3.024 GiB requirement.

@Sinity

Sinity commented Aug 11, 2026

Copy link
Copy Markdown
Owner Author

@codex review

Please review exact head a0da69269458fdd7c90b717109434f05df8ac603, which applies tmpfs headroom accounting to explicitly configured /dev/shm roots.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Bravo.

Reviewed commit: a0da692694

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

@Sinity
Sinity merged commit c27af7d into master Aug 11, 2026
3 checks passed
@Sinity
Sinity deleted the feature/fix/tmpfs-resource-budget branch August 11, 2026 16:51
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