test(server): drop tests of the legacy memory engine (P1.5)

- harvest-provenance: tested the removed harvest pipeline (RawArchive and
  frame metadata), which no longer exists.
- benchmarks: drop the FTS5 frame search and frame/session write
  benchmarks; they measured the legacy engine only.
This commit is contained in:
shumeiko.it
2026-10-24 17:07:10 +02:00
parent f57d618bea
commit ad7b90bebd
2 changed files with 9 additions and 318 deletions

View File

@@ -6,19 +6,17 @@
*
* Coverage:
* 1. Cold start: server boot → first response
* 2. FTS5 search with 1000+ frames
* 3. Workspace list with 50 workspaces
* 4. Session load with 500 messages
* 5. Marketplace FTS5 search (bundled DB)
* 6. Vault set+get cycle
* 7. Memory frame batch write (100 frames)
* 2. Workspace list with 50 workspaces
* 3. Session load with 500 messages
* 4. Marketplace FTS5 search (bundled DB)
* 5. Vault set+get cycle
*/
import { describe, it, expect, beforeAll, afterAll, beforeEach, afterEach } from 'vitest';
import fs from 'node:fs';
import path from 'node:path';
import os from 'node:os';
import { MindDB, FrameStore, SessionStore, VaultStore, WorkspaceManager } from '@waggle/core';
import { VaultStore, WorkspaceManager } from '@waggle/core';
import { buildLocalServer } from '../../src/local/index.js';
import type { FastifyInstance } from 'fastify';
import { injectWithAuth } from '../test-utils.js';
@@ -55,11 +53,6 @@ describe('Performance Benchmarks', () => {
it('server boots and responds within 5 seconds', async () => {
const tmpDir = createTmpDir('coldstart');
try {
// Create a minimal personal.mind so the server can start
const personalPath = path.join(tmpDir, 'personal.mind');
const mind = new MindDB(personalPath);
mind.close();
const start = Date.now();
const server = await buildLocalServer({ dataDir: tmpDir });
const res = await injectWithAuth(server, { method: 'GET', url: '/health' });
@@ -76,97 +69,7 @@ describe('Performance Benchmarks', () => {
}, 15_000);
});
// ── 2. FTS5 Search Performance ──────────────────────────────────────
describe('FTS5 Search with 1000 frames', () => {
let tmpDir: string;
let mind: MindDB;
let frames: FrameStore;
let sessions: SessionStore;
let gopId: string;
beforeAll(() => {
tmpDir = createTmpDir('fts5');
const dbPath = path.join(tmpDir, 'personal.mind');
mind = new MindDB(dbPath);
frames = new FrameStore(mind);
sessions = new SessionStore(mind);
// Create a session for FK constraints
const session = sessions.create('perf-test');
gopId = session.gop_id;
// Insert 1000 frames with varied content
const topics = [
'machine learning model training optimization',
'database indexing strategies for SQLite',
'TypeScript generics and type inference',
'React component lifecycle management',
'Node.js event loop performance tuning',
'memory management garbage collection patterns',
'API design RESTful best practices',
'testing strategies unit integration e2e',
'CI/CD pipeline automation deployment',
'microservices architecture communication patterns',
];
for (let i = 0; i < 1000; i++) {
const topic = topics[i % topics.length];
frames.createIFrame(gopId, `Frame ${i}: ${topic} — detailed notes about ${topic} iteration ${i}`, 'normal');
}
});
afterAll(() => {
mind.close();
cleanupDir(tmpDir);
});
it('FTS5 keyword search completes within 200ms for 1000 frames', () => {
const raw = mind.getDatabase();
const start = Date.now();
const results = raw.prepare(`
SELECT mf.* FROM memory_frames mf
INNER JOIN memory_frames_fts fts ON mf.id = fts.rowid
WHERE memory_frames_fts MATCH ?
LIMIT 20
`).all('machine learning');
const elapsed = Date.now() - start;
expect(results.length).toBeGreaterThan(0);
// 200ms is generous — SQLite FTS5 on 1000 rows should be <10ms
expect(elapsed).toBeLessThan(perfBudget(200));
});
it('FTS5 wildcard search completes within 200ms', () => {
const raw = mind.getDatabase();
const start = Date.now();
const results = raw.prepare(`
SELECT mf.* FROM memory_frames mf
INNER JOIN memory_frames_fts fts ON mf.id = fts.rowid
WHERE memory_frames_fts MATCH ?
LIMIT 20
`).all('database*');
const elapsed = Date.now() - start;
expect(results.length).toBeGreaterThan(0);
expect(elapsed).toBeLessThan(perfBudget(200));
});
it('frame count query completes within 50ms', () => {
const raw = mind.getDatabase();
const start = Date.now();
const row = raw.prepare('SELECT COUNT(*) as cnt FROM memory_frames').get() as { cnt: number };
const elapsed = Date.now() - start;
expect(row.cnt).toBe(1000);
expect(elapsed).toBeLessThan(perfBudget(50));
});
});
// ── 3. Workspace List Performance ───────────────────────────────────
// ── 2. Workspace List Performance ───────────────────────────────────
describe('Workspace Listing with 50 workspaces', () => {
let tmpDir: string;
@@ -175,11 +78,6 @@ describe('Performance Benchmarks', () => {
beforeAll(async () => {
tmpDir = createTmpDir('ws-list');
// Create personal.mind
const personalPath = path.join(tmpDir, 'personal.mind');
const mind = new MindDB(personalPath);
mind.close();
// Create 50 workspaces via WorkspaceManager
const wsManager = new WorkspaceManager(tmpDir);
for (let i = 0; i < 50; i++) {
@@ -211,7 +109,7 @@ describe('Performance Benchmarks', () => {
});
});
// ── 4. Session Load Performance ─────────────────────────────────────
// ── 3. Session Load Performance ─────────────────────────────────────
describe('Session File Loading', () => {
let tmpDir: string;
@@ -258,7 +156,7 @@ describe('Performance Benchmarks', () => {
});
});
// ── 5. Marketplace FTS5 Search ──────────────────────────────────────
// ── 4. Marketplace FTS5 Search ──────────────────────────────────────
describe('Marketplace Search', () => {
it('marketplace FTS5 search completes within 200ms (bundled DB)', () => {
@@ -317,7 +215,7 @@ describe('Performance Benchmarks', () => {
});
});
// ── 6. Vault Operations ─────────────────────────────────────────────
// ── 5. Vault Operations ─────────────────────────────────────────────
describe('Vault Encrypt/Decrypt Cycle', () => {
let tmpDir: string;
@@ -372,81 +270,4 @@ describe('Performance Benchmarks', () => {
expect(elapsed).toBeLessThan(perfBudget(50));
});
});
// ── 7. Memory Frame Write Performance ───────────────────────────────
describe('Memory Frame Batch Write', () => {
let tmpDir: string;
let mind: MindDB;
let frames: FrameStore;
let sessions: SessionStore;
beforeEach(() => {
tmpDir = createTmpDir('frame-write');
const dbPath = path.join(tmpDir, 'write-bench.mind');
mind = new MindDB(dbPath);
frames = new FrameStore(mind);
sessions = new SessionStore(mind);
});
afterEach(() => {
mind.close();
cleanupDir(tmpDir);
});
it('writing 100 I-frames completes within 2 seconds', () => {
const session = sessions.create('write-bench');
const gopId = session.gop_id;
const start = Date.now();
for (let i = 0; i < 100; i++) {
frames.createIFrame(
gopId,
`Batch write test frame ${i}: This is a moderately sized content block that simulates real-world memory frame sizes with enough text to be meaningful.`,
'normal'
);
}
const elapsed = Date.now() - start;
// Verify all frames were written
const allFrames = frames.getGopFrames(gopId);
expect(allFrames.length).toBe(100);
// 2 seconds is generous — SQLite WAL mode batch writes should be <500ms
expect(elapsed).toBeLessThan(perfBudget(2000));
});
it('writing 100 P-frames completes within 2 seconds', () => {
const session = sessions.create('pframe-bench');
const gopId = session.gop_id;
// Create an I-frame as the base
const baseFrame = frames.createIFrame(gopId, 'Base frame for P-frame benchmark', 'normal');
const start = Date.now();
for (let i = 0; i < 100; i++) {
frames.createPFrame(
gopId,
`P-frame delta ${i}: Updated information about the topic with new details and corrections.`,
baseFrame.id,
'normal'
);
}
const elapsed = Date.now() - start;
// 1 base + 100 P-frames = 101
const allFrames = frames.getGopFrames(gopId);
expect(allFrames.length).toBe(101);
expect(elapsed).toBeLessThan(perfBudget(2000));
});
it('creating 50 sessions completes within 1 second', () => {
const start = Date.now();
for (let i = 0; i < 50; i++) {
sessions.create(`session-bench-${i}`);
}
const elapsed = Date.now() - start;
expect(elapsed).toBeLessThan(perfBudget(1000));
});
});
});