diff --git a/BOOTSTRAP.md b/BOOTSTRAP.md index d1048f2..0fd82c7 100644 --- a/BOOTSTRAP.md +++ b/BOOTSTRAP.md @@ -67,6 +67,12 @@ orun new --blueprint repo-blueprint.yaml \ --set subdomain= ``` +`subdomain` is the workers.dev subdomain of the Cloudflare account you deploy +into (Workers & Pages → your subdomain). A build started from the console, or +with `orun baseline new --from bst_…`, never asks for it: the platform reads +it from the workspace's Cloudflare connection, the same one the deploy tokens +mint from. Only a hand-run build like this one passes it. + **`--run-hooks` is the difference between placing files and bootstrapping a product.** Without it `orun new` writes the tree and stops: no repository, no landing, no convergence watch, no probe. That is deliberate — it is what diff --git a/ai/context/current.md b/ai/context/current.md index fdddf54..03f6d27 100644 --- a/ai/context/current.md +++ b/ai/context/current.md @@ -19,8 +19,7 @@ per environment), then records what went live (`02-docs`). | | | |---|---| -| Latest tag | `baseline-v1` (PD4) | -| On `main` since | PD5 — the cirrus standard (no kiox, generated component docs, this context pack) | +| Latest tag | `baseline-v2` (PD5 — the cirrus standard: no kiox, generated component docs, this context pack, and the console card reading `subdomain` from the Cloudflare connection); `baseline-v1` is PD4 | | Proven live | No. Everything short of the platform is proven offline in Baseline CI, a migrated local Postgres served through the built Worker included; a live bootstrap from a tag is still to come (risk PD-J) | ## Where to read @@ -35,7 +34,6 @@ per environment), then records what went live (`02-docs`). ## Next -1. Bootstrap one product from a tag against a workspace with Cloudflare and - Supabase connections and room for two Supabase projects (PD-F), and - record its timings (closes PD-J). -2. Cut the next `baseline-vN` with `tag.yml` so the registry can pin PD5. +1. Bootstrap one product from `baseline-v2` against a workspace with + Cloudflare and Supabase connections and room for two Supabase projects + (PD-F), and record its timings (closes PD-J). diff --git a/ai/context/decisions.md b/ai/context/decisions.md index a4f6980..8d33827 100644 --- a/ai/context/decisions.md +++ b/ai/context/decisions.md @@ -18,3 +18,4 @@ reads in order. | 10 | stack-tectonic 0.19.0, not 0.20.0 | 0.20.0's lane-scoped install is refused by Turbopack | IMPLEMENTATION-STATUS (PD4) | | 11 | orun is pinned only where it runs (the `orun-action` `version:` in each workflow); no kiox | `kiox.yaml` pinned a version (v2.15.0) nothing ran | IMPLEMENTATION-STATUS (PD5) | | 12 | Component docs are generated from the manifests and checked in CI | A hand-written copy of the dependency graph, bindings and migrations drifts silently | `tooling/catalog/gen-component-docs.py` | +| 13 | The console card reads `subdomain` from the Cloudflare connection (`from: connection.cloudflare.workersSubdomain`); only a hand-run build passes it | It belongs to the account like its id and has one right answer; a typed one could only be wrong, and wrong showed up after deploy (cirrus-baseline since baseline-v23) | `blueprint.yaml`, IMPLEMENTATION-STATUS (PD-7) | diff --git a/blueprint.yaml b/blueprint.yaml index f4d6631..95027d3 100644 --- a/blueprint.yaml +++ b/blueprint.yaml @@ -96,6 +96,19 @@ spec: pattern: "^[a-z0-9][a-z0-9-]{0,62}$" help: The workers.dev subdomain of the Cloudflare account the app deploys 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 the site origin the build bakes into the page's Open + # Graph link, the 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. The console + # renders no field for it, and an account with no workers.dev subdomain + # refuses the build at the door, naming the fix, before anything is + # created. + from: connection.cloudflare.workersSubdomain # ── PREVIEW ONLY. repo-blueprint.yaml's `orun.integrations/reconcile@v1` # hooks mint these, brokered, during 01-product. ───────────────────────── diff --git a/docs/phases/README.md b/docs/phases/README.md index 8993de8..1e5bebd 100644 --- a/docs/phases/README.md +++ b/docs/phases/README.md @@ -59,9 +59,11 @@ the blueprint's **required** inputs — `reponame`, `productname`, must be supplied on every invocation, single-phase ones included. A `--values` file is easier than repeating `--set`. -- `subdomain` — the workers.dev subdomain of the Cloudflare account. It is - in every URL the phases probe and in the site origin the build bakes into - the page's Open Graph link. +- `subdomain` — the workers.dev subdomain of the Cloudflare account you + deploy into. It is in every URL the phases probe and in the site origin + the build bakes into the page's Open Graph link. A console or + `--from bst_…` build reads it from the Cloudflare connection; pass it only + for a hand-run build. - `orunWorkspace` — workspace id (`ws_…`). Unset, it is the workspace the build runs in (`from: workspace`); with none anywhere, a placeholder that fails loudly rather than silently claiming another tenant's workspace. diff --git a/repo-blueprint.yaml b/repo-blueprint.yaml index 430a0c4..9a6b7f8 100644 --- a/repo-blueprint.yaml +++ b/repo-blueprint.yaml @@ -56,7 +56,11 @@ inputs: default: "your-workers-subdomain" description: >- The workers.dev subdomain of the Cloudflare account the app deploys - into — its URLs, the site origin its build bakes in, the probes. + into — its URLs, the site origin its build bakes in, the probes. A + console or `--from bst_…` build gets it from the workspace's Cloudflare + connection (blueprint.yaml declares + `from: connection.cloudflare.workersSubdomain`); pass it with --set + only for a hand-run build. repoPrivate: type: boolean default: true diff --git a/specs/epics/README.md b/specs/epics/README.md index 200f589..247ab62 100644 --- a/specs/epics/README.md +++ b/specs/epics/README.md @@ -7,6 +7,6 @@ folder is the adoption; the merge creates the epic in the workspace. | Epic | Cluster | Status | What it is | |------|---------|--------|------------| -| [`postgres-drizzle-starter/`](./postgres-drizzle-starter/) | **PD** | ✅ Shipped (`baseline-v1`); live bootstrap pending | Vercel's Postgres + Drizzle Next.js Starter, equivalent in code and function, on Cloudflare Workers with Supabase Postgres through Hyperdrive — and an Orun baseline that instantiates it in one landing (PD4) | +| [`postgres-drizzle-starter/`](./postgres-drizzle-starter/) | **PD** | ✅ Shipped (`baseline-v2`); live bootstrap pending | Vercel's Postgres + Drizzle Next.js Starter, equivalent in code and function, on Cloudflare Workers with Supabase Postgres through Hyperdrive — and an Orun baseline that instantiates it in one landing (PD4) | As-built ≠ intent: what shipped lives in each epic's `IMPLEMENTATION-STATUS.md`. diff --git a/specs/epics/postgres-drizzle-starter/IMPLEMENTATION-STATUS.md b/specs/epics/postgres-drizzle-starter/IMPLEMENTATION-STATUS.md index 30a9b4b..f91a159 100644 --- a/specs/epics/postgres-drizzle-starter/IMPLEMENTATION-STATUS.md +++ b/specs/epics/postgres-drizzle-starter/IMPLEMENTATION-STATUS.md @@ -10,7 +10,7 @@ the code departed from `design.md` or from the upstream template. | PD2 — Supabase and Hyperdrive from Terraform | ✅ Shipped (validated; apply gated on a linked workspace) | [#3](https://github.com/sourceplane/postgres-drizzle-starter/pull/3) | | PD3 — ready to instantiate | ✅ Shipped | [#4](https://github.com/sourceplane/postgres-drizzle-starter/pull/4) | | PD4 — a baseline | ✅ Shipped (offline-proven; no live bootstrap yet, risk PD-J) | [#5](https://github.com/sourceplane/postgres-drizzle-starter/pull/5) (PD-5), tagged `baseline-v1` | -| PD5 — the cirrus standard | ✅ Shipped | PD-6 — on `main` after `baseline-v1`, not yet tagged | +| PD5 — the cirrus standard | ✅ Shipped | [#6](https://github.com/sourceplane/postgres-drizzle-starter/pull/6) (PD-6), [#7](https://github.com/sourceplane/postgres-drizzle-starter/pull/7) (PD-7), tagged `baseline-v2` | ## Departures from the upstream template @@ -187,6 +187,42 @@ Nothing about the product changed. What changed is the baseline around it: | context pack | `operations.md`, `deployment.md` | plus `current.md`, `decisions.md`, `open-risks.md` | cirrus-baseline's shape; the three new pages are this repository's own and no module places them (the leak gate still allows exactly two) | | status | PD4 "in review" on its branch; an empty `metadataBase` heading; an unlabeled Verified section's "4 tests"; no risk for the missing live bootstrap | PD4 shipped and tagged `baseline-v1`; the heading says what changed; the section is labeled PD1–PD3; risk PD-J (OPEN) | the tag existed; the documents had not caught up | +### The subdomain from the Cloudflare connection (PD-7) + +The console card's `subdomain` input was typed by hand, though it belongs to +the Cloudflare account the same way its id does and has exactly one right +answer. A wrong value surfaced only after deploy: in the site origin the +build bakes into the page's Open Graph link, the smoke checks and the verify +URLs. `blueprint.yaml` now declares +`from: connection.cloudflare.workersSubdomain`, as cirrus-baseline does since +`baseline-v23`: the Cloudflare integration reads the subdomain from the +account at connect and on its hourly health check, and the bootstrap door +fills the input from the connection the build is bound to — the same one +`CLOUDFLARE_ACCOUNT_ID` and the deploy tokens mint from. The console renders +no field for it, and an account with no workers.dev subdomain is refused at +the door, naming the fix. + +- `testing/manifest.test.sh` takes cirrus-baseline's check: a + `connection..` source is accepted, and only when the card's + `spec.requires.integrations` lists the provider (this card lists + `[github, cloudflare, supabase]`). +- `repo-blueprint.yaml` keeps the input and its default; its description, + `BOOTSTRAP.md` and `docs/phases/README.md` say a hand-run `orun new` still + passes `--set subdomain`. +- Nothing a product runs changed: no app, package, Terraform, migration, + test or tooling file. + +Verified: `testing/{manifest,phases,coverage,rebrand,retouch,bootstrap-defer}.test.sh` +green; `gen-component-docs.py --check` green (7 components); at v2.58.11, +`orun new --status` on `repo-blueprint.yaml` (`01-product` 126 files), +`testing/leak.test.sh` (126 files derived, 123 text files read) and +`testing/placement.test.sh` (126 tracked files; `--resume` changes nothing); +`orun task check PD-7` complete. Mutation check: with `cloudflare` removed +from `spec.requires.integrations`, `manifest.test.sh` fails with the one +finding `inputs[subdomain].from is 'connection.cloudflare.workersSubdomain' +but spec.requires.integrations does not list cloudflare`; restored, it +passes. + ## Verified (PD5) - `testing/{manifest,phases,coverage,rebrand,retouch,bootstrap-defer}.test.sh` diff --git a/specs/epics/postgres-drizzle-starter/README.md b/specs/epics/postgres-drizzle-starter/README.md index c82afae..6c892c3 100644 --- a/specs/epics/postgres-drizzle-starter/README.md +++ b/specs/epics/postgres-drizzle-starter/README.md @@ -8,7 +8,7 @@ The port keeps the page, the table component, the refresh button, the schema and | Field | Value | |-------|-------| -| Status | ✅ PD0–PD4 shipped (#1–#5), tagged `baseline-v1`; PD5 (the cirrus standard, PD-6) on `main`, not yet tagged. Terraform applies, a live db-migrate apply and a live deploy are proven only by a live bootstrap (risk PD-J) | +| Status | ✅ PD0–PD5 shipped (#1–#7; PD4 tagged `baseline-v1`, PD5 — the cirrus standard, PD-6 and PD-7 — tagged `baseline-v2`). Terraform applies, a live db-migrate apply and a live deploy are proven only by a live bootstrap (risk PD-J) | | Cluster | **PD** (PD0–PD5) | | Owner(s) | `apps/web` (the page, `lib/db.ts`, `lib/drizzle.ts`, `lib/seed.ts`) · `packages/db` (the migrations and their runner) · `tests/web`, `tests/db` · `infra/terraform/{supabase,cloudflare-hyperdrive}`, `infra/db-migrate` | | Builds on | `lumen`: the `supabase` and `cloudflare-hyperdrive` roots and the per-request `postgres` client; the `saas-starter` port's `getDb()` pattern | @@ -16,7 +16,7 @@ The port keeps the page, the table component, the refresh button, the schema and | Changes | The client resolution (module-level `POSTGRES_URL` → per-request Hyperdrive), the Workers build, tests, two Terraform roots, the deploy contract; page copy says Cloudflare | | Decisions locked | (1) Per-request client, Hyperdrive first, `POSTGRES_URL` fallback. (2) ~~Seed-on-first-use kept as upstream; no `db-migrate` for one table~~ → PD4: the table is `db-migrate`'s, applied before the app serves, with row-level security; the page seeds only the rows, on an empty table. (3) `wrangler.jsonc` rendered from the template: committed as the fixture render (the composition checks it exists before the build), re-rendered per environment by the deploy lanes (PD4; it was git-ignored before). (4) Drizzle moves from 0.28 to the current line with the schema as written. (5) Infra before app on main: supabase → cloudflare-hyperdrive → db-migrate → web, enforced; advisory on pull requests (PD4). | | Gate | PD1 is the first user-visible rung. PD2 applies only with a linked workspace (Supabase + Cloudflare connections); verified by `terraform validate`. | -| Shipped as | `baseline-v1` ([#5](https://github.com/sourceplane/postgres-drizzle-starter/pull/5)), then PD5 on `main`; proven offline (Baseline CI: migrated into a local Postgres and served through the built Worker under `wrangler dev`), deploy gated until a workspace is linked | +| Shipped as | `baseline-v1` ([#5](https://github.com/sourceplane/postgres-drizzle-starter/pull/5)), `baseline-v2` ([#6](https://github.com/sourceplane/postgres-drizzle-starter/pull/6), [#7](https://github.com/sourceplane/postgres-drizzle-starter/pull/7)); proven offline (Baseline CI: migrated into a local Postgres and served through the built Worker under `wrangler dev`), deploy gated until a workspace is linked | ## Read order @@ -34,4 +34,4 @@ The port keeps the page, the table component, the refresh button, the schema and | PD2 — Supabase and Hyperdrive from Terraform | the two roots | they validate; the wiring key matches the template | | PD3 — ready to instantiate | README, as-built status | a reader can run, test, preview and deploy it | | PD4 — a baseline | card, build document, rename, bootstrap tooling, the migrations and `db-migrate`, row-level security, the product's README and context pack, tests | a new product goes from nothing to live on stage and prod in one landing; Baseline CI green | -| PD5 — the cirrus standard | no kiox, generated component docs, the context pack, status that agrees with the tags | Baseline CI green with the docs check | +| PD5 — the cirrus standard | no kiox, generated component docs, the context pack, status that agrees with the tags; the console card reads `subdomain` from the Cloudflare connection | Baseline CI green with the docs check | diff --git a/specs/epics/postgres-drizzle-starter/epic.yaml b/specs/epics/postgres-drizzle-starter/epic.yaml index e5a9389..970e425 100644 --- a/specs/epics/postgres-drizzle-starter/epic.yaml +++ b/specs/epics/postgres-drizzle-starter/epic.yaml @@ -44,4 +44,5 @@ spec: - "every component carries generated docs/{overview,architecture,runbook}.md, and Baseline CI fails a pull request whose manifests and pages disagree" - "ai/context carries this repository's current.md, decisions.md and open-risks.md, and none of them ships to a product" - "every milestone's status row agrees with the tags" - tasks: [PD-6] + - "the console card reads subdomain from the Cloudflare connection (from: connection.cloudflare.workersSubdomain), as cirrus-baseline since baseline-v23" + tasks: [PD-6, PD-7] diff --git a/specs/epics/postgres-drizzle-starter/implementation-plan.md b/specs/epics/postgres-drizzle-starter/implementation-plan.md index b8c8ebf..de55ec6 100644 --- a/specs/epics/postgres-drizzle-starter/implementation-plan.md +++ b/specs/epics/postgres-drizzle-starter/implementation-plan.md @@ -56,7 +56,7 @@ way cirrus-baseline v22 builds a product — in ONE landing: first requests leaving exactly the three seed rows — while the Data API's roles read and write none of it -## PD5 — the cirrus standard (PD-6) ✅ +## PD5 — the cirrus standard (PD-6, PD-7) ✅ Bring the baseline to cirrus-baseline's standard, with nothing about the product itself changing. @@ -73,6 +73,12 @@ product itself changing. repository's own, so no module places them. - **Status that agrees with the tags.** PD4 is shipped and tagged; the risk register names the missing live bootstrap (PD-J). +- **The subdomain from the Cloudflare connection (PD-7).** The card's + `subdomain` input declares `from: connection.cloudflare.workersSubdomain`, + as cirrus-baseline since `baseline-v23`: the console fills it from the + connection the build is bound to and renders no field; `manifest.test.sh` + accepts the source only while the card requires `cloudflare`. A hand-run + build still passes `--set subdomain`. **Done when** - `git grep -i kiox` finds only this milestone's own record, and the leak gate and the offline diff --git a/tasks/PD-7.TaskContract.yaml b/tasks/PD-7.TaskContract.yaml new file mode 100644 index 0000000..d4f8c29 --- /dev/null +++ b/tasks/PD-7.TaskContract.yaml @@ -0,0 +1,24 @@ +apiVersion: orun.io/v1 +kind: TaskContract +metadata: + name: PD-7 + title: "The subdomain from the Cloudflare connection" +spec: + goal: The console card reads the workers.dev subdomain from the workspace's Cloudflare connection (from connection.cloudflare.workersSubdomain), as cirrus-baseline does since baseline-v23, so a console or `--from bst_…` build never asks for it and it always names the account the deploy tokens mint from; a hand-run build still passes it with --set + affects: + - blueprint.yaml + - repo-blueprint.yaml + - testing/manifest.test.sh + - BOOTSTRAP.md + - docs/phases/README.md + - ai/context/current.md + - ai/context/decisions.md + - specs/** + - tasks/** + doneWhen: + - "blueprint.yaml's subdomain input declares `from: connection.cloudflare.workersSubdomain`, and spec.requires.integrations lists cloudflare" + - testing/manifest.test.sh accepts that source only when the card requires the provider's integration, and fails naming the input when it does not (mutation-checked) + - BOOTSTRAP.md, docs/phases/README.md and repo-blueprint.yaml say a hand-run build still passes --set subdomain + - the contract tests, the docs check, the leak gate and the offline bootstrap are green + gates: + - checks diff --git a/testing/manifest.test.sh b/testing/manifest.test.sh index 3fd6af8..5374cb5 100755 --- a/testing/manifest.test.sh +++ b/testing/manifest.test.sh @@ -217,9 +217,20 @@ for path in manifests: # field for it (saas-bootstrap-console BC-K5). Two ways to get it # wrong, and the platform refuses both — check them here too, so the # mistake is caught in this repo rather than at a live bootstrap. + # + # A `connection..` source is read from the connection + # the build is bound to, so the provider must be one the manifest + # requires — the platform's parser refuses it otherwise. + sources_known = ("repo.name", "repo.owner", "repo.fullName", + "connection.cloudflare.workersSubdomain") src = field.get("from") - if src is not None and src not in ("repo.name", "repo.owner", "repo.fullName"): - B(f"inputs[{key}].from is {src!r} — must be repo.name, repo.owner or repo.fullName") + if src is not None and src not in sources_known: + B(f"inputs[{key}].from is {src!r} — must be one of {', '.join(sources_known)}") + if isinstance(src, str) and src.startswith("connection."): + provider = src.split(".")[1] + if provider not in ((spec.get("requires") or {}).get("integrations") or []): + B(f"inputs[{key}].from is {src!r} but spec.requires.integrations " + f"does not list {provider} — there is no connection to read it from") # ── secrets: BOTH or NEITHER, checked both ways ─────────────────────── declared = {s.get("key"): (s.get("provider"), s.get("template")) for s in (spec.get("secrets") or [])}