@vrtmrz/livesync-commonlib 0.6.1 → 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.
- package/README.md +29 -19
- package/dist/common/models/shared.definition.d.ts +10 -1
- package/dist/common/models/shared.definition.js +4 -3
- package/dist/events/coreEvents.d.ts +3 -0
- package/dist/events/coreEvents.js +2 -0
- package/dist/managers/EntryManager/EntryManager.d.ts +1 -1
- package/dist/managers/EntryManager/EntryManager.js +2 -2
- package/dist/managers/EntryManager/EntryManagerImpls.d.ts +1 -1
- package/dist/managers/EntryManager/EntryManagerImpls.js +4 -4
- package/dist/managers/StorageEventManager/admission.d.ts +1 -0
- package/dist/managers/StorageEventManager/admission.js +5 -1
- package/dist/managers/StorageEventManager.d.ts +2 -0
- package/dist/managers/StorageEventManager.js +1 -0
- package/dist/pouchdb/LiveSyncLocalDB.d.ts +1 -1
- package/dist/pouchdb/LiveSyncLocalDB.js +2 -2
- package/dist/replication/LiveSyncAbstractReplicator.d.ts +7 -0
- package/dist/replication/LiveSyncAbstractReplicator.js +5 -2
- package/dist/replication/ReplicatorInstance.d.ts +3 -0
- package/dist/replication/ReplicatorProvider.d.ts +23 -2
- package/dist/replication/ReplicatorProvider.js +10 -0
- package/dist/replication/SyncParamsHandler.js +26 -25
- package/dist/replication/couchdb/LiveSyncReplicator.d.ts +14 -2
- package/dist/replication/couchdb/LiveSyncReplicator.js +247 -122
- package/dist/replication/index.d.ts +4 -2
- package/dist/replication/index.js +6 -0
- package/dist/replication/remoteTransportFailure.d.ts +24 -0
- package/dist/replication/remoteTransportFailure.js +80 -0
- package/dist/replication/trystero/TrysteroReplicatorP2PServer.d.ts +1 -1
- package/dist/replication/trystero/TrysteroReplicatorP2PServer.js +2 -2
- package/dist/replication/trystero/TrysteroRpcRoom.d.ts +14 -0
- package/dist/replication/trystero/TrysteroRpcRoom.js +168 -0
- package/dist/replication/trystero/rpcCompat.d.ts +1 -0
- package/dist/replication/trystero/rpcCompat.js +15 -0
- package/dist/rpc/RpcRoom.d.ts +1 -0
- package/dist/rpc/RpcRoom.js +21 -9
- package/dist/rpc/RpcSession.d.ts +8 -13
- package/dist/rpc/RpcSession.js +14 -35
- package/dist/rpc/commonlibRpcRoom.d.ts +1 -0
- package/dist/rpc/commonlibRpcRoom.js +4 -0
- package/dist/rpc/errors.d.ts +9 -3
- package/dist/rpc/errors.js +13 -16
- package/dist/rpc/index.d.ts +10 -1
- package/dist/rpc/index.js +2 -1
- package/dist/rpc/pouchdb/RpcPouchDBProxy.d.ts +1 -1
- package/dist/rpc/pouchdb/RpcPouchDBServer.d.ts +1 -1
- package/dist/serviceFeatures/targetFilter.d.ts +3 -1
- package/dist/serviceFeatures/targetFilter.js +2 -2
- package/dist/services/base/IService.d.ts +9 -6
- package/dist/services/base/ReadinessEvaluator.d.ts +7 -6
- package/dist/services/base/ReadinessEvaluator.js +4 -2
- package/dist/services/base/RemoteConnection.d.ts +4 -0
- package/dist/services/base/RemoteService.d.ts +5 -3
- package/dist/services/base/RemoteService.js +85 -33
- package/dist/services/base/ReplicationService.d.ts +10 -2
- package/dist/services/base/ReplicationService.js +13 -7
- package/dist/services/base/ReplicationService.readiness.d.ts +14 -4
- package/dist/services/base/ReplicationService.readiness.js +29 -2
- package/dist/services/base/ReplicationService.typedReplication.d.ts +5 -2
- package/dist/services/base/ReplicationService.typedReplication.js +67 -6
- package/dist/services/base/ReplicationStaticsOwner.d.ts +18 -0
- package/dist/services/base/ReplicationStaticsOwner.js +33 -0
- package/dist/services/base/ReplicatorService.d.ts +2 -10
- package/dist/services/base/ReplicatorService.js +6 -3
- package/dist/services/base/VaultService.d.ts +1 -0
- package/dist/string_and_binary/chunks.d.ts +1 -1
- package/dist/string_and_binary/chunks.js +63 -50
- package/dist/worker/bg.worker.js +3 -1
- package/dist/worker/bg.worker.splitting.d.ts +1 -0
- package/dist/worker/bg.worker.splitting.js +42 -6
- package/dist/worker/bgWorker.d.ts +4 -0
- package/dist/worker/bgWorker.js +87 -57
- package/dist/worker/bgWorker.splitting.d.ts +2 -3
- package/dist/worker/bgWorker.splitting.js +48 -52
- package/dist/worker/universalTypes.d.ts +13 -1
- package/docs/development.md +69 -32
- package/docs/p2p-transport-lifecycle.md +2 -3
- package/docs/storage-events-and-reflection.md +10 -3
- 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
|
|
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:
|
|
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 ${
|
|
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
|
-
|
|
56
|
-
|
|
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
|
-
|
|
64
|
-
|
|
65
|
-
|
|
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
|
-
|
|
77
|
-
const
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
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
|
-
|
|
109
|
-
|
|
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
|
|
68
|
+
export type SplitErrorPayload = ResultPayloadBase & {
|
|
69
|
+
error: {
|
|
70
|
+
name: string;
|
|
71
|
+
message: string;
|
|
72
|
+
stack?: string;
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
export type ResultPayloadWithSeq = ResultPayloadPiece | SplitErrorPayload;
|
package/docs/development.md
CHANGED
|
@@ -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
|
|
50
|
-
|
|
|
51
|
-
| `context.ts`, `storage.ts`
|
|
52
|
-
| `locking.ts`
|
|
53
|
-
| `provenance.ts`, `scanning.ts`
|
|
54
|
-
| `saving.ts`
|
|
55
|
-
| `deletion.ts`, `renaming.ts`
|
|
56
|
-
| `deletionRecovery.ts`
|
|
57
|
-
| `reflection.ts`, `protection.ts` | Reflect database revisions while protecting unsynchronised storage content.
|
|
58
|
-
| `events.ts`, `selection.ts`
|
|
59
|
-
| `chunks.ts`
|
|
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`
|
|
88
|
-
| `peerAgreement.ts`
|
|
89
|
-
| `configurationExchange.ts`
|
|
90
|
-
| `progress.ts`
|
|
91
|
-
| `configuredTargets.ts`
|
|
92
|
-
| `transfers.ts`
|
|
93
|
-
| `relayControl.ts`
|
|
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`.
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
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
|
|
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
|
|
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.
|
|
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
|
|
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
|
|
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
|
|
@@ -128,9 +128,8 @@ persistent replication state is added.
|
|
|
128
128
|
|
|
129
129
|
## Best-effort change notifications
|
|
130
130
|
|
|
131
|
-
|
|
132
|
-
Commonlib 0.4.3 and Self-hosted LiveSync 1.0.49.
|
|
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
|
|
@@ -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.
|
|
161
|
-
|
|
162
|
-
|
|
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.
|
|
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.
|
|
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",
|