@adea-ai/app-framework 0.31.0 → 0.33.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 (111) hide show
  1. package/README.md +33 -15
  2. package/dist/app/create-application.js +4 -3
  3. package/dist/app/serial-queue.d.ts +5 -0
  4. package/dist/app/serial-queue.js +14 -0
  5. package/dist/app/value-guards.d.ts +15 -0
  6. package/dist/app/value-guards.js +29 -0
  7. package/dist/ci/toolchain-identity.js +1 -1
  8. package/dist/desktop/channel-proof.js +2 -1
  9. package/dist/desktop/client-asset-stream.js +6 -12
  10. package/dist/desktop/desktop-host.d.ts +25 -5
  11. package/dist/desktop/desktop-host.js +75 -20
  12. package/dist/framework-source.json +1 -1
  13. package/dist/installer/command-artifact.js +4 -3
  14. package/dist/installer/command-qualification-command.js +6 -5
  15. package/dist/installer/hosted-runner.d.ts +9 -2
  16. package/dist/installer/hosted-runner.js +18 -5
  17. package/dist/installer/installed-payload.js +20 -46
  18. package/dist/installer/installer-archive.d.ts +33 -0
  19. package/dist/installer/installer-archive.js +116 -0
  20. package/dist/installer/installer-ci-bootstrap.js +10 -6
  21. package/dist/installer/installer-extraction.js +54 -120
  22. package/dist/installer/installer-identity.js +33 -111
  23. package/dist/installer/installer-observation.js +3 -2
  24. package/dist/installer/installer-process-cleanup.js +7 -46
  25. package/dist/installer/installer-qualification-command.js +6 -5
  26. package/dist/installer/installer-upgrade-command.js +5 -5
  27. package/dist/installer/installer-worker-guard.js +2 -1
  28. package/dist/native/canonical-path.d.ts +5 -0
  29. package/dist/native/canonical-path.js +10 -0
  30. package/dist/native/cef-helper.js +5 -4
  31. package/dist/native/electrobun-source-patch.js +3 -2
  32. package/dist/native/{directory-exchange.d.ts → native-rename.d.ts} +2 -0
  33. package/dist/native/native-rename.js +126 -0
  34. package/dist/native/native-secret-store.js +2 -6
  35. package/dist/native/native-utilities.js +4 -4
  36. package/dist/native/posix-launcher-build.js +1 -1
  37. package/dist/native/posix-tree-removal.js +2 -2
  38. package/dist/native/windows-process.d.ts +9 -0
  39. package/dist/native/windows-process.js +60 -0
  40. package/dist/release/feed-release-cut.js +2 -1
  41. package/dist/release/framework-package-publish.js +1 -1
  42. package/dist/release/framework-update-lock.js +2 -1
  43. package/dist/release/github-cli.d.ts +18 -0
  44. package/dist/release/github-cli.js +13 -1
  45. package/dist/release/github-release-cut.js +3 -2
  46. package/dist/release/github-release-provenance.js +2 -1
  47. package/dist/release/github-release-publisher.js +2 -1
  48. package/dist/release/local-provenance.js +3 -2
  49. package/dist/release/local-release.js +6 -6
  50. package/dist/release/qualification-run.d.ts +25 -0
  51. package/dist/release/qualification-run.js +43 -0
  52. package/dist/release/release-artifact.js +3 -11
  53. package/dist/release/release-assets-plan.js +16 -6
  54. package/dist/release/release-config.js +14 -14
  55. package/dist/release/release-cut-command.js +14 -4
  56. package/dist/release/release-cut.js +3 -2
  57. package/dist/release/release-descriptor-staging.js +13 -27
  58. package/dist/release/release-finalize.js +2 -1
  59. package/dist/release/release-publication.js +3 -11
  60. package/dist/release/release-publish-command.js +15 -6
  61. package/dist/release/release-qualification.js +3 -2
  62. package/dist/release/retained-release-build.js +12 -12
  63. package/dist/update-helper.bundle.js +250 -178
  64. package/dist/updates/desktop-updater.js +53 -58
  65. package/dist/updates/packaged-launch-admission.js +3 -2
  66. package/dist/updates/packaged-release-config.js +6 -5
  67. package/dist/updates/packaged-update-startup.d.ts +25 -5
  68. package/dist/updates/packaged-update-startup.js +30 -5
  69. package/dist/updates/release-feed.js +9 -9
  70. package/dist/updates/signed-release.js +5 -5
  71. package/dist/updates/stable-file.d.ts +18 -0
  72. package/dist/updates/stable-file.js +65 -2
  73. package/dist/updates/update-adapter.d.ts +2 -13
  74. package/dist/updates/update-arm.js +13 -13
  75. package/dist/updates/update-channel-store.js +7 -9
  76. package/dist/updates/update-discovery.js +30 -34
  77. package/dist/updates/update-download-cleanup.js +2 -1
  78. package/dist/updates/update-download.js +2 -4
  79. package/dist/updates/update-extraction.js +1 -1
  80. package/dist/updates/update-generation-lease.js +4 -3
  81. package/dist/updates/update-handoff-plan.js +3 -2
  82. package/dist/updates/update-helper.js +8 -6
  83. package/dist/updates/update-instance-lease.js +3 -2
  84. package/dist/updates/update-launch-gate.js +12 -25
  85. package/dist/updates/update-launch.js +3 -2
  86. package/dist/updates/update-lock.js +3 -2
  87. package/dist/updates/update-marker.js +3 -2
  88. package/dist/updates/update-process-fence.js +10 -39
  89. package/dist/updates/update-process-liveness.js +2 -1
  90. package/dist/updates/update-resume.js +30 -27
  91. package/dist/updates/update-retention-marker.js +7 -5
  92. package/dist/updates/update-retention-plan.js +2 -2
  93. package/dist/updates/update-retirement.js +52 -52
  94. package/dist/updates/update-state-store.d.ts +2 -0
  95. package/dist/updates/update-state-store.js +34 -38
  96. package/dist/updates/update-state.d.ts +8 -3
  97. package/dist/updates/update-swap-stage.js +6 -5
  98. package/dist/updates/update-swap.d.ts +1 -1
  99. package/dist/updates/update-swap.js +8 -6
  100. package/package.json +4 -12
  101. package/src/desktop/client-asset-stream.ts +6 -12
  102. package/src/updates/update-adapter.ts +2 -14
  103. package/src/updates/update-state.ts +11 -2
  104. package/templates/application/src/bun/index.ts +13 -9
  105. package/dist/native/directory-exchange.js +0 -90
  106. package/dist/native/exclusive-rename.d.ts +0 -2
  107. package/dist/native/exclusive-rename.js +0 -52
  108. package/dist/release/retention-dry-run.d.ts +0 -46
  109. package/dist/release/retention-dry-run.js +0 -94
  110. package/dist/updates/update-exclusive-rename.d.ts +0 -3
  111. package/dist/updates/update-exclusive-rename.js +0 -5
@@ -1,7 +1,8 @@
1
+ import { UUID_SOURCE, errorCode, isUuid } from "../app/value-guards.js";
2
+ import { renameExclusive } from "../native/native-rename.js";
1
3
  import { verifyReleaseDescriptor } from "./signed-release.js";
2
- import { renameUpdateExclusive } from "./update-exclusive-rename.js";
3
4
  import { tryAcquireUpdateLock } from "./update-lock.js";
4
- import { UpdateLockBusyError, acquireUpdateLock, readUpdateStageState, syncUpdateStageDirectory, writeUpdateStageState, writeUpdateStageStateDurably } from "./update-state-store.js";
5
+ import { UpdateLockBusyError, acquireUpdateLock, readUpdateHelperRequestFile, readUpdateStageState, syncUpdateStageDirectory, writeUpdateStageState, writeUpdateStageStateDurably } from "./update-state-store.js";
5
6
  import { readUpdateTreeDigest, readUpdateTreeIdentity, readUpdateTreeVersion, sameUpdateTreeDigest, sameUpdateTreeIdentity, syncUpdateTreeParent, updateStagingFor } from "./update-swap.js";
6
7
  import { readUpdateMarker } from "./update-marker.js";
7
8
  import { tryAcquireUpdateInstanceLease } from "./update-instance-lease.js";
@@ -11,12 +12,12 @@ import { updateProcessMayBeAlive } from "./update-process-liveness.js";
11
12
  import { acquireRetainedUpdateTrees, acquireRetainedUpdateTreesWhileLocked, reconcileRetirementCleanupMarkerWhileLocked, retireCompletedUpdateWhileLocked } from "./update-retirement.js";
12
13
  import { lstat, open, readFile, readdir, realpath, rm, rmdir, unlink } from "node:fs/promises";
13
14
  import { join } from "node:path";
14
- import { constants as constants$1 } from "node:fs";
15
15
  import { randomUUID } from "node:crypto";
16
+ import { constants as constants$1 } from "node:fs";
16
17
  // src/updates/update-resume.ts
17
18
  async function exists(path) {
18
19
  return lstat(path).then(() => true, (error) => {
19
- if (error.code === "ENOENT") return false;
20
+ if (errorCode(error) === "ENOENT") return false;
20
21
  throw error;
21
22
  });
22
23
  }
@@ -43,10 +44,9 @@ async function recoverLegacyHandoff(options) {
43
44
  if (!Number.isSafeInteger(helperPid) || helperPid < 2 || updateProcessMayBeAlive(helperPid)) return { status: "recovery-required" };
44
45
  let request;
45
46
  try {
46
- const path = join(staging, "request.json");
47
- const info = await lstat(path);
48
- if (!info.isFile() || info.isSymbolicLink() || info.size < 1 || info.size > 65536) return { status: "recovery-required" };
49
- request = parseUpdateHelperRequest(JSON.parse(await readFile(path, "utf8")));
47
+ const text = await readUpdateHelperRequestFile(staging);
48
+ if (text === void 0) return { status: "recovery-required" };
49
+ request = parseUpdateHelperRequest(JSON.parse(text));
50
50
  } catch {
51
51
  return { status: "recovery-required" };
52
52
  }
@@ -81,13 +81,13 @@ async function recoverLegacyHandoff(options) {
81
81
  if (!targetExists && oldExists) {
82
82
  const oldInfo = await lstat(old);
83
83
  if (!oldInfo.isDirectory() || oldInfo.isSymbolicLink() || await readUpdateTreeVersion(old) !== currentVersion) return { status: "recovery-required" };
84
- renameUpdateExclusive(old, target);
84
+ renameExclusive(old, target);
85
85
  } else if (targetExists && !oldExists) {
86
86
  const targetInfo = await lstat(target);
87
87
  if (!targetInfo.isDirectory() || targetInfo.isSymbolicLink() || await readUpdateTreeVersion(target) !== currentVersion) return { status: "recovery-required" };
88
88
  } else return { status: "recovery-required" };
89
89
  const archived = `${staging}.legacy-${randomUUID()}`;
90
- renameUpdateExclusive(staging, archived);
90
+ renameExclusive(staging, archived);
91
91
  return { status: "not-applied" };
92
92
  }
93
93
  async function resetToStaged(staging, state) {
@@ -135,7 +135,7 @@ async function reconcileSwap(target, staging, state) {
135
135
  const [oldInfo, candidateInfo] = await Promise.all([lstat(old), lstat(candidate)]);
136
136
  const [oldIdentity, candidateIdentity] = await Promise.all([readUpdateTreeIdentity(old), readUpdateTreeIdentity(candidate)]);
137
137
  if (!oldInfo.isDirectory() || oldInfo.isSymbolicLink() || !candidateInfo.isDirectory() || candidateInfo.isSymbolicLink() || !oldIdentity || !candidateIdentity || !sameUpdateTreeIdentity(candidateIdentity, state.candidateTreeIdentity) || sameUpdateTreeIdentity(oldIdentity, candidateIdentity) || state.previousTreeIdentity && !sameUpdateTreeIdentity(oldIdentity, state.previousTreeIdentity) || await readUpdateTreeVersion(old) !== state.previousVersion || await readUpdateTreeVersion(candidate) !== state.version || state.candidateTreeDigest !== void 0 && !sameUpdateTreeDigest(await readTreeDigestForProof(candidate), state.candidateTreeDigest)) return void 0;
138
- renameUpdateExclusive(old, target);
138
+ renameExclusive(old, target);
139
139
  return resetToStaged(staging, state);
140
140
  } catch {
141
141
  return;
@@ -172,7 +172,7 @@ async function recoverStagedCandidate(options) {
172
172
  try {
173
173
  info = await lstat(candidate);
174
174
  } catch (error) {
175
- if (error.code === "ENOENT") return { status: "recovery-required" };
175
+ if (errorCode(error) === "ENOENT") return { status: "recovery-required" };
176
176
  throw error;
177
177
  }
178
178
  if (!info.isDirectory() || info.isSymbolicLink()) return { status: "recovery-required" };
@@ -330,7 +330,6 @@ async function resumeLocked(options) {
330
330
  }
331
331
  throw new Error("Invalid update staging phase");
332
332
  }
333
- var recoveryUuid = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
334
333
  var recoveryStagingEntries = /* @__PURE__ */ new Set([
335
334
  "candidate",
336
335
  "helper",
@@ -351,7 +350,7 @@ async function readOptionalRecoveryFile(path, maxBytes) {
351
350
  try {
352
351
  info = await lstat(path);
353
352
  } catch (error) {
354
- if (error.code === "ENOENT") return void 0;
353
+ if (errorCode(error) === "ENOENT") return void 0;
355
354
  throw error;
356
355
  }
357
356
  if (!info.isFile() || info.isSymbolicLink() || info.size < 1 || info.size > maxBytes) throw new Error("Invalid schema-3 helper recovery artifact");
@@ -366,7 +365,7 @@ async function readOptionalRecoveryFile(path, maxBytes) {
366
365
  }
367
366
  async function recoveryInventoryIsKnown(staging, state) {
368
367
  const names = await readdir(staging);
369
- const stateTemporary = new RegExp(`^\\.state-${state.generation}-[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}\\.tmp$`, "i");
368
+ const stateTemporary = stateTemporaryPattern(state.generation);
370
369
  for (const name of names) {
371
370
  if (recoveryStagingEntries.has(name)) continue;
372
371
  if (!stateTemporary.test(name)) return false;
@@ -387,9 +386,13 @@ async function recoveryInventoryIsKnown(staging, state) {
387
386
  }
388
387
  return true;
389
388
  }
389
+ /** The temporary names `writeUpdateStageState` leaves for one generation's state file. */
390
+ function stateTemporaryPattern(generation) {
391
+ return new RegExp(`^\\.state-${generation}-${UUID_SOURCE}\\.tmp$`, "i");
392
+ }
390
393
  async function isCanonicalRecoveryStaging(staging) {
391
394
  const info = await lstat(staging).catch((error) => {
392
- if (error.code === "ENOENT") return void 0;
395
+ if (errorCode(error) === "ENOENT") return void 0;
393
396
  throw error;
394
397
  });
395
398
  return Boolean(info && info.isDirectory() && !info.isSymbolicLink() && await realpath(staging) === staging);
@@ -403,7 +406,7 @@ async function helperDirectoryIsKnown(staging, state, gate, requestMayBeAbsent)
403
406
  try {
404
407
  entries = await readdir(helper);
405
408
  } catch (error) {
406
- if (error.code === "ENOENT") return requestMayBeAbsent;
409
+ if (errorCode(error) === "ENOENT") return requestMayBeAbsent;
407
410
  throw error;
408
411
  }
409
412
  const copiedFiles = /* @__PURE__ */ new Set();
@@ -416,7 +419,7 @@ async function helperDirectoryIsKnown(staging, state, gate, requestMayBeAbsent)
416
419
  continue;
417
420
  }
418
421
  const match = /^\.(helper-ready|cancel\.json|cancel-ack\.json)\.([0-9a-f-]{36})\.tmp$/i.exec(name);
419
- if (!match || !recoveryUuid.test(match[2])) return false;
422
+ if (!match || !isUuid(match[2])) return false;
420
423
  let text;
421
424
  try {
422
425
  text = await readOptionalRecoveryFile(path, 1024);
@@ -558,10 +561,10 @@ async function schema3TreeLayout(target, staging, state) {
558
561
  if (!state.candidateTreeIdentity || !state.candidateTreeDigest || !state.previousTreeIdentity) return void 0;
559
562
  const candidate = join(staging, "candidate");
560
563
  const [targetInfo, candidateInfo] = await Promise.all([lstat(target).catch((error) => {
561
- if (error.code === "ENOENT") return void 0;
564
+ if (errorCode(error) === "ENOENT") return void 0;
562
565
  throw error;
563
566
  }), lstat(candidate).catch((error) => {
564
- if (error.code === "ENOENT") return void 0;
567
+ if (errorCode(error) === "ENOENT") return void 0;
565
568
  throw error;
566
569
  })]);
567
570
  if (!targetInfo || !targetInfo.isDirectory() || targetInfo.isSymbolicLink() || !candidateInfo || !candidateInfo.isDirectory() || candidateInfo.isSymbolicLink()) return void 0;
@@ -581,7 +584,7 @@ function schema3JournalMatchesGate(state, gate) {
581
584
  "swapping",
582
585
  "completed",
583
586
  "staged"
584
- ].includes(state.phase) && state.generation === gate.generation && state.version === gate.version && state.launchGateOwner === gate.owner && typeof state.helperOwner === "string" && recoveryUuid.test(state.helperOwner) && Number.isSafeInteger(state.helperPid) && (state.helperPid ?? 0) >= 2 && recoveryUuid.test(state.generation) && state.version !== state.previousVersion && state.candidateTreeIdentity !== void 0 && state.candidateTreeDigest !== void 0 && state.previousTreeIdentity !== void 0);
587
+ ].includes(state.phase) && state.generation === gate.generation && state.version === gate.version && state.launchGateOwner === gate.owner && typeof state.helperOwner === "string" && isUuid(state.helperOwner) && Number.isSafeInteger(state.helperPid) && (state.helperPid ?? 0) >= 2 && isUuid(state.generation) && state.version !== state.previousVersion && state.candidateTreeIdentity !== void 0 && state.candidateTreeDigest !== void 0 && state.previousTreeIdentity !== void 0);
585
588
  }
586
589
  async function removeSchema3HelperArtifacts(staging) {
587
590
  for (const name of [
@@ -593,7 +596,7 @@ async function removeSchema3HelperArtifacts(staging) {
593
596
  ]) await rm(join(staging, name), { force: true });
594
597
  const state = await readUpdateStageState(staging);
595
598
  if (!state) throw new Error("Schema-3 recovery journal disappeared");
596
- const stateTemporary = new RegExp(`^\\.state-${state.generation}-[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}\\.tmp$`, "i");
599
+ const stateTemporary = stateTemporaryPattern(state.generation);
597
600
  for (const name of await readdir(staging)) {
598
601
  if (!stateTemporary.test(name)) continue;
599
602
  const path = join(staging, name);
@@ -608,7 +611,7 @@ async function removeSchema3HelperArtifacts(staging) {
608
611
  }
609
612
  async function finalizationTemporaries(staging, state) {
610
613
  const names = await readdir(staging);
611
- const stateTemporary = new RegExp(`^\\.state-${state.generation}-[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}\\.tmp$`, "i");
614
+ const stateTemporary = stateTemporaryPattern(state.generation);
612
615
  const temporaryNames = [];
613
616
  for (const name of names) {
614
617
  if (name === "candidate" || name === "state.json") {
@@ -637,10 +640,10 @@ async function ownerlessStagedTreeMatches(target, staging, state) {
637
640
  if (!state.candidateTreeIdentity || !state.candidateTreeDigest) return false;
638
641
  const candidate = join(staging, "candidate");
639
642
  const [targetInfo, candidateInfo] = await Promise.all([lstat(target).catch((error) => {
640
- if (error.code === "ENOENT") return void 0;
643
+ if (errorCode(error) === "ENOENT") return void 0;
641
644
  throw error;
642
645
  }), lstat(candidate).catch((error) => {
643
- if (error.code === "ENOENT") return void 0;
646
+ if (errorCode(error) === "ENOENT") return void 0;
644
647
  throw error;
645
648
  })]);
646
649
  if (!targetInfo || !targetInfo.isDirectory() || targetInfo.isSymbolicLink() || !candidateInfo || !candidateInfo.isDirectory() || candidateInfo.isSymbolicLink()) return false;
@@ -703,7 +706,7 @@ async function finalizeClearedSchema3StagedOwner(target, staging, trust) {
703
706
  if (!helper) return "helper-live";
704
707
  await syncUpdateTreeParent(target);
705
708
  if (!await lstat(staging).catch((error) => {
706
- if (error.code === "ENOENT") return void 0;
709
+ if (errorCode(error) === "ENOENT") return void 0;
707
710
  throw error;
708
711
  })) return "absent";
709
712
  if (!await isCanonicalRecoveryStaging(staging)) return "unreconciled";
@@ -722,7 +725,7 @@ async function finalizeClearedSchema3StagedOwner(target, staging, trust) {
722
725
  await syncUpdateStageDirectory(staging);
723
726
  return "absent";
724
727
  }
725
- if (!recoveryUuid.test(state.generation) || !recoveryUuid.test(state.launchGateOwner) || !recoveryUuid.test(state.helperOwner ?? "") || !Number.isSafeInteger(state.helperPid) || (state.helperPid ?? 0) < 2) return "unreconciled";
728
+ if (!isUuid(state.generation) || !isUuid(state.launchGateOwner) || !isUuid(state.helperOwner ?? "") || !Number.isSafeInteger(state.helperPid) || (state.helperPid ?? 0) < 2) return "unreconciled";
726
729
  const verified = state.signedRelease ? verifyReleaseDescriptor(state.signedRelease, trust) : { ok: false };
727
730
  if (!verified.ok || verified.descriptor.version !== state.version) return "unreconciled";
728
731
  const temporaries = await finalizationTemporaries(staging, state);
@@ -1,7 +1,9 @@
1
+ import { errorCode } from "../app/value-guards.js";
2
+ import { isCanonicalPath } from "../native/canonical-path.js";
1
3
  import { link, lstat, open, unlink, writeFile } from "node:fs/promises";
2
- import { basename, dirname, isAbsolute, join, resolve } from "node:path";
3
- import { constants as constants$1 } from "node:fs";
4
+ import { basename, dirname, join } from "node:path";
4
5
  import { randomUUID } from "node:crypto";
6
+ import { constants as constants$1 } from "node:fs";
5
7
  // src/updates/update-retention-marker.ts
6
8
  /** Compare all fields that bind an intent to its retained and installed trees. */
7
9
  function sameRetentionIntent(left, right) {
@@ -20,7 +22,7 @@ var UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]
20
22
  var IDENTITY_COMPONENT = /^[1-9]\d{0,19}$/;
21
23
  var MAX_MARKER_BYTES = 2048;
22
24
  function assertCanonicalTarget(target) {
23
- if (typeof target !== "string" || !isAbsolute(target) || resolve(target) !== target || target.includes("\0")) throw new Error("Invalid update retention target");
25
+ if (!isCanonicalPath(target)) throw new Error("Invalid update retention target");
24
26
  }
25
27
  function assertGeneration(generation) {
26
28
  if (typeof generation !== "string" || !UUID.test(generation)) throw new Error("Invalid update retention generation");
@@ -133,7 +135,7 @@ async function readUpdateRetentionIntentFile(path, target, generation) {
133
135
  try {
134
136
  pathInfo = await lstat(path, { bigint: true });
135
137
  } catch (error) {
136
- if (error.code === "ENOENT") return void 0;
138
+ if (errorCode(error) === "ENOENT") return void 0;
137
139
  throw error;
138
140
  }
139
141
  if (!pathInfo.isFile() || pathInfo.isSymbolicLink() || pathInfo.size < 1n || pathInfo.size > BigInt(MAX_MARKER_BYTES)) throw new Error("Invalid update retention intent file");
@@ -141,7 +143,7 @@ async function readUpdateRetentionIntentFile(path, target, generation) {
141
143
  try {
142
144
  file = await open(path, constants$1.O_RDONLY | (constants$1.O_NOFOLLOW ?? 0) | (constants$1.O_NONBLOCK ?? 0));
143
145
  } catch (error) {
144
- if (error.code === "ENOENT") throw new Error("Update retention intent disappeared during inspection", { cause: error });
146
+ if (errorCode(error) === "ENOENT") throw new Error("Update retention intent disappeared during inspection", { cause: error });
145
147
  throw error;
146
148
  }
147
149
  try {
@@ -1,5 +1,5 @@
1
+ import { isUuid } from "../app/value-guards.js";
1
2
  // src/updates/update-retention-plan.ts
2
- var UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
3
3
  /** Canonical key for validated device/inode pairs used in retention inventories. */
4
4
  function retentionIdentityKey(identity) {
5
5
  if (!identity || typeof identity.device !== "string" || !/^[1-9]\d{0,19}$/.test(identity.device) || typeof identity.inode !== "string" || !/^[1-9]\d{0,19}$/.test(identity.inode)) return void 0;
@@ -25,7 +25,7 @@ function planUpdateRetention(current, generations) {
25
25
  const seenPrevious = /* @__PURE__ */ new Set();
26
26
  const seenGenerations = /* @__PURE__ */ new Set();
27
27
  for (const item of generations) {
28
- if (!item || !UUID.test(item.generation) || typeof item.healthy !== "boolean") return fail;
28
+ if (!item || !isUuid(item.generation) || typeof item.healthy !== "boolean") return fail;
29
29
  const installed = retentionIdentityKey(item.installed);
30
30
  const previous = retentionIdentityKey(item.previous);
31
31
  if (!installed || !previous || installed === previous || byInstalled.has(installed) || seenPrevious.has(previous) || seenGenerations.has(item.generation.toLowerCase())) return fail;