@serfab/cadre-core 1.6.0 → 1.8.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.
Files changed (179) hide show
  1. package/README.md +8 -6
  2. package/dist/cadre-node.d.ts +548 -137
  3. package/dist/cadre-node.js +1208 -383
  4. package/dist/cadre-node.js.map +1 -1
  5. package/dist/control-authorization.d.ts +2 -2
  6. package/dist/control-authorization.js +1 -0
  7. package/dist/control-authorization.js.map +1 -1
  8. package/dist/control-cohort.d.ts +6 -0
  9. package/dist/control-cohort.js +6 -0
  10. package/dist/control-cohort.js.map +1 -1
  11. package/dist/control-database.d.ts +46 -8
  12. package/dist/control-database.js +97 -18
  13. package/dist/control-database.js.map +1 -1
  14. package/dist/control-formation-recorder.d.ts +37 -14
  15. package/dist/control-formation-recorder.js +60 -10
  16. package/dist/control-formation-recorder.js.map +1 -1
  17. package/dist/control-read-retry.d.ts +13 -12
  18. package/dist/control-read-retry.js +14 -12
  19. package/dist/control-read-retry.js.map +1 -1
  20. package/dist/control-schema.d.ts +1 -1
  21. package/dist/control-schema.js +67 -5
  22. package/dist/control-schema.js.map +1 -1
  23. package/dist/control-stream.d.ts +9 -1
  24. package/dist/control-stream.js +24 -1
  25. package/dist/control-stream.js.map +1 -1
  26. package/dist/control-write-retry.d.ts +12 -2
  27. package/dist/control-write-retry.js +13 -2
  28. package/dist/control-write-retry.js.map +1 -1
  29. package/dist/delegate-admission.d.ts +11 -8
  30. package/dist/delegate-admission.js +19 -11
  31. package/dist/delegate-admission.js.map +1 -1
  32. package/dist/diagnostics/connection-path.d.ts +0 -7
  33. package/dist/diagnostics/connection-path.js +0 -7
  34. package/dist/diagnostics/connection-path.js.map +1 -1
  35. package/dist/formation-approval.d.ts +7 -0
  36. package/dist/formation-approval.js +9 -3
  37. package/dist/formation-approval.js.map +1 -1
  38. package/dist/fs-atomic.d.ts +11 -2
  39. package/dist/fs-atomic.js +13 -3
  40. package/dist/fs-atomic.js.map +1 -1
  41. package/dist/hibernation-manager.d.ts +111 -8
  42. package/dist/hibernation-manager.js +234 -49
  43. package/dist/hibernation-manager.js.map +1 -1
  44. package/dist/index.d.ts +13 -6
  45. package/dist/index.js +27 -5
  46. package/dist/index.js.map +1 -1
  47. package/dist/joined-strand-store.d.ts +177 -0
  48. package/dist/joined-strand-store.js +431 -0
  49. package/dist/joined-strand-store.js.map +1 -0
  50. package/dist/key-store-file.js +14 -5
  51. package/dist/key-store-file.js.map +1 -1
  52. package/dist/key-store.d.ts +6 -0
  53. package/dist/key-store.js.map +1 -1
  54. package/dist/link-budget.d.ts +367 -69
  55. package/dist/link-budget.js +375 -72
  56. package/dist/link-budget.js.map +1 -1
  57. package/dist/membership-connection-gater.d.ts +30 -43
  58. package/dist/membership-connection-gater.js +31 -42
  59. package/dist/membership-connection-gater.js.map +1 -1
  60. package/dist/node-local-snapshot.d.ts +5 -4
  61. package/dist/node-local-snapshot.js +6 -3
  62. package/dist/node-local-snapshot.js.map +1 -1
  63. package/dist/peer-dial.d.ts +24 -4
  64. package/dist/peer-dial.js +74 -5
  65. package/dist/peer-dial.js.map +1 -1
  66. package/dist/peer-join-backfill.d.ts +35 -15
  67. package/dist/peer-join-backfill.js +115 -55
  68. package/dist/peer-join-backfill.js.map +1 -1
  69. package/dist/push-fanout.d.ts +6 -0
  70. package/dist/push-fanout.js +6 -0
  71. package/dist/push-fanout.js.map +1 -1
  72. package/dist/relay-reservation.d.ts +3 -1
  73. package/dist/relay-reservation.js +3 -1
  74. package/dist/relay-reservation.js.map +1 -1
  75. package/dist/relay-server.d.ts +79 -0
  76. package/dist/relay-server.js +74 -0
  77. package/dist/relay-server.js.map +1 -0
  78. package/dist/seed-bootstrap.d.ts +57 -4
  79. package/dist/seed-bootstrap.js +107 -83
  80. package/dist/seed-bootstrap.js.map +1 -1
  81. package/dist/storage-scope.d.ts +33 -17
  82. package/dist/storage-scope.js +44 -23
  83. package/dist/storage-scope.js.map +1 -1
  84. package/dist/strand-addr-protocol.d.ts +58 -21
  85. package/dist/strand-addr-protocol.js +133 -85
  86. package/dist/strand-addr-protocol.js.map +1 -1
  87. package/dist/strand-database.d.ts +20 -2
  88. package/dist/strand-database.js +42 -5
  89. package/dist/strand-database.js.map +1 -1
  90. package/dist/strand-first-sync-gate.d.ts +59 -21
  91. package/dist/strand-first-sync-gate.js +58 -19
  92. package/dist/strand-first-sync-gate.js.map +1 -1
  93. package/dist/strand-formation-deadlines.d.ts +151 -0
  94. package/dist/strand-formation-deadlines.js +171 -0
  95. package/dist/strand-formation-deadlines.js.map +1 -0
  96. package/dist/strand-formation-manager.d.ts +63 -30
  97. package/dist/strand-formation-manager.js +67 -41
  98. package/dist/strand-formation-manager.js.map +1 -1
  99. package/dist/strand-formation-protocol.d.ts +45 -35
  100. package/dist/strand-formation-protocol.js +59 -122
  101. package/dist/strand-formation-protocol.js.map +1 -1
  102. package/dist/strand-instance-manager.d.ts +152 -6
  103. package/dist/strand-instance-manager.js +331 -42
  104. package/dist/strand-instance-manager.js.map +1 -1
  105. package/dist/strand-membership-writer.d.ts +6 -0
  106. package/dist/strand-membership-writer.js +11 -0
  107. package/dist/strand-membership-writer.js.map +1 -1
  108. package/dist/strand-peer-book-file.d.ts +12 -0
  109. package/dist/strand-peer-book-file.js +37 -0
  110. package/dist/strand-peer-book-file.js.map +1 -0
  111. package/dist/strand-peer-book-protocol.d.ts +168 -0
  112. package/dist/strand-peer-book-protocol.js +356 -0
  113. package/dist/strand-peer-book-protocol.js.map +1 -0
  114. package/dist/strand-peer-book-swap.d.ts +104 -0
  115. package/dist/strand-peer-book-swap.js +284 -0
  116. package/dist/strand-peer-book-swap.js.map +1 -0
  117. package/dist/strand-peer-book.d.ts +159 -0
  118. package/dist/strand-peer-book.js +361 -0
  119. package/dist/strand-peer-book.js.map +1 -0
  120. package/dist/strand-peer-observer.d.ts +88 -0
  121. package/dist/strand-peer-observer.js +180 -0
  122. package/dist/strand-peer-observer.js.map +1 -0
  123. package/dist/strand-revocation-enforcer.js +2 -1
  124. package/dist/strand-revocation-enforcer.js.map +1 -1
  125. package/dist/strand-solicitation.d.ts +36 -20
  126. package/dist/strand-solicitation.js +4 -4
  127. package/dist/strand-solicitation.js.map +1 -1
  128. package/dist/strand-wake-protocol.d.ts +80 -23
  129. package/dist/strand-wake-protocol.js +89 -64
  130. package/dist/strand-wake-protocol.js.map +1 -1
  131. package/dist/types.d.ts +181 -33
  132. package/dist/types.js +4 -3
  133. package/dist/types.js.map +1 -1
  134. package/package.json +11 -7
  135. package/src/cadre-node.ts +1316 -398
  136. package/src/control-authorization.ts +2 -1
  137. package/src/control-cohort.ts +6 -0
  138. package/src/control-database.ts +122 -18
  139. package/src/control-formation-recorder.ts +354 -305
  140. package/src/control-read-retry.ts +14 -12
  141. package/src/control-schema.ts +67 -5
  142. package/src/control-stream.ts +25 -1
  143. package/src/control-write-retry.ts +13 -2
  144. package/src/delegate-admission.ts +23 -13
  145. package/src/diagnostics/connection-path.ts +0 -7
  146. package/src/formation-approval.ts +610 -604
  147. package/src/fs-atomic.ts +14 -4
  148. package/src/hibernation-manager.ts +638 -437
  149. package/src/index.ts +91 -6
  150. package/src/joined-strand-store.ts +498 -0
  151. package/src/key-store-file.ts +14 -5
  152. package/src/key-store.ts +6 -0
  153. package/src/link-budget.ts +393 -74
  154. package/src/membership-connection-gater.ts +31 -45
  155. package/src/node-local-snapshot.ts +293 -289
  156. package/src/peer-dial.ts +81 -7
  157. package/src/peer-join-backfill.ts +120 -57
  158. package/src/push-fanout.ts +6 -0
  159. package/src/relay-reservation.ts +3 -1
  160. package/src/relay-server.ts +98 -0
  161. package/src/seed-bootstrap.ts +133 -91
  162. package/src/storage-scope.ts +44 -23
  163. package/src/strand-addr-protocol.ts +547 -458
  164. package/src/strand-database.ts +287 -242
  165. package/src/strand-first-sync-gate.ts +58 -19
  166. package/src/strand-formation-deadlines.ts +227 -0
  167. package/src/strand-formation-manager.ts +700 -647
  168. package/src/strand-formation-protocol.ts +103 -150
  169. package/src/strand-instance-manager.ts +387 -45
  170. package/src/strand-membership-writer.ts +12 -0
  171. package/src/strand-peer-book-file.ts +39 -0
  172. package/src/strand-peer-book-protocol.ts +466 -0
  173. package/src/strand-peer-book-swap.ts +338 -0
  174. package/src/strand-peer-book.ts +475 -0
  175. package/src/strand-peer-observer.ts +235 -0
  176. package/src/strand-revocation-enforcer.ts +2 -1
  177. package/src/strand-solicitation.ts +519 -500
  178. package/src/strand-wake-protocol.ts +401 -355
  179. package/src/types.ts +185 -33
@@ -1 +1 @@
1
- {"version":3,"file":"strand-wake-protocol.js","sourceRoot":"","sources":["../src/strand-wake-protocol.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,OAAO,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,EAAsB,UAAU,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACrG,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEhD,MAAM,GAAG,GAAG,KAAK,CAAC,0BAA0B,CAAC,CAAC;AAE9C,oFAAoF;AACpF,MAAM,CAAC,MAAM,aAAa,GAAG,2BAA2B,CAAC;AAEzD;;;;GAIG;AACH,MAAM,aAAa,GAAG,EAAE,GAAG,IAAI,CAAC;AAEhC,qFAAqF;AACrF,MAAM,uBAAuB,GAAG,KAAM,CAAC;AAEvC;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,KAAM,CAAC;AAElD,sFAAsF;AACtF,MAAM,4BAA4B,GAAG,KAAM,CAAC;AAE5C,iFAAiF;AACjF,MAAM,4BAA4B,GAAG,GAAG,CAAC;AAEzC;;;;;GAKG;AACH,KAAK,UAAU,SAAS,CAAI,MAAqB,EAAE,SAAiB;IAClE,MAAM,IAAI,GAAG,MAAM,eAAe,CAAC,MAAM,EAAE,EAAE,QAA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OAAO,MAAM,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,EAAE,CAClF,QAAQ,CAAC,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC,CAAC;AAClE,CAAC;AAED;;;;;;;GAOG;AACH,KAAK,UAAU,QAAQ,CACrB,IAAY,EACZ,IAAe,EACf,UAAkB,EAClB,OAAoB,EACpB,SAAiB,EACjB,MAAmB;IAEnB,0EAA0E;IAC1E,0EAA0E;IAC1E,4EAA4E;IAC5E,6EAA6E;IAC7E,uDAAuD;IACvD,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,IAAI,EAAE,UAAU,EAAE,EAAE,sBAAsB,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC;IAEtG,MAAM,GAAG,GAAG,MAAM,aAAa,CAC7B,SAAqC,EACrC,MAAM,EACN,OAAO,EACP,CAAC,MAAM,EAAE,EAAE,CAAC,SAAS,CAAU,MAAM,EAAE,SAAS,CAAC,EACjD,8BAA8B,CAC/B,CAAC;IAEF,GAAG,CAAC,yCAAyC,EAAE,IAAI,CAAC,QAAQ,EAAE,EAAE,GAAG,CAAC,QAAQ,EAAE,GAAG,CAAC,MAAM,IAAI,GAAG,CAAC,CAAC;IACjG,OAAO,GAAG,CAAC;AACb,CAAC"}
package/dist/types.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import type { ConnectionGater, Libp2p, PeerId, PrivateKey } from '@libp2p/interface';
2
+ import type { CircuitRelayServerInit } from '@libp2p/circuit-relay-v2';
2
3
  import type { IRawStorage, Libp2pConnectionMonitorInit, Libp2pTransports, NoiseCryptoInterface } from '@optimystic/db-p2p';
3
4
  import type { IPeerNetwork, IRepo } from '@optimystic/db-core';
4
5
  import type { PeerJoinBackfillConfig } from './peer-join-backfill.js';
@@ -10,7 +11,9 @@ import type { SeedTrustPolicy } from './seed-trust-policy.js';
10
11
  import type { KeyStore, KeyId } from './key-store.js';
11
12
  import type { TrustedOwnerStore, TrustSource } from './trusted-owner-store.js';
12
13
  import type { BootstrapPeerStore } from './bootstrap-peer-store.js';
14
+ import type { StrandPeerBookStore } from './strand-peer-book.js';
13
15
  import type { EnrolledMachineStore } from './enrolled-machine-store.js';
16
+ import type { JoinedStrandStore } from './joined-strand-store.js';
14
17
  import type { PushNotifier } from './push-notifier.js';
15
18
  import type { RevocableTable } from './control-authorization.js';
16
19
  import type { ControlRetryAbandonment } from './control-retry.js';
@@ -91,10 +94,12 @@ export declare const HIBERNATION_TIMEOUTS: Record<LatencyHint, HibernationTimeou
91
94
  * Factory functions are useful for creating per-scope storage instances.
92
95
  *
93
96
  * **The argument is an opaque scope key.** Use it directly as a file name, directory
94
- * name or database name: every key stays within `[A-Za-z0-9._-]`, so no escaping is
95
- * needed and none should be assumed. Do not parse it; `controlStorageScope` /
96
- * `isControlStorageScope` (`storage-scope.ts`) are the supported way to mint and
97
- * recognize the control key. The control key holds the charset by base64url encoding;
97
+ * name or database name: every key stays within `[a-z0-9._-]`, so no escaping is
98
+ * needed and none should be assumed, and two different keys are two different names
99
+ * even on a filesystem that ignores case (Windows, macOS). Do not parse it;
100
+ * `controlStorageScope` / `isControlStorageScope` (`storage-scope.ts`) are the supported
101
+ * way to mint and recognize the control key. The control key holds the charset by
102
+ * lowercase hex encoding;
98
103
  * a strand's key — its strand id, which may have replicated in from another node in
99
104
  * the party — holds it because `StrandInstanceManager.startStrand` runs
100
105
  * `assertStrandScopeKey` on every launch and refuses a strand that fails it.
@@ -138,7 +143,7 @@ export interface StorageConfig {
138
143
  * the single-instance form cannot serve more than one party.
139
144
  *
140
145
  * The `scope` a factory receives is an opaque key already safe as a path or
141
- * database-name segment (always within `[A-Za-z0-9._-]`), so each example below
146
+ * database-name segment (always within `[a-z0-9._-]`), so each example below
142
147
  * interpolates it directly.
143
148
  *
144
149
  * For Node.js environments, use FileRawStorage from @optimystic/db-p2p-storage-fs:
@@ -285,7 +290,8 @@ export interface NetworkConfig {
285
290
  * It buys a node that BOOTS, not a node that boots fast: `start()` still waits
286
291
  * out that first attempt, which costs the drive's whole timeout
287
292
  * (`DEFAULT_RELAY_RESERVE_TIMEOUT_MS`, four link round trips at
288
- * {@link linkRoundTripMs} — 14 s at its default) against a relay that is unreachable
293
+ * {@link linkRoundTripMs} plus two admission decisions — 18 s at its default) against a relay
294
+ * that is unreachable
289
295
  * rather than merely refusing (`relay-reservation.ts` polls to the deadline, in
290
296
  * case libp2p's own discovery lands a reservation independently).
291
297
  *
@@ -308,6 +314,31 @@ export interface NetworkConfig {
308
314
  * better connectivity and uptime), false for transaction profile nodes.
309
315
  */
310
316
  enableRelay?: boolean;
317
+ /**
318
+ * Settings for this machine's circuit-relay SERVER, handed to `@libp2p/circuit-relay-v2`'s
319
+ * `circuitRelayServer(...)` (through db-p2p's `NodeOptions.relayServerInit`) on the control
320
+ * node and on every strand node. Only meaningful while {@link enableRelay} is on.
321
+ *
322
+ * Omitted, a party-run relay FORWARDS WITHOUT LIMIT: `reservations.applyDefaultLimit` is
323
+ * `false`, where libp2p's own default caps every relayed connection at 128 KiB or two
324
+ * minutes and resets it — which cut off any database sync or chat history forwarded
325
+ * through a party's own always-on machine. The store also holds
326
+ * `PARTY_RELAY_MAX_RESERVATIONS` (128) reservations instead of libp2p's 15, and each lives
327
+ * `PARTY_RELAY_RESERVATION_TTL_MS` (2 h) unrefreshed. See `relay-server.ts`.
328
+ *
329
+ * A value is MERGED over those defaults, not substituted for them: `reservations` key by
330
+ * key, every other top-level key as given. Setting only `reservations.maxReservations`
331
+ * keeps the limit off; `reservations: { applyDefaultLimit: true }` is how to turn libp2p's
332
+ * cap back on.
333
+ *
334
+ * The accepted tradeoff of the unlimited default: once a slot is granted, nothing caps what
335
+ * is forwarded through it, and a holder that keeps refreshing keeps it indefinitely — the
336
+ * 2 h lifetime only reclaims a slot whose holder went away. On the control node a peer it
337
+ * cannot place as a party member is bounded by COUNT ({@link unauthorizedRelayReservationCap}).
338
+ * A strand node's relay server has no such budget (its peers are cross-party by design), so
339
+ * any peer that reaches it is bounded only by `maxReservations`.
340
+ */
341
+ relayServerInit?: CircuitRelayServerInit;
311
342
  /**
312
343
  * Cap on concurrent circuit-relay reservations this node's relay server grants to
313
344
  * peers it cannot (yet) recognize as authorized members — the boot-ordering window
@@ -379,16 +410,21 @@ export interface NetworkConfig {
379
410
  * How long ONE cohort peer gets to answer ONE read-path request, in milliseconds, for the
380
411
  * control node and every strand node — as {@link connectionMonitor} is, and for the same
381
412
  * reason: the setting describes the LINK, and a phone's control node and its strand nodes
382
- * ride the same one. Omitted takes {@link COHORT_READ_DEADLINE_MS} (5000 ms), chosen for two
383
- * parties reaching each other only through a relay; Optimystic's own default is 1000 ms.
413
+ * ride the same one. Omitted, the deadline is DERIVED from {@link linkRoundTripMs}: one
414
+ * request and its answer over an open circuit costs two link round trips, so 7 000 ms at the
415
+ * default declaration (`cohortReadDeadlineMs` in `link-budget.ts`; the plugin's
416
+ * {@link COHORT_READ_DEADLINE_MS} is the same number). Optimystic's own default is 1000 ms.
384
417
  *
385
- * Raise it for a link slower still, lower it for a deployment that is all LAN and wants a
386
- * departed peer to stop holding up a read sooner. The cost of a larger value is that a peer
387
- * which is truly gone holds a read of a block missing locally for that long before the read
388
- * is declined and retried, and a joining machine's first sync runs several such consults —
389
- * so a change here should be weighed against
390
- * {@link CadreNodeConfig.strandFirstSync}'s budget. The measurement behind the default, and
391
- * what it costs, are on {@link COHORT_READ_DEADLINE_MS}.
418
+ * Set this only to break the derivation on purpose: an explicit value wins over whatever
419
+ * {@link linkRoundTripMs} would derive, so a deployment that is all LAN can make a departed
420
+ * peer stop holding up a read sooner without declaring a faster link (which would also
421
+ * shorten the dial budgets). A deployment on a slower link should raise
422
+ * {@link linkRoundTripMs} instead, which moves this and every dial budget together. The
423
+ * cost of a larger value is that a peer which is truly gone holds a read of a block missing
424
+ * locally for that long before the read is declined and retried, and a joining machine's
425
+ * first sync runs several such consults — so a change here should be weighed against
426
+ * {@link CadreNodeConfig.strandFirstSync}'s budget. The derivation, its history and what it
427
+ * costs are on {@link COHORT_READ_DEADLINE_MS}.
392
428
  *
393
429
  * Handed to db-p2p's `clusterPolicy.cohortQueryTimeoutMs` unchanged and NOT re-validated
394
430
  * here. Optimystic refuses a value that is not a finite number above zero, or is above its
@@ -407,11 +443,14 @@ export interface NetworkConfig {
407
443
  * This is NOT a timeout. It is the one stated assumption that cadre's own dial and
408
444
  * reservation deadlines are DERIVED from, each by the number of round trips that operation
409
445
  * was measured to cost: a peer-join catch-up's dial to one peer, its push response, one relay
410
- * reservation drive, the control-cohort dial budgets, and libp2p's own `dialTimeout` and
411
- * `inboundUpgradeTimeout` on every node. Reaching another machine through a relay costs a
412
- * fixed number of exchanges, so a deadline written as milliseconds has a link speed above
413
- * which it can never open a connection — which is the defect this declaration exists to make
414
- * impossible to reintroduce one budget at a time. The counts, the measurement behind them,
446
+ * reservation drive, the control-cohort dial budgets, and the per-peer cohort read deadline
447
+ * ({@link cohortQueryTimeoutMs}, unless set explicitly). It is also handed to Optimystic
448
+ * (`NodeOptions.linkRoundTripMs`), default included, which derives its own deadlines from it:
449
+ * its request dials and responses, its block pushes, and libp2p's `dialTimeout` and
450
+ * `inboundUpgradeTimeout` on every node. Reaching another machine through a
451
+ * relay costs a fixed number of exchanges, so a deadline written as milliseconds has a link
452
+ * speed above which it can never open a connection — which is the defect this declaration
453
+ * exists to make impossible to reintroduce one budget at a time. The counts, the measurement behind them,
415
454
  * and what still fails at the supported link are in `link-budget.ts`.
416
455
  *
417
456
  * The default covers the slowest link sereus supports, a 3-second round trip through a relay.
@@ -425,7 +464,8 @@ export interface NetworkConfig {
425
464
  * Refused where the libp2p node is built — inside `CadreNode.start()` for the control
426
465
  * network, inside `CadreNode.addStrand` for a strand — if it is not a finite number above
427
466
  * zero, because every consumer multiplies it into a deadline where a zero means "give up at
428
- * once" and a `NaN` means "never".
467
+ * once" and a `NaN` means "never". Optimystic refuses, in the same place, a value above its
468
+ * `MAX_LINK_ROUND_TRIP_MS` (about 1.66 days).
429
469
  */
430
470
  linkRoundTripMs?: number;
431
471
  /**
@@ -496,14 +536,19 @@ export interface NetworkConfig {
496
536
  * {@link dialTimeoutMs}. Each address is dialed on its own under this limit,
497
537
  * so an address that never answers cannot use up the time the peer's other
498
538
  * addresses needed. Defaults to
499
- * {@link DEFAULT_CONTROL_COHORT_PER_ADDRESS_DIAL_TIMEOUT_MS}.
539
+ * {@link DEFAULT_CONTROL_COHORT_PER_ADDRESS_DIAL_TIMEOUT_MS}. A value given
540
+ * here replaces that whole derived budget, including its allowance for the
541
+ * called machine's admission decision (`relayedDialBudgetMs`).
500
542
  */
501
543
  perAddressDialTimeoutMs?: number;
502
544
  /**
503
- * How often each running strand re-resolves its siblings' strand-network
504
- * addresses into its own libp2p address book — a step of the reconcile pass,
505
- * on its own much longer throttle. Defaults to `STRAND_PEER_ADDR_REFRESH_MS`
506
- * (10 min); must stay well under the peerStore's one-hour address expiry.
545
+ * How long a running strand waits, after a sibling answers its strand-addr
546
+ * RPC, before asking that sibling again for its strand-network addresses — a
547
+ * step of the reconcile pass, scheduled per (sibling, strand). A sibling that
548
+ * did not answer is retried sooner, on `STRAND_PEER_ADDR_RETRY_MS` (or this
549
+ * interval, when it is set shorter). Defaults to
550
+ * `STRAND_PEER_ADDR_REFRESH_MS` (10 min); must stay well under the peerStore's
551
+ * one-hour address expiry.
507
552
  */
508
553
  strandAddrRefreshMs?: number;
509
554
  };
@@ -615,9 +660,10 @@ export interface ControlNetworkConfig {
615
660
  *
616
661
  * The two `*ClusterPolicy` BUILDERS are the same objects with the block-repair
617
662
  * corroboration yardstick declared from the machines enrolled in this party
618
- * ({@link resolveRepairYardstick}) and, if the host set one, its own per-peer read
619
- * deadline in place of {@link COHORT_READ_DEADLINE_MS}. Both arrive in one named
620
- * declarations object, because both are plain numbers meaning unrelated things;
663
+ * ({@link resolveRepairYardstick}) and, if the host set one or declared its link, a
664
+ * per-peer read deadline in place of {@link COHORT_READ_DEADLINE_MS}
665
+ * (`declaredCohortReadDeadlineMs` in `link-budget.ts` settles which). Both arrive in one
666
+ * named declarations object, because both are plain numbers meaning unrelated things;
621
667
  * declaring neither returns the frozen base constant unchanged. A network picks the
622
668
  * derived numbers up when its libp2p node is built, which for a strand is every wake
623
669
  * from hibernation.
@@ -662,6 +708,21 @@ export interface CadreNodeConfig {
662
708
  profile: NodeProfile;
663
709
  /** Which strands to participate in */
664
710
  strandFilter?: StrandFilter;
711
+ /**
712
+ * Run every strand {@link strandFilter} admits, including ones no app on this machine
713
+ * has claimed with `addStrand`, as a **storage replica**: the strand's own libp2p node,
714
+ * storage and `Strand` membership schema, storing and serving its blocks, without the
715
+ * app's schema (no sApp config needed, none of the app's code or schema runs). This is
716
+ * how an always-on machine keeps a copy of every shared workspace its party runs, so a
717
+ * lost phone loses nothing that had reached it.
718
+ *
719
+ * The strand is still announced as `strand:discovered` (once) and stays in
720
+ * `getDiscoveredStrands()` until an app claims it. A replica is always a joiner.
721
+ *
722
+ * Default: `profile === 'storage'` — always-on machines host replicas, phones
723
+ * (`'transaction'`) keep today's announce-only behaviour.
724
+ */
725
+ hostUnclaimedStrands?: boolean;
665
726
  /** Storage configuration (only for storage profile) */
666
727
  storage?: StorageConfig;
667
728
  /** Network configuration */
@@ -874,6 +935,53 @@ export interface CadreNodeConfig {
874
935
  */
875
936
  store?: EnrolledMachineStore;
876
937
  };
938
+ /**
939
+ * Node-local record of the strands this node joined from ANOTHER party and has not yet
940
+ * published to the party-wide `JoinedStrand` table (see `joined-strand-store.ts`): id,
941
+ * type and the closed strand's read secret, recorded by `formStrand` and by a joining
942
+ * (not `founder: true`) `addStrand` whose row this party's control database does not
943
+ * name, offered on every start as `strand:discovered` until an owner machine's
944
+ * reconcile pass publishes it — so an embedding app keeps no list of its own.
945
+ *
946
+ * Absent ⇒ a `KeyStoreJoinedStrandStore` over {@link keyStore} when one is
947
+ * configured (the record carries a secret, and the KeyStore is where every platform
948
+ * already keeps secrets), else an in-memory store that warns once and forgets every
949
+ * join on restart. An embedder that passes {@link privateKey} rather than a
950
+ * `keyStore` injects a durable store here, e.g.
951
+ * `new KeyStoreJoinedStrandStore(new FileKeyStore(dir), partyId)`.
952
+ */
953
+ joinedStrands?: {
954
+ /** Its `partyId` must match `controlNetwork.partyId`; start() fails closed on a mismatch. */
955
+ store?: JoinedStrandStore;
956
+ };
957
+ /**
958
+ * Node-local strand peer book (see `strand-peer-book.ts`): per strand, the strand
959
+ * peers this node has met — the other parties' strand transport peers a formation
960
+ * carried back, and every strand peer observed on a live connection — with their
961
+ * last-known addresses. Read on every launch, hibernation resume and periodic
962
+ * address refresh, so a restarted machine dials the peers it was talking to before
963
+ * anything else, instead of coming back up alone (gotchoices/sereus#18). Sibling
964
+ * of {@link bootstrapPeers} — same NON-replicated, per-party, injected-backend
965
+ * shape — and, like it, nothing here is trust-bearing: dial hints only, each
966
+ * bound to its peer id. Entries age out after 14 days (`STRAND_PEER_MAX_AGE_MS`,
967
+ * overridable per store via `StrandPeerBookOptions.maxAgeMs`).
968
+ *
969
+ * Absent ⇒ an in-memory store is created at start() (ephemeral: the book dies
970
+ * with the process, and a cross-party strand whose only contact was the other
971
+ * party does not re-mesh after a restart until a fresh formation). Every
972
+ * reference embedder injects a durable backend over the same slot kind as its
973
+ * bootstrap-peer store. A new platform needs no new store class: supply a
974
+ * `DurableSlot` and inject `PersistentStrandPeerBookStore.open(slot, partyId)`.
975
+ */
976
+ strandPeers?: {
977
+ /**
978
+ * Injected store instance — e.g. a `FileStrandPeerBookStore` from the
979
+ * Node-only subpath `@serfab/cadre-core/strand-peer-book-file`, persisted in
980
+ * the node's state directory. Its `partyId` must match
981
+ * `controlNetwork.partyId`; start() fails closed on a mismatch.
982
+ */
983
+ store?: StrandPeerBookStore;
984
+ };
877
985
  /**
878
986
  * Platform push-delivery for suspended mobile peers. When present, the node's
879
987
  * server fan-out can deliver strand-wake data messages over the platform push
@@ -944,6 +1052,12 @@ export interface StrandInstance {
944
1052
  memberPrivateKey?: string;
945
1053
  /** Activity tracking */
946
1054
  connectedPeers: number;
1055
+ /**
1056
+ * When the strand last saw activity: the app's (`recordStrandActivity`), a requested wake
1057
+ * (`wakeStrand`), or a peer delivering a gated joiner's `Strand.Header`. Always a fresh
1058
+ * `Date`. Bringing the runtime up is NOT activity — a check-in window decides whether to
1059
+ * re-hibernate by whether this changed since before its resume.
1060
+ */
947
1061
  lastActivity: Date;
948
1062
  nextCheckIn?: Date;
949
1063
  /** Latency hint from app or override */
@@ -1296,6 +1410,10 @@ export interface CadreNodeEvents {
1296
1410
  * re-admits this party, so a second removal is reported again — and a
1297
1411
  * hibernation wake rebuilds the gate, which may re-emit for a strand still
1298
1412
  * revoked.
1413
+ *
1414
+ * For a strand joined from another party, the node also forgets its remembered
1415
+ * join (see {@link CadreNodeConfig.joinedStrands}): it keeps running this session
1416
+ * and is not re-offered after the next start.
1299
1417
  */
1300
1418
  'strand:revoked': {
1301
1419
  strandId: string;
@@ -1333,6 +1451,12 @@ export interface CadreNodeEvents {
1333
1451
  * Carries the full {@link StrandRow} so the app can join without re-querying
1334
1452
  * the control DB.
1335
1453
  *
1454
+ * Also emitted for a strand this node joined from ANOTHER party, which no control
1455
+ * row names: the node remembers every such join (see
1456
+ * {@link CadreNodeConfig.joinedStrands}) and offers it here on each start, as a row
1457
+ * with `FounderOwnerKey: null` carrying the closed strand's `MemberPrivateKey`. That
1458
+ * row is the product of the formation's consent, so claiming it needs no second one.
1459
+ *
1336
1460
  * **Fired once per strand per session, and it can fire before your listener is
1337
1461
  * attached.** The strand watcher's first poll runs inside `CadreNode.start()`
1338
1462
  * (100 ms after the watcher starts), so every strand already stored for this
@@ -1354,6 +1478,12 @@ export interface CadreNodeEvents {
1354
1478
  * be idempotent (guard on an in-flight set, not only on
1355
1479
  * `getStrands().has(id)` — the strand manager tracks an instance only once
1356
1480
  * `addStrand` has resolved).
1481
+ *
1482
+ * On a node that hosts storage replicas ({@link CadreNodeConfig.hostUnclaimedStrands},
1483
+ * the default for `profile: 'storage'`) the event still fires once, and the node launches
1484
+ * the strand as a replica right after it — so there `getStrands().has(id)` soon turns
1485
+ * true for a strand no app has claimed; an unclaimed instance has no `sAppInfo`. A
1486
+ * launch that fails is retried by the watcher without a second `strand:discovered`.
1357
1487
  */
1358
1488
  'strand:discovered': {
1359
1489
  strandId: string;
@@ -1702,7 +1832,11 @@ export interface WakeRequest {
1702
1832
  export interface WakeAck {
1703
1833
  /** Whether the receiver honored the wake (member + participated strand). */
1704
1834
  accepted: boolean;
1705
- /** The strand's status after the wake (present when `accepted`). */
1835
+ /**
1836
+ * The strand's status when the receiver accepted the wake (present when `accepted`). The
1837
+ * receiver replies before the wake runs, so `hibernating` or `idle` here means "a wake was
1838
+ * started", not "the strand is now up".
1839
+ */
1706
1840
  status?: StrandStatus;
1707
1841
  /** Reason for rejection (non-member, unknown strand, malformed frame). */
1708
1842
  reason?: string;
@@ -1725,17 +1859,31 @@ export interface StrandAddrRequest {
1725
1859
  */
1726
1860
  delegatePeerId?: string;
1727
1861
  }
1862
+ /**
1863
+ * How a strand-addr responder handled a {@link StrandAddrRequest}. Carried so the
1864
+ * asker can tell "I have nothing" from "I could not answer" — the two need
1865
+ * different retry timing, and an empty address list alone cannot say which.
1866
+ *
1867
+ * - `ok` — looked up; `multiaddrs` is the truth, possibly empty (strand not running here).
1868
+ * - `unavailable` — the responder could not answer: over its concurrency cap, the
1869
+ * request was unreadable, or its own lookup threw (e.g. a control-database read failed).
1870
+ * - `refused` — the requester is not an authorized member in the responder's
1871
+ * current view (possibly because its `CadrePeer` row has not replicated there yet);
1872
+ * any `delegatePeerId` it carried was NOT recorded.
1873
+ */
1874
+ export type StrandAddrStatus = 'ok' | 'unavailable' | 'refused';
1728
1875
  /**
1729
1876
  * Response to a {@link StrandAddrRequest}, carrying the responder's strand-node
1730
1877
  * multiaddrs, returned on the same stream.
1731
1878
  */
1732
1879
  export interface StrandAddrResponse {
1733
- /** Echoes the requested strand id (empty on a reject/error reply). */
1880
+ /** How the responder handled the request; a reply without one is malformed. */
1881
+ status: StrandAddrStatus;
1882
+ /** Echoes the requested strand id; always empty on an `unavailable` reply. */
1734
1883
  strandId: string;
1735
1884
  /**
1736
1885
  * Dialable strand-network multiaddr strings (signaling/`p2p-circuit` first);
1737
- * empty when the responder is a non-member, or does not currently run that
1738
- * strand, or the exchange failed.
1886
+ * empty unless `status` is `ok` and the responder runs that strand.
1739
1887
  */
1740
1888
  multiaddrs: string[];
1741
1889
  }
package/dist/types.js CHANGED
@@ -119,9 +119,10 @@ export const DEFAULT_CHECKIN_WINDOW_MS = 15 * 1000;
119
119
  *
120
120
  * The two `*ClusterPolicy` BUILDERS are the same objects with the block-repair
121
121
  * corroboration yardstick declared from the machines enrolled in this party
122
- * ({@link resolveRepairYardstick}) and, if the host set one, its own per-peer read
123
- * deadline in place of {@link COHORT_READ_DEADLINE_MS}. Both arrive in one named
124
- * declarations object, because both are plain numbers meaning unrelated things;
122
+ * ({@link resolveRepairYardstick}) and, if the host set one or declared its link, a
123
+ * per-peer read deadline in place of {@link COHORT_READ_DEADLINE_MS}
124
+ * (`declaredCohortReadDeadlineMs` in `link-budget.ts` settles which). Both arrive in one
125
+ * named declarations object, because both are plain numbers meaning unrelated things;
125
126
  * declaring neither returns the frozen base constant unchanged. A network picks the
126
127
  * derived numbers up when its libp2p node is built, which for a strand is every wake
127
128
  * from hibernation.
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAgFA;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAA6C;IAC5E,QAAQ,EAAE;QACR,WAAW,EAAE,QAAQ,EAAS,aAAa;QAC3C,gBAAgB,EAAE,QAAQ,EAAI,kBAAkB;QAChD,eAAe,EAAE,QAAQ,EAAK,MAAM;QACpC,oBAAoB,EAAE,CAAC;QACvB,kBAAk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serfab/cadre-core",
3
- "version": "1.6.0",
3
+ "version": "1.8.0",
4
4
  "type": "module",
5
5
  "description": "Core library for Sereus cadre nodes - manages control networks and strand participation",
6
6
  "main": "dist/index.js",
@@ -36,6 +36,10 @@
36
36
  "types": "./dist/enrolled-machine-store-file.d.ts",
37
37
  "import": "./dist/enrolled-machine-store-file.js"
38
38
  },
39
+ "./strand-peer-book-file": {
40
+ "types": "./dist/strand-peer-book-file.d.ts",
41
+ "import": "./dist/strand-peer-book-file.js"
42
+ },
39
43
  "./push-node": {
40
44
  "types": "./dist/push-node.d.ts",
41
45
  "import": "./dist/push-node.js"
@@ -73,7 +77,7 @@
73
77
  "@libp2p/tcp": "^11.0.10",
74
78
  "@libp2p/webrtc": "6.0.14",
75
79
  "@libp2p/websockets": "^10.1.3",
76
- "@optimystic/db-p2p-storage-fs": "^1.7.0",
80
+ "@optimystic/db-p2p-storage-fs": "^1.8.0",
77
81
  "@types/debug": "^4.1.12",
78
82
  "@types/node": "^25.0.10",
79
83
  "@vitest/coverage-v8": "^4.0.17",
@@ -88,12 +92,12 @@
88
92
  "@libp2p/interface": "^3.1.0",
89
93
  "@libp2p/peer-id": "^6.0.4",
90
94
  "@multiformats/multiaddr": "^12.5.1",
91
- "@optimystic/db-core": "^1.7.0",
92
- "@optimystic/db-p2p": "^1.7.0",
93
- "@optimystic/quereus-plugin-crypto": "^1.7.0",
94
- "@optimystic/quereus-plugin-optimystic": "^1.7.0",
95
+ "@optimystic/db-core": "^1.8.0",
96
+ "@optimystic/db-p2p": "^1.8.0",
97
+ "@optimystic/quereus-plugin-crypto": "^1.8.0",
98
+ "@optimystic/quereus-plugin-optimystic": "^1.8.0",
95
99
  "@quereus/quereus": "^4.20.0",
96
- "@serfab/quereus-plugin-sereus": "^1.6.0",
100
+ "@serfab/quereus-plugin-sereus": "^1.8.0",
97
101
  "debug": "^4.4.3",
98
102
  "libp2p": "^3.1.3",
99
103
  "uint8arrays": "^5.1.0"