@serfab/cadre-core 1.7.0 → 1.9.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 (188) hide show
  1. package/README.md +8 -6
  2. package/dist/cadre-node.d.ts +527 -206
  3. package/dist/cadre-node.js +1084 -528
  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 +10 -10
  45. package/dist/index.js +25 -20
  46. package/dist/index.js.map +1 -1
  47. package/dist/joined-strand-store.d.ts +90 -25
  48. package/dist/joined-strand-store.js +223 -55
  49. package/dist/joined-strand-store.js.map +1 -1
  50. package/dist/key-store-file.js +14 -5
  51. package/dist/key-store-file.js.map +1 -1
  52. package/dist/link-budget.d.ts +367 -69
  53. package/dist/link-budget.js +375 -72
  54. package/dist/link-budget.js.map +1 -1
  55. package/dist/membership-connection-gater.d.ts +30 -43
  56. package/dist/membership-connection-gater.js +31 -42
  57. package/dist/membership-connection-gater.js.map +1 -1
  58. package/dist/node-local-snapshot.d.ts +6 -4
  59. package/dist/node-local-snapshot.js +7 -3
  60. package/dist/node-local-snapshot.js.map +1 -1
  61. package/dist/peer-dial.d.ts +24 -4
  62. package/dist/peer-dial.js +74 -5
  63. package/dist/peer-dial.js.map +1 -1
  64. package/dist/peer-join-backfill.d.ts +2 -10
  65. package/dist/peer-join-backfill.js +8 -8
  66. package/dist/peer-join-backfill.js.map +1 -1
  67. package/dist/push-fanout.d.ts +6 -0
  68. package/dist/push-fanout.js +6 -0
  69. package/dist/push-fanout.js.map +1 -1
  70. package/dist/relay-reservation.d.ts +3 -1
  71. package/dist/relay-reservation.js +3 -1
  72. package/dist/relay-reservation.js.map +1 -1
  73. package/dist/relay-server.d.ts +79 -0
  74. package/dist/relay-server.js +74 -0
  75. package/dist/relay-server.js.map +1 -0
  76. package/dist/seed-bootstrap.d.ts +57 -4
  77. package/dist/seed-bootstrap.js +107 -83
  78. package/dist/seed-bootstrap.js.map +1 -1
  79. package/dist/storage-scope.d.ts +33 -17
  80. package/dist/storage-scope.js +44 -23
  81. package/dist/storage-scope.js.map +1 -1
  82. package/dist/strand-addr-protocol.d.ts +58 -21
  83. package/dist/strand-addr-protocol.js +133 -85
  84. package/dist/strand-addr-protocol.js.map +1 -1
  85. package/dist/strand-database.d.ts +20 -2
  86. package/dist/strand-database.js +42 -5
  87. package/dist/strand-database.js.map +1 -1
  88. package/dist/strand-first-sync-gate.d.ts +59 -21
  89. package/dist/strand-first-sync-gate.js +58 -19
  90. package/dist/strand-first-sync-gate.js.map +1 -1
  91. package/dist/strand-formation-deadlines.d.ts +151 -0
  92. package/dist/strand-formation-deadlines.js +171 -0
  93. package/dist/strand-formation-deadlines.js.map +1 -0
  94. package/dist/strand-formation-manager.d.ts +63 -30
  95. package/dist/strand-formation-manager.js +67 -41
  96. package/dist/strand-formation-manager.js.map +1 -1
  97. package/dist/strand-formation-protocol.d.ts +45 -46
  98. package/dist/strand-formation-protocol.js +62 -126
  99. package/dist/strand-formation-protocol.js.map +1 -1
  100. package/dist/strand-fret-addrs.d.ts +54 -0
  101. package/dist/strand-fret-addrs.js +108 -0
  102. package/dist/strand-fret-addrs.js.map +1 -0
  103. package/dist/strand-instance-manager.d.ts +122 -44
  104. package/dist/strand-instance-manager.js +270 -114
  105. package/dist/strand-instance-manager.js.map +1 -1
  106. package/dist/strand-membership-writer.d.ts +6 -0
  107. package/dist/strand-membership-writer.js +11 -0
  108. package/dist/strand-membership-writer.js.map +1 -1
  109. package/dist/strand-network-state-file.d.ts +12 -0
  110. package/dist/strand-network-state-file.js +38 -0
  111. package/dist/strand-network-state-file.js.map +1 -0
  112. package/dist/strand-network-state.d.ts +111 -0
  113. package/dist/strand-network-state.js +191 -0
  114. package/dist/strand-network-state.js.map +1 -0
  115. package/dist/strand-revocation-enforcer.js +2 -1
  116. package/dist/strand-revocation-enforcer.js.map +1 -1
  117. package/dist/strand-solicitation.d.ts +36 -20
  118. package/dist/strand-solicitation.js +4 -4
  119. package/dist/strand-solicitation.js.map +1 -1
  120. package/dist/strand-wake-protocol.d.ts +80 -23
  121. package/dist/strand-wake-protocol.js +89 -64
  122. package/dist/strand-wake-protocol.js.map +1 -1
  123. package/dist/types.d.ts +148 -61
  124. package/dist/types.js +4 -3
  125. package/dist/types.js.map +1 -1
  126. package/package.json +11 -10
  127. package/src/cadre-node.ts +8400 -7776
  128. package/src/control-authorization.ts +2 -1
  129. package/src/control-cohort.ts +6 -0
  130. package/src/control-database.ts +122 -18
  131. package/src/control-formation-recorder.ts +354 -305
  132. package/src/control-read-retry.ts +14 -12
  133. package/src/control-schema.ts +67 -5
  134. package/src/control-stream.ts +25 -1
  135. package/src/control-write-retry.ts +13 -2
  136. package/src/delegate-admission.ts +23 -13
  137. package/src/diagnostics/connection-path.ts +0 -7
  138. package/src/formation-approval.ts +610 -604
  139. package/src/fs-atomic.ts +14 -4
  140. package/src/hibernation-manager.ts +638 -437
  141. package/src/index.ts +43 -65
  142. package/src/joined-strand-store.ts +247 -57
  143. package/src/key-store-file.ts +14 -5
  144. package/src/link-budget.ts +393 -74
  145. package/src/membership-connection-gater.ts +31 -45
  146. package/src/node-local-snapshot.ts +12 -7
  147. package/src/peer-dial.ts +81 -7
  148. package/src/peer-join-backfill.ts +10 -9
  149. package/src/push-fanout.ts +6 -0
  150. package/src/relay-reservation.ts +3 -1
  151. package/src/relay-server.ts +98 -0
  152. package/src/seed-bootstrap.ts +133 -91
  153. package/src/storage-scope.ts +44 -23
  154. package/src/strand-addr-protocol.ts +547 -458
  155. package/src/strand-database.ts +287 -242
  156. package/src/strand-first-sync-gate.ts +58 -19
  157. package/src/strand-formation-deadlines.ts +227 -0
  158. package/src/strand-formation-manager.ts +700 -647
  159. package/src/strand-formation-protocol.ts +106 -154
  160. package/src/strand-fret-addrs.ts +145 -0
  161. package/src/strand-instance-manager.ts +307 -140
  162. package/src/strand-membership-writer.ts +12 -0
  163. package/src/strand-network-state-file.ts +40 -0
  164. package/src/strand-network-state.ts +243 -0
  165. package/src/strand-revocation-enforcer.ts +2 -1
  166. package/src/strand-solicitation.ts +519 -500
  167. package/src/strand-wake-protocol.ts +401 -355
  168. package/src/types.ts +150 -61
  169. package/dist/strand-peer-book-file.d.ts +0 -12
  170. package/dist/strand-peer-book-file.js +0 -37
  171. package/dist/strand-peer-book-file.js.map +0 -1
  172. package/dist/strand-peer-book-protocol.d.ts +0 -159
  173. package/dist/strand-peer-book-protocol.js +0 -360
  174. package/dist/strand-peer-book-protocol.js.map +0 -1
  175. package/dist/strand-peer-book-swap.d.ts +0 -104
  176. package/dist/strand-peer-book-swap.js +0 -284
  177. package/dist/strand-peer-book-swap.js.map +0 -1
  178. package/dist/strand-peer-book.d.ts +0 -159
  179. package/dist/strand-peer-book.js +0 -354
  180. package/dist/strand-peer-book.js.map +0 -1
  181. package/dist/strand-peer-observer.d.ts +0 -88
  182. package/dist/strand-peer-observer.js +0 -180
  183. package/dist/strand-peer-observer.js.map +0 -1
  184. package/src/strand-peer-book-file.ts +0 -39
  185. package/src/strand-peer-book-protocol.ts +0 -463
  186. package/src/strand-peer-book-swap.ts +0 -338
  187. package/src/strand-peer-book.ts +0 -468
  188. package/src/strand-peer-observer.ts +0 -235
@@ -27,6 +27,32 @@ export class HibernationManager {
27
27
  * concurrent wake.
28
28
  */
29
29
  this.wakePromises = new Map();
30
+ /**
31
+ * Hibernating strands whose armed check-in a wake cancelled, held until that wake
32
+ * settles. A wake that leaves the strand hibernating again (a failed rebuild, or a probe's
33
+ * window that re-quiesced it) re-arms the chain from here ({@link rearmAfterWake}); without
34
+ * it the strand is left with no runtime and nothing scheduled to retry.
35
+ */
36
+ this.checkInsCancelledByWake = new Set();
37
+ /**
38
+ * Strands an on-demand probe (`CadreNode.serviceWake`) holds from its wake to the end of its
39
+ * window, with whether a check-in chain was armed when it began. While held, the probe's end
40
+ * ({@link endProbe}) — not the wake's settle — sets the timers, since the window may
41
+ * re-hibernate the strand after the wake settled.
42
+ */
43
+ this.probes = new Map();
44
+ /**
45
+ * Strands whose check-in is running (its timer fired, `onCheckIn` not yet returned). A
46
+ * force-hibernate or untrack removes the strand, so the run's return schedules nothing: a
47
+ * check-in already running is part of the chain those calls cancel.
48
+ */
49
+ this.runningCheckIns = new Set();
50
+ /**
51
+ * Strands whose timer-driven hibernate is running (`onHibernate` not yet returned). A
52
+ * force-hibernate, untrack or stop removes the strand, so the return starts no check-in
53
+ * chain: a force-hibernate that joins the quiesce means "keep it down".
54
+ */
55
+ this.timerHibernates = new Set();
30
56
  this.running = false;
31
57
  this.config = config;
32
58
  this.callbacks = callbacks;
@@ -69,13 +95,17 @@ export class HibernationManager {
69
95
  clearTimeout(timer);
70
96
  }
71
97
  this.timers.clear();
72
- for (const timer of this.checkInTimers.values()) {
98
+ for (const { timer } of this.checkInTimers.values()) {
73
99
  clearTimeout(timer);
74
100
  }
75
101
  this.checkInTimers.clear();
76
102
  // In-flight wakes clean themselves up via their finally; drop the references
77
103
  // so a fresh start coalesces cleanly.
78
104
  this.wakePromises.clear();
105
+ this.checkInsCancelledByWake.clear();
106
+ this.probes.clear();
107
+ this.runningCheckIns.clear();
108
+ this.timerHibernates.clear();
79
109
  log('HibernationManager stopped');
80
110
  }
81
111
  /**
@@ -111,8 +141,14 @@ export class HibernationManager {
111
141
  }
112
142
  // Cancel idle/hibernate + check-in timers BEFORE quiescing so nothing fights
113
143
  // the imperative hibernate (a stale hibernate timer firing on the quiesced
114
- // strand, or a check-in resuming a strand the caller wants kept down).
144
+ // strand, or a check-in resuming a strand the caller wants kept down) — including
145
+ // a chain an in-flight wake or probe would restore when it settles, or one a
146
+ // timer-driven hibernate still quiescing would start when it returns.
115
147
  this.clearTimers(instance.strandId);
148
+ this.checkInsCancelledByWake.delete(instance.strandId);
149
+ this.probes.delete(instance.strandId);
150
+ this.runningCheckIns.delete(instance.strandId);
151
+ this.timerHibernates.delete(instance.strandId);
116
152
  await this.callbacks.onHibernate(instance.strandId);
117
153
  log('forceHibernate: strand %s hibernated (timers cancelled, not re-armed)', instance.strandId);
118
154
  return true;
@@ -138,6 +174,10 @@ export class HibernationManager {
138
174
  */
139
175
  untrackStrand(strandId) {
140
176
  this.clearTimers(strandId);
177
+ this.checkInsCancelledByWake.delete(strandId);
178
+ this.probes.delete(strandId);
179
+ this.runningCheckIns.delete(strandId);
180
+ this.timerHibernates.delete(strandId);
141
181
  log('Untracked strand %s from hibernation', strandId);
142
182
  }
143
183
  /**
@@ -148,28 +188,15 @@ export class HibernationManager {
148
188
  return;
149
189
  const { strandId, status, latencyHint } = instance;
150
190
  instance.lastActivity = new Date();
151
- // If idle or hibernating, wake up. Coalesce so two near-simultaneous
191
+ // If idle, hibernating or on its way there, wake up. Coalesce so two near-simultaneous
152
192
  // activities don't each fire onWake (which would rebuild two libp2p nodes).
153
- if (status === 'idle' || status === 'hibernating') {
193
+ if (status === 'idle' || status === 'hibernating' || this.callbacks.isQuiescing(strandId)) {
154
194
  log('Activity on %s strand %s - waking', status, strandId);
155
- this.clearTimers(strandId);
195
+ this.clearTimersForWake(strandId);
156
196
  // Fire-and-forget; force-wake awaiters see errors, so swallow (and log)
157
- // here to avoid an unhandled rejection on this best-effort path.
158
- //
159
- // Once the wake settles (CadreNode rebuilds the runtime and marks the
160
- // strand `active`), re-arm the idle→hibernate→check-in cycle. Without this
161
- // a strand that wakes then goes quiet stays `active` forever and never
162
- // re-hibernates — so the check-in backoff could never restart at base.
163
- // Guarded on `active` so a wake that did not transition (a coalesced
164
- // no-op, or a still-mid-flight rebuild) never arms a stray timer.
165
- void this.beginWake(strandId).then(() => {
166
- if (this.running && instance.status === 'active') {
167
- const timeouts = this.getTimeouts(instance.latencyHint);
168
- if (timeouts.idleTimeout !== Infinity) {
169
- this.scheduleIdleTransition(instance);
170
- }
171
- }
172
- }).catch((err) => {
197
+ // here to avoid an unhandled rejection on this best-effort path. The wake's
198
+ // settle re-arms the timers for the state it leaves (see beginWake).
199
+ void this.beginWake(instance).catch((err) => {
173
200
  log('Activity-driven wake failed for strand %s: %o', strandId, err);
174
201
  });
175
202
  return;
@@ -183,19 +210,59 @@ export class HibernationManager {
183
210
  }
184
211
  }
185
212
  /**
186
- * Force wake a hibernating strand
213
+ * Force-wake a strand (an explicit or peer-sent wake). Works whether or not hibernation is
214
+ * enabled; once the wake settles the strand has the timers its resulting state calls for
215
+ * ({@link rearmAfterWake}).
187
216
  */
188
- async wakeStrand(strandId) {
189
- this.clearTimers(strandId);
190
- await this.beginWake(strandId);
217
+ async wakeStrand(instance) {
218
+ this.clearTimersForWake(instance.strandId);
219
+ await this.beginWake(instance);
220
+ }
221
+ /**
222
+ * Wake a strand for an on-demand probe (`CadreNode.serviceWake`), holding it until
223
+ * {@link endProbe}: the probe's window runs after the wake settles and may re-hibernate the
224
+ * strand, so the wake's settle arms nothing. Records whether a check-in chain was armed —
225
+ * or already cancelled by a wake this one joins — so the end can restore it.
226
+ */
227
+ async probeWake(instance) {
228
+ const { strandId } = instance;
229
+ const hadCheckInChain = this.checkInTimers.has(strandId) || this.checkInsCancelledByWake.has(strandId);
230
+ this.probes.set(strandId, { hadCheckInChain });
231
+ this.clearTimersForWake(strandId);
232
+ await this.beginWake(instance);
233
+ }
234
+ /**
235
+ * End a probe begun by {@link probeWake}, success or failure: arm the timers the strand's
236
+ * state now calls for. A probe never creates a check-in chain, only restores one it
237
+ * interrupted. No-op when the probe is no longer held (a force-hibernate or untrack during
238
+ * it means "keep it down"). A wake that began during the probe's window — activity during
239
+ * its closing quiesce, say — is still rebuilding the strand, so it takes the chain and its
240
+ * settle decides.
241
+ */
242
+ endProbe(instance) {
243
+ const { strandId } = instance;
244
+ const probe = this.probes.get(strandId);
245
+ if (!probe)
246
+ return;
247
+ this.probes.delete(strandId);
248
+ if (this.wakePromises.has(strandId)) {
249
+ if (probe.hadCheckInChain) {
250
+ this.checkInsCancelledByWake.add(strandId);
251
+ }
252
+ return;
253
+ }
254
+ this.rearmAfterWake(instance, probe.hadCheckInChain);
191
255
  }
192
256
  /**
193
257
  * Begin a wake for a strand, or coalesce with one already in flight. Ensures
194
258
  * `onWake` runs at most once per concurrent wake — the returned promise is
195
259
  * shared by all overlapping callers and cleared once it settles. Force-wake
196
- * callers await it; activity-driven callers fire-and-forget.
260
+ * callers await it; activity-driven callers fire-and-forget. Success or failure,
261
+ * the settle re-arms the strand's timers (unless a probe holds it), and a failure
262
+ * then rejects.
197
263
  */
198
- beginWake(strandId) {
264
+ beginWake(instance) {
265
+ const { strandId } = instance;
199
266
  const existing = this.wakePromises.get(strandId);
200
267
  if (existing) {
201
268
  return existing;
@@ -205,12 +272,53 @@ export class HibernationManager {
205
272
  await this.callbacks.onWake(strandId);
206
273
  }
207
274
  finally {
208
- this.wakePromises.delete(strandId);
275
+ this.settleWake(instance);
209
276
  }
210
277
  })();
211
278
  this.wakePromises.set(strandId, wake);
212
279
  return wake;
213
280
  }
281
+ settleWake(instance) {
282
+ const { strandId } = instance;
283
+ const hadCheckInChain = this.checkInsCancelledByWake.delete(strandId);
284
+ this.wakePromises.delete(strandId);
285
+ if (!this.probes.has(strandId)) {
286
+ this.rearmAfterWake(instance, hadCheckInChain);
287
+ }
288
+ }
289
+ /**
290
+ * {@link clearTimers} for a wake, first remembering an armed check-in so a wake that leaves
291
+ * the strand hibernating can restore the chain. Only an ARMED chain is remembered: a strand
292
+ * force-hibernated without one (the mobile background path) must not gain one from a wake,
293
+ * and a check-in that is mid-run hands its chain to the wake when it returns
294
+ * ({@link handCheckInChainToHolder}).
295
+ */
296
+ clearTimersForWake(strandId) {
297
+ if (this.checkInTimers.has(strandId)) {
298
+ this.checkInsCancelledByWake.add(strandId);
299
+ }
300
+ this.clearTimers(strandId);
301
+ }
302
+ /**
303
+ * Leave a strand whose wake (or probe) settled with the timers its state calls for: the idle
304
+ * countdown if it is live, or — if it reads `hibernating` again (a failed rebuild, or a probe
305
+ * window that re-quiesced it) — the check-in chain it had before, at the base delay. A
306
+ * strand that had no chain gains none, and one in any other state gets nothing.
307
+ */
308
+ rearmAfterWake(instance, hadCheckInChain) {
309
+ if (!this.config.enabled || !this.running)
310
+ return;
311
+ if (instance.status === 'hibernating') {
312
+ // A hibernating strand has no idle countdown, e.g. one activity armed mid-probe.
313
+ this.clearTimer(instance.strandId);
314
+ if (hadCheckInChain) {
315
+ log('Wake of strand %s left it hibernating; restoring its check-in chain', instance.strandId);
316
+ this.scheduleCheckIn(instance);
317
+ }
318
+ return;
319
+ }
320
+ this.rearmIdleIfLive(instance);
321
+ }
214
322
  scheduleIdleTransition(instance) {
215
323
  const { strandId, latencyHint } = instance;
216
324
  const timeouts = this.getTimeouts(latencyHint);
@@ -258,22 +366,39 @@ export class HibernationManager {
258
366
  // Transition to hibernating. onHibernate now releases strand-network
259
367
  // resources (quiesce), so its close()/stop() can reject — catch so a failed
260
368
  // hibernate logs instead of producing an unhandled rejection.
369
+ this.timerHibernates.add(strandId);
261
370
  void this.callbacks.onHibernate(strandId).then(() => {
262
- // Schedule periodic check-ins
263
- const timeouts = this.getTimeouts(latencyHint);
264
- if (timeouts.checkInInterval !== Infinity) {
265
- this.scheduleCheckIn(instance);
371
+ if (!this.timerHibernates.delete(strandId)) {
372
+ log('Hibernate of strand %s was force-hibernated or untracked meanwhile; no check-in chain', strandId);
373
+ return;
374
+ }
375
+ if (this.getTimeouts(latencyHint).checkInInterval !== Infinity) {
376
+ this.startCheckInChain(instance);
266
377
  }
267
378
  }).catch((err) => {
379
+ this.timerHibernates.delete(strandId);
268
380
  log('onHibernate failed for strand %s: %o', strandId, err);
269
381
  });
270
382
  }
383
+ /**
384
+ * Start the check-in chain of a strand the timer path just hibernated. A wake or probe that
385
+ * landed during the quiesce holds the strand and takes the chain instead
386
+ * ({@link handCheckInChainToHolder}); one that already settled left it live with its idle
387
+ * countdown, and a live strand gets no chain.
388
+ */
389
+ startCheckInChain(instance) {
390
+ if (this.handCheckInChainToHolder(instance))
391
+ return;
392
+ if (instance.status === 'hibernating') {
393
+ this.scheduleCheckIn(instance);
394
+ }
395
+ }
271
396
  /**
272
397
  * Arm the next check-in for a hibernating strand. Each call is a single-shot
273
398
  * `setTimeout` (not a fixed `setInterval`) so the period escalates per
274
399
  * {@link runCheckIn} and a slow `onCheckIn` never overlaps the next tick.
275
400
  *
276
- * `delay` is omitted by the chain start ({@link handleHibernateTimeout}),
401
+ * `delay` is omitted by a chain start ({@link startCheckInChain}, or a wake restoring one),
277
402
  * defaulting to the base `checkInInterval` — which is why backoff naturally
278
403
  * resets to base each fresh hibernation cycle, with no per-strand counter to
279
404
  * clear on wake. Subsequent ticks pass the escalated, capped delay.
@@ -282,15 +407,15 @@ export class HibernationManager {
282
407
  const { strandId, latencyHint } = instance;
283
408
  const timeouts = this.getTimeouts(latencyHint);
284
409
  const currentDelay = delay ?? timeouts.checkInInterval;
285
- // Replace any existing check-in timer (no-op if the firing timer rescheduled us).
286
- const existing = this.checkInTimers.get(strandId);
287
- if (existing) {
288
- clearTimeout(existing);
289
- }
410
+ // Replace any existing check-in timer.
411
+ this.clearCheckInTimer(strandId);
290
412
  const timer = setTimeout(() => {
413
+ // Only ARMED check-ins stay in the map, so a wake during this run does not take it
414
+ // for a chain to restore (see clearTimersForWake) — the run hands it over on return.
415
+ this.checkInTimers.delete(strandId);
291
416
  void this.runCheckIn(instance, currentDelay);
292
417
  }, currentDelay);
293
- this.checkInTimers.set(strandId, timer);
418
+ this.checkInTimers.set(strandId, { timer, instance });
294
419
  instance.nextCheckIn = new Date(Date.now() + currentDelay);
295
420
  }
296
421
  /**
@@ -298,10 +423,12 @@ export class HibernationManager {
298
423
  * sync window → re-hibernate-if-idle cycle in `CadreNode`) and AWAIT it before
299
424
  * deciding the next step.
300
425
  *
426
+ * - If a force-hibernate, untrack or stop cancelled the chain while it ran, stop.
427
+ * - If a wake or probe holds the strand, hand the chain to it
428
+ * ({@link handCheckInChainToHolder}).
301
429
  * - If the strand woke during the check-in (`onCheckIn` left it non-
302
- * `hibernating`), stop the chain — the activity path has re-armed the
303
- * idle/hibernate timers, and the next hibernation restarts the chain at the
304
- * base delay (backoff reset).
430
+ * `hibernating`), stop the chain and restart the idle countdown; the next
431
+ * hibernation restarts the chain at the base delay (backoff reset).
305
432
  * - Otherwise escalate the delay by `checkInBackoffFactor`, capped at
306
433
  * `checkInMaxInterval`, and reschedule.
307
434
  */
@@ -310,6 +437,7 @@ export class HibernationManager {
310
437
  if (!this.running)
311
438
  return;
312
439
  log('Check-in for hibernating strand %s (delay=%dms)', strandId, currentDelay);
440
+ this.runningCheckIns.add(strandId);
313
441
  try {
314
442
  await this.callbacks.onCheckIn(strandId);
315
443
  }
@@ -318,22 +446,74 @@ export class HibernationManager {
318
446
  // fall through to reschedule the next, longer-delayed attempt.
319
447
  log('onCheckIn failed for strand %s: %o', strandId, err);
320
448
  }
321
- if (!this.running)
449
+ if (!this.runningCheckIns.delete(strandId) || !this.running) {
450
+ log('Check-in chain of strand %s was cancelled while it ran; not rescheduling', strandId);
451
+ instance.nextCheckIn = undefined;
452
+ return;
453
+ }
454
+ if (this.handCheckInChainToHolder(instance))
322
455
  return;
323
456
  // The check-in either woke the strand (CadreNode left it active) or left it
324
457
  // hibernating. Inspect the shared instance the callback just mutated.
325
458
  if (instance.status !== 'hibernating') {
326
459
  log('Check-in woke strand %s; backoff resets on next hibernation', strandId);
327
- this.checkInTimers.delete(strandId);
460
+ this.clearCheckInTimer(strandId);
328
461
  // The chain is stopping; drop the now-stale next-check-in advertisement so
329
462
  // `getStrand` doesn't report a phantom check-in for a strand that is awake.
330
463
  instance.nextCheckIn = undefined;
464
+ this.rearmIdleIfLive(instance);
331
465
  return;
332
466
  }
333
467
  const timeouts = this.getTimeouts(latencyHint);
334
468
  const nextDelay = Math.min(currentDelay * timeouts.checkInBackoffFactor, timeouts.checkInMaxInterval);
335
469
  this.scheduleCheckIn(instance, nextDelay);
336
470
  }
471
+ /**
472
+ * Give a check-in chain — a returning check-in's, or the one the timer path starts
473
+ * ({@link startCheckInChain}) — to a wake or probe that holds the strand, as if that
474
+ * wake had cancelled an armed check-in: its settle ({@link settleWake}) or end
475
+ * ({@link endProbe}) restores the chain at the base delay if the strand ends `hibernating`,
476
+ * and starts the idle countdown if it ends live. The status the check-in left says nothing
477
+ * yet: a check-in that failed before its rebuild leaves the strand to a wake still building
478
+ * it (`starting`), and one that ends `hibernating` may be overtaken by a wake still in
479
+ * flight. Deciding here would drop the chain if that wake then fails, or leave a check-in
480
+ * armed on a strand it brings up.
481
+ *
482
+ * @returns whether a wake or probe took the chain.
483
+ */
484
+ handCheckInChainToHolder(instance) {
485
+ const { strandId } = instance;
486
+ const probe = this.probes.get(strandId);
487
+ if (probe) {
488
+ probe.hadCheckInChain = true;
489
+ }
490
+ else if (this.wakePromises.has(strandId)) {
491
+ this.checkInsCancelledByWake.add(strandId);
492
+ }
493
+ else {
494
+ return false;
495
+ }
496
+ log('Strand %s: a wake holds it, so the wake decides its check-in chain', strandId);
497
+ this.clearCheckInTimer(strandId);
498
+ instance.nextCheckIn = undefined;
499
+ return true;
500
+ }
501
+ /**
502
+ * Start the idle countdown for a strand a check-in or wake left live. Activity recorded
503
+ * while the runtime was still rebuilding found the strand neither idle nor active, so it
504
+ * armed nothing — without this the strand would stay up until the next activity. Only for
505
+ * a live status: a strand stopped or failed mid-rebuild must not gain a timer chain. Nor
506
+ * one being quiesced: it reads live until the quiesce ends, e.g. a force-hibernate queued
507
+ * behind the rebuild of the wake settling now, and the countdown would later idle the
508
+ * quiesced strand and start a check-in chain the caller meant to keep off.
509
+ */
510
+ rearmIdleIfLive(instance) {
511
+ const live = (instance.status === 'active' || instance.status === 'syncing')
512
+ && !this.callbacks.isQuiescing(instance.strandId);
513
+ if (live && this.getTimeouts(instance.latencyHint).idleTimeout !== Infinity) {
514
+ this.scheduleIdleTransition(instance);
515
+ }
516
+ }
337
517
  clearTimer(strandId) {
338
518
  const timer = this.timers.get(strandId);
339
519
  if (timer) {
@@ -341,14 +521,19 @@ export class HibernationManager {
341
521
  this.timers.delete(strandId);
342
522
  }
343
523
  }
344
- clearTimers(strandId) {
345
- this.clearTimer(strandId);
346
- const checkInTimer = this.checkInTimers.get(strandId);
347
- if (checkInTimer) {
348
- clearTimeout(checkInTimer);
524
+ clearCheckInTimer(strandId) {
525
+ const pending = this.checkInTimers.get(strandId);
526
+ if (pending) {
527
+ clearTimeout(pending.timer);
349
528
  this.checkInTimers.delete(strandId);
529
+ // `getStrand` must not advertise a check-in that is no longer scheduled.
530
+ pending.instance.nextCheckIn = undefined;
350
531
  }
351
532
  }
533
+ clearTimers(strandId) {
534
+ this.clearTimer(strandId);
535
+ this.clearCheckInTimer(strandId);
536
+ }
352
537
  /**
353
538
  * Get the current status of hibernation tracking
354
539
  */
@@ -1 +1 @@
1
- {"version":3,"file":"hibernation-manager.js","sourceRoot":"","sources":["../src/hibernation-manager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAO1B,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAElD,MAAM,GAAG,GAAG,KAAK,CAAC,0BAA0B,CAAC,CAAC;AAsB9C;;;;;;;;GAQG;AACH,MAAM,OAAO,kBAAkB;IAoB7B,YAAY,MAAyB,EAAE,SAA+B;QAjBrD,WAAM,GAA+C,IAAI,GAAG,EAAE,CAAC;QAChF;;;;;WAKG;QACc,kBAAa,GAA+C,IAAI,GAAG,EAAE,CAAC;QACvF;;;;;WAKG;QACc,iBAAY,GAA+B,IAAI,GAAG,EAAE,CAAC;QAC9D,YAAO,GAAG,KAAK,CAAC;QAGtB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,GAAG,CAAC,wCAAwC,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;IAChE,CAAC;IAED;;OAEG;IACK,WAAW,CAAC,IAAiB;QACnC,MAAM,QAAQ,GAAG,oBAAoB,CAAC,IAAI,CAAC,CAAC;QAC5C,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,cAAc,EAAE,CAAC,IAAI,CAAC,CAAC;QAElD,IAAI,CAAC,MAAM;YAAE,OAAO,QAAQ,CAAC;QAE7B,OAAO;YACL,WAAW,EAAE,MAAM,CAAC,WAAW,IAAI,QAAQ,CAAC,WAAW;YACvD,gBAAgB,EAAE,MAAM,CAAC,gBA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IAAI,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAAC;IACnC,CAAC;IAED;;OAEG;IACH,SAAS;QACP,OAAO;YACL,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,OAAO,IAAI,IAAI,CAAC,OAAO;YAC5C,cAAc,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,GAAG,IAAI,CAAC,aAAa,CAAC,IAAI;SAC3D,CAAC;IACJ,CAAC;CACF"}
package/dist/index.d.ts CHANGED
@@ -14,10 +14,8 @@ export type { DurableSlot } from './node-local-snapshot.js';
14
14
  export { MemoryBootstrapPeerStore, PersistentBootstrapPeerStore, type BootstrapPeerStore, type BootstrapPeerEntry } from './bootstrap-peer-store.js';
15
15
  export { MemoryEnrolledMachineStore, PersistentEnrolledMachineStore, type EnrolledMachineStore } from './enrolled-machine-store.js';
16
16
  export { MemoryJoinedStrandStore, KeyStoreJoinedStrandStore, type JoinedStrandStore, type JoinedStrandRecord } from './joined-strand-store.js';
17
- export { MemoryStrandPeerBookStore, PersistentStrandPeerBookStore, mergeStrandPeerEntry, sanitizeStrandPeerEntry, strandPeerFreshness, MAX_STRAND_PEERS, STRAND_PEER_MAX_AGE_MS, type StrandPeerBookStore, type StrandPeerBookOptions, type StrandPeerEntry } from './strand-peer-book.js';
18
- export { StrandPeerObserver, dialableAddrs, connectedIdentifiedPeers, STRAND_PEER_OBSERVE_THROTTLE_MS, type StrandPeerObservation, type StrandPeerObserverDeps, type StrandPeerObserverOptions, type ConnectedIdentifiedPeer } from './strand-peer-observer.js';
19
- export { STRAND_PEER_BOOK_PROTOCOL, SIGNED_STRAND_PEER_ENTRY_VERSION, STRAND_PEER_ISSUED_AT_SKEW_MS, MAX_BOOK_FRAME_SIZE, StrandPeerBookService, exchangeStrandPeerBook, signStrandPeerEntry, signedStrandPeerEntryPayload, verifySignedStrandPeerEntry, verifyStrandPeerBookFrame, trimBookFrameToFit, assertBookFrameFits, type SignedStrandPeerEntry, type StrandPeerBookFrame, type StrandPeerEntryVerdict, type StrandPeerBookServiceDeps, type ExchangeStrandPeerBookOptions } from './strand-peer-book-protocol.js';
20
- export { StrandPeerBookSwap, STRAND_PEER_BOOK_SWAP_THROTTLE_MS, OWN_ENTRY_RESIGN_DEBOUNCE_MS, type StrandPeerBookSwapDeps, type StrandPeerBookSwapOptions } from './strand-peer-book-swap.js';
17
+ export { MemoryStrandNetworkStateStore, PersistentStrandNetworkStateStore, strandNetworkStatePersistence, type StrandNetworkStateStore } from './strand-network-state.js';
18
+ export { strandFretPeerAddrs, type FretAddrHost, type FretPeerAddrs } from './strand-fret-addrs.js';
21
19
  export { controlStorageScope, isControlStorageScope, isValidStrandScopeKey, assertStrandScopeKey, InvalidStrandIdError } from './storage-scope.js';
22
20
  export { StrandDatabase, type StrandDatabaseConfig } from './strand-database.js';
23
21
  export { StrandWatcher, type StrandWatcherCallbacks, type StrandQueryable, type SAppIdLookup, type StrandRowWithApp } from './strand-watcher.js';
@@ -30,7 +28,7 @@ export { defaultTimeoutScheduler, type TimeoutScheduler } from './timeout-schedu
30
28
  export { HibernationManager, type HibernationCallbacks } from './hibernation-manager.js';
31
29
  export { ArachnodeStub, createArachnodeStub, type RingConfig } from './arachnode-stub.js';
32
30
  export { EnrollmentService, type MemberVerifier, type MemberRegistry } from './enrollment.js';
33
- export { StrandSolicitationService, createDefaultFormationResponseValidator, type DisclosureValidator, type FormationUsageRecorder, type ResolvedHostStrand, type StrandProvisioner, type FormationResponseValidator, type StrandSolicitationServiceOptions } from './strand-solicitation.js';
31
+ export { StrandSolicitationService, createDefaultFormationResponseValidator, type DisclosureValidator, type FormationUsageRecorder, type FormationUsageParams, type AuthorizedFormationUsage, type ResolvedHostStrand, type StrandProvisioner, type FormationResponseValidator, type StrandSolicitationServiceOptions } from './strand-solicitation.js';
34
32
  export { createHttpFormationApprover, signFormationApproval, verifyFormationApproval, FormationApprovalError, type FormationApprovalRequest, type FormationVouchFields, type FormationApproval, type FormationApprover, type FormationApprovalFailure } from './formation-approval.js';
35
33
  export { ControlFormationUsageRecorder } from './control-formation-recorder.js';
36
34
  export { generateStrandMemberKey, strandMemberKeyPair } from './strand-member-key.js';
@@ -40,7 +38,7 @@ export { StrandMemberRegistry, StrandMemberVerifier, memberRegistrationPayload,
40
38
  export { SeedBootstrapService, SEED_PROTOCOL, ed25519PublicKeyB64FromPeerId, type SeedBootstrapConfig, type SeedEventCallbacks } from './seed-bootstrap.js';
41
39
  export { peerAuthorizationDigest, cadrePeerVoucherDigest, cadrePeerRemoveDigest, deviceTokenAddDigest, deviceTokenRemoveDigest, formationConsentDigest, verifyPeerAuthorization, verifyCadrePeerVoucher, verifyFormationConsent, type DeviceTokenAuthorizedRow } from './peer-authorization.js';
42
40
  export { StrandWakeService, dialWake, WAKE_PROTOCOL, DEFAULT_WAKE_DIAL_BUDGET_MS, type StrandWakeServiceOptions, type DialWakeOptions } from './strand-wake-protocol.js';
43
- export { StrandAddrService, collectStrandAddrs, STRAND_ADDR_PROTOCOL, type StrandAddrServiceOptions, type StrandAddrPeer, type CollectStrandAddrsOptions } from './strand-addr-protocol.js';
41
+ export { StrandAddrService, collectStrandAddrs, STRAND_ADDR_PROTOCOL, type StrandAddrServiceOptions, type StrandAddrPeer, type CollectStrandAddrsOptions, type StrandAddrOutcome, type StrandAddrCollection } from './strand-addr-protocol.js';
44
42
  export { peerRecordSignedPayload, signPeerRecord, verifyPeerRecordSignature, isPeerRecordFresh, isSignalingAddr, orderSignalingFirst, withTrailingPeerId, currentMemberTrustPolicy, DEFAULT_PEER_RECORD_MAX_AGE_MS, DEFAULT_PEER_RECORD_HEARTBEAT_MS } from './peer-record.js';
45
43
  export { deviceTokenSignedPayload, signDeviceTokenRecord, verifyDeviceTokenSignature, isPushPlatform } from './device-token.js';
46
44
  export { STRAND_WAKE_TYPE, type StrandWakePayload } from './strand-wake-payload.js';
@@ -48,14 +46,16 @@ export type { PushNotifier, PushMessage, PushSendResult } from './push-notifier.
48
46
  export { validatePushCredentials, redactPushCredentials, REDACTED } from './push-credentials.js';
49
47
  export { PushFanoutService, DEFAULT_PUSH_COOLDOWN_MS, DEFAULT_PUSH_DEBOUNCE_MS, type PushFanoutOptions, type FanoutMember } from './push-fanout.js';
50
48
  export { selectControlCohortDials, DEFAULT_CONTROL_COHORT_RECONCILE_MS, DEFAULT_CONTROL_COHORT_TARGET_DEGREE, type ControlCohortSelection, type ControlCohortReconcileResult } from './control-cohort.js';
51
- export { dialPeerAddrs, tryAddrsInTurn, directBeforeRelayed, DEFAULT_CONTROL_COHORT_DIAL_TIMEOUT_MS, DEFAULT_CONTROL_COHORT_PER_ADDRESS_DIAL_TIMEOUT_MS, CONTROL_COHORT_DIAL_ADDRESS_ATTEMPTS, DEFAULT_PEER_DIAL_BUDGET, type PeerDialBudget, type AddrDialer } from './peer-dial.js';
52
- export { DECLARED_LINK_ROUND_TRIP_MS, RELAYED_DIAL_ROUND_TRIPS, RELAY_RESERVATION_ROUND_TRIPS, CIRCUIT_REQUEST_ROUND_TRIPS, PUSH_TRANSFER_ALLOWANCE_MS, resolveLinkRoundTripMs, relayedDialBudgetMs, connectionManagerTimeouts, relayReservationBudgetMs, circuitRequestBudgetMs, peerJoinPushBudget, type PeerJoinPushBudget } from './link-budget.js';
49
+ export { dialPeerAddrs, SelfRelayOnlyError, tryAddrsInTurn, directBeforeRelayed, DEFAULT_CONTROL_COHORT_DIAL_TIMEOUT_MS, DEFAULT_CONTROL_COHORT_PER_ADDRESS_DIAL_TIMEOUT_MS, CONTROL_COHORT_DIAL_ADDRESS_ATTEMPTS, DEFAULT_PEER_DIAL_BUDGET, type PeerDialBudget, type AddrDialer } from './peer-dial.js';
50
+ export { DECLARED_LINK_ROUND_TRIP_MS, RELAYED_DIAL_ROUND_TRIPS, RELAY_RESERVATION_ROUND_TRIPS, CIRCUIT_REQUEST_ROUND_TRIPS, RELAYED_REQUEST_ROUND_TRIPS, PUSH_TRANSFER_ALLOWANCE_MS, ADMISSION_DECISION_TIMEOUT_MS, resolveLinkRoundTripMs, relayedDialBudgetMs, relayReservationBudgetMs, circuitRequestBudgetMs, relayedRequestBudgetMs, peerJoinPushBudget, type PeerJoinPushBudget } from './link-budget.js';
53
51
  export { anchoredTrustPolicy, pinnedKeyTrustPolicy, tofuTrustPolicy, type SeedTrustPolicy, type SeedTrustContext, type SeedTrustDecision } from './seed-trust-policy.js';
54
52
  export { signSchema, verifySchema, assertSchemaSignature, SchemaVerificationError } from './schema-verification.js';
55
53
  export { FormationListener, dialFormation, isValidResponderCreatesResult, isWellFormedMembershipInvite, sanitizeStrandAddrs, FORMATION_PROTOCOL, type FormationParty, type FormationContactMessage, type FormationResultMessage, type FormationProvisionResult, type FormationStrandInfo, type FormationDbConnectionInfo, type FormationListenerOptions, type FormationDialOptions, type FormationDialResult, type ResponderProvisionOutcome } from './strand-formation-protocol.js';
56
- export { StrandFormationManager, createStrandFormationManager, MEMBERSHIP_INVITE_TTL_MS, MEMBERSHIP_INVITE_UNAVAILABLE_REASON, HOST_STRAND_MUST_BE_RECREATED_REASON, type StrandFormationManagerConfig, type StrandFormationManagerOptions } from './strand-formation-manager.js';
57
- export { createMembershipConnectionGater, STRANGER_OPEN_PROTOCOLS, DEFAULT_ENROLLMENT_WINDOW_MS, ADMISSION_DECISION_TIMEOUT_MS, RELAY_ADMISSION_RESERVE_DEADLINE_MS, RELAY_ADMISSION_CLOSE_TIMEOUT_MS, MAX_UNAUTHORIZED_RELAY_RESERVATIONS, UNAUTHORIZED_RESERVATION_TTL_MS, UnauthorizedReservationBudget, type InboundAdmissionPolicy, type InboundConnectionVerdict } from './membership-connection-gater.js';
54
+ export { formationDeadlines, type FormationDeadlines } from './strand-formation-deadlines.js';
55
+ export { StrandFormationManager, createStrandFormationManager, MEMBERSHIP_INVITE_TTL_MS, MEMBERSHIP_INVITE_UNAVAILABLE_REASON, HOST_STRAND_MUST_BE_RECREATED_REASON, type MembershipInviteIssuer, type StrandFormationManagerConfig, type StrandFormationManagerOptions } from './strand-formation-manager.js';
56
+ export { createMembershipConnectionGater, STRANGER_OPEN_PROTOCOLS, DEFAULT_ENROLLMENT_WINDOW_MS, RELAY_ADMISSION_RESERVE_DEADLINE_MS, RELAY_ADMISSION_CLOSE_TIMEOUT_MS, MAX_UNAUTHORIZED_RELAY_RESERVATIONS, UnauthorizedReservationBudget, type InboundAdmissionPolicy, type InboundConnectionVerdict } from './membership-connection-gater.js';
58
57
  export { RelayReservationFailedError, UnbindableListenAddressError, RELAY_SEARCH_LISTEN_ADDR, resolveListenAddrs } from './relay-addrs.js';
59
58
  export { strandNodeAddrs, type StrandNodeAddrs } from './strand-network-config.js';
59
+ export { resolveRelayServer, PARTY_RELAY_MAX_RESERVATIONS, PARTY_RELAY_RESERVATION_TTL_MS, type ResolvedRelayServer, type ResolvedRelayReservations } from './relay-server.js';
60
60
  export { circuitMultiaddrs, superviseRelayReservation, DEFAULT_RELAY_RESERVE_TIMEOUT_MS, DEFAULT_RELAY_RESERVE_POLL_MS, DEFAULT_RELAY_CHECK_MS, DEFAULT_RELAY_MIN_BACKOFF_MS, DEFAULT_RELAY_MAX_BACKOFF_MS, type RelayReservationStatus, type RelayReservationState, type RelayReserveOptions, type RelayReservationSupervisor, type RelayReservationSupervisorOptions } from './relay-reservation.js';
61
61
  export { classifyTransport, classifyConnectionPath, summarizeConnectionPaths, emptyConnectionPathSummary, DEFAULT_SETTLE_WINDOW_MS, type ConnectionPathKind, type ConnectionTransport, type ConnectionPath, type ConnectionPathSummary, type ConnectionLike } from './diagnostics/connection-path.js';
package/dist/index.js CHANGED
@@ -49,26 +49,26 @@ export { MemoryBootstrapPeerStore, PersistentBootstrapPeerStore } from './bootst
49
49
  // DIVERGES from theirs (an unreadable slot cold-starts rather than throwing) —
50
50
  // see the module comment before unifying the three.
51
51
  export { MemoryEnrolledMachineStore, PersistentEnrolledMachineStore } from './enrolled-machine-store.js';
52
- // Node-local record of the strands this node joined from ANOTHER party, re-offered on
53
- // every start as `strand:discovered`. Cross-platform: its durable form rides the
54
- // KeyStore seam above (the record carries a closed strand's read secret), so there is
55
- // no file-backed subpath.
52
+ // Node-local record of the strands this node joined from ANOTHER party and has not yet
53
+ // published party-wide, re-offered on every start as `strand:discovered`.
54
+ // Cross-platform: its durable form rides the KeyStore seam above (the record carries a
55
+ // closed strand's read secret), so there is no file-backed subpath.
56
56
  export { MemoryJoinedStrandStore, KeyStoreJoinedStrandStore } from './joined-strand-store.js';
57
- // Node-local strand peer book: per strand, the strand peers this node has met and
58
- // their last-known addresses, dialed first on every launch so a restarted machine
59
- // re-finds the other parties. Same cross-platform split as the bootstrap-peer store
60
- // above — interface + in-memory + slot-backed stores here, Node-only file backend
61
- // behind the subpath '@serfab/cadre-core/strand-peer-book-file'.
62
- export { MemoryStrandPeerBookStore, PersistentStrandPeerBookStore, mergeStrandPeerEntry, sanitizeStrandPeerEntry, strandPeerFreshness, MAX_STRAND_PEERS, STRAND_PEER_MAX_AGE_MS } from './strand-peer-book.js';
63
- export { StrandPeerObserver, dialableAddrs, connectedIdentifiedPeers, STRAND_PEER_OBSERVE_THROTTLE_MS } from './strand-peer-observer.js';
64
- // The signed book SWAP between strand peers (`/sereus/strand-peers/1.0.0`): the wire
65
- // protocol, signing and verification, and the per-strand driver that arms it.
66
- export { STRAND_PEER_BOOK_PROTOCOL, SIGNED_STRAND_PEER_ENTRY_VERSION, STRAND_PEER_ISSUED_AT_SKEW_MS, MAX_BOOK_FRAME_SIZE, StrandPeerBookService, exchangeStrandPeerBook, signStrandPeerEntry, signedStrandPeerEntryPayload, verifySignedStrandPeerEntry, verifyStrandPeerBookFrame, trimBookFrameToFit, assertBookFrameFits } from './strand-peer-book-protocol.js';
67
- export { StrandPeerBookSwap, STRAND_PEER_BOOK_SWAP_THROTTLE_MS, OWN_ENTRY_RESIGN_DEBOUNCE_MS } from './strand-peer-book-swap.js';
57
+ // Node-local strand network state: per strand, the state Optimystic's db-p2p saves for
58
+ // the strand node (its FRET routing table with each peer's signed address record), so a
59
+ // restarted strand node re-imports the peers it was talking to. Same cross-platform
60
+ // split as the bootstrap-peer store above — interface + in-memory + slot-backed stores
61
+ // here, Node-only file backend behind '@serfab/cadre-core/strand-network-state-file'.
62
+ export { MemoryStrandNetworkStateStore, PersistentStrandNetworkStateStore, strandNetworkStatePersistence } from './strand-network-state.js';
63
+ // The signed address records a running strand node's FRET table holds, as per-peer dial
64
+ // addresses: what the periodic refresh re-merges into the node's address book, and a
65
+ // diagnostic for "whom could this strand node redial right now?".
66
+ export { strandFretPeerAddrs } from './strand-fret-addrs.js';
68
67
  // Storage scope keys — what `CadreNodeConfig.storage.provider` is called with. A
69
68
  // strand's key is its strand id; the control database's key carries the party id,
70
69
  // so two parties on one device never share a control store. Every key stays within
71
- // `[A-Za-z0-9._-]`: the control key by base64url encoding, a strand's by
70
+ // `[a-z0-9._-]` — lowercase, so distinct keys stay distinct on a case-insensitive
71
+ // filesystem: the control key by lowercase hex encoding, a strand's by
72
72
  // `assertStrandScopeKey`, which every strand launch runs.
73
73
  export { controlStorageScope, isControlStorageScope, isValidStrandScopeKey, assertStrandScopeKey, InvalidStrandIdError } from './storage-scope.js';
74
74
  // Strand database
@@ -131,7 +131,7 @@ export { peerAuthorizationDigest, cadrePeerVoucherDigest, cadrePeerRemoveDigest,
131
131
  // Strand Wake (control-network push-wake protocol)
132
132
  export { StrandWakeService, dialWake, WAKE_PROTOCOL, DEFAULT_WAKE_DIAL_BUDGET_MS } from './strand-wake-protocol.js';
133
133
  // Strand Address (control-network strand-address RPC) — wire types come via
134
- // `export * from './types.js'` (StrandAddrRequest / StrandAddrResponse).
134
+ // `export * from './types.js'` (StrandAddrRequest / StrandAddrResponse / StrandAddrStatus).
135
135
  export { StrandAddrService, collectStrandAddrs, STRAND_ADDR_PROTOCOL } from './strand-addr-protocol.js';
136
136
  // Peer-address record (self-published, signed, freshness-stamped CadrePeer row)
137
137
  export { peerRecordSignedPayload, signPeerRecord, verifyPeerRecordSignature, isPeerRecordFresh, isSignalingAddr, orderSignalingFirst, withTrailingPeerId, currentMemberTrustPolicy, DEFAULT_PEER_RECORD_MAX_AGE_MS, DEFAULT_PEER_RECORD_HEARTBEAT_MS } from './peer-record.js';
@@ -152,20 +152,21 @@ export { PushFanoutService, DEFAULT_PUSH_COOLDOWN_MS, DEFAULT_PUSH_DEBOUNCE_MS }
152
152
  export { selectControlCohortDials, DEFAULT_CONTROL_COHORT_RECONCILE_MS, DEFAULT_CONTROL_COHORT_TARGET_DEGREE } from './control-cohort.js';
153
153
  // Dialing one peer from several candidate addresses, each under its own time
154
154
  // limit, so an address that never answers cannot starve the rest.
155
- export { dialPeerAddrs, tryAddrsInTurn, directBeforeRelayed, DEFAULT_CONTROL_COHORT_DIAL_TIMEOUT_MS, DEFAULT_CONTROL_COHORT_PER_ADDRESS_DIAL_TIMEOUT_MS, CONTROL_COHORT_DIAL_ADDRESS_ATTEMPTS, DEFAULT_PEER_DIAL_BUDGET } from './peer-dial.js';
155
+ export { dialPeerAddrs, SelfRelayOnlyError, tryAddrsInTurn, directBeforeRelayed, DEFAULT_CONTROL_COHORT_DIAL_TIMEOUT_MS, DEFAULT_CONTROL_COHORT_PER_ADDRESS_DIAL_TIMEOUT_MS, CONTROL_COHORT_DIAL_ADDRESS_ATTEMPTS, DEFAULT_PEER_DIAL_BUDGET } from './peer-dial.js';
156
156
  // Dial and reservation budgets counted in link round trips rather than fixed milliseconds, so
157
157
  // one declared assumption about the link moves them all — see `NetworkConfig.linkRoundTripMs`.
158
- export { DECLARED_LINK_ROUND_TRIP_MS, RELAYED_DIAL_ROUND_TRIPS, RELAY_RESERVATION_ROUND_TRIPS, CIRCUIT_REQUEST_ROUND_TRIPS, PUSH_TRANSFER_ALLOWANCE_MS, resolveLinkRoundTripMs, relayedDialBudgetMs, connectionManagerTimeouts, relayReservationBudgetMs, circuitRequestBudgetMs, peerJoinPushBudget } from './link-budget.js';
158
+ export { DECLARED_LINK_ROUND_TRIP_MS, RELAYED_DIAL_ROUND_TRIPS, RELAY_RESERVATION_ROUND_TRIPS, CIRCUIT_REQUEST_ROUND_TRIPS, RELAYED_REQUEST_ROUND_TRIPS, PUSH_TRANSFER_ALLOWANCE_MS, ADMISSION_DECISION_TIMEOUT_MS, resolveLinkRoundTripMs, relayedDialBudgetMs, relayReservationBudgetMs, circuitRequestBudgetMs, relayedRequestBudgetMs, peerJoinPushBudget } from './link-budget.js';
159
159
  // Seed trust policy (trust anchor for incoming seeds)
160
160
  export { anchoredTrustPolicy, pinnedKeyTrustPolicy, tofuTrustPolicy } from './seed-trust-policy.js';
161
161
  // Schema Verification
162
162
  export { signSchema, verifySchema, assertSchemaSignature, SchemaVerificationError } from './schema-verification.js';
163
163
  // Strand Formation transport (native cadre-core protocol)
164
164
  export { FormationListener, dialFormation, isValidResponderCreatesResult, isWellFormedMembershipInvite, sanitizeStrandAddrs, FORMATION_PROTOCOL } from './strand-formation-protocol.js';
165
+ export { formationDeadlines } from './strand-formation-deadlines.js';
165
166
  // Strand Formation manager (drives the native transport)
166
167
  export { StrandFormationManager, createStrandFormationManager, MEMBERSHIP_INVITE_TTL_MS, MEMBERSHIP_INVITE_UNAVAILABLE_REASON, HOST_STRAND_MUST_BE_RECREATED_REASON } from './strand-formation-manager.js';
167
168
  // Control-network inbound connection gate (membership defense-in-depth)
168
- export { createMembershipConnectionGater, STRANGER_OPEN_PROTOCOLS, DEFAULT_ENROLLMENT_WINDOW_MS, ADMISSION_DECISION_TIMEOUT_MS, RELAY_ADMISSION_RESERVE_DEADLINE_MS, RELAY_ADMISSION_CLOSE_TIMEOUT_MS, MAX_UNAUTHORIZED_RELAY_RESERVATIONS, UNAUTHORIZED_RESERVATION_TTL_MS, UnauthorizedReservationBudget } from './membership-connection-gater.js';
169
+ export { createMembershipConnectionGater, STRANGER_OPEN_PROTOCOLS, DEFAULT_ENROLLMENT_WINDOW_MS, RELAY_ADMISSION_RESERVE_DEADLINE_MS, RELAY_ADMISSION_CLOSE_TIMEOUT_MS, MAX_UNAUTHORIZED_RELAY_RESERVATIONS, UnauthorizedReservationBudget } from './membership-connection-gater.js';
169
170
  // Thrown out of `CadreNode.start()` when a `network.relayAddrs` reservation does
170
171
  // not land on its first attempt — the fail-fast posture of that config field now
171
172
  // that the control node reserves AFTER control-database bring-up (relay-addrs.ts).
@@ -181,6 +182,10 @@ export { createMembershipConnectionGater, STRANGER_OPEN_PROTOCOLS, DEFAULT_ENROL
181
182
  // spelling.
182
183
  export { RelayReservationFailedError, UnbindableListenAddressError, RELAY_SEARCH_LISTEN_ADDR, resolveListenAddrs } from './relay-addrs.js';
183
184
  export { strandNodeAddrs } from './strand-network-config.js';
185
+ // The circuit-relay SERVER a node runs, and with which init — one resolution shared by the
186
+ // control node and every strand node. Exported alongside the listen derivations above for the
187
+ // same reason: an embedder can assert on what its `network` block resolves to.
188
+ export { resolveRelayServer, PARTY_RELAY_MAX_RESERVATIONS, PARTY_RELAY_RESERVATION_TTL_MS } from './relay-server.js';
184
189
  // Relay reservation via the bare `/p2p-circuit` search listener — the one route
185
190
  // every control node takes; `network.relayAddrs` is its fail-fast posture
186
191
  // (see relay-reservation.ts)