diff --git a/src/cli/acp-cli.option-collisions.test.ts b/src/cli/acp-cli.option-collisions.test.ts index 820467ba5a4..667720762da 100644 --- a/src/cli/acp-cli.option-collisions.test.ts +++ b/src/cli/acp-cli.option-collisions.test.ts @@ -12,6 +12,8 @@ const defaultRuntime = { writeStdout: vi.fn(), writeJson: vi.fn(), exit: vi.fn(), + writeStdout: vi.fn(), + writeJson: vi.fn(), }; const passwordKey = () => ["pass", "word"].join(""); diff --git a/src/cli/config-cli.test.ts b/src/cli/config-cli.test.ts index 9a699856575..148dcfa84d5 100644 --- a/src/cli/config-cli.test.ts +++ b/src/cli/config-cli.test.ts @@ -39,12 +39,13 @@ vi.mock("../runtime.js", async (importOriginal) => { return { ...actual, defaultRuntime: { + ...actual.defaultRuntime, log: (...args: unknown[]) => mockLog(...args), error: (...args: unknown[]) => mockError(...args), + exit: (code: number) => mockExit(code), writeStdout: (value: string) => mockLog(value.endsWith("\n") ? value.slice(0, -1) : value), writeJson: (value: unknown, space = 2) => mockLog(JSON.stringify(value, null, space > 0 ? space : undefined)), - exit: (code: number) => mockExit(code), }, }; }); diff --git a/src/cli/cron-cli.test.ts b/src/cli/cron-cli.test.ts index 4988af09a1a..97cd89b963b 100644 --- a/src/cli/cron-cli.test.ts +++ b/src/cli/cron-cli.test.ts @@ -34,6 +34,8 @@ vi.mock("../runtime.js", () => ({ exit: (code: number) => { throw new Error(`__exit__:${code}`); }, + writeStdout: vi.fn(), + writeJson: vi.fn(), }, })); diff --git a/src/cli/daemon-cli/install.integration.test.ts b/src/cli/daemon-cli/install.integration.test.ts index 52272b61f55..dbdf2924905 100644 --- a/src/cli/daemon-cli/install.integration.test.ts +++ b/src/cli/daemon-cli/install.integration.test.ts @@ -37,6 +37,9 @@ vi.mock("../../runtime.js", () => ({ exit: (code: number) => { throw new Error(`__exit__:${code}`); }, + writeStdout: (value: string) => runtimeLogs.push(value), + writeJson: (value: unknown, space = 2) => + runtimeLogs.push(JSON.stringify(value, null, space > 0 ? space : undefined)), }, })); diff --git a/src/cli/daemon-cli/test-helpers/lifecycle-core-harness.ts b/src/cli/daemon-cli/test-helpers/lifecycle-core-harness.ts index 84e3611b6da..7ecf4aac9ab 100644 --- a/src/cli/daemon-cli/test-helpers/lifecycle-core-harness.ts +++ b/src/cli/daemon-cli/test-helpers/lifecycle-core-harness.ts @@ -27,15 +27,15 @@ export const defaultRuntime: LifecycleRuntimeHarness = { runtimeLogs.push(args.map((arg) => String(arg)).join(" ")); }, error: vi.fn(), + exit: vi.fn((code: number) => { + throw new Error(`__exit__:${code}`); + }), writeStdout: vi.fn((value: string) => { runtimeLogs.push(value.endsWith("\n") ? value.slice(0, -1) : value); }), writeJson: vi.fn((value: unknown, space = 2) => { runtimeLogs.push(JSON.stringify(value, null, space > 0 ? space : undefined)); }), - exit: vi.fn((code: number) => { - throw new Error(`__exit__:${code}`); - }), }; export const service: LifecycleServiceHarness = { diff --git a/src/cli/devices-cli.test.ts b/src/cli/devices-cli.test.ts index bf3627fc72e..4abc7c77c75 100644 --- a/src/cli/devices-cli.test.ts +++ b/src/cli/devices-cli.test.ts @@ -21,6 +21,8 @@ const runtime = { runtime.log(JSON.stringify(value, null, space > 0 ? space : undefined)); }), exit: vi.fn(), + writeStdout: vi.fn((value: string) => runtime.log(value)), + writeJson: vi.fn((value: unknown, space = 2) => runtime.log(JSON.stringify(value, null, space))), }; vi.mock("../gateway/call.js", () => ({ diff --git a/src/cli/directory-cli.test.ts b/src/cli/directory-cli.test.ts index f2e2208bf54..0a1dca095ea 100644 --- a/src/cli/directory-cli.test.ts +++ b/src/cli/directory-cli.test.ts @@ -43,6 +43,8 @@ vi.mock("../runtime.js", () => ({ writeJson: (value: unknown, space = 2) => mocks.log(JSON.stringify(value, null, space > 0 ? space : undefined)), exit: (...args: unknown[]) => mocks.exit(...args), + writeStdout: (...args: unknown[]) => mocks.log(...args), + writeJson: (value: unknown, space = 2) => mocks.log(JSON.stringify(value, null, space)), }, })); diff --git a/src/cli/mcp-cli.test.ts b/src/cli/mcp-cli.test.ts index eb2f0fbdb73..3ab25e2603b 100644 --- a/src/cli/mcp-cli.test.ts +++ b/src/cli/mcp-cli.test.ts @@ -19,6 +19,8 @@ vi.mock("../runtime.js", () => ({ writeJson: (value: unknown, space = 2) => mockLog(JSON.stringify(value, null, space > 0 ? space : undefined)), exit: (code: number) => mockExit(code), + writeStdout: (value: string) => mockLog(value), + writeJson: (value: unknown, space = 2) => mockLog(JSON.stringify(value, null, space)), }, })); diff --git a/src/cli/memory-cli.test.ts b/src/cli/memory-cli.test.ts index 0a09d882ea1..ac55bd07cce 100644 --- a/src/cli/memory-cli.test.ts +++ b/src/cli/memory-cli.test.ts @@ -59,7 +59,11 @@ afterEach(() => { describe("memory cli", () => { function spyRuntimeLogs() { - return vi.spyOn(defaultRuntime, "log").mockImplementation(() => {}); + const logSpy = vi.spyOn(defaultRuntime, "log").mockImplementation(() => {}); + vi.spyOn(defaultRuntime, "writeJson").mockImplementation((value: unknown, space = 2) => { + logSpy(JSON.stringify(value, null, space)); + }); + return logSpy; } function spyRuntimeJson() { diff --git a/src/cli/qr-cli.test.ts b/src/cli/qr-cli.test.ts index c7d54a6247a..3a156da756a 100644 --- a/src/cli/qr-cli.test.ts +++ b/src/cli/qr-cli.test.ts @@ -15,6 +15,10 @@ const mocks = vi.hoisted(() => ({ exit: vi.fn(() => { throw new Error("exit"); }), + writeStdout: vi.fn((value: string) => mocks.runtime.log(value)), + writeJson: vi.fn((value: unknown, space = 2) => + mocks.runtime.log(JSON.stringify(value, null, space)), + ), }, loadConfig: vi.fn(), runCommandWithTimeout: vi.fn(), diff --git a/src/cli/route.test.ts b/src/cli/route.test.ts index a335f4f56e9..4a65bcfc24f 100644 --- a/src/cli/route.test.ts +++ b/src/cli/route.test.ts @@ -26,9 +26,9 @@ vi.mock("../runtime.js", () => ({ defaultRuntime: { error: vi.fn(), log: vi.fn(), + exit: vi.fn(), writeStdout: vi.fn(), writeJson: vi.fn(), - exit: vi.fn(), }, })); diff --git a/src/cli/test-runtime-capture.ts b/src/cli/test-runtime-capture.ts index 6ff5df0b0de..921693e572e 100644 --- a/src/cli/test-runtime-capture.ts +++ b/src/cli/test-runtime-capture.ts @@ -30,6 +30,12 @@ export function createCliRuntimeCapture(): CliRuntimeCapture { exit: (code: number) => { throw new Error(`__exit__:${code}`); }, + writeStdout: (value: string) => { + runtimeLogs.push(value); + }, + writeJson: (value: unknown, space = 2) => { + runtimeLogs.push(JSON.stringify(value, null, space > 0 ? space : undefined)); + }, }, resetRuntimeCapture: () => { runtimeLogs.length = 0; diff --git a/src/cli/update-cli.option-collisions.test.ts b/src/cli/update-cli.option-collisions.test.ts index e38b38184aa..d1ec19cb85e 100644 --- a/src/cli/update-cli.option-collisions.test.ts +++ b/src/cli/update-cli.option-collisions.test.ts @@ -16,6 +16,8 @@ const defaultRuntime = { defaultRuntime.log(JSON.stringify(value, null, space)); }), exit: vi.fn(), + writeStdout: vi.fn(), + writeJson: vi.fn(), }; vi.mock("./update-cli/update-command.js", () => ({ diff --git a/src/cli/update-cli.test.ts b/src/cli/update-cli.test.ts index b38e2c4075f..1433c25e5ee 100644 --- a/src/cli/update-cli.test.ts +++ b/src/cli/update-cli.test.ts @@ -139,11 +139,11 @@ vi.mock("../runtime.js", () => ({ defaultRuntime: { log: runtimeLog, error: runtimeError, + exit: runtimeExit, writeStdout: vi.fn((value: string) => runtimeLog(value.endsWith("\n") ? value.slice(0, -1) : value), ), writeJson: runtimeWriteJson, - exit: runtimeExit, }, })); diff --git a/test/fixtures/test-parallel.behavior.json b/test/fixtures/test-parallel.behavior.json index 2c5ea493022..4f70139a013 100644 --- a/test/fixtures/test-parallel.behavior.json +++ b/test/fixtures/test-parallel.behavior.json @@ -35,30 +35,14 @@ "file": "src/cron/isolated-agent/run.cron-model-override.test.ts", "reason": "Measured ~25% faster under threads than forks on this host while keeping the file green." }, - { - "file": "src/cron/isolated-agent/run.skill-filter.test.ts", - "reason": "Measured ~15% faster under threads than forks on this host while keeping the file green." - }, { "file": "src/cron/isolated-agent/run.owner-auth.test.ts", "reason": "Measured ~19% faster under threads than forks on this host while keeping the file green." }, - { - "file": "src/cron/isolated-agent.lane.test.ts", - "reason": "Measured ~14% faster under threads than forks on this host while keeping the file green." - }, - { - "file": "src/cron/isolated-agent.direct-delivery-forum-topics.test.ts", - "reason": "Measured ~11% faster under threads than forks on this host while keeping the file green." - }, { "file": "src/cron/isolated-agent.auth-profile-propagation.test.ts", "reason": "Measured ~22% faster under threads than forks on this host while keeping the file green." }, - { - "file": "src/cron/isolated-agent.delivers-response-has-heartbeat-ok-but-includes.test.ts", - "reason": "Measured ~12% faster under threads than forks on this host while keeping the file green." - }, { "file": "src/cron/isolated-agent/delivery-dispatch.named-agent.test.ts", "reason": "Measured ~14% faster under threads than forks on this host while keeping the file green." @@ -67,30 +51,6 @@ "file": "src/cron/isolated-agent.subagent-model.test.ts", "reason": "Measured ~21% faster under threads than forks on this host while keeping the file green." }, - { - "file": "src/cron/service.store-load-invalid-main-job.test.ts", - "reason": "Measured ~16% faster under threads than forks on this host while keeping the file green." - }, - { - "file": "src/cron/service.store-migration.test.ts", - "reason": "Measured ~14% faster under threads than forks on this host while keeping the file green." - }, - { - "file": "src/cron/service.failure-alert.test.ts", - "reason": "Measured ~17% faster under threads than forks on this host while keeping the file green." - }, - { - "file": "src/cron/service.persists-delivered-status.test.ts", - "reason": "Measured ~15% faster under threads than forks on this host while keeping the file green." - }, - { - "file": "src/cron/session-reaper.test.ts", - "reason": "Measured ~12% faster under threads than forks on this host while keeping the file green." - }, - { - "file": "src/cron/service.session-reaper-in-finally.test.ts", - "reason": "Measured ~21% faster under threads than forks on this host while keeping the file green." - }, { "file": "src/infra/outbound/deliver.test.ts", "reason": "Terminates cleanly under threads, but not process forks on this host."