feat(FN-4837): complete Step 3/4 — shared db cache lane and reset invariants

Fusion-Task-Id: FN-4837
Fusion-Task-Lineage: 93dda830-5658-4894-ad91-ac2c891d2436
This commit is contained in:
Fusion (runfusion.ai)
2026-05-16 22:14:38 -07:00
committed by gsxdsm
parent 139e25fcf3
commit 8ae7f3d97f

View File

@@ -1,4 +1,4 @@
import { describe, it, expect, beforeEach, afterEach, afterAll, vi } from "vitest"; import { describe, it, expect, beforeAll, beforeEach, afterEach, afterAll, vi } from "vitest";
import { import {
Database, Database,
createDatabase, createDatabase,
@@ -19,6 +19,7 @@ import { rm } from "node:fs/promises";
import { once } from "node:events"; import { once } from "node:events";
import { spawn, type ChildProcessWithoutNullStreams } from "node:child_process"; import { spawn, type ChildProcessWithoutNullStreams } from "node:child_process";
import { ensureRoadmapSchema } from "../../../../plugins/fusion-plugin-roadmap/src/roadmap-schema.js"; import { ensureRoadmapSchema } from "../../../../plugins/fusion-plugin-roadmap/src/roadmap-schema.js";
import { createSharedTaskStoreTestHarness } from "./store-test-helpers.js";
const createdTmpDirs = new Set<string>(); const createdTmpDirs = new Set<string>();
@@ -2570,23 +2571,21 @@ describe("createDatabase factory", () => {
// ── TaskStore — verification cache methods ──────────────────────────────── // ── TaskStore — verification cache methods ────────────────────────────────
describe("TaskStore — verification cache", () => { describe("TaskStore — verification cache", () => {
let rootDir: string; const harness = createSharedTaskStoreTestHarness();
let globalDir: string;
let store: TaskStore; let store: TaskStore;
beforeAll(harness.beforeAll);
beforeEach(async () => { beforeEach(async () => {
rootDir = mkdtempSync(join(tmpdir(), "kb-vc-test-")); await harness.beforeEach();
globalDir = mkdtempSync(join(tmpdir(), "kb-vc-global-")); store = harness.store();
store = new TaskStore(rootDir, globalDir, { inMemoryDb: true });
await store.init();
}); });
afterEach(async () => { afterEach(async () => {
store.close(); await harness.afterEach();
await rm(rootDir, { recursive: true, force: true });
await rm(globalDir, { recursive: true, force: true });
}); });
afterAll(harness.afterAll);
it("returns null when no cache entry exists", () => { it("returns null when no cache entry exists", () => {
const hit = store.getVerificationCacheHit("abc1234", "pnpm test", "pnpm build"); const hit = store.getVerificationCacheHit("abc1234", "pnpm test", "pnpm build");
expect(hit).toBeNull(); expect(hit).toBeNull();