carlos / platform Public

console: ops-account owners skip the daily app-creation limit (#500)

A benchmark signed in as the platform owner ran out of the per-person
budget of ten app creations a day. The budget is a ceiling on a stolen
token, and an ops owner's token already carries the whole platform, so
allowCreate lets ops owners through. Everyone else, including owners of
other accounts, keeps the limit. A store error is not an exemption.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Human

Prompt

Can we take #500?

From this commit's own message. The prompt ledger has no entries for it — which is what a squashed, rebased or amended commit looks like, and what every commit looks like in a repo without a ledger.

Summary

allowCreate skips the person create budget for owners of the ops account; new test pins that a non-ops account owner still stops at cliCreateBurst.
claude agent, operated by paul@keymail.dev 1dc107c4b01050704a05b62257555c77b502a55a parent b7802fd
2 files changed, +44 −0
  • internal/console/authcli_test.go +36 −0
  • internal/console/svcprincipal.go +8 −0

CI cancelled — superseded by a newer push — run details

diff --git a/internal/console/authcli_test.go b/internal/console/authcli_test.go
index 8074b5acb..211b238e6 100644
--- a/internal/console/authcli_test.go
+++ b/internal/console/authcli_test.go
@@ -675,6 +675,42 @@ func TestPersonBudgetsAreUnchanged(t *testing.T) {
}
}
+// TestOpsOwnerSkipsTheCreateBudget is #500: an owner of the ops account
+// creates apps in any account of theirs past cliCreateBurst, because a
+// benchmark run signed in as the platform owner ran out of it. Owning some
+// other account is not enough: carol owns the same demo account and still
+// stops at the ordinary limit.
+func TestOpsOwnerSkipsTheCreateBudget(t *testing.T) {
+ fx := newConsoleFixture(t)
+ const demoID = 4242
+ if err := fx.st.CreateAccount(demoID, "cdef", "Demo", "paul@keymail.dev", time.Now()); err != nil {
+ t.Fatal(err)
+ }
+ for _, addr := range []string{"paul@keymail.dev", "carol@keymail.dev"} {
+ if err := fx.st.AddMember(demoID, addr, RoleOwner, time.Now()); err != nil {
+ t.Fatal(err)
+ }
+ }
+ paul := cliToken(t, fx, "paul@keymail.dev", "code-ops-owner-budget")
+ for i := 0; i < cliCreateBurst+2; i++ {
+ name := fmt.Sprintf("bench-%d", i)
+ if status, out := postJSON(t, fx.ts.URL+"/api/cli/apps/cdef/new", map[string]string{"name": name}, paul); status != http.StatusOK {
+ t.Fatalf("ops owner create %d = %d %v, want no daily limit", i, status, out)
+ }
+ }
+ carol := cliToken(t, fx, "carol@keymail.dev", "code-demo-owner-budget")
+ for i := 0; i < cliCreateBurst; i++ {
+ name := fmt.Sprintf("carol-%d", i)
+ if status, out := postJSON(t, fx.ts.URL+"/api/cli/apps/cdef/new", map[string]string{"name": name}, carol); status != http.StatusOK {
+ t.Fatalf("demo owner create %d = %d %v", i, status, out)
+ }
+ }
+ status, out := postJSON(t, fx.ts.URL+"/api/cli/apps/cdef/new", map[string]string{"name": "carol-over"}, carol)
+ if status != http.StatusTooManyRequests {
+ t.Errorf("demo owner create %d+1 = %d %v, want 429: only ops owners skip the limit", cliCreateBurst, status, out)
+ }
+}
+
// TestTwoNamedServicesHaveSeparateBudgets is Minor 5 (Task 5 review): two
// DIFFERENT named services in one account must not share a budget just
// because they share an account — closing this alongside C32's empty-name
diff --git a/internal/console/svcprincipal.go b/internal/console/svcprincipal.go
index 12a1c1482..e99996bf1 100644
--- a/internal/console/svcprincipal.go
+++ b/internal/console/svcprincipal.go
@@ -584,8 +584,16 @@ func principalKey(p Principal) string {
// one it is talking to — a call site that got it wrong would be a server
// drawing down an operator's budget, which is the bug this whole change is
// about.
+//
+// An owner of the ops account skips the person budget (#500): it is a
+// ceiling on a stolen token, and the platform owner's token already
+// carries the whole platform. Their benchmark runs create dozens of apps
+// a day on demo accounts. A store error is not an exemption.
func (s *Server) allowCreate(p Principal, now time.Time) bool {
if p.Kind == PrincipalUser {
+ if role, err := s.store.Role(OpsAccountID, p.Address); err == nil && role == RoleOwner {
+ return true
+ }
return s.cli.create.allow(principalKey(p), now)
}
return s.cli.svcCreate.allow(principalKey(p), now)