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.
This commit is contained in:
@@ -81,7 +81,7 @@ describe('H-AUDIT-1 stage threading (end-to-end trace assertion)', () => {
|
||||
// Simulate a turn by calling each stage's log seam directly with the same
|
||||
// turnId. This models what happens when chat.ts generates turnId and it
|
||||
// propagates through agent-loop → orchestrator → retrieval → assembler →
|
||||
// cognify → tool-calls. The actual stage code in each source file emits
|
||||
// tool-calls. The actual stage code in each source file emits
|
||||
// these exact events; here we exercise the same entry points with the
|
||||
// same turnId so the reconstruction contract is verifiable in isolation.
|
||||
const buf = startTurnCapture();
|
||||
@@ -96,8 +96,6 @@ describe('H-AUDIT-1 stage threading (end-to-end trace assertion)', () => {
|
||||
logTurnEvent(turnId, { stage: 'prompt-assembler.assemble' });
|
||||
logTurnEvent(turnId, { stage: 'agent-loop.tool.enter', toolName: 'search_memory' });
|
||||
logTurnEvent(turnId, { stage: 'agent-loop.tool.exit', toolName: 'search_memory' });
|
||||
logTurnEvent(turnId, { stage: 'cognify.batch.enter' });
|
||||
logTurnEvent(turnId, { stage: 'cognify.batch.exit' });
|
||||
logTurnEvent(turnId, { stage: 'agent-loop.exit' });
|
||||
|
||||
// Every event has the same turnId (brief: "svih 6 stage-ova ima isti turnId")
|
||||
@@ -112,13 +110,12 @@ describe('H-AUDIT-1 stage threading (end-to-end trace assertion)', () => {
|
||||
expect(stages.has('orchestrator.recallMemory.enter')).toBe(true);
|
||||
expect(stages.has('retrieval.enter')).toBe(true);
|
||||
expect(stages.has('prompt-assembler.assemble')).toBe(true);
|
||||
expect(stages.has('cognify.batch.enter')).toBe(true);
|
||||
expect(stages.has('agent-loop.tool.enter')).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('H-AUDIT-1 source-tree regression guard', () => {
|
||||
it('turnId appears in the minimum six target files (chat, agent-loop, orchestrator, retrieval, assembler, cognify)', () => {
|
||||
it('turnId appears in the target files (chat, agent-loop, orchestrator, retrieval, assembler)', () => {
|
||||
// Brief: `grep -r "turnId" packages/**/*.ts | wc -l` must return >= 6.
|
||||
// We assert on presence in each specific file rather than raw count,
|
||||
// because the contract is about traceability coverage, not volume.
|
||||
@@ -126,7 +123,6 @@ describe('H-AUDIT-1 source-tree regression guard', () => {
|
||||
const required = [
|
||||
'packages/agent/src/turn-context.ts',
|
||||
'packages/agent/src/orchestrator.ts',
|
||||
'packages/agent/src/cognify.ts',
|
||||
'packages/agent/src/combined-retrieval.ts',
|
||||
'packages/agent/src/prompt-assembler.ts',
|
||||
'packages/agent/src/agent-loop.ts',
|
||||
|
||||
Reference in New Issue
Block a user