diff --git a/.crumb b/.crumb index f6900131..9204ca3d 100644 --- a/.crumb +++ b/.crumb @@ -77,14 +77,14 @@ } ], "children_root": "sha256:9a27d2c98660aef35ed94ecfcb47d82d317ef88f97d0303db847c52915aad07f", - "compiled_at": "2026-10-11T03:40:20Z", + "compiled_at": "2026-10-11T04:00:54Z", "compiler": "crumb-compile/1", - "digest": "sha256:ba3621c082cc19d4a507a6c463b154ad5e385b4ed16f817c6ce28760b5e6f320", + "digest": "sha256:2d48bdca21179a844c8c44b9adf55735cb5c51e04c97621c0ec1fd30f516943d", "evidence_files": 187, "evidence_root": "sha256:27ee0353cb4d4aae2b7dbce2bfe0d9f4ef2a94cd7a4555b84684d59372503280", "files": 2940, - "generated_at_commit": "43208235f560bb98bd57d311b004d100c6cecc3f", - "source_tree": "sha256:62bdae0be8c9c839224eeccfa9a6e8b910ba27878caea0f2ea22e5784f5428d5" + "generated_at_commit": "ecb7b00f13c83a6900f18afb2c3a7d32660a83e9", + "source_tree": "sha256:d90afddb26e6f678a3d0ed4cdafcc008ca98566a24f6bb06bdb4b877dbbb197f" } }, "history": [], diff --git a/crates/aien-cli/.crumb b/crates/aien-cli/.crumb index 8ea66b01..9c5a49c9 100644 --- a/crates/aien-cli/.crumb +++ b/crates/aien-cli/.crumb @@ -34,21 +34,21 @@ "generated": { "children": [ { - "digest": "d2f1dccc8b5c0dc69f3b504558bcc0b31a1eeb955a0dda5ef98cd570eef828b2", - "last_commit": "266b6a2", + "digest": "0d7cbe9cf349fd494cea36df598cbf5a4c97aa969524333c1b67ddb271be85fb", + "last_commit": "ecb7b00", "name": "src", "purpose": "" } ], - "children_root": "sha256:798c2a4462c11753b946a288a72a0217c686580b796e35be2b87a3386cb9740e", - "compiled_at": "2026-10-11T02:47:44Z", + "children_root": "sha256:6ecbe9238675fedfa699fe63d3a9b36e95a93cf0c380aa0e2c9dd456ee49c7e1", + "compiled_at": "2026-10-11T04:00:54Z", "compiler": "crumb-compile/1", - "digest": "sha256:e919bd713c70ecda3dd4b678812e15c67847b8f4f8813e3588fce5d93d2b98ec", + "digest": "sha256:e3127bf29b97d40da109561ad86d1d74e0989f379eeed51741517257bc15d3b1", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "files": 40, - "generated_at_commit": "c1e0af4d37f7f381dd48bdaa6154b9889d37f21a", - "source_tree": "sha256:386d4b5dc1a839d5ce52f3d8f16e02d312b2254706a49149a90b043736a8bc17" + "generated_at_commit": "ecb7b00f13c83a6900f18afb2c3a7d32660a83e9", + "source_tree": "sha256:957017e7747b9408a181e7db9bfa836e3aa560c512da1ec298eed1975b4b3cc8" } }, "history": [ diff --git a/crates/aien-cli/src/.crumb b/crates/aien-cli/src/.crumb index b0a945ea..42d20135 100644 --- a/crates/aien-cli/src/.crumb +++ b/crates/aien-cli/src/.crumb @@ -64,14 +64,14 @@ "generated": { "children": [], "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "compiled_at": "2026-10-11T02:47:44Z", + "compiled_at": "2026-10-11T04:00:54Z", "compiler": "crumb-compile/1", - "digest": "sha256:d2f1dccc8b5c0dc69f3b504558bcc0b31a1eeb955a0dda5ef98cd570eef828b2", + "digest": "sha256:0d7cbe9cf349fd494cea36df598cbf5a4c97aa969524333c1b67ddb271be85fb", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "files": 29, - "generated_at_commit": "c1e0af4d37f7f381dd48bdaa6154b9889d37f21a", - "source_tree": "sha256:27f718e7e92998c40795c907d562082aef202744fb22fea754a07a1085abf1aa" + "generated_at_commit": "ecb7b00f13c83a6900f18afb2c3a7d32660a83e9", + "source_tree": "sha256:a19a681396d82957b581d2e05d8858e8363dfadeafa13e0de5add9ea0a5e1ad2" } }, "history": [ diff --git a/crates/aien-cli/src/commands.rs b/crates/aien-cli/src/commands.rs index 2702cf3e..1bcd62da 100644 --- a/crates/aien-cli/src/commands.rs +++ b/crates/aien-cli/src/commands.rs @@ -1318,6 +1318,20 @@ struct ResidentLoad<'a> { open_session: &'a dyn Fn() -> Result<(), String>, } +/// Plain-English refusal printed by `aien start` when the approval desk key is +/// missing or unusable (sc#414). The desk is mandatory, so this is a refusal, +/// never a warning. `detail` is the runtime's own reason. +pub fn start_refusal_text(detail: &str) -> String { + format!( + "AIEN will not start yet: the approval desk key has not been created. + The desk is how you approve what AIEN is allowed to do, and AIEN refuses to run without it. + Create it once, then start again: + aien compose desk-key --create 1 + aien start + (detail: {detail})" + ) +} + #[cfg(test)] fn load_daemon_model( manifest: DaemonModelManifest, @@ -1874,6 +1888,12 @@ pub async fn handle_start_command() { return; } + // First-run guard (sc#414): the approval desk is mandatory, so refuse here in + // plain words instead of spawning a daemon that exits unseen. + if let Err(detail) = aien_runtime::spine::authorize_desk_at_start_from_env() { + eprintln!("{}", start_refusal_text(&detail).red().bold()); + std::process::exit(1); + } println!( "{}", "⚡ Starting AIEN Sovereign Runtime Machine..." @@ -2174,31 +2194,19 @@ pub async fn handle_cockpit_command() { .spawn(); } +/// `aien harness` is not shipped in this release (sc#414 defect 2). It used to +/// call `spark-harness check`, a subcommand that never existed. The real +/// `spark-harness test` needs data files (workflows.json, evals.json) that the +/// installer does not copy, so nothing real backs this command on an installed +/// machine. It refuses, with a non-zero exit, instead of faking a pass. +pub fn harness_refusal_text() -> &'static str { + "`aien harness` is not shipped in this release, so nothing was checked or certified. \ + Use `aien doctor` to probe this machine." +} + pub async fn handle_harness_command() { - println!( - "{}", - "⚡ Running AIEN 5-Layer Sovereign Harness Sweep..." - .cyan() - .bold() - ); - let status = std::process::Command::new("spark-harness") - .arg("check") - .status(); - match status { - Ok(s) if s.success() => println!( - "{}", - "\n✓ 5-Layer Verification PASS: All invariants certified." - .green() - .bold() - ), - _ => { - println!( - "{}", - "Running comprehensive fallback diagnostic...".yellow() - ); - run_doctor().await; - } - } + eprintln!("{}", harness_refusal_text().red().bold()); + std::process::exit(1); } pub async fn handle_aegis_command() { @@ -2229,6 +2237,21 @@ pub async fn handle_aegis_command() { mod tests { use super::*; + #[test] + fn start_refusal_names_the_exact_command() { + let t = start_refusal_text("no key at /x"); + assert!(t.contains("aien compose desk-key --create 1"), "{t}"); + assert!(t.contains("will not start"), "{t}"); + assert!(t.contains("no key at /x"), "{t}"); + } + + #[test] + fn harness_refuses_plainly_instead_of_faking_a_pass() { + let t = harness_refusal_text(); + assert!(t.contains("not shipped in this release"), "{t}"); + assert!(!t.contains("PASS"), "{t}"); + } + #[test] fn strict_start_line_names_every_protection() { assert_eq!( diff --git a/crates/aien-cli/src/objective.rs b/crates/aien-cli/src/objective.rs index 75959fcf..99bd0380 100644 --- a/crates/aien-cli/src/objective.rs +++ b/crates/aien-cli/src/objective.rs @@ -213,3 +213,22 @@ mod tests { std::env::remove_var("AIEN_PROVENANCE_DIR"); } } + +#[cfg(test)] +mod default_dir_tests { + /// sc#414 defect 3: the CLI and the daemon must derive the same directory, + /// or approval refuses ObjectiveMissing. Both call the one runtime function. + #[test] + fn cli_and_daemon_agree_and_default_is_not_tmp() { + let with = |k: &str| { + if k == "HOME" { + Some("/home/op".to_string()) + } else { + None + } + }; + let root = aien_runtime::objective::provenance_root_with(with); + assert!(!root.starts_with("/tmp"), "{}", root.display()); + assert_eq!(super::dir(), aien_runtime::objective::dir()); + } +} diff --git a/crates/aien-cli/src/tools.rs b/crates/aien-cli/src/tools.rs index c90a6590..e85e55fd 100644 --- a/crates/aien-cli/src/tools.rs +++ b/crates/aien-cli/src/tools.rs @@ -459,9 +459,7 @@ pub(crate) fn record_effect_receipt( "policy": "default_sovereign_engine", "timestamp": chrono::Utc::now().to_rfc3339(), }); - let dir = std::env::var("AIEN_PROVENANCE_DIR") - .map(std::path::PathBuf::from) - .unwrap_or_else(|_| std::path::PathBuf::from("/tmp/aien-provenance")); + let dir = aien_runtime::objective::provenance_root(); if std::fs::create_dir_all(&dir).is_err() { return None; } diff --git a/crates/aien-cli/src/ui.rs b/crates/aien-cli/src/ui.rs index bac164aa..54c9bc30 100644 --- a/crates/aien-cli/src/ui.rs +++ b/crates/aien-cli/src/ui.rs @@ -2,6 +2,15 @@ use crate::telemetry::get_gpu_telemetry; use colored::*; use std::io::{stdout, Write}; +/// Second banner line (sc#414): the runtime is the native Rust daemon. Modular +/// MAX was left on 2026-10-02 and no model seat listens on port 18006 here. +pub fn banner_runtime_line() -> String { + let text = "Grace Blackwell GB10 • Native Rust runtime • Local model, no cloud"; + let inner = 76; + let pad = inner - 2 - text.chars().count(); + format!("│ {text}{}│", " ".repeat(pad)) +} + pub fn print_banner() { println!( "{}", @@ -15,10 +24,7 @@ pub fn print_banner() { .cyan() .bold() ); - println!( - "{}", - "│ Grace Blackwell GB10 • Modular MAX 26.5 • Resident Seat: Port 18006 │".cyan() - ); + println!("{}", banner_runtime_line().cyan()); println!( "{}", "╰────────────────────────────────────────────────────────────────────────────╯" @@ -47,7 +53,7 @@ pub fn print_status_bar() { }; let status = format!( - "[{}] • Seat: atlas-lightning-omni (:18006) • Mask: AIEN • Swarm: aien-hive", + "[{}] • Runtime: native AIEN daemon • Mask: AIEN • Swarm: aien-hive", gpu_status ); println!("{}", status.black().on_cyan().bold()); @@ -99,3 +105,18 @@ pub fn print_safety_prompt(cmd: &str) -> bool { } false } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn banner_describes_native_runtime_not_max() { + let l = banner_runtime_line(); + assert!(l.contains("Native Rust runtime"), "{l}"); + for stale in ["MAX", "26.5", "18006"] { + assert!(!l.contains(stale), "stale banner text {stale}: {l}"); + } + assert_eq!(l.chars().count(), 78, "box width: {l}"); + } +} diff --git a/crates/aien-cli/tests/desk_required_startup_test.rs b/crates/aien-cli/tests/desk_required_startup_test.rs index de9ebdd7..d6adb675 100644 --- a/crates/aien-cli/tests/desk_required_startup_test.rs +++ b/crates/aien-cli/tests/desk_required_startup_test.rs @@ -255,3 +255,41 @@ fn a_failed_check_stops_its_daemon() { "the failed check left daemon(s) {left:?} running" ); } + +/// sc#414 defect 1: `aien start` itself (not just the daemon it spawns) refuses +/// without a desk key, in plain words, naming the exact command, and never +/// leaves a daemon or a socket behind. +#[test] +fn s1_aien_start_without_desk_key_refuses_with_the_command() { + let rig = Rig::new(); + let out = rig + .cmd(false, None) + .arg("start") + .stdin(Stdio::null()) + .output() + .expect("run aien start"); + let all = format!( + "{}{}", + String::from_utf8_lossy(&out.stdout), + String::from_utf8_lossy(&out.stderr) + ); + assert!(!out.status.success(), "start must refuse: {all}"); + assert!(all.contains("AIEN will not start yet"), "{all}"); + assert!(all.contains("aien compose desk-key --create 1"), "{all}"); + assert!(!rig.sock().exists(), "no daemon may be left: {all}"); +} + +/// sc#414 defect 2: `aien harness` refuses with a non-zero exit; it never +/// reports a pass, and never calls the non-existent `spark-harness check`. +#[test] +fn s2_aien_harness_refuses_not_shipped() { + let rig = Rig::new(); + let out = rig.cmd(false, None).arg("harness").output().unwrap(); + let all = format!( + "{}{}", + String::from_utf8_lossy(&out.stdout), + String::from_utf8_lossy(&out.stderr) + ); + assert!(!out.status.success(), "{all}"); + assert!(all.contains("not shipped in this release"), "{all}"); +} diff --git a/crates/aien-runtime/src/objective.rs b/crates/aien-runtime/src/objective.rs index 1d277f71..e1851306 100644 --- a/crates/aien-runtime/src/objective.rs +++ b/crates/aien-runtime/src/objective.rs @@ -1,7 +1,7 @@ //! sovereign-core #408: the operator's objective record, as the daemon reads it. //! //! `aien-cli objective record` (sc#388) writes `objectives/.json` -//! under `AIEN_PROVENANCE_DIR`; the id is sha256 of [`DOMAIN_TAG`], LF, the +//! under the provenance root (`AIEN_PROVENANCE_DIR`, default durable per-user state); the id is sha256 of [`DOMAIN_TAG`], LF, the //! text. The daemon never writes the record. It re-reads it when a grant is //! bound to it (`ComposeAuthorize` with an objective id), before every intent //! on such a grant, and at every reconcile of such an intent, so a record that @@ -24,13 +24,39 @@ pub fn objective_id(text: &str) -> String { sha256_hex(format!("{DOMAIN_TAG}\n{text}").as_bytes()) } -/// `$AIEN_PROVENANCE_DIR/objectives` (default `/tmp/aien-provenance/objectives`), -/// resolved exactly as the CLI resolves it. +/// The provenance root, resolved from a variable lookup (sc#414 defect 3): +/// `$AIEN_PROVENANCE_DIR`, else `$AIEN_RUNTIME_STATE_DIR/provenance`, else +/// `$XDG_STATE_HOME/aien-runtime/provenance`, else +/// `$HOME/.local/state/aien-runtime/provenance`, the same order as the compose +/// home (`spine::compose_dir_from_env`). Never /tmp: a record that vanishes at +/// reboot is not a durable record. With none of those set (no HOME at all), the +/// absolute `/var/lib/aien-runtime/provenance`, so daemon and CLI still agree. +pub fn provenance_root_with(get: impl Fn(&str) -> Option) -> PathBuf { + let get = |k: &str| get(k).filter(|v| !v.trim().is_empty()); + if let Some(d) = get("AIEN_PROVENANCE_DIR") { + return PathBuf::from(d.trim()); + } + if let Some(d) = get("AIEN_RUNTIME_STATE_DIR") { + return PathBuf::from(d.trim()).join("provenance"); + } + if let Some(d) = get("XDG_STATE_HOME") { + return PathBuf::from(d.trim()).join("aien-runtime/provenance"); + } + if let Some(h) = get("HOME") { + return PathBuf::from(h.trim()).join(".local/state/aien-runtime/provenance"); + } + PathBuf::from("/var/lib/aien-runtime/provenance") +} + +/// [`provenance_root_with`] over the process environment. The daemon, the CLI +/// and the effect receipts all call this one function. +pub fn provenance_root() -> PathBuf { + provenance_root_with(|k| std::env::var(k).ok()) +} + +/// `/objectives`, resolved exactly as the CLI resolves it. pub fn dir() -> PathBuf { - std::env::var("AIEN_PROVENANCE_DIR") - .map(PathBuf::from) - .unwrap_or_else(|_| PathBuf::from("/tmp/aien-provenance")) - .join("objectives") + provenance_root().join("objectives") } pub fn valid_id(id: &str) -> bool { @@ -107,6 +133,55 @@ pub fn check(id: &str, text_sha256: &str) -> Result { mod tests { use super::*; + fn env(pairs: &[(&str, &str)]) -> impl Fn(&str) -> Option { + let m: std::collections::HashMap = pairs + .iter() + .map(|(k, v)| (k.to_string(), v.to_string())) + .collect(); + move |k| m.get(k).cloned() + } + + #[test] + fn provenance_default_is_durable_and_never_tmp() { + let home = provenance_root_with(env(&[("HOME", "/home/u")])); + assert_eq!( + home, + PathBuf::from("/home/u/.local/state/aien-runtime/provenance") + ); + for p in [ + home, + provenance_root_with(env(&[])), + provenance_root_with(env(&[("XDG_STATE_HOME", "/x")])), + provenance_root_with(env(&[("AIEN_RUNTIME_STATE_DIR", "/s")])), + ] { + assert!(!p.starts_with("/tmp"), "{}", p.display()); + } + } + + #[test] + fn provenance_follows_the_compose_home_order_and_override_wins() { + let all = [ + ("AIEN_PROVENANCE_DIR", "/p"), + ("AIEN_RUNTIME_STATE_DIR", "/s"), + ("XDG_STATE_HOME", "/x"), + ("HOME", "/h"), + ]; + assert_eq!(provenance_root_with(env(&all)), PathBuf::from("/p")); + assert_eq!( + provenance_root_with(env(&all[1..])), + PathBuf::from("/s/provenance") + ); + assert_eq!( + provenance_root_with(env(&all[2..])), + PathBuf::from("/x/aien-runtime/provenance") + ); + // An empty override is not an override. + assert_eq!( + provenance_root_with(env(&[("AIEN_PROVENANCE_DIR", " "), ("HOME", "/h")])), + PathBuf::from("/h/.local/state/aien-runtime/provenance") + ); + } + #[test] fn id_is_the_cli_formula() { // sha256("AIEN_E2E_OBJECTIVE_V1\nx"), the sc#388 definition.