Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

security(rls): enable RLS on every gbrain table the migrations-only upgrade path left without it (GBRA-95)

garrytand1be3fd40c80
diff --git a/docs/guides/rls-and-you.md b/docs/guides/rls-and-you.md
index 5850bd4877..c205dc291c 100644
--- a/docs/guides/rls-and-you.md
+++ b/docs/guides/rls-and-you.md
@@ -239,7 +239,12 @@ brains, the schema migration that creates the table
(`bun run new:migration <name>`, one file in `src/core/schema-migrations/`)
enables RLS too, with a `sqlFor: { pglite: ... }` variant that leaves it out.
The auto-RLS event trigger and doctor's `rls` check backstop a table that
-slips through on Postgres, but they are the safety net, not the plan.
+slips through on Postgres, but they are the safety net, not the plan: the
+trigger needs a superuser and is missing on many managed brains, and
+`gbrain apply-migrations --yes` runs migrations without replaying
+`src/schema.sql`. `test/e2e/rls-every-table-postgres.test.ts` checks every
+public table after a fresh install and after that migrations-only upgrade,
+both with the trigger inert, so a table that relies on either one fails it.
## Function search_path
diff --git a/scripts/module-size-limits.tsv b/scripts/module-size-limits.tsv
index b7ae9f7c73..4d9b63679a 100644
--- a/scripts/module-size-limits.tsv
+++ b/scripts/module-size-limits.tsv
@@ -47,3 +47,4 @@ src/commands/doctor/checks/extraction-sync.ts 1500 ratchet +7 GBRA-130 A-1: link
src/core/search/evidence-delivery.ts 1733 ratchet +5 W5: EvidencePlan.rankCut resolved with the plan (logic in search/page-rank-cut.ts); +20 W5 whole_pages: wholeCost prices a block as delivery would emit it whole (needs the private Block/enrichBlock internals) and the cut is wired before allocate (cutWholePages lives in search/page-rank-cut.ts); new row: crossed the 1500 unlisted cap at the #6367 merge (master 1479, its explicit-budget cap) by the C1 date header threaded through every block path, cap included; pagePlanHits (search/page-plan-hits.ts) and the header loader (evidence-date.ts blockDateHeaders) were peeled first; peel candidate: allocateCapped; +8 at the #6396 merge: page evidence text cut through the fence-chunk trust overlay and the caller minTrust floor (re-summed: our 1504 + master +8); +119 Cat 40 next wave F2: the search.long_page_unit policy (withLongPagePolicy, selectLongPages size preflight with page/byte/deadline limits) and the long-page fetch and fallback in deliverEvidence, kept in the shared seam the plan names (gbrain-evals docs/plans/2026-10-11-cat40-next-wave, F2); +17 F2 rework to the frozen-comparison policy: search.long_page_min_chars (rendered-body characters, default 20,000) read in withLongPagePolicy, a character count in the preflight, the rendered-body confirmation in deliverEvidence, and the long-page row exemption in capDeliveredSnippets (re-summed at the 0.60.225.0 merge: master 1537 + F2 136); +39 Wave B PR 2 lane 2b: planSegmentedBlock joins the windows search/segmented-evidence.ts reads around a segmented page's hits into one run-marked document (needs the private Doc/Piece/buildDoc/locateAnchor internals), planBlock's unit cut split into blockFromDoc for both, sections bounded by their run, selectionCost counts a gap between runs, and the fetch skips the whole-body fence overlay for a segmented page; +4 segmented pages read at once before planning (segmentedReads; the read is search/segmented-evidence.ts, the statements page-body/read-range.ts); +17 GBRA-156: tail trim plan flag, DeliverOptions.query, DeliveryMeta.tail_trim, the trim call and the frozen-hit score/query library fields (logic in search/evidence-tail-trim.ts; interface fields cannot move)
src/commands/config.ts 1523 ratchet new row: crossed the 1500 unlisted cap in wave 15 P7.4 #5461: set-time validation of think.pages_budget_chars / think.excerpt_ceiling_chars (range + parser live in core/think/pages-budget.ts), mirroring the cycle.consolidate.cluster_threshold hook; +1 wave 16 G5.1 (#6495): set-time refusal hook for search.keyword_statement_timeout_ms (check lives in commands/config/keyword-timeout-value.ts); +1 wave 18b lane 5 (#5012 item 6): search.contextual_retrieval prints the existing-pages hint after the write (text lives in commands/config/contextual-mode-hint.ts); +1 #6712 PR 2: retired/rollback sync key dispatch line (logic in core/sync-config-keys.ts handleSyncKeyConfig); +1 #6865: sync.slug_conflicts.auto_remove boolean validation at set time (refusal text in repair/slug-autoheal.ts); +1 #6948: sync.origin_twins.auto_resolve boolean validation at set time (refusal text in repair/origin-twins-heal.ts); +2 #6795: config set chat_model/expansion_model help line and the model-pin import (shadow report and file-pin unset live in commands/config/model-pin-shadow.ts); +1 #6712 PR 4b: sync.admission set-time hook (value logic in commands/config/sync-admission-value.ts); +4 #7130: set-time refusal hook for sync.max_deletes / sync.max_delete_ratio (and .source.<id>) / purge.retention_hours (check lives in core/sync-reconcile.ts deleteSafetyConfigRefusal); +1 GBRA-150: sync.metafile_pages set-time route (body in config/sync-metafile-pages-value.ts); re-summed at the v0.60.330.0 merge (1520 measured); +2 #7242 minions.terminal_hook file-plane key and its set branch (logic in minions/terminal-hook.ts); +1 GBRA-161: generations.* set-time route (refusal in commands/config/generations-values.ts)
src/commands/mcp-expose.ts 1512 ratchet hosted_option: Session carries the gbrain.io coaching notice on the first-receipt run and Tailscale/service friction exits (copy, refs and gating live in core/onboard/hosted-option.ts)
+src/core/behavior-change-notice.ts 1502 ratchet new row: crossed the 1500 unlisted cap with the GBRA-95 RLS backfill disclosure row (+2); the behavior-change table split (#7607) retires this row
diff --git a/src/core/behavior-change-notice.ts b/src/core/behavior-change-notice.ts
index 4c1af63423..0ab66b843e 100644
--- a/src/core/behavior-change-notice.ts
+++ b/src/core/behavior-change-notice.ts
@@ -1302,6 +1302,8 @@ export const BEHAVIOR_CHANGES: ReadonlyArray<{ since: string; text: ChangeText;
{ since: '0.60.460.0', text: 'A legacy fact row whose `notability` or `confidence` is empty (a long-lived database whose column lost its NOT NULL) is now adopted into its page\'s `## Facts` table with the column default (notability `medium`, confidence 1) instead of being refused as unadoptable (`parse`) on every run, which held its page out of fact reconciliation and booked an `integrity_guard` halt each cycle. The fence cell is written first and the row derives its values from it. A row with no kind or visibility is still refused.' },
{ since: '0.60.460.0', text: '`gbrain repair duplicate-facts` keeps the copy that is a row of a page\'s `## Facts` table over an older database-only copy of the same fact, so the legacy copy is superseded onto the fence row instead of holding it (which left the legacy row unfenced and its page out of fact reconciliation). With no fenced copy it still keeps the oldest row. It stays preview-first and explicit.' },
{ since: '0.60.460.0', text: 'Dream consolidation on a managed brain now closes a fenced fact in its page: the closing `valid_until` is written into the fact\'s row in the entity page\'s `## Facts` fence, published with the take, and the database row takes its value from that cell, so a later sync or re-import keeps the fact closed. Before, only the database row was closed and the next re-import of the page reopened it. A fact with no fence row is still closed in the database. A fenced fact whose fence row is on another page is left open. Facts an earlier release closed in the database only are not changed (GBRA-190).' },
+ // GBRA-95 RLS backfill. `since` is stamped at the merge slot.
+ { since: '0.60.461.0', id: 'rls_backfill_unguarded_tables', text: 'On Postgres, a schema migration now enables row-level security on every gbrain table still without it. A table could be left without RLS because its RLS came only from a full schema replay, which `gbrain apply-migrations --yes` does not run (the four incremental-derivation tables, `page_segment_derivations`, `page_derivation_spend` and the two purge tables), or only from the auto-RLS event trigger, which needs a superuser and is absent on many managed brains. Supabase gives public tables anon and authenticated grants, so with the Data API on such a table was reachable with the anon key. Only a table still without RLS changes; one with a `GBRAIN:RLS_EXEMPT` comment is left alone; no row is read or written. Under a role that does not bypass RLS or does not own a table, the migration names the table on stderr and leaves it, and `gbrain doctor` (rls) keeps naming it with the fix. `gbrain repair missing-tables` now recreates a cache table with RLS on. A role that neither owns a table nor bypasses RLS reads no rows from it once RLS is on (a read-only reporting role, for example): to keep such access on purpose, add the `GBRAIN:RLS_EXEMPT reason=...` comment to that table before upgrading.' },
];
/** The newest disclosed change's release: the notice id moves only when a release adds rows. */
diff --git a/src/core/page-body/schema.ts b/src/core/page-body/schema.ts
index a2529f79c3..87bc974968 100644
--- a/src/core/page-body/schema.ts
+++ b/src/core/page-body/schema.ts
@@ -355,16 +355,19 @@ CREATE TRIGGER page_segment_derivations_refuse_purging BEFORE INSERT OR UPDATE O
/**
* The segment tables hold page text (`page_segment_texts`, `page_body_staging_parts`) or a page's shape and
* headings (`page_body_manifest`, `page_body_stagings`, `page_view_digests`) or derived link context
- * (`page_segment_derivations`, and the purged claims `page_segment_derivation_purges` holds), so they get the posture of `pages`
+ * (`page_segment_derivations`, and the purged claims `page_segment_derivation_purges` holds) or a page's derivation
+ * spend (`page_derivation_spend`), so they get the posture of `pages`
* and `content_chunks`: RLS on, re-asserted on every schema replay like the core list in src/schema.sql, so a brain
* the auto-RLS event trigger (v35) missed, or one where it was dropped or disabled, never serves segment text to a
* role `pages` returns no rows to. Only under a role that bypasses RLS (else the runtime role would lock itself out),
* and only for a table still without it (ENABLE takes an ACCESS EXCLUSIVE lock even when RLS is on, #5227).
* `page_view_digests` is absent while migration v248 runs. Postgres only: PGLite has no role system, and its
* bootstrap enables RLS on no core table either. Source-scoped policies are operator SQL (docs/ENGINES.md).
+ * Only a full initSchema replays this block: a migration that creates one of these tables enables RLS itself
+ * (v275 backfills the v273 tables), since `gbrain apply-migrations --yes` runs migrations without the blob.
*/
export const PAGE_BODY_RLS_TABLES = ['page_segment_texts', 'page_body_manifest', 'page_body_stagings', 'page_body_staging_parts', 'page_view_digests', 'page_body_staging_texts', 'page_segment_derivations',
- 'page_segment_derivation_purges', 'page_segment_derivation_purge_pages'] as const;
+ 'page_derivation_spend', 'page_segment_derivation_purges', 'page_segment_derivation_purge_pages'] as const;
export const PAGE_BODY_RLS_SQL = `DO $rls$
DECLARE target TEXT;
BEGIN
diff --git a/src/core/schema-embedded.generated.ts b/src/core/schema-embedded.generated.ts
index 6863a511d6..2503b63224 100644
--- a/src/core/schema-embedded.generated.ts
+++ b/src/core/schema-embedded.generated.ts
@@ -2313,7 +2313,7 @@ DO \$rls\$
DECLARE target TEXT;
BEGIN
IF EXISTS (SELECT 1 FROM pg_roles r WHERE pg_has_role(current_user, r.oid, 'USAGE') AND (r.rolbypassrls OR r.rolsuper)) THEN
- FOREACH target IN ARRAY ARRAY['page_segment_texts','page_body_manifest','page_body_stagings','page_body_staging_parts','page_view_digests','page_body_staging_texts','page_segment_derivations','page_segment_derivation_purges','page_segment_derivation_purge_pages'] LOOP
+ FOREACH target IN ARRAY ARRAY['page_segment_texts','page_body_manifest','page_body_stagings','page_body_staging_parts','page_view_digests','page_body_staging_texts','page_segment_derivations','page_derivation_spend','page_segment_derivation_purges','page_segment_derivation_purge_pages'] LOOP
IF EXISTS (SELECT 1 FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace
WHERE n.nspname = current_schema() AND c.relname = target AND c.relkind = 'r' AND NOT c.relrowsecurity) THEN
EXECUTE format('ALTER TABLE %I ENABLE ROW LEVEL SECURITY', target);
diff --git a/src/core/schema-migrations/latest.generated.ts b/src/core/schema-migrations/latest.generated.ts
index 6d1e21ecc7..4f1b5b8a21 100644
--- a/src/core/schema-migrations/latest.generated.ts
+++ b/src/core/schema-migrations/latest.generated.ts
@@ -4,4 +4,4 @@
// The highest schema migration version (migrate.ts LATEST_VERSION), importable without
// loading the migrations themselves.
-export const LATEST_SCHEMA_VERSION = 274;
+export const LATEST_SCHEMA_VERSION = 275;
diff --git a/src/core/schema-migrations/registry.generated.ts b/src/core/schema-migrations/registry.generated.ts
index 91b70f5a9d..fa2fc51126 100644
--- a/src/core/schema-migrations/registry.generated.ts
+++ b/src/core/schema-migrations/registry.generated.ts
@@ -275,6 +275,7 @@ import { v271 } from './v271-facts-superseded-by-index.ts';
import { v272 } from './v272-git-canonical-declared.ts';
import { v273 } from './v273-segment-derivations.ts';
import { v274 } from './v274-pages-withheld-source-path.ts';
+import { v275 } from './v275-rls-backfill-unguarded-tables.ts';
// Array order is historical (see HISTORICAL_ARRAY_ORDER in the generator); the
// runner sorts by version before applying.
@@ -548,4 +549,5 @@ export const MIGRATIONS: Migration[] = [
v272,
v273,
v274,
+ v275,
];
diff --git a/src/core/schema-migrations/v273-segment-derivations.ts b/src/core/schema-migrations/v273-segment-derivations.ts
index f971a5d0fa..c8b27da73a 100644
--- a/src/core/schema-migrations/v273-segment-derivations.ts
+++ b/src/core/schema-migrations/v273-segment-derivations.ts
@@ -8,8 +8,11 @@ import { runMigrationStatement } from './helpers.ts';
// Wave B PR 4, incremental derivation (wave-b spec 1.2 item 7, 8.1, 8.2):
// - page_segment_derivations: per page, pipeline and manifest occurrence, the
// segment sha, context hash and pipeline version a derivation ran on, its
-// outcome and a bounded output (also in both blobs; the blob's RLS block,
-// replayed on every initSchema, covers it on Postgres).
+// outcome and a bounded output, with page_derivation_spend and the purge
+// tables beside it (also in both blobs). This migration enables no RLS: the
+// blob's page-body RLS block covers them only when a full initSchema replays
+// it, which `gbrain apply-migrations --yes` does not, and page_derivation_spend
+// was not in that block's list. v275 enables RLS on all four on Postgres.
// - facts.source_window: the conversation window a fact was extracted from,
// {occurrence_id, window_ordinal, window_text_sha} (page-body/derivations.ts
// SourceWindow), so an append re-extracts only new windows and deletes only
diff --git a/src/core/schema-migrations/v275-rls-backfill-unguarded-tables.ts b/src/core/schema-migrations/v275-rls-backfill-unguarded-tables.ts
new file mode 100644
index 0000000000..affd123ddf
--- /dev/null
+++ b/src/core/schema-migrations/v275-rls-backfill-unguarded-tables.ts
@@ -0,0 +1,141 @@
+import type { Migration } from './types.ts';
+import type { BrainEngine } from '../engine.ts';
+import { migrationStatementTimeoutMs } from '../migration-timeout.ts';
+import { isLockTimeoutError } from '../retry-matcher.ts';
+import { resolveSchemaLockTimeoutMs, schemaLockBlockedError } from '../postgres-engine/schema-lock-timeout.ts';
+
+// Applied by src/core/migrate.ts on the next initSchema(); see docs/ENGINES.md
+// ("Canonical schema sources") for when schema.sql or a TS fragment also changes.
+//
+// RLS backfill on Postgres for every table gbrain creates. Supabase grants anon
+// and authenticated default privileges on public tables, so a table left
+// without RLS is readable and writable with the anon key whenever the Data API
+// is on. A table could be left without it because its RLS came from a path that
+// does not run on every brain:
+// - the schema blob's RLS blocks, which only a full initSchema replays:
+// `gbrain apply-migrations --yes` runs migrations without the blob (v273's
+// four tables, and page_derivation_spend was missing from the blob's list);
+// - v35's auto-RLS event trigger, which needs a superuser to create and is
+// absent or inert on managed brains that never had it or lost it (a dump
+// restore does not carry it): every table created after that without its own
+// RLS block came up with RLS off there.
+// TABLES is every table a fresh install creates, frozen at this migration; a
+// later migration that creates a table enables RLS itself
+// (test/e2e/rls-every-table-postgres.test.ts fails otherwise).
+// Same posture as the blob's RLS blocks and v35's backfill: ENABLE only (no
+// FORCE, no policies), only for a table still without RLS (ENABLE takes an
+// ACCESS EXCLUSIVE lock even when RLS is on, #5227), never for a table carrying
+// the GBRAIN:RLS_EXEMPT comment doctor honors, and only under a role that
+// bypasses RLS and owns the table. Under any other role, enabling RLS would
+// lock the runtime role out of its own rows or fail on ownership, and raising
+// would hold every later migration back (#3603), so the table is skipped and
+// named on stderr; doctor's rls check keeps failing with the fix until it is
+// done. Each table is its own short transaction with the migration's
+// transaction-local statement and lock timeouts (safe behind a transaction
+// pooler), so no lock is held while the next one waits. Both the public table
+// (what the Data API serves) and the relation gbrain's unqualified statements
+// resolve to through the search path are covered. Flag change only: no row is
+// read or written. PGLite has no role system and enforces no RLS: no-op.
+const TABLES = [
+ 'access_tokens', 'belief_commit_marks', 'belief_events', 'belief_page_lifetimes', 'belief_redactions',
+ 'belief_retier_manifest', 'budget_ledger', 'budget_reservations', 'calibration_profiles', 'chat_usage_log',
+ 'chronicle_judge_reservations', 'chronicle_page_state', 'code_edges_chunk', 'code_edges_symbol',
+ 'code_traversal_cache', 'config', 'content_chunks', 'context_volunteer_events', 'conversation_parser_llm_cache',
+ 'core_edit_notices', 'decide_calibrations', 'decide_proposals', 'decide_review_proposals', 'decide_review_queue',
+ 'decide_spend', 'decide_state', 'decide_sweep_deferred', 'decision_receipts', 'derivation_inputs',
+ 'derived_generation_activations', 'derived_generation_attempts', 'derived_generation_items',
+ 'derived_generation_valve', 'derived_generations', 'dream_synthesis_completions', 'dream_verdicts',
+ 'drift_decisions', 'entity_identities', 'eval_candidates', 'eval_capture_failures', 'eval_contradictions_cache',
+ 'eval_contradictions_runs', 'eval_takes_quality_runs', 'extract_atoms_page_state',
+ 'extract_atoms_transcript_state', 'extract_rollup_7d', 'fact_purges', 'fact_relink_attempts', 'fact_withdrawals',
+ 'facts', 'file_migration_ledger', 'files', 'gbrain_cycle_locks', 'git_canonical_brain', 'ingest_log',
+ 'link_edge_proposals', 'link_relationships', 'link_transitions', 'links', 'loop_suppressions', 'mcp_request_log',
+ 'mcp_spend_log', 'mcp_spend_reservations', 'mention_gazetteer_entries', 'mention_index_status',
+ 'migration_impact_log', 'minion_attachments', 'minion_budget_log', 'minion_inbox', 'minion_jobs',
+ 'minion_lease_pressure_log', 'minion_self_fix_log', 'needs_rederive', 'oauth_clients', 'oauth_codes',
+ 'oauth_grant_audit', 'oauth_tokens', 'op_checkpoint_paths', 'op_checkpoints', 'open_loops', 'page_aliases',
+ 'page_body_manifest', 'page_body_staging_parts', 'page_body_staging_texts', 'page_body_stagings',
+ 'page_derivation_spend', 'page_embedding_budget', 'page_extraction_state', 'page_facts_reconcile',
+ 'page_generation_clock', 'page_mention_state', 'page_projection_jobs', 'page_purges', 'page_retrievals',
+ 'page_segment_derivation_purge_pages', 'page_segment_derivation_purges', 'page_segment_derivations',
+ 'page_segment_texts', 'page_versions', 'page_view_digests', 'page_write_guards', 'pages', 'persistence_brain',
+ 'persistence_consumers', 'persistence_counters', 'persistence_effects', 'persistence_graduation',
+ 'persistence_host_bindings', 'persistence_local_writers', 'persistence_requests', 'persistence_source_bindings',
+ 'persistence_topology_changes', 'persistence_worktree_refreshes', 'persistence_worktrees',
+ 'persistence_writer_protocols', 'pinned_questions', 'query_cache', 'question_evidence', 'raw_data',
+ 'retrieval_event_links', 'retrieval_event_pages', 'retrieval_events', 'retrieval_feedback', 'retrieval_weights',
+ 'search_telemetry', 'session_context_state', 'shared_skill_delivery_batches', 'shared_skill_heads',
+ 'shared_skill_members', 'shared_skill_packs', 'shared_skill_policies', 'shared_skill_policy_audit',
+ 'shared_skill_revision_leases', 'shared_skill_revisions', 'shared_skill_state', 'slug_aliases',
+ 'source_ingestion_receipts', 'sources', 'subagent_messages', 'subagent_rate_leases', 'subagent_tool_executions',
+ 'sync_notifier_leases', 'sync_notifier_sources', 'sync_wanted_markers', 'synthesis_evidence', 'tags',
+ 'take_domain_assignments', 'take_grade_cache', 'take_horizons', 'take_nudge_log', 'take_proposals', 'take_purges',
+ 'takes', 'think_ab_results', 'timeline_entries', 'trust_allow_rules', 'trust_policy_state', 'trust_proposals',
+ 'wanted_links', 'write_gate_holds', 'write_gate_receipts',
+];
+
+const EXEMPT_RE = String.raw`^GBRAIN:RLS_EXEMPT\s+reason=\S.{3,}`;
+
+function enableRlsSql(oid: number): string {
+ if (!Number.isSafeInteger(oid) || oid <= 0) throw new Error(`enableRlsSql: unexpected relation oid ${oid}`);
+ return `DO $rls$
+DECLARE
+ rel REGCLASS := ${oid}::oid::regclass;
+ t RECORD;
+BEGIN
+ IF NOT EXISTS (SELECT 1 FROM pg_roles r WHERE pg_has_role(current_user, r.oid, 'USAGE') AND (r.rolbypassrls OR r.rolsuper)) THEN
+ RETURN;
+ END IF;
+ SELECT c.relkind, c.relrowsecurity, pg_has_role(current_user, c.relowner, 'USAGE') AS owned, COALESCE(obj_description(c.oid, 'pg_class'), '') AS note
+ INTO t FROM pg_class c WHERE c.oid = rel;
+ IF FOUND AND t.relkind = 'r' AND NOT t.relrowsecurity AND t.owned AND t.note !~ '${EXEMPT_RE}' THEN
+ EXECUTE format('ALTER TABLE %s ENABLE ROW LEVEL SECURITY', rel);
+ END IF;
+END $rls$;`;
+}
+
+/** The public relations and search-path relations named in `tables` that still lack RLS and are not exempt. */
+async function relationsWithoutRls(engine: BrainEngine, tables: readonly string[]): Promise<Array<{ oid: number; name: string }>> {
+ const rows = await engine.executeRaw<{ oid: number | string; name: string }>(
+ `SELECT c.oid, c.oid::regclass::text AS name FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace
+ WHERE c.relkind = 'r' AND c.relname = ANY($1::text[]) AND (n.nspname = 'public' OR c.oid = to_regclass(quote_ident(c.relname)))
+ AND NOT c.relrowsecurity AND COALESCE(obj_description(c.oid, 'pg_class'), '') !~ $2
+ ORDER BY 2`, [tables, EXEMPT_RE]);
+ return rows.map(r => ({ oid: Number(r.oid), name: r.name }));
+}
+
+/**
+ * Enables RLS on the named gbrain tables where it is still off (Postgres; a no-op elsewhere), one transaction per
+ * table, and names on stderr any the role could not protect. Returns those names.
+ */
+export async function protectTables(engine: BrainEngine, tables: readonly string[], label: string): Promise<string[]> {
+ if (engine.kind !== 'postgres') return [];
+ const lockTimeoutMs = resolveSchemaLockTimeoutMs();
+ for (const rel of await relationsWithoutRls(engine, tables)) {
+ try {
+ await engine.transaction(async tx => {
+ await tx.executeRaw(`SET LOCAL statement_timeout = '${migrationStatementTimeoutMs()}'`);
+ await tx.executeRaw(`SET LOCAL lock_timeout = '${lockTimeoutMs}ms'`);
+ await tx.executeRaw(enableRlsSql(rel.oid));
+ });
+ } catch (error) {
+ if (isLockTimeoutError(error)) throw schemaLockBlockedError({ step: `${label} on ${rel.name}`, timeoutMs: lockTimeoutMs, sessions: null, sampledDuringWait: false });
+ throw error;
+ }
+ }
+ const left = (await relationsWithoutRls(engine, tables)).map(r => r.name);
+ if (left.length > 0) {
+ process.stderr.write(` ${label}: row-level security is still off on ${left.length} table(s) (${left.join(', ')}): `
+ + 'the role must bypass RLS and own them. Run gbrain doctor for the fix.\n');
+ }
+ return left;
+}
+
+export const v275: Migration = {
+ version: 275,
+ name: 'rls_backfill_unguarded_tables',
+ idempotent: true,
+ transaction: false,
+ sql: '',
+ handler: async engine => { await protectTables(engine, TABLES, 'v275'); },
+};
diff --git a/src/core/schema-missing-tables.ts b/src/core/schema-missing-tables.ts
index 6ce39a126c..4e0fb09a7f 100644
--- a/src/core/schema-missing-tables.ts
+++ b/src/core/schema-missing-tables.ts
@@ -13,6 +13,7 @@ import { isRebuildableCache } from './persistence/rebuildable-cache.ts';
import { v055 } from './schema-migrations/v055-query-cache-search-lite.ts';
import { v056 } from './schema-migrations/v056-query-cache-knobs-hash.ts';
import { v059 } from './schema-migrations/v059-code-traversal-cache-v0-34.ts';
+import { protectTables } from './schema-migrations/v275-rls-backfill-unguarded-tables.ts';
import { hnswIndexExpected, readExistingEmbeddingShape } from './vector-index.ts';
import type { LossKind } from './persistence/engine-graduation.types.ts';
@@ -58,9 +59,13 @@ const RECREATE: Readonly<Record<string, (engine: BrainEngine) => Promise<void>>>
/** The migration that first creates each recreatable cache; below it the table is not expected yet. */
const CREATED_BY: Readonly<Record<string, number>> = { query_cache: 55, code_traversal_cache: 59 };
-/** The recreate step for a rebuildable cache, or undefined for any other name. */
+/** The recreate step for a rebuildable cache, or undefined for any other name. On Postgres the table comes back with RLS on (v275's gate; a role that cannot is named on stderr). */
export function recreateStep(table: string): ((engine: BrainEngine) => Promise<void>) | undefined {
- return Object.hasOwn(RECREATE, table) && isRebuildableCache(table) ? RECREATE[table] : undefined;
+ if (!Object.hasOwn(RECREATE, table) || !isRebuildableCache(table)) return undefined;
+ return async engine => {
+ await RECREATE[table](engine);
+ await protectTables(engine, [table], 'repair missing-tables');
+ };
}
/** The tables `gbrain repair missing-tables` can recreate. */
diff --git a/src/schema.sql b/src/schema.sql
index 7cd85b5ea2..565611aa22 100644
--- a/src/schema.sql
+++ b/src/schema.sql
@@ -2309,7 +2309,7 @@ DO $rls$
DECLARE target TEXT;
BEGIN
IF EXISTS (SELECT 1 FROM pg_roles r WHERE pg_has_role(current_user, r.oid, 'USAGE') AND (r.rolbypassrls OR r.rolsuper)) THEN
- FOREACH target IN ARRAY ARRAY['page_segment_texts','page_body_manifest','page_body_stagings','page_body_staging_parts','page_view_digests','page_body_staging_texts','page_segment_derivations','page_segment_derivation_purges','page_segment_derivation_purge_pages'] LOOP
+ FOREACH target IN ARRAY ARRAY['page_segment_texts','page_body_manifest','page_body_stagings','page_body_staging_parts','page_view_digests','page_body_staging_texts','page_segment_derivations','page_derivation_spend','page_segment_derivation_purges','page_segment_derivation_purge_pages'] LOOP
IF EXISTS (SELECT 1 FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace
WHERE n.nspname = current_schema() AND c.relname = target AND c.relkind = 'r' AND NOT c.relrowsecurity) THEN
EXECUTE format('ALTER TABLE %I ENABLE ROW LEVEL SECURITY', target);
diff --git a/test/e2e/rls-every-table-postgres.test.ts b/test/e2e/rls-every-table-postgres.test.ts
new file mode 100644
index 0000000000..f74552c066
--- /dev/null
+++ b/test/e2e/rls-every-table-postgres.test.ts
@@ -0,0 +1,258 @@
+/**
+ * Every public table has row-level security after a fresh install and after
+ * the migrations-only upgrade path (#GBRA-95 class: Wave B PR 4's v273 tables
+ * shipped with RLS off on Postgres).
+ *
+ * Supabase grants anon and authenticated default privileges on public tables,
+ * so a gbrain table without RLS is readable and writable with the anon key
+ * whenever the Data API is on. gbrain enables RLS in three places: the schema
+ * blob's DO blocks (replayed by a full initSchema), per-migration DO blocks,
+ * and v35's auto-RLS event trigger. The trigger is superuser-only and absent
+ * or inert on many managed brains, and `gbrain apply-migrations --yes` runs
+ * migrations without replaying the blob, so a migration that creates a table
+ * must enable RLS itself. On a superuser test database the trigger exists and
+ * hides that gap, so each case here starts from a scratch database where the
+ * trigger is pre-created DISABLED (v35 is create-if-absent and converges on
+ * it, as it does on a managed brain whose master user created it).
+ *
+ * The only exemption is a table carrying the documented
+ * `GBRAIN:RLS_EXEMPT reason=...` comment (the regex doctor's rls check uses).
+ * A new table that relies on the event trigger or on the blob alone fails here.
+ * Run: DATABASE_URL=... bun test test/e2e/rls-every-table-postgres.test.ts
+ */
+import { afterAll, describe, expect, test } from 'bun:test';
+import { randomUUID } from 'node:crypto';
+import { rmSync } from 'node:fs';
+import postgres from '#postgres';
+import { assertSafeE2eDatabaseUrl } from '../helpers/db-guard.ts';
+import { collect, makeHome, spawnDriver } from '../helpers/apply-migrations-lock-driver.ts';
+import { writeSchemaDriver } from '../helpers/apply-migrations-schema-driver.ts';
+import { PostgresEngine } from '../../src/core/postgres-engine.ts';
+import { LATEST_VERSION } from '../../src/core/migrate.ts';
+import { v275 } from '../../src/core/schema-migrations/v275-rls-backfill-unguarded-tables.ts';
+import { recreateStep } from '../../src/core/schema-missing-tables.ts';
+
+const DATABASE_URL = process.env.DATABASE_URL;
+const describeE2E = DATABASE_URL ? describe : describe.skip;
+
+const V273_TABLES = ['page_derivation_spend', 'page_segment_derivation_purge_pages', 'page_segment_derivation_purges', 'page_segment_derivations'];
+
+const scratch: string[] = [];
+const homes: string[] = [];
+let admin: ReturnType<typeof postgres> | null = null;
+
+function urlFor(name: string): string {
+ const url = new URL(DATABASE_URL!);
+ url.pathname = `/${name}`;
+ return url.toString();
+}
+
+/** A scratch database whose v35 auto-RLS event trigger exists but never fires. */
+async function scratchDatabase(): Promise<{ url: string; conn: ReturnType<typeof postgres> }> {
+ assertSafeE2eDatabaseUrl(DATABASE_URL!);
+ admin ??= postgres(DATABASE_URL!, { max: 1, prepare: false });
+ const name = `gbrain_test_rls_${randomUUID().replaceAll('-', '')}`;
+ await admin.unsafe(`CREATE DATABASE ${name}`);
+ scratch.push(name);
+ const url = urlFor(name);
+ const conn = postgres(url, { max: 1, prepare: false, onnotice: () => {} });
+ await conn.unsafe(`CREATE FUNCTION auto_enable_rls() RETURNS event_trigger LANGUAGE plpgsql AS $$ BEGIN END $$`);
+ await conn.unsafe(`CREATE EVENT TRIGGER auto_rls_on_create_table ON ddl_command_end WHEN TAG IN ('CREATE TABLE') EXECUTE FUNCTION auto_enable_rls()`);
+ await conn.unsafe(`ALTER EVENT TRIGGER auto_rls_on_create_table DISABLE`);
+ return { url, conn };
+}
+
+async function freshInit(url: string): Promise<void> {
+ const engine = new PostgresEngine();
+ await engine.connect({ database_url: url });
+ try { await engine.initSchema(); } finally { await engine.disconnect(); }
+}
+
+/** Public base tables without RLS, minus the documented GBRAIN:RLS_EXEMPT ones. */
+async function tablesWithoutRls(conn: ReturnType<typeof postgres>): Promise<string[]> {
+ const rows = await conn.unsafe<Array<{ relname: string }>>(`
+ SELECT c.relname FROM pg_class c
+ JOIN pg_namespace n ON n.oid = c.relnamespace
+ LEFT JOIN pg_description d ON d.objoid = c.oid AND d.classoid = 'pg_class'::regclass AND d.objsubid = 0
+ WHERE n.nspname = 'public' AND c.relkind IN ('r', 'p') AND NOT c.relrowsecurity
+ AND (d.description IS NULL OR d.description !~ '^GBRAIN:RLS_EXEMPT\\s+reason=\\S.{3,}')
+ ORDER BY c.relname`);
+ return rows.map(r => r.relname);
+}
+
+async function presentTables(conn: ReturnType<typeof postgres>, names: string[]): Promise<string[]> {
+ const rows = await conn.unsafe<Array<{ relname: string }>>(
+ `SELECT c.relname FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace
+ WHERE n.nspname = 'public' AND c.relkind = 'r' AND c.relname = ANY($1::text[]) ORDER BY c.relname`, [names]);
+ return rows.map(r => r.relname);
+}
+
+describeE2E('RLS on every public table (Postgres, no auto-RLS event trigger)', () => {
+ afterAll(async () => {
+ if (admin) {
+ for (const name of scratch) await admin.unsafe(`DROP DATABASE IF EXISTS ${name} WITH (FORCE)`);
+ await admin.end();
+ }
+ for (const home of homes) rmSync(home, { recursive: true, force: true });
+ });
+
+ test('a fresh initSchema leaves no public table without RLS', async () => {
+ const { url, conn } = await scratchDatabase();
+ try {
+ await freshInit(url);
+ expect(await presentTables(conn, V273_TABLES)).toEqual(V273_TABLES);
+ expect(await tablesWithoutRls(conn)).toEqual([]);
+ } finally {
+ await conn.end();
+ }
+ }, 300_000);
+
+ test('a brain at v272 upgraded with `gbrain apply-migrations --yes` (no blob replay) leaves no public table without RLS', async () => {
+ const { url, conn } = await scratchDatabase();
+ try {
+ await freshInit(url);
+ // Rewind to the schema before v273: drop what v273 and v274 create and stamp version 272.
+ await conn.unsafe(`DROP TABLE page_segment_derivation_purge_pages, page_segment_derivation_purges, page_derivation_spend, page_segment_derivations CASCADE`);
+ await conn.unsafe(`DROP TRIGGER IF EXISTS page_body_manifest_derivation_scope_retire ON page_body_manifest;
+ DROP TRIGGER IF EXISTS page_body_manifest_derivation_scope_delete ON page_body_manifest;
+ DROP TRIGGER IF EXISTS pages_derivation_scope_delete ON pages;
+ DROP FUNCTION IF EXISTS gbrain_mark_derivation_scope_entry();
+ DROP FUNCTION IF EXISTS gbrain_refuse_purging_derivation();
+ ALTER TABLE facts DROP CONSTRAINT IF EXISTS facts_source_window_chk, DROP COLUMN IF EXISTS source_window;
+ ALTER TABLE pages DROP COLUMN IF EXISTS withheld_source_path;`);
+ await conn.unsafe(`UPDATE config SET value = '272' WHERE key = 'version'`);
+ expect(await presentTables(conn, V273_TABLES)).toEqual([]);
+
+ const home = makeHome({ engine: 'postgres', database_url: url });
+ homes.push(home);
+ const run = await collect(spawnDriver(home, writeSchemaDriver(home, { migrations: [], args: ['--yes', '--non-interactive', '--no-autopilot-install', '--json'] })));
+ expect(run.code, run.stderr + run.stdout).toBe(0);
+ const version = await conn.unsafe<Array<{ value: string }>>(`SELECT value FROM config WHERE key = 'version'`);
+ expect(Number(version[0]?.value)).toBe(LATEST_VERSION);
+
+ expect(await presentTables(conn, V273_TABLES)).toEqual(V273_TABLES);
+ expect(await tablesWithoutRls(conn)).toEqual([]);
+ } finally {
+ await conn.end();
+ }
+ }, 300_000);
+
+ test('every public table with RLS turned off at the version before v275, upgraded with `gbrain apply-migrations --yes`, ends with RLS on', async () => {
+ // The upgrade path for tables older than v273: a table whose RLS came only from the blob's blocks or the event
+ // trigger is off on a trigger-less brain however old it is. A later migration that creates a table without its own
+ // RLS block leaves it off here too.
+ const { url, conn } = await scratchDatabase();
+ try {
+ await freshInit(url);
+ const all = await tablesWithoutRls(conn);
+ expect(all).toEqual([]);
+ await conn.unsafe(`DO $$ DECLARE t record; BEGIN
+ FOR t IN SELECT c.oid::regclass AS rel FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace
+ WHERE n.nspname = 'public' AND c.relkind = 'r' AND c.relrowsecurity LOOP
+ EXECUTE format('ALTER TABLE %s DISABLE ROW LEVEL SECURITY', t.rel);
+ END LOOP; END $$`);
+ await conn.unsafe(`UPDATE config SET value = $1 WHERE key = 'version'`, [String(v275.version - 1)]);
+ expect((await tablesWithoutRls(conn)).length).toBeGreaterThan(100);
+
+ const home = makeHome({ engine: 'postgres', database_url: url });
+ homes.push(home);
+ const run = await collect(spawnDriver(home, writeSchemaDriver(home, { migrations: [], args: ['--yes', '--non-interactive', '--no-autopilot-install', '--json'] })));
+ expect(run.code, run.stderr + run.stdout).toBe(0);
+ expect(run.stderr).not.toContain('row-level security is still off');
+ expect(await tablesWithoutRls(conn)).toEqual([]);
+ } finally {
+ await conn.end();
+ }
+ }, 300_000);
+
+ /** Runs the v275 handler on one reserved session (role, search path) and returns what it wrote to stderr. */
+ async function runHandlerAs(conn: ReturnType<typeof postgres>, setup: string): Promise<string> {
+ const session = await conn.reserve();
+ const stderr: string[] = [];
+ const write = process.stderr.write;
+ try {
+ await session.unsafe(setup);
+ const executeRaw = (sql: string, params?: unknown[]) => session.unsafe(sql, params as never[]);
+ const transaction = async (fn: (tx: unknown) => Promise<unknown>) => {
+ await session.unsafe('BEGIN');
+ try {
+ const result = await fn({ executeRaw });
+ await session.unsafe('COMMIT');
+ return result;
+ } catch (error) {
+ await session.unsafe('ROLLBACK');
+ throw error;
+ }
+ };
+ const engine = { kind: 'postgres', executeRaw, transaction };
+ process.stderr.write = ((chunk: string) => { stderr.push(String(chunk)); return true; }) as typeof process.stderr.write;
+ await v275.handler!(engine as never);
+ } finally {
+ process.stderr.write = write;
+ await session.unsafe('RESET ROLE; RESET search_path');
+ session.release();
+ }
+ return stderr.join('');
+ }
+
+ test('v275 skips an exempt table and a table the role cannot protect, and names what is left', async () => {
+ const { url, conn } = await scratchDatabase();
+ const suffix = randomUUID().replaceAll('-', '').slice(0, 12);
+ const noBypass = `gbrain_test_rls_nobypass_${suffix}`;
+ const notOwner = `gbrain_test_rls_notowner_${suffix}`;
+ try {
+ await freshInit(url);
+ await conn.unsafe(`ALTER TABLE page_derivation_spend DISABLE ROW LEVEL SECURITY; ALTER TABLE query_cache DISABLE ROW LEVEL SECURITY;
+ COMMENT ON TABLE query_cache IS 'GBRAIN:RLS_EXEMPT reason=probe table read by an external reader'`);
+ await conn.unsafe(`CREATE ROLE ${noBypass} NOLOGIN NOBYPASSRLS; CREATE ROLE ${notOwner} NOLOGIN BYPASSRLS`);
+ for (const role of [noBypass, notOwner]) {
+ const stderr = await runHandlerAs(conn, `SET ROLE ${role}`);
+ expect(stderr).toContain('v275: row-level security is still off on 1 table(s) (page_derivation_spend)');
+ expect(await tablesWithoutRls(conn)).toEqual(['page_derivation_spend']);
+ }
+
+ expect(await runHandlerAs(conn, 'SELECT 1')).toBe('');
+ expect(await tablesWithoutRls(conn)).toEqual([]);
+ const exempt = await conn.unsafe<Array<{ relrowsecurity: boolean }>>(`SELECT relrowsecurity FROM pg_class WHERE oid = 'public.query_cache'::regclass`);
+ expect(exempt[0]?.relrowsecurity).toBe(false);
+ } finally {
+ await conn.end();
+ await admin!.unsafe(`DROP ROLE IF EXISTS ${noBypass}`).catch(() => {});
+ await admin!.unsafe(`DROP ROLE IF EXISTS ${notOwner}`).catch(() => {});
+ }
+ }, 300_000);
+
+ test('v275 protects the public table when a same-named table earlier in the search path shadows it', async () => {
+ const { url, conn } = await scratchDatabase();
+ try {
+ await freshInit(url);
+ await conn.unsafe(`CREATE SCHEMA shadow; CREATE TABLE shadow.query_cache (LIKE public.query_cache);
+ ALTER TABLE shadow.query_cache DISABLE ROW LEVEL SECURITY; ALTER TABLE public.query_cache DISABLE ROW LEVEL SECURITY`);
+ expect(await runHandlerAs(conn, 'SET search_path = shadow, public')).toBe('');
+ const flags = await conn.unsafe<Array<{ name: string; relrowsecurity: boolean }>>(
+ `SELECT n.nspname || '.' || c.relname AS name, c.relrowsecurity FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace
+ WHERE c.relname = 'query_cache' ORDER BY 1`);
+ expect(flags.map(f => ({ name: f.name, relrowsecurity: f.relrowsecurity }))).toEqual([{ name: 'public.query_cache', relrowsecurity: true }, { name: 'shadow.query_cache', relrowsecurity: true }]);
+ } finally {
+ await conn.end();
+ }
+ }, 300_000);
+
+ test('gbrain repair missing-tables recreates a cache table with RLS on', async () => {
+ const { url, conn } = await scratchDatabase();
+ const engine = new PostgresEngine();
+ try {
+ await freshInit(url);
+ await engine.connect({ database_url: url });
+ for (const table of ['query_cache', 'code_traversal_cache']) {
+ await conn.unsafe(`DROP TABLE ${table}`);
+ await recreateStep(table)!(engine);
+ }
+ expect(await presentTables(conn, ['code_traversal_cache', 'query_cache'])).toEqual(['code_traversal_cache', 'query_cache']);
+ expect(await tablesWithoutRls(conn)).toEqual([]);
+ } finally {
+ await engine.disconnect();
+ await conn.end();
+ }
+ }, 300_000);
+});
diff --git a/test/fixtures/goldens/catalog/postgres-db-initschema.json b/test/fixtures/goldens/catalog/postgres-db-initschema.json
index ccc8d42b9c..aff18d2410 100644
--- a/test/fixtures/goldens/catalog/postgres-db-initschema.json
+++ b/test/fixtures/goldens/catalog/postgres-db-initschema.json
@@ -2399,7 +2399,7 @@
"5 reserved_at timestamp with time zone/timestamptz NULL",
"6 updated_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()"
],
- "flags": "relkind=r rls=false force_rls=false"
+ "flags": "relkind=r rls=true force_rls=false"
},
"page_embedding_budget": {
"columns": [
diff --git a/test/fixtures/goldens/migrations/records.json b/test/fixtures/goldens/migrations/records.json
index 227c97b0ae..64bda389d1 100644
--- a/test/fixtures/goldens/migrations/records.json
+++ b/test/fixtures/goldens/migrations/records.json
@@ -1,6 +1,6 @@
{
"golden": {
- "count": 269,
+ "count": 270,
"gaps": [
17,
18,
@@ -15,6 +15,7 @@
"CONTENT_CHUNKS_GENERATION_INDEX": "c434b3a4acdad499cf3b9f170d9f9967b8e3e8218c829db99f3ecba3b53c8b5d",
"CONTENT_CHUNKS_OCCURRENCE_GENERATION_INDEX": "b4f73db97ad878ef7256128ddef83fd11e2e08fd215e389d9e921a0daf04853d",
"CONTENT_CHUNKS_OCCURRENCE_INDEX": "7b692ba777b30399ab5a3b100eb40b3b9d1b3fb2322dc4dc808ba8a4d667912c",
+ "EXEMPT_RE": "e8b623114f4f77fc3abcfc479abec1442dbf41bc607e046d124b44572d59953c",
"FACTS_SUPERSEDED_BY_INDEX": "555c2b267989359a078de0f82cea830584bc0a268be6796bf526c0a9bed45905",
"FACT_PURGES_ALL_SUBJECTS_INDEX": "99e2eb6c24134b539cb4cfd6e5ff66a724463525d09e9ba1fdde3c13f5787b6c",
"FACT_PURGES_SUBJECT_INDEX": "f4fba07082f2e26da3fa51b0b689f3fe78a3d09afd20c1924dbc2fbe6b1560f1",
@@ -42,6 +43,7 @@
"PERSISTENCE_SYNC_RUN_INDEXES": "e1b12613c5fd2facb850e6857b0bddcf49b2478ec258fa226fe15e71e55df9c1",
"PERSISTENCE_SYNC_WATERMARK_INDEX": "93523954a30e8483717f07ec97a3e0cd062b15d8a60cc759281054b06c23bb40",
"PLANNER_REPAIR_TABLES": "008725595e099adba279d4292661eb4a59930b777c35db43c340220f7f12e093",
+ "TABLES": "3fc77a0fccb525f9b791098f9eae27b19adaa3f5dadbabcff2a719137cbc3ef8",
"TOKEN_TTL_MAX_SECONDS": "f4a45bec6ec0bacc859dc57732ceb76cec7eb72f242b5a6c89d47190d0525ab4",
"TOKEN_TTL_MIN_SECONDS": "441d8ce6bd21f753de90abd3013eaa9992a469ea60c590f1005533618199aa25",
"analyzeAfterIndexBuild": "8d627df6b496e1c197a244f8519aeaf3aebcd23e3f7cf514576d453a4270e33a",
@@ -55,10 +57,12 @@
"chunkSearchVectorTriggerFnSql": "93ed4e29aa058949621b4198fe1ec317218f4b9ec0db0626ec6dc7001032047d",
"clampOAuthTokenTtls": "b1e94ea8f5b3c3870a56b0f6d00d0a274c2e9dcad912b828848aec250732645f",
"dropInvalidConcurrentIndex": "6864d844b7dfb2fbecdd0fb9c73e06248473376feb794b3fe58f036c70d2d44c",
+ "enableRlsSql": "b7901b3d5231fcfacd3260ce0f59d4701d8c0bee902808ff48b1d8affbd444b6",
"ensureFactsFtsIndex": "95e723314ac30cea2db48e0e167c554ef1fa06df80cae765faa2a080a3a655c2",
"getFtsLanguage": "0d790b4c4af1f67a2a1bbd59470beb13f434917b381931baf8404a41c5d903db",
"grantFromRow": "2d0603bb0f964d7e45e04aa76bac54cd4f6f63c91a8d9f028b60b4792bc1695e",
"hnswMaxDimsForType": "a187cdcc520f813b7c39da97ce53da58509232ed9f851627ef41abfe1b68bd26",
+ "isLockTimeoutError": "52a3720e1ffb74ce381cc3269f78130c38a89c807e308283ec3d557bae2b89b1",
"lockTableForAnalyze": "b6e4f173cffd877d2cfd85af813aa694a6d2c32907eaea613c6879800d3a7b44",
"migrateAutoThinkToPins": "34267fe3b1cc4ab2850ddcf9ba18ce73d959678233a53de238c85231e6b71470",
"migrateConnectorCheckpoints": "5c13e69a334bfc5275c7d555c4e7b28e034569f086dd4bd70b4b78fa4770dc7a",
@@ -67,11 +71,15 @@
"migrationStatementTimeoutMs": "2883be5073d2cd96cc17136e2f7d3223c6bdafebe3ef3c7a6836be320867251d",
"originTwinsRepairCommand": "fb3c721e48d9f2a98845ef91231836d4a37eb5929e9a9b62f8dfab5ce395c462",
"pageSearchVectorTriggerFnSql": "c78074a731ae571c508ca0a84c6bb19ac34a933a7f4ab2068b47124aabb87435",
+ "protectTables": "ca31d41dd1fbc1d0cc4a41855741b55f4ec3d428dc264fb2aaf5cd1592082a14",
"quietMigrationNotices": "4045c32034a8f46204dd5d89e185ff5c35e8073f560f14caa8b127f8a695957c",
"readExistingEmbeddingShape": "16d92d7cd52d8ebd7e89982f02e1bbdd8e8d08a6712a4ce57fbcf0952b7a6ca5",
+ "relationsWithoutRls": "1350afca7865e0a915bfd4c6c2614361705090fca4905f25ac3b38312065c99c",
"repairLegacyClientGrants": "c1dc6b1d0c4933c041583aa1c4eacaefc0ff0ae2a67f56cfad7534f87a5ab309",
"repairLegacyTimelineSourceRows": "405d4ae158482c020b029b93aff1ae4ac6854e6948cafaf82dbef473e6e5552e",
+ "resolveSchemaLockTimeoutMs": "944eadd479e8de6c6da7dfb5208eb3b140e84b318db97a644d08ae0054d69138",
"runMigrationStatement": "84ba969e61fe8e898dd50cf96e1643d237e521e04cd92b5ef43c5d6be75940c1",
+ "schemaLockBlockedError": "c3e1346bc85d4e7592eaa64e262487c87011e4f4fae4c2bcca89b7d818c9a345",
"seedConnectorDispatchAttempts": "2395a3995a6bf78776d37e72ce79b0dd15f6c6fa7f81c40612a744cb74ab01a5",
"slugifyPath": "401dbca23580865d8b168dd8d84db4a6c708c6610d7cb61abafc7d0ee9809063",
"sqlQueryForEngine": "71fb1ccec1b22cdc1662876dbd8c17ed81e9ab83485c6965cdf5caa4fc4a4ab5",
@@ -79,7 +87,7 @@
"verifyProjectionStatistics": "0d231b04ecfbc5a4109d6fca9567bf4e8c9e9db6c3fbbb35212e026579ed6f67",
"withSchemaLockTimeout": "95605bd3004955e11e936c7a4aa6889319b401098abf9db18ef3e48da2c3fc59"
},
- "latest": 274,
+ "latest": 275,
"records": [
{
"handler": {
@@ -4410,6 +4418,33 @@
"transaction": "absent",
"verify": "absent",
"version": 274
+ },
+ {
+ "handler": {
+ "form": "arrow",
+ "helpers": [
+ "EXEMPT_RE",
+ "TABLES",
+ "enableRlsSql",
+ "isLockTimeoutError",
+ "migrationStatementTimeoutMs",
+ "protectTables",
+ "relationsWithoutRls",
+ "resolveSchemaLockTimeoutMs",
+ "schemaLockBlockedError"
+ ],
+ "sha256": "f43f901e13f5306d5dc2736eb4a03691e75eb2608858aca24bf38672e47a5dc1"
+ },
+ "idempotent": true,
+ "name": "rls_backfill_unguarded_tables",
+ "sql": {
+ "length": 0,
+ "sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
+ },
+ "sqlFor": "absent",
+ "transaction": false,
+ "verify": "absent",
+ "version": 275
}
],
"versions": [
@@ -4681,7 +4716,8 @@
271,
272,
273,
- 274
+ 274,
+ 275
]
},
"normalizer": "migrations-record-v1"