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/agentdoor-store.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 / agentdoor-store.sh` 340 lines ยท 26563 bytes Raw Blame History 1 #!/usr/bin/env bash 2 # ORACLE: host test driver (bash + curl + git + interplane-native ipl + server/tests/agentdoor.py), not 3 # product code. 4 # store/tests/agentdoor-store.sh: the agent door (docs/AGENT-DOOR.md) of the store-reading build: the 5 # event stream and the feed read from a native store (store/evcol.om), agents.json generated for the 6 # build's units, the served set (every public catalog line less the deny list) and the 503 "moving" 7 # answers of the parts the store build composes out (store/moving.om). 8 # IPL_DIR= bash store/tests/agentdoor-store.sh 9 # (spark; FORGED_CPUS default 0-2, run under its pool lock; AGENTDOOR_PORT default 19994, private 10 # ports 19990..19999 only; KEEP=1 keeps the temp dir) 11 # Everything is private to a temp dir: a store made with ipl and a throwaway key, holding 12 # adfix public: commits, an annotated tag v1 13 # adtwo public, no tag: served, so that "a landing reads one project" has another to skip 14 # adhid a private catalog line: must never appear (pages, JSON, stream) 15 # omega-pearl public under a denied name (server/repos.om fdeny): must never appear 16 # adrid public, its old id the denied rad:`z2ft64NFLsKzWttCXw6NWNbRQLggQ`: must never appear 17 # the social log of server/tests/agentdoor.py (stars of served, private and denied projects, 18 # favorites, a watch, follows, an unstar, accounts, sessions, a logout) and an open shelf list (its 19 # kinds must not occur: the open slice is not composed). The expected served set is computed from the 20 # catalog (store/tests/expect_served.py). The site chrome is read from the real store's interplane.io 21 # project (read only). Never 18480, ~/forge-data, ~/interplane-store or ~/interplane-store-owner writes. 22 # Gates: kinds (release, branch_moved, star, follow only), sources name store objects (chain.tsv: 23 # for a landing, repo.git: for a tag, social.log:), times (the chain record's time for a 24 # landing), change-triggered collection (no pass on unchanged requests; a landing reads one of the two 25 # served projects; a tag written into repo.git reads one project; a catalog rewritten with the same 26 # lines reads nothing; a project added to the catalog is served and adds no event), seq stable 27 # across a restart and continued after it, every agents.json route answering its schema (agentdoor.py 28 # agents), not_available holding the composed-out parts (salvage/, community/, open and trending 29 # with the moving reason), no Radicle words in agents.json or the feed page, the private and denied 30 # projects 404 on their pages, their JSON and absent from stream and feed; every moving address 31 # (salvage, community, open, open.json, bring.sh, get.sh, withdraw.sh, trending, on both bases) 32 # answers 503 with no Retry-After, title "Moving" and exactly "This part is moving to the new 33 # Interplane store and is not available yet.", and as JSON forge/error/1 with "reason":"moving". 34 # Negative controls (each must FAIL the check it targets): a collector whose star check accepts any 35 # repository, a collector that never finds the chain record, an agents table that calls a collab row 36 # part of the forge, a moving seam that does not mark its 503 as moving. 37 set -u 38 cd "$(dirname "$0")/../.." 39 ROOT=$(pwd) 40 H=$ROOT/server/tests 41 CORES=${FORGED_CPUS:-0-2} 42 PORT=${AGENTDOOR_PORT:-19994} 43 case $PORT in 1999[0-9]) ;; *) echo "REFUSED: use a private port in 19990..19999"; exit 2 ;; esac 44 IPLD=${IPL_DIR:?IPL_DIR: an interplane-native checkout with bin/ built} 45 [ -x "$IPLD/ipl" ] && [ -x "$IPLD/bin/landrec" ] && [ -x "$IPLD/bin/chain" ] || { echo "NOT_RUN: $IPLD has no built ipl"; exit 3; } 46 SITE=${FORGE_SITE_STORE:-$HOME/interplane-store-owner/projects/interplane.io/repo.git} 47 [ -d "$SITE" ] || { echo "NOT_RUN: no site repository $SITE for the chrome"; exit 3; } 48 OMC=$HOME/work/flux/omega-mv/seed/out/omc 49 T=$(mktemp -d /tmp/agentdoor-store.XXXXXX) 50 chmod 700 "$T" 51 PASS=0; FAIL=0; PID= 52 ok() { PASS=$((PASS+1)); echo "PASS $*"; } 53 bad() { FAIL=$((FAIL+1)); echo "FAIL $*"; } 54 check() { if [ "$1" = "$2" ]; then ok "$3 ($1)"; else bad "$3: want $2, got $1"; fi; } 55 stop() { [ -n "$PID" ] && kill "$PID" 2> /dev/null; [ -n "$PID" ] && wait "$PID" 2> /dev/null; PID=; } 56 trap 'stop; [ -n "${KEEP:-}" ] || rm -rf "$T"' EXIT 57 if ss -ltn | grep -q "127.0.0.1:$PORT "; then echo "NOT_RUN: port $PORT busy"; exit 3; fi 58 U=http://127.0.0.1:$PORT 59 60 # ---- fixture store 61 ssh-keygen -q -t `ed25519` -N "" -C "agentdoor-store test key" -f "$T/key" || exit 1 62 export GIT_AUTHOR_NAME=fixture GIT_AUTHOR_EMAIL=fixture@invalid GIT_COMMITTER_NAME=fixture GIT_COMMITTER_EMAIL=fixture@invalid 63 export GIT_AUTHOR_DATE=2026-11-13T00:00:00Z GIT_COMMITTER_DATE=2026-11-13T00:00:00Z 64 mkproj() { # mkproj NAME ALIAS [VISIBILITY [notag]]: a working copy $T/w-NAME with a.txt and (unless notag) an annotated tag v1, then init + import 65 local n=$1 w=$T/w-$1 vis=${3:-public} 66 git init -q -b main "$w" && echo "$n" > "$w/a.txt" && git -C "$w" add a.txt && git -C "$w" commit -qm "first $n" || return 1 67 [ "${4:-}" = notag ] || git -C "$w" tag -a v1 -m "release one of $n" || return 1 68 mkdir -p "$T/store/projects/$n" && git clone -q --bare "$w" "$T/store/projects/$n/repo.git" || return 1 69 "$IPLD/ipl" init "$T/store" "$n" main "$vis" "$2" "$T/key" > /dev/null 2>> "$T/ipl.err" || return 1 70 printf 'fixture %s\n' "$n" > "$T/ev-$n"; printf 'note %s\n' "$n" > "$T/note-$n" 71 "$IPLD/ipl" import "$T/store" "$n" main "$T/ev-$n" "$T/note-$n" "import-$n" "$T/key" > /dev/null 2>> "$T/ipl.err" || return 1 72 } 73 RF=zAgentDoorStoreFixtureAdfix1 RP=zAgentDoorStoreFixtureHidden RD=zAgentDoorStoreFixtureDenied RT=zAgentDoorStoreFixtureAdtwo1 74 DENYRID=`z2ft64NFLsKzWttCXw6NWNbRQLggQ` # server/repos.om fdeny (an old id, not a store id) 75 mkproj adfix "rad:$RF" && mkproj adtwo "rad:$RT" public notag && mkproj adhid "rad:$RP" private && mkproj omega-pearl "rad:$RD" \ 76 && mkproj adrid "rad:$DENYRID" public notag || { bad "fixture store: $(tail -3 "$T/ipl.err")"; exit 1; } 77 for n in adfix adtwo adhid omega-pearl adrid; do "$IPLD/ipl" verify "$T/store" "$n" > /dev/null || bad "fixture $n does not verify"; done 78 check "$(wc -l < "$T/store/catalog.tsv")" 5 "fixture catalog lines" 79 check "$(awk -F'\t' '$1 == "adhid" {print $5}' "$T/store/catalog.tsv")" private "adhid is a private catalog line" 80 WANT=$(python3 store/tests/expect_served.py "$T/store" | sort | tr '\n' ' ') 81 check "$WANT" "adfix adtwo " "expected served set computed from the catalog" 82 MAIN0=$(git --git-dir="$T/store/projects/adfix/repo.git" rev-parse refs/heads/main) 83 TAGV1=$(git --git-dir="$T/store/projects/adfix/repo.git" rev-parse refs/tags/v1) 84 85 # ---- data dir, social log, open shelf, research files (as server/tests/agentdoor.sh) 86 mkdir -p "$T/data/logs" "$T/data/open/p" "$T/social" 87 OWN=`z6MkfZDue1TbaNFi3ZzcD9uiTeduPLC52ucdFVuLKZwexxhK` 88 D1=did:key:z6MkfixtureAccountOneKeyAbCdEfGhJkLmNpQrStUvWxY 89 D2=did:key:`z6MkotherFixtureAccountKeyAbCdEfGhJkLmNpQrStUvWxYz` 90 OH=`z3AgentDoorHeadFixtureProject` 91 printf '%s\theld\t%s\t2026-11-10\t10\tshelf-a\tfixture project a\tnote a\n' "$OH" "$D2" > "$T/data/open/list.tsv" 92 mkdir -p "$T/data/research/gen/public.fixture1/w" && ln -s gen/public.fixture1 "$T/data/research/current" 93 printf '{"schema":"interplane/research/1","works":[]}\n' > "$T/data/research/gen/public.fixture1/index.json" 94 printf '{"schema":"interplane/research-work/1","work":{"slug":"fixture-work"}}\n' > "$T/data/research/gen/public.fixture1/w/fixture-work.json" 95 cat > "$T/fixture.json" < /dev/null || { bad "social fixture"; exit 1; } 100 101 # ---- builds: build OUT [SED] [AGENTS_TSV]: this tree's store units, port and data dir rewritten 102 build() { 103 local out=$1 extra=${2:-} at=${3:-} 104 if [ -n "$at" ]; then cp server/agents.tsv "$T/agents.tsv.keep" && cp "$at" server/agents.tsv; fi 105 (export FORGE_STORE=$T/store FORGE_SITE_STORE=$SITE FORGE_CLONE_BASE=https://interplane.io/ 106 { printf 'om2\n'; cat $(./run.sh units); } > "$out.src.om" && cp .build/agents.tsv "$out.agents.tsv") 107 local rc=$? 108 if [ -n "$at" ]; then cp "$T/agents.tsv.keep" server/agents.tsv; fi 109 [ "$rc" = 0 ] || return 1 110 local s=(-e "s/haddr4 a `2130706433` 18480/haddr4 a `2130706433` $PORT/" -e "s|^text tfdata \".*\"|text tfdata \"$T/data/\"|") 111 [ -n "$extra" ] && s+=(-e "$extra") 112 sed "${s[@]}" "$out.src.om" > "$out.om" 113 taskset -c "$CORES" nice -n 10 "$OMC" < "$out.om" > "$out" 2> "$out.err" || { echo "BUILD FAILED $out: $(cat "$out.err")"; return 1; } 114 chmod 755 "$out" 115 } 116 start() { # start BIN 117 FORGE_SOCIAL_DIR=$T/social/ taskset -c "$CORES" nice -n 10 "$1" 2>> "$1.log" & 118 PID=$! 119 for _ in $(seq 100); do curl -s -o /dev/null "$U/explore" && return 0; sleep 0.1; done 120 return 1 121 } 122 passes() { grep -c '^events: pass ' "$1.log"; } 123 get() { curl -s -o "$T/b" -D "$T/h" -w '%{http_code}' -H "X-Forge-Base: ${2:-/}" "$U/$1"; } 124 ev() { curl -s "$U/events.json?limit=200" | python3 -c "$1"; } 125 lastpass() { grep '^events: pass ' "$1.log" | tail -1; } 126 field() { echo "$1" | sed -n "s/.*$2 \([0-9]*\).*/\1/p"; } 127 128 build "$T/forged" || { bad "test build"; exit 1; } 129 ok "test build $(sha256sum < "$T/forged" | cut -c1-16)" 130 grep -q '^fn evcollect' "$T/forged.om" && grep -q '^text tevschn' "$T/forged.om" && ok "door/ composed with store/evcol.om" || bad "store collector not composed" 131 ! grep -q '^fn evcobs' "$T/forged.om" && ok "door/ev3col.om (Radicle refs and COBs) not composed" || bad "door/ev3col.om composed in a store build" 132 start "$T/forged" || { bad "test forged did not start: $(tail -3 "$T/forged.log")"; exit 1; } 133 134 # ---- the served set: every public line less the deny list 135 check "$(get drakestapleton/adfix)" 200 "served project page" 136 check "$(get drakestapleton/adtwo)" 200 "second served project page" 137 check "$(get drakestapleton/adhid)" 404 "private project page" 138 check "$(get drakestapleton/adhid.json)" 404 "private project JSON" 139 check "$(curl -s -o /dev/null -w '%{http_code}' -H 'Accept: application/json' "$U/drakestapleton/adhid")" 404 "private project with Accept JSON" 140 check "$(get drakestapleton/omega-pearl)" 404 "denied project page (name)" 141 check "$(get drakestapleton/adrid)" 404 "denied project page (old id)" 142 check "$(get drakestapleton/adrid.json)" 404 "denied project JSON (old id)" 143 get explore.json > /dev/null 144 check "$(python3 -c 'import json,sys; print("".join(n + " " for n in sorted(r["name"] for r in json.load(open(sys.argv[1]))["repos"])))' "$T/b")" "$WANT" "explore lists exactly the expected served set" 145 check "$(python3 -c 'import json,sys; print(json.load(open(sys.argv[1]))["count"])' "$T/b")" "$(python3 store/tests/expect_served.py --count "$T/store")" "explore.json count = public lines less the deny list" 146 ! grep -q "forged: project adhid" "$T/forged.log" && ok "stderr: the private line is skipped without a line" || bad "a stderr line names the private adhid" 147 grep -q "forged: project omega-pearl left out (on the deny list" "$T/forged.log" && ok "stderr: omega-pearl left out by the deny list" || bad "no deny line for omega-pearl" 148 grep -q "forged: project adrid left out (on the deny list" "$T/forged.log" && ok "stderr: adrid left out by the deny list (its old id)" || bad "no deny line for adrid" 149 150 # ---- the moving parts: 503, no Retry-After, title Moving, exactly the text; JSON reason moving 151 MVTXT='This part is moving to the new Interplane store and is not available yet.' 152 MVHTML="salvage salvage/ salvage/new salvage/x/y community community/ community/join community/dl/x open open/ open/$OH open/alarms trending bring.sh get.sh withdraw.sh" 153 MVJSON="open.json trending.json open/$OH.json open/alarms.json salvage/x.json" 154 mvpage() { # mvpage PATH BASE [ACCEPT]: fetch; prints status, then mvpage.py's verdict 155 curl -s -o "$T/mv.body" -D "$T/mv.h" -w '%{http_code} ' -H "X-Forge-Base: $2" ${3:+-H "Accept: $3"} "$U/$1" 156 grep -qi '^retry-after:' "$T/mv.h" && printf 'retry-after ' || printf 'no-retry ' 157 python3 - "$T/mv.body" "$MVTXT" <<'EOF' 158 import json, re, sys 159 b = open(sys.argv[1], encoding="utf-8", errors="replace").read() 160 try: 161 d = json.loads(b) 162 ok = (d.get("schema") == "forge/error/1" and d.get("status") == 503 and d.get("reason") == "moving" 163 and d.get("message") == sys.argv[2] and d.get("error") == "Moving") 164 print("json-moving" if ok else "json-other") 165 except ValueError: 166 b = re.sub(r'([^<]*)', r"\1", b).replace(' translate="no"', "") 167 m = re.search(r'

(.*?)

(.*?)

', b) 168 t = re.search(r"(.*?)", b) 169 ok = m and m.group(1) == "503 Moving" and m.group(2) == sys.argv[2] and t and "Moving" in t.group(1) 170 print("html-moving" if ok else "html-other") 171 EOF 172 } 173 mvall() { # every moving address on both bases; prints one line per address that is wrong 174 for b in / /forge/; do 175 for p in $MVHTML; do r=$(mvpage "$p" "$b"); [ "$r" = "503 no-retry html-moving" ] || echo "[$b] $p: $r"; done 176 for p in salvage/ community/ open/; do r=$(mvpage "$p" "$b" application/json); [ "$r" = "503 no-retry json-moving" ] || echo "[$b] $p (Accept JSON): $r"; done 177 for p in $MVJSON; do r=$(mvpage "$p" "$b"); [ "$r" = "503 no-retry json-moving" ] || echo "[$b] $p: $r"; done 178 done 179 r=$(curl -s -o /dev/null -w '%{http_code}' -X POST "$U/salvage/"); [ "$r" = 503 ] || echo "POST /salvage/: $r" 180 } 181 mvall > "$T/mv.bad" 182 [ ! -s "$T/mv.bad" ] && ok "every moving address answers 503, no Retry-After, title Moving, the exact text; JSON forge/error/1 reason moving ($(echo $MVHTML $MVJSON | wc -w) addresses, both bases, Accept JSON too)" || bad "moving answers: $(head -5 "$T/mv.bad" | tr '\n' ';')" 183 for p in salvagex community-x opening open.jsonx trendingx salvagex/y; do 184 s=$(get "$p"); [ "$s" != 503 ] && ok "$p is not a moving address ($s)" || bad "$p answers 503" 185 done 186 check "$(mvpage explore /)" "200 no-retry html-other" "the front list is not moving" 187 188 # ---- first pass: the backfill 189 check "$(get events.json)" 200 "first events.json" 190 check "$(passes "$T/forged")" 1 "one collection pass after the first request" 191 lastpass "$T/forged" 192 check "$(ev 'import json,sys; print(" ".join(sorted(e["kind"] for e in json.load(sys.stdin)["events"])))')" "follow follow release star star" "backfill kinds: tag v1, two stars of the served project, two follows" 193 check "$(ev 'import json,sys; print(" ".join(e["source"] for e in json.load(sys.stdin)["events"] if e["kind"]=="release"))')" "repo.git:$TAGV1" "release source names the tag object in repo.git" 194 check "$(ev 'import json,sys; print(" ".join(e["source"] for e in json.load(sys.stdin)["events"] if e["kind"]=="star"))')" "social.log:6 social.log:14" "star sources are social.log lines" 195 for x in "$RP" "$RD" adhid omega-pearl; do 196 n=$(curl -s "$U/events.json?limit=200" | grep -c "$x"); m=$(curl -s "$U/feed" | grep -c "$x") 197 check "$n $m" "0 0" "$x appears in neither events.json nor the feed" 198 done 199 # change-triggered: unchanged requests read nothing 200 for _ in 1 2 3 4 5; do get "events.json?limit=200" > /dev/null; get feed > /dev/null; done 201 check "$(passes "$T/forged")" 1 "ten unchanged requests: no further pass" 202 # the log itself (not only the stream, which also filters at read time) holds no star of a project 203 # that is not served 204 check "$(awk -F'\t' '$3 == 11' "$T/data/events/log" | wc -l)" 2 "event log: two stars, both of the served project" 205 206 # ---- a landing: two commits on adfix main through ipl land 207 (cd "$T/w-adfix" && echo 3 > d.txt && git add d.txt && git commit -qm three && echo 4 > e.txt && git add e.txt && git commit -qm four) 208 MAIN1=$(git -C "$T/w-adfix" rev-parse HEAD) 209 printf 'receipt\n' > "$T/receipt"; printf 'verdict\n' > "$T/verdict" 210 "$IPLD/ipl" land "$T/store" adfix main "$MAIN1" "$T/w-adfix" "$T/receipt" "$T/verdict" land-1 "$T/key" > "$T/land.out" 2>> "$T/ipl.err" \ 211 && ok "ipl land adfix $(cut -c1-60 "$T/land.out")" || bad "ipl land: $(tail -2 "$T/ipl.err")" 212 LANDN=$(awk -F'\t' '$3 == "LAND" {n = $1} END {print n}' "$T/store/projects/adfix/chain.tsv") 213 LANDT=$(awk -F'\t' -v n="$LANDN" '$1 == n {print $2}' "$T/store/projects/adfix/chain.tsv") 214 python3 - "$T/fixture.json" "$MAIN1" <<'EOF' 215 import json, sys 216 f = json.load(open(sys.argv[1])); f["main1"] = sys.argv[2]; json.dump(f, open(sys.argv[1], "w"), indent=1) 217 EOF 218 # the forge follows the catalog (it changed with the landing) before the stream is read 219 for _ in $(seq 50); do get drakestapleton/adfix.json > /dev/null; grep -q "$MAIN1" "$T/b" && break; sleep 0.2; done 220 check "$(get events.json)" 200 "events.json after the landing" 221 check "$(passes "$T/forged")" 2 "one more pass after the landing" 222 L=$(lastpass "$T/forged"); echo "$L" 223 check "$(echo "$L" | sed -n 's/.*sources read \([0-9]*\),.*/\1/p')" 1 "that pass read one source (the landed project)" 224 check "$(echo "$L" | sed -n 's/.*events added \([0-9]*\)$/\1/p')" 1 "that pass added one event" 225 B=$(ev 'import json,sys; e=[e for e in json.load(sys.stdin)["events"] if e["kind"]=="branch_moved"]; print(len(e), e[-1]["source"], e[-1]["commits"], e[-1]["from"], e[-1]["time"], e[-1]["subject"]) if e else print(0)') 226 check "$B" "1 chain.tsv:$LANDN 2 $MAIN0 $LANDT 2 new commits on main" "branch_moved: chain record source, 2 commits, from the old head, the record's time" 227 228 # ---- a tag written into repo.git (the chain has no tag records): release, source repo.git: 229 git --git-dir="$T/store/projects/adfix/repo.git" tag -a v2 -m "release two" "$MAIN1" 230 TAGV2=$(git --git-dir="$T/store/projects/adfix/repo.git" rev-parse refs/tags/v2) 231 check "$(get events.json)" 200 "events.json after tag v2" 232 L=$(lastpass "$T/forged"); check "$(passes "$T/forged") $(echo "$L" | sed -n 's/.*events added \([0-9]*\)$/\1/p')" "3 1" "one pass, one event for tag v2" 233 check "$(ev 'import json,sys; print([e["source"] for e in json.load(sys.stdin)["events"] if e["kind"]=="release"][-1])')" "repo.git:$TAGV2" "release v2 source" 234 235 # ---- the catalog rewritten with the same lines (ipl catalog): no project read, nothing added 236 HEAD_BEFORE=$(ev 'import json,sys; print(json.load(sys.stdin)["head_seq"])') 237 "$IPLD/ipl" catalog "$T/store" > /dev/null 2>> "$T/ipl.err"; touch "$T/store/catalog.tsv" 238 check "$(get events.json)" 200 "events.json after the catalog was rewritten" 239 check "$(passes "$T/forged")" 3 "catalog rewritten with the same lines: no pass (store/evcol.om has no catalog stat)" 240 check "$(ev 'import json,sys; print(json.load(sys.stdin)["head_seq"])')" "$HEAD_BEFORE" "head_seq unchanged by the catalog rewrite" 241 # ---- a project added to the catalog: served at once, read by one pass, no event (it has no tag) 242 mkproj adnew rad:zAgentDoorStoreFixtureAdnew1 public notag || bad "adnew: $(tail -2 "$T/ipl.err")" 243 for _ in $(seq 50); do [ "$(get drakestapleton/adnew.json)" = 200 ] && break; sleep 0.2; done 244 check "$(get drakestapleton/adnew.json)" 200 "a project added to the catalog is served" 245 check "$(get events.json)" 200 "events.json after a project was added" 246 L=$(lastpass "$T/forged"); check "$(passes "$T/forged") $(echo "$L" | sed -n 's/.*events added \([0-9]*\)$/\1/p')" "4 0" "project added: one pass, no event" 247 check "$(ev 'import json,sys; print(json.load(sys.stdin)["head_seq"])')" "$HEAD_BEFORE" "head_seq unchanged by the added project" 248 249 # ---- kinds that this build never has 250 check "$(ev 'import json,sys; print(sorted({e["kind"] for e in json.load(sys.stdin)["events"]} - {"release","branch_moved","star","follow"}))')" "[]" "only release, branch_moved, star, follow" 251 check "$(ev 'import json,sys; d=json.load(sys.stdin)["events"]; print(all(d[i]["seq"]==i+1 for i in range(len(d))))')" "True" "seq 1..n with no gap" 252 check "$(ev 'import json,sys; print(sorted({e["repo"]["rid"][:4] for e in json.load(sys.stdin)["events"] if e["repo"]}))')" "['git:']" "event repo ids are the store identifiers (git:), as forge/repo/1" 253 check "$(curl -s "$U/events.json?limit=200" | grep -c -i -E 'radicle|rad:')" 0 "no Radicle words in events.json" 254 255 # ---- restart: seq stable, then continued 256 cp "$T/data/events/log" "$T/log.before" 257 curl -s "$U/events.json?limit=200" > "$T/ev.before" 258 stop; start "$T/forged" || { bad "restart"; exit 1; } 259 curl -s "$U/events.json?limit=200" > "$T/ev.after" 260 cmp -s "$T/ev.before" "$T/ev.after" && ok "events.json identical across a restart" || bad "events.json changed across a restart" 261 cmp -s "$T/log.before" "$T/data/events/log" && ok "event log unchanged by the restart pass" || bad "restart pass appended to the log" 262 (cd "$T/w-adfix" && echo 5 > f.txt && git add f.txt && git commit -qm five) 263 MAIN2=$(git -C "$T/w-adfix" rev-parse HEAD) 264 "$IPLD/ipl" land "$T/store" adfix main "$MAIN2" "$T/w-adfix" "$T/receipt" "$T/verdict" land-2 "$T/key" > /dev/null 2>> "$T/ipl.err" || bad "second landing" 265 for _ in $(seq 50); do get drakestapleton/adfix.json > /dev/null; grep -q "$MAIN2" "$T/b" && break; sleep 0.2; done 266 check "$(ev 'import json,sys; d=json.load(sys.stdin); print(d["head_seq"], d["events"][-1]["kind"], d["events"][-1]["commits"])')" "$((HEAD_BEFORE + 1)) branch_moved 1" "after the restart the next landing is seq head+1" 267 268 # ---- agents.json and the feed page 269 python3 "$H/agentdoor.py" agents "$PORT" docs/API.md "$T/forged.agents.tsv" "$T/fixture.json" > "$T/agents.log" 2>&1 \ 270 && ok "agentdoor.py agents: $(tail -1 "$T/agents.log")" || bad "agentdoor.py agents: $(grep -m5 FAIL "$T/agents.log" | tr '\n' ' ')" 271 NA=$(curl -s "$U/agents.json" | python3 -c 'import json,sys; d=json.load(sys.stdin); print(" ".join(sorted({w["what"] for w in d["not_available"] if "part is not composed" in w["why"]})))') 272 for p in "{owner}/{repo}/patches" "{owner}/{repo}/issues" status.json; do 273 case " $NA " in *" $p "*) ok "not_available lists $p (not composed)" ;; *) bad "not_available lacks $p" ;; esac 274 done 275 MV=$(curl -s "$U/agents.json" | python3 -c 'import json,sys; d=json.load(sys.stdin); print(" ".join(sorted({w["what"] for w in d["not_available"] if "moving to the new Interplane store" in w["why"] and "answers 503" in w["why"]})))') 276 for p in open.json "open/{project}.json" open/alarms.json trending.json salvage/ community/; do 277 case " $MV " in *" $p "*) ok "not_available lists $p as moving, answering 503" ;; *) bad "not_available lacks $p as moving (got: $MV)" ;; esac 278 done 279 curl -s "$U/agents.json" | python3 -c 'import json,sys; d=json.load(sys.stdin); sys.exit(any(k in r["path"] for r in d["routes"] for k in ("patches", "issues", "open", "salvage", "community", "trending")))' \ 280 && ok "routes list no patches, issues, open, salvage, community or trending address" || bad "routes list a composed-out address" 281 for p in agents.json feed; do 282 n=$(curl -s "$U/$p" | grep -c -i -E 'radicle|rad:|rad clone|\bRIDs?\b|\bCOBs?\b|delegate|heartwood') 283 check "$n" 0 "no Radicle words in $p" 284 done 285 check "$(curl -s "$U/feed" | grep -c 'changes proposed\|open builds shelf')" 0 "feed intro names only this build's kinds" 286 # every not_available address of a part this build does not compose, or of a moving part that does 287 # not answer 503, does not answer its listed schema (filled from the fixture, Accept JSON, both 288 # bases); every moving address that answers 503 answers it as moving; the node health pages answer 289 # 501 (server/nostat.om) 290 curl -s "$U/agents.json" | python3 -c 'import json,sys; [print(w["what"]) for w in json.load(sys.stdin)["not_available"] if "part is not composed" in w["why"] or "this address answers 404" in w["why"]]' > "$T/na.txt" 291 curl -s "$U/agents.json" | python3 -c 'import json,sys; [print(w["what"]) for w in json.load(sys.stdin)["not_available"] if "answers 503" in w["why"]]' > "$T/mv.txt" 292 check "$(grep -c . "$T/mv.txt")" 6 "six moving addresses answering 503 in not_available" 293 while read -r p; do 294 q=$(printf '%s' "$p" | sed -e "s|{project}|$OH|") 295 for b in / /forge/; do 296 r=$(mvpage "$q" "$b" application/json) 297 check "$r" "503 no-retry json-moving" "not_available [$b] $q answers 503 as moving" 298 done 299 done < "$T/mv.txt" 300 while read -r p; do 301 sch=$(awk -F'\t' -v p="$p" '$3 == p {print $5}' server/agents.tsv) 302 q=$(printf '%s' "$p" | sed -e "s|{owner}|drakestapleton|; s|{repo}|adfix|; s|{id}|$TAGV1|; s|{project}|$OH|; s|{order}|trending|") 303 for b in / /forge/; do 304 s=$(curl -s -o "$T/na.body" -w '%{http_code}' -H "X-Forge-Base: $b" -H 'Accept: application/json' "$U/$q") 305 g=$(python3 -c 'import json,sys 306 try: print(json.load(open(sys.argv[1])).get("schema") or "-") 307 except Exception: print("-")' "$T/na.body") 308 if [ "$s" = 200 ] && [ "$g" = "$sch" ]; then bad "not_available [$b] $q answers $s with its schema $sch" 309 else ok "not_available [$b] $q does not answer $sch ($s, schema $g)"; fi 310 done 311 done < "$T/na.txt" 312 check "$(get status) $(get status.json)" "501 501" "node health pages answer 501 in the store build" 313 stop 314 315 # ---- negative controls 316 neg() { # neg NAME SED AGENTS_TSV CHECK...: build the mutant, run, the named check must fail 317 local name=$1; shift 318 build "$T/m-$name" "$1" "$2" || { bad "control $name: build"; return; } 319 start "$T/m-$name" || { bad "control $name: start"; return; } 320 get events.json > /dev/null 321 shift 2 322 if "$@"; then bad "control $name: the check passed on the mutant"; else ok "control $name: caught"; fi 323 stop 324 } 325 rm -rf "$T/data/events" 326 c_star() { [ "$(awk -F'\t' '$3 == 11' "$T/data/events/log" | wc -l)" = 2 ]; } 327 neg star-any 's/^r = evridpub$/r = ulong 0/' "" c_star 328 rm -rf "$T/data/events" 329 # the mutant starts from an empty log after both landings: a branch move is only seen against a 330 # snapshot, so land once more under it first 331 c_src2() { (cd "$T/w-adfix" && echo 6 > g.txt && git add g.txt && git commit -qm six) && "$IPLD/ipl" land "$T/store" adfix main "$(git -C "$T/w-adfix" rev-parse HEAD)" "$T/w-adfix" "$T/receipt" "$T/verdict" "land-m$RANDOM" "$T/key" > /dev/null 2>&1; sleep 1; get drakestapleton/adfix.json > /dev/null; get events.json > /dev/null; [ "$(curl -s "$U/events.json?limit=200" | python3 -c 'import json,sys; print(sum(e["source"].startswith("chain.tsv:") for e in json.load(sys.stdin)["events"]))')" = 1 ]; } 332 neg no-chain 's/^rec = evchain i a$/rec = false/' "" c_src2 333 awk -F'\t' -v OFS='\t' '$3 == "{owner}/{repo}/patches" {$1 = "forge"} 1' server/agents.tsv > "$T/agents-bad.tsv" 334 c_agents() { python3 "$H/agentdoor.py" agents "$PORT" docs/API.md "$T/m-agents.agents.tsv" "$T/fixture.json" > "$T/agents-m.log" 2>&1; } 335 neg agents "" "$T/agents-bad.tsv" c_agents 336 c_moving() { mvall > "$T/mv-m.bad"; [ ! -s "$T/mv-m.bad" ]; } 337 neg moving-unmarked 's/^put fmvng 0 1$/put fmvng 0 0/' "" c_moving 338 339 echo "store/tests/agentdoor-store.sh: $PASS passed, $FAIL failed" 340 [ "$FAIL" = 0 ]