Skip to content

feat(memory): write-time importance scoring for improved retrieval#2062

Merged
bug-ops merged 2 commits intomainfrom
feat-2021-importance-scoring
Mar 20, 2026
Merged

feat(memory): write-time importance scoring for improved retrieval#2062
bug-ops merged 2 commits intomainfrom
feat-2021-importance-scoring

Conversation

@bug-ops
Copy link
Owner

@bug-ops bug-ops commented Mar 20, 2026

Summary

Add write-time importance scoring for memory retrieval, combining marker detection, content density, and role-based weighting. Importance score blends into the hybrid retrieval formula when enabled (default: disabled).

Addresses issue #2021 (MemOS: A Memory OS for AI Systems).

Changes

  • Schema: Migration 039 adds importance_score REAL column with DEFAULT 0.5
  • Importance Module: New semantic/importance.rs with 3-signal heuristic scorer
  • Config: SemanticConfig.importance_enabled and importance_weight with validation
  • Recall Path: Blends importance into final score when enabled, batch-increments access_count
  • Save Path: Computes importance at write time in save_message_with_metadata()
  • Bootstrap: Wires importance settings from config via .with_importance_options()
  • Tests: 23 new unit/integration tests covering all code paths and edge cases

Key Features

  • Backward Compatible: Feature is opt-in (disabled by default), old messages get neutral 0.5 score
  • UTF-8 Safe: Fixed panic in marker detection via char_byte_boundary() helper
  • Configurable Weights: Users can tune importance weight and enable/disable feature
  • No New Dependencies: Pure Rust heuristic scoring
  • --migrate-config Support: New config entries in default.toml for automatic user migration

Test Coverage

  • 13 unit tests: importance computation, density curves, role adjustment, UTF-8 safety
  • 10 integration tests: database operations, recall blending, access count tracking, migration compatibility

Pre-commit Checks

  • cargo +nightly fmt --check
  • cargo clippy --workspace --features full -- -D warnings
  • ✅ All 6099+ tests passing

Closes #2021

…2021)

Add write-time importance scoring that combines marker detection, content density,
and role-based weighting. Importance score blends into hybrid retrieval formula when
enabled (default: disabled). Backward compatible via DEFAULT 0.5 for existing rows.

- Schema migration 039: add importance_score column (REAL, default 0.5)
- New module: compute_importance(content, role) -> f64 with 3-signal heuristic
- Config: SemanticConfig.importance_enabled and importance_weight with validation
- Recall: blend importance into final score, batch-increment access_count
- Save path: compute importance at write time via save_message_with_metadata()
- Bootstrap: wire importance settings from config
- Tests: 23 new unit/integration tests covering edge cases, UTF-8 safety
- UTF-8 fix: char_byte_boundary() helper for safe string slicing
@github-actions github-actions bot added documentation Improvements or additions to documentation memory zeph-memory crate (SQLite) rust Rust code changes core zeph-core crate config Configuration file changes enhancement New feature or request size/XL Extra large PR (500+ lines) labels Mar 20, 2026
@bug-ops bug-ops enabled auto-merge (squash) March 20, 2026 18:53
@bug-ops bug-ops merged commit 09d3211 into main Mar 20, 2026
25 checks passed
@bug-ops bug-ops deleted the feat-2021-importance-scoring branch March 20, 2026 19:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

config Configuration file changes core zeph-core crate 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.

research(memory): write-time importance scoring for improved memory retrieval

1 participant