Orphaned-PR check
Operator-facing reference for the periodic orphaned-PR maintenance pass.
The mill runs background maintenance passes on a schedule, one per registered repo. Each pass is config-gated and respects dry-run mode.
Overview
Detects open PRs on managed repos with no active mill ticket driving them and either auto-closes obsolete ones or files a tracking ticket.
Enabling. Opt-in — default false. Set
orphaned_pr_check.enabled to true in config/config.yaml.
Dry-run. Default true (safe). Logs all actions but makes no forge
mutations. Set orphaned_pr_check.dry_run to false for real closes and
ticket filing. Every log line carries dry_run=true/false.
Age guard. A PR whose tracking ticket was created within
orphaned_pr_check.min_age_hours (default 4 hours) is silently
skipped to avoid racing the deliver stage.
Action cap. orphaned_pr_check.max_actions_per_pass (default 5) caps
combined close + file-ticket actions per pass. Findings beyond the cap are
deferred to the next pass; the remaining count is logged at INFO.
Per-type sub-caps orphaned_pr_check.max_closes_per_pass and
orphaned_pr_check.max_files_per_pass enforce independently alongside the
combined cap.
Author & branch guard. Only branches matching settings.branch_prefix
are evaluated. Human-authored PRs are never touched. The author check
uses orphaned_pr_check.bot_logins (explicit bot login list) or falls
back to get_authenticated_user_login(); when both resolve empty the
author check is skipped with a WARNING (fail-open) while the
branch-prefix filter remains active.
Classification & actions
Each orphaned mill PR lands in one of two buckets:
- Auto-close — empty diff, ticket DONE/CLOSED (merged-equivalent or conflicting), no-ticket empty diff, no-ticket conflicting, errored + empty diff, errored + conflicting. A forge comment explains the reason; the PR is then closed.
- File tracking ticket — non-empty, non-conflicting diff with no
active ticket (
NO_TICKET) or an errored ticket (TICKET_ERRORED). Files a ticket titledTrack orphaned PR: <repo_id>/<branch>, routed viaSourceKind.ORPHANED_PR_CHECK.
Foreign (non-board) PR tracking
By default the pass only considers board-authored PRs (branch starts
with settings.branch_prefix, e.g. mill/). Set
orphaned_pr_check.track_foreign_prs to true (default false,
opt-in) to also file a tracking ticket for foreign PRs — open PRs
whose head branch does not start with the branch prefix (e.g. a human
feature/* branch or a fleet agent's fix/* branch).
- Foreign PRs whose head branch starts with one of
orphaned_pr_check.foreign_ignore_branch_prefixes(defaultdependabot/,renovate/,release-please--,pin-bump/,bump/,deps/) are ignored outright — no ticket is filed and they do not consume the per-pass caps. Those PRs are owned by other automation (the weekly repo-hygiene periodic merges dependency and pin bumps, the release periodic gates release-please PRs); tracking them here would duplicate that work and flood the board with drafts (55 drafts in one pass on 2026-09-09 when the flag was first enabled fleet-wide). They are logged asaction=IGNORED_PREFIX. Set the list to[]to track every foreign PR. - Foreign PRs are never closed — they are external, so the board decides what to do. The pass only files a tracking ticket.
- The tracking ticket uses a deterministic, idempotent title
Track external PR: <repo_id>#<pr_number>(falling back toTrack external PR: <repo_id>/<branch>when the forge dict lacks a PR number), routed viaSourceKind.ORPHANED_PR_CHECK. A second pass is a no-op — the title is de-duped against allORPHANED_PR_CHECKtickets, terminal ones included, so a tracking ticket the board markeddoneorclosedkeeps its PR suppressed. - The ticket body carries the PR number, URL, author login, branch and title, plus a one-line instruction to review-and-merge or close.
- Foreign file-ticket actions count against the same
max_files_per_passand combinedmax_actions_per_passcaps as the board-PR actions; the mill-PR phase runs first, so its actions consume the shared budget before foreign PRs are considered. Deferred foreign PRs are logged and re-considered next pass. - Requires
forge.list_open_prs()to return per-PR metadata (branch, author_login, number, url, title). GitHub and GitLab both provide it; forges that fall back tolist_open_pr_branches(no metadata) do not process foreign PRs.
Auto-disposition of foreign PRs
Set orphaned_pr_check.auto_dispose_foreign_prs to true (default
false, opt-in) to stop filing one human-gate tracking shell per
external PR. When enabled, the foreign-PR phase (which also runs when
track_foreign_prs is on) disposes each candidate PR instead of
filing a per-PR ticket:
- Green → merge. The pass reads the PR's live CI conclusion
(
forge.check_status) and mergeability (forge.pr_status). A PR that is open, conflict-free (mergeable is True) and whose CI concludedsuccessis merged directly via the standard merge path (forge.merge_pr) — no human-gate shell is created. Green merges count against the combinedmax_actions_per_passcap; a green PR deferred by the cap is folded into the digest instead. - Red / conflicted / ambiguous → one daily digest. Every PR that is
not confirmed green (failing/pending/absent CI, merge conflicts,
mergeability not yet computed, or a merge that failed) is consolidated
into a single digest ticket per board per day, titled
External PR review digest: <repo_id> <YYYY-MM-DD>and routed viaSourceKind.ORPHANED_PR_CHECK. The body lists each PR with its number, URL, author, branch and the reason it needs review. The deterministic per-day title de-dupes against allORPHANED_PR_CHECKtickets, so a second pass the same day is a no-op. The human gate therefore sees at most one external-PR tracking ticket per board. - Legacy shells collapsed. Any still-open per-PR
Track external PR: <repo_id>#<n>shell from the pre-auto-dispose behaviour is auto-closed (service.close_tracker) and folded into the digest, draining the existing backlog on the next run. Shells whose PR has already merged or closed on the forge are also auto-closed by the existing reconcile pass. - Dry-run safe. Under
dry_runthe pass logsaction=MERGE,action=DIGEST,action=FILE_DIGESTandaction=DRY_RUN_COLLAPSEintent lines but performs no merges, ticket creation, or tracker closes.
Idempotency
A second pass is a no-op: PRs already closed on the forge are skipped
(forge pr_status check); already-filed tracking tickets are detected by
the deterministic title Track orphaned PR: <repo_id>/<branch> (board
PRs) or Track external PR: <repo_id>#<pr_number> (foreign PRs), queried
as SourceKind.ORPHANED_PR_CHECK tickets not in a terminal state.
Logging
Every action (or would-be action under dry-run) is logged at INFO with
structured fields:
repo=<repo_id> branch=<branch> ticket_state=<state|NOT_FOUND>
action=<CLOSE|FILE_TICKET|DEDUP_SKIP> classification=<reason>
dry_run=<true|false>
Config example
From config/config.example.yaml:
periodic:
orphaned_pr_check:
enabled: false # opt-in: enable periodic orphaned-PR check passes
interval_seconds: 86400 # seconds between passes (min 3600 enforced in worker)
min_age_hours: 4 # minimum ticket age before PR is considered orphaned
max_actions_per_pass: 5 # max combined close+file actions per pass
dry_run: true # log intent only, no forge mutations
track_foreign_prs: false # also file tracking tickets for non-mill PRs (never closes them)
foreign_ignore_branch_prefixes: # foreign PRs owned by other automation — never tracked
- dependabot/
- renovate/
- release-please--
- pin-bump/
- bump/
- deps/