Skip to main content
Back to Projects

MEV - State & Graph Compiler for the Company Brain

Rust CLI that validates a multi-repo knowledge corpus and compiles its derived views — planning state, the cross-repo block graph, and machine-readable output the RAG indexer gates on.

RustStatic AnalysisKnowledge GraphCompilersMarkdownDeveloper Tooling

Overview

MEV started as a Markdown validator and became the write half of the company brain. It reads a corpus of Markdown and MDX spread across nineteen repositories, validates it along five independent axes — OKF frontmatter structure, `[[wikilink]]` and file reference integrity, the `scope:doc_id` knowledge graph, each repo's planning-state schema, and bidirectional `index.md` coverage — and then compiles what it read into derived views that other tools consume. The compiler half is the interesting part. `emit-state` is a fixed-point compiler: it resolves cross-repo planning state — block statuses, dependency edges, epic membership — until the output stops changing, then splices generated tables back into the Markdown documents that describe them. That means a roadmap's sequence table is not hand-maintained prose that drifts; it is compiled output, regenerated from the same `state.json` files the boards read. `emit-graph` and `emit-block-graph` emit the knowledge graph and the corpus-wide block-dependency graph as JSON artifacts for downstream consumers. Because the output is machine-readable (`--json` on every validation path, with a non-zero exit on any error-severity diagnostic), MEV works as a gate rather than a report. The RAG indexer refuses to rebuild against a corpus that fails validation, and the push hook blocks on errors new since the last successful push — so a broken cross-reference is caught at the moment it is introduced rather than discovered later by a reader. The design constraint throughout is that a validator nobody trusts gets disabled. Every check is scoped so it reports only what it can prove, and the diagnostics name the file, the line, and the rule.

Technical Stack

Core

  • ▸Rust
  • ▸clap
  • ▸serde
  • ▸okf-core (path dependency)

Validation

  • ▸OKF frontmatter
  • ▸Wikilink resolution
  • ▸Knowledge-graph integrity
  • ▸State schema
  • ▸index.md coverage

Compilation

  • ▸emit-state (fixed point)
  • ▸emit-graph
  • ▸emit-block-graph
  • ▸Sentinel splicing

Testing

  • ▸cargo nextest
  • ▸Golden-file regression tests

Key Features

✓

Five independent validation axes — frontmatter structure, link integrity, knowledge graph, planning-state schema, and index coverage

✓

`emit-state` fixed-point compiler resolves cross-repo planning state until the output stops changing

✓

Generated tables are spliced back into the documents that describe them, so roadmaps compile rather than drift

✓

`emit-graph` and `emit-block-graph` emit the knowledge and block-dependency graphs as JSON artifacts

✓

Machine-readable `--json` on every path, with a non-zero exit on any error-severity diagnostic

✓

Works as a gate: the RAG indexer refuses to rebuild against a corpus that fails validation

✓

Epic lifecycle commands (defer, resume, complete, sync) reconcile registry status against member blocks in both directions

✓

Every diagnostic names the file, the line, and the rule — a validator nobody trusts gets disabled

Technical Challenges

▪

Making `emit-state` converge: naive regeneration can oscillate when two derived views reference each other

▪

Splicing generated content into hand-written Markdown without clobbering the prose around it

▪

Scoping each check so it reports only what it can prove — a false positive costs more trust than a missed error

▪

Validating a corpus spread across nineteen repositories where every planning directory is a symlink

Project Outcomes

Machine-readable validation output via `validate-brain --json`
Corpus gate
`emit-state` fixed-point compiler, covered by a dedicated D7 regression test
State compiler
5 — structure, links, graph, state, index coverage
Validation axes
901 test-function declarations across 54 files (declaration count, not a pass/fail run)
Tests