Skip to content

Commit 4d56520

Browse files
committed
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 5759357 commit 4d56520

2 files changed

Lines changed: 42 additions & 27 deletions

File tree

producers/scripts/guard_existing_release.py

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,16 @@
3737
exact TestPyPI publication with the draft missing PROCEEDS to recreate
3838
the draft from the preserved original-attempt artifact, while
3939
production files always make the missing-release / preserved-draft
40-
paths authoritative. A full rerun naturally shows `deviating` because
41-
rebuilt bytes differ — that REJECTS the rebuilt attempt and directs
42-
the operator back to the recoverable original run; a burn is asserted
43-
only for a deviation from the ORIGINAL accepted anchor (which finalize
44-
reports as a burn state), never merely from a rebuilt one. A published
45-
release always fails: that version is 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.
4650
"""
4751

4852
from __future__ import annotations
@@ -100,14 +104,16 @@ def decide(release_state: str, pypi: str, testpypi: str) -> GuardAction:
100104
False,
101105
1,
102106
f"{where} holds files for this version that DIFFER from THIS"
103-
" attempt's dist bytes. If this is a full rerun, the rebuilt"
104-
" attempt is REJECTED but the version is NOT burned: abandon"
105-
" this run and re-run the FAILED jobs from the ORIGINAL"
106-
" workflow attempt, whose preserved artifact matches what the"
107-
" index accepted. The version is burned ONLY if the index also"
108-
" deviates from the ORIGINAL accepted anchor (finalize reports"
109-
" that as a burn state) — then bump the version, rebuild, and"
110-
" cut a new tag. Any existing draft is preserved for forensics",
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",
111117
)
112118
if pypi == "exact":
113119
if release_state == "draft":

producers/tests/test_guard_existing_release.py

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -52,25 +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_rejects_the_rebuilt_attempt_before_burning():
56-
# A full rerun rebuilds bytes, so its dist DIFFERS from what the
57-
# index accepted. That REJECTS the rebuilt attempt — the message
58-
# must FIRST direct an accidental full rerun back to the original
59-
# workflow run, and assert a burn only for deviation from the
60-
# ORIGINAL accepted anchor (#353 review).
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.
6162
for release in ("absent", "draft"):
6263
action = guard_existing_release.decide(release, "deviating", "absent")
6364
assert not action.proceed
6465
assert action.exit_code != 0
65-
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
69+
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
6680
assert "NOT burned" in action.message
81+
assert "abandoned" in action.message
6782
assert "ORIGINAL workflow attempt" in action.message
68-
assert "ORIGINAL accepted anchor" in action.message
69-
assert "bump" in action.message # the true-burn branch stays stated
70-
# The original-run direction comes before the burn clause.
71-
assert action.message.index("ORIGINAL workflow attempt") < (
72-
action.message.index("bump")
73-
)
7483
action = guard_existing_release.decide("absent", "absent", "deviating")
7584
assert not action.proceed
7685
assert "TestPyPI" in action.message

0 commit comments

Comments
 (0)