Skip to content

SP5: subscription-payments becomes an Orun baseline - #6

Merged
ruehowl merged 1 commit into
mainfrom
claude/blissful-ptolemy-c5ajf8
Oct 15, 2026
Merged

ruehowl merged 1 commit into
mainfrom
claude/blissful-ptolemy-c5ajf8

Conversation

@ruehowl

@ruehowl ruehowl commented Oct 15, 2026

Copy link
Copy Markdown
Contributor

The repository becomes an Orun baseline on the Cloudflare + Supabase (Lumen) conventions, built the way cirrus-baseline v22 builds a product: in one landing. It follows the saas-starter reference (sourceplane/saas-starter#6), minus Hyperdrive. Milestone SP5, task SP-6.

The baseline

  • blueprint.yaml is the card. It declares requires [github, cloudflare, supabase] and previews four brokered keys: CLOUDFLARE_API_TOKEN (workers-deploy), CLOUDFLARE_ACCOUNT_ID (account-id), SUPABASE_ACCESS_TOKEN (management-access) and SUPABASE_ORG_ID (org-id). It asks for no Stripe key. It says the product uses two Supabase projects, the most the free plan allows, and that prerequisite is in BOOTSTRAP too.
  • repo-blueprint.yaml has two phases:
    • 01-product places every module, then runs the full hook chain: retouch → git-init → stage → rebrand → orun-workspace → work-tree strip → promotion/dev-lanes defer → restage → rebrand-verify → lockfile → repo → link → 4× reconcile → land.
    • Its await watches the merge-sha convergence. It checks with orun.secrets/exists that SUPABASE_PROJECT_REF, SUPABASE_DB_PASSWORD, SUPABASE_DB_URL and WIRING_SUPABASE exist on stage and prod, then probes / and /api/health.
    • 02-docs is hook-only: it restores the deferrals, renders the deployment record and lands it.
  • Order: supabase → db-migrate → web, mode: enforced on github-push-main and advisory on PRs.
  • Supporting files: .baseline/ (identity, task contracts, the product README), the rebrand engine and its seam (apps/web/utils/site.ts), the bootstrap helpers, the deployment-record hook, ai/context/, docs/phases/, BOOTSTRAP.md, baseline.yml, tag.yml, ci.yml's linked gate on v2.78.4, and checks.yml on PRs only.
  • Rebrand protection: the upstream identity (nextjs-subscription-payments, subscription-payments.vercel.app) and all migration files are protected from the rename.

The product

  • WIRING_SUPABASE_<ENV> carries the URL, the anon key and the service-role key. The supabase root publishes it alongside Lumen's three database outputs and nothing else, with Lumen's lock file. The root also:
    • waits for the project to reach ACTIVE_HEALTHY;
    • sets Auth's Site URL and redirect allow-list to the Worker;
    • turns on autoconfirm until the project has SMTP (authEmailConfirmation).
  • web reads only its own environment's document. In stage and prod it re-renders the committed wrangler.jsonc; next build inlines the URL, anon key and site origin from that file. The service-role key reaches the Worker as a Worker secret: the deploy lane pushes it with wrangler secret bulk, the value going over stdin (tooling/wire/secrets.mjs). It is never a var and never in a bundle; the e2e greps the build output to prove it.
  • Fixes an SP1 bug: NEXT_PUBLIC_SITE_URL used to build as …-web-stage..workers.dev, because WORKERS_DEV_SUBDOMAIN only exists in the smoke step.
  • Stripe is optional:
    • Pricing shows the DB's plans, or the template's sample plans, with checkout disabled and "Connect Stripe to enable checkout."
    • Checkout and the portal answer "Stripe is not connected."
    • The webhook answers 503.
    • The publishable key is read per request, so connecting Stripe needs no rebuild.
  • RLS: upstream's policies are kept. Migration 020_row_level_security re-enables RLS on all five tables and fails if any public table lacks it. tests/db (PGlite) checks the catalog, the policies, and what anon, a user and the service role can read and write.
  • /api/health answers 200 only when the project is reachable with the built keys, the schema is migrated and the service-role key is valid. The smoke and the probes use it.

Verified

  • Repo checks: pnpm install --frozen-lockfile, wire:fixture (no diff), typecheck, lint (0 errors), test (53: 42 in tests/web, 11 in tests/db), build. All green.
  • Contract tests: manifest, phases, coverage, rebrand (acme fixture "Sam's Seats & Billing"), retouch and bootstrap-defer all pass.
  • leak and placement pass at orun v2.58.11 and 2.79.0. Placement covers the offline bootstrap of both phases, the product's push-to-main plan (supabase → db-migrate → web, enforced, per env), the PR plan with advisory edges (checked at ≥ the lane pin) and a --resume no-op.
  • e2e passes at orun v2.78.4. It runs a local Supabase built from the real GoTrue 2.180.0 and PostgREST 12.2.12 (pinned and sha256-checked) behind an apikey-checking gateway, and then:
    • runs the db-migrate lane in its staged tree: apply, a second apply that is a no-op, then the PR plan;
    • runs the web lane in its staged tree (verify-app-structure included);
    • starts wrangler dev with no Stripe key and runs the component's own smoke;
    • checks every route, the 503 webhook, and sign-up, account, rename, the checkout/portal notices, sign-out, a wrong password and sign-in, all through the app's own server actions;
    • checks through the Data API that anon reads only plans, a user reads only their own rows, and the service role reads everything;
    • checks that the account page shows the user's own subscription.
  • orun: orun new --status passes at v2.58.11, v2.78.4 and 2.79.0; orun validate and orun work check are clean.
  • Terraform: fmt and validate (init -backend=false) pass on the supabase root.

Only verified offline: the Terraform apply, including whether the brokered OAuth token can reach the API-keys and Auth-config endpoints (risk SP-M); the real wrangler secret bulk push and deploy; a live bootstrap; and a real Stripe round-trip.

🤖 Generated with Claude Code

https://claude.ai/code/session_01AuyckrXahuAVgdmxamUUtk


Generated by Claude Code

The repository is an Orun baseline on the Cloudflare + Supabase (Lumen)
conventions, built the way cirrus-baseline v22 builds a product: ONE
landing, after the saas-starter reference without its Hyperdrive.
01-product places every module, brands it, links the repository, reconciles
four brokered keys (workers-deploy, account-id, management-access, org-id)
and lands it as one pull request, then awaits the convergence, Lumen's three
database credentials and WIRING_SUPABASE on stage and prod, and / +
/api/health; 02-docs restores the promotion gate and dev's lanes and renders
the deployment record. The chain is supabase -> db-migrate -> web, enforced
on main, advisory on pull requests.

The baseline:
- blueprint.yaml (card: requires github, cloudflare, supabase; the two
  Supabase projects the free plan allows stated as a prerequisite) and
  repo-blueprint.yaml (two phases, one landing)
- .baseline/ (identity, task contracts, the product's README), the rename
  engine with the SITE_NAME seam (utils/site.ts) and the upstream's identity
  protected, the bootstrap helpers, the deployment-record hook, ai/context/,
  BOOTSTRAP.md, docs/phases/
- testing/: manifest, phases, coverage, rebrand, retouch, bootstrap-defer,
  leak, placement and e2e — the e2e over a local Supabase made of the real
  Auth (GoTrue 2.180.0) and Data API (PostgREST 12.2.12), pinned and
  checksummed, behind a gateway that checks the API key; the db-migrate and
  web lanes' own steps in the job trees orun stages; a sign-up, sign-out and
  sign-in through the app's own server actions; the anon key refused every
  row the policies do not give it
- baseline.yml, tag.yml; checks.yml on pull requests only; ci.yml's linked
  gate and lanes on v2.78.4; stack-tectonic 0.19.0

The product:
- WIRING_SUPABASE carries the project URL, the anon key and the
  service-role key; the supabase root publishes it beside Lumen's three
  database credentials and nothing else, waits for ACTIVE_HEALTHY, and
  points the project's Auth at the Worker (Site URL, redirect allow-list,
  autoconfirm until SMTP). Lumen's lock file committed
- web reads only its own environment's WIRING_SUPABASE, re-renders the
  committed wrangler.jsonc in stage/prod (URL, anon key, site origin, which
  next build inlines from it), and pushes the service-role key to the Worker
  with `wrangler secret bulk` from the deploy lane (tooling/wire/secrets.mjs)
  — never a var or a bundle. NEXT_PUBLIC_SITE_URL no longer comes out empty
- Stripe optional: pricing shows the DB's plans or the template's sample
  plans with checkout off and "Connect Stripe to enable checkout"; checkout
  and the portal answer "Stripe is not connected."; the webhook answers 503;
  the publishable key is read per request
- migration 020_row_level_security re-enables RLS on the five tables
  (upstream's policies kept) and refuses if any table in public lacks it;
  tests/db checks it in PGlite after every migration
- /api/health (the project reachable with the built keys, the schema
  migrated, the service-role secret valid); the smoke and probes read it

Not verified: a Terraform apply (the brokered OAuth token's reach to the
API-keys and Auth-config endpoints), the secret push and a deploy to a real
account, a live bootstrap, a real Stripe round-trip.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AuyckrXahuAVgdmxamUUtk
@ruehowl
ruehowl marked this pull request as ready for review October 15, 2026 21:03
@ruehowl
ruehowl merged commit b257064 into main Oct 15, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants