From 57d50557195dc41455240b82ca90c54e4f08f796 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 18 Oct 2026 14:11:49 +0000 Subject: [PATCH 1/6] =?UTF-8?q?PS5:=20the=20cirrus=20standard=20=E2=80=94?= =?UTF-8?q?=20no=20kiox,=20generated=20component=20docs,=20the=20context?= =?UTF-8?q?=20pack?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Remove kiox.yaml/kiox.lock and their two blueprint modules: nothing ran the kiox pin (v2.15.0); every workflow pins orun through orun-action. - Generate docs/{overview,architecture,runbook}.md for every component (web, cloudflare-kv, web-tests) from what it declares (tooling/catalog/gen-component-docs.py), and fail Baseline CI when they drift (--check). - Add ai/context/{current,decisions,open-risks}.md (this repository's own; nothing places them). - Close out PS4 (shipped, tagged baseline-v1; the epic README's "Shipped as" was still at #4) and record PS5 (PS-6). Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01D8AmgTwmnp4M8mgmnS9aha --- .github/workflows/baseline.yml | 6 + ai/context/current.md | 42 ++ ai/context/decisions.md | 20 + ai/context/open-risks.md | 15 + apps/web/docs/architecture.md | 27 + apps/web/docs/overview.md | 20 + apps/web/docs/runbook.md | 40 ++ .../cloudflare-kv/docs/architecture.md | 29 + .../terraform/cloudflare-kv/docs/overview.md | 19 + infra/terraform/cloudflare-kv/docs/runbook.md | 20 + kiox.lock | 11 - kiox.yaml | 6 - repo-blueprint.yaml | 12 +- specs/epics/README.md | 2 +- .../IMPLEMENTATION-STATUS.md | 40 +- specs/epics/platforms-starter-kit/README.md | 7 +- specs/epics/platforms-starter-kit/epic.yaml | 7 + .../implementation-plan.md | 27 +- tasks/PS-6.TaskContract.yaml | 28 + testing/phases.test.sh | 2 +- tests/web/docs/architecture.md | 12 + tests/web/docs/overview.md | 18 + tests/web/docs/runbook.md | 26 + tooling/catalog/gen-component-docs.py | 519 ++++++++++++++++++ tooling/rebrand/rebrand.mjs | 1 - 25 files changed, 920 insertions(+), 36 deletions(-) create mode 100644 ai/context/current.md create mode 100644 ai/context/decisions.md create mode 100644 ai/context/open-risks.md create mode 100644 apps/web/docs/architecture.md create mode 100644 apps/web/docs/overview.md create mode 100644 apps/web/docs/runbook.md create mode 100644 infra/terraform/cloudflare-kv/docs/architecture.md create mode 100644 infra/terraform/cloudflare-kv/docs/overview.md create mode 100644 infra/terraform/cloudflare-kv/docs/runbook.md delete mode 100644 kiox.lock delete mode 100644 kiox.yaml create mode 100644 tasks/PS-6.TaskContract.yaml create mode 100644 tests/web/docs/architecture.md create mode 100644 tests/web/docs/overview.md create mode 100644 tests/web/docs/runbook.md create mode 100644 tooling/catalog/gen-component-docs.py diff --git a/.github/workflows/baseline.yml b/.github/workflows/baseline.yml index f149ade..c722c63 100644 --- a/.github/workflows/baseline.yml +++ b/.github/workflows/baseline.yml @@ -51,6 +51,12 @@ jobs: echo "── $t" bash "testing/$t.test.sh" done + # Every component's docs/{overview,architecture,runbook}.md is generated + # from what the component declares (its manifest, Worker config, + # Terraform, migrations, package scripts). A pull request that changes + # one of those facts without regenerating the pages fails here. + - name: Component docs match their manifests + run: python3 tooling/catalog/gen-component-docs.py --check # Tier 1. THE BLUEPRINT, READ AND PLACED BY THE BINARY A BOOTSTRAP RUNS. # diff --git a/ai/context/current.md b/ai/context/current.md new file mode 100644 index 0000000..d2a74f8 --- /dev/null +++ b/ai/context/current.md @@ -0,0 +1,42 @@ +# platforms-starter-kit — where this repository stands + +The entry page for anyone (or any agent) picking this repository up. It is +this repository's own state and does not ship to a product built from it; the +two pages that do are [operations.md](operations.md) and +[deployment.md](deployment.md). + +## What it is + +Vercel's Platforms Starter Kit — a multi-tenant app, every tenant a subdomain +— on Cloudflare Workers + Static Assets (`@opennextjs/cloudflare`), its tenant +records in Workers KV behind a module that keeps the Upstash client's surface, +the namespace provisioned per environment by Terraform through Orun. Packaged +as an Orun baseline: `orun new --blueprint repo-blueprint.yaml` builds a new +product in its own repository and takes it to live on stage and prod in one +landing (`01-product`: cloudflare-kv → web per environment), then records +what went live (`02-docs`). Off the root domain a tenant is `/s/`, so +a fresh product is whole on workers.dev before any custom domain. + +## Release + +| | | +|---|---| +| Latest tag | `baseline-v1` (PS4) | +| On `main` since | PS5 — the cirrus standard (no kiox, generated component docs, this context pack) | +| 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 + +| Question | Page | +|---|---| +| What shipped, and every departure from upstream | `specs/epics/platforms-starter-kit/IMPLEMENTATION-STATUS.md` | +| Why it is built this way | [decisions.md](decisions.md), then `specs/epics/platforms-starter-kit/design.md` | +| What could still go wrong | [open-risks.md](open-risks.md), then `specs/epics/platforms-starter-kit/risks-and-open-questions.md` | +| How to instantiate it | `BOOTSTRAP.md`, `docs/phases/` | +| What each component is | `apps/web/docs/`, `infra/terraform/cloudflare-kv/docs/`, `tests/web/docs/` (generated; `python3 tooling/catalog/gen-component-docs.py`) | + +## Next + +1. Bootstrap one product from the next tag against a workspace, and record + its timings (closes PS-K); then the registry row can leave `unlisted`. +2. Cut the next `baseline-vN` with `tag.yml` so the registry can pin PS5. diff --git a/ai/context/decisions.md b/ai/context/decisions.md new file mode 100644 index 0000000..9691802 --- /dev/null +++ b/ai/context/decisions.md @@ -0,0 +1,20 @@ +# platforms-starter-kit — decisions + +The choices that shape this repository, one line each, with where the full +reasoning lives. Superseded decisions stay listed, marked, so the history +reads in order. + +| # | Decision | Why | Source | +|---|---|---|---| +| 1 | OpenNext on Workers + Static Assets (`cloudflare-workers-assets-turbo`), the proxy inside the Worker | The template's pages, proxy and server actions run as written | `specs/epics/platforms-starter-kit/design.md` §2 | +| 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 | design.md §8, risk PS-B | +| 3 | `lib/redis.ts` keeps the Upstash client's surface (`get / set / del / keys / mget`, same keys, same JSON) | The template's data access and server actions stay untouched | design.md §3, risk PS-C | +| 4 | `wrangler.jsonc` rendered per environment from the KV wiring document, and committed as the fixture render; `dev` renders the fixture | The deploy lane checks the file exists before the build; no root applies to `dev` (PS4) | risks PS-I, PS-J | +| 5 | The root domain is one knob: the environment's `BASE_DOMAIN` in `intent.yaml`, inlined by `next build` | A wrangler var would never be read in production and would be a second place to edit | risk PS-E | +| 6 | One landing (`01-product`) then the record (`02-docs`); `web` depends on `cloudflare-kv`, enforced on a push to `main`, advisory on a pull request | The plan, not a landing boundary, orders the namespace before the Worker (cirrus-baseline since baseline-v22) | design.md §9 | +| 7 | Off the root domain a tenant is `/s/` on the request's host; no domain phase | A fresh deploy has no zone, and `workers-deploy` carries no zone permissions; subdomains are the owner's step | design.md §8b, risk PS-D | +| 8 | `/admin` stays unauthenticated, as upstream | No auth provider to carry; Cloudflare Access in front of `/admin*` is the zero-code gate | risk PS-H | +| 9 | `ci.yml` plans nothing while `intent.yaml` names `ws_CHANGE_ME` (replaced the `ORUN_CI` gate) | A bootstrap cannot set a repository variable | IMPLEMENTATION-STATUS (PS4) | +| 10 | stack-tectonic 0.19.0, not 0.20.0 | 0.20.0's lane-scoped install is refused by Next 16's Turbopack | IMPLEMENTATION-STATUS (PS4) | +| 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` | diff --git a/ai/context/open-risks.md b/ai/context/open-risks.md new file mode 100644 index 0000000..029786e --- /dev/null +++ b/ai/context/open-risks.md @@ -0,0 +1,15 @@ +# platforms-starter-kit — open risks + +What is not yet proven or not yet decided. The full write-up of every risk, +including the accepted and resolved ones, is +`specs/epics/platforms-starter-kit/risks-and-open-questions.md`; this page +lists only what is still live, so it should be short. + +| ID | Risk | State | What closes it | +|---|---|---|---| +| PS-K | No live bootstrap yet: the repository created and linked, the token minted, a real `terraform apply`, the lease-published wiring document, a real `wrangler deploy`, the probes and tenant subdomains on a real zone are all unproven | OPEN | One bootstrap from a tag against a workspace (and a zone routed to the Worker for subdomains) | + +Accepted, and worth knowing before you change them: PS-B (KV is eventually +consistent across locations), PS-D (tenant hostnames need a zone; the +baseline provisions none), PS-H (no authentication on `/admin`, as upstream), +PS-L (the bootstrap floor, orun v2.58.11, plans every edge enforced). diff --git a/apps/web/docs/architecture.md b/apps/web/docs/architecture.md new file mode 100644 index 0000000..6cf66a8 --- /dev/null +++ b/apps/web/docs/architecture.md @@ -0,0 +1,27 @@ +# web — architecture + +Built by the turbo pipeline from `apps/web` and deployed with wrangler. + +| | | +|---|---| +| Worker config | `apps/web/wrangler.template.jsonc` | +| Entry | `.open-next/worker.js` | +| Compatibility date | `2026-10-01` | +| Compatibility flags | `nodejs_compat`, `global_fetch_strictly_public` | + +## Bindings + +| Binding | Kind | Source | +|---|---|---| +| `KV` | Workers KV namespace | `app_kv_id` from `cloudflare-kv` | +| `ASSETS` | Static assets | `.open-next/assets` | + +Identifiers marked *from* a component are filled in at deploy time from +that component's published outputs for the environment being deployed. + +## Wiring + +Resolved at deploy time from secrets the infrastructure lanes publish (names only): + +- `WIRING_CLOUDFLARE_KV_PROD` +- `WIRING_CLOUDFLARE_KV_STAGE` diff --git a/apps/web/docs/overview.md b/apps/web/docs/overview.md new file mode 100644 index 0000000..0b34e73 --- /dev/null +++ b/apps/web/docs/overview.md @@ -0,0 +1,20 @@ +# web + +The Platforms Starter Kit (multi-tenant subdomains, tenants in Workers KV; Next.js on Cloudflare Workers + Static Assets via @opennextjs/cloudflare, per environment) + +A Cloudflare Worker with Static Assets (server rendering plus static files), deployed per environment by its CI lane. + +| | | +|---|---| +| Type | `cloudflare-workers-assets-turbo` | +| Source | `apps/web` | +| Package | `@app/web` | +| Environments | `dev`: `verify` · `stage`: `verify`, `deploy` on a push to `main` · `prod`: `verify`, `deploy` on a push to `main` | + +## Depends on + +- **cloudflare-kv** — Provisions the Cloudflare KV namespace the app binds (stage and prod) + +## Depended on by + +- (none) diff --git a/apps/web/docs/runbook.md b/apps/web/docs/runbook.md new file mode 100644 index 0000000..0e5e68f --- /dev/null +++ b/apps/web/docs/runbook.md @@ -0,0 +1,40 @@ +# web — runbook + +## How it runs + +Pull requests verify it; a merge to `main` deploys it to `stage`, `prod`. +CI plans what changed (`orun plan --changed`) and runs each lane with `orun run`; +the plan orders a component after everything it depends on. + +## Local commands + +```bash +pnpm --filter @app/web dev +pnpm --filter @app/web build +pnpm --filter @app/web typecheck +pnpm --filter @app/web lint +pnpm --filter @app/web preview +``` + +## Verify + +After a deploy the lane runs this smoke against the environment it +deployed (`ORUN_ENVIRONMENT`); `DEPLOYED_URL` overrides the URL: + +```bash +host="${DEPLOYED_URL#*://}" && html=$(curl -sfL "${DEPLOYED_URL}/") && echo "${html}" | grep -qF "${host}/s/" && curl -sf -o /dev/null "${DEPLOYED_URL}/admin" +``` + +## Rollback + +Revert the commit on `main`. The next convergence applies the previous desired +state; nothing was changed out of band, so there is nothing else to undo. + +## Common failures + +- **A `WIRING_*` secret is missing at deploy**: an infrastructure lane upstream + has not applied for this environment yet. Within one convergence the plan + runs it first; on its own, re-run that lane. +- **The smoke fails right after a first deploy**: a new workers.dev route can + answer 4xx for a few seconds and the lane retries. A failure that persists + is a regression in the deployed code. diff --git a/infra/terraform/cloudflare-kv/docs/architecture.md b/infra/terraform/cloudflare-kv/docs/architecture.md new file mode 100644 index 0000000..4ed1148 --- /dev/null +++ b/infra/terraform/cloudflare-kv/docs/architecture.md @@ -0,0 +1,29 @@ +# cloudflare-kv — architecture + +A `terraform` root at `infra/terraform/cloudflare-kv/terraform`. + +- **State** lives in the Orun Cloud HTTP state backend — no local state and + no state bucket to manage. +- **Credentials are brokered per run** from the workspace's provider + connections and resolved by name; none is stored in this repository. +- **Adoption** (`adopt.tf`): when state is empty but the resource already + exists, plan-time import adopts it instead of failing. + +## Resources + +- `cloudflare_workers_kv_namespace.app_kv` + +## Published outputs + +Written as job-output secrets on each environment after an apply; deploy +lanes downstream resolve them by name. + +| Secret | Terraform output | +|---|---| +| `WIRING_CLOUDFLARE_KV` | `wiring` | + +## Resolved at run time (names only) + +- `CLOUDFLARE_ACCOUNT_ID` +- `CLOUDFLARE_API_TOKEN` +- `TF_VAR_cloudflare_account_id` diff --git a/infra/terraform/cloudflare-kv/docs/overview.md b/infra/terraform/cloudflare-kv/docs/overview.md new file mode 100644 index 0000000..752f27c --- /dev/null +++ b/infra/terraform/cloudflare-kv/docs/overview.md @@ -0,0 +1,19 @@ +# cloudflare-kv + +Provisions the Cloudflare KV namespace the app binds (stage and prod) + +Terraform-managed infrastructure, planned and applied per environment by its CI lane. + +| | | +|---|---| +| Type | `terraform` | +| Source | `infra/terraform/cloudflare-kv` | +| Environments | `stage`: `plan-only`, `apply` on a push to `main` · `prod`: `plan-only`, `apply` on a push to `main` | + +## Depends on + +- (none) + +## Depended on by + +- **web** — The Platforms Starter Kit (multi-tenant subdomains, tenants in Workers KV; Next.js on Cloudflare Workers + Static Assets via @opennextjs/cloudflare, per environment) diff --git a/infra/terraform/cloudflare-kv/docs/runbook.md b/infra/terraform/cloudflare-kv/docs/runbook.md new file mode 100644 index 0000000..b5db692 --- /dev/null +++ b/infra/terraform/cloudflare-kv/docs/runbook.md @@ -0,0 +1,20 @@ +# cloudflare-kv — runbook + +## How it runs + +Pull requests plan it; a merge to `main` applies it to `stage`, `prod`. +CI plans what changed (`orun plan --changed`) and runs each lane with `orun run`; +the plan orders a component after everything it depends on. + +## Rollback + +Revert the commit on `main`. The next convergence applies the previous desired +state; nothing was changed out of band, so there is nothing else to undo. + +## Common failures + +- **Provider authentication fails**: the workspace's provider connection is + missing or revoked. Reconnect it in the console; credentials are brokered + from it per run. +- **"Already exists" on a first apply**: state is empty but the resource is + not. `adopt.tf` imports it at plan time; if it still fails, the resource was renamed outside Terraform. diff --git a/kiox.lock b/kiox.lock deleted file mode 100644 index 6e14690..0000000 --- a/kiox.lock +++ /dev/null @@ -1,11 +0,0 @@ -apiVersion: kiox.io/v1 -kind: WorkspaceLock -metadata: - name: example-platform -providers: - - alias: orun - provider: sourceplane/orun - source: ghcr.io/sourceplane/orun:v2.15.0 - version: v2.15.0 - resolved: ghcr.io/sourceplane/orun@sha256:1d28be8612dc8d8083b508f97cd71a24c090f6472c43c71f68455e3709a6a3c1 - store: e02472f57f2eb5fb5168b7d270ea547e5bffbf83824c4286abd7ba20f87cb9d1 diff --git a/kiox.yaml b/kiox.yaml deleted file mode 100644 index d654da0..0000000 --- a/kiox.yaml +++ /dev/null @@ -1,6 +0,0 @@ -apiVersion: kiox.io/v1 -kind: Workspace -metadata: - name: example-platform -providers: - orun: ghcr.io/sourceplane/orun:v2.15.0 diff --git a/repo-blueprint.yaml b/repo-blueprint.yaml index d7178e9..093e752 100644 --- a/repo-blueprint.yaml +++ b/repo-blueprint.yaml @@ -185,16 +185,6 @@ modules: source: baseline from: turbo.json to: turbo.json - - name: root-kiox - mode: copy - source: baseline - from: kiox.yaml - to: kiox.yaml - - name: root-kiox-lock - mode: copy - source: baseline - from: kiox.lock - to: kiox.lock - name: root-gitignore mode: copy source: baseline @@ -406,7 +396,7 @@ phases: await: "One convergence is deploying the product: the KV namespace first, then the app built with its id, on stage and prod side by side. The Next.js build is the long pole; nothing is stuck." done: "{{ .inputs.reponame }} is live on stage and prod — {{ .meta.files }} files on main, branded as {{ .inputs.productname }}, tenants answering at /s/ on workers.dev. That took {{ .meta.elapsed }}." failed: "The product did not come up. The failing lane above names the component — the KV apply, or the app's build, deploy or smoke — and a provider error is in its log; whatever deployed is still there." - modules: [ai-deployment, ai-operations, cloudflare-kv, discovery-roots, github-workflows, rebrand-values, root-gitignore, root-intent, root-kiox, root-kiox-lock, root-package-json, root-pnpm-lock, root-pnpm-workspace, root-readme, root-turbo, tooling-eslint, tooling-tsconfig, tooling-wire, vscode, web, web-tests] + modules: [ai-deployment, ai-operations, cloudflare-kv, discovery-roots, github-workflows, rebrand-values, root-gitignore, root-intent, root-package-json, root-pnpm-lock, root-pnpm-workspace, root-readme, root-turbo, tooling-eslint, tooling-tsconfig, tooling-wire, vscode, web, web-tests] # THE PLATFORM MUST BE ABLE TO SEE THE REPOSITORY BEFORE IT EXISTS. Every # phase lands a pull request that files under its task, and the platform # learns of a PR only through the GitHub App installation on the account diff --git a/specs/epics/README.md b/specs/epics/README.md index 00af518..a532407 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 | 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-v1`); 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 012537a..b8d0e45 100644 --- a/specs/epics/platforms-starter-kit/IMPLEMENTATION-STATUS.md +++ b/specs/epics/platforms-starter-kit/IMPLEMENTATION-STATUS.md @@ -9,7 +9,8 @@ the code departed from `design.md` or from the upstream template. | PS1 — the platform on Workers | ✅ Shipped | [#2](https://github.com/sourceplane/platforms-starter-kit/pull/2) | | PS2 — the KV namespace from Terraform | ✅ Shipped | [#3](https://github.com/sourceplane/platforms-starter-kit/pull/3) | | 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) | this PR (PS-5), to be tagged `baseline-v1` | +| 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 | PS-6 — on `main` after `baseline-v1`, not yet tagged | ## Departures from the upstream template @@ -138,6 +139,43 @@ Vercel", and it ships into every product. | `tooling/wire/render.mjs` | copied the template's header comment | writes a GENERATED banner | the committed render must say it is one | | `tasks/PS-1..4` | no `metadata` | `metadata.name` and `title` | `orun work check` (≥ v2.79) refused them | +## The cirrus standard (PS5) + +Nothing about the product changed. What changed is the baseline around it: + +| What | Before | After | Why | +|---|---|---|---| +| orun pin | `kiox.yaml` (v2.15.0) + `kiox.lock`, shipped to every product | gone; orun is pinned where it runs, the `orun-action` `version:` in each workflow | nothing ran the kiox pin, and it disagreed with the lanes (v2.78.4) | +| `root-kiox`, `root-kiox-lock` modules | in `01-product` | removed (`testing/phases.test.sh` and the rebrand's skip list follow) | a product is placed with 84 − 2 + 9 = 91 files: no kiox, plus the docs below | +| component docs | none | `apps/web/docs/`, `infra/terraform/cloudflare-kv/docs/`, `tests/web/docs/` — `overview.md`, `architecture.md`, `runbook.md` | cirrus-baseline documents every component; the workspace Docs library renders `docs/` beside each `component.yaml` | +| how the docs stay true | — | `tooling/catalog/gen-component-docs.py` derives them from the manifest, the Worker config, Terraform, migrations and package scripts; Baseline CI runs it with `--check` | a hand-written copy of a manifest drifts silently | +| context pack | `operations.md`, `deployment.md` | plus `current.md`, `decisions.md`, `open-risks.md` | cirrus-baseline's shape; the three new pages are this repository's own and no module places them (the leak gate still allows exactly two) | +| status | PS4 "this PR (PS-5), to be tagged `baseline-v1`"; the epic README's "Shipped as" at #4 | PS4 shipped and tagged `baseline-v1` | the tag existed; the documents had not caught up | + +## Verified (PS5) + +- `testing/{manifest,phases,coverage,rebrand,retouch,bootstrap-defer,wire}.test.sh` + green; `gen-component-docs.py --check` green (3 components, 9 pages). +- `testing/leak.test.sh` (v2.58.11): 91 files derived (84 − 2 kiox + 9 docs + pages); 85 shipped sources name no factory path; ai/context still exactly + the two declared pages. +- `testing/placement.test.sh` (v2.78.4, as `baseline.yml` runs it): 91 + tracked files, both landings, branded, re-tenanted; the product's own + `orun plan` for the 01-product merge applies `cloudflare-kv` (level 0) + before it deploys `web` (level 1) on stage and prod; a pull request's plan + waits on nothing; the 02-docs merge plans 0 jobs; `--resume` changes + nothing. +- `pnpm install --frozen-lockfile`, `wire:fixture` (the committed config is + its render), `typecheck`, `lint` (upstream's two `any` warnings), `test` + (28 tests, 6 files), `build` green. +- `testing/e2e.test.sh` (v2.78.4) green: the stage lane's planned steps in a + staged job tree, `wrangler dev` over the built Worker, the component's own + smoke, and a tenant created, read back by path, by `/admin` and by Host + header, and deleted. +- `terraform fmt -check`, `init -backend=false` and `validate` (1.15.3) on + `infra/terraform/cloudflare-kv` green. +- `orun task check PS-6` complete. + ## Verified (PS4) - `orun new --status` reads the blueprint at v2.58.11 (the bootstrap floor), diff --git a/specs/epics/platforms-starter-kit/README.md b/specs/epics/platforms-starter-kit/README.md index c1d84af..6e1c171 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 | ✅ Shipped — PS0–PS3 landed (#1, #2, #3, #4); PS4 — a baseline, in one landing (PS-5); KV apply and live deploy proven only by a live bootstrap | -| Cluster | **PS** (PS0–PS4) | +| Status | ✅ PS0–PS4 shipped (#1–#5), PS4 tagged `baseline-v1`; PS5 (the cirrus standard, PS-6) on `main`, not yet tagged. The KV apply and a live deploy are not yet proven by a live bootstrap (risk PS-K) | +| Cluster | **PS** (PS0–PS5) | | 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 | `main` after [#4](https://github.com/sourceplane/platforms-starter-kit/pull/4); verified locally under `wrangler dev` with a local KV, `terraform validate` on the root, deploy gated until a workspace is linked | +| Shipped as | `baseline-v1` ([#5](https://github.com/sourceplane/platforms-starter-kit/pull/5)), then PS5 on `main`; 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 @@ -34,3 +34,4 @@ The upstream code stays the code: the proxy, the pages, the server actions, `lib | PS2 — the KV namespace from Terraform | `infra/terraform/cloudflare-kv`, the app's `dependsOn` and `secretEnv` | the root validates; the wiring keys match the template's tokens | | 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 | Baseline CI green with the docs check | diff --git a/specs/epics/platforms-starter-kit/epic.yaml b/specs/epics/platforms-starter-kit/epic.yaml index 489da5a..ccf775c 100644 --- a/specs/epics/platforms-starter-kit/epic.yaml +++ b/specs/epics/platforms-starter-kit/epic.yaml @@ -40,3 +40,10 @@ spec: - "a product built from it carries the product only, renamed throughout to its own name, repository, Worker, namespace titles and root domain" - "Baseline CI is green: contract tests, the blueprint read by the pinned orun, the leak gate, the offline bootstrap and the end-to-end tier, which creates a tenant and reads it back through the Worker" tasks: [PS-5] + - name: "PS5 — the cirrus standard" + exitCriteria: + - "no file names kiox: orun is pinned where CI runs it (the orun-action `version:` in each workflow)" + - "every component carries generated docs/{overview,architecture,runbook}.md, and Baseline CI fails a pull request whose manifests and pages disagree" + - "ai/context carries this repository's current.md, decisions.md and open-risks.md, and none of them ships to a product" + - "every milestone's status row agrees with the tags" + tasks: [PS-6] diff --git a/specs/epics/platforms-starter-kit/implementation-plan.md b/specs/epics/platforms-starter-kit/implementation-plan.md index 1222b4e..a9a96ce 100644 --- a/specs/epics/platforms-starter-kit/implementation-plan.md +++ b/specs/epics/platforms-starter-kit/implementation-plan.md @@ -71,9 +71,34 @@ the fixture, `apps/web`'s enforced `dependsOn: cloudflare-kv` on main, - the status file records what is proven offline and what only a live bootstrap (or a custom domain) can prove +## PS5 — the cirrus standard ✅ + +Bring the baseline to cirrus-baseline's standard, with nothing about the +product itself changing. + +- **No kiox.** `kiox.yaml`/`kiox.lock` pinned an orun (v2.15.0) that nothing + ran: every workflow installs orun itself through `orun-action` with its own + `version:`. The files, their two modules and the rebrand's skip entry go. +- **Component docs.** `tooling/catalog/gen-component-docs.py` writes each + component's `docs/overview.md`, `docs/architecture.md` and `docs/runbook.md` + from what the component declares, as cirrus-baseline's do; the pages ship + with the component. Baseline CI runs it with `--check`. +- **The context pack.** `ai/context/current.md`, `decisions.md` and + `open-risks.md` beside the two pages a product ships with — this + repository's own, so no module places them. +- **Status that agrees with the tags.** PS4 is shipped and tagged + `baseline-v1`. + +**Done when** +- `git grep -i kiox` finds nothing, and the leak gate and the offline + bootstrap pass without the two modules +- the docs check is green in Baseline CI +- this file, the status file and `epic.yaml` agree + ## After PS4 (outside this repository) -1. Cut `baseline-v1` with `tag.yml` from the merged `main`. +1. Cut `baseline-v1` with `tag.yml` from the merged `main` — done: `baseline-v1` + is [#5](https://github.com/sourceplane/platforms-starter-kit/pull/5)'s merge. 2. Register the row in orun-cloud's `infra/baselines-registry/baselines.yaml` (unlisted) with the card vendored at the tag. 3. Bootstrap one product from the tag against a workspace; record its diff --git a/tasks/PS-6.TaskContract.yaml b/tasks/PS-6.TaskContract.yaml new file mode 100644 index 0000000..49a25ce --- /dev/null +++ b/tasks/PS-6.TaskContract.yaml @@ -0,0 +1,28 @@ +apiVersion: orun.io/v1 +kind: TaskContract +metadata: + name: PS-6 + title: "The cirrus standard" +spec: + goal: The baseline meets cirrus-baseline's standard — no kiox pin (orun is pinned where CI runs it), every component documented by generated overview/architecture/runbook pages that CI keeps in step with the manifests, the agent context pack, and status documents that agree with the tags + affects: + - kiox.yaml + - kiox.lock + - repo-blueprint.yaml + - testing/phases.test.sh + - tooling/rebrand/** + - tooling/catalog/** + - .github/workflows/baseline.yml + - apps/web/docs/** + - infra/terraform/cloudflare-kv/docs/** + - tests/web/docs/** + - ai/context/** + - specs/** + - tasks/** + doneWhen: + - no file names kiox, and the leak gate and the offline bootstrap place a product without it + - every component has docs/overview.md, docs/architecture.md and docs/runbook.md, and `python3 tooling/catalog/gen-component-docs.py --check` is green in Baseline CI + - ai/context carries current.md, decisions.md and open-risks.md for this repository (none of them ships) + - every milestone's status row agrees with the tags + gates: + - checks diff --git a/testing/phases.test.sh b/testing/phases.test.sh index 5307316..701589d 100755 --- a/testing/phases.test.sh +++ b/testing/phases.test.sh @@ -43,7 +43,7 @@ if not phases: PARTITION = { "01-product": ["ai-deployment", "ai-operations", "cloudflare-kv", "discovery-roots", "github-workflows", "rebrand-values", "root-gitignore", "root-intent", - "root-kiox", "root-kiox-lock", "root-package-json", "root-pnpm-lock", + "root-package-json", "root-pnpm-lock", "root-pnpm-workspace", "root-readme", "root-turbo", "tooling-eslint", "tooling-tsconfig", "tooling-wire", "vscode", "web", "web-tests"], "02-docs": [], diff --git a/tests/web/docs/architecture.md b/tests/web/docs/architecture.md new file mode 100644 index 0000000..7ef9670 --- /dev/null +++ b/tests/web/docs/architecture.md @@ -0,0 +1,12 @@ +# web-tests — architecture + +A test package at `tests/web`. Its lane runs the suite before it builds. + +## Suites (6) + +- `addresses.test.ts` +- `proxy.test.ts` +- `redis.test.ts` +- `site.test.ts` +- `subdomains.test.ts` +- `utils.test.ts` diff --git a/tests/web/docs/overview.md b/tests/web/docs/overview.md new file mode 100644 index 0000000..6e02b2d --- /dev/null +++ b/tests/web/docs/overview.md @@ -0,0 +1,18 @@ +# web-tests + +The test suite for **web**. It deploys nothing: its lane installs, builds and runs the tests. + +| | | +|---|---| +| Type | `turbo-package` | +| Source | `tests/web` | +| Package | `@app/web-tests` | +| Environments | `dev`: `quick-check` | + +## Depends on + +- (none) + +## Depended on by + +- (none) diff --git a/tests/web/docs/runbook.md b/tests/web/docs/runbook.md new file mode 100644 index 0000000..c687de2 --- /dev/null +++ b/tests/web/docs/runbook.md @@ -0,0 +1,26 @@ +# web-tests — runbook + +## How it runs + +Its lane runs on every pull request that changes it; it has no deployed surface. +CI plans what changed (`orun plan --changed`) and runs each lane with `orun run`; +the plan orders a component after everything it depends on. + +## Local commands + +```bash +pnpm --filter @app/web-tests build +pnpm --filter @app/web-tests test +pnpm --filter @app/web-tests typecheck +pnpm --filter @app/web-tests lint +``` + +## Rollback + +Revert the commit on `main`. The next convergence applies the previous desired +state; nothing was changed out of band, so there is nothing else to undo. + +## Common failures + +- **A dependent fails to build after a change here**: run `pnpm typecheck` + across the workspace before merging. diff --git a/tooling/catalog/gen-component-docs.py b/tooling/catalog/gen-component-docs.py new file mode 100644 index 0000000..2a6a8b8 --- /dev/null +++ b/tooling/catalog/gen-component-docs.py @@ -0,0 +1,519 @@ +#!/usr/bin/env python3 +"""Generate each component's docs (overview / architecture / runbook). + + python3 tooling/catalog/gen-component-docs.py # write + python3 tooling/catalog/gen-component-docs.py --check # fail on drift (CI) + +The Orun workspace's Docs library renders the `docs/` folder next to every +`component.yaml`. These pages are generated, not hand-written, because almost +everything in them is already declared somewhere CI validates: the component's +manifest (type, description, dependencies, environments, the secrets a lane +resolves, the smoke), its Worker config (bindings, triggers, the wiring the +deploy fills in), its Terraform (resources and outputs), its migrations and its +package scripts. A hand-written copy of those facts drifts the first time one +changes; a generated one cannot, because `--check` fails the pull request that +changes the fact without the page. + +What is NOT derivable (why a component exists, what a failure means for this +product in particular) belongs in the component's `description` and in the +product's own docs, not here. + +The pages ship with the component into every product built from this tree, so +they say nothing about where they came from: no factory paths, no generator +path, no provenance. Zero dependencies beyond PyYAML. +""" + +from __future__ import annotations + +import json +import pathlib +import re +import sys + +try: + import yaml +except ImportError: # pragma: no cover - the contract job installs it + sys.exit("gen-component-docs needs PyYAML (pip install pyyaml)") + +ROOT = pathlib.Path(__file__).resolve().parents[2] +ROOTS = ("apps", "packages", "infra", "tests") +SKIP_DIRS = {"node_modules", "dist", ".turbo", "docs", ".next", ".open-next", + ".wrangler", ".svelte-kit", ".nuxt", ".output", ".astro", "coverage"} + +# Paths a shipped page must never name: products are not placed with them. +FACTORY = re.compile( + r"repo-blueprint|BOOTSTRAP\.md|(? str: + """JSONC → JSON: drop comments outside strings, then trailing commas.""" + out, i, n, in_str = [], 0, len(text), False + while i < n: + c = text[i] + if in_str: + out.append(c) + if c == "\\" and i + 1 < n: + out.append(text[i + 1]) + i += 2 + continue + if c == '"': + in_str = False + i += 1 + continue + if c == '"': + in_str = True + out.append(c) + i += 1 + elif text.startswith("//", i): + j = text.find("\n", i) + i = n if j < 0 else j + elif text.startswith("/*", i): + j = text.find("*/", i + 2) + i = n if j < 0 else j + 2 + else: + out.append(c) + i += 1 + return re.sub(r",(\s*[}\]])", r"\1", "".join(out)) + + +def read_json(path: pathlib.Path) -> dict | None: + try: + return json.loads(strip_jsonc(path.read_text(encoding="utf-8"))) + except (OSError, ValueError): + return None + + +def rel(p: pathlib.Path) -> str: + return p.relative_to(ROOT).as_posix() + + +def discover() -> list[dict]: + found = [] + for root in ROOTS: + base = ROOT / root + if not base.is_dir(): + continue + stack = [base] + while stack: + d = stack.pop() + for entry in sorted(d.iterdir()): + if entry.is_dir(): + if entry.name in SKIP_DIRS or entry.name.startswith("."): + continue + if (entry / "main.tf").exists() and not (entry / "component.yaml").exists(): + continue + if len(entry.relative_to(base).parts) <= 3: + stack.append(entry) + elif entry.name == "component.yaml": + found.append(read_component(entry)) + comps = [c for c in found if c["name"] and c["type"]] + return sorted(comps, key=lambda c: c["name"]) + + +def read_component(file: pathlib.Path) -> dict: + doc = yaml.safe_load(file.read_text(encoding="utf-8")) or {} + meta, spec = doc.get("metadata") or {}, doc.get("spec") or {} + params = spec.get("parameters") or {} + deps = [d.get("component") for d in (spec.get("dependsOn") or []) if isinstance(d, dict)] + envs = [] + for e in ((spec.get("subscribe") or {}).get("environments") or []): + rules = [(r.get("profile"), ((r.get("when") or {}).get("triggerRef"))) + for r in (e.get("profileRules") or [])] + envs.append({"name": e.get("name"), "profile": e.get("profile"), "rules": rules}) + return { + "dir": file.parent, + "path": rel(file.parent), + "name": meta.get("name"), + "description": (meta.get("description") or "").strip(), + "type": spec.get("type"), + "deps": [d for d in deps if d], + "secret_env": sorted((spec.get("secretEnv") or {}).keys()), + "envs": envs, + "params": params, + "migrations_path": spec.get("path") if spec.get("type") == "db-migrate" else None, + } + + +def package_of(c: dict) -> dict | None: + return read_json(c["dir"] / "package.json") + + +def worker_config(c: dict) -> tuple[str | None, dict | None]: + """The config a deploy uses: the template when wiring renders one.""" + names = ["wrangler.template.jsonc", c["params"].get("wranglerConfig") or "", + "wrangler.jsonc", "wrangler.json"] + for name in names: + if name and (c["dir"] / name).is_file(): + return name, read_json(c["dir"] / name) + return None, None + + +WIRING = re.compile(r"@@wiring\(([^/)]+)/__ENV__:([^)]+)\)@@") + + +def wired(value) -> str | None: + m = WIRING.search(str(value)) if value is not None else None + return f"`{m.group(2)}` from `{m.group(1)}`" if m else None + + +def bindings(cfg: dict) -> list[tuple[str, str, str]]: + rows = [] + for kv in cfg.get("kv_namespaces") or []: + rows.append((kv.get("binding"), "Workers KV namespace", wired(kv.get("id")) or "declared in the config")) + for b in cfg.get("r2_buckets") or []: + rows.append((b.get("binding"), "R2 bucket", wired(b.get("bucket_name")) or f"`{b.get('bucket_name')}`")) + for d in cfg.get("d1_databases") or []: + rows.append((d.get("binding"), "D1 database", wired(d.get("database_id")) or "declared in the config")) + for h in cfg.get("hyperdrive") or []: + rows.append((h.get("binding"), "Hyperdrive (pooled Postgres)", wired(h.get("id")) or "declared in the config")) + if isinstance(cfg.get("ai"), dict) and cfg["ai"].get("binding"): + rows.append((cfg["ai"]["binding"], "Workers AI", "account-level; no resource to provision")) + for d in ((cfg.get("durable_objects") or {}).get("bindings") or []): + rows.append((d.get("name"), "Durable Object", f"class `{d.get('class_name')}`")) + for s in cfg.get("services") or []: + rows.append((s.get("binding"), "Service binding", f"Worker `{s.get('service')}`")) + for q in ((cfg.get("queues") or {}).get("producers") or []): + rows.append((q.get("binding"), "Queue producer", f"queue `{q.get('queue')}`")) + for r in cfg.get("ratelimits") or []: + simple = r.get("simple") or {} + rows.append((r.get("name"), "Rate limiter", + f"{simple.get('limit')} requests / {simple.get('period')}s per location")) + assets = cfg.get("assets") or {} + if assets.get("binding"): + rows.append((assets["binding"], "Static assets", f"`{assets.get('directory')}`")) + return [r for r in rows if r[0]] + + +def tf_facts(c: dict) -> dict: + tf_dir = c["dir"] / (c["params"].get("terraformDir") or "terraform") + resources, outputs, variables, backend = [], [], [], None + for f in sorted(tf_dir.glob("*.tf")) if tf_dir.is_dir() else []: + text = f.read_text(encoding="utf-8") + resources += [f"{t}.{n}" for t, n in re.findall(r'^resource\s+"([^"]+)"\s+"([^"]+)"', text, re.M)] + outputs += re.findall(r'^output\s+"([^"]+)"', text, re.M) + variables += re.findall(r'^variable\s+"([^"]+)"', text, re.M) + m = re.search(r'backend\s+"([^"]+)"', text) + backend = backend or (m.group(1) if m else None) + imports = (tf_dir / "adopt.tf").is_file() if tf_dir.is_dir() else False + return {"dir": rel(tf_dir) if tf_dir.is_dir() else None, "resources": resources, + "outputs": outputs, "variables": variables, "backend": backend, "adopt": imports} + + +def published(c: dict) -> list[tuple[str, str]]: + spec = c["params"].get("secretOutputs") or "" + pairs = [] + for part in str(spec).split(","): + if "=" in part: + k, v = part.split("=", 1) + pairs.append((k.strip(), v.strip())) + return pairs + + +def test_files(c: dict) -> list[str]: + out = [] + for p in sorted(c["dir"].rglob("*")): + if any(part in SKIP_DIRS for part in p.relative_to(c["dir"]).parts): + continue + if p.is_file() and re.search(r"\.(test|spec)\.(ts|tsx|js|mjs|cjs)$", p.name): + out.append(p.name) + return out + + +def migrations(c: dict) -> list[str]: + path = c["migrations_path"] + if not path: + return [] + d = ROOT / path + if not d.is_dir(): + return [] + return sorted(p.name for p in d.iterdir() if p.is_dir() or p.suffix == ".sql") + + +# ── phrasing ───────────────────────────────────────────────────────────── + +KIND = { + "cloudflare-worker-turbo": "A Cloudflare Worker, deployed per environment by its CI lane.", + "cloudflare-workers-assets-turbo": "A Cloudflare Worker with Static Assets (server rendering plus " + "static files), deployed per environment by its CI lane.", + "terraform": "Terraform-managed infrastructure, planned and applied per environment by its CI lane.", + "db-migrate": "Applies this repository's ordered database migrations per environment: " + "plan on pull requests, apply on merge to `main`.", + "turbo-package": "A workspace package built by the turbo pipeline. It deploys nothing itself: " + "its lane type-checks, lints, tests and builds it.", +} + +TRIGGER = {"github-push-main": "a push to `main`", "github-pull-request": "a pull request"} + + +def env_line(e: dict) -> str: + s = f"`{e['name']}`: `{e['profile']}`" + for profile, ref in e["rules"]: + s += f", `{profile}` on {TRIGGER.get(ref, f'`{ref}`')}" + return s + + +def is_tests(c: dict) -> bool: + return c["name"].endswith("-tests") or c["path"].startswith("tests/") + + +def subject_of(c: dict, by_name: dict) -> str | None: + if c["name"].endswith("-tests"): + s = c["name"][: -len("-tests")] + return s if s in by_name else None + return None + + +def bullet_list(names: list[str], by_name: dict) -> list[str]: + if not names: + return ["- (none)"] + out = [] + for n in names: + d = by_name.get(n) + out.append(f"- **{n}** — {d['description']}" if d and d["description"] else f"- **{n}**") + return out + + +# ── pages ──────────────────────────────────────────────────────────────── + +def overview(c: dict, by_name: dict, dependents: list[str]) -> str: + pkg = package_of(c) + kind = KIND.get(c["type"], f"A `{c['type']}` component.") + subject = subject_of(c, by_name) + if is_tests(c): + kind = (f"The test suite for **{subject}**. " if subject else "A test suite. ") + \ + "It deploys nothing: its lane installs, builds and runs the tests." + lines = [f"# {c['name']}", ""] + if c["description"]: + lines += [c["description"], ""] + lines += [kind, "", "| | |", "|---|---|", f"| Type | `{c['type']}` |", f"| Source | `{c['path']}` |"] + if pkg and pkg.get("name"): + lines.append(f"| Package | `{pkg['name']}` |") + if c["envs"]: + lines.append(f"| Environments | {' · '.join(env_line(e) for e in c['envs'])} |") + lines += ["", "## Depends on", "", *bullet_list(c["deps"], by_name), + "", "## Depended on by", "", *bullet_list(dependents, by_name), ""] + return "\n".join(lines) + + +def architecture(c: dict, by_name: dict) -> str: + lines = [f"# {c['name']} — architecture", ""] + t = c["type"] + + if t == "terraform": + f = tf_facts(c) + lines += [f"A `terraform` root at `{f['dir'] or c['path']}`.", ""] + if f["backend"] == "http": + lines += ["- **State** lives in the Orun Cloud HTTP state backend — no local state and", + " no state bucket to manage."] + lines += ["- **Credentials are brokered per run** from the workspace's provider", + " connections and resolved by name; none is stored in this repository."] + if f["adopt"]: + lines += ["- **Adoption** (`adopt.tf`): when state is empty but the resource already", + " exists, plan-time import adopts it instead of failing."] + lines.append("") + if f["resources"]: + lines += ["## Resources", "", *[f"- `{r}`" for r in f["resources"]], ""] + pub = published(c) + if pub: + lines += ["## Published outputs", "", + "Written as job-output secrets on each environment after an apply; deploy", + "lanes downstream resolve them by name.", "", + "| Secret | Terraform output |", "|---|---|", + *[f"| `{k}` | `{v}` |" for k, v in pub], ""] + elif f["outputs"]: + lines += ["## Outputs", "", *[f"- `{o}`" for o in f["outputs"]], ""] + if c["secret_env"]: + lines += ["## Resolved at run time (names only)", "", + *[f"- `{k}`" for k in c["secret_env"]], ""] + return "\n".join(lines) + + if t == "db-migrate": + migs = migrations(c) + lines += [f"Applies the migrations under `{c['migrations_path']}` in order, recording each one", + "it applies so a run only ever applies what is new. An already-applied migration", + "is never edited: a change is a new, later migration.", ""] + if migs: + lines += ["## Migrations", "", *[f"- `{m}`" for m in migs], ""] + if c["secret_env"]: + lines += ["## Resolved at run time (names only)", "", + *[f"- `{k}`" for k in c["secret_env"]], ""] + return "\n".join(lines) + + pkg = package_of(c) + if t.startswith("cloudflare-"): + cfg_name, cfg = worker_config(c) + lines += [f"Built by the turbo pipeline from `{c['path']}` and deployed with wrangler.", ""] + if cfg: + lines += ["| | |", "|---|---|", f"| Worker config | `{c['path']}/{cfg_name}` |"] + if cfg.get("main"): + lines.append(f"| Entry | `{cfg['main']}` |") + if cfg.get("compatibility_date"): + lines.append(f"| Compatibility date | `{cfg['compatibility_date']}` |") + if cfg.get("compatibility_flags"): + lines.append(f"| Compatibility flags | {', '.join(f'`{x}`' for x in cfg['compatibility_flags'])} |") + lines.append("") + rows = bindings(cfg) + lines += ["## Bindings", ""] + if rows: + lines += ["| Binding | Kind | Source |", "|---|---|---|", + *[f"| `{b}` | {k} | {s} |" for b, k, s in rows], ""] + if any("from `" in s for _, _, s in rows): + lines += ["Identifiers marked *from* a component are filled in at deploy time from", + "that component's published outputs for the environment being deployed.", ""] + else: + lines += ["None: the Worker binds no storage or service.", ""] + crons = (cfg.get("triggers") or {}).get("crons") or [] + if crons: + lines += ["## Scheduled triggers", "", *[f"- `{x}`" for x in crons], ""] + env_names = sorted((cfg.get("env") or {}).keys()) + var_names = sorted((cfg.get("vars") or {}).keys()) + if var_names: + lines += ["## Variables", "", ", ".join(f"`{v}`" for v in var_names) + + (f" — overridden per environment ({', '.join(f'`{e}`' for e in env_names)})." + if env_names else "."), ""] + wiring = [k for k in c["secret_env"] if k.startswith("WIRING_")] + others = [k for k in c["secret_env"] if not k.startswith("WIRING_")] + if wiring: + lines += ["## Wiring", "", + "Resolved at deploy time from secrets the infrastructure lanes publish (names only):", + "", *[f"- `{k}`" for k in wiring], ""] + if others: + lines += ["## Secrets resolved by the lane (names only)", "", *[f"- `{k}`" for k in others], ""] + return "\n".join(lines) + + # turbo-package + if is_tests(c): + files = test_files(c) + lines += [f"A test package at `{c['path']}`. Its lane runs the suite before it builds.", ""] + if files: + lines += [f"## Suites ({len(files)})", "", *[f"- `{f}`" for f in files], ""] + return "\n".join(lines) + lines += [f"A workspace package at `{c['path']}`, consumed at build time by the components", + "that depend on it. It holds no credentials and opens no connections of its own.", ""] + if pkg and pkg.get("exports"): + ex = pkg["exports"] + keys = sorted(ex.keys()) if isinstance(ex, dict) else ["."] + lines += ["## Exports", "", *[f"- `{k}`" for k in keys], ""] + return "\n".join(lines) + + +def runbook(c: dict, by_name: dict) -> str: + t = c["type"] + pkg = package_of(c) + lines = [f"# {c['name']} — runbook", "", "## How it runs", ""] + deploys = [e["name"] for e in c["envs"] + if any(ref == "github-push-main" for _, ref in e["rules"])] + if deploys and t in ("terraform", "db-migrate"): + lines += [f"Pull requests plan it; a merge to `main` applies it to " + f"{', '.join(f'`{e}`' for e in deploys)}."] + elif deploys: + lines += [f"Pull requests verify it; a merge to `main` deploys it to " + f"{', '.join(f'`{e}`' for e in deploys)}."] + else: + lines += ["Its lane runs on every pull request that changes it; it has no deployed surface."] + lines += ["CI plans what changed (`orun plan --changed`) and runs each lane with `orun run`;", + "the plan orders a component after everything it depends on.", ""] + + if pkg and pkg.get("scripts"): + name = pkg.get("name") + wanted = [s for s in ("dev", "build", "test", "typecheck", "lint", "preview") if s in pkg["scripts"]] + if name and wanted: + lines += ["## Local commands", "", "```bash", + *[f"pnpm --filter {name} {s}" for s in wanted], "```", ""] + + smoke = c["params"].get("smokeCommand") + if smoke and "No smoke" not in str(smoke): + lines += ["## Verify", "", "After a deploy the lane runs this smoke against the environment it", + "deployed (`ORUN_ENVIRONMENT`); `DEPLOYED_URL` overrides the URL:", "", + "```bash", str(smoke).strip(), "```", ""] + + lines += ["## Rollback", "", + "Revert the commit on `main`. The next convergence applies the previous desired", + "state; nothing was changed out of band, so there is nothing else to undo.", "", + "## Common failures", ""] + if t == "terraform": + lines += ["- **Provider authentication fails**: the workspace's provider connection is", + " missing or revoked. Reconnect it in the console; credentials are brokered", + " from it per run.", + "- **\"Already exists\" on a first apply**: state is empty but the resource is", + " not." + (" `adopt.tf` imports it at plan time; if it still fails, the resource" + " was renamed outside Terraform." if tf_facts(c)["adopt"] else + " Import it, or delete the stray resource, then re-run."), ""] + elif t == "db-migrate": + lines += ["- **An applied migration's file changed**: the run stops rather than guess.", + " Restore the file and write the change as a new migration.", + "- **The database is unreachable**: the infrastructure lane it depends on has", + " not applied for this environment; that lane runs first in a convergence.", ""] + elif t.startswith("cloudflare-"): + lines += ["- **A `WIRING_*` secret is missing at deploy**: an infrastructure lane upstream", + " has not applied for this environment yet. Within one convergence the plan", + " runs it first; on its own, re-run that lane.", + "- **The smoke fails right after a first deploy**: a new workers.dev route can", + " answer 4xx for a few seconds and the lane retries. A failure that persists", + " is a regression in the deployed code.", ""] + else: + lines += ["- **A dependent fails to build after a change here**: run `pnpm typecheck`", + " across the workspace before merging.", ""] + return "\n".join(lines) + + +# ── main ───────────────────────────────────────────────────────────────── + +def main() -> int: + check = "--check" in sys.argv[1:] + comps = discover() + if not comps: + print("no component.yaml found", file=sys.stderr) + return 1 + by_name = {c["name"]: c for c in comps} + dependents: dict[str, list[str]] = {c["name"]: [] for c in comps} + for c in comps: + for d in c["deps"]: + dependents.setdefault(d, []).append(c["name"]) + + drifted, written, leaks = [], 0, [] + for c in comps: + pages = { + "overview.md": overview(c, by_name, sorted(dependents.get(c["name"], []))), + "architecture.md": architecture(c, by_name), + "runbook.md": runbook(c, by_name), + } + for fname, body in pages.items(): + target = c["dir"] / "docs" / fname + for n, line in enumerate(body.splitlines(), 1): + m = FACTORY.search(line) + if m: + leaks.append(f"{rel(target)}:{n} would name {m.group(0)!r}") + current = target.read_text(encoding="utf-8") if target.exists() else None + if current == body: + continue + if check: + drifted.append(rel(target)) + continue + target.parent.mkdir(parents=True, exist_ok=True) + target.write_text(body, encoding="utf-8") + written += 1 + + if leaks: + print("✗ a generated page would name a path products do not have:", file=sys.stderr) + for l in leaks: + print(f" {l}", file=sys.stderr) + return 1 + if check: + if drifted: + print(f"✗ {len(drifted)} component doc(s) differ from what the manifests say:", file=sys.stderr) + for f in drifted: + print(f" {f}", file=sys.stderr) + print("\nRun: python3 tooling/catalog/gen-component-docs.py", file=sys.stderr) + return 1 + print(f"✓ component docs match {len(comps)} component.yaml file(s)") + return 0 + print(f"✓ wrote {written} page(s) for {len(comps)} component(s)") + return 0 + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/tooling/rebrand/rebrand.mjs b/tooling/rebrand/rebrand.mjs index 6985afb..2bedc4b 100644 --- a/tooling/rebrand/rebrand.mjs +++ b/tooling/rebrand/rebrand.mjs @@ -181,7 +181,6 @@ const EXCLUDE_RE = new RegExp( // product claim to be a baseline called by the product's own name. "^\\.baseline/", "^pnpm-lock\\.yaml$", - "^kiox\\.lock$", "\\.(png|jpg|jpeg|ico|gif|webp|woff2?|ttf|eot)$", ].join("|"), ); From 7ab679f82cdb873a6ff01aa4431a72421f3b59d2 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 18 Oct 2026 14:26:03 +0000 Subject: [PATCH 2/6] PS5: the kiox exit criterion names what it can mean This milestone's own record (the status file, the plan, epic.yaml, the task contract, ai/context) says that kiox was removed, so "no file names kiox" could never hold literally. The criterion is now that nothing outside this milestone's own record names kiox. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01D8AmgTwmnp4M8mgmnS9aha --- specs/epics/platforms-starter-kit/epic.yaml | 2 +- specs/epics/platforms-starter-kit/implementation-plan.md | 5 +++-- tasks/PS-6.TaskContract.yaml | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/specs/epics/platforms-starter-kit/epic.yaml b/specs/epics/platforms-starter-kit/epic.yaml index ccf775c..2c9eb8a 100644 --- a/specs/epics/platforms-starter-kit/epic.yaml +++ b/specs/epics/platforms-starter-kit/epic.yaml @@ -42,7 +42,7 @@ spec: tasks: [PS-5] - name: "PS5 — the cirrus standard" exitCriteria: - - "no file names kiox: orun is pinned where CI runs it (the orun-action `version:` in each workflow)" + - "nothing outside this milestone's own record names kiox: orun is pinned where CI runs it (the orun-action `version:` in each workflow)" - "every component carries generated docs/{overview,architecture,runbook}.md, and Baseline CI fails a pull request whose manifests and pages disagree" - "ai/context carries this repository's current.md, decisions.md and open-risks.md, and none of them ships to a product" - "every milestone's status row agrees with the tags" diff --git a/specs/epics/platforms-starter-kit/implementation-plan.md b/specs/epics/platforms-starter-kit/implementation-plan.md index a9a96ce..a79510e 100644 --- a/specs/epics/platforms-starter-kit/implementation-plan.md +++ b/specs/epics/platforms-starter-kit/implementation-plan.md @@ -90,8 +90,9 @@ product itself changing. `baseline-v1`. **Done when** -- `git grep -i kiox` finds nothing, and the leak gate and the offline - bootstrap pass without the two modules +- nothing outside this milestone's own record names kiox (`git grep -i + kiox`), and the leak gate and the offline bootstrap pass without the two + modules - the docs check is green in Baseline CI - this file, the status file and `epic.yaml` agree diff --git a/tasks/PS-6.TaskContract.yaml b/tasks/PS-6.TaskContract.yaml index 49a25ce..0f51317 100644 --- a/tasks/PS-6.TaskContract.yaml +++ b/tasks/PS-6.TaskContract.yaml @@ -20,7 +20,7 @@ spec: - specs/** - tasks/** doneWhen: - - no file names kiox, and the leak gate and the offline bootstrap place a product without it + - nothing outside this milestone's own record names kiox, and the leak gate and the offline bootstrap place a product without it - every component has docs/overview.md, docs/architecture.md and docs/runbook.md, and `python3 tooling/catalog/gen-component-docs.py --check` is green in Baseline CI - ai/context carries current.md, decisions.md and open-risks.md for this repository (none of them ships) - every milestone's status row agrees with the tags From 81b10075186462faa3aaa4f5fb4d3045e8143a3f Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 18 Oct 2026 14:27:53 +0000 Subject: [PATCH 3/6] Regenerate component docs: prettier-padded tables, accurate wording The generator now lays tables out the way prettier does (an app whose lint is `prettier --check` accepts the pages as written), lists the WIRING_* failure only for Workers that take wiring, and no longer claims a package holds no credentials. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01D8AmgTwmnp4M8mgmnS9aha --- apps/web/docs/architecture.md | 20 +++---- apps/web/docs/overview.md | 10 ++-- .../cloudflare-kv/docs/architecture.md | 6 +-- .../terraform/cloudflare-kv/docs/overview.md | 8 +-- tests/web/docs/overview.md | 10 ++-- tooling/catalog/gen-component-docs.py | 53 ++++++++++++------- 6 files changed, 61 insertions(+), 46 deletions(-) diff --git a/apps/web/docs/architecture.md b/apps/web/docs/architecture.md index 6cf66a8..29c1212 100644 --- a/apps/web/docs/architecture.md +++ b/apps/web/docs/architecture.md @@ -2,21 +2,21 @@ Built by the turbo pipeline from `apps/web` and deployed with wrangler. -| | | -|---|---| -| Worker config | `apps/web/wrangler.template.jsonc` | -| Entry | `.open-next/worker.js` | -| Compatibility date | `2026-10-01` | +| | | +| ------------------- | ----------------------------------------------- | +| Worker config | `apps/web/wrangler.template.jsonc` | +| Entry | `.open-next/worker.js` | +| Compatibility date | `2026-10-01` | | Compatibility flags | `nodejs_compat`, `global_fetch_strictly_public` | ## Bindings -| Binding | Kind | Source | -|---|---|---| -| `KV` | Workers KV namespace | `app_kv_id` from `cloudflare-kv` | -| `ASSETS` | Static assets | `.open-next/assets` | +| Binding | Kind | Source | +| -------- | -------------------- | -------------------------------- | +| `KV` | Workers KV namespace | `app_kv_id` from `cloudflare-kv` | +| `ASSETS` | Static assets | `.open-next/assets` | -Identifiers marked *from* a component are filled in at deploy time from +Identifiers marked _from_ a component are filled in at deploy time from that component's published outputs for the environment being deployed. ## Wiring diff --git a/apps/web/docs/overview.md b/apps/web/docs/overview.md index 0b34e73..33e2cca 100644 --- a/apps/web/docs/overview.md +++ b/apps/web/docs/overview.md @@ -4,11 +4,11 @@ The Platforms Starter Kit (multi-tenant subdomains, tenants in Workers KV; Next. A Cloudflare Worker with Static Assets (server rendering plus static files), deployed per environment by its CI lane. -| | | -|---|---| -| Type | `cloudflare-workers-assets-turbo` | -| Source | `apps/web` | -| Package | `@app/web` | +| | | +| ------------ | ------------------------------------------------------------------------------------------------------------------ | +| Type | `cloudflare-workers-assets-turbo` | +| Source | `apps/web` | +| Package | `@app/web` | | Environments | `dev`: `verify` · `stage`: `verify`, `deploy` on a push to `main` · `prod`: `verify`, `deploy` on a push to `main` | ## Depends on diff --git a/infra/terraform/cloudflare-kv/docs/architecture.md b/infra/terraform/cloudflare-kv/docs/architecture.md index 4ed1148..0726cce 100644 --- a/infra/terraform/cloudflare-kv/docs/architecture.md +++ b/infra/terraform/cloudflare-kv/docs/architecture.md @@ -18,9 +18,9 @@ A `terraform` root at `infra/terraform/cloudflare-kv/terraform`. Written as job-output secrets on each environment after an apply; deploy lanes downstream resolve them by name. -| Secret | Terraform output | -|---|---| -| `WIRING_CLOUDFLARE_KV` | `wiring` | +| Secret | Terraform output | +| ---------------------- | ---------------- | +| `WIRING_CLOUDFLARE_KV` | `wiring` | ## Resolved at run time (names only) diff --git a/infra/terraform/cloudflare-kv/docs/overview.md b/infra/terraform/cloudflare-kv/docs/overview.md index 752f27c..bb58837 100644 --- a/infra/terraform/cloudflare-kv/docs/overview.md +++ b/infra/terraform/cloudflare-kv/docs/overview.md @@ -4,10 +4,10 @@ Provisions the Cloudflare KV namespace the app binds (stage and prod) Terraform-managed infrastructure, planned and applied per environment by its CI lane. -| | | -|---|---| -| Type | `terraform` | -| Source | `infra/terraform/cloudflare-kv` | +| | | +| ------------ | ---------------------------------------------------------------------------------------------------- | +| Type | `terraform` | +| Source | `infra/terraform/cloudflare-kv` | | Environments | `stage`: `plan-only`, `apply` on a push to `main` · `prod`: `plan-only`, `apply` on a push to `main` | ## Depends on diff --git a/tests/web/docs/overview.md b/tests/web/docs/overview.md index 6e02b2d..3534e6b 100644 --- a/tests/web/docs/overview.md +++ b/tests/web/docs/overview.md @@ -2,11 +2,11 @@ The test suite for **web**. It deploys nothing: its lane installs, builds and runs the tests. -| | | -|---|---| -| Type | `turbo-package` | -| Source | `tests/web` | -| Package | `@app/web-tests` | +| | | +| ------------ | -------------------- | +| Type | `turbo-package` | +| Source | `tests/web` | +| Package | `@app/web-tests` | | Environments | `dev`: `quick-check` | ## Depends on diff --git a/tooling/catalog/gen-component-docs.py b/tooling/catalog/gen-component-docs.py index 2a6a8b8..cda768f 100644 --- a/tooling/catalog/gen-component-docs.py +++ b/tooling/catalog/gen-component-docs.py @@ -232,6 +232,18 @@ def migrations(c: dict) -> list[str]: return sorted(p.name for p in d.iterdir() if p.is_dir() or p.suffix == ".sql") +# ── markdown ───────────────────────────────────────────────────────────── + +def md_table(header: list[str], rows: list[list[str]]) -> list[str]: + """A table laid out the way prettier lays it out, so a repo whose lint is + `prettier --check` accepts the page as written.""" + cols = len(header) + width = [max(3, len(header[i]), *(len(r[i]) for r in rows)) for i in range(cols)] + def line(cells): + return "| " + " | ".join(c.ljust(width[i]) for i, c in enumerate(cells)) + " |" + return [line(header), "| " + " | ".join("-" * w for w in width) + " |", *(line(r) for r in rows)] + + # ── phrasing ───────────────────────────────────────────────────────────── KIND = { @@ -288,11 +300,12 @@ def overview(c: dict, by_name: dict, dependents: list[str]) -> str: lines = [f"# {c['name']}", ""] if c["description"]: lines += [c["description"], ""] - lines += [kind, "", "| | |", "|---|---|", f"| Type | `{c['type']}` |", f"| Source | `{c['path']}` |"] + facts = [["Type", f"`{c['type']}`"], ["Source", f"`{c['path']}`"]] if pkg and pkg.get("name"): - lines.append(f"| Package | `{pkg['name']}` |") + facts.append(["Package", f"`{pkg['name']}`"]) if c["envs"]: - lines.append(f"| Environments | {' · '.join(env_line(e) for e in c['envs'])} |") + facts.append(["Environments", " · ".join(env_line(e) for e in c["envs"])]) + lines += [kind, "", *md_table(["", ""], facts)] lines += ["", "## Depends on", "", *bullet_list(c["deps"], by_name), "", "## Depended on by", "", *bullet_list(dependents, by_name), ""] return "\n".join(lines) @@ -321,8 +334,7 @@ def architecture(c: dict, by_name: dict) -> str: lines += ["## Published outputs", "", "Written as job-output secrets on each environment after an apply; deploy", "lanes downstream resolve them by name.", "", - "| Secret | Terraform output |", "|---|---|", - *[f"| `{k}` | `{v}` |" for k, v in pub], ""] + *md_table(["Secret", "Terraform output"], [[f"`{k}`", f"`{v}`"] for k, v in pub]), ""] elif f["outputs"]: lines += ["## Outputs", "", *[f"- `{o}`" for o in f["outputs"]], ""] if c["secret_env"]: @@ -347,21 +359,20 @@ def architecture(c: dict, by_name: dict) -> str: cfg_name, cfg = worker_config(c) lines += [f"Built by the turbo pipeline from `{c['path']}` and deployed with wrangler.", ""] if cfg: - lines += ["| | |", "|---|---|", f"| Worker config | `{c['path']}/{cfg_name}` |"] + facts = [["Worker config", f"`{c['path']}/{cfg_name}`"]] if cfg.get("main"): - lines.append(f"| Entry | `{cfg['main']}` |") + facts.append(["Entry", f"`{cfg['main']}`"]) if cfg.get("compatibility_date"): - lines.append(f"| Compatibility date | `{cfg['compatibility_date']}` |") + facts.append(["Compatibility date", f"`{cfg['compatibility_date']}`"]) if cfg.get("compatibility_flags"): - lines.append(f"| Compatibility flags | {', '.join(f'`{x}`' for x in cfg['compatibility_flags'])} |") - lines.append("") + facts.append(["Compatibility flags", ", ".join(f"`{x}`" for x in cfg["compatibility_flags"])]) + lines += [*md_table(["", ""], facts), ""] rows = bindings(cfg) lines += ["## Bindings", ""] if rows: - lines += ["| Binding | Kind | Source |", "|---|---|---|", - *[f"| `{b}` | {k} | {s} |" for b, k, s in rows], ""] + lines += [*md_table(["Binding", "Kind", "Source"], [[f"`{b}`", k, s] for b, k, s in rows]), ""] if any("from `" in s for _, _, s in rows): - lines += ["Identifiers marked *from* a component are filled in at deploy time from", + lines += ["Identifiers marked _from_ a component are filled in at deploy time from", "that component's published outputs for the environment being deployed.", ""] else: lines += ["None: the Worker binds no storage or service.", ""] @@ -391,8 +402,8 @@ def architecture(c: dict, by_name: dict) -> str: if files: lines += [f"## Suites ({len(files)})", "", *[f"- `{f}`" for f in files], ""] return "\n".join(lines) - lines += [f"A workspace package at `{c['path']}`, consumed at build time by the components", - "that depend on it. It holds no credentials and opens no connections of its own.", ""] + lines += [f"A workspace package at `{c['path']}`, consumed by the components that depend", + "on it. It has no deployed surface of its own.", ""] if pkg and pkg.get("exports"): ex = pkg["exports"] keys = sorted(ex.keys()) if isinstance(ex, dict) else ["."] @@ -448,10 +459,14 @@ def runbook(c: dict, by_name: dict) -> str: "- **The database is unreachable**: the infrastructure lane it depends on has", " not applied for this environment; that lane runs first in a convergence.", ""] elif t.startswith("cloudflare-"): - lines += ["- **A `WIRING_*` secret is missing at deploy**: an infrastructure lane upstream", - " has not applied for this environment yet. Within one convergence the plan", - " runs it first; on its own, re-run that lane.", - "- **The smoke fails right after a first deploy**: a new workers.dev route can", + _, cfg = worker_config(c) + takes_wiring = any(k.startswith("WIRING_") for k in c["secret_env"]) or \ + bool(cfg and WIRING.search(json.dumps(cfg))) + if takes_wiring: + lines += ["- **A `WIRING_*` secret is missing at deploy**: an infrastructure lane upstream", + " has not applied for this environment yet. Within one convergence the plan", + " runs it first; on its own, re-run that lane."] + lines += ["- **The smoke fails right after a first deploy**: a new workers.dev route can", " answer 4xx for a few seconds and the lane retries. A failure that persists", " is a regression in the deployed code.", ""] else: From e4da1fbcc40c78cda8793f406da0f7b52bb842e9 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 18 Oct 2026 14:35:04 +0000 Subject: [PATCH 4/6] Component docs: list optional and per-environment secrets The generator now reads `optionalSecretEnv` (listed as "(optional)") and secrets declared per environment under `subscribe.environments[]`, so a page no longer leaves out a secret its component declares. Its tables are laid out as prettier lays them out, the WIRING_* failure is listed only for Workers that take wiring, and a package is no longer said to hold no credentials. Every starter now carries the identical generator. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01D8AmgTwmnp4M8mgmnS9aha --- tooling/catalog/gen-component-docs.py | 37 ++++++++++++++++++--------- 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/tooling/catalog/gen-component-docs.py b/tooling/catalog/gen-component-docs.py index cda768f..9a39931 100644 --- a/tooling/catalog/gen-component-docs.py +++ b/tooling/catalog/gen-component-docs.py @@ -119,7 +119,13 @@ def read_component(file: pathlib.Path) -> dict: params = spec.get("parameters") or {} deps = [d.get("component") for d in (spec.get("dependsOn") or []) if isinstance(d, dict)] envs = [] + # Secrets may be declared for the whole component or per environment + # (`subscribe.environments[].secretEnv`); a page lists both. + req_env = set((spec.get("secretEnv") or {}).keys()) + opt_env = set((spec.get("optionalSecretEnv") or {}).keys()) for e in ((spec.get("subscribe") or {}).get("environments") or []): + req_env |= set((e.get("secretEnv") or {}).keys()) + opt_env |= set((e.get("optionalSecretEnv") or {}).keys()) rules = [(r.get("profile"), ((r.get("when") or {}).get("triggerRef"))) for r in (e.get("profileRules") or [])] envs.append({"name": e.get("name"), "profile": e.get("profile"), "rules": rules}) @@ -130,7 +136,8 @@ def read_component(file: pathlib.Path) -> dict: "description": (meta.get("description") or "").strip(), "type": spec.get("type"), "deps": [d for d in deps if d], - "secret_env": sorted((spec.get("secretEnv") or {}).keys()), + "secret_env": sorted(req_env), + "optional_env": sorted(opt_env - req_env), "envs": envs, "params": params, "migrations_path": spec.get("path") if spec.get("type") == "db-migrate" else None, @@ -278,6 +285,14 @@ def subject_of(c: dict, by_name: dict) -> str | None: return None +def names_list(c: dict, keep) -> list[str]: + """Secret names a lane resolves, required first; an optional one (from + `optionalSecretEnv`) is resolved when it exists and skipped when not.""" + req = [f"- `{k}`" for k in c["secret_env"] if keep(k)] + opt = [f"- `{k}` (optional)" for k in c["optional_env"] if keep(k)] + return req + opt + + def bullet_list(names: list[str], by_name: dict) -> list[str]: if not names: return ["- (none)"] @@ -337,9 +352,8 @@ def architecture(c: dict, by_name: dict) -> str: *md_table(["Secret", "Terraform output"], [[f"`{k}`", f"`{v}`"] for k, v in pub]), ""] elif f["outputs"]: lines += ["## Outputs", "", *[f"- `{o}`" for o in f["outputs"]], ""] - if c["secret_env"]: - lines += ["## Resolved at run time (names only)", "", - *[f"- `{k}`" for k in c["secret_env"]], ""] + if c["secret_env"] or c["optional_env"]: + lines += ["## Resolved at run time (names only)", "", *names_list(c, lambda k: True), ""] return "\n".join(lines) if t == "db-migrate": @@ -349,9 +363,8 @@ def architecture(c: dict, by_name: dict) -> str: "is never edited: a change is a new, later migration.", ""] if migs: lines += ["## Migrations", "", *[f"- `{m}`" for m in migs], ""] - if c["secret_env"]: - lines += ["## Resolved at run time (names only)", "", - *[f"- `{k}`" for k in c["secret_env"]], ""] + if c["secret_env"] or c["optional_env"]: + lines += ["## Resolved at run time (names only)", "", *names_list(c, lambda k: True), ""] return "\n".join(lines) pkg = package_of(c) @@ -385,14 +398,14 @@ def architecture(c: dict, by_name: dict) -> str: lines += ["## Variables", "", ", ".join(f"`{v}`" for v in var_names) + (f" — overridden per environment ({', '.join(f'`{e}`' for e in env_names)})." if env_names else "."), ""] - wiring = [k for k in c["secret_env"] if k.startswith("WIRING_")] - others = [k for k in c["secret_env"] if not k.startswith("WIRING_")] + wiring = names_list(c, lambda k: k.startswith("WIRING_")) + others = names_list(c, lambda k: not k.startswith("WIRING_")) if wiring: lines += ["## Wiring", "", "Resolved at deploy time from secrets the infrastructure lanes publish (names only):", - "", *[f"- `{k}`" for k in wiring], ""] + "", *wiring, ""] if others: - lines += ["## Secrets resolved by the lane (names only)", "", *[f"- `{k}`" for k in others], ""] + lines += ["## Secrets resolved by the lane (names only)", "", *others, ""] return "\n".join(lines) # turbo-package @@ -460,7 +473,7 @@ def runbook(c: dict, by_name: dict) -> str: " not applied for this environment; that lane runs first in a convergence.", ""] elif t.startswith("cloudflare-"): _, cfg = worker_config(c) - takes_wiring = any(k.startswith("WIRING_") for k in c["secret_env"]) or \ + takes_wiring = any(k.startswith("WIRING_") for k in c["secret_env"] + c["optional_env"]) or \ bool(cfg and WIRING.search(json.dumps(cfg))) if takes_wiring: lines += ["- **A `WIRING_*` secret is missing at deploy**: an infrastructure lane upstream", From aab7a32a7798cc13983b7360228840b04664c6a1 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 21 Oct 2026 12:17:50 +0000 Subject: [PATCH 5/6] PS5: read the workers.dev subdomain from the Cloudflare connection - blueprint.yaml: the subdomain input is `from: connection.cloudflare.workersSubdomain`, as cirrus-baseline since baseline-v23 (#30); the console renders no field for it - testing/manifest.test.sh: cirrus's rule verbatim, accepting the source only when spec.requires.integrations lists its provider (mutation-checked) - repo-blueprint.yaml, BOOTSTRAP.md, docs/phases/README.md: only a hand-run build passes --set subdomain - records: PS-7 under PS5, status, plan, epic index, ai/context Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01D8AmgTwmnp4M8mgmnS9aha --- BOOTSTRAP.md | 6 +++ ai/context/current.md | 7 ++-- ai/context/decisions.md | 1 + blueprint.yaml | 13 ++++++ docs/phases/README.md | 6 ++- repo-blueprint.yaml | 7 +++- specs/epics/README.md | 2 +- .../IMPLEMENTATION-STATUS.md | 41 ++++++++++++++++++- specs/epics/platforms-starter-kit/README.md | 6 +-- specs/epics/platforms-starter-kit/epic.yaml | 3 +- .../implementation-plan.md | 5 +++ tasks/PS-7.TaskContract.yaml | 25 +++++++++++ testing/manifest.test.sh | 15 ++++++- 13 files changed, 122 insertions(+), 15 deletions(-) create mode 100644 tasks/PS-7.TaskContract.yaml diff --git a/BOOTSTRAP.md b/BOOTSTRAP.md index 34c9997..fb3ea1d 100644 --- a/BOOTSTRAP.md +++ b/BOOTSTRAP.md @@ -61,6 +61,12 @@ orun new --blueprint repo-blueprint.yaml \ --set subdomain= ``` +`subdomain` is the workers.dev subdomain of the Cloudflare account you deploy +into (Workers & Pages → your subdomain). A build started from the console, or +with `orun baseline new --from bst_…`, never asks for it: the platform reads +it from the workspace's Cloudflare connection, the same one the deploy tokens +mint from. Only a hand-run build like this one passes it. + **`--run-hooks` is the difference between placing files and bootstrapping a product.** Without it `orun new` writes the tree and stops: no repository, no landing, no convergence watch, no probe. That is deliberate — it is what diff --git a/ai/context/current.md b/ai/context/current.md index d2a74f8..a6eb167 100644 --- a/ai/context/current.md +++ b/ai/context/current.md @@ -21,8 +21,8 @@ a fresh product is whole on workers.dev before any custom domain. | | | |---|---| -| Latest tag | `baseline-v1` (PS4) | -| On `main` since | PS5 — the cirrus standard (no kiox, generated component docs, this context pack) | +| 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) | | 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,6 +37,5 @@ a fresh product is whole on workers.dev before any custom domain. ## Next -1. Bootstrap one product from the next tag against a workspace, and record +1. Bootstrap one product from `baseline-v2` against a workspace, and record its timings (closes PS-K); then the registry row can leave `unlisted`. -2. Cut the next `baseline-vN` with `tag.yml` so the registry can pin PS5. diff --git a/ai/context/decisions.md b/ai/context/decisions.md index 9691802..423f3af 100644 --- a/ai/context/decisions.md +++ b/ai/context/decisions.md @@ -18,3 +18,4 @@ reads in order. | 10 | stack-tectonic 0.19.0, not 0.20.0 | 0.20.0's lane-scoped install is refused by Next 16's Turbopack | IMPLEMENTATION-STATUS (PS4) | | 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) | diff --git a/blueprint.yaml b/blueprint.yaml index 75074b8..bfcdfe3 100644 --- a/blueprint.yaml +++ b/blueprint.yaml @@ -100,6 +100,19 @@ spec: pattern: "^[a-z0-9][a-z0-9-]{0,62}$" help: The workers.dev subdomain of the Cloudflare account the site deploys into. example: acme + # READ FROM THE CLOUDFLARE CONNECTION, not asked. (The account's + # subdomain, not a tenant's: tenants are `.` on the + # product domain, the owner's step.) It belongs to the account the same + # way its id does, and there is exactly one right answer — a typed one + # could only be wrong, and wrong showed up after deploy, in the deploy's + # smoke, the phase probes and the verify URLs below. The integration + # reads it from Cloudflare at connect and on its hourly health check; + # the bootstrap door fills this input from the connection the build is + # BOUND to, the same one CLOUDFLARE_ACCOUNT_ID and the deploy tokens + # mint from, so all three name one account. The console renders no + # field for it. An account with no workers.dev subdomain refuses the + # build at the door, naming the fix, before anything is created. + from: connection.cloudflare.workersSubdomain # ── PREVIEW ONLY. repo-blueprint.yaml's `orun.integrations/reconcile@v1` # hooks mint these, brokered, during 01-product. ───────────────────────── diff --git a/docs/phases/README.md b/docs/phases/README.md index 17aaf97..3748259 100644 --- a/docs/phases/README.md +++ b/docs/phases/README.md @@ -64,8 +64,10 @@ the blueprint's **required** inputs — `reponame`, `productname`, must be supplied on every invocation, single-phase ones included. A `--values` file is easier than repeating `--set`. -- `subdomain` — the workers.dev subdomain of the Cloudflare account. It is - in every URL the phases probe. +- `subdomain` — the workers.dev subdomain of the Cloudflare account you + deploy into. It is in every URL the phases probe. A console or + `--from bst_…` build reads it from the Cloudflare connection; pass it only + for a hand-run build. - `orunWorkspace` — workspace id (`ws_…`). Unset, it is the workspace the build runs in (`from: workspace`); with none anywhere, a placeholder that fails loudly rather than silently claiming another tenant's workspace. diff --git a/repo-blueprint.yaml b/repo-blueprint.yaml index 093e752..135e26a 100644 --- a/repo-blueprint.yaml +++ b/repo-blueprint.yaml @@ -54,7 +54,12 @@ inputs: subdomain: type: string default: "your-workers-subdomain" - description: The workers.dev subdomain of the Cloudflare account the site deploys into — its URLs and the probes. + description: >- + The workers.dev subdomain of the Cloudflare account the site deploys + into — its URLs and the probes. A console or `--from bst_…` build gets + it from the workspace's Cloudflare connection (blueprint.yaml declares + `from: connection.cloudflare.workersSubdomain`); pass it with --set + only for a hand-run build. repoPrivate: type: boolean default: true diff --git a/specs/epics/README.md b/specs/epics/README.md index a532407..782a2f2 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-v1`); 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-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) | 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 b8d0e45..deadcdf 100644 --- a/specs/epics/platforms-starter-kit/IMPLEMENTATION-STATUS.md +++ b/specs/epics/platforms-starter-kit/IMPLEMENTATION-STATUS.md @@ -10,7 +10,7 @@ the code departed from `design.md` or from the upstream template. | PS2 — the KV namespace from Terraform | ✅ Shipped | [#3](https://github.com/sourceplane/platforms-starter-kit/pull/3) | | 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 | PS-6 — on `main` after `baseline-v1`, not yet tagged | +| 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` | ## Departures from the upstream template @@ -152,6 +152,45 @@ Nothing about the product changed. What changed is the baseline around it: | context pack | `operations.md`, `deployment.md` | plus `current.md`, `decisions.md`, `open-risks.md` | cirrus-baseline's shape; the three new pages are this repository's own and no module places them (the leak gate still allows exactly two) | | status | PS4 "this PR (PS-5), to be tagged `baseline-v1`"; the epic README's "Shipped as" at #4 | PS4 shipped and tagged `baseline-v1` | the tag existed; the documents had not caught up | +### The subdomain from the Cloudflare connection (PS-7) + +`subdomain` — the account's workers.dev subdomain, not a tenant's — was the +one input an operator typed that the platform could answer itself: it belongs +to the Cloudflare account the same way its id does, and it has exactly one +right answer. A typed one could only be wrong, and wrong showed up after +deploy — in the deploy's smoke (its `DEPLOYED_URL`), the phase probes and the +console's verify URLs. `blueprint.yaml` now declares +`from: connection.cloudflare.workersSubdomain`, as cirrus-baseline does since +baseline-v23: the Cloudflare integration reads the subdomain at connect and on +its hourly health check, and the bootstrap door fills the input from the +connection the build is bound to — the same one `CLOUDFLARE_ACCOUNT_ID` and the +deploy tokens mint from. The console renders no field for it, and an account +with no workers.dev subdomain is refused at the door with the fix named. + +- `testing/manifest.test.sh` takes cirrus-baseline's rule verbatim: the source + is accepted, and only when `spec.requires.integrations` lists its provider. +- `repo-blueprint.yaml` keeps the input and its default; it, `BOOTSTRAP.md` + and `docs/phases/README.md` say only a hand-run build passes + `--set subdomain`. +- Nothing a product carries changes: the rename writes the value where it + always did (`workersDevSubdomain`, the URLs), and the probes read it as + before. + +Verified: + +- `testing/{manifest,phases,coverage,rebrand,retouch,bootstrap-defer,wire}.test.sh` + green; `gen-component-docs.py --check` green (3 components). +- Mutation: with `cloudflare` dropped from `spec.requires.integrations`, + `manifest.test.sh` fails with exactly one finding, naming + `inputs[subdomain]`; restored, it passes. +- `orun new --status` (v2.58.11): `01-product` pending, 91 files. + `testing/leak.test.sh` (v2.58.11): 91 files derived; 85 shipped sources name + no factory path. `testing/placement.test.sh` (v2.78.4, as `baseline.yml` + runs it): 91 tracked files, both landings; the product's own plan applies + `cloudflare-kv` (level 0) before it deploys `web` (level 1) on stage and + prod; the 02-docs merge plans 0 jobs; `--resume` changes nothing. +- `orun task check PS-7` 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 6e1c171..829655c 100644 --- a/specs/epics/platforms-starter-kit/README.md +++ b/specs/epics/platforms-starter-kit/README.md @@ -8,7 +8,7 @@ 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) on `main`, not yet tagged. The KV apply and a live deploy are not yet proven by a live bootstrap (risk PS-K) | +| 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) | | 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` | @@ -16,7 +16,7 @@ The upstream code stays the code: the proxy, the pages, the server actions, `lib | 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 PS5 on `main`; 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-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 | ## Read order @@ -34,4 +34,4 @@ The upstream code stays the code: the proxy, the pages, the server actions, `lib | PS2 — the KV namespace from Terraform | `infra/terraform/cloudflare-kv`, the app's `dependsOn` and `secretEnv` | the root validates; the wiring keys match the template's tokens | | 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 | Baseline CI green with the docs check | +| 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 | diff --git a/specs/epics/platforms-starter-kit/epic.yaml b/specs/epics/platforms-starter-kit/epic.yaml index 2c9eb8a..cf2f0c2 100644 --- a/specs/epics/platforms-starter-kit/epic.yaml +++ b/specs/epics/platforms-starter-kit/epic.yaml @@ -46,4 +46,5 @@ spec: - "every component carries generated docs/{overview,architecture,runbook}.md, and Baseline CI fails a pull request whose manifests and pages disagree" - "ai/context carries this repository's current.md, decisions.md and open-risks.md, and none of them ships to a product" - "every milestone's status row agrees with the tags" - tasks: [PS-6] + - "the console card reads subdomain from the Cloudflare connection (from: connection.cloudflare.workersSubdomain), as cirrus-baseline since baseline-v23" + tasks: [PS-6, PS-7] diff --git a/specs/epics/platforms-starter-kit/implementation-plan.md b/specs/epics/platforms-starter-kit/implementation-plan.md index a79510e..79dae8d 100644 --- a/specs/epics/platforms-starter-kit/implementation-plan.md +++ b/specs/epics/platforms-starter-kit/implementation-plan.md @@ -88,6 +88,11 @@ product itself changing. repository's own, so no module places them. - **Status that agrees with the tags.** PS4 is shipped and tagged `baseline-v1`. +- **The subdomain from the Cloudflare connection (PS-7).** The card declares + the workers.dev `subdomain` as `from: connection.cloudflare.workersSubdomain`, + as cirrus-baseline does since baseline-v23, so the console asks for nothing + the connection already knows; `testing/manifest.test.sh` requires the + source's provider in `spec.requires.integrations`. **Done when** - nothing outside this milestone's own record names kiox (`git grep -i diff --git a/tasks/PS-7.TaskContract.yaml b/tasks/PS-7.TaskContract.yaml new file mode 100644 index 0000000..ed427d4 --- /dev/null +++ b/tasks/PS-7.TaskContract.yaml @@ -0,0 +1,25 @@ +apiVersion: orun.io/v1 +kind: TaskContract +metadata: + name: PS-7 + title: "The subdomain from the Cloudflare connection" +spec: + goal: "The console card reads the workers.dev subdomain from the workspace's Cloudflare connection (`from: connection.cloudflare.workersSubdomain`) instead of asking for it, as cirrus-baseline does since baseline-v23, and the manifest gate holds that source to a connection the card requires" + affects: + - blueprint.yaml + - repo-blueprint.yaml + - testing/manifest.test.sh + - BOOTSTRAP.md + - docs/phases/README.md + - ai/context/current.md + - ai/context/decisions.md + - specs/epics/README.md + - specs/epics/platforms-starter-kit/** + - tasks/PS-7.TaskContract.yaml + doneWhen: + - "blueprint.yaml declares `from: connection.cloudflare.workersSubdomain` on `subdomain`, so the console renders no field for it" + - testing/manifest.test.sh accepts that source only when spec.requires.integrations lists its provider, and fails naming the input when it does not (mutation-checked) + - BOOTSTRAP.md, docs/phases and repo-blueprint.yaml say only a hand-run build passes `--set subdomain` + - the contract tests, the docs check, the leak gate and the offline bootstrap are green + gates: + - checks diff --git a/testing/manifest.test.sh b/testing/manifest.test.sh index 3fd6af8..5374cb5 100755 --- a/testing/manifest.test.sh +++ b/testing/manifest.test.sh @@ -217,9 +217,20 @@ for path in manifests: # field for it (saas-bootstrap-console BC-K5). Two ways to get it # wrong, and the platform refuses both — check them here too, so the # mistake is caught in this repo rather than at a live bootstrap. + # + # A `connection..` source is read from the connection + # the build is bound to, so the provider must be one the manifest + # requires — the platform's parser refuses it otherwise. + sources_known = ("repo.name", "repo.owner", "repo.fullName", + "connection.cloudflare.workersSubdomain") src = field.get("from") - if src is not None and src not in ("repo.name", "repo.owner", "repo.fullName"): - B(f"inputs[{key}].from is {src!r} — must be repo.name, repo.owner or repo.fullName") + if src is not None and src not in sources_known: + B(f"inputs[{key}].from is {src!r} — must be one of {', '.join(sources_known)}") + if isinstance(src, str) and src.startswith("connection."): + provider = src.split(".")[1] + if provider not in ((spec.get("requires") or {}).get("integrations") or []): + B(f"inputs[{key}].from is {src!r} but spec.requires.integrations " + f"does not list {provider} — there is no connection to read it from") # ── secrets: BOTH or NEITHER, checked both ways ─────────────────────── declared = {s.get("key"): (s.get("provider"), s.get("template")) for s in (spec.get("secrets") or [])} From 2213e30940d0c5868d4f955e5cf7a6e37c893548 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 22 Oct 2026 04:00:50 +0000 Subject: [PATCH 6/6] =?UTF-8?q?PS6:=20the=20console=20asks=20for=20no=20do?= =?UTF-8?q?main=20=E2=80=94=20the=20domain=20is=20set=20later?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The site goes live on workers.dev from its first deploy, tenants at /s/, and a root domain for tenant subdomains is the owner's step after the bootstrap, so the console no longer asks for one. The logic that uses the root domain stays where it is, carrying a placeholder. - blueprint.yaml: no productdomain input - repo-blueprint.yaml: productdomain is optional, default empty - rebrand.mjs: productdomain no longer required; empty brands the reserved placeholder .example.com (RFC 2606) where the root domain goes (BASE_DOMAIN in intent.yaml; stage..example.com on stage), inlined as NEXT_PUBLIC_ROOT_DOMAIN, so setting it later is replacing one string - the product README ("Tenant subdomains": replacing the placeholder is now a step, not an option) and ai/context/operations.md say how to set it - testing/fixtures/acme.json carries no domain; placement.test.sh and e2e.test.sh read the fixture's domain and raised KeyError without one — both now expect the placeholder; rebrand.test.sh pins it (absent, stage, empty); baseline.yml's blueprint read sets no domain - records: PS6 / PS-8, tagged baseline-v3 Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01D8AmgTwmnp4M8mgmnS9aha --- .baseline/product/README.md | 24 +++--- .github/workflows/baseline.yml | 1 - BOOTSTRAP.md | 30 ++++--- README.md | 11 +-- ai/context/current.md | 7 +- ai/context/decisions.md | 1 + ai/context/operations.md | 20 ++--- blueprint.yaml | 17 ++-- docs/phases/README.md | 25 ++++-- repo-blueprint.yaml | 18 +++-- specs/epics/README.md | 2 +- .../IMPLEMENTATION-STATUS.md | 78 +++++++++++++++++++ specs/epics/platforms-starter-kit/README.md | 7 +- specs/epics/platforms-starter-kit/epic.yaml | 6 ++ .../implementation-plan.md | 9 +++ tasks/PS-8.TaskContract.yaml | 32 ++++++++ testing/e2e.test.sh | 6 +- testing/fixtures/acme.json | 11 +-- testing/placement.test.sh | 7 +- testing/rebrand.test.sh | 12 +++ tooling/rebrand/rebrand.mjs | 10 ++- 21 files changed, 257 insertions(+), 77 deletions(-) create mode 100644 tasks/PS-8.TaskContract.yaml 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";