Skip to content

feat(memory): MemMachine query bias, episode preservation, HeLa-Mem edge weights and Hebbian updates#3371

Merged
bug-ops merged 3 commits intomainfrom
memmachine-bias-hela-mem-edge
Apr 24, 2026
Merged

feat(memory): MemMachine query bias, episode preservation, HeLa-Mem edge weights and Hebbian updates#3371
bug-ops merged 3 commits intomainfrom
memmachine-bias-hela-mem-edge

Conversation

@bug-ops
Copy link
Copy Markdown
Owner

@bug-ops bug-ops commented Apr 24, 2026

Summary

  • MM-F3 — Query bias correction: lightweight first-person intent detection (regex/prefix heuristic, no LLM) shifts embeddings toward a profile centroid via weighted linear combination. Centroid cached in RwLock<Option<CachedCentroid>> with 5-min TTL; dimension mismatch logs WARN and passes through.
  • MM-F4 — Episode preservation invariant: messages within any summary's [first_message_id, last_message_id] range are excluded from soft-delete in eviction phase 1 via NOT EXISTS with partial index idx_summaries_message_range.
  • HL-F1 — Edge weight schema: adds weight REAL NOT NULL DEFAULT 1.0 to graph_edges via SQLite migration 077; updates Edge, EdgeRow, and 14 SELECT projections.
  • HL-F2 — Hebbian update on retrieval: apply_hebbian_increment increments traversed edge weights by hebbian_lr after each recall; instrumented with tracing span; opt-in via [memory.hebbian].enabled = false default.

New config sections: [memory.retrieval].query_bias_correction, [memory.hebbian]. Both wired into --migrate-config.

Test plan

  • cargo nextest run -p zeph-memory — 1187 tests pass (16 new tests for all four features)
  • cargo clippy -p zeph-memory -p zeph-config -- -D warnings — clean
  • cargo +nightly fmt --check — clean
  • SQLite migration 077 applies cleanly via --migrate-config
  • enabled = false / query_bias_correction = false — zero overhead (verified by impl-critic)
  • Live session test: enable memory.hebbian.enabled = true, run multi-turn, verify edge weights increment in DB

Closes #3341
Closes #3344

@github-actions github-actions Bot added enhancement New feature or request size/XL Extra large PR (500+ lines) documentation Improvements or additions to documentation memory zeph-memory crate (SQLite) rust Rust code changes config Configuration file changes and removed size/XL Extra large PR (500+ lines) labels Apr 24, 2026
@bug-ops bug-ops force-pushed the memmachine-bias-hela-mem-edge branch from 363a7a3 to 83db8f9 Compare April 24, 2026 20:31
@bug-ops bug-ops enabled auto-merge (squash) April 24, 2026 20:31
@github-actions github-actions Bot added the size/XL Extra large PR (500+ lines) label Apr 24, 2026
@bug-ops bug-ops force-pushed the memmachine-bias-hela-mem-edge branch 3 times, most recently from 3c46d27 to e7f784e Compare April 24, 2026 21:01
bug-ops added 3 commits April 24, 2026 23:01
… HeLa-Mem edge weights and Hebbian updates

MM-F3: lightweight first-person query intent detection (regex/prefix, no LLM)
biases embeddings toward profile centroid via weighted linear combination.
Profile centroid cached in RwLock<Option<CachedCentroid>> with 5-min TTL;
dimension mismatch logs WARN and passes through unchanged.

MM-F4: episode preservation as data-integrity invariant — messages within
any summary's [first_message_id, last_message_id] range are excluded from
soft-delete in eviction phase 1 via NOT EXISTS with partial index.

HL-F1: adds weight REAL NOT NULL DEFAULT 1.0 to graph_edges via SQLite
migration 077; updates Edge struct, EdgeRow projection (14 sites), and
--migrate-config pipeline.

HL-F2: apply_hebbian_increment increments traversed edge weights by
hebbian_lr after each recall (WHERE id IN traversed_edge_ids, valid_to IS NULL);
instrumented with tracing span; opt-in via memory.hebbian.enabled (default false).

Config: new [memory.retrieval].query_bias_correction, [memory.hebbian] section.
Tests: 16 new unit/integration tests; 1187 total pass.

Closes #3341
Closes #3344
@bug-ops bug-ops force-pushed the memmachine-bias-hela-mem-edge branch from e7f784e to da4b414 Compare April 24, 2026 21:02
@bug-ops bug-ops merged commit de26c50 into main Apr 24, 2026
32 checks passed
@bug-ops bug-ops deleted the memmachine-bias-hela-mem-edge branch April 24, 2026 21:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

config Configuration file changes documentation Improvements or additions to documentation enhancement New feature or request memory zeph-memory crate (SQLite) rust Rust code changes size/XL Extra large PR (500+ lines)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(memory): HeLa-Mem edge weight schema and Hebbian reinforcement updates feat(memory): MemMachine query bias correction and episode preservation

1 participant