From ed2ecd0d1da1d7564d740db0543f549fb7f8c77e Mon Sep 17 00:00:00 2001 From: Weksa Date: Thu, 12 Nov 2026 19:41:40 +0000 Subject: [PATCH] ja-seed-pairs: publish the AtMostOrUnset schema; sweep through the production Condition::holds; pin :5 and :8 lower bounds Co-Authored-By: Claude Sonnet 5.5 --- crates/weksa/src/ontology.rs | 4 ++- crates/weksa/tests/original_corpus.rs | 33 ++++++++++++------- .../cultnet/weksa.ontology_entry.schema.json | 13 ++++++++ 3 files changed, 37 insertions(+), 13 deletions(-) diff --git a/crates/weksa/src/ontology.rs b/crates/weksa/src/ontology.rs index bd68b69..154c562 100644 --- a/crates/weksa/src/ontology.rs +++ b/crates/weksa/src/ontology.rs @@ -65,7 +65,9 @@ pub struct Condition { } impl Condition { - fn holds(&self, features: &[FeatureValue]) -> bool { + /// Whether this condition holds over a slot's feature values: the one + /// evaluator `select` and the corpus tests share. + pub fn holds(&self, features: &[FeatureValue]) -> bool { let Some(found) = features.iter().find(|f| f.feature == self.feature) else { return matches!(self.test, Test::AtMostOrUnset(_)); }; diff --git a/crates/weksa/tests/original_corpus.rs b/crates/weksa/tests/original_corpus.rs index 10fe5cf..715233c 100644 --- a/crates/weksa/tests/original_corpus.rs +++ b/crates/weksa/tests/original_corpus.rs @@ -987,20 +987,26 @@ fn ja_seed_pairs_never_co_select() { .unwrap_or_else(|| panic!("onto:ja-JP:{n} is absent")) }; type Point = [Option; 5]; + // The production evaluator over the slot's feature values: absent features + // are left out of the list, as a view leaves them out. let holds = |e: &weksa::OntologyEntry, point: &Point| { + use weksa::packet::{FeatValue, FeatureValue, Grade}; e.when.iter().all(|c: &Condition| { assert!(matches!(c.slot, Slot::Stance | Slot::Discourse), "{}", e.key()); - let at = feats + assert!( + matches!(c.test, Test::AtLeast(_) | Test::AtMost(_) | Test::AtMostOrUnset(_)), + "{}", + e.key() + ); + let values: Vec = feats .iter() - .position(|f| *f == c.feature) - .unwrap_or_else(|| panic!("{} reads a feature this test does not sweep", e.key())); - match (&c.test, point[at]) { - (Test::AtLeast(g), Some(v)) => v >= g.get(), - (Test::AtMost(g) | Test::AtMostOrUnset(g), Some(v)) => v <= g.get(), - (Test::AtMostOrUnset(_), None) => true, - (Test::AtLeast(_) | Test::AtMost(_), None) => false, - (other, _) => panic!("{} has {other:?}", e.key()), - } + .zip(point) + .filter_map(|(f, v)| { + v.map(|v| FeatureValue { feature: *f, value: FeatValue::Grade(Grade::new(v).unwrap()) }) + }) + .collect(); + assert!(feats.contains(&c.feature), "{} reads a feature this test does not sweep", e.key()); + c.holds(&values) }) }; let grid = [None, Some(0u16), Some(300), Some(500), Some(599), Some(600), Some(700), Some(799), Some(800), Some(1000)]; @@ -1016,7 +1022,8 @@ fn ja_seed_pairs_never_co_select() { } // Reach: each entry fires at its witnesses and not just outside its core. let (n, s) = (None, Some); - let fires: [(u32, Point); 8] = [ + let fires: [(u32, Point); 9] = [ + (5, [s(600), n, n, n, n]), (5, [s(700), s(799), n, n, n]), (5, [s(700), n, n, n, n]), (7, [n, s(799), n, s(700), s(599)]), @@ -1029,7 +1036,9 @@ fn ja_seed_pairs_never_co_select() { for (e, point) in fires { assert!(holds(ja(e), &point), "onto:ja-JP:{e} does not fire at {point:?}"); } - let silent: [(u32, Point); 4] = [ + let silent: [(u32, Point); 6] = [ + (8, [n, n, s(599), n, s(700)]), + (8, [n, n, n, n, s(700)]), (5, [s(599), n, n, n, n]), (7, [n, n, n, s(599), n]), (7, [n, n, n, s(700), s(600)]), diff --git a/schemas/cultnet/weksa.ontology_entry.schema.json b/schemas/cultnet/weksa.ontology_entry.schema.json index 8e0529b..4d086d7 100644 --- a/schemas/cultnet/weksa.ontology_entry.schema.json +++ b/schemas/cultnet/weksa.ontology_entry.schema.json @@ -257,6 +257,19 @@ "required": [ "Is" ] + }, + { + "description": "Holds when the feature is absent or a grade at most `g`: a bound that\ncosts nothing where the feature is unrated. `AtMost` still fails on an\nabsent feature.", + "type": "object", + "properties": { + "AtMostOrUnset": { + "$ref": "#/$defs/Grade" + } + }, + "additionalProperties": false, + "required": [ + "AtMostOrUnset" + ] } ] }