@rljson/fs-agent 0.1.0 → 0.2.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.
- package/README.api.md +374 -187
- package/README.architecture.md +422 -1372
- package/README.md +8 -7
- package/README.public.md +160 -149
- package/README.tests.md +175 -127
- package/dist/README.api.md +374 -187
- package/dist/README.architecture.md +422 -1372
- package/dist/README.md +8 -7
- package/dist/README.public.md +160 -149
- package/dist/README.tests.md +175 -127
- package/dist/fs-agent.d.ts +436 -1199
- package/dist/fs-agent.js +4952 -6578
- package/dist/fs-atomic-write.d.ts +11 -0
- package/dist/fs-edit-chain.d.ts +53 -267
- package/dist/fs-history.d.ts +83 -0
- package/dist/fs-merge.d.ts +109 -0
- package/dist/fs-receive.d.ts +83 -0
- package/dist/fs-scanner.d.ts +70 -23
- package/dist/fs-send.d.ts +53 -0
- package/dist/fs-signals.d.ts +212 -0
- package/dist/fs-stamps.d.ts +102 -0
- package/dist/fs_agent_version.d.ts +2 -0
- package/dist/index.d.ts +7 -7
- package/package.json +31 -45
- package/dist/fs-anti-entropy.d.ts +0 -404
- package/dist/fs-bucket-sync.d.ts +0 -172
- package/dist/fs-conflict-resolver.d.ts +0 -385
- package/dist/fs-manifest.d.ts +0 -159
package/dist/README.md
CHANGED
|
@@ -20,7 +20,7 @@ decision everything else follows from.
|
|
|
20
20
|
|
|
21
21
|
```bash
|
|
22
22
|
npm install @rljson/fs-agent
|
|
23
|
-
pnpm test #
|
|
23
|
+
pnpm test # 67 files, 771 scenarios, 100 % coverage, then eslint
|
|
24
24
|
```
|
|
25
25
|
|
|
26
26
|
## Where to start
|
|
@@ -28,7 +28,7 @@ pnpm test # 70 files, 923 scenarios, 100 % coverage, then eslint
|
|
|
28
28
|
| if you are | read |
|
|
29
29
|
| --- | --- |
|
|
30
30
|
| **using the package** | [README.public.md](README.public.md) — install, the production configuration, every option and what it costs, troubleshooting |
|
|
31
|
-
| **deciding whether to trust it** | [README.tests.md](README.tests.md) — what the
|
|
31
|
+
| **deciding whether to trust it** | [README.tests.md](README.tests.md) — what the 771 scenarios actually prove, and what they cannot |
|
|
32
32
|
| **changing the sync** | [README.architecture.md](README.architecture.md) — the mechanism, and why each rule exists |
|
|
33
33
|
| **calling the API** | [README.api.md](README.api.md) — every export, grouped by module, with what it costs |
|
|
34
34
|
| **setting the repo up** | [README.contributors.md](README.contributors.md) — run, debug, build, publish |
|
|
@@ -46,8 +46,9 @@ pnpm test # 70 files, 923 scenarios, 100 % coverage, then eslint
|
|
|
46
46
|
|
|
47
47
|
## Before you upgrade an existing fleet
|
|
48
48
|
|
|
49
|
-
**
|
|
50
|
-
and
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
[
|
|
49
|
+
**0.2.0 keeps no compatibility with older releases.** It announces chain heads
|
|
50
|
+
only and orders conflicts by the hub's stamp, so a machine on 0.2.0 and one on
|
|
51
|
+
an older release cannot sync. Upgrade a domain together, while it is in sync,
|
|
52
|
+
and configure its hubs to stamp. See
|
|
53
|
+
[Known constraints](README.public.md#known-constraints) and
|
|
54
|
+
[Removed in 0.2.0](README.architecture.md#removed-in-020).
|
package/dist/README.public.md
CHANGED
|
@@ -22,6 +22,7 @@ machine switched off for a week catches up without replaying the week.
|
|
|
22
22
|
- [Starting and stopping](#starting-and-stopping)
|
|
23
23
|
- [Configuration](#configuration)
|
|
24
24
|
- [Ignore patterns](#ignore-patterns)
|
|
25
|
+
- [Knowing what happened to the folder](#knowing-what-happened-to-the-folder)
|
|
25
26
|
- [Reading what the agent is doing](#reading-what-the-agent-is-doing)
|
|
26
27
|
- [Using it without sync](#using-it-without-sync)
|
|
27
28
|
- [What it guarantees — and what it does not](#what-it-guarantees--and-what-it-does-not)
|
|
@@ -52,10 +53,10 @@ the chain.
|
|
|
52
53
|
|
|
53
54
|
**That is why a deletion works.** An absence is not a deletion. A tree lacks a
|
|
54
55
|
path because the sender removed it, or because the sender never had it, and a
|
|
55
|
-
content hash cannot tell the two apart. So a
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
56
|
+
content hash cannot tell the two apart. So a machine deletes a file for one
|
|
57
|
+
reason only: the edit that lacks it **descends from what this machine holds** —
|
|
58
|
+
its author had the file and chose not to. Anywhere else an absence reaches the
|
|
59
|
+
folder only through a three-way merge, which knows what each side did.
|
|
59
60
|
|
|
60
61
|
Consequences worth knowing before you start:
|
|
61
62
|
|
|
@@ -63,8 +64,8 @@ Consequences worth knowing before you start:
|
|
|
63
64
|
| --- | --- |
|
|
64
65
|
| **A deletion is a fact, not a gap** | so it survives a partition, a restart, and a peer who never heard about it |
|
|
65
66
|
| **A receiver never claims authorship** | so a machine catching up cannot out-order the person who actually typed |
|
|
66
|
-
| **A conflict keeps both versions** |
|
|
67
|
-
| **Nothing is pruned on a peer's authority** |
|
|
67
|
+
| **A conflict keeps both versions** | the version that reached the fleet later keeps the name — by the hub's stamp, never by a clock — the other is kept as a renamed copy, and the conflict is reported |
|
|
68
|
+
| **Nothing is pruned on a peer's authority** | only an edit that descends from this machine's own state can delete anything here |
|
|
68
69
|
| **A joining machine applies the history first** | and a file the history deliberately deleted is moved aside, not resurrected and not destroyed |
|
|
69
70
|
|
|
70
71
|
---
|
|
@@ -107,14 +108,9 @@ await db.core.createTableWithInsertHistory(createTreesTableCfg(treeKey));
|
|
|
107
108
|
const agent = new FsAgent('./my-project', new BsMem(), {
|
|
108
109
|
ignore: ['node_modules', '.git', 'dist', '*.log'],
|
|
109
110
|
|
|
110
|
-
//
|
|
111
|
-
//
|
|
112
|
-
|
|
113
|
-
// a conflicting edit is never merged.
|
|
114
|
-
resolveConflicts: true,
|
|
115
|
-
|
|
116
|
-
// Told, not discovered: where a conflict is reported to a user.
|
|
117
|
-
onConflict: (reports) => console.warn('conflict', reports),
|
|
111
|
+
// Told, not discovered: everything a person might care about, from a
|
|
112
|
+
// conflict to a refused deletion.
|
|
113
|
+
onSignal: (signal) => console.warn(signal.kind, signal.paths),
|
|
118
114
|
|
|
119
115
|
// So a restart does not re-read and re-hash the whole folder.
|
|
120
116
|
scanCachePath: '.cache/fs-agent-scan.json',
|
|
@@ -124,13 +120,17 @@ const agent = new FsAgent('./my-project', new BsMem(), {
|
|
|
124
120
|
const socket = new SocketMock();
|
|
125
121
|
const route = Route.fromFlat(`/${treeKey}`);
|
|
126
122
|
const connector = new Connector(db, route, socket, {
|
|
127
|
-
//
|
|
128
|
-
//
|
|
129
|
-
// warns, once and loudly, if it is missing.
|
|
123
|
+
// `includeClientIdentity` lets the hub tell a machine saying its head
|
|
124
|
+
// again from an echo; `causalOrdering` gives the hub a log to fill gaps from.
|
|
130
125
|
causalOrdering: true,
|
|
131
126
|
includeClientIdentity: true,
|
|
132
127
|
});
|
|
133
128
|
|
|
129
|
+
// The HUB must stamp what it relays — `new Server(route, io, bs,
|
|
130
|
+
// { stamp: { domain, hub } })` in `@rljson/server`. The stamp is what decides
|
|
131
|
+
// which of two versions of one file keeps its name; without it such a
|
|
132
|
+
// conflict waits, both versions kept, and says so as `repair/blocked`.
|
|
133
|
+
|
|
134
134
|
// --- start: RECEIVE FIRST, then push ------------------------------------
|
|
135
135
|
// A machine that announces before it can hear speaks about a state it may be
|
|
136
136
|
// about to replace.
|
|
@@ -148,9 +148,9 @@ agent.dispose();
|
|
|
148
148
|
What the host application does, and **the path that defaults to the
|
|
149
149
|
configuration above**. `fromClient` builds the `Db`, the `Connector` and the
|
|
150
150
|
blob store from an initialised client, adds two convenience wrappers, and
|
|
151
|
-
defaults `
|
|
152
|
-
|
|
153
|
-
|
|
151
|
+
defaults `causalOrdering` and `includeClientIdentity` to `true`, because that is
|
|
152
|
+
the only mode this package measures end to end. Your own values still win if
|
|
153
|
+
you pass them.
|
|
154
154
|
|
|
155
155
|
`new FsAgent(...)` keeps the primitive defaults — it is the building block, and
|
|
156
156
|
the quick start above sets them explicitly for exactly that reason.
|
|
@@ -158,7 +158,6 @@ the quick start above sets them explicitly for exactly that reason.
|
|
|
158
158
|
```typescript
|
|
159
159
|
const agent = await FsAgent.fromClient(folder, treeKey, client, socket, {
|
|
160
160
|
ignore,
|
|
161
|
-
resolveConflicts: true,
|
|
162
161
|
scanCachePath,
|
|
163
162
|
});
|
|
164
163
|
|
|
@@ -174,8 +173,8 @@ Three calls, and they are not interchangeable.
|
|
|
174
173
|
|
|
175
174
|
| call | starts | returns |
|
|
176
175
|
| --- | --- | --- |
|
|
177
|
-
| `syncFromDb(db, connector, treeKey
|
|
178
|
-
| `syncToDb(db, connector, treeKey
|
|
176
|
+
| `syncFromDb(db, connector, treeKey)` | receiving — acting on the heads the network says | a `stop()` |
|
|
177
|
+
| `syncToDb(db, connector, treeKey)` | sending — watching the folder, authoring and announcing | a `stop()` |
|
|
179
178
|
| `dispose()` | — | nothing; **abandons a pending join** |
|
|
180
179
|
|
|
181
180
|
**Start receiving first.** A machine that pushes before it can receive
|
|
@@ -222,12 +221,8 @@ costs.
|
|
|
222
221
|
|
|
223
222
|
| option | default | what it does |
|
|
224
223
|
| --- | --- | --- |
|
|
225
|
-
| `resolveConflicts` | `false` on the constructor, **`true` via `fromClient`** | Reconciles two edits to one file, keeping the loser as a renamed copy. Off, a conflicting edit is never merged — the resolver is not even constructed. The constructor keeps the primitive default because a hub may relay without arbitrating |
|
|
226
|
-
| `onConflict` | — | Called with the conflict reports. Without it a conflict is resolved and nobody is told |
|
|
227
224
|
| `joinWaitMs` | `1500` | How long a folder with files and no history waits for the network before speaking. `0` means "this folder is its own origin" |
|
|
228
|
-
| `
|
|
229
|
-
| `antiEntropy` | `DEFAULT_ANTI_ENTROPY` | The periodic comparison that heals a lost announcement. A machine that is behind **asks**, rather than waiting to be told |
|
|
230
|
-
| `syncConfig` | **`causalOrdering` and `includeClientIdentity` default to `true` via `fromClient`** | Forwarded to every `Connector` the agent builds. Without `causalOrdering` the wire carries no predecessor refs, so no conflicting edit can be merged — the agent warns once, loudly |
|
|
225
|
+
| `syncConfig` | **`causalOrdering` and `includeClientIdentity` default to `true` via `fromClient`** | Forwarded to the `Connector` `fromClient` builds. Without `includeClientIdentity` the hub cannot tell a machine saying its head again from an echo, and holds the re-announcement back |
|
|
231
226
|
| `clientIdentity` | — | Who this machine is, on the wire |
|
|
232
227
|
|
|
233
228
|
### Scanning
|
|
@@ -249,24 +244,25 @@ Every async step is bounded, because an unbounded one is a silent hang.
|
|
|
249
244
|
| `fetchTree` | 20 000 ms |
|
|
250
245
|
| `extract` | 15 000 ms |
|
|
251
246
|
| `restore` | 15 000 ms |
|
|
252
|
-
| `syncCallback` | 25 000 ms |
|
|
253
247
|
| `debounceMs` | 300 ms |
|
|
254
|
-
| `processRefRetries` | 3 |
|
|
255
|
-
| `processRefRetryDelayMs` | 5 000 ms |
|
|
256
|
-
| `recoveryRetries` | 10 |
|
|
257
248
|
|
|
258
|
-
`debounceMs` coalesces a burst of filesystem events into one
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
249
|
+
`debounceMs` coalesces a burst of filesystem events into one edit. Raise it on a
|
|
250
|
+
folder under constant churn, lower it to make a single save feel immediate.
|
|
251
|
+
`restore` bounds every apply: sending and receiving share one lock, so an apply
|
|
252
|
+
waiting on a blob nobody serves would keep this machine from recording its own
|
|
253
|
+
work. A timed-out apply is tried again the next time the hub says its head. A
|
|
254
|
+
large catalogue wants a larger `extract` and `restore` than the defaults.
|
|
262
255
|
|
|
263
|
-
### `
|
|
256
|
+
### `cleanTarget` — read this before setting it
|
|
264
257
|
|
|
265
|
-
`cleanTarget: true` makes `restore()` prune anything not in the tree. **The
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
whole truth
|
|
258
|
+
`cleanTarget: true` makes `restore()` prune anything not in the tree. **The sync
|
|
259
|
+
never uses it**: an apply deletes exactly what an edit descending from this
|
|
260
|
+
machine's state removed, and nothing else. It is honoured only by a direct
|
|
261
|
+
`restore()` or `loadFromDb()` call, where *you* are asserting the tree is the
|
|
262
|
+
whole truth — and by `restoreRevision`, which is that assertion made safely.
|
|
263
|
+
It prunes content only: what the scanner ignores is never deleted, and a prune
|
|
264
|
+
that would take a large part of the folder is refused before anything is
|
|
265
|
+
written.
|
|
270
266
|
|
|
271
267
|
---
|
|
272
268
|
|
|
@@ -325,19 +321,87 @@ matcher.ignores('src/server.log'); // true
|
|
|
325
321
|
|
|
326
322
|
---
|
|
327
323
|
|
|
324
|
+
## Knowing what happened to the folder
|
|
325
|
+
|
|
326
|
+
**Start here, and read one thing:** `agent.signalsNeedingAction`. It is the list
|
|
327
|
+
of things this machine could not resolve and will not resolve — a deletion the
|
|
328
|
+
guard refused, a path this filesystem rejects. If it is empty, the folder has
|
|
329
|
+
dealt with everything it met.
|
|
330
|
+
|
|
331
|
+
```ts
|
|
332
|
+
const agent = await FsAgent.fromClient(folder, 'fileTree', client, socket, {
|
|
333
|
+
onSignal: (signal) => {
|
|
334
|
+
if (signal.action === 'required') alertSomebody(signal.detail);
|
|
335
|
+
},
|
|
336
|
+
});
|
|
337
|
+
|
|
338
|
+
// On start, for whatever happened while this process was not running:
|
|
339
|
+
for (const signal of agent.signalsNeedingAction) alertSomebody(signal.detail);
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
| | |
|
|
343
|
+
| --- | --- |
|
|
344
|
+
| `agent.signals` | everything that happened to this folder worth telling somebody, oldest first. Survives a restart: it is read back from `.fsagent-signals.json` the first time you ask |
|
|
345
|
+
| `agent.signalsNeedingAction` | only the ones a **person** has to act on |
|
|
346
|
+
| `agent.signalTotals` | how many of each kind ever happened — unbounded, so "and 1 240 more" stays answerable after the list has dropped the oldest |
|
|
347
|
+
| `agent.onSignal(cb)` | subscribe at any time; returns an unsubscribe |
|
|
348
|
+
|
|
349
|
+
Each signal says what happened (`kind`), to what (`paths`, `pathCount`), who
|
|
350
|
+
decided (`decidedBy`), and whether somebody has to act (`action`). Three of the
|
|
351
|
+
seven kinds are `required` — a refused deletion, a directory and a file at one
|
|
352
|
+
path, and an unwritable path — because those wait for a person.
|
|
353
|
+
|
|
354
|
+
**The one to read is `conflict/arbitrary`.** Two machines changed one file at
|
|
355
|
+
once: both versions were kept, and the one that reached the fleet later keeps
|
|
356
|
+
the name. That is the order the hub heard them in, not who edited last — which
|
|
357
|
+
nobody can know without trusting two machines' clocks.
|
|
358
|
+
|
|
359
|
+
Every signal has an `id`, derived from what it says and the same on every
|
|
360
|
+
read, so a UI can key a row by it. A merge conflict names the merge (`head`);
|
|
361
|
+
a join names where each file it moved went (`copies`).
|
|
362
|
+
|
|
363
|
+
The full table of kinds and the field reference are in
|
|
364
|
+
[README.api.md § Signals](README.api.md#signals).
|
|
365
|
+
|
|
366
|
+
## Showing the history, and going back
|
|
367
|
+
|
|
368
|
+
```ts
|
|
369
|
+
const head = await agent.headInfo(); // where the folder stands, with its stamp
|
|
370
|
+
const page = await agent.history({ limit: 50 }); // newest first
|
|
371
|
+
const next = await agent.history({ cursor: page.cursor });
|
|
372
|
+
const relation = await agent.relationTo(hubHead); // same, behind, ahead, fork
|
|
373
|
+
|
|
374
|
+
await agent.restoreRevision(page.entries[3].head); // 'restored' | 'unknown' | 'busy'
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
**The history is the edit chain**, the same order on every node: every edit,
|
|
378
|
+
every merge with both of its parents, whichever machine made it. An entry says
|
|
379
|
+
what it changed and removed, when its author made it, and — once the hub said
|
|
380
|
+
it back — its stamp. A host whose agent runs in another process reads the same
|
|
381
|
+
pages from the store with `readFsHistory(db, treeKey, { from })`, which writes
|
|
382
|
+
nothing.
|
|
383
|
+
|
|
384
|
+
**Going back makes the folder exactly that revision**, deleting what it lacks,
|
|
385
|
+
and records the result as a new edit that every machine follows. Nothing is
|
|
386
|
+
lost: work not yet recorded is recorded first, the revision being left stays
|
|
387
|
+
in the history, and a file still being written is waited out (`busy` when it
|
|
388
|
+
does not finish). A revision that would delete a large part of the folder is
|
|
389
|
+
refused with a `MassDeleteRefusedError`, before anything is written.
|
|
390
|
+
|
|
391
|
+
Details in [README.api.md § The history](README.api.md#the-history).
|
|
392
|
+
|
|
328
393
|
## Reading what the agent is doing
|
|
329
394
|
|
|
330
395
|
| | |
|
|
331
396
|
| --- | --- |
|
|
332
|
-
| `agent.stageTimings` | milliseconds per stage of the **last** cycle — scan,
|
|
333
|
-
| `agent.
|
|
334
|
-
| `agent.
|
|
397
|
+
| `agent.stageTimings` | milliseconds per stage of the **last** cycle — scan, announce, fetch, write. A total says a run was slow; this says where |
|
|
398
|
+
| `agent.ownHead` | the chain entry this folder stands on |
|
|
399
|
+
| `agent.antiEntropyStatus` | what the last head the hub said made this machine do — `diverged`, since when, and the last action (`pull`, `push`, `merge` or `blocked`) |
|
|
335
400
|
| `agent.scanner.onChange(cb)` | every filesystem event the scanner accepted |
|
|
336
|
-
| `
|
|
337
|
-
|
|
|
338
|
-
| `.fsagent-conflicts.json` | resolved conflicts, bounded |
|
|
401
|
+
| `SYNC_ERROR_FILE` | `.sync-errors.log` in the folder: a keyed, append-only record of internal failures — a locked file, an unfetchable blob, an impossible path. A refused mass deletion is a signal, not an error |
|
|
402
|
+
| `.fsagent-signals.json` | every signal, bounded, plus the per-kind totals that are not |
|
|
339
403
|
| `.fsagent-recovered/` | files a join kept but deliberately did not announce |
|
|
340
|
-
| `.fsagent-state.json` | what this machine remembers across restarts: the
|
|
404
|
+
| `.fsagent-state.json` | what this machine remembers across restarts: the chain entry it stands on, and the highest stamp epoch it has heard — which a hub taking office on this machine continues above (`minEpoch`) |
|
|
341
405
|
|
|
342
406
|
All of these live inside the synced folder and all are ignored by the scanner —
|
|
343
407
|
otherwise the notification would itself be content, propagate, and be rewritten
|
|
@@ -358,7 +422,8 @@ const tree = await agent.extract();
|
|
|
358
422
|
// Tree -> folder, additively
|
|
359
423
|
await agent.restore(tree, './elsewhere');
|
|
360
424
|
|
|
361
|
-
// Tree -> folder, exactly: prune anything not in the tree
|
|
425
|
+
// Tree -> folder, exactly: prune anything not in the tree that the scanner
|
|
426
|
+
// would see
|
|
362
427
|
await agent.restore(tree, './elsewhere', { cleanTarget: true });
|
|
363
428
|
```
|
|
364
429
|
|
|
@@ -387,60 +452,44 @@ rewriting a whole catalogue.
|
|
|
387
452
|
- **split a large file into blocks.** A file transfers whole, so the transport's
|
|
388
453
|
message limit is the per-file ceiling;
|
|
389
454
|
- **let you approve a mass deletion.** One that looks like a loss is refused
|
|
390
|
-
and reported
|
|
455
|
+
and reported as a `deletion/refused` signal marked `required`; there is no
|
|
456
|
+
override yet;
|
|
391
457
|
- **collect garbage.** Every superseded version stays on every machine;
|
|
392
458
|
- **promise a latency.** Nothing in the suite asserts an arrival deadline, so
|
|
393
459
|
nothing here should be read as one;
|
|
394
460
|
- **repair a folder reverted under a running agent.** Restoring a backup while
|
|
395
461
|
the agent is stopped is handled; doing it underneath a live one is not
|
|
396
462
|
decidable from the history, and the reasoning is in the test;
|
|
397
|
-
- **
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
absence is a deletion" inference the edit chain exists to remove, just moved
|
|
405
|
-
to the sending side, and the chain would then carry that guess as a stated,
|
|
406
|
-
ordered, authoritative removal that every peer obeys — correctly, because
|
|
407
|
-
obeying a stated removal is the whole design. A node whose idea of its own
|
|
408
|
-
last state had drifted could tell the entire fleet to delete files nobody had
|
|
409
|
-
touched.
|
|
410
|
-
|
|
411
|
-
So the asymmetry is chosen on purpose: a file that comes back is visible and
|
|
412
|
-
recoverable — delete it again with the client running and it propagates
|
|
413
|
-
properly — while a file deleted across every machine on a mistaken statement
|
|
414
|
-
is neither. In practice the offline case is often still caught, but it is not
|
|
415
|
-
promised here, and nothing in this package should be read as promising it.
|
|
463
|
+
- **follow a whole folder disappearing that it did not watch go.** A deletion
|
|
464
|
+
made while the agent was stopped is recorded at the next start like any
|
|
465
|
+
edit — unless it looks like a lost folder: more than the floors (a hundred
|
|
466
|
+
files and 30 % of the folder, or all but ten) gone without the watcher seeing
|
|
467
|
+
it. That is the shape of a failed mount or a wiped drive, never of a person,
|
|
468
|
+
so nothing is recorded and a `deletion/refused` signal asks somebody to
|
|
469
|
+
decide. **Delete large amounts with the client running.**
|
|
416
470
|
|
|
417
471
|
---
|
|
418
472
|
|
|
419
473
|
## Troubleshooting
|
|
420
474
|
|
|
421
|
-
**
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
**A conflict happened and nobody was told.** `resolveConflicts` defaults to
|
|
426
|
-
`false`. Set it `true` and pass `onConflict`.
|
|
475
|
+
**Two versions of one file wait instead of being settled.** Their conflict needs
|
|
476
|
+
the hub's stamp and the hub does not give one: a `repair/blocked` signal says
|
|
477
|
+
so, and both machines keep their own version. Configure the hub with
|
|
478
|
+
`stamp: { domain, hub }`.
|
|
427
479
|
|
|
428
480
|
**An ignore pattern does nothing.** With no `*`, `?` or `/` it is a *prefix*,
|
|
429
481
|
not a glob: `exe` ignores files starting with `exe`, while `*.exe` is what
|
|
430
482
|
ignores the extension. Check it with `compileIgnore`.
|
|
431
483
|
|
|
432
|
-
**A
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
**A whole-folder deletion was refused.** The mass-delete guard.
|
|
438
|
-
`.sync-errors.log` names the count and the threshold. There is no override yet.
|
|
484
|
+
**A change arrives late rather than not at all.** A machine that missed an
|
|
485
|
+
announcement catches up the next time the hub says its head — on the state
|
|
486
|
+
beacon, every 30 s in the host client. The failure mode is *delayed*, not
|
|
487
|
+
*silently dropped*.
|
|
439
488
|
|
|
440
|
-
**A
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
489
|
+
**A whole-folder deletion was refused.** The mass-delete guard, at the machine
|
|
490
|
+
that would have recorded it or at one that would have applied it. A
|
|
491
|
+
`deletion/refused` signal names the count and the threshold. There is no
|
|
492
|
+
override yet.
|
|
444
493
|
|
|
445
494
|
**The first start takes minutes.** A cold scan reads and hashes every file.
|
|
446
495
|
Pass `scanCachePath`.
|
|
@@ -468,30 +517,19 @@ than forever. See [doc/safety-rescan.md](doc/safety-rescan.md).
|
|
|
468
517
|
advertised — but no mesh test runs on Windows, so this wants a Windows CI
|
|
469
518
|
runner.
|
|
470
519
|
|
|
471
|
-
**
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
flag would select two different consistency models.
|
|
520
|
+
**Upgrading from 0.0.x changes every ref in the fleet.** 0.2.0 announces chain
|
|
521
|
+
heads only, orders conflicts by the hub's stamp, and keeps no compatibility with
|
|
522
|
+
older wire formats — deliberately: one flag would select two consistency models.
|
|
523
|
+
A machine on 0.2.0 and one on an older release cannot sync. **Upgrade a domain
|
|
524
|
+
together, while it is in sync**, and configure its hubs to stamp; a machine
|
|
525
|
+
whose state file names no head it can read starts as a joiner.
|
|
478
526
|
|
|
479
527
|
**A deliberate mass deletion does not arrive.** Deleting most of a folder is
|
|
480
|
-
refused
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
**On Linux, deleting a whole directory may leave its files behind.** `rm -r`
|
|
486
|
-
unlinks the children and then the directory; when the watched directory goes,
|
|
487
|
-
inotify removes its watch and the queued child events are lost. A removal is
|
|
488
|
-
only stated for a deletion the agent **watched** — an absence is not a deletion,
|
|
489
|
-
which is what stops a folder that failed to mount from wiping the fleet — so an
|
|
490
|
-
unobserved child is not merely unpropagated: a peer still holding it announces
|
|
491
|
-
it back and the folder is restored. Measured on Linux CI across four runs, a
|
|
492
|
-
different subset surviving each time. macOS reports every child deletion and is
|
|
493
|
-
unaffected. Deleting the files individually, or deleting the directory a second
|
|
494
|
-
time, propagates normally.
|
|
528
|
+
refused, and nothing asks the user — see "what it does not do" above. Read
|
|
529
|
+
`agent.signalsNeedingAction` to find out it happened: the guard cannot tell a
|
|
530
|
+
person deleting a project from a machine that lost its disk, and the second is
|
|
531
|
+
why the guard exists. A machine that did lose its folder is refilled: the fleet
|
|
532
|
+
keeps the files and records them again on top of the deletion.
|
|
495
533
|
|
|
496
534
|
**A file still being written cannot be recognised with certainty.** The settle
|
|
497
535
|
rule holds a file back on the first sight of it and for as long as its size keeps
|
|
@@ -504,44 +542,17 @@ truncated version until the copy finishes — at which point the size and timest
|
|
|
504
542
|
change, the file is re-read, and the complete version propagates. Nothing is
|
|
505
543
|
corrupted permanently.
|
|
506
544
|
|
|
507
|
-
**
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
in the test's own instrument. The count of entries in a node's tree used a
|
|
519
|
-
field the tree nodes do not have, so it counted every directory and the folder
|
|
520
|
-
root as files: `6 entries` beside `4 files on disk` was four files, one
|
|
521
|
-
subdirectory and the root, exactly consistent. Nothing was ever lost. The
|
|
522
|
-
measurement that appeared to confirm it on older code was the same miscount.
|
|
523
|
-
- **A machine finishing one file short — FIXED, and it was never rare.** This was
|
|
524
|
-
written down as a limit while the test read the fleet's convergence verdict and
|
|
525
|
-
threw it away, so nothing had ever gated it. Asserting it exposed the cause at
|
|
526
|
-
once: a node that deletes a file keeps a tombstone until it has announced it,
|
|
527
|
-
and that tombstone was allowed to refuse a peer's LATER write of the same path
|
|
528
|
-
— although the comparison had already established the write was newer. The
|
|
529
|
-
deleting node stayed permanently short of a file every peer held, still
|
|
530
|
-
advertising a deletion the fleet had moved past, with nothing to end it. On
|
|
531
|
-
Linux, 6 runs in 8 of one churn scenario. The stale tombstone is now lifted,
|
|
532
|
-
and the node says so in its log when it happens.
|
|
533
|
-
|
|
534
|
-
So the churn scenarios are a real gate: every node ends with the same files and
|
|
535
|
-
the same bytes, and any disagreement must at least be visible in some node's
|
|
536
|
-
`diverged` or `differingPaths`. A run that ends disagreeing says so in the test
|
|
537
|
-
output rather than passing quietly. Measured 8 of 8 on Linux where the same
|
|
538
|
-
scenario failed 6 of 8 before these two fixes.
|
|
539
|
-
|
|
540
|
-
**What to watch in production.** `agent.antiEntropyStatus.differingPaths` names
|
|
541
|
-
the paths rather than reporting that the checksums differ, so it is the more
|
|
542
|
-
useful of the two. `localRef` is this node's state right now and `hubRef` is what
|
|
543
|
-
the hub last announced, so the pair can legitimately differ for a moment while
|
|
544
|
-
`diverged` still reports the previous comparison's verdict.
|
|
545
|
+
**Two limits of ordering by the hub.** Neither loses data, and both converge.
|
|
546
|
+
A machine that missed an announcement derives a later stamp for the versions it
|
|
547
|
+
carried, so its verdict on a same-file conflict can differ from a peer's; the
|
|
548
|
+
two merges then merge once more, leaving one redundant conflicted copy. And a
|
|
549
|
+
version that passed through a merge carries the merge's stamp, so in a
|
|
550
|
+
three-way race the name can go to a version first edited earlier.
|
|
551
|
+
|
|
552
|
+
**What to watch in production.** `agent.antiEntropyStatus`: `hubRef` is the head
|
|
553
|
+
the hub said last and `localRef` this machine's head now. They differ for a
|
|
554
|
+
moment after every edit; `diverged` for a long time, with `lastRepair.action`
|
|
555
|
+
`blocked`, is the case to look at.
|
|
545
556
|
|
|
546
557
|
---
|
|
547
558
|
|
|
@@ -549,9 +560,9 @@ the hub last announced, so the pair can legitimately differ for a moment while
|
|
|
549
560
|
|
|
550
561
|
| document | what is in it |
|
|
551
562
|
| --- | --- |
|
|
552
|
-
| [README.architecture.md](README.architecture.md) | the design: why references rather than payloads, the edit chain,
|
|
563
|
+
| [README.architecture.md](README.architecture.md) | the design: why references rather than payloads, the edit chain, the conflict table, the stamp, the guards |
|
|
553
564
|
| [README.api.md](README.api.md) | every export, grouped by module — the shape, where this document gives the advice |
|
|
554
|
-
| [README.tests.md](README.tests.md) | the
|
|
565
|
+
| [README.tests.md](README.tests.md) | the 771 scenarios this package ships, by what they prove |
|
|
555
566
|
|
|
556
567
|
Related packages: `@rljson/rljson` (trees), `@rljson/db` (database and
|
|
557
568
|
`Connector`), `@rljson/io` (sockets and storage), `@rljson/bs` (blobs),
|