Repository navigation
feat(mq): merge-queue v2 step 4 - landing loop and closure audit (dormant behind --land) - #4698
Merged
Merged
Conversation
- landing.py: 2-probe elevation lapse rule, lease estimate, pre-merge tree/head/base checks, gh pr merge --merge --admin --match-head-commit with bounded retry on rule violations, post-merge parents and proven-tree check, HALT on drift or external merge, one needs_input per lapse, one ejection notice per red-train member - closure.py: closingIssuesReferences vs ticket fixes; post-merge close/reopen; stacked-PR retarget - runner: --land flag (default shadow); ShadowApi refuses PATCH; LANDED state Fixes #4690 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Daniel Meppiel (danielmeppiel)
requested a review
from Sergio Sisternes (sergio-sisternes-epam)
as a code owner
November 21, 2026 21:20
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved critical issues can land trains out of order, trigger false drift halts, lose merge recovery records, and allow merges without valid tickets or the required clean closure audit.
9 open issues
Handle admin probe failures as negative observations · New Block landing when the admitted ticket is no longer valid · New Require a clean closure audit before merging · New Include unlanded GREEN trains in speculative build dependencies · New Journal merge intent and checkpoint completed merges · New Prevent GREEN trains from bypassing earlier TESTING predecessors · New Verify extra issue closures were caused by this landing · New Check PATCH responses and retain failed closure repairs · New Notify RED train ejections while landing is halted · New
What changed in this PR
Adds the opt-in landing stage for merge-queue v2, extending the existing shadow runner with administrative merges and post-merge issue repair. Landing remains disabled unless --land is supplied; live acceptance follows a separate activation gate.
Changes:
- Adds ordered landing, elevation checks, merge verification, persistent HALT records, and notification hooks.
- Adds closure auditing, deferred issue repair, stacked-PR retargeting, and landing-state tracking.
- Extends simulated GitHub tests, shadow-write protection, and contributor documentation.
| File | Description |
|---|---|
tests/unit/scripts/merge_queue/test_runner.py |
Tests shadow-mode PATCH rejection. |
tests/unit/scripts/merge_queue/test_landing.py |
Tests landing, lapse recovery, HALTs, and closure repair. |
tests/unit/scripts/merge_queue/_fake_api.py |
Adds simulated PATCH responses and call tracking. |
scripts/merge_queue/state.py |
Adds landed states, merged-member tracking, and backlog selection. |
scripts/merge_queue/runner.py |
Wires opt-in landing into runner ticks. |
scripts/merge_queue/landing.py |
Implements merge checks, elevation handling, recovery state, and hooks. |
scripts/merge_queue/closure.py |
Audits issue references, repairs closures, and retargets stacked PRs. |
scripts/merge_queue/api.py |
Adds PATCH support to the API abstraction. |
docs/src/content/docs/contributing/integration-testing.md |
Documents opt-in landing and its safeguards. |
Review effort: Balanced
- probe: a failed admin request is a failed probe (lapse rule), not a crash - preflight: every unlanded member needs a valid ticket at its proven head and a clean closure audit (closingIssuesReferences + commit keywords == fixes); else the train is ejected unmerged (or HALTs if partly landed) - intent journal: checkpoint before and after each merge; a crash in between is recovered on the next tick instead of reading as external drift - backlog stops at the first TESTING train; with --land new trains stack on unlanded GREEN trains (State.chain) - closure writes are checked; failed ones stay pending and retry - ejection notices are emitted even while landing is halted Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Merged
5 of 9 tasks
Merged
3 of 10 tasks
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.


Description
This is merge-queue v2 step 4: the landing loop and the closure audit. Landing is dormant by default: the runner stays shadow-only unless it is started with
--land. Turning landing on is a separate maintainer gate, after the v0.38.0 tag and the step-3 shadow acceptance.scripts/merge_queue/:landing.pyadmin-merges GREEN trains in launch order, one member at a time.needs-inputevent. The first good probe after that resumes landing and drains the backlog in order. Trains keep testing throughout.main_seen);gh pr merge --merge --admin --match-head-commit <proven head>. It retries up to 3 times on rule-violation responses, then pauses; it never halts on those.(old main, head)and the proven tree T_k, and it is main's head.landing.jsonuntil a human clears it. Trains keep testing.needs-inputevent per lapse, and oneejection-noticeevent (with a comment body for autopilot-comment) per member of a red train.closure.pyand the landing preflight:closingIssuesReferencesplus closing keywords in the PR's commit messages) must equal the ticket'sfixes. Every unlanded member also needs a valid ticket at its proven head.recover()reconciles an outstanding intent against GitHub on the next tick.--land, new trains stack on proven trains that have not landed yet (State.chain).runner.py:--landflag. Train building still goes throughShadowApi, which now also refuses PATCH.LANDEDstate (GREEN -> LANDED or ABORTED) andMember.merged.api.py: addspatch.Docs: one paragraph in
integration-testing.md(Merge-train proof).Issue and approved scope
Issue: Fixes #4690 (merge-queue v2 step 4; follows step 3 #4671)
Human scope-approval comment: #4690 (comment)
Does this PR complete the issue, or what remains? It delivers the code, with landing off by default. The live acceptance criteria are checked after activation, a separate gate that comes after the v0.38.0 tag and the step-3 acceptance:
The unit tests below already cover each of these behaviours against a simulated GitHub.
Type of change
Testing
Tested locally
All existing tests pass
Added tests for new functionality (if applicable)
test_landing.pyruns against a simulated GitHub. It covers:--land;test_runner.pyadds: with--land, new trains stack on an unlanded GREEN train; the shadow guard refuses PATCH.After the review fixes,
test_landing.pyandtest_runner.pypass locally (41 tests, via the host guard).Static checks, all clean:
check_complexity_ratchet.py --base-ref main;check_test_assertions.py;tests.quality.taxonomy --changed;Changelog
changelog.d/<pr>.<section>.md, holdingone line: user-visible effect first, 25 words or fewer, ending with
(#PR); breaking changes only under upgrade notes; no Highlights; nonew lines under
## [Unreleased]. Seechangelog.d/README.mdand.github/instructions/changelog.instructions.md.Spec conformance (OpenAPM v0.1)
N/A: no
req-XXXbehaviour changes.