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/open/tests/run.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 / open / tests / run.sh` 902 lines · 79409 bytes Raw Blame History 1 #!/usr/bin/env bash 2 # open/tests/run.sh: the gate for Open Humanity's shelf of open builds. 3 # Part 1 open/intake.om, the program outside the sandbox, against a stand-in rad (a shell script 4 # in a throwaway HOME: it logs its arguments, "seeds" by making the storage folder and 5 # prints a payload). No network, no real Radicle node, no real key. 6 # Part 2 open/route.om inside a test copy of forged (private port, private data folder), with a 7 # throwaway `ed25519` key signed in the way social/tests does it. 8 # Each part ends with mutants: the same checks must FAIL on a copy with one guard removed. 9 # Heavy enough to want a pool lock: 10 # flock -o ~/handoffs/hive/queen/pool-18.lock env FORGED_CPUS=18 sh open/tests/run.sh 11 set -u 12 cd "$(dirname "$0")/../.." 13 OMV=$HOME/work/flux/omega-mv 14 OMC=$OMV/seed/out/omc 15 PIN=`3ad9f10f64309e7acf8a725082b28e23a2a4aeb07e98322fb4dc0fcd8fc93194` 16 [ "$(sha256sum "$OMC" | cut -d' ' -f1)" = "$PIN" ] || { echo "omc is not the pin"; exit 1; } 17 PORT=${OPEN_TEST_PORT:-18493} 18 CORES=${FORGED_CPUS:-2} 19 T=$(mktemp -d /tmp/openbuilds.XXXXXX) 20 PASS=0; FAIL=0 21 ok() { PASS=$((PASS+1)); echo "PASS $*"; } 22 bad() { FAIL=$((FAIL+1)); echo "FAIL $*"; } 23 check() { if [ "$1" = "$2" ]; then ok "$3 ($1)"; else bad "$3: want '$2', got '$1'"; fi; } 24 PID= 25 stop() { [ -n "$PID" ] && { kill "$PID" 2>/dev/null; wait "$PID" 2>/dev/null; }; PID=; } 26 trap 'stop; [ -n "${KEEP:-}" ] || rm -rf "$T"' EXIT 27 omc() { taskset -c "$CORES" nice -n 10 "$OMC"; } 28 TAB=$(printf '\t') 29 30 # ------------------------------------------------------------------ part 1: the intake 31 { printf 'om2\n'; cat "$OMV/om/tls/sha2.om" open/intake.om; } | omc > "$T/intake" 2> "$T/omc.err" || { echo "BUILD FAILED open/intake.om: $(cat "$T/omc.err")"; exit 1; } 32 chmod 700 "$T/intake" 33 rid() { printf 'z2abcdefghijkmnopqrstuvw%s' "$1"; } 34 D1=did:key:z6MkTestKeyNumberOne111111111111111111111111111 35 D2=did:key:`z6MkTestKeyNumberTwo222222222222222222222222222` 36 D3=did:key:`z6MkTestKeyNumberThree3333333333333333333333333` 37 # world NAME: a fresh throwaway HOME, storage, open folder, work folder and state file under $T/NAME 38 world() { 39 W=$T/$1; rm -rf "$W" 40 mkdir -p -m 700 "$W/home/.local/bin" "$W/home/stub" "$W/home/store" "$W/open" "$W/work" 41 cat > "$W/home/.local/bin/rad" <<'EOF' 42 #!/bin/sh 43 # stand-in for rad: log the arguments; seed copies stub/template.git (a real bare repository) when 44 # it exists; seed without a rid prints stub/policy (the policy list) or 45 # fails when stub/policyfail exists; a rid in stub/late fails and its folder appears 2 s later (the 46 # node finishing a fetch after rad stopped); seed makes the storage folder unless the rid is listed in 47 # stub/notfound (52 MiB of it when listed in stub/big); inspect prints stub/payload 48 S=$HOME/stub 49 echo "$*" >> "$S/rad.log" 50 r=${2#rad:} 51 case $1 in 52 seed) 53 [ -n "${2:-}" ] || { [ -e "$S/policyfail" ] && exit 1; cat "$S/policy" 2>/dev/null; exit 0; } 54 grep -qx "$r" "$S/late" 2>/dev/null && { ( sleep 2; mkdir -p "$HOME/store/$r"; echo part > "$HOME/store/$r/partial" ) > /dev/null 2>&1 & exit 1; } 55 grep -qx "$r" "$S/notfound" 2>/dev/null && exit 1 56 if [ -d "$S/template.git" ]; then cp -r "$S/template.git" "$HOME/store/$r"; else mkdir -p "$HOME/store/$r" && echo ref > "$HOME/store/$r/HEAD"; fi 57 grep -qx "$r" "$S/big" 2>/dev/null && head -c `54525952` /dev/zero > "$HOME/store/$r/pack" 58 exit 0 ;; 59 unseed) exit 0 ;; 60 inspect) [ "${3:-}" = --visibility ] && { cat "$S/visibility" 2>/dev/null || echo private; exit 0; } 61 [ "${3:-}" = --delegates ] && { [ -e "$S/delfail" ] && exit 1 62 [ -e "$S/delegates" ] && { cat "$S/delegates"; exit 0; } 63 echo 'did:key:z6MkTestKeyNumberOne111111111111111111111111111 (one)'; exit 0; } 64 cat "$S/payload"; exit 0 ;; 65 esac 66 exit 2 67 EOF 68 chmod 700 "$W/home/.local/bin/rad" 69 printf '%s\n' '{"xyz.radicle.project":{"defaultBranch":"main","description":"A demo that stops half way","name":"demo-project"}}' > "$W/home/stub/payload" 70 : > "$W/home/stub/rad.log" 71 # the reserves are the only refusal for room; this gate sets them to one byte, so the machine's 72 # own free space never decides an outcome here (open/tests/up.sh tests them) 73 printf 'OPEN_RESERVE_STORAGE_BYTES=1\nOPEN_RESERVE_DATA_BYTES=1\n' > "$W/work/reserve" 74 } 75 # alarm NAME: "value/threshold|key|volume>=VOL" of a firing alarm in alarms.txt 76 alarm() { awk -F'\t' -v n="$1" -v v="${2:-0}" '$1==n {print $2"/"$3"|"$5"|"($6>=v)}' "$W/work/alarms.txt" 2>/dev/null; } 77 intake() { "${BIN:-$T/intake}" "$W/open/" "$W/state" "$W/work/" "$W/home/store/" "$W/home" once; } 78 q() { printf '%s\n' "$1" >> "$W/open/queue"; } 79 row() { awk -F'\t' -v r="$1" '$1==r' "$W/open/list.tsv" 2>/dev/null; } 80 st() { row "$1" | cut -f2; } 81 calls() { grep -c -- "$1" "$W/home/stub/rad.log"; } 82 83 world w1 84 # 1. no allow file: nobody may bring 85 q "B${TAB}$(rid A1)${TAB}$D1${TAB}first try"; intake 86 case "$(st "$(rid A1)")" in "refused: intake is open to invited keys"*) ok "no allow file: the bring is refused";; *) bad "no allow file: state '$(st "$(rid A1)")'";; esac 87 check "$(calls "^seed rad:")" 0 "no allow file: rad was not called (the alarm pass asks for the bare rad seed list only)" 88 [ ! -e "$W/home/store/$(rid A1)" ] && ok "no allow file: nothing in storage" || bad "storage folder made without permission" 89 # 2. an allowed key brings a project 90 echo "$D1" > "$W/work/allow" 91 q "B${TAB}$(rid A2)${TAB}$D1${TAB}needs a parser & tests"; intake 92 check "$(st "$(rid A2)")" open "allowed key: the project is open" 93 check "$(row "$(rid A2)" | cut -f3)" "$D1" "the row names the key that brought it" 94 row "$(rid A2)" | cut -f4 | grep -qE '^20[0-9]{2}-[0-9]{2}-[0-9]{2}$' && ok "the row has a date" || bad "date '$(row "$(rid A2)" | cut -f4)'" 95 [ "$(row "$(rid A2)" | cut -f5)" -gt 0 ] 2>/dev/null && ok "the row has a size in KiB" || bad "size '$(row "$(rid A2)" | cut -f5)'" 96 check "$(row "$(rid A2)" | cut -f6)" demo-project "name from the identity document" 97 check "$(row "$(rid A2)" | cut -f7)" "A demo that stops half way" "description from the identity document" 98 check "$(row "$(rid A2)" | cut -f8)" "needs a parser & tests" "the note is kept" 99 check "$(grep -c -x "seed rad:$(rid A2) --scope all --fetch" "$W/home/stub/rad.log")" 1 "rad seed was called once with the rid, scope all, fetch" 100 # 3. the same bring again changes nothing 101 q "B${TAB}$(rid A2)${TAB}$D1${TAB}again"; intake 102 check "$(calls "seed rad:$(rid A2)")" 1 "a second bring of an open project does not seed again" 103 check "$(row "$(rid A2)" | cut -f8)" "needs a parser & tests" "a second bring does not rewrite the row" 104 # 4. a key that is not on the list; then the * line 105 q "B${TAB}$(rid A3)${TAB}$D2${TAB}other key"; intake 106 case "$(st "$(rid A3)")" in refused:*invited*) ok "a key not on the list is refused";; *) bad "unlisted key: '$(st "$(rid A3)")'";; esac 107 echo '*' >> "$W/work/allow" 108 q "B${TAB}$(rid A3)${TAB}$D2${TAB}other key"; intake 109 check "$(st "$(rid A3)")" open "a * line admits every key" 110 # 5. a repository this node already holds, and that is not public, is never touched or listed 111 mkdir "$W/home/store/$(rid A4)"; echo keep > "$W/home/store/$(rid A4)/marker" 112 q "B${TAB}$(rid A4)${TAB}$D1${TAB}already here"; intake 113 case "$(st "$(rid A4)")" in "refused: this project's storage is already on this node") ok "storage already present: refused";; *) bad "present storage: '$(st "$(rid A4)")'";; esac 114 check "$(calls "seed rad:$(rid A4)")" 0 "storage already present: no seed" 115 q "W${TAB}$(rid A4)${TAB}$D1"; intake 116 [ -f "$W/home/store/$(rid A4)/marker" ] && ok "withdraw of a refused row leaves the storage alone" || bad "a repository the intake did not bring was removed" 117 check "$(calls "unseed rad:$(rid A4)")" 0 "withdraw of a refused row does not unseed" 118 # 5b. the published copy is not an authority: a row planted there cannot make the intake remove anything 119 mkdir "$W/home/store/$(rid A9)"; echo keep > "$W/home/store/$(rid A9)/marker" 120 printf '%s\topen\t%s\t2026-11-10\t1\tplanted\t\t\n' "$(rid A9)" "$D1" >> "$W/open/list.tsv" 121 q "W${TAB}$(rid A9)${TAB}$D1"; intake 122 [ -f "$W/home/store/$(rid A9)/marker" ] && ok "a row planted in the published list does not get a repository removed" || bad "planted row: repository removed" 123 check "$(calls "unseed rad:$(rid A9)")" 0 "a planted row does not unseed" 124 # 6. not found on the network 125 echo "$(rid A5)" > "$W/home/stub/notfound" 126 q "B${TAB}$(rid A5)${TAB}$D1${TAB}nowhere"; intake 127 case "$(st "$(rid A5)")" in "refused: not found"*) ok "not found: refused";; *) bad "not found: '$(st "$(rid A5)")'";; esac 128 check "$(calls "unseed rad:$(rid A5)")" 1 "not found: the seeding policy is removed again" 129 check "$(grep -c planted "$W/open/list.tsv")" 0 "the publish after it drops the planted row" 130 # 7. over the former size limit (50 MiB): listed and kept; the largest_project_kib alarm names the key 131 # and the volume 132 echo "$(rid A6)" > "$W/home/stub/big" 133 q "B${TAB}$(rid A6)${TAB}$D1${TAB}too big"; intake 134 check "$(st "$(rid A6)")" open "over the former 50 MiB: listed" 135 [ -e "$W/home/store/$(rid A6)/pack" ] && ok "over the former 50 MiB: the copy is kept" || bad "big copy removed" 136 check "$(calls "unseed rad:$(rid A6)")" 0 "over the former 50 MiB: not unseeded" 137 check "$(alarm largest_project_kib `52428800` | cut -d'|' -f2,3)" "$D1|1" "the largest_project_kib alarm names the key and a volume over 50 MiB" 138 # 8. withdraw: only the key that brought it 139 q "W${TAB}$(rid A2)${TAB}$D2"; intake 140 check "$(st "$(rid A2)")" open "another key cannot withdraw the project" 141 [ -d "$W/home/store/$(rid A2)" ] && ok "another key's withdraw leaves the storage" || bad "storage removed by another key" 142 q "W${TAB}$(rid A2)${TAB}$D1"; intake 143 check "$(st "$(rid A2)")" withdrawn "the owner withdraws the project" 144 [ ! -e "$W/home/store/$(rid A2)" ] && ok "withdraw removes the copy" || bad "copy still there after withdraw" 145 check "$(calls "unseed rad:$(rid A2)")" 1 "withdraw unseeds" 146 check "$(row "$(rid A2)" | cut -f6)" demo-project "a withdrawn row keeps the name" 147 # 9. hostile queue lines: none may reach rad or the list 148 before=$(wc -l < "$W/open/list.tsv"); logb=$(grep -vcx seed "$W/home/stub/rad.log") 149 q "B${TAB}../../../../etc${TAB}$D1${TAB}x" 150 q "B${TAB}z2abcdefghijkmnopqr/../../x${TAB}$D1${TAB}x" 151 q "B${TAB}$(rid A7)0OIl${TAB}$D1${TAB}x" 152 q "B${TAB}`z2abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVW`${TAB}$D1${TAB}x" 153 q "B${TAB}$(rid A7)${TAB}did key with spaces${TAB}x" 154 q "B${TAB}$(rid A7)${TAB}${TAB}x" 155 q "B${TAB}a2abcdefghijkmnopqrstuvwA7${TAB}$D1${TAB}x" 156 q "W${TAB}..${TAB}$D1" 157 q "X${TAB}$(rid A7)${TAB}$D1" 158 q "B $(rid A7) $D1" 159 q "" 160 printf 'B\t\377\376\001\t%s\tx\n' "$D1" >> "$W/open/queue" 161 intake 162 check "$(wc -l < "$W/open/list.tsv")" "$before" "12 malformed queue lines add no row" 163 check "$(grep -vcx seed "$W/home/stub/rad.log")" "$logb" "12 malformed queue lines never reach rad" 164 check "$(cat "$W/state")" "$(stat -c %s "$W/open/queue")" "the offset passed every line" 165 # 10. a hostile identity document cannot break the row 166 printf '%s\n' '{"xyz.radicle.project":{"defaultBranch":"main","description":"line\none \"q\" ","name":"a\tb\n\ttabbed line\n'; printf 'ctl\001x \377 end\n'; head -c 900 /dev/zero | tr '\0' a; printf '\n'; } > README.md 420 mkdir src && echo x > src/a.txt && echo y > 'we&name.txt' && git add -A && git commit -q -m 'first commit' && echo z >> src/a.txt && git commit -q -am 'second commit' ) 421 git clone -q --bare "$G" "$W/home/stub/template.git" 422 q "B${TAB}$(rid S1)${TAB}$D1${TAB}snapshot"; intake 423 P=$W/open/p/$(rid S1).txt 424 check "$(st "$(rid S1)")" open "a real repository is brought" 425 check "$(grep '^H' "$P" | cut -f2)" "$(git -C "$G" rev-parse HEAD)" "snapshot: the head is the project's HEAD" 426 check "$(grep -c '^C' "$P")" 2 "snapshot: both commits" 427 check "$(grep '^C' "$P" | head -1 | cut -f4-)" "Ada & Co${TAB}second commit" "snapshot: newest commit first, with its author" 428 check "$(grep '^C' "$P" | sed -n 2p | cut -f5)" "first commit" "snapshot: a subject is kept as data" 429 check "$(grep '^T' "$P" | cut -f2- | tr '\n' '|')" "b${TAB}README.md|t${TAB}src|b${TAB}we&name.txt|" "snapshot: the top-level files with their type" 430 check "$(grep '^R' "$P" | sed -n 1p)" "R${TAB}# Demo" "snapshot: the README, first line" 431 check "$(grep '^R' "$P" | sed -n 4p)" "R${TAB} tabbed line" "snapshot: a tab in the README becomes a space" 432 check "$(grep '^R' "$P" | sed -n 5p)" "R${TAB}ctl x ? end" "snapshot: a control byte becomes a space, a stray byte ?" 433 check "$(grep '^R' "$P" | sed -n '6,8p' | awk '{print length($0) - 2}' | tr '\n' ' ')" "400 400 100 " "snapshot: a 900-byte line is cut into lines of at most 400" 434 iconv -f UTF-8 -t UTF-8 "$P" > /dev/null 2>&1 && ok "snapshot: valid UTF-8" || bad "snapshot is not valid UTF-8" 435 check "$(tr -d '\t\n' < "$P" | LC_ALL=C grep -c '[[:cntrl:]]')" 0 "snapshot: no control byte but tab and line feed" 436 # a second bring by the lister refreshes it; 12 commits and 205 files meet the caps 437 ( cd "$G" && for i in $(seq 1 10); do echo "$i" > "n$i.txt"; git add -A; git commit -q -m "more $i"; done; for i in $(seq 1 205); do : > "f$i"; done; git add -A; git commit -q -m 'many files' 438 git push -q "$W/home/store/$(rid S1)" main ) 439 q "B${TAB}$(rid S1)${TAB}$D2${TAB}someone else"; intake 440 check "$(grep -c '^C' "$P")" 2 "another key's bring does not refresh the snapshot" 441 q "B${TAB}$(rid S1)${TAB}$D1${TAB}again"; intake 442 check "$(grep '^H' "$P" | cut -f2)" "$(git -C "$G" rev-parse HEAD)" "the lister's second bring refreshes the head" 443 check "$(grep -c '^C' "$P")" 10 "at most 10 commits" 444 check "$(grep -c '^T' "$P")" 200 "at most 200 top-level entries" 445 check "$(calls "seed rad:$(rid S1)")" 1 "a refresh does not seed again" 446 q "W${TAB}$(rid S1)${TAB}$D1"; intake 447 [ ! -e "$P" ] && ok "withdraw removes the snapshot" || bad "snapshot left after withdraw" 448 449 # the operator's remove file: a project or a key named there comes off the shelf and stays off 450 world w12; echo '*' > "$W/work/allow" 451 q "B${TAB}$(rid R1)${TAB}$D1${TAB}one"; q "B${TAB}$(rid R2)${TAB}$D2${TAB}two"; q "B${TAB}$(rid R4)${TAB}$D3${TAB}four"; intake 452 check "$(st "$(rid R1)")$(st "$(rid R2)")$(st "$(rid R4)")" openopenopen "three keys bring three projects" 453 printf '*\n\nrad:%s\n' "$(rid R1)" > "$W/work/remove"; intake 454 check "$(st "$(rid R1)")" "refused: removed by the operator" "remove file: the named project is off the shelf, with no request from its bringer" 455 [ ! -e "$W/home/store/$(rid R1)" ] && ok "remove file: its copy is deleted" || bad "copy left after the removal" 456 check "$(calls "unseed rad:$(rid R1)")" 1 "remove file: it is unseeded" 457 check "$(row "$(rid R1)" | cut -f3)" "$D1" "remove file: the row stays under the key that brought it" 458 check "$(row "$(rid R1)" | cut -f7,8)" "$TAB" "remove file: description and note are cleared" 459 check "$(st "$(rid R2)")$(st "$(rid R4)")" openopen "remove file: other projects stay; a * line and an empty line name nothing" 460 q "B${TAB}$(rid R1)${TAB}$D1${TAB}again"; intake 461 check "$(st "$(rid R1)")" "refused: removed by the operator" "a removed project cannot be brought again" 462 check "$(calls "^seed rad:$(rid R1)")" 1 "and the refused bring fetches nothing" 463 echo "$D2" >> "$W/work/remove"; intake 464 check "$(st "$(rid R2)")" "refused: removed by the operator" "remove file: the projects of a named key come off the shelf" 465 q "B${TAB}$(rid R3)${TAB}$D2${TAB}three"; intake 466 check "$(st "$(rid R3)")" "refused: removed by the operator" "a named key cannot bring" 467 check "$(calls "^seed rad:$(rid R3)")" 0 "and nothing is fetched for it" 468 check "$(st "$(rid R4)")" open "a key and a project that are not named are untouched" 469 echo "$D2" > "$W/work/remove"; q "B${TAB}$(rid R1)${TAB}$D1${TAB}back"; intake 470 check "$(st "$(rid R1)")" open "with its line taken out of the file the project can be brought again" 471 world w13; echo "$D1" > "$W/work/allow"; echo public > "$W/home/stub/visibility" 472 mkdir "$W/home/store/$(rid K7)"; echo keep > "$W/home/store/$(rid K7)/marker" 473 printf 'rad:%s own-project allow all\n' "$(rid K7)" > "$W/home/stub/policy" 474 q "B${TAB}$(rid K7)${TAB}$D1${TAB}held"; intake 475 check "$(st "$(rid K7)")" held "a project the node seeds is held" 476 echo "$(rid K7)" > "$W/work/remove"; intake 477 check "$(st "$(rid K7)")" "refused: removed by the operator" "remove file: a held project comes off the shelf (rid without rad:)" 478 [ -e "$W/home/store/$(rid K7)/marker" ] && ok "remove file: a held project's storage is left alone" || bad "held storage deleted by the removal" 479 check "$(calls unseed)" 0 "remove file: a held project is not unseeded" 480 # a did of 96 bytes (the queue's cap): the remove line names it whole; its 95-byte prefix names nothing 481 world w14; echo '*' > "$W/work/allow" 482 D96=did:key:z6Mk$(printf 'L%.0s' $(seq 84)); D95=${D96%?} 483 q "B${TAB}$(rid K8)${TAB}$D96${TAB}long key"; intake 484 check "$(st "$(rid K8)")" open "a 96-byte key brings a project" 485 echo "$D95" > "$W/work/remove"; intake 486 check "$(st "$(rid K8)")" open "remove file: a line that is only a prefix of the key takes nothing down" 487 echo "$D96" > "$W/work/remove"; intake 488 check "$(st "$(rid K8)")" "refused: removed by the operator" "remove file: a named 96-byte key's project comes off the shelf" 489 490 # A failed read must not become an empty/prefix list and advance the queue. A directory opens 491 # read-only but pread fails with EISDIR, exercising the failed-read rather than missing-file path. 492 world readfail; echo "$D1" > "$W/work/allow"; mkdir "$W/work/list.tsv" 493 q "B${TAB}$(rid RF1)${TAB}$D1${TAB}retry me"; intake 2> "$T/readfail.err" 494 check "$(calls '^seed rad:')" 0 'list read failed: no fetch decision made' 495 check "$(cat "$W/state" 2>/dev/null || echo 0)" 0 'list read failed: queue offset not advanced' 496 grep -q 'list.tsv read failed' "$T/readfail.err" && ok 'list read failed: stderr explicitly says the request is retried' || bad 'list read error was silent' 497 rmdir "$W/work/list.tsv"; intake 498 check "$(st "$(rid RF1)")" open 'after repairing the list, the same queue request is retried' 499 # mutants of the intake: each removes one guard; the guarded outcome must change 500 mut() { # NAME PYTHON-EDIT 501 python3 -I - "$T/mut-$1.om" "$2" <<'EOF' 502 import sys 503 s = open('open/intake.om').read() 504 old, new = sys.argv[2].split('=>') 505 old = old.replace('|', '\n'); new = new.replace('|', '\n') 506 assert s.count(old) == 1, (old, s.count(old)) 507 open(sys.argv[1], 'w').write(s.replace(old, new)) 508 EOF 509 { printf 'om2\n'; cat "$OMV/om/tls/sha2.om" "$T/mut-$1.om"; } | omc > "$T/mut-$1" 2>> "$T/omc.err" && chmod 700 "$T/mut-$1" 510 } 511 mut noallow 'if not allowed|rsave kr0 fl|ret|end|=>' && { world m1; BIN=$T/mut-noallow 512 q "B${TAB}$(rid C1)${TAB}$D1${TAB}x"; intake 513 [ "$(st "$(rid C1)")" = open ] && ok "MUTANT without the allow check admits the key (the check is what refuses)" || bad "mutant noallow still refused: '$(st "$(rid C1)")'"; BIN=; } || bad "mutant noallow did not build" 514 mut heldrm 'if not held|dounseed|dorm|end|if snpath false=>dounseed|dorm|if snpath false' && { world m2; BIN=$T/mut-heldrm; echo '*' > "$W/work/allow"; echo public > "$W/home/stub/visibility" 515 printf 'rad:%s own-project allow all\n' "$(rid C2)" > "$W/home/stub/policy" 516 mkdir "$W/home/store/$(rid C2)"; echo keep > "$W/home/store/$(rid C2)/marker" 517 q "B${TAB}$(rid C2)${TAB}$D1${TAB}x"; q "W${TAB}$(rid C2)${TAB}$D1"; intake 518 [ ! -e "$W/home/store/$(rid C2)/marker" ] && ok "MUTANT that treats a held row as fetched removes the node's own repository" || bad "mutant heldrm kept the marker"; BIN=; } || bad "mutant heldrm did not build" 519 mut novis 'if not dovis|save kr1|ret|end|=>' && { world m2b; BIN=$T/mut-novis; echo '*' > "$W/work/allow" 520 mkdir "$W/home/store/$(rid C5)"; printf 'rad:%s own-project allow all\n' "$(rid C5)" > "$W/home/stub/policy" 521 q "B${TAB}$(rid C5)${TAB}$D1${TAB}x"; intake 522 [ "$(st "$(rid C5)")" = held ] && ok "MUTANT without the visibility check lists a private repository" || bad "mutant novis: '$(st "$(rid C5)")'"; BIN=; } || bad "mutant novis did not build" 523 mut heldpol 'hp = policy|if eq hp 2|save kr6|ret|end|if eq hp 0|save kr1|ret|end|=>' && { world m2c; BIN=$T/mut-heldpol; echo "$D1" > "$W/work/allow"; echo public > "$W/home/stub/visibility" 524 echo "$(rid C6)" > "$W/home/stub/late"; q "B${TAB}$(rid C6)${TAB}$D1${TAB}x"; intake; sleep 3; : > "$W/home/stub/late" 525 awk -F'\t' -v r="$(rid C6)" '$1!=r' "$W/work/list.tsv" > "$T/m2c.list" && cat "$T/m2c.list" > "$W/work/list.tsv"; q "B${TAB}$(rid C6)${TAB}$D1${TAB}z"; intake 526 [ "$(st "$(rid C6)")" = held ] && ok "MUTANT without the held policy check lists the leftover of a failed fetch" || bad "mutant heldpol: '$(st "$(rid C6)")'"; BIN=; } || bad "mutant heldpol did not build" 527 mut pubauth 'fn lopen sl ulong to void|lclose sl|wpath klist|=>fn lopen sl ulong to void|lclose sl|pok = pinopen|rname klist|' && { world m4; BIN=$T/mut-pubauth; echo '*' > "$W/work/allow" 528 mkdir "$W/home/store/$(rid C4)"; echo keep > "$W/home/store/$(rid C4)/marker" 529 printf '%s\topen\t%s\t2026-11-10\t1\tplanted\t\t\n' "$(rid C4)" "$D1" > "$W/open/list.tsv" 530 q "W${TAB}$(rid C4)${TAB}$D1"; intake 531 [ ! -e "$W/home/store/$(rid C4)/marker" ] && ok "MUTANT that trusts the published list removes a planted repository" || bad "mutant pubauth kept the marker"; BIN=; } || bad "mutant pubauth did not build" 532 mut anywith 'end|end|if not lisdid s e|ret|end|blank=>end|end|blank' && { world m3; BIN=$T/mut-anywith; echo '*' > "$W/work/allow" 533 q "B${TAB}$(rid C3)${TAB}$D1${TAB}x"; q "W${TAB}$(rid C3)${TAB}$D2"; intake 534 [ "$(st "$(rid C3)")" = withdrawn ] && ok "MUTANT without the owner check lets another key withdraw" || bad "mutant anywith: '$(st "$(rid C3)")'"; BIN=; } || bad "mutant anywith did not build" 535 mut nopolicy 'p = policy|if eq p 1|save kr7|ret|end|if eq p 2|rsave kr6 fl|ret|end|=>' && { world m7; BIN=$T/mut-nopolicy; echo "$D1" > "$W/work/allow" 536 printf 'rad:%s some-project allow followed\n' "$(rid P1)" > "$W/home/stub/policy"; echo "$(rid P1)" > "$W/home/stub/notfound" 537 q "B${TAB}$(rid P1)${TAB}$D1${TAB}x"; intake 538 [ "$(calls "unseed rad:$(rid P1)")" = 1 ] && ok "MUTANT without the policy check unseeds a project the owner seeds" || bad "mutant nopolicy did not unseed"; BIN=; } || bad "mutant nopolicy did not build" 539 mut noleft 'left = fl|=>' && { world m8; BIN=$T/mut-noleft; echo "$D1" > "$W/work/allow"; echo "$(rid L1)" > "$W/home/stub/late" 540 q "B${TAB}$(rid L1)${TAB}$D1${TAB}x"; intake; sleep 3; : > "$W/home/stub/late"; q "B${TAB}$(rid L1)${TAB}$D1${TAB}y"; intake 541 case "$(st "$(rid L1)")" in *"already on this node") ok "MUTANT without the leftover rule refuses the project for good";; *) bad "mutant noleft: '$(st "$(rid L1)")'";; esac; BIN=; } || bad "mutant noleft did not build" 542 mut norsave 'fn rsave t view uchar * fl bool to void|if not fl|save t|end|end|=>fn rsave t view uchar * fl bool to void|save t|end|' && { world m10; BIN=$T/mut-norsave; echo "$D1" > "$W/work/allow"; echo "$(rid L2)" > "$W/home/stub/late" 543 q "B${TAB}$(rid L2)${TAB}$D1${TAB}x"; intake; sleep 3; : > "$W/home/stub/late"; q "B${TAB}$(rid L2)${TAB}$D2${TAB}y"; intake; q "B${TAB}$(rid L2)${TAB}$D1${TAB}z"; intake 544 case "$(st "$(rid L2)")" in *"already on this node") ok "MUTANT whose refusals replace the failed-fetch row refuses the project for good";; *) bad "mutant norsave: '$(st "$(rid L2)")'";; esac; BIN=; } || bad "mutant norsave did not build" 545 mut noutf8 'put dsl 0 jget kdesc 1 400|usnm|usds|=>put dsl 0 jget kdesc 1 400|' && { world m9; BIN=$T/mut-noutf8; echo "$D1" > "$W/work/allow" 546 printf '{"xyz.radicle.project":{"defaultBranch":"main","description":"bad \377 byte","name":"n"}}\n' > "$W/home/stub/payload" 547 q "B${TAB}$(rid U1)${TAB}$D1${TAB}x"; intake 548 iconv -f UTF-8 -t UTF-8 "$W/open/list.tsv" > /dev/null 2>&1 && bad "mutant noutf8 still wrote valid UTF-8" || ok "MUTANT without the UTF-8 pass publishes an invalid list"; BIN=; } || bad "mutant noutf8 did not build" 549 mut snapraw 'if or lt c 32 eq c 127|if not and tabs eq c 9|c = uchar 32|end|end|put ub i c=>put ub i c' && { world m11; BIN=$T/mut-snapraw; echo "$D1" > "$W/work/allow" 550 G=$W/src; git init -q -b main "$G"; ( cd "$G" && git config user.name a && git config user.email a@example.invalid && git config commit.gpgsign false && printf 'ctl\001x\n' > README.md && git add -A && git commit -q -m one ) 551 git clone -q --bare "$G" "$W/home/stub/template.git"; q "B${TAB}$(rid S2)${TAB}$D1${TAB}x"; intake 552 [ "$(tr -d '\t\n' < "$W/open/p/$(rid S2).txt" | LC_ALL=C grep -c '[[:cntrl:]]')" != 0 ] && ok "MUTANT without the control-byte pass writes a control byte into the snapshot" || bad "mutant snapraw wrote a clean snapshot"; BIN=; } || bad "mutant snapraw did not build" 553 mut snapkeep 'if snpath false|r = unlink pth 0 get pthl 0|unpin|end|=>' && { world m12; BIN=$T/mut-snapkeep; echo "$D1" > "$W/work/allow" 554 q "B${TAB}$(rid S3)${TAB}$D1${TAB}x"; q "W${TAB}$(rid S3)${TAB}$D1"; intake 555 [ -e "$W/open/p/$(rid S3).txt" ] && ok "MUTANT that keeps the snapshot leaves the page data of a withdrawn project" || bad "mutant snapkeep removed the snapshot"; BIN=; } || bad "mutant snapkeep did not build" 556 mut oldread 'k = pread int sub get lst o 1 lcb mul sl 65536 65536 long pos=>w = ulong 0|if lt pos 262143|w = sub 262143 pos|end|if gt w 65536|w = ulong 65536|end|k = long 0|if gt w 0|k = pread int sub get lst o 1 lcb mul sl 65536 w long pos|end' && { world m5; BIN=$T/mut-oldread; echo "$D1" > "$W/work/allow" 557 bigrun; k=$(keepck "$T/big.before" "$W/work/list.tsv" "$(rid X1)" "$BREF" "$BOPEN" "$(rid N1)" 2>&1) 558 [ $? != 0 ] && ok "MUTANT that reads only the former 262,143 bytes of the list cuts it ($(wc -l < "$W/work/list.tsv") of $((BROWS + 2)) rows left)" || bad "mutant oldread kept every row"; BIN=; } || bad "mutant oldread did not build" 559 mut norotate 'if not qrotate|ret false|end|z = sleepns `1000000000`|ret true|=>ret false|' && { world m6; BIN=$T/mut-norotate; echo "$D1" > "$W/work/allow" 560 awk 'BEGIN { for (i = 0; i < 4200; i++) printf "X\tz2abcdefghijkmnopqrstuvwxyzABCDEFGHJKLM\tdid:key:z6MkFiller1111111111111111111\n" }' > "$W/open/queue"; intake 561 [ -e "$W/open/queue" ] && ok "MUTANT without the rotation keeps the queue growing toward the cap" || bad "mutant norotate removed the queue"; BIN=; } || bad "mutant norotate did not build" 562 563 mut nosweep 'did2 = sweep|=>did2 = false|' && { world m13; BIN=$T/mut-nosweep; echo '*' > "$W/work/allow" 564 q "B${TAB}$(rid C7)${TAB}$D1${TAB}x"; intake; echo "rad:$(rid C7)" > "$W/work/remove"; intake 565 [ "$(st "$(rid C7)")" = open ] && ok "MUTANT without the sweep leaves a removed project on the shelf" || bad "mutant nosweep: '$(st "$(rid C7)")'"; BIN=; } || bad "mutant nosweep did not build" 566 mut nodeny 'if denied|rsave kr8 fl|ret|end|=>' && { world m14; BIN=$T/mut-nodeny; echo '*' > "$W/work/allow" 567 q "B${TAB}$(rid C8)${TAB}$D1${TAB}x"; intake; echo "rad:$(rid C8)" > "$W/work/remove"; intake; q "B${TAB}$(rid C8)${TAB}$D1${TAB}again"; intake 568 [ "$(calls "^seed rad:$(rid C8)")" = 2 ] && ok "MUTANT without the bring check fetches a removed project again" || bad "mutant nodeny: $(calls "^seed rad:$(rid C8)") fetches"; BIN=; } || bad "mutant nodeny did not build" 569 mut rmheld 'if fetched|dounseed|dorm|end|=>dounseed|dorm|' && { world m15; BIN=$T/mut-rmheld; echo "$D1" > "$W/work/allow"; echo public > "$W/home/stub/visibility" 570 mkdir "$W/home/store/$(rid C9)"; echo keep > "$W/home/store/$(rid C9)/marker"; printf 'rad:%s own-project allow all\n' "$(rid C9)" > "$W/home/stub/policy" 571 q "B${TAB}$(rid C9)${TAB}$D1${TAB}x"; intake; echo "$(rid C9)" > "$W/work/remove"; intake 572 [ ! -e "$W/home/store/$(rid C9)" ] && ok "MUTANT that treats a held project as fetched deletes its storage on removal" || bad "mutant rmheld kept the storage"; BIN=; } || bad "mutant rmheld did not build" 573 mut nodel 'dg = dodel|if eq dg 2|save kr6|ret|end|if eq dg 0|save kr9|ret|end|=>' && { world m16; BIN=$T/mut-nodel; echo '*' > "$W/work/allow"; echo public > "$W/home/stub/visibility" 574 mkdir "$W/home/store/$(rid E1)"; printf 'rad:%s own-project allow all\n' "$(rid E1)" > "$W/home/stub/policy" 575 q "B${TAB}$(rid E1)${TAB}$D2${TAB}not mine"; intake 576 [ "$(st "$(rid E1)")" = held ] && ok "MUTANT without the delegate check lets any key list the node's own project" || bad "mutant nodel: '$(st "$(rid E1)")'"; BIN=; } || bad "mutant nodel did not build" 577 mut delprefix 'ret eq c 13=>ret true' && { world m17; BIN=$T/mut-delprefix; echo '*' > "$W/work/allow"; echo public > "$W/home/stub/visibility" 578 mkdir "$W/home/store/$(rid E2)"; printf 'rad:%s own-project allow all\n' "$(rid E2)" > "$W/home/stub/policy"; printf '%sX (longer key)\n' "$D2" > "$W/home/stub/delegates" 579 q "B${TAB}$(rid E2)${TAB}$D2${TAB}prefix"; intake 580 [ "$(st "$(rid E2)")" = held ] && ok "MUTANT without the end-of-key check admits a key that is only a prefix of a delegate" || bad "mutant delprefix: '$(st "$(rid E2)")'"; BIN=; } || bad "mutant delprefix did not build" 581 mut oldcap 'end|if held|if not dovis=>end|if ge lcount true 8|rsave kr0 fl|ret|end|if held|if not dovis' && { world m18; BIN=$T/mut-oldcap; echo "$D1" > "$W/work/allow" 582 for i in 1 2 3 4 5 6 7 8 9; do q "B${TAB}$(rid G$i)${TAB}$D1${TAB}n$i"; done; intake 583 [ "$(st "$(rid G9)")" != open ] && ok "MUTANT with the old 8-a-key cap refuses the ninth fetched project ($(st "$(rid G9)"))" || bad "mutant oldcap listed the ninth"; BIN=; } || bad "mutant oldcap did not build" 584 mut delstart 'if gt i 0|if ne get cb sub i 1 10|ret false|end|end=>' && { world m19; BIN=$T/mut-delstart; echo '*' > "$W/work/allow"; echo public > "$W/home/stub/visibility" 585 mkdir "$W/home/store/$(rid E3)"; printf 'rad:%s own-project allow all\n' "$(rid E3)" > "$W/home/stub/policy"; printf 'x%s (two)\n' "$D2" > "$W/home/stub/delegates" 586 q "B${TAB}$(rid E3)${TAB}$D2${TAB}mid-line"; intake 587 [ "$(st "$(rid E3)")" = held ] && ok "MUTANT without the start-of-line check admits a key named in the middle of a delegates line" || bad "mutant delstart: '$(st "$(rid E3)")'"; BIN=; } || bad "mutant delstart did not build" 588 mut rmstart 'if not st|ret false|end|for k ulong n bound 44=>for k ulong n bound 44' && { world m20; BIN=$T/mut-rmstart; echo "$D1" > "$W/work/allow"; echo public > "$W/home/stub/visibility" 589 mkdir "$W/home/store/$(rid E4)"; printf 'rad:z2abcdefghijkmnopqrstuvwQQ rad:%s allow all\n' "$(rid E4)" > "$W/home/stub/policy" 590 q "B${TAB}$(rid E4)${TAB}$D1${TAB}name"; intake 591 [ "$(st "$(rid E4)")" = held ] && ok "MUTANT without the first-column check takes a project name for the node's policy" || bad "mutant rmstart: '$(st "$(rid E4)")'"; BIN=; } || bad "mutant rmstart did not build" 592 mut rmend 'e = add i n|if ge e lim|ret true|end|c = get cb e|if eq c 32|ret true|end|if eq c 9|ret true|end|if eq c 13|ret true|end|ret eq c 10=>ret true' && { world m21; BIN=$T/mut-rmend; echo "$D1" > "$W/work/allow"; echo public > "$W/home/stub/visibility" 593 mkdir "$W/home/store/$(rid E5)"; printf 'rad:%sX longer-rid allow all\n' "$(rid E5)" > "$W/home/stub/policy" 594 q "B${TAB}$(rid E5)${TAB}$D1${TAB}longer"; intake 595 [ "$(st "$(rid E5)")" = held ] && ok "MUTANT without the end-of-rid check takes a longer rid for the node's policy" || bad "mutant rmend: '$(st "$(rid E5)")'"; BIN=; } || bad "mutant rmend did not build" 596 # ------------------------------------------------------------------ part 2: the shelf inside forged 597 mkdir -p "$T/data" "$T/social"; mkdir -m 700 "$T/slwork" 598 build() { # OUT [sed expression on the composed source] 599 { printf 'om2\n'; cat $(FORGE_TRY="salvage open" ./run.sh units); } \ 600 | sed -e "s|^text tfdata \".*\"|text tfdata \"$T/data/\"|" -e "s/18480/$PORT/g" ${2:+-e "$2"} | omc > "$1" 2>> "$T/omc.err" && chmod 700 "$1" 601 } 602 build "$T/forged" || { echo "BUILD FAILED forged: $(tail -2 "$T/omc.err")"; exit 1; } 603 start() { 604 FORGE_SOCIAL_DIR="$T/social/" INTERPLANE_SALVAGE_DIR="$T/salvage/" taskset -c "$CORES" nice -n 10 "$1" 2>> "$T/forged.err" & 605 PID=$! 606 for i in $(seq 50); do curl -s -o /dev/null "http://127.0.0.1:$PORT/" && return 0; sleep 0.1; done 607 echo "server did not start"; cat "$T/forged.err"; exit 1 608 } 609 B="http://127.0.0.1:$PORT" 610 # code: forged adds translation hints while it sends a page (server/tr.om: translate="no" attributes and 611 # around hashes and ids); the content checks read the page without them 612 # (server/tests/translate.sh gates the hints themselves) 613 code() { m=$1; p=$2; shift 2; c=$(curl -s -o "$T/body" -D "$T/hdr" -X "$m" "$@" "$B$p" -w '%{http_code}'); grep -qi '^content-type: text/html' "$T/hdr" && sed -i 's/\([^<]*\)<\/span>/\1/g; s/ translate="no"//g' "$T/body"; printf %s "$c"; } 614 hdr() { grep -i "^$1:" "$T/hdr" | head -1 | cut -d' ' -f2- | tr -d '\r'; } 615 field() { grep -o "name=\"$1\" value=\"[^\"]*\"" "$T/body" | head -1 | sed 's/.*value="//; s/"$//'; } 616 ssh-keygen -q -t `ed25519` -N '' -C t1 -f "$T/k1" 617 did() { python3 -I - "$1" <<'EOF' 618 import sys, base64 619 blob = base64.b64decode(open(sys.argv[1]).read().split()[1]) 620 raw = b'\xed\x01' + blob[-32:] 621 A = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz' 622 n = int.from_bytes(raw, 'big'); s = '' 623 while n: n, r = divmod(n, 58); s = A[r] + s 624 print('did:key:z' + s) 625 EOF 626 } 627 K1=$(did "$T/k1.pub") 628 signin() { # [KEYFILE DID], default the first throwaway key 629 code GET /login >/dev/null 630 PREN=$(hdr set-cookie | sed -n 's/^\([A-Za-z_-]*forge_pre\)=.*/\1/p') 631 PRE=$(hdr set-cookie | sed -n 's/^[A-Za-z_-]*forge_pre=\([0-9a-f]*\);.*/\1/p') 632 CSRF=$(field csrf); NONCE=$(field nonce); TS=$(field ts) 633 printf '%s' "interplane-forge-login:$NONCE:$TS" | ssh-keygen -Y sign -f "${1:-$T/k1}" -n interplane-forge > "$T/sig" 2>/dev/null 634 c=$(code POST /login -H "Cookie: $PREN=$PRE" --data-urlencode "csrf=$CSRF" --data-urlencode "nonce=$NONCE" --data-urlencode "ts=$TS" --data-urlencode "did=${2:-$K1}" --data-urlencode "sig@$T/sig") 635 SES=$(hdr set-cookie | sed -n 's/^__Host-forge_session=\([0-9a-f]*\);.*/\1/p') 636 CK="Cookie: __Host-forge_session=$SES" 637 } 638 Q=$T/data/open/queue 639 qn() { [ -f "$Q" ] && wc -l < "$Q" || echo 0; } 640 start "$T/forged" 641 R1=$(rid H1) 642 c=$(code GET /open); check "$c" 301 "GET /open redirects"; check "$(hdr location)" /open/ "to /open/" 643 c=$(code GET /open/); check "$c" 200 "GET /open/ signed out" 644 grep -q "Open builds" "$T/body" && grep -q "Sign in with your key" "$T/body" && ok "signed out: the page asks for a sign-in" || bad "signed-out page text" 645 grep -q 'name="rid"' "$T/body" && bad "signed out: the form is shown" || ok "signed out: no bring form" 646 grep -q "waiting for its first project" "$T/body" && ok "an empty shelf says so" || bad "empty shelf text" 647 c=$(code POST /open/ --data-urlencode "action=bring" --data-urlencode "rid=rad:$R1" --data-urlencode "consent=yes"); [ "$c" != 200 ] && [ "$(qn)" = 0 ] && ok "NEG a POST without a session writes nothing ($c)" || bad "unsigned POST: $c, queue $(qn)" 648 signin; check "${#SES}" 64 "signed in with a throwaway key" 649 c=$(code GET /open/ -H "$CK"); check "$c" 200 "GET /open/ signed in" 650 TOK=$(field csrf); check "${#TOK}" 32 "the bring form carries a CSRF token" 651 grep -q 'name="rid"' "$T/body" && ok "signed in: the bring form is shown" || bad "no bring form when signed in" 652 post() { code POST /open/ -H "$CK" --data-urlencode "csrf=$TOK" "$@"; } 653 c=$(code POST /open/ -H "$CK" --data-urlencode "action=bring" --data-urlencode "rid=rad:$R1" --data-urlencode "consent=yes"); [ "$c" != 303 ] && [ "$(qn)" = 0 ] && ok "NEG no CSRF token: refused ($c)" || bad "POST without csrf: $c" 654 c=$(code POST /open/ -H "$CK" --data-urlencode "csrf=${TOK%?}x" --data-urlencode "action=bring" --data-urlencode "rid=rad:$R1" --data-urlencode "consent=yes"); [ "$c" != 303 ] && [ "$(qn)" = 0 ] && ok "NEG wrong CSRF token: refused ($c)" || bad "POST with wrong csrf: $c" 655 c=$(post --data-urlencode "action=bring" --data-urlencode "rid=rad:../../../etc/passwd" --data-urlencode "consent=yes" --data-urlencode "note="); check "$c" 400 "NEG a path as the rid" 656 c=$(post --data-urlencode "action=bring" --data-urlencode "rid=rad:z2abc" --data-urlencode "consent=yes" --data-urlencode "note="); check "$c" 400 "NEG a rid that is too short" 657 c=$(post --data-urlencode "action=bring" --data-urlencode "rid=rad:${R1}0" --data-urlencode "consent=yes" --data-urlencode "note="); check "$c" 400 "NEG a rid with a character outside base58" 658 c=$(post --data-urlencode "action=bring" --data-urlencode "rid=rad:$R1" --data-urlencode "note="); check "$c" 400 "NEG no permission tick" 659 c=$(post --data-urlencode "action=bring" --data-urlencode "rid=rad:$R1" --data-urlencode "consent=yes" --data-urlencode "note=$(head -c 201 /dev/zero | tr '\0' n)"); check "$c" 400 "NEG a note over 200 bytes" 660 c=$(post --data-urlencode "action=erase" --data-urlencode "rid=rad:$R1" --data-urlencode "consent=yes" --data-urlencode "note="); check "$c" 400 "NEG an unknown action" 661 check "$(qn)" 0 "nine refused posts wrote nothing" 662 c=$(post --data-urlencode "action=bring" --data-urlencode "rid=rad:$R1" --data-urlencode "consent=yes" --data-urlencode "note=needs a parser & tests"); check "$c" 303 "bring" 663 check "$(hdr location)" /open/ "bring returns to the shelf" 664 check "$(sed -n 1p "$Q")" "B${TAB}$R1${TAB}$K1${TAB}needs a parser & tests" "the queue line: kind, rid, the signed-in key, the note" 665 c=$(post --data-urlencode "action=bring" --data-urlencode "rid=$(rid H2)" --data-urlencode "consent=yes" --data-urlencode "note=$(printf 'two\r\nlines\there')"); check "$c" 303 "bring without the rad: prefix, note with a line break and a tab" 666 check "$(qn)" 2 "a line break in the note does not add a queue line" 667 check "$(sed -n 2p "$Q" | awk -F'\t' '{print NF}')" 4 "a tab in the note does not add a field" 668 c=$(post --data-urlencode "action=bring" --data-urlencode "rid=rad:$R1" --data-urlencode "consent=yes" --data-urlencode "note=" --data-urlencode "did=did:key:z6MkSomebodyElse"); check "$c" 303 "bring with an empty note"; check "$(sed -n 3p "$Q" | cut -f3)" "$K1" "a did field in the form is ignored; the session decides" 669 c=$(post --data-urlencode "action=withdraw" --data-urlencode "rid=rad:$R1"); check "$c" 303 "withdraw" 670 check "$(sed -n 4p "$Q")" "W${TAB}$R1${TAB}$K1" "the withdraw line" 671 c=$(code POST /open/ -H "$CK" -H "Origin: https://evil.example" --data-urlencode "csrf=$TOK" --data-urlencode "action=withdraw" --data-urlencode "rid=rad:$R1"); [ "$c" != 303 ] && [ "$(qn)" = 4 ] && ok "NEG a POST from another origin writes nothing ($c)" || bad "cross-origin POST: $c, queue $(qn)" 672 c=$(code PUT /open/ -H "$CK"); check "$c" 405 "NEG PUT" 673 # the list, written here as the intake would write it, with hostile text in every free field 674 H='"&' 675 { 676 printf '%s\topen\t%s\t2026-11-10\t412\t%s\t%s\t%s\n' "$R1" "$K1" "$H" "desc $H" "note $H" 677 printf '%s\topen\t%s\t2026-11-09\t77\tother-project\tsecond one\twants a reviewer\n' "$(rid H3)" "$D2" 678 printf '%s\trefused: larger than 50 MiB\t%s\t2026-11-10\t0\t\t\tmine\n' "$(rid H4)" "$K1" 679 printf '%s\trefused: not found\t%s\t2026-11-10\t0\t\t\ttheirs\n' "$(rid H5)" "$D2" 680 printf '%s\twithdrawn\t%s\t2026-11-10\t0\tgone-project\t\t\n' "$(rid H6)" "$D2" 681 printf '../../etc\topen\t%s\t2026-11-10\t1\tbad-rid\tx\tx\n' "$D2" 682 printf '%s\topen\t%s\n' "$(rid H7)" "$D2" 683 printf '%s\theld\t%s\t2026-11-10\t900\tnode-project\talready on the node\tours\n' "$(rid H8)" "$D2" 684 } > "$T/data/open/list.tsv" 685 mkdir -p "$T/data/open/p" 686 { 687 printf 'H\tabc123def4567890abc123def4567890abc123de\t2026-11-10\n' 688 printf 'C\t1a2b3c4\t2026-11-10\tAda \tfix \n' 689 printf 'T\tb\tREADME.md\nT\tt\tsrc\nT\tb\twe&name.txt\n' 690 printf 'R\t# Demo\nR\t\nR\t\n' 691 printf 'X\tunknown kind\njunk without a tab\n' 692 } > "$T/data/open/p/$R1.txt" 693 cp "$T/data/open/p/$R1.txt" "$T/data/open/p/$(rid H4).txt" 694 c=$(code GET /open/); check "$c" 200 "the shelf with rows" 695 grep -q ' of a listed project" 719 grep -q -e 'src/' "$T/body" && grep -q '
  • we<ird>&name.txt
  • ' "$T/body" && grep -q '`abc123def4567890abc123def4567890abc123de` 2026-11-10' "$T/body" && grep -q 'No public Git URL yet: Interplane does not serve Git clones yet.' "$T/body" && grep -q 'Not verified' "$T/body" && ok "the page shows head, commits, files (a folder with a slash), no-clone-URL line, Not verified" || bad "project page content" 722 grep -q -e 'unknown kind' -e 'junk without' "$T/body" && bad "an unknown snapshot line is shown" || ok "snapshot lines of an unknown kind are not shown" 723 c=$(code GET "/open/$(rid H8)"); check "$c" 200 "a held project has a page"; grep -q 'No snapshot of this project yet' "$T/body" && ok "without a snapshot the page says so" || bad "no-snapshot text" 724 c=$(code GET "/open/$(rid H4)"); check "$c" 404 "NEG a refused project has no page, even with a snapshot file there" 725 c=$(code GET "/open/$(rid H6)"); check "$c" 404 "NEG a withdrawn project has no page" 726 c=$(code GET "/open/$(rid ZZ)"); check "$c" 404 "NEG a rid that is not on the shelf" 727 c=$(code GET "/open/zshort"); check "$c" 404 "NEG a rid that is too short" 728 c=$(code GET "/open/${R1}0"); check "$c" 404 "NEG a rid with a character outside base58" 729 c=$(curl -s -o /dev/null --path-as-is -w '%{http_code}' "$B/open/../open/p/$R1.txt"); [ "$c" != 200 ] && ok "NEG the snapshot file is not served as a path ($c)" || bad "snapshot file served directly" 730 c=$(code POST "/open/$R1" -H "$CK" --data-urlencode "csrf=$TOK"); [ "$c" != 200 ] && [ "$c" != 303 ] && ok "NEG POST to a project page is refused ($c)" || bad "POST to a project page: $c" 731 c=$(code GET "/open/$R1" -H 'Accept: application/json'); check "$c" 200 "the project page as JSON" 732 python3 -I - "$T/body" "$R1" "$K1" <<'EOF' && ok "project JSON: parses; head, commits, files and README round-trip as data" || bad "project JSON" 733 import json, sys 734 d = json.load(open(sys.argv[1], encoding='utf-8')) 735 assert d['schema'] == 'interplane/open-build/1' and d['rid'] == sys.argv[2] and d['brought_by'] == sys.argv[3], d 736 assert d['verified'] is False and d['kib'] == 412 737 assert d['head'] == '`abc123def4567890abc123def4567890abc123de` 2026-11-10', d['head'] 738 assert d['commits'] == ['`1a2b3c4` 2026-11-10 Ada fix '], d['commits'] 739 assert d['files'] == ['README.md', 'src/', 'we&name.txt'], d['files'] 740 assert d['readme'] == '# Demo\n\n\n', d['readme'] 741 assert d['parts'] == [], d['parts'] 742 EOF 743 # parts taken from the project: the salvage store is on in this test server. A second throwaway 744 # key submits (its own write budget), the real collector verifies the derived part. 745 c=$(code GET "/open/$R1"); grep -q 'Parts taken from this project' "$T/body" && grep -q 'None yet' "$T/body" && ok "a project with no submission says so and points to Bring your build" || bad "empty parts section" 746 { printf 'om2\n'; cat "$OMV/om/tls/sha2.om" salvage/00core.om salvage/10verify.om salvage/collector.om; } | omc > "$T/collector" 2>> "$T/omc.err" && chmod 700 "$T/collector" || bad "collector did not build" 747 ssh-keygen -q -t `ed25519` -N '' -C t2 -f "$T/k2"; K2=$(did "$T/k2.pub"); CK1=$CK; signin "$T/k2" "$K2"; CK2=$CK; CK=$CK1 748 code GET /salvage/new -H "$CK2" >/dev/null; STOK=$(field csrf) 749 spost() { p=$1; shift; code POST "$p" -H "$CK2" --data-urlencode "csrf=$STOK" "$@"; } 750 src() { spost /salvage/ --data-urlencode action=source --data-urlencode consent=yes --data-urlencode "title=$1" --data-urlencode "origin=$2" --data-urlencode license=MIT --data-urlencode "description=half a parser" --data-urlencode "source=a sketch $1" --data-urlencode credit=tester --data-urlencode "language=Plain text"; } 751 c=$(src 'Parser sketch' "rad:$R1"); check "$c" 303 "a source is submitted with this project as its origin"; SID=$(hdr location | sed 's|.*/||') 752 c=$(src 'Other project source' "rad:$(rid H3)"); SID2=$(hdr location | sed 's|.*/||') 753 c=$(src 'Near miss origin' "see rad:$R1"); SID3=$(hdr location | sed 's|.*/||') 754 check "${#SID}${#SID2}${#SID3}" 646464 "three sources saved" 755 c=$(code GET "/open/$R1") 756 grep -q "href=\"/salvage/$SID\">Parser <b>sketch</b> (source, not verified)" "$T/body" && ok "the project page lists the source taken from it, title escaped, as not verified" || bad "source not listed" 757 grep -q -e "$SID2" -e "$SID3" "$T/body" && bad "a source of another origin is listed" || ok "a source of another project, or with the rid only inside its origin text, is not listed" 758 printf 'om2\ntext msg "hello\\n"\nfn main to int\nr = write 1 msg 0 len msg\nret 0\nend\n' > "$T/part.om"; printf 'hello\n' > "$T/expected" 759 derive() { spost "/salvage/$SID" --data-urlencode action=derive --data-urlencode consent=yes --data-urlencode "title=$1" --data-urlencode "description=one small part" --data-urlencode "source@$T/part.om" --data-urlencode "input=" --data-urlencode "expected@$T/expected"; } 760 c=$(derive 'Greeting part'); check "$c" 303 "an Omega part is derived from that source"; PRT=$(hdr location | sed 's|.*/||') 761 c=$(code GET "/open/$R1"); grep -q "$PRT" "$T/body" && bad "an unverified draft part is listed" || ok "a derived part that is not verified and published is not listed" 762 c=$(spost "/salvage/$PRT" --data-urlencode action=verify); check "$c" 303 "verification is queued" 763 env -i INTERPLANE_SALVAGE_DIR="$T/salvage/" INTERPLANE_SALVAGE_WORK="$T/slwork/" OMEGA_COMPILER="$OMC" taskset -c "$CORES" "$T/collector" once > "$T/collector.out" 2>&1; check "$?" 1 "the real collector ran the declared example and wrote a receipt (exit 1 = a receipt was written)" 764 c=$(spost "/salvage/$PRT" --data-urlencode action=publish); check "$c" 303 "the verified part is published" 765 c=$(derive 'Draft part, never verified'); DRAFT=$(hdr location | sed 's|.*/||') 766 c=$(code GET "/open/$R1") 767 grep -q "href=\"/salvage/$PRT\">Greeting part (Omega part, verified)" "$T/body" && ok "the project page lists the verified part with a link to its page and receipt" || bad "verified part not listed" 768 grep -q "$DRAFT" "$T/body" && bad "a second, unverified draft is listed" || ok "a later unverified draft is still not listed" 769 grep -q 'Not verified. Brought by' "$T/body" && ok "the project itself stays Not verified" || bad "project line changed" 770 c=$(code GET "/open/$(rid H3)"); grep -q "$SID2" "$T/body" && ! grep -q -e "$SID\"" -e "$PRT" "$T/body" && ok "the other project lists only its own source" || bad "parts of the other project" 771 code GET "/open/$R1" -H 'Accept: application/json' >/dev/null 772 python3 -I - "$T/body" "$SID" "$PRT" <<'EOF' && ok "project JSON: parts holds the verified part and the source, newest first" || bad "project JSON parts" 773 import json, sys 774 p = json.load(open(sys.argv[1], encoding='utf-8'))['parts'] 775 assert p == [{'id': sys.argv[3], 'title': 'Greeting part', 'kind': 'omega-part', 'verified': True}, 776 {'id': sys.argv[2], 'title': 'Parser sketch', 'kind': 'source', 'verified': False}], p 777 EOF 778 # names of their own for the JSON, the forge row entries, the line for agents 779 c=$(code GET /open.json); check "$c" 200 "GET /open.json" 780 python3 -I -c 'import json,sys; d=json.load(open(sys.argv[1])); assert d["schema"]=="interplane/open-builds/1" and len(d["projects"])==3' "$T/body" && ok "/open.json is the shelf JSON without an Accept header" || bad "/open.json" 781 c=$(code GET "/open/$R1.json"); check "$c" 200 "GET /open/.json" 782 python3 -I -c 'import json,sys; d=json.load(open(sys.argv[1])); assert d["schema"]=="interplane/open-build/1" and d["rid"]==sys.argv[2] and len(d["commits"])==1' "$T/body" "$R1" && ok "/open/.json is the project JSON without an Accept header" || bad "/open/.json" 783 c=$(code GET "/open/$(rid H4).json"); check "$c" 404 "NEG the .json name of a refused project" 784 c=$(code GET "/open/${R1}.jsonx"); check "$c" 404 "NEG a near-miss suffix is not a rid" 785 c=$(code POST /open.json -H "$CK" --data-urlencode "csrf=$TOK"); [ "$c" != 200 ] && [ "$c" != 303 ] && ok "NEG POST to /open.json is refused ($c)" || bad "POST /open.json: $c" 786 c=$(code GET /open/) 787 grep -q 'Open builds' "$T/body" && ok "the forge row carries Open builds" || bad "no Open builds entry in the forge row" 788 grep -q 'Bring your build' "$T/body" && ok "the forge row carries Bring your build while the store is on" || bad "no Bring your build entry" 789 grep -q 'open.json' "$T/body" && ok "the shelf tells agents where its JSON is" || bad "no line for agents" 790 # no queue cap: a queue past the former 1 MiB still takes a line (queue_bytes alarms; the data 791 # reserve, through open/space, is what refuses) 792 head -c `1048577` /dev/zero > "$Q" 793 c=$(post --data-urlencode "action=bring" --data-urlencode "rid=rad:$R1" --data-urlencode "consent=yes" --data-urlencode "note="); check "$c" 303 "a queue past the former 1 MiB still takes a line" 794 [ "$(stat -c %s "$Q")" -gt `1048577` ] && ok "and the line is written" || bad "queue not written" 795 stop 796 # the shelf past the former 262,143-byte list buffer: forged reads open/list.tsv a row at a 797 # time; every row on the shelf of a 1.2 MB list (one of them 70,000 bytes) is in /open.json, in 798 # order, and on /open/; project pages past the former buffer answer 799 cp "$T/data/open/list.tsv" "$T/list.small" 800 set -- $(bigplant "$T/data/open/list.tsv" `1200000` 70000 "$D1" "$D2" "$D3"); BPUB=$2 BOPEN=$3 BLONG=$5 801 # shelfck LIST JSON: the rids of /open.json are the shelf rows of LIST, in order 802 shelfck() { 803 python3 -I - "$1" "$2" <<'EOF' 804 import json, sys 805 want = [l.split('\t')[0] for l in open(sys.argv[1], encoding='utf-8') if l.split('\t')[1] in ('open', 'held', 'stored')] 806 got = [p['rid'] for p in json.load(open(sys.argv[2], encoding='utf-8'))['projects']] 807 assert got == want, (len(got), len(want)) 808 print(len(got)) 809 EOF 810 } 811 start "$T/forged" 812 c=$(code GET /open.json); check "$c" 200 "GET /open.json with a 1.2 MB list" 813 n=$(shelfck "$T/data/open/list.tsv" "$T/body" 2>&1) && ok "/open.json lists all $n shelf rows of the 1.2 MB list, in order" || bad "/open.json: $n" 814 check "$n" "$BPUB" "and that is every open and held row planted" 815 c=$(code GET /open/); [ "$c" = 200 ] && grep -q "$BOPEN" "$T/body" && grep -q "$BLONG" "$T/body" && ok "/open/ shows the last open row and the 70,000-byte row" || bad "/open/ with a 1.2 MB list: $c" 816 c=$(code GET "/open/$BOPEN"); check "$c" 200 "the project page of the last row answers" 817 c=$(code GET "/open/$BLONG.json"); [ "$c" = 200 ] && python3 -I -c 'import json,sys; d=json.load(open(sys.argv[1])); assert d["rid"]==sys.argv[2] and len(d["description"])==400' "$T/body" "$BLONG" && ok "the 70,000-byte row has a page; its description is cut at the page's 400 as every row's is" || bad "long row page: $c $(head -c 200 "$T/body")" 818 stop 819 if build "$T/forged-mtr" '/^fn ohlfill /,/^fn ohlnext /s/^k = pread int sub get gost 0 1 goc 0 65536 long pos$/w = ulong 0\nif lt pos 262143\nw = sub 262143 pos\nend\nif gt w 65536\nw = ulong 65536\nend\nk = long 0\nif gt w 0\nk = pread int sub get gost 0 1 goc 0 w long pos\nend/'; then 820 start "$T/forged-mtr"; c=$(code GET /open.json) 821 n=$(shelfck "$T/data/open/list.tsv" "$T/body" 2>&1 | tail -1) && case "$n" in AssertionError*) false;; esac && bad "mutant oldread (forged) listed every row" || ok "MUTANT of forged that reads only the former 262,143 bytes of the list loses rows ($c: $n)"; stop 822 else bad "mutant oldread (forged) did not build"; fi 823 # Far past fob in BOTH representations. Quotes double in JSON and ampersands/quotes expand 824 # five/sixfold in HTML. Assert complete ordered rows, not only the last rid or a successful code. 825 python3 -I - "$T/data/open/list.tsv" "$D1" <<'EOF' 826 import sys 827 A = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz' 828 with open(sys.argv[1], 'w') as f: 829 for i in range(10000): 830 r = 'z2Huge%s%s%sabcdefghijkmnopqrstuvwxyz' % (A[i // 3364 % 58], A[i // 58 % 58], A[i % 58]) 831 f.write('\t'.join([r, 'open', sys.argv[2], '2026-11-11', '1', '&' * 120, '"' * 400, '&' * 200]) + '\n') 832 EOF 833 htmlshelfck() { 834 python3 -I - "$1" "$2" <<'EOF' 835 import sys 836 from html.parser import HTMLParser 837 class Cards(HTMLParser): 838 def __init__(self): super().__init__(); self.rids=[]; self.card=False 839 def handle_starttag(self, tag, attrs): 840 d=dict(attrs) 841 if tag=='article' and 'sl-card' in d.get('class','').split(): self.card=True 842 if self.card and tag=='a' and '/open/' in d.get('href',''): self.rids.append(d['href'].rsplit('/',1)[-1]) 843 def handle_endtag(self, tag): 844 if tag=='article': self.card=False 845 p=Cards(); data=open(sys.argv[2]).read(); p.feed(data) 846 want=[l.split('\t')[0] for l in open(sys.argv[1])] 847 assert len(data.encode()) > `8388608`, len(data.encode()) 848 assert p.rids == want, (len(p.rids), len(want)) 849 print(len(p.rids)) 850 EOF 851 } 852 start "$T/forged" 853 c=$(code GET /open.json); n=$(shelfck "$T/data/open/list.tsv" "$T/body" 2>&1); rc=$? 854 [ "$c" = 200 ] && [ "$rc" = 0 ] && [ "$(stat -c %s "$T/body")" -gt `8388608` ] && grep -qi 'Transfer-Encoding: chunked' "$T/hdr" && ok "streamed /open.json exceeds 8 MiB ($(stat -c %s "$T/body") bytes), 200, all $n rows in order" || bad "huge JSON: $c $n $(stat -c %s "$T/body")" 855 c=$(code GET /open/); n=$(htmlshelfck "$T/data/open/list.tsv" "$T/body" 2>&1); rc=$? 856 [ "$c" = 200 ] && [ "$rc" = 0 ] && grep -qi 'Transfer-Encoding: chunked' "$T/hdr" && ok "streamed /open/ exceeds 8 MiB after escaping ($(stat -c %s "$T/body") bytes), 200, all $n cards in order" || bad "huge HTML: $c $n" 857 c=$(code GET '/open/?format=text'); [ "$c" = 200 ] && grep -q 'z2Huge' "$T/body" && ok 'streamed shelf still supports format=text' || bad "streamed plain text: $c" 858 stop 859 if build "$T/forged-fobmut" 's/^if ge get fobl 0 `1048576`$/if false/'; then 860 start "$T/forged-fobmut"; c=$(code GET /open.json) 861 shelfck "$T/data/open/list.tsv" "$T/body" >/dev/null 2>&1 && bad 'mutant fob-again JSON kept every row' || ok 'MUTANT building shelf in fob again fails the >8 MiB complete JSON check' 862 c=$(code GET /open/); htmlshelfck "$T/data/open/list.tsv" "$T/body" >/dev/null 2>&1 && bad 'mutant fob-again HTML kept every row' || ok 'MUTANT building shelf in fob again fails the >8 MiB complete HTML check' 863 stop 864 else bad 'mutant fob-again did not build'; fi 865 cp "$T/list.small" "$T/data/open/list.tsv" 866 # mutant of the shelf: no HTML escaping in the row output 867 if build "$T/forged-m" '/^fn ohesc /,/^fn ohjs /s/^fescc c$/fputc c/'; then 868 start "$T/forged-m"; code GET /open/ >/dev/null 869 grep -q '' "$T/body" && ok "MUTANT without the escape emits the script tag (the check above sees it)" || bad "mutant noescape: no script tag" 870 stop 871 else bad "mutant noescape did not build"; fi 872 873 if build "$T/forged-m2" '/^fn ohpesc /,/^fn ohpjs /s/^fescc c$/fputc c/'; then 874 start "$T/forged-m2"; code GET "/open/$R1" >/dev/null 875 grep -q '' "$T/body" && ok "MUTANT without the snapshot escape emits the tag on the project page" || bad "mutant nopesc: no tag" 876 stop 877 else bad "mutant nopesc did not build"; fi 878 if build "$T/forged-m3" '/^fn ohprow /,/^fn ohpload /s/^if ohpub s e$/if ohrow s e/'; then 879 start "$T/forged-m3"; c=$(code GET "/open/$(rid H4)") 880 [ "$c" = 200 ] && ok "MUTANT without the shelf check gives a refused project a page" || bad "mutant nopub: $c" 881 stop 882 else bad "mutant nopub did not build"; fi 883 884 if build "$T/forged-m4" '/^fn ohmatch /,/^fn ohtjs /s/^if ohorig$/if slhex id/'; then 885 start "$T/forged-m4"; code GET "/open/$R1" >/dev/null 886 grep -q "$SID2" "$T/body" && ok "MUTANT without the origin check lists another project's source" || bad "mutant noorig: other source not listed" 887 stop 888 else bad "mutant noorig did not build"; fi 889 if build "$T/forged-m5" '/^fn ohmatch /,/^fn ohtjs /s/^if not slpublic id$/if not slload id/'; then 890 start "$T/forged-m5"; code GET "/open/$R1" >/dev/null 891 grep -q "$DRAFT\">Draft part, never verified (Omega part, verified)" "$T/body" && ok "MUTANT without the public check calls an unverified draft a verified part" || bad "mutant nopublic: draft not listed" 892 stop 893 else bad "mutant nopublic did not build"; fi 894 895 if build "$T/forged-m6" '/^fn ohwj /,/^fn ohpage /s/^if ne get gojs 0 0$/if ne get gojs 0 1/'; then 896 start "$T/forged-m6"; code GET /open.json >/dev/null 897 head -c 15 "$T/body" | grep -q '' && ok "MUTANT that ignores the .json name answers HTML at /open.json" || bad "mutant nojsonname: not HTML" 898 stop 899 else bad "mutant nojsonname did not build"; fi 900 901 echo "RESULT pass=$PASS fail=$FAIL" 902 [ "$FAIL" = 0 ]