Skip to content

fix(test): prevent residual cleanup fixture readiness race - #136185

Merged
steipete merged 1 commit into
mainfrom
steipete/jovial-ritchie-d5b146
Sep 2, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/jovial-ritchie-d5b146

Conversation

@steipete

@steipete steipete commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

Resolves a problem where developers running the Vitest runner tests could hit a residual-descendant fixture failure when readiness polling resumed after the real no-output watchdog had already terminated the process group. This is a maintainer-requested fixture repair, kept separate from other lifecycle work.

Why This Change Was Made

The fixture now waits for an acknowledgment from the descendant after it installs its running loop. The leader disconnects private IPC and forwards the PID over watched stdout; the test validates a positive, live PID and signals only the leader synchronously in the line callback. This replaces the stale PID-file handoff and independent polling continuation with one readiness path.

The real 5000 ms watchdog still starts at spawn. No timeout increase, fake clock, keepalive, suppression, or production seam is added. The test now rejects watchdog termination explicitly, retains the complete stopped/zombie-only group snapshot at completion, and awaits the owned completion promise in final cleanup. Descendant stdout/stderr remain ignored, so pipe closure cannot substitute for process-group cleanup.

User Impact

No product behavior changes. Developers get a fixture that proves residual-descendant cleanup without confusing delayed readiness polling or watchdog group termination with the intended leader-only exit. A truly silent startup exceeding five seconds still fails intentionally.

Production/tooling LOC: +0/-0. Tests: +34/-33 (one existing test file; no new test-only production hooks). No changelog, dependency, configuration, schema, or release changes.

Evidence

  • A fault-injected real-process scheduling probe extracted the original test body with equivalent Node assertions and delayed its first 5 ms readiness poll to 6500 ms. Before the fix, the descendant was live at 468 ms, the real watchdog fired at 5385 ms, completion settled at 5573 ms, and the liveness assertion failed at 7012 ms. This is not a claim that the unchanged Vitest command failed naturally; that original-order command passed once.
  • The same probe against the repaired fixture passes, observing a live descendant at leader exit and no running group members at completion. An independent landing replay reproduced the expected before/after exit codes 1/0 and the same causal ordering.
  • Negative controls fail when group joining is omitted (groupStopped: false) and when leader-only termination is withheld (noOutputTimedOut: true). They exercise real production processes, watchdogs, signals, and joining; repository production code is unchanged.
  • OPENCLAW_VITEST_MAX_WORKERS=16 node scripts/run-vitest.mjs test/scripts/test-projects.test.ts test/scripts/test-projects-routing.test.ts test/scripts/run-vitest.test.ts — 644 passed in 3 files, exit 0, 593.7 s. This isolated baseline contains 644 tests, not the initial report's 649; no unrelated routing changes were imported.
  • OPENCLAW_VITEST_MAX_WORKERS=16 node scripts/run-vitest.mjs test/scripts/run-vitest.test.ts test/scripts/vitest-process-group.test.ts — 172 passed, independently rerun during landing with exit 0.
  • node scripts/check-changed.mjs -- test/scripts/run-vitest.test.ts — exit 0: selected guards, formatting, root-test typecheck, script lint, and targeted test lint. git diff --check also passes.
  • Fresh isolated Codex autoreview: scoped-clean at the required P0 priority, no accepted/actionable findings. Current-main comparison at f0d792a772188c1efbcf21ff4db63a1115cc8747 confirms the old fixture remains and relevant runner/process-group sources are unchanged.

Known local extra-proof limitation: a separate command selecting only test/scripts/vitest-process-group.test.ts and unchanged test/scripts/run-vitest-progress.test.ts passed 38 group tests but failed two progress cases: stall=false timed out waiting for case-1 readiness, and stall=true timed out waiting for owned group cleanup. It did not load the changed file. Its exact fixture namespace/process commands were verified gone. These failures, plus the unchanged silent-child case's late diagnostic output, remain in the separately tracked follow-up Investigate Vitest progress fixture timeouts; this PR does not claim that wider sibling sweep passed.

Local proof used macOS and Node 24.20.0; no full-suite or browser proof is claimed. Regression introduction is not attributed here because raw-parent provenance was not independently reverified for landing.

@clawsweeper

clawsweeper Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added size: S maintainer Maintainer-authored PR labels Sep 2, 2026
@steipete
steipete marked this pull request as ready for review September 2, 2026 08:58
@steipete steipete self-assigned this Sep 2, 2026
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. labels Sep 2, 2026
@clawsweeper

clawsweeper Bot commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 2, 2026, 5:18 AM ET / 09:18 UTC.

ClawSweeper review

What this changes

The PR replaces temporary-file polling in the residual-descendant cleanup test with an IPC readiness acknowledgement forwarded through the watched child’s stdout.

Regression provenance

Possible regression — probable (reviewed change; failure trace). No predecessor PR is attributed.

Merge readiness

✅ Ready for maintainer review

Keep open. This maintainer-owned, labeled test repair remains necessary: current main still uses the independent temporary-file poll, while the PR makes readiness a single observed process-output event before signalling the leader. No blocking correctness or security finding was identified.

Priority: P3
Reviewed head: fdac6d61d36ac3e23cf15c7e30cdba41b988f4a0

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, source-consistent test reliability repair with no blocking review finding.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored, test-only PR is exempt from the external contributor proof gate; its supplied real-process trace is consistent with the watched-output and process-group paths inspected in source.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored, test-only PR is exempt from the external contributor proof gate; its supplied real-process trace is consistent with the watched-output and process-group paths inspected in source.
Evidence reviewed 5 items Changed readiness boundary: The PR fixture waits for the descendant’s IPC acknowledgement, checks its live PID, signals the leader in the output callback, and asserts that the watchdog did not fire before completion.
Runtime owner and cleanup invariant: The watcher attaches to child stdout and stderr, routes a no-output timeout to process-group termination, and resolves completion only after child output drains and group cleanup completes.
Current-main comparison: Current main still contains the former PID-file handoff and independent wait loop, so the central test-fixture repair is not already implemented there.
Findings None None.
Security None None.

How this fits together

The Vitest runner watches child output for stalls and terminates an owned process group when output stops. The changed fixture starts a leader and detached descendant, then verifies the runner’s cleanup joins the entire group rather than only the leader.

flowchart LR
  A[Test fixture] --> B[Watched test leader]
  B --> C[Residual descendant]
  C --> D[Readiness output]
  D --> E[Leader termination]
  E --> F[Process-group cleanup]
  F --> G[Stopped-group assertion]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Tests +1. Total +1 across 1 file.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 1 34 33 +1
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 1 34 33 +1

Review metrics

Metric Value Why it matters
Production versus test LOC production +0/-0; tests +34/-33 The patch is a net-one-line test-fixture rewrite and does not alter the shipped runner implementation.

Technical review

Best possible solution:

Use the output-backed readiness handshake so the fixture validates a live descendant before leader termination, while retaining the runner’s existing watchdog and group-join behavior.

Do we have a high-confidence way to reproduce the issue?

Yes, at source level: the former independent polling could continue after the 5-second no-output watchdog terminated the silent group. The supplied PR body also records a real-process fault-injection trace, though this read-only review did not re-execute it.

Is this the best way to solve the issue?

Yes. Readiness is now synchronized on the output event that the watchdog observes, avoiding a timeout increase or a second delayed polling path while preserving process-group cleanup as the runtime owner.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against c077653cd4ec.

Labels

Label justifications:

  • P3: This fixes internal test-fixture synchronization without changing product runtime behavior.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored, test-only PR is exempt from the external contributor proof gate; its supplied real-process trace is consistent with the watched-output and process-group paths inspected in source.

Evidence

What I checked:

  • Changed readiness boundary: The PR fixture waits for the descendant’s IPC acknowledgement, checks its live PID, signals the leader in the output callback, and asserts that the watchdog did not fire before completion. (test/scripts/run-vitest.test.ts:957, fdac6d61d36a)
  • Runtime owner and cleanup invariant: The watcher attaches to child stdout and stderr, routes a no-output timeout to process-group termination, and resolves completion only after child output drains and group cleanup completes. (scripts/run-vitest.mts:1265, fdac6d61d36a)
  • Current-main comparison: Current main still contains the former PID-file handoff and independent wait loop, so the central test-fixture repair is not already implemented there. (test/scripts/run-vitest.test.ts:957, c077653cd4ec)
  • History and routing: Recent history shows Peter Steinberger repeatedly maintaining this test-runner surface; Vincent Koc’s process-group diagnostic work is adjacent ownership context. (test/scripts/run-vitest.test.ts:957, c904e712f9c5)
  • Patch hygiene: The introduced one-file test-only delta is clean under whitespace validation and has no production-code change. (test/scripts/run-vitest.test.ts:957, fdac6d61d36a)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Vincent Koc: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (1 earlier review cycle)
  • reviewed 2026-09-02T09:03:30.706Z sha fdac6d6 :: needs maintainer review before merge. :: none

@steipete steipete closed this Sep 2, 2026
@steipete steipete reopened this Sep 2, 2026
@steipete

steipete commented Sep 2, 2026

Copy link
Copy Markdown
Contributor Author

Land-ready verification for fdac6d61d36ac3e23cf15c7e30cdba41b988f4a0.

The readiness race belongs to the residual-descendant test fixture. It now receives descendant-generated readiness, checks a live positive PID, and signals only the leader synchronously on watched stdout. The old PID-file handoff/poller is removed; the real 5000 ms watchdog and pipe-independent group cleanup are unchanged. Production/tooling +0/-0; tests +34/-33. No changes beyond the reviewed one-file patch.

Verified commands and results:

  • OPENCLAW_VITEST_MAX_WORKERS=16 node scripts/run-vitest.mjs test/scripts/test-projects.test.ts test/scripts/test-projects-routing.test.ts test/scripts/run-vitest.test.ts — 644 passed, three files, exit 0 on the exact candidate.
  • OPENCLAW_VITEST_MAX_WORKERS=16 node scripts/run-vitest.mjs test/scripts/run-vitest.test.ts test/scripts/vitest-process-group.test.ts — 172 passed; independently repeated for landing.
  • node scripts/check-changed.mjs -- test/scripts/run-vitest.test.ts — exit 0; selected guards, format, root-test typecheck, script lint, and targeted test lint.
  • git diff --check — pass; committed test blob matches the proved candidate.
  • Fresh isolated Codex autoreview — scoped-clean P0, no accepted/actionable findings.
  • node scripts/watch-pr-ci.mjs 136185 fdac6d61d36ac3e23cf15c7e30cdba41b988f4a0 — GREEN, exit 0. CI run 33611586004, attempt 1 completed successfully for this exact head.
  • Native scripts/pr review-init, review-checkout-main, review-checkout-pr, review-guard, and review-validate-artifacts passed for this PR. Main still retained the old fixture when compared.

The fault-injected real-process before/after replay was independently repeated: the old delayed polling continuation fails the liveness assertion after watchdog cleanup; the repaired fixture passes with a descendant still alive at leader exit and no running group at completion. Negative controls fail for missing group join and watchdog-driven termination. This is explicitly scheduling-injection proof, not a natural failure of the unchanged Vitest command.

Known proof gap remains unchanged: the separate progress-only/group command did not load this changed test, passed 38 group cases, and failed two unchanged progress cases (case-1 readiness for stall=false; owned-group cleanup for stall=true). Those failures and the unchanged silent-child case's late diagnostics remain in Investigate Vitest progress fixture timeouts. No full-suite or browser proof is claimed.

Read the latest ClawSweeper review: fresh exact-head review, no findings, Before merge: None, and no Rank-up moves list to apply or skip. No unresolved review threads. Live server rules require openclaw/ci-gate and linear history but no independent approval; no red-gate or approval bypass is being used. The temporary GitHub quota preflight failure was retried only after its reported reset with the same steipete writer.

Native hosted prepare initially rejected a missing Workflow Sanity run. The PR creation event had GitHub startup_failure/BuildFailed run 33611534513. After verifying the owned supervisor/process group had stopped, its exact retained operation lock was recovered through scripts/pr lock-recover; the PR was closed/reopened once at the unchanged head to re-fire normal PR workflows. Manual Workflow Sanity dispatch was not used because it selects different jobs.

Recovered cohort: Workflow Sanity 33612990883 and CI 33612990844, both attempt 1, completed successfully for the same source head. The second pinned CI watcher exited 0 with GREEN. An intermediate prepare retry correctly refused the still-active recovery CI; no prior-green shortcut was used, and its exact owned lock was recovered only after process completion.

OPENCLAW_TESTBOX=1 scripts/pr prepare-run 136185 now completed successfully: hosted CI/Testbox gates passed, the remote branch already matched the prepared head, no push/rebase was needed, and prepared/remote head both remain fdac6d61d36ac3e23cf15c7e30cdba41b988f4a0. Proceeding only through native scripts/pr merge-run 136185 for final revalidation and landing.

@steipete
steipete merged commit 4adab73 into main Sep 2, 2026
122 checks passed
@steipete
steipete deleted the steipete/jovial-ritchie-d5b146 branch September 2, 2026 14:43
@steipete

steipete commented Sep 2, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant