Skip to content

enhance(lifecycle): consolidation cron for session-to-insight promotion#32

Open
doctatortot wants to merge 5 commits into
ourmem:mainfrom
doctatortot:feat/consolidation-cron
Open

enhance(lifecycle): consolidation cron for session-to-insight promotion#32
doctatortot wants to merge 5 commits into
ourmem:mainfrom
doctatortot:feat/consolidation-cron

Conversation

@doctatortot

Copy link
Copy Markdown
Contributor

Summary

  • Adds a periodic background job that reviews recent Session-type memories and uses the LLM to decide which contain durable facts worth promoting to long-term Insight memories via supersede_batch
  • Supports single observation promotion (PROMOTE) and multi-observation merging (MERGE_PROMOTE) into consolidated semantic memories
  • Gated by OMEM_CONSOLIDATION_ENABLED (default: off) — no behavior change for existing deployments

Details

New module: lifecycle/consolidator.rs

  • Consolidator::run_once() iterates all spaces, queries recent Session-type memories, sends them to the LLM with a consolidation prompt, and executes decisions via supersede_batch
  • Tier evaluation (TierManager::evaluate_tier) piggybacks on each cycle
  • Graceful shutdown via tokio::sync::watch channel

Config (env vars):

  • OMEM_CONSOLIDATION_ENABLED — default false
  • OMEM_CONSOLIDATION_INTERVAL_SECS — default 3600 (1 hour)
  • OMEM_CONSOLIDATION_LOOKBACK_HOURS — default 24

Supporting change:

  • SpaceStore::list_all_spaces() — lets background jobs iterate every space without a user ID

Test plan

  • 5 new unit tests for consolidator (prompt building, deserialization, config defaults, age formatting)
  • Full test suite passes (400 tests, 0 failures)
  • Integration test with a live LLM endpoint and Session memories to verify end-to-end promotion

🤖 Generated with Claude Code

doctatortot and others added 5 commits June 18, 2026 20:56
Supports iterating all spaces for background jobs like consolidation
that need to process every space, not just those belonging to a user.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…motion

Adds a periodic background job that reviews recent Session-type memories
and uses the LLM to decide which contain durable facts worth promoting
to long-term Insight memories via supersede_batch. Supports both single
observation promotion (PROMOTE) and multi-observation merging
(MERGE_PROMOTE) into consolidated semantic memories.

Key components:
- Consolidator struct with run_once() for per-space consolidation
- LLM prompt that classifies observations as PROMOTE/MERGE_PROMOTE/SKIP
- Tier evaluation piggybacks on each consolidation cycle
- Graceful shutdown via watch channel
- Gated by OMEM_CONSOLIDATION_ENABLED (default: off)
- Configurable interval and lookback window via env vars

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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