Skip to content

Cross-session graph persistence (memory/ → graph merge) #6

@jeremiepas

Description

@jeremiepas

Problem

Conversations saved to memory/ are loaded on startup but NOT merged into the main graph.json. select_context queries only graph nodes, missing conversation nodes in structural queries.

Solution

On startup, merge conversations from memory/ directory into the loaded graph before building the index. After N mutations, write the enriched graph back to graph.json.

Startup flow:

  1. Load graph.json
  2. Load all conversations from memory/
  3. Merge conversation nodes + edges into graph
  4. Build index from enriched graph
  5. Start MCP server with enriched state

Snapshot policy:

  • Every 10 mutations: write graph.json atomically
  • On SIGTERM/SIGINT: force snapshot
  • On explicit snapshot MCP command: force snapshot

Acceptance Criteria

  • On restart, previously saved conversations appear in select_context
  • Periodic snapshot after 10 mutations
  • Graceful shutdown writes final snapshot
  • Atomic write (temp file + rename) to prevent corruption

Files to Modify

  • src/Graphos/Infrastructure/Server/MCP.hs — merge conversations on startup
  • src/Graphos/UseCase/Export.hs — add snapshot function
  • src/Graphos/UseCase/Conversation.hs — add mergeConversationsToGraph

Effort: 1 day

Priority: Critical (depends on #5)

See: docs/proposals/memory-agent/02-gap-analysis.md (Gap 6)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestmemory-agentMemory agent capabilitiesphase-1Phase 1: Mutable Graph + Persistence

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions