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#574 (code only)
Apply it
git checkout -b patch-7508823c26db759f e8cc3aa023552be081c4e05310d66135f1daba30 curl -fsSL https://interplane.io/drakestapleton/aien-sovereign-core-mv/patches/7508823c26db759f.patch | git am
Provenance
github-import 1
aien-dev/aien-sovereign-core-mv
574
81f931e7a66ac237c4cbf61871bc1a4ee25aa536
{"kind":"github-import","owner":"aien-dev","repo":"aien-sovereign-core-mv","number":574,"url":"https://github.com/aien-dev/aien-sovereign-core-mv/pull/574","export_sha256":"967c79e26a893657b5cdaa45efd442be5dbd2ecfe68e25f9a8c1b5da4d60d452","imported_utc":"2026-11-18T16:37:33Z","metadata":"unavailable","state_derived":true}
Changes
diff --git a/.crumb b/.crumb index ca888b85..dee34151 100644 --- a/.crumb +++ b/.crumb @@ -65,43 +65,43 @@ "children": [ { "digest": "e5a81587d398cafcc737337c51428c09697768967eea61386a6ab34f7f871903", - "last_commit": "20877670", + "last_commit": "e8cc3aa0", "name": "crates/aien-allen", "purpose": "ALLEN identity gate: resolve-only subject check, host pin record, deployment record (ADR 0035). " }, { "digest": "a6f60499665540ddd49ad3122d016232b15d9cc878cb68febb725cd711dfbb6d", - "last_commit": "20877670", + "last_commit": "e8cc3aa0", "name": "crates/aien-allen-memory", "purpose": "ALLEN scoped memory store: scopes enforced at recall, inspect/correct/export, key-destroying for" }, { "digest": "3b65ec8698bac001b1d2aef39c1fce13a3475280186147af40a319212ed76d42", - "last_commit": "20877670", + "last_commit": "e8cc3aa0", "name": "crates/aien-allen-profile", "purpose": "ALLEN persona profile v1: versioned, user-editable profile bound to the engaged ALLEN identity; " }, { "digest": "73b7b51a60981ac052f28b05a50071fb6846e6c3f7331d28786d220733f204c7", - "last_commit": "20877670", + "last_commit": "e8cc3aa0", "name": "crates/aien-cli", "purpose": "" }, { "digest": "246e54412a28d811dc38af14bb943890fbafd85f55864c2468a04e6ea698062e", - "last_commit": "20877670", + "last_commit": "e8cc3aa0", "name": "crates/aien-scheduler/src/bin", "purpose": "" }, { "digest": "34d1c3a8c38c4f75d9eca8e73f6d15418f2ffc3d129f99813d7adf9e80902659", - "last_commit": "20877670", + "last_commit": "e8cc3aa0", "name": "crates/spark-cockpit-rs", "purpose": "" }, { "digest": "20f3120e6d2067007c8e67dfd13a821a83f5a382e7e11a0eec22f2d9b6380971", - "last_commit": "20877670", + "last_commit": "e8cc3aa0", "name": "scripts", "purpose": "" }, @@ -113,20 +113,20 @@ }, { "digest": "598dc3bd4d60f47f79ccb3b42d5966be1ba921fdbb24f347ef6c998463a4da3a", - "last_commit": "20877670", + "last_commit": "e8cc3aa0", "name": "tools/aien-local-ci", "purpose": "Local CI sandbox exec contract (C8), aien-run user/caches install, Forgejo trigger hook, health " } ], "children_root": "sha256:0d89f72950a8f4e92fd5b1f360e7092d0b0fb9c28ff362b954b98c44cc053be4", - "compiled_at": "2026-10-24T04:21:21Z", + "compiled_at": "2026-10-24T04:35:32Z", "compiler": "crumb-compile/1", - "digest": "sha256:3b49c0a02cd350da72ac4576403a4ef924c11a4f4e238f165ac9b09806c979af", + "digest": "sha256:982dbd264f58257ab95aff2bc291e338f8268d6590569ed4edb3ce55a1e0047f", "evidence_files": 1578, "evidence_root": "sha256:301c3ce7bca14655fc023095434f2d2942ebdfa9b30d5757d88343925d633a4d", "files": 5898, - "generated_at_commit": "358b7c2e23adb910f23fe4a1ed58981a9c401f72", - "source_tree": "sha256:303a5f99ad9ca6d260b8ad3d74a0d9e59dac0a49757e52c6185e4219fa6814a7" + "generated_at_commit": "26f8a6c5b04e317afd934331d10087056c273386", + "source_tree": "sha256:9cc22f464161318e0ede046c4a1765eabbf9154d0b1a54de26d4e54ac70ae455" } }, "history": [], diff --git a/tools/aien-test/docs/LOCAL_VERIFICATION.md b/tools/aien-test/docs/LOCAL_VERIFICATION.md index b51f5b9c..dfb19791 100644 --- a/tools/aien-test/docs/LOCAL_VERIFICATION.md +++ b/tools/aien-test/docs/LOCAL_VERIFICATION.md @@ -255,9 +255,11 @@ The one rule: commit runs again with every sibling at the same commit; a sibling that moved runs every gate fresh. A declared sibling that cannot be made turns the cache off for the head (`no_cache`). Results are never reused across - commits in the worker: gates read files they do not declare as `inputs` - (SC-TEST reads the root `README.md` and `COVENANT.md`), so a key built - from declared inputs alone could hand a commit another commit's PASS. + commits, in the worker or in a direct `aien-test run`: gates read files + they do not declare as `inputs` (SC-TEST reads the root `README.md` and + `COVENANT.md`), so a key built from declared inputs alone could hand a + commit another commit's PASS. A receipt stands only for the commit it was + made at; `why` reports such a receipt as "made at another commit". `wt.sh remove` takes the whole run directory away (checkout and siblings) and prunes every mirror's worktree list. An older `wt.sh` that still makes diff --git a/tools/aien-test/src/cache.rs b/tools/aien-test/src/cache.rs index 6a2e00cb..317bfb74 100644 --- a/tools/aien-test/src/cache.rs +++ b/tools/aien-test/src/cache.rs @@ -26,10 +26,17 @@ //! receipts themselves: every receipt already carries `volatile.cache.key`, //! so a separate `index.jsonl` would only be a second copy that could drift. //! +//! A result is reused only for the same commit it was made at (sc#517). The +//! key covers a gate's declared inputs, but a gate may read files it did not +//! declare (SC-TEST reads README.md and COVENANT.md and searches the tree), +//! so an older commit's PASS could stand in for a commit that would fail. +//! Direct runs now follow the worker's rule: same commit, same pins, or the +//! gate runs again. Cross-commit reuse returns only once every gate's inputs +//! are proven complete (ADR 0028 cache key). +//! //! Choices where the ADR is silent or contradicts itself (recorded in the PR): -//! - A reused receipt is the source receipt's `core` with one change: its -//! `commit` is the commit being checked. The ADR says "identical core" and -//! also "records that this commit was checked"; both cannot hold, and +//! - A reused receipt is the source receipt's `core` with its `commit` set to +//! the commit being checked (the same commit, since reuse is bound to it). //! `why`, `run` and the dependency lookups all match receipts by commit. //! - Dependencies enter the key as receipt digests, resolved to the original //! fresh receipt when the dependency itself was reused. Without that step a @@ -167,6 +174,9 @@ pub enum Unusable { UncleanTree, /// HEAD moved during the run. HeadMoved, + /// It was made at another commit; a result stands only for its own + /// commit (sc#517). + OtherCommit, /// The run went past its time limit. TimedOut, /// The key written in the receipt is not what its own contents hash to. @@ -186,6 +196,9 @@ impl Unusable { Unusable::NotAnExperiment => "its verdict is not PASS or FAIL", Unusable::UncleanTree => "the tree had uncommitted changes when it ran", Unusable::HeadMoved => "HEAD moved while it ran", + Unusable::OtherCommit => { + "it was made at another commit (a result stands only for its own commit)" + } Unusable::TimedOut => "it ran past its time limit", Unusable::KeyMismatch => "its recorded key does not match its own contents", Unusable::MachineMismatch => "its machine descriptor does not match its machine digest", @@ -195,19 +208,23 @@ impl Unusable { } } -/// May `src` (which carries `key`) stand in for a run now? Fail closed: the -/// first problem found makes it unusable. +/// May `src` (which carries `key`) stand in for a run at `commit` now? Fail +/// closed: the first problem found makes it unusable. pub fn usable( src: &Stored, key: &str, index: &Index, store: &Store, env: &Value, + commit: &str, ) -> Result<(), Unusable> { let (core, vol) = (&src.value["core"], &src.value["volatile"]); if vol["cache"]["reused"] != false { return Err(Unusable::AlreadyReused); } + if src.commit() != commit { + return Err(Unusable::OtherCommit); + } if !matches!(src.verdict(), Some(Verdict::Pass | Verdict::Fail)) { return Err(Unusable::NotAnExperiment); } @@ -270,14 +287,21 @@ pub enum Lookup<'a> { Miss(Miss), } -/// The newest usable fresh receipt whose `cache.key` is `key`. -pub fn lookup<'a>(index: &'a Index, store: &Store, key: &str, env: &Value) -> Lookup<'a> { +/// The newest usable fresh receipt whose `cache.key` is `key`, made at +/// `commit`. +pub fn lookup<'a>( + index: &'a Index, + store: &Store, + key: &str, + env: &Value, + commit: &str, +) -> Lookup<'a> { let mut first_rejection: Option<Miss> = None; for r in index.receipts().iter().rev() { if r.value["volatile"]["cache"]["key"] != key { continue; } - match usable(r, key, index, store, env) { + match usable(r, key, index, store, env, commit) { Ok(()) => return Lookup::Hit(r), Err(why) => { first_rejection.get_or_insert(Miss::Unusable { @@ -422,7 +446,7 @@ pub fn explain_chain( }; match key(&now, index) { Err(e) => lines.push(format!("cache: miss, cannot build the key ({e})")), - Ok(k) => match lookup(index, &store, &k, &env) { + Ok(k) => match lookup(index, &store, &k, &env, commit) { Lookup::Hit(src) => { lines.push(format!( "cache: hit, a run would reuse receipt {} ({}, made at commit {}); key {}", @@ -614,17 +638,21 @@ mod tests { } #[test] - fn reuse_across_commits_records_the_commit_that_was_checked() { + fn a_result_is_bound_to_its_commit_and_never_reused_for_another() { + // sc#517: the key covers only declared inputs, and a gate may read + // files it did not declare, so an older commit's PASS must not stand + // in for a new commit even when every declared input is unchanged. let fx = Fx::new(SCRIPT); let first = fresh_pass(&fx); let old_head = fx.head(); - // A change to a file the gate does not depend on. + // A change to a file the gate does not declare. fx.commit("README", "changed\n"); assert_ne!(fx.head(), old_head); let second = fx.run(&fx.opts()); - assert_eq!(reused_from(&second), first.receipt_digest.as_deref()); - assert_eq!(fx.runs("a"), 1); - let (mut c1, mut c2) = ( + assert_eq!(reused_from(&second), None, "no reuse across commits"); + assert_eq!(second.verdict, Verdict::Pass); + assert_eq!(fx.runs("a"), 2, "the gate ran again at the new commit"); + let (c1, c2) = ( fx.receipt(&first)["core"].clone(), fx.receipt(&second)["core"].clone(), ); @@ -632,11 +660,19 @@ mod tests { assert_eq!( c2["commit"], fx.head(), - "the reuse receipt is for this commit" + "the fresh receipt is for this commit" + ); + // The same key, so only the commit rule kept the second run fresh. + let r1 = fx.receipt(&first); + let r2 = fx.receipt(&second); + assert_eq!( + r1["volatile"]["cache"]["key"], + r2["volatile"]["cache"]["key"] ); - c1["commit"] = Value::Null; - c2["commit"] = Value::Null; - assert_eq!(c1, c2, "everything else in core is the source's"); + // Back at the new commit a third run reuses the second (same commit). + let third = fx.run(&fx.opts()); + assert_eq!(reused_from(&third), second.receipt_digest.as_deref()); + assert_eq!(fx.runs("a"), 2); } #[test] @@ -939,24 +975,29 @@ mod tests { } #[test] - fn a_change_under_a_dependency_reruns_it_and_everything_that_rests_on_it() { + fn a_new_commit_reruns_the_whole_chain_and_the_same_commit_reuses_it() { + // sc#517: a result stands only for its own commit, so any new commit + // reruns every gate, whatever its declared inputs did. Within one + // commit the chain is reused as a whole. let fx = two_gate_fixture(); run_all(&fx, &fx.opts()); - // Gate A's own input (data/ is shared by both gates here, so give B a - // different one first to see that only the chain moves). let b = gate_text("C-B", &["C-A"], &fx.counter("b"), "").replace("data/", "other/"); fx.commit("other/x.txt", "x\n"); fx.commit("tests/b.gate", &b); - run_all(&fx, &fx.opts()); - assert_eq!((fx.runs("a"), fx.runs("b")), (1, 2), "only B changed"); - fx.commit("data/in.txt", "two\n"); let after = run_all(&fx, &fx.opts()); assert!(after.values().all(|o| reused_from(o).is_none())); assert_eq!( (fx.runs("a"), fx.runs("b")), - (2, 3), - "A changed, so B reruns too" + (2, 2), + "a new commit: A reruns although its declared inputs are unchanged, and B with it" ); + let again = run_all(&fx, &fx.opts()); + assert!(again.values().all(|o| reused_from(o).is_some())); + assert_eq!((fx.runs("a"), fx.runs("b")), (2, 2), "same commit: reused"); + fx.commit("data/in.txt", "two\n"); + let after = run_all(&fx, &fx.opts()); + assert!(after.values().all(|o| reused_from(o).is_none())); + assert_eq!((fx.runs("a"), fx.runs("b")), (3, 3)); } // ---- the key itself ------------------------------------------------- @@ -1053,7 +1094,8 @@ mod tests { let store = Store::new(dir.path()); let index = Index::load(&store); let k = original["volatile"]["cache"]["key"].as_str().unwrap(); - match lookup(&index, &store, k, &runner::captured_env()) { + let commit = original["core"]["commit"].as_str().unwrap(); + match lookup(&index, &store, k, &runner::captured_env(), commit) { Lookup::Hit(_) => Err(()), Lookup::Miss(Miss::Unusable { why, .. }) => Ok(why), Lookup::Miss(Miss::NoReceipt) => panic!("the forged receipt must be found by its key"), @@ -1167,13 +1209,18 @@ mod tests { "{before}" ); let first = fresh_pass(&fx); - fx.commit("README", "changed\n"); let hit = why_lines(&fx); assert!(hit.contains("cache: hit"), "{hit}"); assert!( hit.contains(&first.receipt_digest.clone().unwrap()[..12]), "{hit}" ); + // sc#517: a new commit is a miss even when no declared input changed. + fx.commit("README", "changed\n"); + let other = why_lines(&fx); + assert!(other.contains("cache: miss"), "{other}"); + assert!(other.contains("made at another commit"), "{other}"); + assert!(!other.contains("these changed"), "{other}"); fx.commit("data/in.txt", "two\n"); let miss = why_lines(&fx); assert!(miss.contains("cache: miss"), "{miss}"); @@ -1202,7 +1249,7 @@ mod tests { fn why_for_a_dependent_follows_a_reused_dependency() { let fx = two_gate_fixture(); run_all(&fx, &fx.opts()); - fx.commit("README", "changed\n"); + // Same commit: B's dependency A is a hit, so B is one too. let g = graph::load(fx.repo.path()).unwrap(); let index = Index::load(&fx.store()); let b = g.index_of("C-B").unwrap(); diff --git a/tools/aien-test/src/plan.rs b/tools/aien-test/src/plan.rs index 7b3323b1..9bc9c36c 100644 --- a/tools/aien-test/src/plan.rs +++ b/tools/aien-test/src/plan.rs @@ -858,6 +858,11 @@ pub fn probe_cached(root: &Path, graph: &Graph, opts: &crate::runner::Options) - let env = crate::runner::captured_env(); let mut stands_on: BTreeMap<usize, Option<String>> = BTreeMap::new(); let mut out = BTreeSet::new(); + // A result stands only for its own commit (sc#517); without a head + // nothing is cached. + let Ok(head) = crate::runner::head(root) else { + return out; + }; for &i in graph.order() { let node = graph.node(i); let m = &node.manifest; @@ -892,7 +897,7 @@ pub fn probe_cached(root: &Path, graph: &Graph, opts: &crate::runner::Options) - args_override: None, }; if let Ok(k) = cache::key(&now, &index) { - if let Lookup::Hit(src) = cache::lookup(&index, &store, &k, &env) { + if let Lookup::Hit(src) = cache::lookup(&index, &store, &k, &env, &head) { if src.verdict() == Some(Verdict::Pass) { reuse = Some(src.digest.clone()); out.insert(node.id.clone()); diff --git a/tools/aien-test/src/runner.rs b/tools/aien-test/src/runner.rs index 796de254..e4ba52c3 100644 --- a/tools/aien-test/src/runner.rs +++ b/tools/aien-test/src/runner.rs @@ -656,7 +656,7 @@ fn execute_gate(job: &Job<'_>, permit: Option<Permit<'_>>) -> Result<Outcome, Ru // verdict or a dependency that is not PASS is reported as it is, never // hidden behind an old result. if mode == cache::Mode::Allow && !evidence_inside && verdict::pre_run(m, &facts).is_none() { - match cache::lookup(&index, &store, &cache_key, &captured_env()) { + match cache::lookup(&index, &store, &cache_key, &captured_env(), &commit) { cache::Lookup::Hit(src) => { let reused_verdict = src .verdict()