Skip to content

[decision] Demote AI budget circuit breakers to observe-only (BUDGET_ENFORCE, default off) — keep structural caps + meter; re-enable at paid launch #485

Description

@serge-ivo

Decision

Demote the AI budget circuit breakers to observe-only at this stage. Keep the structural caps and the usage meter; stop hard-blocking on dollar/token ceilings. Re-enable enforcement at paid launch.

Why

What changed (this issue)

  • New soft-launch switch BUDGET_ENFORCE (default off), mirroring isPaywallEnforced (billing.ts:185). The two daily account circuit breakers (chargedMicros and tokens) in reserveDelegation (delegation-budget-store.ts) only block when it is on; otherwise usage is metered but never stopped.
  • Kept, untouched: the structural per-tree caps (delegations / depth in the atomic UPDATE) and the whole ai_usage meter + /v1/usage.
  • Visible reminders that it's off (so we get nudged to turn it on):
    • Loud comment at the gate referencing this issue.
    • Commented-out BUDGET_ENFORCE in workers/api/wrangler.toml next to PAYWALL_ENFORCE.
    • A note on the console Usage page: "Budget limits are disabled (observe-only) — usage is metered but never blocked."
  • Enforcement tests set BUDGET_ENFORCE:"1" so the breaker logic stays covered.

Re-enable trigger

Turn BUDGET_ENFORCE on when the subscription-pool economics go live (creators paid from platform Workers-AI/quota spend) — that is when unattributed token use becomes our cost and a real, calibrated breaker earns its place. By then the ai_usage distribution exists to calibrate it from. Until then: meter + structural caps + (later) an alert on payer='platform' spend, which is the only path that is real platform money.

Parked under this decision (deferred, not before external users)

Reframes epic #478; the D1 config resolver from #474 stays in place (we'll want it when enforcement returns).

Acceptance criteria

  • BUDGET_ENFORCE env switch exists, default off; account circuit breakers are no-ops when off.
  • Structural caps and the ai_usage meter are unchanged.
  • Console Usage page shows the "limits disabled (observe-only)" note.
  • wrangler.toml carries the commented-out flag; gate comment references this issue.
  • Tests: breaker-enforcement tests pass with BUDGET_ENFORCE:"1"; a new test asserts no block when off.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3: laterDesign, strategy, or deferred pending a decision or demandbackendBackend / Worker / API workconnectorsConnector + tool frameworkenhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions