feat: add fleet energy telemetry endpoint - #63
Open
0xdfi wants to merge 3 commits into
Open
Conversation
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.
Summary
sparkDash can now report estimated whole-fleet power, rolling 24-hour and 31-day energy, coverage, a 24-hour hourly-watts graph, and watt-hours per output token through
GET /api/fleet-energy.This PR is stacked on #59. The monitor/freshness commits remain visible here until that prerequisite merges; the fleet-energy capability itself is the final commit.
Related: #59, #64
Design decisions
estimatedbecause this is not a wall meter.0600. The loader rejects corrupt or physically impossible state and prevents restart double-counting.New concepts
Coverage-aware energy integration
Energy is accumulated only between consecutive valid power samples. Each interval also adds coverage time, so clients can distinguish a low-energy period from an unobserved period. This avoids the common but misleading alternative of carrying the last watt value through outages.
Use this approach for telemetry-derived totals when source gaps are expected. Do not use it when a hardware meter already supplies cumulative energy directly.
Validation
node --test server/sparks/__tests__/monitor-lifecycle.test.js server/sparks/__tests__/fleet-energy.test.js- 61 passednpm run typecheck- passednpm run build- passedThe unrelated exact-rate timing flakes in the EXL3 and llama.cpp tests are fixed separately in #64.
Post-Deploy Monitoring & Validation
FleetEnergyTracker,fleet energy sample error, andfleet energy shutdown errorfor the first hour.freshNodeCount,coverage24hMs, state-file growth, and process event-loop responsiveness.0600across a restart.