📊 telemetry: restore round-level gauges on journal recovery (schema v3) - #200
Merged
Merged
Conversation
…chema v3)
Startup recovery restored telemetry at most ONCE, and `val_loss` had no
recovery path at all. Two Watchtower restarts 25 minutes apart on
2026-07-31 left every per-miner family at zero series for 17 minutes and
lost cycle 16684's losses permanently.
Three coupled gaps, one schema bump:
1. `val_loss` is journaled (v3 `uid_to_val_loss`). It is published at eval
time and is NOT derivable from `scores`: `delta = max(0.0, baseline -
val_loss)` clamps at zero, so every miner scoring 0 — the majority in
many rounds — would be underivable. Plumbed through `MinerEvalJob.val_loss`
→ `Round.mark_scored(..., val_loss=)` → `Round.val_losses` → journal;
both eval paths (foreground + background) pass it.
2. Recovery now re-emits telemetry on EVERY restart, not just the first.
The replay loop only touches unfinalized journals, and replaying one
marks it finalized — so the second restart found nothing and emitted
nothing. New `republish_telemetry_from_journal` reads the newest
finalized journal and sets the gauges directly.
It is deliberately METRICS-ONLY. Re-running `finalize_round_scores`
would keep the aggregator's point set correct (`drop_round` runs first)
but re-stamp those points with fresh `_utc_now()` timestamps, shoving
them to the end of the time-ordered series — and the rolling average is
"last N by timestamp", which is what drives weight submission. A
re-finalize would therefore silently reshuffle the scoring window. A
test asserts the pass makes zero mutating aggregator calls.
3. The round-level counters (`validator_round_miners_{scored,pending,
failed}`, `lifecycle_step`, `current_round_id`) now restore via that
same pass, so they cover the finalized path too rather than inheriting
the once-only limitation. `roster_size` + `lifecycle_step` are journaled
(v3) to feed them; pre-v3 journals clamp pending to 0 rather than
inventing a denominator.
`verdict_uids` mirrors finalize's entry set exactly — scored ∪
validation-failed ∪ freeze-zero, excluding operational failures, which get
no aggregator entry so telemetry must not imply they were judged.
`from_json` still accepts v1/v2 (missing fields default). Verified against
the v0.3.4 image: the suite's failure set is byte-identical before and
after this change (4 pre-existing failures, unrelated), and the 49 tests
across the journal/telemetry suites pass.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
george-connito
force-pushed
the
feat/restore-round-telemetry-on-recovery
branch
from
July 31, 2026 18:13
0341d15 to
3d42f2f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The per-miner families re-emit via finalize_round_scores (which recovery replays), but validator_round_miners_{scored,pending,failed}, lifecycle_step and current_round_id are written only by the live eval workers — so after every restart the dashboard's "Evaluated N of M" column blanks for a full cycle (~1h45m) until the next Submission freeze.
Journal schema v3 adds two ints: roster_size (= len(foreground_uids) + len(background_uids), the one input Round.stats() needs that wasn't persisted) and lifecycle_step (the last live step the round reached). from_json still accepts v1/v2 (missing fields default to 0). Round now carries lifecycle_step, set alongside the gauge at the three run.py sites; the finalize journal-rewrite preserves both via the recovery stub.
On startup recovery, for each replayed journal we now also set validator_round_miners_scored/failed/pending{round_id} (pending = roster_size - scored - failed, clamped ≥0), lifecycle_step, and current_round_id (journals scan ascending, so it lands on the most recent recovered round), registering each round_id for normal eviction. Pre-v3 journals have roster_size=0 so pending clamps to 0 rather than inventing a denominator — graceful for the first restart after deploy.
Not covered (documented for the backend): validator_miner_val_loss is set at eval time and not journaled; it repopulates when miners are next evaluated. Per-miner cohort_group/assignment_role gauges likewise remain a live-only signal — M is still recoverable from the round_miners_* counters (scored+pending+failed) without them.
Tests: journal v3 round-trip, v2 back-com
pat (roster_size=0), recovery
stub carries the fields, finalize rewrite preserves them. Full telemetry