feat(badge): add metric=apis — a callable-API-count badge#2172
Conversation
Add a new `metric=apis` option to the embeddable badge: the message is the count of a subnet's callable API surfaces (subnet-api / openapi / sse / data-artifact, mirroring the build's callable-service set), counted from the per-subnet surfaces artifact. - "3 apis" (singular "1 api"), "0 apis" when none; informational blue for >0, gray for 0, "n/a" (still 200) when there's no surfaces artifact — so an <img> never breaks, consistent with the existing metrics. - Providers sum the count across their subnets, mirroring how readiness and reliability aggregate. Self-contained in src/badge.mjs (no schema/contract/artifact change); badges aren't part of the typed OpenAPI envelope. Covered by tests for subnet/provider counts, the singular form, the zero case, and the n/a fallback. Closes JSONbored#2171
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2172 +/- ##
==========================================
- Coverage 93.18% 93.17% -0.01%
==========================================
Files 52 52
Lines 8272 8294 +22
Branches 3035 3043 +8
==========================================
+ Hits 7708 7728 +20
Misses 96 96
- Partials 468 470 +2
🚀 New features to boost your workflow:
|
|
Tip 🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩 ✅ Gittensory review — safe to merge
✅ Approved — safe to merge Review summary
Nits — 6 non-blocking
Review context
Contributor next steps
Signal definitions
Review detailsGenerated from public PR metadata and the diff. Advisory only; deterministic signals remain authoritative. Adds `metric=apis` to the badge handler — a callable-surface count from the per-subnet surfaces artifact, informational blue for >0, gray for 0, n/a when the artifact is absent. The implementation is self-contained in `src/badge.mjs`, correctly reuses `readData`/`findProvider`, mirrors the `CALLABLE_SURFACE_KINDS` set from the build, and the n/a-fallback pattern is applied consistently. Provider aggregation filters nulls before summing, which is the right approach and matches how `averageReadiness` handles missing scores. No blockers. Nits (5)
🟩 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.
|
Accept main's metric=apis implementation from JSONbored#2172 and retain the additional edge-case tests from this branch (unknown provider, empty netuids, readArtifact failures). Co-authored-by: Cursor <cursoragent@cursor.com>
Summary
Adds a new
metric=apisoption to the embeddable SVG badge (/api/v1/subnets/{netuid}/badge.svgand/providers/{slug}/badge.svg), alongside the existingreadiness/uptime/grademetrics. It shows how many callable API surfaces a subnet exposes — the core machine-integrability signal the registry is built to surface.Closes #2171
Behavior
subnet-api,openapi,sse,data-artifact(mirrors the build's callable-service set) — counted from the per-subnet/metagraph/surfaces/{netuid}.jsonartifact."3 apis", singular"1 api","0 apis"when none.#007ec6) for >0, gray for 0, and"n/a"(gray, still 200) when there's no surfaces artifact — so an<img>never breaks, consistent with the other metrics.readiness/reliabilityaggregate.Scope
src/badge.mjs— no schema/contract/artifact change (badges aren't part of the typed OpenAPI envelope), so nothing to regenerate.readData/findProviderhelpers and the established n/a-fallback pattern.Tests (
tests/badge.test.mjs)New cases: subnet count (callable-only), singular
"1 api", the"0 apis"gray case, provider sum across subnets, and then/afallback when a subnet has no surfaces artifact. Plus themetric=apisallow-list assertion.eslintandprettier --checkclean on both changed files. Full localvitestrun shows no new failures (the only failures are pre-existing Windows-only env issues — spawning binaries / DNS — that pass on Linux CI).