feat(db): codify live SET work_mem on the ten match_* RPCs, the eight schema-only objects, and three chain-stale columns (#316) - #2106
Conversation
… schema-only objects, and three chain-stale columns (#316) Database remediation Phase 3, reframed as repo-side codification (owner decisions D1 codify-as-live, D2 work_mem canary exemption). No function body changed; no hosted value changed; no production access. - supabase/schema.sql: `set work_mem = '<live value>'` on all ten match_* definitions (128MB on chunks_hybrid, embedding_fields_hybrid, index_units_hybrid, index_units_hybrid_v2; 64MB on the other six), including the effective uppercase blocks for chunks_hybrid and table_facts_text. - 20260818110000_codify_live_rpc_work_mem: ALTER FUNCTION ... SET work_mem per function, versioned after every recreate. Regenerated drift-manifest def_hash for all ten equals the live production def_hash (issue #1963, run 32051068106) byte-for-byte. - 20260818111000_codify_schema_only_indexes_and_triggers: the five document_embedding_fields indexes, documents_status_idx, and the documents_updated_at / ingestion_jobs_updated_at triggers, verbatim from schema.sql (forensics 2.3 b); unmonitored-list reasons refreshed. - 20260818112000_reconcile_chain_stale_table_columns: document_chunks .token_estimate (never in any migration) and the rag_visual_eval_cases/runs id defaults (20260705230000 bound extensions.gen_random_uuid via search_path order) - all idempotent on production. - forensics section Phase 3 written; #316 update + #183 rider queued as inbox requests. Staging proof deliberately not run: Phase 2 re-measure absent on main. RAG impact: no retrieval behaviour change - codifying already-live SET work_mem attributes and mirror-only objects; no function body changed 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: 59 seconds Limit details: You’ve used all 1 included review currently available under your plan. You completed 101 included PR reviews in the past 7 days; at that activity level, included reviews refill 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 for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling 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/schema-work-mem-codify-6200f1) ↗︎
Tasks are run on every commit but only new migration files are pushed.
View logs for this Workflow Run ↗︎. |
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…s §2.5 re-measure + Phase 3 section both kept)
…clip, PR template RAG impact guidance Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…2106 Review of the Phase 3 codification migrations found the forensics runbook offered mark-applied-by-CLI as an equal alternative to db push for the three new migrations, which would violate the guard-migration contract in AGENTS.md since none of them ships a validation guard. Narrow the runbook to require db push (real execution) and forbid migration repair for these versions. Also add SET LOCAL lock_timeout / statement_timeout to the two migrations that take ACCESS EXCLUSIVE locks on hot tables (documents, ingestion_jobs, document_chunks), matching the existing 20260804110240 guard pattern, so a production window fails fast instead of queueing behind a long transaction. No schema.sql change, no function body change, no live Supabase access. RAG impact: no retrieval behaviour change — same scope as the parent PR (SET work_mem attribute codification only; this commit only tightens the production-application runbook and adds lock timeouts to unrelated schema codification migrations).
Records the supabase-schema-guardian review of the Phase 3 codification migrations and the follow-up fix commit at the correct HEAD.
…estion (#2201) * docs(ledger): record the PR #2198 migration-history alignment review Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * docs(db): record the 2026-08-20 alignment window and reopen the D4 question The PGRST106 fix (PR #2198, squash a341832) merged before its production window, so the window's pre-flight found 20260820120000 already applied and db push was never run. Verified read-only against sjrfecxgysukkwxsowpy: stmt_count 3 (executed statements, not mark-applied), prosecdef true, provolatile s, search_path="", proacl postgres=X/postgres | service_role=X/postgres, and the function returns probe ok with version_count 211 against 211 history rows and 211 local files. No guard migration is owed. Two open items are recorded rather than absorbed. D4 is unresolved again. created_by and idempotency_key are NULL on every row from 20260818090000 onward, including ones this programme applied by operator db push, so the history table carries no provenance signal. The 2026-08-19 observation recorded as "D4 is OFF" was that migrations sat pending WHILE a PR was open; that never tested deploy-on-merge, and so never contradicted section 3.7's 34-second application after #2106's squash-merge. Until the dashboard is re-checked, assume merging a migration PR deploys it to production. Staging is one version behind (210 rows, function absent, pending set exactly 20260820120000). Both write paths were denied by the session auto-mode classifier under the live-Supabase confirmation rule added by PR #2196, so Phase 4's staging parity is open by one version until an operator applies it. Also lands the owed PR #2198 review-ledger record, whose original push was cut short when the branch was deleted on merge. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * docs(db): treat a merged migration PR as a production deploy until D4 is re-verified The 2026-08-20 window update reopened D4 (Supabase GitHub auto-deploy), but the status board's active instructions still told a coordinator the opposite: the "Next dispatches" line, the D4 owner-decision entry, the 2026-08-19 "Resolved" paragraph, and the pre-window forensics section all said D4 is OFF and every migration needs its own explicit `db push`. A coordinator reading those could merge a migration PR outside its approved window — the unapproved production schema change the update exists to prevent. All four now point at the reopened decision: assume merging a migration PR deploys it to production until the dashboard toggle is re-verified. Push-before- merge stays the required order, for the inverted reason. Also lands the PR #2201 review-ledger record. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HoyoNN7nCUVDLaE84k6e6c --------- Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
Summary
Database remediation Phase 3 (reframed, ledger
#316): repo-side codification of already-live state so the migration chain,supabase/schema.sqland production agree. No canonical (schema.sql = production) function body changed; no hosted value changed; no production access. Staging received the migrations in an owner-authorised window (below). Owner decisions D1 (codify-as-live) and D2 (work_memeval-canary exemption) are in force.RAG impact: no retrieval behaviour change — codifying already-live SET work_mem attributes, mirror-only objects, and three already-live RPC bodies into the migration chain; no canonical function body changed
SET work_memon the tenmatch_*RPCs —schema.sqlnow carriesset work_mem = '<live value>'on every definition (both the legacy and the effective block formatch_document_chunks_hybridandmatch_document_table_facts_text), andsupabase/migrations/20260818110000_codify_live_rpc_work_mem.sqlruns oneALTER FUNCTION … SET work_memper function, versioned after every recreate (including the20260724120000recreate that dropped the setting ontable_facts_text). Values are exactly the live ones from forensics §1.2: 128 MB onchunks_hybrid,embedding_fields_hybrid,index_units_hybrid,index_units_hybrid_v2; 64 MB on the other six. Proof: the regeneratedsupabase/drift-manifest.jsondef_hashfor all ten equals the live productiondef_hashfrom issue Live drift check failing #1963 (Actions run32051068106) byte-for-byte — e.g.match_document_chunks_hybrid5902c39286335c07714e498ea31513a0,match_document_table_facts_text0ef9a5dfbde03fe6d48d9223e245aa69— so the next production live-drift run reports zeromatch_*mismatches once the migration is marked applied.20260818111000_codify_schema_only_indexes_and_triggers.sqlcreates, verbatim fromschema.sql, the fivedocument_embedding_fields_*indexes,documents_status_idx, and thedocuments_updated_at/ingestion_jobs_updated_attriggers (forensics §2.3 b). Disjoint from#102. All six indexes stay onsupabase/search-health-unmonitored-indexes.json(reasons refreshed to cite the migration);search_schema_health()required_indexesis deliberately untouched — Phase 4.4 decides that by its own migration.document_chunksis CHAIN-stale (token_estimate integer not null default 0exists inschema.sql, production and app code, in zero migrations);rag_visual_eval_cases/rag_visual_eval_runsare CHAIN-stale (20260705230000setssearch_pathwithpg_cataloglast, so theiriddefault bound toextensions.gen_random_uuid();schema.sqland production bind the core function). Both fixed idempotently by20260818112000_reconcile_chain_stale_table_columns.sql.document_chunks_content_trgm_idx: production's restored definition (coalesce(content, '')form,8499c3d3…) is canonical =schema.sql=20260705180000; staging carries the20260606000000bare-contentform (c3db2960…) because later creators useif not exists— staging-only residual for Phase 4.4, no escalation. Nothing UNCLASSIFIED.20260818113000_forward_codify_hybrid_owner_matches_bodies.sqlre-createsmatch_document_embedding_fields_hybrid,match_document_index_units_hybrid,match_document_memory_cards_hybrid_v2verbatim fromschema.sql. On a chain-built database these three still carry the legacy fail-open, sentinel-blind predicate(owner_filter is null or d.owner_id = owner_filter)because20260712000000_forward_codify_retrieval_owner_matches.sqlleft the body codification to an owner step that never happened for them (five other RPCs were codified later).schema.sql== production for all three (manifestdef_hash= livedef_hash, forensics §3.1), so this is a reproducibility hole for migrations-only environments, not a production tenancy hole; the migration is a no-op on production. EverySETclause is restated so proconfig is preserved; ACLs untouched. Protected RAG surface: this migration contains RPC bodies — copied byte-for-byte from the canonical definitions, nothing edited.docs/audit/live-drift-forensics-2026-08.md§Phase 3 written (3.5 carries the staging evidence);#316update (one combined request — the earlier one is cancelled in-inbox to avoid a same-id collision) and the#183rider (Supabase CLI authenticated + repo linked to staging) queued as inbox requests (docs/outstanding-issues-inbox/), plus two P3 captures (check:driftcolumn-diff clip; PR template lacksRAG impact:guidance), all reconciled later on a fresh-base branch.Staging proof — RUN (forensics §3.5)
Gate opened when the Phase 2 re-measure (#2104) merged. Owner-authorised staging window on
ikoiolksxqxfxgiyqpnu(ref verified vialist_projects, project id passed literally on every call; production never targeted):20260818110000/111000/112000applied by the Phase 2 method (file verbatim + explicit history row, neverapply_migration), md5-identical read-back for all three (dd5c8c9e…,9d02d14e…,ea5f9c69…); staging 198 rows,no_statements 0, corpus 0. Offline reproduction ofcheck:drift(samecategoryKeys/comparedFields, per-object md5; 590/594 hash-equal):The 8 never-created objects, the 3 column-set mismatches and 4 of the 7
work_memmismatches are gone. The three remaining functions are the reason for20260818113000; its staging apply is pending owner permission (the tool-permission classifier declined the hostedCREATE OR REPLACEof protected RPCs in-session), after which the trgm index should be the single residual.Production window — NOT authorised in this PR (for the coordinator)
Live state already matches for everything here, so one window can mark all of these applied together, and only the first is a real change:
20260818090000_schema_drift_snapshot_history_probeschema_drift_snapshot()v2 (Phase 6.1)20260818110000_codify_live_rpc_work_memwork_memvalues already match20260818111000_codify_schema_only_indexes_and_triggers20260818112000_reconcile_chain_stale_table_columns20260818113000_forward_codify_hybrid_owner_matches_bodiesNo canary (D2), no index build, no data change, no body that production does not already run.
Verification
npm run verify:pr-local— completed: check:runtime, check:installed-lock-parity, format:changed, sitemap:check, docs:check-index, docs:check-inventory, docs:check-scripts, docs:check-links, check:branch-review-ledger, check:outstanding-issues, check:ledger-write-discipline, lint, typecheck;testreportedTest Files 3 failed | 656 passed | 2 skipped (661) · Tests 3 failed | 7051 passed | 29 skipped (7083)in an 822 s run — the three aretests/session-start-hook.test.ts(known Windows-environmental) plus two host-load timeouts (tests/codex-cloud-setup.test.ts120 s,tests/private-access-routes.test.ts30 s) which pass in isolation:npx vitest run tests/codex-cloud-setup.test.ts tests/private-access-routes.test.ts tests/worker-observability.test.ts→Test Files 3 passed (3) · Tests 182 passed (182); the three not-reached stages were run directly:Offline RAG fixture and manifest validation passed (36 golden cases, 26 suites).,data/medication-interaction-index.json is up to date (525 rows).,docs/medication-interaction-lexicon-review.md is up to date (37 catalogue terms).npm run drift:manifest—Replay complete in 75s (container start included). Wrote supabase/drift-manifest.json; the tendef_hashvalues equal live (see Summary).npm run check:migration-role—Hosted migration-role guard passed: active hosted SQL/tooling uses postgres and immutable applied history is unchanged.npx vitest run tests/supabase-schema.test.ts tests/drift-detection.test.ts tests/migration-history-guards.test.ts tests/search-health-index-coverage.test.ts tests/retrieval-access-scope.test.ts tests/migration-history-placeholders.test.ts tests/hosted-migration-role-guard.test.ts tests/guard-push.test.ts—Test Files 8 passed (8) · Tests 149 passed (149)npm run check:production-readiness— run in this env-less worktree:FAIL (2)are the expected provider capability gaps (Missing server env config …,Missing OPENAI_API_KEY), not regressions; no provider was contacted.eval:retrieval:qualitynot run: no retrieval, ranking, selection, chunking, or scoring behaviour changed (attribute-only; owner decision D2).Risk and rollout
work_memis planner memory (latency-only, result sets fixed by each RPC'sORDER BY … LIMIT). Theschema.sqledits are 12 additiveset work_memlines; the manifest regeneration proves they reproduce live hashes exactly.schema.sql/ manifest and removes the three migration files). If a migration were already applied to a hosted target,ALTER FUNCTION … RESET work_mem/drop index/drop trigger/alter column … drop defaultare the one-statement inverses; none is needed for production, whose state does not change.ikoiolksxqxfxgiyqpnu) received20260818110000/111000/112000in an owner-authorised window; production untouched. Applying to production needs the coordinator's window (table above).Clinical Governance Preflight
Complete this section when the change touches ingestion, answer generation, search/ranking, source rendering, document access, privacy, production env, or clinical output.
Clinical KB Database(sjrfecxgysukkwxsowpy)Notes
match_*definitions changed only by theset work_memattribute line; bodies, signatures, return shapes, volatility,search_path/plan_cache_modeclauses and ACLs are untouched, and the drift-hash equality with live is the proof.scripts/check-drift.ts:192clipscolumnsdiffs to 240 chars per side, so a wide-table column drift never names the column;.github/pull_request_template.mdcarries noRAG impact:guidance althoughpr-policy.mjshard-blocks RAG-surface PRs without it.