@rljson/fs-agent 0.2.2 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.api.md +12 -4
- package/README.architecture.md +48 -1
- package/README.md +2 -2
- package/README.public.md +30 -4
- package/README.tests.md +28 -6
- package/dist/README.api.md +12 -4
- package/dist/README.architecture.md +48 -1
- package/dist/README.md +2 -2
- package/dist/README.public.md +30 -4
- package/dist/README.tests.md +28 -6
- package/dist/fs-agent.d.ts +105 -5
- package/dist/fs-agent.js +607 -175
- package/dist/fs-carry.d.ts +40 -0
- package/dist/fs-ignore.d.ts +9 -0
- package/dist/fs-scanner.d.ts +12 -1
- package/dist/fs_agent_version.d.ts +1 -1
- package/package.json +7 -7
package/README.api.md
CHANGED
|
@@ -378,6 +378,9 @@ Scans and watches a folder. `scan()` reads it into an `FsTree`; `scanFresh()`
|
|
|
378
378
|
returns a pass that started after the call, sharing one with anyone else asking
|
|
379
379
|
meanwhile — what a caller that acts on the folder must use. `watch()`,
|
|
380
380
|
`stopWatch()`, `pauseWatch()`, `onChange(cb)`, `knownFile(path)`.
|
|
381
|
+
`ignore` is the list it applies; `ignores(path, isDirectory?)` and
|
|
382
|
+
`excludes(path, isDirectory)` answer for one path, as
|
|
383
|
+
[`IgnoreMatcher`](#interface-ignorematcher) does.
|
|
381
384
|
|
|
382
385
|
### `interface FsScanOptions`
|
|
383
386
|
|
|
@@ -465,8 +468,8 @@ ignores.
|
|
|
465
468
|
|
|
466
469
|
Compiles ignore patterns into a matcher once: globs (`*`, `?`, `**`, folders
|
|
467
470
|
with `/`, `!` exceptions with last-match-wins), case-insensitive. A pattern with
|
|
468
|
-
no glob characters keeps its old prefix meaning
|
|
469
|
-
`ATOMIC_TMP_PREFIX` depend on it.
|
|
471
|
+
no glob characters keeps its old prefix meaning, case-sensitive as before —
|
|
472
|
+
`~$`, `.~lock.` and `ATOMIC_TMP_PREFIX` depend on it.
|
|
470
473
|
|
|
471
474
|
### `globToRegExp(pattern)`
|
|
472
475
|
|
|
@@ -474,8 +477,13 @@ One glob as a regular expression.
|
|
|
474
477
|
|
|
475
478
|
### `interface IgnoreMatcher`
|
|
476
479
|
|
|
477
|
-
`{ ignores(relativePath, isDirectory?)
|
|
478
|
-
|
|
480
|
+
`{ ignores(relativePath, isDirectory?), excludes(relativePath, isDirectory) }`.
|
|
481
|
+
|
|
482
|
+
- `ignores` — what the list says about the path itself. Pass `isDirectory`
|
|
483
|
+
when known, because a directory-only pattern needs it.
|
|
484
|
+
- `excludes` — whether a scan leaves the path out: the path, or a directory
|
|
485
|
+
above it. A scan does not descend into an ignored directory, so a path
|
|
486
|
+
below one is excluded even where an `!` line would rescue it.
|
|
479
487
|
|
|
480
488
|
---
|
|
481
489
|
|
package/README.architecture.md
CHANGED
|
@@ -68,6 +68,7 @@ hang and an unbounded list is tomorrow's memory ceiling.
|
|
|
68
68
|
| what a host application is told | [One channel for everything](#one-channel-for-everything-that-happened-srcfs-signalsts) |
|
|
69
69
|
| why a half-written file does not go out | [A Copy in Progress](#a-copy-in-progress-does-not-reach-the-wire-fsscanner-the-settle-rule) |
|
|
70
70
|
| which files are skipped | [Ignore Matching](#ignore-matching-srcfs-ignorets) |
|
|
71
|
+
| what a node does with paths it ignores | [Carrying what a node does not see](#carrying-what-a-node-does-not-see-srcfs-carryts) |
|
|
71
72
|
| what 0.2.0 removed | [Removed in 0.2.0](#removed-in-020) |
|
|
72
73
|
| the signature of anything named here | [README.api.md](README.api.md) |
|
|
73
74
|
|
|
@@ -779,10 +780,56 @@ fire — a defect this package has already had.
|
|
|
779
780
|
The matcher is compiled once per agent, because a scan of a real catalogue asks
|
|
780
781
|
this question once per file.
|
|
781
782
|
|
|
782
|
-
**Tested by** `test/fs-ignore.spec.ts` (
|
|
783
|
+
**Tested by** `test/fs-ignore.spec.ts` (32), whose first block is one case per
|
|
783
784
|
pattern that appears in the shipped configuration or in the agent's own list —
|
|
784
785
|
that being the half which can break a running fleet.
|
|
785
786
|
|
|
787
|
+
## Carrying what a node does not see (`src/fs-carry.ts`)
|
|
788
|
+
|
|
789
|
+
Every node has its own ignore list, and a tree does not say which list made
|
|
790
|
+
it. An edit authored from the scan alone leaves out every path its author
|
|
791
|
+
ignores, and the chain reads a missing path as a deletion. Measured with one
|
|
792
|
+
pattern added on one node of three: that node authored nothing ever again — a
|
|
793
|
+
removal waits until the scan agrees the file is gone, and a scan that ignores
|
|
794
|
+
the file never does — and incoming trees were written into the paths it
|
|
795
|
+
ignored. A node whose head did not name the files yet deleted them everywhere
|
|
796
|
+
with its next edit.
|
|
797
|
+
|
|
798
|
+
So a node never touches a path it ignores:
|
|
799
|
+
|
|
800
|
+
- **Authoring** grafts onto the scan what the own head holds at those paths
|
|
801
|
+
(`graftTree`). The graft is the tree the scanner builds for a folder that
|
|
802
|
+
holds them, node for node and ref for ref — a test scans a folder twice,
|
|
803
|
+
once with a narrower list, and the graft of the difference gives the full
|
|
804
|
+
scan's root hash.
|
|
805
|
+
- **Applying** neither writes nor deletes there, and the guard counts only what
|
|
806
|
+
the folder holds (`_applyContent`).
|
|
807
|
+
- **Merging** carries the version the merge kept, from whichever side; a copy a
|
|
808
|
+
conflict made at such a path is written and carried (`_mergeCarried`).
|
|
809
|
+
- **Restoring** into the own folder skips those paths, and never removes an
|
|
810
|
+
entry the node ignores to make room for one of another kind (`_makeRoomFor`):
|
|
811
|
+
that path is reported as unwritable instead.
|
|
812
|
+
|
|
813
|
+
`_carried` holds the own head's nodes at those paths. It is recomputed from the
|
|
814
|
+
head's tree whenever the head changes (`carriedNodes`, which walks the tree as
|
|
815
|
+
the scanner walks the folder), and it is empty while the lists agree — then
|
|
816
|
+
every tree is the scan's own and nothing above changes.
|
|
817
|
+
|
|
818
|
+
**A pattern removed** makes the node see paths it never wrote. Authored as they
|
|
819
|
+
stand, a file it never received would be deleted everywhere and a version of
|
|
820
|
+
its own would overwrite the network's. So the state file records the list the
|
|
821
|
+
folder is in step with, and a restart with another list joins those paths
|
|
822
|
+
(`_uncover`, with `planJoin`): a version of its own goes aside as a conflicted
|
|
823
|
+
copy, one the history removed goes to `.fsagent-recovered/`, and the head's
|
|
824
|
+
version is fetched with every head the node hears (`_takeUncovered`) and
|
|
825
|
+
carried until it is in the folder. The record moves to the new list once
|
|
826
|
+
nothing is missing, so a restart in between takes it up again.
|
|
827
|
+
|
|
828
|
+
**Tested by** `test/fs-carry.spec.ts` (10), `test/fs-agent-ignored-paths.spec.ts`
|
|
829
|
+
and `test/mesh/fs-mesh-ignore-lists.spec.ts` (5): a pattern added on one node,
|
|
830
|
+
different lists from the start, a pattern removed, removed while offline, and a
|
|
831
|
+
merge — every one of which fails on 0.2.2.
|
|
832
|
+
|
|
786
833
|
## Removed in 0.2.0
|
|
787
834
|
|
|
788
835
|
No compatibility with 0.1.x: every mechanism that existed to tolerate, migrate
|
package/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 # 70 files, 807 scenarios, 100 % coverage, then eslint
|
|
24
24
|
```
|
|
25
25
|
|
|
26
26
|
## Where to start
|
|
@@ -28,7 +28,7 @@ pnpm test # 67 files, 776 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 807 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 |
|
package/README.public.md
CHANGED
|
@@ -277,7 +277,7 @@ the path and the pattern.
|
|
|
277
277
|
| `?` | one character within one segment |
|
|
278
278
|
| `**` | crosses separators. A leading `**/` also matches at the root, so `**/tmp` means `tmp` anywhere |
|
|
279
279
|
| `/` in the pattern | matches the whole path, **anchored at the folder root** — `build/out.txt` is the top-level one, not every `build` |
|
|
280
|
-
| trailing `/` | names a directory, and covers its contents |
|
|
280
|
+
| trailing `/` | names a directory, and covers its contents. It does not anchor, and neither does a leading `/`: `build/` and `/build/` are every folder named `build`, at any depth |
|
|
281
281
|
| leading `!` | an exception, rescuing what an earlier line ignored |
|
|
282
282
|
|
|
283
283
|
**Order matters: the last matching line decides.** `['*.log', '!keep.log']`
|
|
@@ -290,7 +290,7 @@ Blank lines and `#` comments are allowed.
|
|
|
290
290
|
|
|
291
291
|
**A pattern containing none of `*`, `?`, `/` or `\`, not starting with `!` and
|
|
292
292
|
not ending with `/` keeps its older meaning: equal to, or a prefix of, any path
|
|
293
|
-
segment.**
|
|
293
|
+
segment — and, as before, case-sensitive.**
|
|
294
294
|
|
|
295
295
|
That is deliberate and load-bearing, not politeness to old configuration files.
|
|
296
296
|
`~$` is Word's lock-file prefix and `.~lock.` is LibreOffice's — neither is a
|
|
@@ -303,9 +303,9 @@ ignore: [
|
|
|
303
303
|
'node_modules', // prefix: also matches anything starting with it
|
|
304
304
|
'~$', // every Word lock file
|
|
305
305
|
'*.log', // every log file, at any depth
|
|
306
|
-
'
|
|
306
|
+
'!important.log', // ...except this one
|
|
307
|
+
'build/', // every folder named build, and its contents
|
|
307
308
|
'**/tmp', // tmp anywhere
|
|
308
|
-
'!build/keep.txt', // ...except this one
|
|
309
309
|
]
|
|
310
310
|
```
|
|
311
311
|
|
|
@@ -317,8 +317,34 @@ import { compileIgnore } from '@rljson/fs-agent';
|
|
|
317
317
|
|
|
318
318
|
const matcher = compileIgnore(patterns);
|
|
319
319
|
matcher.ignores('src/server.log'); // true
|
|
320
|
+
matcher.excludes('build/keep.txt', false); // true: no scan looks inside build/
|
|
320
321
|
```
|
|
321
322
|
|
|
323
|
+
### When nodes' lists differ, or change
|
|
324
|
+
|
|
325
|
+
Each node's list is its own, and a tree does not say which list made it. So
|
|
326
|
+
a path a node ignores is one it never touches:
|
|
327
|
+
|
|
328
|
+
- **Nothing it ignores is written** into its folder, and nothing it ignores is
|
|
329
|
+
deleted from it — not by a peer's edit, not by a merge, not by a restore.
|
|
330
|
+
- **Its edits carry those paths** as its head holds them: other nodes' versions,
|
|
331
|
+
unchanged. A node's ignore list never deletes anything on another node, and
|
|
332
|
+
never takes another node's version back.
|
|
333
|
+
- **Adding a pattern** — the files stay where they are, on every machine, and
|
|
334
|
+
stop syncing from this one. Its own copy stays as it is.
|
|
335
|
+
- **Removing a pattern** — the node takes the network's version first, as a
|
|
336
|
+
joining folder does: what it never received arrives, a version of its own
|
|
337
|
+
that differs is kept beside it as a conflicted copy, and one the network
|
|
338
|
+
deleted is moved to `.fsagent-recovered/`. Until a file has arrived — the
|
|
339
|
+
node started offline, say — it is carried, never announced as deleted.
|
|
340
|
+
- **A folder it ignores is never removed to make room** for a peer's file of
|
|
341
|
+
the same name, or the other way round: that path is reported as unwritable
|
|
342
|
+
(`path/unwritable`) and left as it is.
|
|
343
|
+
|
|
344
|
+
The list is read once, at start: a change takes a restart. The agent records
|
|
345
|
+
the list in `.fsagent-state.json`, which is how it knows on the next start
|
|
346
|
+
which paths it sees again.
|
|
347
|
+
|
|
322
348
|
---
|
|
323
349
|
|
|
324
350
|
## Knowing what happened to the folder
|
package/README.tests.md
CHANGED
|
@@ -8,22 +8,22 @@ found in the LICENSE file in the root of this package.
|
|
|
8
8
|
|
|
9
9
|
# The test suite, as a document
|
|
10
10
|
|
|
11
|
-
**
|
|
12
|
-
lines.**
|
|
11
|
+
**70 files, 807 scenarios, 100 % coverage on statements, branches, functions and
|
|
12
|
+
lines.** 801 must pass; one is committed inverted, and §2.11 says which and why.
|
|
13
13
|
One command runs all of it:
|
|
14
14
|
|
|
15
15
|
```bash
|
|
16
16
|
pnpm test # vitest --coverage --no-file-parallelism, then eslint
|
|
17
17
|
```
|
|
18
18
|
|
|
19
|
-
`--no-file-parallelism` is not a preference. **Thirty-
|
|
19
|
+
`--no-file-parallelism` is not a preference. **Thirty-five of these files**
|
|
20
20
|
drive a real `Server`, a real socket pair or the mesh harness — with real
|
|
21
21
|
watchers and real timers; run in parallel they fight over the cores and invent
|
|
22
22
|
failures. Four different tests once failed
|
|
23
23
|
across four CI runs of the same commit, each passing on re-run — not four bugs,
|
|
24
24
|
one scheduler.
|
|
25
25
|
|
|
26
|
-
This document says what the suite actually proves, because the number
|
|
26
|
+
This document says what the suite actually proves, because the number 807 does
|
|
27
27
|
not. It is organised by the question answered rather than by file; the file
|
|
28
28
|
index is at the end.
|
|
29
29
|
|
|
@@ -268,6 +268,25 @@ Also here: `fs-ref-vs-content.spec.ts` — identical content written at differen
|
|
|
268
268
|
times gives **one** ref and one content map. mtime is deliberately not part of
|
|
269
269
|
content identity: while it was, the same bytes gave a different ref per machine.
|
|
270
270
|
|
|
271
|
+
### 2.7b That a node's ignore list is its own
|
|
272
|
+
|
|
273
|
+
A tree does not say which list made it, so a path one node ignores is, to the
|
|
274
|
+
others, a path its edits leave out — a deletion. `mesh/fs-mesh-ignore-lists.spec.ts`
|
|
275
|
+
changes one node's list and checks the fleet: a pattern added deletes nothing
|
|
276
|
+
anywhere and the node keeps syncing; lists that differ from the start move
|
|
277
|
+
nothing either way; a pattern removed takes the network's version first and
|
|
278
|
+
keeps the node's own beside it; removed while offline, nothing the node could
|
|
279
|
+
not fetch is announced as deleted; a merge carries what the merging node
|
|
280
|
+
ignores, and both sides make the same merge. All five fail on 0.2.2 — the
|
|
281
|
+
first because the node never authors again.
|
|
282
|
+
|
|
283
|
+
Under them, `fs-carry.spec.ts` scans one folder twice, once with a narrower
|
|
284
|
+
list, and requires the graft of the difference to give the full scan's root
|
|
285
|
+
hash: a carried path costs nothing in ref identity. `fs-agent-ignored-paths.spec.ts`
|
|
286
|
+
holds the single-node rules — a restore into the folder skips what it ignores
|
|
287
|
+
and never removes an ignored entry to make room — and the guard: a node whose
|
|
288
|
+
visible files all vanished is refused however many it carries.
|
|
289
|
+
|
|
271
290
|
### 2.8 That a hostile or broken filesystem breaks only itself
|
|
272
291
|
|
|
273
292
|
| suite | what it survives |
|
|
@@ -406,7 +425,7 @@ Open items are in
|
|
|
406
425
|
## 5. File index
|
|
407
426
|
|
|
408
427
|
Counts are what `pnpm test` reports per file, so suites that generate cases in a
|
|
409
|
-
loop are counted as they run. They sum to the
|
|
428
|
+
loop are counted as they run. They sum to the 807 above.
|
|
410
429
|
|
|
411
430
|
### Mesh tier
|
|
412
431
|
|
|
@@ -417,6 +436,7 @@ loop are counted as they run. They sum to the 776 above.
|
|
|
417
436
|
| `mesh/fs-mesh-matrix.spec.ts` | 9 | the scenario matrix at mesh tier (L7, L8, I7, I7b, I10, J4+J5, J6, J9 ×2) |
|
|
418
437
|
| `mesh/fs-mesh-invariants.spec.ts` | 7 | invariants over the route, not the destination |
|
|
419
438
|
| `mesh/fs-mesh-wiped-and-reverted.spec.ts` | 7 | a node comes back empty, or holding an older copy |
|
|
439
|
+
| `mesh/fs-mesh-ignore-lists.spec.ts` | 5 | per-node ignore lists: a pattern added, lists that differ, a pattern removed — online and offline — and a merge |
|
|
420
440
|
| `mesh/fs-mesh-catchup-cost.spec.ts` | 2 | coming back does not cost what you missed |
|
|
421
441
|
| `fs-conflict-rules.spec.ts` | 8 | the conflict table C1–C6 on disks, and C3 before a stamp is known |
|
|
422
442
|
| `fs-agent-history.spec.ts` | 12 | the history a host shows — a pull, a merge, one order — and going back to a revision exactly |
|
|
@@ -465,7 +485,9 @@ loop are counted as they run. They sum to the 776 above.
|
|
|
465
485
|
| `fs-agent-signals.spec.ts` | 19 | one case per thing the agent signals, asserting the fields |
|
|
466
486
|
| `fs-signals.spec.ts` | 41 | the signal sink: the cap, the counters, ids, and a log read from a hostile folder |
|
|
467
487
|
| `fs-history.spec.ts` | 22 | the history walk: its order on hand-written chains, pages, cursors, and the read-only reader |
|
|
468
|
-
| `fs-ignore.spec.ts` |
|
|
488
|
+
| `fs-ignore.spec.ts` | 32 | glob ignore patterns, every legacy prefix, and what a scan leaves out |
|
|
489
|
+
| `fs-carry.spec.ts` | 10 | what a node does not see, it carries: the graft is the scanner's own tree |
|
|
490
|
+
| `fs-agent-ignored-paths.spec.ts` | 12 | what a node ignores it neither writes, deletes nor makes room over; the guard counts the folder; the list a restart compares |
|
|
469
491
|
| `fs-blob-adapter.spec.ts` | 26 | file ↔ blob |
|
|
470
492
|
| `fs-db-adapter.spec.ts` | 6 | storing a tree with its predecessors |
|
|
471
493
|
| `blob-io.spec.ts` | 5 | storing a file as a blob |
|
package/dist/README.api.md
CHANGED
|
@@ -378,6 +378,9 @@ Scans and watches a folder. `scan()` reads it into an `FsTree`; `scanFresh()`
|
|
|
378
378
|
returns a pass that started after the call, sharing one with anyone else asking
|
|
379
379
|
meanwhile — what a caller that acts on the folder must use. `watch()`,
|
|
380
380
|
`stopWatch()`, `pauseWatch()`, `onChange(cb)`, `knownFile(path)`.
|
|
381
|
+
`ignore` is the list it applies; `ignores(path, isDirectory?)` and
|
|
382
|
+
`excludes(path, isDirectory)` answer for one path, as
|
|
383
|
+
[`IgnoreMatcher`](#interface-ignorematcher) does.
|
|
381
384
|
|
|
382
385
|
### `interface FsScanOptions`
|
|
383
386
|
|
|
@@ -465,8 +468,8 @@ ignores.
|
|
|
465
468
|
|
|
466
469
|
Compiles ignore patterns into a matcher once: globs (`*`, `?`, `**`, folders
|
|
467
470
|
with `/`, `!` exceptions with last-match-wins), case-insensitive. A pattern with
|
|
468
|
-
no glob characters keeps its old prefix meaning
|
|
469
|
-
`ATOMIC_TMP_PREFIX` depend on it.
|
|
471
|
+
no glob characters keeps its old prefix meaning, case-sensitive as before —
|
|
472
|
+
`~$`, `.~lock.` and `ATOMIC_TMP_PREFIX` depend on it.
|
|
470
473
|
|
|
471
474
|
### `globToRegExp(pattern)`
|
|
472
475
|
|
|
@@ -474,8 +477,13 @@ One glob as a regular expression.
|
|
|
474
477
|
|
|
475
478
|
### `interface IgnoreMatcher`
|
|
476
479
|
|
|
477
|
-
`{ ignores(relativePath, isDirectory?)
|
|
478
|
-
|
|
480
|
+
`{ ignores(relativePath, isDirectory?), excludes(relativePath, isDirectory) }`.
|
|
481
|
+
|
|
482
|
+
- `ignores` — what the list says about the path itself. Pass `isDirectory`
|
|
483
|
+
when known, because a directory-only pattern needs it.
|
|
484
|
+
- `excludes` — whether a scan leaves the path out: the path, or a directory
|
|
485
|
+
above it. A scan does not descend into an ignored directory, so a path
|
|
486
|
+
below one is excluded even where an `!` line would rescue it.
|
|
479
487
|
|
|
480
488
|
---
|
|
481
489
|
|
|
@@ -68,6 +68,7 @@ hang and an unbounded list is tomorrow's memory ceiling.
|
|
|
68
68
|
| what a host application is told | [One channel for everything](#one-channel-for-everything-that-happened-srcfs-signalsts) |
|
|
69
69
|
| why a half-written file does not go out | [A Copy in Progress](#a-copy-in-progress-does-not-reach-the-wire-fsscanner-the-settle-rule) |
|
|
70
70
|
| which files are skipped | [Ignore Matching](#ignore-matching-srcfs-ignorets) |
|
|
71
|
+
| what a node does with paths it ignores | [Carrying what a node does not see](#carrying-what-a-node-does-not-see-srcfs-carryts) |
|
|
71
72
|
| what 0.2.0 removed | [Removed in 0.2.0](#removed-in-020) |
|
|
72
73
|
| the signature of anything named here | [README.api.md](README.api.md) |
|
|
73
74
|
|
|
@@ -779,10 +780,56 @@ fire — a defect this package has already had.
|
|
|
779
780
|
The matcher is compiled once per agent, because a scan of a real catalogue asks
|
|
780
781
|
this question once per file.
|
|
781
782
|
|
|
782
|
-
**Tested by** `test/fs-ignore.spec.ts` (
|
|
783
|
+
**Tested by** `test/fs-ignore.spec.ts` (32), whose first block is one case per
|
|
783
784
|
pattern that appears in the shipped configuration or in the agent's own list —
|
|
784
785
|
that being the half which can break a running fleet.
|
|
785
786
|
|
|
787
|
+
## Carrying what a node does not see (`src/fs-carry.ts`)
|
|
788
|
+
|
|
789
|
+
Every node has its own ignore list, and a tree does not say which list made
|
|
790
|
+
it. An edit authored from the scan alone leaves out every path its author
|
|
791
|
+
ignores, and the chain reads a missing path as a deletion. Measured with one
|
|
792
|
+
pattern added on one node of three: that node authored nothing ever again — a
|
|
793
|
+
removal waits until the scan agrees the file is gone, and a scan that ignores
|
|
794
|
+
the file never does — and incoming trees were written into the paths it
|
|
795
|
+
ignored. A node whose head did not name the files yet deleted them everywhere
|
|
796
|
+
with its next edit.
|
|
797
|
+
|
|
798
|
+
So a node never touches a path it ignores:
|
|
799
|
+
|
|
800
|
+
- **Authoring** grafts onto the scan what the own head holds at those paths
|
|
801
|
+
(`graftTree`). The graft is the tree the scanner builds for a folder that
|
|
802
|
+
holds them, node for node and ref for ref — a test scans a folder twice,
|
|
803
|
+
once with a narrower list, and the graft of the difference gives the full
|
|
804
|
+
scan's root hash.
|
|
805
|
+
- **Applying** neither writes nor deletes there, and the guard counts only what
|
|
806
|
+
the folder holds (`_applyContent`).
|
|
807
|
+
- **Merging** carries the version the merge kept, from whichever side; a copy a
|
|
808
|
+
conflict made at such a path is written and carried (`_mergeCarried`).
|
|
809
|
+
- **Restoring** into the own folder skips those paths, and never removes an
|
|
810
|
+
entry the node ignores to make room for one of another kind (`_makeRoomFor`):
|
|
811
|
+
that path is reported as unwritable instead.
|
|
812
|
+
|
|
813
|
+
`_carried` holds the own head's nodes at those paths. It is recomputed from the
|
|
814
|
+
head's tree whenever the head changes (`carriedNodes`, which walks the tree as
|
|
815
|
+
the scanner walks the folder), and it is empty while the lists agree — then
|
|
816
|
+
every tree is the scan's own and nothing above changes.
|
|
817
|
+
|
|
818
|
+
**A pattern removed** makes the node see paths it never wrote. Authored as they
|
|
819
|
+
stand, a file it never received would be deleted everywhere and a version of
|
|
820
|
+
its own would overwrite the network's. So the state file records the list the
|
|
821
|
+
folder is in step with, and a restart with another list joins those paths
|
|
822
|
+
(`_uncover`, with `planJoin`): a version of its own goes aside as a conflicted
|
|
823
|
+
copy, one the history removed goes to `.fsagent-recovered/`, and the head's
|
|
824
|
+
version is fetched with every head the node hears (`_takeUncovered`) and
|
|
825
|
+
carried until it is in the folder. The record moves to the new list once
|
|
826
|
+
nothing is missing, so a restart in between takes it up again.
|
|
827
|
+
|
|
828
|
+
**Tested by** `test/fs-carry.spec.ts` (10), `test/fs-agent-ignored-paths.spec.ts`
|
|
829
|
+
and `test/mesh/fs-mesh-ignore-lists.spec.ts` (5): a pattern added on one node,
|
|
830
|
+
different lists from the start, a pattern removed, removed while offline, and a
|
|
831
|
+
merge — every one of which fails on 0.2.2.
|
|
832
|
+
|
|
786
833
|
## Removed in 0.2.0
|
|
787
834
|
|
|
788
835
|
No compatibility with 0.1.x: every mechanism that existed to tolerate, migrate
|
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 # 70 files, 807 scenarios, 100 % coverage, then eslint
|
|
24
24
|
```
|
|
25
25
|
|
|
26
26
|
## Where to start
|
|
@@ -28,7 +28,7 @@ pnpm test # 67 files, 776 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 807 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 |
|
package/dist/README.public.md
CHANGED
|
@@ -277,7 +277,7 @@ the path and the pattern.
|
|
|
277
277
|
| `?` | one character within one segment |
|
|
278
278
|
| `**` | crosses separators. A leading `**/` also matches at the root, so `**/tmp` means `tmp` anywhere |
|
|
279
279
|
| `/` in the pattern | matches the whole path, **anchored at the folder root** — `build/out.txt` is the top-level one, not every `build` |
|
|
280
|
-
| trailing `/` | names a directory, and covers its contents |
|
|
280
|
+
| trailing `/` | names a directory, and covers its contents. It does not anchor, and neither does a leading `/`: `build/` and `/build/` are every folder named `build`, at any depth |
|
|
281
281
|
| leading `!` | an exception, rescuing what an earlier line ignored |
|
|
282
282
|
|
|
283
283
|
**Order matters: the last matching line decides.** `['*.log', '!keep.log']`
|
|
@@ -290,7 +290,7 @@ Blank lines and `#` comments are allowed.
|
|
|
290
290
|
|
|
291
291
|
**A pattern containing none of `*`, `?`, `/` or `\`, not starting with `!` and
|
|
292
292
|
not ending with `/` keeps its older meaning: equal to, or a prefix of, any path
|
|
293
|
-
segment.**
|
|
293
|
+
segment — and, as before, case-sensitive.**
|
|
294
294
|
|
|
295
295
|
That is deliberate and load-bearing, not politeness to old configuration files.
|
|
296
296
|
`~$` is Word's lock-file prefix and `.~lock.` is LibreOffice's — neither is a
|
|
@@ -303,9 +303,9 @@ ignore: [
|
|
|
303
303
|
'node_modules', // prefix: also matches anything starting with it
|
|
304
304
|
'~$', // every Word lock file
|
|
305
305
|
'*.log', // every log file, at any depth
|
|
306
|
-
'
|
|
306
|
+
'!important.log', // ...except this one
|
|
307
|
+
'build/', // every folder named build, and its contents
|
|
307
308
|
'**/tmp', // tmp anywhere
|
|
308
|
-
'!build/keep.txt', // ...except this one
|
|
309
309
|
]
|
|
310
310
|
```
|
|
311
311
|
|
|
@@ -317,8 +317,34 @@ import { compileIgnore } from '@rljson/fs-agent';
|
|
|
317
317
|
|
|
318
318
|
const matcher = compileIgnore(patterns);
|
|
319
319
|
matcher.ignores('src/server.log'); // true
|
|
320
|
+
matcher.excludes('build/keep.txt', false); // true: no scan looks inside build/
|
|
320
321
|
```
|
|
321
322
|
|
|
323
|
+
### When nodes' lists differ, or change
|
|
324
|
+
|
|
325
|
+
Each node's list is its own, and a tree does not say which list made it. So
|
|
326
|
+
a path a node ignores is one it never touches:
|
|
327
|
+
|
|
328
|
+
- **Nothing it ignores is written** into its folder, and nothing it ignores is
|
|
329
|
+
deleted from it — not by a peer's edit, not by a merge, not by a restore.
|
|
330
|
+
- **Its edits carry those paths** as its head holds them: other nodes' versions,
|
|
331
|
+
unchanged. A node's ignore list never deletes anything on another node, and
|
|
332
|
+
never takes another node's version back.
|
|
333
|
+
- **Adding a pattern** — the files stay where they are, on every machine, and
|
|
334
|
+
stop syncing from this one. Its own copy stays as it is.
|
|
335
|
+
- **Removing a pattern** — the node takes the network's version first, as a
|
|
336
|
+
joining folder does: what it never received arrives, a version of its own
|
|
337
|
+
that differs is kept beside it as a conflicted copy, and one the network
|
|
338
|
+
deleted is moved to `.fsagent-recovered/`. Until a file has arrived — the
|
|
339
|
+
node started offline, say — it is carried, never announced as deleted.
|
|
340
|
+
- **A folder it ignores is never removed to make room** for a peer's file of
|
|
341
|
+
the same name, or the other way round: that path is reported as unwritable
|
|
342
|
+
(`path/unwritable`) and left as it is.
|
|
343
|
+
|
|
344
|
+
The list is read once, at start: a change takes a restart. The agent records
|
|
345
|
+
the list in `.fsagent-state.json`, which is how it knows on the next start
|
|
346
|
+
which paths it sees again.
|
|
347
|
+
|
|
322
348
|
---
|
|
323
349
|
|
|
324
350
|
## Knowing what happened to the folder
|
package/dist/README.tests.md
CHANGED
|
@@ -8,22 +8,22 @@ found in the LICENSE file in the root of this package.
|
|
|
8
8
|
|
|
9
9
|
# The test suite, as a document
|
|
10
10
|
|
|
11
|
-
**
|
|
12
|
-
lines.**
|
|
11
|
+
**70 files, 807 scenarios, 100 % coverage on statements, branches, functions and
|
|
12
|
+
lines.** 801 must pass; one is committed inverted, and §2.11 says which and why.
|
|
13
13
|
One command runs all of it:
|
|
14
14
|
|
|
15
15
|
```bash
|
|
16
16
|
pnpm test # vitest --coverage --no-file-parallelism, then eslint
|
|
17
17
|
```
|
|
18
18
|
|
|
19
|
-
`--no-file-parallelism` is not a preference. **Thirty-
|
|
19
|
+
`--no-file-parallelism` is not a preference. **Thirty-five of these files**
|
|
20
20
|
drive a real `Server`, a real socket pair or the mesh harness — with real
|
|
21
21
|
watchers and real timers; run in parallel they fight over the cores and invent
|
|
22
22
|
failures. Four different tests once failed
|
|
23
23
|
across four CI runs of the same commit, each passing on re-run — not four bugs,
|
|
24
24
|
one scheduler.
|
|
25
25
|
|
|
26
|
-
This document says what the suite actually proves, because the number
|
|
26
|
+
This document says what the suite actually proves, because the number 807 does
|
|
27
27
|
not. It is organised by the question answered rather than by file; the file
|
|
28
28
|
index is at the end.
|
|
29
29
|
|
|
@@ -268,6 +268,25 @@ Also here: `fs-ref-vs-content.spec.ts` — identical content written at differen
|
|
|
268
268
|
times gives **one** ref and one content map. mtime is deliberately not part of
|
|
269
269
|
content identity: while it was, the same bytes gave a different ref per machine.
|
|
270
270
|
|
|
271
|
+
### 2.7b That a node's ignore list is its own
|
|
272
|
+
|
|
273
|
+
A tree does not say which list made it, so a path one node ignores is, to the
|
|
274
|
+
others, a path its edits leave out — a deletion. `mesh/fs-mesh-ignore-lists.spec.ts`
|
|
275
|
+
changes one node's list and checks the fleet: a pattern added deletes nothing
|
|
276
|
+
anywhere and the node keeps syncing; lists that differ from the start move
|
|
277
|
+
nothing either way; a pattern removed takes the network's version first and
|
|
278
|
+
keeps the node's own beside it; removed while offline, nothing the node could
|
|
279
|
+
not fetch is announced as deleted; a merge carries what the merging node
|
|
280
|
+
ignores, and both sides make the same merge. All five fail on 0.2.2 — the
|
|
281
|
+
first because the node never authors again.
|
|
282
|
+
|
|
283
|
+
Under them, `fs-carry.spec.ts` scans one folder twice, once with a narrower
|
|
284
|
+
list, and requires the graft of the difference to give the full scan's root
|
|
285
|
+
hash: a carried path costs nothing in ref identity. `fs-agent-ignored-paths.spec.ts`
|
|
286
|
+
holds the single-node rules — a restore into the folder skips what it ignores
|
|
287
|
+
and never removes an ignored entry to make room — and the guard: a node whose
|
|
288
|
+
visible files all vanished is refused however many it carries.
|
|
289
|
+
|
|
271
290
|
### 2.8 That a hostile or broken filesystem breaks only itself
|
|
272
291
|
|
|
273
292
|
| suite | what it survives |
|
|
@@ -406,7 +425,7 @@ Open items are in
|
|
|
406
425
|
## 5. File index
|
|
407
426
|
|
|
408
427
|
Counts are what `pnpm test` reports per file, so suites that generate cases in a
|
|
409
|
-
loop are counted as they run. They sum to the
|
|
428
|
+
loop are counted as they run. They sum to the 807 above.
|
|
410
429
|
|
|
411
430
|
### Mesh tier
|
|
412
431
|
|
|
@@ -417,6 +436,7 @@ loop are counted as they run. They sum to the 776 above.
|
|
|
417
436
|
| `mesh/fs-mesh-matrix.spec.ts` | 9 | the scenario matrix at mesh tier (L7, L8, I7, I7b, I10, J4+J5, J6, J9 ×2) |
|
|
418
437
|
| `mesh/fs-mesh-invariants.spec.ts` | 7 | invariants over the route, not the destination |
|
|
419
438
|
| `mesh/fs-mesh-wiped-and-reverted.spec.ts` | 7 | a node comes back empty, or holding an older copy |
|
|
439
|
+
| `mesh/fs-mesh-ignore-lists.spec.ts` | 5 | per-node ignore lists: a pattern added, lists that differ, a pattern removed — online and offline — and a merge |
|
|
420
440
|
| `mesh/fs-mesh-catchup-cost.spec.ts` | 2 | coming back does not cost what you missed |
|
|
421
441
|
| `fs-conflict-rules.spec.ts` | 8 | the conflict table C1–C6 on disks, and C3 before a stamp is known |
|
|
422
442
|
| `fs-agent-history.spec.ts` | 12 | the history a host shows — a pull, a merge, one order — and going back to a revision exactly |
|
|
@@ -465,7 +485,9 @@ loop are counted as they run. They sum to the 776 above.
|
|
|
465
485
|
| `fs-agent-signals.spec.ts` | 19 | one case per thing the agent signals, asserting the fields |
|
|
466
486
|
| `fs-signals.spec.ts` | 41 | the signal sink: the cap, the counters, ids, and a log read from a hostile folder |
|
|
467
487
|
| `fs-history.spec.ts` | 22 | the history walk: its order on hand-written chains, pages, cursors, and the read-only reader |
|
|
468
|
-
| `fs-ignore.spec.ts` |
|
|
488
|
+
| `fs-ignore.spec.ts` | 32 | glob ignore patterns, every legacy prefix, and what a scan leaves out |
|
|
489
|
+
| `fs-carry.spec.ts` | 10 | what a node does not see, it carries: the graft is the scanner's own tree |
|
|
490
|
+
| `fs-agent-ignored-paths.spec.ts` | 12 | what a node ignores it neither writes, deletes nor makes room over; the guard counts the folder; the list a restart compares |
|
|
469
491
|
| `fs-blob-adapter.spec.ts` | 26 | file ↔ blob |
|
|
470
492
|
| `fs-db-adapter.spec.ts` | 6 | storing a tree with its predecessors |
|
|
471
493
|
| `blob-io.spec.ts` | 5 | storing a file as a blob |
|