fix(api): bust metagraph edge cache on neuron snapshot refresh, not health prober#2181
Conversation
|
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 #2181 +/- ##
==========================================
- Coverage 93.25% 93.23% -0.02%
==========================================
Files 51 51
Lines 8076 8088 +12
Branches 2962 2968 +6
==========================================
+ Hits 7531 7541 +10
Misses 92 92
- Partials 453 455 +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. This PR correctly fixes the metagraph/validators/concentration edge cache staleness bug by decoupling those routes' cache keys from the 15-minute health prober tick and keying them on the per-subnet neuron `captured_at` stamp instead. The `withEdgeCache` extension via an optional `resolveCacheStamp` callback is backward-compatible; all three call sites in `api.mjs` are correctly migrated with matching `netuid` values; the null-MAX guard in `readSubnetNeuronsCacheStamp` (`Number.isInteger(capturedAt) && capturedAt > 0`) correctly suppresses caching when the table is cold or empty. The one material concern is that `readSubnetNeuronsCacheStamp` issues a D1 `MAX(captured_at)` query on every cache-eligible GET, including hits — the original design avoided all D1 on hits via a per-isolate-memoized KV read, and that property is now lost for neurons-tier routes. 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.
|
Summary
subnet-metagraph,subnet-validators,subnet-concentration) on a neurons freshness stamp instead ofhealth:meta.last_run_at.MAX(captured_at)for the subnet, or a lightweight KV pointer updated byloadStagedNeurons.Closes #2180
Why
Agents polling metagraph/validators for stake and rank can see data up to ~12 minutes stale at the edge despite 3-minute neuron refreshes in D1.
Test plan
npm test -- tests/analytics-edge-cache.test.mjscaptured_atadvanceslast_run_atonly