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(induce): safely probe Unicode strings for dateTime
Rudy Celeklif7476119348b
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 3d864085..2f472f54 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -46,6 +46,10 @@ All notable changes to Open Ontologies are documented here.### Fixed+- Treat Unicode strings as strings during the dateTime probe, including mixed+ product names such as `Tシャツ半袖綿素材`, so one-sheet induction can complete+ without slicing through a character. Existing ASCII dateTime checks are retained.+- **The embedding model is loaded once per process rather than once per HTTPsession** (#262). The HTTP arm hands the same server constructor to`StreamableHttpService::new` as a per-session factory, so everything thatdiff --git a/src/induce.rs b/src/induce.rsindex 302ac9b2..9991627a 100644--- a/src/induce.rs+++ b/src/induce.rs@@ -136,14 +136,18 @@ impl Dt {Some(x) => x,None => return false,};+ if !Dt::Date.accepts(d) {+ return false;+ }let t = t.trim_end_matches('Z');let t = t.split(['+']).next().unwrap_or(t);- let t = if t.len() > 8 && &t[8..9] == "-" { &t[..8] } else { t };- Dt::Date.accepts(d)- && t.len() >= 8- && &t[2..3] == ":"- && &t[5..6] == ":"- && t[..8].chars().enumerate().all(|(i, c)| i == 2 || i == 5 || c.is_ascii_digit())+ let t = if t.get(8..9) == Some("-") { &t[..8] } else { t };+ t.len() >= 8+ && t.get(2..3) == Some(":")+ && t.get(5..6) == Some(":")+ && t.get(..8).is_some_and(|prefix| {+ prefix.chars().enumerate().all(|(i, c)| i == 2 || i == 5 || c.is_ascii_digit())+ })}Dt::AnyUri => (v.starts_with("http://") || v.starts_with("https://")) && !v.contains(' '),Dt::String => true,diff --git a/tests/induce_unicode_datetime_test.rs b/tests/induce_unicode_datetime_test.rsnew file mode 100644index 00000000..4a4dd3a0--- /dev/null+++ b/tests/induce_unicode_datetime_test.rs@@ -0,0 +1,79 @@+mod common;++use open_ontologies::induce::{Dt, induce};+use open_ontologies::ingest::DataIngester;++const PRODUCTS: &str = "id,name\nproduct-1,Tシャツ半袖綿素材\nproduct-2,シャツ半袖綿素材\nproduct-3,T-shirt cotton short sleeve\n";++#[test]+fn ordinary_multilingual_product_names_induce_a_string_property() {+ let rows = DataIngester::parse_csv(PRODUCTS).unwrap();+ let headers = vec!["id".into(), "name".into()];+ let inferred = induce(&rows, &headers, "Products", "https://example.org/products/");+ assert_eq!(inferred.rows, 3);+ assert_eq!(inferred.id_column, "id");+ assert_eq!(inferred.columns.len(), 1);+ assert_eq!(inferred.columns[0].property, "name");+ assert_eq!(inferred.columns[0].datatype, Dt::String);+ let triples = inferred.mapping.rows_to_ntriples(&rows);+ assert!(triples.contains("Tシャツ半袖綿素材"));+ assert!(triples.contains("シャツ半袖綿素材"));+ assert!(triples.contains("T-shirt cotton short sleeve"));+}++#[test]+fn datetime_probe_rejects_unicode_strings_without_changing_ascii_checks() {+ for value in [+ "Tシャツ半袖綿素材",+ "2026-10-06T午後一時頃",+ "2026-10-06T13:午後一時",+ "2026-10-06T13:14:午後",+ "2026-10-06T📦発送準備",+ ] {+ assert!(!Dt::DateTime.accepts(value), "{value}");+ }+ for value in [+ "2026-10-06T13:14:15",+ "2026-10-06T13:14:15.123",+ "2026-10-06T13:14:15Z",+ "2026-10-06T13:14:15+02:00",+ "2026-10-06T13:14:15-04:00",+ ] {+ assert!(Dt::DateTime.accepts(value), "{value}");+ }+ for value in [+ "2026-10-06",+ "T-shirt cotton short sleeve",+ "2026-10-06T13:14",+ "2026-10-06T13141500",+ ] {+ assert!(!Dt::DateTime.accepts(value), "{value}");+ }+}++#[test]+fn batch_induction_accepts_a_valid_csv_with_mixed_japanese_product_names() {+ let _gate = common::exec_gate();+ let tmp = tempfile::tempdir().unwrap();+ let source = tmp.path().join("products.csv");+ let script = tmp.path().join("commands.txt");+ std::fs::write(&source, PRODUCTS).unwrap();+ std::fs::write(&script, format!("induce {} --no-load\n", source.display())).unwrap();+ let result = std::process::Command::new(env!("CARGO_BIN_EXE_open-ontologies"))+ .args(["--no-connect", "--data-dir"])+ .arg(tmp.path())+ .arg("batch")+ .arg(script)+ .output()+ .unwrap();+ assert!(+ result.status.success(),+ "{}",+ String::from_utf8_lossy(&result.stderr)+ );+ let output: serde_json::Value = serde_json::from_slice(&result.stdout).unwrap();+ assert_eq!(output["result"]["ok"], true);+ assert_eq!(output["result"]["rows"], 3);+ assert_eq!(output["result"]["id_column"], "id");+ assert_eq!(output["result"]["columns"][0]["datatype"], "string");+}