Files
waggle-os/packages/agent/tests/self-awareness.test.ts
shumeiko.it 2e1999a3f6 refactor: remove self-learning and the optimizer package (P1.4)
Self-learning is excluded from the community edition (ADR-0004); the
project owner reworks it separately. Cost tracking stays.

- agent: delete behaviour evolution (evolve-schema, iterative GEPA,
  compose-evolution, evolution gates, orchestrator and deploy),
  improvement and correction detection, AgentLearning, the eval-dataset
  builder, optimization-capture and the agent_insights tool. Secret
  detection moves from eval-dataset to secret-patterns. The LLM wiring
  keeps only the Haiku adapter and judge call used by skill audit and
  hygiene, so @ax-llm/ax is now declared by agent instead of server.
- server: delete /api/evolution/*, the evolution and optimizer services,
  GEPA expansion of the first chat message, the prompt_optimization and
  monthly_assessment jobs, the idle-session reviewer and its
  session-reviewer persona, prompt injection of past corrections and
  thumbs-down recorded as correction signals. Existing job rows of the
  removed types are ignored, not deleted.
- core: delete OptimizationLogStore; stop re-exporting the improvement
  signal and evolution run stores.
- web: delete the Evolution screen and the two job types in the
  automation editor.
- delete packages/optimizer.

Also logs UF-027 (self-learning loops read data nothing collects) and
UF-028 (the Settings prompt-shape choice is ignored by chat).
2026-10-20 00:54:58 +02:00

94 lines
2.8 KiB
TypeScript

import { describe, it, expect } from 'vitest';
import { buildSelfAwareness, type AgentCapabilities } from '../src/self-awareness.js';
describe('Self-Awareness', () => {
it('builds awareness with tools, skills, and stats', () => {
const caps: AgentCapabilities = {
tools: [
{ name: 'search_memory', description: 'Search saved memories' },
{ name: 'save_memory', description: 'Save a new memory' },
],
skills: ['code-review', 'summarize'],
model: 'claude-sonnet-4-20250514',
memoryStats: { frameCount: 42, sessionCount: 5, entityCount: 10 },
mode: 'local',
version: '0.3.0',
};
const result = buildSelfAwareness(caps);
// Header
expect(result).toContain('# Self-Awareness');
// Version, mode, model
expect(result).toContain('v0.3.0');
expect(result).toContain('local');
expect(result).toContain('claude-sonnet-4-20250514');
// Tools — now summarized, not listed individually
expect(result).toContain('2 tools available');
// Skills
expect(result).toContain('code-review');
expect(result).toContain('summarize');
// Memory stats
expect(result).toContain('42 memories across 5 sessions, 10 knowledge entities');
expect(result).toContain('search_memory');
// Footer
expect(result).toContain('what can you do?');
});
it('includes skills when present', () => {
const caps: AgentCapabilities = {
tools: [{ name: 'test_tool', description: 'A test tool' }],
skills: ['data-analysis', 'translation', 'code-gen'],
model: 'gpt-4o',
memoryStats: { frameCount: 0, sessionCount: 0, entityCount: 0 },
mode: 'team',
version: '1.0.0',
};
const result = buildSelfAwareness(caps);
expect(result).toContain('Active Skills');
expect(result).toContain('data-analysis');
expect(result).toContain('translation');
expect(result).toContain('code-gen');
});
it('handles empty state gracefully', () => {
const caps: AgentCapabilities = {
tools: [],
skills: [],
model: 'unknown',
memoryStats: { frameCount: 0, sessionCount: 0, entityCount: 0 },
mode: 'local',
version: '0.0.0',
};
const result = buildSelfAwareness(caps);
expect(result).toContain('0 tools available');
expect(result).toContain('empty');
expect(result).toContain('fresh start');
});
it('includes groundedness guidance', () => {
const caps: AgentCapabilities = {
tools: [],
skills: [],
model: 'test',
memoryStats: { frameCount: 0, sessionCount: 0, entityCount: 0 },
mode: 'local',
version: '1.0.0',
};
const result = buildSelfAwareness(caps);
expect(result).toContain('## Groundedness');
expect(result).toContain('acquire_capability');
expect(result).toContain('uncertain');
});
});