fix(wallet): unblock production deploys — wallet DVA writer migration ALTER ROLE (42501) #4457
All Vouch review confidence checks passed
Residual risk 0.52 = Change Risk (0.71) × (1 − Review Confidence (0.27)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.71 · 552 lines diff across 6 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 48% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.378
Shallow Review Depth
shallow_review_depth
0.344
Sensitive Paths
sensitive_paths
0.071
Real PR Conversation Timeline
1 comments
"Review active on #4457"
general
weight: 0.35
github-actions[bot]
What is broken
Production deploys have been stopped since #4441 merged. Every Deploy run on
mainfails in thedb-migrationsjob, step "Apply remaining pending migrations via Management API", so the run never reachesdeploy-production. Runs for4096d6a357and5065712f44both failed this way.The failing migration is
supabase/migrations/20261122064203_wallet_dva_restricted_writer.sql. From the job log (run 45046263526, jobdb-migrations):Cause
The migration ran
ALTER ROLE baci_wallet_dva_writer NOLOGIN NOSUPERUSER NOBYPASSRLS NOCREATEROLE NOCREATEDB NOREPLICATION;. The Management API login is not a superuser, and Postgres refuses anyALTER ROLEthat merely names a superuser-class attribute (SUPERUSER,BYPASSRLS,REPLICATION) for such a login, even when nothing would change. The repo already learned this once:20261104140100_piggyvest_webhook_intake_role.sqldocuments the same 42501 and only convergesNOLOGIN.What this PR changes
1. Migration fix. The
ALTER ROLEnow only setsNOLOGIN CONNECTION LIMIT -1 PASSWORD NULL, the same shape as the already-appliedpiggyvest_webhook_intake_roleandblog_media_sweep_workermigrations.CREATE ROLEis unchanged and still creates the roleNOLOGIN NOSUPERUSER NOBYPASSRLS NOCREATEROLE NOCREATEDB NOREPLICATION.2. Security intent kept. A new catalog guard raises
42501ifbaci_wallet_dva_writerhas any elevated attribute (login, superuser, bypassrls, createrole, createdb, replication). It readspg_roles, which any login may do, so it does not need superuser. The function boundary and every grant are untouched.3. Checksum drift. The registry hashes in
apps/web/tools/db/replay-registry/20261122064203_wallet_dva_restricted_writer/{pending,expected-pending}-sources.txtare regenerated with the README's ownshasumcommand (0466499232dd…→4eddf4a87542…). No shared aggregator orci.ymlis edited.4. Regression test.
apps/web/tools/db/wallet-dva-restricted-writer-migration.test.tsfails if anyALTER ROLEin this migration names a superuser-class attribute, and checks the NOLOGIN convergence, theCREATE ROLEattributes and the guard.Why an existing migration is edited in place
Migrations are append-only so that a migration already recorded in production never changes underneath it. This one was never applied: the job log shows
→ applyingand then an abort with "aborting before recording the migration", and the Management API runs a multi-statement query as one implicit transaction, so nothing partial was committed either. A new follow-up migration cannot fix this, because this migration aborts the job before any later migration runs. The owner's brief for this task pre-authorizes the in-place correction. CodeRabbit's "move this to a new migration" finding was evaluated and skipped for these reasons.Verification
CREATEROLElogin (like the deploy login): the old statements fail withpermission denied to alter role; the new statements succeed,pg_rolesshowsbaci_wallet_dva_writerwith login/superuser/bypassrls/createrole/createdb/replication all false, a re-run is idempotent, and the guard rejects a pre-existing role withBYPASSRLS.replay-registry,replay-registry-baseline,materialize-supabase-history-replay{,-ordering,-relations},verify-supabase-history-replay-{manifest,manifest-fixture-drift,gigl-pending-sources}.Not in this PR
main; that is covered by automation PR #4455 and left alone.mainis a production release, so it waits for the owner's go-ahead.🤖 Generated with Claude Code