Skip to content

Leverage full MenteDB feature set in CoderHelm memory module #22

Open

Description

@nambok

Summary

CoderHelm currently uses ~5 functions from 4 MenteDB crates out of 13 available. This ticket covers integrating the remaining 9 crates to make memory smarter, more efficient, and scalable.

Current State

Used: mentedb, mentedb-core, mentedb-embedding, mentedb-extraction

  • open_with_embedder, store, recall_similar, get_memory, memory_count, forget, flush, close
  • MemoryNode, MemoryType (all 6 variants), AgentId, EmbeddingProvider trait
  • Custom BedrockEmbedder for AWS Bedrock
  • S3 sync for persistence, DynamoDB locking for concurrency

Not used: 9 crates with significant capabilities sitting idle.

Implementation Plan

1. Memory Consolidation (mentedb-consolidation) — HIGH PRIORITY

Memories currently grow unbounded per repo. Integrate:

  • DecayEngine — time-based decay scoring so old, unused memories lose relevance
  • MemoryCompressor — compress verbose memories to save tokens
  • ConsolidationEngine — merge duplicate/overlapping memories into consolidated entries
  • Run consolidation at the end of each successful run or on a schedule

2. Context Assembly (mentedb-context) — HIGH PRIORITY

Replace manual string formatting in recall_context with:

  • ContextAssembler — assembles memories into a context window respecting token budgets
  • TokenBudget — tracks token usage across zones (procedural, corrections, semantic, etc.)
  • ZoneBudgetConfig — allocate proportional budget to different memory types
  • assemble_delta — for multi-turn, only inject new/changed memories

3. Graph Relationships (mentedb-graph) — MEDIUM

Connect related memories instead of treating them as isolated vectors:

  • GraphManager — add_relationship between memories (e.g., "this fix corrects that anti-pattern")
  • Traversal — BFS/DFS to find related memory clusters
  • Belief propagation — when a memory is invalidated, propagate to related memories
  • Use relate() on MenteDb to create edges between stored memories

4. Cognitive Trajectories (mentedb-cognitive) — MEDIUM

Track which approaches work for which repos/patterns:

  • TrajectoryTracker — record state transitions (e.g., "tried approach A → failed → approach B → succeeded")
  • TransitionMap — reinforce successful patterns, decay failed ones
  • predict_from — suggest likely successful approaches based on past trajectories
  • Persist per-repo trajectory data alongside memory

5. Query Language (mentedb-query) — LOW

Use MQL for structured memory queries instead of raw vector search:

  • Mql::parse — parse structured queries like RECALL WHERE type = "anti_pattern" AND tags CONTAIN "auth" LIMIT 5
  • QueryPlan — optimized execution plans
  • Could power a memory search/debug UI in the dashboard

6. HNSW Indexing (mentedb-index) — LOW

Replace brute-force similarity search with HNSW for repos with large memory stores:

  • Faster recall at scale (100s-1000s of memories per repo)
  • Automatic index building on memory open

7. Replication (mentedb-replication) — FUTURE

  • Cross-region memory sync for multi-region deployment
  • Not needed until CoderHelm goes multi-region

8. Server Mode (mentedb-server) — FUTURE

  • Shared memory service instead of per-Lambda file-based access
  • Could eliminate S3 sync overhead and DynamoDB locking
  • Consider when memory access patterns become a bottleneck

Acceptance Criteria

  • Memories are consolidated/decayed after each run — no unbounded growth
  • Context assembly uses token budgets instead of hardcoded string formatting
  • Related memories are linked via graph edges
  • Trajectory tracking records success/failure patterns per repo
  • All existing memory tests pass
  • Memory recall quality improves (measured by relevant context in agent prompts)

Files to Modify

  • services/worker/src/memory/mod.rs — main integration point
  • services/worker/Cargo.toml — add new crate dependencies
  • services/worker/src/passes/implement.rs — use context assembly for prompt building
  • services/worker/src/passes/resume.rs — trigger consolidation on run completion

Notes

  • mentedb-storage is already used internally by the mentedb crate (WAL, pages, buffer pool)
  • Memory is feature-flagged via MEMORY_ENABLED env var — new features should respect this
  • Per-repo memory stored in S3 with DynamoDB concurrency locks — consolidation must work within this model

Activity

  1. added
    enhancement
    on Apr 23, 2026
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

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions