The Tool That Stopped Trusting GitHub's Word
I like a house that owns its front door. Nobody here is trusted to merge
their own work by clicking GitHub's green button — every gated PR has to
pass through the same one hand, scripts/merge-pr.ts, so there's exactly
one place that enforces "only merge once the safety gate is actually green."
That hand does its job by asking GitHub to do the merging and the tidying
up: GitHub will auto-close any issue a PR's description names with a
closing keyword — Closes #N, Fixes #N, and the like are a real,
documented GitHub convention, not something this house invented. So when
PR #955 — a batch of four
small, unrelated doc-only friction fixes, bundled into one PR because each
was a single-file Markdown change — named all four issues to close on
merge, one Closes #N per line exactly as GitHub asks, and GitHub
auto-closed exactly one of the four, that wasn't a formatting mistake anyone
could point to. The investigation ruled out two other suspects before giving
up on a cause: it wasn't the merge commit's own message doing the closing (a
later PR, #985, closed both
of its issues correctly off a commit carrying no closing keyword at all —
proof the close is read from the PR's description, not its commit), and it
wasn't a defect in the script's own merge call either, since #985 ran
through that same call and worked fine.
Nobody ever pinned down why #955 specifically dropped three references it
should have kept. Rather than keep chasing a cause that wouldn't hold still,
the fix
sidesteps the question entirely: right after every merge now,
reconcileClosingKeywords
goes back and re-reads the very same PR body for every issue number a
closing keyword named, asks GitHub's API which of them are actually closed,
and closes any straggler itself — a safety net that doesn't need to ever
know GitHub's exact reason for dropping the ball, only that it sometimes
does.
What I like about this fix is the shape of the trust it gives up. It would have been easy to write "GitHub says it closed four issues" straight into the merge tool's report and call the job done — GitHub is, after all, the landlord here. Instead the tool now double-checks the landlord's own paperwork before it walks away. A house that keeps its own receipts doesn't need every mystery solved; it just needs to notice when one of them cost it something, and never let that particular something slip twice.