fix(tests): isolate native Claude home, settle IPC contenders, select pack entries by name - #432
Conversation
… pack entries by name - native-claude-contract: every enabled runNativeClaudeSmoke now gets an isolated homeDirectory, so the stubbed smoke never digests the developer's real ~/.claude (2 GB / 7k files here) and the "fails closed" case no longer times out at 5 s when the claude CLI is installed. - event-ipc: attach the settlement handler to the losing contender the moment it is created. The loser rejects "already has a live server" as soon as the winner listens; on a loaded machine that happened before the test reached its await and surfaced as an unhandled file-level failure. - packOutputFromJson (src + scripts mirror) accepts a package name and selects the entry by it instead of by position; run-packed-tests, the release audit, shared-pack, and the packed native smoke harness pass their package names so a workspace-aware `npm pack --json` listing sibling packages still resolves the intended tarball.
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
🦋 Changeset detectedLatest commit: c511d01 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
@codex review |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
commit: |
|
@codex review |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Summary
Three test-isolation fixes, each fixed at source (no retries, no padding, no longer timeouts):
native-claude-contract.test.ts— every enabledrunNativeClaudeSmokenow receives an isolatedhomeDirectory(withIsolatedHome, mkdtemp + cleanup). Five tests previously ran withenvironment: {}/ nohomeDirectory, soresolveClaudeNormalHomefell back toos.homedir()and digested the developer's real~/.claude(2.1 GB / 7,479 files on this machine) before and after every stubbed run. The "fails closed when the candidate plugin…" case runs three smokes (six digests) and timed out at 5 s wherever theclaudeCLI is installed.event-ipc.test.ts— the three contender-race tests (does not unlink a concurrent winner…,serializes concurrent reclamation…,excludes a second orphan-claim remover…) now attach the settlement handler to the losing server promise the moment it is created (settleContender). Root cause: the loser rejectsEvent runtime endpoint already has a live server.as soon as the winner listens (≤ 10 ms retry loop), while the test only reached itsawait secondServerafter the winner had fully resolved (listen + chmod + stat + Effect layer plumbing). On a loaded machine the rejection landed first and surfaced as an unhandled, file-level failure ("fullName": "", stack inclaimEndpoint) — the exact signature seen in priorpnpm test:unitruns under concurrent lanes. Endpoint ids arecrypto.randomUUID()so there is no cross-run socket-path collision to isolate; the shared/tmpwas only the load source. A copy of the file with a forced 200 ms gap between winner resolution and the loserawaitreproduced the failure deterministically before the fix and passed after it.npm pack --jsonentry selection —packOutputFromJson(src/build/pack-inventory.ts+ thescripts/npm-pack-json.mjsmirror) accepts apackageNameand selects the entry by npm name instead of by position; without a name it still requires exactly one entry.scripts/run-packed-tests.mjs,scripts/audit-packed-release.mjs,tests/support/shared-pack.ts,tests/support/packed-native-smoke.ts,packed-consumer.test.ts, andcli.test.tspassagent-bundle/@agent-bundle/runtime/create-agent-bundle, so a workspace-aware pack that lists sibling packages still resolves the intended tarball. Unit coverage added inprepack.test.ts(array + package-keyed shapes, name-less npm 12 objects, 0/2 match errors).Evidence
Machine:
claudeon PATH (/home/zack/.local/bin/claude), other lanes running tests concurrently.fails closed…→test timed out in 5000ms; file wall 16.5 stest:unitlogs: file-levelEventRuntimeTransportError: Event runtime endpoint already has a live server.with"fullName": ""(5 separate runs on record); deterministic repro via 200 ms gap copy → same signaturepnpm build && pnpm test:packed:nativeon this machine: 6 passed / 1 skipped (35.8 s) — the 4-entrynpm pack --jsonoutput did not reproduce with npm 12.0.2 here, so the fix is by construction + unit-testedpnpm test:packed:nativeloop green (wall 23.7–28.0 s each, opt-in test skipped, Claude plugin proof passing);prepack.test.ts10/10 incl. new name-selection testThe isolated "fails closed…" case alone now runs in 179 ms (
-tfiltered run) versus the former 5 s timeout.Gates:
pnpm typecheck✅ (6.8 s),pnpm lint✅ (0 errors / 0 warnings, 1161 files),pnpm test:unit✅ 204 files, 3003 passed / 5 skipped / 0 failed (44.8 s).Test plan
pnpm exec rstest --config rstest.unit.config.ts packages/agent-bundle/tests/native-claude-contract.test.ts(withclaudeinstalled) — < 2 s, green.packages/agent-bundle/tests/event-ipc.test.tstwice in parallel — both green.pnpm build && pnpm test:packed:native— reaches harness setup, opt-in test skipped, Claude plugin proof passes.AGENT_BUNDLE_WORKBENCH_PREBUILT=1 AGENT_BUNDLE_PACKAGE_PREBUILT=1 pnpm exec rstest --config rstest.integration.config.ts packages/agent-bundle/tests/prepack.test.ts— green.Review status
c511d01cd6bbabed1bf96df3db21af27b7a90239(Changeset present, Dependency review, Docs site, Examples check, Host install proofs, RSC runtime micro-eval, Release gates, Verify (Node 24), pkg.pr.new preview).chatgpt-codex-connector: three requests (automatic on open at 16:51Z,@codex reviewat 16:52Z and 17:11Z) all answered "You have reached your Codex usage limits for code reviews". No review threads were opened.93bd86ea7(fix),c511d01cd(changeset PR reference; head). Merged on CI green per the standing rule; a follow-up PR will answer any threads codex raises later.