@rljson/fs-agent 0.0.84 → 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 +3768 -405
- 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
|
@@ -8,29 +8,115 @@ found in the LICENSE file in the root of this package.
|
|
|
8
8
|
|
|
9
9
|
# Contributors Guide
|
|
10
10
|
|
|
11
|
-
- [
|
|
12
|
-
- [
|
|
13
|
-
- [
|
|
14
|
-
- [
|
|
11
|
+
- [The gate](#the-gate)
|
|
12
|
+
- [Before you change the sync](#before-you-change-the-sync)
|
|
13
|
+
- [How to measure a change](#how-to-measure-a-change)
|
|
14
|
+
- [Test conventions](#test-conventions)
|
|
15
|
+
- [Setup, develop, administrate](#setup-develop-administrate)
|
|
16
|
+
- [Pinned dependencies](#pinned-dependencies)
|
|
15
17
|
|
|
16
|
-
##
|
|
18
|
+
## The gate
|
|
17
19
|
|
|
18
|
-
|
|
20
|
+
```bash
|
|
21
|
+
pnpm test # vitest --coverage --no-file-parallelism, then eslint
|
|
22
|
+
pnpm updateGoldens # re-record the snapshots, then READ the diff
|
|
23
|
+
```
|
|
19
24
|
|
|
20
|
-
|
|
25
|
+
**100 % on statements, branches, functions and lines**, and it is enforced.
|
|
26
|
+
Two things follow from that:
|
|
21
27
|
|
|
22
|
-
|
|
28
|
+
- **Never add `/* v8 ignore */` to avoid testing reachable code.** The marker
|
|
29
|
+
is for a branch that genuinely cannot be taken, and it must say *why* after
|
|
30
|
+
`@preserve`. Forty-nine of the markers here carry no reason, and seven dead
|
|
31
|
+
ones hid among them for months — a whole constructor pattern that never
|
|
32
|
+
worked, kept reachable by two tests that asserted nothing.
|
|
33
|
+
- **100 % coverage does not mean anything was checked.** A test with no
|
|
34
|
+
`expect(` is not a test. If you find one, it is usually the only thing
|
|
35
|
+
keeping dead code alive.
|
|
23
36
|
|
|
24
|
-
|
|
37
|
+
`--no-file-parallelism` is not a preference. Twenty-six files drive real
|
|
38
|
+
servers, sockets, watchers and timers; in parallel they fight over the cores
|
|
39
|
+
and invent failures.
|
|
25
40
|
|
|
26
|
-
##
|
|
41
|
+
## Before you change the sync
|
|
27
42
|
|
|
28
|
-
Read
|
|
43
|
+
Read these first — each is short, and each records a defect that cost real
|
|
44
|
+
data:
|
|
29
45
|
|
|
30
|
-
|
|
46
|
+
1. [The design in one page](README.architecture.md#the-design-in-one-page) —
|
|
47
|
+
five paragraphs, and the constraint everything follows from.
|
|
48
|
+
2. **An absence is not a deletion.** Four separate rules were built to infer a
|
|
49
|
+
deletion from a tree's silence and all four were withdrawn. If a change you
|
|
50
|
+
are making needs to know "did the sender delete this or never have it",
|
|
51
|
+
stop: the answer is not available, which is why removals are stated.
|
|
52
|
+
3. **A node claims only what it changed.**
|
|
53
|
+
[Authorship](README.architecture.md#authorship-a-node-claims-only-what-it-changed)
|
|
54
|
+
— including the trap that claims are recorded *after* the push being judged,
|
|
55
|
+
so a node is a stranger to its own newest work at that moment.
|
|
56
|
+
4. **No `await` in the push path.** The yield between "this is what I am
|
|
57
|
+
announcing" and "this is the entry for it" lets another apply land in the
|
|
58
|
+
middle. That alone cost a node its place in a ten-round run.
|
|
59
|
+
changing is a row there, that row names the test that must still pass.
|
|
31
60
|
|
|
32
|
-
|
|
61
|
+
## How to measure a change
|
|
33
62
|
|
|
34
|
-
|
|
63
|
+
**A pass count is a sample, not a measurement.** These suites carry several
|
|
64
|
+
units of run-to-run variance — more than most fixes move.
|
|
35
65
|
|
|
36
|
-
|
|
66
|
+
- Confirm a change with a run that **isolates** it (`-t "<name>"`, one file),
|
|
67
|
+
**repeated**: three for a signal, **eight** before calling a mesh scenario
|
|
68
|
+
fixed.
|
|
69
|
+
- Never compare two runs that differ in more than one change. A
|
|
70
|
+
"6/8 → 4/8 regression" was once reported here from three runs whose only
|
|
71
|
+
difference was a guard that logged zero hits.
|
|
72
|
+
- **Run the control.** A "conflicted copy" fix was once built on a theory a
|
|
73
|
+
control run then disproved — there was nothing to copy.
|
|
74
|
+
- **Assert WHAT, not HOW MANY.** A cost test asserted "at most two blobs" and
|
|
75
|
+
measured three; the third was the writer's own in-flight push and the second
|
|
76
|
+
a blob the node already held. Naming the contents made it one, every run.
|
|
77
|
+
- A bound raised to swallow a known failure stops measuring anything.
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
# one scenario, repeated
|
|
81
|
+
for i in $(seq 1 8); do pnpm exec vitest run test/mesh/fs-mesh.spec.ts \
|
|
82
|
+
-t "T4" --coverage.enabled=false; done
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Test conventions
|
|
86
|
+
|
|
87
|
+
- **`it.fails` for a known-red test, never `it.skip`.** An inverted test passes
|
|
88
|
+
while the body fails and turns red the day it starts working. A skip is
|
|
89
|
+
silent in both directions. Nine were committed inverted during the
|
|
90
|
+
edit-chain work and all nine are now ordinary assertions.
|
|
91
|
+
- **A skip must carry its argument.** The one skip left in the package is a
|
|
92
|
+
proof that the case is not decidable, written into the test.
|
|
93
|
+
- **`ORIGIN_FIXTURE`** (`{ joinWaitMs: 0 }`) says "this folder is the first
|
|
94
|
+
state of its own history". Use it where that is true; set a real wait where
|
|
95
|
+
the test means to exercise joining.
|
|
96
|
+
- **Tiers matter.** A decision-tier test proves a RULE, not that the rule is
|
|
97
|
+
reached — and this package has had defects in the reaching, not the rule. See
|
|
98
|
+
[README.tests.md](README.tests.md).
|
|
99
|
+
- **Goldens are reviewed, not accepted.** `pnpm updateGoldens` then read the
|
|
100
|
+
diff. `test/goldens/example.log` snapshots the agent's own field layout, so
|
|
101
|
+
adding a field is expected to change it.
|
|
102
|
+
|
|
103
|
+
## Setup, develop, administrate
|
|
104
|
+
|
|
105
|
+
| | |
|
|
106
|
+
| --- | --- |
|
|
107
|
+
| Machine setup | [doc/prepare.md](doc/prepare.md) |
|
|
108
|
+
| The development loop | [doc/develop.md](doc/develop.md) |
|
|
109
|
+
| Debugging in VS Code | [doc/debug-with-vscode.md](doc/debug-with-vscode.md) |
|
|
110
|
+
| Repository and ruleset setup | [doc/create-new-repo.md](doc/create-new-repo.md) |
|
|
111
|
+
| Fast coding | [doc/fast-coding-guide.md](doc/fast-coding-guide.md) |
|
|
112
|
+
| Code review | [doc/code-review.md](doc/code-review.md) |
|
|
113
|
+
| Goldens | [doc/update-goldens.md](doc/update-goldens.md) |
|
|
114
|
+
|
|
115
|
+
## Pinned dependencies
|
|
116
|
+
|
|
117
|
+
**Do NOT update ESLint to v10.x.** The package is pinned to `eslint ~9.39.2`
|
|
118
|
+
because `eslint-plugin-tsdoc@0.5.0` is incompatible with ESLint v10's API
|
|
119
|
+
changes — `context.getSourceCode()` was removed. Updating breaks the build.
|
|
120
|
+
|
|
121
|
+
**Bumping an `@rljson/*` dependency needs the `pnpm.overrides` entry too**, or
|
|
122
|
+
the old version stays installed and nothing tells you.
|
package/dist/README.md
CHANGED
|
@@ -8,17 +8,46 @@ found in the LICENSE file in the root of this package.
|
|
|
8
8
|
|
|
9
9
|
# @rljson/fs-agent
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
**Keeps a folder on several machines the same, without a central authority
|
|
12
|
+
deciding what the folder contains.**
|
|
12
13
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
Each machine watches its own folder, writes down what changed, and tells the
|
|
15
|
+
others. A hub relays and never arbitrates. Two people editing at once get one
|
|
16
|
+
agreed result with both versions kept; a machine switched off for a week
|
|
17
|
+
catches up without replaying the week; and a deletion travels as a stated fact
|
|
18
|
+
rather than being inferred from a file being missing — which is the design
|
|
19
|
+
decision everything else follows from.
|
|
16
20
|
|
|
17
|
-
|
|
21
|
+
```bash
|
|
22
|
+
npm install @rljson/fs-agent
|
|
23
|
+
pnpm test # 70 files, 923 scenarios, 100 % coverage, then eslint
|
|
24
|
+
```
|
|
18
25
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
|
22
|
-
|
|
|
23
|
-
| [README.
|
|
24
|
-
| [README.
|
|
26
|
+
## Where to start
|
|
27
|
+
|
|
28
|
+
| if you are | read |
|
|
29
|
+
| --- | --- |
|
|
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 |
|
|
32
|
+
| **changing the sync** | [README.architecture.md](README.architecture.md) — the mechanism, and why each rule exists |
|
|
33
|
+
| **calling the API** | [README.api.md](README.api.md) — every export, grouped by module, with what it costs |
|
|
34
|
+
| **setting the repo up** | [README.contributors.md](README.contributors.md) — run, debug, build, publish |
|
|
35
|
+
| **stuck** | [README.trouble.md](README.trouble.md) |
|
|
36
|
+
|
|
37
|
+
## Reference
|
|
38
|
+
|
|
39
|
+
| document | what is in it |
|
|
40
|
+
| --- | --- |
|
|
41
|
+
| [doc/safety-rescan.md](doc/safety-rescan.md) | the periodic rescan, and the watcher gaps it covers |
|
|
42
|
+
| [doc/develop.md](doc/develop.md) · [doc/prepare.md](doc/prepare.md) | the development loop and machine setup |
|
|
43
|
+
| [src/client-server/README.md](src/client-server/README.md) | the client–server rules, with a component diagram |
|
|
44
|
+
| [CHANGELOG.md](CHANGELOG.md) | releases |
|
|
45
|
+
| [README.blog.md](README.blog.md) | notes, newest last |
|
|
46
|
+
|
|
47
|
+
## Before you upgrade an existing fleet
|
|
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).
|