feat(report): v0.139.0 — immediate out-of-cycle hub report on user actions (Direction 1)

New report.Trigger (buffered-1 chan + worker; quiet 2s, min spacing 15s,
trailing-edge coalescing) generalizes the v0.70.0 geo out-of-band push.
One canonical fire closure in main.go; wired: geo save/sync + app
deploy/remove/delete (api reportPushNow), escrow recovery-code claim,
notification-prefs save, app-email toggle, offsite config + per-app
toggle, customer claim (web SetReportTrigger seam, nil-safe, fired only
after a successful local commit). 15-min hub-report cycle untouched as
the reconciliation backbone; hub.enabled=false stays a strict no-op.
Tests: trigger engine (2 red-proofs), seam fires-after-commit-only,
nil-seam no-ops.
This commit is contained in:
2026-07-16 19:31:19 +02:00
parent 8f3564c137
commit fe9266f53f
15 changed files with 501 additions and 14 deletions
@@ -0,0 +1,11 @@
package api
import "testing"
// Group D (Scenario D, v0.139.0): with the seam unset (hub reporting disabled → main.go
// never calls SetReportPushTrigger), reportPushNow is a strict nil-safe no-op — the
// deploy/remove/geo handlers calling it must never panic.
func TestReportPushNow_NilSeamIsNoOp(t *testing.T) {
r := &Router{}
r.reportPushNow() // must not panic with triggerReportPush == nil
}
+9
View File
@@ -476,6 +476,9 @@ func (r *Router) deployStack(w http.ResponseWriter, req *http.Request, name stri
go r.OnGeoRelevantChange()
}
// v0.139.0: the hub sees the deploy in seconds (debounced trigger, not per-request)
r.reportPushNow()
// Re-apply integrations that target this newly deployed stack
if r.integrationMgr != nil {
go r.integrationMgr.OnStackStart(context.Background(), name)
@@ -774,6 +777,9 @@ func (r *Router) removeStack(w http.ResponseWriter, req *http.Request, name stri
if r.OnGeoRelevantChange != nil {
go r.OnGeoRelevantChange()
}
// v0.139.0: the hub sees the removal in seconds (debounced trigger, not per-request)
r.reportPushNow()
}
func (r *Router) deleteStack(w http.ResponseWriter, req *http.Request, name string) {
@@ -805,6 +811,9 @@ func (r *Router) deleteStack(w http.ResponseWriter, req *http.Request, name stri
}
writeJSON(w, http.StatusOK, apiResponse{OK: true, Data: resp, Message: "Stack " + name + " deleted"})
// v0.139.0: the hub sees the delete in seconds (debounced trigger, not per-request)
r.reportPushNow()
}
func (r *Router) triggerSync(w http.ResponseWriter, _ *http.Request) {