Pruvo

A spec you can trust, then a parser proven against it.

Pruvo is a formally specified, machine-checked XML parser in Rust, and a repeatable method for building trustworthy specifications. XML is the test case. The method is the point.

Phase 1 · executable spec started · not usable yet

The scarce part

AI agents have made code and proofs cheap. You can ask for a parser and get one in minutes. But a proof only shows the code matches a spec. If the spec is wrong, the proof proves the wrong thing. The scarce part is a specification you can trust.

Cheap now

  • code
  • proofs
  • tests
  • lemmas
  • parsers
  • invariants
  • code
  • proofs

Scarce

A specification document with a seal of trust

A specification you can trust

How it works

Think of the W3C XML standard as a rulebook written in English. Pruvo rewrites the rulebook as an executable spec: code that can act as the referee, or oracle, for any document. Then it does two things with that referee.

How Pruvo builds and uses the executable specThe W3C text is written as an executable spec. The spec is checked against the W3C conformance suite and three reference parsers, with every disagreement recorded in the ledger. The parser is proven to agree with the spec on every input.W3C textthe rulebook, in Englishwritten asExecutable specthe referee (oracle)check the refereeW3C conformance suitelibxml2 · expat · Xerces-Cdifferential fuzzingevery disagreementValidation ledgerprove the parserRust parsermachine-checked proofssame answer as the specfor every inputVerified parser

Testing checks the inputs you thought of. A proof covers every input. The ledger is what makes the proof worth having, because it shows the spec matches reality.

Four things that hold together

The project is proven out when all four of these exist and hold together.

  1. 1 Executable spec

    The W3C rules for XML, rewritten as code anyone can run as an oracle.

    XML 1.0 (Fifth Edition) + Namespaces, in Verus
  2. 2 Validation ledger

    Proof the spec says the right thing: it is checked against the test suite and three real parsers.

    W3C suite · libxml2 · expat · Xerces-C
  3. 3 Verified parser

    A fast Rust parser with machine-checked proofs that it gives the same answer as the spec.

    Safe Rust only · checked by cargo verus verify
  4. 4 Drop-in demo

    A libxml2-compatible C API, so existing software can try it without rewriting anything.

    Target: the lxml test suite

Then the method itself, the workflow and the tooling, gets documented and applied to a second format to show it generalizes.

Every disagreement gets a verdict

When the spec and a real parser disagree, someone is wrong. Pruvo writes the case down and gives it exactly one classification. Majority vote is not the rule; the W3C text is.

Ledger 0001

Is <a:b/> a valid name?

  • pruvo-specaccept
  • libxml2 2.15.4reject
  • expat 2.11.0accept
CONFIG

Both answers follow the rules, in different modes. Plain XML 1.0 allows : in a name; namespace processing rejects an undeclared prefix. libxml2 always applies namespace rules, and the spec has no namespace layer yet.

  • SPEC-BUGOur spec is wrong
  • IMPL-BUG:<lib>A reference library is wrong per the W3C text
  • STD-AMBIGUITYThe W3C text supports more than one reading
  • SUITE-BUGThe test suite's expectation is wrong
  • CONFIGA library option or default, not semantics
  • OUT-OF-SCOPEInvolves an excluded feature

What gets proven

Each property is a theorem that Verus checks by machine. A proof counts only if Verus accepts it.

  • T1 Memory safety

    No out-of-bounds reads or overflows.

  • T2 No panics

    Every path is proven panic-free.

  • T3 Termination

    Every loop and recursion ends.

  • T4 Bounded resources

    Work and output stay within a budget, even under entity expansion.

  • T5 Soundness

    If the parser accepts a document, the spec accepts it with the same tree.

  • T6 Completeness

    If the spec accepts a document within budget, the parser does too.

  • T7 Error agreement

    If the spec rejects with a rule, the parser rejects.

  • T8 Spec ↔ reality

    Not provable. Established by the ledger instead.

T5 + T6 are the headline: for every input, not just tested ones, the parser's output equals the spec's.

Safe by construction

Every parse ends in one of three outcomes, and the spec says which. Nothing falls through the cracks: anything out of scope produces a defined, spec-level rejection, never undefined behavior.

input bytes
  • Ok(tree)A well-formed document and its tree
  • NotWellFormed(rule_id)Rejected, naming the rule that failed
  • ResourceLimit(kind)Stopped by the expansion budget
Billion laughs

Entity expansion has a budget in the spec's result type, so it returns ResourceLimit. Safety becomes a theorem instead of a heuristic.

XXE

External entities and external DTDs are rejected by default.

Roadmap

  1. G0 Week 1

    Proof stack decided, references pinned, CI green

  2. G1 Week 5

    Executable spec complete for v1 scope

    You are here
  3. M2 Week ~10

    Spec + validation ledger published

  4. G3 Week ~20

    Verified parser (soundness + completeness against the spec)

  5. G4 Week ~26

    Drop-in demo, benchmarks, continuous fuzzing

  6. Method Week ~30

    Method guide + second format

Open source · MIT

Follow along on GitHub

The spec, the oracle harness and the ledger are all in the repo. So far only Char, Name and one well-formedness constraint are specified. The full plan is in docs/plan.md, and every external version is pinned in PINS.md.

cargo test --workspace
thepolytheist/pruvo View on GitHub →