Skip to content

fix(test): script fixture tests time out copying the native compiler on loaded hosts - #163374

Merged
steipete merged 1 commit into
mainfrom
steipete/native-compiler-fixture-subset
Oct 2, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/native-compiler-fixture-subset

Conversation

@steipete

@steipete steipete commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Related: #163057, #163322

What Problem This Solves

Fixes: script tooling tests time out on loaded hosts because every native-compiler fixture copies the whole TypeScript 7 package, even when the test never reads most of it.

User Impact

No user-visible change. Maintainer and CI tooling shards stop spending a full package copy (up to ~30 s per fixture on a loaded Mac) where a test only launches the compiler, or never touches the copy at all.

Why This Change Was Made

materializeNativeCompiler copied all 493 files of the native typescript package plus the platform package (tsc binary and default lib.*.d.ts) into every fixture. 482 of those files are dist/ (the typescript/unstable/* JavaScript API) and vendor/ (its JSON-RPC transport). Only two things read them from a fixture: toolchain identity (nativeTypeScriptToolchainFiles, which walks both directories) and API imports resolved from the fixture root. Launching the compiler through the production resolver needs only package.json, lib/getExePath.js, and the platform package inside the checkout.

Each consumer was traced from its test body through every spawned script:

Consumer What it actually needs Change
changed-lanes root-test lint cases Nothing from the copy: root-test lint is boundary-free and check-changed parses config with the repository's own API and binary Drop the copy
write-plugin-sdk-entry-dts (2 sites), write-unified-entry-dts createFixture already physically copies the identical package with its platform binary nested under it (since #156829); the extra call only overlaid the same bytes Drop the redundant overlay
run-tsgo-worktree primary installs, dist-artifact-ownership --version preflight, tsdown-declaration-resolution Windows long-path case Genuine in-root resolver and platform binary, no API materializeNativeCompiler(root, { javaScriptApi: false })
run-tsgo-worktree linked root, dist-artifact-ownership installCompiler callers An in-root interceptor that execs a real compiler Exec the installed binary (resolveInstalledNativeCompiler()); no copy
dist-artifact-ownership lint-consumption case Full fixture install and its own binary: preparation hashes dist//vendor/, imports the fixture API, and admits default-library reads inside the checkout Unchanged behavior (explicit full copy, fixture binary)
dist-artifact-ownership shard-concurrency case Only its synthetic compiler compiler: false
build-artifact-cache, extension-boundary-cache, native-declaration-boundary, prepare-extension-package-boundary-artifacts.native, check-extension-package-tsc-boundary, tsdown-config Fixture-root toolchain hashing and/or fixture-resolved API imports (build-artifact-cache even edits dist/api/async/api.js) Unchanged (full copy)

Copies still go through copyTreeCloseOnExec (filtered fs.cpSync on libuv's close-on-exec path), which now accepts a caller filter. The default materializeNativeCompiler(root) is still the full copy. No assertion, timeout, or retry changed. Test-only.

Evidence

Per-call copy cost (macOS, interleaved in one process, 4 rounds each, same copy semantics as the fixture):

Sample Full typescript (493 files) Launcher subset (11 files) Platform package (113 files)
load 45–63 31.6 s median 1.2 s 1.3–14 s
load 59–79 1.0 s median 27 ms 389 ms

Absolute cost on this 94%-full APFS volume tracks IO contention more than CPU load, but the subset is consistently 25–40× cheaper than the full package.

Per file, pnpm test <file> --maxWorkers=1 (local, 32-core Mac shared with other sessions):

What changes deterministically is the copy work and which tests stop failing at their budget under IO contention. Per-file wall clock on this shared host is dominated by contention from other sessions, which load averages don't capture: identical baseline runs of one file ranged from 78 s to 250 s. All raw numbers are below rather than a cherry-picked pair.

Signal Before (main) After
dist-artifact-ownership 8 of 32 tests timed out (30 s budget): the six installCompiler cases, shard concurrency, lint consumption 32/32 in both after-runs; installCompiler cases 1.9–7.6 s
run-tsgo-worktree 0/3 in the first pass 3/3 in 40.0 s when its fixture git add stays under its own 10 s limit (#163322 fixes that part)
changed-lanes root-lint cases 44.7–56.9 s 15.5–40.4 s
write-unified-entry-dts 5 of 11 timed out (120 s) in the first pass 1 of 11 timed out; the same test passes in 92.4 s with only --testTimeout lifted on the CLI (cold writer status === 0, all six [tsdown-build] invocations)
write-plugin-sdk-entry-dts 4 of 12 timed out (120 s) in the first pass 1 of 12 in the first pass; 12/12 in all three later full-file runs
Raw per-file runs (pnpm test <file> --maxWorkers=1, local, 1-min load at start)

Sequential passes:

File Before After
dist-artifact-ownership 24/32, 806.8 s, load 104 32/32, 234.5 s, load 46
write-unified-entry-dts 6/11, 498.9 s, load 57 10/11, 334.9 s, load 56
write-plugin-sdk-entry-dts 8/12, 745.0 s, load 50 11/12, 403.0 s, load 89
run-tsgo-worktree 0/3 (git add ETIMEDOUT), 202.9 s, load 62 2/3, 79.2 s, load 92; 3/3, 40.0 s, load 48
changed-lanes 106/106, 556.8 s, load 60 106/106, 265.1 s, load 73

Back-to-back pairs (patch reverse-applied for before, re-applied for after):

File Before After
run-tsgo-worktree 3/3, 89.7 s, load 50 2/3 (fixture git add ETIMEDOUT before any compiler setup), 83.8 s, load 82
dist-artifact-ownership 32/32, 209.7 s, load 88 32/32, 95.2 s, load 37
write-unified-entry-dts 11/11, 238.2 s, load 33 10/11 (120 s budget), 224.3 s, load 45
write-plugin-sdk-entry-dts 12/12, 121.9 s, load 36 12/12, 185.4 s, load 35
changed-lanes 106/106, 232.9 s, load 43 106/106, 311.3 s, load 70

write-plugin-sdk-entry-dts ABBA (before, after, after, before): 249.7 s (1 timeout), 214.7 s, 179.6 s, 78.2 s.

Because the after side of that file looked slower, I isolated the test that lost the overlay ("publishes fresh canonical partitions…", -t filter), with temporary timing on every writer launch (not committed). Before: 28.8, 31.7, 55.3, 59.3 s. After: 29.3, 31.3, 40.2, 44.8, 48.1, 54.1, and one 124.1 s outlier. Writer launches were 3–19 s on both sides. There is no systematic penalty; outliers in both directions match this host's known kernel APFS stalls (8–114 s in rename/open), and with calm IO the removed copy costs only a few seconds. The topology snapshot skips dot-entries inside installed trees, so the fixture keeping its .bin junction adds no snapshot work.

The remaining local failures in those runs are 120 s / 30 s per-test budgets expiring at load 55–92, never assertions. To rule out a masked regression in write-unified-entry-dts, "reuses unaffected canonical groups while rebuilding runtime after input edits" was rerun with only --testTimeout lifted on the CLI: it passed in 92.4 s, including the cold writer's status === 0 and all six [tsdown-build] invocations.

Gates: node scripts/check-changed.mjs -- <changed files> passed (format, tsgo:test:root across all three root shards, Knip dead-export scans, scripts lint, root-test oxlint). Codex autoreview: scoped-clean.

CI: the first run failed only on write-unified-entry-dts (ERR_PACKAGE_PATH_NOT_EXPORTED ./record-coerce), inherited from main after #162614 and fixed on main by 0a188c4. The branch was then rebased (patch-identical) onto that fix, and the refreshed head's CI run 37030006629 passed all 49 executed checks, including openclaw/ci-gate, security-fast, and all five Windows jobs (which cover the Windows-only long-path case).

Gaps:

  • The tsdown-declaration-resolution change only affects a win32-only test (skipped on macOS); it is covered by the Windows CI jobs that passed on the landed head, not by local runs.
  • Paired Linux Testbox proof was attempted but blocked by capacity: lease tbx_01m3xrg8k3v9dn5k8hfs47vc5z timed out after 15 min queued, behind about a dozen queued ci-check-testbox leases. Same-load local pairs replace it.
  • Pre-existing load failures seen on unmodified main: run-tsgo-worktree fails on its fixture's git add 10 s timeout (fixed separately in fix(test): run-tsgo worktree tests time out in git add on loaded hosts #163322), and an untouched changed-lanes config-doc case is load-sensitive (71 s against its 120 s budget on baseline; one worker run timed out).

CI seconds: write-unified-entry-dts 11/11 in 20.9 s of test time (job 110914625036, 80 s wall); per-file timings for the other touched files were not broken out of their shared shard jobs.

@clawsweeper

clawsweeper Bot commented Oct 2, 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 2, 2026
@clawsweeper

clawsweeper Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed October 2, 2026, 11:57 AM ET / 15:57 UTC (Revision 3).

ClawSweeper review

What this changes

The PR reduces script-test setup costs by copying only needed compiler files, reusing installed binaries behind fixture interceptors, and removing redundant copies.

Merge readiness

✅ Ready for maintainer review

This PR remains useful: current main still performs the unnecessary compiler copies, and related work addresses different fixture costs. No introduced blocking defect was found.

Priority: P2
Reviewed head: cd1c73c76fba7fa6216696cdf58805fd32c86091

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused fixture optimization with detailed comparative evidence and no identified blocking defect.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The changed fixture-copy owner is exercised by real filesystem measurements and actual compiler/declaration entrypoints on a loaded macOS setup, showing substantially cheaper copies and successful after-fix runs. Windows long-path coverage remains with its existing CI lane; 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 (live_output): The changed fixture-copy owner is exercised by real filesystem measurements and actual compiler/declaration entrypoints on a loaded macOS setup, showing substantially cheaper copies and successful after-fix runs. Windows long-path coverage remains with its existing CI lane; no stored-data contract changes.
Evidence reviewed 9 items Introduced patch: The pinned introduction changes fixture setup and shared test support; assertions, test budgets, production code, dependencies, and workflows are unchanged.
Current-main necessity: Fetched main retains the unconditional full-package copy and has no launcher-only option or installed-binary fixture helper. The central optimization is therefore still absent from current main; no merged fixing PR establishes redundancy.
Compiler boundary preserved: The production resolver admits the fixture-local package, executable resolver, and selected executable. Interceptor fixtures still supply those local entrypoints before delegating to the real installed binary. Consumers that hash dist/vendor or import the compiler API retain full installs.
Findings None None.
Security None None.

How this fits together

Script tests create temporary checkouts and invoke OpenClaw’s real compiler and declaration tooling. Their fixture setup supplies the dependencies needed to verify compiler selection, build ownership, and declaration output.

flowchart TD
  A[Script test scenario] --> B[Fixture dependency needs]
  B --> C[Full compiler install]
  B --> D[Launcher and platform files]
  B --> E[Fixture interceptor]
  E --> F[Installed compiler binary]
  C --> G[Real tooling and assertions]
  D --> G
  F --> G
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Tests +15. Total +15 across 8 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 8 52 37 +15
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 8 52 37 +15

Review metrics

Metric Value Why it matters
Compiler copy workload 493 → 11 TypeScript package files for launcher-only fixtures The supplied measurements show a deterministic reduction in filesystem work, while platform binaries and default libraries remain installed.

Technical review

Best possible solution:

Keep fixture dependencies proportional to each tested contract while retaining private full installs wherever compiler API, hashing, or declaration admission requires them.

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

Yes, the supplied before/after runs identify full compiler copying as a measurable setup bottleneck on loaded hosts, and current-main source confirms those copies. The reviewer did not execute tests; timeout frequency depends on host I/O contention.

Is this the best way to solve the issue?

Yes, tailoring existing fixture setup removes unnecessary work while preserving the real tooling entrypoints, full-install consumers, assertions, and deadlines.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 3c5010ebfacd.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This addresses concrete tooling-test timeouts with limited blast radius and no product-runtime change.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The changed fixture-copy owner is exercised by real filesystem measurements and actual compiler/declaration entrypoints on a loaded macOS setup, showing substantially cheaper copies and successful after-fix runs. Windows long-path coverage remains with its existing CI lane; no stored-data contract changes.
  • proof: sufficient: Contributor real behavior proof is sufficient. The changed fixture-copy owner is exercised by real filesystem measurements and actual compiler/declaration entrypoints on a loaded macOS setup, showing substantially cheaper copies and successful after-fix runs. Windows long-path coverage remains with its existing CI lane; no stored-data contract changes.

Evidence

What I checked:

  • Introduced patch: The pinned introduction changes fixture setup and shared test support; assertions, test budgets, production code, dependencies, and workflows are unchanged. (test/scripts/native-boundary-fixture.ts:46, cd1c73c76fba)
  • Current-main necessity: Fetched main retains the unconditional full-package copy and has no launcher-only option or installed-binary fixture helper. The central optimization is therefore still absent from current main; no merged fixing PR establishes redundancy. (test/scripts/native-boundary-fixture.ts:29, 3c5010ebfacd)
  • Compiler boundary preserved: The production resolver admits the fixture-local package, executable resolver, and selected executable. Interceptor fixtures still supply those local entrypoints before delegating to the real installed binary. Consumers that hash dist/vendor or import the compiler API retain full installs. (scripts/lib/local-check-runtime.mts:149, cd1c73c76fba)
  • Declaration copies already owned: The declaration fixture already recursively copies TypeScript and its platform optional dependency into private fixture storage. Removing the extra overlay preserves the compiler and API inputs used by declaration writers. (test/scripts/declaration-fixture-packages.ts:25, cd1c73c76fba)
  • After-fix behavior evidence: The supplied PR body records real filesystem copy measurements and actual compiler/declaration-tool runs on a loaded macOS host: launcher copies were consistently 25–40 times cheaper, dist-artifact ownership passed 32/32 in both after-runs, and worktree compiler tests passed 3/3 when the separate Git setup bottleneck stayed within budget. Remaining timeout failures and Windows coverage limitations are disclosed. These observations directly exercise the changed fixture setup rather than mocked compiler results.
  • Independent related work: fix(test): run-tsgo worktree tests time out in git add on loaded hosts #163322 remains open and reduces Git’s fixture import-tree workload; fix(test): tsgo changed-test typecheck test times out on loaded hosts #163057 merged and reduces compiler-interceptor process overhead. Neither supplies this PR’s compiler-copy optimization. (test/scripts/run-tsgo-worktree.test.ts:90, cd1c73c76fba)

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; 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 (2 earlier review cycles)
  • reviewed 2026-10-02T08:01:35.450Z sha e568640 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-02T09:01:05.163Z sha e568640 :: needs maintainer review before merge. :: none

materializeNativeCompiler copied the whole native typescript package into
every fixture. 482 of its 493 files are dist/ (the typescript/unstable/*
JavaScript API) and vendor/ (that API's JSON-RPC transport), which only
toolchain identity hashing and fixture-resolved API imports read.

Per consumer:
- changed-lanes: root-test lint is boundary-free and parses config with the
  repository's own API, so the copy was never read; drop it.
- write-plugin-sdk-entry-dts / write-unified-entry-dts: createFixture already
  copies the same package with its platform binary since the TypeScript 7
  cutover; drop the redundant overlay.
- run-tsgo-worktree, ownership --version preflight, Windows long-path
  resolution: launcher-only copies (javaScriptApi: false).
- interceptor fixtures that exec a real compiler: exec the installed binary
  (resolveInstalledNativeCompiler); the lint-consumption case keeps its full
  fixture-local install and binary because preparation hashes it and admits
  default-library reads inside the checkout.
- shard concurrency: its synthetic compiler needs no install.

Build-artifact, extension-boundary, native-declaration, prepare/check
boundary, and tsdown-config fixtures keep the full copy. Copies stay on the
filtered close-on-exec cpSync path; assertions and timeouts are unchanged.
@steipete
steipete force-pushed the steipete/native-compiler-fixture-subset branch from e568640 to cd1c73c Compare October 2, 2026 15:52
@steipete
steipete merged commit 4e3ab7b into main Oct 2, 2026
96 checks passed
@steipete
steipete deleted the steipete/native-compiler-fixture-subset branch October 2, 2026 17:13
@steipete

steipete commented Oct 2, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 3, 2026
…penclaw#163374)

materializeNativeCompiler copied the whole native typescript package into
every fixture. 482 of its 493 files are dist/ (the typescript/unstable/*
JavaScript API) and vendor/ (that API's JSON-RPC transport), which only
toolchain identity hashing and fixture-resolved API imports read.

Per consumer:
- changed-lanes: root-test lint is boundary-free and parses config with the
  repository's own API, so the copy was never read; drop it.
- write-plugin-sdk-entry-dts / write-unified-entry-dts: createFixture already
  copies the same package with its platform binary since the TypeScript 7
  cutover; drop the redundant overlay.
- run-tsgo-worktree, ownership --version preflight, Windows long-path
  resolution: launcher-only copies (javaScriptApi: false).
- interceptor fixtures that exec a real compiler: exec the installed binary
  (resolveInstalledNativeCompiler); the lint-consumption case keeps its full
  fixture-local install and binary because preparation hashes it and admits
  default-library reads inside the checkout.
- shard concurrency: its synthetic compiler needs no install.

Build-artifact, extension-boundary, native-declaration, prepare/check
boundary, and tsdown-config fixtures keep the full copy. Copies stay on the
filtered close-on-exec cpSync path; assertions and timeouts are unchanged.
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