ckb/tests/smoke.sh
Michał Kopeć 1dd18f2c99 Template 1.12.0: ckb-add-conversation, ideas/ scratch folder
- New skill ckb-add-conversation: on request, copies the session's Claude
  Code transcript (JSONL) into raw/saved-conversations/<date>/ with a
  readable Markdown rendering and an index.md; answers "did we discuss X"
  from those files. Saved conversations stay outside retrieval and ingest.
- AGENTS.md: directory contract, cascade note, routing row, disambiguation,
  Rule E session-end ask (save only on a yes).
- ckb-retrieve, ckb-ingest, ckb-reset (tier 3), ckb-init know the folder.
- Docs, both READMEs, CHANGELOG, VERSION; smoke test renders a fixture
  transcript against a golden file.
- .gitignore: ideas/ local scratch folder for template ideas.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-16 08:27:22 +02:00

42 lines
2.3 KiB
Bash
Executable file

#!/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
SAVE=.agents/skills/ckb-add-conversation/scripts/save_conversation.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"
# Conversation rendering must be stable: same fixture transcript, same Markdown.
mkdir -p "$TMP/conv" && python3 "$SAVE" --from tests/fixtures/conversation/session.jsonl --root "$TMP/conv" --today "$TODAY" > /dev/null
cp "$TMP"/conv/raw/saved-conversations/"$TODAY"/*.md "$TMP/conversation.md"
if [[ "${1:-}" == "--update" ]]; then
cp "$TMP/lint.json" tests/expected/lint.json
cp "$TMP/retrieve.json" tests/expected/retrieve.json
cp "$TMP/conversation.md" tests/expected/conversation.md
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 tests/expected/conversation.md "$TMP/conversation.md"; then echo "DRIFT: conversation"; fail=1; fi
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