From b2c784b3f81f203dafbd06bd4f5289ae0456ac69 Mon Sep 17 00:00:00 2001 From: gsxdsm Date: Sun, 19 Jul 2026 14:14:12 -0700 Subject: [PATCH] FN-8381: remove flaky dist-barrel test Remove the repeatedly quarantined extension dist-barrel test while retaining source-level listing coverage. - Delete the CPU-bound dist-barrel regression test after its fourth quarantine cycle. - Remove its quarantine exclusion and ledger entry. - Document retained source-level formatting and truncation coverage. Files changed: .../src/__tests__/extension-dist-barrel.test.ts | 204 --------------------- packages/cli/src/__tests__/extension.test.ts | 4 +- packages/cli/vitest.config.ts | 6 +- scripts/lib/test-quarantine.json | 5 - 4 files changed, 6 insertions(+), 213 deletions(-) Fusion-Task-Id: FN-8381 Fusion-Task-Lineage: ba6e61e1-fba1-4308-9d9d-1d3f387aa5e9 Co-authored-by: Fusion (runfusion.ai) --- .../__tests__/extension-dist-barrel.test.ts | 204 ------------------ packages/cli/src/__tests__/extension.test.ts | 4 +- packages/cli/vitest.config.ts | 6 +- scripts/lib/test-quarantine.json | 5 - 4 files changed, 6 insertions(+), 213 deletions(-) delete mode 100644 packages/cli/src/__tests__/extension-dist-barrel.test.ts diff --git a/packages/cli/src/__tests__/extension-dist-barrel.test.ts b/packages/cli/src/__tests__/extension-dist-barrel.test.ts deleted file mode 100644 index 5d42d29f4e..0000000000 --- a/packages/cli/src/__tests__/extension-dist-barrel.test.ts +++ /dev/null @@ -1,204 +0,0 @@ -import { describe, it, expect, vi, beforeAll, afterAll } from "vitest"; -import { mkdtemp, rm } from "node:fs/promises"; -import { dirname, join, resolve } from "node:path"; -import { tmpdir } from "node:os"; -import { fileURLToPath, pathToFileURL } from "node:url"; - -/* -FNXC:CliTests 2026-07-04-13:50: -FN-7530 split this single test out of extension.test.ts. The whole-file exclude that FN-7447 applied to -extension.test.ts to quarantine this one dist-barrel recompilation case was collaterally dropping ~68 otherwise-stable -tests. Isolating it here lets extension.test.ts return to the default lane while this file (and only this file) carries -its own quarantine entry/deletion clock in lockstep with scripts/lib/test-quarantine.json. See that ledger entry and -packages/cli/vitest.config.ts for the current in/out-of-lane status and root-cause note. -*/ - -vi.mock("@fusion/core/gh-cli", () => ({ - isGhAvailable: vi.fn(() => true), - isGhAuthenticated: vi.fn(() => true), - runGhJsonAsync: vi.fn(), - getGhErrorMessage: vi.fn((error: unknown) => (error instanceof Error ? error.message : String(error))), -})); - -vi.mock("../commands/task.js", () => ({ - runTaskPlan: vi.fn(), -})); - -import { MAX_TASK_LIST_TEXT_CHARS, type Task, type TaskStore } from "@fusion/core"; -import { hasBuiltCoreDistBarrel } from "@fusion/test-utils"; - -const __dirname = dirname(fileURLToPath(import.meta.url)); - -// ── Mock ExtensionAPI that captures registrations (mirrors extension.test.ts) ── - -interface RegisteredTool { - name: string; - label: string; - description: string; - execute: ( - toolCallId: string, - params: any, - signal: AbortSignal | undefined, - onUpdate: ((update: any) => void) | undefined, - ctx: any, - ) => Promise; -} - -function createMockAPI() { - const tools = new Map(); - const commands = new Map(); - const events = new Map(); - - const api = { - registerTool(def: any) { - tools.set(def.name, def); - }, - registerCommand(name: string, def: any) { - commands.set(name, def); - }, - registerShortcut: vi.fn(), - registerFlag: vi.fn(), - on(event: string, handler: Function) { - events.set(event, handler); - }, - tools, - commands, - events, - }; - - return api as any; -} - -function makeCtx(cwd: string) { - return { cwd } as any; -} - -/* -FNXC:CliTests 2026-07-18-07:15: -FN-8271 removes the PG template-database fixture from this built-barrel regression guard. The tool only reads `listTasks`, so coupling its required dist recompilation to CREATE DATABASE ... TEMPLATE and twenty persistent writes made one beforeAll compete for both CPU and the shared PostgreSQL DDL server under shard-4 load. Keep the fixture in memory and inject it through the extension's explicit test cache seam: this preserves the actual fn_task_list formatting/truncation surface while leaving PG isolation coverage to the shared harness consumers that require it. -*/ -const distBarrelTasks = Array.from({ length: 20 }, (_, index) => ({ - id: `FN-${String(index + 1).padStart(3, "0")}`, - title: `Runtime-dist todo task ${String(index + 1).padStart(3, "0")} ${"x".repeat(300)}`, - description: `Runtime-dist todo task ${String(index + 1).padStart(3, "0")}`, - column: "todo", - dependencies: index === 0 ? [] : ["FN-001"], - paused: false, - steps: [], - currentStep: 0, -}) satisfies Partial) as Task[]; - -const distBarrelListStore = { - listTasks: vi.fn(async () => distBarrelTasks), -} as unknown as TaskStore; - -describe.skipIf(!hasBuiltCoreDistBarrel(resolve(__dirname, "../../../core/dist")))( - "fn pi extension (dist-barrel recompilation slice)", - () => { - let tmpDir: string; - let listTool: RegisteredTool; - let closeRuntimeCachedStores: (() => Promise) | undefined; - let runtimeDistArtifactUnavailable = false; - - beforeAll(async () => { - tmpDir = await mkdtemp(join(tmpdir(), "fn-ext-dist-barrel-")); - - /* - FNXC:CliTests 2026-07-18-07:15: - The remaining beforeAll work is only built-dist recompilation. The synchronous barrel predicate covers its direct artifacts but cannot prove every transitive runtime import exists, so record ERR_MODULE_NOT_FOUND here and let each test use its own context to skip cleanly instead of calling a nonexistent suite-hook ctx.skip(). The list-only injected fixture has no connection or file handles; close the runtime cache before removing its temporary project root. - */ - try { - vi.resetModules(); - const distCoreIndex = resolve(__dirname, "../../../core/dist/index.js"); - const distCoreUrl = pathToFileURL(distCoreIndex).href; - const distCoreModule = await vi.importActual(distCoreUrl); - vi.doMock("@fusion/core", () => distCoreModule); - - const runtimeModule = await import("../extension.js?fn6535-runtime-core-dist"); - closeRuntimeCachedStores = runtimeModule.closeCachedStores; - const runtimeApi = createMockAPI(); - runtimeModule.default(runtimeApi); - runtimeModule.__setCachedStoreForTesting(resolve(tmpDir), distBarrelListStore); - listTool = runtimeApi.tools.get("fn_task_list")!; - } catch (error) { - const code = error instanceof Error && "code" in error - ? (error as Error & { code?: string }).code - : undefined; - if (code === "ERR_MODULE_NOT_FOUND") { - runtimeDistArtifactUnavailable = true; - return; - } - throw error; - } - }); - - afterAll(async () => { - try { - await closeRuntimeCachedStores?.(); - if (tmpDir) { - await rm(tmpDir, { recursive: true, force: true }); - } - } finally { - vi.doUnmock("@fusion/core"); - vi.resetModules(); - } - }); - - /* - FNXC:TaskListOutput 2026-06-17-02:37: - FN-6535 reproduces the heartbeat failure at the actual CLI tool surface while forcing @fusion/core to resolve through the built dist barrel. The normal CLI suite aliases @fusion/core to source, so this targeted mock is the regression guard for stale exports.import dist artifacts. - - FNXC:CoreTests 2026-06-18-01:35: - FN-6627 aligns the skip gate with every built @fusion/core dist artifact this runtime-dist mock loads, so a partial stale dist skips cleanly while a complete dist still exercises the heartbeat fn_task_list surface. - - FNXC:CliTests 2026-06-19-11:17: - FN-6734 keeps this guard in the default 5s lane by preserving the runtime-dist truncation invariant with fewer fixture writes instead of appeasing timeouts or reducing workers. - - FNXC:CliTests 2026-06-19-13:16: - The full CLI affected lane runs this file beside many module-mocking suites; verify the built barrel is importable in the executing worker before installing the mock, then skip like the partial-dist gate if a concurrent lane observes stale dist artifacts. - - FNXC:CliTests 2026-07-04-13:50: - FN-7530 moved this case out of extension.test.ts unchanged (same assertions, same dist-resolution invariant, same skip gate). The sibling source-@fusion/core test "bounds large column-filtered listings as a single plain-text block" in extension.test.ts covers the identical truncation invariant against source; this test's only marginal coverage is that the built dist barrel resolves/executes identically, which is why it stays a dedicated, narrowly-scoped file rather than being deleted. - */ - it("lists the built-dist barrel fixture broadly within the text budget", async (ctx) => { - if (runtimeDistArtifactUnavailable) return ctx.skip(); - - const broadResult = await listTool.execute( - "list-runtime-dist-broad", - { limit: 20 }, - undefined, - undefined, - makeCtx(tmpDir), - ); - const broadText = broadResult.content[0].text; - expect(broadResult.content).toHaveLength(1); - expect(broadResult.content[0].type).toBe("text"); - expect(broadText.length).toBeLessThanOrEqual(MAX_TASK_LIST_TEXT_CHARS); - expect(broadText).toContain("Todo (20):"); - expect(broadText).toContain("FN-001"); - expect(broadText).toContain("[deps: FN-001]"); - expect(broadText).toContain("truncated to fit; narrow with column/limit"); - }); - - it("lists the built-dist barrel todo column within the text budget", async (ctx) => { - if (runtimeDistArtifactUnavailable) return ctx.skip(); - - const todoResult = await listTool.execute( - "list-runtime-dist-todo", - { column: "todo", limit: 20 }, - undefined, - undefined, - makeCtx(tmpDir), - ); - const todoText = todoResult.content[0].text; - expect(todoResult.content).toHaveLength(1); - expect(todoResult.content[0].type).toBe("text"); - expect(todoText.length).toBeLessThanOrEqual(MAX_TASK_LIST_TEXT_CHARS); - expect(todoText).toContain("Todo (20):"); - expect(todoText).toContain("FN-001"); - expect(todoText).toContain("[deps: FN-001]"); - expect(todoText).toContain("truncated to fit; narrow with column/limit"); - expect(todoResult.details.count).toBe(20); - }); - }, -); diff --git a/packages/cli/src/__tests__/extension.test.ts b/packages/cli/src/__tests__/extension.test.ts index 188a8b9c62..1389fad9c3 100644 --- a/packages/cli/src/__tests__/extension.test.ts +++ b/packages/cli/src/__tests__/extension.test.ts @@ -3070,8 +3070,8 @@ pgTest("fn pi extension (runnable structured-output regression slice)", () => { }); /* - FNXC:CliTests 2026-07-04-13:50: - FN-7530 split the sibling "executes with @fusion/core resolved through the built dist barrel" case (formerly directly below this test) into packages/cli/src/__tests__/extension-dist-barrel.test.ts. That test's own in-test dist-barrel recompilation (vi.resetModules + vi.importActual of the built @fusion/core dist barrel) is CPU-bound and timeout-prone under 4-shard CI contention (FN-6483/FN-6705/FN-6795/FN-6839/FN-7447 same signature); isolating it kept the ~68 stable tests in this file on the default lane while only the isolated file carries its own quarantine entry. This test covers the identical truncation invariant against the source-aliased @fusion/core. + FNXC:CliTests 2026-07-18-20:45: + FN-8381 deleted the fourth-quarantine built-dist-barrel companion because its full re-mocked module graph was CPU-bound and exceeded the default hook timeout under shard load. Retain this source-aliased test as the focused fn_task_list formatting, dependency, column, count, and truncation invariant; the deleted test's marginal full-barrel substitution signal did not justify timeout, retry, or worker-budget appeasement. */ it("bounds large column-filtered listings as a single plain-text block", async () => { const store = createStore(); diff --git a/packages/cli/vitest.config.ts b/packages/cli/vitest.config.ts index 1bd042bc6b..d6a22d78f5 100644 --- a/packages/cli/vitest.config.ts +++ b/packages/cli/vitest.config.ts @@ -106,12 +106,14 @@ const quarantinedCliTests: string[] = [ Full-suite shard 4 after FN-8271 (runs 29648812375 / 29648952207) re-observed mcp-lock-retry and task-lock-retry 5s timeouts under package-lane shard load without product-bug evidence. Quarantine on sight in lockstep with scripts/lib/test-quarantine.json — do not raise testTimeout or fake-timer budgets. FNXC:CliTests 2026-07-18-15:20: - Full-suite shard 4 on tip after #2322 (run 29662476909): bundle-output failed building desktop assets (ENOENT vendor-reactflow CSS) and extension-dist-barrel beforeAll timed out at 10s under package-lane load without product-bug evidence. Quarantine on sight — do not raise hookTimeout or soften build assertions. + Full-suite shard 4 on tip after #2322 (run 29662476909): bundle-output failed building desktop assets (ENOENT vendor-reactflow CSS) under package-lane load without product-bug evidence. Quarantine on sight — do not soften build assertions. + + FNXC:CliTests 2026-07-18-20:45: + FN-8381 deletes extension-dist-barrel after its fourth quarantine cycle. Timing isolated the full core dist-barrel and re-mocked extension module graph as a 4–5.5s CPU-bound beforeAll while temp setup and cache seeding were negligible; shard contention pushed the same hook beyond Vitest's default 10s in run 29662476909. The source-side extension test retains the fn_task_list formatting/truncation invariant, while this test's marginal full-barrel substitution signal is not worth another load-sensitive rescue. Keep it out of both this exclusion and scripts/lib/test-quarantine.json; do not replace deletion with timeout, retry, or worker-budget appeasement. */ "src/commands/__tests__/mcp-lock-retry.test.ts", "src/commands/__tests__/task-lock-retry.test.ts", "src/__tests__/bundle-output.test.ts", - "src/__tests__/extension-dist-barrel.test.ts", ]; /* diff --git a/scripts/lib/test-quarantine.json b/scripts/lib/test-quarantine.json index 26e9c88762..cbaa0649d2 100644 --- a/scripts/lib/test-quarantine.json +++ b/scripts/lib/test-quarantine.json @@ -31,11 +31,6 @@ "reason": "Full-suite shard 4 (run 29662476909): pnpm build:package / desktop vite build ENOENT on vendor-reactflow CSS under concurrent package-lane load without product-bug evidence. Quarantine on sight per AGENTS.md. Mirrored in packages/cli/vitest.config.ts.", "quarantinedAt": "2026-07-18" }, - { - "file": "packages/cli/src/__tests__/extension-dist-barrel.test.ts", - "reason": "Full-suite shard 4 (run 29662476909): beforeAll hook timed out at 10s under package-lane load without product-bug evidence (prior FN-8093/FN-8271 rescue). Quarantine on sight per AGENTS.md. Mirrored in packages/cli/vitest.config.ts.", - "quarantinedAt": "2026-07-18" - }, { "file": "packages/engine/src/__tests__/reliability-interactions/merge-reuse-task-worktree.slow.test.ts", "reason": "Full-suite engine-slow (run 29663725381): FN-5363 queue-head pollution handoff left leased merge-queue row after merge under load without product-bug evidence. Quarantine on sight per AGENTS.md. Mirrored in packages/engine/vitest.config.ts engine-slow exclude.",