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/bundles.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 / bundles.sh` 269 lines ยท 21199 bytes Raw Blame History 1 #!/bin/sh 2 # Offline complete-bundle and duplicate-licence regressions; no network or live state. 3 set -eu 4 cd "$(dirname "$0")/../.." 5 T=$(mktemp -d) 6 trap 'rm -rf "$T"' EXIT HUP INT TERM 7 pass=0; fail=0 8 ok(){ pass=$((pass+1)); echo "PASS bundles $*"; } 9 bad(){ fail=$((fail+1)); echo "FAIL bundles $*"; } 10 sh research/build-tools.sh "$T/bin" 11 S=$T/bin/research-sync; F=$T/bin/research-jflat 12 OMV=${OMV:-$HOME/work/flux/omega-mv}; OMC=${OMC:-$OMV/seed/out/omc} 13 D1=did:key:`z6MkAbcdefghijkmnopqrstuvw111111111111111111111` 14 D2=did:key:`z6MkAbcdefghijkmnopqrstuvw222222222222222222222` 15 O=0009-0002-6890-7111 16 mkdir "$T/text" 17 printf 'Original imported paragraphs.\n' > "$T/text/same-work.txt" 18 A=$(sha256sum "$T/text/same-work.txt" | cut -d' ' -f1) 19 cp "$T/text/same-work.txt" "$T/original-text" 20 cat > "$T/raw1" < "$T/d1" 3> "$T/plan1" 33 printf 'New ORCID import paragraphs.\n' > "$T/text/same-work.txt" 34 B=$(sha256sum "$T/text/same-work.txt" | cut -d' ' -f1) 35 sed -e "s/$D1/$D2/g" -e 's/Original DOI title/New ORCID title/' -e 's/Original abstract/New abstract/' -e 's/Original profile/New profile/' -e 's/2026-11-10/2026-11-11/g' "$T/raw1" > "$T/raw2" 36 "$S" bind 2 "$T/text/" < "$T/raw2" > "$T/d2" 3> "$T/plan2" 37 [ "$(cat "$T/plan1")" = "$(printf 'same-work\t%s' "$A")" ] && [ "$(cat "$T/plan2")" = "$(printf 'same-work\t%s' "$B")" ] && ok 'bind hashes fresh bytes and plans immutable cache identities' || bad 'bind identity' 38 : > "$T/remove"; : > "$T/list" 39 chosen(){ 40 expected=$1; sha=$2; did=$3 41 [ "$(grep -c '^W' "$T/shown" || :)" = 1 ] && 42 grep -q "$expected" "$T/shown" && 43 [ "$(grep '^T' "$T/shown" | cut -f3)" = "$sha" ] && 44 [ "$(grep '^P' "$T/shown" | cut -f4)" = "$did" ] && 45 [ "$(grep '^O.added-by' "$T/shown" | cut -f3)" = "$did" ] 46 } 47 for order in 12 21; do 48 case $order in 12) cat "$T/d1" "$T/d2" > "$T/both";; 21) cat "$T/d2" "$T/d1" > "$T/both";; esac 49 : > "$T/remove" 50 "$S" gather "$T/remove" "$T/list" < "$T/both" > "$T/shown" 51 chosen 'New ORCID title' "$B" "$D2" && grep -q 'New profile' "$T/shown" && ! grep -q "$D1" "$T/shown" && ok "newest complete bundle survives order=$order" || bad "newest order=$order" 52 printf '%s\n' "$D1" > "$T/remove" 53 "$S" gather "$T/remove" "$T/list" < "$T/both" > "$T/shown" 54 chosen 'New ORCID title' "$B" "$D2" && ok "removed first requester cannot poison survivor order=$order" || bad "first-P poison order=$order" 55 printf '%s\n' "$D2" > "$T/remove" 56 "$S" gather "$T/remove" "$T/list" < "$T/both" > "$T/shown" 57 chosen 'Original DOI title' "$A" "$D1" && ! grep -q "$B" "$T/shown" && ok "fallback keeps older text and metadata order=$order" || bad "fallback order=$order" 58 done 59 printf '10.5281/zenodo.101\n' > "$T/remove" 60 "$S" gather "$T/remove" "$T/list" < "$T/both" > "$T/shown" 61 [ ! -s "$T/shown" ] && ok 'explicit DOI takedown hides every copy' || bad 'DOI takedown' 62 printf 'same-work\n' > "$T/remove" 63 "$S" gather "$T/remove" "$T/list" < "$T/both" > "$T/shown" 64 [ ! -s "$T/shown" ] && ok 'explicit work takedown hides every copy' || bad 'work takedown' 65 printf '%s\n' "$O" > "$T/remove" 66 "$S" gather "$T/remove" "$T/list" < "$T/both" > "$T/shown" 67 [ ! -s "$T/shown" ] && ok 'ORCID takedown hides all associated bundles' || bad 'ORCID takedown' 68 sed '/^P/s/\t1$/\t0/' "$T/d1" > "$T/closed" 69 cat "$T/closed" "$T/d2" > "$T/conflict" 70 printf '%s\n' "$D1" > "$T/remove" 71 "$S" gather "$T/remove" "$T/list" < "$T/conflict" > "$T/shown" 72 [ "$(grep '^P' "$T/shown" | cut -f7)" = 1 ] && ok 'removed closed copy cannot close eligible open copy' || bad 'removed licence poison' 73 : > "$T/remove" 74 "$S" gather "$T/remove" "$T/list" < "$T/conflict" > "$T/shown" 75 [ "$(grep '^P' "$T/shown" | cut -f7)" = 0 ] && chosen 'New ORCID title' "$B" "$D2" && ok 'eligible closed copy closes text without replacing selected metadata' || bad 'eligible licence aggregation' 76 # The profile may follow several W bundles; old fixtures may instead carry a header profile. 77 { grep '^O' "$T/d1"; grep -v '^O' "$T/d1"; } > "$T/header" 78 "$S" gather "$T/remove" "$T/list" < "$T/header" > "$T/shown" 79 chosen 'Original DOI title' "$A" "$D1" && ok 'legacy header profile fallback' || bad 'header profile' 80 # B9: a selected catalog must remain associated with its own profile when raw data is appended. 81 : > "$T/remove" 82 "$S" gather "$T/remove" "$T/list" < "$T/d1" > "$T/selected-d1" 83 printf '%s\n' "$D2" > "$T/remove" 84 for order in selected-first raw-first; do 85 if [ "$order" = selected-first ]; then cat "$T/selected-d1" "$T/d2" > "$T/mixed-selection"; else cat "$T/d2" "$T/selected-d1" > "$T/mixed-selection"; fi 86 "$S" gather "$T/remove" "$T/list" < "$T/mixed-selection" > "$T/shown" 87 chosen 'Original DOI title' "$A" "$D1" && grep -q 'Original profile' "$T/shown" && ! grep -q 'New profile' "$T/shown" && ok "selected/raw profile binding $order" || bad "PROFILE_FROM_REJECTED_BUNDLE $order" 88 done 89 # Header-only compatibility is safe alone, but mixed old header/raw data must fail closed. 90 cat "$T/header" "$T/d2" > "$T/unsafe-mixed" 91 rc=0; "$S" gather "$T/remove" "$T/list" < "$T/unsafe-mixed" > "$T/shown" 2> "$T/mixed.err" || rc=$? 92 [ "$rc" = 1 ] && [ ! -s "$T/shown" ] && grep -q MIXED_PROFILE_LAYOUT "$T/mixed.err" && ok 'ambiguous legacy mixed layout is rejected, not cross-associated' || bad 'unsafe legacy mixed profile accepted' 93 # Upgrade a standalone legacy header RAW catalog, then run the exact withholding/fresh helper. 94 # An old selected shared O is not an authority for rebuilding its lost bundle associations. 95 mkdir -p "$T/fallback/prev" "$T/fallback/target/a/other" "$T/fallback/target/text" "$T/fallback/work" 96 "$S" layout raw < "$T/header" > "$T/header-upgraded" 97 "$S" gather "$T/remove" "$T/list" < "$T/header-upgraded" > "$T/fallback/prev/other.tsv" 98 cp "$T/d2" "$T/fallback/target/a/other/fresh.tsv" 99 cp research/registry/catalog.tsv "$T/fallback/target/catalog.tsv" 100 cp research/registry/text/*.txt "$T/fallback/target/text/" 101 cp "$T/original-text" "$T/fallback/target/text/same-work.$A.txt" 102 python3 - research/sync.sh "$T/fallback/helper.sh" <<'PYFALL' 103 import sys 104 s=open(sys.argv[1]).read();a=s.index('gather_one() {');b=s.index('validate() {',a) 105 with open(sys.argv[2],'w') as f: 106 f.write('set -eu\nSYNC=$1; remove=$2; shelf=$3; W=$4\n'+s[a:b]+'\ngather "$5" "$6" "$7"\n') 107 PYFALL 108 sh "$T/fallback/helper.sh" "$S" "$T/remove" "$T/list" "$T/fallback/work" "$T/fallback/target" "$T/fallback/prev" "$T/fallback/target/a/other/fresh.tsv" 109 cp "$T/fallback/target/show/other.tsv" "$T/shown" 110 chosen 'Original DOI title' "$A" "$D1" && grep -q 'Original profile' "$T/shown" && ! grep -q 'New profile' "$T/shown" && ok 'actual withholding/fresh helper preserves upgraded legacy raw association' || bad 'fallback helper profile association' 111 rc=0; sh research/publish.sh "$T/fallback/site" "$T/fallback/corpus" "$T/fallback/target" > "$T/fallback/publish.log" 2>&1 || rc=$? 112 if [ "$rc" != 0 ]; then cat "$T/fallback/publish.log"; bad "fallback publication refused"; fi 113 if grep -q 'Original profile' "$T/fallback/site/a/other.html" && ! grep -q 'New profile' "$T/fallback/site/a/other.html" && grep -q 'Original imported' "$T/fallback/corpus"; then ok 'fallback profile, metadata and immutable text remain together through publication'; else bad 'published fallback profile mismatch'; fi 114 : > "$T/remove" 115 sed '/^R/s/\t1$/\t10/' "$T/d1" > "$T/ten" 116 cat "$T/ten" "$T/d2" > "$T/numeric" 117 "$S" gather "$T/remove" "$T/list" < "$T/numeric" > "$T/shown" 118 chosen 'Original DOI title' "$A" "$D1" && ok 'serial comparison is numeric, not lexical' || bad 'numeric source order' 119 for kind in missing-p duplicate-p duplicate-r duplicate-t malformed-r malformed-t; do 120 case $kind in 121 missing-p) grep -v '^P' "$T/d2" > "$T/broken";; 122 duplicate-p) sed '/^P/p' "$T/d2" > "$T/broken";; 123 duplicate-r) sed '/^R/p' "$T/d2" > "$T/broken";; 124 duplicate-t) sed '/^T/p' "$T/d2" > "$T/broken";; 125 malformed-r) sed '/^R/s/\t2$/\tbad/' "$T/d2" > "$T/broken";; 126 malformed-t) sed '/^T/s/\t[0-9a-f]*$/\tbad/' "$T/d2" > "$T/broken";; 127 esac 128 cat "$T/d1" "$T/broken" > "$T/incomplete" 129 "$S" gather "$T/remove" "$T/list" < "$T/incomplete" > "$T/shown" 130 chosen 'Original DOI title' "$A" "$D1" && ok "ineligible newer copy cannot poison fallback: $kind" || bad "incomplete bundle $kind" 131 done 132 grep -v '^R' "$T/d1" > "$T/no-r" 133 cat "$T/no-r" "$T/d2" > "$T/old-fixture" 134 "$S" gather "$T/remove" "$T/list" < "$T/old-fixture" > "$T/shown" 135 chosen 'New ORCID title' "$B" "$D2" && ok 'missing legacy serial is zero' || bad 'missing R' 136 # G is tied to the chosen import, including older repo serializers' post-profile G position. 137 { cat "$T/d1"; printf 'G\tsame-work\t1111111111111111111111111111111111111111\t%s\n' "$A"; } > "$T/g1" 138 { cat "$T/d2"; printf 'G\tsame-work\t2222222222222222222222222222222222222222\t%s\n' "$B"; } > "$T/g2" 139 cat "$T/g1" "$T/g2" > "$T/gcopies" 140 "$S" gather "$T/remove" "$T/list" < "$T/gcopies" > "$T/shown" 141 [ "$(grep '^G' "$T/shown" | cut -f3-4)" = "$(printf '`2222222222222222222222222222222222222222`\t%s' "$B")" ] && chosen 'New ORCID title' "$B" "$D2" && ok 'chosen source snapshot and cache binding stay together' || bad 'G provenance mixing' 142 # Each repository copy must still be on the shelf under its own requesting key. 143 R=z2abcdefghijkmnopqrstuvw111 144 sed "/^P/s|zenodo\t|radicle\t|; /^P/s|https://zenodo.org/records/101|rad:$R|" "$T/closed" > "$T/r1" 145 sed "/^P/s|zenodo\t|radicle\t|; /^P/s|https://zenodo.org/records/101|rad:$R|" "$T/d2" > "$T/r2" 146 cat "$T/r1" "$T/r2" > "$T/rcopies" 147 printf '%s\topen\t%s\t2026-11-11\n' "$R" "$D2" > "$T/list" 148 "$S" gather "$T/remove" "$T/list" < "$T/rcopies" > "$T/shown" 149 chosen 'New ORCID title' "$B" "$D2" && [ "$(grep '^P' "$T/shown" | cut -f7)" = 1 ] && ok 'withdrawn closed requester cannot suppress shelf survivor' || bad 'shelf eligibility mixing' 150 printf '%s\n' "$R" > "$T/remove" 151 "$S" gather "$T/remove" "$T/list" < "$T/rcopies" > "$T/shown" 152 [ ! -s "$T/shown" ] && ok 'explicit RID takedown hides all copies' || bad 'RID takedown' 153 : > "$T/remove"; : > "$T/list" 154 # Bind replaces retired descriptors, never consulting an old hashed cache. 155 "$S" bind 3 "$T/text/" < "$T/d1" > "$T/rebound" 3> "$T/replan" 156 [ "$(grep -c '^R' "$T/rebound")" = 1 ] && [ "$(grep -c '^T' "$T/rebound")" = 1 ] && [ "$(grep '^R' "$T/rebound" | cut -f3)" = 3 ] && [ "$(grep '^T' "$T/rebound" | cut -f3)" = "$B" ] && ok 'bind replaces retired R/T rather than duplicating them' || bad 'retired descriptors' 157 mv "$T/text/same-work.txt" "$T/text/same-work.$B.txt" 158 "$S" bind 4 "$T/text/" < "$T/raw2" > "$T/missing" 3> "$T/missing-plan" 159 [ "$(grep '^T' "$T/missing" | cut -f3)" = - ] && [ ! -s "$T/missing-plan" ] && ok 'missing fresh alias never picks old hashed cache' || bad 'stale cache reused' 160 for variant in empty symlink large directory; do 161 rm -rf "$T/text/same-work.txt" 162 case $variant in empty) : > "$T/text/same-work.txt";; symlink) ln -s "same-work.$B.txt" "$T/text/same-work.txt";; large) head -c 262145 /dev/zero > "$T/text/same-work.txt";; directory) mkdir "$T/text/same-work.txt";; esac 163 "$S" bind 5 "$T/text/" < "$T/raw2" > "$T/missing" 3> "$T/missing-plan" 164 [ "$(grep '^T' "$T/missing" | cut -f3)" = - ] && [ ! -s "$T/missing-plan" ] && ok "unusable text metadata-only: $variant" || bad "text admitted: $variant" 165 done 166 for seq in 0 01 +1 -1 1x `10000000000000000000`; do 167 if "$S" bind "$seq" "$T/text/" < "$T/raw1" > "$T/refused" 3> "$T/refplan"; then bad "bad sequence admitted: $seq"; else [ ! -s "$T/refused" ] && ok "sequence refused: $seq" || bad 'partial refused output'; fi 168 done 169 sed 's/same-work/..\/escape/g' "$T/raw1" > "$T/badslug" 170 if "$S" bind 6 "$T/text/" < "$T/badslug" > "$T/refused" 3> "$T/refplan"; then bad 'unsafe slug admitted'; else [ ! -s "$T/refused" ] && ok 'unsafe slug refused without output' || bad 'unsafe partial output'; fi 171 # Real flattened duplicate JSON fields, not guessed flattened inputs. 172 python3 - "$T" <<'PY' 173 import pathlib,sys 174 p=pathlib.Path(sys.argv[1]); base=pathlib.Path('research/tests/fixtures/paper.zenodo.json').read_text() 175 import json 176 obj=json.loads(base); obj.pop('license',None) 177 head=json.dumps(obj)[:-1] 178 cases=[('ids-open-first','"license":{"id":"cc-by-4.0","id":"all-rights-reserved"}'),('ids-closed-first','"license":{"id":"all-rights-reserved","id":"cc-by-4.0"}'),('objects-open-first','"license":{"id":"cc-by-4.0"},"license":{"id":"all-rights-reserved"}'),('objects-closed-first','"license":{"id":"all-rights-reserved"},"license":{"id":"cc-by-4.0"}'),('mixed','"license":"all-rights-reserved","license":{"id":"cc-by-4.0"}'),('same-open','"license":{"id":"cc-by-4.0","id":"cc-by-4.0"}'),('disjoint-open-first','"license":{"id":"cc-by-4.0"},"license":{"title":"all-rights-reserved"}'),('disjoint-closed-first','"license":{"title":"all-rights-reserved"},"license":{"id":"cc-by-4.0"}'),('empty-open-first','"license":{"id":"cc-by-4.0"},"license":{}'),('array-open-first','"license":{"id":"cc-by-4.0"},"license":["all-rights-reserved"]'),('array-closed-first','"license":["all-rights-reserved"],"license":{"id":"cc-by-4.0"}'),('array-only','"license":[{"id":"cc-by-4.0"}]')] 179 for name,lic in cases: (p/(name+'.json')).write_text(head+','+lic+'}') 180 PY 181 R=z2abcdefghijkmnopqrstuvw111 182 for kind in ids-open-first ids-closed-first objects-open-first objects-closed-first mixed same-open disjoint-open-first disjoint-closed-first empty-open-first array-open-first array-closed-first array-only; do 183 "$F" < "$T/$kind.json" > "$T/licflat" 184 printf '@tree\n100644 blob 123 12\tLICENSE\n100644 blob 456 42\tpaper.md\n' >> "$T/licflat" 185 "$S" repo "$R" "$D1" 2026-11-11 other < "$T/licflat" > "$T/liccat" 3> "$T/lictext" 2> "$T/liclog" 186 [ "$(grep '^P' "$T/liccat" | cut -f7)" = 0 ] && [ "$(grep '^W' "$T/liccat" | cut -f12)" = ambiguous ] && [ ! -s "$T/lictext" ] && ok "duplicate licence denies text: $kind" || bad "duplicate licence $kind" 187 done 188 # Full jflat -> Zenodo path also preserves duplicate object boundaries, not only duplicate leaves. 189 python3 - "$T" "$O" <<'PYJSON' 190 import pathlib,json,sys 191 p=pathlib.Path(sys.argv[1]);o=sys.argv[2] 192 for name in ['ids-open-first','ids-closed-first','objects-open-first','objects-closed-first','mixed','same-open','disjoint-open-first','disjoint-closed-first','empty-open-first','array-open-first','array-closed-first','array-only']: 193 raw=(p/(name+'.json')).read_text().replace('"name": "Other, Author"','"name": "Other, Author", "orcid": '+json.dumps(o)) 194 # Fixture name spacing is not part of the admission oracle; require injected creator identity. 195 assert '"orcid"' in raw 196 files=',"files":[{"key":"paper.txt","size":9,"links":{"self":"https://zenodo.org/file"}}]' 197 (p/(name+'.search')).write_text('{"hits":{"total":1,"hits":[{"id":101,"metadata":'+raw+files+'}]}}') 198 meta={'title':'Valid open','creators':[{'name':'Other','orcid':o}],'license':{'id':'cc-by-4.0'}} 199 r={'id':101,'metadata':meta,'files':[{'key':'paper.txt','size':9,'links':{'self':'https://zenodo.org/file'}}]} 200 (p/'unique.search').write_text(json.dumps({'hits':{'total':1,'hits':[r]}})) 201 (p/'parent-duplicate.search').write_text('{"hits":{"total":1,"hits":[{"id":101,"metadata":'+json.dumps(meta)+',"metadata":{"title":"different namespace"}'+files+'}]}}') 202 (p/'parent-array-open-first.search').write_text('{"hits":{"total":1,"hits":[{"id":101,"metadata":'+json.dumps(meta)+',"metadata":["all-rights-reserved"]'+files+'}]}}') 203 (p/'parent-array-closed-first.search').write_text('{"hits":{"total":1,"hits":[{"id":101,"metadata":["all-rights-reserved"],"metadata":'+json.dumps(meta)+files+'}]}}') 204 (p/'parent-array-only.search').write_text('{"hits":{"total":1,"hits":[{"id":101,"metadata":['+json.dumps(meta)+']'+files+'}]}}') 205 PYJSON 206 for kind in ids-open-first ids-closed-first objects-open-first objects-closed-first mixed same-open disjoint-open-first disjoint-closed-first empty-open-first array-open-first array-closed-first array-only parent-duplicate parent-array-open-first parent-array-closed-first parent-array-only; do 207 "$F" < "$T/$kind.search" > "$T/zduplicate.flat" 208 "$S" zenodo "$O" "$D1" 2026-11-11 other < "$T/zduplicate.flat" > "$T/liccat" 3> "$T/lictext" 2> "$T/liclog" 209 case $kind in 210 parent-*) [ ! -s "$T/liccat" ] && [ ! -s "$T/lictext" ] && grep -q 'metadata container' "$T/liclog" && ok "invalid/duplicate metadata parent refused: $kind" || bad "metadata shape $kind" ;; 211 *) [ "$(grep '^P' "$T/liccat" | cut -f7)" = 0 ] && [ ! -s "$T/lictext" ] && grep -q ambiguous "$T/liclog" && ok "actual JSON Zenodo ambiguity denies text: $kind" || bad "Zenodo object ambiguity $kind" ;; 212 esac 213 done 214 "$F" < "$T/unique.search" > "$T/zduplicate.flat" 215 "$S" zenodo "$O" "$D1" 2026-11-11 other < "$T/zduplicate.flat" > "$T/liccat" 3> "$T/lictext" 2> "$T/liclog" 216 [ "$(grep '^P' "$T/liccat" | cut -f7)" = 1 ] && [ -s "$T/lictext" ] && ok 'unique open JSON object is a positive text control' || bad 'unique object incorrectly denied' 217 # Zenodo uses the same all-matches rule independently of repository mode. 218 printf '/hits/hits/0/id\t101\n/hits/hits/0/metadata/title\tDuplicate licence\n/hits/hits/0/metadata/creators/0/name\tOther\n/hits/hits/0/metadata/creators/0/orcid\t%s\n/hits/hits/0/metadata/license/id\tcc-by-4.0\n/hits/hits/0/metadata/license/id\tclosed\n/hits/hits/0/files/0/key\tpaper.txt\n/hits/hits/0/files/0/size\t9\n/hits/hits/0/files/0/links/self\thttps://zenodo.org/file\n' "$O" > "$T/zlic" 219 "$S" zenodo "$O" "$D1" 2026-11-11 other < "$T/zlic" > "$T/liccat" 3> "$T/lictext" 2> "$T/liclog" 220 [ "$(grep '^P' "$T/liccat" | cut -f7)" = 0 ] && [ ! -s "$T/lictext" ] && ok 'Zenodo duplicate licence also denies text' || bad 'Zenodo duplicates' 221 # Targeted mutants: demonstrate each oracle fails for its own cause, not compile/setup failure. 222 mutant(){ { echo om2; cat "$OMV/om/tls/sha2.om" "$T/$1.om"; } | "$OMC" > "$T/$1"; chmod 700 "$T/$1"; } 223 sed 's/pl = gfact s 80/pl = gfact 0 80/' research/sync.om > "$T/first-p.om" 224 mutant first-p 225 cat "$T/d1" "$T/d2" > "$T/both" 226 : > "$T/remove" 227 "$T/first-p" gather "$T/remove" "$T/list" < "$T/both" > "$T/control" 228 printf '%s\n' "$D1" > "$T/remove" 229 "$T/first-p" gather "$T/remove" "$T/list" < "$T/both" > "$T/shown" 230 [ "$(grep -c '^W' "$T/control" || :)" = 1 ] && [ ! -s "$T/shown" ] && ok 'MUTANT first-P poison caught by removal of only D1' || bad 'first-P mutant not caught for own reason' 231 # Lose only per-bundle profile emission in selected output, leaving its shared O block. 232 # Two work slugs then expose the wrong profile after removal, not a parser/setup failure. 233 python3 - research/sync.om "$T/header-profile.om" <<'PYPROFILE' 234 import sys 235 s=open(sys.argv[1]).read();a=s.index('fn gemit ');b=s.index('fn gemprofile ',a);part=s[a:b] 236 if part.count('gattach s\n')!=1:raise SystemExit('profile mutant anchor missing') 237 s=s[:a]+part.replace('gattach s\n','')+s[b:] 238 open(sys.argv[2],'w').write(s) 239 PYPROFILE 240 mutant header-profile 241 : > "$T/remove" 242 sed 's/same-work/second-work/g' "$T/d2" > "$T/second-work" 243 cat "$T/d1" "$T/second-work" > "$T/old-mixed" 244 "$T/header-profile" gather "$T/remove" "$T/list" < "$T/old-mixed" > "$T/old-selected" 245 printf '%s\n' "$D2" > "$T/remove" 246 "$T/header-profile" gather "$T/remove" "$T/list" < "$T/old-selected" > "$T/shown" 247 chosen 'Original DOI title' "$A" "$D1" && grep -q 'New profile' "$T/shown" && ! grep -q 'Original profile' "$T/shown" && ok 'MUTANT caught specifically PROFILE_FROM_REJECTED_BUNDLE' || bad 'profile mutant wrong reason' 248 # B8-R control recreates the lost nonempty-array occurrence in the real JSON decoder. 249 python3 - research/lib/jflat.om "$T/no-array-marker.om" <<'PYARRAY' 250 import sys 251 s=open(sys.argv[1]).read();a=s.index('fn arr to void');b=s.index('fn val to void',a);part=s[a:b] 252 needle='opath\nob uchar 91\nob uchar 10\n';assert part.count(needle)==1 253 part=part.replace(needle,'',1);open(sys.argv[2],'w').write(s[:a]+part+s[b:]) 254 PYARRAY 255 "$OMC" < "$T/no-array-marker.om" > "$T/no-array-marker"; chmod 700 "$T/no-array-marker" 256 for order in array-open-first array-closed-first; do 257 "$T/no-array-marker" < "$T/$order.json" > "$T/array-lost.flat" 258 printf '@tree\n100644 blob 123 12\tLICENSE\n100644 blob 456 42\tpaper.md\n' >> "$T/array-lost.flat" 259 "$S" repo "$R" "$D1" 2026-11-11 other < "$T/array-lost.flat" > "$T/liccat" 3> "$T/lictext" 2> "$T/liclog" 260 [ "$(grep '^P' "$T/liccat" | cut -f7)" = 1 ] && [ -s "$T/lictext" ] && ok "MUTANT caught specifically LOST_ARRAY_OCCURRENCE $order" || bad "array marker control wrong reason $order" 261 done 262 sed 's/if gt get lamb 0 1/if false/g' research/sync.om > "$T/first-lic.om" 263 mutant first-lic 264 "$F" < "$T/ids-open-first.json" > "$T/licflat" 265 printf '@tree\n100644 blob 123 12\tLICENSE\n100644 blob 456 42\tpaper.md\n' >> "$T/licflat" 266 "$T/first-lic" repo "$R" "$D1" 2026-11-11 other < "$T/licflat" > "$T/liccat" 3> "$T/lictext" 2> "$T/liclog" 267 [ "$(grep '^P' "$T/liccat" | cut -f7)" = 1 ] && [ -s "$T/lictext" ] && ok 'MUTANT first licence wins caught by duplicate-field text admission' || bad 'licence mutant not caught for own reason' 268 echo "BUNDLES_RESULT pass=$pass fail=$fail" 269 [ "$fail" = 0 ]