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

GitHub aien-dev/aien-sovereign-core-mv#343 (code only)

closed derived 2267590b5a4e14c7 #343

Imported from GitHub aien-dev/aien-sovereign-core-mv#343 (code only)

GitHub's metadata for this pull request is unavailable: its state is DERIVED from the commits (merged: the head is reachable from this project's main; open: GitHub kept a merge ref; else closed).

Base 47f1014a1aa0cf54b732132c6958bc142e91c20b · Head 5926c07cf058c8736e148e5405ee042de199a95c

Fetch it

A git bundle of the pull request's head, 17410 bytes.

curl -fsSL https://interplane.io/drakestapleton/aien-sovereign-core-mv/patches/2267590b5a4e14c7.bundle -o 2267590b5a4e14c7.bundle
git fetch 2267590b5a4e14c7.bundle refs/pull/343/head

Raw bundle · Diff

Provenance

This proposal is imported from GitHub; it is not signed by its author. Its import statement and source record:

github-import 1
aien-dev/aien-sovereign-core-mv
343
5926c07cf058c8736e148e5405ee042de199a95c
{"kind":"github-import","owner":"aien-dev","repo":"aien-sovereign-core-mv","number":343,"url":"https://github.com/aien-dev/aien-sovereign-core-mv/pull/343","export_sha256":"967c79e26a893657b5cdaa45efd442be5dbd2ecfe68e25f9a8c1b5da4d60d452","imported_utc":"2026-11-18T16:36:52Z","metadata":"unavailable","state_derived":true}

Changes

diff --git a/.crumb b/.crumb
index 454a3b5f..66674ebb 100644
--- a/.crumb
+++ b/.crumb
@@ -77,14 +77,14 @@
         }
       ],
       "children_root": "sha256:285ca7eafbe46d808ebe5e4fb533e464bfdf0fedaf3eef486ac2e2c8826baf6f",
-      "compiled_at": "2026-10-08T17:59:47Z",
+      "compiled_at": "2026-10-08T18:19:04Z",
       "compiler": "crumb-compile/1",
-      "digest": "sha256:e3c54c6f21dc7bd6bb8e6b9e156fa37148bffd458b89c33cc7867e567cbde12c",
+      "digest": "sha256:e8119ca26a0edd4a6516befc79d82edf5ec931e496780c76b442959779cca769",
       "evidence_files": 187,
       "evidence_root": "sha256:27ee0353cb4d4aae2b7dbce2bfe0d9f4ef2a94cd7a4555b84684d59372503280",
-      "files": 1609,
-      "generated_at_commit": "b08d12c0ca28f0621d3aab46a711d0722eaf7caf",
-      "source_tree": "sha256:cdb227e8d38bebb8212ce4797d8fd508c845a1c30bbceec519bf7fdac3cd0044"
+      "files": 1610,
+      "generated_at_commit": "ba22d4198a1169241a200f867f9eab0bc8ac8336",
+      "source_tree": "sha256:5993f464e2a6b8acbfcf4c38cd8527ec115ec5dcb49ce865d5d8801799cebb3d"
     }
   },
   "history": [],
diff --git a/crates/aien-runtime/src/requirements_extract.rs b/crates/aien-runtime/src/requirements_extract.rs
index d5e7d2e0..a3fce2fe 100644
--- a/crates/aien-runtime/src/requirements_extract.rs
+++ b/crates/aien-runtime/src/requirements_extract.rs
@@ -14,9 +14,10 @@
 //! | `at most / no more than / not more than / a maximum of / maximum of / max / up to N <noun>`, `N or fewer|less <noun>` | `MaxX(N)` |
 //! | `more than N <noun>`, `fewer|less than N <noun>` | `MinX(N+1)`, `MaxX(N-1)` |
 //! | `N <noun> or more|fewer|less`, `N <noun> minimum|maximum`, `no longer|shorter than N <noun>` | `MinX(N)` or `MaxX(N)` |
-//! | `<noun>` = `lines`, `words`; `items`, `steps`, `sections`, `headings`, `questions`, `paragraphs` (Min only; singular too) | lines, words, list items, numbered steps, headings, questions, paragraphs (`MinParagraphs`: runs of prose lines, see `requirements::count_paragraphs`) |
+//! | `<noun>` = `lines` (also `non-empty|nonempty|non-blank lines`: lines are counted non-empty anyway), `words`; `items`, `steps`, `sections`, `headings`, `questions`, `paragraphs` (Min only; singular too) | lines, words, list items, numbered steps, headings, questions, paragraphs (`MinParagraphs`: runs of prose lines, see `requirements::count_paragraphs`) |
 //! | `N sentences in|per|for|within every|each section` (or `in every section, ... N sentences`) | `MinSentencesPerSection(N)` |
-//! | `sections|headings titled|named|called A, B and C`, `sections: A, B and C` | `RequiredHeadings` |
+//! | `sections|headings titled|named|called A, B and C`, `sections: A, B and C`; with quoted titles also `section(s) is|are titled "A"` and `[one] section(s) must|should|will|shall|can be titled "A"` | `RequiredHeadings` (a count before the noun must equal the number of titles; `organise it under three sections titled ...` is read the same). The is/are/be forms stay UNCERTAIN after `each every all any` or with `if unless optionally optional may might when whenever perhaps maybe` in the clause |
+//! | `between N and M lines|words` (N <= M) | `MinX(N)` and `MaxX(M)`, inclusive. Other nouns, `from N to M`, ranges like `2-3`, `... or so`, and a range on a part of the document (a countable noun or `gap space distance` right before `between`, or `each every per` within three words) stay UNCERTAIN |
 //! | `covers|covering A, B and C` (and `to|should|must|will|can cover ...`) | `RequiredTopics` |
 //! | `include|contain|use|mention the word(s)|term(s) X, Y` or `"X", "Y"` | `RequiredWords` |
 //! | `include|contain|use|mention the phrase "X"` / `the phrases "X", "Y"` | `RequiredPhrases` |
@@ -74,7 +75,7 @@
 //!   recognized and the span is UNCERTAIN.
 //! - a bound word with a number and a noun that is not supported (`at most 5
 //!   items`, `at most 3 paragraphs`, `exactly 20 lines`, `about 30 lines`,
-//!   `between 10 and 20 lines`, `35-line` with no verb before it) is UNCERTAIN.
+//!   `between 10 and 20 items`, `35-line` with no verb before it) is UNCERTAIN.
 //! - a title list whose parsed length differs from a declared count ("6
 //!   sections titled A, B, C") is UNCERTAIN; so is a list item that is not a
 //!   short noun phrase.
@@ -188,6 +189,53 @@ fn ends_clause(raw: &str) -> bool {
     raw.ends_with([',', '.', ';', ':', '!', '?', ')'])
 }
 
+/// The token ends a sentence: `.`, `!` or `?`, possibly before closing quotes
+/// or a bracket (`"Costs".` and `"Costs."` both end one).
+fn ends_sentence(raw: &str) -> bool {
+    raw.trim_end_matches(['"', '\'', '\u{201d}', '\u{2019}', ')'])
+        .ends_with(['.', '!', '?'])
+}
+
+/// The token range of the sentence holding token `i`.
+fn sentence_of(toks: &[Tok], i: usize) -> std::ops::Range<usize> {
+    let mut lo = i;
+    while lo > 0 && !ends_sentence(&toks[lo - 1].raw) {
+        lo -= 1;
+    }
+    let mut hi = i;
+    while hi + 1 < toks.len() && !ends_sentence(&toks[hi].raw) {
+        hi += 1;
+    }
+    lo..hi + 1
+}
+
+/// Nouns that name a part of the document, not the whole of it: a range or a
+/// bound in the same sentence may be about that part (sc#343 review).
+const PART_NOUNS: [&str; 22] = [
+    "paragraph",
+    "paragraphs",
+    "stanza",
+    "stanzas",
+    "verse",
+    "verses",
+    "bullet",
+    "bullets",
+    "entry",
+    "entries",
+    "item",
+    "items",
+    "sentence",
+    "sentences",
+    "gap",
+    "gaps",
+    "space",
+    "distance",
+    "row",
+    "rows",
+    "column",
+    "columns",
+];
+
 /// Words allowed right after the counted noun or the quoted phrase: they
 /// join a new clause instead of qualifying the count.
 const CLAUSE_JOINERS: [&str; 9] = [
@@ -974,6 +1022,59 @@ pub fn analyze(goal: &str) -> Extraction {
         })
     };
     for s in 0..n {
+        // "between N and M lines|words": inclusive, N <= M (sc#331).
+        if toks[s].word == "between" {
+            let w = |i: usize| toks.get(i).map(|t| t.word.as_str());
+            if let (Some(Num::Val(lo)), Some("and"), Some(Num::Val(hi)), Some(noun)) = (
+                w(s + 1).map(parse_num),
+                w(s + 2),
+                w(s + 3).map(parse_num),
+                w(s + 4),
+            ) {
+                let pair = match noun {
+                    "lines" | "line" => {
+                        Some((Requirement::MinLines(lo), Requirement::MaxLines(hi)))
+                    }
+                    "words" | "word" => {
+                        Some((Requirement::MinWords(lo), Requirement::MaxWords(hi)))
+                    }
+                    _ => None,
+                };
+                // Not about a part of the document ("each paragraph between ...",
+                // "the gap between ..."), and not approximate ("... lines or so",
+                // "roughly", "approximately", "give or take", "-ish").
+                // Anywhere earlier in the sentence: "every single long paragraph
+                // stays between ...", "its stanzas are between ...".
+                let part = s >= 1 && NOUNS.contains(&toks[s - 1].word.as_str())
+                    || toks[sentence_of(&toks, s).start..s].iter().any(|t| {
+                        let t = t.word.as_str();
+                        matches!(t, "each" | "every" | "per")
+                            || PART_NOUNS.contains(&t)
+                            || SECTION_NOUNS.contains(&t)
+                    });
+                let o = if w(s + 5) == Some("long") {
+                    s + 6
+                } else {
+                    s + 5
+                };
+                let or_so = (w(o) == Some("or") && w(o + 1) == Some("so"))
+                    || matches!(w(o), Some("roughly" | "approximately" | "ish"))
+                    || (w(o) == Some("give") && w(o + 1) == Some("or") && w(o + 2) == Some("take"));
+                if let Some((a, b)) = pair {
+                    if lo <= hi
+                        && !part
+                        && !or_so
+                        && !negated_before(&toks, s)
+                        && qualifier_ok(&toks, s + 4)
+                    {
+                        add(&mut counts, a);
+                        add(&mut counts, b);
+                        handled.extend(s..=s + 4);
+                    }
+                }
+            }
+            continue;
+        }
         // "N <noun> or more|fewer|less" and "N <noun> minimum|maximum".
         if let (Num::Val(v), Some(noun)) = (
             parse_num(&toks[s].word),
@@ -1034,7 +1135,17 @@ pub fn analyze(goal: &str) -> Extraction {
         let Num::Val(v) = parse_num(&numtok.word) else {
             continue;
         };
-        let j = i + 1;
+        let mut j = i + 1;
+        // "non-empty lines": line counts are over non-empty lines already (sc#331).
+        if toks
+            .get(j)
+            .is_some_and(|t| matches!(t.word.as_str(), "non-empty" | "nonempty" | "non-blank"))
+            && toks
+                .get(j + 1)
+                .is_some_and(|t| matches!(t.word.as_str(), "lines" | "line"))
+        {
+            j += 1;
+        }
         let Some(noun) = toks.get(j).map(|t| t.word.as_str()) else {
             continue;
         };
@@ -1254,14 +1365,63 @@ pub fn analyze(goal: &str) -> Extraction {
     // ---- section titles: "sections titled A, B and C", "sections: A, B and C" ----
     for k in 0..n {
         let w = toks[k].word.as_str();
-        let titled = matches!(w, "titled" | "named" | "called" | "entitled")
-            && k >= 1
-            && SECTION_NOUNS.contains(&toks[k - 1].word.as_str());
+        let tw = |i: usize| toks[i].word.as_str();
+        // "sections titled", and (sc#331, quoted titles only) "section is titled",
+        // "one section must|should|will|shall|can be titled".
+        let titled_at = if !matches!(w, "titled" | "named" | "called" | "entitled") || k < 1 {
+            None
+        } else if SECTION_NOUNS.contains(&tw(k - 1)) {
+            Some((k - 1, false))
+        } else if k >= 2 && matches!(tw(k - 1), "is" | "are") && SECTION_NOUNS.contains(&tw(k - 2))
+        {
+            Some((k - 2, true))
+        } else if k >= 3
+            && tw(k - 1) == "be"
+            && matches!(tw(k - 2), "must" | "should" | "will" | "shall" | "can")
+            && SECTION_NOUNS.contains(&tw(k - 3))
+        {
+            Some((k - 3, true))
+        } else {
+            None
+        };
+        let titled = titled_at.is_some();
         let colon = SECTION_NOUNS.contains(&w) && toks[k].raw.ends_with(':');
         if !titled && !colon {
             continue;
         }
-        let noun_at = if titled { k - 1 } else { k };
+        let noun_at = titled_at.map_or(k, |x| x.0);
+        let needs_quotes = titled_at.is_some_and(|x| x.1);
+        // The new forms are read only for one plain, unconditional title list:
+        // not "each|every|all|any section is titled", not "... if needed".
+        // The whole sentence is scanned, past commas and semicolons:
+        // "titled \"X\", unless ...", "If needed, one section ...".
+        // The quoted titles themselves ("When to Plant", "What If") are not hedges.
+        let title_bytes = {
+            let from = toks[k].end;
+            from..from + leading_quoted_items(list_region(goal, from)).1
+        };
+        let hedged = needs_quotes && {
+            (noun_at >= 1
+                && matches!(
+                    toks[noun_at - 1].word.as_str(),
+                    "each" | "every" | "all" | "any"
+                ))
+                || toks[sentence_of(&toks, noun_at)].iter().any(|t| {
+                    !title_bytes.contains(&t.start)
+                        && matches!(
+                            t.word.as_str(),
+                            "if" | "unless"
+                                | "optionally"
+                                | "optional"
+                                | "may"
+                                | "might"
+                                | "when"
+                                | "whenever"
+                                | "perhaps"
+                                | "maybe"
+                        )
+                })
+        };
         let declared_at = [1usize, 2].into_iter().find_map(|d| {
             let p = noun_at.checked_sub(d)?;
             matches!(parse_num(&toks[p].word), Num::Val(_)).then_some(p)
@@ -1288,6 +1448,8 @@ pub fn analyze(goal: &str) -> Extraction {
                 .iter()
                 .all(|t| !t.is_empty() && t.split_whitespace().count() <= 8)
             && (quoted_list || !titles.iter().any(|t| has_count_and_noun(t)))
+            && (quoted_list || !needs_quotes)
+            && !hedged
             && declared.is_none_or(|d| d == titles.len());
         if ok {
             let seen = match level {
@@ -1592,7 +1754,27 @@ pub fn analyze(goal: &str) -> Extraction {
             let looks_numeric = matches!(num_at, Some(Num::Val(_)) | Some(Num::Bad));
             let noun_near =
                 (i + 1..=i + reach).any(|j| after(j).is_some_and(|w| NOUNS.contains(&w)));
-            if looks_numeric && (noun_near || num_at == Some(Num::Bad)) {
+            // "under three sections titled A, B and C": a preposition before a
+            // count a recognizer already read (sc#331).
+            let organise = |m: usize| {
+                toks.get(m).is_some_and(|t| {
+                    matches!(
+                        t.word.as_str(),
+                        "organise"
+                            | "organize"
+                            | "structure"
+                            | "arrange"
+                            | "divide"
+                            | "group"
+                            | "split"
+                            | "sort"
+                    )
+                })
+            };
+            let under_read = toks[s].norm == "under"
+                && handled.contains(&i)
+                && ((s >= 1 && organise(s - 1)) || (s >= 2 && organise(s - 2)));
+            if looks_numeric && (noun_near || num_at == Some(Num::Bad)) && !under_read {
                 bad(&mut unsure, s, true);
                 continue;
             }
diff --git a/crates/aien-runtime/tests/requirements_count_wordings_test.rs b/crates/aien-runtime/tests/requirements_count_wordings_test.rs
new file mode 100644
index 00000000..d4bd9948
--- /dev/null
+++ b/crates/aien-runtime/tests/requirements_count_wordings_test.rs
@@ -0,0 +1,163 @@
+//! sc#331: ordinary count wordings of the v5 goals were refused as uncertain
+//! before any model call: an inclusive range ("between 16 and 30 lines"), the
+//! adjective "non-empty" before lines, a counted title list after the
+//! preposition "under", and a single title given as "one section must be
+//! titled". Each is now read; the near misses stay UNCERTAIN.
+use aien_runtime::requirements::{analyze, Requirement};
+
+use Requirement::*;
+
+fn reqs(goal: &str) -> Vec<Requirement> {
+    let ex = analyze(goal);
+    assert!(
+        ex.uncertain.is_empty(),
+        "{goal:?} should be read, uncertain: {:?}",
+        ex.uncertain
+    );
+    ex.requirements
+}
+
+fn heads(t: &[&str]) -> Requirement {
+    RequiredHeadings(t.iter().map(|x| x.to_string()).collect())
+}
+
+#[test]
+fn the_v5_d1_count_sentence_is_read() {
+    // v5 D1, second sentence, verbatim.
+    let g = "It should have at least 22 non-empty lines and three sections titled \"Gather Your Tools\", \"Sharpen the Edge\" and \"Test and Store\".";
+    assert_eq!(
+        reqs(g),
+        [
+            MinLines(22),
+            heads(&["Gather Your Tools", "Sharpen the Edge", "Test and Store"])
+        ]
+    );
+}
+
+#[test]
+fn the_v5_d5_range_and_sections_are_read() {
+    // v5 D5, second sentence, verbatim.
+    assert_eq!(
+        reqs("Keep it between 16 and 30 lines long."),
+        [MinLines(16), MaxLines(30)]
+    );
+    // v5 D5, last sentence up to its word clause (that clause is sc#333).
+    assert_eq!(
+        reqs("Organise it under three sections titled \"Documents\", \"Clothes\" and \"Electronics\"."),
+        [heads(&["Documents", "Clothes", "Electronics"])]
+    );
+}
+
+#[test]
+fn the_v5_d6_single_title_is_read() {
+    // v5 D6, the clause after its paragraph count (that count is sc#335).
+    let g = "Please write a warm essay about adopting a rescue cat, and one section must be titled \"Bringing Her Home\".";
+    assert_eq!(reqs(g), [heads(&["Bringing Her Home"])]);
+}
+
+#[test]
+fn related_wordings_are_read_the_same_way() {
+    for (goal, want) in [
+        (
+            "Write between 100 and 200 words.",
+            vec![MinWords(100), MaxWords(200)],
+        ),
+        (
+            "Keep it between 5 and 5 lines.",
+            vec![MinLines(5), MaxLines(5)],
+        ),
+        ("Use at least 10 nonempty lines.", vec![MinLines(10)]),
+        ("Use no fewer than 10 non-blank lines.", vec![MinLines(10)]),
+        (
+            "The section should be titled \"Costs\".",
+            vec![heads(&["Costs"])],
+        ),
+        ("A section is titled \"Costs\".", vec![heads(&["Costs"])]),
+        // round 3: a hedge word inside the quoted title is part of the title
+        (
+            "One section must be titled \"Water When Dry\".",
+            vec![heads(&["Water When Dry"])],
+        ),
+        (
+            "A section is titled \"What If We Wait\".",
+            vec![heads(&["What If We Wait"])],
+        ),
+        // a hedge in another sentence does not reach this one
+        (
+            "You may write more. One section must be titled \"Costs\".",
+            vec![heads(&["Costs"])],
+        ),
+        (
+            "Keep it between 16 and 30 lines and between 100 and 300 words.",
+            vec![MinLines(16), MaxLines(30), MinWords(100), MaxWords(300)],
+        ),
+        (
+            "Two sections must be titled \"Costs\" and \"Risks\".",
+            vec![heads(&["Costs", "Risks"])],
+        ),
+    ] {
+        assert_eq!(reqs(goal), want, "{goal}");
+    }
+}
+
+#[test]
+fn near_misses_stay_uncertain() {
+    for goal in [
+        // a reversed range
+        "Keep it between 30 and 16 lines.",
+        // no upper bound exists for items
+        "Use between 3 and 5 items.",
+        // a qualified range
+        "Keep it between 16 and 30 lines of code.",
+        "Keep it between 16 and 30 lines per section.",
+        // negated
+        "Do not keep it between 16 and 30 lines.",
+        // other range forms
+        "Write 2-3 lines.",
+        "Write from 16 to 30 lines.",
+        // non-empty before another noun
+        "Use at least 22 non-empty words.",
+        // the count differs from the list
+        "Organise it under two sections titled \"Documents\", \"Clothes\" and \"Electronics\".",
+        "One section must be titled \"A\" and \"B\".",
+        // "under N sections" with no titles is a bound
+        "Keep it under 3 sections.",
+        // negated title
+        "One section must not be titled \"Intro\".",
+        // the aux forms need quoted titles
+        "One section must be titled with the trip name.",
+        // sc#343 review: a shared title, a conditional title
+        "Each section is titled \"X\".",
+        "Every section must be titled \"X\".",
+        "A section is titled \"X\" if needed.",
+        "Optionally one section must be titled \"X\".",
+        // sc#343 review: a range on a part of the document, or approximate
+        "Keep the gap between 10 and 20 lines.",
+        "Keep each paragraph between 2 and 4 lines.",
+        "Make the second paragraph between 16 and 30 words.",
+        "Keep it between 16 and 30 lines or so.",
+        // sc#343 review: "under" is a preposition only after an organising verb
+        "Keep it under 3 sections titled \"A\", \"B\" and \"C\".",
+        // sc#343 review round 2: a hedge anywhere in the sentence
+        "A section is titled \"X\", if you can.",
+        "One section must be titled \"X\", unless it is short.",
+        "One section must be titled \"X\"; maybe add more.",
+        "If needed, one section must be titled \"X\".",
+        "Please write an essay, and one section must be titled \"A\", when relevant.",
+        // round 2: a part of the document anywhere earlier in the sentence
+        "Write the essay so that every single long paragraph stays between 16 and 30 words.",
+        "Write the poem so that its stanzas are between 16 and 30 words.",
+        "Write the poem; the stanzas should be between 16 and 30 words.",
+        "Keep it between 16 and 30 lines long, or so.",
+        "Write between 16 and 30 lines, roughly.",
+        "Write between 16 and 30 lines, give or take.",
+        "Write between 16 and 30 lines approximately.",
+    ] {
+        let ex = analyze(goal);
+        assert!(
+            !ex.uncertain.is_empty(),
+            "{goal:?} should stay uncertain, got {:?}",
+            ex.requirements
+        );
+    }
+}
diff --git a/crates/aien-runtime/tests/requirements_enforce_test.rs b/crates/aien-runtime/tests/requirements_enforce_test.rs
index ce4e08ab..a61d8de7 100644
--- a/crates/aien-runtime/tests/requirements_enforce_test.rs
+++ b/crates/aien-runtime/tests/requirements_enforce_test.rs
@@ -196,7 +196,7 @@ fn uncertain_spans_are_reported_not_dropped() {
         ("at most 3 paragraphs", "at most 3 paragraphs"),
         ("exactly 20 lines", "exactly 20 lines"),
         ("about 30 lines", "about 30 lines"),
-        ("between 10 and 20 lines", "between 10 and 20 lines"),
+        ("between 10 and 20 items", "between 10 and 20 items"),
         ("write **at least 20 lines**", "at least 20 lines"),
         ("at least 20 long lines", "at least 20 long lines"),
         ("do not write at least 20 lines", "at least 20 lines"),