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/9923f3e6011f88b1 # 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#324 (code only) closed derived `9923f3e6011f88b1` #324 Imported from GitHub aien-dev/aien-sovereign-core-mv#324 (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 `61c14e41b9dce2288d72169df09ea6a49498dc7c` · Head `8310b3cf6080502f9a13cdbcbcba0d8ad8a6e6df` ### Apply it ``` git checkout -b patch-9923f3e6011f88b1 61c14e41b9dce2288d72169df09ea6a49498dc7c curl -fsSL https://interplane.io/drakestapleton/aien-sovereign-core-mv/patches/9923f3e6011f88b1.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 324 8310b3cf6080502f9a13cdbcbcba0d8ad8a6e6df ``` ``` {"kind":"github-import","owner":"aien-dev","repo":"aien-sovereign-core-mv","number":324,"url":"https://github.com/aien-dev/aien-sovereign-core-mv/pull/324","export_sha256":"967c79e26a893657b5cdaa45efd442be5dbd2ecfe68e25f9a8c1b5da4d60d452","imported_utc":"2026-11-18T16:36:49Z","metadata":"unavailable","state_derived":true} ``` ### Changes ``` diff --git a/.crumb b/.crumb index 695dc7a5..16fd224c 100644 --- a/.crumb +++ b/.crumb @@ -64,8 +64,8 @@ "generated": { "children": [ { - "digest": "1b6bb256df0b08254396253e0871c19328e2d10e183cf1ef5dbb4d19442b742f", - "last_commit": "6bbe2ec", + "digest": "74a477db88f9514eddafa944edf5fcb54c121c0fdba97b24980362a056e6dea6", + "last_commit": "fb9c2c4", "name": "scripts", "purpose": "" }, @@ -76,15 +76,15 @@ "purpose": "" } ], - "children_root": "sha256:8926a40020c57d1317c07e2a0e7cd5b5eee5a7a09baf2e9a7923e85b766e0b7d", - "compiled_at": "2026-10-08T12:29:05Z", + "children_root": "sha256:c4df3d1702ee8c25a0fe7eb9a108f29afc2f07485c611250594e9f4a542d9052", + "compiled_at": "2026-10-08T12:46:30Z", "compiler": "crumb-compile/1", - "digest": "sha256:94647b7ff27f34ec14b9874851bc03be091440e66af8c28eb12500421a860316", + "digest": "sha256:cfd44c2a4d1a61a84cf08605af0f80ca485adddaf68ca4fdbc144f422c78281e", "evidence_files": 187, "evidence_root": "sha256:27ee0353cb4d4aae2b7dbce2bfe0d9f4ef2a94cd7a4555b84684d59372503280", "files": 1533, - "generated_at_commit": "2dfa118965e2210badb9755c2e5b64605c22279f", - "source_tree": "sha256:a3c1a838a3789286ab77c0c5475ac4a43eaa0c7696f9951943f00b77123af123" + "generated_at_commit": "fb9c2c4440cd756d547f37730749abda43dbfe91", + "source_tree": "sha256:c9962a1e0ba7ebc579abf65366e7a9c9ec2098803ada351e475051870d3a3de5" } }, "history": [], diff --git a/crates/aien-runtime/src/effects.rs b/crates/aien-runtime/src/effects.rs index 53cb8601..870dd05d 100644 --- a/crates/aien-runtime/src/effects.rs +++ b/crates/aien-runtime/src/effects.rs @@ -751,6 +751,13 @@ pub fn check_reserved_note(kind: &str, text: &str) -> Result<(), String> { "ComposeNote: effect records with a \"phase\" are written only by the effect commands" .into(), ), + // sovereign-core #323: a phase-less `write_file` note spends its + // authorization (NEXT-PHASE-1 journals, still read). No caller writes + // a new one: it would block a live grant and void its revoke. + "effect" if v.get("tool").and_then(Value::as_str) == Some("write_file") => Err( + "ComposeNote: write_file effect records are written only by the effect commands (a NEXT-PHASE-1 spend note is never accepted from a caller)" + .into(), + ), // sovereign-core #249: approved-submission replay records come only from // crate::approved_replay. "effect" if v.get(crate::approved_replay::FIELD).is_some() => Err( @@ -2775,6 +2782,17 @@ mod tests { #[test] fn reserved_records_cannot_be_forged_through_compose_note() { assert!(check_reserved_note("effect", r#"{"phase":"ack","intent":3}"#).is_err()); + // #323: the NEXT-PHASE-1 spend note, with or without an authorization. + let legacy = r#"{"tool":"write_file","authorization":2,"success":true}"#; + assert!(check_reserved_note("effect", legacy).is_err()); + assert!(check_reserved_note("effect", r#"{"tool":"write_file"}"#).is_err()); + // The ledger still reads one from an old journal. + let l = Ledger::from_records(&[ + grant(2, Value::Null), + rec(3, "effect", serde_json::from_str(legacy).unwrap()), + ]) + .unwrap(); + assert_eq!(l.legacy_spent.get(&2), Some(&3)); assert!(check_reserved_note("authorization", r#"{"control":"resume"}"#).is_err()); assert!(check_reserved_note("effect", r#"{"tool":"inspect"}"#).is_ok()); assert!(check_reserved_note("constraint", "plain text").is_ok()); diff --git a/crates/aien-runtime/tests/minted_grant_test.rs b/crates/aien-runtime/tests/minted_grant_test.rs index 4c3afc86..f4ede91f 100644 --- a/crates/aien-runtime/tests/minted_grant_test.rs +++ b/crates/aien-runtime/tests/minted_grant_test.rs @@ -456,3 +456,95 @@ linked_test!( assert!(!fx.ws.join("NOTES.md").exists()); } ); + +// sovereign-core #323: the NEXT-PHASE-1 effect note (`write_file`, an +// authorization id, no `phase`) spends its authorization in the ledger. Only +// old journals carry it; the daemon writes no such note since NEXT-PHASE-2. +fn legacy_spend(a: u64) -> String { + json!({"tool": "write_file", "authorization": a, "success": true}).to_string() +} + +// Before the fix a caller of ComposeNote could write one naming a live minted +// grant: that grant then refused to execute (AlreadySpent) and a revoke of it +// recorded nothing. A denial, never a second effect, but a forged record all +// the same. +linked_test!(a_caller_cannot_write_a_legacy_spend_note, |fx| { + let g = noted(fx.mint()).id; + let e = refusal( + fx.b.note("effect", &legacy_spend(g), &[]), + "legacy spend note", + ); + assert!(e.contains("write_file"), "{e}"); + // Not even for an id that is no grant (yet). + refusal( + fx.b.note("effect", &legacy_spend(g + 1000), &[]), + "legacy note, future id", + ); + // The grant is untouched: it still executes once. + let i = noted(fx.open(g)).id; + std::fs::write(fx.target(), CONTENT).unwrap(); + assert_eq!(fx.ack_state(i), "DONE"); + // Other caller effect notes are still accepted. + noted(fx.b.note("effect", r#"{"tool":"inspect"}"#, &[])); +}); + +// An old journal that already holds such a note is still read the same way. +linked_test!(an_old_legacy_spend_note_still_spends_its_grant, |fx| { + let g = noted(fx.mint()).id; + noted(fx.b.note_unchecked("effect", &legacy_spend(g), &[])); + let e = refusal(fx.open(g), "grant spent by an old note"); + assert!( + e.contains("AlreadySpent") && e.contains("NEXT-PHASE-1"), + "{e}" + ); + let c = controlled(effects::control(&fx.b, "revoke", "drake", Some(g))); + assert_eq!(c.revoked, Some(false)); + assert!(!Path::new(&fx.target()).exists()); +}); + +// Pin: a legacy note can never hide a DONE effect from the authorize step. +// Every effect has an intent, and the intent is judged first; a legacy mark, +// a stop, a resume or a revoke afterwards changes nothing. +linked_test!( + a_legacy_note_never_lets_a_done_commit_be_authorized_again, + |fx| { + let g = noted(fx.mint()).id; + let i = noted(fx.open(g)).id; + std::fs::write(fx.target(), CONTENT).unwrap(); + assert_eq!(fx.ack_state(i), "DONE"); + noted(fx.b.note_unchecked("effect", &legacy_spend(g), &[])); + let done = |what: &str| { + let e = refusal(fx.mint(), what); + assert!( + e.contains("AlreadySpent") && e.contains("settled DONE"), + "{what}: {e}" + ); + }; + done("after a legacy mark"); + controlled(effects::control(&fx.b, "stop", "drake", None)); + controlled(effects::control(&fx.b, "resume", "drake", None)); + done("after a legacy mark, stop and resume"); + controlled(effects::control(&fx.b, "revoke", "drake", Some(g))); + done("after a legacy mark and revoke"); + assert!(refusal(fx.open(g), "replay").contains("AlreadySpent")); + } +); + +// A grant marked spent by an old note that never executed, then stopped: one +// new grant may mint (nothing was written), and it gives the one effect. +linked_test!( + a_legacy_marked_unexecuted_grant_still_allows_exactly_one_effect, + |fx| { + let g = noted(fx.mint()).id; + noted(fx.b.note_unchecked("effect", &legacy_spend(g), &[])); + controlled(effects::control(&fx.b, "stop", "drake", None)); + controlled(effects::control(&fx.b, "resume", "drake", None)); + let g2 = noted(fx.mint()).id; + assert!(refusal(fx.open(g), "the legacy-marked grant").contains("AlreadySpent")); + let i = noted(fx.open(g2)).id; + std::fs::write(fx.target(), CONTENT).unwrap(); + assert_eq!(fx.ack_state(i), "DONE"); + let e = refusal(fx.mint(), "a third grant"); + assert!(e.contains("AlreadySpent"), "{e}"); + } +); diff --git a/scripts/.crumb b/scripts/.crumb index 16cb0f50..7aa5f548 100644 --- a/scripts/.crumb +++ b/scripts/.crumb @@ -4,14 +4,14 @@ "generated": { "children": [], "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "compiled_at": "2026-10-08T07:05:20Z", + "compiled_at": "2026-10-08T12:46:30Z", "compiler": "crumb-compile/1", - "digest": "sha256:1b6bb256df0b08254396253e0871c19328e2d10e183cf1ef5dbb4d19442b742f", + "digest": "sha256:74a477db88f9514eddafa944edf5fcb54c121c0fdba97b24980362a056e6dea6", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "files": 26, - "generated_at_commit": "4a95c80468c2741e87abcb89419931e79407d7f3", - "source_tree": "sha256:3917ca995ef7695ddc50b44d425ccfb092b5634beecd87ba44d9af0dc2b30b20" + "generated_at_commit": "fb9c2c4440cd756d547f37730749abda43dbfe91", + "source_tree": "sha256:df1592ba8b677a857115865bd5fbed1af5294f6e91e12c8f86901449e82c8a77" } }, "parent": { diff --git a/scripts/test-linked-compose.sh b/scripts/test-linked-compose.sh index 08c0a372..a37ea464 100755 --- a/scripts/test-linked-compose.sh +++ b/scripts/test-linked-compose.sh @@ -26,21 +26,44 @@ export AIEN_OMEGA_COMPOSE_DIR="$OMW" AIEN_PHYSICS_DIR="$PHW" AIEN_AIENOS_LOCK_RE unset AIEN_OMEGA_DIR AIEN_OMEGA_GPU_LIB AIEN_OMEGA_COMPOSE_LIB AIEN_OMEGA_COMPOSE_SHA AIEN_FORCE_CPU_STUB AIEN_DEV_FALLBACK cd "$ROOT" LOG=$(mktemp); trap 'rm -f "$LOG"' EXIT -run() { # run a test target with --include-ignored; the tests are serial (one process-wide compose home) +run() { # run test targets with --include-ignored; the tests are serial (one process-wide compose home) cargo test "$@" -- --include-ignored --test-threads=1 2>&1 | tee -a "$LOG" } +count() { # how many tests the targets hold, ignored ones included + cargo test "$@" -- --list --include-ignored 2>/dev/null | grep -c ": test$" || true +} +# Every aien-runtime test target, discovered from the directory so a new one is gated +# automatically (sovereign-core #323: minted_grant_test, refusal_table_test and the rest +# were linked-only and outside this gate). Left out, each needing what CI does not have: +# prefill_e2e0/1/2 a real TinyLlama checkpoint (AIEN_E2E_CHECKPOINT). +# aien-cli: compose_ordinary_flow_test and allen_concurrency_test (sc#325, real daemon + CLI, +# no model) are gated. Outside this gate, in other crates: aien-cli recovery_matrix_test and +# provenance_link_live_test (a real SmolLM2 on disk, minutes of CPU per case; run on the +# Spark, receipts on the PR), and the GB10/real-checkpoint inference tests (heavy queue). +RT=() # 46 targets on 2026-10-08; the floor below catches a lost glob or a deleted target +for f in "$ROOT"/crates/aien-runtime/tests/*.rs; do + t=$(basename "$f" .rs) + case "$t" in prefill_e2e*) continue ;; esac + RT+=(--test "$t") +done +[ "${#RT[@]}" -ge 90 ] || die "found only $((${#RT[@]} / 2)) aien-runtime test targets" +CLI=(--test compose_ordinary_flow_test --test allen_concurrency_test) +ATT=$(count -p aien-runtime --test approved_attacks_test) +ALL=$(( $(count -p aien-omega-compose --test compose) + $(count -p aien-runtime "${RT[@]}") + $(count -p aien-cli "${CLI[@]}") )) +[ "$ATT" -gt 0 ] && [ "$ALL" -gt "$ATT" ] || die "could not list the linked tests" : >"$LOG" -# The floor comes from the suite itself, not a hardcoded number. -SUITE=$(cargo test -p aien-runtime --test approved_attacks_test -- --list --include-ignored 2>/dev/null | grep -c ": test$" || true) -[ "$SUITE" -gt 0 ] || die "could not list the approved_attacks tests" run -p aien-omega-compose --test compose -for i in $(seq "$REPEAT"); do +run -p aien-runtime "${RT[@]}" +run -p aien-cli "${CLI[@]}" +# The approved_attacks suite again (it once hid a race, #306): REPEAT runs in all. +for i in $(seq 2 "$REPEAT"); do echo "== approved_attacks run $i/$REPEAT" run -p aien-runtime --test approved_attacks_test done # Not vacuous: the library was linked (no stub warning) and the tests really ran. if grep -q "building the stub" "$LOG"; then die "a stub was built: the composition library is not linked"; fi +want=$(( ALL + ATT * (REPEAT - 1) )) ran=$(grep -E '^test result: ok\. [0-9]+ passed' "$LOG" | awk '{s += $4} END {print s + 0}') -[ "$ran" -ge $((SUITE * REPEAT)) ] || die "only $ran linked tests passed (expected at least $((SUITE * REPEAT)): $SUITE approved_attacks tests x $REPEAT)" +[ "$ran" -ge "$want" ] || die "only $ran linked tests passed (expected $want: $ALL linked tests + approved_attacks $ATT x $((REPEAT - 1)) more)" if grep -E '^test result:.* [1-9][0-9]* ignored' "$LOG" >/dev/null; then die "tests were still ignored"; fi -echo "test-linked-compose: PASS ($ran linked tests passed, approved_attacks x$REPEAT)" +echo "test-linked-compose: PASS ($ran linked tests passed: $ALL across compose, every aien-runtime target but prefill_e2e*, aien-cli ordinary flow + ALLEN concurrency; approved_attacks x$REPEAT)" ```