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/research/tests/publication.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 / research / tests / publication.sh` 231 lines ยท 11373 bytes Raw Blame History 1 #!/bin/sh 2 # Private real forged + publisher + agent-cload fixture. No production pause hook or live data. 3 set -eu 4 cd "$(dirname "$0")/../.." 5 ROOT=$PWD 6 OMC=$HOME/work/flux/omega-mv/seed/out/omc 7 T=$(mktemp -d /tmp/research-publication.XXXXXX) 8 PORT=${RESEARCH_PUBLICATION_PORT:-19467} 9 PID=; PUB=; HTTP=; AGENT= 10 cleanup(){ for p in "$PID" "$PUB" "$HTTP" "$AGENT"; do [ -z "$p" ] || kill "$p" 2>/dev/null || :; done; rm -rf "$T"; } 11 trap cleanup EXIT HUP INT TERM 12 pass=0; fail=0 13 ok(){ pass=$((pass+1)); echo "PASS publication $*"; } 14 bad(){ fail=$((fail+1)); echo "FAIL publication $*"; } 15 check(){ if "$@"; then ok "$*"; else bad "$*"; fi; } 16 mkdir -p "$T/reg/show" "$T/reg/text" "$T/data/research/ask" "$T/data/research/add" "$T/social" "$T/slwork" 17 cp research/registry/catalog.tsv "$T/reg/catalog.tsv" 18 cp research/registry/text/*.txt "$T/reg/text/" 19 printf 'answer stays\n' > "$T/data/research/ask/keep.html" 20 printf 'queue stays\n' > "$T/data/research/add/queue" 21 O=$T/data/research 22 C=$T/corpus 23 fixture(){ 24 printf 'Body for ATOMIC-%s.\n' "$1" > "$T/text" 25 digest=$(sha256sum "$T/text" | cut -d' ' -f1) 26 cp "$T/text" "$T/reg/text/fixture.$digest.txt" 27 { printf 'O\tid\tfixture-author\nO\tname\tFixture Author\nO\tadded-by\tdid:key:zFixture\nO\tvia\tzenodo\nO\tchecked\t2026-11-11\n' 28 printf 'W\tfixture\t\t2026-11-11\tpreprint\tZenodo\t\t\t1\t1\t0\tcc-by-4.0\tATOMIC-%s\n' "$1" 29 printf 'C\tfixture\tFixture Author\nP\tfixture\tzenodo\tdid:key:zFixture\t2026-11-11\thttps://zenodo.org/records/1\t1\nT\tfixture\t%s\n' "$digest" 30 } > "$T/reg/show/fixture.tsv" 31 } 32 publish(){ sh research/publish.sh "$O" "$C" "$T/reg" >> "$T/publish.log" 2>&1; } 33 fixture OLD 34 publish 35 old=$(readlink "$O/current") 36 cp "$O/current/index.json" "$T/old.json" 37 cp "$C" "$T/old.corpus" 38 check test "$(readlink "$O/w")" = current/w 39 check test "$(readlink -f "$C")" = "$(readlink -f "$O/current/corpus.txt")" 40 grep -Ev '^#| research\.(html|json|bib|txt|css)$' research/tests/fixtures/base-sha256.txt > "$T/legacy.sha" 41 if (cd "$O/w" && sha256sum -c "$T/legacy.sha") > "$T/legacy.log"; then ok '48 frozen work documents byte exact'; else bad 'legacy byte drift'; fi 42 # Test-only source seams, named and asserted once. Production source contains neither FIFO nor env hook. 43 mkfifo "$T/publish-go" "$T/http-ready" "$T/http-go" "$T/agent-ready" "$T/agent-go" 44 { echo om2; cat $(./run.sh units); } > "$T/composed.om" 45 python3 - "$T" "$ROOT" "$PORT" <<'PY' 46 import sys 47 from pathlib import Path 48 p=Path(sys.argv[1]); root=sys.argv[2]; port=sys.argv[3] 49 s=Path('research/publish.sh').read_text() 50 s=s.replace('cd "$(dirname "$0")/.."', 'cd "'+root+'"') 51 needle='# ATOMIC_PUBLIC_COMMIT:' 52 assert s.count(needle)==1 53 s=s.replace(needle, 'printf ready > "'+str(p)+'/publish-ready"\nread -r go < "'+str(p)+'/publish-go"\n'+needle) 54 (p/'paused-publish.sh').write_text(s) 55 s=(p/'composed.om').read_text().replace('text tfdata "/home/drakestapleton/forge-data/"', 'text tfdata "'+str(p)+'/data/"').replace('18480',port) 56 # Only /research.json is paused, after rxhas and before fsend3 opens the returned path. 57 needle='if not rxhas\nret 404\nend\nput fobl 0 0' 58 assert s.count(needle)==1 59 pause='''if fpeq txpj 60 x = pgpause 61 end 62 ''' 63 s=s.replace(needle, 'if not rxhas\nret 404\nend\n'+pause+'put fobl 0 0') 64 def seam(prefix): 65 return '''text pgready "'''+str(p)+'/'+prefix+'''-ready" 66 text pggo "'''+str(p)+'/'+prefix+'''-go" 67 text pgbyte "x" 68 fn pgpause to long 69 b = new uchar 1 0 70 fd = fopen pgready 0 len pgready 1 0 71 if lt fd 0 72 ret fd 73 end 74 r = write int fd pgbyte 0 1 75 r = fclose int fd 76 fd = fopen pggo 0 len pggo 0 0 77 if lt fd 0 78 ret fd 79 end 80 r = read int fd b 0 1 81 r = fclose int fd 82 ret r 83 end 84 ''' 85 s+='\n'+seam('http') 86 (p/'server.om').write_text(s) 87 needle='for i ulong ulong k bound 4096\nffilc get v i\nend\nffilc 47' 88 assert s.count(needle)==1 89 (p/'mutant.om').write_text(s.replace(needle,'for i ulong len txcur bound 16\nffilc get txcur i\nend\nffilc 47')) 90 s=Path('research/agent.om').read_text().replace('fn main to int','fn pgoldmain to int') 91 needle='fd = fopen cpa 0 get cpl 0 524288 0\nif lt fd 0\nret false\nend\n' 92 assert s.count(needle)==1 93 s=s.replace(needle,needle+'pgr = pgpause\n') 94 s+='\n'+seam('agent')+'''fn main to int 95 put cpl 0 argp 2 96 r = cload 97 w = write 1 gc 0 get gcl 0 98 ret 0 99 end 100 ''' 101 (p/'agent-read.om').write_text(s) 102 PY 103 "$OMC" < "$T/server.om" > "$T/server"; chmod 700 "$T/server" 104 "$OMC" < "$T/mutant.om" > "$T/mutant"; chmod 700 "$T/mutant" 105 "$OMC" < "$T/agent-read.om" > "$T/agent-read"; chmod 700 "$T/agent-read" 106 FORGE_SOCIAL_DIR="$T/social/" INTERPLANE_SALVAGE_DIR="$T/slwork/" "$T/server" > "$T/server.log" 2>&1 & PID=$! 107 for i in $(seq 1 60); do curl -s -o /dev/null "http://127.0.0.1:$PORT/" && break; sleep .1; done 108 get(){ curl --fail -s "http://127.0.0.1:$PORT$1"; } 109 get /research/fixture.json > "$T/served.json" 110 check grep -q ATOMIC-OLD "$T/served.json" 111 # Exercise the real forged research route and fsend3, not just its generated files. Curl writes 112 # response bodies directly to disk: no shell/text normalization can hide a transport byte change. 113 legacy_count=0 114 mkdir "$T/legacy-http" 115 while read -r expected leaf; do 116 case "$leaf" in 117 *.html) url=/research/${leaf%.html} ;; 118 *.json|*.bib) url=/research/$leaf ;; 119 *) bad "unexpected legacy oracle leaf $leaf"; continue ;; 120 esac 121 legacy_count=$((legacy_count+1)) 122 if curl --fail -s --proxy '' --noproxy '*' --max-time 10 "http://127.0.0.1:$PORT$url" -o "$T/legacy-http/$leaf"; then 123 actual=$(sha256sum "$T/legacy-http/$leaf" | cut -d ' ' -f1) 124 if [ "$actual" = "$expected" ]; then ok "legacy HTTP bytes $url"; else bad "legacy HTTP byte drift $url expected=$expected actual=$actual"; fi 125 else 126 bad "legacy HTTP fetch $url" 127 fi 128 done < "$T/legacy.sha" 129 check test "$legacy_count" = 48 130 for pair in '/research current/index.html' '/research.bib current/works.bib' '/research.txt current/agents.txt' '/assets/research.css current/research.css' '/research/authors/fixture-author current/a/fixture-author.html' '/research/add current/add.html' '/research/doi current/doi.html' '/research/fixture current/w/fixture.html' '/research/fixture.bib current/w/fixture.bib'; do 131 set -- $pair 132 get "$1" > "$T/route-body" 133 check cmp -s "$T/route-body" "$O/$2" 134 done 135 # Pin an HTTP path, and have the actual agent cload open the same old corpus inode. 136 get /research.json > "$T/delayed.json" & HTTP=$! 137 dd if="$T/http-ready" of=/dev/null bs=1 count=1 2>/dev/null 138 "$T/agent-read" unused "$C" > "$T/delayed.corpus" & AGENT=$! 139 dd if="$T/agent-ready" of=/dev/null bs=1 count=1 2>/dev/null 140 fixture NEW 141 sh "$T/paused-publish.sh" "$O" "$C" "$T/reg" >> "$T/publish.log" 2>&1 & PUB=$! 142 for i in $(seq 1 100); do [ ! -f "$T/publish-ready" ] || break; kill -0 "$PUB"; sleep .1; done 143 check test -f "$T/publish-ready" 144 check test "$(readlink "$O/current")" = "$old" 145 check cmp -s "$T/old.corpus" "$C" 146 check cmp -s "$T/old.json" "$O/current/index.json" 147 printf 'go\n' > "$T/publish-go" 148 wait "$PUB"; PUB= 149 new=$(readlink "$O/current") 150 check test "$new" != "$old" 151 check test -f "$O/$old/index.json" 152 printf x > "$T/http-go"; printf x > "$T/agent-go" 153 wait "$HTTP"; HTTP=; wait "$AGENT"; AGENT= 154 check cmp -s "$T/old.json" "$T/delayed.json" 155 check cmp -s "$T/old.corpus" "$T/delayed.corpus" 156 get /research/fixture.json > "$T/new.json" 157 check grep -q ATOMIC-NEW "$T/new.json" 158 check grep -q ATOMIC-NEW "$C" 159 # A new HTTP selection sees new bytes too, then delayed fsend3 consumes its pinned path. 160 get /research.json > "$T/current.json" & HTTP=$! 161 dd if="$T/http-ready" of=/dev/null bs=1 count=1 2>/dev/null 162 printf x > "$T/http-go"; wait "$HTTP"; HTTP= 163 check cmp -s "$O/current/index.json" "$T/current.json" 164 fixture INTERRUPTED 165 rm "$T/publish-ready" 166 sh "$T/paused-publish.sh" "$O" "$C" "$T/reg" >> "$T/publish.log" 2>&1 & PUB=$! 167 for i in $(seq 1 100); do [ ! -f "$T/publish-ready" ] || break; kill -0 "$PUB"; sleep .1; done 168 check test -f "$T/publish-ready" 169 kill -KILL "$PUB"; wait "$PUB" 2>/dev/null || :; PUB= 170 check test "$(readlink "$O/current")" = "$new" 171 get /research/fixture.json > "$T/after-kill.json" 172 check cmp -s "$T/new.json" "$T/after-kill.json" 173 check grep -q ATOMIC-NEW "$C" 174 check test "$(cat "$O/ask/keep.html")" = 'answer stays' 175 check test "$(cat "$O/add/queue")" = 'queue stays' 176 # Restart completes a full generation without deleting any path a prior request pinned. 177 publish 178 check test -f "$O/$old/index.json" 179 check test -f "$O/$new/index.json" 180 check grep -q ATOMIC-INTERRUPTED "$C" 181 # Actual HTTP negative control: replace only the pinned path with current/. 182 kill "$PID"; wait "$PID" 2>/dev/null || :; PID= 183 FORGE_SOCIAL_DIR="$T/social/" INTERPLANE_SALVAGE_DIR="$T/slwork/" "$T/mutant" > "$T/mutant.log" 2>&1 & PID=$! 184 for i in $(seq 1 60); do curl -s -o /dev/null "http://127.0.0.1:$PORT/" && break; sleep .1; done 185 cp "$O/current/index.json" "$T/mutant-before.json" 186 get /research.json > "$T/mutant-delayed.json" & HTTP=$! 187 dd if="$T/http-ready" of=/dev/null bs=1 count=1 2>/dev/null 188 fixture MUTANT 189 publish 190 printf x > "$T/http-go"; wait "$HTTP"; HTTP= 191 if cmp -s "$T/mutant-before.json" "$T/mutant-delayed.json"; then bad 'A5 HTTP unpinned mutant escaped'; 192 elif cmp -s "$O/current/index.json" "$T/mutant-delayed.json"; then ok 'A5 HTTP unpinned mutant caught: late open crossed generation'; 193 else bad 'A5 HTTP mutant failed for unrelated reason'; fi 194 # Text identity is selected with metadata. Neither a missing T nor '-' may reuse slug-only text. 195 printf 'STALE-SLUG-ONLY\n' > "$T/reg/text/fixture.txt" 196 sed '/^T[[:space:]]/d' "$T/reg/show/fixture.tsv" > "$T/no-t" 197 cp "$T/no-t" "$T/reg/show/fixture.tsv" 198 publish 199 if grep -q '^@@.*fixture' "$C"; then bad 'missing T reused stale text'; else ok 'missing T omits foreign text'; fi 200 printf 'T\tfixture\t-\n' >> "$T/reg/show/fixture.tsv" 201 publish 202 if grep -q '^@@.*fixture' "$C"; then bad 'T sentinel reused stale text'; else ok 'T sentinel omits foreign text'; fi 203 # A cache whose content no longer matches its identity cannot activate a generation. 204 fixture DIGEST 205 printf 'tampered cache\n' > "$T/reg/text/fixture.$digest.txt" 206 accepted=$(readlink "$O/current") 207 rc=0; publish || rc=$? 208 check test "$rc" = 1 209 check test "$(readlink "$O/current")" = "$accepted" 210 check grep -q 'text cache digest mismatch' "$T/publish.log" 211 fixture VALID 212 # Hostile BibTeX encoded commands are neutralized; the 48-file oracle above excludes drift. 213 "$OMC" < research/build.om > "$T/build"; chmod 700 "$T/build" 214 { printf 'M\twbib\tescape\nW\tescape\t\t2026-01-01\tpreprint\tZenodo\t\t\t1\t1\t0\tcc\t^^5cinput{evil}~^^5cwrite18{evil}\n'; } | "$T/build" > "$T/escape.bib" 215 if grep -Eq '\^|~|\\input|\\write18' "$T/escape.bib"; then bad 'encoded TeX command survives'; else ok 'caret pair and active tilde neutralized'; fi 216 # T identity: duplicate or malformed identities cannot emit even a prefix of a document. 217 for kind in duplicate short upper extra; do 218 sed '/^T[[:space:]]/d' "$T/reg/show/fixture.tsv" > "$T/t-catalog" 219 case $kind in 220 duplicate) printf 'T\tfixture\t%s\nT\tfixture\t%s\n' "$digest" "$digest" >> "$T/t-catalog" ;; 221 short) printf 'T\tfixture\tabc\n' >> "$T/t-catalog" ;; 222 upper) printf 'T\tfixture\t%s\n' "$(printf '%s' "$digest" | tr a-f A-F)" >> "$T/t-catalog" ;; 223 extra) printf 'T\tfixture\t%s\textra\n' "$digest" >> "$T/t-catalog" ;; 224 esac 225 { printf 'M\tmerge\n'; cat "$T/t-catalog"; } > "$T/bad-t" 226 rc=0; "$T/build" < "$T/bad-t" > "$T/bad-t.out" || rc=$? 227 check test "$rc" = 4 228 check test ! -s "$T/bad-t.out" 229 done 230 echo "PUBLICATION_RESULT pass=$pass fail=$fail" 231 [ "$fail" = 0 ]