@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
@@ -115,7 +115,8 @@
115
115
  * path.
116
116
  */
117
117
  import debug from 'debug';
118
- import { ADMISSION_DECISION_TIMEOUT_MS, decideWithinDeadline } from './membership-connection-gater.js';
118
+ import { decideWithinDeadline } from './membership-connection-gater.js';
119
+ import { ADMISSION_DECISION_TIMEOUT_MS } from './link-budget.js';
119
120
  const log = debug('sereus:cadre:strand-revocation');
120
121
  /**
121
122
  * Default cadence of the deny-set refresh. Bounded staleness is the accepted
@@ -1 +1 @@
1
- {"version":3,"file":"strand-revocation-enforcer.js","sourceRoot":"","sources":["../src/strand-revocation-enforcer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmHG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAAE,6BAA6B,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AAEvG,MAAM,GAAG,GAAG,KAAK,CAAC,gCAAgC,CAAC,CAAC;AAEpD;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,mCAAmC,GAAG,KAAM,CAAC;AA0C1D,MAAM,gBAAgB,GAA+B;IACnD,WAAW,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE;QACtB,MAAM,MAAM,GAAG,WAAW,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;QAClC,MAA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MAAM,EAAE,gCAAgC,CAAC,CAAC;QACjE,CAAC;QACD,2BAA2B,EAAE,KAAK,EAAE,MAAc,EAAoB,EAAE;YACtE,IAAI,MAAM,UAAU,CAAC,GAAG,EAAE,CAAC,IAAI,EAAE,2BAA2B,EAAE,CAAC,MAAM,CAAC,EAAE,6BAA6B,CAAC,EAAE,CAAC;gBACvG,OAAO,IAAI,CAAC;YACd,CAAC;YACD,OAAO,aAAa,CAAC,MAAM,EAAE,6BAA6B,CAAC,CAAC;QAC9D,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import type { Libp2p } from '@libp2p/interface';
2
- import type { OpenInvitation, FormStrandResult, StrandFormationDisclosure, StrandMembershipInvite } from './types.js';
3
- import { type StrandFormationManagerConfig } from './strand-formation-manager.js';
2
+ import type { OpenInvitation, FormStrandResult, StrandFormationDisclosure } from './types.js';
3
+ import { type MembershipInviteIssuer, type StrandFormationManagerConfig } from './strand-formation-manager.js';
4
4
  import { type FormationResultMessage } from './strand-formation-protocol.js';
5
5
  /**
6
6
  * Interface for validating formation disclosures
@@ -43,27 +43,43 @@ export type ResolvedHostStrand = {
43
43
  kind: 'missing';
44
44
  strandId: string;
45
45
  };
46
+ /** One redemption of an invite against an already-existing host strand (the record-only consent write). */
47
+ export interface FormationUsageParams {
48
+ token: string;
49
+ /** The joining peer's own ed25519 public key — written to `FormationUsage.PeerKey` and inside BOTH signed digests. */
50
+ peerKey: string;
51
+ /** The joiner's signature over the `'consent'` digest — written to `FormationUsage.PeerSig`. */
52
+ peerSignature: string;
53
+ /** Joiner-minted single-use nonce; both signed digests cover it. */
54
+ usageStampId: string;
55
+ strandId: string;
56
+ /** Exact text to write to `FormationUsage.Disclosure`; joiner and approver both sign these bytes. */
57
+ disclosure: string;
58
+ /** Aborted when the caller has given up; observed BEFORE any write so the invite stays unspent. */
59
+ signal?: AbortSignal;
60
+ }
61
+ /** A redemption the recorder has authorized (approval obtained, a seat still free) but not yet written. */
62
+ export interface AuthorizedFormationUsage {
63
+ /** Write the consent row. Abort and seat budget are re-checked inside the write lock. */
64
+ record(): Promise<void>;
65
+ }
46
66
  /**
47
67
  * Interface for recording formation usage
48
68
  */
49
69
  export interface FormationUsageRecorder {
50
70
  /**
51
- * Record that a formation invite was used
71
+ * Record that a formation invite was used. Where {@link authorizeUsage} is implemented, this
72
+ * is the same as authorizing and then calling `record()` straight away.
52
73
  */
53
- recordUsage(params: {
54
- token: string;
55
- /** The joining peer's own ed25519 public key — written to `FormationUsage.PeerKey` and inside BOTH signed digests. */
56
- peerKey: string;
57
- /** The joiner's signature over the `'consent'` digest — written to `FormationUsage.PeerSig`. */
58
- peerSignature: string;
59
- /** Joiner-minted single-use nonce; both signed digests cover it. */
60
- usageStampId: string;
61
- strandId: string;
62
- /** Exact text to write to `FormationUsage.Disclosure`; joiner and approver both sign these bytes. */
63
- disclosure: string;
64
- /** Aborted when the caller has given up; observed BEFORE any write so the invite stays unspent. */
65
- signal?: AbortSignal;
66
- }): Promise<void>;
74
+ recordUsage(params: FormationUsageParams): Promise<void>;
75
+ /**
76
+ * Everything {@link recordUsage} does short of the write: obtain the outside approval (when
77
+ * the invite demands one) and pre-check the seat budget, returning a handle whose `record()`
78
+ * writes the consent row with exactly the fields that were approved. Lets the manager ask
79
+ * before it writes anything into the host strand, and write consent only after.
80
+ * Optional: a recorder without it is treated as having nothing to ask up front.
81
+ */
82
+ authorizeUsage?(params: FormationUsageParams): Promise<AuthorizedFormationUsage>;
67
83
  /**
68
84
  * Check if a token has already been used (for single-use invites)
69
85
  */
@@ -177,7 +193,7 @@ export interface StrandSolicitationServiceOptions {
177
193
  * (null = open strand, throw = reject the redemption retryably, unwired = mock/test
178
194
  * posture: approve with no invitation).
179
195
  */
180
- issueMembershipInvite?: (strandId: string) => Promise<StrandMembershipInvite | null>;
196
+ issueMembershipInvite?: MembershipInviteIssuer;
181
197
  /** Configuration for the formation manager */
182
198
  formationConfig?: StrandFormationManagerConfig;
183
199
  }
@@ -227,11 +243,11 @@ export declare class StrandSolicitationService {
227
243
  * Register as a responder on a libp2p node.
228
244
  * This enables the node to handle incoming strand formation requests.
229
245
  */
230
- registerResponder(node: Libp2p): void;
246
+ registerResponder(node: Libp2p): Promise<void>;
231
247
  /**
232
248
  * Unregister as a responder from a libp2p node.
233
249
  */
234
- unregisterResponder(node: Libp2p): void;
250
+ unregisterResponder(node: Libp2p): Promise<void>;
235
251
  /**
236
252
  * Form a strand with a responder via an open invitation.
237
253
  *
@@ -88,15 +88,15 @@ export class StrandSolicitationService {
88
88
  * Register as a responder on a libp2p node.
89
89
  * This enables the node to handle incoming strand formation requests.
90
90
  */
91
- registerResponder(node) {
92
- this.getFormationManager().registerResponder(node);
91
+ async registerResponder(node) {
92
+ await this.getFormationManager().registerResponder(node);
93
93
  log('Registered as responder');
94
94
  }
95
95
  /**
96
96
  * Unregister as a responder from a libp2p node.
97
97
  */
98
- unregisterResponder(node) {
99
- this.getFormationManager().unregisterResponder(node);
98
+ async unregisterResponder(node) {
99
+ await this.getFormationManager().unregisterResponder(node);
100
100
  log('Unregistered as responder');
101
101
  }
102
102
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"strand-solicitation.js","sourceRoot":"","sources":["../src/strand-solicitation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,QAAQ,IAAI,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC5E,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAEvD,OAAO,EAAE,IAAI,EAAE,MAAM,mCAAmC,CAAC;AAOzD,sFAAsF;AACtF,OAAO,EAAE,eAAe,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AACjF,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,wBAAwB,EAAE,MAAM,kBA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,QAAQ,CAAC,CAAC;QACvE,CAAC;IACH,CAAC;CACF"}
@@ -30,32 +30,54 @@ import type { StrandInstance, WakeRequest, WakeAck } from './types.js';
30
30
  /** Protocol id for control-network push-wake (parallel to `/sereus/seed/1.0.0`). */
31
31
  export declare const WAKE_PROTOCOL = "/sereus/strand-wake/1.0.0";
32
32
  /**
33
- * Default budget for a WHOLE {@link dialWake} call, in ms — every candidate
34
- * address together, not each one.
33
+ * Default deadline for ONE wake attempt — dial, request, ack — at the default declared link
34
+ * (ms): `relayedRequestBudgetMs` in `link-budget.ts`, because the target may be reachable
35
+ * only through a relay and the attempt has to open that connection before the exchange.
36
+ * {@link dialWake} derives it from {@link DialWakeOptions.linkRoundTripMs} instead when given.
37
+ *
38
+ * It holds only link work because the receiver acks as soon as it has DECIDED, before the
39
+ * wake itself runs ({@link StrandWakeService.processWakeRequest}).
40
+ *
41
+ * NOTE: the receiver's membership check (two live control reads) runs inside this deadline and
42
+ * is not counted. In steady state those reads touch only held blocks and do not consult the
43
+ * cohort. If a wake or address request is seen timing out while the receiver's membership read
44
+ * is consulting, count one membership decision in this deadline or answer the check from the
45
+ * materialized authorized-peer snapshot. See docs/cadre-consistency.md → "Deadlines Over
46
+ * Optimystic's Reads and Commits".
47
+ */
48
+ export declare const DEFAULT_WAKE_TIMEOUT_MS: number;
49
+ /**
50
+ * Whole attempts one {@link dialWake} call budgets for: a stale signaling address, then the
51
+ * direct address that works.
52
+ */
53
+ export declare const WAKE_DIAL_ATTEMPTS = 2;
54
+ /**
55
+ * Default budget for a WHOLE {@link dialWake} call at the default declared link, in ms —
56
+ * every candidate address together, not each one: {@link WAKE_DIAL_ATTEMPTS} attempt
57
+ * deadlines.
35
58
  *
36
59
  * Without it the cost of a wake is (candidate count × {@link
37
60
  * DEFAULT_WAKE_TIMEOUT_MS}), a number nothing chooses or bounds. That is not
38
61
  * hypothetical: an address behind a dropped NAT mapping, or any host that
39
62
  * blackholes rather than sending a RST, burns its full attempt timeout instead
40
- * of failing in milliseconds, so a two-address peer costs 20 s and a
41
- * five-address one costs 50 s.
63
+ * of failing in milliseconds, so a five-address peer would cost five attempts.
42
64
  *
43
65
  * This makes the TARGET PEER the unit rather than the address — the same
44
66
  * decision, for the same reason, as
45
67
  * `DEFAULT_CONTROL_COHORT_DIAL_TIMEOUT_MS` in `peer-dial.ts`, though not the same
46
- * number: that one is sized to fit several dead addresses ahead of a working one,
68
+ * count: that one is sized to fit several dead addresses ahead of a working one,
47
69
  * while a wake target is expected to be awake and reachable on its first or second
48
- * address. 20 s is deliberately wider than one attempt timeout so a
49
- * reachable peer whose signaling address is stale still gets a genuine try at
50
- * its direct one; a peer needing longer than that is not "asleep and reachable",
51
- * which is the only case a wake is for. The last attempt inside the budget gets
52
- * whatever remains of it, so the call returns at the budget, not past it.
70
+ * address. Two whole attempts so a reachable peer whose signaling address is stale
71
+ * still gets a genuine try at its direct one; a peer needing longer than that is
72
+ * not "asleep and reachable", which is the only case a wake is for. The last
73
+ * attempt inside the budget gets whatever remains of it, so the call returns at
74
+ * the budget, not past it.
53
75
  *
54
76
  * Override per call with {@link DialWakeOptions.budgetMs} — tests that drive
55
77
  * dead addresses on purpose set it low so a dial's duration is a chosen number
56
78
  * rather than a transitive libp2p default stretched by machine load.
57
79
  */
58
- export declare const DEFAULT_WAKE_DIAL_BUDGET_MS = 20000;
80
+ export declare const DEFAULT_WAKE_DIAL_BUDGET_MS: number;
59
81
  /**
60
82
  * Dependencies the {@link StrandWakeService} receiver needs from its host
61
83
  * (`CadreNode`), injected so the service is testable without a full node.
@@ -67,8 +89,12 @@ export interface StrandWakeServiceOptions {
67
89
  getStrand(strandId: string): StrandInstance | undefined;
68
90
  /**
69
91
  * Trigger the local wake path for a hibernating/idle strand. Wired to
70
- * `CadreNode.wakeStrand` (→ `HibernationManager` → `resumeStrand`), whose
71
- * resume coalescing prevents a push-wake racing a concurrent check-in.
92
+ * `CadreNode.wakeStrand` (→ `HibernationManager` → `resumeStrand`); `resumeStrand`
93
+ * joins any resume already in flight, so a push-wake racing a check-in shares its
94
+ * runtime build.
95
+ *
96
+ * Started, not awaited: the ack goes back before the strand is up, and a wake
97
+ * that fails afterwards is logged here rather than reported to the sender.
72
98
  */
73
99
  wake(strandId: string): Promise<void>;
74
100
  /**
@@ -81,14 +107,19 @@ export interface StrandWakeServiceOptions {
81
107
  * Cap on concurrent inbound wake streams (defaults to
82
108
  * {@link DEFAULT_MAX_CONCURRENT_WAKES}). Over the cap, a non-accepting ack is
83
109
  * returned without invoking the wake path.
110
+ *
111
+ * It counts streams, not wakes: a wake started after its ack is no longer
112
+ * counted. Those are bounded by the strands this node participates in instead,
113
+ * since an unknown strand is refused before any wake starts and the wake path
114
+ * coalesces per strand.
84
115
  */
85
116
  maxConcurrent?: number;
86
117
  }
87
118
  /**
88
119
  * Receiver side of the push-wake protocol. Registers a `WAKE_PROTOCOL` handler
89
120
  * on the control node and, for each inbound {@link WakeRequest}, gates on cadre
90
- * membership, then resumes the named strand if it is hibernating/idle and we
91
- * participate in it — replying with a {@link WakeAck}.
121
+ * membership, replies with a {@link WakeAck}, and starts resuming the named
122
+ * strand if it is hibernating/idle and we participate in it.
92
123
  */
93
124
  export declare class StrandWakeService {
94
125
  private readonly options;
@@ -100,12 +131,16 @@ export declare class StrandWakeService {
100
131
  constructor(options: StrandWakeServiceOptions);
101
132
  /** Number of in-flight inbound wake streams. */
102
133
  get activeCount(): number;
103
- /** Register the wake protocol handler on the control node. */
104
- initialize(node: Libp2p): void;
134
+ /**
135
+ * Register the wake protocol handler on the control node. Rejects when libp2p
136
+ * refuses the registration; the node reference is kept only once the handler
137
+ * is in place.
138
+ */
139
+ initialize(node: Libp2p): Promise<void>;
105
140
  /** Unregister the handler and release the node reference. */
106
141
  shutdown(): Promise<void>;
107
142
  /**
108
- * Read the inbound request, decide + execute the wake, and write the ack.
143
+ * Read the inbound request, decide the wake, and write the ack.
109
144
  *
110
145
  * Three hardening layers, all reported as a non-accepting ack rather than a
111
146
  * dropped/hung stream: a concurrency cap (over {@link maxConcurrent}, reply
@@ -114,24 +149,41 @@ export declare class StrandWakeService {
114
149
  * existing malformed/oversized-frame guard.
115
150
  */
116
151
  private handleStream;
152
+ /** Read and decide one inbound request; any failure becomes a non-accepting ack. */
153
+ private answerStream;
117
154
  /**
118
- * Decide and execute the wake for a decoded request. Exposed (not private) so
155
+ * Decide the wake for a decoded request and start it. Exposed (not private) so
119
156
  * the decision matrix can be unit-tested directly.
120
157
  *
121
158
  * - Non-member sender → rejected (`accepted: false`).
122
159
  * - Unknown / not-participated strand → rejected.
123
- * - Hibernating or idle strand → resumed via the wake path, then `accepted`.
160
+ * - Hibernating or idle strand → `accepted` with that status, and a wake started.
124
161
  * - Already-live strand → no-op, `accepted` with current status.
162
+ *
163
+ * The wake is not awaited, so the ack means "a wake was started", not "the
164
+ * strand is up". Awaiting it would put the whole resume — a sibling address
165
+ * collection, a strand node build, a relay reservation drive — inside the
166
+ * sender's attempt deadline, coupling that deadline to this node's own budgets.
125
167
  */
126
168
  processWakeRequest(request: WakeRequest, remotePeerId: string): Promise<WakeAck>;
169
+ /**
170
+ * Start a wake without awaiting it — the same fire-and-forget an activity-driven
171
+ * local wake uses (`HibernationManager`), which also coalesces the two.
172
+ */
173
+ private startWake;
127
174
  }
128
175
  /** Options for {@link dialWake}. */
129
176
  export interface DialWakeOptions {
130
- /** Per-ATTEMPT timeout in ms (default {@link DEFAULT_WAKE_TIMEOUT_MS}). */
177
+ /**
178
+ * The sender's declared link round trip (`NetworkConfig.linkRoundTripMs`), from which
179
+ * both deadlines below are derived when not given. Unset means the declared default.
180
+ */
181
+ linkRoundTripMs?: number;
182
+ /** Per-ATTEMPT timeout in ms (default: derived as {@link DEFAULT_WAKE_TIMEOUT_MS} is). */
131
183
  timeoutMs?: number;
132
184
  /**
133
- * Budget for the whole call — every candidate together (default
134
- * {@link DEFAULT_WAKE_DIAL_BUDGET_MS}).
185
+ * Budget for the whole call — every candidate together (default:
186
+ * {@link WAKE_DIAL_ATTEMPTS} × the per-attempt timeout, as {@link DEFAULT_WAKE_DIAL_BUDGET_MS}).
135
187
  */
136
188
  budgetMs?: number;
137
189
  /** Override the protocol id (defaults to {@link WAKE_PROTOCOL}). */
@@ -161,5 +213,10 @@ export interface DialWakeOptions {
161
213
  * exactly the signaling address this ordering puts first — silently inverting
162
214
  * it, with no per-dial sorter override to opt out of. For the same reason this
163
215
  * does not use `dialPeerAddrs`, which puts relayed addresses last.
216
+ *
217
+ * NOTE: unlike `dialPeerAddrs`, this does not drop addresses that relay through this node, so a
218
+ * relay waking a peer that holds a reservation on it tries that address and gets `Can not dial
219
+ * self` (fast, then the next candidate). If wakes are ever sent from a relay to its own
220
+ * reservation holders routinely, share `dialPeerAddrs`'s filter here.
164
221
  */
165
222
  export declare function dialWake(node: Libp2p, addrs: Multiaddr[], request: WakeRequest, options?: DialWakeOptions): Promise<WakeAck>;
@@ -26,8 +26,9 @@
26
26
  */
27
27
  import debug from 'debug';
28
28
  import { decodeLengthPrefixedFrame } from './seed-bootstrap.js';
29
- import { writeFrame, exchangeFrame, readStreamToEnd } from './control-stream.js';
29
+ import { exchangeFrame, readStreamToEnd, replyAndClose } from './control-stream.js';
30
30
  import { tryAddrsInTurn } from './peer-dial.js';
31
+ import { relayedRequestBudgetMs } from './link-budget.js';
31
32
  const log = debug('sereus:cadre:strand-wake');
32
33
  /** Protocol id for control-network push-wake (parallel to `/sereus/seed/1.0.0`). */
33
34
  export const WAKE_PROTOCOL = '/sereus/strand-wake/1.0.0';
@@ -37,36 +38,57 @@ export const WAKE_PROTOCOL = '/sereus/strand-wake/1.0.0';
37
38
  * bytes a peer can make the receiver buffer per stream.
38
39
  */
39
40
  const MAX_WAKE_SIZE = 64 * 1024;
40
- /** Default time to wait for the ack before abandoning ONE wake dial attempt (ms). */
41
- const DEFAULT_WAKE_TIMEOUT_MS = 10000;
42
41
  /**
43
- * Default budget for a WHOLE {@link dialWake} call, in ms — every candidate
44
- * address together, not each one.
42
+ * Default deadline for ONE wake attempt — dial, request, ack — at the default declared link
43
+ * (ms): `relayedRequestBudgetMs` in `link-budget.ts`, because the target may be reachable
44
+ * only through a relay and the attempt has to open that connection before the exchange.
45
+ * {@link dialWake} derives it from {@link DialWakeOptions.linkRoundTripMs} instead when given.
46
+ *
47
+ * It holds only link work because the receiver acks as soon as it has DECIDED, before the
48
+ * wake itself runs ({@link StrandWakeService.processWakeRequest}).
49
+ *
50
+ * NOTE: the receiver's membership check (two live control reads) runs inside this deadline and
51
+ * is not counted. In steady state those reads touch only held blocks and do not consult the
52
+ * cohort. If a wake or address request is seen timing out while the receiver's membership read
53
+ * is consulting, count one membership decision in this deadline or answer the check from the
54
+ * materialized authorized-peer snapshot. See docs/cadre-consistency.md → "Deadlines Over
55
+ * Optimystic's Reads and Commits".
56
+ */
57
+ export const DEFAULT_WAKE_TIMEOUT_MS = relayedRequestBudgetMs();
58
+ /**
59
+ * Whole attempts one {@link dialWake} call budgets for: a stale signaling address, then the
60
+ * direct address that works.
61
+ */
62
+ export const WAKE_DIAL_ATTEMPTS = 2;
63
+ /**
64
+ * Default budget for a WHOLE {@link dialWake} call at the default declared link, in ms —
65
+ * every candidate address together, not each one: {@link WAKE_DIAL_ATTEMPTS} attempt
66
+ * deadlines.
45
67
  *
46
68
  * Without it the cost of a wake is (candidate count × {@link
47
69
  * DEFAULT_WAKE_TIMEOUT_MS}), a number nothing chooses or bounds. That is not
48
70
  * hypothetical: an address behind a dropped NAT mapping, or any host that
49
71
  * blackholes rather than sending a RST, burns its full attempt timeout instead
50
- * of failing in milliseconds, so a two-address peer costs 20 s and a
51
- * five-address one costs 50 s.
72
+ * of failing in milliseconds, so a five-address peer would cost five attempts.
52
73
  *
53
74
  * This makes the TARGET PEER the unit rather than the address — the same
54
75
  * decision, for the same reason, as
55
76
  * `DEFAULT_CONTROL_COHORT_DIAL_TIMEOUT_MS` in `peer-dial.ts`, though not the same
56
- * number: that one is sized to fit several dead addresses ahead of a working one,
77
+ * count: that one is sized to fit several dead addresses ahead of a working one,
57
78
  * while a wake target is expected to be awake and reachable on its first or second
58
- * address. 20 s is deliberately wider than one attempt timeout so a
59
- * reachable peer whose signaling address is stale still gets a genuine try at
60
- * its direct one; a peer needing longer than that is not "asleep and reachable",
61
- * which is the only case a wake is for. The last attempt inside the budget gets
62
- * whatever remains of it, so the call returns at the budget, not past it.
79
+ * address. Two whole attempts so a reachable peer whose signaling address is stale
80
+ * still gets a genuine try at its direct one; a peer needing longer than that is
81
+ * not "asleep and reachable", which is the only case a wake is for. The last
82
+ * attempt inside the budget gets whatever remains of it, so the call returns at
83
+ * the budget, not past it.
63
84
  *
64
85
  * Override per call with {@link DialWakeOptions.budgetMs} — tests that drive
65
86
  * dead addresses on purpose set it low so a dial's duration is a chosen number
66
87
  * rather than a transitive libp2p default stretched by machine load.
67
88
  */
68
- export const DEFAULT_WAKE_DIAL_BUDGET_MS = 20000;
89
+ export const DEFAULT_WAKE_DIAL_BUDGET_MS = WAKE_DIAL_ATTEMPTS * DEFAULT_WAKE_TIMEOUT_MS;
69
90
  /** Default time the receiver waits for an inbound wake frame before aborting (ms). */
91
+ // eslint-disable-next-line no-restricted-syntax -- link-independent: a receiver cap on one small request frame on a stream the peer already opened; it bounds a peer that opens a stream and never sends, not the dial
70
92
  const DEFAULT_WAKE_READ_TIMEOUT_MS = 10000;
71
93
  /** Default cap on concurrent inbound wake streams a single peer can pin open. */
72
94
  const DEFAULT_MAX_CONCURRENT_WAKES = 100;
@@ -84,8 +106,8 @@ async function readFrame(stream, timeoutMs) {
84
106
  /**
85
107
  * Receiver side of the push-wake protocol. Registers a `WAKE_PROTOCOL` handler
86
108
  * on the control node and, for each inbound {@link WakeRequest}, gates on cadre
87
- * membership, then resumes the named strand if it is hibernating/idle and we
88
- * participate in it — replying with a {@link WakeAck}.
109
+ * membership, replies with a {@link WakeAck}, and starts resuming the named
110
+ * strand if it is hibernating/idle and we participate in it.
89
111
  */
90
112
  export class StrandWakeService {
91
113
  constructor(options) {
@@ -100,18 +122,22 @@ export class StrandWakeService {
100
122
  get activeCount() {
101
123
  return this.activeStreams;
102
124
  }
103
- /** Register the wake protocol handler on the control node. */
104
- initialize(node) {
105
- this.node = node;
125
+ /**
126
+ * Register the wake protocol handler on the control node. Rejects when libp2p
127
+ * refuses the registration; the node reference is kept only once the handler
128
+ * is in place.
129
+ */
130
+ async initialize(node) {
106
131
  // `runOnLimitedConnection: true` is REQUIRED for the relay path: a NAT'd
107
132
  // receiver is reached over a circuit-relay connection, which libp2p marks
108
133
  // "limited" (the relay caps its data/duration). Without this the receiver
109
134
  // would refuse the inbound wake stream on exactly the connection the
110
135
  // protocol is designed to use (see the relay note on `dialWake`).
111
- void node.handle(WAKE_PROTOCOL, async (rawStream, rawConnection) => {
136
+ await node.handle(WAKE_PROTOCOL, async (rawStream, rawConnection) => {
112
137
  const remotePeerId = rawConnection.remotePeer.toString();
113
138
  await this.handleStream(rawStream, remotePeerId);
114
139
  }, { runOnLimitedConnection: true });
140
+ this.node = node;
115
141
  log('StrandWakeService registered handler: %s', WAKE_PROTOCOL);
116
142
  }
117
143
  /** Unregister the handler and release the node reference. */
@@ -123,7 +149,7 @@ export class StrandWakeService {
123
149
  }
124
150
  }
125
151
  /**
126
- * Read the inbound request, decide + execute the wake, and write the ack.
152
+ * Read the inbound request, decide the wake, and write the ack.
127
153
  *
128
154
  * Three hardening layers, all reported as a non-accepting ack rather than a
129
155
  * dropped/hung stream: a concurrency cap (over {@link maxConcurrent}, reply
@@ -135,58 +161,41 @@ export class StrandWakeService {
135
161
  log('Incoming wake request from: %s', remotePeerId);
136
162
  if (this.activeStreams >= this.maxConcurrent) {
137
163
  log('Rejecting wake from %s: %d concurrent streams at cap %d', remotePeerId, this.activeStreams, this.maxConcurrent);
138
- const ack = { accepted: false, reason: 'Too many concurrent wake requests' };
139
- try {
140
- writeFrame(stream, ack);
141
- }
142
- catch {
143
- // Ignore send errors on the reject path.
144
- }
145
- try {
146
- await stream.close();
147
- }
148
- catch {
149
- // Ignore close errors.
150
- }
164
+ await replyAndClose(stream, { accepted: false, reason: 'Too many concurrent wake requests' }, 'Wake');
151
165
  return;
152
166
  }
153
167
  this.activeStreams++;
168
+ try {
169
+ await replyAndClose(stream, await this.answerStream(stream, remotePeerId), 'Wake');
170
+ }
171
+ finally {
172
+ this.activeStreams--;
173
+ }
174
+ }
175
+ /** Read and decide one inbound request; any failure becomes a non-accepting ack. */
176
+ async answerStream(stream, remotePeerId) {
154
177
  try {
155
178
  const request = await readFrame(stream, this.readTimeoutMs);
156
- const ack = await this.processWakeRequest(request, remotePeerId);
157
- writeFrame(stream, ack);
179
+ return await this.processWakeRequest(request, remotePeerId);
158
180
  }
159
181
  catch (err) {
160
182
  log('Error handling wake request from %s: %o', remotePeerId, err);
161
- const ack = {
162
- accepted: false,
163
- reason: err instanceof Error ? err.message : 'Unknown error',
164
- };
165
- try {
166
- writeFrame(stream, ack);
167
- }
168
- catch {
169
- // Ignore send errors on the error path.
170
- }
171
- }
172
- finally {
173
- this.activeStreams--;
174
- try {
175
- await stream.close();
176
- }
177
- catch {
178
- // Ignore close errors.
179
- }
183
+ return { accepted: false, reason: err instanceof Error ? err.message : 'Unknown error' };
180
184
  }
181
185
  }
182
186
  /**
183
- * Decide and execute the wake for a decoded request. Exposed (not private) so
187
+ * Decide the wake for a decoded request and start it. Exposed (not private) so
184
188
  * the decision matrix can be unit-tested directly.
185
189
  *
186
190
  * - Non-member sender → rejected (`accepted: false`).
187
191
  * - Unknown / not-participated strand → rejected.
188
- * - Hibernating or idle strand → resumed via the wake path, then `accepted`.
192
+ * - Hibernating or idle strand → `accepted` with that status, and a wake started.
189
193
  * - Already-live strand → no-op, `accepted` with current status.
194
+ *
195
+ * The wake is not awaited, so the ack means "a wake was started", not "the
196
+ * strand is up". Awaiting it would put the whole resume — a sibling address
197
+ * collection, a strand node build, a relay reservation drive — inside the
198
+ * sender's attempt deadline, coupling that deadline to this node's own budgets.
190
199
  */
191
200
  async processWakeRequest(request, remotePeerId) {
192
201
  // The injected membership predicate is the whole v1 authorization (CadreNode
@@ -200,15 +209,25 @@ export class StrandWakeService {
200
209
  log('Rejecting wake for unknown/unparticipated strand %s', request.strandId);
201
210
  return { accepted: false, reason: 'Strand not found or not participated in' };
202
211
  }
203
- if (instance.status === 'hibernating' || instance.status === 'idle') {
212
+ // Read before the wake starts: the wake path mutates the shared instance.
213
+ const status = instance.status;
214
+ if (status === 'hibernating' || status === 'idle') {
204
215
  log('Waking strand %s on push from %s (reason=%s)', request.strandId, remotePeerId, request.reason ?? 'unspecified');
205
- await this.options.wake(request.strandId);
216
+ this.startWake(request.strandId);
206
217
  }
207
218
  else {
208
- log('Strand %s already %s; push-wake is a no-op', request.strandId, instance.status);
219
+ log('Strand %s already %s; push-wake is a no-op', request.strandId, status);
209
220
  }
210
- // The wake path mutates the shared instance, so re-read its current status.
211
- return { accepted: true, status: instance.status };
221
+ return { accepted: true, status };
222
+ }
223
+ /**
224
+ * Start a wake without awaiting it — the same fire-and-forget an activity-driven
225
+ * local wake uses (`HibernationManager`), which also coalesces the two.
226
+ */
227
+ startWake(strandId) {
228
+ void this.options.wake(strandId).catch((err) => {
229
+ log('Push-wake of strand %s failed after it was accepted: %o', strandId, err);
230
+ });
212
231
  }
213
232
  }
214
233
  /**
@@ -235,15 +254,21 @@ export class StrandWakeService {
235
254
  * exactly the signaling address this ordering puts first — silently inverting
236
255
  * it, with no per-dial sorter override to opt out of. For the same reason this
237
256
  * does not use `dialPeerAddrs`, which puts relayed addresses last.
257
+ *
258
+ * NOTE: unlike `dialPeerAddrs`, this does not drop addresses that relay through this node, so a
259
+ * relay waking a peer that holds a reservation on it tries that address and gets `Can not dial
260
+ * self` (fast, then the next candidate). If wakes are ever sent from a relay to its own
261
+ * reservation holders routinely, share `dialPeerAddrs`'s filter here.
238
262
  */
239
263
  export async function dialWake(node, addrs, request, options = {}) {
240
264
  if (addrs.length === 0) {
241
265
  throw new Error('No dialable address for wake target');
242
266
  }
243
267
  const protocolId = options.protocolId ?? WAKE_PROTOCOL;
268
+ const perAddressMs = options.timeoutMs ?? relayedRequestBudgetMs(options.linkRoundTripMs);
244
269
  const budget = {
245
- perAddressMs: options.timeoutMs ?? DEFAULT_WAKE_TIMEOUT_MS,
246
- totalMs: options.budgetMs ?? DEFAULT_WAKE_DIAL_BUDGET_MS,
270
+ perAddressMs,
271
+ totalMs: options.budgetMs ?? WAKE_DIAL_ATTEMPTS * perAddressMs,
247
272
  };
248
273
  // The attempt's signal aborts the in-flight dialProtocol and resets the live
249
274
  // stream, so neither the connect nor the ack-read leaks.