hub v0.129.0: operator raises ONE clean-up window's cap (R-833); restore-beside script + runbooks (R-834)
gates / gates (push) Successful in 30s
gates / gates (push) Successful in 30s
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0159rPz1ZhFKsS53msqPYxtS
This commit is contained in:
1 parent
3885640f66
commit
55f7621c90
20 files changed
+647
-28
No files matched your search
@@ -11,6 +11,7 @@ import (
|
||||
"log"
|
||||
"math"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
@@ -71,6 +72,7 @@ type Server struct {
|
||||
offsiteKeyAudit func(ctx context.Context) any
|
||||
// offsiteWindowAdmin: operator one-shot grant / weekly switch (decision 68). nil → 503.
|
||||
offsiteWindowGrant func(customerID string) error
|
||||
offsiteWindowGrantMax func(customerID string, maxRemove int) error
|
||||
offsiteWindowSwitch func(on bool) error
|
||||
// operator key-file clean-up (decision 72) and abandonment cancel (decision 74). nil → 503.
|
||||
offsiteRemoveUnpinned func(ctx context.Context, customerID string) (int, error)
|
||||
@@ -210,6 +212,9 @@ func (s *Server) SetOffsiteKeyAdmin(remove func(context.Context, string) (int, e
|
||||
s.offsiteRemoveUnpinned, s.offsiteAbandonCancel = remove, cancel
|
||||
}
|
||||
|
||||
// SetOffsiteWindowLargeGrant wires the operator's one-window raised cap (R-833).
|
||||
func (s *Server) SetOffsiteWindowLargeGrant(fn func(string, int) error) { s.offsiteWindowGrantMax = fn }
|
||||
|
||||
// SetOffsiteWindowAdmin wires the operator's window controls (decision 68).
|
||||
func (s *Server) SetOffsiteWindowAdmin(grant func(string) error, sw func(bool) error) {
|
||||
s.offsiteWindowGrant, s.offsiteWindowSwitch = grant, sw
|
||||
@@ -655,6 +660,18 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
var err error
|
||||
if path == "/offsite/windows-enabled" {
|
||||
err = s.offsiteWindowSwitch(r.FormValue("on") == "1")
|
||||
} else if mr := r.FormValue("max_remove"); mr != "" {
|
||||
// R-833: one window with a raised removal cap (operator only — this server is behind the
|
||||
// operator's login; the box API has no route to it).
|
||||
n, perr := strconv.Atoi(mr)
|
||||
if perr != nil || s.offsiteWindowGrantMax == nil {
|
||||
http.Error(w, "max_remove must be a number", http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
if err = s.offsiteWindowGrantMax(strings.TrimPrefix(path, "/offsite/window-grant/"), n); err != nil {
|
||||
http.Error(w, err.Error(), http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
} else {
|
||||
err = s.offsiteWindowGrant(strings.TrimPrefix(path, "/offsite/window-grant/"))
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user