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 / hive-page / check.sh

83 lines · 3496 bytes Raw Blame History
1#!/bin/sh
2# Regenerate the Hive skeleton and browser scripts using the pinned arm64 omc.
3# CI on x86_64 checks the committed artifacts against their recorded hashes;
4# Pages also runs the skeleton digest test before deployment.
5# OMEGA_OMC overrides the compiler path, never its pin.
6# OMEGA_ACCEPT_CHANGE=1 accepts rewritten artifacts; otherwise stale output exits 4.
7# Exit 2: missing compiler; 3: wrong pin; 4: stale artifact rewritten;
8# 5: nondeterministic output; 6: empty output. Compile/run failures propagate.
9set -eu
10cd "$(dirname "$0")"
11omc=${OMEGA_OMC:-$PWD/omc}
12pin=$(tr -d ' \n' < omc.sha256)
13if [ ! -f "$omc" ]; then
14 printf 'No compiler at %s; set OMEGA_OMC to the pinned omc (%s)\n' "$omc" "$pin" >&2
15 exit 2
16fi
17have=$(sha256sum "$omc" | cut -d' ' -f1)
18if [ "$have" != "$pin" ]; then
19 printf 'Compiler sha256 mismatch: recorded %s, found %s\n' "$pin" "$have" >&2
20 exit 3
21fi
22irwasm=${OMEGA_IRWASM:-$PWD/irwasm}
23irpin=$(tr -d ' \n' < irwasm.sha256)
24if [ ! -f "$irwasm" ]; then
25 printf 'No IR wasm backend at %s; expected %s\n' "$irwasm" "$irpin" >&2
26 exit 2
27fi
28irhave=$(sha256sum "$irwasm" | cut -d' ' -f1)
29if [ "$irhave" != "$irpin" ]; then
30 printf 'IR wasm backend sha256 mismatch: recorded %s, found %s\n' "$irpin" "$irhave" >&2
31 exit 3
32fi
33work=$(mktemp -d "${TMPDIR:-/tmp}/hive-page.XXXXXX")
34trap 'rm -rf "$work"' EXIT HUP INT TERM
35# One executable shares the contract between markup (fd 1) and hydrator (fd 3).
36# Concatenation composes Omega units; it does not implement generation in shell.
37cat contract.om freshness-js.om hive.om hive-js.om > "$work/hive.om"
38"$omc" < "$work/hive.om" > "$work/hive"
39"$omc" < turing-look.om > "$work/turing"
40chmod +x "$work/hive" "$work/turing"
41"$work/hive" > "$work/first.html" 3> "$work/first.hive.js"
42"$work/hive" > "$work/second.html" 3> "$work/second.hive.js"
43"$work/turing" > "$work/first.turing.js"
44"$work/turing" > "$work/second.turing.js"
45{ printf 'ir\n'; cat fresh.om; } > "$work/fresh.ir.om"
46"$omc" < "$work/fresh.ir.om" > "$work/fresh.ir"
47"$irwasm" < "$work/fresh.ir" > "$work/first.fresh.wasm"
48"$irwasm" < "$work/fresh.ir" > "$work/second.fresh.wasm"
49stale=0
50publish() {
51 first=$1
52 second=$2
53 artifact=$3
54 sidecar=$4
55 if ! cmp -s "$first" "$second"; then
56 printf '%s: generator output differs between runs\n' "$artifact" >&2
57 exit 5
58 fi
59 if [ ! -s "$first" ]; then
60 printf '%s: generator wrote nothing\n' "$artifact" >&2
61 exit 6
62 fi
63 if [ ! -f "$artifact" ] || ! cmp -s "$artifact" "$first"; then
64 stale=1
65 fi
66 cp "$first" "$artifact"
67 hash=$(sha256sum "$artifact" | cut -d' ' -f1)
68 printf '%s %s\n' "$hash" "$artifact" > "$sidecar"
69 printf '%s %s bytes sha256 %s\n' "$artifact" "$(wc -c < "$artifact" | tr -d ' ')" "$hash"
70}
71publish "$work/first.html" "$work/second.html" main.html main.html.sha256
72publish "$work/first.hive.js" "$work/second.hive.js" ../../public/js/hive.js hive.js.sha256
73publish "$work/first.turing.js" "$work/second.turing.js" ../../public/js/turing-look.js turing-look.js.sha256
74mkdir -p ../../public/wasm
75publish "$work/first.fresh.wasm" "$work/second.fresh.wasm" ../../public/wasm/hive-fresh.wasm ../../public/wasm/hive-fresh.wasm.sha256
76printf 'irwasm sha256 %s\n' "$irhave"
77printf 'omc sha256 %s\n' "$have"
78if [ "$stale" = 1 ]; then
79 printf 'Generated artifacts were rewritten; commit them with their Omega sources\n' >&2
80 if [ "${OMEGA_ACCEPT_CHANGE:-0}" != 1 ]; then
81 exit 4
82 fi
83fi