Skip to content

Plan, apply and roll back changes to a production ontology, with a blast radius report and a proof an auditor can re-check.

Merge remote-tracking branch 'origin/main' into institution-comorphisms

FABIOTESS6777ac4d09ef
diff --cc docs/trusted-computing-base.md
index e1d79fac,167cfc68..2129b9da
--- a/docs/trusted-computing-base.md
+++ b/docs/trusted-computing-base.md
@@@ -340,82 -436,72 +436,88 @@@ central guard is the fix; the property
## What is still trusted after all of this
- This is the part that matters, and it is longer than the part that is checked. Nothing below is
- verified. Each entry says what would close it.
-
- 1. **`oxrdf`'s escaping is the entire escaping layer.** `asserted.tsv` is safe because
- `print_quoted_str` turns a tab inside a literal into `\t`. This repository has no escaper of its
- own and never inspects a term. TCB-4 pins the behaviour a test can observe, which means an
- upgrade that changed it would fail loudly; it does not mean it cannot change, and it does not
- cover a term that reaches the store by a route the tests do not exercise.
- *To close it:* escape at the certificate writer rather than relying on the term's `Display`, or
- change the format to one that cannot be forged by its payload (length-prefixed, or JSON Lines).
- Both are changes to `lean/`'s parsers as well, which is why neither was done here.
- 2. **`oxiri`'s IRI validation is why a separator cannot reach an IRI.** `NamedNodeRef`'s `Display`
- is `write!(f, "<{}>", self.as_str())` with no escaping at all, so the only thing standing between
- a tab and `asserted.tsv` is that the parser refused to build the IRI. Tens of thousands of lines
- of parsing sit behind that sentence and none of it is verified here.
- *To close it:* check the term at the writer, as in (1). The check is four lines; the reason it is
- not there is that it would be a second place the question is decided.
- 3. **TCB-14, the premise ORDER per rule.** `OOCert.checkStep` matches premises positionally, arm by
- arm, and the emitter passes them in a hand-written order at thirty-one call sites. The two agree
- because `tests/lean_certificate_test.rs` walks every rule and the checker accepts. Nothing
- derives one from the other, so a rule added with the wrong order fails at the checker rather than
- at compile time. *To close it:* generate both sides from one table, which is what the Horn path
- already does and the built-in path does not.
- 4. **TCB-26, the DL name guard's coverage.** `name_is_safe` is applied to a `names` vector built by
- one loop; the files are written by another. Individuals in `model.ind` are covered only because
- `DlAxiom::Indiv(i)` happens to be emitted for every individual that reaches the model.
- *To close it:* check at the point of writing, not in a separate pass.
- 5. **TCB-8 across runs.** Materialising into the default graph turns an inference into the next
- run's assertion, and `asserted.tsv` has no column that says "derived". `inference_graph: true`
- does not fix it either: `GraphStore::all_triples` reads every named graph, so a later certified
- run sees them as assertions. The separation protects `save`; it does not protect the certificate.
- *To close it:* have the certified path read the asserted graph only, and say in the certificate
- which graphs it read.
- 6. **Materialisation is not atomic, and that is now latent rather than fixed.** `GraphStore::
- load_lines` runs `for quad in parser { store.insert(&quad?)?; }`, so a parse error partway
- through a batch leaves everything before it inserted and propagates the error. That is what
- turned the `rdfs7` defect from a crash into uncertified triples in the store. `writable_triple`
- removes the only way the reasoner could hand it an unparseable line, so the path is unreachable
- TODAY; the hazard is still there for any future caller.
+ This is the part that matters. Nothing below is verified. Each entry says what would close it. It
+ was ten entries on 14 September 2026 and it is six, because four of them were closed rather than
+ re-worded: the two that rested on `oxrdf` and `oxiri`, the premise order, and the DL name guard's
+ coverage.
+
+ 1. **TCB-6 and TCB-7, that `asserted.tsv` IS the store's contents.** The engine reads the store,
+ interns what it reads, and writes the interned strings back out. Nothing between the store and
+ the file checks that the file is the store. `tests/certificate_boundary_proptest.rs` re-reads
+ `asserted.tsv` through the N-Triples parser into a fresh store and compares the two, over
+ adversarial graphs, which is the strongest thing a test can do here and is not a proof. This is
+ the unsafe direction: an extra line is an axiom nobody asserted, and every conclusion resting on
+ it is certified against a graph that does not exist.
+ *To close it:* nothing pure-functional reaches it. It is a statement about an execution over a
+ store, so it needs either a verified store or a checker that can see the store, and neither
+ exists.
+ 2. **TCB-10, that `derivations.tsv` covers every triple the run added.** A triple materialised
+ without a line covering it sits in the store under the certificate's cover. The argument is that
+ the single `emit` closure is the only path that pushes a candidate and records the first
+ derivation of anything not already in the closure. That argument is now shorter than it was,
+ because `emit` computes the conclusion from the rule table rather than taking one from the call
+ site, so a site cannot push a triple the table does not license. It is still a reading of a loop
+ plus a property test comparing conclusions against the store's before and after.
+ *To close it:* the same obstacle as (1). It is a property of the run, not of a function.
+ 3. **TCB-19 and TCB-21, that the two rule-table parsers agree.** `parse_rules` in Rust and
+ `OOCert.HornParse.parseRules` in Lean are independent implementations of one grammar. The
+ property test runs against a transcription of the Lean parser, and one deterministic test puts
+ the adversarial shapes through `oo-horn check` itself. Measurement, not proof. TCB-18 and TCB-20
+ are closed around it, because the engine re-parses what it wrote and refuses on mismatch and
+ `pat_of`/`render` are proved inverse, so what is left is exactly the cross-language half.
+ *To close it:* generate both parsers from one grammar, or verify the Rust one against the Lean
+ one as a refinement. Neither was done here.
+ 4. **TCB-8 under `InferenceTarget::DefaultGraph`.** Merging conclusions into the default graph is
+ what the caller asked for and it loses the distinction; a later certified run over that store is
+ conditional on a graph that includes inferences. The named-graph path no longer has this problem.
+ *To close it:* there is nothing to close in this layer. The caller chooses, and
+ `inference_graph: true` is the choice that keeps the certificate honest.
+ 5. **Materialisation is not atomic, and that is latent rather than fixed.** `GraphStore::load_lines`
+ runs `for quad in parser { store.insert(&quad?)?; }`, so a parse error partway through a batch
+ leaves everything before it inserted and propagates the error. That is what turned the `rdfs7`
+ defect from a crash into uncertified triples in the store. `writable_triple` removes the only way
+ the reasoner could hand it an unparseable line, so the path is unreachable TODAY; the hazard is
+ still there for any future caller.
*To close it:* insert into a transaction, or build the batch through a serialiser that cannot
produce an unparseable line rather than through string concatenation.
- 7. **The reasoner's completeness.** The checker proves each recorded step is a sound instance of a
- rule it knows. It says nothing about whether the engine found every inference, so a certificate
- is evidence about what was derived and not about what follows.
- 8. **The SHIQ tableaux reasoner.** Model certificates cover positive satisfiability answers only.
- Unsatisfiability and inconsistency carry no certificate at all, and those are the answers a
- consistency check is usually asked for.
- 9. **The Rust SHACL validator (TCB-28, TCB-29).** Not certified. `oo-shacl` is a second, verified
- evaluator that the Rust one is measured against; a measurement is not a proof, and the two read
- RDF with two different parsers whose agreement is by construction on both sides rather than by a
- check.
- 10. **Everything between the store and the certificate that is not a term:** the SPARQL layer, the
- MCP server, the CLI, the daemon, the file I/O, the roughly fifty thousand lines of `src/`. The
- Kani harnesses cover four pure functions totalling about twenty lines. That is the correct
- proportion to report: this work verified the joint, not the machine.
+ 6. **Everything that is not the certificate boundary at all.** The reasoner's COMPLETENESS: the
+ checker proves each recorded step is a sound instance of a rule it knows and says nothing about
+ whether the engine found every inference, so a certificate is evidence about what was derived and
+ not about what follows. The SHIQ tableaux reasoner: model certificates cover positive
+ satisfiability answers only, and unsatisfiability and inconsistency carry no certificate at all.
+ The Rust SHACL validator (TCB-28, TCB-29): not certified, measured against a second verified
+ evaluator, and the two read RDF with two different parsers whose agreement is by construction on
+ both sides rather than by a check. And the SPARQL layer, the MCP server, the CLI, the daemon, the
+ file I/O, the roughly fifty thousand lines of `src/`. The Kani harnesses cover five pure
+ functions totalling about sixty lines. That is the correct proportion to report: this work
+ verified the joint, not the machine.
+## What the institution layer does not move
+
+`lean/OOCert/Institution.lean` and the four modules with it prove that two translations between
+logics satisfy their satisfaction conditions, and decision 0009 says what that buys. It buys nothing
+on this page, and the reason is worth stating because the two things sound alike.
+
+The comorphism proved in `lean/OOCert/InstitutionFol.lean` runs between two LEAN developments: the
+RDF interpretations of `OOCert/Semantics.lean` and the first-order structures of
+`Fol/Semantics.lean`. It is not `src/tptp.rs`'s translation and says nothing about it. Decision 0005
+item 2 is unchanged: the correspondence between the Rust emitter and the Lean translation is pinned
+by hand-computed tests and is not proved, and the emitted file still says so.
+
+The layer has no run-time part at all. It writes no file, reads no file, produces no certificate and
+no verdict word, and no executable imports it, which is why it is a separate `lean_lib` from
+`OOCert`. Nothing in the property list above changes, no `TCB-*` identifier is retired, and the
+count of trusted properties is what it was.
-
- The honest summary is that the trusted base is four things: the serialisation of a term, the
+ The honest summary is that the trusted base used to be four things: the serialisation of a term, the
identity of the asserted graph, the completeness of the derivation record, and the identity of the
- rule table. Those are now property-tested and, for the pure parts, bounded-model-checked. Every one
- of them still rests on a dependency's behaviour that this repository observes rather than enforces.
- The engine is not verified. It was never going to be, and a report that read as though it were
- would be the same defect this project exists to attack.
+ rule table. The serialisation of a term is no longer one of them: it is enforced here and proved
+ over every byte pattern at the bounds below, rather than observed of a dependency. The identity of
+ the rule table is most of the way off the list: the engine re-parses what it wrote and refuses on
+ mismatch, and the render-parse round trip is proved; what is left is two independent parsers of one
+ grammar, which is a different kind of risk from an engine misreporting its own run.
+
+ **So it is two things.** That `asserted.tsv` is the graph the engine reasoned over, and that
+ `derivations.tsv` covers every triple it added. Both are statements about an execution rather than
+ about a function, which is why no amount of bounded model checking reaches them, and both are
+ property-tested end to end against the store. The engine is not verified. It was never going to be,
+ and a report that read as though it were would be the same defect this project exists to attack.