Skip to content

fix(test): join tsx fixture children before cleanup - #132808

Merged
steipete merged 2 commits into
mainfrom
steipete/affectionate-nightingale-80f73a
Aug 29, 2026
Merged

steipete merged 2 commits into
mainfrom
steipete/affectionate-nightingale-80f73a

Conversation

@steipete

@steipete steipete commented Aug 29, 2026 •

Copy link
Copy Markdown
Contributor

Related: #132713 — paired-Mac catalog repair whose broad fallback CI exposed this independent test-fixture weakness.

What Problem This Solves

Resolves a problem where a timed-out tsx wrapper fixture could delete its temporary checkout without owning descendant teardown, and the failing assertion discarded captured stdout/stderr. This is a maintainer-requested test-infrastructure repair, not a production cache change.

The original Windows job hit the unchanged 10-second spawnSync deadline at head 6ae2b5a8df4a0d9872c622b053f42619e3486ad6. It actually ran Windows 2025 and Node 22.23.2. Its unchanged-code rerun passed. Neither result establishes the initial timeout cause or a tsx cache regression.

Why This Change Was Made

The fixture now awaits its callback and every registered command through the existing runNodeScript / runManagedCommand ownership path before deletion. Unconfirmed cleanup retains the original fixture and bounded command output, with an explicit recovery path. POSIX fixtures sit outside the outer Vitest disposable namespace and outside repository module resolution; Windows keeps the ordinary temporary root.

The shared test runner gains argv/cwd support rather than duplicating subprocess capture or process-tree policy. Its bounded output callback now explicitly declares its existing receiver-independent this: void contract. Production runtime, tsx/esbuild dependencies, worker settings, and cache policy are unchanged. Increasing timeouts or disabling esbuild workers would not repair fixture ownership and was deliberately avoided.

User Impact

No product behavior change. Developers get managed timeout teardown and useful failure diagnostics without changing the 10,000 ms command budget. All existing cache sentinels and scan guard, environment preservation, transformed snapshots, preload/fork behavior, exit-17 assertions, and failure-trailer assertions remain intact.

Production LOC: +0/-0. Tests and test support: +355/-88 (net +267), including the extracted fixture setup and five failure/lifecycle cases. No configuration, schema, persistence, package, or public API surface changes.

Evidence

  • Before repair, three new lifecycle cases failed against the unchanged extracted fixture: both pending callback cases lost their directory before settlement, and unconfirmed cleanup lost its evidence.
  • A real wrapper → transformed implementation → descendant proof rejects the callback while the command is active, reaches the unchanged 10-second timeout, checks all recorded PIDs are dead, and checks captured stdout/stderr. All platforms also check that the directory still exists at managed-command settlement; POSIX additionally checks during the descendant's final shutdown write. Negative controls removing only the teardown wait failed both observations (false, expected true), including the platform-neutral assertion added for Windows. Independent PID-based recovery prevents the regression proof from relying on the broken fixture for cleanup.
  • Cleanup-failure injection replaces only the owner's receipt after a real child has joined; it proves fixture retention and diagnostics, not Windows OS termination.
  • Directly inspected installed tsx 4.23.12 cache/transform implementation and esbuild 0.28.2 worker/service spawn and stop contracts. Workers remain enabled. Also inspected Node's documented Windows signal and close/exit behavior.
  • Full focused local owner/sibling proof on macOS Node 26.8.1: 101 passed, one Linux-only skip. Independent macOS Node 24.20.0 run of the fixture and shared output helpers: 52 passed.
  • Scoped changed gate, root test typecheck, direct type-aware lint, formatting, and git diff --check passed. Fresh isolated Codex autoreview found no actionable findings at its default P0 scope.
  • Earlier local validation had two unchanged-deadline timeouts; the improved diagnostics captured both transformed snapshots. A temporary in-repository fixture placement also exposed dependency-resolution contamination and was removed. Those failed runs are not described as green and did not cause timeout or assertion weakening.

Commands:

node scripts/run-vitest.mjs test/scripts/direct-run-entrypoints.test.ts test/helpers/run-node-script.test.ts test/helpers/bounded-child-output.test.ts test/scripts/managed-child-process.test.ts test/scripts/vitest-fork-shutdown.test.ts
node scripts/check-changed.mjs -- test/helpers/bounded-child-output.ts test/helpers/run-node-script.ts test/scripts/direct-run-entrypoints.test.ts test/scripts/direct-run-entrypoints.test-support.ts
node scripts/run-oxlint.mjs --tsconfig test/tsconfig/tsconfig.test.root.json test/helpers/bounded-child-output.ts test/helpers/run-node-script.ts test/scripts/direct-run-entrypoints.test.ts test/scripts/direct-run-entrypoints.test-support.ts

Pre-rebase Windows proof passed at a938555a9c0347f41bfebd6a6aaac6f5977842b4, run 33271666117, attempt 1: test-1 and test-2. The actual runner was Blacksmith Windows 2025 with Node 22.23.2. The inspected test-1 log confirms both original cache cases and all five lifecycle/failure cases passed, including the real descendant timeout with the platform-neutral ordering assertion (10,122 ms). Both Windows jobs also passed the initial repair head. The assertion-only follow-up was revalidated locally (52 tests, root test types, direct lint, and fresh isolated autoreview all passed).

The previous aggregate CI failure was isolated to the untouched Linux shutdown fixture. The canonical repair landed separately in #132820 at f9b3bcccdba3dc159c6484c30f56974b90a6d938, switching that fixture to native worker CPU/heap profiles. This branch was mechanically rebased onto that repair; it does not duplicate or modify it. Range-diff confirms both original commits are patch-equivalent and the delta remains the same four test/support files (+355/-88; production +0/-0).

Fresh post-rebase local proof on macOS Node 24.20.0 passed 113 tests with one Linux-only skip, including all 12 canonical shutdown-fixture cases and the real descendant timeout (10,767 ms). Root test types, direct type-aware lint, changed-file gates, formatting, and whitespace checks passed. A fresh isolated Codex autoreview of the complete branch diff found no actionable findings at its default P0 scope. No source edits, timeout increases, assertion weakening, or production changes were made during landing recovery.

The focused command above is the final five-file recovery command. The original Windows timeout cause remains unknown; this PR repairs fixture ownership and diagnostics, not an established tsx cache regression.

Final exact-head CI is green at b0354de3e6462136d160f69b9d67bf4786ad6203: run 33275896095, attempt 1, and aggregate gate 99163257204. Both Windows test-1 and Windows test-2 passed. The inspected Windows 2025 / Node 22.23.2 test-1 log confirms all 46 direct-run cases passed, including both cache cases, all five lifecycle cases, and the real descendant timeout with fixture-presence-at-settlement proof (10,117 ms). The normal exact-head watcher finished GREEN; no CI retry or bypass was needed.

The latest ClawSweeper review, reviewed at 21:28 UTC on this exact head, has no code findings. Its rank-up move to complete required exact-head CI is now satisfied. Native review artifacts are complete and validated. The maintainer has reviewed the complete evidence and accepted this fixture-owner repair for landing through the native workflow.

AI-assisted; implementation and evidence independently reviewed.

@clawsweeper

clawsweeper Bot commented Aug 29, 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: M maintainer Maintainer-authored PR labels Aug 29, 2026
@steipete
steipete marked this pull request as ready for review August 29, 2026 19:38
@clawsweeper clawsweeper Bot added merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 29, 2026
@clawsweeper

clawsweeper Bot commented Aug 29, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 29, 2026, 5:28 PM ET / 21:28 UTC.

ClawSweeper review

What this changes

The PR makes tsx wrapper fixtures await callback work and managed Node commands before cleanup, preserving failure output when teardown cannot be verified.

Regression provenance

Possible regression — probable (reviewed change; known regression link). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

Keep open for maintainer review. Current main still has the synchronous fixture cleanup this PR repairs, and no introduced correctness defect was found; exact-head CI is still incomplete.

Priority: P3
Reviewed head: b0354de3e6462136d160f69b9d67bf4786ad6203
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, source-consistent test-infrastructure repair with credible boundary coverage; final readiness depends on exact-head CI completion.
Proof confidence 🌊 off-meta tidepool Not applicable: Repository state identifies the author as a member, so the external-contributor proof gate does not apply; the supplied focused Node descendant-timeout evidence is nevertheless aligned with the changed owner boundary.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: Repository state identifies the author as a member, so the external-contributor proof gate does not apply; the supplied focused Node descendant-timeout evidence is nevertheless aligned with the changed owner boundary.
Evidence reviewed 5 items Current-main behavior: Current main still accepts only one script path, does not pass a working directory, and invokes the managed command without the fixture-level command registry introduced here.
Current-main cleanup gap: Current main invokes the fixture callback synchronously and deletes the fixture in finally, so it cannot wait for asynchronous callback-owned subprocess work.
Introduced ownership repair: The introduced fixture registers each managed command, waits for callback settlement and all registered command results, retains diagnostics for unverified teardown, and only then deletes the fixture.
Findings None None.
Security None None.

How this fits together

The direct-run test fixture creates a temporary checkout and starts Node/tsx wrapper processes. Its managed-command helper terminates and joins child processes before the fixture removes temporary files.

flowchart LR
  A[Fixture callback] --> B[Temporary checkout]
  B --> C[Node and tsx wrapper]
  C --> D[Managed command]
  D --> E[Child teardown and output]
  E --> F[Fixture cleanup]
Loading

Decision needed

Question Recommendation
Once exact-head CI is terminal, should this focused fixture-ownership repair be accepted for the Windows-routed direct-run test lane? Accept after green CI: Merge after the exact current head completes the required test lanes without an attributable failure.

Why: The patch is source-consistent and the item carries the maintainer label, so final merge acceptance requires maintainer judgment after CI resolves.

Before merge

  • Resolve merge risk (P1) - This changes a Windows-routed test-infrastructure path, while the supplied exact-head check rollup is incomplete and GitHub reports the PR blocked; merge only after the exact head reaches a green terminal CI state.
  • Complete next step (P2) - No mechanical repair remains from review; the protected maintainer label and incomplete exact-head CI require normal maintainer acceptance.
Agent review details

Security

None.

PR surface

Tests +267. Total +267 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 4 355 88 +267
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 355 88 +267

Review metrics

Metric Value Why it matters
Production versus test delta production +0/-0; tests and test support +355/-88 (net +267) The added code is confined to test fixtures and lifecycle coverage; no product runtime surface changes.

Merge-risk options

Maintainer options:

  1. Complete exact-head CI validation (recommended)
    Wait for the current head’s Windows-routed and required CI checks to complete green before merge.

Technical review

Best possible solution:

Retain the single managed-command ownership path and land only after the exact head’s relevant CI completes successfully.

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

Yes, source provides a high-confidence path: current main deletes the fixture immediately after a synchronous callback, while the new timeout test holds a descendant command across callback rejection.

Is this the best way to solve the issue?

Yes. Reusing the existing managed-command owner centralizes subprocess teardown and output capture instead of adding another child-process policy path.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P3: This is a developer-facing test-fixture reliability repair with no product behavior change.
  • merge-risk: 🚨 automation: The changed fixture runs in the Windows-routed test lane, so an undetected lifecycle error could affect CI behavior after merge.
  • 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: Repository state identifies the author as a member, so the external-contributor proof gate does not apply; the supplied focused Node descendant-timeout evidence is nevertheless aligned with the changed owner boundary.

Evidence

What I checked:

Likely related people:

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

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Let the exact current head complete the required CI lanes before merge.

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 (2 earlier review cycles)
  • reviewed 2026-08-29T19:55:52.624Z sha a938555 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-29T20:03:44.016Z sha a938555 :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Aug 29, 2026
@steipete
steipete force-pushed the steipete/affectionate-nightingale-80f73a branch from a938555 to b0354de Compare August 29, 2026 21:22
@steipete

Copy link
Copy Markdown
Contributor Author

Maintainer acceptance is complete for the fixture-owner repair at b0354de3e6462136d160f69b9d67bf4786ad6203. Exact-head CI run 33275896095, attempt 1 and the required aggregate gate are green. Both Windows test-1 and test-2 passed; the inspected Windows 2025 / Node 22.23.2 log confirms all 46 direct-run cases, including the real descendant timeout at 10,117 ms.

Local macOS Node 24.20.0 proof: 113 passed, one Linux-only skip:

node scripts/run-vitest.mjs test/scripts/direct-run-entrypoints.test.ts test/helpers/run-node-script.test.ts test/helpers/bounded-child-output.test.ts test/scripts/managed-child-process.test.ts test/scripts/vitest-fork-shutdown.test.ts

Changed-file gates, root test types, direct type-aware lint, formatting, and whitespace checks passed. Fresh isolated Codex autoreview of the full branch diff is clean at its default P0 scope. Native review artifacts validate with zero findings. The latest ClawSweeper rank-up move to complete exact-head CI is satisfied.

The independent shutdown-profile repair #132820 is already in the base. Both task commits remain patch-equivalent: exactly four test/support files, +355/-88 (net +267), production +0/-0. Original 10,000 ms budgets and existing assertions are preserved. The original Windows timeout cause remains unknown; no tsx cache regression or causal cache fix is claimed.

Proceeding through native prepare and merge with all server gates intact.

@steipete
steipete merged commit 075c1f3 into main Aug 29, 2026
154 checks passed
@steipete
steipete deleted the steipete/affectionate-nightingale-80f73a branch August 29, 2026 21:43
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 30, 2026
* fix(test): join tsx fixture children before cleanup

* test: verify fixture retention at command settlement
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M 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