@serfab/cadre-core 1.17.0 → 1.18.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 +1176 -564
- 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 +14 -13
- package/dist/index.js +16 -13
- 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 +89 -20
- package/dist/peer-join-backfill.js +265 -108
- 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/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 +30 -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 +1282 -584
- 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 -17
- 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 +971 -761
- package/src/pending-join-runner.ts +76 -53
- package/src/seed-bootstrap.ts +72 -67
- 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 +33 -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
|
@@ -21,8 +21,7 @@
|
|
|
21
21
|
* - **Retries fast while the join is unfinished, slowly while it is only waiting.** A pass
|
|
22
22
|
* that leaves the join unfinished re-arms on a ladder starting at
|
|
23
23
|
* {@link INITIAL_JOIN_RETRY_INTERVAL_MS} and doubling, capped at the configured poll
|
|
24
|
-
* interval (default {@link
|
|
25
|
-
* `revocationEnforcement.pollIntervalMs` is mirrored here by the instance manager). A pass
|
|
24
|
+
* interval (default {@link DEFAULT_MEMBERSHIP_RECONCILE_INTERVAL_MS}). A pass
|
|
26
25
|
* that finds no member row AND no staged invitation is not an unfinished join but a wait
|
|
27
26
|
* for someone to admit this party — nothing this machine can do faster — so it re-arms on
|
|
28
27
|
* the flat poll interval and resets the ladder. The loop stops on the done state.
|
|
@@ -152,11 +151,17 @@ import {
|
|
|
152
151
|
registerMemberPeer,
|
|
153
152
|
type StrandWriteOptions,
|
|
154
153
|
} from './strand-membership-writer.js';
|
|
155
|
-
import { DEFAULT_REVOCATION_POLL_INTERVAL_MS } from './strand-revocation-enforcer.js';
|
|
156
154
|
import { defaultTimeoutScheduler, type TimeoutScheduler } from './timeout-scheduler.js';
|
|
157
155
|
|
|
158
156
|
const log = debug('sereus:cadre:strand-membership-reconciler');
|
|
159
157
|
|
|
158
|
+
/**
|
|
159
|
+
* Default poll interval, ms: the loop's idle cadence while nobody has admitted this party, and
|
|
160
|
+
* the cap of its unfinished-join retry ladder. The loop stops once joined, so this matters only
|
|
161
|
+
* while a machine is joining.
|
|
162
|
+
*/
|
|
163
|
+
export const DEFAULT_MEMBERSHIP_RECONCILE_INTERVAL_MS = 30_000;
|
|
164
|
+
|
|
160
165
|
/**
|
|
161
166
|
* Idle passes (no member row, no staged invitation) before ONE `console.warn`
|
|
162
167
|
* escalation — at the default 30 s cadence, about five minutes of waiting. The loop
|
|
@@ -182,9 +187,8 @@ export const UNFINISHED_PASSES_BEFORE_ESCALATION = 10;
|
|
|
182
187
|
* unwritable, a database not yet published. Doubles per such pass up to the configured
|
|
183
188
|
* poll interval. Sized for what it retries: invite-row replication resolves in about a
|
|
184
189
|
* second over a direct connection and a few over a relay. The poll interval is NOT sized
|
|
185
|
-
* for that — it is the
|
|
186
|
-
*
|
|
187
|
-
* of a shorter interval.
|
|
190
|
+
* for that — it is sized for the idle case (waiting to be admitted at all), which is why
|
|
191
|
+
* this ladder exists instead of a shorter interval.
|
|
188
192
|
*/
|
|
189
193
|
export const INITIAL_JOIN_RETRY_INTERVAL_MS = 1_000;
|
|
190
194
|
|
|
@@ -366,19 +370,18 @@ export interface StrandMembershipReconciliationConfig {
|
|
|
366
370
|
enabled?: boolean;
|
|
367
371
|
/**
|
|
368
372
|
* Idle cadence, ms — how often the loop re-checks while nobody has admitted this party
|
|
369
|
-
* yet — and the CAP of the unfinished-join retry ladder.
|
|
370
|
-
*
|
|
371
|
-
* {@link DEFAULT_REVOCATION_POLL_INTERVAL_MS}.
|
|
373
|
+
* yet — and the CAP of the unfinished-join retry ladder. Default
|
|
374
|
+
* {@link DEFAULT_MEMBERSHIP_RECONCILE_INTERVAL_MS}.
|
|
372
375
|
*/
|
|
373
376
|
pollIntervalMs?: number;
|
|
374
377
|
}
|
|
375
378
|
|
|
376
379
|
/**
|
|
377
|
-
* The per-strand membership reconciliation loop.
|
|
378
|
-
* `
|
|
379
|
-
*
|
|
380
|
-
*
|
|
381
|
-
*
|
|
380
|
+
* The per-strand membership reconciliation loop. Created in
|
|
381
|
+
* `StrandInstanceManager.buildStrandRuntime` (closed strands with a party key only),
|
|
382
|
+
* started right after the strand database initializes, stopped and dropped in
|
|
383
|
+
* `releaseRuntime` — so quiesce → resume rebuilds it and re-runs the (idempotent) ladder
|
|
384
|
+
* from scratch.
|
|
382
385
|
*/
|
|
383
386
|
export class StrandMembershipReconciler {
|
|
384
387
|
private readonly scheduler: TimeoutScheduler;
|
|
@@ -423,7 +426,7 @@ export class StrandMembershipReconciler {
|
|
|
423
426
|
config?: StrandMembershipReconciliationConfig
|
|
424
427
|
) {
|
|
425
428
|
this.scheduler = deps.scheduler ?? defaultTimeoutScheduler;
|
|
426
|
-
this.pollIntervalMs = config?.pollIntervalMs ??
|
|
429
|
+
this.pollIntervalMs = config?.pollIntervalMs ?? DEFAULT_MEMBERSHIP_RECONCILE_INTERVAL_MS;
|
|
427
430
|
}
|
|
428
431
|
|
|
429
432
|
/**
|
|
@@ -573,16 +576,21 @@ export class StrandMembershipReconciler {
|
|
|
573
576
|
private async attempt(db: Database, keyPair: Ed25519KeyPair): Promise<void> {
|
|
574
577
|
try {
|
|
575
578
|
if (!(await this.ensureMembership(db, keyPair))) return;
|
|
576
|
-
// NOTE: the redemption (`Member` + `ConsumedInvite`) and the binding
|
|
577
|
-
// SEPARATE commits
|
|
578
|
-
//
|
|
579
|
-
//
|
|
580
|
-
//
|
|
581
|
-
//
|
|
582
|
-
//
|
|
583
|
-
//
|
|
584
|
-
//
|
|
585
|
-
//
|
|
579
|
+
// NOTE: accepted tradeoff — the redemption (`Member` + `ConsumedInvite`) and the binding
|
|
580
|
+
// below stay two SEPARATE commits on purpose. One transaction would save no `/cluster`
|
|
581
|
+
// requests: Optimystic pends and commits each collection on its own, about 4 requests per
|
|
582
|
+
// collection (`blocked/optimystic-multi-collection-commit-costs-four-requests-per-collection`),
|
|
583
|
+
// and both commits already span several collections (each table plus its UNIQUE trees),
|
|
584
|
+
// so merging saves only one commit's serial latency. It would also let a torn commit
|
|
585
|
+
// (Optimystic can report a multi-collection commit partly saved) or the cohort applying
|
|
586
|
+
// the collections out of order show this machine's `MemberPeer` without its `Member`,
|
|
587
|
+
// which the revocation enforcer reads as a removed member and hangs up on — fail closed,
|
|
588
|
+
// undone only by a manager clearing the binding (module doc of
|
|
589
|
+
// `strand-revocation-enforcer.ts`). And it would add a half-committed shape (`MemberPeer`
|
|
590
|
+
// saved, the invitation still live) that {@link reportHalfCommittedJoin}'s dropping of the
|
|
591
|
+
// invitation gets wrong. Revisit when Optimystic offers an all-or-nothing multi-collection
|
|
592
|
+
// commit, or when its per-coordinator batching lands and the enforcer can tell a
|
|
593
|
+
// not-yet-seated binding from a removed member's.
|
|
586
594
|
await this.ensureBinding(db, keyPair);
|
|
587
595
|
} finally {
|
|
588
596
|
this.noteAttemptOutcome();
|