@opengeni/db 3.2.0-canary.0 → 3.4.0-canary.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 (81) hide show
  1. package/dist/canonical-human-identities.js +3 -3
  2. package/dist/{chunk-SIBYBA2D.js → chunk-6DPJA36C.js} +30 -11
  3. package/dist/chunk-6DPJA36C.js.map +1 -0
  4. package/dist/{chunk-KRLPEMLH.js → chunk-C2AFP7SB.js} +184 -6
  5. package/dist/chunk-C2AFP7SB.js.map +1 -0
  6. package/dist/{chunk-AZHW7R5V.js → chunk-H7MXYG7R.js} +12 -8
  7. package/dist/chunk-H7MXYG7R.js.map +1 -0
  8. package/dist/{chunk-2PRS4J5Q.js → chunk-HY3F5Q4E.js} +3 -3
  9. package/dist/{chunk-NAB6FKFN.js → chunk-O6FTELKH.js} +3 -3
  10. package/dist/{chunk-UZNXG44K.js → chunk-PYMY3AJW.js} +324 -8
  11. package/dist/chunk-PYMY3AJW.js.map +1 -0
  12. package/dist/{chunk-6HMM2R5T.js → chunk-TRBOWUG3.js} +98 -4
  13. package/dist/chunk-TRBOWUG3.js.map +1 -0
  14. package/dist/{chunk-E6CLMKEE.js → chunk-V3TRUXFJ.js} +2 -2
  15. package/dist/{chunk-2EH4WRHL.js → chunk-ZWRIPCTR.js} +2 -2
  16. package/dist/editable-artifact-durable-export.js +2 -2
  17. package/dist/editable-artifacts.js +3 -3
  18. package/dist/governed-learning-activation.d.ts +16 -0
  19. package/dist/index.d.ts +108 -7
  20. package/dist/index.js +3605 -1417
  21. package/dist/index.js.map +1 -1
  22. package/dist/insights-model-bundle.d.ts +30 -0
  23. package/dist/insights-usage-bundle.d.ts +32 -0
  24. package/dist/insights.d.ts +10 -2
  25. package/dist/lossless-json.d.ts +1 -1
  26. package/dist/managed-user-setup.d.ts +82 -0
  27. package/dist/memory-domain.d.ts +2 -2
  28. package/dist/migrate.d.ts +3 -1
  29. package/dist/migrate.js +1 -1
  30. package/dist/new-session-drafts.d.ts +4 -4
  31. package/dist/organization-membership-lifecycle.d.ts +60 -1
  32. package/dist/pr-review.d.ts +44 -3
  33. package/dist/provision-roles.js +1 -1
  34. package/dist/runtime-posture.d.ts +12 -7
  35. package/dist/schema.d.ts +839 -101
  36. package/dist/schema.js +9 -1
  37. package/dist/session-background-commands.js +3 -3
  38. package/dist/session-tenancy.d.ts +12 -1
  39. package/dist/session-tenancy.js +3 -3
  40. package/dist/video-generation.js +3 -3
  41. package/drizzle/0348_named_signup_and_user_setup.sql +838 -0
  42. package/drizzle/0349_greenfield_session_tenancy_activation.sql +792 -0
  43. package/drizzle/0350_organization_shared_workspace_administration.sql +889 -0
  44. package/drizzle/0351_organization_user_setup_delivery.sql +978 -0
  45. package/drizzle/0352_session_variable_set_attachments.sql +1661 -0
  46. package/drizzle/0353_automatic_session_title_policy_fence.sql +476 -0
  47. package/drizzle/0354_automatic_session_title_quarantine_index.sql +9 -0
  48. package/drizzle/0355_automatic_session_title_quarantine.sql +92 -0
  49. package/drizzle/0356_set_based_insights_session_visibility.sql +237 -0
  50. package/drizzle/0357_rig_platform_base_only.sql +44 -0
  51. package/drizzle/0358_pr_review_managed_github_app.sql +108 -0
  52. package/drizzle/0359_insights_force_rls_read_capability.sql +936 -0
  53. package/drizzle/0360_organization_identity_confirmation_prompt.sql +103 -0
  54. package/drizzle/0361_remember_knowledge_memory_materialization.sql +249 -0
  55. package/package.json +6 -6
  56. package/src/database.ts +12 -8
  57. package/src/governed-learning-activation.ts +74 -2
  58. package/src/index.ts +879 -92
  59. package/src/insights-model-bundle.ts +681 -0
  60. package/src/insights-usage-bundle.ts +240 -0
  61. package/src/insights.ts +265 -152
  62. package/src/lossless-json.ts +2 -1
  63. package/src/managed-user-setup.ts +316 -0
  64. package/src/memory-domain.ts +3 -3
  65. package/src/migrate.ts +38 -14
  66. package/src/new-session-drafts.ts +22 -15
  67. package/src/organization-membership-lifecycle.ts +253 -1
  68. package/src/pr-review.ts +449 -6
  69. package/src/provision-roles.ts +92 -0
  70. package/src/runtime-posture.ts +247 -4
  71. package/src/schema.ts +210 -4
  72. package/src/session-tenancy.ts +120 -2
  73. package/dist/chunk-6HMM2R5T.js.map +0 -1
  74. package/dist/chunk-AZHW7R5V.js.map +0 -1
  75. package/dist/chunk-KRLPEMLH.js.map +0 -1
  76. package/dist/chunk-SIBYBA2D.js.map +0 -1
  77. package/dist/chunk-UZNXG44K.js.map +0 -1
  78. /package/dist/{chunk-2PRS4J5Q.js.map → chunk-HY3F5Q4E.js.map} +0 -0
  79. /package/dist/{chunk-NAB6FKFN.js.map → chunk-O6FTELKH.js.map} +0 -0
  80. /package/dist/{chunk-E6CLMKEE.js.map → chunk-V3TRUXFJ.js.map} +0 -0
  81. /package/dist/{chunk-2EH4WRHL.js.map → chunk-ZWRIPCTR.js.map} +0 -0
@@ -114,7 +114,16 @@ var ARTIFACT_LIVE_TICKET_INTERNAL_ROUTINES = [
114
114
  var ARTIFACT_AUTHORIZATION_CAPABILITY_ROUTINES = [
115
115
  "authorize_editable_artifact_actor(uuid, uuid, text, text, text, text, text, text, integer, text, text, name)"
116
116
  ];
117
- var DEDICATED_ARTIFACT_CAPABILITY_ROUTINES = /* @__PURE__ */ new Set([
117
+ var AUTOMATIC_SESSION_TITLE_FANOUT_RUNTIME_ROUTINES = [
118
+ "claim_automatic_session_title_fanout_v1(integer)",
119
+ "mark_automatic_session_title_fanout_delivered_v1(uuid, uuid)",
120
+ "mark_automatic_session_title_fanout_failed_v1(uuid, uuid, text)"
121
+ ];
122
+ var AUTOMATIC_SESSION_TITLE_FANOUT_MIGRATION_ROUTINE = "enqueue_automatic_session_title_fanout_v1(uuid, uuid, uuid, uuid)";
123
+ var AUTOMATIC_SESSION_TITLE_POLICY_TRIGGER_ROUTINE = "enforce_automatic_session_title_policy_v1()";
124
+ var AUTOMATIC_SESSION_TITLE_FANOUT_OUTBOX_TABLE = "automatic_session_title_fanout_outbox_v1";
125
+ var AUTOMATIC_SESSION_TITLE_QUARANTINE_FENCE_ROUTINE = "acquire_automatic_session_title_quarantine_fences_v1(integer)";
126
+ var OWNER_INTERNAL_PRIVATE_ROUTINES = /* @__PURE__ */ new Set([
118
127
  ...ARTIFACT_OUTBOX_CAPABILITY_ROUTINES,
119
128
  ...ARTIFACT_MATERIALIZER_CAPABILITY_ROUTINES,
120
129
  ...ARTIFACT_LIVE_TICKET_INTERNAL_ROUTINES
@@ -146,7 +155,13 @@ var ORGANIZATION_MEMBERSHIP_LIFECYCLE_ROUTINES = [
146
155
  "get_self_organization_invitation(text, uuid)",
147
156
  "list_organization_invitations(uuid, text, uuid, integer)",
148
157
  "list_organization_members(uuid, text)",
158
+ "list_organization_administration_members(uuid, text)",
149
159
  "get_organization_administration_overview(uuid, text)",
160
+ "get_workspace_kind(uuid, uuid)",
161
+ "organization_workspace_command(jsonb)",
162
+ "resolve_organization_workspace_removal_subject(uuid, text, uuid)",
163
+ "prepare_organization_workspace_member_removal(jsonb)",
164
+ "record_organization_workspace_member_removal(jsonb, uuid, uuid)",
150
165
  "create_managed_organization(text, text, text, uuid)",
151
166
  "assert_organization_shared_workspace_administrator(uuid, uuid, text)",
152
167
  "open_organization_shared_workspace_administration_capability(uuid, uuid, text)",
@@ -158,6 +173,15 @@ var ORGANIZATION_MEMBERSHIP_LIFECYCLE_ROUTINES = [
158
173
  "bind_pending_organization_invitations_for_verified_email(text, text)",
159
174
  "has_pending_organization_invitation_for_subject(text)",
160
175
  "accept_organization_invitation_v2(jsonb)",
176
+ "complete_self_service_organization_setup(jsonb)",
177
+ "ensure_organization_user_setup_intent(jsonb)",
178
+ "claim_organization_user_setup_delivery(jsonb)",
179
+ "prepare_organization_user_setup_delivery(jsonb)",
180
+ "settle_organization_user_setup_delivery(jsonb)",
181
+ "preview_organization_user_setup(text)",
182
+ "get_organization_invitation_for_administration(uuid, text, uuid)",
183
+ "preflight_organization_user_setup(text)",
184
+ "complete_organization_user_setup(jsonb)",
161
185
  "organization_membership_command(jsonb)",
162
186
  "prepare_organization_membership_protocol_settlements(jsonb)",
163
187
  "assert_active_managed_human_organization_membership(uuid, text)",
@@ -181,13 +205,19 @@ var ORGANIZATION_MEMBERSHIP_LIFECYCLE_AUTHORITY_TABLES = [
181
205
  "organization_memberships",
182
206
  "organization_profile_events",
183
207
  "organization_shared_workspace_administration_capabilities",
208
+ "organization_user_setup_deliveries",
209
+ "organization_user_setup_delivery_attempts",
210
+ "organization_user_setup_intents",
184
211
  "organization_user_resource_authorities",
185
212
  "organization_user_resource_grants",
186
213
  "organization_user_retention_deletion_events",
187
214
  "organization_user_retention_deletions",
188
215
  "organization_user_retention_object_deletion_receipts",
189
216
  "organization_user_retention_object_obligations",
190
- "organization_user_retention_policies"
217
+ "organization_user_retention_policies",
218
+ "organization_workspace_lifecycle_events",
219
+ "organization_workspace_operation_receipts",
220
+ "self_service_organization_setup_receipts"
191
221
  ];
192
222
  var PRIVATE_SESSION_CREATE_POLICY_ROUTINE = "get_private_session_create_policy(uuid, uuid, text)";
193
223
  var ORGANIZATION_PRIVATE_SESSION_SETTINGS_READ_ROUTINE = "get_organization_private_session_settings(uuid, text)";
@@ -367,6 +397,7 @@ var GOVERNED_LEARNING_ACTIVATION_ROUTINES = [
367
397
  "activate_governed_learning_decision(uuid, uuid, uuid, uuid)",
368
398
  "activate_human_confirmed_learning_decision(uuid, uuid, uuid, uuid, uuid)",
369
399
  "confirm_remember_knowledge_claim(uuid, uuid, uuid, uuid, integer, uuid, uuid, uuid)",
400
+ "materialize_remember_knowledge_memory(uuid, uuid, uuid)",
370
401
  "undo_governed_learning_activation(uuid, uuid, uuid, uuid)"
371
402
  ];
372
403
  var GOVERNED_LEARNING_INSPECTION_ROUTINES = [
@@ -429,6 +460,7 @@ var GOVERNED_LEARNING_ACTIVATION_AUTHORITY_TABLES = [
429
460
  "preference_registry_preferences",
430
461
  "preference_registry_revisions",
431
462
  "remember_knowledge_confirmation_receipts",
463
+ "remember_knowledge_memory_materializations",
432
464
  "session_human_input_requests",
433
465
  "workspace_instruction_policy_activation_events",
434
466
  "workspace_instruction_policy_deactivation_events",
@@ -446,6 +478,7 @@ var SESSION_TENANCY_ACTIVATED_ROUTINE = "session_tenancy_product_activated(uuid,
446
478
  var SESSION_TENANCY_ANY_ACTIVATION_ROUTINE = "session_tenancy_any_product_activation()";
447
479
  var SESSION_TENANCY_QUIESCENCE_ROUTINE = "assert_session_tenancy_quiescent(uuid, uuid, uuid, boolean)";
448
480
  var TENANCY_BACKFILL_ACTIVATION_EVIDENCE_ROUTINE = "check_tenancy_backfill_activation_evidence(uuid)";
481
+ var GREENFIELD_SESSION_TENANCY_ACTIVATION_ROUTINE = "activate_greenfield_session_tenancy_from_setup(text)";
449
482
  var SESSION_VISIBILITY_LIFECYCLE_CAPABILITY_ROUTINE = "session_visibility_lifecycle_capability_held()";
450
483
  var PRIVATE_SESSION_CREATE_CAPABILITY_ROUTINES = [
451
484
  "open_private_session_create_capability(uuid, uuid, uuid, text)",
@@ -535,7 +568,9 @@ var RUNTIME_TARGET_SCHEMA_PUBLIC_POLICY_PREDICATE_ROUTINE_SET = new Set(
535
568
  RUNTIME_TARGET_SCHEMA_PUBLIC_POLICY_PREDICATE_ROUTINES
536
569
  );
537
570
  var RUNTIME_TARGET_SCHEMA_FORBIDDEN_ROUTINES = [
571
+ AUTOMATIC_SESSION_TITLE_QUARANTINE_FENCE_ROUTINE,
538
572
  ORGANIZATION_PRIVATE_SESSIONS_ENABLED_ROUTINE,
573
+ GREENFIELD_SESSION_TENANCY_ACTIVATION_ROUTINE,
539
574
  SESSION_TENANCY_QUIESCENCE_ROUTINE,
540
575
  TENANCY_BACKFILL_ACTIVATION_EVIDENCE_ROUTINE,
541
576
  ...DOCUMENT_MIGRATION_AUDIT_INTERNAL_ROUTINES
@@ -713,6 +748,11 @@ var FORCE_RLS_TABLES = [
713
748
  "organization_user_retention_object_deletion_receipts",
714
749
  "organization_user_retention_object_obligations",
715
750
  "organization_user_retention_policies",
751
+ "organization_user_setup_deliveries",
752
+ "organization_user_setup_delivery_attempts",
753
+ "organization_user_setup_intents",
754
+ "organization_workspace_lifecycle_events",
755
+ "organization_workspace_operation_receipts",
716
756
  "pack_installation_components",
717
757
  "pack_installations",
718
758
  "personal_document_once_consumption_receipts",
@@ -721,6 +761,7 @@ var FORCE_RLS_TABLES = [
721
761
  "personal_github_repository_selections",
722
762
  "personal_resource_once_consumption_receipts",
723
763
  "pr_review_app_registrations",
764
+ "pr_review_managed_github_authority_nonces",
724
765
  "pr_review_repository_bindings",
725
766
  "preference_registry_events",
726
767
  "preference_registry_preferences",
@@ -728,6 +769,7 @@ var FORCE_RLS_TABLES = [
728
769
  "preference_registry_snapshots",
729
770
  "private_session_create_capabilities",
730
771
  "remember_knowledge_confirmation_receipts",
772
+ "remember_knowledge_memory_materializations",
731
773
  "retained_screenshot_artifacts",
732
774
  "rig_changes",
733
775
  "rig_versions",
@@ -751,6 +793,7 @@ var FORCE_RLS_TABLES = [
751
793
  "scheduled_task_run_personal_resource_snapshots",
752
794
  "scheduled_task_runs",
753
795
  "scheduled_tasks",
796
+ "self_service_organization_setup_receipts",
754
797
  "session_attempt_codemode_calls",
755
798
  "session_attempt_connected_machine_authorizations",
756
799
  "session_attempt_interruptions",
@@ -780,9 +823,11 @@ var FORCE_RLS_TABLES = [
780
823
  "session_system_update_outbox",
781
824
  "session_system_updates",
782
825
  "session_tenancy_activations",
826
+ "session_tenancy_greenfield_activation_evidence",
783
827
  "session_turn_attempts",
784
828
  "session_turn_startup_milestones",
785
829
  "session_turns",
830
+ "session_variable_set_attachments",
786
831
  "session_visibility_write_capabilities",
787
832
  "session_workflow_wake_outbox",
788
833
  "sessions",
@@ -869,6 +914,7 @@ var NON_RLS_RUNTIME_TABLES = [
869
914
  "integration_oauth_clients",
870
915
  "managed_accounts",
871
916
  "nested_agent_depth_configuration",
917
+ "pr_review_managed_github_routes",
872
918
  "stripe_webhook_events",
873
919
  "workspace_memberships",
874
920
  "workspaces"
@@ -947,6 +993,7 @@ var RUNTIME_FULL_DML_TABLES = [
947
993
  "pack_installation_components",
948
994
  "pack_installations",
949
995
  "pr_review_app_registrations",
996
+ "pr_review_managed_github_routes",
950
997
  "pr_review_repository_bindings",
951
998
  "retained_screenshot_artifacts",
952
999
  "rig_changes",
@@ -1079,6 +1126,7 @@ var RUNTIME_READ_INSERT_TABLES = [
1079
1126
  "knowledge_source_objects",
1080
1127
  "knowledge_sources",
1081
1128
  "knowledge_sync_runs",
1129
+ "pr_review_managed_github_authority_nonces",
1082
1130
  "preference_registry_preferences",
1083
1131
  "preference_registry_revisions",
1084
1132
  "session_attempt_tool_catalogs",
@@ -1169,6 +1217,11 @@ var PROTECTED_NO_DIRECT_DML_TABLES = [
1169
1217
  "organization_user_retention_object_deletion_receipts",
1170
1218
  "organization_user_retention_object_obligations",
1171
1219
  "organization_user_retention_policies",
1220
+ "organization_user_setup_deliveries",
1221
+ "organization_user_setup_delivery_attempts",
1222
+ "organization_user_setup_intents",
1223
+ "organization_workspace_lifecycle_events",
1224
+ "organization_workspace_operation_receipts",
1172
1225
  "personal_document_once_consumption_receipts",
1173
1226
  "personal_github_repository_selection_heads",
1174
1227
  "personal_github_repository_selection_operations",
@@ -1176,6 +1229,7 @@ var PROTECTED_NO_DIRECT_DML_TABLES = [
1176
1229
  "personal_resource_once_consumption_receipts",
1177
1230
  "private_session_create_capabilities",
1178
1231
  "remember_knowledge_confirmation_receipts",
1232
+ "remember_knowledge_memory_materializations",
1179
1233
  "scheduled_task_connection_authority_snapshots",
1180
1234
  "scheduled_task_personal_resource_authorities",
1181
1235
  "scheduled_task_personal_resource_snapshots",
@@ -1185,11 +1239,14 @@ var PROTECTED_NO_DIRECT_DML_TABLES = [
1185
1239
  "scheduled_task_run_personal_resource_admissions",
1186
1240
  "scheduled_task_run_personal_resource_once_receipts",
1187
1241
  "scheduled_task_run_personal_resource_snapshots",
1242
+ "self_service_organization_setup_receipts",
1188
1243
  "session_attempt_connected_machine_authorizations",
1189
1244
  "session_attempt_personal_document_admissions",
1190
1245
  "session_attempt_personal_document_snapshots",
1191
1246
  "session_attempt_personal_resource_admissions",
1192
1247
  "session_attempt_personal_resource_snapshots",
1248
+ "session_tenancy_greenfield_activation_evidence",
1249
+ "session_variable_set_attachments",
1193
1250
  "session_visibility_write_capabilities",
1194
1251
  "task_note_events",
1195
1252
  "task_note_knowledge_promotion_capabilities",
@@ -1297,6 +1354,14 @@ async function inspectRuntimeDatabasePosture(db, options) {
1297
1354
  await tx.execute(sql`select session_tenancy_any_product_activation() as activated`)
1298
1355
  );
1299
1356
  const sessionTenancyProductActivationPresent = activationRows[0]?.activated === true;
1357
+ const variableSetCutoverRows = resultRows(
1358
+ await tx.execute(sql`
1359
+ select to_regprocedure(
1360
+ 'opengeni_private.session_variable_set_attachments_protocol_v1_active()'
1361
+ ) is not null as present
1362
+ `)
1363
+ );
1364
+ const sessionVariableSetAttachmentsCutoverPresent = variableSetCutoverRows[0]?.present === true;
1300
1365
  if (options.rlsStrategy === "scoped") {
1301
1366
  return {
1302
1367
  identity: mappedIdentity,
@@ -1308,7 +1373,8 @@ async function inspectRuntimeDatabasePosture(db, options) {
1308
1373
  privateTables: [],
1309
1374
  targetRoutines: [],
1310
1375
  privateRoutines: [],
1311
- sessionTenancyProductActivationPresent
1376
+ sessionTenancyProductActivationPresent,
1377
+ sessionVariableSetAttachmentsCutoverPresent
1312
1378
  };
1313
1379
  }
1314
1380
  const relationshipRows = resultRows(
@@ -1405,6 +1471,10 @@ async function inspectRuntimeDatabasePosture(db, options) {
1405
1471
  select
1406
1472
  c.relname::text as name,
1407
1473
  pg_get_userbyid(c.relowner)::text as owner,
1474
+ c.relrowsecurity as rls_enabled,
1475
+ c.relforcerowsecurity as rls_forced,
1476
+ row_security_active(c.oid) as rls_active,
1477
+ (select count(*)::int from pg_policy policy where policy.polrelid = c.oid) as policy_count,
1408
1478
  has_table_privilege(current_user, c.oid, 'SELECT') as can_select,
1409
1479
  has_table_privilege(current_user, c.oid, 'INSERT') as can_insert,
1410
1480
  has_table_privilege(current_user, c.oid, 'UPDATE') as can_update,
@@ -1420,12 +1490,17 @@ async function inspectRuntimeDatabasePosture(db, options) {
1420
1490
  ${PERSONAL_DOCUMENT_CAPABILITY_TABLE},
1421
1491
  ${DOCUMENT_MIGRATION_CAPABILITY_TABLE},
1422
1492
  ${SCOPED_COMPUTE_CAPABILITY_TABLE},
1423
- ${CONNECTION_TENANCY_BACKFILL_CAPABILITY_TABLE}
1493
+ ${CONNECTION_TENANCY_BACKFILL_CAPABILITY_TABLE},
1494
+ ${AUTOMATIC_SESSION_TITLE_FANOUT_OUTBOX_TABLE}
1424
1495
  )
1425
1496
  `)
1426
1497
  ).map((row) => ({
1427
1498
  name: row.name,
1428
1499
  owner: row.owner,
1500
+ rlsEnabled: row.rls_enabled,
1501
+ rlsForced: row.rls_forced,
1502
+ rlsActive: row.rls_active,
1503
+ policyCount: row.policy_count,
1429
1504
  select: row.can_select,
1430
1505
  insert: row.can_insert,
1431
1506
  update: row.can_update,
@@ -1502,7 +1577,8 @@ async function inspectRuntimeDatabasePosture(db, options) {
1502
1577
  privateTables,
1503
1578
  targetRoutines,
1504
1579
  privateRoutines,
1505
- sessionTenancyProductActivationPresent
1580
+ sessionTenancyProductActivationPresent,
1581
+ sessionVariableSetAttachmentsCutoverPresent
1506
1582
  };
1507
1583
  },
1508
1584
  { isolationLevel: "repeatable read", accessMode: "read only" }
@@ -1511,6 +1587,9 @@ async function inspectRuntimeDatabasePosture(db, options) {
1511
1587
  function evaluateRuntimeDatabasePosture(posture, options) {
1512
1588
  const violations = [];
1513
1589
  const identity = posture.identity;
1590
+ if (!posture.sessionVariableSetAttachmentsCutoverPresent) {
1591
+ violations.push("database is missing the 0352 session Variable Set attachment runtime receipt");
1592
+ }
1514
1593
  if (posture.sessionTenancyProductActivationPresent && options.organizationTenancyCanonicalActivationEnabled !== true) {
1515
1594
  violations.push(
1516
1595
  "session-tenancy product activation is durable but OPENGENI_ORGANIZATION_TENANCY_CANONICAL_ACTIVATION_ENABLED is not true"
@@ -2088,6 +2167,151 @@ function evaluateRuntimeDatabasePosture(posture, options) {
2088
2167
  }
2089
2168
  }
2090
2169
  }
2170
+ const automaticTitleFanoutOutboxes = posture.privateTables.filter(
2171
+ (table) => table.name === AUTOMATIC_SESSION_TITLE_FANOUT_OUTBOX_TABLE
2172
+ );
2173
+ const automaticTitleFanoutRoutineNames = /* @__PURE__ */ new Set([
2174
+ ...AUTOMATIC_SESSION_TITLE_FANOUT_RUNTIME_ROUTINES,
2175
+ AUTOMATIC_SESSION_TITLE_FANOUT_MIGRATION_ROUTINE,
2176
+ AUTOMATIC_SESSION_TITLE_POLICY_TRIGGER_ROUTINE
2177
+ ]);
2178
+ const automaticTitleFanoutCatalogPresent = posture.privateRoutines.some(
2179
+ (routine) => automaticTitleFanoutRoutineNames.has(routine.name)
2180
+ );
2181
+ if (automaticTitleFanoutCatalogPresent && automaticTitleFanoutOutboxes.length !== 1) {
2182
+ violations.push(
2183
+ `automatic session title fanout private outbox ${AUTOMATIC_SESSION_TITLE_FANOUT_OUTBOX_TABLE} is missing or ambiguous`
2184
+ );
2185
+ }
2186
+ const automaticTitleFanoutOutbox = automaticTitleFanoutOutboxes[0];
2187
+ if (automaticTitleFanoutOutbox) {
2188
+ if (automaticTitleFanoutOutbox.owner === expectedRole) {
2189
+ violations.push(
2190
+ `runtime role owns private automatic session title fanout outbox ${automaticTitleFanoutOutbox.name}`
2191
+ );
2192
+ }
2193
+ if (!automaticTitleFanoutOutbox.rlsEnabled) {
2194
+ violations.push(
2195
+ `private automatic session title fanout outbox ${automaticTitleFanoutOutbox.name} does not ENABLE RLS`
2196
+ );
2197
+ }
2198
+ if (!automaticTitleFanoutOutbox.rlsForced) {
2199
+ violations.push(
2200
+ `private automatic session title fanout outbox ${automaticTitleFanoutOutbox.name} does not FORCE RLS`
2201
+ );
2202
+ }
2203
+ if (!automaticTitleFanoutOutbox.rlsActive) {
2204
+ violations.push(
2205
+ `private automatic session title fanout outbox ${automaticTitleFanoutOutbox.name} has inactive RLS for runtime role`
2206
+ );
2207
+ }
2208
+ if ((automaticTitleFanoutOutbox.policyCount ?? 0) < 1) {
2209
+ violations.push(
2210
+ `private automatic session title fanout outbox ${automaticTitleFanoutOutbox.name} has no RLS policy`
2211
+ );
2212
+ }
2213
+ const directPrivileges = [
2214
+ ["SELECT", automaticTitleFanoutOutbox.select],
2215
+ ["INSERT", automaticTitleFanoutOutbox.insert],
2216
+ ["UPDATE", automaticTitleFanoutOutbox.update],
2217
+ ["DELETE", automaticTitleFanoutOutbox.delete]
2218
+ ].filter(([, granted]) => granted);
2219
+ if (directPrivileges.length > 0) {
2220
+ violations.push(
2221
+ `runtime role has forbidden direct privileges on private table ${automaticTitleFanoutOutbox.name}: ${directPrivileges.map(([privilege]) => privilege).join(", ")}`
2222
+ );
2223
+ }
2224
+ for (const expectedRoutine of AUTOMATIC_SESSION_TITLE_FANOUT_RUNTIME_ROUTINES) {
2225
+ const matches = posture.privateRoutines.filter((routine2) => routine2.name === expectedRoutine);
2226
+ if (matches.length !== 1) {
2227
+ violations.push(
2228
+ `automatic session title fanout capability ${expectedRoutine} is missing or ambiguous`
2229
+ );
2230
+ continue;
2231
+ }
2232
+ const routine = matches[0];
2233
+ if (!routine.securityDefiner) {
2234
+ violations.push(
2235
+ `automatic session title fanout capability ${routine.name} is not SECURITY DEFINER`
2236
+ );
2237
+ }
2238
+ if (routine.owner !== automaticTitleFanoutOutbox.owner) {
2239
+ violations.push(
2240
+ `automatic session title fanout capability ${routine.name} owner ${routine.owner} does not match table owner ${automaticTitleFanoutOutbox.owner}`
2241
+ );
2242
+ }
2243
+ if (!routine.execute) {
2244
+ violations.push(
2245
+ `runtime role lacks automatic session title fanout capability ${routine.name}`
2246
+ );
2247
+ }
2248
+ if (routine.publicExecute) {
2249
+ violations.push(
2250
+ `PUBLIC has forbidden automatic session title fanout capability ${routine.name}`
2251
+ );
2252
+ }
2253
+ }
2254
+ const enqueueMatches = posture.privateRoutines.filter(
2255
+ (routine) => routine.name === AUTOMATIC_SESSION_TITLE_FANOUT_MIGRATION_ROUTINE
2256
+ );
2257
+ if (enqueueMatches.length !== 1) {
2258
+ violations.push(
2259
+ `automatic session title fanout migration helper ${AUTOMATIC_SESSION_TITLE_FANOUT_MIGRATION_ROUTINE} is missing or ambiguous`
2260
+ );
2261
+ } else {
2262
+ const routine = enqueueMatches[0];
2263
+ if (routine.securityDefiner) {
2264
+ violations.push(
2265
+ `automatic session title fanout migration helper ${routine.name} must be SECURITY INVOKER`
2266
+ );
2267
+ }
2268
+ if (routine.owner !== automaticTitleFanoutOutbox.owner) {
2269
+ violations.push(
2270
+ `automatic session title fanout migration helper ${routine.name} owner ${routine.owner} does not match table owner ${automaticTitleFanoutOutbox.owner}`
2271
+ );
2272
+ }
2273
+ if (!routine.execute) {
2274
+ violations.push(
2275
+ `runtime role lacks rolling-compatible automatic session title fanout migration helper ${routine.name}`
2276
+ );
2277
+ }
2278
+ if (routine.publicExecute) {
2279
+ violations.push(
2280
+ `PUBLIC has forbidden automatic session title fanout migration helper ${routine.name}`
2281
+ );
2282
+ }
2283
+ }
2284
+ const policyTriggerMatches = posture.privateRoutines.filter(
2285
+ (routine) => routine.name === AUTOMATIC_SESSION_TITLE_POLICY_TRIGGER_ROUTINE
2286
+ );
2287
+ if (policyTriggerMatches.length !== 1) {
2288
+ violations.push(
2289
+ `automatic session title policy trigger ${AUTOMATIC_SESSION_TITLE_POLICY_TRIGGER_ROUTINE} is missing or ambiguous`
2290
+ );
2291
+ } else {
2292
+ const routine = policyTriggerMatches[0];
2293
+ if (routine.securityDefiner) {
2294
+ violations.push(
2295
+ `automatic session title policy trigger ${routine.name} must be SECURITY INVOKER`
2296
+ );
2297
+ }
2298
+ if (routine.owner !== automaticTitleFanoutOutbox.owner) {
2299
+ violations.push(
2300
+ `automatic session title policy trigger ${routine.name} owner ${routine.owner} does not match table owner ${automaticTitleFanoutOutbox.owner}`
2301
+ );
2302
+ }
2303
+ if (!routine.execute) {
2304
+ violations.push(
2305
+ `runtime role lacks rolling-compatible automatic session title policy trigger ${routine.name}`
2306
+ );
2307
+ }
2308
+ if (routine.publicExecute) {
2309
+ violations.push(
2310
+ `PUBLIC has forbidden automatic session title policy trigger ${routine.name}`
2311
+ );
2312
+ }
2313
+ }
2314
+ }
2091
2315
  const artifactMaterializationJobs = tableByName.get("editable_artifact_materialization_jobs");
2092
2316
  if (artifactMaterializationJobs) {
2093
2317
  for (const tableName of [
@@ -2576,8 +2800,8 @@ function evaluateRuntimeDatabasePosture(posture, options) {
2576
2800
  if (routine.owner === expectedRole) {
2577
2801
  violations.push(`runtime role owns private routine ${routine.name}`);
2578
2802
  }
2579
- const dedicatedArtifactCapability = DEDICATED_ARTIFACT_CAPABILITY_ROUTINES.has(routine.name);
2580
- if (!routine.execute && !dedicatedArtifactCapability) {
2803
+ const ownerInternalRoutine = OWNER_INTERNAL_PRIVATE_ROUTINES.has(routine.name);
2804
+ if (!routine.execute && !ownerInternalRoutine) {
2581
2805
  violations.push(`runtime role lacks EXECUTE on private routine ${routine.name}`);
2582
2806
  }
2583
2807
  }
@@ -2916,8 +3140,14 @@ async function grantAppRoleIfSchemaExists(sql2, role, schema) {
2916
3140
  "list_self_organization_invitations(text,uuid,integer)",
2917
3141
  "get_self_organization_invitation(text,uuid)",
2918
3142
  "list_organization_members(uuid,text)",
3143
+ "list_organization_administration_members(uuid,text)",
2919
3144
  "list_organization_invitations(uuid,text,uuid,integer)",
2920
3145
  "get_organization_administration_overview(uuid,text)",
3146
+ "get_workspace_kind(uuid,uuid)",
3147
+ "organization_workspace_command(jsonb)",
3148
+ "resolve_organization_workspace_removal_subject(uuid,text,uuid)",
3149
+ "prepare_organization_workspace_member_removal(jsonb)",
3150
+ "record_organization_workspace_member_removal(jsonb,uuid,uuid)",
2921
3151
  "create_managed_organization(text,text,text,uuid)",
2922
3152
  "assert_organization_shared_workspace_administrator(uuid,uuid,text)",
2923
3153
  "open_organization_shared_workspace_administration_capability(uuid,uuid,text)",
@@ -2929,6 +3159,15 @@ async function grantAppRoleIfSchemaExists(sql2, role, schema) {
2929
3159
  "bind_pending_organization_invitations_for_verified_email(text,text)",
2930
3160
  "has_pending_organization_invitation_for_subject(text)",
2931
3161
  "accept_organization_invitation_v2(jsonb)",
3162
+ "complete_self_service_organization_setup(jsonb)",
3163
+ "ensure_organization_user_setup_intent(jsonb)",
3164
+ "claim_organization_user_setup_delivery(jsonb)",
3165
+ "prepare_organization_user_setup_delivery(jsonb)",
3166
+ "settle_organization_user_setup_delivery(jsonb)",
3167
+ "preview_organization_user_setup(text)",
3168
+ "get_organization_invitation_for_administration(uuid,text,uuid)",
3169
+ "preflight_organization_user_setup(text)",
3170
+ "complete_organization_user_setup(jsonb)",
2932
3171
  "organization_membership_command(jsonb)",
2933
3172
  "prepare_organization_membership_protocol_settlements(jsonb)",
2934
3173
  "assert_active_managed_human_organization_membership(uuid,text)",
@@ -3310,6 +3549,19 @@ BEGIN
3310
3549
  ${literal(role)}
3311
3550
  );
3312
3551
  END IF;
3552
+ IF to_regprocedure(
3553
+ format('%I.materialize_remember_knowledge_memory(uuid,uuid,uuid)', ${literal(schema)})
3554
+ ) IS NOT NULL THEN
3555
+ EXECUTE format(
3556
+ 'REVOKE ALL ON FUNCTION %I.materialize_remember_knowledge_memory(uuid, uuid, uuid) FROM PUBLIC',
3557
+ ${literal(schema)}
3558
+ );
3559
+ EXECUTE format(
3560
+ 'GRANT EXECUTE ON FUNCTION %I.materialize_remember_knowledge_memory(uuid, uuid, uuid) TO %I',
3561
+ ${literal(schema)},
3562
+ ${literal(role)}
3563
+ );
3564
+ END IF;
3313
3565
  IF to_regprocedure(
3314
3566
  format('%I.undo_governed_learning_activation(uuid,uuid,uuid,uuid)', ${literal(schema)})
3315
3567
  ) IS NOT NULL THEN
@@ -3724,6 +3976,38 @@ BEGIN
3724
3976
  ${literal(role)}
3725
3977
  );
3726
3978
  END IF;
3979
+ IF to_regprocedure(
3980
+ format(
3981
+ '%I.fork_session_content_with_runtime(uuid,uuid,uuid,text,uuid,text,boolean,text,text,integer,jsonb,uuid,uuid,text)',
3982
+ ${literal(schema)}
3983
+ )
3984
+ ) IS NOT NULL THEN
3985
+ EXECUTE format(
3986
+ 'REVOKE ALL ON FUNCTION %I.fork_session_content_with_runtime(uuid, uuid, uuid, text, uuid, text, boolean, text, text, integer, jsonb, uuid, uuid, text) FROM PUBLIC',
3987
+ ${literal(schema)}
3988
+ );
3989
+ EXECUTE format(
3990
+ 'GRANT EXECUTE ON FUNCTION %I.fork_session_content_with_runtime(uuid, uuid, uuid, text, uuid, text, boolean, text, text, integer, jsonb, uuid, uuid, text) TO %I',
3991
+ ${literal(schema)},
3992
+ ${literal(role)}
3993
+ );
3994
+ END IF;
3995
+ IF to_regprocedure(
3996
+ format(
3997
+ '%I.replay_applied_session_fork_with_runtime(uuid,uuid,uuid,text,uuid,text,boolean,text,text,integer,text)',
3998
+ ${literal(schema)}
3999
+ )
4000
+ ) IS NOT NULL THEN
4001
+ EXECUTE format(
4002
+ 'REVOKE ALL ON FUNCTION %I.replay_applied_session_fork_with_runtime(uuid, uuid, uuid, text, uuid, text, boolean, text, text, integer, text) FROM PUBLIC',
4003
+ ${literal(schema)}
4004
+ );
4005
+ EXECUTE format(
4006
+ 'GRANT EXECUTE ON FUNCTION %I.replay_applied_session_fork_with_runtime(uuid, uuid, uuid, text, uuid, text, boolean, text, text, integer, text) TO %I',
4007
+ ${literal(schema)},
4008
+ ${literal(role)}
4009
+ );
4010
+ END IF;
3727
4011
  IF to_regprocedure(
3728
4012
  format('%I.session_tenancy_product_activated(uuid,integer)', ${literal(schema)})
3729
4013
  ) IS NOT NULL THEN
@@ -4347,6 +4631,15 @@ BEGIN
4347
4631
  ${literal(role)}
4348
4632
  );
4349
4633
  END IF;
4634
+ IF to_regprocedure('opengeni_private.session_variable_set_attachments_protocol_v1_active()') IS NOT NULL THEN
4635
+ REVOKE ALL ON FUNCTION
4636
+ opengeni_private.session_variable_set_attachments_protocol_v1_active()
4637
+ FROM PUBLIC;
4638
+ EXECUTE format(
4639
+ 'GRANT EXECUTE ON FUNCTION opengeni_private.session_variable_set_attachments_protocol_v1_active() TO %I',
4640
+ ${literal(role)}
4641
+ );
4642
+ END IF;
4350
4643
  IF to_regprocedure('opengeni_private.scoped_compute_capability_active(text)') IS NOT NULL THEN
4351
4644
  REVOKE ALL ON FUNCTION opengeni_private.scoped_compute_capability_active(text) FROM PUBLIC;
4352
4645
  EXECUTE format(
@@ -4358,6 +4651,29 @@ BEGIN
4358
4651
  ${literal(role)}
4359
4652
  );
4360
4653
  END IF;
4654
+ -- The automatic-title migration helper and policy trigger deliberately
4655
+ -- retain role-scoped EXECUTE for pre-policy startup/readiness
4656
+ -- compatibility. Both are SECURITY INVOKER and PUBLIC remains revoked; RLS
4657
+ -- and the private-table ACL deny app-role enqueue writes, while PostgreSQL
4658
+ -- refuses direct trigger calls, so neither grant conveys data authority.
4659
+ IF to_regclass('opengeni_private.automatic_session_title_fanout_outbox_v1') IS NOT NULL THEN
4660
+ EXECUTE format(
4661
+ 'REVOKE ALL PRIVILEGES ON TABLE opengeni_private.automatic_session_title_fanout_outbox_v1 FROM %I',
4662
+ ${literal(role)}
4663
+ );
4664
+ END IF;
4665
+ IF to_regprocedure('opengeni_private.enqueue_automatic_session_title_fanout_v1(uuid,uuid,uuid,uuid)') IS NOT NULL THEN
4666
+ EXECUTE format(
4667
+ 'GRANT EXECUTE ON FUNCTION opengeni_private.enqueue_automatic_session_title_fanout_v1(uuid, uuid, uuid, uuid) TO %I',
4668
+ ${literal(role)}
4669
+ );
4670
+ END IF;
4671
+ IF to_regprocedure('opengeni_private.enforce_automatic_session_title_policy_v1()') IS NOT NULL THEN
4672
+ EXECUTE format(
4673
+ 'GRANT EXECUTE ON FUNCTION opengeni_private.enforce_automatic_session_title_policy_v1() TO %I',
4674
+ ${literal(role)}
4675
+ );
4676
+ END IF;
4361
4677
  -- Global cross-workspace artifact workers are separate capabilities. Never
4362
4678
  -- let the generic tenant-scoped app role inherit them from the historical
4363
4679
  -- blanket grant of already-installed helpers.
@@ -4505,4 +4821,4 @@ export {
4505
4821
  runtimeDatabaseReadyCheck,
4506
4822
  provisionRoles
4507
4823
  };
4508
- //# sourceMappingURL=chunk-UZNXG44K.js.map
4824
+ //# sourceMappingURL=chunk-PYMY3AJW.js.map