Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aien-sovereign-core-mv/patches/fab92390288c64ea # 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 Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers ## GitHub aien-dev/aien-sovereign-core-mv#431 (code only) closed derived `fab92390288c64ea` #431 Imported from GitHub aien-dev/aien-sovereign-core-mv#431 (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 `5886f9110db2bd37dedb23810bfa4659f80af942` · Head `276b0d5bb98dc3001aa724f7adf9cb4f83053e89` ### Apply it ``` git checkout -b patch-fab92390288c64ea 5886f9110db2bd37dedb23810bfa4659f80af942 curl -fsSL https://interplane.io/drakestapleton/aien-sovereign-core-mv/patches/fab92390288c64ea.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 431 276b0d5bb98dc3001aa724f7adf9cb4f83053e89 ``` ``` {"kind":"github-import","owner":"aien-dev","repo":"aien-sovereign-core-mv","number":431,"url":"https://github.com/aien-dev/aien-sovereign-core-mv/pull/431","export_sha256":"967c79e26a893657b5cdaa45efd442be5dbd2ecfe68e25f9a8c1b5da4d60d452","imported_utc":"2026-11-18T16:37:09Z","metadata":"unavailable","state_derived":true} ``` ### Changes ``` diff --git a/.crumb b/.crumb index f023adec..50dd920c 100644 --- a/.crumb +++ b/.crumb @@ -77,14 +77,14 @@ } ], "children_root": "sha256:487a2166057a996c7eb8d85014729071455e5ac4b1728a0b23f5a3cbfada4ab7", - "compiled_at": "2026-10-11T07:11:47Z", + "compiled_at": "2026-10-11T13:55:46Z", "compiler": "crumb-compile/1", - "digest": "sha256:8c6e0db5466604a2e830fa01d7d3ebcfa7f750477885ae5a5dba66fb70b2aec1", + "digest": "sha256:34d8c17cfc237ca09dd1276498f1f8d1fd1b2e47fa1da5440dca83be1beecc6b", "evidence_files": 187, "evidence_root": "sha256:27ee0353cb4d4aae2b7dbce2bfe0d9f4ef2a94cd7a4555b84684d59372503280", - "files": 3533, - "generated_at_commit": "081a766973acf7402959f6133fa44e6c451924d1", - "source_tree": "sha256:0eda8534c69b5bba88283fad33c53459ccb75f641af86a30eb22b5d3475b58b7" + "files": 3534, + "generated_at_commit": "e352e75e355f44486d0dbaf529ad8e039ae30393", + "source_tree": "sha256:3329efbe42fc14b2f975d152d88d65f47015dbcf0fde1f98783b6ab89a355a80" } }, "history": [], diff --git a/crates/aien-runtime/examples/np1_reference.rs b/crates/aien-runtime/examples/np1_reference.rs index 3d382dfb..fede8447 100644 --- a/crates/aien-runtime/examples/np1_reference.rs +++ b/crates/aien-runtime/examples/np1_reference.rs @@ -8,7 +8,7 @@ //! //! usage: np1_reference [retry reason] //! new = the product's NEW-destination prompt (`spine::task_decision`, `TargetClass::New`): -//! `proposal_prompt(goal, workspace)` plus `new_document_block` for the destination the +//! `proposal_prompt(goal)` 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 @@ -158,7 +158,7 @@ fn reference_prompt(mode: &str, goal: &str, ws: &std::path::Path) -> String { }; match mode { "new" => { - let mut prompt = proposal_prompt(goal, &ws.display().to_string()); + let mut prompt = proposal_prompt(goal); if let Some(dest) = classify_destination(goal, ws).1 { prompt.push_str(&new_document_block(&dest)); } @@ -227,10 +227,7 @@ mod tests { 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!(want, aien_runtime::spine::proposal_prompt(goal)); assert_eq!(reference_prompt("new", goal, &ws), want); assert_eq!(reference_prompt("task", goal, &ws), want); } diff --git a/crates/aien-runtime/src/spine.rs b/crates/aien-runtime/src/spine.rs index 5f8bb245..e401ced9 100644 --- a/crates/aien-runtime/src/spine.rs +++ b/crates/aien-runtime/src/spine.rs @@ -1152,8 +1152,20 @@ pub fn compose_assistant_prefix(template: &aien_inference_abi::ChatTemplate) -> } } -/// The fixed proposal template of the production RunComposeTask path. -pub fn proposal_prompt(goal: &str, workspace: &str) -> String { +/// The logical name of the authorized workspace as the model sees it (sc#429). +/// +/// A constant: the model-visible prompt never carries the machine-specific +/// absolute path (host name, user name, job folder), so equal logical inputs +/// give equal prompt bytes and token ids on every machine. The real path stays +/// in the authorization, confinement, execution and evidence layers +/// (`RunComposeTask` canonicalizes the workspace, the task id hashes it, the +/// commit record stores it). +pub const WORKSPACE_LABEL: &str = "workspace"; + +/// The fixed proposal template of the production RunComposeTask path. The +/// workspace is named by `WORKSPACE_LABEL`, never by its path (sc#429). +pub fn proposal_prompt(goal: &str) -> String { + let workspace = WORKSPACE_LABEL; format!( "Goal: {goal}\nAuthorized workspace: {workspace}\n\ Propose exactly one file change inside the workspace.\n\ @@ -1476,13 +1488,8 @@ pub fn task_prompt(goal: &str, ws: &Path) -> String { /// merges an edit reply into this same content, so the bytes the model saw /// are the bytes the merge keeps. pub fn task_prompt_and_target(goal: &str, ws: &Path) -> (String, Option<(String, String)>) { - let (prompt, target, _) = task_plan(goal, ws).unwrap_or_else(|_| { - ( - proposal_prompt(goal, &ws.display().to_string()), - None, - ProposalKind::Document, - ) - }); + let (prompt, target, _) = task_plan(goal, ws) + .unwrap_or_else(|_| (proposal_prompt(goal), None, ProposalKind::Document)); (prompt, target) } @@ -1506,7 +1513,7 @@ pub type TaskDecisionInputs = (TaskPrompt, Option, Vec, Vec Result { - let mut prompt = proposal_prompt(goal, &ws.display().to_string()); + let mut prompt = proposal_prompt(goal); let (class, dest, named) = classify_with_inputs(goal, ws); let kind = class.kind(); if let TargetClass::Refused(why) = class { diff --git a/crates/aien-runtime/tests/chat_template_test.rs b/crates/aien-runtime/tests/chat_template_test.rs index 996f7477..ba185f40 100644 --- a/crates/aien-runtime/tests/chat_template_test.rs +++ b/crates/aien-runtime/tests/chat_template_test.rs @@ -72,11 +72,8 @@ fn proposal_prompt_token_counts() { return; }; let tok = TinyLlamaTokenizer::from_file(path).expect("tokenizer"); - let ws_owned = - std::env::var("AIEN_PROPOSAL_WS").unwrap_or_else(|_| "/tmp/np1-v3run/ws".to_string()); - let ws = ws_owned.as_str(); let goal = "Create the file NOTES.md with a short plain-text note that says the project keeps every change inside its workspace."; - let base = aien_runtime::spine::proposal_prompt(goal, ws); + let base = aien_runtime::spine::proposal_prompt(goal); let retry = aien_runtime::spine::retry_prompt( &base, "no filename line: the first line must be 'filename: '", diff --git a/crates/aien-runtime/tests/inputs_test.rs b/crates/aien-runtime/tests/inputs_test.rs index f334aef3..0384adbd 100644 --- a/crates/aien-runtime/tests/inputs_test.rs +++ b/crates/aien-runtime/tests/inputs_test.rs @@ -242,10 +242,9 @@ fn goal_without_inputs_keeps_prompt_byte_for_byte() { assert_eq!(a.0, b.0); assert!(b.2.is_empty() && b.3.is_empty()); assert!(!a.0 .0.contains("Input files")); - let w = ws.display().to_string(); let want = format!( "{}{}", - aien_runtime::spine::proposal_prompt(goal, &w), + aien_runtime::spine::proposal_prompt(goal), aien_runtime::spine::new_document_block("notes.md") ); assert_eq!(a.0 .0, want); diff --git a/crates/aien-runtime/tests/logical_workspace_test.rs b/crates/aien-runtime/tests/logical_workspace_test.rs new file mode 100644 index 00000000..669586c2 --- /dev/null +++ b/crates/aien-runtime/tests/logical_workspace_test.rs @@ -0,0 +1,129 @@ +//! sc#429: the model-visible prompt names the workspace by a constant logical +//! label, never by its machine-specific absolute path. Two workspaces with the +//! same logical inputs (goal, files, contents) at different absolute paths +//! (different parent folders, depths and names, as a different host, user or +//! job folder would give) must produce byte-identical prompts and, with a +//! tokenizer, identical prompt token ids. The real path stays in the +//! authorization and evidence layers (the canonical workspace is still +//! resolved, and the task id still hashes it). + +use aien_runtime::spine::{proposal_prompt, task_decision_with_inputs, WORKSPACE_LABEL}; +use std::path::Path; + +fn fill(ws: &Path) { + std::fs::create_dir_all(ws.join("inbox")).unwrap(); + std::fs::write(ws.join("inbox/tide.txt"), "High tide at 06:40.\n").unwrap(); + std::fs::write(ws.join("inbox/berth.txt"), "Berth 4 is free.\n").unwrap(); + std::fs::write(ws.join("inbox/crane.txt"), "Crane service at 09:00.\n").unwrap(); + std::fs::write(ws.join("report.md"), "# Harbour report\n\n- morning\n").unwrap(); +} + +/// Two equal workspaces at deliberately different absolute paths. +fn pair() -> ( + tempfile::TempDir, + tempfile::TempDir, + std::path::PathBuf, + std::path::PathBuf, +) { + let a_root = tempfile::tempdir().unwrap(); + let b_root = tempfile::tempdir().unwrap(); + let a = a_root + .path() + .join("jobs") + .join("host-alpha") + .join("ws-contract"); + let b = b_root + .path() + .join("home") + .join("other-user") + .join("deeper") + .join("run") + .join("ws-contract-2"); + fill(&a); + fill(&b); + (a_root, b_root, a, b) +} + +const GOALS: &[&str] = &[ + "Create the file NOTES.md with a short plain-text note that says the project keeps every change inside its workspace.", + "Write the file summary.md from the files tide.txt, berth.txt and crane.txt in the inbox folder.", + "Add the line \"- evening\" under the \"# Harbour report\" heading in report.md.", +]; + +#[test] +fn prompt_carries_the_label_and_never_the_path() { + let (_ka, _kb, a, b) = pair(); + let a = std::fs::canonicalize(&a).unwrap(); + let b = std::fs::canonicalize(&b).unwrap(); + assert_ne!(a, b); + for goal in GOALS { + let (pa, _, _, _) = task_decision_with_inputs(goal, &a).expect("task a"); + let (pb, _, _, _) = task_decision_with_inputs(goal, &b).expect("task b"); + assert_eq!( + pa.0, pb.0, + "prompt differs between workspaces for goal {goal}" + ); + assert!( + pa.0.starts_with(&format!( + "Goal: {goal}\nAuthorized workspace: {WORKSPACE_LABEL}\n" + )), + "label missing in {}", + pa.0 + ); + for p in [&a, &b] { + let s = p.display().to_string(); + assert!( + !pa.0.contains(&s), + "absolute path {s} leaked into the prompt" + ); + // not even the leaf folder name + let leaf = p.file_name().unwrap().to_str().unwrap(); + assert!( + !pa.0.contains(leaf), + "folder name {leaf} leaked into the prompt" + ); + } + } + let base = proposal_prompt(GOALS[0]); + assert!( + !base.contains('/'), + "no path separator in the base prompt: {base}" + ); +} + +/// With a tokenizer (`AIEN_TOKENIZER_PATH`), the token ids of the rendered +/// prompt are equal across the two paths, for every chat template the product +/// serves. +#[test] +fn prompt_token_ids_equal_across_paths() { + let Ok(path) = std::env::var("AIEN_TOKENIZER_PATH") else { + eprintln!("AIEN_TOKENIZER_PATH not set: token-id check skipped"); + return; + }; + use aien_inference_abi::TinyLlamaTokenizer; + use aien_runtime::control::{format_chat, ChatTurn}; + let tok = TinyLlamaTokenizer::from_file(path).expect("tokenizer"); + let (_ka, _kb, a, b) = pair(); + let a = std::fs::canonicalize(&a).unwrap(); + let b = std::fs::canonicalize(&b).unwrap(); + for goal in GOALS { + let (pa, _, _, _) = task_decision_with_inputs(goal, &a).expect("task a"); + let (pb, _, _, _) = task_decision_with_inputs(goal, &b).expect("task b"); + let ids = |p: &str| { + let turn = ChatTurn { + role: "user".into(), + content: p.into(), + }; + let text = format_chat(tok.template(), std::slice::from_ref(&turn)).expect("chat"); + tok.encode(&text).expect("encode") + }; + let ia = ids(&pa.0); + let ib = ids(&pb.0); + assert_eq!(ia, ib, "token ids differ between paths for goal {goal}"); + eprintln!( + "goal {:.40}...: {} prompt tokens, equal on both paths", + goal, + ia.len() + ); + } +} diff --git a/crates/aien-runtime/tests/np1_v6_test.rs b/crates/aien-runtime/tests/np1_v6_test.rs index e76eadc5..38acdc37 100644 --- a/crates/aien-runtime/tests/np1_v6_test.rs +++ b/crates/aien-runtime/tests/np1_v6_test.rs @@ -120,7 +120,6 @@ fn token_ids_reach_the_attempt_record() { #[test] fn edit_block_only_when_the_goal_names_an_existing_file() { let (_d, ws) = ws(); - let w = ws.display().to_string(); // A new-document goal keeps the v5 prompt and gains the destination line // (issue #288); an unsafe destination is refused and keeps the plain prompt. for goal in [ @@ -135,8 +134,8 @@ fn edit_block_only_when_the_goal_names_an_existing_file() { .ok() .and_then(|(_, d)| d); let want = match dest { - Some(d) => format!("{}{}", proposal_prompt(goal, &w), aien_runtime::spine::new_document_block(&d)), - None => proposal_prompt(goal, &w), + Some(d) => format!("{}{}", proposal_prompt(goal), aien_runtime::spine::new_document_block(&d)), + None => proposal_prompt(goal), }; assert_eq!(task_prompt(goal, &ws), want, "{goal}"); } @@ -153,7 +152,7 @@ fn edit_block_only_when_the_goal_names_an_existing_file() { p, format!( "{}{}", - proposal_prompt(goal, &w), + proposal_prompt(goal), edit_block("CHANGELOG.md", log) ) ); diff --git a/crates/aien-runtime/tests/warm_up_before_serving_test.rs b/crates/aien-runtime/tests/warm_up_before_serving_test.rs index 154d5206..b6bc6873 100644 --- a/crates/aien-runtime/tests/warm_up_before_serving_test.rs +++ b/crates/aien-runtime/tests/warm_up_before_serving_test.rs @@ -302,7 +302,7 @@ async fn cpu_reference_tokens_unchanged_by_warm_up() { "{}{}", format_chat( tok.template(), - &user(&aien_runtime::spine::proposal_prompt(goal, "/tmp/ws")) + &user(&aien_runtime::spine::proposal_prompt(goal)) ) .expect("chat"), aien_runtime::spine::COMPOSE_ASSISTANT_PREFIX ```