Repository navigation
fix(test): run-tsgo worktree tests time out in git add on loaded hosts - #163322
Conversation
…/lib The linked-worktree fixture copied, committed, and checked out the whole scripts/lib directory (490 files with the top-level scripts), so its `git add .` exceeded the 10 s spawnSync budget on loaded hosts before any wrapper behavior ran. Commit only the wrapper's runtime import closure (29 files), computed by collectRuntimeImportClosure, plus the two files the CLI shim loads by path (run-tsgo.mts and tsx.mjs). Interleaved A/B at load 46-78: git add 36.2 s -> 3.0 s median, worktree add 16.4 s -> 6.1 s, copy 15.3 s -> 1.6 s. Wrapper status/stdout/stderr are byte-identical between the old and new fixtures; timeouts and assertions are unchanged.
|
🦞👀 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:45 AM ET / 15:45 UTC (Revision 2). ClawSweeper reviewWhat this changesThe compiler-wrapper tests copy only their runtime dependencies into temporary Git worktrees, reducing fixture setup work on loaded hosts. Merge readiness✅ Ready for maintainer review The PR remains useful: current main and the latest release still copy the full scripts library. The focused change preserves the existing assertions and budgets, with convincing measured evidence and no actionable patch findings. Priority: P2 Review scores
Verification
How this fits togetherThese tooling tests create independent Git checkouts and exercise OpenClaw’s compiler wrapper. They verify checkout-local compiler selection, missing-install refusal, and sparse-project skipping. flowchart TD
A[Compiler wrapper sources] --> B[Runtime dependency collection]
B --> C[Temporary primary checkout]
C --> D[Git commit and linked worktree]
D --> E[Real compiler wrapper invocation]
E --> F[Compiler selection and diagnostic assertions]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceTests +2. Total +2 across 1 file. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep fixture inputs tied to the existing runtime dependency collector while preserving real checkout-local compiler coverage. Do we have a high-confidence way to reproduce the issue? Yes for the reported loaded-host setup: the body supplies interleaved before/after Git measurements, and current main still stages the full library. This reviewer did not execute a current-main reproduction; timing failures depend on host contention. Is this the best way to solve the issue? Yes. Reusing the existing dependency collector removes unnecessary fixture work while retaining the real wrapper entrypoint, negative controls, assertions, and deadlines. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 8bb49fa67a27. 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
HistoryReview history (1 earlier review cycle)
|
|
Merged via squash.
|
…/lib (openclaw#163322) The linked-worktree fixture copied, committed, and checked out the whole scripts/lib directory (490 files with the top-level scripts), so its `git add .` exceeded the 10 s spawnSync budget on loaded hosts before any wrapper behavior ran. Commit only the wrapper's runtime import closure (29 files), computed by collectRuntimeImportClosure, plus the two files the CLI shim loads by path (run-tsgo.mts and tsx.mjs). Interleaved A/B at load 46-78: git add 36.2 s -> 3.0 s median, worktree add 16.4 s -> 6.1 s, copy 15.3 s -> 1.6 s. Wrapper status/stdout/stderr are byte-identical between the old and new fixtures; timeouts and assertions are unchanged.
What Problem This Solves
Fixes: all three tests in
test/scripts/run-tsgo-worktree.test.tsfail withspawnSync git ETIMEDOUTon loaded hosts. The failure comes from the fixture's owngit add ., before any wrapper behavior is exercised.User Impact
No user-visible change. The linked-worktree compiler wrapper tests stop spending their 10 s Git budget on hashing hundreds of unrelated files, so they fail far less often for reasons unrelated to the wrapper.
Why This Change Was Made
createLinkedCheckoutFixturecopied five scripts plus the wholescripts/libdirectory (490 files) into a temp primary checkout, committed everything, and checked it out again withgit worktree add. Thegit add, commit, and checkout each had to process every file. The wrapper only loads its own runtime import closure.The fixture now commits just that closure. It is computed by the existing owner,
collectRuntimeImportClosure(with dynamic imports), the same wayworktree-setup.test.tsand the run-vitest fixture build their checkouts. The closure is 29 files instead of 490. The CLI shim loads two files by path rather than by import, so they are explicit inputs:scripts/run-tsgo.mts(itsimplementationoption) andscripts/tsx.mjs(the--importloader). Because the list is computed, it follows the wrapper's import graph as it changes, and the hand-maintained top-level script list is gone. Git timeouts, test budgets, and assertions are unchanged, with no retries and no sleeps.Evidence
Host: 32-core Mac at load 46–89, APFS volume ~93% full.
Fixture steps, interleaved A/B. Six alternating pairs ran in one process, and each Git step was capped at 120 s for measurement only. Values are median (max):
scripts/lib(490 files)git add .git commitgit worktree addgit addexceeded the 10 s budget in 5 of 6 full-tree runs and 1 of 6 closure runs. The unchangedgit initranged from 2.4 s to 103 s in both variants. Those are kernel I/O stalls (processes sit in stateU); a fixture cannot bound them, but it can stop multiplying its exposure by 17×.Whole tests, one Vitest process. The original and changed fixtures ran in the same process with budgets lifted for measurement only:
Same contract. For all four wrapper invocations (
-p tsconfig.jsonin the linked checkout,--versionin primary and linked, and the sparse skip), status, stdout, and stderr were byte-identical between the full-tree and closure fixtures after normalizing temp paths and UUIDs. That includes theCannot find module 'typescript/package.json'refusal and the sparse-skip diagnostics. A module missing from the closure would fail the primary or linked wrapper runs withERR_MODULE_NOT_FOUND, not pass for a different reason.Real budgets.
spawnSync git ETIMEDOUT, insidegit initorgit add.installCheckoutTools, not Git: that test materializes the native compiler twice (24.5 s + 34.2 s at load ~89). That copy cost is tracked separately (fix(test): tsgo changed-test typecheck test times out on loaded hosts #163057 introduces a cheaper installed-compiler path).Cost of the closure. Computing it adds 0.6–2.3 s once per file at collection (module import plus graph build, measured at load ~60). CI timing for this file was 2 s (
config/ci-test-timings.json); on this head's CI run (jobchecks-node-compact-small-1, shardcore-tooling-8-hosted-3) the file took 1.71 s, with tests at 481 ms, 357 ms, and 181 ms.Checks. oxfmt, root-test oxlint (
node scripts/run-oxlint.mjs --tsconfig test/tsconfig/tsconfig.test.root.json),pnpm run tsgo:test:root, andgit diff --checkpass. Autoreview (Codex) ran on the diff.