@narumitw/pi-sync 0.67.3 → 0.68.1
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 +13 -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-CQ4DMLH3.ts → chunk-WQXUZSY5.ts} +25 -83
- package/dist/chunks/chunk-WQXUZSY5.ts.map +7 -0
- package/dist/chunks/{chunk-JREGWM2B.ts → chunk-XNUARYLR.ts} +1 -2
- package/dist/chunks/{command-handler-WF2TDDRZ.ts → command-handler-5LDTCUJE.ts} +64 -59
- package/dist/chunks/command-handler-5LDTCUJE.ts.map +7 -0
- package/dist/chunks/{conflict-review-GWEL4S6C.ts → conflict-review-SZ3AWTX6.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-OTI4JDQ2.ts} +5 -5
- package/dist/chunks/{sync-operations-AGNL7QXA.ts → sync-operations-ZUYJLWUN.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 +81 -65
- 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/ui/sync-format.js +1 -1
- 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 +4 -10
- 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 +60 -77
- 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 +28 -90
- 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-SZ3AWTX6.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-OTI4JDQ2.ts.map} +0 -0
- /package/dist/chunks/{sync-operations-AGNL7QXA.ts.map → sync-operations-ZUYJLWUN.ts.map} +0 -0
|
@@ -20,7 +20,6 @@ function contentLines(config) {
|
|
|
20
20
|
config.scope === "agent-directory"
|
|
21
21
|
? "included content: eligible files in the Pi agent directory"
|
|
22
22
|
: `included content: ${config.include.map(safeTerminalText).join(", ") || "none"}`,
|
|
23
|
-
...(config.ignorePolicy ? ["path policy: local ignore file (published unless it excludes itself)"] : []),
|
|
24
23
|
...(config.exclude === undefined
|
|
25
24
|
? []
|
|
26
25
|
: [`excluded paths: ${config.exclude.map(safeTerminalText).join(", ") || "none"}`]),
|
|
@@ -30,33 +29,59 @@ function contentLines(config) {
|
|
|
30
29
|
`sessions: ${syncSessionsSelected(config) ? "included" : "excluded"}`,
|
|
31
30
|
];
|
|
32
31
|
}
|
|
32
|
+
function fileCount(count) {
|
|
33
|
+
return `${count} ${count === 1 ? "file" : "files"}`;
|
|
34
|
+
}
|
|
35
|
+
function reportSection(title, lines) {
|
|
36
|
+
return lines.length > 0 ? ["", title, ...lines.map((line) => ` ${line}`)] : [];
|
|
37
|
+
}
|
|
38
|
+
function storageSection(connection, destination, details) {
|
|
39
|
+
return reportSection(`Storage · ${safeTerminalText(connection)}`, [
|
|
40
|
+
`Location: ${safeTerminalText(destination)}`,
|
|
41
|
+
...details,
|
|
42
|
+
]);
|
|
43
|
+
}
|
|
33
44
|
export async function status(ctx, options, factory = createSyncBackend) {
|
|
34
45
|
const config = await loadConfig(options.setup);
|
|
35
46
|
throwIfAborted(options.signal);
|
|
36
47
|
setSyncStatus(ctx, `checking ${config.setupName}`, { activity: "checking" });
|
|
37
|
-
const { head, selectionState, localChanged, remoteChanged, localFiles, destination, capability } = await inspectSync(config, await resolvedSnapshotOptionsForContext(ctx, config, options.signal), options.signal, factory);
|
|
48
|
+
const { head, selectionState, localChanged, remoteChanged, localFiles, firstSync, destination, capability } = await inspectSync(config, await resolvedSnapshotOptionsForContext(ctx, config, options.signal), options.signal, factory);
|
|
38
49
|
throwIfAborted(options.signal);
|
|
39
50
|
const continuous = config.continuous
|
|
40
51
|
? await (await import("./continuous-record.js")).continuousStatusLines(config)
|
|
41
52
|
: [];
|
|
42
53
|
throwIfAborted(options.signal);
|
|
43
|
-
const remoteText = head ? `remote: ${head.snapshotId} from ${head.machine} at ${head.createdAt}` : "remote: empty";
|
|
44
54
|
const warnings = syncSessionsWarnings(config);
|
|
55
|
+
const files = fileCount(localFiles);
|
|
56
|
+
const comparison = firstSync
|
|
57
|
+
? [`Local: ${files}`, `Remote: ${head ? "snapshot available" : "empty"}`]
|
|
58
|
+
: [
|
|
59
|
+
`Local: ${localChanged ? "changed" : "unchanged"} (${files})`,
|
|
60
|
+
`Remote: ${remoteChanged ? "changed" : "unchanged"}`,
|
|
61
|
+
];
|
|
45
62
|
setSyncStatus(ctx, undefined);
|
|
46
63
|
ctx.ui.notify([
|
|
47
|
-
`
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
...
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
64
|
+
`Remote status · ${safeTerminalText(config.setupName)}`,
|
|
65
|
+
...reportSection(firstSync ? "No previous sync recorded" : "Changes since last sync", [
|
|
66
|
+
...comparison,
|
|
67
|
+
...(head ? formatRemoteSelectionStatus(selectionState).split("\n") : []),
|
|
68
|
+
]),
|
|
69
|
+
...reportSection("Needs attention", warnings),
|
|
70
|
+
...storageSection(config.connectionName, destination, [
|
|
71
|
+
`Publication safety: ${publicationCapabilityDescription(capability)}`,
|
|
72
|
+
...(head
|
|
73
|
+
? [
|
|
74
|
+
`Latest snapshot: ${safeTerminalText(head.snapshotId)}`,
|
|
75
|
+
`Device: ${safeTerminalText(head.machine)}`,
|
|
76
|
+
`Created: ${safeTerminalText(head.createdAt)}`,
|
|
77
|
+
]
|
|
78
|
+
: firstSync
|
|
79
|
+
? []
|
|
80
|
+
: ["Latest snapshot: none"]),
|
|
81
|
+
]),
|
|
82
|
+
...reportSection("Background activity", continuous.map(safeTerminalText)),
|
|
83
|
+
...reportSection("Sync scope", contentLines(config)),
|
|
84
|
+
].join("\n"), localChanged || remoteChanged || selectionState?.kind === "different" || warnings.length > 0 ? "warning" : "info", "report");
|
|
60
85
|
}
|
|
61
86
|
export async function diff(ctx, options, factory = createSyncBackend) {
|
|
62
87
|
const config = await loadConfig(options.setup);
|
|
@@ -82,94 +107,86 @@ export async function diff(ctx, options, factory = createSyncBackend) {
|
|
|
82
107
|
...warnings,
|
|
83
108
|
].join("\n");
|
|
84
109
|
const level = warnings.length > 0 || selectionState?.kind === "different" ? "warning" : "info";
|
|
85
|
-
if (selectionState?.ignorePolicyComparison === "local-legacy-remote-ignore") {
|
|
86
|
-
ctx.ui.notify(`${header}\n\nFile comparison requires a configured local ignore-file policy.`, level);
|
|
87
|
-
return;
|
|
88
|
-
}
|
|
89
110
|
if (!remote) {
|
|
90
111
|
ctx.ui.notify(`${header}\n\n${formatSnapshotOnlyDiff("Remote is empty. Local push would upload", local)}`, level);
|
|
91
112
|
return;
|
|
92
113
|
}
|
|
93
|
-
|
|
94
|
-
ctx.ui.notify(`${header}\n\n${projection}${formatDiff(local, portableSnapshot(remote, remote.localFields))}`, level);
|
|
114
|
+
ctx.ui.notify(`${header}\n\n${formatDiff(local, portableSnapshot(remote, remote.localFields))}`, level);
|
|
95
115
|
}
|
|
96
116
|
export async function doctor(ctx, options, factory = createSyncBackend) {
|
|
97
|
-
const
|
|
98
|
-
|
|
99
|
-
let
|
|
117
|
+
const attention = [];
|
|
118
|
+
const localChecks = [];
|
|
119
|
+
let config;
|
|
120
|
+
let snapshotOptions;
|
|
100
121
|
let backend;
|
|
101
|
-
let backendSummary = [];
|
|
102
122
|
try {
|
|
103
|
-
|
|
123
|
+
config = await loadConfig(options.setup);
|
|
124
|
+
throwIfAborted(options.signal);
|
|
125
|
+
snapshotOptions = await resolvedSnapshotOptionsForContext(ctx, config, options.signal);
|
|
104
126
|
throwIfAborted(options.signal);
|
|
105
|
-
localConfig = {
|
|
106
|
-
profile: config.snapshotIdentity,
|
|
107
|
-
snapshotOptions: await resolvedSnapshotOptionsForContext(ctx, config, options.signal),
|
|
108
|
-
};
|
|
109
127
|
backend = await factory(config);
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
`publication safety: ${publicationCapabilityDescription(backend.capability)}`,
|
|
114
|
-
];
|
|
115
|
-
const warnings = syncSessionsWarnings(config);
|
|
116
|
-
if (warnings.length > 0) {
|
|
117
|
-
level = "warning";
|
|
118
|
-
messages.push(...warnings);
|
|
119
|
-
}
|
|
128
|
+
throwIfAborted(options.signal);
|
|
129
|
+
localChecks.push("Configuration: OK");
|
|
130
|
+
attention.push(...syncSessionsWarnings(config));
|
|
120
131
|
}
|
|
121
132
|
catch (error) {
|
|
122
133
|
throwIfAborted(options.signal);
|
|
123
|
-
|
|
124
|
-
messages.push(`config: ${errorMessage(error)}`);
|
|
134
|
+
attention.push(`Configuration: ${safeTerminalText(errorMessage(error))}`);
|
|
125
135
|
}
|
|
126
|
-
if (
|
|
127
|
-
const local = await createSnapshot(
|
|
136
|
+
if (config && snapshotOptions) {
|
|
137
|
+
const local = await createSnapshot(config.snapshotIdentity, snapshotOptions);
|
|
128
138
|
throwIfAborted(options.signal);
|
|
129
139
|
const secrets = scanSnapshot(local);
|
|
130
140
|
if (secrets.length > 0) {
|
|
131
|
-
|
|
132
|
-
messages.push("secret scan: possible secrets found:");
|
|
133
|
-
messages.push(...secrets.map((secret) => `- ${safeTerminalText(secret)}`));
|
|
141
|
+
attention.push("Secret scan: possible secrets found", ...secrets.map((secret) => ` - ${safeTerminalText(secret)}`));
|
|
134
142
|
}
|
|
135
143
|
else {
|
|
136
|
-
|
|
144
|
+
localChecks.push(`Secret scan: OK (${fileCount(local.files.length)} checked)`);
|
|
137
145
|
}
|
|
138
146
|
}
|
|
139
147
|
else
|
|
140
|
-
|
|
148
|
+
localChecks.push("Secret scan: skipped without a valid content policy");
|
|
141
149
|
const lock = await inspectLock();
|
|
142
150
|
throwIfAborted(options.signal);
|
|
143
151
|
if (lock.status === "valid" && isStaleLock(lock.lock)) {
|
|
144
|
-
|
|
145
|
-
messages.push(`lock: stale (pid ${lock.lock.pid}); run /sync unlock --stale after verifying no sync is running`);
|
|
152
|
+
attention.push(`Operation lock: stale (PID ${lock.lock.pid}); run /sync unlock --stale after verifying no sync is running`);
|
|
146
153
|
}
|
|
147
154
|
else if (lock.status === "valid") {
|
|
148
|
-
|
|
155
|
+
localChecks.push(`Operation lock: held by PID ${lock.lock.pid} since ${safeTerminalText(lock.lock.startedAt)}`);
|
|
149
156
|
}
|
|
150
157
|
else if (lock.status === "unreadable") {
|
|
151
|
-
|
|
152
|
-
messages.push("lock: unreadable; use /sync unlock --stale only after verifying no sync is running");
|
|
158
|
+
attention.push("Operation lock: unreadable; use /sync unlock --stale only after verifying no sync is running");
|
|
153
159
|
}
|
|
154
160
|
else if (await isLockGuardHeld()) {
|
|
155
|
-
|
|
156
|
-
level = "warning";
|
|
157
|
-
messages.push("lock: guard active while metadata is missing or still being initialized");
|
|
161
|
+
attention.push("Operation lock: guard active while metadata is missing or still being initialized");
|
|
158
162
|
}
|
|
159
163
|
else {
|
|
160
|
-
|
|
164
|
+
localChecks.push("Operation lock: free");
|
|
161
165
|
}
|
|
166
|
+
throwIfAborted(options.signal);
|
|
167
|
+
const storageChecks = [];
|
|
162
168
|
if (backend) {
|
|
163
|
-
messages.push(...backendSummary);
|
|
164
169
|
const diagnostics = await backend.diagnose(options.signal);
|
|
165
170
|
throwIfAborted(options.signal);
|
|
166
171
|
for (const diagnostic of diagnostics) {
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
172
|
+
if (diagnostic.key === "s3-config" && diagnostic.level === "info")
|
|
173
|
+
continue;
|
|
174
|
+
const finding = safeTerminalText(diagnostic.message.replaceAll("\n", " "));
|
|
175
|
+
(diagnostic.level === "info" ? storageChecks : attention).push(finding);
|
|
170
176
|
}
|
|
171
177
|
}
|
|
172
|
-
ctx.ui.notify(
|
|
178
|
+
ctx.ui.notify([
|
|
179
|
+
config ? `Diagnostics · ${safeTerminalText(config.setupName)}` : "Diagnostics",
|
|
180
|
+
...reportSection("Needs attention", attention),
|
|
181
|
+
...reportSection("Local checks", localChecks),
|
|
182
|
+
...(config && backend
|
|
183
|
+
? storageSection(config.connectionName, backend.destination, [
|
|
184
|
+
...storageChecks,
|
|
185
|
+
`Publication safety: ${publicationCapabilityDescription(backend.capability)}`,
|
|
186
|
+
])
|
|
187
|
+
: []),
|
|
188
|
+
...(config ? reportSection("Sync scope", contentLines(config)) : []),
|
|
189
|
+
].join("\n"), attention.length > 0 ? "warning" : "info", "report");
|
|
173
190
|
}
|
|
174
191
|
export async function history(ctx, options, factory = createSyncBackend) {
|
|
175
192
|
const config = await loadConfig(options.setup);
|
|
@@ -202,7 +219,6 @@ export async function history(ctx, options, factory = createSyncBackend) {
|
|
|
202
219
|
await withLock("rollback", () => rollback(ctx, { ...options, args: [snapshot.snapshotRef], yes: false }, factory, {
|
|
203
220
|
backendIdentity: backend.identity,
|
|
204
221
|
setup: config.setupName,
|
|
205
|
-
snapshotId: snapshot.snapshotId,
|
|
206
222
|
}));
|
|
207
223
|
return;
|
|
208
224
|
}
|
|
@@ -1,34 +1,29 @@
|
|
|
1
1
|
import { createSyncBackend } from "../backends/backend-factory.js";
|
|
2
2
|
import { expectedRemoteHead } from "../backends/sync-backend.js";
|
|
3
|
-
import { requireNoPendingAdoption } from "../ignore/adoption-journal.js";
|
|
4
3
|
import { loadConfig, syncCheckConfigFingerprint } from "../settings/config.js";
|
|
5
4
|
import { effectiveSessionRoot, requireStableMergeSessionRoot, resolvedSnapshotOptionsForContext, sessionDirForApply, } from "../snapshot/session-paths.js";
|
|
6
|
-
import { createSnapshot, filterSnapshotForConfigPolicy, regenerateSnapshotIdentity,
|
|
5
|
+
import { createSnapshot, filterSnapshotForConfigPolicy, regenerateSnapshotIdentity, snapshotIncludesSessions, snapshotWithoutSessions, } from "../snapshot/snapshot.js";
|
|
7
6
|
import { applySnapshot } from "../snapshot/snapshot-apply.js";
|
|
8
|
-
import { ignorePolicyValidator } from "../snapshot/snapshot-transaction-policy.js";
|
|
9
7
|
import { pruneMergeBaselines } from "../state/merge-baseline-store.js";
|
|
10
8
|
import { readStateForConfig, syncStateFingerprint, writeStateForConfig } from "../state/sync-state-store.js";
|
|
11
|
-
import {
|
|
12
|
-
import { confirmTransferReview } from "../ui/transfer-review.js";
|
|
9
|
+
import { formatRollbackSummary } from "../ui/sync-format.js";
|
|
13
10
|
import { inspectCaseCleanup, revalidateCaseCleanup } from "./apply-review.js";
|
|
14
11
|
import { confirmFieldMigration } from "./field-migration.js";
|
|
15
|
-
import { ignorePublicationNotice, withPublishedIgnoreRules } from "./ignore-publication.js";
|
|
16
12
|
import { overlayLocalFields, portableSnapshot, sameLocalFields, validatePortableSnapshot } from "./local-fields.js";
|
|
17
13
|
import { requireNoMergeJournal, retireMergeJournal } from "./merge-journal.js";
|
|
18
|
-
import { readSnapshotForHead,
|
|
14
|
+
import { readSnapshotForHead, sameRemoteHead, snapshotForUpload } from "./remote-snapshot.js";
|
|
19
15
|
import { throwIfAborted } from "./signals.js";
|
|
20
16
|
import { PublicationStatePersistenceError, RollbackPublicationError } from "./sync-errors.js";
|
|
21
17
|
import { backupLocal, captureMutationOwner, maybeReload, protectedSessionPaths } from "./sync-local.js";
|
|
22
18
|
import { requireLegacyTransferPolicy, syncSessionsSelected } from "./sync-policy.js";
|
|
23
19
|
import { acceptedSelection, fileHashMap, sameHashes } from "./sync-state.js";
|
|
24
|
-
import { checkLiveProtection, directionalApplyGuards,
|
|
20
|
+
import { checkLiveProtection, directionalApplyGuards, requireResolvedDirectionalProgress, } from "./transfer-freshness.js";
|
|
25
21
|
import { requireTransferSize, selectedPublicationImage, selectedPullImage, transferSizeLimitsEnabled, } from "./transfer-size-limits.js";
|
|
26
22
|
const VERSION = 1;
|
|
27
23
|
const POST_LOCAL_COMMIT_TIMEOUT_MS = 30_000;
|
|
28
24
|
export async function rollback(ctx, options, factory = createSyncBackend, expectedSelection) {
|
|
29
25
|
if (options.directionalAction)
|
|
30
26
|
throw new Error("Single-action transfer cannot authorize rollback.");
|
|
31
|
-
requireNoPendingAdoption();
|
|
32
27
|
const validateMutation = captureMutationOwner(ctx, options.signal);
|
|
33
28
|
const validateCommittedOwner = captureMutationOwner(ctx);
|
|
34
29
|
const target = options.args[0];
|
|
@@ -36,8 +31,6 @@ export async function rollback(ctx, options, factory = createSyncBackend, expect
|
|
|
36
31
|
throw new Error("Usage: /sync rollback <snapshot-id> [--yes]");
|
|
37
32
|
const config = await loadConfig(options.setup);
|
|
38
33
|
validateMutation();
|
|
39
|
-
if (config.ignorePolicy && (options.yes || options.auto || !ctx.hasUI))
|
|
40
|
-
throw new Error("Ignore-file rollback requires a separate foreground review; --yes cannot confirm it.");
|
|
41
34
|
const backend = await factory(config);
|
|
42
35
|
if (expectedSelection &&
|
|
43
36
|
(backend.identity !== expectedSelection.backendIdentity || config.setupName !== expectedSelection.setup)) {
|
|
@@ -46,44 +39,31 @@ export async function rollback(ctx, options, factory = createSyncBackend, expect
|
|
|
46
39
|
await requireNoMergeJournal(config);
|
|
47
40
|
const state = await readStateForConfig(config);
|
|
48
41
|
validateMutation();
|
|
49
|
-
requireIgnoreBaselineReview(ctx, config, state, options);
|
|
50
42
|
requireResolvedDirectionalProgress(state, options, false);
|
|
51
43
|
const decoded = await backend.readSnapshot(target, options.signal);
|
|
52
44
|
validateMutation();
|
|
53
45
|
validatePortableSnapshot(decoded);
|
|
54
|
-
|
|
55
|
-
requireLegacyTransferPolicy(decoded);
|
|
56
|
-
if (config.ignorePolicy && expectedSelection?.snapshotId && decoded.id !== expectedSelection.snapshotId)
|
|
57
|
-
throw new Error("Historical snapshot changed while history was open; reopen history and retry.");
|
|
46
|
+
requireLegacyTransferPolicy(decoded);
|
|
58
47
|
if (!sameLocalFields(decoded.localFields, config.localFields))
|
|
59
48
|
throw new Error("Rollback requires the historical snapshot local-field policy to match the configured rules. Review push --force from current local bytes to migrate policy first; choose matching history afterward.");
|
|
60
49
|
const snapshotOptions = await resolvedSnapshotOptionsForContext(ctx, config, options.signal);
|
|
61
50
|
validateMutation();
|
|
62
|
-
const
|
|
63
|
-
const selected = filterSnapshotForConfigPolicy(config.ignorePolicy || syncSessionsSelected(config) ? decoded : snapshotWithoutSessions(decoded), config, snapshotOptions);
|
|
51
|
+
const selected = filterSnapshotForConfigPolicy(syncSessionsSelected(config) ? decoded : snapshotWithoutSessions(decoded), config, snapshotOptions);
|
|
64
52
|
const remote = portableSnapshot(regenerateSnapshotIdentity(selected), config.localFields);
|
|
65
53
|
const local = await createSnapshot(config.snapshotIdentity, snapshotOptions);
|
|
66
54
|
const expectedHead = await backend.readHead(options.signal);
|
|
67
|
-
const currentRemote = expectedHead
|
|
68
|
-
? await readSnapshotForHead(backend, expectedHead, options.signal, config)
|
|
69
|
-
: undefined;
|
|
55
|
+
const currentRemote = expectedHead ? await readSnapshotForHead(backend, expectedHead, options.signal) : undefined;
|
|
70
56
|
validateMutation();
|
|
71
|
-
if (config.ignorePolicy && currentRemote)
|
|
72
|
-
requireCompatibleRemoteSelection(config, currentRemote);
|
|
73
57
|
if (!(await confirmFieldMigration(ctx, config, state, currentRemote, true, options.signal)))
|
|
74
58
|
return;
|
|
75
59
|
validateMutation();
|
|
76
60
|
const physical = overlayLocalFields(remote, local, config.localFields);
|
|
77
61
|
if (config.scope === "agent-directory")
|
|
78
62
|
requireStableMergeSessionRoot(local, physical, config.scope);
|
|
79
|
-
const upload = config
|
|
80
|
-
? await withPublishedIgnoreRules(remote, config, options.signal)
|
|
81
|
-
: await snapshotForUpload(backend, config, remote, expectedHead, currentRemote, snapshotOptions);
|
|
63
|
+
const upload = await snapshotForUpload(backend, config, remote, expectedHead, currentRemote, snapshotOptions);
|
|
82
64
|
validateMutation();
|
|
83
65
|
if (config.scope === "agent-directory")
|
|
84
66
|
validatePortableSnapshot(upload);
|
|
85
|
-
if (upload.ignoreRules && !config.skipSecretScan && scanSnapshot({ ...upload, files: [] }).length)
|
|
86
|
-
throw new Error("Refusing to publish possible secrets in the ignore file.");
|
|
87
67
|
const caseCleanup = options.yes ? [] : await inspectCaseCleanup(physical, snapshotOptions);
|
|
88
68
|
validateMutation();
|
|
89
69
|
const reviewedProtectedPaths = protectedSessionPaths(ctx, snapshotOptions.sessionDir);
|
|
@@ -93,9 +73,7 @@ export async function rollback(ctx, options, factory = createSyncBackend, expect
|
|
|
93
73
|
if (!options.yes) {
|
|
94
74
|
const title = snapshotIncludesSessions(remote) ? "Rollback pi settings and sessions?" : "Rollback pi settings?";
|
|
95
75
|
const summary = formatRollbackSummary(config, backend.destination, local, physical, target, reviewedProtectedPaths, caseCleanup.map((item) => item.path));
|
|
96
|
-
const confirmed =
|
|
97
|
-
? await confirmTransferReview(ctx, title, formatTransferReview("Historical files are projected through this device's current ignore rules. Historical rules are not adopted. Retained history is not erased.", ignorePublicationNotice(upload) ?? "", summary, "", "Remote publication:", formatPublicationPreview(currentRemote, upload)), options.signal, validateMutation)
|
|
98
|
-
: await ctx.ui.confirm(title, summary.content, { signal: options.signal });
|
|
76
|
+
const confirmed = await ctx.ui.confirm(title, summary.content, { signal: options.signal });
|
|
99
77
|
validateMutation();
|
|
100
78
|
if (!confirmed) {
|
|
101
79
|
ctx.ui.notify("Rollback cancelled.", "info");
|
|
@@ -115,7 +93,7 @@ export async function rollback(ctx, options, factory = createSyncBackend, expect
|
|
|
115
93
|
const backup = await backupLocal(config.snapshotIdentity, snapshotOptions, options.signal);
|
|
116
94
|
const applySessionDir = await sessionDirForApply(ctx, config.scope ? physical : remote, snapshotOptions);
|
|
117
95
|
const currentState = await readStateForConfig(config);
|
|
118
|
-
if (
|
|
96
|
+
if (!options.yes && syncStateFingerprint(currentState) !== syncStateFingerprint(state))
|
|
119
97
|
throw new Error("Baseline changed during rollback review.");
|
|
120
98
|
requireResolvedDirectionalProgress(currentState, options, false);
|
|
121
99
|
if (!options.yes)
|
|
@@ -126,11 +104,6 @@ export async function rollback(ctx, options, factory = createSyncBackend, expect
|
|
|
126
104
|
if (syncCheckConfigFingerprint(config) !== syncCheckConfigFingerprint(await loadConfig(options.setup)))
|
|
127
105
|
throw new Error("Settings changed during rollback review.");
|
|
128
106
|
validateMutation();
|
|
129
|
-
if (validateIgnorePolicy) {
|
|
130
|
-
if (!sameRemoteHead(backend, expectedHead, await backend.readHead(options.signal)))
|
|
131
|
-
throw new Error("Remote changed during rollback review.");
|
|
132
|
-
await validateIgnorePolicy();
|
|
133
|
-
}
|
|
134
107
|
const protectedPaths = protectedSessionPaths(ctx, snapshotOptions.sessionDir);
|
|
135
108
|
if (sizeLimited)
|
|
136
109
|
checkLiveProtection(ctx, snapshotOptions.sessionDir, reviewedProtectedPaths);
|
|
@@ -145,7 +118,6 @@ export async function rollback(ctx, options, factory = createSyncBackend, expect
|
|
|
145
118
|
signal: options.signal,
|
|
146
119
|
onCommit: options.onCommit,
|
|
147
120
|
validateMutation,
|
|
148
|
-
validateIgnorePolicy,
|
|
149
121
|
validateSettings: async () => {
|
|
150
122
|
if (syncCheckConfigFingerprint(config) !==
|
|
151
123
|
syncCheckConfigFingerprint(await loadConfig(options.setup, options.signal)))
|
|
@@ -156,13 +128,12 @@ export async function rollback(ctx, options, factory = createSyncBackend, expect
|
|
|
156
128
|
},
|
|
157
129
|
});
|
|
158
130
|
applyGuards.validateMutation();
|
|
159
|
-
|
|
160
|
-
options.onCommit?.();
|
|
131
|
+
options.onCommit?.();
|
|
161
132
|
const lastFileHashes = await applySnapshot(physical, protectedPaths, {
|
|
162
133
|
...snapshotOptions,
|
|
163
134
|
sessionDir: applySessionDir,
|
|
164
135
|
...applyGuards,
|
|
165
|
-
...(config.scope === "agent-directory" ||
|
|
136
|
+
...(config.scope === "agent-directory" || sizeLimited ? { reviewedLocal: local } : {}),
|
|
166
137
|
expectedFileHashes: config.localFields?.length
|
|
167
138
|
? { "settings.json": fileHashMap(local)["settings.json"] ?? null }
|
|
168
139
|
: undefined,
|
|
@@ -171,17 +142,8 @@ export async function rollback(ctx, options, factory = createSyncBackend, expect
|
|
|
171
142
|
let result;
|
|
172
143
|
try {
|
|
173
144
|
const signal = AbortSignal.timeout(POST_LOCAL_COMMIT_TIMEOUT_MS);
|
|
174
|
-
const validatePolicy = ignorePolicyValidator({
|
|
175
|
-
...snapshotOptions,
|
|
176
|
-
signal,
|
|
177
|
-
validateMutation: validateCommittedOwner,
|
|
178
|
-
});
|
|
179
|
-
const validatePublication = validatePolicy
|
|
180
|
-
? () => validateDirectionalPublication(ctx, config, { ...snapshotOptions, sessionDir: applySessionDir, signal }, state, lastFileHashes, validatePolicy, "rollback")
|
|
181
|
-
: undefined;
|
|
182
145
|
result = await backend.publishSnapshot(upload, expectedRemoteHead(expectedHead), {
|
|
183
146
|
signal,
|
|
184
|
-
...(validatePublication ? { validateIgnorePolicy: validatePublication } : {}),
|
|
185
147
|
});
|
|
186
148
|
}
|
|
187
149
|
catch (error) {
|
|
@@ -3,7 +3,7 @@ import { toPosix } from "../paths.js";
|
|
|
3
3
|
import { canonicalSnapshotPathForConfig, filterSnapshotForConfigPolicy, isSessionPath } from "../snapshot/snapshot.js";
|
|
4
4
|
import { sameSyncExclude } from "./exclude-policy.js";
|
|
5
5
|
import { portableObservation, portableSnapshot, sameLocalFields } from "./local-fields.js";
|
|
6
|
-
import {
|
|
6
|
+
import { configuredSnapshotPathMatcher, customIncludePathsByLower, includeFromSelectionConfig, normalizeSyncInclude, syncDirectoryPolicyKey, syncSessionsSelected, } from "./sync-policy.js";
|
|
7
7
|
export function hasLocalChanges(local, state, config) {
|
|
8
8
|
if (state.lastAppliedSnapshot &&
|
|
9
9
|
(state.scope !== config.scope ||
|
|
@@ -16,11 +16,6 @@ export function hasLocalChanges(local, state, config) {
|
|
|
16
16
|
export function remoteChangedSinceState(head, state, config, sameRevision) {
|
|
17
17
|
if (!head)
|
|
18
18
|
return Boolean(state.lastAppliedSnapshot);
|
|
19
|
-
if (head.selection) {
|
|
20
|
-
const comparison = compareIgnorePolicy(config.ignorePolicy, head.selection);
|
|
21
|
-
if (comparison && comparison !== "match")
|
|
22
|
-
return true;
|
|
23
|
-
}
|
|
24
19
|
if (head.snapshotId !== state.lastAppliedSnapshot)
|
|
25
20
|
return true;
|
|
26
21
|
if (state.lastRemoteRevision && !sameRevision(head.revision, state.lastRemoteRevision))
|
|
@@ -32,9 +27,6 @@ export function remoteChangedSinceState(head, state, config, sameRevision) {
|
|
|
32
27
|
head.syncSessions);
|
|
33
28
|
}
|
|
34
29
|
export function hasRemoteChanges(remote, state, config, ignoredPaths = new Set()) {
|
|
35
|
-
const comparison = compareIgnorePolicy(config.ignorePolicy, remote.selection);
|
|
36
|
-
if (comparison && comparison !== "match")
|
|
37
|
-
return true;
|
|
38
30
|
if (remote.id === state.lastAppliedSnapshot && !syncPolicyChanged(state, config))
|
|
39
31
|
return false;
|
|
40
32
|
return !snapshotHashesMatchState(portableSnapshot(filterSnapshotForConfigPolicy(remote, config), remote.localFields), state, config, ignoredPaths);
|
|
@@ -87,19 +79,14 @@ export function shouldRefreshSyncedState(remote, head, state, config, sameRevisi
|
|
|
87
79
|
syncPolicyChanged(state, config));
|
|
88
80
|
}
|
|
89
81
|
export function acceptedSelection(config) {
|
|
90
|
-
const key = localIgnorePolicyKey(config);
|
|
91
82
|
return {
|
|
92
|
-
include:
|
|
93
|
-
...(key === undefined ? {} : { ignorePolicyKey: key }),
|
|
83
|
+
include: [...config.include],
|
|
94
84
|
...(config.exclude === undefined ? {} : { exclude: [...config.exclude] }),
|
|
95
85
|
...(config.scope === undefined ? {} : { scope: config.scope }),
|
|
96
86
|
...(config.reinclude === undefined ? {} : { reinclude: [...config.reinclude] }),
|
|
97
87
|
};
|
|
98
88
|
}
|
|
99
89
|
function sameSelectionRules(state, config) {
|
|
100
|
-
const key = localIgnorePolicyKey(config);
|
|
101
|
-
if (key !== undefined || state.ignorePolicyKey !== undefined)
|
|
102
|
-
return key === state.ignorePolicyKey;
|
|
103
90
|
return config.scope === "agent-directory" && state.scope === config.scope
|
|
104
91
|
? syncDirectoryPolicyKey(state) === syncDirectoryPolicyKey(config)
|
|
105
92
|
: sameSyncExclude(state.exclude, config.exclude);
|
|
@@ -1,24 +1,15 @@
|
|
|
1
1
|
import { effectiveSessionRoot, resolvedSnapshotOptionsForContext } from "../snapshot/session-paths.js";
|
|
2
2
|
import { createSnapshot } from "../snapshot/snapshot.js";
|
|
3
|
-
import { StaleIgnorePolicyError } from "../snapshot/snapshot-transaction-policy.js";
|
|
4
3
|
import { readStateForConfig, syncStateFingerprint } from "../state/sync-state-store.js";
|
|
5
4
|
import { ContinuousError } from "./continuous-errors.js";
|
|
6
5
|
import { preflightMergedTargets } from "./merge-apply.js";
|
|
7
6
|
import { sameRemoteHead } from "./remote-snapshot.js";
|
|
8
7
|
import { protectedSessionPaths } from "./sync-local.js";
|
|
9
|
-
import { fileHashMap, sameHashes
|
|
8
|
+
import { fileHashMap, sameHashes } from "./sync-state.js";
|
|
10
9
|
export function requireResolvedDirectionalProgress(state, options, allowForce = true) {
|
|
11
10
|
if (state.unresolved?.length && (options.auto || !options.force || !allowForce))
|
|
12
11
|
throw new Error("Unresolved partial conflicts remain. Review /sync conflicts or explicitly choose push --force or pull --force; automatic transfer and rollback cannot accept unresolved groups.");
|
|
13
12
|
}
|
|
14
|
-
export function requireIgnoreBaselineReview(ctx, config, state, options) {
|
|
15
|
-
if ((config.ignorePolicy || config.reservedIgnoreNames !== undefined || state.ignorePolicyKey !== undefined) &&
|
|
16
|
-
state.lastAppliedSnapshot &&
|
|
17
|
-
syncPolicyChanged(state, config) &&
|
|
18
|
-
(options.auto || options.yes || !ctx.hasUI)) {
|
|
19
|
-
throw new Error("Local ignore-file policy or source changed since the last accepted baseline. Review a foreground directional transfer.");
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
13
|
export async function validateDirectionalPublication(ctx, config, options, state, expectedHashes, validatePolicy, direction, effectiveRoot = false) {
|
|
23
14
|
const current = await createSnapshot(config.snapshotIdentity, options);
|
|
24
15
|
if (!sameHashes(fileHashMap(current), expectedHashes))
|
|
@@ -36,10 +27,10 @@ export async function validateDirectionalPublication(ctx, config, options, state
|
|
|
36
27
|
export function checkLiveProtection(ctx, sessionDir, reviewed) {
|
|
37
28
|
const current = protectedSessionPaths(ctx, sessionDir);
|
|
38
29
|
if (current.size !== reviewed.size || [...current].some((item) => !reviewed.has(item)))
|
|
39
|
-
throw new
|
|
30
|
+
throw new Error("Live session protection changed during review; reopen the review.");
|
|
40
31
|
}
|
|
41
|
-
export function directionalApplyGuards({ ctx, config, backend, state, sessionDir, head, protectedPaths, signal, validateMutation,
|
|
42
|
-
if (!
|
|
32
|
+
export function directionalApplyGuards({ ctx, config, backend, state, sessionDir, head, protectedPaths, signal, validateMutation, strictReview, validateSettings, onCommit, effectiveRoot = false, }) {
|
|
33
|
+
if (!strictReview)
|
|
43
34
|
return { validateMutation, validateApplyReview: validateSettings };
|
|
44
35
|
const validateOwner = () => {
|
|
45
36
|
validateMutation();
|
|
@@ -50,16 +41,15 @@ export function directionalApplyGuards({ ctx, config, backend, state, sessionDir
|
|
|
50
41
|
validateMutation: validateOwner,
|
|
51
42
|
validateApplyReview: async () => {
|
|
52
43
|
if (!sameRemoteHead(backend, head, await backend.readHead(signal)))
|
|
53
|
-
throw new
|
|
44
|
+
throw new Error("Remote changed before local apply; reopen the review.");
|
|
54
45
|
if (syncStateFingerprint(await readStateForConfig(config)) !== syncStateFingerprint(state))
|
|
55
|
-
throw new
|
|
46
|
+
throw new Error("Baseline changed before local apply; reopen the review.");
|
|
56
47
|
if (sessionDir !==
|
|
57
48
|
(effectiveRoot
|
|
58
49
|
? await effectiveSessionRoot(ctx, config, signal)
|
|
59
50
|
: (await resolvedSnapshotOptionsForContext(ctx, config, signal)).sessionDir))
|
|
60
|
-
throw new
|
|
51
|
+
throw new Error("Pi session storage changed before local apply; reopen the review.");
|
|
61
52
|
await validateSettings?.();
|
|
62
|
-
await validateIgnorePolicy();
|
|
63
53
|
validateOwner();
|
|
64
54
|
if (!committed) {
|
|
65
55
|
onCommit?.();
|
|
@@ -12,10 +12,9 @@ export function selectedPublicationImage(snapshot, config, sessionDir) {
|
|
|
12
12
|
return {
|
|
13
13
|
side: "Remote",
|
|
14
14
|
files: filterSnapshotForConfigPolicy(snapshot, config, { sessionDir }).files,
|
|
15
|
-
ignoreRules: snapshot.ignoreRules,
|
|
16
15
|
};
|
|
17
16
|
}
|
|
18
|
-
export function selectedPullImage(incoming, local, protectedPaths
|
|
17
|
+
export function selectedPullImage(incoming, local, protectedPaths) {
|
|
19
18
|
return {
|
|
20
19
|
side: "Local",
|
|
21
20
|
files: protectedPaths.size
|
|
@@ -24,7 +23,6 @@ export function selectedPullImage(incoming, local, protectedPaths, ignoreRules)
|
|
|
24
23
|
...local.files.filter((file) => protectedPaths.has(file.path)),
|
|
25
24
|
]
|
|
26
25
|
: incoming.files,
|
|
27
|
-
ignoreRules,
|
|
28
26
|
};
|
|
29
27
|
}
|
|
30
28
|
function compareFindings(a, b) {
|
|
@@ -41,7 +39,7 @@ export function transferSizeDetails(config, images) {
|
|
|
41
39
|
const directoryLimit = (config.maxDirectorySizeMiB ?? Infinity) * MIB;
|
|
42
40
|
const findings = [];
|
|
43
41
|
let count = 0;
|
|
44
|
-
for (const { side, files
|
|
42
|
+
for (const { side, files } of images) {
|
|
45
43
|
const directories = new Map();
|
|
46
44
|
const seen = new Set();
|
|
47
45
|
const measure = (path, size, kind, limit) => {
|
|
@@ -65,8 +63,6 @@ export function transferSizeDetails(config, images) {
|
|
|
65
63
|
for (const parent of parentPaths(path))
|
|
66
64
|
directories.set(parent, (directories.get(parent) ?? 0) + size);
|
|
67
65
|
};
|
|
68
|
-
if (ignoreRules)
|
|
69
|
-
measureFile(ignoreRules.filename, Buffer.byteLength(ignoreRules.text, "utf8"));
|
|
70
66
|
for (const file of files)
|
|
71
67
|
measureFile(file.path, snapshotBase64Size(file.contentBase64, file.path));
|
|
72
68
|
for (const [path, size] of directories)
|
|
@@ -82,7 +78,7 @@ export function transferSizeDetails(config, images) {
|
|
|
82
78
|
return `${side} ${kind} "${label.slice(0, 240)}${shortened ? "…" : ""}": ${size} bytes (limit ${limit} bytes).`;
|
|
83
79
|
}),
|
|
84
80
|
...(omitted ? [`${omitted} additional ${omitted === 1 ? "finding" : "findings"} omitted.`] : []),
|
|
85
|
-
`Use /sync diff, adjust
|
|
81
|
+
`Use /sync diff, adjust exclusions in /sync → Settings, then review a Push or Pull.`,
|
|
86
82
|
].join(" ");
|
|
87
83
|
}
|
|
88
84
|
export function requireTransferSize(config, ...images) {
|
|
@@ -123,7 +123,7 @@ export function publicationCapabilityDescription(capability) {
|
|
|
123
123
|
case "atomic-conditional":
|
|
124
124
|
return "atomic-conditional (verified atomic precondition)";
|
|
125
125
|
case "conditional-required":
|
|
126
|
-
return "
|
|
126
|
+
return "Read-only until atomic conditional writes are verified";
|
|
127
127
|
case "read-check-write-verify":
|
|
128
128
|
return "read-check-write-verify (visible races rejected; simultaneous unseen races remain possible)";
|
|
129
129
|
}
|