Skip to content
Concepts

Environments

Development, staging and production in AppCore: separate data, separate provider connections, sandbox vs production store evidence, promotion and lifecycle states.

On this page

Each app has up to three environments: development, staging and production. An environment is not a flag inside one database. It is a separate resource set with its own runtime Worker, its own D1 database, its own provider connections and its own users.

Diagram (Mermaid source)
flowchart LR
  subgraph dev["development"]
    dW["runtime"] --- dD[("D1")]
    dC["sandbox connections<br/>+ test-only trust material"]
  end
  subgraph stg["staging"]
    sW["runtime"] --- sD[("D1")]
    sC["sandbox connections"]
  end
  subgraph prd["production"]
    pW["runtime"] --- pD[("D1")]
    pC["production connections<br/>(production evidence + gates)"]
  end
  dev -- "promote: same pinned artifact<br/>(code only, no data, no secrets)" --> stg
  stg -- "promote" --> prd

What differs between environments

Concerndevelopmentstagingproduction
Users, sessions, purchases, entitlements, analyticsOwn databaseOwn databaseOwn database
Apple purchases acceptedSandbox onlySandbox onlyProduction only
Google Play purchases acceptedTest purchases onlyTest purchases onlyReal purchases only
Test-only verification material (a test JWKS for ID tokens, a test Apple root certificate)HonoredIgnoredIgnored
Connection activationNeeds real read-only and sandbox evidenceSameNeeds production evidence and every blocking manual gate
Stable identity data keyFalls back to the auth secret, with a readiness warningSameRequired. Without it identity is disabled.
Publishing remote config, catalog, migrations, DLQ replayNon-production permissionNon-production permissionSeparate production permission
Campaign schedulingUses default policyUses default policyRequires a pushed policy profile (409 POLICY_REQUIRED otherwise)

A purchase whose store environment does not match the runtime is rejected with PROVIDER_ENVIRONMENT_MISMATCH and grants nothing. Store webhooks for the wrong app or store environment are rejected with 422 and not ingested.

Creating environments

  • When a tenant is created, you choose which environments its first app gets.
  • When you add another app, it gets the same set of environments as the tenant's first app. If the first app has none, the new app gets development only.
  • Each environment is provisioned as one resumable job: create D1, apply migrations, write and verify the app_scope row, deploy the runtime, wire the route, check health. A retry resumes the same job and the same resource set. It never creates a duplicate.
  • An environment reports ready only when every dependency is live. Missing providers show as partial or degraded, never green. GET /health/ready on the runtime lists each module's evidence, for example email_otp: disabled (no email sender).

Promotion

promote deploys the exact runtime artifact (pinned by SHA-256) of one environment to the next one: development → staging → production. It moves code only. Users, purchases, connections and secrets are never copied. Provider connections are configured per environment. See the provider guides.

Warning

Not yet enabled: copying redacted configuration (catalog drafts, templates, non-secret connection settings) from one environment to another. Configure each environment directly until this ships.

Lifecycle states

Operators can change an environment's operating mode. The runtime reads it as its app status, and every module checks that status before doing scheduled or optional work.

ModeOptional work (campaigns, analytics intake, engagement messages)Essential work (sign-in, verified purchase callbacks, transactional and security messages, retention and erasure)
normal / activeRunsRuns
dormantStopped. Client analytics intake answers 503 APP_INACTIVE with Retry-After: 3600.Runs
suspendedStoppedStore callbacks are still verified and recorded. Engagement stops. Resuming is audited.
archivedStopped. Only export and restore actions are accepted.Nothing is sent. OTP answers 503.

Restore never overwrites a live database. It must target a separate, non-production environment of the same app. It requires a recovery plan, a backup or bookmark reference, evidence that writes have stopped, and an approval. Afterwards it revokes all sessions and requires reconciliation.

Warning

Not yet enabled: environment deletion with retention checks (there is no destroy action), and the automated export pipeline (D1 export to object storage). Today an export request becomes a manual operator step.

What this means for your app

  • Ship separate build flavors (for example staging and production), each with its own API host and its own store/Firebase configuration.
  • Test purchases with sandbox accounts and Play license testers against development or staging. A production runtime refuses them on purpose.
  • Users created in staging do not exist in production. Do not migrate test accounts.
  • Check GET /v1/config/public (the SDK does this) to see which sign-in methods, purchase providers and channels are actually live in the environment you are calling. Do not hard-code that list.
  • Before launch, make sure production has production-ready connections, the stable identity data key and a pushed engagement policy. Otherwise those features stay disabled.