Skip to content

Add capacity forecast client method#571

Open
cniackz wants to merge 5 commits intominio:mainfrom
cniackz:feat/capacity-forecast
Open

Add capacity forecast client method#571
cniackz wants to merge 5 commits intominio:mainfrom
cniackz:feat/capacity-forecast

Conversation

@cniackz
Copy link
Copy Markdown
Contributor

@cniackz cniackz commented Apr 13, 2026

Summary

  • Add CapacityForecast struct with storage capacity predictions
  • Add CapacityForecast() client method calling GET /admin/v4/capacity-forecast
  • Follows existing ServerInfo pattern

Struct fields (15)

Field Type Description
CurrentUsedBytes uint64 Current used storage
CurrentTotalBytes uint64 Total usable storage
CurrentUsedPercent float64 Used percentage (raw, client formats)
DaysUntil80Pct *float64 Days until 80% — nil if no prediction; may be negative if already past
DaysUntil90Pct *float64 Days until 90% — same semantics
DaysUntil100Pct *float64 Days until full — same semantics
GrowthRatePerDay int64 Average bytes/day
DataPointCount int Daily snapshots collected
MinDaysUntilFull *float64 Worst case based on largest single-day delta — nil if no prediction
RSquared float64 Confidence: goodness of fit (0–1)
Variance float64 Variance of daily deltas
DayMinDelta float64 Smallest daily change in usedFraction (can be negative)
DayMaxDelta float64 Largest daily change in usedFraction
RecentGrowthRatePerDay float64 14-day window growth rate
RecentDaysUntilFull *float64 14-day window days-until-full (nil if no prediction)

Design notes

  • Days-until fields are *float64 (not float64 with sentinel) so nil cleanly represents "no prediction possible". A concrete value may be negative when the threshold was already crossed in the past — magnitude is meaningful.
  • All numeric fields return raw precision; the client decides formatting.

Related PRs

Comment thread capacity-forecast.go Outdated
Comment thread capacity-forecast.go Outdated
Comment thread capacity-forecast.go Outdated
@cniackz cniackz force-pushed the feat/capacity-forecast branch from 1a5d6e9 to 805b4f5 Compare April 13, 2026 20:42
@cniackz cniackz requested a review from klauspost April 13, 2026 22:21
@cniackz cniackz marked this pull request as ready for review April 13, 2026 22:22
@cniackz cniackz force-pushed the feat/capacity-forecast branch 3 times, most recently from a47844e to fc0c35f Compare April 27, 2026 20:37
cniackz added 5 commits May 8, 2026 10:16
Add struct and client method for the new GET /admin/v4/capacity-forecast
endpoint. Returns storage capacity predictions based on historical
daily snapshots.
Add MinDaysUntilFull, RSquared, Variance, RecentGrowthRatePerDay,
and RecentDaysUntilFull to CapacityForecast struct for Phase 2
of the prediction algorithm.
Expose concrete min/max daily usedFraction deltas so consumers can
show the actual extremes alongside the statistical summary.
A -1 sentinel collides with legitimate negative values — e.g. days
until 80%% full can legitimately be -5 when usage already crossed
the threshold 5 days ago. Use *float64 with nil for "unknown"
so the type system represents unset state cleanly.

Addresses review feedback from klauspost.
Update struct and field comments to reflect the switch from OLS
linear regression to a Kalman filter. No code or type changes.
@cniackz cniackz force-pushed the feat/capacity-forecast branch from fc0c35f to 134a0b6 Compare May 8, 2026 14:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants