Repository navigation
fix(plugin-sdk): API diff fails under load and on macOS temporary checkouts - #164466
Conversation
…ailures The native declaration subprocess let an emission failure escape as an uncaught top-level rejection. Node then exited immediately, while the TypeScript native API's close() had only ended the compiler's stdin, so tsgo was still shutting down inside the managed process group. Under load the managed runner reported "Managed command exited while its process group remained active" and the real failure was lost. Report the failure through process.exitCode instead, so the event loop drains and joins the compiler exactly as the success path already does.
Native declaration emission sets rootDir to the realpath of the checkout, but the renderer derived its root file names from the unresolved repoRoot. The API diff renders revisions under os.tmpdir(), which is a symlinked alias on macOS (/var -> /private/var), so every source landed outside rootDir and the render failed with TS6059. Canonicalize repoRoot once when rendering starts.
|
🦞👀 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: blocked before merge. Reviewed October 3, 2026, 5:27 PM ET / 21:27 UTC (Revision 2). ClawSweeper reviewWhat this changesThe PR preserves compiler diagnostics while compiler shutdown completes and canonicalizes checkout paths so Plugin SDK API comparisons work through macOS temporary-directory aliases. Merge readiness⛔ Blocked before merge - 1 item remains The PR remains useful and has no blocking correctness findings. The earlier migration-proof blocker is resolved by source inspection: the subprocess hand-off is temporary and its format is unchanged. Priority: P2 Review scores
Verification
How this fits togetherPlugin SDK API comparison tooling compiles selected repository revisions and compares their public declarations. Its renderer uses a managed compiler subprocess and passes the resulting API surfaces to the comparison report. flowchart TD
A[Selected repository revisions] --> B[Temporary checkouts]
B --> C[Canonical checkout paths]
C --> D[Managed declaration compiler]
D --> E{Compilation result}
E -->|Success| F[API comparison report]
E -->|Failure| G[Joined shutdown and diagnostics]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +3, Tests +87, Other +7. Total +97 across 4 files. View PR surface stats
Review metricsNone. Stored data modelPersistent data-model change detected: Technical reviewBest possible solution: Keep one canonical renderer and strict compiler-process ownership while returning useful diagnostics on failure. Do we have a high-confidence way to reproduce the issue? Yes: current source exposes the mismatched canonical root and premature failure exit, and the captured body records the real macOS command failing before the repairs. This review did not execute that command. Is this the best way to solve the issue? Yes: the patch fixes both defects at their existing owners while preserving process-tree checks, declaration validation, and public SDK contracts. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 3f1239520835. 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.
|
Bring in the SDK API diff tooling fix from #164466. Preserve the involvement delta unchanged. Fresh P2 autoreview is scoped clean, and all 12 focused Gateway and worker involvement tests pass on the merged candidate.
…ckouts (openclaw#164466) * fix(scripts): join the native compiler before reporting declaration failures The native declaration subprocess let an emission failure escape as an uncaught top-level rejection. Node then exited immediately, while the TypeScript native API's close() had only ended the compiler's stdin, so tsgo was still shutting down inside the managed process group. Under load the managed runner reported "Managed command exited while its process group remained active" and the real failure was lost. Report the failure through process.exitCode instead, so the event loop drains and joins the compiler exactly as the success path already does. * fix(plugin-sdk): render API surfaces from canonical checkout roots Native declaration emission sets rootDir to the realpath of the checkout, but the renderer derived its root file names from the unresolved repoRoot. The API diff renders revisions under os.tmpdir(), which is a symlinked alias on macOS (/var -> /private/var), so every source landed outside rootDir and the render failed with TS6059. Canonicalize repoRoot once when rendering starts.
What Problem This Solves
Fixes:
pnpm plugin-sdk:api:difffails withManaged command exited while its process group remained activeand produces no report when the host is under heavy load, and on macOS it cannot render any revision at all.User Impact
Maintainers can run the released Plugin SDK comparison locally (including on macOS) and under load, and a genuine render failure now reports its real compiler diagnostics instead of an orphaned-process error. No product or public API behavior changes.
Why This Change Was Made
There were two defects, and the first was hiding the second.
The orphaned compiler. Native declaration emission runs in a managed subprocess that must leave no process-group member behind when it exits (
requireProcessTreeExit, no grace period on POSIX). The TypeScript native API'sclose()only ends the compiler's stdin and drops its process handle; it never waits for exit. On success that was fine, because Node's event loop keeps running until the ref'dtsgochild exits. On failure, though, the subprocess let the error escape as an uncaught top-level rejection, so Node exited immediately whiletsgowas still finishing its stdin-EOF shutdown. The managed runner then saw the live group, SIGKILLed it, and reported the orphan, discarding the real error. A loaded host just widens that race. The subprocess now reports the failure and setsprocess.exitCode, so the event loop drains and joins the compiler on the failure path exactly as it already did on success. The process-group check stays strict.The real failure underneath (macOS). With the orphan fixed, every macOS run surfaced thousands of
TS6059: File '/var/folders/…/src/plugin-sdk/…' is not under 'rootDir' '/private/var/folders/…'. Since #158674, emission setsrootDirto the realpath of the checkout, but the renderer passed root file names derived from the unresolvedrepoRoot. The diff renders revisions underos.tmpdir(), which is the/var→/private/varsymlink alias on macOS.renderPluginSdkApiBaselinenow canonicalizesrepoRootonce when rendering starts. The existing tests never caught this because the shared temp-dir helper already canonicalizesos.tmpdir().Evidence
All runs were on macOS (32 cores) at load averages between 50 and 97, with other agents' renders running concurrently.
pnpm run plugin-sdk:api:diff -- --base v2026.9.8 --head HEADstarted both renders, then failed withManaged command exited while its process group remained activeand no report, matching the reported failure.TS6059 … is not under 'rootDir'for every SDK source, after 259 s.2dfbd058).test/scripts/native-declaration-subprocess.test.ts: a deterministic delay hook (a preload wraps the spawnedtscso its process exits 500 ms after the real compiler, as a loaded host can impose) drives a real declaration failure (TS4094) throughemitNativeDeclarationsInSubprocess. Before the fix it fails with the orphan error; after the fix it passes 3/3 and asserts the compiler process exited before the subprocess settled. It is skipped on Windows, which has no managed tree join for this subprocess.pnpm test test/scripts/native-declaration-subprocess.test.ts --maxWorkers=1: 1 test, 2.3–4.0 s wall (about 1.4 s in the test).src/plugin-sdk/api-baseline.test.ts(renders a fixture through a symlinked alias): before the fix it fails with the same TS6059; after the fix it passes, taking 2.6 s.src/plugin-sdk/api-baseline.test.ts30/30 (80 s under load, mostly existing renders);test/scripts/native-declaration-boundary.test.ts15 passed, 3 platform-skipped.node scripts/check-changed.mjs --base <branch point>: passed, all 50 lanes (typecheck core/tests/extensions/scripts/test root, lint, dead-export scan, ratchets and guards), in 1,347 s. An earlier attempt stopped in extension typecheck on an unrelated qa-lab import because thegatewayworktree profile does not link that package's workspace dependencies; running the full profile'spnpm install --frozen-lockfilefixed the environment, with no code change.Stored Data
None. The V8-serialized
result.binin the native declaration subprocess is a per-call hand-off file in a privatemkdtempdirectory: the same build writes and reads it, then deletes it. This PR does not change its format, and nothing persists across versions, so no migration or upgrade proof applies.