@narumitw/pi-sync 0.67.2 → 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.
Files changed (180) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/README.md +29 -49
  3. package/dist/chunks/{chunk-XUZV4OGI.ts → chunk-335XTMMZ.ts} +3 -2
  4. package/dist/chunks/{chunk-XUZV4OGI.ts.map → chunk-335XTMMZ.ts.map} +2 -2
  5. package/dist/chunks/{chunk-PUSMSKIM.ts → chunk-AYGMIMCV.ts} +2 -11
  6. package/dist/chunks/chunk-AYGMIMCV.ts.map +7 -0
  7. package/dist/chunks/{chunk-2MSJDLSM.ts → chunk-BCDBT4X3.ts} +7 -7
  8. package/dist/chunks/{chunk-GRXNUC6O.ts → chunk-FQKWGVMA.ts} +20 -54
  9. package/dist/chunks/chunk-FQKWGVMA.ts.map +7 -0
  10. package/dist/chunks/{chunk-DGVZYS7T.ts → chunk-FR6A7ASZ.ts} +8 -11
  11. package/dist/chunks/chunk-FR6A7ASZ.ts.map +7 -0
  12. package/dist/chunks/{chunk-3NS4PMCI.ts → chunk-J52GYZO6.ts} +2 -8
  13. package/dist/chunks/{chunk-3NS4PMCI.ts.map → chunk-J52GYZO6.ts.map} +2 -2
  14. package/dist/chunks/{chunk-2MUAR5GH.ts → chunk-KAIVTJIQ.ts} +7 -10
  15. package/dist/chunks/chunk-KAIVTJIQ.ts.map +7 -0
  16. package/dist/chunks/{chunk-WBIOSK76.ts → chunk-R7PN3KIY.ts} +1 -2
  17. package/dist/chunks/{chunk-3Q3DMMID.ts → chunk-TLYT6HVI.ts} +8 -8
  18. package/dist/chunks/{chunk-UF2HU2NM.ts → chunk-WCGLU526.ts} +39 -118
  19. package/dist/chunks/chunk-WCGLU526.ts.map +7 -0
  20. package/dist/chunks/{chunk-JREGWM2B.ts → chunk-XNUARYLR.ts} +1 -2
  21. package/dist/chunks/{chunk-C3E75DXW.ts → chunk-YV2R5SJU.ts} +73 -85
  22. package/dist/chunks/chunk-YV2R5SJU.ts.map +7 -0
  23. package/dist/chunks/{command-handler-HWRPH3K3.ts → command-handler-S6BRZMPW.ts} +117 -69
  24. package/dist/chunks/command-handler-S6BRZMPW.ts.map +7 -0
  25. package/dist/chunks/{conflict-review-OBBBSVQD.ts → conflict-review-3XMYDJIK.ts} +2 -2
  26. package/dist/chunks/{file-selection-GASCVN45.ts → file-selection-4BOQBXS7.ts} +10 -17
  27. package/dist/chunks/file-selection-4BOQBXS7.ts.map +7 -0
  28. package/dist/chunks/{manager-result-dispatcher-MJ6G2CEI.ts → manager-result-dispatcher-A4IWLS4J.ts} +7 -7
  29. package/dist/chunks/{manager-ui-Z3B5ZTA6.ts → manager-ui-KHMCSLLV.ts} +114 -581
  30. package/dist/chunks/manager-ui-KHMCSLLV.ts.map +7 -0
  31. package/dist/chunks/{chunk-ECUCXF5Y.ts → merge-review-LWMUE5IW.ts} +2 -3
  32. package/dist/chunks/{remote-selection-ui-34WC7OFE.ts → remote-selection-ui-F6NJBQ3Y.ts} +6 -6
  33. package/dist/chunks/{setup-switch-JZDFQPVW.ts → setup-switch-7LMIRMZ7.ts} +6 -6
  34. package/dist/chunks/{setup-wizard-YOXLXLBY.ts → setup-wizard-2NRPR433.ts} +11 -16
  35. package/dist/chunks/{setup-wizard-YOXLXLBY.ts.map → setup-wizard-2NRPR433.ts.map} +1 -1
  36. package/dist/chunks/{sync-inspection-NIITROKS.ts → sync-inspection-QGM54YCM.ts} +5 -5
  37. package/dist/chunks/{sync-operations-FFI4ZZQL.ts → sync-operations-DTQMKVRQ.ts} +2 -2
  38. package/dist/daemon/dist/build-id.json +1 -0
  39. package/dist/daemon/dist/build-version.js +24 -4
  40. package/dist/daemon/dist/cli.js +51 -67
  41. package/dist/daemon/dist/client-transport.js +15 -5
  42. package/dist/daemon/dist/client.js +2 -10
  43. package/dist/daemon/dist/consent.js +13 -126
  44. package/dist/daemon/dist/daemon-startup.js +135 -30
  45. package/dist/daemon/dist/daemon-status.js +56 -0
  46. package/dist/daemon/dist/engine/backends/git/git-backend.js +4 -17
  47. package/dist/daemon/dist/engine/backends/git/git-storage.js +11 -44
  48. package/dist/daemon/dist/engine/backends/s3/s3-backend.js +6 -6
  49. package/dist/daemon/dist/engine/backends/webdav/webdav-backend.js +6 -6
  50. package/dist/daemon/dist/engine/settings/config.js +16 -149
  51. package/dist/daemon/dist/engine/settings/retired-ignore-policy.js +16 -0
  52. package/dist/daemon/dist/engine/settings/retired-ignore-recovery.js +14 -0
  53. package/dist/daemon/dist/engine/settings/settings-management.js +2 -10
  54. package/dist/daemon/dist/engine/settings/settings-validation.js +8 -21
  55. package/dist/daemon/dist/engine/snapshot/session-paths.js +13 -41
  56. package/dist/daemon/dist/engine/snapshot/snapshot-apply.js +8 -24
  57. package/dist/daemon/dist/engine/snapshot/snapshot-codec.js +7 -11
  58. package/dist/daemon/dist/engine/snapshot/snapshot-exclude-safety.js +19 -76
  59. package/dist/daemon/dist/engine/snapshot/snapshot-transaction-images.js +1 -7
  60. package/dist/daemon/dist/engine/snapshot/snapshot-transaction-policy.js +8 -102
  61. package/dist/daemon/dist/engine/snapshot/snapshot-transaction.js +20 -100
  62. package/dist/daemon/dist/engine/snapshot/snapshot-types.js +1 -11
  63. package/dist/daemon/dist/engine/snapshot/snapshot.js +26 -78
  64. package/dist/daemon/dist/engine/state/sync-state-store.js +5 -1
  65. package/dist/daemon/dist/engine/sync/agent-plan.js +0 -1
  66. package/dist/daemon/dist/engine/sync/agent-policy.js +1 -1
  67. package/dist/daemon/dist/engine/sync/conflict-review.js +0 -2
  68. package/dist/daemon/dist/engine/sync/continuous-sync.js +2 -17
  69. package/dist/daemon/dist/engine/sync/continuous-watch.js +3 -7
  70. package/dist/daemon/dist/engine/sync/directional-action.js +3 -21
  71. package/dist/daemon/dist/engine/sync/initialization.js +4 -15
  72. package/dist/daemon/dist/engine/sync/local-fields.js +4 -65
  73. package/dist/daemon/dist/engine/sync/merge-apply.js +8 -31
  74. package/dist/daemon/dist/engine/sync/merge-journal.js +8 -118
  75. package/dist/daemon/dist/engine/sync/merged-sync.js +13 -70
  76. package/dist/daemon/dist/engine/sync/push-review.js +1 -16
  77. package/dist/daemon/dist/engine/sync/remote-snapshot.js +48 -65
  78. package/dist/daemon/dist/engine/sync/startup-bootstrap.js +3 -3
  79. package/dist/daemon/dist/engine/sync/sync-error-guidance.js +1 -1
  80. package/dist/daemon/dist/engine/sync/sync-inspection.js +1 -2
  81. package/dist/daemon/dist/engine/sync/sync-mutations.js +26 -118
  82. package/dist/daemon/dist/engine/sync/sync-policy.js +26 -150
  83. package/dist/daemon/dist/engine/sync/sync-queries.js +1 -8
  84. package/dist/daemon/dist/engine/sync/sync-rollback.js +12 -50
  85. package/dist/daemon/dist/engine/sync/sync-state.js +2 -15
  86. package/dist/daemon/dist/engine/sync/transfer-freshness.js +7 -17
  87. package/dist/daemon/dist/engine/sync/transfer-size-limits.js +3 -7
  88. package/dist/daemon/dist/engine-service.js +62 -205
  89. package/dist/daemon/dist/foreground-queue-outcome.js +0 -4
  90. package/dist/daemon/dist/index.js +2 -0
  91. package/dist/daemon/dist/legacy-consent-guard.js +34 -0
  92. package/dist/daemon/dist/server.js +99 -11
  93. package/dist/daemon/dist/service-host.js +3 -9
  94. package/dist/daemon/package.json +1 -1
  95. package/dist/index.ts +49 -49
  96. package/dist/index.ts.map +3 -3
  97. package/docs/agent-continuous-hardening.md +2 -0
  98. package/docs/continuous-sync-verification.md +1 -1
  99. package/docs/daemon-migration.md +17 -15
  100. package/docs/tui-contract.md +4 -6
  101. package/package.json +2 -3
  102. package/skills/configure-pi-sync/SKILL.md +23 -78
  103. package/skills/configure-pi-sync/references/configuration.md +59 -76
  104. package/src/commands/command-execution.ts +15 -38
  105. package/src/commands/command-handler.ts +0 -4
  106. package/src/commands/command.ts +2 -1
  107. package/src/daemon/daemon-status-ui.ts +64 -0
  108. package/src/daemon/directional-recovery.ts +4 -33
  109. package/src/daemon/pi-client.ts +87 -94
  110. package/src/settings/config.ts +0 -1
  111. package/src/sync/setup-switch.ts +1 -4
  112. package/src/sync-extension.ts +14 -27
  113. package/src/ui/cancellable-operation.ts +2 -13
  114. package/src/ui/excluded-paths-ui.ts +1 -4
  115. package/src/ui/file-selection.ts +0 -5
  116. package/src/ui/manager-state.ts +12 -75
  117. package/src/ui/manager-ui.ts +7 -96
  118. package/src/ui/remote-selection-ui.ts +29 -130
  119. package/src/ui/settings-ui.ts +169 -388
  120. package/src/ui/setup/setup-actions.ts +4 -16
  121. package/src/ui/setup/setup-prompts.ts +12 -49
  122. package/src/ui/setup/setup-switcher.ts +8 -14
  123. package/src/ui/storage-connections-ui.ts +21 -32
  124. package/src/ui/sync-setups-ui.ts +27 -53
  125. package/dist/chunks/chunk-2MUAR5GH.ts.map +0 -7
  126. package/dist/chunks/chunk-C3E75DXW.ts.map +0 -7
  127. package/dist/chunks/chunk-DGVZYS7T.ts.map +0 -7
  128. package/dist/chunks/chunk-EJDDRS6O.ts +0 -17
  129. package/dist/chunks/chunk-EJDDRS6O.ts.map +0 -7
  130. package/dist/chunks/chunk-GRXNUC6O.ts.map +0 -7
  131. package/dist/chunks/chunk-I72HGZJJ.ts +0 -106
  132. package/dist/chunks/chunk-I72HGZJJ.ts.map +0 -7
  133. package/dist/chunks/chunk-KNEUL4XN.ts +0 -30
  134. package/dist/chunks/chunk-KNEUL4XN.ts.map +0 -7
  135. package/dist/chunks/chunk-PUSMSKIM.ts.map +0 -7
  136. package/dist/chunks/chunk-UF2HU2NM.ts.map +0 -7
  137. package/dist/chunks/chunk-WFBHWYI6.ts +0 -18
  138. package/dist/chunks/chunk-WFBHWYI6.ts.map +0 -7
  139. package/dist/chunks/command-handler-HWRPH3K3.ts.map +0 -7
  140. package/dist/chunks/config-P54GGMXY.ts +0 -39
  141. package/dist/chunks/continuous-record-3SKJ6I3V.ts +0 -23
  142. package/dist/chunks/continuous-record-3SKJ6I3V.ts.map +0 -7
  143. package/dist/chunks/continuous-storage-3EU6I7Z3.ts +0 -27
  144. package/dist/chunks/continuous-storage-3EU6I7Z3.ts.map +0 -7
  145. package/dist/chunks/file-selection-GASCVN45.ts.map +0 -7
  146. package/dist/chunks/ignore-file-ui-5BWA6LBC.ts +0 -21
  147. package/dist/chunks/manager-ui-Z3B5ZTA6.ts.map +0 -7
  148. package/dist/chunks/merge-review-C2KETZKY.ts +0 -11
  149. package/dist/chunks/merge-review-C2KETZKY.ts.map +0 -7
  150. package/dist/chunks/remote-selection-ui-34WC7OFE.ts.map +0 -7
  151. package/dist/chunks/setup-switch-JZDFQPVW.ts.map +0 -7
  152. package/dist/daemon/dist/engine/ignore/adoption-journal.js +0 -146
  153. package/dist/daemon/dist/engine/ignore/effective-ignore-policy.js +0 -33
  154. package/dist/daemon/dist/engine/ignore/ignore-edit.js +0 -102
  155. package/dist/daemon/dist/engine/ignore/ignore-initialization.js +0 -288
  156. package/dist/daemon/dist/engine/ignore/ignore-migration-prompt.js +0 -139
  157. package/dist/daemon/dist/engine/ignore/ignore-settings.js +0 -391
  158. package/dist/daemon/dist/engine/ignore/ignore-source.js +0 -250
  159. package/dist/daemon/dist/engine/ignore/snapshot-ignore-rules.js +0 -39
  160. package/dist/daemon/dist/engine/sync/ignore-adoption-recovery.js +0 -50
  161. package/dist/daemon/dist/engine/sync/ignore-adoption.js +0 -416
  162. package/dist/daemon/dist/engine/sync/ignore-publication.js +0 -23
  163. package/dist/daemon/dist/engine/ui/ignore-rule-preview.js +0 -18
  164. package/dist/daemon/dist/monitor.js +0 -344
  165. package/src/ui/agent-mode-setting.ts +0 -99
  166. package/src/ui/ignore-file-guidance.ts +0 -7
  167. package/src/ui/ignore-file-ui.ts +0 -105
  168. package/src/ui/ignore-migration-prompt.ts +0 -65
  169. package/src/ui/settings-review.ts +0 -26
  170. /package/dist/chunks/{chunk-2MSJDLSM.ts.map → chunk-BCDBT4X3.ts.map} +0 -0
  171. /package/dist/chunks/{chunk-WBIOSK76.ts.map → chunk-R7PN3KIY.ts.map} +0 -0
  172. /package/dist/chunks/{chunk-3Q3DMMID.ts.map → chunk-TLYT6HVI.ts.map} +0 -0
  173. /package/dist/chunks/{chunk-JREGWM2B.ts.map → chunk-XNUARYLR.ts.map} +0 -0
  174. /package/dist/chunks/{conflict-review-OBBBSVQD.ts.map → conflict-review-3XMYDJIK.ts.map} +0 -0
  175. /package/dist/chunks/{config-P54GGMXY.ts.map → manager-result-dispatcher-A4IWLS4J.ts.map} +0 -0
  176. /package/dist/chunks/{chunk-ECUCXF5Y.ts.map → merge-review-LWMUE5IW.ts.map} +0 -0
  177. /package/dist/chunks/{ignore-file-ui-5BWA6LBC.ts.map → remote-selection-ui-F6NJBQ3Y.ts.map} +0 -0
  178. /package/dist/chunks/{manager-result-dispatcher-MJ6G2CEI.ts.map → setup-switch-7LMIRMZ7.ts.map} +0 -0
  179. /package/dist/chunks/{sync-inspection-NIITROKS.ts.map → sync-inspection-QGM54YCM.ts.map} +0 -0
  180. /package/dist/chunks/{sync-operations-FFI4ZZQL.ts.map → sync-operations-DTQMKVRQ.ts.map} +0 -0
@@ -1,11 +1,41 @@
1
1
  import { spawn } from "node:child_process";
2
+ import { lstat } from "node:fs/promises";
2
3
  import { setTimeout as delay } from "node:timers/promises";
3
4
  import { fileURLToPath } from "node:url";
4
5
  import lockfile from "proper-lockfile";
6
+ import { gt } from "semver";
7
+ import { DAEMON_BUILD_ID, DAEMON_BUILD_VERSION, readInstalledDaemonBuild } from "./build-version.js";
5
8
  import { DaemonError, hello, requestDaemon } from "./client-transport.js";
6
9
  import { canonicalRootGuard, clearUpgradeOwner, daemonPaths, privateDirectory, processExists, processExited, readIdentity, readProcessBirth, readUpgradeOwner, recordUpgradeOwner, runtimePaths, upgradeRepairStarted, } from "./identity.js";
7
10
  import { OWNERSHIP_CLEANUP_REQUIRED, record } from "./protocol.js";
8
- export async function checkUpgradeConsent(paths, assertRoot, signal) {
11
+ const upgradeBlockers = {
12
+ busy: "Daemon update deferred while sync work is active. Let it finish, then use /reload or retry the daemon CLI.",
13
+ repair: "Daemon update blocked by uncertain consent or queue cleanup. Follow the daemon recovery guide before retrying.",
14
+ unattended: "Review or revoke unattended Pi Sync permission before stopping or replacing the daemon.",
15
+ legacy: "This older daemon does not support guarded upgrades. Let sync work finish, run restart from the intended daemon CLI, then /reload.",
16
+ };
17
+ export class DaemonUpgradeBlockedError extends Error {
18
+ instance;
19
+ constructor(instance, reason) {
20
+ super(upgradeBlockers[reason]);
21
+ this.instance = instance;
22
+ this.name = "DaemonUpgradeBlockedError";
23
+ }
24
+ }
25
+ function matchesBuild(version, id) {
26
+ return version === DAEMON_BUILD_VERSION && id === DAEMON_BUILD_ID;
27
+ }
28
+ function assertInstalledBuild() {
29
+ const { version, id } = readInstalledDaemonBuild();
30
+ if (!matchesBuild(version, id))
31
+ throw new Error("The daemon installation changed. Reload the intended Pi Sync build before retrying.");
32
+ }
33
+ const sameIdentity = (left, right) => left?.instance === right?.instance && left?.pid === right?.pid && left?.token === right?.token;
34
+ const sameBarrier = (left, right) => left?.instance === right.instance &&
35
+ left.pid === right.pid &&
36
+ left.birth === right.birth &&
37
+ left.purpose === right.purpose;
38
+ export async function checkUpgradeConsent(paths, assertRoot, signal, instance) {
9
39
  const { readConsent } = await import("./consent.js");
10
40
  const { withStateDirectoryGuardForRoot } = await import("./engine/state/state-directory.js");
11
41
  signal?.throwIfAborted();
@@ -13,8 +43,11 @@ export async function checkUpgradeConsent(paths, assertRoot, signal) {
13
43
  signal?.throwIfAborted();
14
44
  assertRoot();
15
45
  const consent = readConsent(paths.root);
16
- if (consent && Object.values(consent.setups).some((setup) => setup.afterExit))
17
- throw new Error("Review or revoke unattended Pi Sync permission before stopping or replacing the daemon.");
46
+ if (consent && Object.values(consent.setups).some((setup) => setup.afterExit)) {
47
+ if (instance)
48
+ throw new DaemonUpgradeBlockedError(instance, "unattended");
49
+ throw new Error(upgradeBlockers.unattended);
50
+ }
18
51
  });
19
52
  signal?.throwIfAborted();
20
53
  assertRoot();
@@ -24,30 +57,62 @@ export async function finishUpgrade(paths, owner, assertRoot, signal) {
24
57
  const current = await readIdentity(paths);
25
58
  if (current?.instance === owner.instance)
26
59
  throw new Error("The daemon exited without releasing its identity.");
27
- if (current && owner.purpose === "cleanup")
60
+ if (current)
28
61
  throw new Error("Daemon owner changed during recovery. Review the current owner before retrying.");
62
+ const ownerLock = await lstat(paths.owner).catch((error) => {
63
+ if (error.code === "ENOENT")
64
+ return undefined;
65
+ throw error;
66
+ });
67
+ if (ownerLock)
68
+ throw new Error("The daemon exited without releasing its owner lock. Follow daemon recovery.");
29
69
  await checkUpgradeConsent(paths, assertRoot, signal);
70
+ if (!sameBarrier(await readUpgradeOwner(paths), owner))
71
+ throw new Error("Daemon upgrade record changed; private state was retained.");
72
+ signal?.throwIfAborted();
73
+ assertRoot();
30
74
  await clearUpgradeOwner(paths);
31
75
  signal?.throwIfAborted();
32
76
  assertRoot();
33
77
  }
34
- async function drainForUpgrade(paths, owner, { recorded, birth }, assertRoot, signal) {
35
- await checkUpgradeConsent(paths, assertRoot, signal);
78
+ async function drainForUpgrade(paths, owner, { recorded, birth, guarded }, assertRoot, signal) {
79
+ await checkUpgradeConsent(paths, assertRoot, signal, owner.instance);
36
80
  const barrier = recorded ?? { ...owner, birth };
81
+ if (!sameIdentity(await readIdentity(paths), owner))
82
+ throw new Error("Daemon owner changed before stop.");
83
+ signal?.throwIfAborted();
84
+ assertRoot();
85
+ assertInstalledBuild();
86
+ if (!recorded)
87
+ await recordUpgradeOwner(paths, barrier);
88
+ let reply;
37
89
  try {
38
- if (!recorded)
39
- await recordUpgradeOwner(paths, barrier);
90
+ signal?.throwIfAborted();
40
91
  assertRoot();
41
- const reply = await requestDaemon(paths, owner, "stop", {}, signal);
42
- if (!record(reply) || reply.stopping !== true)
92
+ assertInstalledBuild();
93
+ reply = await requestDaemon(paths, owner, guarded ? "upgrade-stop" : "stop", {}, signal);
94
+ if (!record(reply) || (reply.stopping !== true && (!guarded || !isDeferral(reply.deferred))))
43
95
  throw new Error("Daemon did not acknowledge stop.");
44
96
  }
45
97
  catch (error) {
46
98
  signal?.throwIfAborted();
47
- throw new Error("Pi Sync could not upgrade the older daemon safely. Check `pi-sync-daemon status --root <agent-directory>`. Do not force a second owner or remove recovery files.", { cause: error });
99
+ throw new Error("Pi Sync could not replace the daemon safely. Check `pi-sync-daemon status --root <agent-directory>`. Do not force a second owner or remove recovery files.", { cause: error });
100
+ }
101
+ if (guarded && isDeferral(reply.deferred) && reply.stopping !== true) {
102
+ const current = await readIdentity(paths);
103
+ const pending = await readUpgradeOwner(paths);
104
+ signal?.throwIfAborted();
105
+ assertRoot();
106
+ if (!sameIdentity(current, owner) || !sameBarrier(pending, barrier))
107
+ throw new Error("Daemon owner or upgrade record changed; private state was retained.");
108
+ await clearUpgradeOwner(paths);
109
+ throw new DaemonUpgradeBlockedError(owner.instance, reply.deferred);
48
110
  }
49
111
  await finishUpgrade(paths, barrier, assertRoot, signal);
50
112
  }
113
+ function isDeferral(value) {
114
+ return value === "busy" || value === "unattended" || value === "repair";
115
+ }
51
116
  export async function acquireStartupLock(paths, signal) {
52
117
  const deadline = performance.now() + 150_000;
53
118
  for (;;) {
@@ -70,25 +135,38 @@ export async function acquireStartupLock(paths, signal) {
70
135
  }
71
136
  }
72
137
  }
73
- export async function ensureDaemon(root, signal, options) {
138
+ export function ensureDaemon(root, signal, options) {
139
+ return startDaemon(root, signal, options?.compatibleOnly ? "compatible-only" : "ensure");
140
+ }
141
+ export function restartDaemon(root, signal) {
142
+ return startDaemon(root, signal, "restart");
143
+ }
144
+ async function startDaemon(root, signal, intent) {
74
145
  const paths = await runtimePaths(root);
75
146
  const assertRoot = canonicalRootGuard(paths.root);
76
147
  signal?.throwIfAborted();
77
148
  await privateDirectory(paths.directory);
149
+ const restartTarget = intent === "restart" ? { identity: await readIdentity(paths) } : undefined;
78
150
  signal?.throwIfAborted();
79
151
  const release = await acquireStartupLock(paths, signal);
80
152
  try {
81
153
  signal?.throwIfAborted();
82
154
  let waited = false;
83
155
  let upgraded = false;
156
+ let verifyRestartTarget = restartTarget !== undefined;
84
157
  for (;;) {
85
158
  signal?.throwIfAborted();
86
159
  const upgrade = await readUpgradeOwner(paths);
87
- if (upgrade && options?.compatibleOnly)
160
+ if (upgrade && intent === "compatible-only")
88
161
  throw new Error("A daemon upgrade or recovery is pending; no replacement was attempted.");
89
162
  if (upgrade && (await upgradeRepairStarted(paths, upgrade)))
90
163
  throw new Error("A daemon upgrade repair is incomplete. Run `pi-sync-daemon repair-upgrade` for this root.");
91
164
  const existing = await readIdentity(paths);
165
+ if (verifyRestartTarget) {
166
+ if (!sameIdentity(existing, restartTarget?.identity))
167
+ throw new Error("Daemon owner changed while waiting to restart. Check status before retrying.");
168
+ verifyRestartTarget = false;
169
+ }
92
170
  if (upgrade && existing?.instance === upgrade.instance && existing.pid !== upgrade.pid)
93
171
  throw new Error("The recorded upgrade owner changed; private state was retained.");
94
172
  if (upgrade && (existing?.instance !== upgrade.instance || (await processExited(upgrade)))) {
@@ -124,38 +202,53 @@ export async function ensureDaemon(root, signal, options) {
124
202
  }
125
203
  signal?.throwIfAborted();
126
204
  assertRoot();
127
- if (!status.needsUpgrade) {
205
+ const restart = intent === "restart" && !upgraded;
206
+ if (restart && status.buildVersion && gt(status.buildVersion, DAEMON_BUILD_VERSION))
207
+ throw new Error("The running daemon is newer than this CLI. Use the intended Pi Sync build to restart it.");
208
+ if (!status.needsUpgrade && !restart) {
128
209
  if (upgrade)
129
210
  throw new Error("The recorded upgrade owner changed; private state was retained.");
130
- return { paths: daemonPaths(paths, existing.instance), identity: existing, ...status };
211
+ return { paths: daemonPaths(paths, existing.instance), identity: existing, ...status, replacedOwner: false };
131
212
  }
132
- if (options?.compatibleOnly)
213
+ if (intent === "compatible-only")
133
214
  throw new Error("A compatible daemon could not be attached; an older owner was left unchanged.");
134
215
  if (upgraded)
135
216
  throw new Error("An older Pi Sync daemon started again. Close or upgrade other Pi sessions, then use /reload.");
217
+ if (!status.upgradeStop && !restart)
218
+ throw new DaemonUpgradeBlockedError(existing.instance, "legacy");
136
219
  const birth = beforeHello === undefined ? undefined : await readProcessBirth(existing.pid);
137
- if (birth !== undefined && birth !== beforeHello)
220
+ if (birth !== beforeHello || (upgrade?.birth !== undefined && (await processExited(upgrade))))
138
221
  throw new Error("The daemon process changed during authentication; private state was retained.");
139
- await drainForUpgrade(paths, existing, { recorded: upgrade, birth }, assertRoot, signal);
222
+ await drainForUpgrade(paths, existing, { recorded: upgrade, birth, guarded: status.upgradeStop }, assertRoot, signal);
140
223
  upgraded = true;
141
224
  }
142
225
  signal?.throwIfAborted();
143
226
  assertRoot();
227
+ assertInstalledBuild();
144
228
  const executable = process.versions.bun ? "node" : process.execPath;
145
- const child = spawn(executable, [fileURLToPath(new URL("./cli.js", import.meta.url)), "serve", "--root", paths.root], {
229
+ const child = spawn(executable, [
230
+ fileURLToPath(new URL("./cli.js", import.meta.url)),
231
+ "serve",
232
+ "--root",
233
+ paths.root,
234
+ "--expect-build",
235
+ DAEMON_BUILD_VERSION,
236
+ DAEMON_BUILD_ID ?? "",
237
+ ], {
146
238
  detached: true,
147
239
  stdio: ["ignore", "ignore", "ignore", "ipc"],
148
240
  windowsHide: true,
149
241
  });
150
242
  const ready = await new Promise((resolve, reject) => {
151
- let timer;
243
+ let booting = false;
244
+ let timer = setTimeout(() => failed(new Error("Daemon bootstrap timed out before the child handshake.")), 60_000);
245
+ timer.unref?.();
152
246
  const abort = () => {
153
247
  cleanup();
154
248
  reject(signal?.reason);
155
249
  };
156
250
  const cleanup = () => {
157
- if (timer)
158
- clearTimeout(timer);
251
+ clearTimeout(timer);
159
252
  signal?.removeEventListener("abort", abort);
160
253
  child.off("message", message);
161
254
  child.off("error", failed);
@@ -169,15 +262,20 @@ export async function ensureDaemon(root, signal, options) {
169
262
  const message = (value) => {
170
263
  if (!record(value))
171
264
  return;
172
- if (value.type === "booting") {
265
+ if (value.type === "booting" && !booting) {
266
+ booting = true;
267
+ clearTimeout(timer);
173
268
  timer = setTimeout(() => failed(new Error("Daemon readiness timed out.")), 15_000);
174
269
  timer.unref?.();
175
270
  }
176
271
  if (value.type === "error")
177
272
  failed(new Error(typeof value.message === "string" ? value.message : "Daemon startup failed."));
178
- if (value.type === "ready" && record(value.identity)) {
273
+ if (value.type === "ready") {
274
+ const candidate = value.identity;
275
+ if (!record(candidate) || candidate.pid !== child.pid || candidate.root !== paths.root)
276
+ return failed(new Error("Daemon readiness identity did not match the launched process."));
179
277
  cleanup();
180
- resolve(value.identity);
278
+ resolve(candidate);
181
279
  }
182
280
  };
183
281
  signal?.addEventListener("abort", abort, { once: true });
@@ -187,16 +285,21 @@ export async function ensureDaemon(root, signal, options) {
187
285
  if (signal?.aborted)
188
286
  abort();
189
287
  }).finally(() => {
288
+ if (!child.pid)
289
+ child.once("error", () => { });
190
290
  if (child.connected)
191
291
  child.disconnect();
192
292
  child.unref();
193
293
  });
194
- const status = await hello(paths, ready, signal);
294
+ const published = await readIdentity(paths);
295
+ if (!published || !sameIdentity(published, ready))
296
+ throw new Error("Ready daemon was not the published owner.");
297
+ const status = await hello(paths, published, signal);
195
298
  signal?.throwIfAborted();
196
299
  assertRoot();
197
- if (status.needsUpgrade)
300
+ if (!matchesBuild(status.buildVersion, status.buildId))
198
301
  throw new Error("The daemon installation changed during startup. Use /reload to retry.");
199
- return { paths: daemonPaths(paths, ready.instance), identity: ready, ...status };
302
+ return { paths: daemonPaths(paths, ready.instance), identity: ready, ...status, replacedOwner: upgraded };
200
303
  }
201
304
  finally {
202
305
  await release();
@@ -216,7 +319,8 @@ async function waitForProcessExit(owner, signal) {
216
319
  }
217
320
  signal?.throwIfAborted();
218
321
  }
219
- export async function findDaemon(root) {
322
+ export async function findDaemon(root, signal) {
323
+ signal?.throwIfAborted();
220
324
  let paths;
221
325
  try {
222
326
  paths = await runtimePaths(root);
@@ -227,10 +331,11 @@ export async function findDaemon(root) {
227
331
  throw error;
228
332
  }
229
333
  const identity = await readIdentity(paths);
334
+ signal?.throwIfAborted();
230
335
  if (!identity || !processExists(identity.pid))
231
336
  return undefined;
232
337
  try {
233
- const status = await hello(paths, identity);
338
+ const status = await hello(paths, identity, signal);
234
339
  return { paths: daemonPaths(paths, identity.instance), identity, ...status };
235
340
  }
236
341
  catch (error) {
@@ -0,0 +1,56 @@
1
+ import path from "node:path";
2
+ import { gt } from "semver";
3
+ import { DAEMON_BUILD_ID, DAEMON_BUILD_VERSION } from "./build-version.js";
4
+ import { hello } from "./client-transport.js";
5
+ import { processExited, readIdentity, readUpgradeOwner, runtimePaths } from "./identity.js";
6
+ import { PROTOCOL_VERSION } from "./protocol.js";
7
+ export async function inspectDaemonStatus(root, signal) {
8
+ signal?.throwIfAborted();
9
+ const paths = await runtimePaths(root);
10
+ const identity = await readIdentity(paths);
11
+ const pending = await readUpgradeOwner(paths);
12
+ const summary = {
13
+ root: paths.root,
14
+ expectedBuildVersion: DAEMON_BUILD_VERSION,
15
+ ...(DAEMON_BUILD_ID && { expectedBuildId: DAEMON_BUILD_ID }),
16
+ ...(identity && { recordedPid: identity.pid }),
17
+ ...(pending && { pendingUpgradePid: pending.pid }),
18
+ };
19
+ signal?.throwIfAborted();
20
+ if (!identity ||
21
+ (pending?.instance === identity.instance && pending.pid === identity.pid && (await processExited(pending)))) {
22
+ signal?.throwIfAborted();
23
+ return { running: false, ...summary };
24
+ }
25
+ try {
26
+ const build = await hello(paths, identity, signal);
27
+ signal?.throwIfAborted();
28
+ return {
29
+ running: true,
30
+ ...summary,
31
+ version: PROTOCOL_VERSION,
32
+ instance: identity.instance,
33
+ pid: identity.pid,
34
+ ...(build.buildVersion && { buildVersion: build.buildVersion }),
35
+ ...(build.buildId && { buildId: build.buildId }),
36
+ buildComparison: compareBuild(build),
37
+ ...(build.upgradeStop && { guardedUpgrade: true }),
38
+ lifecycleLog: path.join(paths.directory, "lifecycle.log"),
39
+ };
40
+ }
41
+ catch {
42
+ signal?.throwIfAborted();
43
+ return { running: null, ...summary };
44
+ }
45
+ }
46
+ function compareBuild({ buildVersion, buildId, needsUpgrade }) {
47
+ if (!buildVersion)
48
+ return "unversioned";
49
+ if (needsUpgrade)
50
+ return "older";
51
+ if (gt(buildVersion, DAEMON_BUILD_VERSION))
52
+ return "newer";
53
+ if (!buildId || !DAEMON_BUILD_ID)
54
+ return "unverified";
55
+ return buildId === DAEMON_BUILD_ID ? "match" : "different";
56
+ }
@@ -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.validateIgnorePolicy) {
173
- await options.validateIgnorePolicy();
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, isIgnoreSnapshotVersion(manifest.snapshotVersion));
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, strictUtf8 = false) {
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 { isIgnoreSnapshotVersion, isSupportedSnapshotVersion, } from "../../snapshot/snapshot-types.js";
5
- import { sameLocalFields, validateIgnoreSnapshotIdentity, validateIgnoreSnapshotSessionFlag, validatePortableSnapshot, validateSnapshotFieldPolicy, } from "../../sync/local-fields.js";
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
- !isSupportedSnapshotVersion(manifest.snapshotVersion) ||
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 policy = validateSnapshotIgnoreRules({
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 > byteLimit) {
102
- throw new Error(`Git snapshot content exceeds the ${byteLimit}-byte limit.`);
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.validateIgnorePolicy)
82
- await options.validateIgnorePolicy();
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.validateIgnorePolicy)
90
- await options.validateIgnorePolicy();
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.validateIgnorePolicy)
130
- await options.validateIgnorePolicy();
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.validateIgnorePolicy)
65
- await options.validateIgnorePolicy();
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.validateIgnorePolicy)
76
- await options.validateIgnorePolicy();
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.validateIgnorePolicy)
113
- await options.validateIgnorePolicy();
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);