Summary
Refactor MemoryGraphRecallTool to enforce proper module boundaries between the MCP layer (spector-mcp) and the memory module (spector-memory), then add temporal supersession and multi-evidence reconstruction capabilities.
Strategic rationale: The MCP tool currently has 570 lines of BFS traversal engine code that directly imports 7 internal memory classes (EntityDirectory, HyperEntityGraphMemory, TemporalKnowledgeGraph, TemporalFact, MemoryIndex, etc.) via memory.admin(). This logic belongs in CognitiveGraphFacade, which was designed to encapsulate all graph traversal. Fixing this boundary violation first enables temporal supersession to be built cleanly in the memory module without duplicating logic in the MCP layer.
Temporal supersession closes a gap: assertFact doesn't auto-detect supersession (callers must manually retract+assert), there's no public API for fact history chains, graph traversal ignores validity windows, and ContradictionResolver forces a single winner with no multi-evidence mode.
User Stories
Refactoring:
As a Spector developer, I want the MCP layer to use only SpectorMemory public API so that internal memory module changes don't break MCP tools and new memory features automatically surface through MCP.
Temporal Supersession:
As an AI agent, I want "What was the user's preferred model before the June change?" to return the correct historical fact without hallucinating the current one.
As an AI agent, when I assert ("Alice", "works_at", "Google") and a prior fact ("Alice", "works_at", "Meta") exists, I want the prior fact to be automatically superseded with a history link so I can query the complete employment timeline.
Acceptance Criteria
Workstream A: Refactor MemoryGraphRecallTool
Workstream B: Temporal Supersession
Scope
IN scope (MVP):
- Graph recall refactoring with proper module boundaries
- Auto-supersession with
retractsFactId linking
factHistory() API for supersession chains
- Point-in-time
asOf temporal queries in graph traversal
- Validity window filtering in
collectEntityEdges()
- ArchUnit boundary test
ConflictAwareResolver (highest-confidence selection)
OUT of scope (future):
- JPMS
module-info.java (separate effort)
- Irreducible conflict recognition (TANGLE-style conflict-aware action policy)
- Multi-evidence reconstruction in
MemoryRecallTool (only in graph recall for now)
- Migration tooling for existing shards
Getting Started
- Build:
mvn compile -pl memory/spector-memory,synapse/spector-mcp
- Key files:
memory/spector-memory/src/main/java/com/spectrayan/spector/memory/graph/CognitiveGraphFacade.java
synapse/spector-mcp/src/main/java/com/spectrayan/spector/mcp/tools/memory/MemoryGraphRecallTool.java
memory/spector-memory/src/main/java/com/spectrayan/spector/memory/temporal/TemporalKnowledgeGraph.java
memory/spector-memory/src/main/java/com/spectrayan/spector/memory/SpectorMemory.java
- Patterns to follow:
RecallOptions (builder pattern), CognitiveGraphFacade.neighborhood() (facade traversal), ContradictionResolver interface
RICE-C Score
| Factor |
Score |
Rationale |
| Reach |
5/5 |
Affects every agent using graph recall; temporal queries benefit all enterprise users |
| Impact |
3x |
Closes #1 competitive gap (temporal), fixes architecture debt, enables future features cleanly |
| Confidence |
80% |
Infrastructure mostly exists (TKG, CognitiveGraphFacade, ContradictionResolver); scoped tightly |
| Effort |
M |
~2-3 weeks; refactoring is mechanical, temporal features build on existing infra |
| Cognitive Fit |
5/5 |
Core to Spector's neuroscience identity — temporal memory is fundamental to cognition |
Summary
Refactor
MemoryGraphRecallToolto enforce proper module boundaries between the MCP layer (spector-mcp) and the memory module (spector-memory), then add temporal supersession and multi-evidence reconstruction capabilities.Strategic rationale: The MCP tool currently has 570 lines of BFS traversal engine code that directly imports 7 internal memory classes (
EntityDirectory,HyperEntityGraphMemory,TemporalKnowledgeGraph,TemporalFact,MemoryIndex, etc.) viamemory.admin(). This logic belongs inCognitiveGraphFacade, which was designed to encapsulate all graph traversal. Fixing this boundary violation first enables temporal supersession to be built cleanly in the memory module without duplicating logic in the MCP layer.Temporal supersession closes a gap:
assertFactdoesn't auto-detect supersession (callers must manually retract+assert), there's no public API for fact history chains, graph traversal ignores validity windows, andContradictionResolverforces a single winner with no multi-evidence mode.User Stories
Refactoring:
As a Spector developer, I want the MCP layer to use only
SpectorMemorypublic API so that internal memory module changes don't break MCP tools and new memory features automatically surface through MCP.Temporal Supersession:
As an AI agent, I want
"What was the user's preferred model before the June change?"to return the correct historical fact without hallucinating the current one.As an AI agent, when I assert
("Alice", "works_at", "Google")and a prior fact("Alice", "works_at", "Meta")exists, I want the prior fact to be automatically superseded with a history link so I can query the complete employment timeline.Acceptance Criteria
Workstream A: Refactor MemoryGraphRecallTool
GraphRecallOptionsmodel class with builder patternGraphTraversalResultmodel class with structured entities, paths, grounding memoriesCognitiveGraphFacade.graphRecall()encapsulates BFS traversal (ported from MCP tool)SpectorMemory.graphRecall()default method delegates to facadeMemoryGraphRecallToolreduced from 570 to ~120 LOC — zero imports frommemory.graph.*,memory.temporal.*,memory.index.*memory_graph_recallMCP functionality preserved (no behavioral regression)Workstream B: Temporal Supersession
TemporalKnowledgeGraph.assertFactWithSupersession()auto-retracts prior active fact on same (subject, predicate)allowCoexisting=trueflag for multi-valued predicates (e.g.,speaks_language)SpectorMemory.assertFact()defaults to auto-supersessionSpectorMemory.factHistory(subject, predicate)returnsFactHistory(active + superseded chain)FactHistorymodel withFactSnapshotrecords (factId, object, validFrom, validTo, txTime, confidence, supersededByFactId)ConflictAwareResolverreturns highest-confidence fact (multi-evidence viafactHistory())CognitiveGraphFacade.graphRecall()respectsasOftemporal parameter (validity window filtering)CognitiveGraphFacade.collectEntityEdges()filters expired facts by validity windowMemoryGraphRecallTooladdsas_ofandinclude_supersededMCP parametersScope
IN scope (MVP):
retractsFactIdlinkingfactHistory()API for supersession chainsasOftemporal queries in graph traversalcollectEntityEdges()ConflictAwareResolver(highest-confidence selection)OUT of scope (future):
module-info.java(separate effort)MemoryRecallTool(only in graph recall for now)Getting Started
mvn compile -pl memory/spector-memory,synapse/spector-mcpmemory/spector-memory/src/main/java/com/spectrayan/spector/memory/graph/CognitiveGraphFacade.javasynapse/spector-mcp/src/main/java/com/spectrayan/spector/mcp/tools/memory/MemoryGraphRecallTool.javamemory/spector-memory/src/main/java/com/spectrayan/spector/memory/temporal/TemporalKnowledgeGraph.javamemory/spector-memory/src/main/java/com/spectrayan/spector/memory/SpectorMemory.javaRecallOptions(builder pattern),CognitiveGraphFacade.neighborhood()(facade traversal),ContradictionResolverinterfaceRICE-C Score