Skip to content

RFC: compare Raven and Claude Code memory designs for Maka's durable memory architecture #771

Closed

Description

@bug-superman

Context

This is a follow-up to #544, especially the durable execution foundation / Memory track.

#544 defines the high-level requirement:

long-lived user, project, and task memory, not just context summarization; memory needs source attribution, freshness, confidence, scope, and expiry semantics.

Maka already has useful memory and context-management foundations, but it does not yet have a complete durable-memory lifecycle.

This RFC proposes a source-backed comparison of two mature design directions:

  • Raven-native memory/context architecture;
  • the file-based memory and session-compaction architecture exposed by the likun666661/claude-code source fork used in this research.

The Claude source reference is an open-source fork/reconstruction, not the complete current implementation of Anthropic's closed-source Claude Code product. Claims in this issue should therefore be phrased as source behavior in that repository, not as guarantees about every current Claude Code release.

The goal is to decide which concepts Maka should adopt, which existing Maka components should be preserved, and how the work should be split into independently mergeable issues and PRs.

Why this needs a dedicated RFC

Memory is currently mixed with several related but different concerns:

  • prior conversation replay;
  • context compaction;
  • current task continuity;
  • long-lived user/project facts;
  • proactive attention and behavioral state;
  • archive and retrieval;
  • privacy, approval, scope, expiry, and correction.

Treating all of these as one growing MEMORY.md or one summary block would make correctness, cost, privacy, and recovery difficult to reason about.

We should first define explicit ownership and lifecycle boundaries, then implement them incrementally.

Current Maka baseline

Maka is not starting from zero.

Existing durable-memory controls

  • user-visible memory/MEMORY.md;
  • PENDING.md proposal queue;
  • draft / review_required / active / archived / rejected states;
  • proposal -> approve/reject flow;
  • workspace/session scope fields;
  • incognito read/write blocking;
  • secret redaction;
  • backup/restore and atomic writes;
  • agent memory read disabled by default.

Existing context/compaction controls

  • append-only RuntimeEvent ledger;
  • history token/turn budgets;
  • stale and active tool-result pruning;
  • archive retrieval and history search;
  • source-bearing history compact checkpoints;
  • active full compact and semantic compact;
  • compaction boundaries, coverage, hashes, and fail-open diagnostics.

Current gaps and correctness concerns

  • active memory entries are concatenated and then truncated at 12,000 characters;
  • recall is not query-aware or top-K;
  • scope=session is stored but the current prompt builder does not receive a session id or enforce it;
  • the memory prompt may be captured when the backend is created rather than refreshed every turn;
  • there is no per-session message manifest;
  • there is no independent working state for goals/open threads/decisions;
  • there is no episode -> profile consolidation lifecycle;
  • there is no structured stale/conflict/supersedes model;
  • there is no attention/behaviors derived-state pipeline;
  • there is no agent-facing MemoryPropose tool behind the host approval gate.

These correctness issues should be fixed before introducing an LLM Curator.

Raven design summary

Raven provides the stronger end-to-end memory lifecycle and should be considered the primary architectural reference.

Context ownership

  • one ContextAssembler/ContextEngine owns the model-visible context;
  • Fast Path passes history without an extra LLM call while pressure is low;
  • Slow Path uses a smaller Curator model to select/archive/retrieve context;
  • deterministic fallback remains available when Curator fails;
  • the final trimmer enforces token budget and tool-call/result adjacency.

Durable and derived memory layers

  • append-only session history remains the source of truth;
  • lossless archive keeps old messages retrievable;
  • working state tracks goals, open threads, and decisions;
  • episodes record events and source references;
  • profile updates occur after evidence accumulates;
  • attention and behaviors support proactive planning;
  • offsets prevent repeated processing of the same session data.

Evidence currently available

The Raven checkout contains extensive tests covering Curator paths, context invariants, session append/concurrency, locking/CAS, consolidation, attention/behaviors, offsets, and overflow recovery.

The reviewed 13 relevant test files contain 186 statically counted test_* functions. This is a source count, not an independently executed pass result.

Raven also provides benchmark/eval harnesses:

  • PinchBench: 23 task cards;
  • ClawBench Streaming: persistent-session task execution;
  • Proactivity pbench: 120 help-or-skip records;
  • Proactivity longrun: 6 personas x 30 days;
  • Skill Evals: 50 retrieval queries.

Raven's first-party documentation reports:

Benchmark Legacy Curator
PinchBench continuous, 16K, 9 tasks 86.0% 95.9%
DeepResearch-Bench-II, 32K, 10 tasks 43.2% 49.6%
task_21 comprehension 11% 100%

These numbers are useful motivation, but the current repository does not include the complete raw artifacts needed to independently recompute them. Maka must run its own controlled A/B.

Claude Code design summary

Claude Code is the stronger reference for bounded file recall, session continuity, stale handling, and compact recovery.

Bounded file memory

  • MEMORY.md is a small index rather than the full memory body;
  • the index is capped at 200 lines and 25KB;
  • at most 200 topic-file headers are scanned;
  • a relevance side query selects at most 5 topic files;
  • each selected topic is capped at 200 lines / 4KB;
  • one turn injects at most about 20KB of relevant topic memory;
  • session memory prefetch stops after 60KB of cumulative injected content;
  • already-read or already-injected topic files are deduplicated.

Session Memory and compact

  • Session Memory initializes after about 10,000 context tokens;
  • it updates after about 5,000 additional tokens;
  • the notes use fixed sections such as Current State, Task specification, Files and Functions, Workflow, Errors & Corrections, Learnings, Key results, and Worklog;
  • total Session Memory is bounded to about 12,000 tokens;
  • compact boundaries preserve continuation metadata;
  • reactive compact handles prompt-too-long failures;
  • resume reconnects the compact summary and preserved suffix.

Stale and correction behavior

  • memories older than one day receive a stale warning;
  • current code/resource state takes precedence over recalled memory;
  • the extraction prompt asks the agent to update/remove outdated memories and avoid duplicates.

Important limitations for Maka

Claude Code does not provide the full Raven lifecycle:

  • no Raven-style per-message manifest;
  • no explicit episode -> evidence threshold -> profile promotion;
  • no attention/behaviors + offset pipeline;
  • no Raven-style Curator message archive/retrieve tool loop;
  • no Maka-style per-entry user approval requirement.

Comparison

Concern Raven Claude Code Proposed Maka owner
Source-of-truth transcript append-only session transcript + compact boundaries existing Maka RuntimeEvent ledger
Context ownership unified ContextEngine/Curator several compact/recall services Raven-style interface over Maka runtime
Low-pressure cost zero-LLM Fast Path no compact until thresholds; async memory prefetch deterministic Fast Path
High-pressure shaping Curator Slow Path summary/session-memory compact Raven Curator, initially shadow mode
Hard final budget HistoryTrimmer multiple caps and compact budgets one deterministic Maka hard trimmer
Old-history recovery lossless archive/retrieve transcript, boundaries, preserved suffix, past-context search Raven semantics + Maka source-bearing artifacts
Current task continuity working state structured Session Memory combine both
Durable memory lifecycle episodes -> profile direct topic-memory extraction/update Raven lifecycle + Maka approval
Recall local section selection query-aware top-5 topic selection Claude caps + deterministic Maka ranking
Stale/conflict source-aware profile update stale warning/current state first Claude rule + structured Maka relations
Proactive state attention/behaviors no equivalent pipeline Raven, later phase
User approval/privacy weaker automatic update path model/extractor can write files preserve Maka host approval/incognito gates
Reactive compact/resume fallback/context recovery mature compact boundary/resume Claude protocol + Maka boundary types

Proposed direction

The current design hypothesis is:

Raven-first memory semantics
+ Maka-native context runtime
+ Maka approval/privacy/reversible storage
+ Claude-style bounded recall, stale handling, and compact recovery

In practical terms:

  1. Keep RuntimeEvent as the append-only source of truth.
  2. Introduce a narrow ContextEngine interface rather than rewriting Maka's compact internals.
  3. Reuse existing Maka history compact, archive retrieval, history search, active compact, semantic compact, and boundary/checkpoint types as ContextEngine adapters.
  4. Replace full active-memory concatenation with query/scope/freshness-aware bounded recall.
  5. Add per-session manifest and working state.
  6. Add lossless message archive/retrieve with verifiable source refs.
  7. Add episode candidates and evidence-gated profile proposals.
  8. Preserve proposal -> user approval before durable activation.
  9. Add Claude-style reactive compact/resume as a final recovery path.
  10. Add attention/behaviors only after durable memory correctness is stable.

This should not be a big-bang rewrite.

Proposed data ownership

Data or decision Single owner
Raw conversation/tool facts RuntimeEventStore
Model-visible messages for a turn ContextEngine
Final token/tool adjacency validation deterministic hard trimmer
Session goals/open threads/decisions working-state store
Episode candidates episode store/consolidator
Active durable profile LocalMemoryService + user approval
Attention/behaviors derived-state pipeline
Prompt-too-long recovery compact recovery controller

This ownership is intended to prevent the same fact from being injected simultaneously through a compact summary, working state, durable profile, and attention state.

Questions for discussion

  1. Should Raven-first be the main architecture, or should Maka use a simpler Claude-style topic-memory design first?
  2. Should ContextEngine own all model-visible history shaping, while AiSdkBackend only consumes provider-safe messages?
  3. Should the first recall implementation be deterministic, with an LLM selector only in shadow mode?
  4. Should durable profile promotion always require user approval, even after repeated episode evidence?
  5. Which memory scopes are required in v1: workspace and session only, or also user/project/team?
  6. Should MEMORY.md remain the canonical store, or become a human-readable projection over structured entries?
  7. What should be the initial memory-segment token budget and top-K?
  8. How should corrections and deletion propagate through profile, episodes, archive indexes, and compact caches?
  9. Which target models should be used to validate the claim that Raven-style bounded context is better for smaller or less stable tool-calling models?
  10. Which Raven benchmark harnesses should be adapted, and which Maka-native memory datasets must be created?

Proposed implementation order

  1. Fix correctness first:
    • enforce session scope on read;
    • refresh/invalidate memory prompt state per turn;
    • fail closed on invalid semantic compact summaries;
    • ensure every fallback still passes the hard context budget.
  2. Add bounded MemorySegmentBuilder and recall trace.
  3. Extract a narrow ContextEngine interface with real strategy switching.
  4. Add session manifest, lossless archive, and working state.
  5. Add LLM Curator in offline/shadow mode.
  6. Add episode store and profile proposal consolidation.
  7. Harden Claude-style reactive compact/resume.
  8. Add attention/behaviors and proactivity evaluation.

Benchmark and acceptance requirements

At minimum, compare:

  • full context;
  • current Maka;
  • deterministic Curator;
  • LLM Curator;
  • summary compact;
  • hybrid Curator + reactive compact.

Report separately:

  • task pass/verifier score;
  • fact recall precision/recall/F1;
  • final-call context tokens;
  • task and session cumulative tokens;
  • main-model and Curator tokens/cost;
  • p50/p95 latency;
  • Fast/Slow/Fallback counts;
  • archive/retrieve use;
  • provider overflow and emergency recovery;
  • stale/conflict correctness;
  • cross-session/workspace privacy leaks;
  • false profile promotions.

The benchmark report must preserve commit, model/provider config, dataset hash, full transcript, model-visible selected source ids, token CSV, and verifier artifacts.

Non-goals

  • adding EverOS, embeddings, a vector database, or an external memory backend in this RFC;
  • rewriting all existing context/compact code;
  • automatically converting all conversations into durable memory;
  • enabling proactive attention before durable memory correctness is established;
  • claiming Raven benchmark gains without reproducing them on Maka.

Expected outcome of this RFC

  • agree on the target architecture and ownership boundaries;
  • decide what is adopted from Raven, Claude Code, and current Maka;
  • agree on v1 scope, storage, write/read/update/delete semantics;
  • agree on benchmark variants, metrics, and promotion gates;
  • split the work into small implementation issues/PRs.

Suggested follow-up issues

  • Fix session-scope memory reads and per-turn memory refresh.
  • Add deterministic bounded MemorySegmentBuilder and recall diagnostics.
  • Extract ContextEngine strategy interface from AiSdkBackend.
  • Add per-session context manifest and working state.
  • Extend source-bearing archive/retrieve to message-level history.
  • Add episode store and profile proposal consolidation.
  • Add LLM Curator shadow mode and A/B runner.
  • Add compact/resume recovery contract tests.
  • Add attention/behaviors derived-state pipeline.
  • Add Maka continuity and durable-memory lifecycle benchmark datasets.

Related


中文概要

这个 RFC 是 #544 Memory 主线的子 issue,目标不是立刻进行大规模重写,而是先对齐 Maka durable memory 的目标架构。

建议方向:

Raven 作为 memory 生命周期与 ContextEngine 主架构
Maka 保留 RuntimeEvent、compact、审批、隐私和可回滚存储
Claude 补充按需读取、硬上限、stale、Session Memory 和 compact/resume

优先顺序:先修 session scope、memory 刷新、semantic compact 和 fallback budget,再做 bounded recall;之后才进入 ContextEngine、manifest、Curator、episodes/profile 和 attention/behaviors。

Activity

  1. bug-superman commented on Jul 12, 2026

    @bug-superman
    Author

    For this iteration, we propose using Raven-native as the primary architectural reference for Maka's memory system.

    Raven keeps the complete conversation history as a durable source of truth and provides a relatively comprehensive architecture around it: ContextEngine/Curator, lossless archive and retrieval, working state, episodes/profile, and attention/behaviors. It also has substantial source-level test coverage and multiple benchmark/evaluation harnesses.

    Raven has published proactivity evaluation results using a Qwen backend and provides OpenAI-compatible benchmark configurations that can be used with models such as DeepSeek. These results should still be independently reproduced on Maka with fixed models, tasks, parameters, and artifact collection before we make performance claims.

    Using a mature architecture as the main reference gives us a stronger foundation for rebuilding Maka's memory system than continuing to add isolated features to the current single-file flow. The goal of this phase is not to optimize every memory entry point immediately. It is to first establish a complete, testable, measurable, and reversible memory architecture with mature tests and benchmark gates.

    Once that foundation is stable, we can optimize individual modules and memory entry points separately, including durable profile recall, session continuity, context archive/retrieval, proactive state, and model-specific cost policies. We can also selectively adopt useful ideas from Claude Code and other frameworks without weakening the overall ownership and lifecycle model.

    This is intended as an incremental system evolution rather than a big-bang rewrite: establish the architecture and invariants first, validate them with benchmarks, and then optimize each layer based on evidence.

  2. bug-superman commented on Jul 12, 2026

    @bug-superman
    Author

    Raven-first implementation tickets

    Native sub-issue linking is unavailable to the publishing account, so this checklist is the canonical parent relationship. Each child issue also links back to #771.

  3. Astro-Han commented on Jul 12, 2026

    @Astro-Han
    Contributor

    Thanks for putting together the research and ticket breakdown. Raven looks like a useful long-term reference, especially since it covers memory as a full lifecycle rather than a collection of isolated features.

    One concern I have is the size of the proposed first phase. MM-00 through MM-34 currently includes two related but different areas:

    • Context management: compaction, working state, archive/retrieval, resume, and overflow recovery.
    • Durable memory: what should persist across sessions, what becomes active, and how users inspect, correct, or delete it.

    It may help to keep these as separate tracks. Session continuity would sit under context management, while durable memory would focus on information that remains useful across new sessions. Project instructions and repository facts could continue to come from AGENTS.md, the repository, and current runtime state rather than being copied into another workspace memory store.

    For the first durable-memory version, perhaps we could test a narrower scope:

    • one global, user-visible MEMORY.md in a stable Maka home directory;
    • the same file shared by desktop, CLI, and headless;
    • only preferences or facts that the user states explicitly and that are likely to remain useful across sessions;
    • the main agent maintains the file through existing read/edit/write tools;
    • changes take effect automatically but remain visible, editable, and removable;
    • one Memory switch, with incognito mode disabling both reads and writes;
    • inject the complete active file while it remains small, with a hard token limit that never cuts through an entry;
    • archive an old preference when the user clearly replaces it.

    This version may not need a new memory schema, EpisodeStore, evidence thresholds, profile consolidation, Curator, attention, or behavior pipelines yet. Those ideas can remain on the Raven-informed roadmap and be introduced when a concrete failure or evaluation result shows that the simpler model is no longer enough.

    A small validation set may be sufficient for this stage: deterministic tests for the global path, refresh behavior, privacy controls, budgeting, and corrections, plus a short model evaluation covering explicit preferences, temporary requests, project instructions, sensitive content, and later corrections.

    One possible way to reduce the initial scope would be:

    1. Keep ContextEngine, compaction, archive/retrieval, working state, and recovery in a separate context-management RFC.
    2. Start durable memory with one issue, or at most two independently useful slices, covering global file-backed memory and natural agent maintenance.
    3. Keep the remaining Raven components as future decision points rather than immediate implementation tickets.

    This would still use Raven as the main long-term reference, while giving Maka room to validate the basic user experience before committing to the full architecture. Of course, this is only one possible cut of the work, and the author may have constraints or sequencing reasons that are not visible from the issue.

  4. bug-superman commented on Jul 15, 2026

    @bug-superman
    Author

    Implementation pickup update:

    First pickup: #779.

  5. hegu-1 commented on Jul 16, 2026

    @hegu-1

    The split raised in the discussion between context management and durable memory should become an explicit evaluation boundary.

    Compaction can be measured by coverage, replay validity, and recovery under budget pressure. Durable memory needs a different failure matrix:

    • false promotion: inference becomes durable fact;
    • stale conflict: old memory overrides current repository evidence;
    • correction: explicit user correction fails to supersede the old item;
    • scope bleed: user/project/session memory crosses the wrong boundary;
    • revocation: deleted or revoked memory remains in a projection/index;
    • provenance loss: recalled content cannot identify its source;
    • authority confusion: relevant memory is treated as instruction.

    I would add these as deterministic fixtures before comparing Raven versus a file-based design on recall quality. A system can retrieve very well and still be unsafe as durable memory.

    The existing PENDING.md proposal queue is valuable because it already expresses candidate versus active state. Preserving that contract may matter more than adopting any one storage architecture.

    The lifecycle framing I use for a Personal AI OS is documented here: https://github.com/hegu-1/personal-ai-os

  6. Astro-Han commented on Aug 2, 2026

    @Astro-Han
    Contributor

    Closing as superseded. The Raven-vs-Claude-Code memory RFC was never executed as planned: the MM implementation series (#779–#814) never landed outside draft PR #820 (zero reviews, never merged to main), and the durable-memory direction has since converged on #1615 (automatic long-term memory lifecycle, SQLite-based; accepted 2026-07-30, PR ① merged). Remaining context-ownership work is tracked under #853.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions