feat(review): add a public weekly review-accuracy trend (#4447) - #4655
Merged
Conversation
Extends GET /v1/public/stats with accuracyTrend: 8 trailing weeks of the SAME reversal-grounded formula the live totals.accuracyPct already uses (1 - reversed/(merged+closed)), so the trend and the live headline number can never silently diverge into two competing definitions of "accuracy". Deliberately not a cron/rollup table, despite the parent issue describing one: audit_events, pull_requests, and orb_pr_outcomes are already durable, so a live day-bucketed re-query of those same rows (folded into weekly buckets, mirroring the sibling per-repo quality trend in public-quality-metrics.ts from #2568) can recompute any historical week correctly on every request -- no cron-miss gap risk, and no second copy of the number that could drift out of sync with the live one. There is nothing to persist, so there is no follow-up rollup job to land later. A week with fewer than MIN_ACCURACY_TREND_SAMPLE decided PRs reports accuracyPct: null rather than a misleading percentage. Part of epic #4445's #4447 (review-accuracy as a historical trend). Only the homepage trend-chart visualization the issue also describes is deferred to a follow-up PR, matching the capture-then-extend split already used for the epic's #4446 slice.
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
gittensory-ui | 063cc59 | Commit Preview URL Branch Preview URL |
Jul 10 2026, 09:35 AM |
6 tasks
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4655 +/- ##
=======================================
Coverage 94.11% 94.12%
=======================================
Files 433 434 +1
Lines 38494 38542 +48
Branches 14037 14047 +10
=======================================
+ Hits 36229 36277 +48
Misses 1604 1604
Partials 661 661
🚀 New features to boost your workflow:
|
This was referenced Jul 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
GET /v1/public/statswithaccuracyTrend: 8 trailing weeks of the SAME reversal-grounded formula the livetotals.accuracyPctalready uses (1 - reversed/(merged+closed)), so the trend and the live headline number can never silently diverge into two competing definitions of "accuracy".audit_events,pull_requests, andorb_pr_outcomesare already durable, so a live day-bucketed re-query of those same rows (folded into weekly buckets) can recompute any historical week correctly on every request — no cron-miss gap risk, and no second copy of the number that could drift out of sync with the live one. This mirrors the sibling per-repo quality trend already shipped inpublic-quality-metrics.ts(feat(site): add a public per-repo review-quality leaderboard #2568), which solves the exact same "public weekly trend from durable historical rows" problem the same way.MIN_ACCURACY_TREND_SAMPLEdecided PRs reportsaccuracyPct: nullrather than a misleading percentage (mirrors the sibling trend's ownMIN_GATE_TREND_SAMPLEguard).src/services/public-accuracy-trend.ts: a purebuildPublicAccuracyTrend(bucketing/guard logic) plus an I/OloadPublicAccuracyTrend(day-bucketed SQL over the same three tablesgetPublicStatsalready reads). Composed at the route layer (not insidegetPublicStatsitself) to avoid a circular import between the two modules.Scope
type(scope): short summaryConventional Commit format.CONTRIBUTING.mdand does not reintroduce GitHub Pages, VitePress,site/, orCNAME.Validation
git diff --checknpm run actionlintnpm run typechecknpm run test:coveragelocally — 100% line/branch coverage onsrc/services/public-accuracy-trend.ts(28/28 branches); the 2 pre-existing uncovered branches reported forsrc/review/public-stats.tspredate this diff (my only change there is exporting 3 already-covered declarations) and are outside this PR's changed linesnpm 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=moderate— 0 vulnerabilitiesaudit_events/pull_requests/orb_pr_outcomesrows, plus a route-level shape assertionSafety
PublicStatsSchemaextended withaccuracyTrend, regenerated vianpm run ui:openapi, settings-parity checked.UI Evidencesection. — N/A, backend-only change, no visible UI.Notes
computeGateEval(parity.ts) instead, per the issue's literal wording, but that reads only this worker's OWNreview_auditledger — it has no way to represent the registered Orb-fleet volume the live homepage number already folds in (getOrbGlobalStats), so building the trend from it would have made the trend a narrower, inconsistent subset of what the live number represents. Reusing the live number's own formula/scope avoids that regression.