@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
@@ -17,9 +17,9 @@ import { withMissingTargetQueues, withTargetQueues } from "./snapshot-mutation-q
17
17
  import { sessionStorageRoot } from "./snapshot-paths.js";
18
18
  import { prepareSessionRootTransition, resolveTransitionSessionRoot, stableAgentDirectorySettingsImage, } from "./snapshot-root-transition.js";
19
19
  import { pendingTransactionEntries, transactionRoot } from "./snapshot-transaction-directory.js";
20
- import { legacyImage, MAX_TRANSACTION_JOURNAL_BYTES, ownedScopedPostTree, readTransactionJournal, recheckScopedImage, recheckUnchangedFile, removeScopedImage, scopedDescendant, scopedIdentity, scopedPathIdentity, scopedTransactionImage, stableScopedIdentity, verifyUnchangedFile, } from "./snapshot-transaction-images.js";
20
+ import { legacyImage, MAX_TRANSACTION_JOURNAL_BYTES, ownedScopedPostTree, readTransactionJournal, recheckUnchangedFile, removeScopedImage, scopedDescendant, scopedIdentity, scopedPathIdentity, scopedTransactionImage, stableScopedIdentity, verifyUnchangedFile, } from "./snapshot-transaction-images.js";
21
21
  import { indexTransactionPlan } from "./snapshot-transaction-plan.js";
22
- import { AGENT_DIRECTORY_JOURNAL_VERSION, assertAllowedTarget, assertRecoveryPolicy, assertSafeParents, BOUND_DIRECTORY_JOURNAL_VERSION, BOUND_INCLUDED_PATHS_JOURNAL_VERSION, IGNORE_POLICY_JOURNAL_VERSION, ignorePolicyValidator, ignoreSourceBinding, isScopedJournal, isStrictlyInside, recoveryPolicyKey, StaleIgnorePolicyError, touchesProtectedTarget, transactionHasSessionTargets, validateJournal, validateJournalPolicy, } from "./snapshot-transaction-policy.js";
22
+ import { AGENT_DIRECTORY_JOURNAL_VERSION, assertAllowedTarget, assertRecoveryPolicy, assertSafeParents, isScopedJournal, isStrictlyInside, touchesProtectedTarget, transactionHasSessionTargets, validateJournal, validateJournalPolicy, } from "./snapshot-transaction-policy.js";
23
23
  import { assertNoUnclaimedLegacyStage, buildScopedRecoveryStage, cleanScopedLegacyStage, cleanScopedWorkspace, inspectScopedRecoveryStage, prepareLegacyRecoveryStage, recoveryStagePath, } from "./snapshot-transaction-stage.js";
24
24
  import { verifyTarget } from "./snapshot-transaction-verification.js";
25
25
  const JOURNAL_VERSION = 4;
@@ -29,10 +29,9 @@ export async function applySnapshotTransaction(plan, options = {}, skipped = [])
29
29
  options.validateMutation?.();
30
30
  const root = path.resolve(agentDir());
31
31
  if (options.scope === "agent-directory") {
32
- const sessionDir = options.sessionDir ?? (await agentDirectoryConfiguredSessionDir(options.signal, root, options));
32
+ const sessionDir = options.sessionDir ?? (await agentDirectoryConfiguredSessionDir(options.signal, root));
33
33
  options = { ...options, sessionDir: sessionStorageRoot(root, sessionDir) };
34
34
  }
35
- const validateIgnorePolicy = ignorePolicyValidator(options);
36
35
  await recoverPendingSnapshotTransactions(options);
37
36
  const coalesced = await coalesceCaseReplacements(root, plan);
38
37
  options.validateMutation?.();
@@ -41,8 +40,6 @@ export async function applySnapshotTransaction(plan, options = {}, skipped = [])
41
40
  if (targets.length > 16_384)
42
41
  throw new Error("Snapshot transaction exceeds its target bound; review a smaller transfer.");
43
42
  return withTargetQueues(targets, options, async (heldKeys) => {
44
- if (validateIgnorePolicy)
45
- await validateIgnorePolicy();
46
43
  await assertUnexcludedTargets(root, [...targets, ...coalesced.replacements.values()], options);
47
44
  options.signal?.throwIfAborted();
48
45
  if (targets.some((target) => touchesProtectedTarget(target, options.protectedTargets)))
@@ -94,7 +91,7 @@ export async function applySnapshotTransaction(plan, options = {}, skipped = [])
94
91
  for (const [target, expected] of expectedPreimages) {
95
92
  if (skippedPreimages.get(target) === expected)
96
93
  continue;
97
- if (scoped || options.reservedIgnoreNames?.length)
94
+ if (scoped)
98
95
  await assertUnexcludedTargets(root, [target], options);
99
96
  const current = scoped ? (await scopedTransactionImage(target, options)).value : await legacyImage(target);
100
97
  options.validateMutation?.();
@@ -102,8 +99,6 @@ export async function applySnapshotTransaction(plan, options = {}, skipped = [])
102
99
  if (current !== expected)
103
100
  throw new Error("Reviewed file preimage changed before apply; snapshot installation refused.");
104
101
  }
105
- if (validateIgnorePolicy)
106
- await validateIgnorePolicy();
107
102
  const mutationTargets = skipped.length ? targets.filter((target) => !skippedPreimages.has(target)) : targets;
108
103
  const writes = skipped.length ? plan.writes.filter(({ target }) => !skippedPreimages.has(target)) : plan.writes;
109
104
  if (mutationTargets.length === 0) {
@@ -116,8 +111,6 @@ export async function applySnapshotTransaction(plan, options = {}, skipped = [])
116
111
  options.signal?.throwIfAborted();
117
112
  assertProjectedAgentDirectoryBudget(inventory, { deletes: [], writes: [{ target: pendingStateEntry }] }, options);
118
113
  }
119
- if (validateIgnorePolicy)
120
- await validateIgnorePolicy();
121
114
  await verifySkippedWrites(root, skipped, heldKeys, options);
122
115
  options.validateMutation?.();
123
116
  options.signal?.throwIfAborted();
@@ -151,12 +144,8 @@ export async function applySnapshotTransaction(plan, options = {}, skipped = [])
151
144
  .flatMap((entry) => [entry.target, ...(entry.afterTarget ? [entry.afterTarget] : [])]), heldKeys, options, async () => {
152
145
  if (options.validateApplyReview && transaction.journal.entries.some((entry) => entry.removalPending))
153
146
  await options.validateApplyReview();
154
- if (validateIgnorePolicy)
155
- await validateIgnorePolicy();
156
147
  if (scoped && plan.writes.length)
157
148
  await recheckAgentDirectoryBudget(root, { deletes: [], writes: plan.writes }, options);
158
- if (validateIgnorePolicy)
159
- await validateIgnorePolicy();
160
149
  await retireRemovalIntent(transaction.directory, transaction.journal, transaction.journal.entries.filter((entry) => entry.removalPending && (entry.afterImage !== "missing" || (entry.postFiles?.length ?? 0) > 0)), options);
161
150
  // Only this uninterrupted call knows which deleted writes have not attempted installation yet.
162
151
  const uninstalledWrites = new Set(transaction.deletedWrites);
@@ -166,13 +155,11 @@ export async function applySnapshotTransaction(plan, options = {}, skipped = [])
166
155
  if (!entry)
167
156
  throw new Error("Unowned transaction target.");
168
157
  const deletedByThisCall = uninstalledWrites.delete(entry.target);
169
- if (options.scope === "agent-directory" || options.reservedIgnoreNames?.length)
158
+ if (options.scope === "agent-directory")
170
159
  await assertUnexcludedTargets(transaction.journal.root, [item.target], options);
171
160
  await verifyTarget(transaction.directory, entry, transaction.journal, options, deletedByThisCall);
172
161
  options.validateMutation?.();
173
162
  options.signal?.throwIfAborted();
174
- if (validateIgnorePolicy)
175
- await validateIgnorePolicy();
176
163
  await fs.mkdir(path.dirname(item.target), { recursive: true });
177
164
  options.validateMutation?.();
178
165
  options.signal?.throwIfAborted();
@@ -196,18 +183,9 @@ export async function applySnapshotTransaction(plan, options = {}, skipped = [])
196
183
  finally {
197
184
  await handle.close();
198
185
  }
199
- const verified = await verifyTarget(transaction.directory, entry, transaction.journal, options, deletedByThisCall);
186
+ await verifyTarget(transaction.directory, entry, transaction.journal, options, deletedByThisCall);
200
187
  options.signal?.throwIfAborted();
201
188
  options.validateMutation?.();
202
- if (validateIgnorePolicy) {
203
- await validateIgnorePolicy();
204
- if (verified.scoped)
205
- await recheckScopedImage(item.target, verified.scoped, options);
206
- else {
207
- await assertUnexcludedTargets(root, [item.target], options);
208
- await verifyTarget(transaction.directory, entry, transaction.journal, options, deletedByThisCall);
209
- }
210
- }
211
189
  options.validateMutation?.();
212
190
  options.signal?.throwIfAborted();
213
191
  await fs.rename(temp, item.target);
@@ -222,11 +200,7 @@ export async function applySnapshotTransaction(plan, options = {}, skipped = [])
222
200
  await syncMutationParents(mutationTargets, [transaction.journal.root, ...(transaction.journal.sessionRoot ? [transaction.journal.sessionRoot] : [])], options);
223
201
  options.validateMutation?.();
224
202
  options.signal?.throwIfAborted();
225
- if (validateIgnorePolicy)
226
- await validateIgnorePolicy();
227
203
  });
228
- if (validateIgnorePolicy)
229
- await validateIgnorePolicy();
230
204
  await verifySkippedWrites(root, skipped, heldKeys, options);
231
205
  options.validateMutation?.();
232
206
  options.signal?.throwIfAborted();
@@ -235,7 +209,7 @@ export async function applySnapshotTransaction(plan, options = {}, skipped = [])
235
209
  // Aborted owners cannot roll back files after another session has replaced them.
236
210
  if (options.signal?.aborted)
237
211
  throw new Error("Snapshot apply cancelled; guarded transaction evidence retained for review.");
238
- if (error instanceof ScopedRemovalError || error instanceof StaleIgnorePolicyError)
212
+ if (error instanceof ScopedRemovalError)
239
213
  throw error;
240
214
  // Additional queues have been released. Recovery must reserve missing keys afresh.
241
215
  if (changesQueueKey)
@@ -301,14 +275,13 @@ export async function recoverPendingSnapshotTransactions(options = {}) {
301
275
  validateJournalPolicy(journal);
302
276
  if (!journal.completed) {
303
277
  assertRecoveryPolicy(journal, options);
304
- ignorePolicyValidator(options);
305
278
  }
306
279
  let sessionDir = options.sessionDir;
307
280
  if (sessionDir === undefined && !journal.completed) {
308
281
  if (options.scope === "agent-directory")
309
- sessionDir = await agentDirectoryConfiguredSessionDir(options.signal, agentDir(), options);
282
+ sessionDir = await agentDirectoryConfiguredSessionDir(options.signal, agentDir());
310
283
  else if (options.resolveConfiguredSessionDir && transactionHasSessionTargets(journal))
311
- sessionDir = await configuredSessionDir(options);
284
+ sessionDir = await configuredSessionDir();
312
285
  }
313
286
  options.validateMutation?.();
314
287
  options.signal?.throwIfAborted();
@@ -331,8 +304,6 @@ async function prepareTransaction(plan, targets, options, replacements = new Map
331
304
  const { sessionDir } = options;
332
305
  const root = path.resolve(agentDir());
333
306
  const wholeDirectory = options.scope === "agent-directory";
334
- const ignoreSource = options.ignorePolicy ? ignoreSourceBinding(options.ignorePolicy) : undefined;
335
- const localPolicyKey = recoveryPolicyKey(options);
336
307
  const sessionRoot = sessionDir || wholeDirectory ? path.resolve(sessionStorageRoot(root, sessionDir)) : undefined;
337
308
  const indexed = indexTransactionPlan(plan, targets);
338
309
  const directory = path.join(transactionRoot(), randomUUID());
@@ -344,7 +315,7 @@ async function prepareTransaction(plan, targets, options, replacements = new Map
344
315
  options.validateMutation?.();
345
316
  assertAllowedTarget(root, sessionRoot, target);
346
317
  await assertSafeParents(root, sessionRoot, target);
347
- if (wholeDirectory || options.reservedIgnoreNames?.length)
318
+ if (wholeDirectory)
348
319
  await assertUnexcludedTargets(root, [target], options);
349
320
  const entry = { target, backupName: `${index}`, kind: "missing" };
350
321
  if (replacements.has(target))
@@ -382,22 +353,14 @@ async function prepareTransaction(plan, targets, options, replacements = new Map
382
353
  ? undefined
383
354
  : await prepareSessionRootTransition(directory, root, effectiveRoot, entries, plan, options);
384
355
  const journal = {
385
- version: localPolicyKey
386
- ? wholeDirectory
387
- ? BOUND_DIRECTORY_JOURNAL_VERSION
388
- : BOUND_INCLUDED_PATHS_JOURNAL_VERSION
389
- : ignoreSource
390
- ? IGNORE_POLICY_JOURNAL_VERSION
391
- : wholeDirectory
392
- ? AGENT_DIRECTORY_JOURNAL_VERSION
393
- : sessionRootTransition
394
- ? 7
395
- : replacements.size
396
- ? 5
397
- : JOURNAL_VERSION,
356
+ version: wholeDirectory
357
+ ? AGENT_DIRECTORY_JOURNAL_VERSION
358
+ : sessionRootTransition
359
+ ? 7
360
+ : replacements.size
361
+ ? 5
362
+ : JOURNAL_VERSION,
398
363
  root,
399
- ignoreSource,
400
- localPolicyKey,
401
364
  ...(wholeDirectory
402
365
  ? { selection: selectionForSnapshot(includeFromSelectionConfig(options), options.exclude, options) }
403
366
  : options.exclude === undefined
@@ -477,13 +440,8 @@ async function restoreTransaction(directory, journal, options, heldKeys) {
477
440
  async function restoreQueuedTransaction(directory, journal, options, heldKeys) {
478
441
  validateJournal(directory, journal, options.sessionDir);
479
442
  const scoped = isScopedJournal(journal);
480
- const validateIgnorePolicy = ignorePolicyValidator(options);
481
443
  options.validateMutation?.();
482
444
  options.signal?.throwIfAborted();
483
- if (validateIgnorePolicy) {
484
- assertRecoveryPolicy(journal, options);
485
- await validateIgnorePolicy();
486
- }
487
445
  await assertUnexcludedTargets(journal.root, journal.entries.flatMap((entry) => [entry.target, ...(entry.afterTarget ? [entry.afterTarget] : [])]), options);
488
446
  for (const entry of journal.entries) {
489
447
  if (touchesProtectedTarget(entry.target, options.protectedTargets))
@@ -533,8 +491,6 @@ async function restoreQueuedTransaction(directory, journal, options, heldKeys) {
533
491
  const spellingMatches = async () => !entry.afterTarget || (await caseReplacementSpelling(entry.target, entry.afterTarget)) === entry.target;
534
492
  if (current === before && (await spellingMatches())) {
535
493
  if (entry.recoveryWorkspace) {
536
- if (validateIgnorePolicy)
537
- await validateIgnorePolicy();
538
494
  await cleanScopedWorkspace(directory, entry, options);
539
495
  }
540
496
  continue;
@@ -594,11 +550,6 @@ async function restoreQueuedTransaction(directory, journal, options, heldKeys) {
594
550
  options.signal?.throwIfAborted();
595
551
  if (atInstall === before && (await spellingMatches()))
596
552
  return;
597
- if (validateIgnorePolicy) {
598
- await validateIgnorePolicy();
599
- await assertUnexcludedTargets(journal.root, [entry.target], options);
600
- await verifyTarget(directory, entry, journal, options, atRename === "missing");
601
- }
602
553
  options.validateMutation?.();
603
554
  options.signal?.throwIfAborted();
604
555
  await fs.rename(temporary, entry.target);
@@ -648,11 +599,6 @@ async function restoreQueuedTransaction(directory, journal, options, heldKeys) {
648
599
  options.signal?.throwIfAborted();
649
600
  if (atInstall === before)
650
601
  return;
651
- if (validateIgnorePolicy) {
652
- await validateIgnorePolicy();
653
- await assertUnexcludedTargets(journal.root, [entry.target], options);
654
- await verifyTarget(directory, entry, journal, options, atRename === "missing");
655
- }
656
602
  options.validateMutation?.();
657
603
  options.signal?.throwIfAborted();
658
604
  await fs.rename(temporary, entry.target);
@@ -666,21 +612,14 @@ async function restoreQueuedTransaction(directory, journal, options, heldKeys) {
666
612
  await syncMutationParents(journal.entries.map((entry) => entry.target), [journal.root, ...(journal.sessionRoot ? [journal.sessionRoot] : [])], options);
667
613
  options.validateMutation?.();
668
614
  options.signal?.throwIfAborted();
669
- if (validateIgnorePolicy)
670
- await validateIgnorePolicy();
671
615
  await completeTransaction(directory, journal);
672
616
  }
673
617
  async function restoreScopedEntry(directory, journal, entry, options, heldKeys, before, spellingMatches) {
674
- const validateIgnorePolicy = ignorePolicyValidator(options);
675
618
  options.validateMutation?.();
676
619
  options.signal?.throwIfAborted();
677
- if (validateIgnorePolicy)
678
- await validateIgnorePolicy();
679
620
  await fs.mkdir(path.dirname(entry.target), { recursive: true });
680
621
  await assertSafeParents(journal.root, journal.sessionRoot, entry.target);
681
622
  if (!entry.vacantInstall) {
682
- if (validateIgnorePolicy)
683
- await validateIgnorePolicy();
684
623
  await buildScopedRecoveryStage(directory, entry, options, () => persistJournal(directory, journal));
685
624
  }
686
625
  const verifyStage = async () => {
@@ -705,8 +644,6 @@ async function restoreScopedEntry(directory, journal, entry, options, heldKeys,
705
644
  }))) {
706
645
  const queueTargets = needsVacantTarget ? [entry.target, ...(entry.afterTarget ? [entry.afterTarget] : [])] : [];
707
646
  await withMissingTargetQueues(queueTargets, heldKeys, options, async () => {
708
- if (validateIgnorePolicy)
709
- await validateIgnorePolicy();
710
647
  const { value: atRename } = await verifyTarget(directory, entry, journal, options);
711
648
  if (atRename === before && (await spellingMatches()))
712
649
  return;
@@ -714,8 +651,6 @@ async function restoreScopedEntry(directory, journal, entry, options, heldKeys,
714
651
  throw new Error("Transaction target changed after removal; preserve evidence for review.");
715
652
  const stage = await verifyStage();
716
653
  if (needsVacantTarget && !entry.vacantInstall) {
717
- if (validateIgnorePolicy)
718
- await validateIgnorePolicy();
719
654
  entry.vacantInstall = stage.identity;
720
655
  delete entry.removalPending;
721
656
  delete entry.replacementStarted;
@@ -741,11 +676,6 @@ async function restoreScopedEntry(directory, journal, entry, options, heldKeys,
741
676
  throw new Error("Transaction target changed before restoration; preserve evidence for review.");
742
677
  options.validateMutation?.();
743
678
  options.signal?.throwIfAborted();
744
- if (validateIgnorePolicy && atInstall.scoped) {
745
- await validateIgnorePolicy();
746
- await recheckScopedImage(stage.payload, stage.image, options);
747
- await recheckScopedImage(entry.target, atInstall.scoped, options);
748
- }
749
679
  await fs.rename(stage.payload, entry.target);
750
680
  await syncDirectory(path.dirname(entry.target));
751
681
  await syncDirectory(path.dirname(stage.payload));
@@ -754,16 +684,11 @@ async function restoreScopedEntry(directory, journal, entry, options, heldKeys,
754
684
  });
755
685
  }
756
686
  }
757
- if (validateIgnorePolicy)
758
- await validateIgnorePolicy();
759
687
  await cleanScopedWorkspace(directory, entry, options);
760
688
  }
761
689
  async function removeOwnedTarget(directory, entry, journal, options, { apply, restoringBefore } = {}) {
762
690
  const scoped = isScopedJournal(journal);
763
- const validateIgnorePolicy = ignorePolicyValidator(options);
764
691
  try {
765
- if (validateIgnorePolicy)
766
- await validateIgnorePolicy();
767
692
  await assertUnexcludedTargets(journal.root, [entry.target, ...(entry.afterTarget ? [entry.afterTarget] : [])], options);
768
693
  const current = await verifyTarget(directory, entry, journal, options);
769
694
  options.validateMutation?.();
@@ -818,14 +743,9 @@ async function removeOwnedTarget(directory, entry, journal, options, { apply, re
818
743
  if (current.value !== verified.value)
819
744
  throw new Error("Transaction removal image changed.");
820
745
  await assertUnexcludedTargets(journal.root, [entry.target], options);
821
- await removeScopedImage(entry.target, current.scoped, options, validateIgnorePolicy);
746
+ await removeScopedImage(entry.target, current.scoped, options);
822
747
  }
823
748
  else {
824
- if (validateIgnorePolicy) {
825
- await validateIgnorePolicy();
826
- await assertUnexcludedTargets(journal.root, [entry.target], options);
827
- await verifyTarget(directory, entry, journal, options);
828
- }
829
749
  options.validateMutation?.();
830
750
  options.signal?.throwIfAborted();
831
751
  await fs.rm(entry.target, { recursive: true, force: true });
@@ -834,7 +754,7 @@ async function removeOwnedTarget(directory, entry, journal, options, { apply, re
834
754
  return true;
835
755
  }
836
756
  catch (error) {
837
- if (!scoped || error instanceof StaleIgnorePolicyError)
757
+ if (!scoped)
838
758
  throw error;
839
759
  throw new ScopedRemovalError("Scoped transaction removal stopped; preserve transaction and backup for review.", {
840
760
  cause: error,
@@ -882,7 +802,7 @@ async function completeTransaction(directory, journal) {
882
802
  // may only retry cleanup, never roll back already accepted files.
883
803
  await writeJson(path.join(directory, "journal.json"), {
884
804
  ...journal,
885
- version: isScopedJournal(journal) || journal.localPolicyKey ? journal.version : journal.sessionRootTransition ? 7 : 6,
805
+ version: isScopedJournal(journal) ? journal.version : journal.sessionRootTransition ? 7 : 6,
886
806
  completed: true,
887
807
  }, {
888
808
  maxBytes: MAX_TRANSACTION_JOURNAL_BYTES,
@@ -1,13 +1,3 @@
1
- export const IGNORE_SNAPSHOT_VERSION = 6;
2
- export const RULES_SNAPSHOT_VERSION = 7;
3
- export function isIgnoreSnapshotVersion(version) {
4
- return version === IGNORE_SNAPSHOT_VERSION || version === RULES_SNAPSHOT_VERSION;
5
- }
6
1
  export function isSupportedSnapshotVersion(version) {
7
- return (version === 1 ||
8
- version === 2 ||
9
- version === 3 ||
10
- version === 4 ||
11
- version === 5 ||
12
- isIgnoreSnapshotVersion(version));
2
+ return version === 1 || version === 2 || version === 3 || version === 4 || version === 5;
13
3
  }
@@ -6,13 +6,12 @@ import path from "node:path";
6
6
  import { isDeniedPath, posixJoin, safeJoin, toPosix } from "../paths.js";
7
7
  import { agentDir, configuredSessionDir, expandSessionDir } from "./session-paths.js";
8
8
  import { assertAgentDirectorySettingsSize, MAX_AGENT_DIRECTORY_BYTES } from "./snapshot-bounds.js";
9
- import { agentDirectoryAnchor, agentDirectoryPhysicalSessionPath, agentDirectorySessionRoot, reservedIgnoreTargetGuard, } from "./snapshot-exclude-safety.js";
9
+ import { agentDirectoryAnchor, agentDirectoryPhysicalSessionPath, agentDirectorySessionRoot, } from "./snapshot-exclude-safety.js";
10
10
  import { sessionStorageRoot } from "./snapshot-paths.js";
11
11
  export { isDeniedPath } from "../paths.js";
12
12
  export { sessionStorageRoot } from "./snapshot-paths.js";
13
13
  import { compileSyncExclude } from "../sync/exclude-policy.js";
14
- import { assertAgentDirectoryPathLayout, canonicalSnapshotPathForConfig, compileSyncPolicyExclude, compileSyncPolicyTraversal, configuredSnapshotPathMatcher, customIncludePathsByLower, DEFAULT_SYNC_INCLUDE, includeFromSelectionConfig, isIgnoreControlPath, isPreservableUnmanagedSnapshotPath, MAX_AGENT_DIRECTORY_ENTRIES, MAX_AGENT_DIRECTORY_FILES, normalizeExtraFiles, normalizeSyncFiles, requireLegacyTransferPolicy, sameSnapshotSelection, selectionForSnapshot, snapshotSelectionExclude, snapshotSelectionInclude, syncIncludeSelection, syncSessionsSelected, } from "../sync/sync-policy.js";
15
- import { IGNORE_SNAPSHOT_VERSION, } from "./snapshot-types.js";
14
+ import { assertAgentDirectoryPathLayout, canonicalSnapshotPathForConfig, compileSyncPolicyExclude, compileSyncPolicyTraversal, configuredSnapshotPathMatcher, customIncludePathsByLower, DEFAULT_SYNC_INCLUDE, includeFromSelectionConfig, isPreservableUnmanagedSnapshotPath, MAX_AGENT_DIRECTORY_ENTRIES, MAX_AGENT_DIRECTORY_FILES, normalizeExtraFiles, normalizeSyncFiles, requireLegacyTransferPolicy, sameSnapshotSelection, selectionForSnapshot, snapshotSelectionExclude, snapshotSelectionInclude, syncIncludeSelection, syncSessionsSelected, } from "../sync/sync-policy.js";
16
15
  export { canonicalSnapshotPathForConfig, isConfiguredSnapshotPath } from "../sync/sync-policy.js";
17
16
  const VERSION = 1;
18
17
  const scanInventories = new WeakMap();
@@ -84,7 +83,7 @@ async function collectSnapshotFiles(options, materialize) {
84
83
  const needsSessionConfig = syncSessions || !excluded("settings.json");
85
84
  const sessionDir = options.scope === "agent-directory"
86
85
  ? options.sessionDir
87
- : (options.sessionDir ?? (needsSessionConfig ? await configuredSessionDir(options) : undefined));
86
+ : (options.sessionDir ?? (needsSessionConfig ? await configuredSessionDir() : undefined));
88
87
  options.signal?.throwIfAborted();
89
88
  const collectionOptions = { ...policy, sessionDir };
90
89
  const collected = options.scope === "agent-directory"
@@ -123,18 +122,12 @@ export async function createSnapshot(profile, options = {}) {
123
122
  options.signal?.throwIfAborted();
124
123
  const selection = selectionForSnapshot(include, options.exclude, options);
125
124
  const snapshot = {
126
- version: selection.version === 4
127
- ? IGNORE_SNAPSHOT_VERSION
128
- : options.scope === "agent-directory"
129
- ? 5
130
- : options.exclude === undefined
131
- ? VERSION
132
- : 4,
125
+ version: options.scope === "agent-directory" ? 5 : options.exclude === undefined ? VERSION : 4,
133
126
  id: snapshotId(),
134
127
  createdAt: new Date().toISOString(),
135
128
  machine: os.hostname(),
136
129
  profile,
137
- syncSessions: selection.version === 4 ? files.some((file) => isSessionPath(file.path)) : syncSessions,
130
+ syncSessions: syncSessions,
138
131
  selection,
139
132
  files,
140
133
  };
@@ -160,8 +153,7 @@ export async function collectFiles(root, options = {}, excluded = compileSyncPol
160
153
  }
161
154
  async function collectSelectedFiles(root, options, excluded, materialize) {
162
155
  const signal = options.signal;
163
- const guardReserved = reservedIgnoreTargetGuard(root, options);
164
- const collection = { signal, excluded, guardReserved, materialize };
156
+ const collection = { signal, excluded, materialize };
165
157
  signal?.throwIfAborted();
166
158
  const results = [];
167
159
  const entries = await fs.readdir(root, { withFileTypes: true });
@@ -260,14 +252,11 @@ async function readScannedFile(candidate, signal) {
260
252
  await handle.close();
261
253
  }
262
254
  }
263
- export async function agentDirectoryConfiguredSessionDir(signal, root = agentDir(), options = {}) {
264
- const content = await readAgentDirectorySettings(signal, root, options);
255
+ export async function agentDirectoryConfiguredSessionDir(signal, root = agentDir()) {
256
+ const content = await readAgentDirectorySettings(signal, root);
265
257
  return content === undefined ? undefined : agentDirectorySessionDirFromSettings(content);
266
258
  }
267
- export async function readAgentDirectorySettings(signal, root = agentDir(), options = {}) {
268
- const guardReserved = reservedIgnoreTargetGuard(root, options);
269
- if (guardReserved)
270
- await guardReserved(path.join(root, "settings.json"));
259
+ export async function readAgentDirectorySettings(signal, root = agentDir()) {
271
260
  const absolute = path.resolve(root);
272
261
  const canonical = path.join(await fs.realpath(path.dirname(absolute)), path.basename(absolute));
273
262
  await identify(absolute, canonical, signal);
@@ -308,9 +297,9 @@ async function collectAgentDirectory(root, options, materialize, pendingStateEnt
308
297
  const signal = options.signal;
309
298
  const excluded = compileSyncPolicyExclude(options);
310
299
  const canTraverse = compileSyncPolicyTraversal(options);
311
- const sessionDir = options.sessionDir ?? (await agentDirectoryConfiguredSessionDir(signal, root, options));
312
- const isPhysicalSessionPath = agentDirectoryPhysicalSessionPath(root, sessionDir, options.ignorePolicy, options.reservedIgnoreNames);
313
- const sessionRoot = agentDirectorySessionRoot(root, sessionDir, options.ignorePolicy, options.reservedIgnoreNames);
300
+ const sessionDir = options.sessionDir ?? (await agentDirectoryConfiguredSessionDir(signal, root));
301
+ const isPhysicalSessionPath = agentDirectoryPhysicalSessionPath(root, sessionDir);
302
+ const sessionRoot = agentDirectorySessionRoot(root, sessionDir);
314
303
  const directories = [];
315
304
  const candidates = [];
316
305
  const entries = new Map();
@@ -342,7 +331,7 @@ async function collectAgentDirectory(root, options, materialize, pendingStateEnt
342
331
  continue;
343
332
  const candidate = await identify(path.join(directory.absolute, entry.name), path.join(directory.canonical, entry.name), signal);
344
333
  if (entry.isDirectory()) {
345
- if (!excluded(snapshotPath, true))
334
+ if (!excluded(snapshotPath))
346
335
  entries.set(candidate.absolute, "directory");
347
336
  await walk(candidate, snapshotPath, sessions);
348
337
  }
@@ -403,8 +392,7 @@ async function collectAgentDirectory(root, options, materialize, pendingStateEnt
403
392
  }
404
393
  for (const directory of directories)
405
394
  await recheck(directory, signal);
406
- if (options.sessionDir === undefined &&
407
- (await agentDirectoryConfiguredSessionDir(signal, root, options)) !== sessionDir)
395
+ if (options.sessionDir === undefined && (await agentDirectoryConfiguredSessionDir(signal, root)) !== sessionDir)
408
396
  changedScan();
409
397
  const currentSessionDirectory = await identifySessionRoot();
410
398
  if (Boolean(sessionDirectory) !== Boolean(currentSessionDirectory) ||
@@ -455,8 +443,6 @@ async function collectIncludedPath(results, root, relativePath, options) {
455
443
  async function collectDirectory(results, root, relativeDirectory, options) {
456
444
  options.signal?.throwIfAborted();
457
445
  const absoluteDirectory = path.join(root, relativeDirectory);
458
- if (options.guardReserved)
459
- await options.guardReserved(absoluteDirectory);
460
446
  options.signal?.throwIfAborted();
461
447
  for (const entry of await fs.readdir(absoluteDirectory, { withFileTypes: true })) {
462
448
  options.signal?.throwIfAborted();
@@ -472,22 +458,12 @@ async function collectDirectory(results, root, relativeDirectory, options) {
472
458
  }
473
459
  }
474
460
  }
475
- export async function readLegacySnapshotSource(absolutePath, guardReserved, signal) {
476
- if (!guardReserved)
477
- return fs.readFile(absolutePath, { signal });
478
- signal?.throwIfAborted();
479
- const canonical = await guardReserved(absolutePath);
480
- const candidate = await identify(absolutePath, canonical, signal);
481
- if (!candidate.stat.isFile() || candidate.stat.nlink !== 1)
482
- changedScan();
483
- return readScannedFile(candidate, signal);
484
- }
485
- async function addFile(results, root, relativePath, snapshotPath, { signal, guardReserved, materialize }) {
461
+ async function addFile(results, root, relativePath, snapshotPath, { signal, materialize }) {
486
462
  signal?.throwIfAborted();
487
463
  if (!isSafeSnapshotPath(snapshotPath))
488
464
  return;
489
465
  const absolutePath = safeJoin(root, relativePath);
490
- const content = await readLegacySnapshotSource(absolutePath, guardReserved, signal);
466
+ const content = await fs.readFile(absolutePath, { signal });
491
467
  signal?.throwIfAborted();
492
468
  results.push(materialize(snapshotPath, content));
493
469
  }
@@ -515,42 +491,27 @@ export function snapshotTarget(root, relativePath, configuredSessionDir) {
515
491
  export function snapshotIncludesSessions(snapshot) {
516
492
  if (snapshot.selection?.version === 3)
517
493
  return syncSessionsSelected(snapshot.selection);
518
- if (snapshot.selection?.version === 4)
519
- return snapshot.files.some((file) => isSessionPath(file.path));
520
494
  return (snapshot.syncSessions === true ||
521
495
  (snapshotSelectionInclude(snapshot)?.includes("sessions") === true &&
522
496
  !compileSyncExclude(snapshotSelectionExclude(snapshot))("sessions")) ||
523
497
  snapshot.files.some((file) => isSessionPath(file.path)));
524
498
  }
525
499
  export function filterSnapshotForConfigPolicy(snapshot, config, options = {}) {
500
+ requireLegacyTransferPolicy(snapshot);
526
501
  const include = includeFromSelectionConfig(config);
527
502
  const wholeDirectory = config.scope === "agent-directory";
528
- if (!wholeDirectory || !config.ignorePolicy)
529
- requireLegacyTransferPolicy(snapshot);
530
503
  const exclude = config.exclude ?? (snapshot.version >= 4 ? [] : undefined);
531
- const selection = selectionForSnapshot(include, exclude, config);
532
504
  const files = wholeDirectory
533
505
  ? filterAgentDirectoryFiles(snapshot.files, config, options.sessionDir)
534
506
  : canonicalizeSnapshotFilesForConfig(snapshot.files, config, customIncludePathsByLower(include));
535
- const { ignoreRules: _ignoreRules, ...image } = snapshot;
536
507
  const filtered = {
537
- ...image,
538
- version: selection.version === 4
539
- ? IGNORE_SNAPSHOT_VERSION
540
- : wholeDirectory
541
- ? 5
542
- : exclude === undefined
543
- ? snapshot.version
544
- : 4,
545
- syncSessions: selection.version === 4
546
- ? files.some((file) => isSessionPath(file.path))
547
- : syncSessionsSelected(config)
548
- ? snapshot.syncSessions
549
- : false,
550
- selection,
508
+ ...snapshot,
509
+ version: wholeDirectory ? 5 : exclude === undefined ? snapshot.version : 4,
510
+ syncSessions: syncSessionsSelected(config) ? snapshot.syncSessions : false,
511
+ selection: selectionForSnapshot(include, exclude, config),
551
512
  files,
552
513
  };
553
- if (!options.regenerateId || (snapshot.version === filtered.version && snapshotsMatch(snapshot, filtered)))
514
+ if (!options.regenerateId || snapshotsMatch(snapshot, filtered))
554
515
  return filtered;
555
516
  return {
556
517
  ...filtered,
@@ -561,9 +522,7 @@ export function filterSnapshotForConfigPolicy(snapshot, config, options = {}) {
561
522
  }
562
523
  function filterAgentDirectoryFiles(files, config, sessionDir) {
563
524
  const configured = configuredSnapshotPathMatcher(config);
564
- const isPhysicalSessionPath = sessionDir
565
- ? agentDirectoryPhysicalSessionPath(agentDir(), sessionDir, config.ignorePolicy, config.reservedIgnoreNames)
566
- : undefined;
525
+ const isPhysicalSessionPath = sessionDir ? agentDirectoryPhysicalSessionPath(agentDir(), sessionDir) : undefined;
567
526
  const projected = files.filter((file) => {
568
527
  if (!isSafeSnapshotPath(file.path) || !configured(file.path))
569
528
  return false;
@@ -606,12 +565,11 @@ function isPreferredExtraCandidate(left, right) {
606
565
  return left.originalPath.localeCompare(right.originalPath) < 0;
607
566
  }
608
567
  export function snapshotWithoutSessions(snapshot) {
609
- requireLegacyTransferPolicy(snapshot);
610
568
  const files = snapshot.files.filter((file) => !isSessionPath(file.path));
611
569
  const include = snapshotSelectionInclude(snapshot)?.filter((item) => item !== "sessions");
612
570
  if (files.length === snapshot.files.length &&
613
571
  snapshot.syncSessions !== true &&
614
- include?.length === snapshot.selection?.include?.length) {
572
+ include?.length === snapshot.selection?.include.length) {
615
573
  return snapshot;
616
574
  }
617
575
  return {
@@ -642,23 +600,13 @@ export function scanSnapshot(snapshot) {
642
600
  }
643
601
  }
644
602
  }
645
- if (snapshot.ignoreRules && SECRET_PATTERNS.some((pattern) => pattern.test(snapshot.ignoreRules?.text ?? "")))
646
- findings.push(snapshot.ignoreRules.filename);
647
603
  return findings;
648
604
  }
649
605
  export function mergeRemotePreservedFiles(local, remote, config, options = {}) {
650
- if (config.scope !== "agent-directory" || !config.ignorePolicy) {
651
- requireLegacyTransferPolicy(local);
652
- requireLegacyTransferPolicy(remote);
653
- }
606
+ requireLegacyTransferPolicy(local);
607
+ requireLegacyTransferPolicy(remote);
654
608
  if (config.scope === "agent-directory")
655
609
  return filterSnapshotForConfigPolicy(local, config, { ...options, regenerateId: true });
656
- if (config.reservedIgnoreNames !== undefined) {
657
- const names = new Set(config.reservedIgnoreNames);
658
- const files = local.files.filter((file) => !isIgnoreControlPath(toPosix(file.path), names));
659
- if (files.length !== local.files.length)
660
- local = regenerateSnapshotIdentity({ ...local, files });
661
- }
662
610
  const localPathNames = new Set(local.files.map((file) => file.path.toLowerCase()));
663
611
  const preservedPathNames = new Set();
664
612
  const configured = configuredSnapshotPathMatcher(config);
@@ -3,6 +3,7 @@ import fs from "node:fs/promises";
3
3
  import path from "node:path";
4
4
  import { backendIdentityCoordinates } from "../backends/backend-identity.js";
5
5
  import { safeName } from "../paths.js";
6
+ import { retiredIgnorePolicy } from "../settings/retired-ignore-policy.js";
6
7
  import { readJsonIfExists, writeJson } from "./json-file.js";
7
8
  import { stateDir } from "./state-directory.js";
8
9
  const STATE_VERSION = 2;
@@ -21,7 +22,10 @@ export async function writeState(profile, state) {
21
22
  await writeJson(statePath(profile), state);
22
23
  }
23
24
  export async function readStateForConfig(config) {
24
- return ((await readJsonIfExists(statePathForConfig(config))) ?? {
25
+ const state = await readJsonIfExists(statePathForConfig(config));
26
+ if (state && Object.hasOwn(state, "ignorePolicyKey"))
27
+ throw retiredIgnorePolicy("baseline");
28
+ return (state ?? {
25
29
  version: STATE_VERSION,
26
30
  profile: config.snapshotIdentity,
27
31
  lastFileHashes: {},
@@ -45,7 +45,6 @@ export async function resolveAgentPlan(ctx, options, config, backend, state, loc
45
45
  1,
46
46
  backend.identity,
47
47
  syncConfigReviewIdentity(config),
48
- ...(config.configDocumentFingerprint ? [config.configDocumentFingerprint] : []),
49
48
  syncStateFingerprint(state),
50
49
  head.revision,
51
50
  fileHashMap(localRaw),
@@ -1,6 +1,6 @@
1
1
  /** One policy for startup scheduling and commit-time authorization. */
2
2
  export function startupTransferEnabled(config) {
3
- return Boolean(config.automaticTransfer || config.agentMode);
3
+ return Boolean(config.automaticTransfer);
4
4
  }
5
5
  export const AGENT_TIMEOUT_MS = 20_000;
6
6
  export const AGENT_INPUT_BYTES = 24 * 1024;
@@ -1,6 +1,5 @@
1
1
  import { truncateToWidth } from "@earendil-works/pi-tui";
2
2
  import { createSyncBackend } from "../backends/backend-factory.js";
3
- import { requireNoPendingAdoption } from "../ignore/adoption-journal.js";
4
3
  import { loadConfig, syncCheckConfigFingerprint } from "../settings/config.js";
5
4
  import { readStateForConfig, syncStateFingerprint } from "../state/sync-state-store.js";
6
5
  import { confirmMergeReview } from "../ui/merge-review.js";
@@ -10,7 +9,6 @@ import { conflictPreview } from "./conflict-preview.js";
10
9
  import { mergeSync } from "./merged-sync.js";
11
10
  import { captureMutationOwner } from "./sync-local.js";
12
11
  export async function showConflicts(ctx, options, factory = createSyncBackend) {
13
- requireNoPendingAdoption();
14
12
  const validate = captureMutationOwner(ctx, options.signal);
15
13
  const config = await loadConfig(options.setup);
16
14
  validate();