Expand description
EM-Graph: episodic event extraction and causal linking (issue #3713).
The Episodic Memory Graph stores conversation events (actions, decisions, discoveries,
errors) as nodes connected by causal relationships. This is distinct from the
entity-centric MAGMA graph stored in graph_edges — EM-Graph captures what happened
and why, while MAGMA captures what is related to what.
§Storage
Events are stored in episodic_events and causal links in causal_links
(both created by migration 086). Messages are never deleted (spec 001-6), so
FK references from events to messages are always valid even after optical forgetting
compresses the message content.
§Extraction
extract_events calls an LLM to identify events in a conversation turn.
link_events detects causal relationships between the new events and
recent events in the same session.
§Retrieval
recall_episodic_causal finds events relevant to a query and walks the
causal graph to build a chain of causally-related events.
Structs§
- Causal
Link - A directed causal link between two episodic events.
- EmGraph
Config - EM-Graph episodic event extraction and causal linking configuration.
- Episodic
Event - An episodic event extracted from a conversation turn.
Functions§
- extract_
events - Extract episodic events from a conversation turn via LLM.
- fetch_
recent_ events - Retrieve recent events for a session (context for causal linking).
- link_
events - Detect causal links between
new_eventsandrecent_eventsvia LLM. - recall_
episodic_ causal - Retrieve a causal chain of events starting from a seed event.
- store_
events - Persist extracted events to the
episodic_eventstable. - store_
links - Persist causal links to the
causal_linkstable.