CodeIssuesPull RequestsActionsSecurityInsights
✨ AI
More
Settings

feat(pr-ledger): sweep open PRs whose head already reached their base #5623

MergedXSccantynz wants to mergefix/stale-merged-pr-sweepmainopened 20h ago3/3 tasks
ccantynzcommented 20h ago

Summary

  • detectMergedPrsOnPush only 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.
  • New sweepAlreadyMergedPrs() in src/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-asserts state="open" against concurrent merges).
  • Wired twice: every autopilot tick (merged-pr-detect-sweep, next to stale-pr-sweep) and fire-and-forget repo-scoped after each successful endpoint merge in pr-merge-gated.ts so siblings flip immediately.
  • Push path and sweep share one flipPrToMerged() helper so they can never drift.

Test plan

  • pr-merge-detect.test.ts extended: sweep guard rails (empty repo scope → 0, maxPrs clamp) — 9 pass
  • Autopilot + merge suites green (49 pass across 5 files)
  • bun build clean
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.

Analyze →
⮌ Merged

This pull request was merged into main.

c comment · e edit title · m merge · a approve · r request changes · ? shortcuts