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
Stop the suite reporting success for tests that ran nothing
FABIOTESS2cbdb482129f
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex 5f92dce5..d59e6c56 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -38,7 +38,19 @@ jobs:- name: Buildrun: cargo build- name: Test- run: cargo test+ run: cargo test -- --nocapture 2>&1 | tee cargo-test.log+ - name: Report tests that skipped for a missing fixture+ # Some tests need data this repository does not carry, so they skip+ # rather than fail. A skip reports `ok`, which means a green run can+ # hide a suite that quietly shrank. This does not fail the build; it+ # prints the count and the names so a shrinking suite is visible in the+ # log instead of invisible in a pass. tests/common/mod.rs emits the+ # marker, and OO_REQUIRE_FIXTURES=1 turns each skip into a failure for+ # any job that is supposed to supply the fixtures.+ run: |+ n=$(grep -c 'SKIPPED_FIXTURE:' cargo-test.log || true)+ echo "$n test(s) skipped for a missing fixture"+ grep 'SKIPPED_FIXTURE:' cargo-test.log | sort -u || true- name: Clippyrun: cargo clippy -- -D warnings- name: Auditdiff --git a/benchmark/reasoner/run_pizza_correctness.sh b/benchmark/reasoner/run_pizza_correctness.shindex 2ff9e2c3..2ae4fd66 100755--- a/benchmark/reasoner/run_pizza_correctness.sh+++ b/benchmark/reasoner/run_pizza_correctness.sh@@ -17,9 +17,35 @@ if [ ! -f "$PIZZA_OWL" ]; thenfi# 1. Open Ontologies+#+# `load` and `reason` must run in ONE process. The store is in memory and dies+# with the process, so invoking them separately reasoned over an empty graph+# and wrote a result that described nothing, while the script exited 0 and the+# comparison downstream treated it as a measurement. `batch -` keeps one+# process alive across both commands, which is what benchmark/lubm already+# does (see run_lubm.py:90).echo "Running Open Ontologies (owl-dl)..."-$OO_BIN load "$PIZZA_OWL"-$OO_BIN reason --profile owl-dl > "$RESULTS_DIR/oo_result.json"+printf '%s\n' "load $PIZZA_OWL" "reason --profile owl-dl" \+ | $OO_BIN batch - > "$RESULTS_DIR/oo_batch.json"++# Take the reason result, which is the last line, and refuse to continue on an+# empty graph rather than reporting a correctness figure derived from nothing.+python3 - "$RESULTS_DIR/oo_batch.json" "$RESULTS_DIR/oo_result.json" <<'PY'+import json, sys+lines = [l for l in open(sys.argv[1]) if l.strip()]+if not lines:+ sys.exit("ERROR: batch produced no output")+result = json.loads(lines[-1])+if result.get("error"):+ sys.exit("ERROR: reason failed: {}".format(result["error"]))+classes = result.get("classes") or result.get("class_count") or 0+if not classes:+ sys.exit("ERROR: reasoned over an empty graph. The load step did not "+ "reach the reasoner, so any number printed here would be "+ "meaningless. Check that `batch` accepted the load command.")+json.dump(result, open(sys.argv[2], "w"), indent=1)+print(" {} classes reasoned.".format(classes))+PYecho " Done."# 2. HermiTdiff --git a/src/main.rs b/src/main.rsindex 170c97b8..ffa52239 100644--- a/src/main.rs+++ b/src/main.rs@@ -1598,7 +1598,20 @@ async fn async_main() -> anyhow::Result<()> {.headers().get("authorization").and_then(|v| v.to_str().ok());- if auth == Some(&expected) {+ // String equality short-circuits on the first+ // differing byte, which leaks the shared prefix+ // length through response timing and lets a token+ // be recovered byte by byte. Hashing both sides+ // first makes the compared values fixed-length and+ // unrelated to the token's own bytes, so the+ // remaining timing difference reveals nothing, and+ // sha2 is already a dependency.+ let ok = auth.is_some_and(|got| {+ use sha2::{Digest, Sha256};+ Sha256::digest(got.as_bytes())+ == Sha256::digest(expected.as_bytes())+ });+ if ok {next.run(req).await} else {axum::http::Response::builder()diff --git a/tests/clinical_test.rs b/tests/clinical_test.rsindex 3e709bc3..6be424db 100644--- a/tests/clinical_test.rs+++ b/tests/clinical_test.rs@@ -1,3 +1,5 @@+mod common;+use open_ontologies::graph::GraphStore;use std::sync::Arc;@@ -5,8 +7,8 @@ use std::sync::Arc;fn test_crosswalk_lookup() {use open_ontologies::clinical::ClinicalCrosswalks;let cw = ClinicalCrosswalks::load("data/crosswalks.parquet");- if cw.is_err() {- eprintln!("Skipping: crosswalks.parquet not found. Run scripts/build_crosswalks.py first.");+ if common::skip_unless(cw.is_ok(), "data/crosswalks.parquet",+ "Run scripts/build_crosswalks.py first.") {return;}let cw = cw.unwrap();@@ -19,7 +21,10 @@ fn test_crosswalk_lookup() {fn test_crosswalk_search_by_label() {use open_ontologies::clinical::ClinicalCrosswalks;let cw = ClinicalCrosswalks::load("data/crosswalks.parquet");- if cw.is_err() { return; }+ if common::skip_unless(cw.is_ok(), "data/crosswalks.parquet",+ "Run scripts/build_crosswalks.py first.") {+ return;+ }let cw = cw.unwrap();let results = cw.search_label("hypertension");@@ -30,7 +35,10 @@ fn test_crosswalk_search_by_label() {fn test_validate_clinical_terms() {use open_ontologies::clinical::ClinicalCrosswalks;let cw = ClinicalCrosswalks::load("data/crosswalks.parquet");- if cw.is_err() { return; }+ if common::skip_unless(cw.is_ok(), "data/crosswalks.parquet",+ "Run scripts/build_crosswalks.py first.") {+ return;+ }let cw = cw.unwrap();let graph = Arc::new(GraphStore::new());@@ -50,7 +58,10 @@ fn test_validate_clinical_terms() {fn test_enrich_adds_skos_mapping() {use open_ontologies::clinical::ClinicalCrosswalks;let cw = ClinicalCrosswalks::load("data/crosswalks.parquet");- if cw.is_err() { return; }+ if common::skip_unless(cw.is_ok(), "data/crosswalks.parquet",+ "Run scripts/build_crosswalks.py first.") {+ return;+ }let cw = cw.unwrap();let graph = Arc::new(GraphStore::new());diff --git a/tests/common/mod.rs b/tests/common/mod.rsnew file mode 100644index 00000000..202768c7--- /dev/null+++ b/tests/common/mod.rs@@ -0,0 +1,29 @@+//! Shared helper for tests that need a fixture the repository does not carry.+//!+//! Several tests used to `return` when their fixture was missing, three of them+//! without printing anything. A test that returns early reports `ok`, so in CI,+//! where neither `data/crosswalks.parquet` nor the embedding model exists, they+//! counted towards a green run while executing nothing. Reporting success for+//! work that did not happen is the one failure this project is built to catch,+//! and it was in its own suite.+//!+//! `skip_unless` makes the skip loud and, when `OO_REQUIRE_FIXTURES=1` is set,+//! fatal. Set that variable in any job that is supposed to provide fixtures and+//! the suite can no longer quietly shrink.++/// Returns true when the caller should skip. Panics instead if the environment+/// says fixtures are mandatory.+#[allow(dead_code)]+pub fn skip_unless(available: bool, what: &str, how_to_get_it: &str) -> bool {+ if available {+ return false;+ }+ let msg = format!("missing fixture: {what}. {how_to_get_it}");+ if std::env::var("OO_REQUIRE_FIXTURES").as_deref() == Ok("1") {+ panic!("{msg} (OO_REQUIRE_FIXTURES=1, so this is a failure, not a skip)");+ }+ // Distinctive marker so a CI step can count skips rather than let them+ // hide inside a green run.+ eprintln!("SKIPPED_FIXTURE: {msg}");+ true+}diff --git a/tests/embed_test.rs b/tests/embed_test.rsindex 331883c7..3eb168b7 100644--- a/tests/embed_test.rs+++ b/tests/embed_test.rs@@ -1,3 +1,5 @@+mod common;+#[cfg(feature = "embeddings")]mod tests {use open_ontologies::embed::TextEmbedder;@@ -19,7 +21,8 @@ mod tests {let tokenizer_path = model_dir.join("tokenizer.json");if !model_path.exists() {- eprintln!("Skipping: model not downloaded. Run `open-ontologies init` first.");+ common::skip_unless(false, "embedding model",+ "Run `open-ontologies init` first.");return;}@@ -45,7 +48,8 @@ mod tests {let tokenizer_path = model_dir.join("tokenizer.json");if !model_path.exists() {- eprintln!("Skipping: model not downloaded.");+ common::skip_unless(false, "embedding model",+ "Run `open-ontologies init` first.");return;}diff --git a/tests/embedding_e2e_test.rs b/tests/embedding_e2e_test.rsindex d4792633..3582f955 100644--- a/tests/embedding_e2e_test.rs+++ b/tests/embedding_e2e_test.rs@@ -2,6 +2,8 @@//! End-to-end test: load ontology → embed → search → align with embeddings.//! Only runs if the ONNX model is available.+mod common;+#[cfg(feature = "embeddings")]mod tests {use open_ontologies::graph::GraphStore;@@ -21,7 +23,8 @@ mod tests {#[test]fn test_e2e_embed_search_align() {if !model_available() {- eprintln!("Skipping e2e: model not downloaded");+ common::skip_unless(false, "embedding model",+ "Run `open-ontologies init` first.");return;}