Skip to content

Instantly share code, notes, and snippets.

@VincentChalnot
Created July 9, 2026 19:55
Show Gist options
  • Select an option

  • Save VincentChalnot/bd085bedb331e006568ae6c79092d1d7 to your computer and use it in GitHub Desktop.

Select an option

Save VincentChalnot/bd085bedb331e006568ae6c79092d1d7 to your computer and use it in GitHub Desktop.
Theoretical Foundations of a Conversation-Derived Knowledge Graph

Theoretical Foundations of a Conversation-Derived Knowledge Graph

Why This Architecture Is Well-Grounded — and What Is Still Open


1. The Episodic / Semantic Distinction Is the Core Architectural Decision

The most important theoretical anchor for this project comes from Tulving's 1972 distinction between episodic memory and semantic memory — a framework that remains central in cognitive neuroscience and has been directly applied to LLM agent memory systems in recent literature. neuropsychologylab.psych.utoronto

  • Episodic memory stores specific past events: contextual, time-stamped, personally situated. "I had a heating failed error on my Ender 3 after updating to Marlin 2.1.3 on March 12, 2025" is episodic. It answers when, where, who, under what circumstances. pmc.ncbi.nlm.nih
  • Semantic memory stores general, context-free knowledge: facts, concepts, relationships. "Marlin firmware supports PID tuning for extruder temperature control" is semantic. It answers what is true, divorced from any specific experience. psychstory.co

This distinction maps directly onto two different node types in the knowledge graph, which **require different schemas **:

Dimension Episodic node Semantic node
Content A specific event, observation, or decision A general fact, concept, or relationship
Time Mandatory (timestamp, valid_from, valid_to) Optional (may be timeless)
Attribution attributed_to: user (primarily) attributed_to: assistant or none
Confidence Tied to the user's certainty at the time Tied to the reliability of the source
Supersession Common — states evolve Rare — facts rarely change
public flag Always false (personal by definition) Often true (general knowledge)

The practical consequence: a single type enum is not sufficient. The spec should distinguish type: episodic from type: semantic at the top level, with the other values (fact, reflection, decision, etc.) nested under these two roots, or used as subtypes.

What recent AI research says

Several recent papers have independently re-derived this two-layer structure for LLM agent memory. AriGraph (IJCAI 2025) formalizes the memory graph as (G = (V_s, E_s, V_e, E_e)) — semantic vertices/edges plus episodic vertices/edges — and shows that agents using both layers significantly outperform those using only one. Mnemosyne (2026) implements the same split operationally in a knowledge graph with seven node types: episodic nodes store raw observation-action pairs; semantic nodes store extracted propositions with confidence scores; tag nodes serve as concept indices linking related semantic nodes. SKGE (Zenodo, 2026) applies this architecture specifically to personal agent memory in an Obsidian-compatible vault — Markdown files with YAML frontmatter, a five-category ontology, typed edges — which is structurally identical to this project's output format. themoonlight

A key cognitive neuroscience finding is also relevant here: episodic memories consolidate into semantic memories over time. Episodic knowledge graph embeddings support this computationally — semantic memory can be derived from episodic memory by a marginalization operation over temporal context. This means the pipeline should not just classify nodes at extraction time, but plan for a consolidation pass: episodic nodes that appear repeatedly across conversations become candidates for promotion to semantic nodes. papers.ssrn


2. Tags as Chunks — A Theoretically Sound v0 Retrieval Strategy

Miller's 1956 finding on chunking remains one of the most replicated results in cognitive psychology: working memory does not store raw items but chunks — coherent units that are meaningful to the subject. The limit is approximately 7±2 chunks, but crucially, the information content per chunk is unbounded — a chunk can compress an arbitrarily complex concept as long as it has a stable symbolic label. pmc.ncbi.nlm.nih

The analogy to your retrieval strategy is direct:

  • A tag in the knowledge graph plays the role of a chunk label — it is a symbolic pointer to a coherent set of concepts.
  • Exposing the full ontology (all tags/categories) to an agent at the start of a session is equivalent to loading the agent's "working memory index" — not the concepts themselves, but the labels that point to them.
  • When the agent selects a tag and calls get_nodes_by_tag(tag), it retrieves a coherent, pre-grouped block of knowledge — exactly as Miller's chunk is "unpacked" from long-term memory into working context.

This approach is well-motivated as a v0 retrieval baseline for several reasons:

  1. It requires no edge construction — the ontology is the implicit graph structure.
  2. It produces predictable, auditable context blocks (all nodes under 3d_printing/firmware for instance).
  3. It degrades gracefully: if the ontology is imperfect, results are noisier but still coherent within the tag scope.

The limitation is that Miller's chunking is most effective when chunks are semantically homogeneous. In the original design this argued for locking the ontology before extraction. Design review reversed this: a rigid, pre-locked taxonomy causes the extractor to mis-file concepts it has no good slot for. Instead, Pass 1 emits specific leaf tags zealously, and Pass 2 builds and normalizes the tree corpus-wide (leaf → canonical breadcrumb path), where the model can see the whole distribution and enforce homogeneity after the fact. Homogeneity remains the goal — achieved by post-hoc consolidation rather than up-front locking. memory.psych.missouri


3. The Node Schema: Revised for Episodic/Semantic Split

Given the above, here is the node structure adopted in spec v0.2. Note the refinements made during design review: description, categories, subject, and related_to were dropped; public was generalized to sensitivity; origin was added to separate stated knowledge from model inference (see below). The authoritative definition lives in specifications.md §3; this section explains the why.

Semantic node

---
memory_layer: semantic
type: fact | concept | procedure
title: "Informative micro-sentence (English)"
tags: [marlin, pid_tuning]        # flat leaf labels; tree maintained in Pass 2
timestamp: "YYYY-MM-DD"           # date first encountered, not creation date
sensitivity: public | private | confidential
confidence: low | medium | high
origin: stated | inferred
source_input: "{input_id}"
language: "fr"
---
Body in source language (may be empty for general public facts)

Episodic node

---
memory_layer: episodic
type: observation | decision | state
title: "Informative micro-sentence (English)"
tags: [ender_3, heating_failed]
timestamp: "YYYY-MM-DD"           # mandatory — episodic = time-bound
sensitivity: private | confidential   # never public: personal by definition
attributed_to: "speaker name"     # episodic only
confidence: low | medium | high
origin: stated | inferred
source_input: "{input_id}"
language: "fr"
valid_from: "YYYY-MM-DD"          # type: state only, optional
valid_to: "YYYY-MM-DD"            # type: state only, optional
---
Body in source language

The key differences in practice:

  • attributed_to is only on episodic nodes — semantic nodes are attribution-free by definition.
  • Episodic nodes are never sensitivity: public — personal events are not general knowledge.
  • valid_from / valid_to apply only to episodic type: state, and stay optional — the model guesses dates unreliably, so they are populated only when the source states a timeframe explicitly. superseded_by is drawn in Pass 2, not at extraction.
  • origin distinguishes knowledge stated in the input from knowledge the model inferred (tone, emotion, implied intent). It also disambiguates confidence: on stated nodes confidence measures the speaker's linguistic hedging; on inferred nodes it measures the model's certainty in its own inference. This is how the "reading between the lines" signal (§5, confidence discussion) is captured — as rare, explicitly-flagged inferred nodes rather than a noisy per-node tone field.
  • Relationships are not stored as related_to. Shared tags provide implicit links (Layer 1); only three rare, directional, Pass-2 edges are materialized: superseded_by, conflicts_with, derived_from. Query-time traversal by an LLM covers the rest.

4. Consolidation: The Missing Pass

The episodic → semantic consolidation is the step the current pipeline spec does not address, but which the literature suggests is the most valuable long-term operation. qorsync

A practical consolidation heuristic, grounded in the cognitive science:

An episodic node is a candidate for semantic promotion if the same proposition appears across N distinct conversations (N ≥ 3 is a reasonable threshold) and is not time-bound.

For example: if 5 conversations each contain an episodic node about preferring a particular project structure, those 5 nodes should consolidate into a single semantic node preferred_project_structure with confidence: high.

Zep / Graphiti implements this as a temporal KG with valid_from / valid_to and a periodic consolidation pass. The Biomorphic Temporal Memory Architecture (BTMA) proposes a hierarchical consolidation protocol: event → day → month → year, mirroring the hippocampal consolidation process. These are Phase 3 concerns for this project, but the schema should anticipate them: the source_conversation and timestamp fields on every node are what make this pass possible later without re-reading the raw conversations. emergentmind


5. Open Questions and What the Literature Says

How fine-grained should the ontology be?

There is no objective answer, and this is widely acknowledged in the literature. Semantic unit research argues that granularity should be determined by the intended query patterns — not by the structure of the source documents. For this project: L1 categories should map to the types of questions you expect to ask ("what do I know about 3d_printing?"), not to the structure of your conversations. pmc.ncbi.nlm.nih

Miller's work adds a practical constraint, but it applies at retrieval time, not at storage time. The project imposes no hard limit on nodes per tag — the store holds everything. However, a leaf tag that resolves to hundreds of nodes is not a usable chunk for an agent's context window. This is a Pass-2 / retrieval concern, addressed two ways: (a) the tree lets a query narrow from a broad root to a specific leaf, and (b) within a hot leaf, the multilingual vector search ranks and windows results. Granularity of the tree should therefore be driven by expected query patterns, and over-large leaves are a signal to split a branch in Pass 2 — not a cap enforced at extraction. labs.la.utexas

When does an episodic node become semantic?

The consolidation threshold is an open empirical question. Cognitive neuroscience suggests that repetition and emotional salience drive consolidation in humans. In a computational pipeline, repetition is tractable (count occurrences); salience is not directly measurable without additional signals. A proxy: use confidence: high on episodic nodes as a salience indicator, and lower the consolidation threshold for high-confidence nodes. psychstory.co

How to handle contradictions?

The literature on knowledge graph maintenance is clear: conflicting nodes should not be auto-resolved. The current spec handles this with conflicts_with — which is the right decision. What the literature adds is a recommendation to store the source and timestamp of each conflicting claim explicitly, so that temporal ordering can be used as a weak resolution signal (more recent = more likely current). This is already supported by the schema. pmc.ncbi.nlm.nih

Is tag-based retrieval sufficient long-term?

As a v0 baseline, yes. As the graph grows, the limitation becomes clear: tags group nodes by topic, but not by relationship. A query like "why did I decide to switch from X to Y" requires edge traversal across decision and justification nodes, not just tag lookup. This is the well-documented transition point from flat retrieval to graph traversal, and is the main motivation for the Option B edge construction described in the base architecture document. The tag-first approach is the right place to start — it validates the node extraction quality before investing in edge construction. en.wikipedia


Document v0.3 — July 2, 2026. v0.3: schema aligned with specifications.md v0.2 (dropped description/categories/subject/related_to; added origin/sensitivity; tags as flat leaves with tree maintained in Pass 2; no hard cap on nodes per tag). References: Tulving 1972; Miller 1956; AriGraph IJCAI 2025; Mnemosyne 2026; SKGE Zenodo 2026; Zep/Graphiti; semantic units (PubMed 2024).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment