@opengeni/db 4.3.2 → 4.3.3-canary.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/dist/canonical-human-identities.js +3 -3
  2. package/dist/{chunk-UVBPOGA7.js → chunk-232VC2LW.js} +2 -2
  3. package/dist/{chunk-DVSLOUEI.js → chunk-2ZMTQVTR.js} +2 -2
  4. package/dist/{chunk-AI4NC6XW.js → chunk-6TKL3GQO.js} +47 -1
  5. package/dist/chunk-6TKL3GQO.js.map +1 -0
  6. package/dist/{chunk-F4BIHJ7J.js → chunk-EYF6MH6C.js} +4 -4
  7. package/dist/{chunk-I4ITNMX2.js → chunk-GVZJ7XSR.js} +16 -4
  8. package/dist/{chunk-I4ITNMX2.js.map → chunk-GVZJ7XSR.js.map} +1 -1
  9. package/dist/{chunk-XBXANJQS.js → chunk-M7PSMVFF.js} +2 -2
  10. package/dist/{chunk-PFBUHOI5.js → chunk-QLA3UQNX.js} +3 -3
  11. package/dist/{chunk-YVYBAWBU.js → chunk-THJGMEK5.js} +53 -1
  12. package/dist/chunk-THJGMEK5.js.map +1 -0
  13. package/dist/{chunk-UUPY6IGP.js → chunk-UK57QA2H.js} +2 -2
  14. package/dist/connection-token-resolver.d.ts +2 -0
  15. package/dist/database.d.ts +7 -2
  16. package/dist/editable-artifact-durable-export.js +2 -2
  17. package/dist/editable-artifacts.js +3 -3
  18. package/dist/host-mcp-bindings.d.ts +3 -1
  19. package/dist/index.d.ts +9 -0
  20. package/dist/index.js +85 -26
  21. package/dist/index.js.map +1 -1
  22. package/dist/managed-auth-session-sets.js +3 -3
  23. package/dist/mcp-operations.d.ts +95 -0
  24. package/dist/mcp-operations.js +95 -0
  25. package/dist/mcp-operations.js.map +1 -0
  26. package/dist/provision-roles.js +1 -1
  27. package/dist/retained-provider-commands.js +2 -2
  28. package/dist/runtime-posture.d.ts +3 -3
  29. package/dist/schema.d.ts +517 -0
  30. package/dist/schema.js +3 -1
  31. package/dist/session-background-commands.js +4 -4
  32. package/dist/session-command-output.js +4 -4
  33. package/dist/session-event-slices.js +2 -2
  34. package/dist/session-tenancy.js +3 -3
  35. package/dist/video-generation.js +3 -3
  36. package/dist/workspace-tool-defaults.js +4 -4
  37. package/drizzle/0459_mcp_operations.sql +396 -0
  38. package/package.json +10 -6
  39. package/src/connection-token-resolver.ts +2 -0
  40. package/src/database.ts +23 -2
  41. package/src/host-mcp-bindings.ts +14 -1
  42. package/src/index.ts +84 -4
  43. package/src/mcp-operations.ts +189 -0
  44. package/src/provision-roles.ts +6 -0
  45. package/src/runtime-posture.ts +50 -0
  46. package/src/schema.ts +46 -0
  47. package/dist/chunk-AI4NC6XW.js.map +0 -1
  48. package/dist/chunk-YVYBAWBU.js.map +0 -1
  49. /package/dist/{chunk-UVBPOGA7.js.map → chunk-232VC2LW.js.map} +0 -0
  50. /package/dist/{chunk-DVSLOUEI.js.map → chunk-2ZMTQVTR.js.map} +0 -0
  51. /package/dist/{chunk-F4BIHJ7J.js.map → chunk-EYF6MH6C.js.map} +0 -0
  52. /package/dist/{chunk-XBXANJQS.js.map → chunk-M7PSMVFF.js.map} +0 -0
  53. /package/dist/{chunk-PFBUHOI5.js.map → chunk-QLA3UQNX.js.map} +0 -0
  54. /package/dist/{chunk-UUPY6IGP.js.map → chunk-UK57QA2H.js.map} +0 -0
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/provision-roles.ts","../src/runtime-posture.ts","../src/role-relationships.ts"],"sourcesContent":["import postgres from \"postgres\";\nimport type { RlsStrategy } from \"./database\";\nimport {\n RUNTIME_FULL_DML_TABLES,\n RUNTIME_READ_INSERT_TABLES,\n RUNTIME_READ_INSERT_UPDATE_TABLES,\n RUNTIME_READ_ONLY_TABLES,\n RUNTIME_READ_UPDATE_TABLES,\n WORK_CLAIM_CAPABILITY_ROUTINES,\n} from \"./runtime-posture\";\nimport {\n classifyRoleRelationships,\n roleRelationshipsCatalogQuery,\n type RoleRelationshipCatalogRow,\n} from \"./role-relationships\";\n\nexport type ProvisionResult = {\n appRole: string | null;\n artifactOutboxDispatcherRole: string | null;\n artifactMaterializerRole: string | null;\n hostExportRole: string | null;\n temporalRole: string | null;\n temporalDatabases: string[];\n schema: string;\n rlsStrategy: RlsStrategy;\n};\n\nexport type ProvisionRolesOptions = {\n /**\n * The schema OpenGeni's tables live in. The app-role GRANTs target this\n * schema + `opengeni_private`. Defaults to `public` (standalone).\n */\n targetSchema?: string;\n /**\n * RLS posture (Step I). `\"force\"` (default) provisions the non-owner\n * `opengeni_app` login role and GRANTs it table DML in the target schema —\n * the role OpenGeni connects as under FORCE-RLS. `\"scoped\"` SKIPS the app-role\n * provisioning entirely: the embedded host runs OpenGeni's queries over a role\n * IT owns/manages (typically the schema owner), so OpenGeni neither creates\n * nor grants the `opengeni_app` role. Temporal-role provisioning is unaffected\n * by strategy.\n */\n rlsStrategy?: RlsStrategy;\n appRole?: string;\n appPassword?: string;\n /** Global, EXECUTE-only artifact live-hint dispatcher capability. */\n artifactOutboxDispatcherRole?: string;\n artifactOutboxDispatcherPassword?: string;\n /** Global, EXECUTE-only artifact materialization worker capability. */\n artifactMaterializerRole?: string;\n artifactMaterializerPassword?: string;\n /**\n * Optional cross-workspace projection role. It receives schema USAGE and\n * EXECUTE only on the host-export API; it receives no table privileges.\n * Provision it after the first migration run so the schema exists. The\n * provisioner also registers same-owner default privileges for future\n * host-export functions; shipped migrations preserve existing exporter ACLs\n * when a migration-only upgrade adds a function.\n */\n hostExportRole?: string;\n hostExportPassword?: string;\n temporalRole?: string;\n temporalPassword?: string;\n temporalDatabases?: string[];\n};\n\n/**\n * SDK entry point (Step I): provision the OpenGeni database roles + grants over\n * a host-supplied admin connection. This is the named, parameterized form of the\n * historical env-driven `provision-roles` script (which still works as a CLI via\n * the `import.meta.main` block at the bottom — it just reads env into these\n * options).\n *\n * STANDALONE (default): `provisionRoles(adminConnection)` with no options →\n * `targetSchema: \"public\"`, `rlsStrategy: \"force\"`, reads `opengeni_app` creds\n * from env. Byte-for-byte the historical script behavior.\n *\n * EMBEDDED: `provisionRoles(adminConnection, { targetSchema, rlsStrategy })` lets\n * a host provision the app role over a dedicated schema (force) OR skip the\n * app role entirely and own the connection role itself (scoped).\n */\nexport async function provisionRoles(\n adminConnection: string,\n options: ProvisionRolesOptions = {},\n): Promise<ProvisionResult> {\n const schema = validateIdentifier(\"targetSchema\", options.targetSchema ?? \"public\");\n const rlsStrategy: RlsStrategy = options.rlsStrategy ?? \"force\";\n\n const appRole = validateIdentifier(\n \"appRole\",\n options.appRole ?? (process.env.OPENGENI_APP_DATABASE_USER?.trim() || \"opengeni_app\"),\n );\n const appPassword = options.appPassword ?? process.env.OPENGENI_APP_DATABASE_PASSWORD;\n const artifactOutboxDispatcherRole = validateIdentifier(\n \"artifactOutboxDispatcherRole\",\n options.artifactOutboxDispatcherRole ??\n (process.env.OPENGENI_ARTIFACT_OUTBOX_DATABASE_USER?.trim() ||\n \"opengeni_artifact_outbox_dispatcher\"),\n );\n const artifactOutboxDispatcherPassword =\n options.artifactOutboxDispatcherPassword ??\n process.env.OPENGENI_ARTIFACT_OUTBOX_DATABASE_PASSWORD;\n const artifactMaterializerRole = validateIdentifier(\n \"artifactMaterializerRole\",\n options.artifactMaterializerRole ??\n (process.env.OPENGENI_ARTIFACT_MATERIALIZER_DATABASE_USER?.trim() ||\n \"opengeni_artifact_materializer\"),\n );\n const artifactMaterializerPassword =\n options.artifactMaterializerPassword ??\n process.env.OPENGENI_ARTIFACT_MATERIALIZER_DATABASE_PASSWORD;\n const hostExportRole = validateIdentifier(\n \"hostExportRole\",\n options.hostExportRole ??\n (process.env.OPENGENI_HOST_EXPORT_DATABASE_USER?.trim() || \"opengeni_host_exporter\"),\n );\n const hostExportPassword =\n options.hostExportPassword ?? process.env.OPENGENI_HOST_EXPORT_DATABASE_PASSWORD;\n const temporalRole = validateIdentifier(\n \"temporalRole\",\n options.temporalRole ??\n (process.env.OPENGENI_TEMPORAL_DATABASE_USER?.trim() || \"opengeni_temporal\"),\n );\n const temporalPassword =\n options.temporalPassword ?? process.env.OPENGENI_TEMPORAL_DATABASE_PASSWORD;\n const temporalDatabases = (\n options.temporalDatabases ??\n commaSeparated(process.env.OPENGENI_TEMPORAL_DATABASES ?? \"temporal,temporal_visibility\")\n ).map((name) => validateIdentifier(\"temporalDatabases\", name));\n\n const sql = postgres(adminConnection, { max: 1 });\n try {\n // FORCE strategy provisions the non-owner app role OpenGeni connects as.\n // SCOPED strategy: the host owns the connection role; OpenGeni provisions no\n // app role (skipped here), only the optional Temporal role.\n let provisionedAppRole: string | null = null;\n if (rlsStrategy === \"force\") {\n if (!appPassword) {\n throw new Error(\n \"OPENGENI_APP_DATABASE_PASSWORD (or appPassword) is required for rlsStrategy 'force'\",\n );\n }\n // Ownership and privilege-bearing role-graph edges cannot be safely\n // guessed away. Refuse to mutate an existing role until an operator has\n // explicitly transferred objects/removed those memberships; role\n // attributes and direct grants, however, are deterministic and are\n // converged below on every run. PostgreSQL 16+'s exact non-runtime-bearing\n // creator-management edge is classified separately.\n await assertAppRoleSafeToNormalize(sql, appRole);\n await ensureRestrictedAppLoginRole(sql, appRole, appPassword);\n provisionedAppRole = appRole;\n }\n\n let provisionedArtifactOutboxDispatcherRole: string | null = null;\n if (artifactOutboxDispatcherPassword) {\n await assertAppRoleSafeToNormalize(sql, artifactOutboxDispatcherRole);\n await ensureRestrictedAppLoginRole(\n sql,\n artifactOutboxDispatcherRole,\n artifactOutboxDispatcherPassword,\n );\n await grantArtifactCapabilityRoleIfSchemaExists(\n sql,\n artifactOutboxDispatcherRole,\n schema,\n \"outbox\",\n );\n provisionedArtifactOutboxDispatcherRole = artifactOutboxDispatcherRole;\n }\n\n let provisionedArtifactMaterializerRole: string | null = null;\n if (artifactMaterializerPassword) {\n await assertAppRoleSafeToNormalize(sql, artifactMaterializerRole);\n await ensureRestrictedAppLoginRole(\n sql,\n artifactMaterializerRole,\n artifactMaterializerPassword,\n );\n await grantArtifactCapabilityRoleIfSchemaExists(\n sql,\n artifactMaterializerRole,\n schema,\n \"materializer\",\n );\n provisionedArtifactMaterializerRole = artifactMaterializerRole;\n }\n\n if (temporalPassword) {\n await ensureLoginRole(sql, temporalRole, temporalPassword);\n for (const database of temporalDatabases) {\n await ensureDatabase(sql, database, temporalRole);\n await grantTemporalRoleInDatabase(adminConnection, database, temporalRole);\n }\n }\n\n if (hostExportPassword) {\n await ensureLoginRole(sql, hostExportRole, hostExportPassword);\n await grantHostExportRoleIfSchemaExists(sql, hostExportRole);\n }\n\n if (rlsStrategy === \"force\") {\n await grantAppRoleIfSchemaExists(sql, appRole, schema);\n }\n\n return {\n appRole: provisionedAppRole,\n artifactOutboxDispatcherRole: provisionedArtifactOutboxDispatcherRole,\n artifactMaterializerRole: provisionedArtifactMaterializerRole,\n hostExportRole: hostExportPassword ? hostExportRole : null,\n temporalRole: temporalPassword ? temporalRole : null,\n temporalDatabases: temporalPassword ? temporalDatabases : [],\n schema,\n rlsStrategy,\n };\n } finally {\n await sql.end();\n }\n}\n\n/**\n * The exporter is intentionally separate from `opengeni_app`: its functions\n * project every workspace into a host-owned sink and therefore cannot be made\n * available to the tenant-scoped application role.\n */\nasync function grantHostExportRoleIfSchemaExists(sql: postgres.Sql, role: string): Promise<void> {\n await sql.unsafe(`\nDO $$\nBEGIN\n IF EXISTS (SELECT 1 FROM pg_namespace WHERE nspname = 'opengeni_host_export') THEN\n EXECUTE format('GRANT USAGE ON SCHEMA opengeni_host_export TO %I', ${literal(role)});\n EXECUTE format('GRANT EXECUTE ON ALL FUNCTIONS IN SCHEMA opengeni_host_export TO %I', ${literal(role)});\n EXECUTE format('ALTER DEFAULT PRIVILEGES IN SCHEMA opengeni_host_export GRANT EXECUTE ON FUNCTIONS TO %I', ${literal(role)});\n END IF;\nEND $$;\n`);\n}\n\nasync function grantArtifactCapabilityRoleIfSchemaExists(\n sql: postgres.Sql,\n role: string,\n dataSchema: string,\n capability: \"outbox\" | \"materializer\",\n): Promise<void> {\n const routines =\n capability === \"outbox\"\n ? [\n \"claim_editable_artifact_live_outbox(text,integer,integer,name)\",\n \"mark_editable_artifact_live_outbox_published(text,text,integer,name)\",\n \"renew_editable_artifact_live_outbox(text,text,integer,integer,name)\",\n \"retry_editable_artifact_live_outbox(text,text,integer,integer,text,name)\",\n \"dead_letter_editable_artifact_live_outbox(text,text,integer,text,name)\",\n \"release_editable_artifact_live_outbox(text,text,integer,name)\",\n ]\n : [\n \"claim_editable_artifact_materializations(text,integer,integer,name)\",\n \"renew_editable_artifact_materialization(uuid,uuid,text,text,text,integer,integer,name)\",\n \"succeed_editable_artifact_materialization(uuid,uuid,text,text,text,integer,text,text,text,bigint,text,text,timestamp with time zone,name)\",\n \"fail_editable_artifact_materialization(uuid,uuid,text,text,text,integer,text,name)\",\n ];\n const routineArray = `ARRAY[${routines.map(literal).join(\", \")}]`;\n await sql.unsafe(`\nDO $$\nDECLARE routine_signature text;\nBEGIN\n IF EXISTS (SELECT 1 FROM pg_namespace WHERE nspname = ${literal(dataSchema)})\n AND EXISTS (SELECT 1 FROM pg_namespace WHERE nspname = 'opengeni_private')\n THEN\n EXECUTE format('GRANT CONNECT ON DATABASE %I TO %I', current_database(), ${literal(role)});\n EXECUTE format('GRANT USAGE ON SCHEMA %I TO %I', ${literal(dataSchema)}, ${literal(role)});\n EXECUTE format('GRANT USAGE ON SCHEMA opengeni_private TO %I', ${literal(role)});\n EXECUTE format(\n 'REVOKE ALL PRIVILEGES ON ALL TABLES IN SCHEMA %I FROM %I',\n ${literal(dataSchema)}, ${literal(role)}\n );\n EXECUTE format(\n 'REVOKE ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA %I FROM %I',\n ${literal(dataSchema)}, ${literal(role)}\n );\n EXECUTE format(\n 'REVOKE ALL PRIVILEGES ON ALL FUNCTIONS IN SCHEMA opengeni_private FROM %I',\n ${literal(role)}\n );\n FOREACH routine_signature IN ARRAY ${routineArray} LOOP\n IF to_regprocedure('opengeni_private.' || routine_signature) IS NOT NULL THEN\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION opengeni_private.%s TO %I',\n routine_signature, ${literal(role)}\n );\n END IF;\n END LOOP;\n END IF;\nEND $$;\n`);\n}\n\nasync function ensureLoginRole(sql: postgres.Sql, role: string, password: string): Promise<void> {\n await executeRoleConvergence(\n sql,\n `\nDO $$\nBEGIN\n IF NOT EXISTS (SELECT 1 FROM pg_roles WHERE rolname = ${literal(role)}) THEN\n EXECUTE format('CREATE ROLE %I LOGIN PASSWORD %L', ${literal(role)}, ${literal(password)});\n ELSE\n EXECUTE format('ALTER ROLE %I LOGIN PASSWORD %L', ${literal(role)}, ${literal(password)});\n END IF;\nEND $$;\n`,\n );\n}\n\nasync function ensureRestrictedAppLoginRole(\n sql: postgres.Sql,\n role: string,\n password: string,\n): Promise<void> {\n await executeRoleConvergence(\n sql,\n `\nDO $$\nBEGIN\n IF NOT EXISTS (SELECT 1 FROM pg_roles WHERE rolname = ${literal(role)}) THEN\n EXECUTE format(\n 'CREATE ROLE %I WITH LOGIN NOSUPERUSER NOBYPASSRLS NOCREATEROLE NOCREATEDB NOREPLICATION NOINHERIT PASSWORD %L',\n ${literal(role)},\n ${literal(password)}\n );\n ELSIF EXISTS (SELECT 1 FROM pg_roles WHERE rolname = current_user AND rolsuper) THEN\n EXECUTE format(\n 'ALTER ROLE %I WITH LOGIN NOSUPERUSER NOBYPASSRLS NOCREATEROLE NOCREATEDB NOREPLICATION NOINHERIT PASSWORD %L',\n ${literal(role)},\n ${literal(password)}\n );\n ELSE\n -- PostgreSQL requires elevated attributes merely to name SUPERUSER,\n -- BYPASSRLS, REPLICATION, or CREATEDB in ALTER ROLE, even when setting them\n -- false. The preflight has already proved those protected attributes are\n -- false, so a managed CREATEROLE administrator converges only the\n -- attributes it may change.\n EXECUTE format(\n 'ALTER ROLE %I WITH LOGIN NOCREATEROLE NOINHERIT PASSWORD %L',\n ${literal(role)},\n ${literal(password)}\n );\n END IF;\nEND $$;\n`,\n );\n}\n\nconst ROLE_CONVERGENCE_MAX_ATTEMPTS = 20;\n\nfunction isRetryableConcurrentRoleMutation(error: unknown): boolean {\n const details = error as { code?: unknown; message?: unknown; routine?: unknown };\n return (\n (details.code === \"XX000\" &&\n details.message === \"tuple concurrently updated\" &&\n details.routine === \"simple_heap_update\") ||\n (details.code === \"42710\" &&\n typeof details.message === \"string\" &&\n /^role \".+\" already exists$/u.test(details.message))\n );\n}\n\nasync function executeRoleConvergence(sql: postgres.Sql, statement: string): Promise<void> {\n // Roles live in a cluster-global catalog. Two otherwise independent\n // databases can therefore race an identical CREATE/ALTER during parallel\n // deployment or test setup. PostgreSQL exposes no cross-database advisory\n // lock, so retry only its exact concurrent-catalog outcomes and keep every\n // other provisioning failure immediate.\n for (let attempt = 1; attempt <= ROLE_CONVERGENCE_MAX_ATTEMPTS; attempt += 1) {\n try {\n await sql.unsafe(statement);\n return;\n } catch (error) {\n if (!isRetryableConcurrentRoleMutation(error) || attempt === ROLE_CONVERGENCE_MAX_ATTEMPTS) {\n throw error;\n }\n await new Promise((resolve) => setTimeout(resolve, Math.min(25 * attempt, 250)));\n }\n }\n}\n\n/**\n * Fail rather than silently revoking role relationships or transferring owned\n * objects. Those operations have effects outside OpenGeni's runtime grant\n * contract and require an explicit, audited operator decision.\n */\nasync function assertAppRoleSafeToNormalize(sql: postgres.Sql, role: string): Promise<void> {\n const exists = await sql<{ exists: boolean }[]>`\n select exists(select 1 from pg_roles where rolname = ${role}) as exists\n `;\n if (!exists[0]?.exists) {\n return;\n }\n\n const [roleAttributes] = await sql<\n {\n administrator_superuser: boolean;\n app_superuser: boolean;\n app_bypass_rls: boolean;\n app_create_database: boolean;\n app_replication: boolean;\n }[]\n >`\n select\n administrator.rolsuper as administrator_superuser,\n app.rolsuper as app_superuser,\n app.rolbypassrls as app_bypass_rls,\n app.rolcreatedb as app_create_database,\n app.rolreplication as app_replication\n from pg_roles app\n join pg_roles administrator on administrator.rolname = current_user\n where app.rolname = ${role}\n `;\n if (roleAttributes && !roleAttributes.administrator_superuser) {\n const protectedAttributes = [\n roleAttributes.app_superuser ? \"SUPERUSER\" : null,\n roleAttributes.app_bypass_rls ? \"BYPASSRLS\" : null,\n roleAttributes.app_create_database ? \"CREATEDB\" : null,\n roleAttributes.app_replication ? \"REPLICATION\" : null,\n ].filter((attribute): attribute is string => attribute !== null);\n if (protectedAttributes.length > 0) {\n throw new Error(\n `Refusing to normalize app role ${role}: a non-superuser administrator cannot clear protected attributes (${protectedAttributes.join(\", \")})`,\n );\n }\n }\n\n const relationshipRows = await sql.unsafe<RoleRelationshipCatalogRow[]>(\n roleRelationshipsCatalogQuery(\"$1\"),\n [role],\n );\n const { unsafeRelationships } = classifyRoleRelationships(relationshipRows);\n if (unsafeRelationships.length > 0) {\n throw new Error(\n `Refusing to normalize app role ${role}: remove privilege-bearing role relationships first (${unsafeRelationships.join(\", \")})`,\n );\n }\n\n const ownedObjects = await sql<{ object_name: string }[]>`\n select ('database:' || d.datname)::text as object_name\n from pg_database d\n join pg_roles owner on owner.oid = d.datdba\n where owner.rolname = ${role}\n union all\n select ('schema:' || n.nspname)::text as object_name\n from pg_namespace n\n join pg_roles owner on owner.oid = n.nspowner\n where owner.rolname = ${role}\n and n.nspname <> 'information_schema'\n and n.nspname !~ '^pg_'\n union all\n select ('relation:' || n.nspname || '.' || c.relname)::text as object_name\n from pg_class c\n join pg_namespace n on n.oid = c.relnamespace\n join pg_roles owner on owner.oid = c.relowner\n where owner.rolname = ${role}\n and n.nspname <> 'information_schema'\n and n.nspname !~ '^pg_'\n union all\n select (\n 'routine:' || n.nspname || '.' || p.proname || '(' ||\n pg_get_function_identity_arguments(p.oid) || ')'\n )::text as object_name\n from pg_proc p\n join pg_namespace n on n.oid = p.pronamespace\n join pg_roles owner on owner.oid = p.proowner\n where owner.rolname = ${role}\n and n.nspname <> 'information_schema'\n and n.nspname !~ '^pg_'\n order by object_name\n `;\n if (ownedObjects.length > 0) {\n throw new Error(\n `Refusing to normalize app role ${role}: transfer owned objects first (${ownedObjects\n .map((row) => row.object_name)\n .join(\", \")})`,\n );\n }\n}\n\nasync function ensureDatabase(sql: postgres.Sql, database: string, owner: string): Promise<void> {\n const existing = await sql<{ exists: boolean }[]>`\n select exists(select 1 from pg_database where datname = ${database}) as exists\n `;\n if (!existing[0]?.exists) {\n await sql.unsafe(`CREATE DATABASE ${identifier(database)} OWNER ${identifier(owner)}`);\n }\n await sql.unsafe(\n `GRANT ALL PRIVILEGES ON DATABASE ${identifier(database)} TO ${identifier(owner)}`,\n );\n}\n\nasync function grantTemporalRoleInDatabase(\n adminConnection: string,\n database: string,\n role: string,\n): Promise<void> {\n const databaseUrl = databaseUrlFor(adminConnection, database);\n const databaseSql = postgres(databaseUrl, { max: 1 });\n try {\n await databaseSql.unsafe(`GRANT USAGE, CREATE ON SCHEMA public TO ${identifier(role)}`);\n } finally {\n await databaseSql.end();\n }\n}\n\n/**\n * Grant the app role table DML in the OpenGeni data schema + EXECUTE on the\n * `opengeni_private` helper functions. Schema-parameterized (Step I): standalone\n * passes `public`; embedded passes the dedicated schema. The grants are guarded\n * on schema existence so provisioning before migrate is a safe no-op.\n */\nasync function grantAppRoleIfSchemaExists(\n sql: postgres.Sql,\n role: string,\n schema: string,\n): Promise<void> {\n const runtimeFullDmlTables = `ARRAY[${RUNTIME_FULL_DML_TABLES.map(literal).join(\", \")}]`;\n const runtimeReadOnlyTables = `ARRAY[${RUNTIME_READ_ONLY_TABLES.map(literal).join(\", \")}]`;\n const runtimeReadUpdateTables = `ARRAY[${RUNTIME_READ_UPDATE_TABLES.map(literal).join(\", \")}]`;\n const runtimeReadInsertTables = `ARRAY[${RUNTIME_READ_INSERT_TABLES.map(literal).join(\", \")}]`;\n const runtimeReadInsertUpdateTables = `ARRAY[${RUNTIME_READ_INSERT_UPDATE_TABLES.map(literal).join(\", \")}]`;\n const workClaimCapabilityRoutines = `ARRAY[${WORK_CLAIM_CAPABILITY_ROUTINES.map(literal).join(\", \")}]`;\n const organizationMembershipLifecycleRoutines = `ARRAY[${[\n \"ensure_external_identity(uuid,text,text)\",\n \"get_external_identity_link_reference(uuid,uuid,text)\",\n \"get_external_identity_link_inventory_references(uuid,uuid[])\",\n \"list_self_organization_memberships(text)\",\n \"list_self_organization_invitations(text)\",\n \"list_self_organization_invitations(text,uuid,integer)\",\n \"get_self_organization_invitation(text,uuid)\",\n \"list_organization_members(uuid,text)\",\n \"list_organization_administration_members(uuid,text)\",\n \"list_organization_invitations(uuid,text,uuid,integer)\",\n \"get_organization_administration_overview(uuid,text)\",\n \"get_workspace_kind(uuid,uuid)\",\n \"resolve_workspace_codex_subscription_source(uuid,uuid)\",\n \"list_organization_workspace_ids(uuid)\",\n \"list_organization_codex_workspace_ids(uuid)\",\n \"organization_workspace_command(jsonb)\",\n \"authorize_organization_shared_workspace_administration(uuid,uuid,text)\",\n \"resolve_organization_workspace_removal_subject(uuid,text,uuid)\",\n \"prepare_organization_workspace_member_removal(jsonb)\",\n \"record_organization_workspace_member_removal(jsonb,uuid,uuid)\",\n \"create_additional_managed_organization(text,text,text,text,uuid)\",\n \"create_managed_organization(text,text,text,uuid)\",\n \"assert_organization_shared_workspace_administrator(uuid,uuid,text)\",\n \"open_organization_shared_workspace_administration_capability(uuid,uuid,text)\",\n \"close_organization_shared_workspace_administration_capability(uuid)\",\n \"create_organization_shared_workspace(uuid,text,text,text,text,uuid)\",\n \"upsert_organization_shared_workspace_member(uuid,uuid,text,uuid,text,text,jsonb,boolean)\",\n \"update_organization_name(uuid,text,text,timestamptz,uuid)\",\n \"create_organization_invitation_v2(jsonb)\",\n \"bind_pending_organization_invitations_for_verified_email(text,text)\",\n \"has_pending_organization_invitation_for_subject(text)\",\n \"accept_organization_invitation_v2(jsonb)\",\n \"complete_self_service_organization_setup(jsonb)\",\n \"ensure_organization_user_setup_intent(jsonb)\",\n \"claim_organization_user_setup_delivery(jsonb)\",\n \"claim_organization_user_setup_delivery_v2(jsonb)\",\n \"prepare_organization_user_setup_delivery(jsonb)\",\n \"prepare_organization_user_setup_delivery_v2(jsonb)\",\n \"settle_organization_user_setup_delivery(jsonb)\",\n \"preview_organization_user_setup(text)\",\n \"get_organization_invitation_for_administration(uuid,text,uuid)\",\n \"preflight_organization_user_setup(text)\",\n \"complete_organization_user_setup(jsonb)\",\n \"organization_membership_command(jsonb)\",\n \"prepare_organization_membership_protocol_settlements(jsonb)\",\n \"assert_active_managed_human_organization_membership(uuid,text)\",\n \"resolve_workspace_writer_grant_identity(uuid,text)\",\n \"prepare_workspace_membership_removal_settlements(jsonb)\",\n \"workspace_membership_removal_command(jsonb)\",\n \"get_organization_retention_policy(uuid,text)\",\n \"preview_organization_retention_deletions(uuid,integer)\",\n \"claim_organization_retention_deletion(uuid,uuid,uuid[])\",\n \"list_organization_retention_deletion_objects(uuid,uuid,uuid,text,integer)\",\n \"record_organization_retention_object_deleted(uuid,uuid,uuid,text,text,text,text)\",\n \"fail_organization_retention_deletion(uuid,uuid,uuid,text)\",\n \"finalize_organization_retention_deletion(uuid,uuid,uuid,text)\",\n \"complete_organization_retention_deletion(uuid,uuid,uuid,text)\",\n ]\n .map(literal)\n .join(\", \")}]`;\n const managedAuthSessionSetRoutines = `ARRAY[${[\n \"get_canonical_human_exact_login_binding(text,text)\",\n \"managed_auth_session_set_authority_state(text)\",\n \"managed_auth_session_set_snapshot(text,text,boolean,boolean,boolean)\",\n \"managed_auth_session_set_bootstrap(text,text,text,text,uuid,text,bigint,bigint)\",\n \"managed_auth_session_set_begin_transaction(text,text,text,uuid,text,bigint,uuid,bigint,text,text,uuid,uuid,text,timestamp with time zone)\",\n \"managed_auth_session_set_complete_transaction(text,text,uuid,text,bigint,bigint,uuid,text,text,text)\",\n \"managed_auth_session_set_mutate(text,text,uuid,text,bigint,bigint,text,uuid,uuid,uuid,text,text)\",\n \"managed_auth_actor_mutation_fence(text,bigint,uuid)\",\n \"managed_auth_actor_mutation_lease_acquire(text,bigint,uuid,integer)\",\n \"managed_auth_actor_mutation_lease_release(text,uuid)\",\n \"managed_auth_actor_mutation_lease_validate(text,bigint,uuid)\",\n \"managed_auth_adopted_session_snapshot(text)\",\n \"managed_auth_isolated_session_reap(integer)\",\n \"managed_auth_expired_session_set_reap(integer)\",\n \"managed_auth_session_set_operation_receipt(text,uuid,text,text)\",\n ]\n .map(literal)\n .join(\", \")}]`;\n const organizationRecoveryRoutines = `ARRAY[${[\n \"get_organization_recovery_overview(uuid,text,jsonb,text,text)\",\n \"organization_recovery_command(jsonb)\",\n ]\n .map(literal)\n .join(\", \")}]`;\n await sql.unsafe(`\nDO $$\nDECLARE\n owner_role text := current_user;\n runtime_table text;\n routine_signature text;\nBEGIN\n EXECUTE format('REVOKE CREATE ON DATABASE %I FROM %I', current_database(), ${literal(role)});\n IF EXISTS (SELECT 1 FROM pg_namespace WHERE nspname = ${literal(schema)}) THEN\n EXECUTE format('GRANT USAGE ON SCHEMA %I TO %I', ${literal(schema)}, ${literal(role)});\n EXECUTE format('REVOKE CREATE ON SCHEMA %I FROM %I', ${literal(schema)}, ${literal(role)});\n EXECUTE format('REVOKE ALL PRIVILEGES ON ALL TABLES IN SCHEMA %I FROM %I', ${literal(schema)}, ${literal(role)});\n FOREACH runtime_table IN ARRAY ${runtimeFullDmlTables} LOOP\n IF to_regclass(format('%I.%I', ${literal(schema)}, runtime_table)) IS NOT NULL THEN\n EXECUTE format(\n 'GRANT SELECT, INSERT, UPDATE, DELETE ON TABLE %I.%I TO %I',\n ${literal(schema)},\n runtime_table,\n ${literal(role)}\n );\n END IF;\n END LOOP;\n FOREACH runtime_table IN ARRAY ${runtimeReadOnlyTables} LOOP\n IF to_regclass(format('%I.%I', ${literal(schema)}, runtime_table)) IS NOT NULL THEN\n EXECUTE format(\n 'GRANT SELECT ON TABLE %I.%I TO %I',\n ${literal(schema)},\n runtime_table,\n ${literal(role)}\n );\n END IF;\n END LOOP;\n FOREACH runtime_table IN ARRAY ${runtimeReadUpdateTables} LOOP\n IF to_regclass(format('%I.%I', ${literal(schema)}, runtime_table)) IS NOT NULL THEN\n EXECUTE format(\n 'GRANT SELECT, UPDATE ON TABLE %I.%I TO %I',\n ${literal(schema)},\n runtime_table,\n ${literal(role)}\n );\n END IF;\n END LOOP;\n FOREACH runtime_table IN ARRAY ${runtimeReadInsertTables} LOOP\n IF to_regclass(format('%I.%I', ${literal(schema)}, runtime_table)) IS NOT NULL THEN\n EXECUTE format(\n 'GRANT SELECT, INSERT ON TABLE %I.%I TO %I',\n ${literal(schema)},\n runtime_table,\n ${literal(role)}\n );\n END IF;\n END LOOP;\n FOREACH runtime_table IN ARRAY ${runtimeReadInsertUpdateTables} LOOP\n IF to_regclass(format('%I.%I', ${literal(schema)}, runtime_table)) IS NOT NULL THEN\n EXECUTE format(\n 'GRANT SELECT, INSERT, UPDATE ON TABLE %I.%I TO %I',\n ${literal(schema)},\n runtime_table,\n ${literal(role)}\n );\n END IF;\n END LOOP;\n -- Migration 0301 creates this target-schema capability before\n -- opengeni_app exists on a fresh migrate-then-provision installation. Its\n -- policy is evaluated for ordinary session-list snapshot writes, so the\n -- runtime role must be able to execute the predicate even when no\n -- visibility-transition capability is active. Re-converge the exact ACL\n -- here and keep PUBLIC revoked.\n IF to_regprocedure(\n format('%I.session_visibility_lifecycle_capability_held()', ${literal(schema)})\n ) IS NOT NULL THEN\n EXECUTE format(\n 'REVOKE ALL ON FUNCTION %I.session_visibility_lifecycle_capability_held() FROM PUBLIC',\n ${literal(schema)}\n );\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION %I.session_visibility_lifecycle_capability_held() TO %I',\n ${literal(schema)},\n ${literal(role)}\n );\n END IF;\n -- Migration 0300's tenancy backfill ledger seam has the same shape: its\n -- own conditional GRANT block is skipped whenever opengeni_app does not\n -- yet exist, and these three live in the data schema rather than\n -- opengeni_private, so the blanket sweep above never reaches them.\n -- Re-converge them here so migrate-then-provision matches the reverse\n -- order; without this the \"only write path\" seam is unreachable on a\n -- green-field database.\n FOR routine_signature IN\n SELECT unnest(ARRAY[\n 'open_tenancy_backfill_receipt(uuid, text, text)',\n 'record_tenancy_backfill_unresolved(uuid, uuid, text)',\n 'complete_tenancy_backfill_receipt(uuid, bigint, bigint, text)'\n ])\n LOOP\n IF to_regprocedure(format('%I.%s', ${literal(schema)}, routine_signature))\n IS NOT NULL\n THEN\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION %I.%s TO %I',\n ${literal(schema)},\n routine_signature,\n ${literal(role)}\n );\n END IF;\n END LOOP;\n -- Migration 0291's classification assertion seam has the same shape: its\n -- own conditional GRANT block is skipped whenever opengeni_app does not yet\n -- exist, and it lives in the data schema rather than opengeni_private, so\n -- the blanket sweep above never reaches it. (Its inner capability predicate\n -- IS in opengeni_private and is covered by that sweep.)\n IF to_regprocedure(\n format(\n '%I.verify_organization_resource_classification(uuid,text)',\n ${literal(schema)}\n )\n ) IS NOT NULL THEN\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION %I.verify_organization_resource_classification(uuid, text) TO %I',\n ${literal(schema)},\n ${literal(role)}\n );\n END IF;\n -- Migration 0297's session ownership seams have the same shape: their own\n -- conditional GRANT block is skipped whenever opengeni_app does not yet\n -- exist, and they live in the data schema rather than opengeni_private, so\n -- the blanket sweep above never reaches them. (Their inner capability\n -- predicate IS in opengeni_private and is covered by that sweep.)\n IF to_regprocedure(\n format(\n '%I.classify_organization_session_ownership(uuid,text)',\n ${literal(schema)}\n )\n ) IS NOT NULL THEN\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION %I.classify_organization_session_ownership(uuid, text) TO %I',\n ${literal(schema)},\n ${literal(role)}\n );\n END IF;\n IF to_regprocedure(\n format(\n '%I.backfill_organization_session_ownership(uuid,integer,boolean,text)',\n ${literal(schema)}\n )\n ) IS NOT NULL THEN\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION %I.backfill_organization_session_ownership(uuid, integer, boolean, text) TO %I',\n ${literal(schema)},\n ${literal(role)}\n );\n END IF;\n -- Migration 0340's bounded connection convergence and repaired parity\n -- seams also live in the data schema. Converge their exact grants for the\n -- supported migrate-then-provision order.\n FOREACH routine_signature IN ARRAY ARRAY[\n 'classify_organization_connection_authority(uuid,text)',\n 'backfill_organization_connection_authority(uuid,integer,boolean)',\n 'inspect_organization_connection_authority_convergence(uuid,integer,uuid)',\n 'check_organization_tenancy_parity(uuid,integer,integer)'\n ] LOOP\n IF to_regprocedure(format('%I.%s', ${literal(schema)}, routine_signature))\n IS NOT NULL\n THEN\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION %I.%s TO %I',\n ${literal(schema)},\n routine_signature,\n ${literal(role)}\n );\n END IF;\n END LOOP;\n IF to_regclass(\n format(\n '%I.connection_authority_convergence_audit_capabilities',\n ${literal(schema)}\n )\n ) IS NOT NULL THEN\n EXECUTE format(\n 'REVOKE ALL PRIVILEGES ON TABLE %I.connection_authority_convergence_audit_capabilities FROM %I',\n ${literal(schema)},\n ${literal(role)}\n );\n END IF;\n -- Migration 0110 creates this target-schema-local SECURITY DEFINER\n -- capability before opengeni_app may exist. Re-converge its exact EXECUTE\n -- grant here so the supported migrate-then-provision order is equivalent to\n -- provisioning the role before that migration.\n IF to_regprocedure(\n format('%I.lock_nested_agent_depth_configuration()', ${literal(schema)})\n ) IS NOT NULL THEN\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION %I.lock_nested_agent_depth_configuration() TO %I',\n ${literal(schema)},\n ${literal(role)}\n );\n END IF;\n IF to_regprocedure(\n format(\n '%I.preference_registry_apply_lifecycle(text,uuid,integer,uuid,uuid,text,uuid,text,text)',\n ${literal(schema)}\n )\n ) IS NOT NULL THEN\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION %I.preference_registry_apply_lifecycle(text, uuid, integer, uuid, uuid, text, uuid, text, text) TO %I',\n ${literal(schema)},\n ${literal(role)}\n );\n END IF;\n IF to_regprocedure(format('%I.skill_apply_lifecycle(uuid,uuid,jsonb,jsonb)', ${literal(schema)})) IS NOT NULL THEN\n EXECUTE format('GRANT EXECUTE ON FUNCTION %I.skill_apply_lifecycle(uuid,uuid,jsonb,jsonb) TO %I', ${literal(schema)}, ${literal(role)});\n EXECUTE format('GRANT EXECUTE ON FUNCTION %I.skill_files_valid(jsonb) TO %I', ${literal(schema)}, ${literal(role)});\n END IF;\n IF to_regprocedure(\n format('%I.preference_registry_lock_heads(uuid[])', ${literal(schema)})\n ) IS NOT NULL THEN\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION %I.preference_registry_lock_heads(uuid[]) TO %I',\n ${literal(schema)},\n ${literal(role)}\n );\n END IF;\n IF to_regprocedure(\n format(\n '%I.knowledge_memory_apply_operation(jsonb,text,text,text,uuid,uuid,uuid,integer)',\n ${literal(schema)}\n )\n ) IS NOT NULL THEN\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION %I.knowledge_memory_apply_operation(jsonb, text, text, text, uuid, uuid, uuid, integer) TO %I',\n ${literal(schema)},\n ${literal(role)}\n );\n END IF;\n IF to_regprocedure(\n format(\n '%I.knowledge_memory_revert_operation(uuid,uuid,text,text,text,uuid,uuid,uuid,integer)',\n ${literal(schema)}\n )\n ) IS NOT NULL THEN\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION %I.knowledge_memory_revert_operation(uuid, uuid, text, text, text, uuid, uuid, uuid, integer) TO %I',\n ${literal(schema)},\n ${literal(role)}\n );\n END IF;\n IF to_regprocedure(\n format(\n '%I.preference_registry_get_or_create_snapshot(uuid,uuid,uuid,uuid,uuid,integer)',\n ${literal(schema)}\n )\n ) IS NOT NULL THEN\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION %I.preference_registry_get_or_create_snapshot(uuid, uuid, uuid, uuid, uuid, integer) TO %I',\n ${literal(schema)},\n ${literal(role)}\n );\n END IF;\n -- Migration 0289 creates this definer accessor before opengeni_app may\n -- exist, so its migration-time GRANT is skipped on the supported\n -- migrate-then-provision order. Re-converge it here.\n IF to_regprocedure(\n format(\n '%I.preference_registry_activation_authority(uuid,uuid[])',\n ${literal(schema)}\n )\n ) IS NOT NULL THEN\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION %I.preference_registry_activation_authority(uuid, uuid[]) TO %I',\n ${literal(schema)},\n ${literal(role)}\n );\n END IF;\n IF to_regprocedure(\n format(\n '%I.preference_registry_create_knowledge_proposal_for_attempt(uuid,uuid,uuid,uuid,uuid,integer,uuid,text,uuid,text,text,text,text,integer,text,jsonb,timestamptz,text)',\n ${literal(schema)}\n )\n ) IS NOT NULL THEN\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION %I.preference_registry_create_knowledge_proposal_for_attempt(uuid, uuid, uuid, uuid, uuid, integer, uuid, text, uuid, text, text, text, text, integer, text, jsonb, timestamptz, text) TO %I',\n ${literal(schema)},\n ${literal(role)}\n );\n END IF;\n IF to_regprocedure(\n format(\n '%I.create_task_note_for_attempt(uuid,uuid,uuid,uuid,uuid,integer,uuid,text,text,integer)',\n ${literal(schema)}\n )\n ) IS NOT NULL THEN\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION %I.create_task_note_for_attempt(uuid, uuid, uuid, uuid, uuid, integer, uuid, text, text, integer) TO %I',\n ${literal(schema)},\n ${literal(role)}\n );\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION %I.archive_task_note_for_attempt(uuid, uuid, uuid, uuid, uuid, integer, uuid, uuid, integer, text) TO %I',\n ${literal(schema)},\n ${literal(role)}\n );\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION %I.list_task_notes_for_attempt(uuid, uuid, uuid, uuid, uuid, integer, boolean, integer) TO %I',\n ${literal(schema)},\n ${literal(role)}\n );\n END IF;\n IF to_regprocedure(\n format(\n '%I.company_brain_context_get_or_create_selection(uuid,uuid,uuid,uuid,uuid,integer)',\n ${literal(schema)}\n )\n ) IS NOT NULL THEN\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION %I.company_brain_context_get_or_create_selection(uuid, uuid, uuid, uuid, uuid, integer) TO %I',\n ${literal(schema)},\n ${literal(role)}\n );\n END IF;\n IF to_regprocedure(\n format(\n '%I.company_brain_inspect_context_receipts(uuid,uuid,text,uuid,timestamptz,uuid,integer)',\n ${literal(schema)}\n )\n ) IS NOT NULL THEN\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION %I.company_brain_inspect_context_receipts(uuid, uuid, text, uuid, timestamptz, uuid, integer) TO %I',\n ${literal(schema)},\n ${literal(role)}\n );\n END IF;\n IF to_regprocedure(\n format(\n '%I.evaluate_governed_learning_proposal(uuid,uuid,uuid,uuid,uuid,integer,uuid,uuid,uuid,uuid,uuid)',\n ${literal(schema)}\n )\n ) IS NOT NULL THEN\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION %I.evaluate_governed_learning_proposal(uuid, uuid, uuid, uuid, uuid, integer, uuid, uuid, uuid, uuid, uuid) TO %I',\n ${literal(schema)},\n ${literal(role)}\n );\n END IF;\n IF to_regprocedure(\n format('%I.activate_governed_learning_decision(uuid,uuid,uuid,uuid)', ${literal(schema)})\n ) IS NOT NULL THEN\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION %I.activate_governed_learning_decision(uuid, uuid, uuid, uuid) TO %I',\n ${literal(schema)},\n ${literal(role)}\n );\n END IF;\n IF to_regprocedure(\n format('%I.activate_human_confirmed_learning_decision(uuid,uuid,uuid,uuid,uuid)', ${literal(schema)})\n ) IS NOT NULL THEN\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION %I.activate_human_confirmed_learning_decision(uuid, uuid, uuid, uuid, uuid) TO %I',\n ${literal(schema)},\n ${literal(role)}\n );\n END IF;\n IF to_regprocedure(\n format('%I.confirm_remember_knowledge_claim(uuid,uuid,uuid,uuid,integer,uuid,uuid,uuid)', ${literal(schema)})\n ) IS NOT NULL THEN\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION %I.confirm_remember_knowledge_claim(uuid, uuid, uuid, uuid, integer, uuid, uuid, uuid) TO %I',\n ${literal(schema)},\n ${literal(role)}\n );\n END IF;\n IF to_regprocedure(\n format('%I.materialize_remember_knowledge_memory(uuid,uuid,uuid)', ${literal(schema)})\n ) IS NOT NULL THEN\n EXECUTE format(\n 'REVOKE ALL ON FUNCTION %I.materialize_remember_knowledge_memory(uuid, uuid, uuid) FROM PUBLIC',\n ${literal(schema)}\n );\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION %I.materialize_remember_knowledge_memory(uuid, uuid, uuid) TO %I',\n ${literal(schema)},\n ${literal(role)}\n );\n END IF;\n IF to_regprocedure(\n format('%I.undo_governed_learning_activation(uuid,uuid,uuid,uuid)', ${literal(schema)})\n ) IS NOT NULL THEN\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION %I.undo_governed_learning_activation(uuid, uuid, uuid, uuid) TO %I',\n ${literal(schema)},\n ${literal(role)}\n );\n END IF;\n IF to_regprocedure(\n format('%I.inspect_governed_learning_decisions(uuid,uuid,text,integer)', ${literal(schema)})\n ) IS NOT NULL THEN\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION %I.inspect_governed_learning_decisions(uuid, uuid, text, integer) TO %I',\n ${literal(schema)},\n ${literal(role)}\n );\n END IF;\n IF to_regprocedure(\n format('%I.inspect_governed_learning_activations(uuid,uuid,text,integer)', ${literal(schema)})\n ) IS NOT NULL THEN\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION %I.inspect_governed_learning_activations(uuid, uuid, text, integer) TO %I',\n ${literal(schema)},\n ${literal(role)}\n );\n END IF;\n IF to_regprocedure(\n format('%I.inspect_governed_learning_activation_undos(uuid,uuid,text,integer)', ${literal(schema)})\n ) IS NOT NULL THEN\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION %I.inspect_governed_learning_activation_undos(uuid, uuid, text, integer) TO %I',\n ${literal(schema)},\n ${literal(role)}\n );\n END IF;\n IF to_regprocedure(\n format(\n '%I.replace_task_note_for_attempt(uuid,uuid,uuid,uuid,uuid,integer,uuid,uuid,uuid,uuid,integer,text,text,integer,text)',\n ${literal(schema)}\n )\n ) IS NOT NULL THEN\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION %I.replace_task_note_for_attempt(uuid, uuid, uuid, uuid, uuid, integer, uuid, uuid, uuid, uuid, integer, text, text, integer, text) TO %I',\n ${literal(schema)},\n ${literal(role)}\n );\n END IF;\n IF to_regprocedure(\n format(\n '%I.resolve_task_note_knowledge_promotion_source(uuid,uuid,uuid,uuid,uuid,integer,uuid,integer,text,text,text)',\n ${literal(schema)}\n )\n ) IS NOT NULL THEN\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION %I.resolve_task_note_knowledge_promotion_source(uuid, uuid, uuid, uuid, uuid, integer, uuid, integer, text, text, text) TO %I',\n ${literal(schema)},\n ${literal(role)}\n );\n END IF;\n -- Migration 0365 creates the advisory work-claim mutation capabilities\n -- before a custom runtime role may exist. Re-converge their exact grants\n -- for migrate-then-provision installs without exposing claim history or\n -- the write-capability ledger to direct runtime DML.\n FOREACH routine_signature IN ARRAY ${workClaimCapabilityRoutines} LOOP\n IF to_regprocedure(format('%I.%s', ${literal(schema)}, routine_signature)) IS NOT NULL THEN\n EXECUTE format(\n 'REVOKE ALL ON FUNCTION %I.%s FROM PUBLIC',\n ${literal(schema)}, routine_signature\n );\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION %I.%s TO %I',\n ${literal(schema)}, routine_signature, ${literal(role)}\n );\n END IF;\n END LOOP;\n IF to_regprocedure(\n format(\n '%I.workspace_instruction_policy_get_or_create_snapshot(uuid,uuid,uuid,uuid,uuid,integer)',\n ${literal(schema)}\n )\n ) IS NOT NULL THEN\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION %I.workspace_instruction_policy_get_or_create_snapshot(uuid, uuid, uuid, uuid, uuid, integer) TO %I',\n ${literal(schema)},\n ${literal(role)}\n );\n END IF;\n IF to_regprocedure(\n format(\n '%I.company_profile_apply_activation(uuid,text,uuid,uuid,uuid,uuid,bigint,text,text,text,text)',\n ${literal(schema)}\n )\n ) IS NOT NULL THEN\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION %I.company_profile_apply_activation(uuid, text, uuid, uuid, uuid, uuid, bigint, text, text, text, text) TO %I',\n ${literal(schema)},\n ${literal(role)}\n );\n END IF;\n IF to_regprocedure(\n format(\n '%I.company_profile_get_or_create_snapshot(uuid,uuid,uuid,uuid,uuid,integer)',\n ${literal(schema)}\n )\n ) IS NOT NULL THEN\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION %I.company_profile_get_or_create_snapshot(uuid, uuid, uuid, uuid, uuid, integer) TO %I',\n ${literal(schema)},\n ${literal(role)}\n );\n END IF;\n IF to_regprocedure(\n format(\n '%I.propose_company_profile_for_attempt(uuid,uuid,uuid,uuid,uuid,integer,uuid,text,text,text)',\n ${literal(schema)}\n )\n ) IS NOT NULL THEN\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION %I.propose_company_profile_for_attempt(uuid, uuid, uuid, uuid, uuid, integer, uuid, text, text, text) TO %I',\n ${literal(schema)},\n ${literal(role)}\n );\n END IF;\n IF to_regprocedure(\n format(\n '%I.propose_company_profile_for_attempt_v2(uuid,uuid,uuid,uuid,uuid,integer,uuid,uuid,text,text,text)',\n ${literal(schema)}\n )\n ) IS NOT NULL THEN\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION %I.propose_company_profile_for_attempt_v2(uuid, uuid, uuid, uuid, uuid, integer, uuid, uuid, text, text, text) TO %I',\n ${literal(schema)},\n ${literal(role)}\n );\n END IF;\n IF to_regprocedure(\n format(\n '%I.confirm_company_profile_for_attempt(uuid,uuid,uuid,uuid,uuid,integer,uuid,uuid,uuid)',\n ${literal(schema)}\n )\n ) IS NOT NULL THEN\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION %I.confirm_company_profile_for_attempt(uuid, uuid, uuid, uuid, uuid, integer, uuid, uuid, uuid) TO %I',\n ${literal(schema)},\n ${literal(role)}\n );\n END IF;\n IF to_regprocedure(\n format('%I.get_company_profile_agent_policy(uuid,uuid,text)', ${literal(schema)})\n ) IS NOT NULL THEN\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION %I.get_company_profile_agent_policy(uuid, uuid, text) TO %I',\n ${literal(schema)},\n ${literal(role)}\n );\n END IF;\n IF to_regprocedure(\n format(\n '%I.update_company_profile_agent_policy(uuid,uuid,text,text,bigint,uuid)',\n ${literal(schema)}\n )\n ) IS NOT NULL THEN\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION %I.update_company_profile_agent_policy(uuid, uuid, text, text, bigint, uuid) TO %I',\n ${literal(schema)},\n ${literal(role)}\n );\n END IF;\n IF to_regprocedure(\n format(\n '%I.workspace_learning_policy_apply_activation(uuid,text,uuid,uuid,uuid,uuid,bigint,text,text,text)',\n ${literal(schema)}\n )\n ) IS NOT NULL THEN\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION %I.workspace_learning_policy_apply_activation(uuid, text, uuid, uuid, uuid, uuid, bigint, text, text, text) TO %I',\n ${literal(schema)},\n ${literal(role)}\n );\n END IF;\n IF to_regprocedure(\n format('%I.workspace_learning_policy_source_overrides_valid(jsonb)', ${literal(schema)})\n ) IS NOT NULL THEN\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION %I.workspace_learning_policy_source_overrides_valid(jsonb) TO %I',\n ${literal(schema)},\n ${literal(role)}\n );\n END IF;\n IF to_regprocedure(\n format('%I.workspace_learning_policy_hash(text,jsonb)', ${literal(schema)})\n ) IS NOT NULL THEN\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION %I.workspace_learning_policy_hash(text, jsonb) TO %I',\n ${literal(schema)},\n ${literal(role)}\n );\n END IF;\n IF to_regprocedure(\n format(\n '%I.workspace_learning_policy_get_or_create_snapshot(uuid,uuid,uuid,uuid,uuid,integer)',\n ${literal(schema)}\n )\n ) IS NOT NULL THEN\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION %I.workspace_learning_policy_get_or_create_snapshot(uuid, uuid, uuid, uuid, uuid, integer) TO %I',\n ${literal(schema)},\n ${literal(role)}\n );\n END IF;\n IF to_regprocedure(\n format(\n '%I.slack_task_policy_update(uuid,text,uuid,uuid,jsonb,uuid,bigint,text,text)',\n ${literal(schema)}\n )\n ) IS NOT NULL THEN\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION %I.slack_task_policy_update(uuid, text, uuid, uuid, jsonb, uuid, bigint, text, text) TO %I',\n ${literal(schema)},\n ${literal(role)}\n );\n END IF;\n IF to_regprocedure(\n format(\n '%I.scoped_knowledge_apply_lifecycle(uuid,text,uuid,text,bigint,text,text,text,text,text,text)',\n ${literal(schema)}\n )\n ) IS NOT NULL THEN\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION %I.scoped_knowledge_apply_lifecycle(uuid, text, uuid, text, bigint, text, text, text, text, text, text) TO %I',\n ${literal(schema)},\n ${literal(role)}\n );\n END IF;\n -- Migration 0197 creates this target-schema-local SECURITY DEFINER lock\n -- before opengeni_app may exist. Re-converge only its exact EXECUTE grant\n -- for the supported migrate-then-provision install order; keep PUBLIC\n -- revoked and do not widen table privileges.\n IF to_regprocedure(\n format(\n '%I.knowledge_source_sync_lock_authority(uuid,uuid,uuid)',\n ${literal(schema)}\n )\n ) IS NOT NULL THEN\n EXECUTE format(\n 'REVOKE ALL ON FUNCTION %I.knowledge_source_sync_lock_authority(uuid, uuid, uuid) FROM PUBLIC',\n ${literal(schema)}\n );\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION %I.knowledge_source_sync_lock_authority(uuid, uuid, uuid) TO %I',\n ${literal(schema)},\n ${literal(role)}\n );\n END IF;\n -- Migration 0243 adds the exact Google Drive object authorization and\n -- safe-citation projections. Re-converge both capabilities for the same\n -- supported migrate-then-provision order without granting direct mutation\n -- of their append-only ACL evidence tables.\n IF to_regprocedure(\n format(\n '%I.google_drive_file_authorized(uuid,uuid,text,uuid)',\n ${literal(schema)}\n )\n ) IS NOT NULL THEN\n EXECUTE format(\n 'REVOKE ALL ON FUNCTION %I.google_drive_file_authorized(uuid, uuid, text, uuid) FROM PUBLIC',\n ${literal(schema)}\n );\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION %I.google_drive_file_authorized(uuid, uuid, text, uuid) TO %I',\n ${literal(schema)},\n ${literal(role)}\n );\n END IF;\n IF to_regprocedure(\n format(\n '%I.google_drive_document_citation(uuid,uuid,text,uuid,uuid)',\n ${literal(schema)}\n )\n ) IS NOT NULL THEN\n EXECUTE format(\n 'REVOKE ALL ON FUNCTION %I.google_drive_document_citation(uuid, uuid, text, uuid, uuid) FROM PUBLIC',\n ${literal(schema)}\n );\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION %I.google_drive_document_citation(uuid, uuid, text, uuid, uuid) TO %I',\n ${literal(schema)},\n ${literal(role)}\n );\n END IF;\n IF to_regprocedure(\n format(\n '%I.ensure_managed_human_personal_workspace(uuid,text,uuid)',\n ${literal(schema)}\n )\n ) IS NOT NULL THEN\n EXECUTE format(\n 'REVOKE ALL ON FUNCTION %I.ensure_managed_human_personal_workspace(uuid, text, uuid) FROM PUBLIC',\n ${literal(schema)}\n );\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION %I.ensure_managed_human_personal_workspace(uuid, text, uuid) TO %I',\n ${literal(schema)},\n ${literal(role)}\n );\n END IF;\n FOREACH routine_signature IN ARRAY ${organizationMembershipLifecycleRoutines} LOOP\n IF to_regprocedure(format('%I.%s', ${literal(schema)}, routine_signature)) IS NOT NULL THEN\n EXECUTE format(\n 'REVOKE ALL ON FUNCTION %I.%s FROM PUBLIC',\n ${literal(schema)}, routine_signature\n );\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION %I.%s TO %I',\n ${literal(schema)}, routine_signature, ${literal(role)}\n );\n END IF;\n END LOOP;\n IF to_regprocedure(format('%I.ensure_canonical_human_identity(text,text)', ${literal(schema)})) IS NOT NULL THEN\n EXECUTE format(\n 'REVOKE ALL ON FUNCTION %I.ensure_canonical_human_identity(text, text) FROM PUBLIC',\n ${literal(schema)}\n );\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION %I.ensure_canonical_human_identity(text, text) TO %I',\n ${literal(schema)},\n ${literal(role)}\n );\n END IF;\n IF to_regprocedure(format('%I.validate_canonical_human_session(text,text,boolean)', ${literal(schema)})) IS NOT NULL THEN\n EXECUTE format(\n 'REVOKE ALL ON FUNCTION %I.validate_canonical_human_session(text, text, boolean) FROM PUBLIC',\n ${literal(schema)}\n );\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION %I.validate_canonical_human_session(text, text, boolean) TO %I',\n ${literal(schema)},\n ${literal(role)}\n );\n END IF;\n IF to_regprocedure(format('%I.get_canonical_human_identity_projection(text)', ${literal(schema)})) IS NOT NULL THEN\n EXECUTE format(\n 'REVOKE ALL ON FUNCTION %I.get_canonical_human_identity_projection(text) FROM PUBLIC',\n ${literal(schema)}\n );\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION %I.get_canonical_human_identity_projection(text) TO %I',\n ${literal(schema)},\n ${literal(role)}\n );\n END IF;\n IF to_regprocedure(format('%I.apply_canonical_human_identity_operation(uuid,text,bigint,text,uuid,text,text,text)', ${literal(schema)})) IS NOT NULL THEN\n EXECUTE format(\n 'REVOKE ALL ON FUNCTION %I.apply_canonical_human_identity_operation(uuid, text, bigint, text, uuid, text, text, text) FROM PUBLIC',\n ${literal(schema)}\n );\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION %I.apply_canonical_human_identity_operation(uuid, text, bigint, text, uuid, text, text, text) TO %I',\n ${literal(schema)},\n ${literal(role)}\n );\n END IF;\n FOREACH routine_signature IN ARRAY ${managedAuthSessionSetRoutines} LOOP\n IF to_regprocedure(format('%I.%s', ${literal(schema)}, routine_signature)) IS NOT NULL THEN\n EXECUTE format(\n 'REVOKE ALL ON FUNCTION %I.%s FROM PUBLIC',\n ${literal(schema)}, routine_signature\n );\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION %I.%s TO %I',\n ${literal(schema)}, routine_signature, ${literal(role)}\n );\n END IF;\n END LOOP;\n FOREACH routine_signature IN ARRAY ${organizationRecoveryRoutines} LOOP\n IF to_regprocedure(format('%I.%s', ${literal(schema)}, routine_signature)) IS NOT NULL THEN\n EXECUTE format(\n 'REVOKE ALL ON FUNCTION %I.%s FROM PUBLIC',\n ${literal(schema)}, routine_signature\n );\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION %I.%s TO %I',\n ${literal(schema)}, routine_signature, ${literal(role)}\n );\n END IF;\n END LOOP;\n -- Migration 0225 creates these target-schema-local session visibility\n -- capabilities before opengeni_app may exist. Re-converge their exact\n -- EXECUTE grants for migrate-then-provision installs without granting\n -- blanket execution on target-schema routines.\n IF to_regprocedure(\n format(\n '%I.session_private_actor_visible(uuid,uuid,uuid,text)',\n ${literal(schema)}\n )\n ) IS NOT NULL THEN\n EXECUTE format(\n 'REVOKE ALL ON FUNCTION %I.session_private_actor_visible(uuid, uuid, uuid, text) FROM PUBLIC',\n ${literal(schema)}\n );\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION %I.session_private_actor_visible(uuid, uuid, uuid, text) TO %I',\n ${literal(schema)},\n ${literal(role)}\n );\n END IF;\n IF to_regprocedure(\n format(\n '%I.session_reference_visible(uuid,uuid,uuid)',\n ${literal(schema)}\n )\n ) IS NOT NULL THEN\n EXECUTE format(\n 'REVOKE ALL ON FUNCTION %I.session_reference_visible(uuid, uuid, uuid) FROM PUBLIC',\n ${literal(schema)}\n );\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION %I.session_reference_visible(uuid, uuid, uuid) TO %I',\n ${literal(schema)},\n ${literal(role)}\n );\n END IF;\n IF to_regprocedure(\n format(\n '%I.transition_session_visibility(uuid,uuid,uuid,text,text,integer,text,text,integer)',\n ${literal(schema)}\n )\n ) IS NOT NULL THEN\n EXECUTE format(\n 'REVOKE ALL ON FUNCTION %I.transition_session_visibility(uuid, uuid, uuid, text, text, integer, text, text, integer) FROM PUBLIC',\n ${literal(schema)}\n );\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION %I.transition_session_visibility(uuid, uuid, uuid, text, text, integer, text, text, integer) TO %I',\n ${literal(schema)},\n ${literal(role)}\n );\n END IF;\n IF to_regprocedure(\n format(\n '%I.fork_session_content(uuid,uuid,uuid,text,uuid,text,text,text,integer)',\n ${literal(schema)}\n )\n ) IS NOT NULL THEN\n EXECUTE format(\n 'REVOKE ALL ON FUNCTION %I.fork_session_content(uuid, uuid, uuid, text, uuid, text, text, text, integer) FROM PUBLIC',\n ${literal(schema)}\n );\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION %I.fork_session_content(uuid, uuid, uuid, text, uuid, text, text, text, integer) TO %I',\n ${literal(schema)},\n ${literal(role)}\n );\n END IF;\n IF to_regprocedure(\n format(\n '%I.fork_session_content(uuid,uuid,uuid,text,uuid,text,boolean,text,text,integer)',\n ${literal(schema)}\n )\n ) IS NOT NULL THEN\n EXECUTE format(\n 'REVOKE ALL ON FUNCTION %I.fork_session_content(uuid, uuid, uuid, text, uuid, text, boolean, text, text, integer) FROM PUBLIC',\n ${literal(schema)}\n );\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION %I.fork_session_content(uuid, uuid, uuid, text, uuid, text, boolean, text, text, integer) TO %I',\n ${literal(schema)},\n ${literal(role)}\n );\n END IF;\n IF to_regprocedure(\n format(\n '%I.fork_session_content(uuid,uuid,uuid,text,uuid,text,boolean,text,text,integer,uuid)',\n ${literal(schema)}\n )\n ) IS NOT NULL THEN\n EXECUTE format(\n 'REVOKE ALL ON FUNCTION %I.fork_session_content(uuid, uuid, uuid, text, uuid, text, boolean, text, text, integer, uuid) FROM PUBLIC',\n ${literal(schema)}\n );\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION %I.fork_session_content(uuid, uuid, uuid, text, uuid, text, boolean, text, text, integer, uuid) TO %I',\n ${literal(schema)},\n ${literal(role)}\n );\n END IF;\n IF to_regprocedure(\n format(\n '%I.replay_applied_session_fork(uuid,uuid,uuid,text,uuid,text,boolean,text,text,integer)',\n ${literal(schema)}\n )\n ) IS NOT NULL THEN\n EXECUTE format(\n 'REVOKE ALL ON FUNCTION %I.replay_applied_session_fork(uuid, uuid, uuid, text, uuid, text, boolean, text, text, integer) FROM PUBLIC',\n ${literal(schema)}\n );\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION %I.replay_applied_session_fork(uuid, uuid, uuid, text, uuid, text, boolean, text, text, integer) TO %I',\n ${literal(schema)},\n ${literal(role)}\n );\n END IF;\n IF to_regprocedure(\n format(\n '%I.fork_session_content_with_runtime(uuid,uuid,uuid,text,uuid,text,boolean,text,text,integer,jsonb,uuid,uuid,text)',\n ${literal(schema)}\n )\n ) IS NOT NULL THEN\n EXECUTE format(\n 'REVOKE ALL ON FUNCTION %I.fork_session_content_with_runtime(uuid, uuid, uuid, text, uuid, text, boolean, text, text, integer, jsonb, uuid, uuid, text) FROM PUBLIC',\n ${literal(schema)}\n );\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION %I.fork_session_content_with_runtime(uuid, uuid, uuid, text, uuid, text, boolean, text, text, integer, jsonb, uuid, uuid, text) TO %I',\n ${literal(schema)},\n ${literal(role)}\n );\n END IF;\n IF to_regprocedure(\n format(\n '%I.replay_applied_session_fork_with_runtime(uuid,uuid,uuid,text,uuid,text,boolean,text,text,integer,text)',\n ${literal(schema)}\n )\n ) IS NOT NULL THEN\n EXECUTE format(\n 'REVOKE ALL ON FUNCTION %I.replay_applied_session_fork_with_runtime(uuid, uuid, uuid, text, uuid, text, boolean, text, text, integer, text) FROM PUBLIC',\n ${literal(schema)}\n );\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION %I.replay_applied_session_fork_with_runtime(uuid, uuid, uuid, text, uuid, text, boolean, text, text, integer, text) TO %I',\n ${literal(schema)},\n ${literal(role)}\n );\n END IF;\n IF to_regprocedure(\n format('%I.session_tenancy_product_activated(uuid,integer)', ${literal(schema)})\n ) IS NOT NULL THEN\n EXECUTE format(\n 'REVOKE ALL ON FUNCTION %I.session_tenancy_product_activated(uuid, integer) FROM PUBLIC',\n ${literal(schema)}\n );\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION %I.session_tenancy_product_activated(uuid, integer) TO %I',\n ${literal(schema)},\n ${literal(role)}\n );\n EXECUTE format(\n 'REVOKE ALL ON FUNCTION %I.session_tenancy_any_product_activation() FROM PUBLIC',\n ${literal(schema)}\n );\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION %I.session_tenancy_any_product_activation() TO %I',\n ${literal(schema)},\n ${literal(role)}\n );\n EXECUTE format(\n 'REVOKE ALL ON FUNCTION %I.assert_session_tenancy_quiescent(uuid, uuid, uuid, boolean) FROM PUBLIC',\n ${literal(schema)}\n );\n EXECUTE format(\n 'REVOKE ALL ON FUNCTION %I.assert_session_tenancy_quiescent(uuid, uuid, uuid, boolean) FROM %I',\n ${literal(schema)},\n ${literal(role)}\n );\n END IF;\n IF to_regprocedure(\n format('%I.get_private_session_create_policy(uuid,uuid,text)', ${literal(schema)})\n ) IS NOT NULL THEN\n EXECUTE format(\n 'REVOKE ALL ON FUNCTION %I.get_private_session_create_policy(uuid, uuid, text) FROM PUBLIC',\n ${literal(schema)}\n );\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION %I.get_private_session_create_policy(uuid, uuid, text) TO %I',\n ${literal(schema)}, ${literal(role)}\n );\n END IF;\n IF to_regprocedure(\n format('%I.get_organization_private_session_settings(uuid,text)', ${literal(schema)})\n ) IS NOT NULL THEN\n EXECUTE format(\n 'REVOKE ALL ON FUNCTION %I.get_organization_private_session_settings(uuid, text) FROM PUBLIC',\n ${literal(schema)}\n );\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION %I.get_organization_private_session_settings(uuid, text) TO %I',\n ${literal(schema)}, ${literal(role)}\n );\n END IF;\n IF to_regprocedure(\n format(\n '%I.update_organization_private_session_settings(uuid,text,boolean,bigint,uuid)',\n ${literal(schema)}\n )\n ) IS NOT NULL THEN\n EXECUTE format(\n 'REVOKE ALL ON FUNCTION %I.update_organization_private_session_settings(uuid, text, boolean, bigint, uuid) FROM PUBLIC',\n ${literal(schema)}\n );\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION %I.update_organization_private_session_settings(uuid, text, boolean, bigint, uuid) TO %I',\n ${literal(schema)}, ${literal(role)}\n );\n END IF;\n IF to_regprocedure(\n format('%I.organization_private_sessions_enabled(uuid)', ${literal(schema)})\n ) IS NOT NULL THEN\n EXECUTE format(\n 'REVOKE ALL ON FUNCTION %I.organization_private_sessions_enabled(uuid) FROM PUBLIC',\n ${literal(schema)}\n );\n EXECUTE format(\n 'REVOKE ALL ON FUNCTION %I.organization_private_sessions_enabled(uuid) FROM %I',\n ${literal(schema)}, ${literal(role)}\n );\n END IF;\n IF to_regprocedure(\n format('%I.open_private_session_create_capability(uuid,uuid,uuid,text)', ${literal(schema)})\n ) IS NOT NULL THEN\n EXECUTE format(\n 'REVOKE ALL ON FUNCTION %I.open_private_session_create_capability(uuid, uuid, uuid, text) FROM PUBLIC',\n ${literal(schema)}\n );\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION %I.open_private_session_create_capability(uuid, uuid, uuid, text) TO %I',\n ${literal(schema)}, ${literal(role)}\n );\n EXECUTE format(\n 'REVOKE ALL ON FUNCTION %I.close_private_session_create_capability(uuid) FROM PUBLIC',\n ${literal(schema)}\n );\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION %I.close_private_session_create_capability(uuid) TO %I',\n ${literal(schema)}, ${literal(role)}\n );\n END IF;\n IF to_regprocedure(\n format(\n '%I.open_private_child_session_create_capability(uuid,uuid,uuid,uuid,uuid,uuid,integer)',\n ${literal(schema)}\n )\n ) IS NOT NULL THEN\n EXECUTE format(\n 'REVOKE ALL ON FUNCTION %I.open_private_child_session_create_capability(uuid,uuid,uuid,uuid,uuid,uuid,integer) FROM PUBLIC',\n ${literal(schema)}\n );\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION %I.open_private_child_session_create_capability(uuid,uuid,uuid,uuid,uuid,uuid,integer) TO %I',\n ${literal(schema)}, ${literal(role)}\n );\n END IF;\n IF to_regprocedure(\n format(\n '%I.create_xai_subscription_credential(uuid,uuid,text,text,text,text,text,text,text,timestamptz)',\n ${literal(schema)}\n )\n ) IS NOT NULL THEN\n EXECUTE format(\n 'REVOKE ALL ON FUNCTION %I.create_xai_subscription_credential(uuid, uuid, text, text, text, text, text, text, text, timestamptz) FROM PUBLIC',\n ${literal(schema)}\n );\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION %I.create_xai_subscription_credential(uuid, uuid, text, text, text, text, text, text, text, timestamptz) TO %I',\n ${literal(schema)},\n ${literal(role)}\n );\n EXECUTE format(\n 'REVOKE ALL ON FUNCTION %I.disconnect_xai_subscription_credential(uuid, uuid, text, uuid, jsonb) FROM PUBLIC',\n ${literal(schema)}\n );\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION %I.disconnect_xai_subscription_credential(uuid, uuid, text, uuid, jsonb) TO %I',\n ${literal(schema)},\n ${literal(role)}\n );\n EXECUTE format(\n 'REVOKE ALL ON FUNCTION %I.resolve_xai_authority_pool(uuid, uuid, text, jsonb) FROM PUBLIC',\n ${literal(schema)}\n );\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION %I.resolve_xai_authority_pool(uuid, uuid, text, jsonb) TO %I',\n ${literal(schema)},\n ${literal(role)}\n );\n EXECUTE format(\n 'REVOKE ALL ON FUNCTION %I.revalidate_xai_subscription_authority(uuid, text, uuid, jsonb) FROM PUBLIC',\n ${literal(schema)}\n );\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION %I.revalidate_xai_subscription_authority(uuid, text, uuid, jsonb) TO %I',\n ${literal(schema)},\n ${literal(role)}\n );\n EXECUTE format(\n 'REVOKE ALL ON FUNCTION %I.xai_provider_account_authority_snapshot_v1_valid(jsonb) FROM PUBLIC',\n ${literal(schema)}\n );\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION %I.xai_provider_account_authority_snapshot_v1_valid(jsonb) TO %I',\n ${literal(schema)},\n ${literal(role)}\n );\n EXECUTE format(\n 'REVOKE ALL ON FUNCTION %I.xai_subscription_authority_live(uuid, uuid, text, uuid, text, uuid, uuid, bigint) FROM PUBLIC',\n ${literal(schema)}\n );\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION %I.xai_subscription_authority_live(uuid, uuid, text, uuid, text, uuid, uuid, bigint) TO %I',\n ${literal(schema)},\n ${literal(role)}\n );\n EXECUTE format(\n 'REVOKE ALL ON FUNCTION %I.xai_subscription_pool_visible(uuid, uuid, text, text, uuid) FROM PUBLIC',\n ${literal(schema)}\n );\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION %I.xai_subscription_pool_visible(uuid, uuid, text, text, uuid) TO %I',\n ${literal(schema)},\n ${literal(role)}\n );\n END IF;\n IF to_regprocedure(\n format(\n '%I.resolve_session_attempt_personal_resources(uuid,uuid,uuid)',\n ${literal(schema)}\n )\n ) IS NOT NULL THEN\n EXECUTE format(\n 'REVOKE ALL ON FUNCTION %I.resolve_session_attempt_personal_resources(uuid, uuid, uuid) FROM PUBLIC',\n ${literal(schema)}\n );\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION %I.resolve_session_attempt_personal_resources(uuid, uuid, uuid) TO %I',\n ${literal(schema)},\n ${literal(role)}\n );\n END IF;\n IF to_regprocedure(\n format(\n '%I.accept_turn_personal_resource_attachment(uuid,uuid,uuid,uuid,text,integer,boolean,integer)',\n ${literal(schema)}\n )\n ) IS NOT NULL THEN\n EXECUTE format(\n 'REVOKE ALL ON FUNCTION %I.accept_turn_personal_resource_attachment(uuid, uuid, uuid, uuid, text, integer, boolean, integer) FROM PUBLIC',\n ${literal(schema)}\n );\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION %I.accept_turn_personal_resource_attachment(uuid, uuid, uuid, uuid, text, integer, boolean, integer) TO %I',\n ${literal(schema)},\n ${literal(role)}\n );\n END IF;\n IF to_regprocedure(format('%I.list_self_user_resource_authorities(uuid,uuid,text,uuid,integer)', ${literal(schema)}))\n IS NOT NULL THEN\n EXECUTE format('REVOKE ALL ON FUNCTION %I.list_self_user_resource_authorities(uuid) FROM PUBLIC', ${literal(schema)});\n EXECUTE format('REVOKE ALL ON FUNCTION %I.list_self_user_resource_authorities(uuid) FROM %I', ${literal(schema)}, ${literal(role)});\n EXECUTE format('REVOKE ALL ON FUNCTION %I.issue_self_user_resource_grant(uuid, uuid, uuid, text, text, text, uuid, boolean) FROM PUBLIC', ${literal(schema)});\n EXECUTE format('REVOKE ALL ON FUNCTION %I.issue_self_user_resource_grant(uuid, uuid, uuid, text, text, text, uuid, boolean) FROM %I', ${literal(schema)}, ${literal(role)});\n EXECUTE format('REVOKE ALL ON FUNCTION %I.revoke_self_user_resource_grant(uuid, uuid) FROM PUBLIC', ${literal(schema)});\n EXECUTE format('REVOKE ALL ON FUNCTION %I.revoke_self_user_resource_grant(uuid, uuid) FROM %I', ${literal(schema)}, ${literal(role)});\n EXECUTE format('REVOKE ALL ON FUNCTION %I.list_self_user_resource_authorities(uuid, uuid, text, uuid, integer) FROM PUBLIC', ${literal(schema)});\n EXECUTE format('GRANT EXECUTE ON FUNCTION %I.list_self_user_resource_authorities(uuid, uuid, text, uuid, integer) TO %I', ${literal(schema)}, ${literal(role)});\n EXECUTE format('REVOKE ALL ON FUNCTION %I.issue_self_user_resource_grant(uuid, uuid, uuid, text, text, text, uuid, integer, boolean) FROM PUBLIC', ${literal(schema)});\n EXECUTE format('GRANT EXECUTE ON FUNCTION %I.issue_self_user_resource_grant(uuid, uuid, uuid, text, text, text, uuid, integer, boolean) TO %I', ${literal(schema)}, ${literal(role)});\n EXECUTE format('REVOKE ALL ON FUNCTION %I.revoke_self_user_resource_grant(uuid, uuid, uuid) FROM PUBLIC', ${literal(schema)});\n EXECUTE format('GRANT EXECUTE ON FUNCTION %I.revoke_self_user_resource_grant(uuid, uuid, uuid) TO %I', ${literal(schema)}, ${literal(role)});\n EXECUTE format('REVOKE ALL ON FUNCTION %I.authorize_session_attempt_personal_resource_reads(uuid, uuid, uuid) FROM PUBLIC', ${literal(schema)});\n EXECUTE format('GRANT EXECUTE ON FUNCTION %I.authorize_session_attempt_personal_resource_reads(uuid, uuid, uuid) TO %I', ${literal(schema)}, ${literal(role)});\n END IF;\n IF to_regprocedure(format('%I.issue_self_local_connection_use_grant(uuid,uuid,uuid,text,boolean)', ${literal(schema)}))\n IS NOT NULL THEN\n EXECUTE format('REVOKE ALL ON FUNCTION %I.issue_self_local_connection_use_grant(uuid, uuid, uuid, text, boolean) FROM PUBLIC', ${literal(schema)});\n EXECUTE format('GRANT EXECUTE ON FUNCTION %I.issue_self_local_connection_use_grant(uuid, uuid, uuid, text, boolean) TO %I', ${literal(schema)}, ${literal(role)});\n END IF;\n IF to_regprocedure(format('%I.resolve_connection_use_authority(uuid,uuid,uuid,jsonb)', ${literal(schema)}))\n IS NOT NULL THEN\n EXECUTE format('REVOKE ALL ON FUNCTION %I.list_self_connection_authorities(uuid) FROM PUBLIC', ${literal(schema)});\n EXECUTE format('REVOKE ALL ON FUNCTION %I.list_self_connection_authorities(uuid) FROM %I', ${literal(schema)}, ${literal(role)});\n EXECUTE format('REVOKE ALL ON FUNCTION %I.issue_self_connection_use_grant(uuid, uuid, uuid, text, text, uuid, boolean) FROM PUBLIC', ${literal(schema)});\n EXECUTE format('REVOKE ALL ON FUNCTION %I.issue_self_connection_use_grant(uuid, uuid, uuid, text, text, uuid, boolean) FROM %I', ${literal(schema)}, ${literal(role)});\n EXECUTE format('REVOKE ALL ON FUNCTION %I.revoke_self_connection_use_grant(uuid, uuid) FROM PUBLIC', ${literal(schema)});\n EXECUTE format('REVOKE ALL ON FUNCTION %I.revoke_self_connection_use_grant(uuid, uuid) FROM %I', ${literal(schema)}, ${literal(role)});\n EXECUTE format('REVOKE ALL ON FUNCTION %I.resolve_connection_use_authority(uuid, uuid, uuid, jsonb) FROM PUBLIC', ${literal(schema)});\n EXECUTE format('GRANT EXECUTE ON FUNCTION %I.resolve_connection_use_authority(uuid, uuid, uuid, jsonb) TO %I', ${literal(schema)}, ${literal(role)});\n IF to_regprocedure(format('%I.resolve_personal_connection_authority_selection(uuid,uuid,text,uuid,jsonb)', ${literal(schema)})) IS NOT NULL THEN\n EXECUTE format('REVOKE ALL ON FUNCTION %I.resolve_personal_connection_authority_selection(uuid, uuid, text, uuid, jsonb) FROM PUBLIC', ${literal(schema)});\n EXECUTE format('GRANT EXECUTE ON FUNCTION %I.resolve_personal_connection_authority_selection(uuid, uuid, text, uuid, jsonb) TO %I', ${literal(schema)}, ${literal(role)});\n END IF;\n IF to_regprocedure(format('%I.resolve_accepted_connection_use(uuid,uuid,uuid,uuid,uuid,integer,uuid,text,text,uuid,text,text,text,text)', ${literal(schema)})) IS NOT NULL THEN\n EXECUTE format('REVOKE ALL ON FUNCTION %I.resolve_accepted_connection_use(uuid, uuid, uuid, uuid, uuid, integer, uuid, text, text, uuid, text, text, text, text) FROM PUBLIC', ${literal(schema)});\n EXECUTE format('GRANT EXECUTE ON FUNCTION %I.resolve_accepted_connection_use(uuid, uuid, uuid, uuid, uuid, integer, uuid, text, text, uuid, text, text, text, text) TO %I', ${literal(schema)}, ${literal(role)});\n END IF;\n END IF;\n IF to_regprocedure(\n format('%I.get_self_personal_github_repository_selection(uuid,uuid,text,uuid)', ${literal(schema)})\n ) IS NOT NULL THEN\n EXECUTE format(\n 'REVOKE ALL ON FUNCTION %I.get_self_personal_github_repository_selection(uuid,uuid,text,uuid) FROM PUBLIC',\n ${literal(schema)}\n );\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION %I.get_self_personal_github_repository_selection(uuid,uuid,text,uuid) TO %I',\n ${literal(schema)}, ${literal(role)}\n );\n EXECUTE format(\n 'REVOKE ALL ON FUNCTION %I.mutate_self_personal_github_repository_selection(uuid,uuid,text,uuid,bigint,bigint,text,jsonb,boolean) FROM PUBLIC',\n ${literal(schema)}\n );\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION %I.mutate_self_personal_github_repository_selection(uuid,uuid,text,uuid,bigint,bigint,text,jsonb,boolean) TO %I',\n ${literal(schema)}, ${literal(role)}\n );\n EXECUTE format(\n 'REVOKE ALL PRIVILEGES ON TABLE %I.personal_github_repository_selection_heads, %I.personal_github_repository_selections, %I.personal_github_repository_selection_operations FROM %I',\n ${literal(schema)}, ${literal(schema)}, ${literal(schema)}, ${literal(role)}\n );\n END IF;\n IF to_regprocedure(\n format('%I.create_personal_document_authority(uuid,uuid,uuid)', ${literal(schema)})\n ) IS NOT NULL THEN\n EXECUTE format('REVOKE ALL ON FUNCTION %I.create_personal_document_authority(uuid, uuid, uuid) FROM PUBLIC', ${literal(schema)});\n EXECUTE format('GRANT EXECUTE ON FUNCTION %I.create_personal_document_authority(uuid, uuid, uuid) TO %I', ${literal(schema)}, ${literal(role)});\n EXECUTE format('REVOKE ALL ON FUNCTION %I.resolve_document_original_file(uuid, uuid, text, uuid) FROM PUBLIC', ${literal(schema)});\n EXECUTE format('GRANT EXECUTE ON FUNCTION %I.resolve_document_original_file(uuid, uuid, text, uuid) TO %I', ${literal(schema)}, ${literal(role)});\n EXECUTE format('REVOKE ALL ON FUNCTION %I.prepare_session_attempt_personal_document_reads(uuid, uuid, uuid, uuid) FROM PUBLIC', ${literal(schema)});\n EXECUTE format('REVOKE ALL ON FUNCTION %I.prepare_session_attempt_personal_document_reads(uuid, uuid, uuid, uuid) FROM %I', ${literal(schema)}, ${literal(role)});\n EXECUTE format('REVOKE ALL ON FUNCTION %I.resolve_session_attempt_personal_document_reads(uuid, uuid, uuid, uuid) FROM PUBLIC', ${literal(schema)});\n EXECUTE format('GRANT EXECUTE ON FUNCTION %I.resolve_session_attempt_personal_document_reads(uuid, uuid, uuid, uuid) TO %I', ${literal(schema)}, ${literal(role)});\n EXECUTE format('REVOKE ALL ON FUNCTION opengeni_private.personal_document_authority_capability_active(text) FROM PUBLIC');\n EXECUTE format('GRANT EXECUTE ON FUNCTION opengeni_private.personal_document_authority_capability_active(text) TO %I', ${literal(role)});\n EXECUTE format('REVOKE ALL PRIVILEGES ON TABLE opengeni_private.personal_document_authority_capabilities FROM %I', ${literal(role)});\n EXECUTE format('REVOKE ALL PRIVILEGES ON TABLE %I.session_attempt_personal_document_admissions FROM %I', ${literal(schema)}, ${literal(role)});\n EXECUTE format('REVOKE ALL PRIVILEGES ON TABLE %I.session_attempt_personal_document_snapshots FROM %I', ${literal(schema)}, ${literal(role)});\n EXECUTE format('REVOKE ALL PRIVILEGES ON TABLE %I.personal_document_once_consumption_receipts FROM %I', ${literal(schema)}, ${literal(role)});\n END IF;\n IF to_regprocedure(\n format('%I.reclassify_document_authority(jsonb)', ${literal(schema)})\n ) IS NOT NULL THEN\n EXECUTE format('REVOKE ALL ON FUNCTION %I.reclassify_document_authority(jsonb) FROM PUBLIC', ${literal(schema)});\n EXECUTE format('GRANT EXECUTE ON FUNCTION %I.reclassify_document_authority(jsonb) TO %I', ${literal(schema)}, ${literal(role)});\n EXECUTE format('REVOKE ALL ON FUNCTION %I.list_document_authority_reclassifications(uuid, uuid, text, uuid, integer, timestamptz, uuid) FROM PUBLIC', ${literal(schema)});\n EXECUTE format('GRANT EXECUTE ON FUNCTION %I.list_document_authority_reclassifications(uuid, uuid, text, uuid, integer, timestamptz, uuid) TO %I', ${literal(schema)}, ${literal(role)});\n EXECUTE format('REVOKE ALL ON FUNCTION %I.run_document_default_collection_backfill(jsonb) FROM PUBLIC', ${literal(schema)});\n EXECUTE format('GRANT EXECUTE ON FUNCTION %I.run_document_default_collection_backfill(jsonb) TO %I', ${literal(schema)}, ${literal(role)});\n EXECUTE format('REVOKE ALL ON FUNCTION opengeni_private.document_migration_capability_active(text) FROM PUBLIC');\n EXECUTE format('GRANT EXECUTE ON FUNCTION opengeni_private.document_migration_capability_active(text) TO %I', ${literal(role)});\n EXECUTE format('REVOKE ALL PRIVILEGES ON TABLE opengeni_private.document_migration_capabilities FROM %I', ${literal(role)});\n EXECUTE format('GRANT SELECT ON TABLE %I.document_authority_reclassifications TO %I', ${literal(schema)}, ${literal(role)});\n EXECUTE format('REVOKE INSERT, UPDATE, DELETE ON TABLE %I.document_authority_reclassifications FROM %I', ${literal(schema)}, ${literal(role)});\n EXECUTE format('REVOKE ALL PRIVILEGES ON TABLE %I.document_default_collection_backfill_runs, %I.document_default_collection_backfill_operations, %I.document_default_collection_backfill_receipts FROM %I', ${literal(schema)}, ${literal(schema)}, ${literal(schema)}, ${literal(role)});\n IF to_regprocedure(\n format('%I.list_document_default_collection_backfill_runs(jsonb)', ${literal(schema)})\n ) IS NOT NULL THEN\n EXECUTE format('REVOKE ALL ON FUNCTION %I.list_document_default_collection_backfill_runs(jsonb) FROM PUBLIC', ${literal(schema)});\n EXECUTE format('GRANT EXECUTE ON FUNCTION %I.list_document_default_collection_backfill_runs(jsonb) TO %I', ${literal(schema)}, ${literal(role)});\n EXECUTE format('REVOKE ALL ON FUNCTION %I.get_document_default_collection_backfill_audit(jsonb) FROM PUBLIC', ${literal(schema)});\n EXECUTE format('GRANT EXECUTE ON FUNCTION %I.get_document_default_collection_backfill_audit(jsonb) TO %I', ${literal(schema)}, ${literal(role)});\n EXECUTE format('REVOKE ALL ON FUNCTION %I.list_organization_document_authority_reclassifications(jsonb) FROM PUBLIC', ${literal(schema)});\n EXECUTE format('GRANT EXECUTE ON FUNCTION %I.list_organization_document_authority_reclassifications(jsonb) TO %I', ${literal(schema)}, ${literal(role)});\n EXECUTE format('REVOKE ALL ON FUNCTION %I.document_migration_audit_capability_active(text) FROM PUBLIC', ${literal(schema)});\n EXECUTE format('REVOKE ALL ON FUNCTION %I.document_migration_audit_capability_active(text) FROM %I', ${literal(schema)}, ${literal(role)});\n EXECUTE format('REVOKE ALL ON FUNCTION %I.assert_document_migration_audit_authority(jsonb) FROM PUBLIC', ${literal(schema)});\n EXECUTE format('REVOKE ALL ON FUNCTION %I.assert_document_migration_audit_authority(jsonb) FROM %I', ${literal(schema)}, ${literal(role)});\n EXECUTE format('REVOKE ALL PRIVILEGES ON TABLE %I.document_migration_audit_capabilities FROM %I', ${literal(schema)}, ${literal(role)});\n END IF;\n END IF;\n IF to_regprocedure(\n format('%I.create_scoped_variable_set(uuid,uuid,text,text,text,jsonb,boolean)', ${literal(schema)})\n ) IS NOT NULL THEN\n EXECUTE format('GRANT EXECUTE ON FUNCTION %I.create_scoped_variable_set(uuid, uuid, text, text, text, jsonb, boolean) TO %I', ${literal(schema)}, ${literal(role)});\n EXECUTE format('GRANT EXECUTE ON FUNCTION %I.list_scoped_variable_sets(uuid, uuid, uuid, text, text) TO %I', ${literal(schema)}, ${literal(role)});\n EXECUTE format('GRANT EXECUTE ON FUNCTION %I.count_scoped_variable_sets(uuid, uuid, text) TO %I', ${literal(schema)}, ${literal(role)});\n EXECUTE format('GRANT EXECUTE ON FUNCTION %I.mutate_scoped_variable_set(uuid, uuid, uuid, text, text, boolean, text, boolean, text, text, boolean) TO %I', ${literal(schema)}, ${literal(role)});\n EXECUTE format('GRANT EXECUTE ON FUNCTION %I.read_scoped_variable_set_secret(uuid, uuid, uuid, text, text, text, uuid, uuid, uuid, integer) TO %I', ${literal(schema)}, ${literal(role)});\n EXECUTE format('GRANT EXECUTE ON FUNCTION %I.materialize_scoped_variable_set_for_attempt(uuid, uuid, uuid, uuid, uuid, integer, uuid) TO %I', ${literal(schema)}, ${literal(role)});\n EXECUTE format('GRANT EXECUTE ON FUNCTION %I.materialize_scoped_variable_set_for_session(uuid, uuid, uuid, uuid) TO %I', ${literal(schema)}, ${literal(role)});\n EXECUTE format('REVOKE ALL PRIVILEGES ON TABLE %I.workspace_variable_sets FROM %I', ${literal(schema)}, ${literal(role)});\n EXECUTE format('REVOKE ALL PRIVILEGES ON TABLE %I.workspace_variable_set_variables FROM %I', ${literal(schema)}, ${literal(role)});\n END IF;\n IF to_regprocedure(\n format('%I.create_scoped_rig(uuid,uuid,text,text,text,text,jsonb,boolean)', ${literal(schema)})\n ) IS NOT NULL THEN\n EXECUTE format('GRANT EXECUTE ON FUNCTION %I.create_scoped_rig(uuid, uuid, text, text, text, text, jsonb, boolean) TO %I', ${literal(schema)}, ${literal(role)});\n EXECUTE format('GRANT EXECUTE ON FUNCTION %I.list_scoped_rigs(uuid, uuid, uuid, text, text) TO %I', ${literal(schema)}, ${literal(role)});\n EXECUTE format('GRANT EXECUTE ON FUNCTION %I.count_scoped_rigs(uuid, uuid, text) TO %I', ${literal(schema)}, ${literal(role)});\n EXECUTE format('GRANT EXECUTE ON FUNCTION %I.mutate_scoped_rig(uuid, uuid, uuid, text, text, boolean, text, boolean, boolean) TO %I', ${literal(schema)}, ${literal(role)});\n EXECUTE format('GRANT EXECUTE ON FUNCTION %I.finalize_scoped_enrollment(uuid, uuid, text, text, boolean, boolean, text, text, text, boolean) TO %I', ${literal(schema)}, ${literal(role)});\n EXECUTE format('GRANT EXECUTE ON FUNCTION %I.list_scoped_enrollments(uuid, uuid, uuid, text) TO %I', ${literal(schema)}, ${literal(role)});\n EXECUTE format('GRANT EXECUTE ON FUNCTION %I.get_scoped_sandbox(uuid, uuid, uuid) TO %I', ${literal(schema)}, ${literal(role)});\n EXECUTE format('GRANT EXECUTE ON FUNCTION %I.authorize_scoped_sandbox_attach(uuid, uuid, uuid) TO %I', ${literal(schema)}, ${literal(role)});\n EXECUTE format('GRANT EXECUTE ON FUNCTION %I.materialize_scoped_rig_version_for_attempt(uuid, uuid, uuid, uuid, uuid, integer) TO %I', ${literal(schema)}, ${literal(role)});\n EXECUTE format('GRANT EXECUTE ON FUNCTION %I.authorize_session_attempt_personal_machine(uuid, uuid, uuid, uuid, uuid, integer, uuid) TO %I', ${literal(schema)}, ${literal(role)});\n EXECUTE format('GRANT EXECUTE ON FUNCTION %I.assert_session_attempt_personal_machine(uuid, uuid, uuid, uuid, uuid, integer, uuid, boolean) TO %I', ${literal(schema)}, ${literal(role)});\n EXECUTE format('GRANT EXECUTE ON FUNCTION %I.list_scoped_machine_dependent_sessions(uuid, uuid, uuid) TO %I', ${literal(schema)}, ${literal(role)});\n EXECUTE format('GRANT EXECUTE ON FUNCTION %I.detach_scoped_machine_dependent_sessions(uuid, uuid, uuid) TO %I', ${literal(schema)}, ${literal(role)});\n EXECUTE format('REVOKE ALL PRIVILEGES ON TABLE %I.session_attempt_connected_machine_authorizations FROM %I', ${literal(schema)}, ${literal(role)});\n END IF;\n IF to_regprocedure(\n format(\n '%I.freeze_scheduled_task_personal_resources(uuid,uuid,uuid,bigint)',\n ${literal(schema)}\n )\n ) IS NOT NULL THEN\n EXECUTE format(\n 'REVOKE ALL ON FUNCTION %I.freeze_scheduled_task_personal_resources(uuid, uuid, uuid, bigint) FROM PUBLIC',\n ${literal(schema)}\n );\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION %I.freeze_scheduled_task_personal_resources(uuid, uuid, uuid, bigint) TO %I',\n ${literal(schema)},\n ${literal(role)}\n );\n EXECUTE format(\n 'REVOKE ALL ON FUNCTION %I.clone_scheduled_task_personal_resource_authority(uuid, uuid, uuid, bigint, bigint) FROM PUBLIC',\n ${literal(schema)}\n );\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION %I.clone_scheduled_task_personal_resource_authority(uuid, uuid, uuid, bigint, bigint) TO %I',\n ${literal(schema)},\n ${literal(role)}\n );\n IF to_regprocedure(\n format(\n '%I.refresh_scheduled_task_personal_resources_clone_connections(uuid,uuid,uuid,bigint,bigint)',\n ${literal(schema)}\n )\n ) IS NOT NULL THEN\n EXECUTE format(\n 'REVOKE ALL ON FUNCTION %I.refresh_scheduled_task_personal_resources_clone_connections(uuid, uuid, uuid, bigint, bigint) FROM PUBLIC',\n ${literal(schema)}\n );\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION %I.refresh_scheduled_task_personal_resources_clone_connections(uuid, uuid, uuid, bigint, bigint) TO %I',\n ${literal(schema)}, ${literal(role)}\n );\n EXECUTE format(\n 'REVOKE ALL ON FUNCTION %I.create_scheduled_agent_run_with_admission(uuid, uuid, uuid, uuid, bigint, text, text, text, timestamp with time zone, timestamp with time zone, jsonb) FROM PUBLIC',\n ${literal(schema)}\n );\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION %I.create_scheduled_agent_run_with_admission(uuid, uuid, uuid, uuid, bigint, text, text, text, timestamp with time zone, timestamp with time zone, jsonb) TO %I',\n ${literal(schema)}, ${literal(role)}\n );\n EXECUTE format(\n 'REVOKE ALL ON FUNCTION %I.scheduled_task_run_connection_authority_subject(uuid, uuid, uuid) FROM PUBLIC',\n ${literal(schema)}\n );\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION %I.scheduled_task_run_connection_authority_subject(uuid, uuid, uuid) TO %I',\n ${literal(schema)}, ${literal(role)}\n );\n EXECUTE format(\n 'REVOKE ALL ON FUNCTION %I.scheduled_task_personal_resource_authority_subject(uuid, uuid, uuid, bigint) FROM PUBLIC',\n ${literal(schema)}\n );\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION %I.scheduled_task_personal_resource_authority_subject(uuid, uuid, uuid, bigint) TO %I',\n ${literal(schema)}, ${literal(role)}\n );\n EXECUTE format(\n 'REVOKE ALL ON FUNCTION %I.record_scheduled_task_revision_authority(uuid, uuid, uuid, bigint) FROM PUBLIC',\n ${literal(schema)}\n );\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION %I.record_scheduled_task_revision_authority(uuid, uuid, uuid, bigint) TO %I',\n ${literal(schema)}, ${literal(role)}\n );\n EXECUTE format(\n 'REVOKE ALL ON FUNCTION %I.clone_scheduled_task_revision_authority(uuid, uuid, uuid, bigint, bigint) FROM PUBLIC',\n ${literal(schema)}\n );\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION %I.clone_scheduled_task_revision_authority(uuid, uuid, uuid, bigint, bigint) TO %I',\n ${literal(schema)}, ${literal(role)}\n );\n EXECUTE format(\n 'REVOKE ALL ON FUNCTION %I.scheduled_task_revision_authority_subject(uuid, uuid, uuid, bigint) FROM PUBLIC',\n ${literal(schema)}\n );\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION %I.scheduled_task_revision_authority_subject(uuid, uuid, uuid, bigint) TO %I',\n ${literal(schema)}, ${literal(role)}\n );\n EXECUTE format(\n 'REVOKE ALL ON FUNCTION %I.scheduled_task_revision_authority_snapshot(uuid, uuid, uuid, bigint) FROM PUBLIC',\n ${literal(schema)}\n );\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION %I.scheduled_task_revision_authority_snapshot(uuid, uuid, uuid, bigint) TO %I',\n ${literal(schema)}, ${literal(role)}\n );\n EXECUTE format(\n 'REVOKE ALL ON FUNCTION %I.validate_scheduled_agent_run_live_authority(uuid, uuid, uuid) FROM PUBLIC',\n ${literal(schema)}\n );\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION %I.validate_scheduled_agent_run_live_authority(uuid, uuid, uuid) TO %I',\n ${literal(schema)}, ${literal(role)}\n );\n EXECUTE format(\n 'REVOKE ALL ON FUNCTION %I.scheduled_scoped_rig_version_metadata(uuid, uuid, text, uuid, uuid) FROM PUBLIC',\n ${literal(schema)}\n );\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION %I.scheduled_scoped_rig_version_metadata(uuid, uuid, text, uuid, uuid) TO %I',\n ${literal(schema)}, ${literal(role)}\n );\n EXECUTE format(\n 'REVOKE ALL ON FUNCTION %I.scheduled_variable_set_expected_generation_for_attempt(uuid, uuid, uuid, uuid, uuid, integer, uuid) FROM PUBLIC',\n ${literal(schema)}\n );\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION %I.scheduled_variable_set_expected_generation_for_attempt(uuid, uuid, uuid, uuid, uuid, integer, uuid) TO %I',\n ${literal(schema)}, ${literal(role)}\n );\n EXECUTE format(\n 'REVOKE ALL ON FUNCTION %I.bind_scheduled_task_run_session(uuid, uuid, uuid, uuid) FROM PUBLIC',\n ${literal(schema)}\n );\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION %I.bind_scheduled_task_run_session(uuid, uuid, uuid, uuid) TO %I',\n ${literal(schema)}, ${literal(role)}\n );\n EXECUTE format(\n 'REVOKE ALL ON FUNCTION %I.transition_scheduled_agent_run(uuid, uuid, uuid, uuid, uuid, text, text) FROM PUBLIC',\n ${literal(schema)}\n );\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION %I.transition_scheduled_agent_run(uuid, uuid, uuid, uuid, uuid, text, text) TO %I',\n ${literal(schema)}, ${literal(role)}\n );\n EXECUTE format(\n 'REVOKE DELETE ON TABLE %I.scheduled_tasks, %I.scheduled_task_runs FROM %I',\n ${literal(schema)}, ${literal(schema)}, ${literal(role)}\n );\n EXECUTE format(\n 'REVOKE ALL PRIVILEGES ON TABLE %I.scheduled_task_connection_authority_snapshots FROM %I',\n ${literal(schema)}, ${literal(role)}\n );\n EXECUTE format(\n 'REVOKE ALL PRIVILEGES ON TABLE %I.scheduled_task_run_connection_authority_snapshots FROM %I',\n ${literal(schema)}, ${literal(role)}\n );\n EXECUTE format(\n 'REVOKE ALL PRIVILEGES ON TABLE %I.scheduled_task_reusable_connection_materializations FROM %I',\n ${literal(schema)}, ${literal(role)}\n );\n EXECUTE format(\n 'REVOKE ALL PRIVILEGES ON TABLE %I.scheduled_task_revision_authorities FROM %I',\n ${literal(schema)}, ${literal(role)}\n );\n END IF;\n EXECUTE format(\n 'REVOKE ALL ON FUNCTION %I.materialize_scheduled_task_reusable_session_from_run(uuid, uuid, uuid, uuid, uuid, bigint, text) FROM PUBLIC',\n ${literal(schema)}\n );\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION %I.materialize_scheduled_task_reusable_session_from_run(uuid, uuid, uuid, uuid, uuid, bigint, text) TO %I',\n ${literal(schema)},\n ${literal(role)}\n );\n EXECUTE format(\n 'REVOKE ALL ON FUNCTION %I.scheduled_task_run_personal_resource_authority(uuid, uuid, uuid) FROM PUBLIC',\n ${literal(schema)}\n );\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION %I.scheduled_task_run_personal_resource_authority(uuid, uuid, uuid) TO %I',\n ${literal(schema)},\n ${literal(role)}\n );\n END IF;\n IF to_regprocedure(\n format(\n '%I.scoped_knowledge_advance_source_acl(uuid,uuid,bigint,bigint,uuid,text,text,text,text,text,text)',\n ${literal(schema)}\n )\n ) IS NOT NULL THEN\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION %I.scoped_knowledge_advance_source_acl(uuid, uuid, bigint, bigint, uuid, text, text, text, text, text, text) TO %I',\n ${literal(schema)},\n ${literal(role)}\n );\n END IF;\n IF to_regprocedure(\n format(\n '%I.scoped_knowledge_complete_sync(uuid,uuid,text,text,timestamptz,jsonb,text,text,text)',\n ${literal(schema)}\n )\n ) IS NOT NULL THEN\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION %I.scoped_knowledge_complete_sync(uuid, uuid, text, text, timestamptz, jsonb, text, text, text) TO %I',\n ${literal(schema)},\n ${literal(role)}\n );\n END IF;\n IF to_regprocedure(\n format(\n '%I.scoped_knowledge_advance_object_version(uuid,uuid,bigint,bigint,uuid,text,text,text,text,text,text)',\n ${literal(schema)}\n )\n ) IS NOT NULL THEN\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION %I.scoped_knowledge_advance_object_version(uuid, uuid, bigint, bigint, uuid, text, text, text, text, text, text) TO %I',\n ${literal(schema)},\n ${literal(role)}\n );\n END IF;\n EXECUTE format('GRANT USAGE, SELECT ON ALL SEQUENCES IN SCHEMA %I TO %I', ${literal(schema)}, ${literal(role)});\n EXECUTE format(\n 'ALTER DEFAULT PRIVILEGES FOR ROLE %I IN SCHEMA %I REVOKE ALL PRIVILEGES ON TABLES FROM %I',\n owner_role,\n ${literal(schema)},\n ${literal(role)}\n );\n EXECUTE format(\n 'ALTER DEFAULT PRIVILEGES FOR ROLE %I IN SCHEMA %I GRANT USAGE, SELECT ON SEQUENCES TO %I',\n owner_role,\n ${literal(schema)},\n ${literal(role)}\n );\n END IF;\n IF EXISTS (SELECT 1 FROM pg_namespace WHERE nspname = 'opengeni_private') THEN\n EXECUTE format('GRANT USAGE ON SCHEMA opengeni_private TO %I', ${literal(role)});\n EXECUTE format('REVOKE CREATE ON SCHEMA opengeni_private FROM %I', ${literal(role)});\n EXECUTE format('GRANT EXECUTE ON ALL FUNCTIONS IN SCHEMA opengeni_private TO %I', ${literal(role)});\n FOREACH routine_signature IN ARRAY ARRAY[\n 'guard_workspace_owned_skill_head_delete()',\n 'guard_workspace_owned_skill_history_delete()'\n ] LOOP\n IF to_regprocedure('opengeni_private.' || routine_signature) IS NOT NULL THEN\n EXECUTE format('REVOKE ALL ON FUNCTION opengeni_private.%s FROM PUBLIC', routine_signature);\n EXECUTE format('REVOKE ALL ON FUNCTION opengeni_private.%s FROM %I', routine_signature, ${literal(role)});\n END IF;\n END LOOP;\n EXECUTE format(\n 'ALTER DEFAULT PRIVILEGES FOR ROLE %I IN SCHEMA opengeni_private REVOKE EXECUTE ON FUNCTIONS FROM %I',\n owner_role,\n ${literal(role)}\n );\n IF to_regprocedure('opengeni_private.personal_resource_delegation_capability_active(text)') IS NOT NULL THEN\n REVOKE ALL ON FUNCTION\n opengeni_private.personal_resource_delegation_capability_active(text)\n FROM PUBLIC;\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION opengeni_private.personal_resource_delegation_capability_active(text) TO %I',\n ${literal(role)}\n );\n END IF;\n IF to_regprocedure('opengeni_private.scheduled_personal_resource_capability_active(text)') IS NOT NULL THEN\n REVOKE ALL ON FUNCTION\n opengeni_private.scheduled_personal_resource_capability_active(text)\n FROM PUBLIC;\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION opengeni_private.scheduled_personal_resource_capability_active(text) TO %I',\n ${literal(role)}\n );\n END IF;\n IF to_regprocedure('opengeni_private.variable_set_authority_capability_active(text)') IS NOT NULL THEN\n REVOKE ALL ON FUNCTION\n opengeni_private.variable_set_authority_capability_active(text)\n FROM PUBLIC;\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION opengeni_private.variable_set_authority_capability_active(text) TO %I',\n ${literal(role)}\n );\n EXECUTE format(\n 'REVOKE ALL PRIVILEGES ON TABLE opengeni_private.variable_set_authority_capabilities FROM %I',\n ${literal(role)}\n );\n END IF;\n IF to_regprocedure('opengeni_private.session_variable_set_attachments_protocol_v1_active()') IS NOT NULL THEN\n REVOKE ALL ON FUNCTION\n opengeni_private.session_variable_set_attachments_protocol_v1_active()\n FROM PUBLIC;\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION opengeni_private.session_variable_set_attachments_protocol_v1_active() TO %I',\n ${literal(role)}\n );\n END IF;\n IF to_regprocedure('opengeni_private.scoped_compute_capability_active(text)') IS NOT NULL THEN\n REVOKE ALL ON FUNCTION opengeni_private.scoped_compute_capability_active(text) FROM PUBLIC;\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION opengeni_private.scoped_compute_capability_active(text) TO %I',\n ${literal(role)}\n );\n EXECUTE format(\n 'REVOKE ALL PRIVILEGES ON TABLE opengeni_private.scoped_compute_capabilities FROM %I',\n ${literal(role)}\n );\n END IF;\n -- The automatic-title migration helper and policy trigger deliberately\n -- retain role-scoped EXECUTE for pre-policy startup/readiness\n -- compatibility. Both are SECURITY INVOKER and PUBLIC remains revoked; RLS\n -- and the private-table ACL deny app-role enqueue writes, while PostgreSQL\n -- refuses direct trigger calls, so neither grant conveys data authority.\n IF to_regclass('opengeni_private.automatic_session_title_fanout_outbox_v1') IS NOT NULL THEN\n EXECUTE format(\n 'REVOKE ALL PRIVILEGES ON TABLE opengeni_private.automatic_session_title_fanout_outbox_v1 FROM %I',\n ${literal(role)}\n );\n END IF;\n IF to_regprocedure('opengeni_private.enqueue_automatic_session_title_fanout_v1(uuid,uuid,uuid,uuid)') IS NOT NULL THEN\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION opengeni_private.enqueue_automatic_session_title_fanout_v1(uuid, uuid, uuid, uuid) TO %I',\n ${literal(role)}\n );\n END IF;\n IF to_regprocedure('opengeni_private.enforce_automatic_session_title_policy_v1()') IS NOT NULL THEN\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION opengeni_private.enforce_automatic_session_title_policy_v1() TO %I',\n ${literal(role)}\n );\n END IF;\n -- Global cross-workspace artifact workers are separate capabilities. Never\n -- let the generic tenant-scoped app role inherit them from the historical\n -- blanket grant of already-installed helpers.\n IF to_regprocedure('opengeni_private.claim_editable_artifact_live_outbox(text,integer,integer,name)') IS NOT NULL THEN\n EXECUTE format(\n 'REVOKE EXECUTE ON FUNCTION opengeni_private.claim_editable_artifact_live_outbox(text, integer, integer, name) FROM %I',\n ${literal(role)}\n );\n EXECUTE format(\n 'REVOKE EXECUTE ON FUNCTION opengeni_private.mark_editable_artifact_live_outbox_published(text, text, integer, name) FROM %I',\n ${literal(role)}\n );\n EXECUTE format(\n 'REVOKE EXECUTE ON FUNCTION opengeni_private.renew_editable_artifact_live_outbox(text, text, integer, integer, name) FROM %I',\n ${literal(role)}\n );\n EXECUTE format(\n 'REVOKE EXECUTE ON FUNCTION opengeni_private.retry_editable_artifact_live_outbox(text, text, integer, integer, text, name) FROM %I',\n ${literal(role)}\n );\n EXECUTE format(\n 'REVOKE EXECUTE ON FUNCTION opengeni_private.dead_letter_editable_artifact_live_outbox(text, text, integer, text, name) FROM %I',\n ${literal(role)}\n );\n EXECUTE format(\n 'REVOKE EXECUTE ON FUNCTION opengeni_private.release_editable_artifact_live_outbox(text, text, integer, name) FROM %I',\n ${literal(role)}\n );\n END IF;\n IF to_regprocedure('opengeni_private.claim_editable_artifact_materializations(text,integer,integer,name)') IS NOT NULL THEN\n EXECUTE format(\n 'REVOKE EXECUTE ON FUNCTION opengeni_private.claim_editable_artifact_materializations(text, integer, integer, name) FROM %I',\n ${literal(role)}\n );\n EXECUTE format(\n 'REVOKE EXECUTE ON FUNCTION opengeni_private.renew_editable_artifact_materialization(uuid, uuid, text, text, text, integer, integer, name) FROM %I',\n ${literal(role)}\n );\n EXECUTE format(\n 'REVOKE EXECUTE ON FUNCTION opengeni_private.succeed_editable_artifact_materialization(uuid, uuid, text, text, text, integer, text, text, text, bigint, text, text, timestamptz, name) FROM %I',\n ${literal(role)}\n );\n EXECUTE format(\n 'REVOKE EXECUTE ON FUNCTION opengeni_private.fail_editable_artifact_materialization(uuid, uuid, text, text, text, integer, text, name) FROM %I',\n ${literal(role)}\n );\n END IF;\n IF to_regprocedure('opengeni_private.consume_editable_artifact_live_ticket(text,name)') IS NOT NULL THEN\n EXECUTE format(\n 'REVOKE EXECUTE ON FUNCTION opengeni_private.resolve_editable_artifact_ticket_data_schema(name) FROM %I',\n ${literal(role)}\n );\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION opengeni_private.put_editable_artifact_live_ticket(text, uuid, uuid, text, text, text, text, text, text, text, text, integer, text, boolean, integer, timestamptz, timestamptz, name) TO %I',\n ${literal(role)}\n );\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION opengeni_private.consume_editable_artifact_live_ticket(text, name) TO %I',\n ${literal(role)}\n );\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION opengeni_private.cleanup_expired_editable_artifact_live_tickets(integer, name) TO %I',\n ${literal(role)}\n );\n END IF;\n IF to_regprocedure('opengeni_private.authorize_editable_artifact_actor(uuid,uuid,text,text,text,text,text,text,integer,text,text,name)') IS NOT NULL THEN\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION opengeni_private.authorize_editable_artifact_actor(uuid, uuid, text, text, text, text, text, text, integer, text, text, name) TO %I',\n ${literal(role)}\n );\n END IF;\n FOREACH routine_signature IN ARRAY ARRAY[\n 'complete_temporal_schedule_connector_cleanup(uuid,uuid)',\n 'upgrade_temporal_schedule_connector_cleanup(uuid,uuid,text,uuid,text,jsonb,uuid)',\n 'complete_workspace_temporal_connector_cleanups(uuid,uuid)'\n ] LOOP\n IF to_regprocedure('opengeni_private.' || routine_signature) IS NOT NULL THEN\n EXECUTE format(\n 'REVOKE ALL ON FUNCTION opengeni_private.%s FROM PUBLIC',\n routine_signature\n );\n EXECUTE format(\n 'GRANT EXECUTE ON FUNCTION opengeni_private.%s TO %I',\n routine_signature,\n ${literal(role)}\n );\n END IF;\n END LOOP;\n END IF;\nEND $$;\n`);\n}\n\nfunction commaSeparated(value: string): string[] {\n return value\n .split(\",\")\n .map((item) => item.trim())\n .filter(Boolean);\n}\n\nfunction validateIdentifier(name: string, value: string): string {\n if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(value)) {\n throw new Error(`${name} contains an invalid Postgres identifier: ${value}`);\n }\n return value;\n}\n\nfunction identifier(value: string): string {\n return `\"${value.replace(/\"/g, '\"\"')}\"`;\n}\n\nfunction literal(value: string): string {\n return `'${value.replace(/'/g, \"''\")}'`;\n}\n\nfunction databaseUrlFor(value: string, database: string): string {\n const url = new URL(value);\n url.pathname = `/${database}`;\n return url.toString();\n}\n\n// CLI form (unchanged behavior): read env into the SDK options and run. This is\n// what `bun src/provision-roles.ts` / the `provision-roles` package script\n// invokes — standalone byte-for-byte the historical script (public schema,\n// force strategy, env-driven creds).\nif (import.meta.main) {\n const adminUrl =\n process.env.OPENGENI_MIGRATIONS_DATABASE_URL ??\n process.env.OPENGENI_DATABASE_ADMIN_URL ??\n process.env.OPENGENI_DATABASE_URL;\n if (!adminUrl) {\n throw new Error(\n \"OPENGENI_MIGRATIONS_DATABASE_URL, OPENGENI_DATABASE_ADMIN_URL, or OPENGENI_DATABASE_URL is required\",\n );\n }\n const result = await provisionRoles(adminUrl, {\n ...(process.env.OPENGENI_DB_SCHEMA?.trim()\n ? { targetSchema: process.env.OPENGENI_DB_SCHEMA.trim() }\n : {}),\n });\n console.log(JSON.stringify(result, null, 2));\n}\n","import { sql } from \"drizzle-orm\";\nimport type { Database, RlsStrategy } from \"./database\";\nimport {\n classifyRoleRelationships,\n roleRelationshipsCatalogQuery,\n type RoleRelationshipCatalogRow,\n} from \"./role-relationships\";\n\nconst ARTIFACT_OUTBOX_CAPABILITY_ROUTINES = [\n \"claim_editable_artifact_live_outbox(text, integer, integer, name)\",\n \"mark_editable_artifact_live_outbox_published(text, text, integer, name)\",\n \"renew_editable_artifact_live_outbox(text, text, integer, integer, name)\",\n \"retry_editable_artifact_live_outbox(text, text, integer, integer, text, name)\",\n \"dead_letter_editable_artifact_live_outbox(text, text, integer, text, name)\",\n \"release_editable_artifact_live_outbox(text, text, integer, name)\",\n] as const;\n\nconst ARTIFACT_MATERIALIZER_CAPABILITY_ROUTINES = [\n \"claim_editable_artifact_materializations(text, integer, integer, name)\",\n \"renew_editable_artifact_materialization(uuid, uuid, text, text, text, integer, integer, name)\",\n \"succeed_editable_artifact_materialization(uuid, uuid, text, text, text, integer, text, text, text, bigint, text, text, timestamp with time zone, name)\",\n \"fail_editable_artifact_materialization(uuid, uuid, text, text, text, integer, text, name)\",\n] as const;\n\nconst ARTIFACT_LIVE_TICKET_CAPABILITY_ROUTINES = [\n \"put_editable_artifact_live_ticket(text, uuid, uuid, text, text, text, text, text, text, text, text, integer, text, boolean, integer, timestamp with time zone, timestamp with time zone, name)\",\n \"consume_editable_artifact_live_ticket(text, name)\",\n \"cleanup_expired_editable_artifact_live_tickets(integer, name)\",\n] as const;\n\nconst ARTIFACT_LIVE_TICKET_INTERNAL_ROUTINES = [\n \"resolve_editable_artifact_ticket_data_schema(name)\",\n] as const;\n\nconst ARTIFACT_AUTHORIZATION_CAPABILITY_ROUTINES = [\n \"authorize_editable_artifact_actor(uuid, uuid, text, text, text, text, text, text, integer, text, text, name)\",\n] as const;\n\nconst AUTOMATIC_SESSION_TITLE_FANOUT_RUNTIME_ROUTINES = [\n \"claim_automatic_session_title_fanout_v1(integer)\",\n \"mark_automatic_session_title_fanout_delivered_v1(uuid, uuid)\",\n \"mark_automatic_session_title_fanout_failed_v1(uuid, uuid, text)\",\n] as const;\n\nconst AUTOMATIC_SESSION_TITLE_FANOUT_MIGRATION_ROUTINE =\n \"enqueue_automatic_session_title_fanout_v1(uuid, uuid, uuid, uuid)\";\n\nconst AUTOMATIC_SESSION_TITLE_POLICY_TRIGGER_ROUTINE =\n \"enforce_automatic_session_title_policy_v1()\";\nconst AUTOMATIC_SESSION_TITLE_FANOUT_OUTBOX_TABLE = \"automatic_session_title_fanout_outbox_v1\";\nconst AUTOMATIC_SESSION_TITLE_QUARANTINE_FENCE_ROUTINE =\n \"acquire_automatic_session_title_quarantine_fences_v1(integer)\";\n\nconst OWNER_INTERNAL_PRIVATE_ROUTINES = new Set<string>([\n \"guard_workspace_owned_skill_head_delete()\",\n \"guard_workspace_owned_skill_history_delete()\",\n ...ARTIFACT_OUTBOX_CAPABILITY_ROUTINES,\n ...ARTIFACT_MATERIALIZER_CAPABILITY_ROUTINES,\n ...ARTIFACT_LIVE_TICKET_INTERNAL_ROUTINES,\n]);\n\nconst KNOWLEDGE_SOURCE_SYNC_LOCK_AUTHORITY_ROUTINE =\n \"knowledge_source_sync_lock_authority(uuid, uuid, uuid)\";\nconst GOOGLE_DRIVE_FILE_AUTHORIZATION_ROUTINE =\n \"google_drive_file_authorized(uuid, uuid, text, uuid)\";\nconst GOOGLE_DRIVE_DOCUMENT_CITATION_ROUTINE =\n \"google_drive_document_citation(uuid, uuid, text, uuid, uuid)\";\nconst GOOGLE_DRIVE_AUTHORITY_TABLES = [\n \"connections\",\n \"files\",\n \"google_drive_object_acl_evidence\",\n \"google_drive_object_acl_principals\",\n \"knowledge_document_versions\",\n \"knowledge_providers\",\n \"knowledge_source_objects\",\n \"knowledge_source_sync_index_obligations\",\n \"knowledge_source_sync_states\",\n \"knowledge_sources\",\n] as const;\nconst KNOWLEDGE_SOURCE_SYNC_LOCK_AUTHORITY_TABLES = [\n \"knowledge_sources\",\n \"knowledge_source_objects\",\n] as const;\nconst MANAGED_HUMAN_PERSONAL_WORKSPACE_ROUTINE =\n \"ensure_managed_human_personal_workspace(uuid, text, uuid)\";\nconst ADDITIONAL_ORGANIZATION_CREATION_ROUTINE =\n \"create_additional_managed_organization(text, text, text, text, uuid)\";\nconst ORGANIZATION_MEMBERSHIP_LIFECYCLE_ROUTINES = [\n \"get_external_identity_link_reference(uuid, uuid, text)\",\n \"get_external_identity_link_inventory_references(uuid, uuid[])\",\n \"ensure_external_identity(uuid, text, text)\",\n \"list_self_organization_memberships(text)\",\n \"list_self_organization_invitations(text)\",\n \"list_self_organization_invitations(text, uuid, integer)\",\n \"get_self_organization_invitation(text, uuid)\",\n \"list_organization_invitations(uuid, text, uuid, integer)\",\n \"list_organization_members(uuid, text)\",\n \"list_organization_administration_members(uuid, text)\",\n \"get_organization_administration_overview(uuid, text)\",\n \"get_workspace_kind(uuid, uuid)\",\n \"resolve_workspace_codex_subscription_source(uuid, uuid)\",\n \"list_organization_workspace_ids(uuid)\",\n \"list_organization_codex_workspace_ids(uuid)\",\n \"organization_workspace_command(jsonb)\",\n \"authorize_organization_shared_workspace_administration(uuid, uuid, text)\",\n \"resolve_organization_workspace_removal_subject(uuid, text, uuid)\",\n \"prepare_organization_workspace_member_removal(jsonb)\",\n \"record_organization_workspace_member_removal(jsonb, uuid, uuid)\",\n ADDITIONAL_ORGANIZATION_CREATION_ROUTINE,\n \"create_managed_organization(text, text, text, uuid)\",\n \"assert_organization_shared_workspace_administrator(uuid, uuid, text)\",\n \"open_organization_shared_workspace_administration_capability(uuid, uuid, text)\",\n \"close_organization_shared_workspace_administration_capability(uuid)\",\n \"create_organization_shared_workspace(uuid, text, text, text, text, uuid)\",\n \"upsert_organization_shared_workspace_member(uuid, uuid, text, uuid, text, text, jsonb, boolean)\",\n \"update_organization_name(uuid, text, text, timestamp with time zone, uuid)\",\n \"create_organization_invitation_v2(jsonb)\",\n \"bind_pending_organization_invitations_for_verified_email(text, text)\",\n \"has_pending_organization_invitation_for_subject(text)\",\n \"accept_organization_invitation_v2(jsonb)\",\n \"complete_self_service_organization_setup(jsonb)\",\n \"ensure_organization_user_setup_intent(jsonb)\",\n \"claim_organization_user_setup_delivery(jsonb)\",\n \"claim_organization_user_setup_delivery_v2(jsonb)\",\n \"prepare_organization_user_setup_delivery(jsonb)\",\n \"prepare_organization_user_setup_delivery_v2(jsonb)\",\n \"settle_organization_user_setup_delivery(jsonb)\",\n \"preview_organization_user_setup(text)\",\n \"get_organization_invitation_for_administration(uuid, text, uuid)\",\n \"preflight_organization_user_setup(text)\",\n \"complete_organization_user_setup(jsonb)\",\n \"organization_membership_command(jsonb)\",\n \"prepare_organization_membership_protocol_settlements(jsonb)\",\n \"assert_active_managed_human_organization_membership(uuid, text)\",\n \"resolve_workspace_writer_grant_identity(uuid, text)\",\n \"prepare_workspace_membership_removal_settlements(jsonb)\",\n \"workspace_membership_removal_command(jsonb)\",\n \"get_organization_retention_policy(uuid, text)\",\n \"preview_organization_retention_deletions(uuid, integer)\",\n \"claim_organization_retention_deletion(uuid, uuid, uuid[])\",\n \"list_organization_retention_deletion_objects(uuid, uuid, uuid, text, integer)\",\n \"record_organization_retention_object_deleted(uuid, uuid, uuid, text, text, text, text)\",\n \"fail_organization_retention_deletion(uuid, uuid, uuid, text)\",\n \"finalize_organization_retention_deletion(uuid, uuid, uuid, text)\",\n \"complete_organization_retention_deletion(uuid, uuid, uuid, text)\",\n] as const;\nconst ORGANIZATION_MEMBERSHIP_LIFECYCLE_AUTHORITY_TABLES = [\n \"organization_invitation_binding_events\",\n \"organization_membership_invitations\",\n \"organization_membership_lifecycle_events\",\n \"organization_membership_operation_receipts\",\n \"organization_memberships\",\n \"organization_profile_events\",\n \"organization_shared_workspace_administration_capabilities\",\n \"organization_user_setup_deliveries\",\n \"organization_user_setup_delivery_attempts\",\n \"organization_user_setup_intents\",\n \"organization_user_resource_authorities\",\n \"organization_user_resource_grants\",\n \"organization_user_retention_deletion_events\",\n \"organization_user_retention_deletions\",\n \"organization_user_retention_object_deletion_receipts\",\n \"organization_user_retention_object_obligations\",\n \"organization_user_retention_policies\",\n \"organization_workspace_lifecycle_events\",\n \"organization_workspace_operation_receipts\",\n \"self_service_organization_setup_receipts\",\n] as const;\nconst ADDITIONAL_ORGANIZATION_CREATION_AUTHORITY_TABLES = [\n ...ORGANIZATION_MEMBERSHIP_LIFECYCLE_AUTHORITY_TABLES,\n \"additional_organization_creation_receipts\",\n] as const;\nconst PRIVATE_SESSION_CREATE_POLICY_ROUTINE = \"get_private_session_create_policy(uuid, uuid, text)\";\nconst ORGANIZATION_PRIVATE_SESSION_SETTINGS_READ_ROUTINE =\n \"get_organization_private_session_settings(uuid, text)\";\nconst ORGANIZATION_PRIVATE_SESSION_SETTINGS_UPDATE_ROUTINE =\n \"update_organization_private_session_settings(uuid, text, boolean, bigint, uuid)\";\nconst ORGANIZATION_PRIVATE_SESSION_ROUTINE_AUTHORITY_TABLES = {\n [PRIVATE_SESSION_CREATE_POLICY_ROUTINE]: [\n \"organization_memberships\",\n \"organization_private_session_settings\",\n \"session_tenancy_activations\",\n \"workspace_memberships\",\n \"workspaces\",\n ],\n [ORGANIZATION_PRIVATE_SESSION_SETTINGS_READ_ROUTINE]: [\n \"managed_accounts\",\n \"organization_memberships\",\n \"organization_private_session_settings\",\n \"session_tenancy_activations\",\n ],\n [ORGANIZATION_PRIVATE_SESSION_SETTINGS_UPDATE_ROUTINE]: [\n \"managed_accounts\",\n \"organization_memberships\",\n \"organization_private_session_setting_events\",\n \"organization_private_session_settings\",\n \"session_tenancy_activations\",\n ],\n} as const;\nconst ORGANIZATION_PRIVATE_SESSION_ROUTINES = Object.keys(\n ORGANIZATION_PRIVATE_SESSION_ROUTINE_AUTHORITY_TABLES,\n);\nconst ORGANIZATION_PRIVATE_SESSIONS_ENABLED_ROUTINE = \"organization_private_sessions_enabled(uuid)\";\nconst PREFERENCE_KNOWLEDGE_PROPOSAL_ROUTINE =\n \"preference_registry_create_knowledge_proposal_for_attempt(uuid, uuid, uuid, uuid, uuid, integer, uuid, text, uuid, text, text, text, text, integer, text, jsonb, timestamp with time zone, text)\";\nconst PREFERENCE_KNOWLEDGE_PROPOSAL_AUTHORITY_TABLES = [\n \"company_brain_preference_proposal_receipts\",\n \"knowledge_change_proposals\",\n \"knowledge_claim_evidence\",\n \"knowledge_claim_reviews\",\n \"knowledge_claims\",\n \"preference_registry_events\",\n \"preference_registry_preferences\",\n \"preference_registry_revisions\",\n \"session_attempt_interruptions\",\n \"session_turn_attempts\",\n \"session_turns\",\n \"sessions\",\n \"workspaces\",\n] as const;\nconst MANAGED_HUMAN_PERSONAL_WORKSPACE_AUTHORITY_TABLES = [\n \"organization_memberships\",\n \"organization_user_retention_policies\",\n \"organization_user_resource_authorities\",\n \"organization_user_resource_grants\",\n] as const;\nconst PERSONAL_RESOURCE_ATTEMPT_RESOLVER_ROUTINE =\n \"resolve_session_attempt_personal_resources(uuid, uuid, uuid)\";\nconst USER_RESOURCE_LIFECYCLE_ROUTINES = [\n \"accept_turn_personal_resource_attachment(uuid, uuid, uuid, uuid, text, integer, boolean, integer)\",\n \"list_self_user_resource_authorities(uuid, uuid, text, uuid, integer)\",\n \"issue_self_user_resource_grant(uuid, uuid, uuid, text, text, text, uuid, integer, boolean)\",\n \"issue_self_local_connection_use_grant(uuid, uuid, uuid, text, boolean)\",\n \"revoke_self_user_resource_grant(uuid, uuid, uuid)\",\n \"authorize_session_attempt_personal_resource_reads(uuid, uuid, uuid)\",\n] as const;\nconst CONNECTION_CONVERGENCE_AUDIT_CAPABILITY_ROUTINE =\n \"connection_authority_convergence_audit_capability_active(uuid)\";\nconst CONNECTION_AUTHORITY_ROUTINES = [\n CONNECTION_CONVERGENCE_AUDIT_CAPABILITY_ROUTINE,\n \"resolve_personal_connection_authority_selection(uuid, uuid, text, uuid, jsonb)\",\n \"resolve_accepted_connection_use(uuid, uuid, uuid, uuid, uuid, integer, uuid, text, text, uuid, text, text, text, text)\",\n \"resolve_connection_use_authority(uuid, uuid, uuid, jsonb)\",\n \"inspect_organization_connection_authority_convergence(uuid, integer, uuid)\",\n] as const;\nconst PERSONAL_GITHUB_REPOSITORY_AUTHORITY_ROUTINES = [\n \"get_self_personal_github_repository_selection(uuid, uuid, text, uuid)\",\n \"mutate_self_personal_github_repository_selection(uuid, uuid, text, uuid, bigint, bigint, text, jsonb, boolean)\",\n] as const;\nconst PERSONAL_GITHUB_REPOSITORY_AUTHORITY_TABLES = [\n \"personal_github_repository_selection_heads\",\n \"personal_github_repository_selection_operations\",\n \"personal_github_repository_selections\",\n] as const;\nconst SCHEDULED_PERSONAL_RESOURCE_ROUTINES = [\n \"freeze_scheduled_task_personal_resources(uuid, uuid, uuid, bigint)\",\n \"clone_scheduled_task_personal_resource_authority(uuid, uuid, uuid, bigint, bigint)\",\n \"refresh_scheduled_task_personal_resources_clone_connections(uuid, uuid, uuid, bigint, bigint)\",\n \"create_scheduled_agent_run_with_admission(uuid, uuid, uuid, uuid, bigint, text, text, text, timestamp with time zone, timestamp with time zone, jsonb)\",\n \"materialize_scheduled_task_reusable_session_from_run(uuid, uuid, uuid, uuid, uuid, bigint, text)\",\n \"scheduled_task_run_personal_resource_authority(uuid, uuid, uuid)\",\n \"scheduled_task_run_connection_authority_subject(uuid, uuid, uuid)\",\n \"scheduled_task_personal_resource_authority_subject(uuid, uuid, uuid, bigint)\",\n \"record_scheduled_task_revision_authority(uuid, uuid, uuid, bigint)\",\n \"clone_scheduled_task_revision_authority(uuid, uuid, uuid, bigint, bigint)\",\n \"scheduled_task_revision_authority_subject(uuid, uuid, uuid, bigint)\",\n \"scheduled_task_revision_authority_snapshot(uuid, uuid, uuid, bigint)\",\n \"validate_scheduled_agent_run_live_authority(uuid, uuid, uuid)\",\n \"scheduled_scoped_rig_version_metadata(uuid, uuid, text, uuid, uuid)\",\n \"scheduled_variable_set_expected_generation_for_attempt(uuid, uuid, uuid, uuid, uuid, integer, uuid)\",\n \"bind_scheduled_task_run_session(uuid, uuid, uuid, uuid)\",\n \"transition_scheduled_agent_run(uuid, uuid, uuid, uuid, uuid, text, text)\",\n] as const;\nconst PERSONAL_RESOURCE_CAPABILITY_PREDICATE_ROUTINE =\n \"personal_resource_delegation_capability_active(text)\";\nconst PERSONAL_RESOURCE_CAPABILITY_TABLE = \"personal_resource_delegation_capabilities\";\nconst SCHEDULED_PERSONAL_RESOURCE_CAPABILITY_PREDICATE_ROUTINE =\n \"scheduled_personal_resource_capability_active(text)\";\nconst SCHEDULED_PERSONAL_RESOURCE_CAPABILITY_TABLE = \"scheduled_personal_resource_capabilities\";\nconst VARIABLE_SET_CAPABILITY_PREDICATE_ROUTINE = \"variable_set_authority_capability_active(text)\";\nconst VARIABLE_SET_CAPABILITY_TABLE = \"variable_set_authority_capabilities\";\nconst PERSONAL_DOCUMENT_CAPABILITY_PREDICATE_ROUTINE =\n \"personal_document_authority_capability_active(text)\";\nconst PERSONAL_DOCUMENT_CAPABILITY_TABLE = \"personal_document_authority_capabilities\";\nconst PERSONAL_DOCUMENT_AUTHORITY_ROUTINES = [\n \"create_personal_document_authority(uuid, uuid, uuid)\",\n \"resolve_document_original_file(uuid, uuid, text, uuid)\",\n \"resolve_session_attempt_personal_document_reads(uuid, uuid, uuid, uuid)\",\n] as const;\nconst DOCUMENT_MIGRATION_CAPABILITY_PREDICATE_ROUTINE =\n \"document_migration_capability_active(text)\";\nconst DOCUMENT_MIGRATION_CAPABILITY_TABLE = \"document_migration_capabilities\";\nconst DOCUMENT_MIGRATION_AUTHORITY_ROUTINES = [\n \"list_document_authority_reclassifications(uuid, uuid, text, uuid, integer, timestamp with time zone, uuid)\",\n \"reclassify_document_authority(jsonb)\",\n \"run_document_default_collection_backfill(jsonb)\",\n \"list_document_default_collection_backfill_runs(jsonb)\",\n \"get_document_default_collection_backfill_audit(jsonb)\",\n \"list_organization_document_authority_reclassifications(jsonb)\",\n] as const;\nconst DOCUMENT_MIGRATION_AUDIT_INTERNAL_ROUTINES = [\n \"document_migration_audit_capability_active(text)\",\n \"assert_document_migration_audit_authority(jsonb)\",\n] as const;\nconst VARIABLE_SET_AUTHORITY_ROUTINES = [\n \"create_scoped_variable_set(uuid, uuid, text, text, text, jsonb, boolean)\",\n \"list_scoped_variable_sets(uuid, uuid, uuid, text, text)\",\n \"count_scoped_variable_sets(uuid, uuid, text)\",\n \"mutate_scoped_variable_set(uuid, uuid, uuid, text, text, boolean, text, boolean, text, text, boolean)\",\n \"read_scoped_variable_set_secret(uuid, uuid, uuid, text, text, text, uuid, uuid, uuid, integer)\",\n \"materialize_scoped_variable_set_for_attempt(uuid, uuid, uuid, uuid, uuid, integer, uuid)\",\n \"materialize_scoped_variable_set_for_session(uuid, uuid, uuid, uuid)\",\n] as const;\nconst SCOPED_COMPUTE_CAPABILITY_PREDICATE_ROUTINE = \"scoped_compute_capability_active(text)\";\nconst SCOPED_COMPUTE_CAPABILITY_TABLE = \"scoped_compute_capabilities\";\nconst CONNECTION_TENANCY_BACKFILL_CAPABILITY_TABLE = \"connection_tenancy_backfill_capabilities\";\nconst CONNECTION_TENANCY_BACKFILL_CAPABILITY_PREDICATE_ROUTINE =\n \"connection_tenancy_backfill_capability_active(uuid)\";\nconst SCOPED_COMPUTE_AUTHORITY_ROUTINES = [\n \"create_scoped_rig(uuid, uuid, text, text, text, text, jsonb, boolean)\",\n \"list_scoped_rigs(uuid, uuid, uuid, text, text)\",\n \"count_scoped_rigs(uuid, uuid, text)\",\n \"mutate_scoped_rig(uuid, uuid, uuid, text, text, boolean, text, boolean, boolean)\",\n \"finalize_scoped_enrollment(uuid, uuid, text, text, boolean, boolean, text, text, text, boolean)\",\n \"list_scoped_enrollments(uuid, uuid, uuid, text)\",\n \"get_scoped_sandbox(uuid, uuid, uuid)\",\n \"authorize_scoped_sandbox_attach(uuid, uuid, uuid)\",\n \"materialize_scoped_rig_version_for_attempt(uuid, uuid, uuid, uuid, uuid, integer)\",\n \"authorize_session_attempt_personal_machine(uuid, uuid, uuid, uuid, uuid, integer, uuid)\",\n \"assert_session_attempt_personal_machine(uuid, uuid, uuid, uuid, uuid, integer, uuid, boolean)\",\n \"list_scoped_machine_dependent_sessions(uuid, uuid, uuid)\",\n \"detach_scoped_machine_dependent_sessions(uuid, uuid, uuid)\",\n] as const;\nconst CANONICAL_HUMAN_IDENTITY_ROUTINES = [\n \"ensure_canonical_human_identity(text, text)\",\n \"validate_canonical_human_session(text, text, boolean)\",\n \"get_canonical_human_identity_projection(text)\",\n \"apply_canonical_human_identity_operation(uuid, text, bigint, text, uuid, text, text, text)\",\n] as const;\nconst CANONICAL_HUMAN_IDENTITY_AUTHORITY_TABLES = [\n \"canonical_human_identities\",\n \"canonical_human_identity_subjects\",\n \"canonical_human_login_bindings\",\n \"canonical_human_identity_operations\",\n] as const;\nconst MANAGED_AUTH_SESSION_SET_ROUTINES = [\n \"get_canonical_human_exact_login_binding(text, text)\",\n \"managed_auth_session_set_authority_state(text)\",\n \"managed_auth_session_set_snapshot(text, text, boolean, boolean, boolean)\",\n \"managed_auth_session_set_bootstrap(text, text, text, text, uuid, text, bigint, bigint)\",\n \"managed_auth_session_set_begin_transaction(text, text, text, uuid, text, bigint, uuid, bigint, text, text, uuid, uuid, text, timestamp with time zone)\",\n \"managed_auth_session_set_complete_transaction(text, text, uuid, text, bigint, bigint, uuid, text, text, text)\",\n \"managed_auth_session_set_mutate(text, text, uuid, text, bigint, bigint, text, uuid, uuid, uuid, text, text)\",\n \"managed_auth_actor_mutation_fence(text, bigint, uuid)\",\n \"managed_auth_actor_mutation_lease_acquire(text, bigint, uuid, integer)\",\n \"managed_auth_actor_mutation_lease_release(text, uuid)\",\n \"managed_auth_actor_mutation_lease_validate(text, bigint, uuid)\",\n \"managed_auth_adopted_session_snapshot(text)\",\n \"managed_auth_isolated_session_reap(integer)\",\n \"managed_auth_expired_session_set_reap(integer)\",\n \"managed_auth_session_set_operation_receipt(text, uuid, text, text)\",\n] as const;\nconst MANAGED_AUTH_SESSION_SET_AUTHORITY_TABLES = [\n \"managed_auth_actor_mutation_leases\",\n \"managed_auth_browser_installations\",\n \"managed_auth_session_sets\",\n \"managed_auth_login_slots\",\n \"managed_auth_login_return_intents\",\n \"managed_auth_login_transaction_rate_limits\",\n \"managed_auth_login_transactions\",\n \"managed_auth_session_set_operations\",\n] as const;\nconst ORGANIZATION_RECOVERY_ROUTINES = [\n \"get_organization_recovery_overview(uuid, text, jsonb, text, text)\",\n \"organization_recovery_command(jsonb)\",\n] as const;\nconst ORGANIZATION_RECOVERY_AUTHORITY_TABLES = [\n \"organization_recovery_approvals\",\n \"organization_recovery_command_receipts\",\n \"organization_recovery_custodian_acceptances\",\n \"organization_recovery_custodians\",\n \"organization_recovery_events\",\n \"organization_recovery_notification_attempts\",\n \"organization_recovery_notification_outbox\",\n \"organization_recovery_operations\",\n \"organization_recovery_policies\",\n \"organization_recovery_policy_heads\",\n] as const;\nconst SESSION_PRIVATE_ACTOR_VISIBLE_ROUTINE =\n \"session_private_actor_visible(uuid, uuid, uuid, text)\";\nconst SESSION_REFERENCE_VISIBLE_ROUTINE = \"session_reference_visible(uuid, uuid, uuid)\";\nconst TASK_NOTE_CAPABILITY_ROUTINES = [\n \"create_task_note_for_attempt(uuid, uuid, uuid, uuid, uuid, integer, uuid, text, text, integer)\",\n \"archive_task_note_for_attempt(uuid, uuid, uuid, uuid, uuid, integer, uuid, uuid, integer, text)\",\n \"list_task_notes_for_attempt(uuid, uuid, uuid, uuid, uuid, integer, boolean, integer)\",\n \"replace_task_note_for_attempt(uuid, uuid, uuid, uuid, uuid, integer, uuid, uuid, uuid, uuid, integer, text, text, integer, text)\",\n \"resolve_task_note_knowledge_promotion_source(uuid, uuid, uuid, uuid, uuid, integer, uuid, integer, text, text, text)\",\n] as const;\nexport const WORK_CLAIM_CAPABILITY_ROUTINES = [\n \"upsert_session_work_claim_for_attempt(uuid, uuid, uuid, uuid, uuid, integer, uuid, integer, text, text, text, text, text, text, text)\",\n \"release_session_work_claim_for_attempt(uuid, uuid, uuid, uuid, uuid, integer, uuid, uuid, integer, text)\",\n] as const;\nconst COMPANY_BRAIN_CONTEXT_SELECTION_ROUTINE =\n \"company_brain_context_get_or_create_selection(uuid, uuid, uuid, uuid, uuid, integer)\";\nconst COMPANY_BRAIN_CONTEXT_INSPECTION_ROUTINE =\n \"company_brain_inspect_context_receipts(uuid, uuid, text, uuid, timestamp with time zone, uuid, integer)\";\nconst GOVERNED_LEARNING_EVALUATION_ROUTINE =\n \"evaluate_governed_learning_proposal(uuid, uuid, uuid, uuid, uuid, integer, uuid, uuid, uuid, uuid, uuid)\";\nconst GOVERNED_LEARNING_ACTIVATION_ROUTINES = [\n \"activate_governed_learning_decision(uuid, uuid, uuid, uuid)\",\n \"activate_human_confirmed_learning_decision(uuid, uuid, uuid, uuid, uuid)\",\n \"confirm_remember_knowledge_claim(uuid, uuid, uuid, uuid, integer, uuid, uuid, uuid)\",\n \"materialize_remember_knowledge_memory(uuid, uuid, uuid)\",\n \"undo_governed_learning_activation(uuid, uuid, uuid, uuid)\",\n] as const;\nconst GOVERNED_LEARNING_INSPECTION_ROUTINES = [\n \"inspect_governed_learning_decisions(uuid, uuid, text, integer)\",\n \"inspect_governed_learning_activations(uuid, uuid, text, integer)\",\n \"inspect_governed_learning_activation_undos(uuid, uuid, text, integer)\",\n] as const;\nconst GOVERNED_LEARNING_INSPECTION_AUTHORITY_TABLES = [\n \"governed_learning_decision_receipts\",\n \"governed_learning_activation_receipts\",\n \"governed_learning_activation_undo_receipts\",\n \"sessions\",\n] as const;\nconst COMPANY_PROFILE_AGENT_ADMIN_ROUTINES = [\n \"propose_company_profile_for_attempt(uuid, uuid, uuid, uuid, uuid, integer, uuid, text, text, text)\",\n \"propose_company_profile_for_attempt_v2(uuid, uuid, uuid, uuid, uuid, integer, uuid, uuid, text, text, text)\",\n \"confirm_company_profile_for_attempt(uuid, uuid, uuid, uuid, uuid, integer, uuid, uuid, uuid)\",\n \"get_company_profile_agent_policy(uuid, uuid, text)\",\n \"update_company_profile_agent_policy(uuid, uuid, text, text, bigint, uuid)\",\n] as const;\nconst COMPANY_PROFILE_AGENT_ADMIN_AUTHORITY_TABLES = [\n \"company_profile_activation_events\",\n \"company_profile_agent_automatic_activation_receipts\",\n \"company_profile_agent_confirmation_receipts\",\n \"company_profile_agent_proposal_receipts\",\n \"company_profile_heads\",\n \"company_profile_revisions\",\n \"managed_accounts\",\n \"organization_company_profile_agent_policies\",\n \"organization_company_profile_agent_policy_events\",\n \"organization_memberships\",\n \"session_human_input_requests\",\n \"session_turn_attempts\",\n \"session_turns\",\n \"sessions\",\n \"workspaces\",\n] as const;\nconst GOVERNED_LEARNING_EVALUATION_AUTHORITY_TABLES = [\n \"document_chunks\",\n \"documents\",\n \"governed_learning_decision_receipts\",\n \"knowledge_change_proposals\",\n \"knowledge_claim_evidence\",\n \"knowledge_claim_relations\",\n \"knowledge_claim_reviews\",\n \"knowledge_claims\",\n \"knowledge_document_versions\",\n \"knowledge_providers\",\n \"knowledge_source_acl_versions\",\n \"knowledge_source_objects\",\n \"knowledge_sources\",\n \"session_attempt_interruptions\",\n \"session_turn_attempts\",\n \"session_turns\",\n \"sessions\",\n \"task_notes\",\n \"workspace_learning_policy_snapshots\",\n \"workspaces\",\n] as const;\nconst GOVERNED_LEARNING_ACTIVATION_AUTHORITY_TABLES = [\n ...GOVERNED_LEARNING_EVALUATION_AUTHORITY_TABLES,\n \"company_brain_preference_proposal_receipts\",\n \"governed_learning_activation_receipts\",\n \"governed_learning_activation_undo_receipts\",\n \"preference_registry_events\",\n \"preference_registry_preferences\",\n \"preference_registry_revisions\",\n \"remember_knowledge_confirmation_receipts\",\n \"remember_knowledge_memory_materializations\",\n \"session_human_input_requests\",\n \"workspace_instruction_policy_activation_events\",\n \"workspace_instruction_policy_deactivation_events\",\n \"workspace_instruction_policy_heads\",\n \"workspace_instruction_policy_onboarding_proposals\",\n \"workspace_instruction_policy_revisions\",\n \"workspace_learning_policy_heads\",\n \"workspace_learning_policy_revisions\",\n] as const;\nconst TRANSITION_SESSION_VISIBILITY_ROUTINE =\n \"transition_session_visibility(uuid, uuid, uuid, text, text, integer, text, text, integer)\";\nconst LEGACY_FORK_SESSION_CONTENT_ROUTINE =\n \"fork_session_content(uuid, uuid, uuid, text, uuid, text, text, text, integer)\";\nconst FORK_SESSION_CONTENT_ROUTINE =\n \"fork_session_content(uuid, uuid, uuid, text, uuid, text, boolean, text, text, integer)\";\nconst MESSAGE_FORK_SESSION_CONTENT_ROUTINE =\n \"fork_session_content(uuid, uuid, uuid, text, uuid, text, boolean, text, text, integer, uuid)\";\nconst REPLAY_APPLIED_SESSION_FORK_ROUTINE =\n \"replay_applied_session_fork(uuid, uuid, uuid, text, uuid, text, boolean, text, text, integer)\";\nconst SESSION_TENANCY_ACTIVATED_ROUTINE = \"session_tenancy_product_activated(uuid, integer)\";\nconst SESSION_TENANCY_ANY_ACTIVATION_ROUTINE = \"session_tenancy_any_product_activation()\";\nconst SESSION_TENANCY_QUIESCENCE_ROUTINE =\n \"assert_session_tenancy_quiescent(uuid, uuid, uuid, boolean)\";\nconst TENANCY_BACKFILL_ACTIVATION_EVIDENCE_ROUTINE =\n \"check_tenancy_backfill_activation_evidence(uuid)\";\nconst GREENFIELD_SESSION_TENANCY_ACTIVATION_ROUTINE =\n \"activate_greenfield_session_tenancy_from_setup(text)\";\nconst ADDITIONAL_ORGANIZATION_SESSION_TENANCY_ACTIVATION_ROUTINE =\n \"activate_session_tenancy_from_additional_organization(uuid)\";\nconst SESSION_VISIBILITY_LIFECYCLE_CAPABILITY_ROUTINE =\n \"session_visibility_lifecycle_capability_held()\";\nconst PRIVATE_SESSION_CREATE_CAPABILITY_ROUTINES = [\n \"open_private_session_create_capability(uuid, uuid, uuid, text)\",\n \"open_private_child_session_create_capability(uuid, uuid, uuid, uuid, uuid, uuid, integer)\",\n \"close_private_session_create_capability(uuid)\",\n] as const;\nconst SESSION_AUTHORITY_ROUTINES = new Set<string>([\n LEGACY_FORK_SESSION_CONTENT_ROUTINE,\n FORK_SESSION_CONTENT_ROUTINE,\n MESSAGE_FORK_SESSION_CONTENT_ROUTINE,\n REPLAY_APPLIED_SESSION_FORK_ROUTINE,\n SESSION_TENANCY_ACTIVATED_ROUTINE,\n SESSION_TENANCY_ANY_ACTIVATION_ROUTINE,\n SESSION_TENANCY_QUIESCENCE_ROUTINE,\n PERSONAL_RESOURCE_ATTEMPT_RESOLVER_ROUTINE,\n ...USER_RESOURCE_LIFECYCLE_ROUTINES,\n ...CONNECTION_AUTHORITY_ROUTINES,\n ...SCHEDULED_PERSONAL_RESOURCE_ROUTINES,\n SESSION_PRIVATE_ACTOR_VISIBLE_ROUTINE,\n SESSION_REFERENCE_VISIBLE_ROUTINE,\n SESSION_VISIBILITY_LIFECYCLE_CAPABILITY_ROUTINE,\n ...PRIVATE_SESSION_CREATE_CAPABILITY_ROUTINES,\n TRANSITION_SESSION_VISIBILITY_ROUTINE,\n ...TASK_NOTE_CAPABILITY_ROUTINES,\n ...WORK_CLAIM_CAPABILITY_ROUTINES,\n COMPANY_BRAIN_CONTEXT_SELECTION_ROUTINE,\n COMPANY_BRAIN_CONTEXT_INSPECTION_ROUTINE,\n]);\nconst XAI_CREATE_CREDENTIAL_ROUTINE =\n \"create_xai_subscription_credential(uuid, uuid, text, text, text, text, text, text, text, timestamp with time zone)\";\nconst XAI_DISCONNECT_CREDENTIAL_ROUTINE =\n \"disconnect_xai_subscription_credential(uuid, uuid, text, uuid, jsonb)\";\nconst XAI_SNAPSHOT_VALIDATOR_ROUTINE = \"xai_provider_account_authority_snapshot_v1_valid(jsonb)\";\nconst XAI_AUTHORITY_LIVE_ROUTINE =\n \"xai_subscription_authority_live(uuid, uuid, text, uuid, text, uuid, uuid, bigint)\";\nconst XAI_POOL_VISIBLE_ROUTINE = \"xai_subscription_pool_visible(uuid, uuid, text, text, uuid)\";\nconst XAI_RESOLVE_POOL_ROUTINE = \"resolve_xai_authority_pool(uuid, uuid, text, jsonb)\";\nconst XAI_REVALIDATE_CREDENTIAL_ROUTINE =\n \"revalidate_xai_subscription_authority(uuid, text, uuid, jsonb)\";\nconst XAI_AUTHORITY_TABLES = [\n \"organization_memberships\",\n \"organization_user_resource_authorities\",\n \"workspace_memberships\",\n \"xai_subscription_credentials\",\n] as const;\n\nexport const RUNTIME_TARGET_SCHEMA_CAPABILITY_ROUTINES = [\n \"skill_apply_lifecycle(uuid, uuid, jsonb, jsonb)\",\n COMPANY_BRAIN_CONTEXT_INSPECTION_ROUTINE,\n COMPANY_BRAIN_CONTEXT_SELECTION_ROUTINE,\n ...COMPANY_PROFILE_AGENT_ADMIN_ROUTINES,\n GOVERNED_LEARNING_EVALUATION_ROUTINE,\n ...GOVERNED_LEARNING_ACTIVATION_ROUTINES,\n ...GOVERNED_LEARNING_INSPECTION_ROUTINES,\n FORK_SESSION_CONTENT_ROUTINE,\n MESSAGE_FORK_SESSION_CONTENT_ROUTINE,\n LEGACY_FORK_SESSION_CONTENT_ROUTINE,\n REPLAY_APPLIED_SESSION_FORK_ROUTINE,\n SESSION_TENANCY_ACTIVATED_ROUTINE,\n SESSION_TENANCY_ANY_ACTIVATION_ROUTINE,\n XAI_AUTHORITY_LIVE_ROUTINE,\n XAI_CREATE_CREDENTIAL_ROUTINE,\n XAI_DISCONNECT_CREDENTIAL_ROUTINE,\n GOOGLE_DRIVE_DOCUMENT_CITATION_ROUTINE,\n GOOGLE_DRIVE_FILE_AUTHORIZATION_ROUTINE,\n KNOWLEDGE_SOURCE_SYNC_LOCK_AUTHORITY_ROUTINE,\n MANAGED_HUMAN_PERSONAL_WORKSPACE_ROUTINE,\n ...ORGANIZATION_MEMBERSHIP_LIFECYCLE_ROUTINES,\n ...ORGANIZATION_PRIVATE_SESSION_ROUTINES,\n ...PRIVATE_SESSION_CREATE_CAPABILITY_ROUTINES,\n PERSONAL_RESOURCE_ATTEMPT_RESOLVER_ROUTINE,\n ...USER_RESOURCE_LIFECYCLE_ROUTINES,\n PREFERENCE_KNOWLEDGE_PROPOSAL_ROUTINE,\n ...VARIABLE_SET_AUTHORITY_ROUTINES,\n ...CONNECTION_AUTHORITY_ROUTINES,\n ...PERSONAL_GITHUB_REPOSITORY_AUTHORITY_ROUTINES,\n ...PERSONAL_DOCUMENT_AUTHORITY_ROUTINES,\n ...DOCUMENT_MIGRATION_AUTHORITY_ROUTINES,\n ...SCOPED_COMPUTE_AUTHORITY_ROUTINES,\n ...SCHEDULED_PERSONAL_RESOURCE_ROUTINES,\n ...CANONICAL_HUMAN_IDENTITY_ROUTINES,\n ...MANAGED_AUTH_SESSION_SET_ROUTINES,\n ...ORGANIZATION_RECOVERY_ROUTINES,\n ...TASK_NOTE_CAPABILITY_ROUTINES,\n ...WORK_CLAIM_CAPABILITY_ROUTINES,\n SESSION_PRIVATE_ACTOR_VISIBLE_ROUTINE,\n SESSION_REFERENCE_VISIBLE_ROUTINE,\n SESSION_VISIBILITY_LIFECYCLE_CAPABILITY_ROUTINE,\n TRANSITION_SESSION_VISIBILITY_ROUTINE,\n XAI_POOL_VISIBLE_ROUTINE,\n XAI_RESOLVE_POOL_ROUTINE,\n XAI_REVALIDATE_CREDENTIAL_ROUTINE,\n XAI_SNAPSHOT_VALIDATOR_ROUTINE,\n] as const;\n\n/**\n * Boolean-only predicates that shared-table RLS policies must be able to\n * evaluate under table owners and SECURITY DEFINER roles unknown at migration\n * time. The capability ledger and the routine that mints its opaque token stay\n * private; only these exact policy predicates may be PUBLIC-executable.\n */\nexport const RUNTIME_TARGET_SCHEMA_PUBLIC_POLICY_PREDICATE_ROUTINES = [\n CONNECTION_CONVERGENCE_AUDIT_CAPABILITY_ROUTINE,\n] as const;\nconst RUNTIME_TARGET_SCHEMA_PUBLIC_POLICY_PREDICATE_ROUTINE_SET = new Set<string>(\n RUNTIME_TARGET_SCHEMA_PUBLIC_POLICY_PREDICATE_ROUTINES,\n);\n\n/** Owner-internal helpers that must exist but must never be callable by the runtime role. */\nexport const RUNTIME_TARGET_SCHEMA_FORBIDDEN_ROUTINES = [\n ADDITIONAL_ORGANIZATION_SESSION_TENANCY_ACTIVATION_ROUTINE,\n AUTOMATIC_SESSION_TITLE_QUARANTINE_FENCE_ROUTINE,\n ORGANIZATION_PRIVATE_SESSIONS_ENABLED_ROUTINE,\n GREENFIELD_SESSION_TENANCY_ACTIVATION_ROUTINE,\n SESSION_TENANCY_QUIESCENCE_ROUTINE,\n TENANCY_BACKFILL_ACTIVATION_EVIDENCE_ROUTINE,\n ...DOCUMENT_MIGRATION_AUDIT_INTERNAL_ROUTINES,\n] as const;\n\nexport const RUNTIME_TARGET_SCHEMA_INVOKER_ROUTINES = [\n \"resolve_workspace_codex_subscription_source(uuid, uuid)\",\n SESSION_REFERENCE_VISIBLE_ROUTINE,\n XAI_SNAPSHOT_VALIDATOR_ROUTINE,\n] as const;\nconst RUNTIME_TARGET_SCHEMA_INVOKER_ROUTINE_SET = new Set<string>(\n RUNTIME_TARGET_SCHEMA_INVOKER_ROUTINES,\n);\n\n/**\n * The complete standalone tenant-table contract. Adding or removing a\n * FORCE-RLS table is an architectural change: update this list in the same\n * commit as the migration so startup cannot silently accept an unreviewed gap.\n */\nexport const FORCE_RLS_TABLES = [\n \"additional_organization_creation_receipts\",\n \"agent_run_states\",\n \"api_keys\",\n \"attached_browser_devices\",\n \"attached_browser_inventories\",\n \"audit_events\",\n \"auth_runs\",\n \"automation_run_event_links\",\n \"automation_runs\",\n \"automation_sources\",\n \"automation_trigger_events\",\n \"automation_trigger_revisions\",\n \"automation_triggers\",\n \"billing_customers\",\n \"browser_identities\",\n \"browser_revision_components\",\n \"browser_revisions\",\n \"browser_session_associations\",\n \"browser_sessions\",\n \"browser_state_artifacts\",\n \"browser_state_uploads\",\n \"canonical_human_identities\",\n \"canonical_human_identity_operations\",\n \"canonical_human_identity_subjects\",\n \"canonical_human_login_bindings\",\n \"capability_api_facets\",\n \"capability_catalog_items\",\n \"capability_component_owners\",\n \"capability_facet_installations\",\n \"capability_facets\",\n \"capability_installations\",\n \"capability_integration_facets\",\n \"capability_mcp_facets\",\n \"capability_operations\",\n \"capability_plugin_installations\",\n \"capability_plugin_versions\",\n \"capability_plugins\",\n \"capability_skill_facets\",\n \"capability_skill_files\",\n \"channels\",\n \"codex_apps_settings\",\n \"codex_capacity_waiters\",\n \"codex_credential_leases\",\n \"codex_reset_redemption_attempts\",\n \"codex_rotation_settings\",\n \"codex_subscription_credentials\",\n \"company_brain_context_selection_receipts\",\n \"company_brain_preference_proposal_receipts\",\n \"company_brain_turn_context_snapshots\",\n \"company_profile_activation_events\",\n \"company_profile_agent_automatic_activation_receipts\",\n \"company_profile_agent_confirmation_receipts\",\n \"company_profile_agent_proposal_receipts\",\n \"company_profile_heads\",\n \"company_profile_revisions\",\n \"company_profile_snapshots\",\n \"composer_drafts\",\n \"computer_session_associations\",\n \"computer_sessions\",\n \"connect_attempts\",\n \"connection_disconnect_operations\",\n \"connection_use_audit_facts\",\n \"connection_use_once_consumption_receipts\",\n \"connections\",\n \"connector_action_policies\",\n \"connector_action_requests\",\n \"credit_ledger_entries\",\n \"device_enrollment_requests\",\n \"document_authority_reclassifications\",\n \"document_bases\",\n \"document_chunks\",\n \"document_default_collection_backfill_operations\",\n \"document_default_collection_backfill_receipts\",\n \"document_default_collection_backfill_runs\",\n \"documents\",\n \"editable_artifact_blob_refs\",\n \"editable_artifact_idempotency_receipts\",\n \"editable_artifact_live_outbox\",\n \"editable_artifact_live_tickets\",\n \"editable_artifact_materialization_jobs\",\n \"editable_artifact_materialization_results\",\n \"editable_artifact_operations\",\n \"editable_artifact_replica_leases\",\n \"editable_artifact_scope_authorization_heads\",\n \"editable_artifact_sequence_checkpoints\",\n \"editable_artifact_session_links\",\n \"editable_artifact_snapshots\",\n \"editable_artifact_transactions\",\n \"editable_artifact_undo_claims\",\n \"editable_artifact_versions\",\n \"editable_artifacts\",\n \"enrollments\",\n \"external_identities\",\n \"external_identity_links\",\n \"external_link_task_authorities\",\n \"external_link_turn_authorities\",\n \"feedback_submissions\",\n \"file_uploads\",\n \"files\",\n \"generated_image_artifacts\",\n \"generated_video_artifacts\",\n \"github_installation_repositories\",\n \"github_installations\",\n \"google_drive_object_acl_evidence\",\n \"google_drive_object_acl_principals\",\n \"governed_learning_activation_receipts\",\n \"governed_learning_activation_undo_receipts\",\n \"governed_learning_decision_receipts\",\n \"host_export_config\",\n \"host_export_consumers\",\n \"host_export_cursor_state\",\n \"host_export_dead_letters\",\n \"host_export_outbox\",\n \"host_mcp_bindings\",\n \"host_mcp_delegations\",\n \"host_mcp_task_authorities\",\n \"host_mcp_turn_authorities\",\n \"image_generation_operations\",\n \"import_batches\",\n \"integration_facet_binding_owners\",\n \"integration_facet_bindings\",\n \"integration_facet_definitions\",\n \"integration_oauth_state_nonces\",\n \"integration_spec_revisions\",\n \"integration_tools\",\n \"interaction_interventions\",\n \"interaction_operations\",\n \"interaction_resource_operations\",\n \"knowledge_change_proposals\",\n \"knowledge_claim_evidence\",\n \"knowledge_claim_relations\",\n \"knowledge_claim_reviews\",\n \"knowledge_claims\",\n \"knowledge_document_versions\",\n \"knowledge_entities\",\n \"knowledge_entity_aliases\",\n \"knowledge_facts\",\n \"knowledge_lifecycle_events\",\n \"knowledge_memories\",\n \"knowledge_memory_lifecycle_events\",\n \"knowledge_memory_relationships\",\n \"knowledge_operation_receipts\",\n \"knowledge_providers\",\n \"knowledge_source_acl_versions\",\n \"knowledge_source_objects\",\n \"knowledge_source_sync_index_obligations\",\n \"knowledge_source_sync_item_outcomes\",\n \"knowledge_source_sync_object_observations\",\n \"knowledge_source_sync_states\",\n \"knowledge_source_sync_wakes\",\n \"knowledge_sources\",\n \"knowledge_sync_runs\",\n \"machine_metrics_latest\",\n \"machine_metrics_series\",\n \"machine_removal_operations\",\n \"managed_auth_actor_mutation_leases\",\n \"managed_auth_browser_installations\",\n \"managed_auth_login_return_intents\",\n \"managed_auth_login_slots\",\n \"managed_auth_login_transaction_rate_limits\",\n \"managed_auth_login_transactions\",\n \"managed_auth_session_set_operations\",\n \"managed_auth_session_sets\",\n \"memory_slack_publication_configurations\",\n \"memory_slack_publication_receipts\",\n \"memory_slack_publications\",\n \"model_call_facts\",\n \"network_routes\",\n \"new_session_drafts\",\n \"organization_codex_rotation_settings\",\n \"organization_company_profile_agent_policies\",\n \"organization_company_profile_agent_policy_events\",\n \"organization_invitation_binding_events\",\n \"organization_membership_invitations\",\n \"organization_membership_lifecycle_events\",\n \"organization_membership_operation_receipts\",\n \"organization_memberships\",\n \"organization_model_provider_connection_operations\",\n \"organization_model_provider_connections\",\n \"organization_model_provider_custom_models\",\n \"organization_private_session_setting_events\",\n \"organization_private_session_settings\",\n \"organization_profile_events\",\n \"organization_recovery_approvals\",\n \"organization_recovery_command_receipts\",\n \"organization_recovery_custodian_acceptances\",\n \"organization_recovery_custodians\",\n \"organization_recovery_events\",\n \"organization_recovery_notification_attempts\",\n \"organization_recovery_notification_outbox\",\n \"organization_recovery_operations\",\n \"organization_recovery_policies\",\n \"organization_recovery_policy_heads\",\n \"organization_shared_workspace_administration_capabilities\",\n \"organization_user_resource_authorities\",\n \"organization_user_resource_grants\",\n \"organization_user_retention_deletion_events\",\n \"organization_user_retention_deletions\",\n \"organization_user_retention_object_deletion_receipts\",\n \"organization_user_retention_object_obligations\",\n \"organization_user_retention_policies\",\n \"organization_user_setup_deliveries\",\n \"organization_user_setup_delivery_attempts\",\n \"organization_user_setup_intents\",\n \"organization_workspace_lifecycle_events\",\n \"organization_workspace_operation_receipts\",\n \"pack_installation_components\",\n \"pack_installations\",\n \"personal_document_once_consumption_receipts\",\n \"personal_github_repository_selection_heads\",\n \"personal_github_repository_selection_operations\",\n \"personal_github_repository_selections\",\n \"personal_resource_once_consumption_receipts\",\n \"pr_review_app_registrations\",\n \"pr_review_managed_github_authority_nonces\",\n \"pr_review_repository_bindings\",\n \"preference_registry_events\",\n \"preference_registry_preferences\",\n \"preference_registry_revisions\",\n \"preference_registry_snapshots\",\n \"private_session_create_capabilities\",\n \"remember_knowledge_confirmation_receipts\",\n \"remember_knowledge_memory_materializations\",\n \"retained_screenshot_artifacts\",\n \"rig_changes\",\n \"rig_versions\",\n \"rigs\",\n \"sandbox_checkpoint_artifacts\",\n \"sandbox_lease_holders\",\n \"sandbox_leases\",\n \"sandbox_pty_sessions\",\n \"sandbox_retained_processes\",\n \"sandbox_session_envelopes\",\n \"sandbox_workspace_mutation_admissions\",\n \"sandboxes\",\n \"scheduled_task_connection_authority_snapshots\",\n \"scheduled_task_personal_resource_authorities\",\n \"scheduled_task_personal_resource_snapshots\",\n \"scheduled_task_reusable_connection_materializations\",\n \"scheduled_task_revision_authorities\",\n \"scheduled_task_run_connection_authority_snapshots\",\n \"scheduled_task_run_personal_resource_admissions\",\n \"scheduled_task_run_personal_resource_once_receipts\",\n \"scheduled_task_run_personal_resource_snapshots\",\n \"scheduled_task_runs\",\n \"scheduled_tasks\",\n \"self_service_organization_setup_receipts\",\n \"session_attempt_codemode_calls\",\n \"session_attempt_connected_machine_authorizations\",\n \"session_attempt_interruptions\",\n \"session_attempt_model_context_snapshots\",\n \"session_attempt_personal_document_admissions\",\n \"session_attempt_personal_document_snapshots\",\n \"session_attempt_personal_resource_admissions\",\n \"session_attempt_personal_resource_snapshots\",\n \"session_attempt_tool_catalogs\",\n \"session_background_commands\",\n \"session_command_receipts\",\n \"session_event_cursors\",\n \"session_events\",\n \"session_goal_revisions\",\n \"session_goals\",\n \"session_history_items\",\n \"session_human_input_requests\",\n \"session_list_snapshots\",\n \"session_mcp_servers\",\n \"session_pending_tool_calls\",\n \"session_pins\",\n \"session_realtime_connections\",\n \"session_realtime_context_projections\",\n \"session_realtime_entries\",\n \"session_realtime_modes\",\n \"session_recordings\",\n \"session_spawn_denials\",\n \"session_stream_acknowledgments\",\n \"session_system_update_outbox\",\n \"session_system_updates\",\n \"session_tenancy_activations\",\n \"session_tenancy_additional_organization_activation_evidence\",\n \"session_tenancy_greenfield_activation_evidence\",\n \"session_turn_attempts\",\n \"session_turn_startup_milestones\",\n \"session_turns\",\n \"session_variable_set_attachments\",\n \"session_visibility_write_capabilities\",\n \"session_work_claim_revisions\",\n \"session_work_claim_write_capabilities\",\n \"session_work_claims\",\n \"session_workflow_wake_outbox\",\n \"sessions\",\n \"site_auth_connections\",\n \"skill_config_conversion_receipts\",\n \"skill_source_bindings\",\n \"skill_write_receipts\",\n \"slack_app_home_refreshes\",\n \"slack_bot_delete_operations\",\n \"slack_bot_post_operations\",\n \"slack_bot_update_operations\",\n \"slack_bot_user_links\",\n \"slack_channel_routes\",\n \"slack_installation_bindings\",\n \"slack_interaction_action_handles\",\n \"slack_interaction_inbox\",\n \"slack_interaction_progress_deliveries\",\n \"slack_interactions\",\n \"slack_route_prompt_options\",\n \"slack_route_prompts\",\n \"slack_shared_task_origins\",\n \"slack_task_policy_activation_events\",\n \"slack_task_policy_heads\",\n \"slack_task_policy_revisions\",\n \"slack_user_dm_routes\",\n \"slack_user_link_access_request_operations\",\n \"slack_user_link_access_requests\",\n \"social_connections\",\n \"social_posts\",\n \"task_note_events\",\n \"task_note_knowledge_promotion_capabilities\",\n \"task_note_replacement_receipts\",\n \"task_note_write_capabilities\",\n \"task_notes\",\n \"temporal_schedule_cleanup_outbox\",\n \"tenancy_backfill_receipts\",\n \"tenancy_backfill_unresolved_rows\",\n \"tool_gateway_approval_capabilities\",\n \"transcription_recording_chunks\",\n \"transcription_recording_objects\",\n \"transcription_recording_segments\",\n \"transcription_recordings\",\n \"turn_connection_authority_snapshots\",\n \"turn_personal_resource_attachment_receipts\",\n \"turn_personal_resource_once_receipts\",\n \"turn_personal_resource_snapshots\",\n \"usage_events\",\n \"video_generation_operations\",\n \"video_generation_references\",\n \"workspace_artifact_events\",\n \"workspace_artifact_uploads\",\n \"workspace_artifact_versions\",\n \"workspace_artifacts\",\n \"workspace_captures\",\n \"workspace_codex_subscription_preferences\",\n \"workspace_control_events\",\n \"workspace_gateway_custom_models\",\n \"workspace_inference_controls\",\n \"workspace_instruction_policy_activation_events\",\n \"workspace_instruction_policy_deactivation_events\",\n \"workspace_instruction_policy_heads\",\n \"workspace_instruction_policy_onboarding_proposals\",\n \"workspace_instruction_policy_revisions\",\n \"workspace_instruction_policy_snapshots\",\n \"workspace_interaction_revisions\",\n \"workspace_learning_policy_activation_events\",\n \"workspace_learning_policy_heads\",\n \"workspace_learning_policy_revisions\",\n \"workspace_learning_policy_snapshots\",\n \"workspace_model_policies\",\n \"workspace_packs\",\n \"workspace_screenshot_quotas\",\n \"workspace_session_activity_revisions\",\n \"workspace_variable_set_variables\",\n \"workspace_variable_sets\",\n \"workspace_video_generation_policies\",\n \"workspace_video_generation_quotas\",\n \"xai_capacity_waiters\",\n \"xai_credential_leases\",\n \"xai_rotation_settings\",\n \"xai_session_account_pins\",\n \"xai_subscription_credentials\",\n] as const;\n\n/**\n * Deployment-global and authentication tables used by ordinary API/worker\n * traffic. They intentionally do not carry workspace RLS: their access model\n * is implemented by the authentication/access layer or by exact global keys.\n */\nexport const NON_RLS_RUNTIME_TABLES = [\n \"auth_identities\",\n \"auth_rate_limits\",\n \"auth_sessions\",\n \"auth_users\",\n \"auth_verifications\",\n \"automation_webhook_endpoints\",\n \"deployment_model_catalog\",\n \"integration_oauth_clients\",\n \"managed_accounts\",\n \"mcp_oauth_access_tokens\",\n \"mcp_oauth_authorization_codes\",\n \"mcp_oauth_authorization_requests\",\n \"mcp_oauth_clients\",\n \"mcp_oauth_refresh_tokens\",\n \"nested_agent_depth_configuration\",\n \"pr_review_managed_github_routes\",\n \"stripe_webhook_events\",\n \"workspace_memberships\",\n \"workspaces\",\n] as const;\n\n/**\n * Exact full-CRUD class for the standalone runtime role. This is deliberately\n * explicit instead of being derived from FORCE_RLS_TABLES: adding a protected\n * table must not silently grant it broader DML than its migration intended.\n */\nexport const RUNTIME_FULL_DML_TABLES = [\n \"agent_run_states\",\n \"api_keys\",\n \"audit_events\",\n \"auth_identities\",\n \"auth_rate_limits\",\n \"auth_sessions\",\n \"auth_users\",\n \"auth_verifications\",\n \"automation_run_event_links\",\n \"automation_runs\",\n \"automation_sources\",\n \"automation_trigger_events\",\n \"automation_trigger_revisions\",\n \"automation_triggers\",\n \"automation_webhook_endpoints\",\n \"billing_customers\",\n \"browser_session_associations\",\n \"capability_catalog_items\",\n \"capability_component_owners\",\n \"capability_facet_installations\",\n \"capability_installations\",\n \"capability_operations\",\n \"capability_plugin_installations\",\n \"channels\",\n \"codex_apps_settings\",\n \"codex_capacity_waiters\",\n \"codex_credential_leases\",\n \"codex_reset_redemption_attempts\",\n \"codex_rotation_settings\",\n \"codex_subscription_credentials\",\n \"composer_drafts\",\n \"computer_session_associations\",\n \"connect_attempts\",\n \"connection_disconnect_operations\",\n \"connections\",\n \"connector_action_policies\",\n \"connector_action_requests\",\n \"credit_ledger_entries\",\n \"device_enrollment_requests\",\n \"document_bases\",\n \"document_chunks\",\n \"documents\",\n \"editable_artifact_replica_leases\",\n \"enrollments\",\n \"file_uploads\",\n \"files\",\n \"generated_image_artifacts\",\n \"generated_video_artifacts\",\n \"github_installation_repositories\",\n \"github_installations\",\n \"host_mcp_bindings\",\n \"host_mcp_delegations\",\n \"image_generation_operations\",\n \"import_batches\",\n \"integration_facet_binding_owners\",\n \"integration_facet_bindings\",\n \"integration_oauth_clients\",\n \"integration_oauth_state_nonces\",\n \"knowledge_memories\",\n \"knowledge_source_sync_index_obligations\",\n \"knowledge_source_sync_item_outcomes\",\n \"knowledge_source_sync_object_observations\",\n \"knowledge_source_sync_states\",\n \"knowledge_source_sync_wakes\",\n \"machine_metrics_latest\",\n \"machine_metrics_series\",\n \"machine_removal_operations\",\n \"managed_accounts\",\n \"mcp_oauth_access_tokens\",\n \"mcp_oauth_authorization_codes\",\n \"mcp_oauth_authorization_requests\",\n \"mcp_oauth_clients\",\n \"mcp_oauth_refresh_tokens\",\n \"memory_slack_publication_configurations\",\n \"memory_slack_publication_receipts\",\n \"memory_slack_publications\",\n \"model_call_facts\",\n \"new_session_drafts\",\n \"organization_codex_rotation_settings\",\n \"organization_model_provider_connection_operations\",\n \"organization_model_provider_connections\",\n \"organization_model_provider_custom_models\",\n \"pack_installation_components\",\n \"pack_installations\",\n \"pr_review_app_registrations\",\n \"pr_review_managed_github_routes\",\n \"pr_review_repository_bindings\",\n \"retained_screenshot_artifacts\",\n \"rig_changes\",\n \"rig_versions\",\n \"rigs\",\n \"sandbox_checkpoint_artifacts\",\n \"sandbox_lease_holders\",\n \"sandbox_leases\",\n \"sandbox_pty_sessions\",\n \"sandbox_retained_processes\",\n \"sandbox_session_envelopes\",\n \"sandbox_workspace_mutation_admissions\",\n \"sandboxes\",\n \"session_attempt_interruptions\",\n \"session_background_commands\",\n \"session_command_receipts\",\n \"session_event_cursors\",\n \"session_events\",\n \"session_goals\",\n \"session_history_items\",\n \"session_human_input_requests\",\n \"session_list_snapshots\",\n \"session_mcp_servers\",\n \"session_pending_tool_calls\",\n \"session_pins\",\n \"session_realtime_connections\",\n \"session_realtime_context_projections\",\n \"session_realtime_entries\",\n \"session_realtime_modes\",\n \"session_recordings\",\n \"session_stream_acknowledgments\",\n \"session_system_update_outbox\",\n \"session_system_updates\",\n \"session_turn_attempts\",\n \"session_turns\",\n \"session_workflow_wake_outbox\",\n \"sessions\",\n \"slack_app_home_refreshes\",\n \"slack_bot_delete_operations\",\n \"slack_bot_post_operations\",\n \"slack_bot_update_operations\",\n \"slack_bot_user_links\",\n \"slack_channel_routes\",\n \"slack_interaction_action_handles\",\n \"slack_interaction_inbox\",\n \"slack_interaction_progress_deliveries\",\n \"slack_interactions\",\n \"slack_route_prompt_options\",\n \"slack_route_prompts\",\n \"slack_user_dm_routes\",\n \"social_connections\",\n \"social_posts\",\n \"stripe_webhook_events\",\n \"tool_gateway_approval_capabilities\",\n \"transcription_recording_chunks\",\n \"transcription_recording_objects\",\n \"transcription_recording_segments\",\n \"transcription_recordings\",\n \"usage_events\",\n \"video_generation_operations\",\n \"video_generation_references\",\n \"workspace_artifact_uploads\",\n \"workspace_artifacts\",\n \"workspace_captures\",\n \"workspace_codex_subscription_preferences\",\n \"workspace_control_events\",\n \"workspace_gateway_custom_models\",\n \"workspace_inference_controls\",\n \"workspace_instruction_policy_heads\",\n \"workspace_memberships\",\n \"workspace_model_policies\",\n \"workspace_packs\",\n \"workspace_screenshot_quotas\",\n \"workspace_video_generation_policies\",\n \"workspace_video_generation_quotas\",\n \"workspaces\",\n \"xai_capacity_waiters\",\n \"xai_credential_leases\",\n \"xai_rotation_settings\",\n \"xai_session_account_pins\",\n \"xai_subscription_credentials\",\n] as const;\n\n/** Configuration and lifecycle-owned audit rows are read-only at runtime. */\nexport const RUNTIME_READ_ONLY_TABLES = [\n \"company_profile_activation_events\",\n \"company_profile_heads\",\n \"company_profile_snapshots\",\n \"deployment_model_catalog\",\n \"document_authority_reclassifications\",\n \"knowledge_lifecycle_events\",\n \"knowledge_memory_lifecycle_events\",\n \"knowledge_memory_relationships\",\n \"nested_agent_depth_configuration\",\n \"preference_registry_events\",\n \"preference_registry_snapshots\",\n \"session_tenancy_activations\",\n \"session_work_claims\",\n \"skill_source_bindings\",\n \"skill_write_receipts\",\n \"slack_installation_bindings\",\n \"slack_task_policy_activation_events\",\n \"slack_task_policy_heads\",\n \"slack_task_policy_revisions\",\n \"workspace_instruction_policy_deactivation_events\",\n \"workspace_instruction_policy_snapshots\",\n \"workspace_learning_policy_activation_events\",\n \"workspace_learning_policy_heads\",\n \"workspace_learning_policy_snapshots\",\n] as const;\n\n/** Existing runtime authorities that may be observed and advanced, never created or deleted. */\nexport const RUNTIME_READ_UPDATE_TABLES = [\"workspace_session_activity_revisions\"] as const;\n\n/** Append-only evidence/revision tables are insertable and queryable, never mutable. */\nexport const RUNTIME_READ_INSERT_TABLES = [\n \"browser_revision_components\",\n \"browser_revisions\",\n \"company_profile_revisions\",\n \"editable_artifact_blob_refs\",\n \"editable_artifact_idempotency_receipts\",\n \"editable_artifact_live_outbox\",\n \"editable_artifact_materialization_jobs\",\n \"editable_artifact_materialization_results\",\n \"editable_artifact_operations\",\n \"editable_artifact_sequence_checkpoints\",\n \"editable_artifact_snapshots\",\n \"editable_artifact_transactions\",\n \"editable_artifact_undo_claims\",\n \"editable_artifact_versions\",\n \"external_link_task_authorities\",\n \"external_link_turn_authorities\",\n \"feedback_submissions\",\n \"google_drive_object_acl_evidence\",\n \"google_drive_object_acl_principals\",\n \"host_mcp_task_authorities\",\n \"host_mcp_turn_authorities\",\n \"knowledge_change_proposals\",\n \"knowledge_claim_evidence\",\n \"knowledge_claim_relations\",\n \"knowledge_claim_reviews\",\n \"knowledge_claims\",\n \"knowledge_document_versions\",\n \"knowledge_entities\",\n \"knowledge_entity_aliases\",\n \"knowledge_facts\",\n \"knowledge_operation_receipts\",\n \"knowledge_providers\",\n \"knowledge_source_acl_versions\",\n \"knowledge_source_objects\",\n \"knowledge_sources\",\n \"knowledge_sync_runs\",\n \"pr_review_managed_github_authority_nonces\",\n \"preference_registry_preferences\",\n \"preference_registry_revisions\",\n \"session_attempt_tool_catalogs\",\n \"session_goal_revisions\",\n \"session_spawn_denials\",\n \"slack_shared_task_origins\",\n \"slack_user_link_access_request_operations\",\n \"temporal_schedule_cleanup_outbox\",\n \"workspace_artifact_events\",\n \"workspace_artifact_versions\",\n \"workspace_instruction_policy_activation_events\",\n \"workspace_instruction_policy_onboarding_proposals\",\n \"workspace_instruction_policy_revisions\",\n \"workspace_learning_policy_revisions\",\n] as const;\n\n/** Durable operation journals are append/read plus claim/settle updates, never deletes. */\nexport const RUNTIME_READ_INSERT_UPDATE_TABLES = [\n \"attached_browser_devices\",\n \"attached_browser_inventories\",\n \"auth_runs\",\n \"browser_identities\",\n \"browser_sessions\",\n \"browser_state_artifacts\",\n \"browser_state_uploads\",\n \"capability_api_facets\",\n \"capability_facets\",\n \"capability_integration_facets\",\n \"capability_mcp_facets\",\n \"capability_plugin_versions\",\n \"capability_plugins\",\n \"capability_skill_facets\",\n \"capability_skill_files\",\n \"computer_sessions\",\n \"editable_artifact_session_links\",\n \"editable_artifacts\",\n \"external_identity_links\",\n \"integration_facet_definitions\",\n \"integration_spec_revisions\",\n \"integration_tools\",\n \"interaction_interventions\",\n \"interaction_operations\",\n \"interaction_resource_operations\",\n \"network_routes\",\n \"scheduled_task_runs\",\n \"scheduled_tasks\",\n \"session_attempt_codemode_calls\",\n \"session_attempt_model_context_snapshots\",\n \"session_turn_startup_milestones\",\n \"site_auth_connections\",\n \"slack_user_link_access_requests\",\n \"workspace_interaction_revisions\",\n] as const;\n\n/**\n * These FORCE-RLS tables are owned by security-definer host-export routines.\n * The ordinary application role must have no direct table privileges on them.\n */\nexport const PROTECTED_NO_DIRECT_DML_TABLES = [\n \"additional_organization_creation_receipts\",\n \"canonical_human_identities\",\n \"canonical_human_identity_operations\",\n \"canonical_human_identity_subjects\",\n \"canonical_human_login_bindings\",\n \"company_brain_context_selection_receipts\",\n \"company_brain_preference_proposal_receipts\",\n \"company_brain_turn_context_snapshots\",\n \"company_profile_agent_automatic_activation_receipts\",\n \"company_profile_agent_confirmation_receipts\",\n \"company_profile_agent_proposal_receipts\",\n \"connection_use_audit_facts\",\n \"connection_use_once_consumption_receipts\",\n \"document_default_collection_backfill_operations\",\n \"document_default_collection_backfill_receipts\",\n \"document_default_collection_backfill_runs\",\n \"editable_artifact_live_tickets\",\n \"editable_artifact_scope_authorization_heads\",\n \"external_identities\",\n \"governed_learning_activation_receipts\",\n \"governed_learning_activation_undo_receipts\",\n \"governed_learning_decision_receipts\",\n \"host_export_config\",\n \"host_export_consumers\",\n \"host_export_cursor_state\",\n \"host_export_dead_letters\",\n \"host_export_outbox\",\n \"managed_auth_actor_mutation_leases\",\n \"managed_auth_browser_installations\",\n \"managed_auth_login_return_intents\",\n \"managed_auth_login_slots\",\n \"managed_auth_login_transaction_rate_limits\",\n \"managed_auth_login_transactions\",\n \"managed_auth_session_set_operations\",\n \"managed_auth_session_sets\",\n \"organization_company_profile_agent_policies\",\n \"organization_company_profile_agent_policy_events\",\n \"organization_invitation_binding_events\",\n \"organization_membership_invitations\",\n \"organization_membership_lifecycle_events\",\n \"organization_membership_operation_receipts\",\n \"organization_memberships\",\n \"organization_private_session_setting_events\",\n \"organization_private_session_settings\",\n \"organization_profile_events\",\n \"organization_recovery_approvals\",\n \"organization_recovery_command_receipts\",\n \"organization_recovery_custodian_acceptances\",\n \"organization_recovery_custodians\",\n \"organization_recovery_events\",\n \"organization_recovery_notification_attempts\",\n \"organization_recovery_notification_outbox\",\n \"organization_recovery_operations\",\n \"organization_recovery_policies\",\n \"organization_recovery_policy_heads\",\n \"organization_shared_workspace_administration_capabilities\",\n \"organization_user_resource_authorities\",\n \"organization_user_resource_grants\",\n \"organization_user_retention_deletion_events\",\n \"organization_user_retention_deletions\",\n \"organization_user_retention_object_deletion_receipts\",\n \"organization_user_retention_object_obligations\",\n \"organization_user_retention_policies\",\n \"organization_user_setup_deliveries\",\n \"organization_user_setup_delivery_attempts\",\n \"organization_user_setup_intents\",\n \"organization_workspace_lifecycle_events\",\n \"organization_workspace_operation_receipts\",\n \"personal_document_once_consumption_receipts\",\n \"personal_github_repository_selection_heads\",\n \"personal_github_repository_selection_operations\",\n \"personal_github_repository_selections\",\n \"personal_resource_once_consumption_receipts\",\n \"private_session_create_capabilities\",\n \"remember_knowledge_confirmation_receipts\",\n \"remember_knowledge_memory_materializations\",\n \"scheduled_task_connection_authority_snapshots\",\n \"scheduled_task_personal_resource_authorities\",\n \"scheduled_task_personal_resource_snapshots\",\n \"scheduled_task_reusable_connection_materializations\",\n \"scheduled_task_revision_authorities\",\n \"scheduled_task_run_connection_authority_snapshots\",\n \"scheduled_task_run_personal_resource_admissions\",\n \"scheduled_task_run_personal_resource_once_receipts\",\n \"scheduled_task_run_personal_resource_snapshots\",\n \"self_service_organization_setup_receipts\",\n \"session_attempt_connected_machine_authorizations\",\n \"session_attempt_personal_document_admissions\",\n \"session_attempt_personal_document_snapshots\",\n \"session_attempt_personal_resource_admissions\",\n \"session_attempt_personal_resource_snapshots\",\n \"session_tenancy_additional_organization_activation_evidence\",\n \"session_tenancy_greenfield_activation_evidence\",\n \"session_variable_set_attachments\",\n \"session_visibility_write_capabilities\",\n \"session_work_claim_revisions\",\n \"session_work_claim_write_capabilities\",\n \"skill_config_conversion_receipts\",\n \"task_note_events\",\n \"task_note_knowledge_promotion_capabilities\",\n \"task_note_replacement_receipts\",\n \"task_note_write_capabilities\",\n \"task_notes\",\n \"tenancy_backfill_receipts\",\n \"tenancy_backfill_unresolved_rows\",\n \"turn_connection_authority_snapshots\",\n \"turn_personal_resource_attachment_receipts\",\n \"turn_personal_resource_once_receipts\",\n \"turn_personal_resource_snapshots\",\n \"workspace_variable_set_variables\",\n \"workspace_variable_sets\",\n] as const;\n\nexport type RuntimeTableDmlPrivilege = \"SELECT\" | \"INSERT\" | \"UPDATE\" | \"DELETE\";\nexport type RuntimeTablePrivilegeContract = Readonly<\n Record<string, readonly RuntimeTableDmlPrivilege[]>\n>;\n\nconst FULL_DML_PRIVILEGES = [\"SELECT\", \"INSERT\", \"UPDATE\", \"DELETE\"] as const;\n\n/** Exact per-table DML contract. Absence means no direct table privileges. */\nexport const RUNTIME_TABLE_PRIVILEGES: RuntimeTablePrivilegeContract = Object.freeze({\n ...Object.fromEntries(RUNTIME_FULL_DML_TABLES.map((table) => [table, FULL_DML_PRIVILEGES])),\n ...Object.fromEntries(RUNTIME_READ_ONLY_TABLES.map((table) => [table, [\"SELECT\"] as const])),\n ...Object.fromEntries(\n RUNTIME_READ_UPDATE_TABLES.map((table) => [table, [\"SELECT\", \"UPDATE\"] as const]),\n ),\n ...Object.fromEntries(\n RUNTIME_READ_INSERT_TABLES.map((table) => [table, [\"SELECT\", \"INSERT\"] as const]),\n ),\n ...Object.fromEntries(\n RUNTIME_READ_INSERT_UPDATE_TABLES.map((table) => [\n table,\n [\"SELECT\", \"INSERT\", \"UPDATE\"] as const,\n ]),\n ),\n});\n\n/** All tables with any direct runtime DML; retained as the aggregate public contract. */\nexport const RUNTIME_DML_TABLES = Object.freeze(\n Object.keys(RUNTIME_TABLE_PRIVILEGES).sort((a, b) => a.localeCompare(b)),\n);\n\nexport type RuntimeDatabasePostureOptions = {\n rlsStrategy: RlsStrategy;\n expectedRole?: string;\n targetSchema?: string;\n protectedTables?: readonly string[];\n tablePrivileges?: RuntimeTablePrivilegeContract;\n protectedNoDirectDmlTables?: readonly string[];\n targetSchemaCapabilityRoutines?: readonly string[];\n targetSchemaForbiddenRoutines?: readonly string[];\n organizationTenancyCanonicalActivationEnabled?: boolean;\n};\n\nexport type RuntimeDatabaseIdentity = {\n currentUser: string;\n sessionUser: string;\n databaseOwner: string;\n canConnectDatabase: boolean;\n canCreateInDatabase: boolean;\n rowSecurity: string;\n canLogin: boolean;\n superuser: boolean;\n inherit: boolean;\n createRole: boolean;\n createDatabase: boolean;\n replication: boolean;\n bypassRls: boolean;\n};\n\nexport type RuntimeSchemaPosture = {\n name: string;\n owner: string;\n usage: boolean;\n create: boolean;\n};\n\nexport type RuntimeTablePosture = {\n name: string;\n owner: string;\n rlsEnabled: boolean;\n rlsForced: boolean;\n rlsActive: boolean;\n policyCount: number;\n artifactOutboxDispatcherPolicy: boolean;\n artifactMaterializerPolicy: boolean;\n select: boolean;\n insert: boolean;\n update: boolean;\n delete: boolean;\n truncate: boolean;\n references: boolean;\n trigger: boolean;\n};\n\nexport type RuntimeRoutinePosture = {\n name: string;\n owner: string;\n execute: boolean;\n publicExecute?: boolean;\n securityDefiner: boolean;\n};\n\nexport type RuntimeTargetRoutinePosture = RuntimeRoutinePosture & {\n publicExecute: boolean;\n};\n\nexport type RuntimePrivateTablePosture = {\n name: string;\n owner: string;\n rlsEnabled?: boolean;\n rlsForced?: boolean;\n rlsActive?: boolean;\n policyCount?: number;\n select: boolean;\n insert: boolean;\n update: boolean;\n delete: boolean;\n};\n\nexport type RuntimeDatabasePosture = {\n identity: RuntimeDatabaseIdentity;\n /** Privilege-bearing role relationships; exact PG16+ management-only grants are excluded. */\n memberships: string[];\n schemas: RuntimeSchemaPosture[];\n ownedSchemas: string[];\n ownedRelations: string[];\n tables: RuntimeTablePosture[];\n privateTables: RuntimePrivateTablePosture[];\n targetRoutines: RuntimeTargetRoutinePosture[];\n privateRoutines: RuntimeRoutinePosture[];\n sessionTenancyProductActivationPresent: boolean;\n sessionVariableSetAttachmentsCutoverPresent: boolean;\n};\n\nexport class RuntimeDatabasePostureError extends Error {\n readonly violations: readonly string[];\n\n constructor(violations: readonly string[]) {\n super(`Runtime database posture check failed: ${violations.join(\"; \")}`);\n this.name = \"RuntimeDatabasePostureError\";\n this.violations = violations;\n }\n}\n\ntype IdentityRow = {\n current_user: string;\n session_user: string;\n database_owner: string;\n can_connect_database: boolean;\n can_create_in_database: boolean;\n row_security: string;\n rolcanlogin: boolean;\n rolsuper: boolean;\n rolinherit: boolean;\n rolcreaterole: boolean;\n rolcreatedb: boolean;\n rolreplication: boolean;\n rolbypassrls: boolean;\n};\n\nfunction resultRows<T>(result: unknown): T[] {\n if (Array.isArray(result)) {\n return result as T[];\n }\n const rows = (result as { rows?: unknown } | null)?.rows;\n if (Array.isArray(rows)) {\n return rows as T[];\n }\n throw new Error(\"Runtime database posture query returned an unsupported result shape\");\n}\n\nfunction sorted(values: Iterable<string>): string[] {\n return [...values].sort((a, b) => a.localeCompare(b));\n}\n\nfunction difference(left: ReadonlySet<string>, right: ReadonlySet<string>): string[] {\n return sorted([...left].filter((value) => !right.has(value)));\n}\n\n/** Inspect PostgreSQL catalogs plus one value-free global activation predicate; no tenant content. */\nexport async function inspectRuntimeDatabasePosture(\n db: Database,\n options: RuntimeDatabasePostureOptions,\n): Promise<RuntimeDatabasePosture> {\n const targetSchema = options.targetSchema?.trim() || \"public\";\n const targetSchemaCapabilityRoutines =\n options.targetSchemaCapabilityRoutines ?? RUNTIME_TARGET_SCHEMA_CAPABILITY_ROUTINES;\n const targetSchemaForbiddenRoutines =\n options.targetSchemaForbiddenRoutines ?? RUNTIME_TARGET_SCHEMA_FORBIDDEN_ROUTINES;\n\n return await db.transaction(\n async (tx) => {\n const identityRows = resultRows<IdentityRow>(\n await tx.execute(sql`\n select\n current_user::text as current_user,\n session_user::text as session_user,\n pg_get_userbyid(d.datdba)::text as database_owner,\n has_database_privilege(current_user, d.oid, 'CONNECT') as can_connect_database,\n has_database_privilege(current_user, d.oid, 'CREATE') as can_create_in_database,\n current_setting('row_security')::text as row_security,\n r.rolcanlogin,\n r.rolsuper,\n r.rolinherit,\n r.rolcreaterole,\n r.rolcreatedb,\n r.rolreplication,\n r.rolbypassrls\n from pg_roles r\n join pg_database d on d.datname = current_database()\n where r.rolname = current_user\n `),\n );\n const identity = identityRows[0];\n if (!identity) {\n throw new Error(\"Runtime database posture could not resolve the current PostgreSQL role\");\n }\n\n const mappedIdentity: RuntimeDatabaseIdentity = {\n currentUser: identity.current_user,\n sessionUser: identity.session_user,\n databaseOwner: identity.database_owner,\n canConnectDatabase: identity.can_connect_database,\n canCreateInDatabase: identity.can_create_in_database,\n rowSecurity: identity.row_security,\n canLogin: identity.rolcanlogin,\n superuser: identity.rolsuper,\n inherit: identity.rolinherit,\n createRole: identity.rolcreaterole,\n createDatabase: identity.rolcreatedb,\n replication: identity.rolreplication,\n bypassRls: identity.rolbypassrls,\n };\n\n // The forward-only activation receipt outlives topology. Embedded/scoped\n // deployments must enforce the same environment interlock as standalone\n // FORCE-RLS deployments, so inspect the value-free predicate before the\n // scoped catalog fast-path.\n const activationRows = resultRows<{ activated: boolean }>(\n await tx.execute(sql`select session_tenancy_any_product_activation() as activated`),\n );\n const sessionTenancyProductActivationPresent = activationRows[0]?.activated === true;\n const variableSetCutoverRows = resultRows<{ present: boolean }>(\n await tx.execute(sql`\n select to_regprocedure(\n 'opengeni_private.session_variable_set_attachments_protocol_v1_active()'\n ) is not null as present\n `),\n );\n const sessionVariableSetAttachmentsCutoverPresent =\n variableSetCutoverRows[0]?.present === true;\n\n // Scoped/embedded topology deliberately leaves ownership and isolation to\n // the host. Prove the connection identity is coherent, but do not impose\n // the standalone opengeni_app object/grant contract on the host's role.\n if (options.rlsStrategy === \"scoped\") {\n return {\n identity: mappedIdentity,\n memberships: [],\n schemas: [],\n ownedSchemas: [],\n ownedRelations: [],\n tables: [],\n privateTables: [],\n targetRoutines: [],\n privateRoutines: [],\n sessionTenancyProductActivationPresent,\n sessionVariableSetAttachmentsCutoverPresent,\n };\n }\n\n const relationshipRows = resultRows<RoleRelationshipCatalogRow>(\n await tx.execute(sql.raw(roleRelationshipsCatalogQuery(\"current_user\"))),\n );\n const memberships = classifyRoleRelationships(relationshipRows).unsafeRelationships;\n\n const schemas = resultRows<{\n name: string;\n owner: string;\n usage: boolean;\n create: boolean;\n }>(\n await tx.execute(sql`\n select\n n.nspname::text as name,\n pg_get_userbyid(n.nspowner)::text as owner,\n has_schema_privilege(current_user, n.oid, 'USAGE') as usage,\n has_schema_privilege(current_user, n.oid, 'CREATE') as create\n from pg_namespace n\n where n.nspname in (${targetSchema}, 'opengeni_private')\n order by n.nspname\n `),\n );\n\n const ownedSchemas = resultRows<{ name: string }>(\n await tx.execute(sql`\n select n.nspname::text as name\n from pg_namespace n\n join pg_roles r on r.oid = n.nspowner\n where r.rolname = current_user\n and n.nspname <> 'information_schema'\n and n.nspname !~ '^pg_'\n order by n.nspname\n `),\n ).map((row) => row.name);\n\n const ownedRelations = resultRows<{ name: string }>(\n await tx.execute(sql`\n select (n.nspname || '.' || c.relname)::text as name\n from pg_class c\n join pg_namespace n on n.oid = c.relnamespace\n join pg_roles r on r.oid = c.relowner\n where r.rolname = current_user\n and c.relkind in ('r', 'p', 'S', 'v', 'm', 'f')\n and n.nspname <> 'information_schema'\n and n.nspname !~ '^pg_'\n order by n.nspname, c.relname\n `),\n ).map((row) => row.name);\n\n const tables = resultRows<{\n name: string;\n owner: string;\n rls_enabled: boolean;\n rls_forced: boolean;\n rls_active: boolean;\n policy_count: number;\n artifact_outbox_dispatcher_policy: boolean;\n artifact_materializer_policy: boolean;\n can_select: boolean;\n can_insert: boolean;\n can_update: boolean;\n can_delete: boolean;\n can_truncate: boolean;\n can_references: boolean;\n can_trigger: boolean;\n }>(\n await tx.execute(sql`\n select\n c.relname::text as name,\n pg_get_userbyid(c.relowner)::text as owner,\n c.relrowsecurity as rls_enabled,\n c.relforcerowsecurity as rls_forced,\n row_security_active(c.oid) as rls_active,\n (select count(*)::int from pg_policy policy where policy.polrelid = c.oid) as policy_count,\n exists(\n select 1 from pg_policy policy\n where policy.polrelid = c.oid\n and policy.polname = 'editable_artifact_outbox_dispatcher'\n ) as artifact_outbox_dispatcher_policy,\n exists(\n select 1 from pg_policy policy\n where policy.polrelid = c.oid\n and policy.polname = 'editable_artifact_materializer_owner'\n ) as artifact_materializer_policy,\n has_table_privilege(current_user, c.oid, 'SELECT') as can_select,\n has_table_privilege(current_user, c.oid, 'INSERT') as can_insert,\n has_table_privilege(current_user, c.oid, 'UPDATE') as can_update,\n has_table_privilege(current_user, c.oid, 'DELETE') as can_delete,\n has_table_privilege(current_user, c.oid, 'TRUNCATE') as can_truncate,\n has_table_privilege(current_user, c.oid, 'REFERENCES') as can_references,\n has_table_privilege(current_user, c.oid, 'TRIGGER') as can_trigger\n from pg_class c\n join pg_namespace n on n.oid = c.relnamespace\n where n.nspname = ${targetSchema}\n and c.relkind in ('r', 'p')\n order by c.relname\n `),\n ).map((row) => ({\n name: row.name,\n owner: row.owner,\n rlsEnabled: row.rls_enabled,\n rlsForced: row.rls_forced,\n rlsActive: row.rls_active,\n policyCount: row.policy_count,\n artifactOutboxDispatcherPolicy: row.artifact_outbox_dispatcher_policy,\n artifactMaterializerPolicy: row.artifact_materializer_policy,\n select: row.can_select,\n insert: row.can_insert,\n update: row.can_update,\n delete: row.can_delete,\n truncate: row.can_truncate,\n references: row.can_references,\n trigger: row.can_trigger,\n }));\n\n const privateTables = resultRows<{\n name: string;\n owner: string;\n rls_enabled: boolean;\n rls_forced: boolean;\n rls_active: boolean;\n policy_count: number;\n can_select: boolean;\n can_insert: boolean;\n can_update: boolean;\n can_delete: boolean;\n }>(\n await tx.execute(sql`\n select\n c.relname::text as name,\n pg_get_userbyid(c.relowner)::text as owner,\n c.relrowsecurity as rls_enabled,\n c.relforcerowsecurity as rls_forced,\n row_security_active(c.oid) as rls_active,\n (select count(*)::int from pg_policy policy where policy.polrelid = c.oid) as policy_count,\n has_table_privilege(current_user, c.oid, 'SELECT') as can_select,\n has_table_privilege(current_user, c.oid, 'INSERT') as can_insert,\n has_table_privilege(current_user, c.oid, 'UPDATE') as can_update,\n has_table_privilege(current_user, c.oid, 'DELETE') as can_delete\n from pg_class c\n join pg_namespace n on n.oid = c.relnamespace\n where n.nspname = 'opengeni_private'\n and c.relkind in ('r', 'p')\n and c.relname in (\n ${PERSONAL_RESOURCE_CAPABILITY_TABLE},\n ${SCHEDULED_PERSONAL_RESOURCE_CAPABILITY_TABLE},\n ${VARIABLE_SET_CAPABILITY_TABLE},\n ${PERSONAL_DOCUMENT_CAPABILITY_TABLE},\n ${DOCUMENT_MIGRATION_CAPABILITY_TABLE},\n ${SCOPED_COMPUTE_CAPABILITY_TABLE},\n ${CONNECTION_TENANCY_BACKFILL_CAPABILITY_TABLE},\n ${AUTOMATIC_SESSION_TITLE_FANOUT_OUTBOX_TABLE}\n )\n `),\n ).map((row) => ({\n name: row.name,\n owner: row.owner,\n rlsEnabled: row.rls_enabled,\n rlsForced: row.rls_forced,\n rlsActive: row.rls_active,\n policyCount: row.policy_count,\n select: row.can_select,\n insert: row.can_insert,\n update: row.can_update,\n delete: row.can_delete,\n }));\n\n const targetRoutines = resultRows<{\n name: string;\n owner: string;\n can_execute: boolean;\n public_execute: boolean;\n security_definer: boolean;\n }>(\n await tx.execute(sql`\n select\n (p.proname || '(' || pg_catalog.oidvectortypes(p.proargtypes) || ')')::text as name,\n pg_get_userbyid(p.proowner)::text as owner,\n has_function_privilege(current_user, p.oid, 'EXECUTE') as can_execute,\n exists (\n select 1\n from aclexplode(coalesce(p.proacl, acldefault('f', p.proowner))) acl\n where acl.grantee = 0 and acl.privilege_type = 'EXECUTE'\n ) as public_execute,\n p.prosecdef as security_definer\n from pg_proc p\n join pg_namespace n on n.oid = p.pronamespace\n where n.nspname = ${targetSchema}\n and p.prokind in ('f', 'p')\n and (p.proname || '(' || pg_catalog.oidvectortypes(p.proargtypes) || ')') = any(\n array[\n ${sql.join(\n [...targetSchemaCapabilityRoutines, ...targetSchemaForbiddenRoutines].map(\n (name) => sql`${name}`,\n ),\n sql`, `,\n )}\n ]::text[]\n )\n order by p.proname, pg_catalog.oidvectortypes(p.proargtypes)\n `),\n )\n .map((row) => ({\n name: row.name,\n owner: row.owner,\n execute: row.can_execute,\n publicExecute: row.public_execute,\n securityDefiner: row.security_definer,\n }))\n .sort((left, right) => left.name.localeCompare(right.name));\n\n const privateRoutines = resultRows<{\n name: string;\n owner: string;\n can_execute: boolean;\n public_execute: boolean;\n security_definer: boolean;\n }>(\n await tx.execute(sql`\n select\n (p.proname || '(' || pg_catalog.oidvectortypes(p.proargtypes) || ')')::text as name,\n pg_get_userbyid(p.proowner)::text as owner,\n has_function_privilege(current_user, p.oid, 'EXECUTE') as can_execute,\n exists (\n select 1\n from aclexplode(coalesce(p.proacl, acldefault('f', p.proowner))) acl\n where acl.grantee = 0 and acl.privilege_type = 'EXECUTE'\n ) as public_execute,\n p.prosecdef as security_definer\n from pg_proc p\n join pg_namespace n on n.oid = p.pronamespace\n where n.nspname = 'opengeni_private'\n and p.prokind in ('f', 'p')\n order by p.proname, pg_catalog.oidvectortypes(p.proargtypes)\n `),\n ).map((row) => ({\n name: row.name,\n owner: row.owner,\n execute: row.can_execute,\n publicExecute: row.public_execute,\n securityDefiner: row.security_definer,\n }));\n\n return {\n identity: mappedIdentity,\n memberships,\n schemas,\n ownedSchemas,\n ownedRelations,\n tables,\n privateTables,\n targetRoutines,\n privateRoutines,\n sessionTenancyProductActivationPresent,\n sessionVariableSetAttachmentsCutoverPresent,\n };\n },\n { isolationLevel: \"repeatable read\", accessMode: \"read only\" },\n );\n}\n\n/** Pure deterministic evaluator used by startup/readiness and unit tests. */\nexport function evaluateRuntimeDatabasePosture(\n posture: RuntimeDatabasePosture,\n options: RuntimeDatabasePostureOptions,\n): string[] {\n const violations: string[] = [];\n const identity = posture.identity;\n\n if (!posture.sessionVariableSetAttachmentsCutoverPresent) {\n violations.push(\"database is missing the 0352 session Variable Set attachment runtime receipt\");\n }\n\n if (\n posture.sessionTenancyProductActivationPresent &&\n options.organizationTenancyCanonicalActivationEnabled !== true\n ) {\n violations.push(\n \"session-tenancy product activation is durable but OPENGENI_ORGANIZATION_TENANCY_CANONICAL_ACTIVATION_ENABLED is not true\",\n );\n }\n\n if (!identity.currentUser || !identity.sessionUser) {\n violations.push(\"database identity is empty\");\n }\n if (identity.currentUser !== identity.sessionUser) {\n violations.push(\n `current_user ${identity.currentUser} does not match session_user ${identity.sessionUser}`,\n );\n }\n if (!identity.canConnectDatabase) {\n violations.push(\"runtime role lacks CONNECT on the current database\");\n }\n\n if (options.rlsStrategy === \"scoped\") {\n return violations;\n }\n\n const expectedRole = options.expectedRole?.trim() || \"opengeni_app\";\n const targetSchema = options.targetSchema?.trim() || \"public\";\n const protectedTables = new Set(options.protectedTables ?? FORCE_RLS_TABLES);\n const tablePrivileges = options.tablePrivileges ?? RUNTIME_TABLE_PRIVILEGES;\n const directRuntimeTables = new Set(Object.keys(tablePrivileges));\n const protectedNoDirectDmlTables = new Set(\n options.protectedNoDirectDmlTables ??\n (options.protectedTables ? [] : PROTECTED_NO_DIRECT_DML_TABLES),\n );\n const targetSchemaCapabilityRoutines =\n options.targetSchemaCapabilityRoutines ?? RUNTIME_TARGET_SCHEMA_CAPABILITY_ROUTINES;\n const targetSchemaForbiddenRoutines =\n options.targetSchemaForbiddenRoutines ?? RUNTIME_TARGET_SCHEMA_FORBIDDEN_ROUTINES;\n\n if (identity.currentUser !== expectedRole || identity.sessionUser !== expectedRole) {\n violations.push(\n `runtime identity must be ${expectedRole} (current_user=${identity.currentUser}, session_user=${identity.sessionUser})`,\n );\n }\n if (!identity.canLogin) violations.push(\"runtime role is not LOGIN\");\n if (identity.superuser) violations.push(\"runtime role is SUPERUSER\");\n if (identity.bypassRls) violations.push(\"runtime role has BYPASSRLS\");\n if (identity.createRole) violations.push(\"runtime role has CREATEROLE\");\n if (identity.createDatabase) violations.push(\"runtime role has CREATEDB\");\n if (identity.replication) violations.push(\"runtime role has REPLICATION\");\n if (identity.inherit) violations.push(\"runtime role must be NOINHERIT\");\n if (identity.databaseOwner === expectedRole) violations.push(\"runtime role owns the database\");\n if (identity.canCreateInDatabase) {\n violations.push(\"runtime role has CREATE on the current database\");\n }\n if (identity.rowSecurity.toLowerCase() !== \"on\") {\n violations.push(`row_security is ${identity.rowSecurity}, expected on`);\n }\n if (posture.memberships.length > 0) {\n violations.push(`runtime role has memberships: ${sorted(posture.memberships).join(\", \")}`);\n }\n if (posture.ownedSchemas.length > 0) {\n violations.push(`runtime role owns schemas: ${sorted(posture.ownedSchemas).join(\", \")}`);\n }\n if (posture.ownedRelations.length > 0) {\n violations.push(`runtime role owns relations: ${sorted(posture.ownedRelations).join(\", \")}`);\n }\n\n for (const schemaName of new Set([targetSchema, \"opengeni_private\"])) {\n const schema = posture.schemas.find((candidate) => candidate.name === schemaName);\n if (!schema) {\n violations.push(`required schema ${schemaName} is missing`);\n continue;\n }\n if (schema.owner === expectedRole) {\n violations.push(`runtime role owns schema ${schemaName}`);\n }\n if (!schema.usage) violations.push(`runtime role lacks USAGE on schema ${schemaName}`);\n if (schema.create) violations.push(`runtime role has CREATE on schema ${schemaName}`);\n }\n\n const tableByName = new Map(posture.tables.map((table) => [table.name, table]));\n const actualRlsTables = new Set(\n posture.tables.filter((table) => table.rlsEnabled).map((table) => table.name),\n );\n const classifiedProtectedTables = new Set([\n ...directRuntimeTables,\n ...protectedNoDirectDmlTables,\n ]);\n const unclassifiedProtectedTables = difference(protectedTables, classifiedProtectedTables);\n if (unclassifiedProtectedTables.length > 0) {\n violations.push(\n `protected tables lack an explicit privilege class: ${unclassifiedProtectedTables.join(\", \")}`,\n );\n }\n const protectedNoDirectDmlOverlap = difference(\n protectedNoDirectDmlTables,\n new Set([...protectedNoDirectDmlTables].filter((table) => !directRuntimeTables.has(table))),\n );\n if (protectedNoDirectDmlOverlap.length > 0) {\n violations.push(\n `protected no-direct-DML tables also declare runtime privileges: ${protectedNoDirectDmlOverlap.join(\", \")}`,\n );\n }\n const nonProtectedNoDirectDmlTables = difference(protectedNoDirectDmlTables, protectedTables);\n if (nonProtectedNoDirectDmlTables.length > 0) {\n violations.push(\n `no-direct-DML tables are absent from the protected contract: ${nonProtectedNoDirectDmlTables.join(\", \")}`,\n );\n }\n const catalogTables = new Set(tableByName.keys());\n const missingRuntimeTables = difference(directRuntimeTables, catalogTables);\n if (missingRuntimeTables.length > 0) {\n violations.push(`runtime privilege tables are missing: ${missingRuntimeTables.join(\", \")}`);\n }\n const missingTables = difference(protectedTables, catalogTables);\n if (missingTables.length > 0) {\n violations.push(`protected tables are missing: ${missingTables.join(\", \")}`);\n }\n const undeclaredRlsTables = difference(actualRlsTables, protectedTables);\n if (undeclaredRlsTables.length > 0) {\n violations.push(\n `RLS tables are absent from the declared contract: ${undeclaredRlsTables.join(\", \")}`,\n );\n }\n\n for (const table of posture.tables) {\n const privileges = [\n [\"SELECT\", table.select],\n [\"INSERT\", table.insert],\n [\"UPDATE\", table.update],\n [\"DELETE\", table.delete],\n [\"TRUNCATE\", table.truncate],\n [\"REFERENCES\", table.references],\n [\"TRIGGER\", table.trigger],\n ] as const;\n const expectedPrivileges = new Set<string>(tablePrivileges[table.name] ?? []);\n if (table.owner === expectedRole) {\n violations.push(`runtime role owns table ${table.name}`);\n }\n const missingPrivileges = privileges\n .filter(([privilege, granted]) => expectedPrivileges.has(privilege) && !granted)\n .map(([privilege]) => privilege);\n if (missingPrivileges.length > 0) {\n violations.push(\n `table ${table.name} lacks required runtime privileges: ${missingPrivileges.join(\", \")}`,\n );\n }\n const excessPrivileges = privileges\n .filter(([privilege, granted]) => !expectedPrivileges.has(privilege) && granted)\n .map(([privilege]) => privilege);\n if (excessPrivileges.length > 0) {\n violations.push(\n `table ${table.name} grants excess runtime privileges: ${excessPrivileges.join(\", \")}`,\n );\n }\n }\n\n for (const tableName of protectedTables) {\n const table = tableByName.get(tableName);\n if (!table) continue;\n if (!table.rlsEnabled) violations.push(`table ${tableName} does not ENABLE RLS`);\n if (!table.rlsForced) violations.push(`table ${tableName} does not FORCE RLS`);\n if (!table.rlsActive) violations.push(`table ${tableName} has inactive RLS for runtime role`);\n if (table.policyCount < 1) violations.push(`table ${tableName} has no RLS policy`);\n }\n\n const targetSchemaOwner = posture.schemas.find((schema) => schema.name === targetSchema)?.owner;\n for (const forbiddenRoutine of targetSchemaForbiddenRoutines) {\n const matches = posture.targetRoutines.filter((routine) => routine.name === forbiddenRoutine);\n if (matches.length !== 1) {\n violations.push(\n `owner-internal target-schema helper ${forbiddenRoutine} is missing or ambiguous`,\n );\n continue;\n }\n const routine = matches[0]!;\n if (!routine.securityDefiner) {\n violations.push(\n `owner-internal target-schema helper ${routine.name} is not SECURITY DEFINER`,\n );\n }\n const authorityOwner = tableByName.get(\"sessions\")?.owner ?? targetSchemaOwner;\n if (authorityOwner && routine.owner !== authorityOwner) {\n violations.push(\n `owner-internal target-schema helper ${routine.name} owner ${routine.owner} does not match session authority owner ${authorityOwner}`,\n );\n }\n if (routine.execute) {\n violations.push(`runtime role has forbidden owner-internal helper ${routine.name}`);\n }\n if (routine.publicExecute) {\n violations.push(`PUBLIC has forbidden owner-internal helper ${routine.name}`);\n }\n }\n for (const expectedRoutine of targetSchemaCapabilityRoutines) {\n const matches = posture.targetRoutines.filter((routine) => routine.name === expectedRoutine);\n if (matches.length !== 1) {\n violations.push(\n `target-schema runtime capability ${expectedRoutine} is missing or ambiguous`,\n );\n continue;\n }\n const routine = matches[0]!;\n if (RUNTIME_TARGET_SCHEMA_INVOKER_ROUTINE_SET.has(routine.name)) {\n if (routine.securityDefiner) {\n violations.push(\n `target-schema runtime capability ${routine.name} must be SECURITY INVOKER`,\n );\n }\n } else if (!routine.securityDefiner) {\n violations.push(`target-schema runtime capability ${routine.name} is not SECURITY DEFINER`);\n }\n if (\n routine.name === GOOGLE_DRIVE_FILE_AUTHORIZATION_ROUTINE ||\n routine.name === GOOGLE_DRIVE_DOCUMENT_CITATION_ROUTINE\n ) {\n const missingAuthorityTables = GOOGLE_DRIVE_AUTHORITY_TABLES.filter(\n (tableName) => !tableByName.has(tableName),\n );\n if (missingAuthorityTables.length > 0) {\n violations.push(\n `target-schema runtime capability ${routine.name} authority tables are missing: ${missingAuthorityTables.join(\", \")}`,\n );\n } else {\n const authorityTables = GOOGLE_DRIVE_AUTHORITY_TABLES.map(\n (tableName) => tableByName.get(tableName)!,\n );\n const authorityOwners = new Set(authorityTables.map((table) => table.owner));\n if (authorityOwners.size !== 1) {\n violations.push(\n `target-schema runtime capability ${routine.name} authority table owners do not match: ${authorityTables.map((table) => `${table.name}=${table.owner}`).join(\", \")}`,\n );\n } else if (routine.owner !== authorityTables[0]!.owner) {\n violations.push(\n `target-schema runtime capability ${routine.name} owner ${routine.owner} does not match authority table owner ${authorityTables[0]!.owner}`,\n );\n }\n }\n } else if (routine.name === KNOWLEDGE_SOURCE_SYNC_LOCK_AUTHORITY_ROUTINE) {\n const missingAuthorityTables = KNOWLEDGE_SOURCE_SYNC_LOCK_AUTHORITY_TABLES.filter(\n (tableName) => !tableByName.has(tableName),\n );\n if (missingAuthorityTables.length > 0) {\n violations.push(\n `target-schema runtime capability ${routine.name} authority tables are missing: ${missingAuthorityTables.join(\", \")}`,\n );\n } else {\n const authorityTables = KNOWLEDGE_SOURCE_SYNC_LOCK_AUTHORITY_TABLES.map(\n (tableName) => tableByName.get(tableName)!,\n );\n const authorityOwners = new Set(authorityTables.map((table) => table.owner));\n if (authorityOwners.size !== 1) {\n violations.push(\n `target-schema runtime capability ${routine.name} authority table owners do not match: ${authorityTables.map((table) => `${table.name}=${table.owner}`).join(\", \")}`,\n );\n } else if (routine.owner !== authorityTables[0]!.owner) {\n violations.push(\n `target-schema runtime capability ${routine.name} owner ${routine.owner} does not match authority table owner ${authorityTables[0]!.owner}`,\n );\n }\n }\n } else if (\n [\n \"ensure_external_identity(uuid, text, text)\",\n \"get_external_identity_link_reference(uuid, uuid, text)\",\n \"get_external_identity_link_inventory_references(uuid, uuid[])\",\n ].includes(routine.name)\n ) {\n const names =\n routine.name !== \"ensure_external_identity(uuid, text, text)\"\n ? [\"external_identity_links\", \"external_identities\", \"organization_memberships\"]\n : [\n \"external_identities\",\n \"organization_memberships\",\n \"workspaces\",\n \"workspace_inference_controls\",\n ];\n const missing = names.filter((name) => !tableByName.has(name));\n if (missing.length > 0) {\n violations.push(\n `target-schema runtime capability ${routine.name} authority tables are missing: ${missing.join(\", \")}`,\n );\n } else if (names.some((name) => tableByName.get(name)!.owner !== routine.owner)) {\n violations.push(\n `target-schema runtime capability ${routine.name} authority table owners do not match`,\n );\n }\n } else if (routine.name === MANAGED_HUMAN_PERSONAL_WORKSPACE_ROUTINE) {\n const authorityTables = MANAGED_HUMAN_PERSONAL_WORKSPACE_AUTHORITY_TABLES.filter(\n (tableName) => tableByName.has(tableName),\n ).map((tableName) => tableByName.get(tableName)!);\n const authorityOwners = new Set(authorityTables.map((table) => table.owner));\n if (authorityOwners.size > 1) {\n violations.push(\n `target-schema runtime capability ${routine.name} authority table owners do not match: ${authorityTables.map((table) => `${table.name}=${table.owner}`).join(\", \")}`,\n );\n } else if (authorityTables[0] && routine.owner !== authorityTables[0].owner) {\n violations.push(\n `target-schema runtime capability ${routine.name} owner ${routine.owner} does not match authority table owner ${authorityTables[0].owner}`,\n );\n }\n } else if (routine.name === GOVERNED_LEARNING_EVALUATION_ROUTINE) {\n if (!tableByName.has(\"governed_learning_decision_receipts\")) {\n continue;\n }\n const missingAuthorityTables = GOVERNED_LEARNING_EVALUATION_AUTHORITY_TABLES.filter(\n (tableName) => !tableByName.has(tableName),\n );\n if (missingAuthorityTables.length > 0) {\n violations.push(\n `target-schema runtime capability ${routine.name} authority tables are missing: ${missingAuthorityTables.join(\", \")}`,\n );\n } else {\n const authorityTables = GOVERNED_LEARNING_EVALUATION_AUTHORITY_TABLES.map(\n (tableName) => tableByName.get(tableName)!,\n );\n const authorityOwners = new Set(authorityTables.map((table) => table.owner));\n if (authorityOwners.size !== 1) {\n violations.push(\n `target-schema runtime capability ${routine.name} authority table owners do not match: ${authorityTables.map((table) => `${table.name}=${table.owner}`).join(\", \")}`,\n );\n } else if (routine.owner !== authorityTables[0]!.owner) {\n violations.push(\n `target-schema runtime capability ${routine.name} owner ${routine.owner} does not match authority table owner ${authorityTables[0]!.owner}`,\n );\n }\n }\n } else if (\n GOVERNED_LEARNING_INSPECTION_ROUTINES.includes(\n routine.name as (typeof GOVERNED_LEARNING_INSPECTION_ROUTINES)[number],\n )\n ) {\n if (!tableByName.has(\"governed_learning_decision_receipts\")) continue;\n const missingAuthorityTables = GOVERNED_LEARNING_INSPECTION_AUTHORITY_TABLES.filter(\n (name) => !tableByName.has(name),\n );\n if (missingAuthorityTables.length > 0) {\n violations.push(\n `target-schema runtime capability ${routine.name} authority tables are missing: ${missingAuthorityTables.join(\", \")}`,\n );\n } else {\n const authorityTables = GOVERNED_LEARNING_INSPECTION_AUTHORITY_TABLES.map(\n (name) => tableByName.get(name)!,\n );\n const authorityOwners = new Set(authorityTables.map((table) => table.owner));\n if (authorityOwners.size !== 1 || routine.owner !== authorityTables[0]!.owner) {\n violations.push(\n `target-schema runtime capability ${routine.name} owner does not match governed-learning inspection authority`,\n );\n }\n }\n } else if (\n GOVERNED_LEARNING_ACTIVATION_ROUTINES.includes(\n routine.name as (typeof GOVERNED_LEARNING_ACTIVATION_ROUTINES)[number],\n )\n ) {\n if (!tableByName.has(\"governed_learning_activation_receipts\")) {\n continue;\n }\n const missingAuthorityTables = GOVERNED_LEARNING_ACTIVATION_AUTHORITY_TABLES.filter(\n (tableName) => !tableByName.has(tableName),\n );\n if (missingAuthorityTables.length > 0) {\n violations.push(\n `target-schema runtime capability ${routine.name} authority tables are missing: ${missingAuthorityTables.join(\", \")}`,\n );\n } else {\n const authorityTables = GOVERNED_LEARNING_ACTIVATION_AUTHORITY_TABLES.map(\n (tableName) => tableByName.get(tableName)!,\n );\n const authorityOwners = new Set(authorityTables.map((table) => table.owner));\n if (authorityOwners.size !== 1) {\n violations.push(\n `target-schema runtime capability ${routine.name} authority table owners do not match: ${authorityTables.map((table) => `${table.name}=${table.owner}`).join(\", \")}`,\n );\n } else if (routine.owner !== authorityTables[0]!.owner) {\n violations.push(\n `target-schema runtime capability ${routine.name} owner ${routine.owner} does not match authority table owner ${authorityTables[0]!.owner}`,\n );\n }\n }\n } else if (\n COMPANY_PROFILE_AGENT_ADMIN_ROUTINES.includes(\n routine.name as (typeof COMPANY_PROFILE_AGENT_ADMIN_ROUTINES)[number],\n )\n ) {\n const missingAuthorityTables = COMPANY_PROFILE_AGENT_ADMIN_AUTHORITY_TABLES.filter(\n (tableName) => !tableByName.has(tableName),\n );\n if (missingAuthorityTables.length > 0) {\n violations.push(\n `target-schema runtime capability ${routine.name} authority tables are missing: ${missingAuthorityTables.join(\", \")}`,\n );\n } else {\n const authorityTables = COMPANY_PROFILE_AGENT_ADMIN_AUTHORITY_TABLES.map(\n (tableName) => tableByName.get(tableName)!,\n );\n const authorityOwners = new Set(authorityTables.map((table) => table.owner));\n if (authorityOwners.size !== 1) {\n violations.push(\n `target-schema runtime capability ${routine.name} authority table owners do not match: ${authorityTables.map((table) => `${table.name}=${table.owner}`).join(\", \")}`,\n );\n } else if (routine.owner !== authorityTables[0]!.owner) {\n violations.push(\n `target-schema runtime capability ${routine.name} owner ${routine.owner} does not match authority table owner ${authorityTables[0]!.owner}`,\n );\n }\n }\n } else if (routine.name === ADDITIONAL_ORGANIZATION_CREATION_ROUTINE) {\n const missingAuthorityTables = ADDITIONAL_ORGANIZATION_CREATION_AUTHORITY_TABLES.filter(\n (tableName) => !tableByName.has(tableName),\n );\n if (missingAuthorityTables.length > 0) {\n violations.push(\n `target-schema runtime capability ${routine.name} authority tables are missing: ${missingAuthorityTables.join(\", \")}`,\n );\n } else {\n const authorityTables = ADDITIONAL_ORGANIZATION_CREATION_AUTHORITY_TABLES.map(\n (tableName) => tableByName.get(tableName)!,\n );\n const authorityOwners = new Set(authorityTables.map((table) => table.owner));\n if (authorityOwners.size !== 1) {\n violations.push(\n `target-schema runtime capability ${routine.name} authority table owners do not match: ${authorityTables.map((table) => `${table.name}=${table.owner}`).join(\", \")}`,\n );\n } else if (routine.owner !== authorityTables[0]!.owner) {\n violations.push(\n `target-schema runtime capability ${routine.name} owner ${routine.owner} does not match authority table owner ${authorityTables[0]!.owner}`,\n );\n }\n }\n } else if (\n (ORGANIZATION_MEMBERSHIP_LIFECYCLE_ROUTINES as readonly string[]).includes(routine.name)\n ) {\n const missingAuthorityTables = ORGANIZATION_MEMBERSHIP_LIFECYCLE_AUTHORITY_TABLES.filter(\n (tableName) => !tableByName.has(tableName),\n );\n if (missingAuthorityTables.length > 0) {\n violations.push(\n `target-schema runtime capability ${routine.name} authority tables are missing: ${missingAuthorityTables.join(\", \")}`,\n );\n } else {\n const authorityTables = ORGANIZATION_MEMBERSHIP_LIFECYCLE_AUTHORITY_TABLES.map(\n (tableName) => tableByName.get(tableName)!,\n );\n const authorityOwners = new Set(authorityTables.map((table) => table.owner));\n if (authorityOwners.size !== 1) {\n violations.push(\n `target-schema runtime capability ${routine.name} authority table owners do not match: ${authorityTables.map((table) => `${table.name}=${table.owner}`).join(\", \")}`,\n );\n } else if (routine.owner !== authorityTables[0]!.owner) {\n violations.push(\n `target-schema runtime capability ${routine.name} owner ${routine.owner} does not match authority table owner ${authorityTables[0]!.owner}`,\n );\n }\n }\n } else if (\n (ORGANIZATION_PRIVATE_SESSION_ROUTINES as readonly string[]).includes(routine.name)\n ) {\n if (!tableByName.has(\"organization_private_session_settings\")) {\n continue;\n }\n const authorityTableNames =\n ORGANIZATION_PRIVATE_SESSION_ROUTINE_AUTHORITY_TABLES[\n routine.name as keyof typeof ORGANIZATION_PRIVATE_SESSION_ROUTINE_AUTHORITY_TABLES\n ];\n const missingAuthorityTables = authorityTableNames.filter(\n (tableName) => !tableByName.has(tableName),\n );\n if (missingAuthorityTables.length > 0) {\n violations.push(\n `target-schema runtime capability ${routine.name} authority tables are missing: ${missingAuthorityTables.join(\", \")}`,\n );\n } else {\n const authorityTables = authorityTableNames.map((tableName) => tableByName.get(tableName)!);\n const authorityOwners = new Set(authorityTables.map((table) => table.owner));\n if (authorityOwners.size !== 1) {\n violations.push(\n `target-schema runtime capability ${routine.name} authority table owners do not match: ${authorityTables.map((table) => `${table.name}=${table.owner}`).join(\", \")}`,\n );\n } else if (routine.owner !== authorityTables[0]!.owner) {\n violations.push(\n `target-schema runtime capability ${routine.name} owner ${routine.owner} does not match authority table owner ${authorityTables[0]!.owner}`,\n );\n }\n }\n } else if (routine.name === \"skill_apply_lifecycle(uuid, uuid, jsonb, jsonb)\") {\n const authorityTables = [\n \"preference_registry_preferences\",\n \"preference_registry_revisions\",\n \"preference_registry_events\",\n ];\n for (const name of authorityTables) {\n const table = tableByName.get(name);\n if (!table) violations.push(`Skill lifecycle authority table ${name} is missing`);\n else if (routine.owner !== table.owner)\n violations.push(\n `Skill lifecycle owner ${routine.owner} does not match ${name} owner ${table.owner}`,\n );\n }\n } else if (routine.name === PREFERENCE_KNOWLEDGE_PROPOSAL_ROUTINE) {\n if (!tableByName.has(\"company_brain_preference_proposal_receipts\")) {\n continue;\n }\n const missingAuthorityTables = PREFERENCE_KNOWLEDGE_PROPOSAL_AUTHORITY_TABLES.filter(\n (tableName) => !tableByName.has(tableName),\n );\n if (missingAuthorityTables.length > 0) {\n violations.push(\n `target-schema runtime capability ${routine.name} authority tables are missing: ${missingAuthorityTables.join(\", \")}`,\n );\n } else {\n const authorityTables = PREFERENCE_KNOWLEDGE_PROPOSAL_AUTHORITY_TABLES.map(\n (tableName) => tableByName.get(tableName)!,\n );\n const authorityOwners = new Set(authorityTables.map((table) => table.owner));\n if (authorityOwners.size !== 1) {\n violations.push(\n `target-schema runtime capability ${routine.name} authority table owners do not match: ${authorityTables.map((table) => `${table.name}=${table.owner}`).join(\", \")}`,\n );\n } else if (routine.owner !== authorityTables[0]!.owner) {\n violations.push(\n `target-schema runtime capability ${routine.name} owner ${routine.owner} does not match authority table owner ${authorityTables[0]!.owner}`,\n );\n }\n }\n } else if ((ORGANIZATION_RECOVERY_ROUTINES as readonly string[]).includes(routine.name)) {\n const authorityTables = ORGANIZATION_RECOVERY_AUTHORITY_TABLES.filter((tableName) =>\n tableByName.has(tableName),\n ).map((tableName) => tableByName.get(tableName)!);\n const authorityOwners = new Set(authorityTables.map((table) => table.owner));\n if (authorityTables.length !== ORGANIZATION_RECOVERY_AUTHORITY_TABLES.length) {\n violations.push(\n `target-schema runtime capability ${routine.name} organization recovery authority tables are missing`,\n );\n } else if (authorityOwners.size !== 1) {\n violations.push(\n `target-schema runtime capability ${routine.name} authority table owners do not match: ${authorityTables.map((table) => `${table.name}=${table.owner}`).join(\", \")}`,\n );\n } else if (routine.owner !== authorityTables[0]!.owner) {\n violations.push(\n `target-schema runtime capability ${routine.name} owner ${routine.owner} does not match authority table owner ${authorityTables[0]!.owner}`,\n );\n }\n } else if ((MANAGED_AUTH_SESSION_SET_ROUTINES as readonly string[]).includes(routine.name)) {\n const authorityTables = MANAGED_AUTH_SESSION_SET_AUTHORITY_TABLES.filter((tableName) =>\n tableByName.has(tableName),\n ).map((tableName) => tableByName.get(tableName)!);\n const authorityOwners = new Set(authorityTables.map((table) => table.owner));\n if (authorityTables.length !== MANAGED_AUTH_SESSION_SET_AUTHORITY_TABLES.length) {\n violations.push(\n `target-schema runtime capability ${routine.name} managed auth session-set authority tables are missing`,\n );\n } else if (authorityOwners.size !== 1) {\n violations.push(\n `target-schema runtime capability ${routine.name} authority table owners do not match: ${authorityTables.map((table) => `${table.name}=${table.owner}`).join(\", \")}`,\n );\n } else if (routine.owner !== authorityTables[0]!.owner) {\n violations.push(\n `target-schema runtime capability ${routine.name} owner ${routine.owner} does not match authority table owner ${authorityTables[0]!.owner}`,\n );\n }\n } else if ((CANONICAL_HUMAN_IDENTITY_ROUTINES as readonly string[]).includes(routine.name)) {\n const authorityTables = CANONICAL_HUMAN_IDENTITY_AUTHORITY_TABLES.filter((tableName) =>\n tableByName.has(tableName),\n ).map((tableName) => tableByName.get(tableName)!);\n const authorityOwners = new Set(authorityTables.map((table) => table.owner));\n if (authorityTables.length !== CANONICAL_HUMAN_IDENTITY_AUTHORITY_TABLES.length) {\n violations.push(\n `target-schema runtime capability ${routine.name} canonical identity authority tables are missing`,\n );\n } else if (authorityOwners.size !== 1) {\n violations.push(\n `target-schema runtime capability ${routine.name} authority table owners do not match: ${authorityTables.map((table) => `${table.name}=${table.owner}`).join(\", \")}`,\n );\n } else if (routine.owner !== authorityTables[0]!.owner) {\n violations.push(\n `target-schema runtime capability ${routine.name} owner ${routine.owner} does not match authority table owner ${authorityTables[0]!.owner}`,\n );\n }\n } else if (\n (PERSONAL_GITHUB_REPOSITORY_AUTHORITY_ROUTINES as readonly string[]).includes(routine.name)\n ) {\n const authorityTables = PERSONAL_GITHUB_REPOSITORY_AUTHORITY_TABLES.map((tableName) =>\n tableByName.get(tableName),\n ).filter((table): table is RuntimeTablePosture => table !== undefined);\n const authorityOwners = new Set(authorityTables.map((table) => table.owner));\n if (authorityOwners.size > 1) {\n violations.push(\n `target-schema runtime capability ${routine.name} personal GitHub repository authority table owners do not match`,\n );\n } else {\n const authorityOwner = authorityTables[0]?.owner ?? targetSchemaOwner;\n if (authorityOwner && routine.owner !== authorityOwner) {\n violations.push(\n `target-schema runtime capability ${routine.name} owner ${routine.owner} does not match personal GitHub repository authority owner ${authorityOwner}`,\n );\n }\n }\n } else if (\n (PERSONAL_DOCUMENT_AUTHORITY_ROUTINES as readonly string[]).includes(routine.name) ||\n (DOCUMENT_MIGRATION_AUTHORITY_ROUTINES as readonly string[]).includes(routine.name)\n ) {\n const authorityOwner = tableByName.get(\"documents\")?.owner ?? targetSchemaOwner;\n if (authorityOwner && routine.owner !== authorityOwner) {\n violations.push(\n `target-schema runtime capability ${routine.name} owner ${routine.owner} does not match document authority owner ${authorityOwner}`,\n );\n }\n } else if ((VARIABLE_SET_AUTHORITY_ROUTINES as readonly string[]).includes(routine.name)) {\n const authorityTables = [\"workspace_variable_sets\", \"workspace_variable_set_variables\"]\n .map((tableName) => tableByName.get(tableName))\n .filter((table): table is RuntimeTablePosture => table !== undefined);\n const authorityOwners = new Set(authorityTables.map((table) => table.owner));\n if (authorityOwners.size > 1) {\n violations.push(\n `target-schema runtime capability ${routine.name} variable-set table owners do not match`,\n );\n } else {\n const authorityOwner = authorityTables[0]?.owner ?? targetSchemaOwner;\n if (authorityOwner && routine.owner !== authorityOwner) {\n violations.push(\n `target-schema runtime capability ${routine.name} owner ${routine.owner} does not match variable-set authority owner ${authorityOwner}`,\n );\n }\n }\n } else if ((SCOPED_COMPUTE_AUTHORITY_ROUTINES as readonly string[]).includes(routine.name)) {\n const authorityTables = [\"rigs\", \"rig_versions\", \"enrollments\", \"sandboxes\"]\n .map((tableName) => tableByName.get(tableName))\n .filter((table): table is RuntimeTablePosture => table !== undefined);\n const authorityOwners = new Set(authorityTables.map((table) => table.owner));\n if (authorityOwners.size > 1) {\n violations.push(\n `target-schema runtime capability ${routine.name} scoped-compute table owners do not match`,\n );\n } else {\n const authorityOwner = authorityTables[0]?.owner ?? targetSchemaOwner;\n if (authorityOwner && routine.owner !== authorityOwner) {\n violations.push(\n `target-schema runtime capability ${routine.name} owner ${routine.owner} does not match scoped-compute authority owner ${authorityOwner}`,\n );\n }\n }\n } else if (SESSION_AUTHORITY_ROUTINES.has(routine.name)) {\n const authorityOwner = tableByName.get(\"sessions\")?.owner ?? targetSchemaOwner;\n if (authorityOwner && routine.owner !== authorityOwner) {\n violations.push(\n `target-schema runtime capability ${routine.name} owner ${routine.owner} does not match session authority owner ${authorityOwner}`,\n );\n }\n } else if (routine.name === XAI_SNAPSHOT_VALIDATOR_ROUTINE) {\n // The immutable SQL validator is invoker-rights and reads no table. Its\n // exact ACL is posture-checked above; it does not participate in the\n // SECURITY DEFINER same-owner authority graph.\n } else if (\n routine.name === XAI_CREATE_CREDENTIAL_ROUTINE ||\n routine.name === XAI_DISCONNECT_CREDENTIAL_ROUTINE ||\n routine.name === XAI_AUTHORITY_LIVE_ROUTINE ||\n routine.name === XAI_POOL_VISIBLE_ROUTINE ||\n routine.name === XAI_RESOLVE_POOL_ROUTINE ||\n routine.name === XAI_REVALIDATE_CREDENTIAL_ROUTINE\n ) {\n if (!tableByName.has(\"xai_subscription_credentials\")) {\n continue;\n }\n const missingAuthorityTables = XAI_AUTHORITY_TABLES.filter(\n (tableName) => !tableByName.has(tableName),\n );\n if (missingAuthorityTables.length > 0) {\n violations.push(\n `target-schema runtime capability ${routine.name} authority tables are missing: ${missingAuthorityTables.join(\", \")}`,\n );\n } else {\n const authorityTables = XAI_AUTHORITY_TABLES.map(\n (tableName) => tableByName.get(tableName)!,\n );\n const authorityOwners = new Set(authorityTables.map((table) => table.owner));\n if (authorityOwners.size !== 1) {\n violations.push(\n `target-schema runtime capability ${routine.name} authority table owners do not match: ${authorityTables.map((table) => `${table.name}=${table.owner}`).join(\", \")}`,\n );\n } else if (routine.owner !== authorityTables[0]!.owner) {\n violations.push(\n `target-schema runtime capability ${routine.name} owner ${routine.owner} does not match authority table owner ${authorityTables[0]!.owner}`,\n );\n }\n }\n } else if (targetSchemaOwner && routine.owner !== targetSchemaOwner) {\n violations.push(\n `target-schema runtime capability ${routine.name} owner ${routine.owner} does not match schema owner ${targetSchemaOwner}`,\n );\n }\n if (!routine.execute) {\n violations.push(`runtime role lacks target-schema capability ${routine.name}`);\n }\n const publicPolicyPredicate = RUNTIME_TARGET_SCHEMA_PUBLIC_POLICY_PREDICATE_ROUTINE_SET.has(\n routine.name,\n );\n if (publicPolicyPredicate && !routine.publicExecute) {\n violations.push(`PUBLIC lacks required shared-policy predicate ${routine.name}`);\n } else if (!publicPolicyPredicate && routine.publicExecute) {\n violations.push(`PUBLIC has forbidden target-schema capability ${routine.name}`);\n }\n }\n\n const artifactOutbox = tableByName.get(\"editable_artifact_live_outbox\");\n if (artifactOutbox) {\n if (!artifactOutbox.artifactOutboxDispatcherPolicy) {\n violations.push(\"table editable_artifact_live_outbox lacks its owner dispatcher RLS policy\");\n }\n for (const expectedRoutine of ARTIFACT_OUTBOX_CAPABILITY_ROUTINES) {\n const matches = posture.privateRoutines.filter((routine) => routine.name === expectedRoutine);\n if (matches.length !== 1) {\n violations.push(`artifact outbox capability ${expectedRoutine} is missing or ambiguous`);\n continue;\n }\n const routine = matches[0]!;\n if (!routine.securityDefiner) {\n violations.push(`artifact outbox capability ${routine.name} is not SECURITY DEFINER`);\n }\n if (routine.owner !== artifactOutbox.owner) {\n violations.push(\n `artifact outbox capability ${routine.name} owner ${routine.owner} does not match table owner ${artifactOutbox.owner}`,\n );\n }\n if (routine.execute) {\n violations.push(\n `generic runtime role has forbidden global artifact outbox capability ${routine.name}`,\n );\n }\n }\n }\n\n const automaticTitleFanoutOutboxes = posture.privateTables.filter(\n (table) => table.name === AUTOMATIC_SESSION_TITLE_FANOUT_OUTBOX_TABLE,\n );\n const automaticTitleFanoutRoutineNames = new Set<string>([\n ...AUTOMATIC_SESSION_TITLE_FANOUT_RUNTIME_ROUTINES,\n AUTOMATIC_SESSION_TITLE_FANOUT_MIGRATION_ROUTINE,\n AUTOMATIC_SESSION_TITLE_POLICY_TRIGGER_ROUTINE,\n ]);\n const automaticTitleFanoutCatalogPresent = posture.privateRoutines.some((routine) =>\n automaticTitleFanoutRoutineNames.has(routine.name),\n );\n if (automaticTitleFanoutCatalogPresent && automaticTitleFanoutOutboxes.length !== 1) {\n violations.push(\n `automatic session title fanout private outbox ${AUTOMATIC_SESSION_TITLE_FANOUT_OUTBOX_TABLE} is missing or ambiguous`,\n );\n }\n const automaticTitleFanoutOutbox = automaticTitleFanoutOutboxes[0];\n if (automaticTitleFanoutOutbox) {\n if (automaticTitleFanoutOutbox.owner === expectedRole) {\n violations.push(\n `runtime role owns private automatic session title fanout outbox ${automaticTitleFanoutOutbox.name}`,\n );\n }\n if (!automaticTitleFanoutOutbox.rlsEnabled) {\n violations.push(\n `private automatic session title fanout outbox ${automaticTitleFanoutOutbox.name} does not ENABLE RLS`,\n );\n }\n if (!automaticTitleFanoutOutbox.rlsForced) {\n violations.push(\n `private automatic session title fanout outbox ${automaticTitleFanoutOutbox.name} does not FORCE RLS`,\n );\n }\n if (!automaticTitleFanoutOutbox.rlsActive) {\n violations.push(\n `private automatic session title fanout outbox ${automaticTitleFanoutOutbox.name} has inactive RLS for runtime role`,\n );\n }\n if ((automaticTitleFanoutOutbox.policyCount ?? 0) < 1) {\n violations.push(\n `private automatic session title fanout outbox ${automaticTitleFanoutOutbox.name} has no RLS policy`,\n );\n }\n const directPrivileges = [\n [\"SELECT\", automaticTitleFanoutOutbox.select],\n [\"INSERT\", automaticTitleFanoutOutbox.insert],\n [\"UPDATE\", automaticTitleFanoutOutbox.update],\n [\"DELETE\", automaticTitleFanoutOutbox.delete],\n ].filter(([, granted]) => granted);\n if (directPrivileges.length > 0) {\n violations.push(\n `runtime role has forbidden direct privileges on private table ${automaticTitleFanoutOutbox.name}: ${directPrivileges.map(([privilege]) => privilege).join(\", \")}`,\n );\n }\n for (const expectedRoutine of AUTOMATIC_SESSION_TITLE_FANOUT_RUNTIME_ROUTINES) {\n const matches = posture.privateRoutines.filter((routine) => routine.name === expectedRoutine);\n if (matches.length !== 1) {\n violations.push(\n `automatic session title fanout capability ${expectedRoutine} is missing or ambiguous`,\n );\n continue;\n }\n const routine = matches[0]!;\n if (!routine.securityDefiner) {\n violations.push(\n `automatic session title fanout capability ${routine.name} is not SECURITY DEFINER`,\n );\n }\n if (routine.owner !== automaticTitleFanoutOutbox.owner) {\n violations.push(\n `automatic session title fanout capability ${routine.name} owner ${routine.owner} does not match table owner ${automaticTitleFanoutOutbox.owner}`,\n );\n }\n if (!routine.execute) {\n violations.push(\n `runtime role lacks automatic session title fanout capability ${routine.name}`,\n );\n }\n if (routine.publicExecute) {\n violations.push(\n `PUBLIC has forbidden automatic session title fanout capability ${routine.name}`,\n );\n }\n }\n const enqueueMatches = posture.privateRoutines.filter(\n (routine) => routine.name === AUTOMATIC_SESSION_TITLE_FANOUT_MIGRATION_ROUTINE,\n );\n if (enqueueMatches.length !== 1) {\n violations.push(\n `automatic session title fanout migration helper ${AUTOMATIC_SESSION_TITLE_FANOUT_MIGRATION_ROUTINE} is missing or ambiguous`,\n );\n } else {\n const routine = enqueueMatches[0]!;\n if (routine.securityDefiner) {\n violations.push(\n `automatic session title fanout migration helper ${routine.name} must be SECURITY INVOKER`,\n );\n }\n if (routine.owner !== automaticTitleFanoutOutbox.owner) {\n violations.push(\n `automatic session title fanout migration helper ${routine.name} owner ${routine.owner} does not match table owner ${automaticTitleFanoutOutbox.owner}`,\n );\n }\n if (!routine.execute) {\n violations.push(\n `runtime role lacks rolling-compatible automatic session title fanout migration helper ${routine.name}`,\n );\n }\n if (routine.publicExecute) {\n violations.push(\n `PUBLIC has forbidden automatic session title fanout migration helper ${routine.name}`,\n );\n }\n }\n const policyTriggerMatches = posture.privateRoutines.filter(\n (routine) => routine.name === AUTOMATIC_SESSION_TITLE_POLICY_TRIGGER_ROUTINE,\n );\n if (policyTriggerMatches.length !== 1) {\n violations.push(\n `automatic session title policy trigger ${AUTOMATIC_SESSION_TITLE_POLICY_TRIGGER_ROUTINE} is missing or ambiguous`,\n );\n } else {\n const routine = policyTriggerMatches[0]!;\n if (routine.securityDefiner) {\n violations.push(\n `automatic session title policy trigger ${routine.name} must be SECURITY INVOKER`,\n );\n }\n if (routine.owner !== automaticTitleFanoutOutbox.owner) {\n violations.push(\n `automatic session title policy trigger ${routine.name} owner ${routine.owner} does not match table owner ${automaticTitleFanoutOutbox.owner}`,\n );\n }\n if (!routine.execute) {\n violations.push(\n `runtime role lacks rolling-compatible automatic session title policy trigger ${routine.name}`,\n );\n }\n if (routine.publicExecute) {\n violations.push(\n `PUBLIC has forbidden automatic session title policy trigger ${routine.name}`,\n );\n }\n }\n }\n\n const artifactMaterializationJobs = tableByName.get(\"editable_artifact_materialization_jobs\");\n if (artifactMaterializationJobs) {\n for (const tableName of [\n \"editable_artifact_materialization_jobs\",\n \"editable_artifact_materialization_results\",\n \"editable_artifact_blob_refs\",\n \"editable_artifact_sequence_checkpoints\",\n \"editable_artifact_versions\",\n \"editable_artifact_idempotency_receipts\",\n ]) {\n const table = tableByName.get(tableName);\n if (table && !table.artifactMaterializerPolicy) {\n violations.push(`table ${tableName} lacks its owner materializer RLS policy`);\n }\n }\n for (const expectedRoutine of ARTIFACT_MATERIALIZER_CAPABILITY_ROUTINES) {\n const matches = posture.privateRoutines.filter((routine) => routine.name === expectedRoutine);\n if (matches.length !== 1) {\n violations.push(\n `artifact materializer capability ${expectedRoutine} is missing or ambiguous`,\n );\n continue;\n }\n const routine = matches[0]!;\n if (!routine.securityDefiner) {\n violations.push(`artifact materializer capability ${routine.name} is not SECURITY DEFINER`);\n }\n if (routine.owner !== artifactMaterializationJobs.owner) {\n violations.push(\n `artifact materializer capability ${routine.name} owner ${routine.owner} does not match table owner ${artifactMaterializationJobs.owner}`,\n );\n }\n if (routine.execute) {\n violations.push(\n `generic runtime role has forbidden global artifact materializer capability ${routine.name}`,\n );\n }\n }\n }\n const artifactAuthority = tableByName.get(\"editable_artifacts\");\n if (artifactAuthority) {\n const matches = posture.privateRoutines.filter((routine) =>\n routine.name.startsWith(\"advance_editable_artifact_authorization_revision(\"),\n );\n if (matches.length !== 1) {\n violations.push(\n \"editable artifact authorization revision capability is missing or ambiguous\",\n );\n } else {\n const routine = matches[0]!;\n if (!routine.securityDefiner) {\n violations.push(\n `editable artifact authorization revision capability ${routine.name} is not SECURITY DEFINER`,\n );\n }\n if (routine.owner !== artifactAuthority.owner) {\n violations.push(\n `editable artifact authorization revision capability ${routine.name} owner ${routine.owner} does not match table owner ${artifactAuthority.owner}`,\n );\n }\n }\n for (const expectedRoutine of ARTIFACT_AUTHORIZATION_CAPABILITY_ROUTINES) {\n const capabilityMatches = posture.privateRoutines.filter(\n (routine) => routine.name === expectedRoutine,\n );\n if (capabilityMatches.length !== 1) {\n violations.push(\n `editable artifact authorization capability ${expectedRoutine} is missing or ambiguous`,\n );\n continue;\n }\n const routine = capabilityMatches[0]!;\n if (!routine.securityDefiner) {\n violations.push(\n `editable artifact authorization capability ${routine.name} is not SECURITY DEFINER`,\n );\n }\n if (routine.owner !== artifactAuthority.owner) {\n violations.push(\n `editable artifact authorization capability ${routine.name} owner ${routine.owner} does not match table owner ${artifactAuthority.owner}`,\n );\n }\n if (!routine.execute) {\n violations.push(\n `runtime role lacks editable artifact authorization capability ${routine.name}`,\n );\n }\n }\n }\n\n const artifactLiveTickets = tableByName.get(\"editable_artifact_live_tickets\");\n if (artifactLiveTickets) {\n for (const expectedRoutine of ARTIFACT_LIVE_TICKET_CAPABILITY_ROUTINES) {\n const matches = posture.privateRoutines.filter((routine) => routine.name === expectedRoutine);\n if (matches.length !== 1) {\n violations.push(\n `artifact live ticket capability ${expectedRoutine} is missing or ambiguous`,\n );\n continue;\n }\n const routine = matches[0]!;\n if (!routine.securityDefiner) {\n violations.push(`artifact live ticket capability ${routine.name} is not SECURITY DEFINER`);\n }\n if (routine.owner !== artifactLiveTickets.owner) {\n violations.push(\n `artifact live ticket capability ${routine.name} owner ${routine.owner} does not match table owner ${artifactLiveTickets.owner}`,\n );\n }\n if (!routine.execute) {\n violations.push(`runtime role lacks artifact live ticket capability ${routine.name}`);\n }\n }\n for (const internalRoutine of ARTIFACT_LIVE_TICKET_INTERNAL_ROUTINES) {\n const matches = posture.privateRoutines.filter((routine) => routine.name === internalRoutine);\n if (matches.length !== 1) {\n violations.push(\n `artifact live ticket internal routine ${internalRoutine} is missing or ambiguous`,\n );\n continue;\n }\n const routine = matches[0]!;\n if (!routine.securityDefiner) {\n violations.push(\n `artifact live ticket internal routine ${routine.name} is not SECURITY DEFINER`,\n );\n }\n if (routine.owner !== artifactLiveTickets.owner) {\n violations.push(\n `artifact live ticket internal routine ${routine.name} owner ${routine.owner} does not match table owner ${artifactLiveTickets.owner}`,\n );\n }\n if (routine.execute) {\n violations.push(`runtime role has forbidden ticket schema resolver ${routine.name}`);\n }\n }\n }\n\n const personalResourceCapabilityTables = posture.privateTables.filter(\n (table) => table.name === PERSONAL_RESOURCE_CAPABILITY_TABLE,\n );\n const personalResourceCapabilityRoutines = posture.privateRoutines.filter(\n (routine) => routine.name === PERSONAL_RESOURCE_CAPABILITY_PREDICATE_ROUTINE,\n );\n if (personalResourceCapabilityTables.length !== 1) {\n violations.push(\n `personal-resource capability table ${PERSONAL_RESOURCE_CAPABILITY_TABLE} is missing or ambiguous`,\n );\n }\n if (personalResourceCapabilityRoutines.length !== 1) {\n violations.push(\n `personal-resource capability predicate ${PERSONAL_RESOURCE_CAPABILITY_PREDICATE_ROUTINE} is missing or ambiguous`,\n );\n }\n if (\n personalResourceCapabilityTables.length === 1 &&\n personalResourceCapabilityRoutines.length === 1\n ) {\n const table = personalResourceCapabilityTables[0]!;\n const routine = personalResourceCapabilityRoutines[0]!;\n if (routine.owner !== table.owner) {\n violations.push(\n `personal-resource capability predicate ${routine.name} owner ${routine.owner} does not match table owner ${table.owner}`,\n );\n }\n if (!routine.securityDefiner) {\n violations.push(\n `personal-resource capability predicate ${routine.name} is not SECURITY DEFINER`,\n );\n }\n if (!routine.execute) {\n violations.push(`runtime role lacks personal-resource capability predicate ${routine.name}`);\n }\n if (routine.publicExecute) {\n violations.push(\n `PUBLIC has forbidden personal-resource capability predicate ${routine.name}`,\n );\n }\n const directPrivileges = [\n [\"SELECT\", table.select],\n [\"INSERT\", table.insert],\n [\"UPDATE\", table.update],\n [\"DELETE\", table.delete],\n ].filter(([, granted]) => granted);\n if (directPrivileges.length > 0) {\n violations.push(\n `runtime role has forbidden direct privileges on private table ${table.name}: ${directPrivileges.map(([privilege]) => privilege).join(\", \")}`,\n );\n }\n }\n\n const personalDocumentCapabilityTables = posture.privateTables.filter(\n (table) => table.name === PERSONAL_DOCUMENT_CAPABILITY_TABLE,\n );\n const personalDocumentCapabilityRoutines = posture.privateRoutines.filter(\n (routine) => routine.name === PERSONAL_DOCUMENT_CAPABILITY_PREDICATE_ROUTINE,\n );\n if (personalDocumentCapabilityTables.length !== 1) {\n violations.push(\n `personal-document capability table ${PERSONAL_DOCUMENT_CAPABILITY_TABLE} is missing or ambiguous`,\n );\n }\n if (personalDocumentCapabilityRoutines.length !== 1) {\n violations.push(\n `personal-document capability predicate ${PERSONAL_DOCUMENT_CAPABILITY_PREDICATE_ROUTINE} is missing or ambiguous`,\n );\n }\n if (\n personalDocumentCapabilityTables.length === 1 &&\n personalDocumentCapabilityRoutines.length === 1\n ) {\n const table = personalDocumentCapabilityTables[0]!;\n const routine = personalDocumentCapabilityRoutines[0]!;\n if (routine.owner !== table.owner) {\n violations.push(\n `personal-document capability predicate ${routine.name} owner ${routine.owner} does not match table owner ${table.owner}`,\n );\n }\n if (!routine.securityDefiner) {\n violations.push(\n `personal-document capability predicate ${routine.name} is not SECURITY DEFINER`,\n );\n }\n if (!routine.execute) {\n violations.push(`runtime role lacks personal-document capability predicate ${routine.name}`);\n }\n if (routine.publicExecute) {\n violations.push(\n `PUBLIC has forbidden personal-document capability predicate ${routine.name}`,\n );\n }\n const directPrivileges = [\n [\"SELECT\", table.select],\n [\"INSERT\", table.insert],\n [\"UPDATE\", table.update],\n [\"DELETE\", table.delete],\n ].filter(([, granted]) => granted);\n if (directPrivileges.length > 0) {\n violations.push(\n `runtime role has forbidden direct privileges on private table ${table.name}: ${directPrivileges.map(([privilege]) => privilege).join(\", \")}`,\n );\n }\n }\n\n const documentMigrationCapabilityTables = posture.privateTables.filter(\n (table) => table.name === DOCUMENT_MIGRATION_CAPABILITY_TABLE,\n );\n const documentMigrationCapabilityRoutines = posture.privateRoutines.filter(\n (routine) => routine.name === DOCUMENT_MIGRATION_CAPABILITY_PREDICATE_ROUTINE,\n );\n if (documentMigrationCapabilityTables.length !== 1) {\n violations.push(\n `document-migration capability table ${DOCUMENT_MIGRATION_CAPABILITY_TABLE} is missing or ambiguous`,\n );\n }\n if (documentMigrationCapabilityRoutines.length !== 1) {\n violations.push(\n `document-migration capability predicate ${DOCUMENT_MIGRATION_CAPABILITY_PREDICATE_ROUTINE} is missing or ambiguous`,\n );\n }\n if (\n documentMigrationCapabilityTables.length === 1 &&\n documentMigrationCapabilityRoutines.length === 1\n ) {\n const table = documentMigrationCapabilityTables[0]!;\n const routine = documentMigrationCapabilityRoutines[0]!;\n if (routine.owner !== table.owner) {\n violations.push(\n `document-migration capability predicate ${routine.name} owner ${routine.owner} does not match table owner ${table.owner}`,\n );\n }\n if (!routine.securityDefiner) {\n violations.push(\n `document-migration capability predicate ${routine.name} is not SECURITY DEFINER`,\n );\n }\n if (!routine.execute) {\n violations.push(`runtime role lacks document-migration capability predicate ${routine.name}`);\n }\n if (routine.publicExecute) {\n violations.push(\n `PUBLIC has forbidden document-migration capability predicate ${routine.name}`,\n );\n }\n const directPrivileges = [\n [\"SELECT\", table.select],\n [\"INSERT\", table.insert],\n [\"UPDATE\", table.update],\n [\"DELETE\", table.delete],\n ].filter(([, granted]) => granted);\n if (directPrivileges.length > 0) {\n violations.push(\n `runtime role has forbidden direct privileges on private table ${table.name}: ${directPrivileges.map(([privilege]) => privilege).join(\", \")}`,\n );\n }\n }\n\n const scheduledCapabilityTables = posture.privateTables.filter(\n (table) => table.name === SCHEDULED_PERSONAL_RESOURCE_CAPABILITY_TABLE,\n );\n const scheduledCapabilityRoutines = posture.privateRoutines.filter(\n (routine) => routine.name === SCHEDULED_PERSONAL_RESOURCE_CAPABILITY_PREDICATE_ROUTINE,\n );\n if (scheduledCapabilityTables.length !== 1) {\n violations.push(\n `scheduled personal-resource capability table ${SCHEDULED_PERSONAL_RESOURCE_CAPABILITY_TABLE} is missing or ambiguous`,\n );\n }\n if (scheduledCapabilityRoutines.length !== 1) {\n violations.push(\n `scheduled personal-resource capability predicate ${SCHEDULED_PERSONAL_RESOURCE_CAPABILITY_PREDICATE_ROUTINE} is missing or ambiguous`,\n );\n }\n if (scheduledCapabilityTables.length === 1 && scheduledCapabilityRoutines.length === 1) {\n const table = scheduledCapabilityTables[0]!;\n const routine = scheduledCapabilityRoutines[0]!;\n if (routine.owner !== table.owner) {\n violations.push(\n `scheduled personal-resource capability predicate ${routine.name} owner ${routine.owner} does not match table owner ${table.owner}`,\n );\n }\n if (!routine.securityDefiner) {\n violations.push(\n `scheduled personal-resource capability predicate ${routine.name} is not SECURITY DEFINER`,\n );\n }\n if (!routine.execute) {\n violations.push(\n `runtime role lacks scheduled personal-resource capability predicate ${routine.name}`,\n );\n }\n if (routine.publicExecute) {\n violations.push(\n `PUBLIC has forbidden scheduled personal-resource capability predicate ${routine.name}`,\n );\n }\n const directPrivileges = [\n [\"SELECT\", table.select],\n [\"INSERT\", table.insert],\n [\"UPDATE\", table.update],\n [\"DELETE\", table.delete],\n ].filter(([, granted]) => granted);\n if (directPrivileges.length > 0) {\n violations.push(\n `runtime role has forbidden direct privileges on private table ${table.name}: ${directPrivileges.map(([privilege]) => privilege).join(\", \")}`,\n );\n }\n }\n\n if (options.protectedTables === undefined) {\n const variableSetCapabilityTables = posture.privateTables.filter(\n (table) => table.name === VARIABLE_SET_CAPABILITY_TABLE,\n );\n const variableSetCapabilityRoutines = posture.privateRoutines.filter(\n (routine) => routine.name === VARIABLE_SET_CAPABILITY_PREDICATE_ROUTINE,\n );\n if (variableSetCapabilityTables.length !== 1) {\n violations.push(\n `variable-set capability table ${VARIABLE_SET_CAPABILITY_TABLE} is missing or ambiguous`,\n );\n }\n if (variableSetCapabilityRoutines.length !== 1) {\n violations.push(\n `variable-set capability predicate ${VARIABLE_SET_CAPABILITY_PREDICATE_ROUTINE} is missing or ambiguous`,\n );\n }\n if (variableSetCapabilityTables.length === 1 && variableSetCapabilityRoutines.length === 1) {\n const table = variableSetCapabilityTables[0]!;\n const routine = variableSetCapabilityRoutines[0]!;\n if (routine.owner !== table.owner) {\n violations.push(\n `variable-set capability predicate ${routine.name} owner ${routine.owner} does not match table owner ${table.owner}`,\n );\n }\n if (!routine.securityDefiner) {\n violations.push(\n `variable-set capability predicate ${routine.name} is not SECURITY DEFINER`,\n );\n }\n if (!routine.execute) {\n violations.push(`runtime role lacks variable-set capability predicate ${routine.name}`);\n }\n if (routine.publicExecute) {\n violations.push(`PUBLIC has forbidden variable-set capability predicate ${routine.name}`);\n }\n const directPrivileges = [\n [\"SELECT\", table.select],\n [\"INSERT\", table.insert],\n [\"UPDATE\", table.update],\n [\"DELETE\", table.delete],\n ].filter(([, granted]) => granted);\n if (directPrivileges.length > 0) {\n violations.push(\n `runtime role has forbidden direct privileges on private table ${table.name}: ${directPrivileges.map(([privilege]) => privilege).join(\", \")}`,\n );\n }\n }\n const scopedComputeCapabilityTables = posture.privateTables.filter(\n (table) => table.name === SCOPED_COMPUTE_CAPABILITY_TABLE,\n );\n const scopedComputeCapabilityRoutines = posture.privateRoutines.filter(\n (routine) => routine.name === SCOPED_COMPUTE_CAPABILITY_PREDICATE_ROUTINE,\n );\n if (scopedComputeCapabilityTables.length !== 1) {\n violations.push(\n `scoped-compute capability table ${SCOPED_COMPUTE_CAPABILITY_TABLE} is missing or ambiguous`,\n );\n }\n if (scopedComputeCapabilityRoutines.length !== 1) {\n violations.push(\n `scoped-compute capability predicate ${SCOPED_COMPUTE_CAPABILITY_PREDICATE_ROUTINE} is missing or ambiguous`,\n );\n }\n if (\n scopedComputeCapabilityTables.length === 1 &&\n scopedComputeCapabilityRoutines.length === 1\n ) {\n const table = scopedComputeCapabilityTables[0]!;\n const routine = scopedComputeCapabilityRoutines[0]!;\n if (routine.owner !== table.owner) {\n violations.push(\n `scoped-compute capability predicate ${routine.name} owner ${routine.owner} does not match table owner ${table.owner}`,\n );\n }\n if (!routine.securityDefiner) {\n violations.push(\n `scoped-compute capability predicate ${routine.name} is not SECURITY DEFINER`,\n );\n }\n if (!routine.execute) {\n violations.push(`runtime role lacks scoped-compute capability predicate ${routine.name}`);\n }\n if (routine.publicExecute) {\n violations.push(`PUBLIC has forbidden scoped-compute capability predicate ${routine.name}`);\n }\n const directPrivileges = [\n [\"SELECT\", table.select],\n [\"INSERT\", table.insert],\n [\"UPDATE\", table.update],\n [\"DELETE\", table.delete],\n ].filter(([, granted]) => granted);\n if (directPrivileges.length > 0) {\n violations.push(\n `runtime role has forbidden direct privileges on private table ${table.name}: ${directPrivileges.map(([privilege]) => privilege).join(\", \")}`,\n );\n }\n }\n }\n\n if (posture.privateRoutines.length === 0) {\n violations.push(\"opengeni_private has no helper routines\");\n }\n\n const connectionBackfillCapabilityTables = posture.privateTables.filter(\n (table) => table.name === CONNECTION_TENANCY_BACKFILL_CAPABILITY_TABLE,\n );\n const connectionBackfillCapabilityRoutines = posture.privateRoutines.filter(\n (routine) => routine.name === CONNECTION_TENANCY_BACKFILL_CAPABILITY_PREDICATE_ROUTINE,\n );\n if (connectionBackfillCapabilityTables.length !== 1) {\n violations.push(\n `connection-tenancy backfill capability table ${CONNECTION_TENANCY_BACKFILL_CAPABILITY_TABLE} is missing or ambiguous`,\n );\n }\n if (connectionBackfillCapabilityRoutines.length !== 1) {\n violations.push(\n `connection-tenancy backfill capability predicate ${CONNECTION_TENANCY_BACKFILL_CAPABILITY_PREDICATE_ROUTINE} is missing or ambiguous`,\n );\n }\n if (\n connectionBackfillCapabilityTables.length === 1 &&\n connectionBackfillCapabilityRoutines.length === 1\n ) {\n const table = connectionBackfillCapabilityTables[0]!;\n const routine = connectionBackfillCapabilityRoutines[0]!;\n if (routine.owner !== table.owner) {\n violations.push(\n `connection-tenancy backfill capability predicate ${routine.name} owner ${routine.owner} does not match table owner ${table.owner}`,\n );\n }\n if (!routine.securityDefiner) {\n violations.push(\n `connection-tenancy backfill capability predicate ${routine.name} is not SECURITY DEFINER`,\n );\n }\n if (!routine.execute) {\n violations.push(\n `runtime role lacks connection-tenancy backfill capability predicate ${routine.name}`,\n );\n }\n if (routine.publicExecute) {\n violations.push(\n `PUBLIC has forbidden connection-tenancy backfill capability predicate ${routine.name}`,\n );\n }\n const directPrivileges = [\n [\"SELECT\", table.select],\n [\"INSERT\", table.insert],\n [\"UPDATE\", table.update],\n [\"DELETE\", table.delete],\n ].filter(([, granted]) => granted);\n if (directPrivileges.length > 0) {\n violations.push(\n `runtime role has forbidden direct privileges on private table ${table.name}: ${directPrivileges.map(([privilege]) => privilege).join(\", \")}`,\n );\n }\n }\n\n for (const routine of posture.privateRoutines) {\n if (routine.owner === expectedRole) {\n violations.push(`runtime role owns private routine ${routine.name}`);\n }\n const ownerInternalRoutine = OWNER_INTERNAL_PRIVATE_ROUTINES.has(routine.name);\n if (\n [\n \"guard_workspace_owned_skill_head_delete()\",\n \"guard_workspace_owned_skill_history_delete()\",\n ].includes(routine.name) &&\n (routine.execute || routine.publicExecute)\n ) {\n violations.push(\n `runtime or PUBLIC has forbidden EXECUTE on Skill cascade guard ${routine.name}`,\n );\n }\n if (!routine.execute && !ownerInternalRoutine) {\n violations.push(`runtime role lacks EXECUTE on private routine ${routine.name}`);\n }\n }\n\n return violations;\n}\n\nexport async function assertRuntimeDatabasePosture(\n db: Database,\n options: RuntimeDatabasePostureOptions,\n): Promise<RuntimeDatabasePosture> {\n const posture = await inspectRuntimeDatabasePosture(db, options);\n const violations = evaluateRuntimeDatabasePosture(posture, options);\n if (violations.length > 0) {\n throw new RuntimeDatabasePostureError(violations);\n }\n return posture;\n}\n\nexport function runtimeDatabaseReadyCheck(\n db: Database,\n options: RuntimeDatabasePostureOptions,\n): () => Promise<void> {\n return async () => {\n await assertRuntimeDatabasePosture(db, options);\n };\n}\n","export type RoleRelationshipDirection = \"inherits\" | \"member\";\n\nexport type RoleRelationshipCatalogRow = {\n relationship: string;\n direction: RoleRelationshipDirection;\n server_version_num: number;\n admin_option: boolean | null;\n inherit_option: boolean | null;\n set_option: boolean | null;\n member_is_superuser: boolean | null;\n member_can_create_role: boolean | null;\n grantor_role: string | null;\n grantor_is_superuser: boolean | null;\n};\n\nexport type ClassifiedRoleRelationships = {\n relationships: string[];\n managementOnlyRelationships: string[];\n unsafeRelationships: string[];\n};\n\ntype RoleTargetExpression = \"current_user\" | \"$1\";\n\n/**\n * One PostgreSQL 15-compatible catalog query for both provisioning and runtime\n * posture. PostgreSQL 16 added per-membership INHERIT and SET columns; reading\n * the catalog row through to_jsonb keeps this statement parseable on 15 while\n * leaving the missing options null and therefore fail-closed.\n */\nexport function roleRelationshipsCatalogQuery(targetRole: RoleTargetExpression): string {\n return `\nwith recursive target_role(oid, rolname) as (\n select oid, rolname\n from pg_roles\n where rolname = ${targetRole}\n), inherited_roles(oid, rolname) as (\n select parent.oid, parent.rolname\n from pg_auth_members membership\n join target_role target on target.oid = membership.member\n join pg_roles parent on parent.oid = membership.roleid\n union\n select parent.oid, parent.rolname\n from inherited_roles inherited\n join pg_auth_members membership on membership.member = inherited.oid\n join pg_roles parent on parent.oid = membership.roleid\n), relationships as (\n select\n ('inherits:' || inherited.rolname)::text as relationship,\n 'inherits'::text as direction,\n null::boolean as admin_option,\n null::boolean as inherit_option,\n null::boolean as set_option,\n null::boolean as member_is_superuser,\n null::boolean as member_can_create_role,\n null::text as grantor_role,\n null::boolean as grantor_is_superuser\n from inherited_roles inherited\n union all\n select\n ('member:' || member.rolname)::text as relationship,\n 'member'::text as direction,\n membership.admin_option,\n case\n when current_setting('server_version_num')::integer >= 160000\n then (to_jsonb(membership) ->> 'inherit_option')::boolean\n else null::boolean\n end as inherit_option,\n case\n when current_setting('server_version_num')::integer >= 160000\n then (to_jsonb(membership) ->> 'set_option')::boolean\n else null::boolean\n end as set_option,\n member.rolsuper as member_is_superuser,\n member.rolcreaterole as member_can_create_role,\n grantor.rolname::text as grantor_role,\n grantor.rolsuper as grantor_is_superuser\n from pg_auth_members membership\n join target_role target on target.oid = membership.roleid\n join pg_roles member on member.oid = membership.member\n left join pg_roles grantor on grantor.oid = membership.grantor\n)\nselect\n relationship,\n direction,\n current_setting('server_version_num')::integer as server_version_num,\n admin_option,\n inherit_option,\n set_option,\n member_is_superuser,\n member_can_create_role,\n grantor_role,\n grantor_is_superuser\nfrom relationships\norder by relationship, direction, grantor_role nulls first\n`;\n}\n\n/**\n * PostgreSQL 16+ automatically gives a non-superuser CREATEROLE principal an\n * ADMIN-only grant on a role it creates. The exact edge below permits role\n * management but cannot inherit the app role's privileges or SET ROLE into it.\n */\nexport function isManagementOnlyRoleRelationship(row: RoleRelationshipCatalogRow): boolean {\n return (\n row.direction === \"member\" &&\n row.server_version_num >= 160000 &&\n row.admin_option === true &&\n row.inherit_option === false &&\n row.set_option === false &&\n row.member_is_superuser === false &&\n row.member_can_create_role === true &&\n row.grantor_is_superuser === true\n );\n}\n\nfunction sortedUnique(values: Iterable<string>): string[] {\n return [...new Set(values)].sort((a, b) => a.localeCompare(b));\n}\n\n/** Classify exact management-only reverse grants while rejecting every other edge. */\nexport function classifyRoleRelationships(\n rows: readonly RoleRelationshipCatalogRow[],\n): ClassifiedRoleRelationships {\n const managementOnlyRows = rows.filter(isManagementOnlyRoleRelationship);\n const unsafeRows = rows.filter((row) => !isManagementOnlyRoleRelationship(row));\n\n return {\n relationships: sortedUnique(rows.map((row) => row.relationship)),\n managementOnlyRelationships: sortedUnique(managementOnlyRows.map((row) => row.relationship)),\n unsafeRelationships: sortedUnique(unsafeRows.map((row) => row.relationship)),\n };\n}\n"],"mappings":";AAAA,OAAO,cAAc;;;ACArB,SAAS,WAAW;;;AC6Bb,SAAS,8BAA8B,YAA0C;AACtF,SAAO;AAAA;AAAA;AAAA;AAAA,oBAIW,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA6D9B;AAOO,SAAS,iCAAiC,KAA0C;AACzF,SACE,IAAI,cAAc,YAClB,IAAI,sBAAsB,QAC1B,IAAI,iBAAiB,QACrB,IAAI,mBAAmB,SACvB,IAAI,eAAe,SACnB,IAAI,wBAAwB,SAC5B,IAAI,2BAA2B,QAC/B,IAAI,yBAAyB;AAEjC;AAEA,SAAS,aAAa,QAAoC;AACxD,SAAO,CAAC,GAAG,IAAI,IAAI,MAAM,CAAC,EAAE,KAAK,CAAC,GAAG,MAAM,EAAE,cAAc,CAAC,CAAC;AAC/D;AAGO,SAAS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;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL;AAEO,IAAM,yCAAyC;AAAA,EACpD;AAAA,EACA;AAAA,EACA;AACF;AACA,IAAM,4CAA4C,IAAI;AAAA,EACpD;AACF;AAOO,IAAM,mBAAmB;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAOO,IAAM,yBAAyB;AAAA,EACpC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAOO,IAAM,0BAA0B;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAGO,IAAM,2BAA2B;AAAA,EACtC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAGO,IAAM,6BAA6B,CAAC,sCAAsC;AAG1E,IAAM,6BAA6B;AAAA,EACxC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAGO,IAAM,oCAAoC;AAAA,EAC/C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAMO,IAAM,iCAAiC;AAAA,EAC5C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,E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