perf(review): early-exit the re-review when a swept PR is already closed on GitHub - #2000
Conversation
…sed on GitHub reReviewStoredPullRequest only checked the STORED state, then spent GitHub budget resyncing files + running readiness/CI reads + re-reviewing even for a PR already closed/merged on GitHub (a dropped `closed` webhook while the relay was down). After the single memoized fetchLivePullRequest, early-exit on a live NON-open state: upsert the live payload to reconcile the stored row, then return before the files + CI reads + review. Reconciling the row lets the next sweep skip it via the existing stored-state guard. Fail-open: only a live non-open state early-exits. Advances #1936.
|
Warning 🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨 ⏸️ Gittensory review result - manual review recommendedReview updated: 2026-07-01 07:22:24 UTC
⏸️ Suggested Action - Manual Review
Review summary Nits — 5 non-blocking
Review context
Contributor next steps
Signal definitions
🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed 💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →. Checked by Gittensory, a quiet PR intelligence layer for OSS maintainers.
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2000 +/- ##
==========================================
- Coverage 95.66% 95.66% -0.01%
==========================================
Files 220 220
Lines 24453 24456 +3
Branches 8868 8869 +1
==========================================
+ Hits 23394 23395 +1
Misses 436 436
- Partials 623 625 +2
🚀 New features to boost your workflow:
|
Summary
When the re-gate sweep re-reviews a stored-open PR, it only checked the stored state, then spent GitHub budget resyncing files, running the readiness/CI reads, and re-reviewing — even for a PR that is already closed/merged on GitHub (a
closedwebhook the self-host relay dropped while it was down).reReviewStoredPullRequestnow early-exits on the live terminal state, right after the single memoizedfetchLivePullRequest:refreshPullRequestDetails(the/pulls/{n}/filesreads),prReadyForReview(the/commits/{sha}/…CI reads), and the review/publish path;Fail-open: only a live non-open state early-exits — a fetch hiccup leaves
liveundefined and the sweep proceeds with the stored open PR exactly as before.This is the rec #13 half of the #1942 audit ("a job already known to be stale exits before expensive GitHub reads"). Advances #1936. (Rec #12 — the
currentRegateBacklogCOUNT — is a separate follow-up: that path has since moved onto the queuesnapshot()binding, so it needs re-scoping rather than the audit's original edit.)Scope
reReviewStoredPullRequest; no signature or config change.Validation
git diff --checknpm run typechecknpm run test:coverage— new sweep test: a PR closed on GitHub reconciles the stored row toclosed, and makes no/filesor/commitsreads (early-exit); the existing drift / no-drift resync tests still pass.npm run test:cinpm audit --audit-level=moderateSafety