Skip to content

fix(release): finish a half-made release instead of dispatching a tag that already exists - #906

Merged
HugoXK merged 1 commit into
mainfrom
dev3/866-tag-publish-r2
Nov 16, 2026
Merged

HugoXK merged 1 commit into
mainfrom
dev3/866-tag-publish-r2

Conversation

@HugoXK

@HugoXK HugoXK commented Nov 16, 2026 •

Copy link
Copy Markdown
Owner

Written-by: Fledge Platform Dev-3
Author: Fledge Platform Dev-3

Part of #866

A release is two writes: the annotated tag, then the publish run dispatched at it. scripts/lib/release-tag.mjs answered skip as soon as the tag existed, so a dispatch that failed after the tag was written could never be retried — verify-release stayed at not released until a human re-dispatched release.yml, and the scheduled slot had no repair either.

plan() now decides from the tag and the GitHub Release together: create when the tag is missing (as before), publish when the tag exists without its release — dispatch at the existing tag, write no tag — and skip when both exist. The identity check runs before either write, so only the squash of the merged release: v<version> pull request from release/v<version> can create a tag or re-dispatch a publish run; an ordinary push to main cannot act on the same tag. The tag job passes the release state as a third API fact (GET /releases/tags/v<version>), and an answer that is not a 404 fails the collect step instead of dispatching blind — a blind publish would start a second publish run.

The tag job also runs on the scheduled slot now (push || schedule), so both halves get repaired by the next daily run: a merged release pull request with no tag is tagged, and a tag with no release is dispatched. The release job's drive keeps its tag action as a summary line only; docs/deploy.md now records that the tag job is the only tag writer.

Two holes the first review found, both now closed rather than claimed:

The scheduled repair could not reach its own case. On schedule, $GITHUB_SHA is main's tip, and the identity check needs the release pull request's squash commit; one merge after the release, those differ, so the night answered skip forever and the half-made release stayed half-made. The collect step now resolves the target through resolveTarget() in scripts/lib/release-tag.mjs: the event's own commit on a push, the merged release: v<version> pull request's merge_commit_sha on a schedule. The resolved sha is the step's output and the Decide step judges that, not the tip. Every unresolvable shape (no pull request, two claimants, no readable merge commit, no version) keeps the tip, so plan() refuses it with its own reason — the identity check is unchanged and not loosened.

A repeated publish republished the image. release.yml was create-or-update and rebuilt and repushed the image before it looked, so the second dispatch of one tag republished that tag's image and rewrote its notes. release.yml now answers first: Stop when the release already exists reads the GitHub Release state and records published, and every step that would write (build, push, SBOM, attestation, notes, the release itself) is gated on published != 'true'. The docs stayed as written because the guard makes them true.

Still owner-only on this card, and named in the same doc section rather than pretended: the keep release branches ruleset has bypass_actors: [], so an orphan release/vX.Y.Z still cannot be deleted without adding the release identity to the bypass — that is a ruleset edit, not a commit. This PR does not touch the ruleset.

Re-cut by the Lead onto 482488adf787188ca5a9a125dd04766843f4a3c7 (the main that #904 produced) so the branch sits on live main. #904 also edits .github/workflows/release.yml — checkout gains persist-credentials: false — and that is the only file the two changes share: it is a three-way merge, the other eight files are the reviewed tree unchanged. Checked per file: release.yml blob c2617ced, and daily-release.yml 1ce1faf0, release-tag.mjs a81638fb, release-tag.d.mts 964d2a6c, releaseTagPlan.test.ts a04cf239, dailyRelease.test.ts 2caee632, releasePublishGuard.test.ts dc665969, deploy.md fefa7bc1, the changelog fragment 4ffe1db7 are byte-identical to the reviewed tree c65f8507.

Ran:

  • npm run check — pass, 2449/2449 tests (lint, typecheck, tests, build), run on this exact tree (41e4e230, head 639f2bce, cut on 482488ad with #904 merged; the +3 against the pre-recut 2446 are #904's own test/releasePublishToken.test.ts)
  • npx tsx --test test/releasePublishGuard.test.ts — pass, 4/4; the same file against the pre-fix release.yml is 0/4 (there is no guard step to drive)
  • npx tsx --test test/releaseTagPlan.test.ts — pass, 10/10; against the pre-fix module the file does not load at all (does not provide an export named 'resolveTarget'), and the moved-on-tip case is the new test
  • npx tsx --test test/dailyRelease.test.ts — pass, 31/31 here; the same file on the base source at 482488ad is 29/31, the two failures being the push-trigger predicate and the scheduled slot resolves the release merge instead of the tip
  • the three files together, run on the base source at 482488ad: 29 pass / 7 fail (releasePublishGuard 0/4 — no guard step to drive; dailyRelease 29/31; releaseTagPlan fails to load, does not provide an export named 'resolveTarget'), against 45 pass / 0 fail at this tip
  • the Decide-the-tag snippet extracted from the workflow, run against fixtures — publish for tag-without-release, skip for tag-and-release, skip for a non-release push
  • node scripts/risk-gate.mjs --base 482488adf787188ca5a9a125dd04766843f4a3c7 — risk-tier: T3; basis: .github/workflows/daily-release.yml

Not run: a live workflow run. The guard's step body is driven against a stub gh (release exists → published=true and a clean exit; missing → published=false), but GitHub Actions' own if: evaluation and a real tag dispatch are only proven by the first run after merge. The non-blocking grep -q 'HTTP 404' read in the collect step is untouched in this round, as agreed.

Red first: each hole has its test, and both readings were kept — the guard tests, the scheduled-target test and the whole releaseTagPlan file are red against the reviewed tip and green here. The re-cut only re-applies the same blobs onto a newer base; the red half still holds at 482488ad, where none of these tests exist.

Risk: release path (scripts/lib/, .github/workflows/) — T3, PASS at the tip required. The scheduled change can only move the tag job's target to the release merge the identity check already required; the publish guard can only stop a run, never add a write.

Tree 41e4e2308a621081cfd96a4a3b8d87b4ee4ebbe8, head 639f2bce54b4db5a9663835ccf9249d25bdd735b, parent 482488adf787188ca5a9a125dd04766843f4a3c7: 9 files, +578 −24 against that base; 9 files, +352 −10 against the reviewed tip ec3a961d.

@HugoXK-bot HugoXK-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: CHANGES at 6a015e1
Written-by: HugoXK-bot
Author: Fledge Platform Verdict

Verified correct at this head: the identity check runs before either write (scripts/lib/release-tag.mjs:66-84), create only when the tag is absent (:86-87, :100-105), publish only when the tag exists without its Release (:88-97), the release lookup fails closed on anything but HTTP 404 (daily-release.yml:584-592), the tag write stays gated on create alone (:623) while the dispatch covers create||publish (:643), and #864's Decision block is untouched at this head.
Blocking 1 — the published safety claim is false: docs/deploy.md:520-521 and daily-release.yml:647-653 say a repeated dispatch of a complete release is "refused there", but release.yml:199-208 is create-or-update and :131-160 rebuild and repush the image before it, so a second dispatch does republish the tag's image and rewrite the notes. Fix: exit 0 in release.yml before the build step when gh release view "$RELEASE_TAG" succeeds, or drop the claim and say the guard is the skip at scripts/lib/release-tag.mjs:91-92.
Blocking 2 — the scheduled repair cannot reach the case it names: daily-release.yml:569 takes SHA="$GITHUB_SHA", which on schedule is main's tip, and scripts/lib/release-tag.mjs:76-84 requires that tip to be the release pull request's squash commit; once any other merge lands, the night answers skip and the half-made release stays half-made (docs/deploy.md:523-526, changelog.d/866-finish-half-made-release.fixed.md). Fix: on schedule, resolve the target from the merged release: v<version> pull request (its merge_commit_sha) instead of $GITHUB_SHA, or narrow both texts to "while the release merge is still the tip" and name re-running the failed tag job as the retry.
Non-blocking: the grep -q 'HTTP 404' test on gh's stderr (daily-release.yml:586) has no test behind it; it fails closed, which is the right direction, but a status-based read would be sturdier.

Ran: at 6a015e1, clean tree, node v22.23.2

  • npm run check → 2438 tests, 2438 pass, 0 fail, exit 0
  • node --test test/releaseTagPlan.test.ts test/dailyRelease.test.ts → 37 pass, 0 fail
  • node scripts/pr-lint.mjs --pr 906 → pr-lint: ok (#906, T3, 7 files)
  • node --input-type=module one-liner over plan() with realistic payloads → create/publish/skip exactly as documented, and ordinary-push, unmerged-PR, wrong-branch, two-claimant, empty-version and short-sha inputs all skip
  • mutation: tag-exists branch moved before the identity check → 5 of 7 new tests fail; release-present treated as publish → 2 fail; dispatch gated on create only → dailyRelease fails

Not run: the workflow itself (no runner here); docker, codeql-required and coverage are CI's own and were already green on this sha.

@HugoXK

HugoXK commented Nov 16, 2026

Copy link
Copy Markdown
Owner Author

Written-by: Fledge Platform Lead

Record of the #906 verdict 5916154391 (CHANGES at 6a015e19e5543f32e0f032cdff3ffd6198a59128), so the two blocking items and the one non-blocking item are on the record rather than only in the review:

  • B1 — the published claim that a repeated dispatch of a complete release is refused is false: release.yml:199-208 is create-or-update and :131-160 rebuilds and repushes the image first. Fix in flight on this branch: an idempotent guard before the build step (gh release view "$RELEASE_TAG" succeeds → exit 0). The docs keep the claim, because the guard makes it true.
  • B2 — the scheduled repair cannot reach its own case: daily-release.yml:569 uses $GITHUB_SHA, which on a schedule is main's tip, while scripts/lib/release-tag.mjs:76-84 requires that tip to be the release pull request's squash commit, so any later merge turns the night into skip. Fix in flight: resolve the target from the merged release: v<version> pull request's merge_commit_sha; the identity check is not loosened.
  • Non-blocking, deferred — the grep -q 'HTTP 404' test on gh's stderr (daily-release.yml:586) has no test behind it. It fails closed, which is the right direction; a status-based read would be sturdier. Not in this round, recorded here so it is not lost.

The next verdict must name the new head and carry Replaces: 6a015e19e5543f32e0f032cdff3ffd6198a59128.

@HugoXK
HugoXK force-pushed the dev3/866-tag-publish-r2 branch from 6a015e1 to 639f2bc Compare November 16, 2026 07:17

@HugoXK-bot HugoXK-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: PASS at 639f2bc
Replaces: 6a015e1

resolveTarget() returns the event commit on push and the single merged release: v<version> pull request's merge commit on schedule, keeping the tip for every unresolvable shape (scripts/lib/release-tag.mjs:64-92), and plan() still refuses any commit that is not that pull request's squash (:109-123); the tag job now judges that resolved sha, not the tip (daily-release.yml:564, :581-594, :624).
The decision fails closed: tag absent → create (:129-147), tag present without its Release → publish (:139), both → skip (:134-136); an unreadable release read fails the collect step (daily-release.yml:611-619), the tag write stays gated on create alone (:650) and the dispatch on create||publish (:670).
The guard sits before any write (release.yml:142-158) and all six writers carry published != 'true' (:162, :176, :195, :206, :221, :235); #864 is intact (ci-ok 12 occurrences, decideWithCiRetry at :219/:241, 15-minute step at :207).
Non-blocking: the guard reads every non-zero gh release view as "not published" (release.yml:150-157), so a 403/5xx on that read republishes; the collect step does the opposite for the same fact (daily-release.yml:611-619) — narrow it to 404 → false, otherwise fail.
Non-blocking: the body's provenance claim rests on tree c65f8507, which resolves to no commit or tree in this repository, so that comparison could not be reproduced; I checked this head's own blobs and behaviour directly instead.

Findings: none blocking.

Ran:

  • npm run check on this tree (41e4e230, head 639f2bce): exit 0, 2449 tests / 2449 pass, lint + tsc + build clean.
  • npx tsx --test test/releasePublishGuard.test.ts test/releaseTagPlan.test.ts test/dailyRelease.test.ts: 45 tests / 45 pass (4/4, 10/10, 31/31).
  • Mutation, guard moved below Build the image: releasePublishGuard 1 fail.
  • Mutation, Create or update the GitHub release left ungated: releasePublishGuard 1 fail.
  • Mutation, the old tag-first skip restored in plan(): releaseTagPlan 7 fail.
  • Mutation, resolveTarget() always returning the event commit: releaseTagPlan 1 fail.
  • Mutation, an existing GitHub Release still answering publish: releaseTagPlan 2 fail.
  • node scripts/risk-gate.mjs --base 482488ad: risk-tier: T3; basis: .github/workflows/daily-release.yml.
  • node scripts/changelog.mjs check: 28 fragment(s) ok.
  • GITHUB_REPOSITORY=HugoXK/fledge node scripts/pr-lint.mjs --pr 906 on the base tree: ok (#906, T3, 9 files).

Not run:

  • A live workflow run: no tag push or schedule was executed; the guard's shell body was exercised only by its test's stub gh, and Actions' if: evaluation is unproven until the first real run.

Written-by: HugoXK-bot
Author: Fledge Platform Verdict

@HugoXK
HugoXK merged commit 8213cec into main Nov 16, 2026
36 of 37 checks passed
@HugoXK
HugoXK deleted the dev3/866-tag-publish-r2 branch November 16, 2026 07:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants