Problem
Uteke has per-insert contradiction detection (consolidate.rs: check_contradiction), but no retroactive scan of existing memories. Contradictions can accumulate over time as new information supersedes old facts.
Hermes holographic memory runs an O(n^2) pair scan: high entity overlap + low content similarity = contradiction. Uteke already has the building blocks: ONNX cosine similarity for content divergence, memory_edges table with "contradicts" type, and the Dream maintenance pipeline.
Proposed Solution
Add Phase 7: Contradict to Dream pipeline
Insert after Dedup (position 4, before Orphans):
1. Lint
2. Backlinks
3. Dedup
4. Contradict ← NEW
5. Orphans
6. Compact
7. Verify
Algorithm
- Load top 200 most recently updated memories (not full O(n^2))
- For each pair (i, j):
- Compute content cosine similarity via ONNX embeddings (already stored)
- If similarity <= 0.6 AND both memories have overlapping tags (|tags_i ∩ tags_j| >= 1): flag as potential contradiction
- For each contradiction pair:
- Insert memory_edges row: source=older_id, target=newer_id, edge_type="contradicts"
- Optionally: mark older as deprecated (configurable, default off)
- Report: count of contradictions found, edges created
Why tag overlap instead of entity overlap
Uteke does not have structured entity extraction (Hermes uses regex). Tags serve as the closest proxy for "shared topic/context". This avoids adding NLP dependencies while catching the most common contradiction pattern.
Configuration
dream.contradict.enabled: bool (default true)
dream.contradict.similarity_threshold: f32 (default 0.6)
dream.contradict.tag_overlap_min: usize (default 1)
dream.contradict.max_memories: usize (default 200)
dream.contradict.deprecate_older: bool (default false)
Files to Change
- crates/uteke-core/src/dream.rs - Add DreamPhase::Contradict, phase_contradict()
- crates/uteke-core/src/consolidate.rs - Extract reusable pair-scan logic
- crates/uteke-core/src/lib.rs - Config struct additions
Acceptance Criteria
Problem
Uteke has per-insert contradiction detection (consolidate.rs: check_contradiction), but no retroactive scan of existing memories. Contradictions can accumulate over time as new information supersedes old facts.
Hermes holographic memory runs an O(n^2) pair scan: high entity overlap + low content similarity = contradiction. Uteke already has the building blocks: ONNX cosine similarity for content divergence, memory_edges table with "contradicts" type, and the Dream maintenance pipeline.
Proposed Solution
Add Phase 7: Contradict to Dream pipeline
Insert after Dedup (position 4, before Orphans):
Algorithm
Why tag overlap instead of entity overlap
Uteke does not have structured entity extraction (Hermes uses regex). Tags serve as the closest proxy for "shared topic/context". This avoids adding NLP dependencies while catching the most common contradiction pattern.
Configuration
dream.contradict.enabled: bool (default true)dream.contradict.similarity_threshold: f32 (default 0.6)dream.contradict.tag_overlap_min: usize (default 1)dream.contradict.max_memories: usize (default 200)dream.contradict.deprecate_older: bool (default false)Files to Change
Acceptance Criteria