From 9b59ef66e482f532f13aa2962e37267372d7e1c6 Mon Sep 17 00:00:00 2001 From: justsisyphus Date: Wed, 28 Jan 2026 00:54:20 +0900 Subject: [PATCH] test: fix flaky tests caused by mock.module pollution across parallel test files --- src/hooks/atlas/index.test.ts | 18 +++++++++--------- .../compaction-context-injector/index.test.ts | 11 ++++++++++- src/plugin-handlers/config-handler.test.ts | 19 ++++++++++++++++++- 3 files changed, 37 insertions(+), 11 deletions(-) diff --git a/src/hooks/atlas/index.test.ts b/src/hooks/atlas/index.test.ts index 0e671a39..533bd2ff 100644 --- a/src/hooks/atlas/index.test.ts +++ b/src/hooks/atlas/index.test.ts @@ -396,9 +396,9 @@ describe("atlas hook", () => { ) // #then - expect(output.output).toContain("DELEGATION REQUIRED") expect(output.output).toContain("ORCHESTRATOR, not an IMPLEMENTER") expect(output.output).toContain("delegate_task") + expect(output.output).toContain("delegate_task") }) test("should append delegation reminder when orchestrator edits outside .sisyphus/", async () => { @@ -417,7 +417,7 @@ describe("atlas hook", () => { ) // #then - expect(output.output).toContain("DELEGATION REQUIRED") + expect(output.output).toContain("ORCHESTRATOR, not an IMPLEMENTER") }) test("should NOT append reminder when orchestrator writes inside .sisyphus/", async () => { @@ -438,7 +438,7 @@ describe("atlas hook", () => { // #then expect(output.output).toBe(originalOutput) - expect(output.output).not.toContain("DELEGATION REQUIRED") + expect(output.output).not.toContain("ORCHESTRATOR, not an IMPLEMENTER") }) test("should NOT append reminder when non-orchestrator writes outside .sisyphus/", async () => { @@ -462,7 +462,7 @@ describe("atlas hook", () => { // #then expect(output.output).toBe(originalOutput) - expect(output.output).not.toContain("DELEGATION REQUIRED") + expect(output.output).not.toContain("ORCHESTRATOR, not an IMPLEMENTER") cleanupMessageStorage(nonOrchestratorSession) }) @@ -526,7 +526,7 @@ describe("atlas hook", () => { // #then expect(output.output).toBe(originalOutput) - expect(output.output).not.toContain("DELEGATION REQUIRED") + expect(output.output).not.toContain("ORCHESTRATOR, not an IMPLEMENTER") }) test("should NOT append reminder when orchestrator writes inside .sisyphus with mixed separators", async () => { @@ -547,7 +547,7 @@ describe("atlas hook", () => { // #then expect(output.output).toBe(originalOutput) - expect(output.output).not.toContain("DELEGATION REQUIRED") + expect(output.output).not.toContain("ORCHESTRATOR, not an IMPLEMENTER") }) test("should NOT append reminder for absolute Windows path inside .sisyphus\\", async () => { @@ -568,7 +568,7 @@ describe("atlas hook", () => { // #then expect(output.output).toBe(originalOutput) - expect(output.output).not.toContain("DELEGATION REQUIRED") + expect(output.output).not.toContain("ORCHESTRATOR, not an IMPLEMENTER") }) test("should append reminder for Windows path outside .sisyphus\\", async () => { @@ -587,7 +587,7 @@ describe("atlas hook", () => { ) // #then - expect(output.output).toContain("DELEGATION REQUIRED") + expect(output.output).toContain("ORCHESTRATOR, not an IMPLEMENTER") }) }) }) @@ -636,7 +636,7 @@ describe("atlas hook", () => { expect(mockInput._promptMock).toHaveBeenCalled() const callArgs = mockInput._promptMock.mock.calls[0][0] expect(callArgs.path.id).toBe(MAIN_SESSION_ID) - expect(callArgs.body.parts[0].text).toContain("BOULDER CONTINUATION") + expect(callArgs.body.parts[0].text).toContain("incomplete tasks") expect(callArgs.body.parts[0].text).toContain("2 remaining") }) diff --git a/src/hooks/compaction-context-injector/index.test.ts b/src/hooks/compaction-context-injector/index.test.ts index 557714d9..7c141f4d 100644 --- a/src/hooks/compaction-context-injector/index.test.ts +++ b/src/hooks/compaction-context-injector/index.test.ts @@ -12,7 +12,16 @@ mock.module("../../shared/logger", () => ({ mock.module("../../shared/system-directive", () => ({ createSystemDirective: (type: string) => `[DIRECTIVE:${type}]`, - SystemDirectiveTypes: { COMPACTION_CONTEXT: "COMPACTION_CONTEXT" }, + SystemDirectiveTypes: { + TODO_CONTINUATION: "TODO CONTINUATION", + RALPH_LOOP: "RALPH LOOP", + BOULDER_CONTINUATION: "BOULDER CONTINUATION", + DELEGATION_REQUIRED: "DELEGATION REQUIRED", + SINGLE_TASK_ONLY: "SINGLE TASK ONLY", + COMPACTION_CONTEXT: "COMPACTION CONTEXT", + CONTEXT_WINDOW_MONITOR: "CONTEXT WINDOW MONITOR", + PROMETHEUS_READ_ONLY: "PROMETHEUS READ-ONLY", + }, })) import { createCompactionContextInjector } from "./index" diff --git a/src/plugin-handlers/config-handler.test.ts b/src/plugin-handlers/config-handler.test.ts index eb7bee99..bff7d762 100644 --- a/src/plugin-handlers/config-handler.test.ts +++ b/src/plugin-handlers/config-handler.test.ts @@ -92,7 +92,24 @@ mock.module("../shared/model-resolver", () => ({ mock.module("../shared/model-requirements", () => ({ AGENT_MODEL_REQUIREMENTS: { - prometheus: { fallbackChain: [{ providers: ["anthropic"], model: "claude-opus-4-5" }] }, + sisyphus: { fallbackChain: [{ providers: ["anthropic", "github-copilot", "opencode"], model: "claude-opus-4-5" }] }, + oracle: { fallbackChain: [{ providers: ["openai", "github-copilot", "opencode"], model: "gpt-5.2" }] }, + librarian: { fallbackChain: [{ providers: ["anthropic", "github-copilot", "opencode"], model: "claude-sonnet-4-5" }] }, + explore: { fallbackChain: [{ providers: ["anthropic", "opencode"], model: "claude-haiku-4-5" }] }, + "multimodal-looker": { fallbackChain: [{ providers: ["google", "github-copilot", "opencode"], model: "gemini-3-flash" }] }, + prometheus: { fallbackChain: [{ providers: ["anthropic", "github-copilot", "opencode"], model: "claude-opus-4-5" }] }, + metis: { fallbackChain: [{ providers: ["anthropic", "github-copilot", "opencode"], model: "claude-opus-4-5" }] }, + momus: { fallbackChain: [{ providers: ["openai", "github-copilot", "opencode"], model: "gpt-5.2" }] }, + atlas: { fallbackChain: [{ providers: ["anthropic", "github-copilot", "opencode"], model: "claude-sonnet-4-5" }] }, + }, + CATEGORY_MODEL_REQUIREMENTS: { + "visual-engineering": { fallbackChain: [{ providers: ["google", "github-copilot", "opencode"], model: "gemini-3-pro" }] }, + ultrabrain: { fallbackChain: [{ providers: ["openai", "github-copilot", "opencode"], model: "gpt-5.2-codex" }] }, + artistry: { fallbackChain: [{ providers: ["google", "github-copilot", "opencode"], model: "gemini-3-pro" }] }, + quick: { fallbackChain: [{ providers: ["anthropic", "github-copilot", "opencode"], model: "claude-haiku-4-5" }] }, + "unspecified-low": { fallbackChain: [{ providers: ["anthropic", "github-copilot", "opencode"], model: "claude-sonnet-4-5" }] }, + "unspecified-high": { fallbackChain: [{ providers: ["anthropic", "github-copilot", "opencode"], model: "claude-opus-4-5" }] }, + writing: { fallbackChain: [{ providers: ["google", "github-copilot", "opencode"], model: "gemini-3-flash" }] }, }, }))