From 71b9d0e0559a5ebd7aae99cf5a295e2443305c08 Mon Sep 17 00:00:00 2001 From: Weksa Date: Thu, 12 Nov 2026 16:48:52 +0000 Subject: [PATCH] language-ontology-scene fix: default bed carries rev 3-4, scene entries never co-select in a layer, en-US:8 names no register, keeper rank re-derived from situation, README and doc true Co-Authored-By: Claude Sonnet 5.5 --- README.md | 9 ++- crates/weksa/src/inventory.rs | 2 +- crates/weksa/tests/original_corpus.rs | 104 +++++++++++++++++++++++--- crates/weksa/tests/stores.rs | 5 +- data/interlingua/inventory.cc | Bin 7967 -> 11369 bytes data/ontology/ontology.cc | Bin 11425 -> 11501 bytes data/original/speaker-state.cc | Bin 15341 -> 19417 bytes 7 files changed, 104 insertions(+), 16 deletions(-) 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 cf353dbe05112cf2edefb596b06a4e009e41515c..7018ee525bd4b3e946aa0ac75375195ff4be4521 100644 GIT binary patch delta 2566 zcmaJ?U2hvz5XG^hBqXJxYD*JT#W6@lB@plR`fCvtc>y6oc_>H~LRww#PV9yCuC=?i zo2MxMfa%;=j|i1FD*gm_KYi~t;l@ zf6uIaKDe*hmIfV9k;u1;+hlEFV|fxkB2uofBcYF_iXxYla_!S67lz4yic}o+4byz| zW%kiv_AnsXJRKvA8ny)j1_hWmxI7n`JjjQ3$J^&XWOuQ!%^_H2rO}?KjC{3NkT}3g zObYp4AMh7oaXA#J90-#+)XNO2JaIh-tftqRLz3f_e31jP=_>bHfP3?xt+N7%Z9~-u z?079fVl9yP7ME#@kyx7=u4>v=Qw2-!I)>F0@bv&+X=|~ z+vKx__0`k>s2C8w%@MvbBSgg?T1K-4uBXB+4NMcL_jpMtv=HAsrVmK+``80V0EHep zbyNsVJf{n4-*$9YK$7D#d4}G5!kEM?jvg7x-0YUayVXhNbf! z3k_P}5?q)isQW=jg4=L1&HkJvPjk;_Ld10ru{)gX0rt8MC{q2Q119#29;mKIpSg$Q zk2;=VTP_L6?7nY84@@67>>k|qZ)jjaju=aat0_lh@@rg*S7#|u@yMV{)5hAq{~q;C z%0driA|rD7+@8$-rW9(^vAdnoyC!ZXI#`C#@*i>{WJUz~(X}KUmQD{q zENOhB6P!FJ$5IBn@D9g#g<&k+2feG&*4ftolF*H4a3r5FB=UqhLe=b+?RaVD@Az8F zF!c%DF%w+caqq#t-KAFx>s{0HqhBy}aBio%PySxIo+E#*E(II-8kg_I;dsx%ZBXR9 zSo12dt*26G8=~7XMB_T#!e4t1r?tvo7LR=Q&iV#)rI(6-FM9DJzrn^O92wN~{bg7pmw@=3|mzhYC$Tr=&mm4hOfG(ei?#)UwpP tk^>W%4!|``o+zQWxsQW`adS1-4(7>g`RXVC6XM+LDd^0ySzP?35CFC2CVv0` diff --git a/data/ontology/ontology.cc b/data/ontology/ontology.cc index de60651eee63b177ed211e20a5b8bd5ac5394d66..b4a032b09c4c58e54f0aa6327e44508aee8fd6ee 100644 GIT binary patch delta 494 zcmZ1&`8INcI3ufxxs`$GW*J5oMp-a3>L?TcjHRi0x}m{bEGu0yi<9$9i;7bxO*WJ? zoE$D|x_JxJ37D=%mOv(`0oU1hpv=WDIADTrxfEbZg?PFd1)vr%NWC&%P|70t=_G=%kB9n;cMlS?x5^Q;sS70MHfaurJQ z^HLScGfOfQiu2P-Qu9(%6bdqm5{onQ(kJ%{ONwm`Nz6`Fs08{;p(HamRYxH|JF(J! z@jzUpt zdS-D+YLP;DW=V!Za(-S(Q6gAju|i^Aib8s7UP(@>LS}A3YEfcIW?5>n-ozaqsg*hk zC5hQU@e+m9#Nx`ycZIblE2z6n77%8e>?NWK^+$v@{2OlGxHL2 zbivY0lMfo$O*UYZn#^w?Jh{L;Y_f-rz~;k@25ev>l8RCjQ*avrmWCKnz%DgeOek}5 zzM#NnW)3A5u=cc~{NfVa+QHHw?FT{H7Mt=gf@sc+#G<79(jtgHX{gIDPul=@IaC3v z#R0kkn_YRum?zuwiLewWLUc<(bzhpc9y>F6k!{TeseoyeoGdDoHTl1k@a7YuvFww9 zmU9#*W+&!B9WDzs;_9?b$VNbvz|CM{4w@`rkg-`+R*rG9s;oT3*-B8ox2A1J(VLN( zn_rojlCNt7GXNCpnUim+32zRQQ(^{sT$ru6G&d9C3nmkb$^G)8EIdQcSq*UJPu zx?5403FPR>bCuX3w&HMcNn&=st_jRS$;k>zS)1o6pW+5alK@9fVoFLXG@`-Q>4`HU z>^j2(PELy}^dadYCo!)iwFnxy=cH|ZWy#D00M-aM Ag#Z8m delta 115 zcmcaPo$+n?gr$rY8<+7iZr;!2z&6>yMqslvml6wzu{e^SadLp2z~)LpG3Lnzy26_` zhzc@I{?8$>`Jsdr^JZPy81~I`Rpl5b?=unJ{6<}gd9$338q?+o{ZrhVf%+LY2iWPb TOy18Vuz8xZ8SCb2p3F=Dv$G|E