import test from "node:test"; import assert from "node:assert/strict"; import { shouldSkipCodexAppServerDiscovery, } from "./codex-app-server-discovery-guard.mjs"; test("codex app-server discovery is skipped while a master task is running", () => { const decision = shouldSkipCodexAppServerDiscovery({ runtime: { masterTaskBusy: true, activeMasterTask: { taskId: "mastertask-running", status: "running", startedAt: "2026-06-07T07:35:33.368Z", }, }, }); assert.deepEqual(decision, { skip: true, reason: "master_task_running", activeTaskId: "mastertask-running", }); }); test("codex app-server discovery is allowed when explicit busy discovery is enabled", () => { const decision = shouldSkipCodexAppServerDiscovery({ config: { codexAppServerDiscoveryWhileMasterTaskBusy: true, }, runtime: { masterTaskBusy: true, activeMasterTask: { taskId: "mastertask-running", status: "running", }, }, }); assert.deepEqual(decision, { skip: false }); }); test("codex app-server discovery is allowed when no master task is active", () => { const decision = shouldSkipCodexAppServerDiscovery({ runtime: { masterTaskBusy: false, activeMasterTask: null, }, }); assert.deepEqual(decision, { skip: false }); });