@serfab/cadre-core 1.13.0 → 1.14.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 (120) hide show
  1. package/dist/cadre-invite-protocol.d.ts +348 -0
  2. package/dist/cadre-invite-protocol.js +605 -0
  3. package/dist/cadre-invite-protocol.js.map +1 -0
  4. package/dist/cadre-node.d.ts +523 -180
  5. package/dist/cadre-node.js +921 -293
  6. package/dist/cadre-node.js.map +1 -1
  7. package/dist/claim-proof.d.ts +45 -0
  8. package/dist/claim-proof.js +132 -0
  9. package/dist/claim-proof.js.map +1 -0
  10. package/dist/control-authorization.d.ts +80 -19
  11. package/dist/control-authorization.js +55 -13
  12. package/dist/control-authorization.js.map +1 -1
  13. package/dist/control-cohort.js +1 -1
  14. package/dist/control-cohort.js.map +1 -1
  15. package/dist/control-database.d.ts +514 -97
  16. package/dist/control-database.js +1033 -195
  17. package/dist/control-database.js.map +1 -1
  18. package/dist/control-protocol-guard.d.ts +142 -0
  19. package/dist/control-protocol-guard.js +293 -0
  20. package/dist/control-protocol-guard.js.map +1 -0
  21. package/dist/control-schema.d.ts +1 -1
  22. package/dist/control-schema.js +801 -1067
  23. package/dist/control-schema.js.map +1 -1
  24. package/dist/control-stream.d.ts +4 -0
  25. package/dist/control-stream.js +22 -7
  26. package/dist/control-stream.js.map +1 -1
  27. package/dist/delegate-admission.d.ts +1 -1
  28. package/dist/delegate-admission.js +1 -1
  29. package/dist/device-token.d.ts +11 -9
  30. package/dist/device-token.js +14 -12
  31. package/dist/device-token.js.map +1 -1
  32. package/dist/ed25519-key.d.ts +15 -0
  33. package/dist/ed25519-key.js +28 -1
  34. package/dist/ed25519-key.js.map +1 -1
  35. package/dist/index.d.ts +14 -9
  36. package/dist/index.js +27 -9
  37. package/dist/index.js.map +1 -1
  38. package/dist/link-budget.d.ts +16 -29
  39. package/dist/link-budget.js +16 -31
  40. package/dist/link-budget.js.map +1 -1
  41. package/dist/membership-connection-gater.d.ts +190 -151
  42. package/dist/membership-connection-gater.js +235 -173
  43. package/dist/membership-connection-gater.js.map +1 -1
  44. package/dist/node-claim-payload.d.ts +19 -0
  45. package/dist/node-claim-payload.js +120 -0
  46. package/dist/node-claim-payload.js.map +1 -0
  47. package/dist/owner-anchor-sync.d.ts +22 -0
  48. package/dist/owner-anchor-sync.js +143 -0
  49. package/dist/owner-anchor-sync.js.map +1 -0
  50. package/dist/peer-authorization.d.ts +113 -18
  51. package/dist/peer-authorization.js +225 -29
  52. package/dist/peer-authorization.js.map +1 -1
  53. package/dist/peer-dial.d.ts +19 -0
  54. package/dist/peer-dial.js +22 -1
  55. package/dist/peer-dial.js.map +1 -1
  56. package/dist/peer-join-backfill.d.ts +26 -2
  57. package/dist/peer-join-backfill.js +54 -12
  58. package/dist/peer-join-backfill.js.map +1 -1
  59. package/dist/peer-record.d.ts +13 -9
  60. package/dist/peer-record.js +16 -12
  61. package/dist/peer-record.js.map +1 -1
  62. package/dist/pending-join-runner.d.ts +66 -58
  63. package/dist/pending-join-runner.js +136 -145
  64. package/dist/pending-join-runner.js.map +1 -1
  65. package/dist/push-fanout.d.ts +8 -2
  66. package/dist/push-fanout.js +8 -2
  67. package/dist/push-fanout.js.map +1 -1
  68. package/dist/seed-bootstrap.d.ts +147 -122
  69. package/dist/seed-bootstrap.js +284 -269
  70. package/dist/seed-bootstrap.js.map +1 -1
  71. package/dist/seed-trust-policy.d.ts +98 -37
  72. package/dist/seed-trust-policy.js +188 -2
  73. package/dist/seed-trust-policy.js.map +1 -1
  74. package/dist/strand-addr-protocol.d.ts +24 -26
  75. package/dist/strand-addr-protocol.js +19 -26
  76. package/dist/strand-addr-protocol.js.map +1 -1
  77. package/dist/strand-formation-protocol.js +1 -1
  78. package/dist/strand-formation-protocol.js.map +1 -1
  79. package/dist/strand-revocation-enforcer.d.ts +11 -11
  80. package/dist/strand-revocation-enforcer.js +11 -11
  81. package/dist/strand-wake-protocol.d.ts +13 -16
  82. package/dist/strand-wake-protocol.js +13 -20
  83. package/dist/strand-wake-protocol.js.map +1 -1
  84. package/dist/trusted-owner-store.d.ts +35 -5
  85. package/dist/trusted-owner-store.js +50 -8
  86. package/dist/trusted-owner-store.js.map +1 -1
  87. package/dist/types.d.ts +302 -87
  88. package/dist/types.js.map +1 -1
  89. package/package.json +8 -7
  90. package/src/cadre-invite-protocol.ts +864 -0
  91. package/src/cadre-node.ts +9381 -8686
  92. package/src/claim-proof.ts +147 -0
  93. package/src/control-authorization.ts +203 -117
  94. package/src/control-cohort.ts +1 -1
  95. package/src/control-database.ts +1216 -218
  96. package/src/control-protocol-guard.ts +348 -0
  97. package/src/control-schema.ts +812 -1078
  98. package/src/control-stream.ts +26 -7
  99. package/src/delegate-admission.ts +1 -1
  100. package/src/device-token.ts +14 -10
  101. package/src/ed25519-key.ts +28 -1
  102. package/src/index.ts +84 -10
  103. package/src/link-budget.ts +16 -32
  104. package/src/membership-connection-gater.ts +637 -570
  105. package/src/node-claim-payload.ts +125 -0
  106. package/src/owner-anchor-sync.ts +171 -0
  107. package/src/peer-authorization.ts +258 -29
  108. package/src/peer-dial.ts +22 -1
  109. package/src/peer-join-backfill.ts +56 -11
  110. package/src/peer-record.ts +16 -11
  111. package/src/pending-join-runner.ts +729 -735
  112. package/src/push-fanout.ts +8 -2
  113. package/src/seed-bootstrap.ts +344 -321
  114. package/src/seed-trust-policy.ts +353 -140
  115. package/src/strand-addr-protocol.ts +26 -35
  116. package/src/strand-formation-protocol.ts +1 -1
  117. package/src/strand-revocation-enforcer.ts +11 -11
  118. package/src/strand-wake-protocol.ts +13 -23
  119. package/src/trusted-owner-store.ts +242 -171
  120. package/src/types.ts +2471 -2242
@@ -73,9 +73,7 @@
73
73
  * Every row that opens a relayed connection counts opening the relay connection too
74
74
  * ({@link RELAYED_DIAL_ROUND_TRIPS}), because a dialer cannot know beforehand whether it holds
75
75
  * one, and a budget that is too short fails as silently as an absent peer. The
76
- * reservation-request row is {@link RELAY_RESERVE_REQUEST_ROUND_TRIPS}, which also sizes how long
77
- * a party-run relay waits for a stranger's reservation ({@link relayAdmissionReserveDeadlineMs}).
78
- * The commit row is a measurement of a whole write, not a count of exchanges; its doc comment
76
+ * reservation-request row is {@link RELAY_RESERVE_REQUEST_ROUND_TRIPS}. The commit row is a measurement of a whole write, not a count of exchanges; its doc comment
79
77
  * ({@link COMMIT_ROUND_TRIPS}) holds the figures and says when to re-measure it.
80
78
  *
81
79
  * **Measured** 2026-09-26, one Windows machine, loopback dedicated relay: a relayed dial over a
@@ -198,10 +196,10 @@
198
196
  * the host derives its provisioning budget from its own, so a joiner declaring a faster
199
197
  * link than the host gives up on a reply the host is still entitled to send. Declare the
200
198
  * same link on every machine of a party.
201
- * Relay admission too: a party-run relay derives how long a stranger has to ask for a
202
- * reservation from ITS declaration ({@link relayAdmissionReserveDeadlineMs}), so a relay
203
- * declaring a faster link than a client closes that client's connection before its request
204
- * arrives.
199
+ * Provisional admission too: a member derives how long it keeps a connection from a peer it
200
+ * cannot place from ITS declaration ({@link relayedRequestBudgetMs}), so a member declaring a
201
+ * faster link than a redeeming device can close that device's connection while the device is
202
+ * still waiting on its redemption.
205
203
  */
206
204
  import { resolveLinkDeadlines } from '@optimystic/db-p2p';
207
205
  /**
@@ -255,20 +253,19 @@ export const RELAY_DIAL_ROUND_TRIPS = 1;
255
253
  */
256
254
  export const RELAYED_DIAL_ROUND_TRIPS = RELAY_DIAL_ROUND_TRIPS + CIRCUIT_DIAL_ROUND_TRIPS;
257
255
  /**
258
- * Link round trips from the moment a party-run relay admits a stranger's connection for relay
259
- * use to the moment that stranger's RESERVE request reaches it. libp2p's reservation store
260
- * (`@libp2p/circuit-relay-v2`'s `addRelay`) opens the hop stream the instant its dial resolves,
261
- * without waiting for identify, so:
256
+ * Link round trips from the moment a relay accepts a client's connection to the moment that
257
+ * client's RESERVE request reaches it. libp2p's reservation store (`@libp2p/circuit-relay-v2`'s
258
+ * `addRelay`) opens the hop stream the instant its dial resolves, without waiting for identify,
259
+ * so:
262
260
  *
263
261
  * 1. The client's last Noise handshake message and its hop-stream open arrive at the relay
264
- * together. The relay's gate runs on the handshake message (and arms the reserve deadline),
265
- * then the relay answers the protocol negotiation.
262
+ * together. A party-run relay's gate runs on the handshake message, then the relay answers
263
+ * the protocol negotiation.
266
264
  * 2. The answer reaches the client and the client's RESERVE request reaches the relay: one round
267
265
  * trip on the client-to-relay hop, which is the whole link round trip when all of the link's
268
266
  * delay is on the client's own hop (a phone on a congested mobile link).
269
267
  *
270
- * The relay's decision on that request is local time, not link time;
271
- * {@link relayAdmissionReserveDeadlineMs} adds it separately.
268
+ * The relay's decision on that request is local time, not link time.
272
269
  */
273
270
  export const RELAY_RESERVE_REQUEST_ROUND_TRIPS = 1;
274
271
  /**
@@ -489,22 +486,6 @@ export function commitBudgetMs(linkRoundTripMs) {
489
486
  export function relayReservationBudgetMs(linkRoundTripMs) {
490
487
  return RELAY_RESERVATION_ROUND_TRIPS * resolveLinkRoundTripMs(linkRoundTripMs) + 2 * ADMISSION_DECISION_TIMEOUT_MS;
491
488
  }
492
- /**
493
- * How long a party-run relay keeps a connection it admitted only for relay use
494
- * (`membership-connection-gater.ts`'s `'admit-for-relay'`) before closing it, unless a
495
- * reservation is admitted on it first: {@link RELAY_RESERVE_REQUEST_ROUND_TRIPS} at the declared
496
- * link round trip, plus one {@link ADMISSION_DECISION_TIMEOUT_MS} for the relay's own decision on
497
- * the reservation (`denyInboundRelayReservation`), which disarms the timer only once it settles.
498
- * 3 500 + 2 000 = 5 500 ms at the default declaration.
499
- *
500
- * The declaration is the RELAY's own, because the relay is the machine that decides.
501
- *
502
- * What it costs, against the fixed 5 000 ms it replaced: a stranger that connects and never
503
- * reserves holds a mute connection 0.5 s longer at the default declaration.
504
- */
505
- export function relayAdmissionReserveDeadlineMs(linkRoundTripMs) {
506
- return RELAY_RESERVE_REQUEST_ROUND_TRIPS * resolveLinkRoundTripMs(linkRoundTripMs) + ADMISSION_DECISION_TIMEOUT_MS;
507
- }
508
489
  /**
509
490
  * Deadline for one request and its answer over a circuit that is already open —
510
491
  * {@link CIRCUIT_REQUEST_ROUND_TRIPS} at the declared link round trip, plus `transferAllowanceMs`
@@ -522,6 +503,10 @@ export function circuitRequestBudgetMs(linkRoundTripMs, transferAllowanceMs = PU
522
503
  *
523
504
  * No transfer allowance, unlike {@link circuitRequestBudgetMs}: the requests this bounds are a few
524
505
  * hundred bytes to a few KB, so their bytes cost nothing a round trip does not already cover.
506
+ *
507
+ * A control node also keeps a connection it admitted provisionally this long, at its own
508
+ * declaration, because a cadre invitation redemption is bounded by this budget on the device's
509
+ * side (`membership-connection-gater.ts`, `PROVISIONAL_ADMISSION_DEADLINE_MS`).
525
510
  */
526
511
  export function relayedRequestBudgetMs(linkRoundTripMs) {
527
512
  return relayedDialBudgetMs(linkRoundTripMs) + CIRCUIT_REQUEST_ROUND_TRIPS * resolveLinkRoundTripMs(linkRoundTripMs);
@@ -1 +1 @@
1
- {"version":3,"file":"link-budget.js","sourceRoot":"","sources":["../src/link-budget.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4MG;AAEH,OAAO,EAAE,oBAAoB,EAA2D,MAAM,oBAAoB,CAAC;AAEnH;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,IAAI,CAAC;AAEhD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,CAAC;AAE1C;;;;;GAKG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,CAAC;AAExC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,wBAAwB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;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,MAAM,UAAU,oBAAoB,CAAC,eAAwB;IAC5D,OAAO,2BAA2B,GAAG,sBAAsB,CAAC,eAAe,CAAC,CAAC;AAC9E,CAAC;AAUD;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,4BAA4B,CAAC,OAA8B;IAC1E,OAAO,OAAO,EAAE,oBAAoB;WAChC,CAAC,OAAO,EAAE,eAAe,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,oBAAoB,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC;AAC1G,CAAC;AAUD;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAAC,eAAwB;IAC1D,OAAO;QACN,aAAa,EAAE,mBAAmB,CAAC,eAAe,CAAC;QACnD,iBAAiB,EAAE,sBAAsB,CAAC,eAAe,CAAC;KAC1D,CAAC;AACH,CAAC;AAUD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,oBAAoB,CAAC,eAAwB;IAC5D,MAAM,OAAO,GAAG,oBAAoB,CAAC,sBAAsB,CAAC,eAAe,CAAC,CAAC,CAAC;IAC9E,MAAM,WAAW,GAAG,wBAAwB,GAAG,6BAA6B,CAAC;IAC7E,OAAO;QACN,iBAAiB,EAAE;YAClB,kBAAkB,EAAE,OAAO,CAAC,oBAAoB,GAAG,WAAW;YAC9D,WAAW,EAAE,OAAO,CAAC,mBAAmB,GAAG,WAAW;SACtD;QACD,YAAY,EAAE,EAAE,aAAa,EAAE,OAAO,CAAC,aAAa,GAAG,WAAW,EAAE;KACpE,CAAC;AACH,CAAC"}
@@ -1,121 +1,159 @@
1
1
  /**
2
- * Control-network inbound admission gates (defense-in-depth): the
3
- * encrypted-connection checkpoint and the circuit-relay reservation checkpoint.
4
- *
5
- * Layer 2 of the membership enforcement chain: the PRIMARY gates are per-stream
6
- * — every sensitive sereus control protocol rejects a peer that fails the
7
- * voucher-anchored membership check (wake and strand-addr via
8
- * `CadreNode.isAuthorizedMember`; the Optimystic control-DB protocols via the
9
- * materialized-snapshot gate `CadreNode.authorizeInboundControlStream`), and
10
- * the replicated rows an outsider *can* still write are disbelieved at read
11
- * time. This module adds the opportunistic connection-level layer on top: a
12
- * peer this node can positively determine is NOT authorized is refused at the
13
- * encrypted-connection checkpoint, before any protocol negotiation, so a
14
- * known-nothing outsider is never even in the conversation — EXCEPT on a node
15
- * that runs the circuit-relay server, where the refusal moves to the
16
- * relay-reservation checkpoint instead (see "The relay-reservation seam").
17
- *
18
- * ## The stranger allowlist (the ONE place it is defined)
19
- *
20
- * A libp2p connection gater decides per CONNECTION, before protocols are
21
- * negotiated, so "allow seed, deny repo" cannot be expressed here — instead the
22
- * policy admits a connection whenever a legitimate stranger interaction could be
23
- * riding it, and the per-stream gates take over. The complete set of protocols a
24
- * NOT-yet-authorized peer may legitimately speak on a control node is:
25
- *
26
- * - `/sereus/seed/1.0.0` ({@link SEED_PROTOCOL}) — enrollment seed delivery.
2
+ * Control-network inbound admission gates: the encrypted-connection checkpoint
3
+ * and the circuit-relay reservation checkpoint.
4
+ *
5
+ * The fail-closed layer of the membership enforcement chain is per-stream: the
6
+ * control node's protocol guard (`control-protocol-guard.ts`) refuses a peer that
7
+ * is not an authorized member on every protocol not declared open to strangers,
8
+ * before its handler runs, and the replicated rows an outsider *can* still write
9
+ * are disbelieved at read time. This module is NOT a stranger boundary on an
10
+ * enrolled node — outside the bring-up quiet period it admits every inbound
11
+ * connection. Its jobs are:
12
+ *
13
+ * - the bring-up quiet period (below), the one state in which it denies;
14
+ * - deciding which admitted peers carry a deadline: a peer the policy cannot
15
+ * place is admitted PROVISIONALLY, and its connection is closed at the
16
+ * deadline unless the policy admits it by then (see "Provisional admission");
17
+ * - handing circuit-relay reservations to the reservation policy (see "The
18
+ * relay-reservation seam").
19
+ *
20
+ * Why a stranger's connection is admitted at all: the gate sees only a peer id,
21
+ * after the encrypted handshake and before any protocol, so it cannot tell an
22
+ * outsider from a device carrying a cadre invitation this node has not received
23
+ * yet, or from a sibling whose membership row is still replicating. Refusing
24
+ * would fail those at the connection; admitting costs a mute connection for a
25
+ * bounded time, because the protocol guard refuses it every members-only protocol.
26
+ *
27
+ * ## Admitted outright
28
+ *
29
+ * A peer the policy CAN place gets no deadline. Besides members, configured
30
+ * infrastructure and an un-enrolled node's whole world (empty anchor or empty
31
+ * authorized set), that covers the stranger windows: states in which this node
32
+ * expects a stranger on one of the `stranger-open` protocols declared in
33
+ * `controlProtocolClasses` (`control-protocol-guard.ts`):
34
+ *
35
+ * - `/sereus/seed/1.0.0` — enrollment seed delivery.
27
36
  * An owner dials a brand-new node to seed it (the new node has no members
28
- * yet, so its gate is inert), and an invited phone dials the owner before it
29
- * is authorized (admitted via the enrollment window `CadreNode.createInvite`
30
- * opens). The handler's own trust decision is the anchored seed-trust policy.
31
- * - `/sereus/formation/1.0.0` ({@link FORMATION_PROTOCOL}) — cross-party
37
+ * yet, so it admits everyone outright). The handler's own trust decision is the
38
+ * anchored seed-trust policy — or, on a node started with a claim secret
39
+ * (`CadreNodeConfig.claim`), the claim-secret policy. Such a node is the one
40
+ * stranger-facing state that is NOT "admit the connection and let the
41
+ * per-stream gates sort it out": while it waits to be claimed
42
+ * (`CadreNode.isAwaitingClaim`) its connection is admitted, because the claim
43
+ * seed has to ride one, but its control-DB streams and relay reservations are
44
+ * refused ahead of every admission below, the empty-anchor one included. An
45
+ * unclaimed node has no siblings to replicate from, and one on a public
46
+ * address must not relay for anyone. The claim anchors the owner, after which
47
+ * the ordinary rules apply.
48
+ * - `/sereus/formation/1.0.0` — cross-party
32
49
  * strand formation via open invitations. Stranger-facing BY DESIGN: the
33
50
  * initiator is another party, and its token is only checkable inside the
34
- * protocol. The exemption is therefore keyed on EXPECTATION of a stranger,
35
- * not capability to serve one: stranger denial is suspended only while this
36
- * node has at least one UNEXPIRED, NOT-FULLY-CONSUMED open invitation
37
- * outstanding (`StrandSolicitationService.hasOutstandingInvitation` — the
38
- * tokens this process minted or published, plus any still-redeemable
39
- * `FormationInvite` row the usage recorder can see). Registering the
40
- * responder does NOT suspend it, so every node — each registers one at
41
- * `CadreNode.start` — keeps a live gate. The
51
+ * protocol. The window is keyed on EXPECTATION of a stranger, not capability
52
+ * to serve one: it is open only while this node has at least one UNEXPIRED,
53
+ * NOT-FULLY-CONSUMED open invitation outstanding
54
+ * (`StrandSolicitationService.hasOutstandingInvitation` — the tokens this
55
+ * process minted or published, plus any still-redeemable `FormationInvite`
56
+ * row the usage recorder can see). Registering the responder does NOT open
57
+ * it, so on every node — each registers one at `CadreNode.start` — a stranger
58
+ * with no invitation in play stays on the provisional deadline. The
42
59
  * handler's own trust decision remains the per-token check, which is
43
60
  * strictly finer than this one: a peer admitted here can still be rejected
44
61
  * in-protocol for a bogus or spent token.
62
+ * - `/sereus/cadre-invite/1.0.0` — redemption
63
+ * of a cadre invitation at any member machine. Stranger-facing BY DESIGN:
64
+ * the device is not a member until the redemption writes its row, and its
65
+ * proof of possession (a signature with the invitation's private key) is
66
+ * only checkable inside the protocol. Keyed on expectation, as formation's
67
+ * is: open only while this node holds at least one LIVE `CadreInvite` row
68
+ * (`ControlDatabase.hasLiveCadreInvite`: not withdrawn, unexpired, uses left,
69
+ * issuer still an owner). A member that has not yet received the device's
70
+ * row by replication admits the device provisionally instead, seats the row
71
+ * from the invitation bundle during the redemption, and so admits it at the
72
+ * deadline's re-check.
45
73
  *
46
74
  * There is one further connection-level carve-out, which is NOT a protocol
47
- * exemption and needs no stranger window:
75
+ * window:
48
76
  *
49
77
  * - **Announced delegate peers** (`delegate-admission.ts`). A member's strand
50
78
  * node runs as a separate libp2p identity whose peerId no sibling can
51
79
  * recompute. Before starting a strand node, a member's control node
52
80
  * announces that peerId over the already-authenticated strand-addr RPC, and
53
81
  * the receiver holds a short-lived grant for it
54
- * (`CadreNode.grantDelegateAdmission`). The grant admits the CONNECTION,
55
- * admits the peer's RESERVATION at the seam below (without spending the
56
- * unauthorized budget), and nothing else — it is deliberately invisible to
57
- * the per-stream gate, so a delegate still gets refused on every
82
+ * (`CadreNode.grantDelegateAdmission`). The grant admits the CONNECTION
83
+ * outright, admits the peer's RESERVATION at the seam below (without
84
+ * spending the unauthorized budget), and nothing else — it is deliberately
85
+ * invisible to the protocol guard, so a delegate still gets refused on every
58
86
  * members-only protocol.
59
87
  *
88
+ * ## Provisional admission
89
+ *
90
+ * A peer the policy cannot place (`'admit-provisionally'`) gets its connection
91
+ * and a deadline — {@link PROVISIONAL_ADMISSION_DEADLINE_MS} at the default
92
+ * declaration; `CadreNode` passes the one derived from its OWN declared link,
93
+ * because the member is the machine that decides. At the deadline the gate asks
94
+ * the policy again:
95
+ *
96
+ * - `'admit'` — the peer has since become a member, holds a delegate grant, or
97
+ * this node now holds a live invitation (a redeeming device's row was
98
+ * seated): the connection stays, and nothing is re-armed;
99
+ * - `'admit-provisionally'` — the connection is closed (a bounded graceful
100
+ * close, with an abort only as the escalation);
101
+ * - the question throws or outlasts the decision deadline — the connection
102
+ * stays (see "Fail-open, deliberately").
103
+ *
104
+ * A connection that is already gone by then costs no question. One peer may hold
105
+ * several provisional connections; each deadline re-asks on its own.
106
+ *
107
+ * NOTE: the gate does not stop a provisionally admitted stranger from being
108
+ * counted into this node's FRET ring and control-database cohort by opening or
109
+ * advertising the party's protocols — FRET and Optimystic decide that from the
110
+ * protocols libp2p records the peer as serving. Ticket
111
+ * `stranger-joins-the-control-cohort-by-advertising-protocols` (blocked).
112
+ *
60
113
  * ## The relay-reservation seam
61
114
  *
62
115
  * A circuit-relay reservation is established by the reserving peer DIALING the
63
- * relay, so at the relay it is an inbound connection — and killing that
116
+ * relay, so at the relay it rides an inbound connection — and closing that
64
117
  * connection kills the reservation. For a genuine member whose `CadrePeer` row
65
- * has not yet replicated to this node, a connection-level deny here is NOT
66
- * self-healing the way a data connection's is: an outbound reconcile dial
67
- * re-establishes a data link, but no outbound dial can grant the REMOTE peer a
68
- * reservation, and a relay-only peer has no address of its own to dial back —
69
- * the reservation IS its address. Boot ordering makes the window ordinary (a
70
- * node's circuit listener runs inside `libp2p.start()`, before its own row
71
- * could have replicated anywhere), and a stalled replication makes it
72
- * unbounded. So the relay would be answering a RELAY question ("may this peer
73
- * use my forwarding capacity?") with a MEMBERSHIP answer, at a checkpoint where
74
- * a wrong answer is unrecoverable.
75
- *
76
- * On a node whose relay server is enabled the two questions are separated:
77
- *
78
- * - The policy returns `'admit-for-relay'` instead of `'deny'`, and the
79
- * connection is ADMITTED. The fail-closed per-stream gates still refuse such
80
- * a peer every members-only protocol, so it gains identify/ping and the
81
- * relay hop protocol, nothing else.
82
- * - The reservation itself is decided at libp2p's
83
- * `denyInboundRelayReservation` hook (the circuit-relay server consults it
84
- * per RESERVE request): the policy admits members, delegates and configured
85
- * infra outright, and admits peers it cannot place only within a bounded
86
- * budget ({@link UnauthorizedReservationBudget}) — a member whose row is in
87
- * flight always finds a slot under any sane cap, while outsiders cannot
88
- * annex the party's relay capacity. COUNT and lifetime are the only bounds
89
- * on such a peer: a party-run relay forwards without libp2p's per-connection
90
- * data and duration limit by default (`relay-server.ts`), so what a granted
91
- * slot carries is not capped.
92
- * - An `'admit-for-relay'` connection that is NOT reserving is dropped: it has
93
- * {@link RELAY_ADMISSION_RESERVE_DEADLINE_MS} to get a reservation ADMITTED
94
- * at that hook, after which the gate CLOSES the underlying connection so
95
- * both ends let go of the socket. The guarantee above thus weakens on
96
- * relay-enabled nodes from "never in the conversation" to "in it briefly,
97
- * and can speak nothing".
118
+ * has not yet replicated to this node that would NOT be self-healing the way a
119
+ * data connection's close is: an outbound reconcile dial re-establishes a data
120
+ * link, but no outbound dial can grant the REMOTE peer a reservation, and a
121
+ * relay-only peer has no address of its own to dial back — the reservation IS
122
+ * its address. Boot ordering makes the window ordinary (a node reserves at the
123
+ * end of its own `start()`, before its row could have replicated anywhere), and
124
+ * a stalled replication makes it unbounded. So the reservation is decided on its
125
+ * own terms, not by the connection's:
126
+ *
127
+ * - It is decided at libp2p's `denyInboundRelayReservation` hook (the
128
+ * circuit-relay server consults it per RESERVE request): the policy admits
129
+ * members, delegates and configured infra outright, and admits peers it
130
+ * cannot place only within a bounded budget
131
+ * ({@link UnauthorizedReservationBudget}) — a member whose row is in flight
132
+ * always finds a slot under any sane cap, while outsiders cannot annex the
133
+ * party's relay capacity. COUNT and lifetime are the only bounds on such a
134
+ * peer: a party-run relay forwards without libp2p's per-connection data and
135
+ * duration limit by default (`relay-server.ts`), so what a granted slot
136
+ * carries is not capped.
137
+ * - An ADMITTED reservation disarms every provisional deadline the peer holds
138
+ * here, so its connection outlives the deadline even while the peer is still
139
+ * unplaced. A refused one disarms nothing.
98
140
  *
99
141
  * The deadline clears on reservation ADMISSION, not on the reservation's own
100
142
  * success: this gate cannot observe the server-side `reserve()` outcome, so a
101
143
  * peer whose admitted reservation is then refused for server capacity keeps its
102
144
  * connection until either side closes it — bounded and mute, so harmless.
103
145
  *
104
- * Everything else a control node handles — the Optimystic control-DB protocols
105
- * (`/optimystic/control-<party>/{repo,cluster,sync,block-transfer}/…`), wake
106
- * (`/sereus/strand-wake/1.0.0`), and strand-addr (`/sereus/strand-addr/1.0.0`)
107
- * — is members-only, and every one of them enforces that per-stream. Wake and
108
- * strand-addr check `isAuthorizedMember` inside their handlers; the four
109
- * control-DB protocols are gated by the fail-closed
110
- * `CadreNode.authorizeInboundControlStream` (wired as libp2p's
111
- * `authorizeInboundStream` upstream hook), which judges each inbound stream
112
- * against the MATERIALIZED authorized-peer snapshot — synchronous and
113
- * in-memory, because a live DB read from inside the gate would deadlock into
114
- * mutual denial. The two layers complement, not duplicate: this connection
115
- * gate is fail-open over a live DB read (deny only on positive proof of an
116
- * outsider), the stream gate is fail-closed over the snapshot and has NO
117
- * stranger carve-outs — an enrollment window admits a stranger's connection
118
- * for seed delivery, yet its repo streams are still refused.
146
+ * Everything else a control node serves is either libp2p plumbing open to any
147
+ * connection (identify, ping, hole punching, AutoNAT, the relay protocols) or
148
+ * members-only — wake, strand-addr, the Optimystic control-DB protocols and FRET —
149
+ * and the fail-closed layer for all of it is the protocol guard
150
+ * (`control-protocol-guard.ts`), one seam that wraps every handler at dispatch,
151
+ * with a protocol nobody classed treated as members-only. The two layers
152
+ * complement, not duplicate: this connection gate is fail-open over a live DB
153
+ * read and decides only how long a connection lasts, the protocol guard is
154
+ * fail-closed and has NO stranger carve-outs — a live invitation admits a
155
+ * stranger's connection outright for redemption, yet its repo and FRET streams
156
+ * are still refused.
119
157
  *
120
158
  * ## The bring-up quiet period
121
159
  *
@@ -151,55 +189,49 @@
151
189
  *
152
190
  * ## Fail-open, deliberately
153
191
  *
154
- * Outside that window this layer only ever denies on a POSITIVE determination of
155
- * "unauthorized outsider while no stranger path is open". Any error, missing
156
- * dependency, or ambiguous state admits the connection (and the reservation) and
157
- * defers to the fail-closed stream gates — a DB hiccup must not partition a
158
- * legitimate cadre.
192
+ * Outside that window this layer never denies, and it closes a provisional
193
+ * connection only on a positive answer that the peer is still unplaced. Any
194
+ * error, missing dependency, timeout or ambiguous state admits the connection
195
+ * outright (and the reservation), or keeps a provisional connection at its
196
+ * deadline, and defers to the fail-closed stream gates — a DB hiccup must not
197
+ * partition a legitimate cadre.
159
198
  */
160
199
  import type { ConnectionGater } from '@libp2p/interface';
161
200
  /**
162
- * The protocols a not-yet-authorized peer may legitimately speak on a control
163
- * node (see the module doc above for why each is open and where its own trust
164
- * decision lives). Exported as the single reference point so the allowlist
165
- * cannot silently drift across modules.
166
- */
167
- export declare const STRANGER_OPEN_PROTOCOLS: readonly string[];
168
- /**
169
- * How long `CadreNode.createInvite` holds the inbound gate open for strangers
170
- * when the invite carries no explicit expiry: the invitee must dial in before
171
- * it is authorized, and an expiry-less invite gives the gate no bound of its
172
- * own. Redeeming after this window still works once the owner re-mints (or the
173
- * caller re-opens the window via `CadreNode.openEnrollmentWindow`).
174
- */
175
- export declare const DEFAULT_ENROLLMENT_WINDOW_MS: number;
176
- /**
177
- * How long an `'admit-for-relay'` connection may exist without a relay
178
- * reservation being ADMITTED at the `denyInboundRelayReservation` hook, after
179
- * which the gate closes the underlying connection. A reserving client asks for
180
- * its slot immediately after the connection upgrades (`relay-reservation.ts`
181
- * dials and requests in one drive; a strand node's configured circuit listener
182
- * does the same from inside its own `listen()`), so a connection idle past this
183
- * deadline is not reserving.
184
- *
185
- * Derived from the link ({@link relayAdmissionReserveDeadlineMs}): one link round trip for the
186
- * request to arrive plus one admission decision on it. This is the value at the default
187
- * declaration; `CadreNode` passes the one derived from the relay's OWN declaration, because the
188
- * relay is the machine that decides.
201
+ * How long a provisionally admitted connection lasts before the gate re-asks the
202
+ * policy and closes it unless the peer is admissible by then (see the module
203
+ * doc's "Provisional admission").
204
+ *
205
+ * {@link relayedRequestBudgetMs}: 28 500 ms at the default declaration. The
206
+ * longest exchange a stranger legitimately starts on a fresh connection is a
207
+ * cadre invitation redemption, and the device abandons each member address after
208
+ * that same budget of its own declared link (`redeemAtMembers`): it covers the
209
+ * dial, the request, the member's catch-up push, the seat and the redemption. So
210
+ * a member never cuts an exchange the device is still waiting on, and a
211
+ * reservation request lands well inside it. This is the value at the default
212
+ * declaration; `CadreNode` passes the one derived from its OWN declaration.
213
+ *
214
+ * NOTE: accepted tradeoff — any stranger can hold a mute connection to any
215
+ * enrolled member for this long, weighed against letting a device redeem an
216
+ * invitation at a member that has not yet received its row (maintainer,
217
+ * 2026-10-07, plan `cadre-invite-redeemable-before-the-row-replicates`). It can
218
+ * open only stranger-open and transport streams (the protocol guard), and
219
+ * libp2p's connection-manager limits bound how many it holds. Revisit if stranger
220
+ * connections show up as load on a member.
189
221
  */
190
- export declare const RELAY_ADMISSION_RESERVE_DEADLINE_MS: number;
222
+ export declare const PROVISIONAL_ADMISSION_DEADLINE_MS: number;
191
223
  /**
192
- * Bound on the graceful close of an expired relay-only connection. It exists
224
+ * Bound on the graceful close of an expired provisional connection. It exists
193
225
  * because `AbstractMultiaddrConnection.close()` awaits an `idle`/`drain` event
194
226
  * when the connection still has unsent bytes, and that wait has no timeout of
195
227
  * its own — an unsignalled one never ends. This gate writes nothing to a
196
- * stranger, so the wait is not reachable today; the bound is here so a timer
228
+ * stranger, so the wait is not reachable from here; the bound is here so a timer
197
229
  * callback can never hold an unending await.
198
230
  *
199
231
  * Applied through {@link withDeadline}, not `AbortSignal.timeout`: the latter is
200
232
  * not reliably present on React Native/Hermes, which loads this same module.
201
233
  */
202
- export declare const RELAY_ADMISSION_CLOSE_TIMEOUT_MS = 2000;
234
+ export declare const PROVISIONAL_ADMISSION_CLOSE_TIMEOUT_MS = 2000;
203
235
  /**
204
236
  * Default cap on concurrent relay reservations held by peers the membership
205
237
  * check could not place (see {@link UnauthorizedReservationBudget}). Small on
@@ -221,15 +253,16 @@ export declare const MAX_UNAUTHORIZED_RELAY_RESERVATIONS = 8;
221
253
  /**
222
254
  * The connection-level outcome of the admission policy:
223
255
  * - `'admit'` — a peer with a legitimate claim on the connection (member,
224
- * delegate, infra, open stranger window, or any fail-open state).
225
- * - `'deny'` — positively an outsider, and this node runs no relay server, so
226
- * the connection can carry nothing legitimate.
227
- * - `'admit-for-relay'` — positively an outsider (or an unreplicated member —
228
- * indistinguishable), but this node runs the relay server: admit the
229
- * connection so a reservation can be asked for, decide at the reservation
230
- * seam, and drop the connection if no reservation is admitted in time.
256
+ * delegate, infra, open stranger window, or any fail-open state); no deadline.
257
+ * - `'admit-provisionally'` — a peer the policy cannot place (an outsider, a
258
+ * device whose invitation row this node does not hold yet, or a member whose
259
+ * row is still replicating — indistinguishable here): admit the connection,
260
+ * and at the deadline ask again and close it unless the answer is `'admit'`.
261
+ *
262
+ * There is no deny: the gate's only denial is the bring-up quiet period, which
263
+ * is not a judgement of the peer.
231
264
  */
232
- export type InboundConnectionVerdict = 'admit' | 'deny' | 'admit-for-relay';
265
+ export type InboundConnectionVerdict = 'admit' | 'admit-provisionally';
233
266
  /**
234
267
  * The admission decisions the gate defers to — implemented by
235
268
  * `CadreNode.admitInboundControlConnection` /
@@ -239,7 +272,10 @@ export type InboundConnectionVerdict = 'admit' | 'deny' | 'admit-for-relay';
239
272
  * composition/fail-open behavior is unit-testable without a full node.
240
273
  */
241
274
  export interface InboundAdmissionPolicy {
242
- /** Verdict on an inbound encrypted connection from this peer. */
275
+ /**
276
+ * Verdict on an inbound encrypted connection from this peer. Asked again at a
277
+ * provisional connection's deadline, so it must answer from current state.
278
+ */
243
279
  admitInbound(remotePeerId: string): Promise<InboundConnectionVerdict> | InboundConnectionVerdict;
244
280
  /** Should this peer be granted a circuit-relay reservation slot? */
245
281
  admitRelayReservation(remotePeerId: string): Promise<boolean> | boolean;
@@ -304,27 +340,30 @@ export declare class UnauthorizedReservationBudget {
304
340
  * membership — this node decides for itself who to talk to.
305
341
  *
306
342
  * Composition semantics: every hook of `base` is preserved as-is; on the three
307
- * composed hooks a deny from EITHER the base gater or the admission policy
308
- * denies. A policy error — or a decision slower than `decisionTimeoutMs` —
309
- * takes the fail-open outcome (connection admitted / reservation admitted, see
310
- * module doc); the base gater's verdict is still honored first.
343
+ * composed hooks a deny from the base gater denies, and so does the quiet
344
+ * period. The admission policy never denies a connection. A policy error — or a
345
+ * decision slower than `decisionTimeoutMs` — takes the fail-open outcome
346
+ * (connection admitted outright / reservation admitted, see module doc); the
347
+ * base gater's verdict is still honored first.
311
348
  *
312
- * An `'admit-for-relay'` verdict admits the connection and arms a
313
- * `reserveDeadlineMs` timer against it; the timer is disarmed when a
314
- * reservation for that peer is ADMITTED at the reservation hook, and closes the
315
- * underlying `MultiaddrConnection` when it fires first.
349
+ * An `'admit-provisionally'` verdict admits the connection and arms a
350
+ * `provisionalDeadlineMs` timer against it. When the timer fires the policy is
351
+ * asked again, and the underlying `MultiaddrConnection` is closed unless it now
352
+ * answers `'admit'`; a reservation for that peer ADMITTED at the reservation
353
+ * hook disarms the timer first.
316
354
  *
317
355
  * NOTE: `base` is spread, so a gater passed as a CLASS INSTANCE would lose its
318
356
  * prototype methods; every caller in this repo (and libp2p's own default)
319
357
  * supplies a plain object. If a class-based gater ever shows up, delegate
320
358
  * per-hook instead of spreading.
321
359
  *
322
- * Deny timing, as observed by the denied dialer: noise negotiates the muxer in
323
- * the security handshake's early data, so the DIALER's upgrade may complete
324
- * (its `dial()` resolves) before this receiver-side hook runs. The deny then
325
- * aborts the receiver's upgrade — the receiver never registers the connection
326
- * and never creates its muxer, so no protocol can ever be negotiated — and the
327
- * dialer sees its "open" connection close moments later.
360
+ * Deny timing, as observed by the denied dialer (a quiet-period or base-gater
361
+ * deny): noise negotiates the muxer in the security handshake's early data, so
362
+ * the DIALER's upgrade may complete (its `dial()` resolves) before this
363
+ * receiver-side hook runs. The deny then aborts the receiver's upgrade — the
364
+ * receiver never registers the connection and never creates its muxer, so no
365
+ * protocol can ever be negotiated — and the dialer sees its "open" connection
366
+ * close moments later.
328
367
  *
329
368
  * Control node only: strand cohort nodes legitimately connect cross-party
330
369
  * peers, so cadre membership never gates them. An OPEN strand's node receives
@@ -333,7 +372,7 @@ export declare class UnauthorizedReservationBudget {
333
372
  * evidence, not this module's membership admission — see
334
373
  * `strand-revocation-enforcer.ts`.
335
374
  */
336
- export declare function createMembershipConnectionGater(policy: InboundAdmissionPolicy, base?: ConnectionGater, decisionTimeoutMs?: number, reserveDeadlineMs?: number): ConnectionGater;
375
+ export declare function createMembershipConnectionGater(policy: InboundAdmissionPolicy, base?: ConnectionGater, decisionTimeoutMs?: number, provisionalDeadlineMs?: number): ConnectionGater;
337
376
  /**
338
377
  * Run one admission decision under `timeoutMs`, resolving to `fallback` (the
339
378
  * fail-open outcome) if it has not settled in time — see