OKF Graph Wiki — Agent-Maintained Knowledge Graph for Context Retrieval A developer has built an agent-maintained knowledge graph wiki using the Open Knowledge Format (OKF), extending Andrej Karpathy's LLM Wiki pattern. The system compiles typed subject-predicate-object triples into a SQLite index for fast, deterministic retrieval, prioritizing context assembly for LLM queries over human browsing. The project includes a TypeScript/SQLite reference implementation and an implementation spec. I've been running Andrej Karpathy's LLM Wiki https://gist.github.com/karpathy/442a6bf555914893e9891c11519de94f pattern for several months — reading sources, compiling them into a compounding, git-diffable wiki instead of re-deriving everything from scratch every session — and I'm a genuine convert. But two things kept nagging at me: query salience finding the right page reliably, not just something plausible and token economy not re-reading half the wiki to answer one question . The missing piece turned out to be the Open Knowledge Format https://github.com/GoogleCloudPlatform/knowledge-catalog/blob/main/okf/SPEC.md OKF : structured YAML frontmatter an agent can use to record the graph it's already implicitly building in prose, as typed subject–predicate–object triples rather than untyped markdown links. To keep retrieval fast and deterministic — not another LLM call on every question — that frontmatter compiles into a disposable SQLite index. What follows specs that redesign for someone to actually build — an implementation spec , not a blog post, where every section states what to build rather than just the idea. It ships with a working TypeScript/SQLite reference implementation Appendix and pitfalls validated by building and running it, not guessed at §10 . The original gist frames the wiki as a human-browsable, compounding artifact: an agent reads sources, updates markdown pages, a person reads the results in Obsidian. That's still true here, but it is not the primary purpose of this version . The primary purpose is: given a question posed to an LLM, retrieve and assemble the right slice of the graph into that LLM's context window. Human browsing is a secondary, free side benefit of keeping everything as linked markdown. Every design decision below is made in service of the retrieval goal first. Concretely, that reframing changed three things versus the original gist: the file format is now OKF structured provenance/trust/lifecycle fields, not just prose , relationships are typed subject-predicate-object triples in frontmatter not just untyped markdown links , and there is a retrieval pipeline spec section 6 that did not exist in the original idea at all. - Maintain a persistent, compounding knowledge base as a directory of plain markdown files, agent-written and agent-maintained. - Represent facts as typed, sourced, subject-predicate-object triples that a query engine can traverse, not just prose an LLM re-reads from scratch each time. - At question time, retrieve a bounded, relevance-ranked, trust-ranked set of facts and background prose that fits a context budget — this is the deliverable, not an afterthought. - Stay diffable, portable, and toolable: git-diffable markdown as the only source of truth; every other artifact SQLite index, timeline.md , index.md entries is a regenerable build product, never hand-edited. Not a general agent-memory system. This is not session memory, preference tracking, or conversational recall — see §9.3 for why an existing tool in that space mnemon-dev/mnemon was evaluated and rejected as the storage engine. Not a fixed ontology. No upfront RDF/OWL schema. Both OKF's type and this spec's predicate vocabulary are open and grow by convention, documented as they're coined §8 . Not a graph database. SQLite with JSON1 functions is sufficient at the scale this pattern is meant for hundreds to low thousands of concepts ; this spec does not call for Neo4j or similar. Considered a fourth layer, router.md a hand-curated dispatch table from question domain to subdirectory , and dropped it: context for §6 queries the whole bundle in one hybrid-retrieval pass and doesn't benefit from a coarse pre-filter, and the one audience that would have needed file-based dispatch — a human browsing the vault in Obsidian — already has direct SQL access to wiki.db , either via Datasette or a Obsidian SQLite-query plugin SQLite Explorer, SQLite DB, and similar all support embedding live query results in a note . The only scenario where a router file would still earn its keep is an agent given pure filesystem read access with no shell or SQL tool at all; not designed for by default. bundle/ CLAUDE.md / AGENTS.md schema doc: conventions, predicate vocabulary, ingest rules wiki.db SQLite index, regenerated from frontmatter, gitignored or snapshotted log.md OKF-native edit history when the wiki changed timeline.md world-event chronology when things happened , regenerated wiki-trigger-keywords.txt concept titles + tags, regenerated — optional harness-hook pre-filter §12 entities/ index.md OKF-native per-directory catalog