@vrtmrz/livesync-commonlib 0.4.1 → 0.4.3

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 (70) hide show
  1. package/README.md +16 -2
  2. package/dist/API/DirectFileManipulatorV2.d.ts +1 -0
  3. package/dist/API/DirectFileManipulatorV2.js +3 -1
  4. package/dist/API/processSetting.d.ts +1 -0
  5. package/dist/API/processSetting.js +3 -0
  6. package/dist/common/models/setting.const.defaults.js +1 -0
  7. package/dist/common/models/setting.const.qr.js +2 -1
  8. package/dist/common/models/setting.encryption.d.ts +2 -0
  9. package/dist/common/models/setting.encryption.js +6 -0
  10. package/dist/common/models/setting.lifecycle.js +7 -2
  11. package/dist/common/models/setting.policy.d.ts +4 -0
  12. package/dist/common/models/setting.policy.js +9 -0
  13. package/dist/common/models/setting.type.d.ts +2 -0
  14. package/dist/common/models/shared.definition.configNames.js +5 -0
  15. package/dist/common/models/tweak.definition.d.ts +1 -0
  16. package/dist/common/settingConstants.d.ts +1 -0
  17. package/dist/common/utils.js +5 -4
  18. package/dist/diagnostics/couchdb.js +4 -2
  19. package/dist/interfaces/FileHandler.d.ts +59 -0
  20. package/dist/interfaces/FileReflectionProvenance.d.ts +15 -1
  21. package/dist/interfaces/FileReflectionProvenance.js +11 -1
  22. package/dist/managers/ChunkFetcher.js +27 -4
  23. package/dist/managers/chunkFetcher.helper.js +1 -1
  24. package/dist/pouchdb/StreamingFetch.d.ts +1 -2
  25. package/dist/pouchdb/encryption.d.ts +5 -10
  26. package/dist/pouchdb/encryption.eden.d.ts +11 -0
  27. package/dist/pouchdb/encryption.eden.js +37 -0
  28. package/dist/pouchdb/encryption.js +67 -63
  29. package/dist/pouchdb/encryption.policy.d.ts +9 -0
  30. package/dist/pouchdb/encryption.policy.js +125 -0
  31. package/dist/replication/UnencryptedContentRejectedError.d.ts +16 -0
  32. package/dist/replication/UnencryptedContentRejectedError.js +44 -0
  33. package/dist/replication/couchdb/LiveSyncReplicator.js +41 -4
  34. package/dist/replication/index.d.ts +2 -0
  35. package/dist/replication/index.js +3 -0
  36. package/dist/replication/trystero/TrysteroReplicator.d.ts +2 -0
  37. package/dist/replication/unencryptedContentMessages.d.ts +8 -0
  38. package/dist/replication/unencryptedContentMessages.js +12 -0
  39. package/dist/serviceFeatures/offlineScanner/fileStatus.d.ts +61 -0
  40. package/dist/serviceFeatures/offlineScanner/fileStatus.js +85 -0
  41. package/dist/serviceFeatures/offlineScanner/files.d.ts +47 -0
  42. package/dist/serviceFeatures/offlineScanner/files.js +218 -0
  43. package/dist/serviceFeatures/offlineScanner/metadata.d.ts +56 -0
  44. package/dist/serviceFeatures/offlineScanner/metadata.js +320 -0
  45. package/dist/serviceFeatures/offlineScanner/paths.d.ts +20 -0
  46. package/dist/serviceFeatures/offlineScanner/paths.js +16 -0
  47. package/dist/serviceFeatures/offlineScanner/scan.d.ts +35 -0
  48. package/dist/serviceFeatures/offlineScanner/scan.js +358 -0
  49. package/dist/serviceFeatures/offlineScanner/types.d.ts +134 -0
  50. package/dist/serviceFeatures/offlineScanner/types.js +66 -0
  51. package/dist/serviceFeatures/offlineScanner.d.ts +25 -251
  52. package/dist/serviceFeatures/offlineScanner.js +36 -860
  53. package/dist/serviceModules/Rebuilder.js +28 -4
  54. package/dist/serviceModules/ServiceFileHandlerBase/deletionRecovery.d.ts +13 -0
  55. package/dist/serviceModules/ServiceFileHandlerBase/deletionRecovery.js +194 -0
  56. package/dist/serviceModules/ServiceFileHandlerBase.d.ts +22 -1
  57. package/dist/serviceModules/ServiceFileHandlerBase.js +29 -0
  58. package/dist/services/base/KeyValueDBService.d.ts +9 -0
  59. package/dist/services/base/KeyValueDBService.js +11 -1
  60. package/dist/services/base/RemoteConnection.d.ts +2 -0
  61. package/dist/services/base/RemoteService.js +2 -1
  62. package/dist/services/base/SettingService.js +2 -0
  63. package/dist/settings.d.ts +2 -1
  64. package/dist/settings.js +2 -0
  65. package/dist/worker/bgWorker.js +1 -1
  66. package/docs/development.md +4 -0
  67. package/docs/offline-scanner.md +22 -0
  68. package/docs/settings-lifecycle.md +4 -0
  69. package/docs/storage-events-and-reflection.md +16 -10
  70. package/package.json +1 -1
@@ -53,6 +53,7 @@ not add consumer entry points.
53
53
  | `provenance.ts`, `scanning.ts` | Track the displayed revision and content evidence, classify storage, revalidate snapshots, and inspect scan hints. |
54
54
  | `saving.ts` | Save ordinary or reconciled storage content and handle explicit base-revision selection. |
55
55
  | `deletion.ts`, `renaming.ts` | Apply deletion, revision removal, and source-preserving rename operations. |
56
+ | `deletionRecovery.ts` | Recover retained logical deletions and interrupted cleanup under opt-in provenance and shared file admission. |
56
57
  | `reflection.ts`, `protection.ts` | Reflect database revisions while protecting unsynchronised storage content. |
57
58
  | `events.ts`, `selection.ts` | Interpret ordinary, restored, retried, and replicated events against current selection and storage. |
58
59
  | `chunks.ts` | Repair chunks through the host's save method with bounded concurrency. |
@@ -307,3 +308,6 @@ The shared value extraction uses the declared Octagonal Wheels dependency. Its
307
308
  package's public duration and delimiter helpers; source tests cover the
308
309
  internal JSON copy adapter. When testing a future unpublished dependency, keep
309
310
  these checks tied to the same Octagonal Wheels tarball used by the downstream consumer.
311
+
312
+ The opt-in ordinary deletion recovery contract, runtime budgets, and restart
313
+ cleanup ownership are recorded in [Deletion recovery](deletion-recovery.md).
@@ -7,6 +7,12 @@ status: unreleased
7
7
 
8
8
  # Full offline scan
9
9
 
10
+ The public entry remains `serviceFeatures/offlineScanner`. Internally,
11
+ `src/serviceFeatures/offlineScanner/` separates shared types, path comparison,
12
+ Metadata inspection and repair, last-seen persistence, file collection and
13
+ reflection, and scan orchestration. The entry module retains lifecycle integration
14
+ and re-exports its existing public functions; callers do not need to change imports.
15
+
10
16
  Implementation note: the settings-controlled strict comparison correction for [Self-hosted LiveSync #1329](https://github.com/vrtmrz/obsidian-livesync/issues/1329) is implemented but unreleased. The original reviewed-version fields above retain their historical baseline.
11
17
 
12
18
  This document defines the developer contract for `synchroniseAllFilesBetweenDBandStorage`. It describes how the scanner classifies each selected path, chooses an action, and records a database-to-storage reflection. Host-specific setup dialogue and recovery choices remain outside this contract.
@@ -179,3 +185,19 @@ Identity coverage verifies early quarantine when no consistent target exists, co
179
185
  Stored-event coverage verifies that current storage content replaces saved observations, a recreated path suppresses a stale deletion, distinct-ID rename halves are admitted independently from current path state, and a same-ID rename never performs a separate deletion. It also verifies that a storage-inspection failure does not become evidence for a destructive operation, that failed work remains pending, and that an individual replay failure does not prevent the full scan from running.
180
186
 
181
187
  Maintain that interaction boundary when changing file-handler results, last-seen persistence, Fast Setup reflection, or offline deletion detection.
188
+
189
+
190
+ ## Opt-in recovery of retained logical deletions
191
+
192
+ The base action matrix remains the policy for hosts without deletion recovery.
193
+ A host whose handler reports `supportsDeletionRecovery()` may recover a
194
+ conflict-free, newer `both-db-deleted` pair during ordinary `NEWER_WINS` without
195
+ extra policies. This guarded operation does not use `update-storage` or direct
196
+ `delete-local`. Existing explicit policies retain their choices.
197
+
198
+ For `db-only-deleted` pairs, one optional provenance key enumeration identifies
199
+ stale bookkeeping. Cleanup-only work precedes new deletions and never reads file
200
+ bodies or invokes physical deletion. All affected paths are revalidated by their
201
+ handler. See [Deletion recovery](deletion-recovery.md) for completion, error,
202
+ concurrency, and cost contracts. This opt-in extension is published in
203
+ [Commonlib 0.4.2](https://github.com/vrtmrz/livesync-commonlib/releases/tag/0.4.2).
@@ -8,6 +8,10 @@ Commonlib separates three values which older integrations commonly treated as on
8
8
 
9
9
  `DEFAULT_SETTINGS` remains an alias of `SETTINGS_SCHEMA_DEFAULTS` for compatibility. New code should choose the named contract which matches its operation.
10
10
 
11
+ ## Unreleased: plaintext acceptance setting
12
+
13
+ The unreleased `acceptUnencryptedContent` setting defaults to `false`; only the boolean value `true` enables it. With E2EE enabled, it permits receipt of unencrypted file content from third-party tools which do not use the E2EE passphrase. Content sent by the plug-in remains encrypted. Complete Setup URI and QR imports normalise a missing or invalid value to `false`. Settings Markdown includes the value regardless of credential-sharing choice; a partial Markdown import preserves the current value when the field is absent and treats an explicitly invalid value as `false`.
14
+
11
15
  ## Starting a new Vault
12
16
 
13
17
  Use `createNewVaultSettings()` only when the settings store is absent or empty, or when the user explicitly requests a factory reset. `NEW_VAULT_SETTINGS` exposes the values for inspection, while the factory prevents mutable nested settings from being shared between clients:
@@ -2,7 +2,7 @@
2
2
  date: 2026-10-26
3
3
  commonlib-version: "0.2.1"
4
4
  self-hosted-livesync-version: "1.0.40"
5
- status: unreleased
5
+ status: published
6
6
  ---
7
7
 
8
8
  # Storage events and database-to-storage reflection
@@ -11,8 +11,13 @@ This note separates storage-to-database event handling from
11
11
  database-to-storage reflection. It documents the current guard against a stale
12
12
  `DELETE` notification logically deleting Metadata while the same file is still
13
13
  present in storage, and the accepted local completion contract for queued file
14
- operations. The version fields identify the reviewed source versions; these
15
- changes remain unreleased.
14
+ operations. The version fields identify the original reviewed source versions.
15
+
16
+ > Publication note (9th November, 2026): This implementation, including the
17
+ > [ordinary-file retry extension](#retrying-ordinary-file-operations), is included
18
+ > in published [Commonlib 0.4.1](https://github.com/vrtmrz/livesync-commonlib/releases/tag/0.4.1).
19
+ > The original review date and version baseline are retained above. Host
20
+ > applications adopt this package through their own dependency updates.
16
21
 
17
22
  ## Event-manager terminology
18
23
 
@@ -249,12 +254,13 @@ current content for processing.
249
254
 
250
255
  ## Retrying ordinary file operations
251
256
 
252
- The following extension is unreleased. A failed ordinary `CREATE`, `CHANGED`,
253
- `DELETE`, or `RENAME` remains pending, while its attempt has a completed failure
254
- result. A later finite `commitPendingFileEvents()` request can start a new
255
- attempt. A subsequent event for the same path or related rename paths can also
256
- re-evaluate failed predecessors before proceeding. These paths share the event
257
- manager's ownership and use the existing current-state reconciliation rules.
257
+ The following extension is available in Commonlib 0.4.1. A failed ordinary
258
+ `CREATE`, `CHANGED`, `DELETE`, or `RENAME` remains pending, while its attempt has
259
+ a completed failure result. A later finite `commitPendingFileEvents()` request
260
+ can start a new attempt. A subsequent event for the same path or related rename
261
+ paths can also re-evaluate failed predecessors before proceeding. These paths
262
+ share the event manager's ownership and use the existing current-state
263
+ reconciliation rules.
258
264
 
259
265
  Each request captures a finite set of operations and attempts. It may retry an
260
266
  existing failure once, shares an attempt already running, and reports failures
@@ -286,7 +292,7 @@ Runtime retries reuse its file-reconciliation rules without replacing the
286
292
  running manager through `restoreState()`. The saved format, handler return
287
293
  contracts, and optional-provider retry policy remain unchanged. Hosts can use
288
294
  their existing flush and lifecycle calls; no retry timer or new callback is
289
- required. See the [retry decision](https://github.com/vrtmrz/obsidian-livesync/blob/main/docs/adr/2026_11_local_file_operation_retry.md)
295
+ required. See the [reviewed retry decision](https://github.com/vrtmrz/obsidian-livesync/blob/09c17e90dde3b1a2000c8a2e13301245107b915b/docs/adr/2026_11_local_file_operation_retry.md)
290
296
  for the operation matrix and considered alternatives.
291
297
 
292
298
  ## Optional file handlers
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vrtmrz/livesync-commonlib",
3
- "version": "0.4.1",
3
+ "version": "0.4.3",
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",