@rljson/fs-agent 0.0.85 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.api.md +319 -0
- package/README.architecture.md +1327 -141
- package/README.contributors.md +101 -15
- package/README.md +40 -11
- package/README.public.md +452 -815
- package/README.tests.md +443 -0
- package/README.trouble.md +70 -8
- package/dist/README.api.md +319 -0
- package/dist/README.architecture.md +1327 -141
- package/dist/README.contributors.md +101 -15
- package/dist/README.md +40 -11
- package/dist/README.public.md +452 -815
- package/dist/README.tests.md +443 -0
- package/dist/README.trouble.md +70 -8
- package/dist/fs-agent.d.ts +1216 -90
- package/dist/fs-agent.js +3769 -406
- package/dist/fs-anti-entropy.d.ts +267 -9
- package/dist/fs-atomic-write.d.ts +46 -0
- package/dist/fs-bucket-sync.d.ts +172 -0
- package/dist/fs-conflict-resolver.d.ts +212 -8
- package/dist/fs-edit-chain.d.ts +582 -0
- package/dist/fs-ignore.d.ts +32 -0
- package/dist/fs-manifest.d.ts +159 -0
- package/dist/fs-scanner.d.ts +141 -6
- package/dist/index.d.ts +7 -2
- package/package.json +9 -9
|
@@ -0,0 +1,443 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
@license
|
|
3
|
+
Copyright (c) 2025 Rljson
|
|
4
|
+
|
|
5
|
+
Use of this source code is governed by terms that can be
|
|
6
|
+
found in the LICENSE file in the root of this package.
|
|
7
|
+
-->
|
|
8
|
+
|
|
9
|
+
# The test suite, as a document
|
|
10
|
+
|
|
11
|
+
**70 files, 923 scenarios, 100 % coverage on statements, branches, functions and
|
|
12
|
+
lines.** 922 must pass; one is committed inverted, and §2.11 says which and why.
|
|
13
|
+
One command runs all of it:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
pnpm test # vitest --coverage --no-file-parallelism, then eslint
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
`--no-file-parallelism` is not a preference. **Thirty-seven of these files**
|
|
20
|
+
drive a real `Server`, a real socket pair or the mesh harness — with real
|
|
21
|
+
watchers and real timers; run in parallel they fight over the cores and invent
|
|
22
|
+
failures. Four different tests once failed
|
|
23
|
+
across four CI runs of the same commit, each passing on re-run — not four bugs,
|
|
24
|
+
one scheduler.
|
|
25
|
+
|
|
26
|
+
This document says what the suite actually proves, because the number 923 does
|
|
27
|
+
not. It is organised by the question answered rather than by file; the file
|
|
28
|
+
index is at the end.
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## 1. Three tiers, and why the distinction is the point
|
|
33
|
+
|
|
34
|
+
| tier | what it is | files |
|
|
35
|
+
| --- | --- | --- |
|
|
36
|
+
| **mesh** | a real `Server`, real sockets (`createSocketPair`), real watchers, real files on disk, two to four nodes, with cuts, heals, mutes, deafenings and stopped processes | 11 |
|
|
37
|
+
| **client–server** | two or three clients and a real hub, each suite run **twice** — once over `SocketMock`, once over a real socket.io server configured at production's 50 MB limit | 6 |
|
|
38
|
+
| **unit / decision** | one agent, or a pure function with no filesystem and no clock | 52 |
|
|
39
|
+
|
|
40
|
+
A decision-tier test proves a RULE. It does not prove the rule is ever
|
|
41
|
+
reached, and the difference has cost this package real defects: every decision
|
|
42
|
+
in the join protocol was proven by a pure function while the input was never
|
|
43
|
+
assembled, and the defect was in the assembly. So a scenario answered only at
|
|
44
|
+
the unit tier is answered only **partly**, and the tiers above exist to close
|
|
45
|
+
exactly that gap.
|
|
46
|
+
|
|
47
|
+
The mesh harness (`test/mesh/fs-mesh.ts`) is the instrument most of the hard
|
|
48
|
+
results come from. It can `cut()` a node (both directions), `mute()` it (its
|
|
49
|
+
work reaches nobody while it still hears), `deafen()` it (it announces into a
|
|
50
|
+
void), `down()` and `up()` it (a stopped PROCESS, which is what a crash is,
|
|
51
|
+
rather than a broken network), and `join()` a node whose folder was written
|
|
52
|
+
*before* its agent started — which is what restoring a backup actually looks
|
|
53
|
+
like. `converged()` compares **file contents**, not refs, and names the paths
|
|
54
|
+
that differ when it fails.
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## 2. What the suite proves
|
|
59
|
+
|
|
60
|
+
### 2.1 That something arrives at all
|
|
61
|
+
|
|
62
|
+
The floor. `shared-sync-tests.ts` holds 35 scenarios and is run twice, once per
|
|
63
|
+
transport: a file A→B and B→A, content changes, empty files, binaries, files
|
|
64
|
+
with spaces and special characters, a file that grows and then shrinks, a
|
|
65
|
+
100 KB file, multiple files created at once, a new directory with files,
|
|
66
|
+
directory deletion, deeply nested creation, empty directories, nested empty
|
|
67
|
+
directories, a rename, convergence that then stops producing traffic, and —
|
|
68
|
+
asserted explicitly — that teardown really stops it.
|
|
69
|
+
|
|
70
|
+
At mesh tier the same floor is `fs-mesh.spec.ts` T1–T7 and
|
|
71
|
+
`fs-mesh-field-defects.spec.ts` F1–F10, each of which is a defect that was
|
|
72
|
+
measured in the field rather than an invented case.
|
|
73
|
+
|
|
74
|
+
### 2.2 That a deletion travels — the hardest thing here
|
|
75
|
+
|
|
76
|
+
Deletion is where this package has lost data, and it carries the most tests
|
|
77
|
+
per line of code anywhere in it.
|
|
78
|
+
|
|
79
|
+
The architecture is the claim: **an absence is not a deletion.** A tree lacks a
|
|
80
|
+
path because the sender removed it or because the sender never had it, and a
|
|
81
|
+
content hash cannot tell the two apart. Every attempt to infer it failed — a
|
|
82
|
+
rule asking "could the sender have seen my state?", a flag for whether the
|
|
83
|
+
transport carried ancestry, a guard for files not yet announced, and a set of a
|
|
84
|
+
thousand remembered past states. Four reverts, 155 files of measured drift
|
|
85
|
+
across four machines, and a file deleted from 3 642 that was back moments
|
|
86
|
+
later. So a removal is **stated** in the edit chain by the node that performed
|
|
87
|
+
it, and that statement is the only authority.
|
|
88
|
+
|
|
89
|
+
What holds it up:
|
|
90
|
+
|
|
91
|
+
- `fs-collect-removals.spec.ts` (31) — the walk that finds what was removed,
|
|
92
|
+
including netting re-adds against removals in order, concluding **nothing**
|
|
93
|
+
from a walk that cannot complete, and stopping at a bound rather than
|
|
94
|
+
reading a whole history.
|
|
95
|
+
- `fs-plan-removals.spec.ts` (19) — which stated removals may be applied, with
|
|
96
|
+
two floors rather than one.
|
|
97
|
+
- `fs-agent-tombstone-log.spec.ts` (9) — what a restart remembers it deleted.
|
|
98
|
+
A restart that forgets is how a deletion is undone by the first peer that
|
|
99
|
+
never heard about it.
|
|
100
|
+
- `fs-agent-mass-delete-guard.spec.ts` (15) — refusing a deletion that looks
|
|
101
|
+
like a loss, *and* allowing a large one that is still a minority, *and*
|
|
102
|
+
reporting what it refused so the numbers can be judged.
|
|
103
|
+
- At mesh tier: A2 (a delete made while partitioned stays deleted), T2 (a
|
|
104
|
+
delete survives a merge with a peer that still holds the file), T4 (a delete
|
|
105
|
+
made while cut off is not resurrected on rejoin — a coin flip through four
|
|
106
|
+
work packages, now 8 of 8), F1 (removing a **directory** propagates, not just
|
|
107
|
+
its files), F7 (100 deletions out of 400 complete everywhere), I7 (a peer's
|
|
108
|
+
deletion does not remove a file re-created since), and J9 (a deletion made
|
|
109
|
+
while the agent was **down** still propagates).
|
|
110
|
+
|
|
111
|
+
### 2.3 That two people editing one file lose nothing
|
|
112
|
+
|
|
113
|
+
`fs-conflict-resolver.spec.ts` (41) and `fs-manifest.spec.ts` (36) carry the
|
|
114
|
+
decisions; `fs-conflict-integration.spec.ts` and `conflict-sync.spec.ts` carry
|
|
115
|
+
them end to end. The guarantee is that one version wins **deterministically on
|
|
116
|
+
every node**, the loser survives as a renamed conflict copy, and the conflict
|
|
117
|
+
is reported rather than silently settled.
|
|
118
|
+
|
|
119
|
+
The winner is chosen on the edit's own `timeId`, authored where the change was
|
|
120
|
+
made — not on which advertisement arrived last and not on the greater content
|
|
121
|
+
hash, both of which this package has shipped and both of which produced a
|
|
122
|
+
different answer per machine.
|
|
123
|
+
|
|
124
|
+
At mesh tier: F5 (four nodes editing one file end on one version), F10 (two
|
|
125
|
+
nodes keep both versions **and say so**), T3 (both changes kept from a shared
|
|
126
|
+
ancestor), and `simultaneous-edit.spec.ts` (five rounds of three nodes
|
|
127
|
+
contesting one file).
|
|
128
|
+
|
|
129
|
+
### 2.4 That a document never goes backwards
|
|
130
|
+
|
|
131
|
+
`fs-mesh-invariants.spec.ts` asserts properties over the ROUTE rather than the
|
|
132
|
+
destination: *a document never goes backwards while one person edits it*, *a
|
|
133
|
+
converged deletion does not come back*, *every node ends on the last save*,
|
|
134
|
+
*every announcement carries a chain head*, and — under random churn and
|
|
135
|
+
partitions across three seeds — *a disagreement is never silent*.
|
|
136
|
+
|
|
137
|
+
These are the expensive ones, and they are the tests that caught a defect no
|
|
138
|
+
example-based test could: a receiver catching up recorded itself as the author of
|
|
139
|
+
a file it had never edited, 28 seconds after the real edit, and the whole fleet
|
|
140
|
+
settled one version behind the last save about one run in three.
|
|
141
|
+
|
|
142
|
+
**The churn scenarios found three things, and only one of them was what it
|
|
143
|
+
looked like.** One was a real defect and is fixed — a same-path conflict settled
|
|
144
|
+
by content hash rather than by when the edit happened, which made the fleet
|
|
145
|
+
converge on a superseded write. One did not exist: the test's own count of a
|
|
146
|
+
node's tree entries used a field those nodes do not have, so it counted
|
|
147
|
+
directories and the folder root as files and reported a consistent fleet as a
|
|
148
|
+
loss. The third had never been gated at all, because the test read the fleet's
|
|
149
|
+
convergence verdict and used only its snapshot.
|
|
150
|
+
|
|
151
|
+
All three are now asserted: the same files, the same bytes, and — if that ever
|
|
152
|
+
fails — that some node's `diverged` or `differingPaths` said so. The silence
|
|
153
|
+
check is kept beside the equality check rather than instead of it, because a
|
|
154
|
+
disagreement nobody noticed is a different defect from one every node is
|
|
155
|
+
announcing, and a failure should say which. The seed fixes the write sequence
|
|
156
|
+
and nothing else, so each run is a different race; that is why these are run
|
|
157
|
+
repeatedly rather than once, and why a count of passes is the only evidence
|
|
158
|
+
worth quoting.
|
|
159
|
+
|
|
160
|
+
### 2.5 That joining a network cannot destroy what is already there
|
|
161
|
+
|
|
162
|
+
A folder's contents cannot say where a joining node belongs in the history. A
|
|
163
|
+
node that authored a lineage root from whatever it happened to hold, and pushed
|
|
164
|
+
it as the network's newest claim, would carry one defect with two faces: every
|
|
165
|
+
node gets its own root, so every announcement classifies as a fork; and a
|
|
166
|
+
machine restored from a backup pushes a month of deleted files back to the
|
|
167
|
+
fleet.
|
|
168
|
+
|
|
169
|
+
`fs-plan-join.spec.ts` (9) decides it against the chain, with every path in at
|
|
170
|
+
most one of four buckets — write, announce, recover, conflict — and
|
|
171
|
+
`fs-mesh-matrix.spec.ts` proves it reached: **J4+J5** (a joiner keeps its own
|
|
172
|
+
new work and does not resurrect a deletion) and **J9** twice (work done while
|
|
173
|
+
the agent was down is not lost; a deletion made then still propagates).
|
|
174
|
+
|
|
175
|
+
A file the history deliberately deleted is neither announced nor destroyed: it
|
|
176
|
+
is renamed aside into `.fsagent-recovered/`, which the scanner ignores.
|
|
177
|
+
|
|
178
|
+
### 2.6 That a lost message heals itself
|
|
179
|
+
|
|
180
|
+
`heals-after-forced-divergence.spec.ts` (8 scenarios × 2 transports) drops
|
|
181
|
+
messages on purpose: a new file whose push the hub never received, a deletion
|
|
182
|
+
whose push it never received, a deletion a peer never received, a peer deletion
|
|
183
|
+
that must **not** be undone, every node healing when the hub received nothing
|
|
184
|
+
at all, and a node that misses every forward while another keeps writing. It
|
|
185
|
+
keeps the original failure as its own case too.
|
|
186
|
+
|
|
187
|
+
`fs-anti-entropy.spec.ts` (36) and `fs-anti-entropy-level1.spec.ts` (10) carry
|
|
188
|
+
the decision. Level 1 is **enumerations, not examples** — "for every pair of
|
|
189
|
+
views" — because the defect class here is two situations that need opposite
|
|
190
|
+
actions arriving as the same value. That matters concretely: a release passed
|
|
191
|
+
every example test in the suite, fixed the case it was written for, and then
|
|
192
|
+
flipped a production folder between two states about twenty times in ninety
|
|
193
|
+
seconds. Ninety seconds of a production folder rewriting itself was an
|
|
194
|
+
expensive way to learn something a loop over a three-element set says before
|
|
195
|
+
the commit.
|
|
196
|
+
|
|
197
|
+
### 2.7 That a node claims only what it changed
|
|
198
|
+
|
|
199
|
+
The standing design rule: one identical chain on every client, an edit exists
|
|
200
|
+
only where the change was made, a receiver adopts and never authors, and no
|
|
201
|
+
edit without predecessors.
|
|
202
|
+
|
|
203
|
+
`fs-agent-authorship.spec.ts`, `fs-agent-no-laundering.spec.ts` (6, *a node
|
|
204
|
+
does not re-advertise what it adopted*), `fs-agent-own-echo.spec.ts`,
|
|
205
|
+
`fs-agent-self-parent.spec.ts`, `fs-agent-inbound-verdict.spec.ts` (7),
|
|
206
|
+
`fs-agent-stale-reconnect.spec.ts` (13) and
|
|
207
|
+
`fs-agent-send-retires-left-state.spec.ts` hold the edges, with
|
|
208
|
+
`fs-edit-chain.spec.ts` (20), `fs-classify.spec.ts` (11) and
|
|
209
|
+
`fs-chain-crosses-the-wire.spec.ts` under them.
|
|
210
|
+
|
|
211
|
+
Also here: `fs-ref-vs-content.spec.ts` — identical content written at different
|
|
212
|
+
times gives **one** ref. mtime is deliberately not part of content identity,
|
|
213
|
+
because it does not survive a restore byte for byte and on Windows regularly
|
|
214
|
+
does not, and while it was in the identity the same bytes gave a different ref
|
|
215
|
+
per machine and a node's deletions were refused by everybody.
|
|
216
|
+
|
|
217
|
+
### 2.8 That a hostile or broken filesystem breaks only itself
|
|
218
|
+
|
|
219
|
+
| suite | what it survives |
|
|
220
|
+
| --- | --- |
|
|
221
|
+
| `fs-agent-locked-file.spec.ts` (7) | a file another process holds open — the rest of the restore lands, every locked file is named, a non-lock write failure still aborts, and the half-applied state is **not** advertised to peers |
|
|
222
|
+
| `fs-impossible-filename.spec.ts` (4) | a path the filesystem refuses — a 300-character path, `CON.txt`. Each blocks only itself |
|
|
223
|
+
| `fs-filenames.spec.ts` (5) | a German filename round-tripping byte for byte, two Unicode spellings of one name not destroying each other, a case-only rename |
|
|
224
|
+
| `fs-hostile-tree.spec.ts` (4) | a tree from a peer is not trusted with paths — no escaping the sync root |
|
|
225
|
+
| `fs-filetype-changes.spec.ts` (6) | a path that changes what it IS: file → directory, directory → file, symlinks |
|
|
226
|
+
| `fs-scanner-vanish.spec.ts` (12) | an entry deleted between `readdir` and `stat` |
|
|
227
|
+
| `fs-disk-full.spec.ts` (3) | ENOSPC — a clean abort with a message, not a silent standstill |
|
|
228
|
+
| `fs-slow-copy.spec.ts` (3) | a file still being written: never hashed half-done, and one unsettled file does not stop the folder |
|
|
229
|
+
| `fs-clock-skew.spec.ts` (3) | a machine whose clock is wrong — a file is visible whatever its timestamp says |
|
|
230
|
+
| `fs-agent-blob-stream.spec.ts` (3) | a file larger than one socket message, and a transfer that breaks off mid-file |
|
|
231
|
+
|
|
232
|
+
### 2.9 That coming back does not cost what you missed
|
|
233
|
+
|
|
234
|
+
`fs-mesh-catchup-cost.spec.ts` measures, not asserts-and-hopes: a node away for
|
|
235
|
+
twenty saves of one document fetches **one** blob, named by content rather than
|
|
236
|
+
counted, so the measurement cannot be satisfied by a blob the node already
|
|
237
|
+
held. A number that tracked the number of missed saves would mean the cost of
|
|
238
|
+
being away is proportional to how long you were away.
|
|
239
|
+
|
|
240
|
+
`fs-agent-incremental-restore.spec.ts` (8) and `fs-scale.spec.ts` D8 are the
|
|
241
|
+
same property on disk: a new file arriving must not rewrite the folder, and a
|
|
242
|
+
second scan of 4 000 files re-reads nothing.
|
|
243
|
+
|
|
244
|
+
`fs-scale.spec.ts` T1 is endurance — memory, handles and the agent's own
|
|
245
|
+
bounded structures sampled while the folder churns. Short by default;
|
|
246
|
+
`FS_SOAK_MS=14400000` runs the four hours the register asks for and nothing
|
|
247
|
+
about the test changes.
|
|
248
|
+
|
|
249
|
+
### 2.10 That the wire format is what it claims to be
|
|
250
|
+
|
|
251
|
+
`fs-bucket-sync.spec.ts` (29) pins the format itself — message bodies are JSON
|
|
252
|
+
because a POSIX filename may contain any byte but `/` and NUL.
|
|
253
|
+
|
|
254
|
+
There is no mixed-version test, because there is only one format — every node
|
|
255
|
+
announces a chain head, and the fleet is upgraded together.
|
|
256
|
+
|
|
257
|
+
What holds that is a census rather than a sample: `every announcement carries a
|
|
258
|
+
chain head`, in `mesh/fs-mesh-invariants.spec.ts`, records every ref each node
|
|
259
|
+
puts on the wire across the whole mesh tier and fails if any is bare. **Zero
|
|
260
|
+
bare refs.**
|
|
261
|
+
|
|
262
|
+
### 2.11 Reproductions, kept verbatim
|
|
263
|
+
|
|
264
|
+
`field-repro.spec.ts` reproduces reported failures as written,
|
|
265
|
+
and `fs-mesh-wiped-and-reverted.spec.ts` the two shapes a machine comes back
|
|
266
|
+
in: a folder **wiped** (must not empty the fleet, must be refilled) and a
|
|
267
|
+
folder **reverted** to an older copy. Several suites carry a backlog ID in
|
|
268
|
+
their `describe` — `F1/D2`, `F1/D5`, `V2/D3`, `L2/D4`, `F5`, `F7`, `S5` — so
|
|
269
|
+
the item that paid for the test is readable from the test.
|
|
270
|
+
|
|
271
|
+
The reverted shape holds the package's **one inverted test**, *a node reverted
|
|
272
|
+
to an older copy does not drag the fleet back*. A revert performed underneath a
|
|
273
|
+
**running** agent is not decidable from the history: that node had adopted the
|
|
274
|
+
edit whose file is now missing, which is the precise condition for a legitimate
|
|
275
|
+
deletion, so its own watcher states the removal and every peer is right to obey
|
|
276
|
+
it. Three detectors were built for it and each one suppressed ordinary work — a
|
|
277
|
+
rename's target, an atomic save, a create/delete/recreate. The test carries that
|
|
278
|
+
measurement and runs on every gate, so it turns red the day a protection exists.
|
|
279
|
+
The field shape — a backup restored while the agent is **stopped** — is covered,
|
|
280
|
+
because that node joins and `planJoin` renames what the history removed into
|
|
281
|
+
`.fsagent-recovered/`.
|
|
282
|
+
|
|
283
|
+
---
|
|
284
|
+
|
|
285
|
+
## 3. The conventions, and why each exists
|
|
286
|
+
|
|
287
|
+
**`it.fails` for a known-red test, never `it.skip`.** An inverted test passes
|
|
288
|
+
while the body fails and turns red the day it starts working, with "this works
|
|
289
|
+
now — remove the inversion and let it gate". A skipped test is silent in both
|
|
290
|
+
directions and relies on somebody remembering to come back. Ten were committed
|
|
291
|
+
inverted during the edit-chain work; **nine are now ordinary assertions and
|
|
292
|
+
there are no skips anywhere in the package.**
|
|
293
|
+
|
|
294
|
+
**One inversion remains, and it is a proof rather than a backlog item.** *A node
|
|
295
|
+
reverted to an older copy does not drag the fleet back*
|
|
296
|
+
(`fs-mesh-wiped-and-reverted.spec.ts`) carries its own argument: the reverted
|
|
297
|
+
node had ADOPTED the edit whose file is now missing, which is the exact
|
|
298
|
+
condition for a legitimate deletion, so under a live agent the two are not
|
|
299
|
+
separable from the chain. Three detectors were built and every one of them
|
|
300
|
+
suppressed ordinary work — a rename's target, an atomic save, a
|
|
301
|
+
create/delete/recreate — because authorship claims are recorded *after* the
|
|
302
|
+
push being judged. Closing it needs the **L1 approval path**: a human deciding
|
|
303
|
+
whether a bulk disappearance is a restore or a deletion, which is a product
|
|
304
|
+
decision and not a defect in this package. The field shape that matters today
|
|
305
|
+
(a backup restored while the agent is stopped, then a join) is covered by
|
|
306
|
+
`planJoin`'s recover bucket and is green.
|
|
307
|
+
|
|
308
|
+
**A pass count is a sample, not a measurement.** These suites carry several
|
|
309
|
+
units of run-to-run variance — more than most fixes move. A change is confirmed
|
|
310
|
+
by a run that *isolates* it, repeated: three for a signal, eight before calling
|
|
311
|
+
a mesh scenario fixed. This rule exists because a "6/8 → 4/8 regression" was
|
|
312
|
+
once reported from three runs whose only difference was a guard that logged
|
|
313
|
+
zero hits.
|
|
314
|
+
|
|
315
|
+
**Assert WHAT, not HOW MANY.** The catch-up cost test asserted "at most two
|
|
316
|
+
blobs" and measured three; the third was the writer's own in-flight push and
|
|
317
|
+
the second a blob the node already held. Rewritten to name the contents
|
|
318
|
+
touched, it reports one blob on every run. A bound raised to swallow a known
|
|
319
|
+
failure stops measuring anything.
|
|
320
|
+
|
|
321
|
+
**`ORIGIN_FIXTURE` says what is true of a fixture.** A folder with files and no
|
|
322
|
+
history defers its first announcement and asks the network for its state first,
|
|
323
|
+
because announcing over an established fleet is how a restored backup drags it
|
|
324
|
+
back. Nearly every fixture here has exactly that shape and almost none has a
|
|
325
|
+
peer with a history to wait for, so `{ joinWaitMs: 0 }` states "this folder is
|
|
326
|
+
the first state of its own history". It is not a way around the behaviour — a
|
|
327
|
+
test that means to exercise joining sets a real wait.
|
|
328
|
+
|
|
329
|
+
**Goldens** are snapshots reviewed by a human: `pnpm updateGoldens`, then read
|
|
330
|
+
the diff. `test/goldens/example.log` snapshots the agent's own field layout, so
|
|
331
|
+
adding a field is expected to change it.
|
|
332
|
+
|
|
333
|
+
---
|
|
334
|
+
|
|
335
|
+
## 4. What this suite cannot answer
|
|
336
|
+
|
|
337
|
+
Named rather than implied.
|
|
338
|
+
|
|
339
|
+
Of the 23 end-to-end file-sync scenarios an integration environment runs, 14 are answered here at a tier that fails
|
|
340
|
+
the build. The rest are of two honest kinds:
|
|
341
|
+
|
|
342
|
+
- **A budget or a size.** Sync latency, the cold-start budget, and the 44 MB
|
|
343
|
+
file that is a realistic production number. A budget asserted on a developer
|
|
344
|
+
laptop measures the laptop.
|
|
345
|
+
- **An environment this suite does not have.** A Windows file lock (the one
|
|
346
|
+
thing on the list a mesh on macOS cannot settle — it wants a Windows
|
|
347
|
+
runner), the OS watcher at a scale that overwhelms it, a transport limit, and
|
|
348
|
+
the real production folder across four workstations.
|
|
349
|
+
|
|
350
|
+
Open items are in
|
|
351
|
+
[README.public.md § Known constraints](README.public.md#known-constraints).
|
|
352
|
+
|
|
353
|
+
---
|
|
354
|
+
|
|
355
|
+
## 5. File index
|
|
356
|
+
|
|
357
|
+
Counts are what `pnpm test` reports per file, so suites that generate cases in a
|
|
358
|
+
loop are counted as they run. They sum to the 923 above.
|
|
359
|
+
|
|
360
|
+
### Mesh tier
|
|
361
|
+
|
|
362
|
+
| file | n | what it covers |
|
|
363
|
+
| --- | --- | --- |
|
|
364
|
+
| `mesh/fs-mesh.spec.ts` | 6 | T1–T7, the scenarios the sync has to survive |
|
|
365
|
+
| `mesh/fs-mesh-field-defects.spec.ts` | 10 | F1–F10, field defects reduced in process |
|
|
366
|
+
| `mesh/fs-mesh-matrix.spec.ts` | 9 | the scenario matrix at mesh tier (L7, L8, I7, I10, J4+J5, J9 ×2) |
|
|
367
|
+
| `mesh/fs-mesh-invariants.spec.ts` | 7 | invariants over the route, not the destination |
|
|
368
|
+
| `mesh/fs-mesh-wiped-and-reverted.spec.ts` | 6 | a node comes back empty, or holding an older copy |
|
|
369
|
+
| `mesh/fs-mesh-additive.spec.ts` | 3 | additive reconciliation (A1–A3) |
|
|
370
|
+
| `mesh/fs-mesh-catchup-cost.spec.ts` | 2 | coming back does not cost what you missed |
|
|
371
|
+
| `fs-editor-patterns.spec.ts` | 6 | how real programs save |
|
|
372
|
+
| `fs-chain-crosses-the-wire.spec.ts` | 4 | the chain crosses the wire |
|
|
373
|
+
| `field-repro.spec.ts` | 3 | reported failures, reproduced verbatim |
|
|
374
|
+
|
|
375
|
+
### Client–server tier
|
|
376
|
+
|
|
377
|
+
| file | n | what it covers |
|
|
378
|
+
| --- | --- | --- |
|
|
379
|
+
| `client-server/socket-mock.spec.ts` | 35 | the shared suite (`shared-sync-tests.ts`) over `SocketMock` |
|
|
380
|
+
| `client-server/socket-io.spec.ts` | 35 | the same shared suite over a real socket.io server at production's 50 MB limit |
|
|
381
|
+
| `client-server/advanced-sync.spec.ts` | 15 | three clients, catch-up, teardown and restart, 10 MB, 100 files, rapid overwrites |
|
|
382
|
+
| `client-server/heals-after-forced-divergence.spec.ts` | 15 | deliberately dropped messages |
|
|
383
|
+
| `client-server/conflict-sync.spec.ts` | 2 | a real offline divergent edit, both versions preserved |
|
|
384
|
+
| `client-server/simultaneous-edit.spec.ts` | 4 | five rounds of three nodes contesting one file |
|
|
385
|
+
|
|
386
|
+
### Unit and decision tier
|
|
387
|
+
|
|
388
|
+
| file | n | what it covers |
|
|
389
|
+
| --- | --- | --- |
|
|
390
|
+
| `fs-agent.spec.ts` | 90 | the agent's surface |
|
|
391
|
+
| `fs-scanner.spec.ts` | 56 | scanning, watching, the scan cache |
|
|
392
|
+
| `fs-conflict-resolver.spec.ts` | 41 | tip ordering, winners, three-way merge, copy naming |
|
|
393
|
+
| `fs-anti-entropy.spec.ts` | 38 | the repair decision, by example |
|
|
394
|
+
| `fs-manifest.spec.ts` | 46 | buckets, digests, reconciliation plans |
|
|
395
|
+
| `fs-agent-degradation.spec.ts` | 89 | what the agent does when a dependency fails, and the shapes no scenario reaches |
|
|
396
|
+
| `fs-collect-removals.spec.ts` | 31 | the removal walk |
|
|
397
|
+
| `fs-bucket-sync.spec.ts` | 29 | the wire format |
|
|
398
|
+
| `fs-ignore.spec.ts` | 28 | glob ignore patterns, and every legacy prefix |
|
|
399
|
+
| `fs-blob-adapter.spec.ts` | 26 | file ↔ blob |
|
|
400
|
+
| `fs-edit-chain.spec.ts` | 20 | the chain |
|
|
401
|
+
| `fs-plan-removals.spec.ts` | 23 | which removals may be applied |
|
|
402
|
+
| `fs-agent-mass-delete-guard.spec.ts` | 16 | refusing a deletion that looks like a loss, and reporting it |
|
|
403
|
+
| `fs-agent-concurrent-write.spec.ts` | 9 | two writes of one path must not blend — 200 rounds per assertion |
|
|
404
|
+
| `fs-agent-stale-reconnect.spec.ts` | 17 | a peer reconnecting with a stale tree |
|
|
405
|
+
| `fs-scanner-vanish.spec.ts` | 12 | an entry that vanishes mid-scan |
|
|
406
|
+
| `fs-classify.spec.ts` | 11 | behind / ahead / fork / incomplete |
|
|
407
|
+
| `fs-anti-entropy-level1.spec.ts` | 12 | the same decision, **enumerated** |
|
|
408
|
+
| `fs-agent-tombstone-log.spec.ts` | 14 | what a restart remembers it deleted |
|
|
409
|
+
| `fs-plan-join.spec.ts` | 9 | joining, decided before anything is written |
|
|
410
|
+
| `fs-agent-incremental-restore.spec.ts` | 8 | a restore writes only what changed |
|
|
411
|
+
| `fs-agent-locked-file.spec.ts` | 8 | a file held open by another process |
|
|
412
|
+
| `fs-agent-inbound-verdict.spec.ts` | 7 | is an inbound ref news to this agent |
|
|
413
|
+
| `fs-agent-anti-entropy.spec.ts` | 7 | the anti-entropy wiring |
|
|
414
|
+
| `fs-ref-vs-content.spec.ts` | 6 | ref identity vs content identity |
|
|
415
|
+
| `fs-filetype-changes.spec.ts` | 6 | a path changes what it is |
|
|
416
|
+
| `fs-agent-no-laundering.spec.ts` | 6 | a node does not re-advertise what it adopted |
|
|
417
|
+
| `fs-db-adapter.spec.ts` | 6 | storing a tree with its predecessors |
|
|
418
|
+
| `fs-agent-conflict-log.spec.ts` | 5 | recording a resolved conflict |
|
|
419
|
+
| `fs-conflict-integration.spec.ts` | 6 | conflict resolution end to end |
|
|
420
|
+
| `fs-filenames.spec.ts` | 5 | unicode and case |
|
|
421
|
+
| `fs-level2-surfaces.spec.ts` | 5 | the model must be able to EXPRESS it |
|
|
422
|
+
| `blob-io.spec.ts` | 5 | storing a file as a blob |
|
|
423
|
+
| `fs-agent-ancestry-warning.spec.ts` | 4 | a transport with no ancestry must say so |
|
|
424
|
+
| `fs-divergence-is-content.spec.ts` | 4 | a divergence is a difference in CONTENT |
|
|
425
|
+
| `fs-hostile-tree.spec.ts` | 7 | a peer's tree is not trusted with paths |
|
|
426
|
+
| `fs-impossible-filename.spec.ts` | 4 | a path the filesystem refuses |
|
|
427
|
+
| `fs-scanner-scan-coalescing.spec.ts` | 4 | a burst collapses into at most two passes |
|
|
428
|
+
| `fs-agent-silent-joiner.spec.ts` | 4 | an agent with nothing to say does not speak |
|
|
429
|
+
| `fs-stage-timings.spec.ts` | 4 | per-stage timings |
|
|
430
|
+
| `fs-agent-authorship.spec.ts` | 3 | a node claims only what it changed |
|
|
431
|
+
| `fs-agent-blob-stream.spec.ts` | 3 | a restore streams the blob |
|
|
432
|
+
| `fs-clock-skew.spec.ts` | 6 | a file is visible whatever its timestamp says |
|
|
433
|
+
| `fs-disk-full.spec.ts` | 3 | a full disk |
|
|
434
|
+
| `fs-scale.spec.ts` | 3 | scale and endurance |
|
|
435
|
+
| `fs-slow-copy.spec.ts` | 3 | a file being written is not distributed half-done |
|
|
436
|
+
| `fs-agent-announced-heads.spec.ts` | 2 | parked announcement heads, and their cap |
|
|
437
|
+
| `fs-agent-rescan-commits.spec.ts` | 2 | a change found only by the safety rescan |
|
|
438
|
+
| `fs-agent-self-parent.spec.ts` | 2 | a push that parents itself |
|
|
439
|
+
| `fs-rename-folder.spec.ts` | 2 | renaming a folder |
|
|
440
|
+
| `fs-agent-own-echo.spec.ts` | 1 | its own advertisement echoed back |
|
|
441
|
+
| `fs-agent-send-retires-left-state.spec.ts` | 1 | leaving a state retires it |
|
|
442
|
+
| `example.spec.ts` | 1 | the README example, against a golden |
|
|
443
|
+
| `setup/goldens.spec.ts` | 1 | the golden mechanism itself |
|
package/dist/README.trouble.md
CHANGED
|
@@ -8,16 +8,78 @@ found in the LICENSE file in the root of this package.
|
|
|
8
8
|
|
|
9
9
|
# Trouble shooting
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
Development and test-environment problems. For problems **running** the agent,
|
|
12
|
+
see [README.public.md](README.public.md#troubleshooting).
|
|
12
13
|
|
|
13
|
-
- [
|
|
14
|
+
- [Tests fail in ways that do not reproduce](#tests-fail-in-ways-that-do-not-reproduce)
|
|
15
|
+
- [A test leaves folders behind](#a-test-leaves-folders-behind)
|
|
16
|
+
- [The coverage gate fails but every test passes](#the-coverage-gate-fails-but-every-test-passes)
|
|
17
|
+
- [A golden fails after an unrelated change](#a-golden-fails-after-an-unrelated-change)
|
|
18
|
+
- [A mesh test hangs instead of failing](#a-mesh-test-hangs-instead-of-failing)
|
|
19
|
+
- [VS Code on Windows: debugging is not working](#vs-code-on-windows-debugging-is-not-working)
|
|
14
20
|
|
|
15
|
-
##
|
|
21
|
+
## Tests fail in ways that do not reproduce
|
|
22
|
+
|
|
23
|
+
Run the suite the way `package.json` defines it. `vitest run` **without**
|
|
24
|
+
`--no-file-parallelism` puts twenty-six integration files — real servers, real
|
|
25
|
+
sockets, real watchers, real timers — in contention over the cores, and invents
|
|
26
|
+
failures that look exactly like product defects. Four different tests once
|
|
27
|
+
failed across four CI runs of the same commit, each passing on re-run.
|
|
28
|
+
|
|
29
|
+
If a single mesh scenario is flaky, that is information, not noise: run it
|
|
30
|
+
eight times before concluding anything either way.
|
|
31
|
+
|
|
32
|
+
## A test leaves folders behind
|
|
33
|
+
|
|
34
|
+
The mesh and client–server suites create `test-temp-*` directories in the
|
|
35
|
+
repository root and remove them in `afterEach`. A run killed mid-test leaves
|
|
36
|
+
them, and a stale one can make the next run read someone else's state:
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
rm -rf test-temp-*
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## The coverage gate fails but every test passes
|
|
43
|
+
|
|
44
|
+
Expected: the gate is 100 % on all four metrics. The text reporter **omits
|
|
45
|
+
fully covered files**, so an empty table means everything is covered, and any
|
|
46
|
+
file that appears is the one to look at — with its uncovered line numbers in
|
|
47
|
+
the last column.
|
|
48
|
+
|
|
49
|
+
Before reaching for `/* v8 ignore */`, check whether the branch is genuinely
|
|
50
|
+
unreachable. If it is, say why after `@preserve`. If it is reachable, it wants
|
|
51
|
+
a test.
|
|
52
|
+
|
|
53
|
+
## A golden fails after an unrelated change
|
|
54
|
+
|
|
55
|
+
`test/goldens/example.log` is a snapshot of the agent's own field layout, so
|
|
56
|
+
adding or removing a private field changes it legitimately:
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
pnpm updateGoldens
|
|
60
|
+
git diff test/goldens/ # READ this — that is the point of the step
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Accepting a golden without reading the diff is how a real behaviour change gets
|
|
64
|
+
recorded as a formatting one.
|
|
65
|
+
|
|
66
|
+
## A mesh test hangs instead of failing
|
|
67
|
+
|
|
68
|
+
`converged()` and `settlesOn()` poll until a timeout. A hang to the end of the
|
|
69
|
+
timeout means the fleet never agreed, and `whyNot(result)` names the paths that
|
|
70
|
+
differ — assert on it rather than on `converged` alone, or the failure message
|
|
71
|
+
tells you nothing.
|
|
72
|
+
|
|
73
|
+
A node that was `cut()` and never `heal()`ed will never converge. In the
|
|
74
|
+
harness, `cut` is both directions, `mute` is outbound only, `deafen` is inbound
|
|
75
|
+
only, and `down`/`up` stop and restart the agent while leaving the folder
|
|
76
|
+
reachable.
|
|
77
|
+
|
|
78
|
+
## VS Code on Windows: debugging is not working
|
|
16
79
|
|
|
17
80
|
Date: 2025-03-08
|
|
18
81
|
|
|
19
|
-
⚠️
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
resolved.
|
|
82
|
+
⚠️ On Windows, check the repository out on drive C. There is a bug in the VS
|
|
83
|
+
Code Vitest extension (v1.14.4) that prevents test debugging from working:
|
|
84
|
+
<https://github.com/vitest-dev/vscode/issues/548>. Check from time to time
|
|
85
|
+
whether it has been fixed, and remove this note when it has.
|