@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
package/src/runtime-posture.ts
CHANGED
|
@@ -66,12 +66,216 @@ const KNOWLEDGE_SOURCE_SYNC_LOCK_AUTHORITY_TABLES = [
|
|
|
66
66
|
] as const;
|
|
67
67
|
const MANAGED_HUMAN_PERSONAL_WORKSPACE_ROUTINE =
|
|
68
68
|
"ensure_managed_human_personal_workspace(uuid, text, uuid)";
|
|
69
|
+
const ORGANIZATION_MEMBERSHIP_LIFECYCLE_ROUTINES = [
|
|
70
|
+
"list_self_organization_memberships(text)",
|
|
71
|
+
"list_self_organization_invitations(text)",
|
|
72
|
+
"list_self_organization_invitations(text, uuid, integer)",
|
|
73
|
+
"get_self_organization_invitation(text, uuid)",
|
|
74
|
+
"list_organization_invitations(uuid, text, uuid, integer)",
|
|
75
|
+
"list_organization_members(uuid, text)",
|
|
76
|
+
"get_organization_administration_overview(uuid, text)",
|
|
77
|
+
"create_managed_organization(text, text, text, uuid)",
|
|
78
|
+
"assert_organization_shared_workspace_administrator(uuid, uuid, text)",
|
|
79
|
+
"open_organization_shared_workspace_administration_capability(uuid, uuid, text)",
|
|
80
|
+
"close_organization_shared_workspace_administration_capability(uuid)",
|
|
81
|
+
"create_organization_shared_workspace(uuid, text, text, text, text, uuid)",
|
|
82
|
+
"upsert_organization_shared_workspace_member(uuid, uuid, text, uuid, text, text, jsonb, boolean)",
|
|
83
|
+
"update_organization_name(uuid, text, text, timestamp with time zone, uuid)",
|
|
84
|
+
"create_organization_invitation_v2(jsonb)",
|
|
85
|
+
"bind_pending_organization_invitations_for_verified_email(text, text)",
|
|
86
|
+
"has_pending_organization_invitation_for_subject(text)",
|
|
87
|
+
"accept_organization_invitation_v2(jsonb)",
|
|
88
|
+
"organization_membership_command(jsonb)",
|
|
89
|
+
"prepare_organization_membership_protocol_settlements(jsonb)",
|
|
90
|
+
"assert_active_managed_human_organization_membership(uuid, text)",
|
|
91
|
+
"resolve_workspace_writer_grant_identity(uuid, text)",
|
|
92
|
+
"prepare_workspace_membership_removal_settlements(jsonb)",
|
|
93
|
+
"workspace_membership_removal_command(jsonb)",
|
|
94
|
+
"get_organization_retention_policy(uuid, text)",
|
|
95
|
+
"preview_organization_retention_deletions(uuid, integer)",
|
|
96
|
+
"claim_organization_retention_deletion(uuid, uuid, uuid[])",
|
|
97
|
+
"list_organization_retention_deletion_objects(uuid, uuid, uuid, text, integer)",
|
|
98
|
+
"record_organization_retention_object_deleted(uuid, uuid, uuid, text, text, text, text)",
|
|
99
|
+
"fail_organization_retention_deletion(uuid, uuid, uuid, text)",
|
|
100
|
+
"finalize_organization_retention_deletion(uuid, uuid, uuid, text)",
|
|
101
|
+
"complete_organization_retention_deletion(uuid, uuid, uuid, text)",
|
|
102
|
+
] as const;
|
|
103
|
+
const ORGANIZATION_MEMBERSHIP_LIFECYCLE_AUTHORITY_TABLES = [
|
|
104
|
+
"organization_invitation_binding_events",
|
|
105
|
+
"organization_membership_invitations",
|
|
106
|
+
"organization_membership_lifecycle_events",
|
|
107
|
+
"organization_membership_operation_receipts",
|
|
108
|
+
"organization_memberships",
|
|
109
|
+
"organization_profile_events",
|
|
110
|
+
"organization_shared_workspace_administration_capabilities",
|
|
111
|
+
"organization_user_resource_authorities",
|
|
112
|
+
"organization_user_resource_grants",
|
|
113
|
+
"organization_user_retention_deletion_events",
|
|
114
|
+
"organization_user_retention_deletions",
|
|
115
|
+
"organization_user_retention_object_deletion_receipts",
|
|
116
|
+
"organization_user_retention_object_obligations",
|
|
117
|
+
"organization_user_retention_policies",
|
|
118
|
+
] as const;
|
|
119
|
+
const PRIVATE_SESSION_CREATE_POLICY_ROUTINE = "get_private_session_create_policy(uuid, uuid, text)";
|
|
120
|
+
const ORGANIZATION_PRIVATE_SESSION_SETTINGS_READ_ROUTINE =
|
|
121
|
+
"get_organization_private_session_settings(uuid, text)";
|
|
122
|
+
const ORGANIZATION_PRIVATE_SESSION_SETTINGS_UPDATE_ROUTINE =
|
|
123
|
+
"update_organization_private_session_settings(uuid, text, boolean, bigint, uuid)";
|
|
124
|
+
const ORGANIZATION_PRIVATE_SESSION_ROUTINE_AUTHORITY_TABLES = {
|
|
125
|
+
[PRIVATE_SESSION_CREATE_POLICY_ROUTINE]: [
|
|
126
|
+
"organization_memberships",
|
|
127
|
+
"organization_private_session_settings",
|
|
128
|
+
"session_tenancy_activations",
|
|
129
|
+
"workspace_memberships",
|
|
130
|
+
"workspaces",
|
|
131
|
+
],
|
|
132
|
+
[ORGANIZATION_PRIVATE_SESSION_SETTINGS_READ_ROUTINE]: [
|
|
133
|
+
"managed_accounts",
|
|
134
|
+
"organization_memberships",
|
|
135
|
+
"organization_private_session_settings",
|
|
136
|
+
"session_tenancy_activations",
|
|
137
|
+
],
|
|
138
|
+
[ORGANIZATION_PRIVATE_SESSION_SETTINGS_UPDATE_ROUTINE]: [
|
|
139
|
+
"managed_accounts",
|
|
140
|
+
"organization_memberships",
|
|
141
|
+
"organization_private_session_setting_events",
|
|
142
|
+
"organization_private_session_settings",
|
|
143
|
+
"session_tenancy_activations",
|
|
144
|
+
],
|
|
145
|
+
} as const;
|
|
146
|
+
const ORGANIZATION_PRIVATE_SESSION_ROUTINES = Object.keys(
|
|
147
|
+
ORGANIZATION_PRIVATE_SESSION_ROUTINE_AUTHORITY_TABLES,
|
|
148
|
+
);
|
|
149
|
+
const ORGANIZATION_PRIVATE_SESSIONS_ENABLED_ROUTINE = "organization_private_sessions_enabled(uuid)";
|
|
150
|
+
const PREFERENCE_KNOWLEDGE_PROPOSAL_ROUTINE =
|
|
151
|
+
"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)";
|
|
152
|
+
const PREFERENCE_KNOWLEDGE_PROPOSAL_AUTHORITY_TABLES = [
|
|
153
|
+
"company_brain_preference_proposal_receipts",
|
|
154
|
+
"knowledge_change_proposals",
|
|
155
|
+
"knowledge_claim_evidence",
|
|
156
|
+
"knowledge_claim_reviews",
|
|
157
|
+
"knowledge_claims",
|
|
158
|
+
"preference_registry_events",
|
|
159
|
+
"preference_registry_preferences",
|
|
160
|
+
"preference_registry_revisions",
|
|
161
|
+
"session_attempt_interruptions",
|
|
162
|
+
"session_turn_attempts",
|
|
163
|
+
"session_turns",
|
|
164
|
+
"sessions",
|
|
165
|
+
"workspaces",
|
|
166
|
+
] as const;
|
|
69
167
|
const MANAGED_HUMAN_PERSONAL_WORKSPACE_AUTHORITY_TABLES = [
|
|
70
168
|
"organization_memberships",
|
|
71
169
|
"organization_user_retention_policies",
|
|
72
170
|
"organization_user_resource_authorities",
|
|
73
171
|
"organization_user_resource_grants",
|
|
74
172
|
] as const;
|
|
173
|
+
const PERSONAL_RESOURCE_ATTEMPT_RESOLVER_ROUTINE =
|
|
174
|
+
"resolve_session_attempt_personal_resources(uuid, uuid, uuid)";
|
|
175
|
+
const USER_RESOURCE_LIFECYCLE_ROUTINES = [
|
|
176
|
+
"accept_turn_personal_resource_attachment(uuid, uuid, uuid, uuid, text, integer, boolean, integer)",
|
|
177
|
+
"list_self_user_resource_authorities(uuid, uuid, text, uuid, integer)",
|
|
178
|
+
"issue_self_user_resource_grant(uuid, uuid, uuid, text, text, text, uuid, integer, boolean)",
|
|
179
|
+
"revoke_self_user_resource_grant(uuid, uuid, uuid)",
|
|
180
|
+
"authorize_session_attempt_personal_resource_reads(uuid, uuid, uuid)",
|
|
181
|
+
] as const;
|
|
182
|
+
const CONNECTION_CONVERGENCE_AUDIT_CAPABILITY_ROUTINE =
|
|
183
|
+
"connection_authority_convergence_audit_capability_active(uuid)";
|
|
184
|
+
const CONNECTION_AUTHORITY_ROUTINES = [
|
|
185
|
+
CONNECTION_CONVERGENCE_AUDIT_CAPABILITY_ROUTINE,
|
|
186
|
+
"resolve_personal_connection_authority_selection(uuid, uuid, text, uuid, jsonb)",
|
|
187
|
+
"resolve_accepted_connection_use(uuid, uuid, uuid, uuid, uuid, integer, uuid, text, text, uuid, text, text, text, text)",
|
|
188
|
+
"resolve_connection_use_authority(uuid, uuid, uuid, jsonb)",
|
|
189
|
+
"inspect_organization_connection_authority_convergence(uuid, integer, uuid)",
|
|
190
|
+
] as const;
|
|
191
|
+
const PERSONAL_GITHUB_REPOSITORY_AUTHORITY_ROUTINES = [
|
|
192
|
+
"get_self_personal_github_repository_selection(uuid, uuid, text, uuid)",
|
|
193
|
+
"mutate_self_personal_github_repository_selection(uuid, uuid, text, uuid, bigint, bigint, text, jsonb, boolean)",
|
|
194
|
+
] as const;
|
|
195
|
+
const PERSONAL_GITHUB_REPOSITORY_AUTHORITY_TABLES = [
|
|
196
|
+
"personal_github_repository_selection_heads",
|
|
197
|
+
"personal_github_repository_selection_operations",
|
|
198
|
+
"personal_github_repository_selections",
|
|
199
|
+
] as const;
|
|
200
|
+
const SCHEDULED_PERSONAL_RESOURCE_ROUTINES = [
|
|
201
|
+
"freeze_scheduled_task_personal_resources(uuid, uuid, uuid, bigint)",
|
|
202
|
+
"clone_scheduled_task_personal_resource_authority(uuid, uuid, uuid, bigint, bigint)",
|
|
203
|
+
"refresh_scheduled_task_personal_resources_clone_connections(uuid, uuid, uuid, bigint, bigint)",
|
|
204
|
+
"create_scheduled_agent_run_with_admission(uuid, uuid, uuid, uuid, bigint, text, text, text, timestamp with time zone, timestamp with time zone, jsonb)",
|
|
205
|
+
"materialize_scheduled_task_reusable_session_from_run(uuid, uuid, uuid, uuid, uuid, bigint, text)",
|
|
206
|
+
"scheduled_task_run_personal_resource_authority(uuid, uuid, uuid)",
|
|
207
|
+
"scheduled_task_run_connection_authority_subject(uuid, uuid, uuid)",
|
|
208
|
+
"scheduled_task_personal_resource_authority_subject(uuid, uuid, uuid, bigint)",
|
|
209
|
+
"record_scheduled_task_revision_authority(uuid, uuid, uuid, bigint)",
|
|
210
|
+
"clone_scheduled_task_revision_authority(uuid, uuid, uuid, bigint, bigint)",
|
|
211
|
+
"scheduled_task_revision_authority_subject(uuid, uuid, uuid, bigint)",
|
|
212
|
+
"scheduled_task_revision_authority_snapshot(uuid, uuid, uuid, bigint)",
|
|
213
|
+
"validate_scheduled_agent_run_live_authority(uuid, uuid, uuid)",
|
|
214
|
+
"scheduled_scoped_rig_version_metadata(uuid, uuid, text, uuid, uuid)",
|
|
215
|
+
"scheduled_variable_set_expected_generation_for_attempt(uuid, uuid, uuid, uuid, uuid, integer, uuid)",
|
|
216
|
+
"bind_scheduled_task_run_session(uuid, uuid, uuid, uuid)",
|
|
217
|
+
"transition_scheduled_agent_run(uuid, uuid, uuid, uuid, uuid, text, text)",
|
|
218
|
+
] as const;
|
|
219
|
+
const PERSONAL_RESOURCE_CAPABILITY_PREDICATE_ROUTINE =
|
|
220
|
+
"personal_resource_delegation_capability_active(text)";
|
|
221
|
+
const PERSONAL_RESOURCE_CAPABILITY_TABLE = "personal_resource_delegation_capabilities";
|
|
222
|
+
const SCHEDULED_PERSONAL_RESOURCE_CAPABILITY_PREDICATE_ROUTINE =
|
|
223
|
+
"scheduled_personal_resource_capability_active(text)";
|
|
224
|
+
const SCHEDULED_PERSONAL_RESOURCE_CAPABILITY_TABLE = "scheduled_personal_resource_capabilities";
|
|
225
|
+
const VARIABLE_SET_CAPABILITY_PREDICATE_ROUTINE = "variable_set_authority_capability_active(text)";
|
|
226
|
+
const VARIABLE_SET_CAPABILITY_TABLE = "variable_set_authority_capabilities";
|
|
227
|
+
const PERSONAL_DOCUMENT_CAPABILITY_PREDICATE_ROUTINE =
|
|
228
|
+
"personal_document_authority_capability_active(text)";
|
|
229
|
+
const PERSONAL_DOCUMENT_CAPABILITY_TABLE = "personal_document_authority_capabilities";
|
|
230
|
+
const PERSONAL_DOCUMENT_AUTHORITY_ROUTINES = [
|
|
231
|
+
"create_personal_document_authority(uuid, uuid, uuid)",
|
|
232
|
+
"resolve_document_original_file(uuid, uuid, text, uuid)",
|
|
233
|
+
"resolve_session_attempt_personal_document_reads(uuid, uuid, uuid, uuid)",
|
|
234
|
+
] as const;
|
|
235
|
+
const DOCUMENT_MIGRATION_CAPABILITY_PREDICATE_ROUTINE =
|
|
236
|
+
"document_migration_capability_active(text)";
|
|
237
|
+
const DOCUMENT_MIGRATION_CAPABILITY_TABLE = "document_migration_capabilities";
|
|
238
|
+
const DOCUMENT_MIGRATION_AUTHORITY_ROUTINES = [
|
|
239
|
+
"list_document_authority_reclassifications(uuid, uuid, text, uuid, integer, timestamp with time zone, uuid)",
|
|
240
|
+
"reclassify_document_authority(jsonb)",
|
|
241
|
+
"run_document_default_collection_backfill(jsonb)",
|
|
242
|
+
"list_document_default_collection_backfill_runs(jsonb)",
|
|
243
|
+
"get_document_default_collection_backfill_audit(jsonb)",
|
|
244
|
+
"list_organization_document_authority_reclassifications(jsonb)",
|
|
245
|
+
] as const;
|
|
246
|
+
const DOCUMENT_MIGRATION_AUDIT_INTERNAL_ROUTINES = [
|
|
247
|
+
"document_migration_audit_capability_active(text)",
|
|
248
|
+
"assert_document_migration_audit_authority(jsonb)",
|
|
249
|
+
] as const;
|
|
250
|
+
const VARIABLE_SET_AUTHORITY_ROUTINES = [
|
|
251
|
+
"create_scoped_variable_set(uuid, uuid, text, text, text, jsonb, boolean)",
|
|
252
|
+
"list_scoped_variable_sets(uuid, uuid, uuid, text, text)",
|
|
253
|
+
"count_scoped_variable_sets(uuid, uuid, text)",
|
|
254
|
+
"mutate_scoped_variable_set(uuid, uuid, uuid, text, text, boolean, text, boolean, text, text, boolean)",
|
|
255
|
+
"read_scoped_variable_set_secret(uuid, uuid, uuid, text, text, text, uuid, uuid, uuid, integer)",
|
|
256
|
+
"materialize_scoped_variable_set_for_attempt(uuid, uuid, uuid, uuid, uuid, integer, uuid)",
|
|
257
|
+
"materialize_scoped_variable_set_for_session(uuid, uuid, uuid, uuid)",
|
|
258
|
+
] as const;
|
|
259
|
+
const SCOPED_COMPUTE_CAPABILITY_PREDICATE_ROUTINE = "scoped_compute_capability_active(text)";
|
|
260
|
+
const SCOPED_COMPUTE_CAPABILITY_TABLE = "scoped_compute_capabilities";
|
|
261
|
+
const CONNECTION_TENANCY_BACKFILL_CAPABILITY_TABLE = "connection_tenancy_backfill_capabilities";
|
|
262
|
+
const CONNECTION_TENANCY_BACKFILL_CAPABILITY_PREDICATE_ROUTINE =
|
|
263
|
+
"connection_tenancy_backfill_capability_active(uuid)";
|
|
264
|
+
const SCOPED_COMPUTE_AUTHORITY_ROUTINES = [
|
|
265
|
+
"create_scoped_rig(uuid, uuid, text, text, text, text, jsonb, boolean)",
|
|
266
|
+
"list_scoped_rigs(uuid, uuid, uuid, text, text)",
|
|
267
|
+
"count_scoped_rigs(uuid, uuid, text)",
|
|
268
|
+
"mutate_scoped_rig(uuid, uuid, uuid, text, text, boolean, text, boolean, boolean)",
|
|
269
|
+
"finalize_scoped_enrollment(uuid, uuid, text, text, boolean, boolean, text, text, text, boolean)",
|
|
270
|
+
"list_scoped_enrollments(uuid, uuid, uuid, text)",
|
|
271
|
+
"get_scoped_sandbox(uuid, uuid, uuid)",
|
|
272
|
+
"authorize_scoped_sandbox_attach(uuid, uuid, uuid)",
|
|
273
|
+
"materialize_scoped_rig_version_for_attempt(uuid, uuid, uuid, uuid, uuid, integer)",
|
|
274
|
+
"authorize_session_attempt_personal_machine(uuid, uuid, uuid, uuid, uuid, integer, uuid)",
|
|
275
|
+
"assert_session_attempt_personal_machine(uuid, uuid, uuid, uuid, uuid, integer, uuid, boolean)",
|
|
276
|
+
"list_scoped_machine_dependent_sessions(uuid, uuid, uuid)",
|
|
277
|
+
"detach_scoped_machine_dependent_sessions(uuid, uuid, uuid)",
|
|
278
|
+
] as const;
|
|
75
279
|
const CANONICAL_HUMAN_IDENTITY_ROUTINES = [
|
|
76
280
|
"ensure_canonical_human_identity(text, text)",
|
|
77
281
|
"validate_canonical_human_session(text, text, boolean)",
|
|
@@ -91,17 +295,130 @@ const TASK_NOTE_CAPABILITY_ROUTINES = [
|
|
|
91
295
|
"create_task_note_for_attempt(uuid, uuid, uuid, uuid, uuid, integer, uuid, text, text, integer)",
|
|
92
296
|
"archive_task_note_for_attempt(uuid, uuid, uuid, uuid, uuid, integer, uuid, uuid, integer, text)",
|
|
93
297
|
"list_task_notes_for_attempt(uuid, uuid, uuid, uuid, uuid, integer, boolean, integer)",
|
|
298
|
+
"replace_task_note_for_attempt(uuid, uuid, uuid, uuid, uuid, integer, uuid, uuid, uuid, uuid, integer, text, text, integer, text)",
|
|
299
|
+
"resolve_task_note_knowledge_promotion_source(uuid, uuid, uuid, uuid, uuid, integer, uuid, integer, text, text, text)",
|
|
300
|
+
] as const;
|
|
301
|
+
const COMPANY_BRAIN_CONTEXT_SELECTION_ROUTINE =
|
|
302
|
+
"company_brain_context_get_or_create_selection(uuid, uuid, uuid, uuid, uuid, integer)";
|
|
303
|
+
const COMPANY_BRAIN_CONTEXT_INSPECTION_ROUTINE =
|
|
304
|
+
"company_brain_inspect_context_receipts(uuid, uuid, text, uuid, timestamp with time zone, uuid, integer)";
|
|
305
|
+
const GOVERNED_LEARNING_EVALUATION_ROUTINE =
|
|
306
|
+
"evaluate_governed_learning_proposal(uuid, uuid, uuid, uuid, uuid, integer, uuid, uuid, uuid, uuid, uuid)";
|
|
307
|
+
const GOVERNED_LEARNING_ACTIVATION_ROUTINES = [
|
|
308
|
+
"activate_governed_learning_decision(uuid, uuid, uuid, uuid)",
|
|
309
|
+
"activate_human_confirmed_learning_decision(uuid, uuid, uuid, uuid, uuid)",
|
|
310
|
+
"confirm_remember_knowledge_claim(uuid, uuid, uuid, uuid, integer, uuid, uuid, uuid)",
|
|
311
|
+
"undo_governed_learning_activation(uuid, uuid, uuid, uuid)",
|
|
312
|
+
] as const;
|
|
313
|
+
const GOVERNED_LEARNING_INSPECTION_ROUTINES = [
|
|
314
|
+
"inspect_governed_learning_decisions(uuid, uuid, text, integer)",
|
|
315
|
+
"inspect_governed_learning_activations(uuid, uuid, text, integer)",
|
|
316
|
+
"inspect_governed_learning_activation_undos(uuid, uuid, text, integer)",
|
|
317
|
+
] as const;
|
|
318
|
+
const GOVERNED_LEARNING_INSPECTION_AUTHORITY_TABLES = [
|
|
319
|
+
"governed_learning_decision_receipts",
|
|
320
|
+
"governed_learning_activation_receipts",
|
|
321
|
+
"governed_learning_activation_undo_receipts",
|
|
322
|
+
"sessions",
|
|
323
|
+
] as const;
|
|
324
|
+
const COMPANY_PROFILE_AGENT_ADMIN_ROUTINES = [
|
|
325
|
+
"propose_company_profile_for_attempt(uuid, uuid, uuid, uuid, uuid, integer, uuid, text, text, text)",
|
|
326
|
+
"confirm_company_profile_for_attempt(uuid, uuid, uuid, uuid, uuid, integer, uuid, uuid, uuid)",
|
|
327
|
+
] as const;
|
|
328
|
+
const COMPANY_PROFILE_AGENT_ADMIN_AUTHORITY_TABLES = [
|
|
329
|
+
"company_profile_activation_events",
|
|
330
|
+
"company_profile_agent_confirmation_receipts",
|
|
331
|
+
"company_profile_agent_proposal_receipts",
|
|
332
|
+
"company_profile_heads",
|
|
333
|
+
"company_profile_revisions",
|
|
334
|
+
"managed_accounts",
|
|
335
|
+
"organization_memberships",
|
|
336
|
+
"session_human_input_requests",
|
|
337
|
+
"session_turn_attempts",
|
|
338
|
+
"session_turns",
|
|
339
|
+
"sessions",
|
|
340
|
+
"workspaces",
|
|
341
|
+
] as const;
|
|
342
|
+
const GOVERNED_LEARNING_EVALUATION_AUTHORITY_TABLES = [
|
|
343
|
+
"document_chunks",
|
|
344
|
+
"documents",
|
|
345
|
+
"governed_learning_decision_receipts",
|
|
346
|
+
"knowledge_change_proposals",
|
|
347
|
+
"knowledge_claim_evidence",
|
|
348
|
+
"knowledge_claim_relations",
|
|
349
|
+
"knowledge_claim_reviews",
|
|
350
|
+
"knowledge_claims",
|
|
351
|
+
"knowledge_document_versions",
|
|
352
|
+
"knowledge_providers",
|
|
353
|
+
"knowledge_source_acl_versions",
|
|
354
|
+
"knowledge_source_objects",
|
|
355
|
+
"knowledge_sources",
|
|
356
|
+
"session_attempt_interruptions",
|
|
357
|
+
"session_turn_attempts",
|
|
358
|
+
"session_turns",
|
|
359
|
+
"sessions",
|
|
360
|
+
"task_notes",
|
|
361
|
+
"workspace_learning_policy_snapshots",
|
|
362
|
+
"workspaces",
|
|
363
|
+
] as const;
|
|
364
|
+
const GOVERNED_LEARNING_ACTIVATION_AUTHORITY_TABLES = [
|
|
365
|
+
...GOVERNED_LEARNING_EVALUATION_AUTHORITY_TABLES,
|
|
366
|
+
"company_brain_preference_proposal_receipts",
|
|
367
|
+
"governed_learning_activation_receipts",
|
|
368
|
+
"governed_learning_activation_undo_receipts",
|
|
369
|
+
"preference_registry_events",
|
|
370
|
+
"preference_registry_preferences",
|
|
371
|
+
"preference_registry_revisions",
|
|
372
|
+
"remember_knowledge_confirmation_receipts",
|
|
373
|
+
"session_human_input_requests",
|
|
374
|
+
"workspace_instruction_policy_activation_events",
|
|
375
|
+
"workspace_instruction_policy_deactivation_events",
|
|
376
|
+
"workspace_instruction_policy_heads",
|
|
377
|
+
"workspace_instruction_policy_onboarding_proposals",
|
|
378
|
+
"workspace_instruction_policy_revisions",
|
|
379
|
+
"workspace_learning_policy_heads",
|
|
380
|
+
"workspace_learning_policy_revisions",
|
|
94
381
|
] as const;
|
|
95
382
|
const TRANSITION_SESSION_VISIBILITY_ROUTINE =
|
|
96
|
-
"transition_session_visibility(uuid, uuid, uuid, text, text, integer, text, text)";
|
|
383
|
+
"transition_session_visibility(uuid, uuid, uuid, text, text, integer, text, text, integer)";
|
|
384
|
+
const LEGACY_FORK_SESSION_CONTENT_ROUTINE =
|
|
385
|
+
"fork_session_content(uuid, uuid, uuid, text, uuid, text, text, text, integer)";
|
|
97
386
|
const FORK_SESSION_CONTENT_ROUTINE =
|
|
98
|
-
"fork_session_content(uuid, uuid, uuid, text, uuid, text, text, text)";
|
|
387
|
+
"fork_session_content(uuid, uuid, uuid, text, uuid, text, boolean, text, text, integer)";
|
|
388
|
+
const REPLAY_APPLIED_SESSION_FORK_ROUTINE =
|
|
389
|
+
"replay_applied_session_fork(uuid, uuid, uuid, text, uuid, text, boolean, text, text, integer)";
|
|
390
|
+
const SESSION_TENANCY_ACTIVATED_ROUTINE = "session_tenancy_product_activated(uuid, integer)";
|
|
391
|
+
const SESSION_TENANCY_ANY_ACTIVATION_ROUTINE = "session_tenancy_any_product_activation()";
|
|
392
|
+
const SESSION_TENANCY_QUIESCENCE_ROUTINE =
|
|
393
|
+
"assert_session_tenancy_quiescent(uuid, uuid, uuid, boolean)";
|
|
394
|
+
const TENANCY_BACKFILL_ACTIVATION_EVIDENCE_ROUTINE =
|
|
395
|
+
"check_tenancy_backfill_activation_evidence(uuid)";
|
|
396
|
+
const SESSION_VISIBILITY_LIFECYCLE_CAPABILITY_ROUTINE =
|
|
397
|
+
"session_visibility_lifecycle_capability_held()";
|
|
398
|
+
const PRIVATE_SESSION_CREATE_CAPABILITY_ROUTINES = [
|
|
399
|
+
"open_private_session_create_capability(uuid, uuid, uuid, text)",
|
|
400
|
+
"open_private_child_session_create_capability(uuid, uuid, uuid, uuid, uuid, uuid, integer)",
|
|
401
|
+
"close_private_session_create_capability(uuid)",
|
|
402
|
+
] as const;
|
|
99
403
|
const SESSION_AUTHORITY_ROUTINES = new Set<string>([
|
|
404
|
+
LEGACY_FORK_SESSION_CONTENT_ROUTINE,
|
|
100
405
|
FORK_SESSION_CONTENT_ROUTINE,
|
|
406
|
+
REPLAY_APPLIED_SESSION_FORK_ROUTINE,
|
|
407
|
+
SESSION_TENANCY_ACTIVATED_ROUTINE,
|
|
408
|
+
SESSION_TENANCY_ANY_ACTIVATION_ROUTINE,
|
|
409
|
+
SESSION_TENANCY_QUIESCENCE_ROUTINE,
|
|
410
|
+
PERSONAL_RESOURCE_ATTEMPT_RESOLVER_ROUTINE,
|
|
411
|
+
...USER_RESOURCE_LIFECYCLE_ROUTINES,
|
|
412
|
+
...CONNECTION_AUTHORITY_ROUTINES,
|
|
413
|
+
...SCHEDULED_PERSONAL_RESOURCE_ROUTINES,
|
|
101
414
|
SESSION_PRIVATE_ACTOR_VISIBLE_ROUTINE,
|
|
102
415
|
SESSION_REFERENCE_VISIBLE_ROUTINE,
|
|
416
|
+
SESSION_VISIBILITY_LIFECYCLE_CAPABILITY_ROUTINE,
|
|
417
|
+
...PRIVATE_SESSION_CREATE_CAPABILITY_ROUTINES,
|
|
103
418
|
TRANSITION_SESSION_VISIBILITY_ROUTINE,
|
|
104
419
|
...TASK_NOTE_CAPABILITY_ROUTINES,
|
|
420
|
+
COMPANY_BRAIN_CONTEXT_SELECTION_ROUTINE,
|
|
421
|
+
COMPANY_BRAIN_CONTEXT_INSPECTION_ROUTINE,
|
|
105
422
|
]);
|
|
106
423
|
const XAI_CREATE_CREDENTIAL_ROUTINE =
|
|
107
424
|
"create_xai_subscription_credential(uuid, uuid, text, text, text, text, text, text, text, timestamp with time zone)";
|
|
@@ -122,7 +439,17 @@ const XAI_AUTHORITY_TABLES = [
|
|
|
122
439
|
] as const;
|
|
123
440
|
|
|
124
441
|
export const RUNTIME_TARGET_SCHEMA_CAPABILITY_ROUTINES = [
|
|
442
|
+
COMPANY_BRAIN_CONTEXT_INSPECTION_ROUTINE,
|
|
443
|
+
COMPANY_BRAIN_CONTEXT_SELECTION_ROUTINE,
|
|
444
|
+
...COMPANY_PROFILE_AGENT_ADMIN_ROUTINES,
|
|
445
|
+
GOVERNED_LEARNING_EVALUATION_ROUTINE,
|
|
446
|
+
...GOVERNED_LEARNING_ACTIVATION_ROUTINES,
|
|
447
|
+
...GOVERNED_LEARNING_INSPECTION_ROUTINES,
|
|
125
448
|
FORK_SESSION_CONTENT_ROUTINE,
|
|
449
|
+
LEGACY_FORK_SESSION_CONTENT_ROUTINE,
|
|
450
|
+
REPLAY_APPLIED_SESSION_FORK_ROUTINE,
|
|
451
|
+
SESSION_TENANCY_ACTIVATED_ROUTINE,
|
|
452
|
+
SESSION_TENANCY_ANY_ACTIVATION_ROUTINE,
|
|
126
453
|
XAI_AUTHORITY_LIVE_ROUTINE,
|
|
127
454
|
XAI_CREATE_CREDENTIAL_ROUTINE,
|
|
128
455
|
XAI_DISCONNECT_CREDENTIAL_ROUTINE,
|
|
@@ -130,9 +457,24 @@ export const RUNTIME_TARGET_SCHEMA_CAPABILITY_ROUTINES = [
|
|
|
130
457
|
GOOGLE_DRIVE_FILE_AUTHORIZATION_ROUTINE,
|
|
131
458
|
KNOWLEDGE_SOURCE_SYNC_LOCK_AUTHORITY_ROUTINE,
|
|
132
459
|
MANAGED_HUMAN_PERSONAL_WORKSPACE_ROUTINE,
|
|
460
|
+
...ORGANIZATION_MEMBERSHIP_LIFECYCLE_ROUTINES,
|
|
461
|
+
...ORGANIZATION_PRIVATE_SESSION_ROUTINES,
|
|
462
|
+
...PRIVATE_SESSION_CREATE_CAPABILITY_ROUTINES,
|
|
463
|
+
PERSONAL_RESOURCE_ATTEMPT_RESOLVER_ROUTINE,
|
|
464
|
+
...USER_RESOURCE_LIFECYCLE_ROUTINES,
|
|
465
|
+
PREFERENCE_KNOWLEDGE_PROPOSAL_ROUTINE,
|
|
466
|
+
...VARIABLE_SET_AUTHORITY_ROUTINES,
|
|
467
|
+
...CONNECTION_AUTHORITY_ROUTINES,
|
|
468
|
+
...PERSONAL_GITHUB_REPOSITORY_AUTHORITY_ROUTINES,
|
|
469
|
+
...PERSONAL_DOCUMENT_AUTHORITY_ROUTINES,
|
|
470
|
+
...DOCUMENT_MIGRATION_AUTHORITY_ROUTINES,
|
|
471
|
+
...SCOPED_COMPUTE_AUTHORITY_ROUTINES,
|
|
472
|
+
...SCHEDULED_PERSONAL_RESOURCE_ROUTINES,
|
|
133
473
|
...CANONICAL_HUMAN_IDENTITY_ROUTINES,
|
|
474
|
+
...TASK_NOTE_CAPABILITY_ROUTINES,
|
|
134
475
|
SESSION_PRIVATE_ACTOR_VISIBLE_ROUTINE,
|
|
135
476
|
SESSION_REFERENCE_VISIBLE_ROUTINE,
|
|
477
|
+
SESSION_VISIBILITY_LIFECYCLE_CAPABILITY_ROUTINE,
|
|
136
478
|
TRANSITION_SESSION_VISIBILITY_ROUTINE,
|
|
137
479
|
XAI_POOL_VISIBLE_ROUTINE,
|
|
138
480
|
XAI_RESOLVE_POOL_ROUTINE,
|
|
@@ -140,6 +482,27 @@ export const RUNTIME_TARGET_SCHEMA_CAPABILITY_ROUTINES = [
|
|
|
140
482
|
XAI_SNAPSHOT_VALIDATOR_ROUTINE,
|
|
141
483
|
] as const;
|
|
142
484
|
|
|
485
|
+
/**
|
|
486
|
+
* Boolean-only predicates that shared-table RLS policies must be able to
|
|
487
|
+
* evaluate under table owners and SECURITY DEFINER roles unknown at migration
|
|
488
|
+
* time. The capability ledger and the routine that mints its opaque token stay
|
|
489
|
+
* private; only these exact policy predicates may be PUBLIC-executable.
|
|
490
|
+
*/
|
|
491
|
+
export const RUNTIME_TARGET_SCHEMA_PUBLIC_POLICY_PREDICATE_ROUTINES = [
|
|
492
|
+
CONNECTION_CONVERGENCE_AUDIT_CAPABILITY_ROUTINE,
|
|
493
|
+
] as const;
|
|
494
|
+
const RUNTIME_TARGET_SCHEMA_PUBLIC_POLICY_PREDICATE_ROUTINE_SET = new Set<string>(
|
|
495
|
+
RUNTIME_TARGET_SCHEMA_PUBLIC_POLICY_PREDICATE_ROUTINES,
|
|
496
|
+
);
|
|
497
|
+
|
|
498
|
+
/** Owner-internal helpers that must exist but must never be callable by the runtime role. */
|
|
499
|
+
export const RUNTIME_TARGET_SCHEMA_FORBIDDEN_ROUTINES = [
|
|
500
|
+
ORGANIZATION_PRIVATE_SESSIONS_ENABLED_ROUTINE,
|
|
501
|
+
SESSION_TENANCY_QUIESCENCE_ROUTINE,
|
|
502
|
+
TENANCY_BACKFILL_ACTIVATION_EVIDENCE_ROUTINE,
|
|
503
|
+
...DOCUMENT_MIGRATION_AUDIT_INTERNAL_ROUTINES,
|
|
504
|
+
] as const;
|
|
505
|
+
|
|
143
506
|
export const RUNTIME_TARGET_SCHEMA_INVOKER_ROUTINES = [
|
|
144
507
|
SESSION_REFERENCE_VISIBLE_ROUTINE,
|
|
145
508
|
XAI_SNAPSHOT_VALIDATOR_ROUTINE,
|
|
@@ -160,6 +523,12 @@ export const FORCE_RLS_TABLES = [
|
|
|
160
523
|
"attached_browser_inventories",
|
|
161
524
|
"audit_events",
|
|
162
525
|
"auth_runs",
|
|
526
|
+
"automation_run_event_links",
|
|
527
|
+
"automation_runs",
|
|
528
|
+
"automation_sources",
|
|
529
|
+
"automation_trigger_events",
|
|
530
|
+
"automation_trigger_revisions",
|
|
531
|
+
"automation_triggers",
|
|
163
532
|
"billing_customers",
|
|
164
533
|
"browser_identities",
|
|
165
534
|
"browser_revision_components",
|
|
@@ -193,7 +562,12 @@ export const FORCE_RLS_TABLES = [
|
|
|
193
562
|
"codex_reset_redemption_attempts",
|
|
194
563
|
"codex_rotation_settings",
|
|
195
564
|
"codex_subscription_credentials",
|
|
565
|
+
"company_brain_context_selection_receipts",
|
|
566
|
+
"company_brain_preference_proposal_receipts",
|
|
567
|
+
"company_brain_turn_context_snapshots",
|
|
196
568
|
"company_profile_activation_events",
|
|
569
|
+
"company_profile_agent_confirmation_receipts",
|
|
570
|
+
"company_profile_agent_proposal_receipts",
|
|
197
571
|
"company_profile_heads",
|
|
198
572
|
"company_profile_revisions",
|
|
199
573
|
"company_profile_snapshots",
|
|
@@ -201,13 +575,19 @@ export const FORCE_RLS_TABLES = [
|
|
|
201
575
|
"computer_session_associations",
|
|
202
576
|
"computer_sessions",
|
|
203
577
|
"connection_disconnect_operations",
|
|
578
|
+
"connection_use_audit_facts",
|
|
579
|
+
"connection_use_once_consumption_receipts",
|
|
204
580
|
"connections",
|
|
205
581
|
"connector_action_policies",
|
|
206
582
|
"connector_action_requests",
|
|
207
583
|
"credit_ledger_entries",
|
|
208
584
|
"device_enrollment_requests",
|
|
585
|
+
"document_authority_reclassifications",
|
|
209
586
|
"document_bases",
|
|
210
587
|
"document_chunks",
|
|
588
|
+
"document_default_collection_backfill_operations",
|
|
589
|
+
"document_default_collection_backfill_receipts",
|
|
590
|
+
"document_default_collection_backfill_runs",
|
|
211
591
|
"documents",
|
|
212
592
|
"editable_artifact_blob_refs",
|
|
213
593
|
"editable_artifact_idempotency_receipts",
|
|
@@ -234,6 +614,9 @@ export const FORCE_RLS_TABLES = [
|
|
|
234
614
|
"github_installations",
|
|
235
615
|
"google_drive_object_acl_evidence",
|
|
236
616
|
"google_drive_object_acl_principals",
|
|
617
|
+
"governed_learning_activation_receipts",
|
|
618
|
+
"governed_learning_activation_undo_receipts",
|
|
619
|
+
"governed_learning_decision_receipts",
|
|
237
620
|
"host_export_config",
|
|
238
621
|
"host_export_consumers",
|
|
239
622
|
"host_export_cursor_state",
|
|
@@ -283,16 +666,37 @@ export const FORCE_RLS_TABLES = [
|
|
|
283
666
|
"model_call_facts",
|
|
284
667
|
"network_routes",
|
|
285
668
|
"new_session_drafts",
|
|
669
|
+
"organization_invitation_binding_events",
|
|
670
|
+
"organization_membership_invitations",
|
|
671
|
+
"organization_membership_lifecycle_events",
|
|
672
|
+
"organization_membership_operation_receipts",
|
|
286
673
|
"organization_memberships",
|
|
674
|
+
"organization_private_session_setting_events",
|
|
675
|
+
"organization_private_session_settings",
|
|
676
|
+
"organization_profile_events",
|
|
677
|
+
"organization_shared_workspace_administration_capabilities",
|
|
287
678
|
"organization_user_resource_authorities",
|
|
288
679
|
"organization_user_resource_grants",
|
|
680
|
+
"organization_user_retention_deletion_events",
|
|
681
|
+
"organization_user_retention_deletions",
|
|
682
|
+
"organization_user_retention_object_deletion_receipts",
|
|
683
|
+
"organization_user_retention_object_obligations",
|
|
289
684
|
"organization_user_retention_policies",
|
|
290
685
|
"pack_installation_components",
|
|
291
686
|
"pack_installations",
|
|
687
|
+
"personal_document_once_consumption_receipts",
|
|
688
|
+
"personal_github_repository_selection_heads",
|
|
689
|
+
"personal_github_repository_selection_operations",
|
|
690
|
+
"personal_github_repository_selections",
|
|
691
|
+
"personal_resource_once_consumption_receipts",
|
|
692
|
+
"pr_review_app_registrations",
|
|
693
|
+
"pr_review_repository_bindings",
|
|
292
694
|
"preference_registry_events",
|
|
293
695
|
"preference_registry_preferences",
|
|
294
696
|
"preference_registry_revisions",
|
|
295
697
|
"preference_registry_snapshots",
|
|
698
|
+
"private_session_create_capabilities",
|
|
699
|
+
"remember_knowledge_confirmation_receipts",
|
|
296
700
|
"retained_screenshot_artifacts",
|
|
297
701
|
"rig_changes",
|
|
298
702
|
"rig_versions",
|
|
@@ -305,11 +709,26 @@ export const FORCE_RLS_TABLES = [
|
|
|
305
709
|
"sandbox_session_envelopes",
|
|
306
710
|
"sandbox_workspace_mutation_admissions",
|
|
307
711
|
"sandboxes",
|
|
712
|
+
"scheduled_task_connection_authority_snapshots",
|
|
713
|
+
"scheduled_task_personal_resource_authorities",
|
|
714
|
+
"scheduled_task_personal_resource_snapshots",
|
|
715
|
+
"scheduled_task_reusable_connection_materializations",
|
|
716
|
+
"scheduled_task_revision_authorities",
|
|
717
|
+
"scheduled_task_run_connection_authority_snapshots",
|
|
718
|
+
"scheduled_task_run_personal_resource_admissions",
|
|
719
|
+
"scheduled_task_run_personal_resource_once_receipts",
|
|
720
|
+
"scheduled_task_run_personal_resource_snapshots",
|
|
308
721
|
"scheduled_task_runs",
|
|
309
722
|
"scheduled_tasks",
|
|
310
723
|
"session_attempt_codemode_calls",
|
|
724
|
+
"session_attempt_connected_machine_authorizations",
|
|
311
725
|
"session_attempt_interruptions",
|
|
726
|
+
"session_attempt_personal_document_admissions",
|
|
727
|
+
"session_attempt_personal_document_snapshots",
|
|
728
|
+
"session_attempt_personal_resource_admissions",
|
|
729
|
+
"session_attempt_personal_resource_snapshots",
|
|
312
730
|
"session_attempt_tool_catalogs",
|
|
731
|
+
"session_background_commands",
|
|
313
732
|
"session_command_receipts",
|
|
314
733
|
"session_events",
|
|
315
734
|
"session_goal_revisions",
|
|
@@ -329,37 +748,52 @@ export const FORCE_RLS_TABLES = [
|
|
|
329
748
|
"session_stream_acknowledgments",
|
|
330
749
|
"session_system_update_outbox",
|
|
331
750
|
"session_system_updates",
|
|
751
|
+
"session_tenancy_activations",
|
|
332
752
|
"session_turn_attempts",
|
|
753
|
+
"session_turn_startup_milestones",
|
|
333
754
|
"session_turns",
|
|
334
755
|
"session_visibility_write_capabilities",
|
|
335
756
|
"session_workflow_wake_outbox",
|
|
336
757
|
"sessions",
|
|
337
758
|
"site_auth_connections",
|
|
759
|
+
"slack_app_home_refreshes",
|
|
338
760
|
"slack_bot_delete_operations",
|
|
339
761
|
"slack_bot_post_operations",
|
|
340
762
|
"slack_bot_update_operations",
|
|
341
763
|
"slack_bot_user_links",
|
|
764
|
+
"slack_channel_routes",
|
|
342
765
|
"slack_installation_bindings",
|
|
343
766
|
"slack_interaction_action_handles",
|
|
344
767
|
"slack_interaction_inbox",
|
|
345
768
|
"slack_interaction_progress_deliveries",
|
|
346
769
|
"slack_interactions",
|
|
770
|
+
"slack_route_prompt_options",
|
|
771
|
+
"slack_route_prompts",
|
|
347
772
|
"slack_shared_task_origins",
|
|
348
773
|
"slack_task_policy_activation_events",
|
|
349
774
|
"slack_task_policy_heads",
|
|
350
775
|
"slack_task_policy_revisions",
|
|
776
|
+
"slack_user_dm_routes",
|
|
351
777
|
"slack_user_link_access_request_operations",
|
|
352
778
|
"slack_user_link_access_requests",
|
|
353
779
|
"social_connections",
|
|
354
780
|
"social_posts",
|
|
355
781
|
"task_note_events",
|
|
782
|
+
"task_note_knowledge_promotion_capabilities",
|
|
783
|
+
"task_note_replacement_receipts",
|
|
356
784
|
"task_note_write_capabilities",
|
|
357
785
|
"task_notes",
|
|
358
786
|
"temporal_schedule_cleanup_outbox",
|
|
787
|
+
"tenancy_backfill_receipts",
|
|
788
|
+
"tenancy_backfill_unresolved_rows",
|
|
359
789
|
"transcription_recording_chunks",
|
|
360
790
|
"transcription_recording_objects",
|
|
361
791
|
"transcription_recording_segments",
|
|
362
792
|
"transcription_recordings",
|
|
793
|
+
"turn_connection_authority_snapshots",
|
|
794
|
+
"turn_personal_resource_attachment_receipts",
|
|
795
|
+
"turn_personal_resource_once_receipts",
|
|
796
|
+
"turn_personal_resource_snapshots",
|
|
363
797
|
"usage_events",
|
|
364
798
|
"video_generation_operations",
|
|
365
799
|
"video_generation_references",
|
|
@@ -370,6 +804,7 @@ export const FORCE_RLS_TABLES = [
|
|
|
370
804
|
"workspace_control_events",
|
|
371
805
|
"workspace_inference_controls",
|
|
372
806
|
"workspace_instruction_policy_activation_events",
|
|
807
|
+
"workspace_instruction_policy_deactivation_events",
|
|
373
808
|
"workspace_instruction_policy_heads",
|
|
374
809
|
"workspace_instruction_policy_onboarding_proposals",
|
|
375
810
|
"workspace_instruction_policy_revisions",
|
|
@@ -405,6 +840,7 @@ export const NON_RLS_RUNTIME_TABLES = [
|
|
|
405
840
|
"auth_sessions",
|
|
406
841
|
"auth_users",
|
|
407
842
|
"auth_verifications",
|
|
843
|
+
"automation_webhook_endpoints",
|
|
408
844
|
"integration_oauth_clients",
|
|
409
845
|
"managed_accounts",
|
|
410
846
|
"nested_agent_depth_configuration",
|
|
@@ -427,6 +863,13 @@ export const RUNTIME_FULL_DML_TABLES = [
|
|
|
427
863
|
"auth_sessions",
|
|
428
864
|
"auth_users",
|
|
429
865
|
"auth_verifications",
|
|
866
|
+
"automation_run_event_links",
|
|
867
|
+
"automation_runs",
|
|
868
|
+
"automation_sources",
|
|
869
|
+
"automation_trigger_events",
|
|
870
|
+
"automation_trigger_revisions",
|
|
871
|
+
"automation_triggers",
|
|
872
|
+
"automation_webhook_endpoints",
|
|
430
873
|
"billing_customers",
|
|
431
874
|
"browser_session_associations",
|
|
432
875
|
"capability_catalog_items",
|
|
@@ -484,6 +927,8 @@ export const RUNTIME_FULL_DML_TABLES = [
|
|
|
484
927
|
"new_session_drafts",
|
|
485
928
|
"pack_installation_components",
|
|
486
929
|
"pack_installations",
|
|
930
|
+
"pr_review_app_registrations",
|
|
931
|
+
"pr_review_repository_bindings",
|
|
487
932
|
"retained_screenshot_artifacts",
|
|
488
933
|
"rig_changes",
|
|
489
934
|
"rig_versions",
|
|
@@ -496,9 +941,8 @@ export const RUNTIME_FULL_DML_TABLES = [
|
|
|
496
941
|
"sandbox_session_envelopes",
|
|
497
942
|
"sandbox_workspace_mutation_admissions",
|
|
498
943
|
"sandboxes",
|
|
499
|
-
"scheduled_task_runs",
|
|
500
|
-
"scheduled_tasks",
|
|
501
944
|
"session_attempt_interruptions",
|
|
945
|
+
"session_background_commands",
|
|
502
946
|
"session_command_receipts",
|
|
503
947
|
"session_events",
|
|
504
948
|
"session_goals",
|
|
@@ -520,14 +964,19 @@ export const RUNTIME_FULL_DML_TABLES = [
|
|
|
520
964
|
"session_turns",
|
|
521
965
|
"session_workflow_wake_outbox",
|
|
522
966
|
"sessions",
|
|
967
|
+
"slack_app_home_refreshes",
|
|
523
968
|
"slack_bot_delete_operations",
|
|
524
969
|
"slack_bot_post_operations",
|
|
525
970
|
"slack_bot_update_operations",
|
|
526
971
|
"slack_bot_user_links",
|
|
972
|
+
"slack_channel_routes",
|
|
527
973
|
"slack_interaction_action_handles",
|
|
528
974
|
"slack_interaction_inbox",
|
|
529
975
|
"slack_interaction_progress_deliveries",
|
|
530
976
|
"slack_interactions",
|
|
977
|
+
"slack_route_prompt_options",
|
|
978
|
+
"slack_route_prompts",
|
|
979
|
+
"slack_user_dm_routes",
|
|
531
980
|
"social_connections",
|
|
532
981
|
"social_posts",
|
|
533
982
|
"stripe_webhook_events",
|
|
@@ -547,8 +996,6 @@ export const RUNTIME_FULL_DML_TABLES = [
|
|
|
547
996
|
"workspace_model_policies",
|
|
548
997
|
"workspace_packs",
|
|
549
998
|
"workspace_screenshot_quotas",
|
|
550
|
-
"workspace_variable_set_variables",
|
|
551
|
-
"workspace_variable_sets",
|
|
552
999
|
"workspace_video_generation_policies",
|
|
553
1000
|
"workspace_video_generation_quotas",
|
|
554
1001
|
"workspaces",
|
|
@@ -564,16 +1011,19 @@ export const RUNTIME_READ_ONLY_TABLES = [
|
|
|
564
1011
|
"company_profile_activation_events",
|
|
565
1012
|
"company_profile_heads",
|
|
566
1013
|
"company_profile_snapshots",
|
|
1014
|
+
"document_authority_reclassifications",
|
|
567
1015
|
"knowledge_lifecycle_events",
|
|
568
1016
|
"knowledge_memory_lifecycle_events",
|
|
569
1017
|
"knowledge_memory_relationships",
|
|
570
1018
|
"nested_agent_depth_configuration",
|
|
571
1019
|
"preference_registry_events",
|
|
572
1020
|
"preference_registry_snapshots",
|
|
1021
|
+
"session_tenancy_activations",
|
|
573
1022
|
"slack_installation_bindings",
|
|
574
1023
|
"slack_task_policy_activation_events",
|
|
575
1024
|
"slack_task_policy_heads",
|
|
576
1025
|
"slack_task_policy_revisions",
|
|
1026
|
+
"workspace_instruction_policy_deactivation_events",
|
|
577
1027
|
"workspace_instruction_policy_snapshots",
|
|
578
1028
|
"workspace_learning_policy_activation_events",
|
|
579
1029
|
"workspace_learning_policy_heads",
|
|
@@ -659,7 +1109,10 @@ export const RUNTIME_READ_INSERT_UPDATE_TABLES = [
|
|
|
659
1109
|
"interaction_operations",
|
|
660
1110
|
"interaction_resource_operations",
|
|
661
1111
|
"network_routes",
|
|
1112
|
+
"scheduled_task_runs",
|
|
1113
|
+
"scheduled_tasks",
|
|
662
1114
|
"session_attempt_codemode_calls",
|
|
1115
|
+
"session_turn_startup_milestones",
|
|
663
1116
|
"site_auth_connections",
|
|
664
1117
|
"slack_user_link_access_requests",
|
|
665
1118
|
"workspace_interaction_revisions",
|
|
@@ -674,21 +1127,77 @@ export const PROTECTED_NO_DIRECT_DML_TABLES = [
|
|
|
674
1127
|
"canonical_human_identity_operations",
|
|
675
1128
|
"canonical_human_identity_subjects",
|
|
676
1129
|
"canonical_human_login_bindings",
|
|
1130
|
+
"company_brain_context_selection_receipts",
|
|
1131
|
+
"company_brain_preference_proposal_receipts",
|
|
1132
|
+
"company_brain_turn_context_snapshots",
|
|
1133
|
+
"company_profile_agent_confirmation_receipts",
|
|
1134
|
+
"company_profile_agent_proposal_receipts",
|
|
1135
|
+
"connection_use_audit_facts",
|
|
1136
|
+
"connection_use_once_consumption_receipts",
|
|
1137
|
+
"document_default_collection_backfill_operations",
|
|
1138
|
+
"document_default_collection_backfill_receipts",
|
|
1139
|
+
"document_default_collection_backfill_runs",
|
|
677
1140
|
"editable_artifact_live_tickets",
|
|
678
1141
|
"editable_artifact_scope_authorization_heads",
|
|
1142
|
+
"governed_learning_activation_receipts",
|
|
1143
|
+
"governed_learning_activation_undo_receipts",
|
|
1144
|
+
"governed_learning_decision_receipts",
|
|
679
1145
|
"host_export_config",
|
|
680
1146
|
"host_export_consumers",
|
|
681
1147
|
"host_export_cursor_state",
|
|
682
1148
|
"host_export_dead_letters",
|
|
683
1149
|
"host_export_outbox",
|
|
1150
|
+
"organization_invitation_binding_events",
|
|
1151
|
+
"organization_membership_invitations",
|
|
1152
|
+
"organization_membership_lifecycle_events",
|
|
1153
|
+
"organization_membership_operation_receipts",
|
|
684
1154
|
"organization_memberships",
|
|
1155
|
+
"organization_private_session_setting_events",
|
|
1156
|
+
"organization_private_session_settings",
|
|
1157
|
+
"organization_profile_events",
|
|
1158
|
+
"organization_shared_workspace_administration_capabilities",
|
|
685
1159
|
"organization_user_resource_authorities",
|
|
686
1160
|
"organization_user_resource_grants",
|
|
1161
|
+
"organization_user_retention_deletion_events",
|
|
1162
|
+
"organization_user_retention_deletions",
|
|
1163
|
+
"organization_user_retention_object_deletion_receipts",
|
|
1164
|
+
"organization_user_retention_object_obligations",
|
|
687
1165
|
"organization_user_retention_policies",
|
|
1166
|
+
"personal_document_once_consumption_receipts",
|
|
1167
|
+
"personal_github_repository_selection_heads",
|
|
1168
|
+
"personal_github_repository_selection_operations",
|
|
1169
|
+
"personal_github_repository_selections",
|
|
1170
|
+
"personal_resource_once_consumption_receipts",
|
|
1171
|
+
"private_session_create_capabilities",
|
|
1172
|
+
"remember_knowledge_confirmation_receipts",
|
|
1173
|
+
"scheduled_task_connection_authority_snapshots",
|
|
1174
|
+
"scheduled_task_personal_resource_authorities",
|
|
1175
|
+
"scheduled_task_personal_resource_snapshots",
|
|
1176
|
+
"scheduled_task_reusable_connection_materializations",
|
|
1177
|
+
"scheduled_task_revision_authorities",
|
|
1178
|
+
"scheduled_task_run_connection_authority_snapshots",
|
|
1179
|
+
"scheduled_task_run_personal_resource_admissions",
|
|
1180
|
+
"scheduled_task_run_personal_resource_once_receipts",
|
|
1181
|
+
"scheduled_task_run_personal_resource_snapshots",
|
|
1182
|
+
"session_attempt_connected_machine_authorizations",
|
|
1183
|
+
"session_attempt_personal_document_admissions",
|
|
1184
|
+
"session_attempt_personal_document_snapshots",
|
|
1185
|
+
"session_attempt_personal_resource_admissions",
|
|
1186
|
+
"session_attempt_personal_resource_snapshots",
|
|
688
1187
|
"session_visibility_write_capabilities",
|
|
689
1188
|
"task_note_events",
|
|
1189
|
+
"task_note_knowledge_promotion_capabilities",
|
|
1190
|
+
"task_note_replacement_receipts",
|
|
690
1191
|
"task_note_write_capabilities",
|
|
691
1192
|
"task_notes",
|
|
1193
|
+
"tenancy_backfill_receipts",
|
|
1194
|
+
"tenancy_backfill_unresolved_rows",
|
|
1195
|
+
"turn_connection_authority_snapshots",
|
|
1196
|
+
"turn_personal_resource_attachment_receipts",
|
|
1197
|
+
"turn_personal_resource_once_receipts",
|
|
1198
|
+
"turn_personal_resource_snapshots",
|
|
1199
|
+
"workspace_variable_set_variables",
|
|
1200
|
+
"workspace_variable_sets",
|
|
692
1201
|
] as const;
|
|
693
1202
|
|
|
694
1203
|
export type RuntimeTableDmlPrivilege = "SELECT" | "INSERT" | "UPDATE" | "DELETE";
|
|
@@ -728,6 +1237,7 @@ export type RuntimeDatabasePostureOptions = {
|
|
|
728
1237
|
protectedTables?: readonly string[];
|
|
729
1238
|
tablePrivileges?: RuntimeTablePrivilegeContract;
|
|
730
1239
|
protectedNoDirectDmlTables?: readonly string[];
|
|
1240
|
+
organizationTenancyCanonicalActivationEnabled?: boolean;
|
|
731
1241
|
};
|
|
732
1242
|
|
|
733
1243
|
export type RuntimeDatabaseIdentity = {
|
|
@@ -775,6 +1285,7 @@ export type RuntimeRoutinePosture = {
|
|
|
775
1285
|
name: string;
|
|
776
1286
|
owner: string;
|
|
777
1287
|
execute: boolean;
|
|
1288
|
+
publicExecute?: boolean;
|
|
778
1289
|
securityDefiner: boolean;
|
|
779
1290
|
};
|
|
780
1291
|
|
|
@@ -782,6 +1293,15 @@ export type RuntimeTargetRoutinePosture = RuntimeRoutinePosture & {
|
|
|
782
1293
|
publicExecute: boolean;
|
|
783
1294
|
};
|
|
784
1295
|
|
|
1296
|
+
export type RuntimePrivateTablePosture = {
|
|
1297
|
+
name: string;
|
|
1298
|
+
owner: string;
|
|
1299
|
+
select: boolean;
|
|
1300
|
+
insert: boolean;
|
|
1301
|
+
update: boolean;
|
|
1302
|
+
delete: boolean;
|
|
1303
|
+
};
|
|
1304
|
+
|
|
785
1305
|
export type RuntimeDatabasePosture = {
|
|
786
1306
|
identity: RuntimeDatabaseIdentity;
|
|
787
1307
|
/** Privilege-bearing role relationships; exact PG16+ management-only grants are excluded. */
|
|
@@ -790,8 +1310,10 @@ export type RuntimeDatabasePosture = {
|
|
|
790
1310
|
ownedSchemas: string[];
|
|
791
1311
|
ownedRelations: string[];
|
|
792
1312
|
tables: RuntimeTablePosture[];
|
|
1313
|
+
privateTables: RuntimePrivateTablePosture[];
|
|
793
1314
|
targetRoutines: RuntimeTargetRoutinePosture[];
|
|
794
1315
|
privateRoutines: RuntimeRoutinePosture[];
|
|
1316
|
+
sessionTenancyProductActivationPresent: boolean;
|
|
795
1317
|
};
|
|
796
1318
|
|
|
797
1319
|
export class RuntimeDatabasePostureError extends Error {
|
|
@@ -839,7 +1361,7 @@ function difference(left: ReadonlySet<string>, right: ReadonlySet<string>): stri
|
|
|
839
1361
|
return sorted([...left].filter((value) => !right.has(value)));
|
|
840
1362
|
}
|
|
841
1363
|
|
|
842
|
-
/** Inspect
|
|
1364
|
+
/** Inspect PostgreSQL catalogs plus one value-free global activation predicate; no tenant content. */
|
|
843
1365
|
export async function inspectRuntimeDatabasePosture(
|
|
844
1366
|
db: Database,
|
|
845
1367
|
options: RuntimeDatabasePostureOptions,
|
|
@@ -890,6 +1412,15 @@ export async function inspectRuntimeDatabasePosture(
|
|
|
890
1412
|
bypassRls: identity.rolbypassrls,
|
|
891
1413
|
};
|
|
892
1414
|
|
|
1415
|
+
// The forward-only activation receipt outlives topology. Embedded/scoped
|
|
1416
|
+
// deployments must enforce the same environment interlock as standalone
|
|
1417
|
+
// FORCE-RLS deployments, so inspect the value-free predicate before the
|
|
1418
|
+
// scoped catalog fast-path.
|
|
1419
|
+
const activationRows = resultRows<{ activated: boolean }>(
|
|
1420
|
+
await tx.execute(sql`select session_tenancy_any_product_activation() as activated`),
|
|
1421
|
+
);
|
|
1422
|
+
const sessionTenancyProductActivationPresent = activationRows[0]?.activated === true;
|
|
1423
|
+
|
|
893
1424
|
// Scoped/embedded topology deliberately leaves ownership and isolation to
|
|
894
1425
|
// the host. Prove the connection identity is coherent, but do not impose
|
|
895
1426
|
// the standalone opengeni_app object/grant contract on the host's role.
|
|
@@ -901,8 +1432,10 @@ export async function inspectRuntimeDatabasePosture(
|
|
|
901
1432
|
ownedSchemas: [],
|
|
902
1433
|
ownedRelations: [],
|
|
903
1434
|
tables: [],
|
|
1435
|
+
privateTables: [],
|
|
904
1436
|
targetRoutines: [],
|
|
905
1437
|
privateRoutines: [],
|
|
1438
|
+
sessionTenancyProductActivationPresent,
|
|
906
1439
|
};
|
|
907
1440
|
}
|
|
908
1441
|
|
|
@@ -1021,6 +1554,45 @@ export async function inspectRuntimeDatabasePosture(
|
|
|
1021
1554
|
trigger: row.can_trigger,
|
|
1022
1555
|
}));
|
|
1023
1556
|
|
|
1557
|
+
const privateTables = resultRows<{
|
|
1558
|
+
name: string;
|
|
1559
|
+
owner: string;
|
|
1560
|
+
can_select: boolean;
|
|
1561
|
+
can_insert: boolean;
|
|
1562
|
+
can_update: boolean;
|
|
1563
|
+
can_delete: boolean;
|
|
1564
|
+
}>(
|
|
1565
|
+
await tx.execute(sql`
|
|
1566
|
+
select
|
|
1567
|
+
c.relname::text as name,
|
|
1568
|
+
pg_get_userbyid(c.relowner)::text as owner,
|
|
1569
|
+
has_table_privilege(current_user, c.oid, 'SELECT') as can_select,
|
|
1570
|
+
has_table_privilege(current_user, c.oid, 'INSERT') as can_insert,
|
|
1571
|
+
has_table_privilege(current_user, c.oid, 'UPDATE') as can_update,
|
|
1572
|
+
has_table_privilege(current_user, c.oid, 'DELETE') as can_delete
|
|
1573
|
+
from pg_class c
|
|
1574
|
+
join pg_namespace n on n.oid = c.relnamespace
|
|
1575
|
+
where n.nspname = 'opengeni_private'
|
|
1576
|
+
and c.relkind in ('r', 'p')
|
|
1577
|
+
and c.relname in (
|
|
1578
|
+
${PERSONAL_RESOURCE_CAPABILITY_TABLE},
|
|
1579
|
+
${SCHEDULED_PERSONAL_RESOURCE_CAPABILITY_TABLE},
|
|
1580
|
+
${VARIABLE_SET_CAPABILITY_TABLE},
|
|
1581
|
+
${PERSONAL_DOCUMENT_CAPABILITY_TABLE},
|
|
1582
|
+
${DOCUMENT_MIGRATION_CAPABILITY_TABLE},
|
|
1583
|
+
${SCOPED_COMPUTE_CAPABILITY_TABLE},
|
|
1584
|
+
${CONNECTION_TENANCY_BACKFILL_CAPABILITY_TABLE}
|
|
1585
|
+
)
|
|
1586
|
+
`),
|
|
1587
|
+
).map((row) => ({
|
|
1588
|
+
name: row.name,
|
|
1589
|
+
owner: row.owner,
|
|
1590
|
+
select: row.can_select,
|
|
1591
|
+
insert: row.can_insert,
|
|
1592
|
+
update: row.can_update,
|
|
1593
|
+
delete: row.can_delete,
|
|
1594
|
+
}));
|
|
1595
|
+
|
|
1024
1596
|
const targetRoutines = resultRows<{
|
|
1025
1597
|
name: string;
|
|
1026
1598
|
owner: string;
|
|
@@ -1046,25 +1618,31 @@ export async function inspectRuntimeDatabasePosture(
|
|
|
1046
1618
|
and (p.proname || '(' || pg_catalog.oidvectortypes(p.proargtypes) || ')') = any(
|
|
1047
1619
|
array[
|
|
1048
1620
|
${sql.join(
|
|
1049
|
-
|
|
1621
|
+
[
|
|
1622
|
+
...RUNTIME_TARGET_SCHEMA_CAPABILITY_ROUTINES,
|
|
1623
|
+
...RUNTIME_TARGET_SCHEMA_FORBIDDEN_ROUTINES,
|
|
1624
|
+
].map((name) => sql`${name}`),
|
|
1050
1625
|
sql`, `,
|
|
1051
1626
|
)}
|
|
1052
1627
|
]::text[]
|
|
1053
1628
|
)
|
|
1054
1629
|
order by p.proname, pg_catalog.oidvectortypes(p.proargtypes)
|
|
1055
1630
|
`),
|
|
1056
|
-
)
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1631
|
+
)
|
|
1632
|
+
.map((row) => ({
|
|
1633
|
+
name: row.name,
|
|
1634
|
+
owner: row.owner,
|
|
1635
|
+
execute: row.can_execute,
|
|
1636
|
+
publicExecute: row.public_execute,
|
|
1637
|
+
securityDefiner: row.security_definer,
|
|
1638
|
+
}))
|
|
1639
|
+
.sort((left, right) => left.name.localeCompare(right.name));
|
|
1063
1640
|
|
|
1064
1641
|
const privateRoutines = resultRows<{
|
|
1065
1642
|
name: string;
|
|
1066
1643
|
owner: string;
|
|
1067
1644
|
can_execute: boolean;
|
|
1645
|
+
public_execute: boolean;
|
|
1068
1646
|
security_definer: boolean;
|
|
1069
1647
|
}>(
|
|
1070
1648
|
await tx.execute(sql`
|
|
@@ -1072,6 +1650,11 @@ export async function inspectRuntimeDatabasePosture(
|
|
|
1072
1650
|
(p.proname || '(' || pg_catalog.oidvectortypes(p.proargtypes) || ')')::text as name,
|
|
1073
1651
|
pg_get_userbyid(p.proowner)::text as owner,
|
|
1074
1652
|
has_function_privilege(current_user, p.oid, 'EXECUTE') as can_execute,
|
|
1653
|
+
exists (
|
|
1654
|
+
select 1
|
|
1655
|
+
from aclexplode(coalesce(p.proacl, acldefault('f', p.proowner))) acl
|
|
1656
|
+
where acl.grantee = 0 and acl.privilege_type = 'EXECUTE'
|
|
1657
|
+
) as public_execute,
|
|
1075
1658
|
p.prosecdef as security_definer
|
|
1076
1659
|
from pg_proc p
|
|
1077
1660
|
join pg_namespace n on n.oid = p.pronamespace
|
|
@@ -1083,6 +1666,7 @@ export async function inspectRuntimeDatabasePosture(
|
|
|
1083
1666
|
name: row.name,
|
|
1084
1667
|
owner: row.owner,
|
|
1085
1668
|
execute: row.can_execute,
|
|
1669
|
+
publicExecute: row.public_execute,
|
|
1086
1670
|
securityDefiner: row.security_definer,
|
|
1087
1671
|
}));
|
|
1088
1672
|
|
|
@@ -1093,8 +1677,10 @@ export async function inspectRuntimeDatabasePosture(
|
|
|
1093
1677
|
ownedSchemas,
|
|
1094
1678
|
ownedRelations,
|
|
1095
1679
|
tables,
|
|
1680
|
+
privateTables,
|
|
1096
1681
|
targetRoutines,
|
|
1097
1682
|
privateRoutines,
|
|
1683
|
+
sessionTenancyProductActivationPresent,
|
|
1098
1684
|
};
|
|
1099
1685
|
},
|
|
1100
1686
|
{ isolationLevel: "repeatable read", accessMode: "read only" },
|
|
@@ -1109,6 +1695,15 @@ export function evaluateRuntimeDatabasePosture(
|
|
|
1109
1695
|
const violations: string[] = [];
|
|
1110
1696
|
const identity = posture.identity;
|
|
1111
1697
|
|
|
1698
|
+
if (
|
|
1699
|
+
posture.sessionTenancyProductActivationPresent &&
|
|
1700
|
+
options.organizationTenancyCanonicalActivationEnabled !== true
|
|
1701
|
+
) {
|
|
1702
|
+
violations.push(
|
|
1703
|
+
"session-tenancy product activation is durable but OPENGENI_ORGANIZATION_TENANCY_CANONICAL_ACTIVATION_ENABLED is not true",
|
|
1704
|
+
);
|
|
1705
|
+
}
|
|
1706
|
+
|
|
1112
1707
|
if (!identity.currentUser || !identity.sessionUser) {
|
|
1113
1708
|
violations.push("database identity is empty");
|
|
1114
1709
|
}
|
|
@@ -1264,6 +1859,33 @@ export function evaluateRuntimeDatabasePosture(
|
|
|
1264
1859
|
}
|
|
1265
1860
|
|
|
1266
1861
|
const targetSchemaOwner = posture.schemas.find((schema) => schema.name === targetSchema)?.owner;
|
|
1862
|
+
for (const forbiddenRoutine of RUNTIME_TARGET_SCHEMA_FORBIDDEN_ROUTINES) {
|
|
1863
|
+
const matches = posture.targetRoutines.filter((routine) => routine.name === forbiddenRoutine);
|
|
1864
|
+
if (matches.length !== 1) {
|
|
1865
|
+
violations.push(
|
|
1866
|
+
`owner-internal target-schema helper ${forbiddenRoutine} is missing or ambiguous`,
|
|
1867
|
+
);
|
|
1868
|
+
continue;
|
|
1869
|
+
}
|
|
1870
|
+
const routine = matches[0]!;
|
|
1871
|
+
if (!routine.securityDefiner) {
|
|
1872
|
+
violations.push(
|
|
1873
|
+
`owner-internal target-schema helper ${routine.name} is not SECURITY DEFINER`,
|
|
1874
|
+
);
|
|
1875
|
+
}
|
|
1876
|
+
const authorityOwner = tableByName.get("sessions")?.owner ?? targetSchemaOwner;
|
|
1877
|
+
if (authorityOwner && routine.owner !== authorityOwner) {
|
|
1878
|
+
violations.push(
|
|
1879
|
+
`owner-internal target-schema helper ${routine.name} owner ${routine.owner} does not match session authority owner ${authorityOwner}`,
|
|
1880
|
+
);
|
|
1881
|
+
}
|
|
1882
|
+
if (routine.execute) {
|
|
1883
|
+
violations.push(`runtime role has forbidden owner-internal helper ${routine.name}`);
|
|
1884
|
+
}
|
|
1885
|
+
if (routine.publicExecute) {
|
|
1886
|
+
violations.push(`PUBLIC has forbidden owner-internal helper ${routine.name}`);
|
|
1887
|
+
}
|
|
1888
|
+
}
|
|
1267
1889
|
for (const expectedRoutine of RUNTIME_TARGET_SCHEMA_CAPABILITY_ROUTINES) {
|
|
1268
1890
|
const matches = posture.targetRoutines.filter((routine) => routine.name === expectedRoutine);
|
|
1269
1891
|
if (matches.length !== 1) {
|
|
@@ -1345,47 +1967,65 @@ export function evaluateRuntimeDatabasePosture(
|
|
|
1345
1967
|
`target-schema runtime capability ${routine.name} owner ${routine.owner} does not match authority table owner ${authorityTables[0].owner}`,
|
|
1346
1968
|
);
|
|
1347
1969
|
}
|
|
1348
|
-
} else if (
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
const
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
);
|
|
1357
|
-
} else if (authorityOwners.size !== 1) {
|
|
1970
|
+
} else if (routine.name === GOVERNED_LEARNING_EVALUATION_ROUTINE) {
|
|
1971
|
+
if (!tableByName.has("governed_learning_decision_receipts")) {
|
|
1972
|
+
continue;
|
|
1973
|
+
}
|
|
1974
|
+
const missingAuthorityTables = GOVERNED_LEARNING_EVALUATION_AUTHORITY_TABLES.filter(
|
|
1975
|
+
(tableName) => !tableByName.has(tableName),
|
|
1976
|
+
);
|
|
1977
|
+
if (missingAuthorityTables.length > 0) {
|
|
1358
1978
|
violations.push(
|
|
1359
|
-
`target-schema runtime capability ${routine.name} authority
|
|
1979
|
+
`target-schema runtime capability ${routine.name} authority tables are missing: ${missingAuthorityTables.join(", ")}`,
|
|
1360
1980
|
);
|
|
1361
|
-
} else
|
|
1362
|
-
|
|
1363
|
-
|
|
1981
|
+
} else {
|
|
1982
|
+
const authorityTables = GOVERNED_LEARNING_EVALUATION_AUTHORITY_TABLES.map(
|
|
1983
|
+
(tableName) => tableByName.get(tableName)!,
|
|
1364
1984
|
);
|
|
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} authority table owners do not match: ${authorityTables.map((table) => `${table.name}=${table.owner}`).join(", ")}`,
|
|
1989
|
+
);
|
|
1990
|
+
} else if (routine.owner !== authorityTables[0]!.owner) {
|
|
1991
|
+
violations.push(
|
|
1992
|
+
`target-schema runtime capability ${routine.name} owner ${routine.owner} does not match authority table owner ${authorityTables[0]!.owner}`,
|
|
1993
|
+
);
|
|
1994
|
+
}
|
|
1365
1995
|
}
|
|
1366
|
-
} else if (
|
|
1367
|
-
|
|
1368
|
-
|
|
1996
|
+
} else if (
|
|
1997
|
+
GOVERNED_LEARNING_INSPECTION_ROUTINES.includes(
|
|
1998
|
+
routine.name as (typeof GOVERNED_LEARNING_INSPECTION_ROUTINES)[number],
|
|
1999
|
+
)
|
|
2000
|
+
) {
|
|
2001
|
+
if (!tableByName.has("governed_learning_decision_receipts")) continue;
|
|
2002
|
+
const missingAuthorityTables = GOVERNED_LEARNING_INSPECTION_AUTHORITY_TABLES.filter(
|
|
2003
|
+
(name) => !tableByName.has(name),
|
|
2004
|
+
);
|
|
2005
|
+
if (missingAuthorityTables.length > 0) {
|
|
1369
2006
|
violations.push(
|
|
1370
|
-
`target-schema runtime capability ${routine.name}
|
|
2007
|
+
`target-schema runtime capability ${routine.name} authority tables are missing: ${missingAuthorityTables.join(", ")}`,
|
|
1371
2008
|
);
|
|
2009
|
+
} else {
|
|
2010
|
+
const authorityTables = GOVERNED_LEARNING_INSPECTION_AUTHORITY_TABLES.map(
|
|
2011
|
+
(name) => tableByName.get(name)!,
|
|
2012
|
+
);
|
|
2013
|
+
const authorityOwners = new Set(authorityTables.map((table) => table.owner));
|
|
2014
|
+
if (authorityOwners.size !== 1 || routine.owner !== authorityTables[0]!.owner) {
|
|
2015
|
+
violations.push(
|
|
2016
|
+
`target-schema runtime capability ${routine.name} owner does not match governed-learning inspection authority`,
|
|
2017
|
+
);
|
|
2018
|
+
}
|
|
1372
2019
|
}
|
|
1373
|
-
} else if (routine.name === XAI_SNAPSHOT_VALIDATOR_ROUTINE) {
|
|
1374
|
-
// The immutable SQL validator is invoker-rights and reads no table. Its
|
|
1375
|
-
// exact ACL is posture-checked above; it does not participate in the
|
|
1376
|
-
// SECURITY DEFINER same-owner authority graph.
|
|
1377
2020
|
} else if (
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
routine.name === XAI_POOL_VISIBLE_ROUTINE ||
|
|
1382
|
-
routine.name === XAI_RESOLVE_POOL_ROUTINE ||
|
|
1383
|
-
routine.name === XAI_REVALIDATE_CREDENTIAL_ROUTINE
|
|
2021
|
+
GOVERNED_LEARNING_ACTIVATION_ROUTINES.includes(
|
|
2022
|
+
routine.name as (typeof GOVERNED_LEARNING_ACTIVATION_ROUTINES)[number],
|
|
2023
|
+
)
|
|
1384
2024
|
) {
|
|
1385
|
-
if (!tableByName.has("
|
|
2025
|
+
if (!tableByName.has("governed_learning_activation_receipts")) {
|
|
1386
2026
|
continue;
|
|
1387
2027
|
}
|
|
1388
|
-
const missingAuthorityTables =
|
|
2028
|
+
const missingAuthorityTables = GOVERNED_LEARNING_ACTIVATION_AUTHORITY_TABLES.filter(
|
|
1389
2029
|
(tableName) => !tableByName.has(tableName),
|
|
1390
2030
|
);
|
|
1391
2031
|
if (missingAuthorityTables.length > 0) {
|
|
@@ -1393,7 +2033,7 @@ export function evaluateRuntimeDatabasePosture(
|
|
|
1393
2033
|
`target-schema runtime capability ${routine.name} authority tables are missing: ${missingAuthorityTables.join(", ")}`,
|
|
1394
2034
|
);
|
|
1395
2035
|
} else {
|
|
1396
|
-
const authorityTables =
|
|
2036
|
+
const authorityTables = GOVERNED_LEARNING_ACTIVATION_AUTHORITY_TABLES.map(
|
|
1397
2037
|
(tableName) => tableByName.get(tableName)!,
|
|
1398
2038
|
);
|
|
1399
2039
|
const authorityOwners = new Set(authorityTables.map((table) => table.owner));
|
|
@@ -1407,33 +2047,271 @@ export function evaluateRuntimeDatabasePosture(
|
|
|
1407
2047
|
);
|
|
1408
2048
|
}
|
|
1409
2049
|
}
|
|
1410
|
-
} else if (
|
|
1411
|
-
|
|
1412
|
-
|
|
2050
|
+
} else if (
|
|
2051
|
+
COMPANY_PROFILE_AGENT_ADMIN_ROUTINES.includes(
|
|
2052
|
+
routine.name as (typeof COMPANY_PROFILE_AGENT_ADMIN_ROUTINES)[number],
|
|
2053
|
+
)
|
|
2054
|
+
) {
|
|
2055
|
+
const missingAuthorityTables = COMPANY_PROFILE_AGENT_ADMIN_AUTHORITY_TABLES.filter(
|
|
2056
|
+
(tableName) => !tableByName.has(tableName),
|
|
1413
2057
|
);
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
2058
|
+
if (missingAuthorityTables.length > 0) {
|
|
2059
|
+
violations.push(
|
|
2060
|
+
`target-schema runtime capability ${routine.name} authority tables are missing: ${missingAuthorityTables.join(", ")}`,
|
|
2061
|
+
);
|
|
2062
|
+
} else {
|
|
2063
|
+
const authorityTables = COMPANY_PROFILE_AGENT_ADMIN_AUTHORITY_TABLES.map(
|
|
2064
|
+
(tableName) => tableByName.get(tableName)!,
|
|
2065
|
+
);
|
|
2066
|
+
const authorityOwners = new Set(authorityTables.map((table) => table.owner));
|
|
2067
|
+
if (authorityOwners.size !== 1) {
|
|
2068
|
+
violations.push(
|
|
2069
|
+
`target-schema runtime capability ${routine.name} authority table owners do not match: ${authorityTables.map((table) => `${table.name}=${table.owner}`).join(", ")}`,
|
|
2070
|
+
);
|
|
2071
|
+
} else if (routine.owner !== authorityTables[0]!.owner) {
|
|
2072
|
+
violations.push(
|
|
2073
|
+
`target-schema runtime capability ${routine.name} owner ${routine.owner} does not match authority table owner ${authorityTables[0]!.owner}`,
|
|
2074
|
+
);
|
|
2075
|
+
}
|
|
2076
|
+
}
|
|
2077
|
+
} else if (
|
|
2078
|
+
(ORGANIZATION_MEMBERSHIP_LIFECYCLE_ROUTINES as readonly string[]).includes(routine.name)
|
|
2079
|
+
) {
|
|
2080
|
+
const missingAuthorityTables = ORGANIZATION_MEMBERSHIP_LIFECYCLE_AUTHORITY_TABLES.filter(
|
|
2081
|
+
(tableName) => !tableByName.has(tableName),
|
|
2082
|
+
);
|
|
2083
|
+
if (missingAuthorityTables.length > 0) {
|
|
2084
|
+
violations.push(
|
|
2085
|
+
`target-schema runtime capability ${routine.name} authority tables are missing: ${missingAuthorityTables.join(", ")}`,
|
|
2086
|
+
);
|
|
2087
|
+
} else {
|
|
2088
|
+
const authorityTables = ORGANIZATION_MEMBERSHIP_LIFECYCLE_AUTHORITY_TABLES.map(
|
|
2089
|
+
(tableName) => tableByName.get(tableName)!,
|
|
2090
|
+
);
|
|
2091
|
+
const authorityOwners = new Set(authorityTables.map((table) => table.owner));
|
|
2092
|
+
if (authorityOwners.size !== 1) {
|
|
2093
|
+
violations.push(
|
|
2094
|
+
`target-schema runtime capability ${routine.name} authority table owners do not match: ${authorityTables.map((table) => `${table.name}=${table.owner}`).join(", ")}`,
|
|
2095
|
+
);
|
|
2096
|
+
} else if (routine.owner !== authorityTables[0]!.owner) {
|
|
2097
|
+
violations.push(
|
|
2098
|
+
`target-schema runtime capability ${routine.name} owner ${routine.owner} does not match authority table owner ${authorityTables[0]!.owner}`,
|
|
2099
|
+
);
|
|
2100
|
+
}
|
|
2101
|
+
}
|
|
2102
|
+
} else if (
|
|
2103
|
+
(ORGANIZATION_PRIVATE_SESSION_ROUTINES as readonly string[]).includes(routine.name)
|
|
2104
|
+
) {
|
|
2105
|
+
if (!tableByName.has("organization_private_session_settings")) {
|
|
2106
|
+
continue;
|
|
2107
|
+
}
|
|
2108
|
+
const authorityTableNames =
|
|
2109
|
+
ORGANIZATION_PRIVATE_SESSION_ROUTINE_AUTHORITY_TABLES[
|
|
2110
|
+
routine.name as keyof typeof ORGANIZATION_PRIVATE_SESSION_ROUTINE_AUTHORITY_TABLES
|
|
2111
|
+
];
|
|
2112
|
+
const missingAuthorityTables = authorityTableNames.filter(
|
|
2113
|
+
(tableName) => !tableByName.has(tableName),
|
|
2114
|
+
);
|
|
2115
|
+
if (missingAuthorityTables.length > 0) {
|
|
2116
|
+
violations.push(
|
|
2117
|
+
`target-schema runtime capability ${routine.name} authority tables are missing: ${missingAuthorityTables.join(", ")}`,
|
|
2118
|
+
);
|
|
2119
|
+
} else {
|
|
2120
|
+
const authorityTables = authorityTableNames.map((tableName) => tableByName.get(tableName)!);
|
|
2121
|
+
const authorityOwners = new Set(authorityTables.map((table) => table.owner));
|
|
2122
|
+
if (authorityOwners.size !== 1) {
|
|
2123
|
+
violations.push(
|
|
2124
|
+
`target-schema runtime capability ${routine.name} authority table owners do not match: ${authorityTables.map((table) => `${table.name}=${table.owner}`).join(", ")}`,
|
|
2125
|
+
);
|
|
2126
|
+
} else if (routine.owner !== authorityTables[0]!.owner) {
|
|
2127
|
+
violations.push(
|
|
2128
|
+
`target-schema runtime capability ${routine.name} owner ${routine.owner} does not match authority table owner ${authorityTables[0]!.owner}`,
|
|
2129
|
+
);
|
|
2130
|
+
}
|
|
2131
|
+
}
|
|
2132
|
+
} else if (routine.name === PREFERENCE_KNOWLEDGE_PROPOSAL_ROUTINE) {
|
|
2133
|
+
if (!tableByName.has("company_brain_preference_proposal_receipts")) {
|
|
2134
|
+
continue;
|
|
2135
|
+
}
|
|
2136
|
+
const missingAuthorityTables = PREFERENCE_KNOWLEDGE_PROPOSAL_AUTHORITY_TABLES.filter(
|
|
2137
|
+
(tableName) => !tableByName.has(tableName),
|
|
2138
|
+
);
|
|
2139
|
+
if (missingAuthorityTables.length > 0) {
|
|
2140
|
+
violations.push(
|
|
2141
|
+
`target-schema runtime capability ${routine.name} authority tables are missing: ${missingAuthorityTables.join(", ")}`,
|
|
2142
|
+
);
|
|
2143
|
+
} else {
|
|
2144
|
+
const authorityTables = PREFERENCE_KNOWLEDGE_PROPOSAL_AUTHORITY_TABLES.map(
|
|
2145
|
+
(tableName) => tableByName.get(tableName)!,
|
|
2146
|
+
);
|
|
2147
|
+
const authorityOwners = new Set(authorityTables.map((table) => table.owner));
|
|
2148
|
+
if (authorityOwners.size !== 1) {
|
|
2149
|
+
violations.push(
|
|
2150
|
+
`target-schema runtime capability ${routine.name} authority table owners do not match: ${authorityTables.map((table) => `${table.name}=${table.owner}`).join(", ")}`,
|
|
2151
|
+
);
|
|
2152
|
+
} else if (routine.owner !== authorityTables[0]!.owner) {
|
|
2153
|
+
violations.push(
|
|
2154
|
+
`target-schema runtime capability ${routine.name} owner ${routine.owner} does not match authority table owner ${authorityTables[0]!.owner}`,
|
|
2155
|
+
);
|
|
2156
|
+
}
|
|
2157
|
+
}
|
|
2158
|
+
} else if ((CANONICAL_HUMAN_IDENTITY_ROUTINES as readonly string[]).includes(routine.name)) {
|
|
2159
|
+
const authorityTables = CANONICAL_HUMAN_IDENTITY_AUTHORITY_TABLES.filter((tableName) =>
|
|
2160
|
+
tableByName.has(tableName),
|
|
2161
|
+
).map((tableName) => tableByName.get(tableName)!);
|
|
2162
|
+
const authorityOwners = new Set(authorityTables.map((table) => table.owner));
|
|
2163
|
+
if (authorityTables.length !== CANONICAL_HUMAN_IDENTITY_AUTHORITY_TABLES.length) {
|
|
2164
|
+
violations.push(
|
|
2165
|
+
`target-schema runtime capability ${routine.name} canonical identity authority tables are missing`,
|
|
2166
|
+
);
|
|
2167
|
+
} else if (authorityOwners.size !== 1) {
|
|
2168
|
+
violations.push(
|
|
2169
|
+
`target-schema runtime capability ${routine.name} authority table owners do not match: ${authorityTables.map((table) => `${table.name}=${table.owner}`).join(", ")}`,
|
|
2170
|
+
);
|
|
2171
|
+
} else if (routine.owner !== authorityTables[0]!.owner) {
|
|
2172
|
+
violations.push(
|
|
2173
|
+
`target-schema runtime capability ${routine.name} owner ${routine.owner} does not match authority table owner ${authorityTables[0]!.owner}`,
|
|
2174
|
+
);
|
|
2175
|
+
}
|
|
2176
|
+
} else if (
|
|
2177
|
+
(PERSONAL_GITHUB_REPOSITORY_AUTHORITY_ROUTINES as readonly string[]).includes(routine.name)
|
|
2178
|
+
) {
|
|
2179
|
+
const authorityTables = PERSONAL_GITHUB_REPOSITORY_AUTHORITY_TABLES.map((tableName) =>
|
|
2180
|
+
tableByName.get(tableName),
|
|
2181
|
+
).filter((table): table is RuntimeTablePosture => table !== undefined);
|
|
2182
|
+
const authorityOwners = new Set(authorityTables.map((table) => table.owner));
|
|
2183
|
+
if (authorityOwners.size > 1) {
|
|
2184
|
+
violations.push(
|
|
2185
|
+
`target-schema runtime capability ${routine.name} personal GitHub repository authority table owners do not match`,
|
|
2186
|
+
);
|
|
2187
|
+
} else {
|
|
2188
|
+
const authorityOwner = authorityTables[0]?.owner ?? targetSchemaOwner;
|
|
2189
|
+
if (authorityOwner && routine.owner !== authorityOwner) {
|
|
2190
|
+
violations.push(
|
|
2191
|
+
`target-schema runtime capability ${routine.name} owner ${routine.owner} does not match personal GitHub repository authority owner ${authorityOwner}`,
|
|
2192
|
+
);
|
|
2193
|
+
}
|
|
2194
|
+
}
|
|
2195
|
+
} else if (
|
|
2196
|
+
(PERSONAL_DOCUMENT_AUTHORITY_ROUTINES as readonly string[]).includes(routine.name) ||
|
|
2197
|
+
(DOCUMENT_MIGRATION_AUTHORITY_ROUTINES as readonly string[]).includes(routine.name)
|
|
2198
|
+
) {
|
|
2199
|
+
const authorityOwner = tableByName.get("documents")?.owner ?? targetSchemaOwner;
|
|
2200
|
+
if (authorityOwner && routine.owner !== authorityOwner) {
|
|
2201
|
+
violations.push(
|
|
2202
|
+
`target-schema runtime capability ${routine.name} owner ${routine.owner} does not match document authority owner ${authorityOwner}`,
|
|
2203
|
+
);
|
|
2204
|
+
}
|
|
2205
|
+
} else if ((VARIABLE_SET_AUTHORITY_ROUTINES as readonly string[]).includes(routine.name)) {
|
|
2206
|
+
const authorityTables = ["workspace_variable_sets", "workspace_variable_set_variables"]
|
|
2207
|
+
.map((tableName) => tableByName.get(tableName))
|
|
2208
|
+
.filter((table): table is RuntimeTablePosture => table !== undefined);
|
|
2209
|
+
const authorityOwners = new Set(authorityTables.map((table) => table.owner));
|
|
2210
|
+
if (authorityOwners.size > 1) {
|
|
2211
|
+
violations.push(
|
|
2212
|
+
`target-schema runtime capability ${routine.name} variable-set table owners do not match`,
|
|
2213
|
+
);
|
|
2214
|
+
} else {
|
|
2215
|
+
const authorityOwner = authorityTables[0]?.owner ?? targetSchemaOwner;
|
|
2216
|
+
if (authorityOwner && routine.owner !== authorityOwner) {
|
|
2217
|
+
violations.push(
|
|
2218
|
+
`target-schema runtime capability ${routine.name} owner ${routine.owner} does not match variable-set authority owner ${authorityOwner}`,
|
|
2219
|
+
);
|
|
2220
|
+
}
|
|
2221
|
+
}
|
|
2222
|
+
} else if ((SCOPED_COMPUTE_AUTHORITY_ROUTINES as readonly string[]).includes(routine.name)) {
|
|
2223
|
+
const authorityTables = ["rigs", "rig_versions", "enrollments", "sandboxes"]
|
|
2224
|
+
.map((tableName) => tableByName.get(tableName))
|
|
2225
|
+
.filter((table): table is RuntimeTablePosture => table !== undefined);
|
|
2226
|
+
const authorityOwners = new Set(authorityTables.map((table) => table.owner));
|
|
2227
|
+
if (authorityOwners.size > 1) {
|
|
2228
|
+
violations.push(
|
|
2229
|
+
`target-schema runtime capability ${routine.name} scoped-compute table owners do not match`,
|
|
2230
|
+
);
|
|
2231
|
+
} else {
|
|
2232
|
+
const authorityOwner = authorityTables[0]?.owner ?? targetSchemaOwner;
|
|
2233
|
+
if (authorityOwner && routine.owner !== authorityOwner) {
|
|
2234
|
+
violations.push(
|
|
2235
|
+
`target-schema runtime capability ${routine.name} owner ${routine.owner} does not match scoped-compute authority owner ${authorityOwner}`,
|
|
2236
|
+
);
|
|
2237
|
+
}
|
|
2238
|
+
}
|
|
2239
|
+
} else if (SESSION_AUTHORITY_ROUTINES.has(routine.name)) {
|
|
2240
|
+
const authorityOwner = tableByName.get("sessions")?.owner ?? targetSchemaOwner;
|
|
2241
|
+
if (authorityOwner && routine.owner !== authorityOwner) {
|
|
2242
|
+
violations.push(
|
|
2243
|
+
`target-schema runtime capability ${routine.name} owner ${routine.owner} does not match session authority owner ${authorityOwner}`,
|
|
2244
|
+
);
|
|
2245
|
+
}
|
|
2246
|
+
} else if (routine.name === XAI_SNAPSHOT_VALIDATOR_ROUTINE) {
|
|
2247
|
+
// The immutable SQL validator is invoker-rights and reads no table. Its
|
|
2248
|
+
// exact ACL is posture-checked above; it does not participate in the
|
|
2249
|
+
// SECURITY DEFINER same-owner authority graph.
|
|
2250
|
+
} else if (
|
|
2251
|
+
routine.name === XAI_CREATE_CREDENTIAL_ROUTINE ||
|
|
2252
|
+
routine.name === XAI_DISCONNECT_CREDENTIAL_ROUTINE ||
|
|
2253
|
+
routine.name === XAI_AUTHORITY_LIVE_ROUTINE ||
|
|
2254
|
+
routine.name === XAI_POOL_VISIBLE_ROUTINE ||
|
|
2255
|
+
routine.name === XAI_RESOLVE_POOL_ROUTINE ||
|
|
2256
|
+
routine.name === XAI_REVALIDATE_CREDENTIAL_ROUTINE
|
|
2257
|
+
) {
|
|
2258
|
+
if (!tableByName.has("xai_subscription_credentials")) {
|
|
2259
|
+
continue;
|
|
2260
|
+
}
|
|
2261
|
+
const missingAuthorityTables = XAI_AUTHORITY_TABLES.filter(
|
|
2262
|
+
(tableName) => !tableByName.has(tableName),
|
|
2263
|
+
);
|
|
2264
|
+
if (missingAuthorityTables.length > 0) {
|
|
2265
|
+
violations.push(
|
|
2266
|
+
`target-schema runtime capability ${routine.name} authority tables are missing: ${missingAuthorityTables.join(", ")}`,
|
|
2267
|
+
);
|
|
2268
|
+
} else {
|
|
2269
|
+
const authorityTables = XAI_AUTHORITY_TABLES.map(
|
|
2270
|
+
(tableName) => tableByName.get(tableName)!,
|
|
2271
|
+
);
|
|
2272
|
+
const authorityOwners = new Set(authorityTables.map((table) => table.owner));
|
|
2273
|
+
if (authorityOwners.size !== 1) {
|
|
2274
|
+
violations.push(
|
|
2275
|
+
`target-schema runtime capability ${routine.name} authority table owners do not match: ${authorityTables.map((table) => `${table.name}=${table.owner}`).join(", ")}`,
|
|
2276
|
+
);
|
|
2277
|
+
} else if (routine.owner !== authorityTables[0]!.owner) {
|
|
2278
|
+
violations.push(
|
|
2279
|
+
`target-schema runtime capability ${routine.name} owner ${routine.owner} does not match authority table owner ${authorityTables[0]!.owner}`,
|
|
2280
|
+
);
|
|
2281
|
+
}
|
|
2282
|
+
}
|
|
2283
|
+
} else if (targetSchemaOwner && routine.owner !== targetSchemaOwner) {
|
|
2284
|
+
violations.push(
|
|
2285
|
+
`target-schema runtime capability ${routine.name} owner ${routine.owner} does not match schema owner ${targetSchemaOwner}`,
|
|
2286
|
+
);
|
|
2287
|
+
}
|
|
2288
|
+
if (!routine.execute) {
|
|
2289
|
+
violations.push(`runtime role lacks target-schema capability ${routine.name}`);
|
|
2290
|
+
}
|
|
2291
|
+
const publicPolicyPredicate = RUNTIME_TARGET_SCHEMA_PUBLIC_POLICY_PREDICATE_ROUTINE_SET.has(
|
|
2292
|
+
routine.name,
|
|
2293
|
+
);
|
|
2294
|
+
if (publicPolicyPredicate && !routine.publicExecute) {
|
|
2295
|
+
violations.push(`PUBLIC lacks required shared-policy predicate ${routine.name}`);
|
|
2296
|
+
} else if (!publicPolicyPredicate && routine.publicExecute) {
|
|
2297
|
+
violations.push(`PUBLIC has forbidden target-schema capability ${routine.name}`);
|
|
2298
|
+
}
|
|
2299
|
+
}
|
|
2300
|
+
|
|
2301
|
+
const artifactOutbox = tableByName.get("editable_artifact_live_outbox");
|
|
2302
|
+
if (artifactOutbox) {
|
|
2303
|
+
if (!artifactOutbox.artifactOutboxDispatcherPolicy) {
|
|
2304
|
+
violations.push("table editable_artifact_live_outbox lacks its owner dispatcher RLS policy");
|
|
2305
|
+
}
|
|
2306
|
+
for (const expectedRoutine of ARTIFACT_OUTBOX_CAPABILITY_ROUTINES) {
|
|
2307
|
+
const matches = posture.privateRoutines.filter((routine) => routine.name === expectedRoutine);
|
|
2308
|
+
if (matches.length !== 1) {
|
|
2309
|
+
violations.push(`artifact outbox capability ${expectedRoutine} is missing or ambiguous`);
|
|
2310
|
+
continue;
|
|
2311
|
+
}
|
|
2312
|
+
const routine = matches[0]!;
|
|
2313
|
+
if (!routine.securityDefiner) {
|
|
2314
|
+
violations.push(`artifact outbox capability ${routine.name} is not SECURITY DEFINER`);
|
|
1437
2315
|
}
|
|
1438
2316
|
if (routine.owner !== artifactOutbox.owner) {
|
|
1439
2317
|
violations.push(
|
|
@@ -1586,9 +2464,376 @@ export function evaluateRuntimeDatabasePosture(
|
|
|
1586
2464
|
}
|
|
1587
2465
|
}
|
|
1588
2466
|
|
|
2467
|
+
const personalResourceCapabilityTables = posture.privateTables.filter(
|
|
2468
|
+
(table) => table.name === PERSONAL_RESOURCE_CAPABILITY_TABLE,
|
|
2469
|
+
);
|
|
2470
|
+
const personalResourceCapabilityRoutines = posture.privateRoutines.filter(
|
|
2471
|
+
(routine) => routine.name === PERSONAL_RESOURCE_CAPABILITY_PREDICATE_ROUTINE,
|
|
2472
|
+
);
|
|
2473
|
+
if (personalResourceCapabilityTables.length !== 1) {
|
|
2474
|
+
violations.push(
|
|
2475
|
+
`personal-resource capability table ${PERSONAL_RESOURCE_CAPABILITY_TABLE} is missing or ambiguous`,
|
|
2476
|
+
);
|
|
2477
|
+
}
|
|
2478
|
+
if (personalResourceCapabilityRoutines.length !== 1) {
|
|
2479
|
+
violations.push(
|
|
2480
|
+
`personal-resource capability predicate ${PERSONAL_RESOURCE_CAPABILITY_PREDICATE_ROUTINE} is missing or ambiguous`,
|
|
2481
|
+
);
|
|
2482
|
+
}
|
|
2483
|
+
if (
|
|
2484
|
+
personalResourceCapabilityTables.length === 1 &&
|
|
2485
|
+
personalResourceCapabilityRoutines.length === 1
|
|
2486
|
+
) {
|
|
2487
|
+
const table = personalResourceCapabilityTables[0]!;
|
|
2488
|
+
const routine = personalResourceCapabilityRoutines[0]!;
|
|
2489
|
+
if (routine.owner !== table.owner) {
|
|
2490
|
+
violations.push(
|
|
2491
|
+
`personal-resource capability predicate ${routine.name} owner ${routine.owner} does not match table owner ${table.owner}`,
|
|
2492
|
+
);
|
|
2493
|
+
}
|
|
2494
|
+
if (!routine.securityDefiner) {
|
|
2495
|
+
violations.push(
|
|
2496
|
+
`personal-resource capability predicate ${routine.name} is not SECURITY DEFINER`,
|
|
2497
|
+
);
|
|
2498
|
+
}
|
|
2499
|
+
if (!routine.execute) {
|
|
2500
|
+
violations.push(`runtime role lacks personal-resource capability predicate ${routine.name}`);
|
|
2501
|
+
}
|
|
2502
|
+
if (routine.publicExecute) {
|
|
2503
|
+
violations.push(
|
|
2504
|
+
`PUBLIC has forbidden personal-resource capability predicate ${routine.name}`,
|
|
2505
|
+
);
|
|
2506
|
+
}
|
|
2507
|
+
const directPrivileges = [
|
|
2508
|
+
["SELECT", table.select],
|
|
2509
|
+
["INSERT", table.insert],
|
|
2510
|
+
["UPDATE", table.update],
|
|
2511
|
+
["DELETE", table.delete],
|
|
2512
|
+
].filter(([, granted]) => granted);
|
|
2513
|
+
if (directPrivileges.length > 0) {
|
|
2514
|
+
violations.push(
|
|
2515
|
+
`runtime role has forbidden direct privileges on private table ${table.name}: ${directPrivileges.map(([privilege]) => privilege).join(", ")}`,
|
|
2516
|
+
);
|
|
2517
|
+
}
|
|
2518
|
+
}
|
|
2519
|
+
|
|
2520
|
+
const personalDocumentCapabilityTables = posture.privateTables.filter(
|
|
2521
|
+
(table) => table.name === PERSONAL_DOCUMENT_CAPABILITY_TABLE,
|
|
2522
|
+
);
|
|
2523
|
+
const personalDocumentCapabilityRoutines = posture.privateRoutines.filter(
|
|
2524
|
+
(routine) => routine.name === PERSONAL_DOCUMENT_CAPABILITY_PREDICATE_ROUTINE,
|
|
2525
|
+
);
|
|
2526
|
+
if (personalDocumentCapabilityTables.length !== 1) {
|
|
2527
|
+
violations.push(
|
|
2528
|
+
`personal-document capability table ${PERSONAL_DOCUMENT_CAPABILITY_TABLE} is missing or ambiguous`,
|
|
2529
|
+
);
|
|
2530
|
+
}
|
|
2531
|
+
if (personalDocumentCapabilityRoutines.length !== 1) {
|
|
2532
|
+
violations.push(
|
|
2533
|
+
`personal-document capability predicate ${PERSONAL_DOCUMENT_CAPABILITY_PREDICATE_ROUTINE} is missing or ambiguous`,
|
|
2534
|
+
);
|
|
2535
|
+
}
|
|
2536
|
+
if (
|
|
2537
|
+
personalDocumentCapabilityTables.length === 1 &&
|
|
2538
|
+
personalDocumentCapabilityRoutines.length === 1
|
|
2539
|
+
) {
|
|
2540
|
+
const table = personalDocumentCapabilityTables[0]!;
|
|
2541
|
+
const routine = personalDocumentCapabilityRoutines[0]!;
|
|
2542
|
+
if (routine.owner !== table.owner) {
|
|
2543
|
+
violations.push(
|
|
2544
|
+
`personal-document capability predicate ${routine.name} owner ${routine.owner} does not match table owner ${table.owner}`,
|
|
2545
|
+
);
|
|
2546
|
+
}
|
|
2547
|
+
if (!routine.securityDefiner) {
|
|
2548
|
+
violations.push(
|
|
2549
|
+
`personal-document capability predicate ${routine.name} is not SECURITY DEFINER`,
|
|
2550
|
+
);
|
|
2551
|
+
}
|
|
2552
|
+
if (!routine.execute) {
|
|
2553
|
+
violations.push(`runtime role lacks personal-document capability predicate ${routine.name}`);
|
|
2554
|
+
}
|
|
2555
|
+
if (routine.publicExecute) {
|
|
2556
|
+
violations.push(
|
|
2557
|
+
`PUBLIC has forbidden personal-document capability predicate ${routine.name}`,
|
|
2558
|
+
);
|
|
2559
|
+
}
|
|
2560
|
+
const directPrivileges = [
|
|
2561
|
+
["SELECT", table.select],
|
|
2562
|
+
["INSERT", table.insert],
|
|
2563
|
+
["UPDATE", table.update],
|
|
2564
|
+
["DELETE", table.delete],
|
|
2565
|
+
].filter(([, granted]) => granted);
|
|
2566
|
+
if (directPrivileges.length > 0) {
|
|
2567
|
+
violations.push(
|
|
2568
|
+
`runtime role has forbidden direct privileges on private table ${table.name}: ${directPrivileges.map(([privilege]) => privilege).join(", ")}`,
|
|
2569
|
+
);
|
|
2570
|
+
}
|
|
2571
|
+
}
|
|
2572
|
+
|
|
2573
|
+
const documentMigrationCapabilityTables = posture.privateTables.filter(
|
|
2574
|
+
(table) => table.name === DOCUMENT_MIGRATION_CAPABILITY_TABLE,
|
|
2575
|
+
);
|
|
2576
|
+
const documentMigrationCapabilityRoutines = posture.privateRoutines.filter(
|
|
2577
|
+
(routine) => routine.name === DOCUMENT_MIGRATION_CAPABILITY_PREDICATE_ROUTINE,
|
|
2578
|
+
);
|
|
2579
|
+
if (documentMigrationCapabilityTables.length !== 1) {
|
|
2580
|
+
violations.push(
|
|
2581
|
+
`document-migration capability table ${DOCUMENT_MIGRATION_CAPABILITY_TABLE} is missing or ambiguous`,
|
|
2582
|
+
);
|
|
2583
|
+
}
|
|
2584
|
+
if (documentMigrationCapabilityRoutines.length !== 1) {
|
|
2585
|
+
violations.push(
|
|
2586
|
+
`document-migration capability predicate ${DOCUMENT_MIGRATION_CAPABILITY_PREDICATE_ROUTINE} is missing or ambiguous`,
|
|
2587
|
+
);
|
|
2588
|
+
}
|
|
2589
|
+
if (
|
|
2590
|
+
documentMigrationCapabilityTables.length === 1 &&
|
|
2591
|
+
documentMigrationCapabilityRoutines.length === 1
|
|
2592
|
+
) {
|
|
2593
|
+
const table = documentMigrationCapabilityTables[0]!;
|
|
2594
|
+
const routine = documentMigrationCapabilityRoutines[0]!;
|
|
2595
|
+
if (routine.owner !== table.owner) {
|
|
2596
|
+
violations.push(
|
|
2597
|
+
`document-migration capability predicate ${routine.name} owner ${routine.owner} does not match table owner ${table.owner}`,
|
|
2598
|
+
);
|
|
2599
|
+
}
|
|
2600
|
+
if (!routine.securityDefiner) {
|
|
2601
|
+
violations.push(
|
|
2602
|
+
`document-migration capability predicate ${routine.name} is not SECURITY DEFINER`,
|
|
2603
|
+
);
|
|
2604
|
+
}
|
|
2605
|
+
if (!routine.execute) {
|
|
2606
|
+
violations.push(`runtime role lacks document-migration capability predicate ${routine.name}`);
|
|
2607
|
+
}
|
|
2608
|
+
if (routine.publicExecute) {
|
|
2609
|
+
violations.push(
|
|
2610
|
+
`PUBLIC has forbidden document-migration capability predicate ${routine.name}`,
|
|
2611
|
+
);
|
|
2612
|
+
}
|
|
2613
|
+
const directPrivileges = [
|
|
2614
|
+
["SELECT", table.select],
|
|
2615
|
+
["INSERT", table.insert],
|
|
2616
|
+
["UPDATE", table.update],
|
|
2617
|
+
["DELETE", table.delete],
|
|
2618
|
+
].filter(([, granted]) => granted);
|
|
2619
|
+
if (directPrivileges.length > 0) {
|
|
2620
|
+
violations.push(
|
|
2621
|
+
`runtime role has forbidden direct privileges on private table ${table.name}: ${directPrivileges.map(([privilege]) => privilege).join(", ")}`,
|
|
2622
|
+
);
|
|
2623
|
+
}
|
|
2624
|
+
}
|
|
2625
|
+
|
|
2626
|
+
const scheduledCapabilityTables = posture.privateTables.filter(
|
|
2627
|
+
(table) => table.name === SCHEDULED_PERSONAL_RESOURCE_CAPABILITY_TABLE,
|
|
2628
|
+
);
|
|
2629
|
+
const scheduledCapabilityRoutines = posture.privateRoutines.filter(
|
|
2630
|
+
(routine) => routine.name === SCHEDULED_PERSONAL_RESOURCE_CAPABILITY_PREDICATE_ROUTINE,
|
|
2631
|
+
);
|
|
2632
|
+
if (scheduledCapabilityTables.length !== 1) {
|
|
2633
|
+
violations.push(
|
|
2634
|
+
`scheduled personal-resource capability table ${SCHEDULED_PERSONAL_RESOURCE_CAPABILITY_TABLE} is missing or ambiguous`,
|
|
2635
|
+
);
|
|
2636
|
+
}
|
|
2637
|
+
if (scheduledCapabilityRoutines.length !== 1) {
|
|
2638
|
+
violations.push(
|
|
2639
|
+
`scheduled personal-resource capability predicate ${SCHEDULED_PERSONAL_RESOURCE_CAPABILITY_PREDICATE_ROUTINE} is missing or ambiguous`,
|
|
2640
|
+
);
|
|
2641
|
+
}
|
|
2642
|
+
if (scheduledCapabilityTables.length === 1 && scheduledCapabilityRoutines.length === 1) {
|
|
2643
|
+
const table = scheduledCapabilityTables[0]!;
|
|
2644
|
+
const routine = scheduledCapabilityRoutines[0]!;
|
|
2645
|
+
if (routine.owner !== table.owner) {
|
|
2646
|
+
violations.push(
|
|
2647
|
+
`scheduled personal-resource capability predicate ${routine.name} owner ${routine.owner} does not match table owner ${table.owner}`,
|
|
2648
|
+
);
|
|
2649
|
+
}
|
|
2650
|
+
if (!routine.securityDefiner) {
|
|
2651
|
+
violations.push(
|
|
2652
|
+
`scheduled personal-resource capability predicate ${routine.name} is not SECURITY DEFINER`,
|
|
2653
|
+
);
|
|
2654
|
+
}
|
|
2655
|
+
if (!routine.execute) {
|
|
2656
|
+
violations.push(
|
|
2657
|
+
`runtime role lacks scheduled personal-resource capability predicate ${routine.name}`,
|
|
2658
|
+
);
|
|
2659
|
+
}
|
|
2660
|
+
if (routine.publicExecute) {
|
|
2661
|
+
violations.push(
|
|
2662
|
+
`PUBLIC has forbidden scheduled personal-resource capability predicate ${routine.name}`,
|
|
2663
|
+
);
|
|
2664
|
+
}
|
|
2665
|
+
const directPrivileges = [
|
|
2666
|
+
["SELECT", table.select],
|
|
2667
|
+
["INSERT", table.insert],
|
|
2668
|
+
["UPDATE", table.update],
|
|
2669
|
+
["DELETE", table.delete],
|
|
2670
|
+
].filter(([, granted]) => granted);
|
|
2671
|
+
if (directPrivileges.length > 0) {
|
|
2672
|
+
violations.push(
|
|
2673
|
+
`runtime role has forbidden direct privileges on private table ${table.name}: ${directPrivileges.map(([privilege]) => privilege).join(", ")}`,
|
|
2674
|
+
);
|
|
2675
|
+
}
|
|
2676
|
+
}
|
|
2677
|
+
|
|
2678
|
+
if (options.protectedTables === undefined) {
|
|
2679
|
+
const variableSetCapabilityTables = posture.privateTables.filter(
|
|
2680
|
+
(table) => table.name === VARIABLE_SET_CAPABILITY_TABLE,
|
|
2681
|
+
);
|
|
2682
|
+
const variableSetCapabilityRoutines = posture.privateRoutines.filter(
|
|
2683
|
+
(routine) => routine.name === VARIABLE_SET_CAPABILITY_PREDICATE_ROUTINE,
|
|
2684
|
+
);
|
|
2685
|
+
if (variableSetCapabilityTables.length !== 1) {
|
|
2686
|
+
violations.push(
|
|
2687
|
+
`variable-set capability table ${VARIABLE_SET_CAPABILITY_TABLE} is missing or ambiguous`,
|
|
2688
|
+
);
|
|
2689
|
+
}
|
|
2690
|
+
if (variableSetCapabilityRoutines.length !== 1) {
|
|
2691
|
+
violations.push(
|
|
2692
|
+
`variable-set capability predicate ${VARIABLE_SET_CAPABILITY_PREDICATE_ROUTINE} is missing or ambiguous`,
|
|
2693
|
+
);
|
|
2694
|
+
}
|
|
2695
|
+
if (variableSetCapabilityTables.length === 1 && variableSetCapabilityRoutines.length === 1) {
|
|
2696
|
+
const table = variableSetCapabilityTables[0]!;
|
|
2697
|
+
const routine = variableSetCapabilityRoutines[0]!;
|
|
2698
|
+
if (routine.owner !== table.owner) {
|
|
2699
|
+
violations.push(
|
|
2700
|
+
`variable-set capability predicate ${routine.name} owner ${routine.owner} does not match table owner ${table.owner}`,
|
|
2701
|
+
);
|
|
2702
|
+
}
|
|
2703
|
+
if (!routine.securityDefiner) {
|
|
2704
|
+
violations.push(
|
|
2705
|
+
`variable-set capability predicate ${routine.name} is not SECURITY DEFINER`,
|
|
2706
|
+
);
|
|
2707
|
+
}
|
|
2708
|
+
if (!routine.execute) {
|
|
2709
|
+
violations.push(`runtime role lacks variable-set capability predicate ${routine.name}`);
|
|
2710
|
+
}
|
|
2711
|
+
if (routine.publicExecute) {
|
|
2712
|
+
violations.push(`PUBLIC has forbidden variable-set capability predicate ${routine.name}`);
|
|
2713
|
+
}
|
|
2714
|
+
const directPrivileges = [
|
|
2715
|
+
["SELECT", table.select],
|
|
2716
|
+
["INSERT", table.insert],
|
|
2717
|
+
["UPDATE", table.update],
|
|
2718
|
+
["DELETE", table.delete],
|
|
2719
|
+
].filter(([, granted]) => granted);
|
|
2720
|
+
if (directPrivileges.length > 0) {
|
|
2721
|
+
violations.push(
|
|
2722
|
+
`runtime role has forbidden direct privileges on private table ${table.name}: ${directPrivileges.map(([privilege]) => privilege).join(", ")}`,
|
|
2723
|
+
);
|
|
2724
|
+
}
|
|
2725
|
+
}
|
|
2726
|
+
const scopedComputeCapabilityTables = posture.privateTables.filter(
|
|
2727
|
+
(table) => table.name === SCOPED_COMPUTE_CAPABILITY_TABLE,
|
|
2728
|
+
);
|
|
2729
|
+
const scopedComputeCapabilityRoutines = posture.privateRoutines.filter(
|
|
2730
|
+
(routine) => routine.name === SCOPED_COMPUTE_CAPABILITY_PREDICATE_ROUTINE,
|
|
2731
|
+
);
|
|
2732
|
+
if (scopedComputeCapabilityTables.length !== 1) {
|
|
2733
|
+
violations.push(
|
|
2734
|
+
`scoped-compute capability table ${SCOPED_COMPUTE_CAPABILITY_TABLE} is missing or ambiguous`,
|
|
2735
|
+
);
|
|
2736
|
+
}
|
|
2737
|
+
if (scopedComputeCapabilityRoutines.length !== 1) {
|
|
2738
|
+
violations.push(
|
|
2739
|
+
`scoped-compute capability predicate ${SCOPED_COMPUTE_CAPABILITY_PREDICATE_ROUTINE} is missing or ambiguous`,
|
|
2740
|
+
);
|
|
2741
|
+
}
|
|
2742
|
+
if (
|
|
2743
|
+
scopedComputeCapabilityTables.length === 1 &&
|
|
2744
|
+
scopedComputeCapabilityRoutines.length === 1
|
|
2745
|
+
) {
|
|
2746
|
+
const table = scopedComputeCapabilityTables[0]!;
|
|
2747
|
+
const routine = scopedComputeCapabilityRoutines[0]!;
|
|
2748
|
+
if (routine.owner !== table.owner) {
|
|
2749
|
+
violations.push(
|
|
2750
|
+
`scoped-compute capability predicate ${routine.name} owner ${routine.owner} does not match table owner ${table.owner}`,
|
|
2751
|
+
);
|
|
2752
|
+
}
|
|
2753
|
+
if (!routine.securityDefiner) {
|
|
2754
|
+
violations.push(
|
|
2755
|
+
`scoped-compute capability predicate ${routine.name} is not SECURITY DEFINER`,
|
|
2756
|
+
);
|
|
2757
|
+
}
|
|
2758
|
+
if (!routine.execute) {
|
|
2759
|
+
violations.push(`runtime role lacks scoped-compute capability predicate ${routine.name}`);
|
|
2760
|
+
}
|
|
2761
|
+
if (routine.publicExecute) {
|
|
2762
|
+
violations.push(`PUBLIC has forbidden scoped-compute capability predicate ${routine.name}`);
|
|
2763
|
+
}
|
|
2764
|
+
const directPrivileges = [
|
|
2765
|
+
["SELECT", table.select],
|
|
2766
|
+
["INSERT", table.insert],
|
|
2767
|
+
["UPDATE", table.update],
|
|
2768
|
+
["DELETE", table.delete],
|
|
2769
|
+
].filter(([, granted]) => granted);
|
|
2770
|
+
if (directPrivileges.length > 0) {
|
|
2771
|
+
violations.push(
|
|
2772
|
+
`runtime role has forbidden direct privileges on private table ${table.name}: ${directPrivileges.map(([privilege]) => privilege).join(", ")}`,
|
|
2773
|
+
);
|
|
2774
|
+
}
|
|
2775
|
+
}
|
|
2776
|
+
}
|
|
2777
|
+
|
|
1589
2778
|
if (posture.privateRoutines.length === 0) {
|
|
1590
2779
|
violations.push("opengeni_private has no helper routines");
|
|
1591
2780
|
}
|
|
2781
|
+
|
|
2782
|
+
const connectionBackfillCapabilityTables = posture.privateTables.filter(
|
|
2783
|
+
(table) => table.name === CONNECTION_TENANCY_BACKFILL_CAPABILITY_TABLE,
|
|
2784
|
+
);
|
|
2785
|
+
const connectionBackfillCapabilityRoutines = posture.privateRoutines.filter(
|
|
2786
|
+
(routine) => routine.name === CONNECTION_TENANCY_BACKFILL_CAPABILITY_PREDICATE_ROUTINE,
|
|
2787
|
+
);
|
|
2788
|
+
if (connectionBackfillCapabilityTables.length !== 1) {
|
|
2789
|
+
violations.push(
|
|
2790
|
+
`connection-tenancy backfill capability table ${CONNECTION_TENANCY_BACKFILL_CAPABILITY_TABLE} is missing or ambiguous`,
|
|
2791
|
+
);
|
|
2792
|
+
}
|
|
2793
|
+
if (connectionBackfillCapabilityRoutines.length !== 1) {
|
|
2794
|
+
violations.push(
|
|
2795
|
+
`connection-tenancy backfill capability predicate ${CONNECTION_TENANCY_BACKFILL_CAPABILITY_PREDICATE_ROUTINE} is missing or ambiguous`,
|
|
2796
|
+
);
|
|
2797
|
+
}
|
|
2798
|
+
if (
|
|
2799
|
+
connectionBackfillCapabilityTables.length === 1 &&
|
|
2800
|
+
connectionBackfillCapabilityRoutines.length === 1
|
|
2801
|
+
) {
|
|
2802
|
+
const table = connectionBackfillCapabilityTables[0]!;
|
|
2803
|
+
const routine = connectionBackfillCapabilityRoutines[0]!;
|
|
2804
|
+
if (routine.owner !== table.owner) {
|
|
2805
|
+
violations.push(
|
|
2806
|
+
`connection-tenancy backfill capability predicate ${routine.name} owner ${routine.owner} does not match table owner ${table.owner}`,
|
|
2807
|
+
);
|
|
2808
|
+
}
|
|
2809
|
+
if (!routine.securityDefiner) {
|
|
2810
|
+
violations.push(
|
|
2811
|
+
`connection-tenancy backfill capability predicate ${routine.name} is not SECURITY DEFINER`,
|
|
2812
|
+
);
|
|
2813
|
+
}
|
|
2814
|
+
if (!routine.execute) {
|
|
2815
|
+
violations.push(
|
|
2816
|
+
`runtime role lacks connection-tenancy backfill capability predicate ${routine.name}`,
|
|
2817
|
+
);
|
|
2818
|
+
}
|
|
2819
|
+
if (routine.publicExecute) {
|
|
2820
|
+
violations.push(
|
|
2821
|
+
`PUBLIC has forbidden connection-tenancy backfill capability predicate ${routine.name}`,
|
|
2822
|
+
);
|
|
2823
|
+
}
|
|
2824
|
+
const directPrivileges = [
|
|
2825
|
+
["SELECT", table.select],
|
|
2826
|
+
["INSERT", table.insert],
|
|
2827
|
+
["UPDATE", table.update],
|
|
2828
|
+
["DELETE", table.delete],
|
|
2829
|
+
].filter(([, granted]) => granted);
|
|
2830
|
+
if (directPrivileges.length > 0) {
|
|
2831
|
+
violations.push(
|
|
2832
|
+
`runtime role has forbidden direct privileges on private table ${table.name}: ${directPrivileges.map(([privilege]) => privilege).join(", ")}`,
|
|
2833
|
+
);
|
|
2834
|
+
}
|
|
2835
|
+
}
|
|
2836
|
+
|
|
1592
2837
|
for (const routine of posture.privateRoutines) {
|
|
1593
2838
|
if (routine.owner === expectedRole) {
|
|
1594
2839
|
violations.push(`runtime role owns private routine ${routine.name}`);
|