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#362 (code only)

closed derived f1501a14ed9eeb24 #362

Imported from GitHub aien-dev/aien-sovereign-core-mv#362 (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 797039a0bf76eb1d0a4b8af3e7de4a476176d148 · Head b1f0c995842928af15d6223bb1daeff33f34b62d

Apply it

git checkout -b patch-f1501a14ed9eeb24 797039a0bf76eb1d0a4b8af3e7de4a476176d148
curl -fsSL https://interplane.io/drakestapleton/aien-sovereign-core-mv/patches/f1501a14ed9eeb24.patch | git am

Raw patch (mbox) · 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
362
b1f0c995842928af15d6223bb1daeff33f34b62d
{"kind":"github-import","owner":"aien-dev","repo":"aien-sovereign-core-mv","number":362,"url":"https://github.com/aien-dev/aien-sovereign-core-mv/pull/362","export_sha256":"967c79e26a893657b5cdaa45efd442be5dbd2ecfe68e25f9a8c1b5da4d60d452","imported_utc":"2026-11-18T16:36:56Z","metadata":"unavailable","state_derived":true}

Changes

diff --git a/.crumb b/.crumb
index 51fded1c..d34ff840 100644
--- a/.crumb
+++ b/.crumb
@@ -65,7 +65,7 @@
       "children": [
         {
           "digest": "bf0b33103faf720887cc37d410f924747078edab52d2170d7c9d8c965a8b3618",
-          "last_commit": "3bd36c2",
+          "last_commit": "797039a",
           "name": "scripts",
           "purpose": ""
         },
@@ -77,14 +77,14 @@
         }
       ],
       "children_root": "sha256:20c95358a2e6cde016bc1a6b9d07b1ed5500de7131c7eb30982592664870658c",
-      "compiled_at": "2026-10-09T14:36:46Z",
+      "compiled_at": "2026-10-09T14:50:37Z",
       "compiler": "crumb-compile/1",
-      "digest": "sha256:335f6b5a5407bf79938e039ef8ca28f9480f49594593e688d0d93385cbdb36d9",
+      "digest": "sha256:9cfbde28d83d8770600ce621d93cd695720f9fe9088c4eaf3a011a9c196d12a4",
       "evidence_files": 187,
       "evidence_root": "sha256:27ee0353cb4d4aae2b7dbce2bfe0d9f4ef2a94cd7a4555b84684d59372503280",
-      "files": 1847,
-      "generated_at_commit": "8f08f119552ca8aa127e3a7024840155559ad208",
-      "source_tree": "sha256:c5564ec1371a82e51e07316070f50157ffb177c90b18eb49a1db734c1c5786f3"
+      "files": 1848,
+      "generated_at_commit": "2865673d8f0288049f88999f686c613287a628a3",
+      "source_tree": "sha256:b278a7013dfae86f02b66d6b877096408d7388f7aa06830f4da9a010e6924733"
     }
   },
   "history": [],
diff --git a/crates/aien-runtime/src/requirements_extract.rs b/crates/aien-runtime/src/requirements_extract.rs
index f0e60a78..9e951021 100644
--- a/crates/aien-runtime/src/requirements_extract.rs
+++ b/crates/aien-runtime/src/requirements_extract.rs
@@ -1,3 +1,4 @@
+//! | `<min bound> N <noun> and|or|but <bound> M` (second noun left out, e.g. `at least 20 lines and no more than 40`) | the second bound is read with the earlier noun (`MaxLines(40)`); with no clear earlier noun (or no earlier count at all), or a direction the noun does not support (`at least 3 paragraphs and no more than 5`), it is UNCERTAIN, never dropped (#344) |
 //! Reading the requirements out of a goal (see `requirements` for the model).
 //!
 //! `analyze` is rule based and deterministic. It returns the requirements it
@@ -1463,6 +1464,49 @@ pub fn analyze(goal: &str) -> Extraction {
         let Num::Val(v) = parse_num(&numtok.word) else {
             continue;
         };
+        // "at least 20 lines and no more than 40": the second noun is elided
+        // (#344). Read it with the earlier noun, or report it UNCERTAIN; never drop it.
+        let next_is_noun = toks
+            .get(i + 1)
+            .is_some_and(|t| NOUNS.contains(&t.word.as_str()));
+        if !next_is_noun && qualifier_ok(&toks, i) && !negated_before(&toks, s) {
+            let sent = sentence_of(&toks, s);
+            let joined =
+                s > sent.start && matches!(toks[s - 1].word.as_str(), "and" | "or" | "but");
+            // the noun of the count that ends right before the joiner
+            let antecedent = if joined {
+                (sent.start..s - 1).rev().find_map(|p| {
+                    let (l, _, _) = match_cue(&toks, p, false)?;
+                    let Num::Val(_) = parse_num(&toks.get(p + l)?.word) else {
+                        return None;
+                    };
+                    let mut j = p + l + 1;
+                    if toks.get(j).is_some_and(|t| {
+                        matches!(t.word.as_str(), "non-empty" | "nonempty" | "non-blank")
+                    }) {
+                        j += 1;
+                    }
+                    let noun = toks.get(j)?.word.as_str();
+                    // the noun sits right before the joiner (an optional "long" between)
+                    let gap_ok = j + 1 == s - 1 || (j + 2 == s - 1 && toks[j + 1].word == "long");
+                    (NOUNS.contains(&noun) && handled.contains(&p) && gap_ok).then_some(noun)
+                })
+            } else {
+                None
+            };
+            let v = v as i64 + adj;
+            match antecedent.and_then(|noun| count_req(dir, noun, v.max(1) as usize)) {
+                Some(r) if v >= 1 => {
+                    add(&mut counts, r);
+                    handled.extend(s..=i);
+                }
+                _ => {
+                    bad(&mut unsure, s, true);
+                    handled.extend(s..=i);
+                }
+            }
+            continue;
+        }
         let mut j = i + 1;
         // "non-empty lines": line counts are over non-empty lines already (sc#331).
         if toks
@@ -2381,7 +2425,13 @@ pub fn analyze(goal: &str) -> Extraction {
             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 {
+            // a bound cue and a number nothing above read: read or UNCERTAIN, never
+            // ignored ("at most 40 please", "fix at least 2 typos") (#344)
+            let unread_bound =
+                !vague && matches!(num_at, Some(Num::Val(_))) && !handled.contains(&i);
+            if ((looks_numeric && (noun_near || num_at == Some(Num::Bad))) || unread_bound)
+                && !under_read
+            {
                 bad(&mut unsure, s, true);
                 continue;
             }
diff --git a/crates/aien-runtime/tests/requirements_elided_bound_test.rs b/crates/aien-runtime/tests/requirements_elided_bound_test.rs
new file mode 100644
index 00000000..be49a6bc
--- /dev/null
+++ b/crates/aien-runtime/tests/requirements_elided_bound_test.rs
@@ -0,0 +1,238 @@
+//! #344: a second bound whose noun is left out ("at least 20 lines and no more
+//! than 40") is read with the earlier noun, or reported UNCERTAIN. It is never
+//! dropped silently.
+use aien_runtime::control::ControlResponse;
+use aien_runtime::requirements::{analyze, refusal_reason, Requirement};
+use aien_runtime::spine::{
+    check_file_proposal, propose_task_checked, ComposeBridge, ComposeProposer, Generation,
+    COMPOSE_MAX_ATTEMPTS,
+};
+use std::sync::Arc;
+use std::time::Duration;
+
+use Requirement::*;
+
+fn read(goal: &str) -> Vec<Requirement> {
+    let ex = analyze(goal);
+    assert!(ex.uncertain.is_empty(), "{goal:?}: {:?}", ex.uncertain);
+    ex.requirements
+}
+
+#[test]
+fn elided_max_after_min_is_read_with_the_earlier_noun() {
+    let want = [MinLines(20), MaxLines(40)];
+    for g in [
+        "Write at least 20 lines and no more than 40.",
+        "Write at least 20 lines and no more than 40",
+        "Write at least 20 lines, and no more than 40.",
+        "Write at least 20 lines but at most 40.",
+        "Write no fewer than 20 lines and up to 40.",
+        "Create docs/a.md with at least 20 lines and at most 40 in total.",
+    ] {
+        let r = read(g);
+        for w in &want {
+            assert!(r.contains(w), "{g:?} -> {r:?}");
+        }
+    }
+    let r = read("Write at least 100 words but at most 200.");
+    assert!(
+        r.contains(&MinWords(100)) && r.contains(&MaxWords(200)),
+        "{r:?}"
+    );
+    // strict cue keeps its adjustment: fewer than 40 is at most 39
+    let r = read("Write at least 20 lines and fewer than 40.");
+    assert!(r.contains(&MaxLines(39)), "{r:?}");
+}
+
+#[test]
+fn unsupported_noun_or_direction_is_uncertain_not_silent() {
+    // paragraphs have no upper bound in the model
+    let ex = analyze("Write at least 3 paragraphs and no more than 5.");
+    assert!(!ex.uncertain.is_empty(), "{ex:?}");
+    // items: no upper bound either
+    let ex = analyze("List at least 3 items and no more than 5.");
+    assert!(!ex.uncertain.is_empty(), "{ex:?}");
+    // a cue with no earlier noun to carry over
+    let ex = analyze("Write at least 20 lines and then keep it under, no more than 40.");
+    assert!(!ex.uncertain.is_empty(), "{ex:?}");
+}
+
+#[test]
+fn ordinary_numbers_stay_silent() {
+    for g in [
+        "Write at least 20 lines and fix 2 typos.",
+        "Fix 2 typos in README.md",
+        "Update section 3 of docs/a.md",
+        "Write at least 20 lines and update section 3.",
+    ] {
+        let r = analyze(g);
+        assert!(r.uncertain.is_empty(), "{g:?}: {:?}", r.uncertain);
+        assert!(
+            !r.requirements.iter().any(|x| matches!(x, MaxLines(_))),
+            "{g:?}: {:?}",
+            r.requirements
+        );
+    }
+    assert!(analyze("Fix 2 typos").requirements.is_empty());
+    assert!(analyze("Update section 3").requirements.is_empty());
+}
+
+fn gen(text: &str) -> Result<Generation, String> {
+    Ok(Generation {
+        text: text.to_string(),
+        tokens: 5,
+        finish_reason: Some("eos".into()),
+        ..Default::default()
+    })
+}
+
+fn reply(lines: usize) -> String {
+    let mut s = String::from("filename: docs/NOTES.md\n");
+    for i in 0..lines {
+        s.push_str(&format!("line number {i}\n"));
+    }
+    s
+}
+
+const GOAL: &str = "Create the file docs/NOTES.md with at least 20 lines and no more than 40.";
+
+#[test]
+fn bytes_over_the_second_bound_are_refused_and_within_bounds_pass() {
+    let reqs = analyze(GOAL).requirements;
+    let over = check_file_proposal(&reply(45)).unwrap().content;
+    let why = refusal_reason(&reqs, &over).expect("45 lines must be refused");
+    assert!(why.contains("40"), "{why}");
+    for ok in [20usize, 30, 40] {
+        let c = check_file_proposal(&reply(ok)).unwrap().content;
+        assert!(refusal_reason(&reqs, &c).is_none(), "{ok} lines");
+    }
+}
+
+fn bridge(tmp: &std::path::Path, lines: usize) -> ComposeBridge {
+    let text = reply(lines);
+    let proposer: ComposeProposer = Arc::new(move |_: &str, _: Duration| gen(&text));
+    ComposeBridge::new(tmp.join("compose"), proposer, "test:elided")
+}
+
+fn report(resp: ControlResponse) -> Option<aien_runtime::control::ComposeTaskReport> {
+    if !aien_omega_compose::LINKED {
+        assert!(matches!(resp, ControlResponse::Error(_)));
+        return None;
+    }
+    let ControlResponse::ComposeTaskResult(r) = resp else {
+        panic!("{resp:?}")
+    };
+    Some(*r)
+}
+
+#[test]
+fn linked_compose_does_not_commit_45_lines_but_commits_30() {
+    let tmp = tempfile::tempdir().unwrap();
+    let ws = tmp.path().join("ws");
+    std::fs::create_dir_all(&ws).unwrap();
+    let r = report(bridge(tmp.path(), 45).run_task(GOAL, ws.to_str().unwrap()));
+    if let Some(r) = r {
+        assert!(!r.committed, "{r:?}");
+        assert!(r.proposal.is_none());
+        assert_eq!(r.proposal_attempts.len(), COMPOSE_MAX_ATTEMPTS as usize);
+        assert_eq!(std::fs::read_dir(&ws).unwrap().count(), 0);
+    }
+    let tmp = tempfile::tempdir().unwrap();
+    let ws = tmp.path().join("ws");
+    std::fs::create_dir_all(&ws).unwrap();
+    if let Some(r) = report(bridge(tmp.path(), 30).run_task(GOAL, ws.to_str().unwrap())) {
+        assert!(r.committed, "{r:?}");
+        let p = check_file_proposal(r.proposal.as_deref().unwrap()).unwrap();
+        assert_eq!(p.content, check_file_proposal(&reply(30)).unwrap().content);
+    }
+}
+
+/// The real compose verification boundary (`propose_task_checked`), which does
+/// not need the linked omega build: the 45 line reply is refused on every
+/// attempt and nothing is approved; the 30 line reply is approved byte for byte.
+#[test]
+fn compose_boundary_refuses_45_lines_and_approves_30() {
+    let ex = analyze(GOAL);
+    assert!(ex.uncertain.is_empty());
+    let run = |lines: usize| {
+        let text = reply(lines);
+        let proposer = move |_: &str, _: Duration| gen(&text);
+        propose_task_checked(
+            &proposer,
+            "base",
+            None,
+            &ex.requirements,
+            Duration::from_secs(5),
+            Duration::from_millis(1),
+            COMPOSE_MAX_ATTEMPTS,
+        )
+    };
+    let (out, attempts) = run(45);
+    let why = out.unwrap_err();
+    assert!(why.contains("40"), "{why}");
+    assert_eq!(attempts.len(), COMPOSE_MAX_ATTEMPTS as usize);
+    assert!(attempts
+        .iter()
+        .all(|a| a.outcome == "refused" && a.aegis.is_none()));
+    let (out, attempts) = run(30);
+    assert_eq!(out.unwrap(), reply(30));
+    assert_eq!(attempts.len(), 1);
+}
+
+#[test]
+fn bound_cue_with_bare_number_and_no_antecedent_is_uncertain() {
+    for g in [
+        "Keep it to no more than 40",
+        "Keep it to no more than 40.",
+        "Write at least 20",
+        "Write at least 20.",
+        "Use up to 12.",
+        "Make it fewer than 40.",
+        "Make it more than 10.",
+        "Write a maximum of 30.",
+        "Write a minimum of 30.",
+        "Write no fewer than 5.",
+    ] {
+        let ex = analyze(g);
+        assert!(!ex.uncertain.is_empty(), "{g:?} silent: {ex:?}");
+    }
+    for g in [
+        "Fix 2 typos",
+        "Update section 3",
+        "Use Python 3",
+        "Use Python 3.",
+    ] {
+        let ex = analyze(g);
+        assert!(ex.uncertain.is_empty(), "{g:?}: {:?}", ex.uncertain);
+        assert!(ex.requirements.is_empty(), "{g:?}: {:?}", ex.requirements);
+    }
+}
+
+#[test]
+fn every_bound_cue_with_a_number_is_read_or_uncertain() {
+    for g in [
+        "Keep it at most 40 please",
+        "Keep it to no more than 40, thanks.",
+        "Include at least 2 of them",
+        "Fix at least 2 typos in README.md",
+        "Write at least 20 lines and fix at least 2 typos.",
+        "Use not more than 3 colours.",
+        "Use not less than 3 colours.",
+    ] {
+        let ex = analyze(g);
+        assert!(!ex.uncertain.is_empty(), "{g:?} silent: {ex:?}");
+    }
+    // still read, not uncertain
+    assert_eq!(read("Write at most 40 lines please."), [MaxLines(40)]);
+    for g in [
+        "Fix 2 typos in README.md",
+        "Update section 3",
+        "Use Python 3",
+    ] {
+        let ex = analyze(g);
+        assert!(
+            ex.uncertain.is_empty() && ex.requirements.is_empty(),
+            "{g:?}"
+        );
+    }
+}