HOLD: api: forward the Cloud surface to cmux-platform-staging (staging only)
HOLD: do not land until every precondition below is met on cmux-platform-staging. This PR turns cmux-api-staging's Cloud surface over to cmux-platform-staging; with any precondition unmet, Cloud requests on staging are either served locally (no binding) or forwarded to a platform Worker that answers 404 for them.
What this changes
backend/apps/api/wrangler.jsonc, the staging env only:
"PLATFORM_SURFACES": "cloud"invars: the forwarder from #29400 (src/platform-forward.ts) sends NEXT Cloud's ops (cloud:CloudDOowner on/v1/opsand/v1/read) and its machine routes (/v1/cloud/bind,/v1/cloud/keyset, acpmux, client-session, guest) to the platform."services": [{ "binding": "PLATFORM", "service": "cmux-platform-staging" }]: the binding the forwarder fetches through.
Development and production are untouched. No production flip.
Context: the platform side merged in manaflow-ai/cmux-platform#235, #237 (38f241af) and #236 (6a54e55e). Its CLOUD_DO binds cmux-api's own CloudDO through script_name, so a forwarded request meets the same Durable Object and data (docs/port-cloud-worker.md 3.2).
Preconditions, checked read-only on 2026-10-31
What is already true:
- cmux-api-staging's live deploy (e736ec5f, 14:50Z) already contains the forwarder (#29400); with this PR unmerged it is inert.
- cmux-platform-staging is live at 6a54e55e (#236's merge). Its health answers ok;
POST /v1/cloud/keysetanswersroute.not_found(Cloud routes off, as expected). - cmux-api-staging has the
JWT_PRIVATE_JWKsecret.
Still unmet on cmux-platform-staging:
-
Config PR in cmux-platform (lane work, not a secret). The
stagingblock of cmux-platform'swrangler.jsonchas onlyCOMMIT_SHA. It needs:- vars
ENVIRONMENT: "staging"(the install-token issuerhttps://cmux-api/staging; machine routes 404 without it),STACK_PROJECT_ID(cmux-api-staging's),CLOUD_ROUTES_ENABLED: "true"; - Durable Object bindings to cmux-api-staging's own classes with
script_name: "cmux-api-staging":CLOUD_DO(CloudDO),USER_DO(UserDO),TEAM_DO(TeamDO),DOMAIN_DO(DomainDO); - the
CLOUD_KEYSET_LIMITrate limit on cmux-api-staging's namespace (1162), so both Workers share one count.
scripts/check-inert.tsrefuses all of this today:CLOUD_ROUTES_ENABLEDis inNEVER_VARSfor every environment, andCLOUD_DO/USER_DO/CLOUD_KEYSET_LIMITare development-only. The same PR must move them to allowed-in-staging. Note development does not setCLOUD_ROUTES_ENABLEDyet either, so the routes have not been exercised behind the forwarder in any deployed environment. - vars
-
[outward]SecretJWT_PRIVATE_JWKon cmux-platform-staging, the same value as cmux-api-staging's (which has it). cmux-platform-staging's only secret today isINTERNAL_TOKEN. Setting it copies a signing key between Workers, so it is Leo's step. -
[outward]SecretCLOUD_LINK_SIGNING_KEYSon cmux-platform-staging, matching cmux-api-staging. cmux-api-staging does not have this secret either today (its own CloudDO andcloud-link.tsread it), so the key set has to be created and put on cmux-api-staging first, then the same value on cmux-platform-staging. Leo's step.
Order to land: (1) merges and deploys, Leo places (2) and (3), a check shows POST /v1/cloud/keyset on cmux-platform-staging no longer answers route.not_found, then the HOLD line comes off and this PR lands. Rollback is reverting this PR (or removing PLATFORM_SURFACES): the forwarder returns at once with the var unset.
Risk
Staging only. With the binding present and PLATFORM_SURFACES set, a platform that cannot be reached answers a retryable owner.unreachable 503 and the request is not replayed locally. That is why this waits on the preconditions instead of landing ahead of them.
cmux-platform: this is cmux-api config only (the forwarder wiring from #29400); the Cloud code it forwards to already lives in manaflow-ai/cmux-platform.
š¤ Generated with Claude Code
Agent session: agent session
![View with [code]smith](https://pr-comments-assets.blacksmith.sh/codesmith/view-with-codesmith-dark-v3-3x.png)
![Autofix with [code]smith](https://pr-comments-assets.blacksmith.sh/codesmith/autofix-with-codesmith-dark-3x.png)
Need help on this PR? Tag @codesmith-bot with what you need.
Summary by cubic
HOLD: do not merge until the staging preconditions below are met.
Turns cmux-api-staging's Cloud surface over to cmux-platform-staging. Adds PLATFORM_SURFACES: "cloud" and the PLATFORM service binding to the staging env only; development and production are untouched.
Preconditions
- cmux-platform-staging must be configured with
ENVIRONMENT,STACK_PROJECT_ID,CLOUD_ROUTES_ENABLED, DO bindings to cmux-api-staging's classes, and the sharedCLOUD_KEYSET_LIMITrate limit. JWT_PRIVATE_JWKandCLOUD_LINK_SIGNING_KEYSsecrets must be placed on cmux-platform-staging matching cmux-api-staging's values.
With any precondition unmet, forwarded requests either answer 404 from the platform Worker or a retryable 503 if the platform is unreachable. Rollback is reverting this PR or removing PLATFORM_SURFACES.