Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 15 additions & 9 deletions .baseline/product/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 —
`<tenant>.platforms-starter-kit.example.com` on prod,
`<tenant>.stage.platforms-starter-kit.example.com` on stage — once that
domain's wildcard route points at the Worker (below). Until then the site
`<tenant>.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/<tenant>`. The landing form
says which, creating a tenant redirects to it, and `/admin` links to it. The
Expand Down Expand Up @@ -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/<tenant>` 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.
Expand All @@ -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.<domain>` 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/<tenant>`. For customer-owned
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/baseline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
30 changes: 19 additions & 11 deletions BOOTSTRAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -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=<workers-dev-subdomain>
```
Expand Down Expand Up @@ -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/<tenant>`, and `productdomain` defaults to
empty, which brands the reserved placeholder `<reponame>.example.com` into
`BASE_DOMAIN` (`stage.<reponame>.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 |
|---|---|
Expand Down Expand Up @@ -165,18 +171,20 @@ orun new --blueprint repo-blueprint.yaml \
`--components`, the `WIRING_<ROOT>_<ENV>` 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.<productdomain>` 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.<domain>` for
stage — inlined at build time. A console build asks for none, so it is
born as the reserved placeholder `<reponame>.example.com` (a hand-run
build may pass `productdomain`). Until a real one is attached the site
answers on workers.dev, where
`<tenant>.<worker>.<sub>.workers.dev` cannot resolve, so tenants are
served at `/s/<tenant>` 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 (`*.<domain>`) and
the apex, and Worker routes `*.<domain>/*` and `<domain>/*` to
`<reponame>-web-prod` (stage likewise on `stage.<domain>`, 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.
Expand Down Expand Up @@ -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 <product>/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) |
Expand Down
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ for the design, the milestones and the as-built status.
git clone --depth 1 --branch <baseline-tag> 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=<workers-dev-subdomain>
```

Expand All @@ -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/<tenant>` 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 `<reponame>.example.com` as its root domain
(`BASE_DOMAIN`), and that step replaces it with the owner's.

| What makes it a baseline | Where |
|---|---|
Expand Down
7 changes: 4 additions & 3 deletions ai/context/current.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 `<reponame>.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
Expand All @@ -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`.
1 change: 1 addition & 0 deletions ai/context/decisions.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 `<reponame>.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) |
20 changes: 11 additions & 9 deletions ai/context/operations.md
Original file line number Diff line number Diff line change
Expand Up @@ -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, `<tenant>.<root>`; 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/<tenant>`
(`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,
`<tenant>.<root>`; 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/<tenant>` (`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

Expand Down Expand Up @@ -129,7 +131,7 @@ orun integrations list --org <ws> --json && orun cloud check --org <ws>
| 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 <reason> <stamp>`) 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 <id> --prefix subdomain: --remote`, `wrangler kv key delete subdomain:<name> --namespace-id <id> --remote` (the id is in the environment's `WIRING_CLOUDFLARE_KV`) |
Expand Down
17 changes: 8 additions & 9 deletions blueprint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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/<tenant>, 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 `<reponame>.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
Expand All @@ -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 — <tenant>.<domain> on prod,
<tenant>.stage.<domain> on stage. It does not need to exist yet: the
site goes live on workers.dev first, tenants at /s/<tenant>, 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-]*$"
Expand Down
25 changes: 17 additions & 8 deletions docs/phases/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 `<tenant>.<root domain>` (the environment's
`BASE_DOMAIN`: `productdomain` on prod, `stage.<productdomain>` 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`: `<domain>` on prod, `stage.<domain>` on stage, born as the
placeholder `<reponame>.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/<tenant>`, 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/<tenant>`; empty brands the reserved
placeholder `<reponame>.example.com` into `BASE_DOMAIN`
(`stage.<reponame>.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
Expand Down
Loading
Loading