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).
105 lines
3.4 KiB
TypeScript
105 lines
3.4 KiB
TypeScript
/**
|
|
* 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.
|
|
*/
|
|
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
|
|
import {
|
|
MindDB,
|
|
IdentityLayer,
|
|
AwarenessLayer,
|
|
FrameStore,
|
|
SessionStore,
|
|
KnowledgeGraph,
|
|
HybridSearch,
|
|
} from '@waggle/core';
|
|
import { createMindTools } from '../src/tools.js';
|
|
import type { ToolDefinition } from '../src/tools.js';
|
|
import { MockEmbedder } from '../../hive-mind-core/tests/mind/helpers/mock-embedder.js';
|
|
|
|
describe('save_memory — gap K (write-path conflict detection)', () => {
|
|
let db: MindDB;
|
|
let frames: FrameStore;
|
|
let sessions: SessionStore;
|
|
let tools: ToolDefinition[];
|
|
|
|
function getSaveMemory(): ToolDefinition {
|
|
const tool = tools.find(t => t.name === 'save_memory');
|
|
if (!tool) throw new Error('save_memory tool not found');
|
|
return tool;
|
|
}
|
|
|
|
beforeEach(() => {
|
|
db = new MindDB(':memory:');
|
|
const embedder = new MockEmbedder();
|
|
frames = new FrameStore(db);
|
|
sessions = new SessionStore(db);
|
|
const knowledge = new KnowledgeGraph(db);
|
|
const search = new HybridSearch(db, embedder);
|
|
|
|
tools = createMindTools({
|
|
db,
|
|
identity: new IdentityLayer(db),
|
|
awareness: new AwarenessLayer(db),
|
|
frames,
|
|
sessions,
|
|
search,
|
|
knowledge,
|
|
// Intentionally NO cognify → exercises the raw-frame fallback path
|
|
// (no LLM-dependent entity extraction in unit tests).
|
|
});
|
|
});
|
|
|
|
afterEach(() => {
|
|
db.close();
|
|
});
|
|
|
|
it('flags contradictions and records a correction signal', async () => {
|
|
const save = getSaveMemory();
|
|
|
|
// Prime with an affirmative decision frame.
|
|
// Using "enable/disable feature flag rollout users" — the existing
|
|
// detectContradiction algorithm needs asymmetric sentiment to fire;
|
|
// inputs with "will" in both sides add positive noise that can mask
|
|
// the polarity swing. Keep inputs tight and unambiguous.
|
|
const first = await save.execute({
|
|
content: 'Decision: enable feature flag rollout for users; proceed and confirmed.',
|
|
importance: 'important',
|
|
target: 'personal',
|
|
source: 'user_stated',
|
|
});
|
|
expect(first).toContain('Memory saved');
|
|
expect(first).not.toContain('contradicts_existing');
|
|
|
|
// Contradicting decision — disable/reject/cancel instead of enable/approve
|
|
const second = await save.execute({
|
|
content: 'Decision: disable feature flag rollout for users; cancel and reject.',
|
|
importance: 'important',
|
|
target: 'personal',
|
|
source: 'user_stated',
|
|
});
|
|
|
|
// Save still succeeded — conflict is a flag, not an abort
|
|
expect(second).toContain('Memory saved');
|
|
// But the return message is annotated
|
|
expect(second).toContain('[flag: contradicts_existing');
|
|
});
|
|
|
|
it('non-contradicting saves are not flagged', async () => {
|
|
const save = getSaveMemory();
|
|
await save.execute({
|
|
content: 'Decision: we chose PostgreSQL for analytics; approved and confirmed.',
|
|
target: 'personal',
|
|
source: 'user_stated',
|
|
});
|
|
const result = await save.execute({
|
|
content: 'Meeting notes from standup — discussed roadmap for Q2 and sprint planning.',
|
|
target: 'personal',
|
|
source: 'user_stated',
|
|
});
|
|
expect(result).not.toContain('contradicts_existing');
|
|
});
|
|
});
|