Repository navigation
SA5: saas-starter becomes an Orun baseline - #6
Merged
Merged
Conversation
The repository is now a baseline on the Cloudflare + Supabase (Lumen) conventions, built the way cirrus-baseline v22 builds a product: in ONE landing. - blueprint.yaml (the card): requires [github, cloudflare, supabase]; the five brokered keys as a preview (CLOUDFLARE_API_TOKEN workers-deploy, CLOUDFLARE_HYPERDRIVE_TOKEN hyperdrive-edit, CLOUDFLARE_ACCOUNT_ID account-id, SUPABASE_ACCESS_TOKEN management-access, SUPABASE_ORG_ID org-id); programme 01-product, 02-docs. No Stripe key: no platform brokers it. - repo-blueprint.yaml: 01-product places every module, retouches, brands, re-tenants, strips the work tree, defers promotion and dev's push lanes, links the repo, reconciles one key per hook and lands one PR; it awaits the convergence, SUPABASE_PROJECT_REF / _DB_PASSWORD / _DB_URL and WIRING_CLOUDFLARE_HYPERDRIVE on stage and prod, and / plus /api/health. 02-docs is hook-only: restore, render the record, land, probe. - One convergence keeps the order: supabase -> cloudflare-hyperdrive -> db-migrate -> web per environment, every edge `mode: enforced` on github-push-main with an advisory modeRule for pull requests. - The product deploys and serves with no Stripe key: the Stripe client is lazy, pricing says "Connect Stripe to enable checkout", checkout and the portal redirect there, the webhook answers 503. The session key defaults to one the database generates (migration 020_app_secrets), so sign-up works with no AUTH_SECRET. /api/health proves the Hyperdrive path and the schema; the deploy smoke reads it. - apps/web/wrangler.jsonc is committed (the fixture render): the composition's verify-app-structure checks it before the build. Stage and prod re-render it from their wiring; dev verifies with the fixture. - The supabase root publishes Lumen's three outputs only; both roots carry Lumen's provider lock files. stack-tectonic 0.19.0; checks.yml on pull requests only; ci.yml's linked gate and lanes on v2.78.4. - .baseline/, the rename engine (upstream links and migrations protected), the bootstrap helpers, the deployment-record hook, ai/context/, the phase pages, BOOTSTRAP.md, baseline.yml and tag.yml. - testing/: manifest, phases, coverage, rebrand, retouch, bootstrap-defer, leak (every shipped file read for factory paths), placement (the offline bootstrap of both phases; the product's own push-to-main plan read for the order; the PR plan's advisory edges; a --resume no-op) and e2e (checks at the landing; the db-migrate lane's own steps applying to a local Postgres through a Management API stand-in; the web lane's steps in the staged job tree; wrangler dev with no Stripe key and no AUTH_SECRET, the smoke, every route, a sign-up, sign-in and dashboard). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AuyckrXahuAVgdmxamUUtk
Supabase's Data API (PostgREST) serves `public` to anyone holding the project's anon key. The template's tables — users with password hashes, teams, invitations — had no row-level security, so every product built from this baseline would have served them (risk SA-L, now resolved). - Migration 030_row_level_security (drizzle-kit twin 0002, from `.enableRLS()` on every table in schema.ts) enables RLS with NO policy: anon and authenticated read and write nothing through the Data API. - The app is unaffected: it connects through Hyperdrive as `postgres` (the cloudflare-hyperdrive root's database_user; the supabase root's connection_uri), which runs db-migrate and so owns the tables, and an owner is not subject to RLS without FORCE. Unverified live, so the migration first checks that `postgres` owns every table in public or has SUPERUSER/BYPASSRLS, and otherwise raises before enabling anything. The ledgers (_migrations, drizzle) and app_private are outside public. - tests/db runs every migration in PGlite (Postgres in WASM; pinned 0.5.8 with one workspace override) and fails if any table in public lacks RLS, if a policy or FORCE appears, or if a role with the Data API's grants reads or writes a row; it also drives the guard's refusal and its BYPASSRLS pass. - The e2e's Postgres now has Supabase's roles: supabase_admin the superuser, `postgres` a login role WITHOUT superuser or BYPASSRLS that owns what it migrates, anon and authenticated with Supabase's default grants. After a real sign-up and sign-in through the Worker, anon and authenticated see 0 of the users, cannot write one, and cannot read app_private. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AuyckrXahuAVgdmxamUUtk
ruehowl
marked this pull request as ready for review
October 15, 2026 20:12
This was referenced Oct 15, 2026
Merged
ruehowl
added a commit
to sourceplane/rag-chatbot
that referenced
this pull request
Oct 15, 2026
* RG5: rag-chatbot becomes an Orun baseline The repository becomes an Orun baseline on the Cloudflare + Supabase (Lumen) conventions, built the way cirrus-baseline v22 builds a product: ONE landing (01-product), then a hook-only deployment record (02-docs). Copied closely from saas-starter's SA5 (sourceplane/saas-starter#6). - blueprint.yaml (requires [github, cloudflare, supabase]; the five brokered keys; the two-Supabase-projects prerequisite) and repo-blueprint.yaml (every module in 01-product; the cirrus v22 hook chain; await: the convergence, SUPABASE_PROJECT_REF/_DB_PASSWORD/_DB_URL and WIRING_CLOUDFLARE_HYPERDRIVE on stage and prod, / and /api/health). - Infra before app on main: supabase -> cloudflare-hyperdrive -> db-migrate -> web, every edge enforced on github-push-main and advisory on pull requests. - Workers AI is the default model provider through an AI binding in the committed wrangler config: @cf/meta/llama-4-scout-17b-16e-instruct for the chat, @cf/baai/bge-base-en-v1.5 for the embeddings (workers-ai-provider 2.0.2, the AI SDK v5 release). AI_GATEWAY_API_KEY is optional and switches only the chat to upstream's gateway model. - Migration 020_workers_ai_embeddings resizes embeddings.embedding to vector(768) (with a guard against foreign vectors); 030 enables row-level security, no policy, on every table in public. Both have drizzle-kit twins; tests/db runs every migration on PGlite with pgvector. - The build needs no Cloudflare credential: the platform proxy starts only under next dev, and the static-assets cache is populated by a copy. - /api/health, the committed wrangler.jsonc, the rebrand engine and name seam, the bootstrap helpers, the deployment-record hook, ai/context, docs/phases, BOOTSTRAP.md, testing/ (with a deterministic Workers AI stand-in for the e2e), baseline.yml and tag.yml. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AuyckrXahuAVgdmxamUUtk * RG5: the page's Open Graph origin is the product's own Upstream's layout hard-coded its demo's origin as metadataBase, which Next resolves the page's opengraph-image.png against: every product built from this baseline would have advertised upstream's vercel.app image URL as its og:image. - app/(preview)/layout.tsx reads NEXT_PUBLIC_SITE_URL (default http://localhost:3000). - apps/web/component.yaml's buildCommand sets it, as postgres-drizzle-starter and portfolio-starter-kit do: the environment's SITE_URL (intent.yaml env:, for a custom domain), else its workers.dev URL, the subdomain written out because the composition exports WORKERS_DEV_SUBDOMAIN to the smoke step only. The page is pre-rendered, so the build bakes it in. - .env.example documents NEXT_PUBLIC_SITE_URL; intent.yaml, the product README, operations.md and BOOTSTRAP.md say how a custom domain sets it. - rebrand.test.sh covers the line (worker name and subdomain rewritten); tests/web holds the layout and the build line; the e2e asserts the served page's og:image is on the product's own stage origin, not vercel.app, and that the image is served. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AuyckrXahuAVgdmxamUUtk --------- Co-authored-by: pullely <pullely@sourceplane.ai> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The repository becomes an Orun baseline on the Cloudflare + Supabase (Lumen) conventions, built the way cirrus-baseline v22 builds a product: one landing. It is the reference conversion for the Supabase group. Milestone SA5, task SA-6.
What was added
The card (
blueprint.yaml)requires.integrations: [github, cloudflare, supabase].spec.secretspreviews the five brokered keys. Each is transcribed from a reconcile hook, and each is a key the product's plan actually resolves:CLOUDFLARE_API_TOKEN(workers-deploy)CLOUDFLARE_HYPERDRIVE_TOKEN(hyperdrive-edit)CLOUDFLARE_ACCOUNT_ID(account-id)SUPABASE_ACCESS_TOKEN(management-access)SUPABASE_ORG_ID(org-id)01-product,02-docs;expectedMinutes: 20.The build document (
repo-blueprint.yaml): two phases01-productplaces every module (25 of them).--strip, promotion--defer, dev-lanes--defer→ restage, rebrand-verify → pnpm lockfile →orun.repo/ensure@v1, then link → fiveorun.integrations/reconcile@v1hooks, one key each →orun.pr/land@v1.orun.run/watch@v1on the merge sha;orun.secrets/exists@v1forSUPABASE_PROJECT_REF,SUPABASE_DB_PASSWORD,SUPABASE_DB_URLandWIRING_CLOUDFLARE_HYPERDRIVE, on stage and prod;orun.http/probe@v1on/and/api/health, on stage and prod.02-docsis hook-only: restore promotion and dev-lanes, render the record, land, probe.Deploy order on
github-push-maindependsOn+mode: enforced, with amodeRulesentry that makes it advisory ongithub-pull-request(the cirrus shape).db-migratealso waits oncloudflare-hyperdrive. Migrations are the one step a re-run cannot undo, so they run last before the app.Product changes
Stripe (brief rule 8). The Stripe client is built lazily. Without a key:
/pricingrenders the template's plans, with checkout disabled and "Connect Stripe to enable checkout.";/pricing;How the owner adds
STRIPE_SECRET_KEYandSTRIPE_WEBHOOK_SECRETis documented in the product README ("Connect Stripe"),ai/context/operations.mdandBOOTSTRAP.md.The session key. If
AUTH_SECRETis unset, the session key is one the database generates for itself (migration020_app_secrets,app_private.secrets). A fresh build therefore signs users up with no secret set by hand.Row-level security on every table in
public(migration030_row_level_security;.enableRLS()inschema.ts), with no policies.publicto the anon key, and the template's tables, password hashes included, had no RLS. Nowanonandauthenticatedread and write nothing through it.postgres, which owns the tables, so RLS doesn't apply to it.postgresneither owns every table nor has SUPERUSER/BYPASSRLS, it raises before enabling anything./api/health(new) checks that Hyperdrive reaches the database and the schema is migrated. The deploy smoke checks it.apps/web/wrangler.jsoncis now committed as the fixture render (lesson 4). Stage and prod re-render it from their wiring before the build, and dev verifies with the fixture.The supabase root publishes only Lumen's three outputs, and both Terraform roots carry Lumen's lock files.
Pipeline: stack-tectonic pinned at 0.19.0,
checks.ymlruns on pull requests only,ci.ymluses thelinkedgate and runs its lanes on v2.78.4.Baseline machinery
baseline-v2, adapted:.baseline/, the rebrand engine with the product-name seamapps/web/lib/site.ts, the bootstrap helpers,hooks/render-deployment-docs.sh,ai/context/,docs/phases/,BOOTSTRAP.md,baseline.ymlandtag.yml.How it was verified (locally)
Repository checks
pnpm install --frozen-lockfile,wire:fixture, typecheck, lint, test, build.publiclacks RLS, if a policy or FORCE appears, or if a role with the Data API's grants can read or write a row. It also exercises the guard's refusal.testing/*.test.sh--resumeis a no-op.postgreswithout SUPERUSER or BYPASSRLS, owning what it migrates, andanon/authenticatedwith Supabase's default grants.wrangler devruns with no Stripe key and no AUTH_SECRET and passes the smoke, every route, sign-up, dashboard and sign-in;anonandauthenticatedsee 0 of the users, cannot write one, and cannot readapp_private.orun and Terraform
orun new --statusat v2.58.11, v2.78.4 and 2.79.0;orun validate;orun work check: clean.terraform fmt,init -backend=falseandvalidatepass on both roots.Offline only, not live:
planorapply;🤖 Generated with Claude Code
https://claude.ai/code/session_01AuyckrXahuAVgdmxamUUtk