@adea-ai/app-framework 0.37.0 → 0.37.1
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/appearance/appearance-host.js +2 -1
- package/dist/appearance/custom-theme-import.js +3 -1
- package/dist/appearance/custom-theme-library.d.ts +6 -185
- package/dist/appearance/custom-theme-library.js +3 -621
- package/dist/appearance/theme-library-mutation.d.ts +42 -0
- package/dist/appearance/theme-library-mutation.js +172 -0
- package/dist/appearance/theme-library-schema.d.ts +108 -0
- package/dist/appearance/theme-library-schema.js +189 -0
- package/dist/appearance/theme-library-store.d.ts +61 -0
- package/dist/appearance/theme-library-store.js +268 -0
- package/dist/appearance/theme-record-adapter.js +3 -1
- package/dist/appearance/theme-registry.js +2 -1
- package/dist/cli/update-helper-cli.js +1 -1
- package/dist/desktop/desktop-client.d.ts +1 -1
- package/dist/framework-source.json +1 -1
- package/dist/installer/installed-payload.js +2 -2
- package/dist/installer/{installer-archive.js → installer-archive-members.js} +2 -2
- package/dist/installer/installer-extraction.js +2 -2
- package/dist/installer/installer-fetch-guard.d.ts +1 -1
- package/dist/installer/installer-identity.js +2 -2
- package/dist/installer/installer-observation.d.ts +1 -1
- package/dist/installer/installer-observation.js +2 -2
- package/dist/installer/installer-upgrade-command.d.ts +2 -2
- package/dist/installer/installer-upgrade-command.js +5 -5
- package/dist/installer/linux-process-group.js +1 -1
- package/dist/installer/upgrade-asset-download.d.ts +1 -1
- package/dist/installer/upgrade-asset-download.js +2 -2
- package/dist/native/posix-tree-removal.d.ts +1 -1
- package/dist/release/feed-release-cut.d.ts +1 -1
- package/dist/release/feed-state.d.ts +2 -2
- package/dist/release/feed-state.js +3 -3
- package/dist/release/github-release-cut.js +1 -1
- package/dist/release/github-release-promotion.js +1 -1
- package/dist/release/github-release-publisher.js +1 -1
- package/dist/release/github-release-qualification.js +1 -1
- package/dist/release/local-release.d.ts +2 -2
- package/dist/release/local-release.js +3 -3
- package/dist/release/release-artifact.d.ts +1 -1
- package/dist/release/release-artifact.js +2 -2
- package/dist/release/release-assets-plan.js +1 -1
- package/dist/release/release-config.d.ts +1 -1
- package/dist/release/release-config.js +1 -1
- package/dist/release/release-descriptor-staging.js +3 -3
- package/dist/release/release-finalize.js +1 -1
- package/dist/release/release-promotion.js +1 -1
- package/dist/release/release-publication.d.ts +1 -1
- package/dist/release/release-publication.js +2 -2
- package/dist/release/release-publish-command.js +2 -2
- package/dist/update-helper.bundle.js +18 -18
- package/dist/updates/channel-update-manager.d.ts +3 -3
- package/dist/updates/channel-update-manager.js +2 -2
- package/dist/updates/desktop-updater.d.ts +10 -83
- package/dist/updates/desktop-updater.js +14 -217
- package/dist/updates/{packaged-release-config.js → feed/packaged-release-config.js} +5 -5
- package/dist/updates/{release-feed.js → feed/release-feed.js} +2 -2
- package/dist/updates/{release-location.js → feed/release-location.js} +2 -2
- package/dist/updates/{release-version.js → feed/release-version.js} +1 -1
- package/dist/updates/{signed-release.js → feed/signed-release.js} +2 -2
- package/dist/updates/{update-discovery.js → feed/update-discovery.js} +1 -1
- package/dist/updates/helper/launch-gate-recovery.d.ts +8 -0
- package/dist/updates/{update-resume.js → helper/launch-gate-recovery.js} +13 -423
- package/dist/updates/helper/resume-staging.d.ts +22 -0
- package/dist/updates/helper/resume-staging.js +180 -0
- package/dist/updates/{update-helper.d.ts → helper/update-helper.d.ts} +1 -1
- package/dist/updates/{update-helper.js → helper/update-helper.js} +9 -9
- package/dist/updates/{update-resume.d.ts → helper/update-resume.d.ts} +4 -10
- package/dist/updates/helper/update-resume.js +252 -0
- package/dist/updates/{update-shutdown.js → helper/update-shutdown.js} +2 -2
- package/dist/updates/{update-arm.d.ts → install/update-arm.d.ts} +2 -2
- package/dist/updates/{update-arm.js → install/update-arm.js} +9 -9
- package/dist/updates/{update-download-cleanup.d.ts → install/update-download-cleanup.d.ts} +1 -1
- package/dist/updates/{update-download-cleanup.js → install/update-download-cleanup.js} +3 -3
- package/dist/updates/{update-download.d.ts → install/update-download.d.ts} +2 -2
- package/dist/updates/{update-download.js → install/update-download.js} +3 -3
- package/dist/updates/{update-extraction.d.ts → install/update-extraction.d.ts} +2 -2
- package/dist/updates/{update-extraction.js → install/update-extraction.js} +6 -6
- package/dist/updates/{update-handoff-plan.d.ts → install/update-handoff-plan.d.ts} +2 -2
- package/dist/updates/{update-handoff-plan.js → install/update-handoff-plan.js} +5 -5
- package/dist/updates/{update-marker.js → install/update-marker.js} +2 -2
- package/dist/updates/{update-swap-stage.d.ts → install/update-swap-stage.d.ts} +2 -2
- package/dist/updates/{update-swap-stage.js → install/update-swap-stage.js} +7 -6
- package/dist/updates/{update-swap.d.ts → install/update-swap.d.ts} +1 -1
- package/dist/updates/{update-swap.js → install/update-swap.js} +5 -5
- package/dist/updates/install-target.d.ts +8 -0
- package/dist/updates/install-target.js +27 -0
- package/dist/updates/{launch-environment.js → launch/launch-environment.js} +1 -1
- package/dist/updates/{packaged-launch-admission.js → launch/packaged-launch-admission.js} +4 -4
- package/dist/updates/{packaged-update-startup.d.ts → launch/packaged-update-startup.d.ts} +3 -3
- package/dist/updates/{packaged-update-startup.js → launch/packaged-update-startup.js} +10 -7
- package/dist/updates/{update-launch-gate.d.ts → launch/update-launch-gate.d.ts} +1 -1
- package/dist/updates/{update-launch-gate.js → launch/update-launch-gate.js} +9 -9
- package/dist/updates/{update-launch.d.ts → launch/update-launch.d.ts} +1 -1
- package/dist/updates/{update-launch.js → launch/update-launch.js} +2 -2
- package/dist/updates/{linux-process-state.js → locks/linux-process-state.js} +1 -1
- package/dist/updates/{native-file-lock.js → locks/native-file-lock.js} +1 -1
- package/dist/updates/{stable-file.js → locks/stable-file.js} +2 -2
- package/dist/updates/{update-download-lock.js → locks/update-download-lock.js} +1 -1
- package/dist/updates/{update-generation-lease.js → locks/update-generation-lease.js} +3 -3
- package/dist/updates/{update-inherited-launch-lease.d.ts → locks/update-inherited-launch-lease.d.ts} +1 -1
- package/dist/updates/{update-inherited-launch-lease.js → locks/update-inherited-launch-lease.js} +2 -2
- package/dist/updates/{update-instance-lease.js → locks/update-instance-lease.js} +2 -2
- package/dist/updates/{update-lock.js → locks/update-lock.js} +2 -2
- package/dist/updates/{update-process-fence.js → locks/update-process-fence.js} +3 -3
- package/dist/updates/{update-process-liveness.js → locks/update-process-liveness.js} +2 -2
- package/dist/updates/retained-client-assets.d.ts +60 -0
- package/dist/updates/retained-client-assets.js +116 -0
- package/dist/updates/retention/retention-cleanup.d.ts +103 -0
- package/dist/updates/retention/retention-cleanup.js +439 -0
- package/dist/updates/retention/retention-prune-progress.d.ts +27 -0
- package/dist/updates/retention/retention-prune-progress.js +203 -0
- package/dist/updates/retention/retirement-inventory.d.ts +93 -0
- package/dist/updates/retention/retirement-inventory.js +373 -0
- package/dist/updates/retention/retirement-records.d.ts +75 -0
- package/dist/updates/retention/retirement-records.js +309 -0
- package/dist/updates/{update-retention-marker.d.ts → retention/update-retention-marker.d.ts} +1 -1
- package/dist/updates/{update-retention-marker.js → retention/update-retention-marker.js} +3 -3
- package/dist/updates/{update-retention-plan.d.ts → retention/update-retention-plan.d.ts} +1 -1
- package/dist/updates/{update-retention-plan.js → retention/update-retention-plan.js} +2 -2
- package/dist/updates/{update-retention-sync.d.ts → retention/update-retention-sync.d.ts} +1 -1
- package/dist/updates/{update-retention-sync.js → retention/update-retention-sync.js} +2 -2
- package/dist/updates/retention/update-retirement.d.ts +26 -0
- package/dist/updates/retention/update-retirement.js +205 -0
- package/dist/updates/update-adapter.js +1 -1
- package/dist/updates/update-channel-store.d.ts +1 -1
- package/dist/updates/update-channel-store.js +2 -2
- package/dist/updates/update-manager.d.ts +4 -4
- package/dist/updates/update-manager.js +5 -5
- package/dist/updates/update-services.d.ts +15 -0
- package/dist/updates/update-services.js +77 -0
- package/dist/updates/update-state-store.d.ts +2 -2
- package/dist/updates/update-state-store.js +2 -2
- package/dist/views/appearance-surface.js +3 -1
- package/package.json +29 -29
- package/src/appearance/custom-theme-library.ts +42 -956
- package/src/appearance/theme-library-mutation.ts +288 -0
- package/src/appearance/theme-library-schema.ts +347 -0
- package/src/appearance/theme-library-store.ts +379 -0
- package/src/updates/update-adapter.ts +1 -1
- package/dist/updates/update-retirement.d.ts +0 -205
- package/dist/updates/update-retirement.js +0 -1485
- /package/dist/installer/{installer-archive.d.ts → installer-archive-members.d.ts} +0 -0
- /package/dist/updates/{packaged-release-config.d.ts → feed/packaged-release-config.d.ts} +0 -0
- /package/dist/updates/{release-feed.d.ts → feed/release-feed.d.ts} +0 -0
- /package/dist/updates/{release-location.d.ts → feed/release-location.d.ts} +0 -0
- /package/dist/updates/{release-version.d.ts → feed/release-version.d.ts} +0 -0
- /package/dist/updates/{signed-release.d.ts → feed/signed-release.d.ts} +0 -0
- /package/dist/updates/{update-discovery.d.ts → feed/update-discovery.d.ts} +0 -0
- /package/dist/updates/{update-shutdown.d.ts → helper/update-shutdown.d.ts} +0 -0
- /package/dist/updates/{update-marker.d.ts → install/update-marker.d.ts} +0 -0
- /package/dist/updates/{launch-environment.d.ts → launch/launch-environment.d.ts} +0 -0
- /package/dist/updates/{packaged-launch-admission.d.ts → launch/packaged-launch-admission.d.ts} +0 -0
- /package/dist/updates/{linux-process-state.d.ts → locks/linux-process-state.d.ts} +0 -0
- /package/dist/updates/{native-file-lock.d.ts → locks/native-file-lock.d.ts} +0 -0
- /package/dist/updates/{stable-file.d.ts → locks/stable-file.d.ts} +0 -0
- /package/dist/updates/{update-download-lock.d.ts → locks/update-download-lock.d.ts} +0 -0
- /package/dist/updates/{update-generation-lease.d.ts → locks/update-generation-lease.d.ts} +0 -0
- /package/dist/updates/{update-instance-lease.d.ts → locks/update-instance-lease.d.ts} +0 -0
- /package/dist/updates/{update-lock.d.ts → locks/update-lock.d.ts} +0 -0
- /package/dist/updates/{update-process-fence.d.ts → locks/update-process-fence.d.ts} +0 -0
- /package/dist/updates/{update-process-liveness.d.ts → locks/update-process-liveness.d.ts} +0 -0
- /package/src/updates/{release-version.ts → feed/release-version.ts} +0 -0
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import { isUuid } from "../../app/value-guards.js";
|
|
2
|
+
import { readSmallStateFile } from "../locks/stable-file.js";
|
|
3
|
+
import { sameUpdateTreeIdentity } from "../install/update-swap.js";
|
|
4
|
+
import { retentionIdentityKey } from "./update-retention-plan.js";
|
|
5
|
+
import { sameRetentionIntent, updateRetentionIntentPath } from "./update-retention-marker.js";
|
|
6
|
+
import { syncDarwinDescriptor } from "../../native/darwin-sync.js";
|
|
7
|
+
import { hasExactOwnKeys, healthReceiptFor, healthReceiptMatches, ownerMatches, parseHealthReceipt, parseOwner, pathInfo, readHealthReceipt, readOwner, updateRetirementPaths } from "./retirement-records.js";
|
|
8
|
+
import { link, lstat, open, readdir, rename, unlink, writeFile } from "node:fs/promises";
|
|
9
|
+
import { basename, dirname, join } from "node:path";
|
|
10
|
+
import { randomUUID } from "node:crypto";
|
|
11
|
+
import { constants as constants$1 } from "node:fs";
|
|
12
|
+
// src/updates/retention/retention-prune-progress.ts
|
|
13
|
+
function retentionPruneProgressPath(target, generation) {
|
|
14
|
+
return `${updateRetirementPaths(target, generation).claim.slice(0, -11)}.prune-progress.json`;
|
|
15
|
+
}
|
|
16
|
+
function isPruneProgressName(name, target) {
|
|
17
|
+
const prefix = `.${basename(target)}.framework-retired-`;
|
|
18
|
+
if (!name.startsWith(prefix)) return false;
|
|
19
|
+
const suffix = name.slice(prefix.length);
|
|
20
|
+
const match = /^([0-9a-f-]{36})\.prune-progress\.json$/i.exec(suffix);
|
|
21
|
+
return Boolean(match && isUuid(match[1]));
|
|
22
|
+
}
|
|
23
|
+
function pruneProgressNames(target, generation) {
|
|
24
|
+
return [basename(retentionPruneProgressPath(target, generation))];
|
|
25
|
+
}
|
|
26
|
+
function assertNoUnresolvedRetentionPruneArtifacts(target, names, allowances = {}, message = "An update retirement cleanup marker requires recovery") {
|
|
27
|
+
const pruneMarkerPrefix = `.${basename(target)}.framework-prune-`;
|
|
28
|
+
const pruneTemporaryPrefix = `..${basename(target)}.framework-prune-`;
|
|
29
|
+
const retirementPrefix = `.${basename(target)}.framework-retired-`;
|
|
30
|
+
const allowedRetentionIntentName = allowances.allowedRetentionIntentGeneration ? basename(updateRetentionIntentPath(target, allowances.allowedRetentionIntentGeneration)) : void 0;
|
|
31
|
+
const allowedProgressName = allowances.allowedPruneProgressGeneration ? pruneProgressNames(target, allowances.allowedPruneProgressGeneration)[0] : void 0;
|
|
32
|
+
if (names.some((name) => {
|
|
33
|
+
const foldedName = name.toLowerCase();
|
|
34
|
+
if (foldedName.startsWith(pruneMarkerPrefix.toLowerCase()) || foldedName.startsWith(pruneTemporaryPrefix.toLowerCase())) return name !== allowedRetentionIntentName && name !== allowances.allowedRetentionTemporaryName;
|
|
35
|
+
const foldedRetirementPrefix = retirementPrefix.toLowerCase();
|
|
36
|
+
return foldedName.startsWith(foldedRetirementPrefix) && foldedName.slice(foldedRetirementPrefix.length).includes("prune") && name !== allowedProgressName && name !== allowances.allowedPruneProgressTemporaryName;
|
|
37
|
+
})) throw new Error(message);
|
|
38
|
+
}
|
|
39
|
+
async function findPruneProgressTemporaryName(target, generation) {
|
|
40
|
+
const prefix = `${basename(retentionPruneProgressPath(target, generation))}.`;
|
|
41
|
+
const names = (await readdir(dirname(target))).filter((name) => name.startsWith(prefix) && name.endsWith(".tmp"));
|
|
42
|
+
if (names.length > 1) throw new Error("Multiple update retention progress temporaries require recovery");
|
|
43
|
+
const name = names[0];
|
|
44
|
+
if (!name) return void 0;
|
|
45
|
+
const temporaryId = name.slice(prefix.length, -4);
|
|
46
|
+
if (!isUuid(temporaryId)) throw new Error("An update retention progress temporary requires recovery");
|
|
47
|
+
return name;
|
|
48
|
+
}
|
|
49
|
+
async function readPruneProgressFile(path, target, generation, expectedIntent, expectedOwner) {
|
|
50
|
+
try {
|
|
51
|
+
const canonicalPath = retentionPruneProgressPath(target, generation);
|
|
52
|
+
const canonicalName = basename(canonicalPath);
|
|
53
|
+
const pathName = basename(path);
|
|
54
|
+
const temporaryId = pathName.startsWith(`${canonicalName}.`) && pathName.endsWith(".tmp") ? pathName.slice(canonicalName.length + 1, -4) : "";
|
|
55
|
+
const canonicalTemporary = dirname(path) === dirname(canonicalPath) && isUuid(temporaryId);
|
|
56
|
+
if (path !== canonicalPath && !canonicalTemporary) return void 0;
|
|
57
|
+
const text = await readSmallStateFile(path, 8192, "Invalid retention prune progress");
|
|
58
|
+
if (text === void 0) return void 0;
|
|
59
|
+
const value = JSON.parse(text);
|
|
60
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) return void 0;
|
|
61
|
+
const record = value;
|
|
62
|
+
if (!hasExactOwnKeys(record, [
|
|
63
|
+
"schema",
|
|
64
|
+
"phase",
|
|
65
|
+
"intent",
|
|
66
|
+
"owner",
|
|
67
|
+
"healthReceipt"
|
|
68
|
+
]) || record.schema !== 1 || record.phase !== "deleting" && record.phase !== "empty" || typeof record.intent !== "object" || record.intent === null || Array.isArray(record.intent) || !hasExactOwnKeys(record.intent, [
|
|
69
|
+
"schema",
|
|
70
|
+
"phase",
|
|
71
|
+
"target",
|
|
72
|
+
"generation",
|
|
73
|
+
"previousTreeIdentity",
|
|
74
|
+
"installedGeneration",
|
|
75
|
+
"installedTreeIdentity"
|
|
76
|
+
]) || expectedIntent !== void 0 && !sameRetentionIntent(record.intent, expectedIntent) || typeof record.owner !== "object" || record.owner === null || Array.isArray(record.owner)) return void 0;
|
|
77
|
+
const intent = record.intent;
|
|
78
|
+
if (intent.schema !== 1 || intent.phase !== "prune-previous-tree" || typeof intent.target !== "string" || intent.target !== target || typeof intent.generation !== "string" || intent.generation !== generation.toLowerCase() || !retentionIdentityKey(intent.previousTreeIdentity) || !retentionIdentityKey(intent.installedTreeIdentity) || typeof intent.installedGeneration !== "string" || !isUuid(intent.installedGeneration) || Object.keys(intent.previousTreeIdentity).length !== 2 || !hasExactOwnKeys(intent.previousTreeIdentity, ["device", "inode"]) || Object.keys(intent.installedTreeIdentity).length !== 2 || !hasExactOwnKeys(intent.installedTreeIdentity, ["device", "inode"])) return void 0;
|
|
79
|
+
const owner = parseOwner(record.owner);
|
|
80
|
+
if (!owner || expectedOwner && !ownerMatches(owner, expectedOwner)) return void 0;
|
|
81
|
+
const healthReceipt = parseHealthReceipt(record.healthReceipt);
|
|
82
|
+
if (owner.target !== target || owner.generation.toLowerCase() !== intent.generation || !sameUpdateTreeIdentity(intent.previousTreeIdentity, owner.previousTreeIdentity) || !healthReceiptMatches(healthReceipt, healthReceiptFor(owner)) || expectedIntent !== void 0 && !sameRetentionIntent(intent, expectedIntent)) return void 0;
|
|
83
|
+
return {
|
|
84
|
+
schema: 1,
|
|
85
|
+
phase: record.phase,
|
|
86
|
+
intent,
|
|
87
|
+
owner,
|
|
88
|
+
healthReceipt
|
|
89
|
+
};
|
|
90
|
+
} catch {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
async function publishPruneProgress(intent, owner, healthReceipt, phase) {
|
|
95
|
+
const path = retentionPruneProgressPath(intent.target, intent.generation);
|
|
96
|
+
const existing = await readPruneProgressFile(path, intent.target, intent.generation, intent, owner);
|
|
97
|
+
if (existing) {
|
|
98
|
+
if (!healthReceiptMatches(existing.healthReceipt, healthReceipt)) return false;
|
|
99
|
+
if (existing.phase === phase) return true;
|
|
100
|
+
if (existing.phase !== "deleting" || phase !== "empty") return false;
|
|
101
|
+
} else if (phase !== "deleting" || !healthReceiptMatches(healthReceipt, healthReceiptFor(owner)) || !healthReceiptMatches(await readHealthReceipt(updateRetirementPaths(intent.target, intent.generation).healthReceipt), healthReceipt)) return false;
|
|
102
|
+
const temporary = `${path}.${randomUUID()}.tmp`;
|
|
103
|
+
let publicationBarrierPassed = false;
|
|
104
|
+
try {
|
|
105
|
+
await writeFile(temporary, JSON.stringify({
|
|
106
|
+
schema: 1,
|
|
107
|
+
phase,
|
|
108
|
+
intent,
|
|
109
|
+
owner,
|
|
110
|
+
healthReceipt
|
|
111
|
+
}) + "\n", {
|
|
112
|
+
flag: "wx",
|
|
113
|
+
mode: 384
|
|
114
|
+
});
|
|
115
|
+
if (!await readPruneProgressFile(temporary, intent.target, intent.generation, intent, owner)) return false;
|
|
116
|
+
await syncPruneFile(temporary, intent.previousTreeIdentity.device);
|
|
117
|
+
if (existing) {
|
|
118
|
+
const before = await readPruneProgressFile(path, intent.target, intent.generation, intent, owner);
|
|
119
|
+
if (!before || before.phase !== "deleting") return false;
|
|
120
|
+
await rename(temporary, path);
|
|
121
|
+
await syncPruneDirectory(dirname(path), intent.previousTreeIdentity.device);
|
|
122
|
+
publicationBarrierPassed = true;
|
|
123
|
+
} else {
|
|
124
|
+
await link(temporary, path);
|
|
125
|
+
await syncPruneDirectory(dirname(path), intent.previousTreeIdentity.device);
|
|
126
|
+
publicationBarrierPassed = true;
|
|
127
|
+
await unlink(temporary);
|
|
128
|
+
await syncPruneDirectory(dirname(path), intent.previousTreeIdentity.device);
|
|
129
|
+
}
|
|
130
|
+
} catch {
|
|
131
|
+
if (!publicationBarrierPassed || await pathInfo(temporary)) return false;
|
|
132
|
+
return (await readPruneProgressFile(path, intent.target, intent.generation, intent, owner))?.phase === phase;
|
|
133
|
+
}
|
|
134
|
+
return (await readPruneProgressFile(path, intent.target, intent.generation, intent, owner))?.phase === phase;
|
|
135
|
+
}
|
|
136
|
+
async function readPruneProgress(target, generation, expectedIntent) {
|
|
137
|
+
return readPruneProgressFile(retentionPruneProgressPath(target, generation), target, generation, expectedIntent);
|
|
138
|
+
}
|
|
139
|
+
function sameFilesystemObject(left, right) {
|
|
140
|
+
return left.dev === right.dev && left.ino === right.ino;
|
|
141
|
+
}
|
|
142
|
+
async function syncPruneFile(path, expectedDevice) {
|
|
143
|
+
if (typeof constants$1.O_NOFOLLOW !== "number" || typeof constants$1.O_NONBLOCK !== "number") throw new Error("Update retention progress synchronization is unsupported on this platform");
|
|
144
|
+
const before = await lstat(path, { bigint: true });
|
|
145
|
+
if (!before.isFile() || before.isSymbolicLink() || expectedDevice !== void 0 && before.dev.toString() !== expectedDevice) throw new Error("Invalid update retention progress file before sync");
|
|
146
|
+
const file = await open(path, constants$1.O_RDONLY | constants$1.O_NOFOLLOW | constants$1.O_NONBLOCK);
|
|
147
|
+
try {
|
|
148
|
+
const opened = await file.stat({ bigint: true });
|
|
149
|
+
if (!opened.isFile() || !sameFilesystemObject(opened, before) || expectedDevice !== void 0 && opened.dev.toString() !== expectedDevice) throw new Error("Update retention progress file changed before sync");
|
|
150
|
+
syncDarwinDescriptor(file.fd, "file");
|
|
151
|
+
const synced = await file.stat({ bigint: true });
|
|
152
|
+
const after = await lstat(path, { bigint: true });
|
|
153
|
+
if (!synced.isFile() || !after.isFile() || after.isSymbolicLink() || !sameFilesystemObject(synced, opened) || !sameFilesystemObject(after, opened)) throw new Error("Update retention progress file changed during sync");
|
|
154
|
+
} finally {
|
|
155
|
+
await file.close();
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
async function syncPruneDirectory(path, expectedDevice) {
|
|
159
|
+
if (typeof constants$1.O_NOFOLLOW !== "number" || typeof constants$1.O_DIRECTORY !== "number") throw new Error("Update retention directory synchronization is unsupported on this platform");
|
|
160
|
+
const before = await lstat(path, { bigint: true });
|
|
161
|
+
if (!before.isDirectory() || before.isSymbolicLink() || expectedDevice !== void 0 && before.dev.toString() !== expectedDevice) throw new Error("Invalid update retention directory before sync");
|
|
162
|
+
const directory = await open(path, constants$1.O_RDONLY | constants$1.O_DIRECTORY | constants$1.O_NOFOLLOW);
|
|
163
|
+
try {
|
|
164
|
+
const opened = await directory.stat({ bigint: true });
|
|
165
|
+
if (!opened.isDirectory() || !sameFilesystemObject(opened, before) || expectedDevice !== void 0 && opened.dev.toString() !== expectedDevice) throw new Error("Update retention directory changed before sync");
|
|
166
|
+
syncDarwinDescriptor(directory.fd, "directory");
|
|
167
|
+
const synced = await directory.stat({ bigint: true });
|
|
168
|
+
const after = await lstat(path, { bigint: true });
|
|
169
|
+
if (!synced.isDirectory() || !after.isDirectory() || after.isSymbolicLink() || !sameFilesystemObject(synced, opened) || !sameFilesystemObject(after, opened)) throw new Error("Update retention directory changed during sync");
|
|
170
|
+
} finally {
|
|
171
|
+
await directory.close();
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
async function syncPruneRecoveryEvidence(target, intent, inventory) {
|
|
175
|
+
const expectedDevice = intent.previousTreeIdentity.device;
|
|
176
|
+
if (intent.installedTreeIdentity.device !== expectedDevice || inventory.actualIdentity.device !== expectedDevice) throw new Error("Update retention recovery evidence crosses a filesystem boundary");
|
|
177
|
+
const installedOwner = inventory.records.find(({ owner }) => owner.generation.toLowerCase() === intent.installedGeneration.toLowerCase())?.owner;
|
|
178
|
+
if (!installedOwner || installedOwner.newVersion !== inventory.actualVersion || !sameUpdateTreeIdentity(installedOwner.newTreeIdentity, inventory.actualIdentity)) throw new Error("Update retention installed lineage changed before synchronization");
|
|
179
|
+
const versionPath = join(target, ...process.platform === "darwin" ? ["Contents", "Resources"] : ["Resources"], "version.json");
|
|
180
|
+
await syncPruneFile(versionPath, expectedDevice);
|
|
181
|
+
await syncPruneDirectory(dirname(versionPath), expectedDevice);
|
|
182
|
+
await syncPruneDirectory(target, expectedDevice);
|
|
183
|
+
for (const { owner, paths, healthy } of inventory.records) {
|
|
184
|
+
if (!healthy || owner.previousTreeIdentity.device !== expectedDevice || owner.newTreeIdentity.device !== expectedDevice) throw new Error("Update retention record is not complete recovery evidence");
|
|
185
|
+
const claimOwner = await readOwner(paths.claim);
|
|
186
|
+
const receipt = await readHealthReceipt(paths.healthReceipt);
|
|
187
|
+
if (!ownerMatches(claimOwner, owner) || !healthReceiptMatches(receipt, healthReceiptFor(owner))) throw new Error("Update retention recovery evidence changed before synchronization");
|
|
188
|
+
await syncPruneFile(paths.claim, expectedDevice);
|
|
189
|
+
await syncPruneFile(paths.healthReceipt, expectedDevice);
|
|
190
|
+
await syncPruneDirectory(paths.container, expectedDevice);
|
|
191
|
+
}
|
|
192
|
+
await syncPruneDirectory(dirname(target), expectedDevice);
|
|
193
|
+
}
|
|
194
|
+
async function syncPruneProgress(target, generation, expected) {
|
|
195
|
+
const path = retentionPruneProgressPath(target, generation);
|
|
196
|
+
const before = await readPruneProgressFile(path, target, generation, expected.intent, expected.owner);
|
|
197
|
+
if (!before || before.phase !== expected.phase || !healthReceiptMatches(before.healthReceipt, expected.healthReceipt)) throw new Error("Update retention progress changed before synchronization");
|
|
198
|
+
await syncPruneFile(path, expected.intent.previousTreeIdentity.device);
|
|
199
|
+
await syncPruneDirectory(dirname(path), expected.intent.previousTreeIdentity.device);
|
|
200
|
+
const after = await readPruneProgressFile(path, target, generation, expected.intent, expected.owner);
|
|
201
|
+
if (!after || after.phase !== expected.phase || !healthReceiptMatches(after.healthReceipt, expected.healthReceipt)) throw new Error("Update retention progress changed during synchronization");
|
|
202
|
+
}
|
|
203
|
+
export { assertNoUnresolvedRetentionPruneArtifacts, findPruneProgressTemporaryName, isPruneProgressName, pruneProgressNames, publishPruneProgress, readPruneProgress, readPruneProgressFile, retentionPruneProgressPath, syncPruneDirectory, syncPruneFile, syncPruneProgress, syncPruneRecoveryEvidence };
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { type ReleaseTrust } from '../feed/signed-release';
|
|
2
|
+
import { type RetentionPlan } from './update-retention-plan';
|
|
3
|
+
import { type UpdateTreeIdentity } from '../install/update-swap';
|
|
4
|
+
import { type RetirementOwner, type UpdateHealthAcknowledgement, updateRetirementPaths } from './retirement-records';
|
|
5
|
+
type ValidatedRetirementRecord = Readonly<{
|
|
6
|
+
owner: RetirementOwner;
|
|
7
|
+
paths: ReturnType<typeof updateRetirementPaths>;
|
|
8
|
+
healthy: boolean;
|
|
9
|
+
}>;
|
|
10
|
+
export type ValidatedRetirementInventory = Readonly<{
|
|
11
|
+
actualVersion: string;
|
|
12
|
+
actualIdentity: UpdateTreeIdentity;
|
|
13
|
+
records: readonly ValidatedRetirementRecord[];
|
|
14
|
+
allowedIntentObserved: boolean;
|
|
15
|
+
}>;
|
|
16
|
+
export type RetainedUpdateTree = Readonly<{
|
|
17
|
+
generation: string;
|
|
18
|
+
version: string;
|
|
19
|
+
tree: string;
|
|
20
|
+
}>;
|
|
21
|
+
export type RetainedUpdateTrees = Readonly<{
|
|
22
|
+
status: 'none' | 'busy';
|
|
23
|
+
}> | Readonly<{
|
|
24
|
+
status: 'acquired';
|
|
25
|
+
trees: readonly RetainedUpdateTree[];
|
|
26
|
+
release(): Promise<void>;
|
|
27
|
+
}>;
|
|
28
|
+
/**
|
|
29
|
+
* Discover the exact unacknowledged installed generation after staging cleanup.
|
|
30
|
+
* The generation claim is persistent beside the retired tree, so discovery does
|
|
31
|
+
* not depend on a startup return value or log message.
|
|
32
|
+
*/
|
|
33
|
+
export declare function findPendingUpdateHealthAcknowledgement(options: {
|
|
34
|
+
target: string;
|
|
35
|
+
currentVersion: string;
|
|
36
|
+
}): Promise<UpdateHealthAcknowledgement | null>;
|
|
37
|
+
/**
|
|
38
|
+
* Fail closed before publishing a new stage while any retention-prune intent,
|
|
39
|
+
* progress marker, temporary, or unknown prune-shaped artifact is present.
|
|
40
|
+
* Uses the same artifact-name check as strict retention inventory and must be
|
|
41
|
+
* called while the per-install update lock is held. It deliberately does not
|
|
42
|
+
* require unrelated retirement history to be valid before a new stage.
|
|
43
|
+
*/
|
|
44
|
+
export declare function assertNoUpdateRetentionPruneArtifactsWhileLocked(target: string): Promise<void>;
|
|
45
|
+
/**
|
|
46
|
+
* Plan rollback-tree retention from a complete, read-only filesystem inventory.
|
|
47
|
+
* This does not delete or modify retirement records; callers must revalidate
|
|
48
|
+
* ownership and the returned plan before any future cleanup operation.
|
|
49
|
+
*/
|
|
50
|
+
export declare function planValidatedUpdateRetention(options: {
|
|
51
|
+
target: string;
|
|
52
|
+
currentVersion: string;
|
|
53
|
+
}): Promise<RetentionPlan>;
|
|
54
|
+
export declare function planRetentionWhileLocked(target: string, currentVersion: string, options?: Readonly<{
|
|
55
|
+
allowedRetentionIntentGeneration?: string;
|
|
56
|
+
allowedRetentionTemporaryName?: string;
|
|
57
|
+
allowedPruneProgressGeneration?: string;
|
|
58
|
+
allowedPruneProgressTemporaryName?: string;
|
|
59
|
+
allowUnhealthyReads?: boolean;
|
|
60
|
+
validatedStagedVersion?: string;
|
|
61
|
+
stagedTrust?: ReleaseTrust;
|
|
62
|
+
}>): Promise<{
|
|
63
|
+
inventory: Readonly<{
|
|
64
|
+
actualVersion: string;
|
|
65
|
+
actualIdentity: UpdateTreeIdentity;
|
|
66
|
+
records: readonly ValidatedRetirementRecord[];
|
|
67
|
+
allowedIntentObserved: boolean;
|
|
68
|
+
}>;
|
|
69
|
+
plan: RetentionPlan;
|
|
70
|
+
}>;
|
|
71
|
+
/**
|
|
72
|
+
* Acquire shared leases on every validated retained generation. Keep the
|
|
73
|
+
* returned leases until all readers and response bodies have finished. A future
|
|
74
|
+
* deletion implementation must hold the update lock and the same generation's
|
|
75
|
+
* exclusive lease while it revalidates and removes that generation.
|
|
76
|
+
*/
|
|
77
|
+
export declare function acquireRetainedUpdateTrees(options: {
|
|
78
|
+
target: string;
|
|
79
|
+
currentVersion: string;
|
|
80
|
+
}): Promise<RetainedUpdateTrees>;
|
|
81
|
+
/**
|
|
82
|
+
* Acquire retained generations while the caller holds the per-install update
|
|
83
|
+
* lock. A staged candidate is accepted only after its caller has run trusted
|
|
84
|
+
* resume validation; this function repeats the stage identity and descriptor
|
|
85
|
+
* checks before permitting the retention inventory.
|
|
86
|
+
*/
|
|
87
|
+
export declare function acquireRetainedUpdateTreesWhileLocked(options: {
|
|
88
|
+
target: string;
|
|
89
|
+
currentVersion: string;
|
|
90
|
+
validatedStagedVersion?: string;
|
|
91
|
+
stagedTrust?: ReleaseTrust;
|
|
92
|
+
}): Promise<RetainedUpdateTrees>;
|
|
93
|
+
export {};
|