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:
shumeiko.it
2026-10-24 12:37:36 +02:00
parent 851502d347
commit ac23bbd7a6
27 changed files with 1426 additions and 922 deletions

View File

@@ -12,8 +12,9 @@ import { executeCoordinator } from '../../../worker/src/execution/coordinator.js
import { AgentMessageBus } from '../../src/agent-message-bus.js';
import { createAgentCommsTools } from '../../src/agent-comms-tools.js';
import { WorkspaceSessionManager } from '../../../server/src/local/workspace-sessions.js';
import type { MindDB, VaultStore } from '@waggle/core';
import type { Orchestrator } from '../../src/orchestrator.js';
import type { VaultStore } from '@waggle/core';
// The session manager is typed against the published @waggle/agent surface.
import type { Orchestrator } from '@waggle/agent';
import type { ConnectorHealth } from '@waggle/shared';
// ── Mock helpers ──────────────────────────────────────────────────────
@@ -227,12 +228,11 @@ describe('E2E Swarm Scenarios', () => {
describe('SW5: Workspace session lifecycle', () => {
it('create, use, pause, resume, kill session', () => {
const manager = new WorkspaceSessionManager(3);
const mind = { close: vi.fn() } as unknown as MindDB;
const orchestrator = { setWorkspaceMind: vi.fn() } as unknown as Orchestrator;
const orchestrator = { setWorkspace: vi.fn() } as unknown as Orchestrator;
const tools = [{ name: 't1', description: '', parameters: {}, execute: async () => '' }];
// Create
const session = manager.create('ws-1', mind, orchestrator, tools, 'researcher');
const session = manager.create('ws-1', orchestrator, tools, 'researcher');
expect(session.status).toBe('active');
expect(session.personaId).toBe('researcher');
@@ -244,10 +244,10 @@ describe('E2E Swarm Scenarios', () => {
manager.resume('ws-1');
expect(session.status).toBe('active');
// Kill
// Kill: in-flight work of the session is aborted
manager.close('ws-1');
expect(manager.size).toBe(0);
expect(mind.close).toHaveBeenCalled();
expect(session.abortController.signal.aborted).toBe(true);
});
});
});