Skip to content

Fix test harness resource and I/O stall handling - #3940

Merged
Sinity merged 9 commits into
masterfrom
feature/test/harness-resource-admission
Aug 10, 2026
Merged

Sinity merged 9 commits into
masterfrom
feature/test/harness-resource-admission

Conversation

@Sinity

@Sinity Sinity commented Aug 10, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • classify xdist workers wedged in uninterruptible I/O sleep as a typed stall
  • keep tmpfs runs from consuming their entire safety headroom
  • make Dependabot dependency-only scope exceptions authoritative and typed
  • harden the existing fresh-worktree testmon bootstrap path with focused verification

Problem

The full suite previously left all xdist workers in D-state SQLite/filesystem sleep without the supervisor classifying the run, and a tmpfs run could be selected with only the run budget plus no safety margin. Dependabot PRs also failed before verification because human Bead carriers were required for dependency-only changes.

Solution

The managed pytest sampler records xdist worker state and the supervisor terminates only after every observed worker remains uninterruptible for the configured stall interval. Tmpfs admission now requires the bounded run budget plus normal free-space headroom; otherwise the NVMe scratch root is selected. The PR-scope checker accepts only authoritative dependabot[bot] metadata with an exact dependency-only file allowlist; ordinary PRs retain the carrier gate.

Verification

  • direnv exec . devtools test tests/unit/test_pytest_temp_policy.py tests/unit/devtools/test_verify.py -k 'xdist_uninterruptible or managed_pytest_temp_root or resource_sampler' — 10 passed
  • direnv exec . devtools test tests/unit/devtools/test_pr_scope.py tests/unit/devtools/test_testmon_bootstrap.py -k 'dependabot or automated_scope or bootstrap or seed' — 26 passed
  • direnv exec . devtools test tests/unit/devtools/test_pr_scope.py — 25 passed
  • direnv exec . devtools verify --quick — exit 0; all 25 non-test steps passed

Ref #9pf58

@coderabbitai

coderabbitai Bot commented Aug 10, 2026 •

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Pytest verification now validates basetemp capacity, reports xdist worker states, and terminates runs after sustained all-worker uninterruptible stalls. Tests cover timeout classification and tmpfs fallback.

Changes

Pytest runtime supervision

Layer / File(s) Summary
Basetemp capacity resolution
devtools/verify_runs.py, tests/unit/test_pytest_temp_policy.py
Runtime policies record basetemp details. Basetemp selection validates minimum free space, declared demand, and tmpfs headroom.
Xdist worker state classification
devtools/verify_runs.py, tests/unit/devtools/test_verify.py
Process sampling identifies xdist workers and uninterruptible states. Aggregates expose worker counts and stall status. Classification requires the full timeout.
Heartbeat stall termination
devtools/verify.py
The heartbeat runner tracks sustained all-worker uninterruptible states and requests termination after the configured timeout.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Heartbeat as _run_pytest_with_heartbeat
  participant Sampler as resource sampling
  participant Classifier as xdist_uninterruptible_stall_reason
  Heartbeat->>Sampler: sample xdist worker states
  Sampler-->>Heartbeat: all_workers_uninterruptible metrics
  Heartbeat->>Classifier: classify worker state duration
  Classifier-->>Heartbeat: stall reason or None
  Heartbeat->>Heartbeat: terminate run when stall reason is returned
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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 summarizes the primary changes to test harness resource handling and I/O stall detection.
Description check ✅ Passed The description includes the required summary, problem, solution, verification, and Bead disposition information.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/test/harness-resource-admission

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.

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

🤖 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 701-709: Update pytest_basetemp_required_kb to reject negative
parsed values instead of clamping them to zero. Validate the integer before
converting megabytes to kilobytes, and raise PytestResourceError using the
existing invalid-environment-value message for values below zero while
preserving the current handling of empty and valid nonnegative values.
- Around line 790-799: Update the tmpfs admission calculation in the
candidate-selection flow around pytest_tmpfs_budget_kb so min_free_kb is not
added to the declared demand twice. Keep normal headroom separate from the
selected-root requirement, and choose the declared required_kb whenever it is
present, including zero, rather than using truthiness-based fallback to
budget_kb or 0.

In `@devtools/verify.py`:
- Around line 1380-1391: Reorder the loop’s xdist resource sampling and
classification around the generic output/progress timeout logic so
xdist_uninterruptible_stall_reason can complete its interval first.
Alternatively, defer the generic progress_idle termination while
xdist_uninterruptible_since is active, ensuring termination_reason preserves the
typed xdist SQLite/filesystem stall classification.
🪄 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: 7963d9a9-021a-4fba-946a-847acb1a2e33

📥 Commits

Reviewing files that changed from the base of the PR and between bd6222e and 29fe89d.

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

Comment thread devtools/verify_runs.py Resolved
Comment thread devtools/verify_runs.py Resolved
Comment thread devtools/verify.py Resolved

@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: 29fe89d7c3

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

@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: 1833a29571

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

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

ℹ️ 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 Resolved
@Sinity
Sinity merged commit 12618c0 into master Aug 10, 2026
3 checks passed
@Sinity
Sinity deleted the feature/test/harness-resource-admission branch August 10, 2026 23:41
Sinity added a commit that referenced this pull request Aug 11, 2026
## Summary

- record the verified portion of the test-harness resource-admission
work
- preserve the exact evidence, residual successors, and Beads snapshot
in the authoritative JSONL

## Problem

PR #3940 delivered the core fail-safe harness. Exact-head review then
found residual scope in automatic pre-execution reroute and the
controlled xdist stall fixture, so the parent Bead remains open with
named successors.

## Solution

Record a partial disposition for `polylogue-9pf58`: crash-left
seeded-build recovery is complete and tested; automatic reroute and the
six-worker xdist acceptance fixture remain on `polylogue-enl3l` and
`polylogue-7wytz`. The related base-authority Bead remains open.

## Verification

- `devtools lab policy bead-graph --json` — zero unhandled findings; two
explicitly deferred operator-action missing-AC records remain
- Beads pre-push JSONL/dependency validation — passed

<!-- polylogue-pr-scope:v1
{
  "assigned_beads": [
    "polylogue-9pf58"
  ],
"beads_digest":
"134cf7356763f8315cea631a17b9c3beb3d9c5682cf45e16af625a6a4f016cfd",
  "dispositions": [
    {
      "bead_id": "polylogue-9pf58",
      "disposition": "partial",
      "evidence": [
        {
          "kind": "commit",
          "ref": "12618c007 (merged PR #3940)"
        },
        {
          "kind": "commit",
          "ref": "9c2e215dca3d4fc2f6d6bc0f255013af532533a0"
        },
        {
          "kind": "test",
"ref": "devtools test tests/unit/infra/test_workload_artifacts.py: 9
passed"
        },
        {
          "kind": "test",
"ref": "devtools test tests/unit/devtools/test_verify.py -k
xdist/resource: 3 passed"
        },
        {
          "kind": "command",
          "ref": "devtools verify --quick: 25/25 steps passed"
        }
      ],
      "successors": [
        "polylogue-7wytz"
      ]
    }
  ],
  "head_sha": "2dc7bf01ffc3450a7219e59c834529b2623d4333",
"scope_digest":
"2cf55e2bf014618681268fffd265608627a0efc7da67c7dc498419c5819a494b",
  "version": 1
}
-->


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Chores**
* Updated project tracking records to document completed verification
for resource handling, cleanup, recovery, run receipts, stall
termination, release safeguards, and dependency pull request scope.
* Clarified the relationship between automated dependency checks and the
broader pull request scope validation work.


<!-- end of auto-generated comment: release notes by coderabbit.ai -->
@Sinity

Sinity commented Sep 30, 2026

Copy link
Copy Markdown
Owner Author

Historical Codex triage: evidence checked at 5ebcfe5. This records that source revision; it does not claim a fresh review of current master.

Only the rows listed above are dispositioned. Held findings remain open.

@Sinity

Sinity commented Sep 30, 2026

Copy link
Copy Markdown
Owner Author

Historical Codex triage: evidence checked at 5ebcfe5. This records that source revision; it does not claim a fresh review of current master.

  • 56.F045 / P1: stale at the checked revision: The proc-environment xdist identity detector and all-workers-D-state watchdog are absent from the current verifier. devtools/verify.py:854 delegates pytest to the slot runner, whose replacement observer at devtools/pytest_slot.py:1138 is a process-group memory sampler, not the reported worker-state termination mechanism.

Only the rows listed above are dispositioned. Held findings remain open.

@Sinity

Sinity commented Oct 1, 2026

Copy link
Copy Markdown
Owner Author

Historical Codex triage: evidence checked at 5ebcfe5. This records that source revision; it does not claim a fresh review of current master.

  • 57.F030 / P2: stale at the checked revision: The adaptive placement labels and tests/conftest.py no-CoW branch have been removed. devtools/pytest_slot.py:222 now directly chooses an explicit root or the checkout-local launch directory at devtools/pytest_slot.py:224; no selected scratch label is round-tripped through the old configured-root classification.
  • 57.F031 / P2: stale at the checked revision: The conditional adaptive-policy admission receipt described by the finding is no longer the temporary-storage contract. devtools/pytest_slot.py:222 handles configured roots directly and devtools/verify_runs.py:3 assigns temporary-storage lifecycle to AgentCTL; there is no remaining policy=None branch that selectively omits the old free-space receipt.
  • 57.F032 / P2: stale at the checked revision: The max(headroom, demand) admission calculation and BASETEMP_REQUIRED_MB input are absent from the current placement route. devtools/pytest_slot.py:224 selects checkout-local scratch, while devtools/verify_runs.py:3 delegates temporary-storage lifecycle to AgentCTL; the reported arithmetic no longer grants admission.
  • 57.F033 / P2: stale at the checked revision: The direct-pytest adaptive tmpfs resolver and pytest_tmpfs_budget_kb helper have been removed. Managed placement now uses devtools/pytest_slot.py:224 to select checkout-local scratch, rather than enabling /dev/shm by default while omitting its 512 MiB budget.
  • 57.F034 / P2: stale at the checked revision: The declared-demand versus tmpfs-cap admission branch and heartbeat tmpfs killer are absent. devtools/pytest_slot.py:221-224 selects only an explicit root or checkout-local scratch, so the reported 800 MiB demand cannot be admitted under a 512 MiB runtime cap through that removed policy.
  • 57.F035 / P2: stale at the checked revision: The all-D-state watchdog, its triggering worker-state sample, and its last_xdist summary fields are no longer produced. The current observer at devtools/pytest_slot.py:1138 records process-group memory telemetry, so the described overwrite of a D-state termination sample has no remaining producer or receipt field.
  • 57.F036 / P2: stale at the checked revision: The I/O D-state watchdog and its special termination string have been removed from the verifier. devtools/verify.py:868 now obtains termination metadata from the slot outcome, rather than classifying the removed local watchdog string as pytest_terminated instead of pytest_stall_timeout.

Only the rows listed above are dispositioned. Held findings remain open.

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