diff --git a/README.md b/README.md index bfa07f2..34f83c0 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,8 @@ culture, and constraint, and the planned lowerer that turns an agent's meaning packet into the reader's display language. **What is valuable here.** The interlingua standard and the lowering design: a -meaning packet owns what is meant, speaker and scene state (planned; not yet live) own register, +meaning packet owns what is meant, the scene state (live: `weksa scene put|dump`; speaker +documents are planned) owns the speaker's relation to the addressee, which selects register, address and politeness, and a lowerer owns surface text and leaves a trace. **The problem it solves.** An agent's outward speech today is one English @@ -84,9 +85,9 @@ target-specific English receipt. The language ontology is `data/ontology/ontology.cc` (read it with `weksa ontology dump`): per language, the lexicon, grammar and discourse choices a lowerer -reads for a stance and discourse packet. No entry fixes an address or politeness level; those -belong to the speaker and scene state. Its en-US and ja-JP entries are -model-drafted seeds, never Test evidence. Nothing yet grows them from accepted +reads for a stance, a discourse and a scene relation. Only an entry with a Scene condition names an +address or politeness level; the relation, from `data/original/speaker-state.cc`, picks it. Its +en-US and ja-JP entries and the keeper scenes are model-drafted or model-annotated, never Test evidence. Nothing yet grows them from accepted rounds; until that mint exists they change only by a new `weksa ontology admit`. For the first AquaSynth speech-training handoff, see diff --git a/crates/weksa/src/inventory.rs b/crates/weksa/src/inventory.rs index 3ffd5ad..4820ea5 100644 --- a/crates/weksa/src/inventory.rs +++ b/crates/weksa/src/inventory.rs @@ -541,7 +541,7 @@ pub fn proof_revision() -> (InventoryRevision, Vec) { ) } -/// Revision 3: the speaker-state vocabulary. First the Scene features, the +/// Revision `n`: the speaker-state vocabulary. First the Scene features, the /// speaker's relation to one party of a scene (slot `Scene`): `relative_status` /// is the speaker's standing against the addressee's, not a register word, what /// it selects is each language's ontology's business. Then the Speaker features diff --git a/crates/weksa/tests/original_corpus.rs b/crates/weksa/tests/original_corpus.rs index f4bd887..515e855 100644 --- a/crates/weksa/tests/original_corpus.rs +++ b/crates/weksa/tests/original_corpus.rs @@ -282,6 +282,7 @@ fn committed_ontology_is_model_drafted_and_reads_every_inventory() { [ "claude-sonnet-5-5 (Weksa Hands, model-drafted seed ontology)", "claude-sonnet-5-5 (Weksa Hands, model-drafted scene ontology)", + "claude-sonnet-5-5 (Weksa Hands, reworded seed entry)", ] .contains(&generator.as_str()), "{}", @@ -313,16 +314,27 @@ fn committed_ontology_is_model_drafted_and_reads_every_inventory() { "{lang} has no Stance-conditioned entry" ); } - for (corpus, panel) in [("original", &PANEL[..]), ("daodejing", &PANEL[..1])] { + // Every committed inventory bed, the default one included, carries the + // revisions the entries bind to: a run opens over each with its panel. + // The default bed (data/interlingua) is read with the original corpus, + // entities and scenes, as `loop open` with its defaults and `--corpus + // data/original` does. + for (corpus, bed, panel) in [ + ("original", "original", &PANEL[..]), + ("daodejing", "daodejing", &PANEL[..1]), + ("original", "interlingua", &PANEL[..]), + ] { let dir = data.join(corpus); - let copy = |f: &str| { - std::fs::copy(dir.join(f), tmp.path().join(format!("{corpus}-{f}"))).unwrap(); - tmp.path().join(format!("{corpus}-{f}")) + let name = format!("{corpus}-{bed}"); + let copy = |from: &Path, f: &str| { + let to = tmp.path().join(format!("{name}-{f}")); + std::fs::copy(from.join(f), &to).unwrap(); + to }; - let (c, i, e) = (copy("corpus.cc"), copy("inventory.cc"), copy("entity.cc")); - let s = copy("speaker-state.cc"); + let (c, i, e) = (copy(&dir, "corpus.cc"), copy(&data.join(bed), "inventory.cc"), copy(&dir, "entity.cc")); + let s = copy(&dir, "speaker-state.cc"); RunStores::create( - &tmp.path().join(format!("run-{corpus}")), + &tmp.path().join(format!("run-{name}")), corpus, RunPaths { corpus: &c, @@ -337,7 +349,7 @@ fn committed_ontology_is_model_drafted_and_reads_every_inventory() { ModelFamily::Unrecorded, &panel.iter().map(|l| l.to_string()).collect::>(), ) - .unwrap_or_else(|e| panic!("{corpus}: {e:?}")); + .unwrap_or_else(|e| panic!("{name}: {e:?}")); } } @@ -1001,8 +1013,9 @@ fn committed_scenes_cover_original_groups() { .collect(); assert_eq!(live.len(), 56); let held: BTreeSet = scenes.iter().map(|s| s.group.clone()).collect(); - assert_eq!(held, live, "one scene per live Train or Validation group, none other"); - assert_eq!(scenes.len(), 56, "each group holds revision 1 only"); + assert_eq!(held, live, "a scene for each live Train or Validation group, none other"); + // Revisions append: a group's later revisions re-derived its relation. + assert!(scenes.iter().all(|s| s.n <= 2)); for s in &scenes { match &s.annotator { Annotator::Model { family, generator } => { @@ -1017,3 +1030,74 @@ fn committed_scenes_cover_original_groups() { } } } + +/// The committed ontology's Scene-conditioned entries, over every scene relation +/// (relative_status x in_group x intimacy in steps of 50): an entry that names +/// a register or politeness level has a Scene condition, and two Scene-conditioned +/// entries of one language and layer are never selected by the same relation, so +/// the ontology never gives opposing instructions for one relation. +#[test] +fn scene_entries_never_co_select_in_a_layer_and_levels_hang_on_the_scene() { + use weksa::inventory::Slot; + use weksa::ontology::{Condition, Test}; + use weksa::packet::FeatValue; + use weksa::OntologyStore; + let data = Path::new(env!("CARGO_MANIFEST_DIR")).join("../../data"); + let tmp = tempfile::tempdir().unwrap(); + let onto = tmp.path().join("ontology.cc"); + std::fs::copy(data.join("ontology/ontology.cc"), &onto).unwrap(); + let inv = InventoryStore::open(&data.join("original/inventory.cc")).unwrap().inventory().unwrap(); + let id = |gloss: &str| inv.entries().find(|e| e.gloss == gloss).unwrap().id; + let (status, intimacy, in_group) = (id("relative_status"), id("intimacy"), id("in_group")); + let entries = OntologyStore::open(&onto).unwrap().all().unwrap(); + // Terms that name a register or politeness level. + let levels = [ + "teineigo", "sonkeigo", "kenjogo", "desu/masu", "honorific", "register", + "politeness", "polite", "formal", "informal", "casual", + ]; + for e in &entries { + let lower = e.choice.to_lowercase(); + if levels.iter().any(|t| lower.contains(t)) { + // The seed entries that say they set no level carry "no politeness" or + // follow the rest of the line; every other naming is Scene-conditioned. + let disclaimed = lower.contains("sets no politeness") + || lower.contains("politeness follows the rest") + || lower.contains("politeness follows") + || lower.contains("own register allows"); + assert!( + disclaimed || e.when.iter().any(|c: &Condition| c.slot == Slot::Scene), + "{} names a level without a Scene condition", + e.key() + ); + } + } + let holds = |c: &Condition, rel: (&str, u16, bool)| match (c.feature, &c.test) { + (f, Test::Is(FeatValue::Option(l))) if f == status => l.as_str() == rel.0, + (f, Test::AtLeast(g)) if f == intimacy => rel.1 >= g.get(), + (f, Test::AtMost(g)) if f == intimacy => rel.1 <= g.get(), + (f, Test::Is(FeatValue::Flag(b))) if f == in_group => *b == rel.2, + _ => panic!("a Scene condition this test does not model"), + }; + let selects = |e: &weksa::OntologyEntry, rel| { + e.when.iter().all(|c| c.slot != Slot::Scene || holds(c, rel)) + && e.when.iter().all(|c| c.slot == Slot::Scene) + }; + for st in ["below", "level", "above"] { + for ig in [false, true] { + for it in (0..=1000).step_by(50) { + let rel = (st, it, ig); + let mut seen = std::collections::BTreeSet::new(); + for e in entries.iter().filter(|e| e.when.iter().any(|c| c.slot == Slot::Scene)) { + if selects(e, rel) { + assert!( + seen.insert((e.language.clone(), e.layer.name())), + "{} co-selects with another {} entry at {rel:?}", + e.key(), + e.layer.name() + ); + } + } + } + } + } +} diff --git a/crates/weksa/tests/stores.rs b/crates/weksa/tests/stores.rs index 5b26e85..386178e 100644 --- a/crates/weksa/tests/stores.rs +++ b/crates/weksa/tests/stores.rs @@ -1584,7 +1584,8 @@ fn seed_reseeded() { .unwrap(); assert_eq!(items.len(), 3); // The committed inventory is the seed, reseeded (stance features in, the - // displayed-affect features out), then the nibu-proof revision. + // displayed-affect features out), the nibu-proof revision, the Dao revision + // and the speaker-scene revision: the same four as the other beds. let committed = InventoryStore::open(&root.join("data/interlingua/inventory.cc")) .unwrap() .inventory() @@ -1593,6 +1594,8 @@ fn seed_reseeded() { let (proof, proof_entries) = weksa::inventory::proof_revision(); assert!(committed.has_revision(rev.n) && committed.has_revision(proof.n)); entries.extend(proof_entries); + entries.extend(weksa::daodejing::revision().1); + entries.extend(weksa::inventory::speaker_scene_revision(4).1); let mut have: Vec<_> = committed.entries().cloned().collect(); let mut want = entries; have.sort_by_key(|e| e.id); diff --git a/data/interlingua/inventory.cc b/data/interlingua/inventory.cc index cf353db..7018ee5 100644 Binary files a/data/interlingua/inventory.cc and b/data/interlingua/inventory.cc differ diff --git a/data/ontology/ontology.cc b/data/ontology/ontology.cc index de60651..b4a032b 100644 Binary files a/data/ontology/ontology.cc and b/data/ontology/ontology.cc differ diff --git a/data/original/speaker-state.cc b/data/original/speaker-state.cc index 91aa9e5..c4f563d 100644 Binary files a/data/original/speaker-state.cc and b/data/original/speaker-state.cc differ