@opengeni/worker-bundle 0.28.1-canary.0 → 0.28.3-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.
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  observabilityEventLogger
3
- } from "./chunk-BARTLVBK.js";
3
+ } from "./chunk-A4XQWVZK.js";
4
4
 
5
5
  // src/activity-services.ts
6
6
  import { dbSearchPath, getSettings, resolveNatsControlPlaneAuth } from "@opengeni/config";
@@ -1329,6 +1329,8 @@ function goalContinuationPrompt(_goal, _autoContinuation, _cap, options = {}) {
1329
1329
  "Continuation behavior:",
1330
1330
  "- This goal persists across turns. A runtime boundary can end one turn without shrinking the objective; the next continuation resumes the same full objective.",
1331
1331
  "- Keep working until the requested end state is true and verified. Do not end the turn merely because one useful action completed, and do not redefine success around a smaller or easier task.",
1332
+ "- An incomplete-status report is not a substitute for continuing the work. If the remaining problem can be investigated or addressed within your current authority, continue that work in this turn rather than returning another equivalent status-only final.",
1333
+ "- Distinguish unfinished work from a blocker that actually requires human input or external change; use the existing waiting and blocked audits only when their conditions hold.",
1332
1334
  "- Temporary rough edges are acceptable while the work is moving in the right direction. Completion still requires the requested end state to be true and verified.",
1333
1335
  "",
1334
1336
  "Work from evidence:",
@@ -1644,6 +1646,8 @@ async function nextStreamEvent(iterator, context) {
1644
1646
  }
1645
1647
 
1646
1648
  // src/sandbox-archive-storage.ts
1649
+ import { uploadWorkspaceArchiveSpool } from "@opengeni/storage";
1650
+ import { randomUUID as randomUUID2 } from "crypto";
1647
1651
  import {
1648
1652
  parseWorkspaceArchiveObjectRef,
1649
1653
  workspaceArchiveObjectKey
@@ -1655,47 +1659,74 @@ var WorkspaceArchiveObjectStorageRequiredError = class extends Error {
1655
1659
  this.name = "WorkspaceArchiveObjectStorageRequiredError";
1656
1660
  }
1657
1661
  };
1658
- function collectWorkspaceArchiveObjectKeys(resumeState) {
1659
- const sessionState = resumeState?.sessionState && typeof resumeState.sessionState === "object" ? resumeState.sessionState : null;
1660
- const keys = /* @__PURE__ */ new Set();
1661
- for (const value of [sessionState?.workspaceArchiveRef, sessionState?.workspaceArchivePrevRef]) {
1662
- const ref = parseWorkspaceArchiveObjectRef(value);
1663
- if (ref) keys.add(ref.key);
1664
- }
1665
- return keys;
1666
- }
1667
1662
  async function putTarWorkspaceArchiveObject(input) {
1668
- if (input.archive.descriptor.version !== 1) {
1663
+ const descriptor = structuredClone(input.archive.descriptor);
1664
+ if (descriptor.version !== 1) {
1669
1665
  throw new Error("Object-storage workspace archives are portable tar only");
1670
1666
  }
1671
1667
  const key = workspaceArchiveObjectKey({
1672
1668
  accountId: input.accountId,
1673
1669
  workspaceId: input.workspaceId,
1674
1670
  sandboxGroupId: input.sandboxGroupId,
1675
- revision: input.archive.descriptor.revision
1676
- });
1677
- await input.objectStorage.putObject({
1678
- key,
1679
- contentType: "application/x-tar",
1680
- body: input.archive.bytes,
1681
- sha256: input.archive.descriptor.archiveSha256
1671
+ revision: descriptor.revision,
1672
+ uploadId: randomUUID2()
1682
1673
  });
1674
+ const archive = input.archive;
1675
+ if ("spool" in archive) {
1676
+ if (archive.spool.byteSize !== descriptor.archiveBytes || archive.spool.sha256 !== descriptor.archiveSha256) {
1677
+ throw new Error("Workspace archive spool does not match its verified descriptor");
1678
+ }
1679
+ }
1680
+ const source = "spool" in archive ? archive.spool : {
1681
+ path: "",
1682
+ byteSize: archive.bytes.byteLength,
1683
+ sha256: descriptor.archiveSha256,
1684
+ async *open() {
1685
+ for (let offset = 0; offset < archive.bytes.length; offset += 1024 * 1024)
1686
+ yield archive.bytes.subarray(offset, offset + 1024 * 1024);
1687
+ },
1688
+ async dispose() {
1689
+ }
1690
+ };
1691
+ try {
1692
+ await uploadWorkspaceArchiveSpool(input.objectStorage, key, {
1693
+ ...source,
1694
+ byteSize: descriptor.archiveBytes,
1695
+ sha256: descriptor.archiveSha256,
1696
+ open: source.open.bind(source)
1697
+ });
1698
+ } catch (error) {
1699
+ await input.objectStorage.deleteObject(key).catch(() => void 0);
1700
+ throw error;
1701
+ }
1683
1702
  return {
1684
1703
  schema: "sandbox_archive_object_v1",
1685
1704
  key,
1686
- sha256: input.archive.descriptor.archiveSha256,
1687
- bytes: input.archive.descriptor.archiveBytes,
1705
+ sha256: descriptor.archiveSha256,
1706
+ bytes: descriptor.archiveBytes,
1688
1707
  backend: input.objectStorage.backend
1689
1708
  };
1690
1709
  }
1710
+ async function persistWorkspaceArchiveCandidate(input) {
1711
+ const objectStorage = input.objectStorage;
1712
+ const ref = input.ref ? { ...input.ref } : void 0;
1713
+ const result = await input.persist();
1714
+ if (objectStorage && ref && result.candidateDisposition === "unused") {
1715
+ await deleteUnpublishedWorkspaceArchiveObject(objectStorage, ref);
1716
+ }
1717
+ return result;
1718
+ }
1691
1719
  async function putVersion1TarArchiveOrInline(input) {
1692
1720
  if (input.archive.descriptor.version !== 1) {
1721
+ if ("spool" in input.archive) throw new Error("Native snapshots cannot use a portable spool");
1693
1722
  return { workspaceArchive: input.archive.base64 };
1694
1723
  }
1695
1724
  if (input.backend === "opensandbox" && !input.objectStorage) {
1696
1725
  throw new WorkspaceArchiveObjectStorageRequiredError("opensandbox");
1697
1726
  }
1698
1727
  if (!input.objectStorage) {
1728
+ if ("spool" in input.archive)
1729
+ throw new WorkspaceArchiveObjectStorageRequiredError(input.backend);
1699
1730
  return { workspaceArchive: input.archive.base64 };
1700
1731
  }
1701
1732
  try {
@@ -1704,7 +1735,7 @@ async function putVersion1TarArchiveOrInline(input) {
1704
1735
  accountId: input.accountId,
1705
1736
  workspaceId: input.workspaceId,
1706
1737
  sandboxGroupId: input.sandboxGroupId,
1707
- archive: { bytes: input.archive.bytes, descriptor: input.archive.descriptor }
1738
+ archive: input.archive
1708
1739
  });
1709
1740
  try {
1710
1741
  input.metrics?.onWorkspaceArchiveObject?.({
@@ -1745,11 +1776,6 @@ async function deleteUnpublishedWorkspaceArchiveObject(objectStorage, ref, metri
1745
1776
  console.error("unpublished workspace archive object delete failed", { key: ref.key });
1746
1777
  }
1747
1778
  }
1748
- async function deleteWorkspaceArchiveObjectKeys(objectStorage, keys) {
1749
- for (const key of keys) {
1750
- await objectStorage.deleteObject(key);
1751
- }
1752
- }
1753
1779
 
1754
1780
  // src/sandbox-routing.ts
1755
1781
  import { sandboxLifecycleTransitionWaitMs as sandboxLifecycleTransitionWaitMs2 } from "@opengeni/config";
@@ -1804,7 +1830,7 @@ import {
1804
1830
  sandboxArchiveCaptureTimeoutMs,
1805
1831
  sandboxLifecycleTransitionWaitMs
1806
1832
  } from "@opengeni/config";
1807
- import { randomUUID as randomUUID2 } from "crypto";
1833
+ import { randomUUID as randomUUID3 } from "crypto";
1808
1834
  import {
1809
1835
  acquireLease,
1810
1836
  adoptLegacyModalCheckpointArtifact,
@@ -1831,7 +1857,8 @@ import {
1831
1857
  SandboxLeaseTransitionError
1832
1858
  } from "@opengeni/db";
1833
1859
  import {
1834
- captureVerifiedWorkspaceArchive,
1860
+ captureWorkspaceArchiveForStorage,
1861
+ disposeWorkspaceArchive,
1835
1862
  describeLegacyNativeSnapshotArchive,
1836
1863
  inlineWorkspaceArchiveForRestore,
1837
1864
  MODAL_EXEC_READINESS_TIMEOUT_MS,
@@ -1852,6 +1879,10 @@ import {
1852
1879
  verifySandboxExecReadiness,
1853
1880
  withoutSandboxProviderIdentity
1854
1881
  } from "@opengeni/runtime";
1882
+ import {
1883
+ downloadWorkspaceArchiveSpool,
1884
+ WorkspaceArchiveStorageError
1885
+ } from "@opengeni/storage";
1855
1886
  import { parseWorkspaceArchiveObjectRef as parseWorkspaceArchiveObjectRef2 } from "@opengeni/contracts";
1856
1887
  function sandboxLeaseHolderIdForAttempt(attemptId) {
1857
1888
  const normalized = attemptId.trim();
@@ -2107,6 +2138,10 @@ async function materializeSpawnEnvelopeArchive(envelope, objectStorage) {
2107
2138
  "workspace archive object storage is not configured"
2108
2139
  );
2109
2140
  }
2141
+ const descriptor = parseWorkspaceArchiveDescriptor(sessionState.workspaceArchiveMeta);
2142
+ if (process.platform === "linux" && descriptor?.version === 1 && descriptor.workspace.projection === "sdk_local_archive_v1") {
2143
+ return envelope;
2144
+ }
2110
2145
  return {
2111
2146
  ...record,
2112
2147
  sessionState: await inlineWorkspaceArchiveForRestore(
@@ -2204,7 +2239,7 @@ async function persistWarmWorkspaceSnapshot(services, ids, session, leaseEpoch,
2204
2239
  const nativeModalPersistence = workspacePersistence === "snapshot_filesystem" || workspacePersistence === "snapshot_directory";
2205
2240
  const checkpointBinding = nativeModalPersistence ? await resolveModalCheckpointBindingBeforeCapture(settings, persistable, signal) : null;
2206
2241
  if (signal?.aborted) return false;
2207
- const captureId = randomUUID2();
2242
+ const captureId = randomUUID3();
2208
2243
  const captureTimeoutMs = sandboxArchiveCaptureTimeoutMs(settings);
2209
2244
  const claimed = await claimWorkspaceArchiveCapture(db, {
2210
2245
  accountId: ids.accountId,
@@ -2237,7 +2272,7 @@ async function persistWarmWorkspaceSnapshot(services, ids, session, leaseEpoch,
2237
2272
  let timeout;
2238
2273
  const capturedAtMs = Date.now();
2239
2274
  const registerCandidate = async (archive) => {
2240
- if (archive.descriptor.version !== 2 || archive.descriptor.provider !== "modal_snapshot_filesystem" && archive.descriptor.provider !== "modal_snapshot_directory") {
2275
+ if (archive.kind === "host_spool" || archive.descriptor.version !== 2 || archive.descriptor.provider !== "modal_snapshot_filesystem" && archive.descriptor.provider !== "modal_snapshot_directory") {
2241
2276
  return null;
2242
2277
  }
2243
2278
  if (!checkpointBinding) {
@@ -2266,80 +2301,64 @@ async function persistWarmWorkspaceSnapshot(services, ids, session, leaseEpoch,
2266
2301
  }).catch(() => void 0);
2267
2302
  };
2268
2303
  const captureAndPublish = (async () => {
2304
+ let archive;
2269
2305
  let candidate = null;
2270
- let workspaceArchiveRef;
2306
+ let publicationAttempted = false;
2271
2307
  try {
2272
- const archive = await captureVerifiedWorkspaceArchive(session, capturedAtMs, {
2273
- requestId: claimed.claim.providerRequestId,
2274
- strategy: capturePolicy.strategy
2275
- });
2276
- candidate = await registerCandidate(archive);
2277
- const priorLease = await readLease(db, ids.workspaceId, ids.sandboxGroupId);
2278
- const priorKeys = collectWorkspaceArchiveObjectKeys(
2279
- priorLease?.resumeState ?? null
2308
+ archive = await captureWorkspaceArchiveForStorage(
2309
+ session,
2310
+ capturedAtMs,
2311
+ {
2312
+ requestId: claimed.claim.providerRequestId,
2313
+ strategy: capturePolicy.strategy
2314
+ },
2315
+ Boolean(services.objectStorage)
2280
2316
  );
2317
+ candidate = await registerCandidate(archive);
2318
+ const archiveDescriptor = archive.descriptor;
2281
2319
  const published = await putVersion1TarArchiveOrInline({
2282
2320
  backend: lease.backend,
2283
2321
  objectStorage: services.objectStorage,
2284
2322
  accountId: ids.accountId,
2285
2323
  workspaceId: ids.workspaceId,
2286
2324
  sandboxGroupId: ids.sandboxGroupId,
2287
- archive: {
2288
- bytes: archive.bytes,
2289
- descriptor: archive.descriptor,
2290
- base64: archive.base64
2291
- },
2325
+ archive,
2292
2326
  ...services.sandboxMetrics ? { metrics: services.sandboxMetrics } : {}
2293
2327
  });
2294
- workspaceArchiveRef = published.workspaceArchiveRef;
2295
- const { wrote } = await persistWarmSnapshot(db, {
2296
- accountId: ids.accountId,
2297
- workspaceId: ids.workspaceId,
2298
- sessionId: ids.sessionId,
2299
- turnId: ids.turnId,
2300
- attemptId: ids.attemptId,
2301
- sandboxGroupId: ids.sandboxGroupId,
2302
- expectedEpoch: leaseEpoch,
2303
- expectedInstanceId: instanceId,
2304
- expectedWorkspaceGeneration: claimed.claim.workspaceGeneration,
2305
- captureId,
2306
- workspaceArchiveMeta: archive.descriptor,
2307
- ...published,
2308
- checkpointArtifactId: candidate?.id ?? null,
2309
- minIntervalMs: force ? 0 : intervalMs,
2310
- capturedAtMs
2328
+ publicationAttempted = true;
2329
+ const { wrote } = await persistWorkspaceArchiveCandidate({
2330
+ ...services.objectStorage ? { objectStorage: services.objectStorage } : {},
2331
+ ...published.workspaceArchiveRef ? { ref: published.workspaceArchiveRef } : {},
2332
+ persist: () => persistWarmSnapshot(db, {
2333
+ accountId: ids.accountId,
2334
+ workspaceId: ids.workspaceId,
2335
+ sessionId: ids.sessionId,
2336
+ turnId: ids.turnId,
2337
+ attemptId: ids.attemptId,
2338
+ sandboxGroupId: ids.sandboxGroupId,
2339
+ expectedEpoch: leaseEpoch,
2340
+ expectedInstanceId: instanceId,
2341
+ expectedWorkspaceGeneration: claimed.claim.workspaceGeneration,
2342
+ captureId,
2343
+ workspaceArchiveMeta: archiveDescriptor,
2344
+ ...published,
2345
+ checkpointArtifactId: candidate?.id ?? null,
2346
+ minIntervalMs: force ? 0 : intervalMs,
2347
+ capturedAtMs
2348
+ })
2311
2349
  });
2312
- if (published.workspaceArchiveRef && services.objectStorage) {
2313
- if (!wrote) {
2314
- await deleteUnpublishedWorkspaceArchiveObject(
2315
- services.objectStorage,
2316
- published.workspaceArchiveRef,
2317
- services.sandboxMetrics
2318
- );
2319
- } else {
2320
- const afterLease = await readLease(db, ids.workspaceId, ids.sandboxGroupId);
2321
- const afterKeys = collectWorkspaceArchiveObjectKeys(
2322
- afterLease?.resumeState ?? null
2323
- );
2324
- await deleteWorkspaceArchiveObjectKeys(
2325
- services.objectStorage,
2326
- [...priorKeys].filter((key) => !afterKeys.has(key))
2327
- ).catch(() => void 0);
2328
- }
2329
- }
2330
2350
  if (!wrote && candidate) {
2331
2351
  await abandonCandidate(candidate.id, "snapshot_publication_fenced");
2332
2352
  }
2333
2353
  return wrote;
2334
2354
  } catch (error) {
2335
- await deleteUnpublishedWorkspaceArchiveObject(
2336
- services.objectStorage,
2337
- workspaceArchiveRef,
2338
- services.sandboxMetrics
2339
- );
2340
- if (candidate) await abandonCandidate(candidate.id, "snapshot_capture_failed");
2355
+ if (candidate && !publicationAttempted)
2356
+ await abandonCandidate(candidate.id, "snapshot_capture_failed");
2341
2357
  throw error;
2342
2358
  } finally {
2359
+ await disposeWorkspaceArchive(archive).catch(() => {
2360
+ console.warn("workspace archive spool cleanup failed");
2361
+ });
2343
2362
  await releaseWorkspaceArchiveCapture(db, {
2344
2363
  accountId: ids.accountId,
2345
2364
  workspaceId: ids.workspaceId,
@@ -2679,6 +2698,24 @@ async function resumeBoxForTurn(services, ids, kind, holderId) {
2679
2698
  const established = await establishSandboxSessionFromEnvelope(settings, hydrateEnvelope, {
2680
2699
  sessionId: ids.sessionId,
2681
2700
  recovery: "create-or-restore",
2701
+ ...services.objectStorage ? {
2702
+ loadHostWorkspaceArchive: async (ref) => {
2703
+ try {
2704
+ return await downloadWorkspaceArchiveSpool(services.objectStorage, ref.key, {
2705
+ bytes: ref.bytes,
2706
+ sha256: ref.sha256
2707
+ });
2708
+ } catch (error) {
2709
+ if (error instanceof WorkspaceArchiveStorageError) {
2710
+ throw new WorkspaceArchiveIntegrityError(error.code, error.message, {
2711
+ retryable: error.retryable,
2712
+ cause: error
2713
+ });
2714
+ }
2715
+ throw error;
2716
+ }
2717
+ }
2718
+ } : {},
2682
2719
  backendOverride: ids.backend,
2683
2720
  ...ids.environment ? { environment: ids.environment } : {},
2684
2721
  ...services.sandboxMetrics ? { metrics: services.sandboxMetrics } : {},
@@ -3257,11 +3294,11 @@ function afterPersistableHomeMutation(services, ids, home) {
3257
3294
  function beforeRetainedProcessMutation(services, ids) {
3258
3295
  const fence = ids.workspaceMutationFence;
3259
3296
  if (!fence) return void 0;
3260
- return async ({ op, process }) => await advanceWorkspaceGenerationForRetainedProcess(services.db, {
3297
+ return async ({ op, process: process2 }) => await advanceWorkspaceGenerationForRetainedProcess(services.db, {
3261
3298
  accountId: fence.accountId,
3262
3299
  workspaceId: ids.workspaceId,
3263
3300
  sessionId: ids.sessionId,
3264
- processId: process.id,
3301
+ processId: process2.id,
3265
3302
  operation: op,
3266
3303
  captureWaitMs: sandboxLifecycleTransitionWaitMs2(services.settings),
3267
3304
  ...services.waitSignal ? { waitSignal: services.waitSignal } : {}
@@ -3270,7 +3307,7 @@ function beforeRetainedProcessMutation(services, ids) {
3270
3307
  function afterRetainedProcessMutation(services, ids) {
3271
3308
  const fence = ids.workspaceMutationFence;
3272
3309
  if (!fence) return void 0;
3273
- return async ({ op, process, admission, outcome }) => {
3310
+ return async ({ op, process: process2, admission, outcome }) => {
3274
3311
  if (!admission || typeof admission !== "object" || typeof admission.id !== "string" || typeof admission.workspaceGeneration !== "number") {
3275
3312
  throw new Error("Retained-process mutation settlement lacked its exact admission");
3276
3313
  }
@@ -3278,7 +3315,7 @@ function afterRetainedProcessMutation(services, ids) {
3278
3315
  accountId: fence.accountId,
3279
3316
  workspaceId: ids.workspaceId,
3280
3317
  sessionId: ids.sessionId,
3281
- processId: process.id,
3318
+ processId: process2.id,
3282
3319
  admission,
3283
3320
  operation: op,
3284
3321
  outcome
@@ -3304,7 +3341,7 @@ function captureRetainedProcessOutputForTurn(services, ids) {
3304
3341
  const accountId = ids.workspaceMutationFence?.accountId;
3305
3342
  if (!accountId) return void 0;
3306
3343
  return async ({
3307
- process,
3344
+ process: process2,
3308
3345
  chunkId,
3309
3346
  chunk,
3310
3347
  stream,
@@ -3314,7 +3351,7 @@ function captureRetainedProcessOutputForTurn(services, ids) {
3314
3351
  accountId,
3315
3352
  workspaceId: ids.workspaceId,
3316
3353
  sessionId: ids.sessionId,
3317
- commandId: process.id,
3354
+ commandId: process2.id,
3318
3355
  chunkId,
3319
3356
  chunk,
3320
3357
  stream,
@@ -3327,32 +3364,32 @@ function captureRetainedProcessOutputForTurn(services, ids) {
3327
3364
  function observeRetainedProcessTerminalForTurn(services, ids) {
3328
3365
  const fence = ids.workspaceMutationFence;
3329
3366
  if (!fence) return void 0;
3330
- return async ({ process }) => {
3367
+ return async ({ process: process2 }) => {
3331
3368
  await observeSessionBackgroundCommandCompletion(services.db, {
3332
3369
  accountId: fence.accountId,
3333
3370
  workspaceId: ids.workspaceId,
3334
3371
  sessionId: ids.sessionId,
3335
- commandId: process.id
3372
+ commandId: process2.id
3336
3373
  });
3337
3374
  };
3338
3375
  }
3339
3376
  function settleRetainedProcessForTurn(services, ids) {
3340
3377
  const fence = ids.workspaceMutationFence;
3341
3378
  if (!fence) return void 0;
3342
- return async ({ backend, process, proof }) => {
3379
+ return async ({ backend, process: process2, proof }) => {
3343
3380
  const durable = await getRetainedProcess(services.db, {
3344
3381
  workspaceId: ids.workspaceId,
3345
3382
  sessionId: ids.sessionId,
3346
- processId: process.id
3383
+ processId: process2.id
3347
3384
  });
3348
- if (!durable || durable.providerSessionId !== process.providerSessionId || durable.providerBackend !== backend.kind || durable.providerInstanceId !== backend.providerInstanceId || durable.leaseEpoch !== backend.leaseEpoch || durable.routeKind !== (backend.sandboxId === null ? "home" : "active") || durable.routeTargetId !== backend.sandboxId || durable.routeEpoch !== backend.activeEpoch) {
3385
+ if (!durable || durable.providerSessionId !== process2.providerSessionId || durable.providerBackend !== backend.kind || durable.providerInstanceId !== backend.providerInstanceId || durable.leaseEpoch !== backend.leaseEpoch || durable.routeKind !== (backend.sandboxId === null ? "home" : "active") || durable.routeTargetId !== backend.sandboxId || durable.routeEpoch !== backend.activeEpoch) {
3349
3386
  throw new Error("Retained-process settlement lost its exact durable backend identity");
3350
3387
  }
3351
3388
  const settlement = await settleRetainedProcess(services.db, {
3352
3389
  accountId: fence.accountId,
3353
3390
  workspaceId: ids.workspaceId,
3354
3391
  sessionId: ids.sessionId,
3355
- processId: process.id,
3392
+ processId: process2.id,
3356
3393
  expected: retainedProcessSettlementIdentity(durable),
3357
3394
  outcome: proof.outcome,
3358
3395
  exitCode: proof.exitCode,
@@ -3370,13 +3407,13 @@ function settleRetainedProcessForTurn(services, ids) {
3370
3407
  function adoptRetainedProcessAsBackgroundCommandForTurn(services, ids) {
3371
3408
  const fence = ids.workspaceMutationFence;
3372
3409
  if (!fence) return void 0;
3373
- return async ({ backend, process }) => {
3410
+ return async ({ backend, process: process2 }) => {
3374
3411
  const durable = await getRetainedProcess(services.db, {
3375
3412
  workspaceId: ids.workspaceId,
3376
3413
  sessionId: ids.sessionId,
3377
- processId: process.id
3414
+ processId: process2.id
3378
3415
  });
3379
- if (!durable || durable.providerSessionId !== process.providerSessionId || durable.providerBackend !== backend.kind || durable.providerInstanceId !== backend.providerInstanceId || durable.leaseEpoch !== backend.leaseEpoch || durable.routeKind !== (backend.sandboxId === null ? "home" : "active") || durable.routeTargetId !== backend.sandboxId || durable.routeEpoch !== backend.activeEpoch) {
3416
+ if (!durable || durable.providerSessionId !== process2.providerSessionId || durable.providerBackend !== backend.kind || durable.providerInstanceId !== backend.providerInstanceId || durable.leaseEpoch !== backend.leaseEpoch || durable.routeKind !== (backend.sandboxId === null ? "home" : "active") || durable.routeTargetId !== backend.sandboxId || durable.routeEpoch !== backend.activeEpoch) {
3380
3417
  throw new Error("Background command adoption lost its exact retained-process identity");
3381
3418
  }
3382
3419
  await adoptManagedSessionBackgroundCommand(services.db, {
@@ -3386,7 +3423,7 @@ function adoptRetainedProcessAsBackgroundCommandForTurn(services, ids) {
3386
3423
  turnId: fence.turnId,
3387
3424
  executionGeneration: fence.executionGeneration,
3388
3425
  attemptId: fence.attemptId,
3389
- processId: process.id,
3426
+ processId: process2.id,
3390
3427
  expected: retainedProcessSettlementIdentity(durable),
3391
3428
  command: "execCommand"
3392
3429
  });
@@ -3563,11 +3600,11 @@ function wrapTurnBoxWithRouting(services, ids, established) {
3563
3600
  ...services.onSandboxOperation ? { onOperation: services.onSandboxOperation } : {},
3564
3601
  providerCommandHandle: admittedCommandHandle,
3565
3602
  ...ids.workspaceMutationFence ? {
3566
- providerCommandPersistence: (process) => retainedProviderCommandPersistence(db, {
3603
+ providerCommandPersistence: (process2) => retainedProviderCommandPersistence(db, {
3567
3604
  accountId: ids.workspaceMutationFence.accountId,
3568
3605
  workspaceId: ids.workspaceId,
3569
3606
  sessionId: ids.sessionId,
3570
- processId: process.id
3607
+ processId: process2.id
3571
3608
  })
3572
3609
  } : {},
3573
3610
  ...beforeMutation ? { beforeMutation } : {},
@@ -3760,11 +3797,11 @@ function wrapLazyTurnBoxWithRouting(services, ids, args) {
3760
3797
  ...args.onFirstOperation ? { onFirstOperation: args.onFirstOperation } : {},
3761
3798
  providerCommandHandle: admittedCommandHandle,
3762
3799
  ...ids.workspaceMutationFence ? {
3763
- providerCommandPersistence: (process) => retainedProviderCommandPersistence(db, {
3800
+ providerCommandPersistence: (process2) => retainedProviderCommandPersistence(db, {
3764
3801
  accountId: ids.workspaceMutationFence.accountId,
3765
3802
  workspaceId: ids.workspaceId,
3766
3803
  sessionId: ids.sessionId,
3767
- processId: process.id
3804
+ processId: process2.id
3768
3805
  })
3769
3806
  } : {},
3770
3807
  ...beforeMutation ? { beforeMutation } : {},
@@ -4783,7 +4820,7 @@ import {
4783
4820
  classifyProviderSandboxFailure
4784
4821
  } from "@opengeni/runtime";
4785
4822
  import { CancelledFailure } from "@temporalio/activity";
4786
- import { randomUUID as randomUUID3 } from "crypto";
4823
+ import { randomUUID as randomUUID4 } from "crypto";
4787
4824
  var TurnOperationCancelledError = class extends Error {
4788
4825
  constructor(reason) {
4789
4826
  super("Turn operation was cancelled with its owning turn", {
@@ -5074,7 +5111,7 @@ function createTurnSandboxProvisioner(establish, options = {}) {
5074
5111
  return {
5075
5112
  get() {
5076
5113
  if (!memo) {
5077
- const provisionId = options.provisionIdFactory?.() ?? randomUUID3();
5114
+ const provisionId = options.provisionIdFactory?.() ?? randomUUID4();
5078
5115
  memo = (async () => {
5079
5116
  const startedAt = performance.now();
5080
5117
  throwIfTurnOperationCancelled(options.signal);
@@ -6639,10 +6676,8 @@ export {
6639
6676
  currentActivityContext,
6640
6677
  startActivityHeartbeat,
6641
6678
  nextStreamEvent,
6642
- collectWorkspaceArchiveObjectKeys,
6679
+ persistWorkspaceArchiveCandidate,
6643
6680
  putVersion1TarArchiveOrInline,
6644
- deleteUnpublishedWorkspaceArchiveObject,
6645
- deleteWorkspaceArchiveObjectKeys,
6646
6681
  sandboxLeaseHolderIdForAttempt,
6647
6682
  waitForWarmSnapshot,
6648
6683
  maybePersistWarmWorkspaceSnapshot,
@@ -6724,4 +6759,4 @@ export {
6724
6759
  codexUsageLimitFailurePayload,
6725
6760
  CODEX_USAGE_LIMIT_MAX_RESUME_MS
6726
6761
  };
6727
- //# sourceMappingURL=chunk-AKP6BKM2.js.map
6762
+ //# sourceMappingURL=chunk-ZNIKZQMN.js.map