diff --git a/packages/core/src/__tests__/builtin-workflows.test.ts b/packages/core/src/__tests__/builtin-workflows.test.ts index 491314877f..01c1e04c25 100644 --- a/packages/core/src/__tests__/builtin-workflows.test.ts +++ b/packages/core/src/__tests__/builtin-workflows.test.ts @@ -549,6 +549,12 @@ describe("built-in workflows", () => { expect(await store.getWorkflowDefinition("builtin:compound-engineering")).toBeUndefined(); }); + it("opens the plugin store before the shared harness resets globalDir", async () => { + const pluginStore = store.getPluginStore(); + await pluginStore.init(); + expect(await pluginStore.listPlugins()).toEqual([]); + }); + it("shows the compound-engineering built-in when its plugin is installed", async () => { await store.getPluginStore().registerPlugin({ manifest: { diff --git a/packages/core/src/__tests__/store-test-helpers.ts b/packages/core/src/__tests__/store-test-helpers.ts index 503beb21dd..d9855dc7bd 100644 --- a/packages/core/src/__tests__/store-test-helpers.ts +++ b/packages/core/src/__tests__/store-test-helpers.ts @@ -94,6 +94,14 @@ function resetMockPassThroughs() { } async function resetStoreFilesystem(rootDir: string, globalDir: string, store: TaskStore): Promise { + /* + * FNXC:CoreTests 2026-06-25-03:32: + * The shared harness reuses a TaskStore while clearing globalDir between tests. + * Close and null the lazy PluginStore first so its file-backed central DB never survives after fusion-central.db is removed. + */ + (store as any).pluginStore?.close?.(); + (store as any).pluginStore = null; + const fusionDir = store.getFusionDir(); await clearDirectoryContents(join(fusionDir, "tasks")); await clearDirectoryContents(join(fusionDir, "task-documents")); diff --git a/packages/core/src/__tests__/test-project.test.ts b/packages/core/src/__tests__/test-project.test.ts index 8c21af2a2b..0e7d101f04 100644 --- a/packages/core/src/__tests__/test-project.test.ts +++ b/packages/core/src/__tests__/test-project.test.ts @@ -44,8 +44,12 @@ describe("test-project fixture", () => { const configRaw = await readFile(join(fixture.rootDir, ".fusion", "config.json"), "utf-8"); const config = JSON.parse(configRaw); expect(config.nextId).toBeUndefined(); - // FNXC:Workspace 2026-06-24-23:50: taskPrefix defaults to undefined (derived from project name at runtime, see commit 800f845e1). The "FN" fallback is applied in store.ts createTask, not persisted in config.json. + /* + * FNXC:Workspace 2026-06-24-23:50: taskPrefix defaults to undefined (derived from project name at runtime, see commit 800f845e1). The "FN" fallback is applied in store.ts createTask, not persisted in config.json. + * FNXC:Settings 2026-06-25-03:36: Also assert the effective prefix so the fixture matches production config serialization without weakening explicit overrides. + */ expect(config.settings.taskPrefix).toBeUndefined(); + expect(config.settings.taskPrefix ?? "FN").toBe("FN"); const tasks = await fixture.store.listTasks(); expect(tasks).toHaveLength(0); diff --git a/packages/core/src/plugin-store.ts b/packages/core/src/plugin-store.ts index 7f7f399a92..62b568cee4 100644 --- a/packages/core/src/plugin-store.ts +++ b/packages/core/src/plugin-store.ts @@ -129,6 +129,18 @@ export class PluginStore extends EventEmitter { return this._centralDb; } + /** + * FNXC:Plugins 2026-06-25-03:31: + * Shared test harnesses clear the file-backed global settings directory between tests while reusing one TaskStore. + * Dispose both plugin database handles first so future plugin access reopens a fresh central DB instead of writing through a connection whose backing file was removed. + */ + close(): void { + this._localDb?.close(); + this._localDb = null; + this._centralDb?.close(); + this._centralDb = null; + } + async init(): Promise { const _ = this.localDb; const __ = this.centralDb;