interplane-forge
INTERPLANE Forge
Brought by drakestapleton
interplane-forge / research / tests / binding-control.sh
| 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. |
| 4 | set -eu |
| 5 | cd "$(dirname "$0")/../.." |
| 6 | HERE=$(pwd); T=$(mktemp -d) |
| 7 | trap 'rm -rf "$T"' EXIT HUP INT TERM |
| 8 | sh research/build-tools.sh "$T/bin" |
| 9 | F=$T/bin/research-jflat; S=$T/bin/research-sync |
| 10 | O=0009-0002-6890-7111 |
| 11 | D=did:key:z6MkAbcdefghijkmnopqrstuvw111111111111111111111 |
| 12 | python3 - "$T" "$O" <<'PY' |
| 13 | import json,pathlib,sys |
| 14 | p=pathlib.Path(sys.argv[1]);o=sys.argv[2] |
| 15 | r={'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'}}]} |
| 16 | json.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')) |
| 17 | PY |
| 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 |
| 20 | slug=$(cut -f1 "$T/plan"); mkdir "$T/fixture" |
| 21 | printf 'OLD_PUBLIC_PARAGRAPH from an earlier file.\n\n' > "$T/fixture/$slug" |
| 22 | mkdir -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" |
| 24 | run_direct(){ RESEARCH_TOOLS=$T/bin sh "$1" --zenodo "$O" "$D" 2026-11-11 other "$T/reg/a/other/zenodo.tsv" "$2" "$T/fixture"; } |
| 25 | publish(){ "$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; } |
| 26 | run_direct research/sync.sh "$T/old.json" > "$T/seed.log" 2>&1 |
| 27 | publish |
| 28 | grep -q OLD_PUBLIC_PARAGRAPH "$T/corpus" || { echo 'FAIL binding positive cache seed'; exit 1; } |
| 29 | run_direct research/sync.sh "$T/fresh.json" > "$T/fresh.log" 2>&1 |
| 30 | publish |
| 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. |
| 33 | run_direct research/sync.sh "$T/old.json" > "$T/reseed.log" 2>&1 |
| 34 | python3 - research/sync.sh "$T/reuse-old.sh" "$HERE" <<'PY' |
| 35 | import sys |
| 36 | s=open(sys.argv[1]).read();s=s.replace('HERE=$(CDPATH= cd -- "$(dirname "$0")/.." && pwd)','HERE='+sys.argv[3]) |
| 37 | needle='bindtext() {\n';assert s.count(needle)==1 |
| 38 | fault='''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 | ''' |
| 50 | s=s.replace(needle,fault,1);open(sys.argv[2],'w').write(s) |
| 51 | PY |
| 52 | run_direct "$T/reuse-old.sh" "$T/fresh.json" > "$T/mutant.log" 2>&1 |
| 53 | publish |
| 54 | grep -q OLD_PUBLIC_PARAGRAPH "$T/corpus" && grep -q 'Fresh metadata' "$T/site/w/"*.html || { echo 'FAIL binding mutant wrong reason'; exit 1; } |
| 55 | echo 'BINDING_RESULT pass=3 fail=0 mutant=STALE_TEXT_REUSED' |