@opengeni/db 0.28.9 → 0.31.1

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 (163) 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 +91 -0
  4. package/dist/browser-identities.d.ts +128 -0
  5. package/dist/browser-sessions.d.ts +272 -0
  6. package/dist/browser-state-artifacts.d.ts +17 -0
  7. package/dist/capability-components.d.ts +37 -0
  8. package/dist/capability-integrations.d.ts +192 -0
  9. package/dist/chunk-F5FT7BEZ.js +3535 -0
  10. package/dist/chunk-F5FT7BEZ.js.map +1 -0
  11. package/dist/chunk-ISI2TIUG.js +639 -0
  12. package/dist/chunk-ISI2TIUG.js.map +1 -0
  13. package/dist/chunk-MWDVXQOL.js +11639 -0
  14. package/dist/chunk-MWDVXQOL.js.map +1 -0
  15. package/dist/chunk-NBE6CHRI.js +955 -0
  16. package/dist/chunk-NBE6CHRI.js.map +1 -0
  17. package/dist/{chunk-VHBFHMPC.js → chunk-YHZXQ7HP.js} +754 -11
  18. package/dist/chunk-YHZXQ7HP.js.map +1 -0
  19. package/dist/codemode-operations.d.ts +117 -0
  20. package/dist/codex-token-resolver.d.ts +2 -2
  21. package/dist/company-profile-schema.d.ts +798 -0
  22. package/dist/company-profile.d.ts +268 -0
  23. package/dist/computer-sessions.d.ts +109 -0
  24. package/dist/connection-token-resolver.d.ts +9 -4
  25. package/dist/database.d.ts +52 -3
  26. package/dist/editable-artifact-durable-export.d.ts +153 -0
  27. package/dist/editable-artifact-durable-export.js +788 -0
  28. package/dist/editable-artifact-durable-export.js.map +1 -0
  29. package/dist/editable-artifact-materialization.d.ts +123 -0
  30. package/dist/editable-artifacts-schema.d.ts +4152 -0
  31. package/dist/editable-artifacts.d.ts +610 -0
  32. package/dist/editable-artifacts.js +26 -0
  33. package/dist/editable-artifacts.js.map +1 -0
  34. package/dist/generated-images.d.ts +139 -0
  35. package/dist/index.d.ts +698 -111
  36. package/dist/index.js +27573 -10322
  37. package/dist/index.js.map +1 -1
  38. package/dist/insights.d.ts +51 -4
  39. package/dist/integration-bindings.d.ts +70 -0
  40. package/dist/integration-features.d.ts +99 -0
  41. package/dist/interaction-revisions.d.ts +3 -0
  42. package/dist/interaction-schema.d.ts +5372 -0
  43. package/dist/knowledge-source-sync-schema.d.ts +1679 -0
  44. package/dist/knowledge-source-sync.d.ts +274 -0
  45. package/dist/memory-governance.d.ts +2 -2
  46. package/dist/memory-slack-delivery.d.ts +101 -0
  47. package/dist/new-session-drafts.d.ts +2 -2
  48. package/dist/pack-components.d.ts +76 -0
  49. package/dist/pack-installations.d.ts +86 -0
  50. package/dist/persistence-errors.d.ts +3 -3
  51. package/dist/plugin-packages.d.ts +126 -0
  52. package/dist/preference-registry.d.ts +1 -1
  53. package/dist/provision-roles.d.ts +9 -1
  54. package/dist/provision-roles.js +1 -1
  55. package/dist/runtime-posture.d.ts +18 -6
  56. package/dist/schema.d.ts +18342 -9099
  57. package/dist/schema.js +165 -1
  58. package/dist/scoped-knowledge.d.ts +97 -1
  59. package/dist/session-control.d.ts +4 -4
  60. package/dist/session-queue-commands.d.ts +19 -11
  61. package/dist/session-realtime-context.d.ts +2 -2
  62. package/dist/session-realtime-ledger.d.ts +4 -4
  63. package/dist/session-realtime-mirror.d.ts +2 -2
  64. package/dist/session-realtime-state.d.ts +1 -1
  65. package/dist/session-realtime-terminal.d.ts +1 -1
  66. package/dist/session-realtime.d.ts +7 -7
  67. package/dist/session-tool-call-settlement.d.ts +1 -1
  68. package/dist/slack-user-link-access.d.ts +54 -0
  69. package/dist/transcription-recordings.d.ts +2 -2
  70. package/dist/turn-initiator.d.ts +2 -2
  71. package/dist/video-generation.d.ts +216 -0
  72. package/dist/video-generation.js +66 -0
  73. package/dist/video-generation.js.map +1 -0
  74. package/dist/workspace-artifacts.d.ts +1 -1
  75. package/dist/workspace-instruction-policies.d.ts +1 -1
  76. package/dist/workspace-learning-policy-schema.d.ts +932 -0
  77. package/dist/workspace-learning-policy.d.ts +161 -0
  78. package/drizzle/0183_model_call_provider_cost_estimates.sql +39 -0
  79. package/drizzle/0184_sandbox_drain_teardown_fence.sql +682 -0
  80. package/drizzle/0185_temporal_schedule_cleanup_outbox.sql +168 -0
  81. package/drizzle/0186_sandbox_capture_provider_contract.sql +400 -0
  82. package/drizzle/0187_generated_image_artifacts.sql +173 -0
  83. package/drizzle/0188_image_generation_retention_failure.sql +25 -0
  84. package/drizzle/0189_retained_session_image_formats.sql +13 -0
  85. package/drizzle/0190_timeline_annotations.sql +31 -0
  86. package/drizzle/0191_editable_artifact_engine.sql +3853 -0
  87. package/drizzle/0192_editable_artifact_live_tickets.sql +338 -0
  88. package/drizzle/0193_editable_artifact_authorization.sql +190 -0
  89. package/drizzle/0194_editable_artifact_durable_exports.sql +160 -0
  90. package/drizzle/0195_editable_artifact_import_authorization.sql +203 -0
  91. package/drizzle/0196_rig_provider_images.sql +152 -0
  92. package/drizzle/0197_knowledge_source_sync_schedules.sql +523 -0
  93. package/drizzle/0198_memory_slack_publication_delivery.sql +393 -0
  94. package/drizzle/0199_workspace_learning_policy.sql +980 -0
  95. package/drizzle/0201_company_profile_authority.sql +849 -0
  96. package/drizzle/0202_document_index_checkpoints.sql +85 -0
  97. package/drizzle/0203_durable_video_generation.sql +353 -0
  98. package/drizzle/0204_video_generation_funding.sql +44 -0
  99. package/drizzle/0205_attempt_tool_catalogs.sql +230 -0
  100. package/drizzle/0206_browser_sessions.sql +646 -0
  101. package/drizzle/0207_browser_identities.sql +379 -0
  102. package/drizzle/0208_attached_browser_devices.sql +165 -0
  103. package/drizzle/0209_computer_sessions.sql +575 -0
  104. package/drizzle/0210_browser_auth_network_interventions.sql +441 -0
  105. package/drizzle/0211_editable_artifact_session_links.sql +58 -0
  106. package/drizzle/0212_slack_installation_bindings.sql +348 -0
  107. package/drizzle/0213_slack_user_link_access_requests.sql +177 -0
  108. package/drizzle/0214_session_activity_commit_gate.sql +262 -0
  109. package/drizzle/0215_capabilities_platform.sql +980 -0
  110. package/drizzle/0216_pack_component_ownership.sql +235 -0
  111. package/drizzle/0217_capability_definition_delete_authority.sql +32 -0
  112. package/package.json +18 -5
  113. package/src/attached-browser-devices.ts +371 -0
  114. package/src/attempt-tool-catalogs.ts +131 -0
  115. package/src/browser-auth.ts +1896 -0
  116. package/src/browser-identities.ts +1168 -0
  117. package/src/browser-sessions.ts +2005 -0
  118. package/src/browser-state-artifacts.ts +59 -0
  119. package/src/capability-components.ts +166 -0
  120. package/src/capability-integrations.ts +1663 -0
  121. package/src/codemode-operations.ts +674 -0
  122. package/src/company-profile-schema.ts +143 -0
  123. package/src/company-profile.ts +968 -0
  124. package/src/computer-sessions.ts +1130 -0
  125. package/src/connection-token-resolver.ts +270 -25
  126. package/src/database.ts +427 -23
  127. package/src/editable-artifact-durable-export.ts +1201 -0
  128. package/src/editable-artifact-materialization.ts +893 -0
  129. package/src/editable-artifacts-schema.ts +879 -0
  130. package/src/editable-artifacts.ts +5404 -0
  131. package/src/generated-images.ts +740 -0
  132. package/src/index.ts +5917 -1182
  133. package/src/insights.ts +160 -13
  134. package/src/integration-bindings.ts +455 -0
  135. package/src/integration-features.ts +859 -0
  136. package/src/interaction-revisions.ts +40 -0
  137. package/src/interaction-schema.ts +1303 -0
  138. package/src/knowledge-source-sync-schema.ts +192 -0
  139. package/src/knowledge-source-sync.ts +1922 -0
  140. package/src/memory-slack-delivery.ts +801 -0
  141. package/src/pack-components.ts +954 -0
  142. package/src/pack-installations.ts +929 -0
  143. package/src/persistence-errors.ts +4 -7
  144. package/src/plugin-packages.ts +1186 -0
  145. package/src/provision-roles.ts +302 -1
  146. package/src/runtime-posture-cli.ts +9 -0
  147. package/src/runtime-posture.ts +508 -5
  148. package/src/schema.ts +5117 -3119
  149. package/src/scoped-knowledge-schema.ts +1 -1
  150. package/src/scoped-knowledge.ts +655 -3
  151. package/src/session-control.ts +8 -5
  152. package/src/session-queue-commands.ts +187 -14
  153. package/src/session-realtime-context.ts +2 -2
  154. package/src/session-realtime-ledger.ts +3 -3
  155. package/src/session-realtime.ts +7 -7
  156. package/src/session-tool-call-settlement.ts +9 -0
  157. package/src/slack-user-link-access.ts +702 -0
  158. package/src/video-generation.ts +1452 -0
  159. package/src/workspace-learning-policy-schema.ts +139 -0
  160. package/src/workspace-learning-policy.ts +595 -0
  161. package/dist/chunk-P6CUHXQZ.js +0 -7248
  162. package/dist/chunk-P6CUHXQZ.js.map +0 -1
  163. package/dist/chunk-VHBFHMPC.js.map +0 -1
@@ -89,20 +89,85 @@ function classifyRoleRelationships(rows) {
89
89
  }
90
90
 
91
91
  // src/runtime-posture.ts
92
+ var ARTIFACT_OUTBOX_CAPABILITY_ROUTINES = [
93
+ "claim_editable_artifact_live_outbox(text, integer, integer, name)",
94
+ "mark_editable_artifact_live_outbox_published(text, text, integer, name)",
95
+ "renew_editable_artifact_live_outbox(text, text, integer, integer, name)",
96
+ "retry_editable_artifact_live_outbox(text, text, integer, integer, text, name)",
97
+ "dead_letter_editable_artifact_live_outbox(text, text, integer, text, name)",
98
+ "release_editable_artifact_live_outbox(text, text, integer, name)"
99
+ ];
100
+ var ARTIFACT_MATERIALIZER_CAPABILITY_ROUTINES = [
101
+ "claim_editable_artifact_materializations(text, integer, integer, name)",
102
+ "renew_editable_artifact_materialization(uuid, uuid, text, text, text, integer, integer, name)",
103
+ "succeed_editable_artifact_materialization(uuid, uuid, text, text, text, integer, text, text, text, bigint, text, text, timestamp with time zone, name)",
104
+ "fail_editable_artifact_materialization(uuid, uuid, text, text, text, integer, text, name)"
105
+ ];
106
+ var ARTIFACT_LIVE_TICKET_CAPABILITY_ROUTINES = [
107
+ "put_editable_artifact_live_ticket(text, uuid, uuid, text, text, text, text, text, text, text, text, integer, text, boolean, integer, timestamp with time zone, timestamp with time zone, name)",
108
+ "consume_editable_artifact_live_ticket(text, name)",
109
+ "cleanup_expired_editable_artifact_live_tickets(integer, name)"
110
+ ];
111
+ var ARTIFACT_LIVE_TICKET_INTERNAL_ROUTINES = [
112
+ "resolve_editable_artifact_ticket_data_schema(name)"
113
+ ];
114
+ var ARTIFACT_AUTHORIZATION_CAPABILITY_ROUTINES = [
115
+ "authorize_editable_artifact_actor(uuid, uuid, text, text, text, text, text, text, integer, text, text, name)"
116
+ ];
117
+ var DEDICATED_ARTIFACT_CAPABILITY_ROUTINES = /* @__PURE__ */ new Set([
118
+ ...ARTIFACT_OUTBOX_CAPABILITY_ROUTINES,
119
+ ...ARTIFACT_MATERIALIZER_CAPABILITY_ROUTINES,
120
+ ...ARTIFACT_LIVE_TICKET_INTERNAL_ROUTINES
121
+ ]);
122
+ var KNOWLEDGE_SOURCE_SYNC_LOCK_AUTHORITY_ROUTINE = "knowledge_source_sync_lock_authority(uuid, uuid, uuid)";
123
+ var KNOWLEDGE_SOURCE_SYNC_LOCK_AUTHORITY_TABLES = [
124
+ "knowledge_sources",
125
+ "knowledge_source_objects"
126
+ ];
127
+ var RUNTIME_TARGET_SCHEMA_CAPABILITY_ROUTINES = [
128
+ KNOWLEDGE_SOURCE_SYNC_LOCK_AUTHORITY_ROUTINE
129
+ ];
92
130
  var FORCE_RLS_TABLES = [
93
131
  "agent_run_states",
94
132
  "api_keys",
133
+ "attached_browser_devices",
134
+ "attached_browser_inventories",
95
135
  "audit_events",
136
+ "auth_runs",
96
137
  "billing_customers",
138
+ "browser_identities",
139
+ "browser_revision_components",
140
+ "browser_revisions",
141
+ "browser_session_associations",
142
+ "browser_sessions",
143
+ "browser_state_artifacts",
144
+ "capability_api_facets",
97
145
  "capability_catalog_items",
146
+ "capability_component_owners",
147
+ "capability_facet_installations",
148
+ "capability_facets",
98
149
  "capability_installations",
150
+ "capability_integration_facets",
151
+ "capability_mcp_facets",
152
+ "capability_operations",
153
+ "capability_plugin_installations",
154
+ "capability_plugin_versions",
155
+ "capability_plugins",
156
+ "capability_skill_facets",
157
+ "capability_skill_files",
99
158
  "codex_apps_settings",
100
159
  "codex_capacity_waiters",
101
160
  "codex_credential_leases",
102
161
  "codex_reset_redemption_attempts",
103
162
  "codex_rotation_settings",
104
163
  "codex_subscription_credentials",
164
+ "company_profile_activation_events",
165
+ "company_profile_heads",
166
+ "company_profile_revisions",
167
+ "company_profile_snapshots",
105
168
  "composer_drafts",
169
+ "computer_session_associations",
170
+ "computer_sessions",
106
171
  "connection_disconnect_operations",
107
172
  "connections",
108
173
  "connector_action_policies",
@@ -112,9 +177,27 @@ var FORCE_RLS_TABLES = [
112
177
  "document_bases",
113
178
  "document_chunks",
114
179
  "documents",
180
+ "editable_artifact_blob_refs",
181
+ "editable_artifact_idempotency_receipts",
182
+ "editable_artifact_live_outbox",
183
+ "editable_artifact_live_tickets",
184
+ "editable_artifact_materialization_jobs",
185
+ "editable_artifact_materialization_results",
186
+ "editable_artifact_operations",
187
+ "editable_artifact_replica_leases",
188
+ "editable_artifact_scope_authorization_heads",
189
+ "editable_artifact_sequence_checkpoints",
190
+ "editable_artifact_session_links",
191
+ "editable_artifact_snapshots",
192
+ "editable_artifact_transactions",
193
+ "editable_artifact_undo_claims",
194
+ "editable_artifact_versions",
195
+ "editable_artifacts",
115
196
  "enrollments",
116
197
  "file_uploads",
117
198
  "files",
199
+ "generated_image_artifacts",
200
+ "generated_video_artifacts",
118
201
  "github_installation_repositories",
119
202
  "github_installations",
120
203
  "host_export_config",
@@ -122,8 +205,17 @@ var FORCE_RLS_TABLES = [
122
205
  "host_export_cursor_state",
123
206
  "host_export_dead_letters",
124
207
  "host_export_outbox",
208
+ "image_generation_operations",
125
209
  "import_batches",
210
+ "integration_feature_binding_owners",
211
+ "integration_feature_bindings",
212
+ "integration_feature_facets",
126
213
  "integration_oauth_state_nonces",
214
+ "integration_spec_revisions",
215
+ "integration_tools",
216
+ "interaction_interventions",
217
+ "interaction_operations",
218
+ "interaction_resource_operations",
127
219
  "knowledge_change_proposals",
128
220
  "knowledge_claim_evidence",
129
221
  "knowledge_claim_relations",
@@ -141,13 +233,23 @@ var FORCE_RLS_TABLES = [
141
233
  "knowledge_providers",
142
234
  "knowledge_source_acl_versions",
143
235
  "knowledge_source_objects",
236
+ "knowledge_source_sync_index_obligations",
237
+ "knowledge_source_sync_item_outcomes",
238
+ "knowledge_source_sync_object_observations",
239
+ "knowledge_source_sync_states",
240
+ "knowledge_source_sync_wakes",
144
241
  "knowledge_sources",
145
242
  "knowledge_sync_runs",
146
243
  "machine_metrics_latest",
147
244
  "machine_metrics_series",
148
245
  "machine_removal_operations",
246
+ "memory_slack_publication_configurations",
247
+ "memory_slack_publication_receipts",
248
+ "memory_slack_publications",
149
249
  "model_call_facts",
250
+ "network_routes",
150
251
  "new_session_drafts",
252
+ "pack_installation_components",
151
253
  "pack_installations",
152
254
  "preference_registry_events",
153
255
  "preference_registry_preferences",
@@ -167,7 +269,9 @@ var FORCE_RLS_TABLES = [
167
269
  "sandboxes",
168
270
  "scheduled_task_runs",
169
271
  "scheduled_tasks",
272
+ "session_attempt_codemode_calls",
170
273
  "session_attempt_interruptions",
274
+ "session_attempt_tool_catalogs",
171
275
  "session_command_receipts",
172
276
  "session_events",
173
277
  "session_goals",
@@ -190,19 +294,26 @@ var FORCE_RLS_TABLES = [
190
294
  "session_turns",
191
295
  "session_workflow_wake_outbox",
192
296
  "sessions",
297
+ "site_auth_connections",
193
298
  "slack_bot_delete_operations",
194
299
  "slack_bot_post_operations",
195
300
  "slack_bot_user_links",
301
+ "slack_installation_bindings",
196
302
  "slack_interaction_inbox",
197
303
  "slack_interaction_progress_deliveries",
198
304
  "slack_interactions",
305
+ "slack_user_link_access_request_operations",
306
+ "slack_user_link_access_requests",
199
307
  "social_connections",
200
308
  "social_posts",
309
+ "temporal_schedule_cleanup_outbox",
201
310
  "transcription_recording_chunks",
202
311
  "transcription_recording_objects",
203
312
  "transcription_recording_segments",
204
313
  "transcription_recordings",
205
314
  "usage_events",
315
+ "video_generation_operations",
316
+ "video_generation_references",
206
317
  "workspace_artifact_events",
207
318
  "workspace_artifact_versions",
208
319
  "workspace_artifacts",
@@ -214,12 +325,19 @@ var FORCE_RLS_TABLES = [
214
325
  "workspace_instruction_policy_onboarding_proposals",
215
326
  "workspace_instruction_policy_revisions",
216
327
  "workspace_instruction_policy_snapshots",
328
+ "workspace_interaction_revisions",
329
+ "workspace_learning_policy_activation_events",
330
+ "workspace_learning_policy_heads",
331
+ "workspace_learning_policy_revisions",
332
+ "workspace_learning_policy_snapshots",
217
333
  "workspace_model_policies",
218
334
  "workspace_packs",
219
335
  "workspace_screenshot_quotas",
220
336
  "workspace_session_activity_revisions",
221
337
  "workspace_variable_set_variables",
222
- "workspace_variable_sets"
338
+ "workspace_variable_sets",
339
+ "workspace_video_generation_policies",
340
+ "workspace_video_generation_quotas"
223
341
  ];
224
342
  var NON_RLS_RUNTIME_TABLES = [
225
343
  "auth_identities",
@@ -244,8 +362,13 @@ var RUNTIME_FULL_DML_TABLES = [
244
362
  "auth_users",
245
363
  "auth_verifications",
246
364
  "billing_customers",
365
+ "browser_session_associations",
247
366
  "capability_catalog_items",
367
+ "capability_component_owners",
368
+ "capability_facet_installations",
248
369
  "capability_installations",
370
+ "capability_operations",
371
+ "capability_plugin_installations",
249
372
  "codex_apps_settings",
250
373
  "codex_capacity_waiters",
251
374
  "codex_credential_leases",
@@ -253,6 +376,7 @@ var RUNTIME_FULL_DML_TABLES = [
253
376
  "codex_rotation_settings",
254
377
  "codex_subscription_credentials",
255
378
  "composer_drafts",
379
+ "computer_session_associations",
256
380
  "connection_disconnect_operations",
257
381
  "connections",
258
382
  "connector_action_policies",
@@ -262,21 +386,36 @@ var RUNTIME_FULL_DML_TABLES = [
262
386
  "document_bases",
263
387
  "document_chunks",
264
388
  "documents",
389
+ "editable_artifact_replica_leases",
265
390
  "enrollments",
266
391
  "file_uploads",
267
392
  "files",
393
+ "generated_image_artifacts",
394
+ "generated_video_artifacts",
268
395
  "github_installation_repositories",
269
396
  "github_installations",
397
+ "image_generation_operations",
270
398
  "import_batches",
399
+ "integration_feature_binding_owners",
400
+ "integration_feature_bindings",
271
401
  "integration_oauth_clients",
272
402
  "integration_oauth_state_nonces",
273
403
  "knowledge_memories",
404
+ "knowledge_source_sync_index_obligations",
405
+ "knowledge_source_sync_item_outcomes",
406
+ "knowledge_source_sync_object_observations",
407
+ "knowledge_source_sync_states",
408
+ "knowledge_source_sync_wakes",
274
409
  "machine_metrics_latest",
275
410
  "machine_metrics_series",
276
411
  "machine_removal_operations",
277
412
  "managed_accounts",
413
+ "memory_slack_publication_configurations",
414
+ "memory_slack_publication_receipts",
415
+ "memory_slack_publications",
278
416
  "model_call_facts",
279
417
  "new_session_drafts",
418
+ "pack_installation_components",
280
419
  "pack_installations",
281
420
  "retained_screenshot_artifacts",
282
421
  "rig_changes",
@@ -328,6 +467,8 @@ var RUNTIME_FULL_DML_TABLES = [
328
467
  "transcription_recording_segments",
329
468
  "transcription_recordings",
330
469
  "usage_events",
470
+ "video_generation_operations",
471
+ "video_generation_references",
331
472
  "workspace_artifacts",
332
473
  "workspace_captures",
333
474
  "workspace_control_events",
@@ -337,21 +478,44 @@ var RUNTIME_FULL_DML_TABLES = [
337
478
  "workspace_model_policies",
338
479
  "workspace_packs",
339
480
  "workspace_screenshot_quotas",
340
- "workspace_session_activity_revisions",
341
481
  "workspace_variable_set_variables",
342
482
  "workspace_variable_sets",
483
+ "workspace_video_generation_policies",
484
+ "workspace_video_generation_quotas",
343
485
  "workspaces"
344
486
  ];
345
487
  var RUNTIME_READ_ONLY_TABLES = [
488
+ "company_profile_activation_events",
489
+ "company_profile_heads",
490
+ "company_profile_snapshots",
346
491
  "knowledge_lifecycle_events",
347
492
  "knowledge_memory_lifecycle_events",
348
493
  "knowledge_memory_relationships",
349
494
  "nested_agent_depth_configuration",
350
495
  "preference_registry_events",
351
496
  "preference_registry_snapshots",
352
- "workspace_instruction_policy_snapshots"
497
+ "slack_installation_bindings",
498
+ "workspace_instruction_policy_snapshots",
499
+ "workspace_learning_policy_activation_events",
500
+ "workspace_learning_policy_heads",
501
+ "workspace_learning_policy_snapshots"
353
502
  ];
503
+ var RUNTIME_READ_UPDATE_TABLES = ["workspace_session_activity_revisions"];
354
504
  var RUNTIME_READ_INSERT_TABLES = [
505
+ "browser_revision_components",
506
+ "browser_revisions",
507
+ "company_profile_revisions",
508
+ "editable_artifact_blob_refs",
509
+ "editable_artifact_idempotency_receipts",
510
+ "editable_artifact_live_outbox",
511
+ "editable_artifact_materialization_jobs",
512
+ "editable_artifact_materialization_results",
513
+ "editable_artifact_operations",
514
+ "editable_artifact_sequence_checkpoints",
515
+ "editable_artifact_snapshots",
516
+ "editable_artifact_transactions",
517
+ "editable_artifact_undo_claims",
518
+ "editable_artifact_versions",
355
519
  "knowledge_change_proposals",
356
520
  "knowledge_claim_evidence",
357
521
  "knowledge_claim_relations",
@@ -369,14 +533,50 @@ var RUNTIME_READ_INSERT_TABLES = [
369
533
  "knowledge_sync_runs",
370
534
  "preference_registry_preferences",
371
535
  "preference_registry_revisions",
536
+ "session_attempt_tool_catalogs",
372
537
  "session_spawn_denials",
538
+ "slack_user_link_access_request_operations",
539
+ "temporal_schedule_cleanup_outbox",
373
540
  "workspace_artifact_events",
374
541
  "workspace_artifact_versions",
375
542
  "workspace_instruction_policy_activation_events",
376
543
  "workspace_instruction_policy_onboarding_proposals",
377
- "workspace_instruction_policy_revisions"
544
+ "workspace_instruction_policy_revisions",
545
+ "workspace_learning_policy_revisions"
546
+ ];
547
+ var RUNTIME_READ_INSERT_UPDATE_TABLES = [
548
+ "attached_browser_devices",
549
+ "attached_browser_inventories",
550
+ "auth_runs",
551
+ "browser_identities",
552
+ "browser_sessions",
553
+ "browser_state_artifacts",
554
+ "capability_api_facets",
555
+ "capability_facets",
556
+ "capability_integration_facets",
557
+ "capability_mcp_facets",
558
+ "capability_plugin_versions",
559
+ "capability_plugins",
560
+ "capability_skill_facets",
561
+ "capability_skill_files",
562
+ "computer_sessions",
563
+ "editable_artifact_session_links",
564
+ "editable_artifacts",
565
+ "integration_feature_facets",
566
+ "integration_spec_revisions",
567
+ "integration_tools",
568
+ "interaction_interventions",
569
+ "interaction_operations",
570
+ "interaction_resource_operations",
571
+ "network_routes",
572
+ "session_attempt_codemode_calls",
573
+ "site_auth_connections",
574
+ "slack_user_link_access_requests",
575
+ "workspace_interaction_revisions"
378
576
  ];
379
577
  var PROTECTED_NO_DIRECT_DML_TABLES = [
578
+ "editable_artifact_live_tickets",
579
+ "editable_artifact_scope_authorization_heads",
380
580
  "host_export_config",
381
581
  "host_export_consumers",
382
582
  "host_export_cursor_state",
@@ -387,8 +587,17 @@ var FULL_DML_PRIVILEGES = ["SELECT", "INSERT", "UPDATE", "DELETE"];
387
587
  var RUNTIME_TABLE_PRIVILEGES = Object.freeze({
388
588
  ...Object.fromEntries(RUNTIME_FULL_DML_TABLES.map((table) => [table, FULL_DML_PRIVILEGES])),
389
589
  ...Object.fromEntries(RUNTIME_READ_ONLY_TABLES.map((table) => [table, ["SELECT"]])),
590
+ ...Object.fromEntries(
591
+ RUNTIME_READ_UPDATE_TABLES.map((table) => [table, ["SELECT", "UPDATE"]])
592
+ ),
390
593
  ...Object.fromEntries(
391
594
  RUNTIME_READ_INSERT_TABLES.map((table) => [table, ["SELECT", "INSERT"]])
595
+ ),
596
+ ...Object.fromEntries(
597
+ RUNTIME_READ_INSERT_UPDATE_TABLES.map((table) => [
598
+ table,
599
+ ["SELECT", "INSERT", "UPDATE"]
600
+ ])
392
601
  )
393
602
  });
394
603
  var RUNTIME_DML_TABLES = Object.freeze(
@@ -470,6 +679,7 @@ async function inspectRuntimeDatabasePosture(db, options) {
470
679
  ownedSchemas: [],
471
680
  ownedRelations: [],
472
681
  tables: [],
682
+ targetRoutines: [],
473
683
  privateRoutines: []
474
684
  };
475
685
  }
@@ -522,6 +732,16 @@ async function inspectRuntimeDatabasePosture(db, options) {
522
732
  c.relforcerowsecurity as rls_forced,
523
733
  row_security_active(c.oid) as rls_active,
524
734
  (select count(*)::int from pg_policy policy where policy.polrelid = c.oid) as policy_count,
735
+ exists(
736
+ select 1 from pg_policy policy
737
+ where policy.polrelid = c.oid
738
+ and policy.polname = 'editable_artifact_outbox_dispatcher'
739
+ ) as artifact_outbox_dispatcher_policy,
740
+ exists(
741
+ select 1 from pg_policy policy
742
+ where policy.polrelid = c.oid
743
+ and policy.polname = 'editable_artifact_materializer_owner'
744
+ ) as artifact_materializer_policy,
525
745
  has_table_privilege(current_user, c.oid, 'SELECT') as can_select,
526
746
  has_table_privilege(current_user, c.oid, 'INSERT') as can_insert,
527
747
  has_table_privilege(current_user, c.oid, 'UPDATE') as can_update,
@@ -542,6 +762,8 @@ async function inspectRuntimeDatabasePosture(db, options) {
542
762
  rlsForced: row.rls_forced,
543
763
  rlsActive: row.rls_active,
544
764
  policyCount: row.policy_count,
765
+ artifactOutboxDispatcherPolicy: row.artifact_outbox_dispatcher_policy,
766
+ artifactMaterializerPolicy: row.artifact_materializer_policy,
545
767
  select: row.can_select,
546
768
  insert: row.can_insert,
547
769
  update: row.can_update,
@@ -550,22 +772,55 @@ async function inspectRuntimeDatabasePosture(db, options) {
550
772
  references: row.can_references,
551
773
  trigger: row.can_trigger
552
774
  }));
775
+ const targetRoutines = resultRows(
776
+ await tx.execute(sql`
777
+ select
778
+ (p.proname || '(' || pg_catalog.oidvectortypes(p.proargtypes) || ')')::text as name,
779
+ pg_get_userbyid(p.proowner)::text as owner,
780
+ has_function_privilege(current_user, p.oid, 'EXECUTE') as can_execute,
781
+ exists (
782
+ select 1
783
+ from aclexplode(coalesce(p.proacl, acldefault('f', p.proowner))) acl
784
+ where acl.grantee = 0 and acl.privilege_type = 'EXECUTE'
785
+ ) as public_execute,
786
+ p.prosecdef as security_definer
787
+ from pg_proc p
788
+ join pg_namespace n on n.oid = p.pronamespace
789
+ where p.oid = to_regprocedure(
790
+ format(
791
+ '%I.knowledge_source_sync_lock_authority(uuid,uuid,uuid)',
792
+ ${targetSchema}::text
793
+ )
794
+ )
795
+ and n.nspname = ${targetSchema}
796
+ and p.prokind in ('f', 'p')
797
+ order by p.proname, pg_catalog.oidvectortypes(p.proargtypes)
798
+ `)
799
+ ).map((row) => ({
800
+ name: row.name,
801
+ owner: row.owner,
802
+ execute: row.can_execute,
803
+ publicExecute: row.public_execute,
804
+ securityDefiner: row.security_definer
805
+ }));
553
806
  const privateRoutines = resultRows(
554
807
  await tx.execute(sql`
555
808
  select
556
- (p.proname || '(' || pg_get_function_identity_arguments(p.oid) || ')')::text as name,
809
+ (p.proname || '(' || pg_catalog.oidvectortypes(p.proargtypes) || ')')::text as name,
557
810
  pg_get_userbyid(p.proowner)::text as owner,
558
- has_function_privilege(current_user, p.oid, 'EXECUTE') as can_execute
811
+ has_function_privilege(current_user, p.oid, 'EXECUTE') as can_execute,
812
+ p.prosecdef as security_definer
559
813
  from pg_proc p
560
814
  join pg_namespace n on n.oid = p.pronamespace
561
815
  where n.nspname = 'opengeni_private'
562
816
  and p.prokind in ('f', 'p')
563
- order by p.proname, pg_get_function_identity_arguments(p.oid)
817
+ order by p.proname, pg_catalog.oidvectortypes(p.proargtypes)
564
818
  `)
565
819
  ).map((row) => ({
566
820
  name: row.name,
567
821
  owner: row.owner,
568
- execute: row.can_execute
822
+ execute: row.can_execute,
823
+ securityDefiner: row.security_definer
569
824
  }));
570
825
  return {
571
826
  identity: mappedIdentity,
@@ -574,6 +829,7 @@ async function inspectRuntimeDatabasePosture(db, options) {
574
829
  ownedSchemas,
575
830
  ownedRelations,
576
831
  tables,
832
+ targetRoutines,
577
833
  privateRoutines
578
834
  };
579
835
  },
@@ -724,6 +980,217 @@ function evaluateRuntimeDatabasePosture(posture, options) {
724
980
  if (!table.rlsActive) violations.push(`table ${tableName} has inactive RLS for runtime role`);
725
981
  if (table.policyCount < 1) violations.push(`table ${tableName} has no RLS policy`);
726
982
  }
983
+ const targetSchemaOwner = posture.schemas.find((schema) => schema.name === targetSchema)?.owner;
984
+ for (const expectedRoutine of RUNTIME_TARGET_SCHEMA_CAPABILITY_ROUTINES) {
985
+ const matches = posture.targetRoutines.filter((routine2) => routine2.name === expectedRoutine);
986
+ if (matches.length !== 1) {
987
+ violations.push(
988
+ `target-schema runtime capability ${expectedRoutine} is missing or ambiguous`
989
+ );
990
+ continue;
991
+ }
992
+ const routine = matches[0];
993
+ if (!routine.securityDefiner) {
994
+ violations.push(`target-schema runtime capability ${routine.name} is not SECURITY DEFINER`);
995
+ }
996
+ if (routine.name === KNOWLEDGE_SOURCE_SYNC_LOCK_AUTHORITY_ROUTINE) {
997
+ const missingAuthorityTables = KNOWLEDGE_SOURCE_SYNC_LOCK_AUTHORITY_TABLES.filter(
998
+ (tableName) => !tableByName.has(tableName)
999
+ );
1000
+ if (missingAuthorityTables.length > 0) {
1001
+ violations.push(
1002
+ `target-schema runtime capability ${routine.name} authority tables are missing: ${missingAuthorityTables.join(", ")}`
1003
+ );
1004
+ } else {
1005
+ const authorityTables = KNOWLEDGE_SOURCE_SYNC_LOCK_AUTHORITY_TABLES.map(
1006
+ (tableName) => tableByName.get(tableName)
1007
+ );
1008
+ const authorityOwners = new Set(authorityTables.map((table) => table.owner));
1009
+ if (authorityOwners.size !== 1) {
1010
+ violations.push(
1011
+ `target-schema runtime capability ${routine.name} authority table owners do not match: ${authorityTables.map((table) => `${table.name}=${table.owner}`).join(", ")}`
1012
+ );
1013
+ } else if (routine.owner !== authorityTables[0].owner) {
1014
+ violations.push(
1015
+ `target-schema runtime capability ${routine.name} owner ${routine.owner} does not match authority table owner ${authorityTables[0].owner}`
1016
+ );
1017
+ }
1018
+ }
1019
+ } else if (targetSchemaOwner && routine.owner !== targetSchemaOwner) {
1020
+ violations.push(
1021
+ `target-schema runtime capability ${routine.name} owner ${routine.owner} does not match schema owner ${targetSchemaOwner}`
1022
+ );
1023
+ }
1024
+ if (!routine.execute) {
1025
+ violations.push(`runtime role lacks target-schema capability ${routine.name}`);
1026
+ }
1027
+ if (routine.publicExecute) {
1028
+ violations.push(`PUBLIC has forbidden target-schema capability ${routine.name}`);
1029
+ }
1030
+ }
1031
+ const artifactOutbox = tableByName.get("editable_artifact_live_outbox");
1032
+ if (artifactOutbox) {
1033
+ if (!artifactOutbox.artifactOutboxDispatcherPolicy) {
1034
+ violations.push("table editable_artifact_live_outbox lacks its owner dispatcher RLS policy");
1035
+ }
1036
+ for (const expectedRoutine of ARTIFACT_OUTBOX_CAPABILITY_ROUTINES) {
1037
+ const matches = posture.privateRoutines.filter((routine2) => routine2.name === expectedRoutine);
1038
+ if (matches.length !== 1) {
1039
+ violations.push(`artifact outbox capability ${expectedRoutine} is missing or ambiguous`);
1040
+ continue;
1041
+ }
1042
+ const routine = matches[0];
1043
+ if (!routine.securityDefiner) {
1044
+ violations.push(`artifact outbox capability ${routine.name} is not SECURITY DEFINER`);
1045
+ }
1046
+ if (routine.owner !== artifactOutbox.owner) {
1047
+ violations.push(
1048
+ `artifact outbox capability ${routine.name} owner ${routine.owner} does not match table owner ${artifactOutbox.owner}`
1049
+ );
1050
+ }
1051
+ if (routine.execute) {
1052
+ violations.push(
1053
+ `generic runtime role has forbidden global artifact outbox capability ${routine.name}`
1054
+ );
1055
+ }
1056
+ }
1057
+ }
1058
+ const artifactMaterializationJobs = tableByName.get("editable_artifact_materialization_jobs");
1059
+ if (artifactMaterializationJobs) {
1060
+ for (const tableName of [
1061
+ "editable_artifact_materialization_jobs",
1062
+ "editable_artifact_materialization_results",
1063
+ "editable_artifact_blob_refs",
1064
+ "editable_artifact_sequence_checkpoints",
1065
+ "editable_artifact_versions",
1066
+ "editable_artifact_idempotency_receipts"
1067
+ ]) {
1068
+ const table = tableByName.get(tableName);
1069
+ if (table && !table.artifactMaterializerPolicy) {
1070
+ violations.push(`table ${tableName} lacks its owner materializer RLS policy`);
1071
+ }
1072
+ }
1073
+ for (const expectedRoutine of ARTIFACT_MATERIALIZER_CAPABILITY_ROUTINES) {
1074
+ const matches = posture.privateRoutines.filter((routine2) => routine2.name === expectedRoutine);
1075
+ if (matches.length !== 1) {
1076
+ violations.push(
1077
+ `artifact materializer capability ${expectedRoutine} is missing or ambiguous`
1078
+ );
1079
+ continue;
1080
+ }
1081
+ const routine = matches[0];
1082
+ if (!routine.securityDefiner) {
1083
+ violations.push(`artifact materializer capability ${routine.name} is not SECURITY DEFINER`);
1084
+ }
1085
+ if (routine.owner !== artifactMaterializationJobs.owner) {
1086
+ violations.push(
1087
+ `artifact materializer capability ${routine.name} owner ${routine.owner} does not match table owner ${artifactMaterializationJobs.owner}`
1088
+ );
1089
+ }
1090
+ if (routine.execute) {
1091
+ violations.push(
1092
+ `generic runtime role has forbidden global artifact materializer capability ${routine.name}`
1093
+ );
1094
+ }
1095
+ }
1096
+ }
1097
+ const artifactAuthority = tableByName.get("editable_artifacts");
1098
+ if (artifactAuthority) {
1099
+ const matches = posture.privateRoutines.filter(
1100
+ (routine) => routine.name.startsWith("advance_editable_artifact_authorization_revision(")
1101
+ );
1102
+ if (matches.length !== 1) {
1103
+ violations.push(
1104
+ "editable artifact authorization revision capability is missing or ambiguous"
1105
+ );
1106
+ } else {
1107
+ const routine = matches[0];
1108
+ if (!routine.securityDefiner) {
1109
+ violations.push(
1110
+ `editable artifact authorization revision capability ${routine.name} is not SECURITY DEFINER`
1111
+ );
1112
+ }
1113
+ if (routine.owner !== artifactAuthority.owner) {
1114
+ violations.push(
1115
+ `editable artifact authorization revision capability ${routine.name} owner ${routine.owner} does not match table owner ${artifactAuthority.owner}`
1116
+ );
1117
+ }
1118
+ }
1119
+ for (const expectedRoutine of ARTIFACT_AUTHORIZATION_CAPABILITY_ROUTINES) {
1120
+ const capabilityMatches = posture.privateRoutines.filter(
1121
+ (routine2) => routine2.name === expectedRoutine
1122
+ );
1123
+ if (capabilityMatches.length !== 1) {
1124
+ violations.push(
1125
+ `editable artifact authorization capability ${expectedRoutine} is missing or ambiguous`
1126
+ );
1127
+ continue;
1128
+ }
1129
+ const routine = capabilityMatches[0];
1130
+ if (!routine.securityDefiner) {
1131
+ violations.push(
1132
+ `editable artifact authorization capability ${routine.name} is not SECURITY DEFINER`
1133
+ );
1134
+ }
1135
+ if (routine.owner !== artifactAuthority.owner) {
1136
+ violations.push(
1137
+ `editable artifact authorization capability ${routine.name} owner ${routine.owner} does not match table owner ${artifactAuthority.owner}`
1138
+ );
1139
+ }
1140
+ if (!routine.execute) {
1141
+ violations.push(
1142
+ `runtime role lacks editable artifact authorization capability ${routine.name}`
1143
+ );
1144
+ }
1145
+ }
1146
+ }
1147
+ const artifactLiveTickets = tableByName.get("editable_artifact_live_tickets");
1148
+ if (artifactLiveTickets) {
1149
+ for (const expectedRoutine of ARTIFACT_LIVE_TICKET_CAPABILITY_ROUTINES) {
1150
+ const matches = posture.privateRoutines.filter((routine2) => routine2.name === expectedRoutine);
1151
+ if (matches.length !== 1) {
1152
+ violations.push(
1153
+ `artifact live ticket capability ${expectedRoutine} is missing or ambiguous`
1154
+ );
1155
+ continue;
1156
+ }
1157
+ const routine = matches[0];
1158
+ if (!routine.securityDefiner) {
1159
+ violations.push(`artifact live ticket capability ${routine.name} is not SECURITY DEFINER`);
1160
+ }
1161
+ if (routine.owner !== artifactLiveTickets.owner) {
1162
+ violations.push(
1163
+ `artifact live ticket capability ${routine.name} owner ${routine.owner} does not match table owner ${artifactLiveTickets.owner}`
1164
+ );
1165
+ }
1166
+ if (!routine.execute) {
1167
+ violations.push(`runtime role lacks artifact live ticket capability ${routine.name}`);
1168
+ }
1169
+ }
1170
+ for (const internalRoutine of ARTIFACT_LIVE_TICKET_INTERNAL_ROUTINES) {
1171
+ const matches = posture.privateRoutines.filter((routine2) => routine2.name === internalRoutine);
1172
+ if (matches.length !== 1) {
1173
+ violations.push(
1174
+ `artifact live ticket internal routine ${internalRoutine} is missing or ambiguous`
1175
+ );
1176
+ continue;
1177
+ }
1178
+ const routine = matches[0];
1179
+ if (!routine.securityDefiner) {
1180
+ violations.push(
1181
+ `artifact live ticket internal routine ${routine.name} is not SECURITY DEFINER`
1182
+ );
1183
+ }
1184
+ if (routine.owner !== artifactLiveTickets.owner) {
1185
+ violations.push(
1186
+ `artifact live ticket internal routine ${routine.name} owner ${routine.owner} does not match table owner ${artifactLiveTickets.owner}`
1187
+ );
1188
+ }
1189
+ if (routine.execute) {
1190
+ violations.push(`runtime role has forbidden ticket schema resolver ${routine.name}`);
1191
+ }
1192
+ }
1193
+ }
727
1194
  if (posture.privateRoutines.length === 0) {
728
1195
  violations.push("opengeni_private has no helper routines");
729
1196
  }
@@ -731,7 +1198,8 @@ function evaluateRuntimeDatabasePosture(posture, options) {
731
1198
  if (routine.owner === expectedRole) {
732
1199
  violations.push(`runtime role owns private routine ${routine.name}`);
733
1200
  }
734
- if (!routine.execute) {
1201
+ const dedicatedArtifactCapability = DEDICATED_ARTIFACT_CAPABILITY_ROUTINES.has(routine.name);
1202
+ if (!routine.execute && !dedicatedArtifactCapability) {
735
1203
  violations.push(`runtime role lacks EXECUTE on private routine ${routine.name}`);
736
1204
  }
737
1205
  }
@@ -760,6 +1228,16 @@ async function provisionRoles(adminConnection, options = {}) {
760
1228
  options.appRole ?? (process.env.OPENGENI_APP_DATABASE_USER?.trim() || "opengeni_app")
761
1229
  );
762
1230
  const appPassword = options.appPassword ?? process.env.OPENGENI_APP_DATABASE_PASSWORD;
1231
+ const artifactOutboxDispatcherRole = validateIdentifier(
1232
+ "artifactOutboxDispatcherRole",
1233
+ options.artifactOutboxDispatcherRole ?? (process.env.OPENGENI_ARTIFACT_OUTBOX_DATABASE_USER?.trim() || "opengeni_artifact_outbox_dispatcher")
1234
+ );
1235
+ const artifactOutboxDispatcherPassword = options.artifactOutboxDispatcherPassword ?? process.env.OPENGENI_ARTIFACT_OUTBOX_DATABASE_PASSWORD;
1236
+ const artifactMaterializerRole = validateIdentifier(
1237
+ "artifactMaterializerRole",
1238
+ options.artifactMaterializerRole ?? (process.env.OPENGENI_ARTIFACT_MATERIALIZER_DATABASE_USER?.trim() || "opengeni_artifact_materializer")
1239
+ );
1240
+ const artifactMaterializerPassword = options.artifactMaterializerPassword ?? process.env.OPENGENI_ARTIFACT_MATERIALIZER_DATABASE_PASSWORD;
763
1241
  const hostExportRole = validateIdentifier(
764
1242
  "hostExportRole",
765
1243
  options.hostExportRole ?? (process.env.OPENGENI_HOST_EXPORT_DATABASE_USER?.trim() || "opengeni_host_exporter")
@@ -784,6 +1262,38 @@ async function provisionRoles(adminConnection, options = {}) {
784
1262
  await ensureRestrictedAppLoginRole(sql2, appRole, appPassword);
785
1263
  provisionedAppRole = appRole;
786
1264
  }
1265
+ let provisionedArtifactOutboxDispatcherRole = null;
1266
+ if (artifactOutboxDispatcherPassword) {
1267
+ await assertAppRoleSafeToNormalize(sql2, artifactOutboxDispatcherRole);
1268
+ await ensureRestrictedAppLoginRole(
1269
+ sql2,
1270
+ artifactOutboxDispatcherRole,
1271
+ artifactOutboxDispatcherPassword
1272
+ );
1273
+ await grantArtifactCapabilityRoleIfSchemaExists(
1274
+ sql2,
1275
+ artifactOutboxDispatcherRole,
1276
+ schema,
1277
+ "outbox"
1278
+ );
1279
+ provisionedArtifactOutboxDispatcherRole = artifactOutboxDispatcherRole;
1280
+ }
1281
+ let provisionedArtifactMaterializerRole = null;
1282
+ if (artifactMaterializerPassword) {
1283
+ await assertAppRoleSafeToNormalize(sql2, artifactMaterializerRole);
1284
+ await ensureRestrictedAppLoginRole(
1285
+ sql2,
1286
+ artifactMaterializerRole,
1287
+ artifactMaterializerPassword
1288
+ );
1289
+ await grantArtifactCapabilityRoleIfSchemaExists(
1290
+ sql2,
1291
+ artifactMaterializerRole,
1292
+ schema,
1293
+ "materializer"
1294
+ );
1295
+ provisionedArtifactMaterializerRole = artifactMaterializerRole;
1296
+ }
787
1297
  if (temporalPassword) {
788
1298
  await ensureLoginRole(sql2, temporalRole, temporalPassword);
789
1299
  for (const database of temporalDatabases) {
@@ -800,6 +1310,8 @@ async function provisionRoles(adminConnection, options = {}) {
800
1310
  }
801
1311
  return {
802
1312
  appRole: provisionedAppRole,
1313
+ artifactOutboxDispatcherRole: provisionedArtifactOutboxDispatcherRole,
1314
+ artifactMaterializerRole: provisionedArtifactMaterializerRole,
803
1315
  hostExportRole: hostExportPassword ? hostExportRole : null,
804
1316
  temporalRole: temporalPassword ? temporalRole : null,
805
1317
  temporalDatabases: temporalPassword ? temporalDatabases : [],
@@ -822,6 +1334,55 @@ BEGIN
822
1334
  END $$;
823
1335
  `);
824
1336
  }
1337
+ async function grantArtifactCapabilityRoleIfSchemaExists(sql2, role, dataSchema, capability) {
1338
+ const routines = capability === "outbox" ? [
1339
+ "claim_editable_artifact_live_outbox(text,integer,integer,name)",
1340
+ "mark_editable_artifact_live_outbox_published(text,text,integer,name)",
1341
+ "renew_editable_artifact_live_outbox(text,text,integer,integer,name)",
1342
+ "retry_editable_artifact_live_outbox(text,text,integer,integer,text,name)",
1343
+ "dead_letter_editable_artifact_live_outbox(text,text,integer,text,name)",
1344
+ "release_editable_artifact_live_outbox(text,text,integer,name)"
1345
+ ] : [
1346
+ "claim_editable_artifact_materializations(text,integer,integer,name)",
1347
+ "renew_editable_artifact_materialization(uuid,uuid,text,text,text,integer,integer,name)",
1348
+ "succeed_editable_artifact_materialization(uuid,uuid,text,text,text,integer,text,text,text,bigint,text,text,timestamp with time zone,name)",
1349
+ "fail_editable_artifact_materialization(uuid,uuid,text,text,text,integer,text,name)"
1350
+ ];
1351
+ const routineArray = `ARRAY[${routines.map(literal).join(", ")}]`;
1352
+ await sql2.unsafe(`
1353
+ DO $$
1354
+ DECLARE routine_signature text;
1355
+ BEGIN
1356
+ IF EXISTS (SELECT 1 FROM pg_namespace WHERE nspname = ${literal(dataSchema)})
1357
+ AND EXISTS (SELECT 1 FROM pg_namespace WHERE nspname = 'opengeni_private')
1358
+ THEN
1359
+ EXECUTE format('GRANT CONNECT ON DATABASE %I TO %I', current_database(), ${literal(role)});
1360
+ EXECUTE format('GRANT USAGE ON SCHEMA %I TO %I', ${literal(dataSchema)}, ${literal(role)});
1361
+ EXECUTE format('GRANT USAGE ON SCHEMA opengeni_private TO %I', ${literal(role)});
1362
+ EXECUTE format(
1363
+ 'REVOKE ALL PRIVILEGES ON ALL TABLES IN SCHEMA %I FROM %I',
1364
+ ${literal(dataSchema)}, ${literal(role)}
1365
+ );
1366
+ EXECUTE format(
1367
+ 'REVOKE ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA %I FROM %I',
1368
+ ${literal(dataSchema)}, ${literal(role)}
1369
+ );
1370
+ EXECUTE format(
1371
+ 'REVOKE ALL PRIVILEGES ON ALL FUNCTIONS IN SCHEMA opengeni_private FROM %I',
1372
+ ${literal(role)}
1373
+ );
1374
+ FOREACH routine_signature IN ARRAY ${routineArray} LOOP
1375
+ IF to_regprocedure('opengeni_private.' || routine_signature) IS NOT NULL THEN
1376
+ EXECUTE format(
1377
+ 'GRANT EXECUTE ON FUNCTION opengeni_private.%s TO %I',
1378
+ routine_signature, ${literal(role)}
1379
+ );
1380
+ END IF;
1381
+ END LOOP;
1382
+ END IF;
1383
+ END $$;
1384
+ `);
1385
+ }
825
1386
  async function ensureLoginRole(sql2, role, password) {
826
1387
  await sql2.unsafe(`
827
1388
  DO $$
@@ -968,7 +1529,9 @@ async function grantTemporalRoleInDatabase(adminConnection, database, role) {
968
1529
  async function grantAppRoleIfSchemaExists(sql2, role, schema) {
969
1530
  const runtimeFullDmlTables = `ARRAY[${RUNTIME_FULL_DML_TABLES.map(literal).join(", ")}]`;
970
1531
  const runtimeReadOnlyTables = `ARRAY[${RUNTIME_READ_ONLY_TABLES.map(literal).join(", ")}]`;
1532
+ const runtimeReadUpdateTables = `ARRAY[${RUNTIME_READ_UPDATE_TABLES.map(literal).join(", ")}]`;
971
1533
  const runtimeReadInsertTables = `ARRAY[${RUNTIME_READ_INSERT_TABLES.map(literal).join(", ")}]`;
1534
+ const runtimeReadInsertUpdateTables = `ARRAY[${RUNTIME_READ_INSERT_UPDATE_TABLES.map(literal).join(", ")}]`;
972
1535
  await sql2.unsafe(`
973
1536
  DO $$
974
1537
  DECLARE
@@ -1000,6 +1563,16 @@ BEGIN
1000
1563
  );
1001
1564
  END IF;
1002
1565
  END LOOP;
1566
+ FOREACH runtime_table IN ARRAY ${runtimeReadUpdateTables} LOOP
1567
+ IF to_regclass(format('%I.%I', ${literal(schema)}, runtime_table)) IS NOT NULL THEN
1568
+ EXECUTE format(
1569
+ 'GRANT SELECT, UPDATE ON TABLE %I.%I TO %I',
1570
+ ${literal(schema)},
1571
+ runtime_table,
1572
+ ${literal(role)}
1573
+ );
1574
+ END IF;
1575
+ END LOOP;
1003
1576
  FOREACH runtime_table IN ARRAY ${runtimeReadInsertTables} LOOP
1004
1577
  IF to_regclass(format('%I.%I', ${literal(schema)}, runtime_table)) IS NOT NULL THEN
1005
1578
  EXECUTE format(
@@ -1010,6 +1583,16 @@ BEGIN
1010
1583
  );
1011
1584
  END IF;
1012
1585
  END LOOP;
1586
+ FOREACH runtime_table IN ARRAY ${runtimeReadInsertUpdateTables} LOOP
1587
+ IF to_regclass(format('%I.%I', ${literal(schema)}, runtime_table)) IS NOT NULL THEN
1588
+ EXECUTE format(
1589
+ 'GRANT SELECT, INSERT, UPDATE ON TABLE %I.%I TO %I',
1590
+ ${literal(schema)},
1591
+ runtime_table,
1592
+ ${literal(role)}
1593
+ );
1594
+ END IF;
1595
+ END LOOP;
1013
1596
  -- Migration 0110 creates this target-schema-local SECURITY DEFINER
1014
1597
  -- capability before opengeni_app may exist. Re-converge its exact EXECUTE
1015
1598
  -- grant here so the supported migrate-then-provision order is equivalent to
@@ -1092,6 +1675,72 @@ BEGIN
1092
1675
  ${literal(role)}
1093
1676
  );
1094
1677
  END IF;
1678
+ IF to_regprocedure(
1679
+ format(
1680
+ '%I.company_profile_apply_activation(uuid,text,uuid,uuid,uuid,uuid,bigint,text,text,text,text)',
1681
+ ${literal(schema)}
1682
+ )
1683
+ ) IS NOT NULL THEN
1684
+ EXECUTE format(
1685
+ 'GRANT EXECUTE ON FUNCTION %I.company_profile_apply_activation(uuid, text, uuid, uuid, uuid, uuid, bigint, text, text, text, text) TO %I',
1686
+ ${literal(schema)},
1687
+ ${literal(role)}
1688
+ );
1689
+ END IF;
1690
+ IF to_regprocedure(
1691
+ format(
1692
+ '%I.company_profile_get_or_create_snapshot(uuid,uuid,uuid,uuid,uuid,integer)',
1693
+ ${literal(schema)}
1694
+ )
1695
+ ) IS NOT NULL THEN
1696
+ EXECUTE format(
1697
+ 'GRANT EXECUTE ON FUNCTION %I.company_profile_get_or_create_snapshot(uuid, uuid, uuid, uuid, uuid, integer) TO %I',
1698
+ ${literal(schema)},
1699
+ ${literal(role)}
1700
+ );
1701
+ END IF;
1702
+ IF to_regprocedure(
1703
+ format(
1704
+ '%I.workspace_learning_policy_apply_activation(uuid,text,uuid,uuid,uuid,uuid,bigint,text,text,text)',
1705
+ ${literal(schema)}
1706
+ )
1707
+ ) IS NOT NULL THEN
1708
+ EXECUTE format(
1709
+ 'GRANT EXECUTE ON FUNCTION %I.workspace_learning_policy_apply_activation(uuid, text, uuid, uuid, uuid, uuid, bigint, text, text, text) TO %I',
1710
+ ${literal(schema)},
1711
+ ${literal(role)}
1712
+ );
1713
+ END IF;
1714
+ IF to_regprocedure(
1715
+ format('%I.workspace_learning_policy_source_overrides_valid(jsonb)', ${literal(schema)})
1716
+ ) IS NOT NULL THEN
1717
+ EXECUTE format(
1718
+ 'GRANT EXECUTE ON FUNCTION %I.workspace_learning_policy_source_overrides_valid(jsonb) TO %I',
1719
+ ${literal(schema)},
1720
+ ${literal(role)}
1721
+ );
1722
+ END IF;
1723
+ IF to_regprocedure(
1724
+ format('%I.workspace_learning_policy_hash(text,jsonb)', ${literal(schema)})
1725
+ ) IS NOT NULL THEN
1726
+ EXECUTE format(
1727
+ 'GRANT EXECUTE ON FUNCTION %I.workspace_learning_policy_hash(text, jsonb) TO %I',
1728
+ ${literal(schema)},
1729
+ ${literal(role)}
1730
+ );
1731
+ END IF;
1732
+ IF to_regprocedure(
1733
+ format(
1734
+ '%I.workspace_learning_policy_get_or_create_snapshot(uuid,uuid,uuid,uuid,uuid,integer)',
1735
+ ${literal(schema)}
1736
+ )
1737
+ ) IS NOT NULL THEN
1738
+ EXECUTE format(
1739
+ 'GRANT EXECUTE ON FUNCTION %I.workspace_learning_policy_get_or_create_snapshot(uuid, uuid, uuid, uuid, uuid, integer) TO %I',
1740
+ ${literal(schema)},
1741
+ ${literal(role)}
1742
+ );
1743
+ END IF;
1095
1744
  IF to_regprocedure(
1096
1745
  format(
1097
1746
  '%I.scoped_knowledge_apply_lifecycle(uuid,text,uuid,text,bigint,text,text,text,text,text,text)',
@@ -1104,6 +1753,26 @@ BEGIN
1104
1753
  ${literal(role)}
1105
1754
  );
1106
1755
  END IF;
1756
+ -- Migration 0197 creates this target-schema-local SECURITY DEFINER lock
1757
+ -- before opengeni_app may exist. Re-converge only its exact EXECUTE grant
1758
+ -- for the supported migrate-then-provision install order; keep PUBLIC
1759
+ -- revoked and do not widen table privileges.
1760
+ IF to_regprocedure(
1761
+ format(
1762
+ '%I.knowledge_source_sync_lock_authority(uuid,uuid,uuid)',
1763
+ ${literal(schema)}
1764
+ )
1765
+ ) IS NOT NULL THEN
1766
+ EXECUTE format(
1767
+ 'REVOKE ALL ON FUNCTION %I.knowledge_source_sync_lock_authority(uuid, uuid, uuid) FROM PUBLIC',
1768
+ ${literal(schema)}
1769
+ );
1770
+ EXECUTE format(
1771
+ 'GRANT EXECUTE ON FUNCTION %I.knowledge_source_sync_lock_authority(uuid, uuid, uuid) TO %I',
1772
+ ${literal(schema)},
1773
+ ${literal(role)}
1774
+ );
1775
+ END IF;
1107
1776
  IF to_regprocedure(
1108
1777
  format(
1109
1778
  '%I.scoped_knowledge_advance_source_acl(uuid,uuid,bigint,bigint,uuid,text,text,text,text,text,text)',
@@ -1159,10 +1828,81 @@ BEGIN
1159
1828
  EXECUTE format('REVOKE CREATE ON SCHEMA opengeni_private FROM %I', ${literal(role)});
1160
1829
  EXECUTE format('GRANT EXECUTE ON ALL FUNCTIONS IN SCHEMA opengeni_private TO %I', ${literal(role)});
1161
1830
  EXECUTE format(
1162
- 'ALTER DEFAULT PRIVILEGES FOR ROLE %I IN SCHEMA opengeni_private GRANT EXECUTE ON FUNCTIONS TO %I',
1831
+ 'ALTER DEFAULT PRIVILEGES FOR ROLE %I IN SCHEMA opengeni_private REVOKE EXECUTE ON FUNCTIONS FROM %I',
1163
1832
  owner_role,
1164
1833
  ${literal(role)}
1165
1834
  );
1835
+ -- Global cross-workspace artifact workers are separate capabilities. Never
1836
+ -- let the generic tenant-scoped app role inherit them from the historical
1837
+ -- blanket grant of already-installed helpers.
1838
+ IF to_regprocedure('opengeni_private.claim_editable_artifact_live_outbox(text,integer,integer,name)') IS NOT NULL THEN
1839
+ EXECUTE format(
1840
+ 'REVOKE EXECUTE ON FUNCTION opengeni_private.claim_editable_artifact_live_outbox(text, integer, integer, name) FROM %I',
1841
+ ${literal(role)}
1842
+ );
1843
+ EXECUTE format(
1844
+ 'REVOKE EXECUTE ON FUNCTION opengeni_private.mark_editable_artifact_live_outbox_published(text, text, integer, name) FROM %I',
1845
+ ${literal(role)}
1846
+ );
1847
+ EXECUTE format(
1848
+ 'REVOKE EXECUTE ON FUNCTION opengeni_private.renew_editable_artifact_live_outbox(text, text, integer, integer, name) FROM %I',
1849
+ ${literal(role)}
1850
+ );
1851
+ EXECUTE format(
1852
+ 'REVOKE EXECUTE ON FUNCTION opengeni_private.retry_editable_artifact_live_outbox(text, text, integer, integer, text, name) FROM %I',
1853
+ ${literal(role)}
1854
+ );
1855
+ EXECUTE format(
1856
+ 'REVOKE EXECUTE ON FUNCTION opengeni_private.dead_letter_editable_artifact_live_outbox(text, text, integer, text, name) FROM %I',
1857
+ ${literal(role)}
1858
+ );
1859
+ EXECUTE format(
1860
+ 'REVOKE EXECUTE ON FUNCTION opengeni_private.release_editable_artifact_live_outbox(text, text, integer, name) FROM %I',
1861
+ ${literal(role)}
1862
+ );
1863
+ END IF;
1864
+ IF to_regprocedure('opengeni_private.claim_editable_artifact_materializations(text,integer,integer,name)') IS NOT NULL THEN
1865
+ EXECUTE format(
1866
+ 'REVOKE EXECUTE ON FUNCTION opengeni_private.claim_editable_artifact_materializations(text, integer, integer, name) FROM %I',
1867
+ ${literal(role)}
1868
+ );
1869
+ EXECUTE format(
1870
+ 'REVOKE EXECUTE ON FUNCTION opengeni_private.renew_editable_artifact_materialization(uuid, uuid, text, text, text, integer, integer, name) FROM %I',
1871
+ ${literal(role)}
1872
+ );
1873
+ EXECUTE format(
1874
+ 'REVOKE EXECUTE ON FUNCTION opengeni_private.succeed_editable_artifact_materialization(uuid, uuid, text, text, text, integer, text, text, text, bigint, text, text, timestamptz, name) FROM %I',
1875
+ ${literal(role)}
1876
+ );
1877
+ EXECUTE format(
1878
+ 'REVOKE EXECUTE ON FUNCTION opengeni_private.fail_editable_artifact_materialization(uuid, uuid, text, text, text, integer, text, name) FROM %I',
1879
+ ${literal(role)}
1880
+ );
1881
+ END IF;
1882
+ IF to_regprocedure('opengeni_private.consume_editable_artifact_live_ticket(text,name)') IS NOT NULL THEN
1883
+ EXECUTE format(
1884
+ 'REVOKE EXECUTE ON FUNCTION opengeni_private.resolve_editable_artifact_ticket_data_schema(name) FROM %I',
1885
+ ${literal(role)}
1886
+ );
1887
+ EXECUTE format(
1888
+ 'GRANT EXECUTE ON FUNCTION opengeni_private.put_editable_artifact_live_ticket(text, uuid, uuid, text, text, text, text, text, text, text, text, integer, text, boolean, integer, timestamptz, timestamptz, name) TO %I',
1889
+ ${literal(role)}
1890
+ );
1891
+ EXECUTE format(
1892
+ 'GRANT EXECUTE ON FUNCTION opengeni_private.consume_editable_artifact_live_ticket(text, name) TO %I',
1893
+ ${literal(role)}
1894
+ );
1895
+ EXECUTE format(
1896
+ 'GRANT EXECUTE ON FUNCTION opengeni_private.cleanup_expired_editable_artifact_live_tickets(integer, name) TO %I',
1897
+ ${literal(role)}
1898
+ );
1899
+ END IF;
1900
+ IF to_regprocedure('opengeni_private.authorize_editable_artifact_actor(uuid,uuid,text,text,text,text,text,text,integer,text,text,name)') IS NOT NULL THEN
1901
+ EXECUTE format(
1902
+ 'GRANT EXECUTE ON FUNCTION opengeni_private.authorize_editable_artifact_actor(uuid, uuid, text, text, text, text, text, text, integer, text, text, name) TO %I',
1903
+ ${literal(role)}
1904
+ );
1905
+ END IF;
1166
1906
  END IF;
1167
1907
  END $$;
1168
1908
  `);
@@ -1201,11 +1941,14 @@ if (import.meta.main) {
1201
1941
  }
1202
1942
 
1203
1943
  export {
1944
+ RUNTIME_TARGET_SCHEMA_CAPABILITY_ROUTINES,
1204
1945
  FORCE_RLS_TABLES,
1205
1946
  NON_RLS_RUNTIME_TABLES,
1206
1947
  RUNTIME_FULL_DML_TABLES,
1207
1948
  RUNTIME_READ_ONLY_TABLES,
1949
+ RUNTIME_READ_UPDATE_TABLES,
1208
1950
  RUNTIME_READ_INSERT_TABLES,
1951
+ RUNTIME_READ_INSERT_UPDATE_TABLES,
1209
1952
  PROTECTED_NO_DIRECT_DML_TABLES,
1210
1953
  RUNTIME_TABLE_PRIVILEGES,
1211
1954
  RUNTIME_DML_TABLES,
@@ -1216,4 +1959,4 @@ export {
1216
1959
  runtimeDatabaseReadyCheck,
1217
1960
  provisionRoles
1218
1961
  };
1219
- //# sourceMappingURL=chunk-VHBFHMPC.js.map
1962
+ //# sourceMappingURL=chunk-YHZXQ7HP.js.map