interplane.Get Omega
Read in your language

interplane-forge

INTERPLANE Forge

Brought by drakestapleton

branch main Branches Tags History

interplane-forge / research / tests / binding-control.sh

55 lines · 3236 bytes Raw Blame History
1#!/bin/sh
2# Fault in the shared binder models reusing a prior cache when this refresh produced no text.
3# The actual publisher observes stale content, distinguishing it from a compile/transport failure.
4set -eu
5cd "$(dirname "$0")/../.."
6HERE=$(pwd); T=$(mktemp -d)
7trap 'rm -rf "$T"' EXIT HUP INT TERM
8sh research/build-tools.sh "$T/bin"
9F=$T/bin/research-jflat; S=$T/bin/research-sync
10O=0009-0002-6890-7111
11D=did:key:z6MkAbcdefghijkmnopqrstuvw111111111111111111111
12python3 - "$T" "$O" <<'PY'
13import json,pathlib,sys
14p=pathlib.Path(sys.argv[1]);o=sys.argv[2]
15r={'id':991,'doi':'10.5281/zenodo.991','metadata':{'title':'Bound text','description':'Old metadata','license':{'id':'cc-by-4.0'},'creators':[{'name':'Other','orcid':o}]},'files':[{'key':'paper.txt','size':9,'links':{'self':'https://zenodo.org/paper'}}]}
16json.dump({'hits':{'hits':[r]}},open(p/'old.json','w'));r['metadata']['description']='Fresh metadata';r['files']=[];json.dump({'hits':{'hits':[r]}},open(p/'fresh.json','w'))
17PY
18"$F" < "$T/old.json" > "$T/flat"
19"$S" zenodo "$O" "$D" 2026-11-11 other < "$T/flat" > "$T/raw" 3> "$T/plan" 2>/dev/null
20slug=$(cut -f1 "$T/plan"); mkdir "$T/fixture"
21printf 'OLD_PUBLIC_PARAGRAPH from an earlier file.\n\n' > "$T/fixture/$slug"
22mkdir -p "$T/reg/show"; cp research/registry/catalog.tsv "$T/reg/catalog.tsv"; mkdir "$T/reg/text"; cp research/registry/text/*.txt "$T/reg/text/"
23: > "$T/remove"; : > "$T/list"
24run_direct(){ RESEARCH_TOOLS=$T/bin sh "$1" --zenodo "$O" "$D" 2026-11-11 other "$T/reg/a/other/zenodo.tsv" "$2" "$T/fixture"; }
25publish(){ "$S" gather "$T/remove" "$T/list" < "$T/reg/a/other/zenodo.tsv" > "$T/reg/show/other.tsv"; sh research/publish.sh "$T/site" "$T/corpus" "$T/reg" > "$T/pub.log" 2>&1; }
26run_direct research/sync.sh "$T/old.json" > "$T/seed.log" 2>&1
27publish
28grep -q OLD_PUBLIC_PARAGRAPH "$T/corpus" || { echo 'FAIL binding positive cache seed'; exit 1; }
29run_direct research/sync.sh "$T/fresh.json" > "$T/fresh.log" 2>&1
30publish
31! grep -q OLD_PUBLIC_PARAGRAPH "$T/corpus" && grep -q 'Fresh metadata' "$T/site/w/"*.html || { echo 'FAIL binding stale cache after no attachment'; exit 1; }
32# Reseed the same old cache; mutate only the binder's fresh-text input choice, not the oracle.
33run_direct research/sync.sh "$T/old.json" > "$T/reseed.log" 2>&1
34python3 - research/sync.sh "$T/reuse-old.sh" "$HERE" <<'PY'
35import sys
36s=open(sys.argv[1]).read();s=s.replace('HERE=$(CDPATH= cd -- "$(dirname "$0")/.." && pwd)','HERE='+sys.argv[3])
37needle='bindtext() {\n';assert s.count(needle)==1
38fault='''bindtext() {
39 grep '^W[[:space:]]' "$1" | cut -f2 > "$W/mutant-ids"
40 while IFS= read -r oldslug; do
41 if [ ! -s "$3/$oldslug.txt" ]; then
42 for prior in "$4/$oldslug".*.txt; do
43 [ -s "$prior" ] || continue
44 cp "$prior" "$3/$oldslug.txt"
45 break
46 done
47 fi
48 done < "$W/mutant-ids"
49'''
50s=s.replace(needle,fault,1);open(sys.argv[2],'w').write(s)
51PY
52run_direct "$T/reuse-old.sh" "$T/fresh.json" > "$T/mutant.log" 2>&1
53publish
54grep -q OLD_PUBLIC_PARAGRAPH "$T/corpus" && grep -q 'Fresh metadata' "$T/site/w/"*.html || { echo 'FAIL binding mutant wrong reason'; exit 1; }
55echo 'BINDING_RESULT pass=3 fail=0 mutant=STALE_TEXT_REUSED'