@opengeni/db 0.28.9 → 0.36.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (225) hide show
  1. package/dist/attached-browser-devices.d.ts +42 -0
  2. package/dist/attempt-tool-catalogs.d.ts +16 -0
  3. package/dist/browser-auth.d.ts +299 -0
  4. package/dist/browser-downloads.d.ts +51 -0
  5. package/dist/browser-identities.d.ts +137 -0
  6. package/dist/browser-sessions.d.ts +354 -0
  7. package/dist/browser-state-artifacts.d.ts +91 -0
  8. package/dist/canonical-human-identities.d.ts +48 -0
  9. package/dist/canonical-human-identities.js +28 -0
  10. package/dist/canonical-human-identities.js.map +1 -0
  11. package/dist/capability-components.d.ts +37 -0
  12. package/dist/capability-integrations.d.ts +194 -0
  13. package/dist/chunk-5KTIEDX7.js +13200 -0
  14. package/dist/chunk-5KTIEDX7.js.map +1 -0
  15. package/dist/chunk-CQZ4QSP5.js +995 -0
  16. package/dist/chunk-CQZ4QSP5.js.map +1 -0
  17. package/dist/chunk-F32YT7MP.js +117 -0
  18. package/dist/chunk-F32YT7MP.js.map +1 -0
  19. package/dist/chunk-JC5QPLUM.js +666 -0
  20. package/dist/chunk-JC5QPLUM.js.map +1 -0
  21. package/dist/chunk-P3RE4D2B.js +3535 -0
  22. package/dist/chunk-P3RE4D2B.js.map +1 -0
  23. package/dist/chunk-TAUTWOS5.js +259 -0
  24. package/dist/chunk-TAUTWOS5.js.map +1 -0
  25. package/dist/chunk-VKLB2ZGI.js +2389 -0
  26. package/dist/chunk-VKLB2ZGI.js.map +1 -0
  27. package/dist/codemode-operations.d.ts +117 -0
  28. package/dist/codex-token-resolver.d.ts +2 -2
  29. package/dist/company-profile-schema.d.ts +798 -0
  30. package/dist/company-profile.d.ts +268 -0
  31. package/dist/computer-sessions.d.ts +109 -0
  32. package/dist/connection-token-resolver.d.ts +9 -4
  33. package/dist/database.d.ts +57 -3
  34. package/dist/editable-artifact-durable-export.d.ts +153 -0
  35. package/dist/editable-artifact-durable-export.js +788 -0
  36. package/dist/editable-artifact-durable-export.js.map +1 -0
  37. package/dist/editable-artifact-materialization.d.ts +123 -0
  38. package/dist/editable-artifacts-schema.d.ts +4152 -0
  39. package/dist/editable-artifacts.d.ts +610 -0
  40. package/dist/editable-artifacts.js +26 -0
  41. package/dist/editable-artifacts.js.map +1 -0
  42. package/dist/generated-images.d.ts +139 -0
  43. package/dist/index.d.ts +1122 -126
  44. package/dist/index.js +42329 -18407
  45. package/dist/index.js.map +1 -1
  46. package/dist/insights.d.ts +73 -10
  47. package/dist/integration-bindings.d.ts +70 -0
  48. package/dist/integration-facets.d.ts +99 -0
  49. package/dist/interaction-revisions.d.ts +14 -0
  50. package/dist/interaction-schema.d.ts +6036 -0
  51. package/dist/knowledge-source-sync-schema.d.ts +1679 -0
  52. package/dist/knowledge-source-sync.d.ts +274 -0
  53. package/dist/memory-governance.d.ts +2 -2
  54. package/dist/memory-slack-delivery.d.ts +101 -0
  55. package/dist/new-session-drafts.d.ts +2 -2
  56. package/dist/pack-components.d.ts +76 -0
  57. package/dist/pack-installations.d.ts +86 -0
  58. package/dist/persistence-errors.d.ts +3 -3
  59. package/dist/plugin-packages.d.ts +126 -0
  60. package/dist/preference-registry.d.ts +1 -1
  61. package/dist/provision-roles.d.ts +9 -1
  62. package/dist/provision-roles.js +1 -1
  63. package/dist/runtime-posture.d.ts +19 -6
  64. package/dist/schema.d.ts +22654 -9359
  65. package/dist/schema.js +209 -3
  66. package/dist/scoped-knowledge.d.ts +97 -1
  67. package/dist/session-control.d.ts +33 -7
  68. package/dist/session-queue-commands.d.ts +19 -11
  69. package/dist/session-realtime-context.d.ts +2 -2
  70. package/dist/session-realtime-ledger.d.ts +4 -4
  71. package/dist/session-realtime-mirror.d.ts +2 -2
  72. package/dist/session-realtime-state.d.ts +1 -1
  73. package/dist/session-realtime-terminal.d.ts +1 -1
  74. package/dist/session-realtime.d.ts +7 -7
  75. package/dist/session-tenancy.d.ts +44 -0
  76. package/dist/session-tenancy.js +16 -0
  77. package/dist/session-tenancy.js.map +1 -0
  78. package/dist/session-tool-call-settlement.d.ts +1 -1
  79. package/dist/slack-task-policy-schema.d.ts +847 -0
  80. package/dist/slack-task-policy.d.ts +65 -0
  81. package/dist/slack-user-link-access.d.ts +54 -0
  82. package/dist/task-notes-schema.d.ts +924 -0
  83. package/dist/task-notes.d.ts +85 -0
  84. package/dist/transcription-recordings.d.ts +2 -2
  85. package/dist/turn-initiator.d.ts +2 -2
  86. package/dist/video-generation.d.ts +225 -0
  87. package/dist/video-generation.js +68 -0
  88. package/dist/video-generation.js.map +1 -0
  89. package/dist/workspace-artifacts.d.ts +1 -1
  90. package/dist/workspace-instruction-policies.d.ts +1 -1
  91. package/dist/workspace-learning-policy-schema.d.ts +932 -0
  92. package/dist/workspace-learning-policy.d.ts +161 -0
  93. package/dist/xai-subscription.d.ts +326 -0
  94. package/drizzle/0183_model_call_provider_cost_estimates.sql +39 -0
  95. package/drizzle/0184_sandbox_drain_teardown_fence.sql +682 -0
  96. package/drizzle/0185_temporal_schedule_cleanup_outbox.sql +168 -0
  97. package/drizzle/0186_sandbox_capture_provider_contract.sql +400 -0
  98. package/drizzle/0187_generated_image_artifacts.sql +173 -0
  99. package/drizzle/0188_image_generation_retention_failure.sql +25 -0
  100. package/drizzle/0189_retained_session_image_formats.sql +13 -0
  101. package/drizzle/0190_timeline_annotations.sql +31 -0
  102. package/drizzle/0191_editable_artifact_engine.sql +3853 -0
  103. package/drizzle/0192_editable_artifact_live_tickets.sql +338 -0
  104. package/drizzle/0193_editable_artifact_authorization.sql +190 -0
  105. package/drizzle/0194_editable_artifact_durable_exports.sql +160 -0
  106. package/drizzle/0195_editable_artifact_import_authorization.sql +203 -0
  107. package/drizzle/0196_rig_provider_images.sql +152 -0
  108. package/drizzle/0197_knowledge_source_sync_schedules.sql +523 -0
  109. package/drizzle/0198_memory_slack_publication_delivery.sql +393 -0
  110. package/drizzle/0199_workspace_learning_policy.sql +980 -0
  111. package/drizzle/0201_company_profile_authority.sql +849 -0
  112. package/drizzle/0202_document_index_checkpoints.sql +85 -0
  113. package/drizzle/0203_durable_video_generation.sql +353 -0
  114. package/drizzle/0204_video_generation_funding.sql +44 -0
  115. package/drizzle/0205_attempt_tool_catalogs.sql +230 -0
  116. package/drizzle/0206_browser_sessions.sql +646 -0
  117. package/drizzle/0207_browser_identities.sql +379 -0
  118. package/drizzle/0208_attached_browser_devices.sql +165 -0
  119. package/drizzle/0209_computer_sessions.sql +575 -0
  120. package/drizzle/0210_browser_auth_network_interventions.sql +441 -0
  121. package/drizzle/0211_editable_artifact_session_links.sql +58 -0
  122. package/drizzle/0212_browser_state_transfer_hardening.sql +560 -0
  123. package/drizzle/0212_slack_installation_bindings.sql +348 -0
  124. package/drizzle/0213_browser_interaction_authority.sql +67 -0
  125. package/drizzle/0213_slack_user_link_access_requests.sql +177 -0
  126. package/drizzle/0214_browser_download_saves.sql +34 -0
  127. package/drizzle/0214_session_activity_commit_gate.sql +262 -0
  128. package/drizzle/0215_browser_controller_host.sql +385 -0
  129. package/drizzle/0215_capabilities_platform.sql +980 -0
  130. package/drizzle/0216_browser_auth_health_evidence.sql +137 -0
  131. package/drizzle/0216_pack_component_ownership.sql +235 -0
  132. package/drizzle/0217_capability_definition_delete_authority.sql +32 -0
  133. package/drizzle/0217_external_browser_auth_operations.sql +22 -0
  134. package/drizzle/0218_organization_tenancy_foundation.sql +299 -0
  135. package/drizzle/0219_organization_tenancy_managed_human_provisioning.sql +317 -0
  136. package/drizzle/0219_site_auth_maintenance_sessions.sql +234 -0
  137. package/drizzle/0220_memory_slack_append_only_cascade.sql +38 -0
  138. package/drizzle/0220_session_channels.sql +54 -0
  139. package/drizzle/0221_sessions_channel_index.sql +5 -0
  140. package/drizzle/0222_session_visibility_authority_epochs.sql +158 -0
  141. package/drizzle/0222_sessions_channel_fk.sql +89 -0
  142. package/drizzle/0223_pending_tool_event_output.sql +55 -0
  143. package/drizzle/0223_sessions_channel_fk_validate.sql +118 -0
  144. package/drizzle/0224_slack_post_outcome_reconciliation.sql +123 -0
  145. package/drizzle/0225_session_visibility_fork_activation.sql +1363 -0
  146. package/drizzle/0226_personal_codex_authority_foundation.sql +365 -0
  147. package/drizzle/0227_slack_native_actions.sql +145 -0
  148. package/drizzle/0228_interaction_controller_data_plane.sql +14 -0
  149. package/drizzle/0228_slack_task_policy.sql +400 -0
  150. package/drizzle/0229_slack_inbox_file_fact.sql +10 -0
  151. package/drizzle/0230_user_scoped_variable_sets_rigs.sql +84 -0
  152. package/drizzle/0231_integration_definition_identity_cutover.sql +271 -0
  153. package/drizzle/0232_integration_facet_authority_cutover.sql +610 -0
  154. package/drizzle/0233_skill_and_integration_authority_cutover.sql +1162 -0
  155. package/drizzle/0234_xai_subscription_authority.sql +1139 -0
  156. package/drizzle/0235_canonical_human_login_bindings.sql +920 -0
  157. package/drizzle/0236_browser_identity_lifecycle.sql +39 -0
  158. package/drizzle/0236_session_visibility_slack_policy.sql +72 -0
  159. package/drizzle/0237_interaction_transition_reaper.sql +263 -0
  160. package/drizzle/0238_goal_persistence_policy.sql +471 -0
  161. package/drizzle/0238_supergrok_realtime_model.sql +29 -0
  162. package/drizzle/0239_supergrok_video_funding.sql +50 -0
  163. package/drizzle/0239_task_tree_notes.sql +990 -0
  164. package/package.json +26 -5
  165. package/src/attached-browser-devices.ts +371 -0
  166. package/src/attempt-tool-catalogs.ts +131 -0
  167. package/src/browser-auth.ts +4373 -0
  168. package/src/browser-downloads.ts +517 -0
  169. package/src/browser-identities.ts +1385 -0
  170. package/src/browser-sessions.ts +2294 -0
  171. package/src/browser-state-artifacts.ts +449 -0
  172. package/src/canonical-human-identities.ts +317 -0
  173. package/src/capability-components.ts +166 -0
  174. package/src/capability-integrations.ts +1571 -0
  175. package/src/codemode-operations.ts +674 -0
  176. package/src/company-profile-schema.ts +143 -0
  177. package/src/company-profile.ts +968 -0
  178. package/src/computer-sessions.ts +1130 -0
  179. package/src/connection-token-resolver.ts +270 -25
  180. package/src/database.ts +468 -24
  181. package/src/editable-artifact-durable-export.ts +1201 -0
  182. package/src/editable-artifact-materialization.ts +893 -0
  183. package/src/editable-artifacts-schema.ts +879 -0
  184. package/src/editable-artifacts.ts +5404 -0
  185. package/src/generated-images.ts +740 -0
  186. package/src/index.ts +9963 -1465
  187. package/src/insights.ts +251 -23
  188. package/src/integration-bindings.ts +455 -0
  189. package/src/integration-facets.ts +862 -0
  190. package/src/interaction-revisions.ts +70 -0
  191. package/src/interaction-schema.ts +1606 -0
  192. package/src/knowledge-source-sync-schema.ts +192 -0
  193. package/src/knowledge-source-sync.ts +1922 -0
  194. package/src/memory-slack-delivery.ts +801 -0
  195. package/src/pack-components.ts +954 -0
  196. package/src/pack-installations.ts +886 -0
  197. package/src/persistence-errors.ts +4 -7
  198. package/src/plugin-packages.ts +1186 -0
  199. package/src/provision-roles.ts +534 -1
  200. package/src/runtime-posture-cli.ts +9 -0
  201. package/src/runtime-posture.ts +721 -5
  202. package/src/schema.ts +6270 -3159
  203. package/src/scoped-knowledge-schema.ts +1 -1
  204. package/src/scoped-knowledge.ts +655 -3
  205. package/src/session-control.ts +130 -42
  206. package/src/session-queue-commands.ts +265 -15
  207. package/src/session-realtime-context.ts +2 -2
  208. package/src/session-realtime-ledger.ts +3 -3
  209. package/src/session-realtime.ts +7 -7
  210. package/src/session-tenancy.ts +188 -0
  211. package/src/session-tool-call-settlement.ts +18 -3
  212. package/src/slack-task-policy-schema.ts +130 -0
  213. package/src/slack-task-policy.ts +341 -0
  214. package/src/slack-user-link-access.ts +702 -0
  215. package/src/task-notes-schema.ts +135 -0
  216. package/src/task-notes.ts +178 -0
  217. package/src/video-generation.ts +1530 -0
  218. package/src/workspace-artifacts.ts +1 -1
  219. package/src/workspace-learning-policy-schema.ts +139 -0
  220. package/src/workspace-learning-policy.ts +595 -0
  221. package/src/xai-subscription.ts +1887 -0
  222. package/dist/chunk-P6CUHXQZ.js +0 -7248
  223. package/dist/chunk-P6CUHXQZ.js.map +0 -1
  224. package/dist/chunk-VHBFHMPC.js +0 -1219
  225. package/dist/chunk-VHBFHMPC.js.map +0 -1
@@ -6,6 +6,130 @@ import {
6
6
  type RoleRelationshipCatalogRow,
7
7
  } from "./role-relationships";
8
8
 
9
+ const ARTIFACT_OUTBOX_CAPABILITY_ROUTINES = [
10
+ "claim_editable_artifact_live_outbox(text, integer, integer, name)",
11
+ "mark_editable_artifact_live_outbox_published(text, text, integer, name)",
12
+ "renew_editable_artifact_live_outbox(text, text, integer, integer, name)",
13
+ "retry_editable_artifact_live_outbox(text, text, integer, integer, text, name)",
14
+ "dead_letter_editable_artifact_live_outbox(text, text, integer, text, name)",
15
+ "release_editable_artifact_live_outbox(text, text, integer, name)",
16
+ ] as const;
17
+
18
+ const ARTIFACT_MATERIALIZER_CAPABILITY_ROUTINES = [
19
+ "claim_editable_artifact_materializations(text, integer, integer, name)",
20
+ "renew_editable_artifact_materialization(uuid, uuid, text, text, text, integer, integer, name)",
21
+ "succeed_editable_artifact_materialization(uuid, uuid, text, text, text, integer, text, text, text, bigint, text, text, timestamp with time zone, name)",
22
+ "fail_editable_artifact_materialization(uuid, uuid, text, text, text, integer, text, name)",
23
+ ] as const;
24
+
25
+ const ARTIFACT_LIVE_TICKET_CAPABILITY_ROUTINES = [
26
+ "put_editable_artifact_live_ticket(text, uuid, uuid, text, text, text, text, text, text, text, text, integer, text, boolean, integer, timestamp with time zone, timestamp with time zone, name)",
27
+ "consume_editable_artifact_live_ticket(text, name)",
28
+ "cleanup_expired_editable_artifact_live_tickets(integer, name)",
29
+ ] as const;
30
+
31
+ const ARTIFACT_LIVE_TICKET_INTERNAL_ROUTINES = [
32
+ "resolve_editable_artifact_ticket_data_schema(name)",
33
+ ] as const;
34
+
35
+ const ARTIFACT_AUTHORIZATION_CAPABILITY_ROUTINES = [
36
+ "authorize_editable_artifact_actor(uuid, uuid, text, text, text, text, text, text, integer, text, text, name)",
37
+ ] as const;
38
+
39
+ const DEDICATED_ARTIFACT_CAPABILITY_ROUTINES = new Set<string>([
40
+ ...ARTIFACT_OUTBOX_CAPABILITY_ROUTINES,
41
+ ...ARTIFACT_MATERIALIZER_CAPABILITY_ROUTINES,
42
+ ...ARTIFACT_LIVE_TICKET_INTERNAL_ROUTINES,
43
+ ]);
44
+
45
+ const KNOWLEDGE_SOURCE_SYNC_LOCK_AUTHORITY_ROUTINE =
46
+ "knowledge_source_sync_lock_authority(uuid, uuid, uuid)";
47
+ const KNOWLEDGE_SOURCE_SYNC_LOCK_AUTHORITY_TABLES = [
48
+ "knowledge_sources",
49
+ "knowledge_source_objects",
50
+ ] as const;
51
+ const MANAGED_HUMAN_PERSONAL_WORKSPACE_ROUTINE =
52
+ "ensure_managed_human_personal_workspace(uuid, text, uuid)";
53
+ const MANAGED_HUMAN_PERSONAL_WORKSPACE_AUTHORITY_TABLES = [
54
+ "organization_memberships",
55
+ "organization_user_retention_policies",
56
+ "organization_user_resource_authorities",
57
+ "organization_user_resource_grants",
58
+ ] as const;
59
+ const CANONICAL_HUMAN_IDENTITY_ROUTINES = [
60
+ "ensure_canonical_human_identity(text, text)",
61
+ "validate_canonical_human_session(text, text, boolean)",
62
+ "get_canonical_human_identity_projection(text)",
63
+ "apply_canonical_human_identity_operation(uuid, text, bigint, text, uuid, text, text, text)",
64
+ ] as const;
65
+ const CANONICAL_HUMAN_IDENTITY_AUTHORITY_TABLES = [
66
+ "canonical_human_identities",
67
+ "canonical_human_identity_subjects",
68
+ "canonical_human_login_bindings",
69
+ "canonical_human_identity_operations",
70
+ ] as const;
71
+ const SESSION_PRIVATE_ACTOR_VISIBLE_ROUTINE =
72
+ "session_private_actor_visible(uuid, uuid, uuid, text)";
73
+ const SESSION_REFERENCE_VISIBLE_ROUTINE = "session_reference_visible(uuid, uuid, uuid)";
74
+ const TASK_NOTE_CAPABILITY_ROUTINES = [
75
+ "create_task_note_for_attempt(uuid, uuid, uuid, uuid, uuid, integer, uuid, text, text, integer)",
76
+ "archive_task_note_for_attempt(uuid, uuid, uuid, uuid, uuid, integer, uuid, uuid, integer, text)",
77
+ "list_task_notes_for_attempt(uuid, uuid, uuid, uuid, uuid, integer, boolean, integer)",
78
+ ] as const;
79
+ const TRANSITION_SESSION_VISIBILITY_ROUTINE =
80
+ "transition_session_visibility(uuid, uuid, uuid, text, text, integer, text, text)";
81
+ const FORK_SESSION_CONTENT_ROUTINE =
82
+ "fork_session_content(uuid, uuid, uuid, text, uuid, text, text, text)";
83
+ const SESSION_AUTHORITY_ROUTINES = new Set<string>([
84
+ FORK_SESSION_CONTENT_ROUTINE,
85
+ SESSION_PRIVATE_ACTOR_VISIBLE_ROUTINE,
86
+ SESSION_REFERENCE_VISIBLE_ROUTINE,
87
+ TRANSITION_SESSION_VISIBILITY_ROUTINE,
88
+ ...TASK_NOTE_CAPABILITY_ROUTINES,
89
+ ]);
90
+ const XAI_CREATE_CREDENTIAL_ROUTINE =
91
+ "create_xai_subscription_credential(uuid, uuid, text, text, text, text, text, text, text, timestamp with time zone)";
92
+ const XAI_DISCONNECT_CREDENTIAL_ROUTINE =
93
+ "disconnect_xai_subscription_credential(uuid, uuid, text, uuid, jsonb)";
94
+ const XAI_SNAPSHOT_VALIDATOR_ROUTINE = "xai_provider_account_authority_snapshot_v1_valid(jsonb)";
95
+ const XAI_AUTHORITY_LIVE_ROUTINE =
96
+ "xai_subscription_authority_live(uuid, uuid, text, uuid, text, uuid, uuid, bigint)";
97
+ const XAI_POOL_VISIBLE_ROUTINE = "xai_subscription_pool_visible(uuid, uuid, text, text, uuid)";
98
+ const XAI_RESOLVE_POOL_ROUTINE = "resolve_xai_authority_pool(uuid, uuid, text, jsonb)";
99
+ const XAI_REVALIDATE_CREDENTIAL_ROUTINE =
100
+ "revalidate_xai_subscription_authority(uuid, text, uuid, jsonb)";
101
+ const XAI_AUTHORITY_TABLES = [
102
+ "organization_memberships",
103
+ "organization_user_resource_authorities",
104
+ "workspace_memberships",
105
+ "xai_subscription_credentials",
106
+ ] as const;
107
+
108
+ export const RUNTIME_TARGET_SCHEMA_CAPABILITY_ROUTINES = [
109
+ FORK_SESSION_CONTENT_ROUTINE,
110
+ XAI_AUTHORITY_LIVE_ROUTINE,
111
+ XAI_CREATE_CREDENTIAL_ROUTINE,
112
+ XAI_DISCONNECT_CREDENTIAL_ROUTINE,
113
+ KNOWLEDGE_SOURCE_SYNC_LOCK_AUTHORITY_ROUTINE,
114
+ MANAGED_HUMAN_PERSONAL_WORKSPACE_ROUTINE,
115
+ ...CANONICAL_HUMAN_IDENTITY_ROUTINES,
116
+ SESSION_PRIVATE_ACTOR_VISIBLE_ROUTINE,
117
+ SESSION_REFERENCE_VISIBLE_ROUTINE,
118
+ TRANSITION_SESSION_VISIBILITY_ROUTINE,
119
+ XAI_POOL_VISIBLE_ROUTINE,
120
+ XAI_RESOLVE_POOL_ROUTINE,
121
+ XAI_REVALIDATE_CREDENTIAL_ROUTINE,
122
+ XAI_SNAPSHOT_VALIDATOR_ROUTINE,
123
+ ] as const;
124
+
125
+ export const RUNTIME_TARGET_SCHEMA_INVOKER_ROUTINES = [
126
+ SESSION_REFERENCE_VISIBLE_ROUTINE,
127
+ XAI_SNAPSHOT_VALIDATOR_ROUTINE,
128
+ ] as const;
129
+ const RUNTIME_TARGET_SCHEMA_INVOKER_ROUTINE_SET = new Set<string>(
130
+ RUNTIME_TARGET_SCHEMA_INVOKER_ROUTINES,
131
+ );
132
+
9
133
  /**
10
134
  * The complete standalone tenant-table contract. Adding or removing a
11
135
  * FORCE-RLS table is an architectural change: update this list in the same
@@ -14,17 +138,50 @@ import {
14
138
  export const FORCE_RLS_TABLES = [
15
139
  "agent_run_states",
16
140
  "api_keys",
141
+ "attached_browser_devices",
142
+ "attached_browser_inventories",
17
143
  "audit_events",
144
+ "auth_runs",
18
145
  "billing_customers",
146
+ "browser_identities",
147
+ "browser_revision_components",
148
+ "browser_revisions",
149
+ "browser_session_associations",
150
+ "browser_sessions",
151
+ "browser_state_artifacts",
152
+ "browser_state_uploads",
153
+ "canonical_human_identities",
154
+ "canonical_human_identity_operations",
155
+ "canonical_human_identity_subjects",
156
+ "canonical_human_login_bindings",
157
+ "capability_api_facets",
19
158
  "capability_catalog_items",
159
+ "capability_component_owners",
160
+ "capability_facet_installations",
161
+ "capability_facets",
20
162
  "capability_installations",
163
+ "capability_integration_facets",
164
+ "capability_mcp_facets",
165
+ "capability_operations",
166
+ "capability_plugin_installations",
167
+ "capability_plugin_versions",
168
+ "capability_plugins",
169
+ "capability_skill_facets",
170
+ "capability_skill_files",
171
+ "channels",
21
172
  "codex_apps_settings",
22
173
  "codex_capacity_waiters",
23
174
  "codex_credential_leases",
24
175
  "codex_reset_redemption_attempts",
25
176
  "codex_rotation_settings",
26
177
  "codex_subscription_credentials",
178
+ "company_profile_activation_events",
179
+ "company_profile_heads",
180
+ "company_profile_revisions",
181
+ "company_profile_snapshots",
27
182
  "composer_drafts",
183
+ "computer_session_associations",
184
+ "computer_sessions",
28
185
  "connection_disconnect_operations",
29
186
  "connections",
30
187
  "connector_action_policies",
@@ -34,9 +191,27 @@ export const FORCE_RLS_TABLES = [
34
191
  "document_bases",
35
192
  "document_chunks",
36
193
  "documents",
194
+ "editable_artifact_blob_refs",
195
+ "editable_artifact_idempotency_receipts",
196
+ "editable_artifact_live_outbox",
197
+ "editable_artifact_live_tickets",
198
+ "editable_artifact_materialization_jobs",
199
+ "editable_artifact_materialization_results",
200
+ "editable_artifact_operations",
201
+ "editable_artifact_replica_leases",
202
+ "editable_artifact_scope_authorization_heads",
203
+ "editable_artifact_sequence_checkpoints",
204
+ "editable_artifact_session_links",
205
+ "editable_artifact_snapshots",
206
+ "editable_artifact_transactions",
207
+ "editable_artifact_undo_claims",
208
+ "editable_artifact_versions",
209
+ "editable_artifacts",
37
210
  "enrollments",
38
211
  "file_uploads",
39
212
  "files",
213
+ "generated_image_artifacts",
214
+ "generated_video_artifacts",
40
215
  "github_installation_repositories",
41
216
  "github_installations",
42
217
  "host_export_config",
@@ -44,8 +219,17 @@ export const FORCE_RLS_TABLES = [
44
219
  "host_export_cursor_state",
45
220
  "host_export_dead_letters",
46
221
  "host_export_outbox",
222
+ "image_generation_operations",
47
223
  "import_batches",
224
+ "integration_facet_binding_owners",
225
+ "integration_facet_bindings",
226
+ "integration_facet_definitions",
48
227
  "integration_oauth_state_nonces",
228
+ "integration_spec_revisions",
229
+ "integration_tools",
230
+ "interaction_interventions",
231
+ "interaction_operations",
232
+ "interaction_resource_operations",
49
233
  "knowledge_change_proposals",
50
234
  "knowledge_claim_evidence",
51
235
  "knowledge_claim_relations",
@@ -63,13 +247,27 @@ export const FORCE_RLS_TABLES = [
63
247
  "knowledge_providers",
64
248
  "knowledge_source_acl_versions",
65
249
  "knowledge_source_objects",
250
+ "knowledge_source_sync_index_obligations",
251
+ "knowledge_source_sync_item_outcomes",
252
+ "knowledge_source_sync_object_observations",
253
+ "knowledge_source_sync_states",
254
+ "knowledge_source_sync_wakes",
66
255
  "knowledge_sources",
67
256
  "knowledge_sync_runs",
68
257
  "machine_metrics_latest",
69
258
  "machine_metrics_series",
70
259
  "machine_removal_operations",
260
+ "memory_slack_publication_configurations",
261
+ "memory_slack_publication_receipts",
262
+ "memory_slack_publications",
71
263
  "model_call_facts",
264
+ "network_routes",
72
265
  "new_session_drafts",
266
+ "organization_memberships",
267
+ "organization_user_resource_authorities",
268
+ "organization_user_resource_grants",
269
+ "organization_user_retention_policies",
270
+ "pack_installation_components",
73
271
  "pack_installations",
74
272
  "preference_registry_events",
75
273
  "preference_registry_preferences",
@@ -89,9 +287,12 @@ export const FORCE_RLS_TABLES = [
89
287
  "sandboxes",
90
288
  "scheduled_task_runs",
91
289
  "scheduled_tasks",
290
+ "session_attempt_codemode_calls",
92
291
  "session_attempt_interruptions",
292
+ "session_attempt_tool_catalogs",
93
293
  "session_command_receipts",
94
294
  "session_events",
295
+ "session_goal_revisions",
95
296
  "session_goals",
96
297
  "session_history_items",
97
298
  "session_human_input_requests",
@@ -110,21 +311,38 @@ export const FORCE_RLS_TABLES = [
110
311
  "session_system_updates",
111
312
  "session_turn_attempts",
112
313
  "session_turns",
314
+ "session_visibility_write_capabilities",
113
315
  "session_workflow_wake_outbox",
114
316
  "sessions",
317
+ "site_auth_connections",
115
318
  "slack_bot_delete_operations",
116
319
  "slack_bot_post_operations",
320
+ "slack_bot_update_operations",
117
321
  "slack_bot_user_links",
322
+ "slack_installation_bindings",
323
+ "slack_interaction_action_handles",
118
324
  "slack_interaction_inbox",
119
325
  "slack_interaction_progress_deliveries",
120
326
  "slack_interactions",
327
+ "slack_shared_task_origins",
328
+ "slack_task_policy_activation_events",
329
+ "slack_task_policy_heads",
330
+ "slack_task_policy_revisions",
331
+ "slack_user_link_access_request_operations",
332
+ "slack_user_link_access_requests",
121
333
  "social_connections",
122
334
  "social_posts",
335
+ "task_note_events",
336
+ "task_note_write_capabilities",
337
+ "task_notes",
338
+ "temporal_schedule_cleanup_outbox",
123
339
  "transcription_recording_chunks",
124
340
  "transcription_recording_objects",
125
341
  "transcription_recording_segments",
126
342
  "transcription_recordings",
127
343
  "usage_events",
344
+ "video_generation_operations",
345
+ "video_generation_references",
128
346
  "workspace_artifact_events",
129
347
  "workspace_artifact_versions",
130
348
  "workspace_artifacts",
@@ -136,12 +354,24 @@ export const FORCE_RLS_TABLES = [
136
354
  "workspace_instruction_policy_onboarding_proposals",
137
355
  "workspace_instruction_policy_revisions",
138
356
  "workspace_instruction_policy_snapshots",
357
+ "workspace_interaction_revisions",
358
+ "workspace_learning_policy_activation_events",
359
+ "workspace_learning_policy_heads",
360
+ "workspace_learning_policy_revisions",
361
+ "workspace_learning_policy_snapshots",
139
362
  "workspace_model_policies",
140
363
  "workspace_packs",
141
364
  "workspace_screenshot_quotas",
142
365
  "workspace_session_activity_revisions",
143
366
  "workspace_variable_set_variables",
144
367
  "workspace_variable_sets",
368
+ "workspace_video_generation_policies",
369
+ "workspace_video_generation_quotas",
370
+ "xai_capacity_waiters",
371
+ "xai_credential_leases",
372
+ "xai_rotation_settings",
373
+ "xai_session_account_pins",
374
+ "xai_subscription_credentials",
145
375
  ] as const;
146
376
 
147
377
  /**
@@ -178,8 +408,14 @@ export const RUNTIME_FULL_DML_TABLES = [
178
408
  "auth_users",
179
409
  "auth_verifications",
180
410
  "billing_customers",
411
+ "browser_session_associations",
181
412
  "capability_catalog_items",
413
+ "capability_component_owners",
414
+ "capability_facet_installations",
182
415
  "capability_installations",
416
+ "capability_operations",
417
+ "capability_plugin_installations",
418
+ "channels",
183
419
  "codex_apps_settings",
184
420
  "codex_capacity_waiters",
185
421
  "codex_credential_leases",
@@ -187,6 +423,7 @@ export const RUNTIME_FULL_DML_TABLES = [
187
423
  "codex_rotation_settings",
188
424
  "codex_subscription_credentials",
189
425
  "composer_drafts",
426
+ "computer_session_associations",
190
427
  "connection_disconnect_operations",
191
428
  "connections",
192
429
  "connector_action_policies",
@@ -196,21 +433,36 @@ export const RUNTIME_FULL_DML_TABLES = [
196
433
  "document_bases",
197
434
  "document_chunks",
198
435
  "documents",
436
+ "editable_artifact_replica_leases",
199
437
  "enrollments",
200
438
  "file_uploads",
201
439
  "files",
440
+ "generated_image_artifacts",
441
+ "generated_video_artifacts",
202
442
  "github_installation_repositories",
203
443
  "github_installations",
444
+ "image_generation_operations",
204
445
  "import_batches",
446
+ "integration_facet_binding_owners",
447
+ "integration_facet_bindings",
205
448
  "integration_oauth_clients",
206
449
  "integration_oauth_state_nonces",
207
450
  "knowledge_memories",
451
+ "knowledge_source_sync_index_obligations",
452
+ "knowledge_source_sync_item_outcomes",
453
+ "knowledge_source_sync_object_observations",
454
+ "knowledge_source_sync_states",
455
+ "knowledge_source_sync_wakes",
208
456
  "machine_metrics_latest",
209
457
  "machine_metrics_series",
210
458
  "machine_removal_operations",
211
459
  "managed_accounts",
460
+ "memory_slack_publication_configurations",
461
+ "memory_slack_publication_receipts",
462
+ "memory_slack_publications",
212
463
  "model_call_facts",
213
464
  "new_session_drafts",
465
+ "pack_installation_components",
214
466
  "pack_installations",
215
467
  "retained_screenshot_artifacts",
216
468
  "rig_changes",
@@ -250,7 +502,9 @@ export const RUNTIME_FULL_DML_TABLES = [
250
502
  "sessions",
251
503
  "slack_bot_delete_operations",
252
504
  "slack_bot_post_operations",
505
+ "slack_bot_update_operations",
253
506
  "slack_bot_user_links",
507
+ "slack_interaction_action_handles",
254
508
  "slack_interaction_inbox",
255
509
  "slack_interaction_progress_deliveries",
256
510
  "slack_interactions",
@@ -262,6 +516,8 @@ export const RUNTIME_FULL_DML_TABLES = [
262
516
  "transcription_recording_segments",
263
517
  "transcription_recordings",
264
518
  "usage_events",
519
+ "video_generation_operations",
520
+ "video_generation_references",
265
521
  "workspace_artifacts",
266
522
  "workspace_captures",
267
523
  "workspace_control_events",
@@ -271,25 +527,58 @@ export const RUNTIME_FULL_DML_TABLES = [
271
527
  "workspace_model_policies",
272
528
  "workspace_packs",
273
529
  "workspace_screenshot_quotas",
274
- "workspace_session_activity_revisions",
275
530
  "workspace_variable_set_variables",
276
531
  "workspace_variable_sets",
532
+ "workspace_video_generation_policies",
533
+ "workspace_video_generation_quotas",
277
534
  "workspaces",
535
+ "xai_capacity_waiters",
536
+ "xai_credential_leases",
537
+ "xai_rotation_settings",
538
+ "xai_session_account_pins",
539
+ "xai_subscription_credentials",
278
540
  ] as const;
279
541
 
280
542
  /** Configuration and lifecycle-owned audit rows are read-only at runtime. */
281
543
  export const RUNTIME_READ_ONLY_TABLES = [
544
+ "company_profile_activation_events",
545
+ "company_profile_heads",
546
+ "company_profile_snapshots",
282
547
  "knowledge_lifecycle_events",
283
548
  "knowledge_memory_lifecycle_events",
284
549
  "knowledge_memory_relationships",
285
550
  "nested_agent_depth_configuration",
286
551
  "preference_registry_events",
287
552
  "preference_registry_snapshots",
553
+ "slack_installation_bindings",
554
+ "slack_task_policy_activation_events",
555
+ "slack_task_policy_heads",
556
+ "slack_task_policy_revisions",
288
557
  "workspace_instruction_policy_snapshots",
558
+ "workspace_learning_policy_activation_events",
559
+ "workspace_learning_policy_heads",
560
+ "workspace_learning_policy_snapshots",
289
561
  ] as const;
290
562
 
563
+ /** Existing runtime authorities that may be observed and advanced, never created or deleted. */
564
+ export const RUNTIME_READ_UPDATE_TABLES = ["workspace_session_activity_revisions"] as const;
565
+
291
566
  /** Append-only evidence/revision tables are insertable and queryable, never mutable. */
292
567
  export const RUNTIME_READ_INSERT_TABLES = [
568
+ "browser_revision_components",
569
+ "browser_revisions",
570
+ "company_profile_revisions",
571
+ "editable_artifact_blob_refs",
572
+ "editable_artifact_idempotency_receipts",
573
+ "editable_artifact_live_outbox",
574
+ "editable_artifact_materialization_jobs",
575
+ "editable_artifact_materialization_results",
576
+ "editable_artifact_operations",
577
+ "editable_artifact_sequence_checkpoints",
578
+ "editable_artifact_snapshots",
579
+ "editable_artifact_transactions",
580
+ "editable_artifact_undo_claims",
581
+ "editable_artifact_versions",
293
582
  "knowledge_change_proposals",
294
583
  "knowledge_claim_evidence",
295
584
  "knowledge_claim_relations",
@@ -307,12 +596,51 @@ export const RUNTIME_READ_INSERT_TABLES = [
307
596
  "knowledge_sync_runs",
308
597
  "preference_registry_preferences",
309
598
  "preference_registry_revisions",
599
+ "session_attempt_tool_catalogs",
600
+ "session_goal_revisions",
310
601
  "session_spawn_denials",
602
+ "slack_shared_task_origins",
603
+ "slack_user_link_access_request_operations",
604
+ "temporal_schedule_cleanup_outbox",
311
605
  "workspace_artifact_events",
312
606
  "workspace_artifact_versions",
313
607
  "workspace_instruction_policy_activation_events",
314
608
  "workspace_instruction_policy_onboarding_proposals",
315
609
  "workspace_instruction_policy_revisions",
610
+ "workspace_learning_policy_revisions",
611
+ ] as const;
612
+
613
+ /** Durable operation journals are append/read plus claim/settle updates, never deletes. */
614
+ export const RUNTIME_READ_INSERT_UPDATE_TABLES = [
615
+ "attached_browser_devices",
616
+ "attached_browser_inventories",
617
+ "auth_runs",
618
+ "browser_identities",
619
+ "browser_sessions",
620
+ "browser_state_artifacts",
621
+ "browser_state_uploads",
622
+ "capability_api_facets",
623
+ "capability_facets",
624
+ "capability_integration_facets",
625
+ "capability_mcp_facets",
626
+ "capability_plugin_versions",
627
+ "capability_plugins",
628
+ "capability_skill_facets",
629
+ "capability_skill_files",
630
+ "computer_sessions",
631
+ "editable_artifact_session_links",
632
+ "editable_artifacts",
633
+ "integration_facet_definitions",
634
+ "integration_spec_revisions",
635
+ "integration_tools",
636
+ "interaction_interventions",
637
+ "interaction_operations",
638
+ "interaction_resource_operations",
639
+ "network_routes",
640
+ "session_attempt_codemode_calls",
641
+ "site_auth_connections",
642
+ "slack_user_link_access_requests",
643
+ "workspace_interaction_revisions",
316
644
  ] as const;
317
645
 
318
646
  /**
@@ -320,11 +648,25 @@ export const RUNTIME_READ_INSERT_TABLES = [
320
648
  * The ordinary application role must have no direct table privileges on them.
321
649
  */
322
650
  export const PROTECTED_NO_DIRECT_DML_TABLES = [
651
+ "canonical_human_identities",
652
+ "canonical_human_identity_operations",
653
+ "canonical_human_identity_subjects",
654
+ "canonical_human_login_bindings",
655
+ "editable_artifact_live_tickets",
656
+ "editable_artifact_scope_authorization_heads",
323
657
  "host_export_config",
324
658
  "host_export_consumers",
325
659
  "host_export_cursor_state",
326
660
  "host_export_dead_letters",
327
661
  "host_export_outbox",
662
+ "organization_memberships",
663
+ "organization_user_resource_authorities",
664
+ "organization_user_resource_grants",
665
+ "organization_user_retention_policies",
666
+ "session_visibility_write_capabilities",
667
+ "task_note_events",
668
+ "task_note_write_capabilities",
669
+ "task_notes",
328
670
  ] as const;
329
671
 
330
672
  export type RuntimeTableDmlPrivilege = "SELECT" | "INSERT" | "UPDATE" | "DELETE";
@@ -338,9 +680,18 @@ const FULL_DML_PRIVILEGES = ["SELECT", "INSERT", "UPDATE", "DELETE"] as const;
338
680
  export const RUNTIME_TABLE_PRIVILEGES: RuntimeTablePrivilegeContract = Object.freeze({
339
681
  ...Object.fromEntries(RUNTIME_FULL_DML_TABLES.map((table) => [table, FULL_DML_PRIVILEGES])),
340
682
  ...Object.fromEntries(RUNTIME_READ_ONLY_TABLES.map((table) => [table, ["SELECT"] as const])),
683
+ ...Object.fromEntries(
684
+ RUNTIME_READ_UPDATE_TABLES.map((table) => [table, ["SELECT", "UPDATE"] as const]),
685
+ ),
341
686
  ...Object.fromEntries(
342
687
  RUNTIME_READ_INSERT_TABLES.map((table) => [table, ["SELECT", "INSERT"] as const]),
343
688
  ),
689
+ ...Object.fromEntries(
690
+ RUNTIME_READ_INSERT_UPDATE_TABLES.map((table) => [
691
+ table,
692
+ ["SELECT", "INSERT", "UPDATE"] as const,
693
+ ]),
694
+ ),
344
695
  });
345
696
 
346
697
  /** All tables with any direct runtime DML; retained as the aggregate public contract. */
@@ -387,6 +738,8 @@ export type RuntimeTablePosture = {
387
738
  rlsForced: boolean;
388
739
  rlsActive: boolean;
389
740
  policyCount: number;
741
+ artifactOutboxDispatcherPolicy: boolean;
742
+ artifactMaterializerPolicy: boolean;
390
743
  select: boolean;
391
744
  insert: boolean;
392
745
  update: boolean;
@@ -400,6 +753,11 @@ export type RuntimeRoutinePosture = {
400
753
  name: string;
401
754
  owner: string;
402
755
  execute: boolean;
756
+ securityDefiner: boolean;
757
+ };
758
+
759
+ export type RuntimeTargetRoutinePosture = RuntimeRoutinePosture & {
760
+ publicExecute: boolean;
403
761
  };
404
762
 
405
763
  export type RuntimeDatabasePosture = {
@@ -410,6 +768,7 @@ export type RuntimeDatabasePosture = {
410
768
  ownedSchemas: string[];
411
769
  ownedRelations: string[];
412
770
  tables: RuntimeTablePosture[];
771
+ targetRoutines: RuntimeTargetRoutinePosture[];
413
772
  privateRoutines: RuntimeRoutinePosture[];
414
773
  };
415
774
 
@@ -520,6 +879,7 @@ export async function inspectRuntimeDatabasePosture(
520
879
  ownedSchemas: [],
521
880
  ownedRelations: [],
522
881
  tables: [],
882
+ targetRoutines: [],
523
883
  privateRoutines: [],
524
884
  };
525
885
  }
@@ -580,6 +940,8 @@ export async function inspectRuntimeDatabasePosture(
580
940
  rls_forced: boolean;
581
941
  rls_active: boolean;
582
942
  policy_count: number;
943
+ artifact_outbox_dispatcher_policy: boolean;
944
+ artifact_materializer_policy: boolean;
583
945
  can_select: boolean;
584
946
  can_insert: boolean;
585
947
  can_update: boolean;
@@ -596,6 +958,16 @@ export async function inspectRuntimeDatabasePosture(
596
958
  c.relforcerowsecurity as rls_forced,
597
959
  row_security_active(c.oid) as rls_active,
598
960
  (select count(*)::int from pg_policy policy where policy.polrelid = c.oid) as policy_count,
961
+ exists(
962
+ select 1 from pg_policy policy
963
+ where policy.polrelid = c.oid
964
+ and policy.polname = 'editable_artifact_outbox_dispatcher'
965
+ ) as artifact_outbox_dispatcher_policy,
966
+ exists(
967
+ select 1 from pg_policy policy
968
+ where policy.polrelid = c.oid
969
+ and policy.polname = 'editable_artifact_materializer_owner'
970
+ ) as artifact_materializer_policy,
599
971
  has_table_privilege(current_user, c.oid, 'SELECT') as can_select,
600
972
  has_table_privilege(current_user, c.oid, 'INSERT') as can_insert,
601
973
  has_table_privilege(current_user, c.oid, 'UPDATE') as can_update,
@@ -616,6 +988,8 @@ export async function inspectRuntimeDatabasePosture(
616
988
  rlsForced: row.rls_forced,
617
989
  rlsActive: row.rls_active,
618
990
  policyCount: row.policy_count,
991
+ artifactOutboxDispatcherPolicy: row.artifact_outbox_dispatcher_policy,
992
+ artifactMaterializerPolicy: row.artifact_materializer_policy,
619
993
  select: row.can_select,
620
994
  insert: row.can_insert,
621
995
  update: row.can_update,
@@ -625,26 +999,69 @@ export async function inspectRuntimeDatabasePosture(
625
999
  trigger: row.can_trigger,
626
1000
  }));
627
1001
 
1002
+ const targetRoutines = resultRows<{
1003
+ name: string;
1004
+ owner: string;
1005
+ can_execute: boolean;
1006
+ public_execute: boolean;
1007
+ security_definer: boolean;
1008
+ }>(
1009
+ await tx.execute(sql`
1010
+ select
1011
+ (p.proname || '(' || pg_catalog.oidvectortypes(p.proargtypes) || ')')::text as name,
1012
+ pg_get_userbyid(p.proowner)::text as owner,
1013
+ has_function_privilege(current_user, p.oid, 'EXECUTE') as can_execute,
1014
+ exists (
1015
+ select 1
1016
+ from aclexplode(coalesce(p.proacl, acldefault('f', p.proowner))) acl
1017
+ where acl.grantee = 0 and acl.privilege_type = 'EXECUTE'
1018
+ ) as public_execute,
1019
+ p.prosecdef as security_definer
1020
+ from pg_proc p
1021
+ join pg_namespace n on n.oid = p.pronamespace
1022
+ where n.nspname = ${targetSchema}
1023
+ and p.prokind in ('f', 'p')
1024
+ and (p.proname || '(' || pg_catalog.oidvectortypes(p.proargtypes) || ')') = any(
1025
+ array[
1026
+ ${sql.join(
1027
+ RUNTIME_TARGET_SCHEMA_CAPABILITY_ROUTINES.map((name) => sql`${name}`),
1028
+ sql`, `,
1029
+ )}
1030
+ ]::text[]
1031
+ )
1032
+ order by p.proname, pg_catalog.oidvectortypes(p.proargtypes)
1033
+ `),
1034
+ ).map((row) => ({
1035
+ name: row.name,
1036
+ owner: row.owner,
1037
+ execute: row.can_execute,
1038
+ publicExecute: row.public_execute,
1039
+ securityDefiner: row.security_definer,
1040
+ }));
1041
+
628
1042
  const privateRoutines = resultRows<{
629
1043
  name: string;
630
1044
  owner: string;
631
1045
  can_execute: boolean;
1046
+ security_definer: boolean;
632
1047
  }>(
633
1048
  await tx.execute(sql`
634
1049
  select
635
- (p.proname || '(' || pg_get_function_identity_arguments(p.oid) || ')')::text as name,
1050
+ (p.proname || '(' || pg_catalog.oidvectortypes(p.proargtypes) || ')')::text as name,
636
1051
  pg_get_userbyid(p.proowner)::text as owner,
637
- has_function_privilege(current_user, p.oid, 'EXECUTE') as can_execute
1052
+ has_function_privilege(current_user, p.oid, 'EXECUTE') as can_execute,
1053
+ p.prosecdef as security_definer
638
1054
  from pg_proc p
639
1055
  join pg_namespace n on n.oid = p.pronamespace
640
1056
  where n.nspname = 'opengeni_private'
641
1057
  and p.prokind in ('f', 'p')
642
- order by p.proname, pg_get_function_identity_arguments(p.oid)
1058
+ order by p.proname, pg_catalog.oidvectortypes(p.proargtypes)
643
1059
  `),
644
1060
  ).map((row) => ({
645
1061
  name: row.name,
646
1062
  owner: row.owner,
647
1063
  execute: row.can_execute,
1064
+ securityDefiner: row.security_definer,
648
1065
  }));
649
1066
 
650
1067
  return {
@@ -654,6 +1071,7 @@ export async function inspectRuntimeDatabasePosture(
654
1071
  ownedSchemas,
655
1072
  ownedRelations,
656
1073
  tables,
1074
+ targetRoutines,
657
1075
  privateRoutines,
658
1076
  };
659
1077
  },
@@ -823,6 +1241,303 @@ export function evaluateRuntimeDatabasePosture(
823
1241
  if (table.policyCount < 1) violations.push(`table ${tableName} has no RLS policy`);
824
1242
  }
825
1243
 
1244
+ const targetSchemaOwner = posture.schemas.find((schema) => schema.name === targetSchema)?.owner;
1245
+ for (const expectedRoutine of RUNTIME_TARGET_SCHEMA_CAPABILITY_ROUTINES) {
1246
+ const matches = posture.targetRoutines.filter((routine) => routine.name === expectedRoutine);
1247
+ if (matches.length !== 1) {
1248
+ violations.push(
1249
+ `target-schema runtime capability ${expectedRoutine} is missing or ambiguous`,
1250
+ );
1251
+ continue;
1252
+ }
1253
+ const routine = matches[0]!;
1254
+ if (RUNTIME_TARGET_SCHEMA_INVOKER_ROUTINE_SET.has(routine.name)) {
1255
+ if (routine.securityDefiner) {
1256
+ violations.push(
1257
+ `target-schema runtime capability ${routine.name} must be SECURITY INVOKER`,
1258
+ );
1259
+ }
1260
+ } else if (!routine.securityDefiner) {
1261
+ violations.push(`target-schema runtime capability ${routine.name} is not SECURITY DEFINER`);
1262
+ }
1263
+ if (routine.name === KNOWLEDGE_SOURCE_SYNC_LOCK_AUTHORITY_ROUTINE) {
1264
+ const missingAuthorityTables = KNOWLEDGE_SOURCE_SYNC_LOCK_AUTHORITY_TABLES.filter(
1265
+ (tableName) => !tableByName.has(tableName),
1266
+ );
1267
+ if (missingAuthorityTables.length > 0) {
1268
+ violations.push(
1269
+ `target-schema runtime capability ${routine.name} authority tables are missing: ${missingAuthorityTables.join(", ")}`,
1270
+ );
1271
+ } else {
1272
+ const authorityTables = KNOWLEDGE_SOURCE_SYNC_LOCK_AUTHORITY_TABLES.map(
1273
+ (tableName) => tableByName.get(tableName)!,
1274
+ );
1275
+ const authorityOwners = new Set(authorityTables.map((table) => table.owner));
1276
+ if (authorityOwners.size !== 1) {
1277
+ violations.push(
1278
+ `target-schema runtime capability ${routine.name} authority table owners do not match: ${authorityTables.map((table) => `${table.name}=${table.owner}`).join(", ")}`,
1279
+ );
1280
+ } else if (routine.owner !== authorityTables[0]!.owner) {
1281
+ violations.push(
1282
+ `target-schema runtime capability ${routine.name} owner ${routine.owner} does not match authority table owner ${authorityTables[0]!.owner}`,
1283
+ );
1284
+ }
1285
+ }
1286
+ } else if (routine.name === MANAGED_HUMAN_PERSONAL_WORKSPACE_ROUTINE) {
1287
+ const authorityTables = MANAGED_HUMAN_PERSONAL_WORKSPACE_AUTHORITY_TABLES.filter(
1288
+ (tableName) => tableByName.has(tableName),
1289
+ ).map((tableName) => tableByName.get(tableName)!);
1290
+ const authorityOwners = new Set(authorityTables.map((table) => table.owner));
1291
+ if (authorityOwners.size > 1) {
1292
+ violations.push(
1293
+ `target-schema runtime capability ${routine.name} authority table owners do not match: ${authorityTables.map((table) => `${table.name}=${table.owner}`).join(", ")}`,
1294
+ );
1295
+ } else if (authorityTables[0] && routine.owner !== authorityTables[0].owner) {
1296
+ violations.push(
1297
+ `target-schema runtime capability ${routine.name} owner ${routine.owner} does not match authority table owner ${authorityTables[0].owner}`,
1298
+ );
1299
+ }
1300
+ } else if ((CANONICAL_HUMAN_IDENTITY_ROUTINES as readonly string[]).includes(routine.name)) {
1301
+ const authorityTables = CANONICAL_HUMAN_IDENTITY_AUTHORITY_TABLES.filter((tableName) =>
1302
+ tableByName.has(tableName),
1303
+ ).map((tableName) => tableByName.get(tableName)!);
1304
+ const authorityOwners = new Set(authorityTables.map((table) => table.owner));
1305
+ if (authorityTables.length !== CANONICAL_HUMAN_IDENTITY_AUTHORITY_TABLES.length) {
1306
+ violations.push(
1307
+ `target-schema runtime capability ${routine.name} canonical identity authority tables are missing`,
1308
+ );
1309
+ } else if (authorityOwners.size !== 1) {
1310
+ violations.push(
1311
+ `target-schema runtime capability ${routine.name} authority table owners do not match: ${authorityTables.map((table) => `${table.name}=${table.owner}`).join(", ")}`,
1312
+ );
1313
+ } else if (routine.owner !== authorityTables[0]!.owner) {
1314
+ violations.push(
1315
+ `target-schema runtime capability ${routine.name} owner ${routine.owner} does not match authority table owner ${authorityTables[0]!.owner}`,
1316
+ );
1317
+ }
1318
+ } else if (SESSION_AUTHORITY_ROUTINES.has(routine.name)) {
1319
+ const authorityOwner = tableByName.get("sessions")?.owner ?? targetSchemaOwner;
1320
+ if (authorityOwner && routine.owner !== authorityOwner) {
1321
+ violations.push(
1322
+ `target-schema runtime capability ${routine.name} owner ${routine.owner} does not match session authority owner ${authorityOwner}`,
1323
+ );
1324
+ }
1325
+ } else if (routine.name === XAI_SNAPSHOT_VALIDATOR_ROUTINE) {
1326
+ // The immutable SQL validator is invoker-rights and reads no table. Its
1327
+ // exact ACL is posture-checked above; it does not participate in the
1328
+ // SECURITY DEFINER same-owner authority graph.
1329
+ } else if (
1330
+ routine.name === XAI_CREATE_CREDENTIAL_ROUTINE ||
1331
+ routine.name === XAI_DISCONNECT_CREDENTIAL_ROUTINE ||
1332
+ routine.name === XAI_AUTHORITY_LIVE_ROUTINE ||
1333
+ routine.name === XAI_POOL_VISIBLE_ROUTINE ||
1334
+ routine.name === XAI_RESOLVE_POOL_ROUTINE ||
1335
+ routine.name === XAI_REVALIDATE_CREDENTIAL_ROUTINE
1336
+ ) {
1337
+ if (!tableByName.has("xai_subscription_credentials")) {
1338
+ continue;
1339
+ }
1340
+ const missingAuthorityTables = XAI_AUTHORITY_TABLES.filter(
1341
+ (tableName) => !tableByName.has(tableName),
1342
+ );
1343
+ if (missingAuthorityTables.length > 0) {
1344
+ violations.push(
1345
+ `target-schema runtime capability ${routine.name} authority tables are missing: ${missingAuthorityTables.join(", ")}`,
1346
+ );
1347
+ } else {
1348
+ const authorityTables = XAI_AUTHORITY_TABLES.map(
1349
+ (tableName) => tableByName.get(tableName)!,
1350
+ );
1351
+ const authorityOwners = new Set(authorityTables.map((table) => table.owner));
1352
+ if (authorityOwners.size !== 1) {
1353
+ violations.push(
1354
+ `target-schema runtime capability ${routine.name} authority table owners do not match: ${authorityTables.map((table) => `${table.name}=${table.owner}`).join(", ")}`,
1355
+ );
1356
+ } else if (routine.owner !== authorityTables[0]!.owner) {
1357
+ violations.push(
1358
+ `target-schema runtime capability ${routine.name} owner ${routine.owner} does not match authority table owner ${authorityTables[0]!.owner}`,
1359
+ );
1360
+ }
1361
+ }
1362
+ } else if (targetSchemaOwner && routine.owner !== targetSchemaOwner) {
1363
+ violations.push(
1364
+ `target-schema runtime capability ${routine.name} owner ${routine.owner} does not match schema owner ${targetSchemaOwner}`,
1365
+ );
1366
+ }
1367
+ if (!routine.execute) {
1368
+ violations.push(`runtime role lacks target-schema capability ${routine.name}`);
1369
+ }
1370
+ if (routine.publicExecute) {
1371
+ violations.push(`PUBLIC has forbidden target-schema capability ${routine.name}`);
1372
+ }
1373
+ }
1374
+
1375
+ const artifactOutbox = tableByName.get("editable_artifact_live_outbox");
1376
+ if (artifactOutbox) {
1377
+ if (!artifactOutbox.artifactOutboxDispatcherPolicy) {
1378
+ violations.push("table editable_artifact_live_outbox lacks its owner dispatcher RLS policy");
1379
+ }
1380
+ for (const expectedRoutine of ARTIFACT_OUTBOX_CAPABILITY_ROUTINES) {
1381
+ const matches = posture.privateRoutines.filter((routine) => routine.name === expectedRoutine);
1382
+ if (matches.length !== 1) {
1383
+ violations.push(`artifact outbox capability ${expectedRoutine} is missing or ambiguous`);
1384
+ continue;
1385
+ }
1386
+ const routine = matches[0]!;
1387
+ if (!routine.securityDefiner) {
1388
+ violations.push(`artifact outbox capability ${routine.name} is not SECURITY DEFINER`);
1389
+ }
1390
+ if (routine.owner !== artifactOutbox.owner) {
1391
+ violations.push(
1392
+ `artifact outbox capability ${routine.name} owner ${routine.owner} does not match table owner ${artifactOutbox.owner}`,
1393
+ );
1394
+ }
1395
+ if (routine.execute) {
1396
+ violations.push(
1397
+ `generic runtime role has forbidden global artifact outbox capability ${routine.name}`,
1398
+ );
1399
+ }
1400
+ }
1401
+ }
1402
+
1403
+ const artifactMaterializationJobs = tableByName.get("editable_artifact_materialization_jobs");
1404
+ if (artifactMaterializationJobs) {
1405
+ for (const tableName of [
1406
+ "editable_artifact_materialization_jobs",
1407
+ "editable_artifact_materialization_results",
1408
+ "editable_artifact_blob_refs",
1409
+ "editable_artifact_sequence_checkpoints",
1410
+ "editable_artifact_versions",
1411
+ "editable_artifact_idempotency_receipts",
1412
+ ]) {
1413
+ const table = tableByName.get(tableName);
1414
+ if (table && !table.artifactMaterializerPolicy) {
1415
+ violations.push(`table ${tableName} lacks its owner materializer RLS policy`);
1416
+ }
1417
+ }
1418
+ for (const expectedRoutine of ARTIFACT_MATERIALIZER_CAPABILITY_ROUTINES) {
1419
+ const matches = posture.privateRoutines.filter((routine) => routine.name === expectedRoutine);
1420
+ if (matches.length !== 1) {
1421
+ violations.push(
1422
+ `artifact materializer capability ${expectedRoutine} is missing or ambiguous`,
1423
+ );
1424
+ continue;
1425
+ }
1426
+ const routine = matches[0]!;
1427
+ if (!routine.securityDefiner) {
1428
+ violations.push(`artifact materializer capability ${routine.name} is not SECURITY DEFINER`);
1429
+ }
1430
+ if (routine.owner !== artifactMaterializationJobs.owner) {
1431
+ violations.push(
1432
+ `artifact materializer capability ${routine.name} owner ${routine.owner} does not match table owner ${artifactMaterializationJobs.owner}`,
1433
+ );
1434
+ }
1435
+ if (routine.execute) {
1436
+ violations.push(
1437
+ `generic runtime role has forbidden global artifact materializer capability ${routine.name}`,
1438
+ );
1439
+ }
1440
+ }
1441
+ }
1442
+ const artifactAuthority = tableByName.get("editable_artifacts");
1443
+ if (artifactAuthority) {
1444
+ const matches = posture.privateRoutines.filter((routine) =>
1445
+ routine.name.startsWith("advance_editable_artifact_authorization_revision("),
1446
+ );
1447
+ if (matches.length !== 1) {
1448
+ violations.push(
1449
+ "editable artifact authorization revision capability is missing or ambiguous",
1450
+ );
1451
+ } else {
1452
+ const routine = matches[0]!;
1453
+ if (!routine.securityDefiner) {
1454
+ violations.push(
1455
+ `editable artifact authorization revision capability ${routine.name} is not SECURITY DEFINER`,
1456
+ );
1457
+ }
1458
+ if (routine.owner !== artifactAuthority.owner) {
1459
+ violations.push(
1460
+ `editable artifact authorization revision capability ${routine.name} owner ${routine.owner} does not match table owner ${artifactAuthority.owner}`,
1461
+ );
1462
+ }
1463
+ }
1464
+ for (const expectedRoutine of ARTIFACT_AUTHORIZATION_CAPABILITY_ROUTINES) {
1465
+ const capabilityMatches = posture.privateRoutines.filter(
1466
+ (routine) => routine.name === expectedRoutine,
1467
+ );
1468
+ if (capabilityMatches.length !== 1) {
1469
+ violations.push(
1470
+ `editable artifact authorization capability ${expectedRoutine} is missing or ambiguous`,
1471
+ );
1472
+ continue;
1473
+ }
1474
+ const routine = capabilityMatches[0]!;
1475
+ if (!routine.securityDefiner) {
1476
+ violations.push(
1477
+ `editable artifact authorization capability ${routine.name} is not SECURITY DEFINER`,
1478
+ );
1479
+ }
1480
+ if (routine.owner !== artifactAuthority.owner) {
1481
+ violations.push(
1482
+ `editable artifact authorization capability ${routine.name} owner ${routine.owner} does not match table owner ${artifactAuthority.owner}`,
1483
+ );
1484
+ }
1485
+ if (!routine.execute) {
1486
+ violations.push(
1487
+ `runtime role lacks editable artifact authorization capability ${routine.name}`,
1488
+ );
1489
+ }
1490
+ }
1491
+ }
1492
+
1493
+ const artifactLiveTickets = tableByName.get("editable_artifact_live_tickets");
1494
+ if (artifactLiveTickets) {
1495
+ for (const expectedRoutine of ARTIFACT_LIVE_TICKET_CAPABILITY_ROUTINES) {
1496
+ const matches = posture.privateRoutines.filter((routine) => routine.name === expectedRoutine);
1497
+ if (matches.length !== 1) {
1498
+ violations.push(
1499
+ `artifact live ticket capability ${expectedRoutine} is missing or ambiguous`,
1500
+ );
1501
+ continue;
1502
+ }
1503
+ const routine = matches[0]!;
1504
+ if (!routine.securityDefiner) {
1505
+ violations.push(`artifact live ticket capability ${routine.name} is not SECURITY DEFINER`);
1506
+ }
1507
+ if (routine.owner !== artifactLiveTickets.owner) {
1508
+ violations.push(
1509
+ `artifact live ticket capability ${routine.name} owner ${routine.owner} does not match table owner ${artifactLiveTickets.owner}`,
1510
+ );
1511
+ }
1512
+ if (!routine.execute) {
1513
+ violations.push(`runtime role lacks artifact live ticket capability ${routine.name}`);
1514
+ }
1515
+ }
1516
+ for (const internalRoutine of ARTIFACT_LIVE_TICKET_INTERNAL_ROUTINES) {
1517
+ const matches = posture.privateRoutines.filter((routine) => routine.name === internalRoutine);
1518
+ if (matches.length !== 1) {
1519
+ violations.push(
1520
+ `artifact live ticket internal routine ${internalRoutine} is missing or ambiguous`,
1521
+ );
1522
+ continue;
1523
+ }
1524
+ const routine = matches[0]!;
1525
+ if (!routine.securityDefiner) {
1526
+ violations.push(
1527
+ `artifact live ticket internal routine ${routine.name} is not SECURITY DEFINER`,
1528
+ );
1529
+ }
1530
+ if (routine.owner !== artifactLiveTickets.owner) {
1531
+ violations.push(
1532
+ `artifact live ticket internal routine ${routine.name} owner ${routine.owner} does not match table owner ${artifactLiveTickets.owner}`,
1533
+ );
1534
+ }
1535
+ if (routine.execute) {
1536
+ violations.push(`runtime role has forbidden ticket schema resolver ${routine.name}`);
1537
+ }
1538
+ }
1539
+ }
1540
+
826
1541
  if (posture.privateRoutines.length === 0) {
827
1542
  violations.push("opengeni_private has no helper routines");
828
1543
  }
@@ -830,7 +1545,8 @@ export function evaluateRuntimeDatabasePosture(
830
1545
  if (routine.owner === expectedRole) {
831
1546
  violations.push(`runtime role owns private routine ${routine.name}`);
832
1547
  }
833
- if (!routine.execute) {
1548
+ const dedicatedArtifactCapability = DEDICATED_ARTIFACT_CAPABILITY_ROUTINES.has(routine.name);
1549
+ if (!routine.execute && !dedicatedArtifactCapability) {
834
1550
  violations.push(`runtime role lacks EXECUTE on private routine ${routine.name}`);
835
1551
  }
836
1552
  }