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 / tests / algebra / ma_digital_v1_check_evidence.sh

72 lines · 2852 bytes Raw Blame History
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# Content check for MIXED_ALGEBRA_DIGITAL_V1 wrapper receipts
18# (spec/mixed-algebra-digital-v1.md, post-run addenda 2026-09-29).
19#
20# For every evidence/MIXED_ALGEBRA/digital_v1/<name>.json under ROOT
21# (default: current directory = repository root):
22# 1. sha256 of the file bytes must equal <name>;
23# 2. every receipt the wrapper cites ("path": ..., "sha256": ... in its
24# receipts array) must exist under ROOT and re-hash to that digest.
25# Complements check-mixed-algebra-evidence (which only compares against git
26# HEAD): this one also catches a tampered file that was committed.
27# Exit: 0 PASS, 1 FAIL, 2 error.
28set -u
29ROOT=${1:-.}
30DIR="$ROOT/evidence/MIXED_ALGEBRA/digital_v1"
31[ -d "$DIR" ] || { echo "check-mixed-algebra-digital-v1-evidence: no $DIR"; exit 2; }
32nw=0 nr=0 bad=0
33for f in "$DIR"/*.json; do
34 [ -f "$f" ] || continue
35 nw=$((nw + 1))
36 name=$(basename "$f" .json)
37 h=$(sha256sum "$f" | cut -c1-64)
38 if [ "$h" != "$name" ]; then
39 echo "FAIL: $f hashes to $h, not its name"
40 bad=$((bad + 1))
41 fi
42 pairs=$(sed -n 's/.*"path": "\([^"]*\)", "sha256": "\([0-9a-f]\{64\}\)".*/\1 \2/p' "$f")
43 if [ -z "$pairs" ]; then
44 echo "FAIL: $f cites no receipts"
45 bad=$((bad + 1))
46 continue
47 fi
48 cited=0
49 while read -r p d; do
50 cited=$((cited + 1))
51 nr=$((nr + 1))
52 if [ ! -f "$ROOT/$p" ]; then
53 echo "FAIL: $name cites missing receipt $p"
54 bad=$((bad + 1))
55 continue
56 fi
57 rh=$(sha256sum "$ROOT/$p" | cut -c1-64)
58 if [ "$rh" != "$d" ]; then
59 echo "FAIL: $name cites $p with sha256 $d, file now hashes to $rh"
60 bad=$((bad + 1))
61 fi
62 done <<PAIRS
63$pairs
64PAIRS
65 echo " $name: self-hash ok=$([ "$h" = "$name" ] && echo yes || echo no), $cited cited receipts checked"
66done
67[ "$nw" -gt 0 ] || { echo "check-mixed-algebra-digital-v1-evidence: FAIL (no wrapper receipts)"; exit 1; }
68if [ "$bad" -ne 0 ]; then
69 echo "check-mixed-algebra-digital-v1-evidence: FAIL ($bad problems, $nw wrappers, $nr cited receipts)"
70 exit 1
71fi
72echo "check-mixed-algebra-digital-v1-evidence: PASS ($nw wrappers, $nr cited receipts re-hashed)"