Sandbox — isolation and promotion model
What platform-sandbox isolates today
| Layer | Isolated? | Notes |
|---|---|---|
Billing D1 (site_billing, accounts, Stripe mode in D1) | Yes | Sandbox signups live only in lovely-home-platform-billing-sandbox. |
| Provision queues / hub-jobs | Yes | *-sandbox queues and Worker. The sandbox deploy script also puts the deployed commit's workers/hub-jobs/index.js on lovely-home-hub-jobs-sandbox, so the whole sandbox stack runs one commit. |
| Site cards in the dashboard | Filtered on sandbox deploy | deploy-sandbox-lovely-home.sh sets LOVELY_STACK=sandbox / PLATFORM_MANIFEST_SANDBOX=1 so build-platform-manifest.mjs keeps allowlisted hubs (demo, sandbox, test, practice + PLATFORM_MANIFEST_SANDBOX_SITES). Prod manifest unchanged. |
| Health / Access probes | Shared URLs | Manifest points at real hostnames (*.lovely-hub.com, demo, etc.), so sandbox reads prod/test hub endpoints for monitoring. |
| Git / registry PRs | Shared repo | Successful sandbox signup → provision still dispatches the same GitHub workflows. A real site_id can still create real Cloudflare resources. |
So: billing and signup state are sandbox-only; hub cards are filtered after a sandbox deploy (not prod’s full manifest).
Safe sandbox habits
- Use disposable site ids for signup/provision tests (never prod household slugs).
- Redeploy sandbox after merging manifest/provision fixes so Pages picks up queue bindings + filtered manifest.
- Provision still hits real GitHub workflows — test slugs only.
See sandbox-provision-chain.md and scripts/verify-sandbox-provision-chain.sh.
Promotion model (code): feature → sandbox → production
Goal: exercise real marketing + platform + signup on sandbox, then ship the same commit to production.
Branches (suggested)
| Branch | Role |
|---|---|
main | Production truth — merges here deploy prod marketing/platform (manual scripts / existing workflows). |
sandbox (long-lived) | Optional push target for Deploy sandbox on push or local deploy-sandbox-lovely-home.sh. Marketing custom domain uses Production branch main; optional preview alias sandbox via SANDBOX_MARKETING_PAGES_PREVIEW_BRANCH. |
feature/* | Short-lived work; open PR to sandbox or main. |
You do not need a permanent sandbox branch if you prefer deploy sandbox from feature branches via deploy-sandbox-lovely-home.sh (Wrangler) before merge.
Typical flow
text
feature/xyz ──PR──► sandbox (optional) ──deploy sandbox──► QA on marketing-sandbox + platform-sandbox
│
└──PR──► main ──deploy prod──► lovely-home.co.uk + platform.lovely-home.co.uk- Develop on
feature/…. - Verify on sandbox (no prod impact):
bash scripts/deploy-sandbox-lovely-home.shfrom that branch (unsetCLOUDFLARE_API_TOKENfor OAuth), or- merge to
sandboxand auto-deploy if configured.
- Sign-off — signup, billing, My Homes, provision with test site ids only.
- Promote — squash-merge PR to
main. - Production —
deploy-lovely-home-website.sh+deploy-platform-admin.sh(Terraform only when infra vars changed).
What “promotion” is not (today)
- No automatic promotion of D1 data — sandbox billing rows never copy to prod.
- No separate sandbox git fork — one repo; isolation is hostnames + D1 + queues, not a second manifest unless filtered at build.
- Terraform — sandbox uses
platform-sandbox.tfstate; prod usesplatform.tfstate. Promote code via git; promote infra by applying the right var-file + state key onmainwhen module vars change.
CI alignment (optional future)
| Check | Branch |
|---|---|
npm run lint / npm run test | Every PR |
| Deploy sandbox Pages | Push to sandbox, manual Deploy sandbox Lovely Home, or local deploy-sandbox-lovely-home.sh |
| Deploy prod Pages | main only, manual or release workflow |
| Platform admin Terraform | main + apply-platform-admin; sandbox Terraform local with sandbox-hub.tfvars |