#!/usr/bin/env bash # Template smoke test: run the deterministic scripts against the fixture KB and # compare with the golden output. Exit non-zero on any drift. # # tests/smoke.sh # check # tests/smoke.sh --update # regenerate the golden files after an intended change set -euo pipefail cd "$(dirname "$0")/.." FIX=tests/fixtures/minimal-kb TODAY=2026-09-24 LINT=.agents/skills/ckb-lint/scripts/lint_report.py RETR=.agents/skills/ckb-retrieve/scripts/retrieve_candidates.py TMP=$(mktemp -d); trap 'rm -rf "$TMP"' EXIT QUICK=.agents/skills/ckb-lint/scripts/lint_quick.sh ( cd "$FIX" && python3 "../../../$LINT" --json --today "$TODAY" ) > "$TMP/lint.json" # The no-Python fallback must agree with the reference on the three counts it covers. ( cd "$FIX" && python3 "../../../$LINT" --quick --today "$TODAY" || true ) > "$TMP/quick.py.txt" ( cd "$FIX" && bash "../../../$QUICK" --today "$TODAY" || true ) | sed 's/ (fallback:.*//' > "$TMP/quick.sh.txt" python3 "$RETR" "how many times does Atlas retry a failed batch" --root "$FIX" --today "$TODAY" --json > "$TMP/retrieve.json" if [[ "${1:-}" == "--update" ]]; then cp "$TMP/lint.json" tests/expected/lint.json cp "$TMP/retrieve.json" tests/expected/retrieve.json echo "golden files updated"; exit 0 fi fail=0 for f in lint retrieve; do if ! diff -u "tests/expected/$f.json" "$TMP/$f.json"; then echo "DRIFT: $f"; fail=1; fi done if ! diff -u "$TMP/quick.py.txt" "$TMP/quick.sh.txt"; then echo "DRIFT: lint_quick.sh disagrees with lint_report.py --quick"; fail=1; fi top=$(python3 -c "import json;print(json.load(open('$TMP/retrieve.json'))['candidates'][0]['path'])") [[ "$top" == "wiki/entities/atlas-retry-policy.md" ]] || { echo "retrieve: expected atlas-retry-policy first, got $top"; fail=1; } [[ $fail -eq 0 ]] && echo "smoke: OK" exit $fail