Repository navigation
fix(test): script fixture tests time out copying the native compiler on loaded hosts - #163374
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed October 2, 2026, 11:57 AM ET / 15:57 UTC (Revision 3). ClawSweeper reviewWhat this changesThe 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 Review scores
Verification
How this fits togetherScript 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
Before mergeNone. Agent review detailsSecurityNone. PR surfaceTests +15. Total +15 across 8 files. View PR surface stats
Review metrics
Technical reviewBest 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. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
History |
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.
e568640 to
cd1c73c
Compare
|
Merged via squash.
|
…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.
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
materializeNativeCompilercopied all 493 files of the nativetypescriptpackage plus the platform package (tscbinary and defaultlib.*.d.ts) into every fixture. 482 of those files aredist/(thetypescript/unstable/*JavaScript API) andvendor/(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 onlypackage.json,lib/getExePath.js, and the platform package inside the checkout.Each consumer was traced from its test body through every spawned script:
changed-lanesroot-test lint casescheck-changedparses config with the repository's own API and binarywrite-plugin-sdk-entry-dts(2 sites),write-unified-entry-dtscreateFixturealready physically copies the identical package with its platform binary nested under it (since #156829); the extra call only overlaid the same bytesrun-tsgo-worktreeprimary installs,dist-artifact-ownership--versionpreflight,tsdown-declaration-resolutionWindows long-path casematerializeNativeCompiler(root, { javaScriptApi: false })run-tsgo-worktreelinked root,dist-artifact-ownershipinstallCompilercallersresolveInstalledNativeCompiler()); no copydist-artifact-ownershiplint-consumption casedist//vendor/, imports the fixture API, and admits default-library reads inside the checkoutdist-artifact-ownershipshard-concurrency casecompiler: falsebuild-artifact-cache,extension-boundary-cache,native-declaration-boundary,prepare-extension-package-boundary-artifacts.native,check-extension-package-tsc-boundary,tsdown-configbuild-artifact-cacheeven editsdist/api/async/api.js)Copies still go through
copyTreeCloseOnExec(filteredfs.cpSyncon libuv's close-on-exec path), which now accepts a caller filter. The defaultmaterializeNativeCompiler(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):
typescript(493 files)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.
dist-artifact-ownershipinstallCompilercases, shard concurrency, lint consumptioninstallCompilercases 1.9–7.6 srun-tsgo-worktreegit addstays under its own 10 s limit (#163322 fixes that part)changed-lanesroot-lint caseswrite-unified-entry-dts--testTimeoutlifted on the CLI (cold writerstatus === 0, all six[tsdown-build]invocations)write-plugin-sdk-entry-dtsRaw per-file runs (
pnpm test <file> --maxWorkers=1, local, 1-min load at start)Sequential passes:
dist-artifact-ownershipwrite-unified-entry-dtswrite-plugin-sdk-entry-dtsrun-tsgo-worktreegit addETIMEDOUT), 202.9 s, load 62changed-lanesBack-to-back pairs (patch reverse-applied for before, re-applied for after):
run-tsgo-worktreegit addETIMEDOUT before any compiler setup), 83.8 s, load 82dist-artifact-ownershipwrite-unified-entry-dtswrite-plugin-sdk-entry-dtschanged-laneswrite-plugin-sdk-entry-dtsABBA (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…",
-tfilter), 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.binjunction 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--testTimeoutlifted on the CLI: it passed in 92.4 s, including the cold writer'sstatus === 0and all six[tsdown-build]invocations.Gates:
node scripts/check-changed.mjs -- <changed files>passed (format,tsgo:test:rootacross 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, includingopenclaw/ci-gate,security-fast, and all five Windows jobs (which cover the Windows-only long-path case).Gaps:
tsdown-declaration-resolutionchange only affects awin32-only test (skipped on macOS); it is covered by the Windows CI jobs that passed on the landed head, not by local runs.tbx_01m3xrg8k3v9dn5k8hfs47vc5ztimed out after 15 min queued, behind about a dozen queuedci-check-testboxleases. Same-load local pairs replace it.run-tsgo-worktreefails on its fixture'sgit add10 s timeout (fixed separately in fix(test): run-tsgo worktree tests time out in git add on loaded hosts #163322), and an untouchedchanged-lanesconfig-doc case is load-sensitive (71 s against its 120 s budget on baseline; one worker run timed out).CI seconds:
write-unified-entry-dts11/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.