@opengeni/db 4.2.2 → 4.3.2-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.
Files changed (103) hide show
  1. package/dist/canonical-human-identities.js +3 -3
  2. package/dist/{chunk-S4Y42VSX.js → chunk-AI4NC6XW.js} +212 -7
  3. package/dist/chunk-AI4NC6XW.js.map +1 -0
  4. package/dist/{chunk-SNLIKELL.js → chunk-DVSLOUEI.js} +2 -2
  5. package/dist/{chunk-6GAPAYZR.js → chunk-F4BIHJ7J.js} +562 -86
  6. package/dist/chunk-F4BIHJ7J.js.map +1 -0
  7. package/dist/{chunk-B2KR3TEM.js → chunk-I4ITNMX2.js} +2 -2
  8. package/dist/{chunk-MGVOYVPS.js → chunk-PFBUHOI5.js} +3 -3
  9. package/dist/{chunk-6Y7ZDVJ5.js → chunk-UUPY6IGP.js} +2 -2
  10. package/dist/{chunk-FPTI4NP4.js → chunk-UVBPOGA7.js} +2 -2
  11. package/dist/{chunk-7WX3R3YL.js → chunk-XBXANJQS.js} +7 -2
  12. package/dist/chunk-XBXANJQS.js.map +1 -0
  13. package/dist/{chunk-6IQ4X35Y.js → chunk-YVYBAWBU.js} +46 -1
  14. package/dist/chunk-YVYBAWBU.js.map +1 -0
  15. package/dist/connect-attempts.d.ts +60 -0
  16. package/dist/connection-setup-authority.d.ts +10 -0
  17. package/dist/connection-token-resolver.d.ts +11 -2
  18. package/dist/editable-artifact-durable-export.js +2 -2
  19. package/dist/editable-artifacts.js +3 -3
  20. package/dist/external-identities.d.ts +16 -0
  21. package/dist/external-identity-links.d.ts +74 -0
  22. package/dist/external-link-work.d.ts +51 -0
  23. package/dist/host-mcp-binding-match.d.ts +5 -0
  24. package/dist/host-mcp-bindings.d.ts +73 -0
  25. package/dist/host-mcp-task-authority.d.ts +47 -0
  26. package/dist/host-selection-identity.d.ts +6 -0
  27. package/dist/index.d.ts +60 -35
  28. package/dist/index.js +15247 -13793
  29. package/dist/index.js.map +1 -1
  30. package/dist/live-session-attempt.d.ts +275 -0
  31. package/dist/managed-auth-session-sets.js +3 -3
  32. package/dist/memory-domain.d.ts +3 -3
  33. package/dist/provision-roles.js +1 -1
  34. package/dist/retained-provider-commands.js +2 -2
  35. package/dist/runtime-posture.d.ts +6 -6
  36. package/dist/scheduled-task-revision-authority.d.ts +11 -0
  37. package/dist/schema.d.ts +1279 -9
  38. package/dist/schema.js +11 -1
  39. package/dist/session-background-commands.js +4 -4
  40. package/dist/session-command-output.js +4 -4
  41. package/dist/session-event-slices.js +2 -2
  42. package/dist/session-queue-commands.d.ts +7 -0
  43. package/dist/session-tenancy.d.ts +2 -0
  44. package/dist/session-tenancy.js +3 -3
  45. package/dist/video-generation.js +3 -3
  46. package/dist/workspace-authority.d.ts +4 -4
  47. package/dist/workspace-tool-defaults.js +4 -4
  48. package/drizzle/0437_organization_scoped_external_workspaces.sql +71 -0
  49. package/drizzle/0438_durable_connect_attempts.sql +95 -0
  50. package/drizzle/0439_external_identity_provisioning.sql +128 -0
  51. package/drizzle/0440_external_workspace_member_removal.sql +59 -0
  52. package/drizzle/0441_external_identity_membership_lifecycle.sql +163 -0
  53. package/drizzle/0442_external_owning_user_authority.sql +81 -0
  54. package/drizzle/0443_host_mcp_binding_registry.sql +93 -0
  55. package/drizzle/0444_host_mcp_delegations.sql +129 -0
  56. package/drizzle/0445_host_mcp_turn_authorities.sql +145 -0
  57. package/drizzle/0446_host_mcp_causal_continuation.sql +126 -0
  58. package/drizzle/0447_host_mcp_task_authorities.sql +264 -0
  59. package/drizzle/0448_host_mcp_child_authority.sql +115 -0
  60. package/drizzle/0449_external_identity_link_lifecycle.sql +107 -0
  61. package/drizzle/0450_external_identity_link_work.sql +179 -0
  62. package/drizzle/0451_external_link_preview_and_permission_ceiling.sql +82 -0
  63. package/drizzle/0452_external_link_scheduled_origin.sql +34 -0
  64. package/drizzle/0453_host_mcp_native_owner.sql +35 -0
  65. package/drizzle/0454_connect_origin_authority.sql +42 -0
  66. package/drizzle/0455_external_link_inventory_labels.sql +44 -0
  67. package/drizzle/0456_social_connection_versions.sql +14 -0
  68. package/drizzle/0457_canonical_session_scope_subject.sql +46 -0
  69. package/drizzle/0458_skill_review_wire_compatibility.sql +36 -0
  70. package/package.json +6 -6
  71. package/src/connect-attempts.ts +317 -0
  72. package/src/connection-authority.ts +9 -0
  73. package/src/connection-setup-authority.ts +35 -0
  74. package/src/connection-token-resolver.ts +177 -48
  75. package/src/external-identities.ts +70 -0
  76. package/src/external-identity-links.ts +364 -0
  77. package/src/external-link-work.ts +228 -0
  78. package/src/host-mcp-binding-match.ts +33 -0
  79. package/src/host-mcp-bindings.ts +741 -0
  80. package/src/host-mcp-task-authority.ts +383 -0
  81. package/src/host-selection-identity.ts +29 -0
  82. package/src/index.ts +481 -151
  83. package/src/live-session-attempt.ts +85 -0
  84. package/src/managed-human-provisioning.ts +6 -1
  85. package/src/memory-domain.ts +6 -11
  86. package/src/provision-roles.ts +3 -0
  87. package/src/runtime-posture.ts +47 -0
  88. package/src/scheduled-task-revision-authority.ts +30 -0
  89. package/src/schema.ts +233 -7
  90. package/src/session-control.ts +14 -0
  91. package/src/session-queue-commands.ts +11 -0
  92. package/src/session-tenancy.ts +7 -0
  93. package/src/workspace-artifacts.ts +10 -4
  94. package/src/workspace-authority.ts +5 -5
  95. package/dist/chunk-6GAPAYZR.js.map +0 -1
  96. package/dist/chunk-6IQ4X35Y.js.map +0 -1
  97. package/dist/chunk-7WX3R3YL.js.map +0 -1
  98. package/dist/chunk-S4Y42VSX.js.map +0 -1
  99. /package/dist/{chunk-SNLIKELL.js.map → chunk-DVSLOUEI.js.map} +0 -0
  100. /package/dist/{chunk-B2KR3TEM.js.map → chunk-I4ITNMX2.js.map} +0 -0
  101. /package/dist/{chunk-MGVOYVPS.js.map → chunk-PFBUHOI5.js.map} +0 -0
  102. /package/dist/{chunk-6Y7ZDVJ5.js.map → chunk-UUPY6IGP.js.map} +0 -0
  103. /package/dist/{chunk-FPTI4NP4.js.map → chunk-UVBPOGA7.js.map} +0 -0
@@ -95,6 +95,7 @@ export type TransitionSessionVisibilityInput = {
95
95
  targetVisibility: SessionTenancyVisibility;
96
96
  expectedAuthorityEpoch: number;
97
97
  operationKey: string;
98
+ beforeCommit?: (tx: Database) => Promise<void>;
98
99
  };
99
100
 
100
101
  export type TransitionSessionVisibilityResult = {
@@ -124,6 +125,7 @@ export type ForkSessionContentInput = {
124
125
  operationKey: string;
125
126
  runtimeRequest?: ForkSessionRuntimeRequest;
126
127
  runtimeConfiguration?: ForkSessionRuntimeConfiguration;
128
+ beforeCommit?: (tx: Database) => Promise<void>;
127
129
  };
128
130
 
129
131
  export type ForkSessionRuntimeRequest = {
@@ -469,6 +471,7 @@ export async function transitionSessionVisibility(
469
471
  );
470
472
  const result = rows[0];
471
473
  if (!result) throw new Error("Session visibility transition returned no result");
474
+ await input.beforeCommit?.(scopedDb);
472
475
  return result;
473
476
  },
474
477
  undefined,
@@ -545,6 +548,7 @@ export async function forkSessionContent(
545
548
  );
546
549
  const result = rows[0];
547
550
  if (!result) throw new Error("Session fork returned no result");
551
+ await input.beforeCommit?.(scopedDb);
548
552
  return result;
549
553
  }
550
554
  const rows = await rawRows<ForkSessionContentResult>(
@@ -577,6 +581,7 @@ export async function forkSessionContent(
577
581
  );
578
582
  const result = rows[0];
579
583
  if (!result) throw new Error("Session fork returned no result");
584
+ await input.beforeCommit?.(scopedDb);
580
585
  return result;
581
586
  },
582
587
  undefined,
@@ -649,6 +654,7 @@ export async function replayAppliedSessionFork(
649
654
  ${runtimeDigest}
650
655
  )`,
651
656
  );
657
+ await input.beforeCommit?.(scopedDb);
652
658
  return rows[0] ?? null;
653
659
  }
654
660
  const rows = await rawRows<ForkSessionContentResult>(
@@ -678,6 +684,7 @@ export async function replayAppliedSessionFork(
678
684
  ${SESSION_TENANCY_ACTIVATION_VERSION}
679
685
  )`,
680
686
  );
687
+ await input.beforeCommit?.(scopedDb);
681
688
  return rows[0] ?? null;
682
689
  },
683
690
  );
@@ -538,7 +538,11 @@ async function assertAttemptAuthority(
538
538
  FOR NO KEY UPDATE OF session
539
539
  ), locked_turn AS MATERIALIZED (
540
540
  SELECT turn.id, turn.account_id, turn.workspace_id, turn.session_id,
541
- turn.active_attempt_id, turn.execution_generation, turn.initiator_subject_id
541
+ turn.active_attempt_id, turn.execution_generation,
542
+ coalesce(
543
+ turn.initiating_human_subject_id,
544
+ case when turn.initiator_kind = 'subject' then turn.initiator_subject_id end
545
+ ) as initiating_human_subject_id
542
546
  FROM session_turns turn
543
547
  JOIN locked_session session
544
548
  ON session.id = turn.session_id
@@ -548,8 +552,10 @@ async function assertAttemptAuthority(
548
552
  AND turn.active_attempt_id = ${input.sourceAttemptId}::uuid
549
553
  AND turn.execution_generation = ${input.sourceExecutionGeneration}
550
554
  AND turn.status IN ('running', 'requires_action', 'recovering', 'waiting_capacity')
551
- AND turn.initiator_kind = 'subject'
552
- AND length(btrim(turn.initiator_subject_id)) BETWEEN 1 AND 1024
555
+ AND length(btrim(coalesce(
556
+ turn.initiating_human_subject_id,
557
+ case when turn.initiator_kind = 'subject' then turn.initiator_subject_id end
558
+ ))) BETWEEN 1 AND 1024
553
559
  FOR UPDATE OF turn
554
560
  ), locked_attempt AS MATERIALIZED (
555
561
  SELECT attempt.id, attempt.account_id, attempt.workspace_id,
@@ -578,7 +584,7 @@ async function assertAttemptAuthority(
578
584
  `)) as unknown as Array<{ id: string }>;
579
585
  if (!rows[0]) {
580
586
  throw new WorkspaceArtifactOperationError(
581
- "Artifact mutation requires the exact active attempt and execution generation",
587
+ "Artifact mutation requires the exact active attempt, execution generation, and immutable human authority",
582
588
  );
583
589
  }
584
590
  }
@@ -54,10 +54,10 @@ import { rawRows, type Database } from "./database";
54
54
  * adding a caller, that stamp is the part you have to get right; this function
55
55
  * will happily answer `true` for any subject you scope a transaction to.
56
56
  *
57
- * Non-`user:` subjects (API keys, delegated service principals, configured and
58
- * local principals) can never own an organization membership, so they
59
- * short-circuit to the plain membership answer instead of tripping
60
- * `list_self_organization_memberships`' `42501`.
57
+ * Persisted `external_user:` subjects also have an organization membership and
58
+ * an exact Personal pointer. They use the same consistency check only after the
59
+ * API's dedicated verified external proof, never a native-cookie stamp. Other
60
+ * service/configured/local subjects retain the plain membership answer.
61
61
  */
62
62
  export async function subjectHasLiveWorkspaceAuthorityInScope(
63
63
  scopedDb: Database,
@@ -83,7 +83,7 @@ export async function subjectHasLiveWorkspaceAuthorityInScope(
83
83
  and workspace_id = ${input.workspaceId}
84
84
  limit 1`,
85
85
  );
86
- if (!input.subjectId.startsWith("user:")) {
86
+ if (!input.subjectId.startsWith("user:") && !input.subjectId.startsWith("external_user:")) {
87
87
  return Boolean(membershipRow);
88
88
  }
89
89
  const [organizationMembershipResult] = await rawRows<{ result: unknown }>(