Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/interplane-forge/blob/main/server/tests/readmefirst.sh # interplane-forge INTERPLANE Forge Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `interplane-forge / server / tests / readmefirst.sh` 359 lines ยท 26329 bytes Raw Blame History 1 #!/usr/bin/env bash 2 # server/tests/readmefirst.sh: gates of the README-first project page (server/state.om, server/pages.om 3 # frepohd / fpjdev1 / fpjdev2 / frepoli, browse/c1_page.om brhome). 4 # READMEFIRST_BASE= bash server/tests/readmefirst.sh 5 # (spark; FORGED_CPUS default 16-18; READMEFIRST_PORT default 19873, the base build uses PORT+1) 6 # READMEFIRST_BASE is required: the commit whose pages this head must keep (Radicle main before the 7 # change). Two trial copies, HEAD and BASE, run with the same temporary allow-list, storage (links to 8 # the real repositories, read-only) and data dirs; nothing live is touched (not 18480, not ~/forge-data). 9 # A. Records, for 5 sample projects (hop, omega-harness, omega-mv, interplane.io, aien-receipts) and 10 # every page address they had: the same status (and redirect target) on both builds; JSON and raw 11 # bodies byte-identical (the repo JSON apart from the Radicle removal: bare rid, clone and counts 12 # objects checked on their own); on every HTML page, every record of the base page (each link 13 # target, each text, each 7 to 64 digit hex run, each bold number) is still in the head page 14 # outside the project header, except the Radicle records removed on purpose (the header is checked 15 # on its own: description, owner link, the counts lines and the clone panel, which moved to the 16 # "For developers" section of the project home); the README article is the same apart from the 17 # "leaves this site" class. 18 # Negative control: a head mutant whose project home drops the clone panel must fail A. 19 # B. State: the label of each project equals an independent reading of the receipts list (a shell walk 20 # of the chain the way verify.sh does it, plus the evidence file hashes), on the real list (hop 21 # checked, the other four not) and on six made-up site repositories: a valid list naming 22 # omega-harness, the same list with one byte changed in its first record, an evidence file that does 23 # not match its name, a SOURCE record naming a longer RID, no list at all, and a BUILD record that 24 # names the project's current head. Negative control: a mutant that skips the chain check must show 25 # the changed list as checked, and the test must catch it. 26 # C. A made-up project whose README is browse/tests/md/hostile.md: no script, frame, object, style, 27 # event handler or remote image in the page; the page's Content-Security-Policy is sent; every link 28 # that leaves the site is marked. A made-up project without a README: the plain note and its files. 29 # D. Words: the project header and tabs (everything above the README) and the explore page's own text 30 # hold none of RID, delegate, seed, patch, refs, HEAD; the "For developers" section explains the 31 # words it uses (delegate, refs and HEAD, patch, receipt). 32 set -u 33 cd "$(dirname "$0")/../.." 34 ROOT=$(pwd) 35 CORES=${FORGED_CPUS:-16-18} 36 PORT=${READMEFIRST_PORT:-19873} 37 PORTB=$((PORT + 1)) 38 OMC=$HOME/work/flux/omega-mv/seed/out/omc 39 STORE=$HOME/.radicle/storage 40 if [ -z "${READMEFIRST_BASE:-}" ]; then echo "NOT_RUN: READMEFIRST_BASE is not set (the commit whose pages this head must keep)"; exit 3; fi 41 BASE=$READMEFIRST_BASE 42 git rev-parse -q --verify "$BASE^{commit}" > /dev/null || { echo "NOT_RUN: base $BASE is not in this clone"; exit 3; } 43 for p in $PORT $PORTB; do if ss -ltn | grep -q "127.0.0.1:$p "; then echo "NOT_RUN: port $p busy"; exit 3; fi; done 44 T=$(mktemp -d /tmp/readmefirst.XXXXXX) 45 pid=; pidb= 46 pass=0; fail=0 47 ok() { pass=$((pass+1)); echo "PASS $*"; } 48 bad() { fail=$((fail+1)); echo "FAIL $*"; } 49 cleanup() { [ -n "$pid" ] && kill "$pid" 2>/dev/null; [ -n "$pidb" ] && kill "$pidb" 2>/dev/null; wait 2>/dev/null; [ -n "${KEEP:-}" ] || rm -rf "$T"; } 50 trap cleanup EXIT 51 run() { taskset -c "$CORES" nice -n 10 "$@"; } 52 53 rid() { sed -n "s/^| $1 | rad:\(z[1-9A-HJ-NP-Za-km-z]*\) |.*/\1/p" "$HOME/handoffs/radicle/RIDS.md" | head -1; } 54 NAMES="hop omega-harness omega-mv interplane.io aien-receipts" 55 SITE=`z399yKvnXcBQNkKoq86iBDgTvQ5QV` 56 # made-up RIDs: base58 (no 0, O, I or l), 29 characters like the real ones 57 HOSTILE=`z2hostyeXXXXXXXXXXXXXXXXXXXXX` 58 NORD=`z2noreadmeXXXXXXXXXXXXXXXXXXX` 59 mkdir -p "$T/storage" "$T/data/logs" "$T/datab/logs" "$T/ng" "$T/bin" 60 : > "$T/ng/dl.log"; : > "$T/ng/access.log"; : > "$T/ng/wal" 61 cp server/tests/fake/rad server/tests/fake/getent "$T/bin/"; chmod 755 "$T/bin/rad" "$T/bin/getent" 62 { 63 echo "# test table"; echo 64 echo "| repo | RID | default branch | head sha | source dir | UTC |" 65 echo "|---|---|---|---|---|---|" 66 for n in $NAMES; do 67 r=$(rid "$n"); [ -n "$r" ] || { echo "NOT_RUN: $n has no row in RIDS.md"; exit 3; } 68 git clone -q --mirror --shared "$STORE/$r" "$T/storage/$r" || { echo "NOT_RUN: cannot snapshot $n"; exit 3; } 69 echo "| $n | rad:$r | main | - | - | - |" 70 done 71 echo "| hostile | rad:$HOSTILE | main | - | - | - |" 72 echo "| noreadme | rad:$NORD | main | - | - | - |" 73 } > "$T/RIDS.md" 74 [ "$(rid interplane.io)" = "$SITE" ] || { echo "NOT_RUN: the site repository is not $SITE"; exit 3; } 75 mkrepo() { # mkrepo DIR FILE... (pairs: path source): a bare repository whose main holds the files 76 local d=$1 w; shift 77 w=$(mktemp -d "$T/w.XXXXXX") 78 git init -q -b main "$w" 79 while [ $# -gt 0 ]; do mkdir -p "$w/$(dirname "$1")"; cp "$2" "$w/$1"; shift 2; done 80 git -C "$w" add -A 81 git -C "$w" -c user.name=t -c user.email=t@example.invalid commit -q -m fixture --date=2026-11-01T00:00:00Z 82 rm -rf "$d"; git clone -q --bare "$w" "$d"; rm -rf "$w" 83 } 84 mkrepo "$T/storage/$HOSTILE" README.md browse/tests/md/hostile.md img/logo.png server/tests/fake/getent 85 printf 'a file\n' > "$T/plain.txt" 86 mkrepo "$T/storage/$NORD" notes.txt "$T/plain.txt" src/main.om "$T/plain.txt" 87 88 redirect() { # redirect FILE PORT DATA: port, allow-list, storage, data dir and the count sources into $T 89 sed -i -e "s|haddr4 a `2130706433` 18480|haddr4 a `2130706433` $2|" \ 90 -e "s|/home/drakestapleton/handoffs/radicle/RIDS.md|$T/RIDS.md|" \ 91 -e "s|/home/drakestapleton/.radicle/storage/|$T/storage/|g" \ 92 -e "s|/home/drakestapleton/forge-data/|$3/|g" \ 93 -e "s|^text tfzp0 \".*\"|text tfzp0 \"$T/ng/dl.log\"|" \ 94 -e "s|^text tfzp1 \".*\"|text tfzp1 \"$T/ng/access.log\"|" \ 95 -e "s|^text tfzwal \".*\"|text tfzwal \"$T/ng/wal\"|" \ 96 -e "s|^text tfzrad \".*\"|text tfzrad \"$T/bin/rad\"|" \ 97 -e "s|^text tfzspth \".*\"|text tfzspth \"$T/counts.snapshot\"|" \ 98 -e "s|^text tfzgent \".*\"|text tfzgent \"$T/bin/getent\"|" "$1" 99 for p in "`2130706433` $2" "$T/RIDS.md" "$T/storage/" "$3/"; do 100 grep -qF "$p" "$1" || { bad "redirect: '$p' not substituted"; exit 1; } 101 done 102 if grep -q '`2130706433` 18480\|/home/drakestapleton/forge-data\|/home/drakestapleton/.radicle\|/home/drakestapleton/handoffs/radicle' "$1"; then bad "redirect: a live path or port remains"; exit 1; fi 103 } 104 compose() { # compose TREE OUT 105 (cd "$1" && { printf 'om2\n'; cat $(./run.sh units); }) > "$2" 106 } 107 build() { # build TREE NAME PORT DATA 108 compose "$1" "$T/$2.om"; redirect "$T/$2.om" "$3" "$4" 109 run "$OMC" < "$T/$2.om" > "$T/$2" 2> "$T/$2.err" || { bad "build $2: $(cat "$T/$2.err")"; exit 1; } 110 chmod 755 "$T/$2" 111 } 112 start() { # start NAME PORT DATA -> sets spid 113 FORGE_SOCIAL_DIR="$3/" taskset -c "$CORES" nice -n 10 "$T/$1" > "$T/$1.log" 2>&1 & 114 spid=$! 115 for _ in $(seq 100); do curl -s -o /dev/null "http://127.0.0.1:$2/explore" && return; sleep 0.2; done 116 bad "trial $1 did not listen on $2"; exit 1 117 } 118 stop() { kill "$1" 2>/dev/null; wait "$1" 2>/dev/null; for _ in $(seq 50); do ss -ltn | grep -q "127.0.0.1:$2 " || return; sleep 0.2; done; } 119 get() { # get PORT PATH OUT -> prints "status location"; an HTML body is read without the send-time 120 # translation hints of server/tr.om (translate="no" attributes and wrappers), 121 # so ids, commands and names compare as text on both builds 122 curl -s -o "$3" -D "$3.h" -w '%{http_code} %{redirect_url}' -H 'X-Forge-Base: /' -H 'X-Real-IP: 10.9.9.9' "http://127.0.0.1:$1/$2" 123 if grep -qi '^content-type: text/html' "$3.h"; then 124 sed -i -e 's|\([^<]*\)|\1|g' -e 's| translate="no"||g' "$3" 125 fi 126 } 127 mainpart() { sed -n '/^]/,/^<\/main>$/p' "$1"; } 128 nohead() { mainpart "$1" | sed '/^
Radicle: /d' > "$1.nh" # the retired seed-count line (its N) 132 { grep -o 'href="[^"]*"' "$1.nh"; grep -o '[^<]*' "$1.nh"; grep -oE '(^|[^0-9a-f])[0-9a-f]{7,64}([^0-9a-f]|$)' "$1.nh" | grep -oE '[0-9a-f]{7,64}'; grep -o '[0-9]*' "$1.nh"; } | sort -u 133 } 134 gone() { # the base records removed on purpose with Radicle (ids, rad commands, /rad/ clone URLs) 135 grep -viE 'radicle|\brad:z[1-9A-HJ-NP-Za-km-z]{10,}|\brad (clone|init|sync|patch|auth|node|issue|seed|inspect)|git push rad\b|/rad/|heartwood' 136 } 137 jnorm() { # jnorm FILE: the repo JSON without the clone and counts objects, with a bare rid, and the 138 # description cut the way server/util.om fdclean cuts it (sentences naming the retired network) 139 jq -S 'del(.clone, .counts) | if type == "object" and has("rid") then .rid |= sub("^rad:"; "") else . end 140 | if type == "object" and (.description | type) == "string" then .description |= ([splits("(?<=\\.) +")] | map(select(test("radicle|heartwood|rad:z|/rad/|rad (clone|init|sync|id|patch|auth)"; "i") | not)) | join(" ")) else . end' "$1" 141 } 142 readme() { mainpart "$1" | sed -n '/^
/,/^<\/article><\/div>$/p' | sed 's| class="ext" rel="nofollow| rel="nofollow|g; s|\(href="mailto:[^"]*"\) rel="nofollow noopener noreferrer">|\1>|g'; } 143 144 # ---- builds 145 mkdir -p "$T/tree-base" "$T/tree-mutA" "$T/tree-mutB" 146 git archive "$BASE" | tar -x -C "$T/tree-base" 147 tar -C "$ROOT" --exclude=./.git -c . | tar -x -C "$T/tree-mutA" 148 cp -a "$T/tree-mutA/." "$T/tree-mutB/" 149 sed -i '/^fn brhome to long$/,/^ret 200$/{/^dlclone$/d}' "$T/tree-mutA/browse/c1_page.om" 150 cmp -s "$T/tree-mutA/browse/c1_page.om" browse/c1_page.om && { bad "mutant A: sed changed nothing"; exit 1; } 151 sed -i '/^fn fpjrec /,/^fn fpjshl /s/^ret fpjhexeq a$/ret true/' "$T/tree-mutB/server/state.om" 152 cmp -s "$T/tree-mutB/server/state.om" server/state.om && { bad "mutant B: sed changed nothing"; exit 1; } 153 build "$ROOT" head "$PORT" "$T/data" 154 build "$T/tree-base" base "$PORTB" "$T/datab" 155 build "$T/tree-mutA" mutA "$PORT" "$T/data" 156 build "$T/tree-mutB" mutB "$PORT" "$T/data" 157 echo "builds: head $(sha256sum < "$T/head" | cut -c1-16) base $(sha256sum < "$T/base" | cut -c1-16) (base $BASE)" 158 159 # ---- A. records 160 URLS=". tree/main blob/main/README.md raw/main/README.md commits branches tags releases releases/latest patches issues stargazers watchers .json insights" 161 checkrecs() { # checkrecs BUILDPORT LABEL: compare every page of the 5 projects with the base build; prints the failure count 162 local p=$1 nf=0 n u path sh sb 163 for n in $NAMES; do 164 for u in $URLS; do 165 case $u in .) path=drakestapleton/$n ;; .json) path=drakestapleton/$n.json ;; *) path=drakestapleton/$n/$u ;; esac 166 sh=$(get "$p" "$path" "$T/h.html" | sed "s|http://127.0.0.1:$p/|/|"); sb=$(get "$PORTB" "$path" "$T/b.html" | sed "s|http://127.0.0.1:$PORTB/|/|") 167 if [ "$sh" != "$sb" ]; then echo " $2 $path: status '$sh', base '$sb'"; nf=$((nf+1)); continue; fi 168 case "$sh" in 200*) ;; *) continue ;; esac 169 # the repo JSON: the clone and counts objects and the rid prefix changed with the Radicle removal 170 case $u in 171 .json) cmp -s <(jnorm "$T/h.html") <(jnorm "$T/b.html") || { echo " $2 $path: body differs"; nf=$((nf+1)); } 172 [ "$(jq -c .clone "$T/h.html")" = "{\"rad\":\"$(rid "$n")\",\"rad_clone\":null,\"git_https\":null}" ] || { echo " $2 $path: clone object is not bare rid + nulls"; nf=$((nf+1)); } 173 [ "$(jq -c '[.counts.upload_pack_requests.count, .counts.seeds.count, .counts.seeds.as_of]' "$T/h.html")" = "[null,null,null]" ] || { echo " $2 $path: retired counts are not null"; nf=$((nf+1)); } 174 continue ;; 175 raw/*) cmp -s "$T/h.html" "$T/b.html" || { echo " $2 $path: body differs"; nf=$((nf+1)); }; continue ;; 176 esac 177 missing=$(comm -23 <(recs "$T/b.html" | gone) <(recs "$T/h.html")) 178 [ -z "$missing" ] || { echo " $2 $path: records missing: $(echo "$missing" | head -3 | tr '\n' ' ')"; nf=$((nf+1)); } 179 hb=$(headpart "$T/b.html") 180 d=$(echo "$hb" | sed -n 's|.*

\([^<]*\)

.*|\1|p' | head -1) 181 # a description naming the retired network is shown cut (server/util.om fdclean): compare its first sentence that does not 182 d=$(printf '%s' "$d" | sed 's/\. /.\n/g' | grep -viE 'radicle|heartwood|rad:z|/rad/|rad (clone|init|sync|id|patch|auth)' | head -1) 183 [ -z "$d" ] || grep -qF "$d" "$T/h.html" || { echo " $2 $path: description missing"; nf=$((nf+1)); } 184 if grep -q '^
$l" "$T/b.html" | sed 's/ · .*//'); b=$(grep -F "

$l" "$T/h.html" | sed 's/ · .*//') 191 [ -n "$a" ] && [ "$a" = "$b" ] || { echo " $2 $path: count line '$l' differs"; nf=$((nf+1)); } 192 done 193 grep -qF '

Seeding: not measured (the source of this count is retired)

' "$T/h.html" || { echo " $2 $path: seeding line is not 'not measured'"; nf=$((nf+1)); } 194 grep -qF '
' "$T/h.html" || { echo " $2 $path: clone panel missing"; nf=$((nf+1)); } 195 grep -q 'id="For-developers"' "$T/h.html" || { echo " $2 $path: no For-developers section"; nf=$((nf+1)); } 196 [ "$(readme "$T/h.html")" = "$(readme "$T/b.html")" ] || { echo " $2 $path: README differs"; nf=$((nf+1)); } 197 fi 198 done 199 done 200 return $nf 201 } 202 start base "$PORTB" "$T/datab"; pidb=$spid 203 start head "$PORT" "$T/data"; pid=$spid 204 checkrecs "$PORT" head; nf=$? 205 [ "$nf" = 0 ] && ok "A: 5 projects x $(echo $URLS | wc -w) addresses: same status, same records, header records kept" || bad "A: $nf page differences (above)" 206 for b in / /forge/; do 207 s=$(curl -s -o "$T/f.html" -w '%{http_code}' -H "X-Forge-Base: $b" "http://127.0.0.1:$PORT/drakestapleton/hop") 208 [ "$s" = 200 ] && grep -qF "href=\"${b}drakestapleton/hop#For-developers\"" "$T/f.html" && ok "A: base $b: the For developers tab links ${b}drakestapleton/hop#For-developers" || bad "A: base $b: tab link ($s)" 209 done 210 stop "$pid" "$PORT"; pid= 211 start mutA "$PORT" "$T/data"; pid=$spid 212 checkrecs "$PORT" mutA > "$T/mutA.out"; nf=$? 213 [ "$nf" -gt 0 ] && grep -q 'records missing\|clone panel missing' "$T/mutA.out" && ok "A negative control: the home without its clone panel fails ($nf differences)" || bad "A negative control: mutant A passed" 214 stop "$pid" "$PORT"; pid= 215 stop "$pidb" "$PORTB"; pidb= 216 217 # ---- B. state 218 oracle() { # oracle REPODIR RID HEADSHA: independent reading of the list -> "unfinished" or "checked " 219 local g="git --git-dir=$1" L line n=0 prev=GENESIS ok=1 best= 220 L=$($g show HEAD:content/receipts/ledger.tsv 2> /dev/null) || { echo unfinished; return; } 221 $g show HEAD:content/receipts/ledger.tsv > "$T/o.tsv" 222 [ -s "$T/o.tsv" ] && [ -z "$(tail -c 1 "$T/o.tsv")" ] || { echo unfinished; return; } 223 while IFS= read -r line; do 224 n=$((n+1)) 225 [ "$(printf '%s' "$line" | awk -F'\t' '{print NF}')" = 7 ] || ok=0 226 [ "$(printf '%s' "$line" | cut -f1)" = "$n" ] || ok=0 227 [ "$(printf '%s' "$line" | cut -f7)" = "$prev" ] || ok=0 228 printf '%s' "$line" | cut -f2 | grep -qE '^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$' || ok=0 229 printf '%s' "$line" | cut -f6 | grep -qE '^[0-9a-f]{64}$' || ok=0 230 prev=$(printf '%s' "$line" | sha256sum | cut -d' ' -f1) 231 done < "$T/o.tsv" 232 [ "$ok" = 1 ] || { echo unfinished; return; } 233 while IFS=$'\t' read -r num tm kind who what pay link; do 234 [ "$kind" = BUILD ] || continue 235 awk -F'\t' -v k="$num" -v w="$who" -v r="rad:$2" '{ tm[NR] = $2; kd[NR] = $3; wh[NR] = $4; tx[NR] = $5 } END { a = k; while (a > 1 && tm[a - 1] == tm[k]) a--; for (q = a; q <= NR && tm[q] == tm[k]; q++) { if (kd[q] != "SOURCE" || wh[q] != w) continue; s = tx[q]; while ((i = index(s, r)) > 0) { c = substr(s, i + length(r), 1); if (c !~ /[0-9A-Za-z]/) exit 0; s = substr(s, i + 1) } } exit 1 }' "$T/o.tsv" || continue 236 [ "$($g show "HEAD:content/receipts/payload/$pay.txt" 2> /dev/null | sha256sum | cut -d' ' -f1)" = "$pay" ] || continue 237 c=$(printf '%s' "$what" | grep -oE 'from commit [0-9a-f]+' | head -1 | sed 's/from commit //') 238 v=old; [ -n "$c" ] && [ ${#c} -ge 7 ] && [ ${#c} -le 40 ] && case $3 in "$c"*) v=new ;; esac 239 best="checked ${tm:0:10} $v" 240 done < "$T/o.tsv" 241 echo "${best:-unfinished}" 242 } 243 label() { # label PORT NAME -> what the home page header says, in the oracle's words 244 get "$1" "drakestapleton/$2" "$T/s.html" > /dev/null 245 h=$(headpart "$T/s.html") 246 if echo "$h" | grep -q '

Checked: ran again on '; then 247 d=$(echo "$h" | sed -n 's|.*Checked: ran again on \([0-9-]*\)

.*|\1|p') 248 v=old; echo "$h" | grep -q 'That is the version shown here' && v=new 249 echo "checked $d $v" 250 elif echo "$h" | grep -q '

Unfinished: not checked yet

'; then echo unfinished 251 else echo "no label"; fi 252 } 253 rowlabel() { # rowlabel PORT NAME -> the explore row's label 254 get "$1" explore "$T/e.html" > /dev/null 255 r=$(grep -F "
  • " "$T/e.html") 256 if echo "$r" | grep -q 'Checked: ran again on '; then echo "checked $(echo "$r" | sed -n 's|.*ran again on \([0-9-]*\).*|\1|p')" 257 elif echo "$r" | grep -q 'Unfinished: not checked yet'; then echo unfinished; else echo "no label"; fi 258 } 259 headsha() { git --git-dir="$STORE/$(rid "$1")" rev-parse refs/heads/main 2> /dev/null || git --git-dir="$STORE/$(rid "$1")" rev-parse "refs/namespaces/`z6MkfZDue1TbaNFi3ZzcD9uiTeduPLC52ucdFVuLKZwexxhK`/refs/heads/main"; } 260 compare() { # compare PORT CASE SITEDIR: every sample project's header and explore row against the oracle 261 local p=$1 nf=0 n o l rl 262 for n in $NAMES; do 263 o=$(oracle "$3" "$(rid "$n")" "$(headsha "$n")"); l=$(label "$p" "$n"); rl=$(rowlabel "$p" "$n") 264 [ "$o" = "$l" ] || { echo " $2 $n: page says '$l', the list says '$o'"; nf=$((nf+1)); } 265 [ "${o% *}" = "$rl" ] || [ "$o" = unfinished -a "$rl" = unfinished ] || { echo " $2 $n: explore row says '$rl', the list says '$o'"; nf=$((nf+1)); } 266 done 267 echo " $2: $(for n in $NAMES; do printf '%s=%s; ' "$n" "$(label "$p" "$n")"; done)" 268 return $nf 269 } 270 # made-up site repositories (the real list is copied, then changed) 271 REAL=$STORE/$SITE 272 mksite() { # mksite NAME LEDGER PAYLOADDIR 273 local d=$T/sites/$1 w; mkdir -p "$T/sites" 274 w=$(mktemp -d "$T/w.XXXXXX"); git init -q -b main "$w" 275 if [ -n "$2" ]; then mkdir -p "$w/content/receipts/payload"; cp "$2" "$w/content/receipts/ledger.tsv"; cp "$3"/*.txt "$w/content/receipts/payload/" 2> /dev/null; else echo x > "$w/README.md"; fi 276 git -C "$w" add -A; git -C "$w" -c user.name=t -c user.email=t@example.invalid commit -q -m site 277 git clone -q --bare "$w" "$d"; rm -rf "$w" 278 } 279 OH=$(rid omega-harness); OHH=$(headsha omega-harness) 280 # a SOURCE and a BUILD record with the same time and writer, chained, with their evidence files 281 pairledger() { # pairledger OUT PAYDIR SRCTEXT BUILDTEXT 282 local out=$1 pd=$2 l1 l2 h1 h2 p1; mkdir -p "$pd" 283 printf 'source evidence' > "$pd/a"; h1=$(sha256sum < "$pd/a" | cut -d' ' -f1); mv "$pd/a" "$pd/$h1.txt" 284 printf 'build evidence' > "$pd/b"; h2=$(sha256sum < "$pd/b" | cut -d' ' -f1); mv "$pd/b" "$pd/$h2.txt" 285 l1=$(printf '1\t2026-11-03T09:00:00Z\tSOURCE\ttest-desk\t%s\t%s\tGENESIS' "$3" "$h1") 286 p1=$(printf '%s' "$l1" | sha256sum | cut -d' ' -f1) 287 l2=$(printf '2\t2026-11-03T09:00:00Z\tBUILD\ttest-desk\t%s\t%s\t%s' "$4" "$h2" "$p1") 288 printf '%s\n%s\n' "$l1" "$l2" > "$out" 289 } 290 pairledger "$T/f1.tsv" "$T/p1" "omega-harness source commit `1234567` and the signed refs of rad:$OH" "omega-harness rebuilt from commit `1234567`: ok" 291 mksite valid "$T/f1.tsv" "$T/p1" 292 sed '1s/omega-harness source/omega-harness s0urce/' "$T/f1.tsv" > "$T/f2.tsv"; mksite tampered "$T/f2.tsv" "$T/p1" 293 mkdir -p "$T/p3"; cp "$T/p1"/*.txt "$T/p3/"; for f in "$T/p3"/*.txt; do grep -q build "$f" && printf 'build evidence, changed' > "$f"; done; mksite badpay "$T/f1.tsv" "$T/p3" 294 pairledger "$T/f4.tsv" "$T/p4" "omega-harness source and the signed refs of rad:${OH}X" "omega-harness rebuilt from commit `1234567`: ok"; mksite longrid "$T/f4.tsv" "$T/p4" 295 mksite nolist "" "" 296 pairledger "$T/f6.tsv" "$T/p6" "omega-harness source and the signed refs of rad:$OH" "omega-harness rebuilt from commit ${OHH:0:12}: ok"; mksite current "$T/f6.tsv" "$T/p6" 297 swap() { rm -rf "${T:?}/storage/$SITE"; ln -s "$1" "$T/storage/$SITE"; } 298 start head "$PORT" "$T/data"; pid=$spid 299 swap "$REAL"; compare "$PORT" real "$REAL"; nf=$? 300 [ "$nf" = 0 ] && ok "B: real list: every label equals the oracle" || bad "B: real list ($nf)" 301 [ "$(label "$PORT" omega-harness)" = unfinished ] && ok "B: a project with no receipt (omega-harness) says Unfinished: not checked yet" || bad "B: omega-harness label on the real list" 302 case $(label "$PORT" hop) in "checked "*) ok "B: hop, with its rebuild receipt, says Checked" ;; *) bad "B: hop is not Checked on the real list" ;; esac 303 # Alarm (no-hard-caps rule): forged reads the list through its 16 MiB exec buffer (server/state.om 304 # fpjread); past it every project would show Unfinished. Fail loudly at half of that, long before. 305 lsz=$(git --git-dir="$REAL" cat-file -s HEAD:content/receipts/ledger.tsv); lrec=$(git --git-dir="$REAL" show HEAD:content/receipts/ledger.tsv | wc -l) 306 [ "$lsz" -lt `8388608` ] && ok "B: alarm: the receipts list is $lsz bytes, $lrec records (alarm at `8388608` bytes, half of the 16 MiB forged reads)" || bad "B: ALARM: the receipts list is $lsz bytes ($lrec records); server/state.om reads at most `16777216`: give fpjread a streaming reader before it grows further" 307 for c in valid tampered badpay longrid nolist current; do 308 swap "$T/sites/$c"; compare "$PORT" "$c" "$T/sites/$c"; nf=$? 309 [ "$nf" = 0 ] && ok "B: list '$c': every label equals the oracle ($(label "$PORT" omega-harness) for omega-harness)" || bad "B: list '$c' ($nf)" 310 done 311 [ "$(swap "$T/sites/valid"; label "$PORT" omega-harness)" = "checked 2026-11-03 old" ] && ok "B: control: the valid made-up list makes omega-harness Checked" || bad "B: control: the valid list did not check omega-harness" 312 [ "$(swap "$T/sites/current"; label "$PORT" omega-harness)" = "checked 2026-11-03 new" ] && ok "B: a receipt naming the current head says it is the version shown" || bad "B: current-head receipt" 313 stop "$pid" "$PORT"; pid= 314 start mutB "$PORT" "$T/data"; pid=$spid 315 swap "$T/sites/tampered" 316 lb=$(label "$PORT" omega-harness) 317 compare "$PORT" mutB-tampered "$T/sites/tampered" > /dev/null; nf=$? 318 [ "$lb" = "checked 2026-11-03 old" ] || nf=0 319 [ "$nf" -gt 0 ] && ok "B negative control: the mutant without the chain check shows the changed list as Checked and the comparison catches it" || bad "B negative control: mutant B was not caught" 320 stop "$pid" "$PORT"; pid= 321 swap "$REAL" 322 323 # ---- C. hostile README and no README 324 start head "$PORT" "$T/data"; pid=$spid 325 s=$(get "$PORT" drakestapleton/hostile "$T/x.html") 326 art=$(mainpart "$T/x.html" | sed -n '/^
    /,/^<\/article>/p') 327 [ "${s%% *}" = 200 ] && [ -n "$art" ] && ok "C: the hostile project home answers 200 with its README" || bad "C: hostile home ($s)" 328 v=$(printf '%s\n' "$art" | grep -o '<[A-Za-z][^>]*>' | awk '{ n = tolower($0); sub(/^\/].*$/, "", n) 329 if (n !~ /^(a|p|img|h[1-6]|ul|ol|li|code|pre|em|strong|del|blockquote|table|thead|tbody|tr|th|td|hr|br|input|article)$/) print "tag " $0 330 if (tolower($0) ~ /[ \t\/]on[a-z]+[ \t]*=/) print "handler " $0 331 if (n == "img" && $0 !~ / src="\/[^\/]/) print "image " $0 332 if (n == "a" && $0 ~ / href="(https?:|mailto:|\/\/)/ && $0 !~ / class="ext" rel="nofollow noopener noreferrer"/) print "unmarked " $0 333 if (n == "a" && $0 !~ / href="(\/[^\/]|#|https?:|mailto:|\/\/)/) print "unsafe " $0 }') 334 [ -z "$v" ] && ok "C: the hostile README renders no script, frame, handler or remote image, and marks its outside links" || bad "C: hostile README: $(echo "$v" | head -3)" 335 grep -qi "^content-security-policy: default-src 'none'; style-src 'self'; img-src 'self'; script-src 'none'" "$T/x.html.h" && ok "C: the page sends its Content-Security-Policy (img-src 'self', script-src 'none', no frames)" || bad "C: no CSP header" 336 s=$(get "$PORT" drakestapleton/noreadme "$T/n.html") 337 grep -q 'This project has no README yet' "$T/n.html" && grep -q '/drakestapleton/noreadme/blob/main/notes.txt' "$T/n.html" && [ "$(nohead "$T/n.html" | grep -c 'blob/main/notes.txt')" = 1 ] \ 338 && ok "C: a project without a README says so and lists its files once" || bad "C: no-README page ($s)" 339 340 # ---- D. words 341 words='\b(rid|delegates?|seeds?|seeding|seeded|patch(es)?|refs|head)\b' 342 for n in $NAMES hostile noreadme; do 343 get "$PORT" "drakestapleton/$n" "$T/w.html" > /dev/null 344 d=$(headpart "$T/w.html" | sed 's|

    [^<]*

    ||; s|<[^>]*>| |g') 345 hit=$(printf '%s' "$d" | grep -oiE "$words" | sort -u | tr '\n' ' ') 346 [ -z "$hit" ] && ok "D: $n: no developer word above the README" || bad "D: $n above the README: $hit" 347 for t in '
    Delegate
    ' '
    Refs and HEAD
    ' '
    Patch
    ' '
    Receipt
    '; do 348 grep -qF "$t" "$T/w.html" || bad "D: $n: the For developers section lacks $t" 349 done 350 done 351 get "$PORT" explore "$T/w.html" > /dev/null 352 d=$(mainpart "$T/w.html" | sed 's|
    ]*>[^<]*||g; s|

    [^<]*

    ||g; s|

    Last commit: [^<]*|

    |g; s|<[^>]*>| |g') 353 hit=$(printf '%s' "$d" | grep -oiE "$words" | sort -u | tr '\n' ' ') 354 [ -z "$hit" ] && ok "D: explore: no developer word in the page's own text" || bad "D: explore: $hit" 355 r=$(grep -m1 '

  • ' "$T/w.html") 356 case "$r" in *''*'

    Last commit: '*) ok "D: explore row order: name, sentence, state, then the last commit" ;; *) bad "D: explore row order: $r" ;; esac 357 stop "$pid" "$PORT"; pid= 358 echo "readmefirst.sh: $pass passed, $fail failed" 359 [ "$fail" = 0 ]