@vrtmrz/livesync-commonlib 0.6.0 → 0.7.0

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 (83) hide show
  1. package/README.md +29 -19
  2. package/dist/common/models/shared.definition.d.ts +10 -1
  3. package/dist/common/models/shared.definition.js +4 -3
  4. package/dist/events/coreEvents.d.ts +3 -0
  5. package/dist/events/coreEvents.js +2 -0
  6. package/dist/managers/EntryManager/EntryManager.d.ts +1 -1
  7. package/dist/managers/EntryManager/EntryManager.js +2 -2
  8. package/dist/managers/EntryManager/EntryManagerImpls.d.ts +1 -1
  9. package/dist/managers/EntryManager/EntryManagerImpls.js +4 -4
  10. package/dist/managers/StorageEventManager/admission.d.ts +1 -0
  11. package/dist/managers/StorageEventManager/admission.js +5 -1
  12. package/dist/managers/StorageEventManager.d.ts +2 -0
  13. package/dist/managers/StorageEventManager.js +1 -0
  14. package/dist/pouchdb/LiveSyncLocalDB.d.ts +1 -1
  15. package/dist/pouchdb/LiveSyncLocalDB.js +2 -2
  16. package/dist/pouchdb/encryption.policy.js +2 -1
  17. package/dist/replication/LiveSyncAbstractReplicator.d.ts +7 -0
  18. package/dist/replication/LiveSyncAbstractReplicator.js +5 -2
  19. package/dist/replication/ReplicatorInstance.d.ts +3 -0
  20. package/dist/replication/ReplicatorProvider.d.ts +23 -2
  21. package/dist/replication/ReplicatorProvider.js +10 -0
  22. package/dist/replication/SyncParamsHandler.js +26 -25
  23. package/dist/replication/UnsupportedEncryptedDocumentFormatError.d.ts +13 -0
  24. package/dist/replication/UnsupportedEncryptedDocumentFormatError.js +28 -0
  25. package/dist/replication/couchdb/LiveSyncReplicator.d.ts +17 -3
  26. package/dist/replication/couchdb/LiveSyncReplicator.js +265 -132
  27. package/dist/replication/index.d.ts +5 -2
  28. package/dist/replication/index.js +8 -0
  29. package/dist/replication/remoteTransportFailure.d.ts +24 -0
  30. package/dist/replication/remoteTransportFailure.js +80 -0
  31. package/dist/replication/trystero/TrysteroReplicatorP2PServer.d.ts +1 -1
  32. package/dist/replication/trystero/TrysteroReplicatorP2PServer.js +2 -2
  33. package/dist/replication/trystero/TrysteroRpcRoom.d.ts +14 -0
  34. package/dist/replication/trystero/TrysteroRpcRoom.js +168 -0
  35. package/dist/replication/trystero/rpcCompat.d.ts +1 -0
  36. package/dist/replication/trystero/rpcCompat.js +15 -0
  37. package/dist/rpc/RpcRoom.d.ts +1 -0
  38. package/dist/rpc/RpcRoom.js +21 -9
  39. package/dist/rpc/RpcSession.d.ts +8 -13
  40. package/dist/rpc/RpcSession.js +14 -35
  41. package/dist/rpc/commonlibRpcRoom.d.ts +1 -0
  42. package/dist/rpc/commonlibRpcRoom.js +4 -0
  43. package/dist/rpc/errors.d.ts +9 -3
  44. package/dist/rpc/errors.js +13 -16
  45. package/dist/rpc/index.d.ts +10 -1
  46. package/dist/rpc/index.js +2 -1
  47. package/dist/rpc/pouchdb/RpcPouchDBProxy.d.ts +1 -1
  48. package/dist/rpc/pouchdb/RpcPouchDBServer.d.ts +1 -1
  49. package/dist/serviceFeatures/targetFilter.d.ts +3 -1
  50. package/dist/serviceFeatures/targetFilter.js +2 -2
  51. package/dist/services/base/IService.d.ts +9 -6
  52. package/dist/services/base/ReadinessEvaluator.d.ts +7 -6
  53. package/dist/services/base/ReadinessEvaluator.js +4 -2
  54. package/dist/services/base/RemoteConnection.d.ts +4 -0
  55. package/dist/services/base/RemoteService.d.ts +5 -3
  56. package/dist/services/base/RemoteService.js +85 -33
  57. package/dist/services/base/ReplicationService.d.ts +11 -2
  58. package/dist/services/base/ReplicationService.js +18 -7
  59. package/dist/services/base/ReplicationService.readiness.d.ts +14 -4
  60. package/dist/services/base/ReplicationService.readiness.js +29 -2
  61. package/dist/services/base/ReplicationService.typedReplication.d.ts +5 -2
  62. package/dist/services/base/ReplicationService.typedReplication.js +67 -6
  63. package/dist/services/base/ReplicationStaticsOwner.d.ts +18 -0
  64. package/dist/services/base/ReplicationStaticsOwner.js +33 -0
  65. package/dist/services/base/ReplicatorService.d.ts +2 -10
  66. package/dist/services/base/ReplicatorService.js +6 -3
  67. package/dist/services/base/VaultService.d.ts +1 -0
  68. package/dist/string_and_binary/chunks.d.ts +1 -1
  69. package/dist/string_and_binary/chunks.js +63 -50
  70. package/dist/worker/bg.worker.js +3 -1
  71. package/dist/worker/bg.worker.splitting.d.ts +1 -0
  72. package/dist/worker/bg.worker.splitting.js +42 -6
  73. package/dist/worker/bgWorker.d.ts +4 -0
  74. package/dist/worker/bgWorker.js +87 -57
  75. package/dist/worker/bgWorker.splitting.d.ts +2 -3
  76. package/dist/worker/bgWorker.splitting.js +48 -52
  77. package/dist/worker/universalTypes.d.ts +13 -1
  78. package/docs/development.md +69 -32
  79. package/docs/offline-scanner.md +14 -6
  80. package/docs/p2p-transport-lifecycle.md +2 -3
  81. package/docs/releasing.md +6 -5
  82. package/docs/storage-events-and-reflection.md +10 -3
  83. package/package.json +3 -2
@@ -13,12 +13,11 @@ import { type ResultPayloadWithSeq, type SplitProcessItem } from "./universalTyp
13
13
  export declare function _splitPieces2Worker(dataSrc: Blob, pieceSize: number, plainSplit: boolean, minimumChunkSize: number, filename: string | undefined, splitVersion: 1 | 2 | 3, useSegmenter: boolean): () => AsyncGenerator<string, void, unknown>;
14
14
  /**
15
15
  * Aborts all in-flight split tasks identified by the given keys.
16
- * Called when the background worker that owned these tasks has crashed, so the streams
17
- * will never receive any more data and must be torn down to unblock callers.
16
+ * Called when a split fails or its background worker crashes.
18
17
  * @param keys The task keys to abort.
19
18
  * @param error The error to report to each stream.
20
19
  */
21
- export declare function abortSplitTasks(keys: number[], error: Error): void;
20
+ export declare function abortSplitTasks(keys: number[], error: unknown): void;
22
21
  /**
23
22
  * Handles the splitting callback from the worker.
24
23
  * @param process the splitting process item
@@ -1,43 +1,38 @@
1
1
  import { LOG_LEVEL_VERBOSE, Logger } from "../common/logger.js";
2
- import { startWorker, removeTask } from "./bgWorker.js";
2
+ import { startWorker, removeTask, cancelSplitTask } from "./bgWorker.js";
3
3
  import {} from "./universalTypes.js";
4
4
  const SYMBOL_USED = /* @__PURE__ */ Symbol("used");
5
5
  const SYMBOL_END_OF_DATA = /* @__PURE__ */ Symbol("endOfData");
6
- const workerStreams = /* @__PURE__ */ new Map();
7
6
  const writers = /* @__PURE__ */ new Map();
8
7
  const responseBuf = /* @__PURE__ */ new Map();
9
8
  let writerPromise = Promise.resolve();
10
9
  function _splitPieces2Worker(dataSrc, pieceSize, plainSplit, minimumChunkSize, filename, splitVersion, useSegmenter) {
11
- const process = startWorker({
12
- type: "split",
13
- dataSrc,
14
- pieceSize,
15
- plainSplit,
16
- minimumChunkSize,
17
- filename,
18
- useSegmenter,
19
- splitVersion
20
- });
21
- const _key = process.key;
22
- const stream = new TransformStream({
23
- transform: (chunk, controller) => {
24
- if (chunk === null) {
25
- controller.terminate();
26
- return;
27
- }
28
- controller.enqueue(chunk);
29
- },
30
- flush: () => {
31
- }
32
- });
33
- workerStreams.set(_key, stream);
34
- const readable = stream.readable;
35
- const reader = readable.getReader();
36
- const writer = stream.writable.getWriter();
37
- writers.set(_key, writer);
38
10
  return async function* () {
11
+ const stream = new TransformStream({
12
+ transform(chunk, controller) {
13
+ if (chunk === null) {
14
+ controller.terminate();
15
+ return;
16
+ }
17
+ controller.enqueue(chunk);
18
+ }
19
+ });
20
+ const reader = stream.readable.getReader();
21
+ const writer = stream.writable.getWriter();
22
+ const process = startWorker({
23
+ type: "split",
24
+ dataSrc,
25
+ pieceSize,
26
+ plainSplit,
27
+ minimumChunkSize,
28
+ filename,
29
+ useSegmenter,
30
+ splitVersion
31
+ });
32
+ const key = process.key;
33
+ writers.set(key, writer);
34
+ let done = false;
39
35
  try {
40
- let done = false;
41
36
  do {
42
37
  const results = await reader.read();
43
38
  done = results.done;
@@ -47,40 +42,39 @@ function _splitPieces2Worker(dataSrc, pieceSize, plainSplit, minimumChunkSize, f
47
42
  yield results.value;
48
43
  } while (!done);
49
44
  } catch (ex) {
50
- Logger(`Error in worker stream for key ${_key}`);
45
+ Logger(`Error in worker stream for key ${key}`);
51
46
  Logger(ex, LOG_LEVEL_VERBOSE);
52
47
  throw ex;
53
48
  } finally {
54
49
  process.finalize();
55
- workerStreams.delete(_key);
56
- writers.delete(_key);
50
+ writers.delete(key);
51
+ responseBuf.delete(key);
52
+ if (done) {
53
+ removeTask(key);
54
+ } else {
55
+ cancelSplitTask(key);
56
+ }
57
+ void reader.cancel().catch((error) => Logger(error, LOG_LEVEL_VERBOSE));
57
58
  }
58
59
  };
59
60
  }
60
61
  function abortSplitTasks(keys, error) {
61
62
  for (const key of keys) {
63
+ removeTask(key);
62
64
  responseBuf.delete(key);
63
- writerPromise = writerPromise.then(async () => {
64
- const writer = writers.get(key);
65
- if (writer) {
66
- await writer.abort(error);
67
- writers.delete(key);
68
- }
69
- workerStreams.delete(key);
70
- });
65
+ const writer = writers.get(key);
66
+ writers.delete(key);
67
+ void writer?.abort(error).catch((abortError) => Logger(abortError, LOG_LEVEL_VERBOSE));
71
68
  }
72
69
  }
73
70
  function handleTaskSplit(process, data) {
74
71
  const key = data.key;
75
72
  if (!("result" in data)) {
76
- responseBuf.delete(key);
77
- const reportError = data.error || new Error("Unknown error in background splitting");
78
- writerPromise = writerPromise.then(async () => {
79
- const writer = writers.get(key);
80
- if (writer) {
81
- await writer.abort(reportError);
82
- }
83
- });
73
+ const { name, message, stack } = data.error;
74
+ const error = new Error(message);
75
+ error.name = name;
76
+ error.stack = stack ?? error.stack;
77
+ abortSplitTasks([key], error);
84
78
  return;
85
79
  }
86
80
  let thisBuf = responseBuf.get(key);
@@ -105,10 +99,12 @@ function handleTaskSplit(process, data) {
105
99
  responseBuf.set(key, thisBuf);
106
100
  writerPromise = writerPromise.then(async () => {
107
101
  const writer = writers.get(key);
108
- if (!writer) {
109
- throw new Error(`Invalid writer for key ${key} in background splitting`);
102
+ try {
103
+ await writer?.write(result === SYMBOL_END_OF_DATA ? null : result);
104
+ } catch (error) {
105
+ abortSplitTasks([key], error);
106
+ return;
110
107
  }
111
- await writer.write(result === SYMBOL_END_OF_DATA ? null : result);
112
108
  if (result === SYMBOL_END_OF_DATA) {
113
109
  removeTask(key);
114
110
  responseBuf.delete(key);
@@ -24,9 +24,14 @@ export type SplitArguments = {
24
24
  useSegmenter: boolean;
25
25
  splitVersion: 1 | 2 | 3;
26
26
  };
27
+ export type CancelSplitArguments = {
28
+ key: number;
29
+ type: "cancelSplit";
30
+ };
27
31
  export type SplitProcessItem = {
28
32
  key: number;
29
33
  type: SplitArguments["type"];
34
+ workerFinished?: boolean;
30
35
  finalize: () => void;
31
36
  };
32
37
  export type EncryptProcessItem = {
@@ -60,4 +65,11 @@ export type ResultPayloadWithSeqBase = ResultPayload & {
60
65
  export type ResultPayloadPiece = ResultPayloadWithSeqBase & {
61
66
  result: string | END_OF_DATA;
62
67
  };
63
- export type ResultPayloadWithSeq = ResultPayloadPiece | ResultPayloadWithError;
68
+ export type SplitErrorPayload = ResultPayloadBase & {
69
+ error: {
70
+ name: string;
71
+ message: string;
72
+ stack?: string;
73
+ };
74
+ };
75
+ export type ResultPayloadWithSeq = ResultPayloadPiece | SplitErrorPayload;
@@ -46,17 +46,17 @@ class and its existing import path. Its implementation lives in the sibling
46
46
  `ServiceFileHandlerBase/` directory. These modules are package-private; they do
47
47
  not add consumer entry points.
48
48
 
49
- | Modules | Responsibility |
50
- | --- | --- |
51
- | `context.ts`, `storage.ts` | Capture injected services, own per-instance state, retain host method dispatch, and resolve file paths, stubs, and bodies. |
52
- | `locking.ts` | Acquire sorted document locks and run deferred conflict hooks after releasing them. |
53
- | `provenance.ts`, `scanning.ts` | Track the displayed revision and content evidence, classify storage, revalidate snapshots, and inspect scan hints. |
54
- | `saving.ts` | Save ordinary or reconciled storage content and handle explicit base-revision selection. |
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. |
57
- | `reflection.ts`, `protection.ts` | Reflect database revisions while protecting unsynchronised storage content. |
58
- | `events.ts`, `selection.ts` | Interpret ordinary, restored, retried, and replicated events against current selection and storage. |
59
- | `chunks.ts` | Repair chunks through the host's save method with bounded concurrency. |
49
+ | Modules | Responsibility |
50
+ | -------------------------------- | -------------------------------------------------------------------------------------------------------------------------- |
51
+ | `context.ts`, `storage.ts` | Capture injected services, own per-instance state, retain host method dispatch, and resolve file paths, stubs, and bodies. |
52
+ | `locking.ts` | Acquire sorted document locks and run deferred conflict hooks after releasing them. |
53
+ | `provenance.ts`, `scanning.ts` | Track the displayed revision and content evidence, classify storage, revalidate snapshots, and inspect scan hints. |
54
+ | `saving.ts` | Save ordinary or reconciled storage content and handle explicit base-revision selection. |
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. |
57
+ | `reflection.ts`, `protection.ts` | Reflect database revisions while protecting unsynchronised storage content. |
58
+ | `events.ts`, `selection.ts` | Interpret ordinary, restored, retried, and replicated events against current selection and storage. |
59
+ | `chunks.ts` | Repair chunks through the host's save method with bounded concurrency. |
60
60
 
61
61
  The facade acquires document locks at public operation boundaries. Internal
62
62
  operations reuse the caller's locks; routing them back through a public wrapper
@@ -82,15 +82,15 @@ from the file handler's database and storage effects.
82
82
  interface, wire command assembly, peer-arrival policy, and host lifecycle. Its
83
83
  internal modules use narrow capabilities rather than the complete replicator:
84
84
 
85
- | Module under `TrysteroReplicator/` | Responsibility |
86
- | --- | --- |
87
- | `changeRelay.ts` | Own the changes feed, broadcast state, followed peers, and last sequence; schedule notifications and request pulls. |
88
- | `peerAgreement.ts` | Request authentication and compare tweak, path-identity, and ID-derivation agreement without exposing the ID key. |
89
- | `configurationExchange.ts` | Prepare shared settings, obtain passphrases, encrypt or decrypt configuration, and validate imported ID settings. |
90
- | `progress.ts` | Own acknowledged-attempt state and module-realm attempt numbering, project progress events, and report progress to the peer. |
91
- | `configuredTargets.ts` | Resolve configured peer names, wait for discovery with listener cleanup, and aggregate sequential baseline synchronisation results. |
92
- | `transfers.ts` | Own available and active peer sets, apply transfer gates, run the shared replication engine, and finalise progress. |
93
- | `relayControl.ts` | Adapt shared Trystero relay controls and disconnect a captured socket set without changing host-stop ordering. |
85
+ | Module under `TrysteroReplicator/` | Responsibility |
86
+ | ---------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------- |
87
+ | `changeRelay.ts` | Own the changes feed, broadcast state, followed peers, and last sequence; schedule notifications and request pulls. |
88
+ | `peerAgreement.ts` | Request authentication and compare tweak, path-identity, and ID-derivation agreement without exposing the ID key. |
89
+ | `configurationExchange.ts` | Prepare shared settings, obtain passphrases, encrypt or decrypt configuration, and validate imported ID settings. |
90
+ | `progress.ts` | Own acknowledged-attempt state and module-realm attempt numbering, project progress events, and report progress to the peer. |
91
+ | `configuredTargets.ts` | Resolve configured peer names, wait for discovery with listener cleanup, and aggregate sequential baseline synchronisation results. |
92
+ | `transfers.ts` | Own available and active peer sets, apply transfer gates, run the shared replication engine, and finalise progress. |
93
+ | `relayControl.ts` | Adapt shared Trystero relay controls and disconnect a captured socket set without changing host-stop ordering. |
94
94
 
95
95
  The facade's existing relay accessors refer to the relay's single state object.
96
96
  Agreement and configuration operations obtain snapshot settings and current
@@ -132,19 +132,33 @@ database, room, or complete host environment. Decision types remain available
132
132
  through their previous Server exports.
133
133
 
134
134
  The Server's optional third constructor argument accepts `createRoom`, defaulting
135
- to Trystero's `joinRoom`. It is called at the original point after diagnostic
136
- subscriptions, and real `RpcRoom` instances still own message and peer-event
137
- subscriptions. Registration and the synchronous `beforeAdvertisement` hook
138
- precede advertisement sending. A separate boundary spec uses real RPC rooms and
139
- paired fake Trystero rooms to verify calls, notifications, cancellation, and close.
135
+ to Trystero's `joinRoom`. The server subscribes to diagnostics before joining.
136
+ Starting with [Commonlib 0.7.0](../updates.md#070), it creates a Fancy Kit
137
+ room over the `rpc2` action through `TrysteroRpcRoom`.
138
+ The adapter uses a native `AbortController` by default and converts handler
139
+ cancellation reasons to Commonlib `RpcError` instances before aborting.
140
+ The RPC room owns its message and peer-event subscriptions. Commonlib supplies peer admission,
141
+ method binding, and room shutdown. The adapter uses the decoded request to
142
+ retain the full method name in notification warnings and redacts callback
143
+ errors from those warnings. Response-bearing calls carry the original
144
+ structured errors when they can be normalised. The public
145
+ Commonlib `RpcRoom` retains the standalone room constructor. An
146
+ `instanceof RpcRoom` check recognises standalone Commonlib rooms and hosted
147
+ `TrysteroRpcRoom` instances. Both rooms use Fancy Kit's `RpcSession`.
148
+ Registration and the synchronous `beforeAdvertisement` hook precede
149
+ advertisement sending. The boundary spec uses real RPC rooms and paired fake
150
+ Trystero rooms to verify calls, notifications, cancellation, errors, and close.
151
+ It also verifies the PouchDB helpers against an in-memory database over those rooms.
152
+ The packed-consumer check composes the hosted room and session with the
153
+ Commonlib PouchDB helpers.
140
154
  The replicator facade's optional fourth constructor argument supplies relay
141
155
  controls, preserving its third finite-operation-owner argument. Disconnection
142
156
  reads sockets, pauses reconnection, closes the captured set, and starts the public
143
157
  host-stop operation in the original order. Default controls use the shared
144
158
  Trystero registry.
145
159
 
146
- `src/rpc/RpcRoom.ts` retains registrations, inbound request routing, transport,
147
- and chunk state. `RpcRoom/pendingInvocations.ts` owns outbound response waits,
160
+ The standalone `src/rpc/RpcRoom.ts` retains registrations, inbound request
161
+ routing, transport, and chunk state. `RpcRoom/pendingInvocations.ts` owns outbound response waits,
148
162
  deadlines, abort subscriptions, settlement, and request-before-cancel ordering.
149
163
  The room supplies transport, request IDs, timing, and warning callbacks, and
150
164
  forwards peer departure and close events. Notifications bypass this coordinator.
@@ -251,7 +265,7 @@ The multiple-remote profile contract has focused unit coverage in `src/serviceFe
251
265
 
252
266
  The full offline scanner applies both the host's target-file policy and Commonlib's built-in `shouldBeIgnored` policy before constructing storage/database pairs. This keeps legacy LiveSync log files and flag files outside ordinary create, restore, and delete decisions even when a host accepts their file extension. Lower-level write guards remain a defence for direct calls; they are not the normal full-scan filter. The complete pair-state decision matrix and database-to-storage reflection result contract are documented in [Full offline scan](offline-scanner.md). Extend that document, the Cartesian action test, and both collection-side tests whenever the policy changes.
253
267
 
254
- The unreleased watcher deletion checks and the separate database-to-storage reflection path are recorded in [Storage events and database-to-storage reflection](storage-events-and-reflection.md).
268
+ The watcher deletion checks and the separate database-to-storage reflection path are documented in [Storage events and database-to-storage reflection](storage-events-and-reflection.md).
255
269
 
256
270
  File-path parsing recognises only the leading `i:`, `ix:`, and `ps:` namespaces. Colons elsewhere belong to the path, including the complete remainder after one namespace. Document-ID parsing additionally recognises `h:` and `f:`; those document IDs are not ordinary storage paths. Keep normalisation, selection patterns, and database lookup on the complete path. `pathPrefixes.unit.spec.ts`, `typeUtils.unit.spec.ts`, and `PathService.unit.spec.ts` cover these conversions, and `ServiceFileHandlerBase.colonPaths.unit.spec.ts` exercises storage and reflection with real PouchDB Metadata and Chunks. Host filename restrictions remain a separate contract: a host must not interpret an unsupported name as permission to write a shortened one.
257
271
 
@@ -281,6 +295,30 @@ The active local database identity, settings-selected reset sequence, and lifecy
281
295
 
282
296
  `TypedReplicationCoordinator` keeps user-initiated, unattended, continuous, and stop roles as explicit control flows. Their interaction authority, readiness position, activity accounting, and failure handling differ, so these roles must not be collapsed into a flag-driven capability table. Share only mechanics whose lifecycle meaning is identical, such as atomic context acquisition and finite activity accounting, and retain a focused sequencing test for each role.
283
297
 
298
+ Starting with [Commonlib 0.7.0](../updates.md#070), a host may supply
299
+ `ContinuousReplicationRequest.onStartSettled` to observe the result of one
300
+ continuous start. The ordinary `startContinuous()` result
301
+ still reports admission. CouchDB settles the observer when it hands off a
302
+ live PouchDB handle, when preparation or the initial finite pull fails, or
303
+ when the start is cancelled. Requests that join the same CouchDB start
304
+ observe the same handoff or failure. A later transport interruption belongs
305
+ to the live handle's reconnect behaviour.
306
+
307
+ An attributed failure carries the host's online state and the timestamp
308
+ observed at the failing gate or request. The `networkFailure` field is
309
+ present for an offline readiness refusal or a confirmed transport failure
310
+ which prevents handoff after any internal fallback. Preparation handlers return
311
+ `true` to continue, `false` to refuse, or the network failure observed by
312
+ the rejecting operation. Legacy callers of the preparation hooks still receive
313
+ a boolean. The readiness evaluator carries the first rejection to the start
314
+ request. Hosts own the decision and lifecycle for requesting another start.
315
+
316
+ An explicit call to `stopActiveTransfer()` emits
317
+ `EVENT_REPLICATION_ABORT_REQUESTED` on the service context when the request
318
+ arrives, including when the provider has no active transfer. A host can then
319
+ withdraw a pending automatic start before the current transfer finishes
320
+ stopping.
321
+
284
322
  ### P2P composition ownership
285
323
 
286
324
  `useP2PReplicatorFeature` composes one stable P2P service owner, one room-session owner, and their lifecycle bindings. The service exposes focused views, including owner-arbitrated connection-probe admission, over that same state. When `ReplicatorService` requests a P2P Replicator, the provider returns a fresh non-owning adapter. Replacing or disposing that active adapter does not cancel service-owned work or retire the room; the explicit stop capability and transport lifecycle view own those distinct operations. Database reset and explicit close reach the stable service through their pre-destruction lifecycle hooks, so non-ownership by the active adapter cannot leave a room using an unavailable local database.
@@ -310,7 +348,7 @@ The [maintained-host examples and evidence](proven-in-use.md) are optional conte
310
348
 
311
349
  ### Testing an unpublished Octagonal Wheels dependency
312
350
 
313
- The current integration pins the published Octagonal Wheels 0.1.56 release and
351
+ The current integration pins the published Octagonal Wheels 0.1.57 release and
314
352
  uses the ordinary package gate. The override below is for future unpublished
315
353
  dependency changes.
316
354
 
@@ -382,7 +420,7 @@ Resolve these questions before describing the corresponding behaviour as stable:
382
420
  The platform and RPC ownership decisions are accepted:
383
421
 
384
422
  - `/node` and `/browser` are supported platform façades. They deliberately hide platform-specific imports, adapters, and review exceptions behind package-owned boundaries. The selected Node built-in re-exports are part of that boundary; package tests must continue to prove that browser-capable entries do not reach Node-only code.
385
- - `/rpc` is transitional and is not part of the stable Commonlib 1.0 contract. Keep it only while the maintained LiveSync P2P composition requires the existing implementation. The RPC core, transport integration, wire protocol, and PouchDB bridge are planned for an independently owned rewrite in Fancy Kit; do not encourage new Commonlib consumers to adopt the current entry.
423
+ - `/rpc` is transitional and is not part of the stable Commonlib 1.0 contract. Keep it only while the maintained LiveSync P2P composition requires it. The hosted P2P composition uses the Fancy Kit RPC core through the adapter described above. New consumers should use the supported Commonlib entry points.
386
424
  - The high-level composition target is a narrow asynchronous `createLiveSyncFileClient` factory, not a general Service Hub factory. It must keep the context, service graph, database implementation, protocol setup, watches, reconnect work, and shutdown order private. It resolves only after readiness and returns a small file façade with `list`, `get`, `put`, `delete`, `watch`, and `close`. Full Obsidian, CLI, and browser applications retain host-specific composition because they own UI, persistence, permissions, storage events, and process policy.
387
425
  - `DirectFileManipulator` is a migration source for that file client rather than the stable target contract. Do not carry its fire-and-forget constructor initialisation, exposed service graph and database documents, incomplete enumeration, implicit watch retry, or deprecated settings options into the new public API. Define the exact result, conflict, concurrency, watch checkpoint, retry, and error semantics only after the LiveSync 1.0 work rather than making that future client a release gate.
388
426
 
@@ -390,7 +428,7 @@ The platform and RPC ownership decisions are accepted:
390
428
 
391
429
  The package build records each compatibility path explicitly. Do not add a wildcard export. A new compatibility path requires a real downstream import, a packed-consumer or downstream test, and a migration plan towards a focused public entry or the owning package.
392
430
 
393
- For the unreleased reflection integration, service composition uses
431
+ For the reflection integration introduced in Commonlib 0.6.0, service composition uses
394
432
  `handlers<T>().firstApplicable()` to select the first non-`undefined` result and
395
433
  `handlers<T>().allOrThrow()` to run boolean callbacks until one returns `false`.
396
434
  Both propagate callback exceptions unchanged and retain the existing registration,
@@ -412,7 +450,6 @@ The classification in `docs/migration/compatibility-classification.json` is acce
412
450
 
413
451
  Release preparation and staged-publication checks are documented in [the maintainer runbook](releasing.md).
414
452
 
415
-
416
453
  The shared value extraction uses the declared Octagonal Wheels dependency. Its
417
454
  `utils.runtime-tools.unit.spec.ts` tests preserve the legacy adapter contracts;
418
455
  `runtime-tools-types.ts` and `runtime-tools-runtime.mjs` check the installed
@@ -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
  # Full offline scan
@@ -13,7 +13,12 @@ Metadata inspection and repair, last-seen persistence, file collection and
13
13
  reflection, and scan orchestration. The entry module retains lifecycle integration
14
14
  and re-exports its existing public functions; callers do not need to change imports.
15
15
 
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.
16
+ Publication note: this contract, including host recovery integration, is available
17
+ in [Commonlib 0.6.0](https://github.com/vrtmrz/livesync-commonlib/releases/tag/0.6.0).
18
+ The reviewed-version fields above retain their historical baseline. Downstream adoption and runtime evidence are tracked separately in
19
+ [maintained-host evidence](proven-in-use.md).
20
+
21
+ Implementation note: the settings-controlled strict comparison correction for [Self-hosted LiveSync #1329](https://github.com/vrtmrz/obsidian-livesync/issues/1329) is available in Commonlib 0.6.0.
17
22
 
18
23
  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.
19
24
 
@@ -76,7 +81,7 @@ The standard-file revalidation contract is:
76
81
 
77
82
  An inability to inspect the current path is not proof of absence. Revalidation suppresses a destructive half when storage inspection fails, records the failure, and leaves the operation pending. The full scan can still examine the current state and reports any selected-pair failure under its strict or explicitly partial completion policy. Target-file policy and file-size limits are evaluated from current settings rather than inherited from the saved event.
78
83
 
79
- The unreleased rename-exclusion guard retains `renameTarget` when a rename is converted to deletion during target filtering. Unlike an ordinary deletion, this intent can remove a file from synchronisation without removing it from storage. The guard distinguishes deliberate exclusion from transient case-collision rejection, preserves a recreated source, and permits a deliberately excluded same-ID destination without requiring that destination to disappear. Older snapshots without this optional field retain the absence-only rule. See [Storage events and database-to-storage reflection](storage-events-and-reflection.md) for the exact admission conditions and the separate ordinary watcher boundary.
84
+ The rename-exclusion guard retains `renameTarget` when a rename is converted to deletion during target filtering. Unlike an ordinary deletion, this intent can remove a file from synchronisation without removing it from storage. The guard distinguishes deliberate exclusion from transient case-collision rejection, preserves a recreated source, and permits a deliberately excluded same-ID destination without requiring that destination to disappear. Older snapshots without this optional field retain the absence-only rule. See [Storage events and database-to-storage reflection](storage-events-and-reflection.md) for the exact admission conditions and the separate ordinary watcher boundary.
80
85
 
81
86
  Independent validation of rename halves does not remove target-first execution. When the new path currently exists, its inclusion must finish successfully before the old-path deletion may run. A failed inclusion preserves the old database entry. When the new path is currently absent, there is no inclusion to publish, and a separately validated absence at the old path may be applied as deletion intent.
82
87
 
@@ -203,10 +208,13 @@ concurrency, and cost contracts. This opt-in extension is published in
203
208
  [Commonlib 0.4.2](https://github.com/vrtmrz/livesync-commonlib/releases/tag/0.4.2).
204
209
 
205
210
 
206
- ## Unreleased host recovery integration
211
+ <a id="unreleased-host-recovery-integration"></a>
212
+
213
+ ## Host recovery integration
207
214
 
208
- The following extension was reviewed against Commonlib 0.5.0 and Self-hosted
209
- LiveSync 1.0.50. It is implemented on the working branch and is not yet published.
215
+ The following extension was initially reviewed against Commonlib 0.5.0 and
216
+ Self-hosted LiveSync 1.0.50. It is published in
217
+ [Commonlib 0.6.0](https://github.com/vrtmrz/livesync-commonlib/releases/tag/0.6.0).
210
218
 
211
219
  `VaultScanOptions.onReflectionFailed(target, error)` receives a terminal ordinary DB-to-Vault reflection failure. The target is the selected input document ID and revision; a content error can separately identify the historical revision which could not be read. The scanner awaits the owner callback once. A callback rejection propagates as a persistence failure and is not converted into another content failure. Completed reflection, normal absence, and policy skips do not create failed work.
212
220
 
@@ -128,9 +128,8 @@ persistent replication state is added.
128
128
 
129
129
  ## Best-effort change notifications
130
130
 
131
- Implementation note: this notification path is unreleased, reviewed against
132
- Commonlib 0.4.3 and Self-hosted LiveSync 1.0.49. It does not change the published
133
- status of the lifecycle and diagnostics described elsewhere in this document.
131
+ This notification path is available in [Commonlib 0.5.0](../updates.md#050).
132
+ The original review used Commonlib 0.4.3 and Self-hosted LiveSync 1.0.49.
134
133
 
135
134
  P2P change notifications ask a following peer to fetch database changes; they do
136
135
  not carry Vault data or confirm that a transfer has succeeded. The sender uses
package/docs/releasing.md CHANGED
@@ -81,10 +81,11 @@ source compatibility changes use the next minor version under the policy.
81
81
 
82
82
  ### 0.6.0 integration changes
83
83
 
84
- Version 0.6.0 is an unreleased candidate with source compatibility changes to
85
- strict reads, file reflection, and database lifecycle integration. The standard
86
- base implementations supply the new members. Custom overrides must also follow
87
- the updated return and failure contracts.
84
+ Version [0.6.0](https://github.com/vrtmrz/livesync-commonlib/releases/tag/0.6.0)
85
+ introduces source compatibility changes to strict reads, file reflection, and
86
+ database lifecycle integration. The standard base implementations supply the new
87
+ members. Custom overrides must also follow the updated return and failure
88
+ contracts.
88
89
 
89
90
  Direct interface implementations must provide these additional members:
90
91
 
@@ -118,7 +119,7 @@ I/O can continue after its caller wait ends. Raw replication, changes-feed, and
118
119
  maintenance integrations retain responsibility for their own completion and lifetime.
119
120
 
120
121
  See [Local database lifecycle](database-lifecycle.md) and
121
- [Strict content reads and reflection](offline-scanner.md#unreleased-host-recovery-integration)
122
+ [Strict content reads and reflection](offline-scanner.md#host-recovery-integration)
122
123
  for operation ownership and host integration.
123
124
 
124
125
  ## Preparing a release
@@ -157,9 +157,16 @@ saved stub, cache, and event label cannot establish completion by themselves.
157
157
  ## Processing directions
158
158
 
159
159
  `StorageEventManager.appendQueue` receives watcher events, applies target and
160
- ignore policies, and queues `CREATE`, `CHANGED`, `DELETE`, or `RENAME` work. A
161
- rename from a selected path to a rejected path becomes a `DELETE` with an
162
- old-path deleted stub and the destination in `FileEventArgs.renameTarget`.
160
+ ignore policies, and queues `CREATE`, `CHANGED`, `DELETE`, or `RENAME` work.
161
+ Starting with [Commonlib 0.7.0](../updates.md#070), a host can provide
162
+ `isTargetInternalFile` in `StorageEventManagerBaseDependencies` to admit
163
+ `INTERNAL` events separately from the ordinary `syncOnlyRegEx` allow-list
164
+ and `syncInternalFiles` gate. The host callback determines internal-file
165
+ eligibility within the manager's protected-path checks. For example, it can use
166
+ `vaultService.isTargetFile(path, { internalFileEvent: true })`. Hosts without the
167
+ callback use the ordinary admission path. A rename from a selected path to a
168
+ rejected path becomes a `DELETE` with an old-path deleted stub and the destination
169
+ in `FileEventArgs.renameTarget`.
163
170
  A rename from an excluded path to a selected path becomes a `CREATE`.
164
171
 
165
172
  `renameTarget` is recorded only when one incoming `RENAME` is converted in
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vrtmrz/livesync-commonlib",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
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",
@@ -1021,6 +1021,7 @@
1021
1021
  "@smithy/types": "^4.14.3",
1022
1022
  "@smithy/util-retry": "^4.4.5",
1023
1023
  "@trystero-p2p/nostr": "0.26.0",
1024
+ "@vrtmrz/rpc": "0.1.0",
1024
1025
  "@vrtmrz/value-store": "0.1.0",
1025
1026
  "diff-match-patch": "^1.0.5",
1026
1027
  "events": "^3.3.0",
@@ -1028,7 +1029,7 @@
1028
1029
  "idb": "^8.0.3",
1029
1030
  "markdown-it": "^14.3.3",
1030
1031
  "minimatch": "^11.0.3",
1031
- "octagonal-wheels": "0.1.56",
1032
+ "octagonal-wheels": "0.1.57",
1032
1033
  "pouchdb-adapter-http": "^9.0.0",
1033
1034
  "pouchdb-adapter-idb": "^9.0.0",
1034
1035
  "pouchdb-adapter-indexeddb": "^9.0.0",