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:
@@ -1,8 +1,7 @@
|
||||
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
|
||||
import { MindDB } from '@waggle/core';
|
||||
import { describe, it, expect, beforeEach } from 'vitest';
|
||||
import { createInMemoryMemoryStore } from '@waggle/memory-contract';
|
||||
import { Orchestrator } from '../src/orchestrator.js';
|
||||
import { FEATURE_FLAGS, isEnabled } from '../src/feature-flags.js';
|
||||
import { MockEmbedder } from '../../hive-mind-core/tests/mind/helpers/mock-embedder.js';
|
||||
|
||||
/**
|
||||
* Brief §12.4 — feature-flag snapshot tests. Proves:
|
||||
@@ -36,35 +35,28 @@ describe('PROMPT_ASSEMBLER feature flag', () => {
|
||||
});
|
||||
|
||||
describe('Orchestrator prompt paths — flag-off regression protection', () => {
|
||||
let db: MindDB;
|
||||
let orchestrator: Orchestrator;
|
||||
|
||||
beforeEach(() => {
|
||||
db = new MindDB(':memory:');
|
||||
orchestrator = new Orchestrator({
|
||||
db,
|
||||
embedder: new MockEmbedder(),
|
||||
memory: createInMemoryMemoryStore(),
|
||||
model: 'claude-opus-4-7',
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
db.close();
|
||||
});
|
||||
|
||||
it('buildSystemPrompt() is stable across successive calls on a fresh mind', () => {
|
||||
const a = orchestrator.buildSystemPrompt();
|
||||
const b = orchestrator.buildSystemPrompt();
|
||||
it('buildSystemPrompt() is stable across successive calls on a fresh memory', async () => {
|
||||
const a = await orchestrator.buildSystemPrompt();
|
||||
const b = await orchestrator.buildSystemPrompt();
|
||||
expect(a).toBe(b);
|
||||
});
|
||||
|
||||
it('buildSystemPrompt() does not mention PromptAssembler sections by default', () => {
|
||||
const out = orchestrator.buildSystemPrompt();
|
||||
it('buildSystemPrompt() does not mention PromptAssembler sections by default', async () => {
|
||||
const out = await orchestrator.buildSystemPrompt();
|
||||
expect(out).not.toContain('# Response format');
|
||||
expect(out).not.toContain('# Recent changes');
|
||||
});
|
||||
|
||||
it('buildAssembledPrompt() returns well-formed output on a fresh mind', async () => {
|
||||
it('buildAssembledPrompt() returns well-formed output on a fresh memory', async () => {
|
||||
const assembled = await orchestrator.buildAssembledPrompt('test query', null);
|
||||
expect(typeof assembled.system).toBe('string');
|
||||
expect(assembled.system.length).toBeGreaterThan(0);
|
||||
@@ -75,15 +67,12 @@ describe('Orchestrator prompt paths — flag-off regression protection', () => {
|
||||
});
|
||||
|
||||
it('buildAssembledPrompt() maps tier correctly for small models', async () => {
|
||||
const smallDb = new MindDB(':memory:');
|
||||
const smallOrch = new Orchestrator({
|
||||
db: smallDb,
|
||||
embedder: new MockEmbedder(),
|
||||
memory: createInMemoryMemoryStore(),
|
||||
model: 'gemma-4-31b',
|
||||
});
|
||||
const assembled = await smallOrch.buildAssembledPrompt('plan me a migration from A to B', null);
|
||||
expect(assembled.debug.tier).toBe('small');
|
||||
smallDb.close();
|
||||
});
|
||||
|
||||
it('buildAssembledPrompt() excludes all outside context from closed-world rewrites', async () => {
|
||||
@@ -110,7 +99,7 @@ describe('Orchestrator prompt paths — flag-off regression protection', () => {
|
||||
});
|
||||
|
||||
it('buildSystemPrompt() and buildAssembledPrompt() produce different shapes (flag-off vs PA path)', async () => {
|
||||
const legacy = orchestrator.buildSystemPrompt();
|
||||
const legacy = await orchestrator.buildSystemPrompt();
|
||||
const assembled = await orchestrator.buildAssembledPrompt('compare MECE vs BPMN', null);
|
||||
// Both contain identity scaffolding, but the PA output has structured section headers
|
||||
// the legacy path lacks (e.g., "## Persona:" when persona=null, "# State" via frame selection).
|
||||
|
||||
Reference in New Issue
Block a user