Skip to content

fix(public-stats): repoint proof-of-power counter to the live ledger - #1114

Merged
JSONbored merged 1 commit into
mainfrom
fix/public-stats-live-ledger
Jun 23, 2026
Merged

fix(public-stats): repoint proof-of-power counter to the live ledger#1114
JSONbored merged 1 commit into
mainfrom
fix/public-stats-live-ledger

Conversation

@JSONbored

Copy link
Copy Markdown
Owner

Problem

The homepage "PRs reviewed" proof-of-power counter is frozen at 2,742 and never moves, even as the queue keeps reviewing PRs.

Root cause: getPublicStats reads review_targets (dispositions) and review_audit (reversals). Both were orphaned by the convergence cutover — the live engine now writes audit_events, and nothing writes those two tables anymore, so the aggregate is stuck at its last pre-cutover value.

Fix (read-only, backend-only)

Recompute the same payload from the live ledger:

field new source
reviewed distinct PRs the review system published a surface for — audit_events where event_type = 'github_app.pr_public_surface_published' (target_key = owner/repo#number)
disposition (merged / closed / commented=still-open) the pull_requests cache (merged_at, state), LEFT JOINed per PR
reversed review_audit reversal history — historical floor for accuracy (no live reversal signal yet)

Live numbers today: ~3,150 reviewed (awesome-claude 2,368 + gittensory 473 + metagraphed 312), updating within the 60s HTTP cache window — no rollup/cron.

Safety

  • Isolated to src/review/public-stats.ts — zero review-engine files touched, so it cannot affect reviews. All reads are public-safe COUNTs that degrade to 0 via safeAll.
  • PublicStatsPayload shape is byte-identical, so the homepage UI (proof-of-power-stats) needs no changes — it was stale purely because of the orphaned source, and now renders live data automatically.
  • Flag-gated by GITTENSORY_PUBLIC_STATS exactly as before.

Tests

Both public-stats test files reseeded to the live model (audit_events + pull_requests instead of review_targets); 11/11 pass and every changed line is covered (codecov/patch).

The homepage "PRs reviewed" counter was frozen (2,742) because getPublicStats
read review_targets / review_audit — both orphaned by the convergence cutover,
so nothing writes them anymore. Recompute from the LIVE ledger instead:

  reviewed    = distinct PRs the review system published a review surface for
                (audit_events `github_app.pr_public_surface_published`)
  disposition = merged / closed-without-merge / still-open-in-review, read from
                the pull_requests cache
  reversed    = review_audit reversal history (accuracy floor; no live source yet)

Read-only, isolated to public-stats.ts — no review-engine code touched, so it
cannot affect reviews. The PublicStatsPayload shape is byte-identical, so the
homepage UI needs no changes; it renders the live numbers (~3,150 reviewed)
within the 60s HTTP cache window. Tests reseeded to the live model
(audit_events + pull_requests); every changed line is covered.
@dosubot dosubot Bot added the size:L label Jun 23, 2026
@JSONbored JSONbored self-assigned this Jun 23, 2026
@superagent-security

Copy link
Copy Markdown
Contributor

Superagent didn't find any vulnerabilities or security issues in this PR.

@JSONbored
JSONbored merged commit 55ddc6c into main Jun 23, 2026
14 checks passed
@JSONbored
JSONbored deleted the fix/public-stats-live-ledger branch June 23, 2026 22:21
@codecov

codecov Bot commented Jun 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.90%. Comparing base (bcc4702) to head (29fd9ef).
⚠️ Report is 2 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1114      +/-   ##
==========================================
- Coverage   94.90%   94.90%   -0.01%     
==========================================
  Files         154      154              
  Lines       18623    18617       -6     
  Branches     6737     6733       -4     
==========================================
- Hits        17674    17668       -6     
  Misses        390      390              
  Partials      559      559              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant