@opengeni/db 0.31.1 → 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 (122) hide show
  1. package/dist/browser-auth.d.ts +209 -1
  2. package/dist/browser-downloads.d.ts +51 -0
  3. package/dist/browser-identities.d.ts +11 -2
  4. package/dist/browser-sessions.d.ts +83 -1
  5. package/dist/browser-state-artifacts.d.ts +75 -1
  6. package/dist/canonical-human-identities.d.ts +48 -0
  7. package/dist/canonical-human-identities.js +28 -0
  8. package/dist/canonical-human-identities.js.map +1 -0
  9. package/dist/capability-integrations.d.ts +8 -6
  10. package/dist/{chunk-MWDVXQOL.js → chunk-5KTIEDX7.js} +5773 -4212
  11. package/dist/chunk-5KTIEDX7.js.map +1 -0
  12. package/dist/{chunk-NBE6CHRI.js → chunk-CQZ4QSP5.js} +49 -9
  13. package/dist/chunk-CQZ4QSP5.js.map +1 -0
  14. package/dist/chunk-F32YT7MP.js +117 -0
  15. package/dist/chunk-F32YT7MP.js.map +1 -0
  16. package/dist/{chunk-ISI2TIUG.js → chunk-JC5QPLUM.js} +30 -3
  17. package/dist/chunk-JC5QPLUM.js.map +1 -0
  18. package/dist/{chunk-F5FT7BEZ.js → chunk-P3RE4D2B.js} +2 -2
  19. package/dist/chunk-TAUTWOS5.js +259 -0
  20. package/dist/chunk-TAUTWOS5.js.map +1 -0
  21. package/dist/{chunk-YHZXQ7HP.js → chunk-VKLB2ZGI.js} +446 -19
  22. package/dist/chunk-VKLB2ZGI.js.map +1 -0
  23. package/dist/database.d.ts +5 -0
  24. package/dist/editable-artifact-durable-export.js +2 -2
  25. package/dist/editable-artifacts.js +3 -3
  26. package/dist/index.d.ts +438 -29
  27. package/dist/index.js +35640 -28969
  28. package/dist/index.js.map +1 -1
  29. package/dist/insights.d.ts +23 -7
  30. package/dist/integration-bindings.d.ts +24 -24
  31. package/dist/integration-facets.d.ts +99 -0
  32. package/dist/interaction-revisions.d.ts +11 -0
  33. package/dist/interaction-schema.d.ts +698 -34
  34. package/dist/provision-roles.js +1 -1
  35. package/dist/runtime-posture.d.ts +8 -7
  36. package/dist/schema.d.ts +9464 -5412
  37. package/dist/schema.js +51 -9
  38. package/dist/session-control.d.ts +29 -3
  39. package/dist/session-tenancy.d.ts +44 -0
  40. package/dist/session-tenancy.js +16 -0
  41. package/dist/session-tenancy.js.map +1 -0
  42. package/dist/slack-task-policy-schema.d.ts +847 -0
  43. package/dist/slack-task-policy.d.ts +65 -0
  44. package/dist/task-notes-schema.d.ts +924 -0
  45. package/dist/task-notes.d.ts +85 -0
  46. package/dist/video-generation.d.ts +9 -0
  47. package/dist/video-generation.js +5 -3
  48. package/dist/xai-subscription.d.ts +326 -0
  49. package/drizzle/0212_browser_state_transfer_hardening.sql +560 -0
  50. package/drizzle/0213_browser_interaction_authority.sql +67 -0
  51. package/drizzle/0214_browser_download_saves.sql +34 -0
  52. package/drizzle/0215_browser_controller_host.sql +385 -0
  53. package/drizzle/0216_browser_auth_health_evidence.sql +137 -0
  54. package/drizzle/0217_external_browser_auth_operations.sql +22 -0
  55. package/drizzle/0218_organization_tenancy_foundation.sql +299 -0
  56. package/drizzle/0219_organization_tenancy_managed_human_provisioning.sql +317 -0
  57. package/drizzle/0219_site_auth_maintenance_sessions.sql +234 -0
  58. package/drizzle/0220_memory_slack_append_only_cascade.sql +38 -0
  59. package/drizzle/0220_session_channels.sql +54 -0
  60. package/drizzle/0221_sessions_channel_index.sql +5 -0
  61. package/drizzle/0222_session_visibility_authority_epochs.sql +158 -0
  62. package/drizzle/0222_sessions_channel_fk.sql +89 -0
  63. package/drizzle/0223_pending_tool_event_output.sql +55 -0
  64. package/drizzle/0223_sessions_channel_fk_validate.sql +118 -0
  65. package/drizzle/0224_slack_post_outcome_reconciliation.sql +123 -0
  66. package/drizzle/0225_session_visibility_fork_activation.sql +1363 -0
  67. package/drizzle/0226_personal_codex_authority_foundation.sql +365 -0
  68. package/drizzle/0227_slack_native_actions.sql +145 -0
  69. package/drizzle/0228_interaction_controller_data_plane.sql +14 -0
  70. package/drizzle/0228_slack_task_policy.sql +400 -0
  71. package/drizzle/0229_slack_inbox_file_fact.sql +10 -0
  72. package/drizzle/0230_user_scoped_variable_sets_rigs.sql +84 -0
  73. package/drizzle/0231_integration_definition_identity_cutover.sql +271 -0
  74. package/drizzle/0232_integration_facet_authority_cutover.sql +610 -0
  75. package/drizzle/0233_skill_and_integration_authority_cutover.sql +1162 -0
  76. package/drizzle/0234_xai_subscription_authority.sql +1139 -0
  77. package/drizzle/0235_canonical_human_login_bindings.sql +920 -0
  78. package/drizzle/0236_browser_identity_lifecycle.sql +39 -0
  79. package/drizzle/0236_session_visibility_slack_policy.sql +72 -0
  80. package/drizzle/0237_interaction_transition_reaper.sql +263 -0
  81. package/drizzle/0238_goal_persistence_policy.sql +471 -0
  82. package/drizzle/0238_supergrok_realtime_model.sql +29 -0
  83. package/drizzle/0239_supergrok_video_funding.sql +50 -0
  84. package/drizzle/0239_task_tree_notes.sql +990 -0
  85. package/package.json +13 -5
  86. package/src/browser-auth.ts +2600 -123
  87. package/src/browser-downloads.ts +517 -0
  88. package/src/browser-identities.ts +220 -3
  89. package/src/browser-sessions.ts +334 -45
  90. package/src/browser-state-artifacts.ts +402 -12
  91. package/src/canonical-human-identities.ts +317 -0
  92. package/src/capability-integrations.ts +121 -213
  93. package/src/database.ts +41 -1
  94. package/src/index.ts +4157 -394
  95. package/src/insights.ts +109 -28
  96. package/src/integration-bindings.ts +101 -101
  97. package/src/{integration-features.ts → integration-facets.ts} +187 -184
  98. package/src/interaction-revisions.ts +33 -3
  99. package/src/interaction-schema.ts +311 -8
  100. package/src/pack-components.ts +43 -43
  101. package/src/pack-installations.ts +0 -43
  102. package/src/plugin-packages.ts +9 -9
  103. package/src/provision-roles.ts +232 -0
  104. package/src/runtime-posture.ts +227 -14
  105. package/src/schema.ts +1188 -75
  106. package/src/session-control.ts +122 -37
  107. package/src/session-queue-commands.ts +78 -1
  108. package/src/session-tenancy.ts +188 -0
  109. package/src/session-tool-call-settlement.ts +9 -3
  110. package/src/slack-task-policy-schema.ts +130 -0
  111. package/src/slack-task-policy.ts +341 -0
  112. package/src/task-notes-schema.ts +135 -0
  113. package/src/task-notes.ts +178 -0
  114. package/src/video-generation.ts +90 -12
  115. package/src/workspace-artifacts.ts +1 -1
  116. package/src/xai-subscription.ts +1887 -0
  117. package/dist/chunk-ISI2TIUG.js.map +0 -1
  118. package/dist/chunk-MWDVXQOL.js.map +0 -1
  119. package/dist/chunk-NBE6CHRI.js.map +0 -1
  120. package/dist/chunk-YHZXQ7HP.js.map +0 -1
  121. package/dist/integration-features.d.ts +0 -99
  122. /package/dist/{chunk-F5FT7BEZ.js.map → chunk-P3RE4D2B.js.map} +0 -0
@@ -124,9 +124,77 @@ var KNOWLEDGE_SOURCE_SYNC_LOCK_AUTHORITY_TABLES = [
124
124
  "knowledge_sources",
125
125
  "knowledge_source_objects"
126
126
  ];
127
+ var MANAGED_HUMAN_PERSONAL_WORKSPACE_ROUTINE = "ensure_managed_human_personal_workspace(uuid, text, uuid)";
128
+ var MANAGED_HUMAN_PERSONAL_WORKSPACE_AUTHORITY_TABLES = [
129
+ "organization_memberships",
130
+ "organization_user_retention_policies",
131
+ "organization_user_resource_authorities",
132
+ "organization_user_resource_grants"
133
+ ];
134
+ var CANONICAL_HUMAN_IDENTITY_ROUTINES = [
135
+ "ensure_canonical_human_identity(text, text)",
136
+ "validate_canonical_human_session(text, text, boolean)",
137
+ "get_canonical_human_identity_projection(text)",
138
+ "apply_canonical_human_identity_operation(uuid, text, bigint, text, uuid, text, text, text)"
139
+ ];
140
+ var CANONICAL_HUMAN_IDENTITY_AUTHORITY_TABLES = [
141
+ "canonical_human_identities",
142
+ "canonical_human_identity_subjects",
143
+ "canonical_human_login_bindings",
144
+ "canonical_human_identity_operations"
145
+ ];
146
+ var SESSION_PRIVATE_ACTOR_VISIBLE_ROUTINE = "session_private_actor_visible(uuid, uuid, uuid, text)";
147
+ var SESSION_REFERENCE_VISIBLE_ROUTINE = "session_reference_visible(uuid, uuid, uuid)";
148
+ var TASK_NOTE_CAPABILITY_ROUTINES = [
149
+ "create_task_note_for_attempt(uuid, uuid, uuid, uuid, uuid, integer, uuid, text, text, integer)",
150
+ "archive_task_note_for_attempt(uuid, uuid, uuid, uuid, uuid, integer, uuid, uuid, integer, text)",
151
+ "list_task_notes_for_attempt(uuid, uuid, uuid, uuid, uuid, integer, boolean, integer)"
152
+ ];
153
+ var TRANSITION_SESSION_VISIBILITY_ROUTINE = "transition_session_visibility(uuid, uuid, uuid, text, text, integer, text, text)";
154
+ var FORK_SESSION_CONTENT_ROUTINE = "fork_session_content(uuid, uuid, uuid, text, uuid, text, text, text)";
155
+ var SESSION_AUTHORITY_ROUTINES = /* @__PURE__ */ new Set([
156
+ FORK_SESSION_CONTENT_ROUTINE,
157
+ SESSION_PRIVATE_ACTOR_VISIBLE_ROUTINE,
158
+ SESSION_REFERENCE_VISIBLE_ROUTINE,
159
+ TRANSITION_SESSION_VISIBILITY_ROUTINE,
160
+ ...TASK_NOTE_CAPABILITY_ROUTINES
161
+ ]);
162
+ var XAI_CREATE_CREDENTIAL_ROUTINE = "create_xai_subscription_credential(uuid, uuid, text, text, text, text, text, text, text, timestamp with time zone)";
163
+ var XAI_DISCONNECT_CREDENTIAL_ROUTINE = "disconnect_xai_subscription_credential(uuid, uuid, text, uuid, jsonb)";
164
+ var XAI_SNAPSHOT_VALIDATOR_ROUTINE = "xai_provider_account_authority_snapshot_v1_valid(jsonb)";
165
+ var XAI_AUTHORITY_LIVE_ROUTINE = "xai_subscription_authority_live(uuid, uuid, text, uuid, text, uuid, uuid, bigint)";
166
+ var XAI_POOL_VISIBLE_ROUTINE = "xai_subscription_pool_visible(uuid, uuid, text, text, uuid)";
167
+ var XAI_RESOLVE_POOL_ROUTINE = "resolve_xai_authority_pool(uuid, uuid, text, jsonb)";
168
+ var XAI_REVALIDATE_CREDENTIAL_ROUTINE = "revalidate_xai_subscription_authority(uuid, text, uuid, jsonb)";
169
+ var XAI_AUTHORITY_TABLES = [
170
+ "organization_memberships",
171
+ "organization_user_resource_authorities",
172
+ "workspace_memberships",
173
+ "xai_subscription_credentials"
174
+ ];
127
175
  var RUNTIME_TARGET_SCHEMA_CAPABILITY_ROUTINES = [
128
- KNOWLEDGE_SOURCE_SYNC_LOCK_AUTHORITY_ROUTINE
176
+ FORK_SESSION_CONTENT_ROUTINE,
177
+ XAI_AUTHORITY_LIVE_ROUTINE,
178
+ XAI_CREATE_CREDENTIAL_ROUTINE,
179
+ XAI_DISCONNECT_CREDENTIAL_ROUTINE,
180
+ KNOWLEDGE_SOURCE_SYNC_LOCK_AUTHORITY_ROUTINE,
181
+ MANAGED_HUMAN_PERSONAL_WORKSPACE_ROUTINE,
182
+ ...CANONICAL_HUMAN_IDENTITY_ROUTINES,
183
+ SESSION_PRIVATE_ACTOR_VISIBLE_ROUTINE,
184
+ SESSION_REFERENCE_VISIBLE_ROUTINE,
185
+ TRANSITION_SESSION_VISIBILITY_ROUTINE,
186
+ XAI_POOL_VISIBLE_ROUTINE,
187
+ XAI_RESOLVE_POOL_ROUTINE,
188
+ XAI_REVALIDATE_CREDENTIAL_ROUTINE,
189
+ XAI_SNAPSHOT_VALIDATOR_ROUTINE
190
+ ];
191
+ var RUNTIME_TARGET_SCHEMA_INVOKER_ROUTINES = [
192
+ SESSION_REFERENCE_VISIBLE_ROUTINE,
193
+ XAI_SNAPSHOT_VALIDATOR_ROUTINE
129
194
  ];
195
+ var RUNTIME_TARGET_SCHEMA_INVOKER_ROUTINE_SET = new Set(
196
+ RUNTIME_TARGET_SCHEMA_INVOKER_ROUTINES
197
+ );
130
198
  var FORCE_RLS_TABLES = [
131
199
  "agent_run_states",
132
200
  "api_keys",
@@ -141,6 +209,11 @@ var FORCE_RLS_TABLES = [
141
209
  "browser_session_associations",
142
210
  "browser_sessions",
143
211
  "browser_state_artifacts",
212
+ "browser_state_uploads",
213
+ "canonical_human_identities",
214
+ "canonical_human_identity_operations",
215
+ "canonical_human_identity_subjects",
216
+ "canonical_human_login_bindings",
144
217
  "capability_api_facets",
145
218
  "capability_catalog_items",
146
219
  "capability_component_owners",
@@ -155,6 +228,7 @@ var FORCE_RLS_TABLES = [
155
228
  "capability_plugins",
156
229
  "capability_skill_facets",
157
230
  "capability_skill_files",
231
+ "channels",
158
232
  "codex_apps_settings",
159
233
  "codex_capacity_waiters",
160
234
  "codex_credential_leases",
@@ -207,9 +281,9 @@ var FORCE_RLS_TABLES = [
207
281
  "host_export_outbox",
208
282
  "image_generation_operations",
209
283
  "import_batches",
210
- "integration_feature_binding_owners",
211
- "integration_feature_bindings",
212
- "integration_feature_facets",
284
+ "integration_facet_binding_owners",
285
+ "integration_facet_bindings",
286
+ "integration_facet_definitions",
213
287
  "integration_oauth_state_nonces",
214
288
  "integration_spec_revisions",
215
289
  "integration_tools",
@@ -249,6 +323,10 @@ var FORCE_RLS_TABLES = [
249
323
  "model_call_facts",
250
324
  "network_routes",
251
325
  "new_session_drafts",
326
+ "organization_memberships",
327
+ "organization_user_resource_authorities",
328
+ "organization_user_resource_grants",
329
+ "organization_user_retention_policies",
252
330
  "pack_installation_components",
253
331
  "pack_installations",
254
332
  "preference_registry_events",
@@ -274,6 +352,7 @@ var FORCE_RLS_TABLES = [
274
352
  "session_attempt_tool_catalogs",
275
353
  "session_command_receipts",
276
354
  "session_events",
355
+ "session_goal_revisions",
277
356
  "session_goals",
278
357
  "session_history_items",
279
358
  "session_human_input_requests",
@@ -292,20 +371,30 @@ var FORCE_RLS_TABLES = [
292
371
  "session_system_updates",
293
372
  "session_turn_attempts",
294
373
  "session_turns",
374
+ "session_visibility_write_capabilities",
295
375
  "session_workflow_wake_outbox",
296
376
  "sessions",
297
377
  "site_auth_connections",
298
378
  "slack_bot_delete_operations",
299
379
  "slack_bot_post_operations",
380
+ "slack_bot_update_operations",
300
381
  "slack_bot_user_links",
301
382
  "slack_installation_bindings",
383
+ "slack_interaction_action_handles",
302
384
  "slack_interaction_inbox",
303
385
  "slack_interaction_progress_deliveries",
304
386
  "slack_interactions",
387
+ "slack_shared_task_origins",
388
+ "slack_task_policy_activation_events",
389
+ "slack_task_policy_heads",
390
+ "slack_task_policy_revisions",
305
391
  "slack_user_link_access_request_operations",
306
392
  "slack_user_link_access_requests",
307
393
  "social_connections",
308
394
  "social_posts",
395
+ "task_note_events",
396
+ "task_note_write_capabilities",
397
+ "task_notes",
309
398
  "temporal_schedule_cleanup_outbox",
310
399
  "transcription_recording_chunks",
311
400
  "transcription_recording_objects",
@@ -337,7 +426,12 @@ var FORCE_RLS_TABLES = [
337
426
  "workspace_variable_set_variables",
338
427
  "workspace_variable_sets",
339
428
  "workspace_video_generation_policies",
340
- "workspace_video_generation_quotas"
429
+ "workspace_video_generation_quotas",
430
+ "xai_capacity_waiters",
431
+ "xai_credential_leases",
432
+ "xai_rotation_settings",
433
+ "xai_session_account_pins",
434
+ "xai_subscription_credentials"
341
435
  ];
342
436
  var NON_RLS_RUNTIME_TABLES = [
343
437
  "auth_identities",
@@ -369,6 +463,7 @@ var RUNTIME_FULL_DML_TABLES = [
369
463
  "capability_installations",
370
464
  "capability_operations",
371
465
  "capability_plugin_installations",
466
+ "channels",
372
467
  "codex_apps_settings",
373
468
  "codex_capacity_waiters",
374
469
  "codex_credential_leases",
@@ -396,8 +491,8 @@ var RUNTIME_FULL_DML_TABLES = [
396
491
  "github_installations",
397
492
  "image_generation_operations",
398
493
  "import_batches",
399
- "integration_feature_binding_owners",
400
- "integration_feature_bindings",
494
+ "integration_facet_binding_owners",
495
+ "integration_facet_bindings",
401
496
  "integration_oauth_clients",
402
497
  "integration_oauth_state_nonces",
403
498
  "knowledge_memories",
@@ -455,7 +550,9 @@ var RUNTIME_FULL_DML_TABLES = [
455
550
  "sessions",
456
551
  "slack_bot_delete_operations",
457
552
  "slack_bot_post_operations",
553
+ "slack_bot_update_operations",
458
554
  "slack_bot_user_links",
555
+ "slack_interaction_action_handles",
459
556
  "slack_interaction_inbox",
460
557
  "slack_interaction_progress_deliveries",
461
558
  "slack_interactions",
@@ -482,7 +579,12 @@ var RUNTIME_FULL_DML_TABLES = [
482
579
  "workspace_variable_sets",
483
580
  "workspace_video_generation_policies",
484
581
  "workspace_video_generation_quotas",
485
- "workspaces"
582
+ "workspaces",
583
+ "xai_capacity_waiters",
584
+ "xai_credential_leases",
585
+ "xai_rotation_settings",
586
+ "xai_session_account_pins",
587
+ "xai_subscription_credentials"
486
588
  ];
487
589
  var RUNTIME_READ_ONLY_TABLES = [
488
590
  "company_profile_activation_events",
@@ -495,6 +597,9 @@ var RUNTIME_READ_ONLY_TABLES = [
495
597
  "preference_registry_events",
496
598
  "preference_registry_snapshots",
497
599
  "slack_installation_bindings",
600
+ "slack_task_policy_activation_events",
601
+ "slack_task_policy_heads",
602
+ "slack_task_policy_revisions",
498
603
  "workspace_instruction_policy_snapshots",
499
604
  "workspace_learning_policy_activation_events",
500
605
  "workspace_learning_policy_heads",
@@ -534,7 +639,9 @@ var RUNTIME_READ_INSERT_TABLES = [
534
639
  "preference_registry_preferences",
535
640
  "preference_registry_revisions",
536
641
  "session_attempt_tool_catalogs",
642
+ "session_goal_revisions",
537
643
  "session_spawn_denials",
644
+ "slack_shared_task_origins",
538
645
  "slack_user_link_access_request_operations",
539
646
  "temporal_schedule_cleanup_outbox",
540
647
  "workspace_artifact_events",
@@ -551,6 +658,7 @@ var RUNTIME_READ_INSERT_UPDATE_TABLES = [
551
658
  "browser_identities",
552
659
  "browser_sessions",
553
660
  "browser_state_artifacts",
661
+ "browser_state_uploads",
554
662
  "capability_api_facets",
555
663
  "capability_facets",
556
664
  "capability_integration_facets",
@@ -562,7 +670,7 @@ var RUNTIME_READ_INSERT_UPDATE_TABLES = [
562
670
  "computer_sessions",
563
671
  "editable_artifact_session_links",
564
672
  "editable_artifacts",
565
- "integration_feature_facets",
673
+ "integration_facet_definitions",
566
674
  "integration_spec_revisions",
567
675
  "integration_tools",
568
676
  "interaction_interventions",
@@ -575,13 +683,25 @@ var RUNTIME_READ_INSERT_UPDATE_TABLES = [
575
683
  "workspace_interaction_revisions"
576
684
  ];
577
685
  var PROTECTED_NO_DIRECT_DML_TABLES = [
686
+ "canonical_human_identities",
687
+ "canonical_human_identity_operations",
688
+ "canonical_human_identity_subjects",
689
+ "canonical_human_login_bindings",
578
690
  "editable_artifact_live_tickets",
579
691
  "editable_artifact_scope_authorization_heads",
580
692
  "host_export_config",
581
693
  "host_export_consumers",
582
694
  "host_export_cursor_state",
583
695
  "host_export_dead_letters",
584
- "host_export_outbox"
696
+ "host_export_outbox",
697
+ "organization_memberships",
698
+ "organization_user_resource_authorities",
699
+ "organization_user_resource_grants",
700
+ "organization_user_retention_policies",
701
+ "session_visibility_write_capabilities",
702
+ "task_note_events",
703
+ "task_note_write_capabilities",
704
+ "task_notes"
585
705
  ];
586
706
  var FULL_DML_PRIVILEGES = ["SELECT", "INSERT", "UPDATE", "DELETE"];
587
707
  var RUNTIME_TABLE_PRIVILEGES = Object.freeze({
@@ -786,14 +906,16 @@ async function inspectRuntimeDatabasePosture(db, options) {
786
906
  p.prosecdef as security_definer
787
907
  from pg_proc p
788
908
  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}
909
+ where n.nspname = ${targetSchema}
796
910
  and p.prokind in ('f', 'p')
911
+ and (p.proname || '(' || pg_catalog.oidvectortypes(p.proargtypes) || ')') = any(
912
+ array[
913
+ ${sql.join(
914
+ RUNTIME_TARGET_SCHEMA_CAPABILITY_ROUTINES.map((name) => sql`${name}`),
915
+ sql`, `
916
+ )}
917
+ ]::text[]
918
+ )
797
919
  order by p.proname, pg_catalog.oidvectortypes(p.proargtypes)
798
920
  `)
799
921
  ).map((row) => ({
@@ -990,7 +1112,13 @@ function evaluateRuntimeDatabasePosture(posture, options) {
990
1112
  continue;
991
1113
  }
992
1114
  const routine = matches[0];
993
- if (!routine.securityDefiner) {
1115
+ if (RUNTIME_TARGET_SCHEMA_INVOKER_ROUTINE_SET.has(routine.name)) {
1116
+ if (routine.securityDefiner) {
1117
+ violations.push(
1118
+ `target-schema runtime capability ${routine.name} must be SECURITY INVOKER`
1119
+ );
1120
+ }
1121
+ } else if (!routine.securityDefiner) {
994
1122
  violations.push(`target-schema runtime capability ${routine.name} is not SECURITY DEFINER`);
995
1123
  }
996
1124
  if (routine.name === KNOWLEDGE_SOURCE_SYNC_LOCK_AUTHORITY_ROUTINE) {
@@ -1016,6 +1144,72 @@ function evaluateRuntimeDatabasePosture(posture, options) {
1016
1144
  );
1017
1145
  }
1018
1146
  }
1147
+ } else if (routine.name === MANAGED_HUMAN_PERSONAL_WORKSPACE_ROUTINE) {
1148
+ const authorityTables = MANAGED_HUMAN_PERSONAL_WORKSPACE_AUTHORITY_TABLES.filter(
1149
+ (tableName) => tableByName.has(tableName)
1150
+ ).map((tableName) => tableByName.get(tableName));
1151
+ const authorityOwners = new Set(authorityTables.map((table) => table.owner));
1152
+ if (authorityOwners.size > 1) {
1153
+ violations.push(
1154
+ `target-schema runtime capability ${routine.name} authority table owners do not match: ${authorityTables.map((table) => `${table.name}=${table.owner}`).join(", ")}`
1155
+ );
1156
+ } else if (authorityTables[0] && routine.owner !== authorityTables[0].owner) {
1157
+ violations.push(
1158
+ `target-schema runtime capability ${routine.name} owner ${routine.owner} does not match authority table owner ${authorityTables[0].owner}`
1159
+ );
1160
+ }
1161
+ } else if (CANONICAL_HUMAN_IDENTITY_ROUTINES.includes(routine.name)) {
1162
+ const authorityTables = CANONICAL_HUMAN_IDENTITY_AUTHORITY_TABLES.filter(
1163
+ (tableName) => tableByName.has(tableName)
1164
+ ).map((tableName) => tableByName.get(tableName));
1165
+ const authorityOwners = new Set(authorityTables.map((table) => table.owner));
1166
+ if (authorityTables.length !== CANONICAL_HUMAN_IDENTITY_AUTHORITY_TABLES.length) {
1167
+ violations.push(
1168
+ `target-schema runtime capability ${routine.name} canonical identity authority tables are missing`
1169
+ );
1170
+ } else if (authorityOwners.size !== 1) {
1171
+ violations.push(
1172
+ `target-schema runtime capability ${routine.name} authority table owners do not match: ${authorityTables.map((table) => `${table.name}=${table.owner}`).join(", ")}`
1173
+ );
1174
+ } else if (routine.owner !== authorityTables[0].owner) {
1175
+ violations.push(
1176
+ `target-schema runtime capability ${routine.name} owner ${routine.owner} does not match authority table owner ${authorityTables[0].owner}`
1177
+ );
1178
+ }
1179
+ } else if (SESSION_AUTHORITY_ROUTINES.has(routine.name)) {
1180
+ const authorityOwner = tableByName.get("sessions")?.owner ?? targetSchemaOwner;
1181
+ if (authorityOwner && routine.owner !== authorityOwner) {
1182
+ violations.push(
1183
+ `target-schema runtime capability ${routine.name} owner ${routine.owner} does not match session authority owner ${authorityOwner}`
1184
+ );
1185
+ }
1186
+ } else if (routine.name === XAI_SNAPSHOT_VALIDATOR_ROUTINE) {
1187
+ } else if (routine.name === XAI_CREATE_CREDENTIAL_ROUTINE || routine.name === XAI_DISCONNECT_CREDENTIAL_ROUTINE || routine.name === XAI_AUTHORITY_LIVE_ROUTINE || routine.name === XAI_POOL_VISIBLE_ROUTINE || routine.name === XAI_RESOLVE_POOL_ROUTINE || routine.name === XAI_REVALIDATE_CREDENTIAL_ROUTINE) {
1188
+ if (!tableByName.has("xai_subscription_credentials")) {
1189
+ continue;
1190
+ }
1191
+ const missingAuthorityTables = XAI_AUTHORITY_TABLES.filter(
1192
+ (tableName) => !tableByName.has(tableName)
1193
+ );
1194
+ if (missingAuthorityTables.length > 0) {
1195
+ violations.push(
1196
+ `target-schema runtime capability ${routine.name} authority tables are missing: ${missingAuthorityTables.join(", ")}`
1197
+ );
1198
+ } else {
1199
+ const authorityTables = XAI_AUTHORITY_TABLES.map(
1200
+ (tableName) => tableByName.get(tableName)
1201
+ );
1202
+ const authorityOwners = new Set(authorityTables.map((table) => table.owner));
1203
+ if (authorityOwners.size !== 1) {
1204
+ violations.push(
1205
+ `target-schema runtime capability ${routine.name} authority table owners do not match: ${authorityTables.map((table) => `${table.name}=${table.owner}`).join(", ")}`
1206
+ );
1207
+ } else if (routine.owner !== authorityTables[0].owner) {
1208
+ violations.push(
1209
+ `target-schema runtime capability ${routine.name} owner ${routine.owner} does not match authority table owner ${authorityTables[0].owner}`
1210
+ );
1211
+ }
1212
+ }
1019
1213
  } else if (targetSchemaOwner && routine.owner !== targetSchemaOwner) {
1020
1214
  violations.push(
1021
1215
  `target-schema runtime capability ${routine.name} owner ${routine.owner} does not match schema owner ${targetSchemaOwner}`
@@ -1663,6 +1857,28 @@ BEGIN
1663
1857
  ${literal(role)}
1664
1858
  );
1665
1859
  END IF;
1860
+ IF to_regprocedure(
1861
+ format(
1862
+ '%I.create_task_note_for_attempt(uuid,uuid,uuid,uuid,uuid,integer,uuid,text,text,integer)',
1863
+ ${literal(schema)}
1864
+ )
1865
+ ) IS NOT NULL THEN
1866
+ EXECUTE format(
1867
+ 'GRANT EXECUTE ON FUNCTION %I.create_task_note_for_attempt(uuid, uuid, uuid, uuid, uuid, integer, uuid, text, text, integer) TO %I',
1868
+ ${literal(schema)},
1869
+ ${literal(role)}
1870
+ );
1871
+ EXECUTE format(
1872
+ 'GRANT EXECUTE ON FUNCTION %I.archive_task_note_for_attempt(uuid, uuid, uuid, uuid, uuid, integer, uuid, uuid, integer, text) TO %I',
1873
+ ${literal(schema)},
1874
+ ${literal(role)}
1875
+ );
1876
+ EXECUTE format(
1877
+ 'GRANT EXECUTE ON FUNCTION %I.list_task_notes_for_attempt(uuid, uuid, uuid, uuid, uuid, integer, boolean, integer) TO %I',
1878
+ ${literal(schema)},
1879
+ ${literal(role)}
1880
+ );
1881
+ END IF;
1666
1882
  IF to_regprocedure(
1667
1883
  format(
1668
1884
  '%I.workspace_instruction_policy_get_or_create_snapshot(uuid,uuid,uuid,uuid,uuid,integer)',
@@ -1741,6 +1957,18 @@ BEGIN
1741
1957
  ${literal(role)}
1742
1958
  );
1743
1959
  END IF;
1960
+ IF to_regprocedure(
1961
+ format(
1962
+ '%I.slack_task_policy_update(uuid,text,uuid,uuid,jsonb,uuid,bigint,text,text)',
1963
+ ${literal(schema)}
1964
+ )
1965
+ ) IS NOT NULL THEN
1966
+ EXECUTE format(
1967
+ 'GRANT EXECUTE ON FUNCTION %I.slack_task_policy_update(uuid, text, uuid, uuid, jsonb, uuid, bigint, text, text) TO %I',
1968
+ ${literal(schema)},
1969
+ ${literal(role)}
1970
+ );
1971
+ END IF;
1744
1972
  IF to_regprocedure(
1745
1973
  format(
1746
1974
  '%I.scoped_knowledge_apply_lifecycle(uuid,text,uuid,text,bigint,text,text,text,text,text,text)',
@@ -1773,6 +2001,204 @@ BEGIN
1773
2001
  ${literal(role)}
1774
2002
  );
1775
2003
  END IF;
2004
+ IF to_regprocedure(
2005
+ format(
2006
+ '%I.ensure_managed_human_personal_workspace(uuid,text,uuid)',
2007
+ ${literal(schema)}
2008
+ )
2009
+ ) IS NOT NULL THEN
2010
+ EXECUTE format(
2011
+ 'REVOKE ALL ON FUNCTION %I.ensure_managed_human_personal_workspace(uuid, text, uuid) FROM PUBLIC',
2012
+ ${literal(schema)}
2013
+ );
2014
+ EXECUTE format(
2015
+ 'GRANT EXECUTE ON FUNCTION %I.ensure_managed_human_personal_workspace(uuid, text, uuid) TO %I',
2016
+ ${literal(schema)},
2017
+ ${literal(role)}
2018
+ );
2019
+ END IF;
2020
+ IF to_regprocedure(format('%I.ensure_canonical_human_identity(text,text)', ${literal(schema)})) IS NOT NULL THEN
2021
+ EXECUTE format(
2022
+ 'REVOKE ALL ON FUNCTION %I.ensure_canonical_human_identity(text, text) FROM PUBLIC',
2023
+ ${literal(schema)}
2024
+ );
2025
+ EXECUTE format(
2026
+ 'GRANT EXECUTE ON FUNCTION %I.ensure_canonical_human_identity(text, text) TO %I',
2027
+ ${literal(schema)},
2028
+ ${literal(role)}
2029
+ );
2030
+ END IF;
2031
+ IF to_regprocedure(format('%I.validate_canonical_human_session(text,text,boolean)', ${literal(schema)})) IS NOT NULL THEN
2032
+ EXECUTE format(
2033
+ 'REVOKE ALL ON FUNCTION %I.validate_canonical_human_session(text, text, boolean) FROM PUBLIC',
2034
+ ${literal(schema)}
2035
+ );
2036
+ EXECUTE format(
2037
+ 'GRANT EXECUTE ON FUNCTION %I.validate_canonical_human_session(text, text, boolean) TO %I',
2038
+ ${literal(schema)},
2039
+ ${literal(role)}
2040
+ );
2041
+ END IF;
2042
+ IF to_regprocedure(format('%I.get_canonical_human_identity_projection(text)', ${literal(schema)})) IS NOT NULL THEN
2043
+ EXECUTE format(
2044
+ 'REVOKE ALL ON FUNCTION %I.get_canonical_human_identity_projection(text) FROM PUBLIC',
2045
+ ${literal(schema)}
2046
+ );
2047
+ EXECUTE format(
2048
+ 'GRANT EXECUTE ON FUNCTION %I.get_canonical_human_identity_projection(text) TO %I',
2049
+ ${literal(schema)},
2050
+ ${literal(role)}
2051
+ );
2052
+ END IF;
2053
+ IF to_regprocedure(format('%I.apply_canonical_human_identity_operation(uuid,text,bigint,text,uuid,text,text,text)', ${literal(schema)})) IS NOT NULL THEN
2054
+ EXECUTE format(
2055
+ 'REVOKE ALL ON FUNCTION %I.apply_canonical_human_identity_operation(uuid, text, bigint, text, uuid, text, text, text) FROM PUBLIC',
2056
+ ${literal(schema)}
2057
+ );
2058
+ EXECUTE format(
2059
+ 'GRANT EXECUTE ON FUNCTION %I.apply_canonical_human_identity_operation(uuid, text, bigint, text, uuid, text, text, text) TO %I',
2060
+ ${literal(schema)},
2061
+ ${literal(role)}
2062
+ );
2063
+ END IF;
2064
+ -- Migration 0225 creates these target-schema-local session visibility
2065
+ -- capabilities before opengeni_app may exist. Re-converge their exact
2066
+ -- EXECUTE grants for migrate-then-provision installs without granting
2067
+ -- blanket execution on target-schema routines.
2068
+ IF to_regprocedure(
2069
+ format(
2070
+ '%I.session_private_actor_visible(uuid,uuid,uuid,text)',
2071
+ ${literal(schema)}
2072
+ )
2073
+ ) IS NOT NULL THEN
2074
+ EXECUTE format(
2075
+ 'REVOKE ALL ON FUNCTION %I.session_private_actor_visible(uuid, uuid, uuid, text) FROM PUBLIC',
2076
+ ${literal(schema)}
2077
+ );
2078
+ EXECUTE format(
2079
+ 'GRANT EXECUTE ON FUNCTION %I.session_private_actor_visible(uuid, uuid, uuid, text) TO %I',
2080
+ ${literal(schema)},
2081
+ ${literal(role)}
2082
+ );
2083
+ END IF;
2084
+ IF to_regprocedure(
2085
+ format(
2086
+ '%I.session_reference_visible(uuid,uuid,uuid)',
2087
+ ${literal(schema)}
2088
+ )
2089
+ ) IS NOT NULL THEN
2090
+ EXECUTE format(
2091
+ 'REVOKE ALL ON FUNCTION %I.session_reference_visible(uuid, uuid, uuid) FROM PUBLIC',
2092
+ ${literal(schema)}
2093
+ );
2094
+ EXECUTE format(
2095
+ 'GRANT EXECUTE ON FUNCTION %I.session_reference_visible(uuid, uuid, uuid) TO %I',
2096
+ ${literal(schema)},
2097
+ ${literal(role)}
2098
+ );
2099
+ END IF;
2100
+ IF to_regprocedure(
2101
+ format(
2102
+ '%I.transition_session_visibility(uuid,uuid,uuid,text,text,integer,text,text)',
2103
+ ${literal(schema)}
2104
+ )
2105
+ ) IS NOT NULL THEN
2106
+ EXECUTE format(
2107
+ 'REVOKE ALL ON FUNCTION %I.transition_session_visibility(uuid, uuid, uuid, text, text, integer, text, text) FROM PUBLIC',
2108
+ ${literal(schema)}
2109
+ );
2110
+ EXECUTE format(
2111
+ 'GRANT EXECUTE ON FUNCTION %I.transition_session_visibility(uuid, uuid, uuid, text, text, integer, text, text) TO %I',
2112
+ ${literal(schema)},
2113
+ ${literal(role)}
2114
+ );
2115
+ END IF;
2116
+ IF to_regprocedure(
2117
+ format(
2118
+ '%I.fork_session_content(uuid,uuid,uuid,text,uuid,text,text,text)',
2119
+ ${literal(schema)}
2120
+ )
2121
+ ) IS NOT NULL THEN
2122
+ EXECUTE format(
2123
+ 'REVOKE ALL ON FUNCTION %I.fork_session_content(uuid, uuid, uuid, text, uuid, text, text, text) FROM PUBLIC',
2124
+ ${literal(schema)}
2125
+ );
2126
+ EXECUTE format(
2127
+ 'GRANT EXECUTE ON FUNCTION %I.fork_session_content(uuid, uuid, uuid, text, uuid, text, text, text) TO %I',
2128
+ ${literal(schema)},
2129
+ ${literal(role)}
2130
+ );
2131
+ END IF;
2132
+ IF to_regprocedure(
2133
+ format(
2134
+ '%I.create_xai_subscription_credential(uuid,uuid,text,text,text,text,text,text,text,timestamptz)',
2135
+ ${literal(schema)}
2136
+ )
2137
+ ) IS NOT NULL THEN
2138
+ EXECUTE format(
2139
+ 'REVOKE ALL ON FUNCTION %I.create_xai_subscription_credential(uuid, uuid, text, text, text, text, text, text, text, timestamptz) FROM PUBLIC',
2140
+ ${literal(schema)}
2141
+ );
2142
+ EXECUTE format(
2143
+ 'GRANT EXECUTE ON FUNCTION %I.create_xai_subscription_credential(uuid, uuid, text, text, text, text, text, text, text, timestamptz) TO %I',
2144
+ ${literal(schema)},
2145
+ ${literal(role)}
2146
+ );
2147
+ EXECUTE format(
2148
+ 'REVOKE ALL ON FUNCTION %I.disconnect_xai_subscription_credential(uuid, uuid, text, uuid, jsonb) FROM PUBLIC',
2149
+ ${literal(schema)}
2150
+ );
2151
+ EXECUTE format(
2152
+ 'GRANT EXECUTE ON FUNCTION %I.disconnect_xai_subscription_credential(uuid, uuid, text, uuid, jsonb) TO %I',
2153
+ ${literal(schema)},
2154
+ ${literal(role)}
2155
+ );
2156
+ EXECUTE format(
2157
+ 'REVOKE ALL ON FUNCTION %I.resolve_xai_authority_pool(uuid, uuid, text, jsonb) FROM PUBLIC',
2158
+ ${literal(schema)}
2159
+ );
2160
+ EXECUTE format(
2161
+ 'GRANT EXECUTE ON FUNCTION %I.resolve_xai_authority_pool(uuid, uuid, text, jsonb) TO %I',
2162
+ ${literal(schema)},
2163
+ ${literal(role)}
2164
+ );
2165
+ EXECUTE format(
2166
+ 'REVOKE ALL ON FUNCTION %I.revalidate_xai_subscription_authority(uuid, text, uuid, jsonb) FROM PUBLIC',
2167
+ ${literal(schema)}
2168
+ );
2169
+ EXECUTE format(
2170
+ 'GRANT EXECUTE ON FUNCTION %I.revalidate_xai_subscription_authority(uuid, text, uuid, jsonb) TO %I',
2171
+ ${literal(schema)},
2172
+ ${literal(role)}
2173
+ );
2174
+ EXECUTE format(
2175
+ 'REVOKE ALL ON FUNCTION %I.xai_provider_account_authority_snapshot_v1_valid(jsonb) FROM PUBLIC',
2176
+ ${literal(schema)}
2177
+ );
2178
+ EXECUTE format(
2179
+ 'GRANT EXECUTE ON FUNCTION %I.xai_provider_account_authority_snapshot_v1_valid(jsonb) TO %I',
2180
+ ${literal(schema)},
2181
+ ${literal(role)}
2182
+ );
2183
+ EXECUTE format(
2184
+ 'REVOKE ALL ON FUNCTION %I.xai_subscription_authority_live(uuid, uuid, text, uuid, text, uuid, uuid, bigint) FROM PUBLIC',
2185
+ ${literal(schema)}
2186
+ );
2187
+ EXECUTE format(
2188
+ 'GRANT EXECUTE ON FUNCTION %I.xai_subscription_authority_live(uuid, uuid, text, uuid, text, uuid, uuid, bigint) TO %I',
2189
+ ${literal(schema)},
2190
+ ${literal(role)}
2191
+ );
2192
+ EXECUTE format(
2193
+ 'REVOKE ALL ON FUNCTION %I.xai_subscription_pool_visible(uuid, uuid, text, text, uuid) FROM PUBLIC',
2194
+ ${literal(schema)}
2195
+ );
2196
+ EXECUTE format(
2197
+ 'GRANT EXECUTE ON FUNCTION %I.xai_subscription_pool_visible(uuid, uuid, text, text, uuid) TO %I',
2198
+ ${literal(schema)},
2199
+ ${literal(role)}
2200
+ );
2201
+ END IF;
1776
2202
  IF to_regprocedure(
1777
2203
  format(
1778
2204
  '%I.scoped_knowledge_advance_source_acl(uuid,uuid,bigint,bigint,uuid,text,text,text,text,text,text)',
@@ -1942,6 +2368,7 @@ if (import.meta.main) {
1942
2368
 
1943
2369
  export {
1944
2370
  RUNTIME_TARGET_SCHEMA_CAPABILITY_ROUTINES,
2371
+ RUNTIME_TARGET_SCHEMA_INVOKER_ROUTINES,
1945
2372
  FORCE_RLS_TABLES,
1946
2373
  NON_RLS_RUNTIME_TABLES,
1947
2374
  RUNTIME_FULL_DML_TABLES,
@@ -1959,4 +2386,4 @@ export {
1959
2386
  runtimeDatabaseReadyCheck,
1960
2387
  provisionRoles
1961
2388
  };
1962
- //# sourceMappingURL=chunk-YHZXQ7HP.js.map
2389
+ //# sourceMappingURL=chunk-VKLB2ZGI.js.map