@narumitw/pi-sync 0.68.0 → 0.69.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +21 -0
- package/README.md +35 -21
- package/dist/chunks/{chunk-AYGMIMCV.ts → chunk-4KGDPLQ4.ts} +2 -2
- package/dist/chunks/chunk-4KGDPLQ4.ts.map +7 -0
- package/dist/chunks/{chunk-FR6A7ASZ.ts → chunk-EG6BUOUQ.ts} +3 -3
- package/dist/chunks/{chunk-YV2R5SJU.ts → chunk-EI2J5Z4Q.ts} +17 -8
- package/dist/chunks/chunk-EI2J5Z4Q.ts.map +7 -0
- package/dist/chunks/{chunk-BCDBT4X3.ts → chunk-GXB74FYB.ts} +4 -4
- package/dist/chunks/{chunk-J52GYZO6.ts → chunk-LNZRNXNQ.ts} +2 -4
- package/dist/chunks/{chunk-FQKWGVMA.ts → chunk-OWSKD5XG.ts} +10 -7
- package/dist/chunks/chunk-OWSKD5XG.ts.map +7 -0
- package/dist/chunks/{chunk-WCGLU526.ts → chunk-RXZVLBPU.ts} +3 -3
- package/dist/chunks/{chunk-KAIVTJIQ.ts → chunk-RZB2DPVU.ts} +2 -2
- package/dist/chunks/{chunk-335XTMMZ.ts → chunk-VQTYTUBU.ts} +24 -26
- package/dist/chunks/chunk-VQTYTUBU.ts.map +7 -0
- package/dist/chunks/{chunk-TLYT6HVI.ts → chunk-YX6DCQ7P.ts} +2 -2
- package/dist/chunks/{command-handler-S6BRZMPW.ts → command-handler-ZR26OSBX.ts} +39 -143
- package/dist/chunks/command-handler-ZR26OSBX.ts.map +7 -0
- package/dist/chunks/{conflict-review-3XMYDJIK.ts → conflict-review-W5BCZIZG.ts} +2 -2
- package/dist/chunks/{file-selection-4BOQBXS7.ts → file-selection-STCIRKF6.ts} +3 -3
- package/dist/chunks/{manager-result-dispatcher-A4IWLS4J.ts → manager-result-dispatcher-MPLPDR2P.ts} +5 -5
- package/dist/chunks/{manager-ui-KHMCSLLV.ts → manager-ui-OMZOBGYT.ts} +99 -96
- package/dist/chunks/manager-ui-OMZOBGYT.ts.map +7 -0
- package/dist/chunks/{merge-review-LWMUE5IW.ts → merge-review-KTIQBRLL.ts} +2 -2
- package/dist/chunks/{remote-selection-ui-F6NJBQ3Y.ts → remote-selection-ui-CCHMCAHQ.ts} +4 -4
- package/dist/chunks/{setup-switch-7LMIRMZ7.ts → setup-switch-J3YLBB6N.ts} +4 -4
- package/dist/chunks/{setup-wizard-2NRPR433.ts → setup-wizard-J3YOR7BR.ts} +3 -4
- package/dist/chunks/{setup-wizard-2NRPR433.ts.map → setup-wizard-J3YOR7BR.ts.map} +1 -1
- package/dist/chunks/{sync-inspection-QGM54YCM.ts → sync-inspection-7OADBR57.ts} +3 -3
- package/dist/chunks/{sync-operations-DTQMKVRQ.ts → sync-operations-3K6WLPXY.ts} +2 -10
- package/dist/chunks/{sync-operations-DTQMKVRQ.ts.map → sync-operations-3K6WLPXY.ts.map} +2 -2
- package/dist/daemon/dist/build-id.json +1 -1
- package/dist/daemon/dist/engine/backends/git/git-backend.js +1 -1
- package/dist/daemon/dist/engine/backends/s3/s3-backend.js +2 -2
- package/dist/daemon/dist/engine/backends/webdav/webdav-backend.js +67 -6
- package/dist/daemon/dist/engine/debug-check.js +59 -0
- package/dist/daemon/dist/engine/debug-log.js +100 -1
- package/dist/daemon/dist/engine/sync/directional-conflict.js +31 -0
- package/dist/daemon/dist/engine/sync/push-review.js +1 -1
- package/dist/daemon/dist/engine/sync/sync-error-guidance.js +6 -5
- package/dist/daemon/dist/engine/sync/sync-inspection.js +5 -1
- package/dist/daemon/dist/engine/sync/sync-mutations.js +40 -7
- package/dist/daemon/dist/engine/sync/sync-queries.js +179 -82
- package/dist/daemon/dist/engine/sync/sync-state.js +1 -1
- package/dist/daemon/dist/engine/ui/sync-format.js +1 -1
- package/dist/daemon/dist/engine/ui/transfer-review.js +2 -3
- package/dist/daemon/dist/engine-service.js +100 -25
- package/dist/daemon/dist/foreground-transfer.js +10 -0
- package/dist/daemon/dist/index.js +1 -0
- package/dist/daemon/dist/server.js +2 -1
- package/dist/daemon/dist/service-host.js +1 -1
- package/dist/daemon/package.json +1 -1
- package/dist/index.ts +111 -10
- package/dist/index.ts.map +3 -3
- package/docs/daemon-migration.md +2 -2
- package/docs/tui-contract.md +7 -7
- package/package.json +7 -4
- package/skills/configure-pi-sync/SKILL.md +4 -7
- package/skills/configure-pi-sync/references/configuration.md +20 -19
- package/src/commands/command-execution.ts +36 -136
- package/src/commands/command-handler.ts +3 -3
- package/src/commands/command.ts +28 -26
- package/src/daemon/directional-recovery.ts +3 -1
- package/src/daemon/pi-client.ts +14 -2
- package/src/sync/debug-tool.ts +96 -0
- package/src/sync/startup-check.ts +1 -1
- package/src/sync/sync-operations.ts +0 -6
- package/src/sync-extension.ts +13 -1
- package/src/ui/cancellable-operation.ts +11 -4
- package/src/ui/manager-state.ts +13 -12
- package/src/ui/manager-ui.ts +96 -81
- package/src/ui/operation-dialogs.ts +1 -1
- package/src/ui/settings-ui.ts +2 -3
- package/src/ui/setup/webdav-ui.ts +1 -1
- package/dist/chunks/chunk-335XTMMZ.ts.map +0 -7
- package/dist/chunks/chunk-AYGMIMCV.ts.map +0 -7
- package/dist/chunks/chunk-ECYCNZOE.ts +0 -12
- package/dist/chunks/chunk-ECYCNZOE.ts.map +0 -7
- package/dist/chunks/chunk-FQKWGVMA.ts.map +0 -7
- package/dist/chunks/chunk-YV2R5SJU.ts.map +0 -7
- package/dist/chunks/command-handler-S6BRZMPW.ts.map +0 -7
- package/dist/chunks/manager-ui-KHMCSLLV.ts.map +0 -7
- /package/dist/chunks/{chunk-FR6A7ASZ.ts.map → chunk-EG6BUOUQ.ts.map} +0 -0
- /package/dist/chunks/{chunk-BCDBT4X3.ts.map → chunk-GXB74FYB.ts.map} +0 -0
- /package/dist/chunks/{chunk-J52GYZO6.ts.map → chunk-LNZRNXNQ.ts.map} +0 -0
- /package/dist/chunks/{chunk-WCGLU526.ts.map → chunk-RXZVLBPU.ts.map} +0 -0
- /package/dist/chunks/{chunk-KAIVTJIQ.ts.map → chunk-RZB2DPVU.ts.map} +0 -0
- /package/dist/chunks/{chunk-TLYT6HVI.ts.map → chunk-YX6DCQ7P.ts.map} +0 -0
- /package/dist/chunks/{conflict-review-3XMYDJIK.ts.map → conflict-review-W5BCZIZG.ts.map} +0 -0
- /package/dist/chunks/{file-selection-4BOQBXS7.ts.map → file-selection-STCIRKF6.ts.map} +0 -0
- /package/dist/chunks/{manager-result-dispatcher-A4IWLS4J.ts.map → manager-result-dispatcher-MPLPDR2P.ts.map} +0 -0
- /package/dist/chunks/{merge-review-LWMUE5IW.ts.map → merge-review-KTIQBRLL.ts.map} +0 -0
- /package/dist/chunks/{remote-selection-ui-F6NJBQ3Y.ts.map → remote-selection-ui-CCHMCAHQ.ts.map} +0 -0
- /package/dist/chunks/{setup-switch-7LMIRMZ7.ts.map → setup-switch-J3YLBB6N.ts.map} +0 -0
- /package/dist/chunks/{sync-inspection-QGM54YCM.ts.map → sync-inspection-7OADBR57.ts.map} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/sync/sync-operations.ts"],
|
|
4
|
-
"sourcesContent": ["import type { ExtensionContext } from \"@earendil-works/pi-coding-agent\";\nimport type { CommandOptions } from \"../commands/command-types.js\";\nimport { remoteOperation } from \"../daemon/pi-client.js\";\nimport type { SetupPullOutcome } from \"./setup-switch.js\";\n\nfunction transferResult(result: unknown): SetupPullOutcome | undefined {\n if (result === undefined || result === \"applied\" || result === \"cancelled\") return result;\n throw new Error(\"Invalid transfer result from pi-sync-daemon.\");\n}\nexport const push = async (ctx: ExtensionContext, options: CommandOptions) =>\n transferResult(await remoteOperation(ctx, \"push\", options));\nexport const pull = async (ctx: ExtensionContext, options: CommandOptions) =>\n transferResult(await remoteOperation(ctx, \"pull\", options));\nexport async function syncBoth(ctx: ExtensionContext, options: CommandOptions) {\n const result = await remoteOperation(ctx, options.auto ? \"startup-transfer\" : \"sync\", options);\n if (\n result === \"archived\" &&\n !options.auto &&\n !options.agentRetryRefusal &&\n !options.yes &&\n ctx.hasUI &&\n (ctx.mode === \"tui\" || ctx.mode === \"rpc\")\n )\n return result;\n return transferResult(result);\n}\nexport async function rollback(ctx: ExtensionContext, options: CommandOptions) {\n await remoteOperation(ctx, \"rollback\", options);\n}\nexport async function
|
|
5
|
-
"mappings": ";;;;;;;;;;;AAKA,SAAS,eAAe,QAA+C;AACrE,MAAI,WAAW,UAAa,WAAW,aAAa,WAAW,YAAa,QAAO;AACnF,QAAM,IAAI,MAAM,8CAA8C;AAChE;AACO,IAAM,OAAO,OAAO,KAAuB,YAChD,eAAe,MAAM,gBAAgB,KAAK,QAAQ,OAAO,CAAC;AACrD,IAAM,OAAO,OAAO,KAAuB,YAChD,eAAe,MAAM,gBAAgB,KAAK,QAAQ,OAAO,CAAC;AAC5D,eAAsB,SAAS,KAAuB,SAAyB;AAC7E,QAAM,SAAS,MAAM,gBAAgB,KAAK,QAAQ,OAAO,qBAAqB,QAAQ,OAAO;AAC7F,MACE,WAAW,cACX,CAAC,QAAQ,QACT,CAAC,QAAQ,qBACT,CAAC,QAAQ,OACT,IAAI,UACH,IAAI,SAAS,SAAS,IAAI,SAAS;AAEpC,WAAO;AACT,SAAO,eAAe,MAAM;AAC9B;AACA,eAAsB,SAAS,KAAuB,SAAyB;AAC7E,QAAM,gBAAgB,KAAK,YAAY,OAAO;AAChD;AACA,eAAsB,
|
|
4
|
+
"sourcesContent": ["import type { ExtensionContext } from \"@earendil-works/pi-coding-agent\";\nimport type { CommandOptions } from \"../commands/command-types.js\";\nimport { remoteOperation } from \"../daemon/pi-client.js\";\nimport type { SetupPullOutcome } from \"./setup-switch.js\";\n\nfunction transferResult(result: unknown): SetupPullOutcome | undefined {\n if (result === undefined || result === \"applied\" || result === \"cancelled\") return result;\n throw new Error(\"Invalid transfer result from pi-sync-daemon.\");\n}\nexport const push = async (ctx: ExtensionContext, options: CommandOptions) =>\n transferResult(await remoteOperation(ctx, \"push\", options));\nexport const pull = async (ctx: ExtensionContext, options: CommandOptions) =>\n transferResult(await remoteOperation(ctx, \"pull\", options));\nexport async function syncBoth(ctx: ExtensionContext, options: CommandOptions) {\n const result = await remoteOperation(ctx, options.auto ? \"startup-transfer\" : \"sync\", options);\n if (\n result === \"archived\" &&\n !options.auto &&\n !options.agentRetryRefusal &&\n !options.yes &&\n ctx.hasUI &&\n (ctx.mode === \"tui\" || ctx.mode === \"rpc\")\n )\n return result;\n return transferResult(result);\n}\nexport async function rollback(ctx: ExtensionContext, options: CommandOptions) {\n await remoteOperation(ctx, \"rollback\", options);\n}\nexport async function diff(ctx: ExtensionContext, options: CommandOptions) {\n await remoteOperation(ctx, \"diff\", options);\n}\nexport async function history(ctx: ExtensionContext, options: CommandOptions) {\n await remoteOperation(ctx, \"history\", options);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;AAKA,SAAS,eAAe,QAA+C;AACrE,MAAI,WAAW,UAAa,WAAW,aAAa,WAAW,YAAa,QAAO;AACnF,QAAM,IAAI,MAAM,8CAA8C;AAChE;AACO,IAAM,OAAO,OAAO,KAAuB,YAChD,eAAe,MAAM,gBAAgB,KAAK,QAAQ,OAAO,CAAC;AACrD,IAAM,OAAO,OAAO,KAAuB,YAChD,eAAe,MAAM,gBAAgB,KAAK,QAAQ,OAAO,CAAC;AAC5D,eAAsB,SAAS,KAAuB,SAAyB;AAC7E,QAAM,SAAS,MAAM,gBAAgB,KAAK,QAAQ,OAAO,qBAAqB,QAAQ,OAAO;AAC7F,MACE,WAAW,cACX,CAAC,QAAQ,QACT,CAAC,QAAQ,qBACT,CAAC,QAAQ,OACT,IAAI,UACH,IAAI,SAAS,SAAS,IAAI,SAAS;AAEpC,WAAO;AACT,SAAO,eAAe,MAAM;AAC9B;AACA,eAAsB,SAAS,KAAuB,SAAyB;AAC7E,QAAM,gBAAgB,KAAK,YAAY,OAAO;AAChD;AACA,eAAsB,KAAK,KAAuB,SAAyB;AACzE,QAAM,gBAAgB,KAAK,QAAQ,OAAO;AAC5C;AACA,eAAsB,QAAQ,KAAuB,SAAyB;AAC5E,QAAM,gBAAgB,KAAK,WAAW,OAAO;AAC/C;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"
|
|
1
|
+
"0ed048ebfe41646cc97f550817a6c72ba22e7df76d88ab990260d770a6a95552"
|
|
@@ -128,7 +128,7 @@ export class GitSyncBackend {
|
|
|
128
128
|
const files = prepareGitSnapshot(snapshot, this.config.destination.namespace);
|
|
129
129
|
const observed = await this.fetchRemoteHead(options.signal);
|
|
130
130
|
if (!matchesExpected(observed, expected, this.identity)) {
|
|
131
|
-
throw new SyncBackendConflictError("Git remote changed while preparing publication.
|
|
131
|
+
throw new SyncBackendConflictError("Git remote changed while preparing publication. Review changes with /sync diff before retrying.", { currentHead: observed ? await this.headForSha(observed, options.signal) : undefined });
|
|
132
132
|
}
|
|
133
133
|
throwIfAborted(options.signal);
|
|
134
134
|
const manifest = {
|
|
@@ -160,7 +160,7 @@ export class S3SyncBackend {
|
|
|
160
160
|
throw new SyncBackendPublicationOutcomeUnknownError(`Remote snapshot may be active, but publication verification was malformed: ${errorMessage(error)}`, { cause: error });
|
|
161
161
|
}
|
|
162
162
|
if (!samePointer(verifiedPointer, pointer)) {
|
|
163
|
-
throw new SyncBackendConflictError("Remote latest changed immediately after push.
|
|
163
|
+
throw new SyncBackendConflictError("Remote latest changed immediately after push. Review changes with /sync diff before continuing.", {
|
|
164
164
|
phase: "after-commit",
|
|
165
165
|
currentHead: remoteHead(verifiedPointer, this.identity, verifiedObject.etag),
|
|
166
166
|
candidateMayHaveBeenActive: true,
|
|
@@ -249,7 +249,7 @@ export class S3SyncBackend {
|
|
|
249
249
|
return undefined;
|
|
250
250
|
}
|
|
251
251
|
catch (error) {
|
|
252
|
-
return `Remote snapshot is active, but history could not be updated: ${errorMessage(error)}.
|
|
252
|
+
return `Remote snapshot is active, but history could not be updated: ${errorMessage(error)}. History may not list this publication. Use /sync diff to review the active snapshot before transferring again.`;
|
|
253
253
|
}
|
|
254
254
|
}
|
|
255
255
|
async updateHistory(client, pointer, keepRecent = false) {
|
|
@@ -141,7 +141,7 @@ export class WebDavSyncBackend {
|
|
|
141
141
|
throw new SyncBackendPublicationOutcomeUnknownError(`Remote snapshot may be active, but publication verification was malformed: ${errorMessage(error)}`, { cause: error });
|
|
142
142
|
}
|
|
143
143
|
if (!samePointer(pointer, verified)) {
|
|
144
|
-
throw new SyncBackendConflictError("Remote latest changed immediately after push.
|
|
144
|
+
throw new SyncBackendConflictError("Remote latest changed immediately after push. Open /sync → View differences before continuing.", {
|
|
145
145
|
phase: "after-commit",
|
|
146
146
|
currentHead: remoteHead(verified, this.identity, verifiedObject.etag),
|
|
147
147
|
candidateMayHaveBeenActive: true,
|
|
@@ -165,6 +165,57 @@ export class WebDavSyncBackend {
|
|
|
165
165
|
this.registerChecksum(pointer.snapshot, pointer.sha256);
|
|
166
166
|
return pointers.map(remoteHistoryEntry);
|
|
167
167
|
}
|
|
168
|
+
async repairActiveHistory(expected, options) {
|
|
169
|
+
const { signal, validateOwner, validateSettings, onCommit } = options;
|
|
170
|
+
const client = new WebDavClient(this.config, signal);
|
|
171
|
+
const validate = () => {
|
|
172
|
+
throwIfAborted(signal);
|
|
173
|
+
validateOwner();
|
|
174
|
+
};
|
|
175
|
+
const checkReviewedHead = async () => {
|
|
176
|
+
validate();
|
|
177
|
+
const object = await client.getJson(latestPath(this.config));
|
|
178
|
+
validate();
|
|
179
|
+
if (!object.missing) {
|
|
180
|
+
const pointer = requirePointer(object.value, this.config.destination.namespace);
|
|
181
|
+
if (remoteHead(pointer, this.identity, object.etag).revision === expected.revision)
|
|
182
|
+
return pointer;
|
|
183
|
+
}
|
|
184
|
+
throw new SyncBackendConflictError("The active WebDAV snapshot changed. Reopen History before repairing it.");
|
|
185
|
+
};
|
|
186
|
+
const validateWrite = async () => {
|
|
187
|
+
await checkReviewedHead();
|
|
188
|
+
validate();
|
|
189
|
+
await validateSettings();
|
|
190
|
+
};
|
|
191
|
+
const pointer = await checkReviewedHead();
|
|
192
|
+
validate();
|
|
193
|
+
const initial = await this.prepareHistoryUpdate(client, pointer);
|
|
194
|
+
await validateWrite();
|
|
195
|
+
validate();
|
|
196
|
+
if (!initial)
|
|
197
|
+
return false;
|
|
198
|
+
await this.runCapabilityProbe(signal, validate);
|
|
199
|
+
validate();
|
|
200
|
+
const update = await this.prepareHistoryUpdate(client, pointer);
|
|
201
|
+
await validateWrite();
|
|
202
|
+
validate();
|
|
203
|
+
if (!update)
|
|
204
|
+
return false;
|
|
205
|
+
const commitClient = new WebDavClient(this.config, AbortSignal.timeout(this.postCommitTimeoutMs), this.postCommitTimeoutMs);
|
|
206
|
+
onCommit?.();
|
|
207
|
+
try {
|
|
208
|
+
await commitClient.putJson(historyPath(this.config), update.history, update.condition);
|
|
209
|
+
}
|
|
210
|
+
catch (error) {
|
|
211
|
+
if (error instanceof WebDavPreconditionError)
|
|
212
|
+
throw new SyncBackendConflictError("Remote History changed during repair. Reopen History before retrying.", {
|
|
213
|
+
cause: error,
|
|
214
|
+
});
|
|
215
|
+
throw new SyncBackendPublicationOutcomeUnknownError("WebDAV History repair could not be confirmed. Reopen History before retrying.", { cause: error });
|
|
216
|
+
}
|
|
217
|
+
return true;
|
|
218
|
+
}
|
|
168
219
|
async diagnose(signal) {
|
|
169
220
|
const diagnostics = [
|
|
170
221
|
{
|
|
@@ -215,7 +266,7 @@ export class WebDavSyncBackend {
|
|
|
215
266
|
}
|
|
216
267
|
return diagnostics;
|
|
217
268
|
}
|
|
218
|
-
async runCapabilityProbe(signal) {
|
|
269
|
+
async runCapabilityProbe(signal, validateOwner) {
|
|
219
270
|
this.conditionalVerified = false;
|
|
220
271
|
throwIfAborted(signal);
|
|
221
272
|
const probeCollection = joinRemote(rootPath(this.config), ".pi-sync-probes", randomUUID());
|
|
@@ -227,13 +278,16 @@ export class WebDavSyncBackend {
|
|
|
227
278
|
created = true;
|
|
228
279
|
await client.ensureCollection(probeCollection);
|
|
229
280
|
await client.listCollection(probeCollection);
|
|
281
|
+
validateOwner?.();
|
|
230
282
|
await client.putBuffer(probe, Buffer.from("first"), "text/plain", { ifAbsent: true });
|
|
231
283
|
const read = await client.getBuffer(probe);
|
|
232
284
|
const etag = strongEtag(read.etag);
|
|
233
285
|
if (!read.value || !etag) {
|
|
234
286
|
throw new Error("WebDAV server did not return a strong ETag for the capability probe.");
|
|
235
287
|
}
|
|
288
|
+
validateOwner?.();
|
|
236
289
|
await expectPrecondition(client.putBuffer(probe, Buffer.from("replace"), "text/plain", { ifAbsent: true }), "If-None-Match");
|
|
290
|
+
validateOwner?.();
|
|
237
291
|
await expectPrecondition(client.putBuffer(probe, Buffer.from("replace"), "text/plain", {
|
|
238
292
|
ifMatch: '"pi-sync-deliberately-stale"',
|
|
239
293
|
}), "If-Match");
|
|
@@ -241,6 +295,7 @@ export class WebDavSyncBackend {
|
|
|
241
295
|
if (!unchanged.value?.equals(Buffer.from("first"))) {
|
|
242
296
|
throw new Error("WebDAV server changed a probe despite a failed precondition.");
|
|
243
297
|
}
|
|
298
|
+
validateOwner?.();
|
|
244
299
|
await client.putBuffer(probe, Buffer.from("second"), "text/plain", { ifMatch: etag });
|
|
245
300
|
const changed = await client.getBuffer(probe);
|
|
246
301
|
const changedEtag = strongEtag(changed.etag);
|
|
@@ -299,6 +354,13 @@ export class WebDavSyncBackend {
|
|
|
299
354
|
: "webdav history: active snapshot entry present";
|
|
300
355
|
}
|
|
301
356
|
async ensureHistoryPointer(client, pointer, keepRecent = false) {
|
|
357
|
+
const update = await this.prepareHistoryUpdate(client, pointer, keepRecent);
|
|
358
|
+
if (!update)
|
|
359
|
+
return false;
|
|
360
|
+
await client.putJson(historyPath(this.config), update.history, update.condition);
|
|
361
|
+
return true;
|
|
362
|
+
}
|
|
363
|
+
async prepareHistoryUpdate(client, pointer, keepRecent = false) {
|
|
302
364
|
const object = await client.getJson(historyPath(this.config));
|
|
303
365
|
const snapshots = object.missing ? [] : requireHistory(object.value, this.config.destination.namespace);
|
|
304
366
|
const existing = snapshots.find((entry) => entry.snapshot === pointer.snapshot);
|
|
@@ -307,12 +369,11 @@ export class WebDavSyncBackend {
|
|
|
307
369
|
throw new Error("Remote history rebound an immutable snapshot reference.");
|
|
308
370
|
}
|
|
309
371
|
if (!keepRecent || snapshots.at(-1) === existing)
|
|
310
|
-
return
|
|
372
|
+
return;
|
|
311
373
|
}
|
|
312
374
|
const next = [...snapshots.filter((entry) => entry !== existing), pointer].slice(-100);
|
|
313
375
|
const condition = object.missing ? { ifAbsent: true } : { ifMatch: requireStrongEtag(object.etag, "history") };
|
|
314
|
-
|
|
315
|
-
return true;
|
|
376
|
+
return { history: { version: VERSION, snapshots: next }, condition };
|
|
316
377
|
}
|
|
317
378
|
async updateHistorySafely(client, pointer) {
|
|
318
379
|
try {
|
|
@@ -320,7 +381,7 @@ export class WebDavSyncBackend {
|
|
|
320
381
|
return undefined;
|
|
321
382
|
}
|
|
322
383
|
catch (error) {
|
|
323
|
-
return `Remote snapshot is active, but history could not be updated: ${errorMessage(error)}.
|
|
384
|
+
return `Remote snapshot is active, but history could not be updated: ${errorMessage(error)}. Open /sync → History and choose Repair active snapshot history before relying on History.`;
|
|
324
385
|
}
|
|
325
386
|
}
|
|
326
387
|
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { record } from "../protocol.js";
|
|
2
|
+
const selections = ["same", "different", "legacy", "unavailable"];
|
|
3
|
+
const failures = ["settings-changed", "timeout", "permission", "storage", "unavailable"];
|
|
4
|
+
export function summarizeDebugInspection(value) {
|
|
5
|
+
if (!record(value))
|
|
6
|
+
return;
|
|
7
|
+
return validateDebugCheckSummary({
|
|
8
|
+
outcome: "checked",
|
|
9
|
+
baseline: typeof value.firstSync === "boolean" ? !value.firstSync : undefined,
|
|
10
|
+
localChanged: value.localChanged,
|
|
11
|
+
remoteChanged: value.remoteChanged,
|
|
12
|
+
remoteSnapshot: value.head === undefined || record(value.head) ? value.head !== undefined : undefined,
|
|
13
|
+
localFiles: value.localFiles,
|
|
14
|
+
selection: record(value.selectionState) ? value.selectionState.kind : "unavailable",
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
export function debugCheckFailure(error) {
|
|
18
|
+
const fields = record(error) ? error : {};
|
|
19
|
+
const status = fields.status;
|
|
20
|
+
const reason = fields.code === "SYNC_INSPECTION_CHANGED"
|
|
21
|
+
? "settings-changed"
|
|
22
|
+
: fields.name === "TimeoutError" || fields.code === "ETIMEDOUT"
|
|
23
|
+
? "timeout"
|
|
24
|
+
: status === 401 || status === 403
|
|
25
|
+
? "permission"
|
|
26
|
+
: typeof status === "number" && status >= 400
|
|
27
|
+
? "storage"
|
|
28
|
+
: "unavailable";
|
|
29
|
+
return { outcome: "failed", reason };
|
|
30
|
+
}
|
|
31
|
+
export function validateDebugCheckSummary(value) {
|
|
32
|
+
if (!record(value))
|
|
33
|
+
return;
|
|
34
|
+
if (value.outcome === "failed") {
|
|
35
|
+
const reason = failures.find((item) => item === value.reason);
|
|
36
|
+
return reason ? { outcome: "failed", reason } : undefined;
|
|
37
|
+
}
|
|
38
|
+
const selection = selections.find((item) => item === value.selection);
|
|
39
|
+
if (value.outcome !== "checked" ||
|
|
40
|
+
typeof value.baseline !== "boolean" ||
|
|
41
|
+
typeof value.localChanged !== "boolean" ||
|
|
42
|
+
typeof value.remoteChanged !== "boolean" ||
|
|
43
|
+
typeof value.remoteSnapshot !== "boolean" ||
|
|
44
|
+
typeof value.localFiles !== "number" ||
|
|
45
|
+
!Number.isSafeInteger(value.localFiles) ||
|
|
46
|
+
value.localFiles < 0 ||
|
|
47
|
+
!selection ||
|
|
48
|
+
(!value.remoteSnapshot && selection !== "unavailable"))
|
|
49
|
+
return;
|
|
50
|
+
return {
|
|
51
|
+
outcome: "checked",
|
|
52
|
+
baseline: value.baseline,
|
|
53
|
+
localChanged: value.localChanged,
|
|
54
|
+
remoteChanged: value.remoteChanged,
|
|
55
|
+
remoteSnapshot: value.remoteSnapshot,
|
|
56
|
+
localFiles: value.localFiles,
|
|
57
|
+
selection,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import { closeSync, constants, fstatSync, lstatSync, openSync, realpathSync, writeSync, } from "node:fs";
|
|
1
|
+
import { closeSync, constants, fstatSync, lstatSync, openSync, readSync, realpathSync, writeSync, } from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { isForegroundDirection, isForegroundQueueOutcome } from "../foreground-queue-outcome.js";
|
|
4
|
+
import { isDestinationConflict } from "../foreground-transfer.js";
|
|
5
|
+
import { record } from "../protocol.js";
|
|
6
|
+
import { validateDebugCheckSummary } from "./debug-check.js";
|
|
4
7
|
import { DEBUG_LOG_FILENAME } from "./paths.js";
|
|
5
8
|
import { isStartupTimingReport } from "./sync/startup-timings.js";
|
|
6
9
|
const OPERATIONS = [
|
|
@@ -28,6 +31,8 @@ const OPERATIONS = [
|
|
|
28
31
|
const OUTCOMES = ["started", "completed", "failed", "cancelled", "blocked", "skipped"];
|
|
29
32
|
const JOB_ID = /^[a-f0-9]{16}-[a-f0-9]{8}(?:-[a-f0-9]{4}){3}-[a-f0-9]{12}$/u;
|
|
30
33
|
const MAX_RECORD_BYTES = 4_096;
|
|
34
|
+
const MAX_CHECK_READ_BYTES = 64 * 1024;
|
|
35
|
+
const SETUP_KEY = /^[a-f0-9]{64}$/u;
|
|
31
36
|
const CYCLE_REASONS = [
|
|
32
37
|
"transient",
|
|
33
38
|
"contention",
|
|
@@ -50,6 +55,8 @@ export function debugJobResult(operation, result) {
|
|
|
50
55
|
return "blocked";
|
|
51
56
|
result = result.result;
|
|
52
57
|
}
|
|
58
|
+
if (isDestinationConflict(result))
|
|
59
|
+
return "blocked";
|
|
53
60
|
if (result && typeof result === "object" && "outcome" in result) {
|
|
54
61
|
if (result.outcome === "applied")
|
|
55
62
|
return "completed";
|
|
@@ -85,6 +92,8 @@ function safeFields(event) {
|
|
|
85
92
|
: {}),
|
|
86
93
|
};
|
|
87
94
|
break;
|
|
95
|
+
case "check":
|
|
96
|
+
return safeCheckFields(event);
|
|
88
97
|
case "continuous-cycle":
|
|
89
98
|
if (["completed", "failed", "cancelled", "blocked", "skipped"].includes(event.outcome))
|
|
90
99
|
return {
|
|
@@ -95,6 +104,22 @@ function safeFields(event) {
|
|
|
95
104
|
break;
|
|
96
105
|
}
|
|
97
106
|
}
|
|
107
|
+
function safeCheckFields(value) {
|
|
108
|
+
const { origin, setupKey, operationId } = value;
|
|
109
|
+
const summary = validateDebugCheckSummary(value.summary);
|
|
110
|
+
if ((origin !== "startup" && origin !== "recheck") ||
|
|
111
|
+
typeof setupKey !== "string" ||
|
|
112
|
+
!SETUP_KEY.test(setupKey) ||
|
|
113
|
+
!summary)
|
|
114
|
+
return;
|
|
115
|
+
return {
|
|
116
|
+
event: "check",
|
|
117
|
+
origin,
|
|
118
|
+
setupKey,
|
|
119
|
+
summary,
|
|
120
|
+
...(typeof operationId === "string" && JOB_ID.test(operationId) ? { operationId } : {}),
|
|
121
|
+
};
|
|
122
|
+
}
|
|
98
123
|
function owned(stat) {
|
|
99
124
|
return process.getuid === undefined || stat.uid === BigInt(process.getuid());
|
|
100
125
|
}
|
|
@@ -107,6 +132,80 @@ function safeRoot(stat) {
|
|
|
107
132
|
function sameIdentity(left, right) {
|
|
108
133
|
return left.dev === right.dev && left.ino === right.ino;
|
|
109
134
|
}
|
|
135
|
+
export function readLatestDebugCheck(root, setupKey) {
|
|
136
|
+
try {
|
|
137
|
+
const directory = lstatSync(root, { bigint: true });
|
|
138
|
+
if (!SETUP_KEY.test(setupKey) || !safeRoot(directory) || realpathSync(root) !== root)
|
|
139
|
+
return { kind: "unavailable" };
|
|
140
|
+
const target = path.join(root, DEBUG_LOG_FILENAME);
|
|
141
|
+
const previous = lstatSync(target, { bigint: true, throwIfNoEntry: false });
|
|
142
|
+
if (!previous)
|
|
143
|
+
return { kind: "no-record" };
|
|
144
|
+
if (!privateFile(previous))
|
|
145
|
+
return { kind: "unavailable" };
|
|
146
|
+
const fd = openSync(target, constants.O_RDONLY | (constants.O_NOFOLLOW ?? 0) | (constants.O_NONBLOCK ?? 0));
|
|
147
|
+
try {
|
|
148
|
+
const opened = fstatSync(fd, { bigint: true });
|
|
149
|
+
if (!privateFile(opened) || !sameIdentity(previous, opened))
|
|
150
|
+
return { kind: "unavailable" };
|
|
151
|
+
const length = Number(opened.size < BigInt(MAX_CHECK_READ_BYTES) ? opened.size : BigInt(MAX_CHECK_READ_BYTES));
|
|
152
|
+
const start = opened.size - BigInt(length);
|
|
153
|
+
const bytes = Buffer.alloc(length);
|
|
154
|
+
let offset = 0;
|
|
155
|
+
while (offset < length) {
|
|
156
|
+
const read = readSync(fd, bytes, offset, length - offset, start + BigInt(offset));
|
|
157
|
+
if (!read)
|
|
158
|
+
return { kind: "unavailable" };
|
|
159
|
+
offset += read;
|
|
160
|
+
}
|
|
161
|
+
const current = lstatSync(target, { bigint: true });
|
|
162
|
+
const currentRoot = lstatSync(root, { bigint: true });
|
|
163
|
+
if (!privateFile(current) ||
|
|
164
|
+
!sameIdentity(opened, current) ||
|
|
165
|
+
current.size < opened.size ||
|
|
166
|
+
!safeRoot(currentRoot) ||
|
|
167
|
+
!sameIdentity(directory, currentRoot) ||
|
|
168
|
+
realpathSync(root) !== root)
|
|
169
|
+
return { kind: "unavailable" };
|
|
170
|
+
const lines = bytes.toString("utf8").split("\n");
|
|
171
|
+
for (let i = lines.length - 2; i >= (start === 0n ? 0 : 1); i--) {
|
|
172
|
+
const line = lines[i];
|
|
173
|
+
if (!line || Buffer.byteLength(line) >= MAX_RECORD_BYTES)
|
|
174
|
+
continue;
|
|
175
|
+
try {
|
|
176
|
+
const value = JSON.parse(line);
|
|
177
|
+
if (!record(value) ||
|
|
178
|
+
value.event !== "check" ||
|
|
179
|
+
value.setupKey !== setupKey ||
|
|
180
|
+
(value.source !== "pi-sync-daemon" && value.source !== "pi-sync") ||
|
|
181
|
+
typeof value.time !== "string" ||
|
|
182
|
+
value.time.length !== 24 ||
|
|
183
|
+
new Date(value.time).toISOString() !== value.time)
|
|
184
|
+
continue;
|
|
185
|
+
const fields = safeCheckFields(value);
|
|
186
|
+
if (fields)
|
|
187
|
+
return {
|
|
188
|
+
kind: "recorded",
|
|
189
|
+
check: {
|
|
190
|
+
time: value.time,
|
|
191
|
+
origin: fields.origin,
|
|
192
|
+
summary: fields.summary,
|
|
193
|
+
...(fields.operationId ? { operationId: fields.operationId } : {}),
|
|
194
|
+
},
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
catch { }
|
|
198
|
+
}
|
|
199
|
+
return { kind: "no-record" };
|
|
200
|
+
}
|
|
201
|
+
finally {
|
|
202
|
+
closeSync(fd);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
catch {
|
|
206
|
+
return { kind: "unavailable" };
|
|
207
|
+
}
|
|
208
|
+
}
|
|
110
209
|
export function appendDebugEvent(root, source, event) {
|
|
111
210
|
try {
|
|
112
211
|
if (source !== "pi-sync" && source !== "pi-sync-daemon")
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { createSnapshot } from "../snapshot/snapshot.js";
|
|
2
|
+
import { sameRemoteHead } from "./remote-snapshot.js";
|
|
3
|
+
import { fileHashMap, sameHashes, stateHashMapForConfig } from "./sync-state.js";
|
|
4
|
+
export class DirectionalDestinationConflict extends Error {
|
|
5
|
+
}
|
|
6
|
+
export class DirectionalReviewChangedError extends Error {
|
|
7
|
+
constructor() {
|
|
8
|
+
super("The transfer contents changed again. Start from a fresh review.");
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
export function needsDirectionalForce(intent, config, state, destination, candidate, protectedPaths) {
|
|
12
|
+
const current = new Map(destination?.files.map(({ path, sha256 }) => [path, sha256]));
|
|
13
|
+
const proposed = new Map(candidate.files.map(({ path, sha256 }) => [path, sha256]));
|
|
14
|
+
const accepted = state.lastAppliedSnapshot
|
|
15
|
+
? new Map(Object.entries(stateHashMapForConfig(state, config)))
|
|
16
|
+
: new Map();
|
|
17
|
+
const conflicts = [...new Set([...accepted.keys(), ...current.keys()])].some((path) => !protectedPaths.has(path) && current.get(path) !== accepted.get(path) && current.get(path) !== proposed.get(path));
|
|
18
|
+
if (conflicts && !state.lastAppliedSnapshot)
|
|
19
|
+
throw new Error("This destination has no accepted sync baseline. Review first sync with Sync… before replacing content.");
|
|
20
|
+
if (!conflicts && intent === "review-force")
|
|
21
|
+
throw new Error("The destination no longer has a content conflict. Start a normal transfer again.");
|
|
22
|
+
return conflicts;
|
|
23
|
+
}
|
|
24
|
+
export async function recheckDirectionalReview(backend, head, local, options, validate) {
|
|
25
|
+
const currentHead = await backend.readHead(options.signal);
|
|
26
|
+
validate();
|
|
27
|
+
const currentLocal = await createSnapshot(local.profile, options);
|
|
28
|
+
validate();
|
|
29
|
+
if (!sameRemoteHead(backend, head, currentHead) || !sameHashes(fileHashMap(local), fileHashMap(currentLocal)))
|
|
30
|
+
throw new DirectionalReviewChangedError();
|
|
31
|
+
}
|
|
@@ -8,7 +8,7 @@ export async function confirmPush(ctx, options, config, backend, local, upload,
|
|
|
8
8
|
if (options.yes)
|
|
9
9
|
return true;
|
|
10
10
|
const summary = formatPushSummary(config, backend.destination, upload, head, countPreservedRemoteFiles(local, upload), remote);
|
|
11
|
-
const confirmed = await confirmTransferReview(ctx, title, formatTransferReview(summary), options.signal, validateMutation);
|
|
11
|
+
const confirmed = await confirmTransferReview(ctx, title, formatTransferReview(summary), options.signal, validateMutation, options.directionalAction?.intent === "review-force");
|
|
12
12
|
throwIfAborted(options.signal);
|
|
13
13
|
if (confirmed)
|
|
14
14
|
return true;
|
|
@@ -22,11 +22,11 @@ export function syncErrorGuidance(error) {
|
|
|
22
22
|
}
|
|
23
23
|
else if (/\bagent directory exceeds the scan entry bound\b/iu.test(message)) {
|
|
24
24
|
next =
|
|
25
|
-
"Reduce the number of entries Pi Sync must scan before retrying. Exclude whole subdirectories to skip their contents.
|
|
25
|
+
"Reduce the number of entries Pi Sync must scan before retrying. Exclude whole subdirectories to skip their contents. Open /sync → Settings to review the active scope.";
|
|
26
26
|
}
|
|
27
27
|
else if (/\bprojected agent directory exceeds the (64 MiB scan byte|scan file) bound\b/iu.test(message)) {
|
|
28
28
|
next =
|
|
29
|
-
"The resulting files would exceed the sync limit. Review the
|
|
29
|
+
"The resulting files would exceed the sync limit. Review the scope in /sync → Settings and reduce the local or incoming sync content before retrying.";
|
|
30
30
|
}
|
|
31
31
|
else if (/\bagent directory exceeds the (64 MiB scan byte|scan file) bound\b/iu.test(message)) {
|
|
32
32
|
next =
|
|
@@ -46,10 +46,11 @@ export function syncErrorGuidance(error) {
|
|
|
46
46
|
"Verify the connection address and setup's bucket, branch, or path with your provider; this response alone does not prove which resource is missing.";
|
|
47
47
|
}
|
|
48
48
|
else if (status !== undefined && status >= 500) {
|
|
49
|
-
next = "Check your storage provider's service status, then
|
|
49
|
+
next = "Check your storage provider's service status, then use /sync diff to review differences before retrying.";
|
|
50
50
|
}
|
|
51
51
|
else if (/timed out|timeout|request failed|resolve host|Could not resolve|ENOTFOUND|ECONNREFUSED/iu.test(message)) {
|
|
52
|
-
next =
|
|
52
|
+
next =
|
|
53
|
+
"Check the server address and network connection. To review the connection settings, open /sync → Settings → Manage storage connections.";
|
|
53
54
|
}
|
|
54
55
|
else if (/strong ETag|If-Match|If-None-Match|precondition|conditional header/iu.test(message)) {
|
|
55
56
|
next =
|
|
@@ -67,7 +68,7 @@ export function syncErrorGuidance(error) {
|
|
|
67
68
|
"Correct the named field or item in /sync. If the settings file is invalid, repair it before retrying; do not replace it with defaults.";
|
|
68
69
|
}
|
|
69
70
|
else {
|
|
70
|
-
next = "
|
|
71
|
+
next = "Review the setup in /sync → Settings and use /sync diff to review file differences before retrying.";
|
|
71
72
|
}
|
|
72
73
|
return `${message}\n${next}`;
|
|
73
74
|
}
|
|
@@ -7,15 +7,19 @@ import { createStartupTimings } from "./startup-timings.js";
|
|
|
7
7
|
import { syncSelectionHasContent } from "./sync-policy.js";
|
|
8
8
|
import { hasLocalChanges, rawSnapshotHashIdentity, remoteChangedSinceState } from "./sync-state.js";
|
|
9
9
|
/** Advisory baseline-relative observation, never an authorization to transfer files. */
|
|
10
|
-
export async function inspectSync(config, options, signal, factory = createSyncBackend, timings = createStartupTimings()) {
|
|
10
|
+
export async function inspectSync(config, options, signal, factory = createSyncBackend, timings = createStartupTimings(), beforeRemote) {
|
|
11
11
|
throwIfAborted(signal);
|
|
12
12
|
const backend = await timings.measure("backend initialization", () => factory(config));
|
|
13
13
|
throwIfAborted(signal);
|
|
14
14
|
const local = await timings.measure("local snapshot", () => observeSnapshot({ ...options, signal }, Boolean(config.localFields?.length)));
|
|
15
15
|
throwIfAborted(signal);
|
|
16
16
|
const state = await timings.measure("sync state read", () => readStateForConfig(config));
|
|
17
|
+
if (beforeRemote)
|
|
18
|
+
await beforeRemote();
|
|
17
19
|
throwIfAborted(signal);
|
|
18
20
|
const head = await timings.measure("remote head", () => backend.readHead(signal));
|
|
21
|
+
if (head && !head.selection && beforeRemote)
|
|
22
|
+
await beforeRemote();
|
|
19
23
|
throwIfAborted(signal);
|
|
20
24
|
const selectionState = head ? await inspectHeadSelection(backend, config, head, signal) : undefined;
|
|
21
25
|
throwIfAborted(signal);
|
|
@@ -13,6 +13,7 @@ import { confirmTransferReview } from "../ui/transfer-review.js";
|
|
|
13
13
|
import { startupTransferEnabled } from "./agent-policy.js";
|
|
14
14
|
import { inspectCaseCleanup, revalidateCaseCleanup } from "./apply-review.js";
|
|
15
15
|
import { checkpointDirectionalAction, foregroundDirectionalAction, keepProtectedRemoteSessions, localRestoreGuidance, notifyDirectionalSuccess, remoteRestoreGuidance, requireDirectionalPullBoundary, requireDirectionalSelection, validateDirectionalSettings, } from "./directional-action.js";
|
|
16
|
+
import { DirectionalDestinationConflict, needsDirectionalForce, recheckDirectionalReview, } from "./directional-conflict.js";
|
|
16
17
|
import { confirmFieldMigration } from "./field-migration.js";
|
|
17
18
|
import { overlayLocalFields, portableSnapshot, sameLocalFields, validatePortableSnapshot } from "./local-fields.js";
|
|
18
19
|
import { readMergeJournal, requireNoMergeJournal, retireMergeJournal } from "./merge-journal.js";
|
|
@@ -126,7 +127,23 @@ export async function push(ctx, options, input, factory = createSyncBackend) {
|
|
|
126
127
|
throw new Error(`Refusing to push possible secrets:\n${secrets.map((s) => `- ${s}`).join("\n")}`);
|
|
127
128
|
}
|
|
128
129
|
}
|
|
129
|
-
if (
|
|
130
|
+
if (action?.intent) {
|
|
131
|
+
if (!head && state.lastAppliedSnapshot)
|
|
132
|
+
throw new Error("The previously synced remote snapshot is missing. Review sync recovery before publishing.");
|
|
133
|
+
const selected = (snapshot) => filterSnapshotForConfigPolicy(snapshot, config, snapshotOptions);
|
|
134
|
+
const conflict = needsDirectionalForce(action.intent, config, state, remoteForUpload && selected(remoteForUpload), selected(upload), reviewedProtectedPaths);
|
|
135
|
+
if (action.intent === "reject-conflicts" && conflict) {
|
|
136
|
+
setSyncStatus(ctx, undefined);
|
|
137
|
+
throw new DirectionalDestinationConflict();
|
|
138
|
+
}
|
|
139
|
+
if (action.intent === "review-force") {
|
|
140
|
+
if (!(await confirmPush(ctx, options, config, backend, local, upload, head, remoteForUpload, validateMutation, "Force push?")))
|
|
141
|
+
return "cancelled";
|
|
142
|
+
await validateSettings();
|
|
143
|
+
await recheckDirectionalReview(backend, head, localRaw, snapshotOptions, validateMutation);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
else if (!action &&
|
|
130
147
|
!(await confirmPush(ctx, options, config, backend, local, upload, head, remoteForUpload, validateMutation))) {
|
|
131
148
|
return "cancelled";
|
|
132
149
|
}
|
|
@@ -362,18 +379,34 @@ export async function pull(ctx, options, factory = createSyncBackend, initial) {
|
|
|
362
379
|
directMessage: "Both local and remote changed since last sync. Run /sync diff, then choose /sync pull --force or /sync push --force.",
|
|
363
380
|
});
|
|
364
381
|
}
|
|
382
|
+
const validateActionBoundary = action
|
|
383
|
+
? () => requireDirectionalPullBoundary(ctx, options, config, config.scope ? physical : { ...physical, files: [...local.files, ...physical.files] }, snapshotOptions, reviewedProtectedPaths, validateMutation)
|
|
384
|
+
: undefined;
|
|
385
|
+
if (action?.intent) {
|
|
386
|
+
await validateActionBoundary?.();
|
|
387
|
+
validateMutation();
|
|
388
|
+
const conflict = needsDirectionalForce(action.intent, config, state, portableSnapshot(local, config.localFields), logical, reviewedProtectedPaths);
|
|
389
|
+
if (action.intent === "reject-conflicts" && conflict) {
|
|
390
|
+
setSyncStatus(ctx, undefined);
|
|
391
|
+
throw new DirectionalDestinationConflict();
|
|
392
|
+
}
|
|
393
|
+
}
|
|
365
394
|
const caseCleanup = action || options.yes ? [] : await inspectCaseCleanup(physical, snapshotOptions);
|
|
366
395
|
validateMutation();
|
|
367
|
-
if (!action &&
|
|
368
|
-
!
|
|
369
|
-
|
|
396
|
+
if (((!action && !options.yes) || action?.intent === "review-force") &&
|
|
397
|
+
!(await confirmTransferReview(ctx, action?.intent === "review-force"
|
|
398
|
+
? "Force pull?"
|
|
399
|
+
: snapshotIncludesSessions(remote)
|
|
400
|
+
? "Pull pi settings and sessions?"
|
|
401
|
+
: "Pull pi settings?", formatPullSummary(config, backend.destination, local, physical, reviewedProtectedPaths, caseCleanup.map((item) => item.path)), options.signal, validateMutation, action?.intent === "review-force"))) {
|
|
370
402
|
setSyncStatus(ctx, undefined);
|
|
371
403
|
ctx.ui.notify("Pull cancelled.", "info");
|
|
372
404
|
return "cancelled";
|
|
373
405
|
}
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
406
|
+
if (action?.intent === "review-force") {
|
|
407
|
+
await validateActionBoundary?.();
|
|
408
|
+
await recheckDirectionalReview(backend, head, local, snapshotOptions, validateMutation);
|
|
409
|
+
}
|
|
377
410
|
if (action) {
|
|
378
411
|
await checkpointDirectionalAction(options, {
|
|
379
412
|
direction: "pull",
|