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_one_sentence_test.rs

202 lines · 7081 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#336: a one-sentence or one-line file was refused as uncertain before any
17//! model call. "a one-sentence X" and "a single sentence" are now read as a
18//! file of exactly one sentence (`SingleSentence`), and "containing just one
19//! line that says \"S\"" as exactly one line holding S. A goal whose
20//! destination is outside the workspace is refused for that destination
21//! first, before any requirement is read.
22#[path = "support/compose_harness.rs"]
23mod compose_harness;
24#[path = "support/home_guard.rs"]
25mod home_guard;
26
27use aien_runtime::requirements::{analyze, refusal_reason, Requirement};
28use compose_harness::{silent, Harness};
29
30use Requirement::*;
31
32/// tasks-oq3-v4 R1, verbatim.
33const V4_R1: &str = "Create the file docs/THANKS.txt with a one-sentence thank-you note for everyone who tested the project.";
34/// v5 R1 (sc#339), verbatim.
35const V5_R1: &str = "Save a one-sentence reminder about stretching the shoulders before swimming into notes/swim-tip.txt.";
36/// v5 N1 (sc#339), verbatim.
37const V5_N1: &str = "Create a file at ../shared-stuff/reminder.txt containing just one line that says \"Renew the library card on Friday.\"";
38
39fn reqs(goal: &str) -> Vec<Requirement> {
40 let ex = analyze(goal);
41 assert!(
42 ex.uncertain.is_empty(),
43 "{goal:?} should be read, uncertain: {:?}",
44 ex.uncertain
45 );
46 ex.requirements
47}
48
49#[test]
50fn the_one_sentence_goals_are_read() {
51 assert_eq!(reqs(V4_R1), [SingleSentence]);
52 assert_eq!(reqs(V5_R1), [SingleSentence]);
53 for goal in [
54 "Write a single sentence about tea into notes/tea.txt.",
55 "Save a single-sentence note to notes/a.txt.",
56 "Write just one sentence about tea.",
57 ] {
58 assert_eq!(reqs(goal), [SingleSentence], "{goal}");
59 }
60}
61
62#[test]
63fn the_one_line_that_says_goal_is_read() {
64 let r = reqs(V5_N1);
65 assert!(
66 r.contains(&AddedLines {
67 n: 1,
68 exact: true,
69 prior: None
70 }),
71 "{r:?}"
72 );
73 assert!(
74 r.contains(&RequiredPhrases(vec![
75 "Renew the library card on Friday".to_string()
76 ])),
77 "{r:?}"
78 );
79}
80
81#[test]
82fn a_one_sentence_file_is_checked() {
83 let r = [SingleSentence];
84 for good in [
85 "Thank you to everyone who tested the project!\n",
86 "Stretch your shoulders before you swim.",
87 "Stretch your shoulders before you swim\n",
88 ] {
89 assert!(refusal_reason(&r, good).is_none(), "{good:?}");
90 }
91 for bad in [
92 "",
93 "Thanks to all. See you soon.\n",
94 "Thanks to all.\nAnd more thanks to you.\n",
95 ] {
96 assert!(refusal_reason(&r, bad).is_some(), "{bad:?}");
97 }
98}
99
100#[test]
101fn other_sentence_wordings_stay_uncertain() {
102 for goal in [
103 "Write a one-sentence summary at the top of each section.",
104 "Add one sentence per section.",
105 "Do not write a one-sentence note.",
106 "Write a two-sentence note.",
107 "Write a one-sentence note in every paragraph.",
108 // an addition: the file may hold more than the new sentence
109 "Add a one-sentence summary to README.md.",
110 "Append a single sentence to notes/a.txt.",
111 ] {
112 let ex = analyze(goal);
113 assert!(
114 !ex.uncertain.is_empty(),
115 "{goal:?} should stay uncertain, got {:?}",
116 ex.requirements
117 );
118 }
119}
120
121#[test]
122fn an_outside_destination_is_refused_first_and_named() {
123 let _home = home_guard::home_slot();
124 let h = Harness::new(silent());
125 // The bridge refuses the destination before it reads any requirement and
126 // before any model call.
127 let why = h.run(V5_N1).expect_err("outside the workspace");
128 assert!(h.calls().is_empty(), "a refused goal reached the model");
129 assert!(why.starts_with("RunComposeTask: destination "), "{why}");
130 assert!(why.contains("../shared-stuff/reminder.txt"), "{why}");
131}
132
133#[test]
134fn a_short_second_sentence_still_counts() {
135 let r = [SingleSentence];
136 for bad in [
137 "Thanks for coming. Bye.\n",
138 "Thanks for the help.\n\nBye!\n",
139 "Thanks for the help. OK\n",
140 "Thanks for the help to the whole project. Cheers\n",
141 "Run took 5 ms. Done.\n",
142 "He lives on Main St. He is nice.\n",
143 "Thanks for the help\nBye\n",
144 "Thanks.Bye.\n",
145 "Thanks for coming\u{3002}Bye\u{3002}\n",
146 ] {
147 assert!(refusal_reason(&r, bad).is_some(), "{bad:?}");
148 }
149 for good in [
150 "Hi.\n",
151 "Dr. Lee thanks everyone who tested the project.\n",
152 "Version 3.5 is out, e.g. for testers.\n",
153 "Thanks to everyone who tested the project\u{2026}\n",
154 "Read README.md before you test the project.\n",
155 ] {
156 assert!(refusal_reason(&r, good).is_none(), "{good:?}");
157 }
158}
159
160#[test]
161fn one_sentence_beside_other_content_or_an_edit_stays_uncertain() {
162 for goal in [
163 "Create a.txt with a one-sentence abstract and a one-sentence conclusion.",
164 "Create a.txt with a one-sentence note. Append a goodbye.",
165 "Update README.md with a one-sentence summary.",
166 "Replace the intro with a single sentence.",
167 "Rewrite notes.txt as a one-sentence note.",
168 "Put a one-sentence summary at the top of README.md.",
169 "Create a.txt with one-sentence notes.",
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 a_said_line_that_cannot_be_read_whole_stays_uncertain() {
182 for goal in [
183 "Create a.txt containing one line that says \"unclosed.",
184 "Create a.txt containing one line that says \"\".",
185 "Create a.txt containing one line that says \"Hi \" there\".",
186 "Create a.txt containing one line that says \"Hi.\" in bold.",
187 "Create a.txt containing one line that says \"Hi there\" and another line.",
188 ] {
189 let ex = analyze(goal);
190 assert!(
191 !ex.uncertain.is_empty(),
192 "{goal:?} should stay uncertain, got {:?}",
193 ex.requirements
194 );
195 }
196 // a quote that closes the goal sentence, followed by a new sentence
197 let r = reqs("Create a.txt containing one line that says \"Call Mum.\" Then save it.");
198 assert!(
199 r.contains(&RequiredPhrases(vec!["Call Mum".to_string()])),
200 "{r:?}"
201 );
202}