@opengeni/db 4.3.2 → 4.3.3-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 (64) hide show
  1. package/dist/canonical-human-identities.js +3 -3
  2. package/dist/{chunk-UVBPOGA7.js → chunk-232VC2LW.js} +2 -2
  3. package/dist/{chunk-DVSLOUEI.js → chunk-2ZMTQVTR.js} +2 -2
  4. package/dist/{chunk-AI4NC6XW.js → chunk-6TKL3GQO.js} +47 -1
  5. package/dist/chunk-6TKL3GQO.js.map +1 -0
  6. package/dist/{chunk-F4BIHJ7J.js → chunk-EYF6MH6C.js} +4 -4
  7. package/dist/{chunk-I4ITNMX2.js → chunk-GVZJ7XSR.js} +16 -4
  8. package/dist/{chunk-I4ITNMX2.js.map → chunk-GVZJ7XSR.js.map} +1 -1
  9. package/dist/{chunk-XBXANJQS.js → chunk-M7PSMVFF.js} +2 -2
  10. package/dist/{chunk-PFBUHOI5.js → chunk-QLA3UQNX.js} +3 -3
  11. package/dist/{chunk-YVYBAWBU.js → chunk-THJGMEK5.js} +53 -1
  12. package/dist/chunk-THJGMEK5.js.map +1 -0
  13. package/dist/{chunk-UUPY6IGP.js → chunk-UK57QA2H.js} +2 -2
  14. package/dist/codex-selection-diagnostics.d.ts +12 -0
  15. package/dist/connection-token-resolver.d.ts +2 -0
  16. package/dist/database.d.ts +7 -2
  17. package/dist/editable-artifact-durable-export.js +2 -2
  18. package/dist/editable-artifacts.js +3 -3
  19. package/dist/host-mcp-bindings.d.ts +3 -1
  20. package/dist/index.d.ts +32 -1
  21. package/dist/index.js +345 -75
  22. package/dist/index.js.map +1 -1
  23. package/dist/managed-auth-session-sets.js +3 -3
  24. package/dist/mcp-operations.d.ts +95 -0
  25. package/dist/mcp-operations.js +95 -0
  26. package/dist/mcp-operations.js.map +1 -0
  27. package/dist/plugin-packages.d.ts +1 -0
  28. package/dist/provision-roles.js +1 -1
  29. package/dist/retained-provider-commands.js +2 -2
  30. package/dist/runtime-posture.d.ts +3 -3
  31. package/dist/sandbox-transition-wait.d.ts +10 -0
  32. package/dist/schema.d.ts +517 -0
  33. package/dist/schema.js +3 -1
  34. package/dist/session-background-commands.js +4 -4
  35. package/dist/session-command-output.js +4 -4
  36. package/dist/session-event-slices.js +2 -2
  37. package/dist/session-mcp-progress.d.ts +8 -1
  38. package/dist/session-tenancy.js +3 -3
  39. package/dist/video-generation.js +3 -3
  40. package/dist/workspace-tool-defaults.js +4 -4
  41. package/drizzle/0459_mcp_operations.sql +396 -0
  42. package/drizzle/0460_host_export_message_attribution.sql +177 -0
  43. package/package.json +10 -6
  44. package/src/codex-selection-diagnostics.ts +25 -0
  45. package/src/computer-sessions.ts +5 -1
  46. package/src/connection-token-resolver.ts +2 -0
  47. package/src/database.ts +23 -2
  48. package/src/host-mcp-bindings.ts +14 -1
  49. package/src/index.ts +370 -60
  50. package/src/mcp-operations.ts +189 -0
  51. package/src/plugin-packages.ts +3 -0
  52. package/src/provision-roles.ts +6 -0
  53. package/src/runtime-posture.ts +50 -0
  54. package/src/sandbox-transition-wait.ts +45 -0
  55. package/src/schema.ts +46 -0
  56. package/src/session-mcp-progress.ts +26 -5
  57. package/dist/chunk-AI4NC6XW.js.map +0 -1
  58. package/dist/chunk-YVYBAWBU.js.map +0 -1
  59. /package/dist/{chunk-UVBPOGA7.js.map → chunk-232VC2LW.js.map} +0 -0
  60. /package/dist/{chunk-DVSLOUEI.js.map → chunk-2ZMTQVTR.js.map} +0 -0
  61. /package/dist/{chunk-F4BIHJ7J.js.map → chunk-EYF6MH6C.js.map} +0 -0
  62. /package/dist/{chunk-XBXANJQS.js.map → chunk-M7PSMVFF.js.map} +0 -0
  63. /package/dist/{chunk-PFBUHOI5.js.map → chunk-QLA3UQNX.js.map} +0 -0
  64. /package/dist/{chunk-UUPY6IGP.js.map → chunk-UK57QA2H.js.map} +0 -0
@@ -504,7 +504,11 @@ export async function prepareComputerSessionCreate(
504
504
  state: "prepared",
505
505
  actorSubjectId: input.actorSubjectId,
506
506
  })
507
- .onConflictDoNothing({ target: schema.interactionOperations.operationId })
507
+ // The operation also has a workspace/operation unique index. Concurrent
508
+ // speculative inserts can collide there even when the primary-key
509
+ // arbiter would deduplicate them. Arbitrate every constraint, then use
510
+ // the scoped lookup and immutable request checks below to authorize replay.
511
+ .onConflictDoNothing()
508
512
  .returning();
509
513
  if (!insertedOperation) {
510
514
  const existing = await loadOperation(tx, input.workspaceId, input.operationId);
@@ -126,6 +126,8 @@ export type ResolveConnectionCredentialResult =
126
126
  connectionVersion?: number;
127
127
  /** Metadata-only owner attribution from the immediate pre-use fence. */
128
128
  connectionUseAttribution?: ConnectionUseAttribution;
129
+ /** Metadata-only equality key from current live authority; never credentials or authorization. */
130
+ operationAuthorityDigest?: string;
129
131
  /**
130
132
  * Revalidate the exact accepted attempt immediately before one target
131
133
  * provider request. Credential lookup/refresh is a separate audited
package/src/database.ts CHANGED
@@ -715,12 +715,24 @@ export async function withSessionActivityRlsContext<T>(
715
715
  fn: (db: SessionActivityDatabase) => Promise<T>,
716
716
  transactionConfig?: PgTransactionConfig,
717
717
  fenceMode: "shared" | "none" = "shared",
718
+ organizationMembershipFence = false,
718
719
  ): Promise<T> {
719
720
  await assertSessionActivityGateEntry(db);
720
721
  return await withRlsContext(
721
722
  db,
722
723
  context,
723
724
  async (scopedDb) => {
725
+ if (organizationMembershipFence) {
726
+ // Claim can inherit membership-fenced authority after locking sessions.
727
+ // Acquire membership before even a shared tenancy fence: an exclusive
728
+ // tenancy/control waiter can otherwise complete the same lock cycle.
729
+ await scopedDb.execute(sql`select pg_advisory_xact_lock(
730
+ hashtextextended(${`organization-membership:${context.accountId}`}, 0))`);
731
+ if (fenceMode === "shared") {
732
+ await scopedDb.execute(sql`select pg_advisory_xact_lock_shared(
733
+ hashtextextended(${`session-tenancy:${context.workspaceId}`}, 0))`);
734
+ }
735
+ }
724
736
  const gate = await beginSessionActivityGate(scopedDb, context.workspaceId);
725
737
  const value = await fn(gate.db);
726
738
  // The finalizer must never trust tenant GUCs that arbitrary callback code
@@ -733,7 +745,7 @@ export async function withSessionActivityRlsContext<T>(
733
745
  return value;
734
746
  },
735
747
  transactionConfig,
736
- fenceMode,
748
+ organizationMembershipFence ? "none" : fenceMode,
737
749
  );
738
750
  }
739
751
 
@@ -807,10 +819,19 @@ export async function withSessionActivitySavepoint<T>(
807
819
  export async function retrySessionActivityRls<T>(
808
820
  db: Database,
809
821
  workspaceId: string,
810
- options: IdempotentPersistenceTransactionOptions,
822
+ options: IdempotentPersistenceTransactionOptions & {
823
+ /** Claim can inherit membership-fenced causal authority after locking the
824
+ * session. Acquire that fence before tenancy/control/session instead. An
825
+ * enclosing transaction must preserve this same lock prefix. */
826
+ organizationMembershipFence?: boolean;
827
+ },
811
828
  fn: (db: SessionActivityDatabase) => Promise<T>,
812
829
  ): Promise<T> {
813
830
  return await runIdempotentPersistenceTransaction(options, async () => {
831
+ if (options.organizationMembershipFence) {
832
+ const context = { ...(await rlsContextForWorkspace(db, workspaceId)), workspaceId };
833
+ return await withSessionActivityRlsContext(db, context, fn, undefined, "shared", true);
834
+ }
814
835
  return await withWorkspaceSessionActivityRls(db, workspaceId, fn);
815
836
  });
816
837
  }
@@ -588,7 +588,19 @@ export async function inheritChildHostMcpTurnAuthorities(
588
588
  export async function authorizeDirectHostMcpUse(
589
589
  db: Database,
590
590
  request: McpCredentialsRequest,
591
+ /** Internal metadata observer; called only after every live authorization fence succeeds. */
592
+ onAuthorized?: (snapshot: HostMcpAcceptedAuthority) => void,
591
593
  ): Promise<boolean> {
594
+ const snapshot = await resolveDirectHostMcpUseAuthority(db, request);
595
+ if (!snapshot) return false;
596
+ onAuthorized?.(snapshot);
597
+ return true;
598
+ }
599
+
600
+ async function resolveDirectHostMcpUseAuthority(
601
+ db: Database,
602
+ request: McpCredentialsRequest,
603
+ ): Promise<HostMcpAcceptedAuthority | false> {
592
604
  if (!request.attemptId || !request.connectionRef.hostBinding) return false;
593
605
  const current = await getHostMcpLiveAttempt(
594
606
  db,
@@ -735,7 +747,8 @@ export async function authorizeDirectHostMcpUse(
735
747
  return (
736
748
  live !== null &&
737
749
  live.id === request.turnId &&
738
- live.executionGeneration === request.executionGeneration
750
+ live.executionGeneration === request.executionGeneration &&
751
+ a
739
752
  );
740
753
  });
741
754
  }