feat(db): Phase 6.2 — guard the fifteen no-statements history rows (#Q5JHBJ) - #2185
Conversation
…o-statements history rows Six fail-fast validation guard migrations (20260804110240 pattern) covering every object the fifteen hand-applied/mark-applied July versions left on live, and the fifteen migration_history allowlist entries that point at them (class validation, never bare). Guards validate only: absences, catalog comments + retention cron, document FKs, 46 operational index shapes, the index_generation_id promotion, and 15 function def_hashes read from schema_drift_snapshot() itself. Proven: full chain replay into the scratch image Applied 210/210 and CHAIN == MANIFEST (zero unexpected drift); seven mutation proofs raise and name their object; all six dry-ran green on production and a mutant fails there; applied to production by real db push (rows carry statements) and to staging by the Phase 2 method (md5-matched); staging drift comparison green. tests/migration-history-guards.test.ts: the create-index check now ignores string literals/comments (the reference pattern pins canonical `create index` text as data) and requires set local statement_timeout; 20260804110240 is pinned as satisfying the predicate. Ledger: #Q5JHBJ (#316 umbrella). RAG impact: no retrieval behaviour change. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…state, ledger requests Forensics section '6.2 completion' (classification, chain-replay and mutation proofs, production window paste, staging parity, live-drift run 32251326536: drift zero, job red only on the Phase 0 Align-migration-history step PGRST106), coordination board row 6, database-drift-detection live-state paragraph, #Q5JHBJ update request and a new P2 for the align step. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Warning Review limit reachedYou’ve reached a temporary PR review limit under our Fair Usage Limits Policy. Next review available in:56 minutes Limit details: You’ve used the included review currently available. Your 102 included PR review attempts over the past 7 days set your current allowance at 1 review per hour. Your organization has reached its usage spending cap. Adjust your spending cap in the billing tab. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits within each organization. For paid Pro and Pro+ reviews, CodeRabbit uses a developer's included PR review attempts over the past 7 days to set the current hourly allowance. At typical activity levels, the full plan allowance applies. Higher sustained activity can lower the allowance until earlier attempts leave the 7-day window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (13)
Comment |
Updates to Preview Branch (claude/migration-history-drift-allowlist-37444c) ↗︎
Tasks are run on every commit but only new migration files are pushed.
View logs for this Workflow Run ↗︎. |
Uh oh!
There was an error while loading. Please reload this page.
Summary
#Q5JHBJ,#316umbrella): guard the fifteenmigration_historyno-statements rows. Six fail-fast validation guard migrations per the20260804110240pattern —20260819110000dropped objects (absence of 7 functions + 4 indexes),110100catalog comments + thepurge-rag-retrieval-logscron job,110200three document foreign keys,110300forty-six operational index shapes,110400theindex_generation_idpromotion (6 columns + 6 partial indexes + 3def_hashes),110500fifteen functiondef_hashes read fromschema_drift_snapshot()itself — and the fifteensupabase/drift-allowlist.jsonentries that point at them (classvalidation, never bare). Every one of the fifteen isvalidation: none earnedsuperseded(no single later executed migration re-creates every object) orno_ddl(COMMENT ONis a catalog write, not an empty file).schema.sqlanddrift-manifest.jsonare unchanged (validation-only guards create nothing).supabase db push(pending set was exactly the six; rows carry statements,no_statements false; 210 rows; corpus untouched), staging by the Phase 2 method (six md5-matched rows,no_statements 0, drift comparison green).32251326536dispatched on this branch:Compare live schema driftSUCCESS —No unexpected schema drift, all 20 history rows allowed.#316's finding set is empty for the first time since 2026-07-26. The job still concludes failure on the next step (Align migration history for Supabase Preview,check:migration-history), which ran for the first time ever and cannot readsupabase_migrationsover PostgREST (PGRST106, schema not exposed) — a Phase 0 latent defect, not drift; queued as its own P2 in this PR's inbox request, owner decision.tests/migration-history-guards.test.ts: the "validation guard must not create the objects it validates" check now ignores string literals/comments (the20260804110240reference pattern pins canonicalcreate index …text as data and would have failed the raw regex; novalidationentry had ever exercised it), additionally requiresset local statement_timeout, and pins that20260804110240passes the predicate while a realcreate indexstatement fails it.§6.2 completion(classification table, chain-replay + mutation proofs, production/staging pastes, live-drift paste), coordination board row 6 + "where the programme stands",docs/database-drift-detection.mdlive-state paragraph; ledger inbox requests (#Q5JHBJupdate, new P2 for the align step).Verification
npm run verify:pr-local— exit 0:Test Files 682 passed | 2 skipped (684) · Tests 7398 passed | 57 skipped (7455),Offline RAG fixture and manifest validation passed (36 golden cases, 26 suites),failed: (none).npx vitest run tests/migration-history-guards.test.ts tests/drift-detection.test.ts tests/supabase-schema.test.ts tests/search-health-index-coverage.test.ts tests/migration-history-placeholders.test.ts tests/hosted-migration-role-guard.test.ts—Test Files 6 passed (6) · Tests 113 passed (113).npm run check:migration-role—Hosted migration-role guard passed: active hosted SQL/tooling uses postgres and immutable applied history is unchanged.npm run check:drift -- --self-test—check-drift: all offline self-tests passed.supabase/postgres:17.6.1.127image (roles + scaffold, every migration in order, each in its own transaction):Applied 210/210 (all six 20260819110* history guards included)andCHAIN == MANIFEST: no unexpected drift— every hand repair in forensics §2.3/§3.3/Phase 4 is reproduced by the chain; no reconcile migration needed. Seven guard mutants (wrong hash, wrong index def, dropped index, present "absent" index, wrong column type, FK cascade, removed comment) each raise and name their object.public.reset_document_index(uuid) def_hash 243f3960…; cron/comment branches confirmed exercised (cron_schema true · purge_job_rows 1).npm run check:production-readiness— Verification not run: the change is validation-only guard migrations and allowlist entries; no clinical workflow, privacy, environment or deployment behaviour changed, and the hosted state was proven directly (production dry-runs + push + live-drift green).Risk and rollout
Migration replay, Supabase Preview,db reset, DR) now fails loudly if any of the fifteen versions' objects is missing or mis-shaped — which is the intended behaviour. The test-file change is a predicate refinement (strips string literals before the create-index check), not a class widening.migration list; if a rollback is ever needed, remove the rows explicitly in an authorised window rather than leaving history and repo disagreeing. No schema object changes to undo.sjrfecxgysukkwxsowpy—supabase migration list, read-only guard dry-runs,supabase db push --skip-vaultof exactly the six versions,migration listagain,supabase unlink; stagingikoiolksxqxfxgiyqpnuby the Phase 2 method; onelive-driftworkflow dispatch on this branch. No vault access, no data writes, nomigration repair.110500guard pinsmatch_*bodies to the hashes live already carries).Clinical Governance Preflight
Clinical KB Database(sjrfecxgysukkwxsowpy)Notes
20260712170500carries "43 names"; it carries 44create index if not existsstatements, of which 42 persist (the twodocument_table_facts_*left-prefix indexes are re-dropped by20260712172000and proven absent by the110000guard).Align migration historystep until the owner decides howcheck:migration-historyshould readsupabase_migrations(expose the schema read-only / wireSUPABASE_ACCESS_TOKEN#183and usesupabase migration list/ add a versions RPC). Pinned issue Live drift check failing #1963 therefore does not self-close yet even though its drift block is empty.#Q5JHBJupdate and the new P2 are queued as inbox requests; runnpm run issues:reconcilefrom a serialized fresh base after this lands.