Skip to content

Cloud: a credit is a minute of a small machine, from a cutover day (backport) - #1386

Open
wingleeio wants to merge 2 commits into
mainfrom
zeron/credit-rate-main
Open

wingleeio wants to merge 2 commits into
mainfrom
zeron/credit-rate-main

Conversation

@wingleeio

@wingleeio wingleeio commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Backports only the credit rate from 84f24f3 (on zeron/zgx) to main, without 6c4d8a0 or the other zeron/zgx edge commits it sits on.

What changes

  • The rate goes by the UTC day the usage fell on. Days before CLOUD_CREDIT_RATE_FROM stay at 60 billable seconds a credit. From that day on, a credit costs CLOUD_CREDIT_SECONDS.
  • The balance, plan periods, usage per day and a running machine's live estimate all use the per-day rate. The live estimate is split at midnight UTC.
  • Production wrangler.jsonc: CLOUD_CREDIT_SECONDS: "30", CLOUD_CREDIT_RATE_FROM: "SET-AT-DEPLOY". Anything that isn't a real YYYY-MM-DD keeps every day at 60, so merging changes nothing until a deployer sets the day.
  • Staging's block is untouched, so staging stays at 60.

Conflict resolution

  • cloud-account.ts: kept main's size lookup. Main has no live resize (s.machine). Only the estimate now goes through unmeteredCredits.
  • cloud.workerd.test.ts: kept main's policy import (no MACHINES) and added the metering imports.

Left out

  • The "about N small-machine hours" copy in crates/ui, iOS and Android. Main's apps have no small machine to name, so the "about N hours" line stays as it is. Once a real day is set, that line (credits / 60) overstates hours on production's default machine by 2×.
  • The apps/zgx copy changes. That app ships from zeron/zgx.

Deploying

Set CLOUD_CREDIT_RATE_FROM to a whole UTC day after the deploy day. Don't move or remove it once that day has come: doing so re-prices the days in between.

Tests (edge only)

  • The new rate tests fail on origin/main: metering.test.ts doesn't load because the new exports are missing, 1 test fails in credit-pricing, and 5 workerd tests fail.
  • On this branch, unit tests pass 250/250 and workerd tests pass 331/331. tsc --noEmit is clean.

🤖 Generated with Claude Code


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

wingleeio and others added 2 commits November 12, 2026 12:31
Backport of the credit rate from 84f24f3, without the machine-size work
it sits on.

A credit is meant to be a minute of a small machine, which the provider
bills at 0.5×: 30 billable seconds. The code charged 60.

Balances are worked out from raw usage seconds at the current rate, so
just changing it would re-price all past usage too. The rate now goes by
the UTC day the usage fell on: days before CLOUD_CREDIT_RATE_FROM stay at
60 seconds a credit, and from that day on it's CLOUD_CREDIT_SECONDS. That
covers the balance, plan periods, usage per day and a running machine's
live estimate, which is split at midnight UTC. Provider seconds and
dollars don't change.

Without a real day in CLOUD_CREDIT_RATE_FROM every day stays at 60, even
with CLOUD_CREDIT_SECONDS set. Production's wrangler block carries the
new rate and a placeholder day, so merging changes nothing until a
deployer picks one. Staging's block is unchanged and stays at 60.

The apps' "about N hours" copy is left as it is: main's apps have no
small machine to name.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Production was deployed by hand on 2026-11-12 at about 20:00 UTC
(Cloudflare version 52798b85) with this day. Never move or remove it once
it has come: that would re-price the days in between.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: zeronsh[bot] <346184242+zeronsh[bot]@users.noreply.github.com>
@wingleeio

Copy link
Copy Markdown
Contributor Author

Deployed by hand to production on 2026-11-12 ~20:00 UTC: Cloudflare version 52798b85, built from this branch plus CHAT_RELAY_LAYER="1" (#1381) and CLOUD_CREDIT_RATE_FROM=2026-11-13, which is now committed here. After the deploy: install/releases links 200, all 11 secrets and every binding kept, 2,399 ok / 0 errors in 45 s of live traffic. Rollback: wrangler rollback e70b2a43-5230-40e4-9554-8ed13baa3df1 --name comet-native-edge (the version before, with Cloud for everyone and the relay on). Needs a review to merge; until it merges, a deploy from main would drop the rate back to 60.

This branch has not been deployed

No deployments
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