Skip to content

fix(test): frozen admission test fails with spawn ETXTBSY when a sibling test forks during the native parser copy - #162969

Merged
steipete merged 2 commits into
mainfrom
steipete/modest-goodall-c4b7a3
Oct 1, 2026
Merged

steipete merged 2 commits into
mainfrom
steipete/modest-goodall-c4b7a3

Conversation

@steipete

@steipete steipete commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes: the core-tooling-2 shard intermittently fails package-acceptance-workflow.test.ts › "frozen admission workflow barriers / runs the actual June workflow request and shared parser before producers" with frozen bundle contract: unable to read selected bundle source: spawn ETXTBSY when another test file in the same Vitest process forks a child while the fixture copies the native TypeScript compiler.

User Impact

No user-visible change. CI stops flaking on this test. Every fixture that copies a native TypeScript package for later execution now goes through one helper that cannot leave sibling-forked children holding the copied compiler open for writing.

Why This Change Was Made

provisionParser() copied the @typescript/typescript-<platform>-<arch> package with an unfiltered recursive fs.cpSync. On Node 24 (checked on 24.19 and 24.21) that path runs in C++ (copyDir → fsBinding.cpSyncCopyDir → std::filesystem::copy_file), and syscall tracing on Linux showed lib/tsc opened as O_WRONLY|O_CREAT|O_TRUNC without O_CLOEXEC. With a JS filter, Node copies each file through copyFileSync, and libuv opens it as O_WRONLY|O_CREAT|O_CLOEXEC. The tooling project runs in the threads pool, so a sibling file's thread can fork during the copy. That child keeps the writable fd across its own exec, and the frozen bundle contract's lazy spawn(tsc) (typescript syncChannel.js) then fails with ETXTBSY. Node's ChildProcess.spawn throws that synchronous errno as the bare spawn ETXTBSY seen in CI.

Sibling fixtures had already fixed this same class three different ways: the filter: () => true trick in native-boundary-fixture.ts and live-docker-stage.test.ts, and a joined child-process writer in preflight-frozen-target-contracts.test.ts. This site was missed. This PR gives the job one owner, copyNativeCompilerPackage in test/scripts/native-boundary-fixture.ts, moves all four fixtures onto it, and deletes the joined-writer workaround (one fewer Node process per fixture).

The new test/scripts/native-boundary-fixture.test.ts is a Linux-only regression. A worker thread forks long-lived sh -c 'printf .; exec sleep 30' children, waiting for each child's first byte before forking the next. That byte proves the child has exec'd and dropped any close-on-exec descriptor. Meanwhile the helper copies the real platform package, and the test then execs the copied tsc. The fork count self-throttles to exec latency, and the 256 cap is only a non-fatal resource bound, so a slow disk cannot turn it into a false red.

Node's own copyDir carries a TODO to move filtered copies into C++ as well. If that ever lands, this regression is what will catch the helper silently losing close-on-exec.

Evidence

All runs on Blacksmith Testbox through node scripts/crabbox-wrapper.mjs (Linux 6.6, Node 24.19.0):

  • Shard-order repro on base 779880c635c2: rebuilt core-tooling-2 via createNodeTestShardBundles({ includeReleaseOnlyToolingShards: true }) and ran scripts/ci-run-node-test-shard.mts with OPENCLAW_NODE_TEST_GROUPS_JSON. All 3/3 replays passed (281 s, 231 s, 270 s), consistent with the reported timing dependence. The regression is the deterministic repro.
  • Regression red/green: with the helper body swapped back to the original unfiltered cpSync (sha256-verified swap and restore), it failed with ETXTBSY in 10/10 runs. With the fix it passed 20/20. Paced child counts were 5–9 red and 7–13 green.
  • Proof bar on the fixed tree: package-acceptance-workflow.test.ts 20/20 standalone, core-tooling-2 3/3 in original file order with no ETXTBSY, and all 22 fixture-caller files green (1,219 tests passed, 12 skipped). Planner/inventory guards passed (the new file is auto-owned by core-unit-fast-2).
  • Final pushed bytes (sha256-matched on the box): node scripts/check-changed.mjs --base origin/main passed, including root-test oxlint for every touched file and tsgo:test:root; regression 15/15 more runs; oxfmt 0.68.0 and git diff --check clean. Touching native-boundary-fixture.ts brings its pre-existing curly lint violation on main into changed-file lint, so this PR braces that if.
  • New test cost: pnpm test test/scripts/native-boundary-fixture.test.ts --maxWorkers=1 takes ~1.5 s command wall and ~106 ms test time.
  • Autoreview (Codex, P0–P2): scoped-clean.

Follow-ups, not in this PR: test/scripts/pr-wrapper.test-support.ts and pr-wrappers.test.ts copy shebang wrappers that are later exec'd directly and may belong to the same class. declaration-fixture-packages.ts already uses a filtered copy and was left as is, because its filter intentionally excludes nested node_modules.

…ing test forks during the native parser copy

package-acceptance-workflow's provisionParser() copied the native TypeScript
platform package with an unfiltered recursive cpSync. On Node 24 that path runs
in C++ (cpSyncCopyDir -> std::filesystem::copy_file) and opens the destination
without O_CLOEXEC. The tooling Vitest project runs in the threads pool, so a
sibling file's thread can fork a child mid-copy; the child keeps a writable fd
to the copied tsc across exec and the frozen bundle contract's later spawn of
tsc fails with ETXTBSY.

Sibling fixtures had patched the same class three different ways. Route every
native TypeScript package copy through one copyNativeCompilerPackage helper in
native-boundary-fixture.ts (filtered cpSync, i.e. libuv copyFileSync with
O_CLOEXEC), drop the joined child-process writer, and add a Linux regression
that forks paced long-lived children from a worker thread during the copy and
then execs the copied compiler.
@clawsweeper

clawsweeper Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. 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. labels Oct 1, 2026
@clawsweeper

clawsweeper Bot commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed October 1, 2026, 4:08 PM ET / 20:08 UTC.

ClawSweeper review

What this changes

The branch centralizes safe native compiler copying across test fixtures and adds a Linux regression for executing the copied compiler while sibling child processes remain alive.

Merge readiness

✅ Ready for maintainer review

This PR remains useful: current main and the latest release retain the affected unfiltered compiler copy. The focused fixture repair has credible reported red/green evidence, and no introduced blocking defect was found.

Priority: P2
Reviewed head: 5181740e32a2835ddc312e66fca33b6399dad5fc

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused repair with credible real-process validation and no identified blocking defect.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (terminal): For the changed test-support copy owner, the captured body reports real Linux Testbox red/green runs with sibling child processes and execution of the copied native compiler, plus successful admission-workflow and shard runs. The inspected harness matches that descriptor-inheritance scenario; results were not independently rerun. No stored-data contract changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): For the changed test-support copy owner, the captured body reports real Linux Testbox red/green runs with sibling child processes and execution of the copied native compiler, plus successful admission-workflow and shard runs. The inspected harness matches that descriptor-inheritance scenario; results were not independently rerun. No stored-data contract changes.
Evidence reviewed 8 items Pinned introduced change: The merge-base-to-head diff consolidates compiler copying in test support and migrates the affected fixtures. It changes no product runtime, dependency resolution, workflow permissions, or persistent user state.
Current-main necessity: Current main still uses unfiltered recursive cpSync for both parser packages in provisionParser. Its June/July workflow tests invoke this fixture before running the actual admission barrier.
Latest-release comparison: The same unfiltered provisionParser copies are present in v2026.9.7; the inspected release does not supersede this repair.
Findings None None.
Security None None.

How this fits together

Release-workflow tests copy an installed TypeScript compiler into isolated fixtures before checking source admission. These copies must remain executable when other test threads start child processes.

flowchart TD
  A[Installed compiler package] --> B[Shared fixture copy]
  C[Sibling test threads] --> D[Child processes]
  B --> E[Isolated compiler copy]
  E --> F[Source admission tests]
  D --> G[Concurrent execution check]
  E --> G
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Tests +74. Total +74 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 5 114 40 +74
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 114 40 +74

Review metrics

Metric Value Why it matters
Regression cost Reported ~106 ms test time; ~1.5 s command wall The real-process regression has a measured cost below the repository's per-file target.

Technical review

Best possible solution:

Keep compiler-copy safety in the shared fixture owner and retain the real-process regression for descriptor inheritance.

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

Yes: the Linux regression exercises real sibling forks during a native compiler copy, and the PR reports 10/10 failures with the original implementation. This reviewer inspected the path without executing it.

Is this the best way to solve the issue?

Yes: centralizing the existing filtered-copy workaround fixes the missed fixture and removes the separate writer-process workaround without changing admission policy.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 7b4623dc4cca.

Labels

Label changes:

  • add P2: This repairs a bounded test-fixture race without changing user-facing runtime behavior.
  • add proof: sufficient: Contributor real behavior proof is sufficient. For the changed test-support copy owner, the captured body reports real Linux Testbox red/green runs with sibling child processes and execution of the copied native compiler, plus successful admission-workflow and shard runs. The inspected harness matches that descriptor-inheritance scenario; results were not independently rerun. No stored-data contract changes.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): For the changed test-support copy owner, the captured body reports real Linux Testbox red/green runs with sibling child processes and execution of the copied native compiler, plus successful admission-workflow and shard runs. The inspected harness matches that descriptor-inheritance scenario; results were not independently rerun. No stored-data contract changes.

Label justifications:

  • P2: This repairs a bounded test-fixture race without changing user-facing runtime behavior.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): For the changed test-support copy owner, the captured body reports real Linux Testbox red/green runs with sibling child processes and execution of the copied native compiler, plus successful admission-workflow and shard runs. The inspected harness matches that descriptor-inheritance scenario; results were not independently rerun. No stored-data contract changes.
  • proof: sufficient: Contributor real behavior proof is sufficient. For the changed test-support copy owner, the captured body reports real Linux Testbox red/green runs with sibling child processes and execution of the copied native compiler, plus successful admission-workflow and shard runs. The inspected harness matches that descriptor-inheritance scenario; results were not independently rerun. No stored-data contract changes.

Evidence

What I checked:

  • Pinned introduced change: The merge-base-to-head diff consolidates compiler copying in test support and migrates the affected fixtures. It changes no product runtime, dependency resolution, workflow permissions, or persistent user state. (test/scripts/native-boundary-fixture.ts:8, 5181740e32a2)
  • Current-main necessity: Current main still uses unfiltered recursive cpSync for both parser packages in provisionParser. Its June/July workflow tests invoke this fixture before running the actual admission barrier. (test/scripts/package-acceptance-workflow.test.ts:398, 7b4623dc4cca)
  • Latest-release comparison: The same unfiltered provisionParser copies are present in v2026.9.7; the inspected release does not supersede this repair. (test/scripts/package-acceptance-workflow.test.ts, c074824a27c9)
  • Dependency contract verified: The introduced helper directly relies on Node's filtered cpSync behavior. Node v24.19.0 routes unfiltered directories through cpSyncCopyDir, whereas filtered traversal sends new files through copyFileSync. This supports the chosen repair mechanism. (lib/internal/fs/cp/cp-sync.js, cdc1b38d40cb)
  • Close-on-exec implementation: Node's vendored libuv copyfile implementation opens the destination through uv_fs_open; its Unix open implementation adds O_CLOEXEC. No Codex dependency signal exists in this fixture-copy change. (deps/uv/src/unix/fs.c:1265, cdc1b38d40cb)
  • Reported boundary validation: The captured PR body reports Linux 6.6 / Node 24.19.0 Testbox runs: original copy failed with ETXTBSY in 10/10 regression runs; the helper passed 20/20 plus 15 final-byte runs; the affected workflow file passed 20/20 and the original shard passed 3/3. The inspected regression copies the real platform package, waits for real child output, executes the copied binary, and kills and joins the children. These are contributor-reported results, not reviewer execution. (test/scripts/native-boundary-fixture.test.ts:12, 5181740e32a2)

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)
  • vincentkoc: 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.

@steipete
steipete merged commit 95af525 into main Oct 1, 2026
97 checks passed
@steipete
steipete deleted the steipete/modest-goodall-c4b7a3 branch October 1, 2026 20:26
@steipete

steipete commented Oct 1, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

vincentkoc added a commit that referenced this pull request Oct 1, 2026
* origin/main:
  fix(gateway): report approved-but-narrowed scope upgrades truthfully (#162951)
  fix: allow session-scoped shared publication reads (#162984)
  refactor(sessions): share session creation orchestration (#161336)
  perf(gateway): show the first chat sooner after a Gateway start (#162936)
  refactor(scripts): share npm verification command execution (#162978)
  fix(browser): clear MCP runtime cache after profile tests (#162982)
  fix(test): checkout fixture tests fail healthy runs on loaded macOS hosts (#162888)
  ci: bound PR extension lint to direct owners and smoke packages
  fix(ci): await native declaration discovery teardown
  feat(qa): drive forwarded text+photo bursts in Telegram userbot scenarios (#162906)
  build(macos): pin the app runtime to OpenClaw Bun 17c9ecf9eb (#162570)
  fix(test): frozen admission test fails with spawn ETXTBSY when a sibling test forks during the native parser copy (#162969)
  fix(ci): give direct published-driver callers the CI cell envelope (#162837)
  test(gateway): remove low-value tests (batch d136) (#162921)
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 2, 2026
…ing test forks during the native parser copy (openclaw#162969)

* fix(test): frozen admission test fails with spawn ETXTBSY when a sibling test forks during the native parser copy

package-acceptance-workflow's provisionParser() copied the native TypeScript
platform package with an unfiltered recursive cpSync. On Node 24 that path runs
in C++ (cpSyncCopyDir -> std::filesystem::copy_file) and opens the destination
without O_CLOEXEC. The tooling Vitest project runs in the threads pool, so a
sibling file's thread can fork a child mid-copy; the child keeps a writable fd
to the copied tsc across exec and the frozen bundle contract's later spawn of
tsc fails with ETXTBSY.

Sibling fixtures had patched the same class three different ways. Route every
native TypeScript package copy through one copyNativeCompilerPackage helper in
native-boundary-fixture.ts (filtered cpSync, i.e. libuv copyFileSync with
O_CLOEXEC), drop the joined child-process writer, and add a Linux regression
that forks paced long-lived children from a worker thread during the copy and
then execs the copied compiler.

* test: keep the regression's worker cleanup on the worker_threads postMessage shape
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. 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