@opengeni/db 3.4.0-canary.2 → 3.6.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.d.ts +20 -0
- package/dist/canonical-human-identities.js +7 -3
- package/dist/{chunk-ZWRIPCTR.js → chunk-2NT476HD.js} +2 -2
- package/dist/{chunk-PYMY3AJW.js → chunk-744DFC65.js} +202 -7
- package/dist/chunk-744DFC65.js.map +1 -0
- package/dist/{chunk-O6FTELKH.js → chunk-CDMMSUWJ.js} +3 -3
- package/dist/chunk-G3732M3T.js +299 -0
- package/dist/chunk-G3732M3T.js.map +1 -0
- package/dist/{chunk-TRBOWUG3.js → chunk-IW6O6G7R.js} +2 -2
- package/dist/{chunk-HY3F5Q4E.js → chunk-Q5YUGQVK.js} +3 -3
- package/dist/{chunk-V3TRUXFJ.js → chunk-UGDVSQ6U.js} +72 -19
- package/dist/chunk-UGDVSQ6U.js.map +1 -0
- package/dist/{chunk-C2AFP7SB.js → chunk-UJ2EW3QI.js} +6664 -6051
- package/dist/chunk-UJ2EW3QI.js.map +1 -0
- package/dist/{chunk-H7MXYG7R.js → chunk-WW7AJ5IC.js} +2 -2
- package/dist/editable-artifact-durable-export.js +2 -2
- package/dist/editable-artifacts.js +3 -3
- package/dist/index.d.ts +44 -6
- package/dist/index.js +2914 -1535
- package/dist/index.js.map +1 -1
- package/dist/managed-auth-session-set-schema.d.ts +1399 -0
- package/dist/managed-auth-session-sets.d.ts +145 -0
- package/dist/managed-auth-session-sets.js +50 -0
- package/dist/managed-auth-session-sets.js.map +1 -0
- package/dist/organization-recovery-schema.d.ts +2144 -0
- package/dist/organization-recovery.d.ts +186 -0
- package/dist/provision-roles.js +1 -1
- package/dist/runtime-posture.d.ts +7 -4
- package/dist/schema.d.ts +9 -6
- package/dist/schema.js +43 -1
- package/dist/session-background-commands.js +3 -3
- package/dist/session-control.d.ts +5 -3
- package/dist/session-queue-commands.d.ts +2 -0
- package/dist/session-tenancy.js +3 -3
- package/dist/video-generation.js +3 -3
- package/dist/work-claims-schema.d.ts +975 -0
- package/dist/work-claims.d.ts +83 -0
- package/drizzle/0362_managed_auth_session_sets.sql +2347 -0
- package/drizzle/0363_organization_recovery_custody.sql +2418 -0
- package/drizzle/0364_workspace_learning_policy_snapshot_lock_order.sql +221 -0
- package/drizzle/0365_permission_scoped_work_claims.sql +1306 -0
- package/drizzle/0366_session_discovery_title_search_index.sql +5 -0
- package/drizzle/0367_session_discovery_goal_search_index.sql +5 -0
- package/drizzle/0368_session_discovery_claim_search_index.sql +6 -0
- package/package.json +10 -6
- package/src/canonical-human-identities.ts +105 -27
- package/src/index.ts +1471 -433
- package/src/managed-auth-session-set-schema.ts +176 -0
- package/src/managed-auth-session-sets.ts +430 -0
- package/src/organization-recovery-schema.ts +277 -0
- package/src/organization-recovery.ts +424 -0
- package/src/provision-roles.ts +67 -0
- package/src/runtime-posture.ts +144 -6
- package/src/schema.ts +3 -0
- package/src/session-control.ts +255 -16
- package/src/session-queue-commands.ts +10 -1
- package/src/session-tool-call-settlement.ts +6 -1
- package/src/work-claims-schema.ts +148 -0
- package/src/work-claims.ts +200 -0
- package/dist/chunk-C2AFP7SB.js.map +0 -1
- package/dist/chunk-PYMY3AJW.js.map +0 -1
- package/dist/chunk-V3TRUXFJ.js.map +0 -1
- /package/dist/{chunk-ZWRIPCTR.js.map → chunk-2NT476HD.js.map} +0 -0
- /package/dist/{chunk-O6FTELKH.js.map → chunk-CDMMSUWJ.js.map} +0 -0
- /package/dist/{chunk-TRBOWUG3.js.map → chunk-IW6O6G7R.js.map} +0 -0
- /package/dist/{chunk-HY3F5Q4E.js.map → chunk-Q5YUGQVK.js.map} +0 -0
- /package/dist/{chunk-H7MXYG7R.js.map → chunk-WW7AJ5IC.js.map} +0 -0
package/src/provision-roles.ts
CHANGED
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
RUNTIME_READ_INSERT_UPDATE_TABLES,
|
|
7
7
|
RUNTIME_READ_ONLY_TABLES,
|
|
8
8
|
RUNTIME_READ_UPDATE_TABLES,
|
|
9
|
+
WORK_CLAIM_CAPABILITY_ROUTINES,
|
|
9
10
|
} from "./runtime-posture";
|
|
10
11
|
import {
|
|
11
12
|
classifyRoleRelationships,
|
|
@@ -482,6 +483,7 @@ async function grantAppRoleIfSchemaExists(
|
|
|
482
483
|
const runtimeReadUpdateTables = `ARRAY[${RUNTIME_READ_UPDATE_TABLES.map(literal).join(", ")}]`;
|
|
483
484
|
const runtimeReadInsertTables = `ARRAY[${RUNTIME_READ_INSERT_TABLES.map(literal).join(", ")}]`;
|
|
484
485
|
const runtimeReadInsertUpdateTables = `ARRAY[${RUNTIME_READ_INSERT_UPDATE_TABLES.map(literal).join(", ")}]`;
|
|
486
|
+
const workClaimCapabilityRoutines = `ARRAY[${WORK_CLAIM_CAPABILITY_ROUTINES.map(literal).join(", ")}]`;
|
|
485
487
|
const organizationMembershipLifecycleRoutines = `ARRAY[${[
|
|
486
488
|
"list_self_organization_memberships(text)",
|
|
487
489
|
"list_self_organization_invitations(text)",
|
|
@@ -533,6 +535,31 @@ async function grantAppRoleIfSchemaExists(
|
|
|
533
535
|
]
|
|
534
536
|
.map(literal)
|
|
535
537
|
.join(", ")}]`;
|
|
538
|
+
const managedAuthSessionSetRoutines = `ARRAY[${[
|
|
539
|
+
"get_canonical_human_exact_login_binding(text,text)",
|
|
540
|
+
"managed_auth_session_set_authority_state(text)",
|
|
541
|
+
"managed_auth_session_set_snapshot(text,text,boolean,boolean,boolean)",
|
|
542
|
+
"managed_auth_session_set_bootstrap(text,text,text,text,uuid,text,bigint,bigint)",
|
|
543
|
+
"managed_auth_session_set_begin_transaction(text,text,text,uuid,text,bigint,uuid,bigint,text,text,uuid,uuid,text,timestamp with time zone)",
|
|
544
|
+
"managed_auth_session_set_complete_transaction(text,text,uuid,text,bigint,bigint,uuid,text,text,text)",
|
|
545
|
+
"managed_auth_session_set_mutate(text,text,uuid,text,bigint,bigint,text,uuid,uuid,uuid,text,text)",
|
|
546
|
+
"managed_auth_actor_mutation_fence(text,bigint,uuid)",
|
|
547
|
+
"managed_auth_actor_mutation_lease_acquire(text,bigint,uuid,integer)",
|
|
548
|
+
"managed_auth_actor_mutation_lease_release(text,uuid)",
|
|
549
|
+
"managed_auth_actor_mutation_lease_validate(text,bigint,uuid)",
|
|
550
|
+
"managed_auth_adopted_session_snapshot(text)",
|
|
551
|
+
"managed_auth_isolated_session_reap(integer)",
|
|
552
|
+
"managed_auth_expired_session_set_reap(integer)",
|
|
553
|
+
"managed_auth_session_set_operation_receipt(text,uuid,text,text)",
|
|
554
|
+
]
|
|
555
|
+
.map(literal)
|
|
556
|
+
.join(", ")}]`;
|
|
557
|
+
const organizationRecoveryRoutines = `ARRAY[${[
|
|
558
|
+
"get_organization_recovery_overview(uuid,text,jsonb,text,text)",
|
|
559
|
+
"organization_recovery_command(jsonb)",
|
|
560
|
+
]
|
|
561
|
+
.map(literal)
|
|
562
|
+
.join(", ")}]`;
|
|
536
563
|
await sql.unsafe(`
|
|
537
564
|
DO $$
|
|
538
565
|
DECLARE
|
|
@@ -972,6 +999,22 @@ BEGIN
|
|
|
972
999
|
${literal(role)}
|
|
973
1000
|
);
|
|
974
1001
|
END IF;
|
|
1002
|
+
-- Migration 0365 creates the advisory work-claim mutation capabilities
|
|
1003
|
+
-- before a custom runtime role may exist. Re-converge their exact grants
|
|
1004
|
+
-- for migrate-then-provision installs without exposing claim history or
|
|
1005
|
+
-- the write-capability ledger to direct runtime DML.
|
|
1006
|
+
FOREACH routine_signature IN ARRAY ${workClaimCapabilityRoutines} LOOP
|
|
1007
|
+
IF to_regprocedure(format('%I.%s', ${literal(schema)}, routine_signature)) IS NOT NULL THEN
|
|
1008
|
+
EXECUTE format(
|
|
1009
|
+
'REVOKE ALL ON FUNCTION %I.%s FROM PUBLIC',
|
|
1010
|
+
${literal(schema)}, routine_signature
|
|
1011
|
+
);
|
|
1012
|
+
EXECUTE format(
|
|
1013
|
+
'GRANT EXECUTE ON FUNCTION %I.%s TO %I',
|
|
1014
|
+
${literal(schema)}, routine_signature, ${literal(role)}
|
|
1015
|
+
);
|
|
1016
|
+
END IF;
|
|
1017
|
+
END LOOP;
|
|
975
1018
|
IF to_regprocedure(
|
|
976
1019
|
format(
|
|
977
1020
|
'%I.workspace_instruction_policy_get_or_create_snapshot(uuid,uuid,uuid,uuid,uuid,integer)',
|
|
@@ -1226,6 +1269,30 @@ BEGIN
|
|
|
1226
1269
|
${literal(role)}
|
|
1227
1270
|
);
|
|
1228
1271
|
END IF;
|
|
1272
|
+
FOREACH routine_signature IN ARRAY ${managedAuthSessionSetRoutines} LOOP
|
|
1273
|
+
IF to_regprocedure(format('%I.%s', ${literal(schema)}, routine_signature)) IS NOT NULL THEN
|
|
1274
|
+
EXECUTE format(
|
|
1275
|
+
'REVOKE ALL ON FUNCTION %I.%s FROM PUBLIC',
|
|
1276
|
+
${literal(schema)}, routine_signature
|
|
1277
|
+
);
|
|
1278
|
+
EXECUTE format(
|
|
1279
|
+
'GRANT EXECUTE ON FUNCTION %I.%s TO %I',
|
|
1280
|
+
${literal(schema)}, routine_signature, ${literal(role)}
|
|
1281
|
+
);
|
|
1282
|
+
END IF;
|
|
1283
|
+
END LOOP;
|
|
1284
|
+
FOREACH routine_signature IN ARRAY ${organizationRecoveryRoutines} LOOP
|
|
1285
|
+
IF to_regprocedure(format('%I.%s', ${literal(schema)}, routine_signature)) IS NOT NULL THEN
|
|
1286
|
+
EXECUTE format(
|
|
1287
|
+
'REVOKE ALL ON FUNCTION %I.%s FROM PUBLIC',
|
|
1288
|
+
${literal(schema)}, routine_signature
|
|
1289
|
+
);
|
|
1290
|
+
EXECUTE format(
|
|
1291
|
+
'GRANT EXECUTE ON FUNCTION %I.%s TO %I',
|
|
1292
|
+
${literal(schema)}, routine_signature, ${literal(role)}
|
|
1293
|
+
);
|
|
1294
|
+
END IF;
|
|
1295
|
+
END LOOP;
|
|
1229
1296
|
-- Migration 0225 creates these target-schema-local session visibility
|
|
1230
1297
|
-- capabilities before opengeni_app may exist. Re-converge their exact
|
|
1231
1298
|
-- EXECUTE grants for migrate-then-provision installs without granting
|
package/src/runtime-posture.ts
CHANGED
|
@@ -324,6 +324,49 @@ const CANONICAL_HUMAN_IDENTITY_AUTHORITY_TABLES = [
|
|
|
324
324
|
"canonical_human_login_bindings",
|
|
325
325
|
"canonical_human_identity_operations",
|
|
326
326
|
] as const;
|
|
327
|
+
const MANAGED_AUTH_SESSION_SET_ROUTINES = [
|
|
328
|
+
"get_canonical_human_exact_login_binding(text, text)",
|
|
329
|
+
"managed_auth_session_set_authority_state(text)",
|
|
330
|
+
"managed_auth_session_set_snapshot(text, text, boolean, boolean, boolean)",
|
|
331
|
+
"managed_auth_session_set_bootstrap(text, text, text, text, uuid, text, bigint, bigint)",
|
|
332
|
+
"managed_auth_session_set_begin_transaction(text, text, text, uuid, text, bigint, uuid, bigint, text, text, uuid, uuid, text, timestamp with time zone)",
|
|
333
|
+
"managed_auth_session_set_complete_transaction(text, text, uuid, text, bigint, bigint, uuid, text, text, text)",
|
|
334
|
+
"managed_auth_session_set_mutate(text, text, uuid, text, bigint, bigint, text, uuid, uuid, uuid, text, text)",
|
|
335
|
+
"managed_auth_actor_mutation_fence(text, bigint, uuid)",
|
|
336
|
+
"managed_auth_actor_mutation_lease_acquire(text, bigint, uuid, integer)",
|
|
337
|
+
"managed_auth_actor_mutation_lease_release(text, uuid)",
|
|
338
|
+
"managed_auth_actor_mutation_lease_validate(text, bigint, uuid)",
|
|
339
|
+
"managed_auth_adopted_session_snapshot(text)",
|
|
340
|
+
"managed_auth_isolated_session_reap(integer)",
|
|
341
|
+
"managed_auth_expired_session_set_reap(integer)",
|
|
342
|
+
"managed_auth_session_set_operation_receipt(text, uuid, text, text)",
|
|
343
|
+
] as const;
|
|
344
|
+
const MANAGED_AUTH_SESSION_SET_AUTHORITY_TABLES = [
|
|
345
|
+
"managed_auth_actor_mutation_leases",
|
|
346
|
+
"managed_auth_browser_installations",
|
|
347
|
+
"managed_auth_session_sets",
|
|
348
|
+
"managed_auth_login_slots",
|
|
349
|
+
"managed_auth_login_return_intents",
|
|
350
|
+
"managed_auth_login_transaction_rate_limits",
|
|
351
|
+
"managed_auth_login_transactions",
|
|
352
|
+
"managed_auth_session_set_operations",
|
|
353
|
+
] as const;
|
|
354
|
+
const ORGANIZATION_RECOVERY_ROUTINES = [
|
|
355
|
+
"get_organization_recovery_overview(uuid, text, jsonb, text, text)",
|
|
356
|
+
"organization_recovery_command(jsonb)",
|
|
357
|
+
] as const;
|
|
358
|
+
const ORGANIZATION_RECOVERY_AUTHORITY_TABLES = [
|
|
359
|
+
"organization_recovery_approvals",
|
|
360
|
+
"organization_recovery_command_receipts",
|
|
361
|
+
"organization_recovery_custodian_acceptances",
|
|
362
|
+
"organization_recovery_custodians",
|
|
363
|
+
"organization_recovery_events",
|
|
364
|
+
"organization_recovery_notification_attempts",
|
|
365
|
+
"organization_recovery_notification_outbox",
|
|
366
|
+
"organization_recovery_operations",
|
|
367
|
+
"organization_recovery_policies",
|
|
368
|
+
"organization_recovery_policy_heads",
|
|
369
|
+
] as const;
|
|
327
370
|
const SESSION_PRIVATE_ACTOR_VISIBLE_ROUTINE =
|
|
328
371
|
"session_private_actor_visible(uuid, uuid, uuid, text)";
|
|
329
372
|
const SESSION_REFERENCE_VISIBLE_ROUTINE = "session_reference_visible(uuid, uuid, uuid)";
|
|
@@ -334,6 +377,10 @@ const TASK_NOTE_CAPABILITY_ROUTINES = [
|
|
|
334
377
|
"replace_task_note_for_attempt(uuid, uuid, uuid, uuid, uuid, integer, uuid, uuid, uuid, uuid, integer, text, text, integer, text)",
|
|
335
378
|
"resolve_task_note_knowledge_promotion_source(uuid, uuid, uuid, uuid, uuid, integer, uuid, integer, text, text, text)",
|
|
336
379
|
] as const;
|
|
380
|
+
export const WORK_CLAIM_CAPABILITY_ROUTINES = [
|
|
381
|
+
"upsert_session_work_claim_for_attempt(uuid, uuid, uuid, uuid, uuid, integer, uuid, integer, text, text, text, text, text, text, text)",
|
|
382
|
+
"release_session_work_claim_for_attempt(uuid, uuid, uuid, uuid, uuid, integer, uuid, uuid, integer, text)",
|
|
383
|
+
] as const;
|
|
337
384
|
const COMPANY_BRAIN_CONTEXT_SELECTION_ROUTINE =
|
|
338
385
|
"company_brain_context_get_or_create_selection(uuid, uuid, uuid, uuid, uuid, integer)";
|
|
339
386
|
const COMPANY_BRAIN_CONTEXT_INSPECTION_ROUTINE =
|
|
@@ -457,6 +504,7 @@ const SESSION_AUTHORITY_ROUTINES = new Set<string>([
|
|
|
457
504
|
...PRIVATE_SESSION_CREATE_CAPABILITY_ROUTINES,
|
|
458
505
|
TRANSITION_SESSION_VISIBILITY_ROUTINE,
|
|
459
506
|
...TASK_NOTE_CAPABILITY_ROUTINES,
|
|
507
|
+
...WORK_CLAIM_CAPABILITY_ROUTINES,
|
|
460
508
|
COMPANY_BRAIN_CONTEXT_SELECTION_ROUTINE,
|
|
461
509
|
COMPANY_BRAIN_CONTEXT_INSPECTION_ROUTINE,
|
|
462
510
|
]);
|
|
@@ -511,7 +559,10 @@ export const RUNTIME_TARGET_SCHEMA_CAPABILITY_ROUTINES = [
|
|
|
511
559
|
...SCOPED_COMPUTE_AUTHORITY_ROUTINES,
|
|
512
560
|
...SCHEDULED_PERSONAL_RESOURCE_ROUTINES,
|
|
513
561
|
...CANONICAL_HUMAN_IDENTITY_ROUTINES,
|
|
562
|
+
...MANAGED_AUTH_SESSION_SET_ROUTINES,
|
|
563
|
+
...ORGANIZATION_RECOVERY_ROUTINES,
|
|
514
564
|
...TASK_NOTE_CAPABILITY_ROUTINES,
|
|
565
|
+
...WORK_CLAIM_CAPABILITY_ROUTINES,
|
|
515
566
|
SESSION_PRIVATE_ACTOR_VISIBLE_ROUTINE,
|
|
516
567
|
SESSION_REFERENCE_VISIBLE_ROUTINE,
|
|
517
568
|
SESSION_VISIBILITY_LIFECYCLE_CAPABILITY_ROUTINE,
|
|
@@ -702,6 +753,14 @@ export const FORCE_RLS_TABLES = [
|
|
|
702
753
|
"machine_metrics_latest",
|
|
703
754
|
"machine_metrics_series",
|
|
704
755
|
"machine_removal_operations",
|
|
756
|
+
"managed_auth_actor_mutation_leases",
|
|
757
|
+
"managed_auth_browser_installations",
|
|
758
|
+
"managed_auth_login_return_intents",
|
|
759
|
+
"managed_auth_login_slots",
|
|
760
|
+
"managed_auth_login_transaction_rate_limits",
|
|
761
|
+
"managed_auth_login_transactions",
|
|
762
|
+
"managed_auth_session_set_operations",
|
|
763
|
+
"managed_auth_session_sets",
|
|
705
764
|
"memory_slack_publication_configurations",
|
|
706
765
|
"memory_slack_publication_receipts",
|
|
707
766
|
"memory_slack_publications",
|
|
@@ -716,6 +775,16 @@ export const FORCE_RLS_TABLES = [
|
|
|
716
775
|
"organization_private_session_setting_events",
|
|
717
776
|
"organization_private_session_settings",
|
|
718
777
|
"organization_profile_events",
|
|
778
|
+
"organization_recovery_approvals",
|
|
779
|
+
"organization_recovery_command_receipts",
|
|
780
|
+
"organization_recovery_custodian_acceptances",
|
|
781
|
+
"organization_recovery_custodians",
|
|
782
|
+
"organization_recovery_events",
|
|
783
|
+
"organization_recovery_notification_attempts",
|
|
784
|
+
"organization_recovery_notification_outbox",
|
|
785
|
+
"organization_recovery_operations",
|
|
786
|
+
"organization_recovery_policies",
|
|
787
|
+
"organization_recovery_policy_heads",
|
|
719
788
|
"organization_shared_workspace_administration_capabilities",
|
|
720
789
|
"organization_user_resource_authorities",
|
|
721
790
|
"organization_user_resource_grants",
|
|
@@ -805,6 +874,9 @@ export const FORCE_RLS_TABLES = [
|
|
|
805
874
|
"session_turns",
|
|
806
875
|
"session_variable_set_attachments",
|
|
807
876
|
"session_visibility_write_capabilities",
|
|
877
|
+
"session_work_claim_revisions",
|
|
878
|
+
"session_work_claim_write_capabilities",
|
|
879
|
+
"session_work_claims",
|
|
808
880
|
"session_workflow_wake_outbox",
|
|
809
881
|
"sessions",
|
|
810
882
|
"site_auth_connections",
|
|
@@ -1073,6 +1145,7 @@ export const RUNTIME_READ_ONLY_TABLES = [
|
|
|
1073
1145
|
"preference_registry_events",
|
|
1074
1146
|
"preference_registry_snapshots",
|
|
1075
1147
|
"session_tenancy_activations",
|
|
1148
|
+
"session_work_claims",
|
|
1076
1149
|
"slack_installation_bindings",
|
|
1077
1150
|
"slack_task_policy_activation_events",
|
|
1078
1151
|
"slack_task_policy_heads",
|
|
@@ -1202,6 +1275,14 @@ export const PROTECTED_NO_DIRECT_DML_TABLES = [
|
|
|
1202
1275
|
"host_export_cursor_state",
|
|
1203
1276
|
"host_export_dead_letters",
|
|
1204
1277
|
"host_export_outbox",
|
|
1278
|
+
"managed_auth_actor_mutation_leases",
|
|
1279
|
+
"managed_auth_browser_installations",
|
|
1280
|
+
"managed_auth_login_return_intents",
|
|
1281
|
+
"managed_auth_login_slots",
|
|
1282
|
+
"managed_auth_login_transaction_rate_limits",
|
|
1283
|
+
"managed_auth_login_transactions",
|
|
1284
|
+
"managed_auth_session_set_operations",
|
|
1285
|
+
"managed_auth_session_sets",
|
|
1205
1286
|
"organization_invitation_binding_events",
|
|
1206
1287
|
"organization_membership_invitations",
|
|
1207
1288
|
"organization_membership_lifecycle_events",
|
|
@@ -1210,6 +1291,16 @@ export const PROTECTED_NO_DIRECT_DML_TABLES = [
|
|
|
1210
1291
|
"organization_private_session_setting_events",
|
|
1211
1292
|
"organization_private_session_settings",
|
|
1212
1293
|
"organization_profile_events",
|
|
1294
|
+
"organization_recovery_approvals",
|
|
1295
|
+
"organization_recovery_command_receipts",
|
|
1296
|
+
"organization_recovery_custodian_acceptances",
|
|
1297
|
+
"organization_recovery_custodians",
|
|
1298
|
+
"organization_recovery_events",
|
|
1299
|
+
"organization_recovery_notification_attempts",
|
|
1300
|
+
"organization_recovery_notification_outbox",
|
|
1301
|
+
"organization_recovery_operations",
|
|
1302
|
+
"organization_recovery_policies",
|
|
1303
|
+
"organization_recovery_policy_heads",
|
|
1213
1304
|
"organization_shared_workspace_administration_capabilities",
|
|
1214
1305
|
"organization_user_resource_authorities",
|
|
1215
1306
|
"organization_user_resource_grants",
|
|
@@ -1249,6 +1340,8 @@ export const PROTECTED_NO_DIRECT_DML_TABLES = [
|
|
|
1249
1340
|
"session_tenancy_greenfield_activation_evidence",
|
|
1250
1341
|
"session_variable_set_attachments",
|
|
1251
1342
|
"session_visibility_write_capabilities",
|
|
1343
|
+
"session_work_claim_revisions",
|
|
1344
|
+
"session_work_claim_write_capabilities",
|
|
1252
1345
|
"task_note_events",
|
|
1253
1346
|
"task_note_knowledge_promotion_capabilities",
|
|
1254
1347
|
"task_note_replacement_receipts",
|
|
@@ -1301,6 +1394,8 @@ export type RuntimeDatabasePostureOptions = {
|
|
|
1301
1394
|
protectedTables?: readonly string[];
|
|
1302
1395
|
tablePrivileges?: RuntimeTablePrivilegeContract;
|
|
1303
1396
|
protectedNoDirectDmlTables?: readonly string[];
|
|
1397
|
+
targetSchemaCapabilityRoutines?: readonly string[];
|
|
1398
|
+
targetSchemaForbiddenRoutines?: readonly string[];
|
|
1304
1399
|
organizationTenancyCanonicalActivationEnabled?: boolean;
|
|
1305
1400
|
};
|
|
1306
1401
|
|
|
@@ -1436,6 +1531,10 @@ export async function inspectRuntimeDatabasePosture(
|
|
|
1436
1531
|
options: RuntimeDatabasePostureOptions,
|
|
1437
1532
|
): Promise<RuntimeDatabasePosture> {
|
|
1438
1533
|
const targetSchema = options.targetSchema?.trim() || "public";
|
|
1534
|
+
const targetSchemaCapabilityRoutines =
|
|
1535
|
+
options.targetSchemaCapabilityRoutines ?? RUNTIME_TARGET_SCHEMA_CAPABILITY_ROUTINES;
|
|
1536
|
+
const targetSchemaForbiddenRoutines =
|
|
1537
|
+
options.targetSchemaForbiddenRoutines ?? RUNTIME_TARGET_SCHEMA_FORBIDDEN_ROUTINES;
|
|
1439
1538
|
|
|
1440
1539
|
return await db.transaction(
|
|
1441
1540
|
async (tx) => {
|
|
@@ -1710,10 +1809,9 @@ export async function inspectRuntimeDatabasePosture(
|
|
|
1710
1809
|
and (p.proname || '(' || pg_catalog.oidvectortypes(p.proargtypes) || ')') = any(
|
|
1711
1810
|
array[
|
|
1712
1811
|
${sql.join(
|
|
1713
|
-
[
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
].map((name) => sql`${name}`),
|
|
1812
|
+
[...targetSchemaCapabilityRoutines, ...targetSchemaForbiddenRoutines].map(
|
|
1813
|
+
(name) => sql`${name}`,
|
|
1814
|
+
),
|
|
1717
1815
|
sql`, `,
|
|
1718
1816
|
)}
|
|
1719
1817
|
]::text[]
|
|
@@ -1826,6 +1924,10 @@ export function evaluateRuntimeDatabasePosture(
|
|
|
1826
1924
|
options.protectedNoDirectDmlTables ??
|
|
1827
1925
|
(options.protectedTables ? [] : PROTECTED_NO_DIRECT_DML_TABLES),
|
|
1828
1926
|
);
|
|
1927
|
+
const targetSchemaCapabilityRoutines =
|
|
1928
|
+
options.targetSchemaCapabilityRoutines ?? RUNTIME_TARGET_SCHEMA_CAPABILITY_ROUTINES;
|
|
1929
|
+
const targetSchemaForbiddenRoutines =
|
|
1930
|
+
options.targetSchemaForbiddenRoutines ?? RUNTIME_TARGET_SCHEMA_FORBIDDEN_ROUTINES;
|
|
1829
1931
|
|
|
1830
1932
|
if (identity.currentUser !== expectedRole || identity.sessionUser !== expectedRole) {
|
|
1831
1933
|
violations.push(
|
|
@@ -1956,7 +2058,7 @@ export function evaluateRuntimeDatabasePosture(
|
|
|
1956
2058
|
}
|
|
1957
2059
|
|
|
1958
2060
|
const targetSchemaOwner = posture.schemas.find((schema) => schema.name === targetSchema)?.owner;
|
|
1959
|
-
for (const forbiddenRoutine of
|
|
2061
|
+
for (const forbiddenRoutine of targetSchemaForbiddenRoutines) {
|
|
1960
2062
|
const matches = posture.targetRoutines.filter((routine) => routine.name === forbiddenRoutine);
|
|
1961
2063
|
if (matches.length !== 1) {
|
|
1962
2064
|
violations.push(
|
|
@@ -1983,7 +2085,7 @@ export function evaluateRuntimeDatabasePosture(
|
|
|
1983
2085
|
violations.push(`PUBLIC has forbidden owner-internal helper ${routine.name}`);
|
|
1984
2086
|
}
|
|
1985
2087
|
}
|
|
1986
|
-
for (const expectedRoutine of
|
|
2088
|
+
for (const expectedRoutine of targetSchemaCapabilityRoutines) {
|
|
1987
2089
|
const matches = posture.targetRoutines.filter((routine) => routine.name === expectedRoutine);
|
|
1988
2090
|
if (matches.length !== 1) {
|
|
1989
2091
|
violations.push(
|
|
@@ -2252,6 +2354,42 @@ export function evaluateRuntimeDatabasePosture(
|
|
|
2252
2354
|
);
|
|
2253
2355
|
}
|
|
2254
2356
|
}
|
|
2357
|
+
} else if ((ORGANIZATION_RECOVERY_ROUTINES as readonly string[]).includes(routine.name)) {
|
|
2358
|
+
const authorityTables = ORGANIZATION_RECOVERY_AUTHORITY_TABLES.filter((tableName) =>
|
|
2359
|
+
tableByName.has(tableName),
|
|
2360
|
+
).map((tableName) => tableByName.get(tableName)!);
|
|
2361
|
+
const authorityOwners = new Set(authorityTables.map((table) => table.owner));
|
|
2362
|
+
if (authorityTables.length !== ORGANIZATION_RECOVERY_AUTHORITY_TABLES.length) {
|
|
2363
|
+
violations.push(
|
|
2364
|
+
`target-schema runtime capability ${routine.name} organization recovery authority tables are missing`,
|
|
2365
|
+
);
|
|
2366
|
+
} else if (authorityOwners.size !== 1) {
|
|
2367
|
+
violations.push(
|
|
2368
|
+
`target-schema runtime capability ${routine.name} authority table owners do not match: ${authorityTables.map((table) => `${table.name}=${table.owner}`).join(", ")}`,
|
|
2369
|
+
);
|
|
2370
|
+
} else if (routine.owner !== authorityTables[0]!.owner) {
|
|
2371
|
+
violations.push(
|
|
2372
|
+
`target-schema runtime capability ${routine.name} owner ${routine.owner} does not match authority table owner ${authorityTables[0]!.owner}`,
|
|
2373
|
+
);
|
|
2374
|
+
}
|
|
2375
|
+
} else if ((MANAGED_AUTH_SESSION_SET_ROUTINES as readonly string[]).includes(routine.name)) {
|
|
2376
|
+
const authorityTables = MANAGED_AUTH_SESSION_SET_AUTHORITY_TABLES.filter((tableName) =>
|
|
2377
|
+
tableByName.has(tableName),
|
|
2378
|
+
).map((tableName) => tableByName.get(tableName)!);
|
|
2379
|
+
const authorityOwners = new Set(authorityTables.map((table) => table.owner));
|
|
2380
|
+
if (authorityTables.length !== MANAGED_AUTH_SESSION_SET_AUTHORITY_TABLES.length) {
|
|
2381
|
+
violations.push(
|
|
2382
|
+
`target-schema runtime capability ${routine.name} managed auth session-set authority tables are missing`,
|
|
2383
|
+
);
|
|
2384
|
+
} else if (authorityOwners.size !== 1) {
|
|
2385
|
+
violations.push(
|
|
2386
|
+
`target-schema runtime capability ${routine.name} authority table owners do not match: ${authorityTables.map((table) => `${table.name}=${table.owner}`).join(", ")}`,
|
|
2387
|
+
);
|
|
2388
|
+
} else if (routine.owner !== authorityTables[0]!.owner) {
|
|
2389
|
+
violations.push(
|
|
2390
|
+
`target-schema runtime capability ${routine.name} owner ${routine.owner} does not match authority table owner ${authorityTables[0]!.owner}`,
|
|
2391
|
+
);
|
|
2392
|
+
}
|
|
2255
2393
|
} else if ((CANONICAL_HUMAN_IDENTITY_ROUTINES as readonly string[]).includes(routine.name)) {
|
|
2256
2394
|
const authorityTables = CANONICAL_HUMAN_IDENTITY_AUTHORITY_TABLES.filter((tableName) =>
|
|
2257
2395
|
tableByName.has(tableName),
|
package/src/schema.ts
CHANGED
|
@@ -46,6 +46,8 @@ import {
|
|
|
46
46
|
import { losslessCodecVersion, losslessJsonb, losslessText } from "./lossless-columns";
|
|
47
47
|
|
|
48
48
|
export * from "./editable-artifacts-schema";
|
|
49
|
+
export * from "./managed-auth-session-set-schema";
|
|
50
|
+
export * from "./organization-recovery-schema";
|
|
49
51
|
|
|
50
52
|
const vector = customType<{ data: number[]; driverData: string }>({
|
|
51
53
|
dataType() {
|
|
@@ -12481,6 +12483,7 @@ export * from "./preference-registry-schema";
|
|
|
12481
12483
|
export * from "./memory-governance-schema";
|
|
12482
12484
|
export * from "./scoped-knowledge-schema";
|
|
12483
12485
|
export * from "./task-notes-schema";
|
|
12486
|
+
export * from "./work-claims-schema";
|
|
12484
12487
|
export * from "./company-brain-context-selection-schema";
|
|
12485
12488
|
export * from "./governed-learning-evaluator-schema";
|
|
12486
12489
|
export * from "./governed-learning-activation-schema";
|