Skip to content

feat(ui): cycle-time percentiles card (p50/p90/p99) - #4468

Merged
JSONbored merged 3 commits into
JSONbored:mainfrom
claytonlin1110:feat/ui-cycle-time-card-2194
Jul 9, 2026
Merged

feat(ui): cycle-time percentiles card (p50/p90/p99)#4468
JSONbored merged 3 commits into
JSONbored:mainfrom
claytonlin1110:feat/ui-cycle-time-card-2194

Conversation

@claytonlin1110

Copy link
Copy Markdown
Contributor

Summary

  • Add cycleTime (p50/p90/p99 + histogram distribution) to StatsPayload via computeCycleTimeAggregate, reading paired gate_decisionpr_outcome rows from review_audit.
  • Surface cycleTime on the operator dashboard payload and render a new read-only CycleTimeCard on /app/analytics with three percentile Stat tiles and a MiniSparkbar when distribution data is present.
  • Vitest coverage for present percentiles, nullish percentile formatting, empty distribution, and fail-safe empty aggregates.

Scope

  • The PR title follows type(scope): short summary Conventional Commit format, for example fix(api): restore profile access checks.
  • This PR is focused and does not mix unrelated backend, UI, MCP, docs, dependency, and deploy changes.
  • This follows CONTRIBUTING.md and does not reintroduce GitHub Pages, VitePress, site/, or CNAME.
  • I linked a currently open issue this PR resolves (e.g. Closes #123) — a linked open issue is required for every contributor PR.

Closes #2194

Validation

  • git diff --check
  • npm run actionlint
  • npm run typecheck
  • npm run test:coverage locally; codecov/patch requires ≥99% coverage of the lines AND branches you changed (aim for 100% on your diff so CI variance does not fail near the threshold). Global coverage is a non-blocking trend with a loose 90% backstop, not the gate.
  • 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
  • New or changed behavior has unit/integration tests for new branches, fallback paths, and sanitizer boundaries

If any required check was skipped, explain why:

  • Full npm run test:ci gate pending CI; targeted unit/UI tests and coverage run locally on changed paths.

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.
  • API/OpenAPI/MCP behavior is updated and tested where needed.
  • UI changes use live API data or real empty/error/loading states, not production mock/demo fallbacks.
  • Visible UI changes include a UI Evidence section below with JPG/JPEG or PNG screenshots arranged as organized, captioned, clickable thumbnails. SVG screenshots are not used as review evidence. Review-only screenshots or recordings are not committed to the repository.
  • Public docs/changelogs are updated where needed; changelogs are only edited for release-prep PRs.

UI Evidence

Page / Feature Before After
/app/analytics
before: analytics page without cycle-time card

after: Review cycle time card with p50/p90/p99 + distribution

Screenshots to be uploaded to the PR (drag-and-drop) and URLs substituted above before merge.

Test plan

  • npm run test -- test/unit/stats.test.ts test/unit/operator-dashboard.test.ts
  • npm run test -- src/components/site/app-panels/cycle-time-card.test.tsx (UI)
  • Confirm /app/analytics shows empty state when no paired audit rows exist
  • Confirm percentile tiles populate when review_audit has gate_decision + pr_outcome pairs

Notes

Add cycleTime to the stats feed and operator dashboard, plus an analytics CycleTimeCard with percentile tiles and a distribution sparkbar.

Closes JSONbored#2194

Co-authored-by: Cursor <cursoragent@cursor.com>
@claytonlin1110
claytonlin1110 requested a review from JSONbored as a code owner July 9, 2026 20:18
@superagent-security

Copy link
Copy Markdown
Contributor

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

@codecov

codecov Bot commented Jul 9, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.02%. Comparing base (a26924a) to head (0867714).
⚠️ Report is 13 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4468   +/-   ##
=======================================
  Coverage   94.01%   94.02%           
=======================================
  Files         418      418           
  Lines       37439    37469   +30     
  Branches    13685    13692    +7     
=======================================
+ Hits        35200    35230   +30     
  Misses       1583     1583           
  Partials      656      656           
Files with missing lines Coverage Δ
src/review/stats.ts 99.08% <100.00%> (+0.34%) ⬆️
src/services/operator-dashboard.ts 100.00% <ø> (ø)
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@claytonlin1110
claytonlin1110 marked this pull request as draft July 9, 2026 20:30
Exercise computeCycleTimeAggregate day clamping/defaulting, missing D1 results, and null cycle deltas so codecov patch meets the 99% floor.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@claytonlin1110
claytonlin1110 marked this pull request as ready for review July 9, 2026 20:47
@loopover-orb loopover-orb Bot added the gittensor:feature Gittensor-scored feature linked to a feature issue — scores a 0.25x multiplier. label Jul 9, 2026
@loopover-orb

loopover-orb Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Warning

🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨

⏸️ Gittensory review result - manual review recommended

Review updated: 2026-07-09 20:57:48 UTC

8 files · 1 AI reviewer · no blockers · readiness 100/100 · CI green · clean

⏸️ Suggested Action - Manual Review

  • Touches a guarded path — held for manual review: This PR changes guardrail-protected path(s): src/services/operator-dashboard.ts (matched src/services/**).

Review summary
Adds computeCycleTimeAggregate (src/review/stats.ts) to compute p50/p90/p99 cycle-time percentiles + a histogram from paired gate_decision/pr_outcome review_audit rows, wires it fail-safe into StatsPayload and the operator-dashboard payload, and renders a new read-only CycleTimeCard on /app/analytics. The pure fold logic and D1 wrapper are correct and well-tested (present/nullish/empty/fail-safe/day-clamp branches all covered), no schema change is needed since it only reads existing review_audit rows, and the diff is scoped to issue #2194 with no unrelated changes bundled in.

Nits — 6 non-blocking
  • src/review/stats.ts:~223-236 (CYCLE_TIME_SQL): the ROW_NUMBER()-latest gate_decision per target_id isn't scoped by `source` the way computeGateEval (src/review/parity.ts) optionally is — once a SHADOW writer is active, review_audit can hold gate_decision rows from two sources for the same target_id, and this query could pick whichever one has the later created_at, mixing authoritative and shadow decision timestamps into decided_at; consider adding the same optional `source` filter computeGateEval uses before a shadow writer goes live.
  • src/review/stats.ts: the `days` clamp (`Number.isFinite(opts.days) && opts.days > 0 ? Math.min(opts.days, 730) : 90`) is duplicated verbatim between computeCycleTimeAggregate and computeStats; a small shared helper would remove the duplication, though it's harmless as-is.
  • CYCLE_TIME_SQL filters `pr_outcome.created_at >= fromIso` in addition to `gate_decision.created_at >= fromIso`; since an outcome always follows its decision, the po filter is logically redundant given the gd filter already excludes those rows — not a bug, just worth a one-line comment or removal for clarity.
  • Scope CYCLE_TIME_SQL's gate_decision CTE by `source` (mirroring computeGateEval's optional param in src/review/parity.ts) so cycle-time numbers stay meaningful once a shadow writer is active.
  • Factor the repeated day-clamp expression (src/review/stats.ts, both computeCycleTimeAggregate and computeStats) into a small shared `clampDays(days, max=730, default=90)` helper.
  • Touches a guarded path — held for manual review — A maintainer must review and merge this change.
Signal Result Evidence
Code review ✅ No blockers 1 reviewer
Linked issue ✅ Linked #2194
Related work ✅ No active overlap found No same-issue or scoped active PR overlap found.
Change scope ✅ 20/20 Low review scope from cached public metadata (1 linked issue).
Validation posture ✅ 25/25 PR body includes validation/test evidence.
Contributor workload ✅ 10/10 Author activity: 450 registered-repo PR(s), 312 merged, 104 issue(s).
Contributor context ✅ Confirmed Gittensor contributor claytonlin1110; Gittensor profile; 450 PR(s), 104 issue(s).
Gate result ⚠️ Not blocking Advisory; not blocking this PR.
Linked issue satisfaction

Partially addressed
The PR delivers the CycleTimeCard with typed p50/p90/p99 Stat tiles, a conditional MiniSparkbar, wiring into app.analytics.tsx, and Vitest coverage for present/nullish/empty-distribution cases as required, but it implements its own inline hasSamples/empty-state branching instead of using the explicitly specified StateBoundary component (state-views.tsx:215) for loading/empty handling, leaving that

Review context
  • Author: claytonlin1110
  • Role context: outside_contributor
  • Public audience mode: oss maintainer
  • Lane context: Repository is configured for direct PR review.
  • Public profile languages: not available
  • Official Gittensor activity: 450 PR(s), 104 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Keep the PR focused and include validation evidence before maintainer review.
Signal definitions
  • Related work = same linked issue, overlapping active PRs, or title/path similarity.
  • Change scope = cached public metadata such as size labels, draft state, and review-burden hints.
  • Validation posture = whether the PR provides enough public validation/test evidence for maintainer review.
  • Contributor workload = public contributor activity and cleanup pressure, not a repo-wide quality failure.
  • Contributor context = public GitHub/Gittensor identity context; non-Gittensor status is not a blocker.
Visual preview
Route Viewport Before (production) After (this PR's preview) Diff
/app/analytics desktop after /app/analytics
/app/analytics mobile after /app/analytics (mobile)

Click any thumbnail to open the full-size screenshot. Before = production · After = this PR's preview deploy.

🟩 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.

  • Re-run Gittensory review

@JSONbored
JSONbored merged commit 4ecd81b into JSONbored:main Jul 9, 2026
10 checks passed
@loopover-orb loopover-orb Bot added gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. and removed gittensor:feature Gittensor-scored feature linked to a feature issue — scores a 0.25x multiplier. labels Jul 9, 2026
@JSONbored JSONbored added gittensor:feature Gittensor-scored feature linked to a feature issue — scores a 0.25x multiplier. and removed gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. labels Jul 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gittensor:feature Gittensor-scored feature linked to a feature issue — scores a 0.25x multiplier. manual-review Gittensor contributor context

Development

Successfully merging this pull request may close these issues.

feat(ui): cycle-time percentiles card (p50/p90/p99)

2 participants