diff --git a/.baseline/product/README.md b/.baseline/product/README.md index 53eff24..8dd6180 100644 --- a/.baseline/product/README.md +++ b/.baseline/product/README.md @@ -54,8 +54,9 @@ resolve `*.localhost` to the loopback address); under `preview` it is Every tenant is a subdomain of the environment's root domain — `.platforms-starter-kit.example.com` on prod, -`.stage.platforms-starter-kit.example.com` on stage — once that -domain's wildcard route points at the Worker (below). Until then the site +`.stage.platforms-starter-kit.example.com` on stage, a reserved +placeholder until you set your own — once that domain's wildcard route +points at the Worker (below). Until then the site answers on its workers.dev address, where a subdomain cannot resolve, so there a tenant is a path on the same host: `/s/`. The landing form says which, creating a tenant redirects to it, and `/admin` links to it. The @@ -103,8 +104,12 @@ provider-shaped is stored in the repository or in GitHub. ### Tenant subdomains (a custom domain) -A fresh deployment has no domain of its own. To give every tenant its -subdomain, on the Cloudflare account the site deploys into: +A fresh deployment has no domain of its own: its root domain is the +reserved placeholder `platforms-starter-kit.example.com` (and +`stage.platforms-starter-kit.example.com` on stage), which can never be +anyone's zone, so tenants live at `/s/` until you replace it. The +steps below name the placeholder; read your own root domain for it. To give +every tenant its subdomain, on the Cloudflare account the site deploys into: 1. **The zone.** Add the root domain's zone (`platforms-starter-kit.example.com`, or the domain above it) to the account. @@ -118,11 +123,12 @@ subdomain, on the Cloudflare account the site deploys into: `stage.platforms-starter-kit.example.com` and `platforms-starter-kit-web-stage` — a second-level wildcard needs an Advanced Certificate, because Universal SSL covers one level only. -4. **`BASE_DOMAIN`**, only if tenants should hang off another domain: it is - each environment's `env.BASE_DOMAIN` in `intent.yaml`, inlined at build - time. A change there maps to no component, so land it together with a - change under `apps/web` (its last line, `# orun: redeploy …`, is a deploy - trigger) and the next convergence rebuilds with it. +4. **`BASE_DOMAIN`.** Replace the placeholder with your root domain in each + environment's `env.BASE_DOMAIN` in `intent.yaml` (`stage.` on + stage); it is inlined at build time. A change there maps to no + component, so land it together with a change under `apps/web` (its last + line, `# orun: redeploy …`, is a deploy trigger) and the next + convergence rebuilds with it. Nothing else changes: requests arriving on the root domain get subdomain links, requests on workers.dev keep `/s/`. For customer-owned diff --git a/.github/workflows/baseline.yml b/.github/workflows/baseline.yml index c722c63..e7c4a8f 100644 --- a/.github/workflows/baseline.yml +++ b/.github/workflows/baseline.yml @@ -94,7 +94,6 @@ jobs: --out "$(mktemp -d)" \ --set reponame=acme-tenants \ --set "productname=Acme Tenants" \ - --set productdomain=tenants.acme.dev \ --set githuborg=acme-inc - name: the leak gate — what a product carries run: bash testing/leak.test.sh diff --git a/BOOTSTRAP.md b/BOOTSTRAP.md index fb3ea1d..53b0f8b 100644 --- a/BOOTSTRAP.md +++ b/BOOTSTRAP.md @@ -56,7 +56,7 @@ cd platforms-starter-kit orun new --blueprint repo-blueprint.yaml \ --out ~/sites/acme-tenants --run-hooks --resume \ --set reponame=acme-tenants --set productname="Acme Tenants" \ - --set productdomain=tenants.acme.dev --set githuborg=acme-inc \ + --set githuborg=acme-inc \ --set orunWorkspace=ws_XXXXXXXX \ --set subdomain= ``` @@ -93,9 +93,15 @@ orun new --blueprint repo-blueprint.yaml --out ~/sites/acme-tenants --run-hooks `02-docs` reads the identity back from `.rebrand/values.json` in the placed tree, but the blueprint's **required** inputs — `reponame`, `productname`, -`productdomain`, `githuborg` — are validated before anything runs, so pass -them every time (a `--values` file is easier). The full guide, one page per -phase: [docs/phases/README.md](docs/phases/README.md). +`githuborg` — are validated before anything runs, so pass them every time (a +`--values` file is easier). The domain is not one of them: the site goes live +on workers.dev, tenants at `/s/`, and `productdomain` defaults to +empty, which brands the reserved placeholder `.example.com` into +`BASE_DOMAIN` (`stage..example.com` on stage) for an owner to +replace when they attach a root domain (the site's README, "Tenant +subdomains"). Pass `--set productdomain=` only for a site that already has +its domain. +The full guide, one page per phase: [docs/phases/README.md](docs/phases/README.md). | flag | what it does | |---|---| @@ -165,18 +171,20 @@ orun new --blueprint repo-blueprint.yaml \ `--components`, the `WIRING__` secretEnv and an enforced `dependsOn` on it. `ai/context/operations.md` in the product says the same. - **Tenant subdomains (the owner's follow-up)**: the product's root domain - is `productdomain` — prod's `BASE_DOMAIN` in its `intent.yaml`, and - `stage.` for stage — inlined at build time. Until it is - attached the site answers on workers.dev, where + is prod's `BASE_DOMAIN` in its `intent.yaml`, and `stage.` for + stage — inlined at build time. A console build asks for none, so it is + born as the reserved placeholder `.example.com` (a hand-run + build may pass `productdomain`). Until a real one is attached the site + answers on workers.dev, where `...workers.dev` cannot resolve, so tenants are served at `/s/` on that host (the app decides per request: `apps/web/lib/addresses.ts`). To turn on subdomains, on the Cloudflare account: add the zone, a proxied wildcard DNS record (`*.`) and the apex, and Worker routes `*./*` and `/*` to `-web-prod` (stage likewise on `stage.`, which needs an - Advanced Certificate for its second-level wildcard). Only if tenants - should hang off another domain, change `BASE_DOMAIN` and land it with a - change under `apps/web`. The product's README, "Tenant subdomains", walks + Advanced Certificate for its second-level wildcard), and replace the + placeholder in `BASE_DOMAIN` with that domain, landed with a change under + `apps/web`. The product's README, "Tenant subdomains", walks through it. There is no domain phase: routes and DNS need zone permissions the brokered `workers-deploy` token does not carry, and a zone the build does not have. @@ -239,7 +247,7 @@ at the tag and refuses the whole catalogue if it 404s. | Convergence failed AFTER the PR merged; re-running lands nothing | expected on its own — the files are on main. Re-run the phase (`--phase 01-product`, `--redo 01-product`, or the console's Retry): its `retouch` hook gives the landing a diff and the KV root and the app re-plan | | The product's `intent.yaml` says `workspace: ws_SET_ME` | `orunWorkspace` was empty and the build ran outside a workspace; set it and re-run `01-product` | | A bootstrap stopped before `02-docs`; prod no longer waits on stage | the gate is deferred, not dropped: run `02-docs`, or `node tooling/bootstrap/promotion.mjs --restore --file /intent.yaml` | -| `✕ input "productdomain" is required` | all four required inputs must be set on every invocation, single-phase ones included | +| `✕ input "productname" is required` | all three required inputs (`reponame`, `productname`, `githuborg`) must be set on every invocation, single-phase ones included | | `unknown flag: --phase` or a parse error in the blueprint | the CLI is below the v2.58.11 floor | | web lane `verify-app-structure` fails on `wrangler.jsonc` | the config is not committed. It is the fixture render of `wrangler.template.jsonc`: `pnpm run wire:fixture` and commit it | | web lane `build-app`: `Symlink apps/web/node_modules/next is invalid, it points out of the filesystem root` | the product's intent pins stack-tectonic ≥ 0.20.0, whose lane-scoped install links each job's node_modules out of its tree, which Next 16's Turbopack refuses. Pin 0.19.0 (`intent.yaml` says why) | diff --git a/README.md b/README.md index c08f6e2..64f7fec 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ for the design, the milestones and the as-built status. git clone --depth 1 --branch https://github.com/sourceplane/platforms-starter-kit cd platforms-starter-kit orun new --blueprint repo-blueprint.yaml --out ~/sites/acme-tenants --run-hooks --resume \ - --set reponame=acme-tenants --set productname="Acme Tenants" --set productdomain=tenants.acme.dev \ + --set reponame=acme-tenants --set productname="Acme Tenants" \ --set githuborg=acme-inc --set subdomain= ``` @@ -46,10 +46,11 @@ namespace titles and root domain. None of this repository's machinery ships. It goes live on workers.dev: the landing page, creating a tenant, the tenant's page at `/s/` and `/admin` all work there. Tenant -SUBDOMAINS need the product's root domain (`productdomain`) on a Cloudflare -zone with a wildcard route to the Worker — the owner's step after the -bootstrap, described in the product's README; nothing in the repository -changes for it. +SUBDOMAINS need a root domain on a Cloudflare zone with a wildcard route to +the Worker — the owner's step after the bootstrap, described in the +product's README. The console does not ask for it: a product is born with +the reserved placeholder `.example.com` as its root domain +(`BASE_DOMAIN`), and that step replaces it with the owner's. | What makes it a baseline | Where | |---|---| diff --git a/ai/context/current.md b/ai/context/current.md index a6eb167..32bc813 100644 --- a/ai/context/current.md +++ b/ai/context/current.md @@ -21,8 +21,9 @@ a fresh product is whole on workers.dev before any custom domain. | | | |---|---| -| Latest tag | `baseline-v2` (PS5 — the cirrus standard, [#6](https://github.com/sourceplane/platforms-starter-kit/pull/6) and [#7](https://github.com/sourceplane/platforms-starter-kit/pull/7): no kiox, generated component docs, this context pack, and the workers.dev subdomain read from the Cloudflare connection instead of asked) | -| Before it | `baseline-v1` (PS4) | +| Latest tag | `baseline-v3` (PS6 — the domain is set later, [#8](https://github.com/sourceplane/platforms-starter-kit/pull/8): the console asks for no root domain, and a site is born with the placeholder `.example.com` for an owner to replace) | +| Before it | `baseline-v2` (PS5 — the cirrus standard, [#6](https://github.com/sourceplane/platforms-starter-kit/pull/6) and [#7](https://github.com/sourceplane/platforms-starter-kit/pull/7): no kiox, generated component docs, this context pack, and the workers.dev subdomain read from the Cloudflare connection instead of asked) | +| Before that | `baseline-v1` (PS4) | | Proven live | No. Everything short of the platform is proven offline in Baseline CI; a live bootstrap from a tag, and tenant subdomains on a real zone, are still to come (risk PS-K) | ## Where to read @@ -37,5 +38,5 @@ a fresh product is whole on workers.dev before any custom domain. ## Next -1. Bootstrap one product from `baseline-v2` against a workspace, and record +1. Bootstrap one product from `baseline-v3` against a workspace, and record its timings (closes PS-K); then the registry row can leave `unlisted`. diff --git a/ai/context/decisions.md b/ai/context/decisions.md index 423f3af..01559cd 100644 --- a/ai/context/decisions.md +++ b/ai/context/decisions.md @@ -19,3 +19,4 @@ reads in order. | 11 | orun is pinned only where it runs (the `orun-action` `version:` in each workflow); no kiox | `kiox.yaml` pinned a version nothing ran | IMPLEMENTATION-STATUS (PS5) | | 12 | Component docs are generated from the manifests and checked in CI | A hand-written copy of the dependency graph, bindings and published outputs drifts silently | `tooling/catalog/gen-component-docs.py` | | 13 | The workers.dev `subdomain` is read from the Cloudflare connection (`from: connection.cloudflare.workersSubdomain`), never asked | It belongs to the account like its id and has one right answer; a typed one could only be wrong, and showed up after deploy in the smoke and the probes | `blueprint.yaml`, IMPLEMENTATION-STATUS (PS-7) | +| 14 | The console asks for no domain; an empty `productdomain` brands the placeholder `.example.com` | The site goes live on workers.dev and nothing in the build needs a domain; attaching one is an owner's step, and the placeholder keeps every place the domain goes in the repository, ready to replace | `repo-blueprint.yaml`, `tooling/rebrand/rebrand.mjs`, IMPLEMENTATION-STATUS (PS-8) | diff --git a/ai/context/operations.md b/ai/context/operations.md index 03141f4..7f84733 100644 --- a/ai/context/operations.md +++ b/ai/context/operations.md @@ -38,14 +38,16 @@ namespace exists for it (its build renders the committed fixture). The root domain is each environment's `env.BASE_DOMAIN` in `intent.yaml` (`platforms-starter-kit.example.com` on prod, -`stage.platforms-starter-kit.example.com` on stage), inlined into the build -as `NEXT_PUBLIC_ROOT_DOMAIN`. A request arriving ON that domain sees tenants -as subdomains, `.`; a request on any other host — the -workers.dev address, before the domain's wildcard route points at the Worker -— sees them as paths on that host, `/s/` -(`apps/web/lib/addresses.ts`). Both work against the same build; attaching -the domain is the owner's step (README, "Tenant subdomains") and changes -nothing in the repository unless `BASE_DOMAIN` itself changes. +`stage.platforms-starter-kit.example.com` on stage — the reserved +placeholder the site was born with, until an owner replaces it with a +domain of theirs), inlined into the build as `NEXT_PUBLIC_ROOT_DOMAIN`. A +request arriving ON that domain sees tenants as subdomains, +`.`; a request on any other host — the workers.dev address, +before the domain's wildcard route points at the Worker — sees them as +paths on that host, `/s/` (`apps/web/lib/addresses.ts`). Both work +against the same build; attaching the domain is the owner's step (README, +"Tenant subdomains"), and its one change in the repository is replacing the +placeholder in `BASE_DOMAIN`. ## Identity and tenancy @@ -129,7 +131,7 @@ orun integrations list --org --json && orun cloud check --org | change the app | edit `apps/web/app` (its name: `apps/web/app/site.ts`), merge | | deploy a change | merge to `main`; watch the run; failed lanes → `gh run rerun --failed` | | redeploy without a change | edit the last line of `apps/web/component.yaml` (`# orun: redeploy `) and merge — it is a deploy trigger, nothing reads it | -| tenant subdomains | the zone, a wildcard DNS record and a Worker route on the root domain (README, "Tenant subdomains"); nothing in the repository changes | +| tenant subdomains | the zone, a wildcard DNS record and a Worker route on the root domain (README, "Tenant subdomains"), and the placeholder `platforms-starter-kit.example.com` replaced with it in `env.BASE_DOMAIN` (below) | | change the root domain | `env.BASE_DOMAIN` per environment in `intent.yaml`, landed with a change under `apps/web` (it is inlined at build time) | | gate `/admin` | Cloudflare Access on `/admin*`; then drop the `/admin` half of the smoke in `apps/web/component.yaml` | | list or delete tenants by hand | `wrangler kv key list --namespace-id --prefix subdomain: --remote`, `wrangler kv key delete subdomain: --namespace-id --remote` (the id is in the environment's `WIRING_CLOUDFLARE_KV`) | diff --git a/blueprint.yaml b/blueprint.yaml index bfcdfe3..0900449 100644 --- a/blueprint.yaml +++ b/blueprint.yaml @@ -67,6 +67,14 @@ spec: # already holds says so with `from`. repo-blueprint.yaml declares the same # names; `repoPrivate`, `orunWorkspace` and `epicSlug` are build inputs with # defaults (or filled from the build's workspace) and are not asked. + # + # NOR IS THE DOMAIN. The site goes live on workers.dev, tenants at + # /s/, and a root domain for tenant subdomains is an owner's step + # after the bootstrap: `productdomain` defaults to empty, the rebrand + # writes the reserved placeholder `.example.com` where the root + # domain goes (BASE_DOMAIN, `stage.<…>` on stage), and the site's README + # ("Tenant subdomains") says how to set it. Nothing that needs a domain is + # removed — it waits for one. inputs: - key: reponame label: Repo name @@ -78,15 +86,6 @@ spec: pattern: "^[A-Za-z0-9][A-Za-z0-9 .,'&-]{1,48}$" help: The name visitors see — every page's title, and above the landing page's heading. example: Acme Tenants - - key: productdomain - label: Tenant root domain - pattern: "^[a-z0-9]([a-z0-9-]*[a-z0-9])?(\\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)+$" - help: >- - The domain tenants become subdomains of — . on prod, - .stage. on stage. It does not need to exist yet: the - site goes live on workers.dev first, tenants at /s/, until - you point the domain's wildcard route at it. - example: tenants.acme.dev - key: githuborg label: GitHub organisation pattern: "^[A-Za-z0-9][A-Za-z0-9-]*$" diff --git a/docs/phases/README.md b/docs/phases/README.md index 3748259..a112ec2 100644 --- a/docs/phases/README.md +++ b/docs/phases/README.md @@ -44,25 +44,34 @@ and the product's landing waits for it. There is no custom-domain phase, and so no tenant subdomains out of the bootstrap. A tenant is `.` (the environment's -`BASE_DOMAIN`: `productdomain` on prod, `stage.` on stage), -and that needs a zone, a wildcard DNS record and a Worker route — zone -permissions the platform's brokered `workers-deploy` token does not carry. +`BASE_DOMAIN`: `` on prod, `stage.` on stage, born as the +placeholder `.example.com` unless a hand-run build passes +`productdomain`), and that needs a zone, a wildcard DNS record and a Worker +route — zone permissions the platform's brokered `workers-deploy` token does +not carry. So the bootstrap ends on workers.dev, where the app serves every tenant by path, `/s/`, deciding per request from the host it was asked on; the landing page, creating a tenant and visiting it all work there, and the landing's probe and the deploy's smoke check them. Pointing the root domain's wildcard route at the Worker is the owner's step after the -bootstrap — the site's README, "Tenant subdomains", says how — and nothing -in the repository changes for it unless `BASE_DOMAIN` itself does. +bootstrap — the site's README, "Tenant subdomains", says how — and the one +change in the repository is replacing the placeholder in `BASE_DOMAIN`. ## Inputs `01-product` takes the site's identity once and writes it into the repo (`.rebrand/values.json`); `02-docs` reads it back from the placed tree. But the blueprint's **required** inputs — `reponame`, `productname`, -`productdomain`, `githuborg` — are validated before any phase runs, so they -must be supplied on every invocation, single-phase ones included. A -`--values` file is easier than repeating `--set`. +`githuborg` — are validated before any phase runs, so they must be supplied +on every invocation, single-phase ones included. A `--values` file is easier +than repeating `--set`. + +- `productdomain` — NOT ASKED, default empty. The site goes live on + workers.dev, tenants at `/s/`; empty brands the reserved + placeholder `.example.com` into `BASE_DOMAIN` + (`stage..example.com` on stage), for an owner to replace when + they attach a root domain (the site's README, "Tenant subdomains"). Pass + it only for a site that already has its domain. - `subdomain` — the workers.dev subdomain of the Cloudflare account you deploy into. It is in every URL the phases probe. A console or diff --git a/repo-blueprint.yaml b/repo-blueprint.yaml index 135e26a..461b3c9 100644 --- a/repo-blueprint.yaml +++ b/repo-blueprint.yaml @@ -35,13 +35,19 @@ inputs: description: The site's display name (e.g. "Acme Tenants") — every page's title, and above the landing page's heading. productdomain: type: string - required: true + default: "" description: >- - The root domain tenants become subdomains of (e.g. tenants.acme.dev) — - prod's BASE_DOMAIN, and stage's as stage., inlined into the - build. It does not need to exist: the site answers on workers.dev from - its first deploy, tenants at /s/, until the owner points the - domain's wildcard route at the Worker. + The root domain tenants become subdomains of, once the site has one + (e.g. tenants.acme.dev). NOT ASKED: the site answers on workers.dev from + its first deploy, tenants at /s/, and attaching a root domain + is an owner's step after it. Empty, the rebrand writes the reserved + placeholder `.example.com` where the root domain goes — + prod's and dev's BASE_DOMAIN in intent.yaml, stage's as + stage..example.com, inlined into the build as + NEXT_PUBLIC_ROOT_DOMAIN (the landing page, the subdomain form, /admin and + the not-found page name it) — so setting it later is replacing that one + string; the site's README, "Tenant subdomains", says how. Pass it with + --set only to brand a hand-run build with a domain it already has. githuborg: type: string pattern: "^[A-Za-z0-9][A-Za-z0-9-]*$" diff --git a/specs/epics/README.md b/specs/epics/README.md index 782a2f2..4090f3a 100644 --- a/specs/epics/README.md +++ b/specs/epics/README.md @@ -7,6 +7,6 @@ folder is the adoption; the merge creates the epic in the workspace. | Epic | Cluster | Status | What it is | |------|---------|--------|------------| -| [`platforms-starter-kit/`](./platforms-starter-kit/) | **PS** | ✅ Shipped (`baseline-v2`); live bootstrap pending | Vercel's Platforms Starter Kit, equivalent in code and function, on Cloudflare Workers with tenants in Workers KV — and an Orun baseline that instantiates it in one landing, live on workers.dev before any custom domain (PS4) | +| [`platforms-starter-kit/`](./platforms-starter-kit/) | **PS** | ✅ Shipped (`baseline-v3`); live bootstrap pending | Vercel's Platforms Starter Kit, equivalent in code and function, on Cloudflare Workers with tenants in Workers KV — and an Orun baseline that instantiates it in one landing, live on workers.dev before any custom domain (PS4) | As-built ≠ intent: what shipped lives in each epic's `IMPLEMENTATION-STATUS.md`. diff --git a/specs/epics/platforms-starter-kit/IMPLEMENTATION-STATUS.md b/specs/epics/platforms-starter-kit/IMPLEMENTATION-STATUS.md index deadcdf..e2d5b8b 100644 --- a/specs/epics/platforms-starter-kit/IMPLEMENTATION-STATUS.md +++ b/specs/epics/platforms-starter-kit/IMPLEMENTATION-STATUS.md @@ -11,6 +11,7 @@ the code departed from `design.md` or from the upstream template. | PS3 — ready to instantiate | ✅ Shipped | [#4](https://github.com/sourceplane/platforms-starter-kit/pull/4) | | PS4 — a baseline, in one landing | ✅ Shipped (offline-proven; no live bootstrap yet, risk PS-K) | [#5](https://github.com/sourceplane/platforms-starter-kit/pull/5) (PS-5), tagged `baseline-v1` | | PS5 — the cirrus standard | ✅ Shipped | [#6](https://github.com/sourceplane/platforms-starter-kit/pull/6) (PS-6), [#7](https://github.com/sourceplane/platforms-starter-kit/pull/7) (PS-7), tagged `baseline-v2` | +| PS6 — the domain is set later | ✅ Shipped | [#8](https://github.com/sourceplane/platforms-starter-kit/pull/8) (PS-8), tagged `baseline-v3` | ## Departures from the upstream template @@ -191,6 +192,83 @@ Verified: prod; the 02-docs merge plans 0 jobs; `--resume` changes nothing. - `orun task check PS-7` complete. +## The domain is set later (PS6, PS-8) + +The console asked for the tenant root domain, with help text that said it +did not need to exist — and nothing in the build needed one: the site +answers on workers.dev from its first deploy, where tenants are paths +(`/s/`); the smoke and the phase probes read workers.dev; and +`02-docs`'s deployment record names the root domains without probing them. +Attaching a root domain (zone, wildcard DNS, Worker route) is an owner's +step after the bootstrap (README, "Tenant subdomains"), so the form no +longer asks for it. + +The root domain still goes where it went: `BASE_DOMAIN` in `intent.yaml` +(dev and prod; `stage.` on stage), inlined by the build as +`NEXT_PUBLIC_ROOT_DOMAIN`, which `proxy.ts` and `lib/addresses.ts` route by +and the landing page, the subdomain form, `/admin` and the not-found page +name. A site built without a domain carries the reserved placeholder +`.example.com` in all of them, so tenants stay at `/s/` +until an owner replaces that one string. + +- `blueprint.yaml` declares no `productdomain` input; the console asks for + the site's name alone. +- `repo-blueprint.yaml`'s `productdomain` is optional, default empty. Nothing + else in the build reads it — no hook, probe or `when:` (the deployment + record's hook reads `BASE_DOMAIN` from the tree and does not probe it) — so + an empty value is harmless; `.rebrand/values.json` records `""`. A hand-run + build may still pass `--set productdomain=` for a site that already has + its domain. +- `rebrand.mjs` no longer requires it. Empty, it brands the reserved + placeholder `.example.com` (RFC 2606 — never someone else's + domain) where the root domain goes, `stage..example.com` on + stage. +- The product README's "Tenant subdomains" said to change `BASE_DOMAIN` + "only if tenants should hang off another domain"; a site is now born with + a placeholder no one can own, so replacing it is a step of its own, and + "Where tenants live" and `ai/context/operations.md` call it a placeholder. +- `testing/fixtures/acme.json` carries no domain, so the leak gate, the + offline bootstrap and the e2e tier exercise exactly what a console build + supplies. `testing/placement.test.sh` and `testing/e2e.test.sh` read the + fixture's `productdomain` to assert `BASE_DOMAIN` and to address tenants on + the stage root; on the domain-less fixture both raised + `KeyError: 'productdomain'`, so they now expect the placeholder when the + fixture gives none. `testing/rebrand.test.sh` pins the placeholder for an + absent domain (prod and stage) and an empty one; `baseline.yml`'s + blueprint read sets no domain. + +Nothing that needs a domain was removed — it waits for one. + +Verified: + +- `testing/{manifest,phases,coverage,rebrand,retouch,bootstrap-defer,wire}.test.sh` + green (rebrand: with the previous `rebrand.mjs` the three new checks fail; + restored, they pass); `gen-component-docs.py --check` green (3 components). +- At v2.58.11 (the blueprint job's first pin): `orun new --status` with no + `productdomain` reads the document (`01-product` pending, 91 files); + `testing/leak.test.sh` 91 files derived; 85 shipped sources name no + factory path. +- At v2.78.4 (as `baseline.yml` runs placement): `testing/placement.test.sh` + 91 tracked files, both landings, `BASE_DOMAIN` the placeholder + (`acme-platforms.example.com`, stage `stage.acme-platforms.example.com`) in + the intent and in each `web` job; `cloudflare-kv` applied at level 0 + before `web` deploys at level 1 on stage and prod; the 02-docs merge plans + 0 jobs; `--resume` changes nothing. The previous `placement.test.sh` on the + new fixture fails with `KeyError: 'productdomain'` (twice). +- At v2.78.4 (the site job's pin): `testing/e2e.test.sh` green on the + domain-less fixture — the 01-product landing passes the Checks sequence; + the stage lane's `build-app` inlines `stage.acme-platforms.example.com` + and `deploy-dry-run` binds `KV` to the stage document's id; `wrangler dev` + serves the built Worker and its own smoke passes; a tenant created by the + landing form is read back on `/s/acme-e2e` and `/admin`, refused as a + duplicate, served as `acme-e2e.stage.acme-platforms.example.com` by Host + header, kept off `/admin` on its host, and deleted again. +- The offline bootstrap of the fixture leaves `.rebrand/values.json` + `productdomain` empty and the placeholder in all three environments' + `BASE_DOMAIN`, the README's tenant and route examples, `operations.md` and + the rendered `deployment.md`; no line names `platforms-starter-kit.example.com`. +- `orun task check PS-8` complete. + ## Verified (PS5) - `testing/{manifest,phases,coverage,rebrand,retouch,bootstrap-defer,wire}.test.sh` diff --git a/specs/epics/platforms-starter-kit/README.md b/specs/epics/platforms-starter-kit/README.md index 829655c..0469bcd 100644 --- a/specs/epics/platforms-starter-kit/README.md +++ b/specs/epics/platforms-starter-kit/README.md @@ -8,15 +8,15 @@ The upstream code stays the code: the proxy, the pages, the server actions, `lib | Field | Value | |-------|-------| -| Status | ✅ PS0–PS4 shipped (#1–#5), PS4 tagged `baseline-v1`; PS5 (the cirrus standard, PS-6 #6 and PS-7 #7) tagged `baseline-v2`. The KV apply and a live deploy are not yet proven by a live bootstrap (risk PS-K) | -| Cluster | **PS** (PS0–PS5) | +| Status | ✅ PS0–PS6 shipped (#1–#8), PS4 tagged `baseline-v1`; PS5 (the cirrus standard, PS-6 #6 and PS-7 #7) tagged `baseline-v2`; PS6 (the domain is set later, PS-8 #8) tagged `baseline-v3`. The KV apply and a live deploy are not yet proven by a live bootstrap (risk PS-K) | +| Cluster | **PS** (PS0–PS6) | | Owner(s) | `apps/web` (the app) · `tests/web` (adapter and proxy tests) · `infra/terraform/cloudflare-kv` (the namespace) | | Builds on | `cirrus-baseline` conventions — the `cloudflare-kv` Terraform root and the `@@wiring(...)@@` per-environment render; intent, components, `checks.yml` gate, gated `ci.yml` | | Upstream | [vercel/platforms](https://github.com/vercel/platforms) | | Changes | Adds the Workers build, the monorepo wrapper, `lib/redis.ts` over KV, tests, the KV root and the deploy contract; swaps Vercel Speed Insights for the Cloudflare Web Analytics beacon; makes `/admin` explicitly dynamic | | Decisions locked | (1) OpenNext on Workers + Static Assets. (2) Workers KV, not a Durable Object per tenant: the template's store is a key-value map with a prefix scan, and that is what KV is. (3) The adapter keeps the Upstash surface; the app's data access is untouched. (4) `wrangler.jsonc` is rendered per environment from the wiring document — and, since PS4, committed as the fixture render, because the deploy lane checks it exists before the build (risk PS-I). (5) The root domain is one knob — the environment's `BASE_DOMAIN` in `intent.yaml`, inlined by `next build`. (6) PS4: one landing — the plan, not a landing boundary, orders the namespace before the Worker. (7) PS4: off the root domain a tenant is a path on the request's host (`/s/`), so a fresh deploy works on workers.dev; subdomains are the owner's custom-domain step. | | Gate | PS1 is the first user-visible rung. PS2 needs a workspace with a Cloudflare connection to apply; it is verified by `terraform validate` and `plan`. | -| Shipped as | `baseline-v1` ([#5](https://github.com/sourceplane/platforms-starter-kit/pull/5)), then `baseline-v2` (PS5: [#6](https://github.com/sourceplane/platforms-starter-kit/pull/6), [#7](https://github.com/sourceplane/platforms-starter-kit/pull/7)); proven offline (Baseline CI: the produced product built, served by `wrangler dev` with a local KV, and used), `terraform validate` on the root, deploy gated until a workspace is linked | +| Shipped as | `baseline-v3` ([#8](https://github.com/sourceplane/platforms-starter-kit/pull/8), PS6: no domain asked), `baseline-v2` (PS5: [#6](https://github.com/sourceplane/platforms-starter-kit/pull/6), [#7](https://github.com/sourceplane/platforms-starter-kit/pull/7)), `baseline-v1` ([#5](https://github.com/sourceplane/platforms-starter-kit/pull/5)); proven offline (Baseline CI: the produced product built, served by `wrangler dev` with a local KV, and used), `terraform validate` on the root, deploy gated until a workspace is linked | ## Read order @@ -35,3 +35,4 @@ The upstream code stays the code: the proxy, the pages, the server actions, `lib | PS3 — ready to instantiate | README, as-built status | a reader can run, test, preview and deploy it, and knows what the wildcard domain needs | | PS4 — a baseline, in one landing | card, build document, rename, bootstrap tooling, the workers.dev path fallback, tests | a new product goes from nothing to live in one landing, the KV namespace applied before the Worker, tenants created and served on workers.dev; Baseline CI green | | PS5 — the cirrus standard | no kiox, generated component docs, the context pack, status that agrees with the tags; the workers.dev subdomain read from the Cloudflare connection | Baseline CI green with the docs check; the card asks for no workers.dev subdomain | +| PS6 — the domain is set later | the console asks for no root domain; an empty `productdomain` brands the placeholder `.example.com` (stage one level below) for an owner to replace | Baseline CI green on a fixture with no domain, tenants served on the placeholder root in the e2e tier | diff --git a/specs/epics/platforms-starter-kit/epic.yaml b/specs/epics/platforms-starter-kit/epic.yaml index cf2f0c2..e4873fb 100644 --- a/specs/epics/platforms-starter-kit/epic.yaml +++ b/specs/epics/platforms-starter-kit/epic.yaml @@ -48,3 +48,9 @@ spec: - "every milestone's status row agrees with the tags" - "the console card reads subdomain from the Cloudflare connection (from: connection.cloudflare.workersSubdomain), as cirrus-baseline since baseline-v23" tasks: [PS-6, PS-7] + - name: "PS6 — the domain is set later" + exitCriteria: + - "the console card asks for no domain: a site goes live on workers.dev, and productdomain is an optional build input that defaults to empty" + - "a site built without a domain is branded with the reserved placeholder .example.com wherever the domain goes (BASE_DOMAIN, stage..example.com on stage), and its README says how an owner sets the real one" + - "Baseline CI places, leak-checks and plans a site built with no domain" + tasks: [PS-8] diff --git a/specs/epics/platforms-starter-kit/implementation-plan.md b/specs/epics/platforms-starter-kit/implementation-plan.md index 79dae8d..a12da22 100644 --- a/specs/epics/platforms-starter-kit/implementation-plan.md +++ b/specs/epics/platforms-starter-kit/implementation-plan.md @@ -101,6 +101,15 @@ product itself changing. - the docs check is green in Baseline CI - this file, the status file and `epic.yaml` agree +## PS6 — the domain is set later (PS-8) ✅ + +**Done when** the console card asks for no domain; `productdomain` is an +optional build input, empty by default; a site built without one is branded +with the reserved placeholder `.example.com` where the domain goes +(`BASE_DOMAIN` in `intent.yaml`, `stage..example.com` on stage) and its README says how an owner sets the real one; +Baseline CI places, leak-checks and plans a site built with no domain. +Shipped in `baseline-v3`. + ## After PS4 (outside this repository) 1. Cut `baseline-v1` with `tag.yml` from the merged `main` — done: `baseline-v1` diff --git a/tasks/PS-8.TaskContract.yaml b/tasks/PS-8.TaskContract.yaml new file mode 100644 index 0000000..0e09504 --- /dev/null +++ b/tasks/PS-8.TaskContract.yaml @@ -0,0 +1,32 @@ +apiVersion: orun.io/v1 +kind: TaskContract +metadata: + name: PS-8 + title: "The domain is set later" +spec: + goal: "The console no longer asks for the site's domain. A site goes live on workers.dev; productdomain is an optional build input (default empty), the rebrand writes the reserved placeholder .example.com where the domain goes (BASE_DOMAIN, stage..example.com on stage), and the site's README says how an owner replaces it once a domain is attached" + affects: + - blueprint.yaml + - repo-blueprint.yaml + - tooling/rebrand/rebrand.mjs + - testing/rebrand.test.sh + - testing/fixtures/acme.json + - .github/workflows/baseline.yml + - .baseline/product/README.md + - BOOTSTRAP.md + - README.md + - docs/phases/README.md + - ai/context/operations.md + - ai/context/current.md + - ai/context/decisions.md + - testing/placement.test.sh + - testing/e2e.test.sh + - specs/** + - tasks/** + doneWhen: + - blueprint.yaml declares no productdomain input, and repo-blueprint.yaml's productdomain is optional with an empty default + - "rebrand.mjs no longer requires productdomain and brands .example.com when it is empty (testing/rebrand.test.sh)" + - testing/fixtures/acme.json carries no domain, so the leak gate and the offline bootstrap exercise what a console build supplies + - the contract tests, the docs check, the leak gate and the offline bootstrap are green + gates: + - checks diff --git a/testing/e2e.test.sh b/testing/e2e.test.sh index e79a0e2..4398f9c 100755 --- a/testing/e2e.test.sh +++ b/testing/e2e.test.sh @@ -183,7 +183,8 @@ grep -q '"5ca1ab1e5ca1ab1e5ca1ab1e0000a001"' "$work/apps/web/wrangler.jsonc" \ grep -Eq 'env\.KV\b' "$scratch/deploy-dry-run.log" && grep -q '5ca1ab1e5ca1ab1e5ca1ab1e0000a001' "$scratch/deploy-dry-run.log" \ || { echo "FAIL: the dry run does not bind KV to the stage namespace" >&2; tail -20 "$scratch/deploy-dry-run.log" >&2; exit 1; } # The build inlined the stage root domain (the job's BASE_DOMAIN, from intent.yaml). -domain="$(python3 -c "import json,sys;print(json.load(open(sys.argv[1]))['productdomain'])" "$values")" +# The fixture carries no domain, so it is the placeholder .example.com. +domain="$(python3 -c "import json,sys;v=json.load(open(sys.argv[1]));print((v.get('productdomain') or '').strip() or v['reponame']+'.example.com')" "$values")" grep -rqF "stage.$domain" "$work/apps/web/.open-next/server-functions" \ || { echo "FAIL: the stage build did not inline its root domain stage.$domain" >&2; exit 1; } echo " the built config binds KV to the stage document's namespace id, and the build carries" @@ -211,7 +212,8 @@ echo " ▸ every route the site promises: create a tenant, and read it back th python3 - "$url" "$values" <<'PY' import html, json, re, sys, urllib.error, urllib.parse, urllib.request, uuid base, values = sys.argv[1], json.load(open(sys.argv[2])) -name, domain = values["productname"], values["productdomain"] +name = values["productname"] +domain = (values.get("productdomain") or "").strip() or f'{values["reponame"]}.example.com' # none given: the placeholder host = urllib.parse.urlsplit(base).netloc # 127.0.0.1: — off the root domain, like workers.dev port = urllib.parse.urlsplit(base).port root = f"stage.{domain}" # the stage build's BASE_DOMAIN diff --git a/testing/fixtures/acme.json b/testing/fixtures/acme.json index fe64127..0f2f8fb 100644 --- a/testing/fixtures/acme.json +++ b/testing/fixtures/acme.json @@ -6,16 +6,17 @@ "AWKWARD rather than tidy — a site name with an apostrophe and an", "ampersand (both legal in the card's pattern, both special in TypeScript", "strings and HTML), a hyphenated repo slug that CONTAINS a word of the", - "baseline's own (`platforms`), an owner other than the baseline's, and a", - "multi-label root domain — because a fixture that only uses values the", - "templates were written against proves the templates work on the values", - "they were written against.", + "baseline's own (`platforms`), an owner other than the baseline's, and NO", + "root domain — a console build asks for none, so the placeholder", + ".example.com (stage..example.com on stage) is what a", + "site is born with, and the e2e tier serves its tenants on it — because a", + "fixture that only uses values the templates were written against proves", + "the templates work on the values they were written against.", "Every key here is an input repo-blueprint.yaml declares. A key it does not", "declare is a fixture that has drifted, and orun refuses it." ], "reponame": "acme-platforms", "productname": "Sam's Tenants & Co", - "productdomain": "tenants.acme.dev", "githuborg": "acme-inc", "subdomain": "acme", "orunWorkspace": "ws_0000000000000000000000000000000f", diff --git a/testing/placement.test.sh b/testing/placement.test.sh index 698d04c..033bb62 100755 --- a/testing/placement.test.sh +++ b/testing/placement.test.sh @@ -184,7 +184,9 @@ for env in ("stage", "prod"): if intent["environments"][env].get("url") != want: bad(f"environments.{env}.url is {intent['environments'][env].get('url')}, not {want}") # The root domains tenants hang off: the product's domain, stage one level below. -domain = values["productdomain"] +# The fixture carries none (a console build asks for none), so it is the +# placeholder the rebrand writes, .example.com. +domain = (values.get("productdomain") or "").strip() or f'{values["reponame"]}.example.com' for env, want in (("dev", domain), ("stage", f"stage.{domain}"), ("prod", domain)): got = (intent["environments"][env].get("env") or {}).get("BASE_DOMAIN") if got != want: @@ -237,7 +239,8 @@ git -C "$tree" checkout -q main python3 - "$scratch/plan.json" "$values" <<'PY' || fails=$((fails + 1)) import json, sys plan, values = json.load(open(sys.argv[1])), json.load(open(sys.argv[2])) -repo, sub, ws, domain = values["reponame"], values["subdomain"], values["orunWorkspace"], values["productdomain"] +repo, sub, ws = values["reponame"], values["subdomain"], values["orunWorkspace"] +domain = (values.get("productdomain") or "").strip() or f"{repo}.example.com" # none given: the placeholder problems = [] def bad(m): problems.append(m) jobs = {(j["component"], j["environment"]): j for j in plan["jobs"]} diff --git a/testing/rebrand.test.sh b/testing/rebrand.test.sh index 5e36737..cc3029c 100755 --- a/testing/rebrand.test.sh +++ b/testing/rebrand.test.sh @@ -90,6 +90,18 @@ check "the root domain tenants hang off is the product's domain, not a renamed s check "stage's root domain stays one level below it" \ "$acme" intent.yaml ' BASE_DOMAIN: stage.platforms-starter-kit.example.com' \ ' BASE_DOMAIN: stage.tenants.acme.dev' +check "no domain given: the reserved placeholder, for an owner to replace later" \ + '{"reponame":"acme-tenants","productname":"Acme Tenants","githuborg":"acme-inc","subdomain":"acme"}' \ + intent.yaml ' BASE_DOMAIN: platforms-starter-kit.example.com' \ + ' BASE_DOMAIN: acme-tenants.example.com' +check "…and stage's root domain one level below it" \ + '{"reponame":"acme-tenants","productname":"Acme Tenants","githuborg":"acme-inc","subdomain":"acme"}' \ + intent.yaml ' BASE_DOMAIN: stage.platforms-starter-kit.example.com' \ + ' BASE_DOMAIN: stage.acme-tenants.example.com' +check "an empty domain is no domain" \ + '{"reponame":"acme-tenants","productname":"Acme Tenants","productdomain":""}' \ + intent.yaml ' BASE_DOMAIN: platforms-starter-kit.example.com' \ + ' BASE_DOMAIN: acme-tenants.example.com' check "the wildcard route the owner adds names the product's domain and Worker" \ "$acme" README.md '`*.platforms-starter-kit.example.com/*` → `platforms-starter-kit-web-prod`' \ '`*.tenants.acme.dev/*` → `acme-tenants-web-prod`' diff --git a/tooling/rebrand/rebrand.mjs b/tooling/rebrand/rebrand.mjs index 2bedc4b..26c9f2a 100644 --- a/tooling/rebrand/rebrand.mjs +++ b/tooling/rebrand/rebrand.mjs @@ -29,7 +29,7 @@ // { // "reponame": "acme-notes", // required — repo slug // "productname": "Acme Notes", // required — the site's display name -// "productdomain": "acme.dev", // required — the product domain +// "productdomain": "acme.dev", // optional — default .example.com (set later) // "githuborg": "acme-inc", // owner of the product repo (source link) // "brandSlug": "acme", // default: reponame — worker name prefix // "subdomain": "acme", // default: your-workers-subdomain @@ -70,7 +70,7 @@ if (!verifyOnly && !valuesPath) { } if (valuesPath) { values = JSON.parse(fs.readFileSync(valuesPath, "utf8")); - for (const required of ["reponame", "productname", "productdomain"]) { + for (const required of ["reponame", "productname"]) { if (typeof values[required] !== "string" || values[required].length === 0) { console.error(`rebrand: values file is missing required field "${required}"`); process.exit(2); @@ -133,7 +133,11 @@ const rx = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); // All fields are unused under --verify; the fallbacks keep derivation total. const reponame = values.reponame ?? ""; const productname = values.productname ?? ""; -const productdomain = values.productdomain ?? ""; +// The domain is NOT ASKED at bootstrap: a site goes live on workers.dev and an +// owner sets a domain later. Until then the reserved placeholder +// `.example.com` (RFC 2606 — it can never be someone else's) stands +// wherever the domain goes, so setting it is replacing one string. +const productdomain = (values.productdomain ?? "").trim() || (reponame ? `${reponame}.example.com` : ""); const githuborg = (values.githuborg ?? "").trim() || baseline.githubOwner; const brandSlug = (values.brandSlug ?? "").trim() || reponame; const subdomain = (values.subdomain ?? "").trim() || "your-workers-subdomain";