interplane.Get Omega
Read in your language

aien-sovereign-core-mv

AienOS host runtime: inference scheduling, paged KV state, the aien CLI and Spark verification tooling. Its inference engine is in alpha testing (DGX Spark GB10); Omega is the implementation destination.

Brought by drakestapleton

branch main Branches Tags History

aien-sovereign-core-mv / crates / aien-runtime / tests / requirements_topics_test.rs

190 lines · 8330 bytes Raw Blame History
1// SPDX-License-Identifier: Apache-2.0
2// Copyright 2026 Drake Stapleton (AIEN / aien-dev)
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15
16//! sc#332: a counted topic list ("Cover three topics: drying, labelling and
17//! storage.") was refused as uncertain before any model call, and the topic
18//! check refused word forms the goal itself accepts ("dried", "Label",
19//! "stored", "withdrew"). The list is now read when the count matches it, the
20//! word-form rule agrees on y/i, doubled consonants and -age, and a form the
21//! goal ties to one topic ("withdrew ... for the third") is accepted for it.
22use aien_runtime::requirements::{analyze, refusal_reason, Requirement};
23
24use Requirement::*;
25
26/// tasks-oq3-v4 W3, verbatim.
27const W3: &str = "Please put together docs/SEED-SAVING.md, a short explainer on saving vegetable seeds from your own garden. Make it at least eighteen lines long. Cover three topics: drying, labelling and storage. A topic counts as covered when its word, or another form of it such as dried, labelled or stored, appears in the file.";
28/// v5 D3 (sc#339), verbatim.
29const D3: &str = "Write an explainer for beginners called docs/savings-basics.md about how a savings account works. It must cover four topics: interest, deposit, withdraw and balance, and the file needs at least 18 lines. A topic counts as covered when its word or another form of that word appears, for example interests or interested for the first one, deposits or deposited for the second, withdrew or withdrawing for the third, and balances or balancing for the last.";
30
31fn reqs(goal: &str) -> Vec<Requirement> {
32 let ex = analyze(goal);
33 assert!(
34 ex.uncertain.is_empty(),
35 "{goal:?} should be read, uncertain: {:?}",
36 ex.uncertain
37 );
38 ex.requirements
39}
40
41fn topics(r: &[Requirement]) -> Vec<String> {
42 r.iter()
43 .find_map(|x| match x {
44 RequiredTopics(t) => Some(t.clone()),
45 _ => None,
46 })
47 .expect("a topic requirement")
48}
49
50#[test]
51fn the_counted_topic_lists_are_read() {
52 let r = reqs(W3);
53 assert!(r.contains(&MinLines(18)), "{r:?}");
54 assert_eq!(topics(&r), ["drying", "labelling", "storage"]);
55 let r = reqs(D3);
56 assert!(r.contains(&MinLines(18)), "{r:?}");
57 assert_eq!(
58 topics(&r),
59 ["interest", "deposit", "withdraw (or withdrew)", "balance"]
60 );
61}
62
63#[test]
64fn the_forms_the_goals_accept_cover_their_topics() {
65 // evidence-v5/topic-forms-probe.txt: each sentence uses a form the goal accepts.
66 for (topic, text) in [
67 (
68 "drying",
69 "Leave the pods until they have dried on the plant.",
70 ),
71 ("drying", "Dry the seeds on a plate."),
72 ("labelling", "Label each envelope with the variety."),
73 ("labelling", "Keep every packet labelled."),
74 ("storage", "Store the jars somewhere cool."),
75 ("storage", "The seeds are stored in a tin."),
76 ("withdraw (or withdrew)", "She withdrew fifty pounds."),
77 ("withdraw (or withdrew)", "Withdrawing money is free."),
78 // sc#353 G2: noun and participle forms by the -n, -al, -als rule
79 ("withdraw (or withdrew)", "The money was withdrawn."),
80 ("withdraw (or withdrew)", "One withdrawal a day."),
81 ("withdraw (or withdrew)", "Withdrawals are free."),
82 ("withdraw", "The money was withdrawn."),
83 ("withdraw", "Withdrawals are free."),
84 ("withdrawing", "One withdrawal a day."),
85 ("arrive", "Note the arrival time."),
86 ("approve", "Ask for approvals."),
87 ("grow", "The plants have grown."),
88 ("take", "It was taken."),
89 // the cost of the rule, pinned so a tightening is deliberate (sc#354 review)
90 ("sign", "A signal."),
91 ("line", "A linen cloth."),
92 ("interest", "The bank pays interest monthly."),
93 ("balance", "Check the balances each week."),
94 // the same rule elsewhere
95 ("manage", "Good management helps."),
96 ("running", "Run every day."),
97 ("addressing", "Write the address."),
98 ("stories", "Tell a story."),
99 // sc#347 review: plurals of -age words still agree
100 ("messages", "Read the message."),
101 ("message", "Read the messages."),
102 ("storages", "Check the storage."),
103 ("languages", "One language."),
104 ("average", "Two averages."),
105 ("fill", "The cup is filled."),
106 ("dress", "She dressed well."),
107 ("classes", "One class."),
108 ] {
109 let r = [RequiredTopics(vec![topic.to_string()])];
110 assert!(refusal_reason(&r, text).is_none(), "{topic}: {text}");
111 }
112}
113
114#[test]
115fn other_words_still_do_not_cover_a_topic() {
116 for (topic, text) in [
117 ("drying", "Wet the seeds."),
118 ("storage", "Stop here."),
119 ("labelling", "Lab work is fun."),
120 ("manage", "One man went."),
121 // sc#347 review: unrelated words do not collide
122 ("file", "Fill the cup."),
123 ("mile", "The mill turns."),
124 ("tale", "A tall tree."),
125 ("ski", "The sky is blue."),
126 ("pack", "A package came."),
127 ("postage", "Post it today."),
128 ("shortage", "A short note."),
129 ("message", "What a mess."),
130 ("storage", "A story."),
131 // an irregular form counts only when the goal names it
132 ("withdraw", "She withdrew fifty pounds."),
133 // naming `withdrew` opens no loose match: a word sharing its letters stays out
134 ("withdraw (or withdrew)", "She drew fifty pounds."),
135 // the -n / -al / -als rule is explicit, not a prefix: other endings, the bare
136 // shorter word and a different stem stay refused (sc#353 G2)
137 ("withdraw", "Draw fifty pounds."),
138 ("withdraw", "Open the drawer."),
139 ("withdraw (or withdrew)", "Open the drawer."),
140 ("withdraw", "A withdrawer came."),
141 ("withdraw", "The funds are withdrawable."),
142 ("withdraw", "She withheld fifty pounds."),
143 ("drawer", "She drew a line."),
144 ("arm", "An armal plate."),
145 ("bee", "It has been."),
146 // 4 letters before -al / -als, and -n only after w or e (sc#354 review)
147 ("met", "A metal box."),
148 ("met", "Two metals."),
149 ("melo", "A melon."),
150 ("see", "It was seen."),
151 ] {
152 let r = [RequiredTopics(vec![topic.to_string()])];
153 assert!(refusal_reason(&r, text).is_some(), "{topic}: {text}");
154 }
155}
156
157#[test]
158fn counted_topic_near_misses_stay_uncertain() {
159 for goal in [
160 // the count differs from the list
161 "Cover three topics: drying and storage.",
162 "It must cover two topics: interest, deposit and balance.",
163 // negated
164 "Do not cover three topics: drying, labelling and storage.",
165 // a list item that is not a topic
166 "Cover two topics: drying and at least 3 lines.",
167 // sc#347 review: the last item runs on
168 "Cover three topics: drying, labelling and storage and disposal.",
169 "Cover three topics: drying, labelling and storage and write at least 20 lines.",
170 ] {
171 let ex = analyze(goal);
172 assert!(
173 !ex.uncertain.is_empty(),
174 "{goal:?} should stay uncertain, got {:?}",
175 ex.requirements
176 );
177 }
178}
179
180#[test]
181fn forms_are_read_only_when_tied_to_their_topic() {
182 // A sentence that is not about word forms, or a form that is not one of
183 // the topic's, adds nothing.
184 for goal in [
185 "Cover three topics: drying, labelling and storage. In the final format, for example sold or bought for the first one.",
186 "Cover three topics: drying, labelling and storage. Any form is fine, for example sold or bought for the first one.",
187 ] {
188 assert_eq!(topics(&reqs(goal)), ["drying", "labelling", "storage"], "{goal}");
189 }
190}