import { describe, it, expect } from 'vitest'; import { PERSONAL_SCOPE, type MemoryRecord } from '@waggle/memory-contract'; import { toRecallFrame } from '../src/recall-frame.js'; const record: MemoryRecord = { id: 'mem-1', text: 'Decision: ship the beta on Friday', scope: PERSONAL_SCOPE, kind: 'decision', importance: 'important', source: 'user_stated', origin: 'agent', sessionId: 'chat-7', createdAt: '2026-05-07T09:30:00.000Z', updatedAt: null, metadata: { confidence: 'medium' }, }; describe('toRecallFrame', () => { it('maps a memory record onto the prompt-facing frame fields', () => { expect(toRecallFrame(record, 0.42)).toEqual({ id: 'mem-1', content: 'Decision: ship the beta on Friday', kind: 'decision', importance: 'important', source: 'user_stated', created_at: '2026-05-07T09:30:00.000Z', score: 0.42, }); }); it('scores 1 when no score is given (memories picked by a lane)', () => { expect(toRecallFrame(record).score).toBe(1); }); it('accepts a search hit and keeps the score passed in', () => { const hit = { ...record, score: 0.9 }; expect(toRecallFrame(hit, hit.score).score).toBe(0.9); }); });