Skip to content

feat(memory): MAGMA multi-graph memory with typed edges (issue #1821)#2077

Merged
bug-ops merged 2 commits intomainfrom
feat/issue-1821/magma-multi-graph-memory
Mar 21, 2026
Merged

feat(memory): MAGMA multi-graph memory with typed edges (issue #1821)#2077
bug-ops merged 2 commits intomainfrom
feat/issue-1821/magma-multi-graph-memory

Conversation

@bug-ops
Copy link
Owner

@bug-ops bug-ops commented Mar 20, 2026

Summary

Implement MAGMA (Multi-Graph Agentic Memory Architecture) — multi-graph memory with typed edges (Semantic/Temporal/Causal/Entity) enabling subgraph-scoped BFS retrieval.

4-Phase Implementation:

  1. Schema: EdgeType enum + migration 041 with UNIQUE index fix + CHECK constraint
  2. Extraction: LLM edge_type classification with serde defaults + fallback to Semantic
  3. Retrieval: Query classifier (heuristic) + typed subgraph BFS with dynamic filtering
  4. Integration: Context assembly calls classifier, TUI/CLI display edge types

Test Plan

  • 6281/6281 tests PASS (+17 new tests)
  • All validators approved (Security, Impl-Critic, Perf, Tester)
  • Code review approved with 5 minors (all fixed)
  • fmt, clippy, nextest all PASS
  • Both critic mitigations verified and tested
  • Backward compatibility confirmed (empty edge_types = all types)

Key Changes

  • Migration 041: edge_type column + FIXED UNIQUE index + perf indexes + CHECK constraint
  • EdgeType enum: Semantic(default), Temporal, Causal, Entity with serde, Display, FromStr
  • insert_edge_typed(): dedup key includes edge_type (critic mitigation M0: Project bootstrap — workspace and crate skeleton #1)
  • bfs_typed(): typed subgraph BFS with dynamic IN filtering
  • graph_recall(): edge_types parameter, dedup key includes edge_type (critic mitigation M1: Ollama chat loop — interactive CLI with LLM #2)
  • classify_graph_subgraph(): heuristic query classifier with shared marker constants
  • Context assembly: calls classify_graph_subgraph per query
  • LLM extraction: ExtractedEdge.edge_type with serde defaults + parse fallback
  • TUI/CLI: /graph stats shows edge_type_distribution, /graph facts/history display types

Validation Results

  • Security: 0 vulnerabilities, LLM injection defense solid, SQL injection prevention correct
  • Implementation Logic: All 8 focus areas correct (dedup, BFS, classifier, migration, resolver, error handling, backward compatibility)
  • Performance: No regressions, classify <1µs, BFS indexed, memory overhead negligible
  • Test Coverage: 6281/6281 PASS, all mitigations verified, edge cases covered
  • Code Quality: fmt/clippy/nextest all PASS, CHANGELOG updated, architecture adherent

Related Issues

Closes #1821
Related: #1817 (A-MEM note linking), #1341 (temporal edge columns), #1789 (TA-Mem adaptive retrieval)

Add EdgeType enum (Semantic/Temporal/Causal/Entity) to enable subgraph-scoped
BFS traversal. Implement 4-phase upgrade:

1. Schema: EdgeType column + migration 041 with UNIQUE index fix + CHECK constraint
2. Extraction: LLM edge_type classification with serde defaults + fallback to Semantic
3. Retrieval: Query classifier (heuristic) + typed subgraph BFS with dynamic filtering
4. Integration: Context assembly calls classifier, TUI/CLI display edge types

Key mitigations (per critic review):
- insert_edge_typed() dedup key includes edge_type
- graph_recall() dedup key includes edge_type
- CHECK constraint prevents invalid types
- Semantic fallback ensures recall >= current
- Backward compatible: empty edge_types = all types

All 4 validator phases approved:
- Security: 0 vulnerabilities
- Impl-Critic: All logic correct
- Perf: No regressions
- Tester: 6281/6281 PASS (+17)

Closes #1821.
@github-actions github-actions bot added documentation Improvements or additions to documentation memory zeph-memory crate (SQLite) rust Rust code changes core zeph-core crate enhancement New feature or request size/XL Extra large PR (500+ lines) labels Mar 20, 2026
…-multi-graph-memory

# Conflicts:
#	CHANGELOG.md
@bug-ops bug-ops enabled auto-merge (squash) March 21, 2026 00:05
@bug-ops bug-ops merged commit 4f333d4 into main Mar 21, 2026
25 checks passed
@bug-ops bug-ops deleted the feat/issue-1821/magma-multi-graph-memory branch March 21, 2026 00:12
bug-ops added a commit that referenced this pull request Mar 21, 2026
Resolves CHANGELOG.md conflict by keeping both entries.
No code conflicts — changes are in disjoint crates.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core zeph-core crate documentation Improvements or additions to documentation enhancement New feature or request memory zeph-memory crate (SQLite) rust Rust code changes size/XL Extra large PR (500+ lines)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

research(memory): MAGMA multi-graph memory with causal/temporal/semantic/entity edge types

1 participant