Skip to content

feat(memory): semantic memory v2 — namespaces, decay, enrichment, LLM consolidation - #22

Merged
stretchcloud merged 1 commit into
mainfrom
feat/memory-v2
Jul 7, 2026
Merged

feat(memory): semantic memory v2 — namespaces, decay, enrichment, LLM consolidation#22
stretchcloud merged 1 commit into
mainfrom
feat/memory-v2

Conversation

@stretchcloud

Copy link
Copy Markdown
Owner

Summary

Implements the full semantic-memory v2 design (docs/design/semantic-memory-v2.md), Phases 0–4 in one change:

  • Store v2: namespaces (global/repo/session/agent), versioned schema + automatic v1→v2 migration, zero-vector quarantine + re-embed queue, lazy decay with capped reinforcement, composite scored retrieval with no-embedding fallback, eviction, pinning
  • Enrichment actually works now: user prompts get a 250 ms-budgeted, ordering-safe recalled-memory block (previously dead code); original text preserved in history; collapsible recalled-context chip in the UI
  • LLM consolidation: JUDGE→DISTILL→CONSOLIDATE with the design's exact prompt contract, strict JSON validation + retry + concat fallback, turn/idle/session-end/manual triggers
  • Extraction upgrade with thinking-block scrubbing; overview/pin REST endpoints; memory settings (decay, recall depths) in Settings UI; MemoryPanel namespace view

Testing

  • 1630/1630 tests green (159 new), typecheck + production build clean
  • Live-server smoke: settings expose memory config; store→overview→pin round-trip verified against real LanceDB; graceful degradation for unknown sessions/ids confirmed

Review provenance

  • Implemented by AI agents (4 parallel Claude Code agents + integration pass)
  • Human review: no

🤖 Generated with Claude Code

Implements docs/design/semantic-memory-v2.md end to end (Phases 0-4):

- store v2 (semantic-memory.ts, memory-migration.ts): namespace scoping
  (global/repo/session/agent), meta.json schema versioning with automatic
  v1->v2 migration, zero-vector quarantine + lazy re-embed queue,
  dimension-change handling, lazy decay with capped reinforcement,
  composite scored retrieval (sim^1.5 x decay x confidence) with
  pushed-down filters, no-embedding fallback, eviction sweep + namespace
  caps, pinning
- enrichment finally reaches prompts: awaited 250ms-budgeted hook in
  ws-bridge with per-session ordering chains; history keeps the original
  user text while the backend receives the enriched block; the UI gets a
  memory_enriched broadcast rendered as a collapsible recalled-context
  chip (with Playground mocks)
- consolidation pipeline (memory-consolidation.ts): JUDGE (weight x
  confidence filter, near-dup dedupe, greedy clustering) -> DISTILL
  (OpenRouter, exact prompt contract, strict JSON validation,
  retry-once-with-error, concat fallback, budget caps) -> CONSOLIDATE
  (upsert by namespace+tag with supersession tombstones); triggers on
  turn boundary / 30min idle / session end / manual with in-flight guard
- extraction upgrade: keyword gate replaced with recall-biased
  structural cues; thinking-block content scrubbed before any store or
  promotion
- REST: overview + pin endpoints, global/session memory namespace
  fixes; settings gain per-namespace decay half-lives, reinforce
  multipliers, and recall depths (surfaced in Settings UI); MemoryPanel
  shows namespace counts, decayed-weight bars, and pin/unpin

Tests: 159 new (store 78, pipeline 22, wiring 40, frontend 34 areas);
suite 1630/1630 green; typecheck + build clean; live-server smoke of
store/pin/overview round-trip verified.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@stretchcloud
stretchcloud merged commit 58e2d1f into main Jul 7, 2026
1 check passed
@stretchcloud stretchcloud mentioned this pull request Jul 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant