interplane-forge
INTERPLANE Forge
Brought by drakestapleton
interplane-forge / research / tests / authors.sh
| 1 | #!/bin/sh |
| 2 | # Sourced by tests/run.sh after T/build is compiled and T, C, gen, ok and bad exist. |
| 3 | # No new compiler or host-language implementation: fixtures use the actual builder/publisher. |
| 4 | mkdir -p "$T/authors" "$T/auth-reg/show" "$T/auth-reg/text" |
| 5 | cat > "$T/authors/alice.tsv" <<'DATA' |
| 6 | O id alice |
| 7 | O name Alice <script> "&' |
| 8 | O orcid 0000-0000-0000-0001 |
| 9 | O added-by did:key:zAlice |
| 10 | O via zenodo |
| 11 | O checked 2026-11-11 |
| 12 | W foreign-a 2026-11-11 preprint Venue <b> 10.1/x}evil{\%&#_$ 10.1/quoted'"&<> 1 2oops 0 cc-by-4.0 Foreign <script>alert(1)</script> "&' |
| 13 | S foreign-a Summary & <img src=x onerror=alert(1)> |
| 14 | A foreign-a Abstract </p><script>alert(2)</script> |
| 15 | C foreign-a Alice <b> & Bob |
| 16 | B foreign-a Alice }evil{\%&#_$ |
| 17 | K foreign-a <script>keyword</script> |
| 18 | L foreign-a references http://example.org/insecure-link |
| 19 | L foreign-a references javascript:alert(1) |
| 20 | L foreign-a references https://example.org/"'&<> |
| 21 | F foreign-a File <b> "&' 12bytes http://example.org/insecure-file |
| 22 | F foreign-a File <b> "&' 12bytes https://example.org/file?x="'&<> |
| 23 | P foreign-a zenodo did:key:zAlice 2026-11-11 https://zenodo.org/records/1 1 |
| 24 | DATA |
| 25 | cat > "$T/authors/bob.tsv" <<'DATA' |
| 26 | O id bob |
| 27 | O name Bob Separate |
| 28 | O orcid |
| 29 | O added-by did:key:zBob |
| 30 | O via radicle |
| 31 | O checked 2026-11-11 |
| 32 | W foreign-b 2025-01-01 preprint Radicle 1 1 0 custom Bob metadata work |
| 33 | S foreign-b Metadata without text |
| 34 | A foreign-b A metadata-only abstract |
| 35 | C foreign-b Bob Separate |
| 36 | P foreign-b radicle did:key:zBob 2026-11-11 rad:zRepo 0 |
| 37 | G foreign-b 0123456789abcdef0123456789abcdef01234567 0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef |
| 38 | DATA |
| 39 | for id in alice bob; do |
| 40 | gen merge '' "$T/authors/$id.tsv" > "$T/authors/$id.merged" |
| 41 | cp "$T/authors/$id.tsv" "$T/auth-reg/show/$id.tsv" |
| 42 | done |
| 43 | cat "$C" "$T/authors/alice.merged" "$T/authors/bob.merged" > "$T/authors/catalog" |
| 44 | ac=$T/authors/catalog |
| 45 | gen authors '' "$ac" > "$T/authors/ids" |
| 46 | is "$(cat "$T/authors/ids")" "$(printf 'drakestapleton\nalice\nbob')" 'authors returns validated separate IDs' |
| 47 | is "$(grep -c '^O' "$T/authors/alice.merged" || :)" 0 'merge removes foreign O lines' |
| 48 | grep -Fq "$(printf 'J\tforeign-a\talice')" "$T/authors/alice.merged" && ok 'merge joins work to author' || bad 'missing merge join' |
| 49 | for id in alice bob drakestapleton; do gen author "$id" "$ac" > "$T/authors/$id.html"; done |
| 50 | grep -Fq "/research/foreign-a'" "$T/authors/alice.html" && ok 'Alice page lists her work' || bad 'Alice work absent' |
| 51 | is "$(grep -c '/research/foreign-b' "$T/authors/alice.html" || :)" 0 'Alice page excludes Bob work' |
| 52 | grep -Fq "/research/foreign-b'" "$T/authors/bob.html" && ok 'Bob page lists his work' || bad 'Bob work absent' |
| 53 | is "$(grep -c '/research/foreign-a' "$T/authors/bob.html" || :)" 0 'Bob page excludes Alice work' |
| 54 | grep -Fq 'Alice <script> "&'' "$T/authors/alice.html" && ok 'author HTML escaped' || bad 'author name not escaped' |
| 55 | gen index '' "$ac" > "$T/authors/index.html" |
| 56 | gen json '' "$ac" > "$T/authors/index.json" |
| 57 | for id in alice bob; do |
| 58 | grep -Fq "/research/authors/$id'" "$T/authors/index.html" && ok "hub links $id" || bad "hub missing $id" |
| 59 | grep -Fq "\"author_ids\":[\"$id\"]" "$T/authors/index.json" && ok "JSON joins $id" || bad "JSON missing $id" |
| 60 | done |
| 61 | for mode in work wjson wbib; do gen "$mode" foreign-a "$ac" > "$T/authors/$mode"; done |
| 62 | is "$(grep -Eic '<script|<img|<b>' "$T/authors/work" || :)" 0 'foreign markup is data, not elements' |
| 63 | grep -Fq '<script>alert(1)</script>' "$T/authors/work" && ok 'foreign title escaped in HTML' || bad 'foreign title missing' |
| 64 | grep -Fq '"title":"Foreign <script>alert(1)</script> \"' "$T/authors/wjson" && ok 'JSON quotes foreign title' || bad 'JSON title escaping' |
| 65 | is "$(grep -Ec 'http://|javascript:' "$T/authors/work" "$T/authors/wjson" | cut -d: -f2 | sort -u)" 0 'foreign HTML and JSON omit non-https links' |
| 66 | grep -Fq '"bytes":12' "$T/authors/wjson" && ok 'foreign file bytes numeric' || bad 'foreign file bytes invalid' |
| 67 | grep -Fq '"versions":2,' "$T/authors/wjson" && ok 'foreign versions numeric' || bad 'foreign versions invalid' |
| 68 | is "$(grep -c '}evil{' "$T/authors/wbib" || :)" 0 'foreign DOI and author cannot close BibTeX values' |
| 69 | grep -Fq 'doi = {10.1/x evil \%\&\#\_\$}' "$T/authors/wbib" && ok 'foreign DOI BibTeX punctuation escaped' || bad 'foreign DOI escaping wrong' |
| 70 | gen corpus '' "$ac" > "$T/authors/corpus-list" |
| 71 | grep -q '^foreign-a' "$T/authors/corpus-list" && ok 'open P admits foreign text' || bad 'open text missing' |
| 72 | is "$(grep -c '^foreign-b' "$T/authors/corpus-list" || :)" 0 'closed P excludes foreign text' |
| 73 | sed '/^P[[:space:]]foreign-a/d' "$ac" > "$T/authors/no-p" |
| 74 | gen corpus '' "$T/authors/no-p" > "$T/authors/no-p-list" |
| 75 | is "$(grep -c '^foreign-a' "$T/authors/no-p-list" || :)" 0 'missing P fails closed for text' |
| 76 | for mode in add doi; do |
| 77 | gen "$mode" '' "$ac" > "$T/authors/$mode.html" |
| 78 | is "$(grep -Eic '<script|style=|\b(every|everything|everyone|everybody|never|always|online)\b' "$T/authors/$mode.html" || :)" 0 "$mode has no scripts, inline style or banned copy" |
| 79 | done |
| 80 | # Requesters. A Zenodo record is public metadata that a Radicle key requested: the key gains no |
| 81 | # ownership, is labelled Requester, and is never displayed as an author. Radicle keeps "Added through". |
| 82 | zdisc='Zenodo records listed here are public metadata, requested by a key. Requesting a record gives that key no ownership of the record or the work, and the registry makes no claim that the key belongs to the person named on this page.' |
| 83 | wdisc='This Zenodo record is public metadata, requested by a key. Requesting a record gives that key no ownership of the record or the work, and the registry makes no claim that the key belongs to a person named on this page.' |
| 84 | # reqpage FILE DISCLAIMER KEY prints the first failed reason; a passing page prints nothing. |
| 85 | reqpage() { |
| 86 | grep -Fq "$2" "$1" || { echo 'Zenodo public-metadata disclaimer missing'; return; } |
| 87 | grep -Fq "Requester: key $3" "$1" || { echo "requester $3 not labelled"; return; } |
| 88 | ! grep -Fq 'Added by' "$1" || { echo 'requester shown as Added by'; return; } |
| 89 | [ "$(grep -oF "$3" "$1" | wc -l)" = "$(grep -oF "Requester: key $3" "$1" | wc -l)" ] || { echo "requester $3 shown outside its label"; return; } |
| 90 | } |
| 91 | reqfix() { |
| 92 | printf 'O\tid\t%s\nO\tname\t%s\nO\torcid\t\nO\tadded-by\t%s\nO\tvia\tzenodo\nO\tchecked\t2026-11-11\n' "$1" "$2" "$3" |
| 93 | printf 'W\t%s\t\t2025-02-02\tpreprint\tZenodo\t\t\t1\t1\t0\tcustom\t%s metadata work\n' "$5" "$2" |
| 94 | printf 'S\t%s\tPublic metadata\nA\t%s\tA requested abstract\nC\t%s\t%s\n' "$5" "$5" "$5" "$2" |
| 95 | printf 'P\t%s\tzenodo\t%s\t2026-11-11\thttps://zenodo.org/records/%s\t0\n' "$5" "$3" "$4" |
| 96 | } |
| 97 | reqfix dana 'Dana Writer' did:key:zKeyOne 2 foreign-d > "$T/authors/dana.tsv" |
| 98 | reqfix erin 'Erin Writer' did:key:zKeyTwo 3 foreign-e > "$T/authors/erin.tsv" |
| 99 | for id in dana erin; do gen merge '' "$T/authors/$id.tsv" > "$T/authors/$id.merged"; done |
| 100 | cat "$C" "$T/authors/dana.merged" "$T/authors/erin.merged" > "$T/authors/req-catalog" |
| 101 | rq=$T/authors/req-catalog |
| 102 | is "$(gen authors '' "$rq")" "$(printf 'drakestapleton\ndana\nerin')" 'two requester keys add no author IDs' |
| 103 | gen json '' "$rq" > "$T/authors/req-index.json" |
| 104 | gen index '' "$rq" > "$T/authors/req-index.html" |
| 105 | reqcase() { # author-id author-name key other-key work-slug |
| 106 | gen author "$1" "$rq" > "$T/authors/req-$1.html" |
| 107 | gen work "$5" "$rq" > "$T/authors/req-$5.html" |
| 108 | gen wjson "$5" "$rq" > "$T/authors/req-$5.json" |
| 109 | is "$(reqpage "$T/authors/req-$1.html" "$zdisc" "$3")" '' "author page $1 says public metadata, labels requester $3, disclaims ownership" |
| 110 | is "$(reqpage "$T/authors/req-$5.html" "$wdisc" "$3")" '' "work page $5 says public metadata, labels requester $3, disclaims ownership" |
| 111 | grep -Fq "<p class='by'><a href='/research/authors/$1'>$2</a></p>" "$T/authors/req-$5.html" && ok "work $5 byline names author $1, not the requester" || bad "work $5 byline lost author $1" |
| 112 | is "$(cat "$T/authors/req-$1.html" "$T/authors/req-$5.html" | grep -cF "$4" || :)" 0 "pages for $1 omit the other requester $4" |
| 113 | grep -Fq "\"provenance\":{\"how\":\"zenodo\",\"added_by\":\"$3\",\"requester\":\"$3\",\"requester_role\":\"requested public Zenodo metadata; no ownership or identity claim\",\"checked\":\"2026-11-11\"," "$T/authors/req-$5.json" && ok "work JSON $5 keeps added_by and adds requester" || bad "work JSON $5 requester fields wrong" |
| 114 | grep -Fq "{\"id\":\"$1\",\"name\":\"$2\",\"orcid\":\"\",\"added_by\":\"$3\",\"via\":\"zenodo\",\"checked\":\"2026-11-11\",\"requester\":\"$3\",\"requester_role\":\"requested public Zenodo metadata; no ownership or identity claim\"}" "$T/authors/req-index.json" && ok "hub JSON $1 keeps legacy fields and adds requester" || bad "hub JSON $1 requester fields wrong" |
| 115 | } |
| 116 | reqcase dana 'Dana Writer' did:key:zKeyOne did:key:zKeyTwo foreign-d |
| 117 | reqcase erin 'Erin Writer' did:key:zKeyTwo did:key:zKeyOne foreign-e |
| 118 | is "$(grep -o '"author_ids":\[[^]]*\]' "$T/authors/req-index.json" | grep -c 'did:key' || :)" 0 'hub JSON lists no requester key as an author' |
| 119 | is "$(grep -o '"name":"[^"]*"' "$T/authors/req-index.json" | grep -c 'did:key' || :)" 0 'hub JSON names no requester key' |
| 120 | is "$(grep -c "/research/authors/did:" "$T/authors/req-index.html" || :)" 0 'hub HTML links no requester key as an author' |
| 121 | python3 -I -c 'import json,sys; [json.load(open(f, encoding="utf-8")) for f in sys.argv[1:]]' "$T/authors/req-index.json" "$T/authors/req-foreign-d.json" "$T/authors/req-foreign-e.json" && ok 'requester JSON parses' || bad 'requester JSON invalid' |
| 122 | is "$(reqpage "$T/authors/alice.html" "$zdisc" did:key:zAlice)" '' 'Alice Zenodo author page labels requester and disclaims ownership' |
| 123 | is "$(reqpage "$T/authors/work" "$wdisc" did:key:zAlice)" '' 'Alice Zenodo work page labels requester and disclaims ownership' |
| 124 | gen work foreign-b "$ac" > "$T/authors/req-radicle.html" |
| 125 | grep -Fq 'Added through the shelf by key did:key:zBob' "$T/authors/req-radicle.html" && ok 'shelf work keeps its brought-by provenance, without the retired network name' || bad 'shelf provenance wording changed' |
| 126 | is "$(cat "$T/authors/bob.html" "$T/authors/req-radicle.html" | grep -c 'Zenodo record' || :)" 0 'Radicle pages carry no Zenodo disclaimer' |
| 127 | grep -Fq '"requester":"did:key:zBob","requester_role":"brought the repository to the shelf; not verified"}' "$T/authors/index.json" && ok 'hub JSON keeps Radicle meaning: brought, not verified' || bad 'Radicle requester role wrong' |
| 128 | # Negative control: a builder whose two disclaimers are blanked must fail the same oracle for that reason, |
| 129 | # and its pages must differ from the real ones only by the removed section. |
| 130 | sed 's/^text \(mazdisc\|mazwork\) .*/text \1 "\\n"/' research/build.om > "$T/authors/nodisc.om" |
| 131 | is "$(grep -cxF -e 'text mazdisc "\n"' -e 'text mazwork "\n"' "$T/authors/nodisc.om" || :)" 2 'control blanks both Zenodo disclaimers' |
| 132 | if "$OMC" < "$T/authors/nodisc.om" > "$T/authors/nodisc" && chmod 700 "$T/authors/nodisc"; then |
| 133 | { printf 'M\tauthor\tdana\n'; cat "$rq"; } | "$T/authors/nodisc" > "$T/authors/nodisc-dana.html" |
| 134 | { printf 'M\twork\tforeign-d\n'; cat "$rq"; } | "$T/authors/nodisc" > "$T/authors/nodisc-foreign-d.html" |
| 135 | is "$(reqpage "$T/authors/nodisc-dana.html" "$zdisc" did:key:zKeyOne)" 'Zenodo public-metadata disclaimer missing' 'control author page fails for its missing disclaimer' |
| 136 | is "$(reqpage "$T/authors/nodisc-foreign-d.html" "$wdisc" did:key:zKeyOne)" 'Zenodo public-metadata disclaimer missing' 'control work page fails for its missing disclaimer' |
| 137 | is "$(python3 -I -c 'import sys |
| 138 | r = open(sys.argv[1], encoding="utf-8").read(); m = open(sys.argv[2], encoding="utf-8").read() |
| 139 | d = "<section class='"'"'card'"'"'><h2>" + sys.argv[4] + "</h2><p>" + sys.argv[3] + "</p></section>" |
| 140 | print(int(r.count(d) == 1 and m == r.replace(d, "")))' "$T/authors/req-dana.html" "$T/authors/nodisc-dana.html" "$zdisc" 'Zenodo records')$(python3 -I -c 'import sys |
| 141 | r = open(sys.argv[1], encoding="utf-8").read(); m = open(sys.argv[2], encoding="utf-8").read() |
| 142 | d = "<section class='"'"'card'"'"'><h2>" + sys.argv[4] + "</h2><p>" + sys.argv[3] + "</p></section>" |
| 143 | print(int(r.count(d) == 1 and m == r.replace(d, "")))' "$T/authors/req-foreign-d.html" "$T/authors/nodisc-foreign-d.html" "$wdisc" 'Zenodo record')" 11 'control pages differ from the real pages only by the disclaimer' |
| 144 | else |
| 145 | bad 'disclaimer control builder does not compile' |
| 146 | fi |
| 147 | # Frozen baseline, including when foreign authors share the same catalog. |
| 148 | mkdir -p "$T/authors/legacy" |
| 149 | while IFS= read -r s; do |
| 150 | gen work "$s" "$ac" > "$T/authors/legacy/$s.html" |
| 151 | gen wjson "$s" "$ac" > "$T/authors/legacy/$s.json" |
| 152 | gen wbib "$s" "$ac" > "$T/authors/legacy/$s.bib" |
| 153 | done < "$T/slugs" |
| 154 | # The hub changes with the author registry; the immutable contract covers work documents. |
| 155 | basefile=$T/authors/work-sha256.txt |
| 156 | grep -Ev " research\.(html|json|bib|txt|css)$" research/tests/fixtures/base-sha256.txt > "$basefile" |
| 157 | (cd "$T/authors/legacy" && sha256sum -c "$basefile") > "$T/authors/base-check" 2>&1 && ok '16 legacy HTML JSON Bib documents remain byte exact' || bad 'legacy document hash drift' |
| 158 | # Source snapshot: G is shown for the foreign work that carries it, and refused elsewhere. |
| 159 | gcommit=0123456789abcdef0123456789abcdef01234567 |
| 160 | gsha=0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef |
| 161 | gen work foreign-b "$ac" > "$T/authors/g.html" |
| 162 | gen wjson foreign-b "$ac" > "$T/authors/g.json" |
| 163 | grep -Fq "Repository commit: <code>$gcommit</code>. Paper SHA-256: <code>$gsha</code>" "$T/authors/g.html" && ok "G commit and paper digest shown on foreign page" || bad "G snapshot missing from page" |
| 164 | grep -Fq "\"open_text\":false,\"source_commit\":\"$gcommit\",\"paper_sha256\":\"$gsha\"}" "$T/authors/g.json" && ok "G commit and paper digest in provenance JSON" || bad "G snapshot missing from JSON" |
| 165 | python3 -I -c "import json,sys; json.load(open(sys.argv[1]))" "$T/authors/g.json" && ok "G work JSON parses" || bad "G work JSON invalid" |
| 166 | is "$(grep -c "source_commit\|Source snapshot" "$T/authors/work" "$T/authors/wjson" | cut -d: -f2 | sort -u)" 0 "work without G shows no snapshot" |
| 167 | first=$(head -n 1 "$T/slugs") |
| 168 | gline=$(printf "G\tforeign-b\t%s\t%s" "$gcommit" "$gsha") |
| 169 | for gcase in upper short extra legacy duplicate; do |
| 170 | case "$gcase" in |
| 171 | upper) sed "s/^G\tforeign-b\t0123456789abcdef/G\tforeign-b\t0123456789ABCDEF/" "$ac" > "$T/authors/g-$gcase" ;; |
| 172 | short) sed "s/^G\tforeign-b\t$gcommit/G\tforeign-b\t0123456789abcdef0123456789abcdef0123456/" "$ac" > "$T/authors/g-$gcase" ;; |
| 173 | extra) sed "s/^G\tforeign-b\t.*/&\textra/" "$ac" > "$T/authors/g-$gcase" ;; |
| 174 | legacy) { cat "$ac"; printf "G\t%s\t%s\t%s\n" "$first" "$gcommit" "$gsha"; } > "$T/authors/g-$gcase" ;; |
| 175 | duplicate) { cat "$ac"; printf "%s\n" "$gline"; } > "$T/authors/g-$gcase" ;; |
| 176 | esac |
| 177 | rc=0; gen wjson foreign-b "$T/authors/g-$gcase" > "$T/authors/g-$gcase.out" || rc=$? |
| 178 | is "$rc" 4 "G $gcase refused" |
| 179 | is "$(wc -c < "$T/authors/g-$gcase.out" | tr -d " ")" 0 "G $gcase emits no document" |
| 180 | done |
| 181 | # Refusal cases: duplicate work and a path traversal author id produce no document. |
| 182 | cat "$ac" "$T/authors/alice.merged" > "$T/authors/duplicate" |
| 183 | rc=0; gen index '' "$T/authors/duplicate" > "$T/authors/refused" || rc=$? |
| 184 | is "$rc" 4 'duplicate catalog work refused' |
| 185 | is "$(wc -c < "$T/authors/refused" | tr -d ' ')" 0 'duplicate refusal emits no document' |
| 186 | sed 's/^O\tid\talice$/O\tid\t..\/alice/' "$T/authors/alice.tsv" > "$T/authors/bad-id" |
| 187 | rc=0; gen merge '' "$T/authors/bad-id" > "$T/authors/refused" || rc=$? |
| 188 | is "$rc" 4 'path traversal author refused' |
| 189 | # Publication consumes only gathered show/ files, quotes text and prunes its own outputs. |
| 190 | cp "$C" "$T/auth-reg/catalog.tsv" |
| 191 | cp research/registry/text/*.txt "$T/auth-reg/text/" |
| 192 | printf 'First paragraph.\n@@\tforged-source\tFake title\nThird paragraph.\n' > "$T/auth-reg/text/foreign-a.txt" |
| 193 | textsha=$(sha256sum "$T/auth-reg/text/foreign-a.txt" | cut -d' ' -f1) |
| 194 | mv "$T/auth-reg/text/foreign-a.txt" "$T/auth-reg/text/foreign-a.$textsha.txt" |
| 195 | printf 'T\tforeign-a\t%s\n' "$textsha" >> "$T/auth-reg/show/alice.tsv" |
| 196 | printf 'This closed text must not enter the corpus.\n' > "$T/auth-reg/text/foreign-b.txt" |
| 197 | mkdir -p "$T/auth-site/ask" "$T/auth-reg/a/not-gathered" |
| 198 | printf 'keep answer\n' > "$T/auth-site/ask/keep.html" |
| 199 | cp "$T/authors/alice.tsv" "$T/auth-reg/a/not-gathered/unfiltered.tsv" |
| 200 | if sh research/publish.sh "$T/auth-site" "$T/auth-corpus" "$T/auth-reg" > "$T/authors/publish.log" 2>&1; then |
| 201 | ok 'publishes foreign metadata-only work without requiring its text' |
| 202 | [ -f "$T/auth-site/w/foreign-b.html" ] && ok 'metadata-only page exists' || bad 'metadata-only page missing' |
| 203 | is "$(grep -c '^@@' "$T/auth-corpus" || :)" 17 'corpus contains only registry-authoritative headers' |
| 204 | grep -Fq "$(printf '> @@\tforged-source\tFake title')" "$T/auth-corpus" && ok 'foreign planted corpus header quoted' || bad 'foreign corpus header unquoted' |
| 205 | is "$(grep -c '^@@.*foreign-b' "$T/auth-corpus" || :)" 0 'closed foreign text not published' |
| 206 | else |
| 207 | bad "foreign publication failed: $(cat "$T/authors/publish.log")" |
| 208 | fi |
| 209 | # Simulate upstream takedown; raw a/ still contains the removed record. |
| 210 | rm "$T/auth-reg/show/alice.tsv" "$T/auth-reg/show/bob.tsv" |
| 211 | if sh research/publish.sh "$T/auth-site" "$T/auth-corpus" "$T/auth-reg" > "$T/authors/prune.log" 2>&1; then |
| 212 | ok 'republish after upstream takedown' |
| 213 | leftovers=$(find -L "$T/auth-site/w" "$T/auth-site/a" -type f \( -name 'foreign-*' -o -name alice.html -o -name bob.html \) | wc -l | tr -d ' ') |
| 214 | is "$leftovers" 0 'stale foreign docs and author pages removed' |
| 215 | is "$(grep -c 'foreign-a\|forged-source\|foreign-b' "$T/auth-corpus" || :)" 0 'stale foreign corpus removed' |
| 216 | is "$(cat "$T/auth-site/ask/keep.html")" 'keep answer' 'pruning preserves ask answers' |
| 217 | (cd "$T/auth-site/w" && sha256sum -c "$basefile") > "$T/authors/prune-base" 2>&1 && ok 'pruning preserves legacy document bytes' || bad 'pruning changed legacy documents' |
| 218 | else |
| 219 | bad "prune publication failed: $(cat "$T/authors/prune.log")" |
| 220 | fi |
| 221 | # Refuse a full registry instead of emitting a document from a truncated prefix. |
| 222 | { printf 'M\tindex\n'; cat "$C"; dd if=/dev/zero bs=262144 count=1 2>/dev/null; } > "$T/authors/oversize" |
| 223 | rc=0; "$T/build" < "$T/authors/oversize" > "$T/authors/oversize.out" || rc=$? |
| 224 | is "$rc" 4 'oversize merged registry refused' |
| 225 | is "$(wc -c < "$T/authors/oversize.out" | tr -d ' ')" 0 'oversize registry produces no document' |
| 226 | # Failed publication must not replace the last accepted corpus or legacy docs. |
| 227 | cp "$T/auth-corpus" "$T/authors/accepted-corpus" |
| 228 | cp "$T/authors/alice.tsv" "$T/auth-reg/show/alice.tsv" |
| 229 | dd if=/dev/zero bs=4194304 count=1 2>/dev/null | tr '\000' x > "$T/authors/oversize-text" |
| 230 | textsha=$(sha256sum "$T/authors/oversize-text" | cut -d' ' -f1) |
| 231 | cp "$T/authors/oversize-text" "$T/auth-reg/text/foreign-a.$textsha.txt" |
| 232 | printf 'T\tforeign-a\t%s\n' "$textsha" >> "$T/auth-reg/show/alice.tsv" |
| 233 | rc=0; sh research/publish.sh "$T/auth-site" "$T/auth-corpus" "$T/auth-reg" > "$T/authors/oversize-corpus.log" 2>&1 || rc=$? |
| 234 | is "$rc" 1 'oversize corpus refused' |
| 235 | grep -q 'corpus exceeds 4194303 bytes' "$T/authors/oversize-corpus.log" && ok 'oversize corpus fails for capacity, not cache identity' || bad 'oversize corpus wrong refusal' |
| 236 | cmp -s "$T/authors/accepted-corpus" "$T/auth-corpus" && ok 'oversize corpus leaves accepted corpus intact' || bad 'failed publication replaced corpus' |