From 6e0a2f4857fa660d9bc06f9c6abde62500e1bab7 Mon Sep 17 00:00:00 2001 From: Weksa Date: Thu, 12 Nov 2026 18:45:32 +0000 Subject: [PATCH 01/41] encode prompt: state V11's one-role rule and the group referent that coordinates fillers Item original-ja:19 is refused V11DuplicateRole in every round because the encoder prompt never stated the rule. The prompt now says a role holds one filler, coordinated fillers are one group referent, each member related by member_of from member to group. Validator and data untouched; the prompt digest changes by design. Co-Authored-By: Claude Sonnet 5.5 --- crates/weksa/src/context.rs | 2 +- crates/weksa/src/encode.rs | 33 +++++++++++++++++++++++++++++++++ docs/interlingua-standard.md | 4 ++++ 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/crates/weksa/src/context.rs b/crates/weksa/src/context.rs index 3dec960..70d875a 100644 --- a/crates/weksa/src/context.rs +++ b/crates/weksa/src/context.rs @@ -64,7 +64,7 @@ Fields: - predications: a list of {id, concept, frame, roles, features}; roles is a list of {role, filler}, filler a node id. - relations: a list of {relation, from, to, features}. - stance: {features}; the speaker's felt affect and restraint, never the affect the line displays. -Node ids are n1, n2, and so on, one per referent and predication. Every other id comes from the inventory listed below and must be live at its revision. Write each id in full, exactly as the inventory lines spell it, family prefix included: concept:7, never 7. An entity comes only from the entities line. A referent's concept is never null, even when it carries an entity: give the nearest concept id. Participants and audience list the node ids of referents, never an entity id: an entity speaker is a referent whose entity field holds it, and participants lists that referent's node id. +Node ids are n1, n2, and so on, one per referent and predication. Every other id comes from the inventory listed below and must be live at its revision. Write each id in full, exactly as the inventory lines spell it, family prefix included: concept:7, never 7. An entity comes only from the entities line. A referent's concept is never null, even when it carries an entity: give the nearest concept id. Participants and audience list the node ids of referents, never an entity id: an entity speaker is a referent whose entity field holds it, and participants lists that referent's node id. A predication holds each role at most once, and a feature list each feature at most once: two or more fillers of one role are one referent of kind group that fills the role, and each member is related to it by a member_of relation from the member to the group. A feature is {feature, value}; value is {\"Grade\": 0 to 1000}, {\"Option\": label} or {\"Flag\": true or false}, as the inventory lists the feature's kind."; /// The instructions a lowering prompt starts with: the lowerer's whole brief. diff --git a/crates/weksa/src/encode.rs b/crates/weksa/src/encode.rs index d6b22db..1ddabd3 100644 --- a/crates/weksa/src/encode.rs +++ b/crates/weksa/src/encode.rs @@ -474,6 +474,39 @@ mod tests { assert_eq!(PacketDraft::of(&made), draft); } + #[test] + fn coordinated_fillers_admit_as_one_group_referent() { + use crate::store::InventoryStore; + use crate::validate::{Refusal, validate}; + // Item original-ja:19 as measure-ja-2 recorded it: two patients, one role twice. + const REFUSED: &str = r#"{"confidence":720,"context":{"setting":null,"medium":null,"participants":["n1"],"audience":["n1"]},"discourse":{"speech_act":"speech_act:3","addressee":null,"addressee_consent":null,"features":[]},"referents":[{"id":"n1","kind":"referent_kind:1","concept":"concept:28","entity":"entity:keeper","features":[]},{"id":"n2","kind":"referent_kind:1","concept":"concept:31","entity":null,"features":[]},{"id":"n3","kind":"referent_kind:5","concept":"concept:123","entity":null,"features":[]},{"id":"n4","kind":"referent_kind:5","concept":"concept:123","entity":null,"features":[]}],"predications":[{"id":"n5","concept":"concept:26","frame":"frame:4","roles":[{"role":"role:1","filler":"n1"},{"role":"role:2","filler":"n3"},{"role":"role:2","filler":"n4"}],"features":[{"feature":"feature:1","value":{"Option":"positive"}},{"feature":"feature:2","value":{"Option":"present"}},{"feature":"feature:3","value":{"Option":"habitual"}}]},{"id":"n6","concept":"concept:196","frame":"frame:4","roles":[{"role":"role:1","filler":"n1"},{"role":"role:2","filler":"n5"}],"features":[{"feature":"feature:1","value":{"Option":"positive"}},{"feature":"feature:2","value":{"Option":"future"}},{"feature":"feature:4","value":{"Option":"desired"}}]}],"relations":[{"relation":"relation:11","from":"n2","to":"n3","features":[]},{"relation":"relation:11","from":"n1","to":"n4","features":[]}],"stance":{"features":[{"feature":"feature:18","value":{"Grade":600}},{"feature":"feature:11","value":{"Grade":450}},{"feature":"feature:17","value":{"Grade":250}}]}}"#; + const PRESCRIBED: &str = r#"{"confidence":720,"context":{"setting":null,"medium":null,"participants":["n1"],"audience":["n1"]},"discourse":{"speech_act":"speech_act:3","addressee":null,"addressee_consent":null,"features":[]},"referents":[{"id":"n1","kind":"referent_kind:1","concept":"concept:28","entity":"entity:keeper","features":[]},{"id":"n2","kind":"referent_kind:1","concept":"concept:31","entity":null,"features":[]},{"id":"n3","kind":"referent_kind:5","concept":"concept:123","entity":null,"features":[]},{"id":"n4","kind":"referent_kind:5","concept":"concept:123","entity":null,"features":[]},{"id":"n7","kind":"referent_kind:2","concept":"concept:123","entity":null,"features":[]}],"predications":[{"id":"n5","concept":"concept:26","frame":"frame:4","roles":[{"role":"role:1","filler":"n1"},{"role":"role:2","filler":"n7"}],"features":[{"feature":"feature:1","value":{"Option":"positive"}},{"feature":"feature:2","value":{"Option":"present"}},{"feature":"feature:3","value":{"Option":"habitual"}}]},{"id":"n6","concept":"concept:196","frame":"frame:4","roles":[{"role":"role:1","filler":"n1"},{"role":"role:2","filler":"n5"}],"features":[{"feature":"feature:1","value":{"Option":"positive"}},{"feature":"feature:2","value":{"Option":"future"}},{"feature":"feature:4","value":{"Option":"desired"}}]}],"relations":[{"relation":"relation:11","from":"n2","to":"n3","features":[]},{"relation":"relation:11","from":"n1","to":"n4","features":[]},{"relation":"relation:3","from":"n3","to":"n7","features":[]},{"relation":"relation:3","from":"n4","to":"n7","features":[]}],"stance":{"features":[{"feature":"feature:18","value":{"Grade":600}},{"feature":"feature:11","value":{"Grade":450}},{"feature":"feature:17","value":{"Grade":250}}]}}"#; + let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR")) + .join("../../data/original/inventory.cc"); + let inventory = InventoryStore::open(&path).unwrap().inventory().unwrap(); + let item = CorpusItemId::parse("item:original-ja:19").unwrap(); + let encoder = encoder_id("m", "d"); + let packet = |answer: &str| { + PacketDraft::parse(answer) + .unwrap() + .into_packet(&item, 6, &encoder) + }; + assert_eq!( + validate(&packet(REFUSED), &inventory), + Err(vec![Refusal::V11DuplicateRole { + role: "role:2".parse().unwrap(), + predication: "n5".parse().unwrap(), + }]) + ); + assert_eq!(validate(&packet(PRESCRIBED), &inventory), Ok(())); + // The prompt names the shape the packet above admits, by gloss. + let gloss = |id: &str| inventory.entry(&id.parse().unwrap()).unwrap().gloss.clone(); + assert_eq!(gloss("referent_kind:2"), "group"); + assert_eq!(gloss("relation:3"), "member_of"); + let prompt = crate::context::ENCODE_INSTRUCTIONS; + assert!(prompt.contains("member_of") && prompt.contains("group")); + } + #[test] fn lowering_draft_parse() { let draft = LoweringDraft::parse("\n {\"text\":\"a\"} \n").unwrap(); diff --git a/docs/interlingua-standard.md b/docs/interlingua-standard.md index 548862c..f8e7937 100644 --- a/docs/interlingua-standard.md +++ b/docs/interlingua-standard.md @@ -252,6 +252,10 @@ pair a role id with a filler node (the inventory seeds `agent`, `patient`, aspect, polarity, modality and evidentiality are features with declared option sets, not fields. +A predication holds each role once (V11). Coordinated fillers ("A and B") are +one `group` referent filling the role, each member related to it by `member_of`, +from the member to the group. + ### `relations` Edges not owned by one predication. `relation` is a relation id (the inventory From 07c2755b95fcd04a74f4f9a6e3f3ede7ca334f71 Mon Sep 17 00:00:00 2001 From: Weksa Date: Thu, 12 Nov 2026 18:48:40 +0000 Subject: [PATCH 02/41] ja-item19: encoder prompt states one role per predication and the group shape for coordination (#56) --- crates/weksa/src/context.rs | 2 +- crates/weksa/src/encode.rs | 33 +++++++++++++++++++++++++++++++++ docs/interlingua-standard.md | 4 ++++ 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/crates/weksa/src/context.rs b/crates/weksa/src/context.rs index 3dec960..70d875a 100644 --- a/crates/weksa/src/context.rs +++ b/crates/weksa/src/context.rs @@ -64,7 +64,7 @@ Fields: - predications: a list of {id, concept, frame, roles, features}; roles is a list of {role, filler}, filler a node id. - relations: a list of {relation, from, to, features}. - stance: {features}; the speaker's felt affect and restraint, never the affect the line displays. -Node ids are n1, n2, and so on, one per referent and predication. Every other id comes from the inventory listed below and must be live at its revision. Write each id in full, exactly as the inventory lines spell it, family prefix included: concept:7, never 7. An entity comes only from the entities line. A referent's concept is never null, even when it carries an entity: give the nearest concept id. Participants and audience list the node ids of referents, never an entity id: an entity speaker is a referent whose entity field holds it, and participants lists that referent's node id. +Node ids are n1, n2, and so on, one per referent and predication. Every other id comes from the inventory listed below and must be live at its revision. Write each id in full, exactly as the inventory lines spell it, family prefix included: concept:7, never 7. An entity comes only from the entities line. A referent's concept is never null, even when it carries an entity: give the nearest concept id. Participants and audience list the node ids of referents, never an entity id: an entity speaker is a referent whose entity field holds it, and participants lists that referent's node id. A predication holds each role at most once, and a feature list each feature at most once: two or more fillers of one role are one referent of kind group that fills the role, and each member is related to it by a member_of relation from the member to the group. A feature is {feature, value}; value is {\"Grade\": 0 to 1000}, {\"Option\": label} or {\"Flag\": true or false}, as the inventory lists the feature's kind."; /// The instructions a lowering prompt starts with: the lowerer's whole brief. diff --git a/crates/weksa/src/encode.rs b/crates/weksa/src/encode.rs index d6b22db..1ddabd3 100644 --- a/crates/weksa/src/encode.rs +++ b/crates/weksa/src/encode.rs @@ -474,6 +474,39 @@ mod tests { assert_eq!(PacketDraft::of(&made), draft); } + #[test] + fn coordinated_fillers_admit_as_one_group_referent() { + use crate::store::InventoryStore; + use crate::validate::{Refusal, validate}; + // Item original-ja:19 as measure-ja-2 recorded it: two patients, one role twice. + const REFUSED: &str = r#"{"confidence":720,"context":{"setting":null,"medium":null,"participants":["n1"],"audience":["n1"]},"discourse":{"speech_act":"speech_act:3","addressee":null,"addressee_consent":null,"features":[]},"referents":[{"id":"n1","kind":"referent_kind:1","concept":"concept:28","entity":"entity:keeper","features":[]},{"id":"n2","kind":"referent_kind:1","concept":"concept:31","entity":null,"features":[]},{"id":"n3","kind":"referent_kind:5","concept":"concept:123","entity":null,"features":[]},{"id":"n4","kind":"referent_kind:5","concept":"concept:123","entity":null,"features":[]}],"predications":[{"id":"n5","concept":"concept:26","frame":"frame:4","roles":[{"role":"role:1","filler":"n1"},{"role":"role:2","filler":"n3"},{"role":"role:2","filler":"n4"}],"features":[{"feature":"feature:1","value":{"Option":"positive"}},{"feature":"feature:2","value":{"Option":"present"}},{"feature":"feature:3","value":{"Option":"habitual"}}]},{"id":"n6","concept":"concept:196","frame":"frame:4","roles":[{"role":"role:1","filler":"n1"},{"role":"role:2","filler":"n5"}],"features":[{"feature":"feature:1","value":{"Option":"positive"}},{"feature":"feature:2","value":{"Option":"future"}},{"feature":"feature:4","value":{"Option":"desired"}}]}],"relations":[{"relation":"relation:11","from":"n2","to":"n3","features":[]},{"relation":"relation:11","from":"n1","to":"n4","features":[]}],"stance":{"features":[{"feature":"feature:18","value":{"Grade":600}},{"feature":"feature:11","value":{"Grade":450}},{"feature":"feature:17","value":{"Grade":250}}]}}"#; + const PRESCRIBED: &str = r#"{"confidence":720,"context":{"setting":null,"medium":null,"participants":["n1"],"audience":["n1"]},"discourse":{"speech_act":"speech_act:3","addressee":null,"addressee_consent":null,"features":[]},"referents":[{"id":"n1","kind":"referent_kind:1","concept":"concept:28","entity":"entity:keeper","features":[]},{"id":"n2","kind":"referent_kind:1","concept":"concept:31","entity":null,"features":[]},{"id":"n3","kind":"referent_kind:5","concept":"concept:123","entity":null,"features":[]},{"id":"n4","kind":"referent_kind:5","concept":"concept:123","entity":null,"features":[]},{"id":"n7","kind":"referent_kind:2","concept":"concept:123","entity":null,"features":[]}],"predications":[{"id":"n5","concept":"concept:26","frame":"frame:4","roles":[{"role":"role:1","filler":"n1"},{"role":"role:2","filler":"n7"}],"features":[{"feature":"feature:1","value":{"Option":"positive"}},{"feature":"feature:2","value":{"Option":"present"}},{"feature":"feature:3","value":{"Option":"habitual"}}]},{"id":"n6","concept":"concept:196","frame":"frame:4","roles":[{"role":"role:1","filler":"n1"},{"role":"role:2","filler":"n5"}],"features":[{"feature":"feature:1","value":{"Option":"positive"}},{"feature":"feature:2","value":{"Option":"future"}},{"feature":"feature:4","value":{"Option":"desired"}}]}],"relations":[{"relation":"relation:11","from":"n2","to":"n3","features":[]},{"relation":"relation:11","from":"n1","to":"n4","features":[]},{"relation":"relation:3","from":"n3","to":"n7","features":[]},{"relation":"relation:3","from":"n4","to":"n7","features":[]}],"stance":{"features":[{"feature":"feature:18","value":{"Grade":600}},{"feature":"feature:11","value":{"Grade":450}},{"feature":"feature:17","value":{"Grade":250}}]}}"#; + let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR")) + .join("../../data/original/inventory.cc"); + let inventory = InventoryStore::open(&path).unwrap().inventory().unwrap(); + let item = CorpusItemId::parse("item:original-ja:19").unwrap(); + let encoder = encoder_id("m", "d"); + let packet = |answer: &str| { + PacketDraft::parse(answer) + .unwrap() + .into_packet(&item, 6, &encoder) + }; + assert_eq!( + validate(&packet(REFUSED), &inventory), + Err(vec![Refusal::V11DuplicateRole { + role: "role:2".parse().unwrap(), + predication: "n5".parse().unwrap(), + }]) + ); + assert_eq!(validate(&packet(PRESCRIBED), &inventory), Ok(())); + // The prompt names the shape the packet above admits, by gloss. + let gloss = |id: &str| inventory.entry(&id.parse().unwrap()).unwrap().gloss.clone(); + assert_eq!(gloss("referent_kind:2"), "group"); + assert_eq!(gloss("relation:3"), "member_of"); + let prompt = crate::context::ENCODE_INSTRUCTIONS; + assert!(prompt.contains("member_of") && prompt.contains("group")); + } + #[test] fn lowering_draft_parse() { let draft = LoweringDraft::parse("\n {\"text\":\"a\"} \n").unwrap(); diff --git a/docs/interlingua-standard.md b/docs/interlingua-standard.md index 548862c..f8e7937 100644 --- a/docs/interlingua-standard.md +++ b/docs/interlingua-standard.md @@ -252,6 +252,10 @@ pair a role id with a filler node (the inventory seeds `agent`, `patient`, aspect, polarity, modality and evidentiality are features with declared option sets, not fields. +A predication holds each role once (V11). Coordinated fillers ("A and B") are +one `group` referent filling the role, each member related to it by `member_of`, +from the member to the group. + ### `relations` Edges not owned by one predication. `relation` is a relation id (the inventory From 40469430b9c5a3f8322ee76bbb837ffe575efe65 Mon Sep 17 00:00:00 2001 From: Weksa Date: Thu, 12 Nov 2026 19:17:39 +0000 Subject: [PATCH 03/41] ja-withdraw-scene-entries: withdraw onto:ja-JP:14 and :15 (net-negative on register in the paired measure) (#57) --- README.md | 6 +++++- crates/weksa/tests/original_corpus.rs | 17 ++++++++++++++--- data/ontology/ontology.cc | Bin 12856 -> 11710 bytes docs/targets/interlingua-lowering-map.md | 2 +- 4 files changed, 20 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 091bcd6..6702748 100644 --- a/README.md +++ b/README.md @@ -90,7 +90,11 @@ The language ontology is `data/ontology/ontology.cc` (read it with 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`. +rounds; until that mint exists they change only by a new `weksa ontology admit`. ja-JP holds Scene entries `onto:ja-JP:10` to `:13`. It holds none for an above-status out-group +addressee, and none for an above-status in-group addressee below intimacy 700 (`:12` still selects +an in-group addressee at intimacy 700 or more, whatever the status). Two entries for the above-status +cases were withdrawn: a paired measure found they made the lowerer match the reference register less +often, and they stay out until a native reader attests them. For the first AquaSynth speech-training handoff, see [Tiny PanPhon v0.1 Speech Curriculum](./examples/speech-training/tiny-panphon-v0.1/README.md). diff --git a/crates/weksa/tests/original_corpus.rs b/crates/weksa/tests/original_corpus.rs index 18b6c49..75b44e9 100644 --- a/crates/weksa/tests/original_corpus.rs +++ b/crates/weksa/tests/original_corpus.rs @@ -1006,15 +1006,26 @@ fn scene_entries_never_co_select_in_a_layer() { ); } } - // An above, out-group speaker is told by exactly one ja-JP - // Scene-conditioned grammar entry, at every intimacy. + // An above, out-group speaker is told by no ja-JP Scene-conditioned + // grammar entry, at every intimacy: the ja entry that did + // (onto:ja-JP:15) is withdrawn pending native-reader attestation. if (st, ig) == ("above", false) { let told = entries .iter() .filter(|e| e.language == "ja-JP" && e.layer.name() == "grammar") .filter(|e| e.when.iter().any(|c| c.slot == Slot::Scene) && selects(e, rel)) .count(); - assert_eq!(told, 1, "{rel:?}"); + assert_eq!(told, 0, "{rel:?}"); + } + // onto:ja-JP:14's relation (above, in-group, intimacy 600) selects + // no ja-JP Scene entry in any layer: :12 needs intimacy 700. + if (st, ig, it) == ("above", true, 600) { + let told = entries + .iter() + .filter(|e| e.language == "ja-JP") + .filter(|e| e.when.iter().any(|c| c.slot == Slot::Scene) && selects(e, rel)) + .count(); + assert_eq!(told, 0, "{rel:?}"); } } } diff --git a/data/ontology/ontology.cc b/data/ontology/ontology.cc index d2e0911754f1fd10dd3575d323abb50c34b69b03..5e7919a7d0786dd5b84ccb75ef2b01542728a879 100644 GIT binary patch delta 368 zcmdmyvM+kV6Go|tPYu{DtW1H(WU~yT6C<3H%H+ZX=WJl{M{wBKxey$2&VL9!GTd?q zjw25nLYW_*FQX9Do~WaY6K5<<&C?AHp4_kHxcMD_B|=x8peKT}PpAOFF%`Lp;P8sA zL2wR;mmoOSl9C8(qosKfoP60^2xS5CuNfzARn>=k@wKWuLe^6KE`lSgnSkK5Xx&6` XQgosaoTIw62#%-zJOt;RffpkHuTfv> delta 1035 zcmZXT+e=hI9LL#3c2o0KqDWrGTZ^`)k|C@`7(rxKMlYccHSHO9kGnf(JLjyMMCh!N z8DiRymj^4$OW92j!dh6P@G+{lHVBMa*R1}AXpWbihu-FM<~zSR^ZCt0+Lol@m??i` zt;SmKsI7I>9$L&d9XBNanNOG#u#j|4fW?|3AUFB1Sd*VxD4=n-Ma0ggpAj>UGFAlO ztWyFad;9_pXMYipmh)V|yIfsBLtdWPr)^)F0HxrYh_w{`Hqq5x7FtwfHPz7{fK^Q`=}B|V=$hxwyN+fW9*USOj*FPpn5rAMrp-S4Bz|GD4?;$Ada zLaGB`1!xNPAlaoDhxQ=cq41%u1fePc-Hm`()^voCYTrC6&nGOlL!a!Gp(^WL##$L~ z)&!bcQFX3OY5?6v0d1=pHVwFCmz#G*)A^)~UBCysjC7DM1wl8|fvf=uIr*PSMnR}~ z42jV)MkX0~84JJWD%R(?%fYo<)A7+4jEphDB~EZz(VCx&{qfNW7P`BmEy9kHIYyqX z^}pRr&T@y0JWTkF78_kLS}?%N$0w(@c8G;%VoSGqkY<+I=&wC&j&8 xF8OZaeb{`V{HEHs`;bH%vnv+AmK_kul>Jcwzih1nPFLIz@Tu~?0NvhX`UhK;jzItb diff --git a/docs/targets/interlingua-lowering-map.md b/docs/targets/interlingua-lowering-map.md index 5d3719a..46c1435 100644 --- a/docs/targets/interlingua-lowering-map.md +++ b/docs/targets/interlingua-lowering-map.md @@ -34,7 +34,7 @@ means no store holds it and nothing writes it. | Inventory entry | Key `:`, `n` canonical decimal >= 1 (families: concept, frame, role, relation, speech_act, feature, referent_kind, extension); type `weksa.inventory_entry`, with a bounded gloss, value kind (option labels bounded), the slots a feature may sit in (`Discourse`, `Referent`, `Predication`, `Relation`; `Stance` from cut `speaker-state`, `Speaker` and `Scene` from cut `speaker-scene`), `introduced_rev` and optional `retired_rev`. Speaker axes, scene relations and affects are features of those slots, so the loop grows them like any closed-class family and convergence covers them | Added or retired by an inventory revision; never edited in place (a changed meaning is a retire plus an add); a retired id still resolves for packets of earlier revisions | The loop's accepted rounds, whose minting call the context builder assembles from Train items only; `weksa inventory admit` for one model-drafted `EditDraft` outside a run (cap 256, reviewed whole in its cut; same numbering and admission check as the loop); Self on merge to main. `data/original` revs 5 (233 concepts and frames) and 6 (five concepts closing named gaps) were drafted by claude-sonnet-5-5 (Weksa Hands, model-drafted original-bed lexicon from Train and Validation passages); Validation-informed: numbers on this bed measure lowering, never generalization or convergence. Residue after rev 6, not amended (each fresh coverage reader names new gaps; the loop's growth path owns them): simultaneity (ながら), distal deixis (あの), 'first' (まず), counterfactual mood, 'at least', emphatic question; heaven versus sky for the visible 天 stays weak. Admission checks form, not text | | Inventory revision | Key `rev:`, type `weksa.inventory_revision`, with parent, change list and `frozen` | Appended per accepted round; exactly one revision is ever marked frozen, by the convergence test | The loop's accept rule appends; the convergence test freezes; Self records the freeze as a ruling | | Target profile | Locale or language-project id (`en-US`, `ja-JP`, a conlang's slug). Until entries grow in rounds there is no profile revision document: a run names the profile it lowered with by the ontology store's path and digest in its `RunRecord` (cut `language-ontology`); `profile::` revision documents arrive with follow-up `language-ontology-growth` | The ontology store is revised by commit; a run pins it and refuses drift; it likewise pins the speaker-state store (`RunRecord` keys 17 and 18, `Drift(SpeakerState)`, cut `language-ontology-scene`) | Profile authors and accepted rounds; never the lowerer's defaults (`persona-drives-register`) | -| Language ontology entry (cut `language-ontology`) | Key `onto::`, `n` from 1 per language; type `weksa.ontology_entry` in `data/ontology/ontology.cc`: the language, the revision of the inventory it was admitted through (provenance: beds number revisions independently and a run reads each condition's feature at its own head), a layer (lexicon, grammar, discourse, phonology, orthography), at most four conditions (a feature id of slot `Stance`, `Discourse` or `Scene` with `AtLeast`/`AtMost` a grade or `Is` an option or flag; a `Scene` condition reads the relation of the item's speaker to its addressee that `with_scene` selected; slot `Speaker` and community ids wait on follow-up `language-ontology-communities`), a choice of 1 to 200 bytes, at most three examples of 1 to 120 bytes, and an `Annotator`. Whether an entry's text keeps politeness on the scene is a model reader's judgment, owed per change (a mint owes it under `language-ontology-growth`), not a test | Admitted in all-or-nothing batches through `OntologyStore::admit`, immutable, never edited; retire arrives with `language-ontology-growth`. The run pins the store like the entity store (path and digest, `Drift(Ontology)`), never copies it, because no loop step writes it yet. Cut `language-ontology-seed` converts by drafting, not by parse: a fresh model drafts each language's seed from that language's YAML and the inventory's feature lines with no corpus text, then deletes `data/target-language-ontology/` and `.weksa/cultural-ontology/` in the same cut | Seed: a labelled model (`Annotator::Model`), no operator gate, never Test evidence (`ja-ontology-owner-answer`); attestation (operator, native reader) appends later. Accepted rounds later, through a mint call from Train items only. Selection is `ontology::select(ontology, language, view)`, called only inside `Prompt::lower`, so no caller picks entries; the prompt prints each selected entry's id, layer, choice and examples. Its text is minted text for the leak diagnostic, which today has no runtime caller (follow-up `leak-diagnostic-in-round`) | +| Language ontology entry (cut `language-ontology`) | Key `onto::`, `n` from 1 per language; type `weksa.ontology_entry` in `data/ontology/ontology.cc`: the language, the revision of the inventory it was admitted through (provenance: beds number revisions independently and a run reads each condition's feature at its own head), a layer (lexicon, grammar, discourse, phonology, orthography), at most four conditions (a feature id of slot `Stance`, `Discourse` or `Scene` with `AtLeast`/`AtMost` a grade or `Is` an option or flag; a `Scene` condition reads the relation of the item's speaker to its addressee that `with_scene` selected; slot `Speaker` and community ids wait on follow-up `language-ontology-communities`), a choice of 1 to 200 bytes, at most three examples of 1 to 120 bytes, and an `Annotator`. Whether an entry's text keeps politeness on the scene is a model reader's judgment, owed per change (a mint owes it under `language-ontology-growth`), not a test | Admitted in all-or-nothing batches through `OntologyStore::admit`, immutable, never edited; retire arrives with `language-ontology-growth`. The run pins the store like the entity store (path and digest, `Drift(Ontology)`), never copies it, because no loop step writes it yet. Cut `language-ontology-seed` converts by drafting, not by parse: a fresh model drafts each language's seed from that language's YAML and the inventory's feature lines with no corpus text, then deletes `data/target-language-ontology/` and `.weksa/cultural-ontology/` in the same cut | Seed: a labelled model (`Annotator::Model`), no operator gate, never Test evidence (`ja-ontology-owner-answer`); attestation (operator, native reader) appends later. Accepted rounds later, through a mint call from Train items only. Selection is `ontology::select(ontology, language, view)`, called only inside `Prompt::lower`, so no caller picks entries; the prompt prints each selected entry's id, layer, choice and examples. Its text is minted text for the leak diagnostic, which today has no runtime caller (follow-up `leak-diagnostic-in-round`). The store was rebuilt without ja-JP `:14` and `:15` (above-status Scene entries; a paired measure found them net-negative on register, follow-up `ja-scene-entries-lower-register-agreement`), so ja-JP ends at `:13`: an above-status out-group addressee, and an above-status in-group addressee below intimacy 700, select no ja-JP Scene entry (`:12` still selects in-group at intimacy 700 or more regardless of status) until a native reader attests a replacement (`ja-native-reader-scenes`) | | Community (cut `language-ontology`, follow-up `language-ontology-communities`) | Key `community:`; type `weksa.community`, converted from `data/cultural-ontology/cultures/` and `referents/` (YAML deleted in the same cut) | Revised by commit; a speaker names the communities it belongs to by id | The cultural ontology's author (owner-attested evidence only; Discord-only content stays deleted, `discord-only-content-deleted`) | | Speaker (cut `speaker-scene`) | Key `speaker:@`; type `weksa.speaker`: stable axes as feature values of slot `Speaker` (origin, socioeconomic standing, age cohort, education and whatever the loop adds), at an inventory revision, and an `Annotator` | A new revision appends, never edits; a corpus item and every prior turn name a speaker slug, and a round records the speaker revisions it read | The annotator it names: `PersonaSnapshot` (a projection of a `gamecult.persona_state.v0` document, naming its source document and `updatedAt`), `Operator`, `WorkMetadata` (a public-domain work's own cast list and narration), or `Model { family, generator }` (the 2b `ModelFamily`) | | Scene (cut `speaker-scene`) | Key `scene:@`, the item's split group; type `weksa.scene`: participants (speaker slugs) and, per ordered pair, relation features of slot `Scene` (relative status, intimacy, in-group, audience and whatever the loop adds), at an inventory revision (provenance; a run reads the features at its own head), and an `Annotator` | As Speaker. Keyed by the group, so a scene never straddles the split. `data/original/speaker-state.cc` holds Model-annotated keeper scenes, one per Train or Validation group of both languages (`weksa scene put|dump`); a Test group has none and reads `NoScene` | As Speaker; a model-annotated scene is never Test evidence | From 981ad0ea1fccae41d384411ec270ef2c2e14a647 Mon Sep 17 00:00:00 2001 From: Weksa Date: Thu, 12 Nov 2026 19:52:14 +0000 Subject: [PATCH 04/41] ja-seed-pairs: ja-JP :5/:7/:8 get certainty and restraint bounds (AtMostOrUnset) so the seed pairs never co-select (#58) --- README.md | 1 + crates/weksa/src/ontology.rs | 43 ++++++++- crates/weksa/src/store.rs | 2 +- crates/weksa/tests/original_corpus.rs | 89 ++++++++++++++++++ data/ontology/ontology.cc | Bin 11710 -> 11945 bytes docs/targets/interlingua-lowering-map.md | 2 +- .../cultnet/weksa.ontology_entry.schema.json | 13 +++ 7 files changed, 143 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 6702748..3b02136 100644 --- a/README.md +++ b/README.md @@ -95,6 +95,7 @@ addressee, and none for an above-status in-group addressee below intimacy 700 (` an in-group addressee at intimacy 700 or more, whatever the status). Two entries for the above-status cases were withdrawn: a paired measure found they made the lowerer match the reference register less often, and they stay out until a native reader attests them. +ja-JP `:5` (hedging), `:7` (affection) and `:8` (restrained sadness) carry certainty and restraint conditions, through `AtMostOrUnset` bounds (an unrated certainty or restraint does not defeat them), so the hedging, certainty, affection, restraint and sadness entries never co-select on the pairs `:5`/`:6`, `:4`/`:7`, `:6`/`:7` and `:6`/`:8`; the store has no retire, so that was a rebuild of `data/ontology/ontology.cc` with the ja-JP text unchanged. For the first AquaSynth speech-training handoff, see [Tiny PanPhon v0.1 Speech Curriculum](./examples/speech-training/tiny-panphon-v0.1/README.md). diff --git a/crates/weksa/src/ontology.rs b/crates/weksa/src/ontology.rs index 5919588..154c562 100644 --- a/crates/weksa/src/ontology.rs +++ b/crates/weksa/src/ontology.rs @@ -49,6 +49,10 @@ pub enum Test { AtLeast(Grade), AtMost(Grade), Is(FeatValue), + /// Holds when the feature is absent or a grade at most `g`: a bound that + /// costs nothing where the feature is unrated. `AtMost` still fails on an + /// absent feature. + AtMostOrUnset(Grade), } /// One feature of one slot of the view, tested. `Stance`, `Discourse` and @@ -61,13 +65,15 @@ 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 false; + return matches!(self.test, Test::AtMostOrUnset(_)); }; match (&self.test, &found.value) { (Test::AtLeast(g), FeatValue::Grade(v)) => v >= g, - (Test::AtMost(g), FeatValue::Grade(v)) => v <= g, + (Test::AtMost(g) | Test::AtMostOrUnset(g), FeatValue::Grade(v)) => v <= g, (Test::Is(want), v) => want == v, _ => false, } @@ -78,7 +84,7 @@ impl Condition { FeatureValue { feature: self.feature, value: match &self.test { - Test::AtLeast(g) | Test::AtMost(g) => FeatValue::Grade(*g), + Test::AtLeast(g) | Test::AtMost(g) | Test::AtMostOrUnset(g) => FeatValue::Grade(*g), Test::Is(v) => v.clone(), }, } @@ -153,7 +159,7 @@ impl Ontology { /// The entries of exactly `language` whose every condition holds against the /// view's stance, discourse and scene-relation features (the scene's only when /// `with_scene` selected a relation), in `n` order. An absent feature meets no -/// condition. Nothing else of the view is read. +/// condition except `AtMostOrUnset`. Nothing else of the view is read. pub fn select<'a>( o: &'a Ontology, language: &str, @@ -172,3 +178,30 @@ pub fn select<'a>( }) .collect() } + +#[cfg(test)] +mod tests { + use super::*; + + fn cond(test: Test) -> Condition { + Condition { slot: Slot::Discourse, feature: InvId::parse("feature:7").unwrap(), test } + } + fn has(v: FeatValue) -> Vec { + vec![FeatureValue { feature: InvId::parse("feature:7").unwrap(), value: v }] + } + fn grade(g: u16) -> Grade { + Grade::new(g).unwrap() + } + + #[test] + fn at_most_or_unset_holds_when_absent_or_at_most_and_nothing_else() { + let c = cond(Test::AtMostOrUnset(grade(799))); + assert!(c.holds(&[])); + assert!(c.holds(&has(FeatValue::Grade(grade(799))))); + assert!(c.holds(&has(FeatValue::Grade(grade(0))))); + assert!(!c.holds(&has(FeatValue::Grade(grade(800))))); + assert!(!c.holds(&has(FeatValue::Flag(true)))); + // AtMost keeps its meaning: an absent feature fails it. + assert!(!cond(Test::AtMost(grade(799))).holds(&[])); + } +} diff --git a/crates/weksa/src/store.rs b/crates/weksa/src/store.rs index 7408dce..b0b83a9 100644 --- a/crates/weksa/src/store.rs +++ b/crates/weksa/src/store.rs @@ -1287,7 +1287,7 @@ impl OntologyStore { /// The rules of one ontology entry against an inventory: the annotator, the /// bounded and normalized text of the choice and examples, the condition count /// and each condition's feature (slot `Stance`, `Discourse` or `Scene`, a grade -/// feature for `AtLeast` and `AtMost`, an option or flag value for `Is`) read at +/// feature for `AtLeast`, `AtMost` and `AtMostOrUnset`, an option or flag value for `Is`) read at /// `rev`. The store passes the entry's own `inventory_rev` on admission; a run /// passes its inventory's head, because beds number revisions independently. pub(crate) fn check_ontology_entry( diff --git a/crates/weksa/tests/original_corpus.rs b/crates/weksa/tests/original_corpus.rs index 75b44e9..715233c 100644 --- a/crates/weksa/tests/original_corpus.rs +++ b/crates/weksa/tests/original_corpus.rs @@ -313,6 +313,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)", + "claude-sonnet-5-5 (Weksa Hands, conditioned seed entry)", ] .contains(&generator.as_str()), "{}", @@ -960,6 +961,94 @@ fn committed_scenes_cover_original_groups() { } } +/// ja-JP seed entries :4 to :8 over the stance and discourse grades that bear on +/// them (hedge, certainty, sadness, affection, restraint, each also ABSENT): +/// the pairs that gave opposed instructions (hedge against certainty, +/// particles, final force) never hold together; and each of :5, :7, :8 still +/// fires where it should (hedged at certainty 700-799, affection with certainty +/// or restraint unrated), so a tightened bound does not pass as a disjoint one. +#[test] +fn ja_seed_pairs_never_co_select() { + use weksa::inventory::Slot; + use weksa::ontology::{Condition, Test}; + 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 feats = [id("hedge"), id("certainty"), id("sadness"), id("affection"), id("restraint")]; + let entries = OntologyStore::open(&onto).unwrap().all().unwrap(); + let ja = |n: u32| { + entries + .iter() + .find(|e| e.language == "ja-JP" && e.n == n) + .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()); + assert!( + matches!(c.test, Test::AtLeast(_) | Test::AtMost(_) | Test::AtMostOrUnset(_)), + "{}", + e.key() + ); + let values: Vec = feats + .iter() + .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)]; + let pairs = [(5, 6), (4, 7), (6, 7), (6, 8)]; + for p in 0..grid.len().pow(5) { + let point: Point = std::array::from_fn(|i| grid[p / grid.len().pow(i as u32) % grid.len()]); + for (a, b) in pairs { + assert!( + !(holds(ja(a), &point) && holds(ja(b), &point)), + "onto:ja-JP:{a} and :{b} co-select at (hedge, certainty, sadness, affection, restraint) = {point:?}" + ); + } + } + // Reach: each entry fires at its witnesses and not just outside its core. + let (n, s) = (None, Some); + 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)]), + (7, [n, n, n, s(700), n]), + (7, [s(1000), s(0), s(1000), s(600), s(0)]), + (8, [n, s(799), s(700), n, s(700)]), + (8, [n, n, s(600), n, s(600)]), + (6, [n, s(800), n, n, n]), + ]; + for (e, point) in fires { + assert!(holds(ja(e), &point), "onto:ja-JP:{e} does not fire at {point:?}"); + } + 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)]), + (8, [n, n, s(600), n, s(599)]), + ]; + for (e, point) in silent { + assert!(!holds(ja(e), &point), "onto:ja-JP:{e} fires at {point:?}"); + } +} + /// The committed ontology's Scene-conditioned entries, over every scene relation /// (relative_status x in_group x intimacy in steps of 50): two entries of one /// language and layer are never selected by the same relation, so the ontology diff --git a/data/ontology/ontology.cc b/data/ontology/ontology.cc index 5e7919a7d0786dd5b84ccb75ef2b01542728a879..a6d2edd0651d0eeceee77f2cd666baa3aa0ba92d 100644 GIT binary patch delta 622 zcmdlNy)t%#C?mV2m9epvvEgPJMkfR(mC1z(F0+BfAHiW`=R$DAIsYN_$Z*RcIF3AQ z2xWeJz6hB`{6`U-JV8$cXP;03f@3Oj5y9aVTZ7;n5HCS+tR*E8_C!nbA~^Z7w-Cw# z2B``a05+52!1{1NoJD6r(J{sy$Gv*cq4mq*i1C^-Z3fsA)J^LR(D`%?74$ wyw*>iqR delta 450 zcmZ1(yDxf!C?mUtl_?OJY?fhkLU2-2^AnXrXm*+9A2?C2+jfV5(LLuQW9ZLv@|b*lP`M?oo+`K>1V=KCrtj6w(nOQ8xTujO~# z+^?p=IC-9`)8s$u%JAS)(}+Sg(G#kH9cZG>WP7a(U=1PK%JK+9v!H4?7+1Pv7ANPI g78R#XntV=Ee)3jr=gEdT`@wolbrF`t>v}N)05#ovoB#j- diff --git a/docs/targets/interlingua-lowering-map.md b/docs/targets/interlingua-lowering-map.md index 46c1435..b436b3b 100644 --- a/docs/targets/interlingua-lowering-map.md +++ b/docs/targets/interlingua-lowering-map.md @@ -34,7 +34,7 @@ means no store holds it and nothing writes it. | Inventory entry | Key `:`, `n` canonical decimal >= 1 (families: concept, frame, role, relation, speech_act, feature, referent_kind, extension); type `weksa.inventory_entry`, with a bounded gloss, value kind (option labels bounded), the slots a feature may sit in (`Discourse`, `Referent`, `Predication`, `Relation`; `Stance` from cut `speaker-state`, `Speaker` and `Scene` from cut `speaker-scene`), `introduced_rev` and optional `retired_rev`. Speaker axes, scene relations and affects are features of those slots, so the loop grows them like any closed-class family and convergence covers them | Added or retired by an inventory revision; never edited in place (a changed meaning is a retire plus an add); a retired id still resolves for packets of earlier revisions | The loop's accepted rounds, whose minting call the context builder assembles from Train items only; `weksa inventory admit` for one model-drafted `EditDraft` outside a run (cap 256, reviewed whole in its cut; same numbering and admission check as the loop); Self on merge to main. `data/original` revs 5 (233 concepts and frames) and 6 (five concepts closing named gaps) were drafted by claude-sonnet-5-5 (Weksa Hands, model-drafted original-bed lexicon from Train and Validation passages); Validation-informed: numbers on this bed measure lowering, never generalization or convergence. Residue after rev 6, not amended (each fresh coverage reader names new gaps; the loop's growth path owns them): simultaneity (ながら), distal deixis (あの), 'first' (まず), counterfactual mood, 'at least', emphatic question; heaven versus sky for the visible 天 stays weak. Admission checks form, not text | | Inventory revision | Key `rev:`, type `weksa.inventory_revision`, with parent, change list and `frozen` | Appended per accepted round; exactly one revision is ever marked frozen, by the convergence test | The loop's accept rule appends; the convergence test freezes; Self records the freeze as a ruling | | Target profile | Locale or language-project id (`en-US`, `ja-JP`, a conlang's slug). Until entries grow in rounds there is no profile revision document: a run names the profile it lowered with by the ontology store's path and digest in its `RunRecord` (cut `language-ontology`); `profile::` revision documents arrive with follow-up `language-ontology-growth` | The ontology store is revised by commit; a run pins it and refuses drift; it likewise pins the speaker-state store (`RunRecord` keys 17 and 18, `Drift(SpeakerState)`, cut `language-ontology-scene`) | Profile authors and accepted rounds; never the lowerer's defaults (`persona-drives-register`) | -| Language ontology entry (cut `language-ontology`) | Key `onto::`, `n` from 1 per language; type `weksa.ontology_entry` in `data/ontology/ontology.cc`: the language, the revision of the inventory it was admitted through (provenance: beds number revisions independently and a run reads each condition's feature at its own head), a layer (lexicon, grammar, discourse, phonology, orthography), at most four conditions (a feature id of slot `Stance`, `Discourse` or `Scene` with `AtLeast`/`AtMost` a grade or `Is` an option or flag; a `Scene` condition reads the relation of the item's speaker to its addressee that `with_scene` selected; slot `Speaker` and community ids wait on follow-up `language-ontology-communities`), a choice of 1 to 200 bytes, at most three examples of 1 to 120 bytes, and an `Annotator`. Whether an entry's text keeps politeness on the scene is a model reader's judgment, owed per change (a mint owes it under `language-ontology-growth`), not a test | Admitted in all-or-nothing batches through `OntologyStore::admit`, immutable, never edited; retire arrives with `language-ontology-growth`. The run pins the store like the entity store (path and digest, `Drift(Ontology)`), never copies it, because no loop step writes it yet. Cut `language-ontology-seed` converts by drafting, not by parse: a fresh model drafts each language's seed from that language's YAML and the inventory's feature lines with no corpus text, then deletes `data/target-language-ontology/` and `.weksa/cultural-ontology/` in the same cut | Seed: a labelled model (`Annotator::Model`), no operator gate, never Test evidence (`ja-ontology-owner-answer`); attestation (operator, native reader) appends later. Accepted rounds later, through a mint call from Train items only. Selection is `ontology::select(ontology, language, view)`, called only inside `Prompt::lower`, so no caller picks entries; the prompt prints each selected entry's id, layer, choice and examples. Its text is minted text for the leak diagnostic, which today has no runtime caller (follow-up `leak-diagnostic-in-round`). The store was rebuilt without ja-JP `:14` and `:15` (above-status Scene entries; a paired measure found them net-negative on register, follow-up `ja-scene-entries-lower-register-agreement`), so ja-JP ends at `:13`: an above-status out-group addressee, and an above-status in-group addressee below intimacy 700, select no ja-JP Scene entry (`:12` still selects in-group at intimacy 700 or more regardless of status) until a native reader attests a replacement (`ja-native-reader-scenes`) | +| Language ontology entry (cut `language-ontology`) | Key `onto::`, `n` from 1 per language; type `weksa.ontology_entry` in `data/ontology/ontology.cc`: the language, the revision of the inventory it was admitted through (provenance: beds number revisions independently and a run reads each condition's feature at its own head), a layer (lexicon, grammar, discourse, phonology, orthography), at most four conditions (a feature id of slot `Stance`, `Discourse` or `Scene` with `AtLeast`/`AtMost`/`AtMostOrUnset` a grade or `Is` an option or flag; a `Scene` condition reads the relation of the item's speaker to its addressee that `with_scene` selected; slot `Speaker` and community ids wait on follow-up `language-ontology-communities`), a choice of 1 to 200 bytes, at most three examples of 1 to 120 bytes, and an `Annotator`. Whether an entry's text keeps politeness on the scene is a model reader's judgment, owed per change (a mint owes it under `language-ontology-growth`), not a test | Admitted in all-or-nothing batches through `OntologyStore::admit`, immutable, never edited; retire arrives with `language-ontology-growth`. The run pins the store like the entity store (path and digest, `Drift(Ontology)`), never copies it, because no loop step writes it yet. Cut `language-ontology-seed` converts by drafting, not by parse: a fresh model drafts each language's seed from that language's YAML and the inventory's feature lines with no corpus text, then deletes `data/target-language-ontology/` and `.weksa/cultural-ontology/` in the same cut | Seed: a labelled model (`Annotator::Model`), no operator gate, never Test evidence (`ja-ontology-owner-answer`); attestation (operator, native reader) appends later. Accepted rounds later, through a mint call from Train items only. Selection is `ontology::select(ontology, language, view)`, called only inside `Prompt::lower`, so no caller picks entries; the prompt prints each selected entry's id, layer, choice and examples. Its text is minted text for the leak diagnostic, which today has no runtime caller (follow-up `leak-diagnostic-in-round`). The store was rebuilt without ja-JP `:14` and `:15` (above-status Scene entries; a paired measure found them net-negative on register, follow-up `ja-scene-entries-lower-register-agreement`), so ja-JP ends at `:13`: an above-status out-group addressee, and an above-status in-group addressee below intimacy 700, select no ja-JP Scene entry (`:12` still selects in-group at intimacy 700 or more regardless of status) until a native reader attests a replacement (`ja-native-reader-scenes`). ja-JP `:5`, `:7` and `:8` were revised by certainty and restraint `AtMostOrUnset` conditions (holds when the feature is unrated or at most the grade; `AtMost` still fails on an unrated feature) in a store rebuild (the store has no retire, so a conditions change is a rebuild), which makes ja-JP's hedging, certainty, affection, restraint and sadness entries disjoint on `:5`/`:6`, `:4`/`:7`, `:6`/`:7`, `:6`/`:8` | | Community (cut `language-ontology`, follow-up `language-ontology-communities`) | Key `community:`; type `weksa.community`, converted from `data/cultural-ontology/cultures/` and `referents/` (YAML deleted in the same cut) | Revised by commit; a speaker names the communities it belongs to by id | The cultural ontology's author (owner-attested evidence only; Discord-only content stays deleted, `discord-only-content-deleted`) | | Speaker (cut `speaker-scene`) | Key `speaker:@`; type `weksa.speaker`: stable axes as feature values of slot `Speaker` (origin, socioeconomic standing, age cohort, education and whatever the loop adds), at an inventory revision, and an `Annotator` | A new revision appends, never edits; a corpus item and every prior turn name a speaker slug, and a round records the speaker revisions it read | The annotator it names: `PersonaSnapshot` (a projection of a `gamecult.persona_state.v0` document, naming its source document and `updatedAt`), `Operator`, `WorkMetadata` (a public-domain work's own cast list and narration), or `Model { family, generator }` (the 2b `ModelFamily`) | | Scene (cut `speaker-scene`) | Key `scene:@`, the item's split group; type `weksa.scene`: participants (speaker slugs) and, per ordered pair, relation features of slot `Scene` (relative status, intimacy, in-group, audience and whatever the loop adds), at an inventory revision (provenance; a run reads the features at its own head), and an `Annotator` | As Speaker. Keyed by the group, so a scene never straddles the split. `data/original/speaker-state.cc` holds Model-annotated keeper scenes, one per Train or Validation group of both languages (`weksa scene put|dump`); a Test group has none and reads `NoScene` | As Speaker; a model-annotated scene is never Test evidence | 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" + ] } ] } From ccef7a761f9606154828ca4192409644b7ad1f05 Mon Sep 17 00:00:00 2001 From: Weksa Date: Thu, 12 Nov 2026 20:18:45 +0000 Subject: [PATCH 05/41] en-us-seed-pairs: en-US :3/:5/:6 made disjoint by conditions, shared sweep helper (#59) --- README.md | 2 +- crates/weksa/tests/original_corpus.rs | 141 ++++++++++++++++------- data/ontology/ontology.cc | Bin 11945 -> 12164 bytes docs/targets/interlingua-lowering-map.md | 2 +- 4 files changed, 100 insertions(+), 45 deletions(-) diff --git a/README.md b/README.md index 3b02136..24b3b8c 100644 --- a/README.md +++ b/README.md @@ -95,7 +95,7 @@ addressee, and none for an above-status in-group addressee below intimacy 700 (` an in-group addressee at intimacy 700 or more, whatever the status). Two entries for the above-status cases were withdrawn: a paired measure found they made the lowerer match the reference register less often, and they stay out until a native reader attests them. -ja-JP `:5` (hedging), `:7` (affection) and `:8` (restrained sadness) carry certainty and restraint conditions, through `AtMostOrUnset` bounds (an unrated certainty or restraint does not defeat them), so the hedging, certainty, affection, restraint and sadness entries never co-select on the pairs `:5`/`:6`, `:4`/`:7`, `:6`/`:7` and `:6`/`:8`; the store has no retire, so that was a rebuild of `data/ontology/ontology.cc` with the ja-JP text unchanged. +ja-JP `:5` (hedging), `:7` (affection) and `:8` (restrained sadness) carry certainty and restraint conditions, through `AtMostOrUnset` bounds (an unrated certainty or restraint does not defeat them), so the hedging, certainty, affection, restraint and sadness entries never co-select on the pairs `:5`/`:6`, `:4`/`:7`, `:6`/`:7` and `:6`/`:8`; the store has no retire, so that was a rebuild of `data/ontology/ontology.cc` with the ja-JP text unchanged. en-US `:3` (blunt anger) carries `AtMostOrUnset` hedge and affection bounds and `:5` (hedging) an `AtMostOrUnset` certainty bound, so `:3`/`:5`, `:3`/`:8` and `:5`/`:6` never co-select; `:5`'s certainty clause is that condition and no longer prose; `:6` and the Scene entry `:10` still co-select and are kept apart by scoping in the text. For the first AquaSynth speech-training handoff, see [Tiny PanPhon v0.1 Speech Curriculum](./examples/speech-training/tiny-panphon-v0.1/README.md). diff --git a/crates/weksa/tests/original_corpus.rs b/crates/weksa/tests/original_corpus.rs index 715233c..de6c0bb 100644 --- a/crates/weksa/tests/original_corpus.rs +++ b/crates/weksa/tests/original_corpus.rs @@ -961,14 +961,18 @@ fn committed_scenes_cover_original_groups() { } } -/// ja-JP seed entries :4 to :8 over the stance and discourse grades that bear on -/// them (hedge, certainty, sadness, affection, restraint, each also ABSENT): -/// the pairs that gave opposed instructions (hedge against certainty, -/// particles, final force) never hold together; and each of :5, :7, :8 still -/// fires where it should (hedged at certainty 700-799, affection with certainty -/// or restraint unrated), so a tightened bound does not pass as a disjoint one. -#[test] -fn ja_seed_pairs_never_co_select() { +/// The sweep both seed-pair tests share: over a grid of grades per feature (each +/// also ABSENT) and the production `Condition::holds`, no listed pair of one +/// language's entries co-holds; and each witness entry fires where it should and +/// stays silent where it should, so a tightened or dropped bound does not pass +/// as a disjoint one. `glosses` names the swept features, in point order. +fn sweep_seed_pairs( + language: &str, + glosses: [&str; N], + pairs: &[(u32, u32)], + fires: &[(u32, [Option; N])], + silent: &[(u32, [Option; N])], +) { use weksa::inventory::Slot; use weksa::ontology::{Condition, Test}; use weksa::OntologyStore; @@ -978,18 +982,18 @@ fn ja_seed_pairs_never_co_select() { 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 feats = [id("hedge"), id("certainty"), id("sadness"), id("affection"), id("restraint")]; + let feats = glosses.map(id); let entries = OntologyStore::open(&onto).unwrap().all().unwrap(); - let ja = |n: u32| { + let entry = |n: u32| { entries .iter() - .find(|e| e.language == "ja-JP" && e.n == n) - .unwrap_or_else(|| panic!("onto:ja-JP:{n} is absent")) + .find(|e| e.language == language && e.n == n) + .unwrap_or_else(|| panic!("onto:{language}:{n} is absent")) }; - type Point = [Option; 5]; + type Point = [Option; N]; // 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| { + 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()); @@ -1010,45 +1014,96 @@ fn ja_seed_pairs_never_co_select() { }) }; let grid = [None, Some(0u16), Some(300), Some(500), Some(599), Some(600), Some(700), Some(799), Some(800), Some(1000)]; - let pairs = [(5, 6), (4, 7), (6, 7), (6, 8)]; - for p in 0..grid.len().pow(5) { - let point: Point = std::array::from_fn(|i| grid[p / grid.len().pow(i as u32) % grid.len()]); - for (a, b) in pairs { + for p in 0..grid.len().pow(N as u32) { + let point: Point = std::array::from_fn(|i| grid[p / grid.len().pow(i as u32) % grid.len()]); + for &(a, b) in pairs { assert!( - !(holds(ja(a), &point) && holds(ja(b), &point)), - "onto:ja-JP:{a} and :{b} co-select at (hedge, certainty, sadness, affection, restraint) = {point:?}" + !(holds(entry(a), &point) && holds(entry(b), &point)), + "onto:{language}:{a} and :{b} co-select at {glosses:?} = {point:?}" ); } } - // Reach: each entry fires at its witnesses and not just outside its core. - let (n, s) = (None, Some); - 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)]), - (7, [n, n, n, s(700), n]), - (7, [s(1000), s(0), s(1000), s(600), s(0)]), - (8, [n, s(799), s(700), n, s(700)]), - (8, [n, n, s(600), n, s(600)]), - (6, [n, s(800), n, n, n]), - ]; for (e, point) in fires { - assert!(holds(ja(e), &point), "onto:ja-JP:{e} does not fire at {point:?}"); + assert!(holds(entry(*e), point), "onto:{language}:{e} does not fire at {point:?}"); } - 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)]), - (8, [n, n, s(600), n, s(599)]), - ]; for (e, point) in silent { - assert!(!holds(ja(e), &point), "onto:ja-JP:{e} fires at {point:?}"); + assert!(!holds(entry(*e), point), "onto:{language}:{e} fires at {point:?}"); } } +/// ja-JP seed entries :4 to :8 over the stance and discourse grades that bear on +/// them (hedge, certainty, sadness, affection, restraint): the pairs that gave +/// opposed instructions (hedge against certainty, particles, final force) never +/// hold together; and each of :5, :7, :8 still fires where it should (hedged at +/// certainty 700-799, affection with certainty or restraint unrated). +#[test] +fn ja_seed_pairs_never_co_select() { + let (n, s) = (None, Some); + sweep_seed_pairs( + "ja-JP", + ["hedge", "certainty", "sadness", "affection", "restraint"], + &[(5, 6), (4, 7), (6, 7), (6, 8)], + &[ + (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)]), + (7, [n, n, n, s(700), n]), + (7, [s(1000), s(0), s(1000), s(600), s(0)]), + (8, [n, s(799), s(700), n, s(700)]), + (8, [n, n, s(600), n, s(600)]), + (6, [n, s(800), n, n, n]), + ], + &[ + (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)]), + (8, [n, n, s(600), n, s(599)]), + ], + ); +} + +/// en-US seed entries :3, :5, :6, :8 over anger, restraint, hedge, certainty and +/// affection: blunt anger never holds with a hedge or affection entry, and a +/// hedge never holds with a flatly certain line, so the pairs that gave opposed +/// instructions (no cushioning against softening, hedge against no hedge) are +/// disjoint by condition; each of :3, :5, :6, :8 fires and stays silent at its +/// witnesses, so a dropped or tightened bound does not pass as a disjoint one. +/// :6 against the Scene entry :10 is kept apart by scoping in the text only. +#[test] +fn en_us_seed_pairs_never_co_select() { + let (n, s) = (None, Some); + sweep_seed_pairs( + "en-US", + ["anger", "restraint", "hedge", "certainty", "affection"], + &[(3, 5), (3, 8), (5, 6)], + &[ + (3, [s(600), s(300), n, n, n]), + (3, [s(600), s(300), s(599), n, s(599)]), + (3, [s(1000), s(0), s(0), s(799), s(0)]), + (5, [n, n, s(600), n, n]), + (5, [n, n, s(700), s(799), n]), + (5, [s(1000), s(1000), s(600), n, n]), + (6, [n, n, n, s(800), n]), + (8, [n, n, n, n, s(600)]), + (8, [s(1000), s(0), n, n, s(600)]), + ], + &[ + (3, [s(600), s(300), s(600), n, n]), + (3, [s(600), s(300), n, n, s(600)]), + (3, [s(599), s(300), n, n, n]), + (3, [s(600), s(301), n, n, n]), + (3, [s(600), n, n, n, n]), + (5, [n, n, s(599), n, n]), + (5, [n, n, s(700), s(800), n]), + (6, [n, n, n, s(799), n]), + (8, [n, n, n, n, s(599)]), + ], + ); +} + /// The committed ontology's Scene-conditioned entries, over every scene relation /// (relative_status x in_group x intimacy in steps of 50): two entries of one /// language and layer are never selected by the same relation, so the ontology diff --git a/data/ontology/ontology.cc b/data/ontology/ontology.cc index a6d2edd0651d0eeceee77f2cd666baa3aa0ba92d..5876983dbc820d7471d1ee0631ece7da5da058dc 100644 GIT binary patch delta 591 zcmZ1(+Y-M)gptF@z{&uKEH}$AIwJ8>nVgvravNCuka%qDoJc%z&c8_dWVmG+A8VI}n_H5`>!cx0w$ zC?uyAl_X~7l~h_O6qh8Hq$-qTq$(umBxdF+WadpiC1}lOt&pftlv-GtT3n(~l0W%1 zlZ-+!P;F*TjzV#MT1jeNYKlTqC0JikYEEKFW`5peRw38P^Hgns?q-`jMMw$Z_I*P6 zNMU0tasi3QE4CVmcR;)tiDxY-ffT~g(mY7KeA$~wDg)#tk>m;$-H_z=E8SrfK?*sY z8B4Pgb-e;uCOe8~PJXM&zWKh2GLm{OH4!AU)HEWI%|BF)t;ub delta 524 zcmZpPUm3eWgptG0(#qJ_%GhwT45K3wFO|ue2_d(E#Se+c#?Fbv6X*Pkq)&!hmQfC7 zX4Fx}OEZ?H=IMq8GczvtNv+6C&d-}Pxll)Rat@F8W_4a|#>x5;Hj^jvX&~%6$mhc- zf@H!(s0pl-gmfqS2?#OWoHBW~K$fPpLP~yWu|i&ci9%vQK~AMYNxnj&LRwB@36Pzf zT2zvlnWvDGnU^}5Rj>hU%@IKj9wdWBC;t%i5b*ZMOwWL+FR8SeoGfHL`Gt_{}2knOY5^I`-5ku8rS diff --git a/docs/targets/interlingua-lowering-map.md b/docs/targets/interlingua-lowering-map.md index b436b3b..bf4ff74 100644 --- a/docs/targets/interlingua-lowering-map.md +++ b/docs/targets/interlingua-lowering-map.md @@ -34,7 +34,7 @@ means no store holds it and nothing writes it. | Inventory entry | Key `:`, `n` canonical decimal >= 1 (families: concept, frame, role, relation, speech_act, feature, referent_kind, extension); type `weksa.inventory_entry`, with a bounded gloss, value kind (option labels bounded), the slots a feature may sit in (`Discourse`, `Referent`, `Predication`, `Relation`; `Stance` from cut `speaker-state`, `Speaker` and `Scene` from cut `speaker-scene`), `introduced_rev` and optional `retired_rev`. Speaker axes, scene relations and affects are features of those slots, so the loop grows them like any closed-class family and convergence covers them | Added or retired by an inventory revision; never edited in place (a changed meaning is a retire plus an add); a retired id still resolves for packets of earlier revisions | The loop's accepted rounds, whose minting call the context builder assembles from Train items only; `weksa inventory admit` for one model-drafted `EditDraft` outside a run (cap 256, reviewed whole in its cut; same numbering and admission check as the loop); Self on merge to main. `data/original` revs 5 (233 concepts and frames) and 6 (five concepts closing named gaps) were drafted by claude-sonnet-5-5 (Weksa Hands, model-drafted original-bed lexicon from Train and Validation passages); Validation-informed: numbers on this bed measure lowering, never generalization or convergence. Residue after rev 6, not amended (each fresh coverage reader names new gaps; the loop's growth path owns them): simultaneity (ながら), distal deixis (あの), 'first' (まず), counterfactual mood, 'at least', emphatic question; heaven versus sky for the visible 天 stays weak. Admission checks form, not text | | Inventory revision | Key `rev:`, type `weksa.inventory_revision`, with parent, change list and `frozen` | Appended per accepted round; exactly one revision is ever marked frozen, by the convergence test | The loop's accept rule appends; the convergence test freezes; Self records the freeze as a ruling | | Target profile | Locale or language-project id (`en-US`, `ja-JP`, a conlang's slug). Until entries grow in rounds there is no profile revision document: a run names the profile it lowered with by the ontology store's path and digest in its `RunRecord` (cut `language-ontology`); `profile::` revision documents arrive with follow-up `language-ontology-growth` | The ontology store is revised by commit; a run pins it and refuses drift; it likewise pins the speaker-state store (`RunRecord` keys 17 and 18, `Drift(SpeakerState)`, cut `language-ontology-scene`) | Profile authors and accepted rounds; never the lowerer's defaults (`persona-drives-register`) | -| Language ontology entry (cut `language-ontology`) | Key `onto::`, `n` from 1 per language; type `weksa.ontology_entry` in `data/ontology/ontology.cc`: the language, the revision of the inventory it was admitted through (provenance: beds number revisions independently and a run reads each condition's feature at its own head), a layer (lexicon, grammar, discourse, phonology, orthography), at most four conditions (a feature id of slot `Stance`, `Discourse` or `Scene` with `AtLeast`/`AtMost`/`AtMostOrUnset` a grade or `Is` an option or flag; a `Scene` condition reads the relation of the item's speaker to its addressee that `with_scene` selected; slot `Speaker` and community ids wait on follow-up `language-ontology-communities`), a choice of 1 to 200 bytes, at most three examples of 1 to 120 bytes, and an `Annotator`. Whether an entry's text keeps politeness on the scene is a model reader's judgment, owed per change (a mint owes it under `language-ontology-growth`), not a test | Admitted in all-or-nothing batches through `OntologyStore::admit`, immutable, never edited; retire arrives with `language-ontology-growth`. The run pins the store like the entity store (path and digest, `Drift(Ontology)`), never copies it, because no loop step writes it yet. Cut `language-ontology-seed` converts by drafting, not by parse: a fresh model drafts each language's seed from that language's YAML and the inventory's feature lines with no corpus text, then deletes `data/target-language-ontology/` and `.weksa/cultural-ontology/` in the same cut | Seed: a labelled model (`Annotator::Model`), no operator gate, never Test evidence (`ja-ontology-owner-answer`); attestation (operator, native reader) appends later. Accepted rounds later, through a mint call from Train items only. Selection is `ontology::select(ontology, language, view)`, called only inside `Prompt::lower`, so no caller picks entries; the prompt prints each selected entry's id, layer, choice and examples. Its text is minted text for the leak diagnostic, which today has no runtime caller (follow-up `leak-diagnostic-in-round`). The store was rebuilt without ja-JP `:14` and `:15` (above-status Scene entries; a paired measure found them net-negative on register, follow-up `ja-scene-entries-lower-register-agreement`), so ja-JP ends at `:13`: an above-status out-group addressee, and an above-status in-group addressee below intimacy 700, select no ja-JP Scene entry (`:12` still selects in-group at intimacy 700 or more regardless of status) until a native reader attests a replacement (`ja-native-reader-scenes`). ja-JP `:5`, `:7` and `:8` were revised by certainty and restraint `AtMostOrUnset` conditions (holds when the feature is unrated or at most the grade; `AtMost` still fails on an unrated feature) in a store rebuild (the store has no retire, so a conditions change is a rebuild), which makes ja-JP's hedging, certainty, affection, restraint and sadness entries disjoint on `:5`/`:6`, `:4`/`:7`, `:6`/`:7`, `:6`/`:8` | +| Language ontology entry (cut `language-ontology`) | Key `onto::`, `n` from 1 per language; type `weksa.ontology_entry` in `data/ontology/ontology.cc`: the language, the revision of the inventory it was admitted through (provenance: beds number revisions independently and a run reads each condition's feature at its own head), a layer (lexicon, grammar, discourse, phonology, orthography), at most four conditions (a feature id of slot `Stance`, `Discourse` or `Scene` with `AtLeast`/`AtMost`/`AtMostOrUnset` a grade or `Is` an option or flag; a `Scene` condition reads the relation of the item's speaker to its addressee that `with_scene` selected; slot `Speaker` and community ids wait on follow-up `language-ontology-communities`), a choice of 1 to 200 bytes, at most three examples of 1 to 120 bytes, and an `Annotator`. Whether an entry's text keeps politeness on the scene is a model reader's judgment, owed per change (a mint owes it under `language-ontology-growth`), not a test | Admitted in all-or-nothing batches through `OntologyStore::admit`, immutable, never edited; retire arrives with `language-ontology-growth`. The run pins the store like the entity store (path and digest, `Drift(Ontology)`), never copies it, because no loop step writes it yet. Cut `language-ontology-seed` converts by drafting, not by parse: a fresh model drafts each language's seed from that language's YAML and the inventory's feature lines with no corpus text, then deletes `data/target-language-ontology/` and `.weksa/cultural-ontology/` in the same cut | Seed: a labelled model (`Annotator::Model`), no operator gate, never Test evidence (`ja-ontology-owner-answer`); attestation (operator, native reader) appends later. Accepted rounds later, through a mint call from Train items only. Selection is `ontology::select(ontology, language, view)`, called only inside `Prompt::lower`, so no caller picks entries; the prompt prints each selected entry's id, layer, choice and examples. Its text is minted text for the leak diagnostic, which today has no runtime caller (follow-up `leak-diagnostic-in-round`). The store was rebuilt without ja-JP `:14` and `:15` (above-status Scene entries; a paired measure found them net-negative on register, follow-up `ja-scene-entries-lower-register-agreement`), so ja-JP ends at `:13`: an above-status out-group addressee, and an above-status in-group addressee below intimacy 700, select no ja-JP Scene entry (`:12` still selects in-group at intimacy 700 or more regardless of status) until a native reader attests a replacement (`ja-native-reader-scenes`). ja-JP `:5`, `:7` and `:8` were revised by certainty and restraint `AtMostOrUnset` conditions (holds when the feature is unrated or at most the grade; `AtMost` still fails on an unrated feature) in a store rebuild (the store has no retire, so a conditions change is a rebuild), which makes ja-JP's hedging, certainty, affection, restraint and sadness entries disjoint on `:5`/`:6`, `:4`/`:7`, `:6`/`:7`, `:6`/`:8`; en-US `:3` carries `AtMostOrUnset` hedge and affection bounds and `:5` an `AtMostOrUnset` certainty bound (the clause it held in prose), which makes `:3`/`:5`, `:3`/`:8` and `:5`/`:6` disjoint, while `:6`/`:10` stay co-selectable and are kept apart by scoping in `:6`'s text | | Community (cut `language-ontology`, follow-up `language-ontology-communities`) | Key `community:`; type `weksa.community`, converted from `data/cultural-ontology/cultures/` and `referents/` (YAML deleted in the same cut) | Revised by commit; a speaker names the communities it belongs to by id | The cultural ontology's author (owner-attested evidence only; Discord-only content stays deleted, `discord-only-content-deleted`) | | Speaker (cut `speaker-scene`) | Key `speaker:@`; type `weksa.speaker`: stable axes as feature values of slot `Speaker` (origin, socioeconomic standing, age cohort, education and whatever the loop adds), at an inventory revision, and an `Annotator` | A new revision appends, never edits; a corpus item and every prior turn name a speaker slug, and a round records the speaker revisions it read | The annotator it names: `PersonaSnapshot` (a projection of a `gamecult.persona_state.v0` document, naming its source document and `updatedAt`), `Operator`, `WorkMetadata` (a public-domain work's own cast list and narration), or `Model { family, generator }` (the 2b `ModelFamily`) | | Scene (cut `speaker-scene`) | Key `scene:@`, the item's split group; type `weksa.scene`: participants (speaker slugs) and, per ordered pair, relation features of slot `Scene` (relative status, intimacy, in-group, audience and whatever the loop adds), at an inventory revision (provenance; a run reads the features at its own head), and an `Annotator` | As Speaker. Keyed by the group, so a scene never straddles the split. `data/original/speaker-state.cc` holds Model-annotated keeper scenes, one per Train or Validation group of both languages (`weksa scene put|dump`); a Test group has none and reads `NoScene` | As Speaker; a model-annotated scene is never Test evidence | From 0a2d00a25f40d8aaabc5f9b78f617c3b40b8fd1c Mon Sep 17 00:00:00 2001 From: Weksa Date: Thu, 12 Nov 2026 20:27:19 +0000 Subject: [PATCH 06/41] ja-surprise-certainty: ja-JP:9 reworded so its question ending is available, not prescribed (#60) --- README.md | 2 +- data/ontology/ontology.cc | Bin 12164 -> 12263 bytes docs/targets/interlingua-lowering-map.md | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 24b3b8c..d847874 100644 --- a/README.md +++ b/README.md @@ -95,7 +95,7 @@ addressee, and none for an above-status in-group addressee below intimacy 700 (` an in-group addressee at intimacy 700 or more, whatever the status). Two entries for the above-status cases were withdrawn: a paired measure found they made the lowerer match the reference register less often, and they stay out until a native reader attests them. -ja-JP `:5` (hedging), `:7` (affection) and `:8` (restrained sadness) carry certainty and restraint conditions, through `AtMostOrUnset` bounds (an unrated certainty or restraint does not defeat them), so the hedging, certainty, affection, restraint and sadness entries never co-select on the pairs `:5`/`:6`, `:4`/`:7`, `:6`/`:7` and `:6`/`:8`; the store has no retire, so that was a rebuild of `data/ontology/ontology.cc` with the ja-JP text unchanged. en-US `:3` (blunt anger) carries `AtMostOrUnset` hedge and affection bounds and `:5` (hedging) an `AtMostOrUnset` certainty bound, so `:3`/`:5`, `:3`/`:8` and `:5`/`:6` never co-select; `:5`'s certainty clause is that condition and no longer prose; `:6` and the Scene entry `:10` still co-select and are kept apart by scoping in the text. +ja-JP `:5` (hedging), `:7` (affection) and `:8` (restrained sadness) carry certainty and restraint conditions, through `AtMostOrUnset` bounds (an unrated certainty or restraint does not defeat them), so the hedging, certainty, affection, restraint and sadness entries never co-select on the pairs `:5`/`:6`, `:4`/`:7`, `:6`/`:7` and `:6`/`:8`; the store has no retire, so that was a rebuild of `data/ontology/ontology.cc` with the ja-JP text unchanged. en-US `:3` (blunt anger) carries `AtMostOrUnset` hedge and affection bounds and `:5` (hedging) an `AtMostOrUnset` certainty bound, so `:3`/`:5`, `:3`/`:8` and `:5`/`:6` never co-select; `:5`'s certainty clause is that condition and no longer prose; `:6` and the Scene entry `:10` still co-select and are kept apart by scoping in the text. ja-JP `:9` (surprise) states its question ending as available, not prescribed, so `:6`/`:9`, `:5`/`:9` and `:3`/`:9` stay co-selectable and are reconciled by wording, not by condition. For the first AquaSynth speech-training handoff, see [Tiny PanPhon v0.1 Speech Curriculum](./examples/speech-training/tiny-panphon-v0.1/README.md). diff --git a/data/ontology/ontology.cc b/data/ontology/ontology.cc index 5876983dbc820d7471d1ee0631ece7da5da058dc..c23a25ceb860334541c348e5428fb6e031d9d40b 100644 GIT binary patch delta 416 zcmZpPe;&UfU=sMt*92T)e6YBH4dL`?#sZj)v#R47sFGn5sfbC;15fU=sMt*92T)e6YBH4dL`?#sZj)v#R47sFGn5sfbC;15:`, `n` canonical decimal >= 1 (families: concept, frame, role, relation, speech_act, feature, referent_kind, extension); type `weksa.inventory_entry`, with a bounded gloss, value kind (option labels bounded), the slots a feature may sit in (`Discourse`, `Referent`, `Predication`, `Relation`; `Stance` from cut `speaker-state`, `Speaker` and `Scene` from cut `speaker-scene`), `introduced_rev` and optional `retired_rev`. Speaker axes, scene relations and affects are features of those slots, so the loop grows them like any closed-class family and convergence covers them | Added or retired by an inventory revision; never edited in place (a changed meaning is a retire plus an add); a retired id still resolves for packets of earlier revisions | The loop's accepted rounds, whose minting call the context builder assembles from Train items only; `weksa inventory admit` for one model-drafted `EditDraft` outside a run (cap 256, reviewed whole in its cut; same numbering and admission check as the loop); Self on merge to main. `data/original` revs 5 (233 concepts and frames) and 6 (five concepts closing named gaps) were drafted by claude-sonnet-5-5 (Weksa Hands, model-drafted original-bed lexicon from Train and Validation passages); Validation-informed: numbers on this bed measure lowering, never generalization or convergence. Residue after rev 6, not amended (each fresh coverage reader names new gaps; the loop's growth path owns them): simultaneity (ながら), distal deixis (あの), 'first' (まず), counterfactual mood, 'at least', emphatic question; heaven versus sky for the visible 天 stays weak. Admission checks form, not text | | Inventory revision | Key `rev:`, type `weksa.inventory_revision`, with parent, change list and `frozen` | Appended per accepted round; exactly one revision is ever marked frozen, by the convergence test | The loop's accept rule appends; the convergence test freezes; Self records the freeze as a ruling | | Target profile | Locale or language-project id (`en-US`, `ja-JP`, a conlang's slug). Until entries grow in rounds there is no profile revision document: a run names the profile it lowered with by the ontology store's path and digest in its `RunRecord` (cut `language-ontology`); `profile::` revision documents arrive with follow-up `language-ontology-growth` | The ontology store is revised by commit; a run pins it and refuses drift; it likewise pins the speaker-state store (`RunRecord` keys 17 and 18, `Drift(SpeakerState)`, cut `language-ontology-scene`) | Profile authors and accepted rounds; never the lowerer's defaults (`persona-drives-register`) | -| Language ontology entry (cut `language-ontology`) | Key `onto::`, `n` from 1 per language; type `weksa.ontology_entry` in `data/ontology/ontology.cc`: the language, the revision of the inventory it was admitted through (provenance: beds number revisions independently and a run reads each condition's feature at its own head), a layer (lexicon, grammar, discourse, phonology, orthography), at most four conditions (a feature id of slot `Stance`, `Discourse` or `Scene` with `AtLeast`/`AtMost`/`AtMostOrUnset` a grade or `Is` an option or flag; a `Scene` condition reads the relation of the item's speaker to its addressee that `with_scene` selected; slot `Speaker` and community ids wait on follow-up `language-ontology-communities`), a choice of 1 to 200 bytes, at most three examples of 1 to 120 bytes, and an `Annotator`. Whether an entry's text keeps politeness on the scene is a model reader's judgment, owed per change (a mint owes it under `language-ontology-growth`), not a test | Admitted in all-or-nothing batches through `OntologyStore::admit`, immutable, never edited; retire arrives with `language-ontology-growth`. The run pins the store like the entity store (path and digest, `Drift(Ontology)`), never copies it, because no loop step writes it yet. Cut `language-ontology-seed` converts by drafting, not by parse: a fresh model drafts each language's seed from that language's YAML and the inventory's feature lines with no corpus text, then deletes `data/target-language-ontology/` and `.weksa/cultural-ontology/` in the same cut | Seed: a labelled model (`Annotator::Model`), no operator gate, never Test evidence (`ja-ontology-owner-answer`); attestation (operator, native reader) appends later. Accepted rounds later, through a mint call from Train items only. Selection is `ontology::select(ontology, language, view)`, called only inside `Prompt::lower`, so no caller picks entries; the prompt prints each selected entry's id, layer, choice and examples. Its text is minted text for the leak diagnostic, which today has no runtime caller (follow-up `leak-diagnostic-in-round`). The store was rebuilt without ja-JP `:14` and `:15` (above-status Scene entries; a paired measure found them net-negative on register, follow-up `ja-scene-entries-lower-register-agreement`), so ja-JP ends at `:13`: an above-status out-group addressee, and an above-status in-group addressee below intimacy 700, select no ja-JP Scene entry (`:12` still selects in-group at intimacy 700 or more regardless of status) until a native reader attests a replacement (`ja-native-reader-scenes`). ja-JP `:5`, `:7` and `:8` were revised by certainty and restraint `AtMostOrUnset` conditions (holds when the feature is unrated or at most the grade; `AtMost` still fails on an unrated feature) in a store rebuild (the store has no retire, so a conditions change is a rebuild), which makes ja-JP's hedging, certainty, affection, restraint and sadness entries disjoint on `:5`/`:6`, `:4`/`:7`, `:6`/`:7`, `:6`/`:8`; en-US `:3` carries `AtMostOrUnset` hedge and affection bounds and `:5` an `AtMostOrUnset` certainty bound (the clause it held in prose), which makes `:3`/`:5`, `:3`/`:8` and `:5`/`:6` disjoint, while `:6`/`:10` stay co-selectable and are kept apart by scoping in `:6`'s text | +| Language ontology entry (cut `language-ontology`) | Key `onto::`, `n` from 1 per language; type `weksa.ontology_entry` in `data/ontology/ontology.cc`: the language, the revision of the inventory it was admitted through (provenance: beds number revisions independently and a run reads each condition's feature at its own head), a layer (lexicon, grammar, discourse, phonology, orthography), at most four conditions (a feature id of slot `Stance`, `Discourse` or `Scene` with `AtLeast`/`AtMost`/`AtMostOrUnset` a grade or `Is` an option or flag; a `Scene` condition reads the relation of the item's speaker to its addressee that `with_scene` selected; slot `Speaker` and community ids wait on follow-up `language-ontology-communities`), a choice of 1 to 200 bytes, at most three examples of 1 to 120 bytes, and an `Annotator`. Whether an entry's text keeps politeness on the scene is a model reader's judgment, owed per change (a mint owes it under `language-ontology-growth`), not a test | Admitted in all-or-nothing batches through `OntologyStore::admit`, immutable, never edited; retire arrives with `language-ontology-growth`. The run pins the store like the entity store (path and digest, `Drift(Ontology)`), never copies it, because no loop step writes it yet. Cut `language-ontology-seed` converts by drafting, not by parse: a fresh model drafts each language's seed from that language's YAML and the inventory's feature lines with no corpus text, then deletes `data/target-language-ontology/` and `.weksa/cultural-ontology/` in the same cut | Seed: a labelled model (`Annotator::Model`), no operator gate, never Test evidence (`ja-ontology-owner-answer`); attestation (operator, native reader) appends later. Accepted rounds later, through a mint call from Train items only. Selection is `ontology::select(ontology, language, view)`, called only inside `Prompt::lower`, so no caller picks entries; the prompt prints each selected entry's id, layer, choice and examples. Its text is minted text for the leak diagnostic, which today has no runtime caller (follow-up `leak-diagnostic-in-round`). The store was rebuilt without ja-JP `:14` and `:15` (above-status Scene entries; a paired measure found them net-negative on register, follow-up `ja-scene-entries-lower-register-agreement`), so ja-JP ends at `:13`: an above-status out-group addressee, and an above-status in-group addressee below intimacy 700, select no ja-JP Scene entry (`:12` still selects in-group at intimacy 700 or more regardless of status) until a native reader attests a replacement (`ja-native-reader-scenes`). ja-JP `:5`, `:7` and `:8` were revised by certainty and restraint `AtMostOrUnset` conditions (holds when the feature is unrated or at most the grade; `AtMost` still fails on an unrated feature) in a store rebuild (the store has no retire, so a conditions change is a rebuild), which makes ja-JP's hedging, certainty, affection, restraint and sadness entries disjoint on `:5`/`:6`, `:4`/`:7`, `:6`/`:7`, `:6`/`:8`; en-US `:3` carries `AtMostOrUnset` hedge and affection bounds and `:5` an `AtMostOrUnset` certainty bound (the clause it held in prose), which makes `:3`/`:5`, `:3`/`:8` and `:5`/`:6` disjoint, while `:6`/`:10` stay co-selectable and are kept apart by scoping in `:6`'s text; ja-JP `:9` was reworded in a rebuild to state its question ending as available, so `:6`/`:9`, `:5`/`:9` and `:3`/`:9` stay co-selectable and are reconciled by wording, not by condition | | Community (cut `language-ontology`, follow-up `language-ontology-communities`) | Key `community:`; type `weksa.community`, converted from `data/cultural-ontology/cultures/` and `referents/` (YAML deleted in the same cut) | Revised by commit; a speaker names the communities it belongs to by id | The cultural ontology's author (owner-attested evidence only; Discord-only content stays deleted, `discord-only-content-deleted`) | | Speaker (cut `speaker-scene`) | Key `speaker:@`; type `weksa.speaker`: stable axes as feature values of slot `Speaker` (origin, socioeconomic standing, age cohort, education and whatever the loop adds), at an inventory revision, and an `Annotator` | A new revision appends, never edits; a corpus item and every prior turn name a speaker slug, and a round records the speaker revisions it read | The annotator it names: `PersonaSnapshot` (a projection of a `gamecult.persona_state.v0` document, naming its source document and `updatedAt`), `Operator`, `WorkMetadata` (a public-domain work's own cast list and narration), or `Model { family, generator }` (the 2b `ModelFamily`) | | Scene (cut `speaker-scene`) | Key `scene:@`, the item's split group; type `weksa.scene`: participants (speaker slugs) and, per ordered pair, relation features of slot `Scene` (relative status, intimacy, in-group, audience and whatever the loop adds), at an inventory revision (provenance; a run reads the features at its own head), and an `Annotator` | As Speaker. Keyed by the group, so a scene never straddles the split. `data/original/speaker-state.cc` holds Model-annotated keeper scenes, one per Train or Validation group of both languages (`weksa scene put|dump`); a Test group has none and reads `NoScene` | As Speaker; a model-annotated scene is never Test evidence | From 349fe8e23982b92200f17fd80f86820ec7d67d5e Mon Sep 17 00:00:00 2001 From: Weksa Date: Thu, 12 Nov 2026 20:56:10 +0000 Subject: [PATCH 07/41] en-us-6-8: en-US:8 gets a certainty bound so affection and flat certainty never co-select (#61) --- README.md | 2 +- crates/weksa/tests/original_corpus.rs | 10 +++++++--- data/ontology/ontology.cc | Bin 12263 -> 12323 bytes docs/targets/interlingua-lowering-map.md | 2 +- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index d847874..31960d8 100644 --- a/README.md +++ b/README.md @@ -95,7 +95,7 @@ addressee, and none for an above-status in-group addressee below intimacy 700 (` an in-group addressee at intimacy 700 or more, whatever the status). Two entries for the above-status cases were withdrawn: a paired measure found they made the lowerer match the reference register less often, and they stay out until a native reader attests them. -ja-JP `:5` (hedging), `:7` (affection) and `:8` (restrained sadness) carry certainty and restraint conditions, through `AtMostOrUnset` bounds (an unrated certainty or restraint does not defeat them), so the hedging, certainty, affection, restraint and sadness entries never co-select on the pairs `:5`/`:6`, `:4`/`:7`, `:6`/`:7` and `:6`/`:8`; the store has no retire, so that was a rebuild of `data/ontology/ontology.cc` with the ja-JP text unchanged. en-US `:3` (blunt anger) carries `AtMostOrUnset` hedge and affection bounds and `:5` (hedging) an `AtMostOrUnset` certainty bound, so `:3`/`:5`, `:3`/`:8` and `:5`/`:6` never co-select; `:5`'s certainty clause is that condition and no longer prose; `:6` and the Scene entry `:10` still co-select and are kept apart by scoping in the text. ja-JP `:9` (surprise) states its question ending as available, not prescribed, so `:6`/`:9`, `:5`/`:9` and `:3`/`:9` stay co-selectable and are reconciled by wording, not by condition. +ja-JP `:5` (hedging), `:7` (affection) and `:8` (restrained sadness) carry certainty and restraint conditions, through `AtMostOrUnset` bounds (an unrated certainty or restraint does not defeat them), so the hedging, certainty, affection, restraint and sadness entries never co-select on the pairs `:5`/`:6`, `:4`/`:7`, `:6`/`:7` and `:6`/`:8`; the store has no retire, so that was a rebuild of `data/ontology/ontology.cc` with the ja-JP text unchanged. en-US `:3` (blunt anger) carries `AtMostOrUnset` hedge and affection bounds, and `:5` (hedging) and `:8` (affection) each an `AtMostOrUnset` certainty bound (as ja-JP `:7`), so `:3`/`:5`, `:3`/`:8`, `:5`/`:6` and `:6`/`:8` never co-select; `:5`'s certainty clause is that condition and no longer prose; `:6` and the Scene entry `:10` still co-select and are kept apart by scoping in the text. ja-JP `:9` (surprise) states its question ending as available, not prescribed, so `:6`/`:9`, `:5`/`:9` and `:3`/`:9` stay co-selectable and are reconciled by wording, not by condition. For the first AquaSynth speech-training handoff, see [Tiny PanPhon v0.1 Speech Curriculum](./examples/speech-training/tiny-panphon-v0.1/README.md). diff --git a/crates/weksa/tests/original_corpus.rs b/crates/weksa/tests/original_corpus.rs index de6c0bb..6c73ed2 100644 --- a/crates/weksa/tests/original_corpus.rs +++ b/crates/weksa/tests/original_corpus.rs @@ -1067,8 +1067,10 @@ fn ja_seed_pairs_never_co_select() { /// en-US seed entries :3, :5, :6, :8 over anger, restraint, hedge, certainty and /// affection: blunt anger never holds with a hedge or affection entry, and a -/// hedge never holds with a flatly certain line, so the pairs that gave opposed -/// instructions (no cushioning against softening, hedge against no hedge) are +/// hedge never holds with a flatly certain line, nor affection (:8, certainty +/// bound 799) with one, so the pairs that gave opposed instructions (no +/// cushioning against softening, hedge against no hedge, flat declaratives +/// against softened phrasing and tags) are /// disjoint by condition; each of :3, :5, :6, :8 fires and stays silent at its /// witnesses, so a dropped or tightened bound does not pass as a disjoint one. /// :6 against the Scene entry :10 is kept apart by scoping in the text only. @@ -1078,7 +1080,7 @@ fn en_us_seed_pairs_never_co_select() { sweep_seed_pairs( "en-US", ["anger", "restraint", "hedge", "certainty", "affection"], - &[(3, 5), (3, 8), (5, 6)], + &[(3, 5), (3, 8), (5, 6), (6, 8)], &[ (3, [s(600), s(300), n, n, n]), (3, [s(600), s(300), s(599), n, s(599)]), @@ -1089,6 +1091,7 @@ fn en_us_seed_pairs_never_co_select() { (6, [n, n, n, s(800), n]), (8, [n, n, n, n, s(600)]), (8, [s(1000), s(0), n, n, s(600)]), + (8, [n, n, n, s(799), s(600)]), ], &[ (3, [s(600), s(300), s(600), n, n]), @@ -1100,6 +1103,7 @@ fn en_us_seed_pairs_never_co_select() { (5, [n, n, s(700), s(800), n]), (6, [n, n, n, s(799), n]), (8, [n, n, n, n, s(599)]), + (8, [n, n, n, s(800), s(600)]), ], ); } diff --git a/data/ontology/ontology.cc b/data/ontology/ontology.cc index c23a25ceb860334541c348e5428fb6e031d9d40b..c385a8c007c470d6a7a685c0e98e9ab6d64672f5 100644 GIT binary patch delta 338 zcmaDJzc^uoI3ugEk(H^@W*J5o7&Dd0jR`8cfh7>eWMk)nG8c<;!UScw6=1p?d8%Qe z2l@PAqM`z~V9YOq3t-Hd!bObIV0)vEGTxlAG&N5*G?;^Nxld|EW^#Vsq{)Rk@{{>_ z*(cA_5}bTf$7FMas0!oc)4KMPcZg|2o%TX(9n84d5@j%^n3Ock6=pL0Fs7H>9hd@b u1sRyAkCG=$be8gc7_&|_3C4V?CJs}}s2KwjP15=VV@B%0&9%~7%Lo8KBv|+W delta 339 zcmZ3S@H~ElI3uf}rIo4WW*J5o7&Dd0jR`8cfh7>eWMk)nG8c<;!UScw6=1p?d8%Qe z2l@PAqM`z~V9YOq3t-Hd!bOaNV0)vEGR~c`G&N5*G?-)ZSw79l{JiXweMGr8PY_jQ zob0D+Gx>{{wg60N1yt$eMm^ijIpS$B^R7#j!I(i((lBQf$?(INZE|;D3epv1V4@vL oo-omC%J*T+U8+eirlPtyOs%bE3`}&M)+ZQqst(-TGQG8o00@p-D*ylh diff --git a/docs/targets/interlingua-lowering-map.md b/docs/targets/interlingua-lowering-map.md index eb66a40..7374ca2 100644 --- a/docs/targets/interlingua-lowering-map.md +++ b/docs/targets/interlingua-lowering-map.md @@ -34,7 +34,7 @@ means no store holds it and nothing writes it. | Inventory entry | Key `:`, `n` canonical decimal >= 1 (families: concept, frame, role, relation, speech_act, feature, referent_kind, extension); type `weksa.inventory_entry`, with a bounded gloss, value kind (option labels bounded), the slots a feature may sit in (`Discourse`, `Referent`, `Predication`, `Relation`; `Stance` from cut `speaker-state`, `Speaker` and `Scene` from cut `speaker-scene`), `introduced_rev` and optional `retired_rev`. Speaker axes, scene relations and affects are features of those slots, so the loop grows them like any closed-class family and convergence covers them | Added or retired by an inventory revision; never edited in place (a changed meaning is a retire plus an add); a retired id still resolves for packets of earlier revisions | The loop's accepted rounds, whose minting call the context builder assembles from Train items only; `weksa inventory admit` for one model-drafted `EditDraft` outside a run (cap 256, reviewed whole in its cut; same numbering and admission check as the loop); Self on merge to main. `data/original` revs 5 (233 concepts and frames) and 6 (five concepts closing named gaps) were drafted by claude-sonnet-5-5 (Weksa Hands, model-drafted original-bed lexicon from Train and Validation passages); Validation-informed: numbers on this bed measure lowering, never generalization or convergence. Residue after rev 6, not amended (each fresh coverage reader names new gaps; the loop's growth path owns them): simultaneity (ながら), distal deixis (あの), 'first' (まず), counterfactual mood, 'at least', emphatic question; heaven versus sky for the visible 天 stays weak. Admission checks form, not text | | Inventory revision | Key `rev:`, type `weksa.inventory_revision`, with parent, change list and `frozen` | Appended per accepted round; exactly one revision is ever marked frozen, by the convergence test | The loop's accept rule appends; the convergence test freezes; Self records the freeze as a ruling | | Target profile | Locale or language-project id (`en-US`, `ja-JP`, a conlang's slug). Until entries grow in rounds there is no profile revision document: a run names the profile it lowered with by the ontology store's path and digest in its `RunRecord` (cut `language-ontology`); `profile::` revision documents arrive with follow-up `language-ontology-growth` | The ontology store is revised by commit; a run pins it and refuses drift; it likewise pins the speaker-state store (`RunRecord` keys 17 and 18, `Drift(SpeakerState)`, cut `language-ontology-scene`) | Profile authors and accepted rounds; never the lowerer's defaults (`persona-drives-register`) | -| Language ontology entry (cut `language-ontology`) | Key `onto::`, `n` from 1 per language; type `weksa.ontology_entry` in `data/ontology/ontology.cc`: the language, the revision of the inventory it was admitted through (provenance: beds number revisions independently and a run reads each condition's feature at its own head), a layer (lexicon, grammar, discourse, phonology, orthography), at most four conditions (a feature id of slot `Stance`, `Discourse` or `Scene` with `AtLeast`/`AtMost`/`AtMostOrUnset` a grade or `Is` an option or flag; a `Scene` condition reads the relation of the item's speaker to its addressee that `with_scene` selected; slot `Speaker` and community ids wait on follow-up `language-ontology-communities`), a choice of 1 to 200 bytes, at most three examples of 1 to 120 bytes, and an `Annotator`. Whether an entry's text keeps politeness on the scene is a model reader's judgment, owed per change (a mint owes it under `language-ontology-growth`), not a test | Admitted in all-or-nothing batches through `OntologyStore::admit`, immutable, never edited; retire arrives with `language-ontology-growth`. The run pins the store like the entity store (path and digest, `Drift(Ontology)`), never copies it, because no loop step writes it yet. Cut `language-ontology-seed` converts by drafting, not by parse: a fresh model drafts each language's seed from that language's YAML and the inventory's feature lines with no corpus text, then deletes `data/target-language-ontology/` and `.weksa/cultural-ontology/` in the same cut | Seed: a labelled model (`Annotator::Model`), no operator gate, never Test evidence (`ja-ontology-owner-answer`); attestation (operator, native reader) appends later. Accepted rounds later, through a mint call from Train items only. Selection is `ontology::select(ontology, language, view)`, called only inside `Prompt::lower`, so no caller picks entries; the prompt prints each selected entry's id, layer, choice and examples. Its text is minted text for the leak diagnostic, which today has no runtime caller (follow-up `leak-diagnostic-in-round`). The store was rebuilt without ja-JP `:14` and `:15` (above-status Scene entries; a paired measure found them net-negative on register, follow-up `ja-scene-entries-lower-register-agreement`), so ja-JP ends at `:13`: an above-status out-group addressee, and an above-status in-group addressee below intimacy 700, select no ja-JP Scene entry (`:12` still selects in-group at intimacy 700 or more regardless of status) until a native reader attests a replacement (`ja-native-reader-scenes`). ja-JP `:5`, `:7` and `:8` were revised by certainty and restraint `AtMostOrUnset` conditions (holds when the feature is unrated or at most the grade; `AtMost` still fails on an unrated feature) in a store rebuild (the store has no retire, so a conditions change is a rebuild), which makes ja-JP's hedging, certainty, affection, restraint and sadness entries disjoint on `:5`/`:6`, `:4`/`:7`, `:6`/`:7`, `:6`/`:8`; en-US `:3` carries `AtMostOrUnset` hedge and affection bounds and `:5` an `AtMostOrUnset` certainty bound (the clause it held in prose), which makes `:3`/`:5`, `:3`/`:8` and `:5`/`:6` disjoint, while `:6`/`:10` stay co-selectable and are kept apart by scoping in `:6`'s text; ja-JP `:9` was reworded in a rebuild to state its question ending as available, so `:6`/`:9`, `:5`/`:9` and `:3`/`:9` stay co-selectable and are reconciled by wording, not by condition | +| Language ontology entry (cut `language-ontology`) | Key `onto::`, `n` from 1 per language; type `weksa.ontology_entry` in `data/ontology/ontology.cc`: the language, the revision of the inventory it was admitted through (provenance: beds number revisions independently and a run reads each condition's feature at its own head), a layer (lexicon, grammar, discourse, phonology, orthography), at most four conditions (a feature id of slot `Stance`, `Discourse` or `Scene` with `AtLeast`/`AtMost`/`AtMostOrUnset` a grade or `Is` an option or flag; a `Scene` condition reads the relation of the item's speaker to its addressee that `with_scene` selected; slot `Speaker` and community ids wait on follow-up `language-ontology-communities`), a choice of 1 to 200 bytes, at most three examples of 1 to 120 bytes, and an `Annotator`. Whether an entry's text keeps politeness on the scene is a model reader's judgment, owed per change (a mint owes it under `language-ontology-growth`), not a test | Admitted in all-or-nothing batches through `OntologyStore::admit`, immutable, never edited; retire arrives with `language-ontology-growth`. The run pins the store like the entity store (path and digest, `Drift(Ontology)`), never copies it, because no loop step writes it yet. Cut `language-ontology-seed` converts by drafting, not by parse: a fresh model drafts each language's seed from that language's YAML and the inventory's feature lines with no corpus text, then deletes `data/target-language-ontology/` and `.weksa/cultural-ontology/` in the same cut | Seed: a labelled model (`Annotator::Model`), no operator gate, never Test evidence (`ja-ontology-owner-answer`); attestation (operator, native reader) appends later. Accepted rounds later, through a mint call from Train items only. Selection is `ontology::select(ontology, language, view)`, called only inside `Prompt::lower`, so no caller picks entries; the prompt prints each selected entry's id, layer, choice and examples. Its text is minted text for the leak diagnostic, which today has no runtime caller (follow-up `leak-diagnostic-in-round`). The store was rebuilt without ja-JP `:14` and `:15` (above-status Scene entries; a paired measure found them net-negative on register, follow-up `ja-scene-entries-lower-register-agreement`), so ja-JP ends at `:13`: an above-status out-group addressee, and an above-status in-group addressee below intimacy 700, select no ja-JP Scene entry (`:12` still selects in-group at intimacy 700 or more regardless of status) until a native reader attests a replacement (`ja-native-reader-scenes`). ja-JP `:5`, `:7` and `:8` were revised by certainty and restraint `AtMostOrUnset` conditions (holds when the feature is unrated or at most the grade; `AtMost` still fails on an unrated feature) in a store rebuild (the store has no retire, so a conditions change is a rebuild), which makes ja-JP's hedging, certainty, affection, restraint and sadness entries disjoint on `:5`/`:6`, `:4`/`:7`, `:6`/`:7`, `:6`/`:8`; en-US `:3` carries `AtMostOrUnset` hedge and affection bounds, `:5` an `AtMostOrUnset` certainty bound (the clause it held in prose) and `:8` one too (as ja-JP `:7`), which makes `:3`/`:5`, `:3`/`:8`, `:5`/`:6` and `:6`/`:8` disjoint, while `:6`/`:10` stay co-selectable and are kept apart by scoping in `:6`'s text; ja-JP `:9` was reworded in a rebuild to state its question ending as available, so `:6`/`:9`, `:5`/`:9` and `:3`/`:9` stay co-selectable and are reconciled by wording, not by condition | | Community (cut `language-ontology`, follow-up `language-ontology-communities`) | Key `community:`; type `weksa.community`, converted from `data/cultural-ontology/cultures/` and `referents/` (YAML deleted in the same cut) | Revised by commit; a speaker names the communities it belongs to by id | The cultural ontology's author (owner-attested evidence only; Discord-only content stays deleted, `discord-only-content-deleted`) | | Speaker (cut `speaker-scene`) | Key `speaker:@`; type `weksa.speaker`: stable axes as feature values of slot `Speaker` (origin, socioeconomic standing, age cohort, education and whatever the loop adds), at an inventory revision, and an `Annotator` | A new revision appends, never edits; a corpus item and every prior turn name a speaker slug, and a round records the speaker revisions it read | The annotator it names: `PersonaSnapshot` (a projection of a `gamecult.persona_state.v0` document, naming its source document and `updatedAt`), `Operator`, `WorkMetadata` (a public-domain work's own cast list and narration), or `Model { family, generator }` (the 2b `ModelFamily`) | | Scene (cut `speaker-scene`) | Key `scene:@`, the item's split group; type `weksa.scene`: participants (speaker slugs) and, per ordered pair, relation features of slot `Scene` (relative status, intimacy, in-group, audience and whatever the loop adds), at an inventory revision (provenance; a run reads the features at its own head), and an `Annotator` | As Speaker. Keyed by the group, so a scene never straddles the split. `data/original/speaker-state.cc` holds Model-annotated keeper scenes, one per Train or Validation group of both languages (`weksa scene put|dump`); a Test group has none and reads `NoScene` | As Speaker; a model-annotated scene is never Test evidence | From af0a56d45f31ea942ceea1b7bcbd8477a519f02a Mon Sep 17 00:00:00 2001 From: Weksa Date: Thu, 12 Nov 2026 21:40:39 +0000 Subject: [PATCH 08/41] ja-anger-mirror: ja-JP:3 gets hedge and affection bounds as en-US:3 carries (#62) --- README.md | 2 +- crates/weksa/tests/original_corpus.rs | 54 ++++++++++++++--------- data/ontology/ontology.cc | Bin 12323 -> 12438 bytes docs/targets/interlingua-lowering-map.md | 2 +- 4 files changed, 34 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index 31960d8..ff6eadd 100644 --- a/README.md +++ b/README.md @@ -95,7 +95,7 @@ addressee, and none for an above-status in-group addressee below intimacy 700 (` an in-group addressee at intimacy 700 or more, whatever the status). Two entries for the above-status cases were withdrawn: a paired measure found they made the lowerer match the reference register less often, and they stay out until a native reader attests them. -ja-JP `:5` (hedging), `:7` (affection) and `:8` (restrained sadness) carry certainty and restraint conditions, through `AtMostOrUnset` bounds (an unrated certainty or restraint does not defeat them), so the hedging, certainty, affection, restraint and sadness entries never co-select on the pairs `:5`/`:6`, `:4`/`:7`, `:6`/`:7` and `:6`/`:8`; the store has no retire, so that was a rebuild of `data/ontology/ontology.cc` with the ja-JP text unchanged. en-US `:3` (blunt anger) carries `AtMostOrUnset` hedge and affection bounds, and `:5` (hedging) and `:8` (affection) each an `AtMostOrUnset` certainty bound (as ja-JP `:7`), so `:3`/`:5`, `:3`/`:8`, `:5`/`:6` and `:6`/`:8` never co-select; `:5`'s certainty clause is that condition and no longer prose; `:6` and the Scene entry `:10` still co-select and are kept apart by scoping in the text. ja-JP `:9` (surprise) states its question ending as available, not prescribed, so `:6`/`:9`, `:5`/`:9` and `:3`/`:9` stay co-selectable and are reconciled by wording, not by condition. +ja-JP `:5` (hedging), `:7` (affection) and `:8` (restrained sadness) carry certainty and restraint conditions, through `AtMostOrUnset` bounds (an unrated certainty or restraint does not defeat them), so the hedging, certainty, affection, restraint and sadness entries never co-select on the pairs `:5`/`:6`, `:4`/`:7`, `:6`/`:7` and `:6`/`:8`; ja-JP `:3` (anger) carries `AtMostOrUnset` hedge and affection bounds, as en-US `:3`, so `:3`/`:5` and `:3`/`:7` never co-select; the store has no retire, so that was a rebuild of `data/ontology/ontology.cc` with the ja-JP text unchanged. en-US `:3` (blunt anger) carries `AtMostOrUnset` hedge and affection bounds, and `:5` (hedging) and `:8` (affection) each an `AtMostOrUnset` certainty bound (as ja-JP `:7`), so `:3`/`:5`, `:3`/`:8`, `:5`/`:6` and `:6`/`:8` never co-select; `:5`'s certainty clause is that condition and no longer prose; `:6` and the Scene entry `:10` still co-select and are kept apart by scoping in the text. ja-JP `:9` (surprise) states its question ending as available, not prescribed, so `:6`/`:9`, `:5`/`:9` and `:3`/`:9` stay co-selectable and are reconciled by wording, not by condition. For the first AquaSynth speech-training handoff, see [Tiny PanPhon v0.1 Speech Curriculum](./examples/speech-training/tiny-panphon-v0.1/README.md). diff --git a/crates/weksa/tests/original_corpus.rs b/crates/weksa/tests/original_corpus.rs index 6c73ed2..99e7e30 100644 --- a/crates/weksa/tests/original_corpus.rs +++ b/crates/weksa/tests/original_corpus.rs @@ -1031,36 +1031,46 @@ fn sweep_seed_pairs( } } -/// ja-JP seed entries :4 to :8 over the stance and discourse grades that bear on -/// them (hedge, certainty, sadness, affection, restraint): the pairs that gave -/// opposed instructions (hedge against certainty, particles, final force) never -/// hold together; and each of :5, :7, :8 still fires where it should (hedged at -/// certainty 700-799, affection with certainty or restraint unrated). +/// ja-JP seed entries :3 to :8 over the stance and discourse grades that bear on +/// them (anger, hedge, certainty, sadness, affection, restraint): the pairs that +/// gave opposed instructions (clipped anger against hedge or soft particles, +/// hedge against certainty, particles, final force) never hold together; and +/// each of :3, :5, :7, :8 still fires where it should (anger with hedge and +/// affection unrated or below 600, hedged at certainty 700-799, affection with +/// certainty or restraint unrated). #[test] fn ja_seed_pairs_never_co_select() { let (n, s) = (None, Some); sweep_seed_pairs( "ja-JP", - ["hedge", "certainty", "sadness", "affection", "restraint"], - &[(5, 6), (4, 7), (6, 7), (6, 8)], + ["anger", "hedge", "certainty", "sadness", "affection", "restraint"], + &[(5, 6), (4, 7), (6, 7), (6, 8), (3, 5), (3, 7)], &[ - (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)]), - (7, [n, n, n, s(700), n]), - (7, [s(1000), s(0), s(1000), s(600), s(0)]), - (8, [n, s(799), s(700), n, s(700)]), - (8, [n, n, s(600), n, s(600)]), - (6, [n, s(800), n, n, n]), + (3, [s(700), n, n, n, n, s(300)]), + (3, [s(700), s(599), n, n, s(599), s(300)]), + (3, [s(1000), s(0), s(799), n, s(0), s(0)]), + (5, [n, s(600), n, n, n, n]), + (5, [n, s(700), s(799), n, n, n]), + (5, [n, s(700), n, n, n, n]), + (7, [n, n, s(799), n, s(700), s(599)]), + (7, [n, n, n, n, s(700), n]), + (7, [n, s(1000), s(0), s(1000), s(600), s(0)]), + (8, [n, n, s(799), s(700), n, s(700)]), + (8, [n, n, n, s(600), n, s(600)]), + (6, [n, n, s(800), n, n, n]), ], &[ - (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)]), - (8, [n, n, s(600), n, s(599)]), + (3, [s(700), s(600), n, n, n, s(300)]), + (3, [s(700), n, n, n, s(600), s(300)]), + (3, [s(699), n, n, n, n, s(300)]), + (3, [s(700), n, n, n, n, s(301)]), + (3, [s(700), n, n, n, n, n]), + (8, [n, n, n, s(599), n, s(700)]), + (8, [n, n, n, n, n, s(700)]), + (5, [n, s(599), n, n, n, n]), + (7, [n, n, n, n, s(599), n]), + (7, [n, n, n, n, s(700), s(600)]), + (8, [n, n, n, s(600), n, s(599)]), ], ); } diff --git a/data/ontology/ontology.cc b/data/ontology/ontology.cc index c385a8c007c470d6a7a685c0e98e9ab6d64672f5..4cd355459606fe8a02c683e0c2e9e69c54f0c7d3 100644 GIT binary patch delta 353 zcmZ3SFfDO|I3ug6xs{Q@W*J5o7&Dd0jR`8cfh7>eWMk)nG8c<;!UScw6=1p?d8%Qe z2l@PAqM`z~V9YOq3t-Hd!bLEqfG9tc0N4ppM;R+-EKSYR4Go^$sAs!5M?4Lt=()4YQ_5h9Aakle+^`kggyD6YWs)WR!-Q%_K8pX;z}HR{%5Pa`&Rd+}y;XDU(0& zh)&Mok(w;6VmNs_PvK@?6-LI%=QLa=Pf%5bhQKb>B$&yH>f$hyZ8c+HqVu#q!I)EZ L;I1gsTgwOlwO?Jw delta 353 zcmbQ1xHw^hI3ugEk(H^@W*J5o7&Dd0jR`8cfh7>eWMk)nG8c<;!UScw6=1p?d8%Qe z2l@PAqM`z~V9YOq3t-Hd!bLEqfG9sqn~L~4nCNwhG8i*RN*bo1NCvL9P3{g%LArtr zOhJc|C!;jjKT$^+SI$_Pm8k0#z|6SZy(lp^H?e5a:`, `n` canonical decimal >= 1 (families: concept, frame, role, relation, speech_act, feature, referent_kind, extension); type `weksa.inventory_entry`, with a bounded gloss, value kind (option labels bounded), the slots a feature may sit in (`Discourse`, `Referent`, `Predication`, `Relation`; `Stance` from cut `speaker-state`, `Speaker` and `Scene` from cut `speaker-scene`), `introduced_rev` and optional `retired_rev`. Speaker axes, scene relations and affects are features of those slots, so the loop grows them like any closed-class family and convergence covers them | Added or retired by an inventory revision; never edited in place (a changed meaning is a retire plus an add); a retired id still resolves for packets of earlier revisions | The loop's accepted rounds, whose minting call the context builder assembles from Train items only; `weksa inventory admit` for one model-drafted `EditDraft` outside a run (cap 256, reviewed whole in its cut; same numbering and admission check as the loop); Self on merge to main. `data/original` revs 5 (233 concepts and frames) and 6 (five concepts closing named gaps) were drafted by claude-sonnet-5-5 (Weksa Hands, model-drafted original-bed lexicon from Train and Validation passages); Validation-informed: numbers on this bed measure lowering, never generalization or convergence. Residue after rev 6, not amended (each fresh coverage reader names new gaps; the loop's growth path owns them): simultaneity (ながら), distal deixis (あの), 'first' (まず), counterfactual mood, 'at least', emphatic question; heaven versus sky for the visible 天 stays weak. Admission checks form, not text | | Inventory revision | Key `rev:`, type `weksa.inventory_revision`, with parent, change list and `frozen` | Appended per accepted round; exactly one revision is ever marked frozen, by the convergence test | The loop's accept rule appends; the convergence test freezes; Self records the freeze as a ruling | | Target profile | Locale or language-project id (`en-US`, `ja-JP`, a conlang's slug). Until entries grow in rounds there is no profile revision document: a run names the profile it lowered with by the ontology store's path and digest in its `RunRecord` (cut `language-ontology`); `profile::` revision documents arrive with follow-up `language-ontology-growth` | The ontology store is revised by commit; a run pins it and refuses drift; it likewise pins the speaker-state store (`RunRecord` keys 17 and 18, `Drift(SpeakerState)`, cut `language-ontology-scene`) | Profile authors and accepted rounds; never the lowerer's defaults (`persona-drives-register`) | -| Language ontology entry (cut `language-ontology`) | Key `onto::`, `n` from 1 per language; type `weksa.ontology_entry` in `data/ontology/ontology.cc`: the language, the revision of the inventory it was admitted through (provenance: beds number revisions independently and a run reads each condition's feature at its own head), a layer (lexicon, grammar, discourse, phonology, orthography), at most four conditions (a feature id of slot `Stance`, `Discourse` or `Scene` with `AtLeast`/`AtMost`/`AtMostOrUnset` a grade or `Is` an option or flag; a `Scene` condition reads the relation of the item's speaker to its addressee that `with_scene` selected; slot `Speaker` and community ids wait on follow-up `language-ontology-communities`), a choice of 1 to 200 bytes, at most three examples of 1 to 120 bytes, and an `Annotator`. Whether an entry's text keeps politeness on the scene is a model reader's judgment, owed per change (a mint owes it under `language-ontology-growth`), not a test | Admitted in all-or-nothing batches through `OntologyStore::admit`, immutable, never edited; retire arrives with `language-ontology-growth`. The run pins the store like the entity store (path and digest, `Drift(Ontology)`), never copies it, because no loop step writes it yet. Cut `language-ontology-seed` converts by drafting, not by parse: a fresh model drafts each language's seed from that language's YAML and the inventory's feature lines with no corpus text, then deletes `data/target-language-ontology/` and `.weksa/cultural-ontology/` in the same cut | Seed: a labelled model (`Annotator::Model`), no operator gate, never Test evidence (`ja-ontology-owner-answer`); attestation (operator, native reader) appends later. Accepted rounds later, through a mint call from Train items only. Selection is `ontology::select(ontology, language, view)`, called only inside `Prompt::lower`, so no caller picks entries; the prompt prints each selected entry's id, layer, choice and examples. Its text is minted text for the leak diagnostic, which today has no runtime caller (follow-up `leak-diagnostic-in-round`). The store was rebuilt without ja-JP `:14` and `:15` (above-status Scene entries; a paired measure found them net-negative on register, follow-up `ja-scene-entries-lower-register-agreement`), so ja-JP ends at `:13`: an above-status out-group addressee, and an above-status in-group addressee below intimacy 700, select no ja-JP Scene entry (`:12` still selects in-group at intimacy 700 or more regardless of status) until a native reader attests a replacement (`ja-native-reader-scenes`). ja-JP `:5`, `:7` and `:8` were revised by certainty and restraint `AtMostOrUnset` conditions (holds when the feature is unrated or at most the grade; `AtMost` still fails on an unrated feature) in a store rebuild (the store has no retire, so a conditions change is a rebuild), which makes ja-JP's hedging, certainty, affection, restraint and sadness entries disjoint on `:5`/`:6`, `:4`/`:7`, `:6`/`:7`, `:6`/`:8`; en-US `:3` carries `AtMostOrUnset` hedge and affection bounds, `:5` an `AtMostOrUnset` certainty bound (the clause it held in prose) and `:8` one too (as ja-JP `:7`), which makes `:3`/`:5`, `:3`/`:8`, `:5`/`:6` and `:6`/`:8` disjoint, while `:6`/`:10` stay co-selectable and are kept apart by scoping in `:6`'s text; ja-JP `:9` was reworded in a rebuild to state its question ending as available, so `:6`/`:9`, `:5`/`:9` and `:3`/`:9` stay co-selectable and are reconciled by wording, not by condition | +| Language ontology entry (cut `language-ontology`) | Key `onto::`, `n` from 1 per language; type `weksa.ontology_entry` in `data/ontology/ontology.cc`: the language, the revision of the inventory it was admitted through (provenance: beds number revisions independently and a run reads each condition's feature at its own head), a layer (lexicon, grammar, discourse, phonology, orthography), at most four conditions (a feature id of slot `Stance`, `Discourse` or `Scene` with `AtLeast`/`AtMost`/`AtMostOrUnset` a grade or `Is` an option or flag; a `Scene` condition reads the relation of the item's speaker to its addressee that `with_scene` selected; slot `Speaker` and community ids wait on follow-up `language-ontology-communities`), a choice of 1 to 200 bytes, at most three examples of 1 to 120 bytes, and an `Annotator`. Whether an entry's text keeps politeness on the scene is a model reader's judgment, owed per change (a mint owes it under `language-ontology-growth`), not a test | Admitted in all-or-nothing batches through `OntologyStore::admit`, immutable, never edited; retire arrives with `language-ontology-growth`. The run pins the store like the entity store (path and digest, `Drift(Ontology)`), never copies it, because no loop step writes it yet. Cut `language-ontology-seed` converts by drafting, not by parse: a fresh model drafts each language's seed from that language's YAML and the inventory's feature lines with no corpus text, then deletes `data/target-language-ontology/` and `.weksa/cultural-ontology/` in the same cut | Seed: a labelled model (`Annotator::Model`), no operator gate, never Test evidence (`ja-ontology-owner-answer`); attestation (operator, native reader) appends later. Accepted rounds later, through a mint call from Train items only. Selection is `ontology::select(ontology, language, view)`, called only inside `Prompt::lower`, so no caller picks entries; the prompt prints each selected entry's id, layer, choice and examples. Its text is minted text for the leak diagnostic, which today has no runtime caller (follow-up `leak-diagnostic-in-round`). The store was rebuilt without ja-JP `:14` and `:15` (above-status Scene entries; a paired measure found them net-negative on register, follow-up `ja-scene-entries-lower-register-agreement`), so ja-JP ends at `:13`: an above-status out-group addressee, and an above-status in-group addressee below intimacy 700, select no ja-JP Scene entry (`:12` still selects in-group at intimacy 700 or more regardless of status) until a native reader attests a replacement (`ja-native-reader-scenes`). ja-JP `:5`, `:7` and `:8` were revised by certainty and restraint `AtMostOrUnset` conditions (holds when the feature is unrated or at most the grade; `AtMost` still fails on an unrated feature) in a store rebuild (the store has no retire, so a conditions change is a rebuild), which makes ja-JP's hedging, certainty, affection, restraint and sadness entries disjoint on `:5`/`:6`, `:4`/`:7`, `:6`/`:7`, `:6`/`:8`, and ja-JP `:3` (anger) carries `AtMostOrUnset` hedge and affection bounds, as en-US `:3`, which makes `:3`/`:5` and `:3`/`:7` disjoint; en-US `:3` carries `AtMostOrUnset` hedge and affection bounds, `:5` an `AtMostOrUnset` certainty bound (the clause it held in prose) and `:8` one too (as ja-JP `:7`), which makes `:3`/`:5`, `:3`/`:8`, `:5`/`:6` and `:6`/`:8` disjoint, while `:6`/`:10` stay co-selectable and are kept apart by scoping in `:6`'s text; ja-JP `:9` was reworded in a rebuild to state its question ending as available, so `:6`/`:9`, `:5`/`:9` and `:3`/`:9` stay co-selectable and are reconciled by wording, not by condition | | Community (cut `language-ontology`, follow-up `language-ontology-communities`) | Key `community:`; type `weksa.community`, converted from `data/cultural-ontology/cultures/` and `referents/` (YAML deleted in the same cut) | Revised by commit; a speaker names the communities it belongs to by id | The cultural ontology's author (owner-attested evidence only; Discord-only content stays deleted, `discord-only-content-deleted`) | | Speaker (cut `speaker-scene`) | Key `speaker:@`; type `weksa.speaker`: stable axes as feature values of slot `Speaker` (origin, socioeconomic standing, age cohort, education and whatever the loop adds), at an inventory revision, and an `Annotator` | A new revision appends, never edits; a corpus item and every prior turn name a speaker slug, and a round records the speaker revisions it read | The annotator it names: `PersonaSnapshot` (a projection of a `gamecult.persona_state.v0` document, naming its source document and `updatedAt`), `Operator`, `WorkMetadata` (a public-domain work's own cast list and narration), or `Model { family, generator }` (the 2b `ModelFamily`) | | Scene (cut `speaker-scene`) | Key `scene:@`, the item's split group; type `weksa.scene`: participants (speaker slugs) and, per ordered pair, relation features of slot `Scene` (relative status, intimacy, in-group, audience and whatever the loop adds), at an inventory revision (provenance; a run reads the features at its own head), and an `Annotator` | As Speaker. Keyed by the group, so a scene never straddles the split. `data/original/speaker-state.cc` holds Model-annotated keeper scenes, one per Train or Validation group of both languages (`weksa scene put|dump`); a Test group has none and reads `NoScene` | As Speaker; a model-annotated scene is never Test evidence | From 754322252bbd53f81b151da83d14c8c0b84a7cdc Mon Sep 17 00:00:00 2001 From: Weksa Date: Thu, 12 Nov 2026 22:20:44 +0000 Subject: [PATCH 09/41] ontology-mint-probe: weksa loop mint-ontology proposes entries from Train items only, never writes the run ontology (#63) --- crates/weksa/src/context.rs | 76 ++++- crates/weksa/src/main.rs | 29 +- crates/weksa/src/run.rs | 63 +++- crates/weksa/tests/cli.rs | 44 +++ crates/weksa/tests/context.rs | 23 ++ crates/weksa/tests/ontology_mint.rs | 362 +++++++++++++++++++++++ docs/targets/interlingua-lowering-map.md | 2 +- 7 files changed, 595 insertions(+), 4 deletions(-) create mode 100644 crates/weksa/tests/ontology_mint.rs diff --git a/crates/weksa/src/context.rs b/crates/weksa/src/context.rs index 70d875a..98dfe7f 100644 --- a/crates/weksa/src/context.rs +++ b/crates/weksa/src/context.rs @@ -14,6 +14,11 @@ //! entries that `ontology::select` chose for the view; the caller never names //! entries. //! +//! An ontology mint prompt is a second Train-only prompt: the [`TrainItems`] of +//! one language, the inventory's Stance, Discourse and Scene features (the only +//! ones a condition can read) and that language's existing entry lines. It reads +//! no packet, no score and no held-out text. +//! //! Item text may hold line breaks; the renderer indents every continuation line //! (`indented`), so item text cannot forge a `[key]` line or a paragraph. //! Item blocks are data from the run's pinned corpus, reached only through @@ -28,7 +33,7 @@ use std::marker::PhantomData; use serde::Serialize; use crate::corpus::{CorpusItem, CorpusItemId}; -use crate::inventory::{Inventory, InventoryEntry, OptionLabel, ValueKind}; +use crate::inventory::{Inventory, InventoryEntry, OptionLabel, Slot, ValueKind}; use crate::lower::{EntityForms, LowerError, entity}; use crate::ontology::{Ontology, select}; use crate::packet::{ @@ -82,6 +87,13 @@ pub const RECALL_INSTRUCTIONS: &str = "\ Below is the opening of a passage, with what is known of where it comes from. Continue it exactly as its source words it, from memory, until the passage ends. If you do not remember it, give your best guess in the same voice. Answer with one JSON object and nothing else: {\"text\": \"...\"}, the continuation only, not the opening. No code fence, no commentary."; +/// The instructions of an ontology mint: drafting entries for one language from +/// its Train lines. Fixed per run by `PROMPT_SOURCE_DIGEST`. +pub const MINT_ONTOLOGY_INSTRUCTIONS: &str = "\ +Below are lines written in one language (the language line), the features an ontology condition may test, and the entries that language's ontology already has. Draft new entries: choices this language's culture makes, for a speaker in a stance and scene, about word, grammar, discourse, sound or script, that the lines show. +Answer with one JSON object and nothing else: {\"entries\": [{\"layer\": \"...\", \"when\": [...], \"choice\": \"...\", \"examples\": [...]}]}. No code fence, no commentary. +Give 1 to 8 entries. layer is one of lexicon, grammar, discourse, phonology, orthography. when holds at most 4 conditions, each {\"slot\": \"Stance\" | \"Discourse\" | \"Scene\", \"feature\": \"\", \"test\": {\"AtLeast\": } | {\"AtMost\": } | {\"AtMostOrUnset\": } | {\"Is\": }}, over the listed feature ids only; when may be empty when a choice holds for every line of the language. choice states a pattern the lines show, in at most 200 bytes, without quoting a line. examples are original short phrases of the language, never copied from the lines below, at most 3."; + /// The live Train items of a corpus, in key order. The only input minting /// reads; it cannot be built from a slice, and no accessor returns text or an /// item. @@ -502,6 +514,56 @@ impl Prompt { } } + /// [`MINT_ONTOLOGY_INSTRUCTIONS`], the `language` line, the Stance, + /// Discourse and Scene features of `inventory` live at `rev` (grade, flag or + /// options: all a condition can read), the entries `ontology` already holds + /// for `language` as ` `, then the Train items of exactly + /// `language` in key order without prior turns. `None` when there is none. + pub(crate) fn mint_ontology( + train: &TrainItems, + language: &str, + inventory: &Inventory, + rev: u32, + ontology: &Ontology, + ) -> Option { + let items: Vec<&CorpusItem> = train + .items + .iter() + .filter(|item| item.language == language) + .collect(); + if items.is_empty() { + return None; + } + let features: String = inventory + .entries() + .filter(|e| { + e.live_at(rev) + && e.value_kind.is_some() + && e.applies_to + .iter() + .any(|s| matches!(s, Slot::Stance | Slot::Discourse | Slot::Scene)) + }) + .map(|e| format!("\n{}", entry_line(e))) + .collect(); + let existing: String = ontology + .entries() + .iter() + .filter(|e| e.language == language) + .map(|e| format!("\n{} {}", e.key(), e.choice)) + .collect(); + let mut parts = vec![ + MINT_ONTOLOGY_INSTRUCTIONS.to_string(), + format!("language: {language}"), + format!("features rev:{rev}{features}"), + format!("entries{existing}"), + ]; + parts.extend(items.iter().map(|item| block(item, None))); + Some(Prompt { + text: parts.join("\n\n"), + items: items.iter().map(|item| item.id.as_str().to_string()).collect(), + }) + } + /// [`ENCODE_INSTRUCTIONS`], the one offered item with its prior turns resolved /// against `train`, the entities a packet for it may cite, and the entries /// of `inventory` live at `rev`. @@ -663,6 +725,18 @@ mod tests { ); } + #[test] + fn an_ontology_mint_over_no_item_of_the_language_is_no_prompt() { + let inv = Inventory::default(); + let train = TrainItems { items: vec![] }; + assert!(Prompt::mint_ontology(&train, "en-US", &inv, 1, &Ontology::empty()).is_none()); + let mut held = item("item:a:1", "x", &group_in(Split::Train), false); + held.language = "ja-JP".into(); + let train = TrainItems { items: vec![held] }; + assert!(Prompt::mint_ontology(&train, "en-US", &inv, 1, &Ontology::empty()).is_none()); + assert!(Prompt::mint_ontology(&train, "ja-JP", &inv, 1, &Ontology::empty()).is_some()); + } + #[test] fn a_mint_prompt_over_no_train_items_is_the_brief_the_feedback_and_the_listing() { let none = TrainItems { items: vec![] }; diff --git a/crates/weksa/src/main.rs b/crates/weksa/src/main.rs index 24e68b0..92c7d5e 100644 --- a/crates/weksa/src/main.rs +++ b/crates/weksa/src/main.rs @@ -15,7 +15,7 @@ use weksa::packet::{FeatValue, FeatureValue, Grade}; use weksa::packet::proof_packet; use weksa::model::RecordedAnswers; use weksa::run::{ - AblationOutcome, CycleOutcome, LowererReach, RecallOutcome, RoundOutcome, RunPaths, RunStores, cycle, round, + AblationOutcome, CycleOutcome, LowererReach, OntologyMintOutcome, RecallOutcome, RoundOutcome, RunPaths, RunStores, cycle, round, }; use weksa::score::ScoreInput; use weksa::{ @@ -131,6 +131,15 @@ enum LoopCommand { /// half). Prompts and answers live in `/recall`; the command exits 3 /// until every prompt has an answer. A diagnostic, never a gate. Recall { root: PathBuf }, + /// Draft ontology entries from the run's Train items of one language. + /// Prompts and answers live in `/ontology-mint`; the command exits 3 + /// until the prompt has an answer. Admission is `weksa ontology admit` + /// into a copy, never into the run's pinned file. + MintOntology { + root: PathBuf, + #[arg(long)] + language: String, + }, /// Ask whether the lowerer uses a packet's stance: for each live Train and /// Validation packet of round ROUND, ask again with the stance as it is, /// emptied, and swapped for the next item's, and read how far the lowering @@ -1122,6 +1131,24 @@ fn main() -> Result<()> { RecallOutcome::Read(reading) => println!("{}", reading.line()), } } + Command::Loop(LoopCommand::MintOntology { root, language }) => { + let run = RunStores::open(&root)?; + let mut files = AnswerFiles::new(run.ontology_mint_dir(), run.record().model.clone()); + match run.mint_ontology(&mut files, &language)? { + OntologyMintOutcome::Unanswered { prompt } => { + println!("unanswered {prompt}"); + std::process::exit(3); + } + OntologyMintOutcome::Drafted { prompt, entries } => println!( + "drafted {entries} entries {}", + run.ontology_mint_dir().join(format!("{prompt}.answer")).display() + ), + OntologyMintOutcome::Refused { code } => { + println!("{code}"); + std::process::exit(1); + } + } + } Command::Loop(LoopCommand::Cycle { root, ollama_url }) => { let unreadable = |_| anyhow::anyhow!("a store would not read"); let mut run = RunStores::open(&root)?; diff --git a/crates/weksa/src/run.rs b/crates/weksa/src/run.rs index 51be889..d58e2cb 100644 --- a/crates/weksa/src/run.rs +++ b/crates/weksa/src/run.rs @@ -40,7 +40,9 @@ use unicode_segmentation::UnicodeSegmentation; use crate::context::{EditFeedback, EncoderOffer, Prompt, TrainItems}; use crate::corpus::{CorpusItem, CorpusItemId, ModelFamily, Source}; -use crate::encode::{EditDraft, LoweringDraft, MAX_EDIT_CHANGES, PacketDraft, encoder_id}; +use crate::encode::{ + EditDraft, LoweringDraft, MAX_EDIT_CHANGES, OntologyDraft, PacketDraft, encoder_id, +}; use crate::form::{is_attestation, is_language_tag, is_slug}; use crate::model::{ModelPort, PortError}; use crate::packet::{Packet, Stance}; @@ -1157,6 +1159,65 @@ impl RunStores { } } +/// What an ontology mint came to: the call's prompt digest, never an entry +/// admitted. +#[derive(Debug, PartialEq, Eq)] +pub enum OntologyMintOutcome { + /// The prompt is written; nobody has answered it. + Unanswered { prompt: String }, + /// The answer reads as a draft of `entries` entries; the answer file is the + /// draft, for `weksa ontology admit`. + Drafted { prompt: String, entries: usize }, + /// Nothing asked, or the answer is no draft: a closed code. + Refused { code: &'static str }, +} + +impl RunStores { + /// Asks `model` to draft ontology entries for `language` from the run's + /// Train items of that language. Writes the prompt and answer files of + /// `model` and nothing else: the draft is admitted, if ever, by + /// `weksa ontology admit` into a copy of the ontology, never here. + pub fn mint_ontology( + &self, + model: &mut dyn ModelPort, + language: &str, + ) -> Result { + let store = |_| RunError::Store; + if !self.record.panel.iter().any(|tag| tag == language) { + return Ok(OntologyMintOutcome::Refused { code: "language-not-in-panel" }); + } + let inventory = self.inventory.inventory().map_err(store)?; + let rev = inventory.latest().ok_or(RunError::NoInventory)?.n; + let ontology = self.ontology.ontology().map_err(store)?; + let train = self.train().map_err(store)?; + // A panel language has a live Train item (`create` requires it and the + // corpus is pinned), so no prompt here is a store that broke its pin. + let prompt = Prompt::mint_ontology(&train, language, &inventory, rev, &ontology) + .ok_or(RunError::Malformed("ontology-mint train"))?; + match model.answer(&prompt) { + Ok(answer) => Ok(match OntologyDraft::parse(&answer) { + Ok(draft) => OntologyMintOutcome::Drafted { + prompt: prompt.digest(), + entries: draft.entries.len(), + }, + Err(e) => OntologyMintOutcome::Refused { code: e.class.code() }, + }), + Err(PortError::Unanswered) => Ok(OntologyMintOutcome::Unanswered { + prompt: prompt.digest(), + }), + Err(PortError::Io(ErrorKind::InvalidData)) => { + Ok(OntologyMintOutcome::Refused { code: "invalid-data" }) + } + Err(PortError::Io(kind)) => Err(RunError::Io(kind)), + } + } + + /// `/ontology-mint`, where a mint's prompts and answers live. + pub fn ontology_mint_dir(&self) -> PathBuf { + self.root.join("ontology-mint") + } +} + /// What the lowerer's answer did to each variant of a packet's stance, per /// split. Means only; no key, text or stance value. #[derive(Clone, Debug, PartialEq)] diff --git a/crates/weksa/tests/cli.rs b/crates/weksa/tests/cli.rs index 2940efd..40aa288 100644 --- a/crates/weksa/tests/cli.rs +++ b/crates/weksa/tests/cli.rs @@ -1452,6 +1452,50 @@ fn open_dao_run(d: &std::path::Path) { assert!(o.status.success(), "{}", out(&o)); } +/// `weksa loop mint-ontology`: exit 3 and a prompt file until answered, exit 0 +/// and the answer path once it is a draft, a missing language or one outside +/// the panel refused, and nothing of the run written. +#[test] +fn loop_mint_ontology_protocol() { + let d = tempfile::tempdir().unwrap(); + open_dao_run(d.path()); + let root = d.path().join("canaryroot"); + let held = |name: &str| std::fs::read(root.join(name)).unwrap(); + let (run_cc, onto) = (held("run.cc"), std::fs::read(d.path().join("o.cc")).unwrap()); + let mint = |args: &[&str]| weksa(d.path(), &[&["loop", "mint-ontology", "canaryroot"], args].concat()); + + let none = mint(&[]); + assert_eq!(none.status.code(), Some(2), "{}", out(&none)); + assert!(!root.join("ontology-mint").exists()); + + let outside = mint(&["--language", "ja-JP"]); + assert_eq!(outside.status.code(), Some(1), "{}", out(&outside)); + assert_eq!(out(&outside), "language-not-in-panel\n"); + assert!(!root.join("ontology-mint").exists(), "a refused mint wrote a prompt"); + + let first = mint(&["--language", "en-US"]); + assert_eq!(first.status.code(), Some(3), "{}", out(&first)); + let text = out(&first); + let digest = text.strip_prefix("unanswered ").unwrap().trim_end(); + assert_eq!(digest.len(), 16, "{text}"); + let dir = root.join("ontology-mint"); + assert!(dir.join(format!("{digest}.prompt")).is_file()); + + let answer = dir.join(format!("{digest}.answer")); + std::fs::write(&answer, r#"{"entries":[{"layer":"Grammar","choice":"a pattern"}]}"#).unwrap(); + let done = mint(&["--language", "en-US"]); + assert_eq!(done.status.code(), Some(0), "{}", out(&done)); + assert_eq!(out(&done), format!("drafted 1 entries canaryroot/ontology-mint/{digest}.answer\n")); + + std::fs::write(&answer, "not json").unwrap(); + let bad = mint(&["--language", "en-US"]); + assert_eq!(bad.status.code(), Some(1), "{}", out(&bad)); + assert_eq!(out(&bad), "syntax\n"); + + assert_eq!(held("run.cc"), run_cc, "the mint wrote the run record"); + assert_eq!(std::fs::read(d.path().join("o.cc")).unwrap(), onto); +} + /// The family `loop open` pinned at `root`, read from the run record. fn pinned_family(d: &std::path::Path, root: &str, flag: &[&str]) -> weksa::corpus::ModelFamily { let mut args = vec![ diff --git a/crates/weksa/tests/context.rs b/crates/weksa/tests/context.rs index 82cf5b9..3c66989 100644 --- a/crates/weksa/tests/context.rs +++ b/crates/weksa/tests/context.rs @@ -692,6 +692,29 @@ mod lowering { } } + /// The mint cut added no line to what the lowerer sees: a prompt with a + /// selected ontology entry has the digest it had at af0a56d. + #[test] + fn the_lowering_prompt_of_a_fixed_packet_is_unchanged_by_the_ontology_mint() { + use weksa::encode::OntologyDraft; + use weksa::speaker::Annotator; + let (view, inv, entities, item) = dao(2); + let store = InventoryStore::open(&data("daodejing/inventory.cc")).unwrap(); + let dir = tempfile::tempdir().unwrap(); + let mut onto = weksa::OntologyStore::open(&dir.path().join("o.cc")).unwrap(); + let annotator = Annotator::Model { + family: weksa::corpus::ModelFamily::Anthropic, + generator: "golden".into(), + }; + let draft = r#"{"entries":[{"layer":"Grammar","choice":"golden choice","examples":["golden example"]}]}"#; + let entries = OntologyDraft::parse(draft).unwrap().into_entries("en-US", 3, 1, &annotator); + onto.admit(entries, &store).unwrap(); + let prompt = + Prompt::lower(&view, &item, "en-US", &inv, &entities, &onto.ontology().unwrap()).unwrap(); + assert!(prompt.text().contains("golden choice")); + assert_eq!(prompt.digest(), "4a40eb57282b059d"); + } + #[test] fn lower_prompt_moves_with_the_stance_alone() { use weksa::packet::{FeatValue, FeatureValue, Grade, Stance}; diff --git a/crates/weksa/tests/ontology_mint.rs b/crates/weksa/tests/ontology_mint.rs new file mode 100644 index 0000000..891f543 --- /dev/null +++ b/crates/weksa/tests/ontology_mint.rs @@ -0,0 +1,362 @@ +//! The ontology mint (`weksa loop mint-ontology`): a Train-only call that drafts +//! entries for `weksa ontology admit`. It shows a model the Train lines of one +//! panel language, the features a condition can read and that language's entry +//! lines; it admits nothing and writes nothing of the run. + +mod common; + +use std::path::Path; + +use common::{cast, entities_in, group_in_bucket, item_in}; +use weksa::context::Prompt; +use weksa::corpus::{ModelFamily, Source}; +use weksa::inventory::{Change, seed}; +use weksa::model::{AnswerFiles, ModelPort, PortError}; +use weksa::run::{LowererReach, OntologyMintOutcome, RunPaths, RunStores}; +use weksa::speaker::Annotator; +use weksa::{CorpusStore, InventoryStore, OntologyStore, Slot, ValueKind}; + +/// Records every prompt shown; answers with `reply`. +struct Record { + prompts: Vec<(String, Vec)>, + reply: String, +} + +impl Record { + fn new(reply: &str) -> Self { + Self { prompts: vec![], reply: reply.to_string() } + } +} + +impl ModelPort for Record { + fn model(&self) -> &str { + "record" + } + fn answer(&mut self, p: &Prompt) -> Result { + self.prompts.push((p.text().to_string(), p.item_keys().to_vec())); + Ok(self.reply.clone()) + } +} + +fn public() -> Source { + Source::PublicDomain { + work: "A Work".into(), + author: "An Author".into(), + edition_url: "https://example.org/e".into(), + licence: "CC0".into(), + jurisdiction: "US".into(), + translator: "A Translator".into(), + edition_year: 1900, + } +} + +const STANCE_G: &str = "feature:60"; +const DISC_FLAG: &str = "feature:61"; +const REF_ONLY: &str = "feature:62"; +const PRED_ONLY: &str = "feature:63"; +const STANCE_RETIRED: &str = "feature:64"; +const SCENE_G: &str = "feature:65"; + +/// A fixture: items in en-US and ja-JP across every split and a withdrawal, an +/// inventory with condition-readable and unreadable features, an ontology with +/// en-US and ja-JP entries, and a run over them with `panel`. +fn fixture(dir: &Path, panel: &[&str]) -> RunStores { + let entities = entities_in(dir); + let mut corpus = CorpusStore::open(&dir.join("c.cc")).unwrap(); + let rows = [ + ("item:en:1", "en-US", "entrain mark one", 10, cast(), false), + ("item:en:2", "en-US", "entrain mark two", 11, cast(), false), + ("item:en:3", "en-US", "envalid mark three", 50, cast(), false), + ("item:en:4", "en-US", "engone mark four", 12, cast(), true), + ("item:en:5", "en-US", "entest mark five", 90, public(), false), + ("item:ja:1", "ja-JP", "jatrain mark one", 13, cast(), false), + ("item:ja:2", "ja-JP", "javalid mark two", 51, cast(), false), + ("item:ja:3", "ja-JP", "jatest mark three", 91, public(), false), + ]; + for (id, language, text, bucket, source, withdrawn) in rows { + let mut item = item_in(id, text, &group_in_bucket(bucket), source); + item.language = language.into(); + corpus.add(item, &entities).unwrap(); + if withdrawn { + corpus.withdraw(id).unwrap(); + } + } + drop(corpus); + + let mut inv = InventoryStore::open(&dir.join("i.cc")).unwrap(); + let (rev1, entries) = seed(); + inv.admit_revision(rev1, entries).unwrap(); + let f = |id, kind, slots: &[Slot]| common::feature(id, kind, slots); + let features = vec![ + f(STANCE_G, ValueKind::Grade, &[Slot::Stance]), + f(DISC_FLAG, ValueKind::Flag, &[Slot::Discourse]), + f(REF_ONLY, ValueKind::Grade, &[Slot::Referent]), + f(PRED_ONLY, ValueKind::Grade, &[Slot::Predication]), + f(STANCE_RETIRED, ValueKind::Grade, &[Slot::Stance]), + f(SCENE_G, ValueKind::Grade, &[Slot::Scene]), + ]; + let changes = features.iter().map(|e| Change::Add(e.id)).collect(); + let mut features = features; + for e in &mut features { + e.introduced_rev = 2; + } + inv.admit_revision(common::rev_with(changes, 2, Some(1)), features).unwrap(); + inv.admit_revision( + common::rev_with(vec![Change::Retire(common::iv(STANCE_RETIRED))], 3, Some(2)), + vec![], + ) + .unwrap(); + + let mut onto = OntologyStore::open(&dir.join("ontology.cc")).unwrap(); + let annotator = Annotator::Model { family: ModelFamily::Anthropic, generator: "seed".into() }; + let entry = |language: &str, choice: &str, examples: &[&str]| { + weksa::encode::OntologyDraft::parse(&format!( + r#"{{"entries":[{{"layer":"Grammar","choice":"{choice}","examples":[{}]}}]}}"#, + examples.iter().map(|x| format!("\"{x}\"")).collect::>().join(",") + )) + .unwrap() + .into_entries(language, 3, 1, &annotator) + }; + onto.admit(entry("en-US", "enchoice marker", &["enexample marker"]), &inv).unwrap(); + onto.admit(entry("ja-JP", "jachoice marker", &["jaexample marker"]), &inv).unwrap(); + drop(onto); + drop(inv); + + std::fs::write(dir.join("speaker-state.cc"), [0x90]).unwrap(); + let panel: Vec = panel.iter().map(|s| s.to_string()).collect(); + RunStores::create( + &dir.join("run"), + "t", + RunPaths { + corpus: &dir.join("c.cc"), + inventory: &dir.join("i.cc"), + entities: &dir.join("entities.cc"), + ontology: &dir.join("ontology.cc"), + speaker_state: &dir.join("speaker-state.cc"), + }, + "fake-model", + "bag", + LowererReach::ToolLessRelay, + ModelFamily::Unrecorded, + &panel, + ) + .unwrap() +} + +const DRAFT: &str = + r#"{"entries":[{"layer":"Discourse","when":[],"choice":"a pattern","examples":[]}]}"#; + +#[test] +fn mint_ontology_prompt_shows_only_train_items_of_the_language() { + let dir = tempfile::tempdir().unwrap(); + let run = fixture(dir.path(), &["en-US", "ja-JP"]); + let mut m = Record::new(DRAFT); + run.mint_ontology(&mut m, "en-US").unwrap(); + let (text, keys) = &m.prompts[0]; + assert!(text.contains("language: en-US")); + assert_eq!(keys, &["item:en:1", "item:en:2"]); + for shown in ["entrain mark one", "entrain mark two"] { + assert!(text.contains(shown), "{shown}"); + } + for hidden in [ + "envalid", "engone", "entest", "jatrain", "javalid", "jatest", "item:en:3", "item:en:5", + "item:ja", + ] { + assert!(!text.contains(hidden), "the en-US mint showed {hidden}"); + } + let mut m = Record::new(DRAFT); + run.mint_ontology(&mut m, "ja-JP").unwrap(); + let (text, keys) = &m.prompts[0]; + assert_eq!(keys, &["item:ja:1"]); + assert!(text.contains("jatrain mark one") && !text.contains("entrain")); +} + +#[test] +fn mint_ontology_refuses_a_language_outside_the_panel() { + let dir = tempfile::tempdir().unwrap(); + let run = fixture(dir.path(), &["en-US"]); + let mut m = Record::new(DRAFT); + // ja-JP has Train items in the corpus but is not in the panel. + for (language, code) in [("ja-JP", "language-not-in-panel"), ("fr-FR", "language-not-in-panel")] { + assert_eq!( + run.mint_ontology(&mut m, language).unwrap(), + OntologyMintOutcome::Refused { code } + ); + } + assert!(m.prompts.is_empty(), "a refused mint asked the model"); +} + +#[test] +fn mint_ontology_prompt_lists_only_condition_readable_features() { + let dir = tempfile::tempdir().unwrap(); + let run = fixture(dir.path(), &["en-US"]); + let mut m = Record::new(DRAFT); + run.mint_ontology(&mut m, "en-US").unwrap(); + let text = &m.prompts[0].0; + let listed = |id: &str| text.contains(&format!("\n{id}: ")); + for id in [STANCE_G, DISC_FLAG, SCENE_G] { + assert!(listed(id), "{id} is readable by a condition"); + } + for id in [REF_ONLY, PRED_ONLY, STANCE_RETIRED] { + assert!(!listed(id), "{id} is not"); + } + // Nothing that is not a feature: no concept or role line. + assert!(!text.contains("\nconcept:") && !text.contains("\nrole:")); + assert!(text.contains("features rev:3")); +} + +#[test] +fn mint_ontology_prompt_lists_only_the_languages_existing_entries() { + let dir = tempfile::tempdir().unwrap(); + let run = fixture(dir.path(), &["en-US", "ja-JP"]); + let mut m = Record::new(DRAFT); + run.mint_ontology(&mut m, "en-US").unwrap(); + let text = &m.prompts[0].0; + assert!(text.contains("onto:en-US:1 enchoice marker")); + for hidden in ["jachoice", "onto:ja-JP", "enexample", "jaexample"] { + assert!(!text.contains(hidden), "{hidden}"); + } +} + +fn digests(dir: &Path) -> Vec<(String, Vec)> { + let mut out = vec![]; + let mut stack = vec![dir.to_path_buf()]; + while let Some(d) = stack.pop() { + for e in std::fs::read_dir(&d).unwrap() { + let p = e.unwrap().path(); + if p.is_dir() { + stack.push(p); + } else if !p.starts_with(dir.join("run").join("ontology-mint")) { + out.push((p.display().to_string(), std::fs::read(&p).unwrap())); + } + } + } + out.sort(); + out +} + +#[test] +fn mint_ontology_writes_nothing_but_its_prompt_and_answer_files() { + let dir = tempfile::tempdir().unwrap(); + let run = fixture(dir.path(), &["en-US", "ja-JP"]); + let before = digests(dir.path()); + let mut files = AnswerFiles::new(run.ontology_mint_dir(), "m".into()); + let OntologyMintOutcome::Unanswered { prompt } = + run.mint_ontology(&mut files, "en-US").unwrap() + else { + panic!("unanswered"); + }; + std::fs::write(run.ontology_mint_dir().join(format!("{prompt}.answer")), DRAFT).unwrap(); + assert!(matches!( + run.mint_ontology(&mut files, "en-US").unwrap(), + OntologyMintOutcome::Drafted { entries: 1, .. } + )); + assert_eq!(digests(dir.path()), before, "the mint wrote outside ontology-mint"); + let mut names: Vec = std::fs::read_dir(run.ontology_mint_dir()) + .unwrap() + .map(|e| e.unwrap().file_name().into_string().unwrap()) + .collect(); + names.sort(); + assert_eq!(names, [format!("{prompt}.answer"), format!("{prompt}.prompt")]); + drop(run); + RunStores::open(&dir.path().join("run")).expect("no Drift after a mint"); +} + +#[test] +fn mint_ontology_unanswered_then_drafted_then_refused() { + let dir = tempfile::tempdir().unwrap(); + let run = fixture(dir.path(), &["en-US"]); + let mut files = AnswerFiles::new(run.ontology_mint_dir(), "m".into()); + let OntologyMintOutcome::Unanswered { prompt } = + run.mint_ontology(&mut files, "en-US").unwrap() + else { + panic!("unanswered"); + }; + let mint = run.ontology_mint_dir(); + assert!(mint.join(format!("{prompt}.prompt")).exists()); + let answer = mint.join(format!("{prompt}.answer")); + std::fs::write(&answer, DRAFT).unwrap(); + assert_eq!( + run.mint_ontology(&mut files, "en-US").unwrap(), + OntologyMintOutcome::Drafted { prompt: prompt.clone(), entries: 1 } + ); + let two = r#"{"entries":[{"layer":"Grammar","choice":"a"},{"layer":"Lexicon","choice":"b"}]}"#; + std::fs::write(&answer, two).unwrap(); + assert!(matches!( + run.mint_ontology(&mut files, "en-US").unwrap(), + OntologyMintOutcome::Drafted { entries: 2, .. } + )); + let unknown = r#"{"entries":[{"layer":"Grammar","choice":"a","key":"x"}]}"#; + std::fs::write(&answer, unknown).unwrap(); + assert_eq!( + run.mint_ontology(&mut files, "en-US").unwrap(), + OntologyMintOutcome::Refused { code: "unknown-field" } + ); + std::fs::write(&answer, "not json").unwrap(); + assert_eq!( + run.mint_ontology(&mut files, "en-US").unwrap(), + OntologyMintOutcome::Refused { code: "syntax" } + ); +} + +#[test] +fn a_mint_answer_admits_into_a_copy_and_a_new_run_pins_the_copy() { + let dir = tempfile::tempdir().unwrap(); + let run = fixture(dir.path(), &["en-US"]); + let pinned = std::fs::read(dir.path().join("ontology.cc")).unwrap(); + let pin = run.record().ontology_digest.clone(); + let draft = format!( + r#"{{"entries":[{{"layer":"Discourse","when":[{{"slot":"Stance","feature":"{STANCE_G}","test":{{"AtLeast":500}}}}],"choice":"a grown choice","examples":[]}}]}}"# + ); + let mut files = AnswerFiles::new(run.ontology_mint_dir(), "m".into()); + let OntologyMintOutcome::Unanswered { prompt } = + run.mint_ontology(&mut files, "en-US").unwrap() + else { + panic!("unanswered"); + }; + let answer = run.ontology_mint_dir().join(format!("{prompt}.answer")); + std::fs::write(&answer, &draft).unwrap(); + + let copy = dir.path().join("grown.cc"); + std::fs::copy(dir.path().join("ontology.cc"), ©).unwrap(); + let inv = InventoryStore::open(&dir.path().join("i.cc")).unwrap(); + let mut grown = OntologyStore::open(©).unwrap(); + let annotator = Annotator::Model { family: ModelFamily::Anthropic, generator: "minter".into() }; + let first_n = grown.ontology().unwrap().entries().iter().filter(|e| e.language == "en-US").count() as u32 + 1; + let entries = weksa::encode::OntologyDraft::parse(&std::fs::read_to_string(&answer).unwrap()) + .unwrap() + .into_entries("en-US", 3, first_n, &annotator); + grown.admit(entries, &inv).unwrap(); + drop(grown); + + assert_eq!(std::fs::read(dir.path().join("ontology.cc")).unwrap(), pinned); + let again = RunStores::open(&dir.path().join("run")).unwrap(); + assert_eq!(again.record().ontology_digest, pin); + + let second = RunStores::create( + &dir.path().join("run-grown"), + "t", + RunPaths { + corpus: &dir.path().join("c.cc"), + inventory: &dir.path().join("i.cc"), + entities: &dir.path().join("entities.cc"), + ontology: ©, + speaker_state: &dir.path().join("speaker-state.cc"), + }, + "fake-model", + "bag", + LowererReach::ToolLessRelay, + ModelFamily::Unrecorded, + &["en-US".to_string()], + ) + .unwrap(); + assert_ne!(second.record().ontology_digest, pin); + + // A condition on a feature outside the inventory is the store's to refuse. + let outside = draft.replace(STANCE_G, "feature:99"); + let entries = weksa::encode::OntologyDraft::parse(&outside) + .unwrap() + .into_entries("en-US", 3, 9, &annotator); + let mut grown = OntologyStore::open(©).unwrap(); + assert!(grown.admit(entries, &inv).is_err()); +} diff --git a/docs/targets/interlingua-lowering-map.md b/docs/targets/interlingua-lowering-map.md index a279f0e..380d55c 100644 --- a/docs/targets/interlingua-lowering-map.md +++ b/docs/targets/interlingua-lowering-map.md @@ -34,7 +34,7 @@ means no store holds it and nothing writes it. | Inventory entry | Key `:`, `n` canonical decimal >= 1 (families: concept, frame, role, relation, speech_act, feature, referent_kind, extension); type `weksa.inventory_entry`, with a bounded gloss, value kind (option labels bounded), the slots a feature may sit in (`Discourse`, `Referent`, `Predication`, `Relation`; `Stance` from cut `speaker-state`, `Speaker` and `Scene` from cut `speaker-scene`), `introduced_rev` and optional `retired_rev`. Speaker axes, scene relations and affects are features of those slots, so the loop grows them like any closed-class family and convergence covers them | Added or retired by an inventory revision; never edited in place (a changed meaning is a retire plus an add); a retired id still resolves for packets of earlier revisions | The loop's accepted rounds, whose minting call the context builder assembles from Train items only; `weksa inventory admit` for one model-drafted `EditDraft` outside a run (cap 256, reviewed whole in its cut; same numbering and admission check as the loop); Self on merge to main. `data/original` revs 5 (233 concepts and frames) and 6 (five concepts closing named gaps) were drafted by claude-sonnet-5-5 (Weksa Hands, model-drafted original-bed lexicon from Train and Validation passages); Validation-informed: numbers on this bed measure lowering, never generalization or convergence. Residue after rev 6, not amended (each fresh coverage reader names new gaps; the loop's growth path owns them): simultaneity (ながら), distal deixis (あの), 'first' (まず), counterfactual mood, 'at least', emphatic question; heaven versus sky for the visible 天 stays weak. Admission checks form, not text | | Inventory revision | Key `rev:`, type `weksa.inventory_revision`, with parent, change list and `frozen` | Appended per accepted round; exactly one revision is ever marked frozen, by the convergence test | The loop's accept rule appends; the convergence test freezes; Self records the freeze as a ruling | | Target profile | Locale or language-project id (`en-US`, `ja-JP`, a conlang's slug). Until entries grow in rounds there is no profile revision document: a run names the profile it lowered with by the ontology store's path and digest in its `RunRecord` (cut `language-ontology`); `profile::` revision documents arrive with follow-up `language-ontology-growth` | The ontology store is revised by commit; a run pins it and refuses drift; it likewise pins the speaker-state store (`RunRecord` keys 17 and 18, `Drift(SpeakerState)`, cut `language-ontology-scene`) | Profile authors and accepted rounds; never the lowerer's defaults (`persona-drives-register`) | -| Language ontology entry (cut `language-ontology`) | Key `onto::`, `n` from 1 per language; type `weksa.ontology_entry` in `data/ontology/ontology.cc`: the language, the revision of the inventory it was admitted through (provenance: beds number revisions independently and a run reads each condition's feature at its own head), a layer (lexicon, grammar, discourse, phonology, orthography), at most four conditions (a feature id of slot `Stance`, `Discourse` or `Scene` with `AtLeast`/`AtMost`/`AtMostOrUnset` a grade or `Is` an option or flag; a `Scene` condition reads the relation of the item's speaker to its addressee that `with_scene` selected; slot `Speaker` and community ids wait on follow-up `language-ontology-communities`), a choice of 1 to 200 bytes, at most three examples of 1 to 120 bytes, and an `Annotator`. Whether an entry's text keeps politeness on the scene is a model reader's judgment, owed per change (a mint owes it under `language-ontology-growth`), not a test | Admitted in all-or-nothing batches through `OntologyStore::admit`, immutable, never edited; retire arrives with `language-ontology-growth`. The run pins the store like the entity store (path and digest, `Drift(Ontology)`), never copies it, because no loop step writes it yet. Cut `language-ontology-seed` converts by drafting, not by parse: a fresh model drafts each language's seed from that language's YAML and the inventory's feature lines with no corpus text, then deletes `data/target-language-ontology/` and `.weksa/cultural-ontology/` in the same cut | Seed: a labelled model (`Annotator::Model`), no operator gate, never Test evidence (`ja-ontology-owner-answer`); attestation (operator, native reader) appends later. Accepted rounds later, through a mint call from Train items only. Selection is `ontology::select(ontology, language, view)`, called only inside `Prompt::lower`, so no caller picks entries; the prompt prints each selected entry's id, layer, choice and examples. Its text is minted text for the leak diagnostic, which today has no runtime caller (follow-up `leak-diagnostic-in-round`). The store was rebuilt without ja-JP `:14` and `:15` (above-status Scene entries; a paired measure found them net-negative on register, follow-up `ja-scene-entries-lower-register-agreement`), so ja-JP ends at `:13`: an above-status out-group addressee, and an above-status in-group addressee below intimacy 700, select no ja-JP Scene entry (`:12` still selects in-group at intimacy 700 or more regardless of status) until a native reader attests a replacement (`ja-native-reader-scenes`). ja-JP `:5`, `:7` and `:8` were revised by certainty and restraint `AtMostOrUnset` conditions (holds when the feature is unrated or at most the grade; `AtMost` still fails on an unrated feature) in a store rebuild (the store has no retire, so a conditions change is a rebuild), which makes ja-JP's hedging, certainty, affection, restraint and sadness entries disjoint on `:5`/`:6`, `:4`/`:7`, `:6`/`:7`, `:6`/`:8`, and ja-JP `:3` (anger) carries `AtMostOrUnset` hedge and affection bounds, as en-US `:3`, which makes `:3`/`:5` and `:3`/`:7` disjoint; en-US `:3` carries `AtMostOrUnset` hedge and affection bounds, `:5` an `AtMostOrUnset` certainty bound (the clause it held in prose) and `:8` one too (as ja-JP `:7`), which makes `:3`/`:5`, `:3`/`:8`, `:5`/`:6` and `:6`/`:8` disjoint, while `:6`/`:10` stay co-selectable and are kept apart by scoping in `:6`'s text; ja-JP `:9` was reworded in a rebuild to state its question ending as available, so `:6`/`:9`, `:5`/`:9` and `:3`/`:9` stay co-selectable and are reconciled by wording, not by condition | +| Language ontology entry (cut `language-ontology`) | Key `onto::`, `n` from 1 per language; type `weksa.ontology_entry` in `data/ontology/ontology.cc`: the language, the revision of the inventory it was admitted through (provenance: beds number revisions independently and a run reads each condition's feature at its own head), a layer (lexicon, grammar, discourse, phonology, orthography), at most four conditions (a feature id of slot `Stance`, `Discourse` or `Scene` with `AtLeast`/`AtMost`/`AtMostOrUnset` a grade or `Is` an option or flag; a `Scene` condition reads the relation of the item's speaker to its addressee that `with_scene` selected; slot `Speaker` and community ids wait on follow-up `language-ontology-communities`), a choice of 1 to 200 bytes, at most three examples of 1 to 120 bytes, and an `Annotator`. Whether an entry's text keeps politeness on the scene is a model reader's judgment, owed per change (a mint owes it under `language-ontology-growth`), not a test | Admitted in all-or-nothing batches through `OntologyStore::admit`, immutable, never edited; retire arrives with `language-ontology-growth`. The run pins the store like the entity store (path and digest, `Drift(Ontology)`) and never writes it; slice 1 of growth is outside any run: `weksa loop mint-ontology` drafts entries from the run's Train items of one language into `/ontology-mint/.answer`, `weksa ontology admit --ontology ` admits them into a file copy, and a new run pins the copy (a run-owned copy waits on follow-up `language-ontology-growth`). Cut `language-ontology-seed` converts by drafting, not by parse: a fresh model drafts each language's seed from that language's YAML and the inventory's feature lines with no corpus text, then deletes `data/target-language-ontology/` and `.weksa/cultural-ontology/` in the same cut | Seed: a labelled model (`Annotator::Model`), no operator gate, never Test evidence (`ja-ontology-owner-answer`); attestation (operator, native reader) appends later. Accepted rounds later, through a mint call from Train items only. Selection is `ontology::select(ontology, language, view)`, called only inside `Prompt::lower`, so no caller picks entries; the prompt prints each selected entry's id, layer, choice and examples. Its text is minted text for the leak diagnostic, which today has no runtime caller (follow-up `leak-diagnostic-in-round`). The store was rebuilt without ja-JP `:14` and `:15` (above-status Scene entries; a paired measure found them net-negative on register, follow-up `ja-scene-entries-lower-register-agreement`), so ja-JP ends at `:13`: an above-status out-group addressee, and an above-status in-group addressee below intimacy 700, select no ja-JP Scene entry (`:12` still selects in-group at intimacy 700 or more regardless of status) until a native reader attests a replacement (`ja-native-reader-scenes`). ja-JP `:5`, `:7` and `:8` were revised by certainty and restraint `AtMostOrUnset` conditions (holds when the feature is unrated or at most the grade; `AtMost` still fails on an unrated feature) in a store rebuild (the store has no retire, so a conditions change is a rebuild), which makes ja-JP's hedging, certainty, affection, restraint and sadness entries disjoint on `:5`/`:6`, `:4`/`:7`, `:6`/`:7`, `:6`/`:8`, and ja-JP `:3` (anger) carries `AtMostOrUnset` hedge and affection bounds, as en-US `:3`, which makes `:3`/`:5` and `:3`/`:7` disjoint; en-US `:3` carries `AtMostOrUnset` hedge and affection bounds, `:5` an `AtMostOrUnset` certainty bound (the clause it held in prose) and `:8` one too (as ja-JP `:7`), which makes `:3`/`:5`, `:3`/`:8`, `:5`/`:6` and `:6`/`:8` disjoint, while `:6`/`:10` stay co-selectable and are kept apart by scoping in `:6`'s text; ja-JP `:9` was reworded in a rebuild to state its question ending as available, so `:6`/`:9`, `:5`/`:9` and `:3`/`:9` stay co-selectable and are reconciled by wording, not by condition | | Community (cut `language-ontology`, follow-up `language-ontology-communities`) | Key `community:`; type `weksa.community`, converted from `data/cultural-ontology/cultures/` and `referents/` (YAML deleted in the same cut) | Revised by commit; a speaker names the communities it belongs to by id | The cultural ontology's author (owner-attested evidence only; Discord-only content stays deleted, `discord-only-content-deleted`) | | Speaker (cut `speaker-scene`) | Key `speaker:@`; type `weksa.speaker`: stable axes as feature values of slot `Speaker` (origin, socioeconomic standing, age cohort, education and whatever the loop adds), at an inventory revision, and an `Annotator` | A new revision appends, never edits; a corpus item and every prior turn name a speaker slug, and a round records the speaker revisions it read | The annotator it names: `PersonaSnapshot` (a projection of a `gamecult.persona_state.v0` document, naming its source document and `updatedAt`), `Operator`, `WorkMetadata` (a public-domain work's own cast list and narration), or `Model { family, generator }` (the 2b `ModelFamily`) | | Scene (cut `speaker-scene`) | Key `scene:@`, the item's split group; type `weksa.scene`: participants (speaker slugs) and, per ordered pair, relation features of slot `Scene` (relative status, intimacy, in-group, audience and whatever the loop adds), at an inventory revision (provenance; a run reads the features at its own head), and an `Annotator` | As Speaker. Keyed by the group, so a scene never straddles the split. `data/original/speaker-state.cc` holds Model-annotated keeper scenes, one per Train or Validation group of both languages (`weksa scene put|dump`); a Test group has none and reads `NoScene` | As Speaker; a model-annotated scene is never Test evidence | From 887e79ef44da0b00eab198f74493c47910348398 Mon Sep 17 00:00:00 2001 From: Weksa Date: Thu, 12 Nov 2026 23:54:01 +0000 Subject: [PATCH 10/41] mint-prompt-door: the mint prompt teaches the shape the admit door admits (#64) --- crates/weksa/src/context.rs | 67 +++++++++++++++++++----- crates/weksa/tests/ontology_mint.rs | 40 ++++++++++++++ docs/targets/interlingua-lowering-map.md | 2 +- 3 files changed, 96 insertions(+), 13 deletions(-) diff --git a/crates/weksa/src/context.rs b/crates/weksa/src/context.rs index 98dfe7f..de2ff8f 100644 --- a/crates/weksa/src/context.rs +++ b/crates/weksa/src/context.rs @@ -35,9 +35,10 @@ use serde::Serialize; use crate::corpus::{CorpusItem, CorpusItemId}; use crate::inventory::{Inventory, InventoryEntry, OptionLabel, Slot, ValueKind}; use crate::lower::{EntityForms, LowerError, entity}; -use crate::ontology::{Ontology, select}; +use crate::encode::{EntryOntologyDraft, OntologyDraft}; +use crate::ontology::{Condition, Layer, Ontology, Test, select}; use crate::packet::{ - Context, Discourse, EntityId, Extension, Predication, Referent, Relation, Stance, + Context, Discourse, EntityId, Extension, FeatValue, Grade, Predication, Referent, Relation, Stance, }; use crate::run::LADDER_STEP; use crate::split::{Checkpoint, Split, SplitScheme, fnv1a64, hex16}; @@ -92,7 +93,7 @@ Answer with one JSON object and nothing else: {\"text\": \"...\"}, the continuat pub const MINT_ONTOLOGY_INSTRUCTIONS: &str = "\ Below are lines written in one language (the language line), the features an ontology condition may test, and the entries that language's ontology already has. Draft new entries: choices this language's culture makes, for a speaker in a stance and scene, about word, grammar, discourse, sound or script, that the lines show. Answer with one JSON object and nothing else: {\"entries\": [{\"layer\": \"...\", \"when\": [...], \"choice\": \"...\", \"examples\": [...]}]}. No code fence, no commentary. -Give 1 to 8 entries. layer is one of lexicon, grammar, discourse, phonology, orthography. when holds at most 4 conditions, each {\"slot\": \"Stance\" | \"Discourse\" | \"Scene\", \"feature\": \"\", \"test\": {\"AtLeast\": } | {\"AtMost\": } | {\"AtMostOrUnset\": } | {\"Is\": }}, over the listed feature ids only; when may be empty when a choice holds for every line of the language. choice states a pattern the lines show, in at most 200 bytes, without quoting a line. examples are original short phrases of the language, never copied from the lines below, at most 3."; +Give 1 to 8 entries. layer is exactly one of Lexicon, Grammar, Discourse, Phonology, Orthography. when holds at most 4 conditions, each {\"slot\": \"Stance\" | \"Discourse\" | \"Scene\", \"feature\": \"\", \"test\": ...}, where is the id printed before the colon of a listed feature (\"feature:10\", never its name) and its slot is one that feature lists. test is {\"AtLeast\": }, {\"AtMost\": } or {\"AtMostOrUnset\": } on a grade feature, or {\"Is\": {\"Option\": \"