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 / rx_host_receipts.sh
| 1 | #!/bin/bash |
| 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 | # rx_host_receipts.sh -- summarise and check the resident-reaction receipts in |
| 18 | # the "Emit qualification receipt" step of .github/workflows/rx-host.yml. |
| 19 | # |
| 20 | # tools/rx_host_receipts.sh heartbeat RECEIPT (R1-R6 heartbeat) |
| 21 | # tools/rx_host_receipts.sh native RECEIPT CANDIDATE (R7 native authority) |
| 22 | # tools/rx_host_receipts.sh generation RECEIPT CANDIDATE (R9 generation barrier) |
| 23 | # |
| 24 | # Prints the summary lines to stdout (Python-style True/False/None, as the |
| 25 | # retired inline python3 blocks did). native and generation then check the |
| 26 | # receipt is bound to CANDIDATE, came from a clean tree and has a non-empty, |
| 27 | # matching Linux/native differential; generation also needs >= 8 coherent |
| 28 | # crash recoveries covering lineages 1 and 2, each GENESIS or CANDIDATE. |
| 29 | # A failed check prints its reason on stderr and exits 1. Shell + jq + |
| 30 | # sha256sum; no Python. |
| 31 | set -u |
| 32 | |
| 33 | # Python str() of a JSON value for the summary lines. |
| 34 | PY='def py: if . == true then "True" elif . == false then "False" |
| 35 | elif . == null then "None" elif type == "string" then . else tojson end; |
| 36 | def req($k): if type == "object" and has($k) then .[$k] |
| 37 | else error("receipt has no \"\($k)\"") end; |
| 38 | def falsy: . == null or . == false or . == 0 or . == "" or . == [] or . == {};' |
| 39 | |
| 40 | die() { echo "$1" >&2; exit 1; } |
| 41 | |
| 42 | summary() { jq -r "$PY $1" "$2" || exit 1; } |
| 43 | |
| 44 | # check PROGRAM FILE CANDIDATE -- PROGRAM yields "" or a failure reason. |
| 45 | check() { |
| 46 | local msg |
| 47 | msg=$(jq -r --arg candidate "$3" "$PY $1" "$2") || exit 1 |
| 48 | [ -z "$msg" ] || die "$msg" |
| 49 | } |
| 50 | |
| 51 | mode=${1:?usage: rx_host_receipts.sh heartbeat|native|generation RECEIPT [CANDIDATE]} |
| 52 | path=${2:?receipt path required} |
| 53 | [ -r "$path" ] || die "cannot read $path" |
| 54 | jq empty "$path" || exit 1 |
| 55 | |
| 56 | case $mode in |
| 57 | heartbeat) |
| 58 | summary '"test totals: tests=\(req("totals") | req("tests") | py) passed=\(.totals | req("tests_passed") | py) checks=\(.totals | req("checks") | py) failures=\(.totals | req("failures") | py)"' "$path" |
| 59 | echo "receipt: $path" |
| 60 | echo "receipt hash: $(sha256sum < "$path" | cut -d' ' -f1)" |
| 61 | summary 'req("gates") as $g |
| 62 | | ("R1_CANONICAL_SHARED_WORLD_PASS", "R2_CROSS_ENGINE_ABI_PASS", |
| 63 | "R3_REACTION_CORE", "R4_CAUSAL_TRACE", |
| 64 | "R5_RESOURCE_ARBITRATION", "R6_REACTION_STABILITY") as $n |
| 65 | | "gate \($n): \(if ($g | has($n)) then ($g[$n] | py) else "missing" end)"' "$path" |
| 66 | summary '"not-claimed gates: \(.gates.not_claimed // [] | join(", "))", |
| 67 | "hardware scope: \(.hardware_scope | py)"' "$path" |
| 68 | ;; |
| 69 | native) |
| 70 | candidate=${3:?candidate commit required} |
| 71 | echo "native receipt: $path" |
| 72 | echo "native receipt hash: $(sha256sum < "$path" | cut -d' ' -f1)" |
| 73 | summary '"native candidate: \(.candidate_commit | py)", |
| 74 | "native candidate bound: \(.candidate_bound | py)", |
| 75 | "native tree dirty: \(.tree_dirty | py)", |
| 76 | "native aienos: \(.aienos_commit | py)", |
| 77 | "native gate: \(req("gates") | .R7_NATIVE_AUTHORITY | py)", |
| 78 | "native differential rows: \(.differential // [] | length)"' "$path" |
| 79 | check '(.differential // []) as $d |
| 80 | | if .candidate_commit != $candidate or .candidate_bound != true |
| 81 | then "native receipt is not bound to this candidate" |
| 82 | elif .tree_dirty != false |
| 83 | then "native receipt was produced from a dirty tree" |
| 84 | elif ($d | length) == 0 or any($d[]; .linux != .native) |
| 85 | then "native differential is empty or mismatched" |
| 86 | else "" end' "$path" "$candidate" |
| 87 | ;; |
| 88 | generation) |
| 89 | candidate=${3:?candidate commit required} |
| 90 | echo "generation receipt: $path" |
| 91 | summary '"generation candidate bound: \(.candidate_bound | py)", |
| 92 | "generation gate: \(req("gates") | .R9_GENERATION_BARRIER | py)", |
| 93 | "generation crash rows: \(.crashes // [] | length)"' "$path" |
| 94 | check '(.differential // []) as $d | (.crashes // []) as $c |
| 95 | | if .candidate_commit != $candidate or .candidate_bound != true |
| 96 | then "generation receipt is not bound to this candidate" |
| 97 | elif .tree_dirty != false or .failures != 0 |
| 98 | then "generation receipt was not a clean passing run" |
| 99 | elif ($d | length) == 0 or any($d[]; .linux != .native) |
| 100 | then "generation differential is empty or mismatched" |
| 101 | elif ($c | length) < 8 or ([$c[] | .lineage] | unique) != [1, 2] |
| 102 | then "generation crash recoveries did not cover both generations" |
| 103 | elif any($c[]; .coherent | falsy) |
| 104 | then "a crash recovery was not coherent" |
| 105 | elif any($c[]; .evidence != "GENESIS" and .evidence != "CANDIDATE") |
| 106 | then "a crash recovery mixed generations" |
| 107 | else "" end' "$path" "$candidate" |
| 108 | ;; |
| 109 | *) die "unknown receipt kind: $mode" ;; |
| 110 | esac |