Skip to content

Exempt paid organizations from the execution rate-limit backstop - #1695

Merged
RhysSullivan merged 1 commit into
mainfrom
rhys/paid-plan-rate-limit-exemption
Aug 20, 2026
Merged

Exempt paid organizations from the execution rate-limit backstop#1695
RhysSullivan merged 1 commit into
mainfrom
rhys/paid-plan-rate-limit-exemption

Conversation

@RhysSullivan

Copy link
Copy Markdown
Collaborator

The per-org hourly execution cap is an abuse backstop sized for the free tier, but it applied to every organization regardless of plan. A paid org running a heavy workload crossed it and was blocked mid-run — the client saw Rate limit exceeded: too many executions this hour, and the agent stopped using the product and switched to a direct integration instead.

What changed

  • Paid orgs skip the cap. "Paid" is hasPaidOrganizationSubscription from extensions/billing/plans.ts — the same PAID_AUTUMN_PLAN_IDS config the org-creation and seat gates already read, so it means one thing across the app.
  • The exemption resolves only when the counter reports an org over the limit. Under the cap nothing extra runs, so the common path costs exactly what it did before. The answer is then cached per org, so an org running well past the cap does one lookup per TTL rather than one per execution.
  • The limiter still names no billing concept: it takes an opaque isExempt predicate, and the Autumn coupling lives in execution-stack-metered.ts, which already owns that dependency.
  • Blocks are now logged with the org id and count. Nothing recorded them before — a blocked execution is never usage-tracked, and it is deliberately not sent to Sentry, so the only previous evidence a block had happened was a user reporting it.

Fail-open behaviour

The counter still fails open: an unreachable or slow counter DO allows the execution, unchanged.

An unresolved exemption deliberately does not. The balance gate already fails open when Autumn is unreachable, so if the exemption did too, a billing outage would switch the backstop off entirely — which is the exact "billing outage plus runaway automation" case it exists to cover. A stale positive is reused when one is cached, so a blip cannot flip a known-paid org into a block mid-workload; otherwise the cap applies.

Verification

  • apps/cloud/src/engine/execution-rate-limit.node.test.ts — 9 new unit tests: no lookup under the cap, blocked when not exempt, allowed when exempt, cached, re-resolved after TTL, fail-closed with nothing cached, stale positive honoured on later failure, counter failure still fails open.
  • New e2e scenario in cloud/mcp-execution-limits.test.ts: a paid org runs past the cap and every execution is still metered. It uses a new autumn.attachPlan surface helper and Enterprise, which the emulator activates inline (no price, no card-required trial) and whose unlimited executions isolate the backstop as the only guard under test.
  • Full cloud unit suite green (289 tests), lint, typecheck, format clean.
  • Cloud e2e mcp-execution-limits passed on a cold run (5/5, including the new scenario).

Note on e2e reruns: this suite only passes on the first local run; every rerun fails all scenarios at MCP connect with InvalidGrantError: The code is invalid or has been used. Confirmed environmental — unmodified main fails identically in the same shell. Worth a look separately; it is not introduced here.

@github-actions

github-actions Bot commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Cloudflare preview

Torn down — the PR is closed.

@pkg-pr-new

pkg-pr-new Bot commented Aug 19, 2026

Copy link
Copy Markdown

Open in StackBlitz

@executor-js/codemode-core

npm i https://pkg.pr.new/@executor-js/codemode-core@1695

@executor-js/runtime-quickjs

npm i https://pkg.pr.new/@executor-js/runtime-quickjs@1695

@executor-js/plugin-file-secrets

npm i https://pkg.pr.new/@executor-js/plugin-file-secrets@1695

@executor-js/plugin-graphql

npm i https://pkg.pr.new/@executor-js/plugin-graphql@1695

@executor-js/plugin-keychain

npm i https://pkg.pr.new/@executor-js/plugin-keychain@1695

@executor-js/plugin-mcp

npm i https://pkg.pr.new/@executor-js/plugin-mcp@1695

@executor-js/plugin-onepassword

npm i https://pkg.pr.new/@executor-js/plugin-onepassword@1695

@executor-js/plugin-openapi

npm i https://pkg.pr.new/@executor-js/plugin-openapi@1695

@executor-js/cli

npm i https://pkg.pr.new/@executor-js/cli@1695

@executor-js/config

npm i https://pkg.pr.new/@executor-js/config@1695

@executor-js/execution

npm i https://pkg.pr.new/@executor-js/execution@1695

@executor-js/sdk

npm i https://pkg.pr.new/@executor-js/sdk@1695

executor

npm i https://pkg.pr.new/executor@1695

commit: bae4a7b

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Aug 19, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
executor-cloud bae4a7b Aug 20 2026, 03:25 PM

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Aug 19, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
executor-marketing bae4a7b Commit Preview URL

Branch Preview URL
Aug 20 2026, 03:25 PM

The per-org hourly cap was sized for free-tier abuse but applied to every
org regardless of plan, so a paying customer running a heavy workload was
blocked mid-run.

Paid orgs now skip the cap. The exemption is resolved only once the counter
reports an org over the limit, so the common path is unchanged, and the
result is cached per org. An unresolved exemption does not fail open: that
would disable the backstop during exactly the billing outage it exists to
cover, so a stale positive is reused when available and the cap otherwise
applies. Blocks are logged, which nothing did before.
@RhysSullivan
RhysSullivan force-pushed the rhys/paid-plan-rate-limit-exemption branch from 47f3c8a to bae4a7b Compare August 20, 2026 15:22
@RhysSullivan
RhysSullivan marked this pull request as ready for review August 20, 2026 15:28
@RhysSullivan
RhysSullivan merged commit b917755 into main Aug 20, 2026
44 checks passed
@RhysSullivan
RhysSullivan deleted the rhys/paid-plan-rate-limit-exemption branch August 20, 2026 15:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant