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

166 lines · 7534 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#334: an item count that points back at a line prefix the same sentence
17//! defines ("Write every item as a line starting with "- [ ]" and include at
18//! least twelve of them.") was refused as uncertain before any model call. It
19//! is now read as `MinPrefixedLines`: at least N lines that start with exactly
20//! that quoted prefix. Without such a referent the count stays UNCERTAIN.
21use aien_runtime::requirements::{analyze, refusal_reason, Requirement};
22
23use Requirement::*;
24
25/// tasks-oq3-v4 W5, verbatim.
26const V4_W5: &str = "Make a new file called docs/CAMPING-LIST.md, a packing checklist for a weekend camping trip. It should run to a minimum of 16 lines and no more than 45 lines. Write every item as a line starting with \"- [ ]\" and include at least twelve of them. Use sections titled \"Shelter\", \"Food and water\" and \"Safety\", and use the exact words headlamp and first-aid somewhere in the list.";
27
28/// tasks-oq3-v5 D5, the sentence under test (the rest of D5 is sc#331 and sc#333).
29const V5_D5: &str = "Make me a carry-on packing checklist in docs/packing-carry-on.md. Every item must be its own line starting with \"- [ ]\" and I want at least 12 of those items.";
30
31fn prefixed(n: usize) -> Requirement {
32 MinPrefixedLines {
33 prefix: "- [ ]".into(),
34 n,
35 }
36}
37
38#[test]
39fn the_v4_w5_goal_reads_the_item_count() {
40 let ex = analyze(V4_W5);
41 assert!(ex.uncertain.is_empty(), "uncertain: {:?}", ex.uncertain);
42 assert!(ex.requirements.contains(&prefixed(12)), "{ex:?}");
43 assert!(ex.requirements.contains(&MinLines(16)));
44 assert!(ex.requirements.contains(&MaxLines(45)));
45}
46
47#[test]
48fn the_v5_d5_sentence_reads_the_item_count() {
49 let ex = analyze(V5_D5);
50 assert!(ex.uncertain.is_empty(), "uncertain: {:?}", ex.uncertain);
51 assert_eq!(ex.requirements, [prefixed(12)]);
52}
53
54#[test]
55fn other_referents_and_wordings_read_the_same_way() {
56 for (goal, n) in [
57 (
58 "Put each task on a line beginning with \"TODO:\" and write at least 5 of them.",
59 5,
60 ),
61 (
62 "Each entry is a line that starts with \"* \"; add no fewer than three of these.",
63 3,
64 ),
65 (
66 "Every step is its own line starting with \"- \" and I want more than 4 of them.",
67 5,
68 ),
69 // curly quotes (sc#340 review: a curly closing quote panicked the reader)
70 (
71 "Write every item as a line starting with \u{201C}- [ ]\u{201D} and include at least 4 of them.",
72 4,
73 ),
74 (
75 "Write lines starting with \u{201C}- [ ]\u{201D} and include at least 6 of those lines.",
76 6,
77 ),
78 ] {
79 let ex = analyze(goal);
80 assert!(ex.uncertain.is_empty(), "{goal}: {:?}", ex.uncertain);
81 assert_eq!(ex.requirements.len(), 1, "{goal}: {ex:?}");
82 assert!(
83 matches!(&ex.requirements[0], MinPrefixedLines { n: m, .. } if *m == n),
84 "{goal}: {ex:?}"
85 );
86 }
87}
88
89#[test]
90fn a_trailing_description_after_the_count_is_not_a_count() {
91 // "each with a date" is not measurable; the prefix count is what is checked.
92 let ex = analyze(
93 "Write every item as a line starting with \"- [ ]\" and include at least 4 of them, each with a date.",
94 );
95 assert!(ex.uncertain.is_empty(), "{:?}", ex.uncertain);
96 assert_eq!(ex.requirements, [prefixed(4)]);
97}
98
99#[test]
100fn only_lines_with_the_exact_prefix_count() {
101 let r = prefixed(3);
102 let good = "## Shelter\n- [ ] tent\n- [ ] pegs\n - [ ] mallet\n";
103 assert!(refusal_reason(std::slice::from_ref(&r), good).is_none());
104 // Plain list lines, checked boxes and fenced lines are not "- [ ]" lines.
105 let bad =
106 "- tent\n- [x] pegs\n* [ ] stove\n```\n- [ ] in code\n```\n- [ ] mallet\n- [ ] rope\n";
107 let why = refusal_reason(std::slice::from_ref(&r), bad).expect("unmet");
108 assert!(
109 why.contains("at least 3 lines starting with \"- [ ]\", found 2"),
110 "{why}"
111 );
112}
113
114#[test]
115fn a_count_without_a_stated_referent_stays_uncertain() {
116 for goal in [
117 // no prefix in the sentence
118 "Write a packing list and include at least twelve of them.",
119 // the prefix is in an earlier sentence
120 "Every item starts with \"- [ ]\". Include at least twelve of them.",
121 // the prefix is not a line prefix
122 "Use the word \"tent\" and include at least twelve of them.",
123 // an upper bound is not read
124 "Write every item as a line starting with \"- [ ]\" and include at most twelve of them.",
125 // no bound cue
126 "Write every item as a line starting with \"- [ ]\" and include twelve of them.",
127 // a count that qualifies the referent further
128 "Write every item as a line starting with \"- [ ]\" and include at least twelve of them per section.",
129 // negated
130 "Write every item as a line starting with \"- [ ]\" but do not include at least twelve of them.",
131 // two prefixes: which one is meant is unclear
132 "Write each item as a line starting with \"- [ ]\" or \"* [ ]\" and include at least twelve of them.",
133 // sc#340 review cases: a curly quote with another clause before the count
134 "Each line starting with \u{201C}- [ ]\u{201D} counts; include at least 4 of them.",
135 // a negator before the referent
136 "Avoid lines starting with \"- [ ]\" and include at least five of them.",
137 "Do not write any line starting with \"TODO\" and include at least five of them.",
138 // a single line, not every item
139 "Start the file with a line starting with \"# Title\" and include at least 5 of those items.",
140 // a per-section intent
141 "Each section has lines starting with \"- [ ]\", and include at least 3 of them.",
142 // another condition on the lines
143 "Write lines starting with \"- \" and ending with \"!\" and include at least 4 of them.",
144 // the referent is too far from the count
145 "Write lines starting with \"- \" for the shopping, the cleaning, the garden and the car, and include at least 4 of them.",
146 // a count the bound cue does not lead
147 "Write lines starting with \"- [ ]\" and include 12 or more of them.",
148 // round 2: a line break ends the sentence
149 "Write lines starting with \"- [ ]\"\nInclude at least 12 of them.",
150 // round 2: only the listed joining words
151 "Write lines starting with \"- [ ]\" and make at least 12 of them.",
152 ] {
153 let ex = analyze(goal);
154 assert!(
155 !ex.uncertain.is_empty(),
156 "{goal:?} should stay uncertain, got {:?}",
157 ex.requirements
158 );
159 assert!(
160 !ex.requirements
161 .iter()
162 .any(|r| matches!(r, MinPrefixedLines { .. })),
163 "{goal:?}: {ex:?}"
164 );
165 }
166}