@opengeni/db 3.2.0-canary.0 → 3.4.0-canary.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/canonical-human-identities.js +3 -3
- package/dist/{chunk-SIBYBA2D.js → chunk-6DPJA36C.js} +30 -11
- package/dist/chunk-6DPJA36C.js.map +1 -0
- package/dist/{chunk-KRLPEMLH.js → chunk-C2AFP7SB.js} +184 -6
- package/dist/chunk-C2AFP7SB.js.map +1 -0
- package/dist/{chunk-AZHW7R5V.js → chunk-H7MXYG7R.js} +12 -8
- package/dist/chunk-H7MXYG7R.js.map +1 -0
- package/dist/{chunk-2PRS4J5Q.js → chunk-HY3F5Q4E.js} +3 -3
- package/dist/{chunk-NAB6FKFN.js → chunk-O6FTELKH.js} +3 -3
- package/dist/{chunk-UZNXG44K.js → chunk-PYMY3AJW.js} +324 -8
- package/dist/chunk-PYMY3AJW.js.map +1 -0
- package/dist/{chunk-6HMM2R5T.js → chunk-TRBOWUG3.js} +98 -4
- package/dist/chunk-TRBOWUG3.js.map +1 -0
- package/dist/{chunk-E6CLMKEE.js → chunk-V3TRUXFJ.js} +2 -2
- package/dist/{chunk-2EH4WRHL.js → chunk-ZWRIPCTR.js} +2 -2
- package/dist/editable-artifact-durable-export.js +2 -2
- package/dist/editable-artifacts.js +3 -3
- package/dist/governed-learning-activation.d.ts +16 -0
- package/dist/index.d.ts +108 -7
- package/dist/index.js +3605 -1417
- package/dist/index.js.map +1 -1
- package/dist/insights-model-bundle.d.ts +30 -0
- package/dist/insights-usage-bundle.d.ts +32 -0
- package/dist/insights.d.ts +10 -2
- package/dist/lossless-json.d.ts +1 -1
- package/dist/managed-user-setup.d.ts +82 -0
- package/dist/memory-domain.d.ts +2 -2
- package/dist/migrate.d.ts +3 -1
- package/dist/migrate.js +1 -1
- package/dist/new-session-drafts.d.ts +4 -4
- package/dist/organization-membership-lifecycle.d.ts +60 -1
- package/dist/pr-review.d.ts +44 -3
- package/dist/provision-roles.js +1 -1
- package/dist/runtime-posture.d.ts +12 -7
- package/dist/schema.d.ts +839 -101
- package/dist/schema.js +9 -1
- package/dist/session-background-commands.js +3 -3
- package/dist/session-tenancy.d.ts +12 -1
- package/dist/session-tenancy.js +3 -3
- package/dist/video-generation.js +3 -3
- package/drizzle/0348_named_signup_and_user_setup.sql +838 -0
- package/drizzle/0349_greenfield_session_tenancy_activation.sql +792 -0
- package/drizzle/0350_organization_shared_workspace_administration.sql +889 -0
- package/drizzle/0351_organization_user_setup_delivery.sql +978 -0
- package/drizzle/0352_session_variable_set_attachments.sql +1661 -0
- package/drizzle/0353_automatic_session_title_policy_fence.sql +476 -0
- package/drizzle/0354_automatic_session_title_quarantine_index.sql +9 -0
- package/drizzle/0355_automatic_session_title_quarantine.sql +92 -0
- package/drizzle/0356_set_based_insights_session_visibility.sql +237 -0
- package/drizzle/0357_rig_platform_base_only.sql +44 -0
- package/drizzle/0358_pr_review_managed_github_app.sql +108 -0
- package/drizzle/0359_insights_force_rls_read_capability.sql +936 -0
- package/drizzle/0360_organization_identity_confirmation_prompt.sql +103 -0
- package/drizzle/0361_remember_knowledge_memory_materialization.sql +249 -0
- package/package.json +6 -6
- package/src/database.ts +12 -8
- package/src/governed-learning-activation.ts +74 -2
- package/src/index.ts +879 -92
- package/src/insights-model-bundle.ts +681 -0
- package/src/insights-usage-bundle.ts +240 -0
- package/src/insights.ts +265 -152
- package/src/lossless-json.ts +2 -1
- package/src/managed-user-setup.ts +316 -0
- package/src/memory-domain.ts +3 -3
- package/src/migrate.ts +38 -14
- package/src/new-session-drafts.ts +22 -15
- package/src/organization-membership-lifecycle.ts +253 -1
- package/src/pr-review.ts +449 -6
- package/src/provision-roles.ts +92 -0
- package/src/runtime-posture.ts +247 -4
- package/src/schema.ts +210 -4
- package/src/session-tenancy.ts +120 -2
- package/dist/chunk-6HMM2R5T.js.map +0 -1
- package/dist/chunk-AZHW7R5V.js.map +0 -1
- package/dist/chunk-KRLPEMLH.js.map +0 -1
- package/dist/chunk-SIBYBA2D.js.map +0 -1
- package/dist/chunk-UZNXG44K.js.map +0 -1
- /package/dist/{chunk-2PRS4J5Q.js.map → chunk-HY3F5Q4E.js.map} +0 -0
- /package/dist/{chunk-NAB6FKFN.js.map → chunk-O6FTELKH.js.map} +0 -0
- /package/dist/{chunk-E6CLMKEE.js.map → chunk-V3TRUXFJ.js.map} +0 -0
- /package/dist/{chunk-2EH4WRHL.js.map → chunk-ZWRIPCTR.js.map} +0 -0
package/src/runtime-posture.ts
CHANGED
|
@@ -36,7 +36,22 @@ const ARTIFACT_AUTHORIZATION_CAPABILITY_ROUTINES = [
|
|
|
36
36
|
"authorize_editable_artifact_actor(uuid, uuid, text, text, text, text, text, text, integer, text, text, name)",
|
|
37
37
|
] as const;
|
|
38
38
|
|
|
39
|
-
const
|
|
39
|
+
const AUTOMATIC_SESSION_TITLE_FANOUT_RUNTIME_ROUTINES = [
|
|
40
|
+
"claim_automatic_session_title_fanout_v1(integer)",
|
|
41
|
+
"mark_automatic_session_title_fanout_delivered_v1(uuid, uuid)",
|
|
42
|
+
"mark_automatic_session_title_fanout_failed_v1(uuid, uuid, text)",
|
|
43
|
+
] as const;
|
|
44
|
+
|
|
45
|
+
const AUTOMATIC_SESSION_TITLE_FANOUT_MIGRATION_ROUTINE =
|
|
46
|
+
"enqueue_automatic_session_title_fanout_v1(uuid, uuid, uuid, uuid)";
|
|
47
|
+
|
|
48
|
+
const AUTOMATIC_SESSION_TITLE_POLICY_TRIGGER_ROUTINE =
|
|
49
|
+
"enforce_automatic_session_title_policy_v1()";
|
|
50
|
+
const AUTOMATIC_SESSION_TITLE_FANOUT_OUTBOX_TABLE = "automatic_session_title_fanout_outbox_v1";
|
|
51
|
+
const AUTOMATIC_SESSION_TITLE_QUARANTINE_FENCE_ROUTINE =
|
|
52
|
+
"acquire_automatic_session_title_quarantine_fences_v1(integer)";
|
|
53
|
+
|
|
54
|
+
const OWNER_INTERNAL_PRIVATE_ROUTINES = new Set<string>([
|
|
40
55
|
...ARTIFACT_OUTBOX_CAPABILITY_ROUTINES,
|
|
41
56
|
...ARTIFACT_MATERIALIZER_CAPABILITY_ROUTINES,
|
|
42
57
|
...ARTIFACT_LIVE_TICKET_INTERNAL_ROUTINES,
|
|
@@ -73,7 +88,13 @@ const ORGANIZATION_MEMBERSHIP_LIFECYCLE_ROUTINES = [
|
|
|
73
88
|
"get_self_organization_invitation(text, uuid)",
|
|
74
89
|
"list_organization_invitations(uuid, text, uuid, integer)",
|
|
75
90
|
"list_organization_members(uuid, text)",
|
|
91
|
+
"list_organization_administration_members(uuid, text)",
|
|
76
92
|
"get_organization_administration_overview(uuid, text)",
|
|
93
|
+
"get_workspace_kind(uuid, uuid)",
|
|
94
|
+
"organization_workspace_command(jsonb)",
|
|
95
|
+
"resolve_organization_workspace_removal_subject(uuid, text, uuid)",
|
|
96
|
+
"prepare_organization_workspace_member_removal(jsonb)",
|
|
97
|
+
"record_organization_workspace_member_removal(jsonb, uuid, uuid)",
|
|
77
98
|
"create_managed_organization(text, text, text, uuid)",
|
|
78
99
|
"assert_organization_shared_workspace_administrator(uuid, uuid, text)",
|
|
79
100
|
"open_organization_shared_workspace_administration_capability(uuid, uuid, text)",
|
|
@@ -85,6 +106,15 @@ const ORGANIZATION_MEMBERSHIP_LIFECYCLE_ROUTINES = [
|
|
|
85
106
|
"bind_pending_organization_invitations_for_verified_email(text, text)",
|
|
86
107
|
"has_pending_organization_invitation_for_subject(text)",
|
|
87
108
|
"accept_organization_invitation_v2(jsonb)",
|
|
109
|
+
"complete_self_service_organization_setup(jsonb)",
|
|
110
|
+
"ensure_organization_user_setup_intent(jsonb)",
|
|
111
|
+
"claim_organization_user_setup_delivery(jsonb)",
|
|
112
|
+
"prepare_organization_user_setup_delivery(jsonb)",
|
|
113
|
+
"settle_organization_user_setup_delivery(jsonb)",
|
|
114
|
+
"preview_organization_user_setup(text)",
|
|
115
|
+
"get_organization_invitation_for_administration(uuid, text, uuid)",
|
|
116
|
+
"preflight_organization_user_setup(text)",
|
|
117
|
+
"complete_organization_user_setup(jsonb)",
|
|
88
118
|
"organization_membership_command(jsonb)",
|
|
89
119
|
"prepare_organization_membership_protocol_settlements(jsonb)",
|
|
90
120
|
"assert_active_managed_human_organization_membership(uuid, text)",
|
|
@@ -108,6 +138,9 @@ const ORGANIZATION_MEMBERSHIP_LIFECYCLE_AUTHORITY_TABLES = [
|
|
|
108
138
|
"organization_memberships",
|
|
109
139
|
"organization_profile_events",
|
|
110
140
|
"organization_shared_workspace_administration_capabilities",
|
|
141
|
+
"organization_user_setup_deliveries",
|
|
142
|
+
"organization_user_setup_delivery_attempts",
|
|
143
|
+
"organization_user_setup_intents",
|
|
111
144
|
"organization_user_resource_authorities",
|
|
112
145
|
"organization_user_resource_grants",
|
|
113
146
|
"organization_user_retention_deletion_events",
|
|
@@ -115,6 +148,9 @@ const ORGANIZATION_MEMBERSHIP_LIFECYCLE_AUTHORITY_TABLES = [
|
|
|
115
148
|
"organization_user_retention_object_deletion_receipts",
|
|
116
149
|
"organization_user_retention_object_obligations",
|
|
117
150
|
"organization_user_retention_policies",
|
|
151
|
+
"organization_workspace_lifecycle_events",
|
|
152
|
+
"organization_workspace_operation_receipts",
|
|
153
|
+
"self_service_organization_setup_receipts",
|
|
118
154
|
] as const;
|
|
119
155
|
const PRIVATE_SESSION_CREATE_POLICY_ROUTINE = "get_private_session_create_policy(uuid, uuid, text)";
|
|
120
156
|
const ORGANIZATION_PRIVATE_SESSION_SETTINGS_READ_ROUTINE =
|
|
@@ -308,6 +344,7 @@ const GOVERNED_LEARNING_ACTIVATION_ROUTINES = [
|
|
|
308
344
|
"activate_governed_learning_decision(uuid, uuid, uuid, uuid)",
|
|
309
345
|
"activate_human_confirmed_learning_decision(uuid, uuid, uuid, uuid, uuid)",
|
|
310
346
|
"confirm_remember_knowledge_claim(uuid, uuid, uuid, uuid, integer, uuid, uuid, uuid)",
|
|
347
|
+
"materialize_remember_knowledge_memory(uuid, uuid, uuid)",
|
|
311
348
|
"undo_governed_learning_activation(uuid, uuid, uuid, uuid)",
|
|
312
349
|
] as const;
|
|
313
350
|
const GOVERNED_LEARNING_INSPECTION_ROUTINES = [
|
|
@@ -370,6 +407,7 @@ const GOVERNED_LEARNING_ACTIVATION_AUTHORITY_TABLES = [
|
|
|
370
407
|
"preference_registry_preferences",
|
|
371
408
|
"preference_registry_revisions",
|
|
372
409
|
"remember_knowledge_confirmation_receipts",
|
|
410
|
+
"remember_knowledge_memory_materializations",
|
|
373
411
|
"session_human_input_requests",
|
|
374
412
|
"workspace_instruction_policy_activation_events",
|
|
375
413
|
"workspace_instruction_policy_deactivation_events",
|
|
@@ -393,6 +431,8 @@ const SESSION_TENANCY_QUIESCENCE_ROUTINE =
|
|
|
393
431
|
"assert_session_tenancy_quiescent(uuid, uuid, uuid, boolean)";
|
|
394
432
|
const TENANCY_BACKFILL_ACTIVATION_EVIDENCE_ROUTINE =
|
|
395
433
|
"check_tenancy_backfill_activation_evidence(uuid)";
|
|
434
|
+
const GREENFIELD_SESSION_TENANCY_ACTIVATION_ROUTINE =
|
|
435
|
+
"activate_greenfield_session_tenancy_from_setup(text)";
|
|
396
436
|
const SESSION_VISIBILITY_LIFECYCLE_CAPABILITY_ROUTINE =
|
|
397
437
|
"session_visibility_lifecycle_capability_held()";
|
|
398
438
|
const PRIVATE_SESSION_CREATE_CAPABILITY_ROUTINES = [
|
|
@@ -497,7 +537,9 @@ const RUNTIME_TARGET_SCHEMA_PUBLIC_POLICY_PREDICATE_ROUTINE_SET = new Set<string
|
|
|
497
537
|
|
|
498
538
|
/** Owner-internal helpers that must exist but must never be callable by the runtime role. */
|
|
499
539
|
export const RUNTIME_TARGET_SCHEMA_FORBIDDEN_ROUTINES = [
|
|
540
|
+
AUTOMATIC_SESSION_TITLE_QUARANTINE_FENCE_ROUTINE,
|
|
500
541
|
ORGANIZATION_PRIVATE_SESSIONS_ENABLED_ROUTINE,
|
|
542
|
+
GREENFIELD_SESSION_TENANCY_ACTIVATION_ROUTINE,
|
|
501
543
|
SESSION_TENANCY_QUIESCENCE_ROUTINE,
|
|
502
544
|
TENANCY_BACKFILL_ACTIVATION_EVIDENCE_ROUTINE,
|
|
503
545
|
...DOCUMENT_MIGRATION_AUDIT_INTERNAL_ROUTINES,
|
|
@@ -682,6 +724,11 @@ export const FORCE_RLS_TABLES = [
|
|
|
682
724
|
"organization_user_retention_object_deletion_receipts",
|
|
683
725
|
"organization_user_retention_object_obligations",
|
|
684
726
|
"organization_user_retention_policies",
|
|
727
|
+
"organization_user_setup_deliveries",
|
|
728
|
+
"organization_user_setup_delivery_attempts",
|
|
729
|
+
"organization_user_setup_intents",
|
|
730
|
+
"organization_workspace_lifecycle_events",
|
|
731
|
+
"organization_workspace_operation_receipts",
|
|
685
732
|
"pack_installation_components",
|
|
686
733
|
"pack_installations",
|
|
687
734
|
"personal_document_once_consumption_receipts",
|
|
@@ -690,6 +737,7 @@ export const FORCE_RLS_TABLES = [
|
|
|
690
737
|
"personal_github_repository_selections",
|
|
691
738
|
"personal_resource_once_consumption_receipts",
|
|
692
739
|
"pr_review_app_registrations",
|
|
740
|
+
"pr_review_managed_github_authority_nonces",
|
|
693
741
|
"pr_review_repository_bindings",
|
|
694
742
|
"preference_registry_events",
|
|
695
743
|
"preference_registry_preferences",
|
|
@@ -697,6 +745,7 @@ export const FORCE_RLS_TABLES = [
|
|
|
697
745
|
"preference_registry_snapshots",
|
|
698
746
|
"private_session_create_capabilities",
|
|
699
747
|
"remember_knowledge_confirmation_receipts",
|
|
748
|
+
"remember_knowledge_memory_materializations",
|
|
700
749
|
"retained_screenshot_artifacts",
|
|
701
750
|
"rig_changes",
|
|
702
751
|
"rig_versions",
|
|
@@ -720,6 +769,7 @@ export const FORCE_RLS_TABLES = [
|
|
|
720
769
|
"scheduled_task_run_personal_resource_snapshots",
|
|
721
770
|
"scheduled_task_runs",
|
|
722
771
|
"scheduled_tasks",
|
|
772
|
+
"self_service_organization_setup_receipts",
|
|
723
773
|
"session_attempt_codemode_calls",
|
|
724
774
|
"session_attempt_connected_machine_authorizations",
|
|
725
775
|
"session_attempt_interruptions",
|
|
@@ -749,9 +799,11 @@ export const FORCE_RLS_TABLES = [
|
|
|
749
799
|
"session_system_update_outbox",
|
|
750
800
|
"session_system_updates",
|
|
751
801
|
"session_tenancy_activations",
|
|
802
|
+
"session_tenancy_greenfield_activation_evidence",
|
|
752
803
|
"session_turn_attempts",
|
|
753
804
|
"session_turn_startup_milestones",
|
|
754
805
|
"session_turns",
|
|
806
|
+
"session_variable_set_attachments",
|
|
755
807
|
"session_visibility_write_capabilities",
|
|
756
808
|
"session_workflow_wake_outbox",
|
|
757
809
|
"sessions",
|
|
@@ -844,6 +896,7 @@ export const NON_RLS_RUNTIME_TABLES = [
|
|
|
844
896
|
"integration_oauth_clients",
|
|
845
897
|
"managed_accounts",
|
|
846
898
|
"nested_agent_depth_configuration",
|
|
899
|
+
"pr_review_managed_github_routes",
|
|
847
900
|
"stripe_webhook_events",
|
|
848
901
|
"workspace_memberships",
|
|
849
902
|
"workspaces",
|
|
@@ -928,6 +981,7 @@ export const RUNTIME_FULL_DML_TABLES = [
|
|
|
928
981
|
"pack_installation_components",
|
|
929
982
|
"pack_installations",
|
|
930
983
|
"pr_review_app_registrations",
|
|
984
|
+
"pr_review_managed_github_routes",
|
|
931
985
|
"pr_review_repository_bindings",
|
|
932
986
|
"retained_screenshot_artifacts",
|
|
933
987
|
"rig_changes",
|
|
@@ -1066,6 +1120,7 @@ export const RUNTIME_READ_INSERT_TABLES = [
|
|
|
1066
1120
|
"knowledge_source_objects",
|
|
1067
1121
|
"knowledge_sources",
|
|
1068
1122
|
"knowledge_sync_runs",
|
|
1123
|
+
"pr_review_managed_github_authority_nonces",
|
|
1069
1124
|
"preference_registry_preferences",
|
|
1070
1125
|
"preference_registry_revisions",
|
|
1071
1126
|
"session_attempt_tool_catalogs",
|
|
@@ -1163,6 +1218,11 @@ export const PROTECTED_NO_DIRECT_DML_TABLES = [
|
|
|
1163
1218
|
"organization_user_retention_object_deletion_receipts",
|
|
1164
1219
|
"organization_user_retention_object_obligations",
|
|
1165
1220
|
"organization_user_retention_policies",
|
|
1221
|
+
"organization_user_setup_deliveries",
|
|
1222
|
+
"organization_user_setup_delivery_attempts",
|
|
1223
|
+
"organization_user_setup_intents",
|
|
1224
|
+
"organization_workspace_lifecycle_events",
|
|
1225
|
+
"organization_workspace_operation_receipts",
|
|
1166
1226
|
"personal_document_once_consumption_receipts",
|
|
1167
1227
|
"personal_github_repository_selection_heads",
|
|
1168
1228
|
"personal_github_repository_selection_operations",
|
|
@@ -1170,6 +1230,7 @@ export const PROTECTED_NO_DIRECT_DML_TABLES = [
|
|
|
1170
1230
|
"personal_resource_once_consumption_receipts",
|
|
1171
1231
|
"private_session_create_capabilities",
|
|
1172
1232
|
"remember_knowledge_confirmation_receipts",
|
|
1233
|
+
"remember_knowledge_memory_materializations",
|
|
1173
1234
|
"scheduled_task_connection_authority_snapshots",
|
|
1174
1235
|
"scheduled_task_personal_resource_authorities",
|
|
1175
1236
|
"scheduled_task_personal_resource_snapshots",
|
|
@@ -1179,11 +1240,14 @@ export const PROTECTED_NO_DIRECT_DML_TABLES = [
|
|
|
1179
1240
|
"scheduled_task_run_personal_resource_admissions",
|
|
1180
1241
|
"scheduled_task_run_personal_resource_once_receipts",
|
|
1181
1242
|
"scheduled_task_run_personal_resource_snapshots",
|
|
1243
|
+
"self_service_organization_setup_receipts",
|
|
1182
1244
|
"session_attempt_connected_machine_authorizations",
|
|
1183
1245
|
"session_attempt_personal_document_admissions",
|
|
1184
1246
|
"session_attempt_personal_document_snapshots",
|
|
1185
1247
|
"session_attempt_personal_resource_admissions",
|
|
1186
1248
|
"session_attempt_personal_resource_snapshots",
|
|
1249
|
+
"session_tenancy_greenfield_activation_evidence",
|
|
1250
|
+
"session_variable_set_attachments",
|
|
1187
1251
|
"session_visibility_write_capabilities",
|
|
1188
1252
|
"task_note_events",
|
|
1189
1253
|
"task_note_knowledge_promotion_capabilities",
|
|
@@ -1296,6 +1360,10 @@ export type RuntimeTargetRoutinePosture = RuntimeRoutinePosture & {
|
|
|
1296
1360
|
export type RuntimePrivateTablePosture = {
|
|
1297
1361
|
name: string;
|
|
1298
1362
|
owner: string;
|
|
1363
|
+
rlsEnabled?: boolean;
|
|
1364
|
+
rlsForced?: boolean;
|
|
1365
|
+
rlsActive?: boolean;
|
|
1366
|
+
policyCount?: number;
|
|
1299
1367
|
select: boolean;
|
|
1300
1368
|
insert: boolean;
|
|
1301
1369
|
update: boolean;
|
|
@@ -1314,6 +1382,7 @@ export type RuntimeDatabasePosture = {
|
|
|
1314
1382
|
targetRoutines: RuntimeTargetRoutinePosture[];
|
|
1315
1383
|
privateRoutines: RuntimeRoutinePosture[];
|
|
1316
1384
|
sessionTenancyProductActivationPresent: boolean;
|
|
1385
|
+
sessionVariableSetAttachmentsCutoverPresent: boolean;
|
|
1317
1386
|
};
|
|
1318
1387
|
|
|
1319
1388
|
export class RuntimeDatabasePostureError extends Error {
|
|
@@ -1420,6 +1489,15 @@ export async function inspectRuntimeDatabasePosture(
|
|
|
1420
1489
|
await tx.execute(sql`select session_tenancy_any_product_activation() as activated`),
|
|
1421
1490
|
);
|
|
1422
1491
|
const sessionTenancyProductActivationPresent = activationRows[0]?.activated === true;
|
|
1492
|
+
const variableSetCutoverRows = resultRows<{ present: boolean }>(
|
|
1493
|
+
await tx.execute(sql`
|
|
1494
|
+
select to_regprocedure(
|
|
1495
|
+
'opengeni_private.session_variable_set_attachments_protocol_v1_active()'
|
|
1496
|
+
) is not null as present
|
|
1497
|
+
`),
|
|
1498
|
+
);
|
|
1499
|
+
const sessionVariableSetAttachmentsCutoverPresent =
|
|
1500
|
+
variableSetCutoverRows[0]?.present === true;
|
|
1423
1501
|
|
|
1424
1502
|
// Scoped/embedded topology deliberately leaves ownership and isolation to
|
|
1425
1503
|
// the host. Prove the connection identity is coherent, but do not impose
|
|
@@ -1436,6 +1514,7 @@ export async function inspectRuntimeDatabasePosture(
|
|
|
1436
1514
|
targetRoutines: [],
|
|
1437
1515
|
privateRoutines: [],
|
|
1438
1516
|
sessionTenancyProductActivationPresent,
|
|
1517
|
+
sessionVariableSetAttachmentsCutoverPresent,
|
|
1439
1518
|
};
|
|
1440
1519
|
}
|
|
1441
1520
|
|
|
@@ -1557,6 +1636,10 @@ export async function inspectRuntimeDatabasePosture(
|
|
|
1557
1636
|
const privateTables = resultRows<{
|
|
1558
1637
|
name: string;
|
|
1559
1638
|
owner: string;
|
|
1639
|
+
rls_enabled: boolean;
|
|
1640
|
+
rls_forced: boolean;
|
|
1641
|
+
rls_active: boolean;
|
|
1642
|
+
policy_count: number;
|
|
1560
1643
|
can_select: boolean;
|
|
1561
1644
|
can_insert: boolean;
|
|
1562
1645
|
can_update: boolean;
|
|
@@ -1566,6 +1649,10 @@ export async function inspectRuntimeDatabasePosture(
|
|
|
1566
1649
|
select
|
|
1567
1650
|
c.relname::text as name,
|
|
1568
1651
|
pg_get_userbyid(c.relowner)::text as owner,
|
|
1652
|
+
c.relrowsecurity as rls_enabled,
|
|
1653
|
+
c.relforcerowsecurity as rls_forced,
|
|
1654
|
+
row_security_active(c.oid) as rls_active,
|
|
1655
|
+
(select count(*)::int from pg_policy policy where policy.polrelid = c.oid) as policy_count,
|
|
1569
1656
|
has_table_privilege(current_user, c.oid, 'SELECT') as can_select,
|
|
1570
1657
|
has_table_privilege(current_user, c.oid, 'INSERT') as can_insert,
|
|
1571
1658
|
has_table_privilege(current_user, c.oid, 'UPDATE') as can_update,
|
|
@@ -1581,12 +1668,17 @@ export async function inspectRuntimeDatabasePosture(
|
|
|
1581
1668
|
${PERSONAL_DOCUMENT_CAPABILITY_TABLE},
|
|
1582
1669
|
${DOCUMENT_MIGRATION_CAPABILITY_TABLE},
|
|
1583
1670
|
${SCOPED_COMPUTE_CAPABILITY_TABLE},
|
|
1584
|
-
${CONNECTION_TENANCY_BACKFILL_CAPABILITY_TABLE}
|
|
1671
|
+
${CONNECTION_TENANCY_BACKFILL_CAPABILITY_TABLE},
|
|
1672
|
+
${AUTOMATIC_SESSION_TITLE_FANOUT_OUTBOX_TABLE}
|
|
1585
1673
|
)
|
|
1586
1674
|
`),
|
|
1587
1675
|
).map((row) => ({
|
|
1588
1676
|
name: row.name,
|
|
1589
1677
|
owner: row.owner,
|
|
1678
|
+
rlsEnabled: row.rls_enabled,
|
|
1679
|
+
rlsForced: row.rls_forced,
|
|
1680
|
+
rlsActive: row.rls_active,
|
|
1681
|
+
policyCount: row.policy_count,
|
|
1590
1682
|
select: row.can_select,
|
|
1591
1683
|
insert: row.can_insert,
|
|
1592
1684
|
update: row.can_update,
|
|
@@ -1681,6 +1773,7 @@ export async function inspectRuntimeDatabasePosture(
|
|
|
1681
1773
|
targetRoutines,
|
|
1682
1774
|
privateRoutines,
|
|
1683
1775
|
sessionTenancyProductActivationPresent,
|
|
1776
|
+
sessionVariableSetAttachmentsCutoverPresent,
|
|
1684
1777
|
};
|
|
1685
1778
|
},
|
|
1686
1779
|
{ isolationLevel: "repeatable read", accessMode: "read only" },
|
|
@@ -1695,6 +1788,10 @@ export function evaluateRuntimeDatabasePosture(
|
|
|
1695
1788
|
const violations: string[] = [];
|
|
1696
1789
|
const identity = posture.identity;
|
|
1697
1790
|
|
|
1791
|
+
if (!posture.sessionVariableSetAttachmentsCutoverPresent) {
|
|
1792
|
+
violations.push("database is missing the 0352 session Variable Set attachment runtime receipt");
|
|
1793
|
+
}
|
|
1794
|
+
|
|
1698
1795
|
if (
|
|
1699
1796
|
posture.sessionTenancyProductActivationPresent &&
|
|
1700
1797
|
options.organizationTenancyCanonicalActivationEnabled !== true
|
|
@@ -2326,6 +2423,152 @@ export function evaluateRuntimeDatabasePosture(
|
|
|
2326
2423
|
}
|
|
2327
2424
|
}
|
|
2328
2425
|
|
|
2426
|
+
const automaticTitleFanoutOutboxes = posture.privateTables.filter(
|
|
2427
|
+
(table) => table.name === AUTOMATIC_SESSION_TITLE_FANOUT_OUTBOX_TABLE,
|
|
2428
|
+
);
|
|
2429
|
+
const automaticTitleFanoutRoutineNames = new Set<string>([
|
|
2430
|
+
...AUTOMATIC_SESSION_TITLE_FANOUT_RUNTIME_ROUTINES,
|
|
2431
|
+
AUTOMATIC_SESSION_TITLE_FANOUT_MIGRATION_ROUTINE,
|
|
2432
|
+
AUTOMATIC_SESSION_TITLE_POLICY_TRIGGER_ROUTINE,
|
|
2433
|
+
]);
|
|
2434
|
+
const automaticTitleFanoutCatalogPresent = posture.privateRoutines.some((routine) =>
|
|
2435
|
+
automaticTitleFanoutRoutineNames.has(routine.name),
|
|
2436
|
+
);
|
|
2437
|
+
if (automaticTitleFanoutCatalogPresent && automaticTitleFanoutOutboxes.length !== 1) {
|
|
2438
|
+
violations.push(
|
|
2439
|
+
`automatic session title fanout private outbox ${AUTOMATIC_SESSION_TITLE_FANOUT_OUTBOX_TABLE} is missing or ambiguous`,
|
|
2440
|
+
);
|
|
2441
|
+
}
|
|
2442
|
+
const automaticTitleFanoutOutbox = automaticTitleFanoutOutboxes[0];
|
|
2443
|
+
if (automaticTitleFanoutOutbox) {
|
|
2444
|
+
if (automaticTitleFanoutOutbox.owner === expectedRole) {
|
|
2445
|
+
violations.push(
|
|
2446
|
+
`runtime role owns private automatic session title fanout outbox ${automaticTitleFanoutOutbox.name}`,
|
|
2447
|
+
);
|
|
2448
|
+
}
|
|
2449
|
+
if (!automaticTitleFanoutOutbox.rlsEnabled) {
|
|
2450
|
+
violations.push(
|
|
2451
|
+
`private automatic session title fanout outbox ${automaticTitleFanoutOutbox.name} does not ENABLE RLS`,
|
|
2452
|
+
);
|
|
2453
|
+
}
|
|
2454
|
+
if (!automaticTitleFanoutOutbox.rlsForced) {
|
|
2455
|
+
violations.push(
|
|
2456
|
+
`private automatic session title fanout outbox ${automaticTitleFanoutOutbox.name} does not FORCE RLS`,
|
|
2457
|
+
);
|
|
2458
|
+
}
|
|
2459
|
+
if (!automaticTitleFanoutOutbox.rlsActive) {
|
|
2460
|
+
violations.push(
|
|
2461
|
+
`private automatic session title fanout outbox ${automaticTitleFanoutOutbox.name} has inactive RLS for runtime role`,
|
|
2462
|
+
);
|
|
2463
|
+
}
|
|
2464
|
+
if ((automaticTitleFanoutOutbox.policyCount ?? 0) < 1) {
|
|
2465
|
+
violations.push(
|
|
2466
|
+
`private automatic session title fanout outbox ${automaticTitleFanoutOutbox.name} has no RLS policy`,
|
|
2467
|
+
);
|
|
2468
|
+
}
|
|
2469
|
+
const directPrivileges = [
|
|
2470
|
+
["SELECT", automaticTitleFanoutOutbox.select],
|
|
2471
|
+
["INSERT", automaticTitleFanoutOutbox.insert],
|
|
2472
|
+
["UPDATE", automaticTitleFanoutOutbox.update],
|
|
2473
|
+
["DELETE", automaticTitleFanoutOutbox.delete],
|
|
2474
|
+
].filter(([, granted]) => granted);
|
|
2475
|
+
if (directPrivileges.length > 0) {
|
|
2476
|
+
violations.push(
|
|
2477
|
+
`runtime role has forbidden direct privileges on private table ${automaticTitleFanoutOutbox.name}: ${directPrivileges.map(([privilege]) => privilege).join(", ")}`,
|
|
2478
|
+
);
|
|
2479
|
+
}
|
|
2480
|
+
for (const expectedRoutine of AUTOMATIC_SESSION_TITLE_FANOUT_RUNTIME_ROUTINES) {
|
|
2481
|
+
const matches = posture.privateRoutines.filter((routine) => routine.name === expectedRoutine);
|
|
2482
|
+
if (matches.length !== 1) {
|
|
2483
|
+
violations.push(
|
|
2484
|
+
`automatic session title fanout capability ${expectedRoutine} is missing or ambiguous`,
|
|
2485
|
+
);
|
|
2486
|
+
continue;
|
|
2487
|
+
}
|
|
2488
|
+
const routine = matches[0]!;
|
|
2489
|
+
if (!routine.securityDefiner) {
|
|
2490
|
+
violations.push(
|
|
2491
|
+
`automatic session title fanout capability ${routine.name} is not SECURITY DEFINER`,
|
|
2492
|
+
);
|
|
2493
|
+
}
|
|
2494
|
+
if (routine.owner !== automaticTitleFanoutOutbox.owner) {
|
|
2495
|
+
violations.push(
|
|
2496
|
+
`automatic session title fanout capability ${routine.name} owner ${routine.owner} does not match table owner ${automaticTitleFanoutOutbox.owner}`,
|
|
2497
|
+
);
|
|
2498
|
+
}
|
|
2499
|
+
if (!routine.execute) {
|
|
2500
|
+
violations.push(
|
|
2501
|
+
`runtime role lacks automatic session title fanout capability ${routine.name}`,
|
|
2502
|
+
);
|
|
2503
|
+
}
|
|
2504
|
+
if (routine.publicExecute) {
|
|
2505
|
+
violations.push(
|
|
2506
|
+
`PUBLIC has forbidden automatic session title fanout capability ${routine.name}`,
|
|
2507
|
+
);
|
|
2508
|
+
}
|
|
2509
|
+
}
|
|
2510
|
+
const enqueueMatches = posture.privateRoutines.filter(
|
|
2511
|
+
(routine) => routine.name === AUTOMATIC_SESSION_TITLE_FANOUT_MIGRATION_ROUTINE,
|
|
2512
|
+
);
|
|
2513
|
+
if (enqueueMatches.length !== 1) {
|
|
2514
|
+
violations.push(
|
|
2515
|
+
`automatic session title fanout migration helper ${AUTOMATIC_SESSION_TITLE_FANOUT_MIGRATION_ROUTINE} is missing or ambiguous`,
|
|
2516
|
+
);
|
|
2517
|
+
} else {
|
|
2518
|
+
const routine = enqueueMatches[0]!;
|
|
2519
|
+
if (routine.securityDefiner) {
|
|
2520
|
+
violations.push(
|
|
2521
|
+
`automatic session title fanout migration helper ${routine.name} must be SECURITY INVOKER`,
|
|
2522
|
+
);
|
|
2523
|
+
}
|
|
2524
|
+
if (routine.owner !== automaticTitleFanoutOutbox.owner) {
|
|
2525
|
+
violations.push(
|
|
2526
|
+
`automatic session title fanout migration helper ${routine.name} owner ${routine.owner} does not match table owner ${automaticTitleFanoutOutbox.owner}`,
|
|
2527
|
+
);
|
|
2528
|
+
}
|
|
2529
|
+
if (!routine.execute) {
|
|
2530
|
+
violations.push(
|
|
2531
|
+
`runtime role lacks rolling-compatible automatic session title fanout migration helper ${routine.name}`,
|
|
2532
|
+
);
|
|
2533
|
+
}
|
|
2534
|
+
if (routine.publicExecute) {
|
|
2535
|
+
violations.push(
|
|
2536
|
+
`PUBLIC has forbidden automatic session title fanout migration helper ${routine.name}`,
|
|
2537
|
+
);
|
|
2538
|
+
}
|
|
2539
|
+
}
|
|
2540
|
+
const policyTriggerMatches = posture.privateRoutines.filter(
|
|
2541
|
+
(routine) => routine.name === AUTOMATIC_SESSION_TITLE_POLICY_TRIGGER_ROUTINE,
|
|
2542
|
+
);
|
|
2543
|
+
if (policyTriggerMatches.length !== 1) {
|
|
2544
|
+
violations.push(
|
|
2545
|
+
`automatic session title policy trigger ${AUTOMATIC_SESSION_TITLE_POLICY_TRIGGER_ROUTINE} is missing or ambiguous`,
|
|
2546
|
+
);
|
|
2547
|
+
} else {
|
|
2548
|
+
const routine = policyTriggerMatches[0]!;
|
|
2549
|
+
if (routine.securityDefiner) {
|
|
2550
|
+
violations.push(
|
|
2551
|
+
`automatic session title policy trigger ${routine.name} must be SECURITY INVOKER`,
|
|
2552
|
+
);
|
|
2553
|
+
}
|
|
2554
|
+
if (routine.owner !== automaticTitleFanoutOutbox.owner) {
|
|
2555
|
+
violations.push(
|
|
2556
|
+
`automatic session title policy trigger ${routine.name} owner ${routine.owner} does not match table owner ${automaticTitleFanoutOutbox.owner}`,
|
|
2557
|
+
);
|
|
2558
|
+
}
|
|
2559
|
+
if (!routine.execute) {
|
|
2560
|
+
violations.push(
|
|
2561
|
+
`runtime role lacks rolling-compatible automatic session title policy trigger ${routine.name}`,
|
|
2562
|
+
);
|
|
2563
|
+
}
|
|
2564
|
+
if (routine.publicExecute) {
|
|
2565
|
+
violations.push(
|
|
2566
|
+
`PUBLIC has forbidden automatic session title policy trigger ${routine.name}`,
|
|
2567
|
+
);
|
|
2568
|
+
}
|
|
2569
|
+
}
|
|
2570
|
+
}
|
|
2571
|
+
|
|
2329
2572
|
const artifactMaterializationJobs = tableByName.get("editable_artifact_materialization_jobs");
|
|
2330
2573
|
if (artifactMaterializationJobs) {
|
|
2331
2574
|
for (const tableName of [
|
|
@@ -2838,8 +3081,8 @@ export function evaluateRuntimeDatabasePosture(
|
|
|
2838
3081
|
if (routine.owner === expectedRole) {
|
|
2839
3082
|
violations.push(`runtime role owns private routine ${routine.name}`);
|
|
2840
3083
|
}
|
|
2841
|
-
const
|
|
2842
|
-
if (!routine.execute && !
|
|
3084
|
+
const ownerInternalRoutine = OWNER_INTERNAL_PRIVATE_ROUTINES.has(routine.name);
|
|
3085
|
+
if (!routine.execute && !ownerInternalRoutine) {
|
|
2843
3086
|
violations.push(`runtime role lacks EXECUTE on private routine ${routine.name}`);
|
|
2844
3087
|
}
|
|
2845
3088
|
}
|