scorpiox-bot-plugin-crontab
←run.shbash
448 lines · 19 KBHEADBlameDownload
1#!/bin/sh
2# tests/run.sh — 60+ offline checks for plugin_crontab across all 3 modes.
3#
4# Everything runs against ./plugin_crontab (native build) with CRONTAB_FILE
5# pointed at fixtures, so no real crontab is read and no command is executed.
6# If a musl static build or a Windows PE (plugin_crontab.exe) is present they
7# are checked too. The whole git history is finally audited for secrets, PATs
8# and internal network addresses.
9#
10# Exit code 0 = everything passed.
11
12set -u
13
14ROOT=$(cd "$(dirname "$0")/.." && pwd)
15cd "$ROOT" || exit 1
16
17BIN=./plugin_crontab
18PASS=0
19FAIL=0
20
21if [ -t 1 ]; then
22 C_OK=$(printf '\033[32m'); C_BAD=$(printf '\033[31m'); C_B=$(printf '\033[1m'); C_0=$(printf '\033[0m')
23else
24 C_OK=; C_BAD=; C_B=; C_0=
25fi
26pass() { PASS=$((PASS + 1)); printf ' %sok%s %s\n' "$C_OK" "$C_0" "$1"; }
27fail() { FAIL=$((FAIL + 1)); printf ' %sFAIL%s %s\n' "$C_BAD" "$C_0" "$1"; }
28
29check() { # check <desc> <expected-substring> <actual>
30 if printf '%s' "$3" | grep -F -q -- "$2"; then pass "$1"; else
31 fail "$1 (want: $2)"; printf ' got: %s\n' "$(printf '%s' "$3" | head -c 400)"
32 fi
33}
34
35check_not() { # check_not <desc> <forbidden-substring> <actual>
36 if printf '%s' "$3" | grep -F -q -- "$2"; then
37 fail "$1 (must NOT contain: $2)"; else pass "$1"
38 fi
39}
40
41section() { printf '\n%s== %s ==%s\n' "$C_B" "$1" "$C_0"; }
42
43body() { # strip CGI headers if present, drop CRs, keep the payload
44 printf '%s\n' "$1" | tr -d '\r' | awk '
45 BEGIN { inhdr = 0 }
46 NR == 1 && ($0 ~ /^(Content-Type|Status|Cache-Control|X-Content-Type-Options):/) { inhdr = 1; next }
47 inhdr && $0 == "" { inhdr = 0; next }
48 inhdr { next }
49 { print }
50 '
51}
52
53json_ok() { # json_ok <desc> <json> [python-expression]
54 expr=${3:-True}
55 if printf '%s' "$2" | python3 -c "import json,sys; d=json.load(sys.stdin); sys.exit(0 if ($expr) else 1)" 2>/dev/null; then
56 pass "$1"
57 else
58 fail "$1 (invalid JSON or assertion failed)"; printf ' got: %s\n' "$(printf '%s' "$2" | head -c 400)"
59 fi
60}
61
62explain() { # explain <expr> -> JSON body
63 enc=$(python3 -c 'import urllib.parse,sys; print(urllib.parse.quote(sys.argv[1]))' "$1")
64 body "$(QUERY_STRING="action=explain&expr=$enc" $BIN)"
65}
66
67# ---------------------------------------------------------------- setup
68section "build"
69if [ ! -x "$BIN" ]; then
70 echo " building native binary..."
71 cc -O2 -std=c99 -Wall -Wextra -Wno-overlength-strings -o "$BIN" src/plugin_crontab.c \
72 || { echo " build failed"; exit 1; }
73fi
74[ -x "$BIN" ] && pass "native binary exists and is executable" || fail "native binary missing"
75
76WORK=$(mktemp -d 2>/dev/null || echo /tmp/pc_$$)
77mkdir -p "$WORK"
78
79FIX="$WORK/crontab.txt"
80cat > "$FIX" <<'FIXEOF'
81# a comment line
82SHELL=/bin/sh
83PATH=/usr/bin:/bin
84*/5 * * * * /usr/bin/backup.sh --flag
850 3 * * * /usr/bin/logrotate
86@hourly /usr/local/bin/ping
8730 2 * * 0 /usr/local/bin/weekly
880 0 1 * * /usr/local/bin/monthly-report
89@reboot /usr/local/bin/boot-task
900 9 * * mon-fri /usr/local/bin/standup
91FIXEOF
92
93SYS="$WORK/etc-crontab.txt"
94cat > "$SYS" <<'SYSEOF'
95# sx:system
96SHELL=/bin/sh
9717 * * * * root cd / && run-parts --report /etc/cron.hourly
9825 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
99SYSEOF
100
101EMPTY="$WORK/empty.txt"
102: > "$EMPTY"
103
104BAD="$WORK/bad.txt"
105cat > "$BAD" <<'BADEOF'
10661 * * * * /usr/bin/never
107foo bar baz qux quux
108* * * /usr/bin/short
1090 0 * * 9 /usr/bin/bad-dow
110BADEOF
111
112# ---------------------------------------------------------------- meta
113section "mode 1 — discovery metadata"
114M=$(body "$($BIN --meta)")
115json_ok "--meta is valid JSON" "$M" "d['name']=='crontab'"
116check "--meta name is one word" '"name":"crontab"' "$M"
117check "--meta desc is 9 chars" '"desc":"Cron jobs"' "$M"
118M2=$(body "$(SX_PLUGIN_META=1 $BIN)")
119check "SX_PLUGIN_META env var works" '"name":"crontab"' "$M2"
120check_not "--meta has no extra keys" '"title"' "$M"
121V=$($BIN --version)
122check "--version prints the version" '1.0.1' "$V"
123H=$($BIN --help)
124check "--help mentions jobs action" 'action=jobs' "$H"
125check "--help mentions explain action" 'action=explain' "$H"
126check "--help states read-only" 'read-only' "$H"
127
128# ---------------------------------------------------------------- explain
129section "mode 2a — cron expression playground"
130R=$(explain '*/15 9-17 * * 1-5')
131json_ok "explain */15 9-17 * * 1-5 parses" "$R" "d['valid'] is True"
132check "explain reports every 15 minutes" 'Every 15 minutes' "$R"
133check "explain names the weekday range" 'Monday' "$R"
134json_ok "explain returns exactly 5 next runs" "$R" "len(d['next'])==5"
135json_ok "next runs are strictly increasing" "$R" "all(d['next'][i]['in_seconds'] < d['next'][i+1]['in_seconds'] for i in range(4))"
136json_ok "run timestamps carry UTC and local" "$R" "'utc' in d['next'][0] and 'local' in d['next'][0]"
137json_ok "run timestamps end in Z" "$R" "d['next'][0]['utc'].endswith('Z')"
138json_ok "fields are echoed back" "$R" "d['fields']['minute']=='*/15'"
139
140R=$(explain '@daily')
141json_ok "@daily parses" "$R" "d['valid'] is True and d['keyword']=='@daily'"
142check "@daily reads as midnight" 'Every day at midnight' "$R"
143json_ok "@daily next run is at 00:00 UTC" "$R" "d['next'][0]['utc'].endswith('T00:00:00Z')"
144json_ok "@daily fires once per day" "$R" "d['next'][1]['in_seconds'] - d['next'][0]['in_seconds'] == 86400"
145
146R=$(explain '@hourly')
147json_ok "@hourly parses" "$R" "d['valid'] is True"
148json_ok "@hourly fires hourly" "$R" "d['next'][1]['in_seconds'] - d['next'][0]['in_seconds'] == 3600"
149
150R=$(explain '@weekly')
151json_ok "@weekly parses" "$R" "d['valid'] is True"
152check "@weekly reads as Sunday" 'Every Sunday at midnight' "$R"
153json_ok "@weekly next run is a Sunday" "$R" "d['next'][0]['utc'][:10] >= '2026-01-01'"
154
155R=$(explain '@monthly')
156json_ok "@monthly parses" "$R" "d['valid'] is True"
157json_ok "@monthly fires on the 1st" "$R" "d['next'][0]['utc'][8:10] == '01'"
158
159R=$(explain '@yearly')
160json_ok "@yearly parses" "$R" "d['valid'] is True"
161json_ok "@yearly fires on 1 January" "$R" "d['next'][0]['utc'][5:10] == '01-01'"
162
163R=$(explain '@annually')
164check "@annually is accepted as an alias" '"valid":true' "$R"
165
166R=$(explain '@midnight')
167check "@midnight is accepted" '"valid":true' "$R"
168
169R=$(explain '@reboot')
170json_ok "@reboot parses but has no clock times" "$R" "d['valid'] is True and d['boot_only'] is True and d['next']==[]"
171check "@reboot reads as a boot trigger" 'system starts' "$R"
172
173R=$(explain '*/15 * * * *')
174check "plain */15 explains as every 15 minutes" 'Every 15 minutes' "$R"
175
176R=$(explain '1-5/2 * * * *')
177json_ok "range with step parses" "$R" "d['valid'] is True"
178
179R=$(explain '0,30 * * * *')
180json_ok "comma list parses" "$R" "d['valid'] is True"
181check "comma list of two minutes lists both" '0 and 30' "$R"
182
183R=$(explain '0 0 1 1 *')
184check "yearly 5-field form names January" 'January' "$R"
185json_ok "yearly 5-field form fires only in January" "$R" "d['next'][0]['utc'][5:7] == '01'"
186
187R=$(explain '0 0 * * 7')
188json_ok "day-of-week 7 equals Sunday" "$R" "d['valid'] is True"
189check "day-of-week 7 reads as Sunday" 'Sunday' "$R"
190
191R=$(explain '0 0 * * sun')
192check "day-of-week names are accepted" 'Sunday' "$R"
193
194R=$(explain '0 0 * JAN-MAR *')
195json_ok "month name ranges parse" "$R" "d['valid'] is True"
196check "month name range lists the months" 'February' "$R"
197
198R=$(explain '0 0 29 2 *')
199json_ok "29 February schedule parses" "$R" "d['valid'] is True"
200json_ok "29 February finds a leap year within four years" "$R" "len(d['next'])>=1 and d['next'][0]['utc'][5:10]=='02-29'"
201
202R=$(explain '* * * * *')
203check "every minute reads plainly" 'Every minute' "$R"
204
205R=$(explain '61 * * * *')
206json_ok "minute 61 is rejected" "$R" "d['valid'] is False"
207check "minute 61 error names the range" '0-59' "$R"
208
209R=$(explain '0 24 * * *')
210json_ok "hour 24 is rejected" "$R" "d['valid'] is False"
211check "hour 24 error names the range" '0-23' "$R"
212
213R=$(explain '0 0 32 * *')
214json_ok "day 32 is rejected" "$R" "d['valid'] is False"
215
216R=$(explain '0 0 * 13 *')
217json_ok "month 13 is rejected" "$R" "d['valid'] is False"
218
219R=$(explain '0 0 * * 9')
220json_ok "day-of-week 9 is rejected" "$R" "d['valid'] is False"
221
222R=$(explain '* * *')
223json_ok "three fields are rejected" "$R" "d['valid'] is False"
224check "three-field error says 5 fields" 'expected 5 fields' "$R"
225
226R=$(explain '* * * * * *')
227json_ok "six fields are rejected" "$R" "d['valid'] is False"
228
229R=$(explain 'abc * * * *')
230json_ok "non-numeric minute is rejected" "$R" "d['valid'] is False"
231
232R=$(explain '*/0 * * * *')
233json_ok "zero step is rejected" "$R" "d['valid'] is False"
234
235R=$(explain '5-1 * * * *')
236json_ok "descending range is rejected" "$R" "d['valid'] is False"
237
238R=$(explain '@sometimes')
239json_ok "unknown keyword is rejected" "$R" "d['valid'] is False"
240check "unknown keyword error is explicit" 'unknown @keyword' "$R"
241
242R=$(body "$(QUERY_STRING='action=explain' $BIN)")
243json_ok "missing expr parameter fails cleanly" "$R" "d['ok'] is False"
244check "missing expr names the parameter" 'missing expr' "$R"
245
246R=$(explain '0 12 * * *')
247json_ok "noon schedule returns UTC times" "$R" "d['next'][0]['utc'].endswith('T12:00:00Z')"
248json_ok "noon schedule carries a local string" "$R" "len(d['next'][0]['local']) == 16"
249
250# URL-encoded spaces and plus signs survive
251R=$(body "$(QUERY_STRING='action=explain&expr=0+1+*+*+*' $BIN)")
252json_ok "plus-sign space encoding works" "$R" "d['valid'] is True and d['fields']['hour']=='1'"
253
254# ---------------------------------------------------------------- jobs
255section "mode 2b — local job listing"
256J=$(body "$(CRONTAB_FILE="$FIX" QUERY_STRING='action=jobs' $BIN)")
257json_ok "jobs returns valid JSON" "$J" "d['ok'] is True"
258json_ok "jobs counts only real schedule lines" "$J" "d['count']==7"
259check "jobs source is the fixture" '"fixture"' "$J"
260check_not "environment assignments are skipped" 'SHELL=/bin/sh' "$J"
261json_ok "every fixture job parsed" "$J" "all(j['valid'] for j in d['jobs'])"
262json_ok "each job carries 5 next runs" "$J" "all(len(j['next'])==5 for j in d['jobs'] if j['expr']!='@reboot')"
263json_ok "@reboot job has no runs" "$J" "any(j['expr']=='@reboot' and j['next']==[] for j in d['jobs'])"
264json_ok "comments never become jobs" "$J" "not any('comment' in j['command'] for j in d['jobs'])"
265json_ok "commands are preserved verbatim" "$J" "any(j['command']=='/usr/bin/backup.sh --flag' for j in d['jobs'])"
266json_ok "descriptions are human readable" "$J" "all(len(j['description'])>3 for j in d['jobs'])"
267json_ok "kind is marked cron" "$J" "all(j['kind']=='cron' for j in d['jobs'])"
268json_ok "now timestamps are present" "$J" "'now_utc' in d and 'now_local' in d"
269json_ok "truncated flag is false" "$J" "d['truncated'] is False"
270
271S=$(body "$(CRONTAB_FILE="$SYS" QUERY_STRING='action=jobs' $BIN)")
272json_ok "system crontab format parses" "$S" "d['count']==2"
273json_ok "system format extracts the run-as user" "$S" "all(j['user']=='root' for j in d['jobs'])"
274json_ok "system format keeps the command" "$S" "any('run-parts' in j['command'] for j in d['jobs'])"
275json_ok "system hourly job reads as minute 17" "$S" "any('minute 17' in j['description'] for j in d['jobs'])"
276
277E=$(body "$(CRONTAB_FILE="$EMPTY" QUERY_STRING='action=jobs' $BIN)")
278json_ok "empty fixture returns zero jobs" "$E" "d['count']==0"
279json_ok "empty fixture still returns ok" "$E" "d['ok'] is True and d['jobs']==[]"
280
281B=$(body "$(CRONTAB_FILE="$BAD" QUERY_STRING='action=jobs' $BIN)")
282json_ok "malformed lines still produce a response" "$B" "d['ok'] is True"
283json_ok "invalid lines are flagged, not dropped" "$B" "any(j['valid'] is False for j in d['jobs'])"
284json_ok "invalid lines carry an error string" "$B" "all(j['error'] for j in d['jobs'] if not j['valid'])"
285json_ok "invalid lines have no next runs" "$B" "all(j['next']==[] for j in d['jobs'] if not j['valid'])"
286
287L=$(body "$(CRONTAB_FILE="$FIX" QUERY_STRING='action=list' $BIN)")
288json_ok "action=list is an alias for jobs" "$L" "d['count']==7"
289
290F=$(body "$(CRONTAB_FILE="$FIX" QUERY_STRING='format=json' $BIN)")
291json_ok "format=json alone returns the job listing" "$F" "d['ok'] is True and 'jobs' in d"
292
293I=$(body "$(QUERY_STRING='action=info' $BIN)")
294json_ok "info action returns metadata" "$I" "d['plugin']=='plugin_crontab'"
295json_ok "info declares read-only" "$I" "d['read_only'] is True"
296json_ok "info lists the supported actions" "$I" "set(d['actions'])=={'jobs','explain','info'}"
297json_ok "info carries a trust notice" "$I" "len(d['trust_notice'])>20"
298
299U=$(body "$(QUERY_STRING='action=nope' $BIN)")
300json_ok "unknown action fails cleanly" "$U" "d['ok'] is False"
301check "unknown action names the problem" 'unknown action' "$U"
302
303# ---------------------------------------------------------------- auth
304section "node password gate"
305A=$(QUERY_STRING='action=info' BOT_PASSWORD=s3cret $BIN)
306check "wrong password is rejected" '401 Unauthorized' "$A"
307A=$(QUERY_STRING='action=info' BOT_PASSWORD=s3cret HTTP_X_BOT_PASSWORD=s3cret $BIN)
308check "X-Bot-Password header is accepted" '"ok":true' "$A"
309A=$(QUERY_STRING='action=info' BOT_PASSWORD=s3cret HTTP_AUTHORIZATION='Bearer s3cret' $BIN)
310check "Bearer token is accepted" '"ok":true' "$A"
311A=$(QUERY_STRING='action=info&pwd=s3cret' BOT_PASSWORD=s3cret $BIN)
312check "pwd query parameter is accepted" '"ok":true' "$A"
313A=$(QUERY_STRING='action=info&pwd=wrong' BOT_PASSWORD=s3cret $BIN)
314check "wrong pwd query parameter is rejected" '401 Unauthorized' "$A"
315
316# ---------------------------------------------------------------- html
317section "mode 3 — HTML UI"
318HTML=$(CRONTAB_FILE="$FIX" QUERY_STRING='' $BIN)
319check "HTML declares utf-8 charset" "Content-Type: text/html; charset=utf-8" "$HTML"
320check "HTML sets no-store" 'Cache-Control: no-store' "$HTML"
321check_not "HTML sets no Content-Length" 'Content-Length' "$HTML"
322check "HTML has a doctype" '<!DOCTYPE html>' "$HTML"
323check "HTML shows the plugin title" "<h1 class='title'>crontab</h1>" "$HTML"
324check "HTML has the jobs table" "<tbody id='rows'>" "$HTML"
325check "HTML has the playground input" "id='ex'" "$HTML"
326check "HTML has the explain button" "id='goBtn'" "$HTML"
327check "HTML has a theme toggle" "id='themeBtn'" "$HTML"
328check "HTML honours bot_theme" 'bot_theme' "$HTML"
329
330# ---- theme handoff (bot_theme_plugin.h) ----
331# the bot owns the theme: ?theme= before first paint, sx-theme after it
332check "html reads ?theme= before paint" 'theme=(light|dark)' "$HTML"
333check "html listens for sx-theme" "d.type==='sx-theme'" "$HTML"
334check "html asks the host for the theme" "sx-theme-request" "$HTML"
335check "html uses bot token --bg-card" "--bg-card" "$HTML"
336check "html uses bot token --surface-2" "--surface-2" "$HTML"
337check "html uses bot token --text-2" "--text-2" "$HTML"
338check "html hides its toggle when embedded" "embed-hide" "$HTML"
339check_not "html no retired brand casing" 'Scorpio'"X Bot" "$HTML"
340check_not "html no private palette 0d0d10" '0d0d10' "$HTML"
341check_not "html no private palette 16161a" '16161a' "$HTML"
342check_not "html no private palette f4f4f7" 'f4f4f7' "$HTML"
343THEMEQ=$(QUERY_STRING='theme=light' "$BIN")
344check "?theme=light still renders the UI" 'prefers-color-scheme' "$THEMEQ"
345# ---- end theme handoff ----
346
347check "HTML polls for refreshes" 'setInterval(load' "$HTML"
348check "HTML documents read-only behaviour" 'never' "$HTML"
349check "HTML mentions the fixture override" 'CRONTAB_FILE' "$HTML"
350check "HTML has a mobile breakpoint" '@media(max-width:640px)' "$HTML"
351check "HTML escapes its own shell prompt" "location.pathname" "$HTML"
352check "HTML exposes the KPI block" "id='k-total'" "$HTML"
353check "HTML playground defaults to a real expression" "*/15 9-17 * * 1-5" "$HTML"
354check_not "HTML contains no emoji" '🚀' "$HTML"
355
356EMB=$(CRONTAB_FILE="$FIX" QUERY_STRING='embed=1' $BIN)
357check_not "embed=1 hides the back link" 'Back to Bot' "$EMB"
358check "embed=1 still renders the table" "<tbody id='rows'>" "$EMB"
359PL=$(CRONTAB_FILE="$FIX" QUERY_STRING='embed=1' BOT_PASSWORD= $BIN)
360check "embed as string 'true' also works" 'crontab' "$(CRONTAB_FILE="$FIX" QUERY_STRING='embed=true' $BIN)"
361
362# ---------------------------------------------------------------- read-only
363section "read-only guarantees"
364N=$(grep -c 'crontab -l' src/plugin_crontab.c)
365if [ "$N" -ge 1 ]; then pass "plugin reads the user crontab"; else fail "no crontab -l read found"; fi
366check_not "no crontab write path" 'crontab -' "$(grep -v 'crontab -l' src/plugin_crontab.c | grep -F 'crontab -' || true)"
367check_not "no crontab install path" 'crontab -r' "$(cat src/plugin_crontab.c)"
368check_not "no schtasks write path" 'schtasks /Create' "$(cat src/plugin_crontab.c)"
369check_not "no repository-network egress" 'http://' "$(cat src/plugin_crontab.c)"
370check_not "no TLS egress" 'https://' "$(cat src/plugin_crontab.c)"
371check_not "no socket API" 'socket(' "$(cat src/plugin_crontab.c)"
372check "reads the system crontab" '/etc/crontab' "$(cat src/plugin_crontab.c)"
373check "reads cron.d drop-ins" '/etc/cron.d' "$(cat src/plugin_crontab.c)"
374check "supports the Windows task list" 'schtasks /Query' "$(cat src/plugin_crontab.c)"
375check "honours CRONTAB_FILE" 'CRONTAB_FILE' "$(cat src/plugin_crontab.c)"
376
377# ---------------------------------------------------------------- cross builds
378section "cross-platform artifacts"
379if [ -f "$BIN.musl" ]; then
380 if file "$BIN.musl" 2>/dev/null | grep -q 'statically linked'; then
381 pass "musl build is statically linked"
382 else
383 pass "musl build present (file(1) unavailable or non-static report)"
384 fi
385 M2=$(body "$(CRONTAB_FILE="$FIX" QUERY_STRING='action=jobs' "$BIN".musl)")
386 check "musl build runs" '"ok":true' "$M2"
387else
388 echo " skip musl build (not built here)"
389fi
390
391if [ -f plugin_crontab.exe ]; then
392 if [ "$(head -c 2 plugin_crontab.exe)" = "MZ" ]; then
393 pass "windows artifact starts with an MZ header"
394 else
395 fail "windows artifact is not a PE"
396 fi
397 SZ=$(wc -c < plugin_crontab.exe | tr -d ' ')
398 if [ "$SZ" -gt 20000 ]; then pass "windows artifact has a plausible size"; else fail "windows artifact is too small"; fi
399else
400 echo " skip windows artifact (not built here)"
401fi
402
403for f in LICENSE README.md Makefile build.ps1 release-dist.sh; do
404 [ -f "$f" ] && pass "$f present" || fail "$f missing"
405done
406check "LICENSE is MIT" 'MIT License' "$(cat LICENSE)"
407check "README documents the actions" 'action=explain' "$(cat README.md)"
408
409# ---------------------------------------------------------------- history audit
410section "git history secret audit"
411if git rev-parse --git-dir >/dev/null 2>&1; then
412 ALL="$WORK/history.txt"
413 git log -p --all 2>/dev/null \
414 | grep -v '^Author: ' \
415 | grep -vE 'scan_hist|HITS=|grep -E|suspects=|audit "|check_not "html has no internal fleet' \
416 > "$ALL" || : > "$ALL"
417
418 audit() { # audit <label> <regex>
419 H=$(grep -Eo "$2" "$ALL" 2>/dev/null | sort -u | head -3 || true)
420 if [ -n "$H" ]; then
421 fail "history: $1"; printf '%s\n' "$H" | sed 's/^/ /'
422 else
423 pass "history clean: $1"
424 fi
425 }
426 audit "LAN 192.168.x" '192\.168\.[0-9]+\.[0-9]+'
427 audit "private 10.x" '\b10\.[0-9]+\.[0-9]+\.[0-9]+'
428 audit "private 172.16-31.x" '172\.(1[6-9]|2[0-9]|3[01])\.[0-9]+\.[0-9]+'
429 audit "GitHub PAT" 'ghp_[A-Za-z0-9]{36}'
430 audit "HuggingFace token" 'hf_[A-Za-z0-9]{30,}'
431 audit "embedded git creds" 'scorpioxinc:[A-Za-z0-9]{20,}'
432 PK="pico""bot"; WT=".work""trees"
433 audit "internal fleet path" "/codebases/${PK}|${WT}"
434else
435 echo " skip history audit (not a git checkout)"
436fi
437
438# ---------------------------------------------------------------- summary
439rm -rf "$WORK"
440printf '\n%s== summary ==%s\n' "$C_B" "$C_0"
441printf ' passed: %d\n' "$PASS"
442printf ' failed: %d\n' "$FAIL"
443if [ "$FAIL" -ne 0 ]; then
444 printf ' %sRESULT: FAILED%s\n' "$C_BAD" "$C_0"
445 exit 1
446fi
447printf ' %sRESULT: OK%s\n' "$C_OK" "$C_0"
448exit 0