@rljson/fs-agent 0.1.0 → 0.2.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/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 # 70 files, 923 scenarios, 100 % coverage, then eslint
23
+ pnpm test # 63 files, 723 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 923 scenarios actually prove, and what they cannot |
31
+ | **deciding whether to trust it** | [README.tests.md](README.tests.md) — what the 723 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
- **Every tree ref changes.** Content identity now fixes a canonical child order
50
- and excludes file modification times. Nothing is destroyed and no data moves,
51
- but the fleet reads divergent until every machine has re-scanned, so upgrade
52
- them together. See
53
- [Rolling Out](README.architecture.md#rolling-out-what-a-peer-can-notice).
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).
@@ -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 removal is **stated** by the
56
- machine that performed it, and a receiver applies what is stated rather than
57
- inferring from what is missing. Every attempt to guess it instead cost data —
58
- see [Known constraints](#known-constraints).
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** | one wins deterministically on every machine, the loser is kept as a renamed copy, and the conflict is reported |
67
- | **Nothing is pruned on a peer's authority** | a tree you receive can add and overwrite; only a stated removal deletes |
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
- // Reconciles two edits to one file and keeps both versions. The host
111
- // application
112
- // sets this; a hub deliberately leaves it off to stay a dumb relay. Off,
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
- // A REQUIREMENT, not a tuning option: the predecessor refs this puts on
128
- // the wire are what let a conflicting edit be merged at all. The agent
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 `resolveConflicts`, `causalOrdering` and `includeClientIdentity` to
152
- `true`, because that is the only mode this package measures end to end. Your own
153
- values still win if you pass them.
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, restoreOptions?)` | receiving — applying what peers announce | a `stop()` |
178
- | `syncToDb(db, connector, treeKey, storageOptions?)` | sending — watching the folder and announcing | a `stop()` |
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
- | `bucketSync` | `true` | Repairs a divergence by comparing manifests and fetching only what is missing, instead of replacing a folder |
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,22 @@ 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 sync cycle. Raise
259
- it on a folder under constant churn, lower it to make a single save feel
260
- immediate. A large catalogue wants a larger `extract` and `restore` than the
261
- defaults.
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
  ### `restoreOptions.cleanTarget` — read this before setting it
264
257
 
265
- `cleanTarget: true` makes `restore()` prune anything not in the tree. **The
266
- sync path ignores it and always applies additively**, because pruning on a
267
- received tree is precisely how an absence becomes a deletion. It is honoured
268
- only by a direct `restore()` call, where *you* are asserting the tree is the
269
- whole truth. Passing it to `syncFromDb` is harmless and has no effect.
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.
270
263
 
271
264
  ---
272
265
 
@@ -325,19 +318,56 @@ matcher.ignores('src/server.log'); // true
325
318
 
326
319
  ---
327
320
 
321
+ ## Knowing what happened to the folder
322
+
323
+ **Start here, and read one thing:** `agent.signalsNeedingAction`. It is the list
324
+ of things this machine could not resolve and will not resolve — a deletion the
325
+ guard refused, a path this filesystem rejects. If it is empty, the folder has
326
+ dealt with everything it met.
327
+
328
+ ```ts
329
+ const agent = await FsAgent.fromClient(folder, 'fileTree', client, socket, {
330
+ onSignal: (signal) => {
331
+ if (signal.action === 'required') alertSomebody(signal.detail);
332
+ },
333
+ });
334
+
335
+ // On start, for whatever happened while this process was not running:
336
+ for (const signal of agent.signalsNeedingAction) alertSomebody(signal.detail);
337
+ ```
338
+
339
+ | | |
340
+ | --- | --- |
341
+ | `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 |
342
+ | `agent.signalsNeedingAction` | only the ones a **person** has to act on |
343
+ | `agent.signalTotals` | how many of each kind ever happened — unbounded, so "and 1 240 more" stays answerable after the list has dropped the oldest |
344
+ | `agent.onSignal(cb)` | subscribe at any time; returns an unsubscribe |
345
+
346
+ Each signal says what happened (`kind`), to what (`paths`, `pathCount`), who
347
+ decided (`decidedBy`), and whether somebody has to act (`action`). Three of the
348
+ seven kinds are `required` — a refused deletion, a directory and a file at one
349
+ path, and an unwritable path — because those wait for a person.
350
+
351
+ **The one to read is `conflict/arbitrary`.** Two machines changed one file at
352
+ once: both versions were kept, and the one that reached the fleet later keeps
353
+ the name. That is the order the hub heard them in, not who edited last — which
354
+ nobody can know without trusting two machines' clocks.
355
+
356
+ The full table of kinds and the field reference are in
357
+ [README.api.md § Signals](README.api.md#signals).
358
+
328
359
  ## Reading what the agent is doing
329
360
 
330
361
  | | |
331
362
  | --- | --- |
332
- | `agent.stageTimings` | milliseconds per stage of the **last** cycle — scan, hash, store, announce, fetch, write, re-derive. A total says a run was slow; this says where |
333
- | `agent.antiEntropyStatus` | whether this machine agrees with the hub, and what it last did about it |
334
- | `agent.refusedDeletions` | deletions the mass-delete guard **refused**, newest last — `{ atMs, route, wouldRemove, held, paths }`. Read this to answer "why did my deletion not arrive": the guard refuses on every machine, so a deliberate mass deletion stalls the whole fleet and the only other trace is a line in each machine's log. Bounded at `REFUSED_DELETION_LOG_MAX`, in memory, and it refills on the next announcement |
363
+ | `agent.stageTimings` | milliseconds per stage of the **last** cycle — scan, announce, fetch, write. A total says a run was slow; this says where |
364
+ | `agent.ownHead` | the chain entry this folder stands on |
365
+ | `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
366
  | `agent.scanner.onChange(cb)` | every filesystem event the scanner accepted |
336
- | `onConflict` | conflicts, as they are resolved |
337
- | `SYNC_ERROR_FILE` | `.sync-errors.log` in the folder: a keyed, append-only record of every refusal and failure — a locked file, an unfetchable blob, an impossible path, a refused mass deletion |
338
- | `.fsagent-conflicts.json` | resolved conflicts, bounded |
367
+ | `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 |
368
+ | `.fsagent-signals.json` | every signal, bounded, plus the per-kind totals that are not |
339
369
  | `.fsagent-recovered/` | files a join kept but deliberately did not announce |
340
- | `.fsagent-state.json` | what this machine remembers across restarts: the state it was last at, the paths it deleted, and **when each path was last edited**. The edit times are what let a peer's tombstone be ordered against the write it claims to supersede — a machine that has forgotten them sends no time, and the comparison has one operand |
370
+ | `.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
371
 
342
372
  All of these live inside the synced folder and all are ignored by the scanner —
343
373
  otherwise the notification would itself be content, propagate, and be rewritten
@@ -387,60 +417,44 @@ rewriting a whole catalogue.
387
417
  - **split a large file into blocks.** A file transfers whole, so the transport's
388
418
  message limit is the per-file ceiling;
389
419
  - **let you approve a mass deletion.** One that looks like a loss is refused
390
- and reported through `agent.refusedDeletions`; there is no override yet;
420
+ and reported as a `deletion/refused` signal marked `required`; there is no
421
+ override yet;
391
422
  - **collect garbage.** Every superseded version stays on every machine;
392
423
  - **promise a latency.** Nothing in the suite asserts an arrival deadline, so
393
424
  nothing here should be read as one;
394
425
  - **repair a folder reverted under a running agent.** Restoring a backup while
395
426
  the agent is stopped is handled; doing it underneath a live one is not
396
427
  decidable from the history, and the reasoning is in the test;
397
- - **promise that a deletion made while the agent was NOT RUNNING propagates.**
398
- **Delete files with the client running.** One deleted while it is stopped may
399
- come back from the history on the next sync.
400
-
401
- This is a deliberate trade, and the reason is worth knowing. A removal is
402
- only ever announced for a file the agent WATCHED being deleted — never for
403
- any file merely missing from the folder. Announcing an absence is the same "an
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.
428
+ - **follow a whole folder disappearing that it did not watch go.** A deletion
429
+ made while the agent was stopped is recorded at the next start like any
430
+ edit — unless it looks like a lost folder: more than the floors (a hundred
431
+ files and 30 % of the folder, or all but ten) gone without the watcher seeing
432
+ it. That is the shape of a failed mount or a wiped drive, never of a person,
433
+ so nothing is recorded and a `deletion/refused` signal asks somebody to
434
+ decide. **Delete large amounts with the client running.**
416
435
 
417
436
  ---
418
437
 
419
438
  ## Troubleshooting
420
439
 
421
- **Nothing syncs and the log says `carries no ancestry`.**
422
- `syncConfig.causalOrdering` is not `true`, so conflicting edits will not be
423
- merged. Set it on the `Connector`.
424
-
425
- **A conflict happened and nobody was told.** `resolveConflicts` defaults to
426
- `false`. Set it `true` and pass `onConflict`.
440
+ **Two versions of one file wait instead of being settled.** Their conflict needs
441
+ the hub's stamp and the hub does not give one: a `repair/blocked` signal says
442
+ so, and both machines keep their own version. Configure the hub with
443
+ `stamp: { domain, hub }`.
427
444
 
428
445
  **An ignore pattern does nothing.** With no `*`, `?` or `/` it is a *prefix*,
429
446
  not a glob: `exe` ignores files starting with `exe`, while `*.exe` is what
430
447
  ignores the extension. Check it with `compileIgnore`.
431
448
 
432
- **A deletion is slow rather than lost.** A removal travels as a statement, and
433
- a walk that cannot complete yet does nothing and waits for the next
434
- announcement. The failure mode is *delayed*, not *silently dropped*, and that
435
- is deliberate.
449
+ **A change arrives late rather than not at all.** A machine that missed an
450
+ announcement catches up the next time the hub says its head — on the state
451
+ beacon, every 30 s in the host client. The failure mode is *delayed*, not
452
+ *silently dropped*.
436
453
 
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.
439
-
440
- **A machine sits empty after its folder was wiped.** Above a hundred files the
441
- agent recognises the loss and re-joins. Between eleven and ninety-nine it
442
- announces the emptiness, the fleet correctly refuses it, and that machine is
443
- not refilled — no data is lost anywhere, but it needs a restart.
454
+ **A whole-folder deletion was refused.** The mass-delete guard, at the machine
455
+ that would have recorded it or at one that would have applied it. A
456
+ `deletion/refused` signal names the count and the threshold. There is no
457
+ override yet.
444
458
 
445
459
  **The first start takes minutes.** A cold scan reads and hashes every file.
446
460
  Pass `scanCachePath`.
@@ -468,30 +482,19 @@ than forever. See [doc/safety-rescan.md](doc/safety-rescan.md).
468
482
  advertised — but no mesh test runs on Windows, so this wants a Windows CI
469
483
  runner.
470
484
 
471
- **An upgrade changes every tree ref in the fleet.** Content identity now
472
- excludes mtime and fixes a canonical child order, so the same bytes hash
473
- differently than in older releases. Nothing is destroyed, but the fleet reads
474
- divergent until every machine has re-scanned. **Upgrade machines together**:
475
- there is no switch for speaking an older wire format, deliberately — a build
476
- that cannot read a chain head cannot read the bucket protocol either, so one
477
- flag would select two different consistency models.
485
+ **Upgrading from 0.0.x changes every ref in the fleet.** 0.2.0 announces chain
486
+ heads only, orders conflicts by the hub's stamp, and keeps no compatibility with
487
+ older wire formats — deliberately: one flag would select two consistency models.
488
+ A machine on 0.2.0 and one on an older release cannot sync. **Upgrade a domain
489
+ together, while it is in sync**, and configure its hubs to stamp; a machine
490
+ whose state file names no head it can read starts as a joiner.
478
491
 
479
492
  **A deliberate mass deletion does not arrive.** Deleting most of a folder is
480
- refused on every machine, and nothing asks the user — see "what it does not do"
481
- above. Read `agent.refusedDeletions` to find out it happened: the guard cannot
482
- tell a person deleting a project from a machine that was wiped telling the fleet
483
- to wipe, and the second one is why the guard exists.
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.
493
+ refused, and nothing asks the user — see "what it does not do" above. Read
494
+ `agent.signalsNeedingAction` to find out it happened: the guard cannot tell a
495
+ person deleting a project from a machine that lost its disk, and the second is
496
+ why the guard exists. A machine that did lose its folder is refilled: the fleet
497
+ keeps the files and records them again on top of the deletion.
495
498
 
496
499
  **A file still being written cannot be recognised with certainty.** The settle
497
500
  rule holds a file back on the first sight of it and for as long as its size keeps
@@ -504,44 +507,17 @@ truncated version until the copy finishes — at which point the size and timest
504
507
  change, the file is re-read, and the complete version propagates. Nothing is
505
508
  corrupted permanently.
506
509
 
507
- **Heavy churn is now gated, and two constraints that stood here are gone.**
508
- Earlier releases of this document listed three things the churn fuzzer found.
509
- What they actually were:
510
-
511
- - **Two machines holding different bytes for one path while both reported
512
- perfect health — FIXED.** A same-path conflict where both sides had edited the
513
- file was settled by whichever content hash sorted higher, because the edit time
514
- carried on the wire was read only when one side had deleted the path. The newer
515
- edit now wins, and both sides compute the same verdict. The fleet converged on
516
- the superseded write about half the time this arose.
517
- - **A re-created file lost from every machine — DID NOT EXIST.** It was an error
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.
510
+ **Two limits of ordering by the hub.** Neither loses data, and both converge.
511
+ A machine that missed an announcement derives a later stamp for the versions it
512
+ carried, so its verdict on a same-file conflict can differ from a peer's; the
513
+ two merges then merge once more, leaving one redundant conflicted copy. And a
514
+ version that passed through a merge carries the merge's stamp, so in a
515
+ three-way race the name can go to a version first edited earlier.
516
+
517
+ **What to watch in production.** `agent.antiEntropyStatus`: `hubRef` is the head
518
+ the hub said last and `localRef` this machine's head now. They differ for a
519
+ moment after every edit; `diverged` for a long time, with `lastRepair.action`
520
+ `blocked`, is the case to look at.
545
521
 
546
522
  ---
547
523
 
@@ -549,9 +525,9 @@ the hub last announced, so the pair can legitimately differ for a moment while
549
525
 
550
526
  | document | what is in it |
551
527
  | --- | --- |
552
- | [README.architecture.md](README.architecture.md) | the design: why references rather than payloads, the edit chain, additive reconciliation, anti-entropy |
528
+ | [README.architecture.md](README.architecture.md) | the design: why references rather than payloads, the edit chain, the conflict table, the stamp, the guards |
553
529
  | [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 810 scenarios this package ships, by what they prove |
530
+ | [README.tests.md](README.tests.md) | the 723 scenarios this package ships, by what they prove |
555
531
 
556
532
  Related packages: `@rljson/rljson` (trees), `@rljson/db` (database and
557
533
  `Connector`), `@rljson/io` (sockets and storage), `@rljson/bs` (blobs),