G4: SPARQL theorem-backed end-to-end (program plan)#

Owner goal (2026-08-09, verbatim): "SPARQL theorem backed end to end: parser, expression eval, solution modifiers, filters, results.... Push F* theorems as far as they can go, giving us a solid basis for improvements, optimisations, indexing and persistent storage."

Starting point (see theorem registry §5 and the layer accounting that motivated this goal): BGP matching, join keys, dedup keys, planner reordering, index access, and the corerdfs entailment chain are theorem-backed on the shipping entry points. The unproved semantic surfaces in a response are the two edges — parsing in, serialization out — and the expression language + modifiers between.

Milestones (value order)#

Method#

proof-factory skill governs dispatch (closure-identity law, guard depth ≤3, brief anatomy, spray-and-verify economics, harvest pattern). Registry updated with every landing. No --lax, no admits. Findings discipline: refuted statements become machine-checked counterexample rows, as in G3.

G1 fold-in (owner decision)#

Owner, 2026-08-09, on folding the G1 review-kernel remainder into M5: "Yes fold it in." M5 therefore delivers BOTH the composed response-level theorems AND the curated review kernel (the minimal set of spec predicates + theorem statements a W3C expert can read end-to-end, with the guarantee nothing outside it overrides what it states) — assembled at the same time because composition is when the kernel's contents become final. Task #38's kernel item transfers to task #46/M5; the G2 remainder (claims block, npm batch) stays in task #40.

Fast-path re-founding constraints (owner steer, 2026-08-10, verbatim)#

"Refound migration - the mention of ocaml scares me as earlier Claudes slipped into writing everything in ocaml, and it took weeks to recover. This cannot be that again. Also, we need practical performant parsers (memory, speed, streaming; error recovery from realworld data flaws"

Binding constraints on the FastString migration and all parser work:

  1. ACCEPTANCE CRITERION: every semantic decision has an extracted F* definition as its source; anything OCaml is substitutable, equivalence-gated (rule 11(b) Option-B), and deletable. The migration REMOVES hand-written OCaml semantics (patch 89's realised assume vals); optimized OCaml returns only if benchmarks demand it.
  2. Benchmark-gated at every step (parser throughput harness, perf-benchmarking discipline) — no perf regressions on faith.
  3. Streaming: N-Quads chunk-fold with bounded carry; streaming==batch as a theorem; line-based formats first.
  4. Error recovery as proof targets: strict mode = position-carrying errors; lenient mode = resync-point skip with recovery-soundness theorems (every emitted triple grammatical, every skip reported with position, silent drops impossible — retires the #334/#344 bug class by construction).