Plan, apply and roll back changes to a production ontology, with a blast radius report and a proof an auditor can re-check.
Rust ai-nativedescription-logicsformal-verificationinfrastructure-as-codeisabelle-languageknowledge-graphleanlean4mcpmcp-serverontologyowlowl2reasoningrustshaclsparqltheorem-proving
One number, one decision, and every decision in the index (#190)
Fabio Rovaie6a879913256
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 9a161c56..eb796c32 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -368,7 +368,7 @@ All notable changes to Open Ontologies are documented here.an antichain, and a truncated run withdraws the claim that they are minimal supports. 35 testsin `tests/justify_test.rs` and `tests/provenance_test.rs`, every fixture small enough that theanswer is known on paper. See- [decision 0009](docs/decisions/0009-a-conclusion-names-the-axioms-responsible-for-it.md) and+ [decision 0009](docs/decisions/0016-a-conclusion-names-the-axioms-responsible-for-it.md) anddocs/explanation.md.- **Common Logic has three dialects and this engine emitted one, so `fol --format cgif` writes asecond.** ISO/IEC 24707 defines CLIF, CGIF and XCL, and ISO/IEC 21838-1 clause 4.3 names alldiff --git a/docs/decisions/0009-a-conclusion-names-the-axioms-responsible-for-it.md b/docs/decisions/0016-a-conclusion-names-the-axioms-responsible-for-it.mdsimilarity index 99%rename from docs/decisions/0009-a-conclusion-names-the-axioms-responsible-for-it.mdrename to docs/decisions/0016-a-conclusion-names-the-axioms-responsible-for-it.mdindex 3b255d6b..1da53e1f 100644--- a/docs/decisions/0009-a-conclusion-names-the-axioms-responsible-for-it.md+++ b/docs/decisions/0016-a-conclusion-names-the-axioms-responsible-for-it.md@@ -1,4 +1,4 @@-# 0009 · A conclusion names the axioms responsible for it, and minimality is re-run+# 0016 · A conclusion names the axioms responsible for it, and minimality is re-run- **Status**: implemented · `src/justify.rs`, `src/provenance.rs`,`Reasoner::derivation_graph` · `onto_justify`, `onto_provenance` ·diff --git a/docs/decisions/README.md b/docs/decisions/README.mdindex ca263ee9..957ca542 100644--- a/docs/decisions/README.md+++ b/docs/decisions/README.md@@ -12,17 +12,27 @@ and whose benefit is not gets dropped the first time it is inconvenient.| [0006](0006-a-model-is-a-certificate-and-a-refutation-is-not.md) | A model is a certificate, and a refutation is not | Treating an exhausted bounded search as unsatisfiability || [0007](0007-a-slice-preserves-a-conclusion-or-it-does-not.md) | A slice preserves a conclusion, or it does not | A retrieval slice quietly dropping the conclusion it was asked about || [0008](0008-a-binding-is-data-and-evidence-admits-one-reading.md) | A binding is data, and evidence admits one reading | A certificate format admitting two readings, so two checkers disagree |+| [0009](0009-a-translation-between-logics-carries-its-satisfaction-condition.md) | A translation between logics carries its satisfaction condition | Moving a sentence between logics and assuming the truth came with it |+| [0010](0010-the-input-is-a-value-and-not-a-store.md) | The input is a value and not a store | Certifying a run against a store that can change under it |+| [0011](0011-a-module-carries-a-theorem-and-a-slice-carries-a-measurement.md) | A module carries a theorem, a slice carries a measurement | Reading a measured slice as though it carried the theorem a module does || [0012](0012-concurrency-lives-below-the-certificate.md) | Concurrency lives below the certificate, and a proof cannot follow it there | Adopting a program logic for a hazard that lives in a dependency, and calling the result assurance || [0014](0014-a-verifier-that-cannot-read-the-code-verifies-a-rewrite.md) | A verifier that cannot read the code verifies a rewrite | Counting a green verifier as evidence about code it never read || [0015](0015-a-blank-line-is-a-line-or-it-is-not.md) | A blank line is a line, or it is not, and the format never said which | The same failure again, found by a third kernel and still OPEN: two checkers reading one file differently because nobody wrote down what an empty line is |+| [0016](0016-a-conclusion-names-the-axioms-responsible-for-it.md) | A conclusion names the axioms responsible for it, and minimality is re-run | Presenting a justification as minimal when nothing re-ran it |There is no 0004. The decision now numbered 0006 was drafted as 0004 on a branch that never merged,so the number never reached `main`. It is left as a hole rather than reused, because a reused numbermakes an old citation silently come to mean something else.-This table has rows for 0009 to 0011 missing rather than absent. Those records exist in this-directory, there are two numbered 0009, and nobody has written their rows. The gap is recorded here-so that a reader does not conclude from the jump that the numbers were skipped the way 0004 was.+Every record in this directory has a row above, and `tests/decision_numbers_test.rs` fails if that+stops being true, if two records take one number, or if a row points at a file that does not exist.++There used to be two records numbered 0009, written in parallel on branches that could not see each+other. Git does not catch that: the filenames differ, so both merge cleanly and the index gets a+plausible row from each. The later of the two, on justification, is now 0016. It moved rather than+the earlier one because a citation should keep meaning what it meant, and the earlier record had+been on `main` longer. The same collision then happened three more times in one day between+parallel branches, which is why the check exists rather than a note asking people to be careful.## What this discipline has caughtdiff --git a/docs/lean-certificates.md b/docs/lean-certificates.mdindex 3f82bd11..10649f0b 100644--- a/docs/lean-certificates.md+++ b/docs/lean-certificates.md@@ -97,7 +97,7 @@ explanation built from it would be specific, confident and false.`onto_justify` and `onto_provenance` therefore ask the reasoner for every applicable ground ruleinstance instead, and never open the file. See [docs/explanation.md](explanation.md) and-[decision 0009](decisions/0009-a-conclusion-names-the-axioms-responsible-for-it.md). What the+[decision 0009](decisions/0016-a-conclusion-names-the-axioms-responsible-for-it.md). What thecertificate IS enough for, those tools use: with `certificate_dir`, each justification gets its owncertified run over its own triples, so `oo-cert` can verify that the conclusion really does followfrom that subset. Minimality is not in the theorem and is re-run instead.diff --git a/tests/decision_numbers_test.rs b/tests/decision_numbers_test.rsnew file mode 100644index 00000000..fd74a37e--- /dev/null+++ b/tests/decision_numbers_test.rs@@ -0,0 +1,112 @@+//! **Issue #185.** One number, one decision, and every decision in the index.+//!+//! `docs/decisions/` numbers records in their filename and nothing checked the+//! number was unique. Two records numbered 0009 sat on `main` for days, and in+//! a single day three more collisions happened between branches running in+//! parallel: 0013 twice and 0012 once.+//!+//! **Review does not catch this.** The filenames differ, so git sees two+//! unrelated new files and merges both cleanly. There is no conflict, no+//! failing test, and nothing in either diff that looks wrong. The index gets a+//! row from each, so even the index reads plausibly. One of those collisions+//! was committed and pushed by the person who filed the issue describing it,+//! which is a fair measure of how little a filename collision announces+//! itself.+//!+//! A reused number is worse than a missing one: an old citation silently comes+//! to mean something else. That is why 0004 is a hole rather than a number+//! waiting to be filled, and why the later of the two 0009 records moved to+//! 0016 instead of the earlier one moving.++use std::collections::BTreeMap;+use std::path::PathBuf;++fn decisions_dir() -> PathBuf {+ PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("docs").join("decisions")+}++/// Every record file, as (number, filename). `README.md` is the index and is+/// not a record.+fn records() -> Vec<(String, String)> {+ let mut out = Vec::new();+ for entry in std::fs::read_dir(decisions_dir()).expect("read docs/decisions") {+ let name = entry.expect("dir entry").file_name().to_string_lossy().to_string();+ if !name.ends_with(".md") || name == "README.md" {+ continue;+ }+ let digits: String = name.chars().take_while(|c| c.is_ascii_digit()).collect();+ assert_eq!(+ digits.len(),+ 4,+ "a decision record must start with four digits, and {name} does not. Without that \+ the number cannot be read, so neither this check nor a reader can tell which \+ decision it is"+ );+ out.push((digits, name));+ }+ out.sort();+ assert!(out.len() > 5, "only {} records found; the scan is not running", out.len());+ out+}++#[test]+fn no_two_decisions_take_the_same_number() {+ let mut by_number: BTreeMap<String, Vec<String>> = BTreeMap::new();+ for (n, name) in records() {+ by_number.entry(n).or_default().push(name);+ }+ let clashes: Vec<String> = by_number+ .iter()+ .filter(|(_, files)| files.len() > 1)+ .map(|(n, files)| format!("{n}: {}", files.join(" and ")))+ .collect();+ assert!(+ clashes.is_empty(),+ "{} number(s) name more than one decision:\n {}\n\nGit will not have flagged this: the \+ filenames differ, so both merged cleanly. Renumber the LATER record to the next free \+ number and move every reference with it. Do not reuse 0004, which is a deliberate hole.",+ clashes.len(),+ clashes.join("\n ")+ );+}++#[test]+fn every_decision_has_a_row_in_the_index_and_every_row_resolves() {+ let index = std::fs::read_to_string(decisions_dir().join("README.md")).expect("read index");++ // Rows are markdown links to a file in this directory.+ let mut linked: Vec<String> = Vec::new();+ let mut rest = index.as_str();+ while let Some(i) = rest.find("](") {+ let after = &rest[i + 2..];+ if let Some(j) = after.find(')') {+ let target = &after[..j];+ if target.ends_with(".md") && !target.contains('/') {+ linked.push(target.to_string());+ }+ }+ rest = &rest[i + 2..];+ }+ assert!(!linked.is_empty(), "the index links to no record, so this test checks nothing");++ for target in &linked {+ assert!(+ decisions_dir().join(target).is_file(),+ "the index links to {target}, which does not exist. A renumbered record leaves this \+ behind, and the row still renders, so nothing else would notice"+ );+ }++ let missing: Vec<String> = records()+ .into_iter()+ .map(|(_, name)| name)+ .filter(|name| !linked.contains(name))+ .collect();+ assert!(+ missing.is_empty(),+ "{} record(s) exist with no row in the index:\n {}\n\nAn index that looks complete and \+ is not is worse than one that admits the gap.",+ missing.len(),+ missing.join("\n ")+ );+}