feat(memory): AOI three-layer hierarchical memory architecture#2092
Merged
feat(memory): AOI three-layer hierarchical memory architecture#2092
Conversation
Introduces explicit tier promotion between Working, Episodic, and Semantic memory layers based on the AOI paper (arXiv:2512.13956). - Add migration 042: `tier`, `promotion_timestamp`, `session_count` columns on `messages` table with indexes - Add `MemoryTier` enum (Working/Episodic/Semantic) to zeph-memory types - Add `TierPromotionConfig` under `[memory.tiers]` with validation - New `tiers.rs`: background sweep loop that clusters episodic embeddings by cosine similarity, merges clusters via LLM, promotes distilled facts to semantic tier, soft-deletes episodic originals - Wire `increment_session_counts_for_conversation()` into `load_history()` so session_count increments on every session restore - Apply additive tier boost (+0.3) to semantic facts in recall scoring - Add `/memory promote` and `/memory tiers` slash commands - Show semantic fact count in TUI memory panel - Update `--init` wizard with `[memory.tiers]` prompts - Update `--migrate-config` to inject `[memory.tiers]` for existing configs Tests: 6304 passed (+11 new)
bug-ops
added a commit
that referenced
this pull request
Mar 21, 2026
Closes #2094. Adds 29 inline tests in sqlite/messages/tests.rs covering all tier DB methods introduced in the AOI three-layer memory epic (#1839, #2092): - fetch_tiers: empty input, default episodic tier, nonexistent IDs, tier value after manual_promote - count_messages_by_tier: empty DB, all-episodic, post-promotion counts, soft-deleted rows excluded - find_promotion_candidates: empty when session_count below threshold, returns rows meeting threshold, excludes semantic rows, respects batch_size - promote_to_semantic: creates semantic message, soft-deletes originals, new ID greater than originals, empty-ids error, tier count update - manual_promote: empty input no-op, sets tier to semantic, does not delete original, idempotent (0 rows affected on second call), skips nonexistent IDs - migration 042 schema defaults: tier defaults to 'episodic', session_count defaults to 0 for rows inserted without those columns
11 tasks
bug-ops
added a commit
that referenced
this pull request
Mar 21, 2026
Closes #2094. Adds 29 inline tests in sqlite/messages/tests.rs covering all tier DB methods introduced in the AOI three-layer memory epic (#1839, #2092): - fetch_tiers: empty input, default episodic tier, nonexistent IDs, tier value after manual_promote - count_messages_by_tier: empty DB, all-episodic, post-promotion counts, soft-deleted rows excluded - find_promotion_candidates: empty when session_count below threshold, returns rows meeting threshold, excludes semantic rows, respects batch_size - promote_to_semantic: creates semantic message, soft-deletes originals, new ID greater than originals, empty-ids error, tier count update - manual_promote: empty input no-op, sets tier to semantic, does not delete original, idempotent (0 rows affected on second call), skips nonexistent IDs - migration 042 schema defaults: tier defaults to 'episodic', session_count defaults to 0 for rows inserted without those columns
bug-ops
added a commit
that referenced
this pull request
Mar 21, 2026
…2097) Closes #2094. Adds 29 inline tests in sqlite/messages/tests.rs covering all tier DB methods introduced in the AOI three-layer memory epic (#1839, #2092): - fetch_tiers: empty input, default episodic tier, nonexistent IDs, tier value after manual_promote - count_messages_by_tier: empty DB, all-episodic, post-promotion counts, soft-deleted rows excluded - find_promotion_candidates: empty when session_count below threshold, returns rows meeting threshold, excludes semantic rows, respects batch_size - promote_to_semantic: creates semantic message, soft-deletes originals, new ID greater than originals, empty-ids error, tier count update - manual_promote: empty input no-op, sets tier to semantic, does not delete original, idempotent (0 rows affected on second call), skips nonexistent IDs - migration 042 schema defaults: tier defaults to 'episodic', session_count defaults to 0 for rows inserted without those columns
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1839
Summary
MemoryTierenum (Working/Episodic/Semantic) and promotion pipeline based on the AOI paper (arXiv:2512.13956)tier,promotion_timestamp,session_countcolumns tomessagestablesession_countincremented on every session restore viaload_history()— drives promotion eligibility/memory promoteand/memory tiersslash commands--initwizard and--migrate-configupdated for[memory.tiers]Test plan
cargo +nightly fmt --check— cleancargo clippy --workspace --features full -- -D warnings— cleancargo nextest run --workspace --features full --lib --bins— 6304 passed (+11 new)increment_session_counts_for_conversationwired inload_history(), covered by 2 new unit tests--migrate-configinjects[memory.tiers]for existing configsFollow-up issues to file
tiers.rs:169)promote_to_semantic,find_promotion_candidates, etc.)similarity_threshold > 1.0rejection test inTierConfig