Skip to content

Commit 7cd8401

Browse files
authored
fix(release): deviating guard message — reject the rebuilt attempt, burn only vs the original anchor (#353) (#369)
* fix(release): deviating guard message directs full reruns to the original run before asserting a burn (#353) A deviation from THIS attempt's rebuilt bytes does not by itself burn the version: an accidental full rerun is rejected, and the operator is directed back to the ORIGINAL workflow attempt whose preserved artifact matches what the index accepted. The burn clause is scoped to a deviation from the ORIGINAL accepted anchor (which finalize reports as a burn state). Tests assert the message shape and ordering (original-run direction before the burn clause). * fix(release): deviating message states the first-attempt burn branch explicitly (#353 review round 2) The guard's inputs cannot distinguish a first-attempt index conflict from a full rerun, so the message now states both branches: on the ORIGINAL workflow attempt the current distributions ARE the original workflow build anchor and pre-existing/conflicting index files burn the version outright (finalize cannot classify that run — github-release fails at this guard); on a full rerun the mismatch proves only that the rebuilt attempt must be abandoned in favor of the recoverable original run. 'original accepted anchor' wording replaced with 'original workflow build anchor'; regressions pin BOTH interpretations.
1 parent 96a079f commit 7cd8401

2 files changed

Lines changed: 45 additions & 12 deletions

File tree

producers/scripts/guard_existing_release.py

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,18 @@
3535
current wheel+sdist bytes), or `deviating` (anything else — burned).
3636
That makes the guard consistent with the reconciler's recoveries: an
3737
exact TestPyPI publication with the draft missing PROCEEDS to recreate
38-
the draft from the preserved original-attempt artifact (a full rerun
39-
naturally shows `deviating` because rebuilt bytes differ), while
38+
the draft from the preserved original-attempt artifact, while
4039
production files always make the missing-release / preserved-draft
41-
paths authoritative. A published release always fails: that version is
42-
burned.
40+
paths authoritative. `deviating` covers two situations the guard cannot
41+
tell apart from its inputs, so the message states both branches: on
42+
the ORIGINAL workflow attempt the current distributions ARE the
43+
original workflow build anchor, and an index conflict (pre-existing or
44+
tampered files) burns the version outright — finalize cannot classify
45+
that run because github-release fails at this guard; on a full rerun
46+
the mismatch proves only that the rebuilt attempt must be abandoned in
47+
favor of the recoverable original run. A burn is asserted against the
48+
original workflow build anchor, never merely against a rebuilt one. A
49+
published release always fails: that version is burned.
4350
"""
4451

4552
from __future__ import annotations
@@ -96,10 +103,17 @@ def decide(release_state: str, pypi: str, testpypi: str) -> GuardAction:
96103
return GuardAction(
97104
False,
98105
1,
99-
f"{where} holds files for this version that DIFFER from the"
100-
" current dist bytes — the version is burned there (bump the"
101-
" version, rebuild, and cut a new tag); any existing draft is"
102-
" preserved for forensics",
106+
f"{where} holds files for this version that DIFFER from THIS"
107+
" attempt's dist bytes. If THIS IS the ORIGINAL workflow"
108+
" attempt, these distributions ARE the original workflow build"
109+
" anchor — the index already holds conflicting or pre-existing"
110+
" files that cannot be replaced, so the version is BURNED: bump"
111+
" the version, rebuild, and cut a new tag. If this is a full"
112+
" rerun, the mismatch proves only that the rebuilt attempt must"
113+
" be abandoned (NOT burned by this check alone): return to the"
114+
" ORIGINAL workflow attempt and re-run its FAILED jobs for"
115+
" authoritative reconciliation. Any existing draft is preserved"
116+
" for forensics",
103117
)
104118
if pypi == "exact":
105119
if release_state == "draft":

producers/tests/test_guard_existing_release.py

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,34 @@ def test_draft_with_exact_testpypi_files_is_preserved_too():
5252
assert "TestPyPI" in action.message
5353

5454

55-
def test_deviating_index_is_burned():
56-
# A full rerun rebuilds bytes, so its dist DIFFERS from what the
57-
# index accepted: byte validation turns that into an explicit burn.
55+
def test_deviating_message_states_the_first_attempt_burn_branch():
56+
# The guard's inputs cannot distinguish a first-attempt conflict
57+
# from a full rerun, so the message must state the ORIGINAL-attempt
58+
# branch explicitly (#353 review): on the original attempt the
59+
# current distributions ARE the original workflow build anchor, and
60+
# pre-existing/conflicting index files burn the version — finalize
61+
# cannot classify that run because github-release fails here.
5862
for release in ("absent", "draft"):
5963
action = guard_existing_release.decide(release, "deviating", "absent")
6064
assert not action.proceed
6165
assert action.exit_code != 0
62-
assert "DIFFER" in action.message
66+
assert "ORIGINAL workflow" in action.message
67+
assert "original workflow build anchor" in action.message
68+
assert "BURNED" in action.message
6369
assert "bump" in action.message
70+
assert "accepted anchor" not in action.message # corrected wording
71+
72+
73+
def test_deviating_message_states_the_full_rerun_reject_branch():
74+
# Same inputs, second interpretation: a full rerun's rebuilt bytes
75+
# prove only that the rebuilt attempt must be abandoned — return to
76+
# the original run for authoritative reconciliation.
77+
for release in ("absent", "draft"):
78+
action = guard_existing_release.decide(release, "deviating", "absent")
79+
assert "full" in action.message and "rerun" in action.message
80+
assert "NOT burned" in action.message
81+
assert "abandoned" in action.message
82+
assert "ORIGINAL workflow attempt" in action.message
6483
action = guard_existing_release.decide("absent", "absent", "deviating")
6584
assert not action.proceed
6685
assert "TestPyPI" in action.message

0 commit comments

Comments
 (0)