Collapsed's KB layer has three components: KB Librarian (files candidate sources with S/A/B tier gate), KB Context Researcher (T0 cosine search + rerank), KB Field Researcher (autonomous deep-research). All stored in Supabase tables.
The V2-P1 spec deferred KB ('no KB / RAG, references stand-in'). With the substrate change to git-as-truth (ADR 0004), the KB needs a new home that doesn't reintroduce JSONB.
Karpathy published the 'LLM Wiki' gist on 2026-04-04 — a pattern for persistent, compounding LLM-maintained knowledge bases as an alternative to RAG. Within two weeks: 5,000+ stars. The fit with V2's design is exact.
The V2 KB implements Karpathy's LLM Wiki pattern as a per-teacher git repo, with the Task primitive + prompts handling all four verbs.
| Path | Layer | Purpose |
|---|---|---|
| kb/AGENTS.md | Schema | Defines page conventions, frontmatter, workflows |
| kb/index.md | Catalog | Link + 1-line summary per page |
| kb/pages/*.md | Wiki core | Mutable, LLM-authored knowledge pages |
| kb/sources/*.md | Raw sources | Immutable, markdown-converted |
| kb/media/ | Assets | Extracted/harvested images, diagrams |
| git history | Log (replaces Karpathy's log.md) | Chronological feed via git log |
| Karpathy verb | V2 prompt | Trigger |
|---|---|---|
| Ingest | kb/librarian.md | Teacher uploads source; or Field Researcher writes new page |
| Query | kb/context-researcher.md + kb/relevance-judge.md | Course sub-agent Task-invokes; teacher search |
| Lint | kb/linter.md | Periodic cron + on-demand |
| File-back | kb/librarian.md (chat-segment input) | Per-chat-resolution affordance |