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.
78 lines
2.4 KiB
TypeScript
78 lines
2.4 KiB
TypeScript
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
|
|
import { WaggleDB, IdentityLayer } from '@waggle/core';
|
|
import { ensureIdentity } from '../src/auto-identity.js';
|
|
|
|
describe('ensureIdentity', () => {
|
|
let db: WaggleDB;
|
|
let identity: IdentityLayer;
|
|
|
|
beforeEach(() => {
|
|
db = new WaggleDB(':memory:');
|
|
identity = new IdentityLayer(db);
|
|
});
|
|
|
|
afterEach(() => {
|
|
db.close();
|
|
});
|
|
|
|
it('creates default identity when none exists', () => {
|
|
expect(identity.exists()).toBe(false);
|
|
|
|
ensureIdentity(identity);
|
|
|
|
expect(identity.exists()).toBe(true);
|
|
const id = identity.get();
|
|
expect(id.name).toBe('Waggle');
|
|
expect(id.role).toBe('AI assistant with persistent memory and web access');
|
|
expect(id.personality).toContain('Direct, concise, helpful');
|
|
expect(id.capabilities).toContain('persistent memory (.mind file)');
|
|
expect(id.capabilities).toContain('task tracking');
|
|
});
|
|
|
|
it('does not overwrite existing identity', () => {
|
|
identity.create({
|
|
name: 'CustomBot',
|
|
role: 'Custom role',
|
|
department: 'Engineering',
|
|
personality: 'Friendly',
|
|
capabilities: 'custom cap',
|
|
system_prompt: 'custom prompt',
|
|
});
|
|
|
|
ensureIdentity(identity);
|
|
|
|
const id = identity.get();
|
|
expect(id.name).toBe('CustomBot');
|
|
expect(id.role).toBe('Custom role');
|
|
expect(id.department).toBe('Engineering');
|
|
expect(id.personality).toBe('Friendly');
|
|
expect(id.capabilities).toBe('custom cap');
|
|
});
|
|
|
|
it('creates identity with custom config', () => {
|
|
ensureIdentity(identity, {
|
|
name: 'MyAgent',
|
|
role: 'Research assistant',
|
|
personality: 'Curious and thorough',
|
|
capabilities: ['web search', 'data analysis'],
|
|
});
|
|
|
|
expect(identity.exists()).toBe(true);
|
|
const id = identity.get();
|
|
expect(id.name).toBe('MyAgent');
|
|
expect(id.role).toBe('Research assistant');
|
|
expect(id.personality).toBe('Curious and thorough');
|
|
expect(id.capabilities).toBe('web search, data analysis');
|
|
});
|
|
|
|
it('uses defaults for omitted config fields', () => {
|
|
ensureIdentity(identity, { name: 'PartialBot' });
|
|
|
|
const id = identity.get();
|
|
expect(id.name).toBe('PartialBot');
|
|
// Other fields should be defaults
|
|
expect(id.role).toBe('AI assistant with persistent memory and web access');
|
|
expect(id.personality).toContain('Direct, concise, helpful');
|
|
});
|
|
});
|