@serfab/cadre-core 1.17.0 → 1.19.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 +3 -2
- package/dist/cadre-invite-protocol.d.ts +35 -13
- package/dist/cadre-invite-protocol.js +90 -25
- package/dist/cadre-invite-protocol.js.map +1 -1
- package/dist/cadre-node.d.ts +586 -255
- package/dist/cadre-node.js +1182 -566
- package/dist/cadre-node.js.map +1 -1
- package/dist/control-cohort.d.ts +66 -9
- package/dist/control-cohort.js +67 -9
- package/dist/control-cohort.js.map +1 -1
- package/dist/control-database.d.ts +451 -193
- package/dist/control-database.js +701 -359
- package/dist/control-database.js.map +1 -1
- package/dist/control-formation-recorder.d.ts +46 -43
- package/dist/control-formation-recorder.js +77 -78
- package/dist/control-formation-recorder.js.map +1 -1
- package/dist/control-protocol-guard.d.ts +6 -0
- package/dist/control-protocol-guard.js +14 -2
- package/dist/control-protocol-guard.js.map +1 -1
- package/dist/control-schema-version.d.ts +48 -31
- package/dist/control-schema-version.js +67 -45
- package/dist/control-schema-version.js.map +1 -1
- package/dist/control-schema.d.ts +8 -8
- package/dist/control-schema.js +16 -16
- package/dist/control-schema.js.map +1 -1
- package/dist/control-write-retry.d.ts +42 -7
- package/dist/control-write-retry.js +87 -19
- package/dist/control-write-retry.js.map +1 -1
- package/dist/enrolled-machine-store.d.ts +3 -3
- package/dist/enrolled-machine-store.js +3 -3
- package/dist/formation-token.d.ts +48 -0
- package/dist/formation-token.js +26 -0
- package/dist/formation-token.js.map +1 -0
- package/dist/index.d.ts +15 -14
- package/dist/index.js +17 -14
- package/dist/index.js.map +1 -1
- package/dist/joined-strand-store.d.ts +26 -9
- package/dist/joined-strand-store.js +63 -24
- package/dist/joined-strand-store.js.map +1 -1
- package/dist/link-budget.d.ts +9 -7
- package/dist/link-budget.js +9 -7
- package/dist/link-budget.js.map +1 -1
- package/dist/member-redemption.d.ts +15 -9
- package/dist/member-redemption.js +13 -8
- package/dist/member-redemption.js.map +1 -1
- package/dist/membership-view.d.ts +91 -0
- package/dist/membership-view.js +110 -0
- package/dist/membership-view.js.map +1 -0
- package/dist/owner-grant-protocol.d.ts +11 -7
- package/dist/owner-grant-protocol.js +31 -17
- package/dist/owner-grant-protocol.js.map +1 -1
- package/dist/peer-addr-book.d.ts +10 -1
- package/dist/peer-addr-book.js +4 -3
- package/dist/peer-addr-book.js.map +1 -1
- package/dist/peer-join-backfill.d.ts +96 -30
- package/dist/peer-join-backfill.js +272 -128
- package/dist/peer-join-backfill.js.map +1 -1
- package/dist/pending-join-runner.d.ts +48 -18
- package/dist/pending-join-runner.js +74 -56
- package/dist/pending-join-runner.js.map +1 -1
- package/dist/seed-bootstrap.d.ts +47 -40
- package/dist/seed-bootstrap.js +66 -61
- package/dist/seed-bootstrap.js.map +1 -1
- package/dist/self-address-update.d.ts +13 -0
- package/dist/self-address-update.js +19 -0
- package/dist/self-address-update.js.map +1 -0
- package/dist/strand-database.d.ts +23 -2
- package/dist/strand-database.js +26 -6
- package/dist/strand-database.js.map +1 -1
- package/dist/strand-first-sync-gate.d.ts +176 -89
- package/dist/strand-first-sync-gate.js +288 -122
- package/dist/strand-first-sync-gate.js.map +1 -1
- package/dist/strand-formation-deadlines.d.ts +9 -9
- package/dist/strand-formation-deadlines.js +9 -9
- package/dist/strand-formation-manager.d.ts +23 -17
- package/dist/strand-formation-manager.js +46 -44
- package/dist/strand-formation-manager.js.map +1 -1
- package/dist/strand-formation-protocol.d.ts +5 -8
- package/dist/strand-formation-protocol.js +101 -16
- package/dist/strand-formation-protocol.js.map +1 -1
- package/dist/strand-instance-manager.d.ts +26 -17
- package/dist/strand-instance-manager.js +119 -50
- package/dist/strand-instance-manager.js.map +1 -1
- package/dist/strand-membership-reconciler.d.ts +16 -13
- package/dist/strand-membership-reconciler.js +28 -22
- package/dist/strand-membership-reconciler.js.map +1 -1
- package/dist/strand-membership-writer.d.ts +40 -28
- package/dist/strand-membership-writer.js +212 -153
- package/dist/strand-membership-writer.js.map +1 -1
- package/dist/strand-move.js +5 -2
- package/dist/strand-move.js.map +1 -1
- package/dist/strand-revocation-enforcer.d.ts +134 -60
- package/dist/strand-revocation-enforcer.js +144 -71
- package/dist/strand-revocation-enforcer.js.map +1 -1
- package/dist/strand-solicitation.d.ts +50 -39
- package/dist/strand-solicitation.js +10 -3
- package/dist/strand-solicitation.js.map +1 -1
- package/dist/strand-watcher.d.ts +80 -13
- package/dist/strand-watcher.js +152 -48
- package/dist/strand-watcher.js.map +1 -1
- package/dist/table-change-watch.d.ts +63 -0
- package/dist/table-change-watch.js +209 -0
- package/dist/table-change-watch.js.map +1 -0
- package/dist/timeout-scheduler.d.ts +4 -3
- package/dist/timeout-scheduler.js +4 -3
- package/dist/timeout-scheduler.js.map +1 -1
- package/dist/types.d.ts +90 -49
- package/dist/types.js +4 -4
- package/dist/types.js.map +1 -1
- package/package.json +8 -8
- package/src/cadre-invite-protocol.ts +119 -31
- package/src/cadre-node.ts +1289 -588
- package/src/control-cohort.ts +86 -9
- package/src/control-database.ts +848 -403
- package/src/control-formation-recorder.ts +359 -353
- package/src/control-protocol-guard.ts +16 -2
- package/src/control-schema-version.ts +101 -51
- package/src/control-schema.ts +16 -16
- package/src/control-write-retry.ts +91 -19
- package/src/delegate-admission.ts +351 -351
- package/src/enrolled-machine-store.ts +3 -3
- package/src/formation-token.ts +63 -0
- package/src/index.ts +30 -18
- package/src/joined-strand-store.ts +69 -24
- package/src/link-budget.ts +9 -7
- package/src/member-redemption.ts +20 -13
- package/src/membership-view.ts +144 -0
- package/src/owner-grant-protocol.ts +33 -18
- package/src/peer-addr-book.ts +4 -3
- package/src/peer-join-backfill.ts +961 -761
- package/src/pending-join-runner.ts +76 -53
- package/src/seed-bootstrap.ts +72 -67
- package/src/self-address-update.ts +19 -0
- package/src/strand-database.ts +352 -322
- package/src/strand-first-sync-gate.ts +334 -134
- package/src/strand-formation-deadlines.ts +227 -227
- package/src/strand-formation-manager.ts +731 -725
- package/src/strand-formation-protocol.ts +122 -24
- package/src/strand-instance-manager.ts +2092 -2026
- package/src/strand-membership-reconciler.ts +31 -25
- package/src/strand-membership-writer.ts +2093 -2019
- package/src/strand-move.ts +5 -2
- package/src/strand-revocation-enforcer.ts +740 -654
- package/src/strand-solicitation.ts +61 -34
- package/src/strand-watcher.ts +175 -56
- package/src/table-change-watch.ts +285 -0
- package/src/timeout-scheduler.ts +29 -28
- package/src/types.ts +89 -51
package/src/control-cohort.ts
CHANGED
|
@@ -24,17 +24,46 @@
|
|
|
24
24
|
import type { CohortPeerRow } from './strand-cohort.js';
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
|
-
* Default
|
|
28
|
-
*
|
|
29
|
-
*
|
|
27
|
+
* Default backstop for {@link CadreNode.reconcileControlCohort} (ms): a pass runs this long
|
|
28
|
+
* after the last one settled whether or not anything woke it. Passes normally run on a
|
|
29
|
+
* change — a membership table changing, a sibling connecting or disconnecting, an address
|
|
30
|
+
* change — and on the retries a pass arms for itself ({@link nextReconcileWakeMs}); the
|
|
31
|
+
* backstop bounds how stale this node can be after a change it hears nothing of: one that
|
|
32
|
+
* reaches it with no storage event, which happens to a machine outside the block's cohort
|
|
33
|
+
* (a cadre larger than `CONTROL_REPLICATION_BREADTH`) and to one in the cohort that the
|
|
34
|
+
* writer could not reach when it committed. The membership rows view's maximum age
|
|
35
|
+
* (`MEMBERSHIP_VIEW_MAX_AGE_MS`, 15 s) is shorter than this, so the backstop pass reads
|
|
36
|
+
* storage and starts the cohort consult that brings such a change in.
|
|
30
37
|
*
|
|
31
|
-
* An interval between
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
38
|
+
* `network.controlCohort.reconcileMs` overrides it. An interval between a pass settling and
|
|
39
|
+
* the next start, not a deadline on a pass: passes are single-flight, and one unreachable
|
|
40
|
+
* sibling's dial alone can take the whole per-peer dial budget (86 s at the default
|
|
41
|
+
* declared link).
|
|
42
|
+
*
|
|
43
|
+
* NOTE: a machine whose storage takes no event for a change — one outside the block's cohort
|
|
44
|
+
* in a cadre larger than `CONTROL_REPLICATION_BREADTH` (16 machines), or one the writer could
|
|
45
|
+
* not reach when it committed — sees it only at this backstop, where the change-driven path
|
|
46
|
+
* serves a machine the commit reached within the 50 ms coalescing window. If a party ever
|
|
47
|
+
* needs a tighter bound, lower the backstop for its nodes or give the plugin's change bridge
|
|
48
|
+
* a path for outside-the-cohort reads.
|
|
49
|
+
*/
|
|
50
|
+
export const DEFAULT_CONTROL_COHORT_RECONCILE_MS = 120_000;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* First redial delay after a pass's dial of a selected sibling, or a cold-start bootstrap peer,
|
|
54
|
+
* fails (ms). Doubles per consecutive such pass and is capped at the backstop, so a
|
|
55
|
+
* sibling that is offline costs one dial per backstop once the ladder saturates, and a
|
|
56
|
+
* stranded cold-start node keeps trying forever (15 s, 30 s, 60 s, then every backstop).
|
|
36
57
|
*/
|
|
37
|
-
export const
|
|
58
|
+
export const CONTROL_COHORT_REDIAL_MS = 15_000;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* How often an owner retries a node it has just claimed while that node restarts into the
|
|
62
|
+
* owner's party (ms; `CadreNode.claimNode`). A poll step, not a deadline: the retries run for
|
|
63
|
+
* {@link CONTROL_COHORT_REDIAL_MS} after the node accepts the claim, the delay of the reconcile
|
|
64
|
+
* pass's first redial, which would otherwise be the owner's next dial of the node.
|
|
65
|
+
*/
|
|
66
|
+
export const CLAIM_RESTART_REDIAL_STEP_MS = 1_000;
|
|
38
67
|
|
|
39
68
|
/**
|
|
40
69
|
* Default cap on the number of **non-backbone** members a single reconcile pass
|
|
@@ -125,3 +154,51 @@ export function selectControlCohortDials(
|
|
|
125
154
|
cappedNonBackbone: rest.length - fill.length,
|
|
126
155
|
};
|
|
127
156
|
}
|
|
157
|
+
|
|
158
|
+
/** What {@link nextReconcileWakeMs} decides from, all times epoch milliseconds. */
|
|
159
|
+
export interface ReconcileWakeInput {
|
|
160
|
+
/**
|
|
161
|
+
* Consecutive passes, this one included, whose dial of a selected sibling or a cold-start
|
|
162
|
+
* bootstrap peer failed; 0 when none of this pass's dials did.
|
|
163
|
+
*/
|
|
164
|
+
redialStreak: number;
|
|
165
|
+
/** When the pass that just ended began. */
|
|
166
|
+
passStartedAt: number;
|
|
167
|
+
/** Every (sibling, strand) strand-address due time this node holds. */
|
|
168
|
+
strandAddrDueAt: Iterable<number>;
|
|
169
|
+
now: number;
|
|
170
|
+
/** The scheduler's backstop (ms); no wake is later than it. */
|
|
171
|
+
backstopMs: number;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* How long after a pass the next one should run for the pass's own reasons, or `undefined`
|
|
176
|
+
* when the backstop covers everything:
|
|
177
|
+
*
|
|
178
|
+
* - **Redial.** A streak of unconnected passes wakes after
|
|
179
|
+
* `min(CONTROL_COHORT_REDIAL_MS × 2^(streak − 1), backstop)`.
|
|
180
|
+
* - **Strand addresses.** The earliest strand-address due time LATER THAN the pass's start,
|
|
181
|
+
* when it is sooner than the backstop, wakes when it falls due (now at the latest). A due
|
|
182
|
+
* time at or before the start belongs to a (sibling, strand) the pass skipped for another
|
|
183
|
+
* reason — the strand stopped, the sibling disconnected — and waking for it would spin; the
|
|
184
|
+
* strand watcher's launch retry keeps the same rule.
|
|
185
|
+
*
|
|
186
|
+
* The smaller wins.
|
|
187
|
+
*/
|
|
188
|
+
export function nextReconcileWakeMs(input: ReconcileWakeInput): number | undefined {
|
|
189
|
+
const { redialStreak, passStartedAt, strandAddrDueAt, now, backstopMs } = input;
|
|
190
|
+
let wake: number | undefined;
|
|
191
|
+
if (redialStreak > 0) {
|
|
192
|
+
wake = Math.min(CONTROL_COHORT_REDIAL_MS * 2 ** (redialStreak - 1), backstopMs);
|
|
193
|
+
}
|
|
194
|
+
for (const dueAt of strandAddrDueAt) {
|
|
195
|
+
if (dueAt <= passStartedAt) {
|
|
196
|
+
continue;
|
|
197
|
+
}
|
|
198
|
+
const delay = Math.max(0, dueAt - now);
|
|
199
|
+
if (delay < backstopMs && (wake === undefined || delay < wake)) {
|
|
200
|
+
wake = delay;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
return wake;
|
|
204
|
+
}
|