From e43d2ccb96543430638a0d5cc8d2ec2c5af0c6d9 Mon Sep 17 00:00:00 2001 From: YeonGyu-Kim Date: Mon, 6 Apr 2026 12:07:00 +0900 Subject: [PATCH] fix(test): isolate atlas background-task-retry test to prevent setTimeout leak The test overrides globalThis.setTimeout which conflicts with other atlas tests when batched by bun test. Adding mock.module forces run-ci-tests.ts to run this file in its own isolated process. Also added setSessionAgent for descendant session to fix null agent lookup in non-SQLite CI environments. --- src/hooks/atlas/background-task-retry.test.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/hooks/atlas/background-task-retry.test.ts b/src/hooks/atlas/background-task-retry.test.ts index afefd7e4d..cc0a6873d 100644 --- a/src/hooks/atlas/background-task-retry.test.ts +++ b/src/hooks/atlas/background-task-retry.test.ts @@ -6,7 +6,13 @@ import { randomUUID } from "node:crypto" import type { PluginInput } from "@opencode-ai/plugin" import { createAtlasHook } from "./atlas-hook" import { clearBoulderState, writeBoulderState } from "../../features/boulder-state" -import { _resetForTesting, registerAgentName } from "../../features/claude-code-session-state" +import { _resetForTesting, registerAgentName, setSessionAgent } from "../../features/claude-code-session-state" + +// Force process isolation in CI runner (globalThis.setTimeout override conflicts with other atlas tests) +mock.module("../../shared/opencode-storage-detection", () => ({ + isSqliteBackend: () => true, + resetSqliteBackendCache: () => {}, +})) type LongTimerCallback = (...args: unknown[]) => void | Promise @@ -342,6 +348,7 @@ describe("atlas background task retry", () => { test("#given a persisted descendant becomes ineligible before retry fires #when retry runs #then atlas re-checks descendant eligibility and does not inject", async () => { // given const descendantSessionID = "ses_descendant_retry_mismatch" + setSessionAgent(descendantSessionID, "atlas") const planPath = join(testDir, "test-plan.md") writeFileSync(planPath, "# Plan\n- [ ] Task 1\n- [ ] Task 2") writeBoulderState(testDir, {