feat(pr-ledger): sweep open PRs whose head already reached their base #5623
ccantynzAI Reviewcommented 20h ago
AI Triage
(no summary)
Priority: medium Risk area: mixed
Suggested labels: (no label suggestions) Suggested reviewers: (no reviewer suggestions)
Suggestions only — nothing has been applied. The PR author stays in control.
gluecron[bot]🤖 botAI Reviewcommented 20h ago
AI review unavailable
The platform's AI balance is exhausted, so AI generation is temporarily unavailable. Nothing was lost. You can queue this as a repair for the internal agent from the repository's Health page, or try again once the balance is restored. The PR is otherwise unchanged.
Cross-repo impact
See what breaks downstream if this PR merges.
⮌ Merged
This pull request was merged into main.
c comment · e edit title · m merge · a approve · r request changes · ? shortcuts
Summary
detectMergedPrsOnPushonly fires in post-receive, but a server-side endpoint merge advances the base ref without a push — so sibling open PRs whose heads just became reachable stayed "open" forever. Founding case: #5607 sat open 2 days with its head an ancestor of main; "merging" it was pure bookkeeping.sweepAlreadyMergedPrs()insrc/lib/pr-merge-detect.ts: reachability-only detection over open PRs (capped 200/tick, base tips cached per repo+branch, deleted head branches untouched, flip re-assertsstate="open"against concurrent merges).merged-pr-detect-sweep, next to stale-pr-sweep) and fire-and-forget repo-scoped after each successful endpoint merge inpr-merge-gated.tsso siblings flip immediately.flipPrToMerged()helper so they can never drift.Test plan
pr-merge-detect.test.tsextended: sweep guard rails (empty repo scope → 0, maxPrs clamp) — 9 passbun buildclean