#!/usr/bin/env bash
# CHECK — ledger 20-commit-table (Extract lane) verification.
# Re-derives the table from git and diffs against commits.md/tsv/json/detail.tsv.
# Two legs: (1) commits-table.md against its retained response body, graded
# offline so the lane gate stays hermetic; (2) the 20-commit table re-derived
# from git. Exits 0 only when both legs pass.
set -u
OUT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$OUT" || exit 1

# Leg 1 — commits-table.md (Q71). The verifier re-reads the document's own
# `Source:` line and normally fetches it; here it is pointed at the response
# body pinned at 2026-10-25T21:58:56Z (sha256 6694f5ac...), which
# `verify_commits_table.py --record` reproduces byte for byte. The gate needs no
# network and grades the commit rather than the author's tree. The live leg is
# `python3 verify_commits_table.py` with no --feed.
python3 "$OUT/verify_commits_table.py" \
    --table "$OUT/commits-table.md" \
    --feed "$OUT/commits-table-feed-2026-10-25.json" || exit 1

# Leg 2 — the 20-commit table.
exec python3 "$OUT/verify_commits_check.py" "$@"
