test: read run memories through the contract in the live collaboration test (P1.5)

The live external-agent test (skipped unless WAGGLE_LIVE_EXTERNAL_AGENTS=1)
looked up run memory receipts as frames in server.multiMind and
server.mindCache, which the server no longer has. Look them up with
server.memory.get and check that personal and workspace receipts sit in
their own scopes. Also type the prompt assembler's bulk fixture as
RecallFrame.
This commit is contained in:
shumeiko.it
2026-10-24 17:20:55 +02:00
parent 4280a85b24
commit 3308263613
2 changed files with 23 additions and 21 deletions

View File

@@ -108,7 +108,7 @@ describe('PromptAssembler.assemble', () => {
});
it('small tier caps State frames at 3', () => {
const frames: MemoryFrame[] = [];
const frames: RecallFrame[] = [];
for (let i = 0; i < 10; i++) {
frames.push(frame(`State frame ${i}`, { importance: 'important' }));
}

View File

@@ -5,7 +5,7 @@ import os from 'node:os';
import path from 'node:path';
import type { FastifyInstance } from 'fastify';
import { detectInstalledTools, getToolRegistry, runExternalTool } from '@waggle/agent';
import { FrameStore } from '@waggle/core';
import { scopeKey, workspaceScope } from '@waggle/memory-contract';
import { AgentRunRegistry } from '../../packages/server/src/local/agent-run-registry.js';
import { buildLocalServer } from '../../packages/server/src/local/index.js';
import { injectWithAuth } from '../../packages/server/tests/test-utils.js';
@@ -222,41 +222,43 @@ describeLive('live external-agent collaboration', () => {
expect(durable?.memoryRefs, diagnostic).toEqual(server.agentRunRegistry.get(id)?.memoryRefs);
}
const personalFrames = new FrameStore(server.multiMind.personal);
for (const run of runs) {
const workspaceId = run.kind === 'worker' ? run.workspaceId : undefined;
expect(Object.keys(run.memoryRefs.workspaceFrameIds), diagnostic).toEqual([workspaceId]);
const personal = run.memoryRefs.personalFrameIds.map((id) => personalFrames.getById(id));
let workspace = [] as ReturnType<FrameStore['getById']>[];
if (workspaceId) {
const workspaceMind = server.mindCache.acquire(workspaceId);
try {
const frames = new FrameStore(workspaceMind);
workspace = run.memoryRefs.workspaceFrameIds[workspaceId].map((id) => frames.getById(id));
} finally {
server.mindCache.release(workspaceId);
}
}
const personal = await Promise.all(
run.memoryRefs.personalFrameIds.map((id) => server.memory.get(id)),
);
const workspace = workspaceId
? await Promise.all(
run.memoryRefs.workspaceFrameIds[workspaceId].map((id) => server.memory.get(id)),
)
: [];
expect(personal.length, diagnostic).toBeGreaterThan(0);
expect(workspace.length, diagnostic).toBeGreaterThan(0);
for (const frame of [...personal, ...workspace]) {
expect(frame, diagnostic).toBeDefined();
const metadata = JSON.parse(frame?.metadata ?? '{}') as Record<string, unknown>;
for (const memory of personal) {
expect(memory?.scope.kind, diagnostic).toBe('personal');
}
for (const memory of workspace) {
expect(memory && scopeKey(memory.scope), diagnostic).toBe(scopeKey(workspaceScope(workspaceId!)));
}
for (const memory of [...personal, ...workspace]) {
expect(memory, diagnostic).not.toBeNull();
const metadata = memory?.metadata ?? {};
expect(metadata).toMatchObject({
runId: run.id,
roomId: run.roomId,
workspaceId: run.kind === 'worker' ? run.workspaceId : undefined,
toolId: run.executor.toolId,
});
expect(frame?.content.includes(run.id), diagnostic).toBe(true);
expect(memory?.text.includes(run.id), diagnostic).toBe(true);
for (const forbiddenPath of [dataDir, sourceWorkspaceDir, synthesisWorkspaceDir]) {
expect(frame?.content.includes(forbiddenPath), diagnostic).toBe(false);
expect(memory?.text.includes(forbiddenPath), diagnostic).toBe(false);
expect(JSON.stringify(metadata).includes(forbiddenPath), diagnostic).toBe(false);
}
}
const expectedSummary = run.result?.summary.trim() ?? '';
expect(personal.some((frame) => frame?.content.includes(expectedSummary)), diagnostic).toBe(true);
expect(workspace.some((frame) => frame?.content.includes(expectedSummary)), diagnostic).toBe(true);
expect(personal.some((memory) => memory?.text.includes(expectedSummary)), diagnostic).toBe(true);
expect(workspace.some((memory) => memory?.text.includes(expectedSummary)), diagnostic).toBe(true);
}
expect(new Set(room?.memoryRefs.personalFrameIds)).toEqual(
new Set(runs.flatMap((run) => run.memoryRefs.personalFrameIds)),