@serfab/cadre-core 1.6.0 → 1.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -6
- package/dist/cadre-node.d.ts +548 -137
- package/dist/cadre-node.js +1208 -383
- package/dist/cadre-node.js.map +1 -1
- package/dist/control-authorization.d.ts +2 -2
- package/dist/control-authorization.js +1 -0
- package/dist/control-authorization.js.map +1 -1
- package/dist/control-cohort.d.ts +6 -0
- package/dist/control-cohort.js +6 -0
- package/dist/control-cohort.js.map +1 -1
- package/dist/control-database.d.ts +46 -8
- package/dist/control-database.js +97 -18
- package/dist/control-database.js.map +1 -1
- package/dist/control-formation-recorder.d.ts +37 -14
- package/dist/control-formation-recorder.js +60 -10
- package/dist/control-formation-recorder.js.map +1 -1
- package/dist/control-read-retry.d.ts +13 -12
- package/dist/control-read-retry.js +14 -12
- package/dist/control-read-retry.js.map +1 -1
- package/dist/control-schema.d.ts +1 -1
- package/dist/control-schema.js +67 -5
- package/dist/control-schema.js.map +1 -1
- package/dist/control-stream.d.ts +9 -1
- package/dist/control-stream.js +24 -1
- package/dist/control-stream.js.map +1 -1
- package/dist/control-write-retry.d.ts +12 -2
- package/dist/control-write-retry.js +13 -2
- package/dist/control-write-retry.js.map +1 -1
- package/dist/delegate-admission.d.ts +11 -8
- package/dist/delegate-admission.js +19 -11
- package/dist/delegate-admission.js.map +1 -1
- package/dist/diagnostics/connection-path.d.ts +0 -7
- package/dist/diagnostics/connection-path.js +0 -7
- package/dist/diagnostics/connection-path.js.map +1 -1
- package/dist/formation-approval.d.ts +7 -0
- package/dist/formation-approval.js +9 -3
- package/dist/formation-approval.js.map +1 -1
- package/dist/fs-atomic.d.ts +11 -2
- package/dist/fs-atomic.js +13 -3
- package/dist/fs-atomic.js.map +1 -1
- package/dist/hibernation-manager.d.ts +111 -8
- package/dist/hibernation-manager.js +234 -49
- package/dist/hibernation-manager.js.map +1 -1
- package/dist/index.d.ts +13 -6
- package/dist/index.js +27 -5
- package/dist/index.js.map +1 -1
- package/dist/joined-strand-store.d.ts +177 -0
- package/dist/joined-strand-store.js +431 -0
- package/dist/joined-strand-store.js.map +1 -0
- package/dist/key-store-file.js +14 -5
- package/dist/key-store-file.js.map +1 -1
- package/dist/key-store.d.ts +6 -0
- package/dist/key-store.js.map +1 -1
- package/dist/link-budget.d.ts +367 -69
- package/dist/link-budget.js +375 -72
- package/dist/link-budget.js.map +1 -1
- package/dist/membership-connection-gater.d.ts +30 -43
- package/dist/membership-connection-gater.js +31 -42
- package/dist/membership-connection-gater.js.map +1 -1
- package/dist/node-local-snapshot.d.ts +5 -4
- package/dist/node-local-snapshot.js +6 -3
- package/dist/node-local-snapshot.js.map +1 -1
- package/dist/peer-dial.d.ts +24 -4
- package/dist/peer-dial.js +74 -5
- package/dist/peer-dial.js.map +1 -1
- package/dist/peer-join-backfill.d.ts +35 -15
- package/dist/peer-join-backfill.js +115 -55
- package/dist/peer-join-backfill.js.map +1 -1
- package/dist/push-fanout.d.ts +6 -0
- package/dist/push-fanout.js +6 -0
- package/dist/push-fanout.js.map +1 -1
- package/dist/relay-reservation.d.ts +3 -1
- package/dist/relay-reservation.js +3 -1
- package/dist/relay-reservation.js.map +1 -1
- package/dist/relay-server.d.ts +79 -0
- package/dist/relay-server.js +74 -0
- package/dist/relay-server.js.map +1 -0
- package/dist/seed-bootstrap.d.ts +57 -4
- package/dist/seed-bootstrap.js +107 -83
- package/dist/seed-bootstrap.js.map +1 -1
- package/dist/storage-scope.d.ts +33 -17
- package/dist/storage-scope.js +44 -23
- package/dist/storage-scope.js.map +1 -1
- package/dist/strand-addr-protocol.d.ts +58 -21
- package/dist/strand-addr-protocol.js +133 -85
- package/dist/strand-addr-protocol.js.map +1 -1
- package/dist/strand-database.d.ts +20 -2
- package/dist/strand-database.js +42 -5
- package/dist/strand-database.js.map +1 -1
- package/dist/strand-first-sync-gate.d.ts +59 -21
- package/dist/strand-first-sync-gate.js +58 -19
- package/dist/strand-first-sync-gate.js.map +1 -1
- package/dist/strand-formation-deadlines.d.ts +151 -0
- package/dist/strand-formation-deadlines.js +171 -0
- package/dist/strand-formation-deadlines.js.map +1 -0
- package/dist/strand-formation-manager.d.ts +63 -30
- package/dist/strand-formation-manager.js +67 -41
- package/dist/strand-formation-manager.js.map +1 -1
- package/dist/strand-formation-protocol.d.ts +45 -35
- package/dist/strand-formation-protocol.js +59 -122
- package/dist/strand-formation-protocol.js.map +1 -1
- package/dist/strand-instance-manager.d.ts +152 -6
- package/dist/strand-instance-manager.js +331 -42
- package/dist/strand-instance-manager.js.map +1 -1
- package/dist/strand-membership-writer.d.ts +6 -0
- package/dist/strand-membership-writer.js +11 -0
- package/dist/strand-membership-writer.js.map +1 -1
- package/dist/strand-peer-book-file.d.ts +12 -0
- package/dist/strand-peer-book-file.js +37 -0
- package/dist/strand-peer-book-file.js.map +1 -0
- package/dist/strand-peer-book-protocol.d.ts +168 -0
- package/dist/strand-peer-book-protocol.js +356 -0
- package/dist/strand-peer-book-protocol.js.map +1 -0
- package/dist/strand-peer-book-swap.d.ts +104 -0
- package/dist/strand-peer-book-swap.js +284 -0
- package/dist/strand-peer-book-swap.js.map +1 -0
- package/dist/strand-peer-book.d.ts +159 -0
- package/dist/strand-peer-book.js +361 -0
- package/dist/strand-peer-book.js.map +1 -0
- package/dist/strand-peer-observer.d.ts +88 -0
- package/dist/strand-peer-observer.js +180 -0
- package/dist/strand-peer-observer.js.map +1 -0
- package/dist/strand-revocation-enforcer.js +2 -1
- package/dist/strand-revocation-enforcer.js.map +1 -1
- package/dist/strand-solicitation.d.ts +36 -20
- package/dist/strand-solicitation.js +4 -4
- package/dist/strand-solicitation.js.map +1 -1
- package/dist/strand-wake-protocol.d.ts +80 -23
- package/dist/strand-wake-protocol.js +89 -64
- package/dist/strand-wake-protocol.js.map +1 -1
- package/dist/types.d.ts +181 -33
- package/dist/types.js +4 -3
- package/dist/types.js.map +1 -1
- package/package.json +11 -7
- package/src/cadre-node.ts +1316 -398
- package/src/control-authorization.ts +2 -1
- package/src/control-cohort.ts +6 -0
- package/src/control-database.ts +122 -18
- package/src/control-formation-recorder.ts +354 -305
- package/src/control-read-retry.ts +14 -12
- package/src/control-schema.ts +67 -5
- package/src/control-stream.ts +25 -1
- package/src/control-write-retry.ts +13 -2
- package/src/delegate-admission.ts +23 -13
- package/src/diagnostics/connection-path.ts +0 -7
- package/src/formation-approval.ts +610 -604
- package/src/fs-atomic.ts +14 -4
- package/src/hibernation-manager.ts +638 -437
- package/src/index.ts +91 -6
- package/src/joined-strand-store.ts +498 -0
- package/src/key-store-file.ts +14 -5
- package/src/key-store.ts +6 -0
- package/src/link-budget.ts +393 -74
- package/src/membership-connection-gater.ts +31 -45
- package/src/node-local-snapshot.ts +293 -289
- package/src/peer-dial.ts +81 -7
- package/src/peer-join-backfill.ts +120 -57
- package/src/push-fanout.ts +6 -0
- package/src/relay-reservation.ts +3 -1
- package/src/relay-server.ts +98 -0
- package/src/seed-bootstrap.ts +133 -91
- package/src/storage-scope.ts +44 -23
- package/src/strand-addr-protocol.ts +547 -458
- package/src/strand-database.ts +287 -242
- package/src/strand-first-sync-gate.ts +58 -19
- package/src/strand-formation-deadlines.ts +227 -0
- package/src/strand-formation-manager.ts +700 -647
- package/src/strand-formation-protocol.ts +103 -150
- package/src/strand-instance-manager.ts +387 -45
- package/src/strand-membership-writer.ts +12 -0
- package/src/strand-peer-book-file.ts +39 -0
- package/src/strand-peer-book-protocol.ts +466 -0
- package/src/strand-peer-book-swap.ts +338 -0
- package/src/strand-peer-book.ts +475 -0
- package/src/strand-peer-observer.ts +235 -0
- package/src/strand-revocation-enforcer.ts +2 -1
- package/src/strand-solicitation.ts +519 -500
- package/src/strand-wake-protocol.ts +401 -355
- package/src/types.ts +185 -33
|
@@ -72,11 +72,21 @@ export const SCHEMA_INIT_ATTEMPTS = 5;
|
|
|
72
72
|
* This budget — not the attempt count — is what makes the policy safe to sit under every
|
|
73
73
|
* control write. A transient failure (stream reset while a connection is still forming)
|
|
74
74
|
* surfaces in well under a second, so it is retried and the loop adds at most ~2.2 s. A
|
|
75
|
-
* genuinely silent cohort member fails at ~
|
|
76
|
-
* attempts,
|
|
75
|
+
* genuinely silent cohort member fails at ~21 s per pend round (two `ClusterClient`
|
|
76
|
+
* response-deadline attempts, 10.5 s each at the default declared link; a two-round write
|
|
77
|
+
* measured 42.2 s in `control-write-degraded-cohort-member.integration.ts`), which
|
|
77
78
|
* already exceeds this budget when attempt 1 returns — so that case is surfaced immediately
|
|
78
79
|
* and retry adds ZERO latency to the case where it cannot help.
|
|
79
80
|
*
|
|
81
|
+
* It cuts the loop off by design, so it does not grow with the link: its job is to end the
|
|
82
|
+
* retries of slow attempts, and the caller gets the last attempt's error unchanged. An attempt
|
|
83
|
+
* whose read phase consulted a silent peer ends at about one per-peer read deadline
|
|
84
|
+
* (`cohortReadDeadlineMs` in `link-budget.ts`: 7 s at the default declared link, 5 s before it
|
|
85
|
+
* was derived, 1 s at Optimystic's own default), so it still gets one retry inside this budget
|
|
86
|
+
* where it once got two; an attempt that runs into the `ClusterClient` response deadline
|
|
87
|
+
* (10.5 s at the default declared link) still gets none. See `docs/cadre-consistency.md` →
|
|
88
|
+
* "Deadlines Over Optimystic's Reads and Commits".
|
|
89
|
+
*
|
|
80
90
|
* NOTE: a failed commit attempt now also pays a cancel discharge before its error returns
|
|
81
91
|
* (optimystic `TransactorSource.transact`'s catch, added by upstream
|
|
82
92
|
* `1-a-failed-attempt-must-discharge-its-own-pend`) — bounded by six rounds and
|
|
@@ -88,6 +98,7 @@ export const SCHEMA_INIT_ATTEMPTS = 5;
|
|
|
88
98
|
* to do: if that case ever starts failing with `failed after 2/3 attempt(s)`, the cancel
|
|
89
99
|
* discharge is where the time went.
|
|
90
100
|
*/
|
|
101
|
+
// eslint-disable-next-line no-restricted-syntax -- cuts off by design: it ends the retries of slow attempts rather than waiting them out; see docs/cadre-consistency.md → "Deadlines Over Optimystic's Reads and Commits"
|
|
91
102
|
export const CONTROL_WRITE_RETRY_BUDGET_MS = 10000;
|
|
92
103
|
/**
|
|
93
104
|
* Backoff before retry N, jittered ±50% (so the first sleep is 125–375 ms — the jitter can
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"control-write-retry.js","sourceRoot":"","sources":["../src/control-write-retry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,6BAA6B,EAAE,uBAAuB,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC9G,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AAC3E,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAGtF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAEH;;;;;GAKG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,CAAC;AAExC;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC;AAEtC
|
|
1
|
+
{"version":3,"file":"control-write-retry.js","sourceRoot":"","sources":["../src/control-write-retry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,6BAA6B,EAAE,uBAAuB,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC9G,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AAC3E,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAGtF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAEH;;;;;GAKG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,CAAC;AAExC;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC;AAEtC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,0NAA0N;AAC1N,MAAM,CAAC,MAAM,6BAA6B,GAAG,KA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GAAG,aAAa,CAAC,KAAK,CAAC,CAAC;IACtC,IAAI,0BAA0B,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC1C,OAAO,KAAK,CAAC;IACd,CAAC;IACD,IAAI,KAAK,CAAC,IAAI,CAAC,gBAAgB,CAAC,EAAE,CAAC;QAClC,OAAO,IAAI,CAAC;IACb,CAAC;IACD,OAAO,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AAC7E,CAAC;AAcD;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAuC;IAC3E,QAAQ,EAAE,oBAAoB;IAC9B,QAAQ,EAAE,2BAA2B;IACrC,WAAW,EAAE,4BAA4B;CACzC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,UAAU,iBAAiB,CAChC,OAAyB,EACzB,UAAoC,EAAE;IAEtC,OAAO,qBAAqB,CAAC,OAAO,EAAE;QACrC,QAAQ,EAAE,sBAAsB;QAChC,QAAQ,EAAE,6BAA6B;QACvC,QAAQ,EAAE,6BAA6B;QACvC,WAAW,EAAE,8BAA8B;QAC3C,4EAA4E;QAC5E,mDAAmD;QACnD,SAAS,EAAE,eAAe;KAC1B,EAAE,OAAO,CAAC,CAAC;AACb,CAAC"}
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
* The receiver side is {@link DelegateAdmissionStore}. The announcer side keeps
|
|
36
36
|
* its own throttle state (a "last announced at" map that `CadreNode` owns) and
|
|
37
37
|
* decides from it, per reconcile pass, which relays are due a re-announce —
|
|
38
|
-
* {@link dueRelayAnnounces} and {@link
|
|
38
|
+
* {@link dueRelayAnnounces} and {@link prunePeerStrandKeys} are that
|
|
39
39
|
* decision, pure and testable, kept here beside the TTL they are derived from.
|
|
40
40
|
*/
|
|
41
41
|
/**
|
|
@@ -49,9 +49,10 @@ export declare const MAX_DELEGATE_GRANTS_PER_MEMBER = 32;
|
|
|
49
49
|
/** Cap on live grants in total (soonest-expiry evicted first). */
|
|
50
50
|
export declare const MAX_DELEGATE_GRANTS = 256;
|
|
51
51
|
/**
|
|
52
|
-
* Composite map key for
|
|
53
|
-
*
|
|
54
|
-
* per-(
|
|
52
|
+
* Composite map key for per-(peer, strand) state: the receiver's
|
|
53
|
+
* replace-per-(announcer, strand) grant, the announcer's per-(target, strand)
|
|
54
|
+
* throttle timestamp, and `CadreNode`'s per-(sibling, strand) strand-addr ask
|
|
55
|
+
* due time.
|
|
55
56
|
*/
|
|
56
57
|
export declare function peerStrandKey(peerId: string, strandId: string): string;
|
|
57
58
|
/**
|
|
@@ -121,11 +122,13 @@ export declare function extractCircuitRelayTargets(addrs: string[]): CircuitRela
|
|
|
121
122
|
*/
|
|
122
123
|
export declare function dueRelayAnnounces(announceAt: ReadonlyMap<string, number>, relays: readonly CircuitRelayTarget[], strandId: string, now: number, ttlMs?: number): CircuitRelayTarget[];
|
|
123
124
|
/**
|
|
124
|
-
* Drop
|
|
125
|
-
*
|
|
126
|
-
*
|
|
125
|
+
* Drop the entries of a {@link peerStrandKey}-keyed map whose strand is no longer
|
|
126
|
+
* running, and — when `livePeerIds` is given — whose peer is not among them. A
|
|
127
|
+
* stopped strand needs no refresh, a departed peer is owed a fresh start when it
|
|
128
|
+
* returns, and without this the map grows for the node's lifetime. Mutates in
|
|
129
|
+
* place.
|
|
127
130
|
*/
|
|
128
|
-
export declare function
|
|
131
|
+
export declare function prunePeerStrandKeys(byKey: Map<string, number>, runningStrandIds: ReadonlySet<string>, livePeerIds?: ReadonlySet<string>): void;
|
|
129
132
|
/**
|
|
130
133
|
* The circuit relay named by `addr`, throwing when `addr` is unparsable or names
|
|
131
134
|
* no relay. The throwing form exists for CONFIG-facing callers (`relay-addrs.ts`),
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
* The receiver side is {@link DelegateAdmissionStore}. The announcer side keeps
|
|
36
36
|
* its own throttle state (a "last announced at" map that `CadreNode` owns) and
|
|
37
37
|
* decides from it, per reconcile pass, which relays are due a re-announce —
|
|
38
|
-
* {@link dueRelayAnnounces} and {@link
|
|
38
|
+
* {@link dueRelayAnnounces} and {@link prunePeerStrandKeys} are that
|
|
39
39
|
* decision, pure and testable, kept here beside the TTL they are derived from.
|
|
40
40
|
*/
|
|
41
41
|
import debug from 'debug';
|
|
@@ -53,13 +53,18 @@ export const MAX_DELEGATE_GRANTS_PER_MEMBER = 32;
|
|
|
53
53
|
/** Cap on live grants in total (soonest-expiry evicted first). */
|
|
54
54
|
export const MAX_DELEGATE_GRANTS = 256;
|
|
55
55
|
/**
|
|
56
|
-
* Composite map key for
|
|
57
|
-
*
|
|
58
|
-
* per-(
|
|
56
|
+
* Composite map key for per-(peer, strand) state: the receiver's
|
|
57
|
+
* replace-per-(announcer, strand) grant, the announcer's per-(target, strand)
|
|
58
|
+
* throttle timestamp, and `CadreNode`'s per-(sibling, strand) strand-addr ask
|
|
59
|
+
* due time.
|
|
59
60
|
*/
|
|
60
61
|
export function peerStrandKey(peerId, strandId) {
|
|
61
62
|
return `${peerId}\n${strandId}`;
|
|
62
63
|
}
|
|
64
|
+
/** The `peerId` half of a {@link peerStrandKey} (a peer id never contains a newline). */
|
|
65
|
+
function peerIdOfKey(key) {
|
|
66
|
+
return key.slice(0, key.indexOf('\n'));
|
|
67
|
+
}
|
|
63
68
|
/** The `strandId` half of a {@link peerStrandKey}. */
|
|
64
69
|
function strandIdOfKey(key) {
|
|
65
70
|
return key.slice(key.indexOf('\n') + 1);
|
|
@@ -179,14 +184,17 @@ export function dueRelayAnnounces(announceAt, relays, strandId, now, ttlMs = DEL
|
|
|
179
184
|
return relays.filter((relay) => now - (announceAt.get(peerStrandKey(relay.relayPeerId, strandId)) ?? 0) >= ttlMs / 2);
|
|
180
185
|
}
|
|
181
186
|
/**
|
|
182
|
-
* Drop
|
|
183
|
-
*
|
|
184
|
-
*
|
|
187
|
+
* Drop the entries of a {@link peerStrandKey}-keyed map whose strand is no longer
|
|
188
|
+
* running, and — when `livePeerIds` is given — whose peer is not among them. A
|
|
189
|
+
* stopped strand needs no refresh, a departed peer is owed a fresh start when it
|
|
190
|
+
* returns, and without this the map grows for the node's lifetime. Mutates in
|
|
191
|
+
* place.
|
|
185
192
|
*/
|
|
186
|
-
export function
|
|
187
|
-
for (const key of
|
|
188
|
-
|
|
189
|
-
|
|
193
|
+
export function prunePeerStrandKeys(byKey, runningStrandIds, livePeerIds) {
|
|
194
|
+
for (const key of byKey.keys()) {
|
|
195
|
+
const peerGone = livePeerIds !== undefined && !livePeerIds.has(peerIdOfKey(key));
|
|
196
|
+
if (peerGone || !runningStrandIds.has(strandIdOfKey(key))) {
|
|
197
|
+
byKey.delete(key);
|
|
190
198
|
}
|
|
191
199
|
}
|
|
192
200
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delegate-admission.js","sourceRoot":"","sources":["../src/delegate-admission.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEnD,MAAM,GAAG,GAAG,KAAK,CAAC,iCAAiC,CAAC,CAAC;AAErD;;;;GAIG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAEpD,+EAA+E;AAC/E,MAAM,CAAC,MAAM,8BAA8B,GAAG,EAAE,CAAC;AAEjD,kEAAkE;AAClE,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAG,CAAC;AAcvC
|
|
1
|
+
{"version":3,"file":"delegate-admission.js","sourceRoot":"","sources":["../src/delegate-admission.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;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|
6
|
-
* This is the **canonical** implementation. The web reference app keeps a
|
|
7
|
-
* deliberate, documented duplicate at
|
|
8
|
-
* `packages/reference-app-web/src/lib/connection-path.ts` (it does not depend on
|
|
9
|
-
* `@serfab/cadre-core`). Keep the function signatures and classification table
|
|
10
|
-
* identical across both copies so a future shared micro-package would be a
|
|
11
|
-
* drop-in.
|
|
12
|
-
*
|
|
13
6
|
* The whole signal is a pure function over `node.getConnections()` + a settle
|
|
14
7
|
* window + `Date.now()`. A connection's path is derivable from its `remoteAddr`
|
|
15
8
|
* multiaddr string alone — no I/O, no events, no stateful observer.
|
|
@@ -3,13 +3,6 @@
|
|
|
3
3
|
* (`/p2p-circuit`) vs direct, tag its transport, and summarise counts plus a
|
|
4
4
|
* "stuck on relay" condition.
|
|
5
5
|
*
|
|
6
|
-
* This is the **canonical** implementation. The web reference app keeps a
|
|
7
|
-
* deliberate, documented duplicate at
|
|
8
|
-
* `packages/reference-app-web/src/lib/connection-path.ts` (it does not depend on
|
|
9
|
-
* `@serfab/cadre-core`). Keep the function signatures and classification table
|
|
10
|
-
* identical across both copies so a future shared micro-package would be a
|
|
11
|
-
* drop-in.
|
|
12
|
-
*
|
|
13
6
|
* The whole signal is a pure function over `node.getConnections()` + a settle
|
|
14
7
|
* window + `Date.now()`. A connection's path is derivable from its `remoteAddr`
|
|
15
8
|
* multiaddr string alone — no I/O, no events, no stateful observer.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connection-path.js","sourceRoot":"","sources":["../../src/diagnostics/connection-path.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"connection-path.js","sourceRoot":"","sources":["../../src/diagnostics/connection-path.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AA2DH,MAAM,CAAC,MAAM,wBAAwB,GAAG,KAAM,CAAC;AAE/C,MAAM,cAAc,GAAmC;IACrD,eAAe;IACf,QAAQ;IACR,aAAa;IACb,eAAe;IACf,WAAW;IACX,KAAK;IACL,SA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B,SAAS,EAAE,CAAC,CAAC,SAAS;YACtB,UAAU,EAAE,CAAC,CAAC,UAAU;YACxB,KAAK,EAAE,CAAC,CAAC,KAAK;YACd,YAAY;SACb,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,OAAO;QACL,KAAK,EAAE,IAAI,CAAC,MAAM;QAClB,OAAO;QACP,MAAM;QACN,YAAY,EAAE,UAAU;QACxB,WAAW;QACX,cAAc;QACd,KAAK;QACL,cAAc;KACf,CAAC;AACJ,CAAC;AAED,SAAS,UAAU,CAAC,IAAoB;IACtC,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,UAAU,EAAE,QAAQ,EAAE,EAAE,IAAI,EAAE,CAAC;IAC7C,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC"}
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Abort an unanswered approval request after this long when no `timeoutMs` is supplied.
|
|
3
|
+
* Exported because the formation responder's provisioning budget has to contain it:
|
|
4
|
+
* `formationDeadlines` (`strand-formation-deadlines.ts`) adds it as a flat term, since an HTTP
|
|
5
|
+
* call to the hook does not cross the link between the two parties' machines.
|
|
6
|
+
*/
|
|
7
|
+
export declare const DEFAULT_APPROVAL_TIMEOUT_MS = 10000;
|
|
1
8
|
/**
|
|
2
9
|
* Everything ONE approval is bound to — the five fields inside the approver's signed digest
|
|
3
10
|
* (see `formationVouchMessage`), plus the hook to ask.
|
|
@@ -3,8 +3,14 @@ import { concat as uint8ArrayConcat, fromString as uint8ArrayFromString, toStrin
|
|
|
3
3
|
import { sign, verify } from '@optimystic/quereus-plugin-crypto';
|
|
4
4
|
import { formationVouchMessage } from './control-database.js';
|
|
5
5
|
const log = debug('sereus:cadre:formation-approval');
|
|
6
|
-
/**
|
|
7
|
-
|
|
6
|
+
/**
|
|
7
|
+
* Abort an unanswered approval request after this long when no `timeoutMs` is supplied.
|
|
8
|
+
* Exported because the formation responder's provisioning budget has to contain it:
|
|
9
|
+
* `formationDeadlines` (`strand-formation-deadlines.ts`) adds it as a flat term, since an HTTP
|
|
10
|
+
* call to the hook does not cross the link between the two parties' machines.
|
|
11
|
+
*/
|
|
12
|
+
// eslint-disable-next-line no-restricted-syntax -- link-independent: an outbound HTTP call to the approval hook, not the libp2p link between machines
|
|
13
|
+
export const DEFAULT_APPROVAL_TIMEOUT_MS = 10000;
|
|
8
14
|
/**
|
|
9
15
|
* Largest approval response body this client will read (64 KiB). An approval is two short
|
|
10
16
|
* base64url strings; anything approaching this is a broken or hostile hook, and reading it
|
|
@@ -327,7 +333,7 @@ async function fetchWithinBudget(pending, budget) {
|
|
|
327
333
|
* Cross-platform by construction: global `fetch` + `AbortController` only, no `node:` imports.
|
|
328
334
|
*/
|
|
329
335
|
export function createHttpFormationApprover(options) {
|
|
330
|
-
const timeoutMs = options?.timeoutMs ??
|
|
336
|
+
const timeoutMs = options?.timeoutMs ?? DEFAULT_APPROVAL_TIMEOUT_MS;
|
|
331
337
|
// A non-positive or non-finite budget would abort every request before it left, turning a
|
|
332
338
|
// config typo into a hook that appears permanently down. Fail where the mistake was made.
|
|
333
339
|
if (!Number.isFinite(timeoutMs) || timeoutMs <= 0) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formation-approval.js","sourceRoot":"","sources":["../src/formation-approval.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EACL,MAAM,IAAI,gBAAgB,EAC1B,UAAU,IAAI,oBAAoB,EAClC,QAAQ,IAAI,kBAAkB,EAC/B,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,mCAAmC,CAAC;AACjE,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAE9D,MAAM,GAAG,GAAG,KAAK,CAAC,iCAAiC,CAAC,CAAC;AAErD,
|
|
1
|
+
{"version":3,"file":"formation-approval.js","sourceRoot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C1B,CAAC,EACF,MAAM,CACP,CAAC;gBACF,MAAM,QAAQ,GAAG,MAAM,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;gBAC9D,GAAG,CAAC,wCAAwC,EAAE,MAAM,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;gBACrE,OAAO,QAAQ,CAAC;YAClB,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,sFAAsF;gBACtF,yFAAyF;gBACzF,IAAI,KAAK,YAAY,sBAAsB,EAAE,CAAC;oBAC5C,MAAM,KAAK,CAAC;gBACd,CAAC;gBACD,MAAM,IAAI,sBAAsB,CAC9B,aAAa,EACb,iBAAiB,MAAM,uBAAuB,EAC9C,EAAE,KAAK,EAAE,KAAK,EAAE,CACjB,CAAC;YACJ,CAAC;oBAAS,CAAC;gBACT,MAAM,CAAC,OAAO,EAAE,CAAC;YACnB,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/dist/fs-atomic.d.ts
CHANGED
|
@@ -7,8 +7,17 @@ export declare const FILE_MODE = 384;
|
|
|
7
7
|
* also escapes the unreserved characters `encodeURIComponent` leaves intact but
|
|
8
8
|
* that are unsafe in filenames on some platforms (notably `*` on Windows) — and
|
|
9
9
|
* `.`, so a file suffix appended by the caller is the only literal dot, making
|
|
10
|
-
* suffix-stripping unambiguous
|
|
11
|
-
*
|
|
10
|
+
* suffix-stripping unambiguous — and every uppercase letter, because Windows
|
|
11
|
+
* (NTFS) and macOS (APFS/HFS+ by default) ignore case in file names. Reversed by
|
|
12
|
+
* `decodeURIComponent`.
|
|
13
|
+
*
|
|
14
|
+
* The result contains only `a-z0-9-_` and `%XX` escapes (uppercase hex). Since a
|
|
15
|
+
* literal `%` is itself escaped, every `%` starts an escape, so ignoring case
|
|
16
|
+
* can change only escape hex digits — which decode case-insensitively — and two
|
|
17
|
+
* different inputs never yield names equal ignoring case. The escapes keep
|
|
18
|
+
* `encodeURIComponent`'s uppercase hex so a name built from an id with no
|
|
19
|
+
* capital letters (the identity slot `cadre%2Fidentity.key`, a lowercase party
|
|
20
|
+
* id) is the same as before uppercase letters were escaped.
|
|
12
21
|
*/
|
|
13
22
|
export declare function encodeFileSafeComponent(component: string): string;
|
|
14
23
|
/** Whether an unknown error is a Node "file/dir not found" (ENOENT). */
|
package/dist/fs-atomic.js
CHANGED
|
@@ -18,11 +18,21 @@ export const FILE_MODE = 0o600;
|
|
|
18
18
|
* also escapes the unreserved characters `encodeURIComponent` leaves intact but
|
|
19
19
|
* that are unsafe in filenames on some platforms (notably `*` on Windows) — and
|
|
20
20
|
* `.`, so a file suffix appended by the caller is the only literal dot, making
|
|
21
|
-
* suffix-stripping unambiguous
|
|
22
|
-
*
|
|
21
|
+
* suffix-stripping unambiguous — and every uppercase letter, because Windows
|
|
22
|
+
* (NTFS) and macOS (APFS/HFS+ by default) ignore case in file names. Reversed by
|
|
23
|
+
* `decodeURIComponent`.
|
|
24
|
+
*
|
|
25
|
+
* The result contains only `a-z0-9-_` and `%XX` escapes (uppercase hex). Since a
|
|
26
|
+
* literal `%` is itself escaped, every `%` starts an escape, so ignoring case
|
|
27
|
+
* can change only escape hex digits — which decode case-insensitively — and two
|
|
28
|
+
* different inputs never yield names equal ignoring case. The escapes keep
|
|
29
|
+
* `encodeURIComponent`'s uppercase hex so a name built from an id with no
|
|
30
|
+
* capital letters (the identity slot `cadre%2Fidentity.key`, a lowercase party
|
|
31
|
+
* id) is the same as before uppercase letters were escaped.
|
|
23
32
|
*/
|
|
24
33
|
export function encodeFileSafeComponent(component) {
|
|
25
|
-
|
|
34
|
+
// NOTE: a file left from before uppercase letters were escaped (`trusted-owners.Alice.json`) has, ignoring case, the new name of the all-lowercase id (`alice`), so on Windows/macOS a lookup for that id opens it; the per-party records' envelope party-id check rejects it (cold start), and `FileKeyStore` needs two parties in one key directory whose ids fold to the same lowercase string. The release note says to delete old files; if a store ever reads another id's old file in practice, rename or remove old-format files when the store opens.
|
|
35
|
+
return encodeURIComponent(component).replace(/(%[0-9A-F]{2})|[!'()*~.A-Z]/g, (c, escape) => escape ?? `%${c.charCodeAt(0).toString(16).toUpperCase()}`);
|
|
26
36
|
}
|
|
27
37
|
/** Whether an unknown error is a Node "file/dir not found" (ENOENT). */
|
|
28
38
|
export function isNotFound(error) {
|
package/dist/fs-atomic.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fs-atomic.js","sourceRoot":"","sources":["../src/fs-atomic.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAG3D,MAAM,GAAG,GAAG,KAAK,CAAC,wBAAwB,CAAC,CAAC;AAE5C,6EAA6E;AAC7E,MAAM,CAAC,MAAM,QAAQ,GAAG,KAAK,CAAC;AAC9B,MAAM,CAAC,MAAM,SAAS,GAAG,KAAK,CAAC;AAE/B
|
|
1
|
+
{"version":3,"file":"fs-atomic.js","sourceRoot":"","sources":["../src/fs-atomic.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAG3D,MAAM,GAAG,GAAG,KAAK,CAAC,wBAAwB,CAAC,CAAC;AAE5C,6EAA6E;AAC7E,MAAM,CAAC,MAAM,QAAQ,GAAG,KAAK,CAAC;AAC9B,MAAM,CAAC,MAAM,SAAS,GAAG,KAAK,CAAC;AAE/B;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,uBAAuB,CAAC,SAAiB;IACxD,+hBAA+hB;IAC/hB,OAAO,kBAAkB,CAAC,SAAS,CAAC,CAAC,OAAO,CAC3C,8BAA8B,EAC9B,CAAC,CAAC,EAAE,MAA0B,EAAE,E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,MAAM,iBAAiB,CAAC,GAAG,CAAC,CAAC;AAC9B,CAAC;AAED;;;;;GAKG;AACH,KAAK,UAAU,iBAAiB,CAAC,GAAW;IAC3C,IAAI,SAAiC,CAAC;IACtC,IAAI,CAAC;QACJ,SAAS,GAAG,MAAM,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;QACjC,MAAM,SAAS,CAAC,IAAI,EAAE,CAAC;IACxB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,GAAG,CAAC,oCAAoC,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;IACvD,CAAC;YAAS,CAAC;QACV,MAAM,SAAS,EAAE,KAAK,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;IAC1C,CAAC;AACF,CAAC"}
|
|
@@ -14,9 +14,16 @@ export interface HibernationCallbacks {
|
|
|
14
14
|
* the next (longer-delayed) check-in, so a slow check-in never overlaps the
|
|
15
15
|
* next tick. After it resolves the manager inspects `instance.status`: a
|
|
16
16
|
* strand left non-`hibernating` is treated as woken (backoff resets on the
|
|
17
|
-
* next hibernation); a strand left `hibernating` escalates the backoff.
|
|
17
|
+
* next hibernation); a strand left `hibernating` escalates the backoff. While
|
|
18
|
+
* a wake or probe holds the strand, the chain passes to it instead.
|
|
18
19
|
*/
|
|
19
20
|
onCheckIn: (strandId: string) => Promise<void>;
|
|
21
|
+
/**
|
|
22
|
+
* Whether the strand's runtime is being released right now
|
|
23
|
+
* (`StrandInstanceManager.isQuiescing`): it may still read live, but it is on its way to
|
|
24
|
+
* `hibernating`, so activity on it wakes it as activity on a hibernating strand does.
|
|
25
|
+
*/
|
|
26
|
+
isQuiescing: (strandId: string) => boolean;
|
|
20
27
|
}
|
|
21
28
|
/**
|
|
22
29
|
* Manages strand hibernation state transitions based on activity.
|
|
@@ -45,6 +52,32 @@ export declare class HibernationManager {
|
|
|
45
52
|
* concurrent wake.
|
|
46
53
|
*/
|
|
47
54
|
private readonly wakePromises;
|
|
55
|
+
/**
|
|
56
|
+
* Hibernating strands whose armed check-in a wake cancelled, held until that wake
|
|
57
|
+
* settles. A wake that leaves the strand hibernating again (a failed rebuild, or a probe's
|
|
58
|
+
* window that re-quiesced it) re-arms the chain from here ({@link rearmAfterWake}); without
|
|
59
|
+
* it the strand is left with no runtime and nothing scheduled to retry.
|
|
60
|
+
*/
|
|
61
|
+
private readonly checkInsCancelledByWake;
|
|
62
|
+
/**
|
|
63
|
+
* Strands an on-demand probe (`CadreNode.serviceWake`) holds from its wake to the end of its
|
|
64
|
+
* window, with whether a check-in chain was armed when it began. While held, the probe's end
|
|
65
|
+
* ({@link endProbe}) — not the wake's settle — sets the timers, since the window may
|
|
66
|
+
* re-hibernate the strand after the wake settled.
|
|
67
|
+
*/
|
|
68
|
+
private readonly probes;
|
|
69
|
+
/**
|
|
70
|
+
* Strands whose check-in is running (its timer fired, `onCheckIn` not yet returned). A
|
|
71
|
+
* force-hibernate or untrack removes the strand, so the run's return schedules nothing: a
|
|
72
|
+
* check-in already running is part of the chain those calls cancel.
|
|
73
|
+
*/
|
|
74
|
+
private readonly runningCheckIns;
|
|
75
|
+
/**
|
|
76
|
+
* Strands whose timer-driven hibernate is running (`onHibernate` not yet returned). A
|
|
77
|
+
* force-hibernate, untrack or stop removes the strand, so the return starts no check-in
|
|
78
|
+
* chain: a force-hibernate that joins the quiesce means "keep it down".
|
|
79
|
+
*/
|
|
80
|
+
private readonly timerHibernates;
|
|
48
81
|
private running;
|
|
49
82
|
constructor(config: HibernationConfig, callbacks: HibernationCallbacks);
|
|
50
83
|
/**
|
|
@@ -97,26 +130,69 @@ export declare class HibernationManager {
|
|
|
97
130
|
*/
|
|
98
131
|
recordActivity(instance: StrandInstance): void;
|
|
99
132
|
/**
|
|
100
|
-
* Force
|
|
133
|
+
* Force-wake a strand (an explicit or peer-sent wake). Works whether or not hibernation is
|
|
134
|
+
* enabled; once the wake settles the strand has the timers its resulting state calls for
|
|
135
|
+
* ({@link rearmAfterWake}).
|
|
101
136
|
*/
|
|
102
|
-
wakeStrand(
|
|
137
|
+
wakeStrand(instance: StrandInstance): Promise<void>;
|
|
138
|
+
/**
|
|
139
|
+
* Wake a strand for an on-demand probe (`CadreNode.serviceWake`), holding it until
|
|
140
|
+
* {@link endProbe}: the probe's window runs after the wake settles and may re-hibernate the
|
|
141
|
+
* strand, so the wake's settle arms nothing. Records whether a check-in chain was armed —
|
|
142
|
+
* or already cancelled by a wake this one joins — so the end can restore it.
|
|
143
|
+
*/
|
|
144
|
+
probeWake(instance: StrandInstance): Promise<void>;
|
|
145
|
+
/**
|
|
146
|
+
* End a probe begun by {@link probeWake}, success or failure: arm the timers the strand's
|
|
147
|
+
* state now calls for. A probe never creates a check-in chain, only restores one it
|
|
148
|
+
* interrupted. No-op when the probe is no longer held (a force-hibernate or untrack during
|
|
149
|
+
* it means "keep it down"). A wake that began during the probe's window — activity during
|
|
150
|
+
* its closing quiesce, say — is still rebuilding the strand, so it takes the chain and its
|
|
151
|
+
* settle decides.
|
|
152
|
+
*/
|
|
153
|
+
endProbe(instance: StrandInstance): void;
|
|
103
154
|
/**
|
|
104
155
|
* Begin a wake for a strand, or coalesce with one already in flight. Ensures
|
|
105
156
|
* `onWake` runs at most once per concurrent wake — the returned promise is
|
|
106
157
|
* shared by all overlapping callers and cleared once it settles. Force-wake
|
|
107
|
-
* callers await it; activity-driven callers fire-and-forget.
|
|
158
|
+
* callers await it; activity-driven callers fire-and-forget. Success or failure,
|
|
159
|
+
* the settle re-arms the strand's timers (unless a probe holds it), and a failure
|
|
160
|
+
* then rejects.
|
|
108
161
|
*/
|
|
109
162
|
private beginWake;
|
|
163
|
+
private settleWake;
|
|
164
|
+
/**
|
|
165
|
+
* {@link clearTimers} for a wake, first remembering an armed check-in so a wake that leaves
|
|
166
|
+
* the strand hibernating can restore the chain. Only an ARMED chain is remembered: a strand
|
|
167
|
+
* force-hibernated without one (the mobile background path) must not gain one from a wake,
|
|
168
|
+
* and a check-in that is mid-run hands its chain to the wake when it returns
|
|
169
|
+
* ({@link handCheckInChainToHolder}).
|
|
170
|
+
*/
|
|
171
|
+
private clearTimersForWake;
|
|
172
|
+
/**
|
|
173
|
+
* Leave a strand whose wake (or probe) settled with the timers its state calls for: the idle
|
|
174
|
+
* countdown if it is live, or — if it reads `hibernating` again (a failed rebuild, or a probe
|
|
175
|
+
* window that re-quiesced it) — the check-in chain it had before, at the base delay. A
|
|
176
|
+
* strand that had no chain gains none, and one in any other state gets nothing.
|
|
177
|
+
*/
|
|
178
|
+
private rearmAfterWake;
|
|
110
179
|
private scheduleIdleTransition;
|
|
111
180
|
private handleIdleTimeout;
|
|
112
181
|
private scheduleHibernateTransition;
|
|
113
182
|
private handleHibernateTimeout;
|
|
183
|
+
/**
|
|
184
|
+
* Start the check-in chain of a strand the timer path just hibernated. A wake or probe that
|
|
185
|
+
* landed during the quiesce holds the strand and takes the chain instead
|
|
186
|
+
* ({@link handCheckInChainToHolder}); one that already settled left it live with its idle
|
|
187
|
+
* countdown, and a live strand gets no chain.
|
|
188
|
+
*/
|
|
189
|
+
private startCheckInChain;
|
|
114
190
|
/**
|
|
115
191
|
* Arm the next check-in for a hibernating strand. Each call is a single-shot
|
|
116
192
|
* `setTimeout` (not a fixed `setInterval`) so the period escalates per
|
|
117
193
|
* {@link runCheckIn} and a slow `onCheckIn` never overlaps the next tick.
|
|
118
194
|
*
|
|
119
|
-
* `delay` is omitted by
|
|
195
|
+
* `delay` is omitted by a chain start ({@link startCheckInChain}, or a wake restoring one),
|
|
120
196
|
* defaulting to the base `checkInInterval` — which is why backoff naturally
|
|
121
197
|
* resets to base each fresh hibernation cycle, with no per-strand counter to
|
|
122
198
|
* clear on wake. Subsequent ticks pass the escalated, capped delay.
|
|
@@ -127,15 +203,42 @@ export declare class HibernationManager {
|
|
|
127
203
|
* sync window → re-hibernate-if-idle cycle in `CadreNode`) and AWAIT it before
|
|
128
204
|
* deciding the next step.
|
|
129
205
|
*
|
|
206
|
+
* - If a force-hibernate, untrack or stop cancelled the chain while it ran, stop.
|
|
207
|
+
* - If a wake or probe holds the strand, hand the chain to it
|
|
208
|
+
* ({@link handCheckInChainToHolder}).
|
|
130
209
|
* - If the strand woke during the check-in (`onCheckIn` left it non-
|
|
131
|
-
* `hibernating`), stop the chain
|
|
132
|
-
*
|
|
133
|
-
* base delay (backoff reset).
|
|
210
|
+
* `hibernating`), stop the chain and restart the idle countdown; the next
|
|
211
|
+
* hibernation restarts the chain at the base delay (backoff reset).
|
|
134
212
|
* - Otherwise escalate the delay by `checkInBackoffFactor`, capped at
|
|
135
213
|
* `checkInMaxInterval`, and reschedule.
|
|
136
214
|
*/
|
|
137
215
|
private runCheckIn;
|
|
216
|
+
/**
|
|
217
|
+
* Give a check-in chain — a returning check-in's, or the one the timer path starts
|
|
218
|
+
* ({@link startCheckInChain}) — to a wake or probe that holds the strand, as if that
|
|
219
|
+
* wake had cancelled an armed check-in: its settle ({@link settleWake}) or end
|
|
220
|
+
* ({@link endProbe}) restores the chain at the base delay if the strand ends `hibernating`,
|
|
221
|
+
* and starts the idle countdown if it ends live. The status the check-in left says nothing
|
|
222
|
+
* yet: a check-in that failed before its rebuild leaves the strand to a wake still building
|
|
223
|
+
* it (`starting`), and one that ends `hibernating` may be overtaken by a wake still in
|
|
224
|
+
* flight. Deciding here would drop the chain if that wake then fails, or leave a check-in
|
|
225
|
+
* armed on a strand it brings up.
|
|
226
|
+
*
|
|
227
|
+
* @returns whether a wake or probe took the chain.
|
|
228
|
+
*/
|
|
229
|
+
private handCheckInChainToHolder;
|
|
230
|
+
/**
|
|
231
|
+
* Start the idle countdown for a strand a check-in or wake left live. Activity recorded
|
|
232
|
+
* while the runtime was still rebuilding found the strand neither idle nor active, so it
|
|
233
|
+
* armed nothing — without this the strand would stay up until the next activity. Only for
|
|
234
|
+
* a live status: a strand stopped or failed mid-rebuild must not gain a timer chain. Nor
|
|
235
|
+
* one being quiesced: it reads live until the quiesce ends, e.g. a force-hibernate queued
|
|
236
|
+
* behind the rebuild of the wake settling now, and the countdown would later idle the
|
|
237
|
+
* quiesced strand and start a check-in chain the caller meant to keep off.
|
|
238
|
+
*/
|
|
239
|
+
private rearmIdleIfLive;
|
|
138
240
|
private clearTimer;
|
|
241
|
+
private clearCheckInTimer;
|
|
139
242
|
private clearTimers;
|
|
140
243
|
/**
|
|
141
244
|
* Get the current status of hibernation tracking
|