fix(origin-proof): read private repos via FLEET_PAT and refuse a shrinking manifest (#67)

FLEET_READ_TOKEN does not exist; FLEET_PAT is the org PAT the auto-merge sweep
already runs on, so the nightly run can see all 47 repos. And a manifest that
lists fewer repos than the last one is refused: a token that sees less is far
likelier than repos vanishing, and a wrong manifest sits in the chain forever.
ORIGIN_PROOF_ALLOW_SHRINK=1 confirms a real deletion.


Claude-Session: https://claude.ai/code/session_01DzY8KuwgUM7u95GVTpRL2m

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
CatoandClaude Fable 5.1 authored and GitHub committed 2026-09-13 18:52:34 -07:00
1 parent 10229a1ec9
commit 3a030d1ceb
3 files changed
+38 -7

No files matched your search

+6 -4
View File
@@ -40,10 +40,12 @@ jobs:
- name: Stamp, archive, upgrade
env:
# The default token reads public repos only; private ones would be
# silently omitted from the manifest. The script prints how many repos
# it stamped — a drop in that number is the tell. FLEET_READ_TOKEN
# covers all of them.
GH_TOKEN: ${{ secrets.FLEET_READ_TOKEN || secrets.GITHUB_TOKEN }}
# silently omitted from the manifest. FLEET_PAT is the org PAT the
# auto-merge sweep already runs on, so it can see every repo. The
# script refuses to write a manifest that lists FEWER repos than the
# last one — a token that sees less is far likelier than repos
# vanishing, and a wrong manifest is in the chain forever.
GH_TOKEN: ${{ secrets.FLEET_READ_TOKEN || secrets.FLEET_PAT || secrets.GITHUB_TOKEN }}
# Optional. Lifts the Software Heritage save limit from 10/h to 1200/h.
SWH_TOKEN: ${{ secrets.SWH_TOKEN }}
run: |
+13
View File
@@ -161,6 +161,19 @@ stamp() {
rm -f "$candidate"
return 0
fi
# Fewer repos than last time is almost always a token that sees less (the
# default GITHUB_TOKEN reads public repos only), not repos that vanished. A
# manifest missing three repos would sit in the chain forever, so refuse;
# a deleted or transferred repo is confirmed with ORIGIN_PROOF_ALLOW_SHRINK=1.
if [ -n "$prev" ] && [ "${ORIGIN_PROOF_ALLOW_SHRINK:-}" != "1" ]; then
local before; before="$(jq '.repos | length' "$prev")"
if [ "$n" -lt "$before" ]; then
echo " refusing: $n repos now, $before in $(basename "$prev") — a token that cannot see them all?" >&2
echo " set ORIGIN_PROOF_ALLOW_SHRINK=1 if repos were really deleted or transferred" >&2
rm -f "$candidate"
exit 1
fi
fi
local out="$PROOF_DIR/$(date -u +%Y-%m-%dT%H%M%SZ).json"
mv "$candidate" "$out"
chmod 644 "$out" # mktemp made it 0600; this is a public record
+19 -3
View File
@@ -35,7 +35,8 @@ cat > "$TMP/bin/gh" <<'FAKE'
case "$1 $2" in
"repo list")
if [[ "$*" == *isFork* && "$*" == *defaultBranchRef* ]]; then
printf 'pubkit\tPUBLIC\tmain\nsecret-thing\tPRIVATE\tmain\n'
printf 'pubkit\tPUBLIC\tmain\n'
[ -n "${FAKE_HIDE_PRIVATE:-}" ] || printf 'secret-thing\tPRIVATE\tmain\n'
else
printf 'pubkit\tPUBLIC\nsecret-thing\tPRIVATE\n'
fi ;;
@@ -103,13 +104,28 @@ m2="$(ls "$TMP/proofs"/*.json | sort | tail -1)"
&& [ "$(jq -r '.previous.sha256' "$m2")" = "$(sha256sum "$m1" | cut -c1-64)" ] \
&& ok "the second manifest links to the first by name and sha256" || no "chain link wrong: $(jq '.previous' "$m2")"
# ── the org shrank ─────────────────────────────────────────────────────────
# A token that reads public repos only sees fewer repos — the manifest must
# NOT be written, or the private repos silently drop out of the chain.
echo "fourth run, the token sees one repo fewer"
cp "$TMP/heads" "$TMP/heads.full"
sed -i '/^secret-thing/d' "$TMP/heads"
FAKE_HIDE_PRIVATE=1 out="$(FAKE_HIDE_PRIVATE=1 run --stamp)"; rc=$?
[ $rc -ne 0 ] && grep -q "refusing: 1 repos now, 2" <<<"$out" && [ "$(ls "$TMP/proofs"/*.json | wc -l)" = "2" ] \
&& ok "fewer repos than the last manifest is refused, nothing written" || no "shrink not refused (rc=$rc): $out"
out="$(FAKE_HIDE_PRIVATE=1 ORIGIN_PROOF_ALLOW_SHRINK=1 run --stamp)"; rc=$?
[ $rc -eq 0 ] && [ "$(ls "$TMP/proofs"/*.json | wc -l)" = "3" ] \
&& ok "ORIGIN_PROOF_ALLOW_SHRINK=1 confirms a real deletion" || no "allow-shrink did not write (rc=$rc): $out"
m3="$(ls "$TMP/proofs"/*.json | sort | tail -1)"
cp "$TMP/heads.full" "$TMP/heads"
# ── check ──────────────────────────────────────────────────────────────────
echo "check"
out="$(run --check)"; rc=$?
[ $rc -eq 0 ] && grep -q "chain intact" <<<"$out" && ok "--check passes on an untouched chain" || no "check failed on clean chain: $out"
out="$(run --upgrade)"
grep -q "anchored in Bitcoin: 2, awaiting a block: 0" <<<"$out" \
grep -q "anchored in Bitcoin: 3, awaiting a block: 0" <<<"$out" \
&& ok "--upgrade reports attestations and removes .bak files" || no "upgrade tally: $out"
[ -z "$(ls "$TMP/proofs"/*.bak 2>/dev/null)" ] && ok "no .bak litter after upgrade" || no ".bak left behind"
@@ -120,7 +136,7 @@ out="$(run --check)"; rc=$?
[ $rc -ne 0 ] && grep -q "proof is over" <<<"$out" && grep -q "previous link does not match" <<<"$out" \
&& ok "editing a stamped manifest fails its proof AND breaks the next link" || no "tamper not detected (rc=$rc): $out"
rm "$m2.ots"
rm "$m3.ots"
out="$(run --check)"; rc=$?
[ $rc -ne 0 ] && grep -q "has no .ots proof" <<<"$out" \
&& ok "a manifest without a proof is reported" || no "missing proof not detected: $out"