test(server): move the remaining server tests onto the memory contract (P1.5)
- Workspace sessions, fleet runs, agent groups, loops, the file indexer, external tool runs, chat and the health endpoint are checked against the memory store instead of .mind files. Assertions on mind-cache pins and releases go with the pins; the drain and cancellation checks stay. - Delete the sticky-erasure test (harvest import was removed) and the session-distillation test (distillation on workspace activation was removed). - The saved-history retry test checks the conversation only: the failed user turn is kept in workspace memory by design (#3).
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
/**
|
||||
* File Indexer Integration Tests (L-20)
|
||||
*
|
||||
* Verifies that file-route mutations call into the workspace mind's FileIndexer:
|
||||
* Verifies that file-route mutations call into the workspace's FileIndexer:
|
||||
* POST /upload (base64 JSON path) indexes a new .md/.txt
|
||||
* POST /delete removes the index row + frame
|
||||
* POST /delete removes the index row + memory
|
||||
* POST /move updates the index row path
|
||||
* POST /copy indexes the destination
|
||||
*
|
||||
@@ -16,7 +16,7 @@ import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import os from 'node:os';
|
||||
import type { FastifyInstance } from 'fastify';
|
||||
import { MindDB, SessionStore, FrameStore, FileIndexer } from '@waggle/core';
|
||||
import { FileIndexer } from '@waggle/core';
|
||||
import { buildLocalServer } from '../../src/local/index.js';
|
||||
import { injectWithAuth } from '../test-utils.js';
|
||||
|
||||
@@ -27,12 +27,6 @@ describe('File Indexer — integration with /files routes (L-20)', () => {
|
||||
|
||||
beforeAll(async () => {
|
||||
tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'waggle-files-indexer-'));
|
||||
const mind = new MindDB(path.join(tmpDir, 'personal.mind'));
|
||||
const sessions = new SessionStore(mind);
|
||||
const frames = new FrameStore(mind);
|
||||
const s = sessions.create('files-indexer-seed');
|
||||
frames.createIFrame(s.gop_id, 'seed', 'normal');
|
||||
mind.close();
|
||||
|
||||
server = await buildLocalServer({ dataDir: tmpDir });
|
||||
|
||||
@@ -51,17 +45,9 @@ describe('File Indexer — integration with /files routes (L-20)', () => {
|
||||
|
||||
const prefix = () => `/api/workspaces/${workspaceId}/files`;
|
||||
|
||||
/** Reach the same workspace mind the route handlers use (via mindCache). */
|
||||
/** The same index and memory the route handlers use. */
|
||||
function getIndexer(): FileIndexer {
|
||||
const mind = server.mindCache.getOrOpen(workspaceId);
|
||||
if (!mind) throw new Error('workspace mind unavailable');
|
||||
return new FileIndexer(mind);
|
||||
}
|
||||
|
||||
function getFrameStore(): FrameStore {
|
||||
const mind = server.mindCache.getOrOpen(workspaceId);
|
||||
if (!mind) throw new Error('workspace mind unavailable');
|
||||
return new FrameStore(mind);
|
||||
return new FileIndexer(server.waggleDb, server.memory, workspaceId);
|
||||
}
|
||||
|
||||
async function uploadViaJson(name: string, content: string, dir = '/notes') {
|
||||
@@ -78,10 +64,9 @@ describe('File Indexer — integration with /files routes (L-20)', () => {
|
||||
|
||||
const row = getIndexer().getRow('/notes/indexed.md');
|
||||
expect(row).toBeTruthy();
|
||||
expect(row!.frameId).toBeGreaterThan(0);
|
||||
const frame = getFrameStore().getById(row!.frameId);
|
||||
expect(frame?.content).toContain('# indexed');
|
||||
expect(frame?.content).toContain('/notes/indexed.md');
|
||||
const memory = await server.memory.get(row!.memoryId);
|
||||
expect(memory?.text).toContain('# indexed');
|
||||
expect(memory?.text).toContain('/notes/indexed.md');
|
||||
});
|
||||
|
||||
it('skips non-indexable extensions silently (pdf)', async () => {
|
||||
@@ -111,12 +96,13 @@ describe('File Indexer — integration with /files routes (L-20)', () => {
|
||||
|
||||
expect(res.statusCode).toBe(201);
|
||||
expect(getIndexer().getRow('/notes/guarded-overwrite.md')).toEqual(before);
|
||||
expect(getFrameStore().getById(before!.frameId)?.content).toContain('Approved launch checklist.');
|
||||
expect((await server.memory.get(before!.memoryId))?.text).toContain('Approved launch checklist.');
|
||||
});
|
||||
|
||||
it('removes the index row on delete', async () => {
|
||||
it('removes the index row and its memory on delete', async () => {
|
||||
await uploadViaJson('doomed.md', 'bye');
|
||||
expect(getIndexer().getRow('/notes/doomed.md')).toBeTruthy();
|
||||
const row = getIndexer().getRow('/notes/doomed.md');
|
||||
expect(row).toBeTruthy();
|
||||
|
||||
const del = await injectWithAuth(server, {
|
||||
method: 'POST',
|
||||
@@ -126,6 +112,7 @@ describe('File Indexer — integration with /files routes (L-20)', () => {
|
||||
expect(del.statusCode).toBe(204);
|
||||
|
||||
expect(getIndexer().getRow('/notes/doomed.md')).toBeNull();
|
||||
expect(await server.memory.get(row!.memoryId)).toBeNull();
|
||||
});
|
||||
|
||||
it('updates the path on move', async () => {
|
||||
@@ -162,7 +149,7 @@ describe('File Indexer — integration with /files routes (L-20)', () => {
|
||||
|
||||
await uploadViaJson('overwrite.md', 'second');
|
||||
const secondRow = getIndexer().getRow('/notes/overwrite.md')!;
|
||||
expect(secondRow.frameId).not.toBe(firstRow.frameId);
|
||||
expect(secondRow.memoryId).not.toBe(firstRow.memoryId);
|
||||
expect(secondRow.contentHash).not.toBe(firstRow.contentHash);
|
||||
});
|
||||
|
||||
@@ -172,7 +159,7 @@ describe('File Indexer — integration with /files routes (L-20)', () => {
|
||||
|
||||
await uploadViaJson('same.md', 'same');
|
||||
const secondRow = getIndexer().getRow('/notes/same.md')!;
|
||||
expect(secondRow.frameId).toBe(firstRow.frameId);
|
||||
expect(secondRow.memoryId).toBe(firstRow.memoryId);
|
||||
expect(secondRow.contentHash).toBe(firstRow.contentHash);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user