Skip to content

fix(storage): repair recall hybrid union, feedback scoring, UTC decay, consolidation, and maintenance - #91

Open
michael-denyer wants to merge 1 commit into
mainfrom
fix/retrieval-feedback-and-maintenance
Open

michael-denyer wants to merge 1 commit into
mainfrom
fix/retrieval-feedback-and-maintenance

Conversation

@michael-denyer

Copy link
Copy Markdown
Owner

Why

Address all retrieval, feedback, consolidation, and retention defects in memory-mcp so the hot cache and recall loop stay accurate and bounded over time.

What changed

  • Union FTS5 keyword matches with vector top-K in Storage.recall and score FTS hits monotonically without penalizing strong vector similarity.
  • Remove duplicate retrieved_count increments in record_retrieval_event.
  • Recompute clamped Bayesian utility_score and scope injections by project_id in mark_used_memories.
  • Scope get_recent_recalls and predict_next_memories by project_id inside get_hot_cache.
  • Filter Storage._detect_contradictions with _looks_like_contradiction so elaborations are not marked contradicts.
  • Standardize decay and staleness math on utc_now and ensure_utc to match SQLite CURRENT_TIMESTAMP.
  • Fix _merge_with_existing project-scoped hashing and vec0 delete-then-insert; protect pinned memories, scope projects, reuse stored vectors via matrix multiply, and repoint edges in ConsolidationMixin.
  • Wire retention cleanups and stamp pruning into Storage.maintenance and throttle Stop-hook maintenance via run_periodic_hook_maintenance.

Scope

Storage search, retrieval, predictions, injection tracking, hot cache, memory CRUD, consolidation, maintenance, CLI Stop hook, and regression tests in tests/test_bug_regressions.py.

Tradeoffs

  • mark_used_memories scopes by project_id rather than session_id because the MCP server generates its own session UUID separately from Claude Code hooks.
  • Stop-hook maintenance runs at most once per hour so the injection co-occurrence query no longer executes on every assistant turn.

Blast Radius

Existing recall ranking, hot-cache slot selection, consolidation behavior, and db_maintenance output gain new fields with zero-default backwards compatibility in MaintenanceResponse.

Verification

  • pytest -q: 466 passed, 1 skipped on this branch (476 passed, 1 skipped at stack tip), including 7 new regression tests in TestPR1RetrievalAndFeedbackFixes.
  • ruff check src/ tests/ and ruff format --check src/ tests/: passed.

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