Skip to content

feat(stats): review turnaround-time tracking (webhook received → comment posted), public + historical #4446

Description

@JSONbored

Part of #4445.

Context

No code anywhere computes or stores review turnaround time (webhook received → comment/verdict posted). activeReviewTracking (src/db/schema.ts:807-823) has a startedAt field, but it's only used to dedupe concurrent review passes on the same head SHA (src/db/repositories.ts:5091-5156) — it is never diffed against a completion timestamp. The only latency field that exists at all, productUsageEvents.latencyMs (src/db/schema.ts:1298), measures UI/API surface latency, not review processing time.

This is distinct from two adjacent, already-tracked things:

Requirements

  • Start the clock when a review pass begins (the existing activeReviewTracking claim, or the webhook-received timestamp already available in the processing pipeline) and stop it when github_app.pr_public_surface_published fires (the existing audit event already recorded per completed review, src/queue/processors.ts — same site that already writes reviewEffortMinutes, see processors.ts:9031).
  • Persist the duration per review (a new column/field alongside the existing publish audit metadata, or a small new rollup table — follow the reviewEffortMinutes-in-audit-metadata precedent for the raw per-review number).
  • Build a periodic (daily) rollup: p50/p95 duration per project, refreshed by the existing cron pattern (mirrors the */30 cron already used for pr_handling_stats per feat(stats): public proof-of-power — lifetime PRs-handled + accuracy counter on homepage hero #1059).
  • Extend GET /v1/public/stats (src/review/public-stats.ts:179-346, src/api/routes.ts:949-957) with the new rollup — reuse the existing totals/weekly/byProject response shape rather than inventing a new one. Regenerate OpenAPI (npm run ui:openapi).
  • Surface the trend on the homepage Proof-of-Power area (apps/gittensory-ui/src/components/site/proof-of-power-stats.tsx) or a /stats detail page — a p50/p95-over-time chart, not just a single current number.
  • Handle the "not enough history yet" state explicitly (a repo/project with too few completed reviews shows a clear unavailable state, not a misleading number from a tiny sample) — mirrors the pattern feat(signals): add queue pressure and review velocity trend windows #110 already established for its own trend windows.

Deliverables

  • Duration captured per completed review (start → pr_public_surface_published), persisted
  • Daily p50/p95 rollup per project, cron-refreshed
  • GET /v1/public/stats extended with the new trend data; OpenAPI regenerated
  • Homepage//stats page shows a review-speed trend, with an honest empty/insufficient-history state
  • No sensitive data in the public payload (aggregates only — matches the existing public-stats safety bar)
  • Tests: duration computation, rollup aggregation (including the empty-history branch), public endpoint shape

Expected outcome

A real, historical, publicly-visible "how fast does gittensory turn around a review" number — the first genuine measurement of this that has ever existed in this codebase.

References

Effort

M

Metadata

Metadata

Assignees

Labels

maintainer-onlyOwner-only work — yields no Gittensor points.

Projects

Status
Done

Relationships

None yet

Development

No branches or pull requests

Issue actions