Skip to content

feat(review): add a public weekly review-accuracy trend (#4447) - #4655

Merged
JSONbored merged 1 commit into
mainfrom
feat/review-accuracy-trend-4447
Jul 10, 2026
Merged

feat(review): add a public weekly review-accuracy trend (#4447)#4655
JSONbored merged 1 commit into
mainfrom
feat/review-accuracy-trend-4447

Conversation

@JSONbored

Copy link
Copy Markdown
Owner

Summary

  • 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's text 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) 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 in public-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.
  • A week with fewer than MIN_ACCURACY_TREND_SAMPLE decided PRs reports accuracyPct: null rather than a misleading percentage (mirrors the sibling trend's own MIN_GATE_TREND_SAMPLE guard).
  • New src/services/public-accuracy-trend.ts: a pure buildPublicAccuracyTrend (bucketing/guard logic) plus an I/O loadPublicAccuracyTrend (day-bucketed SQL over the same three tables getPublicStats already reads). Composed at the route layer (not inside getPublicStats itself) to avoid a circular import between the two modules.
  • Part of epic Epic: public, tracked-over-time benchmarks for gittensory's own review engine (speed, accuracy trend, efficiency) #4445's feat(stats): review-accuracy as a historical trend, not just a live snapshot #4447. 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 feat(stats): review turnaround-time tracking (webhook received → comment posted), public + historical #4446 slice (PR #4635).

Scope

Validation

  • git diff --check
  • npm run actionlint
  • npm run typecheck
  • npm run test:coverage locally — 100% line/branch coverage on src/services/public-accuracy-trend.ts (28/28 branches); the 2 pre-existing uncovered branches reported for src/review/public-stats.ts predate this diff (my only change there is exporting 3 already-covered declarations) and are outside this PR's changed lines
  • npm run test:workers
  • npm run build:mcp
  • npm run test:mcp-pack
  • npm run ui:openapi:check
  • npm run ui:lint
  • npm run ui:typecheck
  • npm run ui:build
  • npm audit --audit-level=moderate — 0 vulnerabilities
  • New or changed behavior has unit/integration tests for new branches, fallback paths, and sanitizer boundaries — pure-function tests (bucketing, MIN_SAMPLE guard, out-of-window/unparseable-day regressions, the reversed-exceeds-decided clamp) plus end-to-end integration tests seeding real audit_events/pull_requests/orb_pr_outcomes rows, plus a route-level shape assertion

Safety

  • No secrets, wallet details, hotkeys, coldkeys, user PATs, private keys, raw trust scores, private rankings, or private maintainer evidence are exposed.
  • Public GitHub text stays sanitized, low-noise, and does not imply compensation guarantees or optimization tactics.
  • Auth, cookie, CORS, GitHub App, Cloudflare, or session changes include negative-path tests. — N/A, no auth/session surface touched.
  • API/OpenAPI/MCP behavior is updated and tested where needed — PublicStatsSchema extended with accuracyTrend, regenerated via npm run ui:openapi, settings-parity checked.
  • UI changes use live API data or real empty/error/loading states, not production mock/demo fallbacks. — N/A, backend-only change (no frontend chart in this slice).
  • Visible UI changes include a UI Evidence section. — N/A, backend-only change, no visible UI.
  • Public docs/changelogs are updated where needed. — N/A, no changelog edits in a normal PR; the trend has no public docs yet since there's no chart consuming it until the follow-up PR.

Notes

  • Considered snapshotting computeGateEval (parity.ts) instead, per the issue's literal wording, but that reads only this worker's OWN review_audit ledger — 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.

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.
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

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

@JSONbored JSONbored linked an issue Jul 10, 2026 that may be closed by this pull request
6 tasks
@JSONbored JSONbored self-assigned this Jul 10, 2026
@JSONbored
JSONbored merged commit 07f74e8 into main Jul 10, 2026
9 checks passed
@JSONbored
JSONbored deleted the feat/review-accuracy-trend-4447 branch July 10, 2026 09:44
@codecov

codecov Bot commented Jul 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.12%. Comparing base (bda42f7) to head (063cc59).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

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           
Files with missing lines Coverage Δ
src/api/routes.ts 94.26% <100.00%> (ø)
src/openapi/schemas.ts 100.00% <ø> (ø)
src/review/public-stats.ts 96.66% <100.00%> (ø)
src/services/public-accuracy-trend.ts 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

feat(stats): review-accuracy as a historical trend, not just a live snapshot

1 participant