graph/ — the content graph¶
The content graph: structural, agent and behavioural edges, the vectors beside them in Postgres, and the retrieval built on them.
Entities, edges and vectors in Postgres (note §5), and the retrieval built on them.
- Structural edges come free. On every publish,
index_pagerebuilds the page'schild_of,references(Wagtail'sReferenceIndex: chooser blocks, foreign keys),links_to(Markdown links and Obsidian wikilinks resolved by permalink, URL or source path),tagged/in_category(topic entities) andtranslation_ofedges. They are derived, so they are replaced, never edited. - Agent edges (
mentions,about,similar_to,contradicts,supersedes) come fromgraph.upsert_edge: written directly only at or aboveGRAPH_EDGE_AUTO_THRESHOLD(0.85) under adraft-or-higher policy, otherwise a Suggestion. - Behavioural edges come from Rails'
app.user.interactionevents, aggregated into daily counts as they arrive (no reader identifier is stored) and turned intoviewed_togetheredges nightly (build_viewed_together). - Vectors live in one table,
Embedding, for every kind of object, keyed by(object, model)and stamped with thecontent_hashthey were computed from; a page whose hash did not change is not re-embedded.EmbeddingFieldis pgvector'svectoron Postgres and JSON text on SQLite; kNN uses<=>on Postgres and computes cosine in Python elsewhere. The default embedder (hashing-256) is deterministic feature hashing, so everything works offline;EMBEDDING_BACKEND=litellmswaps in a real model, through the provider registry (ai/providers/).
Reading: related(page) merges vector neighbours (0.6) with one hop of edges and shared topics (0.4); semantic_search, neighbors (≤ 2 hops), path (≤ 4) and graph_rag (search → expand → rerank). GraphQL exposes related, semanticSearch, graphSearch and entities; REST exposes /api/v2/graph/{neighbors,path,related,search}/; agents get graph.* tools.