test(core): drop the legacy memory engine from core tests (P1.5)

- install audit: build fixtures on WaggleDB, the store's real home; drop the
  substrate SCHEMA_SQL parity half and the two MindDB-only recovery cases
  for rows stranded in install_audit__mig_old.
- workspace manager: create() and ensure() no longer leave a workspace.mind;
  getMindPath tests create the legacy file themselves. Drop the
  MultiMindCache cases (reopen of a missing mind, post-resolution junction
  swap): they tested the legacy cache, not the manager.
- transformers model load: use core's own in-process reranker.
This commit is contained in:
shumeiko.it
2026-10-24 13:33:27 +02:00
parent 52ee21ddb5
commit c6a9fbf85a
4 changed files with 36 additions and 163 deletions

View File

@@ -3,7 +3,6 @@ import fs from 'node:fs';
import path from 'node:path';
import os from 'node:os';
import { WorkspaceManager, type WorkspaceConfig } from '../src/workspace-manager.js';
import { MultiMindCache } from '@waggle/hive-mind-core';
describe('WorkspaceManager', () => {
let tmpDir: string;
@@ -35,7 +34,7 @@ describe('WorkspaceManager', () => {
});
describe('create', () => {
it('creates workspace with directory, config, mind file, and sessions dir', () => {
it('creates workspace with directory, config and sessions dir, and no mind file', () => {
const ws = manager.create({ name: 'My Project', group: 'Work' });
expect(ws.id).toBe('my-project');
@@ -46,7 +45,7 @@ describe('WorkspaceManager', () => {
const wsDir = path.join(tmpDir, 'workspaces', 'my-project');
expect(fs.existsSync(wsDir)).toBe(true);
expect(fs.existsSync(path.join(wsDir, 'workspace.json'))).toBe(true);
expect(fs.existsSync(path.join(wsDir, 'workspace.mind'))).toBe(true);
expect(fs.existsSync(path.join(wsDir, 'workspace.mind'))).toBe(false);
expect(fs.existsSync(path.join(wsDir, 'sessions'))).toBe(true);
expect(fs.statSync(path.join(wsDir, 'sessions')).isDirectory()).toBe(true);
});
@@ -233,11 +232,13 @@ describe('WorkspaceManager', () => {
});
describe('getMindPath', () => {
it('returns path to workspace.mind', () => {
it('returns path to a legacy workspace.mind', () => {
manager.create({ name: 'Mind Test', group: 'Work' });
const legacyMind = path.join(tmpDir, 'workspaces', 'mind-test', 'workspace.mind');
fs.writeFileSync(legacyMind, 'legacy mind');
const mindPath = manager.getMindPath('mind-test');
expect(mindPath).toBe(path.join(tmpDir, 'workspaces', 'mind-test', 'workspace.mind'));
expect(mindPath).toBe(legacyMind);
});
it.each(['missing-workspace', '..', '../escape', 'C:\\escape']) (
@@ -260,7 +261,6 @@ describe('WorkspaceManager', () => {
manager.create({ name: 'Linked Mind', group: 'Work' });
const mindPath = path.join(tmpDir, 'workspaces', 'linked-mind', 'workspace.mind');
const missingTarget = path.join(tmpDir, 'missing-mind-target');
fs.unlinkSync(mindPath);
fs.symlinkSync(missingTarget, mindPath, process.platform === 'win32' ? 'junction' : 'dir');
expect(() => manager.getMindPath('linked-mind')).toThrow(/regular file/i);
@@ -273,60 +273,18 @@ describe('WorkspaceManager', () => {
const mindPath = path.join(tmpDir, 'workspaces', 'hard-linked-mind', 'workspace.mind');
const outsidePath = path.join(tmpDir, 'outside.mind');
fs.writeFileSync(outsidePath, 'outside sentinel');
fs.unlinkSync(mindPath);
fs.linkSync(outsidePath, mindPath);
expect(() => manager.getMindPath('hard-linked-mind')).toThrow(/regular file/i);
expect(fs.readFileSync(outsidePath, 'utf8')).toBe('outside sentinel');
});
it('allows a valid workspace to recreate a missing mind inside its directory', () => {
it('returns the mind path of a workspace without a mind file and does not create one', () => {
manager.create({ name: 'Missing Mind', group: 'Work' });
const mindPath = path.join(tmpDir, 'workspaces', 'missing-mind', 'workspace.mind');
fs.unlinkSync(mindPath);
expect(manager.getMindPath('missing-mind')).toBe(mindPath);
const cache = new MultiMindCache({
maxOpen: 2,
getMindPath: id => manager.getMindPath(id),
allowedRoot: path.join(tmpDir, 'workspaces'),
});
expect(cache.getOrOpen('missing-mind')).not.toBeNull();
expect(fs.statSync(mindPath).isFile()).toBe(true);
cache.closeAll();
});
it('contains resolver failures and rejects a post-resolution junction swap', () => {
const throwingCache = new MultiMindCache({
maxOpen: 2,
getMindPath: () => { throw new Error('unsafe workspace'); },
allowedRoot: path.join(tmpDir, 'workspaces'),
});
expect(throwingCache.getOrOpen('missing')).toBeNull();
manager.create({ name: 'Swap Target', group: 'Work' });
const workspaceDir = path.join(tmpDir, 'workspaces', 'swap-target');
const outsideDir = fs.mkdtempSync(path.join(os.tmpdir(), 'waggle-ws-swap-'));
const outsideMind = path.join(outsideDir, 'workspace.mind');
fs.writeFileSync(outsideMind, 'outside sentinel');
const cache = new MultiMindCache({
maxOpen: 2,
allowedRoot: path.join(tmpDir, 'workspaces'),
getMindPath: id => {
const resolved = manager.getMindPath(id);
fs.rmSync(workspaceDir, { recursive: true, force: true });
fs.symlinkSync(outsideDir, workspaceDir, process.platform === 'win32' ? 'junction' : 'dir');
return resolved;
},
});
try {
expect(cache.getOrOpen('swap-target')).toBeNull();
expect(fs.readFileSync(outsideMind, 'utf8')).toBe('outside sentinel');
} finally {
fs.unlinkSync(workspaceDir);
fs.rmSync(outsideDir, { recursive: true, force: true });
}
expect(fs.existsSync(mindPath)).toBe(false);
});
});
@@ -492,7 +450,7 @@ describe('WorkspaceManager', () => {
expect(workspace.id).toBe('default');
expect(fs.statSync(sessionsDir).isDirectory()).toBe(true);
expect(fs.existsSync(path.join(workspaceDir, 'workspace.mind'))).toBe(true);
expect(fs.existsSync(path.join(workspaceDir, 'workspace.mind'))).toBe(false);
expect(manager.get('default')).toEqual(workspace);
},
);
@@ -544,7 +502,7 @@ describe('WorkspaceManager', () => {
const wsDir = path.join(tmpDir, 'workspaces', 'cwd-derived-id');
expect(fs.existsSync(path.join(wsDir, 'workspace.json'))).toBe(true);
expect(fs.existsSync(path.join(wsDir, 'workspace.mind'))).toBe(true);
expect(fs.existsSync(path.join(wsDir, 'workspace.mind'))).toBe(false);
expect(fs.existsSync(path.join(wsDir, 'sessions'))).toBe(true);
});