omega-mv
Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.
Brought by drakestapleton
omega-mv / tools / c4_requal.sh
| 1 | #!/bin/sh |
| 2 | # SPDX-License-Identifier: Apache-2.0 |
| 3 | # Copyright 2026 Drake Stapleton (AIEN / aien-dev) |
| 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
| 16 | |
| 17 | # C4 requalification gate: the complete local runtime (World -> J-Space -> |
| 18 | # AEGIS/FORGE verify -> commit -> Cortex) on one machine, one repeatable task, |
| 19 | # with interruption and recovery. Refuses a dirty tree, builds and runs the |
| 20 | # committed source, stores a receipt named by its content hash: |
| 21 | # evidence/C4-REQUAL/<sha256-of-receipt>.json |
| 22 | # The receipt carries the commit of every repo of the candidate (and whether it |
| 23 | # matches the CAND-0 manifest in aien-architecture), the executable digests, |
| 24 | # the 14-step COMPOSITION-2 gate verdict, every injection case, and (with |
| 25 | # --mutants) the recovery-check mutant results. |
| 26 | # usage: tools/c4_requal.sh [--mutants] |
| 27 | # Env: MAKE_ARGS (e.g. AIENOS_LOCK_REPO=...), C4_SC_DIR, C4_PROTO_DIR, C4_ARCH_DIR. |
| 28 | set -eu |
| 29 | want_mut=0 |
| 30 | [ "${1:-}" = "--mutants" ] && want_mut=1 |
| 31 | root=$(git rev-parse --show-toplevel) |
| 32 | cd "$root" |
| 33 | if [ -n "$(git status --porcelain --untracked-files=normal)" ]; then |
| 34 | echo "c4_requal: working tree is dirty; commit first" >&2 |
| 35 | git status --short >&2 |
| 36 | exit 2 |
| 37 | fi |
| 38 | commit=$(git rev-parse HEAD) |
| 39 | sc_dir=${C4_SC_DIR:-$HOME/workspace/aien-sovereign-core} |
| 40 | proto_dir=${C4_PROTO_DIR:-$HOME/workspace/aien-protocols} |
| 41 | arch_dir=${C4_ARCH_DIR:-$HOME/workspace/aien-architecture} |
| 42 | head_of() { git -C "$1" rev-parse origin/main 2>/dev/null || echo unknown; } |
| 43 | aienos_pin=$(head -n 1 aienos.lock) |
| 44 | sc_head=$(head_of "$sc_dir"); proto_head=$(head_of "$proto_dir"); arch_head=$(head_of "$arch_dir") |
| 45 | |
| 46 | # CAND-0 pins (aien-architecture qualification/candidates/CAND-0.toml on origin/main). |
| 47 | cand=$(git -C "$arch_dir" show origin/main:qualification/candidates/CAND-0.toml 2>/dev/null || true) |
| 48 | cand_status=$(printf '%s\n' "$cand" | sed -n 's/^status *= *"\(.*\)"/\1/p' | head -n 1) |
| 49 | pin() { printf '%s\n' "$cand" | sed -n "s/^$1 *= *\"\([0-9a-f]\{40\}\)\".*/\1/p" | head -n 1; } |
| 50 | c_omega=$(pin omega); c_aienos=$(pin aienos); c_sc=$(pin aien-sovereign-core) |
| 51 | c_proto=$(pin aien-protocols); c_arch=$(pin aien-architecture) |
| 52 | m() { [ -n "$2" ] && [ "$1" = "$2" ] && echo true || echo false; } |
| 53 | |
| 54 | make ${MAKE_ARGS:-} c4-requal-bin composition-gate-bin >/dev/null |
| 55 | bin=$(make -s ${MAKE_ARGS:-} print-c4-requal-bin) |
| 56 | gbin=$(make -s ${MAKE_ARGS:-} print-composition-gate-bin) |
| 57 | work=$(mktemp -d /tmp/c4req.XXXXXX) |
| 58 | trap 'rm -rf "$work"' EXIT |
| 59 | set +e |
| 60 | "./$gbin" "$commit" "$work/composition.json" >"$work/composition.out" 2>&1 |
| 61 | gstatus=$? |
| 62 | "./$bin" "$work/injection.json" >"$work/injection.out" 2>&1 |
| 63 | istatus=$? |
| 64 | mut_status=0 |
| 65 | if [ $want_mut -eq 1 ]; then |
| 66 | tools/c4_requal_mutants.sh "$work/mutants.json" >"$work/mutants.out" 2>&1 |
| 67 | mut_status=$? |
| 68 | fi |
| 69 | set -e |
| 70 | [ -s "$work/injection.json" ] || { echo "c4_requal: no injection receipt" >&2; cat "$work/injection.out" >&2; exit 2; } |
| 71 | gverdict=$(sed -n 's/.*"verdict": "\([A-Z]*\)".*/\1/p' "$work/composition.json" | head -n 1) |
| 72 | iverdict=$(sed -n 's/.*"verdict": "\([A-Z]*\)".*/\1/p' "$work/injection.json" | head -n 1) |
| 73 | verdict=PASS |
| 74 | [ "$gstatus" -eq 0 ] && [ "$gverdict" = PASS ] || verdict=FAIL |
| 75 | [ "$istatus" -eq 0 ] && [ "$iverdict" = PASS ] || verdict=FAIL |
| 76 | [ "$mut_status" -eq 0 ] || verdict=FAIL |
| 77 | bsha=$(sha256sum "$bin" | cut -d' ' -f1); gsha=$(sha256sum "$gbin" | cut -d' ' -f1) |
| 78 | binding=NOT_BOUND |
| 79 | if [ "$cand_status" = frozen ] && [ "$(m "$commit" "$c_omega")" = true ] && [ "$(m "$aienos_pin" "$c_aienos")" = true ]; then binding=BOUND; fi |
| 80 | indent() { sed 's/^/ /' "$1"; } |
| 81 | tmp="$work/receipt.json" |
| 82 | { |
| 83 | printf '{\n "schema": "C4RequalReceiptV1",\n "gate": "C4-REQUAL",\n "verdict": "%s",\n' "$verdict" |
| 84 | printf ' "date_utc": "%s",\n' "$(date -u +%Y-%m-%dT%H:%M:%SZ)" |
| 85 | printf ' "env_class": "host CPU on the Spark (no chip, no QEMU, no network)",\n' |
| 86 | printf ' "machine": {"host": "%s", "arch": "%s", "kernel": "%s"},\n' "$(hostname)" "$(uname -m)" "$(uname -r)" |
| 87 | printf ' "tree_dirty": false,\n' |
| 88 | printf ' "repos": {\n' |
| 89 | printf ' "omega": {"commit": "%s", "exercised": true, "cand0_pin": "%s", "matches_cand0": %s},\n' "$commit" "$c_omega" "$(m "$commit" "$c_omega")" |
| 90 | printf ' "aienos": {"commit": "%s", "source": "omega aienos.lock (capability authority library built from this commit)", "exercised": true, "cand0_pin": "%s", "matches_cand0": %s},\n' "$aienos_pin" "$c_aienos" "$(m "$aienos_pin" "$c_aienos")" |
| 91 | printf ' "aien-sovereign-core": {"commit": "%s", "source": "origin/main of local clone at run time", "exercised": false, "cand0_pin": "%s", "matches_cand0": %s},\n' "$sc_head" "$c_sc" "$(m "$sc_head" "$c_sc")" |
| 92 | printf ' "aien-protocols": {"commit": "%s", "source": "origin/main of local clone at run time", "exercised": false, "cand0_pin": "%s", "matches_cand0": %s},\n' "$proto_head" "$c_proto" "$(m "$proto_head" "$c_proto")" |
| 93 | printf ' "aien-architecture": {"commit": "%s", "source": "origin/main of local clone at run time", "exercised": false, "cand0_pin": "%s", "matches_cand0": %s}\n' "$arch_head" "$c_arch" "$(m "$arch_head" "$c_arch")" |
| 94 | printf ' },\n' |
| 95 | printf ' "candidate": {"id": "CAND-0", "manifest_status": "%s", "binding": "%s", "note": "binding is BOUND only when CAND-0 is frozen and the omega and aienos commits match; this run is evidence for the listed commits, not a candidate qualification"},\n' "${cand_status:-unreadable}" "$binding" |
| 96 | printf ' "executables": {"rx_c4_requal": "%s", "rx_composition_gate": "%s", "build": "make c4-requal-bin composition-gate-bin (c4 binary is a test build, -DAIEN_TEST_BUILD=1; the composition gate binary is the production build)"},\n' "$bsha" "$gsha" |
| 97 | printf ' "composition_gate": {"verdict": "%s", "exit": %s},\n' "$gverdict" "$gstatus" |
| 98 | printf ' "known_gaps": [\n' |
| 99 | printf ' "FORGE is not on the composed path: the Skills are CPU procedures; omega_forge_realize has no caller in src/runtime (GPU tier uses the m16 native path, not FORGE)",\n' |
| 100 | printf ' "aien-sovereign-core and aien-protocols are not exercised by this chain",\n' |
| 101 | printf ' "Cortex owner is unresolved (three implementations); this gate qualifies omega rx_cortex only",\n' |
| 102 | printf ' "Fabric and remote J-Space do not exist; local only",\n' |
| 103 | printf ' "J-Space spill file is empty in this task, so corruption of spilled data is not exercised",\n' |
| 104 | printf ' "power-loss durability (fsync ordering on real media) is not tested; crashes are process exits and SIGKILL"\n' |
| 105 | printf ' ],\n' |
| 106 | printf ' "injection":\n' |
| 107 | indent "$work/injection.json" |
| 108 | if [ $want_mut -eq 1 ]; then printf ' ,\n "mutants":\n'; indent "$work/mutants.json"; else printf ' ,\n "mutants": null\n'; fi |
| 109 | printf '}\n' |
| 110 | } > "$tmp" |
| 111 | sum=$(sha256sum "$tmp" | cut -d' ' -f1) |
| 112 | mkdir -p evidence/C4-REQUAL |
| 113 | out="evidence/C4-REQUAL/$sum.json" |
| 114 | cp "$tmp" "$out" |
| 115 | chmod 0644 "$out" |
| 116 | cat "$work/injection.out" | tail -n 5 |
| 117 | [ $want_mut -eq 1 ] && cat "$work/mutants.out" # one line per mutant (an ERROR line carries the make exit code and last log lines) |
| 118 | echo "receipt: $out" |
| 119 | echo "verdict: $verdict (omega $commit, binding $binding)" |
| 120 | [ "$verdict" = PASS ] |