interplane.Get Omega
Read in your language

aienos.com

Source of www.aienos.com, served from my own hardware

Brought by drakestapleton

branch main Branches Tags History

aienos.com / om / allen-panes / check.sh

55 lines · 2299 bytes Raw Blame History
1#!/bin/sh
2# Regenerate the Allen glass panes script using the pinned arm64 omc.
3# The compiler is the one vendored for the Hive page; its pin is recorded once,
4# in ../hive-page/omc.sha256. contract.om is the canonical pane contract (owned
5# by the science protocol); its kinds, events, version and byte limits are
6# compiled into the script. CI on x86_64 checks the committed artifact against
7# its recorded hash. OMEGA_OMC overrides the compiler path, never its pin.
8# OMEGA_ACCEPT_CHANGE=1 accepts a rewritten artifact; otherwise stale output exits 4.
9# Exit 2: missing compiler; 3: wrong pin; 4: stale artifact rewritten;
10# 5: nondeterministic output; 6: empty output. Compile/run failures propagate.
11set -eu
12cd "$(dirname "$0")"
13omc=${OMEGA_OMC:-$PWD/../hive-page/omc}
14pin=$(tr -d ' \n' < ../hive-page/omc.sha256)
15if [ ! -f "$omc" ]; then
16 printf 'No compiler at %s; set OMEGA_OMC to the pinned omc (%s)\n' "$omc" "$pin" >&2
17 exit 2
18fi
19have=$(sha256sum "$omc" | cut -d' ' -f1)
20if [ "$have" != "$pin" ]; then
21 printf 'Compiler sha256 mismatch: recorded %s, found %s\n' "$pin" "$have" >&2
22 exit 3
23fi
24work=$(mktemp -d "${TMPDIR:-/tmp}/allen-panes.XXXXXX")
25trap 'rm -rf "$work"' EXIT HUP INT TERM
26# Concatenation composes Omega units; it does not implement generation in shell.
27cat contract.om panes.om > "$work/panes.om"
28"$omc" < "$work/panes.om" > "$work/panes"
29chmod +x "$work/panes"
30"$work/panes" > "$work/first.js"
31"$work/panes" > "$work/second.js"
32if ! cmp -s "$work/first.js" "$work/second.js"; then
33 printf 'allen-panes.js: generator output differs between runs\n' >&2
34 exit 5
35fi
36if [ ! -s "$work/first.js" ]; then
37 printf 'allen-panes.js: generator wrote nothing\n' >&2
38 exit 6
39fi
40artifact=../../public/js/allen-panes.js
41stale=0
42if [ ! -f "$artifact" ] || ! cmp -s "$artifact" "$work/first.js"; then
43 stale=1
44fi
45cp "$work/first.js" "$artifact"
46hash=$(sha256sum "$artifact" | cut -d' ' -f1)
47printf '%s %s\n' "$hash" "$artifact" > allen-panes.js.sha256
48printf '%s %s bytes sha256 %s\n' "$artifact" "$(wc -c < "$artifact" | tr -d ' ')" "$hash"
49printf 'omc sha256 %s\n' "$have"
50if [ "$stale" = 1 ]; then
51 printf 'Generated artifact was rewritten; commit it with its Omega sources\n' >&2
52 if [ "${OMEGA_ACCEPT_CHANGE:-0}" != 1 ]; then
53 exit 4
54 fi
55fi