From a2e5c0a30cd5368094c3aec1d529dabe5db5bc94 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 21 Oct 2026 12:12:16 +0000 Subject: [PATCH 1/3] feat: read the workers.dev subdomain from the Cloudflare connection MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - blueprint.yaml: the subdomain input declares from: connection.cloudflare.workersSubdomain, with the reason at the field; the card already requires [github, cloudflare, supabase] - testing/manifest.test.sh accepts the source and requires its provider in spec.requires.integrations (cirrus-baseline's block, verbatim; mutation-checked) - repo-blueprint.yaml, BOOTSTRAP.md, docs/phases/01-scaffold.md and docs/phases/README.md: a console or --from bst_… build never asks for it; only a hand-run build passes --set subdomain - saas-lumen-baseline status: dated record, with a superseded note for the console section that called the field typed Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01D8AmgTwmnp4M8mgmnS9aha --- BOOTSTRAP.md | 15 +++++++-- blueprint.yaml | 13 ++++++++ docs/phases/01-scaffold.md | 2 +- docs/phases/README.md | 5 ++- repo-blueprint.yaml | 6 +++- .../IMPLEMENTATION-STATUS.md | 31 +++++++++++++++++++ testing/manifest.test.sh | 15 +++++++-- 7 files changed, 79 insertions(+), 8 deletions(-) diff --git a/BOOTSTRAP.md b/BOOTSTRAP.md index 876836e1..e2d9852a 100644 --- a/BOOTSTRAP.md +++ b/BOOTSTRAP.md @@ -94,6 +94,12 @@ it, so a wrong value ships a product that deploys cleanly and is unreachable at every address it advertises. Find it under Workers & Pages in the dashboard. +A build started from the console, or with `orun baseline new --from bst_…`, +never asks for it: the platform reads the workers.dev subdomain of the +Cloudflare account you deploy into 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 repo is created, nothing is landed, no convergence is watched, and no phase probes @@ -255,8 +261,11 @@ tag, which is why it carries none. What that means for a console build: - `reponame` and `githuborg` come from the repository the operator picked; - `apibaseurl` is derived (`https://api.{productdomain}`); only - `productname`, `productdomain` and `subdomain` are typed. + `apibaseurl` is derived (`https://api.{productdomain}`); `subdomain` is + read from the workspace's Cloudflare connection (`from: + connection.cloudflare.workersSubdomain`), the one the deploy tokens mint + from, and an account with no workers.dev subdomain is refused before + anything is created. Only `productname` and `productdomain` are typed. - `orunWorkspace` is not on the form — it cannot be. The build runs inside the workspace, and `from: workspace` (orun ≥ v2.58.11) fills it from there. - The card collects no `domain`, so a console build skips `07-domain`. Run @@ -343,7 +352,7 @@ purpose, written down so they read as instructions rather than breakage. | api-edge deploy: `Service binding '_WORKER' … not found` | A fleet worker never deployed in phase 04. Resume that convergence, then re-run `05-edge`. | | Convergence run fails, lanes look transient | `orun.run/watch@v1` already resumes it up to 3× (`gh run rerun --failed` is a true resume: exec-id + `--retry`). | | Convergence still red after the resume budget | Re-running the phase lands nothing new, and CI plans `--changed`, so nothing redeploys what the failed run left undeployed. Resume the run itself — `gh run rerun --failed ` — then re-run the phase so its `await` hooks verify. | -| `/health` probes fail against a green deploy | Check `subdomain` first: it must be the Cloudflare account's workers.dev subdomain, and the default is a placeholder. | +| `/health` probes fail against a green deploy | Check `subdomain` first: it must be the Cloudflare account's workers.dev subdomain. A console build reads it from the Cloudflare connection; on a hand-run build the default is a placeholder. | | CLI login dies with 429 `rate_limited` | Fixed ≥ v2.48.1 (redeem honours Retry-After). Upgrade the CLI. | | `unknown flag: --phase`, `cannot unmarshal !!map into []scaffold.Hook`, or an action `has no parameter "githubOwner"` / `"sha"` | The CLI is below the v2.58.11 floor. This blueprint is not readable by an older one. | | A fresh build stops before 01-scaffold: `✕ phase "04-workers" precondition "wiring" is not met: … project "" not found` | The CLI is below v2.58.10, which asks the preflight about the product's project before phase 01 has created it and calls the answer a failure. Upgrade; the probe is then deferred to phase 04. | diff --git a/blueprint.yaml b/blueprint.yaml index 69d1b598..97c78036 100644 --- a/blueprint.yaml +++ b/blueprint.yaml @@ -106,6 +106,19 @@ spec: pattern: "^[a-z0-9][a-z0-9-]{0,62}$" help: The workers.dev subdomain on the Cloudflare account this builds into. example: acme + # READ FROM THE CLOUDFLARE CONNECTION, not asked. The subdomain 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 CORS, OAuth origins, smoke checks 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. + # + # No probe and no orun action is needed, because the platform already + # holds the fact. 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 `integrations/reconcile` hooks # mint these, brokered, during phase 03. ──────────────────────────────── diff --git a/docs/phases/01-scaffold.md b/docs/phases/01-scaffold.md index 13d62ad6..6b1e4561 100644 --- a/docs/phases/01-scaffold.md +++ b/docs/phases/01-scaffold.md @@ -47,7 +47,7 @@ gates the set, so the promise is a test rather than a claim. | `productdomain` | `acme.dev` | REQUIRED. Product domain | | `githuborg` | `sourceplane` | REQUIRED. The org or user the repo is created under | | `orunWorkspace` | `ws_ABCD1234` | workspace id. Unset, the workspace the build runs in (ORUN_WORKSPACE); with none anywhere, the placeholder `ws_SET_ME` | -| `subdomain` | `rahulvarghesepullely` | the Cloudflare account's workers.dev subdomain — every URL derives from it (worker names are brand-prefixed, so keeping the baseline's account is supported) | +| `subdomain` | `rahulvarghesepullely` | workers.dev subdomain of the Cloudflare account you deploy into — every URL derives from it (worker names are brand-prefixed, so keeping the baseline's account is supported). A console or `--from bst_…` build reads it from the Cloudflare connection; pass it only for a hand-run build | | `apibaseurl` | `https://api.acme.dev` | CLI default API base; empty derives from `productdomain` | | `repoPrivate` | `true` (default) | visibility at creation only | | `epicSlug` | `infra-baselining` (default) | the epic every phase files its task under | diff --git a/docs/phases/README.md b/docs/phases/README.md index 421d17ec..80811ea7 100644 --- a/docs/phases/README.md +++ b/docs/phases/README.md @@ -76,7 +76,7 @@ same words. | `productname` | yes | display name | | `productdomain` | yes | the apex domain the product answers on; it does not need to exist yet | | `githuborg` | yes | the org or user the repo lives under. The console fills it from the chosen repository's owner | -| `subdomain` | — | the Cloudflare **account's** workers.dev subdomain. The default is a placeholder; see below | +| `subdomain` | — | workers.dev subdomain of the Cloudflare **account** you deploy into. A console or `--from bst_…` build reads it from the Cloudflare connection; pass it only for a hand-run build, where the default is a placeholder; see below | | `apibaseurl` | — | the CLI/SDK default API base; empty means `https://api.` | | `orunWorkspace` | — | workspace id. Unset, it is the workspace the build runs in (`from: workspace`, ORUN_WORKSPACE, which a console build always has); with none anywhere, 01 writes the placeholder `ws_SET_ME`, which fails loudly rather than silently cross-tenanting | | `epicSlug` | — | default `infra-baselining`; the epic every phase files its task under, found by slug so a fresh run and a resumed run find the same work | @@ -89,6 +89,9 @@ api-edge CORS allowlist derive from it, so a wrong value ships a product that deploys cleanly and is unreachable at every address it advertises — and the `/health` probes of 05, 06 and 08 fail against hosts that were never going to exist. Find it under Workers & Pages in the Cloudflare dashboard. +A console or `orun baseline new --from bst_…` build never asks for it: the +platform reads it from the workspace's Cloudflare connection, the same one +the deploy tokens mint from, so only a hand-run build can get it wrong. `01-scaffold` writes the answers into the product as `.rebrand/values.json`, which is committed. Every later phase's rebrand hook diff --git a/repo-blueprint.yaml b/repo-blueprint.yaml index 1d7d9d8d..84d9394d 100644 --- a/repo-blueprint.yaml +++ b/repo-blueprint.yaml @@ -60,7 +60,11 @@ inputs: subdomain: type: string default: "your-workers-subdomain" - description: workers.dev subdomain for app-config seams. + description: >- + workers.dev subdomain for app-config seams. 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. salesEmail: type: string default: "" diff --git a/specs/epics/saas-lumen-baseline/IMPLEMENTATION-STATUS.md b/specs/epics/saas-lumen-baseline/IMPLEMENTATION-STATUS.md index ed2983d4..6d22c3a8 100644 --- a/specs/epics/saas-lumen-baseline/IMPLEMENTATION-STATUS.md +++ b/specs/epics/saas-lumen-baseline/IMPLEMENTATION-STATUS.md @@ -142,3 +142,34 @@ exists, because the registry pins a tag and never a branch. `expectedMinutes: 75` in the registry and catalog is Lumen's measured figure, labelled as inherited in both places (risk R5), and is replaced by this baseline's own first instantiation. + +## The workers.dev subdomain, read from the Cloudflare connection (2026-10-21, `baseline-v4`) + +`subdomain` was the one input a console build still asked for that the +platform could answer. It belongs to the Cloudflare account the same way the +account id does and has exactly one right answer, so a typed value could only +be wrong — and wrong surfaced only after deploy, in CORS, OAuth origins, the +smoke checks and the verify URLs. As cirrus-baseline did in `baseline-v23`: + +- `blueprint.yaml` declares `from: connection.cloudflare.workersSubdomain`. + The Cloudflare integration reads the subdomain from the account at connect + and on its hourly health check; 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 — and refuses an account with no workers.dev + subdomain before anything is created. The console renders no field for it. +- `testing/manifest.test.sh` accepts the new source and requires its provider + in `spec.requires.integrations` (the card lists `cloudflare`). +- `repo-blueprint.yaml`, `BOOTSTRAP.md`, `docs/phases/01-scaffold.md` and + `docs/phases/README.md` say a hand-run build still passes `--set subdomain`. + +> **Superseded (2026-10-21).** This page never recorded `subdomain` as typed, +> but `BOOTSTRAP.md`'s console section did ("only `productname`, +> `productdomain` and `subdomain` are typed"). It is read from the connection +> now; no probe and no orun action was needed, because the platform already +> held the fact. + +Verified: the manifest, phases, coverage and rebrand contract tests pass; a +**mutation check** — `cloudflare` deleted from the card's +`spec.requires.integrations` — fails `manifest.test.sh` (exit 1) naming +`inputs[subdomain].from`, and passes again once restored; leak and placement +(orun 2.58.11, the CI pin) pass with 1083 files, unchanged. diff --git a/testing/manifest.test.sh b/testing/manifest.test.sh index cf6dcd27..2d685250 100755 --- a/testing/manifest.test.sh +++ b/testing/manifest.test.sh @@ -218,9 +218,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 fba3ad1be6b0dc3de8aed18df78fa3e5497e4a4c Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 21 Oct 2026 12:17:07 +0000 Subject: [PATCH 2/3] =?UTF-8?q?feat:=20remove=20the=20domain=20input=20?= =?UTF-8?q?=E2=80=94=20the=20custom-domain=20component=20lands=20in=2006-c?= =?UTF-8?q?onsole,=20parked?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - repo-blueprint.yaml: the `domain` input, its .rebrand/values.json key and the 07-domain phase are gone; cloudflare-domain joins 06-console (it ships parked: subscribe.environments: []) - blueprint.yaml: the programme drops the conditional 07-domain milestone (nine phases, seven milestones) - tasks/07-domain.TaskContract.yaml and docs/phases/07-domain.md deleted; what is still true is a section of docs/phases/06-console.md and a row in ai/context/operations.md; 06-console's contract says why `affects` leaves the parked component out - tests: phases.test.sh records 07-domain as folded into 06-console; leak/placement no longer force `domain` on (1083 files placed, as before); the phased sequence places 08-docs after the rebrand - tests/fixtures/acme.json drops "domain": false - docs and records: BOOTSTRAP.md, docs/phases/*, a "Since then" note on the epic's phase table, and a dated status section Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01D8AmgTwmnp4M8mgmnS9aha --- BOOTSTRAP.md | 28 ++-- ai/context/operations.md | 10 +- blueprint.yaml | 12 +- docs/phases/01-scaffold.md | 1 - docs/phases/06-console.md | 46 ++++++- docs/phases/07-domain.md | 120 ------------------ docs/phases/08-docs.md | 8 +- docs/phases/README.md | 29 ++--- docs/phases/TIMINGS.md | 6 +- repo-blueprint.yaml | 98 ++------------ .../IMPLEMENTATION-STATUS.md | 54 ++++++++ specs/epics/saas-lumen-baseline/design.md | 6 + tasks/06-console.TaskContract.yaml | 2 + tasks/07-domain.TaskContract.yaml | 14 -- testing/leak.test.sh | 4 +- testing/manifest.test.sh | 9 +- testing/phases.test.sh | 16 ++- testing/placement.test.sh | 11 +- tests/fixtures/acme.json | 3 +- 19 files changed, 190 insertions(+), 287 deletions(-) delete mode 100644 docs/phases/07-domain.md delete mode 100644 tasks/07-domain.TaskContract.yaml diff --git a/BOOTSTRAP.md b/BOOTSTRAP.md index e2d9852a..ebb3436e 100644 --- a/BOOTSTRAP.md +++ b/BOOTSTRAP.md @@ -117,8 +117,10 @@ every phase after `01-scaffold` brands the tree — derives as `drifted`, and The phases are `01-scaffold`, `02-foundation`, `03-infrastructure`, `03-infrastructure-database`, `04-workers`, `04-workers-restore`, `05-edge`, -`06-console`, `07-domain` (only when `domain=true`), `08-docs` — ten phases -filed under eight milestones. Each is idempotent, each follows one contract — +`06-console`, `08-docs` — nine phases filed under seven milestones. The gap +at 07 is the optional `07-domain` phase that used to land the custom-domain +component behind a `domain` input; that component lands in `06-console` now, +parked, and the input is gone. Each is idempotent, each follows one contract — **place its modules → land them as a PR that must go green → watch the convergence → verify the outcome** — and each carries its own narration. Full guide: [docs/phases/README.md](docs/phases/README.md), with a page per @@ -138,8 +140,7 @@ orun new --blueprint repo-blueprint.yaml --out ~/sourceplane/acme --run-hooks \ orun new --blueprint repo-blueprint.yaml --out ~/sourceplane/acme --run-hooks \ --phase 02-foundation --values ~/sourceplane/acme/.rebrand/values.json # … 03-infrastructure, 03-infrastructure-database, 04-workers, -# 04-workers-restore, 05-edge, 06-console, 08-docs; -# 07-domain only with --set domain=true. +# 04-workers-restore, 05-edge, 06-console, 08-docs. ``` The flags that shape a run: @@ -253,7 +254,7 @@ The console renders **`blueprint.yaml`**, the card, and never this file or the blueprint directly. The card owns the build contract: the overview, the three integrations and the admin key role it requires, the inputs the form collects, a read-only preview of the five brokered secrets and of the -programme (the epic and its eight milestones), and `bootstrap.blueprint: +programme (the epic and its seven milestones), and `bootstrap.blueprint: repo-blueprint.yaml` — the document a runner places. The registry row in orun-cloud owns identity and the pinned tag; the card is fetched *at* that tag, which is why it carries none. @@ -268,8 +269,8 @@ What that means for a console build: anything is created. Only `productname` and `productdomain` are typed. - `orunWorkspace` is not on the form — it cannot be. The build runs inside the workspace, and `from: workspace` (orun ≥ v2.58.11) fills it from there. -- The card collects no `domain`, so a console build skips `07-domain`. Run - it later from the CLI (and read its page first). +- The custom-domain component lands in `06-console`, parked, on every + build; there is no `domain` switch to collect. - The runner hands its refreshed token over through `ORUN_TOKEN_FILE` (`bootstrap.tokenChannel`), so a session that rotates mid-build does not end it. @@ -282,11 +283,14 @@ that mint them, and its programme and inputs to the blueprint's. - **Deployment record**: `08-docs` is the close-out, and safe to re-run any time as a live-state refresh. -- **Custom domain**: `07-domain` needs the product zone to exist in - Cloudflare, and in this baseline the `cloudflare-domain` component ships - parked and mid-migration to provider v5, so the phase lands it without - deploying anything. See [docs/phases/07-domain.md](docs/phases/07-domain.md) - before running it. +- **Custom domain**: the `cloudflare-domain` component is already in the + product, landed by `06-console` and parked (it subscribes to no + environment, and it is mid-migration to provider v5). Create the product + zone in Cloudflare, restore the component's commented-out `subscribe` + block and finish that migration in an ordinary PR (see + [docs/phases/06-console.md](docs/phases/06-console.md#the-custom-domain--parked)), + and re-run `--phase 08-docs` once it converges so the docs pick up the + domain URLs. - **Runtime secrets** (OAuth client secrets, billing keys, …): seed with `orun secrets set --org --env `; the next deploy pushes them to the workers (`wire-now-seed-later` — nothing blocks on them). diff --git a/ai/context/operations.md b/ai/context/operations.md index 95a210b6..adc60ca0 100644 --- a/ai/context/operations.md +++ b/ai/context/operations.md @@ -113,11 +113,11 @@ orun integrations list --org --json && orun cloud check --org | add a runtime secret | `orun secrets set --org --env ` | | resolve workspace identity | `orun workspace ` | | check integrations | `orun integrations list --org --json` | -| custom domain | run the `07-domain` phase once the zone exists, then `08-docs` | +| custom domain | `infra/terraform/cloudflare-domain` ships parked (`subscribe.environments: []`). Once the zone exists in the Cloudflare account, restore the `subscribe` block its `component.yaml` carries commented out (and finish the provider-v5 re-import its comment names), merge, then run the `08-docs` phase | | headless/CI credentials | `ORUN_TOKEN` (workspace-scoped) + `GITHUB_TOKEN` | -The ops phases (docs refresh, custom domain, and the original deployment -sequence) all live in ONE versioned artifact: `repo-blueprint.yaml` in the +The ops phases (docs refresh and the original deployment sequence) all live +in ONE versioned artifact: `repo-blueprint.yaml` in the baseline this product was born from. Clone it at a tag and select the phase — from anywhere, with the two tokens above exported: @@ -126,10 +126,6 @@ git clone --depth 1 https://github.com/OPSFLOWS baseline && cd baseline orun new --blueprint repo-blueprint.yaml --out \ --run-hooks --phase 08-docs --values # docs refresh - -orun new --blueprint repo-blueprint.yaml --out \ - --run-hooks --phase 07-domain --set domain=true \ - --values # custom domain ``` `` carries this product's identity — at minimum `reponame`, diff --git a/blueprint.yaml b/blueprint.yaml index 97c78036..c1f6b3f5 100644 --- a/blueprint.yaml +++ b/blueprint.yaml @@ -157,7 +157,7 @@ spec: # these. Idempotent by identity — epic by slug, milestone by name-within-epic # — so a re-run finds what it made before. The console renders the programme # so an operator can see the shape of the work before pressing Build. - # Ten phases, eight milestones: `03-infrastructure-database` and + # Nine phases, seven milestones: `03-infrastructure-database` and # `04-workers-restore` are second landings of 03 and 04, and file under them. # New with the blueprint: the flows this replaced opened no milestones (there # was no track.sh here), so this card used to declare no programme at all. @@ -170,13 +170,11 @@ spec: - name: 03-infrastructure - name: 04-workers - name: 05-edge + # The custom-domain component lands in 06-console, parked (it + # subscribes to no environment until an owner wires a zone), so the + # optional 07-domain milestone and the `domain` input that switched it + # on are gone. The numbering keeps its gaps so 08 keeps its name. - name: 06-console - # 07-domain carries `when: inputs.domain` in repo-blueprint.yaml (it - # needs the Cloudflare zone to already exist), so its milestone is - # ensured only on a run that asks for it. Declared with its condition - # rather than silently listed, so the console can say so. - - name: 07-domain - when: domain - name: 08-docs bootstrap: diff --git a/docs/phases/01-scaffold.md b/docs/phases/01-scaffold.md index 6b1e4561..341973df 100644 --- a/docs/phases/01-scaffold.md +++ b/docs/phases/01-scaffold.md @@ -51,7 +51,6 @@ gates the set, so the promise is a test rather than a claim. | `apibaseurl` | `https://api.acme.dev` | CLI default API base; empty derives from `productdomain` | | `repoPrivate` | `true` (default) | visibility at creation only | | `epicSlug` | `infra-baselining` (default) | the epic every phase files its task under | -| `domain` | `false` (default) | `true` also runs `07-domain` | The full set, rebrand overrides included, is in the [phases README](README.md#inputs) and `repo-blueprint.yaml`'s `inputs:` diff --git a/docs/phases/06-console.md b/docs/phases/06-console.md index e561982b..1b999190 100644 --- a/docs/phases/06-console.md +++ b/docs/phases/06-console.md @@ -2,7 +2,7 @@ Lands the **web console** (`repo-blueprint.yaml`, phase `06-console`) — the product UI served from Workers static assets — and proves both it and the -edge it talks to live. +edge it talks to live. The custom-domain component lands with it, parked. ## What it lands @@ -12,6 +12,45 @@ phase 05 edge. Console builds are the heaviest lane in the product, which is why this phase's landing waits up to 45 minutes for its PR and its convergence watch up to 45 minutes too. +`infra/terraform/cloudflare-domain` lands in the same PR and deploys nothing +(below). + +## The custom domain — parked + +`infra/terraform/cloudflare-domain` (the zone lookup and, once wired, a +custom domain per environment for the console worker — +`CONSOLE_CUSTOM_DOMAIN` in the product's `intent.yaml`, `stage.` +and `prod.` after rebrand, empty for `dev`) lands with the +console and **deploys nothing**: its `component.yaml` declares +`subscribe.environments: []`, so CI plans no lanes for it. The product runs +on workers.dev URLs until an owner wires it. + +It used to land on its own as the optional `07-domain` phase, behind a +`domain` input. That landing deployed nothing either — its convergence was a +green run with nothing in it — so the phase and the switch are gone, and the +task contract's `affects` leaves the component out: there is nothing in it to +re-plan. + +Wiring it is a normal pull request in the product, once the zone exists: + +1. **The zone first.** The product zone (e.g. `acme.dev`) must already exist + in the Cloudflare account the product deploys into, created in the + dashboard; zone creation is an account-plan operation the platform does + not broker. The component runs with `zoneMode: existing`: it looks the + zone up by `baseDomain` and manages records and custom domains IN it, not + the zone itself — without it the plan fails with `no zone found` (or the + brokered token's account is not the zone's). +2. **Restore the `subscribe` block** the component carries commented out, + and finish the provider-v5 re-import its comment names: the v4 + custom-domain resource was dropped from state and its block is commented + out until the v5 `cloudflare_workers_custom_domain` replaces it (the + component's `README.md` says where that migration stands). Un-parked as it + stands, the root would look up the zone and attach nothing. +3. **Land it.** The convergence on `main` applies it; check the product + resolves on its own domain (DNS propagation applies), then re-run + [`08-docs`](08-docs.md) so the deployment manifest records the + custom-domain URLs. + ## Inputs `--out` is the product repo. The blueprint's required inputs — `reponame`, @@ -79,9 +118,8 @@ nothing new, and the `await` hooks re-probe. ## Next -[Phase 08 — docs](08-docs.md) records what was built. Optional -[phase 07 — domain](07-domain.md) comes first only if you set -`domain=true` — read that page before you do. +[Phase 08 — docs](08-docs.md) records what was built. The custom domain +is wired later, in an ordinary PR ([above](#the-custom-domain--parked)). Post-baseline: seed runtime worker secrets (`orun secrets set --org --env `; wire-now-seed-later, nothing blocks on them) and ship diff --git a/docs/phases/07-domain.md b/docs/phases/07-domain.md deleted file mode 100644 index f93d996c..00000000 --- a/docs/phases/07-domain.md +++ /dev/null @@ -1,120 +0,0 @@ -# Phase 07 — domain (OPTIONAL, and not yet wired end to end) - -Lands the **custom product domain** (`repo-blueprint.yaml`, phase -`07-domain`): the `cloudflare-domain` terraform that is meant to put the -console on `` instead of workers.dev. - -Skip it until you own the domain — the baseline is fully functional on -workers.dev URLs after phase 06. And read the next section before you run it -at all. - -## What this phase does today — read this first - -In this baseline, running `07-domain` lands the component and **deploys -nothing**, for two reasons that live in the component rather than in the -phase: - -1. **`cloudflare-domain` ships parked.** Its `component.yaml` declares - `subscribe.environments: []`, so CI plans no lanes for it. The phase's - convergence is therefore a run with nothing in it, and reads green. This - is the "a green run that deployed nothing" trap every other phase guards - against with a probe; this phase has no probe to catch it. -2. **The custom-domain attachment is fenced off.** The component is midway - through a two-step migration to Cloudflare provider v5: the v4 - `cloudflare_workers_domain` resource was dropped from state and its - block is commented out until the v5 `cloudflare_workers_custom_domain` - replaces it. Un-parked as it stands, the root would look up the zone and - attach nothing. - -So the honest status is: the phase, its task and its PR work; the domain -does not. Wiring it for real means, in the product, finishing the v5 -resource and restoring the `subscribe` block (both are described in the -component's own comments), then landing that as a normal PR once the zone -exists. The phase's narration says as much when it is done: the component -is in the repository, and nothing is attached until it subscribes. - -## Prerequisite (hard) - -The product zone (e.g. `acme.dev`) must **already exist in the Cloudflare -account** — created in the dashboard; zone creation is an account-plan -operation the platform does not broker. The component runs with -`zoneMode: existing`: it looks the zone up by `baseDomain` and manages -records and custom domains IN it, not the zone itself. Without the zone a -plan fails with `no zone found`. - -## What it lands - -`infra/terraform/cloudflare-domain`: the zone lookup and, once the migration -above is finished, a custom domain per environment for the console worker — -`CONSOLE_CUSTOM_DOMAIN` in the product's `intent.yaml`, -`stage.` and `prod.` after rebrand (empty for -`dev`). - -## Inputs - -`--out` is the product repo. The blueprint's required inputs — `reponame`, -`productname`, `productdomain`, `githuborg` — are validated before any phase -runs, so pass them on every invocation; the product's own -`.rebrand/values.json` is a complete values file. See -[the phases README](README.md#inputs). - -The phase carries `when: inputs.domain`, so it is **skipped** unless -`domain=true` — set on the command line or recorded in the values file. A -skipped phase does not block `08-docs`, which requires `06-console` rather -than this one. The console card collects no `domain`, so a console build -always skips this phase. - -## Steps - -1. **requires** — `06-console` placed. -2. **pre** — the phase's task (its milestone is ensured only on a run that - asks for the phase). -3. **place** → **brand** → **lockfile** → **land** — the standard contract - (PR `phase(07-domain): custom domain`). -4. **converge** — `orun.run/watch@v1` on the merged commit. See above for - what that run contains today. - -## Verify / done means - -The convergence run is green. Then — once the component is wired — check the -product resolves on its own domain (DNS propagation applies), and re-run -[phase 08](08-docs.md) so the deployment manifest records the custom-domain -URLs. - -## Troubleshooting - -- **Plan fails: zone not found** — the zone does not exist in this - Cloudflare account yet, or the brokered token's account differs from the - zone's account. Create the zone, re-run. -- **Green convergence, domain does not resolve** — expected today; see - "What this phase does today". - -## Example commands - -From the baseline checkout: - -```bash -orun new --blueprint repo-blueprint.yaml --out $HOME/sourceplane/acme \ - --run-hooks --phase 07-domain --set domain=true \ - --values $HOME/sourceplane/acme/.rebrand/values.json -``` - -Headless (fresh container / no checkout — see BOOTSTRAP.md §2): clone the -baseline at a tag and run the same command, with `ORUN_TOKEN` + -`GITHUB_TOKEN` exported: - -```bash -export ORUN_TOKEN="$(orun auth token | tail -1)" GITHUB_TOKEN=… -git clone --depth 1 --branch https://github.com/sourceplane/multi-tenant-saas -cd multi-tenant-saas -orun new --blueprint repo-blueprint.yaml --out /work/acme \ - --run-hooks --phase 07-domain --set domain=true --values /work/acme.values.yaml -``` - -Preview with zero side effects: drop `--run-hooks` — the phase places files -and stops, with no landing, no convergence watch and no probe. `--status` -derives every phase's state and writes nothing at all. - -## Next - -[Phase 08 — docs](08-docs.md). diff --git a/docs/phases/08-docs.md b/docs/phases/08-docs.md index 87a89a9f..a69bfaae 100644 --- a/docs/phases/08-docs.md +++ b/docs/phases/08-docs.md @@ -25,8 +25,7 @@ this credential" rather than a failed render. ## Steps -1. **requires** — `06-console` placed. Not `07-domain`, so a bootstrap that - skips the custom domain still reaches this phase. +1. **requires** — `06-console` placed. 2. **pre** — the phase's task. 3. **render** — a `post` hook runs `hooks/render-deployment-docs.sh . ` from the baseline checkout. It reads identity from @@ -46,8 +45,9 @@ this credential" rather than a failed render. - Right after [phase 06](06-console.md) — the "working baseline" moment — to record it. -- Again after [phase 07](07-domain.md), once the domain actually resolves, - so the manifest picks up the custom-domain URLs. +- Again once an owner has wired the custom domain (see + [06-console](06-console.md#the-custom-domain--parked)) and it actually + resolves, so the manifest picks up the custom-domain URLs. - Any time later as a **live-state refresh**: the manifest is regenerated from scratch on every run and carries its own render timestamp. The product's `ai/context/operations.md` carries the same command for its own diff --git a/docs/phases/README.md b/docs/phases/README.md index 80811ea7..b08e9b6c 100644 --- a/docs/phases/README.md +++ b/docs/phases/README.md @@ -1,6 +1,6 @@ -# The phases — one blueprint, ten selections +# The phases — one blueprint, nine selections -`repo-blueprint.yaml` declares ten phases that take a product from +`repo-blueprint.yaml` declares nine phases that take a product from **nothing** to a **live, documented baseline** on Cloudflare and Supabase. Run them one at a time at your own pace with `--phase `, or run the whole sequence unattended with `--resume`. There is no wrapper that runs @@ -41,17 +41,21 @@ deploying is what a merge does and a PR cannot. | [`04-workers`](04-workers.md) | 04-workers | the 12-worker fleet, two feedback bindings stripped | convergence green | | [`04-workers-restore`](04-workers.md#the-second-landing-04-workers-restore) | 04-workers | the two bindings put back (places no files) | convergence green | | [`05-edge`](05-edge.md) | 05-edge | `api-edge` (+ its tests) | `/health` answers on stage and prod | -| [`06-console`](06-console.md) | 06-console | web console | console + edge live on stage and prod | -| [`07-domain`](07-domain.md) | 07-domain | custom domain (OPTIONAL — `when: inputs.domain`) | convergence green | +| [`06-console`](06-console.md) | 06-console | web console, and the custom-domain component (parked until a zone is wired) | console + edge live on stage and prod | | [`08-docs`](08-docs.md) | 08-docs | live-deployment docs (places no files; a hook renders them) | the URLs the manifest claims, re-probed | -Ten phases, eight milestones. `03-infrastructure-database` and +Nine phases, seven milestones. `03-infrastructure-database` and `04-workers-restore` are second landings of the unit before them: each has its own PR and its own task, and each files under its predecessor's milestone. They are documented on their predecessor's page for the same -reason. +reason. The numbering keeps a gap at 07: the custom-domain component that +was the optional `07-domain` phase, behind a `domain` input, lands in +`06-console`, parked, and an owner wires it later in an ordinary PR (see +[06-console](06-console.md#the-custom-domain--parked)). Its own landing +deployed nothing, so the phase and the switch are gone; `08-docs` keeps its +name. -Two requirements look odd and are deliberate: +One requirement looks odd and is deliberate: - **`05-edge` requires `04-workers`, not `04-workers-restore`.** A phase that places no files derives as `unknown` — the product repo cannot be @@ -61,8 +65,6 @@ Two requirements look odd and are deliberate: that catches a phase run against a tree where its predecessor never happened. `testing/phases.test.sh` refuses a requirement on a hook-only phase. -- **`08-docs` requires `06-console`, not `07-domain`**, so a bootstrap that - skips the custom domain still reaches it. ## Inputs @@ -81,7 +83,6 @@ same words. | `orunWorkspace` | — | workspace id. Unset, it is the workspace the build runs in (`from: workspace`, ORUN_WORKSPACE, which a console build always has); with none anywhere, 01 writes the placeholder `ws_SET_ME`, which fails loudly rather than silently cross-tenanting | | `epicSlug` | — | default `infra-baselining`; the epic every phase files its task under, found by slug so a fresh run and a resumed run find the same work | | `repoPrivate` | — | default `true`; applied only when `01-scaffold` creates the repo — an existing repo keeps its visibility | -| `domain` | — | default `false`; `true` runs `07-domain` (read that page first) | | `pascalName`, `brandSlug`, `cliBin`, `salesEmail` | — | rebrand overrides. Empty, the first three derive from the names above (`brandSlug`, the worker prefix, from `reponame`); an empty `salesEmail` keeps the baseline mailbox | **`subdomain` is not the product name.** Every generated URL and the @@ -95,7 +96,7 @@ the deploy tokens mint from, so only a hand-run build can get it wrong. `01-scaffold` writes the answers into the product as `.rebrand/values.json`, which is committed. Every later phase's rebrand hook -reads it, and it carries `githuborg`, `epicSlug` and `domain` too, so a phase +reads it, and it carries `githuborg` and `epicSlug` too, so a phase run months later in a fresh container can recover what the operator answered (orun's own record, `.orun/provenance.lock`, is gitignored and does not survive a container). The blueprint's **required** inputs are still @@ -174,8 +175,7 @@ Why it can run unattended: reverting your product's identity to the baseline's. Re-place one deliberately with `--phase `. - `04-workers-restore` and `08-docs` place no files, so they derive as - `unknown`; `07-domain` derives as `skipped` unless `domain=true`. - `--status` prints all of this without writing anything. + `unknown`. `--status` prints all of this without writing anything. - **Git-level idempotence is not deploy-level idempotence.** The product's CI plans `--changed`: a component deploys only when its files changed in the push. If a convergence is still red after the watch has spent its @@ -275,8 +275,7 @@ never product content. The whole design: `specs/epics/saas-baseline-tracking/`. The console previews the same programme from `blueprint.yaml`'s -`programme:` block — the epic and its eight milestones, with `07-domain` -marked conditional. +`programme:` block — the epic and its seven milestones. ## Why there is one document diff --git a/docs/phases/TIMINGS.md b/docs/phases/TIMINGS.md index 7bac0327..9424ff70 100644 --- a/docs/phases/TIMINGS.md +++ b/docs/phases/TIMINGS.md @@ -47,13 +47,12 @@ quotes to an operator ("About N minutes"). | `04-workers-restore` | 5 | **estimate** | — as its own phase; its convergence was the 10m54s inside vela's 31m | billing + membership redeploy | | `05-edge` | 5 | measured | 5m22s vela; 5m03s ambient | land → converge → `/health` probes | | `06-console` | 16 | measured | 15m37s vela (all 3 resumes, self-healed); 14m01s ambient (0 resumes) | console builds are heavy | -| `07-domain` | 5 | **estimate, never run** | — | today its convergence plans nothing ([07-domain.md](07-domain.md)) | | `08-docs` | 1 | **estimate** | — (neither run's table records it) | probe + render + land | | tracking (BT) | seconds per landing | **estimate** | — | one task lookup and at most two creates per landing, plus the epic once | **Totals.** Measured: ~73m for 01–06 on vela, ~60m for 02–06 on ambient. The card (`blueprint.yaml`) promises ~60–75 minutes and budgets 75. The -per-phase numbers above sum to 84 without `07-domain` — they overstate, +per-phase numbers above sum to 84 — they overstate, because `04-workers`' 31 is vela's figure for the old phase 04, which already contained the restore landing that `04-workers-restore` budgets again. Budget **60–75 minutes**, and treat the 04 pair as ~20–31 between them. @@ -88,7 +87,8 @@ unchanged is a document nobody checked. over `ORUN_TOKEN`. 5. **A convergence that follows a commit touching NO components** plans zero lanes and reads "green". The phase's verify hook is the real gate; never - trust a green run without one. (`07-domain` is exactly this case today.) + trust a green run without one. (`07-domain`, whose one component ships + parked, was exactly this case until it was folded into `06-console`.) ## Defect log from the measured runs diff --git a/repo-blueprint.yaml b/repo-blueprint.yaml index 84d9394d..cb4209b4 100644 --- a/repo-blueprint.yaml +++ b/repo-blueprint.yaml @@ -95,7 +95,8 @@ inputs: id is a valid ref segment (the resolve accepts a slug, a public id or a ws_ ref). It falls back to the repo name only when neither is set. # ── The facts the phases below need and the flows used to hold. They were - # workflow inputs (`githuborg`, `epicslug`, `domain` on the flows' per-phase + # workflow inputs (`githuborg`, `epicslug` — and `domain`, gone since the + # custom-domain component lands in 06-console — on the flows' per-phase # workflow.yaml), which made them invisible to anything reading this file — # including the console that has to render a form. githuborg: @@ -121,14 +122,6 @@ inputs: cannot be un-made retroactively for anything already pushed. `orun.repo/ensure@v1` only sets this at creation: an existing repository keeps whatever visibility it already has. - domain: - type: boolean - default: false - description: >- - Whether to wire the product's custom domain (phase 07). It needs the - Cloudflare zone to already exist, so it is off unless asked for — the - condition the umbrella carried as a shell `[ = "true" ]` test and phase - 07 now carries as its own `when:`. # ── SOURCES ─────────────────────────────────────────────────────────────── # The baseline is this repo itself. Run `orun new` from this repo's root so @@ -642,7 +635,7 @@ modules: # records the non-secret inputs in .orun/provenance.lock, but `.orun/` is # gitignored in the product, so it has never survived a container — this # file is committed, which is why every input a later phase needs must - # appear here. githuborg/epicSlug/domain are here for exactly that: a + # appear here. githuborg/epicSlug are here for exactly that: a # phase run months later in a fresh container reads them back. - name: rebrand-values mode: template @@ -661,8 +654,7 @@ modules: "orunWorkspace": "{{ .orunWorkspace }}",{{ if .orunWorkspaceSlug }} "orunWorkspaceSlug": "{{ .orunWorkspaceSlug }}",{{ end }} "githuborg": "{{ .githuborg }}", - "epicSlug": "{{ .epicSlug }}", - "domain": {{ if .domain }}true{{ else }}false{{ end }} + "epicSlug": "{{ .epicSlug }}" } # ── PHASES ──────────────────────────────────────────────────────────────── @@ -1405,6 +1397,14 @@ phases: - "https://{{ .inputs.reponame }}-api-edge-stage.{{ .inputs.subdomain }}.workers.dev/health" - "https://{{ .inputs.reponame }}-api-edge-prod.{{ .inputs.subdomain }}.workers.dev/health" + # 06-console also places the custom-domain component, PARKED: it subscribes + # to no environment until an owner wires a zone (the commented-out + # `subscribe` block in infra/terraform/cloudflare-domain/component.yaml), so + # it deploys nothing here. It lands with the console because it routes the + # DEPLOYED console and edge. It was the optional 07-domain phase, behind a + # `domain` input, until that input was removed: a landing of its own changed + # nothing live, and the switch turned on a component that is already off. + # The numbering keeps its gap so 08-docs keeps its name. - name: 06-console title: The web console expectedMinutes: 16 @@ -1413,7 +1413,7 @@ phases: await: "The console is building. This is the second-longest wait of the build." done: "The console is live on stage and prod, talking to the edge. {{ .meta.elapsed }}." failed: "The console did not build. The build log above carries the error." - modules: [web-console-next, web-console-next-tests] + modules: [cloudflare-domain, web-console-next, web-console-next-tests] requires: phases: [05-edge] hooks: @@ -1483,78 +1483,6 @@ phases: - "https://{{ .inputs.reponame }}-api-edge-prod.{{ .inputs.subdomain }}.workers.dev/health" - "https://{{ .inputs.reponame }}-web-console-next-prod.{{ .inputs.subdomain }}.workers.dev" - # cloudflare-domain trails the console because it wires the DEPLOYED - # console's custom domain. `when:` is the condition the umbrella carried as - # `[ "{{ inputs.domain }}" = "true" ]` in shell — a phase that declares when - # it runs beats a caller remembering not to ask for it. - - name: 07-domain - title: The custom domain - expectedMinutes: 5 - narrate: - start: "Now placing the custom-domain component for {{ .inputs.productdomain }} — the zone and the console's custom domains." - await: "Waiting for the convergence run that follows the domain PR." - done: "The custom-domain component is in the repository. It subscribes to no environment yet, so nothing is attached until it does — docs/phases/07-domain.md says what to change." - failed: "The domain phase did not land. Check that the zone for {{ .inputs.productdomain }} exists in this Cloudflare account." - modules: [cloudflare-domain] - when: inputs.domain - requires: - phases: [06-console] - hooks: - pre: - - id: task - uses: orun.task/ensure@v1 - with: - kind: task - epic: "{{ .inputs.epicSlug }}" - milestone: "{{ .phase.name }}" - name: "phase({{ .phase.name }}): custom domain" - prefix: BASE - contract: tasks/07-domain.TaskContract.yaml - post: - # Brand what this phase placed before it lands (see 02-foundation). - - id: stage - run: ["git", "add", "-A"] - - id: rebrand - run: ["node", "{{ .baseline.dir }}/tooling/rebrand/rebrand.mjs", "--values", ".rebrand/values.json", "--allow-dirty"] - - id: restage - run: ["git", "add", "-A"] - - id: rebrand-verify - run: ["node", "{{ .baseline.dir }}/tooling/rebrand/rebrand.mjs", "--verify", "--values", ".rebrand/values.json"] - # THE COMPONENT DOCS DESCRIBE THE TREE THEY ARE IN. Each component's - # pages are generated from the manifests, "Depended on by" included, - # and the product's CI checks them (`render-component-docs.py - # --check`). Placed as the baseline rendered them, they describe the - # WHOLE fleet — so a product holding only this phase's components - # fails the check on this phase's own PR, which now has to be green to - # merge. Re-rendered here, after the rebrand, they describe exactly - # what this landing holds; each later phase re-renders them again. - - id: component-docs - run: - - bash - - -c - - | - python3 -c 'import yaml' 2>/dev/null || python3 -m pip install --quiet --user pyyaml - python3 tooling/docs/render-component-docs.py - - id: pnpm-lockfile - run: ["pnpm", "install", "--lockfile-only"] - - id: land - uses: orun.pr/land@v1 - narrate: "The domain PR is merged into main." - with: - task: "{{ .phase.hooks.task.outputs.key }}" - epic: "{{ .inputs.epicSlug }}" - branchSlug: "{{ .phase.name }}" - title: "phase({{ .phase.name }}): custom domain" - await: - - id: converge - uses: orun.run/watch@v1 - narrate: "The convergence run after the domain PR came back green." - with: - sha: "{{ .phase.hooks.land.outputs.mergeSha }}" - repo: "{{ .inputs.githuborg }}/{{ .inputs.reponame }}" - resumeBudget: 3 - waitSeconds: 1800 - # Places nothing. It records what the other phases built, from PROBED facts # rather than from what the blueprint intended — which is why it runs last # and why its verify is the same probe 06-console ends on. diff --git a/specs/epics/saas-lumen-baseline/IMPLEMENTATION-STATUS.md b/specs/epics/saas-lumen-baseline/IMPLEMENTATION-STATUS.md index 6d22c3a8..00af1482 100644 --- a/specs/epics/saas-lumen-baseline/IMPLEMENTATION-STATUS.md +++ b/specs/epics/saas-lumen-baseline/IMPLEMENTATION-STATUS.md @@ -173,3 +173,57 @@ Verified: the manifest, phases, coverage and rebrand contract tests pass; a `spec.requires.integrations` — fails `manifest.test.sh` (exit 1) naming `inputs[subdomain].from`, and passes again once restored; leak and placement (orun 2.58.11, the CI pin) pass with 1083 files, unchanged. + +## The `domain` input, removed (2026-10-21, `baseline-v4`) + +`07-domain` was the one conditional phase: `when: inputs.domain`, off by +default, landing a single component, `cloudflare-domain`. That component +ships PARKED — `subscribe.environments: []` — so CI plans no lanes for it and +the phase's convergence was a green run with nothing in it. A landing that +deploys nothing, behind a switch that turns on a component which is already +off, was one more question and one more PR for no effect. As cirrus-baseline +did (where it folded into `01-product`, its only landing): + +### What shipped + +- `repo-blueprint.yaml`: the `domain` input is gone, and so is its key in the + `.rebrand/values.json` template; `cloudflare-domain` joins `06-console`'s + modules — the last landing that converges a deploy, and the one that places + the console the custom domain routes; the `07-domain` phase is deleted. + Nine phases remain under seven milestones. The numbering keeps its gap, so + `08-docs` keeps its name; it already required `06-console`. +- `blueprint.yaml`: the programme drops the conditional `07-domain` + milestone. +- `tasks/07-domain.TaskContract.yaml` and `docs/phases/07-domain.md` are + deleted. What the page said that is still true — the component ships + parked, the zone must exist in the account first, wiring it is restoring + the commented-out `subscribe` block and finishing the provider-v5 + re-import — is now a section of `docs/phases/06-console.md`, and + `ai/context/operations.md` (which ships) says the same without naming a + factory path. +- `06-console`'s task contract leaves `cloudflare-domain` out of `affects`: + that list is what the convergence deploys, and a parked component deploys + nothing. +- `tests/fixtures/acme.json` loses `"domain": false`. + +### What the tests had to become + +- `testing/phases.test.sh` records `07-domain` as FOLDED into `06-console` + (`WAS["07-domain"]` stays as history), so the partition gate still proves + the component moved whole and nothing moved with it. Mutation-checked: + dropping `cloudflare-domain` from `06-console` fails it. +- `testing/leak.test.sh` and `testing/placement.test.sh` no longer force + `domain` on: `06-console` places the component on every build, so the + gates cover it without help. The placement tier's phased sequence now ends + with `08-docs` after the rebrand — it requires the drifted `06-console`, + the case BE-O12 fixed. + +### Verification + +| check | result | +|---|---| +| manifest, phases, coverage, rebrand | all pass — 7 milestones agree; 58 narration lines resolve; 44 of 44 components placed | +| component docs `--check` | 44 up to date | +| `orun new --status` (orun 2.58.11, the CI pin) | parses; nine phases | +| `testing/leak.test.sh` (orun 2.58.11) | pass — 1083 files, 2 context files, no factory paths | +| `testing/placement.test.sh` (orun 2.58.11) | pass — 1083 product files, the same count as with `domain` forced on before; `01 → 08` place through the rebrand; `--resume` keeps the branding | diff --git a/specs/epics/saas-lumen-baseline/design.md b/specs/epics/saas-lumen-baseline/design.md index 4760c995..63cc7a56 100644 --- a/specs/epics/saas-lumen-baseline/design.md +++ b/specs/epics/saas-lumen-baseline/design.md @@ -158,6 +158,12 @@ Eight workflows, one contract each, all idempotent: | 07 | domain | custom domain (optional) | convergence green | | 08 | docs | live-deployment docs | committed manifest matches probed reality | +> **Since then.** `07-domain` was folded into `06-console` in `baseline-v4`, +> when the `domain` input was removed: its one component ships parked, so it +> lands with the console. A bootstrap today runs nine phases under seven +> milestones (`03` and `04` each have a second landing). The table above is +> the shape this epic planned, kept as the record. + Phase 01 takes the product identity once and writes `.rebrand/values.json`; every later phase reads it back and needs only `out`, `workspace`, and optionally `dryrun`. diff --git a/tasks/06-console.TaskContract.yaml b/tasks/06-console.TaskContract.yaml index eb914f89..deb0440d 100644 --- a/tasks/06-console.TaskContract.yaml +++ b/tasks/06-console.TaskContract.yaml @@ -7,6 +7,8 @@ apiVersion: orun.io/v1 kind: TaskContract spec: goal: The web console is live on stage and prod, talking to the edge + # cloudflare-domain lands in this phase too, but parked: `affects` is what + # the convergence deploys, and a parked component deploys nothing. affects: - web-console-next doneWhen: diff --git a/tasks/07-domain.TaskContract.yaml b/tasks/07-domain.TaskContract.yaml deleted file mode 100644 index 3a1de971..00000000 --- a/tasks/07-domain.TaskContract.yaml +++ /dev/null @@ -1,14 +0,0 @@ -# Task contract template for the 07-domain landing (saas-baseline-tracking BT1). -# Unbound to a key on purpose: `orun task create --contract` seals and -# attaches it to the key the allocator issues. gates: [] is a DECLARATION — -# merge alone finishes this task; the main convergence is the gate the flow -# watches, not one the plane observes as a PR check. -apiVersion: orun.io/v1 -kind: TaskContract -spec: - goal: The product answers on its custom domain instead of workers.dev - affects: - - cloudflare-domain - doneWhen: - - convergence green on the custom domain - gates: [] diff --git a/testing/leak.test.sh b/testing/leak.test.sh index c0085594..4c240033 100755 --- a/testing/leak.test.sh +++ b/testing/leak.test.sh @@ -28,14 +28,12 @@ trap 'rm -rf "$scratch"' EXIT echo "── deriving what every phase would place" # Inputs come from the fixture, so a new required input fails HERE rather than -# in front of an operator. `domain` is forced on: 07-domain is conditional, and -# a gate that never looks at a phase cannot vouch for it. +# in front of an operator. sets=() while IFS=$'\t' read -r k v; do sets+=( --set "$k=$v" ); done < <( python3 - "$root/tests/fixtures/acme.json" <<'PY' import json, sys vals = json.load(open(sys.argv[1])) -vals["domain"] = True for k, v in vals.items(): if k.startswith("_"): continue diff --git a/testing/manifest.test.sh b/testing/manifest.test.sh index 2d685250..4ae5cab8 100755 --- a/testing/manifest.test.sh +++ b/testing/manifest.test.sh @@ -322,7 +322,7 @@ for path in manifests: # refused. # # ONE DIRECTION ONLY. The blueprint declares more than this file does — - # `githuborg`, `epicSlug`, `domain`, `orunWorkspace` and the identity + # `githuborg`, `epicSlug`, `orunWorkspace` and the identity # defaults are how a BUILD is driven, not what a product is configured # with. What must hold is that nothing this file declares arrives at an # engine that cannot take it. @@ -339,7 +339,7 @@ for path in manifests: # ── …AND THE OTHER DIRECTION, for REQUIRED inputs only ─────────────── # # The check above is one-directional on purpose: the blueprint declares - # more than this card does, because `epicSlug`, `domain` and the identity + # more than this card does, because `epicSlug` and the identity # defaults are how a BUILD is driven rather than what a product is # configured with. That tolerance had no floor, and `githuborg` fell # through it — `required: true` in the blueprint, absent from this card, @@ -372,8 +372,9 @@ for path in manifests: # # A milestone is what a phase CLUBS ITS TASK UNDER, which the phase states # as `orun.task/ensure@v1`'s `milestone:`. Reading that is why nine phases - # correctly produce eight milestones: `04-workers-restore` names - # `04-workers`, because it is the second landing of one unit of work. + # correctly produce seven milestones: `03-infrastructure-database` and + # `04-workers-restore` name `03-infrastructure` and `04-workers`, because + # each is the second landing of one unit of work. # # Distinct, in phase order. The old check grepped the umbrella's # `ensure-milestone` lines for the same list. diff --git a/testing/phases.test.sh b/testing/phases.test.sh index 47672924..89fc5ae4 100755 --- a/testing/phases.test.sh +++ b/testing/phases.test.sh @@ -79,6 +79,14 @@ WAS = { # is likewise new — the empty apps/infra/packages/tests roots orun's repo-scale # gate requires, which the scaffold flow used to create with a mkdir. ADDED = {"01-scaffold": ["discovery-roots"]} +# FOLDED, deliberately: 07-domain's one component lands in 06-console since the +# `domain` input went. It ships parked (it subscribes to no environment until +# an owner wires a zone), so a landing of its own deployed nothing, and an +# on/off switch for a component that is already off was one more question for +# nothing. 06-console is the last landing that converges a deploy and the one +# that places the console the custom domain routes. The module moves whole — +# nothing is lost, and nothing else is allowed to move with it. +FOLDED = {"07-domain": "06-console"} HOOK_ONLY = {"04-workers-restore", "08-docs"} by_name = {p["name"]: p for p in phases} @@ -90,12 +98,18 @@ if names != sorted(names): f"order; a phase out of sequence is a barrier in the wrong place.") # ── the partition has not drifted ───────────────────────────────────────── +for gone, into in FOLDED.items(): + if gone in by_name: + bad(f"phase {gone} is declared again, but it is folded into {into}") for name, was in WAS.items(): + if name in FOLDED: + continue if name not in by_name: bad(f"phase {name} is gone — the bootstrap ran it before BE1") continue now = sorted(by_name[name].get("modules") or []) - want = sorted(was + ADDED.get(name, [])) + folded_in = [m for gone, into in FOLDED.items() if into == name for m in WAS[gone]] + want = sorted(was + ADDED.get(name, []) + folded_in) if now != want: moved_in = sorted(set(now) - set(want)) moved_out = sorted(set(want) - set(now)) diff --git a/testing/placement.test.sh b/testing/placement.test.sh index 8958bcd5..45311a31 100755 --- a/testing/placement.test.sh +++ b/testing/placement.test.sh @@ -43,14 +43,12 @@ fails=0 fail() { echo " ✕ $*" >&2; fails=$((fails + 1)); } # The fixture is the source of inputs, so a new required input fails HERE rather -# than in front of an operator. `domain` is forced on: 07-domain is conditional, -# and a tier that never places a phase cannot vouch for it. +# than in front of an operator. sets=() while IFS=$'\t' read -r k v; do sets+=( --set "$k=$v" ); done < <( python3 - "$root/tests/fixtures/acme.json" <<'PY' import json, sys vals = json.load(open(sys.argv[1])) -vals["domain"] = True for k, v in vals.items(): if k.startswith("_"): continue @@ -238,7 +236,10 @@ name_after_brand="$(python3 -c "import json;print(json.load(open('$seq/package.j [ "$name_after_brand" = "acme-cloud" ] \ || fail "after branding, package.json name is $name_after_brand, not the product's" -for ph in 02-foundation 03-infrastructure 03-infrastructure-database 04-workers 05-edge 06-console 07-domain; do +# 08-docs requires 06-console, which the rebrand has just drifted: the case +# BE-O12 used to refuse. (The custom-domain component used to land on its own +# as 07-domain; it lands in 06-console now, parked.) +for ph in 02-foundation 03-infrastructure 03-infrastructure-database 04-workers 05-edge 06-console 08-docs; do if ! orun new --blueprint "$root/repo-blueprint.yaml" --out "$seq" --phase "$ph" \ "${sets[@]}" > "$scratch/p-$ph.log" 2>&1; then fail "phase $ph refused after the rebrand: $(tail -1 "$scratch/p-$ph.log")" @@ -269,7 +270,7 @@ name_after_resume="$(python3 -c "import json;print(json.load(open('$seq/package. $name_after_resume. A resume between phases must not un-brand a product." [ "$fails" -eq 0 ] && \ - echo " 01 → 07 place through the rebrand; --resume leaves the branding alone" + echo " 01 → 08 place through the rebrand; --resume leaves the branding alone" [ "$fails" -eq 0 ] || { echo "placement.test.sh: $fails failure(s)" >&2; exit 1; } echo "placement.test.sh: ok" diff --git a/tests/fixtures/acme.json b/tests/fixtures/acme.json index 194bdbb4..6813d825 100644 --- a/tests/fixtures/acme.json +++ b/tests/fixtures/acme.json @@ -16,6 +16,5 @@ "githuborg": "acme-inc", "subdomain": "acme", "orunWorkspace": "ws_0000000000000000000000000000000f", - "epicSlug": "infra-baselining", - "domain": false + "epicSlug": "infra-baselining" } From 159a60d3d382472b73a18b4c925ba0f470d46bbd Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 22 Oct 2026 03:59:13 +0000 Subject: [PATCH 3/3] =?UTF-8?q?feat:=20the=20console=20asks=20for=20no=20d?= =?UTF-8?q?omain=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 product answers on workers.dev from its first deploy and nothing in the build needs a domain, so the console card no longer asks for one. Everything that uses the domain stays where it is, carrying a placeholder until an owner sets it. As turso-starter #9. - blueprint.yaml: no productdomain input, and no apibaseurl (it derived from {productdomain}; a card can only derive from inputs it declares) - repo-blueprint.yaml: productdomain optional, default empty - rebrand.mjs: productdomain no longer required; empty brands the reserved placeholder .example.com where sourceplane.ai stood as the product domain (intent BASE_DOMAIN/CONSOLE_CUSTOM_DOMAIN, edge and identity origins, mail sender, billing success URLs); with no domain the CLI default is the prod edge, https://-api-edge-prod..workers.dev - cloudflare-domain README examples name sourceplane.ai and sourceplane-web-console-next, so they follow the placeholder and the console Worker like baseDomain/workerNamePrefix already did (cirrus #32) - ai/context/operations.md: "Setting the domain later" - render-deployment-docs.sh: the placeholder is no domain to probe - tests: fixture carries no domain; placement checks the product's CLI default and placeholder instead of the card's derive; rebrand.test.sh covers no domain, an empty one and a given one; CI reads the blueprint with no domain - docs: BOOTSTRAP.md, docs/phases; record in saas-lumen-baseline (baseline-v4, with #364) Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01D8AmgTwmnp4M8mgmnS9aha --- .github/workflows/baseline.yml | 5 +- BOOTSTRAP.md | 33 ++++-- ai/context/operations.md | 60 +++++++++- blueprint.yaml | 25 ++-- docs/phases/01-scaffold.md | 5 +- docs/phases/02-foundation.md | 2 +- docs/phases/04-workers.md | 2 +- docs/phases/05-edge.md | 2 +- docs/phases/06-console.md | 14 ++- docs/phases/08-docs.md | 9 +- docs/phases/README.md | 4 +- hooks/render-deployment-docs.sh | 12 +- infra/terraform/cloudflare-domain/README.md | 14 +-- repo-blueprint.yaml | 23 +++- .../IMPLEMENTATION-STATUS.md | 109 ++++++++++++++++++ testing/manifest.test.sh | 7 ++ testing/placement.test.sh | 80 ++++++++++--- testing/rebrand.test.sh | 43 +++++++ tests/fixtures/acme.json | 11 +- tooling/rebrand/rebrand.mjs | 26 ++++- 20 files changed, 403 insertions(+), 83 deletions(-) diff --git a/.github/workflows/baseline.yml b/.github/workflows/baseline.yml index d0eaaa26..fb91871b 100644 --- a/.github/workflows/baseline.yml +++ b/.github/workflows/baseline.yml @@ -95,12 +95,13 @@ jobs: set -euo pipefail orun --version # Inputs that are `required: true` must be supplied for the document - # to resolve; the values are arbitrary and nothing is written. + # to resolve; the values are arbitrary and nothing is written. No + # domain: the console asks for none, so the document must resolve + # without one. orun new --blueprint repo-blueprint.yaml --status \ --out "$(mktemp -d)" \ --set reponame=acme-cloud \ --set "productname=Acme Cloud" \ - --set productdomain=acme.dev \ --set githuborg=acme-inc # Tier 1's leak gate. It derives what every phase WOULD place and gates # that set — so it needs orun, which is why it rides this job rather than diff --git a/BOOTSTRAP.md b/BOOTSTRAP.md index ebb3436e..2ce6aba1 100644 --- a/BOOTSTRAP.md +++ b/BOOTSTRAP.md @@ -83,7 +83,7 @@ cd multi-tenant-saas orun new --blueprint repo-blueprint.yaml \ --out ~/sourceplane/acme --run-hooks --resume \ --set reponame=acme --set productname="Acme Cloud" \ - --set productdomain=acme.dev --set githuborg=sourceplane \ + --set githuborg=sourceplane \ --set orunWorkspace=ws_XXXXXXXX \ --set subdomain= ``` @@ -100,6 +100,17 @@ Cloudflare account you deploy into from the workspace's Cloudflare connection, the same one the deploy tokens mint from. Only a hand-run build like this one passes it. +**No domain is asked.** The blueprint's required inputs are `reponame`, +`productname` and `githuborg`; the domain is not one of them. The product +goes live on workers.dev, and `productdomain` defaults to empty, which brands +the reserved placeholder `.example.com` wherever the domain goes +(intent's `BASE_DOMAIN` and `CONSOLE_CUSTOM_DOMAIN`, the edge and identity +console origins, the mail sender, the billing return URLs) for an owner to +replace later (§4). With no domain the CLI's default API is the product's own +prod edge, `https://-api-edge-prod..workers.dev`. Pass +`--set productdomain=` only for a product that already has its domain; the +CLI then defaults to `https://api.`. + **`--run-hooks` is the difference between placing files and bootstrapping a product.** Without it `orun new` writes the tree and stops: no repo is created, nothing is landed, no convergence is watched, and no phase probes @@ -131,7 +142,7 @@ phase in that folder. orun new --blueprint repo-blueprint.yaml --out ~/sourceplane/acme --run-hooks \ --phase 01-scaffold \ --set reponame=acme --set productname="Acme Cloud" \ - --set productdomain=acme.dev --set githuborg=sourceplane \ + --set githuborg=sourceplane \ --set orunWorkspace=ws_XXXXXXXX --set subdomain= # 01 committed the answers as .rebrand/values.json, keyed by the blueprint's @@ -262,11 +273,15 @@ tag, which is why it carries none. What that means for a console build: - `reponame` and `githuborg` come from the repository the operator picked; - `apibaseurl` is derived (`https://api.{productdomain}`); `subdomain` is - read from the workspace's Cloudflare connection (`from: + `subdomain` is read from the workspace's Cloudflare connection (`from: connection.cloudflare.workersSubdomain`), the one the deploy tokens mint from, and an account with no workers.dev subdomain is refused before - anything is created. Only `productname` and `productdomain` are typed. + anything is created. Only `productname` is typed. +- No domain is asked. `productdomain` and `apibaseurl` (which the card + derived from it, and a card can only derive from inputs it declares) left + the card in baseline-v4: the product is born with the placeholder + `.example.com` where the domain goes, and its CLI defaults to its + own prod edge on workers.dev. An owner sets the domain later (§4). - `orunWorkspace` is not on the form — it cannot be. The build runs inside the workspace, and `from: workspace` (orun ≥ v2.58.11) fills it from there. - The custom-domain component lands in `06-console`, parked, on every @@ -283,7 +298,11 @@ that mint them, and its programme and inputs to the blueprint's. - **Deployment record**: `08-docs` is the close-out, and safe to re-run any time as a live-state refresh. -- **Custom domain**: the `cloudflare-domain` component is already in the +- **Custom domain**: a product built without one carries the placeholder + `.example.com` wherever the domain goes; replacing it + (`git grep -l .example.com`) is the first step, and the + product's `ai/context/operations.md`, "Setting the domain later", lists + every place and step. The `cloudflare-domain` component is already in the product, landed by `06-console` and parked (it subscribes to no environment, and it is mid-migration to provider v5). Create the product zone in Cloudflare, restore the component's commented-out `subscribe` @@ -361,7 +380,7 @@ purpose, written down so they read as instructions rather than breakage. | `unknown flag: --phase`, `cannot unmarshal !!map into []scaffold.Hook`, or an action `has no parameter "githubOwner"` / `"sha"` | The CLI is below the v2.58.11 floor. This blueprint is not readable by an older one. | | A fresh build stops before 01-scaffold: `✕ phase "04-workers" precondition "wiring" is not met: … project "" not found` | The CLI is below v2.58.10, which asks the preflight about the product's project before phase 01 has created it and calls the answer a failure. Upgrade; the probe is then deferred to phase 04. | | The product's `intent.yaml` says `workspace: ws_SET_ME`, or its secret refs name the repository (`secret:///…`) | `orunWorkspace` was empty: set it, or run the build in the workspace (ORUN_WORKSPACE) with a CLI ≥ v2.58.11, which fills it from there. | -| `✕ input "productdomain" is required` | Required inputs are validated before anything else, so this names the key nobody typed. All four — `reponame`, `productname`, `productdomain`, `githuborg` — must be set on every invocation, including single-phase ones. `--values /.rebrand/values.json` carries them. | +| `✕ input "productname" is required` | Required inputs are validated before anything else, so this names the key nobody typed. All three — `reponame`, `productname`, `githuborg` — must be set on every invocation, including single-phase ones. `--values /.rebrand/values.json` carries them. The domain is not required (a baseline before v4 asked for `productdomain` too). | | Console/edge smoke fails right after the FIRST deploy of a worker | workers.dev route propagation race — the deploy lane's smoke retries with backoff (stack-tectonic ≥ 0.18.2); a convergence resume clears older pins. | | Terraform lane: "state already locked" by ITS OWN plan | Backend lock-release race — a convergence resume clears it. | | Lanes fail with NO logs at all | GitHub Actions billing or spending limit. The message lives only in the check-run annotations (`gh api repos///check-runs//annotations`). | diff --git a/ai/context/operations.md b/ai/context/operations.md index adc60ca0..034d456d 100644 --- a/ai/context/operations.md +++ b/ai/context/operations.md @@ -113,7 +113,7 @@ orun integrations list --org --json && orun cloud check --org | add a runtime secret | `orun secrets set --org --env ` | | resolve workspace identity | `orun workspace ` | | check integrations | `orun integrations list --org --json` | -| custom domain | `infra/terraform/cloudflare-domain` ships parked (`subscribe.environments: []`). Once the zone exists in the Cloudflare account, restore the `subscribe` block its `component.yaml` carries commented out (and finish the provider-v5 re-import its comment names), merge, then run the `08-docs` phase | +| custom domain | see [Setting the domain later](#setting-the-domain-later): replace the domain string, create the zone, restore `infra/terraform/cloudflare-domain`'s commented-out `subscribe` block (it ships parked, `subscribe.environments: []`, mid-way to provider v5), merge, then run the `08-docs` phase | | headless/CI credentials | `ORUN_TOKEN` (workspace-scoped) + `GITHUB_TOKEN` | The ops phases (docs refresh and the original deployment sequence) all live @@ -129,12 +129,66 @@ orun new --blueprint repo-blueprint.yaml --out \ ``` `` carries this product's identity — at minimum `reponame`, -`productname`, `productdomain`, `githuborg` and `orunWorkspace`, which the -blueprint validates before anything runs. `--run-hooks` is what makes a phase +`productname`, `githuborg` and `orunWorkspace`, which the blueprint validates +before anything runs (and `productdomain` once the product has a domain; +`.rebrand/values.json` in this repository is a complete one). `--run-hooks` +is what makes a phase land and verify rather than just place files; `--status` previews without writing. Every phase is idempotent — re-running a completed one is a no-op that re-verifies. +## Setting the domain later + +This product answers on workers.dev from its first deploy, and it was built +without a domain. Every place the domain goes carries one string until an +owner sets it — in this repository, `sourceplane.ai` (built without a domain, +that is the reserved placeholder `.example.com`, which can never be +anyone's real domain). Nothing that uses the domain was removed; it waits: + +| where | what it is | +|---|---| +| `intent.yaml` | `BASE_DOMAIN` (every environment) and `CONSOLE_CUSTOM_DOMAIN` (`stage.sourceplane.ai`, `prod.sourceplane.ai`) — the parameters of the parked `infra/terraform/cloudflare-domain` | +| `infra/terraform/cloudflare-domain` | `baseDomain` in its `component.yaml`, the Terraform variable's default, its README (its `workerNamePrefix` already names this product's console Worker, `sourceplane-web-console-next`) | +| `apps/api-edge/wrangler.template.jsonc` | `CONSOLE_CUSTOM_DOMAIN`, the console origin CORS allows besides the workers.dev one | +| `apps/identity-worker/wrangler.template.jsonc` | `OAUTH_ALLOWED_CONSOLE_ORIGINS`, which lists the workers.dev console too, so sign-in works without a domain | +| `apps/notifications-worker/wrangler.template.jsonc` | `EMAIL_FROM_ADDRESS`, `no-reply@mail.sourceplane.ai` | +| `apps/billing-worker/wrangler.template.jsonc` | `POLAR_SUCCESS_URL`, the fallback return after checkout | +| `tests/api-edge` | the CORS fixtures, which follow the edge's config | + +To set it, in one PR: + +1. **Replace the string everywhere**, and record the domain as + `productdomain` in `.rebrand/values.json`, where the docs refresh reads + it: + + ```bash + git grep -lF 'sourceplane.ai' # every file that names it + git grep -lzF 'sourceplane.ai' | xargs -0 perl -pi -e 's/\Qsourceplane.ai\E/acme.dev/g' # acme.dev: yours + ``` + +2. **Create the zone** in the Cloudflare account the product deploys into + (dashboard; the platform does not create zones), then restore the + `subscribe` block `infra/terraform/cloudflare-domain/component.yaml` + carries commented out, and finish the provider-v5 custom-domain resource + its comments describe. Until then the console has no custom domain and + keeps its workers.dev URL. +3. **Verify the mail domain** — `mail.` in Cloudflare Email + Service (DKIM/SPF). The notifications worker sends from + `no-reply@mail.`; until it is verified, sends surface as + `notification.failed` events and nothing else breaks. +4. **Supabase auth URLs.** This product sets none: sign-in is the identity + worker's, and `infra/terraform/supabase` names no domain. If you have + since set Supabase Auth's site URL or redirect URLs in its dashboard, + point them at the domain too. +5. **The CLI default, if you want it on the domain.** Built without a + domain, `DEFAULT_API_URL` in `packages/cli/src/brand.ts` is the prod edge + on workers.dev, `https://api-edge-prod..workers.dev`; + replacing the domain string does not move it. Re-point it once a host on + your domain routes to the edge. +6. **Merge, then run the docs flow** (the `08-docs` phase, above) once the + convergence is green and DNS resolves, so `deployment.md` records the + domain. + ## Evolution Structural changes (new workers, infra components, packages) follow the diff --git a/blueprint.yaml b/blueprint.yaml index c1f6b3f5..8ce8e6f6 100644 --- a/blueprint.yaml +++ b/blueprint.yaml @@ -64,6 +64,18 @@ spec: # The cost lands here. An `askedBy: agent` input was exempt from `pattern`, # because prose asked for it and prose does not validate. Every input now # carries the rule its value is checked against before Continue. + # + # THE DOMAIN IS NOT ASKED. The product goes live on workers.dev, and a + # domain is an owner's step after the bootstrap: `productdomain` defaults + # to empty in repo-blueprint.yaml, and the rebrand writes the reserved + # placeholder `.example.com` wherever the domain goes (intent's + # BASE_DOMAIN and CONSOLE_CUSTOM_DOMAIN, the edge and identity origins, the + # mail sender, the billing return URLs) for the product's + # ai/context/operations.md, "Setting the domain later", to replace. Nothing + # that needs a domain is removed — it waits for one. `apibaseurl` went with + # it: it was derived from `{productdomain}`, and a card can only derive + # from inputs it declares. With no domain, the CLI's default API is the + # product's own prod edge on workers.dev (rebrand.mjs). - key: reponame label: Repo name pattern: "^[a-z][a-z0-9-]{1,38}$" @@ -78,19 +90,6 @@ spec: pattern: "^[A-Za-z0-9][A-Za-z0-9 .,'&-]{1,48}$" help: The name people will see — in the console header, the emails, the docs. example: Acme Cloud - - key: productdomain - label: Product domain - pattern: "^[a-z0-9]([a-z0-9-]*[a-z0-9])?(\\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)+$" - help: The apex domain the product answers on. It does not need to exist yet. - example: acme.dev - - key: apibaseurl - label: API base URL - pattern: "^https://[a-z0-9.-]+$" - help: Where the CLI and SDK point by default. - # Derived rather than asked: it is the product domain with a prefix, and - # a field for it is a field an operator can get subtly wrong (http, a - # trailing slash, api. on the wrong half) for no gain. - derive: "https://api.{productdomain}" - key: githuborg label: GitHub organisation pattern: "^[A-Za-z0-9][A-Za-z0-9-]*$" diff --git a/docs/phases/01-scaffold.md b/docs/phases/01-scaffold.md index 341973df..cfce24b7 100644 --- a/docs/phases/01-scaffold.md +++ b/docs/phases/01-scaffold.md @@ -44,11 +44,11 @@ gates the set, so the promise is a test rather than a claim. | `--out` | `$HOME/sourceplane/acme` | a flag, not an input; created if absent | | `reponame` | `acme` | REQUIRED. Lowercase slug (`^[a-z][a-z0-9-]*$`); repo becomes `/` | | `productname` | `Acme Cloud` | REQUIRED. Display name | -| `productdomain` | `acme.dev` | REQUIRED. Product domain | +| `productdomain` | — (default empty) | NOT ASKED. Empty brands the placeholder `.example.com` where the domain goes, for an owner to replace later; pass it only for a product that already has its domain | | `githuborg` | `sourceplane` | REQUIRED. The org or user the repo is created under | | `orunWorkspace` | `ws_ABCD1234` | workspace id. Unset, the workspace the build runs in (ORUN_WORKSPACE); with none anywhere, the placeholder `ws_SET_ME` | | `subdomain` | `rahulvarghesepullely` | workers.dev subdomain of the Cloudflare account you deploy into — every URL derives from it (worker names are brand-prefixed, so keeping the baseline's account is supported). A console or `--from bst_…` build reads it from the Cloudflare connection; pass it only for a hand-run build | -| `apibaseurl` | `https://api.acme.dev` | CLI default API base; empty derives from `productdomain` | +| `apibaseurl` | — (default empty) | CLI default API base; empty derives `https://api.`, or with no domain the prod edge, `https://-api-edge-prod..workers.dev` | | `repoPrivate` | `true` (default) | visibility at creation only | | `epicSlug` | `infra-baselining` (default) | the epic every phase files its task under | @@ -149,7 +149,6 @@ orun new --blueprint repo-blueprint.yaml \ --out $HOME/sourceplane/acme --run-hooks --phase 01-scaffold \ --set reponame=acme \ --set productname="Acme Cloud" \ - --set productdomain=acme.dev \ --set githuborg=sourceplane \ --set orunWorkspace=ws_ABCD1234 \ --set subdomain=rahulvarghesepullely diff --git a/docs/phases/02-foundation.md b/docs/phases/02-foundation.md index 66e929f9..7b2b9eee 100644 --- a/docs/phases/02-foundation.md +++ b/docs/phases/02-foundation.md @@ -20,7 +20,7 @@ applies them yet: the migration runner (`infra/db-migrate`) lands in ## Inputs `--out` is the product repo. The blueprint's required inputs — `reponame`, -`productname`, `productdomain`, `githuborg` — are validated before any phase +`productname`, `githuborg` — are validated before any phase runs, so pass them on every invocation; the product's own `.rebrand/values.json` is a complete values file. See [the phases README](README.md#inputs). diff --git a/docs/phases/04-workers.md b/docs/phases/04-workers.md index f1b0c266..52239fc9 100644 --- a/docs/phases/04-workers.md +++ b/docs/phases/04-workers.md @@ -64,7 +64,7 @@ PRs and two task contracts, are two phases here. ## Inputs `--out` is the product repo. The blueprint's required inputs — `reponame`, -`productname`, `productdomain`, `githuborg` — are validated before any phase +`productname`, `githuborg` — are validated before any phase runs, so pass them on every invocation; the product's own `.rebrand/values.json` is a complete values file. See [the phases README](README.md#inputs). diff --git a/docs/phases/05-edge.md b/docs/phases/05-edge.md index 0cb12823..192f4924 100644 --- a/docs/phases/05-edge.md +++ b/docs/phases/05-edge.md @@ -23,7 +23,7 @@ own deploy lane in phase 04 is the evidence for it. ## Inputs `--out` is the product repo. The blueprint's required inputs — `reponame`, -`productname`, `productdomain`, `githuborg` — are validated before any phase +`productname`, `githuborg` — are validated before any phase runs, so pass them on every invocation; the product's own `.rebrand/values.json` is a complete values file. See [the phases README](README.md#inputs). diff --git a/docs/phases/06-console.md b/docs/phases/06-console.md index 1b999190..e2911c48 100644 --- a/docs/phases/06-console.md +++ b/docs/phases/06-console.md @@ -20,8 +20,10 @@ convergence watch up to 45 minutes too. `infra/terraform/cloudflare-domain` (the zone lookup and, once wired, a custom domain per environment for the console worker — `CONSOLE_CUSTOM_DOMAIN` in the product's `intent.yaml`, `stage.` -and `prod.` after rebrand, empty for `dev`) lands with the -console and **deploys nothing**: its `component.yaml` declares +and `prod.` after rebrand, empty for `dev` — and, since the +console asks for no domain, `` is the placeholder +`.example.com` until an owner sets one) lands with the console and +**deploys nothing**: its `component.yaml` declares `subscribe.environments: []`, so CI plans no lanes for it. The product runs on workers.dev URLs until an owner wires it. @@ -31,7 +33,11 @@ green run with nothing in it — so the phase and the switch are gone, and the task contract's `affects` leaves the component out: there is nothing in it to re-plan. -Wiring it is a normal pull request in the product, once the zone exists: +Wiring it is a normal pull request in the product, once the zone exists. +The product's `ai/context/operations.md` ("Setting the domain later") carries +the whole list for its owner: replace the placeholder everywhere it stands +(`git grep -l .example.com` — intent, the edge and identity console +origins, the mail sender, the billing return URLs), then: 1. **The zone first.** The product zone (e.g. `acme.dev`) must already exist in the Cloudflare account the product deploys into, created in the @@ -54,7 +60,7 @@ Wiring it is a normal pull request in the product, once the zone exists: ## Inputs `--out` is the product repo. The blueprint's required inputs — `reponame`, -`productname`, `productdomain`, `githuborg` — are validated before any phase +`productname`, `githuborg` — are validated before any phase runs, so pass them on every invocation; the product's own `.rebrand/values.json` is a complete values file. See [the phases README](README.md#inputs). diff --git a/docs/phases/08-docs.md b/docs/phases/08-docs.md index a69bfaae..d1c27f39 100644 --- a/docs/phases/08-docs.md +++ b/docs/phases/08-docs.md @@ -29,9 +29,10 @@ this credential" rather than a failed render. 2. **pre** — the phase's task. 3. **render** — a `post` hook runs `hooks/render-deployment-docs.sh . ` from the baseline checkout. It reads identity from - `.rebrand/values.json`, probes the four public URLs (and - `api./health` and `app.`, reported as - pending when they do not answer), lists secrets and integrations by name + `.rebrand/values.json`, probes the four public URLs (and, when that file + records a domain, `api./health` and `app.`, + reported as pending when they do not answer — a product built without a + domain records none, so they are skipped), lists secrets and integrations by name with `orun secrets list` / `orun integrations list`, and renders the files above. It refuses to finish if a `TBD_08DOCS` placeholder survives. 4. **land** — `orun.pr/land@v1`: PR `docs(deployment): record live @@ -56,7 +57,7 @@ this credential" rather than a failed render. ## Inputs `--out` is the product repo. The blueprint's required inputs — `reponame`, -`productname`, `productdomain`, `githuborg` — are validated before any phase +`productname`, `githuborg` — are validated before any phase runs, so pass them on every invocation; the product's own `.rebrand/values.json` is a complete values file. The renderer also takes `orunWorkspace`, which that file records. See diff --git a/docs/phases/README.md b/docs/phases/README.md index b08e9b6c..7a62bd95 100644 --- a/docs/phases/README.md +++ b/docs/phases/README.md @@ -76,10 +76,10 @@ same words. |---|---|---| | `reponame` | yes | lowercase slug (`^[a-z][a-z0-9-]*$`); the repo becomes `/`, and it prefixes the Supabase projects and every worker. The console fills it from the chosen repository | | `productname` | yes | display name | -| `productdomain` | yes | the apex domain the product answers on; it does not need to exist yet | +| `productdomain` | — | NOT ASKED, default empty. The product goes live on workers.dev; empty brands the reserved placeholder `.example.com` wherever the domain goes (intent's `BASE_DOMAIN` / `CONSOLE_CUSTOM_DOMAIN`, the edge and identity console origins, the mail sender, the billing return URLs), for an owner to replace later (the product's `ai/context/operations.md`, "Setting the domain later"). Pass it only for a product that already has its domain | | `githuborg` | yes | the org or user the repo lives under. The console fills it from the chosen repository's owner | | `subdomain` | — | workers.dev subdomain of the Cloudflare **account** you deploy into. A console or `--from bst_…` build reads it from the Cloudflare connection; pass it only for a hand-run build, where the default is a placeholder; see below | -| `apibaseurl` | — | the CLI/SDK default API base; empty means `https://api.` | +| `apibaseurl` | — | the CLI default API base. Empty, it is `https://api.` when a domain is given, and otherwise the product's own prod edge on workers.dev, `https://-api-edge-prod..workers.dev`. Not on the card: it was derived from the domain | | `orunWorkspace` | — | workspace id. Unset, it is the workspace the build runs in (`from: workspace`, ORUN_WORKSPACE, which a console build always has); with none anywhere, 01 writes the placeholder `ws_SET_ME`, which fails loudly rather than silently cross-tenanting | | `epicSlug` | — | default `infra-baselining`; the epic every phase files its task under, found by slug so a fresh run and a resumed run find the same work | | `repoPrivate` | — | default `true`; applied only when `01-scaffold` creates the repo — an existing repo keeps its visibility | diff --git a/hooks/render-deployment-docs.sh b/hooks/render-deployment-docs.sh index c2d9f84d..a3a2cac2 100755 --- a/hooks/render-deployment-docs.sh +++ b/hooks/render-deployment-docs.sh @@ -3,7 +3,7 @@ # Called by phase 08-docs as a `run:` hook (and safe to run by hand). # Idempotent: the # generated files and the README section are fully re-rendered on every run, -# so re-running after phase 07 (custom domain) or any redeploy refreshes them. +# so re-running after the custom domain is wired or any redeploy refreshes them. # # hooks/render-deployment-docs.sh # @@ -31,6 +31,10 @@ vals=".rebrand/values.json" repo="$(python3 -c "import json;print(json.load(open('$vals'))['reponame'])")" sub="$(python3 -c "import json;print(json.load(open('$vals'))['subdomain'])")" domain="$(python3 -c "import json;print(json.load(open('$vals')).get('productdomain',''))")" +# A product is built with no domain (the console asks for none): values.json +# records "" and the tree carries the reserved placeholder .example.com +# until an owner sets one. Neither is a domain to probe. +case "$domain" in *.example.com) domain="" ;; esac # Workspace slug via the direct backend read (works for user sessions AND # workspace-scoped ORUN_TOKENs); tolerate failure — slug then shows as "?". @@ -54,14 +58,14 @@ con_prod="https://${repo}-web-console-next-prod.${sub}.workers.dev" p_es="$(probe "$edge_stage/health")"; p_ep="$(probe "$edge_prod/health")" p_cs="$(probe "$con_stage")"; p_cp="$(probe "$con_prod")" -# Custom domain (phase 07, optional): probe only if a domain is declared; +# Custom domain (set later, by an owner): probe only if a domain is recorded; # an unreachable domain is reported as pending, never a failure. dom_rows="" if [ -n "$domain" ]; then p_da="$(probe "https://api.${domain}/health")" p_dc="$(probe "https://app.${domain}")" - dom_rows="| edge (custom domain) | https://api.${domain}/health | $( [ "$p_da" = 000 ] && echo 'pending (phase 07 not run, or DNS propagating)' || badge "$p_da" ) | -| console (custom domain) | https://app.${domain} | $( [ "$p_dc" = 000 ] && echo 'pending (phase 07 not run, or DNS propagating)' || badge "$p_dc" ) |" + dom_rows="| edge (custom domain) | https://api.${domain}/health | $( [ "$p_da" = 000 ] && echo 'pending (not wired yet, or DNS propagating)' || badge "$p_da" ) | +| console (custom domain) | https://app.${domain} | $( [ "$p_dc" = 000 ] && echo 'pending (not wired yet, or DNS propagating)' || badge "$p_dc" ) |" fi # Inventories — NAMES/status only, never values. Tolerant: a token that diff --git a/infra/terraform/cloudflare-domain/README.md b/infra/terraform/cloudflare-domain/README.md index 71f76bb1..aeb30978 100644 --- a/infra/terraform/cloudflare-domain/README.md +++ b/infra/terraform/cloudflare-domain/README.md @@ -17,8 +17,8 @@ declarations: | Variable | Description | Example | |----------|-------------|---------| -| `BASE_DOMAIN` | Root domain for the zone | `multi-tenant-saas.app` | -| `CONSOLE_CUSTOM_DOMAIN` | Custom domain for the console Worker | `stage.multi-tenant-saas.app` | +| `BASE_DOMAIN` | Root domain for the zone | `sourceplane.ai` | +| `CONSOLE_CUSTOM_DOMAIN` | Custom domain for the console Worker | `stage.sourceplane.ai` | These are exported as `TF_VAR_*` by the Orun job template and consumed by Terraform. The same variables are available to Workers (via `wrangler.jsonc` @@ -45,9 +45,9 @@ vars) for runtime CORS decisions. | Parameter | Required | Description | |-----------|----------|-------------| -| `baseDomain` | yes | Root domain (e.g. `multi-tenant-saas.app`) | +| `baseDomain` | yes | Root domain (e.g. `sourceplane.ai`) | | `zoneMode` | yes | `existing` or `managed` | -| `workerNamePrefix` | yes | Worker name prefix (e.g. `multi-tenant-saas-web-console-next`); fully-qualified service name is `{workerNamePrefix}-{environment}` | +| `workerNamePrefix` | yes | Worker name prefix (e.g. `sourceplane-web-console-next`); fully-qualified service name is `{workerNamePrefix}-{environment}` | | `stackName` | yes | Terraform stack identifier | | `terraformDir` | yes | Path to Terraform root | | `terraformVersion` | yes | Terraform CLI version | @@ -83,9 +83,9 @@ After merge to main, verify: 1. `terraform apply` succeeds in CI (`github-push-main` trigger). 2. Workers custom domains show `active` status in Cloudflare (Workers → the - `multi-tenant-saas-web-console-next-{env}` Worker → Triggers → Custom Domains). -3. `https://stage.multi-tenant-saas.app/` serves the stage console (web-console-next). -4. `https://prod.multi-tenant-saas.app/` serves the prod console (web-console-next). + `sourceplane-web-console-next-{env}` Worker → Triggers → Custom Domains). +3. `https://stage.sourceplane.ai/` serves the stage console (web-console-next). +4. `https://prod.sourceplane.ai/` serves the prod console (web-console-next). 5. SSL certificates are provisioned (automatic via Cloudflare). ## Outputs diff --git a/repo-blueprint.yaml b/repo-blueprint.yaml index cb4209b4..a9f502de 100644 --- a/repo-blueprint.yaml +++ b/repo-blueprint.yaml @@ -39,8 +39,20 @@ inputs: description: Human display name (e.g. "Acme Cloud"). productdomain: type: string - required: true - description: Product domain (e.g. acme.dev) — BASE_DOMAIN, console custom domains, OAuth origins. + default: "" + description: >- + The product's own domain, once it has one (e.g. acme.dev). NOT ASKED: + the product answers on workers.dev from its first deploy, and a domain + is an owner's step after it. Empty, the rebrand writes the reserved + placeholder `.example.com` wherever the domain goes — + intent.yaml's BASE_DOMAIN and CONSOLE_CUSTOM_DOMAIN (the parked + cloudflare-domain's parameters), the api-edge CORS and identity-worker + OAuth console origins (both also allow the workers.dev console, so + sign-in works without it), the notifications sender and the billing + success URLs — so setting it later is replacing that one string; the + product's ai/context/operations.md, "Setting the domain later", says + how. Pass it with --set only to brand a hand-run build with a domain it + already has. pascalName: type: string default: "" @@ -56,7 +68,12 @@ inputs: apibaseurl: type: string default: "" - description: CLI default API base (default https://api.). + description: >- + CLI default API base. Empty, the rebrand derives it: with a + `productdomain`, https://api.; with none (the console + asks for none), the product's own prod edge on workers.dev, + https://-api-edge-prod..workers.dev, which is + live from the first deploy. subdomain: type: string default: "your-workers-subdomain" diff --git a/specs/epics/saas-lumen-baseline/IMPLEMENTATION-STATUS.md b/specs/epics/saas-lumen-baseline/IMPLEMENTATION-STATUS.md index 00af1482..a77d6ccb 100644 --- a/specs/epics/saas-lumen-baseline/IMPLEMENTATION-STATUS.md +++ b/specs/epics/saas-lumen-baseline/IMPLEMENTATION-STATUS.md @@ -167,6 +167,9 @@ smoke checks and the verify URLs. As cirrus-baseline did in `baseline-v23`: > `productdomain` and `subdomain` are typed"). It is read from the connection > now; no probe and no orun action was needed, because the platform already > held the fact. +> +> **Since then (2026-10-22).** `productdomain` is not asked either: the card +> asks for `productname` alone, and the domain is set later (below). Verified: the manifest, phases, coverage and rebrand contract tests pass; a **mutation check** — `cloudflare` deleted from the card's @@ -227,3 +230,109 @@ did (where it folded into `01-product`, its only landing): | `orun new --status` (orun 2.58.11, the CI pin) | parses; nine phases | | `testing/leak.test.sh` (orun 2.58.11) | pass — 1083 files, 2 context files, no factory paths | | `testing/placement.test.sh` (orun 2.58.11) | pass — 1083 product files, the same count as with `domain` forced on before; `01 → 08` place through the rebrand; `--resume` keeps the branding | + +## The domain is set later (2026-10-22, `baseline-v4`) + +The console card asked for the product's domain, with help text that said it +did not need to exist — and nothing in the build needed one: the product +answers on workers.dev from its first deploy, every phase probes workers.dev, +and the one component that attaches a domain, `cloudflare-domain`, ships +parked. The owner asked for the domain to stop being an input at bootstrap, +with the logic that uses it kept where it is so it can be set later. As +turso-starter did (its #9). Ships in `baseline-v4` with #364: the tag was +never pushed, and the owner pushes it at this PR's merge commit, so the one +release carries the subdomain source, the removed `domain` switch and this. + +### What shipped + +- `blueprint.yaml` declares no `productdomain` and no `apibaseurl`. The card + derived `apibaseurl` as `https://api.{productdomain}`, and a card can only + derive from inputs it declares, so it left with the domain. The console's + Product step asks for the display name alone. +- `repo-blueprint.yaml`: `productdomain` is optional, default `""`, and its + description names where the domain goes and how it is set later; + `apibaseurl`'s description states the CLI rule below. The values template + still writes `"productdomain": ""`. A hand-run build may pass + `--set productdomain=` for a product that already has its domain. +- `tooling/rebrand/rebrand.mjs` no longer requires `productdomain`. Empty, it + brands the reserved placeholder `.example.com` (RFC 2606) where + `sourceplane.ai` stood as the product domain — intent's `BASE_DOMAIN` and + `CONSOLE_CUSTOM_DOMAIN` (the parked `cloudflare-domain`'s parameters, and + the component's own `baseDomain`), api-edge's `CONSOLE_CUSTOM_DOMAIN` + (CORS), identity-worker's `OAUTH_ALLOWED_CONSOLE_ORIGINS` (which also lists + the workers.dev console, so sign-in works without a domain), the + notifications sender `no-reply@mail.`, billing's + `POLAR_SUCCESS_URL`, and the edge's CORS test fixtures. Company mailboxes + (`@sourceplane.ai`) stay protected. No component logic changed. The + Supabase root configures no auth URLs, so nothing there names the domain. +- The CLI's default API. `apibaseurl` fell back to `https://api.`, + which with the placeholder is a host that can never answer. With no domain + it is now the product's own prod edge on workers.dev, + `https://-api-edge-prod..workers.dev` — the worker + rule's name for `api-edge` deployed `--env prod`, live from the first + deploy. With a domain it is `https://api.`; an explicit + `apibaseurl` still wins. +- `cloudflare-domain`'s README examples named `multi-tenant-saas.app` and + `multi-tenant-saas-web-console-next`, which the rebrand turns into + `.app` and `-web-console-next` — not the product's + placeholder, and not its console Worker when `brandSlug` differs. They now + name `sourceplane.ai` and `sourceplane-web-console-next`, like the + component's `baseDomain` / `workerNamePrefix` and their Terraform defaults, + which already did (the bug cirrus-baseline fixed in its #32). All of them + follow the placeholder and the console Worker; nothing asks an owner to set + them by hand. +- `hooks/render-deployment-docs.sh` already probed the custom domain only + when `.rebrand/values.json` records one, so the empty value skips it; it + now also treats the `*.example.com` placeholder as no domain, and its + narration no longer names the removed `07-domain`. +- The shipped `ai/context/operations.md` gains "Setting the domain later": + every place the domain goes, then replace the placeholder + (`git grep -lF`), create the zone and restore `cloudflare-domain`'s + commented-out `subscribe` block, verify the mail domain, Supabase auth URLs + (none configured), re-point the CLI default if wanted, merge, run the docs + flow. It names the baseline's `sourceplane.ai`, which the rebrand turns + into the product's own placeholder, and no factory path. +- `BOOTSTRAP.md`, `docs/phases/README.md`, `docs/phases/01-scaffold.md` and + the required-inputs sentence of five phase pages: three required inputs + (`reponame`, `productname`, `githuborg`); `productdomain` NOT ASKED; + `06-console.md` and `08-docs.md` say the custom domain is the placeholder + until set. The troubleshooting row for a missing input names + `productname`. + +### What the tests had to become + +- `tests/fixtures/acme.json` carries no domain, so the leak gate and the + placement tier exercise exactly what a console build supplies. +- `testing/placement.test.sh` read the card's `derive` and exited "gone + blind" without it. It now checks the value a no-domain product gets: its + `DEFAULT_API_URL` must be the PLACED, BRANDED api-edge's wrangler name plus + `-prod` on the fixture's subdomain (with `--env prod` read from its + `component.yaml`), and every `BASE_DOMAIN` / non-empty + `CONSOLE_CUSTOM_DOMAIN` in its `intent.yaml` must be the placeholder. It + refuses to pass on nothing: a fixture with a domain or an `apibaseurl`, a + missing worker name, deploy env, `DEFAULT_API_URL` or `BASE_DOMAIN` each + fail it. +- `testing/rebrand.test.sh` gains nine checks: no domain and an empty domain + brand the placeholder; the OAuth origins keep the workers.dev console; the + no-domain CLI default is the prod edge, follows `brandSlug`, and survives + three passes; a given domain brands itself and `https://api.`; an + explicit `apibaseurl` wins. +- `testing/manifest.test.sh` (comment only): the derive-agreement check has + nothing to hold today and stays for the next derived input. +- `baseline.yml`'s blueprint read sets no domain, so CI proves the document + resolves without one. + +### Verification + +| check | result | +|---|---| +| manifest, phases, coverage, rebrand | all pass — 7 milestones agree; 9 phases, 65 modules, 58 narration lines resolve; 44 of 44 components placed; rebrand 24 checks (15 before) | +| component docs `--check` | 44 up to date | +| `orun new --status` with no `productdomain` (orun 2.58.11, the CI pin) | parses; nine phases | +| `testing/leak.test.sh` (orun 2.58.11) | pass — 1083 files derived, unchanged; 2 context files, no factory paths | +| `testing/placement.test.sh` (orun 2.58.11) | pass — 1083 product files, unchanged; `DEFAULT_API_URL` is `https://acme-cloud-api-edge-prod.acme.workers.dev`; the placeholder `acme-cloud.example.com` in `BASE_DOMAIN` ×3 and `CONSOLE_CUSTOM_DOMAIN` ×2, 10 files carry it; `01 → 08` place through the rebrand | +| mutation: the old CLI rule (`https://api.` always) | `rebrand.test.sh` fails 3 checks, `placement.test.sh` fails naming `https://api.acme-cloud.example.com`; restored, both pass | +| mutation: no placeholder (empty domain stays empty) | `rebrand.test.sh` fails 3 checks, `placement.test.sh` fails on `BASE_DOMAIN ''`; restored, both pass | +| `cloudflare-domain`, branded with no domain | `baseDomain: acme-cloud.example.com`, `workerNamePrefix: acme-cloud-web-console-next` (= the console Worker), the same in the Terraform defaults and README; with `brandSlug: acme`, `acme-web-console-next` = the console Worker | +| the documented replacement, on a placed product | `git grep -lF acme-cloud.example.com` lists 10 files; the `perl` one-liner leaves 0, and `BASE_DOMAIN` / `baseDomain` read `acme.dev` | +| a second rebrand pass over the placed product | 0 files affected; `DEFAULT_API_URL` unchanged | diff --git a/testing/manifest.test.sh b/testing/manifest.test.sh index 4ae5cab8..a6ac6ef8 100755 --- a/testing/manifest.test.sh +++ b/testing/manifest.test.sh @@ -193,6 +193,13 @@ for path in manifests: # run by hand passes nothing and rebrand's fallback wins. One rule, two # implementations — which is the thing this file's header warns about, # unless something holds them equal. This does. + # + # Since the console stopped asking for the domain, the card derives + # nothing: `apibaseurl` left it with `productdomain` (a card can only + # derive from inputs it declares), and rebrand's fallback alone picks + # the value — `https://api.`, or with no domain the product's + # prod edge on workers.dev, which placement.test.sh checks in a placed + # product. This stays for the next input that derives. if derive is not None and (root / REBRAND).exists(): js = (root / REBRAND).read_text(errors="replace") for m in re.finditer(r"const (\w+) = values\.\w+ \?\? `([^`]+)`", js): diff --git a/testing/placement.test.sh b/testing/placement.test.sh index 45311a31..6a29972f 100755 --- a/testing/placement.test.sh +++ b/testing/placement.test.sh @@ -20,9 +20,9 @@ # because that already happened once with a version pin; # 3. brand it as `01-scaffold`'s hook chain does, then `rebrand.mjs --verify`; # 4. run the leak rules over the REAL FILES rather than the derivation; -# 5. check the API base the product ends up with against the rule -# `blueprint.yaml` states as its `derive` — the last mile of BE3's gate, -# in the product; +# 5. check the API base and the domain the product ends up with: built with +# no domain, as a console build is, its CLI defaults to its own prod edge +# on workers.dev and the domain's places carry `.example.com`; # 6. THE PHASED SEQUENCE THROUGH A REBRAND: place 01, brand, then place the # phases that follow. This is the step no test in this repository has ever # taken, and it is where BE-O12's two defects lived. @@ -181,30 +181,74 @@ print(f" {len(placed)} product files; ai/context is exactly " f"{len(ALLOWED_AI)}; no factory, no provenance prose") PY -# ── the derived API base, in the product ─────────────────────────────────── -# BE3 states `derive: "https://api.{productdomain}"` in blueprint.yaml and holds -# it equal to rebrand.mjs's fallback. Both of those are checks on the RULES. -# This checks the value a product ends up with. -echo "── the API base the product ends up with" +# ── the API base and the domain, in the product ──────────────────────────── +# The console asks for no domain, so the fixture carries none, and BE3's +# `derive: "https://api.{productdomain}"` left the card with it (a card can +# only derive from inputs it declares). What a product built that way must +# end up with, checked in the product rather than as a rule: +# +# - its CLI's DEFAULT_API_URL is its own prod edge on workers.dev. The name +# is read from the PLACED, BRANDED api-edge — its wrangler `name` plus the +# `--env prod` its component.yaml deploys — so the CLI and the worker it +# points at are held to one rule. `https://api.` could never +# answer; +# - every place the domain goes carries the reserved placeholder +# `.example.com`, for an owner to replace later. +# +# Neither half can pass on nothing: a fixture that gains a domain, a brand.ts +# without DEFAULT_API_URL, an api-edge that stops deploying `--env prod`, or an +# intent without BASE_DOMAIN fails here instead of going blind. +echo "── the API base and the domain the product ends up with" python3 - "$tree" "$root" <<'PY' import json, pathlib, re, sys -import yaml tree, root = pathlib.Path(sys.argv[1]), pathlib.Path(sys.argv[2]) -man = yaml.safe_load((root / "blueprint.yaml").read_text())["spec"] -derive = next((f.get("derive") for f in man["inputs"] if f["key"] == "apibaseurl"), None) -if not derive: - sys.exit("blueprint.yaml no longer derives apibaseurl — this check has gone blind") vals = json.loads((root / "tests/fixtures/acme.json").read_text()) -want = re.sub(r"\{([a-z]+)\}", - lambda m: {"productdomain": vals["productdomain"]}[m.group(1)], derive) +if (vals.get("productdomain") or "").strip(): + sys.exit("tests/fixtures/acme.json carries a productdomain — a console build " + "supplies none, so this would no longer check what one produces") +if (vals.get("apibaseurl") or "").strip(): + sys.exit("tests/fixtures/acme.json carries an apibaseurl — the CLI default " + "would be that, and the no-domain rule would go unchecked") + +wr = (tree / "apps/api-edge/wrangler.template.jsonc").read_text() +name = re.search(r'"name":\s*"([a-z0-9-]+)"', wr) +if not name: + sys.exit("apps/api-edge/wrangler.template.jsonc has no worker name — gone blind") +if not name.group(1).startswith(vals["reponame"] + "-"): + sys.exit(f"FAIL: the placed api-edge is named {name.group(1)!r}, not branded " + f"with {vals['reponame']!r}") +comp = (tree / "apps/api-edge/component.yaml").read_text() +if not re.search(r"^\s*deployCommand:.*--env prod\s*$", comp, re.M): + sys.exit("apps/api-edge/component.yaml no longer deploys `--env prod` — gone blind") +want = f"https://{name.group(1)}-prod.{vals['subdomain']}.workers.dev" brand = (tree / "packages/cli/src/brand.ts").read_text() m = re.search(r'DEFAULT_API_URL = "([^"]+)"', brand) if not m: sys.exit("packages/cli/src/brand.ts no longer declares DEFAULT_API_URL — gone blind") if m.group(1) != want: - sys.exit(f"FAIL: the product's DEFAULT_API_URL is {m.group(1)!r}; " - f"blueprint.yaml's derive over this fixture says {want!r}") -print(f" DEFAULT_API_URL is {want} — the rule blueprint.yaml declares") + sys.exit(f"FAIL: the product's DEFAULT_API_URL is {m.group(1)!r}; built with no " + f"domain it must be its own prod edge, {want!r}") +print(f" DEFAULT_API_URL is {want} — api-edge's prod worker") + +placeholder = f"{vals['reponame']}.example.com" +intent = (tree / "intent.yaml").read_text() +bases = re.findall(r"^[ \t]*BASE_DOMAIN:[ \t]*(.*?)[ \t]*$", intent, re.M) +consoles = [c for c in re.findall(r"^[ \t]*CONSOLE_CUSTOM_DOMAIN:[ \t]*(.*?)[ \t]*$", intent, re.M) + if c not in ('""', "''")] +if not bases or not consoles: + sys.exit("intent.yaml carries no BASE_DOMAIN or CONSOLE_CUSTOM_DOMAIN — gone blind") +for b in bases: + if b != placeholder: + sys.exit(f"FAIL: intent.yaml's BASE_DOMAIN is {b!r}, not the placeholder {placeholder!r}") +for c in consoles: + if not c.endswith("." + placeholder): + sys.exit(f"FAIL: intent.yaml's CONSOLE_CUSTOM_DOMAIN is {c!r}, not under {placeholder!r}") +carrying = sorted( + str(p.relative_to(tree)) for p in tree.rglob("*") + if p.is_file() and ".git" not in p.parts and ".orun" not in p.parts + and placeholder in p.read_text(errors="replace")) +print(f" the domain is the placeholder {placeholder}: BASE_DOMAIN x{len(bases)}, " + f"CONSOLE_CUSTOM_DOMAIN x{len(consoles)}; {len(carrying)} files carry it") PY # ── THE PHASED SEQUENCE THROUGH A REBRAND ────────────────────────────────── diff --git a/testing/rebrand.test.sh b/testing/rebrand.test.sh index 6b72bd52..a48cba85 100755 --- a/testing/rebrand.test.sh +++ b/testing/rebrand.test.sh @@ -112,6 +112,49 @@ check "a token keeps the word boundaries its value had" \ "{$base}" packages/cli/notes.yaml 'id: sourceplane.aisourceplane' \ 'id: altocumulus.devsourceplane' +# THE DOMAIN IS SET LATER. The console asks for none, so the values file a +# console build writes has an empty `productdomain`, and the rebrand writes the +# reserved placeholder `.example.com` wherever the domain goes. The +# CLI's default API cannot be `https://api.`, which never answers: +# it is the product's own prod edge on workers.dev, named by the worker rule +# (`-api-edge-prod`). A hand-run build that passes a domain keeps +# `https://api.`. +echo "── rebrand: no domain given, and a domain given" +nodomain='{"reponame":"acme-cloud","productname":"Acme Cloud","githuborg":"acme-inc","subdomain":"acme"}' +check "no domain given: the reserved placeholder, for an owner to replace later" \ + "$nodomain" intent.yaml ' BASE_DOMAIN: sourceplane.ai' \ + ' BASE_DOMAIN: acme-cloud.example.com' +check "an empty domain is no domain" \ + '{"reponame":"acme-cloud","productname":"Acme Cloud","productdomain":""}' \ + intent.yaml ' BASE_DOMAIN: sourceplane.ai' \ + ' BASE_DOMAIN: acme-cloud.example.com' +check "no domain: the OAuth console origins keep the workers.dev console" \ + "$nodomain" apps/identity-worker/wrangler.template.jsonc \ + ' "OAUTH_ALLOWED_CONSOLE_ORIGINS": "https://prod.sourceplane.ai,https://sourceplane-web-console-next-prod.rahulvarghesepullely.workers.dev"' \ + ' "OAUTH_ALLOWED_CONSOLE_ORIGINS": "https://prod.acme-cloud.example.com,https://acme-cloud-web-console-next-prod.acme.workers.dev"' +check "no domain: the CLI defaults to the product's prod edge on workers.dev" \ + "$nodomain" packages/cli/src/brand.ts 'export const DEFAULT_API_URL = "https://api.sourceplane.dev";' \ + 'export const DEFAULT_API_URL = "https://acme-cloud-api-edge-prod.acme.workers.dev";' +check "…named by the worker rule, so a brandSlug renames it too" \ + '{"reponame":"acme-cloud","productname":"Acme Cloud","brandSlug":"acme","subdomain":"acme"}' \ + packages/cli/src/brand.ts 'export const DEFAULT_API_URL = "https://api.sourceplane.dev";' \ + 'export const DEFAULT_API_URL = "https://acme-api-edge-prod.acme.workers.dev";' +check "…and survives every later phase's pass" \ + "$nodomain" packages/cli/src/brand.ts 'export const DEFAULT_API_URL = "https://api.sourceplane.dev";' \ + 'export const DEFAULT_API_URL = "https://acme-cloud-api-edge-prod.acme.workers.dev";' 3 +check "a domain given: the domain where the domain goes" \ + '{"reponame":"acme-cloud","productname":"Acme Cloud","productdomain":"acme.dev","subdomain":"acme"}' \ + intent.yaml ' BASE_DOMAIN: sourceplane.ai' \ + ' BASE_DOMAIN: acme.dev' +check "a domain given: the CLI defaults to api." \ + '{"reponame":"acme-cloud","productname":"Acme Cloud","productdomain":"acme.dev","subdomain":"acme"}' \ + packages/cli/src/brand.ts 'export const DEFAULT_API_URL = "https://api.sourceplane.dev";' \ + 'export const DEFAULT_API_URL = "https://api.acme.dev";' +check "an explicit apibaseurl wins either way" \ + '{"reponame":"acme-cloud","productname":"Acme Cloud","apibaseurl":"https://edge.acme.dev"}' \ + packages/cli/src/brand.ts 'export const DEFAULT_API_URL = "https://api.sourceplane.dev";' \ + 'export const DEFAULT_API_URL = "https://edge.acme.dev";' + # --verify runs in every phase of a bootstrap. Without the product's values it # cannot tell the product's own identity from a baseline leftover, and a product # whose name contains `Sourceplane` failed it in every phase; with them it diff --git a/tests/fixtures/acme.json b/tests/fixtures/acme.json index 6813d825..38c21a3c 100644 --- a/tests/fixtures/acme.json +++ b/tests/fixtures/acme.json @@ -3,16 +3,17 @@ "The inputs a Tier 1 dry instantiation renders with (saas-bootstrap-engine BE5).", "Acme is not a real product and never becomes one: this tree is placed into a", "temp directory, asserted against, and deleted. The values are chosen to be", - "AWKWARD rather than tidy — a two-word product name, a hyphenated repo slug, a", - "multi-label domain — because a fixture that only uses values the templates", - "were written against proves the templates work on the values they were", - "written against.", + "AWKWARD rather than tidy — a two-word product name, a hyphenated repo slug,", + "and NO domain: a console build asks for none, so the placeholder", + ".example.com is what a product is born with, and the CLI defaults", + "to the product's own prod edge on workers.dev — 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-cloud", "productname": "Acme Cloud", - "productdomain": "acme.dev", "githuborg": "acme-inc", "subdomain": "acme", "orunWorkspace": "ws_0000000000000000000000000000000f", diff --git a/tooling/rebrand/rebrand.mjs b/tooling/rebrand/rebrand.mjs index 08a96815..d0694108 100644 --- a/tooling/rebrand/rebrand.mjs +++ b/tooling/rebrand/rebrand.mjs @@ -19,11 +19,12 @@ // { // "reponame": "acme-cloud", // required — repo slug // "productname": "Acme Cloud", // required — display name -// "productdomain": "acme.dev", // required — product domain +// "productdomain": "acme.dev", // optional — default .example.com (set later) // "pascalName": "AcmeCloud", // default: productname, non-alnum stripped // "brandSlug": "acme", // default: reponame // "cliBin": "acme", // default: reponame -// "apibaseurl": "https://api.acme.dev", // default: https://api. +// "apibaseurl": "https://api.acme.dev", // default: https://api., or with no +// // domain https://-api-edge-prod..workers.dev // "subdomain": "my-subdomain", // default: "your-workers-subdomain" // "salesEmail": "sales@acme.dev" // optional: keeps baseline mailbox if absent // } @@ -77,7 +78,7 @@ if (valuesPath) { for (const [key, old] of Object.entries(LEGACY)) { if (values[key] === undefined && values[old] !== undefined) values[key] = values[old]; } - 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); @@ -101,12 +102,27 @@ if (valuesPath) { // 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 product 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 pascalName = values.pascalName ?? productname.replace(/[^A-Za-z0-9]/g, ""); const brandSlug = values.brandSlug ?? reponame; const cliBin = values.cliBin ?? reponame; -const apibaseurl = values.apibaseurl ?? `https://api.${productdomain}`; const subdomain = values.subdomain ?? "your-workers-subdomain"; +// The CLI's default API. With a domain it is `https://api.`. With none, +// `api.` would point every CLI at a host that can never answer, so +// it is the product's own prod edge on workers.dev, live from the first deploy: +// api-edge deploys `--env prod` (apps/api-edge/component.yaml) as its wrangler +// name `api-edge` + `-prod`, which the worker rule below brands as +// `-api-edge-prod`. Re-pointing it at a domain later is an edit to +// packages/cli/src/brand.ts. +const apibaseurl = + (values.apibaseurl ?? "").trim() || + ((values.productdomain ?? "").trim() + ? `https://api.${productdomain}` + : `https://${brandSlug}-api-edge-prod.${subdomain}.workers.dev`); const salesEmail = values.salesEmail; // optional // A `secret://///` ref names the WORKSPACE // first and the project (repo) second. Here the two differ (`halo` /