interplane.Get Omega
Read in your language

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

branch main Branches Tags History

omega-mv / tools / m19r_campaign.sh

91 lines · 4393 bytes Raw Blame History
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# m19r_campaign.sh -- mechanical verdict for a multi-run M19R qualification
18# campaign.
19#
20# tools/m19r_campaign.sh --campaign-dir D --runs N
21#
22# D holds one run directory per qualification run (each written by
23# tools/m19r_qualify.sh --evidence-root D). Writes D/campaign.json at first
24# use (sha, rule, created_at) and prints + writes D/final-verdict.json.
25#
26# Rule, evaluated in this order:
27# INVALID any run directory lacks run.json or verdict.json, lacks
28# hashes.sha256, or fails `sha256sum -c hashes.sha256`
29# (also: extra files not covered by hashes are NOT detected,
30# only altered or missing hashed files).
31# FAIL any run whose status is not PASS (a failed mandatory gate or
32# step; QUICK_PASS is not a full PASS).
33# INCOMPLETE fewer than N usable (verified) run directories.
34# PASS at least N usable runs, all with status PASS.
35# Exit 0 only on PASS; 1 on any other verdict; 2 on bad arguments.
36# Shell + coreutils + git + jq. No Python.
37
38campaign_rule='PASS = N completed runs all status PASS; FAIL = any completed run not PASS; INCOMPLETE = fewer than N usable run dirs; INVALID = any run dir missing run.json/verdict.json/hashes.sha256 or failing sha256sum -c (checked first)'
39
40campaign_main() {
41 local dir= n= d id status invalid=() failed=() usable=0 verdict here sha
42 while [ $# -gt 0 ]; do
43 case $1 in
44 --campaign-dir) dir=${2:-}; shift;;
45 --campaign-dir=*) dir=${1#*=};;
46 --runs) n=${2:-}; shift;;
47 --runs=*) n=${1#*=};;
48 *) echo "usage: m19r_campaign.sh --campaign-dir D --runs N" >&2; return 2;;
49 esac
50 shift
51 done
52 if [ -z "$dir" ] || [ ! -d "$dir" ] || ! [[ ${n:-} =~ ^[1-9][0-9]*$ ]]; then
53 echo "usage: m19r_campaign.sh --campaign-dir D --runs N (D must exist, N >= 1)" >&2
54 return 2
55 fi
56 here=$(cd -P "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)
57 if [ ! -e "$dir/campaign.json" ]; then
58 sha=$(git -C "$here" rev-parse HEAD 2> /dev/null || echo unknown)
59 jq -n --arg sha "$sha" --arg rule "$campaign_rule" --argjson runs "$n" \
60 --arg at "$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
61 '{sha: $sha, rule: $rule, runs_required: $runs, created_at: $at}' > "$dir/campaign.json"
62 fi
63 for d in "$dir"/*/; do
64 [ -d "$d" ] || continue
65 id=$(basename "$d")
66 if [ ! -f "$d/run.json" ] || [ ! -f "$d/verdict.json" ] || [ ! -f "$d/hashes.sha256" ]; then
67 invalid+=("$id: missing run.json, verdict.json or hashes.sha256"); continue
68 fi
69 if ! (cd "$d" && sha256sum --quiet -c hashes.sha256 > /dev/null 2>&1); then
70 invalid+=("$id: hashes.sha256 does not verify"); continue
71 fi
72 status=$(jq -r '.status' "$d/verdict.json" 2> /dev/null)
73 if [ -z "$status" ] || [ "$status" = null ]; then
74 invalid+=("$id: verdict.json unreadable"); continue
75 fi
76 usable=$((usable + 1))
77 [ "$status" = PASS ] || failed+=("$id: $status")
78 done
79 if [ ${#invalid[@]} -gt 0 ]; then verdict=INVALID
80 elif [ ${#failed[@]} -gt 0 ]; then verdict=FAIL
81 elif [ "$usable" -lt "$n" ]; then verdict=INCOMPLETE
82 else verdict=PASS; fi
83 jq -n --arg v "$verdict" --argjson n "$n" --argjson usable "$usable" \
84 --argjson invalid "$(printf '%s\n' "${invalid[@]}" | jq -Rn '[inputs | select(length > 0)]')" \
85 --argjson failed "$(printf '%s\n' "${failed[@]}" | jq -Rn '[inputs | select(length > 0)]')" \
86 '{verdict: $v, runs_required: $n, usable_runs: $usable, invalid: $invalid, failed: $failed}' > "$dir/final-verdict.json"
87 cat "$dir/final-verdict.json"
88 [ "$verdict" = PASS ]
89}
90
91campaign_main "$@"