VeriWiki Architecture

VeriWiki reframes an LLM-maintained Markdown knowledge base from a loose note folder into a deterministic four-stage epistemic compiler and context runtime.

extends llm-wiki supports incremental-merkle-compilation supports epistemic-contradiction-and-drift supports submodular-context-packaging compares agentic-knowledge-systems-2026

Diagnosed Failure Modes in Naive LLM Wikis and RAG

  • EXTRACTED: Silent Cascade Drift — When raw documents or foundational concepts are edited in a prompt-only LLM Wiki, downstream synthesis and comparison pages retain stale claims because no transitive Merkle dependency graph tracks provenance invalidation.
  • EXTRACTED: Hub Flood and Contradiction Blindness — Treating all [[wikilinks]] as uniform untyped edges causes generic navigation hubs to dominate 1-hop graph walks while conflicting polarity/numeric claims and uncollapsed superseded_by chains accumulate silently.
  • EXTRACTED: Redundant Top-K Context Collapse — Greedy top-K document concatenation wastes context budgets on overlapping introductory sections and emits unverified metadata rather than live-rebound SHA-256 spans.

Four-Stage Compiler Pipeline

Stage 1: Provenance-Bound Epistemic IR & Merkle Compiler

src/veriwiki/ir.py and src/veriwiki/compiler.py parse wiki/ Markdown files (under strict non-symlink physical confinement) into PageIR nodes with heading-scoped SectionSpan SHA-256 digests, structured ClaimRecord annotations (EXTRACTED, INFERRED, AMBIGUOUS, UNVERIFIED), and resolved TypedEdge relations. Tarjan Strongly Connected Components (SCC) condensation computes cycle-safe transitive merkle_sha256 hashes and topological dirty-propagation wavefronts (veriwiki compile --plan).

Stage 2: Epistemic Verification & Belief Lifecycle Engine

src/veriwiki/verifier.py enforces link/index/privacy boundary invariants alongside epistemic tension detection (signed supports/contradicts triangle audits, claim polarity divergence on shared entities, and supersession chain/cycle checks), Hub-Penalized Typed Personalized PageRank, and multi-source corroboration-weighted belief retention.

Stage 3: Submodular Budgeted Context Compiler

src/veriwiki/packager.py fuses field-weighted BM25F (title, tags, headings, claims, body) with Hub-Penalized Typed PPR, then optimizes heading-scoped excerpt selection via lazy-greedy monotone submodular coverage plus MMR redundancy penalization under (max_chars, max_source_chars) budgets, rebinding live SHA-256 digests into [W1..Wk] citations across L0–L3 progressive layers.

Stage 4: Protocol-Native Agent & Publishing Runtime

src/veriwiki/mcp_server.py serves 8 deterministic tools and 4 URI resources over zero-dependency JSON-RPC 2.0 stdio (Content-Length and NDJSON auto-detected), complemented by the veriwiki CLI, static codebase AST causal analysis (veriwiki codegraph), Obsidian vault export, and Quartz static publishing.

Counterpoints and Gaps

  • INFERRED: Static polarity and numeric tension heuristics catch structural inconsistencies deterministically with zero LLM cost, but subtle semantic contradictions phrased without lexical overlap still benefit from periodic agent-driven veriwiki verify review.
  • AMBIGUOUS: When a corpus scales past 50,000 pages, single-file JSON catalog storage should transition to an embedded SQLite/FTS5 backend while keeping Markdown files as the canonical Git source of truth.