interplane.Get Omega
Read in your language

aien-architecture-mv

Canonical architecture for the AIEN ecosystem: flows, boundaries, ADRs, and the map from design to implementation repositories.

Brought by drakestapleton

branch main Branches Tags History

aien-architecture-mv / tools / name-check / gate.sh

34 lines · 1952 bytes Raw Blame History
1#!/bin/sh
2# Bootstrap trust boundary, as in ../doctrine/gate.sh: authenticate AIEN_OMC against
3# ../zero-legacy/omega.pin before executing it. The judgments are made in namecheck.om and gate.om;
4# this script only selects the change under review and hands its git diff to them.
5# gate.sh ROOT [BASE] BASE defaults to origin/main when it exists, else HEAD~1; the change is
6# merge-base(BASE, HEAD)..HEAD.
7set -eu
8root="${1:?usage: gate.sh ROOT [BASE]}"
9base="${2:-}"
10# ROOT is resolved against the caller's directory before this script changes directory
11root=$(cd "$root" && pwd) || { echo "gate.sh: ROOT $1 is not a directory" >&2; exit 2; }
12cd "$(dirname "$0")"
13not_run() { echo "gate.sh: AIEN_OMC is unavailable or not independently pinned (NOT_RUN)" >&2; exit 3; }
14[ -n "${AIEN_OMC:-}" ] && [ -x "$AIEN_OMC" ] || not_run
15want=$(sed -n 's/^omc_sha256: //p' ../zero-legacy/omega.pin) || not_run
16[ "${#want}" -eq 64 ] || not_run
17case "$want" in *[!0-9a-f]*) not_run ;; esac
18have=$(sha256sum -- "$AIEN_OMC") || not_run
19have=${have%% *}
20[ "$have" = "$want" ] || not_run
21if [ -z "$base" ]; then
22 if git -C "$root" rev-parse -q --verify origin/main >/dev/null; then base=origin/main; else base=HEAD~1; fi
23fi
24mb=$(git -C "$root" merge-base "$base" HEAD) || { echo "gate.sh: no merge base with $base" >&2; exit 2; }
25mkdir -p build
26# fixed prefixes and no textconv, whatever the user or repository config says (diff.noprefix,
27# diff.mnemonicPrefix, textconv drivers): the judge must see the bytes git stores, under b/PATH
28git -C "$root" -c core.quotePath=false diff --no-color --no-ext-diff --no-textconv \
29 --src-prefix=a/ --dst-prefix=b/ -U0 "$mb" HEAD > build/change.diff
30printf 'AIEN-OBS name_check_base "%s"\n' "$mb"
31"$AIEN_OMC" < gate.om > build/gate
32chmod +x build/gate
33[ -s build/gate ] || { echo "gate.sh: AIEN_OMC produced no program from gate.om (NOT_RUN)" >&2; exit 3; }
34exec build/gate "$AIEN_OMC" build/change.diff