Files
waggle-os/packages/agent/tests/recall-frame.test.ts
shumeiko.it ac23bbd7a6 test(agent): move the agent suites onto the memory contract (P1.5)
Rewrites the orchestrator, recall, compaction, save_memory and assembler
suites for MemoryStore (createInMemoryMemoryStore; mem0 with the word
embedder for the M3b integration test), string ids, async prompt building
and setWorkspace(). Creation times are set with fake timers, since a write
cannot set its own. Stores of Waggle's own data (identity, traces) are built
on WaggleDB; the session-manager stubs use the new create() signature.

Kept behaviour: importance lane (cap, active scope, temporary exclusion),
profile and event lanes, date window and its fallback, catch-up, injection
blocking of recall and preloaded context, autosave safety, decision consent,
compaction update-in-place, reranker wiring.

New tests: recall with a workspace active versus personal only;
fetchRecentMemories ordering; toRecallFrame; context loader; save_memory
routing, dedup, rate limit, dramatic-claim downgrade and contradiction
scope; search_memory and search_all_workspaces; pattern write-back kinds,
scopes and sign gate; read_other_workspace; reranker off unless
WAGGLE_RERANKER=1, wider rerank pool, failure fallbacks.

Deleted, because the behaviour is gone:
- w46-rawdetail-recall.test.ts: the raw-turn (RAWDETAIL) recall lane.
- orchestrator.test.ts, query_knowledge (3 tests) and the recall-hardening
  M4 "Key Knowledge" test: the knowledge graph is not in v1 (ADR-0002).
- orchestrator-context-frames "profile override": scoring profiles.
- Assertions on I/P frame types, GOP sessions, FTS rows, the "Memory Facts"
  lane, cognify stages and session/entity counts were replaced by the
  equivalent contract-level checks.
2026-10-24 13:19:06 +02:00

41 lines
1.2 KiB
TypeScript

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);
});
});