zen-fs-config 0.7.23 → 0.7.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -1121,6 +1121,16 @@ declare class ConfigRepo implements IConfigRepo {
1121
1121
  * 这些路径改由 processTombstones 主动删除,直到所有副本确认不存在、
1122
1122
  * 墓碑被 GC 之后才恢复同步。
1123
1123
  */
1124
+ /**
1125
+ * 永不参与内容同步的元数据路径。
1126
+ *
1127
+ * `.meta/group.json` 是同步身份(kind/id/instanceId)的载体,只在身份流程里写:
1128
+ * 建同步对时读它、认领/对齐时写它。一旦让普通内容同步(按 mtime 双向)
1129
+ * 也去搬这个文件,身份就成了"谁最后写谁赢"——两台设备各持一个实例 ID 时会
1130
+ * 互相覆盖,远端根的 instanceId 便会反复变化,且全程绕开 claim / 冲突判定。
1131
+ * 所以这里固定排除,刷新墓碑排除表时也不得清掉。
1132
+ */
1133
+ private static readonly PERMANENT_SYNC_EXCLUSIONS;
1124
1134
  private readonly tombstoneExcludePrefixes;
1125
1135
  private readonly syncFilter;
1126
1136
  /**
package/dist/index.d.ts CHANGED
@@ -1121,6 +1121,16 @@ declare class ConfigRepo implements IConfigRepo {
1121
1121
  * 这些路径改由 processTombstones 主动删除,直到所有副本确认不存在、
1122
1122
  * 墓碑被 GC 之后才恢复同步。
1123
1123
  */
1124
+ /**
1125
+ * 永不参与内容同步的元数据路径。
1126
+ *
1127
+ * `.meta/group.json` 是同步身份(kind/id/instanceId)的载体,只在身份流程里写:
1128
+ * 建同步对时读它、认领/对齐时写它。一旦让普通内容同步(按 mtime 双向)
1129
+ * 也去搬这个文件,身份就成了"谁最后写谁赢"——两台设备各持一个实例 ID 时会
1130
+ * 互相覆盖,远端根的 instanceId 便会反复变化,且全程绕开 claim / 冲突判定。
1131
+ * 所以这里固定排除,刷新墓碑排除表时也不得清掉。
1132
+ */
1133
+ private static readonly PERMANENT_SYNC_EXCLUSIONS;
1124
1134
  private readonly tombstoneExcludePrefixes;
1125
1135
  private readonly syncFilter;
1126
1136
  /**
package/dist/index.js CHANGED
@@ -1829,7 +1829,14 @@ var LEGACY_TOMBSTONES_DIR = `${META_DIR}/.deleted`;
1829
1829
  var VERSIONS_DIR = `${META_DIR}/versions`;
1830
1830
  var CONFLICTS_DIR = `${META_DIR}/conflicts`;
1831
1831
  var LEGACY_CONFLICTS_DIR = `${META_DIR}/.conflicts`;
1832
+ var LEGACY_APP_DATA_GROUPS_DIR = `${META_DIR}/app-data-groups`;
1832
1833
  var CONFIG_DIR = "/.config";
1834
+ function isDeletableLegacyMetaPath(path) {
1835
+ for (const dir of [LEGACY_TOMBSTONES_DIR, LEGACY_CONFLICTS_DIR, LEGACY_APP_DATA_GROUPS_DIR]) {
1836
+ if (path === dir || path.startsWith(`${dir}/`)) return true;
1837
+ }
1838
+ return false;
1839
+ }
1833
1840
  var DATA_GROUP_DEFAULT_FEATURES = {
1834
1841
  tombstones: true,
1835
1842
  versions: false,
@@ -2900,15 +2907,11 @@ var BACKENDS_FILE = `${META_DIR}/backends.json`;
2900
2907
  var BACKENDS_DIR = META_BACKENDS_DIR;
2901
2908
  var LEGACY_BACKENDS_DIR = `${CONFIG_DIR}/backends`;
2902
2909
  var APP_DATA_GROUPS_DIR = `${CONFIG_DIR}/app-data-groups`;
2903
- var LEGACY_APP_DATA_GROUPS_DIR = `${META_DIR}/app-data-groups`;
2904
2910
  var CONFIG_SYNC_GROUP_FILE = `${CONFIG_DIR}/config-sync-group.json`;
2905
2911
  var LEGACY_CONFIG_SYNC_GROUP_FILE = `${META_DIR}/config-sync-group.json`;
2906
2912
  var GROUP_NAME_MAX_LENGTH = 40;
2907
2913
  var NODES_DIR = "/nodes";
2908
2914
  var SHARED_DIR = "/shared";
2909
- function isDeletableLegacyMetaPath(path) {
2910
- return path === LEGACY_TOMBSTONES_DIR || path.startsWith(`${LEGACY_TOMBSTONES_DIR}/`) || path === LEGACY_CONFLICTS_DIR || path.startsWith(`${LEGACY_CONFLICTS_DIR}/`);
2911
- }
2912
2915
  var CONFIG_GROUP_ID = "config";
2913
2916
  var CONFIG_GROUP_FEATURES = {
2914
2917
  tombstones: true,
@@ -3018,7 +3021,7 @@ function dedupeAppDataBackends(backends) {
3018
3021
  }
3019
3022
  return { kept: Array.from(byKey.values()), removed };
3020
3023
  }
3021
- var ConfigRepo = class {
3024
+ var ConfigRepo = class _ConfigRepo {
3022
3025
  appId;
3023
3026
  nodeId;
3024
3027
  /** Fixed id for the unified sync-group model. */
@@ -3054,7 +3057,17 @@ var ConfigRepo = class {
3054
3057
  * 这些路径改由 processTombstones 主动删除,直到所有副本确认不存在、
3055
3058
  * 墓碑被 GC 之后才恢复同步。
3056
3059
  */
3057
- tombstoneExcludePrefixes = [];
3060
+ /**
3061
+ * 永不参与内容同步的元数据路径。
3062
+ *
3063
+ * `.meta/group.json` 是同步身份(kind/id/instanceId)的载体,只在身份流程里写:
3064
+ * 建同步对时读它、认领/对齐时写它。一旦让普通内容同步(按 mtime 双向)
3065
+ * 也去搬这个文件,身份就成了"谁最后写谁赢"——两台设备各持一个实例 ID 时会
3066
+ * 互相覆盖,远端根的 instanceId 便会反复变化,且全程绕开 claim / 冲突判定。
3067
+ * 所以这里固定排除,刷新墓碑排除表时也不得清掉。
3068
+ */
3069
+ static PERMANENT_SYNC_EXCLUSIONS = [GROUP_DESCRIPTOR_FILE3];
3070
+ tombstoneExcludePrefixes = [..._ConfigRepo.PERMANENT_SYNC_EXCLUSIONS];
3058
3071
  syncFilter = { excludePrefixes: this.tombstoneExcludePrefixes };
3059
3072
  /**
3060
3073
  * 本轮 processTombstones 中,各副本对墓碑路径"已确认不存在"的结果。
@@ -3365,7 +3378,7 @@ var ConfigRepo = class {
3365
3378
  * `filter.excludePrefixes`),所以这里原地更新即可生效。
3366
3379
  */
3367
3380
  refreshSyncExclusions(tombstones) {
3368
- this.tombstoneExcludePrefixes.length = 0;
3381
+ this.tombstoneExcludePrefixes.length = _ConfigRepo.PERMANENT_SYNC_EXCLUSIONS.length;
3369
3382
  const add = (target) => {
3370
3383
  this.tombstoneExcludePrefixes.push(target, `${target}/`);
3371
3384
  };
@@ -5481,7 +5494,7 @@ var ConfigRepo = class {
5481
5494
  }
5482
5495
  }
5483
5496
  };
5484
- var AppDataGroupImpl = class {
5497
+ var AppDataGroupImpl = class _AppDataGroupImpl {
5485
5498
  groupId;
5486
5499
  appId;
5487
5500
  kind = "data";
@@ -5504,8 +5517,12 @@ var AppDataGroupImpl = class {
5504
5517
  * 保留期内的墓碑路径不参与同步:否则副本上的残留会被当作"远端内容"逐文件
5505
5518
  * 拉回本地,把已删除的目录复活。数组与各同步对共享同一实例(zen-fs-sync
5506
5519
  * 每次检测时实时读取 `filter.excludePrefixes`),原地更新即可生效。
5520
+ *
5521
+ * 除墓碑外还固定排除 `.meta/group.json`:它是本组的同步身份,只允许身份流程
5522
+ * 写入;让普通内容同步搬它,等于让"谁最后写谁赢"决定组身份。
5507
5523
  */
5508
- tombstoneExcludePrefixes = [...CONFIG_ONLY_PREFIXES];
5524
+ static PERMANENT_SYNC_EXCLUSIONS = [...CONFIG_ONLY_PREFIXES, GROUP_DESCRIPTOR_FILE3];
5525
+ tombstoneExcludePrefixes = [..._AppDataGroupImpl.PERMANENT_SYNC_EXCLUSIONS];
5509
5526
  syncFilter = { excludePrefixes: this.tombstoneExcludePrefixes };
5510
5527
  constructor(groupId, appId, backends, pollIntervalMs, parent, descriptor = {}) {
5511
5528
  this.groupId = groupId;
@@ -6237,8 +6254,7 @@ var AppDataGroupImpl = class {
6237
6254
  * 参与同步。注意**不能**为 `.keep` 占位排除父目录,否则真实数据会被一起挡掉。
6238
6255
  */
6239
6256
  refreshSyncExclusions(tombstones) {
6240
- this.tombstoneExcludePrefixes.length = 0;
6241
- this.tombstoneExcludePrefixes.push(...CONFIG_ONLY_PREFIXES);
6257
+ this.tombstoneExcludePrefixes.length = _AppDataGroupImpl.PERMANENT_SYNC_EXCLUSIONS.length;
6242
6258
  for (const tombstone of tombstones) {
6243
6259
  if (!tombstone.path) continue;
6244
6260
  this.tombstoneExcludePrefixes.push(tombstone.path, `${tombstone.path}/`);
@@ -6547,9 +6563,9 @@ async function createConfigRepo(appId, options = {}) {
6547
6563
  schemaVersion: 2,
6548
6564
  kind: "config",
6549
6565
  id: CONFIG_GROUP_ID,
6550
- // 被污染的 instanceId 属于那个数据组,不能当成自己的身份继续用;
6551
- // 重新分配一个,界面上的「实例 ID 不一致」会提示用户拍板统一。
6552
- instanceId: newGroupInstanceId(),
6566
+ // 只纠正 kind/id,instanceId 原样保留:换身份必须由用户拍板,
6567
+ // 初始化阶段不得顺手派生新 UUID(那会给远端根引入第三个值)。
6568
+ ...isValidGroupInstanceId(declaredIdentity.instanceId) ? { instanceId: declaredIdentity.instanceId } : {},
6553
6569
  ...declaredIdentity.name ? { name: declaredIdentity.name } : {},
6554
6570
  features: CONFIG_GROUP_FEATURES
6555
6571
  });
@@ -6564,15 +6580,6 @@ async function createConfigRepo(appId, options = {}) {
6564
6580
  await primaryInstance.writeFile(markerPath, groupTypeBytes);
6565
6581
  log5.log(`[createConfigRepo] group-type set to "config-sync" at ${markerPath}`);
6566
6582
  }
6567
- if (!declaredIdentity) {
6568
- await writeGroupDescriptor(primaryInstance, {
6569
- schemaVersion: 2,
6570
- kind: "config",
6571
- id: CONFIG_GROUP_ID,
6572
- instanceId: newGroupInstanceId(),
6573
- features: CONFIG_GROUP_FEATURES
6574
- });
6575
- }
6576
6583
  try {
6577
6584
  await primaryInstance.unlink(`${META_DIR}/group-type`);
6578
6585
  log5.log("[createConfigRepo] removed stale legacy .meta/group-type");
package/dist/index.mjs CHANGED
@@ -1070,7 +1070,14 @@ var LEGACY_TOMBSTONES_DIR = `${META_DIR}/.deleted`;
1070
1070
  var VERSIONS_DIR = `${META_DIR}/versions`;
1071
1071
  var CONFLICTS_DIR = `${META_DIR}/conflicts`;
1072
1072
  var LEGACY_CONFLICTS_DIR = `${META_DIR}/.conflicts`;
1073
+ var LEGACY_APP_DATA_GROUPS_DIR = `${META_DIR}/app-data-groups`;
1073
1074
  var CONFIG_DIR = "/.config";
1075
+ function isDeletableLegacyMetaPath(path) {
1076
+ for (const dir of [LEGACY_TOMBSTONES_DIR, LEGACY_CONFLICTS_DIR, LEGACY_APP_DATA_GROUPS_DIR]) {
1077
+ if (path === dir || path.startsWith(`${dir}/`)) return true;
1078
+ }
1079
+ return false;
1080
+ }
1074
1081
  var DATA_GROUP_DEFAULT_FEATURES = {
1075
1082
  tombstones: true,
1076
1083
  versions: false,
@@ -2141,15 +2148,11 @@ var BACKENDS_FILE = `${META_DIR}/backends.json`;
2141
2148
  var BACKENDS_DIR = META_BACKENDS_DIR;
2142
2149
  var LEGACY_BACKENDS_DIR = `${CONFIG_DIR}/backends`;
2143
2150
  var APP_DATA_GROUPS_DIR = `${CONFIG_DIR}/app-data-groups`;
2144
- var LEGACY_APP_DATA_GROUPS_DIR = `${META_DIR}/app-data-groups`;
2145
2151
  var CONFIG_SYNC_GROUP_FILE = `${CONFIG_DIR}/config-sync-group.json`;
2146
2152
  var LEGACY_CONFIG_SYNC_GROUP_FILE = `${META_DIR}/config-sync-group.json`;
2147
2153
  var GROUP_NAME_MAX_LENGTH = 40;
2148
2154
  var NODES_DIR = "/nodes";
2149
2155
  var SHARED_DIR = "/shared";
2150
- function isDeletableLegacyMetaPath(path) {
2151
- return path === LEGACY_TOMBSTONES_DIR || path.startsWith(`${LEGACY_TOMBSTONES_DIR}/`) || path === LEGACY_CONFLICTS_DIR || path.startsWith(`${LEGACY_CONFLICTS_DIR}/`);
2152
- }
2153
2156
  var CONFIG_GROUP_ID = "config";
2154
2157
  var CONFIG_GROUP_FEATURES = {
2155
2158
  tombstones: true,
@@ -2259,7 +2262,7 @@ function dedupeAppDataBackends(backends) {
2259
2262
  }
2260
2263
  return { kept: Array.from(byKey.values()), removed };
2261
2264
  }
2262
- var ConfigRepo = class {
2265
+ var ConfigRepo = class _ConfigRepo {
2263
2266
  appId;
2264
2267
  nodeId;
2265
2268
  /** Fixed id for the unified sync-group model. */
@@ -2295,7 +2298,17 @@ var ConfigRepo = class {
2295
2298
  * 这些路径改由 processTombstones 主动删除,直到所有副本确认不存在、
2296
2299
  * 墓碑被 GC 之后才恢复同步。
2297
2300
  */
2298
- tombstoneExcludePrefixes = [];
2301
+ /**
2302
+ * 永不参与内容同步的元数据路径。
2303
+ *
2304
+ * `.meta/group.json` 是同步身份(kind/id/instanceId)的载体,只在身份流程里写:
2305
+ * 建同步对时读它、认领/对齐时写它。一旦让普通内容同步(按 mtime 双向)
2306
+ * 也去搬这个文件,身份就成了"谁最后写谁赢"——两台设备各持一个实例 ID 时会
2307
+ * 互相覆盖,远端根的 instanceId 便会反复变化,且全程绕开 claim / 冲突判定。
2308
+ * 所以这里固定排除,刷新墓碑排除表时也不得清掉。
2309
+ */
2310
+ static PERMANENT_SYNC_EXCLUSIONS = [GROUP_DESCRIPTOR_FILE3];
2311
+ tombstoneExcludePrefixes = [..._ConfigRepo.PERMANENT_SYNC_EXCLUSIONS];
2299
2312
  syncFilter = { excludePrefixes: this.tombstoneExcludePrefixes };
2300
2313
  /**
2301
2314
  * 本轮 processTombstones 中,各副本对墓碑路径"已确认不存在"的结果。
@@ -2606,7 +2619,7 @@ var ConfigRepo = class {
2606
2619
  * `filter.excludePrefixes`),所以这里原地更新即可生效。
2607
2620
  */
2608
2621
  refreshSyncExclusions(tombstones) {
2609
- this.tombstoneExcludePrefixes.length = 0;
2622
+ this.tombstoneExcludePrefixes.length = _ConfigRepo.PERMANENT_SYNC_EXCLUSIONS.length;
2610
2623
  const add = (target) => {
2611
2624
  this.tombstoneExcludePrefixes.push(target, `${target}/`);
2612
2625
  };
@@ -4722,7 +4735,7 @@ var ConfigRepo = class {
4722
4735
  }
4723
4736
  }
4724
4737
  };
4725
- var AppDataGroupImpl = class {
4738
+ var AppDataGroupImpl = class _AppDataGroupImpl {
4726
4739
  groupId;
4727
4740
  appId;
4728
4741
  kind = "data";
@@ -4745,8 +4758,12 @@ var AppDataGroupImpl = class {
4745
4758
  * 保留期内的墓碑路径不参与同步:否则副本上的残留会被当作"远端内容"逐文件
4746
4759
  * 拉回本地,把已删除的目录复活。数组与各同步对共享同一实例(zen-fs-sync
4747
4760
  * 每次检测时实时读取 `filter.excludePrefixes`),原地更新即可生效。
4761
+ *
4762
+ * 除墓碑外还固定排除 `.meta/group.json`:它是本组的同步身份,只允许身份流程
4763
+ * 写入;让普通内容同步搬它,等于让"谁最后写谁赢"决定组身份。
4748
4764
  */
4749
- tombstoneExcludePrefixes = [...CONFIG_ONLY_PREFIXES];
4765
+ static PERMANENT_SYNC_EXCLUSIONS = [...CONFIG_ONLY_PREFIXES, GROUP_DESCRIPTOR_FILE3];
4766
+ tombstoneExcludePrefixes = [..._AppDataGroupImpl.PERMANENT_SYNC_EXCLUSIONS];
4750
4767
  syncFilter = { excludePrefixes: this.tombstoneExcludePrefixes };
4751
4768
  constructor(groupId, appId, backends, pollIntervalMs, parent, descriptor = {}) {
4752
4769
  this.groupId = groupId;
@@ -5478,8 +5495,7 @@ var AppDataGroupImpl = class {
5478
5495
  * 参与同步。注意**不能**为 `.keep` 占位排除父目录,否则真实数据会被一起挡掉。
5479
5496
  */
5480
5497
  refreshSyncExclusions(tombstones) {
5481
- this.tombstoneExcludePrefixes.length = 0;
5482
- this.tombstoneExcludePrefixes.push(...CONFIG_ONLY_PREFIXES);
5498
+ this.tombstoneExcludePrefixes.length = _AppDataGroupImpl.PERMANENT_SYNC_EXCLUSIONS.length;
5483
5499
  for (const tombstone of tombstones) {
5484
5500
  if (!tombstone.path) continue;
5485
5501
  this.tombstoneExcludePrefixes.push(tombstone.path, `${tombstone.path}/`);
@@ -5788,9 +5804,9 @@ async function createConfigRepo(appId, options = {}) {
5788
5804
  schemaVersion: 2,
5789
5805
  kind: "config",
5790
5806
  id: CONFIG_GROUP_ID,
5791
- // 被污染的 instanceId 属于那个数据组,不能当成自己的身份继续用;
5792
- // 重新分配一个,界面上的「实例 ID 不一致」会提示用户拍板统一。
5793
- instanceId: newGroupInstanceId(),
5807
+ // 只纠正 kind/id,instanceId 原样保留:换身份必须由用户拍板,
5808
+ // 初始化阶段不得顺手派生新 UUID(那会给远端根引入第三个值)。
5809
+ ...isValidGroupInstanceId(declaredIdentity.instanceId) ? { instanceId: declaredIdentity.instanceId } : {},
5794
5810
  ...declaredIdentity.name ? { name: declaredIdentity.name } : {},
5795
5811
  features: CONFIG_GROUP_FEATURES
5796
5812
  });
@@ -5805,15 +5821,6 @@ async function createConfigRepo(appId, options = {}) {
5805
5821
  await primaryInstance.writeFile(markerPath, groupTypeBytes);
5806
5822
  log5.log(`[createConfigRepo] group-type set to "config-sync" at ${markerPath}`);
5807
5823
  }
5808
- if (!declaredIdentity) {
5809
- await writeGroupDescriptor(primaryInstance, {
5810
- schemaVersion: 2,
5811
- kind: "config",
5812
- id: CONFIG_GROUP_ID,
5813
- instanceId: newGroupInstanceId(),
5814
- features: CONFIG_GROUP_FEATURES
5815
- });
5816
- }
5817
5824
  try {
5818
5825
  await primaryInstance.unlink(`${META_DIR}/group-type`);
5819
5826
  log5.log("[createConfigRepo] removed stale legacy .meta/group-type");
@@ -27795,7 +27795,14 @@ var ZenFSConfig = (() => {
27795
27795
  var VERSIONS_DIR = `${META_DIR}/versions`;
27796
27796
  var CONFLICTS_DIR = `${META_DIR}/conflicts`;
27797
27797
  var LEGACY_CONFLICTS_DIR = `${META_DIR}/.conflicts`;
27798
+ var LEGACY_APP_DATA_GROUPS_DIR = `${META_DIR}/app-data-groups`;
27798
27799
  var CONFIG_DIR = "/.config";
27800
+ function isDeletableLegacyMetaPath(path) {
27801
+ for (const dir of [LEGACY_TOMBSTONES_DIR, LEGACY_CONFLICTS_DIR, LEGACY_APP_DATA_GROUPS_DIR]) {
27802
+ if (path === dir || path.startsWith(`${dir}/`)) return true;
27803
+ }
27804
+ return false;
27805
+ }
27799
27806
  var DATA_GROUP_DEFAULT_FEATURES = {
27800
27807
  tombstones: true,
27801
27808
  versions: false,
@@ -28857,15 +28864,11 @@ var ZenFSConfig = (() => {
28857
28864
  var BACKENDS_DIR = META_BACKENDS_DIR;
28858
28865
  var LEGACY_BACKENDS_DIR = `${CONFIG_DIR}/backends`;
28859
28866
  var APP_DATA_GROUPS_DIR = `${CONFIG_DIR}/app-data-groups`;
28860
- var LEGACY_APP_DATA_GROUPS_DIR = `${META_DIR}/app-data-groups`;
28861
28867
  var CONFIG_SYNC_GROUP_FILE = `${CONFIG_DIR}/config-sync-group.json`;
28862
28868
  var LEGACY_CONFIG_SYNC_GROUP_FILE = `${META_DIR}/config-sync-group.json`;
28863
28869
  var GROUP_NAME_MAX_LENGTH = 40;
28864
28870
  var NODES_DIR = "/nodes";
28865
28871
  var SHARED_DIR = "/shared";
28866
- function isDeletableLegacyMetaPath(path) {
28867
- return path === LEGACY_TOMBSTONES_DIR || path.startsWith(`${LEGACY_TOMBSTONES_DIR}/`) || path === LEGACY_CONFLICTS_DIR || path.startsWith(`${LEGACY_CONFLICTS_DIR}/`);
28868
- }
28869
28872
  var CONFIG_GROUP_ID = "config";
28870
28873
  var CONFIG_GROUP_FEATURES = {
28871
28874
  tombstones: true,
@@ -28975,7 +28978,7 @@ var ZenFSConfig = (() => {
28975
28978
  }
28976
28979
  return { kept: Array.from(byKey.values()), removed };
28977
28980
  }
28978
- var ConfigRepo = class {
28981
+ var _ConfigRepo = class _ConfigRepo {
28979
28982
  constructor(appId, nodeId, primaryBackendId, cachedFS, serializer, onConflict, pollIntervalMs, cacheOptions) {
28980
28983
  __publicField(this, "appId");
28981
28984
  __publicField(this, "nodeId");
@@ -29004,15 +29007,7 @@ var ZenFSConfig = (() => {
29004
29007
  __publicField(this, "pollIntervalMs");
29005
29008
  /** Tombstone cache — avoids redundant reads within a single flush() cycle. */
29006
29009
  __publicField(this, "tombstoneCache", null);
29007
- /**
29008
- * 墓碑存在期间被排除在同步之外的路径。
29009
- *
29010
- * 远端副本可能仍残留被删路径(哪怕只剩 `.keep` / `.keep.mtime` 占位)。
29011
- * 若同步照常进行,这类残留会被当成"远端新增"再拉回本地,造成空壳复活。
29012
- * 这些路径改由 processTombstones 主动删除,直到所有副本确认不存在、
29013
- * 墓碑被 GC 之后才恢复同步。
29014
- */
29015
- __publicField(this, "tombstoneExcludePrefixes", []);
29010
+ __publicField(this, "tombstoneExcludePrefixes", [..._ConfigRepo.PERMANENT_SYNC_EXCLUSIONS]);
29016
29011
  __publicField(this, "syncFilter", { excludePrefixes: this.tombstoneExcludePrefixes });
29017
29012
  /**
29018
29013
  * 本轮 processTombstones 中,各副本对墓碑路径"已确认不存在"的结果。
@@ -29322,7 +29317,7 @@ var ZenFSConfig = (() => {
29322
29317
  * `filter.excludePrefixes`),所以这里原地更新即可生效。
29323
29318
  */
29324
29319
  refreshSyncExclusions(tombstones) {
29325
- this.tombstoneExcludePrefixes.length = 0;
29320
+ this.tombstoneExcludePrefixes.length = _ConfigRepo.PERMANENT_SYNC_EXCLUSIONS.length;
29326
29321
  const add = (target) => {
29327
29322
  this.tombstoneExcludePrefixes.push(target, `${target}/`);
29328
29323
  };
@@ -31438,7 +31433,26 @@ var ZenFSConfig = (() => {
31438
31433
  }
31439
31434
  }
31440
31435
  };
31441
- var AppDataGroupImpl = class {
31436
+ /**
31437
+ * 墓碑存在期间被排除在同步之外的路径。
31438
+ *
31439
+ * 远端副本可能仍残留被删路径(哪怕只剩 `.keep` / `.keep.mtime` 占位)。
31440
+ * 若同步照常进行,这类残留会被当成"远端新增"再拉回本地,造成空壳复活。
31441
+ * 这些路径改由 processTombstones 主动删除,直到所有副本确认不存在、
31442
+ * 墓碑被 GC 之后才恢复同步。
31443
+ */
31444
+ /**
31445
+ * 永不参与内容同步的元数据路径。
31446
+ *
31447
+ * `.meta/group.json` 是同步身份(kind/id/instanceId)的载体,只在身份流程里写:
31448
+ * 建同步对时读它、认领/对齐时写它。一旦让普通内容同步(按 mtime 双向)
31449
+ * 也去搬这个文件,身份就成了"谁最后写谁赢"——两台设备各持一个实例 ID 时会
31450
+ * 互相覆盖,远端根的 instanceId 便会反复变化,且全程绕开 claim / 冲突判定。
31451
+ * 所以这里固定排除,刷新墓碑排除表时也不得清掉。
31452
+ */
31453
+ __publicField(_ConfigRepo, "PERMANENT_SYNC_EXCLUSIONS", [GROUP_DESCRIPTOR_FILE3]);
31454
+ var ConfigRepo = _ConfigRepo;
31455
+ var _AppDataGroupImpl = class _AppDataGroupImpl {
31442
31456
  constructor(groupId, appId, backends, pollIntervalMs, parent, descriptor = {}) {
31443
31457
  __publicField(this, "groupId");
31444
31458
  __publicField(this, "appId");
@@ -31456,14 +31470,7 @@ var ZenFSConfig = (() => {
31456
31470
  __publicField(this, "versions");
31457
31471
  __publicField(this, "conflicts");
31458
31472
  __publicField(this, "postDeleteTimer");
31459
- /**
31460
- * 墓碑路径的同步排除表(与配置组同一套机制)。
31461
- *
31462
- * 保留期内的墓碑路径不参与同步:否则副本上的残留会被当作"远端内容"逐文件
31463
- * 拉回本地,把已删除的目录复活。数组与各同步对共享同一实例(zen-fs-sync
31464
- * 每次检测时实时读取 `filter.excludePrefixes`),原地更新即可生效。
31465
- */
31466
- __publicField(this, "tombstoneExcludePrefixes", [...CONFIG_ONLY_PREFIXES]);
31473
+ __publicField(this, "tombstoneExcludePrefixes", [..._AppDataGroupImpl.PERMANENT_SYNC_EXCLUSIONS]);
31467
31474
  __publicField(this, "syncFilter", { excludePrefixes: this.tombstoneExcludePrefixes });
31468
31475
  __publicField(this, "parent");
31469
31476
  __publicField(this, "_backends");
@@ -32194,8 +32201,7 @@ var ZenFSConfig = (() => {
32194
32201
  * 参与同步。注意**不能**为 `.keep` 占位排除父目录,否则真实数据会被一起挡掉。
32195
32202
  */
32196
32203
  refreshSyncExclusions(tombstones) {
32197
- this.tombstoneExcludePrefixes.length = 0;
32198
- this.tombstoneExcludePrefixes.push(...CONFIG_ONLY_PREFIXES);
32204
+ this.tombstoneExcludePrefixes.length = _AppDataGroupImpl.PERMANENT_SYNC_EXCLUSIONS.length;
32199
32205
  for (const tombstone of tombstones) {
32200
32206
  if (!tombstone.path) continue;
32201
32207
  this.tombstoneExcludePrefixes.push(tombstone.path, `${tombstone.path}/`);
@@ -32441,6 +32447,18 @@ var ZenFSConfig = (() => {
32441
32447
  this.dataBackends.clear();
32442
32448
  }
32443
32449
  };
32450
+ /**
32451
+ * 墓碑路径的同步排除表(与配置组同一套机制)。
32452
+ *
32453
+ * 保留期内的墓碑路径不参与同步:否则副本上的残留会被当作"远端内容"逐文件
32454
+ * 拉回本地,把已删除的目录复活。数组与各同步对共享同一实例(zen-fs-sync
32455
+ * 每次检测时实时读取 `filter.excludePrefixes`),原地更新即可生效。
32456
+ *
32457
+ * 除墓碑外还固定排除 `.meta/group.json`:它是本组的同步身份,只允许身份流程
32458
+ * 写入;让普通内容同步搬它,等于让"谁最后写谁赢"决定组身份。
32459
+ */
32460
+ __publicField(_AppDataGroupImpl, "PERMANENT_SYNC_EXCLUSIONS", [...CONFIG_ONLY_PREFIXES, GROUP_DESCRIPTOR_FILE3]);
32461
+ var AppDataGroupImpl = _AppDataGroupImpl;
32444
32462
  function toUint8Array2(raw) {
32445
32463
  if (raw instanceof ArrayBuffer) return new Uint8Array(raw);
32446
32464
  if (raw instanceof Uint8Array) return raw;
@@ -32504,9 +32522,9 @@ var ZenFSConfig = (() => {
32504
32522
  schemaVersion: 2,
32505
32523
  kind: "config",
32506
32524
  id: CONFIG_GROUP_ID,
32507
- // 被污染的 instanceId 属于那个数据组,不能当成自己的身份继续用;
32508
- // 重新分配一个,界面上的「实例 ID 不一致」会提示用户拍板统一。
32509
- instanceId: newGroupInstanceId(),
32525
+ // 只纠正 kind/id,instanceId 原样保留:换身份必须由用户拍板,
32526
+ // 初始化阶段不得顺手派生新 UUID(那会给远端根引入第三个值)。
32527
+ ...isValidGroupInstanceId(declaredIdentity.instanceId) ? { instanceId: declaredIdentity.instanceId } : {},
32510
32528
  ...declaredIdentity.name ? { name: declaredIdentity.name } : {},
32511
32529
  features: CONFIG_GROUP_FEATURES
32512
32530
  });
@@ -32521,15 +32539,6 @@ var ZenFSConfig = (() => {
32521
32539
  await primaryInstance.writeFile(markerPath, groupTypeBytes);
32522
32540
  log9.log(`[createConfigRepo] group-type set to "config-sync" at ${markerPath}`);
32523
32541
  }
32524
- if (!declaredIdentity) {
32525
- await writeGroupDescriptor(primaryInstance, {
32526
- schemaVersion: 2,
32527
- kind: "config",
32528
- id: CONFIG_GROUP_ID,
32529
- instanceId: newGroupInstanceId(),
32530
- features: CONFIG_GROUP_FEATURES
32531
- });
32532
- }
32533
32542
  try {
32534
32543
  await primaryInstance.unlink(`${META_DIR}/group-type`);
32535
32544
  log9.log("[createConfigRepo] removed stale legacy .meta/group-type");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zen-fs-config",
3
- "version": "0.7.23",
3
+ "version": "0.7.25",
4
4
  "description": "Distributed config management library built on ZenFS, zen-fs-cache, and zen-fs-sync",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",