@vrtmrz/livesync-commonlib 0.2.3 → 0.3.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 (91) hide show
  1. package/README.md +46 -8
  2. package/dist/API/DirectFileManipulatorV2.d.ts +8 -1
  3. package/dist/API/DirectFileManipulatorV2.js +52 -79
  4. package/dist/API/DirectFileWatchOwner.d.ts +24 -0
  5. package/dist/API/DirectFileWatchOwner.js +256 -0
  6. package/dist/API/processSetting.d.ts +1 -0
  7. package/dist/API/processSetting.js +3 -3
  8. package/dist/common/models/setting.const.defaults.js +1 -0
  9. package/dist/common/models/setting.const.qr.js +1 -0
  10. package/dist/common/models/setting.policy.d.ts +4 -0
  11. package/dist/common/models/setting.policy.js +1 -0
  12. package/dist/common/models/setting.type.d.ts +3 -1
  13. package/dist/common/models/shared.definition.configNames.js +1 -2
  14. package/dist/common/models/tweak.definition.d.ts +2 -1
  15. package/dist/common/pathNamespace.d.ts +4 -0
  16. package/dist/common/pathNamespace.js +10 -0
  17. package/dist/common/pathNormalization.d.ts +2 -0
  18. package/dist/common/pathNormalization.js +7 -2
  19. package/dist/common/settingConstants.d.ts +1 -0
  20. package/dist/common/settingConstants.js +4 -0
  21. package/dist/managers/ChunkFetcher.d.ts +3 -0
  22. package/dist/managers/ChunkFetcher.js +20 -13
  23. package/dist/managers/LiveSyncManagers.d.ts +2 -0
  24. package/dist/managers/LiveSyncManagers.js +1 -0
  25. package/dist/managers/chunkFetchSource.d.ts +14 -0
  26. package/dist/managers/chunkFetchSource.js +12 -0
  27. package/dist/platform/AmbiguousNormalisedPathError.d.ts +16 -0
  28. package/dist/platform/AmbiguousNormalisedPathError.js +21 -0
  29. package/dist/platform/StoragePathResolver.d.ts +15 -0
  30. package/dist/platform/StoragePathResolver.js +113 -0
  31. package/dist/platform/browser/UnicodeResolvingFileSystemAccessStorageAdapter.d.ts +74 -0
  32. package/dist/platform/browser/UnicodeResolvingFileSystemAccessStorageAdapter.js +169 -0
  33. package/dist/platform/browser/index.d.ts +1 -0
  34. package/dist/platform/browser/index.js +2 -0
  35. package/dist/platform/browser/storage.d.ts +23 -0
  36. package/dist/platform/browser/storage.js +138 -0
  37. package/dist/platform/node/UnicodeResolvingNodeStorageAdapter.d.ts +79 -0
  38. package/dist/platform/node/UnicodeResolvingNodeStorageAdapter.js +218 -0
  39. package/dist/platform/node/index.d.ts +1 -0
  40. package/dist/platform/node/index.js +2 -0
  41. package/dist/platform/node/storage.d.ts +30 -1
  42. package/dist/platform/node/storage.js +88 -0
  43. package/dist/platform/pathComparison.d.ts +53 -0
  44. package/dist/platform/pathComparison.js +39 -0
  45. package/dist/platform/pathTypes.d.ts +154 -0
  46. package/dist/platform/pathTypes.js +0 -0
  47. package/dist/platform/storagePathResolution.d.ts +13 -0
  48. package/dist/platform/storagePathResolution.js +9 -0
  49. package/dist/pouchdb/LiveSyncDBFunctions.js +5 -0
  50. package/dist/pouchdb/LiveSyncLocalDB.d.ts +7 -1
  51. package/dist/pouchdb/LiveSyncLocalDB.js +13 -10
  52. package/dist/pouchdb/pathIdentityCompatibility.d.ts +8 -0
  53. package/dist/pouchdb/pathIdentityCompatibility.js +19 -1
  54. package/dist/replication/RemoteResource.d.ts +3 -0
  55. package/dist/replication/couchdb/LiveSyncReplicator.js +5 -3
  56. package/dist/replication/index.d.ts +2 -0
  57. package/dist/replication/index.js +2 -0
  58. package/dist/replication/journal/JournalSyncCore.d.ts +1 -0
  59. package/dist/replication/journal/JournalSyncCore.js +35 -19
  60. package/dist/replication/journal/LiveSyncJournalReplicator.d.ts +11 -3
  61. package/dist/replication/journal/LiveSyncJournalReplicator.js +123 -45
  62. package/dist/replication/trystero/P2PRoomSessionOwner.js +14 -13
  63. package/dist/replication/trystero/TrysteroReplicator.d.ts +9 -5
  64. package/dist/replication/trystero/TrysteroReplicator.js +98 -70
  65. package/dist/replication/trystero/TrysteroReplicator.pathIdentity.d.ts +11 -0
  66. package/dist/replication/trystero/TrysteroReplicator.pathIdentity.js +72 -0
  67. package/dist/replication/trystero/p2pReplicatorConfigurationIdentity.js +2 -0
  68. package/dist/replication/trystero/useP2PReplicatorFeature.js +6 -2
  69. package/dist/serviceModules/Rebuilder.d.ts +1 -0
  70. package/dist/serviceModules/Rebuilder.js +35 -6
  71. package/dist/services/base/FileProcessingService.d.ts +2 -2
  72. package/dist/services/base/RemoteConnection.d.ts +2 -0
  73. package/dist/services/base/RemoteService.d.ts +1 -1
  74. package/dist/services/base/RemoteService.js +13 -5
  75. package/dist/services/implements/injectable/InjectableVaultService.d.ts +1 -1
  76. package/dist/services/lib/couchdbHttpCache.d.ts +5 -0
  77. package/dist/services/lib/couchdbHttpCache.js +36 -0
  78. package/dist/storage.d.ts +4 -0
  79. package/dist/storage.js +19 -0
  80. package/dist/string_and_binary/path.js +4 -7
  81. package/dist/worker/bgWorker.js +1 -1
  82. package/docs/adr/2026_11_shared_storage_path_resolution.md +73 -0
  83. package/docs/conflict-resolution.md +1 -1
  84. package/docs/design_docs/storage_path_resolution.md +305 -0
  85. package/docs/development.md +15 -1
  86. package/docs/platform-storage.md +61 -0
  87. package/docs/proven-in-use.md +30 -13
  88. package/docs/releasing.md +27 -0
  89. package/docs/service-feature-composition.md +7 -1
  90. package/docs/unicode-path-identity.md +104 -12
  91. package/package.json +10 -2
@@ -2,7 +2,7 @@
2
2
  date: 2026-10-19
3
3
  commonlib-version: "0.1.42"
4
4
  self-hosted-livesync-version: "1.0.38"
5
- status: unreleased
5
+ status: published
6
6
  ---
7
7
 
8
8
  # Unicode path identity
@@ -14,7 +14,11 @@ does not alter the Metadata path or require physical files to be renamed.
14
14
  Unsupported values are rejected.
15
15
 
16
16
  NFC identity shipped in Commonlib `0.1.42` and Self-hosted LiveSync `1.0.38`.
17
- The deletion handling below is an unreleased refinement of reconstruction.
17
+ The Journal and P2P extension is published in
18
+ [Commonlib 0.3.0](https://www.npmjs.com/package/@vrtmrz/livesync-commonlib/v/0.3.0).
19
+ The original date and reviewed versions above retain the CouchDB baseline.
20
+ CLI and Obsidian host adoption is pending in
21
+ [Self-hosted LiveSync #1309](https://github.com/vrtmrz/obsidian-livesync/pull/1309).
18
22
 
19
23
  ## Package contract
20
24
 
@@ -25,6 +29,25 @@ implementation for Metadata IDs rather than add a host-specific normalisation
25
29
  rule. Host storage adapters remain responsible for mapping a logical path back
26
30
  to its existing physical entry.
27
31
 
32
+ ## Initial host settings
33
+
34
+ Commonlib's shared new-Vault and stored-setting defaults retain version `0`.
35
+ The maintained CLI and Obsidian host extension uses version `1` for newly
36
+ created synchronisation settings, while retaining `0` for old settings and
37
+ Setup URIs which omit the field. Its application adoption is tracked above.
38
+ This policy does not enable NFC for WebApp or WebPeer, and does not migrate
39
+ existing databases.
40
+
41
+ The focused replication entry exports `inspectDatabasePathIdentity` and
42
+ `PathIdentityInspection`. The existing `RemoteConnectionProbe` may expose
43
+ `inspectPathIdentity` for read-only initial setup. Inspection distinguishes a
44
+ confirmed empty remote from an existing declaration; unavailable or unsupported
45
+ state rejects. Hosts use the existing declaration before first participation,
46
+ and keep source Rebuild and configured startup explicit. Journal inspection
47
+ reads milestone evidence without writing a node, Security Seed, or checkpoint.
48
+ A P2P signalling probe does not establish peer database identity; Setup URIs
49
+ carry the selected mode, and manual configuration must match the source.
50
+
28
51
  ## Database compatibility
29
52
 
30
53
  Version `1` uses `nfc-path-identity-v1` in the existing generation-13
@@ -78,16 +101,85 @@ does not itself perform the required reconstruction.
78
101
 
79
102
  ## Supported hosts
80
103
 
81
- The initial support boundary is the maintained CLI and Obsidian with CouchDB.
82
- `PathService` owns logical ID derivation. The CLI resolves NFC-equivalent names
83
- against directory entries while preserving the actual entry spelling; its
84
- generic Node storage contract remains exact-path access. Obsidian supplies its
85
- normalised storage paths and preserves an existing physical spelling when it
86
- is NFC-equivalent to the received path.
87
-
88
- Journal and P2P refuse version `1`. Direct file access refuses a remote which
89
- declares the NFC feature. Other host adapters must establish physical path
90
- resolution before offering this setting. The regression tests cover ASCII,
104
+ The published Commonlib `0.3.0` package includes NFC protocol support for
105
+ Journal and P2P. The matching Self-hosted LiveSync CLI and Obsidian host
106
+ adoption remains an unreleased candidate tracked by
107
+ [pull request #1309](https://github.com/vrtmrz/obsidian-livesync/pull/1309);
108
+ the package protocol support alone does not mean those host integrations have
109
+ shipped.
110
+
111
+ The shared `/storage` resolver, Node and File System Access adapters, and
112
+ explicit `DirectFileManipulator` path-version option are later unpublished
113
+ additions described in the [shared storage path design](design_docs/storage_path_resolution.md).
114
+ They are not in the registry artefact `0.3.0` and require a new immutable
115
+ Commonlib package version. A source checkout carrying the same version string
116
+ does not make these additions part of the published artefact.
117
+
118
+ | Consumer surface | Published baseline | Current candidate status |
119
+ | --- | --- | --- |
120
+ | CLI and Obsidian with CouchDB | NFC identity is released in Commonlib `0.1.42` and Self-hosted LiveSync `1.0.38`. | The unreleased LiveSync candidate adds the shared Node resolver in the CLI and shared namespace/comparison helpers in Obsidian. |
121
+ | CLI and Obsidian with Journal or P2P | Commonlib `0.3.0` publishes the NFC protocol support. | Matching host adoption remains unreleased pending [LiveSync #1309](https://github.com/vrtmrz/obsidian-livesync/pull/1309). |
122
+ | Bridge | Legacy version `0` remains the default baseline. | The Bridge candidate enables version `1` only by explicit peer opt-in; every peer in a group must use the same path version. Its ordinary case-mismatch check remains separate from the required version check. |
123
+ | WebApp | Legacy version `0` only. | WebApp remains Legacy-only; an explicit version `1` is rejected at startup. The browser storage primitive alone does not enable application support. |
124
+ | WebPeer | A vaultless P2P utility. | It is not an NFC filesystem host. |
125
+ | `DirectFileManipulator` | The published package rejects a remote declaring the NFC feature. | The unpublished option defaults to version `0`, accepts explicit `0` or `1`, and rejects a populated database in the opposite mode. The caller still owns physical path handling. |
126
+
127
+ `PathService` owns logical ID derivation. In the unreleased LiveSync host
128
+ candidate, the CLI resolves NFC-equivalent names against directory entries
129
+ while preserving the actual entry spelling; its generic Node storage contract
130
+ remains exact-path access. Obsidian supplies its normalised storage paths and
131
+ preserves an existing physical spelling when it is NFC-equivalent to the
132
+ received path.
133
+
134
+ Journal uses compatibility range `4` for NFC identity, independently of
135
+ encryption and path obfuscation. Legacy ranges remain unchanged. The existing
136
+ stored node ranges and required Tweak reject a different identity even when
137
+ ordinary mismatch warnings are disabled. Removing preferred Tweaks does not
138
+ remove the range check or an existing document-ID agreement proof. The existing
139
+ ID check is also reused before Fetch and ordinary milestone updates. A missing
140
+ milestone over existing journals requires Rebuild in both legacy and NFC modes;
141
+ it is not permission to declare a new identity. Older clients must be updated
142
+ before migration; their explicit version-check override is outside this
143
+ compatibility guarantee.
144
+
145
+ The same read-only identity assessment runs before a Journal Fetch resets the
146
+ local database and before ordinary milestone updates. It does not publish a
147
+ node, create a Security Seed, or change a checkpoint. Rebuild first locks the
148
+ existing milestone for the rebuilding node, retaining an existing compatibility
149
+ range for that node and preserving the old identity evidence and Tweaks until
150
+ the journals are deleted. Deletion lists the keys once, retaining skipped control
151
+ document keys until all Journal pages have been processed. It then removes those
152
+ control documents, including the milestone and Security Seed, in finite batches.
153
+ A repeated or backwards listing cursor stops the reset before those control
154
+ documents are removed. A partial failure or interrupted request during Journal
155
+ deletion retains those control documents and the transfer checkpoint for a retry. Checkpoints reset only after control
156
+ document deletion also succeeds. A missing milestone stays absent during this
157
+ step. The replacement identity is declared after deletion succeeds, so a failed
158
+ or interrupted deletion cannot label the old journals with the new identity.
159
+
160
+ P2P uses its existing Tweak exchange and version document to check both peers
161
+ before ordinary data replication. Missing path settings mean version `0`.
162
+ Local Metadata without the matching feature requires Rebuild. A fresh database
163
+ with only control documents may declare the existing NFC feature. Connection
164
+ state is renewed when the selected identity changes. This adds no
165
+ authentication protocol or persistent admission store; all participating peers
166
+ must be updated and migrated.
167
+
168
+ Journal migration rebuilds the source local database and remote journals. P2P
169
+ Rebuild prepares only the source local database. Other devices replace their
170
+ local databases through Fetch. The existing local reset destroys Journal KV
171
+ checkpoints; the P2P source mark and target checkpoint handle database
172
+ replacement. These operations do not rewrite IDs or merge histories in place.
173
+ P2P retains its existing source selection during Fetch.
174
+
175
+ Published Commonlib direct file access refuses a remote which declares the NFC
176
+ feature. The unpublished `DirectFileManipulator` addition exposes explicit
177
+ `pathNormalizationVersion` options, defaulting to `0`: missing or `0` retains
178
+ Legacy and rejects an NFC database; `1` accepts NFC and rejects a populated
179
+ Legacy database before feature negotiation can change its declaration. A
180
+ confirmed empty database follows the existing first-write feature contract.
181
+ Direct integrations must establish physical path resolution before offering
182
+ this setting; database admission alone does not provide that host behaviour. The regression tests cover ASCII,
91
183
  NFC, NFD, and mixed paths through in-memory PouchDB Metadata lookup, with and
92
184
  without path obfuscation, plus database admission, reconstruction ordering,
93
185
  collisions, and physical path handling. These tests do not establish native
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vrtmrz/livesync-commonlib",
3
- "version": "0.2.3",
3
+ "version": "0.3.1",
4
4
  "description": "Shared data, storage, and replication primitives for Self-hosted LiveSync clients.",
5
5
  "type": "module",
6
6
  "types": "./dist/index.d.ts",
@@ -92,6 +92,11 @@
92
92
  "import": "./dist/settings.js",
93
93
  "default": "./dist/settings.js"
94
94
  },
95
+ "./storage": {
96
+ "types": "./dist/storage.d.ts",
97
+ "import": "./dist/storage.js",
98
+ "default": "./dist/storage.js"
99
+ },
95
100
  "./setup-uri": {
96
101
  "types": "./dist/setupUri.d.ts",
97
102
  "import": "./dist/setupUri.js",
@@ -675,6 +680,9 @@
675
680
  "settings": [
676
681
  "dist/settings.d.ts"
677
682
  ],
683
+ "storage": [
684
+ "dist/storage.d.ts"
685
+ ],
678
686
  "setup-uri": [
679
687
  "dist/setupUri.d.ts"
680
688
  ],
@@ -1019,7 +1027,7 @@
1019
1027
  "fflate": "^0.8.2",
1020
1028
  "idb": "^8.0.3",
1021
1029
  "markdown-it": "^14.3.3",
1022
- "minimatch": "^10.2.6",
1030
+ "minimatch": "^11.0.3",
1023
1031
  "octagonal-wheels": "0.1.56",
1024
1032
  "pouchdb-adapter-http": "^9.0.0",
1025
1033
  "pouchdb-adapter-idb": "^9.0.0",