fix(health): clamp analytics uptime_ratio below 1#2045
Conversation
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2045 +/- ##
==========================================
+ Coverage 93.23% 93.26% +0.03%
==========================================
Files 48 48
Lines 7626 7755 +129
Branches 2804 2839 +35
==========================================
+ Hits 7110 7233 +123
- Misses 90 92 +2
- Partials 426 430 +4
🚀 New features to boost your workflow:
|
|
Tip 🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩 ✅ Gittensory review — safe to merge
✅ Approved — safe to merge Review summary
Nits — 4 non-blocking
Review context
Contributor next steps
Signal definitions
Review detailsGenerated from public PR metadata and the diff. Advisory only; deterministic signals remain authoritative. This PR exports `displayUptimeRatio` from `reliability.mjs` and routes all `uptime_ratio` emissions across seven call sites in `health-serving.mjs` (`formatTrends` ×2, `formatBulkTrends` ×2, `formatIncidents`, `formatLeaderboards`, `formatUptime`) through it, replacing naive `toFixed(4)` / `round4` calls. The logic is correct: sub-perfect ratios that floating-point round to exactly `1` are clamped to `0.9999`, while a genuinely perfect ratio (`okCount === total`) passes through as `1`. The regression test in `health-serving.test.mjs` validates both cases through `formatTrends`. Nits (4)
🟩 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.
|
Summary
displayUptimeRatioinreliability.mjsalready prevents sub-perfect ratios from rounding up to an exact1forscoreFromStats/ badges (Uptime badge renders 100% for a sub-perfect uptime ratio (scoreFromStats rounds 0.99996 up to 1) #1796), but several analytics formatters inhealth-serving.mjsstill used naivetoFixed(4)/round4foruptime_ratio.What Changed
displayUptimeRatiofromreliability.mjs.uptime_ratioemission informatTrends, subnet uptime trends, incidents SLA, leaderboards, and uptime history throughdisplayUptimeRatio.24999/25000->0.9999, not1.Fixes #2025
Registry Safety
Validation
npx vitest run tests/health-serving.test.mjs -t \"clamps a sub-perfect uptime_ratio\"git diff --check