Repository navigation
Description
Junior should retain useful knowledge across Conversations without accumulating redundant facts, losing important details, or restoring removed information. This issue tracks the Memory quality and lifecycle roadmap, including consolidation, expiry, deletion, index repair, and evaluation. The goal is measurable improvement in task results, not just fewer stored records.
Current Baseline
Source was inspected at 7be403183 on 2026-09-23. This replaces stale claims in the original issue while preserving its unresolved work.
- Expiry filtering and opportunistic archive batches now exist. The first archive work is recorded in fix(memory): Archive expired memories opportunistically #663; fix(memory): Deduplicate memory writes #665 is also linked in the original discussion. A periodic Memory-wide lifecycle job remains missing.
- The current kinds are
preference,procedure, andknowledge; extraction and writes carry these kinds. The old eight-kind taxonomy and “everything is knowledge” diagnosis no longer apply. - Exact duplicate checks normalize whitespace and require the same kind, access scope, and subject. Semantic duplicate review and supersession run only for user preferences. Procedures and knowledge have no equivalent write-time review. See
createScopedMemoryand Passive capture writes near-duplicate knowledge #1218. - Shared procedures use their origin Conversation as their subject. This can prevent equal facts learned in different Conversations from matching the exact duplicate gate. Origin, subject, and access need separate treatment.
- Extraction asks the model to skip existing facts after a broad top-10 search. Recall selects relevant memories but does not explicitly require each selected record to add distinct information. See
process-session.tsandrecall.ts. - Archived records can be recreated with an old write key. Retry lookup follows only one supersession link. Existing storage tests confirm archived recreation and the absence of semantic review for non-preference memories. These contracts need deliberate revision before broad consolidation.
- Embedding writes still suppress failures. Repair on some repeated writes and aggregate embedding coverage do not replace failure diagnostics or a bounded repair job. Preserve this unresolved work from the original issue.
Target Behavior
- Retain one supported representation of a fact while keeping related but distinct procedures separate.
- Preserve source references, ownership, conditions, exceptions, versions, and observation times through updates.
- Resolve supported corrections without treating the latest extraction time as proof of truth. Keep unresolved conflicts explicit.
- Recall distinct useful facts at the point they help the task, including during a Turn where evaluation supports it.
- Honor removal across retries and derived copies. Distinguish a new explicit request to remember a fact from replay of an old extraction.
- Keep access boundaries intact. Never combine private records from different Users or promote private content into public memory.
- Bound background work, storage growth, model spend, and index repair. Keep semantic consolidation, expiry, user removal, and physical deletion as separate operations.
Proposed Roadmap
This is the agreed direction to evaluate, not a claim that the design is implemented or that its quality is established.
- Establish a labeled baseline for duplicate, complementary, conflicting, stale, and distinct memories. Include difficult non-duplicates, not only easy merge cases.
- Prevent new procedure and knowledge duplicates through candidate-level review. Improve extraction search under Focus extraction hybrid pre-search queries #1247. Similarity can find candidates; it must not alone authorize removal. This replaces the original hard cosine-deletion proposal.
- Improve recall selection so redundant records do not consume the prompt budget. Preserve useful exceptions and distinct facts about the same topic.
- Define source relations, replacement history, durable retry outcomes, and removal behavior. Handle repeated supersession, concurrent writes, user removal during review, and rollback after later changes.
- Add bounded nightly consolidation in dry-run mode. Review changed records plus a rotating backlog. Record decisions and cost without changing active state.
- Enable conservative, reversible application after evaluation. First select an existing complete record and supersede redundant records. Add generated synthesis and cross-Conversation consolidation only when evidence and subject handling preserve all material details and origins.
- Complete lifecycle operations: expired backlog cleanup, embedding failure diagnostics, missing/stale embedding repair, and explicit retention rules for superseded content, evidence, caches, and removal markers.
- Evaluate task-aware recall through Research action-conditioned mid-run memory recall #1342. Keep this distinct from write quality and nightly maintenance.
Explicit removal and expiry filtering must not wait for the nightly job. Do not delete a record merely because it is old or rarely recalled. Physical cleanup must follow a defined retention policy; consolidating active records is not itself storage reclamation.
Acceptance And Evaluation
A representative case is four overlapping definitions of “deslop.” The target is one complete supported definition, with specific terminology-refactor and eval-cleanup procedures left separate. Confirm ownership, source context, and all qualifiers before applying that consolidation.
- Compare current behavior, recall-only duplicate suppression, candidate-level write review, and write review plus nightly consolidation.
- Measure unique relevant facts per prompt, answer quality, correction handling, abstention, lost details, harmful merges, cost, latency, and backlog age.
- Exercise repeated updates and repeated maintenance runs. Unchanged input should not cause repeated rewrites or make old facts appear newly observed.
- Test access boundaries, source removal, retry replay, replacement chains, overlapping workers, partial failures, missing embeddings, and rollback through real Junior integration wiring.
- Use model-based evals for semantic decisions and final answer quality. Keep source content and review prompts out of logs and traces.
- Require no known access leak or removed-fact recreation, no harmful merge in the critical suite, and no material task-quality regression before automatic application.
- Compare against simple baselines and leading memory systems using the same workloads, models, and cost budgets. Include Junior tasks and long-term memory benchmarks. Best-in-class reliability is the first milestone; a state-of-the-art quality claim requires comparative results.
Four focused existing PGlite storage tests passed during investigation. They verify current exact deduplication, preservation of distinct facts with identical embeddings, non-preference review behavior, and archived recreation. They do not validate this proposal. Corpus-wide rates, operating budgets, retention periods, and safe semantic-review thresholds remain to be measured or decided.
Related Work And Consolidation
This issue is the umbrella. Keep the focused issues open; their distinct scope and evidence are not duplicates to discard.
- Passive capture writes near-duplicate knowledge #1218 — write-time duplicate prevention for knowledge and procedures; owns the concrete repeated-capture failure.
- Focus extraction hybrid pre-search queries #1247 — extraction search quality; related PR perf(memory): focus extraction memory search #1246 was open and unmerged when inspected.
- Research action-conditioned mid-run memory recall #1342 — recall during work; owns trigger selection and mid-Turn recall evaluation.
- Move Memory fully into Junior core #1861 — Memory-to-core migration. Keep ownership/schema adoption separate from new lifecycle behavior and mass consolidation. Preserve its compatibility contract.
Prior Art
- Mem0: separate extraction from per-fact update review.
- Letta: perform memory work outside foreground conversation.
- Graphiti/Zep: retain source links and distinguish recorded time from fact validity.
- Hindsight: evidence-backed consolidation and duplicate review of consolidated records; per-session grouping can obstruct cross-session consolidation.
- LongMemEval: evaluate knowledge updates, temporal reasoning, and abstention as well as retrieval.
These inform the design; they do not establish its performance. No graph database, giant profile summary, or unrestricted autonomous memory editor is required for the first milestone.
Original investigation: View Session in Sentry.
via David Cramer.
--
Activity
dcramer commentedon Jun 28, 2026
First pass of archive done in #663
fix(memory): Preserve legacy cache idempotency
fix(memory): Require canonical extraction cache
fix(memory): Use kind for memory classification (#664)
fix(memory): Keep dedup aliases active with targets
dcramer commentedon Jun 29, 2026
#665
fix(memory): Load related supersession targets
feat(memory): Add preference supersession (#670)
[-]Operationalize memory lifecycle: expiry, dedup, supersession[/-][+]Keep Memory useful, current, and safe as it grows[/+]