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
Three more test files write a script while their siblings fork, so they hold the exec gate too (#271)
Fabio Rovai9b2dfc24ebeb
diff --git a/tests/certified_token_binding_test.rs b/tests/certified_token_binding_test.rsindex 7b863f40..21817346 100644--- a/tests/certified_token_binding_test.rs+++ b/tests/certified_token_binding_test.rs@@ -27,6 +27,8 @@//! naming a theorem, which is the whole of what the mint reads, so it is//! enough to test what the mint does with the digest.+mod common;+use open_ontologies::verdict::{subject_digest, CheckerBinary, CheckerRun};use std::path::{Path, PathBuf};use std::process::Command;@@ -40,8 +42,13 @@ const THEOREM: &str = "OOCert.certificate_sound";/// parallel threads of one process, so one test's write landed between/// another's run and its recomputation, and the digests disagreed. It passed/// on my machine and failed on CI, which is the signature of exactly this.-/// The script the fake checker runs lives here too: writing over a file-/// another thread is executing is `ETXTBSY` on Linux.+///+/// The script the fake checker runs lives here too, and a directory of its own+/// does NOT keep it out of `ETXTBSY`. On 1 October 2026 the build job on `main`+/// failed in `a_token_earned_over_one_artefact_is_not_about_another` with+/// "Text file busy", one script per directory and all. The race is between any+/// write and any fork in this process, not between two writers of one path,+/// so `fake_checker` and `run_over` both hold `common::exec_gate`.fn dir(tag: &str) -> PathBuf {let d = std::env::temp_dir().join(format!("oo-token-binding-{}-{tag}", std::process::id()));std::fs::create_dir_all(&d).unwrap();@@ -64,6 +71,7 @@ fn fake_checker(tag: &str) -> PathBuf {} else {format!("#!/bin/sh\necho '{say}'\nexit 0\n")};+ let _gate = common::exec_gate();std::fs::write(&p, body).unwrap();#[cfg(unix)]{@@ -79,6 +87,9 @@ fn run_over(tag: &str, inputs: &[&Path]) -> std::io::Result<CheckerRun> {for i in inputs {cmd.arg(i);}+ // `CheckerRun::spawn` forks, and a fork while another test is writing its+ // script hands that write descriptor to the child. See `common::exec_gate`.+ let _gate = common::exec_gate();CheckerRun::spawn(&CheckerBinary::found_at(bin), cmd, inputs)}diff --git a/tests/fol_solver_verdict_test.rs b/tests/fol_solver_verdict_test.rsindex 62e3a0a4..5c9cced9 100644--- a/tests/fol_solver_verdict_test.rs+++ b/tests/fol_solver_verdict_test.rs@@ -49,10 +49,22 @@ use std::path::{Path, PathBuf};use std::process::Command;use open_ontologies::fol_solve::{- Outcome, SolveOptions, Solver, find_checker, solve, verdict_means,+ Outcome, SolveOptions, Solver, find_checker, solve as solve_ungated, verdict_means,};use open_ontologies::tptp::{FolProblem, Form, P1, P2, Term};+/// `solve`, behind `common::exec_gate`.+///+/// `solve` forks the solver and the checker, and three tests here write stub+/// checkers while their siblings solve. A fork in the middle of one of those+/// writes hands the child the write descriptor, and Linux then refuses to exec+/// the stub with `ETXTBSY`. Shadowing the name means no call in this file can+/// forget the gate.+fn solve(problem: &FolProblem, opts: &SolveOptions, dir: &Path) -> anyhow::Result<Outcome> {+ let _gate = common::exec_gate();+ solve_ungated(problem, opts, dir)+}+// ── Problems, built small so the carrier they need is known ─────────────────fn cls(a: &str, t: Term) -> Form {@@ -162,6 +174,7 @@ fn opts(max_domain: u32) -> SolveOptions {/// `oo-folmodel` on the branches a correct checker never reaches.fn stub(dir: &Path, name: &str, body: &str) -> PathBuf {let p = dir.join(name);+ let _gate = common::exec_gate();std::fs::write(&p, body).expect("write stub");#[cfg(unix)]{@@ -513,6 +526,7 @@ fn a_missing_solver_is_loud() {return;}let d = scratch("nopath");+ let gate = common::exec_gate();let out = Command::new(&bin).arg("--no-connect").arg("--data-dir")@@ -538,6 +552,7 @@ fn a_missing_solver_is_loud() {c.wait_with_output()}).expect("run the CLI");+ drop(gate);let err = String::from_utf8_lossy(&out.stderr);let so = String::from_utf8_lossy(&out.stdout);assert!(@@ -604,6 +619,7 @@ fn a_lying_solver_stops_the_line_and_fails_the_command() {.display(),d.join("solve").display());+ let gate = common::exec_gate();let out = Command::new(&bin).arg("--no-connect").arg("--data-dir")@@ -622,6 +638,7 @@ fn a_lying_solver_stops_the_line_and_fails_the_command() {c.wait_with_output()}).expect("run the CLI");+ drop(gate);let so = String::from_utf8_lossy(&out.stdout);let line = so.lines()diff --git a/tests/smt_second_oracle_test.rs b/tests/smt_second_oracle_test.rsindex d85fa608..bacf811c 100644--- a/tests/smt_second_oracle_test.rs+++ b/tests/smt_second_oracle_test.rs@@ -40,9 +40,23 @@ use std::path::{Path, PathBuf};use std::process::Command;use open_ontologies::fol_model::{IngestError, cvc5, z3};-use open_ontologies::fol_solve::{SolveOptions, Solver, find_checker, solve};+use open_ontologies::fol_solve::{+ Outcome, SolveOptions, Solver, find_checker, solve as solve_ungated,+};use open_ontologies::tptp::{Concept, FolProblem, OwlAxiom, smtlib::SmtEncoding};+/// `solve`, behind `common::exec_gate`.+///+/// `solve` forks the solver and the checker, and the lying-solver test writes+/// an executable while its siblings solve. A fork in the middle of that write+/// hands the child the write descriptor, and Linux then refuses to exec the+/// script with `ETXTBSY`. Shadowing the name means no call in this file can+/// forget the gate.+fn solve(problem: &FolProblem, opts: &SolveOptions, dir: &Path) -> anyhow::Result<Outcome> {+ let _gate = common::exec_gate();+ solve_ungated(problem, opts, dir)+}+fn repo() -> PathBuf {PathBuf::from(env!("CARGO_MANIFEST_DIR"))}@@ -105,6 +119,7 @@ fn subsumption() -> FolProblem {fn run_checker(problem: &Path, model: &Path) -> (i32, String) {let checker = find_checker(None).expect("checked by skip()");+ let _gate = common::exec_gate();let out = Command::new(checker).arg(problem).arg(model)@@ -368,11 +383,13 @@ fn cvc5_prints_a_structure_after_unknown_and_the_checker_rejects_it() {// No --finite-model-find. That is the whole point: this is cvc5's DEFAULT// behaviour on a quantified problem, which is what a reader who ran the// binary by hand would see.+ let gate = common::exec_gate();let out = Command::new("cvc5").arg("--tlimit=30000").arg(&smt).output().expect("run cvc5");+ drop(gate);let text = String::from_utf8_lossy(&out.stdout).to_string();let status = text.lines()@@ -496,7 +513,9 @@ fn differential(args: &[&str], extra_path: Option<&Path>) -> (bool, String) {let path = std::env::var("PATH").unwrap_or_default();cmd.env("PATH", format!("{}:{}", p.display(), path));}+ let gate = common::exec_gate();let out = cmd.output().expect("run tools/smt_differential.py");+ drop(gate);(out.status.success(),format!(@@ -591,19 +610,22 @@ fn a_lying_solver_turns_the_differential_red() {}let d = scratch("lying-z3");let liar = d.join("z3");- std::fs::write(- &liar,- "#!/bin/sh\n\- # A Z3 that refutes everything, including problems with obvious models.\n\- # Nothing in this architecture can check an unsat, which is exactly why\n\- # a second solver is the only thing that can catch this.\n\- echo unsat\n",- )- .expect("write stub");- #[cfg(unix)]{- use std::os::unix::fs::PermissionsExt;- std::fs::set_permissions(&liar, std::fs::Permissions::from_mode(0o755)).expect("chmod");+ let _gate = common::exec_gate();+ std::fs::write(+ &liar,+ "#!/bin/sh\n\+ # A Z3 that refutes everything, including problems with obvious models.\n\+ # Nothing in this architecture can check an unsat, which is exactly why\n\+ # a second solver is the only thing that can catch this.\n\+ echo unsat\n",+ )+ .expect("write stub");+ #[cfg(unix)]+ {+ use std::os::unix::fs::PermissionsExt;+ std::fs::set_permissions(&liar, std::fs::Permissions::from_mode(0o755)).expect("chmod");+ }}let (ok, out) = differential(