carlos / platform Public

plans: the built-in ops account is exempt from plans: no limits, caps, lifecycle, billing or free-account count; the plan door refuses it

Paul, 2026-10-28: turning plans on for dev's billing rehearsal put ops
on Free, and owning ops counted against his one free account.

One predicate, (s *Store) planExempt (internal/console/planexempt.go),
true only for account #1. The console never writes ops's limits record
and deletes one left from before, once per console start: a box reads
an account with no record as having no limits. EffectiveLimits is nil
for ops, so every creation cap, warning, grace, after-grace stage,
throttle and lapse passes it by; it gets no default row, and an existing
row is ignored, never migrated. Owning ops is not owning a free
account. The billing page says there is nothing to buy, and Checkout,
change, renewal, seats and portal refuse it; the billing passes skip it.
The operator plan door answers 409 for ops, to a read as to a change.
TestPlanExemptConsulted pins the call sites and that every cap refusal
and limits write asks the predicate.

Tests whose fixture account is ops put it under plans with governOps.
Two draft strings await copy review: planCopyExempt and
billingCopy["notice.exempt"].
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by claude agent, operated by paul@keymail.dev 6f140ed0de6912640fa7905d8c65010308ed43f0 parent 26578a2
30 files changed, +645 −37
  • internal/console/accountplans.go +4 −3
  • internal/console/apiaccountplan.go +6 −1
  • internal/console/apiaccountplan_copy.go +3 −0
  • internal/console/apiinstances_ratelimit_test.go +2 −0
  • internal/console/appsettings_ratelimit_test.go +2 −0
  • internal/console/billingchange.go +8 −2
  • internal/console/billingcheckout.go +3 −0
  • internal/console/billingpage.go +14 −3
  • internal/console/billingpage_copy.go +1 −0
  • internal/console/billingpass.go +15 −3
  • internal/console/billingportal.go +5 −0
  • internal/console/billingseats.go +5 −2
  • internal/console/claim_invariant_world_test.go +3 −0
  • internal/console/plancaps.go +2 −1
  • internal/console/plancaps_doors_test.go +28 −2
  • internal/console/planexempt.go +74 −0
  • internal/console/planexempt_test.go +415 −0
  • internal/console/plangrace_cli_test.go +1 −0
  • internal/console/plangrace_view_test.go +5 −0
  • internal/console/plangracepass.go +3 −3
  • internal/console/planlapse.go +7 −4
  • internal/console/planlapse_keep.go +3 −3
  • internal/console/planlapse_test.go +2 −0
  • internal/console/planlimits.go +10 −3
  • internal/console/planmail_test.go +1 −0
  • internal/console/planmembers.go +6 −5
  • internal/console/planmembers_test.go +5 −0
  • internal/console/planstorage_test.go +1 −0
  • internal/console/server.go +4 −1
  • internal/console/store.go +7 −1

CI cancelled — superseded by a newer push — run details

diff --git a/internal/console/accountplans.go b/internal/console/accountplans.go
index 62b4db272..87a84d482 100644
--- a/internal/console/accountplans.go
+++ b/internal/console/accountplans.go
@@ -240,13 +240,14 @@ func billingSetPlan(tx *sql.Tx, accountID int64, plan string, packs map[string]i
}
// EnsureDefaultPlans gives every live account without a plan row the
-// default plan, and reports how many rows it inserted.
+// default plan, and reports how many rows it inserted. The exempt account
+// (planExempt) gets none.
func (s *Store) EnsureDefaultPlans(defaultPlan string, now time.Time) (int, error) {
res, err := s.db.Exec(`INSERT INTO account_plans
(account_id, plan, packs, source, revision, updated_by, updated_at)
SELECT id, ?, '{}', ?, 1, ?, ? FROM accounts
- WHERE deleted_at = 0 AND id NOT IN (SELECT account_id FROM account_plans)`,
- defaultPlan, PlanSourceDefault, planDefaultActor, now.Unix())
+ WHERE deleted_at = 0 AND id != ? AND id NOT IN (SELECT account_id FROM account_plans)`,
+ defaultPlan, PlanSourceDefault, planDefaultActor, now.Unix(), s.planExemptID)
if err != nil {
return 0, err
}
diff --git a/internal/console/apiaccountplan.go b/internal/console/apiaccountplan.go
index d7d0dd575..649cde6eb 100644
--- a/internal/console/apiaccountplan.go
+++ b/internal/console/apiaccountplan.go
@@ -15,7 +15,8 @@ import (
// The account plan door (plans-caps-packs spec §4, §8.7, §9.4): a fleet
// operator reads or sets an account's plan, packs and sponsored limits.
// Everyone else gets 404, the store-approval doors' convention. With no
-// catalog configured it answers 409: plans are off.
+// catalog configured it answers 409: plans are off. The exempt ops account
+// (planExempt) answers 409 too, to a read as to a change: it has no plan.
type accountPlanReply struct {
Account string `json:"account"`
@@ -70,6 +71,10 @@ func (s *Server) accountPlanDoor(w http.ResponseWriter, r *http.Request) (string
jsonError(w, http.StatusConflict, planCopyNoCatalog)
return "", nil, false
}
+ if s.store.planExempt(acct.ID) {
+ jsonError(w, http.StatusConflict, planCopyExempt)
+ return "", nil, false
+ }
return addr, acct, true
}
diff --git a/internal/console/apiaccountplan_copy.go b/internal/console/apiaccountplan_copy.go
index e9e62051f..9f4e307ee 100644
--- a/internal/console/apiaccountplan_copy.go
+++ b/internal/console/apiaccountplan_copy.go
@@ -11,4 +11,7 @@ const (
planCopyPackNotOffered = "the %s plan does not offer the %s pack"
planCopyPackQuantity = "the %s pack can be bought 1 to %d times"
planCopySaveFailed = "could not save the plan. try again"
+ // Draft (2026-10-28), awaiting copy review: the plan door's answer for
+ // the exempt ops account.
+ planCopyExempt = "the ops account is exempt from plans. it has no limits, caps or billing"
)
diff --git a/internal/console/apiinstances_ratelimit_test.go b/internal/console/apiinstances_ratelimit_test.go
index 4a31652c6..cdf834e80 100644
--- a/internal/console/apiinstances_ratelimit_test.go
+++ b/internal/console/apiinstances_ratelimit_test.go
@@ -140,6 +140,7 @@ func TestPatchRateLimitOverPlanCeiling(t *testing.T) {
// Installed after the create: the catalog's running_things cap is not
// what this test is about.
fx.srv.cfg.PlanCatalog = rlCatalog(t)
+ governOps(fx) // the fixture account is ops
refused := []struct{ body, want string }{
{`{"rate":500}`, "The backstop rate can be at most 400 on this account's plan."},
@@ -244,6 +245,7 @@ func TestRateLimitGet(t *testing.T) {
}
fx.srv.cfg.PlanCatalog = rlCatalog(t)
+ governOps(fx) // the fixture account is ops
status, _, out = rawReq(t, http.MethodGet, gu, token, "")
if status != http.StatusOK {
t.Fatalf("GET = %d %s", status, out)
diff --git a/internal/console/appsettings_ratelimit_test.go b/internal/console/appsettings_ratelimit_test.go
index 25a1f1dbe..d4b7cec62 100644
--- a/internal/console/appsettings_ratelimit_test.go
+++ b/internal/console/appsettings_ratelimit_test.go
@@ -142,6 +142,7 @@ func TestAppSettingsRateLimitKeepsPaths(t *testing.T) {
// Under a plan the lines show what the edge applies: clamped.
fx.srv.cfg.PlanCatalog = rlCatalog(t)
+ governOps(fx) // the fixture account is ops
_, _, body = get(t, c, fx.u("/apps/shop/settings/domains"))
if want := "<li>/api/ 8 in flight per address when busy, backstop 77 a second, bursts of 1000</li>"; !strings.Contains(body, want) {
t.Fatalf("page lacks the clamped line %q: %s", want, body)
@@ -173,6 +174,7 @@ func TestAppSettingsRateLimitKeepsPaths(t *testing.T) {
func TestAppSettingsRateLimitOverCeiling(t *testing.T) {
fx, c, csrf := rlSettingsFixture(t, "code-settings-rl-ceiling")
fx.srv.cfg.PlanCatalog = rlCatalog(t)
+ governOps(fx) // the fixture account is ops
status, loc, _ := postForm(t, c, fx.u("/apps/shop/ratelimit"),
rlForm(csrf, "set", "busy_at", "", "client_share", "", "rate", "500", "burst", ""))
diff --git a/internal/console/billingchange.go b/internal/console/billingchange.go
index 9adf009a4..6af3fd4c1 100644
--- a/internal/console/billingchange.go
+++ b/internal/console/billingchange.go
@@ -216,10 +216,13 @@ func (s *Server) renderChangeConfirm(w http.ResponseWriter, r *http.Request, add
}
// changeRefusalsLocked are the refusals a change needs no provider request
-// for: a retiring account, an open billing problem, a plan billing does not
-// own.
+// for: the exempt account, a retiring account, an open billing problem, a
+// plan billing does not own.
func (s *Server) changeRefusalsLocked(h billingHold, acct *Account, now time.Time) error {
_ = h
+ if s.store.planExempt(acct.ID) {
+ return errBillingExempt
+ }
if retiring, err := s.store.BillingRetiring(acct.ID, now); err != nil {
return err
} else if retiring {
@@ -584,6 +587,9 @@ func renewalText(renew bool, periodEnd time.Time) changeReply {
// problem never refuses it: renewal prepares no charge or quantity raise
// (refuseOnProblemLocked is only for flows that can).
func (s *Server) renewalLocked(h billingHold, ctx context.Context, acct *Account, renew bool, now time.Time) (changeReply, error) {
+ if s.store.planExempt(acct.ID) {
+ return changeReply{}, errBillingExempt
+ }
if retiring, err := s.store.BillingRetiring(acct.ID, now); err != nil {
return changeReply{}, err
} else if retiring {
diff --git a/internal/console/billingcheckout.go b/internal/console/billingcheckout.go
index 9a04fc335..611212fd5 100644
--- a/internal/console/billingcheckout.go
+++ b/internal/console/billingcheckout.go
@@ -195,6 +195,9 @@ func (s *Server) handleBillingCheckout(w http.ResponseWriter, r *http.Request) {
func (s *Server) checkoutLocked(h billingHold, ctx context.Context, acct *Account, ask checkoutAsk, now time.Time) (string, error) {
cfg := s.billing.cfg
// Refusals that need no provider request.
+ if s.store.planExempt(acct.ID) {
+ return "", errBillingExempt
+ }
if retiring, err := s.store.BillingRetiring(acct.ID, now); err != nil {
return "", err
} else if retiring {
diff --git a/internal/console/billingpage.go b/internal/console/billingpage.go
index 8e341705e..395a26f2f 100644
--- a/internal/console/billingpage.go
+++ b/internal/console/billingpage.go
@@ -48,7 +48,9 @@ type billingPageInput struct {
Op *billingOp // the outstanding operation, nil for none
Problems []string // open problem reasons
Retiring, Ready, Owner bool
- Now time.Time
+ // Exempt is the ops account, which has no plan (planExempt).
+ Exempt bool
+ Now time.Time
}
// billingPageState is the page's decision: a billingCopy notice key ("" for
@@ -89,6 +91,8 @@ func decideBillingOwner(in billingPageInput) (string, []string) {
op = nil
}
switch {
+ case in.Exempt:
+ return "notice.exempt", nil
case !in.Ready:
return "notice.not_ready", nil
case in.Retiring:
@@ -254,7 +258,10 @@ type billingChangeView struct {
// billingPageInputFor reads the stored facts the page decides from.
func (s *Server) billingPageInputFor(acct *Account, role string, now time.Time) (billingPageInput, error) {
- in := billingPageInput{Owner: role == RoleOwner, Ready: s.billing.ready.Load(), Now: now}
+ in := billingPageInput{Owner: role == RoleOwner, Ready: s.billing.ready.Load(), Exempt: s.store.planExempt(acct.ID), Now: now}
+ if in.Exempt {
+ return in, nil // nothing else decides its page
+ }
var err error
if in.Row, err = s.store.AccountPlan(acct.ID); err != nil {
return in, err
@@ -333,6 +340,9 @@ func (s *Server) billingViewFor(r *http.Request, in billingPageInput, st billing
if st.OwnersOnly {
v.OwnersOnly = billingCopy["notice.owners_only"]
}
+ if in.Exempt {
+ return v // no plan, so no facts about one
+ }
for _, k := range st.Offered {
switch k {
case offerBuy:
@@ -641,7 +651,8 @@ func (s *Server) handleUpgrade(w http.ResponseWriter, r *http.Request) {
}
var owned []Account
for _, a := range accts {
- if a.Role == RoleOwner {
+ // The exempt account has nothing to buy (planExempt).
+ if a.Role == RoleOwner && !s.store.planExempt(a.ID) {
owned = append(owned, a)
}
}
diff --git a/internal/console/billingpage_copy.go b/internal/console/billingpage_copy.go
index 20d716e8e..d45a3ccda 100644
--- a/internal/console/billingpage_copy.go
+++ b/internal/console/billingpage_copy.go
@@ -72,6 +72,7 @@ var billingCopy = map[string]string{
"notice.seats_unpaid": "This account has more members than it pays for. Remove members, or ask an operator.",
"notice.unresolved": "We couldn't confirm a recent change, and someone is checking it. Nothing more will be charged.",
"notice.operator_plan": "An operator set this account's plan, so there's nothing to buy here.",
+ "notice.exempt": "This is the deployment's own account. It has no plan, so there's nothing to buy here.", // draft 2026-10-28, awaiting copy review
"notice.confirming": "We're confirming a recent change. Nothing more will be charged.",
"notice.settling": "We're confirming your payment. This page shows your new plan once it's done.",
"notice.pending_payment": "A change is waiting for payment. Pay it from Payment and invoices, or it will be dropped after a day.",
diff --git a/internal/console/billingpass.go b/internal/console/billingpass.go
index d78f3bd88..8da4b401c 100644
--- a/internal/console/billingpass.go
+++ b/internal/console/billingpass.go
@@ -107,7 +107,8 @@ func (s *Server) StartBillingSyncPass(ctx context.Context) {
// stops the others. The round shares one provider-time recorder: an
// observation at most observationMaxAge old serves every decision in the
// round, and a decision reached after it expires probes again. The pass
-// never writes to the provider (Invariant 5).
+// never writes to the provider (Invariant 5). Every part of it skips the
+// exempt account (planExempt), which billing never governs.
func (s *Server) billingSyncPass(ctx context.Context, now time.Time) {
if s.billing == nil || !s.billing.ready.Load() {
return
@@ -124,6 +125,9 @@ func (s *Server) billingSyncPass(ctx context.Context, now time.Time) {
}
for _, b := range page {
after = b.AccountID
+ if s.store.planExempt(b.AccountID) {
+ continue
+ }
if err := s.syncSubscription(ctx, b.Subscription, now); err != nil {
log.Printf("console: billing sync pass: account %d: %v", b.AccountID, err)
jobFailed(ctx, fmt.Errorf("billing sync pass: account %d: %w", b.AccountID, err))
@@ -172,6 +176,9 @@ func (s *Server) billingIntentPass(ctx context.Context, now time.Time) {
}
func (s *Server) observeIntent(ctx context.Context, ci checkoutIntent, now time.Time) {
+ if s.store.planExempt(ci.AccountID) {
+ return
+ }
acct, err := s.store.AccountByID(ci.AccountID)
if err != nil || acct == nil {
log.Printf("console: billing intent pass: intent %s: account %d: %v", ci.ID, ci.AccountID, err)
@@ -225,6 +232,9 @@ func (s *Server) billingOpsPass(ctx context.Context, now time.Time, synced map[s
}
func (s *Server) observeOp(ctx context.Context, op billingOp, now time.Time, synced map[string]bool) {
+ if s.store.planExempt(op.AccountID) {
+ return
+ }
acct, err := s.store.AccountByID(op.AccountID)
if err != nil || acct == nil {
log.Printf("console: billing ops pass: operation %s: account %d: %v", op.ID, op.AccountID, err)
@@ -277,7 +287,7 @@ func (s *Server) billingRestorePass(ctx context.Context, now time.Time, synced m
}
for _, c := range page {
afterCreated, afterID = c.CreatedAt, c.OpID
- if synced[c.Subscription] {
+ if synced[c.Subscription] || s.store.planExempt(c.AccountID) {
continue
}
acct, err := s.store.AccountByID(c.AccountID)
@@ -318,7 +328,9 @@ func (s *Server) billingDiscoveryPass(ctx context.Context, now time.Time) {
}
for _, b := range page {
after = b.AccountID
- s.discoverCustomer(ctx, b, now)
+ if !s.store.planExempt(b.AccountID) {
+ s.discoverCustomer(ctx, b, now)
+ }
}
if len(page) < billingSyncBatch {
return
diff --git a/internal/console/billingportal.go b/internal/console/billingportal.go
index 3ae012949..c4d50ca87 100644
--- a/internal/console/billingportal.go
+++ b/internal/console/billingportal.go
@@ -44,6 +44,11 @@ func (s *Server) handleBillingPortal(w http.ResponseWriter, r *http.Request) {
return
}
back := billingPagePath(acct.Sqid)
+ if s.store.planExempt(acct.ID) {
+ s.setFlash(w, "err", billingCopy["notice.exempt"])
+ http.Redirect(w, r, back, http.StatusSeeOther)
+ return
+ }
if !s.billing.ready.Load() {
s.setFlash(w, "err", billingCopy["portal.failed"])
http.Redirect(w, r, back, http.StatusSeeOther)
diff --git a/internal/console/billingseats.go b/internal/console/billingseats.go
index 5e00acc53..1150cd964 100644
--- a/internal/console/billingseats.go
+++ b/internal/console/billingseats.go
@@ -133,10 +133,10 @@ func (s *Store) PutSeatObservation(accountID int64, driftAt time.Time, driftMemb
// billingTeam is the account's team block when billing is configured and the
// account's plan row is a team plan billing owns, else nil: only such an
-// account's membership is billed.
+// account's membership is billed. The exempt account's never is.
func (s *Server) billingTeam(acct *Account) (*plans.Team, error) {
cat := s.cfg.PlanCatalog
- if s.billing == nil || cat == nil {
+ if s.billing == nil || cat == nil || s.store.planExempt(acct.ID) {
return nil, nil
}
row, err := s.store.AccountPlan(acct.ID)
@@ -531,6 +531,9 @@ func (s *Server) observeSeatsLocked(h billingHold, acct *Account, members int, d
// the refresh after it; then the seat observation. It answers the
// reduction's outcome, with a zero State when nothing was sent.
func (s *Server) reconcileSeatsLocked(h billingHold, ctx context.Context, acct *Account, members int, now time.Time) (opOutcome, error) {
+ if s.store.planExempt(acct.ID) {
+ return opOutcome{}, errBillingExempt
+ }
if retiring, err := s.store.BillingRetiring(acct.ID, now); err != nil {
return opOutcome{}, err
} else if retiring {
diff --git a/internal/console/claim_invariant_world_test.go b/internal/console/claim_invariant_world_test.go
index e53dc5f6a..e55416c83 100644
--- a/internal/console/claim_invariant_world_test.go
+++ b/internal/console/claim_invariant_world_test.go
@@ -608,6 +608,9 @@ func newClaimCaseWith(t *testing.T, opts ...func(*Config)) *claimCase {
secretsPriv: secretsPriv, vars: map[string]string{}, appIDs: map[claimAppRef]string{},
hits: hits,
}
+ // The world's account is ops, which plans exempt; its plan and billing
+ // probes need it governed.
+ governOps(cx.consoleFixture)
cx.enroll(t, release.OpsAccount, "kass")
cx.enroll(t, release.OpsAccount, "titogo")
cx.browser = newBrowser(t)
diff --git a/internal/console/plancaps.go b/internal/console/plancaps.go
index 996e381e7..8dc6272eb 100644
--- a/internal/console/plancaps.go
+++ b/internal/console/plancaps.go
@@ -143,6 +143,7 @@ func (s *Server) checkSidecars(ctx context.Context, acct *Account, app string) e
// checkNewFreeAccount refuses a person a further account on a free plan once
// they own the catalog's allowance of them (spec §8.1; creation only).
+// Owning the exempt account (planExempt) is not owning a free one.
func (s *Server) checkNewFreeAccount(addr string) error {
cat := s.cfg.PlanCatalog
if cat == nil || cat.FreeAccountsPerPerson <= 0 {
@@ -157,7 +158,7 @@ func (s *Server) checkNewFreeAccount(addr string) error {
}
free := 0
for _, a := range accts {
- if a.Role != RoleOwner {
+ if a.Role != RoleOwner || s.store.planExempt(a.ID) {
continue
}
plan := cat.DefaultPlan
diff --git a/internal/console/plancaps_doors_test.go b/internal/console/plancaps_doors_test.go
index b94632859..e78bdeff8 100644
--- a/internal/console/plancaps_doors_test.go
+++ b/internal/console/plancaps_doors_test.go
@@ -25,6 +25,7 @@ import (
func atRunningCap(t *testing.T, fx *consoleFixture, capN int) *Account {
t.Helper()
fx.srv.cfg.PlanCatalog = examplePlanCatalog(t)
+ governOps(fx) // the fixture account is ops
acct, err := fx.st.AccountBySqid(fx.sqid)
if err != nil || acct == nil {
t.Fatalf("ops account: %v", err)
@@ -205,6 +206,7 @@ func TestSidecarCreateRefusedAtTheSidecarCap(t *testing.T) {
fx, token := instanceFixture(t, "code-cap-sidecar")
enableSidecars(t, fx, "titogo", titoSidecarManifest())
fx.srv.cfg.PlanCatalog = examplePlanCatalog(t)
+ governOps(fx) // the fixture account is ops
acct, _ := fx.st.AccountBySqid("bab")
capsSidecar(t, fx, acct, "titogo", "first")
status, _, out := rawReq(t, http.MethodPost, sidecarsURL(fx, "bab", "titogo"), token, `{"name":"bot","region":"ie"}`)
@@ -242,9 +244,15 @@ func accountCount(t *testing.T, fx *consoleFixture) int {
func TestNewAccountRefusedForASecondFreeAccount(t *testing.T) {
fx := newConsoleFixture(t)
fx.srv.cfg.PlanCatalog = examplePlanCatalog(t)
- before := accountCount(t, fx)
token := cliToken(t, fx, "paul@keymail.dev", "code-cap-acct")
- status, out := postJSON(t, fx.ts.URL+"/auth/cli/accounts", map[string]string{"name": "second"}, token)
+ // Paul owns ops, which is exempt from plans (2026-10-28): his first
+ // free account is allowed beside it.
+ status, out := postJSON(t, fx.ts.URL+"/auth/cli/accounts", map[string]string{"name": "first"}, token)
+ if status != http.StatusOK {
+ t.Fatalf("CLI first free account beside ops = %d %v, want 200", status, out)
+ }
+ before := accountCount(t, fx)
+ status, out = postJSON(t, fx.ts.URL+"/auth/cli/accounts", map[string]string{"name": "second"}, token)
if status != http.StatusConflict || out["code"] != "cap" {
t.Fatalf("CLI second free account = %d %v, want 409 cap", status, out)
}
@@ -271,6 +279,7 @@ func TestFirstAccountIsNeverRefused(t *testing.T) {
func TestNewAccountAllowedWhenTheOtherIsPaid(t *testing.T) {
fx := newConsoleFixture(t)
fx.srv.cfg.PlanCatalog = examplePlanCatalog(t)
+ governOps(fx) // the fixture account is ops
ops, _ := fx.st.AccountBySqid(fx.sqid)
if _, err := fx.st.SetAccountPlan(ops.ID, "personal", nil, 0, PlanSourceOperator, nil, "r", "ops@example.com", planNow); err != nil {
t.Fatal(err)
@@ -294,6 +303,7 @@ func TestNewAccountWithoutACatalogUnchanged(t *testing.T) {
func TestFleetCreateRefusedOnAPlanWithoutFleets(t *testing.T) {
fx, token := fleetFixture(t, "code-cap-fleet")
fx.srv.cfg.PlanCatalog = examplePlanCatalog(t)
+ governOps(fx) // the fixture account is ops
status, out := postJSON(t, fleetsURL(fx, fx.sqid)+"/new", map[string]string{"name": "acme", "bucket": "bkt-1"}, token)
if status != http.StatusConflict || out["code"] != "cap" {
t.Fatalf("fleet create on free = %d %v, want 409 cap", status, out)
@@ -305,6 +315,7 @@ func TestCustomDomainRefusedOnAFreePlan(t *testing.T) {
shipVersion(t, fx, "titogo", "v1")
seedChannel(t, fx, "titogo", "canary/live", "v1")
fx.srv.cfg.PlanCatalog = examplePlanCatalog(t)
+ governOps(fx) // the fixture account is ops
for name, body := range map[string]string{
"alias": `{"host":"tickets.example.com","route":"go.tito.io"}`,
"first route": `{"host":"fresh.example.com","kind":"static"}`,
@@ -401,6 +412,7 @@ func daemonFixture(t *testing.T, code string) (*consoleFixture, string) {
func TestShipRefusesDaemonUnderAPlan(t *testing.T) {
fx, token := daemonFixture(t, "code-cap-daemon")
fx.srv.cfg.PlanCatalog = examplePlanCatalog(t)
+ governOps(fx) // the fixture account is ops
status, out := shipDaemon(t, fx, token, "dmn00001")
if status != http.StatusConflict || out["code"] != "cap" {
t.Fatalf("daemon ship under a plan = %d %v, want 409 cap", status, out)
@@ -416,6 +428,7 @@ func TestShipRefusesDaemonEvenOnReship(t *testing.T) {
t.Fatalf("setup ship with no catalog = %d %v", status, out)
}
fx.srv.cfg.PlanCatalog = examplePlanCatalog(t)
+ governOps(fx) // the fixture account is ops
if status, out := shipDaemon(t, fx, token, "dmn00002"); status != http.StatusConflict || out["code"] != "cap" {
t.Fatalf("identical daemon re-ship under a plan = %d %v, want 409 cap", status, out)
}
@@ -451,6 +464,7 @@ func TestSidecarEnableRefusesHibernateFalseUnderAPlan(t *testing.T) {
fx, token := instanceFixture(t, "code-cap-alwayson")
enableSidecars(t, fx, "titogo", titoSidecarManifest())
fx.srv.cfg.PlanCatalog = examplePlanCatalog(t)
+ governOps(fx) // the fixture account is ops
status, _, out := rawReq(t, http.MethodPut, sidecarEnableURL(fx, "bab", "titogo"), token, `{"hibernate":false}`)
if status != http.StatusConflict || !strings.Contains(out, `"code":"cap"`) {
t.Fatalf("hibernate:false under a plan = %d %s, want 409 cap", status, out)
@@ -492,6 +506,7 @@ func setSchedule(t *testing.T, fx *consoleFixture, token, body string) int {
func TestScheduleRefusedBelowThePlanMinimum(t *testing.T) {
fx, token := scheduleFixture(t, "code-cap-schedule")
fx.srv.cfg.PlanCatalog = examplePlanCatalog(t)
+ governOps(fx) // the fixture account is ops
for _, body := range []string{
`{"name":"often","every":"5m","path":"/jobs/x"}`,
`{"name":"often","cron":"*/1 * * * *","path":"/jobs/x"}`,
@@ -570,6 +585,7 @@ func placeOnNamedFleet(t *testing.T, fx *consoleFixture, app, name string) {
func TestOwnBoxesNeedsAFleetTheAccountOwns(t *testing.T) {
fx := newConsoleFixture(t)
fx.srv.cfg.PlanCatalog = examplePlanCatalog(t)
+ governOps(fx) // the fixture account is ops
acct, _ := fx.st.AccountBySqid(fx.sqid)
addFleet(t, fx, "mine", fx.sqid)
addFleet(t, fx, "theirs", "zzz")
@@ -634,6 +650,7 @@ func TestSidecarCreateRefusedUnderAnAlwaysOnManifest(t *testing.T) {
m.Hibernate = &off
enableSidecars(t, fx, "titogo", m)
fx.srv.cfg.PlanCatalog = examplePlanCatalog(t)
+ governOps(fx) // the fixture account is ops
status, _, out := rawReq(t, http.MethodPost, sidecarsURL(fx, "bab", "titogo"), token, `{"name":"bot","region":"ie"}`)
if status != http.StatusConflict || !strings.Contains(out, `"code":"cap"`) {
t.Fatalf("new worker under an always-on manifest on shared boxes = %d %s, want 409 cap", status, out)
@@ -649,6 +666,7 @@ func TestAlwaysOnRefusedWhileSidecarsRemainOnSharedBoxes(t *testing.T) {
t.Fatalf("setup sidecar on shared boxes = %d %s", status, out)
}
fx.srv.cfg.PlanCatalog = examplePlanCatalog(t)
+ governOps(fx) // the fixture account is ops
placeOnFleet(t, fx, "titogo")
status, _, out := rawReq(t, http.MethodPut, sidecarEnableURL(fx, "bab", "titogo"), token, `{"hibernate":false}`)
if status != http.StatusConflict || !strings.Contains(out, `"code":"cap"`) {
@@ -664,6 +682,7 @@ func TestPromoteRefusesADaemonReleaseUnderAPlan(t *testing.T) {
t.Fatalf("setup daemon ship with no catalog = %d %v", status, out)
}
fx.srv.cfg.PlanCatalog = examplePlanCatalog(t)
+ governOps(fx) // the fixture account is ops
status, out := postJSON(t, fx.ts.URL+"/api/cli/apps/bab/relayapp/promote",
map[string]string{"version": "dmn00020", "channel": "canary/x"}, token)
if status != http.StatusConflict || out["code"] != "cap" {
@@ -696,6 +715,7 @@ func TestBrowserPromoteAndCanaryRefuseADaemonReleaseUnderAPlan(t *testing.T) {
fx := newConsoleFixture(t)
shipDaemonVersion(t, fx, "kass", "dmn1")
fx.srv.cfg.PlanCatalog = examplePlanCatalog(t)
+ governOps(fx) // the fixture account is ops
c := signInPaul(t, fx)
csrf := sessionToken(t, fx, c)
@@ -735,6 +755,7 @@ func TestPendingPromoteOfADaemonReleaseRefusedUnderAPlan(t *testing.T) {
t.Fatalf("pending = %v, %v, want exactly one", pending, err)
}
fx.srv.cfg.PlanCatalog = examplePlanCatalog(t)
+ governOps(fx) // the fixture account is ops
kim := newBrowser(t)
fx.setUser("kim@keymail.dev")
@@ -755,6 +776,7 @@ func TestAlwaysOnRefusedPastAnUnreadableSidecarRecord(t *testing.T) {
t.Fatal(err)
}
fx.srv.cfg.PlanCatalog = examplePlanCatalog(t)
+ governOps(fx) // the fixture account is ops
placeOnFleet(t, fx, "titogo")
status, _, out := rawReq(t, http.MethodPut, sidecarEnableURL(fx, "bab", "titogo"), token, `{"hibernate":false}`)
if status == http.StatusOK || status == http.StatusNoContent {
@@ -783,6 +805,7 @@ func TestRollbackToADaemonReleaseRefusedUnderAPlan(t *testing.T) {
fx := newConsoleFixture(t)
daemonInHistory(t, fx, "kass")
fx.srv.cfg.PlanCatalog = examplePlanCatalog(t)
+ governOps(fx) // the fixture account is ops
token := cliToken(t, fx, "paul@keymail.dev", "code-cap-daemon-rollback")
status, out := postJSON(t, fx.ts.URL+"/api/cli/apps/bab/kass/rollback", map[string]string{"channel": "canary/x"}, token)
@@ -814,6 +837,7 @@ func TestRollbackDaemonGuardReadsThePointerAtWriteTime(t *testing.T) {
t.Fatalf("guard with plans off = %v, %v, want none", guard != nil, err)
}
fx.srv.cfg.PlanCatalog = examplePlanCatalog(t)
+ governOps(fx) // the fixture account is ops
guard, err := fx.srv.rollbackDaemonGuard(ctx, acct, "kass", "canary/x")
if err != nil || guard == nil {
t.Fatalf("guard under a plan = %v, %v, want one", guard != nil, err)
@@ -847,6 +871,7 @@ func TestPendingRollbackToADaemonReleaseRefusedUnderAPlan(t *testing.T) {
t.Fatalf("pending = %v, %v, want exactly one", pending, err)
}
fx.srv.cfg.PlanCatalog = examplePlanCatalog(t)
+ governOps(fx) // the fixture account is ops
kim := newBrowser(t)
fx.setUser("kim@keymail.dev")
signUp(t, fx, kim, "code-kim-daemon-rollback")
@@ -888,6 +913,7 @@ func TestRollbackGuardReadFailureIsAPlanCheckFailure(t *testing.T) {
seedChannel(t, fx, "kass", "canary/x", "old1")
seedChannel(t, fx, "kass", "canary/x", "new2")
fx.srv.cfg.PlanCatalog = examplePlanCatalog(t)
+ governOps(fx) // the fixture account is ops
if err := fx.rel.Delete(context.Background(), release.ManifestKey(release.OpsAccount, "kass", "old1")); err != nil {
t.Fatal(err)
}
diff --git a/internal/console/planexempt.go b/internal/console/planexempt.go
new file mode 100644
index 000000000..5d0baf15b
--- /dev/null
+++ b/internal/console/planexempt.go
@@ -0,0 +1,74 @@
+package console
+
+import (
+ "context"
+ "errors"
+ "fmt"
+ "log"
+ "os"
+ "time"
+
+ "github.com/carlosframework/platform/internal/plans"
+)
+
+// The ops account is exempt from plans (Paul, 2026-10-28). Account #1 is
+// the deployment operator's built-in account: it runs the console and the
+// platform's own apps, and its owners are the operators. It has no plan:
+//
+// - no limits: the console never writes its limits record, and a box
+// reads an account with no record as having no limits (internal/host's
+// plansPass), the same as a deployment with plans off;
+// - no caps, warnings, grace, after-grace stages, throttle or lapse;
+// - owning it is not owning a free account;
+// - no billing: nothing to buy, and no Checkout, change, seat or portal
+// path starts for it; the billing passes skip it;
+// - the operator plan door refuses it.
+//
+// An account_plans row it already holds (dev's sponsored row) is ignored,
+// never migrated or deleted. Every path above asks planExempt
+// (TestPlanExemptConsulted).
+
+// planExempt reports whether plans never govern the account: the built-in
+// ops account (Store.planExemptID, always OpsAccountID).
+func (s *Store) planExempt(accountID int64) bool { return accountID == s.planExemptID }
+
+// errPlanExempt refuses a plan change for the exempt account.
+var errPlanExempt = errors.New("console: " + planCopyExempt)
+
+// errBillingExempt refuses a billing door for the exempt account.
+var errBillingExempt = billingRefusal{Key: "notice.exempt"}
+
+// settlePlanExempt removes, once per console start, what plans left on the
+// exempt account from before it was exempt: its limits record, so the
+// boxes stop applying it, and a storage deny the grace pass set. It reads
+// and writes nothing of the account's plan row. A failure is retried on
+// the next limits pass.
+func (s *Server) settlePlanExempt(ctx context.Context, now time.Time) {
+ if s.planExemptSettled.Load() {
+ return
+ }
+ acct, err := s.store.AccountByID(s.store.planExemptID)
+ if err != nil {
+ log.Printf("console: plan limits: exempt account: %v", err)
+ jobFailed(ctx, fmt.Errorf("plan limits: exempt account: %w", err))
+ return
+ }
+ if acct == nil {
+ s.planExemptSettled.Store(true)
+ return
+ }
+ defer s.lapseLock(acct.ID)()
+ var errs []error
+ if err := s.cfg.Releases.Delete(ctx, plans.LimitsKey(acct.Sqid)); err != nil && !errors.Is(err, os.ErrNotExist) {
+ errs = append(errs, fmt.Errorf("limits record: %w", err))
+ }
+ if err := s.clearStorageDeny(ctx, acct, now); err != nil {
+ errs = append(errs, fmt.Errorf("storage deny: %w", err))
+ }
+ if err := errors.Join(errs...); err != nil {
+ log.Printf("console: plan limits: exempt account %s: %v", acct.Sqid, err)
+ jobFailed(ctx, fmt.Errorf("plan limits: exempt account %s: %w", acct.Sqid, err))
+ return
+ }
+ s.planExemptSettled.Store(true)
+}
diff --git a/internal/console/planexempt_test.go b/internal/console/planexempt_test.go
new file mode 100644
index 000000000..e66ad0d76
--- /dev/null
+++ b/internal/console/planexempt_test.go
@@ -0,0 +1,415 @@
+package console
+
+import (
+ "context"
+ "database/sql"
+ "go/ast"
+ "net/http"
+ "slices"
+ "sort"
+ "strings"
+ "testing"
+
+ "github.com/carlosframework/platform/internal/plans"
+)
+
+// The ops account is exempt from plans (Paul, 2026-10-28): no limits
+// record, no caps, no grace, lapse or throttle, no billing, and owning it
+// is not owning a free account. planExempt is the one predicate.
+
+// governOps puts the fixture's own account, which is ops, under plans, for
+// the tests that exercise plans through the fixture's account and doors.
+func governOps(fx *consoleFixture) { fx.st.planExemptID = 0 }
+
+// opsPlanAccount is the built-in ops account, created when the fixture's
+// store does not have it yet, owned by owner.
+func opsPlanAccount(t *testing.T, fx *consoleFixture, owner string) *Account {
+ t.Helper()
+ acct, err := fx.st.AccountByID(OpsAccountID)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if acct == nil {
+ if err := fx.st.CreateAccount(OpsAccountID, opsSqid, "ops", owner, planNow); err != nil {
+ t.Fatal(err)
+ }
+ } else if err := fx.st.AddMember(OpsAccountID, owner, RoleOwner, planNow); err != nil {
+ t.Fatal(err)
+ }
+ if acct, err = fx.st.AccountByID(OpsAccountID); err != nil || acct == nil {
+ t.Fatalf("ops account: %v", err)
+ }
+ return acct
+}
+
+// opsSponsoredRow gives ops the kind of row dev holds today: a sponsored
+// free assignment, published, with a throttle and a lapse mark.
+func opsSponsoredRow(t *testing.T, fx *consoleFixture, ops *Account) *AccountPlanRow {
+ t.Helper()
+ if _, err := fx.st.SetAccountPlan(ops.ID, "free", nil, 0, PlanSourceSponsored, &plans.Limits{RunningThings: 1}, "rehearsal", "paul@example.com", planNow); err != nil {
+ t.Fatal(err)
+ }
+ if _, err := fx.st.db.Exec(`UPDATE account_plans SET lapse_since = ?, throttle = '{"bandwidth":true,"until":"2099-01-01T00:00:00Z"}' WHERE account_id = ?`, planNow.Unix(), ops.ID); err != nil {
+ t.Fatal(err)
+ }
+ row, err := fx.st.AccountPlan(ops.ID)
+ if err != nil || row == nil {
+ t.Fatalf("ops row: %v", err)
+ }
+ return row
+}
+
+func TestPlanExemptIsTheOpsAccountAlone(t *testing.T) {
+ fx := newConsoleFixture(t)
+ if !fx.st.planExempt(OpsAccountID) {
+ t.Fatal("ops is not exempt")
+ }
+ for _, id := range []int64{0, 2, 501} {
+ if fx.st.planExempt(id) {
+ t.Fatalf("account %d is exempt", id)
+ }
+ }
+}
+
+func TestPlanExemptLimitsPassWritesNoRecordAndRemovesAnOldOne(t *testing.T) {
+ fx := newConsoleFixture(t)
+ fx.srv.cfg.PlanCatalog = examplePlanCatalog(t)
+ ops := opsPlanAccount(t, fx, "paul@example.com")
+ other := planAccount(t, fx, 501)
+
+ // A fresh deployment: no row for ops, no record.
+ fx.srv.planLimitsPass(context.Background(), planNow)
+ if row, _ := fx.st.AccountPlan(ops.ID); row != nil {
+ t.Fatalf("the default pass gave ops a row: %+v", row)
+ }
+ if r, _ := readLimits(t, fx, ops.Sqid); r != nil {
+ t.Fatalf("ops has a limits record: %+v", r)
+ }
+ if r, _ := readLimits(t, fx, other.Sqid); r == nil {
+ t.Fatal("another account's record was not published")
+ }
+
+ // Dev today: a row and a record written before the exemption. The
+ // record goes once per console start; the row is left as it is.
+ row := opsSponsoredRow(t, fx, ops)
+ old := &plans.Record{Account: ops.Sqid, CatalogID: fx.srv.cfg.PlanCatalog.ID(), Plan: "free", Source: PlanSourceSponsored,
+ Revision: row.Revision, Limits: plans.Limits{RunningThings: 1, IdleSeconds: 60}, IssuedAt: planNow,
+ Throttle: &plans.Throttle{Awake: true}, Disabled: []string{"shop.example.com"}}
+ if _, err := plans.PutLimits(context.Background(), fx.rel, old, ""); err != nil {
+ t.Fatal(err)
+ }
+ fx.srv.planExemptSettled.Store(false) // a console start
+ fx.srv.planLimitsPass(context.Background(), planNow)
+ if r, _ := readLimits(t, fx, ops.Sqid); r != nil {
+ t.Fatalf("the old ops record is still there: %+v", r)
+ }
+ after, _ := fx.st.AccountPlan(ops.ID)
+ if after == nil || after.Revision != row.Revision || after.Source != row.Source || after.Plan != row.Plan ||
+ after.PublishedRevision != row.PublishedRevision || after.Throttle == nil || after.LapseSince.IsZero() {
+ t.Fatalf("the ops row changed: %+v, was %+v", after, row)
+ }
+
+ // A later pass, or a publish asked for directly, writes nothing back.
+ fx.srv.planLimitsPass(context.Background(), planNow)
+ if err := fx.srv.publishAccountLimits(context.Background(), *after, planNow); err != nil {
+ t.Fatal(err)
+ }
+ if r, _ := readLimits(t, fx, ops.Sqid); r != nil {
+ t.Fatalf("ops record written back: %+v", r)
+ }
+}
+
+func TestPlanExemptHasNoLimitsOrCaps(t *testing.T) {
+ fx := newConsoleFixture(t)
+ fx.srv.cfg.PlanCatalog = examplePlanCatalog(t)
+ ops := opsPlanAccount(t, fx, "paul@example.com")
+ opsSponsoredRow(t, fx, ops)
+ for i := range 5 {
+ capsApp(t, fx, ops, "app"+string(rune('a'+i)))
+ }
+ capsSidecar(t, fx, ops, "appa", "w1")
+ capsSidecar(t, fx, ops, "appa", "w2")
+ if l, err := fx.srv.EffectiveLimits(ops); err != nil || l != nil {
+ t.Fatalf("ops limits = %+v, %v; want none", l, err)
+ }
+ for i := range 6 {
+ if err := fx.st.AddMember(ops.ID, "crew"+string(rune('a'+i))+"@example.com", RoleMember, planNow); err != nil {
+ t.Fatal(err)
+ }
+ }
+ ctx := context.Background()
+ for name, err := range map[string]error{
+ "running things": fx.srv.checkRunningThings(ctx, ops, 1),
+ "restore": fx.srv.checkRestore(ctx, ops, "appa"),
+ "sidecars": fx.srv.checkSidecars(ctx, ops, "appa"),
+ "fleets": fx.srv.checkFleets(ops),
+ "custom domains": fx.srv.checkCustomDomains(ops),
+ "daemon": fx.srv.checkDaemon(ops, "appa"),
+ "always on": fx.srv.checkAlwaysOnCreate(ops, "appa"),
+ "members": fx.srv.checkMemberCap(ops, 10),
+ } {
+ if err != nil {
+ t.Errorf("%s for ops: %v", name, err)
+ }
+ }
+}
+
+func TestPlanExemptOwnershipIsNotAFreeAccount(t *testing.T) {
+ fx := newConsoleFixture(t)
+ fx.srv.cfg.PlanCatalog = examplePlanCatalog(t)
+ owner := "paul@example.com"
+ ops := opsPlanAccount(t, fx, owner)
+ if err := fx.srv.checkNewFreeAccount(owner); err != nil {
+ t.Fatalf("owning ops alone counted as a free account: %v", err)
+ }
+ opsSponsoredRow(t, fx, ops)
+ if err := fx.srv.checkNewFreeAccount(owner); err != nil {
+ t.Fatalf("owning ops with a free row counted as a free account: %v", err)
+ }
+ // The cap itself still holds for the person's real accounts.
+ if err := fx.st.CreateAccount(502, "bac", "mine", owner, planNow); err != nil {
+ t.Fatal(err)
+ }
+ if err := fx.srv.checkNewFreeAccount(owner); !isCap(err) {
+ t.Fatalf("owner of ops and one free account: %v, want the cap", err)
+ }
+}
+
+func TestPlanExemptHasNoGraceLapseOrWarnings(t *testing.T) {
+ fx := newConsoleFixture(t)
+ fx.srv.cfg.PlanCatalog = examplePlanCatalog(t)
+ ops := opsPlanAccount(t, fx, "paul@example.com")
+ row := opsSponsoredRow(t, fx, ops)
+ for i := range 5 {
+ capsApp(t, fx, ops, "app"+string(rune('a'+i)))
+ }
+ if err := fx.st.PutCapState(capState{AccountID: ops.ID, Cap: capRunningThings, Level: levelOver, Used: 5, Limit: 1,
+ FirstOver: planNow, GraceEnds: planNow, UpdatedAt: planNow}); err != nil {
+ t.Fatal(err)
+ }
+ if fx.st.lapseEligible(row) {
+ t.Fatal("ops's row is on the lapse path")
+ }
+ if lines, seen := fx.srv.planBanner(ops, RoleOwner, planNow); len(lines) != 0 || len(seen) != 0 {
+ t.Fatalf("ops banner = %v", lines)
+ }
+ fx.srv.planGracePass(context.Background(), planNow)
+ after, _ := fx.st.AccountPlan(ops.ID)
+ if after.Revision != row.Revision || after.Throttle == nil || after.Disabled != nil {
+ t.Fatalf("the grace pass touched the ops row: %+v", after)
+ }
+ states, _ := fx.st.CapStates(ops.ID)
+ for _, st := range states {
+ if st.UpdatedAt.After(planNow) || st.Cap != capRunningThings {
+ t.Fatalf("the grace pass measured ops: %+v", st)
+ }
+ }
+}
+
+func TestPlanExemptPlanDoorRefuses(t *testing.T) {
+ fx := newConsoleFixture(t)
+ fx.srv.cfg.PlanCatalog = examplePlanCatalog(t)
+ ops := opsPlanAccount(t, fx, "paul@example.com")
+ token := planOperatorToken(t, fx, "ops@keymail.dev", "code-plan-exempt")
+ status, out := getJSON(t, accountPlanURL(fx, ops.Sqid), token)
+ if status != http.StatusConflict || out["error"] != planCopyExempt {
+ t.Fatalf("GET ops plan = %d %v, want 409 %q", status, out, planCopyExempt)
+ }
+ status, out = postJSON(t, accountPlanURL(fx, ops.Sqid), map[string]any{"plan": "personal", "reason": "r"}, token)
+ if status != http.StatusConflict || out["error"] != planCopyExempt {
+ t.Fatalf("POST ops plan = %d %v, want 409 %q", status, out, planCopyExempt)
+ }
+ if row, _ := fx.st.AccountPlan(ops.ID); row != nil {
+ t.Fatalf("refused POST wrote %+v", row)
+ }
+ if err := fx.srv.applyAccountPlan(context.Background(), ops, "personal", nil, 0, PlanSourceOperator, nil, "r", "x", planNow); err == nil {
+ t.Fatal("a plan transition wrote ops's plan")
+ }
+ if row, _ := fx.st.AccountPlan(ops.ID); row != nil {
+ t.Fatalf("a plan transition wrote %+v", row)
+ }
+ // Membership changes still work, and touch no plan row.
+ if err := fx.srv.membershipTransition(context.Background(), ops, planNow, func(*sql.Tx) error { return nil }); err != nil {
+ t.Fatalf("ops membership change: %v", err)
+ }
+ for _, s := range []string{planCopyExempt, billingCopy["notice.exempt"]} {
+ if strings.Contains(s, "—") {
+ t.Errorf("%q has an em dash", s)
+ }
+ }
+ if planCopyExempt != strings.ToLower(planCopyExempt) || strings.HasSuffix(planCopyExempt, ".") {
+ t.Errorf("door string %q is not lower case without a final full stop", planCopyExempt)
+ }
+}
+
+func TestPlanExemptHasNoBilling(t *testing.T) {
+ bf := newBillingFixture(t)
+ bf.srv.billing.ready.Store(true)
+ ops := opsPlanAccount(t, bf.consoleFixture, "paul@example.com")
+
+ // The page: nothing to buy, whatever the row says.
+ for _, row := range []*AccountPlanRow{nil, {Plan: "free", Source: PlanSourceDefault}, {Plan: "free", Source: PlanSourceSponsored}} {
+ for _, owner := range []bool{true, false} {
+ in := billingPageInput{Ready: true, Owner: owner, Exempt: true, Row: row}
+ if st := decideBillingPage(in); st.Notice != "notice.exempt" || len(st.Offered) != 0 || st.OwnersOnly {
+ t.Fatalf("exempt page (owner %v, row %+v) = %+v", owner, row, st)
+ }
+ }
+ }
+ in, err := bf.srv.billingPageInputFor(ops, RoleOwner, billingNow)
+ if err != nil || !in.Exempt {
+ t.Fatalf("ops page input = %+v, %v", in, err)
+ }
+ if in, _ := bf.srv.billingPageInputFor(bf.acct, RoleOwner, billingNow); in.Exempt {
+ t.Fatal("another account's page is exempt")
+ }
+
+ // The doors: Checkout, change, renewal, seats.
+ ctx := bf.srv.billingClock(context.Background())
+ h, release := bf.srv.holdBilling(ops.Sqid)
+ _, cerr := bf.srv.checkoutLocked(h, ctx, ops, checkoutAsk{Plan: "personal", Currency: "usd"}, billingNow)
+ chErr := bf.srv.changeRefusalsLocked(h, ops, billingNow)
+ _, rErr := bf.srv.renewalLocked(h, ctx, ops, false, billingNow)
+ _, sErr := bf.srv.reconcileSeatsLocked(h, ctx, ops, 3, billingNow)
+ release()
+ for name, err := range map[string]error{"checkout": cerr, "change": chErr, "renewal": rErr, "seats": sErr} {
+ if err != errBillingExempt {
+ t.Errorf("%s for ops = %v, want errBillingExempt", name, err)
+ }
+ }
+ if team, err := bf.srv.billingTeam(ops); err != nil || team != nil {
+ t.Fatalf("ops billing team = %+v, %v", team, err)
+ }
+ bf.fake.Lock()
+ sent := bf.fake.Calls
+ bf.fake.Unlock()
+ if sent != 0 {
+ t.Fatalf("the provider got %d requests for ops", sent)
+ }
+}
+
+// ---- the guard ----------------------------------------------------------------
+
+// planExemptSites are the functions that decide plans or billing for one
+// account and must ask planExempt themselves.
+var planExemptSites = []string{
+ // Limits (req 1).
+ "EnsureDefaultPlans", "publishAccountLimits", "EffectiveLimits",
+ // Caps and lifecycle (req 2).
+ "checkMemberCap", "lapseEligible", "planBanner", "writePlanWarnings",
+ "transitionAccountPlan", "membershipTransition",
+ // Free accounts (req 3).
+ "checkNewFreeAccount",
+ // Billing (req 4).
+ "billingPageInputFor", "checkoutLocked", "changeRefusalsLocked", "renewalLocked",
+ "reconcileSeatsLocked", "billingTeam", "handleBillingPortal", "handleUpgrade",
+ "billingSyncPass", "observeIntent", "observeOp", "billingRestorePass", "billingDiscoveryPass",
+ // The plan door (req 5).
+ "accountPlanDoor",
+}
+
+// asksPlanExempt is whether fd's body names planExempt or the store's
+// planExemptID.
+func asksPlanExempt(fd *ast.FuncDecl) bool {
+ found := false
+ ast.Inspect(fd, func(n ast.Node) bool {
+ if id, ok := n.(*ast.Ident); ok && (id.Name == "planExempt" || id.Name == "planExemptID") {
+ found = true
+ }
+ return !found
+ })
+ return found
+}
+
+// callsAny is whether fd calls a function or method named one of names.
+func callsAny(fd *ast.FuncDecl, names ...string) bool {
+ found := false
+ ast.Inspect(fd, func(n ast.Node) bool {
+ call, ok := n.(*ast.CallExpr)
+ if !ok {
+ return !found
+ }
+ switch fn := call.Fun.(type) {
+ case *ast.Ident:
+ found = found || slices.Contains(names, fn.Name)
+ case *ast.SelectorExpr:
+ found = found || slices.Contains(names, fn.Sel.Name)
+ }
+ return !found
+ })
+ return found
+}
+
+// buildsPlanCap is whether fd makes a planCapError.
+func buildsPlanCap(fd *ast.FuncDecl) bool {
+ found := false
+ ast.Inspect(fd, func(n ast.Node) bool {
+ if cl, ok := n.(*ast.CompositeLit); ok {
+ if id, ok := cl.Type.(*ast.Ident); ok && id.Name == "planCapError" {
+ found = true
+ }
+ }
+ return !found
+ })
+ return found
+}
+
+// planExemptFindings: every named site asks planExempt; every function that
+// refuses with a plan cap or writes a limits record asks planExempt or
+// reads EffectiveLimits (which asks it). It answers the findings and the
+// sites it found.
+func planExemptFindings(files map[string]*ast.File, sites []string) (findings, found []string) {
+ for _, f := range files {
+ for _, d := range f.Decls {
+ fd, ok := d.(*ast.FuncDecl)
+ if !ok || fd.Body == nil {
+ continue
+ }
+ name := fd.Name.Name
+ if slices.Contains(sites, name) {
+ found = append(found, name)
+ if !asksPlanExempt(fd) {
+ findings = append(findings, name+" does not ask planExempt")
+ }
+ continue
+ }
+ if (buildsPlanCap(fd) || callsAny(fd, "PutLimits")) && !asksPlanExempt(fd) && !callsAny(fd, "EffectiveLimits") {
+ findings = append(findings, name+" applies a plan without asking planExempt or EffectiveLimits")
+ }
+ }
+ }
+ sort.Strings(findings)
+ return findings, found
+}
+
+// TestPlanExemptConsulted pins the one predicate (req 6): the limits, caps,
+// lifecycle, free-account, billing and door paths all ask it, and any new
+// cap refusal or limits write must too.
+func TestPlanExemptConsulted(t *testing.T) {
+ _, files := parsePackageSources(t)
+ findings, found := planExemptFindings(files, planExemptSites)
+ for _, f := range findings {
+ t.Error(f)
+ }
+ for _, name := range planExemptSites {
+ if !slices.Contains(found, name) {
+ t.Errorf("%s is gone; update planExemptSites", name)
+ }
+ }
+ fset, _ := parsePackageSources(t)
+ planted := parsePlanted(t, fset, "planted.go", `
+func (s *Server) checkNewThing(acct *Account) error { return &planCapError{msg: "x"} }
+func (s *Server) publishSideways(ctx int) { plans.PutLimits(nil, nil, nil, "") }
+func (s *Server) checkCounted(acct *Account) error { s.EffectiveLimits(acct); return &planCapError{msg: "x"} }
+func (s *Server) EffectiveLimits(acct *Account) {}
+`)
+ got, _ := planExemptFindings(planted, planExemptSites)
+ want := []string{
+ "EffectiveLimits does not ask planExempt",
+ "checkNewThing applies a plan without asking planExempt or EffectiveLimits",
+ "publishSideways applies a plan without asking planExempt or EffectiveLimits",
+ }
+ if !slices.Equal(got, want) {
+ t.Fatalf("planted findings = %q, want %q", got, want)
+ }
+}
diff --git a/internal/console/plangrace_cli_test.go b/internal/console/plangrace_cli_test.go
index bcf98a152..c736aa1cd 100644
--- a/internal/console/plangrace_cli_test.go
+++ b/internal/console/plangrace_cli_test.go
@@ -103,6 +103,7 @@ func TestCLIWarningOnAppScopedDoors(t *testing.T) {
func TestCLIWarningSaysStorageWritesDenied(t *testing.T) {
fx := newConsoleFixture(t)
fx.srv.cfg.PlanCatalog = examplePlanCatalog(t)
+ governOps(fx) // the fixture account is ops
acct, _ := fx.st.AccountBySqid(fx.sqid)
st := evaluateCap(nil, capStorage, 3_000_000_000, 1_000_000_000, time.Now().Add(-time.Hour))
st.AccountID = acct.ID
diff --git a/internal/console/plangrace_view_test.go b/internal/console/plangrace_view_test.go
index e0a928082..75118c7d5 100644
--- a/internal/console/plangrace_view_test.go
+++ b/internal/console/plangrace_view_test.go
@@ -13,6 +13,7 @@ import (
func overRow(t *testing.T, fx *consoleFixture) *Account {
t.Helper()
fx.srv.cfg.PlanCatalog = examplePlanCatalog(t)
+ governOps(fx) // the fixture account is ops
acct, _ := fx.st.AccountBySqid(fx.sqid)
// The real clock: page views and CLI requests record notice at
// time.Now(), which must not fall before the first over.
@@ -93,6 +94,7 @@ func TestBannerNoticeOnlyWhenRendered(t *testing.T) {
func TestBannerSaysEmailPaused(t *testing.T) {
fx := newConsoleFixture(t)
fx.srv.cfg.PlanCatalog = examplePlanCatalog(t)
+ governOps(fx) // the fixture account is ops
acct, _ := fx.st.AccountBySqid(fx.sqid)
st := evaluateCap(nil, capEmail, 100, 50, time.Now()) // free: 50 a day, paused at 100
st.AccountID = acct.ID
@@ -108,6 +110,7 @@ func TestBannerSaysEmailPaused(t *testing.T) {
func TestBannerSaysStorageWritesDenied(t *testing.T) {
fx := newConsoleFixture(t)
fx.srv.cfg.PlanCatalog = examplePlanCatalog(t)
+ governOps(fx) // the fixture account is ops
acct, _ := fx.st.AccountBySqid(fx.sqid)
st := evaluateCap(nil, capStorage, 3_000_000_000, 1_000_000_000, time.Now().Add(-time.Hour)) // 3x: the hard ceiling
st.AccountID = acct.ID
@@ -123,6 +126,7 @@ func TestBannerSaysStorageWritesDenied(t *testing.T) {
func TestBannerSaysBandwidthThrottled(t *testing.T) {
fx := newConsoleFixture(t)
fx.srv.cfg.PlanCatalog = examplePlanCatalog(t)
+ governOps(fx) // the fixture account is ops
acct, _ := fx.st.AccountBySqid(fx.sqid)
st := evaluateCap(nil, capBandwidth, 25_000_000_000, 10_737_418_240, time.Now()) // free: 10 GiB a month, 2x and over
st.AccountID = acct.ID
@@ -140,6 +144,7 @@ func TestBannerSaysBandwidthThrottled(t *testing.T) {
func lapsedOps(t *testing.T, fx *consoleFixture) (*Account, capState) {
t.Helper()
fx.srv.cfg.PlanCatalog = examplePlanCatalog(t)
+ governOps(fx) // the fixture account is ops
acct, _ := fx.st.AccountBySqid(fx.sqid)
if _, err := fx.st.SetAccountPlan(acct.ID, "free", nil, 0, PlanSourceOperator, nil, "r", "ops@example.com", time.Now()); err != nil {
t.Fatal(err)
diff --git a/internal/console/plangracepass.go b/internal/console/plangracepass.go
index 11d958505..949ff2fe6 100644
--- a/internal/console/plangracepass.go
+++ b/internal/console/plangracepass.go
@@ -98,7 +98,7 @@ func (s *Server) planGraceAccountLocked(ctx context.Context, acct *Account, now
measures, errs := s.measureCaps(ctx, acct, l, now)
// Plans 4d: an eligible account's leftovers. An inventory that cannot
// be read keeps both leftover rows and changes nothing turned off.
- eligible := lapseEligible(row)
+ eligible := s.store.lapseEligible(row)
var inv *lapseInventory
if eligible {
var invErr error
@@ -345,7 +345,7 @@ func humanGB(b int64) string {
// the page is written (Astra plans-4a finding 3). A store error shows no
// banner and never fails the page.
func (s *Server) planBanner(acct *Account, role string, now time.Time) ([]string, []capState) {
- if s.cfg.PlanCatalog == nil {
+ if s.cfg.PlanCatalog == nil || s.store.planExempt(acct.ID) {
return nil, nil
}
states, err := s.store.CapStates(acct.ID)
@@ -397,7 +397,7 @@ const (
// header, and must earn no notice. A person who owns the account receiving
// a cap that is over is notice received (spec §6); a service is not.
func (s *Server) writePlanWarnings(w http.ResponseWriter, r *http.Request, p Principal, acct *Account) {
- if s.cfg.PlanCatalog == nil || r.Header.Get(planWarningsAccept) != "1" {
+ if s.cfg.PlanCatalog == nil || s.store.planExempt(acct.ID) || r.Header.Get(planWarningsAccept) != "1" {
return
}
states, err := s.store.CapStates(acct.ID)
diff --git a/internal/console/planlapse.go b/internal/console/planlapse.go
index 3ad466483..4523e3bc0 100644
--- a/internal/console/planlapse.go
+++ b/internal/console/planlapse.go
@@ -12,9 +12,9 @@ import (
// lapseEligible reports whether an account is on the lapse path (plans 4d):
// its limits fell from a paid assignment and it is not sponsored. Sponsored
-// accounts never are (spec §9.2).
-func lapseEligible(row *AccountPlanRow) bool {
- return row != nil && !row.LapseSince.IsZero() && !planRowSponsored(row)
+// accounts never are (spec §9.2), and nor is the exempt account.
+func (s *Store) lapseEligible(row *AccountPlanRow) bool {
+ return row != nil && !s.planExempt(row.AccountID) && !row.LapseSince.IsZero() && !planRowSponsored(row)
}
func planRowSponsored(row *AccountPlanRow) bool {
@@ -176,6 +176,9 @@ func (s *Server) applyBillingPlan(ctx context.Context, acct *Account, next *bill
// once and the limits record is published best-effort.
func (s *Server) transitionAccountPlan(ctx context.Context, acct *Account, now time.Time,
write func(old *AccountPlanRow) (bool, error)) error {
+ if s.store.planExempt(acct.ID) {
+ return errPlanExempt // no plan change, operator's or billing's, reaches it
+ }
defer s.lapseLock(acct.ID)()
old, err := s.store.AccountPlan(acct.ID)
if err != nil {
@@ -384,7 +387,7 @@ func lapseCapOf(kind string) capID {
func (s *Server) lapseStages(acct *Account) func(capState) string {
none := func(capState) string { return "" }
row, err := s.store.AccountPlan(acct.ID)
- if err != nil || !lapseEligible(row) {
+ if err != nil || !s.store.lapseEligible(row) {
return none
}
items, err := s.store.LapseItems(acct.ID)
diff --git a/internal/console/planlapse_keep.go b/internal/console/planlapse_keep.go
index 082e7a5f5..6bcba2153 100644
--- a/internal/console/planlapse_keep.go
+++ b/internal/console/planlapse_keep.go
@@ -36,7 +36,7 @@ func (s *Server) planKeepOffered(acct *Account) bool {
return false
}
row, err := s.store.AccountPlan(acct.ID)
- if err != nil || !lapseEligible(row) {
+ if err != nil || !s.store.lapseEligible(row) {
return false
}
states, err := s.store.CapStates(acct.ID)
@@ -72,7 +72,7 @@ func (s *Server) handlePlanKeep(w http.ResponseWriter, r *http.Request) {
view := &planKeepView{Title: planKeepCopy["keep.title"], Save: planKeepCopy["keep.save"]}
p.PlanKeep = view
row, err := s.store.AccountPlan(acct.ID)
- if err != nil || !lapseEligible(row) {
+ if err != nil || !s.store.lapseEligible(row) {
if err != nil {
log.Printf("console: plan keep %s: %v", acct.Sqid, err)
}
@@ -186,7 +186,7 @@ func (s *Server) handlePlanKeepSave(w http.ResponseWriter, r *http.Request) {
http.Redirect(w, r, back, http.StatusSeeOther)
}
row, err := s.store.AccountPlan(acct.ID)
- if err != nil || !lapseEligible(row) {
+ if err != nil || !s.store.lapseEligible(row) {
fail(planKeepCopy["keep.nothing"])
return
}
diff --git a/internal/console/planlapse_test.go b/internal/console/planlapse_test.go
index 41d405b5a..3b0e61ae8 100644
--- a/internal/console/planlapse_test.go
+++ b/internal/console/planlapse_test.go
@@ -126,6 +126,8 @@ func TestApplyAccountPlanSponsoredIsNoLapse(t *testing.T) {
}
func TestLapseEligible(t *testing.T) {
+ st := &Store{planExemptID: OpsAccountID}
+ lapseEligible := st.lapseEligible
marked := &AccountPlanRow{Plan: "free", Source: PlanSourceOperator, LapseSince: planNow}
if !lapseEligible(marked) {
t.Fatal("a marked operator row is not eligible")
diff --git a/internal/console/planlimits.go b/internal/console/planlimits.go
index 0e9a20ab7..3e5e61b44 100644
--- a/internal/console/planlimits.go
+++ b/internal/console/planlimits.go
@@ -49,6 +49,7 @@ func (s *Server) planLimitsPass(ctx context.Context, now time.Time) {
jobFailed(ctx, fmt.Errorf("plan limits: default plans: %w", err))
return
}
+ s.settlePlanExempt(ctx, now)
// Page by account id: a row that cannot be published (an orphaned
// assignment) stays due, but never holds a later account back.
var after int64
@@ -79,11 +80,16 @@ func (s *Server) planLimitsPass(ctx context.Context, now time.Time) {
// record. An assignment the catalog cannot price (a plan or pack it no
// longer has) writes nothing, so boxes keep the last good record. A record
// already at this revision or newer, under this catalog, is left alone.
+// The exempt account's row writes nothing and is not marked: it has no
+// record, which boxes read as no limits.
func (s *Server) publishAccountLimits(ctx context.Context, row AccountPlanRow, now time.Time) error {
cat := s.cfg.PlanCatalog
if cat == nil {
return errors.New("no plan catalog")
}
+ if s.store.planExempt(row.AccountID) {
+ return nil
+ }
members, err := s.planMembers(&row, row.AccountID)
if err != nil {
return err
@@ -124,11 +130,12 @@ func (s *Server) publishAccountLimits(ctx context.Context, row AccountPlanRow, n
}
// EffectiveLimits is acct's limits under the configured catalog, or nil
-// when plans are off. An account with no row is on the default plan. A
-// team plan is limited at planMembers' count.
+// when plans are off or the account is exempt (planExempt). An account
+// with no row is on the default plan. A team plan is limited at
+// planMembers' count.
func (s *Server) EffectiveLimits(acct *Account) (*plans.Limits, error) {
cat := s.cfg.PlanCatalog
- if cat == nil {
+ if cat == nil || s.store.planExempt(acct.ID) {
return nil, nil
}
row, err := s.store.AccountPlan(acct.ID)
diff --git a/internal/console/planmail_test.go b/internal/console/planmail_test.go
index 9a774e97f..b79c59047 100644
--- a/internal/console/planmail_test.go
+++ b/internal/console/planmail_test.go
@@ -42,6 +42,7 @@ func planMailFixture(t *testing.T) *consoleFixture {
fx := newConsoleFixture(t)
fx.srv.cfg.MailProvisioner = mail.NewMemProvisioner("1")
fx.srv.cfg.PlanCatalog = examplePlanCatalog(t)
+ governOps(fx) // the fixture account is ops
addMailApp(t, fx, "blog")
addMailApp(t, fx, "shop")
return fx
diff --git a/internal/console/planmembers.go b/internal/console/planmembers.go
index 38d00d09a..02310e4ce 100644
--- a/internal/console/planmembers.go
+++ b/internal/console/planmembers.go
@@ -150,10 +150,11 @@ func (s *Store) MembershipTransition(accountID int64, cat *plans.Catalog, old *A
// (transitionAccountPlan), so a change that moves a team's limits
// re-converges the account and publishes its record at once (the limits
// pass retries a failed publication). Callers hold the account's member
-// lock. Without a catalog it is just the membership write.
+// lock. Without a catalog, or for the exempt account (planExempt), it is
+// just the membership write.
func (s *Server) membershipTransition(ctx context.Context, acct *Account, now time.Time, write func(tx *sql.Tx) error) error {
cat := s.cfg.PlanCatalog
- if cat == nil {
+ if cat == nil || s.store.planExempt(acct.ID) {
_, err := s.store.MembershipTransition(acct.ID, nil, nil, write, now)
return err
}
@@ -164,11 +165,11 @@ func (s *Server) membershipTransition(ctx context.Context, acct *Account, now ti
// checkMemberCap refuses adding more people to an account whose plan caps
// its members (max_members, Call 14) when they would pass the cap. Team
-// plans, sponsored rows, plans with no cap and consoles with no catalog
-// pass. Callers hold the account's member lock.
+// plans, sponsored rows, plans with no cap, the exempt account and consoles
+// with no catalog pass. Callers hold the account's member lock.
func (s *Server) checkMemberCap(acct *Account, adding int) error {
cat := s.cfg.PlanCatalog
- if cat == nil {
+ if cat == nil || s.store.planExempt(acct.ID) {
return nil
}
row, err := s.store.AccountPlan(acct.ID)
diff --git a/internal/console/planmembers_test.go b/internal/console/planmembers_test.go
index 38899a1b7..25302ac2b 100644
--- a/internal/console/planmembers_test.go
+++ b/internal/console/planmembers_test.go
@@ -149,6 +149,7 @@ func TestMembershipRiseReconvergesAndPublishes(t *testing.T) {
sam := newBrowser(t)
signUp(t, fx, sam, "code-sam")
fx.srv.cfg.PlanCatalog = examplePlanCatalog(t)
+ governOps(fx) // the fixture account is ops
acct := opsAccount(t, fx)
fillMembers(t, fx, acct.ID, 10)
applyPlan(t, fx, acct, "community", nil, nil, planNow)
@@ -299,6 +300,7 @@ func TestConcurrentInvitesRespectCap(t *testing.T) {
owner := newBrowser(t)
signUp(t, fx, owner, "code-owner")
fx.srv.cfg.PlanCatalog = examplePlanCatalog(t)
+ governOps(fx) // the fixture account is ops
acct := opsAccount(t, fx)
fillMembers(t, fx, acct.ID, 2)
applyPlan(t, fx, acct, "personal", nil, nil, planNow)
@@ -348,6 +350,7 @@ func TestConcurrentAcceptsRespectCap(t *testing.T) {
fx := newConsoleFixture(t)
browsers, tokens := acceptInvitees(t, fx, "kim@keymail.dev", "lee@keymail.dev")
fx.srv.cfg.PlanCatalog = examplePlanCatalog(t)
+ governOps(fx) // the fixture account is ops
acct := opsAccount(t, fx)
fillMembers(t, fx, acct.ID, 2)
applyPlan(t, fx, acct, "personal", nil, nil, planNow)
@@ -426,6 +429,7 @@ func TestMemberCapAtInvite(t *testing.T) {
owner := newBrowser(t)
signUp(t, fx, owner, "code-owner")
fx.srv.cfg.PlanCatalog = examplePlanCatalog(t)
+ governOps(fx) // the fixture account is ops
acct := opsAccount(t, fx)
fillMembers(t, fx, acct.ID, 2)
if _, err := fx.st.CreateInvite(acct.ID, "waiting@keymail.dev", "paul@keymail.dev", time.Now()); err != nil {
@@ -505,6 +509,7 @@ func TestMembershipRemoveDoorUnderLock(t *testing.T) {
owner := newBrowser(t)
signUp(t, fx, owner, "code-owner")
fx.srv.cfg.PlanCatalog = examplePlanCatalog(t)
+ governOps(fx) // the fixture account is ops
acct := opsAccount(t, fx)
fillMembers(t, fx, acct.ID, 11)
applyPlan(t, fx, acct, "community", nil, nil, planNow)
diff --git a/internal/console/planstorage_test.go b/internal/console/planstorage_test.go
index 313098b86..73d02661a 100644
--- a/internal/console/planstorage_test.go
+++ b/internal/console/planstorage_test.go
@@ -21,6 +21,7 @@ func deniedStoreFixture(t *testing.T, code string) (*consoleFixture, *objstore.M
fx, fake, token, _ := storeArmed(t, code)
grantStore(t, fx, token)
fx.srv.cfg.PlanCatalog = examplePlanCatalog(t)
+ governOps(fx) // the fixture account is ops
acct, _ := fx.st.AccountBySqid(fx.sqid)
return fx, fake, acct
}
diff --git a/internal/console/server.go b/internal/console/server.go
index 2d8d88c22..9578cce68 100644
--- a/internal/console/server.go
+++ b/internal/console/server.go
@@ -971,7 +971,10 @@ type Server struct {
// lapseLocks serialises, per account, everything that changes what a
// lapse turns off (plans 4d, Astra finding 1): a plan change, the grace
// pass's convergence and a keep save. Account id to *sync.Mutex.
- lapseLocks sync.Map
+ lapseLocks sync.Map
+ // planExemptSettled is set once settlePlanExempt has cleared what plans
+ // left on the exempt account in this process (planexempt.go).
+ planExemptSettled atomic.Bool
claimLossPageMu sync.Mutex
claimLossPageDone chan struct{}
diff --git a/internal/console/store.go b/internal/console/store.go
index 3764cc2d7..c6643a55d 100644
--- a/internal/console/store.go
+++ b/internal/console/store.go
@@ -56,6 +56,11 @@ type Store struct {
gate *claimGate
bound *claimBinding
+ // planExemptID is the account plans never govern: always OpsAccountID
+ // (planexempt.go). A field only so a test whose fixture account is ops
+ // can put that account under a plan.
+ planExemptID int64
+
// mailEventsPruned is when mail_events was last trimmed to its
// retention window, as unix seconds (mailevents.go). Zero means not yet
// this process, which is what makes the first event after a restart
@@ -85,7 +90,8 @@ func newStore(db *sql.DB) *Store {
_, _ = rand.Read(key)
ep := make([]byte, 8)
_, _ = rand.Read(ep)
- return &Store{codeEpoch: hex.EncodeToString(ep), db: db, rawPool: db, rawBoot: db, mailEventsPruned: new(atomic.Int64), mailPushPruned: new(atomic.Int64), codeKey: key, names: &appNameLocks{}}
+ return &Store{codeEpoch: hex.EncodeToString(ep), db: db, rawPool: db, rawBoot: db, mailEventsPruned: new(atomic.Int64), mailPushPruned: new(atomic.Int64), codeKey: key, names: &appNameLocks{},
+ planExemptID: OpsAccountID}
}
// Open opens (creating if needed) the console DB at path.