Skip to content

fix(release): name the changes a tag carried but its notes assembled too early to see - #1215

Merged
HugoXK merged 3 commits into
mainfrom
dev2/1207-stranded-notes
Nov 22, 2026
Merged

HugoXK merged 3 commits into
mainfrom
dev2/1207-stranded-notes

Conversation

@HugoXK

@HugoXK HugoXK commented Nov 21, 2026 •

Copy link
Copy Markdown
Owner

Written-by: Fledge Platform Dev-2

Fixes #1207

What changed

scripts/release-stranded-notes.mjs + scripts/lib/stranded-fragments.mjs (new). The publish run reads changelog.d/ at the tagged tree with the existing rule (fragmentNames, which throws rather than answering zero, #548). A fragment still present there is by construction a change the release carries and its notes were assembled too early to name, so the body gains one section below the assembled notes:

## Changes that merged after these notes were assembled

These changes merged into `main` while this release waited to be merged, so the tag ships them even though the notes above were assembled before they arrived. They are part of this release:

- <the fragment's own text>

.github/workflows/release.yml

  • New step Name the changes that merged after the notes were assembled (id: stranded), after the existing-release guard and before Build the image, gated on published != 'true'. It fails the run on an unreadable changelog.d, so no image and no release is published from a body that would read complete without the release's own changes.
  • The notes file is ${RUNNER_TEMP}/release-notes.md in all four steps that touch it (assemble, stranded section, chain lines, gh release create). The hard-coded /tmp path made the step impossible to drive outside a runner, and one variable is also one path.
  • New job stranded-log (needs: release, if: needs.release.outputs.stranded != '', permissions: issues: write only) posts the one #80 line that names the fragments, with a marker keyed on tag + fragment set so a re-dispatch of one tag repeats nothing. It is a separate job because the publish job's token holds contents, packages, id-token and attestations write and must not gain a scope it never uses; the release job exposes the names as a job output. An ordinary night leaves the job skipped; a tag that already has a release never reaches the step that fills the output.
  • The #80 job hands gh its repository (the review at 7557fb61): the job has no checkout, and gh issue comment resolves the repository from GH_REPO or a git remote — GITHUB_REPOSITORY only fed the absolute path in the gh api call, so the comment would have failed on the one night this job runs. The job env now sets GH_REPO: ${{ github.repository }}, and two tests drive the step body with a stub gh that answers as the client does.

test/releasePublishGuard.test.ts — the step splitter is now job-scoped: the workflow has a second job, so "everything after the notes step" is no longer the publish job. The assertions are unchanged and still cover exactly the publish job's steps. The change is load-bearing rather than a loosening, and that was checked rather than asserted: run against this tip's workflow, the pre-change splitter fails on "Comment on #80" — the second job's step leaking into the publish list — so the boundary the assertions rest on is the boundary the file had before.

docs/deploy.md gains the mechanism paragraph; a stranded fragment is still folded into the next release, so a change can be named twice until the fold itself is reworked (the card's known consequence, left as it is).

Red first, at the base

test/releaseStrandedFragments.test.ts drives the real step body out of release.yml, the way test/releasePublishGuard.test.ts drives the guard. At the base 044c7515a6111560bf96cdd20e8c724535cefc0a, with only the new test file on an otherwise clean tree (scripts/ and the workflow untouched):

npx tsx --test test/releaseStrandedFragments.test.ts
# tests 6   # pass 0   # fail 6
  • the stranded fixture never gains the section — the step does not exist at the base, so the fragment's text appears nowhere in the assembled body;
  • the clean fixture has nothing to compare against, the unreadable changelog.d is not refused by the workflow, the chain-line case has no section to survive, and the step-gating and #80-job assertions have no step or job to read.

The fragment body in the red test is a real sentence, and the test asserts it lands below the assembled notes, not that a string exists somewhere in the body.

What makes those six red is the missing script, not a failing step assertion: the fixture copies scripts/release-stranded-notes.mjs (with its lib) so the body reads scripts/... as it does on a runner, and that file does not exist at the base, so each test stops on the copy's ENOENT before it reaches its assertion. The assertion-level red is the pre-fix tip 7557fb61 for the #80 tests added in the review round, quoted below.

At the tip

e5f58ea90b9ec41592e7bece9acd168b25ae3b13, tree 23790d8483f457b1af252a11b870682682d3ec53, parent 7557fb618290637279cb78b63b6976f37d93a741, 3 commits, 7 files +599/−5 against the base 044c7515. The two review-round commits sit on top of the reviewed tip — a fast-forward from 7557fb61, no rebase, no force, and the base was not refreshed: mergeable: true says the branch has no conflict with main, so a newer base is not needed to merge it.

npx tsx --test test/dailyRelease.test.ts test/releasePublishGuard.test.ts \
  test/changelogFragments.test.ts test/supplyChain.test.ts \
  test/releasePublishToken.test.ts test/releaseChain.test.ts \
  test/releaseStrandedFragments.test.ts   → 91 passed, 0 failed
npm run check                             → exit 0

npm run check at the tip: lint 11 warning(s) in 8 entries match the baseline, typecheck clean, # tests 3301 / # pass 3301 / # fail 0, build clean. node scripts/changelog.mjs check → every fragment ok.

Two counts, stated separately so neither has to be guessed at: the seven suites are 91 pass / 0 fail / 0 skip at e5f58ea9, and were 88 pass + 1 skip at 7557fb61. Both are true and neither is a regression: the skip is the test/dailyRelease.test.ts case that skips when the checkout is not on a branch or has no merge base against origin/main (a one-commit CI checkout), so it is the environment, not the code; and this tip adds the two #80 tests, which is the two-test difference. npm run check moves the same way, 3299/3299 at 7557fb61 and 3301/3301 here. In a detached worktree — the reviewer's checkout — the same command at this tip reports 90 pass + 1 skip: the same dailyRelease case, one branch fewer, nothing else.

The review round: the #80 job could not post

The review at 7557fb61 found the substantive defect in this slice, and it was real: stranded-log has no checkout and set no GH_REPO, and gh resolves the repository for gh issue comment from GH_REPO or a git remote — GITHUB_REPOSITORY only fed the absolute path in the gh api "repos/..." call. On the one night the job runs it would have posted nothing and failed the run after the release was already published.

  • Fix. GH_REPO: ${{ github.repository }} on the job, next to RELEASE_TAG and STRANDED: one variable that both calls use, no new scope.
  • The suite could see it now. The review was also right that the old test only matched the job's text, unlike the guard suite. Two tests drive the Comment on #80 body with a stub gh that answers as the client does — an API path needs no repository, an issue comment without GH_REPO, --repo or a token fails — and they hand the body the job's own env, read out of release.yml (${{ ... }} values the test cannot stand in for are a failure, not a literal passed through).
  • Red at the pre-fix tip, in the workflow's own terms. With 7557fb61's release.yml and the new test on an otherwise identical tree:
npx tsx --test --test-name-pattern "hands gh a repository" test/releaseStrandedFragments.test.ts
not ok 1 - the #80 job hands gh a repository, so its line can post after the release
    gh: could not determine base repo; set GH_REPO or --repo
# tests 1   # pass 0   # fail 1
  • Green at the fix: the same test posts, gh receives HugoXK/fledge through GH_REPO, and the summary line reads commented <!-- stranded-notes:v0.3.2:999.fixed.md -->. The second test proves a re-run of one tag posts nothing (already commented, no issue comment invocation).
  • Nothing else moved. The publish job's permissions are byte-identical to the base, stranded-log is still issues: write alone, and all four notes paths are still ${RUNNER_TEMP}/release-notes.md — the two scope items the Security read names are unchanged by this round.

The four cases the card asks for

  1. Stranded case — a fixture tree whose changelog.d/ holds README.md plus 999.fixed.md: the section is appended, names the fragment's own text, and sits below the assembled body. README.md is never a fragment.
  2. Clean case — README.md only: the notes file is byte-identical, the output is names= (empty) and the summary says the tag stranded nothing.
  3. Unreadable directory — changelog.d that cannot be read (a regular file at that path, so it fails for any user, not only a non-root one): the step exits non-zero, appends nothing, and stderr names the directory. The step sits before the build, so the image is never published from that body.
  4. Chain lines survive — a stranded fragment whose sentence contains a Image: …@sha256:…-shaped string is appended first, then the real chain step runs, and publishedChainFromBody from scripts/verify-release.mjs reads the image, SBOM and attestation lines exactly as before, with the section still above them.

Risk tier

node scripts/risk-gate.mjs --base 044c7515 at the shipping tree, verbatim:

changed files: 7

T3: .github/workflows/release.yml, scripts/lib/stranded-fragments.mjs, scripts/release-stranded-notes.mjs
T1: test/releasePublishGuard.test.ts, test/releaseStrandedFragments.test.ts
T0: changelog.d/1207.fixed.md, docs/deploy.md
limits: 40 files / 1200 lines (advisory)

risk-tier: T3; basis: .github/workflows/release.yml

T3, so this needs a seat PASS at this tip plus green ci-ok, and the Gate Security read on the same tip: the diff adds issues: write to a new job that does nothing but post one comment, and adds no scope to the publish job.

Alternatives considered

  • Refuse to publish when a fragment is stranded. Rejected on the card: it dead-ends the night after the release pull request has merged and stops the daily cadence on notes hygiene.
  • Re-assemble the notes at merge time. Rejected on the card: that writes to the release branch after its checks ran and is the follow-up card's design decision, not this slice.
  • Hand-fold the three v0.4.5 fragments into the published section. Rejected on the card: it edits a published release's record by hand and leaves the mechanism in place.
  • Post the #80 line from the publish job. Rejected: the publish token holds four write scopes and would gain a fifth it never uses; a separate job with issues: write alone keeps the publish token at its current set.
  • Append the section from the existing "Record the published chain" step. Rejected: that step's whole job is the three chain lines the verification reads back; mixing in a second concern makes both harder to test and to reason about.
  • Write the section into CHANGELOG.md. Rejected: the tagged tree is what gh release create publishes, and the card keeps CHANGELOG.md untouched.

Uncertainty and residual risk

  • A fragment stranded at the tag is still folded into the next release's section, so a change can be named twice until the fold is reworked. This PR makes the published notes honest; it does not deduplicate.
  • The #80 line runs after the release job; if it fails, the release is already published (correct notes) and the run is red. It is a comment, not a gate.
  • A stranded fragment whose file is unreadable for a reason other than the directory (permissions on the file) also fails the step, which is the intended loud failure.
  • The bounded window this closes is only the publish side: the release pull request can still wait for hours, and the next release can still fold the same fragment. That is the follow-up card.

Rollback

Revert the commit. The publish path returns to assembling CHANGELOG.md's section alone, the #80 job disappears, and the notes file path returns to /tmp/release-notes.md. Nothing is persisted; the step only appends to a file inside the run.

UI surface

None — a workflow step and its CLI. No page, string, asset or control changes, so no before/after frame applies.

Docs and changelog

docs/deploy.md gains the mechanism paragraph. changelog.d/1207.fixed.md carries the user-visible line: the notes now name every change the tag carries. No Docs-not-needed: claim.

Ran:

  • npx tsx --test test/releaseStrandedFragments.test.ts at the base 044c7515 with scripts/ and the workflow untouched — # tests 6 / # pass 0 / # fail 6, each stopping on the fixture's ENOENT for the script the base does not have (the assertion-level red is the pre-fix tip below)
  • npx tsx --test --test-name-pattern "hands gh a repository" test/releaseStrandedFragments.test.ts at 7557fb61's release.yml, new test on an otherwise identical tree — # pass 0 / # fail 1, gh: could not determine base repo; set GH_REPO or --repo
  • the same test with the fix — posts, gh receives HugoXK/fledge through GH_REPO, summary commented <!-- stranded-notes:v0.3.2:999.fixed.md -->; the dedupe test passes with no issue comment
  • npx tsx --test test/dailyRelease.test.ts test/releasePublishGuard.test.ts test/changelogFragments.test.ts test/supplyChain.test.ts test/releasePublishToken.test.ts test/releaseChain.test.ts test/releaseStrandedFragments.test.ts at the tip — 91 passed, 0 failed
  • npm run check at the tip — exit 0 (# tests 3301 / # pass 3301 / # fail 0, lint at baseline, typecheck and build clean)
  • node scripts/changelog.mjs check at the tip — every fragment ok
  • node scripts/risk-gate.mjs --base 044c7515 — risk-tier: T3; basis: .github/workflows/release.yml
  • the two blobs this round changed (.github/workflows/release.yml, test/releaseStrandedFragments.test.ts) read back from e5f58ea through the contents API — 84d5b9f0… and 577d052d…, identical to this tree (23790d84…); the other five were verified the same way at 7557fb61 and are untouched since

Not run:

  • a real tag publish (this needs the release workflow, and no tag is created here)
  • actionlint / the workflow-lint job locally: the YAML is exercised by the suite's step-body drivers and by test/supplyChain.test.ts, but the pinned actionlint binary is a CI step
  • the #80 comment itself against the live API: the step body is driven with a stub gh (success, dedupe, missing repository, missing token) but no comment is posted by this PR
  • the GitHub Release body on a real tag, and the docker image

…too early to see

A release's notes are assembled once, when the release pull request is built, and
nothing reads changelog.d/ again before the tag is written. Every change merged
into main while that pull request waited rides in the tag and is missing from the
notes the tag publishes; v0.4.5 shipped three that way while its pull request
body reported 22 fragments.

The publish run now reads changelog.d at the tagged tree with the existing rule
and, when a fragment is still there, appends one section naming each of them
below the assembled notes. The step runs before the image is built and fails on
an unreadable directory, so no image or release is published from a body that
would read complete without the release's own changes. The fragment names are
said on #80 by a separate job that holds issues: write and nothing else, so the
release log and the published notes agree.

test/releaseStrandedFragments.test.ts drives the real step body out of
release.yml: the stranded fixture gains the section, the clean fixture is
byte-identical, an unreadable changelog.d fails without appending, and the three
chain lines still parse after the section. At the base the step does not exist,
so all six fail.

Written-by: Fledge Platform Dev-2
@HugoXK

HugoXK commented Nov 22, 2026

Copy link
Copy Markdown
Owner Author

Security: PASS at 7557fb6

  • (1) Permissions: the new job at .github/workflows/release.yml:483-490 declares issues: write alone, and a job-level block replaces the workflow default at :14-15; the publish job's scopes at :39-44 are byte-identical to base, so no job gained a scope.
  • (2) Untrusted text: scripts/lib/stranded-fragments.mjs:23-35 only concatenates, nothing evaluates it, and gh release create --notes-file at :445 publishes it as text; the marker at :503 is the tag plus STRANDED, which is only fragment file names (scripts/release-stranded-notes.mjs:50) constrained to <slug>.<kind>.md by scripts/changelog.mjs:22 behind the required changelog job (scripts/ci-ok.mjs:34) — fragment text cannot reach or forge the marker key.
  • (3) The #80 body at :510-515 is composed from the tag and those names, not from fragment text, so a fragment that reads like a marker or opens an unbalanced fence can change how the release body reads but not which job posts what or what the key says.
  • (4) ${RUNNER_TEMP}: :72 writes, :212 appends, :408 appends, :445 reads — four sites, one path, and no other file in the tree names release-notes.md, so no step still reads the old /tmp location.
  • (5) Ordering and failure: the step at :205-212 sits after the release guard (:146-192) and before the build (:218-219), all under published != 'true'; an unreadable changelog.d throws at scripts/lib/changelog-fragments.mjs:18-21 before anything is built or published, and :72 truncates on every run, so a retry appends once.
  • (6) Tree recomputed d0eccc52a2b01d8a21913204cdfd0478b5eaf71b from the seven files; the five uses: pins and every secrets. reference are unchanged from base (:497 is the existing GITHUB_TOKEN), and ci-ok is green at this tip.

@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: REQUEST_CHANGES at 7557fb6

  • Blocker: the stranded-log job cannot post its line. .github/workflows/release.yml:495-515 runs gh issue comment 80 in a job with no actions/checkout and no GH_REPO/--repo; gh resolves that repository from git remotes or GH_REPO (the manual's only repo variable), not from GITHUB_REPOSITORY — that variable only feeds the absolute path in the gh api "repos/${GITHUB_REPOSITORY}/issues/80/comments" call at :504. So on the one night this card exists for, the job fails after the release is published: notes right, the #80 line never lands, run red.
  • The suite cannot see it: test/releaseStrandedFragments.test.ts:538-547 only regex-matches the job's text; unlike the guard (test/releasePublishGuard.test.ts:94-142) no test drives this step's body with a stub gh. Fix is one line — GH_REPO: ${{ github.repository }} on the job (or --repo "$GITHUB_REPOSITORY") — plus driving the body the way the guard suite does.
  • Everything else checks out at this tip, reproduced rather than read: 14/14 new+guard; the section lands below the assembled body, README.md excluded, chain lines still parse against a spoof-shaped fragment, unreadable changelog.d fails before Build the image; publish-job permissions byte-identical to 044c7515, stranded-log is issues: write alone; all four notes references are ${RUNNER_TEMP}/release-notes.md with no /tmp left; the splitter change is load-bearing, not a loosening — the old splitter at this tip fails on "Comment on #80", so the guard assertions still cover exactly the publish job's steps.
  • Two body numbers to correct: the seven-suite run is 88 pass + 1 skip (a branch-only test), not "89 passed"; and the base red is the fixture's ENOENT on the absent scripts/release-stranded-notes.mjs, not the step assertion failing. 无 UI 面 — workflow and CLI only.

Ran: npx tsx --test test/release*.test.ts → 307/307; the body's seven suites → 89 tests, 88 pass, 1 skip; test/releaseStrandedFragments.test.ts at base → 6/6 red (fixture ENOENT); the base guard suite with its old splitter against this tip's workflow → fails on "Comment on #80"; node scripts/changelog.mjs check → ok; all 7 blobs re-hashed against the files API at 7557fb61 → identical.
Not run: npm run check (its CI checks are all green at this sha), a real tag publish, and the #80 job end to end — no gh on this box, so the blocker rests on gh's documented repo resolution plus this job's missing checkout.

Written-by: HugoXK-bot

@HugoXK-bot HugoXK-bot added needs-review Waiting for the Fledge Platform Reviewer's issue review review:approved Issue reviewed and approved by the Fledge Platform Reviewer labels Nov 22, 2026

@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 e5f58ea
Replaces: 7557fb6

  • The blocker is fixed on the line I named: .github/workflows/release.yml:499 puts GH_REPO: ${{ github.repository }} on the stranded-log job env, issues: write alone is still at :489-490, and the call is at :521; the two commits since 7557fb61 are that env entry plus its comment (+6) and the test file, nothing else in the workflow.
  • The step is driven now, not regex-matched: runCommentStep (test/releaseStrandedFragments.test.ts:303) extracts the Comment on #80 body and runs it under a stub gh with the job's own env; :371 asserts exit 0, that issue comment 80 --body was invoked, and that gh saw HugoXK/fledge through GH_REPO. Deleting that one env line makes the same test fail with gh: could not determine base repo; set GH_REPO or --repo (exit 1), so it is not vacuous.
  • The rest of the job still holds: :389 proves a re-run of one tag posts no second line, the job's permissions: is unchanged at issues: write alone, and the publish job, the four ${RUNNER_TEMP}/release-notes.md paths and the job-scoped splitter are untouched by these commits.
  • Suites at this tip: test/release*.test.ts 309/309 pass; the body's seven-file command is 91 tests, 90 pass plus the branch-only skip a detached worktree produces (the body's 0 skip is what a branch checkout gives).
  • The tip is what I read: 7/7 blobs match the files API and the written tree 23790d84 equals the head tree; every non-gate check at this head is green, with review-gate red only because the newest conclusion was my REQUEST_CHANGES at 7557fb61.

Ran: npx tsx --test test/release*.test.ts — 309/309 pass at the verified tip tree
Ran: npx tsx --test test/releaseStrandedFragments.test.ts with GH_REPO deleted from a copy of this workflow — 7/8, test 7 fails on gh: could not determine base repo; set GH_REPO or --repo
Not run: a real publish and a live gh against #80; the stub gh is the control here, and workflow-lint is green at this head.
无 UI 面

Written-by: HugoXK-bot

@HugoXK-bot HugoXK-bot removed the needs-review Waiting for the Fledge Platform Reviewer's issue review label Nov 22, 2026
@HugoXK

HugoXK commented Nov 22, 2026

Copy link
Copy Markdown
Owner Author

Security: PASS at e5f58ea

Replaces: 7557fb6

  • (1) Scope: stranded-log at .github/workflows/release.yml:483-500 declares issues: write alone at :489-490 — a job block replaces the workflow default at :14-15 — and the publish job's five scopes at :39-44 are byte-identical to 044c7515 (only outputs: at :47-48 is new), so no job gained a scope.
  • (2) The marker cannot be forged from fragment text: the output is the file-name set only (scripts/release-stranded-notes.mjs:50 gave names=999.fixed.md for a fragment whose body is the literal <!-- stranded-notes:… --> line plus an open fence), that body lands verbatim inside the appended section (scripts/lib/stranded-fragments.mjs:25-34), and :509 builds the marker from the tag and those names.
  • (3) Nothing evaluates it: the section is a concatenation (scripts/lib/stranded-fragments.mjs:25-34) published as bytes by --notes-file (:445), and the fragment set reaches the shell through env: (:492-493) and is quoted, so a name cannot inject a command.
  • (4) No double post: MARKER is compared with the last <!-- stranded-notes:-prefixed first line on release: daily minor release with the 10+/5+ rule #80 (:510-511); my own stub posted once across two runs of one tag, and the step fails closed when gh has no repository (exit 1) or no token (exit 4).
  • (5) Paths and ordering: ${RUNNER_TEMP}/release-notes.md at :72, :212, :408, :445 and no /tmp/release-notes.md left in the workflow; empty or missing notes exit 1 (scripts/release-stranded-notes.mjs:32-36), and :205-212 runs after the guard (:146) and before Build the image (:218); tree recomputed 23790d8483f457b1af252a11b870682682d3ec53, ci-ok green at this tip.

… step in the suite

The stranded-log job runs with no checkout, and gh resolves the repository for
`gh issue comment 80` from GH_REPO or a git remote: GITHUB_REPOSITORY is only an
expression this file builds the API path from, not a variable gh reads. So on the
night the job exists for it would have failed after the release was already
published — correct notes, no line on #80, red run. The job env now sets GH_REPO
to the repository, which both calls use.

The suite could not see it because it only matched the job's text. Two tests now
drive the Comment on #80 body with a stub gh that answers as the client does: an
API path needs no repository, an issue comment without GH_REPO, --repo or a token
fails. The first test posts and asserts gh received GH_REPO; the second proves a
re-run of one tag posts nothing. Against the pre-fix workflow the first fails on
the missing repository.

Refs #1207
The review at 7557fb6 asked for a test that drives the step body rather than
one that matches the job's text, so the failure a future removal produces is the
one the job would produce: with the pre-fix workflow this test stops on
`gh: could not determine base repo; set GH_REPO or --repo`, not on a missing
string in release.yml.

Refs #1207
@HugoXK
HugoXK merged commit 3f24965 into main Nov 22, 2026
40 of 41 checks passed
@HugoXK
HugoXK deleted the dev2/1207-stranded-notes branch November 22, 2026 08:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent-pr area:deploy Deploy, backup, logs, systemd bug Something isn't working review:approved Issue reviewed and approved by the Fledge Platform Reviewer risk:T3

Projects

None yet

Development

Successfully merging this pull request may close these issues.

release: a tag's notes omit every change merged while its release pull request waited

2 participants