@tnunamak/dalan 0.8.1 → 0.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +59 -2
- package/CONTRIBUTING.md +2 -0
- package/README.md +8 -12
- package/bin/dalan.mjs +25 -4
- package/bin/dot-acp-agent.mjs +572 -76
- package/bin/dot-alert.mjs +9 -3
- package/bin/dot-deadman.mjs +3 -1
- package/bin/dot-heartbeat.mjs +14 -7
- package/bin/dot-pr-reviewer.mjs +3 -31
- package/bin/dot-worker.mjs +121 -34
- package/contracts/adapter-qualification.schema.json +94 -7
- package/docs/chatgpt-worker-onboarding.md +1 -1
- package/docs/codex-to-muse.md +2 -2
- package/docs/connect-chatgpt.md +1 -1
- package/docs/connection-longevity.md +2 -2
- package/docs/dalan-upgrade.md +8 -5
- package/docs/deadman.md +4 -0
- package/docs/design/authority-matrix.md +18 -0
- package/docs/design/failure-table.md +87 -0
- package/docs/design/identities.md +22 -0
- package/docs/design/pnpm-prepared-dependencies.md +64 -0
- package/docs/design/reuse-ledger.md +75 -0
- package/docs/design/target-architecture-v2.md +434 -0
- package/docs/local-agent-mcp.md +14 -0
- package/docs/local-agent-requester.md +2 -1
- package/docs/manual-setup.md +1 -1
- package/docs/operations.md +77 -14
- package/docs/pull-workers.md +11 -1
- package/docs/service-setup.md +10 -10
- package/docs/t3-integration.md +4 -2
- package/docs/t3-reverse-control.md +5 -5
- package/docs/test-suite-isolation.md +7 -6
- package/docs/trials/chatgpt-agent.md +47 -0
- package/docs/trials/claude-code-requester.md +68 -0
- package/docs/trials/muse.md +46 -0
- package/docs/usage.md +21 -7
- package/docs/worker-clients.md +1 -1
- package/integrations/t3/acp-kit/src/errors.mjs +6 -2
- package/integrations/t3/acp-kit/src/lock.mjs +46 -17
- package/integrations/t3/acp-kit/src/session-store.mjs +15 -3
- package/integrations/t3/acp-kit/src/t3-envelope.mjs +10 -2
- package/package.json +4 -3
- package/packages/job-core/protocol/canonical.mjs +45 -7
- package/packages/job-core/transitions.mjs +4 -2
- package/scripts/upgrade-drain.mjs +96 -8
- package/scripts/worker-bridge-setup.mjs +215 -120
- package/src/ack-ledger.mjs +7 -1
- package/src/acp-bridge.mjs +256 -28
- package/src/admin-socket.mjs +32 -3
- package/src/alerts.mjs +17 -8
- package/src/answer-journal-retention.mjs +82 -0
- package/src/answer-journal.mjs +6 -4
- package/src/as-store.mjs +51 -6
- package/src/as.mjs +27 -5
- package/src/catalog-switch-inventory.mjs +70 -0
- package/src/check-response.mjs +4 -1
- package/src/cli-help.mjs +14 -3
- package/src/cli-name.mjs +13 -1
- package/src/connect-cli.mjs +159 -4
- package/src/deadman.mjs +8 -5
- package/src/delivery.mjs +2 -19
- package/src/destinations/index.mjs +75 -14
- package/src/drain-runner.mjs +5 -1
- package/src/follow-current.mjs +3 -1
- package/src/get-summary.mjs +11 -2
- package/src/git-env.mjs +1 -1
- package/src/gozar-routes.mjs +313 -94
- package/src/host-budget-storage.py +56 -6
- package/src/host-budget.mjs +98 -15
- package/src/host-execution-policy.mjs +17 -6
- package/src/legacy-names.mjs +0 -2
- package/src/lifecycle.mjs +44 -9
- package/src/loopback-probe.mjs +46 -0
- package/src/mcp-outcome.mjs +3 -1
- package/src/mcp-sse.mjs +2 -1
- package/src/mcp-stdio.mjs +192 -30
- package/src/patch-apply.mjs +212 -7
- package/src/phase-trace.mjs +73 -0
- package/src/prepared-go-modules.mjs +127 -0
- package/src/prepared-node-modules.mjs +225 -38
- package/src/prepared-pnpm.mjs +276 -0
- package/src/prepared-store-prune.mjs +52 -0
- package/src/projects.mjs +59 -7
- package/src/protocol-artifact-commands.mjs +28 -0
- package/src/protocol-finish.mjs +3 -2
- package/src/publication-authority.mjs +22 -0
- package/src/publish-plan.mjs +2 -2
- package/src/pull-queue.mjs +55 -20
- package/src/read-api.mjs +127 -0
- package/src/redaction.mjs +173 -0
- package/src/rejections.mjs +19 -3
- package/src/route-custody.mjs +90 -0
- package/src/route-publication.mjs +50 -0
- package/src/route-setup.mjs +184 -0
- package/src/schema-subset.mjs +5 -3
- package/src/server.mjs +503 -98
- package/src/service-launchd.mjs +5 -1
- package/src/service-update-lock.mjs +7 -4
- package/src/service-update-runtime.mjs +64 -19
- package/src/service-update.mjs +193 -48
- package/src/service.mjs +276 -77
- package/src/setup.mjs +48 -25
- package/src/signal.mjs +1 -1
- package/src/status-evidence.mjs +18 -5
- package/src/store.mjs +876 -120
- package/src/submission-policy.mjs +257 -56
- package/src/t3-control.mjs +1 -1
- package/src/t3.mjs +14 -8
- package/src/terminal-safe.mjs +9 -7
- package/src/tool-registry.mjs +134 -41
- package/src/try-exposure.mjs +53 -86
- package/src/try-hosted.mjs +257 -70
- package/src/try.mjs +48 -22
- package/src/work-order.mjs +11 -6
- package/src/worker-instructions.mjs +26 -4
- package/src/worker-runs.mjs +35 -0
- package/src/workers.mjs +34 -7
- package/src/workspace.mjs +354 -54
- package/systemd/dot-deadman.service +3 -1
- package/docs/dot-pr-reviewer.config.example.json +0 -9
- package/docs/pr-head-reviewer.md +0 -70
- package/src/pr-head-reviewer.mjs +0 -596
- package/systemd/dot-pr-reviewer.service +0 -11
- package/systemd/dot-pr-reviewer.timer +0 -10
package/src/service-launchd.mjs
CHANGED
|
@@ -19,7 +19,10 @@ const SESSION_TYPES = ['Aqua', 'Background'];
|
|
|
19
19
|
const SAFE_PATH = /^[A-Za-z0-9_@+=:,./-]+$/;
|
|
20
20
|
const fail = message => { throw new Error(message); };
|
|
21
21
|
|
|
22
|
-
export const launchdLabels = unit =>
|
|
22
|
+
export const launchdLabels = unit => {
|
|
23
|
+
if (typeof unit !== 'string' || !/^[A-Za-z0-9][A-Za-z0-9_.@-]*$/.test(unit)) fail('invalid LaunchAgent unit name');
|
|
24
|
+
return { service: `org.dalan.${unit}`, update: `org.dalan.${unit}-update` };
|
|
25
|
+
};
|
|
23
26
|
export const launchAgentsDir = (env = process.env) => path.join(env.HOME || os.homedir(), 'Library', 'LaunchAgents');
|
|
24
27
|
const agentPath = (node) => [...new Set([path.dirname(node), '/opt/homebrew/bin', '/usr/local/bin', '/usr/bin', '/bin'])].join(':');
|
|
25
28
|
const xml = text => String(text).replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');
|
|
@@ -36,6 +39,7 @@ const plist = (label, body) => ['<?xml version="1.0" encoding="UTF-8"?>',
|
|
|
36
39
|
`<!-- ${MARKER}. Remove with: dalan service uninstall -->`, '<plist version="1.0">', body, '</plist>', ''].join('\n');
|
|
37
40
|
|
|
38
41
|
export function servicePlist({ unit, node, home, port, enableWorkspace = false, enableT3 = false }) {
|
|
42
|
+
if (!Number.isInteger(port) || port < 1 || port > 65535) fail('LaunchAgent port must be an integer from 1 to 65535');
|
|
39
43
|
const current = path.join(home, 'current');
|
|
40
44
|
assertSafe({ home, node, current });
|
|
41
45
|
const { service } = launchdLabels(unit);
|
|
@@ -5,14 +5,17 @@ import { DatabaseSync } from 'node:sqlite';
|
|
|
5
5
|
// Keep the inode: deleting a lock file would let a new caller lock a different file.
|
|
6
6
|
// SQLite's exclusive lock is released by the kernel even if the updater is killed.
|
|
7
7
|
export function acquireUpdateLock(home) {
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
return acquirePrivateLock(path.join(home, 'update-lock.sqlite'), 'another service update is already running');
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function acquirePrivateLock(file, busyMessage) {
|
|
12
|
+
const fd = fs.openSync(file, fs.constants.O_WRONLY | fs.constants.O_CREAT | fs.constants.O_NOFOLLOW, 0o600);
|
|
10
13
|
fs.closeSync(fd);
|
|
11
14
|
const info = fs.lstatSync(file);
|
|
12
|
-
if (!info.isFile() || info.isSymbolicLink() || (info.mode & 0o777) !== 0o600) throw new Error('service
|
|
15
|
+
if (!info.isFile() || info.isSymbolicLink() || (info.mode & 0o777) !== 0o600) throw new Error('service lock must be a private regular file');
|
|
13
16
|
const db = new DatabaseSync(file);
|
|
14
17
|
try { db.exec('PRAGMA busy_timeout=0; BEGIN EXCLUSIVE'); }
|
|
15
|
-
catch (error) { db.close(); if (error.errcode === 5 || error.errcode === 6) throw new Error(
|
|
18
|
+
catch (error) { db.close(); if (error.errcode === 5 || error.errcode === 6) throw new Error(busyMessage); throw error; }
|
|
16
19
|
let held = true;
|
|
17
20
|
return () => {
|
|
18
21
|
if (!held) return;
|
|
@@ -9,6 +9,7 @@ import { spawn } from 'node:child_process';
|
|
|
9
9
|
import { createHash, randomBytes } from 'node:crypto';
|
|
10
10
|
import { fileURLToPath } from 'node:url';
|
|
11
11
|
import { defaultPath } from './paths.mjs';
|
|
12
|
+
import { adminSocketPath } from './admin-socket.mjs';
|
|
12
13
|
import { initAsFiles } from './as-files.mjs';
|
|
13
14
|
|
|
14
15
|
const PACKAGE = '@tnunamak/dalan';
|
|
@@ -20,11 +21,22 @@ const MAX_TARBALL_BYTES = 200 * 1024 * 1024;
|
|
|
20
21
|
|
|
21
22
|
// npm 12 refuses a remote tarball URL as a dependency (allow-remote defaults to none), so the updater fetches the tarball itself,
|
|
22
23
|
// checks every byte against the registry's sha512 integrity, and hands npm only a local file. Works the same on npm 10, 11 and 12.
|
|
23
|
-
async function fetchTarball(url, integrity, { timeout = 120_000, fetchImpl = fetch } = {}) {
|
|
24
|
+
export async function fetchTarball(url, integrity, { timeout = 120_000, fetchImpl = fetch } = {}) {
|
|
24
25
|
let bytes;
|
|
25
26
|
if (/^file:\/\//.test(url)) bytes = fs.readFileSync(fileURLToPath(url));
|
|
26
27
|
else {
|
|
27
|
-
const
|
|
28
|
+
const signal = AbortSignal.timeout(timeout);
|
|
29
|
+
const origin = new URL(url).origin;
|
|
30
|
+
let target = new URL(url), response;
|
|
31
|
+
for (let hops = 0; ; hops++) {
|
|
32
|
+
if (target.origin !== origin || target.username || target.password) fail('release tarball redirect left its approved origin');
|
|
33
|
+
response = await fetchImpl(target.href, { signal, redirect: 'manual' });
|
|
34
|
+
if (![301, 302, 303, 307, 308].includes(response.status)) break;
|
|
35
|
+
const location = response.headers.get('location');
|
|
36
|
+
await response.body?.cancel();
|
|
37
|
+
if (hops >= 5 || !location) fail('release tarball redirect did not resolve');
|
|
38
|
+
target = new URL(location, target);
|
|
39
|
+
}
|
|
28
40
|
if (!response.ok) fail(`release tarball download failed (${response.status})`);
|
|
29
41
|
const length = Number(response.headers.get('content-length'));
|
|
30
42
|
if (Number.isFinite(length) && length > MAX_TARBALL_BYTES) fail('release tarball is too large');
|
|
@@ -163,7 +175,7 @@ function expectedProbe(home, receipt, repo) {
|
|
|
163
175
|
}
|
|
164
176
|
|
|
165
177
|
export async function probeService(home, _receipt, options = {}) {
|
|
166
|
-
const socketPath = defaultPath(home, '.local/share/dot-bridge'
|
|
178
|
+
const socketPath = adminSocketPath(defaultPath(home, '.local/share/dot-bridge'));
|
|
167
179
|
const operator = fs.readFileSync(defaultPath(home, '.config/dot-bridge', 'operator.key'), 'utf8').trim();
|
|
168
180
|
if (!operator || operator.length > 1024) fail('service operator key is invalid');
|
|
169
181
|
const timeout = options.timeout ?? TIMEOUT;
|
|
@@ -212,15 +224,29 @@ function prepareProbeConfig(from, to) {
|
|
|
212
224
|
fs.writeFileSync(path.join(target, 'operator.key'), `${randomBytes(32).toString('hex')}\n`, { mode: 0o600 });
|
|
213
225
|
}
|
|
214
226
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
227
|
+
function waitForChildClose(child, timeoutMs) {
|
|
228
|
+
return new Promise(resolve => {
|
|
229
|
+
let timer;
|
|
230
|
+
const finish = closed => {
|
|
231
|
+
clearTimeout(timer);
|
|
232
|
+
child.removeListener('close', onClose);
|
|
233
|
+
resolve(closed);
|
|
234
|
+
};
|
|
235
|
+
const onClose = () => finish(true);
|
|
236
|
+
child.once('close', onClose);
|
|
237
|
+
timer = setTimeout(() => finish(false), timeoutMs);
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
export async function stopChild(child, { termTimeoutMs = 3000, killTimeoutMs = 5000 } = {}) {
|
|
242
|
+
if (!child || child.exitCode !== null || child.signalCode !== null || child.spawned === false || !child.pid) return true;
|
|
243
|
+
const termWait = waitForChildClose(child, termTimeoutMs);
|
|
244
|
+
try { child.kill('SIGTERM'); } catch { /* a probe child may exit while it is being stopped */ }
|
|
245
|
+
if (await termWait) return true;
|
|
246
|
+
if (child.exitCode !== null || child.signalCode !== null || child.spawned === false) return true;
|
|
247
|
+
const killWait = waitForChildClose(child, killTimeoutMs);
|
|
248
|
+
try { child.kill('SIGKILL'); } catch { /* bounded cleanup must not replace the probe result */ }
|
|
249
|
+
return await killWait || child.exitCode !== null || child.signalCode !== null || child.spawned === false;
|
|
224
250
|
}
|
|
225
251
|
|
|
226
252
|
async function requireCatalogGuard(repo, env, receipt, options) {
|
|
@@ -232,8 +258,8 @@ async function requireCatalogGuard(repo, env, receipt, options) {
|
|
|
232
258
|
child.stdout?.on('data', chunk => { if (stdout.length < 8192) stdout += chunk.toString().slice(0, 8192 - stdout.length); });
|
|
233
259
|
child.stderr?.on('data', chunk => { if (stderr.length < 8192) stderr += chunk.toString().slice(0, 8192 - stderr.length); });
|
|
234
260
|
try {
|
|
235
|
-
const deadline =
|
|
236
|
-
while (
|
|
261
|
+
const deadline = performance.now() + (options.guardTimeoutMs ?? 10_000);
|
|
262
|
+
while (performance.now() < deadline) {
|
|
237
263
|
if (spawnError) fail(`candidate service could not start: ${spawnError.message}`);
|
|
238
264
|
if (/MCP listening|admin socket/.test(stdout)) fail('candidate started despite mismatched service catalog pin');
|
|
239
265
|
if (closed) break;
|
|
@@ -245,6 +271,18 @@ async function requireCatalogGuard(repo, env, receipt, options) {
|
|
|
245
271
|
} finally { await stopChild(child); }
|
|
246
272
|
}
|
|
247
273
|
|
|
274
|
+
// Only fixed diagnostics authored by this module; never propagate socket or filesystem data.
|
|
275
|
+
const SAFE_CANDIDATE_PROBE_FAILURES = new Set([
|
|
276
|
+
'service self-check response is incomplete',
|
|
277
|
+
'service self-check returned an invalid worker catalog',
|
|
278
|
+
'service self-check worker set does not match configuration',
|
|
279
|
+
'service self-check version does not match selected package',
|
|
280
|
+
'worker configuration is invalid for service self-check',
|
|
281
|
+
'service operator key is invalid',
|
|
282
|
+
'service probe timeout must be positive',
|
|
283
|
+
'service probe timed out',
|
|
284
|
+
]);
|
|
285
|
+
|
|
248
286
|
export async function probeCandidate(home, receipt, repo, options = {}) {
|
|
249
287
|
const scratchBase = path.join(os.homedir(), '.tmp');
|
|
250
288
|
fs.mkdirSync(scratchBase, { recursive: true, mode: 0o700 });
|
|
@@ -264,15 +302,22 @@ export async function probeCandidate(home, receipt, repo, options = {}) {
|
|
|
264
302
|
let spawnError = null, closed = false;
|
|
265
303
|
child.on('error', error => { spawnError = error; });
|
|
266
304
|
child.once('close', () => { closed = true; });
|
|
267
|
-
const deadline =
|
|
268
|
-
let result;
|
|
269
|
-
|
|
305
|
+
const deadline = performance.now() + (options.startupTimeoutMs ?? 20_000);
|
|
306
|
+
let result, lastSafeProbeFailure;
|
|
307
|
+
const probe = options.probeService ?? probeService;
|
|
308
|
+
while (performance.now() < deadline) {
|
|
270
309
|
if (spawnError) fail(`candidate service could not start: ${spawnError.message}`);
|
|
271
310
|
if (closed) fail('candidate service exited before self-check');
|
|
272
311
|
if (child.exitCode !== null || child.signalCode !== null) fail('candidate service exited before self-check');
|
|
273
|
-
try { result = await
|
|
312
|
+
try { result = await probe(scratch, { ...receipt, repo }); break; }
|
|
313
|
+
catch (error) {
|
|
314
|
+
if (error instanceof Error && SAFE_CANDIDATE_PROBE_FAILURES.has(error.message)) lastSafeProbeFailure = error.message;
|
|
315
|
+
await new Promise(resolve => setTimeout(resolve, 150));
|
|
316
|
+
}
|
|
274
317
|
}
|
|
275
|
-
if (!result) fail(
|
|
318
|
+
if (!result) fail(lastSafeProbeFailure
|
|
319
|
+
? `candidate service did not pass its self-check: ${lastSafeProbeFailure}`
|
|
320
|
+
: 'candidate service did not pass its self-check before timeout');
|
|
276
321
|
return result;
|
|
277
322
|
} finally {
|
|
278
323
|
await stopChild(child);
|
package/src/service-update.mjs
CHANGED
|
@@ -11,13 +11,17 @@ const PACKAGE = '@tnunamak/dalan';
|
|
|
11
11
|
const HEALTH_TIMEOUT_MS = 30_000;
|
|
12
12
|
const fail = message => { throw new Error(message); };
|
|
13
13
|
const privateDir = dir => fs.mkdirSync(dir, { recursive: true, mode: 0o700 });
|
|
14
|
+
// A receipt names the home it was installed for; the same directory reached through a link is still that home.
|
|
15
|
+
const realHome = dir => { try { return fs.realpathSync(dir); } catch { return path.resolve(dir); } };
|
|
16
|
+
const resolveHome = home => realHome(path.resolve(home ?? fail('home is required')));
|
|
17
|
+
const sameHome = (recorded, home) => typeof recorded === 'string' && (recorded === home || realHome(recorded) === realHome(home));
|
|
14
18
|
function readReceipt(home) {
|
|
15
19
|
const file = path.join(defaultPath(home, '.config/dot-bridge'), 'service-install.json');
|
|
16
20
|
let st, value;
|
|
17
21
|
try { st = fs.lstatSync(file); value = JSON.parse(fs.readFileSync(file, 'utf8')); }
|
|
18
22
|
catch { fail(`service receipt is missing or invalid: ${file}`); }
|
|
19
23
|
if (!st.isFile() || st.isSymbolicLink() || (st.mode & 0o777) !== 0o600) fail(`${file} must be a private regular file`);
|
|
20
|
-
if (!value || value.schema_version !== 1 || value.home
|
|
24
|
+
if (!value || value.schema_version !== 1 || !sameHome(value.home, home) || !value.unit) fail(`${file} has an unsupported service receipt`);
|
|
21
25
|
return { file, value };
|
|
22
26
|
}
|
|
23
27
|
function canonical(x) {
|
|
@@ -55,18 +59,28 @@ function catalogsEqual(a, b, workers) {
|
|
|
55
59
|
const hasCatalogs = catalogs => !!catalogs && Object.keys(catalogs).length > 0;
|
|
56
60
|
function releaseVersion(r, current) {
|
|
57
61
|
if (!r || r.name !== PACKAGE || typeof r.version !== 'string' || !/^\d+\.\d+\.\d+$/.test(r.version) || typeof r.dist?.integrity !== 'string' || !r.dist.integrity.startsWith('sha512-')) fail('registry returned invalid stable release metadata');
|
|
62
|
+
if (typeof current !== 'string' || !/^\d+\.\d+\.\d+$/.test(current)) fail('installed service version is not a stable semantic version');
|
|
58
63
|
const parts = s => s.split('.').map(Number), a = parts(r.version), b = parts(current);
|
|
59
|
-
if (
|
|
64
|
+
if (a.some(n => !Number.isSafeInteger(n)) || b.some(n => !Number.isSafeInteger(n))) fail('installed service version is not a stable semantic version');
|
|
60
65
|
return a[0] > b[0] || a[0] === b[0] && (a[1] > b[1] || a[1] === b[1] && a[2] > b[2]);
|
|
61
66
|
}
|
|
62
67
|
function atomic(file, text) {
|
|
63
68
|
privateDir(path.dirname(file)); writeAtomic(file, text);
|
|
64
69
|
}
|
|
65
70
|
const failedFile = home => path.join(home, 'update-failed.json');
|
|
66
|
-
function
|
|
71
|
+
function clearFailedReleaseMarker(home, warnings) {
|
|
72
|
+
try { fs.rmSync(failedFile(home), { force: true }); }
|
|
73
|
+
catch { warnings.push('failed release marker cleanup failed'); }
|
|
74
|
+
}
|
|
75
|
+
function readFailed(home, active) {
|
|
67
76
|
try {
|
|
68
77
|
const v = JSON.parse(fs.readFileSync(failedFile(home), 'utf8'));
|
|
69
|
-
|
|
78
|
+
if (typeof v?.version !== 'string' || typeof v.integrity !== 'string') return null;
|
|
79
|
+
// A cleanup failure may leave the marker for the very bytes now selected.
|
|
80
|
+
// Do not infer integrity from the version alone or rewrite the marker here.
|
|
81
|
+
if (active?.repo && active.receipt.repo === active.repo && active.receipt.version === active.version &&
|
|
82
|
+
v.version === active.version && v.integrity === active.receipt.release_integrity) return null;
|
|
83
|
+
return v;
|
|
70
84
|
} catch { return null; }
|
|
71
85
|
}
|
|
72
86
|
function copyTree(src, dst) {
|
|
@@ -79,9 +93,34 @@ function copyTree(src, dst) {
|
|
|
79
93
|
fs.chmodSync(dst, st.mode & 0o777);
|
|
80
94
|
} else { fs.copyFileSync(src, dst); fs.chmodSync(dst, st.mode & 0o777); }
|
|
81
95
|
}
|
|
82
|
-
function replaceTree(src, dst) {
|
|
83
|
-
fs.
|
|
84
|
-
|
|
96
|
+
export function replaceTree(src, dst, { copy = copyTree } = {}) {
|
|
97
|
+
if (!fs.existsSync(src)) {
|
|
98
|
+
fs.rmSync(dst, { recursive: true, force: true });
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
const staging = dst + '.restore-' + process.pid;
|
|
102
|
+
fs.rmSync(staging, { recursive: true, force: true });
|
|
103
|
+
try {
|
|
104
|
+
copy(src, staging);
|
|
105
|
+
} catch (error) {
|
|
106
|
+
fs.rmSync(staging, { recursive: true, force: true });
|
|
107
|
+
throw error;
|
|
108
|
+
}
|
|
109
|
+
// Keep the existing destination until the replacement is ready and recover it if activation fails.
|
|
110
|
+
const aside=dst+'.previous-'+randomUUID();
|
|
111
|
+
let moved=false;
|
|
112
|
+
try {
|
|
113
|
+
if(fs.lstatSync(dst,{throwIfNoEntry:false})) { fs.renameSync(dst,aside); moved=true; }
|
|
114
|
+
fs.renameSync(staging,dst);
|
|
115
|
+
} catch (error) {
|
|
116
|
+
if(moved) {
|
|
117
|
+
try { fs.renameSync(aside,dst); }
|
|
118
|
+
catch(rollbackError) { throw new AggregateError([error,rollbackError], 'restore activation and rollback failed; previous directory retained at '+aside); }
|
|
119
|
+
}
|
|
120
|
+
fs.rmSync(staging,{recursive:true,force:true});
|
|
121
|
+
throw error;
|
|
122
|
+
}
|
|
123
|
+
if(moved) fs.rmSync(aside,{recursive:true,force:true});
|
|
85
124
|
}
|
|
86
125
|
function snapshot(home, txn) {
|
|
87
126
|
const target = path.join(txn, 'snapshot.pending'); fs.rmSync(target, { recursive: true, force: true }); privateDir(target);
|
|
@@ -166,14 +205,26 @@ function prune(home, active, previous) {
|
|
|
166
205
|
async function probeReady(probe, home, receipt, healthTimeoutMs = HEALTH_TIMEOUT_MS) {
|
|
167
206
|
const deadline = performance.now() + healthTimeoutMs;
|
|
168
207
|
let error;
|
|
169
|
-
|
|
170
|
-
const
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
208
|
+
for (let remaining = deadline - performance.now(); remaining > 0; remaining = deadline - performance.now()) {
|
|
209
|
+
const controller = new AbortController();
|
|
210
|
+
let timer;
|
|
211
|
+
const expired = new Promise((_, reject) => {
|
|
212
|
+
timer = setTimeout(() => {
|
|
213
|
+
reject(new Error('health probe did not respond'));
|
|
214
|
+
controller.abort();
|
|
215
|
+
}, Math.ceil(remaining));
|
|
216
|
+
});
|
|
217
|
+
try {
|
|
218
|
+
const live = await Promise.race([
|
|
219
|
+
probe(home, receipt, { timeout: Math.max(1, Math.min(remaining, 1000)), signal: controller.signal }),
|
|
220
|
+
expired,
|
|
221
|
+
]);
|
|
222
|
+
if (performance.now() < deadline) return live;
|
|
223
|
+
} catch (e) { error = e; }
|
|
224
|
+
finally { clearTimeout(timer); }
|
|
225
|
+
if (controller.signal.aborted) break;
|
|
226
|
+
const delay = Math.min(150, Math.max(0, deadline - performance.now()));
|
|
227
|
+
if (delay) await new Promise(resolve => setTimeout(resolve, delay));
|
|
177
228
|
}
|
|
178
229
|
throw new Error(`service health check timed out after ${healthTimeoutMs}ms${error ? `: ${error.message}` : ''}`);
|
|
179
230
|
}
|
|
@@ -185,10 +236,10 @@ function readJournal(home) {
|
|
|
185
236
|
let tx;
|
|
186
237
|
try { tx = JSON.parse(fs.readFileSync(file, 'utf8')); } catch { fail('update transaction is invalid JSON'); }
|
|
187
238
|
const oldReceipt = tx?.oldReceipt;
|
|
188
|
-
if (tx.home
|
|
239
|
+
if (!sameHome(tx.home, home) || !oldReceipt || !sameHome(oldReceipt.home, home) || oldReceipt.schema_version !== 1 || !oldReceipt.unit ||
|
|
189
240
|
!tx.oldRepo || !tx.oldVersion || !tx.snapshot || !['prepared', 'switched', 'committed'].includes(tx.phase)) fail('invalid interrupted update transaction');
|
|
190
241
|
if (tx.unitFile !== (oldReceipt.unit && oldReceipt.platform !== 'darwin' ? unitPath(oldReceipt, home) : null) || !tx.oldCatalogs || typeof tx.oldCatalogs !== 'object') fail('update transaction control data is invalid');
|
|
191
|
-
if (path.resolve(tx.snapshot) !== path.join(home, 'update-backup', 'snapshot')) fail('update transaction snapshot path is invalid');
|
|
242
|
+
if (path.resolve(realHome(path.dirname(tx.snapshot)), path.basename(tx.snapshot)) !== path.join(home, 'update-backup', 'snapshot')) fail('update transaction snapshot path is invalid');
|
|
192
243
|
return { file, tx };
|
|
193
244
|
}
|
|
194
245
|
// Put the old package, unit and saved state back on disk. Touches no service and probes nothing.
|
|
@@ -213,7 +264,7 @@ function restoreFromJournal(home, tx) {
|
|
|
213
264
|
}
|
|
214
265
|
// Run at service start (ExecStartPre): finish filesystem recovery without touching systemd.
|
|
215
266
|
export function recoverService({ home }) {
|
|
216
|
-
home =
|
|
267
|
+
home = resolveHome(home);
|
|
217
268
|
if (!fs.existsSync(path.join(home, 'update-transaction.json'))) return { outcome: 'nothing_pending' };
|
|
218
269
|
let release;
|
|
219
270
|
try { release = acquireUpdateLock(home); }
|
|
@@ -251,29 +302,87 @@ function actualWorkers(home) {
|
|
|
251
302
|
if (!workers.length) fail('configured worker set is empty');
|
|
252
303
|
return workers;
|
|
253
304
|
}
|
|
305
|
+
// update-result.json is an optional record. If it cannot be written the outcome stands; the failure is reported as a warning.
|
|
306
|
+
// Each write carries the started-at stamp of the operation that produced it, and a write whose stamp is older than
|
|
307
|
+
// the stamp already in the file is refused: it is a stale result from an operation that started before a newer one
|
|
308
|
+
// finished. Callers must hold the update lock while calling this, so the stamp read and the write cannot interleave
|
|
309
|
+
// with another writer.
|
|
310
|
+
function readResultStamp(file) {
|
|
311
|
+
try {
|
|
312
|
+
const value = JSON.parse(fs.readFileSync(file, 'utf8'));
|
|
313
|
+
return typeof value?.started_at_ms === 'number' && Number.isFinite(value.started_at_ms) ? value.started_at_ms : null;
|
|
314
|
+
} catch { return null; }
|
|
315
|
+
}
|
|
316
|
+
function recordResult(file, result, startedAtMs) {
|
|
317
|
+
try {
|
|
318
|
+
if (typeof startedAtMs === 'number') {
|
|
319
|
+
const existing = readResultStamp(file);
|
|
320
|
+
if (existing !== null && existing >= startedAtMs) return false;
|
|
321
|
+
}
|
|
322
|
+
atomic(file, JSON.stringify({ ...result, started_at_ms: startedAtMs, timestamp: new Date().toISOString() }));
|
|
323
|
+
return true;
|
|
324
|
+
}
|
|
325
|
+
catch {
|
|
326
|
+
const warning = 'could not write the optional update-result.json record';
|
|
327
|
+
console.error(`dalan: ${warning}`);
|
|
328
|
+
(result.warnings ??= []).push(warning);
|
|
329
|
+
return false;
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
const UPDATE_FAILURES = new Set(['rolled_back', 'rollback_failed', 'commit_uncertain']);
|
|
333
|
+
function failedUpdate(error, phase) {
|
|
334
|
+
const outcome = UPDATE_FAILURES.has(error.updateOutcome) ? error.updateOutcome : 'failed';
|
|
335
|
+
return { outcome, phase, error: `service update failed during ${phase.replaceAll('_', ' ')}` };
|
|
336
|
+
}
|
|
337
|
+
|
|
254
338
|
export async function updateService({ home, check = false, yes = false, retry = false }, seams = {}) {
|
|
339
|
+
// The stamp this operation started at orders its status write against a newer operation's.
|
|
340
|
+
const startedAtMs = Date.now();
|
|
255
341
|
if (check && retry) fail('--retry cannot be used with --check');
|
|
256
|
-
home =
|
|
342
|
+
home = resolveHome(home);
|
|
257
343
|
const latest = seams.latestRelease ?? defaultLatest, install = seams.installRelease ?? defaultInstall;
|
|
258
344
|
const probe = seams.probeService ?? defaultProbe, candidateProbe = seams.probeCandidate ?? defaultCandidate;
|
|
259
345
|
const control = seams.controlService ?? defaultControl, pruneVersions = seams.pruneVersions ?? prune;
|
|
260
346
|
const healthTimeoutMs = seams.healthTimeoutMs ?? HEALTH_TIMEOUT_MS;
|
|
261
347
|
if (!Number.isFinite(healthTimeoutMs) || healthTimeoutMs <= 0) fail('healthTimeoutMs must be a positive finite duration');
|
|
262
348
|
if (check) {
|
|
263
|
-
const
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
349
|
+
const checkFile = path.join(home, 'update-result.json');
|
|
350
|
+
let checked, phase = 'read_install';
|
|
351
|
+
try {
|
|
352
|
+
const receipt = adoptInstall(readReceipt(home).value, home), active = fs.existsSync(path.join(home, 'current')) ? fs.realpathSync(path.join(home, 'current')) : receipt.repo;
|
|
353
|
+
if (!active) fail('current service repository is missing');
|
|
354
|
+
const current = JSON.parse(fs.readFileSync(path.join(active, 'package.json'), 'utf8')).version;
|
|
355
|
+
phase = 'check_release';
|
|
356
|
+
const r = await latest(receipt); const forward = releaseVersion(r, current);
|
|
357
|
+
checked = { outcome: forward ? 'update_available' : 'up_to_date', current_version: current, latest_version: r.version };
|
|
358
|
+
return checked;
|
|
359
|
+
} catch (error) {
|
|
360
|
+
checked = failedUpdate(error, phase);
|
|
361
|
+
throw error;
|
|
362
|
+
} finally {
|
|
363
|
+
if (checked) {
|
|
364
|
+
// The check holds no lock while it waits on the registry, so an update may finish first. Take the
|
|
365
|
+
// update lock for this write, so the stamp read and the write cannot interleave with the update's write.
|
|
366
|
+
// When an update is already running, its own result supersedes this check, so the write is skipped.
|
|
367
|
+
let releaseCheckLock = null;
|
|
368
|
+
try { releaseCheckLock = acquireUpdateLock(home); } catch (error) {
|
|
369
|
+
if (!/already running/.test(error.message) && !/active in another/.test(error.message) && error.code !== 'session_busy') {
|
|
370
|
+
console.error('dalan: could not write the optional update-result.json record');
|
|
371
|
+
(checked.warnings ??= []).push('could not write the optional update-result.json record');
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
try { if (releaseCheckLock) recordResult(checkFile, checked, startedAtMs); }
|
|
375
|
+
finally { releaseCheckLock?.(); }
|
|
376
|
+
}
|
|
377
|
+
}
|
|
270
378
|
}
|
|
271
379
|
privateDir(home);
|
|
272
380
|
const releaseLock = acquireUpdateLock(home);
|
|
273
381
|
const resultFile = path.join(home, 'update-result.json');
|
|
274
|
-
let result, attempted;
|
|
382
|
+
let result, attempted, phase = 'recover';
|
|
275
383
|
try {
|
|
276
384
|
await recover(home, control, probe, healthTimeoutMs);
|
|
385
|
+
phase = 'read_install';
|
|
277
386
|
const { value: storedReceipt, file: receiptFile } = readReceipt(home);
|
|
278
387
|
const receipt = adoptInstall(storedReceipt, home);
|
|
279
388
|
let current = path.join(home, 'current');
|
|
@@ -281,19 +390,23 @@ export async function updateService({ home, check = false, yes = false, retry =
|
|
|
281
390
|
if (!oldRepo || !fs.existsSync(oldRepo)) fail('current service repository is missing');
|
|
282
391
|
const oldVersion = JSON.parse(fs.readFileSync(path.join(oldRepo, 'package.json'), 'utf8')).version;
|
|
283
392
|
const workers = actualWorkers(home);
|
|
393
|
+
phase = 'check_release';
|
|
284
394
|
const r = await latest(receipt), forward = releaseVersion(r, oldVersion);
|
|
285
395
|
if (!forward) { result = { outcome: 'up_to_date', current_version: oldVersion, latest_version: r.version }; return result; }
|
|
286
|
-
const failed = readFailed(home);
|
|
396
|
+
const failed = readFailed(home, { repo: oldRepo, version: oldVersion, receipt });
|
|
287
397
|
if (!retry && failed && failed.version === r.version && failed.integrity === r.dist.integrity) {
|
|
288
|
-
|
|
398
|
+
const reason = failed.outcome === 'commit_uncertain' ? 'has an uncertain earlier commit' : 'was rolled back earlier';
|
|
399
|
+
result = { outcome: 'skipped_failed_release', current_version: oldVersion, latest_version: r.version, failed_version: failed.version, message: `Release ${r.version} ${reason}; not retrying automatically. Run dalan service update --retry to try it again.` };
|
|
289
400
|
return result;
|
|
290
401
|
}
|
|
291
402
|
attempted = r;
|
|
403
|
+
phase = 'install';
|
|
292
404
|
const installed = await install(home, r);
|
|
293
405
|
const candidate = path.resolve(installed), versions = path.resolve(home, 'versions');
|
|
294
406
|
if (candidate !== path.join(versions, r.version, 'node_modules', '@tnunamak', 'dalan') || !candidate.startsWith(`${versions}${path.sep}`) || fs.realpathSync(candidate) !== candidate) fail('candidate repository does not match exact package version path');
|
|
295
407
|
const packageInfo = JSON.parse(fs.readFileSync(path.join(candidate, 'package.json'), 'utf8'));
|
|
296
408
|
if (packageInfo.name !== PACKAGE || packageInfo.version !== r.version) fail('installed candidate package identity does not match registry release');
|
|
409
|
+
phase = 'verify_candidate';
|
|
297
410
|
const base = await probe(home, receipt), legacy = base.legacy === true;
|
|
298
411
|
const configBeforeCandidate = configurationDigest(home, receipt);
|
|
299
412
|
const tested = await candidateProbe(home, receipt, candidate);
|
|
@@ -311,6 +424,7 @@ export async function updateService({ home, check = false, yes = false, retry =
|
|
|
311
424
|
const liveAgain = await probe(home, receipt);
|
|
312
425
|
if (liveAgain.version !== oldVersion || !legacy && !catalogsEqual(base, liveAgain, workers)) fail('live worker catalog changed during update; retry after connector refresh');
|
|
313
426
|
if (configurationDigest(home, receipt) !== digestBeforeRecheck || digestBeforeRecheck !== configBeforeCandidate) fail('service configuration changed during update; retry after connector refresh');
|
|
427
|
+
phase = 'switch';
|
|
314
428
|
// A macOS agent runs the package through the home's `current` link, so a switch needs no plist rewrite.
|
|
315
429
|
const unitFile = receipt.unit && receipt.platform !== 'darwin' ? unitPath(receipt, home) : null;
|
|
316
430
|
const txDir = path.join(home, 'update-backup'); privateDir(txDir);
|
|
@@ -327,9 +441,11 @@ export async function updateService({ home, check = false, yes = false, retry =
|
|
|
327
441
|
select(home, candidate);
|
|
328
442
|
if (unitFile) rewriteUnit(unitFile, current, home);
|
|
329
443
|
await control(receipt, 'daemon-reload'); await control(receipt, 'restart');
|
|
444
|
+
phase = 'health_check';
|
|
330
445
|
const live = await probeReady(probe, home, { ...receipt, repo: candidate }, healthTimeoutMs);
|
|
331
446
|
if (live.version !== r.version || !completeCatalogs(tested, live, workers) || !catalogsEqual(tested, live, workers)) fail('updated service health or worker catalogs failed');
|
|
332
|
-
|
|
447
|
+
phase = 'commit';
|
|
448
|
+
receipt.repo = candidate; receipt.version = r.version; receipt.release_integrity = r.dist.integrity;
|
|
333
449
|
atomic(receiptFile, JSON.stringify(receipt));
|
|
334
450
|
fs.rmSync(defaultPath(home, '.config/dot-bridge', 'service-catalog.json'), { force: true });
|
|
335
451
|
const committedTx = { ...tx, phase: 'committed' };
|
|
@@ -338,10 +454,11 @@ export async function updateService({ home, check = false, yes = false, retry =
|
|
|
338
454
|
let journal;
|
|
339
455
|
try { journal = JSON.parse(fs.readFileSync(path.join(home, 'update-transaction.json'), 'utf8')); }
|
|
340
456
|
catch { error.preserveCandidate = true; throw error; }
|
|
341
|
-
if (journal.phase === 'committed' && journal.home
|
|
457
|
+
if (journal.phase === 'committed' && sameHome(journal.home, home)) {
|
|
342
458
|
tx.phase = 'committed';
|
|
343
|
-
|
|
344
|
-
|
|
459
|
+
const cleanupWarnings = ['committed journal is visible but its durability check failed and recovery data was preserved'];
|
|
460
|
+
clearFailedReleaseMarker(home, cleanupWarnings);
|
|
461
|
+
result = { outcome: 'commit_uncertain', phase, previous_version: oldVersion, version: r.version, cleanup_warning: cleanupWarnings.join('; ') };
|
|
345
462
|
return result;
|
|
346
463
|
}
|
|
347
464
|
if (journal.phase !== 'switched') { error.preserveCandidate = true; throw error; }
|
|
@@ -349,23 +466,23 @@ export async function updateService({ home, check = false, yes = false, retry =
|
|
|
349
466
|
}
|
|
350
467
|
tx.phase = 'committed';
|
|
351
468
|
result = { outcome: 'updated', previous_version: oldVersion, version: r.version, ...(legacy ? { adopted_legacy_server: true } : {}) };
|
|
352
|
-
try { fs.rmSync(failedFile(home), { force: true }); } catch { /* stale record only skips the same release */ }
|
|
353
469
|
const cleanupWarnings = [];
|
|
354
|
-
|
|
355
|
-
try { fs.rmSync(
|
|
356
|
-
try {
|
|
470
|
+
clearFailedReleaseMarker(home, cleanupWarnings);
|
|
471
|
+
try { fs.rmSync(path.join(home, 'update-transaction.json'), { force: true }); } catch { cleanupWarnings.push('transaction marker cleanup failed'); }
|
|
472
|
+
try { fs.rmSync(txDir, { recursive: true, force: true }); } catch { cleanupWarnings.push('backup cleanup failed'); }
|
|
473
|
+
try { pruneVersions(home, r.version, oldVersion); } catch { cleanupWarnings.push('version pruning failed'); }
|
|
357
474
|
if (cleanupWarnings.length) result.cleanup_warning = cleanupWarnings.join('; ');
|
|
358
475
|
} catch (error) {
|
|
359
476
|
if (error.preserveCandidate) {
|
|
360
477
|
const uncertain = new Error(`update commit state is uncertain; candidate and recovery data were preserved: ${error.message}`);
|
|
361
|
-
uncertain.updateOutcome = '
|
|
478
|
+
uncertain.updateOutcome = 'commit_uncertain';
|
|
362
479
|
throw uncertain;
|
|
363
480
|
}
|
|
364
481
|
let rollbackError;
|
|
365
482
|
try {
|
|
366
483
|
if (tx.phase === 'switched') validateSnapshot(tx);
|
|
367
|
-
await control(receipt, 'stop');
|
|
368
|
-
if (tx.phase === 'switched')
|
|
484
|
+
await control(receipt, 'stop');
|
|
485
|
+
if (tx.phase === 'switched') restoreFiles(home, tx);
|
|
369
486
|
await control(receipt, 'daemon-reload'); await control(receipt, 'restart');
|
|
370
487
|
const restored = await probeReady(probe, home, { ...receipt, repo: oldRepo }, healthTimeoutMs);
|
|
371
488
|
if (restored.version !== oldVersion || !legacy && !catalogsEqual(base, restored, workers)) fail('old service health verification failed');
|
|
@@ -377,23 +494,51 @@ export async function updateService({ home, check = false, yes = false, retry =
|
|
|
377
494
|
}
|
|
378
495
|
return result;
|
|
379
496
|
} catch (error) {
|
|
380
|
-
result =
|
|
381
|
-
if (attempted && (result.outcome
|
|
497
|
+
result = failedUpdate(error, phase);
|
|
498
|
+
if (attempted && UPDATE_FAILURES.has(result.outcome)) {
|
|
382
499
|
try { atomic(failedFile(home), JSON.stringify({ version: attempted.version, integrity: attempted.dist.integrity, outcome: result.outcome, timestamp: new Date().toISOString() })); } catch { /* best effort */ }
|
|
383
500
|
}
|
|
384
501
|
throw error;
|
|
385
502
|
} finally {
|
|
386
|
-
try { if (result)
|
|
503
|
+
try { if (result) recordResult(resultFile, result, startedAtMs); }
|
|
387
504
|
finally { releaseLock(); }
|
|
388
505
|
}
|
|
389
506
|
}
|
|
390
507
|
|
|
508
|
+
// Only outcomes persisted by updateService are accepted; recovery commands return their own ephemeral status.
|
|
509
|
+
const UPDATE_RESULT_OUTCOMES = new Set([
|
|
510
|
+
'update_available', 'up_to_date', 'skipped_failed_release', 'connector_refresh_required',
|
|
511
|
+
'updated', 'failed', 'rolled_back', 'rollback_failed', 'commit_uncertain',
|
|
512
|
+
]);
|
|
513
|
+
|
|
514
|
+
// Persisted fields written by updateService; do not publish arbitrary file keys.
|
|
515
|
+
const UPDATE_RESULT_FIELDS = [
|
|
516
|
+
'outcome', 'current_version', 'latest_version', 'candidate_version', 'failed_version',
|
|
517
|
+
'previous_version', 'version', 'connector_refresh_required', 'adopted_legacy_server',
|
|
518
|
+
'cleanup_warning', 'error', 'phase', 'message', 'timestamp',
|
|
519
|
+
];
|
|
520
|
+
|
|
391
521
|
export function serviceStatus({ home }) {
|
|
392
|
-
home =
|
|
522
|
+
home = resolveHome(home);
|
|
393
523
|
const { value: receipt } = readReceipt(home), current = path.join(home, 'current');
|
|
394
|
-
|
|
395
|
-
|
|
524
|
+
const repo = fs.existsSync(current) ? fs.realpathSync(current) : null;
|
|
525
|
+
const version = repo ? JSON.parse(fs.readFileSync(path.join(repo, 'package.json'), 'utf8')).version : receipt.version;
|
|
396
526
|
let last_result = null;
|
|
397
|
-
|
|
398
|
-
|
|
527
|
+
let raw;
|
|
528
|
+
try { raw = fs.readFileSync(path.join(home, 'update-result.json'), 'utf8'); }
|
|
529
|
+
catch (error) {
|
|
530
|
+
if (error.code !== 'ENOENT') last_result = { status: 'unavailable', reason: 'unreadable' };
|
|
531
|
+
}
|
|
532
|
+
if (raw !== undefined) {
|
|
533
|
+
try {
|
|
534
|
+
const result = JSON.parse(raw);
|
|
535
|
+
last_result = result && typeof result === 'object' && !Array.isArray(result) &&
|
|
536
|
+
Object.hasOwn(result, 'outcome') && UPDATE_RESULT_OUTCOMES.has(result.outcome)
|
|
537
|
+
? Object.fromEntries(UPDATE_RESULT_FIELDS.filter(key => Object.hasOwn(result, key)).map(key => [key, result[key]]))
|
|
538
|
+
: { status: 'unavailable', reason: 'malformed' };
|
|
539
|
+
} catch {
|
|
540
|
+
last_result = { status: 'unavailable', reason: 'malformed' };
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
return { version, auto_update: receipt.auto_update ?? false, last_result, failed_release: readFailed(home, { repo, version, receipt })?.version ?? null };
|
|
399
544
|
}
|