@opengeni/db 4.3.2-canary.0 → 4.3.2
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/index.d.ts +0 -9
- package/dist/index.js +14 -66
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
- package/src/index.ts +4 -83
package/dist/index.d.ts
CHANGED
|
@@ -8112,13 +8112,6 @@ export type LegacyModalCheckpointAdoptionTarget = Omit<LegacyModalCheckpointSlot
|
|
|
8112
8112
|
* an unreferenced candidate that GC might delete while the legacy slot still
|
|
8113
8113
|
* depends on that provider object. */
|
|
8114
8114
|
export declare function adoptLegacyModalCheckpointArtifact(db: Database, input: LegacyModalCheckpointAdoptionTarget): Promise<boolean>;
|
|
8115
|
-
/** Object-candidate outcome from the publication transaction, independent of
|
|
8116
|
-
* lifecycle `wrote`. Absent for inline/provider receipts and pure CAS checks.
|
|
8117
|
-
* `unused` is NOT a retirement receipt: only the owner of a fresh candidate with
|
|
8118
|
-
* no other publication in flight may use it for immediate cleanup. Exceptions
|
|
8119
|
-
* give no disposition (commit may have happened). Legacy/shared keys and evicted
|
|
8120
|
-
* refs need durable no-reattachment evidence before deletion. */
|
|
8121
|
-
export type WorkspaceArchiveCandidateDisposition = "adopted" | "already_referenced" | "unused";
|
|
8122
8115
|
export declare function persistDrainSnapshot(db: Database, input: {
|
|
8123
8116
|
accountId: string;
|
|
8124
8117
|
workspaceId: string;
|
|
@@ -8149,7 +8142,6 @@ export declare function persistDrainSnapshot(db: Database, input: {
|
|
|
8149
8142
|
})): Promise<{
|
|
8150
8143
|
wrote: boolean;
|
|
8151
8144
|
archiveRevision: string | null;
|
|
8152
|
-
candidateDisposition?: WorkspaceArchiveCandidateDisposition;
|
|
8153
8145
|
}>;
|
|
8154
8146
|
/**
|
|
8155
8147
|
* The ONE archive-fold write, shared by the drain seam (persistDrainSnapshot)
|
|
@@ -8221,7 +8213,6 @@ export declare function persistWarmSnapshot(db: Database, input: {
|
|
|
8221
8213
|
throttled: boolean;
|
|
8222
8214
|
superseded: boolean;
|
|
8223
8215
|
archiveRevision: string | null;
|
|
8224
|
-
candidateDisposition?: WorkspaceArchiveCandidateDisposition;
|
|
8225
8216
|
}>;
|
|
8226
8217
|
export declare function getMaterializedSandboxFileResources(db: Database, input: {
|
|
8227
8218
|
accountId: string;
|
package/dist/index.js
CHANGED
|
@@ -9207,7 +9207,6 @@ import {
|
|
|
9207
9207
|
SANDBOX_PROVIDER_INSTANCE_ID_FIELDS_BY_BACKEND,
|
|
9208
9208
|
parseWorkspaceArchiveDescriptor,
|
|
9209
9209
|
parseWorkspaceArchiveObjectRef,
|
|
9210
|
-
validateWorkspaceArchiveObjectRef,
|
|
9211
9210
|
workspaceArchivePayloadPresent,
|
|
9212
9211
|
omitInlineWorkspaceArchiveWhenObjectRefPresent,
|
|
9213
9212
|
stableJson as stableJson16,
|
|
@@ -76188,17 +76187,7 @@ async function adoptLegacyModalCheckpointArtifact(db, input) {
|
|
|
76188
76187
|
);
|
|
76189
76188
|
}
|
|
76190
76189
|
function publishedWorkspaceArchiveFields(input) {
|
|
76191
|
-
const ref = input.workspaceArchiveRef
|
|
76192
|
-
accountId: input.accountId,
|
|
76193
|
-
workspaceId: input.workspaceId,
|
|
76194
|
-
sandboxGroupId: input.sandboxGroupId,
|
|
76195
|
-
descriptor: input.workspaceArchiveMeta
|
|
76196
|
-
}) ?? void 0;
|
|
76197
|
-
if (input.workspaceArchiveRef != null && !ref) {
|
|
76198
|
-
throw new Error(
|
|
76199
|
-
"Invalid workspace archive object ref: publication scope or descriptor mismatch"
|
|
76200
|
-
);
|
|
76201
|
-
}
|
|
76190
|
+
const ref = parseWorkspaceArchiveObjectRef(input.workspaceArchiveRef) ?? void 0;
|
|
76202
76191
|
const inline = typeof input.workspaceArchive === "string" && input.workspaceArchive.length > 0 ? input.workspaceArchive : void 0;
|
|
76203
76192
|
if (!ref && !inline) {
|
|
76204
76193
|
throw new Error("workspace archive publication requires inline bytes or an object ref");
|
|
@@ -76215,24 +76204,11 @@ function publishedWorkspaceArchiveFields(input) {
|
|
|
76215
76204
|
}
|
|
76216
76205
|
return { workspaceArchive: inline };
|
|
76217
76206
|
}
|
|
76218
|
-
function workspaceArchiveCandidateFields(candidate, lockedResumeState) {
|
|
76219
|
-
if (!candidate) return {};
|
|
76220
|
-
const sessionState = lockedResumeState?.sessionState;
|
|
76221
|
-
const referenced = [
|
|
76222
|
-
sessionState?.workspaceArchiveRef,
|
|
76223
|
-
sessionState?.workspaceArchivePrevRef
|
|
76224
|
-
].some((value) => {
|
|
76225
|
-
const ref = parseWorkspaceArchiveObjectRef(value);
|
|
76226
|
-
return ref?.key === candidate.key && ref.backend === candidate.backend;
|
|
76227
|
-
});
|
|
76228
|
-
return { candidateDisposition: referenced ? "already_referenced" : "unused" };
|
|
76229
|
-
}
|
|
76230
76207
|
async function persistDrainSnapshot(db, input) {
|
|
76231
76208
|
const workspaceArchiveMeta = input.workspaceArchive === null ? null : parseArchiveRevision(input.workspaceArchiveMeta);
|
|
76232
76209
|
if (input.workspaceArchive !== null && !workspaceArchiveMeta) {
|
|
76233
76210
|
throw new Error("Invalid verified workspace archive descriptor");
|
|
76234
76211
|
}
|
|
76235
|
-
const published = input.workspaceArchive === null ? null : publishedWorkspaceArchiveFields(input);
|
|
76236
76212
|
if (workspaceArchiveMeta?.version === 2 && (workspaceArchiveMeta.provider === "modal_snapshot_filesystem" || workspaceArchiveMeta.provider === "modal_snapshot_directory") && !input.checkpointArtifactId) {
|
|
76237
76213
|
throw new Error("Modal native checkpoint publication requires a registered artifact");
|
|
76238
76214
|
}
|
|
@@ -76270,15 +76246,10 @@ async function persistDrainSnapshot(db, input) {
|
|
|
76270
76246
|
for update
|
|
76271
76247
|
`);
|
|
76272
76248
|
const row = guard[0];
|
|
76273
|
-
const candidateFields = workspaceArchiveCandidateFields(
|
|
76274
|
-
published?.workspaceArchiveRef,
|
|
76275
|
-
row?.resume_state
|
|
76276
|
-
);
|
|
76277
76249
|
if (!row) {
|
|
76278
76250
|
return {
|
|
76279
76251
|
wrote: false,
|
|
76280
|
-
archiveRevision: null
|
|
76281
|
-
...candidateFields
|
|
76252
|
+
archiveRevision: null
|
|
76282
76253
|
};
|
|
76283
76254
|
}
|
|
76284
76255
|
const sourceLeaseMatches = input.expectedLeaseId === void 0 || row.id === input.expectedLeaseId;
|
|
@@ -76288,7 +76259,7 @@ async function persistDrainSnapshot(db, input) {
|
|
|
76288
76259
|
const lateReceipt = recovery.lateArchiveCapture;
|
|
76289
76260
|
const coldLatePublication = input.workspaceArchive !== null && input.expectedLeaseId !== void 0 && input.providerRequestId !== void 0 && row.id === input.expectedLeaseId && row.liveness === "cold" && Number(row.refcount) === 0 && Number(row.lease_epoch) === input.expectedEpoch + 1 && row.instance_id === null && Number(row.workspace_generation) === input.expectedWorkspaceGeneration && row.archive_capture_id === null && recovery.provider.status === "missing" && recovery.provider.instanceId === input.expectedInstanceId && recovery.restore.rematerializationId === null && (recovery.restore.status === "unrecoverable" || recovery.restore.status === "degraded" || recovery.restore.status === "pending") && lateReceipt?.sourceLeaseId === input.expectedLeaseId && lateReceipt.sourceLeaseEpoch === input.expectedEpoch && lateReceipt.sourceInstanceId === input.expectedInstanceId && lateReceipt.sourceWorkspaceGeneration === input.expectedWorkspaceGeneration && lateReceipt.providerRequestId === input.providerRequestId && !row.unsettled_mutation;
|
|
76290
76261
|
if (!activePublication && !coldLatePublication) {
|
|
76291
|
-
return { wrote: false, archiveRevision: null
|
|
76262
|
+
return { wrote: false, archiveRevision: null };
|
|
76292
76263
|
}
|
|
76293
76264
|
const priorArchive = row.prior_archive ?? null;
|
|
76294
76265
|
const priorArchivePrev = row.prior_archive_prev ?? null;
|
|
@@ -76300,7 +76271,7 @@ async function persistDrainSnapshot(db, input) {
|
|
|
76300
76271
|
archiveRevision: null
|
|
76301
76272
|
};
|
|
76302
76273
|
}
|
|
76303
|
-
|
|
76274
|
+
const published = publishedWorkspaceArchiveFields(input);
|
|
76304
76275
|
const priorMeta = parseArchiveRevision(priorSessionState?.workspaceArchiveMeta);
|
|
76305
76276
|
if (activePublication && row.archive_capture_published_at !== null) {
|
|
76306
76277
|
if (priorArchive === null && priorRef === null || priorMeta === null) {
|
|
@@ -76320,7 +76291,7 @@ async function persistDrainSnapshot(db, input) {
|
|
|
76320
76291
|
)
|
|
76321
76292
|
`);
|
|
76322
76293
|
}
|
|
76323
|
-
return { wrote: true, archiveRevision: priorMeta.revision
|
|
76294
|
+
return { wrote: true, archiveRevision: priorMeta.revision };
|
|
76324
76295
|
}
|
|
76325
76296
|
const rotation = rotateWorkspaceArchives({
|
|
76326
76297
|
resumeState: row.resume_state,
|
|
@@ -76374,14 +76345,12 @@ async function persistDrainSnapshot(db, input) {
|
|
|
76374
76345
|
if (!folded) {
|
|
76375
76346
|
return {
|
|
76376
76347
|
wrote: false,
|
|
76377
|
-
archiveRevision: null
|
|
76378
|
-
...candidateFields
|
|
76348
|
+
archiveRevision: null
|
|
76379
76349
|
};
|
|
76380
76350
|
}
|
|
76381
76351
|
return {
|
|
76382
76352
|
wrote: true,
|
|
76383
|
-
archiveRevision: workspaceArchiveMeta?.revision ?? null
|
|
76384
|
-
...published.workspaceArchiveRef ? { candidateDisposition: "adopted" } : {}
|
|
76353
|
+
archiveRevision: workspaceArchiveMeta?.revision ?? null
|
|
76385
76354
|
};
|
|
76386
76355
|
}
|
|
76387
76356
|
);
|
|
@@ -76658,27 +76627,12 @@ async function persistWarmSnapshot(db, input) {
|
|
|
76658
76627
|
)
|
|
76659
76628
|
).limit(1) : [];
|
|
76660
76629
|
const attemptMayPersistWorkspace = attempt !== void 0 && (attempt.state === "claimed" || attempt.state === "running" ? attempt.outcome === null : attempt.state === "closed" && (attempt.outcome === "completed" || attempt.outcome === "failed" || attempt.outcome === "requires_action"));
|
|
76661
|
-
const candidateLease = published.workspaceArchiveRef ? await scopedDb.execute(sql81`
|
|
76662
|
-
select jsonb_build_object('sessionState', jsonb_build_object(
|
|
76663
|
-
'workspaceArchiveRef', resume_state #> '{sessionState,workspaceArchiveRef}',
|
|
76664
|
-
'workspaceArchivePrevRef', resume_state #> '{sessionState,workspaceArchivePrevRef}'
|
|
76665
|
-
)) as resume_state
|
|
76666
|
-
from sandbox_leases
|
|
76667
|
-
where workspace_id = ${input.workspaceId}
|
|
76668
|
-
and sandbox_group_id = ${input.sandboxGroupId}
|
|
76669
|
-
for update
|
|
76670
|
-
`) : [];
|
|
76671
|
-
const candidateFields = workspaceArchiveCandidateFields(
|
|
76672
|
-
published.workspaceArchiveRef,
|
|
76673
|
-
candidateLease[0]?.resume_state
|
|
76674
|
-
);
|
|
76675
76630
|
if (!attempt || attempt.accountId !== input.accountId || attempt.sandboxGroupId !== input.sandboxGroupId || interruption || !attemptMayPersistWorkspace) {
|
|
76676
76631
|
return {
|
|
76677
76632
|
wrote: false,
|
|
76678
76633
|
throttled: false,
|
|
76679
76634
|
superseded: true,
|
|
76680
|
-
archiveRevision: null
|
|
76681
|
-
...candidateFields
|
|
76635
|
+
archiveRevision: null
|
|
76682
76636
|
};
|
|
76683
76637
|
}
|
|
76684
76638
|
const guard = await scopedDb.execute(sql81`
|
|
@@ -76726,8 +76680,7 @@ async function persistWarmSnapshot(db, input) {
|
|
|
76726
76680
|
wrote: false,
|
|
76727
76681
|
throttled: false,
|
|
76728
76682
|
superseded: false,
|
|
76729
|
-
archiveRevision: null
|
|
76730
|
-
...candidateFields
|
|
76683
|
+
archiveRevision: null
|
|
76731
76684
|
};
|
|
76732
76685
|
}
|
|
76733
76686
|
const priorArchive = guard[0].prior_archive ?? null;
|
|
@@ -76740,8 +76693,7 @@ async function persistWarmSnapshot(db, input) {
|
|
|
76740
76693
|
wrote: false,
|
|
76741
76694
|
throttled: false,
|
|
76742
76695
|
superseded: true,
|
|
76743
|
-
archiveRevision: null
|
|
76744
|
-
...candidateFields
|
|
76696
|
+
archiveRevision: null
|
|
76745
76697
|
};
|
|
76746
76698
|
}
|
|
76747
76699
|
if (input.minIntervalMs > 0 && Number.isFinite(priorAtMs) && capturedAtMs - priorAtMs < input.minIntervalMs) {
|
|
@@ -76749,8 +76701,7 @@ async function persistWarmSnapshot(db, input) {
|
|
|
76749
76701
|
wrote: false,
|
|
76750
76702
|
throttled: true,
|
|
76751
76703
|
superseded: false,
|
|
76752
|
-
archiveRevision: null
|
|
76753
|
-
...candidateFields
|
|
76704
|
+
archiveRevision: null
|
|
76754
76705
|
};
|
|
76755
76706
|
}
|
|
76756
76707
|
const rotation = rotateWorkspaceArchives({
|
|
@@ -76771,8 +76722,7 @@ async function persistWarmSnapshot(db, input) {
|
|
|
76771
76722
|
wrote: false,
|
|
76772
76723
|
throttled: false,
|
|
76773
76724
|
superseded: false,
|
|
76774
|
-
archiveRevision: null
|
|
76775
|
-
...candidateFields
|
|
76725
|
+
archiveRevision: null
|
|
76776
76726
|
};
|
|
76777
76727
|
}
|
|
76778
76728
|
const livenessGuard = rowLiveness;
|
|
@@ -76802,16 +76752,14 @@ async function persistWarmSnapshot(db, input) {
|
|
|
76802
76752
|
wrote: false,
|
|
76803
76753
|
throttled: false,
|
|
76804
76754
|
superseded: false,
|
|
76805
|
-
archiveRevision: null
|
|
76806
|
-
...candidateFields
|
|
76755
|
+
archiveRevision: null
|
|
76807
76756
|
};
|
|
76808
76757
|
}
|
|
76809
76758
|
return {
|
|
76810
76759
|
wrote: true,
|
|
76811
76760
|
throttled: false,
|
|
76812
76761
|
superseded: false,
|
|
76813
|
-
archiveRevision: workspaceArchiveMeta.revision
|
|
76814
|
-
...published.workspaceArchiveRef ? { candidateDisposition: "adopted" } : {}
|
|
76762
|
+
archiveRevision: workspaceArchiveMeta.revision
|
|
76815
76763
|
};
|
|
76816
76764
|
}
|
|
76817
76765
|
);
|