From c637b0bd23a3f0e2fcf1f36b94ca8d00a9fea8fd Mon Sep 17 00:00:00 2001 From: Cato <41178744+catomean@users.noreply.github.com> Date: Sun, 13 Sep 2026 18:55:24 -0700 Subject: [PATCH] fix(origin-proof): two stamps in one second must not share a filename (#68) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Manifest names are second-resolution and the chain is ordered by name. On CI's faster runner the shrink test's second stamp landed in the same second as the one before it, overwrote it, and broke the chain link — the suite went red on #67 after it had merged. The script now waits for a free name; the test no longer sleeps before that run so the collision path is exercised. Claude-Session: https://claude.ai/code/session_01DzY8KuwgUM7u95GVTpRL2m Co-authored-by: Claude Fable 5.1 --- scripts/ci/origin-proof.sh | 4 ++++ scripts/ci/test-origin-proof.sh | 6 ++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/scripts/ci/origin-proof.sh b/scripts/ci/origin-proof.sh index db23f23..5a034d6 100755 --- a/scripts/ci/origin-proof.sh +++ b/scripts/ci/origin-proof.sh @@ -174,7 +174,11 @@ stamp() { exit 1 fi fi + # Names are second-resolution and the chain is ordered by name, so a second + # stamp within the same second must wait rather than overwrite the first — + # CI's runner did exactly that on 2026-09-14 and broke its own chain link. local out="$PROOF_DIR/$(date -u +%Y-%m-%dT%H%M%SZ).json" + while [ -e "$out" ]; do sleep 1; out="$PROOF_DIR/$(date -u +%Y-%m-%dT%H%M%SZ).json"; done mv "$candidate" "$out" chmod 644 "$out" # mktemp made it 0600; this is a public record ots stamp "$out" >/dev/null diff --git a/scripts/ci/test-origin-proof.sh b/scripts/ci/test-origin-proof.sh index c17a01f..9921c4a 100755 --- a/scripts/ci/test-origin-proof.sh +++ b/scripts/ci/test-origin-proof.sh @@ -96,7 +96,6 @@ out="$(run --stamp)" # ── a HEAD moved ─────────────────────────────────────────────────────────── echo "third run, one HEAD moved" sed -i 's/^pubkit\t.*/pubkit\t3333333333333333333333333333333333333333/' "$TMP/heads" -sleep 1 # filenames are second-resolution out="$(run --stamp)" m2="$(ls "$TMP/proofs"/*.json | sort | tail -1)" [ "$m2" != "$m1" ] && ok "a moved HEAD produces a second manifest" || no "no second manifest: $out" @@ -113,9 +112,12 @@ 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" +# No sleep before this one on purpose: it can land in the same second as the +# previous manifest, and the script must pick a distinct, later name rather +# than overwrite it (which is what happened on CI's faster runner). 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" + && ok "ORIGIN_PROOF_ALLOW_SHRINK=1 confirms a real deletion, under a distinct name" || no "allow-shrink did not write (rc=$rc): $out" m3="$(ls "$TMP/proofs"/*.json | sort | tail -1)" cp "$TMP/heads.full" "$TMP/heads"