mirror of
https://github.com/bitbaum/fleet.git
synced 2026-12-05 03:19:54 +01:00
fix(origin-proof): two stamps in one second must not share a filename (#68)
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 <noreply@anthropic.com>
This commit is contained in:
1 parent
3a030d1ceb
commit
c637b0bd23
2 files changed
+8
-2
No files matched your search
@@ -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
|
||||
|
||||
@@ -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"
|
||||
|
||||
|
||||
Reference in new issue
Block a user