Repository navigation
Conversation
PsqlExecutor now logs in as postgres unless a call names supabase_admin, the way the Supabase CLI applies migrations and seeds. The ledger, the sequence markers, the baseline record and the seed all run as postgres, so postgres creates and owns _tzudong_local. A ledger that another role created fails with local_ledger_owner_mismatch and names the reset. Four calls keep supabase_admin, each for a role postgres cannot hold: the storage.objects policies (owner supabase_storage_admin), the privacy fixture, the receipt readback of privacy_retention rows, and the closure runtime scan, which runs privacy_retention's G014 assertions. The G014 guards forbid postgres any membership in privacy_workflow_owner. The privacy rows move from local-seed.sql to local-seed-privacy-fixture.sql. No migration function can write them with the fixture's fixed id and timestamps, so the file runs as supabase_admin and writes them under SET LOCAL ROLE privacy_workflow_owner. The seed marker and the receipt's seed_source_sha256 bind both files. local-stack.py creates the local_analytics namespace as postgres, which the image's demote-postgres migration grants ALL on the database. Refs #3323 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`local_baseline.py ownership` reads every project object's owner and exploded ACL and fails on any one owned or granted by supabase_admin, since no migration assigns one. --exact also requires the objects the baseline covers to match ownership.txt line for line, and --catalog-manifest compares relation owners and grants with the catalog generator's manifest, reading ALL as PostgreSQL 15's seven table privileges. Either comparison fails when it has nothing to compare. The nightly runs the superuser rule right after migration_apply. Provisioning already holds covered objects to ownership.txt, and a later migration may legitimately change them. The three nightly probes that keep supabase_admin say why. Refs #3323 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Refs #3323 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The baseline covers every migration, so the post-apply owner rule had nothing new to judge. `local-migrate.py probe-uncovered` runs right after migration_apply through the applier's executor as postgres. In one transaction that ends in ROLLBACK it creates a table, a sequence and a function in public and reads back their owners and exploded ACLs. It fails unless the owner is postgres, no grantor is supabase_admin, and the grants equal what pg_default_acl on the live database gives postgres in public. A socket-only scratch PostgreSQL now backs the tests for the probe, the _tzudong_local owner guard and the privacy fixture. The fixture must be one transaction with SET LOCAL ROLE privacy_workflow_owner before every insert. A test pins the local_analytics bridge to postgres. Refs #3323 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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.
Why
Local migration apply should run as the role hosted uses. D2 in
docs/operations/local-postgres17-transition.mdmakespostgres(non-superuser) the applier's role, as the Supabase CLI'smigrateAndSeeddoes, and keepssupabase_adminonly where PostgreSQL 17 needs a superuser or the platform owner. Refs #3323What changed
PsqlExecutordefaults topostgres. The ledger, sequence markers, baseline record, auth API ledger and seed run aspostgres, which creates and owns_tzudong_local. A ledger another role created fails withlocal_ledger_owner_mismatch.local-seed-privacy-fixture.sql. It runs assupabase_adminunderSET LOCAL ROLE privacy_workflow_owner.publish_privacy_policy_versionexists, but it cannot write the fixture's fixed id and timestamps, and no function writes the age profile directly. The seed digest binds both files.local-stack.pycreateslocal_analyticsaspostgres, which10000000000000_demote-postgres.sqlgrantsALL ON DATABASE postgres.local_baseline.py ownershipfails on any project object owned or granted bysupabase_admin.--exactalso requires covered objects to matchownership.txt, and--catalog-manifestcompares owners and grants with the generator. The nightly runs the rule aftermigration_apply.Scope
Remaining
supabase_admincall sites, each for a rolepostgrescannot hold:_apply_platform_bootstrap: policies onstorage.objects, whose ownersupabase_storage_adminthe image revoked frompostgres(20250421084701).privacy_retention, which onlyprivacy_workflow_ownermay use. The G014 guards forbidpostgresany membership in that role.local-function-runtime-scan.py:ALTER FUNCTIONneeds the owner, and 14 of 128 candidates belong toprivacy_workflow_ownerorprivacy_auth_bridge.privacy_workflow_owner, grant themselves that role, or add triggers onauth.users(ownersupabase_auth_admin, revoked frompostgres).local_baseline.pyrestore: the role file and multi-owner restore D2 names as superuser steps.Tradeoffs
supabase_adminwithSET ROLE postgreswould keep one transaction, butsession_userwould differ from the CLI's. The seed is now two transactions. Both are idempotent.supabase_adminrule. A later migration may legitimately change a covered object's grants, and provisioning and the drift gate already hold covered objects toownership.txt.Blast Radius
Local stacks and the nightly only. No hosted access and no migration body changes. An existing local stack whose ledger an older applier created needs
local-stack.py reset.Verification
pg17_baseline=true: green at d0b0ade, https://github.com/twoimo/tzudong/actions/runs/45210447234. The drift gate found no drift. The next commit only adds this evidence to the plan doc.migration_apply, no project object is owned or granted bysupabase_admin.ownership --exact --catalog-manifeston the run's post-apply capture shows 0 differences fromownership.txt(2,192 lines) and from the generator's manifest (Catalog run 45145493029: 61 relation owners, 419 grants).supabase_admin, the fixture withoutSET LOCAL ROLE, aspostgresor withRESET ROLE, the runtime scan aspostgres(red then green), and the owner and grantor rules disabled.privacy_workflow_owner.🤖 Generated with Claude Code