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/interplane-mv/blob/main/adapters/aien/scripts/demo-verified-fix.sh # interplane-mv INTERPLANE: open interoperability protocol between AI models and agent runtimes. Models express intent. Runtimes retain authority. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `interplane-mv / adapters / aien / scripts / demo-verified-fix.sh` 232 lines ยท 15869 bytes Raw Blame History 1 #!/usr/bin/env bash 2 # Reproducible demo of the verified fix-the-test workflow (VAC M4a). 3 # 4 # One command runs the fix-the-test slice gate (scripts/test-fix-the-test.sh) against a real native 5 # `aien-cli daemon`, records every revision it depends on, and writes $OUT/DEMO-RESULT.md. It refuses to 6 # pass when the daemon reports a STUB compose library, when the verdict is anything other than the 7 # labelled-incomplete one a scripted run may earn, or when any recorded fact disagrees with its source. 8 # 9 # Prerequisites: git, jq, make, cc, cargo/rustc, sha256sum, the Llama-3.2-1B-Instruct snapshot (see 10 # adapters/aien/README.md "Reproducible demo"). `quietlock check` is honoured when quietlock exists. 11 # 12 # Daemon, one of: 13 # AIEN_BIN= an aien-cli built natively (omega compose library linked). Its sovereign-core rev is 14 # caller-asserted via SOVEREIGN_CORE_REV unless the daemon prints it. 15 # build mode SC_DIR (aien-sovereign-core checkout), OMEGA_DIR (HEAD == SC_DIR/omega.lock), 16 # PHYSICS_DIR (HEAD == OMEGA_DIR/physics.lock), AIENOS_REPO (HEAD == OMEGA_DIR/aienos.lock); 17 # builds `cargo build -p aien-cli` on the CPU with the same env as sovereign-core's 18 # scripts/test-linked-compose.sh. CARGO_TARGET_DIR is honoured. 19 # Also: OUT (fresh directory, required), AIEN_LEDGER_MODEL_DIR, SOVEREIGN_CORE_REV, OMEGA_LOCK_REV. 20 # No process is killed here. Exit non-zero on any failure. 21 set -euo pipefail 22 23 here="$(cd "$(dirname "$0")" && pwd)" 24 adapter="$(cd "$here/.." && pwd)" 25 repo="$(cd "$adapter/../.." && pwd)" 26 die() { echo "DEMO FAIL: $*" >&2; exit 1; } 27 : "${OUT:?OUT must name a fresh output directory}" 28 for t in git jq make cc sha256sum rustc cargo; do command -v "$t" >/dev/null || die "$t is required"; done 29 [ ! -e "$OUT/gate" ] || die "$OUT/gate exists: use a fresh OUT" 30 mkdir -p "$OUT"; OUT="$(cd "$OUT" && pwd)" 31 if command -v quietlock >/dev/null && ! quietlock check >/dev/null 2>&1; then die "quiet flag is held (quietlock check)"; fi 32 model_dir="${AIEN_LEDGER_MODEL_DIR:-$HOME/.cache/huggingface/hub/models--unsloth--Llama-3.2-1B-Instruct/snapshots/`5a8abab4a5d6f164389b1079fb721cfab8d7126c`}" 33 red() { sed -e "s#$HOME#~#g" -e "s#$repo##g"; } # no home paths in the record 34 started="$(date -u +%FT%TZ)" 35 [ -z "$(git -C "$repo" status --porcelain -- adapters provenance)" ] || die "adapters/ or provenance/ has uncommitted changes: the demo records a commit, so commit or stash first" 36 37 # 1. The daemon: given, or built from the four checkouts and their locks. 38 build_note="" 39 if [ -z "${AIEN_BIN:-}" ]; then 40 : "${SC_DIR:?set AIEN_BIN, or SC_DIR OMEGA_DIR PHYSICS_DIR AIENOS_REPO to build}" 41 : "${OMEGA_DIR:?OMEGA_DIR}" "${PHYSICS_DIR:?PHYSICS_DIR}" "${AIENOS_REPO:?AIENOS_REPO}" 42 SC_DIR="$(cd "$SC_DIR" && pwd)"; OMEGA_DIR="$(cd "$OMEGA_DIR" && pwd)" 43 PHYSICS_DIR="$(cd "$PHYSICS_DIR" && pwd)"; AIENOS_REPO="$(cd "$AIENOS_REPO" && pwd)" 44 [ "$(git -C "$OMEGA_DIR" rev-parse HEAD)" = "$(tr -d '[:space:]' <"$SC_DIR/omega.lock")" ] || die "omega HEAD != sovereign-core omega.lock" 45 [ "$(git -C "$PHYSICS_DIR" rev-parse HEAD)" = "$(tr -d '[:space:]' <"$OMEGA_DIR/physics.lock")" ] || die "physics HEAD != omega physics.lock" 46 [ "$(git -C "$AIENOS_REPO" rev-parse HEAD)" = "$(tr -d '[:space:]' <"$OMEGA_DIR/aienos.lock")" ] || die "aienos HEAD != omega aienos.lock" 47 export AIEN_OMEGA_COMPOSE_DIR="$OMEGA_DIR" AIEN_PHYSICS_DIR="$PHYSICS_DIR" AIEN_AIENOS_LOCK_REPO="$AIENOS_REPO" 48 unset AIEN_OMEGA_DIR AIEN_OMEGA_GPU_LIB AIEN_OMEGA_COMPOSE_LIB AIEN_OMEGA_COMPOSE_SHA AIEN_FORCE_CPU_STUB AIEN_DEV_FALLBACK 49 (cd "$SC_DIR" && cargo build -p aien-cli) >"$OUT/build.log" 2>&1 || { tail -5 "$OUT/build.log" >&2; die "daemon build failed (log $OUT/build.log)"; } 50 AIEN_BIN="${CARGO_TARGET_DIR:-$SC_DIR/target}/debug/aien-cli" 51 SOVEREIGN_CORE_REV="$(git -C "$SC_DIR" rev-parse HEAD)"; export SOVEREIGN_CORE_REV 52 [ -z "$(git -C "$SC_DIR" status --porcelain --untracked-files=no)" ] || die "sovereign-core checkout is dirty" 53 build_note="built here from SC_DIR at $SOVEREIGN_CORE_REV (CPU, debug)" 54 else 55 [ -x "$AIEN_BIN" ] || die "AIEN_BIN not executable: $AIEN_BIN" 56 build_note="supplied via AIEN_BIN, not built by this run" 57 OMEGA_DIR="${OMEGA_DIR:-${AIEN_OMEGA_COMPOSE_DIR:-}}"; PHYSICS_DIR="${PHYSICS_DIR:-${AIEN_PHYSICS_DIR:-}}"; AIENOS_REPO="${AIENOS_REPO:-${AIEN_AIENOS_LOCK_REPO:-}}" 58 SC_DIR="${SC_DIR:-}" 59 fi 60 export AIEN_BIN 61 rev_of() { [ -n "$1" ] && git -C "$1" rev-parse HEAD 2>/dev/null || echo "UNVERIFIED (checkout not given)"; } 62 omega_rev="${OMEGA_LOCK_REV:-$(rev_of "${OMEGA_DIR:-}")}" 63 physics_rev="$(rev_of "${PHYSICS_DIR:-}")"; aienos_rev="$(rev_of "${AIENOS_REPO:-}")" 64 omega_lock="n/a"; physics_lock="n/a"; aienos_lock="n/a" 65 [ -n "${SC_DIR:-}" ] && [ -f "$SC_DIR/omega.lock" ] && omega_lock="$(tr -d '[:space:]' <"$SC_DIR/omega.lock")" 66 [ -n "${OMEGA_DIR:-}" ] && [ -f "$OMEGA_DIR/physics.lock" ] && physics_lock="$(tr -d '[:space:]' <"$OMEGA_DIR/physics.lock")" 67 [ -n "${OMEGA_DIR:-}" ] && [ -f "$OMEGA_DIR/aienos.lock" ] && aienos_lock="$(tr -d '[:space:]' <"$OMEGA_DIR/aienos.lock")" 68 bin_sha="$(sha256sum "$AIEN_BIN" | cut -d' ' -f1)" 69 sc_rev="${SOVEREIGN_CORE_REV:-UNVERIFIED}" 70 if [ -n "${SC_DIR:-}" ] && [ -d "$SC_DIR/.git" -o -f "$SC_DIR/.git" ]; then sc_rev="$(git -C "$SC_DIR" rev-parse HEAD)"; sc_src="read from SC_DIR"; else sc_src="caller-asserted (SOVEREIGN_CORE_REV), not verified by this run"; fi 71 export SOVEREIGN_CORE_REV="$sc_rev" 72 [ "$sc_rev" != "UNVERIFIED" ] || echo "note: SOVEREIGN_CORE_REV not given; recorded as UNVERIFIED" >&2 73 74 # 2. The slice gate, once. A stub daemon is refused below, from the daemon's own report. 75 gate_rc=0 76 OMEGA_LOCK_REV="$omega_rev" OUT="$OUT/gate" "$here/test-fix-the-test.sh" >"$OUT/gate.log" 2>&1 || gate_rc=$? 77 [ "$gate_rc" -eq 0 ] || { tail -5 "$OUT/gate.log" | red >&2; die "slice gate failed with $gate_rc (log $OUT/gate.log)"; } 78 g="$OUT/gate"; rec="$g/receipt.json"; b="$g/rows/slice1/bundle"; r="$b/records" 79 dlog="$g/rows/slice1/daemon.log" 80 [ -f "$rec" ] && [ -f "$b/COMPANION.json" ] && [ -f "$dlog" ] || die "gate left no receipt, bundle or daemon log" 81 82 # 3. Facts, each read from the daemon's or the run's own output. 83 compose_line="$(grep -m1 '^Compose:' "$dlog" || true)" 84 [ -n "$compose_line" ] || die "daemon log has no Compose: line" 85 case "$compose_line" in "Compose: native ("*) ;; *) die "STUB daemon (daemon says: $compose_line): the demo does not pass on a stub";; esac 86 recall_native="$(jq -r '.compose_native // "absent"' "$r/aien/compose-recall.json")" 87 recall_omega="$(jq -r '.omega_sha // "absent"' "$r/aien/compose-recall.json")" 88 [ "$recall_native" = "true" ] || die "ComposeRecall compose_native=$recall_native (need true)" 89 line_omega="$(printf '%s' "$compose_line" | sed -n 's/^Compose: native (omega \([0-9a-f]*\)).*/\1/p')" 90 [ "$line_omega" = "$recall_omega" ] || die "Compose line omega ($line_omega) != ComposeRecall omega_sha ($recall_omega)" 91 if [ "$omega_rev" != "${omega_rev#UNVERIFIED}" ] || [ "$omega_rev" = "n/a" ]; then omega_check="not compared (omega checkout not given)" 92 else [ "$omega_rev" = "$recall_omega" ] || die "omega checkout $omega_rev != daemon omega $recall_omega"; omega_check="matches the daemon's report"; fi 93 [ "$(jq -r .aien.native.claimed "$b/COMPANION.json")" = "true" ] || die "bundle does not claim native" 94 verdict="$(jq -r .verdict "$rec")" 95 want="PASS_LABELLED_INCOMPLETE missing=link:model_turn effect=aien-ledger-slice/1:strong proposal=scripted_turn" 96 [ "$verdict" = "$want" ] || die "verdict is not the expected labelled-incomplete one: $verdict" 97 case "$verdict" in PASS|"PASS complete"*) die "a scripted run cannot be PASS complete";; esac 98 [ "$(jq -r .aien_cli_sha256 "$rec")" = "$bin_sha" ] || die "daemon binary hash changed during the run" 99 100 model_sha="$(sed -n 's/.*model_sha256=\([0-9a-f]*\).*/\1/p' "$dlog" | head -1)" 101 tok_sha="$(sed -n 's/.*tokenizer_sha256=\([0-9a-f]*\).*/\1/p' "$dlog" | head -1)" 102 [ -n "$model_sha" ] && [ -n "$tok_sha" ] || die "daemon load log lacks model/tokenizer sha256" 103 [ "$model_sha" = "$(sha256sum "$model_dir/model.safetensors" | cut -d' ' -f1)" ] || die "model sha256 in the daemon log != the file on disk" 104 [ "$tok_sha" = "$(sha256sum "$model_dir/tokenizer.json" | cut -d' ' -f1)" ] || die "tokenizer sha256 in the daemon log != the file on disk" 105 backend="$(grep -m1 -i 'backend' "$dlog" | red || true)" 106 107 grant="$(jq -r .text "$r/aien/ledger-grant.json")"; ack="$(jq -r .text "$r/aien/ledger-ack.json")"; intent="$(jq -r .text "$r/aien/ledger-intent.json")" 108 appr_id="$(jq -r .approval_id <<<"$grant")"; appr_key="$(jq -r .approval_key <<<"$grant")"; approver="$(jq -r .approver <<<"$grant")" 109 w_path="$(jq -r .path <<<"$intent")"; w_sha="$(jq -r .content_sha256 <<<"$intent")"; w_prior="$(jq -r .prior_sha256 <<<"$intent")" 110 ack_phase="$(jq -r .phase <<<"$ack")"; ack_disk="$(jq -r .disk_sha256 <<<"$ack")"; ack_err="$(jq -r '.disk_error // "null"' <<<"$ack")" 111 [ "$ack_phase" = "ack" ] && [ "$ack_disk" = "$w_sha" ] && [ "$ack_err" = "null" ] || die "ack does not confirm the approved bytes on disk" 112 # The intent carries no approval id; it binds to the grant by `authorization` (= the grant record id), and the 113 # grant carries the approval. So all three must hold: intent -> this grant, grant -> an approval, same proposal. 114 grant_id="$(jq -r .id "$r/aien/ledger-grant.json")" 115 [ "$(jq -r .authorization <<<"$intent")" = "$grant_id" ] || die "intent.authorization is not this grant ($grant_id)" 116 case "$appr_id" in ""|null) die "grant carries no approval_id";; esac 117 [ "$(jq -r .proposal_sha256 <<<"$intent")" = "$(jq -r .proposal_sha256 <<<"$grant")" ] || die "intent and grant name different proposals" 118 approved_content_sha="$(jq -r .content_sha256 <<<"$grant")" 119 [ "$approved_content_sha" = "$w_sha" ] || die "grant content sha != written content sha" 120 trace_content_sha="$(jq -j ".[0].payload.arguments.content" "$r/interplane/trace.json" | sha256sum | cut -d" " -f1)" 121 [ "$trace_content_sha" = "$w_sha" ] || die "the INTERPLANE request content digest ($trace_content_sha) != the approved content digest" 122 t_before_exit="$(jq -r .task.test_exit_before "$rec")"; t_after_exit="$(jq -r .task.test_exit_after "$rec")" 123 out_before_sha="$(jq -r .before.stdout_sha256 "$r/task/test-run.json")"; out_after_sha="$(jq -r .stdout_sha256 "$r/task/test-run.json")" 124 [ "$out_after_sha" = "$(sha256sum "$r/task/test-stdout.txt" | cut -d' ' -f1)" ] || die "retained stdout digest != test-run record" 125 neg_n="$(jq '.negative_checks | length' "$rec")"; [ "$neg_n" -eq 8 ] || die "expected 8 negative checks (control + 7), got $neg_n" 126 rustc_v="$(rustc --version)" 127 finished="$(date -u +%FT%TZ)" 128 mf() { jq -r "$1" "$rec"; } 129 130 # 4. DEMO-RESULT.md 131 res="$OUT/DEMO-RESULT.md" 132 { 133 cat < && cd interplane 206 # prerequisites: git jq make cc cargo; the Llama-3.2-1B-Instruct snapshot at \$AIEN_LEDGER_MODEL_DIR 207 # a native aien-cli (see the build-mode comment in the script), then: 208 AIEN_BIN= SOVEREIGN_CORE_REV=$sc_rev OUT= adapters/aien/scripts/demo-verified-fix.sh 209 # or build it: SC_DIR= OMEGA_DIR= PHYSICS_DIR= \\ 210 # AIENOS_REPO= OUT= adapters/aien/scripts/demo-verified-fix.sh 211 \`\`\` 212 This run: daemon $build_note; AIEN_OMEGA_COMPOSE_DIR/AIEN_PHYSICS_DIR/AIEN_AIENOS_LOCK_REPO as in the table; the script calls \`scripts/test-fix-the-test.sh\` once (one live row, a real daemon, CPU). 213 214 ## 9. What is proven 215 - The approved write is bound to exact bytes: grant, intent and ack share one content digest, and the ack's on-disk digest equals it [O]. 216 - The write went through the daemon's approved ledger (claim, grant, intent, ack, committed records retained) [O]. 217 - Tests failed before and passed after; their stdout digests are retained and checked by the verifier [O]. 218 - The source pin matches the grant's prior_sha256; the native claim agrees with the daemon's own report; seven tampers are each refused with their specific code [O]. 219 - The daemon was native (not a stub) by its own report, and its model/tokenizer hashes equal the files on disk [O]. 220 221 ## 10. What is not proven 222 - The model turn is scripted: the verdict is labelled incomplete (\`missing=link:model_turn\`), never PASS complete. No authorship claim for the proposal. 223 - Records are unsigned exports: the verifier cannot tell an export from a hand-written file. 224 - The test run is harness evidence, not a daemon effect (the daemon only writes the file). 225 - The desk MAC for ComposeAuthorize stays default-off (unchanged here). No security default was changed. 226 - CPU reference backend only; no GPU path was exercised. 227 - Sovereign-core rev: $sc_src. 228 - The demo checks the native report after the gate's run, not before it: a stub daemon is refused (exit non-zero) but only after the run. 229 MD 230 } | red >"$res" 231 grep -q "$HOME" "$res" && die "home path leaked into the record" 232 echo "DEMO PASS (labelled incomplete): $res"