Add quota receipt aggregation and approved standup advisories

This commit is contained in:
kami
2026-07-26 20:39:21 +04:00
parent 3dfe97f4fd
commit 3e143cb703
5 changed files with 141 additions and 13 deletions
+5 -4
View File
@@ -17,8 +17,9 @@ type AlwaysAvailable struct{}
func (AlwaysAvailable) Available(registry.Herdr) bool { return true }
// QuotaAvailability applies the conservative 80% rule to the most recent
// native quota report in the configured rolling window.
// QuotaAvailability applies the conservative 80% rule to summed native
// receipts in the configured rolling window. Receipts are additive across
// rotations; a cumulative report must not replace earlier rotations.
type QuotaAvailability struct {
Store *store.Store
Limits map[string]float64
@@ -51,8 +52,8 @@ func (q QuotaAvailability) Available(h registry.Herdr) bool {
HarnessID string `json:"harness_id"`
Consumed float64 `json:"consumed"`
}
if json.Unmarshal(e.Payload, &p) == nil && p.HarnessID == h.ID && p.Consumed > consumed {
consumed = p.Consumed
if json.Unmarshal(e.Payload, &p) == nil && p.HarnessID == h.ID && p.Consumed >= 0 {
consumed += p.Consumed
}
}
return consumed < limit*0.8