interplane.Get Omega
Read in your language

interplane-mv

INTERPLANE: open interoperability protocol between AI models and agent runtimes. Models express intent. Runtimes retain authority.

Brought by drakestapleton

branch main Branches Tags History

interplane-mv / tests / gates / run.sh

168 lines · 10060 bytes Raw Blame History
1#!/usr/bin/env bash
2# tests/gates/run.sh: the one entry point for the local verification gates of interplane.
3# Every step runs the SAME commands as the hosted job it mirrors (.github/workflows/ci.yml, jobs
4# no-python, schemas-and-fixtures, rust, package, negative-controls, provenance, adapter-aien).
5# Manifests under tests/gates/ name this script plus one step word, so no manifest needs shell
6# expansion (ADR 0028 P6). Observations print as "AIEN-OBS <name> <json>".
7#
8# Two deliberate differences from the hosted runner, neither changes what is checked:
9# - Files the hosted job writes beside the checkout (rust-verdicts.json, rust-matrix.json,
10# t4-verdicts.json) go to a private temp dir here, so the checkout stays clean while the gates
11# of one head run in parallel in it; the cmp against conformance/expected/ is unchanged.
12# - Paths into cargo's target dir honour CARGO_TARGET_DIR (the Spark worker sets it).
13#
14# Sibling checkouts (adapter-aien): the hosted job runs adapters/aien/setup-siblings.sh, which
15# clones aegis-runtime and aien-protocols at the commits in adapters/aien/PINS into
16# <parent>/interplane-audit/, where adapters/aien/Cargo.toml expects them
17# (../../../interplane-audit/aegis-runtime). The Spark worker provides ../aegis-runtime and
18# ../aien-protocols (main, read-only) and the run directory is not writable, so this step builds
19# the hosted layout in a private temp dir: a copy of this commit at <tmp>/interplane and local
20# clones of the two siblings (no network) at <tmp>/interplane-audit, then runs the real
21# setup-siblings.sh there, which checks out the PINS commits and checks the Cargo.toml revs.
22set -euo pipefail
23ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
24cd "$ROOT"
25step="${1:?usage: tests/gates/run.sh <step>}"
26obs() { printf 'AIEN-OBS %s %s\n' "$1" "$2"; }
27tmp=$(mktemp -d)
28trap 'rm -rf "$tmp"' EXIT
29export CARGO_TERM_COLOR=never
30TARGET="${CARGO_TARGET_DIR:-$ROOT/rust/target}"
31
32need_sibling() {
33 local name="$1"
34 if [ ! -d "../$name" ]; then
35 echo "run.sh: ../$name is missing; the hosted job clones aien-dev/$name at adapters/aien/PINS" >&2
36 exit 3
37 fi
38 obs "sibling_${name//-/_}_commit" "\"$(git -C "../$name" rev-parse HEAD 2>/dev/null || echo unknown)\""
39}
40
41case "$step" in
42 no-python)
43 # Hosted ci.yml job no-python (project rule, Drake 2026-10-15: no Python ships here).
44 found=$(git ls-files -- ':(glob)**/*.py' ':(glob)**/*.pyi' ':(glob)**/*.pyx' ':(glob)**/*.ipynb' \
45 ':(glob)**/pyproject.toml' ':(glob)**/requirements*.txt' ':(glob)**/setup.py' ':(glob)**/setup.cfg' \
46 ':(glob)**/Pipfile' ':(glob)**/Pipfile.lock')
47 # Scripts without a .py ending: a first line that runs Python.
48 shebang=$(git ls-files -z | xargs -0 -r awk 'FNR == 1 { if ($0 ~ /^#!.*python/) print FILENAME; nextfile }')
49 found=$(printf '%s\n%s\n' "$found" "$shebang" | sed '/^$/d')
50 if [ -n "$found" ]; then
51 printf 'Python files are tracked; this repository ships no Python:\n%s\n' "$found"
52 obs python_files_found true
53 exit 1
54 fi
55 obs python_files_found false
56 ;;
57 schemas-and-fixtures)
58 cd rust
59 cargo run -q --locked -p interplane-conformance --bin interplane-corpus -- schemas
60 cargo run -q --locked -p interplane-conformance --bin interplane-corpus -- validate
61 ;;
62 rust)
63 cd rust
64 cargo fmt --all --check
65 cargo clippy --all-targets --all-features -- -D warnings
66 cargo test --all
67 # negative controls (test-only feature) detect their defects
68 cargo test -p interplane-conformance --features negative-controls
69 # both examples run offline and check their own story (exit 1 on any difference)
70 cargo run -q -p interplane-crossveil --example offline
71 cargo run -q -p interplane-crossveil --example todo_adapter
72 # conformance verdicts equal the recorded reference (106 cases)
73 cargo run -q --locked -p interplane-conformance --bin interplane-conformance -- ../conformance/fixtures --out "$tmp/rust-verdicts.json"
74 cmp "$tmp/rust-verdicts.json" ../conformance/expected/verdicts.json
75 test "$(jq length "$tmp/rust-verdicts.json")" = 106
76 obs conformance_cases 106
77 ;;
78 package)
79 # Release check: every crate packages and builds from its .crate alone.
80 cd rust
81 # The Spark judge has no network (2026-10-19: index.crates.io did not resolve), so package
82 # from the local registry cache, like every other gate here.
83 # Its CARGO_HOME is read-only. Verifying a crate that depends on another workspace crate
84 # unpacks that crate from cargo's temporary registry into $CARGO_HOME/registry/src, and on a
85 # read-only home cargo fails with "no hash listed for interplane-core". So package with a
86 # scratch CARGO_HOME: a copy of the index, the real .crate cache and unpacked sources linked
87 # read-only, and a writable registry/src for the workspace crates.
88 real_home="${CARGO_HOME:-$HOME/.cargo}"
89 pkg_home="$tmp/cargo-home"
90 mkdir -p "$pkg_home/registry/src" "$pkg_home/registry/cache"
91 if [ -d "$real_home/registry/index" ]; then cp -R "$real_home/registry/index" "$pkg_home/registry/index"; chmod -R u+w "$pkg_home/registry/index"; fi
92 for d in "$real_home"/registry/cache/* "$real_home"/registry/src/*; do
93 [ -d "$d" ] && ln -s "$d" "$pkg_home/registry/$(basename "$(dirname "$d")")/$(basename "$d")"
94 done
95 [ -d "$real_home/git" ] && ln -s "$real_home/git" "$pkg_home/git"
96 CARGO_HOME="$pkg_home" cargo package --workspace --locked --offline
97 ;;
98 negative-controls)
99 # trust corpus and protocol digests match conformance/TRUST-DIGEST.txt
100 (cd rust && cargo run -q --locked -p interplane-conformance --bin interplane-corpus -- trust-digest --check)
101 # pipeline libraries never mention the negative controls ("if", because set -e ignores a "!" command)
102 if grep -rIl -E 'negctl|negative-controls|NEGCTL' rust/crates/interplane-core rust/crates/interplane-crossveil rust/crates/interplane-crossaxis rust/crates/interplane-lenshift; then
103 echo "run.sh: a pipeline library mentions the negative controls" >&2; exit 1
104 fi
105 # default build refuses a variant and carries no variant code
106 (
107 cd rust
108 cargo build -q -p interplane-conformance
109 if grep -q NEGCTL_BUILT_IN "$TARGET/debug/interplane-conformance"; then
110 echo "run.sh: the default build carries variant code" >&2; exit 1
111 fi
112 rc=0; "$TARGET/debug/interplane-conformance" ../conformance/fixtures --out /dev/null --variant V4 || rc=$?
113 test "$rc" = 2
114 )
115 # negative-control matrix, offline, equals the recorded reference (every variant must be detected)
116 (cd rust && cargo run -q -p interplane-conformance --bin interplane-conformance --features negative-controls -- ../conformance/fixtures --matrix "$tmp/rust-matrix.json")
117 cmp "$tmp/rust-matrix.json" conformance/expected/negative-control-matrix.json
118 ;;
119 provenance)
120 cd provenance
121 cargo fmt --all --check
122 cargo clippy --locked --all-targets -- -D warnings
123 cargo test --locked
124 # fixture verdicts from the CLI
125 test "$(cargo run -q --locked -- verify fixtures/synthetic-full-chain)" = "PASS_LABELLED_INCOMPLETE missing=link:model_turn effect=aien-ledger-slice/1:strong proposal=scripted_turn"
126 test "$(cargo run -q --locked -- verify fixtures/synthetic-fix-the-test)" = "PASS_LABELLED_INCOMPLETE missing=link:model_turn effect=aien-ledger-slice/1:strong proposal=scripted_turn"
127 test "$(cargo run -q --locked -- verify fixtures/synthetic-weak-receipt)" = "PASS_LABELLED_INCOMPLETE missing=link:model_turn effect=record_effect_receipt/1:weak"
128 test "$(cargo run -q --locked -- verify fixtures/real-waldo-aien-chain)" = "PASS complete effect=aien-ledger-slice/1:strong proposal=model_generation/2 candidate=none"
129 test "$(cargo run -q --locked -- verify fixtures/real-waldo-tokenizer-json)" = "PASS_LABELLED_INCOMPLETE missing=link:effect,link:interplane"
130 test "$(cargo run -q --locked -- verify fixtures/real-waldo-smoke)" = "PASS_LABELLED_INCOMPLETE missing=link:aien,link:effect,link:interplane"
131 ;;
132 adapter-aien)
133 need_sibling aegis-runtime
134 need_sibling aien-protocols
135 # The hosted layout, built privately: <tmp>/interplane (this commit) beside <tmp>/interplane-audit.
136 mkdir -p "$tmp/interplane" "$tmp/interplane-audit"
137 git archive HEAD | tar -x -C "$tmp/interplane"
138 for sib in aegis-runtime aien-protocols; do
139 git clone -q --no-checkout "../$sib" "$tmp/interplane-audit/$sib"
140 done
141 # The real hosted setup step: checks out the PINS commits (already in the siblings' history,
142 # no network) and checks that the Cargo.toml git revs equal PINS.
143 "$tmp/interplane/adapters/aien/setup-siblings.sh" "$tmp"
144 . "$tmp/interplane/adapters/aien/PINS"
145 test "$(git -C "$tmp/interplane-audit/aegis-runtime" rev-parse HEAD)" = "$AEGIS_RUNTIME_REV"
146 test "$(git -C "$tmp/interplane-audit/aien-protocols" rev-parse HEAD)" = "$AIEN_PROTOCOLS_REV"
147 obs aegis_runtime_pin "\"$AEGIS_RUNTIME_REV\""
148 obs aien_protocols_pin "\"$AIEN_PROTOCOLS_REV\""
149 cd "$tmp/interplane/adapters/aien"
150 # libsqlite3-sys (via aegis-runtime) copies its bundled bindings from the registry, which is
151 # read-only on the Spark judge, so OUT_DIR/bindgen.rs is left mode 0444 in the shared target
152 # dir. When the build script runs again it cannot overwrite that file ("Could not copy
153 # bindings to output directory: Permission denied", operator run of 657081c4, 2026-10-19).
154 # Make such leftovers writable first; the build script then rewrites them.
155 if [ -d "$TARGET" ]; then
156 find "$TARGET" -path '*/build/libsqlite3-sys-*/out/*' -type f ! -perm -u+w -exec chmod u+w {} + 2>/dev/null || true
157 fi
158 cargo fmt --all --check
159 cargo clippy --all-targets -- -D warnings
160 cargo test
161 # T4 subset through the real Pipeline and AIEN authority (bench/PROTOCOL-0.3.md section 2; no skips)
162 T4_OUT="$tmp/t4-verdicts.json" cargo test --test t4_corpus -- --nocapture
163 ;;
164 *)
165 echo "run.sh: unknown step '$step'" >&2
166 exit 2
167 ;;
168esac