From 33082636137766a56cc858fc9c1476b5a3e01420 Mon Sep 17 00:00:00 2001 From: "shumeiko.it" Date: Sat, 24 Oct 2026 17:20:55 +0200 Subject: [PATCH] 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. --- packages/agent/tests/prompt-assembler.test.ts | 2 +- .../external-agent-collaboration.live.test.ts | 42 ++++++++++--------- 2 files changed, 23 insertions(+), 21 deletions(-) diff --git a/packages/agent/tests/prompt-assembler.test.ts b/packages/agent/tests/prompt-assembler.test.ts index c21b150..73c3181 100644 --- a/packages/agent/tests/prompt-assembler.test.ts +++ b/packages/agent/tests/prompt-assembler.test.ts @@ -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' })); } diff --git a/tests/integration/external-agent-collaboration.live.test.ts b/tests/integration/external-agent-collaboration.live.test.ts index 416949d..9a45d3f 100644 --- a/tests/integration/external-agent-collaboration.live.test.ts +++ b/tests/integration/external-agent-collaboration.live.test.ts @@ -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[]; - 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; + 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)),