@narumitw/pi-sync 0.67.0 → 0.67.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 +12 -0
- package/README.md +1 -1
- package/dist/chunks/{chunk-BESRBKVO.ts → chunk-2MSJDLSM.ts} +7 -7
- package/dist/chunks/{chunk-BYVHABNR.ts → chunk-2MUAR5GH.ts} +2 -2
- package/dist/chunks/{chunk-DAZZ5BEJ.ts → chunk-3NS4PMCI.ts} +6 -2
- package/dist/chunks/{chunk-FI2F5JBS.ts → chunk-3Q3DMMID.ts} +8 -8
- package/dist/chunks/{chunk-JQ5BAWW2.ts → chunk-C3E75DXW.ts} +84 -21
- package/dist/chunks/chunk-C3E75DXW.ts.map +7 -0
- package/dist/chunks/{chunk-SZJOUVCL.ts → chunk-DGVZYS7T.ts} +5 -5
- package/dist/chunks/{chunk-WJQ4TGN5.ts → chunk-ECUCXF5Y.ts} +2 -2
- package/dist/chunks/{chunk-ASU3GZPW.ts → chunk-GRXNUC6O.ts} +6 -6
- package/dist/chunks/{chunk-Z5JMOXJM.ts → chunk-I72HGZJJ.ts} +5 -5
- package/dist/chunks/{chunk-AYGMIMCV.ts → chunk-PUSMSKIM.ts} +11 -2
- package/dist/chunks/chunk-PUSMSKIM.ts.map +7 -0
- package/dist/chunks/{chunk-5YOLQKNZ.ts → chunk-UF2HU2NM.ts} +14 -14
- package/dist/chunks/{command-handler-SQC2L2FJ.ts → command-handler-HWRPH3K3.ts} +40 -32
- package/dist/chunks/command-handler-HWRPH3K3.ts.map +7 -0
- package/dist/chunks/config-P54GGMXY.ts +39 -0
- package/dist/chunks/{conflict-review-J7L7S4AR.ts → conflict-review-OBBBSVQD.ts} +2 -2
- package/dist/chunks/{file-selection-XWACUTAH.ts → file-selection-GASCVN45.ts} +6 -6
- package/dist/chunks/{ignore-file-ui-OHFISFVC.ts → ignore-file-ui-5BWA6LBC.ts} +5 -5
- package/dist/chunks/{manager-result-dispatcher-WXE2BAQO.ts → manager-result-dispatcher-MJ6G2CEI.ts} +7 -7
- package/dist/chunks/{manager-ui-DWOMAJKE.ts → manager-ui-Z3B5ZTA6.ts} +50 -32
- package/dist/chunks/manager-ui-Z3B5ZTA6.ts.map +7 -0
- package/dist/chunks/{merge-review-AAC674C6.ts → merge-review-C2KETZKY.ts} +3 -3
- package/dist/chunks/{remote-selection-ui-E4XZCQ7A.ts → remote-selection-ui-34WC7OFE.ts} +6 -6
- package/dist/chunks/{setup-switch-644T6KHG.ts → setup-switch-JZDFQPVW.ts} +4 -4
- package/dist/chunks/setup-switch-JZDFQPVW.ts.map +7 -0
- package/dist/chunks/{setup-wizard-IEW56AZE.ts → setup-wizard-YOXLXLBY.ts} +9 -9
- package/dist/chunks/{sync-inspection-NBBTSMKR.ts → sync-inspection-NIITROKS.ts} +5 -5
- package/dist/chunks/{sync-operations-AIEM2KL2.ts → sync-operations-FFI4ZZQL.ts} +2 -2
- package/dist/daemon/dist/client.js +32 -18
- package/dist/daemon/dist/daemon-recovery.js +5 -3
- package/dist/daemon/dist/engine/debug-log.js +19 -0
- package/dist/daemon/dist/engine/ignore/adoption-journal.js +6 -3
- package/dist/daemon/dist/engine/sync/ignore-adoption.js +8 -2
- package/dist/daemon/dist/engine/sync/sync-mutations.js +4 -1
- package/dist/daemon/dist/engine-service.js +22 -6
- package/dist/daemon/dist/foreground-queue-outcome.js +4 -0
- package/dist/daemon/dist/server.js +4 -3
- package/dist/daemon/dist/service-host.js +7 -2
- package/dist/daemon/package.json +1 -1
- package/dist/index.ts +41 -32
- package/dist/index.ts.map +2 -2
- package/docs/daemon-migration.md +2 -0
- package/package.json +2 -2
- package/skills/configure-pi-sync/references/configuration.md +2 -0
- package/src/commands/command-execution.ts +10 -1
- package/src/commands/command-handler.ts +4 -0
- package/src/daemon/client-debug.ts +6 -3
- package/src/daemon/directional-recovery.ts +35 -5
- package/src/daemon/pi-client.ts +83 -14
- package/src/sync-extension.ts +17 -9
- package/src/ui/cancellable-operation.ts +13 -2
- package/src/ui/manager-state.ts +1 -0
- package/src/ui/manager-ui.ts +25 -4
- package/dist/chunks/chunk-AYGMIMCV.ts.map +0 -7
- package/dist/chunks/chunk-JQ5BAWW2.ts.map +0 -7
- package/dist/chunks/command-handler-SQC2L2FJ.ts.map +0 -7
- package/dist/chunks/manager-ui-DWOMAJKE.ts.map +0 -7
- /package/dist/chunks/{chunk-BESRBKVO.ts.map → chunk-2MSJDLSM.ts.map} +0 -0
- /package/dist/chunks/{chunk-BYVHABNR.ts.map → chunk-2MUAR5GH.ts.map} +0 -0
- /package/dist/chunks/{chunk-DAZZ5BEJ.ts.map → chunk-3NS4PMCI.ts.map} +0 -0
- /package/dist/chunks/{chunk-FI2F5JBS.ts.map → chunk-3Q3DMMID.ts.map} +0 -0
- /package/dist/chunks/{chunk-SZJOUVCL.ts.map → chunk-DGVZYS7T.ts.map} +0 -0
- /package/dist/chunks/{chunk-WJQ4TGN5.ts.map → chunk-ECUCXF5Y.ts.map} +0 -0
- /package/dist/chunks/{chunk-ASU3GZPW.ts.map → chunk-GRXNUC6O.ts.map} +0 -0
- /package/dist/chunks/{chunk-Z5JMOXJM.ts.map → chunk-I72HGZJJ.ts.map} +0 -0
- /package/dist/chunks/{chunk-5YOLQKNZ.ts.map → chunk-UF2HU2NM.ts.map} +0 -0
- /package/dist/chunks/{ignore-file-ui-OHFISFVC.ts.map → config-P54GGMXY.ts.map} +0 -0
- /package/dist/chunks/{conflict-review-J7L7S4AR.ts.map → conflict-review-OBBBSVQD.ts.map} +0 -0
- /package/dist/chunks/{file-selection-XWACUTAH.ts.map → file-selection-GASCVN45.ts.map} +0 -0
- /package/dist/chunks/{manager-result-dispatcher-WXE2BAQO.ts.map → ignore-file-ui-5BWA6LBC.ts.map} +0 -0
- /package/dist/chunks/{merge-review-AAC674C6.ts.map → manager-result-dispatcher-MJ6G2CEI.ts.map} +0 -0
- /package/dist/chunks/{remote-selection-ui-E4XZCQ7A.ts.map → merge-review-C2KETZKY.ts.map} +0 -0
- /package/dist/chunks/{setup-switch-644T6KHG.ts.map → remote-selection-ui-34WC7OFE.ts.map} +0 -0
- /package/dist/chunks/{setup-wizard-IEW56AZE.ts.map → setup-wizard-YOXLXLBY.ts.map} +0 -0
- /package/dist/chunks/{sync-inspection-NBBTSMKR.ts.map → sync-inspection-NIITROKS.ts.map} +0 -0
- /package/dist/chunks/{sync-operations-AIEM2KL2.ts.map → sync-operations-FFI4ZZQL.ts.map} +0 -0
|
@@ -5,30 +5,30 @@ import {
|
|
|
5
5
|
showGitSetup,
|
|
6
6
|
showS3Setup,
|
|
7
7
|
showWebDavSetup
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-GRXNUC6O.ts";
|
|
9
9
|
import "./chunk-ECYCNZOE.ts";
|
|
10
|
-
import "./chunk-
|
|
10
|
+
import "./chunk-I72HGZJJ.ts";
|
|
11
11
|
import "./chunk-KNEUL4XN.ts";
|
|
12
12
|
import {
|
|
13
13
|
validateConfigName
|
|
14
14
|
} from "./chunk-APZVJAEW.ts";
|
|
15
15
|
import "./chunk-WBIOSK76.ts";
|
|
16
|
+
import "./chunk-C3E75DXW.ts";
|
|
16
17
|
import {
|
|
17
18
|
throwIfAborted
|
|
18
19
|
} from "./chunk-UMPA5S7X.ts";
|
|
20
|
+
import "./chunk-H7VOTY5N.ts";
|
|
19
21
|
import "./chunk-XUZV4OGI.ts";
|
|
20
|
-
import "./chunk-
|
|
22
|
+
import "./chunk-PUSMSKIM.ts";
|
|
23
|
+
import {
|
|
24
|
+
errorMessage
|
|
25
|
+
} from "./chunk-6YKOHBSC.ts";
|
|
21
26
|
import "./chunk-JREGWM2B.ts";
|
|
22
27
|
import {
|
|
23
28
|
localConfigPath
|
|
24
29
|
} from "./chunk-IBXEM35O.ts";
|
|
25
30
|
import "./chunk-NXWHPVXR.ts";
|
|
26
31
|
import "./chunk-GELYN4UC.ts";
|
|
27
|
-
import "./chunk-JQ5BAWW2.ts";
|
|
28
|
-
import "./chunk-H7VOTY5N.ts";
|
|
29
|
-
import {
|
|
30
|
-
errorMessage
|
|
31
|
-
} from "./chunk-6YKOHBSC.ts";
|
|
32
32
|
import "./chunk-R3SAMXB6.ts";
|
|
33
33
|
import {
|
|
34
34
|
safeTerminalText
|
|
@@ -95,4 +95,4 @@ async function showSetupWizard(ctx, signal) {
|
|
|
95
95
|
export {
|
|
96
96
|
showSetupWizard
|
|
97
97
|
};
|
|
98
|
-
//# sourceMappingURL=setup-wizard-
|
|
98
|
+
//# sourceMappingURL=setup-wizard-YOXLXLBY.ts.map
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
// @generated by scripts/build-runtime.mjs; do not edit.
|
|
2
2
|
// @ts-nocheck -- generated JavaScript uses a .ts extension for Pi's Jiti loader.
|
|
3
|
-
import {
|
|
4
|
-
syncCheckConfigFingerprint
|
|
5
|
-
} from "./chunk-DAZZ5BEJ.ts";
|
|
6
3
|
import {
|
|
7
4
|
currentPiDaemonClient
|
|
8
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-C3E75DXW.ts";
|
|
9
6
|
import "./chunk-H7VOTY5N.ts";
|
|
10
7
|
import "./chunk-6YKOHBSC.ts";
|
|
11
8
|
import "./chunk-R3SAMXB6.ts";
|
|
9
|
+
import {
|
|
10
|
+
syncCheckConfigFingerprint
|
|
11
|
+
} from "./chunk-3NS4PMCI.ts";
|
|
12
12
|
import "./chunk-2JNFEZ3V.ts";
|
|
13
13
|
|
|
14
14
|
// src/sync/sync-inspection.ts
|
|
@@ -20,4 +20,4 @@ var inspectSync = async (config, _options, signal) => await currentPiDaemonClien
|
|
|
20
20
|
export {
|
|
21
21
|
inspectSync
|
|
22
22
|
};
|
|
23
|
-
//# sourceMappingURL=sync-inspection-
|
|
23
|
+
//# sourceMappingURL=sync-inspection-NIITROKS.ts.map
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// @ts-nocheck -- generated JavaScript uses a .ts extension for Pi's Jiti loader.
|
|
3
3
|
import {
|
|
4
4
|
remoteOperation
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-C3E75DXW.ts";
|
|
6
6
|
import "./chunk-H7VOTY5N.ts";
|
|
7
7
|
import "./chunk-6YKOHBSC.ts";
|
|
8
8
|
import "./chunk-R3SAMXB6.ts";
|
|
@@ -46,4 +46,4 @@ export {
|
|
|
46
46
|
status,
|
|
47
47
|
syncBoth
|
|
48
48
|
};
|
|
49
|
-
//# sourceMappingURL=sync-operations-
|
|
49
|
+
//# sourceMappingURL=sync-operations-FFI4ZZQL.ts.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createHash, randomUUID } from "node:crypto";
|
|
2
2
|
import { setTimeout as delay } from "node:timers/promises";
|
|
3
3
|
import { DaemonError, requestDaemon } from "./client-transport.js";
|
|
4
|
-
import { stopDaemonAfterForegroundQueueFailure } from "./daemon-recovery.js";
|
|
4
|
+
import { ForegroundStopRefusedError, stopDaemonAfterForegroundQueueFailure } from "./daemon-recovery.js";
|
|
5
5
|
import { isForegroundDirection, isForegroundQueueOutcome } from "./foreground-queue-outcome.js";
|
|
6
6
|
import { canonicalRootGuard, readProcessBirth } from "./identity.js";
|
|
7
7
|
import { withCleanup } from "./lifecycle.js";
|
|
@@ -270,7 +270,13 @@ export class DaemonConnection {
|
|
|
270
270
|
if (!foreground)
|
|
271
271
|
signal?.throwIfAborted();
|
|
272
272
|
if (assertRoot && isForegroundQueueOutcome(job.result))
|
|
273
|
-
this.foregroundRecovery = {
|
|
273
|
+
this.foregroundRecovery = {
|
|
274
|
+
job: id,
|
|
275
|
+
generation,
|
|
276
|
+
birth,
|
|
277
|
+
assertRoot,
|
|
278
|
+
retryOnRefusal: job.result.foregroundQueueCleanup === "resume-adoption",
|
|
279
|
+
};
|
|
274
280
|
return job.result;
|
|
275
281
|
};
|
|
276
282
|
if (onCommit)
|
|
@@ -367,29 +373,37 @@ export class DaemonConnection {
|
|
|
367
373
|
this.pendingJobs.delete(id);
|
|
368
374
|
});
|
|
369
375
|
}
|
|
376
|
+
canRecoverForeground(job) {
|
|
377
|
+
const target = this.foregroundRecovery;
|
|
378
|
+
return (!!target &&
|
|
379
|
+
target.job === job &&
|
|
380
|
+
target.generation === this.facts.generation &&
|
|
381
|
+
!target.attempted &&
|
|
382
|
+
this.attached &&
|
|
383
|
+
!this.closed &&
|
|
384
|
+
!this.admitting &&
|
|
385
|
+
!this.disposing &&
|
|
386
|
+
!this.pausing &&
|
|
387
|
+
this.pendingJobs.size === 0 &&
|
|
388
|
+
!this.uncertain &&
|
|
389
|
+
this.contactResumeState === "idle");
|
|
390
|
+
}
|
|
370
391
|
async recoverForeground(job, signal) {
|
|
371
392
|
signal.throwIfAborted();
|
|
372
393
|
const target = this.foregroundRecovery;
|
|
373
|
-
if (!target ||
|
|
374
|
-
target.job !== job ||
|
|
375
|
-
target.generation !== this.facts.generation ||
|
|
376
|
-
target.attempted ||
|
|
377
|
-
!this.attached ||
|
|
378
|
-
this.closed ||
|
|
379
|
-
this.admitting ||
|
|
380
|
-
this.disposing ||
|
|
381
|
-
this.pausing ||
|
|
382
|
-
this.pendingJobs.size ||
|
|
383
|
-
this.uncertain ||
|
|
384
|
-
this.contactResumeState !== "idle")
|
|
394
|
+
if (!target || !this.canRecoverForeground(job))
|
|
385
395
|
throw new Error("The current Pi session could not verify a completed transfer for daemon recovery.");
|
|
386
396
|
target.assertRoot();
|
|
387
397
|
target.attempted = true;
|
|
388
398
|
const owned = AbortSignal.any([signal, this.controller.signal, AbortSignal.timeout(FOREGROUND_RECOVERY_MS)]);
|
|
389
|
-
|
|
390
|
-
...target,
|
|
391
|
-
|
|
392
|
-
|
|
399
|
+
try {
|
|
400
|
+
await stopDaemonAfterForegroundQueueFailure(this.paths, this.identity, { ...target, client: this.facts.id }, owned);
|
|
401
|
+
}
|
|
402
|
+
catch (error) {
|
|
403
|
+
if (target.retryOnRefusal && error instanceof ForegroundStopRefusedError)
|
|
404
|
+
delete target.attempted;
|
|
405
|
+
throw error;
|
|
406
|
+
}
|
|
393
407
|
await this.closeLocal();
|
|
394
408
|
target.assertRoot();
|
|
395
409
|
}
|
|
@@ -3,6 +3,8 @@ import { acquireStartupLock, checkUpgradeConsent, finishUpgrade } from "./daemon
|
|
|
3
3
|
import { canonicalRootGuard, clearUpgradeOwner, processExists, processExited, readIdentity, readProcessBirth, readUpgradeOwner, recordUpgradeOwner, runtimePaths, upgradeRepairStarted, } from "./identity.js";
|
|
4
4
|
import { withCleanup } from "./lifecycle.js";
|
|
5
5
|
import { record } from "./protocol.js";
|
|
6
|
+
export class ForegroundStopRefusedError extends Error {
|
|
7
|
+
}
|
|
6
8
|
export async function stopDaemonAfterForegroundQueueFailure(paths, identity, { job, client, generation, birth }, signal) {
|
|
7
9
|
const assertRoot = canonicalRootGuard(paths.root);
|
|
8
10
|
if (process.platform === "linux" && birth === undefined)
|
|
@@ -44,10 +46,10 @@ export async function stopDaemonAfterForegroundQueueFailure(paths, identity, { j
|
|
|
44
46
|
return;
|
|
45
47
|
throw error;
|
|
46
48
|
}
|
|
49
|
+
if (record(checked) && typeof checked.blocked === "string" && checked.eligible !== true)
|
|
50
|
+
throw new ForegroundStopRefusedError(checked.blocked);
|
|
47
51
|
if (!record(checked) || checked.eligible !== true)
|
|
48
|
-
throw new Error(
|
|
49
|
-
? checked.blocked
|
|
50
|
-
: "Daemon queue cleanup could not be verified.");
|
|
52
|
+
throw new Error("Daemon queue cleanup could not be verified.");
|
|
51
53
|
if (!(await requireCurrent()))
|
|
52
54
|
return;
|
|
53
55
|
signal.throwIfAborted();
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { closeSync, constants, fstatSync, lstatSync, openSync, realpathSync, writeSync, } from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
|
+
import { isForegroundDirection, isForegroundQueueOutcome } from "../foreground-queue-outcome.js";
|
|
3
4
|
import { DEBUG_LOG_FILENAME } from "./paths.js";
|
|
4
5
|
import { isStartupTimingReport } from "./sync/startup-timings.js";
|
|
5
6
|
const OPERATIONS = [
|
|
@@ -11,6 +12,8 @@ const OPERATIONS = [
|
|
|
11
12
|
"history",
|
|
12
13
|
"push",
|
|
13
14
|
"pull",
|
|
15
|
+
"push.foreground",
|
|
16
|
+
"pull.foreground",
|
|
14
17
|
"sync",
|
|
15
18
|
"startup-transfer",
|
|
16
19
|
"shutdown",
|
|
@@ -39,6 +42,22 @@ const CYCLE_REASONS = [
|
|
|
39
42
|
export function debugOperation(operation) {
|
|
40
43
|
return OPERATIONS.find((known) => known === operation);
|
|
41
44
|
}
|
|
45
|
+
export function debugJobResult(operation, result) {
|
|
46
|
+
if (!isForegroundDirection(operation))
|
|
47
|
+
return result === "cancelled" ? "cancelled" : undefined;
|
|
48
|
+
if (isForegroundQueueOutcome(result)) {
|
|
49
|
+
if (result.foregroundQueueCleanup !== "verified-result")
|
|
50
|
+
return "blocked";
|
|
51
|
+
result = result.result;
|
|
52
|
+
}
|
|
53
|
+
if (result && typeof result === "object" && "outcome" in result) {
|
|
54
|
+
if (result.outcome === "applied")
|
|
55
|
+
return "completed";
|
|
56
|
+
if (result.outcome === "cancelled")
|
|
57
|
+
return "cancelled";
|
|
58
|
+
}
|
|
59
|
+
return "failed";
|
|
60
|
+
}
|
|
42
61
|
function safeFields(event) {
|
|
43
62
|
switch (event.event) {
|
|
44
63
|
case "startup-timings":
|
|
@@ -113,24 +113,27 @@ export async function verifyAdoptionBackup(journal, signal) {
|
|
|
113
113
|
await handle.close();
|
|
114
114
|
}
|
|
115
115
|
}
|
|
116
|
+
export function adoptionJournalFingerprint(journal) {
|
|
117
|
+
return createHash("sha256").update(JSON.stringify(journal)).digest("hex");
|
|
118
|
+
}
|
|
116
119
|
export async function createAdoptionJournal(journal) {
|
|
117
120
|
requireNoPendingAdoption();
|
|
118
121
|
const target = journalPath();
|
|
119
122
|
await writeJson(target, journal, { maxBytes: MAX_BYTES });
|
|
120
123
|
await syncDirectory(path.dirname(path.dirname(target)));
|
|
121
124
|
}
|
|
122
|
-
async function
|
|
125
|
+
export async function assertCurrentAdoptionJournal(journal) {
|
|
123
126
|
if (JSON.stringify(await loadAdoptionJournal()) !== JSON.stringify(journal))
|
|
124
127
|
throw new Error(recoveryMessage);
|
|
125
128
|
}
|
|
126
129
|
export async function recordInstalledIdentity(journal, identity) {
|
|
127
|
-
await
|
|
130
|
+
await assertCurrentAdoptionJournal(journal);
|
|
128
131
|
const next = { ...journal, installedIdentity: identity };
|
|
129
132
|
await writeJson(journalPath(), next, { maxBytes: MAX_BYTES });
|
|
130
133
|
return next;
|
|
131
134
|
}
|
|
132
135
|
export async function completeAdoptionJournal(journal) {
|
|
133
|
-
await
|
|
136
|
+
await assertCurrentAdoptionJournal(journal);
|
|
134
137
|
const target = journalPath();
|
|
135
138
|
const backups = path.join(path.dirname(target), "backups");
|
|
136
139
|
if (!(await fs.lstat(backups)).isDirectory())
|
|
@@ -3,7 +3,7 @@ import { lstatSync, renameSync, statSync } from "node:fs";
|
|
|
3
3
|
import fs from "node:fs/promises";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import { getEngineRoot, withEngineMutationQueue } from "../host.js";
|
|
6
|
-
import { completeAdoptionJournal, createAdoptionJournal, recordInstalledIdentity, verifyAdoptionBackup, } from "../ignore/adoption-journal.js";
|
|
6
|
+
import { adoptionJournalFingerprint, assertCurrentAdoptionJournal, completeAdoptionJournal, createAdoptionJournal, recordInstalledIdentity, verifyAdoptionBackup, } from "../ignore/adoption-journal.js";
|
|
7
7
|
import { DEFAULT_IGNORE_FILENAME, ignoreFileIdentity, ignorePolicyFingerprint, ignoreSourceDigest, readIgnoreSource, sameFile, } from "../ignore/ignore-source.js";
|
|
8
8
|
import { validateSnapshotIgnoreRules } from "../ignore/snapshot-ignore-rules.js";
|
|
9
9
|
import { loadConfigForCheck, syncConfigReviewFingerprint, syncSettingsConfigFingerprint } from "../settings/config.js";
|
|
@@ -207,8 +207,10 @@ export async function adoptRemoteRules(input) {
|
|
|
207
207
|
!sameLocalFields(latest.localFields, remote.localFields) ||
|
|
208
208
|
rawSnapshotHashIdentity(latest) !== remoteFilesIdentity)
|
|
209
209
|
throw new Error("The reviewed remote snapshot changed; reopen Pull.");
|
|
210
|
-
if (current)
|
|
210
|
+
if (current) {
|
|
211
211
|
await verifyAdoptionBackup(current, signal);
|
|
212
|
+
await assertCurrentAdoptionJournal(current);
|
|
213
|
+
}
|
|
212
214
|
await validateContext();
|
|
213
215
|
const refresh = async () => {
|
|
214
216
|
const next = await createSnapshot(config.snapshotIdentity, projected);
|
|
@@ -283,15 +285,19 @@ export async function adoptRemoteRules(input) {
|
|
|
283
285
|
!sameHashes(appliedFileHashMap(physical, before, protectedPaths), journal.afterFiles))
|
|
284
286
|
throw new Error("Local files changed after the reviewed Pull. Preserve its journal.");
|
|
285
287
|
markCommit();
|
|
288
|
+
if (!journal.installedIdentity)
|
|
289
|
+
options.directionalAction?.setAdoptionResume?.(adoptionJournalFingerprint(journal));
|
|
286
290
|
await applySnapshot(physical, protectedPaths, {
|
|
287
291
|
...projected,
|
|
288
292
|
reviewedLocal: before,
|
|
289
293
|
validateApplyReview: async () => {
|
|
290
294
|
await validateContext();
|
|
295
|
+
await assertCurrentAdoptionJournal(journal);
|
|
291
296
|
if (syncStateFingerprint(await readStateForConfig(config)) !== journal.stateFingerprint)
|
|
292
297
|
throw new Error("Baseline changed at Pull's commit boundary.");
|
|
293
298
|
},
|
|
294
299
|
});
|
|
300
|
+
options.directionalAction?.setAdoptionResume?.(undefined);
|
|
295
301
|
}
|
|
296
302
|
await validateContext();
|
|
297
303
|
if (!sameHashes(fileHashMap(await refresh()), journal.afterFiles))
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createSyncBackend } from "../backends/backend-factory.js";
|
|
2
2
|
import { expectedRemoteHead, SyncBackendConflictError, } from "../backends/sync-backend.js";
|
|
3
|
-
import { loadAdoptionJournal, requireNoPendingAdoption } from "../ignore/adoption-journal.js";
|
|
3
|
+
import { adoptionJournalFingerprint, loadAdoptionJournal, requireNoPendingAdoption, } from "../ignore/adoption-journal.js";
|
|
4
4
|
import { loadConfig, loadConfigForCheck, syncCheckConfigFingerprint } from "../settings/config.js";
|
|
5
5
|
import { effectiveSessionRoot, requireStableMergeSessionRoot, resolvedSnapshotOptionsForContext, sessionDirForApply, } from "../snapshot/session-paths.js";
|
|
6
6
|
import { createSnapshot, filterSnapshotForConfigPolicy, scanSnapshot, snapshotIncludesSessions, } from "../snapshot/snapshot.js";
|
|
@@ -304,6 +304,9 @@ export async function pull(ctx, options, factory = createSyncBackend, initial) {
|
|
|
304
304
|
throw new Error("Single-action Pull cannot be used for initial-source selection.");
|
|
305
305
|
const adoptionReview = !initial && canReviewAdoption(ctx, options);
|
|
306
306
|
const journal = adoptionReview ? await loadAdoptionJournal() : undefined;
|
|
307
|
+
if (action?.expectedAdoptionJournal !== undefined &&
|
|
308
|
+
(!journal || adoptionJournalFingerprint(journal) !== action.expectedAdoptionJournal))
|
|
309
|
+
throw new Error("The recorded Pull changed during recovery. No transfer was started.");
|
|
307
310
|
if (!adoptionReview)
|
|
308
311
|
requireNoPendingAdoption();
|
|
309
312
|
const validateOwner = captureMutationOwner(ctx, options.signal);
|
|
@@ -433,17 +433,22 @@ async function runForegroundDirectional(host, execution, ctx, direction, payload
|
|
|
433
433
|
!ctx.hasUI ||
|
|
434
434
|
!["tui", "rpc"].includes(ctx.mode) ||
|
|
435
435
|
!record(payload) ||
|
|
436
|
-
Object.keys(payload).some((key) => !["setup", "fingerprint", "retryCheckpoint"].includes(key)) ||
|
|
436
|
+
Object.keys(payload).some((key) => !["setup", "fingerprint", "retryCheckpoint", "retryAdoptionJournal"].includes(key)) ||
|
|
437
437
|
typeof payload.setup !== "string" ||
|
|
438
438
|
!payload.setup ||
|
|
439
439
|
payload.setup.length > 512 ||
|
|
440
440
|
typeof payload.fingerprint !== "string" ||
|
|
441
441
|
!fingerprintPattern.test(payload.fingerprint) ||
|
|
442
442
|
(payload.retryCheckpoint !== undefined &&
|
|
443
|
-
(typeof payload.retryCheckpoint !== "string" || !fingerprintPattern.test(payload.retryCheckpoint)))
|
|
443
|
+
(typeof payload.retryCheckpoint !== "string" || !fingerprintPattern.test(payload.retryCheckpoint))) ||
|
|
444
|
+
(payload.retryAdoptionJournal !== undefined &&
|
|
445
|
+
(direction !== "pull" ||
|
|
446
|
+
payload.retryCheckpoint !== undefined ||
|
|
447
|
+
typeof payload.retryAdoptionJournal !== "string" ||
|
|
448
|
+
!fingerprintPattern.test(payload.retryAdoptionJournal)))) {
|
|
444
449
|
throw new Error("Invalid foreground directional request.");
|
|
445
450
|
}
|
|
446
|
-
const { setup, fingerprint, retryCheckpoint } = payload;
|
|
451
|
+
const { setup, fingerprint, retryCheckpoint, retryAdoptionJournal } = payload;
|
|
447
452
|
const { withStateDirectoryAccess } = await import("./engine/state/state-directory.js");
|
|
448
453
|
const { withLock } = await import("./engine/state/lock.js");
|
|
449
454
|
const { loadConfigForCheck, syncCheckConfigFingerprint } = await import("./engine/settings/config.js");
|
|
@@ -456,7 +461,7 @@ async function runForegroundDirectional(host, execution, ctx, direction, payload
|
|
|
456
461
|
execution.validate();
|
|
457
462
|
return withStateDirectoryAccess(async () => {
|
|
458
463
|
validate(await loadConfigForCheck(undefined, execution.signal));
|
|
459
|
-
if (retryCheckpoint === undefined) {
|
|
464
|
+
if (retryCheckpoint === undefined && retryAdoptionJournal === undefined) {
|
|
460
465
|
await requireHandover(execution);
|
|
461
466
|
validate(await loadConfigForCheck(undefined, execution.signal));
|
|
462
467
|
await initialize(ctx, execution, false);
|
|
@@ -466,18 +471,29 @@ async function runForegroundDirectional(host, execution, ctx, direction, payload
|
|
|
466
471
|
throw new Error("Daemon handover is no longer valid; the transfer was not replayed.");
|
|
467
472
|
await requireStartupRecoveryCleared(execution);
|
|
468
473
|
}
|
|
469
|
-
return host.runForeground(execution, () => withLock(direction, async () => {
|
|
474
|
+
return host.runForeground(execution, (setAdoptionResume) => withLock(direction, async () => {
|
|
470
475
|
validate(await loadConfigForCheck(undefined, execution.signal));
|
|
471
476
|
let message;
|
|
477
|
+
let adoptionRecovery = false;
|
|
472
478
|
const outcome = await operations[direction](ctx, {
|
|
473
479
|
...optionsFrom({ setup, args: [] }, execution, false),
|
|
474
480
|
directionalAction: {
|
|
475
481
|
validate,
|
|
482
|
+
expectedAdoptionJournal: retryAdoptionJournal,
|
|
483
|
+
setAdoptionResume(journal) {
|
|
484
|
+
if (adoptionRecovery)
|
|
485
|
+
setAdoptionResume(journal);
|
|
486
|
+
},
|
|
476
487
|
async checkpoint(current) {
|
|
477
488
|
execution.validate();
|
|
478
489
|
if (retryCheckpoint !== undefined && retryCheckpoint !== current)
|
|
479
490
|
throw new Error("The transfer source or destination changed during recovery. The transfer was not replayed.");
|
|
480
|
-
|
|
491
|
+
const accepted = await execution.request("directional-checkpoint", {
|
|
492
|
+
fingerprint: current,
|
|
493
|
+
...(direction === "pull" ? { adoptionRecovery: 1 } : {}),
|
|
494
|
+
});
|
|
495
|
+
adoptionRecovery = direction === "pull" && record(accepted) && accepted.adoptionRecovery === 1;
|
|
496
|
+
if (accepted !== true && !adoptionRecovery)
|
|
481
497
|
throw new Error("The original transfer could not be retained for recovery. No transfer was started.");
|
|
482
498
|
execution.validate();
|
|
483
499
|
},
|
|
@@ -5,5 +5,9 @@ export function isForegroundQueueOutcome(value) {
|
|
|
5
5
|
if (!value || typeof value !== "object" || !("foregroundQueueCleanup" in value))
|
|
6
6
|
return false;
|
|
7
7
|
return (value.foregroundQueueCleanup === "before-mutation" ||
|
|
8
|
+
(value.foregroundQueueCleanup === "resume-adoption" &&
|
|
9
|
+
"journal" in value &&
|
|
10
|
+
typeof value.journal === "string" &&
|
|
11
|
+
/^[a-f0-9]{64}$/u.test(value.journal)) ||
|
|
8
12
|
(value.foregroundQueueCleanup === "verified-result" && Object.hasOwn(value, "result")));
|
|
9
13
|
}
|
|
@@ -7,7 +7,7 @@ import lockfile from "proper-lockfile";
|
|
|
7
7
|
import { DAEMON_BUILD_VERSION } from "./build-version.js";
|
|
8
8
|
import { ConsentPublicationError, readConsent } from "./consent.js";
|
|
9
9
|
import { endpointOwner } from "./endpoint.js";
|
|
10
|
-
import { debugOperation } from "./engine/debug-log.js";
|
|
10
|
+
import { debugJobResult, debugOperation } from "./engine/debug-log.js";
|
|
11
11
|
import { SyncDecisionRequiredError } from "./engine/sync/sync-errors.js";
|
|
12
12
|
import { isForegroundDirection, isForegroundQueueOutcome } from "./foreground-queue-outcome.js";
|
|
13
13
|
import { canonicalRootGuard, daemonPaths, matchesPublishedIdentity, privateDirectory, processExists, publishIdentity, readIdentity, readJsonBody, readUpgradeOwner, runtimePaths, } from "./identity.js";
|
|
@@ -402,7 +402,8 @@ export async function startServer(root, execute, hooks = {}) {
|
|
|
402
402
|
if (Buffer.byteLength(JSON.stringify(result ?? null)) > MAX_MESSAGE_BYTES / 2)
|
|
403
403
|
throw new Error("Operation result exceeds its byte limit; use bounded inspection.");
|
|
404
404
|
if (isForegroundDirection(operation) && isForegroundQueueOutcome(result)) {
|
|
405
|
-
if (result.foregroundQueueCleanup === "before-mutation" && job.committed)
|
|
405
|
+
if ((result.foregroundQueueCleanup === "before-mutation" && job.committed) ||
|
|
406
|
+
(result.foregroundQueueCleanup === "resume-adoption" && (!job.committed || operation !== "pull.foreground")))
|
|
406
407
|
throw Object.assign(new Error("File-queue release and transfer outcome could not be verified."), {
|
|
407
408
|
code: OWNERSHIP_CLEANUP_REQUIRED,
|
|
408
409
|
});
|
|
@@ -410,7 +411,7 @@ export async function startServer(root, execute, hooks = {}) {
|
|
|
410
411
|
}
|
|
411
412
|
job.view.result = result;
|
|
412
413
|
job.view.phase = "done";
|
|
413
|
-
note(result
|
|
414
|
+
note(debugJobResult(operation, result) ?? job.debugOutcome ?? "completed");
|
|
414
415
|
})
|
|
415
416
|
.catch((error) => {
|
|
416
417
|
if (error instanceof ConsentPublicationError)
|
|
@@ -155,9 +155,12 @@ export function installServiceHost(root, ignoreFileOperationsAvailable) {
|
|
|
155
155
|
if (owner.execution !== execution || !execution.clientId || owner.held.size || owner.foreground)
|
|
156
156
|
throw new Error("Foreground queue recovery requires one attached directional job.");
|
|
157
157
|
const foreground = { entered: false, deferred: false };
|
|
158
|
+
let adoptionResume;
|
|
158
159
|
return scope.run({ ...owner, foreground }, async () => {
|
|
159
160
|
try {
|
|
160
|
-
const result = await action()
|
|
161
|
+
const result = await action((journal) => {
|
|
162
|
+
adoptionResume = journal;
|
|
163
|
+
});
|
|
161
164
|
if (foreground.deferred && poisoned === "queue")
|
|
162
165
|
return { foregroundQueueCleanup: "verified-result", result };
|
|
163
166
|
return result;
|
|
@@ -167,7 +170,9 @@ export function installServiceHost(root, ignoreFileOperationsAvailable) {
|
|
|
167
170
|
!execution.signal.aborted &&
|
|
168
171
|
error instanceof AggregateError &&
|
|
169
172
|
error.errors.includes(foreground.beforeMutation))
|
|
170
|
-
return
|
|
173
|
+
return adoptionResume === undefined
|
|
174
|
+
? { foregroundQueueCleanup: "before-mutation" }
|
|
175
|
+
: { foregroundQueueCleanup: "resume-adoption", journal: adoptionResume };
|
|
171
176
|
if (foreground.deferred && !(error instanceof OwnershipCleanupError)) {
|
|
172
177
|
const detail = error instanceof Error ? ` ${error.message}` : "";
|
|
173
178
|
throw new OwnershipCleanupError(`File-queue release was not confirmed.${detail}`, { cause: error });
|
package/dist/daemon/package.json
CHANGED
package/dist/index.ts
CHANGED
|
@@ -7,11 +7,22 @@ import {
|
|
|
7
7
|
createSyncAttentionController,
|
|
8
8
|
readStateForConfig,
|
|
9
9
|
syncStateFingerprint
|
|
10
|
-
} from "./chunks/chunk-
|
|
10
|
+
} from "./chunks/chunk-3Q3DMMID.ts";
|
|
11
|
+
import {
|
|
12
|
+
bindPiDaemonClient,
|
|
13
|
+
installPiDaemonHost,
|
|
14
|
+
piDaemonClient,
|
|
15
|
+
withPiDaemonClient
|
|
16
|
+
} from "./chunks/chunk-C3E75DXW.ts";
|
|
11
17
|
import {
|
|
12
18
|
combineSignals,
|
|
13
19
|
throwIfAborted
|
|
14
20
|
} from "./chunks/chunk-UMPA5S7X.ts";
|
|
21
|
+
import {
|
|
22
|
+
configureSyncStatus,
|
|
23
|
+
createSyncStatusPublisher,
|
|
24
|
+
setSyncStatus
|
|
25
|
+
} from "./chunks/chunk-H7VOTY5N.ts";
|
|
15
26
|
import {
|
|
16
27
|
completeSyncArguments,
|
|
17
28
|
setSyncSetupCompletions,
|
|
@@ -20,32 +31,21 @@ import {
|
|
|
20
31
|
import {
|
|
21
32
|
withStateDirectoryAccess
|
|
22
33
|
} from "./chunks/chunk-T3LABNHF.ts";
|
|
34
|
+
import {
|
|
35
|
+
errorMessage
|
|
36
|
+
} from "./chunks/chunk-6YKOHBSC.ts";
|
|
23
37
|
import {
|
|
24
38
|
snapshotOptionsForContext
|
|
25
39
|
} from "./chunks/chunk-P4GI7LTT.ts";
|
|
26
40
|
import "./chunks/chunk-ZO52JM4H.ts";
|
|
41
|
+
import {
|
|
42
|
+
syncSessionsSelected
|
|
43
|
+
} from "./chunks/chunk-R3SAMXB6.ts";
|
|
27
44
|
import {
|
|
28
45
|
configFromSettings,
|
|
29
46
|
loadConfigForCheck,
|
|
30
47
|
syncCheckConfigFingerprint
|
|
31
|
-
} from "./chunks/chunk-
|
|
32
|
-
import {
|
|
33
|
-
bindPiDaemonClient,
|
|
34
|
-
installPiDaemonHost,
|
|
35
|
-
piDaemonClient,
|
|
36
|
-
withPiDaemonClient
|
|
37
|
-
} from "./chunks/chunk-JQ5BAWW2.ts";
|
|
38
|
-
import {
|
|
39
|
-
configureSyncStatus,
|
|
40
|
-
createSyncStatusPublisher,
|
|
41
|
-
setSyncStatus
|
|
42
|
-
} from "./chunks/chunk-H7VOTY5N.ts";
|
|
43
|
-
import {
|
|
44
|
-
errorMessage
|
|
45
|
-
} from "./chunks/chunk-6YKOHBSC.ts";
|
|
46
|
-
import {
|
|
47
|
-
syncSessionsSelected
|
|
48
|
-
} from "./chunks/chunk-R3SAMXB6.ts";
|
|
48
|
+
} from "./chunks/chunk-3NS4PMCI.ts";
|
|
49
49
|
import {
|
|
50
50
|
safeTerminalText
|
|
51
51
|
} from "./chunks/chunk-2JNFEZ3V.ts";
|
|
@@ -334,12 +334,12 @@ function createStartupCheck(loaders, attention, timeoutMs = 3e4, publish) {
|
|
|
334
334
|
// src/sync/sync-loaders.ts
|
|
335
335
|
function createSyncLoaders(dependencies) {
|
|
336
336
|
const loaders = {
|
|
337
|
-
commands: cachedModuleLoader(dependencies.loadCommandHandler ?? (() => import("./chunks/command-handler-
|
|
338
|
-
inspection: cachedModuleLoader(dependencies.loadSyncInspection ?? (() => import("./chunks/sync-inspection-
|
|
339
|
-
setupSwitch: cachedModuleLoader(dependencies.loadSetupSwitch ?? (() => import("./chunks/setup-switch-
|
|
337
|
+
commands: cachedModuleLoader(dependencies.loadCommandHandler ?? (() => import("./chunks/command-handler-HWRPH3K3.ts"))),
|
|
338
|
+
inspection: cachedModuleLoader(dependencies.loadSyncInspection ?? (() => import("./chunks/sync-inspection-NIITROKS.ts"))),
|
|
339
|
+
setupSwitch: cachedModuleLoader(dependencies.loadSetupSwitch ?? (() => import("./chunks/setup-switch-JZDFQPVW.ts"))),
|
|
340
340
|
snapshot: cachedModuleLoader(dependencies.loadSnapshot ?? (() => import("./chunks/snapshot-ZUJJZCFW.ts"))),
|
|
341
341
|
syncState: cachedModuleLoader(dependencies.loadSyncState ?? (() => import("./chunks/sync-state-QIT64TKV.ts"))),
|
|
342
|
-
operations: cachedModuleLoader(dependencies.loadSyncOperations ?? (() => import("./chunks/sync-operations-
|
|
342
|
+
operations: cachedModuleLoader(dependencies.loadSyncOperations ?? (() => import("./chunks/sync-operations-FFI4ZZQL.ts")))
|
|
343
343
|
};
|
|
344
344
|
return loaders;
|
|
345
345
|
}
|
|
@@ -426,15 +426,24 @@ function sync(pi, dependencies = {}) {
|
|
|
426
426
|
}
|
|
427
427
|
const commands = await loaders.commands();
|
|
428
428
|
if (signal.aborted || owner !== client) return;
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
429
|
+
const recoveryMenu = !command && client.pendingPullReview;
|
|
430
|
+
if (recoveryMenu) await client.setBusy("command", true, false);
|
|
431
|
+
try {
|
|
432
|
+
if (signal.aborted || owner !== client) return;
|
|
433
|
+
await commands.handleCommand(
|
|
434
|
+
args,
|
|
435
|
+
ctx2,
|
|
436
|
+
commandSignal,
|
|
437
|
+
loaders,
|
|
438
|
+
attention,
|
|
439
|
+
void 0,
|
|
440
|
+
needsDaemonRecovery
|
|
441
|
+
);
|
|
442
|
+
} finally {
|
|
443
|
+
if (recoveryMenu && !signal.aborted && owner === client)
|
|
444
|
+
await client.setBusy("command", false, !needsDaemonRecovery()).catch(() => {
|
|
445
|
+
});
|
|
446
|
+
}
|
|
438
447
|
return;
|
|
439
448
|
}
|
|
440
449
|
const requiresContact = !["help", "unlock", "migrate-state"].includes(command ?? "");
|