@opengeni/db 1.4.0 → 1.4.4
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 +2 -2
- package/dist/capability-reconciliation.js +1 -1
- package/dist/{chunk-27T4AP25.js → chunk-45EMCVJC.js} +22 -6
- package/dist/{chunk-27T4AP25.js.map → chunk-45EMCVJC.js.map} +1 -1
- package/dist/{chunk-EMYA6XNE.js → chunk-4SUZSKKW.js} +2 -2
- package/dist/{chunk-VCHK4D6S.js → chunk-57FM4RG4.js} +2 -2
- package/dist/{chunk-7QWWTVYH.js → chunk-5ROHLEN6.js} +29 -4
- package/dist/chunk-5ROHLEN6.js.map +1 -0
- package/dist/{chunk-BA52ITIY.js → chunk-7HP5NCRN.js} +2 -2
- package/dist/{chunk-UQELJ6OM.js → chunk-A4LPJOKP.js} +2 -2
- package/dist/{chunk-CKDHKQS4.js → chunk-DEMX4GWU.js} +4 -4
- package/dist/{chunk-GC5GUTV3.js → chunk-ISNA4KUA.js} +2 -2
- package/dist/{chunk-3WUCM7YF.js → chunk-JYKUR5KT.js} +2 -2
- package/dist/{chunk-EFANLEWI.js → chunk-LGXWM3UJ.js} +2 -2
- package/dist/{chunk-T3CYF3DH.js → chunk-NI3WPW2L.js} +35 -17
- package/dist/{chunk-T3CYF3DH.js.map → chunk-NI3WPW2L.js.map} +1 -1
- package/dist/{chunk-TRUEH4I2.js → chunk-PUOQEL6A.js} +2 -2
- package/dist/{chunk-NT7OGKYX.js → chunk-SG5YDHSE.js} +3 -3
- package/dist/{chunk-AMK3FNOW.js → chunk-WAFY2TCB.js} +3 -3
- package/dist/codemode-approvals.d.ts +7 -1
- package/dist/connect-attempts.js +2 -2
- package/dist/credit-balances.d.ts +25 -4
- package/dist/database.d.ts +15 -3
- package/dist/editable-artifact-durable-export.js +1 -1
- package/dist/editable-artifacts.js +2 -2
- package/dist/index.d.ts +24 -2
- package/dist/index.js +2782 -2509
- package/dist/index.js.map +1 -1
- package/dist/interaction-schema.d.ts +2 -0
- package/dist/managed-auth-session-sets.js +2 -2
- package/dist/mcp-operations.js +1 -1
- package/dist/modal-native-live-origin.d.ts +75 -0
- package/dist/organization-integration-policy.js +2 -2
- package/dist/provision-roles.js +1 -1
- package/dist/retained-provider-commands.d.ts +21 -21
- package/dist/retained-provider-commands.js +5 -5
- package/dist/runtime-posture.d.ts +1 -1
- package/dist/sandbox-interaction-idle.d.ts +22 -0
- package/dist/session-background-commands.js +3 -3
- package/dist/session-command-output.js +4 -4
- package/dist/session-event-slices.js +2 -2
- package/dist/session-mcp-credential-rotation.js +4 -4
- package/dist/session-tenancy.js +2 -2
- package/dist/video-generation.js +2 -2
- package/dist/workspace-tool-defaults.js +3 -3
- package/drizzle/0632_modal_native_live_origin.sql +239 -0
- package/package.json +7 -7
- package/src/codemode-approvals.ts +52 -22
- package/src/codemode-operations.ts +198 -181
- package/src/credit-balances.ts +58 -17
- package/src/database.ts +47 -8
- package/src/index.ts +453 -255
- package/src/modal-native-live-origin.ts +148 -0
- package/src/provision-roles.ts +12 -0
- package/src/runtime-posture.ts +32 -3
- package/src/sandbox-interaction-idle.ts +91 -0
- package/src/transcription-recordings.ts +3 -1
- package/dist/chunk-7QWWTVYH.js.map +0 -1
- /package/dist/{chunk-EMYA6XNE.js.map → chunk-4SUZSKKW.js.map} +0 -0
- /package/dist/{chunk-VCHK4D6S.js.map → chunk-57FM4RG4.js.map} +0 -0
- /package/dist/{chunk-BA52ITIY.js.map → chunk-7HP5NCRN.js.map} +0 -0
- /package/dist/{chunk-UQELJ6OM.js.map → chunk-A4LPJOKP.js.map} +0 -0
- /package/dist/{chunk-CKDHKQS4.js.map → chunk-DEMX4GWU.js.map} +0 -0
- /package/dist/{chunk-GC5GUTV3.js.map → chunk-ISNA4KUA.js.map} +0 -0
- /package/dist/{chunk-3WUCM7YF.js.map → chunk-JYKUR5KT.js.map} +0 -0
- /package/dist/{chunk-EFANLEWI.js.map → chunk-LGXWM3UJ.js.map} +0 -0
- /package/dist/{chunk-TRUEH4I2.js.map → chunk-PUOQEL6A.js.map} +0 -0
- /package/dist/{chunk-NT7OGKYX.js.map → chunk-SG5YDHSE.js.map} +0 -0
- /package/dist/{chunk-AMK3FNOW.js.map → chunk-WAFY2TCB.js.map} +0 -0
package/src/database.ts
CHANGED
|
@@ -864,17 +864,33 @@ export async function withSessionActivityRlsContext<T>(
|
|
|
864
864
|
fn: (db: SessionActivityDatabase) => Promise<T>,
|
|
865
865
|
transactionConfig?: PgTransactionConfig,
|
|
866
866
|
fenceMode: "shared" | "none" = "shared",
|
|
867
|
-
organizationMembershipFence = false,
|
|
867
|
+
organizationMembershipFence: OrganizationMembershipFenceMode = false,
|
|
868
868
|
): Promise<T> {
|
|
869
869
|
await assertSessionActivityGateEntry(db);
|
|
870
870
|
return await withRlsContext(
|
|
871
871
|
db,
|
|
872
872
|
context,
|
|
873
873
|
async (scopedDb) => {
|
|
874
|
-
if (organizationMembershipFence) {
|
|
875
|
-
//
|
|
876
|
-
//
|
|
877
|
-
//
|
|
874
|
+
if (organizationMembershipFence === "shared") {
|
|
875
|
+
// A pure reader of membership truth (the turn claim) only needs to
|
|
876
|
+
// exclude membership/tenancy mutators, which hold this key
|
|
877
|
+
// exclusively. Readers must not serialize each other: an exclusive
|
|
878
|
+
// claim fence made every turn claim in one organization queue behind
|
|
879
|
+
// every other one. Same position as the exclusive mode below, so the
|
|
880
|
+
// membership -> tenancy -> control prefix order is unchanged. A
|
|
881
|
+
// caller using this mode must never request the exclusive lock on the
|
|
882
|
+
// same key later in the transaction (no in-place escalation).
|
|
883
|
+
await scopedDb.execute(sql`select pg_advisory_xact_lock_shared(
|
|
884
|
+
hashtextextended(${`organization-membership:${context.accountId}`}, 0))`);
|
|
885
|
+
if (fenceMode === "shared") {
|
|
886
|
+
await scopedDb.execute(sql`select pg_advisory_xact_lock_shared(
|
|
887
|
+
hashtextextended(${`session-tenancy:${context.workspaceId}`}, 0))`);
|
|
888
|
+
}
|
|
889
|
+
} else if (organizationMembershipFence) {
|
|
890
|
+
// Callers that reauthorize or mutate under the membership lifecycle
|
|
891
|
+
// lock take it exclusively. Acquire membership before even a shared
|
|
892
|
+
// tenancy fence: an exclusive tenancy/control waiter can otherwise
|
|
893
|
+
// complete the same lock cycle.
|
|
878
894
|
await scopedDb.execute(sql`select pg_advisory_xact_lock(
|
|
879
895
|
hashtextextended(${`organization-membership:${context.accountId}`}, 0))`);
|
|
880
896
|
if (fenceMode === "shared") {
|
|
@@ -894,21 +910,37 @@ export async function withSessionActivityRlsContext<T>(
|
|
|
894
910
|
return value;
|
|
895
911
|
},
|
|
896
912
|
transactionConfig,
|
|
897
|
-
organizationMembershipFence ? "none" : fenceMode,
|
|
913
|
+
organizationMembershipFence !== false ? "none" : fenceMode,
|
|
898
914
|
);
|
|
899
915
|
}
|
|
900
916
|
|
|
917
|
+
/**
|
|
918
|
+
* `true`/`"exclusive"`: the callback reauthorizes or mutates under the
|
|
919
|
+
* organization-membership lifecycle lock. `"shared"`: the callback only reads
|
|
920
|
+
* membership-fenced authority and must never escalate to exclusive.
|
|
921
|
+
*/
|
|
922
|
+
export type OrganizationMembershipFenceMode = boolean | "exclusive" | "shared";
|
|
923
|
+
|
|
924
|
+
/**
|
|
925
|
+
* `organizationMembershipFence` is required when the callback takes the
|
|
926
|
+
* organization-membership lifecycle lock (for example external-actor
|
|
927
|
+
* reauthorization): that lock precedes the session-tenancy fence and the
|
|
928
|
+
* canonical control/workspace/session prefix, never follows it.
|
|
929
|
+
*/
|
|
901
930
|
export async function withWorkspaceSessionActivityRls<T>(
|
|
902
931
|
db: Database,
|
|
903
932
|
workspaceId: string,
|
|
904
933
|
fn: (db: SessionActivityDatabase) => Promise<T>,
|
|
905
934
|
transactionConfig?: PgTransactionConfig,
|
|
935
|
+
organizationMembershipFence = false,
|
|
906
936
|
): Promise<T> {
|
|
907
937
|
return await withSessionActivityRlsContext(
|
|
908
938
|
db,
|
|
909
939
|
{ ...(await rlsContextForWorkspace(db, workspaceId)), workspaceId },
|
|
910
940
|
fn,
|
|
911
941
|
transactionConfig,
|
|
942
|
+
"shared",
|
|
943
|
+
organizationMembershipFence,
|
|
912
944
|
);
|
|
913
945
|
}
|
|
914
946
|
|
|
@@ -972,14 +1004,21 @@ export async function retrySessionActivityRls<T>(
|
|
|
972
1004
|
/** Claim can inherit membership-fenced causal authority after locking the
|
|
973
1005
|
* session. Acquire that fence before tenancy/control/session instead. An
|
|
974
1006
|
* enclosing transaction must preserve this same lock prefix. */
|
|
975
|
-
organizationMembershipFence?:
|
|
1007
|
+
organizationMembershipFence?: OrganizationMembershipFenceMode;
|
|
976
1008
|
},
|
|
977
1009
|
fn: (db: SessionActivityDatabase) => Promise<T>,
|
|
978
1010
|
): Promise<T> {
|
|
979
1011
|
return await runIdempotentPersistenceTransaction(options, async () => {
|
|
980
1012
|
if (options.organizationMembershipFence) {
|
|
981
1013
|
const context = { ...(await rlsContextForWorkspace(db, workspaceId)), workspaceId };
|
|
982
|
-
return await withSessionActivityRlsContext(
|
|
1014
|
+
return await withSessionActivityRlsContext(
|
|
1015
|
+
db,
|
|
1016
|
+
context,
|
|
1017
|
+
fn,
|
|
1018
|
+
undefined,
|
|
1019
|
+
"shared",
|
|
1020
|
+
options.organizationMembershipFence,
|
|
1021
|
+
);
|
|
983
1022
|
}
|
|
984
1023
|
return await withWorkspaceSessionActivityRls(db, workspaceId, fn);
|
|
985
1024
|
});
|