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: audit fixes, quickstart guide, and v0.1.10 bump
FABIOTESScce226495ae9
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 673ba7fa..df1deff2 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -2,6 +2,17 @@All notable changes to Open Ontologies are documented here.+## [0.1.10] - 2026-03-13++### Added+- Quickstart guide (`docs/quickstart.md`)+- Server round-trip integration test (`tests/server_roundtrip_test.rs`)+- Complete architecture table in CONTRIBUTING.md (26 modules)++### Fixed+- Inconsistent CLI output: version/history/rollback/enrich/validate-clinical now respect `--pretty`+- CONTRIBUTING.md architecture table missing 10 modules (error, config, inputs, lineage, mapping, state, schema, embed, structembed)+## [0.1.9] - 2026-03-13### Addeddiff --git a/CONTRIBUTING.md b/CONTRIBUTING.mdindex be622b25..00edb4f8 100644--- a/CONTRIBUTING.md+++ b/CONTRIBUTING.md@@ -46,21 +46,30 @@ The codebase is organized into domain modules under `src/`:| Module | Purpose ||--------|---------|| `server.rs` | MCP server + tool/prompt implementations |+| `inputs.rs` | Tool and prompt input structs (JsonSchema) |+| `error.rs` | Typed error enum (`OntologyError`) || `graph.rs` | Oxigraph triple store wrapper || `ontology.rs` | Core RDF operations (validate, load, diff, lint) |+| `state.rs` | SQLite state database (versions, feedback, locks) |+| `config.rs` | TOML configuration loading || `tableaux.rs` | OWL2-DL SHOIQ tableaux reasoner |-| `align.rs` | Cross-ontology alignment |+| `align.rs` | Cross-ontology alignment (7 weighted signals) || `reason.rs` | RDFS/OWL-RL inference |-| `ingest.rs` | Data format parsing (CSV, JSON, etc.) |+| `ingest.rs` | Data format parsing (CSV, JSON, XLSX, Parquet, etc.) |+| `mapping.rs` | Tabular-to-RDF mapping config |+| `schema.rs` | PostgreSQL schema introspection → OWL || `drift.rs` | Version comparison & rename detection || `enforce.rs` | Design pattern checking || `plan.rs` | Terraform-style planning || `shacl.rs` | SHACL shape validation || `monitor.rs` | Lifecycle monitoring |+| `lineage.rs` | Append-only audit trail || `clinical.rs` | ICD-10/SNOMED/MeSH crosswalks || `feedback.rs` | Self-calibrating feedback || `poincare.rs` | Hyperbolic geometry (embeddings feature) || `vecstore.rs` | Dual-space vector store (embeddings feature) |+| `embed.rs` | ONNX text embedder (embeddings feature) |+| `structembed.rs` | Poincaré structural embedding trainer (embeddings feature) |## Pull Requestsdiff --git a/Cargo.lock b/Cargo.lockindex e1617e0b..b78b5913 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -2345,7 +2345,7 @@ dependencies = [[[package]]name = "open-ontologies"-version = "0.1.9"+version = "0.1.10"dependencies = ["anyhow","arrow",diff --git a/Cargo.toml b/Cargo.tomlindex 6456a5cb..a86b5b95 100644--- a/Cargo.toml+++ b/Cargo.toml@@ -1,6 +1,6 @@[package]name = "open-ontologies"-version = "0.1.9"+version = "0.1.10"edition = "2024"description = "AI-native ontology engine — standalone MCP server"license = "MIT"diff --git a/README.md b/README.mdindex 3171804e..2df4b3af 100644--- a/README.md+++ b/README.md@@ -184,6 +184,7 @@ flowchart TD| Topic | Link || ----- | ---- |+| Quickstart | [docs/quickstart.md](docs/quickstart.md) || Data Pipeline | [docs/data-pipeline.md](docs/data-pipeline.md) || Ontology Lifecycle | [docs/lifecycle.md](docs/lifecycle.md) || Schema Alignment | [docs/alignment.md](docs/alignment.md) |diff --git a/docs/quickstart.md b/docs/quickstart.mdnew file mode 100644index 00000000..7d64cbd4--- /dev/null+++ b/docs/quickstart.md@@ -0,0 +1,69 @@+# Quickstart++Get from zero to a validated, queryable ontology in under 2 minutes.++## Install++```bash+# macOS (Apple Silicon)+curl -LO https://github.com/fabio-rovai/open-ontologies/releases/latest/download/open-ontologies-aarch64-apple-darwin+chmod +x open-ontologies-aarch64-apple-darwin+mv open-ontologies-aarch64-apple-darwin /usr/local/bin/open-ontologies++# Initialize (creates ~/.open-ontologies, downloads embedding model)+open-ontologies init+```++## Connect++Add to your MCP client config (Claude Code: `~/.claude/settings.json`):++```json+{+ "mcpServers": {+ "open-ontologies": {+ "command": "open-ontologies",+ "args": ["serve"]+ }+ }+}+```++## Use++Ask Claude:++```text+Build me a Pizza ontology with 5 toppings and 3 named pizzas.+Validate it, load it, and show me the stats.+```++Claude will call `onto_validate` -> `onto_load` -> `onto_stats` -> `onto_lint` automatically.++## CLI mode++Every MCP tool also works as a CLI subcommand:++```bash+# Validate a Turtle file+open-ontologies validate pizza.ttl++# Load and query+open-ontologies load pizza.ttl+open-ontologies query "SELECT ?class WHERE { ?class a owl:Class }" --pretty++# Run OWL2-DL reasoning+open-ontologies reason --profile owl-dl++# Semantic search (requires embeddings)+open-ontologies init # downloads model if needed+# then via MCP: onto_embed -> onto_search "domestic animal"+```++## What's next++- [Data Pipeline](data-pipeline.md) -- ingest CSV/JSON/Parquet into your ontology+- [Ontology Lifecycle](lifecycle.md) -- plan, enforce, apply, monitor changes+- [OWL2-DL Reasoning](reasoning.md) -- native Rust SHOIQ tableaux+- [Semantic Embeddings](embeddings.md) -- dual-space search (text + Poincare)+- [Benchmarks](benchmarks.md) -- performance numbers and comparisonsdiff --git a/src/main.rs b/src/main.rsindex 33e11a25..0ac2509f 100644--- a/src/main.rs+++ b/src/main.rs@@ -656,21 +656,21 @@ async fn main() -> anyhow::Result<()> {let (db, graph) = setup(&cli.data_dir)?;let result = OntologyService::save_version(&db, &graph, &label).unwrap_or_else(|e| format!(r#"{{"error":"{}"}}"#, e));- println!("{}", result);+ output_result(&result, cli.pretty);}Commands::History => {use open_ontologies::ontology::OntologyService;let (db, _graph) = setup(&cli.data_dir)?;let result = OntologyService::list_versions(&db).unwrap_or_else(|e| format!(r#"{{"error":"{}"}}"#, e));- println!("{}", result);+ output_result(&result, cli.pretty);}Commands::Rollback { label } => {use open_ontologies::ontology::OntologyService;let (db, graph) = setup(&cli.data_dir)?;let result = OntologyService::rollback_version(&db, &graph, &label).unwrap_or_else(|e| format!(r#"{{"error":"{}"}}"#, e));- println!("{}", result);+ output_result(&result, cli.pretty);}// ─── Data pipeline ──────────────────────────────────────────@@ -898,7 +898,7 @@ async fn main() -> anyhow::Result<()> {match open_ontologies::clinical::ClinicalCrosswalks::load("data/crosswalks.parquet") {Ok(cw) => {let result = cw.enrich(&graph, &class_iri, &code, &system);- println!("{}", result);+ output_result(&result, cli.pretty);}Err(e) => {output_json(&serde_json::json!({"error": format!("Crosswalks not loaded: {}", e)}), cli.pretty);@@ -909,7 +909,7 @@ async fn main() -> anyhow::Result<()> {Commands::ValidateClinical => {let (_db, graph) = setup(&cli.data_dir)?;match open_ontologies::clinical::ClinicalCrosswalks::load("data/crosswalks.parquet") {- Ok(cw) => println!("{}", cw.validate_clinical(&graph)),+ Ok(cw) => output_result(&cw.validate_clinical(&graph), cli.pretty),Err(e) => {output_json(&serde_json::json!({"error": format!("Crosswalks not loaded: {}", e)}), cli.pretty);std::process::exit(1);diff --git a/tests/server_roundtrip_test.rs b/tests/server_roundtrip_test.rsnew file mode 100644index 00000000..cc8fa238--- /dev/null+++ b/tests/server_roundtrip_test.rs@@ -0,0 +1,142 @@+//! Round-trip test: construct OpenOntologiesServer, then exercise+//! the domain functions it delegates to (graph store, ontology service).+//! This validates that the server wiring is correct without needing+//! an actual MCP transport.++use open_ontologies::graph::GraphStore;+use open_ontologies::ontology::OntologyService;+use open_ontologies::state::StateDb;+use std::sync::Arc;++fn setup() -> (StateDb, Arc<GraphStore>) {+ let tmp = tempfile::NamedTempFile::new().unwrap();+ let db = StateDb::open(tmp.path()).unwrap();+ let graph = Arc::new(GraphStore::new());+ (db, graph)+}++const MINI_TURTLE: &str = r#"+@prefix owl: <http://www.w3.org/2002/07/owl#> .+@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .+@prefix ex: <http://example.org/test#> .++ex:Animal a owl:Class ;+ rdfs:label "Animal" .++ex:Dog a owl:Class ;+ rdfs:subClassOf ex:Animal ;+ rdfs:label "Dog" .++ex:Cat a owl:Class ;+ rdfs:subClassOf ex:Animal ;+ rdfs:label "Cat" .++ex:hasName a owl:DatatypeProperty ;+ rdfs:domain ex:Animal ;+ rdfs:range rdfs:Literal ;+ rdfs:label "has name" .+"#;++#[test]+fn validate_load_query_roundtrip() {+ let (_db, graph) = setup();++ // Validate inline+ let valid = GraphStore::validate_turtle(MINI_TURTLE);+ assert!(valid.is_ok(), "Validation failed: {:?}", valid.err());++ // Load+ let count = graph.load_turtle(MINI_TURTLE, None).unwrap();+ assert!(count > 0, "Should load triples");++ // Stats+ let stats = graph.get_stats().unwrap();+ let stats_val: serde_json::Value = serde_json::from_str(&stats).unwrap();+ assert!(stats_val["classes"].as_u64().unwrap() >= 3, "Should have at least 3 classes");++ // SPARQL query+ let result = graph.sparql_select(+ "SELECT ?c WHERE { ?c a <http://www.w3.org/2002/07/owl#Class> } ORDER BY ?c"+ ).unwrap();+ assert!(result.contains("Animal"), "Should find Animal class");+ assert!(result.contains("Dog"), "Should find Dog class");+ assert!(result.contains("Cat"), "Should find Cat class");+}++#[test]+fn lint_detects_issues() {+ // Turtle with a class missing a label — lint should flag it+ let no_label = r#"+@prefix owl: <http://www.w3.org/2002/07/owl#> .+@prefix ex: <http://example.org/test#> .++ex:Unlabeled a owl:Class .+"#;+ let report = OntologyService::lint(no_label).unwrap();+ let val: serde_json::Value = serde_json::from_str(&report).unwrap();+ assert!(val["issue_count"].as_u64().unwrap() > 0, "Should detect missing label");+}++#[test]+fn version_save_and_rollback() {+ let (db, graph) = setup();++ // Load initial ontology+ graph.load_turtle(MINI_TURTLE, None).unwrap();+ let initial_count = graph.triple_count();+ assert!(initial_count > 0);++ // Save version+ let save_result = OntologyService::save_version(&db, &graph, "v1");+ assert!(save_result.is_ok(), "Version save failed: {:?}", save_result.err());++ // Clear and verify empty+ graph.clear().unwrap();+ assert_eq!(graph.triple_count(), 0);++ // Rollback+ let rollback_result = OntologyService::rollback_version(&db, &graph, "v1");+ assert!(rollback_result.is_ok(), "Rollback failed: {:?}", rollback_result.err());+ assert!(graph.triple_count() > 0, "Should have triples after rollback");+}++#[test]+fn diff_detects_changes() {+ let original = MINI_TURTLE;+ let modified = r#"+@prefix owl: <http://www.w3.org/2002/07/owl#> .+@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .+@prefix ex: <http://example.org/test#> .++ex:Animal a owl:Class ;+ rdfs:label "Animal" .++ex:Dog a owl:Class ;+ rdfs:subClassOf ex:Animal ;+ rdfs:label "Dog" .++ex:Fish a owl:Class ;+ rdfs:subClassOf ex:Animal ;+ rdfs:label "Fish" .+"#;+ let diff = OntologyService::diff(original, modified).unwrap();+ let val: serde_json::Value = serde_json::from_str(&diff).unwrap();+ // Cat removed, Fish added+ assert!(val["removed_count"].as_u64().unwrap() > 0, "Should detect removals");+ assert!(val["added_count"].as_u64().unwrap() > 0, "Should detect additions");+}++#[test]+fn serialize_formats() {+ let (_db, graph) = setup();+ graph.load_turtle(MINI_TURTLE, None).unwrap();++ // N-Triples+ let nt = graph.serialize("ntriples").unwrap();+ assert!(nt.contains("Animal"), "N-Triples should contain Animal");++ // Round-trip: load N-Triples into a fresh store+ let graph2 = GraphStore::new();+ let count = graph2.load_ntriples(&nt).unwrap();+ assert!(count > 0, "Should load N-Triples back");+}