From 8c31db68bb33397098c2f6e41eb8b42e20cf83f8 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 18 Oct 2026 14:20:44 +0000 Subject: [PATCH 1/6] =?UTF-8?q?SP6:=20the=20cirrus=20standard=20=E2=80=94?= =?UTF-8?q?=20no=20kiox,=20generated=20component=20docs,=20the=20context?= =?UTF-8?q?=20pack?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Remove kiox.yaml/kiox.lock and their two blueprint modules: nothing ran the kiox pin (v2.15.0); every workflow pins orun through orun-action. - Generate docs/{overview,architecture,runbook}.md for all six components from what each declares (tooling/catalog/gen-component-docs.py), and fail Baseline CI when they drift (--check). - Add ai/context/{current,decisions,open-risks}.md (this repository's own; nothing places them). - Close out SP5 (shipped, tagged baseline-v1) and record SP6 (SP-7). Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01D8AmgTwmnp4M8mgmnS9aha --- .github/workflows/baseline.yml | 6 + ai/context/current.md | 43 ++ ai/context/decisions.md | 20 + ai/context/open-risks.md | 17 + apps/web/docs/architecture.md | 20 + apps/web/docs/overview.md | 21 + apps/web/docs/runbook.md | 40 ++ infra/db-migrate/docs/architecture.md | 18 + infra/db-migrate/docs/overview.md | 20 + infra/db-migrate/docs/runbook.md | 19 + infra/terraform/supabase/docs/architecture.md | 34 ++ infra/terraform/supabase/docs/overview.md | 20 + infra/terraform/supabase/docs/runbook.md | 20 + kiox.lock | 11 - kiox.yaml | 6 - packages/db/docs/architecture.md | 11 + packages/db/docs/overview.md | 20 + packages/db/docs/runbook.md | 25 + repo-blueprint.yaml | 12 +- specs/epics/README.md | 2 +- .../IMPLEMENTATION-STATUS.md | 38 +- specs/epics/subscription-payments/README.md | 7 +- specs/epics/subscription-payments/design.md | 2 +- specs/epics/subscription-payments/epic.yaml | 7 + .../implementation-plan.md | 25 +- tasks/SP-7.TaskContract.yaml | 31 ++ testing/phases.test.sh | 2 +- tests/db/docs/architecture.md | 8 + tests/db/docs/overview.md | 18 + tests/db/docs/runbook.md | 26 + tests/web/docs/architecture.md | 12 + tests/web/docs/overview.md | 18 + tests/web/docs/runbook.md | 26 + tooling/catalog/gen-component-docs.py | 519 ++++++++++++++++++ tooling/rebrand/rebrand.mjs | 1 - 35 files changed, 1088 insertions(+), 37 deletions(-) create mode 100644 ai/context/current.md create mode 100644 ai/context/decisions.md create mode 100644 ai/context/open-risks.md create mode 100644 apps/web/docs/architecture.md create mode 100644 apps/web/docs/overview.md create mode 100644 apps/web/docs/runbook.md create mode 100644 infra/db-migrate/docs/architecture.md create mode 100644 infra/db-migrate/docs/overview.md create mode 100644 infra/db-migrate/docs/runbook.md create mode 100644 infra/terraform/supabase/docs/architecture.md create mode 100644 infra/terraform/supabase/docs/overview.md create mode 100644 infra/terraform/supabase/docs/runbook.md delete mode 100644 kiox.lock delete mode 100644 kiox.yaml create mode 100644 packages/db/docs/architecture.md create mode 100644 packages/db/docs/overview.md create mode 100644 packages/db/docs/runbook.md create mode 100644 tasks/SP-7.TaskContract.yaml create mode 100644 tests/db/docs/architecture.md create mode 100644 tests/db/docs/overview.md create mode 100644 tests/db/docs/runbook.md create mode 100644 tests/web/docs/architecture.md create mode 100644 tests/web/docs/overview.md create mode 100644 tests/web/docs/runbook.md create mode 100644 tooling/catalog/gen-component-docs.py diff --git a/.github/workflows/baseline.yml b/.github/workflows/baseline.yml index bf641bf..e2c051b 100644 --- a/.github/workflows/baseline.yml +++ b/.github/workflows/baseline.yml @@ -52,6 +52,12 @@ jobs: echo "── $t" bash "testing/$t.test.sh" done + # Every component's docs/{overview,architecture,runbook}.md is generated + # from what the component declares (its manifest, Worker config, + # Terraform, migrations, package scripts). A pull request that changes + # one of those facts without regenerating the pages fails here. + - name: Component docs match their manifests + run: python3 tooling/catalog/gen-component-docs.py --check # Tier 1. THE BLUEPRINT, READ AND PLACED BY THE BINARY A BOOTSTRAP RUNS. # diff --git a/ai/context/current.md b/ai/context/current.md new file mode 100644 index 0000000..c188008 --- /dev/null +++ b/ai/context/current.md @@ -0,0 +1,43 @@ +# subscription-payments — where this repository stands + +The entry page for anyone (or any agent) picking this repository up. It is +this repository's own state and does not ship to a product built from it; +the two pages that do are [operations.md](operations.md) and +[deployment.md](deployment.md). + +## What it is + +Vercel's Next.js Subscription Payments Starter — Supabase Auth, a Postgres +schema behind row-level security, Stripe Checkout, the Customer Portal and +webhooks — on Cloudflare Workers + Static Assets (through +`@opennextjs/cloudflare`), with its Supabase project from Terraform and its +schema applied by db-migrate. It is packaged as an Orun baseline: +`orun new --blueprint repo-blueprint.yaml` builds a new product in its own +repository and takes it to live on stage and prod in one landing +(`01-product`: the Supabase project, then the migrations, then the app), +then records what went live (`02-docs`). Stripe is the owner's to connect +afterwards; the app deploys and serves without it. + +## Release + +| | | +|---|---| +| Latest tag | `baseline-v1` (SP5, [#6](https://github.com/sourceplane/subscription-payments/pull/6)) | +| On `main` since | SP6 — the cirrus standard (no kiox, generated component docs, this context pack) | +| Proven live | No. Everything short of the platform is proven offline in Baseline CI: the e2e tier migrates a local Postgres under the real Supabase Auth and Data API with the product's own runner, builds in orun's staged job tree, and signs a user up and in with no Stripe key. No bootstrap from a tag has run against a workspace: the Supabase root's apply through the brokered token (SP-M), db-migrate against a real project, the service-role push, a real deploy and the card's twenty minutes (SP-N) are unproven | + +## Where to read + +| Question | Page | +|---|---| +| What shipped, and every departure from upstream | `specs/epics/subscription-payments/IMPLEMENTATION-STATUS.md` | +| Why it is built this way | [decisions.md](decisions.md), then `specs/epics/subscription-payments/design.md` | +| What could still go wrong | [open-risks.md](open-risks.md), then `specs/epics/subscription-payments/risks-and-open-questions.md` | +| How to instantiate it | `BOOTSTRAP.md`, `docs/phases/` | +| What each component is | `/docs/` beside each `component.yaml` — `apps/web`, `packages/db`, `infra/db-migrate`, `infra/terraform/supabase`, `tests/{web,db}` (generated; `python3 tooling/catalog/gen-component-docs.py`) | + +## Next + +1. Bootstrap one product from a tag against a workspace with Cloudflare and + Supabase connected, and record its timings (closes SP-M and SP-N). +2. Cut the next `baseline-vN` with `tag.yml` so the registry can pin SP6. diff --git a/ai/context/decisions.md b/ai/context/decisions.md new file mode 100644 index 0000000..1fba2cf --- /dev/null +++ b/ai/context/decisions.md @@ -0,0 +1,20 @@ +# subscription-payments — decisions + +The choices that shape this repository, one line each, with where the full +reasoning lives. Superseded decisions stay listed, marked, so the history +reads in order. + +| # | Decision | Why | Source | +|---|---|---|---| +| 1 | OpenNext on Workers + Static Assets (Next 16.3.8, React 19) | `@opennextjs/cloudflare` needs Next ≥ 15.5; only what Next 16 and Workers force changes in the template | epic README, IMPLEMENTATION-STATUS | +| 2 | One wiring document per environment, `WIRING_SUPABASE`: the URL and anon key are wrangler vars the build inlines; the service-role key is pushed as a Worker secret by every deploy (`wrangler secret bulk`). *Supersedes SP1–SP4's separate secrets* | The anon key is public (RLS protects the data); the service-role key bypasses RLS and never enters a wrangler file or a bundle | design.md §3, risks SP-B, SP-L | +| 3 | Stripe is optional: the app deploys and serves with no key (sample plans, checkout disabled, webhook 503); the owner adds the three Stripe secrets when ready | The platform brokers no Stripe connection, so a fresh product must come up without one | risk SP-I | +| 4 | `stripe` stays on v14, with `createFetchHttpClient` and SubtleCrypto webhook verification | v14 already has both Workers adapters; nothing else in the Stripe code changes | design.md §4, risk SP-E | +| 5 | The schema is applied by the `@saas/db` runner through Supabase's Management API, from the template's `init.sql` verbatim — not `supabase db push` in CI | The token is already brokered; no CLI binary, no direct Postgres connection on the runner | design.md §7, risk SP-A | +| 6 | Row-level security on every table in `public`, upstream's policies kept; migration `020` raises if any table lacks it | RLS is the app's access control over the Data API | risk SP-K | +| 7 | No Hyperdrive | The app speaks PostgREST over HTTPS, never a Postgres socket | epic README | +| 8 | `apps/web/wrangler.jsonc` is committed as the fixture render; stage and prod re-render it | The composition checks it exists before the build | risk SP-J | +| 9 | The supabase root points the project's Auth at the Worker (`supabase_settings`) and autoconfirms unless SMTP is configured | Auth emails and redirects must reach the product's own origin | risk SP-C | +| 10 | One landing (`01-product`) then the record (`02-docs`); supabase → db-migrate → web enforced on main, advisory on a pull request; stack-tectonic 0.19.0 | A landing has a fixed cost; 0.20.0's lane-scoped install is refused by Turbopack | `repo-blueprint.yaml`, `intent.yaml`, IMPLEMENTATION-STATUS (SP5) | +| 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 (SP6) | +| 12 | Component docs are generated from the manifests and checked in CI | A hand-written copy of the dependency graph and bindings drifts silently | `tooling/catalog/gen-component-docs.py` | diff --git a/ai/context/open-risks.md b/ai/context/open-risks.md new file mode 100644 index 0000000..2b35d93 --- /dev/null +++ b/ai/context/open-risks.md @@ -0,0 +1,17 @@ +# subscription-payments — open risks + +What is not yet proven or not yet decided. The full write-up of every risk, +including the accepted and resolved ones, is +`specs/epics/subscription-payments/risks-and-open-questions.md`; this page +lists only what is still live, so it should be short. + +| ID | Risk | State | What closes it | +|---|---|---|---| +| SP-M | The supabase root reads the project's API keys and writes its Auth config with the brokered `management-access` token; whether that token's scopes reach those endpoints is untested, and a refusal fails the first apply | OPEN | The first live bootstrap's supabase apply | +| SP-N | No bootstrap has been timed (the card's twenty minutes is summed from estimates); the root has not been applied and db-migrate has not run against a real project | OPEN | One bootstrap from a tag against a workspace | + +Accepted, and worth knowing before you change them: SP-A (`init.sql` is not +idempotent), SP-F (the `supabase` CLI devDependency under pnpm 10), SP-H +(lucide-react 0.330.0 on React 19), SP-L (the service-role key's path), SP-O +(the bootstrap floor plans `modeRules` as enforced), SP-P (two Supabase +projects per product), SP-Q (the e2e downloads real Supabase binaries). diff --git a/apps/web/docs/architecture.md b/apps/web/docs/architecture.md new file mode 100644 index 0000000..2c32b00 --- /dev/null +++ b/apps/web/docs/architecture.md @@ -0,0 +1,20 @@ +# web — architecture + +Built by the turbo pipeline from `apps/web` and deployed with wrangler. + +| | | +|---|---| +| Worker config | `apps/web/wrangler.template.jsonc` | +| Entry | `.open-next/worker.js` | +| Compatibility date | `2026-10-01` | +| Compatibility flags | `nodejs_compat`, `global_fetch_strictly_public` | + +## Bindings + +| Binding | Kind | Source | +|---|---|---| +| `ASSETS` | Static assets | `.open-next/assets` | + +## Variables + +`NEXT_PUBLIC_SITE_URL`, `NEXT_PUBLIC_SUPABASE_ANON_KEY`, `NEXT_PUBLIC_SUPABASE_URL`. diff --git a/apps/web/docs/overview.md b/apps/web/docs/overview.md new file mode 100644 index 0000000..cdd0662 --- /dev/null +++ b/apps/web/docs/overview.md @@ -0,0 +1,21 @@ +# web + +The Next.js Subscription Payments Starter — Supabase Auth, Stripe Checkout, Customer Portal and webhooks (Next.js on Cloudflare Workers + Static Assets via @opennextjs/cloudflare, per environment) + +A Cloudflare Worker with Static Assets (server rendering plus static files), deployed per environment by its CI lane. + +| | | +|---|---| +| Type | `cloudflare-workers-assets-turbo` | +| Source | `apps/web` | +| Package | `@app/web` | +| Environments | `dev`: `verify` · `stage`: `verify`, `deploy` on a push to `main` · `prod`: `verify`, `deploy` on a push to `main` | + +## Depends on + +- **supabase** — Provisions Supabase projects for stage and prod, points their Auth at the app, and wires the database credentials and the app's URL and keys into orun secrets +- **db-migrate** — Applies database migrations to stage and prod Supabase instances + +## Depended on by + +- (none) diff --git a/apps/web/docs/runbook.md b/apps/web/docs/runbook.md new file mode 100644 index 0000000..21dfc6d --- /dev/null +++ b/apps/web/docs/runbook.md @@ -0,0 +1,40 @@ +# web — runbook + +## How it runs + +Pull requests verify it; a merge to `main` deploys it to `stage`, `prod`. +CI plans what changed (`orun plan --changed`) and runs each lane with `orun run`; +the plan orders a component after everything it depends on. + +## Local commands + +```bash +pnpm --filter @app/web dev +pnpm --filter @app/web build +pnpm --filter @app/web typecheck +pnpm --filter @app/web lint +pnpm --filter @app/web preview +``` + +## Verify + +After a deploy the lane runs this smoke against the environment it +deployed (`ORUN_ENVIRONMENT`); `DEPLOYED_URL` overrides the URL: + +```bash +html=$(curl -sfL "${DEPLOYED_URL}/") && echo "${html}" | grep -q 'Pricing' && health=$(curl -sf "${DEPLOYED_URL}/api/health") && echo "${health}" | grep -q '"ok":true' +``` + +## Rollback + +Revert the commit on `main`. The next convergence applies the previous desired +state; nothing was changed out of band, so there is nothing else to undo. + +## Common failures + +- **A `WIRING_*` secret is missing at deploy**: an infrastructure lane upstream + has not applied for this environment yet. Within one convergence the plan + runs it first; on its own, re-run that lane. +- **The smoke fails right after a first deploy**: a new workers.dev route can + answer 4xx for a few seconds and the lane retries. A failure that persists + is a regression in the deployed code. diff --git a/infra/db-migrate/docs/architecture.md b/infra/db-migrate/docs/architecture.md new file mode 100644 index 0000000..bb14415 --- /dev/null +++ b/infra/db-migrate/docs/architecture.md @@ -0,0 +1,18 @@ +# db-migrate — architecture + +Applies the migrations under `packages/db/src/migrations` in order, recording each one +it applies so a run only ever applies what is new. An already-applied migration +is never edited: a change is a new, later migration. + +## Migrations + +- `000_control` +- `010_subscriptions_init` +- `020_row_level_security` + +## Resolved at run time (names only) + +- `SUPABASE_ACCESS_TOKEN` +- `SUPABASE_DB_PASSWORD` +- `SUPABASE_DB_URL` +- `SUPABASE_PROJECT_REF` diff --git a/infra/db-migrate/docs/overview.md b/infra/db-migrate/docs/overview.md new file mode 100644 index 0000000..0cb546d --- /dev/null +++ b/infra/db-migrate/docs/overview.md @@ -0,0 +1,20 @@ +# db-migrate + +Applies database migrations to stage and prod Supabase instances + +Applies this repository's ordered database migrations per environment: plan on pull requests, apply on merge to `main`. + +| | | +|---|---| +| Type | `db-migrate` | +| Source | `infra/db-migrate` | +| Environments | `stage`: `plan`, `apply` on a push to `main` · `prod`: `plan`, `apply` on a push to `main` | + +## Depends on + +- **db** — The database migrations and their runner (built by the db-migrate component before it plans or applies) +- **supabase** — Provisions Supabase projects for stage and prod, points their Auth at the app, and wires the database credentials and the app's URL and keys into orun secrets + +## Depended on by + +- **web** — The Next.js Subscription Payments Starter — Supabase Auth, Stripe Checkout, Customer Portal and webhooks (Next.js on Cloudflare Workers + Static Assets via @opennextjs/cloudflare, per environment) diff --git a/infra/db-migrate/docs/runbook.md b/infra/db-migrate/docs/runbook.md new file mode 100644 index 0000000..04a50d1 --- /dev/null +++ b/infra/db-migrate/docs/runbook.md @@ -0,0 +1,19 @@ +# db-migrate — runbook + +## How it runs + +Pull requests plan it; a merge to `main` applies it to `stage`, `prod`. +CI plans what changed (`orun plan --changed`) and runs each lane with `orun run`; +the plan orders a component after everything it depends on. + +## Rollback + +Revert the commit on `main`. The next convergence applies the previous desired +state; nothing was changed out of band, so there is nothing else to undo. + +## Common failures + +- **An applied migration's file changed**: the run stops rather than guess. + Restore the file and write the change as a new migration. +- **The database is unreachable**: the infrastructure lane it depends on has + not applied for this environment; that lane runs first in a convergence. diff --git a/infra/terraform/supabase/docs/architecture.md b/infra/terraform/supabase/docs/architecture.md new file mode 100644 index 0000000..a9bdad1 --- /dev/null +++ b/infra/terraform/supabase/docs/architecture.md @@ -0,0 +1,34 @@ +# supabase — architecture + +A `terraform` root at `infra/terraform/supabase/terraform`. + +- **State** lives in the Orun Cloud HTTP state backend — no local state and + no state bucket to manage. +- **Credentials are brokered per run** from the workspace's provider + connections and resolved by name; none is stored in this repository. +- **Adoption** (`adopt.tf`): when state is empty but the resource already + exists, plan-time import adopts it instead of failing. + +## Resources + +- `random_password.db_password` +- `supabase_project.this` +- `terraform_data.project_ready` +- `supabase_settings.this` + +## Published outputs + +Written as job-output secrets on each environment after an apply; deploy +lanes downstream resolve them by name. + +| Secret | Terraform output | +|---|---| +| `SUPABASE_PROJECT_REF` | `project_ref` | +| `SUPABASE_DB_PASSWORD` | `database_password` | +| `SUPABASE_DB_URL` | `connection_uri` | +| `WIRING_SUPABASE` | `wiring` | + +## Resolved at run time (names only) + +- `SUPABASE_ACCESS_TOKEN` +- `TF_VAR_supabaseOrgId` diff --git a/infra/terraform/supabase/docs/overview.md b/infra/terraform/supabase/docs/overview.md new file mode 100644 index 0000000..fed9eed --- /dev/null +++ b/infra/terraform/supabase/docs/overview.md @@ -0,0 +1,20 @@ +# supabase + +Provisions Supabase projects for stage and prod, points their Auth at the app, and wires the database credentials and the app's URL and keys into orun secrets + +Terraform-managed infrastructure, planned and applied per environment by its CI lane. + +| | | +|---|---| +| Type | `terraform` | +| Source | `infra/terraform/supabase` | +| Environments | `stage`: `plan-only`, `apply` on a push to `main` · `prod`: `plan-only`, `apply` on a push to `main` | + +## Depends on + +- (none) + +## Depended on by + +- **db-migrate** — Applies database migrations to stage and prod Supabase instances +- **web** — The Next.js Subscription Payments Starter — Supabase Auth, Stripe Checkout, Customer Portal and webhooks (Next.js on Cloudflare Workers + Static Assets via @opennextjs/cloudflare, per environment) diff --git a/infra/terraform/supabase/docs/runbook.md b/infra/terraform/supabase/docs/runbook.md new file mode 100644 index 0000000..d240972 --- /dev/null +++ b/infra/terraform/supabase/docs/runbook.md @@ -0,0 +1,20 @@ +# supabase — runbook + +## How it runs + +Pull requests plan it; a merge to `main` applies it to `stage`, `prod`. +CI plans what changed (`orun plan --changed`) and runs each lane with `orun run`; +the plan orders a component after everything it depends on. + +## Rollback + +Revert the commit on `main`. The next convergence applies the previous desired +state; nothing was changed out of band, so there is nothing else to undo. + +## Common failures + +- **Provider authentication fails**: the workspace's provider connection is + missing or revoked. Reconnect it in the console; credentials are brokered + from it per run. +- **"Already exists" on a first apply**: state is empty but the resource is + not. `adopt.tf` imports it at plan time; if it still fails, the resource was renamed outside Terraform. diff --git a/kiox.lock b/kiox.lock deleted file mode 100644 index 6e14690..0000000 --- a/kiox.lock +++ /dev/null @@ -1,11 +0,0 @@ -apiVersion: kiox.io/v1 -kind: WorkspaceLock -metadata: - name: example-platform -providers: - - alias: orun - provider: sourceplane/orun - source: ghcr.io/sourceplane/orun:v2.15.0 - version: v2.15.0 - resolved: ghcr.io/sourceplane/orun@sha256:1d28be8612dc8d8083b508f97cd71a24c090f6472c43c71f68455e3709a6a3c1 - store: e02472f57f2eb5fb5168b7d270ea547e5bffbf83824c4286abd7ba20f87cb9d1 diff --git a/kiox.yaml b/kiox.yaml deleted file mode 100644 index d654da0..0000000 --- a/kiox.yaml +++ /dev/null @@ -1,6 +0,0 @@ -apiVersion: kiox.io/v1 -kind: Workspace -metadata: - name: example-platform -providers: - orun: ghcr.io/sourceplane/orun:v2.15.0 diff --git a/packages/db/docs/architecture.md b/packages/db/docs/architecture.md new file mode 100644 index 0000000..135d4b4 --- /dev/null +++ b/packages/db/docs/architecture.md @@ -0,0 +1,11 @@ +# db — architecture + +A workspace package at `packages/db`, consumed at build time by the components +that depend on it. It holds no credentials and opens no connections of its own. + +## Exports + +- `.` +- `./manifest` +- `./runner` +- `./types` diff --git a/packages/db/docs/overview.md b/packages/db/docs/overview.md new file mode 100644 index 0000000..859cdce --- /dev/null +++ b/packages/db/docs/overview.md @@ -0,0 +1,20 @@ +# db + +The database migrations and their runner (built by the db-migrate component before it plans or applies) + +A workspace package built by the turbo pipeline. It deploys nothing itself: its lane type-checks, lints, tests and builds it. + +| | | +|---|---| +| Type | `turbo-package` | +| Source | `packages/db` | +| Package | `@saas/db` | +| Environments | `dev`: `quick-check` · `stage`: `quick-check` · `prod`: `quick-check` | + +## Depends on + +- (none) + +## Depended on by + +- **db-migrate** — Applies database migrations to stage and prod Supabase instances diff --git a/packages/db/docs/runbook.md b/packages/db/docs/runbook.md new file mode 100644 index 0000000..3fa7445 --- /dev/null +++ b/packages/db/docs/runbook.md @@ -0,0 +1,25 @@ +# db — runbook + +## How it runs + +Its lane runs on every pull request that changes it; it has no deployed surface. +CI plans what changed (`orun plan --changed`) and runs each lane with `orun run`; +the plan orders a component after everything it depends on. + +## Local commands + +```bash +pnpm --filter @saas/db build +pnpm --filter @saas/db typecheck +pnpm --filter @saas/db lint +``` + +## Rollback + +Revert the commit on `main`. The next convergence applies the previous desired +state; nothing was changed out of band, so there is nothing else to undo. + +## Common failures + +- **A dependent fails to build after a change here**: run `pnpm typecheck` + across the workspace before merging. diff --git a/repo-blueprint.yaml b/repo-blueprint.yaml index 963ccd4..acfb80c 100644 --- a/repo-blueprint.yaml +++ b/repo-blueprint.yaml @@ -193,16 +193,6 @@ modules: source: baseline from: turbo.json to: turbo.json - - name: root-kiox - mode: copy - source: baseline - from: kiox.yaml - to: kiox.yaml - - name: root-kiox-lock - mode: copy - source: baseline - from: kiox.lock - to: kiox.lock - name: root-gitignore mode: copy source: baseline @@ -426,7 +416,7 @@ phases: await: "One convergence is running per environment: the Supabase project first (five to seven minutes to come up), then the migrations, then the app. Nothing is stuck." done: "{{ .inputs.reponame }} is live on stage and prod — {{ .meta.files }} files on main, branded as {{ .inputs.productname }}, signing users up through its own Supabase project. Stripe connects whenever you add its keys. That took {{ .meta.elapsed }}." failed: "The product did not come up. The failing lane above names the component — supabase, db-migrate or web — and the provider's own error is in its log; whatever was provisioned is still there." - modules: [ai-deployment, ai-operations, db, db-migrate, db-tests, github-workflows, rebrand-values, root-gitignore, root-intent, root-kiox, root-kiox-lock, root-package-json, root-pnpm-lock, root-pnpm-workspace, root-readme, root-turbo, supabase, tooling-eslint, tooling-migrations, tooling-tsconfig, tooling-wire, vscode, web, web-tests] + modules: [ai-deployment, ai-operations, db, db-migrate, db-tests, github-workflows, rebrand-values, root-gitignore, root-intent, root-package-json, root-pnpm-lock, root-pnpm-workspace, root-readme, root-turbo, supabase, tooling-eslint, tooling-migrations, tooling-tsconfig, tooling-wire, vscode, web, web-tests] # THE PLATFORM MUST BE ABLE TO SEE THE REPOSITORY BEFORE IT EXISTS. Every # phase lands a pull request that files under its task, and the platform # learns of a PR only through the GitHub App installation on the account diff --git a/specs/epics/README.md b/specs/epics/README.md index cf46c35..d195e05 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 | |------|---------|--------|------------| -| [`subscription-payments/`](./subscription-payments/) | **SP** | 🔄 SP5 in review | Vercel's Next.js Subscription Payments Starter, equivalent in code and function, on Cloudflare Workers with Supabase provisioned and migrated through Orun — and an Orun baseline that instantiates it in one landing (SP5) | +| [`subscription-payments/`](./subscription-payments/) | **SP** | ✅ Shipped (`baseline-v1`); live bootstrap pending | Vercel's Next.js Subscription Payments Starter, equivalent in code and function, on Cloudflare Workers with Supabase provisioned and migrated through Orun — and an Orun baseline that instantiates it in one landing (SP5) | As-built ≠ intent: what shipped lives in each epic's `IMPLEMENTATION-STATUS.md`. diff --git a/specs/epics/subscription-payments/IMPLEMENTATION-STATUS.md b/specs/epics/subscription-payments/IMPLEMENTATION-STATUS.md index 713d8f1..2507918 100644 --- a/specs/epics/subscription-payments/IMPLEMENTATION-STATUS.md +++ b/specs/epics/subscription-payments/IMPLEMENTATION-STATUS.md @@ -10,7 +10,8 @@ the code departed from `design.md` or from the upstream template. | SP2 — the schema through db-migrate | ✅ Shipped (planned offline; apply gated on a linked workspace) | [#3](https://github.com/sourceplane/subscription-payments/pull/3) | | SP3 — the Supabase project from Terraform | ✅ Shipped (validated; apply gated on a linked workspace) | [#4](https://github.com/sourceplane/subscription-payments/pull/4) | | SP4 — ready to instantiate | ✅ Shipped | [#5](https://github.com/sourceplane/subscription-payments/pull/5) | -| SP5 — a baseline | 🔄 In review (SP-6) | this branch, `claude/blissful-ptolemy-c5ajf8` | +| SP5 — a baseline | ✅ Shipped | [#6](https://github.com/sourceplane/subscription-payments/pull/6) (SP-6), tagged `baseline-v1` | +| SP6 — the cirrus standard | ✅ Shipped | SP-7 — on `main` after `baseline-v1`, not yet tagged | ## Departures from the upstream template @@ -324,3 +325,38 @@ Not verified: a Terraform apply (the project, its API keys and its Auth settings through the brokered OAuth token — SP-M), a db-migrate apply against a real project, the `wrangler secret bulk` push and a deploy to a real account, a live bootstrap, and checkout against a real Stripe account. + +## The cirrus standard (SP6) + +Nothing about the app changed. What changed is the baseline around it: + +| What | Before | After | Why | +|---|---|---|---| +| orun pin | `kiox.yaml` (v2.15.0) + `kiox.lock`, shipped to every product | gone; orun is pinned where it runs, the `orun-action` `version:` in each workflow | nothing ran the kiox pin, and it disagreed with the lanes (v2.78.4) | +| `root-kiox`, `root-kiox-lock` modules | in `01-product` | removed (`testing/phases.test.sh` and the rebrand's skip list follow) | a product is placed with 181 files: 165 − 2 kiox + 18 docs pages | +| component docs | none | `docs/overview.md`, `architecture.md`, `runbook.md` beside each of the six `component.yaml` | cirrus-baseline documents every component; the workspace Docs library renders `docs/` beside each manifest | +| how the docs stay true | — | `tooling/catalog/gen-component-docs.py` derives them from the manifest, the Worker config, Terraform, migrations and package scripts; Baseline CI runs it with `--check` | a hand-written copy of a manifest drifts silently | +| context pack | `operations.md`, `deployment.md` | plus `current.md`, `decisions.md`, `open-risks.md` | cirrus-baseline's shape; the three new pages are this repository's own and no module places them (the leak gate still allows exactly two) | +| status | SP5 "in review", on a branch | SP5 shipped and tagged `baseline-v1` | the tag existed; the documents had not caught up | + +## Verified (SP6) + +- `testing/{manifest,phases,coverage,rebrand,retouch,bootstrap-defer}.test.sh` + green; `gen-component-docs.py --check` green (6 components, 18 pages). +- `orun new --status` at v2.58.11: `01-product` 181 files, `02-docs` + hook-only. +- `testing/leak.test.sh` at v2.58.11: 181 files derived, 174 text files + read; ai/context still exactly the two declared pages; the generated pages + name no factory path. +- `testing/placement.test.sh` at v2.58.11: 181 files placed, both landings, + branded, re-tenanted; the product's own plan orders supabase → db-migrate → + web on stage and prod, enforced; `--resume` changes nothing. +- `pnpm install --frozen-lockfile`, `wire:fixture` (the tree unchanged), + `typecheck`, `lint`, `test` (53 tests: 42 in `tests/web`, 11 in + `tests/db`), `build` green. +- `testing/e2e.test.sh` at v2.78.4 green: the stage db-migrate and web lanes + in staged job trees over a local Supabase (GoTrue v2.180.0, PostgREST + v12.2.12); `wrangler dev` with the service-role key as its one secret; a + sign-up, the account page, checkout and the portal saying Stripe is not + connected, a sign-out and a sign-in; 0 of 5 public tables without RLS. +- `orun task check SP-7` complete. diff --git a/specs/epics/subscription-payments/README.md b/specs/epics/subscription-payments/README.md index e938b13..4df8765 100644 --- a/specs/epics/subscription-payments/README.md +++ b/specs/epics/subscription-payments/README.md @@ -8,15 +8,15 @@ The upstream code stays the code: the `@supabase/ssr` clients and the session-re | Field | Value | |-------|-------| -| Status | ✅ SP0–SP4 shipped (#1–#5) · 🔄 SP5 — a baseline (SP-6) in review. The Supabase and migration applies and a live deploy are gated on a linked workspace; Stripe keys are the product owner's | -| Cluster | **SP** (SP0–SP5) | +| Status | ✅ SP0–SP5 shipped (#1–#6), tagged `baseline-v1`; SP6 (the cirrus standard, SP-7) on `main`, not yet tagged. Not yet proven by a live bootstrap: the Supabase and migration applies and a live deploy (risks SP-M, SP-N); Stripe keys are the product owner's | +| Cluster | **SP** (SP0–SP6) | | Owner(s) | `apps/web` (the app) · `tests/web` (helper and webhook tests) · `packages/db` + `infra/db-migrate` + `tests/db` (the schema) · `infra/terraform/supabase` (the project) | | Builds on | `lumen` conventions — the `supabase` Terraform root, the `@saas/db` runner and `db-migrate` component, the orun-secrets wiring; `supabase-starter` for the app-on-Workers shape; `cirrus-baseline` conventions for the repository shape | | Upstream | [vercel/nextjs-subscription-payments](https://github.com/vercel/nextjs-subscription-payments) (sunset upstream in favour of `nextjs/saas-starter`; ported as it stands) | | Changes | Adds the Workers build, the monorepo wrapper, tests, the migrations package, the db-migrate component, the Supabase root and the deploy contract; the template's code changes only where Next 16 / Workers force it (every change is in `IMPLEMENTATION-STATUS.md`) | | Decisions locked | (1) OpenNext on Workers + Static Assets. (2) The anon key is a wrangler var, not a secret: RLS protects the data; the service-role key and the Stripe secrets are Worker secrets — the service-role key pushed by every deploy from `WIRING_SUPABASE` (SP5), the Stripe keys added by the owner when ready, the app deploying and serving without them (SP5). (3) `wrangler.jsonc` rendered from the template: committed as the fixture render (the composition checks it exists before the build), re-rendered per environment from the wiring document by the deploy lanes, which the build inlines (SP5; it was never committed before). (4) The schema is applied by the `@saas/db` runner through Supabase's Management API, from the template's `init.sql` verbatim — not by `supabase db push` in CI — then RLS checked on every table (`020`, SP5). (5) No Hyperdrive: the app speaks PostgREST over HTTPS, never a Postgres socket. (6) `stripe` stays on v14: it already has the fetch client and async webhook verification. (7) Infra before app on main: supabase → db-migrate → web, enforced; advisory on pull requests (SP5). | | Gate | SP1 is the first user-visible rung. SP2 and SP3 need a workspace with a Supabase connection to apply; they are verified by `plan` / `terraform validate`. Checkout and the webhook need the product's Stripe keys as Worker secrets (the one manual step, see `design.md` §3). | -| Shipped as | `main` after [#5](https://github.com/sourceplane/subscription-payments/pull/5); verified locally under `wrangler dev` with fixture vars and dummy Worker secrets | +| Shipped as | `baseline-v1` ([#6](https://github.com/sourceplane/subscription-payments/pull/6)), then SP6 on `main`; proven offline (Baseline CI: contract, leak, placement and the e2e tier over a local Supabase Auth and Data API), deploy gated until a workspace is linked | ## Read order @@ -35,3 +35,4 @@ The upstream code stays the code: the `@supabase/ssr` clients and the session-re | SP3 — the Supabase project from Terraform | `infra/terraform/supabase`, the app's `secretEnv` and `dependsOn` it completes | the root validates; the secret and wiring keys match the component | | SP4 — ready to instantiate | README, as-built status | a reader can run, test, preview, configure Stripe and deploy it | | SP5 — a baseline | card, build document, rename, bootstrap tooling, the product's README and context pack, tests | a new product goes from nothing to live on stage and prod in one landing, with no Stripe key, every table behind RLS; Baseline CI green | +| SP6 — the cirrus standard | no kiox, generated component docs, the context pack, status that agrees with the tags | Baseline CI green with the docs check | diff --git a/specs/epics/subscription-payments/design.md b/specs/epics/subscription-payments/design.md index 65c1fce..d17af16 100644 --- a/specs/epics/subscription-payments/design.md +++ b/specs/epics/subscription-payments/design.md @@ -120,7 +120,7 @@ apps/web the template (app/, components/, utils/, styles/, wiring.fixture.json offline values for the verify lane .dev.vars.example the Worker secrets, for wrangler dev open-next.config.ts static-assets incremental cache (pre-rendered shells), no R2/KV/D1 -packages/db @saas/db: the control migration + 010_subscriptions_init (init.sql verbatim), the Management-API runner +packages/db @saas/db: the control migration + 010_subscriptions_init (init.sql verbatim) + 020_row_level_security (SP5), the Management-API runner infra/db-migrate plan on PRs, apply on merge, after supabase infra/terraform/supabase the Supabase project per environment (Lumen's root + API keys + wiring document) tests/web vitest: getURL, trial-end, toDateTime, the toast redirects, the auth settings, the webhook route's 400 paths (mocked stripe + admin) diff --git a/specs/epics/subscription-payments/epic.yaml b/specs/epics/subscription-payments/epic.yaml index 9cfab88..1843b63 100644 --- a/specs/epics/subscription-payments/epic.yaml +++ b/specs/epics/subscription-payments/epic.yaml @@ -47,3 +47,10 @@ spec: - "every table in public has row-level security with upstream's policies: the anon key reads the plans and nothing else, a user their own row and subscriptions; migration 020 and tests/db hold it" - "Baseline CI is green: contract tests, the blueprint read by the pinned orun, the leak gate, the offline bootstrap and the product's plans, and the end-to-end tier over a local Supabase Auth and Data API" tasks: [SP-6] + - name: "SP6 — the cirrus standard" + exitCriteria: + - "no file names kiox: orun is pinned where CI runs it (the orun-action `version:` in each workflow)" + - "every component carries generated docs/{overview,architecture,runbook}.md, and Baseline CI fails a pull request whose manifests and pages disagree" + - "ai/context carries this repository's current.md, decisions.md and open-risks.md, and none of them ships to a product" + - "every milestone's status row agrees with the tags" + tasks: [SP-7] diff --git a/specs/epics/subscription-payments/implementation-plan.md b/specs/epics/subscription-payments/implementation-plan.md index 81ca68c..6cbb2a5 100644 --- a/specs/epics/subscription-payments/implementation-plan.md +++ b/specs/epics/subscription-payments/implementation-plan.md @@ -61,7 +61,7 @@ departures, epic `completed`. - the README quick start works from a fresh clone with a `.env.local` and a `.dev.vars` - the status file lists every PR and departure -## SP5 — a baseline +## SP5 — a baseline (SP-6) ✅ The repository becomes an Orun baseline on the Lumen conventions, built the way cirrus-baseline v22 builds a product — in ONE landing — following the @@ -101,6 +101,29 @@ saas-starter reference (SA5) without its Hyperdrive: up, out and in with no Stripe key, the anon key refused every row the policies do not give it +## SP6 — the cirrus standard (SP-7) ✅ + +Bring the baseline to cirrus-baseline's standard, with nothing about the app +itself changing. + +- **No kiox.** `kiox.yaml`/`kiox.lock` pinned an orun (v2.15.0) that nothing + ran: every workflow installs orun itself through `orun-action` with its own + `version:`. The files, their two modules and the rebrand's skip entry go. +- **Component docs.** `tooling/catalog/gen-component-docs.py` writes each of + the six components' `docs/overview.md`, `docs/architecture.md` and + `docs/runbook.md` from what the component declares, as cirrus-baseline's + do; the pages ship with the component. Baseline CI runs it with `--check`. +- **The context pack.** `ai/context/current.md`, `decisions.md` and + `open-risks.md` beside the two pages a product ships with — this + repository's own, so no module places them. +- **Status that agrees with the tags.** SP5 is shipped and tagged. + +**Done when** +- `git grep -i kiox` finds nothing, and the leak gate and the offline + bootstrap pass without the two modules +- the docs check is green in Baseline CI +- this file, the status file and `epic.yaml` agree + ## Sequencing note SP1's component already names the root's secrets and the db-migrate diff --git a/tasks/SP-7.TaskContract.yaml b/tasks/SP-7.TaskContract.yaml new file mode 100644 index 0000000..364bbcb --- /dev/null +++ b/tasks/SP-7.TaskContract.yaml @@ -0,0 +1,31 @@ +apiVersion: orun.io/v1 +kind: TaskContract +metadata: + name: SP-7 + title: "The cirrus standard" +spec: + goal: The baseline meets cirrus-baseline's standard — no kiox pin (orun is pinned where CI runs it), every component documented by generated overview/architecture/runbook pages that CI keeps in step with the manifests, the agent context pack, and status documents that agree with the tags + affects: + - kiox.yaml + - kiox.lock + - repo-blueprint.yaml + - testing/phases.test.sh + - tooling/rebrand/** + - tooling/catalog/** + - .github/workflows/baseline.yml + - apps/web/docs/** + - packages/db/docs/** + - infra/db-migrate/docs/** + - infra/terraform/supabase/docs/** + - tests/web/docs/** + - tests/db/docs/** + - ai/context/** + - specs/** + - tasks/** + doneWhen: + - no file names kiox, and the leak gate and the offline bootstrap place a product without it + - every component has docs/overview.md, docs/architecture.md and docs/runbook.md, and `python3 tooling/catalog/gen-component-docs.py --check` is green in Baseline CI + - ai/context carries current.md, decisions.md and open-risks.md for this repository (none of them ships) + - every milestone's status row agrees with the tags + gates: + - checks diff --git a/testing/phases.test.sh b/testing/phases.test.sh index 50e49f8..121cb86 100755 --- a/testing/phases.test.sh +++ b/testing/phases.test.sh @@ -47,7 +47,7 @@ if not phases: PRODUCT = ["ai-deployment", "ai-operations", "db", "db-migrate", "db-tests", "github-workflows", "rebrand-values", "root-gitignore", "root-intent", - "root-kiox", "root-kiox-lock", "root-package-json", "root-pnpm-lock", + "root-package-json", "root-pnpm-lock", "root-pnpm-workspace", "root-readme", "root-turbo", "supabase", "tooling-eslint", "tooling-migrations", "tooling-tsconfig", "tooling-wire", "vscode", "web", "web-tests"] diff --git a/tests/db/docs/architecture.md b/tests/db/docs/architecture.md new file mode 100644 index 0000000..40a7e32 --- /dev/null +++ b/tests/db/docs/architecture.md @@ -0,0 +1,8 @@ +# db-tests — architecture + +A test package at `tests/db`. Its lane runs the suite before it builds. + +## Suites (2) + +- `migrations.test.ts` +- `row-level-security.test.ts` diff --git a/tests/db/docs/overview.md b/tests/db/docs/overview.md new file mode 100644 index 0000000..9bdd262 --- /dev/null +++ b/tests/db/docs/overview.md @@ -0,0 +1,18 @@ +# db-tests + +The test suite for **db**. It deploys nothing: its lane installs, builds and runs the tests. + +| | | +|---|---| +| Type | `turbo-package` | +| Source | `tests/db` | +| Package | `@app/db-tests` | +| Environments | `dev`: `quick-check` | + +## Depends on + +- (none) + +## Depended on by + +- (none) diff --git a/tests/db/docs/runbook.md b/tests/db/docs/runbook.md new file mode 100644 index 0000000..aa64499 --- /dev/null +++ b/tests/db/docs/runbook.md @@ -0,0 +1,26 @@ +# db-tests — runbook + +## How it runs + +Its lane runs on every pull request that changes it; it has no deployed surface. +CI plans what changed (`orun plan --changed`) and runs each lane with `orun run`; +the plan orders a component after everything it depends on. + +## Local commands + +```bash +pnpm --filter @app/db-tests build +pnpm --filter @app/db-tests test +pnpm --filter @app/db-tests typecheck +pnpm --filter @app/db-tests lint +``` + +## Rollback + +Revert the commit on `main`. The next convergence applies the previous desired +state; nothing was changed out of band, so there is nothing else to undo. + +## Common failures + +- **A dependent fails to build after a change here**: run `pnpm typecheck` + across the workspace before merging. diff --git a/tests/web/docs/architecture.md b/tests/web/docs/architecture.md new file mode 100644 index 0000000..1414db1 --- /dev/null +++ b/tests/web/docs/architecture.md @@ -0,0 +1,12 @@ +# web-tests — architecture + +A test package at `tests/web`. Its lane runs the suite before it builds. + +## Suites (6) + +- `auth-settings.test.ts` +- `health.test.ts` +- `helpers.test.ts` +- `stripe-not-connected.test.ts` +- `webhooks.test.ts` +- `wrangler-config.test.ts` diff --git a/tests/web/docs/overview.md b/tests/web/docs/overview.md new file mode 100644 index 0000000..6e02b2d --- /dev/null +++ b/tests/web/docs/overview.md @@ -0,0 +1,18 @@ +# web-tests + +The test suite for **web**. It deploys nothing: its lane installs, builds and runs the tests. + +| | | +|---|---| +| Type | `turbo-package` | +| Source | `tests/web` | +| Package | `@app/web-tests` | +| Environments | `dev`: `quick-check` | + +## Depends on + +- (none) + +## Depended on by + +- (none) diff --git a/tests/web/docs/runbook.md b/tests/web/docs/runbook.md new file mode 100644 index 0000000..c687de2 --- /dev/null +++ b/tests/web/docs/runbook.md @@ -0,0 +1,26 @@ +# web-tests — runbook + +## How it runs + +Its lane runs on every pull request that changes it; it has no deployed surface. +CI plans what changed (`orun plan --changed`) and runs each lane with `orun run`; +the plan orders a component after everything it depends on. + +## Local commands + +```bash +pnpm --filter @app/web-tests build +pnpm --filter @app/web-tests test +pnpm --filter @app/web-tests typecheck +pnpm --filter @app/web-tests lint +``` + +## Rollback + +Revert the commit on `main`. The next convergence applies the previous desired +state; nothing was changed out of band, so there is nothing else to undo. + +## Common failures + +- **A dependent fails to build after a change here**: run `pnpm typecheck` + across the workspace before merging. diff --git a/tooling/catalog/gen-component-docs.py b/tooling/catalog/gen-component-docs.py new file mode 100644 index 0000000..2a6a8b8 --- /dev/null +++ b/tooling/catalog/gen-component-docs.py @@ -0,0 +1,519 @@ +#!/usr/bin/env python3 +"""Generate each component's docs (overview / architecture / runbook). + + python3 tooling/catalog/gen-component-docs.py # write + python3 tooling/catalog/gen-component-docs.py --check # fail on drift (CI) + +The Orun workspace's Docs library renders the `docs/` folder next to every +`component.yaml`. These pages are generated, not hand-written, because almost +everything in them is already declared somewhere CI validates: the component's +manifest (type, description, dependencies, environments, the secrets a lane +resolves, the smoke), its Worker config (bindings, triggers, the wiring the +deploy fills in), its Terraform (resources and outputs), its migrations and its +package scripts. A hand-written copy of those facts drifts the first time one +changes; a generated one cannot, because `--check` fails the pull request that +changes the fact without the page. + +What is NOT derivable (why a component exists, what a failure means for this +product in particular) belongs in the component's `description` and in the +product's own docs, not here. + +The pages ship with the component into every product built from this tree, so +they say nothing about where they came from: no factory paths, no generator +path, no provenance. Zero dependencies beyond PyYAML. +""" + +from __future__ import annotations + +import json +import pathlib +import re +import sys + +try: + import yaml +except ImportError: # pragma: no cover - the contract job installs it + sys.exit("gen-component-docs needs PyYAML (pip install pyyaml)") + +ROOT = pathlib.Path(__file__).resolve().parents[2] +ROOTS = ("apps", "packages", "infra", "tests") +SKIP_DIRS = {"node_modules", "dist", ".turbo", "docs", ".next", ".open-next", + ".wrangler", ".svelte-kit", ".nuxt", ".output", ".astro", "coverage"} + +# Paths a shipped page must never name: products are not placed with them. +FACTORY = re.compile( + r"repo-blueprint|BOOTSTRAP\.md|(? str: + """JSONC → JSON: drop comments outside strings, then trailing commas.""" + out, i, n, in_str = [], 0, len(text), False + while i < n: + c = text[i] + if in_str: + out.append(c) + if c == "\\" and i + 1 < n: + out.append(text[i + 1]) + i += 2 + continue + if c == '"': + in_str = False + i += 1 + continue + if c == '"': + in_str = True + out.append(c) + i += 1 + elif text.startswith("//", i): + j = text.find("\n", i) + i = n if j < 0 else j + elif text.startswith("/*", i): + j = text.find("*/", i + 2) + i = n if j < 0 else j + 2 + else: + out.append(c) + i += 1 + return re.sub(r",(\s*[}\]])", r"\1", "".join(out)) + + +def read_json(path: pathlib.Path) -> dict | None: + try: + return json.loads(strip_jsonc(path.read_text(encoding="utf-8"))) + except (OSError, ValueError): + return None + + +def rel(p: pathlib.Path) -> str: + return p.relative_to(ROOT).as_posix() + + +def discover() -> list[dict]: + found = [] + for root in ROOTS: + base = ROOT / root + if not base.is_dir(): + continue + stack = [base] + while stack: + d = stack.pop() + for entry in sorted(d.iterdir()): + if entry.is_dir(): + if entry.name in SKIP_DIRS or entry.name.startswith("."): + continue + if (entry / "main.tf").exists() and not (entry / "component.yaml").exists(): + continue + if len(entry.relative_to(base).parts) <= 3: + stack.append(entry) + elif entry.name == "component.yaml": + found.append(read_component(entry)) + comps = [c for c in found if c["name"] and c["type"]] + return sorted(comps, key=lambda c: c["name"]) + + +def read_component(file: pathlib.Path) -> dict: + doc = yaml.safe_load(file.read_text(encoding="utf-8")) or {} + meta, spec = doc.get("metadata") or {}, doc.get("spec") or {} + params = spec.get("parameters") or {} + deps = [d.get("component") for d in (spec.get("dependsOn") or []) if isinstance(d, dict)] + envs = [] + for e in ((spec.get("subscribe") or {}).get("environments") or []): + rules = [(r.get("profile"), ((r.get("when") or {}).get("triggerRef"))) + for r in (e.get("profileRules") or [])] + envs.append({"name": e.get("name"), "profile": e.get("profile"), "rules": rules}) + return { + "dir": file.parent, + "path": rel(file.parent), + "name": meta.get("name"), + "description": (meta.get("description") or "").strip(), + "type": spec.get("type"), + "deps": [d for d in deps if d], + "secret_env": sorted((spec.get("secretEnv") or {}).keys()), + "envs": envs, + "params": params, + "migrations_path": spec.get("path") if spec.get("type") == "db-migrate" else None, + } + + +def package_of(c: dict) -> dict | None: + return read_json(c["dir"] / "package.json") + + +def worker_config(c: dict) -> tuple[str | None, dict | None]: + """The config a deploy uses: the template when wiring renders one.""" + names = ["wrangler.template.jsonc", c["params"].get("wranglerConfig") or "", + "wrangler.jsonc", "wrangler.json"] + for name in names: + if name and (c["dir"] / name).is_file(): + return name, read_json(c["dir"] / name) + return None, None + + +WIRING = re.compile(r"@@wiring\(([^/)]+)/__ENV__:([^)]+)\)@@") + + +def wired(value) -> str | None: + m = WIRING.search(str(value)) if value is not None else None + return f"`{m.group(2)}` from `{m.group(1)}`" if m else None + + +def bindings(cfg: dict) -> list[tuple[str, str, str]]: + rows = [] + for kv in cfg.get("kv_namespaces") or []: + rows.append((kv.get("binding"), "Workers KV namespace", wired(kv.get("id")) or "declared in the config")) + for b in cfg.get("r2_buckets") or []: + rows.append((b.get("binding"), "R2 bucket", wired(b.get("bucket_name")) or f"`{b.get('bucket_name')}`")) + for d in cfg.get("d1_databases") or []: + rows.append((d.get("binding"), "D1 database", wired(d.get("database_id")) or "declared in the config")) + for h in cfg.get("hyperdrive") or []: + rows.append((h.get("binding"), "Hyperdrive (pooled Postgres)", wired(h.get("id")) or "declared in the config")) + if isinstance(cfg.get("ai"), dict) and cfg["ai"].get("binding"): + rows.append((cfg["ai"]["binding"], "Workers AI", "account-level; no resource to provision")) + for d in ((cfg.get("durable_objects") or {}).get("bindings") or []): + rows.append((d.get("name"), "Durable Object", f"class `{d.get('class_name')}`")) + for s in cfg.get("services") or []: + rows.append((s.get("binding"), "Service binding", f"Worker `{s.get('service')}`")) + for q in ((cfg.get("queues") or {}).get("producers") or []): + rows.append((q.get("binding"), "Queue producer", f"queue `{q.get('queue')}`")) + for r in cfg.get("ratelimits") or []: + simple = r.get("simple") or {} + rows.append((r.get("name"), "Rate limiter", + f"{simple.get('limit')} requests / {simple.get('period')}s per location")) + assets = cfg.get("assets") or {} + if assets.get("binding"): + rows.append((assets["binding"], "Static assets", f"`{assets.get('directory')}`")) + return [r for r in rows if r[0]] + + +def tf_facts(c: dict) -> dict: + tf_dir = c["dir"] / (c["params"].get("terraformDir") or "terraform") + resources, outputs, variables, backend = [], [], [], None + for f in sorted(tf_dir.glob("*.tf")) if tf_dir.is_dir() else []: + text = f.read_text(encoding="utf-8") + resources += [f"{t}.{n}" for t, n in re.findall(r'^resource\s+"([^"]+)"\s+"([^"]+)"', text, re.M)] + outputs += re.findall(r'^output\s+"([^"]+)"', text, re.M) + variables += re.findall(r'^variable\s+"([^"]+)"', text, re.M) + m = re.search(r'backend\s+"([^"]+)"', text) + backend = backend or (m.group(1) if m else None) + imports = (tf_dir / "adopt.tf").is_file() if tf_dir.is_dir() else False + return {"dir": rel(tf_dir) if tf_dir.is_dir() else None, "resources": resources, + "outputs": outputs, "variables": variables, "backend": backend, "adopt": imports} + + +def published(c: dict) -> list[tuple[str, str]]: + spec = c["params"].get("secretOutputs") or "" + pairs = [] + for part in str(spec).split(","): + if "=" in part: + k, v = part.split("=", 1) + pairs.append((k.strip(), v.strip())) + return pairs + + +def test_files(c: dict) -> list[str]: + out = [] + for p in sorted(c["dir"].rglob("*")): + if any(part in SKIP_DIRS for part in p.relative_to(c["dir"]).parts): + continue + if p.is_file() and re.search(r"\.(test|spec)\.(ts|tsx|js|mjs|cjs)$", p.name): + out.append(p.name) + return out + + +def migrations(c: dict) -> list[str]: + path = c["migrations_path"] + if not path: + return [] + d = ROOT / path + if not d.is_dir(): + return [] + return sorted(p.name for p in d.iterdir() if p.is_dir() or p.suffix == ".sql") + + +# ── phrasing ───────────────────────────────────────────────────────────── + +KIND = { + "cloudflare-worker-turbo": "A Cloudflare Worker, deployed per environment by its CI lane.", + "cloudflare-workers-assets-turbo": "A Cloudflare Worker with Static Assets (server rendering plus " + "static files), deployed per environment by its CI lane.", + "terraform": "Terraform-managed infrastructure, planned and applied per environment by its CI lane.", + "db-migrate": "Applies this repository's ordered database migrations per environment: " + "plan on pull requests, apply on merge to `main`.", + "turbo-package": "A workspace package built by the turbo pipeline. It deploys nothing itself: " + "its lane type-checks, lints, tests and builds it.", +} + +TRIGGER = {"github-push-main": "a push to `main`", "github-pull-request": "a pull request"} + + +def env_line(e: dict) -> str: + s = f"`{e['name']}`: `{e['profile']}`" + for profile, ref in e["rules"]: + s += f", `{profile}` on {TRIGGER.get(ref, f'`{ref}`')}" + return s + + +def is_tests(c: dict) -> bool: + return c["name"].endswith("-tests") or c["path"].startswith("tests/") + + +def subject_of(c: dict, by_name: dict) -> str | None: + if c["name"].endswith("-tests"): + s = c["name"][: -len("-tests")] + return s if s in by_name else None + return None + + +def bullet_list(names: list[str], by_name: dict) -> list[str]: + if not names: + return ["- (none)"] + out = [] + for n in names: + d = by_name.get(n) + out.append(f"- **{n}** — {d['description']}" if d and d["description"] else f"- **{n}**") + return out + + +# ── pages ──────────────────────────────────────────────────────────────── + +def overview(c: dict, by_name: dict, dependents: list[str]) -> str: + pkg = package_of(c) + kind = KIND.get(c["type"], f"A `{c['type']}` component.") + subject = subject_of(c, by_name) + if is_tests(c): + kind = (f"The test suite for **{subject}**. " if subject else "A test suite. ") + \ + "It deploys nothing: its lane installs, builds and runs the tests." + lines = [f"# {c['name']}", ""] + if c["description"]: + lines += [c["description"], ""] + lines += [kind, "", "| | |", "|---|---|", f"| Type | `{c['type']}` |", f"| Source | `{c['path']}` |"] + if pkg and pkg.get("name"): + lines.append(f"| Package | `{pkg['name']}` |") + if c["envs"]: + lines.append(f"| Environments | {' · '.join(env_line(e) for e in c['envs'])} |") + lines += ["", "## Depends on", "", *bullet_list(c["deps"], by_name), + "", "## Depended on by", "", *bullet_list(dependents, by_name), ""] + return "\n".join(lines) + + +def architecture(c: dict, by_name: dict) -> str: + lines = [f"# {c['name']} — architecture", ""] + t = c["type"] + + if t == "terraform": + f = tf_facts(c) + lines += [f"A `terraform` root at `{f['dir'] or c['path']}`.", ""] + if f["backend"] == "http": + lines += ["- **State** lives in the Orun Cloud HTTP state backend — no local state and", + " no state bucket to manage."] + lines += ["- **Credentials are brokered per run** from the workspace's provider", + " connections and resolved by name; none is stored in this repository."] + if f["adopt"]: + lines += ["- **Adoption** (`adopt.tf`): when state is empty but the resource already", + " exists, plan-time import adopts it instead of failing."] + lines.append("") + if f["resources"]: + lines += ["## Resources", "", *[f"- `{r}`" for r in f["resources"]], ""] + pub = published(c) + if pub: + lines += ["## Published outputs", "", + "Written as job-output secrets on each environment after an apply; deploy", + "lanes downstream resolve them by name.", "", + "| Secret | Terraform output |", "|---|---|", + *[f"| `{k}` | `{v}` |" for k, v in pub], ""] + elif f["outputs"]: + lines += ["## Outputs", "", *[f"- `{o}`" for o in f["outputs"]], ""] + if c["secret_env"]: + lines += ["## Resolved at run time (names only)", "", + *[f"- `{k}`" for k in c["secret_env"]], ""] + return "\n".join(lines) + + if t == "db-migrate": + migs = migrations(c) + lines += [f"Applies the migrations under `{c['migrations_path']}` in order, recording each one", + "it applies so a run only ever applies what is new. An already-applied migration", + "is never edited: a change is a new, later migration.", ""] + if migs: + lines += ["## Migrations", "", *[f"- `{m}`" for m in migs], ""] + if c["secret_env"]: + lines += ["## Resolved at run time (names only)", "", + *[f"- `{k}`" for k in c["secret_env"]], ""] + return "\n".join(lines) + + pkg = package_of(c) + if t.startswith("cloudflare-"): + cfg_name, cfg = worker_config(c) + lines += [f"Built by the turbo pipeline from `{c['path']}` and deployed with wrangler.", ""] + if cfg: + lines += ["| | |", "|---|---|", f"| Worker config | `{c['path']}/{cfg_name}` |"] + if cfg.get("main"): + lines.append(f"| Entry | `{cfg['main']}` |") + if cfg.get("compatibility_date"): + lines.append(f"| Compatibility date | `{cfg['compatibility_date']}` |") + if cfg.get("compatibility_flags"): + lines.append(f"| Compatibility flags | {', '.join(f'`{x}`' for x in cfg['compatibility_flags'])} |") + lines.append("") + rows = bindings(cfg) + lines += ["## Bindings", ""] + if rows: + lines += ["| Binding | Kind | Source |", "|---|---|---|", + *[f"| `{b}` | {k} | {s} |" for b, k, s in rows], ""] + if any("from `" in s for _, _, s in rows): + lines += ["Identifiers marked *from* a component are filled in at deploy time from", + "that component's published outputs for the environment being deployed.", ""] + else: + lines += ["None: the Worker binds no storage or service.", ""] + crons = (cfg.get("triggers") or {}).get("crons") or [] + if crons: + lines += ["## Scheduled triggers", "", *[f"- `{x}`" for x in crons], ""] + env_names = sorted((cfg.get("env") or {}).keys()) + var_names = sorted((cfg.get("vars") or {}).keys()) + if var_names: + lines += ["## Variables", "", ", ".join(f"`{v}`" for v in var_names) + + (f" — overridden per environment ({', '.join(f'`{e}`' for e in env_names)})." + if env_names else "."), ""] + wiring = [k for k in c["secret_env"] if k.startswith("WIRING_")] + others = [k for k in c["secret_env"] if not k.startswith("WIRING_")] + if wiring: + lines += ["## Wiring", "", + "Resolved at deploy time from secrets the infrastructure lanes publish (names only):", + "", *[f"- `{k}`" for k in wiring], ""] + if others: + lines += ["## Secrets resolved by the lane (names only)", "", *[f"- `{k}`" for k in others], ""] + return "\n".join(lines) + + # turbo-package + if is_tests(c): + files = test_files(c) + lines += [f"A test package at `{c['path']}`. Its lane runs the suite before it builds.", ""] + if files: + lines += [f"## Suites ({len(files)})", "", *[f"- `{f}`" for f in files], ""] + return "\n".join(lines) + lines += [f"A workspace package at `{c['path']}`, consumed at build time by the components", + "that depend on it. It holds no credentials and opens no connections of its own.", ""] + if pkg and pkg.get("exports"): + ex = pkg["exports"] + keys = sorted(ex.keys()) if isinstance(ex, dict) else ["."] + lines += ["## Exports", "", *[f"- `{k}`" for k in keys], ""] + return "\n".join(lines) + + +def runbook(c: dict, by_name: dict) -> str: + t = c["type"] + pkg = package_of(c) + lines = [f"# {c['name']} — runbook", "", "## How it runs", ""] + deploys = [e["name"] for e in c["envs"] + if any(ref == "github-push-main" for _, ref in e["rules"])] + if deploys and t in ("terraform", "db-migrate"): + lines += [f"Pull requests plan it; a merge to `main` applies it to " + f"{', '.join(f'`{e}`' for e in deploys)}."] + elif deploys: + lines += [f"Pull requests verify it; a merge to `main` deploys it to " + f"{', '.join(f'`{e}`' for e in deploys)}."] + else: + lines += ["Its lane runs on every pull request that changes it; it has no deployed surface."] + lines += ["CI plans what changed (`orun plan --changed`) and runs each lane with `orun run`;", + "the plan orders a component after everything it depends on.", ""] + + if pkg and pkg.get("scripts"): + name = pkg.get("name") + wanted = [s for s in ("dev", "build", "test", "typecheck", "lint", "preview") if s in pkg["scripts"]] + if name and wanted: + lines += ["## Local commands", "", "```bash", + *[f"pnpm --filter {name} {s}" for s in wanted], "```", ""] + + smoke = c["params"].get("smokeCommand") + if smoke and "No smoke" not in str(smoke): + lines += ["## Verify", "", "After a deploy the lane runs this smoke against the environment it", + "deployed (`ORUN_ENVIRONMENT`); `DEPLOYED_URL` overrides the URL:", "", + "```bash", str(smoke).strip(), "```", ""] + + lines += ["## Rollback", "", + "Revert the commit on `main`. The next convergence applies the previous desired", + "state; nothing was changed out of band, so there is nothing else to undo.", "", + "## Common failures", ""] + if t == "terraform": + lines += ["- **Provider authentication fails**: the workspace's provider connection is", + " missing or revoked. Reconnect it in the console; credentials are brokered", + " from it per run.", + "- **\"Already exists\" on a first apply**: state is empty but the resource is", + " not." + (" `adopt.tf` imports it at plan time; if it still fails, the resource" + " was renamed outside Terraform." if tf_facts(c)["adopt"] else + " Import it, or delete the stray resource, then re-run."), ""] + elif t == "db-migrate": + lines += ["- **An applied migration's file changed**: the run stops rather than guess.", + " Restore the file and write the change as a new migration.", + "- **The database is unreachable**: the infrastructure lane it depends on has", + " not applied for this environment; that lane runs first in a convergence.", ""] + elif t.startswith("cloudflare-"): + lines += ["- **A `WIRING_*` secret is missing at deploy**: an infrastructure lane upstream", + " has not applied for this environment yet. Within one convergence the plan", + " runs it first; on its own, re-run that lane.", + "- **The smoke fails right after a first deploy**: a new workers.dev route can", + " answer 4xx for a few seconds and the lane retries. A failure that persists", + " is a regression in the deployed code.", ""] + else: + lines += ["- **A dependent fails to build after a change here**: run `pnpm typecheck`", + " across the workspace before merging.", ""] + return "\n".join(lines) + + +# ── main ───────────────────────────────────────────────────────────────── + +def main() -> int: + check = "--check" in sys.argv[1:] + comps = discover() + if not comps: + print("no component.yaml found", file=sys.stderr) + return 1 + by_name = {c["name"]: c for c in comps} + dependents: dict[str, list[str]] = {c["name"]: [] for c in comps} + for c in comps: + for d in c["deps"]: + dependents.setdefault(d, []).append(c["name"]) + + drifted, written, leaks = [], 0, [] + for c in comps: + pages = { + "overview.md": overview(c, by_name, sorted(dependents.get(c["name"], []))), + "architecture.md": architecture(c, by_name), + "runbook.md": runbook(c, by_name), + } + for fname, body in pages.items(): + target = c["dir"] / "docs" / fname + for n, line in enumerate(body.splitlines(), 1): + m = FACTORY.search(line) + if m: + leaks.append(f"{rel(target)}:{n} would name {m.group(0)!r}") + current = target.read_text(encoding="utf-8") if target.exists() else None + if current == body: + continue + if check: + drifted.append(rel(target)) + continue + target.parent.mkdir(parents=True, exist_ok=True) + target.write_text(body, encoding="utf-8") + written += 1 + + if leaks: + print("✗ a generated page would name a path products do not have:", file=sys.stderr) + for l in leaks: + print(f" {l}", file=sys.stderr) + return 1 + if check: + if drifted: + print(f"✗ {len(drifted)} component doc(s) differ from what the manifests say:", file=sys.stderr) + for f in drifted: + print(f" {f}", file=sys.stderr) + print("\nRun: python3 tooling/catalog/gen-component-docs.py", file=sys.stderr) + return 1 + print(f"✓ component docs match {len(comps)} component.yaml file(s)") + return 0 + print(f"✓ wrote {written} page(s) for {len(comps)} component(s)") + return 0 + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/tooling/rebrand/rebrand.mjs b/tooling/rebrand/rebrand.mjs index a4f4977..c39dd49 100644 --- a/tooling/rebrand/rebrand.mjs +++ b/tooling/rebrand/rebrand.mjs @@ -181,7 +181,6 @@ const EXCLUDE_RE = new RegExp( // product claim to be a baseline called by the product's own name. "^\\.baseline/", "^pnpm-lock\\.yaml$", - "^kiox\\.lock$", // Migrations are immutable once applied: db-migrate compares each file's // sha256 to packages/db/src/manifest.ts and to the database's ledger, so // a byte renamed here would stop every later deploy; the Supabase CLI's From ff4339f20b0bba1e9f8b80f0c6738a40b845fc18 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 18 Oct 2026 14:22:13 +0000 Subject: [PATCH 2/6] =?UTF-8?q?SP6:=20decisions.md=20=E2=80=94=20autoconfi?= =?UTF-8?q?rm=20follows=20authEmailConfirmation,=20not=20SMTP?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01D8AmgTwmnp4M8mgmnS9aha --- ai/context/decisions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ai/context/decisions.md b/ai/context/decisions.md index 1fba2cf..9048c0e 100644 --- a/ai/context/decisions.md +++ b/ai/context/decisions.md @@ -14,7 +14,7 @@ reads in order. | 6 | Row-level security on every table in `public`, upstream's policies kept; migration `020` raises if any table lacks it | RLS is the app's access control over the Data API | risk SP-K | | 7 | No Hyperdrive | The app speaks PostgREST over HTTPS, never a Postgres socket | epic README | | 8 | `apps/web/wrangler.jsonc` is committed as the fixture render; stage and prod re-render it | The composition checks it exists before the build | risk SP-J | -| 9 | The supabase root points the project's Auth at the Worker (`supabase_settings`) and autoconfirms unless SMTP is configured | Auth emails and redirects must reach the product's own origin | risk SP-C | +| 9 | The supabase root points the project's Auth at the Worker (`supabase_settings`: Site URL and redirect allow-list) and autoconfirms sign-ups unless the component's `authEmailConfirmation` is `"true"` | Auth redirects must reach the product's own origin, and a project without its own SMTP emails only its organization's members | risk SP-C, `infra/terraform/supabase/terraform/main.tf` | | 10 | One landing (`01-product`) then the record (`02-docs`); supabase → db-migrate → web enforced on main, advisory on a pull request; stack-tectonic 0.19.0 | A landing has a fixed cost; 0.20.0's lane-scoped install is refused by Turbopack | `repo-blueprint.yaml`, `intent.yaml`, IMPLEMENTATION-STATUS (SP5) | | 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 (SP6) | | 12 | Component docs are generated from the manifests and checked in CI | A hand-written copy of the dependency graph and bindings drifts silently | `tooling/catalog/gen-component-docs.py` | From 474e83c476d047f19f7853a54615c4ec9f5d1149 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 18 Oct 2026 14:27:26 +0000 Subject: [PATCH 3/6] SP6: word the kiox criterion as the record allows MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Nothing outside this milestone's own record names kiox — the record of the removal necessarily does. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01D8AmgTwmnp4M8mgmnS9aha --- specs/epics/subscription-payments/epic.yaml | 2 +- specs/epics/subscription-payments/implementation-plan.md | 5 +++-- tasks/SP-7.TaskContract.yaml | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/specs/epics/subscription-payments/epic.yaml b/specs/epics/subscription-payments/epic.yaml index 1843b63..ca021c5 100644 --- a/specs/epics/subscription-payments/epic.yaml +++ b/specs/epics/subscription-payments/epic.yaml @@ -49,7 +49,7 @@ spec: tasks: [SP-6] - name: "SP6 — the cirrus standard" exitCriteria: - - "no file names kiox: orun is pinned where CI runs it (the orun-action `version:` in each workflow)" + - "nothing outside this milestone's own record names kiox: orun is pinned where CI runs it (the orun-action `version:` in each workflow)" - "every component carries generated docs/{overview,architecture,runbook}.md, and Baseline CI fails a pull request whose manifests and pages disagree" - "ai/context carries this repository's current.md, decisions.md and open-risks.md, and none of them ships to a product" - "every milestone's status row agrees with the tags" diff --git a/specs/epics/subscription-payments/implementation-plan.md b/specs/epics/subscription-payments/implementation-plan.md index 6cbb2a5..3e76d75 100644 --- a/specs/epics/subscription-payments/implementation-plan.md +++ b/specs/epics/subscription-payments/implementation-plan.md @@ -119,8 +119,9 @@ itself changing. - **Status that agrees with the tags.** SP5 is shipped and tagged. **Done when** -- `git grep -i kiox` finds nothing, and the leak gate and the offline - bootstrap pass without the two modules +- nothing outside this milestone's own record names kiox (`git grep -i + kiox`), and the leak gate and the offline bootstrap pass without the two + modules - the docs check is green in Baseline CI - this file, the status file and `epic.yaml` agree diff --git a/tasks/SP-7.TaskContract.yaml b/tasks/SP-7.TaskContract.yaml index 364bbcb..5291150 100644 --- a/tasks/SP-7.TaskContract.yaml +++ b/tasks/SP-7.TaskContract.yaml @@ -23,7 +23,7 @@ spec: - specs/** - tasks/** doneWhen: - - no file names kiox, and the leak gate and the offline bootstrap place a product without it + - nothing outside this milestone's own record names kiox, and the leak gate and the offline bootstrap place a product without it - every component has docs/overview.md, docs/architecture.md and docs/runbook.md, and `python3 tooling/catalog/gen-component-docs.py --check` is green in Baseline CI - ai/context carries current.md, decisions.md and open-risks.md for this repository (none of them ships) - every milestone's status row agrees with the tags From 43c9d3bacb27a907ac581ab5deed692eb66f924c Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 18 Oct 2026 14:35:18 +0000 Subject: [PATCH 4/6] Component docs: list optional and per-environment secrets The generator now reads `optionalSecretEnv` (listed as "(optional)") and secrets declared per environment under `subscribe.environments[]`, so a page no longer leaves out a secret its component declares. Its tables are laid out as prettier lays them out, the WIRING_* failure is listed only for Workers that take wiring, and a package is no longer said to hold no credentials. Every starter now carries the identical generator. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01D8AmgTwmnp4M8mgmnS9aha --- apps/web/docs/architecture.md | 21 +++-- apps/web/docs/overview.md | 10 +-- infra/db-migrate/docs/overview.md | 8 +- infra/terraform/supabase/docs/architecture.md | 10 +-- infra/terraform/supabase/docs/overview.md | 8 +- packages/db/docs/architecture.md | 4 +- packages/db/docs/overview.md | 10 +-- tests/db/docs/overview.md | 10 +-- tests/web/docs/overview.md | 10 +-- tooling/catalog/gen-component-docs.py | 88 ++++++++++++------- 10 files changed, 107 insertions(+), 72 deletions(-) diff --git a/apps/web/docs/architecture.md b/apps/web/docs/architecture.md index 2c32b00..49802e3 100644 --- a/apps/web/docs/architecture.md +++ b/apps/web/docs/architecture.md @@ -2,19 +2,26 @@ Built by the turbo pipeline from `apps/web` and deployed with wrangler. -| | | -|---|---| -| Worker config | `apps/web/wrangler.template.jsonc` | -| Entry | `.open-next/worker.js` | -| Compatibility date | `2026-10-01` | +| | | +| ------------------- | ----------------------------------------------- | +| Worker config | `apps/web/wrangler.template.jsonc` | +| Entry | `.open-next/worker.js` | +| Compatibility date | `2026-10-01` | | Compatibility flags | `nodejs_compat`, `global_fetch_strictly_public` | ## Bindings -| Binding | Kind | Source | -|---|---|---| +| Binding | Kind | Source | +| -------- | ------------- | ------------------- | | `ASSETS` | Static assets | `.open-next/assets` | ## Variables `NEXT_PUBLIC_SITE_URL`, `NEXT_PUBLIC_SUPABASE_ANON_KEY`, `NEXT_PUBLIC_SUPABASE_URL`. + +## Wiring + +Resolved at deploy time from secrets the infrastructure lanes publish (names only): + +- `WIRING_SUPABASE_PROD` +- `WIRING_SUPABASE_STAGE` diff --git a/apps/web/docs/overview.md b/apps/web/docs/overview.md index cdd0662..99adb6e 100644 --- a/apps/web/docs/overview.md +++ b/apps/web/docs/overview.md @@ -4,11 +4,11 @@ The Next.js Subscription Payments Starter — Supabase Auth, Stripe Checkout, Cu A Cloudflare Worker with Static Assets (server rendering plus static files), deployed per environment by its CI lane. -| | | -|---|---| -| Type | `cloudflare-workers-assets-turbo` | -| Source | `apps/web` | -| Package | `@app/web` | +| | | +| ------------ | ------------------------------------------------------------------------------------------------------------------ | +| Type | `cloudflare-workers-assets-turbo` | +| Source | `apps/web` | +| Package | `@app/web` | | Environments | `dev`: `verify` · `stage`: `verify`, `deploy` on a push to `main` · `prod`: `verify`, `deploy` on a push to `main` | ## Depends on diff --git a/infra/db-migrate/docs/overview.md b/infra/db-migrate/docs/overview.md index 0cb546d..f9b9355 100644 --- a/infra/db-migrate/docs/overview.md +++ b/infra/db-migrate/docs/overview.md @@ -4,10 +4,10 @@ Applies database migrations to stage and prod Supabase instances Applies this repository's ordered database migrations per environment: plan on pull requests, apply on merge to `main`. -| | | -|---|---| -| Type | `db-migrate` | -| Source | `infra/db-migrate` | +| | | +| ------------ | ------------------------------------------------------------------------------------------ | +| Type | `db-migrate` | +| Source | `infra/db-migrate` | | Environments | `stage`: `plan`, `apply` on a push to `main` · `prod`: `plan`, `apply` on a push to `main` | ## Depends on diff --git a/infra/terraform/supabase/docs/architecture.md b/infra/terraform/supabase/docs/architecture.md index a9bdad1..86f94a7 100644 --- a/infra/terraform/supabase/docs/architecture.md +++ b/infra/terraform/supabase/docs/architecture.md @@ -21,12 +21,12 @@ A `terraform` root at `infra/terraform/supabase/terraform`. Written as job-output secrets on each environment after an apply; deploy lanes downstream resolve them by name. -| Secret | Terraform output | -|---|---| -| `SUPABASE_PROJECT_REF` | `project_ref` | +| Secret | Terraform output | +| ---------------------- | ------------------- | +| `SUPABASE_PROJECT_REF` | `project_ref` | | `SUPABASE_DB_PASSWORD` | `database_password` | -| `SUPABASE_DB_URL` | `connection_uri` | -| `WIRING_SUPABASE` | `wiring` | +| `SUPABASE_DB_URL` | `connection_uri` | +| `WIRING_SUPABASE` | `wiring` | ## Resolved at run time (names only) diff --git a/infra/terraform/supabase/docs/overview.md b/infra/terraform/supabase/docs/overview.md index fed9eed..9bab1cb 100644 --- a/infra/terraform/supabase/docs/overview.md +++ b/infra/terraform/supabase/docs/overview.md @@ -4,10 +4,10 @@ Provisions Supabase projects for stage and prod, points their Auth at the app, a Terraform-managed infrastructure, planned and applied per environment by its CI lane. -| | | -|---|---| -| Type | `terraform` | -| Source | `infra/terraform/supabase` | +| | | +| ------------ | ---------------------------------------------------------------------------------------------------- | +| Type | `terraform` | +| Source | `infra/terraform/supabase` | | Environments | `stage`: `plan-only`, `apply` on a push to `main` · `prod`: `plan-only`, `apply` on a push to `main` | ## Depends on diff --git a/packages/db/docs/architecture.md b/packages/db/docs/architecture.md index 135d4b4..3f9b079 100644 --- a/packages/db/docs/architecture.md +++ b/packages/db/docs/architecture.md @@ -1,7 +1,7 @@ # db — architecture -A workspace package at `packages/db`, consumed at build time by the components -that depend on it. It holds no credentials and opens no connections of its own. +A workspace package at `packages/db`, consumed by the components that depend +on it. It has no deployed surface of its own. ## Exports diff --git a/packages/db/docs/overview.md b/packages/db/docs/overview.md index 859cdce..c0097af 100644 --- a/packages/db/docs/overview.md +++ b/packages/db/docs/overview.md @@ -4,11 +4,11 @@ The database migrations and their runner (built by the db-migrate component befo A workspace package built by the turbo pipeline. It deploys nothing itself: its lane type-checks, lints, tests and builds it. -| | | -|---|---| -| Type | `turbo-package` | -| Source | `packages/db` | -| Package | `@saas/db` | +| | | +| ------------ | --------------------------------------------------------------------- | +| Type | `turbo-package` | +| Source | `packages/db` | +| Package | `@saas/db` | | Environments | `dev`: `quick-check` · `stage`: `quick-check` · `prod`: `quick-check` | ## Depends on diff --git a/tests/db/docs/overview.md b/tests/db/docs/overview.md index 9bdd262..ea4ef3f 100644 --- a/tests/db/docs/overview.md +++ b/tests/db/docs/overview.md @@ -2,11 +2,11 @@ The test suite for **db**. It deploys nothing: its lane installs, builds and runs the tests. -| | | -|---|---| -| Type | `turbo-package` | -| Source | `tests/db` | -| Package | `@app/db-tests` | +| | | +| ------------ | -------------------- | +| Type | `turbo-package` | +| Source | `tests/db` | +| Package | `@app/db-tests` | | Environments | `dev`: `quick-check` | ## Depends on diff --git a/tests/web/docs/overview.md b/tests/web/docs/overview.md index 6e02b2d..3534e6b 100644 --- a/tests/web/docs/overview.md +++ b/tests/web/docs/overview.md @@ -2,11 +2,11 @@ The test suite for **web**. It deploys nothing: its lane installs, builds and runs the tests. -| | | -|---|---| -| Type | `turbo-package` | -| Source | `tests/web` | -| Package | `@app/web-tests` | +| | | +| ------------ | -------------------- | +| Type | `turbo-package` | +| Source | `tests/web` | +| Package | `@app/web-tests` | | Environments | `dev`: `quick-check` | ## Depends on diff --git a/tooling/catalog/gen-component-docs.py b/tooling/catalog/gen-component-docs.py index 2a6a8b8..9a39931 100644 --- a/tooling/catalog/gen-component-docs.py +++ b/tooling/catalog/gen-component-docs.py @@ -119,7 +119,13 @@ def read_component(file: pathlib.Path) -> dict: params = spec.get("parameters") or {} deps = [d.get("component") for d in (spec.get("dependsOn") or []) if isinstance(d, dict)] envs = [] + # Secrets may be declared for the whole component or per environment + # (`subscribe.environments[].secretEnv`); a page lists both. + req_env = set((spec.get("secretEnv") or {}).keys()) + opt_env = set((spec.get("optionalSecretEnv") or {}).keys()) for e in ((spec.get("subscribe") or {}).get("environments") or []): + req_env |= set((e.get("secretEnv") or {}).keys()) + opt_env |= set((e.get("optionalSecretEnv") or {}).keys()) rules = [(r.get("profile"), ((r.get("when") or {}).get("triggerRef"))) for r in (e.get("profileRules") or [])] envs.append({"name": e.get("name"), "profile": e.get("profile"), "rules": rules}) @@ -130,7 +136,8 @@ def read_component(file: pathlib.Path) -> dict: "description": (meta.get("description") or "").strip(), "type": spec.get("type"), "deps": [d for d in deps if d], - "secret_env": sorted((spec.get("secretEnv") or {}).keys()), + "secret_env": sorted(req_env), + "optional_env": sorted(opt_env - req_env), "envs": envs, "params": params, "migrations_path": spec.get("path") if spec.get("type") == "db-migrate" else None, @@ -232,6 +239,18 @@ def migrations(c: dict) -> list[str]: return sorted(p.name for p in d.iterdir() if p.is_dir() or p.suffix == ".sql") +# ── markdown ───────────────────────────────────────────────────────────── + +def md_table(header: list[str], rows: list[list[str]]) -> list[str]: + """A table laid out the way prettier lays it out, so a repo whose lint is + `prettier --check` accepts the page as written.""" + cols = len(header) + width = [max(3, len(header[i]), *(len(r[i]) for r in rows)) for i in range(cols)] + def line(cells): + return "| " + " | ".join(c.ljust(width[i]) for i, c in enumerate(cells)) + " |" + return [line(header), "| " + " | ".join("-" * w for w in width) + " |", *(line(r) for r in rows)] + + # ── phrasing ───────────────────────────────────────────────────────────── KIND = { @@ -266,6 +285,14 @@ def subject_of(c: dict, by_name: dict) -> str | None: return None +def names_list(c: dict, keep) -> list[str]: + """Secret names a lane resolves, required first; an optional one (from + `optionalSecretEnv`) is resolved when it exists and skipped when not.""" + req = [f"- `{k}`" for k in c["secret_env"] if keep(k)] + opt = [f"- `{k}` (optional)" for k in c["optional_env"] if keep(k)] + return req + opt + + def bullet_list(names: list[str], by_name: dict) -> list[str]: if not names: return ["- (none)"] @@ -288,11 +315,12 @@ def overview(c: dict, by_name: dict, dependents: list[str]) -> str: lines = [f"# {c['name']}", ""] if c["description"]: lines += [c["description"], ""] - lines += [kind, "", "| | |", "|---|---|", f"| Type | `{c['type']}` |", f"| Source | `{c['path']}` |"] + facts = [["Type", f"`{c['type']}`"], ["Source", f"`{c['path']}`"]] if pkg and pkg.get("name"): - lines.append(f"| Package | `{pkg['name']}` |") + facts.append(["Package", f"`{pkg['name']}`"]) if c["envs"]: - lines.append(f"| Environments | {' · '.join(env_line(e) for e in c['envs'])} |") + facts.append(["Environments", " · ".join(env_line(e) for e in c["envs"])]) + lines += [kind, "", *md_table(["", ""], facts)] lines += ["", "## Depends on", "", *bullet_list(c["deps"], by_name), "", "## Depended on by", "", *bullet_list(dependents, by_name), ""] return "\n".join(lines) @@ -321,13 +349,11 @@ def architecture(c: dict, by_name: dict) -> str: lines += ["## Published outputs", "", "Written as job-output secrets on each environment after an apply; deploy", "lanes downstream resolve them by name.", "", - "| Secret | Terraform output |", "|---|---|", - *[f"| `{k}` | `{v}` |" for k, v in pub], ""] + *md_table(["Secret", "Terraform output"], [[f"`{k}`", f"`{v}`"] for k, v in pub]), ""] elif f["outputs"]: lines += ["## Outputs", "", *[f"- `{o}`" for o in f["outputs"]], ""] - if c["secret_env"]: - lines += ["## Resolved at run time (names only)", "", - *[f"- `{k}`" for k in c["secret_env"]], ""] + if c["secret_env"] or c["optional_env"]: + lines += ["## Resolved at run time (names only)", "", *names_list(c, lambda k: True), ""] return "\n".join(lines) if t == "db-migrate": @@ -337,9 +363,8 @@ def architecture(c: dict, by_name: dict) -> str: "is never edited: a change is a new, later migration.", ""] if migs: lines += ["## Migrations", "", *[f"- `{m}`" for m in migs], ""] - if c["secret_env"]: - lines += ["## Resolved at run time (names only)", "", - *[f"- `{k}`" for k in c["secret_env"]], ""] + if c["secret_env"] or c["optional_env"]: + lines += ["## Resolved at run time (names only)", "", *names_list(c, lambda k: True), ""] return "\n".join(lines) pkg = package_of(c) @@ -347,21 +372,20 @@ def architecture(c: dict, by_name: dict) -> str: cfg_name, cfg = worker_config(c) lines += [f"Built by the turbo pipeline from `{c['path']}` and deployed with wrangler.", ""] if cfg: - lines += ["| | |", "|---|---|", f"| Worker config | `{c['path']}/{cfg_name}` |"] + facts = [["Worker config", f"`{c['path']}/{cfg_name}`"]] if cfg.get("main"): - lines.append(f"| Entry | `{cfg['main']}` |") + facts.append(["Entry", f"`{cfg['main']}`"]) if cfg.get("compatibility_date"): - lines.append(f"| Compatibility date | `{cfg['compatibility_date']}` |") + facts.append(["Compatibility date", f"`{cfg['compatibility_date']}`"]) if cfg.get("compatibility_flags"): - lines.append(f"| Compatibility flags | {', '.join(f'`{x}`' for x in cfg['compatibility_flags'])} |") - lines.append("") + facts.append(["Compatibility flags", ", ".join(f"`{x}`" for x in cfg["compatibility_flags"])]) + lines += [*md_table(["", ""], facts), ""] rows = bindings(cfg) lines += ["## Bindings", ""] if rows: - lines += ["| Binding | Kind | Source |", "|---|---|---|", - *[f"| `{b}` | {k} | {s} |" for b, k, s in rows], ""] + lines += [*md_table(["Binding", "Kind", "Source"], [[f"`{b}`", k, s] for b, k, s in rows]), ""] if any("from `" in s for _, _, s in rows): - lines += ["Identifiers marked *from* a component are filled in at deploy time from", + lines += ["Identifiers marked _from_ a component are filled in at deploy time from", "that component's published outputs for the environment being deployed.", ""] else: lines += ["None: the Worker binds no storage or service.", ""] @@ -374,14 +398,14 @@ def architecture(c: dict, by_name: dict) -> str: lines += ["## Variables", "", ", ".join(f"`{v}`" for v in var_names) + (f" — overridden per environment ({', '.join(f'`{e}`' for e in env_names)})." if env_names else "."), ""] - wiring = [k for k in c["secret_env"] if k.startswith("WIRING_")] - others = [k for k in c["secret_env"] if not k.startswith("WIRING_")] + wiring = names_list(c, lambda k: k.startswith("WIRING_")) + others = names_list(c, lambda k: not k.startswith("WIRING_")) if wiring: lines += ["## Wiring", "", "Resolved at deploy time from secrets the infrastructure lanes publish (names only):", - "", *[f"- `{k}`" for k in wiring], ""] + "", *wiring, ""] if others: - lines += ["## Secrets resolved by the lane (names only)", "", *[f"- `{k}`" for k in others], ""] + lines += ["## Secrets resolved by the lane (names only)", "", *others, ""] return "\n".join(lines) # turbo-package @@ -391,8 +415,8 @@ def architecture(c: dict, by_name: dict) -> str: if files: lines += [f"## Suites ({len(files)})", "", *[f"- `{f}`" for f in files], ""] return "\n".join(lines) - lines += [f"A workspace package at `{c['path']}`, consumed at build time by the components", - "that depend on it. It holds no credentials and opens no connections of its own.", ""] + lines += [f"A workspace package at `{c['path']}`, consumed by the components that depend", + "on it. It has no deployed surface of its own.", ""] if pkg and pkg.get("exports"): ex = pkg["exports"] keys = sorted(ex.keys()) if isinstance(ex, dict) else ["."] @@ -448,10 +472,14 @@ def runbook(c: dict, by_name: dict) -> str: "- **The database is unreachable**: the infrastructure lane it depends on has", " not applied for this environment; that lane runs first in a convergence.", ""] elif t.startswith("cloudflare-"): - lines += ["- **A `WIRING_*` secret is missing at deploy**: an infrastructure lane upstream", - " has not applied for this environment yet. Within one convergence the plan", - " runs it first; on its own, re-run that lane.", - "- **The smoke fails right after a first deploy**: a new workers.dev route can", + _, cfg = worker_config(c) + takes_wiring = any(k.startswith("WIRING_") for k in c["secret_env"] + c["optional_env"]) or \ + bool(cfg and WIRING.search(json.dumps(cfg))) + if takes_wiring: + lines += ["- **A `WIRING_*` secret is missing at deploy**: an infrastructure lane upstream", + " has not applied for this environment yet. Within one convergence the plan", + " runs it first; on its own, re-run that lane."] + lines += ["- **The smoke fails right after a first deploy**: a new workers.dev route can", " answer 4xx for a few seconds and the lane retries. A failure that persists", " is a regression in the deployed code.", ""] else: From e749c1db809780cae08a15a08c487e6945ad4a77 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 21 Oct 2026 12:10:27 +0000 Subject: [PATCH 5/6] SP6: read the workers.dev subdomain from the Cloudflare connection - blueprint.yaml: the subdomain input is `from: connection.cloudflare.workersSubdomain`, as cirrus-baseline since baseline-v23 (#30); the console renders no field for it - testing/manifest.test.sh: cirrus's rule verbatim, accepting the source only when spec.requires.integrations lists its provider (mutation-checked) - repo-blueprint.yaml, BOOTSTRAP.md, docs/phases/README.md: only a hand-run build passes --set subdomain - records: SP-8 under SP6, status, plan, epic index, ai/context Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01D8AmgTwmnp4M8mgmnS9aha --- BOOTSTRAP.md | 6 +++ ai/context/current.md | 10 ++--- ai/context/decisions.md | 1 + blueprint.yaml | 13 ++++++ docs/phases/README.md | 8 ++-- repo-blueprint.yaml | 5 ++- specs/epics/README.md | 2 +- .../IMPLEMENTATION-STATUS.md | 41 ++++++++++++++++++- specs/epics/subscription-payments/README.md | 6 +-- specs/epics/subscription-payments/epic.yaml | 3 +- .../implementation-plan.md | 5 +++ tasks/SP-8.TaskContract.yaml | 25 +++++++++++ testing/manifest.test.sh | 15 ++++++- 13 files changed, 123 insertions(+), 17 deletions(-) create mode 100644 tasks/SP-8.TaskContract.yaml diff --git a/BOOTSTRAP.md b/BOOTSTRAP.md index 4cb5a0c..bcfd572 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 c188008..e77b56e 100644 --- a/ai/context/current.md +++ b/ai/context/current.md @@ -22,8 +22,8 @@ afterwards; the app deploys and serves without it. | | | |---|---| -| Latest tag | `baseline-v1` (SP5, [#6](https://github.com/sourceplane/subscription-payments/pull/6)) | -| On `main` since | SP6 — the cirrus standard (no kiox, generated component docs, this context pack) | +| Latest tag | `baseline-v2` (SP6 — the cirrus standard, [#7](https://github.com/sourceplane/subscription-payments/pull/7) and [#8](https://github.com/sourceplane/subscription-payments/pull/8): no kiox, generated component docs, this context pack, and the workers.dev subdomain read from the Cloudflare connection instead of asked) | +| Before it | `baseline-v1` (SP5, [#6](https://github.com/sourceplane/subscription-payments/pull/6)) | | Proven live | No. Everything short of the platform is proven offline in Baseline CI: the e2e tier migrates a local Postgres under the real Supabase Auth and Data API with the product's own runner, builds in orun's staged job tree, and signs a user up and in with no Stripe key. No bootstrap from a tag has run against a workspace: the Supabase root's apply through the brokered token (SP-M), db-migrate against a real project, the service-role push, a real deploy and the card's twenty minutes (SP-N) are unproven | ## Where to read @@ -38,6 +38,6 @@ afterwards; the app deploys and serves without it. ## Next -1. Bootstrap one product from a tag against a workspace with Cloudflare and - Supabase connected, and record its timings (closes SP-M and SP-N). -2. Cut the next `baseline-vN` with `tag.yml` so the registry can pin SP6. +1. Bootstrap one product from `baseline-v2` against a workspace with + Cloudflare and Supabase connected, and record its timings (closes SP-M + and SP-N). diff --git a/ai/context/decisions.md b/ai/context/decisions.md index 9048c0e..f0192df 100644 --- a/ai/context/decisions.md +++ b/ai/context/decisions.md @@ -18,3 +18,4 @@ reads in order. | 10 | One landing (`01-product`) then the record (`02-docs`); supabase → db-migrate → web enforced on main, advisory on a pull request; stack-tectonic 0.19.0 | A landing has a fixed cost; 0.20.0's lane-scoped install is refused by Turbopack | `repo-blueprint.yaml`, `intent.yaml`, IMPLEMENTATION-STATUS (SP5) | | 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 (SP6) | | 12 | Component docs are generated from the manifests and checked in CI | A hand-written copy of the dependency graph and bindings drifts silently | `tooling/catalog/gen-component-docs.py` | +| 13 | `subdomain` is read from the Cloudflare connection (`from: connection.cloudflare.workersSubdomain`), never asked | It belongs to the account like its id and has one right answer; a typed one could only be wrong, and showed up after deploy in the origin Stripe and Supabase Auth return to, the smoke and the probes | `blueprint.yaml`, IMPLEMENTATION-STATUS (SP-8) | diff --git a/blueprint.yaml b/blueprint.yaml index 30e10dc..3765ff0 100644 --- a/blueprint.yaml +++ b/blueprint.yaml @@ -95,6 +95,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 origin Stripe and Supabase Auth send visitors + # back to, the deploy's smoke, the phase probes and the verify URLs + # below. The integration reads it from Cloudflare at connect and on its + # hourly health check; the bootstrap door fills this input from the + # connection the build is BOUND to, the same one CLOUDFLARE_ACCOUNT_ID + # and the deploy tokens mint from, so all three name one account. The + # console renders no field for it. An account with no workers.dev + # subdomain refuses the build at the door, naming the fix, before + # anything is created. + from: connection.cloudflare.workersSubdomain # ── PREVIEW ONLY. repo-blueprint.yaml's `orun.integrations/reconcile@v1` # hooks mint these, brokered, during 01-product. ───────────────────────── diff --git a/docs/phases/README.md b/docs/phases/README.md index 792122a..443a5d8 100644 --- a/docs/phases/README.md +++ b/docs/phases/README.md @@ -61,9 +61,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, in the origin Stripe returns visitors to, - and in the Site URL the Supabase root gives the project's Auth. +- `subdomain` — the workers.dev subdomain of the Cloudflare account you + deploy into. It is in every URL the phases probe, in the origin Stripe + returns visitors to, and in the Site URL the Supabase root gives the + project's Auth. 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 acfb80c..2c6e821 100644 --- a/repo-blueprint.yaml +++ b/repo-blueprint.yaml @@ -57,7 +57,10 @@ inputs: description: >- The workers.dev subdomain of the Cloudflare account the app deploys into — its URLs, the origin Stripe and Supabase Auth send visitors back - to, the probes. + to, 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 d195e05..aa17c6a 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 | |------|---------|--------|------------| -| [`subscription-payments/`](./subscription-payments/) | **SP** | ✅ Shipped (`baseline-v1`); live bootstrap pending | Vercel's Next.js Subscription Payments Starter, equivalent in code and function, on Cloudflare Workers with Supabase provisioned and migrated through Orun — and an Orun baseline that instantiates it in one landing (SP5) | +| [`subscription-payments/`](./subscription-payments/) | **SP** | ✅ Shipped (`baseline-v2`); live bootstrap pending | Vercel's Next.js Subscription Payments Starter, equivalent in code and function, on Cloudflare Workers with Supabase provisioned and migrated through Orun — and an Orun baseline that instantiates it in one landing (SP5) | As-built ≠ intent: what shipped lives in each epic's `IMPLEMENTATION-STATUS.md`. diff --git a/specs/epics/subscription-payments/IMPLEMENTATION-STATUS.md b/specs/epics/subscription-payments/IMPLEMENTATION-STATUS.md index 2507918..dac3619 100644 --- a/specs/epics/subscription-payments/IMPLEMENTATION-STATUS.md +++ b/specs/epics/subscription-payments/IMPLEMENTATION-STATUS.md @@ -11,7 +11,7 @@ the code departed from `design.md` or from the upstream template. | SP3 — the Supabase project from Terraform | ✅ Shipped (validated; apply gated on a linked workspace) | [#4](https://github.com/sourceplane/subscription-payments/pull/4) | | SP4 — ready to instantiate | ✅ Shipped | [#5](https://github.com/sourceplane/subscription-payments/pull/5) | | SP5 — a baseline | ✅ Shipped | [#6](https://github.com/sourceplane/subscription-payments/pull/6) (SP-6), tagged `baseline-v1` | -| SP6 — the cirrus standard | ✅ Shipped | SP-7 — on `main` after `baseline-v1`, not yet tagged | +| SP6 — the cirrus standard | ✅ Shipped | [#7](https://github.com/sourceplane/subscription-payments/pull/7) (SP-7), [#8](https://github.com/sourceplane/subscription-payments/pull/8) (SP-8), tagged `baseline-v2` | ## Departures from the upstream template @@ -339,6 +339,45 @@ Nothing about the app 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 | SP5 "in review", on a branch | SP5 shipped and tagged `baseline-v1` | the tag existed; the documents had not caught up | +### The subdomain from the Cloudflare connection (SP-8) + +`subdomain` was the one input an operator typed that the platform could +answer itself: it belongs to the Cloudflare account the same way its id does, +and it has exactly one right answer. A typed one could only be wrong, and +wrong showed up after deploy — in the origin Stripe and Supabase Auth send +visitors back to, the deploy's smoke, the phase probes and the console's +verify URLs. `blueprint.yaml` now declares +`from: connection.cloudflare.workersSubdomain`, as cirrus-baseline does since +baseline-v23: the Cloudflare integration reads the subdomain at connect and on +its hourly health check, and the bootstrap door fills the input from the +connection the build is bound to — the same one `CLOUDFLARE_ACCOUNT_ID` and the +deploy tokens mint from. The console renders no field for it, and an account +with no workers.dev subdomain is refused at the door with the fix named. + +- `testing/manifest.test.sh` takes cirrus-baseline's rule verbatim: the source + is accepted, and only when `spec.requires.integrations` lists its provider. +- `repo-blueprint.yaml` keeps the input and its default; it, `BOOTSTRAP.md` + and `docs/phases/README.md` say only a hand-run build passes + `--set subdomain`. +- Nothing a product carries changes: the rename writes the value where it + always did (`workersDevSubdomain` on the web and Supabase components, the + site URL, the URLs), and the probes read it as before. + +Verified: + +- `testing/{manifest,phases,coverage,rebrand,retouch,bootstrap-defer}.test.sh` + green; `gen-component-docs.py --check` green (6 components). +- Mutation: with `cloudflare` dropped from `spec.requires.integrations`, + `manifest.test.sh` fails with exactly one finding, naming + `inputs[subdomain]`; restored, it passes. +- At v2.58.11 (the blueprint job's pin, placement included): + `orun new --status` reads the document (`01-product` pending, 181 files); + `testing/leak.test.sh` 181 files derived, 174 text files read; + `testing/placement.test.sh` 181 files placed, both landings, the product's + own plan orders supabase → db-migrate → web on stage and prod; `--resume` + changes nothing. +- `orun task check SP-8` complete. + ## Verified (SP6) - `testing/{manifest,phases,coverage,rebrand,retouch,bootstrap-defer}.test.sh` diff --git a/specs/epics/subscription-payments/README.md b/specs/epics/subscription-payments/README.md index 4df8765..590424a 100644 --- a/specs/epics/subscription-payments/README.md +++ b/specs/epics/subscription-payments/README.md @@ -8,7 +8,7 @@ The upstream code stays the code: the `@supabase/ssr` clients and the session-re | Field | Value | |-------|-------| -| Status | ✅ SP0–SP5 shipped (#1–#6), tagged `baseline-v1`; SP6 (the cirrus standard, SP-7) on `main`, not yet tagged. Not yet proven by a live bootstrap: the Supabase and migration applies and a live deploy (risks SP-M, SP-N); Stripe keys are the product owner's | +| Status | ✅ SP0–SP5 shipped (#1–#6), tagged `baseline-v1`; SP6 (the cirrus standard, SP-7 #7 and SP-8 #8) tagged `baseline-v2`. Not yet proven by a live bootstrap: the Supabase and migration applies and a live deploy (risks SP-M, SP-N); Stripe keys are the product owner's | | Cluster | **SP** (SP0–SP6) | | Owner(s) | `apps/web` (the app) · `tests/web` (helper and webhook tests) · `packages/db` + `infra/db-migrate` + `tests/db` (the schema) · `infra/terraform/supabase` (the project) | | Builds on | `lumen` conventions — the `supabase` Terraform root, the `@saas/db` runner and `db-migrate` component, the orun-secrets wiring; `supabase-starter` for the app-on-Workers shape; `cirrus-baseline` conventions for the repository shape | @@ -16,7 +16,7 @@ The upstream code stays the code: the `@supabase/ssr` clients and the session-re | Changes | Adds the Workers build, the monorepo wrapper, tests, the migrations package, the db-migrate component, the Supabase root and the deploy contract; the template's code changes only where Next 16 / Workers force it (every change is in `IMPLEMENTATION-STATUS.md`) | | Decisions locked | (1) OpenNext on Workers + Static Assets. (2) The anon key is a wrangler var, not a secret: RLS protects the data; the service-role key and the Stripe secrets are Worker secrets — the service-role key pushed by every deploy from `WIRING_SUPABASE` (SP5), the Stripe keys added by the owner when ready, the app deploying and serving without them (SP5). (3) `wrangler.jsonc` rendered from the template: committed as the fixture render (the composition checks it exists before the build), re-rendered per environment from the wiring document by the deploy lanes, which the build inlines (SP5; it was never committed before). (4) The schema is applied by the `@saas/db` runner through Supabase's Management API, from the template's `init.sql` verbatim — not by `supabase db push` in CI — then RLS checked on every table (`020`, SP5). (5) No Hyperdrive: the app speaks PostgREST over HTTPS, never a Postgres socket. (6) `stripe` stays on v14: it already has the fetch client and async webhook verification. (7) Infra before app on main: supabase → db-migrate → web, enforced; advisory on pull requests (SP5). | | Gate | SP1 is the first user-visible rung. SP2 and SP3 need a workspace with a Supabase connection to apply; they are verified by `plan` / `terraform validate`. Checkout and the webhook need the product's Stripe keys as Worker secrets (the one manual step, see `design.md` §3). | -| Shipped as | `baseline-v1` ([#6](https://github.com/sourceplane/subscription-payments/pull/6)), then SP6 on `main`; proven offline (Baseline CI: contract, leak, placement and the e2e tier over a local Supabase Auth and Data API), deploy gated until a workspace is linked | +| Shipped as | `baseline-v1` ([#6](https://github.com/sourceplane/subscription-payments/pull/6)), then `baseline-v2` (SP6: [#7](https://github.com/sourceplane/subscription-payments/pull/7), [#8](https://github.com/sourceplane/subscription-payments/pull/8)); proven offline (Baseline CI: contract, leak, placement and the e2e tier over a local Supabase Auth and Data API), deploy gated until a workspace is linked | ## Read order @@ -35,4 +35,4 @@ The upstream code stays the code: the `@supabase/ssr` clients and the session-re | SP3 — the Supabase project from Terraform | `infra/terraform/supabase`, the app's `secretEnv` and `dependsOn` it completes | the root validates; the secret and wiring keys match the component | | SP4 — ready to instantiate | README, as-built status | a reader can run, test, preview, configure Stripe and deploy it | | SP5 — a baseline | card, build document, rename, bootstrap tooling, the product's README and context pack, tests | a new product goes from nothing to live on stage and prod in one landing, with no Stripe key, every table behind RLS; Baseline CI green | -| SP6 — the cirrus standard | no kiox, generated component docs, the context pack, status that agrees with the tags | Baseline CI green with the docs check | +| SP6 — the cirrus standard | no kiox, generated component docs, the context pack, status that agrees with the tags; the subdomain read from the Cloudflare connection | Baseline CI green with the docs check; the card asks for no subdomain | diff --git a/specs/epics/subscription-payments/epic.yaml b/specs/epics/subscription-payments/epic.yaml index ca021c5..b54425a 100644 --- a/specs/epics/subscription-payments/epic.yaml +++ b/specs/epics/subscription-payments/epic.yaml @@ -53,4 +53,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: [SP-7] + - "the console card reads subdomain from the Cloudflare connection (from: connection.cloudflare.workersSubdomain), as cirrus-baseline since baseline-v23" + tasks: [SP-7, SP-8] diff --git a/specs/epics/subscription-payments/implementation-plan.md b/specs/epics/subscription-payments/implementation-plan.md index 3e76d75..7001638 100644 --- a/specs/epics/subscription-payments/implementation-plan.md +++ b/specs/epics/subscription-payments/implementation-plan.md @@ -117,6 +117,11 @@ itself changing. `open-risks.md` beside the two pages a product ships with — this repository's own, so no module places them. - **Status that agrees with the tags.** SP5 is shipped and tagged. +- **The subdomain from the Cloudflare connection (SP-8).** The card declares + `subdomain` as `from: connection.cloudflare.workersSubdomain`, as + cirrus-baseline does since baseline-v23, so the console asks for nothing the + connection already knows; `testing/manifest.test.sh` requires the source's + provider in `spec.requires.integrations`. **Done when** - nothing outside this milestone's own record names kiox (`git grep -i diff --git a/tasks/SP-8.TaskContract.yaml b/tasks/SP-8.TaskContract.yaml new file mode 100644 index 0000000..8d6d007 --- /dev/null +++ b/tasks/SP-8.TaskContract.yaml @@ -0,0 +1,25 @@ +apiVersion: orun.io/v1 +kind: TaskContract +metadata: + name: SP-8 + title: "The subdomain from the Cloudflare connection" +spec: + goal: "The console card reads the workers.dev subdomain from the workspace's Cloudflare connection (`from: connection.cloudflare.workersSubdomain`) instead of asking for it, as cirrus-baseline does since baseline-v23, and the manifest gate holds that source to a connection the card requires" + affects: + - blueprint.yaml + - repo-blueprint.yaml + - testing/manifest.test.sh + - BOOTSTRAP.md + - docs/phases/README.md + - ai/context/current.md + - ai/context/decisions.md + - specs/epics/README.md + - specs/epics/subscription-payments/** + - tasks/SP-8.TaskContract.yaml + doneWhen: + - "blueprint.yaml declares `from: connection.cloudflare.workersSubdomain` on `subdomain`, so the console renders no field for it" + - testing/manifest.test.sh accepts that source only when spec.requires.integrations lists its provider, and fails naming the input when it does not (mutation-checked) + - BOOTSTRAP.md, docs/phases and repo-blueprint.yaml say only a hand-run build passes `--set subdomain` + - the contract tests, the docs check, the leak gate and the offline bootstrap are green + gates: + - checks diff --git a/testing/manifest.test.sh b/testing/manifest.test.sh index 3fd6af8..5374cb5 100755 --- a/testing/manifest.test.sh +++ b/testing/manifest.test.sh @@ -217,9 +217,20 @@ for path in manifests: # field for it (saas-bootstrap-console BC-K5). Two ways to get it # wrong, and the platform refuses both — check them here too, so the # mistake is caught in this repo rather than at a live bootstrap. + # + # A `connection..` source is read from the connection + # the build is bound to, so the provider must be one the manifest + # requires — the platform's parser refuses it otherwise. + sources_known = ("repo.name", "repo.owner", "repo.fullName", + "connection.cloudflare.workersSubdomain") src = field.get("from") - if src is not None and src not in ("repo.name", "repo.owner", "repo.fullName"): - B(f"inputs[{key}].from is {src!r} — must be repo.name, repo.owner or repo.fullName") + if src is not None and src not in sources_known: + B(f"inputs[{key}].from is {src!r} — must be one of {', '.join(sources_known)}") + if isinstance(src, str) and src.startswith("connection."): + provider = src.split(".")[1] + if provider not in ((spec.get("requires") or {}).get("integrations") or []): + B(f"inputs[{key}].from is {src!r} but spec.requires.integrations " + f"does not list {provider} — there is no connection to read it from") # ── secrets: BOTH or NEITHER, checked both ways ─────────────────────── declared = {s.get("key"): (s.get("provider"), s.get("template")) for s in (spec.get("secrets") or [])} From 4338fca0b722c54f45e5858eff9aa014dd3d34ea Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 22 Oct 2026 03:48:42 +0000 Subject: [PATCH 6/6] =?UTF-8?q?SP7:=20the=20console=20asks=20for=20no=20do?= =?UTF-8?q?main=20=E2=80=94=20the=20domain=20is=20set=20later?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The app goes live on workers.dev from its first deploy, and every URL it builds (the site URL, the Supabase Auth origin, Stripe's return URLs and webhook) is that origin, so the console no longer asks for a domain. The logic that uses a domain stays where it is, waiting for one. - blueprint.yaml: no productdomain input - repo-blueprint.yaml: productdomain is optional, default empty - rebrand.mjs: productdomain no longer required; empty brands the reserved placeholder .example.com (RFC 2606) where the domain goes (BASE_DOMAIN in intent.yaml, every environment), so setting it later is replacing one string - the product README ("Custom domain") and ai/context/operations.md say how to set it, beside the site URL, Auth origin and Stripe webhook they list - testing/fixtures/acme.json carries no domain; rebrand.test.sh pins the placeholder; baseline.yml's blueprint read sets no domain - records: SP7 / SP-9, tagged baseline-v3 Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01D8AmgTwmnp4M8mgmnS9aha --- .baseline/product/README.md | 5 +- .github/workflows/baseline.yml | 1 - BOOTSTRAP.md | 14 ++++-- README.md | 2 +- ai/context/current.md | 7 +-- ai/context/decisions.md | 1 + ai/context/operations.md | 2 +- blueprint.yaml | 11 ++-- docs/phases/README.md | 12 +++-- repo-blueprint.yaml | 15 ++++-- specs/epics/README.md | 2 +- .../IMPLEMENTATION-STATUS.md | 50 +++++++++++++++++++ specs/epics/subscription-payments/README.md | 7 +-- specs/epics/subscription-payments/epic.yaml | 6 +++ .../implementation-plan.md | 9 ++++ tasks/SP-9.TaskContract.yaml | 30 +++++++++++ testing/fixtures/acme.json | 10 ++-- testing/rebrand.test.sh | 8 +++ tooling/rebrand/rebrand.mjs | 10 ++-- 19 files changed, 166 insertions(+), 36 deletions(-) create mode 100644 tasks/SP-9.TaskContract.yaml diff --git a/.baseline/product/README.md b/.baseline/product/README.md index 4f48e72..7bdb89f 100644 --- a/.baseline/product/README.md +++ b/.baseline/product/README.md @@ -162,7 +162,10 @@ own domain, attach the domain to the Worker in Cloudflare (Workers & Pages → `NEXT_PUBLIC_SITE_URL` in `apps/web/wrangler.template.jsonc` and the Auth origin (`app_origin`) in `infra/terraform/supabase/terraform/main.tf` to it, run `pnpm run wire:fixture`, merge, and point Stripe's webhook at the new -origin. +origin. In the same change, replace the reserved placeholder +`subscription-payments.example.com` the product was born with in +`intent.yaml`'s `BASE_DOMAIN` (one line per environment) — the one place the +repository names the domain itself. ## CI diff --git a/.github/workflows/baseline.yml b/.github/workflows/baseline.yml index e2c051b..4f04bf7 100644 --- a/.github/workflows/baseline.yml +++ b/.github/workflows/baseline.yml @@ -95,7 +95,6 @@ jobs: --out "$(mktemp -d)" \ --set reponame=acme-pay \ --set "productname=Acme Cloud" \ - --set productdomain=acme.dev \ --set githuborg=acme-inc - name: the leak gate — what a product carries run: bash testing/leak.test.sh diff --git a/BOOTSTRAP.md b/BOOTSTRAP.md index bcfd572..c56089d 100644 --- a/BOOTSTRAP.md +++ b/BOOTSTRAP.md @@ -62,7 +62,7 @@ cd subscription-payments orun new --blueprint repo-blueprint.yaml \ --out ~/products/acme-pay --run-hooks --resume \ --set reponame=acme-pay --set productname="Acme Cloud" \ - --set productdomain=acme.dev --set githuborg=acme-inc \ + --set githuborg=acme-inc \ --set orunWorkspace=ws_XXXXXXXX \ --set subdomain= ``` @@ -99,9 +99,13 @@ orun new --blueprint repo-blueprint.yaml --out ~/products/acme-pay --run-hooks \ `02-docs` reads the identity back from `.rebrand/values.json` in the placed tree, but the blueprint's **required** inputs — `reponame`, `productname`, -`productdomain`, `githuborg` — are validated before anything runs, so pass -them every time (a `--values` file is easier). The full guide, one page per -phase: [docs/phases/README.md](docs/phases/README.md). +`githuborg` — are validated before anything runs, so pass them every time (a +`--values` file is easier). The domain is not one of them: the product goes live +on workers.dev, and `productdomain` defaults to empty, which brands the +reserved placeholder `.example.com` into `BASE_DOMAIN` for an owner +to replace when they attach a domain (README, "Custom domain"). Pass +`--set productdomain=` only for a product that already has its domain. +The full guide, one page per phase: [docs/phases/README.md](docs/phases/README.md). | flag | what it does | |---|---| @@ -253,5 +257,5 @@ at the tag and refuses the whole catalogue if it 404s. | The convergence reported green, then `verify` got 404 | a second workflow ran on the push to main and the watch took its run. Only `ci.yml` may run on a push to main; `checks.yml` runs on pull requests only | | The product's `intent.yaml` says `workspace: ws_SET_ME` | `orunWorkspace` was empty and the build ran outside a workspace; set it and re-run `01-product` | | A bootstrap stopped before `02-docs`; prod no longer waits on stage | the gate is deferred, not dropped: run `02-docs`, or `node tooling/bootstrap/promotion.mjs --restore --file /intent.yaml` | -| `✕ input "productdomain" is required` | all four required inputs must be set on every invocation, single-phase ones included | +| `✕ input "productname" is required` | all three required inputs (`reponame`, `productname`, `githuborg`) must be set on every invocation, single-phase ones included | | `unknown flag: --phase` or a parse error in the blueprint | the CLI is below the v2.58.11 floor | diff --git a/README.md b/README.md index 12b8c50..3d2481c 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ departure. git clone --depth 1 --branch https://github.com/sourceplane/subscription-payments cd subscription-payments orun new --blueprint repo-blueprint.yaml --out ~/products/acme-pay --run-hooks --resume \ - --set reponame=acme-pay --set productname="Acme Cloud" --set productdomain=acme.dev \ + --set reponame=acme-pay --set productname="Acme Cloud" \ --set githuborg=acme-inc --set subdomain= ``` diff --git a/ai/context/current.md b/ai/context/current.md index e77b56e..7218889 100644 --- a/ai/context/current.md +++ b/ai/context/current.md @@ -22,8 +22,9 @@ afterwards; the app deploys and serves without it. | | | |---|---| -| Latest tag | `baseline-v2` (SP6 — the cirrus standard, [#7](https://github.com/sourceplane/subscription-payments/pull/7) and [#8](https://github.com/sourceplane/subscription-payments/pull/8): no kiox, generated component docs, this context pack, and the workers.dev subdomain read from the Cloudflare connection instead of asked) | -| Before it | `baseline-v1` (SP5, [#6](https://github.com/sourceplane/subscription-payments/pull/6)) | +| Latest tag | `baseline-v3` (SP7 — the domain is set later, [#9](https://github.com/sourceplane/subscription-payments/pull/9): the console asks for no domain, and a product is born with the placeholder `.example.com` for an owner to replace) | +| Before it | `baseline-v2` (SP6 — the cirrus standard, [#7](https://github.com/sourceplane/subscription-payments/pull/7) and [#8](https://github.com/sourceplane/subscription-payments/pull/8): no kiox, generated component docs, this context pack, and the workers.dev subdomain read from the Cloudflare connection instead of asked) | +| Before that | `baseline-v1` (SP5, [#6](https://github.com/sourceplane/subscription-payments/pull/6)) | | Proven live | No. Everything short of the platform is proven offline in Baseline CI: the e2e tier migrates a local Postgres under the real Supabase Auth and Data API with the product's own runner, builds in orun's staged job tree, and signs a user up and in with no Stripe key. No bootstrap from a tag has run against a workspace: the Supabase root's apply through the brokered token (SP-M), db-migrate against a real project, the service-role push, a real deploy and the card's twenty minutes (SP-N) are unproven | ## Where to read @@ -38,6 +39,6 @@ afterwards; the app deploys and serves without it. ## Next -1. Bootstrap one product from `baseline-v2` against a workspace with +1. Bootstrap one product from `baseline-v3` against a workspace with Cloudflare and Supabase connected, and record its timings (closes SP-M and SP-N). diff --git a/ai/context/decisions.md b/ai/context/decisions.md index f0192df..6080444 100644 --- a/ai/context/decisions.md +++ b/ai/context/decisions.md @@ -19,3 +19,4 @@ reads in order. | 11 | orun is pinned only where it runs (the `orun-action` `version:` in each workflow); no kiox | `kiox.yaml` pinned a version (v2.15.0) nothing ran | IMPLEMENTATION-STATUS (SP6) | | 12 | Component docs are generated from the manifests and checked in CI | A hand-written copy of the dependency graph and bindings drifts silently | `tooling/catalog/gen-component-docs.py` | | 13 | `subdomain` is read from the Cloudflare connection (`from: connection.cloudflare.workersSubdomain`), never asked | It belongs to the account like its id and has one right answer; a typed one could only be wrong, and showed up after deploy in the origin Stripe and Supabase Auth return to, the smoke and the probes | `blueprint.yaml`, IMPLEMENTATION-STATUS (SP-8) | +| 14 | The console asks for no domain; an empty `productdomain` brands the placeholder `.example.com` | The product goes live on workers.dev and nothing in the build needs a domain; attaching one is an owner's step, and the placeholder keeps every place the domain goes in the repository, ready to replace | `repo-blueprint.yaml`, `tooling/rebrand/rebrand.mjs`, IMPLEMENTATION-STATUS (SP-9) | diff --git a/ai/context/operations.md b/ai/context/operations.md index 59f5492..0299478 100644 --- a/ai/context/operations.md +++ b/ai/context/operations.md @@ -192,7 +192,7 @@ orun integrations list --org --json && orun cloud check --org | connect Stripe | above | | turn on email confirmation | above, "Supabase Auth email" | | rotate the service-role key | rotate it in the Supabase dashboard (API keys), then re-run the supabase apply (a merge touching `infra/terraform/supabase`): it republishes `WIRING_SUPABASE`, and the next web deploy pushes the new key | -| serve a custom domain | attach it to the Worker in Cloudflare; change `NEXT_PUBLIC_SITE_URL` in `apps/web/wrangler.template.jsonc` and the Auth origin in the supabase root; add the new webhook URL in Stripe | +| serve a custom domain | attach it to the Worker in Cloudflare; change `NEXT_PUBLIC_SITE_URL` in `apps/web/wrangler.template.jsonc` and the Auth origin in the supabase root; add the new webhook URL in Stripe; replace the placeholder `subscription-payments.example.com` in `intent.yaml`'s `BASE_DOMAIN` with it | | headless credentials | `ORUN_TOKEN` (workspace-scoped) + `GITHUB_TOKEN` | The deployment record is the bootstrap's `02-docs` phase. Re-running it (the diff --git a/blueprint.yaml b/blueprint.yaml index 3765ff0..6d945cf 100644 --- a/blueprint.yaml +++ b/blueprint.yaml @@ -66,6 +66,12 @@ spec: # already holds says so with `from`. repo-blueprint.yaml declares the same # names; `repoPrivate`, `orunWorkspace` and `epicSlug` are build inputs with # defaults (or filled from the build's workspace) and are not asked. + # + # NOR IS THE DOMAIN. The product goes live on workers.dev, and a domain is an + # owner's step after the bootstrap: `productdomain` defaults to empty, the + # rebrand writes the reserved placeholder `.example.com` where + # the domain goes, and the product's README ("Custom domain") says how to set + # it. Nothing that needs a domain is removed — it waits for one. inputs: - key: reponame label: Repo name @@ -77,11 +83,6 @@ spec: pattern: "^[A-Za-z0-9][A-Za-z0-9 .,'&-]{1,48}$" help: The name people see — beside the logo and in every page title. 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 domain the product will answer on. It does not need to exist — the app goes live on workers.dev first. - example: acme.dev - key: githuborg label: GitHub organisation pattern: "^[A-Za-z0-9][A-Za-z0-9-]*$" diff --git a/docs/phases/README.md b/docs/phases/README.md index 443a5d8..378c518 100644 --- a/docs/phases/README.md +++ b/docs/phases/README.md @@ -57,9 +57,15 @@ carry, so it is an owner's step after the bootstrap (the product's README, `01-product` takes the product's identity once and writes it into the repo (`.rebrand/values.json`); `02-docs` reads it back from the placed tree. But the blueprint's **required** inputs — `reponame`, `productname`, -`productdomain`, `githuborg` — are validated before any phase runs, so they -must be supplied on every invocation, single-phase ones included. A -`--values` file is easier than repeating `--set`. +`githuborg` — are validated before any phase runs, so they must be supplied +on every invocation, single-phase ones included. A `--values` file is easier +than repeating `--set`. + +- `productdomain` — NOT ASKED, default empty. The product goes live on + workers.dev; empty brands the reserved placeholder `.example.com` + into `BASE_DOMAIN`, for an owner to replace when they attach a domain (the + product's README, "Custom domain"). Pass it only for a product that already + has its domain. - `subdomain` — the workers.dev subdomain of the Cloudflare account you deploy into. It is in every URL the phases probe, in the origin Stripe diff --git a/repo-blueprint.yaml b/repo-blueprint.yaml index 2c6e821..df72473 100644 --- a/repo-blueprint.yaml +++ b/repo-blueprint.yaml @@ -37,11 +37,18 @@ inputs: description: The product's display name (e.g. "Acme Cloud") — beside the logo and in every page title. productdomain: type: string - required: true + default: "" description: >- - The domain the product will answer on (e.g. acme.dev) — BASE_DOMAIN and - the custom-domain guidance. It does not need to exist: the app answers - on workers.dev from its first deploy. + The product's own domain, once it has one (e.g. acme.dev). NOT ASKED: + the app answers on workers.dev from its first deploy — its site URL, + the Supabase Auth origin and the Stripe return and webhook URLs are all + the workers.dev origin — and a domain is an owner's step after it. + Empty, the rebrand writes the reserved placeholder + `.example.com` where the domain goes (BASE_DOMAIN in + intent.yaml, for every environment), so setting it later is replacing + that one string — the product's README, "Custom domain", says how. Pass + it with --set only to brand a hand-run build with a domain it already + has. githuborg: type: string pattern: "^[A-Za-z0-9][A-Za-z0-9-]*$" diff --git a/specs/epics/README.md b/specs/epics/README.md index aa17c6a..23639a7 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 | |------|---------|--------|------------| -| [`subscription-payments/`](./subscription-payments/) | **SP** | ✅ Shipped (`baseline-v2`); live bootstrap pending | Vercel's Next.js Subscription Payments Starter, equivalent in code and function, on Cloudflare Workers with Supabase provisioned and migrated through Orun — and an Orun baseline that instantiates it in one landing (SP5) | +| [`subscription-payments/`](./subscription-payments/) | **SP** | ✅ Shipped (`baseline-v3`); live bootstrap pending | Vercel's Next.js Subscription Payments Starter, equivalent in code and function, on Cloudflare Workers with Supabase provisioned and migrated through Orun — and an Orun baseline that instantiates it in one landing (SP5) | As-built ≠ intent: what shipped lives in each epic's `IMPLEMENTATION-STATUS.md`. diff --git a/specs/epics/subscription-payments/IMPLEMENTATION-STATUS.md b/specs/epics/subscription-payments/IMPLEMENTATION-STATUS.md index dac3619..e307184 100644 --- a/specs/epics/subscription-payments/IMPLEMENTATION-STATUS.md +++ b/specs/epics/subscription-payments/IMPLEMENTATION-STATUS.md @@ -12,6 +12,7 @@ the code departed from `design.md` or from the upstream template. | SP4 — ready to instantiate | ✅ Shipped | [#5](https://github.com/sourceplane/subscription-payments/pull/5) | | SP5 — a baseline | ✅ Shipped | [#6](https://github.com/sourceplane/subscription-payments/pull/6) (SP-6), tagged `baseline-v1` | | SP6 — the cirrus standard | ✅ Shipped | [#7](https://github.com/sourceplane/subscription-payments/pull/7) (SP-7), [#8](https://github.com/sourceplane/subscription-payments/pull/8) (SP-8), tagged `baseline-v2` | +| SP7 — the domain is set later | ✅ Shipped | [#9](https://github.com/sourceplane/subscription-payments/pull/9) (SP-9), tagged `baseline-v3` | ## Departures from the upstream template @@ -378,6 +379,55 @@ Verified: changes nothing. - `orun task check SP-8` complete. +## The domain is set later (SP7, SP-9) + +The console 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 app answers on +workers.dev from its first deploy, and every URL it builds is that origin — +`NEXT_PUBLIC_SITE_URL` (the metadata base, the Supabase Auth callbacks and +Stripe's checkout and portal return URLs, through `getURL()`), the Supabase +root's `app_origin` (Auth's Site URL and allow-list) and the Stripe webhook +the owner registers. The one place the repository names the domain is +`BASE_DOMAIN` in `intent.yaml` (one line per environment: dev, stage, prod). +A domain is an owner's step after the bootstrap (README, "Custom domain"), so +the form no longer asks for it. + +- `blueprint.yaml` declares no `productdomain` input; the console asks for + the product's name alone. +- `repo-blueprint.yaml`'s `productdomain` is optional, default empty. Nothing + else in the build reads it — no hook, probe or `when:` — so an empty value + is harmless; `.rebrand/values.json` records `""`. A hand-run build may still + pass `--set productdomain=` for a product that already has its domain. +- `rebrand.mjs` no longer requires it. Empty, it brands the reserved + placeholder `.example.com` (RFC 2606 — never someone else's + domain) where the domain goes, so setting it later is replacing one + string; the product README ("Custom domain", beside the site URL, the Auth + origin and the Stripe webhook it already listed) and + `ai/context/operations.md` say so. +- `testing/fixtures/acme.json` carries no domain, so the leak gate, the + offline bootstrap and the e2e tier exercise exactly what a console build + supplies; `testing/rebrand.test.sh` pins the placeholder for an absent and + an empty domain; `baseline.yml`'s blueprint read sets no domain. + +Nothing that needs a domain was removed — it waits for one. + +Verified: + +- `testing/{manifest,phases,coverage,rebrand,retouch,bootstrap-defer}.test.sh` + green; `gen-component-docs.py --check` green (6 components). +- At v2.58.11 (the blueprint job's pin): `orun new --status` with no + `productdomain` reads the document (`01-product` pending, 181 files); + `testing/leak.test.sh` 181 files derived, 174 text files read; + `testing/placement.test.sh` 181 files placed, both landings, the product's + own plan orders supabase → db-migrate → web on stage and prod; `--resume` + changes nothing. +- The offline bootstrap of the fixture leaves `.rebrand/values.json` + `productdomain` empty and `BASE_DOMAIN: acme-pay.example.com` in all three + environments of the product's `intent.yaml` (and the same string in its + README and `operations.md`); no line names + `subscription-payments.example.com`. +- `orun task check SP-9` complete. + ## Verified (SP6) - `testing/{manifest,phases,coverage,rebrand,retouch,bootstrap-defer}.test.sh` diff --git a/specs/epics/subscription-payments/README.md b/specs/epics/subscription-payments/README.md index 590424a..a832ca1 100644 --- a/specs/epics/subscription-payments/README.md +++ b/specs/epics/subscription-payments/README.md @@ -8,15 +8,15 @@ The upstream code stays the code: the `@supabase/ssr` clients and the session-re | Field | Value | |-------|-------| -| Status | ✅ SP0–SP5 shipped (#1–#6), tagged `baseline-v1`; SP6 (the cirrus standard, SP-7 #7 and SP-8 #8) tagged `baseline-v2`. Not yet proven by a live bootstrap: the Supabase and migration applies and a live deploy (risks SP-M, SP-N); Stripe keys are the product owner's | -| Cluster | **SP** (SP0–SP6) | +| Status | ✅ SP0–SP7 shipped (#1–#9): SP0–SP5 tagged `baseline-v1`; SP6 (the cirrus standard, SP-7 #7 and SP-8 #8) tagged `baseline-v2`; SP7 (the domain is set later, SP-9 #9) tagged `baseline-v3`. Not yet proven by a live bootstrap: the Supabase and migration applies and a live deploy (risks SP-M, SP-N); Stripe keys are the product owner's | +| Cluster | **SP** (SP0–SP7) | | Owner(s) | `apps/web` (the app) · `tests/web` (helper and webhook tests) · `packages/db` + `infra/db-migrate` + `tests/db` (the schema) · `infra/terraform/supabase` (the project) | | Builds on | `lumen` conventions — the `supabase` Terraform root, the `@saas/db` runner and `db-migrate` component, the orun-secrets wiring; `supabase-starter` for the app-on-Workers shape; `cirrus-baseline` conventions for the repository shape | | Upstream | [vercel/nextjs-subscription-payments](https://github.com/vercel/nextjs-subscription-payments) (sunset upstream in favour of `nextjs/saas-starter`; ported as it stands) | | Changes | Adds the Workers build, the monorepo wrapper, tests, the migrations package, the db-migrate component, the Supabase root and the deploy contract; the template's code changes only where Next 16 / Workers force it (every change is in `IMPLEMENTATION-STATUS.md`) | | Decisions locked | (1) OpenNext on Workers + Static Assets. (2) The anon key is a wrangler var, not a secret: RLS protects the data; the service-role key and the Stripe secrets are Worker secrets — the service-role key pushed by every deploy from `WIRING_SUPABASE` (SP5), the Stripe keys added by the owner when ready, the app deploying and serving without them (SP5). (3) `wrangler.jsonc` rendered from the template: committed as the fixture render (the composition checks it exists before the build), re-rendered per environment from the wiring document by the deploy lanes, which the build inlines (SP5; it was never committed before). (4) The schema is applied by the `@saas/db` runner through Supabase's Management API, from the template's `init.sql` verbatim — not by `supabase db push` in CI — then RLS checked on every table (`020`, SP5). (5) No Hyperdrive: the app speaks PostgREST over HTTPS, never a Postgres socket. (6) `stripe` stays on v14: it already has the fetch client and async webhook verification. (7) Infra before app on main: supabase → db-migrate → web, enforced; advisory on pull requests (SP5). | | Gate | SP1 is the first user-visible rung. SP2 and SP3 need a workspace with a Supabase connection to apply; they are verified by `plan` / `terraform validate`. Checkout and the webhook need the product's Stripe keys as Worker secrets (the one manual step, see `design.md` §3). | -| Shipped as | `baseline-v1` ([#6](https://github.com/sourceplane/subscription-payments/pull/6)), then `baseline-v2` (SP6: [#7](https://github.com/sourceplane/subscription-payments/pull/7), [#8](https://github.com/sourceplane/subscription-payments/pull/8)); proven offline (Baseline CI: contract, leak, placement and the e2e tier over a local Supabase Auth and Data API), deploy gated until a workspace is linked | +| Shipped as | `baseline-v3` ([#9](https://github.com/sourceplane/subscription-payments/pull/9), SP7: no domain asked), `baseline-v2` (SP6: [#7](https://github.com/sourceplane/subscription-payments/pull/7), [#8](https://github.com/sourceplane/subscription-payments/pull/8)), `baseline-v1` ([#6](https://github.com/sourceplane/subscription-payments/pull/6)); proven offline (Baseline CI: contract, leak, placement and the e2e tier over a local Supabase Auth and Data API), deploy gated until a workspace is linked | ## Read order @@ -36,3 +36,4 @@ The upstream code stays the code: the `@supabase/ssr` clients and the session-re | SP4 — ready to instantiate | README, as-built status | a reader can run, test, preview, configure Stripe and deploy it | | SP5 — a baseline | card, build document, rename, bootstrap tooling, the product's README and context pack, tests | a new product goes from nothing to live on stage and prod in one landing, with no Stripe key, every table behind RLS; Baseline CI green | | SP6 — the cirrus standard | no kiox, generated component docs, the context pack, status that agrees with the tags; the subdomain read from the Cloudflare connection | Baseline CI green with the docs check; the card asks for no subdomain | +| SP7 — the domain is set later | the console asks for no domain; an empty `productdomain` brands the placeholder `.example.com` for an owner to replace | Baseline CI green on a fixture with no domain | diff --git a/specs/epics/subscription-payments/epic.yaml b/specs/epics/subscription-payments/epic.yaml index b54425a..07b5e2b 100644 --- a/specs/epics/subscription-payments/epic.yaml +++ b/specs/epics/subscription-payments/epic.yaml @@ -55,3 +55,9 @@ spec: - "every milestone's status row agrees with the tags" - "the console card reads subdomain from the Cloudflare connection (from: connection.cloudflare.workersSubdomain), as cirrus-baseline since baseline-v23" tasks: [SP-7, SP-8] + - name: "SP7 — the domain is set later" + exitCriteria: + - "the console card asks for no domain: a product goes live on workers.dev, and productdomain is an optional build input that defaults to empty" + - "a product built without a domain is branded with the reserved placeholder .example.com wherever the domain goes (BASE_DOMAIN), and its README says how an owner sets the real one" + - "Baseline CI places, leak-checks and plans a product built with no domain" + tasks: [SP-9] diff --git a/specs/epics/subscription-payments/implementation-plan.md b/specs/epics/subscription-payments/implementation-plan.md index 7001638..cf8228a 100644 --- a/specs/epics/subscription-payments/implementation-plan.md +++ b/specs/epics/subscription-payments/implementation-plan.md @@ -130,6 +130,15 @@ itself changing. - the docs check is green in Baseline CI - this file, the status file and `epic.yaml` agree +## SP7 — the domain is set later (SP-9) ✅ + +**Done when** the console card asks for no domain; `productdomain` is an +optional build input, empty by default; a product built without one is branded +with the reserved placeholder `.example.com` where the domain goes +(`BASE_DOMAIN` in `intent.yaml`) and its README says how an owner sets the real one; +Baseline CI places, leak-checks and plans a product built with no domain. +Shipped in `baseline-v3`. + ## Sequencing note SP1's component already names the root's secrets and the db-migrate diff --git a/tasks/SP-9.TaskContract.yaml b/tasks/SP-9.TaskContract.yaml new file mode 100644 index 0000000..0b7b8a8 --- /dev/null +++ b/tasks/SP-9.TaskContract.yaml @@ -0,0 +1,30 @@ +apiVersion: orun.io/v1 +kind: TaskContract +metadata: + name: SP-9 + title: "The domain is set later" +spec: + goal: "The console no longer asks for the product's domain. A product goes live on workers.dev; productdomain is an optional build input (default empty), the rebrand writes the reserved placeholder .example.com where the domain goes (BASE_DOMAIN), and the product's README says how an owner replaces it once a domain is attached" + affects: + - blueprint.yaml + - repo-blueprint.yaml + - tooling/rebrand/rebrand.mjs + - testing/rebrand.test.sh + - testing/fixtures/acme.json + - .github/workflows/baseline.yml + - .baseline/product/README.md + - BOOTSTRAP.md + - README.md + - docs/phases/README.md + - ai/context/operations.md + - ai/context/current.md + - ai/context/decisions.md + - specs/** + - tasks/** + doneWhen: + - blueprint.yaml declares no productdomain input, and repo-blueprint.yaml's productdomain is optional with an empty default + - "rebrand.mjs no longer requires productdomain and brands .example.com when it is empty (testing/rebrand.test.sh)" + - testing/fixtures/acme.json carries no domain, so the leak gate and the offline bootstrap exercise what a console build supplies + - the contract tests, the docs check, the leak gate and the offline bootstrap are green + gates: + - checks diff --git a/testing/fixtures/acme.json b/testing/fixtures/acme.json index 3b39a36..70e872c 100644 --- a/testing/fixtures/acme.json +++ b/testing/fixtures/acme.json @@ -6,16 +6,16 @@ "AWKWARD rather than tidy — a product name with an apostrophe and an", "ampersand (both legal in the card's pattern, both special in TypeScript", "strings, HTML and a PR title), a hyphenated repo slug that CONTAINS the", - "word `pay`, an owner other than the baseline's, and 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.", + "word `pay`, an owner other than the baseline's, and NO domain — a", + "console build asks for none, so the placeholder .example.com", + "is what a product is born with — 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-pay", "productname": "Sam's Seats & Billing", - "productdomain": "seats.acme.dev", "githuborg": "acme-inc", "subdomain": "acme", "orunWorkspace": "ws_0000000000000000000000000000000f", diff --git a/testing/rebrand.test.sh b/testing/rebrand.test.sh index 6d08694..2607506 100755 --- a/testing/rebrand.test.sh +++ b/testing/rebrand.test.sh @@ -80,6 +80,14 @@ check "the Worker's own origin (NEXT_PUBLIC_SITE_URL): worker name and subdomain check "the placeholder domain is the product's domain, not a renamed slug" \ "$acme" intent.yaml ' BASE_DOMAIN: subscription-payments.example.com' \ ' BASE_DOMAIN: acme.dev' +check "no domain given: the reserved placeholder, for an owner to replace later" \ + '{"reponame":"acme-pay","productname":"Acme Cloud","githuborg":"acme-inc","subdomain":"acme"}' \ + intent.yaml ' BASE_DOMAIN: subscription-payments.example.com' \ + ' BASE_DOMAIN: acme-pay.example.com' +check "an empty domain is no domain" \ + '{"reponame":"acme-pay","productname":"Acme Cloud","productdomain":""}' \ + intent.yaml ' BASE_DOMAIN: subscription-payments.example.com' \ + ' BASE_DOMAIN: acme-pay.example.com' check "the repo slug" \ "$acme" package.json ' "name": "subscription-payments",' \ ' "name": "acme-pay",' diff --git a/tooling/rebrand/rebrand.mjs b/tooling/rebrand/rebrand.mjs index c39dd49..998f927 100644 --- a/tooling/rebrand/rebrand.mjs +++ b/tooling/rebrand/rebrand.mjs @@ -28,7 +28,7 @@ // { // "reponame": "acme-pay", // required — repo slug // "productname": "Acme Cloud", // required — the product's display name -// "productdomain": "acme.dev", // required — the product domain +// "productdomain": "acme.dev", // optional — default .example.com (set later) // "githuborg": "acme-inc", // owner of the product repo (source link in docs) // "brandSlug": "acme", // default: reponame — worker name prefix // "subdomain": "acme", // default: your-workers-subdomain @@ -69,7 +69,7 @@ if (!verifyOnly && !valuesPath) { } if (valuesPath) { values = JSON.parse(fs.readFileSync(valuesPath, "utf8")); - for (const required of ["reponame", "productname", "productdomain"]) { + for (const required of ["reponame", "productname"]) { if (typeof values[required] !== "string" || values[required].length === 0) { console.error(`rebrand: values file is missing required field "${required}"`); process.exit(2); @@ -133,7 +133,11 @@ const rx = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); // All fields are unused under --verify; the fallbacks keep derivation total. const reponame = values.reponame ?? ""; const productname = values.productname ?? ""; -const productdomain = values.productdomain ?? ""; +// The domain is NOT ASKED at bootstrap: a 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 githuborg = (values.githuborg ?? "").trim() || baseline.githubOwner; const brandSlug = (values.brandSlug ?? "").trim() || reponame; const subdomain = (values.subdomain ?? "").trim() || "your-workers-subdomain";