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#360 (code only)
Apply it
git checkout -b patch-cc8c27fd97cbbda4 e27bda8af585290ec2c1d9146c4a5023e9b3a0d3 curl -fsSL https://interplane.io/drakestapleton/aien-sovereign-core-mv/patches/cc8c27fd97cbbda4.patch | git am
Provenance
github-import 1
aien-dev/aien-sovereign-core-mv
360
b054dc47afc373bc1394085741ee14b8a55d1e03
{"kind":"github-import","owner":"aien-dev","repo":"aien-sovereign-core-mv","number":360,"url":"https://github.com/aien-dev/aien-sovereign-core-mv/pull/360","export_sha256":"967c79e26a893657b5cdaa45efd442be5dbd2ecfe68e25f9a8c1b5da4d60d452","imported_utc":"2026-11-18T16:36:56Z","metadata":"unavailable","state_derived":true}
Changes
diff --git a/.crumb b/.crumb index 137ac6e5..37f88af4 100644 --- a/.crumb +++ b/.crumb @@ -77,14 +77,14 @@ } ], "children_root": "sha256:95ba9db41a2ad217bd02bbbe25aaf363580b5cd23754f40351ee780858343de5", - "compiled_at": "2026-10-08T23:08:09Z", + "compiled_at": "2026-10-09T00:33:00Z", "compiler": "crumb-compile/1", - "digest": "sha256:d1f6e5adb11581eb50b38ed303a703da9d0a4ee94f2881fc021438e8b28b1556", + "digest": "sha256:e78426abf00f4650b7714aa32a18a7156b1fb462f6f92e510a3c4339a872ef68", "evidence_files": 187, "evidence_root": "sha256:27ee0353cb4d4aae2b7dbce2bfe0d9f4ef2a94cd7a4555b84684d59372503280", "files": 1732, - "generated_at_commit": "95ea4d5f902484f0d5579e199ba768ba61913ff7", - "source_tree": "sha256:d31f7309cfcbec7ce04424e35f0e4ddcc456997c191aa983805d4a840b7190ae" + "generated_at_commit": "71b5696248285f34d46697aabe0ae417e3f11aa7", + "source_tree": "sha256:98831b953fac9300fcc063377c65afb1663d007f3890072aa7440298f8d79f48" } }, "history": [], diff --git a/crates/aien-runtime/Cargo.toml b/crates/aien-runtime/Cargo.toml index c7816914..d7e8cd3b 100644 --- a/crates/aien-runtime/Cargo.toml +++ b/crates/aien-runtime/Cargo.toml @@ -42,3 +42,8 @@ test-support = [] [dev-dependencies] tempfile = "3.10" aien-runtime = { path = ".", features = ["test-support"] } + +# The CPU reference driver's prompt tests (examples/np1_reference.rs) run with `cargo test`. +[[example]] +name = "np1_reference" +test = true diff --git a/crates/aien-runtime/examples/np1_reference.rs b/crates/aien-runtime/examples/np1_reference.rs index 6ccad57f..3d382dfb 100644 --- a/crates/aien-runtime/examples/np1_reference.rs +++ b/crates/aien-runtime/examples/np1_reference.rs @@ -7,7 +7,10 @@ //! the model's stop set. Prints one JSON object. //! //! usage: np1_reference <model_dir> <goal> <workspace> <max_tokens> <new|task> [retry reason] -//! new = `proposal_prompt(goal, workspace)` (the v5 template, no edit block) +//! new = the product's NEW-destination prompt (`spine::task_decision`, `TargetClass::New`): +//! `proposal_prompt(goal, workspace)` plus `new_document_block` for the destination the +//! goal names, from the product's own public pieces, so it still holds after the run wrote +//! that destination (the v5 template alone when the goal names none) //! task = `task_prompt(goal, workspace)` on the workspace as it is now //! retry reason: the prompt of attempt k > 1, `retry_prompt(<prompt>, reason)` use aien_inference_abi::{ChatTokenizer, SamplingParams}; @@ -95,10 +98,7 @@ async fn main() { let (w, _, _) = turn(&mut spine, &mut backend, &wids, 1, &stop) .await .expect("warm-up"); - let base = match mode { - "new" => aien_runtime::spine::proposal_prompt(goal, &ws.display().to_string()), - _ => aien_runtime::spine::task_prompt(goal, &ws), - }; + let base = reference_prompt(mode, goal, &ws); let retry = a.get(6).cloned(); let prompt = match &retry { Some(why) => aien_runtime::spine::retry_prompt(&base, why), @@ -141,3 +141,97 @@ async fn main() { }) ); } + +/// The prompt of one reference run. `new` repeats the `TargetClass::New` branch of +/// `spine::task_decision` (the template plus `new_document_block` for the named +/// destination) with the product's own functions; it does not call `task_decision` +/// because the run being replayed may already have written that destination, which +/// would turn the live decision into an edit. `task` is the product's `task_prompt` +/// on the workspace as it is now. The tests below hold both byte-equal to the product. +/// Limit: a word without an extension is a destination only once it exists as a file +/// (`destination::path_like`), so a goal like "save it into notes/tea" can gain the block +/// after the run wrote `notes/tea`; name replayed destinations with an extension (v5 R1: +/// `notes/swim-tip.txt`). +fn reference_prompt(mode: &str, goal: &str, ws: &std::path::Path) -> String { + use aien_runtime::spine::{ + classify_destination, new_document_block, proposal_prompt, task_prompt, + }; + match mode { + "new" => { + let mut prompt = proposal_prompt(goal, &ws.display().to_string()); + if let Some(dest) = classify_destination(goal, ws).1 { + prompt.push_str(&new_document_block(&dest)); + } + prompt + } + _ => task_prompt(goal, ws), + } +} + +#[cfg(test)] +mod tests { + use super::reference_prompt; + use aien_runtime::spine::{task_decision, ProposalKind}; + use std::path::{Path, PathBuf}; + + fn workspace() -> (tempfile::TempDir, PathBuf) { + let t = tempfile::tempdir().unwrap(); + let ws = std::fs::canonicalize(t.path()).unwrap(); + std::fs::create_dir_all(ws.join("docs")).unwrap(); + std::fs::write(ws.join("README.md"), "# workspace\n").unwrap(); + (t, ws) + } + + fn product(goal: &str, ws: &Path) -> (String, ProposalKind) { + let ((prompt, _, kind), _) = task_decision(goal, ws).unwrap(); + (prompt, kind) + } + + // NEW: a goal naming a missing file (here in a folder that does not exist yet, like + // v5 R1). The reference prompt equals the product prompt before the run, and stays + // byte-equal to it after the run wrote the destination. + #[test] + fn new_destination_prompt_equals_the_product_before_and_after_the_write() { + let (_t, ws) = workspace(); + let goal = "Save a one-sentence reminder about stretching the shoulders before swimming into notes/swim-tip.txt."; + let (want, kind) = product(goal, &ws); + assert_eq!(kind, ProposalKind::Document); + assert!(want.ends_with("filename: notes/swim-tip.txt"), "{want}"); + assert_eq!(reference_prompt("new", goal, &ws), want); + std::fs::create_dir_all(ws.join("notes")).unwrap(); + std::fs::write(ws.join("notes/swim-tip.txt"), "Stretch first.\n").unwrap(); + assert_eq!(reference_prompt("new", goal, &ws), want); + } + + // EDIT: a goal naming an existing file. The reference `task` mode is the product + // prompt with the edit block. + #[test] + fn edit_destination_prompt_equals_the_product() { + let (_t, ws) = workspace(); + std::fs::write(ws.join("docs/plan.md"), "## Steps\n1. Start.\n").unwrap(); + let goal = "In the existing file docs/plan.md, add the line \"2. Finish.\" at the end."; + let (want, kind) = product(goal, &ws); + assert_eq!(kind, ProposalKind::Edit); + assert!( + want.contains("The file docs/plan.md already exists."), + "{want}" + ); + assert_eq!(reference_prompt("task", goal, &ws), want); + } + + // Plain task: a goal naming no destination. Both reference modes are the product + // prompt, the template with no added block. + #[test] + fn plain_task_prompt_equals_the_product() { + let (_t, ws) = workspace(); + let goal = "Write a short note about brewing green tea."; + let (want, kind) = product(goal, &ws); + assert_eq!(kind, ProposalKind::Document); + assert_eq!( + want, + aien_runtime::spine::proposal_prompt(goal, &ws.display().to_string()) + ); + assert_eq!(reference_prompt("new", goal, &ws), want); + assert_eq!(reference_prompt("task", goal, &ws), want); + } +}