Skip to content

fix(testmon): stop seed admission after harness failures - #3961

Merged
Sinity merged 4 commits into
masterfrom
feature/perf/test-harness-sol
Aug 12, 2026
Merged

fix(testmon): stop seed admission after harness failures#3961
Sinity merged 4 commits into
masterfrom
feature/perf/test-harness-sol

Conversation

@Sinity

@Sinity Sinity commented Aug 12, 2026

Copy link
Copy Markdown
Owner

Summary

Stop resumable testmon seed admission after an infrastructure-fatal shard while preserving continued dependency capture after ordinary red tests.

Problem

The failed seed run at /realm/worktrees/polylogue-testmon-final/.cache/verify/runs/20260812T114200Z-seed-testmon-55347-bc4afc5f timed out shard 1 after 2,700.84 seconds, then immediately attempted shard 2. At timeout, the shard had completed 3,860/4,096 nodes, peaked at 2,568,784 KiB process-tree RSS and 2,221,538 KiB PSS, used 571,952 KiB swap PSS, and issued 27,789,180,928 bytes of writes while the basetemp peaked at only 97,570 KiB. Admitting more work after that bounded resource stop produced no trustworthy release baseline and obscured the original terminal condition.

Ordinary assertion failures are different: their testmon rows remain useful, and later shards should continue to populate the resumable graph.

PR #3960 owns bounded response-file argv and managed worker execution. This change is intentionally disjoint: it controls admission after a shard has already returned.

Solution

  • classify shard results at the seed-loop boundary;
  • continue only for a structured ordinary pytest red result (exit 1, pytest_failed);
  • checkpoint and stop before another shard after timeouts, resource refusals, worker/internal errors, usage errors, or unclassified failures;
  • cover both mutations: removing the stop re-admits work after timeout, while an unconditional stop loses useful dependency evidence after red tests.

Verification

  • .venv/bin/python -m devtools test tests/unit/devtools/test_verify.py -k 'stops_only_after_infrastructure_failed_shard or seed_resource_timeout_has_a_distinct_typed_terminal_outcome' — 5 passed, 149 deselected in 1.81s.
  • .venv/bin/python -m devtools test tests/unit/devtools/test_verify.py — 154 passed in 19.93s.
  • PATH="$PWD/.venv/bin:$PATH" .venv/bin/python -m devtools verify --quick — all 25 steps passed in 196.05s at exact head 6aa95bea4; strict mypy passed over 2,735 files.
  • Real-route diagnostic: devtools test over the oversized annotation-batch API node and lexical archive-query node — 1 passed, 1 pre-existing failure in 7.94s. The query call took 6.2385s versus 28.4543s in the serial testmon shard. The existing API failure is ReadOnlyArchiveError: read-only archive evidence cannot mutate user.db; it is retained unchanged.
  • Default devtools verify — refused before tests because this linked worktree has no completed testmon seed. No replacement multi-hour seed was started while PR fix(testmon): run resumable shards with bounded argv #3960 owns that repair.

Residual baseline

The supplied seed artifact is not green: it includes existing API/reindex/convergence failures and terminated before completing the 20,965-node corpus. This PR neither excludes those nodes nor grants release authority.

Bead disposition

Scope Disposition Evidence
Self-contained harness fix Satisfied Commits 85e0b3512, 1c4959e76, d11742db0, 6aa95bea4; focused and module verification above
Beads Unchanged No assigned or mutated Beads

@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Seed testmon execution now continues after ordinary pytest_failed shard results. It stops after infrastructure failures, preserves pending shards, propagates the stopping exit code, and finalizes shard and receipt states through regression tests.

Changes

Seed shard failure handling

Layer / File(s) Summary
Failure classification and shard execution
devtools/verify.py, tests/unit/devtools/test_verify.py
The seed runner continues after exit code 1 results diagnosed as pytest_failed. Other nonzero results stop execution. Tests cover completed, incomplete, pending, exit-code, and receipt states.

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

Sequence Diagram(s)

sequenceDiagram
  participant SeedShardExecution
  participant FailureClassifier
  participant ShardStatusAndReceipt
  SeedShardExecution->>FailureClassifier: classify shard exit code and diagnosis
  FailureClassifier-->>SeedShardExecution: continue after pytest_failed or stop
  SeedShardExecution->>ShardStatusAndReceipt: finalize shard and receipt states
Loading
🚥 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 describes the main change: stopping testmon seed admission after harness failures.
Description check ✅ Passed The description covers the change, problem, solution, verification, scope, and residual baseline with concrete evidence.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/perf/test-harness-sol

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.

@Sinity

Sinity commented Aug 12, 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

polylogue/devtools/verify.py

Lines 3450 to 3454 in 1c4959e

}
shard_result.update(shard_metadata)
step_results.append(shard_result)
prepared_seed_attempt = _checkpoint_testmon_seed_shard(
prepared=prepared_seed_attempt,

P2 Badge Return the infrastructure failure after an earlier red shard

When an ordinary failing-test shard runs first and a later shard times out or is resource-refused, this branch stops admission but leaves exit_code at the earlier value 1 because it only records the fatal shard's code when the accumulator is zero. The command and top-level verification receipt therefore report an ordinary test failure instead of the infrastructure-fatal 124/125 result that actually terminated the seed, preventing callers from distinguishing a retryable harness failure from a red baseline. A stop-requiring shard should replace the accumulated exit code even if an earlier shard was red.

ℹ️ 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
Comment on lines +1847 to +1849
if exit_code == 0:
return False
return not (exit_code == 1 and step.get("diagnosis") == "pytest_failed")

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 Stop admitting shards after xdist worker crashes

When xdist aborts a shard after exhausting crashed-worker restarts, it can return exit 1, but _run() obtains its diagnosis from classify_pytest_result(), which labels every positive non-terminated result pytest_failed; it never produces the xdist_worker_crash diagnosis used elsewhere in the seed code. Consequently this condition mistakes that infrastructure failure for an ordinary red test and starts the next expensive shard, contrary to the new admission policy. The decision needs evidence that the shard completed normally, rather than relying solely on exit 1 plus this generic diagnosis.

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 6aa95be. The continue decision now requires the checkpointed shard ledger to be complete in addition to exit 1 and pytest_failed, so an xdist crash with missing/worker_crash outcomes stops admission. The incomplete-generic-exit-1 regression is included in the 5 focused cases.

@Sinity

Sinity commented Aug 12, 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.py`:
- Around line 3458-3464: The shard aggregation logic around
_seed_shard_failure_requires_stop must retain the terminal shard diagnosis
whenever a later infrastructure failure replaces exit_code, so the
pytest_failed-then-pytest_timeout scenario reports pytest_timeout in JSON
history and VerifyRun. Update devtools/verify.py lines 3458-3464 accordingly,
and add or adjust the assertion in tests/unit/devtools/test_verify.py lines
3178-3285 to verify the JSON diagnosis is pytest_timeout.
🪄 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: 94a691ae-e198-4ce8-b5ae-eda080e90d4d

📥 Commits

Reviewing files that changed from the base of the PR and between 4516ece and d11742d.

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

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: d11742db04

ℹ️ 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
Comment on lines +1846 to +1849
exit_code = step.get("exit")
if exit_code == 0:
return False
return not (exit_code == 1 and step.get("diagnosis") == "pytest_failed")

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 Stop after a shard checkpoints incomplete

When a shard subprocess exits 0 but its selection or progress artifacts are missing/incomplete, _checkpoint_testmon_seed_shard() records the shard as incomplete, yet this early return treats it as healthy and the loop admits the next expensive shard. This can occur if the pytest progress plugin fails to produce a complete selection.json or terminal events even though pytest itself exits successfully; base the admission decision on the checkpointed shard status as well as the process exit.

Useful? React with 👍 / 👎.

@Sinity

Sinity commented Aug 12, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: 6aa95bea43

ℹ️ 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 ff83ec5 into master Aug 12, 2026
3 checks passed
@Sinity
Sinity deleted the feature/perf/test-harness-sol branch August 12, 2026 14:22
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