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/store/tests/compare-controls.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 / store / tests / compare-controls.sh` 155 lines ยท 8915 bytes Raw Blame History 1 #!/usr/bin/env bash 2 # Controls for `compare.py radicle` (review-b1 finding 1). Each control builds two tiny fetch folders 3 # (MAIN and STORE, the index.tsv + body files that `compare.py fetch` writes) in a temporary folder 4 # and runs the comparator on them; nothing is fetched and no server is started. 5 # sh store/tests/compare-controls.sh [OLD_REV] 6 # The table gives the expected and observed exit of each run; the script exits 0 only when every 7 # observed exit is the expected one. OLD_REV (default `babf1706`) is the commit whose compare.py is run on 8 # the controls marked "old": they show what the earlier per-line presence test accepted. 9 set -u 10 D=$(cd "$(dirname "$0")" && pwd) 11 OLD_REV=${1:-`babf1706080e75dff2f8dd412e0d62ecbc538d44`} 12 T=$(mktemp -d) 13 trap 'rm -rf "$T"' EXIT 14 git -C "$D" show "$OLD_REV:store/tests/compare.py" > "$T/compare-old.py" || { echo "cannot read compare.py at $OLD_REV"; exit 2; } 15 16 python3 - "$T" <<'EOF' 17 import hashlib, os, sys 18 T = sys.argv[1] 19 O = "drakestapleton" 20 RID, RID2 = "`z3uek4Z9YSEAtFXmedDzEG4xvD4XR`", "`z44GqrPVAPjZkhoD2MWVjqy18ighN`" 21 GID, GID2, GID3 = "ab" * 32, "cd" * 32, "ef" * 32 22 KEY = "SHA256:VY3HfHMNlI1gw6laxupXOx2vj2zSOOjYcQS1sC3S6t0" 23 NAV = ('
') 25 FOOT_A = ('INTERPLANE Forge: agents express intent; the forge retains authority. Built on Radicle' 26 ' (Heartwood): repositories are Radicle projects served by forged, a seeded-Omega web server, with no' 27 ' JavaScript.
') 28 FOOT_B = ('INTERPLANE Forge: agents express intent; the forge retains authority. Repositories are' 29 " plain Git kept in Interplane's own signed store, served by forged, a seeded-Omega web server, with no" 30 ' JavaScript.
') 31 C = ''
32 DEV_A = [
33 "RID The Radicle ID: the project's permanent name on Radicle, the open network that stores and signs"
34 " it. This one is " + C + "rad:" + RID + " .",
35 "Home
", 77 FOOT_B if store else FOOT_A)), 78 ("/", "json"): (200, "application/json", "[\n" + item(rid) + ",\n" + item(rid2, name="core") + "\n]\n"), 79 ("/%s/hop" % O, "html"): (200, "text/html; charset=utf-8", 80 html(*(DEV_B if store else DEV_A), PANEL_B if store else PANEL_A, "same
")), 81 ("/%s/hop" % O, "json"): (200, "application/json", repo_json(rid, store)), 82 ("/%s/hop/tags/1" % O, "json"): (200, "application/json", 83 '{"schema":"forge/tags/1","repo":' + item(rid) + ',"count":0}\n'), 84 ("/%s/hop/archive/refs/heads/main.zip" % O, "html"): (200, "application/zip", "PK\x03\x04 same bytes"), 85 ("/%s/hop/raw/main/README.md" % O, "html"): (200, "text/plain; charset=utf-8", "readme\n"), 86 } 87 88 89 def mutate(control, p): 90 k = ("/%s/hop/tags/1" % O, "json") 91 if control == "b": # a non-id JSON field changed, on a one-line body that also holds an id 92 st, ct, body = p[k] 93 p[k] = (st, ct, body.replace('"tags":[]', '"tags":["v1","v2","v3"]')) 94 elif control == "c": # status differs 95 p[k] = (404, p[k][1], p[k][2]) 96 elif control == "d": # a binary page differs 97 z = ("/%s/hop/archive/refs/heads/main.zip" % O, "html") 98 p[z] = (p[z][0], p[z][1], "PK\x03\x04 other bytes") 99 elif control == "e": # footer replaced by other text that carries a store id 100 h = ("/", "html") 101 p[h] = (p[h][0], p[h][1], p[h][2].replace(FOOT_B, "Nothing to see; git:" + GID3 + "
")) 102 elif control == "f": # one Radicle id given two different store ids on two pages 103 j = ("/", "json") 104 p[j] = (p[j][0], p[j][1], p[j][2].replace("git:" + GID, "git:" + GID3, 1)) 105 elif control == "g": # the clone panel names another project's repository 106 h = ("/%s/hop" % O, "html") 107 p[h] = (p[h][0], p[h][1], p[h][2].replace("projects/hop/repo.git", "projects/other/repo.git")) 108 elif control == "h": # a MAIN-only Radicle line with no STORE counterpart (the kept run's agent line) 109 return "main-extra" 110 return None 111 112 113 def write(d, p): 114 os.makedirs(d) 115 idx = [] 116 for (path, kind), (st, ct, body) in p.items(): 117 b = body.encode("utf-8") 118 name = hashlib.sha256((kind + " " + path).encode()).hexdigest()[:32] 119 open(os.path.join(d, name), "wb").write(b) 120 idx.append("\t".join([name, kind, path, str(st), ct, "", str(len(b)), hashlib.sha256(b).hexdigest()])) 121 open(os.path.join(d, "index.tsv"), "w", encoding="utf-8").write("\n".join(idx) + "\n") 122 123 124 for control in "abcdefgh": 125 main, store = pages(False), pages(True) 126 if mutate(control, store) == "main-extra": 127 h = ("/%s/hop" % O, "html") 128 main[h] = (main[h][0], main[h][1], main[h][2].replace("same
", CONTRIB + "\nsame
")) 129 write(os.path.join(T, control, "main"), main) 130 write(os.path.join(T, control, "store"), store) 131 EOF 132 [ -d "$T/h/store" ] || { echo "fixtures not written"; exit 2; } 133 134 fail=0 135 printf '%-8s %-5s %-70s %-8s %s\n' control code what expected observed 136 run() { # run CONTROL CODE EXPECTED WHAT 137 if [ "$2" = old ]; then py="$T/compare-old.py"; else py="$D/compare.py"; fi 138 python3 "$py" radicle "$T/$1/main" "$T/$1/store" > "$T/$1.$2.out" 2>&1 139 got=$? 140 [ "$got" = "$3" ] || fail=1 141 printf '%-8s %-5s %-70s %-8s %s%s\n' "$1" "$2" "$4" "$3" "$got" "$([ "$got" = "$3" ] || echo ' MISMATCH')" 142 { grep -m3 '^BAD' "$T/$1.$2.out"; tail -1 "$T/$1.$2.out"; } | cut -c1-200 | sed 's/^/ /' 143 } 144 run a new 0 "identical apart from id forms and the listed rules" 145 run b new 1 'tags [] vs three tags in a one-line JSON body with an id' 146 run b old 0 "same, earlier presence test (the defect: it passes)" 147 run c new 1 "status 200 vs 404" 148 run d new 1 "binary (application/zip) page bytes differ" 149 run e new 1 "footer replaced by other text carrying git: