@evomap/evolver-proxy 2.0.41 → 2.0.44
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/bin/evolver-proxy.d.ts +3 -1
- package/dist/bin/evolver-proxy.js +4 -1
- package/dist/daemon/proxyDaemon.d.ts +9 -1
- package/dist/daemon/proxyDaemon.js +119 -12
- package/dist/daemon/publishBindingLedger.js +5 -0
- package/dist/lifecycle/claimNudge.js +1 -1
- package/dist/lifecycle/deployGuard.js +1 -1
- package/dist/lifecycle/legacyNodeId.js +1 -1
- package/dist/lifecycle/manager.js +1 -1
- package/dist/llm/bodyCapture.js +293 -1
- package/dist/llm/index.js +1 -1
- package/dist/llm/server.js +1 -1
- package/dist/llm/traceBackfill.js +1 -1
- package/dist/llm/traceConfig.js +1 -1
- package/dist/llm/traceControl.js +1 -1
- package/dist/llm/traceEnvelope.js +1 -1
- package/dist/llm/traceSink.js +1 -1
- package/dist/llm/traceUploadPayload.js +1 -1
- package/dist/llm/upstream.js +1 -1
- package/dist/private/adapterLoader.d.ts +13 -0
- package/dist/private/adapterLoader.js +13 -0
- package/dist/router/cachePassthrough.js +1 -1
- package/dist/router/features.js +1 -1
- package/dist/router/index.js +1 -1
- package/dist/router/messagesRoute.js +1 -1
- package/dist/router/modelRouter.js +1 -1
- package/dist/router/providerRoutes.js +1 -1
- package/dist/router/sseScan.js +1 -1
- package/dist/selfUpdate/bootstrap.d.ts +3 -0
- package/dist/selfUpdate/bootstrap.js +33 -7
- package/dist/selfUpdate/legacyLaunchdAbsentServiceBlock.d.ts +10 -0
- package/dist/selfUpdate/legacyLaunchdAbsentServiceBlock.js +39 -0
- package/dist/selfUpdate/migration.d.ts +5 -0
- package/dist/selfUpdate/migration.js +108 -9
- package/dist/sync/engine.js +1 -1
- package/package.json +3 -3
|
@@ -24,6 +24,7 @@ import { isSelfUpdateExplicit, resolveSelfUpdatePolicy, selfUpdateSupervisorAtte
|
|
|
24
24
|
import { isStandaloneReleaseBinaryName, resolveSelfUpdateTarget, } from './releaseBinary.js';
|
|
25
25
|
import { expandHomePath, parseEnvFile } from '../bin/envFile.js';
|
|
26
26
|
import { migrateToStandaloneBinary, } from './migration.js';
|
|
27
|
+
import { isLegacyAbsentServicePreflightBlock, } from './legacyLaunchdAbsentServiceBlock.js';
|
|
27
28
|
const requireFromHere = createRequire(import.meta.url);
|
|
28
29
|
const BOOTSTRAP_ATTEMPT_FILE = 'bootstrap-attempt.json';
|
|
29
30
|
const BOOTSTRAP_REGISTRATION_INTENT_FILE = coreBootstrap.LIFECYCLE_BOOTSTRAP_REGISTRATION_INTENT_FILE;
|
|
@@ -353,7 +354,7 @@ function parseBootstrapLockOwnerJson(raw) {
|
|
|
353
354
|
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed))
|
|
354
355
|
return undefined;
|
|
355
356
|
const record = parsed;
|
|
356
|
-
const keys = Object.keys(record).sort();
|
|
357
|
+
const keys = Object.keys(record).filter(key => key !== 'processStartCollector').sort();
|
|
357
358
|
if (keys.length !== 4
|
|
358
359
|
|| keys[0] !== 'pid'
|
|
359
360
|
|| keys[1] !== 'processStart'
|
|
@@ -367,6 +368,12 @@ function parseBootstrapLockOwnerJson(raw) {
|
|
|
367
368
|
const processStartIdentity = util.parseFileLockProcessStartIdentity(record['processStart']);
|
|
368
369
|
if (!processStartIdentity)
|
|
369
370
|
return undefined;
|
|
371
|
+
// The native Windows collector keeps the legacy identity wire shape. Its additive diagnostic
|
|
372
|
+
// marker is not authority; accept only the known value on that identity, preserving strict keys.
|
|
373
|
+
if (Object.hasOwn(record, 'processStartCollector')
|
|
374
|
+
&& (record['processStartCollector'] !== 'kernel32-get-process-times'
|
|
375
|
+
|| processStartIdentity.source !== 'windows-powershell'))
|
|
376
|
+
return undefined;
|
|
370
377
|
return {
|
|
371
378
|
pid: record['pid'],
|
|
372
379
|
token: record['token'],
|
|
@@ -1502,7 +1509,7 @@ function observationDetail(observation, stdout, stderr) {
|
|
|
1502
1509
|
parts.push(stderrText);
|
|
1503
1510
|
return parts.length > 0 ? boundedBootstrapDetail(parts.join('; ')) : undefined;
|
|
1504
1511
|
}
|
|
1505
|
-
function reconcileBootstrapOutcome(observation, state, stdout, stderr) {
|
|
1512
|
+
function reconcileBootstrapOutcome(observation, state, stdout, stderr, host) {
|
|
1506
1513
|
const detail = observationDetail(observation, stdout, stderr);
|
|
1507
1514
|
const failClosed = (reason, failureDetail) => ({
|
|
1508
1515
|
ok: false,
|
|
@@ -1561,6 +1568,20 @@ function reconcileBootstrapOutcome(observation, state, stdout, stderr) {
|
|
|
1561
1568
|
};
|
|
1562
1569
|
}
|
|
1563
1570
|
if (observation.cli?.outcome === 'blocked') {
|
|
1571
|
+
if (state.status === 'clean' && isLegacyAbsentServicePreflightBlock({
|
|
1572
|
+
platform: host.platform ?? process.platform,
|
|
1573
|
+
exitCode: observation.code,
|
|
1574
|
+
cliDetail: observation.cli.detail,
|
|
1575
|
+
stdoutTruncated: stdout.truncated,
|
|
1576
|
+
}, host.launchdServiceProbe)) {
|
|
1577
|
+
// The child rejected its own preflight before publishing any artifact or journal, and
|
|
1578
|
+
// launchd confirms no proxy service is loaded, so nothing is left to roll back.
|
|
1579
|
+
return {
|
|
1580
|
+
ok: false,
|
|
1581
|
+
reason: 'rolled_back',
|
|
1582
|
+
detail: boundedBootstrapDetail(`legacy_absent_service_preflight: ${observation.cli.detail}`),
|
|
1583
|
+
};
|
|
1584
|
+
}
|
|
1564
1585
|
return failClosed('blocked', combinedDetail || observation.cli.detail);
|
|
1565
1586
|
}
|
|
1566
1587
|
return failClosed('ambiguous', combinedDetail || `CLI result did not prove commit or rollback (exit ${observation.code ?? 'null'})`);
|
|
@@ -1686,7 +1707,7 @@ async function terminateBootstrapProcessTree(child, platform, childClosed, deadl
|
|
|
1686
1707
|
/** Spawn `evolver lifecycle bootstrap` and await its result within a bounded timeout. */
|
|
1687
1708
|
export async function runBootstrap(options) {
|
|
1688
1709
|
const emptyOutput = () => captureBootstrapOutput(undefined);
|
|
1689
|
-
const reconcileNoChild = (reason, detail) => reconcileBootstrapOutcome({ kind: 'no_child', reason, ...(detail ? { detail } : {}) }, inspectLifecycleBootstrapDurableState(options.env, options), emptyOutput(), emptyOutput());
|
|
1710
|
+
const reconcileNoChild = (reason, detail) => reconcileBootstrapOutcome({ kind: 'no_child', reason, ...(detail ? { detail } : {}) }, inspectLifecycleBootstrapDurableState(options.env, options), emptyOutput(), emptyOutput(), options);
|
|
1690
1711
|
const invocation = resolveBootstrapCliInvocation(options);
|
|
1691
1712
|
if (!invocation)
|
|
1692
1713
|
return reconcileNoChild('cli_not_found');
|
|
@@ -1737,7 +1758,7 @@ export async function runBootstrap(options) {
|
|
|
1737
1758
|
settled = true;
|
|
1738
1759
|
if (timerRef.value)
|
|
1739
1760
|
clearTimeout(timerRef.value);
|
|
1740
|
-
resolvePromise(reconcileBootstrapOutcome(observation, inspectLifecycleBootstrapDurableState(options.env, options), stdout, stderr));
|
|
1761
|
+
resolvePromise(reconcileBootstrapOutcome(observation, inspectLifecycleBootstrapDurableState(options.env, options), stdout, stderr, options));
|
|
1741
1762
|
};
|
|
1742
1763
|
const containAndSettle = (confirmedObservation) => {
|
|
1743
1764
|
if (settled || containmentStarted)
|
|
@@ -3229,6 +3250,7 @@ function defaultMigrationRegistrationRunner(options) {
|
|
|
3229
3250
|
...(options.treeKillSpawnFn !== undefined ? { treeKillSpawnFn: options.treeKillSpawnFn } : {}),
|
|
3230
3251
|
...(options.processKill !== undefined ? { processKill: options.processKill } : {}),
|
|
3231
3252
|
...(options.terminationGraceMs !== undefined ? { terminationGraceMs: options.terminationGraceMs } : {}),
|
|
3253
|
+
...(options.launchdServiceProbe !== undefined ? { launchdServiceProbe: options.launchdServiceProbe } : {}),
|
|
3232
3254
|
...(options.beforeIntentPublish !== undefined ? { beforeIntentPublish: options.beforeIntentPublish } : {}),
|
|
3233
3255
|
...(options.afterIntentPublicationStep !== undefined
|
|
3234
3256
|
? { afterIntentPublicationStep: options.afterIntentPublicationStep }
|
|
@@ -3370,8 +3392,10 @@ export async function bootstrapDegradedSelfUpdateStartup(env, platform = process
|
|
|
3370
3392
|
});
|
|
3371
3393
|
const recoveringPendingOwnership = reason === 'migration_ambiguous'
|
|
3372
3394
|
|| reason === 'bootstrap_attempt_pending';
|
|
3373
|
-
|
|
3374
|
-
|
|
3395
|
+
const pendingOwnershipUnresolved = recoveringPendingOwnership
|
|
3396
|
+
&& migration.outcome !== 'migrated'
|
|
3397
|
+
&& migration.priorOwnershipRolledBack !== true;
|
|
3398
|
+
if (migration.requiresForegroundExit === true || pendingOwnershipUnresolved) {
|
|
3375
3399
|
return {
|
|
3376
3400
|
disposition: 'fail_closed',
|
|
3377
3401
|
handedOver: false,
|
|
@@ -3389,7 +3413,9 @@ export async function bootstrapDegradedSelfUpdateStartup(env, platform = process
|
|
|
3389
3413
|
message: migration.message,
|
|
3390
3414
|
};
|
|
3391
3415
|
}
|
|
3392
|
-
if (migration.outcome === 'skipped'
|
|
3416
|
+
if (migration.outcome === 'skipped'
|
|
3417
|
+
&& migration.reason !== 'cooldown'
|
|
3418
|
+
&& migration.priorOwnershipRolledBack !== true) {
|
|
3393
3419
|
recordBootstrapAttempt(bootstrapEnv, { ok: false, reason }, options);
|
|
3394
3420
|
}
|
|
3395
3421
|
return {
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const LEGACY_ABSENT_SERVICE_PREFLIGHT_DETAIL = "bootstrap preflight existing service check failed closed with manager state unavailable";
|
|
2
|
+
/** Exit status of `launchctl print gui/<uid>/<proxy label>`, or null when it did not exit normally. */
|
|
3
|
+
export type LaunchdServiceProbe = (uid: number) => number | null;
|
|
4
|
+
export interface LegacyBootstrapBlock {
|
|
5
|
+
platform: NodeJS.Platform;
|
|
6
|
+
exitCode: number | null;
|
|
7
|
+
cliDetail: string | undefined;
|
|
8
|
+
stdoutTruncated: boolean;
|
|
9
|
+
}
|
|
10
|
+
export declare function isLegacyAbsentServicePreflightBlock(block: LegacyBootstrapBlock, probe?: LaunchdServiceProbe): boolean;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// Releases through 2.0.42 read `launchctl print` exit 113 ("Could not find specified service") as
|
|
2
|
+
// an unavailable manager, so `lifecycle bootstrap` rejects its own preflight on every macOS host
|
|
3
|
+
// that never had the service and reports `blocked`. Those binaries stay installed on user machines
|
|
4
|
+
// and keep answering this way, so the foreground proxy has to recognise that one answer itself.
|
|
5
|
+
//
|
|
6
|
+
// The recognition is deliberately brittle-by-design: it matches the exact text those releases emit
|
|
7
|
+
// and still requires this process to observe, through launchd, that the service is not loaded.
|
|
8
|
+
// Any other wording, exit status, or probe result stays fail-closed.
|
|
9
|
+
import { spawnSync } from 'node:child_process';
|
|
10
|
+
const LAUNCHCTL_PATH = '/bin/launchctl';
|
|
11
|
+
const PROXY_LAUNCHD_LABEL = 'com.evomap.evolver-proxy';
|
|
12
|
+
const LAUNCHCTL_SERVICE_NOT_FOUND_STATUS = 113;
|
|
13
|
+
const LAUNCHD_SERVICE_PROBE_TIMEOUT_MS = 5_000;
|
|
14
|
+
const LEGACY_BOOTSTRAP_FAILURE_EXIT_CODE = 1;
|
|
15
|
+
export const LEGACY_ABSENT_SERVICE_PREFLIGHT_DETAIL = 'bootstrap preflight existing service check failed closed with manager state unavailable';
|
|
16
|
+
function probeLaunchdProxyService(uid) {
|
|
17
|
+
const result = spawnSync(LAUNCHCTL_PATH, ['print', `gui/${uid}/${PROXY_LAUNCHD_LABEL}`], { stdio: 'ignore', timeout: LAUNCHD_SERVICE_PROBE_TIMEOUT_MS, windowsHide: true });
|
|
18
|
+
return result.error ? null : result.status;
|
|
19
|
+
}
|
|
20
|
+
function matchesLegacyAbsentServicePreflight(block) {
|
|
21
|
+
return block.platform === 'darwin'
|
|
22
|
+
&& block.exitCode === LEGACY_BOOTSTRAP_FAILURE_EXIT_CODE
|
|
23
|
+
&& !block.stdoutTruncated
|
|
24
|
+
&& block.cliDetail === LEGACY_ABSENT_SERVICE_PREFLIGHT_DETAIL;
|
|
25
|
+
}
|
|
26
|
+
function launchdProxyServiceProvenNotLoaded(probe) {
|
|
27
|
+
const uid = typeof process.getuid === 'function' ? process.getuid() : undefined;
|
|
28
|
+
if (uid === undefined)
|
|
29
|
+
return false;
|
|
30
|
+
try {
|
|
31
|
+
return probe(uid) === LAUNCHCTL_SERVICE_NOT_FOUND_STATUS;
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
export function isLegacyAbsentServicePreflightBlock(block, probe = probeLaunchdProxyService) {
|
|
38
|
+
return matchesLegacyAbsentServicePreflight(block) && launchdProxyServiceProvenNotLoaded(probe);
|
|
39
|
+
}
|
|
@@ -133,6 +133,11 @@ export interface MigrationResult {
|
|
|
133
133
|
destPath?: string;
|
|
134
134
|
/** Registration ownership is ambiguous, so the foreground proxy must not continue. */
|
|
135
135
|
requiresForegroundExit?: true;
|
|
136
|
+
/**
|
|
137
|
+
* A stored registration transaction was durably rolled back during this call and the
|
|
138
|
+
* `migration_ambiguous` attempt marker it left behind has been replaced.
|
|
139
|
+
*/
|
|
140
|
+
priorOwnershipRolledBack?: true;
|
|
136
141
|
/** Operator-facing message (short phrase for skipped/failed; full line for migrated). */
|
|
137
142
|
message: string;
|
|
138
143
|
}
|
|
@@ -490,6 +490,64 @@ function parseCanonicalMigrationState(raw) {
|
|
|
490
490
|
}
|
|
491
491
|
: undefined;
|
|
492
492
|
}
|
|
493
|
+
// Releases cut before the canonical schema (2.0.0–2.0.2) wrote `migration.json` without
|
|
494
|
+
// `schemaVersion` and recorded EVERY failure as `state: 'failed'`, including registration
|
|
495
|
+
// failures whose child may still own the service manager. Only a failure in the signed download
|
|
496
|
+
// or in signature/hash verification proves nothing was written into the install target or
|
|
497
|
+
// executed from the artifact; a staged-binary preflight already ran the artifact.
|
|
498
|
+
const LEGACY_PRE_INSTALL_FAILURE_PREFIXES = [
|
|
499
|
+
`${SELF_UPDATE_FAILURE_CODES.MIGRATION_DOWNLOAD_FAILED}:`,
|
|
500
|
+
`${SELF_UPDATE_FAILURE_CODES.MIGRATION_VERIFY_FAILED}:`,
|
|
501
|
+
];
|
|
502
|
+
const LEGACY_EXECUTED_ARTIFACT_FAILURE_PREFIX = `${SELF_UPDATE_FAILURE_CODES.MIGRATION_VERIFY_FAILED}:preflight:`;
|
|
503
|
+
function parseLegacyPreInstallMigrationFailure(raw) {
|
|
504
|
+
let parsed;
|
|
505
|
+
try {
|
|
506
|
+
parsed = JSON.parse(raw);
|
|
507
|
+
}
|
|
508
|
+
catch {
|
|
509
|
+
return undefined;
|
|
510
|
+
}
|
|
511
|
+
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed))
|
|
512
|
+
return undefined;
|
|
513
|
+
const record = parsed;
|
|
514
|
+
const version = record['version'];
|
|
515
|
+
const destPath = record['destPath'];
|
|
516
|
+
const reason = record['reason'];
|
|
517
|
+
// The legacy writer never bounded or sanitized `reason`; only its leading failure code is read.
|
|
518
|
+
if (!exactMigrationRecordKeys(record, ['state', 'version', 'destPath', 'reason', 'attemptedAt'])
|
|
519
|
+
|| record['state'] !== 'failed'
|
|
520
|
+
|| typeof version !== 'string'
|
|
521
|
+
|| version.length > 128
|
|
522
|
+
|| ops.normalizeConcreteVersion(version) !== version
|
|
523
|
+
|| typeof destPath !== 'string'
|
|
524
|
+
|| !isAbsolute(destPath)
|
|
525
|
+
|| destPath.length > 4_096
|
|
526
|
+
|| /[\p{Cc}\p{Cf}\p{Zl}\p{Zp}]/u.test(destPath)
|
|
527
|
+
|| !exactMigrationTimestamp(record['attemptedAt'])
|
|
528
|
+
|| typeof reason !== 'string'
|
|
529
|
+
|| !LEGACY_PRE_INSTALL_FAILURE_PREFIXES.some((prefix) => reason.startsWith(prefix))
|
|
530
|
+
|| reason.startsWith(LEGACY_EXECUTED_ARTIFACT_FAILURE_PREFIX)) {
|
|
531
|
+
return undefined;
|
|
532
|
+
}
|
|
533
|
+
return { destPath };
|
|
534
|
+
}
|
|
535
|
+
/**
|
|
536
|
+
* A pre-schema record proves a clean rollback only while its install target is still absent:
|
|
537
|
+
* anything found there could belong to an earlier attempt the advisory record overwrote.
|
|
538
|
+
*/
|
|
539
|
+
function legacyPreInstallFailureInstalledNothing(raw) {
|
|
540
|
+
const legacy = parseLegacyPreInstallMigrationFailure(raw);
|
|
541
|
+
if (!legacy)
|
|
542
|
+
return false;
|
|
543
|
+
try {
|
|
544
|
+
lstatSync(legacy.destPath);
|
|
545
|
+
return false;
|
|
546
|
+
}
|
|
547
|
+
catch (error) {
|
|
548
|
+
return isErrno(error, 'ENOENT');
|
|
549
|
+
}
|
|
550
|
+
}
|
|
493
551
|
function inspectMigrationStartupState(env, options) {
|
|
494
552
|
let raw;
|
|
495
553
|
try {
|
|
@@ -502,6 +560,13 @@ function inspectMigrationStartupState(env, options) {
|
|
|
502
560
|
return { classification: 'none', canonicalPresent: false };
|
|
503
561
|
const record = parseCanonicalMigrationState(raw);
|
|
504
562
|
if (!record) {
|
|
563
|
+
// Classified as if no canonical record existed, so a legacy ownership outcome in
|
|
564
|
+
// bootstrap-attempt.json still keeps this attempt fail-closed.
|
|
565
|
+
// regression: 2026-10-08 a 2.0.2 download timeout left this record and every later
|
|
566
|
+
// release exited fail-closed on each start without writing anything, so it never cleared.
|
|
567
|
+
if (legacyPreInstallFailureInstalledNothing(raw)) {
|
|
568
|
+
return { classification: 'none', canonicalPresent: false };
|
|
569
|
+
}
|
|
505
570
|
return { classification: 'unsafe', canonicalPresent: true, detail: 'migration_state_invalid' };
|
|
506
571
|
}
|
|
507
572
|
if (record.state === 'rolled_back' || record.state === 'failed') {
|
|
@@ -682,21 +747,41 @@ function assertTrustedMigrationDirectoryChainSync(directory) {
|
|
|
682
747
|
}
|
|
683
748
|
assertWindowsMigrationAclTrusted(windowsChecks);
|
|
684
749
|
}
|
|
685
|
-
function
|
|
750
|
+
function recordedBootstrapAttemptOutcome(env, readFile) {
|
|
686
751
|
try {
|
|
687
752
|
const raw = readFile(join(resolveBootstrapStateDir(env), BOOTSTRAP_ATTEMPT_FILE));
|
|
688
753
|
if (raw.length === 0 || raw.length > 4 * 1024)
|
|
689
|
-
return
|
|
754
|
+
return undefined;
|
|
690
755
|
const parsed = JSON.parse(raw);
|
|
691
756
|
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed))
|
|
692
|
-
return
|
|
693
|
-
|
|
694
|
-
return outcome === 'migration_ambiguous' || outcome === 'migrated' || outcome === 'completed';
|
|
757
|
+
return undefined;
|
|
758
|
+
return parsed['outcome'];
|
|
695
759
|
}
|
|
696
760
|
catch {
|
|
697
|
-
return
|
|
761
|
+
return undefined;
|
|
698
762
|
}
|
|
699
763
|
}
|
|
764
|
+
function unresolvedLegacyMigrationOwnership(env, readFile) {
|
|
765
|
+
const outcome = recordedBootstrapAttemptOutcome(env, readFile);
|
|
766
|
+
return outcome === 'migration_ambiguous' || outcome === 'migrated' || outcome === 'completed';
|
|
767
|
+
}
|
|
768
|
+
/**
|
|
769
|
+
* Once the canonical record is durably `rolled_back` and the retried migration did not raise a new
|
|
770
|
+
* ambiguity, a leftover `migration_ambiguous` attempt marker no longer describes any owned artifact
|
|
771
|
+
* or child. A retry that recorded its own outcome already replaced it; a retry that was skipped did
|
|
772
|
+
* not, so replace it here with a clean failure. Returns whether the marker is no longer ambiguous.
|
|
773
|
+
*/
|
|
774
|
+
function retireRolledBackMigrationAmbiguity(env, options) {
|
|
775
|
+
const readFile = options.readFile ?? defaultReadTextFile;
|
|
776
|
+
if (recordedBootstrapAttemptOutcome(env, readFile) !== 'migration_ambiguous')
|
|
777
|
+
return true;
|
|
778
|
+
recordBootstrapAttempt(env, {
|
|
779
|
+
ok: false,
|
|
780
|
+
reason: 'migration_failed',
|
|
781
|
+
detail: `${SELF_UPDATE_FAILURE_CODES.MIGRATION_REGISTER_FAILED}: stored_registration_rolled_back`,
|
|
782
|
+
}, options);
|
|
783
|
+
return recordedBootstrapAttemptOutcome(env, readFile) !== 'migration_ambiguous';
|
|
784
|
+
}
|
|
700
785
|
async function assertTrustedMigrationDirectoryChain(directory, effectiveUid = resolveProcessUid()) {
|
|
701
786
|
let current = resolvePath(directory);
|
|
702
787
|
const root = parsePath(current).root;
|
|
@@ -1377,8 +1462,12 @@ async function removeMaterializedMigrationTemporaryFile(input) {
|
|
|
1377
1462
|
}
|
|
1378
1463
|
function parsePendingMigrationInstall(raw) {
|
|
1379
1464
|
const record = parseCanonicalMigrationState(raw);
|
|
1380
|
-
if (!record)
|
|
1465
|
+
if (!record) {
|
|
1466
|
+
// The pre-schema clean failure startup accepted is no install journal; re-proved under the lock.
|
|
1467
|
+
if (legacyPreInstallFailureInstalledNothing(raw))
|
|
1468
|
+
return undefined;
|
|
1381
1469
|
throw new Error('migration_install_journal_invalid');
|
|
1470
|
+
}
|
|
1382
1471
|
if (record.state !== 'installing')
|
|
1383
1472
|
return undefined;
|
|
1384
1473
|
return {
|
|
@@ -2044,6 +2133,16 @@ export async function migrateToStandaloneBinary(env, platform = process.platform
|
|
|
2044
2133
|
if (!hadPriorAmbiguity && recentBootstrapFailure(env, readText, now)) {
|
|
2045
2134
|
return skipped('cooldown', 'one-time standalone migration skipped (recent bootstrap failure cooldown)');
|
|
2046
2135
|
}
|
|
2136
|
+
const retryCurrentAfterStoredRollback = async () => {
|
|
2137
|
+
const markerOwnedByRolledBackMigration = recordedBootstrapAttemptOutcome(env, readText) === 'migration_ambiguous';
|
|
2138
|
+
const retried = await migrateToStandaloneBinary(env, platform, options);
|
|
2139
|
+
if (!markerOwnedByRolledBackMigration
|
|
2140
|
+
|| retried.requiresForegroundExit === true
|
|
2141
|
+
|| !retireRolledBackMigrationAmbiguity(env, { ...options, ...recordOptions })) {
|
|
2142
|
+
return retried;
|
|
2143
|
+
}
|
|
2144
|
+
return { ...retried, priorOwnershipRolledBack: true };
|
|
2145
|
+
};
|
|
2047
2146
|
if (startupState.classification === 'retryable'
|
|
2048
2147
|
&& startupState.record.state === 'installing') {
|
|
2049
2148
|
const reconciliation = await reconcileStoredMigrationInstall({
|
|
@@ -2072,7 +2171,7 @@ export async function migrateToStandaloneBinary(env, platform = process.platform
|
|
|
2072
2171
|
return reconciliation.result;
|
|
2073
2172
|
// Cleanup is idempotently complete and terminal state is durable; only now may the current
|
|
2074
2173
|
// version/home request replace the old transaction authority.
|
|
2075
|
-
return
|
|
2174
|
+
return retryCurrentAfterStoredRollback();
|
|
2076
2175
|
}
|
|
2077
2176
|
if (startupState.classification === 'retryable'
|
|
2078
2177
|
&& isCanonicalMigrationRegistrationState(startupState.record)) {
|
|
@@ -2088,7 +2187,7 @@ export async function migrateToStandaloneBinary(env, platform = process.platform
|
|
|
2088
2187
|
return reconciliation.result;
|
|
2089
2188
|
// The exact old transaction is now durably rolled back. Re-read canonical state before
|
|
2090
2189
|
// beginning the current version/home request so no stale in-memory authority crosses it.
|
|
2091
|
-
return
|
|
2190
|
+
return retryCurrentAfterStoredRollback();
|
|
2092
2191
|
}
|
|
2093
2192
|
// RESOLVE: version, asset name, dest path.
|
|
2094
2193
|
const version = resolveMigrationVersion(env);
|