Staging-aware Supabase identity guard + staging setup runbook#400
Merged
Conversation
Prepares turnkey staging provisioning without creating any live resource. - src/lib/supabase/project.ts: the identity guard now accepts a second (staging) project ONLY when explicitly declared via SUPABASE_STAGING_PROJECT_REF + SUPABASE_STAGING_PROJECT_NAME. It refuses a staging ref that is invalid, partially declared, or collides with the production/stale ref — the "can't silently point staging at prod" guard the deployment doc called for. Production behavior is byte-identical when the staging vars are unset (expectedSupabaseProject stays the resolved default). observed.environment now reports production | staging. - src/lib/env.ts + scripts/check-supabase-project.ts: pass the two staging vars through, so activating staging is env-only (no code edit) and the CLI guard prints the resolved [environment]. - tests/supabase-project.test.ts: +4 cases — staging accepted, production unchanged with staging declared, prod-ref collision rejected, partial declaration rejected. - docs/staging-setup.md: turnkey runbook (create project -> supabase db push -> seed -> build image -> runtime secrets -> soak validation), with the operator-only steps (billable project create, host account) called out. verify:cheap green (1350 passed / 1 skipped). Live check:supabase-project for production still passes unchanged. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
BigSimmo
marked this pull request as ready for review
July 8, 2026 13:47
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
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.
Summary
Makes staging provisioning turnkey without creating any live resource (per the decision to defer the billable Supabase project). Follows on from the production-platform work (PR #332).
The only code change staging needed was the identity guard:
src/lib/supabase/project.tspinned the expected project to production, so a staging deployment would failcheck:supabase-projectand throw at env-load (env.ts→assertExpectedSupabaseProjectConfig). This makes the guard accept a second, explicitly-declared staging project while preserving the anti-footgun property.What changed
src/lib/supabase/project.ts— accepts a staging project only when bothSUPABASE_STAGING_PROJECT_REFandSUPABASE_STAGING_PROJECT_NAMEare set. It refuses a staging ref that is invalid, partially declared, or collides with the production/stale ref (the "can't silently point staging at prod" speed bump the deployment doc asked for).expectedSupabaseProjectstays the resolved default, so production behavior is byte-identical when the staging vars are unset.observed.environmentnow reportsproduction | staging.src/lib/env.ts+scripts/check-supabase-project.ts— pass the two staging vars through, so activating staging is env-only, no code edit, and the CLI guard prints the resolved[environment].tests/supabase-project.test.ts— +4 cases: staging accepted, production unchanged with staging declared, prod-ref collision rejected, partial declaration rejected.docs/staging-setup.md— turnkey runbook: create project →supabase db push→ seed synthetic corpus → build image → runtime-secrets table → soak validation, with operator-only steps (billable project create, Fly host) called out.Verification
verify:cheap✅ — 1350 passed / 1 skipped (lint, typecheck, sitemap, unit).check:supabase-projectfor production still passes unchanged (now tagged[production]).Supabase targets Clinical KB Staging), proving env-only activation.How to activate staging (once the project exists)
supabase db pushthe migrations; seed a small synthetic corpus.SUPABASE_STAGING_PROJECT_REF+SUPABASE_STAGING_PROJECT_NAME(plus the usualNEXT_PUBLIC_SUPABASE_URL/SUPABASE_PROJECT_REF/keys) on the staging host → it boots.No production settings touched. No live resource created.
🤖 Generated with Claude Code