@opengeni/db 1.0.1 → 3.2.0-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.
- package/dist/attached-browser-devices.d.ts +7 -0
- package/dist/automations.d.ts +154 -0
- package/dist/canonical-human-identities.js +3 -3
- package/dist/capability-integrations.d.ts +13 -0
- package/dist/child-lifecycle-notices.d.ts +68 -0
- package/dist/{chunk-4SR4HKKA.js → chunk-2EH4WRHL.js} +19 -11
- package/dist/chunk-2EH4WRHL.js.map +1 -0
- package/dist/{chunk-CUPM3FGB.js → chunk-2PRS4J5Q.js} +3 -3
- package/dist/chunk-6HMM2R5T.js +390 -0
- package/dist/chunk-6HMM2R5T.js.map +1 -0
- package/dist/{chunk-ZWREYEWA.js → chunk-AZHW7R5V.js} +56 -11
- package/dist/chunk-AZHW7R5V.js.map +1 -0
- package/dist/{chunk-LTG3S6ZY.js → chunk-E6CLMKEE.js} +2 -2
- package/dist/{chunk-6ZYKCRFO.js → chunk-KRLPEMLH.js} +7591 -4417
- package/dist/chunk-KRLPEMLH.js.map +1 -0
- package/dist/chunk-NAB6FKFN.js +516 -0
- package/dist/chunk-NAB6FKFN.js.map +1 -0
- package/dist/{chunk-SK7YYHBI.js → chunk-SIBYBA2D.js} +46 -1
- package/dist/chunk-SIBYBA2D.js.map +1 -0
- package/dist/chunk-UZNXG44K.js +4508 -0
- package/dist/chunk-UZNXG44K.js.map +1 -0
- package/dist/codemode-operations.d.ts +1 -6
- package/dist/company-brain-context-selection-schema.d.ts +705 -0
- package/dist/company-brain-context-selection.d.ts +94 -0
- package/dist/company-brain-governed-writes.d.ts +24 -0
- package/dist/company-brain.d.ts +55 -0
- package/dist/company-profile-agent-admin.d.ts +15 -0
- package/dist/company-profile-schema.d.ts +619 -2
- package/dist/company-profile.d.ts +9 -4
- package/dist/connection-authority.d.ts +95 -0
- package/dist/connection-scopes.d.ts +8 -0
- package/dist/connection-tenancy-backfill.d.ts +85 -0
- package/dist/connection-token-resolver.d.ts +30 -1
- package/dist/database.d.ts +23 -4
- package/dist/editable-artifact-durable-export.js +2 -2
- package/dist/editable-artifacts.d.ts +2 -2
- package/dist/editable-artifacts.js +3 -3
- package/dist/governed-learning-activation-schema.d.ts +984 -0
- package/dist/governed-learning-activation.d.ts +98 -0
- package/dist/governed-learning-evaluator-schema.d.ts +633 -0
- package/dist/governed-learning-evaluator.d.ts +28 -0
- package/dist/index.d.ts +1606 -81
- package/dist/index.js +21898 -8147
- package/dist/index.js.map +1 -1
- package/dist/insights.d.ts +18 -0
- package/dist/integration-bindings.d.ts +1 -0
- package/dist/integration-facets.d.ts +30 -0
- package/dist/interaction-placement-loss.d.ts +22 -0
- package/dist/managed-human-provisioning.d.ts +25 -0
- package/dist/memory-domain.d.ts +3 -3
- package/dist/migrate.d.ts +11 -1
- package/dist/migrate.js +1 -1
- package/dist/new-session-drafts.d.ts +43 -5
- package/dist/organization-membership-backfill.d.ts +174 -0
- package/dist/organization-membership-lifecycle.d.ts +162 -0
- package/dist/pr-review.d.ts +107 -0
- package/dist/preference-registry-schema.d.ts +2 -0
- package/dist/preference-registry.d.ts +2 -0
- package/dist/provision-roles.js +1 -1
- package/dist/runtime-posture.d.ts +29 -8
- package/dist/schema.d.ts +24914 -13703
- package/dist/schema.js +99 -1
- package/dist/scoped-knowledge-schema.d.ts +52 -1
- package/dist/session-background-commands.d.ts +125 -0
- package/dist/session-background-commands.js +34 -0
- package/dist/session-background-commands.js.map +1 -0
- package/dist/session-control.d.ts +156 -3
- package/dist/session-goal-pacing.d.ts +68 -0
- package/dist/session-queue-commands.d.ts +43 -4
- package/dist/session-realtime-ledger.d.ts +2 -0
- package/dist/session-tenancy.d.ts +71 -1
- package/dist/session-tenancy.js +25 -3
- package/dist/session-tool-call-settlement.d.ts +9 -4
- package/dist/slack-routing-personal-workspace.d.ts +23 -0
- package/dist/slack-routing.d.ts +268 -0
- package/dist/slack-task-policy-schema.d.ts +34 -0
- package/dist/slack-task-policy.d.ts +8 -0
- package/dist/slack-user-link-access.d.ts +28 -0
- package/dist/task-notes-schema.d.ts +594 -0
- package/dist/task-notes.d.ts +39 -0
- package/dist/turn-initiator.d.ts +2 -0
- package/dist/user-resource-authority.d.ts +109 -0
- package/dist/video-generation.js +3 -3
- package/dist/workspace-authority.d.ts +81 -0
- package/dist/workspace-instruction-policies-schema.d.ts +279 -0
- package/dist/workspace-instruction-policies.d.ts +62 -0
- package/dist/workspace-learning-policy.d.ts +1 -0
- package/dist/workspace-membership-permissions.d.ts +2 -0
- package/drizzle/0240_enrollment_connection_authority.sql +39 -0
- package/drizzle/0241_atomic_personal_resource_delegation.sql +1000 -0
- package/drizzle/0241_enrollment_agent_runtime.sql +70 -0
- package/drizzle/0244_slack_app_home_refresh_queue.sql +120 -0
- package/drizzle/0245_model_context_contribution_facts.sql +88 -0
- package/drizzle/0246_integration_personal_instance_authority.sql +70 -0
- package/drizzle/0247_terraform_stacks_provenance_repair.sql +428 -0
- package/drizzle/0248_terraform_stacks_component_resolution_fence.sql +83 -0
- package/drizzle/0249_personal_resource_delegation_authority_correction.sql +662 -0
- package/drizzle/0250_direct_retained_process_owner_liveness.sql +199 -0
- package/drizzle/0251_connected_machine_operation_policy.sql +45 -0
- package/drizzle/0252_scheduled_personal_resource_delegation.sql +1867 -0
- package/drizzle/0253_common_user_resource_authority_lifecycle.sql +1555 -0
- package/drizzle/0254_scoped_variable_set_authority.sql +1255 -0
- package/drizzle/0255_company_brain_governed_write_proposals.sql +524 -0
- package/drizzle/0256_connection_authority_delegation.sql +703 -0
- package/drizzle/0257_goal_revision_decisions_and_root_constraints.sql +436 -0
- package/drizzle/0258_three_scope_document_knowledge_authority.sql +1273 -0
- package/drizzle/0259_company_brain_context_selection_receipts.sql +869 -0
- package/drizzle/0260_task_note_knowledge_promotion.sql +820 -0
- package/drizzle/0261_preference_knowledge_proposal_actor_binding.sql +471 -0
- package/drizzle/0262_scoped_connected_machines_and_rigs.sql +1700 -0
- package/drizzle/0263_organization_membership_lifecycle.sql +3284 -0
- package/drizzle/0264_connection_authority_runtime_activation.sql +1084 -0
- package/drizzle/0266_company_brain_context_receipt_inspection.sql +156 -0
- package/drizzle/0268_governed_learning_decision_receipts.sql +825 -0
- package/drizzle/0269_governed_learning_activation_controller.sql +1874 -0
- package/drizzle/0270_governed_learning_history_inspection.sql +170 -0
- package/drizzle/0271_company_brain_retrieval_only_default.sql +524 -0
- package/drizzle/0272_human_confirmed_learning_activation.sql +591 -0
- package/drizzle/0273_scheduled_variable_set_materialization.sql +268 -0
- package/drizzle/0274_human_confirmed_knowledge_review.sql +310 -0
- package/drizzle/0275_scheduled_connection_authority.sql +5527 -0
- package/drizzle/0276_onboarding_proposal_initiating_human_guc.sql +198 -0
- package/drizzle/0277_workspace_writer_authority_attribution.sql +393 -0
- package/drizzle/0278_workspace_membership_removal_fencing.sql +1174 -0
- package/drizzle/0279_workspace_connection_use_lane.sql +343 -0
- package/drizzle/0280_connection_and_variable_set_audit_attribution.sql +773 -0
- package/drizzle/0281_viewer_holder_authority_claims.sql +52 -0
- package/drizzle/0282_variable_set_session_attach_attribution.sql +178 -0
- package/drizzle/0283_editable_spreadsheet_authored_state.sql +82 -0
- package/drizzle/0284_truthful_human_confirmed_review_reason.sql +930 -0
- package/drizzle/0285_organization_tenancy_inventory.sql +329 -0
- package/drizzle/0286_widen_task_note_expiry_ceiling.sql +391 -0
- package/drizzle/0287_open_suffix_pending_tool_calls.sql +18 -0
- package/drizzle/0288_attached_browser_reenrollment.sql +64 -0
- package/drizzle/0289_session_composer_policy_authority.sql +597 -0
- package/drizzle/0290_organization_membership_backfill.sql +268 -0
- package/drizzle/0291_resource_authority_classification_assertion.sql +371 -0
- package/drizzle/0292_truthful_tenancy_inventory_counters.sql +291 -0
- package/drizzle/0293_confirm_time_rule_rebaseline.sql +615 -0
- package/drizzle/0294_preference_activation_authority.sql +237 -0
- package/drizzle/0295_retire_legacy_standing_memory_mode.sql +476 -0
- package/drizzle/0296_force_rls_backfill_noop_repair.sql +215 -0
- package/drizzle/0297_session_ownership_classification_and_backfill.sql +752 -0
- package/drizzle/0298_organization_tenancy_parity.sql +609 -0
- package/drizzle/0299_organization_membership_lock_order.sql +291 -0
- package/drizzle/0300_tenancy_backfill_ledger.sql +459 -0
- package/drizzle/0301_session_snapshot_and_pin_visibility.sql +181 -0
- package/drizzle/0302_personal_workspace_session_ownership.sql +303 -0
- package/drizzle/0303_session_tenancy_product_activation.sql +919 -0
- package/drizzle/0304_personal_workspace_private_session_reads.sql +97 -0
- package/drizzle/0305_personal_resource_grant_management.sql +584 -0
- package/drizzle/0306_atomic_personal_resource_attachments.sql +1374 -0
- package/drizzle/0307_session_attention_state.sql +51 -0
- package/drizzle/0308_session_archives.sql +35 -0
- package/drizzle/0309_channel_project_pins.sql +6 -0
- package/drizzle/0310_channel_project_order.sql +27 -0
- package/drizzle/0311_company_scope_and_private_session_create.sql +656 -0
- package/drizzle/0312_quiescent_session_tree_deletion.sql +39 -0
- package/drizzle/0313_private_child_session_authority.sql +365 -0
- package/drizzle/0314_unregistered_organization_invitations.sql +606 -0
- package/drizzle/0315_personal_github_repository_selection.sql +624 -0
- package/drizzle/0316_human_confirmed_activation_resumed_generation.sql +869 -0
- package/drizzle/0317_session_goal_continuation_hold.sql +64 -0
- package/drizzle/0318_session_turn_startup_milestones.sql +115 -0
- package/drizzle/0319_event_triggered_automations.sql +254 -0
- package/drizzle/0320_pr_review_pack.sql +113 -0
- package/drizzle/0321_slack_bot_environment_display_name.sql +15 -0
- package/drizzle/0322_session_turns_unclaimed_prompt_trigger_index.sql +5 -0
- package/drizzle/0323_organization_private_session_enablement.sql +489 -0
- package/drizzle/0324_human_confirmed_company_profile_agent_admin.sql +856 -0
- package/drizzle/0325_child_lifecycle_notices.sql +44 -0
- package/drizzle/0326_interaction_operation_error_codes.sql +62 -0
- package/drizzle/0327_slack_first_task_hint.sql +29 -0
- package/drizzle/0328_session_background_commands.sql +590 -0
- package/drizzle/0329_slack_orchestration_delivery_events.sql +91 -0
- package/drizzle/0330_api_key_descriptions.sql +20 -0
- package/drizzle/0331_managed_organization_creation.sql +163 -0
- package/drizzle/0332_organization_shared_workspace_control_plane.sql +539 -0
- package/drizzle/0333_session_turn_prompt_routing.sql +45 -0
- package/drizzle/0334_connected_machine_workspace_root.sql +99 -0
- package/drizzle/0335_slack_workspace_routing.sql +460 -0
- package/drizzle/0336_atomic_session_fork_visibility.sql +667 -0
- package/drizzle/0337_slack_routed_action_handles.sql +189 -0
- package/drizzle/0338_atomic_connected_machine_attachments.sql +410 -0
- package/drizzle/0339_document_authority_reclassification.sql +1153 -0
- package/drizzle/0340_tenancy_backfill_activation_evidence.sql +1347 -0
- package/drizzle/0341_slack_routing_probe_organization_fence.sql +109 -0
- package/drizzle/0342_slack_route_prompt_single_pending.sql +32 -0
- package/drizzle/0343_personal_document_force_rls_lock_repair.sql +146 -0
- package/drizzle/0344_private_session_visibility_transition_gate.sql +85 -0
- package/drizzle/0345_tenant_scoped_session_tenancy_fence.sql +2839 -0
- package/drizzle/0346_document_migration_audit_surface.sql +454 -0
- package/drizzle/0347_connection_authority_convergence_evidence.sql +396 -0
- package/package.json +10 -6
- package/src/attached-browser-devices.ts +233 -5
- package/src/automations.ts +911 -0
- package/src/browser-sessions.ts +10 -0
- package/src/capability-integrations.ts +175 -1
- package/src/child-lifecycle-notices.ts +241 -0
- package/src/codemode-operations.ts +1 -35
- package/src/company-brain-context-selection-schema.ts +100 -0
- package/src/company-brain-context-selection.ts +359 -0
- package/src/company-brain-governed-writes.ts +1170 -0
- package/src/company-brain.ts +309 -0
- package/src/company-profile-agent-admin.ts +225 -0
- package/src/company-profile-schema.ts +121 -1
- package/src/company-profile.ts +21 -0
- package/src/computer-sessions.ts +10 -1
- package/src/connection-authority.ts +290 -0
- package/src/connection-scopes.ts +20 -0
- package/src/connection-tenancy-backfill.ts +167 -0
- package/src/connection-token-resolver.ts +263 -31
- package/src/database.ts +87 -2
- package/src/editable-artifacts-schema.ts +10 -5
- package/src/editable-artifacts.ts +21 -11
- package/src/governed-learning-activation-schema.ts +121 -0
- package/src/governed-learning-activation.ts +588 -0
- package/src/governed-learning-evaluator-schema.ts +72 -0
- package/src/governed-learning-evaluator.ts +217 -0
- package/src/index.ts +11676 -1550
- package/src/insights.ts +107 -0
- package/src/integration-bindings.ts +88 -6
- package/src/integration-facets.ts +287 -84
- package/src/interaction-placement-loss.ts +234 -0
- package/src/managed-human-provisioning.ts +116 -0
- package/src/memory-domain.ts +27 -32
- package/src/migrate.ts +77 -1
- package/src/new-session-drafts.ts +229 -35
- package/src/organization-membership-backfill.ts +735 -0
- package/src/organization-membership-lifecycle.ts +995 -0
- package/src/pr-review.ts +890 -0
- package/src/preference-registry.ts +31 -1
- package/src/provision-roles.ts +905 -6
- package/src/runtime-posture-cli.ts +2 -0
- package/src/runtime-posture.ts +1317 -72
- package/src/schema.ts +3316 -428
- package/src/scoped-knowledge-schema.ts +16 -8
- package/src/scoped-knowledge.ts +1 -1
- package/src/session-background-commands.ts +759 -0
- package/src/session-control.ts +640 -74
- package/src/session-goal-pacing.ts +126 -0
- package/src/session-queue-commands.ts +441 -85
- package/src/session-realtime-context.ts +4 -6
- package/src/session-realtime-ledger.ts +28 -14
- package/src/session-realtime-mirror.ts +1 -1
- package/src/session-tenancy.ts +410 -49
- package/src/session-tool-call-settlement.ts +38 -29
- package/src/slack-routing-personal-workspace.ts +67 -0
- package/src/slack-routing.ts +867 -0
- package/src/slack-task-policy-schema.ts +5 -0
- package/src/slack-task-policy.ts +18 -0
- package/src/slack-user-link-access.ts +138 -11
- package/src/task-notes-schema.ts +74 -0
- package/src/task-notes.ts +124 -2
- package/src/turn-initiator.ts +8 -0
- package/src/user-resource-authority.ts +377 -0
- package/src/workspace-authority.ts +160 -0
- package/src/workspace-instruction-policies-schema.ts +53 -1
- package/src/workspace-instruction-policies.ts +528 -77
- package/src/workspace-learning-policy.ts +21 -5
- package/src/workspace-membership-permissions.ts +9 -0
- package/dist/chunk-4SR4HKKA.js.map +0 -1
- package/dist/chunk-6ZYKCRFO.js.map +0 -1
- package/dist/chunk-NXAFLCQX.js +0 -2468
- package/dist/chunk-NXAFLCQX.js.map +0 -1
- package/dist/chunk-SK7YYHBI.js.map +0 -1
- package/dist/chunk-WD5ROSLL.js +0 -117
- package/dist/chunk-WD5ROSLL.js.map +0 -1
- package/dist/chunk-ZWREYEWA.js.map +0 -1
- /package/dist/{chunk-CUPM3FGB.js.map → chunk-2PRS4J5Q.js.map} +0 -0
- /package/dist/{chunk-LTG3S6ZY.js.map → chunk-E6CLMKEE.js.map} +0 -0
|
@@ -0,0 +1,4508 @@
|
|
|
1
|
+
// src/provision-roles.ts
|
|
2
|
+
import postgres from "postgres";
|
|
3
|
+
|
|
4
|
+
// src/runtime-posture.ts
|
|
5
|
+
import { sql } from "drizzle-orm";
|
|
6
|
+
|
|
7
|
+
// src/role-relationships.ts
|
|
8
|
+
function roleRelationshipsCatalogQuery(targetRole) {
|
|
9
|
+
return `
|
|
10
|
+
with recursive target_role(oid, rolname) as (
|
|
11
|
+
select oid, rolname
|
|
12
|
+
from pg_roles
|
|
13
|
+
where rolname = ${targetRole}
|
|
14
|
+
), inherited_roles(oid, rolname) as (
|
|
15
|
+
select parent.oid, parent.rolname
|
|
16
|
+
from pg_auth_members membership
|
|
17
|
+
join target_role target on target.oid = membership.member
|
|
18
|
+
join pg_roles parent on parent.oid = membership.roleid
|
|
19
|
+
union
|
|
20
|
+
select parent.oid, parent.rolname
|
|
21
|
+
from inherited_roles inherited
|
|
22
|
+
join pg_auth_members membership on membership.member = inherited.oid
|
|
23
|
+
join pg_roles parent on parent.oid = membership.roleid
|
|
24
|
+
), relationships as (
|
|
25
|
+
select
|
|
26
|
+
('inherits:' || inherited.rolname)::text as relationship,
|
|
27
|
+
'inherits'::text as direction,
|
|
28
|
+
null::boolean as admin_option,
|
|
29
|
+
null::boolean as inherit_option,
|
|
30
|
+
null::boolean as set_option,
|
|
31
|
+
null::boolean as member_is_superuser,
|
|
32
|
+
null::boolean as member_can_create_role,
|
|
33
|
+
null::text as grantor_role,
|
|
34
|
+
null::boolean as grantor_is_superuser
|
|
35
|
+
from inherited_roles inherited
|
|
36
|
+
union all
|
|
37
|
+
select
|
|
38
|
+
('member:' || member.rolname)::text as relationship,
|
|
39
|
+
'member'::text as direction,
|
|
40
|
+
membership.admin_option,
|
|
41
|
+
case
|
|
42
|
+
when current_setting('server_version_num')::integer >= 160000
|
|
43
|
+
then (to_jsonb(membership) ->> 'inherit_option')::boolean
|
|
44
|
+
else null::boolean
|
|
45
|
+
end as inherit_option,
|
|
46
|
+
case
|
|
47
|
+
when current_setting('server_version_num')::integer >= 160000
|
|
48
|
+
then (to_jsonb(membership) ->> 'set_option')::boolean
|
|
49
|
+
else null::boolean
|
|
50
|
+
end as set_option,
|
|
51
|
+
member.rolsuper as member_is_superuser,
|
|
52
|
+
member.rolcreaterole as member_can_create_role,
|
|
53
|
+
grantor.rolname::text as grantor_role,
|
|
54
|
+
grantor.rolsuper as grantor_is_superuser
|
|
55
|
+
from pg_auth_members membership
|
|
56
|
+
join target_role target on target.oid = membership.roleid
|
|
57
|
+
join pg_roles member on member.oid = membership.member
|
|
58
|
+
left join pg_roles grantor on grantor.oid = membership.grantor
|
|
59
|
+
)
|
|
60
|
+
select
|
|
61
|
+
relationship,
|
|
62
|
+
direction,
|
|
63
|
+
current_setting('server_version_num')::integer as server_version_num,
|
|
64
|
+
admin_option,
|
|
65
|
+
inherit_option,
|
|
66
|
+
set_option,
|
|
67
|
+
member_is_superuser,
|
|
68
|
+
member_can_create_role,
|
|
69
|
+
grantor_role,
|
|
70
|
+
grantor_is_superuser
|
|
71
|
+
from relationships
|
|
72
|
+
order by relationship, direction, grantor_role nulls first
|
|
73
|
+
`;
|
|
74
|
+
}
|
|
75
|
+
function isManagementOnlyRoleRelationship(row) {
|
|
76
|
+
return row.direction === "member" && row.server_version_num >= 16e4 && row.admin_option === true && row.inherit_option === false && row.set_option === false && row.member_is_superuser === false && row.member_can_create_role === true && row.grantor_is_superuser === true;
|
|
77
|
+
}
|
|
78
|
+
function sortedUnique(values) {
|
|
79
|
+
return [...new Set(values)].sort((a, b) => a.localeCompare(b));
|
|
80
|
+
}
|
|
81
|
+
function classifyRoleRelationships(rows) {
|
|
82
|
+
const managementOnlyRows = rows.filter(isManagementOnlyRoleRelationship);
|
|
83
|
+
const unsafeRows = rows.filter((row) => !isManagementOnlyRoleRelationship(row));
|
|
84
|
+
return {
|
|
85
|
+
relationships: sortedUnique(rows.map((row) => row.relationship)),
|
|
86
|
+
managementOnlyRelationships: sortedUnique(managementOnlyRows.map((row) => row.relationship)),
|
|
87
|
+
unsafeRelationships: sortedUnique(unsafeRows.map((row) => row.relationship))
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// src/runtime-posture.ts
|
|
92
|
+
var ARTIFACT_OUTBOX_CAPABILITY_ROUTINES = [
|
|
93
|
+
"claim_editable_artifact_live_outbox(text, integer, integer, name)",
|
|
94
|
+
"mark_editable_artifact_live_outbox_published(text, text, integer, name)",
|
|
95
|
+
"renew_editable_artifact_live_outbox(text, text, integer, integer, name)",
|
|
96
|
+
"retry_editable_artifact_live_outbox(text, text, integer, integer, text, name)",
|
|
97
|
+
"dead_letter_editable_artifact_live_outbox(text, text, integer, text, name)",
|
|
98
|
+
"release_editable_artifact_live_outbox(text, text, integer, name)"
|
|
99
|
+
];
|
|
100
|
+
var ARTIFACT_MATERIALIZER_CAPABILITY_ROUTINES = [
|
|
101
|
+
"claim_editable_artifact_materializations(text, integer, integer, name)",
|
|
102
|
+
"renew_editable_artifact_materialization(uuid, uuid, text, text, text, integer, integer, name)",
|
|
103
|
+
"succeed_editable_artifact_materialization(uuid, uuid, text, text, text, integer, text, text, text, bigint, text, text, timestamp with time zone, name)",
|
|
104
|
+
"fail_editable_artifact_materialization(uuid, uuid, text, text, text, integer, text, name)"
|
|
105
|
+
];
|
|
106
|
+
var ARTIFACT_LIVE_TICKET_CAPABILITY_ROUTINES = [
|
|
107
|
+
"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)",
|
|
108
|
+
"consume_editable_artifact_live_ticket(text, name)",
|
|
109
|
+
"cleanup_expired_editable_artifact_live_tickets(integer, name)"
|
|
110
|
+
];
|
|
111
|
+
var ARTIFACT_LIVE_TICKET_INTERNAL_ROUTINES = [
|
|
112
|
+
"resolve_editable_artifact_ticket_data_schema(name)"
|
|
113
|
+
];
|
|
114
|
+
var ARTIFACT_AUTHORIZATION_CAPABILITY_ROUTINES = [
|
|
115
|
+
"authorize_editable_artifact_actor(uuid, uuid, text, text, text, text, text, text, integer, text, text, name)"
|
|
116
|
+
];
|
|
117
|
+
var DEDICATED_ARTIFACT_CAPABILITY_ROUTINES = /* @__PURE__ */ new Set([
|
|
118
|
+
...ARTIFACT_OUTBOX_CAPABILITY_ROUTINES,
|
|
119
|
+
...ARTIFACT_MATERIALIZER_CAPABILITY_ROUTINES,
|
|
120
|
+
...ARTIFACT_LIVE_TICKET_INTERNAL_ROUTINES
|
|
121
|
+
]);
|
|
122
|
+
var KNOWLEDGE_SOURCE_SYNC_LOCK_AUTHORITY_ROUTINE = "knowledge_source_sync_lock_authority(uuid, uuid, uuid)";
|
|
123
|
+
var GOOGLE_DRIVE_FILE_AUTHORIZATION_ROUTINE = "google_drive_file_authorized(uuid, uuid, text, uuid)";
|
|
124
|
+
var GOOGLE_DRIVE_DOCUMENT_CITATION_ROUTINE = "google_drive_document_citation(uuid, uuid, text, uuid, uuid)";
|
|
125
|
+
var GOOGLE_DRIVE_AUTHORITY_TABLES = [
|
|
126
|
+
"connections",
|
|
127
|
+
"files",
|
|
128
|
+
"google_drive_object_acl_evidence",
|
|
129
|
+
"google_drive_object_acl_principals",
|
|
130
|
+
"knowledge_document_versions",
|
|
131
|
+
"knowledge_providers",
|
|
132
|
+
"knowledge_source_objects",
|
|
133
|
+
"knowledge_source_sync_index_obligations",
|
|
134
|
+
"knowledge_source_sync_states",
|
|
135
|
+
"knowledge_sources"
|
|
136
|
+
];
|
|
137
|
+
var KNOWLEDGE_SOURCE_SYNC_LOCK_AUTHORITY_TABLES = [
|
|
138
|
+
"knowledge_sources",
|
|
139
|
+
"knowledge_source_objects"
|
|
140
|
+
];
|
|
141
|
+
var MANAGED_HUMAN_PERSONAL_WORKSPACE_ROUTINE = "ensure_managed_human_personal_workspace(uuid, text, uuid)";
|
|
142
|
+
var ORGANIZATION_MEMBERSHIP_LIFECYCLE_ROUTINES = [
|
|
143
|
+
"list_self_organization_memberships(text)",
|
|
144
|
+
"list_self_organization_invitations(text)",
|
|
145
|
+
"list_self_organization_invitations(text, uuid, integer)",
|
|
146
|
+
"get_self_organization_invitation(text, uuid)",
|
|
147
|
+
"list_organization_invitations(uuid, text, uuid, integer)",
|
|
148
|
+
"list_organization_members(uuid, text)",
|
|
149
|
+
"get_organization_administration_overview(uuid, text)",
|
|
150
|
+
"create_managed_organization(text, text, text, uuid)",
|
|
151
|
+
"assert_organization_shared_workspace_administrator(uuid, uuid, text)",
|
|
152
|
+
"open_organization_shared_workspace_administration_capability(uuid, uuid, text)",
|
|
153
|
+
"close_organization_shared_workspace_administration_capability(uuid)",
|
|
154
|
+
"create_organization_shared_workspace(uuid, text, text, text, text, uuid)",
|
|
155
|
+
"upsert_organization_shared_workspace_member(uuid, uuid, text, uuid, text, text, jsonb, boolean)",
|
|
156
|
+
"update_organization_name(uuid, text, text, timestamp with time zone, uuid)",
|
|
157
|
+
"create_organization_invitation_v2(jsonb)",
|
|
158
|
+
"bind_pending_organization_invitations_for_verified_email(text, text)",
|
|
159
|
+
"has_pending_organization_invitation_for_subject(text)",
|
|
160
|
+
"accept_organization_invitation_v2(jsonb)",
|
|
161
|
+
"organization_membership_command(jsonb)",
|
|
162
|
+
"prepare_organization_membership_protocol_settlements(jsonb)",
|
|
163
|
+
"assert_active_managed_human_organization_membership(uuid, text)",
|
|
164
|
+
"resolve_workspace_writer_grant_identity(uuid, text)",
|
|
165
|
+
"prepare_workspace_membership_removal_settlements(jsonb)",
|
|
166
|
+
"workspace_membership_removal_command(jsonb)",
|
|
167
|
+
"get_organization_retention_policy(uuid, text)",
|
|
168
|
+
"preview_organization_retention_deletions(uuid, integer)",
|
|
169
|
+
"claim_organization_retention_deletion(uuid, uuid, uuid[])",
|
|
170
|
+
"list_organization_retention_deletion_objects(uuid, uuid, uuid, text, integer)",
|
|
171
|
+
"record_organization_retention_object_deleted(uuid, uuid, uuid, text, text, text, text)",
|
|
172
|
+
"fail_organization_retention_deletion(uuid, uuid, uuid, text)",
|
|
173
|
+
"finalize_organization_retention_deletion(uuid, uuid, uuid, text)",
|
|
174
|
+
"complete_organization_retention_deletion(uuid, uuid, uuid, text)"
|
|
175
|
+
];
|
|
176
|
+
var ORGANIZATION_MEMBERSHIP_LIFECYCLE_AUTHORITY_TABLES = [
|
|
177
|
+
"organization_invitation_binding_events",
|
|
178
|
+
"organization_membership_invitations",
|
|
179
|
+
"organization_membership_lifecycle_events",
|
|
180
|
+
"organization_membership_operation_receipts",
|
|
181
|
+
"organization_memberships",
|
|
182
|
+
"organization_profile_events",
|
|
183
|
+
"organization_shared_workspace_administration_capabilities",
|
|
184
|
+
"organization_user_resource_authorities",
|
|
185
|
+
"organization_user_resource_grants",
|
|
186
|
+
"organization_user_retention_deletion_events",
|
|
187
|
+
"organization_user_retention_deletions",
|
|
188
|
+
"organization_user_retention_object_deletion_receipts",
|
|
189
|
+
"organization_user_retention_object_obligations",
|
|
190
|
+
"organization_user_retention_policies"
|
|
191
|
+
];
|
|
192
|
+
var PRIVATE_SESSION_CREATE_POLICY_ROUTINE = "get_private_session_create_policy(uuid, uuid, text)";
|
|
193
|
+
var ORGANIZATION_PRIVATE_SESSION_SETTINGS_READ_ROUTINE = "get_organization_private_session_settings(uuid, text)";
|
|
194
|
+
var ORGANIZATION_PRIVATE_SESSION_SETTINGS_UPDATE_ROUTINE = "update_organization_private_session_settings(uuid, text, boolean, bigint, uuid)";
|
|
195
|
+
var ORGANIZATION_PRIVATE_SESSION_ROUTINE_AUTHORITY_TABLES = {
|
|
196
|
+
[PRIVATE_SESSION_CREATE_POLICY_ROUTINE]: [
|
|
197
|
+
"organization_memberships",
|
|
198
|
+
"organization_private_session_settings",
|
|
199
|
+
"session_tenancy_activations",
|
|
200
|
+
"workspace_memberships",
|
|
201
|
+
"workspaces"
|
|
202
|
+
],
|
|
203
|
+
[ORGANIZATION_PRIVATE_SESSION_SETTINGS_READ_ROUTINE]: [
|
|
204
|
+
"managed_accounts",
|
|
205
|
+
"organization_memberships",
|
|
206
|
+
"organization_private_session_settings",
|
|
207
|
+
"session_tenancy_activations"
|
|
208
|
+
],
|
|
209
|
+
[ORGANIZATION_PRIVATE_SESSION_SETTINGS_UPDATE_ROUTINE]: [
|
|
210
|
+
"managed_accounts",
|
|
211
|
+
"organization_memberships",
|
|
212
|
+
"organization_private_session_setting_events",
|
|
213
|
+
"organization_private_session_settings",
|
|
214
|
+
"session_tenancy_activations"
|
|
215
|
+
]
|
|
216
|
+
};
|
|
217
|
+
var ORGANIZATION_PRIVATE_SESSION_ROUTINES = Object.keys(
|
|
218
|
+
ORGANIZATION_PRIVATE_SESSION_ROUTINE_AUTHORITY_TABLES
|
|
219
|
+
);
|
|
220
|
+
var ORGANIZATION_PRIVATE_SESSIONS_ENABLED_ROUTINE = "organization_private_sessions_enabled(uuid)";
|
|
221
|
+
var PREFERENCE_KNOWLEDGE_PROPOSAL_ROUTINE = "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)";
|
|
222
|
+
var PREFERENCE_KNOWLEDGE_PROPOSAL_AUTHORITY_TABLES = [
|
|
223
|
+
"company_brain_preference_proposal_receipts",
|
|
224
|
+
"knowledge_change_proposals",
|
|
225
|
+
"knowledge_claim_evidence",
|
|
226
|
+
"knowledge_claim_reviews",
|
|
227
|
+
"knowledge_claims",
|
|
228
|
+
"preference_registry_events",
|
|
229
|
+
"preference_registry_preferences",
|
|
230
|
+
"preference_registry_revisions",
|
|
231
|
+
"session_attempt_interruptions",
|
|
232
|
+
"session_turn_attempts",
|
|
233
|
+
"session_turns",
|
|
234
|
+
"sessions",
|
|
235
|
+
"workspaces"
|
|
236
|
+
];
|
|
237
|
+
var MANAGED_HUMAN_PERSONAL_WORKSPACE_AUTHORITY_TABLES = [
|
|
238
|
+
"organization_memberships",
|
|
239
|
+
"organization_user_retention_policies",
|
|
240
|
+
"organization_user_resource_authorities",
|
|
241
|
+
"organization_user_resource_grants"
|
|
242
|
+
];
|
|
243
|
+
var PERSONAL_RESOURCE_ATTEMPT_RESOLVER_ROUTINE = "resolve_session_attempt_personal_resources(uuid, uuid, uuid)";
|
|
244
|
+
var USER_RESOURCE_LIFECYCLE_ROUTINES = [
|
|
245
|
+
"accept_turn_personal_resource_attachment(uuid, uuid, uuid, uuid, text, integer, boolean, integer)",
|
|
246
|
+
"list_self_user_resource_authorities(uuid, uuid, text, uuid, integer)",
|
|
247
|
+
"issue_self_user_resource_grant(uuid, uuid, uuid, text, text, text, uuid, integer, boolean)",
|
|
248
|
+
"revoke_self_user_resource_grant(uuid, uuid, uuid)",
|
|
249
|
+
"authorize_session_attempt_personal_resource_reads(uuid, uuid, uuid)"
|
|
250
|
+
];
|
|
251
|
+
var CONNECTION_CONVERGENCE_AUDIT_CAPABILITY_ROUTINE = "connection_authority_convergence_audit_capability_active(uuid)";
|
|
252
|
+
var CONNECTION_AUTHORITY_ROUTINES = [
|
|
253
|
+
CONNECTION_CONVERGENCE_AUDIT_CAPABILITY_ROUTINE,
|
|
254
|
+
"resolve_personal_connection_authority_selection(uuid, uuid, text, uuid, jsonb)",
|
|
255
|
+
"resolve_accepted_connection_use(uuid, uuid, uuid, uuid, uuid, integer, uuid, text, text, uuid, text, text, text, text)",
|
|
256
|
+
"resolve_connection_use_authority(uuid, uuid, uuid, jsonb)",
|
|
257
|
+
"inspect_organization_connection_authority_convergence(uuid, integer, uuid)"
|
|
258
|
+
];
|
|
259
|
+
var PERSONAL_GITHUB_REPOSITORY_AUTHORITY_ROUTINES = [
|
|
260
|
+
"get_self_personal_github_repository_selection(uuid, uuid, text, uuid)",
|
|
261
|
+
"mutate_self_personal_github_repository_selection(uuid, uuid, text, uuid, bigint, bigint, text, jsonb, boolean)"
|
|
262
|
+
];
|
|
263
|
+
var PERSONAL_GITHUB_REPOSITORY_AUTHORITY_TABLES = [
|
|
264
|
+
"personal_github_repository_selection_heads",
|
|
265
|
+
"personal_github_repository_selection_operations",
|
|
266
|
+
"personal_github_repository_selections"
|
|
267
|
+
];
|
|
268
|
+
var SCHEDULED_PERSONAL_RESOURCE_ROUTINES = [
|
|
269
|
+
"freeze_scheduled_task_personal_resources(uuid, uuid, uuid, bigint)",
|
|
270
|
+
"clone_scheduled_task_personal_resource_authority(uuid, uuid, uuid, bigint, bigint)",
|
|
271
|
+
"refresh_scheduled_task_personal_resources_clone_connections(uuid, uuid, uuid, bigint, bigint)",
|
|
272
|
+
"create_scheduled_agent_run_with_admission(uuid, uuid, uuid, uuid, bigint, text, text, text, timestamp with time zone, timestamp with time zone, jsonb)",
|
|
273
|
+
"materialize_scheduled_task_reusable_session_from_run(uuid, uuid, uuid, uuid, uuid, bigint, text)",
|
|
274
|
+
"scheduled_task_run_personal_resource_authority(uuid, uuid, uuid)",
|
|
275
|
+
"scheduled_task_run_connection_authority_subject(uuid, uuid, uuid)",
|
|
276
|
+
"scheduled_task_personal_resource_authority_subject(uuid, uuid, uuid, bigint)",
|
|
277
|
+
"record_scheduled_task_revision_authority(uuid, uuid, uuid, bigint)",
|
|
278
|
+
"clone_scheduled_task_revision_authority(uuid, uuid, uuid, bigint, bigint)",
|
|
279
|
+
"scheduled_task_revision_authority_subject(uuid, uuid, uuid, bigint)",
|
|
280
|
+
"scheduled_task_revision_authority_snapshot(uuid, uuid, uuid, bigint)",
|
|
281
|
+
"validate_scheduled_agent_run_live_authority(uuid, uuid, uuid)",
|
|
282
|
+
"scheduled_scoped_rig_version_metadata(uuid, uuid, text, uuid, uuid)",
|
|
283
|
+
"scheduled_variable_set_expected_generation_for_attempt(uuid, uuid, uuid, uuid, uuid, integer, uuid)",
|
|
284
|
+
"bind_scheduled_task_run_session(uuid, uuid, uuid, uuid)",
|
|
285
|
+
"transition_scheduled_agent_run(uuid, uuid, uuid, uuid, uuid, text, text)"
|
|
286
|
+
];
|
|
287
|
+
var PERSONAL_RESOURCE_CAPABILITY_PREDICATE_ROUTINE = "personal_resource_delegation_capability_active(text)";
|
|
288
|
+
var PERSONAL_RESOURCE_CAPABILITY_TABLE = "personal_resource_delegation_capabilities";
|
|
289
|
+
var SCHEDULED_PERSONAL_RESOURCE_CAPABILITY_PREDICATE_ROUTINE = "scheduled_personal_resource_capability_active(text)";
|
|
290
|
+
var SCHEDULED_PERSONAL_RESOURCE_CAPABILITY_TABLE = "scheduled_personal_resource_capabilities";
|
|
291
|
+
var VARIABLE_SET_CAPABILITY_PREDICATE_ROUTINE = "variable_set_authority_capability_active(text)";
|
|
292
|
+
var VARIABLE_SET_CAPABILITY_TABLE = "variable_set_authority_capabilities";
|
|
293
|
+
var PERSONAL_DOCUMENT_CAPABILITY_PREDICATE_ROUTINE = "personal_document_authority_capability_active(text)";
|
|
294
|
+
var PERSONAL_DOCUMENT_CAPABILITY_TABLE = "personal_document_authority_capabilities";
|
|
295
|
+
var PERSONAL_DOCUMENT_AUTHORITY_ROUTINES = [
|
|
296
|
+
"create_personal_document_authority(uuid, uuid, uuid)",
|
|
297
|
+
"resolve_document_original_file(uuid, uuid, text, uuid)",
|
|
298
|
+
"resolve_session_attempt_personal_document_reads(uuid, uuid, uuid, uuid)"
|
|
299
|
+
];
|
|
300
|
+
var DOCUMENT_MIGRATION_CAPABILITY_PREDICATE_ROUTINE = "document_migration_capability_active(text)";
|
|
301
|
+
var DOCUMENT_MIGRATION_CAPABILITY_TABLE = "document_migration_capabilities";
|
|
302
|
+
var DOCUMENT_MIGRATION_AUTHORITY_ROUTINES = [
|
|
303
|
+
"list_document_authority_reclassifications(uuid, uuid, text, uuid, integer, timestamp with time zone, uuid)",
|
|
304
|
+
"reclassify_document_authority(jsonb)",
|
|
305
|
+
"run_document_default_collection_backfill(jsonb)",
|
|
306
|
+
"list_document_default_collection_backfill_runs(jsonb)",
|
|
307
|
+
"get_document_default_collection_backfill_audit(jsonb)",
|
|
308
|
+
"list_organization_document_authority_reclassifications(jsonb)"
|
|
309
|
+
];
|
|
310
|
+
var DOCUMENT_MIGRATION_AUDIT_INTERNAL_ROUTINES = [
|
|
311
|
+
"document_migration_audit_capability_active(text)",
|
|
312
|
+
"assert_document_migration_audit_authority(jsonb)"
|
|
313
|
+
];
|
|
314
|
+
var VARIABLE_SET_AUTHORITY_ROUTINES = [
|
|
315
|
+
"create_scoped_variable_set(uuid, uuid, text, text, text, jsonb, boolean)",
|
|
316
|
+
"list_scoped_variable_sets(uuid, uuid, uuid, text, text)",
|
|
317
|
+
"count_scoped_variable_sets(uuid, uuid, text)",
|
|
318
|
+
"mutate_scoped_variable_set(uuid, uuid, uuid, text, text, boolean, text, boolean, text, text, boolean)",
|
|
319
|
+
"read_scoped_variable_set_secret(uuid, uuid, uuid, text, text, text, uuid, uuid, uuid, integer)",
|
|
320
|
+
"materialize_scoped_variable_set_for_attempt(uuid, uuid, uuid, uuid, uuid, integer, uuid)",
|
|
321
|
+
"materialize_scoped_variable_set_for_session(uuid, uuid, uuid, uuid)"
|
|
322
|
+
];
|
|
323
|
+
var SCOPED_COMPUTE_CAPABILITY_PREDICATE_ROUTINE = "scoped_compute_capability_active(text)";
|
|
324
|
+
var SCOPED_COMPUTE_CAPABILITY_TABLE = "scoped_compute_capabilities";
|
|
325
|
+
var CONNECTION_TENANCY_BACKFILL_CAPABILITY_TABLE = "connection_tenancy_backfill_capabilities";
|
|
326
|
+
var CONNECTION_TENANCY_BACKFILL_CAPABILITY_PREDICATE_ROUTINE = "connection_tenancy_backfill_capability_active(uuid)";
|
|
327
|
+
var SCOPED_COMPUTE_AUTHORITY_ROUTINES = [
|
|
328
|
+
"create_scoped_rig(uuid, uuid, text, text, text, text, jsonb, boolean)",
|
|
329
|
+
"list_scoped_rigs(uuid, uuid, uuid, text, text)",
|
|
330
|
+
"count_scoped_rigs(uuid, uuid, text)",
|
|
331
|
+
"mutate_scoped_rig(uuid, uuid, uuid, text, text, boolean, text, boolean, boolean)",
|
|
332
|
+
"finalize_scoped_enrollment(uuid, uuid, text, text, boolean, boolean, text, text, text, boolean)",
|
|
333
|
+
"list_scoped_enrollments(uuid, uuid, uuid, text)",
|
|
334
|
+
"get_scoped_sandbox(uuid, uuid, uuid)",
|
|
335
|
+
"authorize_scoped_sandbox_attach(uuid, uuid, uuid)",
|
|
336
|
+
"materialize_scoped_rig_version_for_attempt(uuid, uuid, uuid, uuid, uuid, integer)",
|
|
337
|
+
"authorize_session_attempt_personal_machine(uuid, uuid, uuid, uuid, uuid, integer, uuid)",
|
|
338
|
+
"assert_session_attempt_personal_machine(uuid, uuid, uuid, uuid, uuid, integer, uuid, boolean)",
|
|
339
|
+
"list_scoped_machine_dependent_sessions(uuid, uuid, uuid)",
|
|
340
|
+
"detach_scoped_machine_dependent_sessions(uuid, uuid, uuid)"
|
|
341
|
+
];
|
|
342
|
+
var CANONICAL_HUMAN_IDENTITY_ROUTINES = [
|
|
343
|
+
"ensure_canonical_human_identity(text, text)",
|
|
344
|
+
"validate_canonical_human_session(text, text, boolean)",
|
|
345
|
+
"get_canonical_human_identity_projection(text)",
|
|
346
|
+
"apply_canonical_human_identity_operation(uuid, text, bigint, text, uuid, text, text, text)"
|
|
347
|
+
];
|
|
348
|
+
var CANONICAL_HUMAN_IDENTITY_AUTHORITY_TABLES = [
|
|
349
|
+
"canonical_human_identities",
|
|
350
|
+
"canonical_human_identity_subjects",
|
|
351
|
+
"canonical_human_login_bindings",
|
|
352
|
+
"canonical_human_identity_operations"
|
|
353
|
+
];
|
|
354
|
+
var SESSION_PRIVATE_ACTOR_VISIBLE_ROUTINE = "session_private_actor_visible(uuid, uuid, uuid, text)";
|
|
355
|
+
var SESSION_REFERENCE_VISIBLE_ROUTINE = "session_reference_visible(uuid, uuid, uuid)";
|
|
356
|
+
var TASK_NOTE_CAPABILITY_ROUTINES = [
|
|
357
|
+
"create_task_note_for_attempt(uuid, uuid, uuid, uuid, uuid, integer, uuid, text, text, integer)",
|
|
358
|
+
"archive_task_note_for_attempt(uuid, uuid, uuid, uuid, uuid, integer, uuid, uuid, integer, text)",
|
|
359
|
+
"list_task_notes_for_attempt(uuid, uuid, uuid, uuid, uuid, integer, boolean, integer)",
|
|
360
|
+
"replace_task_note_for_attempt(uuid, uuid, uuid, uuid, uuid, integer, uuid, uuid, uuid, uuid, integer, text, text, integer, text)",
|
|
361
|
+
"resolve_task_note_knowledge_promotion_source(uuid, uuid, uuid, uuid, uuid, integer, uuid, integer, text, text, text)"
|
|
362
|
+
];
|
|
363
|
+
var COMPANY_BRAIN_CONTEXT_SELECTION_ROUTINE = "company_brain_context_get_or_create_selection(uuid, uuid, uuid, uuid, uuid, integer)";
|
|
364
|
+
var COMPANY_BRAIN_CONTEXT_INSPECTION_ROUTINE = "company_brain_inspect_context_receipts(uuid, uuid, text, uuid, timestamp with time zone, uuid, integer)";
|
|
365
|
+
var GOVERNED_LEARNING_EVALUATION_ROUTINE = "evaluate_governed_learning_proposal(uuid, uuid, uuid, uuid, uuid, integer, uuid, uuid, uuid, uuid, uuid)";
|
|
366
|
+
var GOVERNED_LEARNING_ACTIVATION_ROUTINES = [
|
|
367
|
+
"activate_governed_learning_decision(uuid, uuid, uuid, uuid)",
|
|
368
|
+
"activate_human_confirmed_learning_decision(uuid, uuid, uuid, uuid, uuid)",
|
|
369
|
+
"confirm_remember_knowledge_claim(uuid, uuid, uuid, uuid, integer, uuid, uuid, uuid)",
|
|
370
|
+
"undo_governed_learning_activation(uuid, uuid, uuid, uuid)"
|
|
371
|
+
];
|
|
372
|
+
var GOVERNED_LEARNING_INSPECTION_ROUTINES = [
|
|
373
|
+
"inspect_governed_learning_decisions(uuid, uuid, text, integer)",
|
|
374
|
+
"inspect_governed_learning_activations(uuid, uuid, text, integer)",
|
|
375
|
+
"inspect_governed_learning_activation_undos(uuid, uuid, text, integer)"
|
|
376
|
+
];
|
|
377
|
+
var GOVERNED_LEARNING_INSPECTION_AUTHORITY_TABLES = [
|
|
378
|
+
"governed_learning_decision_receipts",
|
|
379
|
+
"governed_learning_activation_receipts",
|
|
380
|
+
"governed_learning_activation_undo_receipts",
|
|
381
|
+
"sessions"
|
|
382
|
+
];
|
|
383
|
+
var COMPANY_PROFILE_AGENT_ADMIN_ROUTINES = [
|
|
384
|
+
"propose_company_profile_for_attempt(uuid, uuid, uuid, uuid, uuid, integer, uuid, text, text, text)",
|
|
385
|
+
"confirm_company_profile_for_attempt(uuid, uuid, uuid, uuid, uuid, integer, uuid, uuid, uuid)"
|
|
386
|
+
];
|
|
387
|
+
var COMPANY_PROFILE_AGENT_ADMIN_AUTHORITY_TABLES = [
|
|
388
|
+
"company_profile_activation_events",
|
|
389
|
+
"company_profile_agent_confirmation_receipts",
|
|
390
|
+
"company_profile_agent_proposal_receipts",
|
|
391
|
+
"company_profile_heads",
|
|
392
|
+
"company_profile_revisions",
|
|
393
|
+
"managed_accounts",
|
|
394
|
+
"organization_memberships",
|
|
395
|
+
"session_human_input_requests",
|
|
396
|
+
"session_turn_attempts",
|
|
397
|
+
"session_turns",
|
|
398
|
+
"sessions",
|
|
399
|
+
"workspaces"
|
|
400
|
+
];
|
|
401
|
+
var GOVERNED_LEARNING_EVALUATION_AUTHORITY_TABLES = [
|
|
402
|
+
"document_chunks",
|
|
403
|
+
"documents",
|
|
404
|
+
"governed_learning_decision_receipts",
|
|
405
|
+
"knowledge_change_proposals",
|
|
406
|
+
"knowledge_claim_evidence",
|
|
407
|
+
"knowledge_claim_relations",
|
|
408
|
+
"knowledge_claim_reviews",
|
|
409
|
+
"knowledge_claims",
|
|
410
|
+
"knowledge_document_versions",
|
|
411
|
+
"knowledge_providers",
|
|
412
|
+
"knowledge_source_acl_versions",
|
|
413
|
+
"knowledge_source_objects",
|
|
414
|
+
"knowledge_sources",
|
|
415
|
+
"session_attempt_interruptions",
|
|
416
|
+
"session_turn_attempts",
|
|
417
|
+
"session_turns",
|
|
418
|
+
"sessions",
|
|
419
|
+
"task_notes",
|
|
420
|
+
"workspace_learning_policy_snapshots",
|
|
421
|
+
"workspaces"
|
|
422
|
+
];
|
|
423
|
+
var GOVERNED_LEARNING_ACTIVATION_AUTHORITY_TABLES = [
|
|
424
|
+
...GOVERNED_LEARNING_EVALUATION_AUTHORITY_TABLES,
|
|
425
|
+
"company_brain_preference_proposal_receipts",
|
|
426
|
+
"governed_learning_activation_receipts",
|
|
427
|
+
"governed_learning_activation_undo_receipts",
|
|
428
|
+
"preference_registry_events",
|
|
429
|
+
"preference_registry_preferences",
|
|
430
|
+
"preference_registry_revisions",
|
|
431
|
+
"remember_knowledge_confirmation_receipts",
|
|
432
|
+
"session_human_input_requests",
|
|
433
|
+
"workspace_instruction_policy_activation_events",
|
|
434
|
+
"workspace_instruction_policy_deactivation_events",
|
|
435
|
+
"workspace_instruction_policy_heads",
|
|
436
|
+
"workspace_instruction_policy_onboarding_proposals",
|
|
437
|
+
"workspace_instruction_policy_revisions",
|
|
438
|
+
"workspace_learning_policy_heads",
|
|
439
|
+
"workspace_learning_policy_revisions"
|
|
440
|
+
];
|
|
441
|
+
var TRANSITION_SESSION_VISIBILITY_ROUTINE = "transition_session_visibility(uuid, uuid, uuid, text, text, integer, text, text, integer)";
|
|
442
|
+
var LEGACY_FORK_SESSION_CONTENT_ROUTINE = "fork_session_content(uuid, uuid, uuid, text, uuid, text, text, text, integer)";
|
|
443
|
+
var FORK_SESSION_CONTENT_ROUTINE = "fork_session_content(uuid, uuid, uuid, text, uuid, text, boolean, text, text, integer)";
|
|
444
|
+
var REPLAY_APPLIED_SESSION_FORK_ROUTINE = "replay_applied_session_fork(uuid, uuid, uuid, text, uuid, text, boolean, text, text, integer)";
|
|
445
|
+
var SESSION_TENANCY_ACTIVATED_ROUTINE = "session_tenancy_product_activated(uuid, integer)";
|
|
446
|
+
var SESSION_TENANCY_ANY_ACTIVATION_ROUTINE = "session_tenancy_any_product_activation()";
|
|
447
|
+
var SESSION_TENANCY_QUIESCENCE_ROUTINE = "assert_session_tenancy_quiescent(uuid, uuid, uuid, boolean)";
|
|
448
|
+
var TENANCY_BACKFILL_ACTIVATION_EVIDENCE_ROUTINE = "check_tenancy_backfill_activation_evidence(uuid)";
|
|
449
|
+
var SESSION_VISIBILITY_LIFECYCLE_CAPABILITY_ROUTINE = "session_visibility_lifecycle_capability_held()";
|
|
450
|
+
var PRIVATE_SESSION_CREATE_CAPABILITY_ROUTINES = [
|
|
451
|
+
"open_private_session_create_capability(uuid, uuid, uuid, text)",
|
|
452
|
+
"open_private_child_session_create_capability(uuid, uuid, uuid, uuid, uuid, uuid, integer)",
|
|
453
|
+
"close_private_session_create_capability(uuid)"
|
|
454
|
+
];
|
|
455
|
+
var SESSION_AUTHORITY_ROUTINES = /* @__PURE__ */ new Set([
|
|
456
|
+
LEGACY_FORK_SESSION_CONTENT_ROUTINE,
|
|
457
|
+
FORK_SESSION_CONTENT_ROUTINE,
|
|
458
|
+
REPLAY_APPLIED_SESSION_FORK_ROUTINE,
|
|
459
|
+
SESSION_TENANCY_ACTIVATED_ROUTINE,
|
|
460
|
+
SESSION_TENANCY_ANY_ACTIVATION_ROUTINE,
|
|
461
|
+
SESSION_TENANCY_QUIESCENCE_ROUTINE,
|
|
462
|
+
PERSONAL_RESOURCE_ATTEMPT_RESOLVER_ROUTINE,
|
|
463
|
+
...USER_RESOURCE_LIFECYCLE_ROUTINES,
|
|
464
|
+
...CONNECTION_AUTHORITY_ROUTINES,
|
|
465
|
+
...SCHEDULED_PERSONAL_RESOURCE_ROUTINES,
|
|
466
|
+
SESSION_PRIVATE_ACTOR_VISIBLE_ROUTINE,
|
|
467
|
+
SESSION_REFERENCE_VISIBLE_ROUTINE,
|
|
468
|
+
SESSION_VISIBILITY_LIFECYCLE_CAPABILITY_ROUTINE,
|
|
469
|
+
...PRIVATE_SESSION_CREATE_CAPABILITY_ROUTINES,
|
|
470
|
+
TRANSITION_SESSION_VISIBILITY_ROUTINE,
|
|
471
|
+
...TASK_NOTE_CAPABILITY_ROUTINES,
|
|
472
|
+
COMPANY_BRAIN_CONTEXT_SELECTION_ROUTINE,
|
|
473
|
+
COMPANY_BRAIN_CONTEXT_INSPECTION_ROUTINE
|
|
474
|
+
]);
|
|
475
|
+
var XAI_CREATE_CREDENTIAL_ROUTINE = "create_xai_subscription_credential(uuid, uuid, text, text, text, text, text, text, text, timestamp with time zone)";
|
|
476
|
+
var XAI_DISCONNECT_CREDENTIAL_ROUTINE = "disconnect_xai_subscription_credential(uuid, uuid, text, uuid, jsonb)";
|
|
477
|
+
var XAI_SNAPSHOT_VALIDATOR_ROUTINE = "xai_provider_account_authority_snapshot_v1_valid(jsonb)";
|
|
478
|
+
var XAI_AUTHORITY_LIVE_ROUTINE = "xai_subscription_authority_live(uuid, uuid, text, uuid, text, uuid, uuid, bigint)";
|
|
479
|
+
var XAI_POOL_VISIBLE_ROUTINE = "xai_subscription_pool_visible(uuid, uuid, text, text, uuid)";
|
|
480
|
+
var XAI_RESOLVE_POOL_ROUTINE = "resolve_xai_authority_pool(uuid, uuid, text, jsonb)";
|
|
481
|
+
var XAI_REVALIDATE_CREDENTIAL_ROUTINE = "revalidate_xai_subscription_authority(uuid, text, uuid, jsonb)";
|
|
482
|
+
var XAI_AUTHORITY_TABLES = [
|
|
483
|
+
"organization_memberships",
|
|
484
|
+
"organization_user_resource_authorities",
|
|
485
|
+
"workspace_memberships",
|
|
486
|
+
"xai_subscription_credentials"
|
|
487
|
+
];
|
|
488
|
+
var RUNTIME_TARGET_SCHEMA_CAPABILITY_ROUTINES = [
|
|
489
|
+
COMPANY_BRAIN_CONTEXT_INSPECTION_ROUTINE,
|
|
490
|
+
COMPANY_BRAIN_CONTEXT_SELECTION_ROUTINE,
|
|
491
|
+
...COMPANY_PROFILE_AGENT_ADMIN_ROUTINES,
|
|
492
|
+
GOVERNED_LEARNING_EVALUATION_ROUTINE,
|
|
493
|
+
...GOVERNED_LEARNING_ACTIVATION_ROUTINES,
|
|
494
|
+
...GOVERNED_LEARNING_INSPECTION_ROUTINES,
|
|
495
|
+
FORK_SESSION_CONTENT_ROUTINE,
|
|
496
|
+
LEGACY_FORK_SESSION_CONTENT_ROUTINE,
|
|
497
|
+
REPLAY_APPLIED_SESSION_FORK_ROUTINE,
|
|
498
|
+
SESSION_TENANCY_ACTIVATED_ROUTINE,
|
|
499
|
+
SESSION_TENANCY_ANY_ACTIVATION_ROUTINE,
|
|
500
|
+
XAI_AUTHORITY_LIVE_ROUTINE,
|
|
501
|
+
XAI_CREATE_CREDENTIAL_ROUTINE,
|
|
502
|
+
XAI_DISCONNECT_CREDENTIAL_ROUTINE,
|
|
503
|
+
GOOGLE_DRIVE_DOCUMENT_CITATION_ROUTINE,
|
|
504
|
+
GOOGLE_DRIVE_FILE_AUTHORIZATION_ROUTINE,
|
|
505
|
+
KNOWLEDGE_SOURCE_SYNC_LOCK_AUTHORITY_ROUTINE,
|
|
506
|
+
MANAGED_HUMAN_PERSONAL_WORKSPACE_ROUTINE,
|
|
507
|
+
...ORGANIZATION_MEMBERSHIP_LIFECYCLE_ROUTINES,
|
|
508
|
+
...ORGANIZATION_PRIVATE_SESSION_ROUTINES,
|
|
509
|
+
...PRIVATE_SESSION_CREATE_CAPABILITY_ROUTINES,
|
|
510
|
+
PERSONAL_RESOURCE_ATTEMPT_RESOLVER_ROUTINE,
|
|
511
|
+
...USER_RESOURCE_LIFECYCLE_ROUTINES,
|
|
512
|
+
PREFERENCE_KNOWLEDGE_PROPOSAL_ROUTINE,
|
|
513
|
+
...VARIABLE_SET_AUTHORITY_ROUTINES,
|
|
514
|
+
...CONNECTION_AUTHORITY_ROUTINES,
|
|
515
|
+
...PERSONAL_GITHUB_REPOSITORY_AUTHORITY_ROUTINES,
|
|
516
|
+
...PERSONAL_DOCUMENT_AUTHORITY_ROUTINES,
|
|
517
|
+
...DOCUMENT_MIGRATION_AUTHORITY_ROUTINES,
|
|
518
|
+
...SCOPED_COMPUTE_AUTHORITY_ROUTINES,
|
|
519
|
+
...SCHEDULED_PERSONAL_RESOURCE_ROUTINES,
|
|
520
|
+
...CANONICAL_HUMAN_IDENTITY_ROUTINES,
|
|
521
|
+
...TASK_NOTE_CAPABILITY_ROUTINES,
|
|
522
|
+
SESSION_PRIVATE_ACTOR_VISIBLE_ROUTINE,
|
|
523
|
+
SESSION_REFERENCE_VISIBLE_ROUTINE,
|
|
524
|
+
SESSION_VISIBILITY_LIFECYCLE_CAPABILITY_ROUTINE,
|
|
525
|
+
TRANSITION_SESSION_VISIBILITY_ROUTINE,
|
|
526
|
+
XAI_POOL_VISIBLE_ROUTINE,
|
|
527
|
+
XAI_RESOLVE_POOL_ROUTINE,
|
|
528
|
+
XAI_REVALIDATE_CREDENTIAL_ROUTINE,
|
|
529
|
+
XAI_SNAPSHOT_VALIDATOR_ROUTINE
|
|
530
|
+
];
|
|
531
|
+
var RUNTIME_TARGET_SCHEMA_PUBLIC_POLICY_PREDICATE_ROUTINES = [
|
|
532
|
+
CONNECTION_CONVERGENCE_AUDIT_CAPABILITY_ROUTINE
|
|
533
|
+
];
|
|
534
|
+
var RUNTIME_TARGET_SCHEMA_PUBLIC_POLICY_PREDICATE_ROUTINE_SET = new Set(
|
|
535
|
+
RUNTIME_TARGET_SCHEMA_PUBLIC_POLICY_PREDICATE_ROUTINES
|
|
536
|
+
);
|
|
537
|
+
var RUNTIME_TARGET_SCHEMA_FORBIDDEN_ROUTINES = [
|
|
538
|
+
ORGANIZATION_PRIVATE_SESSIONS_ENABLED_ROUTINE,
|
|
539
|
+
SESSION_TENANCY_QUIESCENCE_ROUTINE,
|
|
540
|
+
TENANCY_BACKFILL_ACTIVATION_EVIDENCE_ROUTINE,
|
|
541
|
+
...DOCUMENT_MIGRATION_AUDIT_INTERNAL_ROUTINES
|
|
542
|
+
];
|
|
543
|
+
var RUNTIME_TARGET_SCHEMA_INVOKER_ROUTINES = [
|
|
544
|
+
SESSION_REFERENCE_VISIBLE_ROUTINE,
|
|
545
|
+
XAI_SNAPSHOT_VALIDATOR_ROUTINE
|
|
546
|
+
];
|
|
547
|
+
var RUNTIME_TARGET_SCHEMA_INVOKER_ROUTINE_SET = new Set(
|
|
548
|
+
RUNTIME_TARGET_SCHEMA_INVOKER_ROUTINES
|
|
549
|
+
);
|
|
550
|
+
var FORCE_RLS_TABLES = [
|
|
551
|
+
"agent_run_states",
|
|
552
|
+
"api_keys",
|
|
553
|
+
"attached_browser_devices",
|
|
554
|
+
"attached_browser_inventories",
|
|
555
|
+
"audit_events",
|
|
556
|
+
"auth_runs",
|
|
557
|
+
"automation_run_event_links",
|
|
558
|
+
"automation_runs",
|
|
559
|
+
"automation_sources",
|
|
560
|
+
"automation_trigger_events",
|
|
561
|
+
"automation_trigger_revisions",
|
|
562
|
+
"automation_triggers",
|
|
563
|
+
"billing_customers",
|
|
564
|
+
"browser_identities",
|
|
565
|
+
"browser_revision_components",
|
|
566
|
+
"browser_revisions",
|
|
567
|
+
"browser_session_associations",
|
|
568
|
+
"browser_sessions",
|
|
569
|
+
"browser_state_artifacts",
|
|
570
|
+
"browser_state_uploads",
|
|
571
|
+
"canonical_human_identities",
|
|
572
|
+
"canonical_human_identity_operations",
|
|
573
|
+
"canonical_human_identity_subjects",
|
|
574
|
+
"canonical_human_login_bindings",
|
|
575
|
+
"capability_api_facets",
|
|
576
|
+
"capability_catalog_items",
|
|
577
|
+
"capability_component_owners",
|
|
578
|
+
"capability_facet_installations",
|
|
579
|
+
"capability_facets",
|
|
580
|
+
"capability_installations",
|
|
581
|
+
"capability_integration_facets",
|
|
582
|
+
"capability_mcp_facets",
|
|
583
|
+
"capability_operations",
|
|
584
|
+
"capability_plugin_installations",
|
|
585
|
+
"capability_plugin_versions",
|
|
586
|
+
"capability_plugins",
|
|
587
|
+
"capability_skill_facets",
|
|
588
|
+
"capability_skill_files",
|
|
589
|
+
"channels",
|
|
590
|
+
"codex_apps_settings",
|
|
591
|
+
"codex_capacity_waiters",
|
|
592
|
+
"codex_credential_leases",
|
|
593
|
+
"codex_reset_redemption_attempts",
|
|
594
|
+
"codex_rotation_settings",
|
|
595
|
+
"codex_subscription_credentials",
|
|
596
|
+
"company_brain_context_selection_receipts",
|
|
597
|
+
"company_brain_preference_proposal_receipts",
|
|
598
|
+
"company_brain_turn_context_snapshots",
|
|
599
|
+
"company_profile_activation_events",
|
|
600
|
+
"company_profile_agent_confirmation_receipts",
|
|
601
|
+
"company_profile_agent_proposal_receipts",
|
|
602
|
+
"company_profile_heads",
|
|
603
|
+
"company_profile_revisions",
|
|
604
|
+
"company_profile_snapshots",
|
|
605
|
+
"composer_drafts",
|
|
606
|
+
"computer_session_associations",
|
|
607
|
+
"computer_sessions",
|
|
608
|
+
"connection_disconnect_operations",
|
|
609
|
+
"connection_use_audit_facts",
|
|
610
|
+
"connection_use_once_consumption_receipts",
|
|
611
|
+
"connections",
|
|
612
|
+
"connector_action_policies",
|
|
613
|
+
"connector_action_requests",
|
|
614
|
+
"credit_ledger_entries",
|
|
615
|
+
"device_enrollment_requests",
|
|
616
|
+
"document_authority_reclassifications",
|
|
617
|
+
"document_bases",
|
|
618
|
+
"document_chunks",
|
|
619
|
+
"document_default_collection_backfill_operations",
|
|
620
|
+
"document_default_collection_backfill_receipts",
|
|
621
|
+
"document_default_collection_backfill_runs",
|
|
622
|
+
"documents",
|
|
623
|
+
"editable_artifact_blob_refs",
|
|
624
|
+
"editable_artifact_idempotency_receipts",
|
|
625
|
+
"editable_artifact_live_outbox",
|
|
626
|
+
"editable_artifact_live_tickets",
|
|
627
|
+
"editable_artifact_materialization_jobs",
|
|
628
|
+
"editable_artifact_materialization_results",
|
|
629
|
+
"editable_artifact_operations",
|
|
630
|
+
"editable_artifact_replica_leases",
|
|
631
|
+
"editable_artifact_scope_authorization_heads",
|
|
632
|
+
"editable_artifact_sequence_checkpoints",
|
|
633
|
+
"editable_artifact_session_links",
|
|
634
|
+
"editable_artifact_snapshots",
|
|
635
|
+
"editable_artifact_transactions",
|
|
636
|
+
"editable_artifact_undo_claims",
|
|
637
|
+
"editable_artifact_versions",
|
|
638
|
+
"editable_artifacts",
|
|
639
|
+
"enrollments",
|
|
640
|
+
"file_uploads",
|
|
641
|
+
"files",
|
|
642
|
+
"generated_image_artifacts",
|
|
643
|
+
"generated_video_artifacts",
|
|
644
|
+
"github_installation_repositories",
|
|
645
|
+
"github_installations",
|
|
646
|
+
"google_drive_object_acl_evidence",
|
|
647
|
+
"google_drive_object_acl_principals",
|
|
648
|
+
"governed_learning_activation_receipts",
|
|
649
|
+
"governed_learning_activation_undo_receipts",
|
|
650
|
+
"governed_learning_decision_receipts",
|
|
651
|
+
"host_export_config",
|
|
652
|
+
"host_export_consumers",
|
|
653
|
+
"host_export_cursor_state",
|
|
654
|
+
"host_export_dead_letters",
|
|
655
|
+
"host_export_outbox",
|
|
656
|
+
"image_generation_operations",
|
|
657
|
+
"import_batches",
|
|
658
|
+
"integration_facet_binding_owners",
|
|
659
|
+
"integration_facet_bindings",
|
|
660
|
+
"integration_facet_definitions",
|
|
661
|
+
"integration_oauth_state_nonces",
|
|
662
|
+
"integration_spec_revisions",
|
|
663
|
+
"integration_tools",
|
|
664
|
+
"interaction_interventions",
|
|
665
|
+
"interaction_operations",
|
|
666
|
+
"interaction_resource_operations",
|
|
667
|
+
"knowledge_change_proposals",
|
|
668
|
+
"knowledge_claim_evidence",
|
|
669
|
+
"knowledge_claim_relations",
|
|
670
|
+
"knowledge_claim_reviews",
|
|
671
|
+
"knowledge_claims",
|
|
672
|
+
"knowledge_document_versions",
|
|
673
|
+
"knowledge_entities",
|
|
674
|
+
"knowledge_entity_aliases",
|
|
675
|
+
"knowledge_facts",
|
|
676
|
+
"knowledge_lifecycle_events",
|
|
677
|
+
"knowledge_memories",
|
|
678
|
+
"knowledge_memory_lifecycle_events",
|
|
679
|
+
"knowledge_memory_relationships",
|
|
680
|
+
"knowledge_operation_receipts",
|
|
681
|
+
"knowledge_providers",
|
|
682
|
+
"knowledge_source_acl_versions",
|
|
683
|
+
"knowledge_source_objects",
|
|
684
|
+
"knowledge_source_sync_index_obligations",
|
|
685
|
+
"knowledge_source_sync_item_outcomes",
|
|
686
|
+
"knowledge_source_sync_object_observations",
|
|
687
|
+
"knowledge_source_sync_states",
|
|
688
|
+
"knowledge_source_sync_wakes",
|
|
689
|
+
"knowledge_sources",
|
|
690
|
+
"knowledge_sync_runs",
|
|
691
|
+
"machine_metrics_latest",
|
|
692
|
+
"machine_metrics_series",
|
|
693
|
+
"machine_removal_operations",
|
|
694
|
+
"memory_slack_publication_configurations",
|
|
695
|
+
"memory_slack_publication_receipts",
|
|
696
|
+
"memory_slack_publications",
|
|
697
|
+
"model_call_facts",
|
|
698
|
+
"network_routes",
|
|
699
|
+
"new_session_drafts",
|
|
700
|
+
"organization_invitation_binding_events",
|
|
701
|
+
"organization_membership_invitations",
|
|
702
|
+
"organization_membership_lifecycle_events",
|
|
703
|
+
"organization_membership_operation_receipts",
|
|
704
|
+
"organization_memberships",
|
|
705
|
+
"organization_private_session_setting_events",
|
|
706
|
+
"organization_private_session_settings",
|
|
707
|
+
"organization_profile_events",
|
|
708
|
+
"organization_shared_workspace_administration_capabilities",
|
|
709
|
+
"organization_user_resource_authorities",
|
|
710
|
+
"organization_user_resource_grants",
|
|
711
|
+
"organization_user_retention_deletion_events",
|
|
712
|
+
"organization_user_retention_deletions",
|
|
713
|
+
"organization_user_retention_object_deletion_receipts",
|
|
714
|
+
"organization_user_retention_object_obligations",
|
|
715
|
+
"organization_user_retention_policies",
|
|
716
|
+
"pack_installation_components",
|
|
717
|
+
"pack_installations",
|
|
718
|
+
"personal_document_once_consumption_receipts",
|
|
719
|
+
"personal_github_repository_selection_heads",
|
|
720
|
+
"personal_github_repository_selection_operations",
|
|
721
|
+
"personal_github_repository_selections",
|
|
722
|
+
"personal_resource_once_consumption_receipts",
|
|
723
|
+
"pr_review_app_registrations",
|
|
724
|
+
"pr_review_repository_bindings",
|
|
725
|
+
"preference_registry_events",
|
|
726
|
+
"preference_registry_preferences",
|
|
727
|
+
"preference_registry_revisions",
|
|
728
|
+
"preference_registry_snapshots",
|
|
729
|
+
"private_session_create_capabilities",
|
|
730
|
+
"remember_knowledge_confirmation_receipts",
|
|
731
|
+
"retained_screenshot_artifacts",
|
|
732
|
+
"rig_changes",
|
|
733
|
+
"rig_versions",
|
|
734
|
+
"rigs",
|
|
735
|
+
"sandbox_checkpoint_artifacts",
|
|
736
|
+
"sandbox_lease_holders",
|
|
737
|
+
"sandbox_leases",
|
|
738
|
+
"sandbox_pty_sessions",
|
|
739
|
+
"sandbox_retained_processes",
|
|
740
|
+
"sandbox_session_envelopes",
|
|
741
|
+
"sandbox_workspace_mutation_admissions",
|
|
742
|
+
"sandboxes",
|
|
743
|
+
"scheduled_task_connection_authority_snapshots",
|
|
744
|
+
"scheduled_task_personal_resource_authorities",
|
|
745
|
+
"scheduled_task_personal_resource_snapshots",
|
|
746
|
+
"scheduled_task_reusable_connection_materializations",
|
|
747
|
+
"scheduled_task_revision_authorities",
|
|
748
|
+
"scheduled_task_run_connection_authority_snapshots",
|
|
749
|
+
"scheduled_task_run_personal_resource_admissions",
|
|
750
|
+
"scheduled_task_run_personal_resource_once_receipts",
|
|
751
|
+
"scheduled_task_run_personal_resource_snapshots",
|
|
752
|
+
"scheduled_task_runs",
|
|
753
|
+
"scheduled_tasks",
|
|
754
|
+
"session_attempt_codemode_calls",
|
|
755
|
+
"session_attempt_connected_machine_authorizations",
|
|
756
|
+
"session_attempt_interruptions",
|
|
757
|
+
"session_attempt_personal_document_admissions",
|
|
758
|
+
"session_attempt_personal_document_snapshots",
|
|
759
|
+
"session_attempt_personal_resource_admissions",
|
|
760
|
+
"session_attempt_personal_resource_snapshots",
|
|
761
|
+
"session_attempt_tool_catalogs",
|
|
762
|
+
"session_background_commands",
|
|
763
|
+
"session_command_receipts",
|
|
764
|
+
"session_events",
|
|
765
|
+
"session_goal_revisions",
|
|
766
|
+
"session_goals",
|
|
767
|
+
"session_history_items",
|
|
768
|
+
"session_human_input_requests",
|
|
769
|
+
"session_list_snapshots",
|
|
770
|
+
"session_mcp_servers",
|
|
771
|
+
"session_pending_tool_calls",
|
|
772
|
+
"session_pins",
|
|
773
|
+
"session_realtime_connections",
|
|
774
|
+
"session_realtime_context_projections",
|
|
775
|
+
"session_realtime_entries",
|
|
776
|
+
"session_realtime_modes",
|
|
777
|
+
"session_recordings",
|
|
778
|
+
"session_spawn_denials",
|
|
779
|
+
"session_stream_acknowledgments",
|
|
780
|
+
"session_system_update_outbox",
|
|
781
|
+
"session_system_updates",
|
|
782
|
+
"session_tenancy_activations",
|
|
783
|
+
"session_turn_attempts",
|
|
784
|
+
"session_turn_startup_milestones",
|
|
785
|
+
"session_turns",
|
|
786
|
+
"session_visibility_write_capabilities",
|
|
787
|
+
"session_workflow_wake_outbox",
|
|
788
|
+
"sessions",
|
|
789
|
+
"site_auth_connections",
|
|
790
|
+
"slack_app_home_refreshes",
|
|
791
|
+
"slack_bot_delete_operations",
|
|
792
|
+
"slack_bot_post_operations",
|
|
793
|
+
"slack_bot_update_operations",
|
|
794
|
+
"slack_bot_user_links",
|
|
795
|
+
"slack_channel_routes",
|
|
796
|
+
"slack_installation_bindings",
|
|
797
|
+
"slack_interaction_action_handles",
|
|
798
|
+
"slack_interaction_inbox",
|
|
799
|
+
"slack_interaction_progress_deliveries",
|
|
800
|
+
"slack_interactions",
|
|
801
|
+
"slack_route_prompt_options",
|
|
802
|
+
"slack_route_prompts",
|
|
803
|
+
"slack_shared_task_origins",
|
|
804
|
+
"slack_task_policy_activation_events",
|
|
805
|
+
"slack_task_policy_heads",
|
|
806
|
+
"slack_task_policy_revisions",
|
|
807
|
+
"slack_user_dm_routes",
|
|
808
|
+
"slack_user_link_access_request_operations",
|
|
809
|
+
"slack_user_link_access_requests",
|
|
810
|
+
"social_connections",
|
|
811
|
+
"social_posts",
|
|
812
|
+
"task_note_events",
|
|
813
|
+
"task_note_knowledge_promotion_capabilities",
|
|
814
|
+
"task_note_replacement_receipts",
|
|
815
|
+
"task_note_write_capabilities",
|
|
816
|
+
"task_notes",
|
|
817
|
+
"temporal_schedule_cleanup_outbox",
|
|
818
|
+
"tenancy_backfill_receipts",
|
|
819
|
+
"tenancy_backfill_unresolved_rows",
|
|
820
|
+
"transcription_recording_chunks",
|
|
821
|
+
"transcription_recording_objects",
|
|
822
|
+
"transcription_recording_segments",
|
|
823
|
+
"transcription_recordings",
|
|
824
|
+
"turn_connection_authority_snapshots",
|
|
825
|
+
"turn_personal_resource_attachment_receipts",
|
|
826
|
+
"turn_personal_resource_once_receipts",
|
|
827
|
+
"turn_personal_resource_snapshots",
|
|
828
|
+
"usage_events",
|
|
829
|
+
"video_generation_operations",
|
|
830
|
+
"video_generation_references",
|
|
831
|
+
"workspace_artifact_events",
|
|
832
|
+
"workspace_artifact_versions",
|
|
833
|
+
"workspace_artifacts",
|
|
834
|
+
"workspace_captures",
|
|
835
|
+
"workspace_control_events",
|
|
836
|
+
"workspace_inference_controls",
|
|
837
|
+
"workspace_instruction_policy_activation_events",
|
|
838
|
+
"workspace_instruction_policy_deactivation_events",
|
|
839
|
+
"workspace_instruction_policy_heads",
|
|
840
|
+
"workspace_instruction_policy_onboarding_proposals",
|
|
841
|
+
"workspace_instruction_policy_revisions",
|
|
842
|
+
"workspace_instruction_policy_snapshots",
|
|
843
|
+
"workspace_interaction_revisions",
|
|
844
|
+
"workspace_learning_policy_activation_events",
|
|
845
|
+
"workspace_learning_policy_heads",
|
|
846
|
+
"workspace_learning_policy_revisions",
|
|
847
|
+
"workspace_learning_policy_snapshots",
|
|
848
|
+
"workspace_model_policies",
|
|
849
|
+
"workspace_packs",
|
|
850
|
+
"workspace_screenshot_quotas",
|
|
851
|
+
"workspace_session_activity_revisions",
|
|
852
|
+
"workspace_variable_set_variables",
|
|
853
|
+
"workspace_variable_sets",
|
|
854
|
+
"workspace_video_generation_policies",
|
|
855
|
+
"workspace_video_generation_quotas",
|
|
856
|
+
"xai_capacity_waiters",
|
|
857
|
+
"xai_credential_leases",
|
|
858
|
+
"xai_rotation_settings",
|
|
859
|
+
"xai_session_account_pins",
|
|
860
|
+
"xai_subscription_credentials"
|
|
861
|
+
];
|
|
862
|
+
var NON_RLS_RUNTIME_TABLES = [
|
|
863
|
+
"auth_identities",
|
|
864
|
+
"auth_rate_limits",
|
|
865
|
+
"auth_sessions",
|
|
866
|
+
"auth_users",
|
|
867
|
+
"auth_verifications",
|
|
868
|
+
"automation_webhook_endpoints",
|
|
869
|
+
"integration_oauth_clients",
|
|
870
|
+
"managed_accounts",
|
|
871
|
+
"nested_agent_depth_configuration",
|
|
872
|
+
"stripe_webhook_events",
|
|
873
|
+
"workspace_memberships",
|
|
874
|
+
"workspaces"
|
|
875
|
+
];
|
|
876
|
+
var RUNTIME_FULL_DML_TABLES = [
|
|
877
|
+
"agent_run_states",
|
|
878
|
+
"api_keys",
|
|
879
|
+
"audit_events",
|
|
880
|
+
"auth_identities",
|
|
881
|
+
"auth_rate_limits",
|
|
882
|
+
"auth_sessions",
|
|
883
|
+
"auth_users",
|
|
884
|
+
"auth_verifications",
|
|
885
|
+
"automation_run_event_links",
|
|
886
|
+
"automation_runs",
|
|
887
|
+
"automation_sources",
|
|
888
|
+
"automation_trigger_events",
|
|
889
|
+
"automation_trigger_revisions",
|
|
890
|
+
"automation_triggers",
|
|
891
|
+
"automation_webhook_endpoints",
|
|
892
|
+
"billing_customers",
|
|
893
|
+
"browser_session_associations",
|
|
894
|
+
"capability_catalog_items",
|
|
895
|
+
"capability_component_owners",
|
|
896
|
+
"capability_facet_installations",
|
|
897
|
+
"capability_installations",
|
|
898
|
+
"capability_operations",
|
|
899
|
+
"capability_plugin_installations",
|
|
900
|
+
"channels",
|
|
901
|
+
"codex_apps_settings",
|
|
902
|
+
"codex_capacity_waiters",
|
|
903
|
+
"codex_credential_leases",
|
|
904
|
+
"codex_reset_redemption_attempts",
|
|
905
|
+
"codex_rotation_settings",
|
|
906
|
+
"codex_subscription_credentials",
|
|
907
|
+
"composer_drafts",
|
|
908
|
+
"computer_session_associations",
|
|
909
|
+
"connection_disconnect_operations",
|
|
910
|
+
"connections",
|
|
911
|
+
"connector_action_policies",
|
|
912
|
+
"connector_action_requests",
|
|
913
|
+
"credit_ledger_entries",
|
|
914
|
+
"device_enrollment_requests",
|
|
915
|
+
"document_bases",
|
|
916
|
+
"document_chunks",
|
|
917
|
+
"documents",
|
|
918
|
+
"editable_artifact_replica_leases",
|
|
919
|
+
"enrollments",
|
|
920
|
+
"file_uploads",
|
|
921
|
+
"files",
|
|
922
|
+
"generated_image_artifacts",
|
|
923
|
+
"generated_video_artifacts",
|
|
924
|
+
"github_installation_repositories",
|
|
925
|
+
"github_installations",
|
|
926
|
+
"image_generation_operations",
|
|
927
|
+
"import_batches",
|
|
928
|
+
"integration_facet_binding_owners",
|
|
929
|
+
"integration_facet_bindings",
|
|
930
|
+
"integration_oauth_clients",
|
|
931
|
+
"integration_oauth_state_nonces",
|
|
932
|
+
"knowledge_memories",
|
|
933
|
+
"knowledge_source_sync_index_obligations",
|
|
934
|
+
"knowledge_source_sync_item_outcomes",
|
|
935
|
+
"knowledge_source_sync_object_observations",
|
|
936
|
+
"knowledge_source_sync_states",
|
|
937
|
+
"knowledge_source_sync_wakes",
|
|
938
|
+
"machine_metrics_latest",
|
|
939
|
+
"machine_metrics_series",
|
|
940
|
+
"machine_removal_operations",
|
|
941
|
+
"managed_accounts",
|
|
942
|
+
"memory_slack_publication_configurations",
|
|
943
|
+
"memory_slack_publication_receipts",
|
|
944
|
+
"memory_slack_publications",
|
|
945
|
+
"model_call_facts",
|
|
946
|
+
"new_session_drafts",
|
|
947
|
+
"pack_installation_components",
|
|
948
|
+
"pack_installations",
|
|
949
|
+
"pr_review_app_registrations",
|
|
950
|
+
"pr_review_repository_bindings",
|
|
951
|
+
"retained_screenshot_artifacts",
|
|
952
|
+
"rig_changes",
|
|
953
|
+
"rig_versions",
|
|
954
|
+
"rigs",
|
|
955
|
+
"sandbox_checkpoint_artifacts",
|
|
956
|
+
"sandbox_lease_holders",
|
|
957
|
+
"sandbox_leases",
|
|
958
|
+
"sandbox_pty_sessions",
|
|
959
|
+
"sandbox_retained_processes",
|
|
960
|
+
"sandbox_session_envelopes",
|
|
961
|
+
"sandbox_workspace_mutation_admissions",
|
|
962
|
+
"sandboxes",
|
|
963
|
+
"session_attempt_interruptions",
|
|
964
|
+
"session_background_commands",
|
|
965
|
+
"session_command_receipts",
|
|
966
|
+
"session_events",
|
|
967
|
+
"session_goals",
|
|
968
|
+
"session_history_items",
|
|
969
|
+
"session_human_input_requests",
|
|
970
|
+
"session_list_snapshots",
|
|
971
|
+
"session_mcp_servers",
|
|
972
|
+
"session_pending_tool_calls",
|
|
973
|
+
"session_pins",
|
|
974
|
+
"session_realtime_connections",
|
|
975
|
+
"session_realtime_context_projections",
|
|
976
|
+
"session_realtime_entries",
|
|
977
|
+
"session_realtime_modes",
|
|
978
|
+
"session_recordings",
|
|
979
|
+
"session_stream_acknowledgments",
|
|
980
|
+
"session_system_update_outbox",
|
|
981
|
+
"session_system_updates",
|
|
982
|
+
"session_turn_attempts",
|
|
983
|
+
"session_turns",
|
|
984
|
+
"session_workflow_wake_outbox",
|
|
985
|
+
"sessions",
|
|
986
|
+
"slack_app_home_refreshes",
|
|
987
|
+
"slack_bot_delete_operations",
|
|
988
|
+
"slack_bot_post_operations",
|
|
989
|
+
"slack_bot_update_operations",
|
|
990
|
+
"slack_bot_user_links",
|
|
991
|
+
"slack_channel_routes",
|
|
992
|
+
"slack_interaction_action_handles",
|
|
993
|
+
"slack_interaction_inbox",
|
|
994
|
+
"slack_interaction_progress_deliveries",
|
|
995
|
+
"slack_interactions",
|
|
996
|
+
"slack_route_prompt_options",
|
|
997
|
+
"slack_route_prompts",
|
|
998
|
+
"slack_user_dm_routes",
|
|
999
|
+
"social_connections",
|
|
1000
|
+
"social_posts",
|
|
1001
|
+
"stripe_webhook_events",
|
|
1002
|
+
"transcription_recording_chunks",
|
|
1003
|
+
"transcription_recording_objects",
|
|
1004
|
+
"transcription_recording_segments",
|
|
1005
|
+
"transcription_recordings",
|
|
1006
|
+
"usage_events",
|
|
1007
|
+
"video_generation_operations",
|
|
1008
|
+
"video_generation_references",
|
|
1009
|
+
"workspace_artifacts",
|
|
1010
|
+
"workspace_captures",
|
|
1011
|
+
"workspace_control_events",
|
|
1012
|
+
"workspace_inference_controls",
|
|
1013
|
+
"workspace_instruction_policy_heads",
|
|
1014
|
+
"workspace_memberships",
|
|
1015
|
+
"workspace_model_policies",
|
|
1016
|
+
"workspace_packs",
|
|
1017
|
+
"workspace_screenshot_quotas",
|
|
1018
|
+
"workspace_video_generation_policies",
|
|
1019
|
+
"workspace_video_generation_quotas",
|
|
1020
|
+
"workspaces",
|
|
1021
|
+
"xai_capacity_waiters",
|
|
1022
|
+
"xai_credential_leases",
|
|
1023
|
+
"xai_rotation_settings",
|
|
1024
|
+
"xai_session_account_pins",
|
|
1025
|
+
"xai_subscription_credentials"
|
|
1026
|
+
];
|
|
1027
|
+
var RUNTIME_READ_ONLY_TABLES = [
|
|
1028
|
+
"company_profile_activation_events",
|
|
1029
|
+
"company_profile_heads",
|
|
1030
|
+
"company_profile_snapshots",
|
|
1031
|
+
"document_authority_reclassifications",
|
|
1032
|
+
"knowledge_lifecycle_events",
|
|
1033
|
+
"knowledge_memory_lifecycle_events",
|
|
1034
|
+
"knowledge_memory_relationships",
|
|
1035
|
+
"nested_agent_depth_configuration",
|
|
1036
|
+
"preference_registry_events",
|
|
1037
|
+
"preference_registry_snapshots",
|
|
1038
|
+
"session_tenancy_activations",
|
|
1039
|
+
"slack_installation_bindings",
|
|
1040
|
+
"slack_task_policy_activation_events",
|
|
1041
|
+
"slack_task_policy_heads",
|
|
1042
|
+
"slack_task_policy_revisions",
|
|
1043
|
+
"workspace_instruction_policy_deactivation_events",
|
|
1044
|
+
"workspace_instruction_policy_snapshots",
|
|
1045
|
+
"workspace_learning_policy_activation_events",
|
|
1046
|
+
"workspace_learning_policy_heads",
|
|
1047
|
+
"workspace_learning_policy_snapshots"
|
|
1048
|
+
];
|
|
1049
|
+
var RUNTIME_READ_UPDATE_TABLES = ["workspace_session_activity_revisions"];
|
|
1050
|
+
var RUNTIME_READ_INSERT_TABLES = [
|
|
1051
|
+
"browser_revision_components",
|
|
1052
|
+
"browser_revisions",
|
|
1053
|
+
"company_profile_revisions",
|
|
1054
|
+
"editable_artifact_blob_refs",
|
|
1055
|
+
"editable_artifact_idempotency_receipts",
|
|
1056
|
+
"editable_artifact_live_outbox",
|
|
1057
|
+
"editable_artifact_materialization_jobs",
|
|
1058
|
+
"editable_artifact_materialization_results",
|
|
1059
|
+
"editable_artifact_operations",
|
|
1060
|
+
"editable_artifact_sequence_checkpoints",
|
|
1061
|
+
"editable_artifact_snapshots",
|
|
1062
|
+
"editable_artifact_transactions",
|
|
1063
|
+
"editable_artifact_undo_claims",
|
|
1064
|
+
"editable_artifact_versions",
|
|
1065
|
+
"google_drive_object_acl_evidence",
|
|
1066
|
+
"google_drive_object_acl_principals",
|
|
1067
|
+
"knowledge_change_proposals",
|
|
1068
|
+
"knowledge_claim_evidence",
|
|
1069
|
+
"knowledge_claim_relations",
|
|
1070
|
+
"knowledge_claim_reviews",
|
|
1071
|
+
"knowledge_claims",
|
|
1072
|
+
"knowledge_document_versions",
|
|
1073
|
+
"knowledge_entities",
|
|
1074
|
+
"knowledge_entity_aliases",
|
|
1075
|
+
"knowledge_facts",
|
|
1076
|
+
"knowledge_operation_receipts",
|
|
1077
|
+
"knowledge_providers",
|
|
1078
|
+
"knowledge_source_acl_versions",
|
|
1079
|
+
"knowledge_source_objects",
|
|
1080
|
+
"knowledge_sources",
|
|
1081
|
+
"knowledge_sync_runs",
|
|
1082
|
+
"preference_registry_preferences",
|
|
1083
|
+
"preference_registry_revisions",
|
|
1084
|
+
"session_attempt_tool_catalogs",
|
|
1085
|
+
"session_goal_revisions",
|
|
1086
|
+
"session_spawn_denials",
|
|
1087
|
+
"slack_shared_task_origins",
|
|
1088
|
+
"slack_user_link_access_request_operations",
|
|
1089
|
+
"temporal_schedule_cleanup_outbox",
|
|
1090
|
+
"workspace_artifact_events",
|
|
1091
|
+
"workspace_artifact_versions",
|
|
1092
|
+
"workspace_instruction_policy_activation_events",
|
|
1093
|
+
"workspace_instruction_policy_onboarding_proposals",
|
|
1094
|
+
"workspace_instruction_policy_revisions",
|
|
1095
|
+
"workspace_learning_policy_revisions"
|
|
1096
|
+
];
|
|
1097
|
+
var RUNTIME_READ_INSERT_UPDATE_TABLES = [
|
|
1098
|
+
"attached_browser_devices",
|
|
1099
|
+
"attached_browser_inventories",
|
|
1100
|
+
"auth_runs",
|
|
1101
|
+
"browser_identities",
|
|
1102
|
+
"browser_sessions",
|
|
1103
|
+
"browser_state_artifacts",
|
|
1104
|
+
"browser_state_uploads",
|
|
1105
|
+
"capability_api_facets",
|
|
1106
|
+
"capability_facets",
|
|
1107
|
+
"capability_integration_facets",
|
|
1108
|
+
"capability_mcp_facets",
|
|
1109
|
+
"capability_plugin_versions",
|
|
1110
|
+
"capability_plugins",
|
|
1111
|
+
"capability_skill_facets",
|
|
1112
|
+
"capability_skill_files",
|
|
1113
|
+
"computer_sessions",
|
|
1114
|
+
"editable_artifact_session_links",
|
|
1115
|
+
"editable_artifacts",
|
|
1116
|
+
"integration_facet_definitions",
|
|
1117
|
+
"integration_spec_revisions",
|
|
1118
|
+
"integration_tools",
|
|
1119
|
+
"interaction_interventions",
|
|
1120
|
+
"interaction_operations",
|
|
1121
|
+
"interaction_resource_operations",
|
|
1122
|
+
"network_routes",
|
|
1123
|
+
"scheduled_task_runs",
|
|
1124
|
+
"scheduled_tasks",
|
|
1125
|
+
"session_attempt_codemode_calls",
|
|
1126
|
+
"session_turn_startup_milestones",
|
|
1127
|
+
"site_auth_connections",
|
|
1128
|
+
"slack_user_link_access_requests",
|
|
1129
|
+
"workspace_interaction_revisions"
|
|
1130
|
+
];
|
|
1131
|
+
var PROTECTED_NO_DIRECT_DML_TABLES = [
|
|
1132
|
+
"canonical_human_identities",
|
|
1133
|
+
"canonical_human_identity_operations",
|
|
1134
|
+
"canonical_human_identity_subjects",
|
|
1135
|
+
"canonical_human_login_bindings",
|
|
1136
|
+
"company_brain_context_selection_receipts",
|
|
1137
|
+
"company_brain_preference_proposal_receipts",
|
|
1138
|
+
"company_brain_turn_context_snapshots",
|
|
1139
|
+
"company_profile_agent_confirmation_receipts",
|
|
1140
|
+
"company_profile_agent_proposal_receipts",
|
|
1141
|
+
"connection_use_audit_facts",
|
|
1142
|
+
"connection_use_once_consumption_receipts",
|
|
1143
|
+
"document_default_collection_backfill_operations",
|
|
1144
|
+
"document_default_collection_backfill_receipts",
|
|
1145
|
+
"document_default_collection_backfill_runs",
|
|
1146
|
+
"editable_artifact_live_tickets",
|
|
1147
|
+
"editable_artifact_scope_authorization_heads",
|
|
1148
|
+
"governed_learning_activation_receipts",
|
|
1149
|
+
"governed_learning_activation_undo_receipts",
|
|
1150
|
+
"governed_learning_decision_receipts",
|
|
1151
|
+
"host_export_config",
|
|
1152
|
+
"host_export_consumers",
|
|
1153
|
+
"host_export_cursor_state",
|
|
1154
|
+
"host_export_dead_letters",
|
|
1155
|
+
"host_export_outbox",
|
|
1156
|
+
"organization_invitation_binding_events",
|
|
1157
|
+
"organization_membership_invitations",
|
|
1158
|
+
"organization_membership_lifecycle_events",
|
|
1159
|
+
"organization_membership_operation_receipts",
|
|
1160
|
+
"organization_memberships",
|
|
1161
|
+
"organization_private_session_setting_events",
|
|
1162
|
+
"organization_private_session_settings",
|
|
1163
|
+
"organization_profile_events",
|
|
1164
|
+
"organization_shared_workspace_administration_capabilities",
|
|
1165
|
+
"organization_user_resource_authorities",
|
|
1166
|
+
"organization_user_resource_grants",
|
|
1167
|
+
"organization_user_retention_deletion_events",
|
|
1168
|
+
"organization_user_retention_deletions",
|
|
1169
|
+
"organization_user_retention_object_deletion_receipts",
|
|
1170
|
+
"organization_user_retention_object_obligations",
|
|
1171
|
+
"organization_user_retention_policies",
|
|
1172
|
+
"personal_document_once_consumption_receipts",
|
|
1173
|
+
"personal_github_repository_selection_heads",
|
|
1174
|
+
"personal_github_repository_selection_operations",
|
|
1175
|
+
"personal_github_repository_selections",
|
|
1176
|
+
"personal_resource_once_consumption_receipts",
|
|
1177
|
+
"private_session_create_capabilities",
|
|
1178
|
+
"remember_knowledge_confirmation_receipts",
|
|
1179
|
+
"scheduled_task_connection_authority_snapshots",
|
|
1180
|
+
"scheduled_task_personal_resource_authorities",
|
|
1181
|
+
"scheduled_task_personal_resource_snapshots",
|
|
1182
|
+
"scheduled_task_reusable_connection_materializations",
|
|
1183
|
+
"scheduled_task_revision_authorities",
|
|
1184
|
+
"scheduled_task_run_connection_authority_snapshots",
|
|
1185
|
+
"scheduled_task_run_personal_resource_admissions",
|
|
1186
|
+
"scheduled_task_run_personal_resource_once_receipts",
|
|
1187
|
+
"scheduled_task_run_personal_resource_snapshots",
|
|
1188
|
+
"session_attempt_connected_machine_authorizations",
|
|
1189
|
+
"session_attempt_personal_document_admissions",
|
|
1190
|
+
"session_attempt_personal_document_snapshots",
|
|
1191
|
+
"session_attempt_personal_resource_admissions",
|
|
1192
|
+
"session_attempt_personal_resource_snapshots",
|
|
1193
|
+
"session_visibility_write_capabilities",
|
|
1194
|
+
"task_note_events",
|
|
1195
|
+
"task_note_knowledge_promotion_capabilities",
|
|
1196
|
+
"task_note_replacement_receipts",
|
|
1197
|
+
"task_note_write_capabilities",
|
|
1198
|
+
"task_notes",
|
|
1199
|
+
"tenancy_backfill_receipts",
|
|
1200
|
+
"tenancy_backfill_unresolved_rows",
|
|
1201
|
+
"turn_connection_authority_snapshots",
|
|
1202
|
+
"turn_personal_resource_attachment_receipts",
|
|
1203
|
+
"turn_personal_resource_once_receipts",
|
|
1204
|
+
"turn_personal_resource_snapshots",
|
|
1205
|
+
"workspace_variable_set_variables",
|
|
1206
|
+
"workspace_variable_sets"
|
|
1207
|
+
];
|
|
1208
|
+
var FULL_DML_PRIVILEGES = ["SELECT", "INSERT", "UPDATE", "DELETE"];
|
|
1209
|
+
var RUNTIME_TABLE_PRIVILEGES = Object.freeze({
|
|
1210
|
+
...Object.fromEntries(RUNTIME_FULL_DML_TABLES.map((table) => [table, FULL_DML_PRIVILEGES])),
|
|
1211
|
+
...Object.fromEntries(RUNTIME_READ_ONLY_TABLES.map((table) => [table, ["SELECT"]])),
|
|
1212
|
+
...Object.fromEntries(
|
|
1213
|
+
RUNTIME_READ_UPDATE_TABLES.map((table) => [table, ["SELECT", "UPDATE"]])
|
|
1214
|
+
),
|
|
1215
|
+
...Object.fromEntries(
|
|
1216
|
+
RUNTIME_READ_INSERT_TABLES.map((table) => [table, ["SELECT", "INSERT"]])
|
|
1217
|
+
),
|
|
1218
|
+
...Object.fromEntries(
|
|
1219
|
+
RUNTIME_READ_INSERT_UPDATE_TABLES.map((table) => [
|
|
1220
|
+
table,
|
|
1221
|
+
["SELECT", "INSERT", "UPDATE"]
|
|
1222
|
+
])
|
|
1223
|
+
)
|
|
1224
|
+
});
|
|
1225
|
+
var RUNTIME_DML_TABLES = Object.freeze(
|
|
1226
|
+
Object.keys(RUNTIME_TABLE_PRIVILEGES).sort((a, b) => a.localeCompare(b))
|
|
1227
|
+
);
|
|
1228
|
+
var RuntimeDatabasePostureError = class extends Error {
|
|
1229
|
+
violations;
|
|
1230
|
+
constructor(violations) {
|
|
1231
|
+
super(`Runtime database posture check failed: ${violations.join("; ")}`);
|
|
1232
|
+
this.name = "RuntimeDatabasePostureError";
|
|
1233
|
+
this.violations = violations;
|
|
1234
|
+
}
|
|
1235
|
+
};
|
|
1236
|
+
function resultRows(result) {
|
|
1237
|
+
if (Array.isArray(result)) {
|
|
1238
|
+
return result;
|
|
1239
|
+
}
|
|
1240
|
+
const rows = result?.rows;
|
|
1241
|
+
if (Array.isArray(rows)) {
|
|
1242
|
+
return rows;
|
|
1243
|
+
}
|
|
1244
|
+
throw new Error("Runtime database posture query returned an unsupported result shape");
|
|
1245
|
+
}
|
|
1246
|
+
function sorted(values) {
|
|
1247
|
+
return [...values].sort((a, b) => a.localeCompare(b));
|
|
1248
|
+
}
|
|
1249
|
+
function difference(left, right) {
|
|
1250
|
+
return sorted([...left].filter((value) => !right.has(value)));
|
|
1251
|
+
}
|
|
1252
|
+
async function inspectRuntimeDatabasePosture(db, options) {
|
|
1253
|
+
const targetSchema = options.targetSchema?.trim() || "public";
|
|
1254
|
+
return await db.transaction(
|
|
1255
|
+
async (tx) => {
|
|
1256
|
+
const identityRows = resultRows(
|
|
1257
|
+
await tx.execute(sql`
|
|
1258
|
+
select
|
|
1259
|
+
current_user::text as current_user,
|
|
1260
|
+
session_user::text as session_user,
|
|
1261
|
+
pg_get_userbyid(d.datdba)::text as database_owner,
|
|
1262
|
+
has_database_privilege(current_user, d.oid, 'CONNECT') as can_connect_database,
|
|
1263
|
+
has_database_privilege(current_user, d.oid, 'CREATE') as can_create_in_database,
|
|
1264
|
+
current_setting('row_security')::text as row_security,
|
|
1265
|
+
r.rolcanlogin,
|
|
1266
|
+
r.rolsuper,
|
|
1267
|
+
r.rolinherit,
|
|
1268
|
+
r.rolcreaterole,
|
|
1269
|
+
r.rolcreatedb,
|
|
1270
|
+
r.rolreplication,
|
|
1271
|
+
r.rolbypassrls
|
|
1272
|
+
from pg_roles r
|
|
1273
|
+
join pg_database d on d.datname = current_database()
|
|
1274
|
+
where r.rolname = current_user
|
|
1275
|
+
`)
|
|
1276
|
+
);
|
|
1277
|
+
const identity = identityRows[0];
|
|
1278
|
+
if (!identity) {
|
|
1279
|
+
throw new Error("Runtime database posture could not resolve the current PostgreSQL role");
|
|
1280
|
+
}
|
|
1281
|
+
const mappedIdentity = {
|
|
1282
|
+
currentUser: identity.current_user,
|
|
1283
|
+
sessionUser: identity.session_user,
|
|
1284
|
+
databaseOwner: identity.database_owner,
|
|
1285
|
+
canConnectDatabase: identity.can_connect_database,
|
|
1286
|
+
canCreateInDatabase: identity.can_create_in_database,
|
|
1287
|
+
rowSecurity: identity.row_security,
|
|
1288
|
+
canLogin: identity.rolcanlogin,
|
|
1289
|
+
superuser: identity.rolsuper,
|
|
1290
|
+
inherit: identity.rolinherit,
|
|
1291
|
+
createRole: identity.rolcreaterole,
|
|
1292
|
+
createDatabase: identity.rolcreatedb,
|
|
1293
|
+
replication: identity.rolreplication,
|
|
1294
|
+
bypassRls: identity.rolbypassrls
|
|
1295
|
+
};
|
|
1296
|
+
const activationRows = resultRows(
|
|
1297
|
+
await tx.execute(sql`select session_tenancy_any_product_activation() as activated`)
|
|
1298
|
+
);
|
|
1299
|
+
const sessionTenancyProductActivationPresent = activationRows[0]?.activated === true;
|
|
1300
|
+
if (options.rlsStrategy === "scoped") {
|
|
1301
|
+
return {
|
|
1302
|
+
identity: mappedIdentity,
|
|
1303
|
+
memberships: [],
|
|
1304
|
+
schemas: [],
|
|
1305
|
+
ownedSchemas: [],
|
|
1306
|
+
ownedRelations: [],
|
|
1307
|
+
tables: [],
|
|
1308
|
+
privateTables: [],
|
|
1309
|
+
targetRoutines: [],
|
|
1310
|
+
privateRoutines: [],
|
|
1311
|
+
sessionTenancyProductActivationPresent
|
|
1312
|
+
};
|
|
1313
|
+
}
|
|
1314
|
+
const relationshipRows = resultRows(
|
|
1315
|
+
await tx.execute(sql.raw(roleRelationshipsCatalogQuery("current_user")))
|
|
1316
|
+
);
|
|
1317
|
+
const memberships = classifyRoleRelationships(relationshipRows).unsafeRelationships;
|
|
1318
|
+
const schemas = resultRows(
|
|
1319
|
+
await tx.execute(sql`
|
|
1320
|
+
select
|
|
1321
|
+
n.nspname::text as name,
|
|
1322
|
+
pg_get_userbyid(n.nspowner)::text as owner,
|
|
1323
|
+
has_schema_privilege(current_user, n.oid, 'USAGE') as usage,
|
|
1324
|
+
has_schema_privilege(current_user, n.oid, 'CREATE') as create
|
|
1325
|
+
from pg_namespace n
|
|
1326
|
+
where n.nspname in (${targetSchema}, 'opengeni_private')
|
|
1327
|
+
order by n.nspname
|
|
1328
|
+
`)
|
|
1329
|
+
);
|
|
1330
|
+
const ownedSchemas = resultRows(
|
|
1331
|
+
await tx.execute(sql`
|
|
1332
|
+
select n.nspname::text as name
|
|
1333
|
+
from pg_namespace n
|
|
1334
|
+
join pg_roles r on r.oid = n.nspowner
|
|
1335
|
+
where r.rolname = current_user
|
|
1336
|
+
and n.nspname <> 'information_schema'
|
|
1337
|
+
and n.nspname !~ '^pg_'
|
|
1338
|
+
order by n.nspname
|
|
1339
|
+
`)
|
|
1340
|
+
).map((row) => row.name);
|
|
1341
|
+
const ownedRelations = resultRows(
|
|
1342
|
+
await tx.execute(sql`
|
|
1343
|
+
select (n.nspname || '.' || c.relname)::text as name
|
|
1344
|
+
from pg_class c
|
|
1345
|
+
join pg_namespace n on n.oid = c.relnamespace
|
|
1346
|
+
join pg_roles r on r.oid = c.relowner
|
|
1347
|
+
where r.rolname = current_user
|
|
1348
|
+
and c.relkind in ('r', 'p', 'S', 'v', 'm', 'f')
|
|
1349
|
+
and n.nspname <> 'information_schema'
|
|
1350
|
+
and n.nspname !~ '^pg_'
|
|
1351
|
+
order by n.nspname, c.relname
|
|
1352
|
+
`)
|
|
1353
|
+
).map((row) => row.name);
|
|
1354
|
+
const tables = resultRows(
|
|
1355
|
+
await tx.execute(sql`
|
|
1356
|
+
select
|
|
1357
|
+
c.relname::text as name,
|
|
1358
|
+
pg_get_userbyid(c.relowner)::text as owner,
|
|
1359
|
+
c.relrowsecurity as rls_enabled,
|
|
1360
|
+
c.relforcerowsecurity as rls_forced,
|
|
1361
|
+
row_security_active(c.oid) as rls_active,
|
|
1362
|
+
(select count(*)::int from pg_policy policy where policy.polrelid = c.oid) as policy_count,
|
|
1363
|
+
exists(
|
|
1364
|
+
select 1 from pg_policy policy
|
|
1365
|
+
where policy.polrelid = c.oid
|
|
1366
|
+
and policy.polname = 'editable_artifact_outbox_dispatcher'
|
|
1367
|
+
) as artifact_outbox_dispatcher_policy,
|
|
1368
|
+
exists(
|
|
1369
|
+
select 1 from pg_policy policy
|
|
1370
|
+
where policy.polrelid = c.oid
|
|
1371
|
+
and policy.polname = 'editable_artifact_materializer_owner'
|
|
1372
|
+
) as artifact_materializer_policy,
|
|
1373
|
+
has_table_privilege(current_user, c.oid, 'SELECT') as can_select,
|
|
1374
|
+
has_table_privilege(current_user, c.oid, 'INSERT') as can_insert,
|
|
1375
|
+
has_table_privilege(current_user, c.oid, 'UPDATE') as can_update,
|
|
1376
|
+
has_table_privilege(current_user, c.oid, 'DELETE') as can_delete,
|
|
1377
|
+
has_table_privilege(current_user, c.oid, 'TRUNCATE') as can_truncate,
|
|
1378
|
+
has_table_privilege(current_user, c.oid, 'REFERENCES') as can_references,
|
|
1379
|
+
has_table_privilege(current_user, c.oid, 'TRIGGER') as can_trigger
|
|
1380
|
+
from pg_class c
|
|
1381
|
+
join pg_namespace n on n.oid = c.relnamespace
|
|
1382
|
+
where n.nspname = ${targetSchema}
|
|
1383
|
+
and c.relkind in ('r', 'p')
|
|
1384
|
+
order by c.relname
|
|
1385
|
+
`)
|
|
1386
|
+
).map((row) => ({
|
|
1387
|
+
name: row.name,
|
|
1388
|
+
owner: row.owner,
|
|
1389
|
+
rlsEnabled: row.rls_enabled,
|
|
1390
|
+
rlsForced: row.rls_forced,
|
|
1391
|
+
rlsActive: row.rls_active,
|
|
1392
|
+
policyCount: row.policy_count,
|
|
1393
|
+
artifactOutboxDispatcherPolicy: row.artifact_outbox_dispatcher_policy,
|
|
1394
|
+
artifactMaterializerPolicy: row.artifact_materializer_policy,
|
|
1395
|
+
select: row.can_select,
|
|
1396
|
+
insert: row.can_insert,
|
|
1397
|
+
update: row.can_update,
|
|
1398
|
+
delete: row.can_delete,
|
|
1399
|
+
truncate: row.can_truncate,
|
|
1400
|
+
references: row.can_references,
|
|
1401
|
+
trigger: row.can_trigger
|
|
1402
|
+
}));
|
|
1403
|
+
const privateTables = resultRows(
|
|
1404
|
+
await tx.execute(sql`
|
|
1405
|
+
select
|
|
1406
|
+
c.relname::text as name,
|
|
1407
|
+
pg_get_userbyid(c.relowner)::text as owner,
|
|
1408
|
+
has_table_privilege(current_user, c.oid, 'SELECT') as can_select,
|
|
1409
|
+
has_table_privilege(current_user, c.oid, 'INSERT') as can_insert,
|
|
1410
|
+
has_table_privilege(current_user, c.oid, 'UPDATE') as can_update,
|
|
1411
|
+
has_table_privilege(current_user, c.oid, 'DELETE') as can_delete
|
|
1412
|
+
from pg_class c
|
|
1413
|
+
join pg_namespace n on n.oid = c.relnamespace
|
|
1414
|
+
where n.nspname = 'opengeni_private'
|
|
1415
|
+
and c.relkind in ('r', 'p')
|
|
1416
|
+
and c.relname in (
|
|
1417
|
+
${PERSONAL_RESOURCE_CAPABILITY_TABLE},
|
|
1418
|
+
${SCHEDULED_PERSONAL_RESOURCE_CAPABILITY_TABLE},
|
|
1419
|
+
${VARIABLE_SET_CAPABILITY_TABLE},
|
|
1420
|
+
${PERSONAL_DOCUMENT_CAPABILITY_TABLE},
|
|
1421
|
+
${DOCUMENT_MIGRATION_CAPABILITY_TABLE},
|
|
1422
|
+
${SCOPED_COMPUTE_CAPABILITY_TABLE},
|
|
1423
|
+
${CONNECTION_TENANCY_BACKFILL_CAPABILITY_TABLE}
|
|
1424
|
+
)
|
|
1425
|
+
`)
|
|
1426
|
+
).map((row) => ({
|
|
1427
|
+
name: row.name,
|
|
1428
|
+
owner: row.owner,
|
|
1429
|
+
select: row.can_select,
|
|
1430
|
+
insert: row.can_insert,
|
|
1431
|
+
update: row.can_update,
|
|
1432
|
+
delete: row.can_delete
|
|
1433
|
+
}));
|
|
1434
|
+
const targetRoutines = resultRows(
|
|
1435
|
+
await tx.execute(sql`
|
|
1436
|
+
select
|
|
1437
|
+
(p.proname || '(' || pg_catalog.oidvectortypes(p.proargtypes) || ')')::text as name,
|
|
1438
|
+
pg_get_userbyid(p.proowner)::text as owner,
|
|
1439
|
+
has_function_privilege(current_user, p.oid, 'EXECUTE') as can_execute,
|
|
1440
|
+
exists (
|
|
1441
|
+
select 1
|
|
1442
|
+
from aclexplode(coalesce(p.proacl, acldefault('f', p.proowner))) acl
|
|
1443
|
+
where acl.grantee = 0 and acl.privilege_type = 'EXECUTE'
|
|
1444
|
+
) as public_execute,
|
|
1445
|
+
p.prosecdef as security_definer
|
|
1446
|
+
from pg_proc p
|
|
1447
|
+
join pg_namespace n on n.oid = p.pronamespace
|
|
1448
|
+
where n.nspname = ${targetSchema}
|
|
1449
|
+
and p.prokind in ('f', 'p')
|
|
1450
|
+
and (p.proname || '(' || pg_catalog.oidvectortypes(p.proargtypes) || ')') = any(
|
|
1451
|
+
array[
|
|
1452
|
+
${sql.join(
|
|
1453
|
+
[
|
|
1454
|
+
...RUNTIME_TARGET_SCHEMA_CAPABILITY_ROUTINES,
|
|
1455
|
+
...RUNTIME_TARGET_SCHEMA_FORBIDDEN_ROUTINES
|
|
1456
|
+
].map((name) => sql`${name}`),
|
|
1457
|
+
sql`, `
|
|
1458
|
+
)}
|
|
1459
|
+
]::text[]
|
|
1460
|
+
)
|
|
1461
|
+
order by p.proname, pg_catalog.oidvectortypes(p.proargtypes)
|
|
1462
|
+
`)
|
|
1463
|
+
).map((row) => ({
|
|
1464
|
+
name: row.name,
|
|
1465
|
+
owner: row.owner,
|
|
1466
|
+
execute: row.can_execute,
|
|
1467
|
+
publicExecute: row.public_execute,
|
|
1468
|
+
securityDefiner: row.security_definer
|
|
1469
|
+
})).sort((left, right) => left.name.localeCompare(right.name));
|
|
1470
|
+
const privateRoutines = resultRows(
|
|
1471
|
+
await tx.execute(sql`
|
|
1472
|
+
select
|
|
1473
|
+
(p.proname || '(' || pg_catalog.oidvectortypes(p.proargtypes) || ')')::text as name,
|
|
1474
|
+
pg_get_userbyid(p.proowner)::text as owner,
|
|
1475
|
+
has_function_privilege(current_user, p.oid, 'EXECUTE') as can_execute,
|
|
1476
|
+
exists (
|
|
1477
|
+
select 1
|
|
1478
|
+
from aclexplode(coalesce(p.proacl, acldefault('f', p.proowner))) acl
|
|
1479
|
+
where acl.grantee = 0 and acl.privilege_type = 'EXECUTE'
|
|
1480
|
+
) as public_execute,
|
|
1481
|
+
p.prosecdef as security_definer
|
|
1482
|
+
from pg_proc p
|
|
1483
|
+
join pg_namespace n on n.oid = p.pronamespace
|
|
1484
|
+
where n.nspname = 'opengeni_private'
|
|
1485
|
+
and p.prokind in ('f', 'p')
|
|
1486
|
+
order by p.proname, pg_catalog.oidvectortypes(p.proargtypes)
|
|
1487
|
+
`)
|
|
1488
|
+
).map((row) => ({
|
|
1489
|
+
name: row.name,
|
|
1490
|
+
owner: row.owner,
|
|
1491
|
+
execute: row.can_execute,
|
|
1492
|
+
publicExecute: row.public_execute,
|
|
1493
|
+
securityDefiner: row.security_definer
|
|
1494
|
+
}));
|
|
1495
|
+
return {
|
|
1496
|
+
identity: mappedIdentity,
|
|
1497
|
+
memberships,
|
|
1498
|
+
schemas,
|
|
1499
|
+
ownedSchemas,
|
|
1500
|
+
ownedRelations,
|
|
1501
|
+
tables,
|
|
1502
|
+
privateTables,
|
|
1503
|
+
targetRoutines,
|
|
1504
|
+
privateRoutines,
|
|
1505
|
+
sessionTenancyProductActivationPresent
|
|
1506
|
+
};
|
|
1507
|
+
},
|
|
1508
|
+
{ isolationLevel: "repeatable read", accessMode: "read only" }
|
|
1509
|
+
);
|
|
1510
|
+
}
|
|
1511
|
+
function evaluateRuntimeDatabasePosture(posture, options) {
|
|
1512
|
+
const violations = [];
|
|
1513
|
+
const identity = posture.identity;
|
|
1514
|
+
if (posture.sessionTenancyProductActivationPresent && options.organizationTenancyCanonicalActivationEnabled !== true) {
|
|
1515
|
+
violations.push(
|
|
1516
|
+
"session-tenancy product activation is durable but OPENGENI_ORGANIZATION_TENANCY_CANONICAL_ACTIVATION_ENABLED is not true"
|
|
1517
|
+
);
|
|
1518
|
+
}
|
|
1519
|
+
if (!identity.currentUser || !identity.sessionUser) {
|
|
1520
|
+
violations.push("database identity is empty");
|
|
1521
|
+
}
|
|
1522
|
+
if (identity.currentUser !== identity.sessionUser) {
|
|
1523
|
+
violations.push(
|
|
1524
|
+
`current_user ${identity.currentUser} does not match session_user ${identity.sessionUser}`
|
|
1525
|
+
);
|
|
1526
|
+
}
|
|
1527
|
+
if (!identity.canConnectDatabase) {
|
|
1528
|
+
violations.push("runtime role lacks CONNECT on the current database");
|
|
1529
|
+
}
|
|
1530
|
+
if (options.rlsStrategy === "scoped") {
|
|
1531
|
+
return violations;
|
|
1532
|
+
}
|
|
1533
|
+
const expectedRole = options.expectedRole?.trim() || "opengeni_app";
|
|
1534
|
+
const targetSchema = options.targetSchema?.trim() || "public";
|
|
1535
|
+
const protectedTables = new Set(options.protectedTables ?? FORCE_RLS_TABLES);
|
|
1536
|
+
const tablePrivileges = options.tablePrivileges ?? RUNTIME_TABLE_PRIVILEGES;
|
|
1537
|
+
const directRuntimeTables = new Set(Object.keys(tablePrivileges));
|
|
1538
|
+
const protectedNoDirectDmlTables = new Set(
|
|
1539
|
+
options.protectedNoDirectDmlTables ?? (options.protectedTables ? [] : PROTECTED_NO_DIRECT_DML_TABLES)
|
|
1540
|
+
);
|
|
1541
|
+
if (identity.currentUser !== expectedRole || identity.sessionUser !== expectedRole) {
|
|
1542
|
+
violations.push(
|
|
1543
|
+
`runtime identity must be ${expectedRole} (current_user=${identity.currentUser}, session_user=${identity.sessionUser})`
|
|
1544
|
+
);
|
|
1545
|
+
}
|
|
1546
|
+
if (!identity.canLogin) violations.push("runtime role is not LOGIN");
|
|
1547
|
+
if (identity.superuser) violations.push("runtime role is SUPERUSER");
|
|
1548
|
+
if (identity.bypassRls) violations.push("runtime role has BYPASSRLS");
|
|
1549
|
+
if (identity.createRole) violations.push("runtime role has CREATEROLE");
|
|
1550
|
+
if (identity.createDatabase) violations.push("runtime role has CREATEDB");
|
|
1551
|
+
if (identity.replication) violations.push("runtime role has REPLICATION");
|
|
1552
|
+
if (identity.inherit) violations.push("runtime role must be NOINHERIT");
|
|
1553
|
+
if (identity.databaseOwner === expectedRole) violations.push("runtime role owns the database");
|
|
1554
|
+
if (identity.canCreateInDatabase) {
|
|
1555
|
+
violations.push("runtime role has CREATE on the current database");
|
|
1556
|
+
}
|
|
1557
|
+
if (identity.rowSecurity.toLowerCase() !== "on") {
|
|
1558
|
+
violations.push(`row_security is ${identity.rowSecurity}, expected on`);
|
|
1559
|
+
}
|
|
1560
|
+
if (posture.memberships.length > 0) {
|
|
1561
|
+
violations.push(`runtime role has memberships: ${sorted(posture.memberships).join(", ")}`);
|
|
1562
|
+
}
|
|
1563
|
+
if (posture.ownedSchemas.length > 0) {
|
|
1564
|
+
violations.push(`runtime role owns schemas: ${sorted(posture.ownedSchemas).join(", ")}`);
|
|
1565
|
+
}
|
|
1566
|
+
if (posture.ownedRelations.length > 0) {
|
|
1567
|
+
violations.push(`runtime role owns relations: ${sorted(posture.ownedRelations).join(", ")}`);
|
|
1568
|
+
}
|
|
1569
|
+
for (const schemaName of /* @__PURE__ */ new Set([targetSchema, "opengeni_private"])) {
|
|
1570
|
+
const schema = posture.schemas.find((candidate) => candidate.name === schemaName);
|
|
1571
|
+
if (!schema) {
|
|
1572
|
+
violations.push(`required schema ${schemaName} is missing`);
|
|
1573
|
+
continue;
|
|
1574
|
+
}
|
|
1575
|
+
if (schema.owner === expectedRole) {
|
|
1576
|
+
violations.push(`runtime role owns schema ${schemaName}`);
|
|
1577
|
+
}
|
|
1578
|
+
if (!schema.usage) violations.push(`runtime role lacks USAGE on schema ${schemaName}`);
|
|
1579
|
+
if (schema.create) violations.push(`runtime role has CREATE on schema ${schemaName}`);
|
|
1580
|
+
}
|
|
1581
|
+
const tableByName = new Map(posture.tables.map((table) => [table.name, table]));
|
|
1582
|
+
const actualRlsTables = new Set(
|
|
1583
|
+
posture.tables.filter((table) => table.rlsEnabled).map((table) => table.name)
|
|
1584
|
+
);
|
|
1585
|
+
const classifiedProtectedTables = /* @__PURE__ */ new Set([
|
|
1586
|
+
...directRuntimeTables,
|
|
1587
|
+
...protectedNoDirectDmlTables
|
|
1588
|
+
]);
|
|
1589
|
+
const unclassifiedProtectedTables = difference(protectedTables, classifiedProtectedTables);
|
|
1590
|
+
if (unclassifiedProtectedTables.length > 0) {
|
|
1591
|
+
violations.push(
|
|
1592
|
+
`protected tables lack an explicit privilege class: ${unclassifiedProtectedTables.join(", ")}`
|
|
1593
|
+
);
|
|
1594
|
+
}
|
|
1595
|
+
const protectedNoDirectDmlOverlap = difference(
|
|
1596
|
+
protectedNoDirectDmlTables,
|
|
1597
|
+
new Set([...protectedNoDirectDmlTables].filter((table) => !directRuntimeTables.has(table)))
|
|
1598
|
+
);
|
|
1599
|
+
if (protectedNoDirectDmlOverlap.length > 0) {
|
|
1600
|
+
violations.push(
|
|
1601
|
+
`protected no-direct-DML tables also declare runtime privileges: ${protectedNoDirectDmlOverlap.join(", ")}`
|
|
1602
|
+
);
|
|
1603
|
+
}
|
|
1604
|
+
const nonProtectedNoDirectDmlTables = difference(protectedNoDirectDmlTables, protectedTables);
|
|
1605
|
+
if (nonProtectedNoDirectDmlTables.length > 0) {
|
|
1606
|
+
violations.push(
|
|
1607
|
+
`no-direct-DML tables are absent from the protected contract: ${nonProtectedNoDirectDmlTables.join(", ")}`
|
|
1608
|
+
);
|
|
1609
|
+
}
|
|
1610
|
+
const catalogTables = new Set(tableByName.keys());
|
|
1611
|
+
const missingRuntimeTables = difference(directRuntimeTables, catalogTables);
|
|
1612
|
+
if (missingRuntimeTables.length > 0) {
|
|
1613
|
+
violations.push(`runtime privilege tables are missing: ${missingRuntimeTables.join(", ")}`);
|
|
1614
|
+
}
|
|
1615
|
+
const missingTables = difference(protectedTables, catalogTables);
|
|
1616
|
+
if (missingTables.length > 0) {
|
|
1617
|
+
violations.push(`protected tables are missing: ${missingTables.join(", ")}`);
|
|
1618
|
+
}
|
|
1619
|
+
const undeclaredRlsTables = difference(actualRlsTables, protectedTables);
|
|
1620
|
+
if (undeclaredRlsTables.length > 0) {
|
|
1621
|
+
violations.push(
|
|
1622
|
+
`RLS tables are absent from the declared contract: ${undeclaredRlsTables.join(", ")}`
|
|
1623
|
+
);
|
|
1624
|
+
}
|
|
1625
|
+
for (const table of posture.tables) {
|
|
1626
|
+
const privileges = [
|
|
1627
|
+
["SELECT", table.select],
|
|
1628
|
+
["INSERT", table.insert],
|
|
1629
|
+
["UPDATE", table.update],
|
|
1630
|
+
["DELETE", table.delete],
|
|
1631
|
+
["TRUNCATE", table.truncate],
|
|
1632
|
+
["REFERENCES", table.references],
|
|
1633
|
+
["TRIGGER", table.trigger]
|
|
1634
|
+
];
|
|
1635
|
+
const expectedPrivileges = new Set(tablePrivileges[table.name] ?? []);
|
|
1636
|
+
if (table.owner === expectedRole) {
|
|
1637
|
+
violations.push(`runtime role owns table ${table.name}`);
|
|
1638
|
+
}
|
|
1639
|
+
const missingPrivileges = privileges.filter(([privilege, granted]) => expectedPrivileges.has(privilege) && !granted).map(([privilege]) => privilege);
|
|
1640
|
+
if (missingPrivileges.length > 0) {
|
|
1641
|
+
violations.push(
|
|
1642
|
+
`table ${table.name} lacks required runtime privileges: ${missingPrivileges.join(", ")}`
|
|
1643
|
+
);
|
|
1644
|
+
}
|
|
1645
|
+
const excessPrivileges = privileges.filter(([privilege, granted]) => !expectedPrivileges.has(privilege) && granted).map(([privilege]) => privilege);
|
|
1646
|
+
if (excessPrivileges.length > 0) {
|
|
1647
|
+
violations.push(
|
|
1648
|
+
`table ${table.name} grants excess runtime privileges: ${excessPrivileges.join(", ")}`
|
|
1649
|
+
);
|
|
1650
|
+
}
|
|
1651
|
+
}
|
|
1652
|
+
for (const tableName of protectedTables) {
|
|
1653
|
+
const table = tableByName.get(tableName);
|
|
1654
|
+
if (!table) continue;
|
|
1655
|
+
if (!table.rlsEnabled) violations.push(`table ${tableName} does not ENABLE RLS`);
|
|
1656
|
+
if (!table.rlsForced) violations.push(`table ${tableName} does not FORCE RLS`);
|
|
1657
|
+
if (!table.rlsActive) violations.push(`table ${tableName} has inactive RLS for runtime role`);
|
|
1658
|
+
if (table.policyCount < 1) violations.push(`table ${tableName} has no RLS policy`);
|
|
1659
|
+
}
|
|
1660
|
+
const targetSchemaOwner = posture.schemas.find((schema) => schema.name === targetSchema)?.owner;
|
|
1661
|
+
for (const forbiddenRoutine of RUNTIME_TARGET_SCHEMA_FORBIDDEN_ROUTINES) {
|
|
1662
|
+
const matches = posture.targetRoutines.filter((routine2) => routine2.name === forbiddenRoutine);
|
|
1663
|
+
if (matches.length !== 1) {
|
|
1664
|
+
violations.push(
|
|
1665
|
+
`owner-internal target-schema helper ${forbiddenRoutine} is missing or ambiguous`
|
|
1666
|
+
);
|
|
1667
|
+
continue;
|
|
1668
|
+
}
|
|
1669
|
+
const routine = matches[0];
|
|
1670
|
+
if (!routine.securityDefiner) {
|
|
1671
|
+
violations.push(
|
|
1672
|
+
`owner-internal target-schema helper ${routine.name} is not SECURITY DEFINER`
|
|
1673
|
+
);
|
|
1674
|
+
}
|
|
1675
|
+
const authorityOwner = tableByName.get("sessions")?.owner ?? targetSchemaOwner;
|
|
1676
|
+
if (authorityOwner && routine.owner !== authorityOwner) {
|
|
1677
|
+
violations.push(
|
|
1678
|
+
`owner-internal target-schema helper ${routine.name} owner ${routine.owner} does not match session authority owner ${authorityOwner}`
|
|
1679
|
+
);
|
|
1680
|
+
}
|
|
1681
|
+
if (routine.execute) {
|
|
1682
|
+
violations.push(`runtime role has forbidden owner-internal helper ${routine.name}`);
|
|
1683
|
+
}
|
|
1684
|
+
if (routine.publicExecute) {
|
|
1685
|
+
violations.push(`PUBLIC has forbidden owner-internal helper ${routine.name}`);
|
|
1686
|
+
}
|
|
1687
|
+
}
|
|
1688
|
+
for (const expectedRoutine of RUNTIME_TARGET_SCHEMA_CAPABILITY_ROUTINES) {
|
|
1689
|
+
const matches = posture.targetRoutines.filter((routine2) => routine2.name === expectedRoutine);
|
|
1690
|
+
if (matches.length !== 1) {
|
|
1691
|
+
violations.push(
|
|
1692
|
+
`target-schema runtime capability ${expectedRoutine} is missing or ambiguous`
|
|
1693
|
+
);
|
|
1694
|
+
continue;
|
|
1695
|
+
}
|
|
1696
|
+
const routine = matches[0];
|
|
1697
|
+
if (RUNTIME_TARGET_SCHEMA_INVOKER_ROUTINE_SET.has(routine.name)) {
|
|
1698
|
+
if (routine.securityDefiner) {
|
|
1699
|
+
violations.push(
|
|
1700
|
+
`target-schema runtime capability ${routine.name} must be SECURITY INVOKER`
|
|
1701
|
+
);
|
|
1702
|
+
}
|
|
1703
|
+
} else if (!routine.securityDefiner) {
|
|
1704
|
+
violations.push(`target-schema runtime capability ${routine.name} is not SECURITY DEFINER`);
|
|
1705
|
+
}
|
|
1706
|
+
if (routine.name === GOOGLE_DRIVE_FILE_AUTHORIZATION_ROUTINE || routine.name === GOOGLE_DRIVE_DOCUMENT_CITATION_ROUTINE) {
|
|
1707
|
+
const missingAuthorityTables = GOOGLE_DRIVE_AUTHORITY_TABLES.filter(
|
|
1708
|
+
(tableName) => !tableByName.has(tableName)
|
|
1709
|
+
);
|
|
1710
|
+
if (missingAuthorityTables.length > 0) {
|
|
1711
|
+
violations.push(
|
|
1712
|
+
`target-schema runtime capability ${routine.name} authority tables are missing: ${missingAuthorityTables.join(", ")}`
|
|
1713
|
+
);
|
|
1714
|
+
} else {
|
|
1715
|
+
const authorityTables = GOOGLE_DRIVE_AUTHORITY_TABLES.map(
|
|
1716
|
+
(tableName) => tableByName.get(tableName)
|
|
1717
|
+
);
|
|
1718
|
+
const authorityOwners = new Set(authorityTables.map((table) => table.owner));
|
|
1719
|
+
if (authorityOwners.size !== 1) {
|
|
1720
|
+
violations.push(
|
|
1721
|
+
`target-schema runtime capability ${routine.name} authority table owners do not match: ${authorityTables.map((table) => `${table.name}=${table.owner}`).join(", ")}`
|
|
1722
|
+
);
|
|
1723
|
+
} else if (routine.owner !== authorityTables[0].owner) {
|
|
1724
|
+
violations.push(
|
|
1725
|
+
`target-schema runtime capability ${routine.name} owner ${routine.owner} does not match authority table owner ${authorityTables[0].owner}`
|
|
1726
|
+
);
|
|
1727
|
+
}
|
|
1728
|
+
}
|
|
1729
|
+
} else if (routine.name === KNOWLEDGE_SOURCE_SYNC_LOCK_AUTHORITY_ROUTINE) {
|
|
1730
|
+
const missingAuthorityTables = KNOWLEDGE_SOURCE_SYNC_LOCK_AUTHORITY_TABLES.filter(
|
|
1731
|
+
(tableName) => !tableByName.has(tableName)
|
|
1732
|
+
);
|
|
1733
|
+
if (missingAuthorityTables.length > 0) {
|
|
1734
|
+
violations.push(
|
|
1735
|
+
`target-schema runtime capability ${routine.name} authority tables are missing: ${missingAuthorityTables.join(", ")}`
|
|
1736
|
+
);
|
|
1737
|
+
} else {
|
|
1738
|
+
const authorityTables = KNOWLEDGE_SOURCE_SYNC_LOCK_AUTHORITY_TABLES.map(
|
|
1739
|
+
(tableName) => tableByName.get(tableName)
|
|
1740
|
+
);
|
|
1741
|
+
const authorityOwners = new Set(authorityTables.map((table) => table.owner));
|
|
1742
|
+
if (authorityOwners.size !== 1) {
|
|
1743
|
+
violations.push(
|
|
1744
|
+
`target-schema runtime capability ${routine.name} authority table owners do not match: ${authorityTables.map((table) => `${table.name}=${table.owner}`).join(", ")}`
|
|
1745
|
+
);
|
|
1746
|
+
} else if (routine.owner !== authorityTables[0].owner) {
|
|
1747
|
+
violations.push(
|
|
1748
|
+
`target-schema runtime capability ${routine.name} owner ${routine.owner} does not match authority table owner ${authorityTables[0].owner}`
|
|
1749
|
+
);
|
|
1750
|
+
}
|
|
1751
|
+
}
|
|
1752
|
+
} else if (routine.name === MANAGED_HUMAN_PERSONAL_WORKSPACE_ROUTINE) {
|
|
1753
|
+
const authorityTables = MANAGED_HUMAN_PERSONAL_WORKSPACE_AUTHORITY_TABLES.filter(
|
|
1754
|
+
(tableName) => tableByName.has(tableName)
|
|
1755
|
+
).map((tableName) => tableByName.get(tableName));
|
|
1756
|
+
const authorityOwners = new Set(authorityTables.map((table) => table.owner));
|
|
1757
|
+
if (authorityOwners.size > 1) {
|
|
1758
|
+
violations.push(
|
|
1759
|
+
`target-schema runtime capability ${routine.name} authority table owners do not match: ${authorityTables.map((table) => `${table.name}=${table.owner}`).join(", ")}`
|
|
1760
|
+
);
|
|
1761
|
+
} else if (authorityTables[0] && routine.owner !== authorityTables[0].owner) {
|
|
1762
|
+
violations.push(
|
|
1763
|
+
`target-schema runtime capability ${routine.name} owner ${routine.owner} does not match authority table owner ${authorityTables[0].owner}`
|
|
1764
|
+
);
|
|
1765
|
+
}
|
|
1766
|
+
} else if (routine.name === GOVERNED_LEARNING_EVALUATION_ROUTINE) {
|
|
1767
|
+
if (!tableByName.has("governed_learning_decision_receipts")) {
|
|
1768
|
+
continue;
|
|
1769
|
+
}
|
|
1770
|
+
const missingAuthorityTables = GOVERNED_LEARNING_EVALUATION_AUTHORITY_TABLES.filter(
|
|
1771
|
+
(tableName) => !tableByName.has(tableName)
|
|
1772
|
+
);
|
|
1773
|
+
if (missingAuthorityTables.length > 0) {
|
|
1774
|
+
violations.push(
|
|
1775
|
+
`target-schema runtime capability ${routine.name} authority tables are missing: ${missingAuthorityTables.join(", ")}`
|
|
1776
|
+
);
|
|
1777
|
+
} else {
|
|
1778
|
+
const authorityTables = GOVERNED_LEARNING_EVALUATION_AUTHORITY_TABLES.map(
|
|
1779
|
+
(tableName) => tableByName.get(tableName)
|
|
1780
|
+
);
|
|
1781
|
+
const authorityOwners = new Set(authorityTables.map((table) => table.owner));
|
|
1782
|
+
if (authorityOwners.size !== 1) {
|
|
1783
|
+
violations.push(
|
|
1784
|
+
`target-schema runtime capability ${routine.name} authority table owners do not match: ${authorityTables.map((table) => `${table.name}=${table.owner}`).join(", ")}`
|
|
1785
|
+
);
|
|
1786
|
+
} else if (routine.owner !== authorityTables[0].owner) {
|
|
1787
|
+
violations.push(
|
|
1788
|
+
`target-schema runtime capability ${routine.name} owner ${routine.owner} does not match authority table owner ${authorityTables[0].owner}`
|
|
1789
|
+
);
|
|
1790
|
+
}
|
|
1791
|
+
}
|
|
1792
|
+
} else if (GOVERNED_LEARNING_INSPECTION_ROUTINES.includes(
|
|
1793
|
+
routine.name
|
|
1794
|
+
)) {
|
|
1795
|
+
if (!tableByName.has("governed_learning_decision_receipts")) continue;
|
|
1796
|
+
const missingAuthorityTables = GOVERNED_LEARNING_INSPECTION_AUTHORITY_TABLES.filter(
|
|
1797
|
+
(name) => !tableByName.has(name)
|
|
1798
|
+
);
|
|
1799
|
+
if (missingAuthorityTables.length > 0) {
|
|
1800
|
+
violations.push(
|
|
1801
|
+
`target-schema runtime capability ${routine.name} authority tables are missing: ${missingAuthorityTables.join(", ")}`
|
|
1802
|
+
);
|
|
1803
|
+
} else {
|
|
1804
|
+
const authorityTables = GOVERNED_LEARNING_INSPECTION_AUTHORITY_TABLES.map(
|
|
1805
|
+
(name) => tableByName.get(name)
|
|
1806
|
+
);
|
|
1807
|
+
const authorityOwners = new Set(authorityTables.map((table) => table.owner));
|
|
1808
|
+
if (authorityOwners.size !== 1 || routine.owner !== authorityTables[0].owner) {
|
|
1809
|
+
violations.push(
|
|
1810
|
+
`target-schema runtime capability ${routine.name} owner does not match governed-learning inspection authority`
|
|
1811
|
+
);
|
|
1812
|
+
}
|
|
1813
|
+
}
|
|
1814
|
+
} else if (GOVERNED_LEARNING_ACTIVATION_ROUTINES.includes(
|
|
1815
|
+
routine.name
|
|
1816
|
+
)) {
|
|
1817
|
+
if (!tableByName.has("governed_learning_activation_receipts")) {
|
|
1818
|
+
continue;
|
|
1819
|
+
}
|
|
1820
|
+
const missingAuthorityTables = GOVERNED_LEARNING_ACTIVATION_AUTHORITY_TABLES.filter(
|
|
1821
|
+
(tableName) => !tableByName.has(tableName)
|
|
1822
|
+
);
|
|
1823
|
+
if (missingAuthorityTables.length > 0) {
|
|
1824
|
+
violations.push(
|
|
1825
|
+
`target-schema runtime capability ${routine.name} authority tables are missing: ${missingAuthorityTables.join(", ")}`
|
|
1826
|
+
);
|
|
1827
|
+
} else {
|
|
1828
|
+
const authorityTables = GOVERNED_LEARNING_ACTIVATION_AUTHORITY_TABLES.map(
|
|
1829
|
+
(tableName) => tableByName.get(tableName)
|
|
1830
|
+
);
|
|
1831
|
+
const authorityOwners = new Set(authorityTables.map((table) => table.owner));
|
|
1832
|
+
if (authorityOwners.size !== 1) {
|
|
1833
|
+
violations.push(
|
|
1834
|
+
`target-schema runtime capability ${routine.name} authority table owners do not match: ${authorityTables.map((table) => `${table.name}=${table.owner}`).join(", ")}`
|
|
1835
|
+
);
|
|
1836
|
+
} else if (routine.owner !== authorityTables[0].owner) {
|
|
1837
|
+
violations.push(
|
|
1838
|
+
`target-schema runtime capability ${routine.name} owner ${routine.owner} does not match authority table owner ${authorityTables[0].owner}`
|
|
1839
|
+
);
|
|
1840
|
+
}
|
|
1841
|
+
}
|
|
1842
|
+
} else if (COMPANY_PROFILE_AGENT_ADMIN_ROUTINES.includes(
|
|
1843
|
+
routine.name
|
|
1844
|
+
)) {
|
|
1845
|
+
const missingAuthorityTables = COMPANY_PROFILE_AGENT_ADMIN_AUTHORITY_TABLES.filter(
|
|
1846
|
+
(tableName) => !tableByName.has(tableName)
|
|
1847
|
+
);
|
|
1848
|
+
if (missingAuthorityTables.length > 0) {
|
|
1849
|
+
violations.push(
|
|
1850
|
+
`target-schema runtime capability ${routine.name} authority tables are missing: ${missingAuthorityTables.join(", ")}`
|
|
1851
|
+
);
|
|
1852
|
+
} else {
|
|
1853
|
+
const authorityTables = COMPANY_PROFILE_AGENT_ADMIN_AUTHORITY_TABLES.map(
|
|
1854
|
+
(tableName) => tableByName.get(tableName)
|
|
1855
|
+
);
|
|
1856
|
+
const authorityOwners = new Set(authorityTables.map((table) => table.owner));
|
|
1857
|
+
if (authorityOwners.size !== 1) {
|
|
1858
|
+
violations.push(
|
|
1859
|
+
`target-schema runtime capability ${routine.name} authority table owners do not match: ${authorityTables.map((table) => `${table.name}=${table.owner}`).join(", ")}`
|
|
1860
|
+
);
|
|
1861
|
+
} else if (routine.owner !== authorityTables[0].owner) {
|
|
1862
|
+
violations.push(
|
|
1863
|
+
`target-schema runtime capability ${routine.name} owner ${routine.owner} does not match authority table owner ${authorityTables[0].owner}`
|
|
1864
|
+
);
|
|
1865
|
+
}
|
|
1866
|
+
}
|
|
1867
|
+
} else if (ORGANIZATION_MEMBERSHIP_LIFECYCLE_ROUTINES.includes(routine.name)) {
|
|
1868
|
+
const missingAuthorityTables = ORGANIZATION_MEMBERSHIP_LIFECYCLE_AUTHORITY_TABLES.filter(
|
|
1869
|
+
(tableName) => !tableByName.has(tableName)
|
|
1870
|
+
);
|
|
1871
|
+
if (missingAuthorityTables.length > 0) {
|
|
1872
|
+
violations.push(
|
|
1873
|
+
`target-schema runtime capability ${routine.name} authority tables are missing: ${missingAuthorityTables.join(", ")}`
|
|
1874
|
+
);
|
|
1875
|
+
} else {
|
|
1876
|
+
const authorityTables = ORGANIZATION_MEMBERSHIP_LIFECYCLE_AUTHORITY_TABLES.map(
|
|
1877
|
+
(tableName) => tableByName.get(tableName)
|
|
1878
|
+
);
|
|
1879
|
+
const authorityOwners = new Set(authorityTables.map((table) => table.owner));
|
|
1880
|
+
if (authorityOwners.size !== 1) {
|
|
1881
|
+
violations.push(
|
|
1882
|
+
`target-schema runtime capability ${routine.name} authority table owners do not match: ${authorityTables.map((table) => `${table.name}=${table.owner}`).join(", ")}`
|
|
1883
|
+
);
|
|
1884
|
+
} else if (routine.owner !== authorityTables[0].owner) {
|
|
1885
|
+
violations.push(
|
|
1886
|
+
`target-schema runtime capability ${routine.name} owner ${routine.owner} does not match authority table owner ${authorityTables[0].owner}`
|
|
1887
|
+
);
|
|
1888
|
+
}
|
|
1889
|
+
}
|
|
1890
|
+
} else if (ORGANIZATION_PRIVATE_SESSION_ROUTINES.includes(routine.name)) {
|
|
1891
|
+
if (!tableByName.has("organization_private_session_settings")) {
|
|
1892
|
+
continue;
|
|
1893
|
+
}
|
|
1894
|
+
const authorityTableNames = ORGANIZATION_PRIVATE_SESSION_ROUTINE_AUTHORITY_TABLES[routine.name];
|
|
1895
|
+
const missingAuthorityTables = authorityTableNames.filter(
|
|
1896
|
+
(tableName) => !tableByName.has(tableName)
|
|
1897
|
+
);
|
|
1898
|
+
if (missingAuthorityTables.length > 0) {
|
|
1899
|
+
violations.push(
|
|
1900
|
+
`target-schema runtime capability ${routine.name} authority tables are missing: ${missingAuthorityTables.join(", ")}`
|
|
1901
|
+
);
|
|
1902
|
+
} else {
|
|
1903
|
+
const authorityTables = authorityTableNames.map((tableName) => tableByName.get(tableName));
|
|
1904
|
+
const authorityOwners = new Set(authorityTables.map((table) => table.owner));
|
|
1905
|
+
if (authorityOwners.size !== 1) {
|
|
1906
|
+
violations.push(
|
|
1907
|
+
`target-schema runtime capability ${routine.name} authority table owners do not match: ${authorityTables.map((table) => `${table.name}=${table.owner}`).join(", ")}`
|
|
1908
|
+
);
|
|
1909
|
+
} else if (routine.owner !== authorityTables[0].owner) {
|
|
1910
|
+
violations.push(
|
|
1911
|
+
`target-schema runtime capability ${routine.name} owner ${routine.owner} does not match authority table owner ${authorityTables[0].owner}`
|
|
1912
|
+
);
|
|
1913
|
+
}
|
|
1914
|
+
}
|
|
1915
|
+
} else if (routine.name === PREFERENCE_KNOWLEDGE_PROPOSAL_ROUTINE) {
|
|
1916
|
+
if (!tableByName.has("company_brain_preference_proposal_receipts")) {
|
|
1917
|
+
continue;
|
|
1918
|
+
}
|
|
1919
|
+
const missingAuthorityTables = PREFERENCE_KNOWLEDGE_PROPOSAL_AUTHORITY_TABLES.filter(
|
|
1920
|
+
(tableName) => !tableByName.has(tableName)
|
|
1921
|
+
);
|
|
1922
|
+
if (missingAuthorityTables.length > 0) {
|
|
1923
|
+
violations.push(
|
|
1924
|
+
`target-schema runtime capability ${routine.name} authority tables are missing: ${missingAuthorityTables.join(", ")}`
|
|
1925
|
+
);
|
|
1926
|
+
} else {
|
|
1927
|
+
const authorityTables = PREFERENCE_KNOWLEDGE_PROPOSAL_AUTHORITY_TABLES.map(
|
|
1928
|
+
(tableName) => tableByName.get(tableName)
|
|
1929
|
+
);
|
|
1930
|
+
const authorityOwners = new Set(authorityTables.map((table) => table.owner));
|
|
1931
|
+
if (authorityOwners.size !== 1) {
|
|
1932
|
+
violations.push(
|
|
1933
|
+
`target-schema runtime capability ${routine.name} authority table owners do not match: ${authorityTables.map((table) => `${table.name}=${table.owner}`).join(", ")}`
|
|
1934
|
+
);
|
|
1935
|
+
} else if (routine.owner !== authorityTables[0].owner) {
|
|
1936
|
+
violations.push(
|
|
1937
|
+
`target-schema runtime capability ${routine.name} owner ${routine.owner} does not match authority table owner ${authorityTables[0].owner}`
|
|
1938
|
+
);
|
|
1939
|
+
}
|
|
1940
|
+
}
|
|
1941
|
+
} else if (CANONICAL_HUMAN_IDENTITY_ROUTINES.includes(routine.name)) {
|
|
1942
|
+
const authorityTables = CANONICAL_HUMAN_IDENTITY_AUTHORITY_TABLES.filter(
|
|
1943
|
+
(tableName) => tableByName.has(tableName)
|
|
1944
|
+
).map((tableName) => tableByName.get(tableName));
|
|
1945
|
+
const authorityOwners = new Set(authorityTables.map((table) => table.owner));
|
|
1946
|
+
if (authorityTables.length !== CANONICAL_HUMAN_IDENTITY_AUTHORITY_TABLES.length) {
|
|
1947
|
+
violations.push(
|
|
1948
|
+
`target-schema runtime capability ${routine.name} canonical identity authority tables are missing`
|
|
1949
|
+
);
|
|
1950
|
+
} else if (authorityOwners.size !== 1) {
|
|
1951
|
+
violations.push(
|
|
1952
|
+
`target-schema runtime capability ${routine.name} authority table owners do not match: ${authorityTables.map((table) => `${table.name}=${table.owner}`).join(", ")}`
|
|
1953
|
+
);
|
|
1954
|
+
} else if (routine.owner !== authorityTables[0].owner) {
|
|
1955
|
+
violations.push(
|
|
1956
|
+
`target-schema runtime capability ${routine.name} owner ${routine.owner} does not match authority table owner ${authorityTables[0].owner}`
|
|
1957
|
+
);
|
|
1958
|
+
}
|
|
1959
|
+
} else if (PERSONAL_GITHUB_REPOSITORY_AUTHORITY_ROUTINES.includes(routine.name)) {
|
|
1960
|
+
const authorityTables = PERSONAL_GITHUB_REPOSITORY_AUTHORITY_TABLES.map(
|
|
1961
|
+
(tableName) => tableByName.get(tableName)
|
|
1962
|
+
).filter((table) => table !== void 0);
|
|
1963
|
+
const authorityOwners = new Set(authorityTables.map((table) => table.owner));
|
|
1964
|
+
if (authorityOwners.size > 1) {
|
|
1965
|
+
violations.push(
|
|
1966
|
+
`target-schema runtime capability ${routine.name} personal GitHub repository authority table owners do not match`
|
|
1967
|
+
);
|
|
1968
|
+
} else {
|
|
1969
|
+
const authorityOwner = authorityTables[0]?.owner ?? targetSchemaOwner;
|
|
1970
|
+
if (authorityOwner && routine.owner !== authorityOwner) {
|
|
1971
|
+
violations.push(
|
|
1972
|
+
`target-schema runtime capability ${routine.name} owner ${routine.owner} does not match personal GitHub repository authority owner ${authorityOwner}`
|
|
1973
|
+
);
|
|
1974
|
+
}
|
|
1975
|
+
}
|
|
1976
|
+
} else if (PERSONAL_DOCUMENT_AUTHORITY_ROUTINES.includes(routine.name) || DOCUMENT_MIGRATION_AUTHORITY_ROUTINES.includes(routine.name)) {
|
|
1977
|
+
const authorityOwner = tableByName.get("documents")?.owner ?? targetSchemaOwner;
|
|
1978
|
+
if (authorityOwner && routine.owner !== authorityOwner) {
|
|
1979
|
+
violations.push(
|
|
1980
|
+
`target-schema runtime capability ${routine.name} owner ${routine.owner} does not match document authority owner ${authorityOwner}`
|
|
1981
|
+
);
|
|
1982
|
+
}
|
|
1983
|
+
} else if (VARIABLE_SET_AUTHORITY_ROUTINES.includes(routine.name)) {
|
|
1984
|
+
const authorityTables = ["workspace_variable_sets", "workspace_variable_set_variables"].map((tableName) => tableByName.get(tableName)).filter((table) => table !== void 0);
|
|
1985
|
+
const authorityOwners = new Set(authorityTables.map((table) => table.owner));
|
|
1986
|
+
if (authorityOwners.size > 1) {
|
|
1987
|
+
violations.push(
|
|
1988
|
+
`target-schema runtime capability ${routine.name} variable-set table owners do not match`
|
|
1989
|
+
);
|
|
1990
|
+
} else {
|
|
1991
|
+
const authorityOwner = authorityTables[0]?.owner ?? targetSchemaOwner;
|
|
1992
|
+
if (authorityOwner && routine.owner !== authorityOwner) {
|
|
1993
|
+
violations.push(
|
|
1994
|
+
`target-schema runtime capability ${routine.name} owner ${routine.owner} does not match variable-set authority owner ${authorityOwner}`
|
|
1995
|
+
);
|
|
1996
|
+
}
|
|
1997
|
+
}
|
|
1998
|
+
} else if (SCOPED_COMPUTE_AUTHORITY_ROUTINES.includes(routine.name)) {
|
|
1999
|
+
const authorityTables = ["rigs", "rig_versions", "enrollments", "sandboxes"].map((tableName) => tableByName.get(tableName)).filter((table) => table !== void 0);
|
|
2000
|
+
const authorityOwners = new Set(authorityTables.map((table) => table.owner));
|
|
2001
|
+
if (authorityOwners.size > 1) {
|
|
2002
|
+
violations.push(
|
|
2003
|
+
`target-schema runtime capability ${routine.name} scoped-compute table owners do not match`
|
|
2004
|
+
);
|
|
2005
|
+
} else {
|
|
2006
|
+
const authorityOwner = authorityTables[0]?.owner ?? targetSchemaOwner;
|
|
2007
|
+
if (authorityOwner && routine.owner !== authorityOwner) {
|
|
2008
|
+
violations.push(
|
|
2009
|
+
`target-schema runtime capability ${routine.name} owner ${routine.owner} does not match scoped-compute authority owner ${authorityOwner}`
|
|
2010
|
+
);
|
|
2011
|
+
}
|
|
2012
|
+
}
|
|
2013
|
+
} else if (SESSION_AUTHORITY_ROUTINES.has(routine.name)) {
|
|
2014
|
+
const authorityOwner = tableByName.get("sessions")?.owner ?? targetSchemaOwner;
|
|
2015
|
+
if (authorityOwner && routine.owner !== authorityOwner) {
|
|
2016
|
+
violations.push(
|
|
2017
|
+
`target-schema runtime capability ${routine.name} owner ${routine.owner} does not match session authority owner ${authorityOwner}`
|
|
2018
|
+
);
|
|
2019
|
+
}
|
|
2020
|
+
} else if (routine.name === XAI_SNAPSHOT_VALIDATOR_ROUTINE) {
|
|
2021
|
+
} else if (routine.name === XAI_CREATE_CREDENTIAL_ROUTINE || routine.name === XAI_DISCONNECT_CREDENTIAL_ROUTINE || routine.name === XAI_AUTHORITY_LIVE_ROUTINE || routine.name === XAI_POOL_VISIBLE_ROUTINE || routine.name === XAI_RESOLVE_POOL_ROUTINE || routine.name === XAI_REVALIDATE_CREDENTIAL_ROUTINE) {
|
|
2022
|
+
if (!tableByName.has("xai_subscription_credentials")) {
|
|
2023
|
+
continue;
|
|
2024
|
+
}
|
|
2025
|
+
const missingAuthorityTables = XAI_AUTHORITY_TABLES.filter(
|
|
2026
|
+
(tableName) => !tableByName.has(tableName)
|
|
2027
|
+
);
|
|
2028
|
+
if (missingAuthorityTables.length > 0) {
|
|
2029
|
+
violations.push(
|
|
2030
|
+
`target-schema runtime capability ${routine.name} authority tables are missing: ${missingAuthorityTables.join(", ")}`
|
|
2031
|
+
);
|
|
2032
|
+
} else {
|
|
2033
|
+
const authorityTables = XAI_AUTHORITY_TABLES.map(
|
|
2034
|
+
(tableName) => tableByName.get(tableName)
|
|
2035
|
+
);
|
|
2036
|
+
const authorityOwners = new Set(authorityTables.map((table) => table.owner));
|
|
2037
|
+
if (authorityOwners.size !== 1) {
|
|
2038
|
+
violations.push(
|
|
2039
|
+
`target-schema runtime capability ${routine.name} authority table owners do not match: ${authorityTables.map((table) => `${table.name}=${table.owner}`).join(", ")}`
|
|
2040
|
+
);
|
|
2041
|
+
} else if (routine.owner !== authorityTables[0].owner) {
|
|
2042
|
+
violations.push(
|
|
2043
|
+
`target-schema runtime capability ${routine.name} owner ${routine.owner} does not match authority table owner ${authorityTables[0].owner}`
|
|
2044
|
+
);
|
|
2045
|
+
}
|
|
2046
|
+
}
|
|
2047
|
+
} else if (targetSchemaOwner && routine.owner !== targetSchemaOwner) {
|
|
2048
|
+
violations.push(
|
|
2049
|
+
`target-schema runtime capability ${routine.name} owner ${routine.owner} does not match schema owner ${targetSchemaOwner}`
|
|
2050
|
+
);
|
|
2051
|
+
}
|
|
2052
|
+
if (!routine.execute) {
|
|
2053
|
+
violations.push(`runtime role lacks target-schema capability ${routine.name}`);
|
|
2054
|
+
}
|
|
2055
|
+
const publicPolicyPredicate = RUNTIME_TARGET_SCHEMA_PUBLIC_POLICY_PREDICATE_ROUTINE_SET.has(
|
|
2056
|
+
routine.name
|
|
2057
|
+
);
|
|
2058
|
+
if (publicPolicyPredicate && !routine.publicExecute) {
|
|
2059
|
+
violations.push(`PUBLIC lacks required shared-policy predicate ${routine.name}`);
|
|
2060
|
+
} else if (!publicPolicyPredicate && routine.publicExecute) {
|
|
2061
|
+
violations.push(`PUBLIC has forbidden target-schema capability ${routine.name}`);
|
|
2062
|
+
}
|
|
2063
|
+
}
|
|
2064
|
+
const artifactOutbox = tableByName.get("editable_artifact_live_outbox");
|
|
2065
|
+
if (artifactOutbox) {
|
|
2066
|
+
if (!artifactOutbox.artifactOutboxDispatcherPolicy) {
|
|
2067
|
+
violations.push("table editable_artifact_live_outbox lacks its owner dispatcher RLS policy");
|
|
2068
|
+
}
|
|
2069
|
+
for (const expectedRoutine of ARTIFACT_OUTBOX_CAPABILITY_ROUTINES) {
|
|
2070
|
+
const matches = posture.privateRoutines.filter((routine2) => routine2.name === expectedRoutine);
|
|
2071
|
+
if (matches.length !== 1) {
|
|
2072
|
+
violations.push(`artifact outbox capability ${expectedRoutine} is missing or ambiguous`);
|
|
2073
|
+
continue;
|
|
2074
|
+
}
|
|
2075
|
+
const routine = matches[0];
|
|
2076
|
+
if (!routine.securityDefiner) {
|
|
2077
|
+
violations.push(`artifact outbox capability ${routine.name} is not SECURITY DEFINER`);
|
|
2078
|
+
}
|
|
2079
|
+
if (routine.owner !== artifactOutbox.owner) {
|
|
2080
|
+
violations.push(
|
|
2081
|
+
`artifact outbox capability ${routine.name} owner ${routine.owner} does not match table owner ${artifactOutbox.owner}`
|
|
2082
|
+
);
|
|
2083
|
+
}
|
|
2084
|
+
if (routine.execute) {
|
|
2085
|
+
violations.push(
|
|
2086
|
+
`generic runtime role has forbidden global artifact outbox capability ${routine.name}`
|
|
2087
|
+
);
|
|
2088
|
+
}
|
|
2089
|
+
}
|
|
2090
|
+
}
|
|
2091
|
+
const artifactMaterializationJobs = tableByName.get("editable_artifact_materialization_jobs");
|
|
2092
|
+
if (artifactMaterializationJobs) {
|
|
2093
|
+
for (const tableName of [
|
|
2094
|
+
"editable_artifact_materialization_jobs",
|
|
2095
|
+
"editable_artifact_materialization_results",
|
|
2096
|
+
"editable_artifact_blob_refs",
|
|
2097
|
+
"editable_artifact_sequence_checkpoints",
|
|
2098
|
+
"editable_artifact_versions",
|
|
2099
|
+
"editable_artifact_idempotency_receipts"
|
|
2100
|
+
]) {
|
|
2101
|
+
const table = tableByName.get(tableName);
|
|
2102
|
+
if (table && !table.artifactMaterializerPolicy) {
|
|
2103
|
+
violations.push(`table ${tableName} lacks its owner materializer RLS policy`);
|
|
2104
|
+
}
|
|
2105
|
+
}
|
|
2106
|
+
for (const expectedRoutine of ARTIFACT_MATERIALIZER_CAPABILITY_ROUTINES) {
|
|
2107
|
+
const matches = posture.privateRoutines.filter((routine2) => routine2.name === expectedRoutine);
|
|
2108
|
+
if (matches.length !== 1) {
|
|
2109
|
+
violations.push(
|
|
2110
|
+
`artifact materializer capability ${expectedRoutine} is missing or ambiguous`
|
|
2111
|
+
);
|
|
2112
|
+
continue;
|
|
2113
|
+
}
|
|
2114
|
+
const routine = matches[0];
|
|
2115
|
+
if (!routine.securityDefiner) {
|
|
2116
|
+
violations.push(`artifact materializer capability ${routine.name} is not SECURITY DEFINER`);
|
|
2117
|
+
}
|
|
2118
|
+
if (routine.owner !== artifactMaterializationJobs.owner) {
|
|
2119
|
+
violations.push(
|
|
2120
|
+
`artifact materializer capability ${routine.name} owner ${routine.owner} does not match table owner ${artifactMaterializationJobs.owner}`
|
|
2121
|
+
);
|
|
2122
|
+
}
|
|
2123
|
+
if (routine.execute) {
|
|
2124
|
+
violations.push(
|
|
2125
|
+
`generic runtime role has forbidden global artifact materializer capability ${routine.name}`
|
|
2126
|
+
);
|
|
2127
|
+
}
|
|
2128
|
+
}
|
|
2129
|
+
}
|
|
2130
|
+
const artifactAuthority = tableByName.get("editable_artifacts");
|
|
2131
|
+
if (artifactAuthority) {
|
|
2132
|
+
const matches = posture.privateRoutines.filter(
|
|
2133
|
+
(routine) => routine.name.startsWith("advance_editable_artifact_authorization_revision(")
|
|
2134
|
+
);
|
|
2135
|
+
if (matches.length !== 1) {
|
|
2136
|
+
violations.push(
|
|
2137
|
+
"editable artifact authorization revision capability is missing or ambiguous"
|
|
2138
|
+
);
|
|
2139
|
+
} else {
|
|
2140
|
+
const routine = matches[0];
|
|
2141
|
+
if (!routine.securityDefiner) {
|
|
2142
|
+
violations.push(
|
|
2143
|
+
`editable artifact authorization revision capability ${routine.name} is not SECURITY DEFINER`
|
|
2144
|
+
);
|
|
2145
|
+
}
|
|
2146
|
+
if (routine.owner !== artifactAuthority.owner) {
|
|
2147
|
+
violations.push(
|
|
2148
|
+
`editable artifact authorization revision capability ${routine.name} owner ${routine.owner} does not match table owner ${artifactAuthority.owner}`
|
|
2149
|
+
);
|
|
2150
|
+
}
|
|
2151
|
+
}
|
|
2152
|
+
for (const expectedRoutine of ARTIFACT_AUTHORIZATION_CAPABILITY_ROUTINES) {
|
|
2153
|
+
const capabilityMatches = posture.privateRoutines.filter(
|
|
2154
|
+
(routine2) => routine2.name === expectedRoutine
|
|
2155
|
+
);
|
|
2156
|
+
if (capabilityMatches.length !== 1) {
|
|
2157
|
+
violations.push(
|
|
2158
|
+
`editable artifact authorization capability ${expectedRoutine} is missing or ambiguous`
|
|
2159
|
+
);
|
|
2160
|
+
continue;
|
|
2161
|
+
}
|
|
2162
|
+
const routine = capabilityMatches[0];
|
|
2163
|
+
if (!routine.securityDefiner) {
|
|
2164
|
+
violations.push(
|
|
2165
|
+
`editable artifact authorization capability ${routine.name} is not SECURITY DEFINER`
|
|
2166
|
+
);
|
|
2167
|
+
}
|
|
2168
|
+
if (routine.owner !== artifactAuthority.owner) {
|
|
2169
|
+
violations.push(
|
|
2170
|
+
`editable artifact authorization capability ${routine.name} owner ${routine.owner} does not match table owner ${artifactAuthority.owner}`
|
|
2171
|
+
);
|
|
2172
|
+
}
|
|
2173
|
+
if (!routine.execute) {
|
|
2174
|
+
violations.push(
|
|
2175
|
+
`runtime role lacks editable artifact authorization capability ${routine.name}`
|
|
2176
|
+
);
|
|
2177
|
+
}
|
|
2178
|
+
}
|
|
2179
|
+
}
|
|
2180
|
+
const artifactLiveTickets = tableByName.get("editable_artifact_live_tickets");
|
|
2181
|
+
if (artifactLiveTickets) {
|
|
2182
|
+
for (const expectedRoutine of ARTIFACT_LIVE_TICKET_CAPABILITY_ROUTINES) {
|
|
2183
|
+
const matches = posture.privateRoutines.filter((routine2) => routine2.name === expectedRoutine);
|
|
2184
|
+
if (matches.length !== 1) {
|
|
2185
|
+
violations.push(
|
|
2186
|
+
`artifact live ticket capability ${expectedRoutine} is missing or ambiguous`
|
|
2187
|
+
);
|
|
2188
|
+
continue;
|
|
2189
|
+
}
|
|
2190
|
+
const routine = matches[0];
|
|
2191
|
+
if (!routine.securityDefiner) {
|
|
2192
|
+
violations.push(`artifact live ticket capability ${routine.name} is not SECURITY DEFINER`);
|
|
2193
|
+
}
|
|
2194
|
+
if (routine.owner !== artifactLiveTickets.owner) {
|
|
2195
|
+
violations.push(
|
|
2196
|
+
`artifact live ticket capability ${routine.name} owner ${routine.owner} does not match table owner ${artifactLiveTickets.owner}`
|
|
2197
|
+
);
|
|
2198
|
+
}
|
|
2199
|
+
if (!routine.execute) {
|
|
2200
|
+
violations.push(`runtime role lacks artifact live ticket capability ${routine.name}`);
|
|
2201
|
+
}
|
|
2202
|
+
}
|
|
2203
|
+
for (const internalRoutine of ARTIFACT_LIVE_TICKET_INTERNAL_ROUTINES) {
|
|
2204
|
+
const matches = posture.privateRoutines.filter((routine2) => routine2.name === internalRoutine);
|
|
2205
|
+
if (matches.length !== 1) {
|
|
2206
|
+
violations.push(
|
|
2207
|
+
`artifact live ticket internal routine ${internalRoutine} is missing or ambiguous`
|
|
2208
|
+
);
|
|
2209
|
+
continue;
|
|
2210
|
+
}
|
|
2211
|
+
const routine = matches[0];
|
|
2212
|
+
if (!routine.securityDefiner) {
|
|
2213
|
+
violations.push(
|
|
2214
|
+
`artifact live ticket internal routine ${routine.name} is not SECURITY DEFINER`
|
|
2215
|
+
);
|
|
2216
|
+
}
|
|
2217
|
+
if (routine.owner !== artifactLiveTickets.owner) {
|
|
2218
|
+
violations.push(
|
|
2219
|
+
`artifact live ticket internal routine ${routine.name} owner ${routine.owner} does not match table owner ${artifactLiveTickets.owner}`
|
|
2220
|
+
);
|
|
2221
|
+
}
|
|
2222
|
+
if (routine.execute) {
|
|
2223
|
+
violations.push(`runtime role has forbidden ticket schema resolver ${routine.name}`);
|
|
2224
|
+
}
|
|
2225
|
+
}
|
|
2226
|
+
}
|
|
2227
|
+
const personalResourceCapabilityTables = posture.privateTables.filter(
|
|
2228
|
+
(table) => table.name === PERSONAL_RESOURCE_CAPABILITY_TABLE
|
|
2229
|
+
);
|
|
2230
|
+
const personalResourceCapabilityRoutines = posture.privateRoutines.filter(
|
|
2231
|
+
(routine) => routine.name === PERSONAL_RESOURCE_CAPABILITY_PREDICATE_ROUTINE
|
|
2232
|
+
);
|
|
2233
|
+
if (personalResourceCapabilityTables.length !== 1) {
|
|
2234
|
+
violations.push(
|
|
2235
|
+
`personal-resource capability table ${PERSONAL_RESOURCE_CAPABILITY_TABLE} is missing or ambiguous`
|
|
2236
|
+
);
|
|
2237
|
+
}
|
|
2238
|
+
if (personalResourceCapabilityRoutines.length !== 1) {
|
|
2239
|
+
violations.push(
|
|
2240
|
+
`personal-resource capability predicate ${PERSONAL_RESOURCE_CAPABILITY_PREDICATE_ROUTINE} is missing or ambiguous`
|
|
2241
|
+
);
|
|
2242
|
+
}
|
|
2243
|
+
if (personalResourceCapabilityTables.length === 1 && personalResourceCapabilityRoutines.length === 1) {
|
|
2244
|
+
const table = personalResourceCapabilityTables[0];
|
|
2245
|
+
const routine = personalResourceCapabilityRoutines[0];
|
|
2246
|
+
if (routine.owner !== table.owner) {
|
|
2247
|
+
violations.push(
|
|
2248
|
+
`personal-resource capability predicate ${routine.name} owner ${routine.owner} does not match table owner ${table.owner}`
|
|
2249
|
+
);
|
|
2250
|
+
}
|
|
2251
|
+
if (!routine.securityDefiner) {
|
|
2252
|
+
violations.push(
|
|
2253
|
+
`personal-resource capability predicate ${routine.name} is not SECURITY DEFINER`
|
|
2254
|
+
);
|
|
2255
|
+
}
|
|
2256
|
+
if (!routine.execute) {
|
|
2257
|
+
violations.push(`runtime role lacks personal-resource capability predicate ${routine.name}`);
|
|
2258
|
+
}
|
|
2259
|
+
if (routine.publicExecute) {
|
|
2260
|
+
violations.push(
|
|
2261
|
+
`PUBLIC has forbidden personal-resource capability predicate ${routine.name}`
|
|
2262
|
+
);
|
|
2263
|
+
}
|
|
2264
|
+
const directPrivileges = [
|
|
2265
|
+
["SELECT", table.select],
|
|
2266
|
+
["INSERT", table.insert],
|
|
2267
|
+
["UPDATE", table.update],
|
|
2268
|
+
["DELETE", table.delete]
|
|
2269
|
+
].filter(([, granted]) => granted);
|
|
2270
|
+
if (directPrivileges.length > 0) {
|
|
2271
|
+
violations.push(
|
|
2272
|
+
`runtime role has forbidden direct privileges on private table ${table.name}: ${directPrivileges.map(([privilege]) => privilege).join(", ")}`
|
|
2273
|
+
);
|
|
2274
|
+
}
|
|
2275
|
+
}
|
|
2276
|
+
const personalDocumentCapabilityTables = posture.privateTables.filter(
|
|
2277
|
+
(table) => table.name === PERSONAL_DOCUMENT_CAPABILITY_TABLE
|
|
2278
|
+
);
|
|
2279
|
+
const personalDocumentCapabilityRoutines = posture.privateRoutines.filter(
|
|
2280
|
+
(routine) => routine.name === PERSONAL_DOCUMENT_CAPABILITY_PREDICATE_ROUTINE
|
|
2281
|
+
);
|
|
2282
|
+
if (personalDocumentCapabilityTables.length !== 1) {
|
|
2283
|
+
violations.push(
|
|
2284
|
+
`personal-document capability table ${PERSONAL_DOCUMENT_CAPABILITY_TABLE} is missing or ambiguous`
|
|
2285
|
+
);
|
|
2286
|
+
}
|
|
2287
|
+
if (personalDocumentCapabilityRoutines.length !== 1) {
|
|
2288
|
+
violations.push(
|
|
2289
|
+
`personal-document capability predicate ${PERSONAL_DOCUMENT_CAPABILITY_PREDICATE_ROUTINE} is missing or ambiguous`
|
|
2290
|
+
);
|
|
2291
|
+
}
|
|
2292
|
+
if (personalDocumentCapabilityTables.length === 1 && personalDocumentCapabilityRoutines.length === 1) {
|
|
2293
|
+
const table = personalDocumentCapabilityTables[0];
|
|
2294
|
+
const routine = personalDocumentCapabilityRoutines[0];
|
|
2295
|
+
if (routine.owner !== table.owner) {
|
|
2296
|
+
violations.push(
|
|
2297
|
+
`personal-document capability predicate ${routine.name} owner ${routine.owner} does not match table owner ${table.owner}`
|
|
2298
|
+
);
|
|
2299
|
+
}
|
|
2300
|
+
if (!routine.securityDefiner) {
|
|
2301
|
+
violations.push(
|
|
2302
|
+
`personal-document capability predicate ${routine.name} is not SECURITY DEFINER`
|
|
2303
|
+
);
|
|
2304
|
+
}
|
|
2305
|
+
if (!routine.execute) {
|
|
2306
|
+
violations.push(`runtime role lacks personal-document capability predicate ${routine.name}`);
|
|
2307
|
+
}
|
|
2308
|
+
if (routine.publicExecute) {
|
|
2309
|
+
violations.push(
|
|
2310
|
+
`PUBLIC has forbidden personal-document capability predicate ${routine.name}`
|
|
2311
|
+
);
|
|
2312
|
+
}
|
|
2313
|
+
const directPrivileges = [
|
|
2314
|
+
["SELECT", table.select],
|
|
2315
|
+
["INSERT", table.insert],
|
|
2316
|
+
["UPDATE", table.update],
|
|
2317
|
+
["DELETE", table.delete]
|
|
2318
|
+
].filter(([, granted]) => granted);
|
|
2319
|
+
if (directPrivileges.length > 0) {
|
|
2320
|
+
violations.push(
|
|
2321
|
+
`runtime role has forbidden direct privileges on private table ${table.name}: ${directPrivileges.map(([privilege]) => privilege).join(", ")}`
|
|
2322
|
+
);
|
|
2323
|
+
}
|
|
2324
|
+
}
|
|
2325
|
+
const documentMigrationCapabilityTables = posture.privateTables.filter(
|
|
2326
|
+
(table) => table.name === DOCUMENT_MIGRATION_CAPABILITY_TABLE
|
|
2327
|
+
);
|
|
2328
|
+
const documentMigrationCapabilityRoutines = posture.privateRoutines.filter(
|
|
2329
|
+
(routine) => routine.name === DOCUMENT_MIGRATION_CAPABILITY_PREDICATE_ROUTINE
|
|
2330
|
+
);
|
|
2331
|
+
if (documentMigrationCapabilityTables.length !== 1) {
|
|
2332
|
+
violations.push(
|
|
2333
|
+
`document-migration capability table ${DOCUMENT_MIGRATION_CAPABILITY_TABLE} is missing or ambiguous`
|
|
2334
|
+
);
|
|
2335
|
+
}
|
|
2336
|
+
if (documentMigrationCapabilityRoutines.length !== 1) {
|
|
2337
|
+
violations.push(
|
|
2338
|
+
`document-migration capability predicate ${DOCUMENT_MIGRATION_CAPABILITY_PREDICATE_ROUTINE} is missing or ambiguous`
|
|
2339
|
+
);
|
|
2340
|
+
}
|
|
2341
|
+
if (documentMigrationCapabilityTables.length === 1 && documentMigrationCapabilityRoutines.length === 1) {
|
|
2342
|
+
const table = documentMigrationCapabilityTables[0];
|
|
2343
|
+
const routine = documentMigrationCapabilityRoutines[0];
|
|
2344
|
+
if (routine.owner !== table.owner) {
|
|
2345
|
+
violations.push(
|
|
2346
|
+
`document-migration capability predicate ${routine.name} owner ${routine.owner} does not match table owner ${table.owner}`
|
|
2347
|
+
);
|
|
2348
|
+
}
|
|
2349
|
+
if (!routine.securityDefiner) {
|
|
2350
|
+
violations.push(
|
|
2351
|
+
`document-migration capability predicate ${routine.name} is not SECURITY DEFINER`
|
|
2352
|
+
);
|
|
2353
|
+
}
|
|
2354
|
+
if (!routine.execute) {
|
|
2355
|
+
violations.push(`runtime role lacks document-migration capability predicate ${routine.name}`);
|
|
2356
|
+
}
|
|
2357
|
+
if (routine.publicExecute) {
|
|
2358
|
+
violations.push(
|
|
2359
|
+
`PUBLIC has forbidden document-migration capability predicate ${routine.name}`
|
|
2360
|
+
);
|
|
2361
|
+
}
|
|
2362
|
+
const directPrivileges = [
|
|
2363
|
+
["SELECT", table.select],
|
|
2364
|
+
["INSERT", table.insert],
|
|
2365
|
+
["UPDATE", table.update],
|
|
2366
|
+
["DELETE", table.delete]
|
|
2367
|
+
].filter(([, granted]) => granted);
|
|
2368
|
+
if (directPrivileges.length > 0) {
|
|
2369
|
+
violations.push(
|
|
2370
|
+
`runtime role has forbidden direct privileges on private table ${table.name}: ${directPrivileges.map(([privilege]) => privilege).join(", ")}`
|
|
2371
|
+
);
|
|
2372
|
+
}
|
|
2373
|
+
}
|
|
2374
|
+
const scheduledCapabilityTables = posture.privateTables.filter(
|
|
2375
|
+
(table) => table.name === SCHEDULED_PERSONAL_RESOURCE_CAPABILITY_TABLE
|
|
2376
|
+
);
|
|
2377
|
+
const scheduledCapabilityRoutines = posture.privateRoutines.filter(
|
|
2378
|
+
(routine) => routine.name === SCHEDULED_PERSONAL_RESOURCE_CAPABILITY_PREDICATE_ROUTINE
|
|
2379
|
+
);
|
|
2380
|
+
if (scheduledCapabilityTables.length !== 1) {
|
|
2381
|
+
violations.push(
|
|
2382
|
+
`scheduled personal-resource capability table ${SCHEDULED_PERSONAL_RESOURCE_CAPABILITY_TABLE} is missing or ambiguous`
|
|
2383
|
+
);
|
|
2384
|
+
}
|
|
2385
|
+
if (scheduledCapabilityRoutines.length !== 1) {
|
|
2386
|
+
violations.push(
|
|
2387
|
+
`scheduled personal-resource capability predicate ${SCHEDULED_PERSONAL_RESOURCE_CAPABILITY_PREDICATE_ROUTINE} is missing or ambiguous`
|
|
2388
|
+
);
|
|
2389
|
+
}
|
|
2390
|
+
if (scheduledCapabilityTables.length === 1 && scheduledCapabilityRoutines.length === 1) {
|
|
2391
|
+
const table = scheduledCapabilityTables[0];
|
|
2392
|
+
const routine = scheduledCapabilityRoutines[0];
|
|
2393
|
+
if (routine.owner !== table.owner) {
|
|
2394
|
+
violations.push(
|
|
2395
|
+
`scheduled personal-resource capability predicate ${routine.name} owner ${routine.owner} does not match table owner ${table.owner}`
|
|
2396
|
+
);
|
|
2397
|
+
}
|
|
2398
|
+
if (!routine.securityDefiner) {
|
|
2399
|
+
violations.push(
|
|
2400
|
+
`scheduled personal-resource capability predicate ${routine.name} is not SECURITY DEFINER`
|
|
2401
|
+
);
|
|
2402
|
+
}
|
|
2403
|
+
if (!routine.execute) {
|
|
2404
|
+
violations.push(
|
|
2405
|
+
`runtime role lacks scheduled personal-resource capability predicate ${routine.name}`
|
|
2406
|
+
);
|
|
2407
|
+
}
|
|
2408
|
+
if (routine.publicExecute) {
|
|
2409
|
+
violations.push(
|
|
2410
|
+
`PUBLIC has forbidden scheduled personal-resource capability predicate ${routine.name}`
|
|
2411
|
+
);
|
|
2412
|
+
}
|
|
2413
|
+
const directPrivileges = [
|
|
2414
|
+
["SELECT", table.select],
|
|
2415
|
+
["INSERT", table.insert],
|
|
2416
|
+
["UPDATE", table.update],
|
|
2417
|
+
["DELETE", table.delete]
|
|
2418
|
+
].filter(([, granted]) => granted);
|
|
2419
|
+
if (directPrivileges.length > 0) {
|
|
2420
|
+
violations.push(
|
|
2421
|
+
`runtime role has forbidden direct privileges on private table ${table.name}: ${directPrivileges.map(([privilege]) => privilege).join(", ")}`
|
|
2422
|
+
);
|
|
2423
|
+
}
|
|
2424
|
+
}
|
|
2425
|
+
if (options.protectedTables === void 0) {
|
|
2426
|
+
const variableSetCapabilityTables = posture.privateTables.filter(
|
|
2427
|
+
(table) => table.name === VARIABLE_SET_CAPABILITY_TABLE
|
|
2428
|
+
);
|
|
2429
|
+
const variableSetCapabilityRoutines = posture.privateRoutines.filter(
|
|
2430
|
+
(routine) => routine.name === VARIABLE_SET_CAPABILITY_PREDICATE_ROUTINE
|
|
2431
|
+
);
|
|
2432
|
+
if (variableSetCapabilityTables.length !== 1) {
|
|
2433
|
+
violations.push(
|
|
2434
|
+
`variable-set capability table ${VARIABLE_SET_CAPABILITY_TABLE} is missing or ambiguous`
|
|
2435
|
+
);
|
|
2436
|
+
}
|
|
2437
|
+
if (variableSetCapabilityRoutines.length !== 1) {
|
|
2438
|
+
violations.push(
|
|
2439
|
+
`variable-set capability predicate ${VARIABLE_SET_CAPABILITY_PREDICATE_ROUTINE} is missing or ambiguous`
|
|
2440
|
+
);
|
|
2441
|
+
}
|
|
2442
|
+
if (variableSetCapabilityTables.length === 1 && variableSetCapabilityRoutines.length === 1) {
|
|
2443
|
+
const table = variableSetCapabilityTables[0];
|
|
2444
|
+
const routine = variableSetCapabilityRoutines[0];
|
|
2445
|
+
if (routine.owner !== table.owner) {
|
|
2446
|
+
violations.push(
|
|
2447
|
+
`variable-set capability predicate ${routine.name} owner ${routine.owner} does not match table owner ${table.owner}`
|
|
2448
|
+
);
|
|
2449
|
+
}
|
|
2450
|
+
if (!routine.securityDefiner) {
|
|
2451
|
+
violations.push(
|
|
2452
|
+
`variable-set capability predicate ${routine.name} is not SECURITY DEFINER`
|
|
2453
|
+
);
|
|
2454
|
+
}
|
|
2455
|
+
if (!routine.execute) {
|
|
2456
|
+
violations.push(`runtime role lacks variable-set capability predicate ${routine.name}`);
|
|
2457
|
+
}
|
|
2458
|
+
if (routine.publicExecute) {
|
|
2459
|
+
violations.push(`PUBLIC has forbidden variable-set capability predicate ${routine.name}`);
|
|
2460
|
+
}
|
|
2461
|
+
const directPrivileges = [
|
|
2462
|
+
["SELECT", table.select],
|
|
2463
|
+
["INSERT", table.insert],
|
|
2464
|
+
["UPDATE", table.update],
|
|
2465
|
+
["DELETE", table.delete]
|
|
2466
|
+
].filter(([, granted]) => granted);
|
|
2467
|
+
if (directPrivileges.length > 0) {
|
|
2468
|
+
violations.push(
|
|
2469
|
+
`runtime role has forbidden direct privileges on private table ${table.name}: ${directPrivileges.map(([privilege]) => privilege).join(", ")}`
|
|
2470
|
+
);
|
|
2471
|
+
}
|
|
2472
|
+
}
|
|
2473
|
+
const scopedComputeCapabilityTables = posture.privateTables.filter(
|
|
2474
|
+
(table) => table.name === SCOPED_COMPUTE_CAPABILITY_TABLE
|
|
2475
|
+
);
|
|
2476
|
+
const scopedComputeCapabilityRoutines = posture.privateRoutines.filter(
|
|
2477
|
+
(routine) => routine.name === SCOPED_COMPUTE_CAPABILITY_PREDICATE_ROUTINE
|
|
2478
|
+
);
|
|
2479
|
+
if (scopedComputeCapabilityTables.length !== 1) {
|
|
2480
|
+
violations.push(
|
|
2481
|
+
`scoped-compute capability table ${SCOPED_COMPUTE_CAPABILITY_TABLE} is missing or ambiguous`
|
|
2482
|
+
);
|
|
2483
|
+
}
|
|
2484
|
+
if (scopedComputeCapabilityRoutines.length !== 1) {
|
|
2485
|
+
violations.push(
|
|
2486
|
+
`scoped-compute capability predicate ${SCOPED_COMPUTE_CAPABILITY_PREDICATE_ROUTINE} is missing or ambiguous`
|
|
2487
|
+
);
|
|
2488
|
+
}
|
|
2489
|
+
if (scopedComputeCapabilityTables.length === 1 && scopedComputeCapabilityRoutines.length === 1) {
|
|
2490
|
+
const table = scopedComputeCapabilityTables[0];
|
|
2491
|
+
const routine = scopedComputeCapabilityRoutines[0];
|
|
2492
|
+
if (routine.owner !== table.owner) {
|
|
2493
|
+
violations.push(
|
|
2494
|
+
`scoped-compute capability predicate ${routine.name} owner ${routine.owner} does not match table owner ${table.owner}`
|
|
2495
|
+
);
|
|
2496
|
+
}
|
|
2497
|
+
if (!routine.securityDefiner) {
|
|
2498
|
+
violations.push(
|
|
2499
|
+
`scoped-compute capability predicate ${routine.name} is not SECURITY DEFINER`
|
|
2500
|
+
);
|
|
2501
|
+
}
|
|
2502
|
+
if (!routine.execute) {
|
|
2503
|
+
violations.push(`runtime role lacks scoped-compute capability predicate ${routine.name}`);
|
|
2504
|
+
}
|
|
2505
|
+
if (routine.publicExecute) {
|
|
2506
|
+
violations.push(`PUBLIC has forbidden scoped-compute capability predicate ${routine.name}`);
|
|
2507
|
+
}
|
|
2508
|
+
const directPrivileges = [
|
|
2509
|
+
["SELECT", table.select],
|
|
2510
|
+
["INSERT", table.insert],
|
|
2511
|
+
["UPDATE", table.update],
|
|
2512
|
+
["DELETE", table.delete]
|
|
2513
|
+
].filter(([, granted]) => granted);
|
|
2514
|
+
if (directPrivileges.length > 0) {
|
|
2515
|
+
violations.push(
|
|
2516
|
+
`runtime role has forbidden direct privileges on private table ${table.name}: ${directPrivileges.map(([privilege]) => privilege).join(", ")}`
|
|
2517
|
+
);
|
|
2518
|
+
}
|
|
2519
|
+
}
|
|
2520
|
+
}
|
|
2521
|
+
if (posture.privateRoutines.length === 0) {
|
|
2522
|
+
violations.push("opengeni_private has no helper routines");
|
|
2523
|
+
}
|
|
2524
|
+
const connectionBackfillCapabilityTables = posture.privateTables.filter(
|
|
2525
|
+
(table) => table.name === CONNECTION_TENANCY_BACKFILL_CAPABILITY_TABLE
|
|
2526
|
+
);
|
|
2527
|
+
const connectionBackfillCapabilityRoutines = posture.privateRoutines.filter(
|
|
2528
|
+
(routine) => routine.name === CONNECTION_TENANCY_BACKFILL_CAPABILITY_PREDICATE_ROUTINE
|
|
2529
|
+
);
|
|
2530
|
+
if (connectionBackfillCapabilityTables.length !== 1) {
|
|
2531
|
+
violations.push(
|
|
2532
|
+
`connection-tenancy backfill capability table ${CONNECTION_TENANCY_BACKFILL_CAPABILITY_TABLE} is missing or ambiguous`
|
|
2533
|
+
);
|
|
2534
|
+
}
|
|
2535
|
+
if (connectionBackfillCapabilityRoutines.length !== 1) {
|
|
2536
|
+
violations.push(
|
|
2537
|
+
`connection-tenancy backfill capability predicate ${CONNECTION_TENANCY_BACKFILL_CAPABILITY_PREDICATE_ROUTINE} is missing or ambiguous`
|
|
2538
|
+
);
|
|
2539
|
+
}
|
|
2540
|
+
if (connectionBackfillCapabilityTables.length === 1 && connectionBackfillCapabilityRoutines.length === 1) {
|
|
2541
|
+
const table = connectionBackfillCapabilityTables[0];
|
|
2542
|
+
const routine = connectionBackfillCapabilityRoutines[0];
|
|
2543
|
+
if (routine.owner !== table.owner) {
|
|
2544
|
+
violations.push(
|
|
2545
|
+
`connection-tenancy backfill capability predicate ${routine.name} owner ${routine.owner} does not match table owner ${table.owner}`
|
|
2546
|
+
);
|
|
2547
|
+
}
|
|
2548
|
+
if (!routine.securityDefiner) {
|
|
2549
|
+
violations.push(
|
|
2550
|
+
`connection-tenancy backfill capability predicate ${routine.name} is not SECURITY DEFINER`
|
|
2551
|
+
);
|
|
2552
|
+
}
|
|
2553
|
+
if (!routine.execute) {
|
|
2554
|
+
violations.push(
|
|
2555
|
+
`runtime role lacks connection-tenancy backfill capability predicate ${routine.name}`
|
|
2556
|
+
);
|
|
2557
|
+
}
|
|
2558
|
+
if (routine.publicExecute) {
|
|
2559
|
+
violations.push(
|
|
2560
|
+
`PUBLIC has forbidden connection-tenancy backfill capability predicate ${routine.name}`
|
|
2561
|
+
);
|
|
2562
|
+
}
|
|
2563
|
+
const directPrivileges = [
|
|
2564
|
+
["SELECT", table.select],
|
|
2565
|
+
["INSERT", table.insert],
|
|
2566
|
+
["UPDATE", table.update],
|
|
2567
|
+
["DELETE", table.delete]
|
|
2568
|
+
].filter(([, granted]) => granted);
|
|
2569
|
+
if (directPrivileges.length > 0) {
|
|
2570
|
+
violations.push(
|
|
2571
|
+
`runtime role has forbidden direct privileges on private table ${table.name}: ${directPrivileges.map(([privilege]) => privilege).join(", ")}`
|
|
2572
|
+
);
|
|
2573
|
+
}
|
|
2574
|
+
}
|
|
2575
|
+
for (const routine of posture.privateRoutines) {
|
|
2576
|
+
if (routine.owner === expectedRole) {
|
|
2577
|
+
violations.push(`runtime role owns private routine ${routine.name}`);
|
|
2578
|
+
}
|
|
2579
|
+
const dedicatedArtifactCapability = DEDICATED_ARTIFACT_CAPABILITY_ROUTINES.has(routine.name);
|
|
2580
|
+
if (!routine.execute && !dedicatedArtifactCapability) {
|
|
2581
|
+
violations.push(`runtime role lacks EXECUTE on private routine ${routine.name}`);
|
|
2582
|
+
}
|
|
2583
|
+
}
|
|
2584
|
+
return violations;
|
|
2585
|
+
}
|
|
2586
|
+
async function assertRuntimeDatabasePosture(db, options) {
|
|
2587
|
+
const posture = await inspectRuntimeDatabasePosture(db, options);
|
|
2588
|
+
const violations = evaluateRuntimeDatabasePosture(posture, options);
|
|
2589
|
+
if (violations.length > 0) {
|
|
2590
|
+
throw new RuntimeDatabasePostureError(violations);
|
|
2591
|
+
}
|
|
2592
|
+
return posture;
|
|
2593
|
+
}
|
|
2594
|
+
function runtimeDatabaseReadyCheck(db, options) {
|
|
2595
|
+
return async () => {
|
|
2596
|
+
await assertRuntimeDatabasePosture(db, options);
|
|
2597
|
+
};
|
|
2598
|
+
}
|
|
2599
|
+
|
|
2600
|
+
// src/provision-roles.ts
|
|
2601
|
+
async function provisionRoles(adminConnection, options = {}) {
|
|
2602
|
+
const schema = validateIdentifier("targetSchema", options.targetSchema ?? "public");
|
|
2603
|
+
const rlsStrategy = options.rlsStrategy ?? "force";
|
|
2604
|
+
const appRole = validateIdentifier(
|
|
2605
|
+
"appRole",
|
|
2606
|
+
options.appRole ?? (process.env.OPENGENI_APP_DATABASE_USER?.trim() || "opengeni_app")
|
|
2607
|
+
);
|
|
2608
|
+
const appPassword = options.appPassword ?? process.env.OPENGENI_APP_DATABASE_PASSWORD;
|
|
2609
|
+
const artifactOutboxDispatcherRole = validateIdentifier(
|
|
2610
|
+
"artifactOutboxDispatcherRole",
|
|
2611
|
+
options.artifactOutboxDispatcherRole ?? (process.env.OPENGENI_ARTIFACT_OUTBOX_DATABASE_USER?.trim() || "opengeni_artifact_outbox_dispatcher")
|
|
2612
|
+
);
|
|
2613
|
+
const artifactOutboxDispatcherPassword = options.artifactOutboxDispatcherPassword ?? process.env.OPENGENI_ARTIFACT_OUTBOX_DATABASE_PASSWORD;
|
|
2614
|
+
const artifactMaterializerRole = validateIdentifier(
|
|
2615
|
+
"artifactMaterializerRole",
|
|
2616
|
+
options.artifactMaterializerRole ?? (process.env.OPENGENI_ARTIFACT_MATERIALIZER_DATABASE_USER?.trim() || "opengeni_artifact_materializer")
|
|
2617
|
+
);
|
|
2618
|
+
const artifactMaterializerPassword = options.artifactMaterializerPassword ?? process.env.OPENGENI_ARTIFACT_MATERIALIZER_DATABASE_PASSWORD;
|
|
2619
|
+
const hostExportRole = validateIdentifier(
|
|
2620
|
+
"hostExportRole",
|
|
2621
|
+
options.hostExportRole ?? (process.env.OPENGENI_HOST_EXPORT_DATABASE_USER?.trim() || "opengeni_host_exporter")
|
|
2622
|
+
);
|
|
2623
|
+
const hostExportPassword = options.hostExportPassword ?? process.env.OPENGENI_HOST_EXPORT_DATABASE_PASSWORD;
|
|
2624
|
+
const temporalRole = validateIdentifier(
|
|
2625
|
+
"temporalRole",
|
|
2626
|
+
options.temporalRole ?? (process.env.OPENGENI_TEMPORAL_DATABASE_USER?.trim() || "opengeni_temporal")
|
|
2627
|
+
);
|
|
2628
|
+
const temporalPassword = options.temporalPassword ?? process.env.OPENGENI_TEMPORAL_DATABASE_PASSWORD;
|
|
2629
|
+
const temporalDatabases = (options.temporalDatabases ?? commaSeparated(process.env.OPENGENI_TEMPORAL_DATABASES ?? "temporal,temporal_visibility")).map((name) => validateIdentifier("temporalDatabases", name));
|
|
2630
|
+
const sql2 = postgres(adminConnection, { max: 1 });
|
|
2631
|
+
try {
|
|
2632
|
+
let provisionedAppRole = null;
|
|
2633
|
+
if (rlsStrategy === "force") {
|
|
2634
|
+
if (!appPassword) {
|
|
2635
|
+
throw new Error(
|
|
2636
|
+
"OPENGENI_APP_DATABASE_PASSWORD (or appPassword) is required for rlsStrategy 'force'"
|
|
2637
|
+
);
|
|
2638
|
+
}
|
|
2639
|
+
await assertAppRoleSafeToNormalize(sql2, appRole);
|
|
2640
|
+
await ensureRestrictedAppLoginRole(sql2, appRole, appPassword);
|
|
2641
|
+
provisionedAppRole = appRole;
|
|
2642
|
+
}
|
|
2643
|
+
let provisionedArtifactOutboxDispatcherRole = null;
|
|
2644
|
+
if (artifactOutboxDispatcherPassword) {
|
|
2645
|
+
await assertAppRoleSafeToNormalize(sql2, artifactOutboxDispatcherRole);
|
|
2646
|
+
await ensureRestrictedAppLoginRole(
|
|
2647
|
+
sql2,
|
|
2648
|
+
artifactOutboxDispatcherRole,
|
|
2649
|
+
artifactOutboxDispatcherPassword
|
|
2650
|
+
);
|
|
2651
|
+
await grantArtifactCapabilityRoleIfSchemaExists(
|
|
2652
|
+
sql2,
|
|
2653
|
+
artifactOutboxDispatcherRole,
|
|
2654
|
+
schema,
|
|
2655
|
+
"outbox"
|
|
2656
|
+
);
|
|
2657
|
+
provisionedArtifactOutboxDispatcherRole = artifactOutboxDispatcherRole;
|
|
2658
|
+
}
|
|
2659
|
+
let provisionedArtifactMaterializerRole = null;
|
|
2660
|
+
if (artifactMaterializerPassword) {
|
|
2661
|
+
await assertAppRoleSafeToNormalize(sql2, artifactMaterializerRole);
|
|
2662
|
+
await ensureRestrictedAppLoginRole(
|
|
2663
|
+
sql2,
|
|
2664
|
+
artifactMaterializerRole,
|
|
2665
|
+
artifactMaterializerPassword
|
|
2666
|
+
);
|
|
2667
|
+
await grantArtifactCapabilityRoleIfSchemaExists(
|
|
2668
|
+
sql2,
|
|
2669
|
+
artifactMaterializerRole,
|
|
2670
|
+
schema,
|
|
2671
|
+
"materializer"
|
|
2672
|
+
);
|
|
2673
|
+
provisionedArtifactMaterializerRole = artifactMaterializerRole;
|
|
2674
|
+
}
|
|
2675
|
+
if (temporalPassword) {
|
|
2676
|
+
await ensureLoginRole(sql2, temporalRole, temporalPassword);
|
|
2677
|
+
for (const database of temporalDatabases) {
|
|
2678
|
+
await ensureDatabase(sql2, database, temporalRole);
|
|
2679
|
+
await grantTemporalRoleInDatabase(adminConnection, database, temporalRole);
|
|
2680
|
+
}
|
|
2681
|
+
}
|
|
2682
|
+
if (hostExportPassword) {
|
|
2683
|
+
await ensureLoginRole(sql2, hostExportRole, hostExportPassword);
|
|
2684
|
+
await grantHostExportRoleIfSchemaExists(sql2, hostExportRole);
|
|
2685
|
+
}
|
|
2686
|
+
if (rlsStrategy === "force") {
|
|
2687
|
+
await grantAppRoleIfSchemaExists(sql2, appRole, schema);
|
|
2688
|
+
}
|
|
2689
|
+
return {
|
|
2690
|
+
appRole: provisionedAppRole,
|
|
2691
|
+
artifactOutboxDispatcherRole: provisionedArtifactOutboxDispatcherRole,
|
|
2692
|
+
artifactMaterializerRole: provisionedArtifactMaterializerRole,
|
|
2693
|
+
hostExportRole: hostExportPassword ? hostExportRole : null,
|
|
2694
|
+
temporalRole: temporalPassword ? temporalRole : null,
|
|
2695
|
+
temporalDatabases: temporalPassword ? temporalDatabases : [],
|
|
2696
|
+
schema,
|
|
2697
|
+
rlsStrategy
|
|
2698
|
+
};
|
|
2699
|
+
} finally {
|
|
2700
|
+
await sql2.end();
|
|
2701
|
+
}
|
|
2702
|
+
}
|
|
2703
|
+
async function grantHostExportRoleIfSchemaExists(sql2, role) {
|
|
2704
|
+
await sql2.unsafe(`
|
|
2705
|
+
DO $$
|
|
2706
|
+
BEGIN
|
|
2707
|
+
IF EXISTS (SELECT 1 FROM pg_namespace WHERE nspname = 'opengeni_host_export') THEN
|
|
2708
|
+
EXECUTE format('GRANT USAGE ON SCHEMA opengeni_host_export TO %I', ${literal(role)});
|
|
2709
|
+
EXECUTE format('GRANT EXECUTE ON ALL FUNCTIONS IN SCHEMA opengeni_host_export TO %I', ${literal(role)});
|
|
2710
|
+
EXECUTE format('ALTER DEFAULT PRIVILEGES IN SCHEMA opengeni_host_export GRANT EXECUTE ON FUNCTIONS TO %I', ${literal(role)});
|
|
2711
|
+
END IF;
|
|
2712
|
+
END $$;
|
|
2713
|
+
`);
|
|
2714
|
+
}
|
|
2715
|
+
async function grantArtifactCapabilityRoleIfSchemaExists(sql2, role, dataSchema, capability) {
|
|
2716
|
+
const routines = capability === "outbox" ? [
|
|
2717
|
+
"claim_editable_artifact_live_outbox(text,integer,integer,name)",
|
|
2718
|
+
"mark_editable_artifact_live_outbox_published(text,text,integer,name)",
|
|
2719
|
+
"renew_editable_artifact_live_outbox(text,text,integer,integer,name)",
|
|
2720
|
+
"retry_editable_artifact_live_outbox(text,text,integer,integer,text,name)",
|
|
2721
|
+
"dead_letter_editable_artifact_live_outbox(text,text,integer,text,name)",
|
|
2722
|
+
"release_editable_artifact_live_outbox(text,text,integer,name)"
|
|
2723
|
+
] : [
|
|
2724
|
+
"claim_editable_artifact_materializations(text,integer,integer,name)",
|
|
2725
|
+
"renew_editable_artifact_materialization(uuid,uuid,text,text,text,integer,integer,name)",
|
|
2726
|
+
"succeed_editable_artifact_materialization(uuid,uuid,text,text,text,integer,text,text,text,bigint,text,text,timestamp with time zone,name)",
|
|
2727
|
+
"fail_editable_artifact_materialization(uuid,uuid,text,text,text,integer,text,name)"
|
|
2728
|
+
];
|
|
2729
|
+
const routineArray = `ARRAY[${routines.map(literal).join(", ")}]`;
|
|
2730
|
+
await sql2.unsafe(`
|
|
2731
|
+
DO $$
|
|
2732
|
+
DECLARE routine_signature text;
|
|
2733
|
+
BEGIN
|
|
2734
|
+
IF EXISTS (SELECT 1 FROM pg_namespace WHERE nspname = ${literal(dataSchema)})
|
|
2735
|
+
AND EXISTS (SELECT 1 FROM pg_namespace WHERE nspname = 'opengeni_private')
|
|
2736
|
+
THEN
|
|
2737
|
+
EXECUTE format('GRANT CONNECT ON DATABASE %I TO %I', current_database(), ${literal(role)});
|
|
2738
|
+
EXECUTE format('GRANT USAGE ON SCHEMA %I TO %I', ${literal(dataSchema)}, ${literal(role)});
|
|
2739
|
+
EXECUTE format('GRANT USAGE ON SCHEMA opengeni_private TO %I', ${literal(role)});
|
|
2740
|
+
EXECUTE format(
|
|
2741
|
+
'REVOKE ALL PRIVILEGES ON ALL TABLES IN SCHEMA %I FROM %I',
|
|
2742
|
+
${literal(dataSchema)}, ${literal(role)}
|
|
2743
|
+
);
|
|
2744
|
+
EXECUTE format(
|
|
2745
|
+
'REVOKE ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA %I FROM %I',
|
|
2746
|
+
${literal(dataSchema)}, ${literal(role)}
|
|
2747
|
+
);
|
|
2748
|
+
EXECUTE format(
|
|
2749
|
+
'REVOKE ALL PRIVILEGES ON ALL FUNCTIONS IN SCHEMA opengeni_private FROM %I',
|
|
2750
|
+
${literal(role)}
|
|
2751
|
+
);
|
|
2752
|
+
FOREACH routine_signature IN ARRAY ${routineArray} LOOP
|
|
2753
|
+
IF to_regprocedure('opengeni_private.' || routine_signature) IS NOT NULL THEN
|
|
2754
|
+
EXECUTE format(
|
|
2755
|
+
'GRANT EXECUTE ON FUNCTION opengeni_private.%s TO %I',
|
|
2756
|
+
routine_signature, ${literal(role)}
|
|
2757
|
+
);
|
|
2758
|
+
END IF;
|
|
2759
|
+
END LOOP;
|
|
2760
|
+
END IF;
|
|
2761
|
+
END $$;
|
|
2762
|
+
`);
|
|
2763
|
+
}
|
|
2764
|
+
async function ensureLoginRole(sql2, role, password) {
|
|
2765
|
+
await sql2.unsafe(`
|
|
2766
|
+
DO $$
|
|
2767
|
+
BEGIN
|
|
2768
|
+
IF NOT EXISTS (SELECT 1 FROM pg_roles WHERE rolname = ${literal(role)}) THEN
|
|
2769
|
+
EXECUTE format('CREATE ROLE %I LOGIN PASSWORD %L', ${literal(role)}, ${literal(password)});
|
|
2770
|
+
ELSE
|
|
2771
|
+
EXECUTE format('ALTER ROLE %I LOGIN PASSWORD %L', ${literal(role)}, ${literal(password)});
|
|
2772
|
+
END IF;
|
|
2773
|
+
END $$;
|
|
2774
|
+
`);
|
|
2775
|
+
}
|
|
2776
|
+
async function ensureRestrictedAppLoginRole(sql2, role, password) {
|
|
2777
|
+
await sql2.unsafe(`
|
|
2778
|
+
DO $$
|
|
2779
|
+
BEGIN
|
|
2780
|
+
IF NOT EXISTS (SELECT 1 FROM pg_roles WHERE rolname = ${literal(role)}) THEN
|
|
2781
|
+
EXECUTE format(
|
|
2782
|
+
'CREATE ROLE %I WITH LOGIN NOSUPERUSER NOBYPASSRLS NOCREATEROLE NOCREATEDB NOREPLICATION NOINHERIT PASSWORD %L',
|
|
2783
|
+
${literal(role)},
|
|
2784
|
+
${literal(password)}
|
|
2785
|
+
);
|
|
2786
|
+
ELSIF EXISTS (SELECT 1 FROM pg_roles WHERE rolname = current_user AND rolsuper) THEN
|
|
2787
|
+
EXECUTE format(
|
|
2788
|
+
'ALTER ROLE %I WITH LOGIN NOSUPERUSER NOBYPASSRLS NOCREATEROLE NOCREATEDB NOREPLICATION NOINHERIT PASSWORD %L',
|
|
2789
|
+
${literal(role)},
|
|
2790
|
+
${literal(password)}
|
|
2791
|
+
);
|
|
2792
|
+
ELSE
|
|
2793
|
+
-- PostgreSQL requires elevated attributes merely to name SUPERUSER,
|
|
2794
|
+
-- BYPASSRLS, REPLICATION, or CREATEDB in ALTER ROLE, even when setting them
|
|
2795
|
+
-- false. The preflight has already proved those protected attributes are
|
|
2796
|
+
-- false, so a managed CREATEROLE administrator converges only the
|
|
2797
|
+
-- attributes it may change.
|
|
2798
|
+
EXECUTE format(
|
|
2799
|
+
'ALTER ROLE %I WITH LOGIN NOCREATEROLE NOINHERIT PASSWORD %L',
|
|
2800
|
+
${literal(role)},
|
|
2801
|
+
${literal(password)}
|
|
2802
|
+
);
|
|
2803
|
+
END IF;
|
|
2804
|
+
END $$;
|
|
2805
|
+
`);
|
|
2806
|
+
}
|
|
2807
|
+
async function assertAppRoleSafeToNormalize(sql2, role) {
|
|
2808
|
+
const exists = await sql2`
|
|
2809
|
+
select exists(select 1 from pg_roles where rolname = ${role}) as exists
|
|
2810
|
+
`;
|
|
2811
|
+
if (!exists[0]?.exists) {
|
|
2812
|
+
return;
|
|
2813
|
+
}
|
|
2814
|
+
const [roleAttributes] = await sql2`
|
|
2815
|
+
select
|
|
2816
|
+
administrator.rolsuper as administrator_superuser,
|
|
2817
|
+
app.rolsuper as app_superuser,
|
|
2818
|
+
app.rolbypassrls as app_bypass_rls,
|
|
2819
|
+
app.rolcreatedb as app_create_database,
|
|
2820
|
+
app.rolreplication as app_replication
|
|
2821
|
+
from pg_roles app
|
|
2822
|
+
join pg_roles administrator on administrator.rolname = current_user
|
|
2823
|
+
where app.rolname = ${role}
|
|
2824
|
+
`;
|
|
2825
|
+
if (roleAttributes && !roleAttributes.administrator_superuser) {
|
|
2826
|
+
const protectedAttributes = [
|
|
2827
|
+
roleAttributes.app_superuser ? "SUPERUSER" : null,
|
|
2828
|
+
roleAttributes.app_bypass_rls ? "BYPASSRLS" : null,
|
|
2829
|
+
roleAttributes.app_create_database ? "CREATEDB" : null,
|
|
2830
|
+
roleAttributes.app_replication ? "REPLICATION" : null
|
|
2831
|
+
].filter((attribute) => attribute !== null);
|
|
2832
|
+
if (protectedAttributes.length > 0) {
|
|
2833
|
+
throw new Error(
|
|
2834
|
+
`Refusing to normalize app role ${role}: a non-superuser administrator cannot clear protected attributes (${protectedAttributes.join(", ")})`
|
|
2835
|
+
);
|
|
2836
|
+
}
|
|
2837
|
+
}
|
|
2838
|
+
const relationshipRows = await sql2.unsafe(
|
|
2839
|
+
roleRelationshipsCatalogQuery("$1"),
|
|
2840
|
+
[role]
|
|
2841
|
+
);
|
|
2842
|
+
const { unsafeRelationships } = classifyRoleRelationships(relationshipRows);
|
|
2843
|
+
if (unsafeRelationships.length > 0) {
|
|
2844
|
+
throw new Error(
|
|
2845
|
+
`Refusing to normalize app role ${role}: remove privilege-bearing role relationships first (${unsafeRelationships.join(", ")})`
|
|
2846
|
+
);
|
|
2847
|
+
}
|
|
2848
|
+
const ownedObjects = await sql2`
|
|
2849
|
+
select ('database:' || d.datname)::text as object_name
|
|
2850
|
+
from pg_database d
|
|
2851
|
+
join pg_roles owner on owner.oid = d.datdba
|
|
2852
|
+
where owner.rolname = ${role}
|
|
2853
|
+
union all
|
|
2854
|
+
select ('schema:' || n.nspname)::text as object_name
|
|
2855
|
+
from pg_namespace n
|
|
2856
|
+
join pg_roles owner on owner.oid = n.nspowner
|
|
2857
|
+
where owner.rolname = ${role}
|
|
2858
|
+
and n.nspname <> 'information_schema'
|
|
2859
|
+
and n.nspname !~ '^pg_'
|
|
2860
|
+
union all
|
|
2861
|
+
select ('relation:' || n.nspname || '.' || c.relname)::text as object_name
|
|
2862
|
+
from pg_class c
|
|
2863
|
+
join pg_namespace n on n.oid = c.relnamespace
|
|
2864
|
+
join pg_roles owner on owner.oid = c.relowner
|
|
2865
|
+
where owner.rolname = ${role}
|
|
2866
|
+
and n.nspname <> 'information_schema'
|
|
2867
|
+
and n.nspname !~ '^pg_'
|
|
2868
|
+
union all
|
|
2869
|
+
select (
|
|
2870
|
+
'routine:' || n.nspname || '.' || p.proname || '(' ||
|
|
2871
|
+
pg_get_function_identity_arguments(p.oid) || ')'
|
|
2872
|
+
)::text as object_name
|
|
2873
|
+
from pg_proc p
|
|
2874
|
+
join pg_namespace n on n.oid = p.pronamespace
|
|
2875
|
+
join pg_roles owner on owner.oid = p.proowner
|
|
2876
|
+
where owner.rolname = ${role}
|
|
2877
|
+
and n.nspname <> 'information_schema'
|
|
2878
|
+
and n.nspname !~ '^pg_'
|
|
2879
|
+
order by object_name
|
|
2880
|
+
`;
|
|
2881
|
+
if (ownedObjects.length > 0) {
|
|
2882
|
+
throw new Error(
|
|
2883
|
+
`Refusing to normalize app role ${role}: transfer owned objects first (${ownedObjects.map((row) => row.object_name).join(", ")})`
|
|
2884
|
+
);
|
|
2885
|
+
}
|
|
2886
|
+
}
|
|
2887
|
+
async function ensureDatabase(sql2, database, owner) {
|
|
2888
|
+
const existing = await sql2`
|
|
2889
|
+
select exists(select 1 from pg_database where datname = ${database}) as exists
|
|
2890
|
+
`;
|
|
2891
|
+
if (!existing[0]?.exists) {
|
|
2892
|
+
await sql2.unsafe(`CREATE DATABASE ${identifier(database)} OWNER ${identifier(owner)}`);
|
|
2893
|
+
}
|
|
2894
|
+
await sql2.unsafe(
|
|
2895
|
+
`GRANT ALL PRIVILEGES ON DATABASE ${identifier(database)} TO ${identifier(owner)}`
|
|
2896
|
+
);
|
|
2897
|
+
}
|
|
2898
|
+
async function grantTemporalRoleInDatabase(adminConnection, database, role) {
|
|
2899
|
+
const databaseUrl = databaseUrlFor(adminConnection, database);
|
|
2900
|
+
const databaseSql = postgres(databaseUrl, { max: 1 });
|
|
2901
|
+
try {
|
|
2902
|
+
await databaseSql.unsafe(`GRANT USAGE, CREATE ON SCHEMA public TO ${identifier(role)}`);
|
|
2903
|
+
} finally {
|
|
2904
|
+
await databaseSql.end();
|
|
2905
|
+
}
|
|
2906
|
+
}
|
|
2907
|
+
async function grantAppRoleIfSchemaExists(sql2, role, schema) {
|
|
2908
|
+
const runtimeFullDmlTables = `ARRAY[${RUNTIME_FULL_DML_TABLES.map(literal).join(", ")}]`;
|
|
2909
|
+
const runtimeReadOnlyTables = `ARRAY[${RUNTIME_READ_ONLY_TABLES.map(literal).join(", ")}]`;
|
|
2910
|
+
const runtimeReadUpdateTables = `ARRAY[${RUNTIME_READ_UPDATE_TABLES.map(literal).join(", ")}]`;
|
|
2911
|
+
const runtimeReadInsertTables = `ARRAY[${RUNTIME_READ_INSERT_TABLES.map(literal).join(", ")}]`;
|
|
2912
|
+
const runtimeReadInsertUpdateTables = `ARRAY[${RUNTIME_READ_INSERT_UPDATE_TABLES.map(literal).join(", ")}]`;
|
|
2913
|
+
const organizationMembershipLifecycleRoutines = `ARRAY[${[
|
|
2914
|
+
"list_self_organization_memberships(text)",
|
|
2915
|
+
"list_self_organization_invitations(text)",
|
|
2916
|
+
"list_self_organization_invitations(text,uuid,integer)",
|
|
2917
|
+
"get_self_organization_invitation(text,uuid)",
|
|
2918
|
+
"list_organization_members(uuid,text)",
|
|
2919
|
+
"list_organization_invitations(uuid,text,uuid,integer)",
|
|
2920
|
+
"get_organization_administration_overview(uuid,text)",
|
|
2921
|
+
"create_managed_organization(text,text,text,uuid)",
|
|
2922
|
+
"assert_organization_shared_workspace_administrator(uuid,uuid,text)",
|
|
2923
|
+
"open_organization_shared_workspace_administration_capability(uuid,uuid,text)",
|
|
2924
|
+
"close_organization_shared_workspace_administration_capability(uuid)",
|
|
2925
|
+
"create_organization_shared_workspace(uuid,text,text,text,text,uuid)",
|
|
2926
|
+
"upsert_organization_shared_workspace_member(uuid,uuid,text,uuid,text,text,jsonb,boolean)",
|
|
2927
|
+
"update_organization_name(uuid,text,text,timestamptz,uuid)",
|
|
2928
|
+
"create_organization_invitation_v2(jsonb)",
|
|
2929
|
+
"bind_pending_organization_invitations_for_verified_email(text,text)",
|
|
2930
|
+
"has_pending_organization_invitation_for_subject(text)",
|
|
2931
|
+
"accept_organization_invitation_v2(jsonb)",
|
|
2932
|
+
"organization_membership_command(jsonb)",
|
|
2933
|
+
"prepare_organization_membership_protocol_settlements(jsonb)",
|
|
2934
|
+
"assert_active_managed_human_organization_membership(uuid,text)",
|
|
2935
|
+
"resolve_workspace_writer_grant_identity(uuid,text)",
|
|
2936
|
+
"prepare_workspace_membership_removal_settlements(jsonb)",
|
|
2937
|
+
"workspace_membership_removal_command(jsonb)",
|
|
2938
|
+
"get_organization_retention_policy(uuid,text)",
|
|
2939
|
+
"preview_organization_retention_deletions(uuid,integer)",
|
|
2940
|
+
"claim_organization_retention_deletion(uuid,uuid,uuid[])",
|
|
2941
|
+
"list_organization_retention_deletion_objects(uuid,uuid,uuid,text,integer)",
|
|
2942
|
+
"record_organization_retention_object_deleted(uuid,uuid,uuid,text,text,text,text)",
|
|
2943
|
+
"fail_organization_retention_deletion(uuid,uuid,uuid,text)",
|
|
2944
|
+
"finalize_organization_retention_deletion(uuid,uuid,uuid,text)",
|
|
2945
|
+
"complete_organization_retention_deletion(uuid,uuid,uuid,text)"
|
|
2946
|
+
].map(literal).join(", ")}]`;
|
|
2947
|
+
await sql2.unsafe(`
|
|
2948
|
+
DO $$
|
|
2949
|
+
DECLARE
|
|
2950
|
+
owner_role text := current_user;
|
|
2951
|
+
runtime_table text;
|
|
2952
|
+
routine_signature text;
|
|
2953
|
+
BEGIN
|
|
2954
|
+
EXECUTE format('REVOKE CREATE ON DATABASE %I FROM %I', current_database(), ${literal(role)});
|
|
2955
|
+
IF EXISTS (SELECT 1 FROM pg_namespace WHERE nspname = ${literal(schema)}) THEN
|
|
2956
|
+
EXECUTE format('GRANT USAGE ON SCHEMA %I TO %I', ${literal(schema)}, ${literal(role)});
|
|
2957
|
+
EXECUTE format('REVOKE CREATE ON SCHEMA %I FROM %I', ${literal(schema)}, ${literal(role)});
|
|
2958
|
+
EXECUTE format('REVOKE ALL PRIVILEGES ON ALL TABLES IN SCHEMA %I FROM %I', ${literal(schema)}, ${literal(role)});
|
|
2959
|
+
FOREACH runtime_table IN ARRAY ${runtimeFullDmlTables} LOOP
|
|
2960
|
+
IF to_regclass(format('%I.%I', ${literal(schema)}, runtime_table)) IS NOT NULL THEN
|
|
2961
|
+
EXECUTE format(
|
|
2962
|
+
'GRANT SELECT, INSERT, UPDATE, DELETE ON TABLE %I.%I TO %I',
|
|
2963
|
+
${literal(schema)},
|
|
2964
|
+
runtime_table,
|
|
2965
|
+
${literal(role)}
|
|
2966
|
+
);
|
|
2967
|
+
END IF;
|
|
2968
|
+
END LOOP;
|
|
2969
|
+
FOREACH runtime_table IN ARRAY ${runtimeReadOnlyTables} LOOP
|
|
2970
|
+
IF to_regclass(format('%I.%I', ${literal(schema)}, runtime_table)) IS NOT NULL THEN
|
|
2971
|
+
EXECUTE format(
|
|
2972
|
+
'GRANT SELECT ON TABLE %I.%I TO %I',
|
|
2973
|
+
${literal(schema)},
|
|
2974
|
+
runtime_table,
|
|
2975
|
+
${literal(role)}
|
|
2976
|
+
);
|
|
2977
|
+
END IF;
|
|
2978
|
+
END LOOP;
|
|
2979
|
+
FOREACH runtime_table IN ARRAY ${runtimeReadUpdateTables} LOOP
|
|
2980
|
+
IF to_regclass(format('%I.%I', ${literal(schema)}, runtime_table)) IS NOT NULL THEN
|
|
2981
|
+
EXECUTE format(
|
|
2982
|
+
'GRANT SELECT, UPDATE ON TABLE %I.%I TO %I',
|
|
2983
|
+
${literal(schema)},
|
|
2984
|
+
runtime_table,
|
|
2985
|
+
${literal(role)}
|
|
2986
|
+
);
|
|
2987
|
+
END IF;
|
|
2988
|
+
END LOOP;
|
|
2989
|
+
FOREACH runtime_table IN ARRAY ${runtimeReadInsertTables} LOOP
|
|
2990
|
+
IF to_regclass(format('%I.%I', ${literal(schema)}, runtime_table)) IS NOT NULL THEN
|
|
2991
|
+
EXECUTE format(
|
|
2992
|
+
'GRANT SELECT, INSERT ON TABLE %I.%I TO %I',
|
|
2993
|
+
${literal(schema)},
|
|
2994
|
+
runtime_table,
|
|
2995
|
+
${literal(role)}
|
|
2996
|
+
);
|
|
2997
|
+
END IF;
|
|
2998
|
+
END LOOP;
|
|
2999
|
+
FOREACH runtime_table IN ARRAY ${runtimeReadInsertUpdateTables} LOOP
|
|
3000
|
+
IF to_regclass(format('%I.%I', ${literal(schema)}, runtime_table)) IS NOT NULL THEN
|
|
3001
|
+
EXECUTE format(
|
|
3002
|
+
'GRANT SELECT, INSERT, UPDATE ON TABLE %I.%I TO %I',
|
|
3003
|
+
${literal(schema)},
|
|
3004
|
+
runtime_table,
|
|
3005
|
+
${literal(role)}
|
|
3006
|
+
);
|
|
3007
|
+
END IF;
|
|
3008
|
+
END LOOP;
|
|
3009
|
+
-- Migration 0301 creates this target-schema capability before
|
|
3010
|
+
-- opengeni_app exists on a fresh migrate-then-provision installation. Its
|
|
3011
|
+
-- policy is evaluated for ordinary session-list snapshot writes, so the
|
|
3012
|
+
-- runtime role must be able to execute the predicate even when no
|
|
3013
|
+
-- visibility-transition capability is active. Re-converge the exact ACL
|
|
3014
|
+
-- here and keep PUBLIC revoked.
|
|
3015
|
+
IF to_regprocedure(
|
|
3016
|
+
format('%I.session_visibility_lifecycle_capability_held()', ${literal(schema)})
|
|
3017
|
+
) IS NOT NULL THEN
|
|
3018
|
+
EXECUTE format(
|
|
3019
|
+
'REVOKE ALL ON FUNCTION %I.session_visibility_lifecycle_capability_held() FROM PUBLIC',
|
|
3020
|
+
${literal(schema)}
|
|
3021
|
+
);
|
|
3022
|
+
EXECUTE format(
|
|
3023
|
+
'GRANT EXECUTE ON FUNCTION %I.session_visibility_lifecycle_capability_held() TO %I',
|
|
3024
|
+
${literal(schema)},
|
|
3025
|
+
${literal(role)}
|
|
3026
|
+
);
|
|
3027
|
+
END IF;
|
|
3028
|
+
-- Migration 0300's tenancy backfill ledger seam has the same shape: its
|
|
3029
|
+
-- own conditional GRANT block is skipped whenever opengeni_app does not
|
|
3030
|
+
-- yet exist, and these three live in the data schema rather than
|
|
3031
|
+
-- opengeni_private, so the blanket sweep above never reaches them.
|
|
3032
|
+
-- Re-converge them here so migrate-then-provision matches the reverse
|
|
3033
|
+
-- order; without this the "only write path" seam is unreachable on a
|
|
3034
|
+
-- green-field database.
|
|
3035
|
+
FOR routine_signature IN
|
|
3036
|
+
SELECT unnest(ARRAY[
|
|
3037
|
+
'open_tenancy_backfill_receipt(uuid, text, text)',
|
|
3038
|
+
'record_tenancy_backfill_unresolved(uuid, uuid, text)',
|
|
3039
|
+
'complete_tenancy_backfill_receipt(uuid, bigint, bigint, text)'
|
|
3040
|
+
])
|
|
3041
|
+
LOOP
|
|
3042
|
+
IF to_regprocedure(format('%I.%s', ${literal(schema)}, routine_signature))
|
|
3043
|
+
IS NOT NULL
|
|
3044
|
+
THEN
|
|
3045
|
+
EXECUTE format(
|
|
3046
|
+
'GRANT EXECUTE ON FUNCTION %I.%s TO %I',
|
|
3047
|
+
${literal(schema)},
|
|
3048
|
+
routine_signature,
|
|
3049
|
+
${literal(role)}
|
|
3050
|
+
);
|
|
3051
|
+
END IF;
|
|
3052
|
+
END LOOP;
|
|
3053
|
+
-- Migration 0291's classification assertion seam has the same shape: its
|
|
3054
|
+
-- own conditional GRANT block is skipped whenever opengeni_app does not yet
|
|
3055
|
+
-- exist, and it lives in the data schema rather than opengeni_private, so
|
|
3056
|
+
-- the blanket sweep above never reaches it. (Its inner capability predicate
|
|
3057
|
+
-- IS in opengeni_private and is covered by that sweep.)
|
|
3058
|
+
IF to_regprocedure(
|
|
3059
|
+
format(
|
|
3060
|
+
'%I.verify_organization_resource_classification(uuid,text)',
|
|
3061
|
+
${literal(schema)}
|
|
3062
|
+
)
|
|
3063
|
+
) IS NOT NULL THEN
|
|
3064
|
+
EXECUTE format(
|
|
3065
|
+
'GRANT EXECUTE ON FUNCTION %I.verify_organization_resource_classification(uuid, text) TO %I',
|
|
3066
|
+
${literal(schema)},
|
|
3067
|
+
${literal(role)}
|
|
3068
|
+
);
|
|
3069
|
+
END IF;
|
|
3070
|
+
-- Migration 0297's session ownership seams have the same shape: their own
|
|
3071
|
+
-- conditional GRANT block is skipped whenever opengeni_app does not yet
|
|
3072
|
+
-- exist, and they live in the data schema rather than opengeni_private, so
|
|
3073
|
+
-- the blanket sweep above never reaches them. (Their inner capability
|
|
3074
|
+
-- predicate IS in opengeni_private and is covered by that sweep.)
|
|
3075
|
+
IF to_regprocedure(
|
|
3076
|
+
format(
|
|
3077
|
+
'%I.classify_organization_session_ownership(uuid,text)',
|
|
3078
|
+
${literal(schema)}
|
|
3079
|
+
)
|
|
3080
|
+
) IS NOT NULL THEN
|
|
3081
|
+
EXECUTE format(
|
|
3082
|
+
'GRANT EXECUTE ON FUNCTION %I.classify_organization_session_ownership(uuid, text) TO %I',
|
|
3083
|
+
${literal(schema)},
|
|
3084
|
+
${literal(role)}
|
|
3085
|
+
);
|
|
3086
|
+
END IF;
|
|
3087
|
+
IF to_regprocedure(
|
|
3088
|
+
format(
|
|
3089
|
+
'%I.backfill_organization_session_ownership(uuid,integer,boolean,text)',
|
|
3090
|
+
${literal(schema)}
|
|
3091
|
+
)
|
|
3092
|
+
) IS NOT NULL THEN
|
|
3093
|
+
EXECUTE format(
|
|
3094
|
+
'GRANT EXECUTE ON FUNCTION %I.backfill_organization_session_ownership(uuid, integer, boolean, text) TO %I',
|
|
3095
|
+
${literal(schema)},
|
|
3096
|
+
${literal(role)}
|
|
3097
|
+
);
|
|
3098
|
+
END IF;
|
|
3099
|
+
-- Migration 0340's bounded connection convergence and repaired parity
|
|
3100
|
+
-- seams also live in the data schema. Converge their exact grants for the
|
|
3101
|
+
-- supported migrate-then-provision order.
|
|
3102
|
+
FOREACH routine_signature IN ARRAY ARRAY[
|
|
3103
|
+
'classify_organization_connection_authority(uuid,text)',
|
|
3104
|
+
'backfill_organization_connection_authority(uuid,integer,boolean)',
|
|
3105
|
+
'inspect_organization_connection_authority_convergence(uuid,integer,uuid)',
|
|
3106
|
+
'check_organization_tenancy_parity(uuid,integer,integer)'
|
|
3107
|
+
] LOOP
|
|
3108
|
+
IF to_regprocedure(format('%I.%s', ${literal(schema)}, routine_signature))
|
|
3109
|
+
IS NOT NULL
|
|
3110
|
+
THEN
|
|
3111
|
+
EXECUTE format(
|
|
3112
|
+
'GRANT EXECUTE ON FUNCTION %I.%s TO %I',
|
|
3113
|
+
${literal(schema)},
|
|
3114
|
+
routine_signature,
|
|
3115
|
+
${literal(role)}
|
|
3116
|
+
);
|
|
3117
|
+
END IF;
|
|
3118
|
+
END LOOP;
|
|
3119
|
+
IF to_regclass(
|
|
3120
|
+
format(
|
|
3121
|
+
'%I.connection_authority_convergence_audit_capabilities',
|
|
3122
|
+
${literal(schema)}
|
|
3123
|
+
)
|
|
3124
|
+
) IS NOT NULL THEN
|
|
3125
|
+
EXECUTE format(
|
|
3126
|
+
'REVOKE ALL PRIVILEGES ON TABLE %I.connection_authority_convergence_audit_capabilities FROM %I',
|
|
3127
|
+
${literal(schema)},
|
|
3128
|
+
${literal(role)}
|
|
3129
|
+
);
|
|
3130
|
+
END IF;
|
|
3131
|
+
-- Migration 0110 creates this target-schema-local SECURITY DEFINER
|
|
3132
|
+
-- capability before opengeni_app may exist. Re-converge its exact EXECUTE
|
|
3133
|
+
-- grant here so the supported migrate-then-provision order is equivalent to
|
|
3134
|
+
-- provisioning the role before that migration.
|
|
3135
|
+
IF to_regprocedure(
|
|
3136
|
+
format('%I.lock_nested_agent_depth_configuration()', ${literal(schema)})
|
|
3137
|
+
) IS NOT NULL THEN
|
|
3138
|
+
EXECUTE format(
|
|
3139
|
+
'GRANT EXECUTE ON FUNCTION %I.lock_nested_agent_depth_configuration() TO %I',
|
|
3140
|
+
${literal(schema)},
|
|
3141
|
+
${literal(role)}
|
|
3142
|
+
);
|
|
3143
|
+
END IF;
|
|
3144
|
+
IF to_regprocedure(
|
|
3145
|
+
format(
|
|
3146
|
+
'%I.preference_registry_apply_lifecycle(text,uuid,integer,uuid,uuid,text,uuid,text,text)',
|
|
3147
|
+
${literal(schema)}
|
|
3148
|
+
)
|
|
3149
|
+
) IS NOT NULL THEN
|
|
3150
|
+
EXECUTE format(
|
|
3151
|
+
'GRANT EXECUTE ON FUNCTION %I.preference_registry_apply_lifecycle(text, uuid, integer, uuid, uuid, text, uuid, text, text) TO %I',
|
|
3152
|
+
${literal(schema)},
|
|
3153
|
+
${literal(role)}
|
|
3154
|
+
);
|
|
3155
|
+
END IF;
|
|
3156
|
+
IF to_regprocedure(
|
|
3157
|
+
format('%I.preference_registry_lock_heads(uuid[])', ${literal(schema)})
|
|
3158
|
+
) IS NOT NULL THEN
|
|
3159
|
+
EXECUTE format(
|
|
3160
|
+
'GRANT EXECUTE ON FUNCTION %I.preference_registry_lock_heads(uuid[]) TO %I',
|
|
3161
|
+
${literal(schema)},
|
|
3162
|
+
${literal(role)}
|
|
3163
|
+
);
|
|
3164
|
+
END IF;
|
|
3165
|
+
IF to_regprocedure(
|
|
3166
|
+
format(
|
|
3167
|
+
'%I.knowledge_memory_apply_operation(jsonb,text,text,text,uuid,uuid,uuid,integer)',
|
|
3168
|
+
${literal(schema)}
|
|
3169
|
+
)
|
|
3170
|
+
) IS NOT NULL THEN
|
|
3171
|
+
EXECUTE format(
|
|
3172
|
+
'GRANT EXECUTE ON FUNCTION %I.knowledge_memory_apply_operation(jsonb, text, text, text, uuid, uuid, uuid, integer) TO %I',
|
|
3173
|
+
${literal(schema)},
|
|
3174
|
+
${literal(role)}
|
|
3175
|
+
);
|
|
3176
|
+
END IF;
|
|
3177
|
+
IF to_regprocedure(
|
|
3178
|
+
format(
|
|
3179
|
+
'%I.knowledge_memory_revert_operation(uuid,uuid,text,text,text,uuid,uuid,uuid,integer)',
|
|
3180
|
+
${literal(schema)}
|
|
3181
|
+
)
|
|
3182
|
+
) IS NOT NULL THEN
|
|
3183
|
+
EXECUTE format(
|
|
3184
|
+
'GRANT EXECUTE ON FUNCTION %I.knowledge_memory_revert_operation(uuid, uuid, text, text, text, uuid, uuid, uuid, integer) TO %I',
|
|
3185
|
+
${literal(schema)},
|
|
3186
|
+
${literal(role)}
|
|
3187
|
+
);
|
|
3188
|
+
END IF;
|
|
3189
|
+
IF to_regprocedure(
|
|
3190
|
+
format(
|
|
3191
|
+
'%I.preference_registry_get_or_create_snapshot(uuid,uuid,uuid,uuid,uuid,integer)',
|
|
3192
|
+
${literal(schema)}
|
|
3193
|
+
)
|
|
3194
|
+
) IS NOT NULL THEN
|
|
3195
|
+
EXECUTE format(
|
|
3196
|
+
'GRANT EXECUTE ON FUNCTION %I.preference_registry_get_or_create_snapshot(uuid, uuid, uuid, uuid, uuid, integer) TO %I',
|
|
3197
|
+
${literal(schema)},
|
|
3198
|
+
${literal(role)}
|
|
3199
|
+
);
|
|
3200
|
+
END IF;
|
|
3201
|
+
-- Migration 0289 creates this definer accessor before opengeni_app may
|
|
3202
|
+
-- exist, so its migration-time GRANT is skipped on the supported
|
|
3203
|
+
-- migrate-then-provision order. Re-converge it here.
|
|
3204
|
+
IF to_regprocedure(
|
|
3205
|
+
format(
|
|
3206
|
+
'%I.preference_registry_activation_authority(uuid,uuid[])',
|
|
3207
|
+
${literal(schema)}
|
|
3208
|
+
)
|
|
3209
|
+
) IS NOT NULL THEN
|
|
3210
|
+
EXECUTE format(
|
|
3211
|
+
'GRANT EXECUTE ON FUNCTION %I.preference_registry_activation_authority(uuid, uuid[]) TO %I',
|
|
3212
|
+
${literal(schema)},
|
|
3213
|
+
${literal(role)}
|
|
3214
|
+
);
|
|
3215
|
+
END IF;
|
|
3216
|
+
IF to_regprocedure(
|
|
3217
|
+
format(
|
|
3218
|
+
'%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)',
|
|
3219
|
+
${literal(schema)}
|
|
3220
|
+
)
|
|
3221
|
+
) IS NOT NULL THEN
|
|
3222
|
+
EXECUTE format(
|
|
3223
|
+
'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',
|
|
3224
|
+
${literal(schema)},
|
|
3225
|
+
${literal(role)}
|
|
3226
|
+
);
|
|
3227
|
+
END IF;
|
|
3228
|
+
IF to_regprocedure(
|
|
3229
|
+
format(
|
|
3230
|
+
'%I.create_task_note_for_attempt(uuid,uuid,uuid,uuid,uuid,integer,uuid,text,text,integer)',
|
|
3231
|
+
${literal(schema)}
|
|
3232
|
+
)
|
|
3233
|
+
) IS NOT NULL THEN
|
|
3234
|
+
EXECUTE format(
|
|
3235
|
+
'GRANT EXECUTE ON FUNCTION %I.create_task_note_for_attempt(uuid, uuid, uuid, uuid, uuid, integer, uuid, text, text, integer) TO %I',
|
|
3236
|
+
${literal(schema)},
|
|
3237
|
+
${literal(role)}
|
|
3238
|
+
);
|
|
3239
|
+
EXECUTE format(
|
|
3240
|
+
'GRANT EXECUTE ON FUNCTION %I.archive_task_note_for_attempt(uuid, uuid, uuid, uuid, uuid, integer, uuid, uuid, integer, text) TO %I',
|
|
3241
|
+
${literal(schema)},
|
|
3242
|
+
${literal(role)}
|
|
3243
|
+
);
|
|
3244
|
+
EXECUTE format(
|
|
3245
|
+
'GRANT EXECUTE ON FUNCTION %I.list_task_notes_for_attempt(uuid, uuid, uuid, uuid, uuid, integer, boolean, integer) TO %I',
|
|
3246
|
+
${literal(schema)},
|
|
3247
|
+
${literal(role)}
|
|
3248
|
+
);
|
|
3249
|
+
END IF;
|
|
3250
|
+
IF to_regprocedure(
|
|
3251
|
+
format(
|
|
3252
|
+
'%I.company_brain_context_get_or_create_selection(uuid,uuid,uuid,uuid,uuid,integer)',
|
|
3253
|
+
${literal(schema)}
|
|
3254
|
+
)
|
|
3255
|
+
) IS NOT NULL THEN
|
|
3256
|
+
EXECUTE format(
|
|
3257
|
+
'GRANT EXECUTE ON FUNCTION %I.company_brain_context_get_or_create_selection(uuid, uuid, uuid, uuid, uuid, integer) TO %I',
|
|
3258
|
+
${literal(schema)},
|
|
3259
|
+
${literal(role)}
|
|
3260
|
+
);
|
|
3261
|
+
END IF;
|
|
3262
|
+
IF to_regprocedure(
|
|
3263
|
+
format(
|
|
3264
|
+
'%I.company_brain_inspect_context_receipts(uuid,uuid,text,uuid,timestamptz,uuid,integer)',
|
|
3265
|
+
${literal(schema)}
|
|
3266
|
+
)
|
|
3267
|
+
) IS NOT NULL THEN
|
|
3268
|
+
EXECUTE format(
|
|
3269
|
+
'GRANT EXECUTE ON FUNCTION %I.company_brain_inspect_context_receipts(uuid, uuid, text, uuid, timestamptz, uuid, integer) TO %I',
|
|
3270
|
+
${literal(schema)},
|
|
3271
|
+
${literal(role)}
|
|
3272
|
+
);
|
|
3273
|
+
END IF;
|
|
3274
|
+
IF to_regprocedure(
|
|
3275
|
+
format(
|
|
3276
|
+
'%I.evaluate_governed_learning_proposal(uuid,uuid,uuid,uuid,uuid,integer,uuid,uuid,uuid,uuid,uuid)',
|
|
3277
|
+
${literal(schema)}
|
|
3278
|
+
)
|
|
3279
|
+
) IS NOT NULL THEN
|
|
3280
|
+
EXECUTE format(
|
|
3281
|
+
'GRANT EXECUTE ON FUNCTION %I.evaluate_governed_learning_proposal(uuid, uuid, uuid, uuid, uuid, integer, uuid, uuid, uuid, uuid, uuid) TO %I',
|
|
3282
|
+
${literal(schema)},
|
|
3283
|
+
${literal(role)}
|
|
3284
|
+
);
|
|
3285
|
+
END IF;
|
|
3286
|
+
IF to_regprocedure(
|
|
3287
|
+
format('%I.activate_governed_learning_decision(uuid,uuid,uuid,uuid)', ${literal(schema)})
|
|
3288
|
+
) IS NOT NULL THEN
|
|
3289
|
+
EXECUTE format(
|
|
3290
|
+
'GRANT EXECUTE ON FUNCTION %I.activate_governed_learning_decision(uuid, uuid, uuid, uuid) TO %I',
|
|
3291
|
+
${literal(schema)},
|
|
3292
|
+
${literal(role)}
|
|
3293
|
+
);
|
|
3294
|
+
END IF;
|
|
3295
|
+
IF to_regprocedure(
|
|
3296
|
+
format('%I.activate_human_confirmed_learning_decision(uuid,uuid,uuid,uuid,uuid)', ${literal(schema)})
|
|
3297
|
+
) IS NOT NULL THEN
|
|
3298
|
+
EXECUTE format(
|
|
3299
|
+
'GRANT EXECUTE ON FUNCTION %I.activate_human_confirmed_learning_decision(uuid, uuid, uuid, uuid, uuid) TO %I',
|
|
3300
|
+
${literal(schema)},
|
|
3301
|
+
${literal(role)}
|
|
3302
|
+
);
|
|
3303
|
+
END IF;
|
|
3304
|
+
IF to_regprocedure(
|
|
3305
|
+
format('%I.confirm_remember_knowledge_claim(uuid,uuid,uuid,uuid,integer,uuid,uuid,uuid)', ${literal(schema)})
|
|
3306
|
+
) IS NOT NULL THEN
|
|
3307
|
+
EXECUTE format(
|
|
3308
|
+
'GRANT EXECUTE ON FUNCTION %I.confirm_remember_knowledge_claim(uuid, uuid, uuid, uuid, integer, uuid, uuid, uuid) TO %I',
|
|
3309
|
+
${literal(schema)},
|
|
3310
|
+
${literal(role)}
|
|
3311
|
+
);
|
|
3312
|
+
END IF;
|
|
3313
|
+
IF to_regprocedure(
|
|
3314
|
+
format('%I.undo_governed_learning_activation(uuid,uuid,uuid,uuid)', ${literal(schema)})
|
|
3315
|
+
) IS NOT NULL THEN
|
|
3316
|
+
EXECUTE format(
|
|
3317
|
+
'GRANT EXECUTE ON FUNCTION %I.undo_governed_learning_activation(uuid, uuid, uuid, uuid) TO %I',
|
|
3318
|
+
${literal(schema)},
|
|
3319
|
+
${literal(role)}
|
|
3320
|
+
);
|
|
3321
|
+
END IF;
|
|
3322
|
+
IF to_regprocedure(
|
|
3323
|
+
format('%I.inspect_governed_learning_decisions(uuid,uuid,text,integer)', ${literal(schema)})
|
|
3324
|
+
) IS NOT NULL THEN
|
|
3325
|
+
EXECUTE format(
|
|
3326
|
+
'GRANT EXECUTE ON FUNCTION %I.inspect_governed_learning_decisions(uuid, uuid, text, integer) TO %I',
|
|
3327
|
+
${literal(schema)},
|
|
3328
|
+
${literal(role)}
|
|
3329
|
+
);
|
|
3330
|
+
END IF;
|
|
3331
|
+
IF to_regprocedure(
|
|
3332
|
+
format('%I.inspect_governed_learning_activations(uuid,uuid,text,integer)', ${literal(schema)})
|
|
3333
|
+
) IS NOT NULL THEN
|
|
3334
|
+
EXECUTE format(
|
|
3335
|
+
'GRANT EXECUTE ON FUNCTION %I.inspect_governed_learning_activations(uuid, uuid, text, integer) TO %I',
|
|
3336
|
+
${literal(schema)},
|
|
3337
|
+
${literal(role)}
|
|
3338
|
+
);
|
|
3339
|
+
END IF;
|
|
3340
|
+
IF to_regprocedure(
|
|
3341
|
+
format('%I.inspect_governed_learning_activation_undos(uuid,uuid,text,integer)', ${literal(schema)})
|
|
3342
|
+
) IS NOT NULL THEN
|
|
3343
|
+
EXECUTE format(
|
|
3344
|
+
'GRANT EXECUTE ON FUNCTION %I.inspect_governed_learning_activation_undos(uuid, uuid, text, integer) TO %I',
|
|
3345
|
+
${literal(schema)},
|
|
3346
|
+
${literal(role)}
|
|
3347
|
+
);
|
|
3348
|
+
END IF;
|
|
3349
|
+
IF to_regprocedure(
|
|
3350
|
+
format(
|
|
3351
|
+
'%I.replace_task_note_for_attempt(uuid,uuid,uuid,uuid,uuid,integer,uuid,uuid,uuid,uuid,integer,text,text,integer,text)',
|
|
3352
|
+
${literal(schema)}
|
|
3353
|
+
)
|
|
3354
|
+
) IS NOT NULL THEN
|
|
3355
|
+
EXECUTE format(
|
|
3356
|
+
'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',
|
|
3357
|
+
${literal(schema)},
|
|
3358
|
+
${literal(role)}
|
|
3359
|
+
);
|
|
3360
|
+
END IF;
|
|
3361
|
+
IF to_regprocedure(
|
|
3362
|
+
format(
|
|
3363
|
+
'%I.resolve_task_note_knowledge_promotion_source(uuid,uuid,uuid,uuid,uuid,integer,uuid,integer,text,text,text)',
|
|
3364
|
+
${literal(schema)}
|
|
3365
|
+
)
|
|
3366
|
+
) IS NOT NULL THEN
|
|
3367
|
+
EXECUTE format(
|
|
3368
|
+
'GRANT EXECUTE ON FUNCTION %I.resolve_task_note_knowledge_promotion_source(uuid, uuid, uuid, uuid, uuid, integer, uuid, integer, text, text, text) TO %I',
|
|
3369
|
+
${literal(schema)},
|
|
3370
|
+
${literal(role)}
|
|
3371
|
+
);
|
|
3372
|
+
END IF;
|
|
3373
|
+
IF to_regprocedure(
|
|
3374
|
+
format(
|
|
3375
|
+
'%I.workspace_instruction_policy_get_or_create_snapshot(uuid,uuid,uuid,uuid,uuid,integer)',
|
|
3376
|
+
${literal(schema)}
|
|
3377
|
+
)
|
|
3378
|
+
) IS NOT NULL THEN
|
|
3379
|
+
EXECUTE format(
|
|
3380
|
+
'GRANT EXECUTE ON FUNCTION %I.workspace_instruction_policy_get_or_create_snapshot(uuid, uuid, uuid, uuid, uuid, integer) TO %I',
|
|
3381
|
+
${literal(schema)},
|
|
3382
|
+
${literal(role)}
|
|
3383
|
+
);
|
|
3384
|
+
END IF;
|
|
3385
|
+
IF to_regprocedure(
|
|
3386
|
+
format(
|
|
3387
|
+
'%I.company_profile_apply_activation(uuid,text,uuid,uuid,uuid,uuid,bigint,text,text,text,text)',
|
|
3388
|
+
${literal(schema)}
|
|
3389
|
+
)
|
|
3390
|
+
) IS NOT NULL THEN
|
|
3391
|
+
EXECUTE format(
|
|
3392
|
+
'GRANT EXECUTE ON FUNCTION %I.company_profile_apply_activation(uuid, text, uuid, uuid, uuid, uuid, bigint, text, text, text, text) TO %I',
|
|
3393
|
+
${literal(schema)},
|
|
3394
|
+
${literal(role)}
|
|
3395
|
+
);
|
|
3396
|
+
END IF;
|
|
3397
|
+
IF to_regprocedure(
|
|
3398
|
+
format(
|
|
3399
|
+
'%I.company_profile_get_or_create_snapshot(uuid,uuid,uuid,uuid,uuid,integer)',
|
|
3400
|
+
${literal(schema)}
|
|
3401
|
+
)
|
|
3402
|
+
) IS NOT NULL THEN
|
|
3403
|
+
EXECUTE format(
|
|
3404
|
+
'GRANT EXECUTE ON FUNCTION %I.company_profile_get_or_create_snapshot(uuid, uuid, uuid, uuid, uuid, integer) TO %I',
|
|
3405
|
+
${literal(schema)},
|
|
3406
|
+
${literal(role)}
|
|
3407
|
+
);
|
|
3408
|
+
END IF;
|
|
3409
|
+
IF to_regprocedure(
|
|
3410
|
+
format(
|
|
3411
|
+
'%I.propose_company_profile_for_attempt(uuid,uuid,uuid,uuid,uuid,integer,uuid,text,text,text)',
|
|
3412
|
+
${literal(schema)}
|
|
3413
|
+
)
|
|
3414
|
+
) IS NOT NULL THEN
|
|
3415
|
+
EXECUTE format(
|
|
3416
|
+
'GRANT EXECUTE ON FUNCTION %I.propose_company_profile_for_attempt(uuid, uuid, uuid, uuid, uuid, integer, uuid, text, text, text) TO %I',
|
|
3417
|
+
${literal(schema)},
|
|
3418
|
+
${literal(role)}
|
|
3419
|
+
);
|
|
3420
|
+
END IF;
|
|
3421
|
+
IF to_regprocedure(
|
|
3422
|
+
format(
|
|
3423
|
+
'%I.confirm_company_profile_for_attempt(uuid,uuid,uuid,uuid,uuid,integer,uuid,uuid,uuid)',
|
|
3424
|
+
${literal(schema)}
|
|
3425
|
+
)
|
|
3426
|
+
) IS NOT NULL THEN
|
|
3427
|
+
EXECUTE format(
|
|
3428
|
+
'GRANT EXECUTE ON FUNCTION %I.confirm_company_profile_for_attempt(uuid, uuid, uuid, uuid, uuid, integer, uuid, uuid, uuid) TO %I',
|
|
3429
|
+
${literal(schema)},
|
|
3430
|
+
${literal(role)}
|
|
3431
|
+
);
|
|
3432
|
+
END IF;
|
|
3433
|
+
IF to_regprocedure(
|
|
3434
|
+
format(
|
|
3435
|
+
'%I.workspace_learning_policy_apply_activation(uuid,text,uuid,uuid,uuid,uuid,bigint,text,text,text)',
|
|
3436
|
+
${literal(schema)}
|
|
3437
|
+
)
|
|
3438
|
+
) IS NOT NULL THEN
|
|
3439
|
+
EXECUTE format(
|
|
3440
|
+
'GRANT EXECUTE ON FUNCTION %I.workspace_learning_policy_apply_activation(uuid, text, uuid, uuid, uuid, uuid, bigint, text, text, text) TO %I',
|
|
3441
|
+
${literal(schema)},
|
|
3442
|
+
${literal(role)}
|
|
3443
|
+
);
|
|
3444
|
+
END IF;
|
|
3445
|
+
IF to_regprocedure(
|
|
3446
|
+
format('%I.workspace_learning_policy_source_overrides_valid(jsonb)', ${literal(schema)})
|
|
3447
|
+
) IS NOT NULL THEN
|
|
3448
|
+
EXECUTE format(
|
|
3449
|
+
'GRANT EXECUTE ON FUNCTION %I.workspace_learning_policy_source_overrides_valid(jsonb) TO %I',
|
|
3450
|
+
${literal(schema)},
|
|
3451
|
+
${literal(role)}
|
|
3452
|
+
);
|
|
3453
|
+
END IF;
|
|
3454
|
+
IF to_regprocedure(
|
|
3455
|
+
format('%I.workspace_learning_policy_hash(text,jsonb)', ${literal(schema)})
|
|
3456
|
+
) IS NOT NULL THEN
|
|
3457
|
+
EXECUTE format(
|
|
3458
|
+
'GRANT EXECUTE ON FUNCTION %I.workspace_learning_policy_hash(text, jsonb) TO %I',
|
|
3459
|
+
${literal(schema)},
|
|
3460
|
+
${literal(role)}
|
|
3461
|
+
);
|
|
3462
|
+
END IF;
|
|
3463
|
+
IF to_regprocedure(
|
|
3464
|
+
format(
|
|
3465
|
+
'%I.workspace_learning_policy_get_or_create_snapshot(uuid,uuid,uuid,uuid,uuid,integer)',
|
|
3466
|
+
${literal(schema)}
|
|
3467
|
+
)
|
|
3468
|
+
) IS NOT NULL THEN
|
|
3469
|
+
EXECUTE format(
|
|
3470
|
+
'GRANT EXECUTE ON FUNCTION %I.workspace_learning_policy_get_or_create_snapshot(uuid, uuid, uuid, uuid, uuid, integer) TO %I',
|
|
3471
|
+
${literal(schema)},
|
|
3472
|
+
${literal(role)}
|
|
3473
|
+
);
|
|
3474
|
+
END IF;
|
|
3475
|
+
IF to_regprocedure(
|
|
3476
|
+
format(
|
|
3477
|
+
'%I.slack_task_policy_update(uuid,text,uuid,uuid,jsonb,uuid,bigint,text,text)',
|
|
3478
|
+
${literal(schema)}
|
|
3479
|
+
)
|
|
3480
|
+
) IS NOT NULL THEN
|
|
3481
|
+
EXECUTE format(
|
|
3482
|
+
'GRANT EXECUTE ON FUNCTION %I.slack_task_policy_update(uuid, text, uuid, uuid, jsonb, uuid, bigint, text, text) TO %I',
|
|
3483
|
+
${literal(schema)},
|
|
3484
|
+
${literal(role)}
|
|
3485
|
+
);
|
|
3486
|
+
END IF;
|
|
3487
|
+
IF to_regprocedure(
|
|
3488
|
+
format(
|
|
3489
|
+
'%I.scoped_knowledge_apply_lifecycle(uuid,text,uuid,text,bigint,text,text,text,text,text,text)',
|
|
3490
|
+
${literal(schema)}
|
|
3491
|
+
)
|
|
3492
|
+
) IS NOT NULL THEN
|
|
3493
|
+
EXECUTE format(
|
|
3494
|
+
'GRANT EXECUTE ON FUNCTION %I.scoped_knowledge_apply_lifecycle(uuid, text, uuid, text, bigint, text, text, text, text, text, text) TO %I',
|
|
3495
|
+
${literal(schema)},
|
|
3496
|
+
${literal(role)}
|
|
3497
|
+
);
|
|
3498
|
+
END IF;
|
|
3499
|
+
-- Migration 0197 creates this target-schema-local SECURITY DEFINER lock
|
|
3500
|
+
-- before opengeni_app may exist. Re-converge only its exact EXECUTE grant
|
|
3501
|
+
-- for the supported migrate-then-provision install order; keep PUBLIC
|
|
3502
|
+
-- revoked and do not widen table privileges.
|
|
3503
|
+
IF to_regprocedure(
|
|
3504
|
+
format(
|
|
3505
|
+
'%I.knowledge_source_sync_lock_authority(uuid,uuid,uuid)',
|
|
3506
|
+
${literal(schema)}
|
|
3507
|
+
)
|
|
3508
|
+
) IS NOT NULL THEN
|
|
3509
|
+
EXECUTE format(
|
|
3510
|
+
'REVOKE ALL ON FUNCTION %I.knowledge_source_sync_lock_authority(uuid, uuid, uuid) FROM PUBLIC',
|
|
3511
|
+
${literal(schema)}
|
|
3512
|
+
);
|
|
3513
|
+
EXECUTE format(
|
|
3514
|
+
'GRANT EXECUTE ON FUNCTION %I.knowledge_source_sync_lock_authority(uuid, uuid, uuid) TO %I',
|
|
3515
|
+
${literal(schema)},
|
|
3516
|
+
${literal(role)}
|
|
3517
|
+
);
|
|
3518
|
+
END IF;
|
|
3519
|
+
-- Migration 0243 adds the exact Google Drive object authorization and
|
|
3520
|
+
-- safe-citation projections. Re-converge both capabilities for the same
|
|
3521
|
+
-- supported migrate-then-provision order without granting direct mutation
|
|
3522
|
+
-- of their append-only ACL evidence tables.
|
|
3523
|
+
IF to_regprocedure(
|
|
3524
|
+
format(
|
|
3525
|
+
'%I.google_drive_file_authorized(uuid,uuid,text,uuid)',
|
|
3526
|
+
${literal(schema)}
|
|
3527
|
+
)
|
|
3528
|
+
) IS NOT NULL THEN
|
|
3529
|
+
EXECUTE format(
|
|
3530
|
+
'REVOKE ALL ON FUNCTION %I.google_drive_file_authorized(uuid, uuid, text, uuid) FROM PUBLIC',
|
|
3531
|
+
${literal(schema)}
|
|
3532
|
+
);
|
|
3533
|
+
EXECUTE format(
|
|
3534
|
+
'GRANT EXECUTE ON FUNCTION %I.google_drive_file_authorized(uuid, uuid, text, uuid) TO %I',
|
|
3535
|
+
${literal(schema)},
|
|
3536
|
+
${literal(role)}
|
|
3537
|
+
);
|
|
3538
|
+
END IF;
|
|
3539
|
+
IF to_regprocedure(
|
|
3540
|
+
format(
|
|
3541
|
+
'%I.google_drive_document_citation(uuid,uuid,text,uuid,uuid)',
|
|
3542
|
+
${literal(schema)}
|
|
3543
|
+
)
|
|
3544
|
+
) IS NOT NULL THEN
|
|
3545
|
+
EXECUTE format(
|
|
3546
|
+
'REVOKE ALL ON FUNCTION %I.google_drive_document_citation(uuid, uuid, text, uuid, uuid) FROM PUBLIC',
|
|
3547
|
+
${literal(schema)}
|
|
3548
|
+
);
|
|
3549
|
+
EXECUTE format(
|
|
3550
|
+
'GRANT EXECUTE ON FUNCTION %I.google_drive_document_citation(uuid, uuid, text, uuid, uuid) TO %I',
|
|
3551
|
+
${literal(schema)},
|
|
3552
|
+
${literal(role)}
|
|
3553
|
+
);
|
|
3554
|
+
END IF;
|
|
3555
|
+
IF to_regprocedure(
|
|
3556
|
+
format(
|
|
3557
|
+
'%I.ensure_managed_human_personal_workspace(uuid,text,uuid)',
|
|
3558
|
+
${literal(schema)}
|
|
3559
|
+
)
|
|
3560
|
+
) IS NOT NULL THEN
|
|
3561
|
+
EXECUTE format(
|
|
3562
|
+
'REVOKE ALL ON FUNCTION %I.ensure_managed_human_personal_workspace(uuid, text, uuid) FROM PUBLIC',
|
|
3563
|
+
${literal(schema)}
|
|
3564
|
+
);
|
|
3565
|
+
EXECUTE format(
|
|
3566
|
+
'GRANT EXECUTE ON FUNCTION %I.ensure_managed_human_personal_workspace(uuid, text, uuid) TO %I',
|
|
3567
|
+
${literal(schema)},
|
|
3568
|
+
${literal(role)}
|
|
3569
|
+
);
|
|
3570
|
+
END IF;
|
|
3571
|
+
FOREACH routine_signature IN ARRAY ${organizationMembershipLifecycleRoutines} LOOP
|
|
3572
|
+
IF to_regprocedure(format('%I.%s', ${literal(schema)}, routine_signature)) IS NOT NULL THEN
|
|
3573
|
+
EXECUTE format(
|
|
3574
|
+
'REVOKE ALL ON FUNCTION %I.%s FROM PUBLIC',
|
|
3575
|
+
${literal(schema)}, routine_signature
|
|
3576
|
+
);
|
|
3577
|
+
EXECUTE format(
|
|
3578
|
+
'GRANT EXECUTE ON FUNCTION %I.%s TO %I',
|
|
3579
|
+
${literal(schema)}, routine_signature, ${literal(role)}
|
|
3580
|
+
);
|
|
3581
|
+
END IF;
|
|
3582
|
+
END LOOP;
|
|
3583
|
+
IF to_regprocedure(format('%I.ensure_canonical_human_identity(text,text)', ${literal(schema)})) IS NOT NULL THEN
|
|
3584
|
+
EXECUTE format(
|
|
3585
|
+
'REVOKE ALL ON FUNCTION %I.ensure_canonical_human_identity(text, text) FROM PUBLIC',
|
|
3586
|
+
${literal(schema)}
|
|
3587
|
+
);
|
|
3588
|
+
EXECUTE format(
|
|
3589
|
+
'GRANT EXECUTE ON FUNCTION %I.ensure_canonical_human_identity(text, text) TO %I',
|
|
3590
|
+
${literal(schema)},
|
|
3591
|
+
${literal(role)}
|
|
3592
|
+
);
|
|
3593
|
+
END IF;
|
|
3594
|
+
IF to_regprocedure(format('%I.validate_canonical_human_session(text,text,boolean)', ${literal(schema)})) IS NOT NULL THEN
|
|
3595
|
+
EXECUTE format(
|
|
3596
|
+
'REVOKE ALL ON FUNCTION %I.validate_canonical_human_session(text, text, boolean) FROM PUBLIC',
|
|
3597
|
+
${literal(schema)}
|
|
3598
|
+
);
|
|
3599
|
+
EXECUTE format(
|
|
3600
|
+
'GRANT EXECUTE ON FUNCTION %I.validate_canonical_human_session(text, text, boolean) TO %I',
|
|
3601
|
+
${literal(schema)},
|
|
3602
|
+
${literal(role)}
|
|
3603
|
+
);
|
|
3604
|
+
END IF;
|
|
3605
|
+
IF to_regprocedure(format('%I.get_canonical_human_identity_projection(text)', ${literal(schema)})) IS NOT NULL THEN
|
|
3606
|
+
EXECUTE format(
|
|
3607
|
+
'REVOKE ALL ON FUNCTION %I.get_canonical_human_identity_projection(text) FROM PUBLIC',
|
|
3608
|
+
${literal(schema)}
|
|
3609
|
+
);
|
|
3610
|
+
EXECUTE format(
|
|
3611
|
+
'GRANT EXECUTE ON FUNCTION %I.get_canonical_human_identity_projection(text) TO %I',
|
|
3612
|
+
${literal(schema)},
|
|
3613
|
+
${literal(role)}
|
|
3614
|
+
);
|
|
3615
|
+
END IF;
|
|
3616
|
+
IF to_regprocedure(format('%I.apply_canonical_human_identity_operation(uuid,text,bigint,text,uuid,text,text,text)', ${literal(schema)})) IS NOT NULL THEN
|
|
3617
|
+
EXECUTE format(
|
|
3618
|
+
'REVOKE ALL ON FUNCTION %I.apply_canonical_human_identity_operation(uuid, text, bigint, text, uuid, text, text, text) FROM PUBLIC',
|
|
3619
|
+
${literal(schema)}
|
|
3620
|
+
);
|
|
3621
|
+
EXECUTE format(
|
|
3622
|
+
'GRANT EXECUTE ON FUNCTION %I.apply_canonical_human_identity_operation(uuid, text, bigint, text, uuid, text, text, text) TO %I',
|
|
3623
|
+
${literal(schema)},
|
|
3624
|
+
${literal(role)}
|
|
3625
|
+
);
|
|
3626
|
+
END IF;
|
|
3627
|
+
-- Migration 0225 creates these target-schema-local session visibility
|
|
3628
|
+
-- capabilities before opengeni_app may exist. Re-converge their exact
|
|
3629
|
+
-- EXECUTE grants for migrate-then-provision installs without granting
|
|
3630
|
+
-- blanket execution on target-schema routines.
|
|
3631
|
+
IF to_regprocedure(
|
|
3632
|
+
format(
|
|
3633
|
+
'%I.session_private_actor_visible(uuid,uuid,uuid,text)',
|
|
3634
|
+
${literal(schema)}
|
|
3635
|
+
)
|
|
3636
|
+
) IS NOT NULL THEN
|
|
3637
|
+
EXECUTE format(
|
|
3638
|
+
'REVOKE ALL ON FUNCTION %I.session_private_actor_visible(uuid, uuid, uuid, text) FROM PUBLIC',
|
|
3639
|
+
${literal(schema)}
|
|
3640
|
+
);
|
|
3641
|
+
EXECUTE format(
|
|
3642
|
+
'GRANT EXECUTE ON FUNCTION %I.session_private_actor_visible(uuid, uuid, uuid, text) TO %I',
|
|
3643
|
+
${literal(schema)},
|
|
3644
|
+
${literal(role)}
|
|
3645
|
+
);
|
|
3646
|
+
END IF;
|
|
3647
|
+
IF to_regprocedure(
|
|
3648
|
+
format(
|
|
3649
|
+
'%I.session_reference_visible(uuid,uuid,uuid)',
|
|
3650
|
+
${literal(schema)}
|
|
3651
|
+
)
|
|
3652
|
+
) IS NOT NULL THEN
|
|
3653
|
+
EXECUTE format(
|
|
3654
|
+
'REVOKE ALL ON FUNCTION %I.session_reference_visible(uuid, uuid, uuid) FROM PUBLIC',
|
|
3655
|
+
${literal(schema)}
|
|
3656
|
+
);
|
|
3657
|
+
EXECUTE format(
|
|
3658
|
+
'GRANT EXECUTE ON FUNCTION %I.session_reference_visible(uuid, uuid, uuid) TO %I',
|
|
3659
|
+
${literal(schema)},
|
|
3660
|
+
${literal(role)}
|
|
3661
|
+
);
|
|
3662
|
+
END IF;
|
|
3663
|
+
IF to_regprocedure(
|
|
3664
|
+
format(
|
|
3665
|
+
'%I.transition_session_visibility(uuid,uuid,uuid,text,text,integer,text,text,integer)',
|
|
3666
|
+
${literal(schema)}
|
|
3667
|
+
)
|
|
3668
|
+
) IS NOT NULL THEN
|
|
3669
|
+
EXECUTE format(
|
|
3670
|
+
'REVOKE ALL ON FUNCTION %I.transition_session_visibility(uuid, uuid, uuid, text, text, integer, text, text, integer) FROM PUBLIC',
|
|
3671
|
+
${literal(schema)}
|
|
3672
|
+
);
|
|
3673
|
+
EXECUTE format(
|
|
3674
|
+
'GRANT EXECUTE ON FUNCTION %I.transition_session_visibility(uuid, uuid, uuid, text, text, integer, text, text, integer) TO %I',
|
|
3675
|
+
${literal(schema)},
|
|
3676
|
+
${literal(role)}
|
|
3677
|
+
);
|
|
3678
|
+
END IF;
|
|
3679
|
+
IF to_regprocedure(
|
|
3680
|
+
format(
|
|
3681
|
+
'%I.fork_session_content(uuid,uuid,uuid,text,uuid,text,text,text,integer)',
|
|
3682
|
+
${literal(schema)}
|
|
3683
|
+
)
|
|
3684
|
+
) IS NOT NULL THEN
|
|
3685
|
+
EXECUTE format(
|
|
3686
|
+
'REVOKE ALL ON FUNCTION %I.fork_session_content(uuid, uuid, uuid, text, uuid, text, text, text, integer) FROM PUBLIC',
|
|
3687
|
+
${literal(schema)}
|
|
3688
|
+
);
|
|
3689
|
+
EXECUTE format(
|
|
3690
|
+
'GRANT EXECUTE ON FUNCTION %I.fork_session_content(uuid, uuid, uuid, text, uuid, text, text, text, integer) TO %I',
|
|
3691
|
+
${literal(schema)},
|
|
3692
|
+
${literal(role)}
|
|
3693
|
+
);
|
|
3694
|
+
END IF;
|
|
3695
|
+
IF to_regprocedure(
|
|
3696
|
+
format(
|
|
3697
|
+
'%I.fork_session_content(uuid,uuid,uuid,text,uuid,text,boolean,text,text,integer)',
|
|
3698
|
+
${literal(schema)}
|
|
3699
|
+
)
|
|
3700
|
+
) IS NOT NULL THEN
|
|
3701
|
+
EXECUTE format(
|
|
3702
|
+
'REVOKE ALL ON FUNCTION %I.fork_session_content(uuid, uuid, uuid, text, uuid, text, boolean, text, text, integer) FROM PUBLIC',
|
|
3703
|
+
${literal(schema)}
|
|
3704
|
+
);
|
|
3705
|
+
EXECUTE format(
|
|
3706
|
+
'GRANT EXECUTE ON FUNCTION %I.fork_session_content(uuid, uuid, uuid, text, uuid, text, boolean, text, text, integer) TO %I',
|
|
3707
|
+
${literal(schema)},
|
|
3708
|
+
${literal(role)}
|
|
3709
|
+
);
|
|
3710
|
+
END IF;
|
|
3711
|
+
IF to_regprocedure(
|
|
3712
|
+
format(
|
|
3713
|
+
'%I.replay_applied_session_fork(uuid,uuid,uuid,text,uuid,text,boolean,text,text,integer)',
|
|
3714
|
+
${literal(schema)}
|
|
3715
|
+
)
|
|
3716
|
+
) IS NOT NULL THEN
|
|
3717
|
+
EXECUTE format(
|
|
3718
|
+
'REVOKE ALL ON FUNCTION %I.replay_applied_session_fork(uuid, uuid, uuid, text, uuid, text, boolean, text, text, integer) FROM PUBLIC',
|
|
3719
|
+
${literal(schema)}
|
|
3720
|
+
);
|
|
3721
|
+
EXECUTE format(
|
|
3722
|
+
'GRANT EXECUTE ON FUNCTION %I.replay_applied_session_fork(uuid, uuid, uuid, text, uuid, text, boolean, text, text, integer) TO %I',
|
|
3723
|
+
${literal(schema)},
|
|
3724
|
+
${literal(role)}
|
|
3725
|
+
);
|
|
3726
|
+
END IF;
|
|
3727
|
+
IF to_regprocedure(
|
|
3728
|
+
format('%I.session_tenancy_product_activated(uuid,integer)', ${literal(schema)})
|
|
3729
|
+
) IS NOT NULL THEN
|
|
3730
|
+
EXECUTE format(
|
|
3731
|
+
'REVOKE ALL ON FUNCTION %I.session_tenancy_product_activated(uuid, integer) FROM PUBLIC',
|
|
3732
|
+
${literal(schema)}
|
|
3733
|
+
);
|
|
3734
|
+
EXECUTE format(
|
|
3735
|
+
'GRANT EXECUTE ON FUNCTION %I.session_tenancy_product_activated(uuid, integer) TO %I',
|
|
3736
|
+
${literal(schema)},
|
|
3737
|
+
${literal(role)}
|
|
3738
|
+
);
|
|
3739
|
+
EXECUTE format(
|
|
3740
|
+
'REVOKE ALL ON FUNCTION %I.session_tenancy_any_product_activation() FROM PUBLIC',
|
|
3741
|
+
${literal(schema)}
|
|
3742
|
+
);
|
|
3743
|
+
EXECUTE format(
|
|
3744
|
+
'GRANT EXECUTE ON FUNCTION %I.session_tenancy_any_product_activation() TO %I',
|
|
3745
|
+
${literal(schema)},
|
|
3746
|
+
${literal(role)}
|
|
3747
|
+
);
|
|
3748
|
+
EXECUTE format(
|
|
3749
|
+
'REVOKE ALL ON FUNCTION %I.assert_session_tenancy_quiescent(uuid, uuid, uuid, boolean) FROM PUBLIC',
|
|
3750
|
+
${literal(schema)}
|
|
3751
|
+
);
|
|
3752
|
+
EXECUTE format(
|
|
3753
|
+
'REVOKE ALL ON FUNCTION %I.assert_session_tenancy_quiescent(uuid, uuid, uuid, boolean) FROM %I',
|
|
3754
|
+
${literal(schema)},
|
|
3755
|
+
${literal(role)}
|
|
3756
|
+
);
|
|
3757
|
+
END IF;
|
|
3758
|
+
IF to_regprocedure(
|
|
3759
|
+
format('%I.get_private_session_create_policy(uuid,uuid,text)', ${literal(schema)})
|
|
3760
|
+
) IS NOT NULL THEN
|
|
3761
|
+
EXECUTE format(
|
|
3762
|
+
'REVOKE ALL ON FUNCTION %I.get_private_session_create_policy(uuid, uuid, text) FROM PUBLIC',
|
|
3763
|
+
${literal(schema)}
|
|
3764
|
+
);
|
|
3765
|
+
EXECUTE format(
|
|
3766
|
+
'GRANT EXECUTE ON FUNCTION %I.get_private_session_create_policy(uuid, uuid, text) TO %I',
|
|
3767
|
+
${literal(schema)}, ${literal(role)}
|
|
3768
|
+
);
|
|
3769
|
+
END IF;
|
|
3770
|
+
IF to_regprocedure(
|
|
3771
|
+
format('%I.get_organization_private_session_settings(uuid,text)', ${literal(schema)})
|
|
3772
|
+
) IS NOT NULL THEN
|
|
3773
|
+
EXECUTE format(
|
|
3774
|
+
'REVOKE ALL ON FUNCTION %I.get_organization_private_session_settings(uuid, text) FROM PUBLIC',
|
|
3775
|
+
${literal(schema)}
|
|
3776
|
+
);
|
|
3777
|
+
EXECUTE format(
|
|
3778
|
+
'GRANT EXECUTE ON FUNCTION %I.get_organization_private_session_settings(uuid, text) TO %I',
|
|
3779
|
+
${literal(schema)}, ${literal(role)}
|
|
3780
|
+
);
|
|
3781
|
+
END IF;
|
|
3782
|
+
IF to_regprocedure(
|
|
3783
|
+
format(
|
|
3784
|
+
'%I.update_organization_private_session_settings(uuid,text,boolean,bigint,uuid)',
|
|
3785
|
+
${literal(schema)}
|
|
3786
|
+
)
|
|
3787
|
+
) IS NOT NULL THEN
|
|
3788
|
+
EXECUTE format(
|
|
3789
|
+
'REVOKE ALL ON FUNCTION %I.update_organization_private_session_settings(uuid, text, boolean, bigint, uuid) FROM PUBLIC',
|
|
3790
|
+
${literal(schema)}
|
|
3791
|
+
);
|
|
3792
|
+
EXECUTE format(
|
|
3793
|
+
'GRANT EXECUTE ON FUNCTION %I.update_organization_private_session_settings(uuid, text, boolean, bigint, uuid) TO %I',
|
|
3794
|
+
${literal(schema)}, ${literal(role)}
|
|
3795
|
+
);
|
|
3796
|
+
END IF;
|
|
3797
|
+
IF to_regprocedure(
|
|
3798
|
+
format('%I.organization_private_sessions_enabled(uuid)', ${literal(schema)})
|
|
3799
|
+
) IS NOT NULL THEN
|
|
3800
|
+
EXECUTE format(
|
|
3801
|
+
'REVOKE ALL ON FUNCTION %I.organization_private_sessions_enabled(uuid) FROM PUBLIC',
|
|
3802
|
+
${literal(schema)}
|
|
3803
|
+
);
|
|
3804
|
+
EXECUTE format(
|
|
3805
|
+
'REVOKE ALL ON FUNCTION %I.organization_private_sessions_enabled(uuid) FROM %I',
|
|
3806
|
+
${literal(schema)}, ${literal(role)}
|
|
3807
|
+
);
|
|
3808
|
+
END IF;
|
|
3809
|
+
IF to_regprocedure(
|
|
3810
|
+
format('%I.open_private_session_create_capability(uuid,uuid,uuid,text)', ${literal(schema)})
|
|
3811
|
+
) IS NOT NULL THEN
|
|
3812
|
+
EXECUTE format(
|
|
3813
|
+
'REVOKE ALL ON FUNCTION %I.open_private_session_create_capability(uuid, uuid, uuid, text) FROM PUBLIC',
|
|
3814
|
+
${literal(schema)}
|
|
3815
|
+
);
|
|
3816
|
+
EXECUTE format(
|
|
3817
|
+
'GRANT EXECUTE ON FUNCTION %I.open_private_session_create_capability(uuid, uuid, uuid, text) TO %I',
|
|
3818
|
+
${literal(schema)}, ${literal(role)}
|
|
3819
|
+
);
|
|
3820
|
+
EXECUTE format(
|
|
3821
|
+
'REVOKE ALL ON FUNCTION %I.close_private_session_create_capability(uuid) FROM PUBLIC',
|
|
3822
|
+
${literal(schema)}
|
|
3823
|
+
);
|
|
3824
|
+
EXECUTE format(
|
|
3825
|
+
'GRANT EXECUTE ON FUNCTION %I.close_private_session_create_capability(uuid) TO %I',
|
|
3826
|
+
${literal(schema)}, ${literal(role)}
|
|
3827
|
+
);
|
|
3828
|
+
END IF;
|
|
3829
|
+
IF to_regprocedure(
|
|
3830
|
+
format(
|
|
3831
|
+
'%I.open_private_child_session_create_capability(uuid,uuid,uuid,uuid,uuid,uuid,integer)',
|
|
3832
|
+
${literal(schema)}
|
|
3833
|
+
)
|
|
3834
|
+
) IS NOT NULL THEN
|
|
3835
|
+
EXECUTE format(
|
|
3836
|
+
'REVOKE ALL ON FUNCTION %I.open_private_child_session_create_capability(uuid,uuid,uuid,uuid,uuid,uuid,integer) FROM PUBLIC',
|
|
3837
|
+
${literal(schema)}
|
|
3838
|
+
);
|
|
3839
|
+
EXECUTE format(
|
|
3840
|
+
'GRANT EXECUTE ON FUNCTION %I.open_private_child_session_create_capability(uuid,uuid,uuid,uuid,uuid,uuid,integer) TO %I',
|
|
3841
|
+
${literal(schema)}, ${literal(role)}
|
|
3842
|
+
);
|
|
3843
|
+
END IF;
|
|
3844
|
+
IF to_regprocedure(
|
|
3845
|
+
format(
|
|
3846
|
+
'%I.create_xai_subscription_credential(uuid,uuid,text,text,text,text,text,text,text,timestamptz)',
|
|
3847
|
+
${literal(schema)}
|
|
3848
|
+
)
|
|
3849
|
+
) IS NOT NULL THEN
|
|
3850
|
+
EXECUTE format(
|
|
3851
|
+
'REVOKE ALL ON FUNCTION %I.create_xai_subscription_credential(uuid, uuid, text, text, text, text, text, text, text, timestamptz) FROM PUBLIC',
|
|
3852
|
+
${literal(schema)}
|
|
3853
|
+
);
|
|
3854
|
+
EXECUTE format(
|
|
3855
|
+
'GRANT EXECUTE ON FUNCTION %I.create_xai_subscription_credential(uuid, uuid, text, text, text, text, text, text, text, timestamptz) TO %I',
|
|
3856
|
+
${literal(schema)},
|
|
3857
|
+
${literal(role)}
|
|
3858
|
+
);
|
|
3859
|
+
EXECUTE format(
|
|
3860
|
+
'REVOKE ALL ON FUNCTION %I.disconnect_xai_subscription_credential(uuid, uuid, text, uuid, jsonb) FROM PUBLIC',
|
|
3861
|
+
${literal(schema)}
|
|
3862
|
+
);
|
|
3863
|
+
EXECUTE format(
|
|
3864
|
+
'GRANT EXECUTE ON FUNCTION %I.disconnect_xai_subscription_credential(uuid, uuid, text, uuid, jsonb) TO %I',
|
|
3865
|
+
${literal(schema)},
|
|
3866
|
+
${literal(role)}
|
|
3867
|
+
);
|
|
3868
|
+
EXECUTE format(
|
|
3869
|
+
'REVOKE ALL ON FUNCTION %I.resolve_xai_authority_pool(uuid, uuid, text, jsonb) FROM PUBLIC',
|
|
3870
|
+
${literal(schema)}
|
|
3871
|
+
);
|
|
3872
|
+
EXECUTE format(
|
|
3873
|
+
'GRANT EXECUTE ON FUNCTION %I.resolve_xai_authority_pool(uuid, uuid, text, jsonb) TO %I',
|
|
3874
|
+
${literal(schema)},
|
|
3875
|
+
${literal(role)}
|
|
3876
|
+
);
|
|
3877
|
+
EXECUTE format(
|
|
3878
|
+
'REVOKE ALL ON FUNCTION %I.revalidate_xai_subscription_authority(uuid, text, uuid, jsonb) FROM PUBLIC',
|
|
3879
|
+
${literal(schema)}
|
|
3880
|
+
);
|
|
3881
|
+
EXECUTE format(
|
|
3882
|
+
'GRANT EXECUTE ON FUNCTION %I.revalidate_xai_subscription_authority(uuid, text, uuid, jsonb) TO %I',
|
|
3883
|
+
${literal(schema)},
|
|
3884
|
+
${literal(role)}
|
|
3885
|
+
);
|
|
3886
|
+
EXECUTE format(
|
|
3887
|
+
'REVOKE ALL ON FUNCTION %I.xai_provider_account_authority_snapshot_v1_valid(jsonb) FROM PUBLIC',
|
|
3888
|
+
${literal(schema)}
|
|
3889
|
+
);
|
|
3890
|
+
EXECUTE format(
|
|
3891
|
+
'GRANT EXECUTE ON FUNCTION %I.xai_provider_account_authority_snapshot_v1_valid(jsonb) TO %I',
|
|
3892
|
+
${literal(schema)},
|
|
3893
|
+
${literal(role)}
|
|
3894
|
+
);
|
|
3895
|
+
EXECUTE format(
|
|
3896
|
+
'REVOKE ALL ON FUNCTION %I.xai_subscription_authority_live(uuid, uuid, text, uuid, text, uuid, uuid, bigint) FROM PUBLIC',
|
|
3897
|
+
${literal(schema)}
|
|
3898
|
+
);
|
|
3899
|
+
EXECUTE format(
|
|
3900
|
+
'GRANT EXECUTE ON FUNCTION %I.xai_subscription_authority_live(uuid, uuid, text, uuid, text, uuid, uuid, bigint) TO %I',
|
|
3901
|
+
${literal(schema)},
|
|
3902
|
+
${literal(role)}
|
|
3903
|
+
);
|
|
3904
|
+
EXECUTE format(
|
|
3905
|
+
'REVOKE ALL ON FUNCTION %I.xai_subscription_pool_visible(uuid, uuid, text, text, uuid) FROM PUBLIC',
|
|
3906
|
+
${literal(schema)}
|
|
3907
|
+
);
|
|
3908
|
+
EXECUTE format(
|
|
3909
|
+
'GRANT EXECUTE ON FUNCTION %I.xai_subscription_pool_visible(uuid, uuid, text, text, uuid) TO %I',
|
|
3910
|
+
${literal(schema)},
|
|
3911
|
+
${literal(role)}
|
|
3912
|
+
);
|
|
3913
|
+
END IF;
|
|
3914
|
+
IF to_regprocedure(
|
|
3915
|
+
format(
|
|
3916
|
+
'%I.resolve_session_attempt_personal_resources(uuid,uuid,uuid)',
|
|
3917
|
+
${literal(schema)}
|
|
3918
|
+
)
|
|
3919
|
+
) IS NOT NULL THEN
|
|
3920
|
+
EXECUTE format(
|
|
3921
|
+
'REVOKE ALL ON FUNCTION %I.resolve_session_attempt_personal_resources(uuid, uuid, uuid) FROM PUBLIC',
|
|
3922
|
+
${literal(schema)}
|
|
3923
|
+
);
|
|
3924
|
+
EXECUTE format(
|
|
3925
|
+
'GRANT EXECUTE ON FUNCTION %I.resolve_session_attempt_personal_resources(uuid, uuid, uuid) TO %I',
|
|
3926
|
+
${literal(schema)},
|
|
3927
|
+
${literal(role)}
|
|
3928
|
+
);
|
|
3929
|
+
END IF;
|
|
3930
|
+
IF to_regprocedure(
|
|
3931
|
+
format(
|
|
3932
|
+
'%I.accept_turn_personal_resource_attachment(uuid,uuid,uuid,uuid,text,integer,boolean,integer)',
|
|
3933
|
+
${literal(schema)}
|
|
3934
|
+
)
|
|
3935
|
+
) IS NOT NULL THEN
|
|
3936
|
+
EXECUTE format(
|
|
3937
|
+
'REVOKE ALL ON FUNCTION %I.accept_turn_personal_resource_attachment(uuid, uuid, uuid, uuid, text, integer, boolean, integer) FROM PUBLIC',
|
|
3938
|
+
${literal(schema)}
|
|
3939
|
+
);
|
|
3940
|
+
EXECUTE format(
|
|
3941
|
+
'GRANT EXECUTE ON FUNCTION %I.accept_turn_personal_resource_attachment(uuid, uuid, uuid, uuid, text, integer, boolean, integer) TO %I',
|
|
3942
|
+
${literal(schema)},
|
|
3943
|
+
${literal(role)}
|
|
3944
|
+
);
|
|
3945
|
+
END IF;
|
|
3946
|
+
IF to_regprocedure(format('%I.list_self_user_resource_authorities(uuid,uuid,text,uuid,integer)', ${literal(schema)}))
|
|
3947
|
+
IS NOT NULL THEN
|
|
3948
|
+
EXECUTE format('REVOKE ALL ON FUNCTION %I.list_self_user_resource_authorities(uuid) FROM PUBLIC', ${literal(schema)});
|
|
3949
|
+
EXECUTE format('REVOKE ALL ON FUNCTION %I.list_self_user_resource_authorities(uuid) FROM %I', ${literal(schema)}, ${literal(role)});
|
|
3950
|
+
EXECUTE format('REVOKE ALL ON FUNCTION %I.issue_self_user_resource_grant(uuid, uuid, uuid, text, text, text, uuid, boolean) FROM PUBLIC', ${literal(schema)});
|
|
3951
|
+
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)});
|
|
3952
|
+
EXECUTE format('REVOKE ALL ON FUNCTION %I.revoke_self_user_resource_grant(uuid, uuid) FROM PUBLIC', ${literal(schema)});
|
|
3953
|
+
EXECUTE format('REVOKE ALL ON FUNCTION %I.revoke_self_user_resource_grant(uuid, uuid) FROM %I', ${literal(schema)}, ${literal(role)});
|
|
3954
|
+
EXECUTE format('REVOKE ALL ON FUNCTION %I.list_self_user_resource_authorities(uuid, uuid, text, uuid, integer) FROM PUBLIC', ${literal(schema)});
|
|
3955
|
+
EXECUTE format('GRANT EXECUTE ON FUNCTION %I.list_self_user_resource_authorities(uuid, uuid, text, uuid, integer) TO %I', ${literal(schema)}, ${literal(role)});
|
|
3956
|
+
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)});
|
|
3957
|
+
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)});
|
|
3958
|
+
EXECUTE format('REVOKE ALL ON FUNCTION %I.revoke_self_user_resource_grant(uuid, uuid, uuid) FROM PUBLIC', ${literal(schema)});
|
|
3959
|
+
EXECUTE format('GRANT EXECUTE ON FUNCTION %I.revoke_self_user_resource_grant(uuid, uuid, uuid) TO %I', ${literal(schema)}, ${literal(role)});
|
|
3960
|
+
EXECUTE format('REVOKE ALL ON FUNCTION %I.authorize_session_attempt_personal_resource_reads(uuid, uuid, uuid) FROM PUBLIC', ${literal(schema)});
|
|
3961
|
+
EXECUTE format('GRANT EXECUTE ON FUNCTION %I.authorize_session_attempt_personal_resource_reads(uuid, uuid, uuid) TO %I', ${literal(schema)}, ${literal(role)});
|
|
3962
|
+
END IF;
|
|
3963
|
+
IF to_regprocedure(format('%I.resolve_connection_use_authority(uuid,uuid,uuid,jsonb)', ${literal(schema)}))
|
|
3964
|
+
IS NOT NULL THEN
|
|
3965
|
+
EXECUTE format('REVOKE ALL ON FUNCTION %I.list_self_connection_authorities(uuid) FROM PUBLIC', ${literal(schema)});
|
|
3966
|
+
EXECUTE format('REVOKE ALL ON FUNCTION %I.list_self_connection_authorities(uuid) FROM %I', ${literal(schema)}, ${literal(role)});
|
|
3967
|
+
EXECUTE format('REVOKE ALL ON FUNCTION %I.issue_self_connection_use_grant(uuid, uuid, uuid, text, text, uuid, boolean) FROM PUBLIC', ${literal(schema)});
|
|
3968
|
+
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)});
|
|
3969
|
+
EXECUTE format('REVOKE ALL ON FUNCTION %I.revoke_self_connection_use_grant(uuid, uuid) FROM PUBLIC', ${literal(schema)});
|
|
3970
|
+
EXECUTE format('REVOKE ALL ON FUNCTION %I.revoke_self_connection_use_grant(uuid, uuid) FROM %I', ${literal(schema)}, ${literal(role)});
|
|
3971
|
+
EXECUTE format('REVOKE ALL ON FUNCTION %I.resolve_connection_use_authority(uuid, uuid, uuid, jsonb) FROM PUBLIC', ${literal(schema)});
|
|
3972
|
+
EXECUTE format('GRANT EXECUTE ON FUNCTION %I.resolve_connection_use_authority(uuid, uuid, uuid, jsonb) TO %I', ${literal(schema)}, ${literal(role)});
|
|
3973
|
+
IF to_regprocedure(format('%I.resolve_personal_connection_authority_selection(uuid,uuid,text,uuid,jsonb)', ${literal(schema)})) IS NOT NULL THEN
|
|
3974
|
+
EXECUTE format('REVOKE ALL ON FUNCTION %I.resolve_personal_connection_authority_selection(uuid, uuid, text, uuid, jsonb) FROM PUBLIC', ${literal(schema)});
|
|
3975
|
+
EXECUTE format('GRANT EXECUTE ON FUNCTION %I.resolve_personal_connection_authority_selection(uuid, uuid, text, uuid, jsonb) TO %I', ${literal(schema)}, ${literal(role)});
|
|
3976
|
+
END IF;
|
|
3977
|
+
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
|
|
3978
|
+
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)});
|
|
3979
|
+
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)});
|
|
3980
|
+
END IF;
|
|
3981
|
+
END IF;
|
|
3982
|
+
IF to_regprocedure(
|
|
3983
|
+
format('%I.get_self_personal_github_repository_selection(uuid,uuid,text,uuid)', ${literal(schema)})
|
|
3984
|
+
) IS NOT NULL THEN
|
|
3985
|
+
EXECUTE format(
|
|
3986
|
+
'REVOKE ALL ON FUNCTION %I.get_self_personal_github_repository_selection(uuid,uuid,text,uuid) FROM PUBLIC',
|
|
3987
|
+
${literal(schema)}
|
|
3988
|
+
);
|
|
3989
|
+
EXECUTE format(
|
|
3990
|
+
'GRANT EXECUTE ON FUNCTION %I.get_self_personal_github_repository_selection(uuid,uuid,text,uuid) TO %I',
|
|
3991
|
+
${literal(schema)}, ${literal(role)}
|
|
3992
|
+
);
|
|
3993
|
+
EXECUTE format(
|
|
3994
|
+
'REVOKE ALL ON FUNCTION %I.mutate_self_personal_github_repository_selection(uuid,uuid,text,uuid,bigint,bigint,text,jsonb,boolean) FROM PUBLIC',
|
|
3995
|
+
${literal(schema)}
|
|
3996
|
+
);
|
|
3997
|
+
EXECUTE format(
|
|
3998
|
+
'GRANT EXECUTE ON FUNCTION %I.mutate_self_personal_github_repository_selection(uuid,uuid,text,uuid,bigint,bigint,text,jsonb,boolean) TO %I',
|
|
3999
|
+
${literal(schema)}, ${literal(role)}
|
|
4000
|
+
);
|
|
4001
|
+
EXECUTE format(
|
|
4002
|
+
'REVOKE ALL PRIVILEGES ON TABLE %I.personal_github_repository_selection_heads, %I.personal_github_repository_selections, %I.personal_github_repository_selection_operations FROM %I',
|
|
4003
|
+
${literal(schema)}, ${literal(schema)}, ${literal(schema)}, ${literal(role)}
|
|
4004
|
+
);
|
|
4005
|
+
END IF;
|
|
4006
|
+
IF to_regprocedure(
|
|
4007
|
+
format('%I.create_personal_document_authority(uuid,uuid,uuid)', ${literal(schema)})
|
|
4008
|
+
) IS NOT NULL THEN
|
|
4009
|
+
EXECUTE format('REVOKE ALL ON FUNCTION %I.create_personal_document_authority(uuid, uuid, uuid) FROM PUBLIC', ${literal(schema)});
|
|
4010
|
+
EXECUTE format('GRANT EXECUTE ON FUNCTION %I.create_personal_document_authority(uuid, uuid, uuid) TO %I', ${literal(schema)}, ${literal(role)});
|
|
4011
|
+
EXECUTE format('REVOKE ALL ON FUNCTION %I.resolve_document_original_file(uuid, uuid, text, uuid) FROM PUBLIC', ${literal(schema)});
|
|
4012
|
+
EXECUTE format('GRANT EXECUTE ON FUNCTION %I.resolve_document_original_file(uuid, uuid, text, uuid) TO %I', ${literal(schema)}, ${literal(role)});
|
|
4013
|
+
EXECUTE format('REVOKE ALL ON FUNCTION %I.prepare_session_attempt_personal_document_reads(uuid, uuid, uuid, uuid) FROM PUBLIC', ${literal(schema)});
|
|
4014
|
+
EXECUTE format('REVOKE ALL ON FUNCTION %I.prepare_session_attempt_personal_document_reads(uuid, uuid, uuid, uuid) FROM %I', ${literal(schema)}, ${literal(role)});
|
|
4015
|
+
EXECUTE format('REVOKE ALL ON FUNCTION %I.resolve_session_attempt_personal_document_reads(uuid, uuid, uuid, uuid) FROM PUBLIC', ${literal(schema)});
|
|
4016
|
+
EXECUTE format('GRANT EXECUTE ON FUNCTION %I.resolve_session_attempt_personal_document_reads(uuid, uuid, uuid, uuid) TO %I', ${literal(schema)}, ${literal(role)});
|
|
4017
|
+
EXECUTE format('REVOKE ALL ON FUNCTION opengeni_private.personal_document_authority_capability_active(text) FROM PUBLIC');
|
|
4018
|
+
EXECUTE format('GRANT EXECUTE ON FUNCTION opengeni_private.personal_document_authority_capability_active(text) TO %I', ${literal(role)});
|
|
4019
|
+
EXECUTE format('REVOKE ALL PRIVILEGES ON TABLE opengeni_private.personal_document_authority_capabilities FROM %I', ${literal(role)});
|
|
4020
|
+
EXECUTE format('REVOKE ALL PRIVILEGES ON TABLE %I.session_attempt_personal_document_admissions FROM %I', ${literal(schema)}, ${literal(role)});
|
|
4021
|
+
EXECUTE format('REVOKE ALL PRIVILEGES ON TABLE %I.session_attempt_personal_document_snapshots FROM %I', ${literal(schema)}, ${literal(role)});
|
|
4022
|
+
EXECUTE format('REVOKE ALL PRIVILEGES ON TABLE %I.personal_document_once_consumption_receipts FROM %I', ${literal(schema)}, ${literal(role)});
|
|
4023
|
+
END IF;
|
|
4024
|
+
IF to_regprocedure(
|
|
4025
|
+
format('%I.reclassify_document_authority(jsonb)', ${literal(schema)})
|
|
4026
|
+
) IS NOT NULL THEN
|
|
4027
|
+
EXECUTE format('REVOKE ALL ON FUNCTION %I.reclassify_document_authority(jsonb) FROM PUBLIC', ${literal(schema)});
|
|
4028
|
+
EXECUTE format('GRANT EXECUTE ON FUNCTION %I.reclassify_document_authority(jsonb) TO %I', ${literal(schema)}, ${literal(role)});
|
|
4029
|
+
EXECUTE format('REVOKE ALL ON FUNCTION %I.list_document_authority_reclassifications(uuid, uuid, text, uuid, integer, timestamptz, uuid) FROM PUBLIC', ${literal(schema)});
|
|
4030
|
+
EXECUTE format('GRANT EXECUTE ON FUNCTION %I.list_document_authority_reclassifications(uuid, uuid, text, uuid, integer, timestamptz, uuid) TO %I', ${literal(schema)}, ${literal(role)});
|
|
4031
|
+
EXECUTE format('REVOKE ALL ON FUNCTION %I.run_document_default_collection_backfill(jsonb) FROM PUBLIC', ${literal(schema)});
|
|
4032
|
+
EXECUTE format('GRANT EXECUTE ON FUNCTION %I.run_document_default_collection_backfill(jsonb) TO %I', ${literal(schema)}, ${literal(role)});
|
|
4033
|
+
EXECUTE format('REVOKE ALL ON FUNCTION opengeni_private.document_migration_capability_active(text) FROM PUBLIC');
|
|
4034
|
+
EXECUTE format('GRANT EXECUTE ON FUNCTION opengeni_private.document_migration_capability_active(text) TO %I', ${literal(role)});
|
|
4035
|
+
EXECUTE format('REVOKE ALL PRIVILEGES ON TABLE opengeni_private.document_migration_capabilities FROM %I', ${literal(role)});
|
|
4036
|
+
EXECUTE format('GRANT SELECT ON TABLE %I.document_authority_reclassifications TO %I', ${literal(schema)}, ${literal(role)});
|
|
4037
|
+
EXECUTE format('REVOKE INSERT, UPDATE, DELETE ON TABLE %I.document_authority_reclassifications FROM %I', ${literal(schema)}, ${literal(role)});
|
|
4038
|
+
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)});
|
|
4039
|
+
IF to_regprocedure(
|
|
4040
|
+
format('%I.list_document_default_collection_backfill_runs(jsonb)', ${literal(schema)})
|
|
4041
|
+
) IS NOT NULL THEN
|
|
4042
|
+
EXECUTE format('REVOKE ALL ON FUNCTION %I.list_document_default_collection_backfill_runs(jsonb) FROM PUBLIC', ${literal(schema)});
|
|
4043
|
+
EXECUTE format('GRANT EXECUTE ON FUNCTION %I.list_document_default_collection_backfill_runs(jsonb) TO %I', ${literal(schema)}, ${literal(role)});
|
|
4044
|
+
EXECUTE format('REVOKE ALL ON FUNCTION %I.get_document_default_collection_backfill_audit(jsonb) FROM PUBLIC', ${literal(schema)});
|
|
4045
|
+
EXECUTE format('GRANT EXECUTE ON FUNCTION %I.get_document_default_collection_backfill_audit(jsonb) TO %I', ${literal(schema)}, ${literal(role)});
|
|
4046
|
+
EXECUTE format('REVOKE ALL ON FUNCTION %I.list_organization_document_authority_reclassifications(jsonb) FROM PUBLIC', ${literal(schema)});
|
|
4047
|
+
EXECUTE format('GRANT EXECUTE ON FUNCTION %I.list_organization_document_authority_reclassifications(jsonb) TO %I', ${literal(schema)}, ${literal(role)});
|
|
4048
|
+
EXECUTE format('REVOKE ALL ON FUNCTION %I.document_migration_audit_capability_active(text) FROM PUBLIC', ${literal(schema)});
|
|
4049
|
+
EXECUTE format('REVOKE ALL ON FUNCTION %I.document_migration_audit_capability_active(text) FROM %I', ${literal(schema)}, ${literal(role)});
|
|
4050
|
+
EXECUTE format('REVOKE ALL ON FUNCTION %I.assert_document_migration_audit_authority(jsonb) FROM PUBLIC', ${literal(schema)});
|
|
4051
|
+
EXECUTE format('REVOKE ALL ON FUNCTION %I.assert_document_migration_audit_authority(jsonb) FROM %I', ${literal(schema)}, ${literal(role)});
|
|
4052
|
+
EXECUTE format('REVOKE ALL PRIVILEGES ON TABLE %I.document_migration_audit_capabilities FROM %I', ${literal(schema)}, ${literal(role)});
|
|
4053
|
+
END IF;
|
|
4054
|
+
END IF;
|
|
4055
|
+
IF to_regprocedure(
|
|
4056
|
+
format('%I.create_scoped_variable_set(uuid,uuid,text,text,text,jsonb,boolean)', ${literal(schema)})
|
|
4057
|
+
) IS NOT NULL THEN
|
|
4058
|
+
EXECUTE format('GRANT EXECUTE ON FUNCTION %I.create_scoped_variable_set(uuid, uuid, text, text, text, jsonb, boolean) TO %I', ${literal(schema)}, ${literal(role)});
|
|
4059
|
+
EXECUTE format('GRANT EXECUTE ON FUNCTION %I.list_scoped_variable_sets(uuid, uuid, uuid, text, text) TO %I', ${literal(schema)}, ${literal(role)});
|
|
4060
|
+
EXECUTE format('GRANT EXECUTE ON FUNCTION %I.count_scoped_variable_sets(uuid, uuid, text) TO %I', ${literal(schema)}, ${literal(role)});
|
|
4061
|
+
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)});
|
|
4062
|
+
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)});
|
|
4063
|
+
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)});
|
|
4064
|
+
EXECUTE format('GRANT EXECUTE ON FUNCTION %I.materialize_scoped_variable_set_for_session(uuid, uuid, uuid, uuid) TO %I', ${literal(schema)}, ${literal(role)});
|
|
4065
|
+
EXECUTE format('REVOKE ALL PRIVILEGES ON TABLE %I.workspace_variable_sets FROM %I', ${literal(schema)}, ${literal(role)});
|
|
4066
|
+
EXECUTE format('REVOKE ALL PRIVILEGES ON TABLE %I.workspace_variable_set_variables FROM %I', ${literal(schema)}, ${literal(role)});
|
|
4067
|
+
END IF;
|
|
4068
|
+
IF to_regprocedure(
|
|
4069
|
+
format('%I.create_scoped_rig(uuid,uuid,text,text,text,text,jsonb,boolean)', ${literal(schema)})
|
|
4070
|
+
) IS NOT NULL THEN
|
|
4071
|
+
EXECUTE format('GRANT EXECUTE ON FUNCTION %I.create_scoped_rig(uuid, uuid, text, text, text, text, jsonb, boolean) TO %I', ${literal(schema)}, ${literal(role)});
|
|
4072
|
+
EXECUTE format('GRANT EXECUTE ON FUNCTION %I.list_scoped_rigs(uuid, uuid, uuid, text, text) TO %I', ${literal(schema)}, ${literal(role)});
|
|
4073
|
+
EXECUTE format('GRANT EXECUTE ON FUNCTION %I.count_scoped_rigs(uuid, uuid, text) TO %I', ${literal(schema)}, ${literal(role)});
|
|
4074
|
+
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)});
|
|
4075
|
+
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)});
|
|
4076
|
+
EXECUTE format('GRANT EXECUTE ON FUNCTION %I.list_scoped_enrollments(uuid, uuid, uuid, text) TO %I', ${literal(schema)}, ${literal(role)});
|
|
4077
|
+
EXECUTE format('GRANT EXECUTE ON FUNCTION %I.get_scoped_sandbox(uuid, uuid, uuid) TO %I', ${literal(schema)}, ${literal(role)});
|
|
4078
|
+
EXECUTE format('GRANT EXECUTE ON FUNCTION %I.authorize_scoped_sandbox_attach(uuid, uuid, uuid) TO %I', ${literal(schema)}, ${literal(role)});
|
|
4079
|
+
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)});
|
|
4080
|
+
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)});
|
|
4081
|
+
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)});
|
|
4082
|
+
EXECUTE format('GRANT EXECUTE ON FUNCTION %I.list_scoped_machine_dependent_sessions(uuid, uuid, uuid) TO %I', ${literal(schema)}, ${literal(role)});
|
|
4083
|
+
EXECUTE format('GRANT EXECUTE ON FUNCTION %I.detach_scoped_machine_dependent_sessions(uuid, uuid, uuid) TO %I', ${literal(schema)}, ${literal(role)});
|
|
4084
|
+
EXECUTE format('REVOKE ALL PRIVILEGES ON TABLE %I.session_attempt_connected_machine_authorizations FROM %I', ${literal(schema)}, ${literal(role)});
|
|
4085
|
+
END IF;
|
|
4086
|
+
IF to_regprocedure(
|
|
4087
|
+
format(
|
|
4088
|
+
'%I.freeze_scheduled_task_personal_resources(uuid,uuid,uuid,bigint)',
|
|
4089
|
+
${literal(schema)}
|
|
4090
|
+
)
|
|
4091
|
+
) IS NOT NULL THEN
|
|
4092
|
+
EXECUTE format(
|
|
4093
|
+
'REVOKE ALL ON FUNCTION %I.freeze_scheduled_task_personal_resources(uuid, uuid, uuid, bigint) FROM PUBLIC',
|
|
4094
|
+
${literal(schema)}
|
|
4095
|
+
);
|
|
4096
|
+
EXECUTE format(
|
|
4097
|
+
'GRANT EXECUTE ON FUNCTION %I.freeze_scheduled_task_personal_resources(uuid, uuid, uuid, bigint) TO %I',
|
|
4098
|
+
${literal(schema)},
|
|
4099
|
+
${literal(role)}
|
|
4100
|
+
);
|
|
4101
|
+
EXECUTE format(
|
|
4102
|
+
'REVOKE ALL ON FUNCTION %I.clone_scheduled_task_personal_resource_authority(uuid, uuid, uuid, bigint, bigint) FROM PUBLIC',
|
|
4103
|
+
${literal(schema)}
|
|
4104
|
+
);
|
|
4105
|
+
EXECUTE format(
|
|
4106
|
+
'GRANT EXECUTE ON FUNCTION %I.clone_scheduled_task_personal_resource_authority(uuid, uuid, uuid, bigint, bigint) TO %I',
|
|
4107
|
+
${literal(schema)},
|
|
4108
|
+
${literal(role)}
|
|
4109
|
+
);
|
|
4110
|
+
IF to_regprocedure(
|
|
4111
|
+
format(
|
|
4112
|
+
'%I.refresh_scheduled_task_personal_resources_clone_connections(uuid,uuid,uuid,bigint,bigint)',
|
|
4113
|
+
${literal(schema)}
|
|
4114
|
+
)
|
|
4115
|
+
) IS NOT NULL THEN
|
|
4116
|
+
EXECUTE format(
|
|
4117
|
+
'REVOKE ALL ON FUNCTION %I.refresh_scheduled_task_personal_resources_clone_connections(uuid, uuid, uuid, bigint, bigint) FROM PUBLIC',
|
|
4118
|
+
${literal(schema)}
|
|
4119
|
+
);
|
|
4120
|
+
EXECUTE format(
|
|
4121
|
+
'GRANT EXECUTE ON FUNCTION %I.refresh_scheduled_task_personal_resources_clone_connections(uuid, uuid, uuid, bigint, bigint) TO %I',
|
|
4122
|
+
${literal(schema)}, ${literal(role)}
|
|
4123
|
+
);
|
|
4124
|
+
EXECUTE format(
|
|
4125
|
+
'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',
|
|
4126
|
+
${literal(schema)}
|
|
4127
|
+
);
|
|
4128
|
+
EXECUTE format(
|
|
4129
|
+
'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',
|
|
4130
|
+
${literal(schema)}, ${literal(role)}
|
|
4131
|
+
);
|
|
4132
|
+
EXECUTE format(
|
|
4133
|
+
'REVOKE ALL ON FUNCTION %I.scheduled_task_run_connection_authority_subject(uuid, uuid, uuid) FROM PUBLIC',
|
|
4134
|
+
${literal(schema)}
|
|
4135
|
+
);
|
|
4136
|
+
EXECUTE format(
|
|
4137
|
+
'GRANT EXECUTE ON FUNCTION %I.scheduled_task_run_connection_authority_subject(uuid, uuid, uuid) TO %I',
|
|
4138
|
+
${literal(schema)}, ${literal(role)}
|
|
4139
|
+
);
|
|
4140
|
+
EXECUTE format(
|
|
4141
|
+
'REVOKE ALL ON FUNCTION %I.scheduled_task_personal_resource_authority_subject(uuid, uuid, uuid, bigint) FROM PUBLIC',
|
|
4142
|
+
${literal(schema)}
|
|
4143
|
+
);
|
|
4144
|
+
EXECUTE format(
|
|
4145
|
+
'GRANT EXECUTE ON FUNCTION %I.scheduled_task_personal_resource_authority_subject(uuid, uuid, uuid, bigint) TO %I',
|
|
4146
|
+
${literal(schema)}, ${literal(role)}
|
|
4147
|
+
);
|
|
4148
|
+
EXECUTE format(
|
|
4149
|
+
'REVOKE ALL ON FUNCTION %I.record_scheduled_task_revision_authority(uuid, uuid, uuid, bigint) FROM PUBLIC',
|
|
4150
|
+
${literal(schema)}
|
|
4151
|
+
);
|
|
4152
|
+
EXECUTE format(
|
|
4153
|
+
'GRANT EXECUTE ON FUNCTION %I.record_scheduled_task_revision_authority(uuid, uuid, uuid, bigint) TO %I',
|
|
4154
|
+
${literal(schema)}, ${literal(role)}
|
|
4155
|
+
);
|
|
4156
|
+
EXECUTE format(
|
|
4157
|
+
'REVOKE ALL ON FUNCTION %I.clone_scheduled_task_revision_authority(uuid, uuid, uuid, bigint, bigint) FROM PUBLIC',
|
|
4158
|
+
${literal(schema)}
|
|
4159
|
+
);
|
|
4160
|
+
EXECUTE format(
|
|
4161
|
+
'GRANT EXECUTE ON FUNCTION %I.clone_scheduled_task_revision_authority(uuid, uuid, uuid, bigint, bigint) TO %I',
|
|
4162
|
+
${literal(schema)}, ${literal(role)}
|
|
4163
|
+
);
|
|
4164
|
+
EXECUTE format(
|
|
4165
|
+
'REVOKE ALL ON FUNCTION %I.scheduled_task_revision_authority_subject(uuid, uuid, uuid, bigint) FROM PUBLIC',
|
|
4166
|
+
${literal(schema)}
|
|
4167
|
+
);
|
|
4168
|
+
EXECUTE format(
|
|
4169
|
+
'GRANT EXECUTE ON FUNCTION %I.scheduled_task_revision_authority_subject(uuid, uuid, uuid, bigint) TO %I',
|
|
4170
|
+
${literal(schema)}, ${literal(role)}
|
|
4171
|
+
);
|
|
4172
|
+
EXECUTE format(
|
|
4173
|
+
'REVOKE ALL ON FUNCTION %I.scheduled_task_revision_authority_snapshot(uuid, uuid, uuid, bigint) FROM PUBLIC',
|
|
4174
|
+
${literal(schema)}
|
|
4175
|
+
);
|
|
4176
|
+
EXECUTE format(
|
|
4177
|
+
'GRANT EXECUTE ON FUNCTION %I.scheduled_task_revision_authority_snapshot(uuid, uuid, uuid, bigint) TO %I',
|
|
4178
|
+
${literal(schema)}, ${literal(role)}
|
|
4179
|
+
);
|
|
4180
|
+
EXECUTE format(
|
|
4181
|
+
'REVOKE ALL ON FUNCTION %I.validate_scheduled_agent_run_live_authority(uuid, uuid, uuid) FROM PUBLIC',
|
|
4182
|
+
${literal(schema)}
|
|
4183
|
+
);
|
|
4184
|
+
EXECUTE format(
|
|
4185
|
+
'GRANT EXECUTE ON FUNCTION %I.validate_scheduled_agent_run_live_authority(uuid, uuid, uuid) TO %I',
|
|
4186
|
+
${literal(schema)}, ${literal(role)}
|
|
4187
|
+
);
|
|
4188
|
+
EXECUTE format(
|
|
4189
|
+
'REVOKE ALL ON FUNCTION %I.scheduled_scoped_rig_version_metadata(uuid, uuid, text, uuid, uuid) FROM PUBLIC',
|
|
4190
|
+
${literal(schema)}
|
|
4191
|
+
);
|
|
4192
|
+
EXECUTE format(
|
|
4193
|
+
'GRANT EXECUTE ON FUNCTION %I.scheduled_scoped_rig_version_metadata(uuid, uuid, text, uuid, uuid) TO %I',
|
|
4194
|
+
${literal(schema)}, ${literal(role)}
|
|
4195
|
+
);
|
|
4196
|
+
EXECUTE format(
|
|
4197
|
+
'REVOKE ALL ON FUNCTION %I.scheduled_variable_set_expected_generation_for_attempt(uuid, uuid, uuid, uuid, uuid, integer, uuid) FROM PUBLIC',
|
|
4198
|
+
${literal(schema)}
|
|
4199
|
+
);
|
|
4200
|
+
EXECUTE format(
|
|
4201
|
+
'GRANT EXECUTE ON FUNCTION %I.scheduled_variable_set_expected_generation_for_attempt(uuid, uuid, uuid, uuid, uuid, integer, uuid) TO %I',
|
|
4202
|
+
${literal(schema)}, ${literal(role)}
|
|
4203
|
+
);
|
|
4204
|
+
EXECUTE format(
|
|
4205
|
+
'REVOKE ALL ON FUNCTION %I.bind_scheduled_task_run_session(uuid, uuid, uuid, uuid) FROM PUBLIC',
|
|
4206
|
+
${literal(schema)}
|
|
4207
|
+
);
|
|
4208
|
+
EXECUTE format(
|
|
4209
|
+
'GRANT EXECUTE ON FUNCTION %I.bind_scheduled_task_run_session(uuid, uuid, uuid, uuid) TO %I',
|
|
4210
|
+
${literal(schema)}, ${literal(role)}
|
|
4211
|
+
);
|
|
4212
|
+
EXECUTE format(
|
|
4213
|
+
'REVOKE ALL ON FUNCTION %I.transition_scheduled_agent_run(uuid, uuid, uuid, uuid, uuid, text, text) FROM PUBLIC',
|
|
4214
|
+
${literal(schema)}
|
|
4215
|
+
);
|
|
4216
|
+
EXECUTE format(
|
|
4217
|
+
'GRANT EXECUTE ON FUNCTION %I.transition_scheduled_agent_run(uuid, uuid, uuid, uuid, uuid, text, text) TO %I',
|
|
4218
|
+
${literal(schema)}, ${literal(role)}
|
|
4219
|
+
);
|
|
4220
|
+
EXECUTE format(
|
|
4221
|
+
'REVOKE DELETE ON TABLE %I.scheduled_tasks, %I.scheduled_task_runs FROM %I',
|
|
4222
|
+
${literal(schema)}, ${literal(schema)}, ${literal(role)}
|
|
4223
|
+
);
|
|
4224
|
+
EXECUTE format(
|
|
4225
|
+
'REVOKE ALL PRIVILEGES ON TABLE %I.scheduled_task_connection_authority_snapshots FROM %I',
|
|
4226
|
+
${literal(schema)}, ${literal(role)}
|
|
4227
|
+
);
|
|
4228
|
+
EXECUTE format(
|
|
4229
|
+
'REVOKE ALL PRIVILEGES ON TABLE %I.scheduled_task_run_connection_authority_snapshots FROM %I',
|
|
4230
|
+
${literal(schema)}, ${literal(role)}
|
|
4231
|
+
);
|
|
4232
|
+
EXECUTE format(
|
|
4233
|
+
'REVOKE ALL PRIVILEGES ON TABLE %I.scheduled_task_reusable_connection_materializations FROM %I',
|
|
4234
|
+
${literal(schema)}, ${literal(role)}
|
|
4235
|
+
);
|
|
4236
|
+
EXECUTE format(
|
|
4237
|
+
'REVOKE ALL PRIVILEGES ON TABLE %I.scheduled_task_revision_authorities FROM %I',
|
|
4238
|
+
${literal(schema)}, ${literal(role)}
|
|
4239
|
+
);
|
|
4240
|
+
END IF;
|
|
4241
|
+
EXECUTE format(
|
|
4242
|
+
'REVOKE ALL ON FUNCTION %I.materialize_scheduled_task_reusable_session_from_run(uuid, uuid, uuid, uuid, uuid, bigint, text) FROM PUBLIC',
|
|
4243
|
+
${literal(schema)}
|
|
4244
|
+
);
|
|
4245
|
+
EXECUTE format(
|
|
4246
|
+
'GRANT EXECUTE ON FUNCTION %I.materialize_scheduled_task_reusable_session_from_run(uuid, uuid, uuid, uuid, uuid, bigint, text) TO %I',
|
|
4247
|
+
${literal(schema)},
|
|
4248
|
+
${literal(role)}
|
|
4249
|
+
);
|
|
4250
|
+
EXECUTE format(
|
|
4251
|
+
'REVOKE ALL ON FUNCTION %I.scheduled_task_run_personal_resource_authority(uuid, uuid, uuid) FROM PUBLIC',
|
|
4252
|
+
${literal(schema)}
|
|
4253
|
+
);
|
|
4254
|
+
EXECUTE format(
|
|
4255
|
+
'GRANT EXECUTE ON FUNCTION %I.scheduled_task_run_personal_resource_authority(uuid, uuid, uuid) TO %I',
|
|
4256
|
+
${literal(schema)},
|
|
4257
|
+
${literal(role)}
|
|
4258
|
+
);
|
|
4259
|
+
END IF;
|
|
4260
|
+
IF to_regprocedure(
|
|
4261
|
+
format(
|
|
4262
|
+
'%I.scoped_knowledge_advance_source_acl(uuid,uuid,bigint,bigint,uuid,text,text,text,text,text,text)',
|
|
4263
|
+
${literal(schema)}
|
|
4264
|
+
)
|
|
4265
|
+
) IS NOT NULL THEN
|
|
4266
|
+
EXECUTE format(
|
|
4267
|
+
'GRANT EXECUTE ON FUNCTION %I.scoped_knowledge_advance_source_acl(uuid, uuid, bigint, bigint, uuid, text, text, text, text, text, text) TO %I',
|
|
4268
|
+
${literal(schema)},
|
|
4269
|
+
${literal(role)}
|
|
4270
|
+
);
|
|
4271
|
+
END IF;
|
|
4272
|
+
IF to_regprocedure(
|
|
4273
|
+
format(
|
|
4274
|
+
'%I.scoped_knowledge_complete_sync(uuid,uuid,text,text,timestamptz,jsonb,text,text,text)',
|
|
4275
|
+
${literal(schema)}
|
|
4276
|
+
)
|
|
4277
|
+
) IS NOT NULL THEN
|
|
4278
|
+
EXECUTE format(
|
|
4279
|
+
'GRANT EXECUTE ON FUNCTION %I.scoped_knowledge_complete_sync(uuid, uuid, text, text, timestamptz, jsonb, text, text, text) TO %I',
|
|
4280
|
+
${literal(schema)},
|
|
4281
|
+
${literal(role)}
|
|
4282
|
+
);
|
|
4283
|
+
END IF;
|
|
4284
|
+
IF to_regprocedure(
|
|
4285
|
+
format(
|
|
4286
|
+
'%I.scoped_knowledge_advance_object_version(uuid,uuid,bigint,bigint,uuid,text,text,text,text,text,text)',
|
|
4287
|
+
${literal(schema)}
|
|
4288
|
+
)
|
|
4289
|
+
) IS NOT NULL THEN
|
|
4290
|
+
EXECUTE format(
|
|
4291
|
+
'GRANT EXECUTE ON FUNCTION %I.scoped_knowledge_advance_object_version(uuid, uuid, bigint, bigint, uuid, text, text, text, text, text, text) TO %I',
|
|
4292
|
+
${literal(schema)},
|
|
4293
|
+
${literal(role)}
|
|
4294
|
+
);
|
|
4295
|
+
END IF;
|
|
4296
|
+
EXECUTE format('GRANT USAGE, SELECT ON ALL SEQUENCES IN SCHEMA %I TO %I', ${literal(schema)}, ${literal(role)});
|
|
4297
|
+
EXECUTE format(
|
|
4298
|
+
'ALTER DEFAULT PRIVILEGES FOR ROLE %I IN SCHEMA %I REVOKE ALL PRIVILEGES ON TABLES FROM %I',
|
|
4299
|
+
owner_role,
|
|
4300
|
+
${literal(schema)},
|
|
4301
|
+
${literal(role)}
|
|
4302
|
+
);
|
|
4303
|
+
EXECUTE format(
|
|
4304
|
+
'ALTER DEFAULT PRIVILEGES FOR ROLE %I IN SCHEMA %I GRANT USAGE, SELECT ON SEQUENCES TO %I',
|
|
4305
|
+
owner_role,
|
|
4306
|
+
${literal(schema)},
|
|
4307
|
+
${literal(role)}
|
|
4308
|
+
);
|
|
4309
|
+
END IF;
|
|
4310
|
+
IF EXISTS (SELECT 1 FROM pg_namespace WHERE nspname = 'opengeni_private') THEN
|
|
4311
|
+
EXECUTE format('GRANT USAGE ON SCHEMA opengeni_private TO %I', ${literal(role)});
|
|
4312
|
+
EXECUTE format('REVOKE CREATE ON SCHEMA opengeni_private FROM %I', ${literal(role)});
|
|
4313
|
+
EXECUTE format('GRANT EXECUTE ON ALL FUNCTIONS IN SCHEMA opengeni_private TO %I', ${literal(role)});
|
|
4314
|
+
EXECUTE format(
|
|
4315
|
+
'ALTER DEFAULT PRIVILEGES FOR ROLE %I IN SCHEMA opengeni_private REVOKE EXECUTE ON FUNCTIONS FROM %I',
|
|
4316
|
+
owner_role,
|
|
4317
|
+
${literal(role)}
|
|
4318
|
+
);
|
|
4319
|
+
IF to_regprocedure('opengeni_private.personal_resource_delegation_capability_active(text)') IS NOT NULL THEN
|
|
4320
|
+
REVOKE ALL ON FUNCTION
|
|
4321
|
+
opengeni_private.personal_resource_delegation_capability_active(text)
|
|
4322
|
+
FROM PUBLIC;
|
|
4323
|
+
EXECUTE format(
|
|
4324
|
+
'GRANT EXECUTE ON FUNCTION opengeni_private.personal_resource_delegation_capability_active(text) TO %I',
|
|
4325
|
+
${literal(role)}
|
|
4326
|
+
);
|
|
4327
|
+
END IF;
|
|
4328
|
+
IF to_regprocedure('opengeni_private.scheduled_personal_resource_capability_active(text)') IS NOT NULL THEN
|
|
4329
|
+
REVOKE ALL ON FUNCTION
|
|
4330
|
+
opengeni_private.scheduled_personal_resource_capability_active(text)
|
|
4331
|
+
FROM PUBLIC;
|
|
4332
|
+
EXECUTE format(
|
|
4333
|
+
'GRANT EXECUTE ON FUNCTION opengeni_private.scheduled_personal_resource_capability_active(text) TO %I',
|
|
4334
|
+
${literal(role)}
|
|
4335
|
+
);
|
|
4336
|
+
END IF;
|
|
4337
|
+
IF to_regprocedure('opengeni_private.variable_set_authority_capability_active(text)') IS NOT NULL THEN
|
|
4338
|
+
REVOKE ALL ON FUNCTION
|
|
4339
|
+
opengeni_private.variable_set_authority_capability_active(text)
|
|
4340
|
+
FROM PUBLIC;
|
|
4341
|
+
EXECUTE format(
|
|
4342
|
+
'GRANT EXECUTE ON FUNCTION opengeni_private.variable_set_authority_capability_active(text) TO %I',
|
|
4343
|
+
${literal(role)}
|
|
4344
|
+
);
|
|
4345
|
+
EXECUTE format(
|
|
4346
|
+
'REVOKE ALL PRIVILEGES ON TABLE opengeni_private.variable_set_authority_capabilities FROM %I',
|
|
4347
|
+
${literal(role)}
|
|
4348
|
+
);
|
|
4349
|
+
END IF;
|
|
4350
|
+
IF to_regprocedure('opengeni_private.scoped_compute_capability_active(text)') IS NOT NULL THEN
|
|
4351
|
+
REVOKE ALL ON FUNCTION opengeni_private.scoped_compute_capability_active(text) FROM PUBLIC;
|
|
4352
|
+
EXECUTE format(
|
|
4353
|
+
'GRANT EXECUTE ON FUNCTION opengeni_private.scoped_compute_capability_active(text) TO %I',
|
|
4354
|
+
${literal(role)}
|
|
4355
|
+
);
|
|
4356
|
+
EXECUTE format(
|
|
4357
|
+
'REVOKE ALL PRIVILEGES ON TABLE opengeni_private.scoped_compute_capabilities FROM %I',
|
|
4358
|
+
${literal(role)}
|
|
4359
|
+
);
|
|
4360
|
+
END IF;
|
|
4361
|
+
-- Global cross-workspace artifact workers are separate capabilities. Never
|
|
4362
|
+
-- let the generic tenant-scoped app role inherit them from the historical
|
|
4363
|
+
-- blanket grant of already-installed helpers.
|
|
4364
|
+
IF to_regprocedure('opengeni_private.claim_editable_artifact_live_outbox(text,integer,integer,name)') IS NOT NULL THEN
|
|
4365
|
+
EXECUTE format(
|
|
4366
|
+
'REVOKE EXECUTE ON FUNCTION opengeni_private.claim_editable_artifact_live_outbox(text, integer, integer, name) FROM %I',
|
|
4367
|
+
${literal(role)}
|
|
4368
|
+
);
|
|
4369
|
+
EXECUTE format(
|
|
4370
|
+
'REVOKE EXECUTE ON FUNCTION opengeni_private.mark_editable_artifact_live_outbox_published(text, text, integer, name) FROM %I',
|
|
4371
|
+
${literal(role)}
|
|
4372
|
+
);
|
|
4373
|
+
EXECUTE format(
|
|
4374
|
+
'REVOKE EXECUTE ON FUNCTION opengeni_private.renew_editable_artifact_live_outbox(text, text, integer, integer, name) FROM %I',
|
|
4375
|
+
${literal(role)}
|
|
4376
|
+
);
|
|
4377
|
+
EXECUTE format(
|
|
4378
|
+
'REVOKE EXECUTE ON FUNCTION opengeni_private.retry_editable_artifact_live_outbox(text, text, integer, integer, text, name) FROM %I',
|
|
4379
|
+
${literal(role)}
|
|
4380
|
+
);
|
|
4381
|
+
EXECUTE format(
|
|
4382
|
+
'REVOKE EXECUTE ON FUNCTION opengeni_private.dead_letter_editable_artifact_live_outbox(text, text, integer, text, name) FROM %I',
|
|
4383
|
+
${literal(role)}
|
|
4384
|
+
);
|
|
4385
|
+
EXECUTE format(
|
|
4386
|
+
'REVOKE EXECUTE ON FUNCTION opengeni_private.release_editable_artifact_live_outbox(text, text, integer, name) FROM %I',
|
|
4387
|
+
${literal(role)}
|
|
4388
|
+
);
|
|
4389
|
+
END IF;
|
|
4390
|
+
IF to_regprocedure('opengeni_private.claim_editable_artifact_materializations(text,integer,integer,name)') IS NOT NULL THEN
|
|
4391
|
+
EXECUTE format(
|
|
4392
|
+
'REVOKE EXECUTE ON FUNCTION opengeni_private.claim_editable_artifact_materializations(text, integer, integer, name) FROM %I',
|
|
4393
|
+
${literal(role)}
|
|
4394
|
+
);
|
|
4395
|
+
EXECUTE format(
|
|
4396
|
+
'REVOKE EXECUTE ON FUNCTION opengeni_private.renew_editable_artifact_materialization(uuid, uuid, text, text, text, integer, integer, name) FROM %I',
|
|
4397
|
+
${literal(role)}
|
|
4398
|
+
);
|
|
4399
|
+
EXECUTE format(
|
|
4400
|
+
'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',
|
|
4401
|
+
${literal(role)}
|
|
4402
|
+
);
|
|
4403
|
+
EXECUTE format(
|
|
4404
|
+
'REVOKE EXECUTE ON FUNCTION opengeni_private.fail_editable_artifact_materialization(uuid, uuid, text, text, text, integer, text, name) FROM %I',
|
|
4405
|
+
${literal(role)}
|
|
4406
|
+
);
|
|
4407
|
+
END IF;
|
|
4408
|
+
IF to_regprocedure('opengeni_private.consume_editable_artifact_live_ticket(text,name)') IS NOT NULL THEN
|
|
4409
|
+
EXECUTE format(
|
|
4410
|
+
'REVOKE EXECUTE ON FUNCTION opengeni_private.resolve_editable_artifact_ticket_data_schema(name) FROM %I',
|
|
4411
|
+
${literal(role)}
|
|
4412
|
+
);
|
|
4413
|
+
EXECUTE format(
|
|
4414
|
+
'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',
|
|
4415
|
+
${literal(role)}
|
|
4416
|
+
);
|
|
4417
|
+
EXECUTE format(
|
|
4418
|
+
'GRANT EXECUTE ON FUNCTION opengeni_private.consume_editable_artifact_live_ticket(text, name) TO %I',
|
|
4419
|
+
${literal(role)}
|
|
4420
|
+
);
|
|
4421
|
+
EXECUTE format(
|
|
4422
|
+
'GRANT EXECUTE ON FUNCTION opengeni_private.cleanup_expired_editable_artifact_live_tickets(integer, name) TO %I',
|
|
4423
|
+
${literal(role)}
|
|
4424
|
+
);
|
|
4425
|
+
END IF;
|
|
4426
|
+
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
|
|
4427
|
+
EXECUTE format(
|
|
4428
|
+
'GRANT EXECUTE ON FUNCTION opengeni_private.authorize_editable_artifact_actor(uuid, uuid, text, text, text, text, text, text, integer, text, text, name) TO %I',
|
|
4429
|
+
${literal(role)}
|
|
4430
|
+
);
|
|
4431
|
+
END IF;
|
|
4432
|
+
FOREACH routine_signature IN ARRAY ARRAY[
|
|
4433
|
+
'complete_temporal_schedule_connector_cleanup(uuid,uuid)',
|
|
4434
|
+
'upgrade_temporal_schedule_connector_cleanup(uuid,uuid,text,uuid,text,jsonb,uuid)',
|
|
4435
|
+
'complete_workspace_temporal_connector_cleanups(uuid,uuid)'
|
|
4436
|
+
] LOOP
|
|
4437
|
+
IF to_regprocedure('opengeni_private.' || routine_signature) IS NOT NULL THEN
|
|
4438
|
+
EXECUTE format(
|
|
4439
|
+
'REVOKE ALL ON FUNCTION opengeni_private.%s FROM PUBLIC',
|
|
4440
|
+
routine_signature
|
|
4441
|
+
);
|
|
4442
|
+
EXECUTE format(
|
|
4443
|
+
'GRANT EXECUTE ON FUNCTION opengeni_private.%s TO %I',
|
|
4444
|
+
routine_signature,
|
|
4445
|
+
${literal(role)}
|
|
4446
|
+
);
|
|
4447
|
+
END IF;
|
|
4448
|
+
END LOOP;
|
|
4449
|
+
END IF;
|
|
4450
|
+
END $$;
|
|
4451
|
+
`);
|
|
4452
|
+
}
|
|
4453
|
+
function commaSeparated(value) {
|
|
4454
|
+
return value.split(",").map((item) => item.trim()).filter(Boolean);
|
|
4455
|
+
}
|
|
4456
|
+
function validateIdentifier(name, value) {
|
|
4457
|
+
if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(value)) {
|
|
4458
|
+
throw new Error(`${name} contains an invalid Postgres identifier: ${value}`);
|
|
4459
|
+
}
|
|
4460
|
+
return value;
|
|
4461
|
+
}
|
|
4462
|
+
function identifier(value) {
|
|
4463
|
+
return `"${value.replace(/"/g, '""')}"`;
|
|
4464
|
+
}
|
|
4465
|
+
function literal(value) {
|
|
4466
|
+
return `'${value.replace(/'/g, "''")}'`;
|
|
4467
|
+
}
|
|
4468
|
+
function databaseUrlFor(value, database) {
|
|
4469
|
+
const url = new URL(value);
|
|
4470
|
+
url.pathname = `/${database}`;
|
|
4471
|
+
return url.toString();
|
|
4472
|
+
}
|
|
4473
|
+
if (import.meta.main) {
|
|
4474
|
+
const adminUrl = process.env.OPENGENI_MIGRATIONS_DATABASE_URL ?? process.env.OPENGENI_DATABASE_ADMIN_URL ?? process.env.OPENGENI_DATABASE_URL;
|
|
4475
|
+
if (!adminUrl) {
|
|
4476
|
+
throw new Error(
|
|
4477
|
+
"OPENGENI_MIGRATIONS_DATABASE_URL, OPENGENI_DATABASE_ADMIN_URL, or OPENGENI_DATABASE_URL is required"
|
|
4478
|
+
);
|
|
4479
|
+
}
|
|
4480
|
+
const result = await provisionRoles(adminUrl, {
|
|
4481
|
+
...process.env.OPENGENI_DB_SCHEMA?.trim() ? { targetSchema: process.env.OPENGENI_DB_SCHEMA.trim() } : {}
|
|
4482
|
+
});
|
|
4483
|
+
console.log(JSON.stringify(result, null, 2));
|
|
4484
|
+
}
|
|
4485
|
+
|
|
4486
|
+
export {
|
|
4487
|
+
RUNTIME_TARGET_SCHEMA_CAPABILITY_ROUTINES,
|
|
4488
|
+
RUNTIME_TARGET_SCHEMA_PUBLIC_POLICY_PREDICATE_ROUTINES,
|
|
4489
|
+
RUNTIME_TARGET_SCHEMA_FORBIDDEN_ROUTINES,
|
|
4490
|
+
RUNTIME_TARGET_SCHEMA_INVOKER_ROUTINES,
|
|
4491
|
+
FORCE_RLS_TABLES,
|
|
4492
|
+
NON_RLS_RUNTIME_TABLES,
|
|
4493
|
+
RUNTIME_FULL_DML_TABLES,
|
|
4494
|
+
RUNTIME_READ_ONLY_TABLES,
|
|
4495
|
+
RUNTIME_READ_UPDATE_TABLES,
|
|
4496
|
+
RUNTIME_READ_INSERT_TABLES,
|
|
4497
|
+
RUNTIME_READ_INSERT_UPDATE_TABLES,
|
|
4498
|
+
PROTECTED_NO_DIRECT_DML_TABLES,
|
|
4499
|
+
RUNTIME_TABLE_PRIVILEGES,
|
|
4500
|
+
RUNTIME_DML_TABLES,
|
|
4501
|
+
RuntimeDatabasePostureError,
|
|
4502
|
+
inspectRuntimeDatabasePosture,
|
|
4503
|
+
evaluateRuntimeDatabasePosture,
|
|
4504
|
+
assertRuntimeDatabasePosture,
|
|
4505
|
+
runtimeDatabaseReadyCheck,
|
|
4506
|
+
provisionRoles
|
|
4507
|
+
};
|
|
4508
|
+
//# sourceMappingURL=chunk-UZNXG44K.js.map
|