The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.
TypeScript 3d-modelingagent-frameworkagent-harnessai-agentscadclaude-codecodexcoding-agentsdeveloper-toolsesp32game-developmentmcp-servermulti-agentopen-hardwareopencodeopenharnesspcbroboticsterminaltmux
CLI resume gate passes on agent Macs: build the Darwin helper, room for one slow test, full coverage (#4405) (#3510)
0xken150b1d2757356b
diff --git a/cli/src/lib/resumeAgentService.spec.ts b/cli/src/lib/resumeAgentService.spec.tsindex 99748a415..ccda788bf 100644--- a/cli/src/lib/resumeAgentService.spec.ts+++ b/cli/src/lib/resumeAgentService.spec.ts@@ -449,6 +449,20 @@ describe('production resume handler', () => {const stopOrder = vi.mocked(stopConflictingBackgroundJob).mock.invocationCallOrder[0]const argvOrder = vi.mocked(buildEngineLaunchArgv).mock.invocationCallOrder[0]expect(stopOrder).toBeLessThan(argvOrder)+ // What the stop reports reaches the daemon's log under the agent's short id.+ const said = vi.spyOn(console, 'log').mockImplementation(() => {})+ try {+ vi.mocked(stopConflictingBackgroundJob).mock.calls[0]![0].log!('stopped background job bg-1')+ expect(said).toHaveBeenCalledWith(`[resume] ${saved.agentId.slice(0, 8)} stopped background job bg-1`)+ } finally { said.mockRestore() }+ })++ it('builds nothing when the resume is cancelled while the background job stops', async () => {+ rewrite({ engine: 'claude' })+ vi.mocked(stopConflictingBackgroundJob).mockImplementationOnce(async () => { deps.restartJobs.cancel(saved.agentId) })+ expect(await start()).toMatchObject({ ok: false, error: 'AGENT_CHANGED' })+ expect(buildEngineLaunchArgv).not.toHaveBeenCalled()+ expect(create).not.toHaveBeenCalled()})it('never checks for a background job on a fresh or fork launch (no resumeSessionId)', async () => {diff --git a/cli/src/lib/sessionRepair.spec.ts b/cli/src/lib/sessionRepair.spec.tsindex c584f14c1..8b8b2d0a1 100644--- a/cli/src/lib/sessionRepair.spec.ts+++ b/cli/src/lib/sessionRepair.spec.ts@@ -1,7 +1,8 @@import { clearEngineHomeFixture } from '../testing/engineHomeFixture.js'import { nativeConversationFixture } from '../testing/nativeConversationEvidence.js'+import { darwinProcessImages } from '../testing/darwinProcessImages.js'import { afterEach, describe, expect, it, vi } from 'vitest'-import { mkdirSync, mkdtempSync, readFileSync, realpathSync, rmSync, utimesSync, writeFileSync } from 'fs'+import { mkdirSync, mkdtempSync, realpathSync, rmSync, utimesSync, writeFileSync } from 'fs'import { execFileSync, spawn } from 'child_process'import { tmpdir } from 'os'import { join } from 'path'@@ -547,13 +548,9 @@ describe('session repair — a Codex process names its own rollout', () => {})it('does not give a starting process the only sibling rollout before its own file opens', async () => {- if (process.platform === 'darwin') {- // Native source tests explicitly supply the same verified artifact as the bundle.- // A missing helper is itself a held identity, never a permissive ps/lsof fallback.- const artifact = process.env.HARNESS_PROCESS_IMAGES_ARTIFACT- expect(artifact, 'Build the private Darwin helper for native integration tests').toBeTruthy()- vi.stubGlobal('__DARWIN_PROCESS_IMAGES__', readFileSync(artifact!, 'utf8'))- }+ // Native source tests supply the helper the bundle embeds: a missing one is itself a held identity, never a+ // permissive ps/lsof fallback.+ if (process.platform === 'darwin') vi.stubGlobal('__DARWIN_PROCESS_IMAGES__', darwinProcessImages())const profile = tempRoot()const sibling = 'a1b2c3d4-1111-4a4a-8a8a-000000000009'writeCodexRollout(profile, sibling, CWD, Date.now())@@ -594,10 +591,7 @@ describe('session repair — a Codex process names its own rollout', () => {})it('reads a live process\'s open files, and binds the repair to the rollout it holds', async () => {- if (process.platform === 'darwin') {- expect(process.env.HARNESS_PROCESS_IMAGES_ARTIFACT, 'Build the private Darwin helper for native integration tests').toBeTruthy()- vi.stubGlobal('__DARWIN_PROCESS_IMAGES__', readFileSync(process.env.HARNESS_PROCESS_IMAGES_ARTIFACT!, 'utf8'))- }+ if (process.platform === 'darwin') vi.stubGlobal('__DARWIN_PROCESS_IMAGES__', darwinProcessImages())const profile = tempRoot()const fork = 'a1b2c3d4-1111-4a4a-8a8a-000000000006'const forkFile = writeCodexRollout(profile, fork, CWD, STARTED_AT + 1_000)diff --git a/cli/src/lib/stoppedAgents.spec.ts b/cli/src/lib/stoppedAgents.spec.tsindex 3784f918e..5b1959157 100644--- a/cli/src/lib/stoppedAgents.spec.ts+++ b/cli/src/lib/stoppedAgents.spec.ts@@ -183,7 +183,9 @@ describe('saved catalog reads', () => {expect(store.list()).toHaveLength(2050)expect(readFileSync).toHaveBeenCalledTimes(2)}- })+ // 2,050 files written and listed three times: 0.8 to 0.9 s alone on the Mac Studio, 7.7 s inside `npm run test:resume`+ // beside six other files at a load of 6 to 7, past the 5 s default (task #4405).+ }, 30_000)})async function fixture() {diff --git a/cli/src/testing/darwinProcessImages.ts b/cli/src/testing/darwinProcessImages.tsnew file mode 100644index 000000000..8c08ca5e7--- /dev/null+++ b/cli/src/testing/darwinProcessImages.ts@@ -0,0 +1,31 @@+import { execFileSync } from 'child_process'+import { mkdtempSync, readFileSync, rmSync } from 'fs'+import { tmpdir } from 'os'+import { join } from 'path'+import { fileURLToPath } from 'url'++const BUILDER = fileURLToPath(new URL('../../scripts/build-process-images.py', import.meta.url))+let built: string | undefined++/** The private Darwin process-image helper a native macOS test stubs in as `__DARWIN_PROCESS_IMAGES__`: the verified+ * artifact HARNESS_PROCESS_IMAGES_ARTIFACT names (the release's), else one built once from this checkout by the+ * release's own builder. Agent Macs run `npm run test:resume` with no artifact set, so its native tests failed there+ * while Linux CI, which skips them, passed (task #4405). Building needs Xcode's command line tools, as a release does. */+export function darwinProcessImages(): string {+ const given = process.env.HARNESS_PROCESS_IMAGES_ARTIFACT+ if (given) return readFileSync(given, 'utf8')+ if (built) return built+ const dir = mkdtempSync(join(tmpdir(), 'harness-process-images-'))+ try {+ const output = join(dir, 'process-images.json')+ try {+ execFileSync('python3', [BUILDER, '--output', output], { stdio: 'pipe', timeout: 120_000 })+ } catch (error) {+ const detail = (error as { stderr?: Buffer }).stderr?.toString().trim() || String(error)+ throw new Error(`Building the Darwin process-image helper for native tests needs Xcode's command line tools: ${detail}`)+ }+ return built = readFileSync(output, 'utf8')+ } finally {+ rmSync(dir, { recursive: true, force: true })+ }+}diff --git a/docs/plans/2026-11-07-resume-gate-on-agent-macs-plan.md b/docs/plans/2026-11-07-resume-gate-on-agent-macs-plan.mdnew file mode 100644index 000000000..f8b41c504--- /dev/null+++ b/docs/plans/2026-11-07-resume-gate-on-agent-macs-plan.md@@ -0,0 +1,30 @@+# The resume gate passes on agent Macs (task #4405) Plan++> Written by the Engineer by the project's way of working: superpowers writing-plans, one pull request.++**Goal:** `npm run test:resume` passes at clean main on the Mac Studio, as its specs do in Linux CI, so pull requests in+that area can record their exact-head receipt.++**Spec:** Task #4405's brief.++## Reproduced at main 27356f78f, Mac Studio, `npm run test:resume`++Three causes, none of them the temp folder, a running Harness or the ES-module marker (so not #4356's or #4370's):++| # | What fails | Cause | Why CI passes |+|---|---|---|---|+| 1 | Two `sessionRepair.spec.ts` native tests | On macOS they stub in the private Darwin process-image helper from `HARNESS_PROCESS_IMAGES_ARTIFACT`, which only the release workflow builds. Unset on an agent Mac, so they fail at once. | Linux skips the Darwin branch. |+| 2 | `stoppedAgents.spec.ts` "bounds cached record count" (some runs) | 2,050 files written and listed three times: 0.8–0.9 s alone, 7.7 s beside six other files at load 6–7, past the 5 s default. | CI runners are not that loaded. |+| 3 | The gate's 100% coverage (`resumeAgentService.ts` 344, 347) | The resume's stop of a conflicting `claude --bg` job is mocked: its log callback never runs, and no test cancels a resume during that stop. | CI does not run the coverage gate. |++## Fixes++1. `src/testing/darwinProcessImages.ts`: the artifact the variable names, else one built once from this checkout by the+ release's own builder (`scripts/build-process-images.py`, ~1 s, Xcode command line tools). The spec uses it.+2. A 30 s limit on that one test, with the measurement as its reason. No sleep, no retry.+3. Two tests: the log line the stop reports, and a resume cancelled during the stop builds nothing.++## Evidence++- Red: main's `npm run test:resume` on the Mac Studio fails (2 tests; with the helper built, then coverage 99.81%).+- Green: the branch's `npm run test:resume` with no artifact set, 454 passed, 100% on every file.