@narumitw/pi-sync 0.67.3 → 0.68.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 +7 -0
- package/README.md +26 -48
- package/dist/chunks/{chunk-XUZV4OGI.ts → chunk-335XTMMZ.ts} +3 -2
- package/dist/chunks/{chunk-XUZV4OGI.ts.map → chunk-335XTMMZ.ts.map} +2 -2
- package/dist/chunks/{chunk-PUSMSKIM.ts → chunk-AYGMIMCV.ts} +2 -11
- package/dist/chunks/chunk-AYGMIMCV.ts.map +7 -0
- package/dist/chunks/{chunk-HLJIRWFL.ts → chunk-BCDBT4X3.ts} +7 -7
- package/dist/chunks/{chunk-AVTW6WNP.ts → chunk-FQKWGVMA.ts} +20 -54
- package/dist/chunks/chunk-FQKWGVMA.ts.map +7 -0
- package/dist/chunks/{chunk-DGVZYS7T.ts → chunk-FR6A7ASZ.ts} +8 -11
- package/dist/chunks/chunk-FR6A7ASZ.ts.map +7 -0
- package/dist/chunks/{chunk-3NS4PMCI.ts → chunk-J52GYZO6.ts} +2 -8
- package/dist/chunks/{chunk-3NS4PMCI.ts.map → chunk-J52GYZO6.ts.map} +2 -2
- package/dist/chunks/{chunk-2MUAR5GH.ts → chunk-KAIVTJIQ.ts} +7 -10
- package/dist/chunks/chunk-KAIVTJIQ.ts.map +7 -0
- package/dist/chunks/{chunk-WBIOSK76.ts → chunk-R7PN3KIY.ts} +1 -2
- package/dist/chunks/{chunk-3Q3DMMID.ts → chunk-TLYT6HVI.ts} +8 -8
- package/dist/chunks/{chunk-X344HTVV.ts → chunk-WCGLU526.ts} +39 -118
- package/dist/chunks/chunk-WCGLU526.ts.map +7 -0
- package/dist/chunks/{chunk-JREGWM2B.ts → chunk-XNUARYLR.ts} +1 -2
- package/dist/chunks/{chunk-CQ4DMLH3.ts → chunk-YV2R5SJU.ts} +21 -81
- package/dist/chunks/chunk-YV2R5SJU.ts.map +7 -0
- package/dist/chunks/{command-handler-WF2TDDRZ.ts → command-handler-S6BRZMPW.ts} +64 -59
- package/dist/chunks/command-handler-S6BRZMPW.ts.map +7 -0
- package/dist/chunks/{conflict-review-GWEL4S6C.ts → conflict-review-3XMYDJIK.ts} +2 -2
- package/dist/chunks/{file-selection-GASCVN45.ts → file-selection-4BOQBXS7.ts} +10 -17
- package/dist/chunks/file-selection-4BOQBXS7.ts.map +7 -0
- package/dist/chunks/{manager-result-dispatcher-BXN46NRC.ts → manager-result-dispatcher-A4IWLS4J.ts} +7 -7
- package/dist/chunks/{manager-ui-FS4QIKRA.ts → manager-ui-KHMCSLLV.ts} +114 -581
- package/dist/chunks/manager-ui-KHMCSLLV.ts.map +7 -0
- package/dist/chunks/{chunk-ECUCXF5Y.ts → merge-review-LWMUE5IW.ts} +2 -3
- package/dist/chunks/{remote-selection-ui-DOYKUMER.ts → remote-selection-ui-F6NJBQ3Y.ts} +6 -6
- package/dist/chunks/{setup-switch-JZDFQPVW.ts → setup-switch-7LMIRMZ7.ts} +6 -6
- package/dist/chunks/{setup-wizard-PI45SF2C.ts → setup-wizard-2NRPR433.ts} +11 -16
- package/dist/chunks/{setup-wizard-PI45SF2C.ts.map → setup-wizard-2NRPR433.ts.map} +1 -1
- package/dist/chunks/{sync-inspection-DI5J6EUH.ts → sync-inspection-QGM54YCM.ts} +5 -5
- package/dist/chunks/{sync-operations-AGNL7QXA.ts → sync-operations-DTQMKVRQ.ts} +2 -2
- package/dist/daemon/dist/build-id.json +1 -1
- package/dist/daemon/dist/cli.js +22 -3
- package/dist/daemon/dist/client-transport.js +2 -0
- package/dist/daemon/dist/client.js +2 -10
- package/dist/daemon/dist/consent.js +13 -135
- package/dist/daemon/dist/engine/backends/git/git-backend.js +4 -17
- package/dist/daemon/dist/engine/backends/git/git-storage.js +11 -44
- package/dist/daemon/dist/engine/backends/s3/s3-backend.js +6 -6
- package/dist/daemon/dist/engine/backends/webdav/webdav-backend.js +6 -6
- package/dist/daemon/dist/engine/settings/config.js +16 -149
- package/dist/daemon/dist/engine/settings/retired-ignore-policy.js +16 -0
- package/dist/daemon/dist/engine/settings/retired-ignore-recovery.js +14 -0
- package/dist/daemon/dist/engine/settings/settings-management.js +2 -10
- package/dist/daemon/dist/engine/settings/settings-validation.js +8 -21
- package/dist/daemon/dist/engine/snapshot/session-paths.js +13 -41
- package/dist/daemon/dist/engine/snapshot/snapshot-apply.js +8 -24
- package/dist/daemon/dist/engine/snapshot/snapshot-codec.js +7 -11
- package/dist/daemon/dist/engine/snapshot/snapshot-exclude-safety.js +19 -76
- package/dist/daemon/dist/engine/snapshot/snapshot-transaction-images.js +1 -7
- package/dist/daemon/dist/engine/snapshot/snapshot-transaction-policy.js +8 -102
- package/dist/daemon/dist/engine/snapshot/snapshot-transaction.js +20 -100
- package/dist/daemon/dist/engine/snapshot/snapshot-types.js +1 -11
- package/dist/daemon/dist/engine/snapshot/snapshot.js +26 -78
- package/dist/daemon/dist/engine/state/sync-state-store.js +5 -1
- package/dist/daemon/dist/engine/sync/agent-plan.js +0 -1
- package/dist/daemon/dist/engine/sync/agent-policy.js +1 -1
- package/dist/daemon/dist/engine/sync/conflict-review.js +0 -2
- package/dist/daemon/dist/engine/sync/continuous-sync.js +2 -17
- package/dist/daemon/dist/engine/sync/continuous-watch.js +3 -7
- package/dist/daemon/dist/engine/sync/directional-action.js +3 -21
- package/dist/daemon/dist/engine/sync/initialization.js +4 -15
- package/dist/daemon/dist/engine/sync/local-fields.js +4 -65
- package/dist/daemon/dist/engine/sync/merge-apply.js +8 -31
- package/dist/daemon/dist/engine/sync/merge-journal.js +8 -118
- package/dist/daemon/dist/engine/sync/merged-sync.js +12 -70
- package/dist/daemon/dist/engine/sync/push-review.js +1 -16
- package/dist/daemon/dist/engine/sync/remote-snapshot.js +48 -65
- package/dist/daemon/dist/engine/sync/startup-bootstrap.js +3 -3
- package/dist/daemon/dist/engine/sync/sync-error-guidance.js +1 -1
- package/dist/daemon/dist/engine/sync/sync-inspection.js +1 -2
- package/dist/daemon/dist/engine/sync/sync-mutations.js +25 -118
- package/dist/daemon/dist/engine/sync/sync-policy.js +26 -150
- package/dist/daemon/dist/engine/sync/sync-queries.js +1 -8
- package/dist/daemon/dist/engine/sync/sync-rollback.js +12 -50
- package/dist/daemon/dist/engine/sync/sync-state.js +2 -15
- package/dist/daemon/dist/engine/sync/transfer-freshness.js +7 -17
- package/dist/daemon/dist/engine/sync/transfer-size-limits.js +3 -7
- package/dist/daemon/dist/engine-service.js +60 -219
- package/dist/daemon/dist/foreground-queue-outcome.js +0 -4
- package/dist/daemon/dist/legacy-consent-guard.js +34 -0
- package/dist/daemon/dist/server.js +4 -8
- package/dist/daemon/dist/service-host.js +3 -9
- package/dist/daemon/package.json +1 -1
- package/dist/index.ts +45 -46
- package/dist/index.ts.map +3 -3
- package/docs/continuous-sync-verification.md +1 -1
- package/docs/daemon-migration.md +7 -5
- package/docs/tui-contract.md +4 -6
- package/package.json +2 -3
- package/skills/configure-pi-sync/SKILL.md +18 -77
- package/skills/configure-pi-sync/references/configuration.md +58 -75
- package/src/commands/command-execution.ts +13 -29
- package/src/commands/command-handler.ts +0 -4
- package/src/commands/command.ts +2 -1
- package/src/daemon/directional-recovery.ts +4 -33
- package/src/daemon/pi-client.ts +20 -88
- package/src/settings/config.ts +0 -1
- package/src/sync/setup-switch.ts +1 -4
- package/src/sync-extension.ts +10 -24
- package/src/ui/cancellable-operation.ts +2 -13
- package/src/ui/excluded-paths-ui.ts +1 -4
- package/src/ui/file-selection.ts +0 -5
- package/src/ui/manager-state.ts +12 -75
- package/src/ui/manager-ui.ts +7 -96
- package/src/ui/remote-selection-ui.ts +29 -130
- package/src/ui/settings-ui.ts +169 -388
- package/src/ui/setup/setup-actions.ts +4 -16
- package/src/ui/setup/setup-prompts.ts +12 -49
- package/src/ui/setup/setup-switcher.ts +8 -14
- package/src/ui/storage-connections-ui.ts +21 -32
- package/src/ui/sync-setups-ui.ts +27 -53
- package/dist/chunks/chunk-2MUAR5GH.ts.map +0 -7
- package/dist/chunks/chunk-33EDXDLC.ts +0 -106
- package/dist/chunks/chunk-33EDXDLC.ts.map +0 -7
- package/dist/chunks/chunk-AVTW6WNP.ts.map +0 -7
- package/dist/chunks/chunk-CQ4DMLH3.ts.map +0 -7
- package/dist/chunks/chunk-DGVZYS7T.ts.map +0 -7
- package/dist/chunks/chunk-EJDDRS6O.ts +0 -17
- package/dist/chunks/chunk-EJDDRS6O.ts.map +0 -7
- package/dist/chunks/chunk-KNEUL4XN.ts +0 -30
- package/dist/chunks/chunk-KNEUL4XN.ts.map +0 -7
- package/dist/chunks/chunk-PUSMSKIM.ts.map +0 -7
- package/dist/chunks/chunk-WFBHWYI6.ts +0 -18
- package/dist/chunks/chunk-WFBHWYI6.ts.map +0 -7
- package/dist/chunks/chunk-X344HTVV.ts.map +0 -7
- package/dist/chunks/command-handler-WF2TDDRZ.ts.map +0 -7
- package/dist/chunks/config-P54GGMXY.ts +0 -39
- package/dist/chunks/continuous-record-3SKJ6I3V.ts +0 -23
- package/dist/chunks/continuous-record-3SKJ6I3V.ts.map +0 -7
- package/dist/chunks/continuous-storage-3EU6I7Z3.ts +0 -27
- package/dist/chunks/continuous-storage-3EU6I7Z3.ts.map +0 -7
- package/dist/chunks/file-selection-GASCVN45.ts.map +0 -7
- package/dist/chunks/ignore-file-ui-BEZZZIEE.ts +0 -21
- package/dist/chunks/manager-ui-FS4QIKRA.ts.map +0 -7
- package/dist/chunks/merge-review-C2KETZKY.ts +0 -11
- package/dist/chunks/merge-review-C2KETZKY.ts.map +0 -7
- package/dist/chunks/remote-selection-ui-DOYKUMER.ts.map +0 -7
- package/dist/chunks/setup-switch-JZDFQPVW.ts.map +0 -7
- package/dist/daemon/dist/engine/ignore/adoption-journal.js +0 -146
- package/dist/daemon/dist/engine/ignore/effective-ignore-policy.js +0 -33
- package/dist/daemon/dist/engine/ignore/ignore-edit.js +0 -102
- package/dist/daemon/dist/engine/ignore/ignore-initialization.js +0 -288
- package/dist/daemon/dist/engine/ignore/ignore-migration-prompt.js +0 -139
- package/dist/daemon/dist/engine/ignore/ignore-settings.js +0 -391
- package/dist/daemon/dist/engine/ignore/ignore-source.js +0 -250
- package/dist/daemon/dist/engine/ignore/snapshot-ignore-rules.js +0 -39
- package/dist/daemon/dist/engine/sync/ignore-adoption-recovery.js +0 -50
- package/dist/daemon/dist/engine/sync/ignore-adoption.js +0 -416
- package/dist/daemon/dist/engine/sync/ignore-publication.js +0 -23
- package/dist/daemon/dist/engine/ui/ignore-rule-preview.js +0 -18
- package/dist/daemon/dist/monitor.js +0 -344
- package/src/ui/agent-mode-setting.ts +0 -99
- package/src/ui/ignore-file-guidance.ts +0 -7
- package/src/ui/ignore-file-ui.ts +0 -105
- package/src/ui/ignore-migration-prompt.ts +0 -65
- package/src/ui/settings-review.ts +0 -26
- /package/dist/chunks/{chunk-HLJIRWFL.ts.map → chunk-BCDBT4X3.ts.map} +0 -0
- /package/dist/chunks/{chunk-WBIOSK76.ts.map → chunk-R7PN3KIY.ts.map} +0 -0
- /package/dist/chunks/{chunk-3Q3DMMID.ts.map → chunk-TLYT6HVI.ts.map} +0 -0
- /package/dist/chunks/{chunk-JREGWM2B.ts.map → chunk-XNUARYLR.ts.map} +0 -0
- /package/dist/chunks/{conflict-review-GWEL4S6C.ts.map → conflict-review-3XMYDJIK.ts.map} +0 -0
- /package/dist/chunks/{config-P54GGMXY.ts.map → manager-result-dispatcher-A4IWLS4J.ts.map} +0 -0
- /package/dist/chunks/{chunk-ECUCXF5Y.ts.map → merge-review-LWMUE5IW.ts.map} +0 -0
- /package/dist/chunks/{ignore-file-ui-BEZZZIEE.ts.map → remote-selection-ui-F6NJBQ3Y.ts.map} +0 -0
- /package/dist/chunks/{manager-result-dispatcher-BXN46NRC.ts.map → setup-switch-7LMIRMZ7.ts.map} +0 -0
- /package/dist/chunks/{sync-inspection-DI5J6EUH.ts.map → sync-inspection-QGM54YCM.ts.map} +0 -0
- /package/dist/chunks/{sync-operations-AGNL7QXA.ts.map → sync-operations-DTQMKVRQ.ts.map} +0 -0
package/dist/daemon/dist/cli.js
CHANGED
|
@@ -7,6 +7,23 @@ import { DaemonUpgradeBlockedError, ensureDaemon, restartDaemon } from "./daemon
|
|
|
7
7
|
import { inspectDaemonStatus } from "./daemon-status.js";
|
|
8
8
|
import { privateDirectory, readIdentity, runtimePaths } from "./identity.js";
|
|
9
9
|
import { openLifecycleLog } from "./lifecycle-log.js";
|
|
10
|
+
async function retiredPolicyBlocker(root) {
|
|
11
|
+
const { RetiredIgnorePolicyError } = await import("./engine/settings/retired-ignore-policy.js");
|
|
12
|
+
try {
|
|
13
|
+
const { assertNoRetiredRuleJournal } = await import("./engine/settings/retired-ignore-recovery.js");
|
|
14
|
+
assertNoRetiredRuleJournal(root);
|
|
15
|
+
const { readLocalConfigForDiagnostics } = await import("./engine/settings/config-file.js");
|
|
16
|
+
const { validateSettingsDocument } = await import("./engine/settings/settings-validation.js");
|
|
17
|
+
const source = await readLocalConfigForDiagnostics(root);
|
|
18
|
+
if (source?.stillCurrent())
|
|
19
|
+
validateSettingsDocument(source.document.parsed);
|
|
20
|
+
}
|
|
21
|
+
catch (error) {
|
|
22
|
+
if (error instanceof RetiredIgnorePolicyError)
|
|
23
|
+
return error.message;
|
|
24
|
+
}
|
|
25
|
+
return undefined;
|
|
26
|
+
}
|
|
10
27
|
function reportLaunch(message) {
|
|
11
28
|
if (process.connected)
|
|
12
29
|
process.send?.(message, () => { });
|
|
@@ -14,7 +31,7 @@ function reportLaunch(message) {
|
|
|
14
31
|
export async function main(args) {
|
|
15
32
|
const [command = "help", flag, root, ...extra] = args;
|
|
16
33
|
if (["help", "--help", "-h"].includes(command)) {
|
|
17
|
-
console.log("pi-sync-daemon <start|status|stop|restart|repair-upgrade|serve> --root <canonical-agent-directory>\nLocal synchronization owner; no OS service registration. status/stop/repair-upgrade never start a service.\nrepair-upgrade revokes all retained unattended grants after verified exit and archives the pending upgrade records.");
|
|
34
|
+
console.log("pi-sync-daemon <start|status|stop|restart|repair-upgrade|serve> --root <canonical-agent-directory>\nLocal synchronization owner; no OS service registration. status/stop/repair-upgrade never start a service.\nrepair-upgrade revokes all retained unattended grants after verified exit and archives the pending upgrade records.\nIf a retired ignore-file policy blocks sync, use /skill:configure-pi-sync in Pi or see the Pi Sync manual recovery guide.");
|
|
18
35
|
return;
|
|
19
36
|
}
|
|
20
37
|
const expectedBuild = command === "serve" && extra[0] === "--expect-build" && extra.length === 3;
|
|
@@ -47,7 +64,7 @@ export async function main(args) {
|
|
|
47
64
|
log?.close(); /* Never follow a replaced diagnostic path. */
|
|
48
65
|
}
|
|
49
66
|
};
|
|
50
|
-
const service = createEngineService(paths.root
|
|
67
|
+
const service = createEngineService(paths.root);
|
|
51
68
|
let server;
|
|
52
69
|
try {
|
|
53
70
|
server = await startServer(paths.root, service.execute, {
|
|
@@ -100,7 +117,9 @@ export async function main(args) {
|
|
|
100
117
|
return;
|
|
101
118
|
}
|
|
102
119
|
if (command === "status") {
|
|
103
|
-
|
|
120
|
+
const status = await inspectDaemonStatus(root);
|
|
121
|
+
const retiredPolicy = await retiredPolicyBlocker(status.root);
|
|
122
|
+
console.log(JSON.stringify({ ...status, ...(retiredPolicy ? { retiredPolicy } : {}) }));
|
|
104
123
|
return;
|
|
105
124
|
}
|
|
106
125
|
const paths = await runtimePaths(root);
|
|
@@ -69,6 +69,8 @@ export async function hello(paths, identity, signal) {
|
|
|
69
69
|
buildVersion,
|
|
70
70
|
buildId,
|
|
71
71
|
upgradeStop: value.upgradeStop === 1,
|
|
72
|
+
ignoreFilesRetired: value.ignoreFilesRetired === true,
|
|
73
|
+
autonomousSyncRetired: value.autonomousSyncRetired === true,
|
|
72
74
|
needsUpgrade: buildVersion === undefined || lt(buildVersion, DAEMON_BUILD_VERSION),
|
|
73
75
|
};
|
|
74
76
|
}
|
|
@@ -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 {
|
|
4
|
+
import { 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";
|
|
@@ -275,7 +275,6 @@ export class DaemonConnection {
|
|
|
275
275
|
generation,
|
|
276
276
|
birth,
|
|
277
277
|
assertRoot,
|
|
278
|
-
retryOnRefusal: job.result.foregroundQueueCleanup === "resume-adoption",
|
|
279
278
|
};
|
|
280
279
|
return job.result;
|
|
281
280
|
};
|
|
@@ -396,14 +395,7 @@ export class DaemonConnection {
|
|
|
396
395
|
target.assertRoot();
|
|
397
396
|
target.attempted = true;
|
|
398
397
|
const owned = AbortSignal.any([signal, this.controller.signal, AbortSignal.timeout(FOREGROUND_RECOVERY_MS)]);
|
|
399
|
-
|
|
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
|
-
}
|
|
398
|
+
await stopDaemonAfterForegroundQueueFailure(this.paths, this.identity, { ...target, client: this.facts.id }, owned);
|
|
407
399
|
await this.closeLocal();
|
|
408
400
|
target.assertRoot();
|
|
409
401
|
}
|
|
@@ -3,8 +3,6 @@ import { closeSync, fstatSync, fsyncSync, lstatSync, mkdirSync, openSync, readFi
|
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { syncCheckConfigFingerprint } from "./engine/settings/config.js";
|
|
5
5
|
import { stateDir } from "./engine/state/state-directory.js";
|
|
6
|
-
import { startupTransferEnabled } from "./engine/sync/agent-policy.js";
|
|
7
|
-
import { syncSessionsSelected } from "./engine/sync/sync-policy.js";
|
|
8
6
|
import { safeTerminalText } from "./engine/ui/terminal-text.js";
|
|
9
7
|
import { record } from "./protocol.js";
|
|
10
8
|
function file(root) {
|
|
@@ -169,117 +167,10 @@ export function consentFingerprint(root, config) {
|
|
|
169
167
|
throw new Error("Review daemon handover first.");
|
|
170
168
|
// Keep the original digest domain across package renames; never persist the internal freshness token.
|
|
171
169
|
return createHmac("sha256", consent.nonce)
|
|
172
|
-
.update(
|
|
170
|
+
.update("sync-daemon-consent/v1")
|
|
173
171
|
.update(syncCheckConfigFingerprint(config))
|
|
174
172
|
.digest("hex");
|
|
175
173
|
}
|
|
176
|
-
export function automaticPolicyAuthorized(root, config) {
|
|
177
|
-
if (config.reservedIgnoreNames === undefined)
|
|
178
|
-
return true;
|
|
179
|
-
const saved = readConsent(root)?.setups[config.setupName];
|
|
180
|
-
return saved?.automaticFingerprint !== undefined && saved.automaticFingerprint === consentFingerprint(root, config);
|
|
181
|
-
}
|
|
182
|
-
function ignorePublicationConsentLines(config) {
|
|
183
|
-
const policy = config.ignorePolicy;
|
|
184
|
-
if (!policy)
|
|
185
|
-
return [];
|
|
186
|
-
return [
|
|
187
|
-
"Review this file before you approve its scope. Peers must be able to read snapshot version 7.",
|
|
188
|
-
policy.matches(policy.filename)
|
|
189
|
-
? "The rule file excludes itself; new snapshots omit its text."
|
|
190
|
-
: "New snapshots include the rule file, including any rule comments and private path names.",
|
|
191
|
-
];
|
|
192
|
-
}
|
|
193
|
-
export async function reviewAutomaticPolicy(execution, config, expectedFingerprint, origin) {
|
|
194
|
-
if (consentFingerprint(execution.root, config) !== expectedFingerprint)
|
|
195
|
-
throw new Error("Setup changed; reopen the automatic transfer review.");
|
|
196
|
-
if (config.reservedIgnoreNames === undefined || automaticPolicyAuthorized(execution.root, config)) {
|
|
197
|
-
execution.noteDebugOutcome?.("skipped");
|
|
198
|
-
return false;
|
|
199
|
-
}
|
|
200
|
-
const consent = readConsent(execution.root);
|
|
201
|
-
if (!consent) {
|
|
202
|
-
execution.noteDebugOutcome?.("blocked");
|
|
203
|
-
return false;
|
|
204
|
-
}
|
|
205
|
-
const consentToken = JSON.stringify(consent);
|
|
206
|
-
const peers = participantBinding(execution);
|
|
207
|
-
const binding = JSON.stringify(execution.facts());
|
|
208
|
-
const { loadConfigForCheck } = await import("./engine/settings/config.js");
|
|
209
|
-
const fingerprint = syncCheckConfigFingerprint(config);
|
|
210
|
-
const validate = () => {
|
|
211
|
-
execution.validate();
|
|
212
|
-
execution.signal.throwIfAborted();
|
|
213
|
-
if (participantBinding(execution) !== peers ||
|
|
214
|
-
JSON.stringify(execution.facts()) !== binding ||
|
|
215
|
-
JSON.stringify(readConsent(execution.root)) !== consentToken)
|
|
216
|
-
throw new Error("Participants or consent changed during automatic transfer review.");
|
|
217
|
-
};
|
|
218
|
-
const current = await loadConfigForCheck(undefined, execution.signal);
|
|
219
|
-
validate();
|
|
220
|
-
if (syncCheckConfigFingerprint(current) !== fingerprint) {
|
|
221
|
-
execution.noteDebugOutcome?.("blocked");
|
|
222
|
-
return false;
|
|
223
|
-
}
|
|
224
|
-
const modes = [
|
|
225
|
-
startupTransferEnabled(config) && "Automatic transfer at startup",
|
|
226
|
-
config.automatic &&
|
|
227
|
-
syncSessionsSelected(config) &&
|
|
228
|
-
"Push selected files on shutdown (including sessions when selected)",
|
|
229
|
-
config.continuous && config.agentMode && "Continuous sync and Autonomous model requests",
|
|
230
|
-
].filter(Boolean);
|
|
231
|
-
if (modes.length === 0)
|
|
232
|
-
throw new Error("No automatic transfer mode is enabled under the current local rules.");
|
|
233
|
-
const title = "Allow the enabled automatic sync modes for this setup?";
|
|
234
|
-
const lines = [
|
|
235
|
-
`Setup: ${safeTerminalText(config.setupName)}`,
|
|
236
|
-
`Destination: ${safeTerminalText(config.connectionName)} · ${safeTerminalText(config.storagePath)}`,
|
|
237
|
-
...(config.ignorePolicy
|
|
238
|
-
? [
|
|
239
|
-
`Local ignore file: ${safeTerminalText(config.ignorePolicy.filename)}`,
|
|
240
|
-
...ignorePublicationConsentLines(config),
|
|
241
|
-
]
|
|
242
|
-
: []),
|
|
243
|
-
`Enabled modes: ${modes.join("; ")}`,
|
|
244
|
-
"Their usual baseline, remote selection, and ownership checks still apply. This does not allow work after the last Pi exits. A settings or rule-file change requires a new review.",
|
|
245
|
-
];
|
|
246
|
-
if (origin === "retry")
|
|
247
|
-
lines.push("This approval is saved separately from the model retry. Sending conflict evidence again still requires its own confirmation.");
|
|
248
|
-
const content = lines.join("\n");
|
|
249
|
-
const accepted = origin === "retry"
|
|
250
|
-
? await execution.request("merge-review", {
|
|
251
|
-
title,
|
|
252
|
-
content,
|
|
253
|
-
confirmationLabel: "Approve automatic transfers",
|
|
254
|
-
summaryLines: lines,
|
|
255
|
-
})
|
|
256
|
-
: await execution.request("confirm", { title, message: content });
|
|
257
|
-
validate();
|
|
258
|
-
if (accepted !== true) {
|
|
259
|
-
execution.noteDebugOutcome?.("cancelled");
|
|
260
|
-
return false;
|
|
261
|
-
}
|
|
262
|
-
const latest = await loadConfigForCheck(undefined, execution.signal);
|
|
263
|
-
await config.validateIgnorePolicy?.();
|
|
264
|
-
validate();
|
|
265
|
-
if (syncCheckConfigFingerprint(latest) !== fingerprint)
|
|
266
|
-
throw new Error("Setup changed during automatic transfer review.");
|
|
267
|
-
const saved = consent.setups[config.setupName];
|
|
268
|
-
const automaticFingerprint = consentFingerprint(execution.root, config);
|
|
269
|
-
publishConsent({
|
|
270
|
-
...consent,
|
|
271
|
-
setups: {
|
|
272
|
-
...consent.setups,
|
|
273
|
-
[config.setupName]: {
|
|
274
|
-
...saved,
|
|
275
|
-
fingerprint: saved?.fingerprint ?? automaticFingerprint,
|
|
276
|
-
afterExit: saved?.afterExit ?? false,
|
|
277
|
-
automaticFingerprint,
|
|
278
|
-
},
|
|
279
|
-
},
|
|
280
|
-
});
|
|
281
|
-
return true;
|
|
282
|
-
}
|
|
283
174
|
export async function captureAutomaticAuthorization(execution, expectedFingerprint) {
|
|
284
175
|
const consent = readConsent(execution.root);
|
|
285
176
|
if (!consent) {
|
|
@@ -300,14 +191,10 @@ export async function captureAutomaticAuthorization(execution, expectedFingerpri
|
|
|
300
191
|
const config = await loadConfigForCheck(undefined, execution.signal);
|
|
301
192
|
validateParticipants();
|
|
302
193
|
const fingerprint = syncCheckConfigFingerprint(config);
|
|
303
|
-
if (expectedFingerprint !== undefined
|
|
194
|
+
if (expectedFingerprint !== undefined && fingerprint !== expectedFingerprint) {
|
|
304
195
|
execution.noteDebugOutcome?.("blocked");
|
|
305
196
|
throw new Error("Settings changed before automatic work; use the reviewed foreground command.");
|
|
306
197
|
}
|
|
307
|
-
if (!automaticPolicyAuthorized(execution.root, config)) {
|
|
308
|
-
execution.noteDebugOutcome?.("blocked");
|
|
309
|
-
throw new Error("Automatic transfer requires separate approval for the current setup and policy. Run reviewed /sync first.");
|
|
310
|
-
}
|
|
311
198
|
const validate = (current) => {
|
|
312
199
|
validateParticipants();
|
|
313
200
|
if (current && syncCheckConfigFingerprint(current) !== fingerprint) {
|
|
@@ -329,7 +216,7 @@ export async function requireHandover(execution) {
|
|
|
329
216
|
return;
|
|
330
217
|
const accepted = await execution.request("confirm", {
|
|
331
218
|
title: "Adopt pi-sync-daemon as the synchronization owner?",
|
|
332
|
-
message: "Close or upgrade every older Pi process before continuing. An idle older Pi cannot be detected from an absent sync lock. The daemon will own transfers; Pi keeps presentation and live file queues.
|
|
219
|
+
message: "Close or upgrade every older Pi process before continuing. An idle older Pi cannot be detected from an absent sync lock. The daemon will own transfers; Pi keeps presentation and live file queues. This does not authorize new transfers after the last Pi exits.",
|
|
333
220
|
});
|
|
334
221
|
execution.validate();
|
|
335
222
|
if (accepted !== true) {
|
|
@@ -352,6 +239,8 @@ export async function requireHandover(execution) {
|
|
|
352
239
|
export async function authorizeAfterExit(execution, payload) {
|
|
353
240
|
if (!record(payload) || typeof payload.afterExit !== "boolean" || typeof payload.fingerprint !== "string")
|
|
354
241
|
throw new Error("Invalid daemon authorization.");
|
|
242
|
+
if (payload.afterExit)
|
|
243
|
+
throw new Error("Continuous sync was retired. New after-exit grants are not supported.");
|
|
355
244
|
await requireHandover(execution);
|
|
356
245
|
const peers = participantBinding(execution);
|
|
357
246
|
const { loadConfigForCheck } = await import("./engine/settings/config.js");
|
|
@@ -365,27 +254,18 @@ export async function authorizeAfterExit(execution, payload) {
|
|
|
365
254
|
const policyGeneration = JSON.stringify(readConsent(execution.root));
|
|
366
255
|
if (fingerprint !== payload.fingerprint)
|
|
367
256
|
throw new Error("Setup changed; reopen the daemon authorization review.");
|
|
368
|
-
if (payload.afterExit && (!config.continuous || !config.agentMode))
|
|
369
|
-
throw new Error("Enable the reviewed Autonomous and Continuous policies first.");
|
|
370
257
|
const paths = (rules) => rules?.map(safeTerminalText).join(", ") || "none";
|
|
371
|
-
const selection = config.
|
|
258
|
+
const selection = config.scope === "agent-directory"
|
|
372
259
|
? [
|
|
373
|
-
"Selected content: eligible files in the Pi agent directory",
|
|
374
|
-
`
|
|
375
|
-
|
|
376
|
-
`Session opt-in: ${config.
|
|
260
|
+
"Selected content: all eligible files in the Pi agent directory",
|
|
261
|
+
`Excluded paths: ${paths(config.exclude)}`,
|
|
262
|
+
`Re-included paths: ${paths(config.reinclude)}`,
|
|
263
|
+
`Session opt-in: ${config.include.includes("sessions") ? "On — path rules still apply" : "Off"}`,
|
|
377
264
|
].join("\n")
|
|
378
|
-
: config.
|
|
379
|
-
? [
|
|
380
|
-
"Selected content: all eligible files in the Pi agent directory",
|
|
381
|
-
`Excluded paths: ${paths(config.exclude)}`,
|
|
382
|
-
`Re-included paths: ${paths(config.reinclude)}`,
|
|
383
|
-
`Session opt-in: ${config.include.includes("sessions") ? "On — path rules still apply" : "Off"}`,
|
|
384
|
-
].join("\n")
|
|
385
|
-
: `Selected content: ${paths(config.include)}`;
|
|
265
|
+
: `Selected content: ${paths(config.include)}`;
|
|
386
266
|
const accepted = await execution.request("confirm", {
|
|
387
|
-
title:
|
|
388
|
-
message: `Setup: ${safeTerminalText(config.setupName)}\n${selection}\
|
|
267
|
+
title: "Revoke unattended sync?",
|
|
268
|
+
message: `Setup: ${safeTerminalText(config.setupName)}\n${selection}\n\nThis clears the retained after-exit grant without transferring files.`,
|
|
389
269
|
});
|
|
390
270
|
execution.validate();
|
|
391
271
|
if (accepted !== true) {
|
|
@@ -394,7 +274,6 @@ export async function authorizeAfterExit(execution, payload) {
|
|
|
394
274
|
}
|
|
395
275
|
const latest = await loadConfigForCheck(undefined, execution.signal);
|
|
396
276
|
execution.validate();
|
|
397
|
-
await config.validateIgnorePolicy?.();
|
|
398
277
|
execution.validate();
|
|
399
278
|
if (participantBinding(execution) !== peers ||
|
|
400
279
|
consentFingerprint(execution.root, latest) !== fingerprint ||
|
|
@@ -418,7 +297,6 @@ export async function authorizeAfterExit(execution, payload) {
|
|
|
418
297
|
sessionDir: facts?.sessionDir,
|
|
419
298
|
cwd: facts?.cwd,
|
|
420
299
|
afterExit: payload.afterExit,
|
|
421
|
-
...(payload.afterExit && config.reservedIgnoreNames !== undefined ? { automaticFingerprint: fingerprint } : {}),
|
|
422
300
|
},
|
|
423
301
|
},
|
|
424
302
|
});
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import { isUtf8 } from "node:buffer";
|
|
2
1
|
import { createHash, randomUUID } from "node:crypto";
|
|
3
2
|
import fs from "node:fs/promises";
|
|
4
3
|
import path from "node:path";
|
|
5
4
|
import { posixJoin } from "../../paths.js";
|
|
6
5
|
import { snapshotFileFromBlob } from "../../snapshot/snapshot-payload.js";
|
|
7
|
-
import { isIgnoreSnapshotVersion } from "../../snapshot/snapshot-types.js";
|
|
8
6
|
import { stateDir } from "../../state/state-directory.js";
|
|
9
7
|
import { throwIfAborted } from "../../sync/signals.js";
|
|
10
8
|
import { syncErrorGuidance } from "../../sync/sync-error-guidance.js";
|
|
@@ -119,7 +117,6 @@ export class GitSyncBackend {
|
|
|
119
117
|
profile: manifest.profile,
|
|
120
118
|
...(manifest.snapshotSyncSessions === undefined ? {} : { syncSessions: manifest.snapshotSyncSessions }),
|
|
121
119
|
...(manifest.selection === undefined ? {} : { selection: structuredClone(manifest.selection) }),
|
|
122
|
-
...(manifest.ignoreRules === undefined ? {} : { ignoreRules: structuredClone(manifest.ignoreRules) }),
|
|
123
120
|
...(manifest.localFields === undefined ? {} : { localFields: [...manifest.localFields] }),
|
|
124
121
|
files,
|
|
125
122
|
};
|
|
@@ -144,7 +141,6 @@ export class GitSyncBackend {
|
|
|
144
141
|
syncSessions: snapshot.syncSessions === true || snapshot.files.some((file) => file.path.startsWith("sessions/")),
|
|
145
142
|
...(snapshot.syncSessions === undefined ? {} : { snapshotSyncSessions: snapshot.syncSessions }),
|
|
146
143
|
...(snapshot.selection === undefined ? {} : { selection: snapshot.selection }),
|
|
147
|
-
...(snapshot.ignoreRules === undefined ? {} : { ignoreRules: snapshot.ignoreRules }),
|
|
148
144
|
...(snapshot.localFields === undefined ? {} : { localFields: snapshot.localFields }),
|
|
149
145
|
files: files.map(({ path: filePath, sha256: fileSha, size }) => ({
|
|
150
146
|
path: filePath,
|
|
@@ -169,8 +165,8 @@ export class GitSyncBackend {
|
|
|
169
165
|
throw new Error(`Cannot verify the previous Git publication ${observed} in History; remote head was not updated.`, { cause: error });
|
|
170
166
|
}
|
|
171
167
|
}
|
|
172
|
-
if (options.
|
|
173
|
-
await options.
|
|
168
|
+
if (options.validatePublication) {
|
|
169
|
+
await options.validatePublication();
|
|
174
170
|
throwIfAborted(options.signal);
|
|
175
171
|
}
|
|
176
172
|
options.onCommit?.();
|
|
@@ -568,17 +564,15 @@ export class GitSyncBackend {
|
|
|
568
564
|
(await this.git(["show", `${commit}:${this.manifestPath()}`], { signal, maxOutputBytes: MAX_GIT_MANIFEST_BYTES }))
|
|
569
565
|
.stdout;
|
|
570
566
|
const manifest = parseGitManifest(bytes);
|
|
571
|
-
const entries = await this.readPublicationTree(commit, signal
|
|
567
|
+
const entries = await this.readPublicationTree(commit, signal);
|
|
572
568
|
const payloadEntries = validateGitPublicationTree(entries, manifest, this.manifestPath(), (filePath) => this.filePath(filePath));
|
|
573
569
|
return { manifest, payloadEntries };
|
|
574
570
|
}
|
|
575
|
-
async readPublicationTree(commit, signal
|
|
571
|
+
async readPublicationTree(commit, signal) {
|
|
576
572
|
const result = await this.git(["ls-tree", "-r", "-z", commit], {
|
|
577
573
|
signal,
|
|
578
574
|
maxOutputBytes: MAX_GIT_TREE_OUTPUT_BYTES,
|
|
579
575
|
});
|
|
580
|
-
if (strictUtf8 && !isUtf8(result.stdout))
|
|
581
|
-
throw new Error("Git snapshot tree paths must be valid UTF-8.");
|
|
582
576
|
return parseGitTree(result.stdout);
|
|
583
577
|
}
|
|
584
578
|
redactedError(error) {
|
|
@@ -632,13 +626,6 @@ function parseGitManifest(bytes) {
|
|
|
632
626
|
catch (error) {
|
|
633
627
|
throw new Error("Git publication manifest is malformed.", { cause: error });
|
|
634
628
|
}
|
|
635
|
-
if (parsed &&
|
|
636
|
-
typeof parsed === "object" &&
|
|
637
|
-
"snapshotVersion" in parsed &&
|
|
638
|
-
isIgnoreSnapshotVersion(parsed.snapshotVersion) &&
|
|
639
|
-
!isUtf8(bytes)) {
|
|
640
|
-
throw new Error("Git publication manifest is not valid UTF-8.");
|
|
641
|
-
}
|
|
642
629
|
return requireGitManifest(parsed);
|
|
643
630
|
}
|
|
644
631
|
function remoteHead(sha, manifest, identity) {
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import { validateSnapshotIgnoreRules } from "../../ignore/snapshot-ignore-rules.js";
|
|
2
|
-
import { assertAgentDirectorySettingsSize, MAX_AGENT_DIRECTORY_BYTES } from "../../snapshot/snapshot-bounds.js";
|
|
3
1
|
import { materializeSnapshotFilePayload } from "../../snapshot/snapshot-payload.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { assertAgentDirectoryPathLayout, assertSnapshotExcludesDebugLog, assertSnapshotPathExcludesDebugLog, configuredSnapshotPathMatcher, portableSnapshotSelection, sameSnapshotSelection, snapshotSelectionInclude, validateSnapshotSelection, } from "../../sync/sync-policy.js";
|
|
2
|
+
import { sameLocalFields, validatePortableSnapshot, validateSnapshotFieldPolicy } from "../../sync/local-fields.js";
|
|
3
|
+
import { assertAgentDirectoryPathLayout, assertSnapshotExcludesDebugLog, assertSnapshotPathExcludesDebugLog, configuredSnapshotPathMatcher, portableSnapshotSelection, requireLegacyTransferPolicy, sameSnapshotSelection, validateSnapshotSelection, } from "../../sync/sync-policy.js";
|
|
7
4
|
export const GIT_MANIFEST_VERSION = 2;
|
|
8
5
|
export const MAX_GIT_MANIFEST_BYTES = 1024 * 1024;
|
|
9
6
|
export const MAX_GIT_TREE_OUTPUT_BYTES = 16 * 1024 * 1024;
|
|
@@ -17,11 +14,16 @@ export function requireGitManifest(value) {
|
|
|
17
14
|
throw new Error("Git publication manifest is malformed.");
|
|
18
15
|
}
|
|
19
16
|
const manifest = value;
|
|
17
|
+
requireLegacyTransferPolicy({ version: manifest.snapshotVersion, selection: manifest.selection });
|
|
20
18
|
if (manifest.version === 1) {
|
|
21
19
|
throw new Error("Git publication uses the unsupported pre-release gzip format; recreate this pi-sync-owned test branch.");
|
|
22
20
|
}
|
|
23
21
|
if (manifest.version !== GIT_MANIFEST_VERSION ||
|
|
24
|
-
|
|
22
|
+
(manifest.snapshotVersion !== 1 &&
|
|
23
|
+
manifest.snapshotVersion !== 2 &&
|
|
24
|
+
manifest.snapshotVersion !== 3 &&
|
|
25
|
+
manifest.snapshotVersion !== 4 &&
|
|
26
|
+
manifest.snapshotVersion !== 5) ||
|
|
25
27
|
typeof manifest.snapshotId !== "string" ||
|
|
26
28
|
manifest.snapshotId.length > 512 ||
|
|
27
29
|
!/^[A-Za-z0-9._-]+$/u.test(manifest.snapshotId) ||
|
|
@@ -49,7 +51,6 @@ export function requireGitManifest(value) {
|
|
|
49
51
|
"syncSessions",
|
|
50
52
|
...(manifest.snapshotSyncSessions === undefined ? [] : ["snapshotSyncSessions"]),
|
|
51
53
|
...(manifest.selection === undefined ? [] : ["selection"]),
|
|
52
|
-
...(Object.hasOwn(manifest, "ignoreRules") ? ["ignoreRules"] : []),
|
|
53
54
|
...(manifest.localFields === undefined ? [] : ["localFields"]),
|
|
54
55
|
"files",
|
|
55
56
|
])) {
|
|
@@ -58,27 +59,8 @@ export function requireGitManifest(value) {
|
|
|
58
59
|
validateSnapshotFieldPolicy({ version: manifest.snapshotVersion, localFields: manifest.localFields });
|
|
59
60
|
const selection = manifest.selection === undefined ? undefined : portableSnapshotSelection(manifest.selection);
|
|
60
61
|
validateSnapshotSelection({ version: manifest.snapshotVersion, selection });
|
|
61
|
-
const
|
|
62
|
-
version: manifest.snapshotVersion,
|
|
63
|
-
selection,
|
|
64
|
-
...(Object.hasOwn(manifest, "ignoreRules") ? { ignoreRules: manifest.ignoreRules } : {}),
|
|
65
|
-
});
|
|
66
|
-
const ignoreSnapshot = selection?.version === 4;
|
|
67
|
-
if (ignoreSnapshot) {
|
|
68
|
-
validateIgnoreSnapshotIdentity({
|
|
69
|
-
id: manifest.snapshotId,
|
|
70
|
-
createdAt: manifest.createdAt,
|
|
71
|
-
machine: manifest.machine,
|
|
72
|
-
profile: manifest.profile,
|
|
73
|
-
});
|
|
74
|
-
validateIgnoreSnapshotSessionFlag(selection, manifest.snapshotSyncSessions);
|
|
75
|
-
}
|
|
76
|
-
const selected = selection?.scope
|
|
77
|
-
? configuredSnapshotPathMatcher(policy ? { ...selection, ignorePolicy: policy } : selection)
|
|
78
|
-
: undefined;
|
|
79
|
-
const byteLimit = ignoreSnapshot ? MAX_AGENT_DIRECTORY_BYTES : MAX_GIT_SNAPSHOT_BYTES;
|
|
62
|
+
const selected = selection?.scope ? configuredSnapshotPathMatcher(selection) : undefined;
|
|
80
63
|
let total = 0;
|
|
81
|
-
let hasSessionFiles = false;
|
|
82
64
|
const paths = new Set();
|
|
83
65
|
for (const rawFile of manifest.files) {
|
|
84
66
|
if (!rawFile || typeof rawFile !== "object" || Array.isArray(rawFile)) {
|
|
@@ -90,7 +72,6 @@ export function requireGitManifest(value) {
|
|
|
90
72
|
!isSafeSnapshotPath(file.path) ||
|
|
91
73
|
(selected !== undefined && !selected(file.path)) ||
|
|
92
74
|
typeof file.sha256 !== "string" ||
|
|
93
|
-
(ignoreSnapshot && file.sha256.length !== 64) ||
|
|
94
75
|
!/^[0-9a-f]{64}$/u.test(file.sha256) ||
|
|
95
76
|
typeof file.size !== "number" ||
|
|
96
77
|
!isGitPayloadSizeAllowed(file.size) ||
|
|
@@ -98,20 +79,11 @@ export function requireGitManifest(value) {
|
|
|
98
79
|
throw new Error("Git publication manifest file is malformed.");
|
|
99
80
|
}
|
|
100
81
|
total += file.size;
|
|
101
|
-
if (!Number.isSafeInteger(total) || total >
|
|
102
|
-
throw new Error(`Git snapshot content exceeds the ${
|
|
103
|
-
}
|
|
104
|
-
if (ignoreSnapshot) {
|
|
105
|
-
if (file.path === "settings.json")
|
|
106
|
-
assertAgentDirectorySettingsSize(file.size);
|
|
107
|
-
if (file.path.startsWith("sessions/"))
|
|
108
|
-
hasSessionFiles = true;
|
|
82
|
+
if (!Number.isSafeInteger(total) || total > MAX_GIT_SNAPSHOT_BYTES) {
|
|
83
|
+
throw new Error(`Git snapshot content exceeds the ${MAX_GIT_SNAPSHOT_BYTES}-byte limit.`);
|
|
109
84
|
}
|
|
110
85
|
paths.add(file.path);
|
|
111
86
|
}
|
|
112
|
-
if (ignoreSnapshot && manifest.syncSessions !== (manifest.snapshotSyncSessions === true || hasSessionFiles)) {
|
|
113
|
-
throw new Error("Invalid Git ignore snapshot session metadata.");
|
|
114
|
-
}
|
|
115
87
|
if (selected)
|
|
116
88
|
assertAgentDirectoryPathLayout(paths);
|
|
117
89
|
else
|
|
@@ -130,9 +102,6 @@ export function validateGitSnapshot(snapshot, manifest, namespace) {
|
|
|
130
102
|
snapshot.syncSessions !== manifest.snapshotSyncSessions ||
|
|
131
103
|
syncSessions !== manifest.syncSessions ||
|
|
132
104
|
!sameSnapshotSelection(snapshot.selection, manifest.selection) ||
|
|
133
|
-
(snapshot.ignoreRules === null) !== (manifest.ignoreRules === null) ||
|
|
134
|
-
snapshot.ignoreRules?.filename !== manifest.ignoreRules?.filename ||
|
|
135
|
-
snapshot.ignoreRules?.text !== manifest.ignoreRules?.text ||
|
|
136
105
|
prepared.length !== manifest.files.length ||
|
|
137
106
|
prepared.some((file, index) => {
|
|
138
107
|
const expected = manifest.files[index];
|
|
@@ -143,8 +112,6 @@ export function validateGitSnapshot(snapshot, manifest, namespace) {
|
|
|
143
112
|
}
|
|
144
113
|
export function prepareGitSnapshot(snapshot, namespace) {
|
|
145
114
|
assertSnapshotExcludesDebugLog(snapshot);
|
|
146
|
-
if (!isIgnoreSnapshotVersion(snapshot.version))
|
|
147
|
-
snapshotSelectionInclude(snapshot);
|
|
148
115
|
validatePortableSnapshot(snapshot);
|
|
149
116
|
if (typeof snapshot.id !== "string" ||
|
|
150
117
|
!snapshot.id ||
|
|
@@ -78,16 +78,16 @@ export class S3SyncBackend {
|
|
|
78
78
|
throwIfAborted(options.signal);
|
|
79
79
|
const image = capturePublicationImage(snapshot);
|
|
80
80
|
assertSnapshotIdentity(image, this.config.destination.namespace);
|
|
81
|
-
if (options.
|
|
82
|
-
await options.
|
|
81
|
+
if (options.validatePublication)
|
|
82
|
+
await options.validatePublication();
|
|
83
83
|
throwIfAborted(options.signal);
|
|
84
84
|
const encoded = await encodeForPublication(image, () => verifyS3Conditions(this.config, options.signal));
|
|
85
85
|
throwIfAborted(options.signal);
|
|
86
86
|
const stagedKey = snapshotKey(this.config, image.id);
|
|
87
87
|
const pointer = pointerFor(this.config, image, sha256(encoded));
|
|
88
88
|
const cancellableClient = new S3Client(this.config, options.signal);
|
|
89
|
-
if (options.
|
|
90
|
-
await options.
|
|
89
|
+
if (options.validatePublication)
|
|
90
|
+
await options.validatePublication();
|
|
91
91
|
throwIfAborted(options.signal);
|
|
92
92
|
try {
|
|
93
93
|
await cancellableClient.putBuffer(stagedKey, encoded, "application/gzip", {
|
|
@@ -126,8 +126,8 @@ export class S3SyncBackend {
|
|
|
126
126
|
throw new Error(`Cannot verify the previous remote snapshot ${current.snapshotId} in History; remote head was not updated.`, { cause: error });
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
|
-
if (options.
|
|
130
|
-
await options.
|
|
129
|
+
if (options.validatePublication)
|
|
130
|
+
await options.validatePublication();
|
|
131
131
|
throwIfAborted(options.signal);
|
|
132
132
|
options.onCommit?.();
|
|
133
133
|
// The active-head PUT is the publication boundary. Do not bind it or its
|
|
@@ -61,8 +61,8 @@ export class WebDavSyncBackend {
|
|
|
61
61
|
throwIfAborted(options.signal);
|
|
62
62
|
const image = capturePublicationImage(snapshot);
|
|
63
63
|
assertSnapshotIdentity(image, this.config.destination.namespace);
|
|
64
|
-
if (options.
|
|
65
|
-
await options.
|
|
64
|
+
if (options.validatePublication)
|
|
65
|
+
await options.validatePublication();
|
|
66
66
|
throwIfAborted(options.signal);
|
|
67
67
|
const client = new WebDavClient(this.config, options.signal);
|
|
68
68
|
const encoded = await encodeForPublication(image, async () => {
|
|
@@ -72,8 +72,8 @@ export class WebDavSyncBackend {
|
|
|
72
72
|
throwIfAborted(options.signal);
|
|
73
73
|
const pointer = createLatestPointer(this.config.destination.namespace, image, sha256(encoded));
|
|
74
74
|
const stagedPath = snapshotPath(this.config, image.id);
|
|
75
|
-
if (options.
|
|
76
|
-
await options.
|
|
75
|
+
if (options.validatePublication)
|
|
76
|
+
await options.validatePublication();
|
|
77
77
|
throwIfAborted(options.signal);
|
|
78
78
|
try {
|
|
79
79
|
await client.putBuffer(stagedPath, encoded, "application/gzip", { ifAbsent: true });
|
|
@@ -109,8 +109,8 @@ export class WebDavSyncBackend {
|
|
|
109
109
|
throw new Error(`Cannot verify the previous remote snapshot ${current.snapshotId} in History; remote head was not updated.`, { cause: error });
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
|
-
if (options.
|
|
113
|
-
await options.
|
|
112
|
+
if (options.validatePublication)
|
|
113
|
+
await options.validatePublication();
|
|
114
114
|
throwIfAborted(options.signal);
|
|
115
115
|
options.onCommit?.();
|
|
116
116
|
const commitClient = new WebDavClient(this.config, AbortSignal.timeout(this.postCommitTimeoutMs), this.postCommitTimeoutMs);
|