From a79950f8d06baa7e7302a8b39d9e9515a62a95ce Mon Sep 17 00:00:00 2001 From: Drake Stapleton Date: Fri, 16 Oct 2026 03:49:59 -0500 Subject: [PATCH] ci: enroll synapse in the Spark verification pipeline (ADR 0033 phase 2) .aien/verify.pub is the same Spark public key as the other enrolled repos. tests/gates mirror the hosted portable workflow: SYNAPSE-WORKSPACE and SYNAPSE-CONFORMANCE run `bash scripts/ci/portable.sh ` exactly as the hosted matrix does (conformance gets aien-architecture at the same pin from a local clone of the worker's sibling, no network); both are always-run because the hosted workflow has no path filter. SYNAPSE-ZERO-DISK-SECRETS is the always-run invariant of the Rust repos. AIEN Verification is the phase 2 (neutral) thin gate; the phase 3 flip follows once this is on main. Verified locally: run.sh workspace and conformance both PASS (Rust 1.98.1); aien-test list sees the three gates. Co-Authored-By: Claude Opus 5.5 --- .aien/always | 8 + .aien/unmapped-ok | 10 ++ .aien/verify.pub | 1 + .github/workflows/aien-verification.yml | 169 +++++++++++++++++++++ tests/gates/run.sh | 53 +++++++ tests/gates/synapse-conformance.gate | 23 +++ tests/gates/synapse-workspace.gate | 23 +++ tests/gates/synapse-zero-disk-secrets.gate | 19 +++ 8 files changed, 306 insertions(+) create mode 100644 .aien/always create mode 100644 .aien/unmapped-ok create mode 100644 .aien/verify.pub create mode 100644 .github/workflows/aien-verification.yml create mode 100755 tests/gates/run.sh create mode 100644 tests/gates/synapse-conformance.gate create mode 100644 tests/gates/synapse-workspace.gate create mode 100644 tests/gates/synapse-zero-disk-secrets.gate diff --git a/.aien/always b/.aien/always new file mode 100644 index 0000000..bc37242 --- /dev/null +++ b/.aien/always @@ -0,0 +1,8 @@ +# 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. +# The hosted portable workflow runs both of its gates on every pull request (no path +# filter), so both are always-run here too. This repository's crumb is not compiled +# by any hosted check, so there is no CRUMB-VERIFY gate. +SYNAPSE-WORKSPACE +SYNAPSE-CONFORMANCE +SYNAPSE-ZERO-DISK-SECRETS diff --git a/.aien/unmapped-ok b/.aien/unmapped-ok new file mode 100644 index 0000000..22b2609 --- /dev/null +++ b/.aien/unmapped-ok @@ -0,0 +1,10 @@ +# 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. +# The always-run set already holds both hosted gates, so this list only stops pure +# documentation and metadata from being reported as unmapped. Read from the base ref. +docs/** +*.md +LICENSE +.gitignore +.goals.json +assets/** 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/.github/workflows/aien-verification.yml b/.github/workflows/aien-verification.yml new file mode 100644 index 0000000..1382bbd --- /dev/null +++ b/.github/workflows/aien-verification.yml @@ -0,0 +1,169 @@ +# 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); fetch //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 pinned verifier tool aien-test, and +# only once the repository is enrolled (no crumb check: no hosted check compiles this repository's crumb). 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/synapse + 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: 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-spark/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/synapse/${{ 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/run.sh b/tests/gates/run.sh new file mode 100755 index 0000000..aea3cc4 --- /dev/null +++ b/tests/gates/run.sh @@ -0,0 +1,53 @@ +#!/usr/bin/env bash +# tests/gates/run.sh: the one entry point for the local verification gates of synapse. +# Every step runs the SAME command as the hosted job it mirrors (.github/workflows/portable.yml, +# matrix gate workspace|conformance: `bash scripts/ci/portable.sh `). Manifests under +# tests/gates/ name this script plus one step word, so no manifest needs shell expansion +# (ADR 0028 P6). Observations print as "AIEN-OBS ". +# +# Sibling checkout (conformance): the hosted job checks out aien-spark/aien-architecture at the +# pin below as .ci-architecture. Here the worker provides ../aien-architecture (main); this +# script makes a local clone of it at the pin in a temp dir (no network), so the pinned +# checkout portable.sh insists on (HEAD == pin) exists without touching the sibling. +set -euo pipefail +ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)" +cd "$ROOT" +step="${1:?usage: tests/gates/run.sh }" +obs() { printf 'AIEN-OBS %s %s\n' "$1" "$2"; } +ARCH_PIN=29780e56c9e6b9111d884e0d4b146737228c19f6 +tmp=$(mktemp -d) +trap 'rm -rf "$tmp"' EXIT +# Evidence goes outside the tree (hosted: target/ci-evidence, uploaded as an artifact). +export CI_EVIDENCE_DIR="$tmp/ci-evidence" +export CARGO_TERM_COLOR=never + +case "$step" in + workspace) + bash scripts/ci/portable.sh workspace + ;; + conformance) + if [ ! -d ../aien-architecture ]; then + echo "run.sh: ../aien-architecture is missing; the hosted job checks out aien-spark/aien-architecture at $ARCH_PIN" >&2 + exit 3 + fi + obs sibling_aien_architecture_commit "\"$(git -C ../aien-architecture rev-parse HEAD 2>/dev/null || echo unknown)\"" + git clone -q --no-checkout ../aien-architecture "$tmp/arch" + git -C "$tmp/arch" checkout -q --detach "$ARCH_PIN" + obs architecture_pin "\"$ARCH_PIN\"" + AIEN_ARCHITECTURE_REPO="$tmp/arch" bash scripts/ci/portable.sh conformance + ;; + zero-disk-secrets) + echo "Auditing repository for prohibited plaintext secret files..." + if find . -maxdepth 4 -name ".env*" -not -path "*/.git/*" -not -path "*/target/*" | grep -q .; then + echo "Prohibited plaintext .env file found. Use an approved AIEN SecretProvider." + obs env_files_found true + exit 1 + fi + obs env_files_found false + echo "Zero plaintext .env files verified." + ;; + *) + echo "run.sh: unknown step '$step'" >&2 + exit 2 + ;; +esac diff --git a/tests/gates/synapse-conformance.gate b/tests/gates/synapse-conformance.gate new file mode 100644 index 0000000..1b37739 --- /dev/null +++ b/tests/gates/synapse-conformance.gate @@ -0,0 +1,23 @@ +# tests/gates/synapse-conformance.gate +# Mirrors hosted: portable.yml matrix gate 'conformance' (bash scripts/ci/portable.sh conformance, Rust 1.98.1) +gate: SYNAPSE-CONFORMANCE +manifest_version: 2 +owner: synapse +requires: + - host +inputs: + - Cargo.toml + - Cargo.lock + - crates/ + - scripts/ + - evidence/ + - tests/gates/ +run: + exec: tests/gates/run.sh + args: ["conformance"] +expects: + exit: 0 + verdict: PASS +timeout: 30m +exactness: EXACT +cache_scope: machine diff --git a/tests/gates/synapse-workspace.gate b/tests/gates/synapse-workspace.gate new file mode 100644 index 0000000..df2e003 --- /dev/null +++ b/tests/gates/synapse-workspace.gate @@ -0,0 +1,23 @@ +# tests/gates/synapse-workspace.gate +# Mirrors hosted: portable.yml matrix gate 'workspace' (bash scripts/ci/portable.sh workspace, Rust 1.98.1) +gate: SYNAPSE-WORKSPACE +manifest_version: 2 +owner: synapse +requires: + - host +inputs: + - Cargo.toml + - Cargo.lock + - crates/ + - scripts/ + - evidence/ + - tests/gates/ +run: + exec: tests/gates/run.sh + args: ["workspace"] +expects: + exit: 0 + verdict: PASS +timeout: 30m +exactness: EXACT +cache_scope: machine diff --git a/tests/gates/synapse-zero-disk-secrets.gate b/tests/gates/synapse-zero-disk-secrets.gate new file mode 100644 index 0000000..0659f5c --- /dev/null +++ b/tests/gates/synapse-zero-disk-secrets.gate @@ -0,0 +1,19 @@ +# tests/gates/synapse-zero-disk-secrets.gate +# Mirrors hosted: no hosted step; the zero-disk-secrets invariant of the Rust repos (always-run) +gate: SYNAPSE-ZERO-DISK-SECRETS +manifest_version: 2 +owner: synapse +requires: + - portable +inputs: + - tests/gates/ +run: + exec: tests/gates/run.sh + args: ["zero-disk-secrets"] +expects: + exit: 0 + observe: ["env_files_found == false"] + verdict: PASS +timeout: 2m +exactness: EXACT +cache_scope: portable