aien-architecture-mv
Canonical architecture for the AIEN ecosystem: flows, boundaries, ADRs, and the map from design to implementation repositories.
Brought by drakestapleton
GitHub aien-dev/aien-architecture-mv#209 (code only)
Fetch it
curl -fsSL https://interplane.io/drakestapleton/aien-architecture-mv/patches/1a6220020aa6447c.bundle -o 1a6220020aa6447c.bundle git fetch 1a6220020aa6447c.bundle refs/pull/209/head
Provenance
github-import 1
aien-dev/aien-architecture-mv
209
0490a6fe357afe93558d058c325a1a158de47881
{"kind":"github-import","owner":"aien-dev","repo":"aien-architecture-mv","number":209,"url":"https://github.com/aien-dev/aien-architecture-mv/pull/209","export_sha256":"967c79e26a893657b5cdaa45efd442be5dbd2ecfe68e25f9a8c1b5da4d60d452","imported_utc":"2026-11-18T16:37:56Z","metadata":"unavailable","state_derived":true}
Changes
diff --git a/.aien/always b/.aien/always new file mode 100644 index 0000000..e158139 --- /dev/null +++ b/.aien/always @@ -0,0 +1,5 @@ +# Gates that run on every commit regardless of changed paths (ADR 0033 Decision 12 +# allow-list; inventory contract C6). One gate name per line. Read from the base ref. +CRUMB-VERIFY +ARCH-DOCTRINE +ARCH-QUALIFICATION-STATUS diff --git a/.aien/unmapped-ok b/.aien/unmapped-ok new file mode 100644 index 0000000..dbb6e7a --- /dev/null +++ b/.aien/unmapped-ok @@ -0,0 +1,9 @@ +# Changed paths matching these globs need only the always-run set (.aien/always). +# Everything else must be covered by a manifest's inputs or the commit is NOT_RUN. +# Conservative. Doctrine and roadmap text is still checked on every commit because +# ARCH-DOCTRINE and ARCH-QUALIFICATION-STATUS are in .aien/always. Read from the base ref. +docs/** +*.md +LICENSE +.gitignore +REPOSITORY_TREE.txt diff --git a/.aien/verify.pub b/.aien/verify.pub new file mode 100644 index 0000000..3e65411 --- /dev/null +++ b/.aien/verify.pub @@ -0,0 +1 @@ +01368e0b02dc1113ae7425ad6ab00fdf5aa7dd97e0690745918a52f051d5cf68 diff --git a/.crumb b/.crumb index 5711be6..05c4c3a 100644 --- a/.crumb +++ b/.crumb @@ -22,7 +22,7 @@ "children": [ { "digest": "70d9230285c422ca3110af8ff0a7577dbd3bd8998bfa1e88aff2e3f9d1699897", - "last_commit": "57b62d3", + "last_commit": "94fffbc", "name": "docs", "purpose": "Directory docs. Purpose not yet described by a human." }, @@ -34,26 +34,26 @@ }, { "digest": "49cbeb77d72e03b36387a66b0c379073bc64cd12a4b7487be91f4810f4e89147", - "last_commit": "0e5e0cc", + "last_commit": "94fffbc", "name": "scripts", "purpose": "Directory scripts. Purpose not yet described by a human." }, { "digest": "c23d700ed9187da8eb0363e6a06ddda1449809cbf02b0a7857c83d0a92e349e8", - "last_commit": "57b62d3", + "last_commit": "94fffbc", "name": "tools", "purpose": "Directory tools. Purpose not yet described by a human." } ], "children_root": "sha256:fd2b7a2ce273f9b7c5f60221b3ad6c57d7fd05b49fa70d3ef582d12194c92972", - "compiled_at": "2026-10-11T16:36:23Z", + "compiled_at": "2026-10-11T16:52:31Z", "compiler": "crumb-compile/1", - "digest": "sha256:38922d4b46900ea276424f661a9905e35e617b1f3037828c89660c7f559b0b22", + "digest": "sha256:4154ef72d8cef204f51aa3aacd5f2cd2c907bfd5cf02294752408a2a25941f4e", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "files": 294, - "generated_at_commit": "0e5e0cc616a8752a0e424f6db7c2d65a38b240e5", - "source_tree": "sha256:79ee3afdebe6279d7f9fffc7d7b8bd351035815dab4ffb264a999e157ed69040" + "files": 304, + "generated_at_commit": "532bc8d2cf1f08a8dc0a87ffb1f26b442aca1f93", + "source_tree": "sha256:24956fb98411dbca6ba87a397c494ca07f9f66617bf256038df3cbadc086dfc1" }, "owner_lane": "", "provenance": { diff --git a/.github/workflows/aien-verification.yml b/.github/workflows/aien-verification.yml new file mode 100644 index 0000000..49ae1a3 --- /dev/null +++ b/.github/workflows/aien-verification.yml @@ -0,0 +1,179 @@ +# AIEN Verification: the GitHub thin gate (ADR 0033 Decision 11, inventory contract C5). +# +# PHASE 2 DRAFT (2026-10-11, lane REPOS). This workflow is NOT a required check yet. It runs +# beside the existing hosted workflows so that, for N >= 3 commits, the hosted verdict and the +# locally signed bundle verdict can be compared (advisor amendment A7). Nothing here changes +# the repository's required contexts; that switch is phase 3 and needs Drake's agreement. +# +# What it does: checkout; read the trust anchors from the BASE ref (origin/main), never from +# the head under test (amendment A1); crumb verify; fetch <repo>/<sha>/bundle.json from +# aien-dev/aien-receipts; verify the bundle signature and content with the pinned aien-test +# build; run the repository's portable smoke set (gates whose requires is only "portable"). +# +# GitHub-hosted compute: this workflow compiles only the two pinned verifier tools (the crumb +# checker, and aien-test once the repository is enrolled). It never builds or tests this +# repository's own code; the portable smoke set is text scans and format checks only. +# +# PHASE 3 FLIPS (marked "PHASE3" below): a missing bundle becomes NOT_RUN (status pending with +# a retry window) instead of a neutral note, and a trust-surface change becomes a failure +# unless the operator ran it by hand (BLOCKED_OPERATOR). +name: AIEN Verification + +on: + pull_request: + push: + branches: [main] + +permissions: + contents: read + +jobs: + verify: + name: AIEN Verification + runs-on: ubuntu-latest + timeout-minutes: 30 + env: + REPO_SLUG: aien-dev/aien-architecture + AIEN_TEST_PIN: c26f4d7ac3156088469b27462390f5b08ef4f436 + RECEIPTS_RAW: https://raw.githubusercontent.com/aien-dev/aien-receipts/main + steps: + - name: Checkout the head under test + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Resolve the commit under test and the base ref + id: ids + run: | + if [ "${{ github.event_name }}" = pull_request ]; then + sha="${{ github.event.pull_request.head.sha }}" + else + sha="${{ github.sha }}" + fi + git fetch -q origin main + echo "sha=$sha" >> "$GITHUB_OUTPUT" + echo "base=$(git rev-parse origin/main)" >> "$GITHUB_OUTPUT" + echo "commit under test: $sha" + echo "base (trust anchors): $(git rev-parse origin/main)" + + - name: "Trust anchors from the base ref (A1: never from the head under test)" + id: anchors + run: | + mkdir -p "$RUNNER_TEMP/anchors" + base="${{ steps.ids.outputs.base }}" + if git show "$base:.aien/verify.pub" > "$RUNNER_TEMP/anchors/verify.pub" 2>/dev/null; then + echo "enrolled=true" >> "$GITHUB_OUTPUT" + git show "$base:.aien/always" > "$RUNNER_TEMP/anchors/always" 2>/dev/null || : > "$RUNNER_TEMP/anchors/always" + git show "$base:.aien/unmapped-ok" > "$RUNNER_TEMP/anchors/unmapped-ok" 2>/dev/null || : > "$RUNNER_TEMP/anchors/unmapped-ok" + echo "verify.pub (base): $(cat "$RUNNER_TEMP/anchors/verify.pub")" + else + echo "enrolled=false" >> "$GITHUB_OUTPUT" + echo "::notice::.aien/verify.pub is not on the base ref yet: this repository is not enrolled. Phase 2: neutral." + fi + # Trust-surface changes are run by the operator by hand (A1): BLOCKED_OPERATOR. + changed=$(git diff --name-only "$base...${{ steps.ids.outputs.sha }}" -- .aien tests/gates .github/workflows .forgejo tools/aien-test || true) + if [ -n "$changed" ]; then + echo "blocked=true" >> "$GITHUB_OUTPUT" + echo "::notice::BLOCKED_OPERATOR: this head changes the trust surface:"; echo "$changed" + # PHASE3: fail here unless an operator attestation for this sha is present. + else + echo "blocked=false" >> "$GITHUB_OUTPUT" + fi + + - name: Build the crumb tool from this repository (aien-architecture owns it) + run: | + make -C tools/crumb crumb + mkdir -p "$RUNNER_TEMP/bin" && cp tools/crumb/crumb "$RUNNER_TEMP/bin/crumb" + echo "$RUNNER_TEMP/bin" >> "$GITHUB_PATH" + git status --porcelain --untracked-files=normal + + - name: Crumbs must be exactly what the compiler produces now (stays GitHub-hosted, D11) + run: crumb verify . + + - name: Install Stable Rust Toolchain (for the pinned aien-test build and the smoke set) + if: steps.anchors.outputs.enrolled == 'true' + uses: dtolnay/rust-toolchain@stable + with: + components: rustfmt + + - name: Checkout the pinned aien-test source (aien-sovereign-core @ ${{ env.AIEN_TEST_PIN }}) + if: steps.anchors.outputs.enrolled == 'true' + uses: actions/checkout@v4 + with: + repository: aien-dev/aien-sovereign-core + ref: ${{ env.AIEN_TEST_PIN }} + path: .aien-test-src + + - name: Cache the pinned aien-test build + if: steps.anchors.outputs.enrolled == 'true' + uses: actions/cache@v4 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + .aien-test-src/target + key: aien-test-${{ runner.os }}-${{ env.AIEN_TEST_PIN }} + + - name: Build aien-test from the pin (never from the tree under test), then remove the source + if: steps.anchors.outputs.enrolled == 'true' + run: | + cargo build --release -p aien-test --manifest-path .aien-test-src/Cargo.toml + cp .aien-test-src/target/release/aien-test "$RUNNER_TEMP/bin/aien-test" 2>/dev/null || { mkdir -p "$RUNNER_TEMP/bin"; cp .aien-test-src/target/release/aien-test "$RUNNER_TEMP/bin/aien-test"; } + echo "$RUNNER_TEMP/bin" >> "$GITHUB_PATH" + rm -rf .aien-test-src + git status --porcelain --untracked-files=normal + + - name: Fetch the signed verification bundle for this commit + id: bundle + run: | + url="$RECEIPTS_RAW/aien-architecture/${{ steps.ids.outputs.sha }}/bundle.json" + echo "bundle url: $url" + if curl -fsSL "$url" -o "$RUNNER_TEMP/bundle.json"; then + echo "present=true" >> "$GITHUB_OUTPUT" + else + echo "present=false" >> "$GITHUB_OUTPUT" + echo "::notice::bundle not published yet for ${{ steps.ids.outputs.sha }} (phase 2: neutral)." + # PHASE3: exit 2 here (NOT_RUN, status pending with a retry window) instead of a neutral note. + fi + + - name: Verify the bundle with the base-ref public key + if: steps.bundle.outputs.present == 'true' && steps.anchors.outputs.enrolled == 'true' + run: | + required=$(grep -v '^#' "$RUNNER_TEMP/anchors/always" | grep -v '^$' | paste -sd, -) + set +e + aien-test verify-bundle "$RUNNER_TEMP/bundle.json" \ + --repo "github.com/$REPO_SLUG" \ + --commit "${{ steps.ids.outputs.sha }}" \ + --pubkey "$RUNNER_TEMP/anchors/verify.pub" \ + ${required:+--require "$required"} + rc=$? + set -e + echo "verify-bundle exit $rc (0 PASS, 1 FAIL, 2 NOT_RUN, 3 REJECTED)" + [ "$rc" = 0 ] || exit "$rc" + + - name: Portable smoke set (gates whose requires is only portable, named at the base ref) + if: steps.anchors.outputs.enrolled == 'true' && steps.anchors.outputs.blocked == 'false' + run: | + base="${{ steps.ids.outputs.base }}" + names=$(for f in $(git ls-tree -r --name-only "$base" -- tests/gates | grep '\.gate$'); do + git show "$base:$f" | awk ' + /^gate:/ {g=$2} + /^requires:/ {inr=1; next} + inr && /^ - / { if ($2 != "portable") other=1; next } + /^[a-z]/ {inr=0} + END { if (g != "" && !other) print g }' + done) + echo "portable smoke set: $(echo $names)" + mkdir -p "$RUNNER_TEMP/evidence" + fail=0 + for g in $names; do + echo "::group::$g" + if timeout 600 aien-test run "$g" --evidence-dir "$RUNNER_TEMP/evidence"; then echo "$g: PASS"; else echo "::error::$g: not PASS"; fail=1; fi + echo "::endgroup::" + done + exit $fail + + - name: "Not enrolled or blocked: nothing to verify in this phase" + if: steps.anchors.outputs.enrolled != 'true' || steps.anchors.outputs.blocked == 'true' + run: | + echo "AIEN Verification: neutral (enrolled=${{ steps.anchors.outputs.enrolled }}, blocked=${{ steps.anchors.outputs.blocked }}). PHASE3 turns this into a failure." diff --git a/tests/gates/arch-crumb-tool-test.gate b/tests/gates/arch-crumb-tool-test.gate new file mode 100644 index 0000000..fed6977 --- /dev/null +++ b/tests/gates/arch-crumb-tool-test.gate @@ -0,0 +1,19 @@ +# tests/gates/arch-crumb-tool-test.gate +# Mirrors hosted: crumb.yml 'Build and test the crumb tool' (make -C tools/crumb test; hosted job 15 s) +gate: ARCH-CRUMB-TOOL-TEST +manifest_version: 2 +owner: aien-architecture +requires: + - host +inputs: + - tools/crumb/ + - tests/gates/ +run: + exec: tests/gates/run.sh + args: ["crumb-tool-test"] +expects: + exit: 0 + verdict: PASS +timeout: 5m +exactness: EXACT +cache_scope: machine diff --git a/tests/gates/arch-doctrine.gate b/tests/gates/arch-doctrine.gate new file mode 100644 index 0000000..6ab86b0 --- /dev/null +++ b/tests/gates/arch-doctrine.gate @@ -0,0 +1,23 @@ +# tests/gates/arch-doctrine.gate +# Mirrors hosted: repository script scripts/check_doctrine.sh (not a hosted job; doctrine consistency, always-run) +gate: ARCH-DOCTRINE +manifest_version: 2 +owner: aien-architecture +requires: + - portable +inputs: + - scripts/check_doctrine.sh + - doctrine/ + - docs/ + - CURRENT_EXECUTION_PLAN.md + - PLAN_AUTHORITY.md + - tests/gates/ +run: + exec: tests/gates/run.sh + args: ["doctrine"] +expects: + exit: 0 + verdict: PASS +timeout: 5m +exactness: EXACT +cache_scope: portable diff --git a/tests/gates/arch-qualification-status.gate b/tests/gates/arch-qualification-status.gate new file mode 100644 index 0000000..90ec918 --- /dev/null +++ b/tests/gates/arch-qualification-status.gate @@ -0,0 +1,22 @@ +# tests/gates/arch-qualification-status.gate +# Mirrors hosted: qualification-status.yml 'sh scripts/verify-r16-status.sh omega-evidence' (hosted job 10 s; needs an omega checkout as sibling ../omega) +# cache: never because the omega evidence it reads is outside this repository. +gate: ARCH-QUALIFICATION-STATUS +manifest_version: 2 +owner: aien-architecture +requires: + - host +inputs: + - scripts/verify-r16-status.sh + - doctrine/ROADMAP.md + - tests/gates/ +run: + exec: tests/gates/run.sh + args: ["qualification-status"] +expects: + exit: 0 + verdict: PASS +timeout: 5m +exactness: EXACT +cache_scope: machine +cache: never diff --git a/tests/gates/arch-script-tests.gate b/tests/gates/arch-script-tests.gate new file mode 100644 index 0000000..cda6eab --- /dev/null +++ b/tests/gates/arch-script-tests.gate @@ -0,0 +1,20 @@ +# tests/gates/arch-script-tests.gate +# Mirrors hosted: offline tests of scripts/pr-gate.sh, rebase-crumb.sh, check_candidate.sh, check_candidate_pins.sh (not a hosted job) +gate: ARCH-SCRIPT-TESTS +manifest_version: 2 +owner: aien-architecture +requires: + - host +inputs: + - scripts/ + - tests/gates/ +run: + exec: tests/gates/run.sh + args: ["script-tests"] +expects: + exit: 0 + observe: ["script_tests_run == 4"] + verdict: PASS +timeout: 10m +exactness: EXACT +cache_scope: machine diff --git a/tests/gates/crumb.gate b/tests/gates/crumb.gate new file mode 100644 index 0000000..8a21817 --- /dev/null +++ b/tests/gates/crumb.gate @@ -0,0 +1,22 @@ +# tests/gates/crumb.gate +# Mirrors hosted: crumb.yml 'Crumbs must be exactly what the compiler produces now' (./tools/crumb/crumb verify .) +# cache: never because crumbs live in many directories and inputs are literal paths; the check is sub-second. +gate: CRUMB-VERIFY +manifest_version: 2 +owner: aien-architecture +requires: + - portable +inputs: + - .crumb + - tools/crumb/ + - tests/gates/ +run: + exec: tests/gates/run.sh + args: ["crumb-verify"] +expects: + exit: 0 + verdict: PASS +timeout: 5m +exactness: EXACT +cache_scope: portable +cache: never diff --git a/tests/gates/run.sh b/tests/gates/run.sh new file mode 100755 index 0000000..81abf6e --- /dev/null +++ b/tests/gates/run.sh @@ -0,0 +1,52 @@ +#!/usr/bin/env bash +# tests/gates/run.sh: the one entry point for the local verification gates of aien-architecture. +# Every step runs the SAME command as the hosted job it mirrors (.github/workflows/crumb.yml and +# qualification-status.yml) or the repository's own offline scripts. Manifests under tests/gates/ +# name this script plus one step word, so no manifest needs shell expansion (ADR 0028 P6). +set -euo pipefail +ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)" +cd "$ROOT" +step="${1:?usage: tests/gates/run.sh <step>}" +obs() { printf 'AIEN-OBS %s %s\n' "$1" "$2"; } + +case "$step" in + crumb-verify) + # Hosted crumb.yml step "Crumbs must be exactly what the compiler produces now". The + # binary tools/crumb/crumb is gitignored (tools/crumb/.gitignore), so building it in + # place leaves the tree clean. Needs only a C11 compiler. + make -C tools/crumb crumb + ./tools/crumb/crumb verify . + ;; + crumb-tool-test) + # Hosted crumb.yml step "Build and test the crumb tool". + make -C tools/crumb test + ;; + qualification-status) + # Hosted qualification-status.yml checks out aien-dev/omega (default branch, unpinned) + # as omega-evidence and runs the script against it. Locally the sibling ../omega plays + # that role; its commit is recorded so the receipt says which evidence was read. + if [ ! -d ../omega/evidence ]; then + echo "run.sh: ../omega is missing; the hosted job checks out aien-dev/omega as omega-evidence" >&2 + exit 3 + fi + obs sibling_omega_commit "\"$(git -C ../omega rev-parse HEAD 2>/dev/null || echo unknown)\"" + sh scripts/verify-r16-status.sh ../omega + ;; + doctrine) + # Repository script (aien-architecture#7): doctrine consistency, pure text, no network. + bash scripts/check_doctrine.sh "$ROOT" + ;; + script-tests) + # The offline tests of the repository's own operator scripts. Each builds temporary git + # repos and fake gh/crumb tools under mktemp; no network, no auth (see their headers). + for t in scripts/test_pr_gate.sh scripts/test_rebase_crumb.sh scripts/test_check_candidate.sh scripts/test_check_candidate_pins.sh; do + echo "== $t" + bash "$t" + done + obs script_tests_run 4 + ;; + *) + echo "run.sh: unknown step '$step'" >&2 + exit 2 + ;; +esac