Skip to content

feat(validator): load repo hyperparameters from the das API#1511

Draft
anderdc wants to merge 15 commits into
testfrom
feat/hyperparam-api
Draft

feat(validator): load repo hyperparameters from the das API#1511
anderdc wants to merge 15 commits into
testfrom
feat/hyperparam-api

Conversation

@anderdc

@anderdc anderdc commented Jun 21, 2026

Copy link
Copy Markdown
Collaborator

Flips the validator's source of truth for repository hyperparameters from the bundled master_repositories.json to the das-gittensor API. Part of the coordinated hyperparameter-API migration:

  • das-gittensor#82 — authed editing endpoints + GET /repos registry
  • gittensor-db#50repository_config_edits audit/cooldown table
  • gt-utils (feat/hyperparam-api) — stop clobbering the API-authoritative repositories table
  • this PR — validator reads the API

Change

load_master_repo_weights() now:

  1. GET https://api.gittensor.io/repos (requests + retry/backoff), parses + validates.
  2. On any failure (unreachable, or data that violates the registry contract), falls back to the bundled master_repositories.json seed — a transient outage or a bad push can't brick scoring.
  3. Returns {} only if both the API and the seed are unavailable. A broken seed still raises (real bug).

Parsing/validation was extracted into _parse_registry() and is shared by both paths, so the contract is identical regardless of source. Return type (Dict[str, RepositoryConfig]) is unchanged — no call site or downstream consumer moves.

master_repositories.json is retained only as the fallback seed (regenerate from the DB via gt-utils fetch_master_data.py).

Tests

  • Autouse fixture defaults validator tests to the seed (offline, deterministic) — all 185 existing load/blend tests pass unchanged.
  • Added explicit tests: API success, fallback on API failure, fallback on contract-violating API data, empty when both gone, broken-seed-still-raises.
  • ruff check/ruff format clean; pyright 0 errors; CLI miner score tests pass.

Notes for review

  • Per-epoch fetch hits one endpoint; GET /repos is @NoCache on the API so edits propagate immediately. Consider signing/versioning the payload later (a central live source is weaker than git-pinned commits) — fallback seed mitigates availability, not authenticity.

anderdc and others added 3 commits June 21, 2026 15:19
Flip load_master_repo_weights() to fetch the repository registry from the
das-gittensor API (GET api.gittensor.io/repos), the new source of truth for
repository hyperparameters (maintainer/admin edits land there).

- Extract parse+validate into _parse_registry(); add _fetch_registry_from_api()
  (requests + retry/backoff) and _load_registry_from_file().
- API-first with a bundled master_repositories.json fallback: a transient API
  outage or a contract-violating push falls back to the seed instead of
  bricking scoring. A broken bundled seed still raises.
- Tests default to the seed via an autouse fixture (offline/deterministic);
  added explicit API-path + fallback tests.

master_repositories.json is retained only as the fallback seed.
…os (#1523)

Co-authored-by: anderdc <me@alexanderdc.com>
Co-authored-by: anderdc <me@alexanderdc.com>
@anderdc anderdc marked this pull request as draft June 24, 2026 16:05
ai-hpc and others added 12 commits June 24, 2026 12:33
…intainer_cut 0.30 (#1533)

Co-authored-by: Ander <61125407+anderdc@users.noreply.github.com>
…1530)

Co-authored-by: Ander <61125407+anderdc@users.noreply.github.com>
… in blend_emission_pools (#1534)

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-authored-by: Ander <61125407+anderdc@users.noreply.github.com>
)

Co-authored-by: e35ventura <e35ventura@gmail.com>
Co-authored-by: Ander <61125407+anderdc@users.noreply.github.com>
Co-authored-by: e35ventura <e35ventura@gmail.com>
…helper (#1541)

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-authored-by: Ander <61125407+anderdc@users.noreply.github.com>
… cache

Layers the disk-cache resilience on top of anderdc's API-fetch loader and
removes the bundled registry entirely (das DB is now the sole source of truth).

- load_master_repo_weights(): on a successful GET /repos, write the registry to
  an on-disk last-good cache; on API failure read that cache; with no cache,
  return an empty registry (logged loudly) — per-field knob defaults still apply.
- _write_registry_to_cache() writes atomically (tmp + replace) and is best-effort
  (a cache-write failure never breaks the scoring cycle); _load_registry_from_cache()
  + _get_repos_cache_path() (env GITTENSOR_REPOS_CACHE_PATH, ~/.gittensor default).
- constants: add REPOS_CACHE_PATH; refresh stale master_repositories.json comments.
- DELETE gittensor/validator/weights/master_repositories.json and the
  _load_registry_from_file seed path (languages/token JSON untouched).
- tests: conftest autouse fixture now points the cache at an empty per-test tmp
  (default load => empty); injection tests warm the cache instead of the bundled
  file; obsolete live-registry-content tests removed; new disk-cache tests added
  (cache-write on success, fallback-to-cache, empty-when-no-cache, invalid-cache).

MERGE GATE: do not ship before the gt-utils seed migration has populated the prod
DB so GET /repos is non-empty (critical sequencing risk in the spec).
@LandynDev

Copy link
Copy Markdown
Collaborator

Layered on (commit 738985a): replaced bundled-JSON fallback with on-disk last-good cache (REPOS_CACHE_PATH; atomic write on success → read on failure → empty+log), DELETED master_repositories.json + file-seed path, refactored tests/conftest. 709 validator+cli tests green. ⚠️ Keep DRAFT — do not merge until prod repositories table is seeded (gt-utils #4) so GET /repos is never empty.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants