@narumitw/pi-sync 0.65.0 → 0.66.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 +10 -0
- package/README.md +4 -4
- package/dist/chunks/{chunk-OWEOZZZE.ts → chunk-5YOLQKNZ.ts} +38 -2
- package/dist/chunks/chunk-5YOLQKNZ.ts.map +7 -0
- package/dist/chunks/{chunk-OBVJTKVY.ts → chunk-ASU3GZPW.ts} +10 -92
- package/dist/chunks/chunk-ASU3GZPW.ts.map +7 -0
- package/dist/chunks/{chunk-IOM6E5FW.ts → chunk-BESRBKVO.ts} +2 -2
- package/dist/chunks/{chunk-TZMVSTAM.ts → chunk-BYVHABNR.ts} +4 -4
- package/dist/chunks/chunk-ECYCNZOE.ts +12 -0
- package/dist/chunks/chunk-ECYCNZOE.ts.map +7 -0
- package/dist/chunks/{chunk-MANNB4WZ.ts → chunk-KNEUL4XN.ts} +1 -7
- package/dist/chunks/chunk-KNEUL4XN.ts.map +7 -0
- package/dist/chunks/chunk-Z5JMOXJM.ts +106 -0
- package/dist/chunks/chunk-Z5JMOXJM.ts.map +7 -0
- package/dist/chunks/{command-handler-YZ4DXQ7N.ts → command-handler-44EFGPWH.ts} +9 -7
- package/dist/chunks/{command-handler-YZ4DXQ7N.ts.map → command-handler-44EFGPWH.ts.map} +1 -1
- package/dist/chunks/{file-selection-DDQN4LVD.ts → file-selection-XWACUTAH.ts} +8 -8
- package/dist/chunks/ignore-file-ui-OHFISFVC.ts +21 -0
- package/dist/chunks/{manager-result-dispatcher-XB75YLEG.ts → manager-result-dispatcher-WXE2BAQO.ts} +3 -3
- package/dist/chunks/{manager-ui-RGA26Z6G.ts → manager-ui-CVZLMXJ5.ts} +57 -45
- package/dist/chunks/manager-ui-CVZLMXJ5.ts.map +7 -0
- package/dist/chunks/{remote-selection-ui-WVMET5RI.ts → remote-selection-ui-E4XZCQ7A.ts} +2 -2
- package/dist/chunks/remote-selection-ui-E4XZCQ7A.ts.map +7 -0
- package/dist/chunks/{setup-wizard-YP2KF2WQ.ts → setup-wizard-IEW56AZE.ts} +7 -5
- package/dist/chunks/{setup-wizard-YP2KF2WQ.ts.map → setup-wizard-IEW56AZE.ts.map} +1 -1
- package/dist/daemon/dist/consent.js +14 -2
- package/dist/daemon/dist/engine/backends/git/git-backend.js +5 -3
- package/dist/daemon/dist/engine/backends/git/git-storage.js +15 -3
- package/dist/daemon/dist/engine/ignore/adoption-journal.js +143 -0
- package/dist/daemon/dist/engine/ignore/snapshot-ignore-rules.js +39 -0
- package/dist/daemon/dist/engine/snapshot/snapshot-apply.js +2 -2
- package/dist/daemon/dist/engine/snapshot/snapshot-codec.js +6 -6
- package/dist/daemon/dist/engine/snapshot/snapshot-types.js +5 -1
- package/dist/daemon/dist/engine/snapshot/snapshot.js +5 -2
- package/dist/daemon/dist/engine/sync/conflict-review.js +2 -0
- package/dist/daemon/dist/engine/sync/continuous-watch.js +3 -2
- package/dist/daemon/dist/engine/sync/directional-action.js +3 -8
- package/dist/daemon/dist/engine/sync/ignore-adoption-recovery.js +50 -0
- package/dist/daemon/dist/engine/sync/ignore-adoption.js +401 -0
- package/dist/daemon/dist/engine/sync/ignore-publication.js +23 -0
- package/dist/daemon/dist/engine/sync/initialization.js +12 -0
- package/dist/daemon/dist/engine/sync/local-fields.js +6 -3
- package/dist/daemon/dist/engine/sync/merge-journal.js +2 -2
- package/dist/daemon/dist/engine/sync/merged-sync.js +14 -3
- package/dist/daemon/dist/engine/sync/sync-local.js +2 -1
- package/dist/daemon/dist/engine/sync/sync-mutations.js +82 -19
- package/dist/daemon/dist/engine/sync/sync-policy.js +5 -5
- package/dist/daemon/dist/engine/sync/sync-queries.js +1 -1
- package/dist/daemon/dist/engine/sync/sync-rollback.js +9 -3
- package/dist/daemon/dist/engine/ui/ignore-rule-preview.js +18 -0
- package/dist/daemon/dist/engine-service.js +1 -1
- package/dist/daemon/package.json +1 -1
- package/dist/index.ts +1 -1
- package/docs/tui-contract.md +3 -3
- package/package.json +2 -2
- package/skills/configure-pi-sync/references/configuration.md +10 -8
- package/src/ui/ignore-file-ui.ts +13 -5
- package/src/ui/manager-state.ts +15 -8
- package/src/ui/manager-ui.ts +1 -1
- package/src/ui/remote-selection-ui.ts +43 -2
- package/src/ui/settings-ui.ts +30 -30
- package/dist/chunks/chunk-MANNB4WZ.ts.map +0 -7
- package/dist/chunks/chunk-OBVJTKVY.ts.map +0 -7
- package/dist/chunks/chunk-OWEOZZZE.ts.map +0 -7
- package/dist/chunks/manager-ui-RGA26Z6G.ts.map +0 -7
- /package/dist/chunks/{chunk-IOM6E5FW.ts.map → chunk-BESRBKVO.ts.map} +0 -0
- /package/dist/chunks/{chunk-TZMVSTAM.ts.map → chunk-BYVHABNR.ts.map} +0 -0
- /package/dist/chunks/{file-selection-DDQN4LVD.ts.map → file-selection-XWACUTAH.ts.map} +0 -0
- /package/dist/chunks/{manager-result-dispatcher-XB75YLEG.ts.map → ignore-file-ui-OHFISFVC.ts.map} +0 -0
- /package/dist/chunks/{remote-selection-ui-WVMET5RI.ts.map → manager-result-dispatcher-WXE2BAQO.ts.map} +0 -0
|
@@ -0,0 +1,401 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import { lstatSync, renameSync, statSync } from "node:fs";
|
|
3
|
+
import fs from "node:fs/promises";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import { getEngineRoot, withEngineMutationQueue } from "../host.js";
|
|
6
|
+
import { completeAdoptionJournal, createAdoptionJournal, recordInstalledIdentity, verifyAdoptionBackup, } from "../ignore/adoption-journal.js";
|
|
7
|
+
import { DEFAULT_IGNORE_FILENAME, ignoreFileIdentity, ignorePolicyFingerprint, ignoreSourceDigest, readIgnoreSource, sameFile, } from "../ignore/ignore-source.js";
|
|
8
|
+
import { validateSnapshotIgnoreRules } from "../ignore/snapshot-ignore-rules.js";
|
|
9
|
+
import { loadConfigForCheck, syncConfigReviewFingerprint, syncSettingsConfigFingerprint } from "../settings/config.js";
|
|
10
|
+
import { readActiveLocalConfigDocumentForRepair, withLockedLocalConfigDocument } from "../settings/config-file.js";
|
|
11
|
+
import { validateSettingsDocument } from "../settings/settings-validation.js";
|
|
12
|
+
import { effectiveSessionRoot, requireStableMergeSessionRoot } from "../snapshot/session-paths.js";
|
|
13
|
+
import { createSnapshot, filterSnapshotForConfigPolicy, regenerateSnapshotIdentity } from "../snapshot/snapshot.js";
|
|
14
|
+
import { appliedFileHashMap, applySnapshot } from "../snapshot/snapshot-apply.js";
|
|
15
|
+
import { recoverPendingSnapshotTransactions } from "../snapshot/snapshot-transaction.js";
|
|
16
|
+
import { pendingTransactionEntries } from "../snapshot/snapshot-transaction-directory.js";
|
|
17
|
+
import { syncDirectory } from "../state/json-file.js";
|
|
18
|
+
import { readStateForConfig, syncStateFingerprint, writeStateForConfig } from "../state/sync-state-store.js";
|
|
19
|
+
import { formatRuleChanges } from "../ui/ignore-rule-preview.js";
|
|
20
|
+
import { formatPullSummary, formatTransferReview } from "../ui/sync-format.js";
|
|
21
|
+
import { snapshotPathLabel } from "../ui/terminal-text.js";
|
|
22
|
+
import { confirmTransferReview } from "../ui/transfer-review.js";
|
|
23
|
+
import { inspectCaseCleanup, revalidateCaseCleanup } from "./apply-review.js";
|
|
24
|
+
import { checkpointDirectionalAction, localRestoreGuidance, notifyDirectionalSuccess } from "./directional-action.js";
|
|
25
|
+
import { overlayLocalFields, portableSnapshot, sameLocalFields } from "./local-fields.js";
|
|
26
|
+
import { readMergeJournal } from "./merge-journal.js";
|
|
27
|
+
import { readSnapshotForHead, sameRemoteHead } from "./remote-snapshot.js";
|
|
28
|
+
import { backupDirectionalSnapshot, captureMutationOwner, maybeReload, protectedSessionPaths } from "./sync-local.js";
|
|
29
|
+
import { acceptedSelection, fileHashMap, rawSnapshotHashIdentity, sameHashes } from "./sync-state.js";
|
|
30
|
+
import { checkLiveProtection } from "./transfer-freshness.js";
|
|
31
|
+
export function canReviewAdoption(ctx, options) {
|
|
32
|
+
return (ctx.hasUI &&
|
|
33
|
+
(ctx.mode === "tui" || ctx.mode === "rpc") &&
|
|
34
|
+
!options.auto &&
|
|
35
|
+
!options.background &&
|
|
36
|
+
!options.yes &&
|
|
37
|
+
!options.agentRetryRefusal);
|
|
38
|
+
}
|
|
39
|
+
export function adoptionSettingsFingerprint(config) {
|
|
40
|
+
return syncConfigReviewFingerprint({ ...config, ignorePolicy: undefined, ignoreSourceIdentity: undefined });
|
|
41
|
+
}
|
|
42
|
+
function scopeChangeReview(label, paths) {
|
|
43
|
+
if (!paths.length)
|
|
44
|
+
return { lines: [], content: "" };
|
|
45
|
+
return {
|
|
46
|
+
lines: [`${label}: ${paths.length} file(s). View details for paths.`],
|
|
47
|
+
content: paths.map((name) => `${label}: ${snapshotPathLabel(name)}`).join("\n"),
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
async function assertDedicatedSource(config, filename) {
|
|
51
|
+
const doc = await readActiveLocalConfigDocumentForRepair();
|
|
52
|
+
if (!doc)
|
|
53
|
+
throw new Error("Sync setup no longer exists; reopen Pull.");
|
|
54
|
+
const settings = validateSettingsDocument(doc.parsed);
|
|
55
|
+
if (Object.entries(settings.syncSetups).some(([name, setup]) => name !== config.setupName &&
|
|
56
|
+
setup.sync.pathPolicy === "ignore-file" &&
|
|
57
|
+
(setup.sync.ignoreFile ?? DEFAULT_IGNORE_FILENAME).toLowerCase() === filename.toLowerCase()))
|
|
58
|
+
throw new Error("The ignore file is shared by other setups. Select a dedicated rule file before Pull.");
|
|
59
|
+
return doc;
|
|
60
|
+
}
|
|
61
|
+
function assertNotLiveRuleTarget(ctx, target, identity) {
|
|
62
|
+
const live = [...(ctx.protectedSessionFiles ?? []), ctx.sessionManager.getSessionFile?.()];
|
|
63
|
+
for (const entry of live) {
|
|
64
|
+
if (!entry)
|
|
65
|
+
continue;
|
|
66
|
+
const stat = statSync(entry, { bigint: true, throwIfNoEntry: false });
|
|
67
|
+
if (path.resolve(entry) === target || (stat && ignoreFileIdentity(stat) === identity))
|
|
68
|
+
throw new Error("The rule file is a protected live session; Pull cannot replace it.");
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
export async function adoptRemoteRules(input) {
|
|
72
|
+
const { ctx, options, config, state, backend, head, remote, snapshotOptions, validateMutation } = input;
|
|
73
|
+
const signal = options.signal;
|
|
74
|
+
const validateCommittedOwner = captureMutationOwner(ctx);
|
|
75
|
+
if (!canReviewAdoption(ctx, options) || !config.ignorePolicy)
|
|
76
|
+
throw new Error("Rule adoption requires a reviewed foreground Pull.");
|
|
77
|
+
const remotePolicy = validateSnapshotIgnoreRules(remote);
|
|
78
|
+
if (!remotePolicy || !remote.ignoreRules) {
|
|
79
|
+
throw new Error(remote.ignoreRules === null
|
|
80
|
+
? "Remote rules exclude their own file. Match the publisher's rules manually before Pull."
|
|
81
|
+
: "Remote snapshot does not contain rule text. Match the publisher's rules or publish a new snapshot first.");
|
|
82
|
+
}
|
|
83
|
+
const { text } = remote.ignoreRules;
|
|
84
|
+
const { filename, sessions, reservedNames } = config.ignorePolicy;
|
|
85
|
+
if (sessions !== remotePolicy.sessions)
|
|
86
|
+
throw new Error("Sessions opt-in differs. Review your local Sessions setting and reopen Pull.");
|
|
87
|
+
if (remotePolicy.matches(filename))
|
|
88
|
+
throw new Error("The remote rules exclude this setup's rule filename. Review a matching rule filename before Pull.");
|
|
89
|
+
if (!sameLocalFields(config.localFields, remote.localFields))
|
|
90
|
+
throw new Error("Machine-local field policy differs. Match that policy before adopting remote ignore rules.");
|
|
91
|
+
const root = getEngineRoot();
|
|
92
|
+
const target = path.join(root, filename);
|
|
93
|
+
const source = await readIgnoreSource(root, filename, signal);
|
|
94
|
+
if (!source.present ||
|
|
95
|
+
source.identity !== config.ignoreSourceIdentity ||
|
|
96
|
+
source.sourceDigest !== config.ignorePolicy.sourceDigest)
|
|
97
|
+
throw new Error("Local ignore source changed; reopen Pull.");
|
|
98
|
+
const doc = await assertDedicatedSource(config, filename);
|
|
99
|
+
validateMutation();
|
|
100
|
+
assertNotLiveRuleTarget(ctx, target, source.identity);
|
|
101
|
+
if (state.unresolved?.length || (await readMergeJournal(config)))
|
|
102
|
+
throw new Error("Resolve or recover pending merge work before adopting rules.");
|
|
103
|
+
const adoptedPolicy = {
|
|
104
|
+
...remotePolicy,
|
|
105
|
+
filename,
|
|
106
|
+
reservedNames,
|
|
107
|
+
sourceDigest: ignoreSourceDigest(filename, true, Buffer.from(text)),
|
|
108
|
+
};
|
|
109
|
+
const setupFingerprint = adoptionSettingsFingerprint(config);
|
|
110
|
+
const settingsFreshness = syncSettingsConfigFingerprint(config);
|
|
111
|
+
const stateFingerprint = syncStateFingerprint(state);
|
|
112
|
+
const sessionDir = snapshotOptions.sessionDir;
|
|
113
|
+
const protectedPaths = protectedSessionPaths(ctx, sessionDir);
|
|
114
|
+
const remoteFilesIdentity = rawSnapshotHashIdentity(remote);
|
|
115
|
+
const resuming = input.journal !== undefined;
|
|
116
|
+
let current = input.journal;
|
|
117
|
+
if (current &&
|
|
118
|
+
(current.setupName !== config.setupName ||
|
|
119
|
+
current.setupFingerprint !== setupFingerprint ||
|
|
120
|
+
current.filename !== filename ||
|
|
121
|
+
current.afterRules !== text ||
|
|
122
|
+
current.remoteFilesIdentity !== remoteFilesIdentity ||
|
|
123
|
+
current.sessionDir !== sessionDir ||
|
|
124
|
+
!sameRemoteHead(backend, current.head, head) ||
|
|
125
|
+
(source.text === text
|
|
126
|
+
? current.installedIdentity !== source.identity
|
|
127
|
+
: current.beforeRules !== source.text || current.sourceIdentity !== source.identity)))
|
|
128
|
+
throw new Error("Pending rule adoption no longer matches this setup, source, or remote. Preserve its journal.");
|
|
129
|
+
if (!current && (await pendingTransactionEntries()).length)
|
|
130
|
+
throw new Error("Recover the pending file transaction before adopting rules.");
|
|
131
|
+
const policyConfig = { ...config, ignorePolicy: adoptedPolicy };
|
|
132
|
+
const validateSource = async () => {
|
|
133
|
+
validateMutation();
|
|
134
|
+
const latest = await loadConfigForCheck(config.setupName, signal);
|
|
135
|
+
validateMutation();
|
|
136
|
+
if (getEngineRoot() !== root ||
|
|
137
|
+
latest.configDocumentFingerprint !== config.configDocumentFingerprint ||
|
|
138
|
+
syncSettingsConfigFingerprint(latest) !== settingsFreshness ||
|
|
139
|
+
latest.ignoreSourceIdentity !== source.identity ||
|
|
140
|
+
latest.ignorePolicy?.sourceDigest !== source.sourceDigest)
|
|
141
|
+
throw new Error("Local rules or settings changed during Pull; reopen the review.");
|
|
142
|
+
assertNotLiveRuleTarget(ctx, target, source.identity);
|
|
143
|
+
checkLiveProtection(ctx, sessionDir, protectedPaths);
|
|
144
|
+
};
|
|
145
|
+
const projected = {
|
|
146
|
+
...snapshotOptions,
|
|
147
|
+
ignorePolicy: adoptedPolicy,
|
|
148
|
+
ignoreSourceIdentity: current?.sourceIdentity ?? source.identity,
|
|
149
|
+
validateMutation,
|
|
150
|
+
validateIgnorePolicy: validateSource,
|
|
151
|
+
};
|
|
152
|
+
const logical = portableSnapshot(filterSnapshotForConfigPolicy(remote, policyConfig, projected), config.localFields);
|
|
153
|
+
let before = await createSnapshot(config.snapshotIdentity, projected);
|
|
154
|
+
let physical = overlayLocalFields(logical, before, config.localFields);
|
|
155
|
+
const prior = current ? undefined : await createSnapshot(config.snapshotIdentity, snapshotOptions);
|
|
156
|
+
const beforePaths = new Set(before.files.map((file) => file.path));
|
|
157
|
+
const priorPaths = new Set(prior?.files.map((file) => file.path));
|
|
158
|
+
const left = prior?.files.filter((file) => !beforePaths.has(file.path)).map((file) => file.path) ?? [];
|
|
159
|
+
const incomingPaths = new Set(physical.files.map((file) => file.path));
|
|
160
|
+
const newlyRemoved = before.files
|
|
161
|
+
.filter((file) => !priorPaths.has(file.path) && !protectedPaths.has(file.path) && !incomingPaths.has(file.path))
|
|
162
|
+
.map((file) => file.path);
|
|
163
|
+
const caseCleanup = current ? [] : await inspectCaseCleanup(physical, projected);
|
|
164
|
+
requireStableMergeSessionRoot(before, physical, config.scope);
|
|
165
|
+
await validateSource();
|
|
166
|
+
const approved = await confirmTransferReview(ctx, current ? "Resume reviewed ignore-rule Pull?" : "Overwrite local rules and pull?", formatTransferReview(`Local rule file: ${snapshotPathLabel(target)}. The remote will not change.`, `Sessions opt-in: ${sessions ? "on" : "off"} (unchanged).`, ...(current
|
|
167
|
+
? ["Resume from the recorded snapshot, not the current remote head. Local evidence must still match."]
|
|
168
|
+
: []), formatPullSummary(policyConfig, backend.destination, before, physical, protectedPaths, caseCleanup.map((item) => item.path)), ...(left.length ? [scopeChangeReview("Now excluded; leave local", left)] : []), ...(!current && newlyRemoved.length ? [scopeChangeReview("Newly selected; remove locally", newlyRemoved)] : []), formatRuleChanges(current?.beforeRules ?? source.text, text)), signal, validateMutation);
|
|
169
|
+
if (!approved)
|
|
170
|
+
return "cancelled";
|
|
171
|
+
await checkpointDirectionalAction(options, {
|
|
172
|
+
direction: "pull",
|
|
173
|
+
config,
|
|
174
|
+
state,
|
|
175
|
+
local: before,
|
|
176
|
+
remote,
|
|
177
|
+
head,
|
|
178
|
+
sessionDir,
|
|
179
|
+
protectedPaths,
|
|
180
|
+
});
|
|
181
|
+
validateMutation();
|
|
182
|
+
const validateHead = async () => {
|
|
183
|
+
if (resuming)
|
|
184
|
+
return;
|
|
185
|
+
const latestHead = await backend.readHead(signal);
|
|
186
|
+
validateMutation();
|
|
187
|
+
if (!sameRemoteHead(backend, head, latestHead))
|
|
188
|
+
throw new Error("Remote changed during Pull; reopen the review.");
|
|
189
|
+
};
|
|
190
|
+
const validateContext = async () => {
|
|
191
|
+
await validateHead();
|
|
192
|
+
if ((await effectiveSessionRoot(ctx, config, signal)) !== sessionDir)
|
|
193
|
+
throw new Error("Session storage changed; reopen Pull.");
|
|
194
|
+
await validateSource();
|
|
195
|
+
};
|
|
196
|
+
const latest = await readSnapshotForHead(backend, head, signal, config);
|
|
197
|
+
if (latest.version !== remote.version ||
|
|
198
|
+
latest.ignoreRules?.text !== text ||
|
|
199
|
+
latest.ignoreRules.filename !== remote.ignoreRules.filename ||
|
|
200
|
+
!sameLocalFields(latest.localFields, remote.localFields) ||
|
|
201
|
+
rawSnapshotHashIdentity(latest) !== remoteFilesIdentity)
|
|
202
|
+
throw new Error("The reviewed remote snapshot changed; reopen Pull.");
|
|
203
|
+
if (current)
|
|
204
|
+
await verifyAdoptionBackup(current, signal);
|
|
205
|
+
await validateContext();
|
|
206
|
+
const refresh = async () => {
|
|
207
|
+
const next = await createSnapshot(config.snapshotIdentity, projected);
|
|
208
|
+
await validateSource();
|
|
209
|
+
return next;
|
|
210
|
+
};
|
|
211
|
+
let commitStarted = false;
|
|
212
|
+
const markCommit = () => {
|
|
213
|
+
if (!commitStarted)
|
|
214
|
+
options.onCommit?.();
|
|
215
|
+
commitStarted = true;
|
|
216
|
+
};
|
|
217
|
+
if (current && (await pendingTransactionEntries()).length) {
|
|
218
|
+
if (source.text === text || current.stateFingerprint !== stateFingerprint)
|
|
219
|
+
throw new Error("Pending local files and rule adoption cannot be reconciled; preserve both journals.");
|
|
220
|
+
markCommit();
|
|
221
|
+
await recoverPendingSnapshotTransactions({ ...projected, protectedTargets: liveSessionFiles(ctx) });
|
|
222
|
+
before = await refresh();
|
|
223
|
+
physical = overlayLocalFields(logical, before, config.localFields);
|
|
224
|
+
}
|
|
225
|
+
if (!current) {
|
|
226
|
+
await revalidateCaseCleanup(caseCleanup, physical, projected);
|
|
227
|
+
if (!sameHashes(fileHashMap(await refresh()), fileHashMap(before)))
|
|
228
|
+
throw new Error("Local files changed; reopen Pull.");
|
|
229
|
+
const backup = await backupDirectionalSnapshot(regenerateSnapshotIdentity(before), signal);
|
|
230
|
+
await validateContext();
|
|
231
|
+
if (syncStateFingerprint(await readStateForConfig(config)) !== stateFingerprint)
|
|
232
|
+
throw new Error("Baseline changed; reopen Pull.");
|
|
233
|
+
await backup.validate();
|
|
234
|
+
await validateSource();
|
|
235
|
+
current = {
|
|
236
|
+
version: 1,
|
|
237
|
+
setupName: config.setupName,
|
|
238
|
+
setupFingerprint,
|
|
239
|
+
stateFingerprint,
|
|
240
|
+
filename,
|
|
241
|
+
sourceIdentity: source.identity,
|
|
242
|
+
beforeRules: source.text,
|
|
243
|
+
afterRules: text,
|
|
244
|
+
beforeFiles: fileHashMap(before),
|
|
245
|
+
afterFiles: appliedFileHashMap(physical, before, protectedPaths),
|
|
246
|
+
head,
|
|
247
|
+
remoteFilesIdentity,
|
|
248
|
+
sessionDir,
|
|
249
|
+
backupId: path.basename(backup.backupPath, ".json.gz"),
|
|
250
|
+
backupDigest: backup.digest,
|
|
251
|
+
};
|
|
252
|
+
markCommit();
|
|
253
|
+
await createAdoptionJournal(current);
|
|
254
|
+
}
|
|
255
|
+
let journal = current;
|
|
256
|
+
const installedHashes = journal.afterFiles;
|
|
257
|
+
const stateFor = (acceptedConfig) => ({
|
|
258
|
+
version: 1,
|
|
259
|
+
profile: config.snapshotIdentity,
|
|
260
|
+
lastAppliedSnapshot: head.snapshotId,
|
|
261
|
+
lastRemoteRevision: head.revision,
|
|
262
|
+
lastFileHashes: config.localFields?.length
|
|
263
|
+
? { ...installedHashes, "settings.json": fileHashMap(logical)["settings.json"] }
|
|
264
|
+
: installedHashes,
|
|
265
|
+
...acceptedSelection(acceptedConfig),
|
|
266
|
+
...(config.localFields !== undefined ? { localFields: config.localFields } : {}),
|
|
267
|
+
});
|
|
268
|
+
const hashes = fileHashMap(await refresh());
|
|
269
|
+
if (source.text !== text && journal.stateFingerprint !== stateFingerprint)
|
|
270
|
+
throw new Error("Baseline changed after the reviewed Pull. Preserve its journal.");
|
|
271
|
+
if (!sameHashes(hashes, journal.afterFiles)) {
|
|
272
|
+
if (source.text === text ||
|
|
273
|
+
!sameHashes(hashes, journal.beforeFiles) ||
|
|
274
|
+
!sameHashes(appliedFileHashMap(physical, before, protectedPaths), journal.afterFiles))
|
|
275
|
+
throw new Error("Local files changed after the reviewed Pull. Preserve its journal.");
|
|
276
|
+
markCommit();
|
|
277
|
+
await applySnapshot(physical, protectedPaths, {
|
|
278
|
+
...projected,
|
|
279
|
+
reviewedLocal: before,
|
|
280
|
+
validateApplyReview: async () => {
|
|
281
|
+
await validateContext();
|
|
282
|
+
if (syncStateFingerprint(await readStateForConfig(config)) !== journal.stateFingerprint)
|
|
283
|
+
throw new Error("Baseline changed at Pull's commit boundary.");
|
|
284
|
+
},
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
await validateContext();
|
|
288
|
+
if (!sameHashes(fileHashMap(await refresh()), journal.afterFiles))
|
|
289
|
+
throw new Error("Installed files changed before rule adoption completed; preserve the journal.");
|
|
290
|
+
markCommit();
|
|
291
|
+
if (source.text !== text) {
|
|
292
|
+
await withEngineMutationQueue(target, async () => {
|
|
293
|
+
await validateContext();
|
|
294
|
+
if (!sameHashes(fileHashMap(await refresh()), installedHashes))
|
|
295
|
+
throw new Error("Local files changed while reserving the rule file; preserve the journal.");
|
|
296
|
+
await withLockedLocalConfigDocument(async (latest, recheck) => {
|
|
297
|
+
if (!latest?.bytes.equals(doc.bytes) || JSON.stringify(latest.identity) !== JSON.stringify(doc.identity))
|
|
298
|
+
throw new Error("Sync settings changed; preserve the journal.");
|
|
299
|
+
await installRuleFile(ctx, root, target, source.identity, source.sourceDigest, filename, text, signal, async (identity) => {
|
|
300
|
+
journal = await recordInstalledIdentity(journal, identity);
|
|
301
|
+
await validateHead();
|
|
302
|
+
}, () => {
|
|
303
|
+
recheck();
|
|
304
|
+
validateMutation();
|
|
305
|
+
checkLiveProtection(ctx, sessionDir, protectedPaths);
|
|
306
|
+
});
|
|
307
|
+
}, signal, true);
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
else {
|
|
311
|
+
await syncDirectory(root);
|
|
312
|
+
validateCommittedOwner();
|
|
313
|
+
}
|
|
314
|
+
const installed = await loadConfigForCheck(config.setupName);
|
|
315
|
+
if (installed.configDocumentFingerprint !== config.configDocumentFingerprint ||
|
|
316
|
+
adoptionSettingsFingerprint(installed) !== setupFingerprint ||
|
|
317
|
+
installed.ignorePolicy?.fingerprint !== ignorePolicyFingerprint(text, sessions) ||
|
|
318
|
+
installed.ignorePolicy?.sourceDigest !== adoptedPolicy.sourceDigest ||
|
|
319
|
+
installed.ignoreSourceIdentity !== journal.installedIdentity)
|
|
320
|
+
throw new Error("Cannot verify the installed rule file. Preserve the adoption journal.");
|
|
321
|
+
const finalState = stateFor(installed);
|
|
322
|
+
const latestFingerprint = syncStateFingerprint(await readStateForConfig(installed));
|
|
323
|
+
const validateFinal = () => {
|
|
324
|
+
validateCommittedOwner();
|
|
325
|
+
checkLiveProtection(ctx, sessionDir, protectedPaths);
|
|
326
|
+
};
|
|
327
|
+
validateFinal();
|
|
328
|
+
const installedFiles = await createSnapshot(config.snapshotIdentity, {
|
|
329
|
+
...projected,
|
|
330
|
+
ignorePolicy: installed.ignorePolicy,
|
|
331
|
+
ignoreSourceIdentity: installed.ignoreSourceIdentity,
|
|
332
|
+
validateMutation: validateFinal,
|
|
333
|
+
validateIgnorePolicy: installed.validateIgnorePolicy,
|
|
334
|
+
});
|
|
335
|
+
if (!sameHashes(fileHashMap(installedFiles), installedHashes))
|
|
336
|
+
throw new Error("Local files changed during adoption. Preserve the journal.");
|
|
337
|
+
await installed.validateIgnorePolicy?.();
|
|
338
|
+
validateFinal();
|
|
339
|
+
if (latestFingerprint === journal.stateFingerprint)
|
|
340
|
+
await writeStateForConfig(installed, finalState, logical, validateFinal);
|
|
341
|
+
else if (latestFingerprint !== syncStateFingerprint(finalState))
|
|
342
|
+
throw new Error("Baseline changed during installation; preserve the adoption journal.");
|
|
343
|
+
validateFinal();
|
|
344
|
+
const archive = await completeAdoptionJournal(journal);
|
|
345
|
+
validateFinal();
|
|
346
|
+
if (!signal?.aborted) {
|
|
347
|
+
notifyDirectionalSuccess(ctx, options, [
|
|
348
|
+
`Adopted remote rules and pulled snapshot ${snapshotPathLabel(head.snapshotId)}.`,
|
|
349
|
+
localRestoreGuidance(path.join(path.dirname(archive), `${journal.backupId}.json.gz`)),
|
|
350
|
+
`Previous rule text: ${snapshotPathLabel(archive)}.`,
|
|
351
|
+
].join("\n"));
|
|
352
|
+
if (!options.directionalAction && options.reload)
|
|
353
|
+
await maybeReload(ctx, signal, validateFinal);
|
|
354
|
+
}
|
|
355
|
+
return "applied";
|
|
356
|
+
}
|
|
357
|
+
function liveSessionFiles(ctx) {
|
|
358
|
+
const current = ctx.sessionManager.getSessionFile?.();
|
|
359
|
+
return [...(ctx.protectedSessionFiles ?? []), ...(current ? [current] : [])];
|
|
360
|
+
}
|
|
361
|
+
async function installRuleFile(ctx, root, target, identity, digest, filename, text, signal, recordIdentity, validate) {
|
|
362
|
+
const before = lstatSync(target, { bigint: true });
|
|
363
|
+
const temporary = path.join(root, `.pi-sync.json.${randomUUID()}.ignore-adopt`);
|
|
364
|
+
const handle = await fs.open(temporary, "wx", 0o600);
|
|
365
|
+
let temporaryIdentity;
|
|
366
|
+
try {
|
|
367
|
+
let staged;
|
|
368
|
+
try {
|
|
369
|
+
temporaryIdentity = ignoreFileIdentity(await handle.stat({ bigint: true }));
|
|
370
|
+
await handle.writeFile(text, "utf8");
|
|
371
|
+
if (process.platform !== "win32")
|
|
372
|
+
await handle.chmod(Number(before.mode & 511n));
|
|
373
|
+
await handle.sync();
|
|
374
|
+
staged = await handle.stat({ bigint: true });
|
|
375
|
+
}
|
|
376
|
+
finally {
|
|
377
|
+
await handle.close();
|
|
378
|
+
}
|
|
379
|
+
await recordIdentity(ignoreFileIdentity(staged));
|
|
380
|
+
const current = await readIgnoreSource(root, filename, signal);
|
|
381
|
+
validate();
|
|
382
|
+
signal?.throwIfAborted();
|
|
383
|
+
const after = lstatSync(target, { bigint: true });
|
|
384
|
+
assertNotLiveRuleTarget(ctx, target, identity);
|
|
385
|
+
const stagedNow = lstatSync(temporary, { bigint: true });
|
|
386
|
+
if (!sameFile(staged, stagedNow) ||
|
|
387
|
+
stagedNow.nlink !== 1n ||
|
|
388
|
+
!sameFile(before, after) ||
|
|
389
|
+
!current.present ||
|
|
390
|
+
current.identity !== identity ||
|
|
391
|
+
current.sourceDigest !== digest)
|
|
392
|
+
throw new Error("Local rule file changed; preserve the adoption journal.");
|
|
393
|
+
renameSync(temporary, target);
|
|
394
|
+
await syncDirectory(root);
|
|
395
|
+
}
|
|
396
|
+
finally {
|
|
397
|
+
const remaining = lstatSync(temporary, { bigint: true, throwIfNoEntry: false });
|
|
398
|
+
if (remaining && ignoreFileIdentity(remaining) === temporaryIdentity)
|
|
399
|
+
await fs.rm(temporary, { force: true });
|
|
400
|
+
}
|
|
401
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { getEngineRoot } from "../host.js";
|
|
2
|
+
import { readIgnoreSource } from "../ignore/ignore-source.js";
|
|
3
|
+
import { selectSnapshotIgnoreRules } from "../ignore/snapshot-ignore-rules.js";
|
|
4
|
+
import { regenerateSnapshotIdentity } from "../snapshot/snapshot.js";
|
|
5
|
+
import { RULES_SNAPSHOT_VERSION } from "../snapshot/snapshot-types.js";
|
|
6
|
+
import { safeTerminalText } from "../ui/terminal-text.js";
|
|
7
|
+
export async function withPublishedIgnoreRules(snapshot, config, signal) {
|
|
8
|
+
const policy = config.ignorePolicy;
|
|
9
|
+
if (!policy)
|
|
10
|
+
return snapshot;
|
|
11
|
+
const source = await readIgnoreSource(getEngineRoot(), policy.filename, signal);
|
|
12
|
+
if (!source.present || source.identity !== config.ignoreSourceIdentity)
|
|
13
|
+
throw new Error("Ignore file was replaced before publication; reopen the review.");
|
|
14
|
+
const ignoreRules = selectSnapshotIgnoreRules(source, policy);
|
|
15
|
+
return regenerateSnapshotIdentity({ ...snapshot, version: RULES_SNAPSHOT_VERSION, ignoreRules });
|
|
16
|
+
}
|
|
17
|
+
export function ignorePublicationNotice(snapshot) {
|
|
18
|
+
if (snapshot.ignoreRules === null)
|
|
19
|
+
return "The active rule file excludes itself; this snapshot omits its text.";
|
|
20
|
+
if (!snapshot.ignoreRules)
|
|
21
|
+
return undefined;
|
|
22
|
+
return `This snapshot includes ${safeTerminalText(snapshot.ignoreRules.filename)}. Its rules and comments will be retained in remote history. Peers must support snapshot version ${RULES_SNAPSHOT_VERSION}.`;
|
|
23
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { hasPendingAdoption } from "../ignore/adoption-journal.js";
|
|
1
2
|
import { loadConfig } from "../settings/config.js";
|
|
2
3
|
import { isMissingConfigError } from "../settings/config-errors.js";
|
|
3
4
|
import { consumeLocalConfigMigrationNotice } from "../settings/config-file.js";
|
|
@@ -23,6 +24,17 @@ export async function initializeSync(ctx, signal, publish, observe) {
|
|
|
23
24
|
await timings.measure("transaction recovery", async () => {
|
|
24
25
|
const pending = await pendingTransactionEntries();
|
|
25
26
|
validate();
|
|
27
|
+
if (hasPendingAdoption()) {
|
|
28
|
+
if (pending.length) {
|
|
29
|
+
const { recoverAdoptionFilesOnStartup } = await import("./ignore-adoption-recovery.js");
|
|
30
|
+
validate();
|
|
31
|
+
await recoverAdoptionFilesOnStartup(ctx, signal, validate);
|
|
32
|
+
validate();
|
|
33
|
+
}
|
|
34
|
+
if (ctx.hasUI)
|
|
35
|
+
ctx.ui.notify("Ignore-rule adoption is pending. Resume from the originating setup with /sync pull.", "warning");
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
26
38
|
if (!pending.some((entry) => entry.isDirectory()))
|
|
27
39
|
return;
|
|
28
40
|
const { recoverSnapshotTransactionsOnStartup } = await import("../snapshot/snapshot-transaction.js");
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
|
+
import { validateSnapshotIgnoreRules } from "../ignore/snapshot-ignore-rules.js";
|
|
2
3
|
import { regenerateSnapshotIdentity } from "../snapshot/snapshot.js";
|
|
3
4
|
import { assertAgentDirectorySnapshotBound } from "../snapshot/snapshot-bounds.js";
|
|
4
5
|
import { assertSnapshotFilePayload } from "../snapshot/snapshot-payload.js";
|
|
5
|
-
import {
|
|
6
|
+
import { isIgnoreSnapshotVersion, isSupportedSnapshotVersion, } from "../snapshot/snapshot-types.js";
|
|
6
7
|
import { jsonEqual, parseSettingsDocument, renderSettingsMembers, } from "./json-document.js";
|
|
7
8
|
import { normalizeLocalFields } from "./local-field-policy.js";
|
|
8
9
|
import { compileSyncPolicyExclude, configuredSnapshotPathMatcher, validateSnapshotSelection } from "./sync-policy.js";
|
|
@@ -55,6 +56,7 @@ function validateIgnoreSnapshotEnvelope(snapshot, selection) {
|
|
|
55
56
|
"profile",
|
|
56
57
|
"syncSessions",
|
|
57
58
|
"selection",
|
|
59
|
+
"ignoreRules",
|
|
58
60
|
"localFields",
|
|
59
61
|
"files",
|
|
60
62
|
].includes(key)))
|
|
@@ -77,14 +79,15 @@ export function validatePortableSnapshot(snapshot) {
|
|
|
77
79
|
validateSnapshotFieldPolicy(snapshot);
|
|
78
80
|
validateSnapshotSelection(snapshot);
|
|
79
81
|
const selection = snapshot.selection;
|
|
82
|
+
const policy = validateSnapshotIgnoreRules(snapshot);
|
|
80
83
|
if (selection?.version === 4)
|
|
81
84
|
validateIgnoreSnapshotEnvelope(snapshot, selection);
|
|
82
85
|
if (selection?.scope) {
|
|
83
|
-
const selected = configuredSnapshotPathMatcher(selection);
|
|
86
|
+
const selected = configuredSnapshotPathMatcher(policy ? { ...selection, ignorePolicy: policy } : selection);
|
|
84
87
|
if (snapshot.files.some((file) => typeof file?.path !== "string" || !selected(file.path)))
|
|
85
88
|
throw new Error("Portable snapshot retains excluded or unsafe agent-directory paths.");
|
|
86
89
|
assertAgentDirectorySnapshotBound(snapshot.files);
|
|
87
|
-
if (snapshot.version
|
|
90
|
+
if (isIgnoreSnapshotVersion(snapshot.version))
|
|
88
91
|
validateIgnoreSnapshotFiles(snapshot.files);
|
|
89
92
|
}
|
|
90
93
|
else {
|
|
@@ -2,7 +2,7 @@ import { randomUUID } from "node:crypto";
|
|
|
2
2
|
import fs from "node:fs/promises";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { assertRecoveryPolicy, BOUND_DIRECTORY_JOURNAL_VERSION, IGNORE_POLICY_JOURNAL_VERSION, ignorePolicyValidator, ignoreSourceBinding, recoveryPolicyKey, validateJournalPolicy, } from "../snapshot/snapshot-transaction-policy.js";
|
|
5
|
-
import {
|
|
5
|
+
import { isIgnoreSnapshotVersion } from "../snapshot/snapshot-types.js";
|
|
6
6
|
import { readJsonIfExists, syncDirectory, writeJson } from "../state/json-file.js";
|
|
7
7
|
import { readStateForConfig, statePathForConfig, syncStateFingerprint } from "../state/sync-state-store.js";
|
|
8
8
|
import { confirmMergeReview } from "../ui/merge-review.js";
|
|
@@ -142,7 +142,7 @@ export async function readMergeJournal(config) {
|
|
|
142
142
|
validateSnapshotFieldPolicy(snapshot);
|
|
143
143
|
validateSnapshotSelection(snapshot);
|
|
144
144
|
if ((journal.ignoreSource !== undefined
|
|
145
|
-
? snapshot.version
|
|
145
|
+
? !isIgnoreSnapshotVersion(snapshot.version) ||
|
|
146
146
|
!sameSnapshotSelection(snapshot.selection, journal.upload.selection)
|
|
147
147
|
: ![1, 2, 3, 4, 5].includes(snapshot.version)) ||
|
|
148
148
|
typeof snapshot.id !== "string" ||
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createSyncBackend } from "../backends/backend-factory.js";
|
|
2
2
|
import { expectedRemoteHead, SyncBackendConflictError } from "../backends/sync-backend.js";
|
|
3
|
+
import { requireNoPendingAdoption } from "../ignore/adoption-journal.js";
|
|
3
4
|
import { loadConfig, syncCheckConfigFingerprint } from "../settings/config.js";
|
|
4
5
|
import { effectiveSessionRoot, requireStableMergeSessionRoot, snapshotOptionsForContext, } from "../snapshot/session-paths.js";
|
|
5
6
|
import { createSnapshot, filterSnapshotForConfigPolicy, mergeRemotePreservedFiles, observeSnapshot, regenerateSnapshotIdentity, scanSnapshot, snapshotWithObservedInventory, } from "../snapshot/snapshot.js";
|
|
@@ -17,6 +18,7 @@ import { pruneCompletedConflicts } from "./conflict-retention.js";
|
|
|
17
18
|
import { resolveContentConflicts } from "./content-conflicts.js";
|
|
18
19
|
import { ContinuousError } from "./continuous-errors.js";
|
|
19
20
|
import { planFileMerge } from "./file-merge-planner.js";
|
|
21
|
+
import { ignorePublicationNotice, withPublishedIgnoreRules } from "./ignore-publication.js";
|
|
20
22
|
import { overlayLocalFields, portableSnapshot, sameLocalFields } from "./local-fields.js";
|
|
21
23
|
import { acceptedState, matchesAcceptedState, writeAcceptedState } from "./merge-acceptance.js";
|
|
22
24
|
import { applyMergedSnapshot, preflightMergedTargets } from "./merge-apply.js";
|
|
@@ -35,6 +37,7 @@ import { checkLiveProtection, validateMergeApplyReview, validateMergedPublicatio
|
|
|
35
37
|
const MAX_ATTEMPTS = 3;
|
|
36
38
|
/** Established-baseline sync only. First-source selection remains in the existing command flow. */
|
|
37
39
|
export async function mergeSync(ctx, options, factory = createSyncBackend, resolution) {
|
|
40
|
+
requireNoPendingAdoption();
|
|
38
41
|
const timings = options.startupTimings ?? createStartupTimings();
|
|
39
42
|
const sessionOwner = captureMutationOwner(ctx, options.signal);
|
|
40
43
|
const validateOwner = (config) => {
|
|
@@ -351,9 +354,12 @@ export async function mergeSync(ctx, options, factory = createSyncBackend, resol
|
|
|
351
354
|
...remote.files.filter((file) => withheld.has(file.path)),
|
|
352
355
|
],
|
|
353
356
|
});
|
|
354
|
-
const upload = mergeRemotePreservedFiles(publication, rawRemote, config, { sessionDir: sessionRoot });
|
|
355
357
|
const publish = !sameHashes(fileHashMap(publication), fileHashMap(remote)) ||
|
|
356
358
|
Boolean(config.partialSync && rawRemote.version < 3);
|
|
359
|
+
const candidate = mergeRemotePreservedFiles(publication, rawRemote, config, { sessionDir: sessionRoot });
|
|
360
|
+
const upload = publish ? await withPublishedIgnoreRules(candidate, config, options.signal) : candidate;
|
|
361
|
+
if (config.ignorePolicy && publish)
|
|
362
|
+
await validate();
|
|
357
363
|
const apply = !sameHashes(fileHashMap(localRaw), fileHashMap(after));
|
|
358
364
|
if (!publish && !apply) {
|
|
359
365
|
const beforeEvidence = await timings.measure("transfer remote head", () => backend.readHead(options.signal));
|
|
@@ -407,7 +413,8 @@ export async function mergeSync(ctx, options, factory = createSyncBackend, resol
|
|
|
407
413
|
decisions: plan.decisions,
|
|
408
414
|
capability: backend.capability,
|
|
409
415
|
});
|
|
410
|
-
|
|
416
|
+
const notice = ignorePublicationNotice(upload);
|
|
417
|
+
if (!(await confirmMergeReview(ctx, summary.title, notice ? `${notice}\n\n${summary.content}` : summary.content, options.signal, isCurrent, summary.confirmationLabel, notice ? [notice, "", ...summary.lines] : summary.lines)))
|
|
411
418
|
return "cancelled";
|
|
412
419
|
}
|
|
413
420
|
await validate();
|
|
@@ -623,7 +630,11 @@ async function completeJournal(ctx, config, backend, journal, { validate, valida
|
|
|
623
630
|
const observed = await timings.measure("transfer snapshot download", () => readSnapshotForHead(backend, head, signal, config));
|
|
624
631
|
requireCompatibleRemoteSelection(config, observed);
|
|
625
632
|
if (!sameHashes(fileHashMap(observed), fileHashMap(journal.upload)) ||
|
|
626
|
-
JSON.stringify(observed.selection) !== JSON.stringify(journal.upload.selection)
|
|
633
|
+
JSON.stringify(observed.selection) !== JSON.stringify(journal.upload.selection) ||
|
|
634
|
+
observed.version !== journal.upload.version ||
|
|
635
|
+
(observed.ignoreRules === null) !== (journal.upload.ignoreRules === null) ||
|
|
636
|
+
observed.ignoreRules?.filename !== journal.upload.ignoreRules?.filename ||
|
|
637
|
+
observed.ignoreRules?.text !== journal.upload.ignoreRules?.text)
|
|
627
638
|
throw new Error("Remote snapshot does not match the recorded merge publication.");
|
|
628
639
|
const state = await timings.measure("transfer state read", () => readStateForConfig(config));
|
|
629
640
|
if (matchesAcceptedState(state, config, head, journal.accepted ?? journal.after, journal.progress)) {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
1
2
|
import { constants } from "node:fs";
|
|
2
3
|
import fs from "node:fs/promises";
|
|
3
4
|
import path from "node:path";
|
|
@@ -65,7 +66,7 @@ export async function backupDirectionalSnapshot(snapshot, signal) {
|
|
|
65
66
|
throwIfAborted(signal);
|
|
66
67
|
};
|
|
67
68
|
await validate();
|
|
68
|
-
return { backupPath, validate };
|
|
69
|
+
return { backupPath, validate, digest: createHash("sha256").update(encoded).digest("hex") };
|
|
69
70
|
}
|
|
70
71
|
async function writeSnapshotBackup(snapshot, signal, durableParent = false) {
|
|
71
72
|
throwIfAborted(signal);
|