Skip to content

fix(registry): agent-resources subnet_count excludes root (netuid 0) - #8464

Open
JSONbored wants to merge 1 commit into
mainfrom
fix/8460-agent-resources-subnet-count
Open

fix(registry): agent-resources subnet_count excludes root (netuid 0)#8464
JSONbored wants to merge 1 commit into
mainfrom
fix/8460-agent-resources-subnet-count

Conversation

@JSONbored

Copy link
Copy Markdown
Owner

Summary

/api/v1/agent-resources's summary.subnet_count reported 129 — it counted
mergedSubnets.length directly, which includes root (netuid 0, subnet_type: "root"). Root is base-layer chain infrastructure, not an application subnet
(registry/subnets/root.json's own notes say so), and coverage.json
already draws this exact distinction via root_subnet_count/
application_subnet_count (128 application subnets). This is the same
off-by-one #8340 already fixed in the README's catalog count — a second,
independent consumer that drifted the same way, on the AI-agents-facing
surface this time (surfaced by /agents' new stat rail in #8455/#8457).

What changed

scripts/build-artifacts.ts's agentResourcesContent.summary.subnet_count
now filters mergedSubnets to subnet_type !== "root" before counting,
mirroring coverage.json's existing application_subnet_count field.

callable_service_count is intentionally untouched: root's own surfaces (17
of them — RPC/WSS endpoints, docs, source repo) are genuinely callable
services an agent can use for chain access (the agent-catalog readiness
logic explicitly points agents at get_best_rpc_endpoint for exactly this),
so excluding them from the callable count would be wrong, unlike excluding
root from a "how many subnets" count.

Added a regression assertion in tests/artifacts.test.ts cross-checking
agentResources.summary.subnet_count against coverage.application_subnet_count
so the two can't independently drift again.

Registry Safety

  • Links a tracked, currently-open issue (Closes #8461)
  • No secrets, PATs, wallet data, private dashboards, private URLs, or validator-local state
  • Generated artifacts were produced by repo scripts, not hand-edited (agent-resources.json is R2-only — no committed public/metagraph artifact to regenerate)
  • R2-only/high-churn detail artifacts are not committed
  • No public API/OpenAPI/schema shape change — only a computed value's correctness

Validation

  • git diff --check
  • npm run lint — clean
  • npm run format:check — clean
  • npm run typecheck — clean
  • npm run build — succeeds; confirmed dist/metagraph-r2/metagraph/agent-resources.json's summary.subnet_count is now 128 (was 129)
  • npm run validateValidated 129 native subnet(s), 129 curated overlay(s), 3444 surface(s), 136 provider(s), and 2037 candidate(s).
  • npm run validate:schemas / validate:api / validate:openapi — clean
  • npm run scan:public-safety — clean
  • npm run test:coverage — 502 files / 12336 tests passed, including the new regression assertion

Closes #8461

/api/v1/agent-resources' summary.subnet_count counted mergedSubnets
directly, including root (netuid 0, subnet_type "root") -- base-layer
chain infrastructure, not an application subnet. coverage.json already
draws this exact distinction via root_subnet_count/application_subnet_count;
this is the same off-by-one #8340 fixed in the README's catalog count,
just a second independent consumer that drifted the same way.

callable_service_count is untouched: root's own surfaces (RPC/WSS
endpoints, docs, source repo) are genuinely callable services an agent
can use for chain access, so excluding them would be wrong -- only the
subnet count itself is off.

Closes #8461
@superagent-security

Copy link
Copy Markdown

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

@loopover-orb

loopover-orb Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Warning

⏸️ LoopOver review result - manual review recommended

Review updated: 2026-07-28 00:08:21 UTC

2 files · 1 AI reviewer · no blockers · CI green · clean

⏸️ Suggested Action - Manual Review

Review summary
This is a small, correct off-by-one fix: `agent-resources.json`'s `summary.subnet_count` previously counted `mergedSubnets.length` verbatim (including root, netuid 0), and the diff now filters out `subnet_type === "root"`, matching the existing `coverage.json` `application_subnet_count` convention and the precedent set in `scripts/lib/readme-catalog.ts`'s `curatedSubnetOverlays`. `callable_service_count` is correctly left untouched since root's RPC/docs surfaces are legitimately callable. A regression test cross-checking `agentResources.summary.subnet_count` against `coverage.application_subnet_count` is added to prevent future drift, and CI passed on this commit.

Nits — 3 non-blocking
  • The inline root-exclusion comment in scripts/build-artifacts.ts duplicates the rationale already captured in scripts/lib/readme-catalog.ts's curatedSubnetOverlays doc comment — could reference that instead of restating it.
  • Consider extracting a shared `isApplicationSubnet`/`excludeRoot` helper (mirroring `curatedSubnetOverlays`) so this filter logic isn't reimplemented ad hoc a third time if another consumer needs the same count.
  • PR author also opened the linked issue — Link an issue that was opened by a different contributor, or provide a rationale for why this self-authored issue represents genuine discovery work.

Decision drivers

  • ✅ Code review — No blockers (1 reviewer)
  • ✅ Gate result — Passing (No configured blocker found.)
Context & advisory signals — never blocks the verdict
Signal Result Evidence
Linked issue ✅ Linked #8461
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: 14 registered-repo PR(s), 13 merged, 346 issue(s).
Contributor context ✅ Confirmed Gittensor contributor JSONbored; Gittensor profile; 14 PR(s), 346 issue(s).
Linked issue satisfaction

Addressed
The diff filters mergedSubnets to exclude subnet_type "root" before computing subnet_count, exactly as requested, while explicitly leaving callable_service_count untouched per the issue's explicit instruction, and adds a regression test cross-checking against coverage.application_subnet_count.

Review context
  • Author: JSONbored
  • Role context: owner (maintainer lane)
  • Public audience mode: oss maintainer
  • Lane context: Repository is configured for direct PR review.
  • Public profile languages: Python, TypeScript, Ruby, Go, MDX, Shell, Solidity, JavaScript
  • Official Gittensor activity: 14 PR(s), 346 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Start here: Treat this as maintainer-lane context rather than normal contributor-lane activity.
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.
🧪 Chat with LoopOver

Ask LoopOver a question about this PR directly in a comment — grounded only in the same cached, public-safe facts shown above, never a new claim.

  • @loopover ask <question> answers contribution-quality Q&A with source citations and freshness.
  • @loopover chat <question> answers in natural prose from cached decision-pack facts via local inference (maintainer/collaborator; read-only).
  • A plain-language @loopover mention with a real question is routed to the closest matching read-only command automatically — no exact syntax required.

Full command reference: https://loopover.ai/docs/loopover-commands

🧪 Experimental — new and may change.

Decision record
  • action: hold · clause: content_lane_deliverable_missing
  • config: ca1bfb13265da3e7bc19d262fed8fb79d6417f7976befa2a52ea543245d2a7be · pack: oss-anti-slop · ci: passed
  • record: 6d6e92e9a1dff83aa06b7e5b802f956ead96333ea1d1fb71f4f43747ce204d6b (schema v5, head cc68384)

🟩 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 LoopOver, a quiet PR intelligence layer for OSS maintainers.

  • Re-run LoopOver review

@codecov

codecov Bot commented Jul 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.81%. Comparing base (befe16c) to head (cc68384).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #8464   +/-   ##
=======================================
  Coverage   97.81%   97.81%           
=======================================
  Files         419      419           
  Lines       29074    29074           
  Branches    10931    10931           
=======================================
  Hits        28440    28440           
  Misses        143      143           
  Partials      491      491           
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@loopover-orb loopover-orb Bot added the manual-review Gittensor contributor context label Jul 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

manual-review Gittensor contributor context

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(registry): agent-resources subnet_count includes root (netuid 0)

1 participant