feat(review): add fast open-PR reconciliation to catch silently-lost webhooks#3840
Conversation
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
|
Warning 🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨 ⏸️ Gittensory review result - manual review recommendedReview updated: 2026-07-07 02:28:46 UTC
⏸️ Suggested Action - Manual Review
Review summary Nits — 7 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 #3840 +/- ##
==========================================
+ Coverage 93.56% 93.57% +0.01%
==========================================
Files 339 340 +1
Lines 33445 33508 +63
Branches 12242 12255 +13
==========================================
+ Hits 31292 31355 +63
Misses 1528 1528
Partials 625 625
🚀 New features to boost your workflow:
|
b39d5f1 to
79e925e
Compare
…webhooks (#3812) Two contributor PRs had zero trace anywhere (no audit event, no local row) for roughly two hours before a manually-forced sweep's open-PR discovery side effect happened to surface them. The only organic re-discovery path skips any repo whose sync is "fresh" (up to 6 hours), so a silently-lost "PR opened" webhook could go unnoticed far too long. Add a dedicated, much tighter reconciliation (flag-gated, default OFF, every 10 minutes): a cheap list-only GitHub read diffed against the local pull_requests table for every acting-autonomy repo. On divergence, immediately catch up each missing PR number through the exact same pipeline a real webhook would have used -- fetch full details, upsert, and enqueue a normal regate -- instead of waiting on the opportunistic 6-hour backfill. Fails safe at every level: a catch-up failure, a per-repo scan error, and a total scan failure are all logged and swallowed rather than lost or thrown into the queue.
79e925e to
8105190
Compare
…CHDOG was missing)
Summary
Closes #3812 (the new-capability deliverable; the two adjacent zero-trace bug fixes from the same issue already shipped separately).
pull_requestsrow — for ~2 hours on 2026-07-06, until an operator manually forced a sweep whose open-PR discovery side effect happened to surface them. The only organic re-discovery path,backfillRegisteredRepositories, skips any repo whose sync is "fresh" (up to 6 hours), so a silently-lost webhook could go unnoticed for hours.GITTENSORY_PR_RECONCILIATION, default OFF, every 10 minutes): a cheap list-only GitHub read (GET /pulls?state=open, PR numbers only — never a full detail fetch) diffed against the localpull_requeststable for every acting-autonomy repo (the same repo-selectionfanOutAgentRegateSweepJobsuses).open_pr_reconciliation_divergencelog (Sentry-visible) and agittensory_open_pr_reconciliation_missing_total{repo=...}counter, then immediately catches up every missing PR number — fetches its full live payload, upserts it, and enqueues a normalagent-regate-prjob, i.e. the exact same pipeline a real "PR opened" webhook would have fed it into (reviewed, labeled, gated like any other PR).#sweep-uninstalled-budget-waste) since it can never get a per-PR fan-out regardless.reconcile-open-prsjob type, wired end-to-end:types.ts,wrangler.jsonc/worker-configuration.d.ts(new flag, regenerated viacf-typegen),env.d.ts(widened test/runtime override, matching every other togglable flag),src/index.ts(10-minute cron enqueue, flag-gated),src/queue/processors.ts(job handler),src/selfhost/maintenance-admission.ts(registered as a deferrable maintenance job type).reconcileOpenPullRequests(the list-diff itself) lives insrc/github/backfill.ts, reusing that file's existing low-level GitHub-fetch primitives (githubJsonWithHeaders,hasNextPage,repoAdmissionKeyForToken) rather than introducing new ones.Scope
type(scope): short summaryConventional Commit format, for examplefix(api): restore profile access checks.CONTRIBUTING.mdand does not reintroduce GitHub Pages, VitePress,site/, orCNAME.Validation
git diff --checknpm run actionlintnpm run typechecknpm run test:coveragelocally;codecov/patchrequires ≥99% coverage of the lines AND branches you changed (aim for 100% on your diff so CI variance does not fail near the threshold). Global coverage is a non-blocking trend with a loose 90% backstop, not the gate.npm run test:workersnpm run build:mcpnpm run test:mcp-packnpm run ui:openapi:checknpm run ui:lintnpm run ui:typechecknpm run ui:buildnpm audit --audit-level=moderateSafety
UI Evidencesection below. (N/A — no visible UI change.)Notes
*-wire.tspattern) — this PR's deploy is byte-identical until the flag is explicitly set.