fix(orb): stop double-counting PRs already tracked by the own-ledger#5257
Conversation
getOrbGlobalStats folded in every registered Orb installation's outcomes unconditionally, re-counting PRs the frozen own-ledger (pull_requests + audit_events, frozen since the self-host cutover) already counted. Quantified: 243 PRs (173 merged + 70 closed, 96% in one repo), inflating the public homepage's "PRs reviewed" and "Decision accuracy" tiles. Adds a NOT EXISTS anti-join so orb_pr_outcomes rows whose (repo, pr_number) already has a github_app.pr_public_surface_published audit event are excluded — the two sums are now over disjoint PR sets. No data loss: the own-ledger side is untouched, and no backfill is needed since the two sources' actual PR-number ranges barely overlap outside the double-counted set.
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5257 +/- ##
=======================================
Coverage 94.27% 94.27%
=======================================
Files 474 474
Lines 40078 40078
Branches 14612 14612
=======================================
Hits 37782 37782
Misses 1609 1609
Partials 687 687
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
|
Warning 🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨 ⏸️ Gittensory review result - manual review recommendedReview updated: 2026-07-12 12:12:11 UTC
⏸️ Suggested Action - Manual Review
Review summary Blockers
Nits — 5 non-blocking
Concerns raised — review before merging
Review context
Contributor next steps
Signal definitions
[BETA] Chat with GittensoryAsk Gittensory a question about this PR directly in a comment — grounded only in the same cached, public-safe facts shown above, never a new claim.
Full command reference: https://gittensory.aethereal.dev/docs/gittensory-commands 🟩 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.
|
Summary
getOrbGlobalStats(src/orb/outcomes.ts) folds in every registered Orb installation'sorb_pr_outcomesunconditionally, re-counting PRs the frozen own-ledger (pull_requests+audit_events, frozen since the self-host cutover — the source App has since been fully deleted, so it can never grow again) already counted.merged/closed/accuracyPcton the live public endpoint.NOT EXISTSanti-join ingetOrbGlobalStats's SQL, skipping anyorb_pr_outcomesrow whose(repo, pr_number)already has agithub_app.pr_public_surface_publishedaudit event (the same event the own-ledger's disposition query itself reads). The two sums become strictly additive over disjoint PR sets — no new env var, no bind-parameter list, no schema change.public-stats.tsthat previously (incorrectly) characterized this as "a small, bounded double-count" — measured, it wasn't.orb_pr_outcomes) would have been the wrong fix: self-host's own Postgres andorb_pr_outcomesonly cover PRs since the ~06-27 cutover, while 3,244 of the 3,487 own-ledger PRs predate that window and exist nowhere else now that the source App is deleted — dropping the own-ledger would have under-counted by ~39%.Validation
npm run typechecktest/integration/orb-outcomes.test.ts— excludes a PR already counted by the own-ledger, still counts an unrelated onetest/unit/public-stats.test.ts(isDispositions) that would have wrongly matched the new anti-join's SQL textnpm run test:ci(full local gate, unsharded) — greengit diff)Safety
orb_pr_outcomesrows get summed.