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).
This commit is contained in:
shumeiko.it
2026-10-20 00:54:58 +02:00
parent b734c1d3d2
commit 2e1999a3f6
112 changed files with 336 additions and 16165 deletions

View File

@@ -2,13 +2,8 @@
* Skills 2.0 gap K — write-path conflict detection.
*
* When save_memory writes a new frame that contradicts an existing frame
* (detectContradiction), the save still succeeds but:
* - the return string carries a [flag: contradicts_existing …] marker
* - a correction-category improvement signal is recorded
*
* Previously detectContradiction existed but was never called on the write
* path — write-path conflicts silently overwrote reality, degrading the
* evolution-signal loop.
* (detectContradiction), the save still succeeds but the return string
* carries a [flag: contradicts_existing …] marker.
*/
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
import {
@@ -19,7 +14,6 @@ import {
SessionStore,
KnowledgeGraph,
HybridSearch,
ImprovementSignalStore,
} from '@waggle/core';
import { createMindTools } from '../src/tools.js';
import type { ToolDefinition } from '../src/tools.js';
@@ -30,7 +24,6 @@ describe('save_memory — gap K (write-path conflict detection)', () => {
let frames: FrameStore;
let sessions: SessionStore;
let tools: ToolDefinition[];
let improvementSignals: ImprovementSignalStore;
function getSaveMemory(): ToolDefinition {
const tool = tools.find(t => t.name === 'save_memory');
@@ -45,7 +38,6 @@ describe('save_memory — gap K (write-path conflict detection)', () => {
sessions = new SessionStore(db);
const knowledge = new KnowledgeGraph(db);
const search = new HybridSearch(db, embedder);
improvementSignals = new ImprovementSignalStore(db);
tools = createMindTools({
db,
@@ -55,7 +47,6 @@ describe('save_memory — gap K (write-path conflict detection)', () => {
sessions,
search,
knowledge,
improvementSignals,
// Intentionally NO cognify → exercises the raw-frame fallback path
// (no LLM-dependent entity extraction in unit tests).
});
@@ -94,17 +85,9 @@ describe('save_memory — gap K (write-path conflict detection)', () => {
expect(second).toContain('Memory saved');
// But the return message is annotated
expect(second).toContain('[flag: contradicts_existing');
// And a correction signal is recorded
const top = improvementSignals.getByCategory('correction');
expect(top.length).toBeGreaterThan(0);
const writeConflict = top.find(s => s.pattern_key.startsWith('write-conflict:'));
expect(writeConflict).toBeDefined();
expect(writeConflict!.detail).toMatch(/contradicts existing frame/i);
expect(writeConflict!.category).toBe('correction');
});
it('non-contradicting saves do not flag or emit a signal', async () => {
it('non-contradicting saves are not flagged', async () => {
const save = getSaveMemory();
await save.execute({
content: 'Decision: we chose PostgreSQL for analytics; approved and confirmed.',
@@ -117,34 +100,5 @@ describe('save_memory — gap K (write-path conflict detection)', () => {
source: 'user_stated',
});
expect(result).not.toContain('contradicts_existing');
const top = improvementSignals.getByCategory('correction');
expect(top.find(s => s.pattern_key.startsWith('write-conflict:'))).toBeUndefined();
});
it('works without improvementSignals dep (backwards-compatible)', async () => {
// Rebuild tools without signals dep
const db2 = new MindDB(':memory:');
const embedder = new MockEmbedder();
const frames2 = new FrameStore(db2);
const sessions2 = new SessionStore(db2);
const knowledge2 = new KnowledgeGraph(db2);
const search2 = new HybridSearch(db2, embedder);
const tools2 = createMindTools({
db: db2,
identity: new IdentityLayer(db2),
awareness: new AwarenessLayer(db2),
frames: frames2,
sessions: sessions2,
search: search2,
knowledge: knowledge2,
// No improvementSignals — should not throw
});
const save = tools2.find(t => t.name === 'save_memory')!;
await save.execute({ content: 'Decision: enable feature flag rollout for users; proceed.', target: 'personal' });
const result = await save.execute({ content: 'Decision: disable feature flag rollout for users; cancel.', target: 'personal' });
// Flag still appears (detectContradiction doesn't need the signal store)
expect(result).toContain('contradicts_existing');
db2.close();
});
});