-
Notifications
You must be signed in to change notification settings - Fork 0
fix(review-gate): accept regeneration rewrites on the generated release branch #343
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -222,6 +222,30 @@ function untraceableRewriteError() { | |
| ); | ||
| } | ||
|
|
||
| // Release Please regenerates its release branch by force-pushing it, and GitHub records | ||
| // those rewrites with no `before_commit_id`, so they are untraceable by the check below. | ||
| // | ||
| // The continuity check exists so a rewrite cannot replace human-reviewed code without a | ||
| // trace. A generated release branch has no such state to protect: the bot rebuilds the | ||
| // branch from the base branch on every upstream merge, so a rewrite discards only content | ||
| // the next run reproduces. Without this, a release pull request becomes unmergeable as | ||
| // soon as anything lands on the base branch, which blocked v0.6.0 entirely (#342). | ||
| // | ||
| // Deliberately narrow, and evidence-based rather than name-based. A branch name alone is | ||
| // not evidence, because anyone who can push may choose one. Both must hold: | ||
| // - the head branch is release-please's generated name for *this* pull request's base, | ||
| // - the pull request is authored by a bot. | ||
| // A human branch named to look generated fails the second condition, and a bot pull | ||
| // request from an ordinary branch fails the first. | ||
| function isGeneratedReleasePullRequest(pr) { | ||
| const baseRef = pr?.base?.ref; | ||
| const headRef = pr?.head?.ref; | ||
| if (typeof baseRef !== "string" || baseRef.length === 0) return false; | ||
| if (typeof headRef !== "string") return false; | ||
| if (String(pr?.user?.type ?? "").toLowerCase() !== "bot") return false; | ||
| return headRef.startsWith(`release-please--branches--${baseRef}--components--`); | ||
| } | ||
|
|
||
| function loadLatestDurableReviewState(pr) { | ||
| const { priorHeads: forcePushedPriorShas, hasUntraceableRewrite } = loadForcePushedPriorShas( | ||
| pr.number, | ||
|
|
@@ -230,7 +254,13 @@ function loadLatestDurableReviewState(pr) { | |
| // commit cannot contain a finding that was observed and then deleted only on the head this | ||
| // rewrite discarded, so returning it would publish success while losing that ask. Continuity | ||
| // across a null `before_commit_id` cannot be proved, so no reachable state is trustworthy here. | ||
| if (hasUntraceableRewrite) throw untraceableRewriteError(); | ||
| if (hasUntraceableRewrite) { | ||
| if (!isGeneratedReleasePullRequest(pr)) throw untraceableRewriteError(); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Even when Release Please legitimately performs this rewrite, exempting it discards the exact state the continuity guard protects: if the scheduled check persisted an open finding on the release PR and that comment is subsequently deleted, the null AGENTS.md reference: AGENTS.md:L94-L97 Useful? React with 👍 / 👎. |
||
| // Logged, never silent: an exemption nobody can see is one nobody can audit. | ||
| console.log( | ||
| `Accepting an untraceable rewrite on generated release branch ${pr.head.ref}: its contents are regenerated from ${pr.base.ref} rather than carried across review.`, | ||
| ); | ||
| } | ||
| const currentPrShas = loadCurrentPrCommitShas(pr); | ||
| const currentPrShaSet = new Set(currentPrShas); | ||
| const pendingShas = [...currentPrShas, ...forcePushedPriorShas]; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pr.user.typeidentifies who originally opened the pull request, not who performed a later force-push. Once Release Please creates this PR, a maintainer or unrelated bot can rewrite its generated-named branch and this predicate still grants the exemption; when GitHub omitsbefore_commit_id, the gate can then seed from the rewritten history and lose an orphaned durable finding. Authenticate the rewrite as trusted Release Please automation rather than relying on the PR creator's persistent type.AGENTS.md reference: AGENTS.md:L90-L92
Useful? React with 👍 / 👎.