test: finish moving the root suites to the community edition (P1.5, P1.3b)
- The workspace isolation scenarios store memories through the memory store and check that one workspace's search never returns another's. - The Ollama manifest test covers the Linux x64 and arm64 artifacts added for P1.3b; an unsupported platform still resolves to nothing. - The root run leaves out the tests that only exercise excluded packages (the hook packages and the memory MCP server); they go with those packages in P2.2.
This commit is contained in:
@@ -13,9 +13,17 @@ import os from 'node:os';
|
||||
import path from 'node:path';
|
||||
import type { FastifyInstance } from 'fastify';
|
||||
import { startService } from '@waggle/server/local/service';
|
||||
import { FrameStore, SessionStore } from '@waggle/core';
|
||||
import { PERSONAL_SCOPE, workspaceScope } from '@waggle/memory-contract';
|
||||
import { injectWithAuth } from './test-utils.js';
|
||||
|
||||
/** Texts of the memories `/api/memory/search` returns for a query. */
|
||||
async function searchTexts(server: FastifyInstance, q: string, scope: string, workspace?: string): Promise<string[]> {
|
||||
const params = new URLSearchParams({ q, scope, ...(workspace && { workspace }) });
|
||||
const res = await injectWithAuth(server, { method: 'GET', url: `/api/memory/search?${params}` });
|
||||
expect(res.statusCode).toBe(200);
|
||||
return (JSON.parse(res.payload) as { results: Array<{ content: string }> }).results.map((r) => r.content);
|
||||
}
|
||||
|
||||
function makeTmpDir(): string {
|
||||
return fs.mkdtempSync(path.join(os.tmpdir(), 'waggle-e2e-'));
|
||||
}
|
||||
@@ -112,67 +120,17 @@ describe('Workspaces & Sessions E2E', () => {
|
||||
expect(ws1.group).toBe('Work');
|
||||
expect(ws2.group).toBe('Personal');
|
||||
|
||||
// Each workspace has its own .mind file on disk
|
||||
const mind1Path = path.join(dataDir, 'workspaces', ws1.id, 'workspace.mind');
|
||||
const mind2Path = path.join(dataDir, 'workspaces', ws2.id, 'workspace.mind');
|
||||
expect(fs.existsSync(mind1Path)).toBe(true);
|
||||
expect(fs.existsSync(mind2Path)).toBe(true);
|
||||
// Workspace memory lives in the memory store, not in per-workspace files.
|
||||
expect(fs.existsSync(path.join(dataDir, 'workspaces', ws1.id, 'workspace.mind'))).toBe(false);
|
||||
|
||||
// Switch to ws-A, store memory, verify it's found
|
||||
server.multiMind.switchWorkspace(mind1Path);
|
||||
const wsASessions = new SessionStore(server.multiMind.workspace!);
|
||||
const wsASession = wsASessions.create();
|
||||
const wsAFrames = new FrameStore(server.multiMind.workspace!);
|
||||
wsAFrames.createIFrame(wsASession.gop_id, 'Alpha project uses Kubernetes for deployment');
|
||||
await server.memory.remember({ scope: workspaceScope(ws1.id), text: 'Alpha project uses Kubernetes for deployment' });
|
||||
await server.memory.remember({ scope: workspaceScope(ws2.id), text: 'Beta project uses Docker Compose locally' });
|
||||
|
||||
// Search ws-A scope — should find Kubernetes
|
||||
const searchA = await injectWithAuth(server, {
|
||||
method: 'GET',
|
||||
url: '/api/memory/search?q=Kubernetes&scope=workspace',
|
||||
});
|
||||
expect(searchA.statusCode).toBe(200);
|
||||
const resultsA = JSON.parse(searchA.payload);
|
||||
expect(resultsA.count).toBeGreaterThan(0);
|
||||
|
||||
// Switch to ws-B — search should NOT find ws-A's memory
|
||||
server.multiMind.switchWorkspace(mind2Path);
|
||||
const searchB = await injectWithAuth(server, {
|
||||
method: 'GET',
|
||||
url: '/api/memory/search?q=Kubernetes&scope=workspace',
|
||||
});
|
||||
expect(searchB.statusCode).toBe(200);
|
||||
const resultsB = JSON.parse(searchB.payload);
|
||||
expect(resultsB.count).toBe(0);
|
||||
|
||||
// Store different memory in ws-B
|
||||
const wsBSessions = new SessionStore(server.multiMind.workspace!);
|
||||
const wsBSession = wsBSessions.create();
|
||||
const wsBFrames = new FrameStore(server.multiMind.workspace!);
|
||||
wsBFrames.createIFrame(wsBSession.gop_id, 'Beta project uses Docker Compose locally');
|
||||
|
||||
// ws-B should find Docker but not Kubernetes
|
||||
const searchB2 = await injectWithAuth(server, {
|
||||
method: 'GET',
|
||||
url: '/api/memory/search?q=Docker&scope=workspace',
|
||||
});
|
||||
expect(searchB2.statusCode).toBe(200);
|
||||
expect(JSON.parse(searchB2.payload).count).toBeGreaterThan(0);
|
||||
|
||||
// Switch back to ws-A — should find Kubernetes, not Docker
|
||||
server.multiMind.switchWorkspace(mind1Path);
|
||||
const searchA2 = await injectWithAuth(server, {
|
||||
method: 'GET',
|
||||
url: '/api/memory/search?q=Kubernetes&scope=workspace',
|
||||
});
|
||||
expect(searchA2.statusCode).toBe(200);
|
||||
expect(JSON.parse(searchA2.payload).count).toBeGreaterThan(0);
|
||||
|
||||
const searchA3 = await injectWithAuth(server, {
|
||||
method: 'GET',
|
||||
url: '/api/memory/search?q=Docker&scope=workspace',
|
||||
});
|
||||
expect(searchA3.statusCode).toBe(200);
|
||||
expect(JSON.parse(searchA3.payload).count).toBe(0);
|
||||
// Each workspace finds its own memory and never the other's.
|
||||
expect(await searchTexts(server, 'Kubernetes', 'workspace', ws1.id)).toContain('Alpha project uses Kubernetes for deployment');
|
||||
expect(await searchTexts(server, 'Kubernetes', 'workspace', ws2.id)).not.toContain('Alpha project uses Kubernetes for deployment');
|
||||
expect(await searchTexts(server, 'Docker', 'workspace', ws2.id)).toContain('Beta project uses Docker Compose locally');
|
||||
expect(await searchTexts(server, 'Docker', 'workspace', ws1.id)).not.toContain('Beta project uses Docker Compose locally');
|
||||
});
|
||||
|
||||
// Scenario 6: Memory search returns results from correct mind only
|
||||
@@ -184,63 +142,23 @@ describe('Workspaces & Sessions E2E', () => {
|
||||
const { server } = await startService({ dataDir, port, skipLiteLLM: true });
|
||||
servers.push(server);
|
||||
|
||||
// Store a memory in the personal mind — need a session first (FK constraint)
|
||||
const personalSessions = new SessionStore(server.multiMind.personal);
|
||||
const pSession = personalSessions.create();
|
||||
const personalFrames = new FrameStore(server.multiMind.personal);
|
||||
personalFrames.createIFrame(pSession.gop_id, 'Waggle architecture uses Tauri with React frontend');
|
||||
await server.memory.remember({ scope: PERSONAL_SCOPE, text: 'Waggle architecture uses Tauri with React frontend' });
|
||||
|
||||
// Create a workspace and store memory in its mind
|
||||
const createRes = await injectWithAuth(server, {
|
||||
method: 'POST',
|
||||
url: '/api/workspaces',
|
||||
payload: { name: 'Research', group: 'Study' },
|
||||
});
|
||||
const ws = JSON.parse(createRes.payload);
|
||||
await server.memory.remember({ scope: workspaceScope(ws.id), text: 'GraphContext uses SHACL validation for knowledge graphs' });
|
||||
|
||||
// Switch multiMind to workspace so workspace search works
|
||||
const wsMindPath = path.join(dataDir, 'workspaces', ws.id, 'workspace.mind');
|
||||
server.multiMind.switchWorkspace(wsMindPath);
|
||||
|
||||
// Store memory in workspace mind — need a session first (FK constraint)
|
||||
const wsSessions = new SessionStore(server.multiMind.workspace!);
|
||||
const wSession = wsSessions.create();
|
||||
const wsFrames = new FrameStore(server.multiMind.workspace!);
|
||||
wsFrames.createIFrame(wSession.gop_id, 'GraphContext uses SHACL validation for knowledge graphs');
|
||||
|
||||
// Search personal scope — should find "Tauri" but not "SHACL"
|
||||
const personalSearch = await injectWithAuth(server, {
|
||||
method: 'GET',
|
||||
url: '/api/memory/search?q=Tauri&scope=personal',
|
||||
});
|
||||
expect(personalSearch.statusCode).toBe(200);
|
||||
const personalResults = JSON.parse(personalSearch.payload);
|
||||
expect(personalResults.count).toBeGreaterThan(0);
|
||||
|
||||
// Search workspace scope — should find "SHACL" but not "Tauri"
|
||||
const wsSearch = await injectWithAuth(server, {
|
||||
method: 'GET',
|
||||
url: '/api/memory/search?q=SHACL&scope=workspace',
|
||||
});
|
||||
expect(wsSearch.statusCode).toBe(200);
|
||||
const wsResults = JSON.parse(wsSearch.payload);
|
||||
expect(wsResults.count).toBeGreaterThan(0);
|
||||
|
||||
// Cross-check: personal scope should NOT find workspace-only content
|
||||
const crossCheck = await injectWithAuth(server, {
|
||||
method: 'GET',
|
||||
url: '/api/memory/search?q=SHACL&scope=personal',
|
||||
});
|
||||
const crossResults = JSON.parse(crossCheck.payload);
|
||||
expect(crossResults.count).toBe(0);
|
||||
|
||||
// Search all scope — should find both
|
||||
const allSearch = await injectWithAuth(server, {
|
||||
method: 'GET',
|
||||
url: '/api/memory/search?q=architecture&scope=all',
|
||||
});
|
||||
const allResults = JSON.parse(allSearch.payload);
|
||||
expect(allResults.count).toBeGreaterThanOrEqual(1);
|
||||
expect(await searchTexts(server, 'Tauri', 'personal')).toContain('Waggle architecture uses Tauri with React frontend');
|
||||
expect(await searchTexts(server, 'SHACL', 'workspace', ws.id)).toContain('GraphContext uses SHACL validation for knowledge graphs');
|
||||
// Personal search never returns workspace-only memories.
|
||||
expect(await searchTexts(server, 'SHACL', 'personal')).not.toContain('GraphContext uses SHACL validation for knowledge graphs');
|
||||
// 'all' covers personal memory plus the named workspace.
|
||||
const all = await searchTexts(server, 'architecture', 'all', ws.id);
|
||||
expect(all.length).toBeGreaterThanOrEqual(1);
|
||||
});
|
||||
|
||||
// Scenario 8: Session CRUD — create, list, rename (switch), delete
|
||||
|
||||
Reference in New Issue
Block a user