Complete autonomous recovery controls

This commit is contained in:
kami
2026-07-30 14:57:25 +04:00
parent 8174400b1a
commit e8fadfc998
18 changed files with 364 additions and 77 deletions
+11
View File
@@ -61,6 +61,17 @@ type QuotaReceipt struct {
At time.Time `json:"at"`
}
// QuotaWindows publishes the two routing windows from the same additive
// per-lease receipts used by the scheduler.
type QuotaWindows struct {
FiveHour map[string]float64 `json:"five_hour"`
Weekly map[string]float64 `json:"weekly"`
}
func ProjectQuotaWindows(events []domain.Event, now time.Time) QuotaWindows {
return QuotaWindows{FiveHour: AggregateQuota(events, now.Add(-5*time.Hour), now), Weekly: AggregateQuota(events, now.Add(-7*24*time.Hour), now)}
}
// AggregateQuota sums native receipts in the requested window. It does not
// de-duplicate rotations or use a cumulative session total.
func AggregateQuota(events []domain.Event, from, to time.Time) map[string]float64 {