@serfab/cadre-core 1.9.0 → 1.10.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 (87) hide show
  1. package/dist/cadre-node.d.ts +148 -17
  2. package/dist/cadre-node.js +361 -45
  3. package/dist/cadre-node.js.map +1 -1
  4. package/dist/control-authorization.d.ts +2 -2
  5. package/dist/control-authorization.js +1 -0
  6. package/dist/control-authorization.js.map +1 -1
  7. package/dist/control-cohort.d.ts +1 -1
  8. package/dist/control-cohort.js +1 -1
  9. package/dist/control-database.d.ts +105 -14
  10. package/dist/control-database.js +242 -73
  11. package/dist/control-database.js.map +1 -1
  12. package/dist/control-formation-recorder.d.ts +6 -6
  13. package/dist/control-formation-recorder.js +7 -8
  14. package/dist/control-formation-recorder.js.map +1 -1
  15. package/dist/control-schema.d.ts +1 -1
  16. package/dist/control-schema.js +90 -3
  17. package/dist/control-schema.js.map +1 -1
  18. package/dist/control-write-retry.d.ts +21 -15
  19. package/dist/control-write-retry.js +21 -15
  20. package/dist/control-write-retry.js.map +1 -1
  21. package/dist/index.d.ts +5 -3
  22. package/dist/index.js +6 -2
  23. package/dist/index.js.map +1 -1
  24. package/dist/invitation-bootstrap.d.ts +32 -0
  25. package/dist/invitation-bootstrap.js +30 -0
  26. package/dist/invitation-bootstrap.js.map +1 -0
  27. package/dist/link-budget.d.ts +204 -119
  28. package/dist/link-budget.js +208 -120
  29. package/dist/link-budget.js.map +1 -1
  30. package/dist/membership-connection-gater.d.ts +3 -3
  31. package/dist/membership-connection-gater.js +3 -3
  32. package/dist/peer-dial.d.ts +18 -14
  33. package/dist/peer-dial.js +18 -14
  34. package/dist/peer-dial.js.map +1 -1
  35. package/dist/peer-join-backfill.d.ts +3 -3
  36. package/dist/pending-join-runner.d.ts +186 -0
  37. package/dist/pending-join-runner.js +649 -0
  38. package/dist/pending-join-runner.js.map +1 -0
  39. package/dist/push-fanout.d.ts +1 -1
  40. package/dist/push-fanout.js +1 -1
  41. package/dist/seed-bootstrap.d.ts +2 -2
  42. package/dist/seed-bootstrap.js +1 -1
  43. package/dist/strand-addr-protocol.js +2 -2
  44. package/dist/strand-formation-deadlines.d.ts +5 -5
  45. package/dist/strand-formation-deadlines.js +5 -5
  46. package/dist/strand-formation-manager.d.ts +18 -4
  47. package/dist/strand-formation-manager.js +48 -33
  48. package/dist/strand-formation-manager.js.map +1 -1
  49. package/dist/strand-formation-protocol.d.ts +71 -14
  50. package/dist/strand-formation-protocol.js +222 -47
  51. package/dist/strand-formation-protocol.js.map +1 -1
  52. package/dist/strand-formation-rejection.d.ts +94 -0
  53. package/dist/strand-formation-rejection.js +77 -0
  54. package/dist/strand-formation-rejection.js.map +1 -0
  55. package/dist/strand-instance-manager.js +4 -1
  56. package/dist/strand-instance-manager.js.map +1 -1
  57. package/dist/strand-solicitation.d.ts +11 -3
  58. package/dist/strand-solicitation.js +9 -0
  59. package/dist/strand-solicitation.js.map +1 -1
  60. package/dist/types.d.ts +103 -17
  61. package/dist/types.js +5 -9
  62. package/dist/types.js.map +1 -1
  63. package/package.json +22 -22
  64. package/src/cadre-node.ts +399 -46
  65. package/src/control-authorization.ts +117 -116
  66. package/src/control-cohort.ts +1 -1
  67. package/src/control-database.ts +303 -82
  68. package/src/control-formation-recorder.ts +8 -9
  69. package/src/control-schema.ts +90 -3
  70. package/src/control-write-retry.ts +21 -15
  71. package/src/index.ts +21 -1
  72. package/src/invitation-bootstrap.ts +40 -0
  73. package/src/link-budget.ts +221 -120
  74. package/src/membership-connection-gater.ts +3 -3
  75. package/src/peer-dial.ts +18 -14
  76. package/src/peer-join-backfill.ts +3 -3
  77. package/src/pending-join-runner.ts +735 -0
  78. package/src/push-fanout.ts +1 -1
  79. package/src/seed-bootstrap.ts +2 -2
  80. package/src/strand-addr-protocol.ts +2 -2
  81. package/src/strand-formation-deadlines.ts +5 -5
  82. package/src/strand-formation-manager.ts +62 -37
  83. package/src/strand-formation-protocol.ts +1036 -802
  84. package/src/strand-formation-rejection.ts +129 -0
  85. package/src/strand-instance-manager.ts +4 -1
  86. package/src/strand-solicitation.ts +17 -4
  87. package/src/types.ts +99 -17
@@ -36,9 +36,9 @@
36
36
  * node has at least one UNEXPIRED, NOT-FULLY-CONSUMED open invitation
37
37
  * outstanding (`StrandSolicitationService.hasOutstandingInvitation` — the
38
38
  * tokens this process minted or published, plus any still-redeemable
39
- * `FormationInvite` row the usage recorder can see). Merely registering the
40
- * responder (`CadreNode.initializeStrandSolicitation`) does NOT suspend it,
41
- * so an app that registers eagerly at node bring-up keeps a live gate. The
39
+ * `FormationInvite` row the usage recorder can see). Registering the
40
+ * responder does NOT suspend it, so every node — each registers one at
41
+ * `CadreNode.start` — keeps a live gate. The
42
42
  * handler's own trust decision remains the per-token check, which is
43
43
  * strictly finer than this one: a peer admitted here can still be rejected
44
44
  * in-protocol for a bogus or spent token.
package/src/peer-dial.ts CHANGED
@@ -2,12 +2,15 @@
2
2
  * Dialing one peer from a list of candidate addresses, so that an address that
3
3
  * never answers cannot use up the time the others needed.
4
4
  *
5
- * libp2p's own multi-address dial (`libp2p.dial(addrs)`, libp2p 3.1.3's
6
- * `DialQueue.dialPeer`) tries the addresses ONE AT A TIME under ONE signal, with
7
- * no time limit per address. An address whose connection attempt is silently
8
- * dropped — a firewall, a subnet the dialer cannot route to, a virtual adapter's
9
- * address a Windows host reports alongside its real ones — holds that dial until
10
- * the whole signal expires, and every address sorted after it is never tried. It
5
+ * libp2p's own multi-address dial (`libp2p.dial(addrs)`, `DialQueue.dialPeer`)
6
+ * tries the addresses ONE AT A TIME under ONE signal. Its only per-address limit
7
+ * is the connection manager's `addressDialTimeout` (libp2p 3.3+), which cadre
8
+ * sizes for a cold relayed open through two admission decisions
9
+ * (`optimysticDialLimits` in `link-budget.ts`: 39 s at the default declared
10
+ * link). An address whose connection attempt is silently dropped — a firewall, a
11
+ * subnet the dialer cannot route to, a virtual adapter's address a Windows host
12
+ * reports alongside its real ones — holds that dial for that long or until the
13
+ * whole signal expires, and the addresses sorted after it get what is left. It
11
14
  * also sorts the list itself (`defaultAddressSorter`), putting loopback addresses
12
15
  * last, behind exactly the LAN addresses most likely to be dropped. A phone
13
16
  * borrowing a node from a cadre-host whose only reachable address was the
@@ -34,17 +37,17 @@ const log = debug('sereus:cadre:peer-dial');
34
37
 
35
38
  /**
36
39
  * Default limit on ONE address's dial attempt, in ms, at the DEFAULT declared link round trip:
37
- * `RELAYED_DIAL_ROUND_TRIPS` (4) x `DECLARED_LINK_ROUND_TRIP_MS` (3500 ms) plus the called
38
- * machine's `ADMISSION_DECISION_TIMEOUT_MS` (2000 ms) = 16 000 ms (`relayedDialBudgetMs`). It
39
- * was a fixed 8000 ms before it was derived.
40
+ * `RELAYED_DIAL_ROUND_TRIPS` (5) x `DECLARED_LINK_ROUND_TRIP_MS` (3500 ms) plus
41
+ * `DIAL_ADMISSION_DECISIONS` (2) x `ADMISSION_DECISION_TIMEOUT_MS` (2000 ms) = 21 500 ms
42
+ * (`relayedDialBudgetMs`). It was a fixed 8000 ms before it was derived.
40
43
  *
41
44
  * It has to cover the slowest address that should succeed, because an attempt
42
45
  * that needs longer fails the same way on every retry. That is a relayed dial on
43
46
  * a mobile link: connect to the relay (transport, encryption and multiplexer
44
47
  * handshakes, when no relay connection is open yet), open the circuit, then run
45
48
  * both handshakes again end to end through the relay. `link-budget.ts` is where that
46
- * reasoning is now a measured count instead of an estimate — four link round trips, measured at
47
- * 12 094 ms on a link whose round trip is 3 s — so the value MOVES with a host's
49
+ * reasoning is now a measured count instead of an estimate — five link round trips, measured at
50
+ * 15 113 ms on a link whose round trip is 3 s — so the value MOVES with a host's
48
51
  * `NetworkConfig.linkRoundTripMs` rather than pinning the band this node can reach to whatever
49
52
  * number was typed here. A direct dial that works is far quicker — a phone's WebSocket dial to
50
53
  * a node forwarded over `adb reverse` measured 1.6 s end to end.
@@ -200,9 +203,10 @@ export async function dialPeerAddrs(
200
203
  * one address and immediately dialing the next for the same peer therefore
201
204
  * joins the dying job, which rejects the new dial with `AbortError` before it
202
205
  * touches the network — the next address is never tried. Seen against libp2p
203
- * 3.1.3; `test/peer-dial.spec.ts` dials real nodes so an upgrade that changes it
204
- * shows up there. All of the queue's cleanup runs as microtasks, so it has
205
- * finished by the time a macrotask runs.
206
+ * 3.1.3, and the queue's join is unchanged in 3.3.11; `test/peer-dial.spec.ts`
207
+ * dials real nodes so an upgrade that changes it shows up there. All of the
208
+ * queue's cleanup runs as microtasks, so it has finished by the time a
209
+ * macrotask runs.
206
210
  */
207
211
  export async function tryAddrsInTurn<T>(
208
212
  addrs: readonly Multiaddr[],
@@ -175,9 +175,9 @@ export interface PeerJoinBackfillConfig {
175
175
  /** Max blocks per push message. Default 64. */
176
176
  maxChunkBlocks?: number;
177
177
  /**
178
- * Per-push dial deadline, ms. Default {@link peerJoinPushBudget}'s `dialTimeoutMs` — four link
179
- * round trips at the declared link plus the called machine's admission decision, 16 000 ms as
180
- * shipped. NOT a fixed number: a relayed dial
178
+ * Per-push dial deadline, ms. Default {@link peerJoinPushBudget}'s `dialTimeoutMs` — five link
179
+ * round trips at the declared link plus two admission decisions (a party-run relay's and the
180
+ * called machine's), 21 500 ms as shipped. NOT a fixed number: a relayed dial
181
181
  * costs a fixed number of exchanges, so a host on a slower link moves this (and every other
182
182
  * cadre dial budget) by declaring `NetworkConfig.linkRoundTripMs`. Naming it here still wins
183
183
  * over the derived value — `link-budget.ts` has the counts and the measurement.