carlos / platform Public

free storage: refuse per-instance stores; approved book 2026-11-15-v2

Summary

Paul's #1086 decisions 8 and 10. On a plan that requires scanning, per-instance stores are refused on the enable door and on the gate every create, seed and import runs (before the walk and under its lock); a paid plan still gets them. Its sentence is a placeholder until copy review. Book 2026-11-15-v2 is the approved copy of the draft (status approved, same amounts); it is the stripe-setup default and the tests' approvedBook. Runbook: a Stripe step is needed, because the price map needs every key of the running book and keys carry its version, so 24 new prices at the same amounts.
claude agent, operated by paul@keymail.dev aba229d1aff70e59116298c91292ea254f11169f parent 7a7759f
8 files changed, +153 −30
  • cmd/console/stripesetup_script_test.go +19 −14
  • deploy/billing/pricebook-2026-11-15-v2.json +23 −0
  • docs/superpowers/plans/2026-11-15-free-storage-rollout.md +24 −13
  • internal/console/apistore_provision.go +23 −0
  • internal/console/freestorage_copy_pending.go +7 −0
  • internal/console/instanceprivatestore.go +1 −1
  • internal/console/storeselfserve_test.go +54 −0
  • scripts/stripe-setup.sh +2 −2

CI passed — run details

diff --git a/cmd/console/stripesetup_script_test.go b/cmd/console/stripesetup_script_test.go
index ae3e1aa2f..ef0ef75ca 100644
--- a/cmd/console/stripesetup_script_test.go
+++ b/cmd/console/stripesetup_script_test.go
@@ -24,7 +24,8 @@ import (
const (
stripeSetupScript = "../../scripts/stripe-setup.sh"
- approvedBook = "../../deploy/billing/pricebook-2026-11-14-v2.json"
+ approvedBook = "../../deploy/billing/pricebook-2026-11-15-v2.json"
+ flatApprovedBook = "../../deploy/billing/pricebook-2026-11-14-v2.json"
prevApprovedBook = "../../deploy/billing/pricebook-2026-11-01-v1.json"
draftBook = "../../deploy/billing/pricebook-2026-10-27-v1.json"
flatDraftBook = "../../deploy/billing/pricebook-2026-11-14-v1.json"
@@ -362,7 +363,7 @@ func TestStripeSetupLiveApply(t *testing.T) {
}
}
for _, p := range fw.Objects["prices"] {
- if k, _ := p["lookup_key"].(string); !strings.HasPrefix(k, "2026-11-14-v2/") {
+ if k, _ := p["lookup_key"].(string); !strings.HasPrefix(k, "2026-11-15-v2/") {
t.Errorf("price %v has lookup key %q, not one of the approved book's", p["id"], k)
}
}
@@ -375,7 +376,7 @@ func TestStripeSetupLiveApply(t *testing.T) {
if got := fw.Objects["webhook_endpoints"][0]["enabled_events"]; !reflect.DeepEqual(got, webhookEvents) {
t.Errorf("webhook endpoint events %v, want %v", got, webhookEvents)
}
- for _, want := range []string{"CARLOS_BILLING=live", `"2026-11-14-v2/pack/apps/gbp":"price_`, "rk_live_"} {
+ for _, want := range []string{"CARLOS_BILLING=live", `"2026-11-15-v2/pack/apps/gbp":"price_`, "rk_live_"} {
if !strings.Contains(stdout, want) {
t.Errorf("stdout lacks %q:\n%s", want, stdout)
}
@@ -453,7 +454,7 @@ func TestStripeSetupLiveDryRunSendsNothing(t *testing.T) {
}
}
}
- if printed == 0 || !strings.Contains(stdout, "2026-11-14-v2/personal/usd") || !strings.Contains(stdout, "CARLOS_BILLING=live") {
+ if printed == 0 || !strings.Contains(stdout, "2026-11-15-v2/personal/usd") || !strings.Contains(stdout, "CARLOS_BILLING=live") {
t.Fatalf("the dry run printed no live plan:\n%s", stdout)
}
}
@@ -579,7 +580,7 @@ func TestStripeSetupReplayedArchivedPriceStops(t *testing.T) {
fw := w.load()
archived := ""
for _, p := range fw.Objects["prices"] {
- if p["lookup_key"] == "2026-11-14-v2/personal/usd" {
+ if p["lookup_key"] == "2026-11-15-v2/personal/usd" {
p["active"], p["lookup_key"] = false, nil
archived = p["id"].(string)
}
@@ -609,10 +610,10 @@ func TestStripeSetupReplayedArchivedPriceStops(t *testing.T) {
// installs). Books for catalog 2026-10-20-v1 priced its per-member team
// plans, which this console no longer loads (#1033); they stay as the
// record of what was sold, and a subscription bought under one keeps its
-// price keys. approvedBook is the newest approved book, 2026-11-14-v2
-// (Paul, 2026-11-14), written from the draft 2026-11-14-v1, which stays as
-// it was. The draft 2026-11-15-v1 (#1076) prices the draft catalog of the
-// same version and stays a draft until Paul approves it.
+// price keys. approvedBook is the newest approved book, 2026-11-15-v2
+// (Paul, 2026-11-15, #1086), written from the draft 2026-11-15-v1, which
+// stays as it was; flatApprovedBook, 2026-11-14-v2, is the one before it.
+// The draft 2026-11-15-v1 stays a draft.
func TestRepoPriceBooksLoad(t *testing.T) {
catalogs := map[string]*plans.Catalog{}
catalogFor := func(version string) *plans.Catalog {
@@ -668,10 +669,14 @@ func TestRepoPriceBooksLoad(t *testing.T) {
if current == 0 {
t.Error("no book prices a catalog in deploy/billing")
}
+ if _, err := plans.LoadPriceBook(flatApprovedBook, catalogFor("2026-11-14-v1")); err != nil {
+ t.Errorf("%s: %v", flatApprovedBook, err)
+ }
if newestApproved != approvedBook {
t.Errorf("the newest approved book is %s, not %s", newestApproved, approvedBook)
}
- for book, catalog := range map[string]string{flatDraftBook: "2026-11-14-v1", freeStorageDraftBook: "2026-11-15-v1"} {
+ for book, catalog := range map[string]string{flatDraftBook: "2026-11-14-v1", freeStorageDraftBook: "2026-11-15-v1"} { // drafts
+
draft, err := plans.LoadPriceBook(book, catalogFor(catalog))
if err != nil || draft.Approved() {
t.Fatalf("%s: %v, approved %v; want a draft that loads", book, err, err == nil && draft.Approved())
@@ -705,9 +710,9 @@ func TestStripeSetupFlatBook(t *testing.T) {
t.Errorf("%d prices, want 24 per book", n)
}
want := map[string]float64{
- "2026-11-14-v2/community/eur": 5000, "2026-11-14-v2/community/usd": 6000, "2026-11-14-v2/community/gbp": 4500,
- "2026-11-14-v2/business/eur": 50000, "2026-11-14-v2/business/usd": 60000, "2026-11-14-v2/business/gbp": 45000,
- "2026-11-14-v2/personal/eur": 2400,
+ "2026-11-15-v2/community/eur": 5000, "2026-11-15-v2/community/usd": 6000, "2026-11-15-v2/community/gbp": 4500,
+ "2026-11-15-v2/business/eur": 50000, "2026-11-15-v2/business/usd": 60000, "2026-11-15-v2/business/gbp": 45000,
+ "2026-11-15-v2/personal/eur": 2400,
}
for _, p := range fw.Objects["prices"] {
k, _ := p["lookup_key"].(string)
@@ -732,7 +737,7 @@ func TestStripeSetupFlatBook(t *testing.T) {
t.Fatalf("printed price map %q: %v, want the flat book's 24 keys", line, err)
}
for k := range printed {
- if !strings.HasPrefix(k, "2026-11-14-v2/") {
+ if !strings.HasPrefix(k, "2026-11-15-v2/") {
t.Errorf("printed key %q is not the flat book's", k)
}
}
diff --git a/deploy/billing/pricebook-2026-11-15-v2.json b/deploy/billing/pricebook-2026-11-15-v2.json
new file mode 100644
index 000000000..dc35f73c8
--- /dev/null
+++ b/deploy/billing/pricebook-2026-11-15-v2.json
@@ -0,0 +1,23 @@
+{
+ "version": "2026-11-15-v2",
+ "status": "approved",
+ "catalog_version": "2026-11-15-v1",
+ "default_currency": "usd",
+ "currencies": ["usd", "eur", "gbp"],
+ "country_currency": {
+ "eur": ["AT", "BE", "BG", "HR", "CY", "CZ", "DK", "EE", "FI", "FR", "DE", "GR", "HU", "IE", "IT", "LV", "LT", "LU", "MT", "NL", "PL", "PT", "RO", "SK", "SI", "ES", "SE"],
+ "gbp": ["GB"]
+ },
+ "plans": {
+ "personal": {"usd": 2800, "eur": 2400, "gbp": 2200},
+ "community": {"usd": 6000, "eur": 5000, "gbp": 4500},
+ "business": {"usd": 60000, "eur": 50000, "gbp": 45000}
+ },
+ "packs": {
+ "apps": {"usd": 1200, "eur": 1000, "gbp": 900},
+ "disk": {"usd": 3600, "eur": 3100, "gbp": 2800},
+ "storage": {"usd": 1200, "eur": 1000, "gbp": 900},
+ "email": {"usd": 2400, "eur": 2100, "gbp": 1900},
+ "bandwidth": {"usd": 4800, "eur": 4100, "gbp": 3800}
+ }
+}
diff --git a/docs/superpowers/plans/2026-11-15-free-storage-rollout.md b/docs/superpowers/plans/2026-11-15-free-storage-rollout.md
index 7eb6c1b30..26d4dcd9e 100644
--- a/docs/superpowers/plans/2026-11-15-free-storage-rollout.md
+++ b/docs/superpowers/plans/2026-11-15-free-storage-rollout.md
@@ -21,21 +21,32 @@ keeps fixtures only.
before 2026-11-15 (`kept_storage`). Every paid plan, pack, ceiling, the
PDF allowances and the sponsor cutoff are the flagship's.
-## 1. Paul approves
+## 1. Paul approves (done, 2026-11-15, #1086)
+
+Paul approved the figures, the cutoff, the copy (two reviews) and the book.
+As the process requires, the approval is a new file,
+`deploy/billing/pricebook-2026-11-15-v2.json`: the draft's amounts with
+`"status": "approved"`. It is the script's default `PRICE_BOOK` and the
+test's `approvedBook`. The catalog keeps its version, `2026-11-15-v1`.
+
+## 2. Stripe: needed, even though Free has no price
+
+The console's price map must hold a price for every key of the book it
+runs (`billing.ParsePriceMap`), and keys carry the book version
+(`2026-11-15-v2/personal/eur`). One Stripe price cannot serve two keys.
+So the new book needs 24 new prices, at the same amounts, live and in the
+sandbox: `scripts/stripe-setup.sh` as in the flat-plans runbook, steps 2
+and 3 (`--check`, then `--apply`; it reuses the products, portal, coupon
+and webhook). Then merge its printed map into `CARLOS_BILLING_PRICES`
+beside the current keys, so subscriptions bought under 2026-11-14-v2 stay
+recognised:
-The figures, the copy (every `copy pending review (#1076): <key>`
-placeholder is replaced by the approved sentence before merge) and the
-cutoff. Approval is new files, never an edit: book
-`pricebook-2026-11-15-v2.json` with `"status": "approved"`; the catalog keeps
-its version. Move `approvedBook` in `cmd/console/stripesetup_script_test.go`
-and the script's default `PRICE_BOOK` with it.
-
-## 2. Stripe
+```
+jq -cS -s '.[0] + .[1]' <(printf '%s' "$OLD") <(printf '%s' "$NEW")
+```
-A new book version means new price keys (`2026-11-15-v2/...`): run
-`scripts/stripe-setup.sh` as in the flat-plans runbook, steps 2 and 3, and
-merge the printed map into `CARLOS_BILLING_PRICES` beside the current keys.
-Amounts are unchanged.
+No subscription moves: the amounts are unchanged, and an earlier book's
+subscription keeps its price keys for life.
## 3. Order: binary first, then the catalog
diff --git a/internal/console/apistore_provision.go b/internal/console/apistore_provision.go
index 62f9ac8b6..03a058618 100644
--- a/internal/console/apistore_provision.go
+++ b/internal/console/apistore_provision.go
@@ -119,5 +119,28 @@ func (s *Server) storeProvisionApproval(ctx context.Context, w http.ResponseWrit
jsonError(w, http.StatusForbidden, "this account is not approved for object storage. run `carlos store apply` to ask for it")
return nil, false
}
+ // Per-instance stores are environment stores, which are not scanned:
+ // a plan that requires scanning gets none, approval or not (Paul, #1086
+ // decision 8). This is the instance and seed create paths' gate, both
+ // before the walk and again under its lock.
+ if !s.refuseInstanceStoresIfScanned(w, acct) {
+ return nil, false
+ }
return e, true
}
+
+// refuseInstanceStoresIfScanned answers false, having refused on w, when
+// acct's plan requires its stores scanned (storeScanRequired).
+func (s *Server) refuseInstanceStoresIfScanned(w http.ResponseWriter, acct *Account) bool {
+ scan, err := s.storeScanRequired(acct)
+ if err != nil {
+ log.Printf("console: instance store %s: plan limits: %v", acct.Sqid, err)
+ jsonError(w, http.StatusBadGateway, "could not read the storage application. try again")
+ return false
+ }
+ if scan {
+ jsonError(w, http.StatusConflict, freeStorageCopyPending["store.scan_required.instance"])
+ return false
+ }
+ return true
+}
diff --git a/internal/console/freestorage_copy_pending.go b/internal/console/freestorage_copy_pending.go
new file mode 100644
index 000000000..4e213eace
--- /dev/null
+++ b/internal/console/freestorage_copy_pending.go
@@ -0,0 +1,7 @@
+package console
+
+// Copy in Paul's review (#1076, round 2). Each value is replaced by the
+// approved sentence, and moved into freestorage_copy.go, before merge.
+var freeStorageCopyPending = map[string]string{
+ "store.scan_required.instance": "copy pending review (#1076): store.scan_required.instance",
+}
diff --git a/internal/console/instanceprivatestore.go b/internal/console/instanceprivatestore.go
index f5fb17da2..972483c01 100644
--- a/internal/console/instanceprivatestore.go
+++ b/internal/console/instanceprivatestore.go
@@ -450,5 +450,5 @@ func (s *Server) instancePrivateStorageAllowed(ctx context.Context, w http.Respo
"this account is not approved for object storage, so its instances cannot be given storage of their own — run `carlos store apply` and ask an operator to approve it first")
return false
}
- return true
+ return s.refuseInstanceStoresIfScanned(w, acct)
}
diff --git a/internal/console/storeselfserve_test.go b/internal/console/storeselfserve_test.go
index 6e4fe271b..1784f5589 100644
--- a/internal/console/storeselfserve_test.go
+++ b/internal/console/storeselfserve_test.go
@@ -3,6 +3,7 @@ package console
import (
"context"
"net/http"
+ "net/http/httptest"
"strings"
"testing"
"time"
@@ -247,3 +248,56 @@ func storedRecordIn(t *testing.T, fx *consoleFixture, app, env string) *objstore
}
return rec
}
+
+// Per-instance stores are environment stores, which are not scanned: on a
+// plan that requires scanning, an approved account gets none, on the
+// enable door, the preflight every create, seed and import runs, and the
+// gate under the store lock (Paul, #1086 decision 8).
+func TestScanRequiredRefusesPerInstanceStores(t *testing.T) {
+ scanned := func(fx *consoleFixture) {
+ fx.st.planExemptID = 0
+ fx.srv.cfg.PlanCatalog = draftFreeStorageCatalog(t)
+ }
+ t.Run("enable door", func(t *testing.T) {
+ fx, _, token, _ := privateStorageFixture(t, "code-scan-instance-enable")
+ fx.srv.cfg.AppsDomain = "oncarlos.test"
+ scanned(fx)
+ status, _, out := rawReq(t, http.MethodPut, enableURL(fx, "bab", "titogo"), token, `{"private_storage":true}`)
+ if status != http.StatusConflict || !strings.Contains(out, freeStorageCopyPending["store.scan_required.instance"]) {
+ t.Fatalf("enable = %d %s, want the scan-required refusal", status, out)
+ }
+ assertNoPolicy(t, fx)
+ })
+ t.Run("create, seed and import preflight", func(t *testing.T) {
+ fx, fake, acct := seededStoreFixture(t, "code-scan-instance-preflight")
+ scanned(fx)
+ w := httptest.NewRecorder()
+ if _, ok := fx.srv.instanceStorePreflight(context.Background(), w, acct, "shop"); ok || w.Code != http.StatusConflict {
+ t.Fatalf("preflight = %v (%d %s), want the scan-required refusal", ok, w.Code, w.Body.String())
+ }
+ untouched(t, fake, "a refused per-instance preflight")
+ })
+ t.Run("under the store lock", func(t *testing.T) {
+ fx, fake, acct := seededStoreFixture(t, "code-scan-instance-locked")
+ scanned(fx)
+ w := httptest.NewRecorder()
+ if _, ok, err := fx.srv.instanceStoreProvisionFor(context.Background(), w, acct, "shop", "canary", "alice@keymail.dev", seedA); ok || err != nil || w.Code != http.StatusConflict {
+ t.Fatalf("provision = %v, %v (%d %s), want the scan-required refusal", ok, err, w.Code, w.Body.String())
+ }
+ untouched(t, fake, "a refused per-instance store")
+ if rec, _, _ := objstore.GetIn(context.Background(), fx.rel, fx.sqid, "shop", "canary"); rec != nil {
+ t.Fatalf("a refused per-instance store was declared: %+v", rec)
+ }
+ })
+ t.Run("a paid plan still may", func(t *testing.T) {
+ fx, _, acct := seededStoreFixture(t, "code-scan-instance-paid")
+ scanned(fx)
+ if _, err := fx.st.SetAccountPlan(OpsAccountID, "personal", nil, PlanSourceOperator, nil, "test", "op", time.Now()); err != nil {
+ t.Fatal(err)
+ }
+ w := httptest.NewRecorder()
+ if _, ok, err := fx.srv.instanceStoreProvisionFor(context.Background(), w, acct, "shop", "canary", "alice@keymail.dev", seedA); !ok || err != nil {
+ t.Fatalf("paid provision = %v, %v (%d %s)", ok, err, w.Code, w.Body.String())
+ }
+ })
+}
diff --git a/scripts/stripe-setup.sh b/scripts/stripe-setup.sh
index e2ca09f46..75411c33f 100755
--- a/scripts/stripe-setup.sh
+++ b/scripts/stripe-setup.sh
@@ -40,7 +40,7 @@
# be using. It is the second confirmation of a live run.
# Without --live it must be unset.
# PRICE_BOOK the book file. Default
-# deploy/billing/pricebook-2026-11-14-v2.json.
+# deploy/billing/pricebook-2026-11-15-v2.json.
# PRICE_BOOK_PATH where the console box keeps the book, for the
# printed CARLOS_PRICE_BOOK. Default
# /etc/carlos/<book file name>.
@@ -168,7 +168,7 @@ else
[[ "$account" =~ ^acct_[A-Za-z0-9]+$ ]] || die "STRIPE_ACCOUNT must look like acct_..."
fi
-book_file="${PRICE_BOOK:-$here/../deploy/billing/pricebook-2026-11-14-v2.json}"
+book_file="${PRICE_BOOK:-$here/../deploy/billing/pricebook-2026-11-15-v2.json}"
[[ -r "$book_file" ]] || die "PRICE_BOOK $book_file cannot be read"
book_path="${PRICE_BOOK_PATH:-/etc/carlos/$(basename "$book_file")}"
catalog_path="${PLAN_CATALOG_PATH:-/etc/carlos/plans.json}"