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/b9f57c69951d3075 # 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#404 (code only) closed derived `b9f57c69951d3075` #404 Imported from GitHub aien-dev/aien-sovereign-core-mv#404 (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 `479b1c9595e68d9909d06dd64d867fe3c72f18b5` · Head `15e97452bde5cd08e78ade606296c134731980c9` ### Apply it ``` git checkout -b patch-b9f57c69951d3075 479b1c9595e68d9909d06dd64d867fe3c72f18b5 curl -fsSL https://interplane.io/drakestapleton/aien-sovereign-core-mv/patches/b9f57c69951d3075.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 404 15e97452bde5cd08e78ade606296c134731980c9 ``` ``` {"kind":"github-import","owner":"aien-dev","repo":"aien-sovereign-core-mv","number":404,"url":"https://github.com/aien-dev/aien-sovereign-core-mv/pull/404","export_sha256":"967c79e26a893657b5cdaa45efd442be5dbd2ecfe68e25f9a8c1b5da4d60d452","imported_utc":"2026-11-18T16:37:05Z","metadata":"unavailable","state_derived":true} ``` ### Changes ``` diff --git a/.crumb b/.crumb index b7797c15..029d4735 100644 --- a/.crumb +++ b/.crumb @@ -64,8 +64,8 @@ "generated": { "children": [ { - "digest": "bc6f40b1151875289060253262a789e03563c9df036f500dec18ae21532324e2", - "last_commit": "19c00d4", + "digest": "a9a608274d2cd652e5a2f916d7e072549848dc24d0f64e3de7f339be98d2ec0a", + "last_commit": "58ae459", "name": "scripts", "purpose": "" }, @@ -76,15 +76,15 @@ "purpose": "" } ], - "children_root": "sha256:fde3a06dc77578e424777f1f6eee824390049694aff805601f603269f26db25d", - "compiled_at": "2026-10-11T01:37:05Z", + "children_root": "sha256:0437b60143e09a554077835240ed097aa0555d7e1e4a53295e7c5b27c207f92b", + "compiled_at": "2026-10-11T01:50:25Z", "compiler": "crumb-compile/1", - "digest": "sha256:182beb26b1a6b5e53650a03a20069567fb5b116a66112c0abb5e8961bf8cf33b", + "digest": "sha256:9b0e8b7ebfa15926a6be9c1a1d10eb4cdd2e3d386d96755bca5a65c9e00f53d8", "evidence_files": 187, "evidence_root": "sha256:27ee0353cb4d4aae2b7dbce2bfe0d9f4ef2a94cd7a4555b84684d59372503280", - "files": 2418, - "generated_at_commit": "66374c8aa2e6b45e9f808b38133b80c388ff0841", - "source_tree": "sha256:b16a97005fa59f346bfaddda0067fbee2f0962b9e9872304a21f73e08fa30507" + "files": 2420, + "generated_at_commit": "58ae459a1d50f602ca335aa5f61980e4b7e23ccd", + "source_tree": "sha256:640cafb7d3b2e08c2abb0443c66182ec90aa63ccd664a2a20fbcbb9aad87452a" } }, "history": [], diff --git a/docs/campaigns/whole-system-e2e/ACCEPTANCE-v1.3-ctrl-e5.md b/docs/campaigns/whole-system-e2e/ACCEPTANCE-v1.3-ctrl-e5.md new file mode 100644 index 00000000..9504a657 --- /dev/null +++ b/docs/campaigns/whole-system-e2e/ACCEPTANCE-v1.3-ctrl-e5.md @@ -0,0 +1,59 @@ +# WHOLE-SYSTEM-E2E, addendum v1.3-ctrl-e5: the verifier judges CTRL-E5 itself + +Tracking: aien-dev/aien-sovereign-core#403, aien-dev/aien-architecture#190 (L4). Contract `ACCEPTANCE_E2E.md` stays FROZEN +(aien-architecture b2400fe, sha256 `9e3d5f4e23d65ac17be8f2f4ca48355f0aaa486f67ff5a8a8044dcdd646d34e8`). `ACCEPTANCE-v1.md`, +`-v1.1.md`, `-v1.2.md` and every recorded run stay as written. This file is committed before the code that implements it. + +## Why + +RUN-1 and R7 judged CTRL-E5 by hand (`RESULT-RUN-1-R7.md`, `r7/`): one byte of `artifacts/E3-report.md` changed on a scratch +copy gave E3 FAIL DIGEST_MISMATCH, chain_unbroken false and a different verdict_id, on both machines. The harness wrote no +CTRL-E5 receipt, so the verifier's own CTRL-E5 row stayed NOT_RUN. This addendum puts the same check inside the chain. + +## Rule (harness tail, after the verifier) + +1. The chain is closed as before (receipts 001..N, console transcript, `VERDICT_ROWS.txt`, `chain/SHA256SUMS`). The harness no + longer writes a `CTRL-E5 NOT_RUN` placeholder receipt. +2. The verifier runs over the real folder with `--write` (no peer). Its verdict is the PRE-CTRL-E5 verdict: CTRL-E5 NOT_RUN + (receipt absent), E5 NOT_RUN. Its `verdict_id` is `original_verdict_id`. The harness copies that file to + `artifacts/VERIFIER_VERDICT.pre-ctrl-e5.txt`. +3. The harness copies the run folder to scratch, changes one byte of `artifacts/E3-report.md` (offset 3; the byte becomes `X`, + or `Y` if it already was `X`), and runs the verifier on the copy (no `--write`). Its output is kept as + `artifacts/CTRL-E5-mutated-verdict.txt`. +4. The harness appends one receipt, step `CTRL-E5`, to the chain (linked to the previous receipt as every receipt is), with + the fields: `mutated_file`, `mutation` {`offset`, `before_byte_hex`, `after_byte_hex`}, `original_verdict_id`, + `mutated_verdict_id`, `mutated_chain_unbroken`, `mutated_e3_row` (the verifier's E3 line on the copy), + `mutated_output_rejected` (true iff the copy's E3 row is FAIL with `DIGEST_MISMATCH` and `chain_unbroken` is false), + `verifier_reason`, `verifier_sha256`, `verifier_source_sha256`. If `E3-report.md` is absent or shorter than 4 bytes the + receipt is `NOT_RUN` with `mutated_output_rejected` omitted. +5. `VERDICT_ROWS.txt` is rewritten to include the CTRL-E5 row, `chain/SHA256SUMS` is rewritten (it now lists the new receipt, + the two new artifacts, the longer console transcript and the new `VERDICT_ROWS.txt`), and the verifier runs again over the + real folder with `--write`. That FINAL `VERIFIER_VERDICT.txt` is the run's verdict. + +## What the verifier judges (CTRL-E5) + +From the LAST `CTRL-E5` receipt in the chain, facts only (the status word is never trusted): +- absent, or lacking any of `mutated_output_rejected`, `mutated_chain_unbroken`, `original_verdict_id`, `mutated_verdict_id`, + `verifier_reason`: **NOT_RUN**; +- **PASS** iff `mutated_output_rejected` true, `mutated_chain_unbroken` false, `verifier_reason` names `DIGEST_MISMATCH`, + `mutated_verdict_id` differs from `original_verdict_id`, and `original_verdict_id` equals the id the verifier itself + computes from this folder with CTRL-E5 and E5 forced to NOT_RUN (so a receipt cannot cite a verdict it never saw); +- otherwise **FAIL**, with the reason naming which fact failed. + +## Verdict ids + +`verdict_id` hashes the rows including CTRL-E5. So the final `verdict_id` differs from the pre-CTRL-E5 one by exactly the +CTRL-E5 row (NOT_RUN to PASS). Both are recorded: the pre id inside the CTRL-E5 receipt and `artifacts/VERIFIER_VERDICT.pre-ctrl-e5.txt`, +the final one in `VERIFIER_VERDICT.txt`. `base_verdict_id` (E5 forced NOT_RUN, the id peers exchange) now includes the CTRL-E5 row, +so a peer machine verifying a v1.3 folder agrees with the harness machine on it. +Folders without a facts-bearing CTRL-E5 receipt (every run before v1.3) verify exactly as before: RUN-1-20261010T154724Z +gives `verdict_id` 437467db4149b013738578c10ef68b7168dfb95feae8dea882de17a6118fc5fd with the Spark base id as peer, and +base `a50fccb63363ef9224a19bd8bf4f249754abf5d88667ba0fd6ce93dfb8d63d80`. + +## Predictions + +| row | prediction | +|---|---| +| CTRL-E5 on a new run | PASS (the same check passed by hand on both machines) | +| verifier tests | present+PASS, present+FAIL (rejected false), absent NOT_RUN, wrong original id FAIL, all green | +| RUN-1 regression | ids unchanged | diff --git a/docs/campaigns/whole-system-e2e/REGRESSION-sc403.md b/docs/campaigns/whole-system-e2e/REGRESSION-sc403.md new file mode 100644 index 00000000..dda871a7 --- /dev/null +++ b/docs/campaigns/whole-system-e2e/REGRESSION-sc403.md @@ -0,0 +1,14 @@ +# Regression evidence, sc#403 (CTRL-E5 receipt), Lane E, 2026-10-11 + +Pre-registered in `ACCEPTANCE-v1.3-ctrl-e5.md` (committed before the code). Verifier built with `tools/aien-verify/build.sh` (rustc only). + +| check | result | +|---|---| +| `tools/aien-verify/tests/run.sh` | passed 43, failed 0 (was 34; nine new CTRL-E5 and RUN-1 checks) | +| `rustc --test` unit tests | 2 passed | +| `scripts/whole_system_e2e.sh selftest` | PASS | +| RUN-1-20261010T154724Z, Spark base id `a50fccb6...` as peer | `verdict_id 437467db4149b013738578c10ef68b7168dfb95feae8dea882de17a6118fc5fd`, `base_verdict_id a50fccb63363ef9224a19bd8bf4f249754abf5d88667ba0fd6ce93dfb8d63d80`, CTRL-E5 NOT_RUN (unchanged) | +| Harness tail run against a scratch copy of RUN-1 (daemon-free; the 017 placeholder removed) | pre-CTRL-E5 `verdict_id` a50fccb6...; scratch copy mutated at byte 3 of `artifacts/E3-report.md` (6f to 58): rejected=true, chain_unbroken=false, mutated id starts `cb72e9d9` (as R7 by hand); receipt CTRL-E5 PASS; final verdict `CTRL-E5 PASS`, chain_unbroken true, `verdict_id 02a8f01309fba46776b62e34ae31594429d12d98c823f86bc8cff6c7dc0706a2` | + +Limits: the tail was exercised on a scratch copy of RUN-1, not on a fresh full run (a full run needs the daemon and about an hour of CPU +model time and belongs to the next scheduled run). `runs/` was not modified. diff --git a/docs/campaigns/whole-system-e2e/VERIFIER-v1.md b/docs/campaigns/whole-system-e2e/VERIFIER-v1.md index 868ea212..d736d821 100644 --- a/docs/campaigns/whole-system-e2e/VERIFIER-v1.md +++ b/docs/campaigns/whole-system-e2e/VERIFIER-v1.md @@ -125,3 +125,9 @@ CTRL-E1, CTRL-E2, CTRL-E5 and CTRL-E6 field names are provisional until lanes L5 second-machine agreement (E5) is a procedure (each machine passes the other's base id) that this folder has not yet been run through on a MacBook. Run folders are not signed: an adversary who rewrites receipts, links and manifest consistently defeats the chain check; the verifier still re-derives every row from facts and files, which is what this lane promises. + +## CTRL-E5 (v1.3-ctrl-e5, sc#403) + +The verifier judges CTRL-E5 from the last `CTRL-E5` receipt's facts (rule: `ACCEPTANCE-v1.3-ctrl-e5.md`). It also derives the +pre-CTRL-E5 verdict id itself (CTRL-E5 and E5 forced to NOT_RUN) and requires the receipt's `original_verdict_id` to equal it. +Folders without a facts-bearing receipt give NOT_RUN and the ids recorded before v1.3. diff --git a/scripts/.crumb b/scripts/.crumb index fe4e0a98..89e47a66 100644 --- a/scripts/.crumb +++ b/scripts/.crumb @@ -4,14 +4,14 @@ "generated": { "children": [], "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "compiled_at": "2026-10-11T01:11:10Z", + "compiled_at": "2026-10-11T01:50:25Z", "compiler": "crumb-compile/1", - "digest": "sha256:bc6f40b1151875289060253262a789e03563c9df036f500dec18ae21532324e2", + "digest": "sha256:a9a608274d2cd652e5a2f916d7e072549848dc24d0f64e3de7f339be98d2ec0a", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "files": 33, - "generated_at_commit": "ef1fe354ef36e3aaad36671ab5a6c155f69634c9", - "source_tree": "sha256:30b5b39351d56d227d89dab480acac96fd08a113d2de0267cc8cbac813e050ee" + "generated_at_commit": "58ae459a1d50f602ca335aa5f61980e4b7e23ccd", + "source_tree": "sha256:d0efd88d594e863d457f94413e41b4840a00ff3831ec03ac7f450086b59e7b59" } }, "parent": { diff --git a/scripts/whole_system_e2e.sh b/scripts/whole_system_e2e.sh index 5ce0ccec..73409324 100755 --- a/scripts/whole_system_e2e.sh +++ b/scripts/whole_system_e2e.sh @@ -491,13 +491,46 @@ else rcpt CTRL-E4 NOT_RUN "E3m did not pass or no daemon" '{}'; fi rcpt E5 NOT_RUN "cross-machine agreement is R7 (second machine); this machine's verifier (tools/aien-verify, sc#389) runs over the closed chain after this receipt and writes VERIFIER_VERDICT.txt and VERIFIER_RECEIPT.json outside the manifest" \ "$(jq -nc --arg v "$VER_SHA" --arg s "$VER_SRC_SHA" --arg c "$CONTRACT_SHA" '{verifier_sha256:$v, verifier_source_sha256:$s, verifier_build:"sh tools/aien-verify/build.sh (rustc --edition 2021 -O, std only)", contract_sha256:$c, cross_machine:"NOT_RUN (R7)"}')" rcpt CTRL-E1 NOT_RUN "no release artifact in RUN-1 (lane L5)" '{}' -rcpt CTRL-E5 NOT_RUN "the mutation check runs with the second-machine verifier (lane L4, R7)" '{}' stop_graceful cp "$LOGS"/daemon-*.txt "$OUT/artifacts/" 2>/dev/null -printf 'objective_id %s\ncontract_sha256 %s\n%s' "$OBJ_ID" "$CONTRACT_SHA" "$ROWS" >"$OUT/VERDICT_ROWS.txt" +# ---- close the chain, run the verifier, then CTRL-E5 (ACCEPTANCE-v1.3-ctrl-e5.md) ----------------------------- +write_close() { # VERDICT_ROWS.txt and the manifest, from the current chain + printf 'objective_id %s\ncontract_sha256 %s\n%s' "$OBJ_ID" "$CONTRACT_SHA" "$ROWS" >"$OUT/VERDICT_ROWS.txt" + rm -f "$CHAIN/SHA256SUMS" + ( cd "$OUT" && find . -type f ! -name SHA256SUMS ! -name VERIFIER_VERDICT.txt ! -name VERIFIER_RECEIPT.json -print0 | LC_ALL=C sort -z | xargs -0 sha256sum >chain/SHA256SUMS ) +} +verify_out() { "$VER" "$1" --contract-sha256 "$CONTRACT_SHA" --objective-id "$OBJ_ID" "${@:2}"; } echo "run folder written: $OUT ($(ls "$CHAIN" | wc -l) chain files); console closed; manifest and verifier follow" | tee -a "$OUT/console.txt" -( cd "$OUT" && find . -type f ! -name SHA256SUMS -print0 | LC_ALL=C sort -z | xargs -0 sha256sum >chain/SHA256SUMS ) +write_close cat "$OUT/VERDICT_ROWS.txt" -"$VER" "$OUT" --contract-sha256 "$CONTRACT_SHA" --objective-id "$OBJ_ID" --write >"$D/verify.out" 2>&1; VRC=$? -echo "verifier exit $VRC: $(grep -E '^(verdict_id|chain_unbroken|base_verdict_id) ' "$OUT/VERIFIER_VERDICT.txt" 2>/dev/null | tr '\n' ' ')" +verify_out "$OUT" --write >"$D/verify.out" 2>&1; VRC=$? +echo "verifier exit $VRC (pre-CTRL-E5): $(grep -E '^(verdict_id|chain_unbroken|base_verdict_id) ' "$OUT/VERIFIER_VERDICT.txt" 2>/dev/null | tr '\n' ' ')" + +# CTRL-E5: one byte of artifacts/E3-report.md changed on a scratch copy; the verifier must reject the copy. +ORIG_VID=$(sed -n 's/^verdict_id //p' "$OUT/VERIFIER_VERDICT.txt" 2>/dev/null) +MUT=$OUT/artifacts/E3-report.md; MCOPY=$D/ctrl-e5-copy; rm -rf "$MCOPY" +if [ -n "$ORIG_VID" ] && [ -f "$MUT" ] && [ "$(wc -c <"$MUT")" -ge 4 ]; then + cp -a "$OUT" "$MCOPY" + BEFORE_HEX=$(od -An -tx1 -j3 -N1 "$MCOPY/artifacts/E3-report.md" | tr -d ' \n') + AFTER_HEX=$([ "$BEFORE_HEX" = 58 ] && echo 59 || echo 58) + printf "\\x$AFTER_HEX" | dd of="$MCOPY/artifacts/E3-report.md" bs=1 seek=3 conv=notrunc 2>/dev/null + verify_out "$MCOPY" >"$OUT/artifacts/CTRL-E5-mutated-verdict.txt" 2>/dev/null + M_VID=$(sed -n 's/^verdict_id //p' "$OUT/artifacts/CTRL-E5-mutated-verdict.txt") + M_CU=$(sed -n 's/^chain_unbroken //p' "$OUT/artifacts/CTRL-E5-mutated-verdict.txt") + M_E3=$(grep -m1 '^# E3 ' "$OUT/artifacts/CTRL-E5-mutated-verdict.txt" | cut -c1-300) + M_REJ=$(case "$M_E3" in "# E3 FAIL"*DIGEST_MISMATCH*) [ "$M_CU" = false ] && echo true || echo false ;; *) echo false ;; esac) + M_WHY=$(printf '%s' "$M_E3" | cut -c1-120) + if [ "$M_REJ" = true ] && [ -n "$M_VID" ] && [ "$M_VID" != "$ORIG_VID" ]; then ST=PASS; else ST=FAIL; fi + rcpt CTRL-E5 $ST "byte 3 of artifacts/E3-report.md ($BEFORE_HEX to $AFTER_HEX) on a scratch copy: rejected=$M_REJ, chain_unbroken=$M_CU, verdict id ${ORIG_VID%"${ORIG_VID#????????}"} to ${M_VID%"${M_VID#????????}"}" \ + "$(jq -nc --arg mf artifacts/E3-report.md --argjson off 3 --arg bh "$BEFORE_HEX" --arg ah "$AFTER_HEX" --arg ov "$ORIG_VID" --arg mv "$M_VID" --argjson mcu "$([ "$M_CU" = false ] && echo false || echo true)" \ + --arg e3 "$M_E3" --argjson rej "$M_REJ" --arg why "$M_WHY" --arg v "$VER_SHA" --arg s "$VER_SRC_SHA" \ + '{mutated_file:$mf, mutation:{offset:$off, before_byte_hex:$bh, after_byte_hex:$ah}, original_verdict_id:$ov, mutated_verdict_id:$mv, mutated_chain_unbroken:$mcu, mutated_e3_row:$e3, mutated_output_rejected:$rej, verifier_reason:$why, verifier_sha256:$v, verifier_source_sha256:$s}')" + rm -rf "$MCOPY" +else + rcpt CTRL-E5 NOT_RUN "no pre-CTRL-E5 verdict or no usable artifacts/E3-report.md; the mutation check could not run" '{}' +fi +cp "$OUT/VERIFIER_VERDICT.txt" "$OUT/artifacts/VERIFIER_VERDICT.pre-ctrl-e5.txt" 2>/dev/null # after the mutated copy is gone, so the copy is a clean copy of the closed folder +write_close +verify_out "$OUT" --write >"$D/verify-final.out" 2>&1; VRC=$? +echo "verifier exit $VRC (final): $(grep -E '^(CTRL-E5|verdict_id|chain_unbroken|base_verdict_id) ' "$OUT/VERIFIER_VERDICT.txt" 2>/dev/null | tr '\n' ' ')" exit 0 diff --git a/tools/aien-verify/src/main.rs b/tools/aien-verify/src/main.rs index fb61e583..d0e6ea77 100644 --- a/tools/aien-verify/src/main.rs +++ b/tools/aien-verify/src/main.rs @@ -920,12 +920,37 @@ fn ctrl_e2(ctx: &Ctx) -> Row { }) } -fn ctrl_e5(ctx: &Ctx) -> Row { - ctrl_simple(ctx, "CTRL-E5", |j| { - let m = j.b("mutated_output_rejected")?; - let why = j.s("verifier_reason")?; - Some(if m && contains_ci(Some(why), "digest") { Ok("mutated output rejected on a digest mismatch".into()) } else { Err(format!("mutated_output_rejected {}, reason {:?}", m, why)) }) - }) +// CTRL-E5 (v1.3-ctrl-e5): judged from the LAST CTRL-E5 receipt's facts. `pre_id` is the verdict id this verifier computes +// from the folder with CTRL-E5 and E5 forced to NOT_RUN; the receipt's original_verdict_id must equal it. +fn ctrl_e5(ctx: &Ctx, pre_id: &str) -> Row { + let Some(r) = ctx.recs.iter().rev().find(|r| r.step == "CTRL-E5") else { return row("CTRL-E5", V::NotRun, "no receipt for this step in the chain") }; + let j = &r.j; + let (Some(rej), Some(mcu), Some(orig), Some(mutd), Some(why)) = + (j.b("mutated_output_rejected"), j.b("mutated_chain_unbroken"), j.s("original_verdict_id"), j.s("mutated_verdict_id"), j.s("verifier_reason")) + else { + return row("CTRL-E5", V::NotRun, "receipt lacks the facts this control needs"); + }; + let mut bad = vec![]; + if !rej { + bad.push("mutated_output_rejected false".to_string()); + } + if mcu { + bad.push("mutated copy's chain still unbroken".into()); + } + if !why.contains("DIGEST_MISMATCH") { + bad.push(format!("reason {:?} does not name DIGEST_MISMATCH", why)); + } + if !is_hex64(orig) || !is_hex64(mutd) || orig == mutd { + bad.push("mutated verdict id is not a different, well-formed id".into()); + } + if orig != pre_id { + bad.push(format!("original_verdict_id {} is not the pre-CTRL-E5 id {} this verifier derives", orig, pre_id)); + } + if bad.is_empty() { + row("CTRL-E5", V::Pass, "one byte of an output changed on a copy: rejected on DIGEST_MISMATCH, chain broken, verdict id changed") + } else { + row("CTRL-E5", V::Fail, bad.join("; ")) + } } fn ctrl_e6(ctx: &Ctx) -> Row { @@ -1074,12 +1099,15 @@ fn main() -> ExitCode { }; rows.push(c3); rows.push(ctrl_e4(&ctx, e4_recalled)); - rows.push(ctrl_e5(&ctx)); + let c5_idx = rows.len(); + rows.push(row("CTRL-E5", V::NotRun, "placeholder")); rows.push(ctrl_e6(&ctx)); let mut supp = vec![pre_row(&ctx), doc_row(&ctx, "E3m"), a, b, net_row(&ctx)]; // E5: base verdict id with E5 NOT_RUN, then the peer comparison let map = |rows: &Vec| rows.iter().map(|r| (r.name.clone(), r.v)).collect::>(); + let pre_id = verdict_id(&chain.objective_id, &o.contract, &map(&rows)); + rows[c5_idx] = ctrl_e5(&ctx, &pre_id); let base_id = verdict_id(&chain.objective_id, &o.contract, &map(&rows)); rows[e5_idx] = match (&o.peer, chain_unbroken) { (None, _) => row("E5", V::NotRun, "no --peer-verdict-id: cross-machine agreement not shown"), diff --git a/tools/aien-verify/tests/run.sh b/tools/aien-verify/tests/run.sh index bcff7879..2e340771 100755 --- a/tools/aien-verify/tests/run.sh +++ b/tools/aien-verify/tests/run.sh @@ -123,6 +123,41 @@ detect "M5 unlisted extra file" MANIFEST_UNLISTED mutant "$FB"; rm "$work/m/chain/007-E4.json" detect "M6 receipt file dropped" SEQUENCE_GAP +# CTRL-E5 (v1.3-ctrl-e5): judged from the receipt's facts. Built on a copy of fixture B with a receipt appended and the manifest rewritten. +mkE5() { # dir, fields json (merged over a good receipt) + rm -rf "$1"; cp -r "$FB" "$1"; rm -f "$1/chain/SHA256SUMS" + last=$(ls "$1"/chain/0*.json | LC_ALL=C sort | tail -1); num=$(basename "$last" | cut -c1-3); next=$(printf '%03d' $((1$num - 999))) + jq --arg prev "$(sha256sum "$last" | cut -d' ' -f1)" --arg step CTRL-E5 --argjson f "$2" \ + '{objective_id, run_id, step:$step, status:"PASS", prev_receipt_sha256:$prev, evidence:"test"} + $f' "$last" >"$1/chain/$next-CTRL-E5.json" + (cd "$1" && find . -type f ! -name SHA256SUMS ! -name VERIFIER_VERDICT.txt ! -name VERIFIER_RECEIPT.json -print0 | LC_ALL=C sort -z | xargs -0 sha256sum >chain/SHA256SUMS) +} +GOOD="{\"mutated_output_rejected\":true,\"mutated_chain_unbroken\":false,\"original_verdict_id\":\"$B1\",\"mutated_verdict_id\":\"1111111111111111111111111111111111111111111111111111111111111111\",\"verifier_reason\":\"# E3 FAIL: DIGEST_MISMATCH: x\"}" +c5() { "$bin" "$1" --contract-sha256 $CS 2>/dev/null; } +mkE5 "$work/e5a" "$GOOD" +c5 "$work/e5a" | grep -q "^CTRL-E5 PASS$" && ok "CTRL-E5 PASS from a good receipt" || { bad "CTRL-E5 PASS from a good receipt"; c5 "$work/e5a" | grep "CTRL-E5"; } +c5 "$work/e5a" | grep -q '^chain_unbroken true$' && ok "CTRL-E5 fixture chain unbroken" || bad "CTRL-E5 fixture chain unbroken" +[ "$(c5 "$work/e5a" | sed -n 's/^verdict_id //p')" != "$B1" ] && ok "CTRL-E5 PASS changes the final id" || bad "CTRL-E5 PASS changes the final id" +mkE5 "$work/e5b" "$(printf '%s' "$GOOD" | jq -c '.mutated_output_rejected=false')" +c5 "$work/e5b" | grep -q '^CTRL-E5 FAIL$' && ok "CTRL-E5 FAIL when mutated_output_rejected is false" || bad "CTRL-E5 FAIL when rejected false" +mkE5 "$work/e5c" "$(printf '%s' "$GOOD" | jq -c '.original_verdict_id="2222222222222222222222222222222222222222222222222222222222222222"')" +c5 "$work/e5c" | grep -q '^CTRL-E5 FAIL$' && ok "CTRL-E5 FAIL when original_verdict_id is not the derived pre id" || bad "CTRL-E5 FAIL on wrong original id" +mkE5 "$work/e5d" "$(printf '%s' "$GOOD" | jq -c '.mutated_verdict_id=.original_verdict_id')" +c5 "$work/e5d" | grep -q '^CTRL-E5 FAIL$' && ok "CTRL-E5 FAIL when the verdict id did not change" || bad "CTRL-E5 FAIL on unchanged id" +mkE5 "$work/e5e" "$(printf '%s' "$GOOD" | jq -c '.mutated_chain_unbroken=true')" +c5 "$work/e5e" | grep -q '^CTRL-E5 FAIL$' && ok "CTRL-E5 FAIL when the mutated chain stayed unbroken" || bad "CTRL-E5 FAIL on unbroken mutated chain" +mkE5 "$work/e5f" "{}" +c5 "$work/e5f" | grep -q '^CTRL-E5 NOT_RUN$' && ok "CTRL-E5 NOT_RUN when the receipt lacks facts" || bad "CTRL-E5 NOT_RUN without facts" +c5 "$FB" | grep -q '^CTRL-E5 NOT_RUN$' && ok "CTRL-E5 NOT_RUN when no receipt" || bad "CTRL-E5 NOT_RUN absent" + +# regression: the recorded RUN-1 (no facts-bearing CTRL-E5 receipt) still verifies to its recorded ids +R1=$runs/RUN-1-20261010T154724Z +if [ -d "$R1" ]; then + C9=9e3d5f4e23d65ac17be8f2f4ca48355f0aaa486f67ff5a8a8044dcdd646d34e8 + out=$("$bin" "$R1" --contract-sha256 $C9 --peer-verdict-id a50fccb63363ef9224a19bd8bf4f249754abf5d88667ba0fd6ce93dfb8d63d80 2>/dev/null) + printf '%s\n' "$out" | grep -q '^verdict_id 437467db4149b013738578c10ef68b7168dfb95feae8dea882de17a6118fc5fd$' && ok "RUN-1 verdict_id unchanged with the Spark base id as peer" || bad "RUN-1 verdict_id unchanged" + printf '%s\n' "$out" | grep -q '^base_verdict_id a50fccb63363ef9224a19bd8bf4f249754abf5d88667ba0fd6ce93dfb8d63d80$' && ok "RUN-1 base_verdict_id unchanged" || bad "RUN-1 base_verdict_id unchanged" +fi + after=$(tree_sum "$runs") [ "$before" = "$after" ] && ok "fixtures untouched" || bad "fixtures untouched" echo "passed $pass, failed $fail" ```