@uuaid/pillar 2.6.1 → 2.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/README.md +325 -7
  2. package/bin/carrier.mjs +21 -0
  3. package/bin/pillar-ask.mjs +4 -1
  4. package/bin/pillar-blob.mjs +6 -0
  5. package/bin/pillar-directory.mjs +282 -16
  6. package/bin/pillar-escrow.mjs +4 -1
  7. package/bin/pillar-group-v2.mjs +6 -0
  8. package/bin/pillar-notify.mjs +13 -0
  9. package/bin/pillar-responder.mjs +266 -23
  10. package/bin/pillar.mjs +512 -257
  11. package/package.json +17 -25
  12. package/src/cli-help.mjs +23 -0
  13. package/src/group-v2-cli.mjs +1 -1
  14. package/src/identity/trust.mjs +72 -6
  15. package/src/mailbox/mailbox.mjs +313 -12
  16. package/src/net/carrier-server.mjs +34 -2
  17. package/src/net/refusals.mjs +2 -0
  18. package/src/net/seed-registry.mjs +2 -1
  19. package/src/net/transport.mjs +320 -91
  20. package/src/node-check.mjs +29 -8
  21. package/src/notify-events.mjs +148 -0
  22. package/src/notify-log.mjs +124 -0
  23. package/src/notify-runner.mjs +372 -0
  24. package/src/notify-store.mjs +736 -0
  25. package/src/notify.mjs +350 -0
  26. package/src/pillar.mjs +382 -27
  27. package/src/readers.mjs +2 -2
  28. package/src/registry/federation.mjs +3056 -0
  29. package/src/registry/gossip.mjs +294 -0
  30. package/src/registry/heartbeats.mjs +205 -0
  31. package/src/registry/lineage-verifier.mjs +972 -0
  32. package/src/registry/lineage.mjs +984 -0
  33. package/src/registry/listings.mjs +612 -0
  34. package/src/registry/resolve.mjs +376 -0
  35. package/src/registry/stats.mjs +508 -0
  36. package/src/sqlite-loader.mjs +40 -0
  37. package/src/vendor/pillar-core.mjs +22 -0
  38. package/src/vendor/uuaid-soul.mjs +2246 -0
  39. package/src/vnext/a6b-common.mjs +270 -0
  40. package/src/vnext/b1-cli.mjs +970 -0
  41. package/src/vnext/card-cli.mjs +370 -0
  42. package/src/vnext/greeter-operator.mjs +160 -0
  43. package/src/vnext/greeter-suggest.mjs +318 -0
  44. package/src/vnext/greeter.mjs +571 -0
  45. package/src/vnext/homes.mjs +48 -0
  46. package/src/vnext/init-cli.mjs +489 -0
  47. package/src/vnext/intro-cli.mjs +81 -0
  48. package/src/vnext/json-dir-mailbox.mjs +304 -0
  49. package/src/vnext/jsonl-mailbox.mjs +1132 -0
  50. package/src/vnext/knock-answer.mjs +162 -0
  51. package/src/vnext/knock-cli.mjs +520 -0
  52. package/src/vnext/knock-lane.mjs +312 -0
  53. package/src/vnext/knock-responder.mjs +344 -0
  54. package/src/vnext/lineage-cli.mjs +653 -0
  55. package/src/vnext/listing-cli.mjs +323 -0
  56. package/src/vnext/resolve-cli.mjs +104 -0
  57. package/src/vnext/soul-cli.mjs +666 -0
  58. package/src/vnext/verify-cli.mjs +333 -0
  59. package/src/vnext/w4-redirect.mjs +178 -0
  60. package/src/vnext/wave-a.mjs +193 -0
  61. package/src/vnext/witness-cli.mjs +547 -0
package/README.md CHANGED
@@ -15,9 +15,11 @@ exchanges encrypted, signed envelopes through the pillar network — a
15
15
  store-and-forward carrier mesh with a LimeWire/BitTorrent-style seed topology:
16
16
  no single carrier is the only store.
17
17
 
18
- **Minimal requirements:** Node.js >= 22, outbound HTTPS. That's it. Carrier
18
+ **Minimal requirements:** Node.js >= 20, outbound HTTPS. That's it. Carrier
19
19
  mode needs no inbound ports, no daemon, no account. One identity = one
20
- keychain file + one SQLite mailbox.
20
+ keychain file + one mailbox: SQLite when the optional `better-sqlite3` is
21
+ installed (it needs Node.js >= 22), else a JSONL store (`<home>/mailbox/`)
22
+ that suits small homes.
21
23
 
22
24
  ## Install
23
25
 
@@ -27,6 +29,66 @@ npm install -g @uuaid/pillar # global bins: pillar, pillar-carrier, pilla
27
29
  npm install @uuaid/pillar # then npx pillar ... / npx pillar-ask ...
28
30
  ```
29
31
 
32
+ **Direct peer-to-peer (optional).** Since 2.7.0, `@uuaid/pillar` is
33
+ carrier-only and has no libp2p in it. For direct delivery over libp2p (TCP,
34
+ WebSockets, circuit relay, DHT), also install the companion package
35
+ at the same version and pass `--libp2p` (or `pillar init --libp2p`):
36
+
37
+ ```sh
38
+ npm install -g @uuaid/pillar-p2p # same version as @uuaid/pillar
39
+ pillar recv --libp2p
40
+ ```
41
+
42
+ Without it, `--libp2p` refuses with `p2p-not-installed`, and a home that uses
43
+ libp2p and names no carrier refuses `recv` and `send` the same way.
44
+
45
+ ## Upgrading from 2.6.x
46
+
47
+ `npm install -g @uuaid/pillar` takes a 2.6.x install straight to 2.7.1, over
48
+ 2.7.0. These changes came with 2.7.0; read them before you upgrade a host.
49
+
50
+ 1. **libp2p is a separate package.** `@uuaid/pillar` is carrier-only and
51
+ never starts libp2p unless you pass `--libp2p` and install
52
+ `@uuaid/pillar-p2p` at the same version (see "Direct peer-to-peer" above).
53
+ A 2.6.x host that used libp2p runs carrier-only until you add both; if its
54
+ home also names no carrier, `recv` and `send` refuse with
55
+ `p2p-not-installed`.
56
+ 2. **`better-sqlite3` is optional.** A home without `mailbox.db` works
57
+ without it and keeps its mail in a JSONL store (`<home>/mailbox/`, for
58
+ small homes). A home that already has `mailbox.db` needs it: if the addon
59
+ cannot load (missing, not built, or built for another Node version),
60
+ pillar refuses with one line, `sqlite-not-installed: install or rebuild
61
+ optional dependency better-sqlite3 with npm i better-sqlite3`, and exits 1.
62
+ It never opens an empty second store beside your mail.
63
+ 3. **Node.js >= 20** (was >= 22). The SQLite store still needs Node.js >= 22.
64
+ 4. **Added, nothing removed:** the bin `pillar-notify` and the export
65
+ `@uuaid/pillar/vda`. Every bin, export and file of 2.6.1 is still there.
66
+ 5. **Mailbox schema:** one new table (`knocks`). 2.5.5 and 2.6.x still read a
67
+ `mailbox.db` that 2.7.x has opened.
68
+ 6. **Wake paths:** builds before 2.7.0 take no `notify/wake.lock`. Stop or
69
+ upgrade every older `pillar` process on a home before you run
70
+ `pillar recv --notify` there, and do not run it on a home another wake
71
+ service watches.
72
+ 7. **`--help` and `-h` on every bin** print usage and exit 0 without
73
+ touching anything. Before, `pillar-carrier --help` opened `carrier.db` and
74
+ listened, and `pillar-directory --help` minted a registry key in
75
+ `~/.pillar-directory`. An argument that is literally `-h` or `--help`
76
+ (before `--`) is now a help request.
77
+ 8. **`pillar notify` on a home with no `notify` block** writes nothing and
78
+ prints `{"enabled":false,"notified":0}`. Homes from before 2.7.0 are left
79
+ as they are; `pillar init` writes the block for new homes.
80
+ 9. **`peerIdFromEd25519Hex`** (exported from `@uuaid/pillar`) returns a plain
81
+ PeerId-like object built without libp2p: the same string, with
82
+ `toString()`, `type`, `publicKey.raw` and `multihash`. It is not a
83
+ `@libp2p/peer-id` instance, so convert it before you pass it to a libp2p
84
+ API. The input must be 64 hex characters.
85
+ 10. **A bare `pillar init`** (no `--carriers`, no `--offline`) writes
86
+ `carriers: ["https://pillar.uuaid.org"]` and `carrierOnly: true`. Use
87
+ `--offline` for a home with no carrier.
88
+ 11. **After you switch Node versions** with SQLite installed, rebuild it:
89
+ `npm rebuild better-sqlite3`. An addon built for another Node major can
90
+ crash the process instead of falling back to JSONL.
91
+
30
92
  ## Quick start — become an addressable agent in 3 commands
31
93
 
32
94
  ```sh
@@ -52,7 +114,12 @@ pillar inbox --notify 'osascript -e "display notification ..."' # hook when mai
52
114
 
53
115
  For automated checking, put `pillar inbox --notify <cmd>` on a cron/launchd
54
116
  interval — the hook gets `PILLAR_NEW` / `PILLAR_UNREAD` / `PILLAR_UUAID` env
55
- vars and a JSON summary on stdin, and only fires when there is mail.
117
+ vars and a JSON summary on stdin, and only fires when there is mail. The hook
118
+ runs only while no other wake path (`recv --notify`, `pillar notify`, a bridged
119
+ `recv`, `pillar-responder --command`) holds the home's `notify/wake.lock`;
120
+ otherwise it is skipped with one stderr line and the exit code stays 0. The
121
+ hook gets 10 s: after that its process group is killed (one stderr line; the
122
+ exit code still stays 0).
56
123
 
57
124
  If every configured carrier fails, `inbox` behaves as 2.5.5 did: it prints
58
125
  each refusal as `<code>: <fix>` on stderr (any other failure as the error
@@ -80,7 +147,7 @@ inbox — every reader sees every message, whoever pulled it:
80
147
  ```sh
81
148
  pillar inbox --reader planner --mark-read # or PILLAR_READER=planner
82
149
  pillar inbox --reader auditor # sees the same mail, independently
83
- pillar recv --reader bridge # a daemon can be a named reader too
150
+ pillar recv --reader daemon # a daemon can be a named reader too
84
151
  pillar readers # each reader, its cursor, unseen count, live leases
85
152
  ```
86
153
 
@@ -92,6 +159,15 @@ reader last looked (naming the process and its directory), or when a live
92
159
  are flagged too. `pillar-responder` and `pillar-ask` still want their own
93
160
  identity/home: they act on first arrival, which a cursor cannot share.
94
161
 
162
+ A `pillar recv` with the Zestro bridge (`--zestro-bridge` or `PILLAR_ZESTRO_URL`)
163
+ is a wake path: it forwards each message as an agent command. It and
164
+ `pillar recv --notify` (or the one-shot `pillar notify`) are mutually exclusive
165
+ on one home: whichever starts second exits 64 with "two wake paths", and only
166
+ one bridged recv runs per home. A bridged recv writes no notify eligibility
167
+ events. A plain `pillar recv` or `pillar inbox` reader (without `--notify`) is
168
+ not a wake path and runs beside either. `pillar inbox --notify CMD` is a wake
169
+ path while its hook runs: see "One wake path per home" below.
170
+
95
171
  ### Mailbox: local message erasure (library)
96
172
 
97
173
  `pillar.mailbox.eraseRows(selector)` synchronously redacts inbox **and**
@@ -200,6 +276,164 @@ while pillar wait --reader bot; do
200
276
  done
201
277
  ```
202
278
 
279
+ A loop like this is your own wake path. `pillar wait` takes no
280
+ `notify/wake.lock`, so pillar cannot see it: run one loop per home, and do not
281
+ run it beside `recv --notify`, a bridged `recv` or `pillar-responder
282
+ --command` on the same home.
283
+
284
+ ### New-mail notices: `pillar recv --notify`
285
+
286
+ `pillar init` writes `notify` into `config.json` (`enabled: true`; kinds
287
+ `message`, `reply`, `request`; no hook). `pillar init --no-notify` writes
288
+ `enabled: false`. `init --refresh` and `init --force` never add or change it.
289
+ `init` installs and starts nothing.
290
+
291
+ **Eligibility events.** With `notify` enabled, every process that stores mail
292
+ for the home (`recv`, `inbox`, named or not) writes one event to
293
+ `notify/state.json` per envelope, after signature, decryption, the trust
294
+ verdict and group admission. Knocks, duplicates, quarantined or erased rows,
295
+ blocked senders, group control messages and groups not yet admitted give
296
+ none; an accepted held-group release gives one. A manual quarantine release
297
+ gives none. Acks give none unless `notify.acks` is `"outbox"`, and then only
298
+ the first ack of a message you sent, from its recipient. An envelope is
299
+ noticed at most once per home, whichever process stored it.
300
+
301
+ **The hook.** Set it in `config.json`; it is never taken from a command line:
302
+
303
+ ```json
304
+ "notify": { "enabled": true, "hook": { "exec": "/absolute/path/to/wake-agent", "args": ["--fixed", "args"] } }
305
+ ```
306
+
307
+ `exec` must be an absolute path to a regular executable file that group and
308
+ others cannot write, owned by you or root, in a directory that group and
309
+ others cannot write; the resolved real path is what runs. It runs with no shell, its own process group, the home as
310
+ its working directory, and only `PILLAR_NEW` and `PILLAR_UUAID` in its
311
+ environment (put compound commands in a wrapper script). Its stdin is one line
312
+ of JSON, at most 32 records and 16 KiB, metadata only — never message text:
313
+
314
+ ```json
315
+ {"v":"pillar-notify/1","uuaid":"<this home>","new":3,"records":[{"id":"env-…","from":"uuaid:…","kind":"message","at":"<local receipt time>"}],"more":2}
316
+ ```
317
+
318
+ `inReplyTo` appears only when it names a message you sent to that sender.
319
+ Fields that fail their protocol checks are counted in `more`, not listed. The
320
+ hook's output is discarded (counted only). After 10 s (`notify.timeoutS`, 1-10)
321
+ its process group gets SIGTERM, then SIGKILL, and is reaped. When the hook
322
+ exits, anything it left running in its process group is killed too (a process
323
+ that calls `setsid` has left the group and is not reached). One hook runs at a
324
+ time per home.
325
+
326
+ **Main path:** keep `pillar recv --home H --notify` running. Print a unit,
327
+ review it, and install it yourself; units carry no command text and no timer,
328
+ and send stdout and stderr to `/dev/null`. The wake path's status (counts, the
329
+ last run and the last error code, no sender data) is in `notify/status.json`.
330
+ In `--notify` mode every stderr line is also written to `notify/recv.log`
331
+ (0600, rotated at 256 KiB into `recv.1.log`): control characters escaped,
332
+ words cut to 64 characters, lines to 400, at most 30 lines a minute (the rest
333
+ counted). `--notify` refuses to run with the Zestro bridge (`--zestro-bridge`
334
+ or `PILLAR_ZESTRO_URL`): exit 64, "two wake paths". A problem with the files in
335
+ `notify/` never stops mail intake: `recv --notify` logs one line, receives
336
+ without notify, and retries every minute:
337
+
338
+ ```sh
339
+ pillar notify --print-unit launchd # KeepAlive LaunchAgent
340
+ pillar notify --print-unit systemd # Restart=always user service
341
+ ```
342
+
343
+ The first start of a wake path baselines at the tip: mail stored before it
344
+ is not noticed. A carrier wakes a waiting long-poll as soon as an envelope for
345
+ it is stored (the 400 ms re-read stays as a fallback). Measured on loopback:
346
+ send to hook start, median about 75 ms.
347
+
348
+ **Wake budget** (`notify.budget`, durable across restarts and both wake
349
+ paths): at least 30 s between hook starts (`minIntervalS`), at most 6 wakes
350
+ per rolling hour triggered by senders outside your address book
351
+ (`unknownPerHour`), one wake per sender per 10 min (`perPrincipalS`), 60 per
352
+ hour in total (`totalPerHour`), of which 12 (`priorityReserve`) only
353
+ `notify.priority` senders (your sensors and key contacts) may use. Optional
354
+ `notify.maxWakesPerDay` caps wakes in any rolling 24 h for every sender class
355
+ (`null`, the default, is off). Arrivals that cannot start a hook wait and are
356
+ coalesced into the next start. Mail delivery never waits on the budget. A limit
357
+ that is set but not a whole number in range stops both wake paths (exit 2)
358
+ instead of falling back to a default.
359
+
360
+ **Retry contract and crash window.** A notice is attempted at most once per
361
+ envelope. The claim is committed before the hook starts; if the process dies
362
+ while the hook runs, the next start marks that run `ambiguous` and does not
363
+ run it again. A failed or timed-out hook is not re-run. Events not yet claimed
364
+ survive a restart and are noticed once. A notice is lost (the mail itself is
365
+ kept) when the process dies between storing an envelope and writing its event,
366
+ or when the writer lock stays held through both tries of that write (10 s, a
367
+ short backoff, then 10 s more; counted as `notify.emit-failed`). Treat a
368
+ notice as a hint: the agent reads the mailbox for the mail.
369
+
370
+ **One wake path per home.** `notify/wake.lock` admits exactly one of: the
371
+ resident `recv --notify`, the one-shot fallback `pillar notify`, a `pillar
372
+ recv` with the Zestro bridge (in any process, named reader or not), or
373
+ `pillar inbox --notify CMD` while its hook runs, or `pillar-responder
374
+ --command` while it runs (kind `responder`). A second `recv --notify` or
375
+ fallback is refused as before; any pairing with the bridge or the responder,
376
+ in either order, exits 64 ("two wake paths"). `inbox --notify` skips its hook
377
+ when another wake path holds the lock (one stderr line; its output and exit
378
+ code are unchanged). A plain `pillar recv` or `pillar inbox` takes no lock.
379
+
380
+ On the same machine a live holder keeps the lock however long it is paused
381
+ (SIGSTOP, laptop sleep): only a dead pid, or a pid reused by another process
382
+ (the lock records the holder's start time), frees it. The start time is
383
+ seconds since 1970 UTC (`epoch:N`; on Linux the `/proc` start ticks,
384
+ `ticks:N`). It is read without the caller's environment, so processes in
385
+ different time zones or locales read the same value. A start time in another
386
+ or older format (`lstart:` from a 2.7.0 pre-release) counts as unknown: that
387
+ lock is not stale while its pid lives. A lock with no start time keeps the
388
+ 90 s wall-clock rule. "Same machine" means the same machine id (macOS
389
+ `IOPlatformUUID`, Linux `/etc/machine-id`; the lock stores a hash of it), so a
390
+ hostname change does not free a live holder; the hostname is used only when no
391
+ machine id can be read. On the same machine the holder only reads the lock (it
392
+ never rewrites it, so it cannot erase a new holder). A holder on another host must refresh it every 90 s; that refresh
393
+ reads and then rewrites the lock, so a takeover in the gap between the two can
394
+ be undone (a narrow window, cross-host only). A long-running holder re-reads the lock every 2 s
395
+ and before every hook or bridge command; if its token is gone it stops at once
396
+ (bridge closed, notifier stopped) and exits 75 with one stderr line. The
397
+ printed systemd unit restarts it after 10 s but not after a refusal
398
+ (`RestartPreventExitStatus=64`); launchd cannot filter exit codes, so a refused
399
+ resident under launchd retries every 10 s (`ThrottleInterval`) and is refused
400
+ again while the other wake path lives.
401
+
402
+ **Upgrading to 2.7.0.** Pillar builds before 2.7.0 take no `wake.lock`, so the
403
+ lock cannot see them. Before the first `recv --notify` on a home, stop or
404
+ upgrade every pre-2.7.0 `pillar` process that uses that home (a bridged `recv`,
405
+ an `inbox --notify` job, a responder).
406
+
407
+ **Other wake services.** Do not run `recv --notify` with a hook on a home that
408
+ another wake service already watches (a launchd, systemd or cron job with its
409
+ own `pillar wait` or `pillar inbox` loop). Pillar cannot see that service, so
410
+ each message would wake the agent twice. Retire the service, or keep the hook
411
+ off on that home.
412
+
413
+ **Fallback (one-shot):** `pillar notify` is for hosts that cannot keep a
414
+ process. It never pulls or stores mail and sends no receipts. It notices the
415
+ committed events (mail some reader of the home stored), under the same
416
+ budget, cursor and log, and runs the hook once for them. A one-round carrier
417
+ peek adds an unverified count (`"carrier": {"count": N, "verified": false,
418
+ "truncated": false}`) that never starts a hook. `truncated: true` means a
419
+ carrier answered a full page (200 envelopes) or an answer was abandoned, so
420
+ `count` is a lower bound. `pillar notify --print-unit cron` prints it as a
421
+ labelled fallback cron line; do not install it with the resident unit.
422
+
423
+ **Files.** `notify/` is 0700 and its files 0600: `state.json` (events, cursor,
424
+ budget, last run: one atomic commit, kept under 4 MiB on every write; an
425
+ event's `id` and `from` are stored only when they pass the protocol checks,
426
+ else `null`), `status.json` (bounded status for owners), `recv.log`,
427
+ `notifications.jsonl` (one line per
428
+ wake, rotated at 2,000 lines or 256 KiB, two old files kept up to 30 days).
429
+ Symlinks, hard links, non-regular files and files of another owner are
430
+ refused. Writes are exclusive private temp files, flushed, then renamed, under
431
+ one writer lock. An oversized `state.json` (left by an earlier build) keeps its
432
+ budget, counters and cursor; its pending events are dropped and counted. A log
433
+ from a pre-2.7.0 notifier that holds message text is made 0600 and refused
434
+ until you move it out. `pillar-notify` is an alias of
435
+ `pillar notify`.
436
+
203
437
  `--directory` fetches the directory and configures every carrier + seed listed
204
438
  there, and writes every `agents[]` entry (uuaid + publicKey) into
205
439
  `<home>/fleet.json` as your address book — so step 3 works immediately, no key
@@ -414,15 +648,87 @@ grant to `<home>/rotated/<time>-<old id>/` — the old key still opens the old
414
648
  mail there. To re-sync carriers and contacts without a new identity, use
415
649
  `init --refresh --directory <url>`.
416
650
 
651
+ ## Verify an agent, a card or a lineage
652
+
653
+ Every claim pillar makes about an identity is signed, and `pillar verify`
654
+ checks it. It has two forms:
655
+
656
+ ```sh
657
+ pillar verify <uuaid> [--registry URL] # live: is this agent who its registry listing says?
658
+ pillar verify <file|-> # offline: a saved card, listing, lineage log, intro, ...
659
+ pillar verify --help # both forms, every flag, the exit codes
660
+ ```
661
+
662
+ **Live (`pillar verify <uuaid>`).** pillar asks a registry for the agent
663
+ (`GET /v1/resolve/<uuaid>`) and checks the answer itself: the listing
664
+ signature, the card signature and the whole lineage (inception, rotations,
665
+ recoveries). It prints the lineage verdict, the current key, status
666
+ (live, quiet or dead) and the card's name and public key:
667
+
668
+ ```text
669
+ valid uuaid:pillar:agent:… (live: listing, card and lineage verified)
670
+ lineage: uuaid:pillar:agent:…
671
+ current: uuaid:pillar:agent:…
672
+ status: live
673
+ name: Alice
674
+ publicKey: …
675
+ registry: https://registry.example
676
+ ```
677
+
678
+ A registry answer that does not verify (a changed card, a forged listing,
679
+ an unknown agent) prints `not verified <uuaid>: <reason>` and exits 1:
680
+ pillar never trusts an answer it could not check. The registry is
681
+ `--registry URL`, else `registry` in the home's `config.json`, else
682
+ `https://pillar.uuaid.org`. It must run `pillar-directory` 2.7.0 or later,
683
+ the first version that answers `/v1/resolve`.
684
+
685
+ > **Today `https://pillar.uuaid.org` does not answer `/v1/resolve`**, so pass
686
+ > `--registry URL` (a registry running `pillar-directory` 2.7.0 or later, for
687
+ > example your own) until it is upgraded. Without it, `pillar verify <uuaid>`
688
+ > exits 1 with `not verified`. The file form needs no registry.
689
+
690
+ **Offline (`pillar verify <file>`).** No network. Pass the artifact (or `-`
691
+ for stdin); pillar detects its type, or takes `--type`:
692
+
693
+ ```sh
694
+ pillar verify ~/.pillar/lineage/log.json # your own lineage log
695
+ pillar verify card.json --lineage lineage.json # a card, checked against its lineage
696
+ pillar verify card.json # without its lineage: indeterminate lineage-required
697
+ ```
698
+
699
+ Exit codes (both forms): `0` valid; `10` recovered, pending-recovery or
700
+ contested; `1` invalid or not verified; `2` indeterminate; `64` usage. Add
701
+ `--json` for the full `pillar-verdict/1` object. A file of the same name as
702
+ a UUAID is read as a file.
703
+
704
+ **Related commands.**
705
+
706
+ | Command | What it does |
707
+ |---|---|
708
+ | `pillar resolve <uuaid> [--registry URL]` | The same live check as `verify <uuaid>`, printing the resolved record (and with `--json`, the lineage log). |
709
+ | `pillar lineage show [--json]` | This home's lineage: current key, head, verdict, rotations, doors. `<home>/lineage/log.json` is the file to give others. |
710
+ | `pillar lineage rotate` | Rotate this home's key (a signed lineage event). |
711
+ | `pillar card build` / `card show` / `card serve` | Write, print or serve this home's signed agent card (`<home>/card/card.json`). |
712
+ | `pillar listing publish --registry URL` | Publish the card as a signed listing, so `verify <uuaid>` finds you. |
713
+
417
714
  ## The three always-on roles
418
715
 
419
716
  | Bin | What it runs | Ongoing requirements |
420
717
  |---|---|---|
421
718
  | `pillar-responder` | Always-on auto-attendant: acks requests instantly, replies from fixed text or a command hook. Run it as a service; agents anywhere get ack+reply without you being live. | one process, outbound HTTPS |
422
719
  | `pillar-seed` | A carrier seed — makes you part of the p2p mesh. Any agent that lists your URL replicates every envelope to you and polls you in parallel with other seeds. `--announce` enrolls it in a seed registry, if one runs `pillar-directory` (see "Running a seed" below). | one process, one SQLite file, TLS-terminating proxy in front |
423
- | `pillar-directory` | The seed registry: serves `directory.json`, accepts permissionless seed enrollment, probes enrolled seeds, and promotes them. Run one if you publish a directory. | one process, one SQLite file |
720
+ | `pillar-directory` | The seed registry: serves `directory.json`, accepts permissionless seed enrollment, probes enrolled seeds, and promotes them. Run one if you publish a directory. **A public registry stays on 2.6.1 until 2.7.2** (note below this table). | one process, one SQLite file |
424
721
  | `pillar` | The full CLI (`init`, `id`, `send`, `group`, `groups`, `send-group`, `recv`, `inbox`, `wait`, `readers`, `status`, `receipts`, `trust`, `tier`, `peers`, `delegate`) — optional libp2p DHT, or carrier-only. | only when used interactively |
425
722
 
723
+ > **Running a public registry (`pillar-directory`)? Stay on 2.6.1 until
724
+ > 2.7.2.** A 2.7.x registry can stop answering `directory.json` (and every
725
+ > other request while it works) for up to one prune pass, about 3.5 ms per
726
+ > listing, at startup and about every 10 minutes. 2.7.1 fixes the timer
727
+ > pause and the heartbeat-seq issue; 2.7.2 fixes the rest. Agents, carriers
728
+ > and private registries can use 2.7.1. The UUAID registry at
729
+ > pillar.uuaid.org is upgraded separately; until then it does not answer
730
+ > /v1/resolve.
731
+
426
732
  ```sh
427
733
  pillar-responder --home ~/.pillar-responder --reply-text "ack" &
428
734
  pillar-seed --home /var/lib/pillar/seed --db /var/lib/pillar/seed.db & # 127.0.0.1:8799 by default
@@ -433,6 +739,11 @@ pillar-seed --home /var/lib/pillar/seed --db /var/lib/pillar/seed.db \
433
739
  pillar-seed --help # every flag, and its environment variable
434
740
  ```
435
741
 
742
+ Give `pillar-responder` its own home. With a command hook (`--command`) it is
743
+ a wake path: it holds that home's `notify/wake.lock` as kind `responder` while
744
+ it runs, and exits 64 ("two wake paths") when another wake path already holds
745
+ it.
746
+
436
747
  ### Running a seed
437
748
 
438
749
  What an outside operator needs to know before the first start:
@@ -592,8 +903,9 @@ survivors.
592
903
  ### Joining is permissionless
593
904
 
594
905
  TLS-terminate your seed's public URL and announce it to a registry running
595
- `pillar-directory`. For the planned public registry, use
596
- `https://pillar.uuaid.org` once deployed (see "Running a seed" above):
906
+ `pillar-directory` (see "Running a seed" above). Any operator can run one;
907
+ use the URL of the registry whose directory your agents bootstrap from, and
908
+ check that it answers `GET <registry>/v1/health` first:
597
909
 
598
910
  ```sh
599
911
  pillar-seed --home /var/lib/pillar/seed --db /var/lib/pillar/seed.db \
@@ -848,6 +1160,12 @@ rate and body size — see "Tier grants" above for the ladder. It is a
848
1160
  numbered list that citation implies was never published, and no items #1-#4
849
1161
  exist in this tree. `HOSTING-LIMITS.md` is now the published list of what a
850
1162
  carrier enforces. It does not use that numbering.
1163
+ - **New-mail notices (`recv --notify`) for unsafe metadata are counts only.**
1164
+ An event whose envelope id or sender fails the protocol checks is stored
1165
+ with `id`/`from` set to `null`, counted, and never listed. It is not
1166
+ re-checked against the mailbox when it is claimed, so it still counts toward
1167
+ a wake if its row was later erased or quarantined. All such senders share one
1168
+ per-sender budget window: they are deferred together, never let through.
851
1169
  - **Carrier retention is time-bounded.** Envelopes are retained until TTL,
852
1170
  default 14 days, then vacuumed (`src/net/carrier-server.mjs`).
853
1171
  - **No metering.** The carrier's rate limiter is an in-memory sliding window
package/bin/carrier.mjs CHANGED
@@ -43,6 +43,7 @@ import { CarrierServer, parseSecureDelete, parseCommunityWaits, MAX_TTL_DAYS } f
43
43
  import { Keychain, keyDerivesUuaid } from "../src/identity/keychain.mjs";
44
44
  import { checkSeedUrl } from "../src/net/seed-registry.mjs";
45
45
  import { parseTrustedProxies } from "../src/net/client-ip.mjs";
46
+ import { exitWithHelp, wantsHelp } from "../src/cli-help.mjs";
46
47
 
47
48
  function parseArgs(argv) {
48
49
  const args = {};
@@ -70,6 +71,26 @@ function oneLine(text) {
70
71
  return String(text).replace(/[\u0000-\u001f\u007f-\u009f\u2028\u2029]/g, (c) => ESCAPES[c] ?? `\\u${c.charCodeAt(0).toString(16).padStart(4, "0")}`);
71
72
  }
72
73
 
74
+ const USAGE = `usage: pillar-carrier [flags]
75
+
76
+ Runs a standalone carrier server (store-and-forward). Listens on 127.0.0.1 by
77
+ default; put a TLS-terminating proxy in front of it.
78
+
79
+ --port <n> listen port (CARRIER_PORT, default 8799)
80
+ --host <addr> listen address (CARRIER_HOST, default 127.0.0.1)
81
+ --db <file> SQLite database (CARRIER_DB, default ./carrier.db)
82
+ --ttl <days> envelope lifetime (CARRIER_TTL_DAYS, default 14, at most 36500)
83
+ --secure-delete <on|off> zero deleted envelopes (CARRIER_SECURE_DELETE, default on)
84
+ --community-waits <n> community long-poll cap (CARRIER_COMMUNITY_WAITS, default 48)
85
+ --trusted-proxy <ips> whose X-Forwarded-For counts (CARRIER_TRUSTED_PROXIES, default 127.0.0.1,::1)
86
+ --tier-issuers <hex,...> tier grant issuer keys (CARRIER_TIER_ISSUERS)
87
+ --receipt-keychain <file> sign carrier receipts with this existing key (CARRIER_RECEIPT_KEYCHAIN)
88
+ --seed-keychain <file> with --public-url: serve a signed /v1/seed-info (CARRIER_SEED_KEYCHAIN)
89
+ --public-url <https://> the URL the proxy serves (CARRIER_PUBLIC_URL)
90
+ -h, --help print this help and exit
91
+
92
+ The carrier never mints a key. See the header of bin/carrier.mjs for details.`;
93
+ if (wantsHelp(process.argv.slice(2))) await exitWithHelp(USAGE); // R2: before carrier.db is opened or a port is bound
73
94
  const args = parseArgs(process.argv.slice(2));
74
95
  const port = Number(args.port ?? process.env.CARRIER_PORT ?? 8799);
75
96
  const host = args.host ?? process.env.CARRIER_HOST ?? "127.0.0.1";
@@ -18,6 +18,7 @@ import { argv, exit } from "node:process";
18
18
  import { Keychain } from "../src/identity/keychain.mjs";
19
19
  import { Pillar } from "../src/pillar.mjs";
20
20
  import { loadFleetAddressBook } from "../src/address-book.mjs";
21
+ import { exitWithHelp, wantsHelp } from "../src/cli-help.mjs";
21
22
 
22
23
  function parseArgs(argv) {
23
24
  const args = { _: [] };
@@ -33,10 +34,12 @@ function parseArgs(argv) {
33
34
  return args;
34
35
  }
35
36
 
37
+ const USAGE = "usage: pillar-ask <recipient-uuaid> '<question>' [--to-pubkey HEX] [--home DIR] [--fleet FLEET.json] [--timeout S]";
38
+ if (wantsHelp(argv.slice(2))) await exitWithHelp(USAGE); // R2: before the home is read
36
39
  const args = parseArgs(argv.slice(2));
37
40
  const [recipient, question] = args._;
38
41
  if (!recipient || !question) {
39
- console.error("usage: pillar-ask <recipient-uuaid> '<question>' [--to-pubkey HEX] [--home DIR] [--fleet FLEET.json] [--timeout S]");
42
+ console.error(USAGE);
40
43
  exit(2);
41
44
  }
42
45
 
@@ -30,6 +30,7 @@ import { Pillar } from "../src/pillar.mjs";
30
30
  import { PillarBlobHttpClient, BLOB_BROKERS, DEFAULT_BLOB_BROKER } from "../src/blob/http.mjs";
31
31
  import { fetchBrokerBlob, DEFAULT_BLOB_TTL_MS, BlobError } from "../src/blob/blob.mjs";
32
32
  import { refusalLine } from "../src/net/refusals.mjs";
33
+ import { exitWithHelp, wantsHelp } from "../src/cli-help.mjs";
33
34
 
34
35
  function usage(code = 2) {
35
36
  process.stderr.write("usage: pillar-blob send|get (run without arguments to see the source header)\n");
@@ -74,6 +75,11 @@ function fail(error) {
74
75
  process.exit(code === "blob-not-found" || code === "blob-expired" ? 3 : code.includes("integrity") ? 5 : 6);
75
76
  }
76
77
 
78
+ const USAGE = `usage: pillar-blob send --to UUAID --recipient-pubkey HEX --data FILE [--broker URL]
79
+ [--carriers URL,...] [--key-id KEY_ID] [--ttl-ms N]
80
+ pillar-blob get --ref-file FILE --expect-envelope ID [--key-id KEY_ID]
81
+ [--broker URL] [--out FILE|-]`;
82
+ if (wantsHelp(process.argv.slice(2))) await exitWithHelp(USAGE); // R2: before the home or broker is touched
77
83
  const [command, ...rest] = process.argv.slice(2);
78
84
  if (!command) usage();
79
85
  const args = parse(rest);