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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions BOOTSTRAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ orun new --blueprint repo-blueprint.yaml \
--set subdomain=<workers-dev-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
Expand Down
10 changes: 5 additions & 5 deletions ai/context/current.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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).
1 change: 1 addition & 0 deletions ai/context/decisions.md
Original file line number Diff line number Diff line change
Expand Up @@ -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) |
13 changes: 13 additions & 0 deletions blueprint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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. ─────────────────────────
Expand Down
8 changes: 5 additions & 3 deletions docs/phases/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 4 additions & 1 deletion repo-blueprint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion specs/epics/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
41 changes: 40 additions & 1 deletion specs/epics/subscription-payments/IMPLEMENTATION-STATUS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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`
Expand Down
6 changes: 3 additions & 3 deletions specs/epics/subscription-payments/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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) 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 |
| 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 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

Expand All @@ -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 |
3 changes: 2 additions & 1 deletion specs/epics/subscription-payments/epic.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
5 changes: 5 additions & 0 deletions specs/epics/subscription-payments/implementation-plan.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
25 changes: 25 additions & 0 deletions tasks/SP-8.TaskContract.yaml
Original file line number Diff line number Diff line change
@@ -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
15 changes: 13 additions & 2 deletions testing/manifest.test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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.<provider>.<fact>` 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 [])}
Expand Down
Loading