@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.
- package/README.md +33 -15
- package/dist/app/create-application.js +4 -3
- package/dist/app/serial-queue.d.ts +5 -0
- package/dist/app/serial-queue.js +14 -0
- package/dist/app/value-guards.d.ts +15 -0
- package/dist/app/value-guards.js +29 -0
- package/dist/ci/toolchain-identity.js +1 -1
- package/dist/desktop/channel-proof.js +2 -1
- package/dist/desktop/client-asset-stream.js +6 -12
- package/dist/desktop/desktop-host.d.ts +25 -5
- package/dist/desktop/desktop-host.js +75 -20
- package/dist/framework-source.json +1 -1
- package/dist/installer/command-artifact.js +4 -3
- package/dist/installer/command-qualification-command.js +6 -5
- package/dist/installer/hosted-runner.d.ts +9 -2
- package/dist/installer/hosted-runner.js +18 -5
- package/dist/installer/installed-payload.js +20 -46
- package/dist/installer/installer-archive.d.ts +33 -0
- package/dist/installer/installer-archive.js +116 -0
- package/dist/installer/installer-ci-bootstrap.js +10 -6
- package/dist/installer/installer-extraction.js +54 -120
- package/dist/installer/installer-identity.js +33 -111
- package/dist/installer/installer-observation.js +3 -2
- package/dist/installer/installer-process-cleanup.js +7 -46
- package/dist/installer/installer-qualification-command.js +6 -5
- package/dist/installer/installer-upgrade-command.js +5 -5
- package/dist/installer/installer-worker-guard.js +2 -1
- package/dist/native/canonical-path.d.ts +5 -0
- package/dist/native/canonical-path.js +10 -0
- package/dist/native/cef-helper.js +5 -4
- package/dist/native/electrobun-source-patch.js +3 -2
- package/dist/native/{directory-exchange.d.ts → native-rename.d.ts} +2 -0
- package/dist/native/native-rename.js +126 -0
- package/dist/native/native-secret-store.js +2 -6
- package/dist/native/native-utilities.js +4 -4
- package/dist/native/posix-launcher-build.js +1 -1
- package/dist/native/posix-tree-removal.js +2 -2
- package/dist/native/windows-process.d.ts +9 -0
- package/dist/native/windows-process.js +60 -0
- package/dist/release/feed-release-cut.js +2 -1
- package/dist/release/framework-package-publish.js +1 -1
- package/dist/release/framework-update-lock.js +2 -1
- package/dist/release/github-cli.d.ts +18 -0
- package/dist/release/github-cli.js +13 -1
- package/dist/release/github-release-cut.js +3 -2
- package/dist/release/github-release-provenance.js +2 -1
- package/dist/release/github-release-publisher.js +2 -1
- package/dist/release/local-provenance.js +3 -2
- package/dist/release/local-release.js +6 -6
- package/dist/release/qualification-run.d.ts +25 -0
- package/dist/release/qualification-run.js +43 -0
- package/dist/release/release-artifact.js +3 -11
- package/dist/release/release-assets-plan.js +16 -6
- package/dist/release/release-config.js +14 -14
- package/dist/release/release-cut-command.js +14 -4
- package/dist/release/release-cut.js +3 -2
- package/dist/release/release-descriptor-staging.js +13 -27
- package/dist/release/release-finalize.js +2 -1
- package/dist/release/release-publication.js +3 -11
- package/dist/release/release-publish-command.js +15 -6
- package/dist/release/release-qualification.js +3 -2
- package/dist/release/retained-release-build.js +12 -12
- package/dist/update-helper.bundle.js +250 -178
- package/dist/updates/desktop-updater.js +53 -58
- package/dist/updates/packaged-launch-admission.js +3 -2
- package/dist/updates/packaged-release-config.js +6 -5
- package/dist/updates/packaged-update-startup.d.ts +25 -5
- package/dist/updates/packaged-update-startup.js +30 -5
- package/dist/updates/release-feed.js +9 -9
- package/dist/updates/signed-release.js +5 -5
- package/dist/updates/stable-file.d.ts +18 -0
- package/dist/updates/stable-file.js +65 -2
- package/dist/updates/update-adapter.d.ts +2 -13
- package/dist/updates/update-arm.js +13 -13
- package/dist/updates/update-channel-store.js +7 -9
- package/dist/updates/update-discovery.js +30 -34
- package/dist/updates/update-download-cleanup.js +2 -1
- package/dist/updates/update-download.js +2 -4
- package/dist/updates/update-extraction.js +1 -1
- package/dist/updates/update-generation-lease.js +4 -3
- package/dist/updates/update-handoff-plan.js +3 -2
- package/dist/updates/update-helper.js +8 -6
- package/dist/updates/update-instance-lease.js +3 -2
- package/dist/updates/update-launch-gate.js +12 -25
- package/dist/updates/update-launch.js +3 -2
- package/dist/updates/update-lock.js +3 -2
- package/dist/updates/update-marker.js +3 -2
- package/dist/updates/update-process-fence.js +10 -39
- package/dist/updates/update-process-liveness.js +2 -1
- package/dist/updates/update-resume.js +30 -27
- package/dist/updates/update-retention-marker.js +7 -5
- package/dist/updates/update-retention-plan.js +2 -2
- package/dist/updates/update-retirement.js +52 -52
- package/dist/updates/update-state-store.d.ts +2 -0
- package/dist/updates/update-state-store.js +34 -38
- package/dist/updates/update-state.d.ts +8 -3
- package/dist/updates/update-swap-stage.js +6 -5
- package/dist/updates/update-swap.d.ts +1 -1
- package/dist/updates/update-swap.js +8 -6
- package/package.json +4 -12
- package/src/desktop/client-asset-stream.ts +6 -12
- package/src/updates/update-adapter.ts +2 -14
- package/src/updates/update-state.ts +11 -2
- package/templates/application/src/bun/index.ts +13 -9
- package/dist/native/directory-exchange.js +0 -90
- package/dist/native/exclusive-rename.d.ts +0 -2
- package/dist/native/exclusive-rename.js +0 -52
- package/dist/release/retention-dry-run.d.ts +0 -46
- package/dist/release/retention-dry-run.js +0 -94
- package/dist/updates/update-exclusive-rename.d.ts +0 -3
- 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
|
|
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
|
|
47
|
-
|
|
48
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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
|
|
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 =
|
|
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
|
|
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
|
|
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 || !
|
|
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
|
|
564
|
+
if (errorCode(error) === "ENOENT") return void 0;
|
|
562
565
|
throw error;
|
|
563
566
|
}), lstat(candidate).catch((error) => {
|
|
564
|
-
if (error
|
|
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" &&
|
|
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 =
|
|
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 =
|
|
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
|
|
643
|
+
if (errorCode(error) === "ENOENT") return void 0;
|
|
641
644
|
throw error;
|
|
642
645
|
}), lstat(candidate).catch((error) => {
|
|
643
|
-
if (error
|
|
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
|
|
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 (!
|
|
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,
|
|
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 (
|
|
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
|
|
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
|
|
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 || !
|
|
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;
|