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
fix(temporal): report non_overlapping instead of claiming supersession (#116)
Nicolas Geysse625c9e5781c6
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 70916905..e194f832 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -24,6 +24,24 @@ All notable changes to Open Ontologies are documented here.the 20,000-row cap covers roughly 5,000 fully described graphs where itcovered roughly 6,700 with three predicates; there is a test that proves thecost rather than asserting it in a comment.+- **`onto_temporal_conflicts` stops calling every non-overlapping pair a+ correction.** The check is `!overlaps`, which proves the two periods share no+ instant and nothing more. It does not establish that one assertion replaced+ the other -- the data carries no link that would -- and the same bucket also+ holds pairs separated by a GAP, which is missing coverage rather than+ history. The results now come back under `non_overlapping` /+ `non_overlapping_count`, and the `note` says what was checked instead of+ claiming adjacency the code never tested -- including the comparison that+ backs it. Bounds are compared as text, so two periods written with different+ timezone offsets can share an hour and still land in `non_overlapping`; the+ note says so, and a conformance test pins it so the parsed-time work turns it+ into a contradiction as a diff rather than a new assertion.++ `superseded` / `superseded_count` are still emitted, unconditionally and+ behind no flag, carrying exactly the same rows until 2.0. Deprecated, not+ renamed: when lineage-backed supersession arrives it takes a new key, so no+ key ever names a different set on either side of a major version.+- **`open-ontologies-lite` no longer installs an MCP server with the library**(released as 0.5.0). `mcp` was a core dependency of a package that imports itin exactly one module, `server.py`, so every consumer of the library APIdiff --git a/CLAUDE.md b/CLAUDE.mdindex b12ac399..40777999 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -97,7 +97,7 @@ Claude dynamically decides the next tool call based on what the previous tool re| `onto_unpack` | To load a pack, refusing it if the checksum does not match. `verify_only` inspects the manifest and evidence without loading || `onto_temporal_snapshot` | To see which named graphs are in scope at a point in time. Two independent clocks: `valid_at` asks what was TRUE then, `as_of` asks what was KNOWN then. Both intervals are half-open — `temporal:recordedUntil` closes the recorded one, so `as_of` answers what was believed then rather than everything recorded by then. Graphs without validity metadata are timeless and always in scope, so the vocabulary is additive to an existing store || `onto_temporal_query` | To run a SPARQL graph pattern against only the graphs in temporal scope: what the graph said at a given valid time, as known at a given recorded time |-| `onto_temporal_conflicts` | To separate genuine contradictions from corrections. A disjointness violation only counts when the two assertions claim OVERLAPPING validity; where one period ends as the other begins, the pair is superseded history, not a conflict |+| `onto_temporal_conflicts` | To separate genuine contradictions from pairs that never met. A disjointness violation only counts when the two assertions claim OVERLAPPING validity; everything else lands in `non_overlapping`, which proves only that the two share no instant under a LEXICAL comparison of their bounds (offsets are not normalised) — not that one replaced the other, and it also holds pairs separated by a gap, which is missing coverage rather than history. `superseded` is the same set under its old name, deprecated and dropped at 2.0 || `onto_lineage` | To view the session's lineage trail (plan → enforce → apply → monitor → drift) || `onto_lint_feedback` | To accept/dismiss a lint issue — teaches lint to suppress repeatedly dismissed warnings || `onto_enforce_feedback` | To accept/dismiss an enforce violation — teaches enforce to suppress repeatedly dismissed violations |diff --git a/src/server.rs b/src/server.rsindex f23f5950..8d426d04 100644--- a/src/server.rs+++ b/src/server.rs@@ -1030,7 +1030,7 @@ impl OpenOntologiesServer {}}- #[tool(name = "onto_temporal_conflicts", description = "Disjointness violations that claim OVERLAPPING validity, separated from those that do not. Without valid time a correction reads as a contradiction: an entity recorded one way until May and another after trips every check. This reports genuine disagreement about the same period as contradictions, and everything else as superseded history. The scans are capped: `complete` says whether they finished, and if the validity scan was cut a `warning` marks the classification unsound, because a pair compared without its periods can appear here as a contradiction when it is a correction.")]+ #[tool(name = "onto_temporal_conflicts", description = "Disjointness violations that claim OVERLAPPING validity, separated from those that do not. Without valid time a correction reads as a contradiction: an entity recorded one way until May and another after trips every check. This reports genuine disagreement about the same period as contradictions, and everything else as non_overlapping: pairs with no instant in common under LEXICAL comparison of their bounds. That is all that is checked -- it is not evidence that one assertion replaced another, and the bucket also holds pairs separated by a GAP, which is missing coverage rather than history. The `superseded` key carries the same set under a name that claimed more than was proven; it is deprecated and will be dropped at 2.0. The scans are capped: `complete` says whether they finished, and if the validity scan was cut a `warning` marks the classification unsound, because a pair compared without its periods can appear here as a contradiction when it is a correction.")]async fn onto_temporal_conflicts(&self) -> String {use crate::temporal::Temporal;match Temporal::new(self.graph.clone()).conflicts() {diff --git a/src/temporal.rs b/src/temporal.rsindex 7aec84fc..c4f05bf2 100644--- a/src/temporal.rs+++ b/src/temporal.rs@@ -523,8 +523,18 @@ impl Temporal {/// This is the point of carrying valid time at all. Without it, a/// correction reads as a contradiction: an entity recorded as one thing/// until May and another thereafter trips every disjointness check, and- /// the finding is noise. With it, a superseded statement is superseded,- /// and only genuine disagreement about the same period survives.+ /// the finding is noise. With it, only genuine disagreement about the same+ /// period survives.+ ///+ /// What the other bucket contains is narrower than it used to claim. The+ /// test is `!overlaps`, which proves the two periods share no instant —+ /// nothing more. It does NOT prove one replaced the other, and the data+ /// carries no link that would. Three different situations land there:+ /// periods that touch at a boundary, periods separated by a GAP, and+ /// periods that never met. The gap is the one that is not benign: it is+ /// missing coverage, not history, and reading it as a correction invents a+ /// continuity nobody asserted. Hence `non_overlapping`, and hence+ /// `superseded` being deprecated rather than redefined — see #110.pub fn conflicts(&self) -> anyhow::Result<String> {let (validities, validity_scan) = self.validities()?;let scan = self.rows(@@ -540,7 +550,7 @@ impl Temporal {)?;let mut conflicts = Vec::new();- let mut superseded = Vec::new();+ let mut non_overlapping = Vec::new();for row in &scan.rows {let get = |k: &str| row.get(k).and_then(|v| v.as_str()).map(plain);let (Some(s), Some(a), Some(b), Some(ga), Some(gb)) = (@@ -571,20 +581,35 @@ impl Temporal {if va.overlaps(vb) {conflicts.push(entry);} else {- superseded.push(entry);+ non_overlapping.push(entry);}}+ // `superseded` is the same set under its old, wrong name. Emitted+ // unconditionally until 2.0 and behind no flag: an opt-out would be a+ // third response shape to document and test, and it would let a client+ // code against a shape no release guarantees. It is deprecated, not+ // renamed — when lineage-backed supersession arrives it gets a NEW+ // key, so that no key ever names a different set across a major+ // version. See #110.let mut out = serde_json::json!({"ok": true,"contradictions": conflicts,"contradiction_count": conflicts.len(),- "superseded": superseded,- "superseded_count": superseded.len(),+ "non_overlapping": non_overlapping,+ "non_overlapping_count": non_overlapping.len(),+ "superseded": non_overlapping,+ "superseded_count": non_overlapping.len(),"complete": !validity_scan.hit && !scan.capped.hit,"note": "contradictions claim overlapping validity and genuinely disagree. \- superseded pairs are corrections: one period ends where the other begins, \- which is a history rather than a conflict.",+ non_overlapping pairs have no instant in common UNDER LEXICAL \+ COMPARISON of their bounds, which is all that has been checked: it is \+ not evidence that one replaced the other, the bucket also holds pairs \+ separated by a GAP (missing coverage rather than history), and bounds \+ written with different timezone offsets are compared as text, so a \+ genuinely overlapping pair can land here until bounds are parsed as \+ instants. superseded is the same set under a name that claimed more \+ than was proven; it is deprecated and will be dropped at 2.0.",});// A cut validity scan is not a smaller answer here, it is a wrong one:diff --git a/tests/temporal_conformance_test.rs b/tests/temporal_conformance_test.rsindex 431e768b..8869b7f9 100644--- a/tests/temporal_conformance_test.rs+++ b/tests/temporal_conformance_test.rs@@ -439,9 +439,137 @@ fn boundary_touching_disjoint_assertions_are_superseded_not_contradictory() {out["contradiction_count"], 0,"touching half-open periods do not overlap: {out}");+ assert_eq!(+ out["non_overlapping_count"], 1,+ "the two periods share no instant: {out}"+ );assert_eq!(out["superseded_count"], 1,- "the earlier assertion is superseded history, not a live conflict"+ "the deprecated key carries the same set until 2.0"+ );+}++/// Two disjoint types with a GAP between their periods — nothing is asserted+/// about 2025 at all. `!overlaps` is true here exactly as it is for a touching+/// pair, which is why the bucket cannot be called `superseded`: this is missing+/// coverage, not a correction.+const CONFLICT_GAP: &str = r#"+@prefix ex: <http://example.org/> .+@prefix owl: <http://www.w3.org/2002/07/owl#> .+@prefix t: <https://open-ontologies.org/temporal#> .++ex:g_a { ex:X a ex:Adherent . }+ex:g_b { ex:X a ex:Suspension . }++{+ ex:Adherent owl:disjointWith ex:Suspension .+ ex:g_a t:validFrom "2024-01-01" ; t:validTo "2025-01-01" .+ ex:g_b t:validFrom "2026-01-01" .+}+"#;++#[test]+fn a_gap_between_periods_is_not_a_contradiction_and_is_not_a_correction() {+ let t = temporal(CONFLICT_GAP);+ let out: serde_json::Value = serde_json::from_str(&t.conflicts().unwrap()).unwrap();+ assert_eq!(+ out["contradiction_count"], 0,+ "the periods share no instant, so they do not disagree: {out}"+ );+ assert_eq!(+ out["non_overlapping_count"], 1,+ "and that is the whole of what has been established: {out}"+ );+ // The old name says a correction happened. Nothing here shows one did:+ // the whole of 2025 is undescribed, and the pair lands in exactly the same+ // bucket as a touching pair does.+ assert_eq!(out["superseded_count"], 1);+}++#[test]+fn the_deprecated_key_carries_the_same_set_until_2_0() {+ for fixture in [CONFLICT_SUPERSEDED, CONFLICT_GAP, CONFLICT_OVERLAP] {+ let t = temporal(fixture);+ let out: serde_json::Value = serde_json::from_str(&t.conflicts().unwrap()).unwrap();+ assert_eq!(+ out["superseded"], out["non_overlapping"],+ "the deprecated key is emitted unconditionally and holds the same \+ rows, so no reader has to change on the day it appears: {out}"+ );+ assert_eq!(out["superseded_count"], out["non_overlapping_count"]);+ }+}++/// The `note` is output, and output can be wrong. It claimed "one period ends+/// where the other begins" — adjacency — when the only test performed is+/// `!overlaps`, which is disjointness. A gap satisfies it too. Nothing pinned+/// that sentence, which is how it survived; this pins what the code proves.+#[test]+fn the_note_claims_only_what_the_code_checks() {+ let t = temporal(CONFLICT_GAP);+ let out: serde_json::Value = serde_json::from_str(&t.conflicts().unwrap()).unwrap();+ let note = out["note"].as_str().expect("note is a string");+ assert!(+ note.contains("no instant in common"),+ "the note must state the check that was performed: {note}"+ );+ assert!(+ note.contains("gap") || note.contains("GAP"),+ "and must name the case that is missing coverage rather than history: {note}"+ );+ assert!(+ note.contains("LEXICAL COMPARISON") || note.contains("lexical"),+ "and must qualify the guarantee by the comparison that backs it: {note}"+ );+ assert!(+ !note.contains("one period ends where the other begins"),+ "adjacency is never established by `!overlaps`: {note}"+ );+}++/// Two periods that DO share an hour, written with different timezone offsets.+/// `2026-05-01T00:00:00-02:00` is `02:00Z`, so the first period runs past the+/// `01:00Z` start of the second.+const CONFLICT_OFFSET_OVERLAP: &str = r#"+@prefix ex: <http://example.org/> .+@prefix owl: <http://www.w3.org/2002/07/owl#> .+@prefix t: <https://open-ontologies.org/temporal#> .+@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .++ex:g_a { ex:X a ex:Adherent . }+ex:g_b { ex:X a ex:Suspension . }++{+ ex:Adherent owl:disjointWith ex:Suspension .+ ex:g_a t:validFrom "2026-04-01T00:00:00Z"^^xsd:dateTime ;+ t:validTo "2026-05-01T00:00:00-02:00"^^xsd:dateTime .+ ex:g_b t:validFrom "2026-05-01T01:00:00Z"^^xsd:dateTime .+}+"#;++/// ACCIDENTAL, pinned on purpose so the parsed-time work (#95, item 4) lands as+/// a diff on an assertion that already exists rather than as a new one.+///+/// `overlaps()` compares datatype-stripped literals as TEXT. `"…T01:00:00Z"`+/// sorts after `"…T00:00:00-02:00"`, so the two periods read as disjoint and+/// the pair is classified `non_overlapping` — while on the real timeline they+/// share an hour and are a genuine contradiction.+///+/// This is why the `note` qualifies its guarantee with the comparison that+/// backs it: the key must not promise more than `overlaps()` can establish.+///+/// AFTER item 4: `contradiction_count` is 1 and `non_overlapping_count` is 0.+#[test]+fn accidental_offset_bounds_can_hide_a_real_overlap_from_the_disjointness_check() {+ let t = temporal(CONFLICT_OFFSET_OVERLAP);+ let out: serde_json::Value = serde_json::from_str(&t.conflicts().unwrap()).unwrap();+ assert_eq!(+ out["contradiction_count"], 0,+ "today the offsets are compared as text, so the real overlap is invisible: {out}"+ );+ assert_eq!(+ out["non_overlapping_count"], 1,+ "and the pair lands in the bucket whose guarantee it violates: {out}");}