Skip to content

Staging-aware Supabase identity guard + staging setup runbook#400

Merged
BigSimmo merged 1 commit into
mainfrom
claude/staging-provisioning
Jul 8, 2026
Merged

Staging-aware Supabase identity guard + staging setup runbook#400
BigSimmo merged 1 commit into
mainfrom
claude/staging-provisioning

Conversation

@BigSimmo

@BigSimmo BigSimmo commented Jul 8, 2026

Copy link
Copy Markdown
Owner

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.ts pinned the expected project to production, so a staging deployment would fail check:supabase-project and throw at env-load (env.tsassertExpectedSupabaseProjectConfig). 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 both SUPABASE_STAGING_PROJECT_REF and SUPABASE_STAGING_PROJECT_NAME are 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). expectedSupabaseProject stays the resolved default, so production behavior is byte-identical when the staging vars are unset. 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 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).
  • Live check:supabase-project for production still passes unchanged (now tagged [production]).
  • Staging-declared config with a test ref resolves and passes (Supabase targets Clinical KB Staging), proving env-only activation.

How to activate staging (once the project exists)

  1. Create the staging Supabase project (ap-southeast-2). Deferred — billable; can be done via Supabase MCP or dashboard.
  2. supabase db push the migrations; seed a small synthetic corpus.
  3. Set SUPABASE_STAGING_PROJECT_REF + SUPABASE_STAGING_PROJECT_NAME (plus the usual NEXT_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

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>
@supabase

supabase Bot commented Jul 8, 2026

Copy link
Copy Markdown

This pull request has been ignored for the connected project sjrfecxgysukkwxsowpy because there are no changes detected in supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

@BigSimmo
BigSimmo marked this pull request as ready for review July 8, 2026 13:47
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@BigSimmo
BigSimmo merged commit c2ae52e into main Jul 8, 2026
6 checks passed
@BigSimmo
BigSimmo deleted the claude/staging-provisioning branch July 8, 2026 16:22
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.

1 participant