fix(github): re-open the merge gate when an apply terminalizes on a superseded commit - #969
Draft
aparajon wants to merge 2 commits into
Draft
fix(github): re-open the merge gate when an apply terminalizes on a superseded commit#969aparajon wants to merge 2 commits into
aparajon wants to merge 2 commits into
Conversation
…uperseded commit A stored check row recorded for a commit the PR has moved past contributes a blocking placeholder to the aggregate, because results computed for one commit say nothing about another. Nothing re-keys that row on its own: the push that moved the head declined to overwrite it while an apply owned it, and the fold that follows the apply reaching a terminal state re-publishes the same placeholder over the same stale row. A plan on the current commit is the only action that records results for it. The terminal refresh now re-plans on the PR's current commit instead of folding on the superseded one. It refuses while any apply on the PR is non-terminal, so a started apply stays authoritative for its PR's check state, and refuses on storage uncertainty for the same reason; both refusals leave the gate blocking. A closed PR is left to close-time cleanup. The blocking placeholder itself now names its exit — the plan command that records results for the commit — and logs a warning with a metric when no apply is running on any commit, which is the shape only an operator can clear. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses a merge-gate deadlock where a terminal apply can leave its stored check row keyed to a superseded commit, causing the aggregate check to remain blocked indefinitely even though the PR head has advanced. It introduces an automatic re-plan on the PR’s current head when this condition is detected, and improves aggregate messaging/telemetry to make the “stale rows with no running work” condition actionable for operators.
Changes:
- Add a terminal-apply hook that detects a superseded stored check head and triggers an auto-plan on the PR’s current head, while refusing to run if any apply on the PR is still non-terminal.
- Improve aggregate Check Run title/summary when stale rows block the latest commit, including explicit operator command guidance and additional warning telemetry.
- Add integration tests covering the stale-gate replan path and its safety deferrals (in-flight apply; already-current head).
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| pkg/webhook/stale_gate_replan.go | Adds the terminal-apply superseded-head detection and auto-plan replan mechanism. |
| pkg/webhook/stale_gate_replan_integration_test.go | Integration coverage for re-keying behavior and safety stand-down conditions. |
| pkg/webhook/handler.go | Hooks the replan into the terminal-apply refresh path before folding the aggregate. |
| pkg/webhook/check_publisher.go | Enhances aggregate placeholder summary/title and adds warning telemetry for “stale + no running work”. |
| pkg/webhook/check_aggregate.go | Updates placeholder title, adds summary helper, and introduces an “any in progress on any commit” helper. |
| pkg/webhook/check_aggregate_test.go | Adds tests for the new helper and summary formatting. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
The superseded-head re-plan recorded a success before the plan dispatch ran and dropped the error the dispatch returned. A re-plan that fails leaves the merge gate blocked on the superseded commit, which is the condition the metric exists to surface, so it read as healthy exactly when it was not. The metric now records after the dispatch and takes its status from the outcome, and a failed re-plan logs at error level with the head sha the gate is stuck on. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why this matters
An apply that finishes after its PR has moved on leaves its stored check row pinned to the commit it ran against. That row folds into the aggregate as a blocking placeholder, and nothing re-keys it: the push that moved the head left the row alone because an apply still owned it, and folding again on the superseded commit only republishes the same placeholder. The gate stays shut with no operator command that can open it.
What it does
🤖 Generated with Claude Code