@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,12 +1,10 @@
1
1
  import { createSyncBackend } from "../backends/backend-factory.js";
2
2
  import { expectedRemoteHead, SyncBackendConflictError, } from "../backends/sync-backend.js";
3
- import { adoptionJournalFingerprint, loadAdoptionJournal, requireNoPendingAdoption, } from "../ignore/adoption-journal.js";
4
3
  import { loadConfig, loadConfigForCheck, syncCheckConfigFingerprint } from "../settings/config.js";
5
4
  import { effectiveSessionRoot, requireStableMergeSessionRoot, resolvedSnapshotOptionsForContext, sessionDirForApply, } from "../snapshot/session-paths.js";
6
5
  import { createSnapshot, filterSnapshotForConfigPolicy, scanSnapshot, snapshotIncludesSessions, } from "../snapshot/snapshot.js";
7
6
  import { applySnapshot } from "../snapshot/snapshot-apply.js";
8
7
  import { pendingTransactionEntries } from "../snapshot/snapshot-transaction-directory.js";
9
- import { ignorePolicyValidator } from "../snapshot/snapshot-transaction-policy.js";
10
8
  import { pruneMergeBaselines } from "../state/merge-baseline-store.js";
11
9
  import { readStateForConfig, syncStateFingerprint, writeStateForConfig } from "../state/sync-state-store.js";
12
10
  import { formatPullSummary } from "../ui/sync-format.js";
@@ -16,8 +14,6 @@ import { startupTransferEnabled } from "./agent-policy.js";
16
14
  import { inspectCaseCleanup, revalidateCaseCleanup } from "./apply-review.js";
17
15
  import { checkpointDirectionalAction, foregroundDirectionalAction, keepProtectedRemoteSessions, localRestoreGuidance, notifyDirectionalSuccess, remoteRestoreGuidance, requireDirectionalPullBoundary, requireDirectionalSelection, validateDirectionalSettings, } from "./directional-action.js";
18
16
  import { confirmFieldMigration } from "./field-migration.js";
19
- import { adoptionSettingsFingerprint, adoptRemoteRules, canReviewAdoption } from "./ignore-adoption.js";
20
- import { withPublishedIgnoreRules } from "./ignore-publication.js";
21
17
  import { overlayLocalFields, portableSnapshot, sameLocalFields, validatePortableSnapshot } from "./local-fields.js";
22
18
  import { readMergeJournal, requireNoMergeJournal, retireMergeJournal } from "./merge-journal.js";
23
19
  import { mergeSync } from "./merged-sync.js";
@@ -27,15 +23,14 @@ import { throwIfAborted } from "./signals.js";
27
23
  import { createSyncDecision } from "./sync-decision.js";
28
24
  import { errorMessage, PublicationStatePersistenceError } from "./sync-errors.js";
29
25
  import { backupDirectionalSnapshot, backupLocal, captureMutationOwner, LocalBackupVerificationError, maybeReload, protectedSessionPaths, } from "./sync-local.js";
30
- import { inspectRemoteSelection, syncSelectionHasContent, syncSessionsSelected } from "./sync-policy.js";
26
+ import { syncSelectionHasContent, syncSessionsSelected } from "./sync-policy.js";
31
27
  import { acceptedSelection, canPullRemoteSessionsOnFirstSync, canPullRemoteSettingsOnFirstSync, fileHashMap, hasLocalChanges, hasRemoteChanges, remoteChangedSinceState, sameHashes, shouldRefreshSyncedState, snapshotHashesMatchState, snapshotsMatch, syncPolicyChanged, } from "./sync-state.js";
32
- import { checkLiveProtection, directionalApplyGuards, requireIgnoreBaselineReview, requireResolvedDirectionalProgress, validateDirectionalPublication, } from "./transfer-freshness.js";
28
+ import { checkLiveProtection, directionalApplyGuards, requireResolvedDirectionalProgress, validateDirectionalPublication, } from "./transfer-freshness.js";
33
29
  import { requireTransferSize, selectedPublicationImage, selectedPullImage, transferSizeLimitsEnabled, } from "./transfer-size-limits.js";
34
30
  const VERSION = 1;
35
31
  export { PublicationStatePersistenceError, RollbackPublicationError } from "./sync-errors.js";
36
32
  export { rollback } from "./sync-rollback.js";
37
33
  export async function push(ctx, options, input, factory = createSyncBackend) {
38
- requireNoPendingAdoption();
39
34
  const validateOwner = captureMutationOwner(ctx, options.signal);
40
35
  const validateCommittedOwner = captureMutationOwner(ctx);
41
36
  const action = foregroundDirectionalAction(ctx, options);
@@ -55,10 +50,7 @@ export async function push(ctx, options, input, factory = createSyncBackend) {
55
50
  validateMutation();
56
51
  requireResolvedDirectionalProgress(state, options);
57
52
  if (options.auto &&
58
- (config.scope === "agent-directory" ||
59
- state.scope !== undefined ||
60
- config.reservedIgnoreNames !== undefined ||
61
- state.ignorePolicyKey !== undefined) &&
53
+ (config.scope === "agent-directory" || state.scope !== undefined) &&
62
54
  (options.force || !state.lastAppliedSnapshot || syncPolicyChanged(state, config))) {
63
55
  throw new Error("Automatic push requires an accepted baseline with matching content policy.");
64
56
  }
@@ -69,34 +61,23 @@ export async function push(ctx, options, input, factory = createSyncBackend) {
69
61
  if (action)
70
62
  snapshotOptions.sessionDir = await effectiveSessionRoot(ctx, config, options.signal);
71
63
  validateMutation();
72
- const validateIgnorePolicy = ignorePolicyValidator({ ...snapshotOptions, validateMutation });
73
64
  const localRaw = input?.local ?? (await createSnapshot(config.snapshotIdentity, snapshotOptions));
74
65
  const local = portableSnapshot(localRaw, config.localFields);
75
66
  const reviewedProtectedPaths = action ? protectedSessionPaths(ctx, snapshotOptions.sessionDir) : new Set();
76
- if (validateIgnorePolicy)
77
- await validateIgnorePolicy();
78
67
  throwIfAborted(options.signal);
79
68
  let head = await backend.readHead(options.signal);
80
69
  let remoteForUpload = action && head
81
- ? await readSnapshotForHead(backend, head, options.signal, config)
70
+ ? await readSnapshotForHead(backend, head, options.signal)
82
71
  : await readRemoteSnapshotForUpload(backend, config, head, state, options);
83
72
  validateMutation();
84
- const policyOverwrite = Boolean(config.ignorePolicy &&
85
- remoteForUpload &&
86
- inspectRemoteSelection(config.include, remoteForUpload, config.exclude, config).kind === "different");
87
- if (policyOverwrite && remoteForUpload && (options.auto || options.background || options.yes || !ctx.hasUI))
88
- requireCompatibleRemoteSelection(config, remoteForUpload);
89
- if (action && !policyOverwrite)
73
+ if (action)
90
74
  requireDirectionalSelection(config, state, localRaw, remoteForUpload, snapshotOptions.sessionDir);
91
- else
92
- requireIgnoreBaselineReview(ctx, config, state, options);
93
- if (!action && remoteForUpload && !options.force && !policyOverwrite) {
75
+ if (!action && remoteForUpload && !options.force) {
94
76
  requireCompatibleRemoteSelection(config, remoteForUpload);
95
77
  }
96
78
  if (!action &&
97
79
  remoteChangedSinceState(head, state, config, (left, right) => backend.sameRevision(left, right)) &&
98
- !options.force &&
99
- !policyOverwrite) {
80
+ !options.force) {
100
81
  const remoteForConflict = remoteForUpload
101
82
  ? filterSnapshotForConfigPolicy(remoteForUpload, config, snapshotOptions)
102
83
  : undefined;
@@ -114,7 +95,7 @@ export async function push(ctx, options, input, factory = createSyncBackend) {
114
95
  }
115
96
  }
116
97
  if (!remoteForUpload && head && (config.localFields !== undefined || !options.yes))
117
- remoteForUpload = await readSnapshotForHead(backend, head, options.signal, config);
98
+ remoteForUpload = await readSnapshotForHead(backend, head, options.signal);
118
99
  validateMutation();
119
100
  if (!(await confirmFieldMigration(ctx, config, state, remoteForUpload, options.force, options.signal))) {
120
101
  setSyncStatus(ctx, undefined);
@@ -137,16 +118,15 @@ export async function push(ctx, options, input, factory = createSyncBackend) {
137
118
  upload = keepProtectedRemoteSessions(config, upload, remoteForUpload, snapshotOptions.sessionDir, reviewedProtectedPaths);
138
119
  validatePortableSnapshot(upload);
139
120
  }
140
- upload = await withPublishedIgnoreRules(upload, config, options.signal);
141
121
  validateMutation();
142
122
  checkUpload(upload);
143
123
  if (!config.skipSecretScan) {
144
- const secrets = scanSnapshot({ ...local, ...(upload.ignoreRules ? { ignoreRules: upload.ignoreRules } : {}) });
124
+ const secrets = scanSnapshot(local);
145
125
  if (secrets.length > 0) {
146
126
  throw new Error(`Refusing to push possible secrets:\n${secrets.map((s) => `- ${s}`).join("\n")}`);
147
127
  }
148
128
  }
149
- if ((!action || policyOverwrite) &&
129
+ if (!action &&
150
130
  !(await confirmPush(ctx, options, config, backend, local, upload, head, remoteForUpload, validateMutation))) {
151
131
  return "cancelled";
152
132
  }
@@ -167,10 +147,8 @@ export async function push(ctx, options, input, factory = createSyncBackend) {
167
147
  const refreshedHead = await backend.readHead(options.signal);
168
148
  validateMutation();
169
149
  if (!sameRemoteHead(backend, head, refreshedHead)) {
170
- if (config.ignorePolicy)
171
- throw new Error("Remote changed during ignore-file push review; reopen the review.");
172
150
  head = refreshedHead;
173
- remoteForUpload = head ? await readSnapshotForHead(backend, head, options.signal, config) : undefined;
151
+ remoteForUpload = head ? await readSnapshotForHead(backend, head, options.signal) : undefined;
174
152
  validateMutation();
175
153
  if (!(await confirmFieldMigration(ctx, config, state, remoteForUpload, options.force, options.signal))) {
176
154
  setSyncStatus(ctx, undefined);
@@ -189,7 +167,6 @@ export async function push(ctx, options, input, factory = createSyncBackend) {
189
167
  await validateSettings();
190
168
  if (!action &&
191
169
  (config.scope === "agent-directory" ||
192
- validateIgnorePolicy ||
193
170
  !options.yes ||
194
171
  config.localFields !== undefined ||
195
172
  (await readMergeJournal(config)))) {
@@ -198,7 +175,7 @@ export async function push(ctx, options, input, factory = createSyncBackend) {
198
175
  throw new Error("Local content changed during push review; retry from current bytes.");
199
176
  }
200
177
  const currentState = await readStateForConfig(config);
201
- if ((validateIgnorePolicy || !options.yes) && syncStateFingerprint(currentState) !== syncStateFingerprint(state))
178
+ if (!options.yes && syncStateFingerprint(currentState) !== syncStateFingerprint(state))
202
179
  throw new Error("Baseline changed during push review.");
203
180
  requireResolvedDirectionalProgress(currentState, options);
204
181
  if (config.scope === "agent-directory" &&
@@ -206,24 +183,19 @@ export async function push(ctx, options, input, factory = createSyncBackend) {
206
183
  throw new Error("Pi session storage changed during push review.");
207
184
  validateMutation();
208
185
  await validateSettings();
209
- const validatePublication = validateIgnorePolicy || options.background || action
186
+ const validatePublication = options.background || action
210
187
  ? async () => {
211
188
  if (action && !sameRemoteHead(backend, head, await backend.readHead(options.signal)))
212
189
  throw new Error("Remote changed before Push could publish.");
213
190
  validateMutation();
214
191
  await validateDirectionalPublication(ctx, config, snapshotOptions, state, fileHashMap(localRaw), action
215
192
  ? async () => {
216
- await validateIgnorePolicy?.();
217
193
  await validateDirectionalSettings(options, config, validateMutation);
218
194
  checkLiveProtection(ctx, snapshotOptions.sessionDir, reviewedProtectedPaths);
219
195
  }
220
- : (validateIgnorePolicy ?? validateSettings), "push", Boolean(action));
196
+ : validateSettings, "push", Boolean(action));
221
197
  }
222
198
  : validateSettings;
223
- if (validateIgnorePolicy) {
224
- validatePortableSnapshot(upload);
225
- await validateIgnorePolicy();
226
- }
227
199
  if (action)
228
200
  await validatePublication?.();
229
201
  const accepted = action ? filterSnapshotForConfigPolicy(upload, config, snapshotOptions) : local;
@@ -242,7 +214,7 @@ export async function push(ctx, options, input, factory = createSyncBackend) {
242
214
  startedPublication = true;
243
215
  }
244
216
  : options.onCommit,
245
- validateIgnorePolicy: validatePublication,
217
+ validatePublication,
246
218
  });
247
219
  }
248
220
  catch (error) {
@@ -302,13 +274,6 @@ export async function pull(ctx, options, factory = createSyncBackend, initial) {
302
274
  const action = foregroundDirectionalAction(ctx, options);
303
275
  if (action && initial)
304
276
  throw new Error("Single-action Pull cannot be used for initial-source selection.");
305
- const adoptionReview = !initial && canReviewAdoption(ctx, options);
306
- const journal = adoptionReview ? await loadAdoptionJournal() : undefined;
307
- if (action?.expectedAdoptionJournal !== undefined &&
308
- (!journal || adoptionJournalFingerprint(journal) !== action.expectedAdoptionJournal))
309
- throw new Error("The recorded Pull changed during recovery. No transfer was started.");
310
- if (!adoptionReview)
311
- requireNoPendingAdoption();
312
277
  const validateOwner = captureMutationOwner(ctx, options.signal);
313
278
  const validateCommittedOwner = captureMutationOwner(ctx);
314
279
  const config = action ? await loadConfigForCheck(undefined, options.signal) : await loadConfig(options.setup);
@@ -321,7 +286,7 @@ export async function pull(ctx, options, factory = createSyncBackend, initial) {
321
286
  if (initial && initial.configIdentity !== configIdentity)
322
287
  throw new Error("Settings changed before initial pull; run sync again.");
323
288
  await requireNoMergeJournal(config, options);
324
- if (action && !journal && (await pendingTransactionEntries()).length)
289
+ if (action && (await pendingTransactionEntries()).length)
325
290
  throw new Error("A pending local transaction must be reconciled before Pull; its evidence was retained.");
326
291
  validateMutation();
327
292
  setSyncStatus(ctx, `pulling ${config.setupName}`, { activity: "pulling" });
@@ -335,27 +300,6 @@ export async function pull(ctx, options, factory = createSyncBackend, initial) {
335
300
  if (action)
336
301
  snapshotOptions.sessionDir = await effectiveSessionRoot(ctx, config, options.signal);
337
302
  validateMutation();
338
- if (journal) {
339
- if (journal.setupName !== config.setupName ||
340
- journal.setupFingerprint !== adoptionSettingsFingerprint(config) ||
341
- config.pathPolicy !== "ignore-file")
342
- throw new Error("Pending rule adoption belongs to a different setup. Preserve its journal and use the originating setup.");
343
- const remote = await readSnapshotForHead(backend, journal.head, options.signal, config);
344
- validateMutation();
345
- return adoptRemoteRules({
346
- ctx,
347
- options,
348
- config,
349
- backend,
350
- state,
351
- head: journal.head,
352
- remote,
353
- snapshotOptions,
354
- validateMutation,
355
- journal,
356
- });
357
- }
358
- const validateIgnorePolicy = ignorePolicyValidator({ ...snapshotOptions, validateMutation });
359
303
  if (initial && initial.sessionDir !== snapshotOptions.sessionDir)
360
304
  throw new Error("Pi session storage changed before initial pull; run sync again.");
361
305
  const local = await createSnapshot(config.snapshotIdentity, snapshotOptions);
@@ -363,44 +307,20 @@ export async function pull(ctx, options, factory = createSyncBackend, initial) {
363
307
  if (initial && !sameHashes(initial.localHashes, fileHashMap(local)))
364
308
  throw new Error("Local bytes changed before initial pull; run sync again.");
365
309
  let preimageRemote;
366
- let adoption;
367
310
  const { head, snapshot: remote } = await readRemoteSnapshot(backend, config, options.signal, {
368
311
  ...snapshotOptions,
369
- ...(action || (adoptionReview && config.ignorePolicy)
312
+ ...(action
370
313
  ? {
371
314
  validateSelection: (raw) => {
372
- const comparison = inspectRemoteSelection(config.include, raw, config.exclude, config).ignorePolicyComparison;
373
- if (adoptionReview && comparison === "mismatch") {
374
- adoption = raw;
375
- }
376
- else if (action) {
377
- requireDirectionalSelection(config, state, local, raw, snapshotOptions.sessionDir);
378
- preimageRemote = raw;
379
- }
380
- else {
381
- requireCompatibleRemoteSelection(config, raw);
382
- }
315
+ requireDirectionalSelection(config, state, local, raw, snapshotOptions.sessionDir);
316
+ preimageRemote = raw;
383
317
  },
384
318
  }
385
319
  : {}),
386
320
  });
387
321
  validateMutation();
388
- if (adoption && head)
389
- return adoptRemoteRules({
390
- ctx,
391
- options,
392
- config,
393
- backend,
394
- state,
395
- head,
396
- remote: adoption,
397
- snapshotOptions,
398
- validateMutation,
399
- });
400
322
  if (initial && !matchesInitialHead(initial, backend, head))
401
323
  throw new Error("Remote changed before initial pull; run sync again.");
402
- if (!action)
403
- requireIgnoreBaselineReview(ctx, config, state, options);
404
324
  const localChanged = hasLocalChanges(local, state, config);
405
325
  if (!remote) {
406
326
  throw createSyncDecision({
@@ -503,8 +423,7 @@ export async function pull(ctx, options, factory = createSyncBackend, initial) {
503
423
  await requireFreshRecovery();
504
424
  const currentState = await readStateForConfig(config);
505
425
  validateMutation();
506
- if ((validateIgnorePolicy || initial || !options.yes) &&
507
- syncStateFingerprint(currentState) !== syncStateFingerprint(state))
426
+ if ((initial || !options.yes) && syncStateFingerprint(currentState) !== syncStateFingerprint(state))
508
427
  throw new Error("Baseline changed during pull review.");
509
428
  requireResolvedDirectionalProgress(currentState, options);
510
429
  if (!action && !options.yes)
@@ -518,11 +437,6 @@ export async function pull(ctx, options, factory = createSyncBackend, initial) {
518
437
  if (!action && configIdentity !== syncCheckConfigFingerprint(await loadConfig(options.setup)))
519
438
  throw new Error("Settings changed during pull review.");
520
439
  validateMutation();
521
- if (validateIgnorePolicy) {
522
- if (!sameRemoteHead(backend, head, await backend.readHead(options.signal)))
523
- throw new Error("Remote changed during pull review.");
524
- await validateIgnorePolicy();
525
- }
526
440
  const protectedPaths = protectedSessionPaths(ctx, snapshotOptions.sessionDir);
527
441
  const validateApplySettings = async () => {
528
442
  if (configIdentity !== syncCheckConfigFingerprint(await loadConfig(options.setup, options.signal)))
@@ -547,26 +461,23 @@ export async function pull(ctx, options, factory = createSyncBackend, initial) {
547
461
  }
548
462
  : options.onCommit,
549
463
  validateMutation,
550
- validateIgnorePolicy: action
464
+ validateSettings: action
551
465
  ? async () => {
552
466
  await restorePoint?.validate();
553
- await validateIgnorePolicy?.();
554
467
  await validateActionBoundary?.();
555
468
  }
556
- : validateIgnorePolicy,
557
- validateSettings: action ? undefined : validateApplySettings,
469
+ : validateApplySettings,
470
+ strictReview: Boolean(action),
558
471
  effectiveRoot: Boolean(action),
559
472
  });
560
473
  applyGuards.validateMutation();
561
- if (!validateIgnorePolicy && !action)
474
+ if (!action)
562
475
  options.onCommit?.();
563
476
  const lastFileHashes = await applySnapshot(physical, protectedPaths, {
564
477
  ...snapshotOptions,
565
478
  sessionDir: applySessionDir,
566
479
  ...applyGuards,
567
- ...(action || config.scope === "agent-directory" || validateIgnorePolicy || sizeLimited
568
- ? { reviewedLocal: local }
569
- : {}),
480
+ ...(action || config.scope === "agent-directory" || sizeLimited ? { reviewedLocal: local } : {}),
570
481
  expectedFileHashes: config.localFields?.length
571
482
  ? { "settings.json": fileHashMap(local)["settings.json"] ?? null }
572
483
  : undefined,
@@ -621,7 +532,6 @@ export async function pull(ctx, options, factory = createSyncBackend, initial) {
621
532
  return "applied";
622
533
  }
623
534
  export async function syncBoth(ctx, options, factory = createSyncBackend) {
624
- requireNoPendingAdoption();
625
535
  if (options.directionalAction)
626
536
  throw new Error("Single-action transfer cannot authorize bidirectional Sync.");
627
537
  const validateMutation = captureMutationOwner(ctx, options.signal);
@@ -695,9 +605,6 @@ export async function syncBoth(ctx, options, factory = createSyncBackend) {
695
605
  configIdentity !== syncCheckConfigFingerprint(await loadConfig(options.setup)))
696
606
  throw new Error("Settings or Pi session storage changed before baseline acceptance; run sync again.");
697
607
  validateMutation();
698
- const validateIgnorePolicy = ignorePolicyValidator({ ...snapshotOptions, validateMutation });
699
- if (validateIgnorePolicy)
700
- await validateIgnorePolicy();
701
608
  }
702
609
  const accepted = portableSnapshot(snapshot, config.localFields);
703
610
  await writeStateForConfig(config, {
@@ -1,7 +1,6 @@
1
- import { createHash } from "node:crypto";
2
1
  import path from "node:path";
3
2
  import { DEBUG_LOG_FILENAME, isDebugLogPath, isDeniedPath, toPosix } from "../paths.js";
4
- import { isIgnoreSnapshotVersion, } from "../snapshot/snapshot-types.js";
3
+ import { retiredIgnorePolicy } from "../settings/retired-ignore-policy.js";
5
4
  import { compilePathRules, compileSyncExclude, normalizeSyncExclude, sameSyncExclude } from "./exclude-policy.js";
6
5
  export const BUILT_IN_SYNC_ROOTS = [
7
6
  "settings.json",
@@ -109,23 +108,9 @@ export function normalizeDirectoryRules(value) {
109
108
  : value);
110
109
  }
111
110
  export function portableSnapshotSelection(value) {
111
+ if (typeof value === "object" && value !== null && "version" in value && value.version === 4)
112
+ throw retiredIgnorePolicy("snapshot");
112
113
  const selection = value;
113
- if (selection && typeof selection === "object" && !Array.isArray(selection) && selection.version === 4) {
114
- if (selection.scope !== "agent-directory" ||
115
- typeof selection.sessions !== "boolean" ||
116
- typeof selection.fingerprint !== "string" ||
117
- selection.fingerprint.length !== 64 ||
118
- !/^[0-9a-f]{64}$/u.test(selection.fingerprint) ||
119
- Object.keys(selection).length !== 4 ||
120
- !["version", "scope", "sessions", "fingerprint"].every((key) => Object.hasOwn(selection, key)))
121
- throw new Error("Invalid ignore-file snapshot policy.");
122
- return {
123
- version: 4,
124
- scope: "agent-directory",
125
- fingerprint: selection.fingerprint,
126
- sessions: selection.sessions,
127
- };
128
- }
129
114
  if (selection && typeof selection === "object" && !Array.isArray(selection) && selection.version === 3) {
130
115
  if (selection.scope !== "agent-directory" ||
131
116
  !Array.isArray(selection.exclude) ||
@@ -150,10 +135,7 @@ export function portableSnapshotSelection(value) {
150
135
  return { version: 2, include, exclude: normalizeSyncExclude(selection.exclude) };
151
136
  }
152
137
  export function snapshotSelectionInclude(snapshot) {
153
- if (snapshot.selection === undefined)
154
- return undefined;
155
- const selection = portableSnapshotSelection(snapshot.selection);
156
- return selection.version === 4 ? (selection.sessions ? ["sessions"] : []) : selection.include;
138
+ return snapshot.selection === undefined ? undefined : portableSnapshotSelection(snapshot.selection).include;
157
139
  }
158
140
  export function snapshotSelectionExclude(snapshot) {
159
141
  return snapshot.selection === undefined ? undefined : portableSnapshotSelection(snapshot.selection).exclude;
@@ -171,16 +153,6 @@ function directorySelection(include, exclude, reinclude) {
171
153
  };
172
154
  }
173
155
  export function selectionForSnapshot(include, exclude, directory) {
174
- if (directory?.ignorePolicy) {
175
- if (directory.scope !== "agent-directory")
176
- throw new Error("Ignore rules require agent-directory scope.");
177
- return portableSnapshotSelection({
178
- version: 4,
179
- scope: directory.scope,
180
- fingerprint: directory.ignorePolicy.fingerprint,
181
- sessions: directory.ignorePolicy.sessions,
182
- });
183
- }
184
156
  if (directory?.scope === "agent-directory")
185
157
  return directorySelection(include, exclude, directory.reinclude);
186
158
  const normalized = normalizeSyncInclude(include);
@@ -194,13 +166,12 @@ export function sameSnapshotSelection(left, right) {
194
166
  JSON.stringify(right === undefined ? null : portableSnapshotSelection(right)));
195
167
  }
196
168
  export function validateSnapshotSelection(snapshot) {
169
+ requireLegacyTransferPolicy(snapshot);
197
170
  const selection = snapshot.selection === undefined ? undefined : portableSnapshotSelection(snapshot.selection);
198
171
  if ((snapshot.version === 4) !== (selection?.version === 2))
199
172
  throw new Error("Exclude policy requires snapshot version 4 and selection version 2.");
200
173
  if ((snapshot.version === 5) !== (selection?.version === 3))
201
174
  throw new Error("Agent-directory policy requires snapshot version 5 and selection version 3.");
202
- if (isIgnoreSnapshotVersion(snapshot.version) !== (selection?.version === 4))
203
- throw new Error("Ignore-file policy requires snapshot version 6 or 7 and selection version 4.");
204
175
  }
205
176
  export function assertSnapshotPathExcludesDebugLog(filePath) {
206
177
  if (typeof filePath === "string" && isDebugLogPath(filePath))
@@ -211,8 +182,12 @@ export function assertSnapshotExcludesDebugLog(snapshot) {
211
182
  assertSnapshotPathExcludesDebugLog(file?.path);
212
183
  }
213
184
  export function requireLegacyTransferPolicy(snapshot) {
214
- if (isIgnoreSnapshotVersion(snapshot.version) || snapshot.selection?.version === 4)
215
- throw new Error("This setup cannot transfer an ignore-file snapshot without a reviewed local ignore policy.");
185
+ const selectionVersion = snapshot.selection?.version;
186
+ if (snapshot.version === 6 ||
187
+ snapshot.version === 7 ||
188
+ selectionVersion === 4 ||
189
+ Object.hasOwn(snapshot, "ignoreRules"))
190
+ throw retiredIgnorePolicy("snapshot");
216
191
  }
217
192
  export function sameSyncInclude(left, right) {
218
193
  const normalizedLeft = normalizeSyncInclude(left);
@@ -231,39 +206,9 @@ export function compareSyncInclude(local, remote) {
231
206
  localOnly: localInclude.filter((item) => !remoteSet.has(item)),
232
207
  };
233
208
  }
234
- export function compareIgnorePolicy(local, remote) {
235
- if (remote?.version !== 4)
236
- return local ? "local-ignore-remote-legacy" : undefined;
237
- if (!local)
238
- return "local-legacy-remote-ignore";
239
- return local.fingerprint === remote.fingerprint && local.sessions === remote.sessions ? "match" : "mismatch";
240
- }
241
- export function formatIgnorePolicyComparison(comparison) {
242
- switch (comparison) {
243
- case "match":
244
- return "Remote ignore-file policy matches this device.";
245
- case "mismatch":
246
- return "Remote ignore-file policy differs. Review a directional Push or Pull; Pull needs the remote rule text.";
247
- case "local-ignore-remote-legacy":
248
- return "Remote uses a legacy content policy. Review publishing this device's ignore-file policy.";
249
- case "local-legacy-remote-ignore":
250
- return "Remote uses an ignore-file policy. Configure matching local rules before transferring.";
251
- }
252
- }
253
209
  export function syncDirectoryPolicyKey(config) {
254
210
  if (config.scope !== "agent-directory")
255
211
  return undefined;
256
- const policy = config.ignorePolicy;
257
- if (policy) {
258
- return JSON.stringify([
259
- "ignore-file",
260
- policy.fingerprint,
261
- policy.sessions,
262
- policy.filename,
263
- policy.sourceDigest,
264
- policy.reservedNames,
265
- ]);
266
- }
267
212
  return JSON.stringify([
268
213
  config.scope,
269
214
  includeFromSelectionConfig(config).includes("sessions"),
@@ -271,34 +216,8 @@ export function syncDirectoryPolicyKey(config) {
271
216
  normalizeDirectoryRules(config.reinclude).map((rule) => rule.toLowerCase()),
272
217
  ]);
273
218
  }
274
- export function localIgnorePolicyKey(config) {
275
- if (!config.ignorePolicy && config.reservedIgnoreNames === undefined)
276
- return undefined;
277
- const reserved = reservedIgnoreSnapshotNames(config);
278
- return createHash("sha256")
279
- .update(JSON.stringify([
280
- config.setupName,
281
- config.recoverySetupKey,
282
- syncDirectoryPolicyKey(config) ?? [
283
- includeFromSelectionConfig(config),
284
- normalizeSyncExclude(config.exclude).map((rule) => rule.toLowerCase()),
285
- ],
286
- config.ignoreSourceIdentity,
287
- [...(reserved ?? [])].sort(),
288
- ]))
289
- .digest("hex");
290
- }
291
219
  export function inspectRemoteSelection(localInclude, snapshot, localExclude, directory) {
292
220
  const selection = snapshot.selection === undefined ? undefined : portableSnapshotSelection(snapshot.selection);
293
- const ignorePolicyComparison = compareIgnorePolicy(directory?.ignorePolicy, selection);
294
- if (ignorePolicyComparison !== undefined) {
295
- const include = snapshotSelectionInclude(snapshot) ?? discoverLegacySnapshotInclude(snapshot);
296
- const scope = selection?.scope;
297
- if (ignorePolicyComparison === "match")
298
- return { kind: "same", include, scope, ignorePolicyComparison };
299
- const comparison = compareSyncInclude(directory?.ignorePolicy ? (directory.ignorePolicy.sessions ? ["sessions"] : []) : localInclude, include);
300
- return { kind: "different", include, scope, ...comparison, ignorePolicyComparison };
301
- }
302
221
  if (!selection && !directory?.scope)
303
222
  return { kind: "legacy", discovered: discoverLegacySnapshotInclude(snapshot) };
304
223
  const remoteInclude = selection?.include ?? discoverLegacySnapshotInclude(snapshot);
@@ -328,12 +247,10 @@ export class RemoteSelectionMismatchError extends Error {
328
247
  setupName;
329
248
  localInclude;
330
249
  remoteInclude;
331
- constructor(setupName, localInclude, remoteInclude, configIdentity = JSON.stringify([setupName, normalizeSyncInclude(localInclude)]), localExclude, remoteExclude, localDirectory, remoteDirectory, ignorePolicyComparison) {
250
+ constructor(setupName, localInclude, remoteInclude, configIdentity = JSON.stringify([setupName, normalizeSyncInclude(localInclude)]), localExclude, remoteExclude, localDirectory, remoteDirectory) {
332
251
  const local = normalizeSyncInclude(localInclude);
333
252
  const remote = normalizeSyncInclude(remoteInclude);
334
- super(ignorePolicyComparison
335
- ? formatIgnorePolicyComparison(ignorePolicyComparison)
336
- : formatRemoteSelectionMismatch(setupName, local, remote, localExclude, remoteExclude, localDirectory, remoteDirectory));
253
+ super(formatRemoteSelectionMismatch(setupName, local, remote, localExclude, remoteExclude, localDirectory, remoteDirectory));
337
254
  this.name = "RemoteSelectionMismatchError";
338
255
  this.setupName = setupName;
339
256
  this.localInclude = local;
@@ -343,14 +260,10 @@ export class RemoteSelectionMismatchError extends Error {
343
260
  configIdentity,
344
261
  localInclude: [...local],
345
262
  remoteInclude: [...remote],
346
- ...(ignorePolicyComparison
347
- ? { ignorePolicyComparison }
348
- : {
349
- ...(localExclude === undefined ? {} : { localExclude: normalizeSyncExclude(localExclude) }),
350
- ...(remoteExclude === undefined ? {} : { remoteExclude: normalizeSyncExclude(remoteExclude) }),
351
- ...(localDirectory?.scope ? { localDirectory: directoryRules(localDirectory) } : {}),
352
- ...(remoteDirectory?.scope ? { remoteDirectory: directoryRules(remoteDirectory) } : {}),
353
- }),
263
+ ...(localExclude === undefined ? {} : { localExclude: normalizeSyncExclude(localExclude) }),
264
+ ...(remoteExclude === undefined ? {} : { remoteExclude: normalizeSyncExclude(remoteExclude) }),
265
+ ...(localDirectory?.scope ? { localDirectory: directoryRules(localDirectory) } : {}),
266
+ ...(remoteDirectory?.scope ? { remoteDirectory: directoryRules(remoteDirectory) } : {}),
354
267
  };
355
268
  }
356
269
  }
@@ -358,7 +271,7 @@ function directoryRules(directory) {
358
271
  return { scope: directory.scope, reinclude: normalizeDirectoryRules(directory.reinclude) };
359
272
  }
360
273
  export function remoteSelectionMismatch(config, remoteInclude, configIdentity, remoteExclude, remoteDirectory) {
361
- return new RemoteSelectionMismatchError(config.setupName, config.include, remoteInclude, configIdentity, config.exclude, remoteExclude, config, remoteDirectory, remoteDirectory?.ignorePolicyComparison);
274
+ return new RemoteSelectionMismatchError(config.setupName, config.include, remoteInclude, configIdentity, config.exclude, remoteExclude, config, remoteDirectory);
362
275
  }
363
276
  export function formatRemoteSelectionMismatch(setupName, localInclude, remoteInclude, localExclude, remoteExclude, localDirectory, remoteDirectory) {
364
277
  const comparison = compareSyncInclude(localInclude, remoteInclude);
@@ -432,12 +345,10 @@ export function customIncludePathsByLower(value) {
432
345
  return new Map(syncIncludeSelection(value).custom.map((relativePath) => [relativePath.toLowerCase(), relativePath]));
433
346
  }
434
347
  export function includeFromSelectionConfig(config) {
435
- if (config.ignorePolicy)
436
- return config.ignorePolicy.sessions ? ["sessions"] : [];
437
348
  if (config.include !== undefined)
438
349
  return normalizeSyncInclude(config.include);
439
350
  if (config.scope === "agent-directory")
440
- return isIgnoreSnapshotSelection(config) && config.sessions ? ["sessions"] : [];
351
+ return [];
441
352
  return [
442
353
  ...normalizeSyncFiles(config.syncFiles),
443
354
  ...normalizeExtraFiles(config.extraFiles),
@@ -488,44 +399,11 @@ function isProtectedDirectoryPath(relativePath) {
488
399
  }
489
400
  return false;
490
401
  }
491
- export function isIgnoreControlPath(relativePath, reservedNames) {
492
- const first = (relativePath.split("/", 1)[0] ?? "").toLowerCase();
493
- return first === ".syncignore" || reservedNames?.has(first) === true;
494
- }
495
- function isIgnoreSnapshotSelection(config) {
496
- return config.version === 4 && config.fingerprint !== undefined;
497
- }
498
- function reservedIgnoreSnapshotNames(config) {
499
- const local = config.ignorePolicy;
500
- if (!local && !config.reservedIgnoreNames && !isIgnoreSnapshotSelection(config))
501
- return undefined;
502
- return new Set([
503
- ".syncignore",
504
- ...(local ? [local.filename, ...local.reservedNames] : []),
505
- ...(config.reservedIgnoreNames ?? []),
506
- ].map((name) => name.toLowerCase()));
507
- }
508
- function compileIgnoreControlPath(config) {
509
- const names = reservedIgnoreSnapshotNames(config);
510
- return names ? (relativePath) => isIgnoreControlPath(relativePath, names) : undefined;
511
- }
512
402
  function compileDirectoryPolicy(config) {
513
- const localIgnore = config.ignorePolicy;
514
- const ignoreSelection = localIgnore !== undefined || isIgnoreSnapshotSelection(config);
515
- const controlPath = compileIgnoreControlPath(config);
516
- const sessions = includeFromSelectionConfig(config).includes("sessions");
517
- const blocked = (relativePath) => isProtectedDirectoryPath(relativePath) ||
518
- (ignoreSelection && !relativePath.isWellFormed()) ||
519
- controlPath?.(relativePath) === true ||
520
- (!sessions && /^sessions(?:\/|$)/iu.test(relativePath));
521
- if (localIgnore) {
522
- return {
523
- excludes: (relativePath, directory = false) => blocked(relativePath) || localIgnore.matches(relativePath, directory),
524
- descends: (relativePath) => !blocked(relativePath) && !localIgnore.matches(relativePath, true),
525
- };
526
- }
527
403
  const excluded = compilePathRules(normalizeDirectoryRules(config.exclude));
528
404
  const restored = compilePathRules(normalizeDirectoryRules(config.reinclude));
405
+ const sessions = includeFromSelectionConfig(config).includes("sessions");
406
+ const blocked = (relativePath) => isProtectedDirectoryPath(relativePath) || (!sessions && /^sessions(?:\/|$)/iu.test(relativePath));
529
407
  return {
530
408
  excludes: (relativePath) => blocked(relativePath) || (excluded.matches(relativePath) && !restored.matches(relativePath)),
531
409
  descends: (relativePath) => !blocked(relativePath) &&
@@ -557,16 +435,14 @@ export function assertAgentDirectoryPathLayout(files) {
557
435
  }
558
436
  }
559
437
  export function compileSyncPolicyExclude(config) {
560
- if (config.scope === "agent-directory")
561
- return compileDirectoryPolicy(config).excludes;
562
- const excludes = compileSyncExclude(config.exclude);
563
- const controlPath = compileIgnoreControlPath(config);
564
- return controlPath ? (relativePath) => controlPath(toPosix(relativePath)) || excludes(relativePath) : excludes;
438
+ return config.scope === "agent-directory"
439
+ ? compileDirectoryPolicy(config).excludes
440
+ : compileSyncExclude(config.exclude);
565
441
  }
566
442
  export function compileSyncPolicyTraversal(config) {
567
443
  if (config.scope === "agent-directory")
568
444
  return compileDirectoryPolicy(config).descends;
569
- const excludes = compileSyncPolicyExclude(config);
445
+ const excludes = compileSyncExclude(config.exclude);
570
446
  return (relativePath) => !excludes(relativePath);
571
447
  }
572
448
  export function syncSessionsSelected(config) {
@@ -583,7 +459,7 @@ export function configuredSnapshotPathMatcher(config) {
583
459
  (!relativePath.startsWith("sessions/") || relativePath.endsWith(".jsonl"));
584
460
  }
585
461
  const selection = syncIncludeSelection(includeFromSelectionConfig(config));
586
- const excluded = compileSyncPolicyExclude(config);
462
+ const excluded = compileSyncExclude(config.exclude);
587
463
  return (relativePath) => {
588
464
  const normalized = toPosix(relativePath);
589
465
  if (excluded(normalized))