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/server/tests/agentdoor.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 / server / tests / agentdoor.sh`
320 lines ยท 20739 bytes Raw Blame History
1 #!/usr/bin/env bash
2 # ORACLE: host test driver (bash + curl + rad + git + server/tests/agentdoor.py), not product code.
3 # server/tests/agentdoor.sh: gates of the agent door (docs/AGENT-DOOR.md): agents.json,
4 # events.json (and events / feed with Accept JSON), the feed page, the event log.
5 # bash server/tests/agentdoor.sh (spark; FORGED_CPUS default 16-18, run under its pool lock;
6 # AGENTDOOR_PORT default 19984, private ports 19980..19989 only;
7 # AGENTDOOR_LIVE=0 skips the live-sized cost run; KEEP=1 keeps the temp dir)
8 # Everything is private to a temp dir: a throwaway Radicle profile (RAD_HOME) with three repositories:
9 # adfix public, on the test allow-list: commits, an annotated tag v1 (root refs/tags), patch one
10 # (two revisions, an accept review, a comment, merged), patch two (archived), an issue (a
11 # comment, closed); after the first pass two more commits move main
12 # adpriv private, not on the allow-list, with a patch and an issue: must never appear
13 # adden on the allow-list under the refused name omega-pearl, with a patch: must never appear
14 # a social log written by agentdoor.py (accounts, names, sessions, stars of public, private and refused
15 # repositories, favorites, a watch, follows, an unstar, a logout) and an open shelf list (held,
16 # withdrawn, and the refused RID z2ft64...). Only star (public repo), follow, brought and withdrawn
17 # may become events. The test forged is built from this tree (run.sh units) with its port, data dir,
18 # storage and allow-list rewritten; never 18480, ~/forge-data or ~/.radicle.
19 # Gates: every kind, every exclusion, schemas against docs/API.md, after= paging (no gap, no repeat,
20 # strictly increasing), limit cap, 400s, ETag 304, both bases, the feed HTML and its text form, every
21 # agents.json row answering its listed schema, table <-> docs/API.md both ways, change-triggered
22 # collection (no pass on unchanged requests), seq stability across a restart, a new event after it.
23 # Negative controls (each must FAIL the same checks): a broken agents.tsv row, a collector that leaks
24 # favorites, a log that numbers seq downwards. Then the measured costs, and (AGENTDOOR_LIVE=1) the same
25 # build on the live-sized data, read-only: real storage and allow-list, copies of the social log and
26 # the open list in the temp dir.
27 set -u
28 cd "$(dirname "$0")/../.."
29 ROOT=$(pwd)
30 H=$ROOT/server/tests
31 CORES=${FORGED_CPUS:-16-18}
32 PORT=${AGENTDOOR_PORT:-19984}
33 LIVE=${AGENTDOOR_LIVE:-1}
34 case $PORT in 1998[0-9]) ;; *) echo "REFUSED: use a private port in 19980..19989"; exit 2 ;; esac
35 OMC=$HOME/work/flux/omega-mv/seed/out/omc
36 T=$(mktemp -d /tmp/agentdoor.XXXXXX)
37 PASS=0; FAIL=0; PID=
38 ok() { PASS=$((PASS+1)); echo "PASS $*"; }
39 bad() { FAIL=$((FAIL+1)); echo "FAIL $*"; }
40 check() { if [ "$1" = "$2" ]; then ok "$3 ($1)"; else bad "$3: want $2, got $1"; fi; }
41 stop() { [ -n "$PID" ] && kill "$PID" 2> /dev/null; [ -n "$PID" ] && wait "$PID" 2> /dev/null; PID=; }
42 trap 'stop; [ -n "${KEEP:-}" ] || rm -rf "$T"' EXIT
43 if ss -ltn | grep -q "127.0.0.1:$PORT "; then echo "NOT_RUN: port $PORT busy"; exit 3; fi
44 U=http://127.0.0.1:$PORT
45
46 # ---- fixture storage
47 export RAD_HOME=$T/rad RAD_PASSPHRASE=
48 rad auth --alias adfix < /dev/null > /dev/null 2>&1 || { echo "rad auth failed"; exit 1; }
49 D1=$(rad self --did)
50 NID=${D1#did:key:}
51 G=(-c user.name=fixture -c user.email=fixture@t.invalid)
52 mkrepo() { # mkrepo NAME VISIBILITY: a working copy in $T/w-NAME with one commit, initialised; prints the RID
53 local w=$T/w-$1
54 git init -q -b main "$w" && echo "$1" > "$w/a.txt" && git -C "$w" add a.txt && git -C "$w" "${G[@]}" commit -qm init \
55 && (cd "$w" && rad init "--$2" --name "$1" --description "agent door fixture" --default-branch main --no-confirm --no-seed > "$T/init-$1.out" 2>&1) \
56 || { echo "rad init $1 failed: $(cat "$T/init-$1.out")"; exit 1; }
57 (cd "$w" && rad . | sed 's/^rad://')
58 }
59 patchref() { git --git-dir="$RAD_HOME/storage/$1" for-each-ref --format='%(refname)' "refs/namespaces/*/refs/cobs/xyz.radicle.$2/*" | sed 's|.*/||'; }
60 RF=$(mkrepo adfix public); RP=$(mkrepo adpriv private); RD=$(mkrepo adden public)
61 S=$RAD_HOME/storage/$RF
62 W=$T/w-adfix
63 set -e
64 (
65 cd "$W"
66 git checkout -q -b f1 && echo one > b.txt && git add b.txt && git "${G[@]}" commit -qm "change one"
67 git push -q -o patch.message="fixture change one" rad HEAD:refs/patches > "$T/p1.out" 2>&1
68 )
69 P1=$(patchref "$RF" patch)
70 (
71 cd "$W"
72 echo two >> b.txt && git add b.txt && git "${G[@]}" commit -qm "change one, revision two"
73 git push -q rad f1 > "$T/p1b.out" 2>&1
74 rad patch review "$P1" --accept -m "looks right" --no-announce > "$T/rv.out" 2>&1
75 rad patch comment "$P1" -m "a comment on change one" --no-announce > "$T/pc.out" 2>&1
76 git checkout -q main && git merge -q --ff-only f1 && git push -q rad main > "$T/merge.out" 2>&1
77 git checkout -q -b f2 && echo x > c.txt && git add c.txt && git "${G[@]}" commit -qm "change two"
78 git push -q -o patch.message="fixture change two" rad HEAD:refs/patches > "$T/p2.out" 2>&1
79 )
80 P2=$(patchref "$RF" patch | grep -v "$P1")
81 (
82 cd "$W"
83 rad patch archive "$P2" --no-announce > "$T/pa.out" 2>&1
84 rad issue open --title "fixture issue" --description "issue body" --no-announce > "$T/io.out" 2>&1
85 )
86 I1=$(patchref "$RF" issue)
87 (
88 cd "$W"
89 rad issue comment "$I1" --message "a comment on the issue" --no-announce > "$T/ic.out" 2>&1
90 rad issue state "$I1" --closed --no-announce > "$T/is.out" 2>&1
91 git checkout -q main && git tag -a v1 -m "release one" && git push -q rad v1 > "$T/tag.out" 2>&1
92 )
93 # the root (canonical) tag, as the node keeps it for a delegate's tag
94 git --git-dir="$S" update-ref refs/tags/v1 "$(git -C "$W" rev-parse v1)"
95 TAGV1=$(git --git-dir="$S" rev-parse refs/tags/v1)
96 MAIN0=$(git --git-dir="$S" rev-parse refs/heads/main)
97 # the private and the refused repository: a patch and an issue each
98 for r in adpriv adden; do
99 (cd "$T/w-$r" && git checkout -q -b f && echo p > p.txt && git add p.txt && git "${G[@]}" commit -qm "hidden change" \
100 && git push -q -o patch.message="hidden change $r" rad HEAD:refs/patches > "$T/h-$r.out" 2>&1 \
101 && rad issue open --title "hidden issue $r" --description x --no-announce > "$T/hi-$r.out" 2>&1)
102 done
103 set +e
104 check "$(git --git-dir="$S" cat-file -t "$TAGV1")" tag "fixture: v1 is an annotated tag object"
105 check "$(patchref "$RF" patch | wc -l)" 2 "fixture: two patches in adfix"
106 check "$(rad patch list --repo "rad:$RF" --merged 2> /dev/null | grep -c "${P1:0:7}")" 1 "fixture: patch one merged (rad patch list oracle)"
107
108 # ---- allow-list, data dir, social log, open shelf
109 printf '# test allow-list\n\n| repo | RID | default branch |\n|---|---|---|\n| adfix | rad:%s | main |\n| omega-pearl | rad:%s | main |\n' "$RF" "$RD" > "$T/rids.md"
110 mkdir -p "$T/data/open" "$T/data/open/p" "$T/social"
111 OWN=`z6MkfZDue1TbaNFi3ZzcD9uiTeduPLC52ucdFVuLKZwexxhK`
112 D2=did:key:`z6MkotherFixtureAccountKeyAbCdEfGhJkLmNpQrStUvWxYz`
113 OH=`z3AgentDoorHeadFixtureProject` OW=z4AgentDoorWithdrawnFixture ODN=`z2ft64NFLsKzWttCXw6NWNbRQLggQ`
114 printf '%s\theld\t%s\t2026-11-10\t10\tshelf-a\tfixture project a\tnote a\n%s\twithdrawn\t%s\t2026-11-11\t0\tshelf-b\t\t\n%s\theld\t%s\t2026-11-09\t10\tpearl\tthe refused one\t\n' \
115 "$OH" "$D2" "$OW" "$D2" "$ODN" "$D2" > "$T/data/open/list.tsv"
116 # the files the other agents.json rows read (as the open intake and research-build write them)
117 printf 'H\t%s\t2026-11-10\nC\t%s\t2026-11-10\tFixture\tinit\nT\tb\tREADME.md\nR\t# shelf-a\n' "$MAIN0" "${MAIN0:0:7}" > "$T/data/open/p/$OH.txt"
118 printf '{"schema":"interplane/open-alarms/1","alarms":[]}\n' > "$T/data/open/alarms.json"
119 mkdir -p "$T/data/research/gen/public.fixture1/w" && ln -s gen/public.fixture1 "$T/data/research/current"
120 printf '{"schema":"interplane/research/1","works":[]}\n' > "$T/data/research/gen/public.fixture1/index.json"
121 printf '{"schema":"interplane/research-work/1","work":{"slug":"fixture-work"}}\n' > "$T/data/research/gen/public.fixture1/w/fixture-work.json"
122 cat > "$T/fixture.json" < "$out.src.om" || return 1
133 local s=(-e "s/18480/$PORT/g" -e "s|^text tfdata \".*\"|text tfdata \"$3\"|"
134 -e "s|^text tfstore \".*\"|text tfstore \"${4:-$RAD_HOME/storage/}\"|" -e "s|^text tfrids \".*\"|text tfrids \"${5:-$T/rids.md}\"|")
135 [ -n "$extra" ] && s+=(-e "$extra")
136 sed "${s[@]}" "$out.src.om" > "$out.om"
137 taskset -c "$CORES" nice -n 10 "$OMC" < "$out.om" > "$out" 2> "$out.err" || { echo "BUILD FAILED $out: $(cat "$out.err")"; return 1; }
138 chmod 755 "$out"
139 }
140 start() { # start BIN SOCIALDIR
141 FORGE_SOCIAL_DIR=$2 taskset -c "$CORES" nice -n 10 "$1" 2>> "$1.log" &
142 PID=$!
143 for _ in $(seq 100); do curl -s -o /dev/null "$U/explore" -H 'X-Forge-Base: /' && return 0; sleep 0.1; done
144 return 1
145 }
146 passes() { grep -c '^events: pass ' "$1.log"; }
147 get() { curl -s -o "$T/b" -D "$T/h" -w '%{http_code}' -H "X-Forge-Base: ${2:-/}" "$U/$1"; }
148
149 build "$T/forged" "" "$T/data/" || { bad "test build"; exit 1; }
150 ok "test build $(sha256sum < "$T/forged" | cut -c1-16)"
151 grep -q '^fn evcollect' "$T/forged.om" && ok "door/ composed" || bad "door/ not composed (seam used)"
152 start "$T/forged" "$T/social/" || { bad "test forged did not start: $(tail -3 "$T/forged.log")"; exit 1; }
153
154 # first pass: the backfill of the fixture
155 check "$(get events.json)" 200 "first events.json"
156 check "$(passes "$T/forged")" 1 "one collection pass after the first request"
157 grep '^events: pass ' "$T/forged.log" | tail -1
158 # change-triggered: unchanged requests read nothing
159 for _ in 1 2 3 4 5; do get "events.json?limit=200" > /dev/null; get feed > /dev/null; done
160 check "$(passes "$T/forged")" 1 "ten unchanged requests: no further pass (fingerprints only)"
161 # main moves by two commits: the next request reads that repository alone
162 (cd "$W" && git checkout -q main && echo 3 > d.txt && git add d.txt && git "${G[@]}" commit -qm three \
163 && echo 4 > e.txt && git add e.txt && git "${G[@]}" commit -qm four && git push -q rad main > "$T/m2.out" 2>&1)
164 MAIN1=$(git --git-dir="$S" rev-parse refs/heads/main)
165 python3 - "$T/fixture.json" "$MAIN1" <<'EOF'
166 import json, sys
167 f = json.load(open(sys.argv[1])); f["main1"] = sys.argv[2]; json.dump(f, open(sys.argv[1], "w"), indent=1)
168 EOF
169 check "$(get events.json)" 200 "events.json after main moved"
170 check "$(passes "$T/forged")" 2 "one more pass after main moved"
171 L=$(grep '^events: pass ' "$T/forged.log" | tail -1); echo "$L"
172 check "$(echo "$L" | sed -n 's/.*sources read \([0-9]*\),.*/\1/p')" 1 "that pass read one source (the moved repository)"
173 check "$(echo "$L" | sed -n 's/.*events added \([0-9]*\)$/\1/p')" 1 "that pass added one event (branch_moved)"
174
175 # ---- the checks of agentdoor.py, both bases
176 python3 "$H/agentdoor.py" check "$PORT" docs/API.md "$ROOT/.build/agents.tsv" "$T/fixture.json" > "$T/check.log" 2>&1
177 rc=$?; grep '^FAIL' "$T/check.log" | head -30; tail -1 "$T/check.log"
178 check "$rc" 0 "agentdoor.py check (both bases): $(tail -1 "$T/check.log")"
179 for b in / /forge/; do
180 python3 "$H/agentdoor.py" walk "$PORT" "$b" 3 "$T/walk3-${b//\//_}.jsonl" > "$T/walk.log" 2>&1
181 check "$?" 0 "walk $b with limit 3: no gap, no repeat, increasing ($(tail -1 "$T/walk.log"))"
182 done
183 python3 "$H/agentdoor.py" walk "$PORT" / 200 "$T/walk200.jsonl" > /dev/null 2>&1
184 cmp -s "$T/walk3-_.jsonl" "$T/walk200.jsonl" && ok "pages of 3 and of 200 give the same events" || bad "pages of 3 and of 200 differ"
185 check "$(wc -l < "$T/walk200.jsonl")" 18 "18 events"
186
187 # ---- restart: the same seq numbers, then a new event continues the stream
188 cp "$T/data/events/log" "$T/log.before"
189 stop
190 start "$T/forged" "$T/social/" || bad "restart"
191 python3 "$H/agentdoor.py" walk "$PORT" / 200 "$T/walk-restart.jsonl" > /dev/null 2>&1
192 cmp -s "$T/walk200.jsonl" "$T/walk-restart.jsonl" && ok "after a restart every event has the same seq and content" || bad "events differ after restart"
193 cmp -s "$T/log.before" "$T/data/events/log" && ok "the restart pass appended nothing (log byte-identical)" || bad "restart changed the log"
194 L=$(grep '^events: pass ' "$T/forged.log" | tail -1); echo "restart $L"
195 (cd "$W" && rad issue comment "$I1" --message "after the restart" --no-announce > "$T/ic2.out" 2>&1)
196 python3 "$H/agentdoor.py" walk "$PORT" / 200 "$T/walk-new.jsonl" > /dev/null 2>&1
197 check "$(wc -l < "$T/walk-new.jsonl")" 19 "a comment after the restart is event 19"
198 check "$(head -18 "$T/walk-new.jsonl" | cmp -s - "$T/walk200.jsonl" && echo same)" same "events 1..18 unchanged"
199 check "$(tail -1 "$T/walk-new.jsonl" | python3 -c 'import json,sys; e=json.loads(sys.stdin.read()); print(e["seq"], e["kind"], e["repo"]["name"])')" "19 comment adfix" "event 19"
200 # the chain: an independent check of every line's prev
201 python3 - "$T/data/events/log" <<'EOF' && ok "events/log hash chain verified independently" || bad "events/log chain"
202 import hashlib, sys
203 prev = "0" * 64
204 for i, ln in enumerate(open(sys.argv[1], "rb").read().split(b"\n")[:-1]):
205 f = ln.split(b"\t")
206 assert len(f) == 11 and int(f[0]) == i + 1 and f[10].decode() == prev, (i, f[:3])
207 prev = hashlib.sha256(ln).hexdigest()
208 EOF
209 # a changed line switches the stream off (fail closed)
210 stop
211 cp "$T/data/events/log" "$T/log.good"
212 sed -i '3s/^3\t/3\t9/' "$T/data/events/log"
213 start "$T/forged" "$T/social/" || bad "start on a tampered log"
214 check "$(get events.json)" 503 "tampered log: events.json 503"
215 check "$(grep -c 'EVENTS-LOG TAMPER' "$T/forged.log")" 1 "tampered log: one TAMPER line on stderr"
216 stop
217 cp "$T/log.good" "$T/data/events/log"
218
219 # ---- measured costs (fixture): request without change, 20 samples
220 start "$T/forged" "$T/social/" || bad "restart for costs"
221 get events.json > /dev/null
222 for _ in $(seq 20); do curl -s -o /dev/null -w '%{time_total}\n' -H 'X-Forge-Base: /' "$U/events.json?limit=200"; done > "$T/cost-fixture.txt"
223 echo "COST fixture events.json?limit=200 (19 events) seconds: $(sort -n "$T/cost-fixture.txt" | tr '\n' ' ')"
224 grep '^events: pass ' "$T/forged.log" | sed 's/^/COST fixture /'
225 stop
226
227 # ---- negative controls. Each mutant runs on a fresh data dir (its own first pass), so the stream
228 # has no branch_moved there; the twin (no mutation) runs the same way, and a control counts only when
229 # the mutant shows its own failure line and the twin does not.
230 negrun() { # negrun NAME SED: build, start, run check and walk into $T/neg-NAME
231 local d=$T/neg-$1
232 rm -rf "$d"; mkdir -p "$d/data/open" "$d/social"
233 cp "$T/data/open/list.tsv" "$d/data/open/"
234 cp "$T/social/social.log" "$T/social/social.head" "$d/social/"
235 build "$d/forged" "$2" "$d/data/" || return 1
236 start "$d/forged" "$d/social/" || return 1
237 python3 "$H/agentdoor.py" check "$PORT" docs/API.md "$ROOT/.build/agents.tsv" "$T/fixture.json" > "$d/check.log" 2>&1
238 python3 "$H/agentdoor.py" walk "$PORT" / 3 "$d/walk.jsonl" > "$d/walk.log" 2>&1
239 stop
240 cat "$d/check.log" "$d/walk.log" | grep '^FAIL' > "$d/fails.txt"
241 return 0
242 }
243 negrun twin 's/^x$/x/' || bad "negative control twin did not run"
244 neg() { # neg NAME SED MARKER PATTERN: MARKER proves the mutation is in the source; PATTERN is its failure
245 negrun "$1" "$2" || { bad "negative control $1 did not build or start"; return; }
246 grep -qF -- "$3" "$T/neg-$1/forged.om" || { bad "negative control $1: mutation not applied"; return; }
247 if grep -qE -- "$4" "$T/neg-twin/fails.txt"; then
248 bad "negative control $1: the twin already fails with /$4/"
249 elif grep -qE -- "$4" "$T/neg-$1/fails.txt"; then
250 ok "negative control $1 fails: $(grep -m1 -E -- "$4" "$T/neg-$1/fails.txt" | cut -c1-200)"
251 else
252 bad "negative control $1: no failure /$4/ ($(wc -l < "$T/neg-$1/fails.txt") other failures)"
253 fi
254 }
255 # (1) a broken agents.tsv row: the blob row lists forge/tree/1
256 neg broken-row 's|\\tforge/blob/1\\tnone\\t|\\tforge/tree/1\\tnone\\t|' '{path}\taccept\tforge/tree/1' 'blob/main/a.txt answers forge/tree/1'
257 # (2) the collector leaks favorites (a fav line read as a star)
258 neg leak-fav '/^fn evsocln/,/^fn evsstar/s/^if eq a 1$/if or eq a 1 eq a 3/' 'if or eq a 1 eq a 3' 'social line 7 \(fav .* is not an event'
259 # (3) seq numbered downwards
260 neg seq-down 's/^evlnum add get gevn 0 1$/evlnum sub `1000000` get gevn 0/' 'evlnum sub `1000000` get gevn 0' 'not increasing'
261
262 # ---- the seam (a build without door/: as a store-reading build composes it): 501, consistently
263 SEAMD=$T/seam
264 mkdir -p "$SEAMD/data" "$SEAMD/social"
265 { printf 'om2\n'; cat $(sh run.sh units | sed 's|^door/.*\.om$||' | awk 'NF' | awk '/server\/agents.om/{print "server/nodoor.om"} {print}'); } \
266 | sed -e "s/18480/$PORT/g" -e "s|^text tfdata \".*\"|text tfdata \"$SEAMD/data/\"|" \
267 -e "s|^text tfstore \".*\"|text tfstore \"$RAD_HOME/storage/\"|" -e "s|^text tfrids \".*\"|text tfrids \"$T/rids.md\"|" > "$SEAMD/forged.om"
268 if taskset -c "$CORES" nice -n 10 "$OMC" < "$SEAMD/forged.om" > "$SEAMD/forged" 2> "$SEAMD/forged.err"; then
269 chmod 755 "$SEAMD/forged"
270 start "$SEAMD/forged" "$SEAMD/social/" || bad "seam build did not start"
271 for b in / /forge/; do
272 check "$(get events.json "$b")" 501 "[$b] seam: events.json 501"
273 check "$(python3 -c 'import json,sys; d=json.load(open(sys.argv[1])); print(d["schema"], d["status"])' "$T/b")" "forge/error/1 501" "[$b] seam: forge/error/1"
274 check "$(get feed "$b")" 501 "[$b] seam: feed 501"
275 check "$(curl -s -o /dev/null -w '%{http_code}' -H "X-Forge-Base: $b" -H 'Accept: application/json' "$U/events")" 501 "[$b] seam: events (JSON) 501"
276 get agents.json "$b" > /dev/null
277 check "$(python3 -c 'import json,sys; d=json.load(open(sys.argv[1])); print(d["events"], any(r["schema"]=="interplane/events/1" for r in d["routes"]), sum("events" in r["what"] or "feed" in r["what"] for r in d["not_available"]))' "$T/b")" "None False 3" "[$b] seam: agents.json lists the stream under not_available"
278 get explore "$b" > /dev/null
279 grep -q '>Feed' "$T/b" && bad "[$b] seam: Feed entry shown" || ok "[$b] seam: no Feed entry in the forge row"
280 done
281 stop
282 else
283 bad "seam build: $(cat "$SEAMD/forged.err")"
284 fi
285
286 # ---- live-sized data, read-only: real storage and allow-list; copies of the social log and the open list
287 if [ "$LIVE" = 1 ]; then
288 LD=$T/live
289 mkdir -p "$LD/data/open" "$LD/social"
290 cp "$HOME/forge-data/social.log" "$HOME/forge-data/social.head" "$LD/social/"
291 cp "$HOME/forge-data/open/list.tsv" "$LD/data/open/"
292 build "$LD/forged" "" "$LD/data/" "$HOME/.radicle/storage/" "$HOME/handoffs/radicle/RIDS.md" || bad "live-sized build"
293 start "$LD/forged" "$LD/social/" || bad "live-sized start"
294 t1=$(curl -s -o "$LD/first.json" -w '%{time_total}' -H 'X-Forge-Base: /' "$U/events.json?limit=200")
295 echo "COST live first request (backfill pass included) seconds: $t1"
296 grep '^events: pass ' "$LD/forged.log" | sed 's/^/COST live backfill /'
297 for _ in $(seq 20); do curl -s -o /dev/null -w '%{time_total}\n' -H 'X-Forge-Base: /' "$U/events.json?limit=200"; done > "$LD/cost.txt"
298 echo "COST live events.json?limit=200, unchanged, seconds: $(sort -n "$LD/cost.txt" | tr '\n' ' ')"
299 for _ in $(seq 5); do curl -s -o /dev/null -w '%{time_total}\n' -H 'X-Forge-Base: /' "$U/feed"; done > "$LD/costf.txt"
300 echo "COST live feed, unchanged, seconds: $(sort -n "$LD/costf.txt" | tr '\n' ' ')"
301 check "$(passes "$LD/forged")" 1 "live-sized: one pass, none on the 25 unchanged requests"
302 stop
303 start "$LD/forged" "$LD/social/" || bad "live-sized restart"
304 t2=$(curl -s -o /dev/null -w '%{time_total}' -H 'X-Forge-Base: /' "$U/events.json?limit=200")
305 echo "COST live first request after a restart (every repository read again, nothing new) seconds: $t2"
306 grep '^events: pass ' "$LD/forged.log" | tail -1 | sed 's/^/COST live restart /'
307 echo "COST live events: $(wc -l < "$LD/data/events/log") lines, $(wc -c < "$LD/data/events/log") bytes; snapshots $(du -sb "$LD/data/events/r" | cut -f1) bytes"
308 python3 "$H/agentdoor.py" walk "$PORT" / 200 "$LD/walk.jsonl" > "$LD/walk.log" 2>&1
309 check "$?" 0 "live-sized: walk with no gap or repeat ($(tail -1 "$LD/walk.log"))"
310 python3 - "$LD/walk.jsonl" <<'EOF'
311 import collections, json, sys
312 c = collections.Counter(json.loads(l)["kind"] for l in open(sys.argv[1]))
313 print("COST live kinds: " + ", ".join("%s %d" % kv for kv in sorted(c.items())))
314 EOF
315 grep -c '^events: COB not loaded' "$LD/forged.log" | sed 's/^/live COBs not loaded: /'
316 stop
317 fi
318
319 echo "agentdoor.sh: $PASS passed, $FAIL failed"
320 [ "$FAIL" = 0 ]