@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.
Files changed (175) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/README.md +26 -48
  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-HLJIRWFL.ts → chunk-BCDBT4X3.ts} +7 -7
  8. package/dist/chunks/{chunk-AVTW6WNP.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-X344HTVV.ts → chunk-WCGLU526.ts} +39 -118
  19. package/dist/chunks/chunk-WCGLU526.ts.map +7 -0
  20. package/dist/chunks/{chunk-CQ4DMLH3.ts → chunk-WQXUZSY5.ts} +25 -83
  21. package/dist/chunks/chunk-WQXUZSY5.ts.map +7 -0
  22. package/dist/chunks/{chunk-JREGWM2B.ts → chunk-XNUARYLR.ts} +1 -2
  23. package/dist/chunks/{command-handler-WF2TDDRZ.ts → command-handler-5LDTCUJE.ts} +64 -59
  24. package/dist/chunks/command-handler-5LDTCUJE.ts.map +7 -0
  25. package/dist/chunks/{conflict-review-GWEL4S6C.ts → conflict-review-SZ3AWTX6.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-BXN46NRC.ts → manager-result-dispatcher-A4IWLS4J.ts} +7 -7
  29. package/dist/chunks/{manager-ui-FS4QIKRA.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-DOYKUMER.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-PI45SF2C.ts → setup-wizard-2NRPR433.ts} +11 -16
  35. package/dist/chunks/{setup-wizard-PI45SF2C.ts.map → setup-wizard-2NRPR433.ts.map} +1 -1
  36. package/dist/chunks/{sync-inspection-DI5J6EUH.ts → sync-inspection-OTI4JDQ2.ts} +5 -5
  37. package/dist/chunks/{sync-operations-AGNL7QXA.ts → sync-operations-ZUYJLWUN.ts} +2 -2
  38. package/dist/daemon/dist/build-id.json +1 -1
  39. package/dist/daemon/dist/cli.js +22 -3
  40. package/dist/daemon/dist/client-transport.js +2 -0
  41. package/dist/daemon/dist/client.js +2 -10
  42. package/dist/daemon/dist/consent.js +13 -135
  43. package/dist/daemon/dist/engine/backends/git/git-backend.js +4 -17
  44. package/dist/daemon/dist/engine/backends/git/git-storage.js +11 -44
  45. package/dist/daemon/dist/engine/backends/s3/s3-backend.js +6 -6
  46. package/dist/daemon/dist/engine/backends/webdav/webdav-backend.js +6 -6
  47. package/dist/daemon/dist/engine/settings/config.js +16 -149
  48. package/dist/daemon/dist/engine/settings/retired-ignore-policy.js +16 -0
  49. package/dist/daemon/dist/engine/settings/retired-ignore-recovery.js +14 -0
  50. package/dist/daemon/dist/engine/settings/settings-management.js +2 -10
  51. package/dist/daemon/dist/engine/settings/settings-validation.js +8 -21
  52. package/dist/daemon/dist/engine/snapshot/session-paths.js +13 -41
  53. package/dist/daemon/dist/engine/snapshot/snapshot-apply.js +8 -24
  54. package/dist/daemon/dist/engine/snapshot/snapshot-codec.js +7 -11
  55. package/dist/daemon/dist/engine/snapshot/snapshot-exclude-safety.js +19 -76
  56. package/dist/daemon/dist/engine/snapshot/snapshot-transaction-images.js +1 -7
  57. package/dist/daemon/dist/engine/snapshot/snapshot-transaction-policy.js +8 -102
  58. package/dist/daemon/dist/engine/snapshot/snapshot-transaction.js +20 -100
  59. package/dist/daemon/dist/engine/snapshot/snapshot-types.js +1 -11
  60. package/dist/daemon/dist/engine/snapshot/snapshot.js +26 -78
  61. package/dist/daemon/dist/engine/state/sync-state-store.js +5 -1
  62. package/dist/daemon/dist/engine/sync/agent-plan.js +0 -1
  63. package/dist/daemon/dist/engine/sync/agent-policy.js +1 -1
  64. package/dist/daemon/dist/engine/sync/conflict-review.js +0 -2
  65. package/dist/daemon/dist/engine/sync/continuous-sync.js +2 -17
  66. package/dist/daemon/dist/engine/sync/continuous-watch.js +3 -7
  67. package/dist/daemon/dist/engine/sync/directional-action.js +3 -21
  68. package/dist/daemon/dist/engine/sync/initialization.js +4 -15
  69. package/dist/daemon/dist/engine/sync/local-fields.js +4 -65
  70. package/dist/daemon/dist/engine/sync/merge-apply.js +8 -31
  71. package/dist/daemon/dist/engine/sync/merge-journal.js +8 -118
  72. package/dist/daemon/dist/engine/sync/merged-sync.js +12 -70
  73. package/dist/daemon/dist/engine/sync/push-review.js +1 -16
  74. package/dist/daemon/dist/engine/sync/remote-snapshot.js +48 -65
  75. package/dist/daemon/dist/engine/sync/startup-bootstrap.js +3 -3
  76. package/dist/daemon/dist/engine/sync/sync-error-guidance.js +1 -1
  77. package/dist/daemon/dist/engine/sync/sync-inspection.js +1 -2
  78. package/dist/daemon/dist/engine/sync/sync-mutations.js +25 -118
  79. package/dist/daemon/dist/engine/sync/sync-policy.js +26 -150
  80. package/dist/daemon/dist/engine/sync/sync-queries.js +81 -65
  81. package/dist/daemon/dist/engine/sync/sync-rollback.js +12 -50
  82. package/dist/daemon/dist/engine/sync/sync-state.js +2 -15
  83. package/dist/daemon/dist/engine/sync/transfer-freshness.js +7 -17
  84. package/dist/daemon/dist/engine/sync/transfer-size-limits.js +3 -7
  85. package/dist/daemon/dist/engine/ui/sync-format.js +1 -1
  86. package/dist/daemon/dist/engine-service.js +60 -219
  87. package/dist/daemon/dist/foreground-queue-outcome.js +0 -4
  88. package/dist/daemon/dist/legacy-consent-guard.js +34 -0
  89. package/dist/daemon/dist/server.js +4 -8
  90. package/dist/daemon/dist/service-host.js +4 -10
  91. package/dist/daemon/package.json +1 -1
  92. package/dist/index.ts +45 -46
  93. package/dist/index.ts.map +3 -3
  94. package/docs/continuous-sync-verification.md +1 -1
  95. package/docs/daemon-migration.md +7 -5
  96. package/docs/tui-contract.md +4 -6
  97. package/package.json +2 -3
  98. package/skills/configure-pi-sync/SKILL.md +18 -77
  99. package/skills/configure-pi-sync/references/configuration.md +60 -77
  100. package/src/commands/command-execution.ts +13 -29
  101. package/src/commands/command-handler.ts +0 -4
  102. package/src/commands/command.ts +2 -1
  103. package/src/daemon/directional-recovery.ts +4 -33
  104. package/src/daemon/pi-client.ts +28 -90
  105. package/src/settings/config.ts +0 -1
  106. package/src/sync/setup-switch.ts +1 -4
  107. package/src/sync-extension.ts +10 -24
  108. package/src/ui/cancellable-operation.ts +2 -13
  109. package/src/ui/excluded-paths-ui.ts +1 -4
  110. package/src/ui/file-selection.ts +0 -5
  111. package/src/ui/manager-state.ts +12 -75
  112. package/src/ui/manager-ui.ts +7 -96
  113. package/src/ui/remote-selection-ui.ts +29 -130
  114. package/src/ui/settings-ui.ts +169 -388
  115. package/src/ui/setup/setup-actions.ts +4 -16
  116. package/src/ui/setup/setup-prompts.ts +12 -49
  117. package/src/ui/setup/setup-switcher.ts +8 -14
  118. package/src/ui/storage-connections-ui.ts +21 -32
  119. package/src/ui/sync-setups-ui.ts +27 -53
  120. package/dist/chunks/chunk-2MUAR5GH.ts.map +0 -7
  121. package/dist/chunks/chunk-33EDXDLC.ts +0 -106
  122. package/dist/chunks/chunk-33EDXDLC.ts.map +0 -7
  123. package/dist/chunks/chunk-AVTW6WNP.ts.map +0 -7
  124. package/dist/chunks/chunk-CQ4DMLH3.ts.map +0 -7
  125. package/dist/chunks/chunk-DGVZYS7T.ts.map +0 -7
  126. package/dist/chunks/chunk-EJDDRS6O.ts +0 -17
  127. package/dist/chunks/chunk-EJDDRS6O.ts.map +0 -7
  128. package/dist/chunks/chunk-KNEUL4XN.ts +0 -30
  129. package/dist/chunks/chunk-KNEUL4XN.ts.map +0 -7
  130. package/dist/chunks/chunk-PUSMSKIM.ts.map +0 -7
  131. package/dist/chunks/chunk-WFBHWYI6.ts +0 -18
  132. package/dist/chunks/chunk-WFBHWYI6.ts.map +0 -7
  133. package/dist/chunks/chunk-X344HTVV.ts.map +0 -7
  134. package/dist/chunks/command-handler-WF2TDDRZ.ts.map +0 -7
  135. package/dist/chunks/config-P54GGMXY.ts +0 -39
  136. package/dist/chunks/continuous-record-3SKJ6I3V.ts +0 -23
  137. package/dist/chunks/continuous-record-3SKJ6I3V.ts.map +0 -7
  138. package/dist/chunks/continuous-storage-3EU6I7Z3.ts +0 -27
  139. package/dist/chunks/continuous-storage-3EU6I7Z3.ts.map +0 -7
  140. package/dist/chunks/file-selection-GASCVN45.ts.map +0 -7
  141. package/dist/chunks/ignore-file-ui-BEZZZIEE.ts +0 -21
  142. package/dist/chunks/manager-ui-FS4QIKRA.ts.map +0 -7
  143. package/dist/chunks/merge-review-C2KETZKY.ts +0 -11
  144. package/dist/chunks/merge-review-C2KETZKY.ts.map +0 -7
  145. package/dist/chunks/remote-selection-ui-DOYKUMER.ts.map +0 -7
  146. package/dist/chunks/setup-switch-JZDFQPVW.ts.map +0 -7
  147. package/dist/daemon/dist/engine/ignore/adoption-journal.js +0 -146
  148. package/dist/daemon/dist/engine/ignore/effective-ignore-policy.js +0 -33
  149. package/dist/daemon/dist/engine/ignore/ignore-edit.js +0 -102
  150. package/dist/daemon/dist/engine/ignore/ignore-initialization.js +0 -288
  151. package/dist/daemon/dist/engine/ignore/ignore-migration-prompt.js +0 -139
  152. package/dist/daemon/dist/engine/ignore/ignore-settings.js +0 -391
  153. package/dist/daemon/dist/engine/ignore/ignore-source.js +0 -250
  154. package/dist/daemon/dist/engine/ignore/snapshot-ignore-rules.js +0 -39
  155. package/dist/daemon/dist/engine/sync/ignore-adoption-recovery.js +0 -50
  156. package/dist/daemon/dist/engine/sync/ignore-adoption.js +0 -416
  157. package/dist/daemon/dist/engine/sync/ignore-publication.js +0 -23
  158. package/dist/daemon/dist/engine/ui/ignore-rule-preview.js +0 -18
  159. package/dist/daemon/dist/monitor.js +0 -344
  160. package/src/ui/agent-mode-setting.ts +0 -99
  161. package/src/ui/ignore-file-guidance.ts +0 -7
  162. package/src/ui/ignore-file-ui.ts +0 -105
  163. package/src/ui/ignore-migration-prompt.ts +0 -65
  164. package/src/ui/settings-review.ts +0 -26
  165. /package/dist/chunks/{chunk-HLJIRWFL.ts.map → chunk-BCDBT4X3.ts.map} +0 -0
  166. /package/dist/chunks/{chunk-WBIOSK76.ts.map → chunk-R7PN3KIY.ts.map} +0 -0
  167. /package/dist/chunks/{chunk-3Q3DMMID.ts.map → chunk-TLYT6HVI.ts.map} +0 -0
  168. /package/dist/chunks/{chunk-JREGWM2B.ts.map → chunk-XNUARYLR.ts.map} +0 -0
  169. /package/dist/chunks/{conflict-review-GWEL4S6C.ts.map → conflict-review-SZ3AWTX6.ts.map} +0 -0
  170. /package/dist/chunks/{config-P54GGMXY.ts.map → manager-result-dispatcher-A4IWLS4J.ts.map} +0 -0
  171. /package/dist/chunks/{chunk-ECUCXF5Y.ts.map → merge-review-LWMUE5IW.ts.map} +0 -0
  172. /package/dist/chunks/{ignore-file-ui-BEZZZIEE.ts.map → remote-selection-ui-F6NJBQ3Y.ts.map} +0 -0
  173. /package/dist/chunks/{manager-result-dispatcher-BXN46NRC.ts.map → setup-switch-7LMIRMZ7.ts.map} +0 -0
  174. /package/dist/chunks/{sync-inspection-DI5J6EUH.ts.map → sync-inspection-OTI4JDQ2.ts.map} +0 -0
  175. /package/dist/chunks/{sync-operations-AGNL7QXA.ts.map → sync-operations-ZUYJLWUN.ts.map} +0 -0
@@ -1,10 +1,8 @@
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";
4
3
  import { loadConfig, syncCheckConfigFingerprint } from "../settings/config.js";
5
4
  import { effectiveSessionRoot, requireStableMergeSessionRoot, snapshotOptionsForContext, } from "../snapshot/session-paths.js";
6
5
  import { createSnapshot, filterSnapshotForConfigPolicy, mergeRemotePreservedFiles, observeSnapshot, regenerateSnapshotIdentity, scanSnapshot, snapshotWithObservedInventory, } from "../snapshot/snapshot.js";
7
- import { ignorePolicyValidator } from "../snapshot/snapshot-transaction-policy.js";
8
6
  import { hasCurrentMergeBaseline, pruneMergeBaselines, readMergeAncestors } from "../state/merge-baseline-store.js";
9
7
  import { readStateForConfig, statePathForConfig, syncStateFingerprint } from "../state/sync-state-store.js";
10
8
  import { confirmMergeReview } from "../ui/merge-review.js";
@@ -18,11 +16,10 @@ import { pruneCompletedConflicts } from "./conflict-retention.js";
18
16
  import { resolveContentConflicts } from "./content-conflicts.js";
19
17
  import { ContinuousError, TransferSizeError } from "./continuous-errors.js";
20
18
  import { planFileMerge } from "./file-merge-planner.js";
21
- import { ignorePublicationNotice, withPublishedIgnoreRules } from "./ignore-publication.js";
22
19
  import { overlayLocalFields, portableSnapshot, sameLocalFields } from "./local-fields.js";
23
20
  import { acceptedState, matchesAcceptedState, writeAcceptedState } from "./merge-acceptance.js";
24
21
  import { applyMergedSnapshot, preflightMergedTargets } from "./merge-apply.js";
25
- import { assertMergeJournalPolicy, clearMergeJournal, mergeJournalIdentity, mergeJournalPolicy, readMergeJournal, reviewInactiveIgnoreMerge, sameMergeRecoveryHead, writeMergeJournal, } from "./merge-journal.js";
22
+ import { clearMergeJournal, mergeJournalIdentity, readMergeJournal, sameMergeRecoveryHead, writeMergeJournal, } from "./merge-journal.js";
26
23
  import { mergeTransferError } from "./merge-transfer-error.js";
27
24
  import { acceptedMergeFiles } from "./partial-progress.js";
28
25
  import { formatRemoteSelectionStatus, readSnapshotForHead, requireCompatibleRemoteSelection, } from "./remote-snapshot.js";
@@ -33,12 +30,10 @@ import { backupSnapshot, captureMutationOwner, protectedSessionPaths } from "./s
33
30
  import { configuredSnapshotPathMatcher, inspectRemoteSelection, syncSessionsSelected } from "./sync-policy.js";
34
31
  import { fileHashMap, hasLocalChanges, hasRemoteChanges, sameHashes, syncPolicyChanged } from "./sync-state.js";
35
32
  import { TEXT_MERGE_WORK_LIMIT } from "./text-merge.js";
36
- import { checkLiveProtection, validateMergeApplyReview, validateMergedPublication } from "./transfer-freshness.js";
37
33
  import { requireTransferSize, selectedPublicationImage, transferSizeDetails, transferSizeLimitsEnabled, } from "./transfer-size-limits.js";
38
34
  const MAX_ATTEMPTS = 3;
39
35
  /** Established-baseline sync only. First-source selection remains in the existing command flow. */
40
36
  export async function mergeSync(ctx, options, factory = createSyncBackend, resolution) {
41
- requireNoPendingAdoption();
42
37
  const timings = options.startupTimings ?? createStartupTimings();
43
38
  const sessionOwner = captureMutationOwner(ctx, options.signal);
44
39
  const validateOwner = (config) => {
@@ -62,8 +57,6 @@ export async function mergeSync(ctx, options, factory = createSyncBackend, resol
62
57
  };
63
58
  const config = await loadConfig(options.setup);
64
59
  validateOwner(config);
65
- if (config.pathPolicy === "ignore-file" && !config.ignorePolicy)
66
- throw new Error("Merged sync requires the resolved local ignore-file policy.");
67
60
  validateRetryAuthorization(config);
68
61
  const configToken = syncCheckConfigFingerprint(config);
69
62
  const modelToken = JSON.stringify(ctx.model);
@@ -94,34 +87,16 @@ export async function mergeSync(ctx, options, factory = createSyncBackend, resol
94
87
  if (options.auto && (!startupTransferEnabled(latest) || !ctx.isIdle()))
95
88
  throw new Error("Automatic transfer is no longer authorized at this idle boundary.");
96
89
  });
97
- const validateIgnore = ignorePolicyValidator({
98
- ...config,
99
- signal: options.signal,
100
- validateMutation: () => {
101
- validateOwner();
102
- if (options.auto && !ctx.isIdle())
103
- throw new Error("Automatic transfer is no longer authorized at this idle boundary.");
104
- },
105
- });
106
- const validateFresh = validateIgnore
107
- ? async () => {
108
- await validate();
109
- await validateIgnore();
110
- }
111
- : validate;
90
+ const validateFresh = validate;
112
91
  await validateFresh();
113
92
  const pending = await timings.measure("transfer journal read", () => readMergeJournal(config));
114
93
  await validate();
115
94
  if (pending && options.agentRetryRefusal)
116
95
  throw new Error("A pending merge journal requires ordinary Sync now before retrying a refused candidate.");
117
- if (pending)
118
- assertMergeJournalPolicy(pending, config);
119
96
  const backend = await timings.measure("transfer backend initialization", () => factory(config));
120
97
  await validate();
121
98
  if (pending) {
122
99
  const recovered = await timings.measure("transfer journal recovery", () => completeJournal(ctx, config, backend, pending, { validate, validateFresh, validateOwner }, timings, options, resolution ? undefined : isCurrent));
123
- if (recovered === "archived" || recovered === "cancelled")
124
- return recovered;
125
100
  if (!recovered) {
126
101
  if ((options.auto || !options.silent) && !options.signal?.aborted)
127
102
  ctx.ui.notify("Interrupted candidate is not active; local content and baseline were unchanged. Evidence was reconciled without retrying publication. Run sync again for a fresh plan.", "warning");
@@ -133,7 +108,7 @@ export async function mergeSync(ctx, options, factory = createSyncBackend, resol
133
108
  }
134
109
  // Recovery above never publishes. This gate applies only to new autonomous transfers.
135
110
  if ((options.auto || config.agentMode) && backend.capability === "read-check-write-verify") {
136
- throw new Error("Automatic transfer requires conditional publication or a lease; this backend supports only read/check/write/verify. Disable Autonomous sync and use manual sync.");
111
+ throw new Error("Automatic transfer requires conditional publication or a lease; this backend supports only read/check/write/verify. Use reviewed manual sync.");
137
112
  }
138
113
  const textBudget = { remaining: TEXT_MERGE_WORK_LIMIT };
139
114
  const createdArtifacts = [];
@@ -182,7 +157,7 @@ export async function mergeSync(ctx, options, factory = createSyncBackend, resol
182
157
  }
183
158
  }
184
159
  const rawRemote = head
185
- ? await timings.measure("transfer snapshot download", () => readSnapshotForHead(backend, head, options.signal, config))
160
+ ? await timings.measure("transfer snapshot download", () => readSnapshotForHead(backend, head, options.signal))
186
161
  : undefined;
187
162
  await validate();
188
163
  if (rawRemote) {
@@ -375,9 +350,7 @@ export async function mergeSync(ctx, options, factory = createSyncBackend, resol
375
350
  const publish = !sameHashes(fileHashMap(publication), fileHashMap(remote)) ||
376
351
  Boolean(config.partialSync && rawRemote.version < 3);
377
352
  const candidate = mergeRemotePreservedFiles(publication, rawRemote, config, { sessionDir: sessionRoot });
378
- const upload = publish ? await withPublishedIgnoreRules(candidate, config, options.signal) : candidate;
379
- if (config.ignorePolicy && publish)
380
- await validate();
353
+ const upload = candidate;
381
354
  const apply = !sameHashes(fileHashMap(localRaw), fileHashMap(after));
382
355
  if (!publish && !apply) {
383
356
  const beforeEvidence = await timings.measure("transfer remote head", () => backend.readHead(options.signal));
@@ -433,8 +406,7 @@ export async function mergeSync(ctx, options, factory = createSyncBackend, resol
433
406
  decisions: plan.decisions,
434
407
  capability: backend.capability,
435
408
  });
436
- const notice = ignorePublicationNotice(upload);
437
- 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)))
409
+ if (!(await confirmMergeReview(ctx, summary.title, summary.content, options.signal, isCurrent, summary.confirmationLabel, summary.lines)))
438
410
  return "cancelled";
439
411
  }
440
412
  await validate();
@@ -458,7 +430,7 @@ export async function mergeSync(ctx, options, factory = createSyncBackend, resol
458
430
  const backup = await timings.measure("transfer backup", () => backupSnapshot(regenerateSnapshotIdentity(refreshed), options.signal));
459
431
  await validateFresh();
460
432
  const journal = {
461
- ...mergeJournalPolicy(config),
433
+ version: 1,
462
434
  identity: mergeJournalIdentity(config, backend.identity),
463
435
  before: localRaw,
464
436
  after,
@@ -501,11 +473,7 @@ export async function mergeSync(ctx, options, factory = createSyncBackend, resol
501
473
  const result = await timings.measure("transfer remote publication", () => backend.publishSnapshot(upload, expectedRemoteHead(head), {
502
474
  signal: options.signal,
503
475
  onCommit: options.onCommit,
504
- ...(validateIgnore
505
- ? {
506
- validateIgnorePolicy: () => validateMergedPublication(ctx, config, snapshotOptions, localRaw, after, journal.stateIdentity, validateFresh),
507
- }
508
- : { validateIgnorePolicy: validateFresh }),
476
+ validatePublication: validateFresh,
509
477
  }));
510
478
  journal.committedHead = result.head;
511
479
  journal.warnings = result.warnings;
@@ -551,7 +519,7 @@ export async function mergeSync(ctx, options, factory = createSyncBackend, resol
551
519
  await timings.measure("transfer cleanup", () => releaseConflictArtifacts(config, ownedStatePath, createdArtifacts));
552
520
  }
553
521
  }
554
- async function completeJournal(ctx, config, backend, journal, { validate, validateFresh, validateOwner, }, timings, options, isCurrent) {
522
+ async function completeJournal(ctx, config, backend, journal, { validate, validateFresh, validateOwner, }, timings, options, _isCurrent) {
555
523
  const { auto, signal } = options;
556
524
  const validateMutation = () => {
557
525
  validateOwner();
@@ -561,7 +529,6 @@ async function completeJournal(ctx, config, backend, journal, { validate, valida
561
529
  if (journal.identity !== mergeJournalIdentity(config, backend.identity) ||
562
530
  !sameLocalFields(journal.upload.localFields, config.localFields))
563
531
  throw new Error("Merge journal belongs to a different setup, selection or local-field policy; preserve it for reviewed recovery.");
564
- assertMergeJournalPolicy(journal, config);
565
532
  await validateFresh();
566
533
  const sessionRoot = config.scope === "agent-directory" || syncSessionsSelected(config)
567
534
  ? await effectiveSessionRoot(ctx, config, signal)
@@ -597,8 +564,6 @@ async function completeJournal(ctx, config, backend, journal, { validate, valida
597
564
  const state = await timings.measure("transfer state read", () => readStateForConfig(config));
598
565
  await validate();
599
566
  if (matchesAcceptedState(state, config, journal.committedHead, journal.accepted ?? journal.after, journal.progress)) {
600
- if (journal.localPolicyKey)
601
- await validateFresh();
602
567
  await clearMergeJournal(config);
603
568
  await validate();
604
569
  await pruneMergeBaselines(config, state, captureMutationOwner(ctx, signal));
@@ -606,28 +571,13 @@ async function completeJournal(ctx, config, backend, journal, { validate, valida
606
571
  return true;
607
572
  }
608
573
  }
609
- if (head &&
610
- (journal.ignoreSource || head.selection?.version === 4) &&
611
- inspectRemoteSelection(config.include, { selection: head.selection, files: [] }, config.exclude, config).kind !==
612
- "same")
613
- throw new Error("Remote ignore-file policy differs or is unavailable; preserve the pending merge for review.");
614
574
  if (!journal.committedHead &&
615
575
  head &&
616
576
  (backend.sameRevision(head.revision, journal.expectedHead.revision) ||
617
577
  backend.matchesUncommittedRecoveryHead?.(head, journal.expectedHead))) {
618
- if (journal.ignoreSource &&
619
- (head.snapshotId !== journal.expectedHead.snapshotId ||
620
- head.snapshotRef !== journal.expectedHead.snapshotRef ||
621
- head.snapshotId === journal.upload.id))
622
- throw new Error("Cannot verify that the ignore-file candidate is inactive; preserve the journal and backup.");
623
578
  const { sameBaseline, sameLocal } = await readRetirementEvidence();
624
579
  validateMutation();
625
580
  if (!sameBaseline || !sameLocal) {
626
- if (journal.ignoreSource) {
627
- if (!sameBaseline)
628
- throw new Error("Sync baseline changed after uncertain publication; preserve the journal and backup for review.");
629
- return reviewInactiveIgnoreMerge(ctx, config, backend, journal, head, options, validateFresh, isCurrent);
630
- }
631
581
  throw new Error("Uncertain publication is not active, but local content or baseline changed; keep the journal for reviewed recovery.");
632
582
  }
633
583
  await clearMergeJournal(config);
@@ -647,14 +597,11 @@ async function completeJournal(ctx, config, backend, journal, { validate, valida
647
597
  (journal.committedHead && !backend.sameRevision(head.revision, journal.committedHead.revision))) {
648
598
  throw new Error("Publication outcome cannot be reconciled with the current remote head. Journal and backup retained; do not retry publication or restore old bytes blindly.");
649
599
  }
650
- const observed = await timings.measure("transfer snapshot download", () => readSnapshotForHead(backend, head, signal, config));
600
+ const observed = await timings.measure("transfer snapshot download", () => readSnapshotForHead(backend, head, signal));
651
601
  requireCompatibleRemoteSelection(config, observed);
652
602
  if (!sameHashes(fileHashMap(observed), fileHashMap(journal.upload)) ||
653
603
  JSON.stringify(observed.selection) !== JSON.stringify(journal.upload.selection) ||
654
- observed.version !== journal.upload.version ||
655
- (observed.ignoreRules === null) !== (journal.upload.ignoreRules === null) ||
656
- observed.ignoreRules?.filename !== journal.upload.ignoreRules?.filename ||
657
- observed.ignoreRules?.text !== journal.upload.ignoreRules?.text)
604
+ observed.version !== journal.upload.version)
658
605
  throw new Error("Remote snapshot does not match the recorded merge publication.");
659
606
  const state = await timings.measure("transfer state read", () => readStateForConfig(config));
660
607
  if (matchesAcceptedState(state, config, head, journal.accepted ?? journal.after, journal.progress)) {
@@ -689,13 +636,8 @@ async function completeJournal(ctx, config, backend, journal, { validate, valida
689
636
  const protectedPaths = protectedSessionPaths(ctx, sessionRoot);
690
637
  const validateApply = () => {
691
638
  validateMutation();
692
- if (journal.localPolicyKey)
693
- checkLiveProtection(ctx, sessionRoot, protectedPaths);
694
639
  };
695
- const validateApplyReview = journal.localPolicyKey
696
- ? () => validateMergeApplyReview(backend, config, head, journal.stateIdentity, validateFresh, signal)
697
- : undefined;
698
- await timings.measure("transfer local apply", () => applyMergedSnapshot(journal.before, journal.after, protectedPaths, { ...snapshotOptions, validateMutation: validateApply, validateApplyReview, requireReviewedApplyImage }, validate, ctx.sessionManager.getSessionFile?.()));
640
+ await timings.measure("transfer local apply", () => applyMergedSnapshot(journal.before, journal.after, protectedPaths, { ...snapshotOptions, validateMutation: validateApply, requireReviewedApplyImage }, validate, ctx.sessionManager.getSessionFile?.()));
699
641
  await validate();
700
642
  const headAtAcceptance = await timings.measure("transfer remote head", () => backend.readHead(signal));
701
643
  await validate();
@@ -1,29 +1,14 @@
1
1
  import { snapshotIncludesSessions } from "../snapshot/snapshot.js";
2
- import { formatRuleChanges } from "../ui/ignore-rule-preview.js";
3
2
  import { countPreservedRemoteFiles, formatPushSummary, formatTransferReview } from "../ui/sync-format.js";
4
3
  import { setSyncStatus } from "../ui/sync-status.js";
5
4
  import { confirmTransferReview } from "../ui/transfer-review.js";
6
- import { ignorePublicationNotice } from "./ignore-publication.js";
7
5
  import { throwIfAborted } from "./signals.js";
8
- import { formatIgnorePolicyComparison, inspectRemoteSelection } from "./sync-policy.js";
9
6
  export async function confirmPush(ctx, options, config, backend, local, upload, head, remote, validateMutation, title = snapshotIncludesSessions(upload) ? "Push pi settings and sessions?" : "Push pi settings?") {
10
7
  validateMutation();
11
8
  if (options.yes)
12
9
  return true;
13
10
  const summary = formatPushSummary(config, backend.destination, upload, head, countPreservedRemoteFiles(local, upload), remote);
14
- const comparison = config.ignorePolicy && remote
15
- ? inspectRemoteSelection(config.include, remote, config.exclude, config).ignorePolicyComparison
16
- : undefined;
17
- const notice = ignorePublicationNotice(upload);
18
- const overwrite = comparison !== undefined && comparison !== "match";
19
- const confirmed = await confirmTransferReview(ctx, overwrite ? "Overwrite remote policy and push?" : title, formatTransferReview(...(overwrite
20
- ? [
21
- formatIgnorePolicyComparison(comparison),
22
- "This replaces the remote policy with this device's rules. Remote rules are not adopted on this device.",
23
- `Sessions opt-in: ${remote?.selection?.version === 4 ? (remote.selection.sessions ? "on" : "off") : "legacy"} → ${config.ignorePolicy?.sessions ? "on" : "off"}.`,
24
- formatRuleChanges(remote?.ignoreRules?.text, upload.ignoreRules?.text),
25
- ]
26
- : []), ...(notice ? [notice, ""] : []), summary), options.signal, validateMutation);
11
+ const confirmed = await confirmTransferReview(ctx, title, formatTransferReview(summary), options.signal, validateMutation);
27
12
  throwIfAborted(options.signal);
28
13
  if (confirmed)
29
14
  return true;
@@ -3,7 +3,7 @@ import { filterSnapshotForConfigPolicy, mergeRemotePreservedFiles } from "../sna
3
3
  import { safeTerminalText } from "../ui/terminal-text.js";
4
4
  import { sameLocalFields, validatePortableSnapshot } from "./local-fields.js";
5
5
  import { throwIfAborted } from "./signals.js";
6
- import { formatIgnorePolicyComparison, inspectRemoteSelection, remoteSelectionMismatch, requireLegacyTransferPolicy, sameSnapshotSelection, } from "./sync-policy.js";
6
+ import { inspectRemoteSelection, remoteSelectionMismatch, requireLegacyTransferPolicy, sameSnapshotSelection, } from "./sync-policy.js";
7
7
  import { syncPolicyChanged } from "./sync-state.js";
8
8
  async function readValidatedSnapshotForHead(backend, head, signal) {
9
9
  const snapshot = await backend.readSnapshot(head.snapshotRef, signal);
@@ -22,73 +22,17 @@ function validateSnapshotForHead(snapshot, head) {
22
22
  }
23
23
  return snapshot;
24
24
  }
25
- export async function readSnapshotForHead(backend, head, signal, config) {
26
- const snapshot = await readValidatedSnapshotForHead(backend, head, signal);
27
- if (!config)
28
- requireLegacyTransferPolicy(snapshot);
29
- else if (!config.ignorePolicy && snapshot.selection?.version === 4)
30
- requireCompatibleRemoteSelection(config, snapshot);
31
- return snapshot;
32
- }
33
- export async function readRemoteSnapshotForUpload(backend, config, head, state, options) {
34
- if (!head)
35
- return undefined;
36
- if (config.ignorePolicy ||
37
- head.selection?.version === 4 ||
38
- head.snapshotId !== state.lastAppliedSnapshot ||
39
- syncPolicyChanged(state, config) ||
40
- (state.lastRemoteRevision && !backend.sameRevision(head.revision, state.lastRemoteRevision)) ||
41
- (!options.force &&
42
- (config.scope === "agent-directory" ||
43
- (head.selection &&
44
- inspectRemoteSelection(config.include, { selection: head.selection, files: [] }, config.exclude, config)
45
- .kind === "different"))))
46
- return readSnapshotForHead(backend, head, options.signal, config);
47
- return undefined;
48
- }
49
- export async function snapshotForUpload(backend, config, local, head, remote, options) {
50
- if (config.ignorePolicy)
51
- return filterSnapshotForConfigPolicy(local, config, { ...options, regenerateId: true });
52
- if (!head)
53
- return config.reservedIgnoreNames === undefined ? local : filterSnapshotForConfigPolicy(local, config, options);
54
- const snapshot = remote ?? (await readSnapshotForHead(backend, head, options.signal, config));
55
- const remoteScoped = snapshot.selection?.version === 3;
56
- if (remoteScoped !== (config.scope === "agent-directory")) {
57
- throw new Error("Converting an existing remote between included paths and agent-directory scope is not supported. Use a separate storage location.");
58
- }
59
- return mergeRemotePreservedFiles(local, snapshot, config, options);
60
- }
61
- export function sameRemoteHead(backend, left, right) {
62
- if (!left || !right)
63
- return left === right;
64
- return (left.snapshotId === right.snapshotId &&
65
- left.snapshotRef === right.snapshotRef &&
66
- backend.sameRevision(left.revision, right.revision) &&
67
- sameSnapshotSelection(left.selection, right.selection));
68
- }
69
25
  export function requireCompatibleRemoteSelection(config, snapshot) {
70
- const state = inspectRemoteSelection(config.include, snapshot, config.exclude, config);
71
- if (state.kind === "different" && state.ignorePolicyComparison)
72
- throw selectionMismatch(config, state);
73
26
  if (!sameLocalFields(config.localFields, snapshot.localFields))
74
27
  throw new Error("Remote local-field policy differs; confirm a reviewed directional migration. Old history is not erased.");
75
- if (state.kind === "different")
76
- throw selectionMismatch(config, state);
77
- }
78
- export async function inspectHeadSelection(backend, config, head, signal) {
79
- const remote = !head.selection && config.ignorePolicy
80
- ? await readValidatedSnapshotForHead(backend, head, signal)
81
- : { selection: head.selection, files: [] };
82
- return inspectRemoteSelection(config.include, remote, config.exclude, config);
83
- }
84
- function selectionMismatch(config, state) {
85
- return remoteSelectionMismatch(config, state.include, syncConfigReviewFingerprint(config), state.exclude, state);
28
+ const state = inspectRemoteSelection(config.include, snapshot, config.exclude, config);
29
+ if (state.kind === "different") {
30
+ throw remoteSelectionMismatch(config, state.include, syncConfigReviewFingerprint(config), state.exclude, state);
31
+ }
86
32
  }
87
33
  export function formatRemoteSelectionStatus(state) {
88
34
  if (!state)
89
35
  return "remote included content: unavailable (remote is empty)";
90
- if (state.ignorePolicyComparison)
91
- return formatIgnorePolicyComparison(state.ignorePolicyComparison);
92
36
  if (state.kind === "same")
93
37
  return "remote included content: matches this setup";
94
38
  if (state.kind === "legacy") {
@@ -116,10 +60,8 @@ export async function readRemoteSnapshot(backend, config, signal, options = {})
116
60
  if (options.validateSelection)
117
61
  options.validateSelection(rawSnapshot);
118
62
  else if (!options.allowSelectionDifference && selectionState.kind === "different")
119
- throw selectionMismatch(config, selectionState);
120
- const snapshot = selectionState.ignorePolicyComparison === "local-legacy-remote-ignore"
121
- ? undefined
122
- : filterSnapshotForConfigPolicy(rawSnapshot, config, { sessionDir: options.sessionDir });
63
+ throw remoteSelectionMismatch(config, selectionState.include, syncConfigReviewFingerprint(config), selectionState.exclude, selectionState);
64
+ const snapshot = filterSnapshotForConfigPolicy(rawSnapshot, config, { sessionDir: options.sessionDir });
123
65
  return { head, snapshot, selectionState };
124
66
  }
125
67
  async function readCurrentSnapshot(backend, singleObservation, signal) {
@@ -134,3 +76,44 @@ async function readCurrentSnapshot(backend, singleObservation, signal) {
134
76
  throwIfAborted(signal);
135
77
  return head && { head, snapshot: await readValidatedSnapshotForHead(backend, head, signal) };
136
78
  }
79
+ export async function readSnapshotForHead(backend, head, signal) {
80
+ const snapshot = await readValidatedSnapshotForHead(backend, head, signal);
81
+ requireLegacyTransferPolicy(snapshot);
82
+ return snapshot;
83
+ }
84
+ export async function readRemoteSnapshotForUpload(backend, config, head, state, options) {
85
+ if (!head)
86
+ return undefined;
87
+ if (!head.selection ||
88
+ head.snapshotId !== state.lastAppliedSnapshot ||
89
+ syncPolicyChanged(state, config) ||
90
+ (state.lastRemoteRevision && !backend.sameRevision(head.revision, state.lastRemoteRevision)) ||
91
+ (!options.force &&
92
+ (config.scope === "agent-directory" ||
93
+ inspectRemoteSelection(config.include, { selection: head.selection, files: [] }, config.exclude, config)
94
+ .kind === "different")))
95
+ return readSnapshotForHead(backend, head, options.signal);
96
+ return undefined;
97
+ }
98
+ export async function snapshotForUpload(backend, config, local, head, remote, options) {
99
+ if (!head)
100
+ return local;
101
+ const snapshot = remote ?? (await readSnapshotForHead(backend, head, options.signal));
102
+ if ((snapshot.selection?.version === 3) !== (config.scope === "agent-directory"))
103
+ throw new Error("Converting an existing remote between included paths and agent-directory scope is not supported. Use a separate storage location.");
104
+ return mergeRemotePreservedFiles(local, snapshot, config, options);
105
+ }
106
+ export function sameRemoteHead(backend, left, right) {
107
+ if (!left || !right)
108
+ return left === right;
109
+ return (left.snapshotId === right.snapshotId &&
110
+ left.snapshotRef === right.snapshotRef &&
111
+ backend.sameRevision(left.revision, right.revision) &&
112
+ sameSnapshotSelection(left.selection, right.selection));
113
+ }
114
+ export async function inspectHeadSelection(backend, config, head, signal) {
115
+ const remote = head.selection
116
+ ? { selection: head.selection, files: [] }
117
+ : await readSnapshotForHead(backend, head, signal);
118
+ return inspectRemoteSelection(config.include, remote, config.exclude, config);
119
+ }
@@ -5,6 +5,7 @@ import { documentFingerprint } from "../../document.js";
5
5
  import { MAX_SETTINGS_BYTES } from "../../protocol.js";
6
6
  import { configFromSettings } from "../settings/config.js";
7
7
  import { legacyLocalConfigPath, localConfigPath } from "../settings/config-file.js";
8
+ import { hasRetiredRuleJournal } from "../settings/retired-ignore-recovery.js";
8
9
  import { validateSettingsDocument } from "../settings/settings-validation.js";
9
10
  import { stateDirectoryMigrationNotice } from "../state/state-directory.js";
10
11
  import { statePathForConfig } from "../state/sync-state-store.js";
@@ -63,7 +64,7 @@ function readCanonicalSettings() {
63
64
  }
64
65
  export function captureStartupBootstrap(root, expected, signal, reviewOwnsLock) {
65
66
  signal.throwIfAborted();
66
- if (stateDirectoryMigrationNotice())
67
+ if (stateDirectoryMigrationNotice() || hasRetiredRuleJournal(root))
67
68
  return;
68
69
  const recovery = startupRecoveryEvidence(root, reviewOwnsLock);
69
70
  if (recovery === undefined)
@@ -85,8 +86,6 @@ export function captureStartupBootstrap(root, expected, signal, reviewOwnsLock)
85
86
  if (!settings.activeSyncSetup)
86
87
  return;
87
88
  const config = configFromSettings(settings);
88
- if (config.reservedIgnoreNames)
89
- return;
90
89
  const stateFile = statePathForConfig(config);
91
90
  const noMergeJournal = () => {
92
91
  const setupDirectory = inspect(path.dirname(stateFile));
@@ -97,6 +96,7 @@ export function captureStartupBootstrap(root, expected, signal, reviewOwnsLock)
97
96
  signal.throwIfAborted();
98
97
  return (readCanonicalSettings()?.fingerprint === expected &&
99
98
  !stateDirectoryMigrationNotice() &&
99
+ !hasRetiredRuleJournal(root) &&
100
100
  JSON.stringify(readConsent(root)) === consentToken &&
101
101
  noMergeJournal() &&
102
102
  startupRecoveryEvidence(root, reviewOwnsLock) === recovery);
@@ -30,7 +30,7 @@ export function syncErrorGuidance(error) {
30
30
  }
31
31
  else if (/\bagent directory exceeds the (64 MiB scan byte|scan file) bound\b/iu.test(message)) {
32
32
  next =
33
- "Reduce the files managed by this setup before retrying. Use /sync config to find the active ignore file, or edit Agent directory scope in /sync → Settings for legacy rules.";
33
+ "Reduce the files managed by this setup before retrying. Edit Agent directory scope in /sync → Settings to exclude paths you do not need.";
34
34
  }
35
35
  else if (/changed while|type changed|reopen/iu.test(message)) {
36
36
  next = "Reopen the item in /sync and review its current settings before saving again.";
@@ -28,8 +28,7 @@ export async function inspectSync(config, options, signal, factory = createSyncB
28
28
  selectionState,
29
29
  localFiles: local.files.length,
30
30
  localChanged: hasLocalChanges(local, state, config),
31
- remoteChanged: (selectionState?.kind === "different" && !!selectionState.ignorePolicyComparison) ||
32
- remoteChangedSinceState(head, state, config, (left, right) => backend.sameRevision(left, right)),
31
+ remoteChanged: remoteChangedSinceState(head, state, config, (left, right) => backend.sameRevision(left, right)),
33
32
  firstSync: !state.lastAppliedSnapshot,
34
33
  emptyInclude: !syncSelectionHasContent(config),
35
34
  stateIdentity: syncStateFingerprint(state),