@serfab/cadre-core 1.21.0 → 1.23.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 +294 -294
- package/dist/cadre-node.d.ts +334 -53
- package/dist/cadre-node.js +794 -85
- package/dist/cadre-node.js.map +1 -1
- package/dist/control-authorization.d.ts +32 -2
- package/dist/control-authorization.js +19 -0
- package/dist/control-authorization.js.map +1 -1
- package/dist/control-database.d.ts +236 -23
- package/dist/control-database.js +587 -173
- package/dist/control-database.js.map +1 -1
- package/dist/control-schema.d.ts +3 -3
- package/dist/control-schema.js +71 -7
- package/dist/control-schema.js.map +1 -1
- package/dist/ed25519-key.d.ts +8 -0
- package/dist/ed25519-key.js +11 -1
- package/dist/ed25519-key.js.map +1 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +13 -1
- package/dist/index.js.map +1 -1
- package/dist/machine-removal.d.ts +51 -1
- package/dist/machine-removal.js +42 -1
- package/dist/machine-removal.js.map +1 -1
- package/dist/membership-connection-gater.d.ts +8 -0
- package/dist/membership-connection-gater.js +13 -1
- package/dist/membership-connection-gater.js.map +1 -1
- package/dist/membership-view.js +4 -1
- package/dist/membership-view.js.map +1 -1
- package/dist/owner-keys.js +2 -1
- package/dist/owner-keys.js.map +1 -1
- package/dist/owner-signer.js +3 -4
- package/dist/owner-signer.js.map +1 -1
- package/dist/peer-authorization.d.ts +14 -2
- package/dist/peer-authorization.js +24 -1
- package/dist/peer-authorization.js.map +1 -1
- package/dist/sealed-party-key.d.ts +32 -0
- package/dist/sealed-party-key.js +162 -0
- package/dist/sealed-party-key.js.map +1 -0
- package/dist/seed-bootstrap.d.ts +10 -3
- package/dist/seed-bootstrap.js +12 -0
- package/dist/seed-bootstrap.js.map +1 -1
- package/dist/strand-addr-protocol.d.ts +56 -6
- package/dist/strand-addr-protocol.js +57 -5
- package/dist/strand-addr-protocol.js.map +1 -1
- package/dist/strand-commit-durability.d.ts +33 -2
- package/dist/strand-commit-durability.js +44 -4
- package/dist/strand-commit-durability.js.map +1 -1
- package/dist/strand-database.d.ts +35 -5
- package/dist/strand-database.js +34 -10
- package/dist/strand-database.js.map +1 -1
- package/dist/strand-instance-manager.d.ts +200 -18
- package/dist/strand-instance-manager.js +434 -64
- package/dist/strand-instance-manager.js.map +1 -1
- package/dist/strand-membership-reconciler.d.ts +250 -51
- package/dist/strand-membership-reconciler.js +410 -66
- package/dist/strand-membership-reconciler.js.map +1 -1
- package/dist/strand-membership-writer.d.ts +7 -0
- package/dist/strand-membership-writer.js +9 -0
- package/dist/strand-membership-writer.js.map +1 -1
- package/dist/strand-party-key-rotation.d.ts +177 -0
- package/dist/strand-party-key-rotation.js +340 -0
- package/dist/strand-party-key-rotation.js.map +1 -0
- package/dist/strand-party-machines.d.ts +111 -0
- package/dist/strand-party-machines.js +258 -0
- package/dist/strand-party-machines.js.map +1 -0
- package/dist/strand-party-peers.d.ts +101 -0
- package/dist/strand-party-peers.js +49 -0
- package/dist/strand-party-peers.js.map +1 -0
- package/dist/strand-peer-redial.d.ts +34 -7
- package/dist/strand-peer-redial.js +46 -13
- package/dist/strand-peer-redial.js.map +1 -1
- package/dist/strand-revocation-enforcer.d.ts +15 -1
- package/dist/strand-revocation-enforcer.js +16 -9
- package/dist/strand-revocation-enforcer.js.map +1 -1
- package/dist/strand-transport-key.js +3 -0
- package/dist/strand-transport-key.js.map +1 -1
- package/dist/strand-watcher.d.ts +7 -4
- package/dist/strand-watcher.js +12 -7
- package/dist/strand-watcher.js.map +1 -1
- package/dist/types.d.ts +169 -13
- package/dist/types.js.map +1 -1
- package/package.json +9 -8
- package/src/cadre-node.ts +12280 -11528
- package/src/control-authorization.ts +41 -1
- package/src/control-database.ts +6123 -5603
- package/src/control-schema.ts +71 -7
- package/src/ed25519-key.ts +12 -1
- package/src/index.ts +957 -924
- package/src/machine-removal.ts +80 -1
- package/src/membership-connection-gater.ts +13 -1
- package/src/membership-view.ts +4 -1
- package/src/owner-keys.ts +2 -1
- package/src/owner-signer.ts +92 -94
- package/src/peer-authorization.ts +27 -3
- package/src/sealed-party-key.ts +190 -0
- package/src/seed-bootstrap.ts +17 -3
- package/src/strand-addr-protocol.ts +67 -6
- package/src/strand-commit-durability.ts +54 -5
- package/src/strand-database.ts +47 -11
- package/src/strand-instance-manager.ts +524 -65
- package/src/strand-membership-reconciler.ts +1310 -942
- package/src/strand-membership-writer.ts +10 -0
- package/src/strand-party-key-rotation.ts +436 -0
- package/src/strand-party-machines.ts +293 -0
- package/src/strand-party-peers.ts +129 -0
- package/src/strand-peer-redial.ts +61 -14
- package/src/strand-revocation-enforcer.ts +27 -9
- package/src/strand-transport-key.ts +3 -0
- package/src/strand-watcher.ts +12 -7
- package/src/types.ts +3121 -2963
|
@@ -6,6 +6,7 @@ import { type PeerJoinBackfillConfig } from './peer-join-backfill.js';
|
|
|
6
6
|
import { type StrandNetworkStateStore } from './strand-network-state.js';
|
|
7
7
|
import { type StrandRevocationEnforcementConfig } from './strand-revocation-enforcer.js';
|
|
8
8
|
import { type PendingMembershipInviteSource, type StrandMembershipReconciliationConfig } from './strand-membership-reconciler.js';
|
|
9
|
+
import type { PartyStrandPeer, PartyStrandPeerSource } from './strand-party-peers.js';
|
|
9
10
|
import { type StrandFirstSyncConfig } from './strand-first-sync-gate.js';
|
|
10
11
|
import type { StrandInstance, StrandRow, StorageConfig, NetworkConfig, LatencyHint, NodeProfile, SAppConfig } from './types.js';
|
|
11
12
|
import { type StrandReactivityConfig } from './strand-reactivity.js';
|
|
@@ -178,6 +179,39 @@ export interface StartStrandConfig {
|
|
|
178
179
|
* default `DEFAULT_MEMBERSHIP_RECONCILE_INTERVAL_MS`.
|
|
179
180
|
*/
|
|
180
181
|
membershipReconciliation?: StrandMembershipReconciliationConfig;
|
|
182
|
+
/**
|
|
183
|
+
* The party's machines in THIS strand, as the control database records them
|
|
184
|
+
* (`strand-party-peers.ts`): `CadreNode.launchStrand` wires it for every strand, open or
|
|
185
|
+
* closed, party key or not. Bring-up publishes this machine's own `StrandPeer` row through it
|
|
186
|
+
* in the background, once the strand's libp2p node exists (launch and hibernation resume
|
|
187
|
+
* alike, since the row is this machine's statement of a peer id that is the same across
|
|
188
|
+
* both). On a closed strand the membership reconciler reads the party's other machines
|
|
189
|
+
* through it to bind them (`strand-membership-reconciler.ts` → "Binding the party's other
|
|
190
|
+
* machines"); on a node offering offline mode ({@link offline}) the queue's gate reads them
|
|
191
|
+
* as the machines a queued transaction waits for (`strand-party-machines.ts`). An open
|
|
192
|
+
* strand's row serves only that wait. Retained with the launch config.
|
|
193
|
+
*/
|
|
194
|
+
partyPeers?: PartyStrandPeerSource;
|
|
195
|
+
/**
|
|
196
|
+
* Called when the membership reconciler finds the party's PENDING membership key seated as a
|
|
197
|
+
* `Strand.Member` in this strand (`strand-membership-reconciler.ts` → "Redeeming under the
|
|
198
|
+
* pending key"): it redeemed the host's fresh invitation under that key, or another party's
|
|
199
|
+
* manager admitted the key by hand. `CadreNode` wires it to its party key rotation driver,
|
|
200
|
+
* which then finishes the move on an owner machine the key is sealed to
|
|
201
|
+
* (`strand-party-key-rotation.ts`). Called on every pass that sees the seat until the control
|
|
202
|
+
* record is swapped, so the receiver refuses cheaply when it cannot drive. Retained with the
|
|
203
|
+
* launch config.
|
|
204
|
+
*/
|
|
205
|
+
onPartyKeySeated?: (strandId: string) => void;
|
|
206
|
+
/**
|
|
207
|
+
* Called when a read of the party's machines finds one removed from the cadre in
|
|
208
|
+
* {@link bootstrapNodes}, on a node tracking them ({@link offline} with {@link partyPeers}), and
|
|
209
|
+
* once per such machine ({@link watchRemovedMachinesInSeed}). The node refuses that peer but
|
|
210
|
+
* cannot drop it from its frozen seed, so its queue stays held until a new node is built from a
|
|
211
|
+
* fresh seed: `CadreNode` quiesces and resumes the runtime. May be called during a build or a
|
|
212
|
+
* rebuild, so the receiver serializes. Retained with the launch config.
|
|
213
|
+
*/
|
|
214
|
+
onRemovedMachineInSeed?: (strandId: string) => void;
|
|
181
215
|
/**
|
|
182
216
|
* Called when THIS node's own peer id turns up in the strand's revoked set —
|
|
183
217
|
* this node's party was removed from the closed strand, or left it. Fires once
|
|
@@ -288,6 +322,12 @@ export interface ResumeStrandOverrides {
|
|
|
288
322
|
* {@link StartStrandConfig} does — it retains the last value; see `resumeStrand`.
|
|
289
323
|
*/
|
|
290
324
|
servingMachines?: number;
|
|
325
|
+
/**
|
|
326
|
+
* The party's membership key for a closed strand as the control record names it now
|
|
327
|
+
* (`StrandPartyKey.PrivateKey`), re-read by `CadreNode.resumeStrandRuntime` because a party
|
|
328
|
+
* key rotation can finish while the strand hibernates. Omitted, the retained key stands.
|
|
329
|
+
*/
|
|
330
|
+
partyMemberPrivateKey?: string;
|
|
291
331
|
}
|
|
292
332
|
/**
|
|
293
333
|
* Get the isolated storage path for a specific strand.
|
|
@@ -379,6 +419,21 @@ export declare class StrandInstanceManager {
|
|
|
379
419
|
* nobody and a resume redials over the new node.
|
|
380
420
|
*/
|
|
381
421
|
private peerRedials;
|
|
422
|
+
/**
|
|
423
|
+
* The party's other machines known to hold each strand (`strand-party-machines.ts`), keyed
|
|
424
|
+
* by strand id, on a node offering offline mode for a launch with a party-machine seam. Same
|
|
425
|
+
* lifecycle as {@link peerRedials}: built in `buildStrandRuntime` before the libp2p node (the
|
|
426
|
+
* node's redial loop, the database's offline gate and its commit record read it), stopped and dropped in
|
|
427
|
+
* `releaseRuntime`, so a resume reads the control database afresh. Refreshed by
|
|
428
|
+
* {@link notifyPartyPeersChanged}.
|
|
429
|
+
*/
|
|
430
|
+
private partyMachines;
|
|
431
|
+
/**
|
|
432
|
+
* Per strand, the removed machines' peer ids a rebuild was asked for
|
|
433
|
+
* ({@link watchRemovedMachinesInSeed}). Outlives a runtime, which is its point: it is what stops
|
|
434
|
+
* a rebuilt node whose seed still names one from asking again. Dropped with the launch config.
|
|
435
|
+
*/
|
|
436
|
+
private seedRemovalsAnnounced;
|
|
382
437
|
/**
|
|
383
438
|
* The resolved (cache-wrapped) raw storage per strand id — the instance's OWN
|
|
384
439
|
* store, resolved once in `startStrand` and held until `stopStrand` disposes it.
|
|
@@ -423,6 +478,14 @@ export declare class StrandInstanceManager {
|
|
|
423
478
|
* {@link releaseRuntime}, so a stop or a quiesce cancels it.
|
|
424
479
|
*/
|
|
425
480
|
private unreachableJoinRetries;
|
|
481
|
+
/**
|
|
482
|
+
* Per strand id, the sApp claim ({@link attachSApp}) whose schema the retained launch config
|
|
483
|
+
* carries but no apply has landed yet: the claim found no live database, or its live apply failed
|
|
484
|
+
* for a reason that may pass. Lets a build that refuses that schema fall back to the replica
|
|
485
|
+
* ({@link revertRefusedAttach}). Deleted when a database applies the schema, by that fallback,
|
|
486
|
+
* and when {@link stopStrand} begins.
|
|
487
|
+
*/
|
|
488
|
+
private unappliedAttaches;
|
|
426
489
|
/**
|
|
427
490
|
* The offline mode set per strand id ({@link setOfflineMode}); a strand absent here runs in its
|
|
428
491
|
* launch's `initialMode`. Never cleared: the mode belongs to the strand, not to one database, so
|
|
@@ -509,10 +572,27 @@ export declare class StrandInstanceManager {
|
|
|
509
572
|
private buildStrandDatabase;
|
|
510
573
|
/**
|
|
511
574
|
* One build's {@link StrandDatabaseOffline}: the strand's journal, which the database resolves as
|
|
512
|
-
* it initializes (a throw or rejection fails the build),
|
|
513
|
-
* time it applies it.
|
|
575
|
+
* it initializes (a throw or rejection fails the build), the strand's mode, which it reads each
|
|
576
|
+
* time it applies it, and the gate its queue asks, when one could be built.
|
|
514
577
|
*/
|
|
515
578
|
private offlineDatabaseConfig;
|
|
579
|
+
/**
|
|
580
|
+
* The gate a build's offline queue asks: the node's own, closed also while the party has
|
|
581
|
+
* machines holding the strand that this node is alone in a cohort without
|
|
582
|
+
* (`cohortGateWaitingForMachines`). None when the launch tracks no party machines (no offline
|
|
583
|
+
* mode, or no party-machine seam), or when the node carries no gate or key network to compose
|
|
584
|
+
* over; the queue then asks the node's own gate, as before.
|
|
585
|
+
*/
|
|
586
|
+
private offlineCohortGate;
|
|
587
|
+
/** Ask the launcher for a rebuild when a machine removed from the party is in this runtime's seed. */
|
|
588
|
+
private watchSeedForRemovedMachines;
|
|
589
|
+
/**
|
|
590
|
+
* The party's other machines known to hold `strandId` with no open connection from its strand
|
|
591
|
+
* node: what an offline queue reporting `waitingFor: 'cohort'` may be waiting for
|
|
592
|
+
* (`docs/strands.md` → "Waiting for the party's own machines"). Empty for a strand not tracked
|
|
593
|
+
* or not running here, and on a launch that tracks no party machines.
|
|
594
|
+
*/
|
|
595
|
+
unreachedPartyMachines(strandId: string): readonly PartyStrandPeer[];
|
|
516
596
|
/**
|
|
517
597
|
* Whether this strand's raw store holds no block. False for a store that cannot list its
|
|
518
598
|
* blocks, or whose listing fails, so such a launch probes at once.
|
|
@@ -546,9 +626,17 @@ export declare class StrandInstanceManager {
|
|
|
546
626
|
* runtime still attached. Skipped when the strand was stopped or released since — a quiesce
|
|
547
627
|
* releases it and the resume after rebuilds the whole runtime — or already has a database.
|
|
548
628
|
* A failure other than an unanswered seed releases the runtime and marks the strand
|
|
549
|
-
* `'error'`, as a failed resume does
|
|
629
|
+
* `'error'`, as a failed resume does, unless it is a refusal of a claim's schema the replica
|
|
630
|
+
* can fall back from ({@link buildJoinDatabaseOrReplica}).
|
|
550
631
|
*/
|
|
551
632
|
private retryUnreachableJoin;
|
|
633
|
+
/**
|
|
634
|
+
* A deferred join's database phase ({@link buildStrandDatabase}), run once more as the replica
|
|
635
|
+
* when it fails on the schema of a claim that has not applied yet ({@link revertRefusedAttach}).
|
|
636
|
+
* The failed attempt's database is closed first: a failure leaves it registered with its gate.
|
|
637
|
+
* `'released'` when a stop began while it closed.
|
|
638
|
+
*/
|
|
639
|
+
private buildJoinDatabaseOrReplica;
|
|
552
640
|
/** Whether `instance` is still tracked, with `node` still its runtime's libp2p node. */
|
|
553
641
|
private isCurrentRuntime;
|
|
554
642
|
/**
|
|
@@ -626,6 +714,55 @@ export declare class StrandInstanceManager {
|
|
|
626
714
|
* loop's own serialized chain and never rejects.
|
|
627
715
|
*/
|
|
628
716
|
notifyMembershipInviteStaged(strandId: string): void;
|
|
717
|
+
/**
|
|
718
|
+
* The party's machines changed in the control database — a `StrandPeer` row, a `CadrePeer`
|
|
719
|
+
* row or a tombstone arrived or was written here (`CadreNode`'s watch on those tables,
|
|
720
|
+
* coalesced). Re-arm every armed membership reconciler, so a sibling's row is bound, or a
|
|
721
|
+
* removed machine's binding cleared, within the watch's window rather than at the next
|
|
722
|
+
* resume, and read every strand's party machines again, so an offline queue waits for a
|
|
723
|
+
* machine as soon as its row arrives and stops waiting for one as soon as it is removed.
|
|
724
|
+
* Table events carry no row keys, so every strand's loop and tracker is woken; a loop with
|
|
725
|
+
* nothing to do confirms and stops again. Returns at once; each pass runs on its loop's own
|
|
726
|
+
* serialized chain and never rejects.
|
|
727
|
+
*/
|
|
728
|
+
notifyPartyPeersChanged(): void;
|
|
729
|
+
/** Re-arm `strandId`'s membership reconciler for `cause`; `false` when none is armed. */
|
|
730
|
+
private rearmMembershipReconciler;
|
|
731
|
+
/**
|
|
732
|
+
* Build and start `instance`'s membership reconciler from `config`, for a closed strand that
|
|
733
|
+
* carries the party's own membership key with the loop enabled; nothing otherwise. Called by
|
|
734
|
+
* {@link buildStrandRuntime} after the database phase, and by {@link rekeyParty} over a
|
|
735
|
+
* running instance with the re-keyed config. Every dependency is read per pass, never
|
|
736
|
+
* captured, so the loop follows the instance through quiesce and resume.
|
|
737
|
+
*/
|
|
738
|
+
private armMembershipReconciler;
|
|
739
|
+
/**
|
|
740
|
+
* Move a tracked closed strand onto `partyMemberPrivateKey`, the party's membership key the
|
|
741
|
+
* control record now names (a party key rotation finished here or replicated from the machine
|
|
742
|
+
* that finished it: `strand-party-key-rotation.ts`). The retained launch config is replaced
|
|
743
|
+
* with a fresh object carrying the key ({@link foundExistingStrand}'s idiom: the caller's
|
|
744
|
+
* config object is not ours to rewrite), so every later resume rebuilds under it, and the
|
|
745
|
+
* founder bootstrap a resume re-runs derives from it (insert-if-absent; the strand's rows
|
|
746
|
+
* already hold the new key as member and manager, so it writes nothing). The running
|
|
747
|
+
* instance's membership reconciler, which signs with the key, is stopped and awaited, then
|
|
748
|
+
* rebuilt and started over the re-keyed config, so its next pass binds under the new key.
|
|
749
|
+
*
|
|
750
|
+
* A tracked instance with no party key before (a storage replica launched before the party's
|
|
751
|
+
* row reached this node) is keyed the same way and gains its reconciler now rather than at its
|
|
752
|
+
* next resume. A build in flight is waited out first, so the reconciler it arms is the one
|
|
753
|
+
* replaced here rather than a second one beside it; a key the retained config already names
|
|
754
|
+
* is answered before that wait, since the party key watch asks this for every tracked closed
|
|
755
|
+
* strand on every change to the key tables.
|
|
756
|
+
*
|
|
757
|
+
* @returns `rekeyed` when a running instance's reconciler was rebuilt; `retained` when only the
|
|
758
|
+
* config changed (a hibernating instance, or one with the loop disabled); `unchanged` when
|
|
759
|
+
* the key already matched or the strand is open; `untracked` when the strand is not here.
|
|
760
|
+
*/
|
|
761
|
+
rekeyParty(strandId: string, partyMemberPrivateKey: string): Promise<'rekeyed' | 'retained' | 'unchanged' | 'untracked'>;
|
|
762
|
+
/** Whether {@link rekeyParty} has anything to do for `strandId`: the retained config is a closed strand's and names another key. */
|
|
763
|
+
private rekeyNeeded;
|
|
764
|
+
/** The ids of every tracked closed strand, running or hibernating. */
|
|
765
|
+
trackedClosedStrandIds(): string[];
|
|
629
766
|
/**
|
|
630
767
|
* Best-effort removal of THIS machine's own `Strand.MemberPeer` binding — the
|
|
631
768
|
* self arm of `removeMemberPeer`, signed with the retained launch config's party
|
|
@@ -643,13 +780,16 @@ export declare class StrandInstanceManager {
|
|
|
643
780
|
* and its in-flight pass awaited — FIRST, so a pass that was already past its
|
|
644
781
|
* own stopped check cannot re-register the binding this is about to clear.
|
|
645
782
|
*
|
|
646
|
-
*
|
|
647
|
-
*
|
|
648
|
-
*
|
|
649
|
-
*
|
|
650
|
-
*
|
|
651
|
-
*
|
|
652
|
-
*
|
|
783
|
+
* A machine removed from the CADRE at the control layer is not cleared here either: the
|
|
784
|
+
* party replaces its key in the strand instead (`strand-party-key-rotation.ts`), which
|
|
785
|
+
* leaves that machine's binding an orphan the revoked-peer gate denies, and the membership
|
|
786
|
+
* reconciler clears what a lagging sibling wrote under the new key.
|
|
787
|
+
*
|
|
788
|
+
* NOTE: deliberately NOT handled here (or anywhere yet): clearing the bindings of a party's
|
|
789
|
+
* OTHER machines when the party unpublishes — the party still holds the key on every
|
|
790
|
+
* surviving machine and can clear from any of them, and the stale rows grant nothing while
|
|
791
|
+
* admission is deny-list only. Revisit when `feat-strand-member-allowlist-admission` lands
|
|
792
|
+
* and a stale binding starts granting admission rather than merely mis-crediting diversity.
|
|
653
793
|
*/
|
|
654
794
|
clearOwnMemberPeerBinding(strandId: string): Promise<void>;
|
|
655
795
|
/**
|
|
@@ -699,6 +839,28 @@ export declare class StrandInstanceManager {
|
|
|
699
839
|
private settleTransition;
|
|
700
840
|
/** Body of {@link resumeStrand}; at most one runs per strand at a time. */
|
|
701
841
|
private runResume;
|
|
842
|
+
/**
|
|
843
|
+
* {@link buildStrandRuntime}, run once more as the replica when it fails on the schema of a
|
|
844
|
+
* claim that has not applied yet ({@link revertRefusedAttach}). Safe to run twice: a failed
|
|
845
|
+
* build releases both handles before it rejects.
|
|
846
|
+
*/
|
|
847
|
+
private buildRuntimeOrReplica;
|
|
848
|
+
/**
|
|
849
|
+
* Undo a claim of a storage replica ({@link attachSApp}) after an apply of its schema was refused
|
|
850
|
+
* (`AppSchemaRefusedError`): the retained launch config drops the sApp, so later rebuilds run the
|
|
851
|
+
* replica, and the instance gets back the replica's unset `sAppInfo` and its latency hint. Only
|
|
852
|
+
* when `error` is such a refusal, `refused` is the claim the strand has not applied yet, and the
|
|
853
|
+
* retained config still carries it, so a config rewritten since is left alone.
|
|
854
|
+
*
|
|
855
|
+
* @returns the replica's launch config, or `undefined` when nothing was undone.
|
|
856
|
+
*/
|
|
857
|
+
private revertRefusedAttach;
|
|
858
|
+
/**
|
|
859
|
+
* Forget the unapplied claim of `strandId` once `database`, given the claim's sApp config as
|
|
860
|
+
* `applied`, has applied its schema. An apply still deferred keeps it, since its retry can still be
|
|
861
|
+
* refused by the strand's rows.
|
|
862
|
+
*/
|
|
863
|
+
private forgetAppliedAttach;
|
|
702
864
|
/**
|
|
703
865
|
* Honor a founder request against an ALREADY-TRACKED strand — the seam that
|
|
704
866
|
* closes the "whoever launches first decides whether the bootstrap runs" gap:
|
|
@@ -742,19 +904,24 @@ export declare class StrandInstanceManager {
|
|
|
742
904
|
*
|
|
743
905
|
* A runtime build in flight (the replica's launch, or a hibernation wake) is waited out
|
|
744
906
|
* first, so the attach acts on the database that build produced. Then, in order: the
|
|
745
|
-
* schema signature
|
|
746
|
-
*
|
|
747
|
-
*
|
|
748
|
-
*
|
|
749
|
-
*
|
|
750
|
-
*
|
|
907
|
+
* schema signature, and the refusals the schema's text alone decides (`checkAppSchema`: a
|
|
908
|
+
* `seed` item, an item the parser skipped, a syntax error), are checked before anything
|
|
909
|
+
* changes; the retained launch config takes the sApp, so every later rebuild applies it
|
|
910
|
+
* through `composeStrand`; the live database — published, or still held by the first-sync
|
|
911
|
+
* gate — gets the schema; and only then does the instance record `sAppInfo` and the sApp's
|
|
912
|
+
* latency hint. An instance with no live database gets the config alone: a quiesced one
|
|
913
|
+
* applies the schema at its next resume, a launch waiting for a seed peer at its next
|
|
914
|
+
* database retry, and that build falls back to the replica if the strand's tables and rows
|
|
915
|
+
* refuse the schema ({@link revertRefusedAttach}).
|
|
751
916
|
*
|
|
752
917
|
* @returns `'already-attached'` when the instance already runs an sApp — a DIFFERENT one
|
|
753
918
|
* is logged and left as it is, as a second claim of a claimed strand always has been —
|
|
754
919
|
* else `'attached'`.
|
|
755
920
|
* @throws when the strand is not tracked (a caller bug, or a launch that failed while
|
|
756
|
-
* this waited on it); when the schema signature is refused, having
|
|
757
|
-
*
|
|
921
|
+
* this waited on it); when the schema signature or the schema's text is refused, having
|
|
922
|
+
* changed nothing; `AppSchemaRefusedError` when the live apply refuses the schema against
|
|
923
|
+
* the replica's tables and rows, having put the retained config back to the replica's; and
|
|
924
|
+
* whatever else the live apply throws (e.g. a quiesce closed the database mid-apply) — the
|
|
758
925
|
* retained config then still carries the sApp and `sAppInfo` stays unset, so the next
|
|
759
926
|
* claim retries the apply.
|
|
760
927
|
*
|
|
@@ -766,6 +933,21 @@ export declare class StrandInstanceManager {
|
|
|
766
933
|
attachSApp(strandId: string, sAppConfig: SAppConfig, options?: {
|
|
767
934
|
requireSignedSchemas?: boolean;
|
|
768
935
|
}): Promise<'attached' | 'already-attached'>;
|
|
936
|
+
/**
|
|
937
|
+
* The tracked instance and retained config an {@link attachSApp} claim acts on, or
|
|
938
|
+
* `'already-attached'` when the instance already runs an sApp (a claim for a different one is
|
|
939
|
+
* logged and ignored).
|
|
940
|
+
*
|
|
941
|
+
* @throws when the strand is not tracked.
|
|
942
|
+
*/
|
|
943
|
+
private claimTarget;
|
|
944
|
+
/**
|
|
945
|
+
* Apply a claim's schema to the replica's live database. A refusal by the replica's tables and
|
|
946
|
+
* rows puts the retained config back to the replica's ({@link revertRefusedAttach}): the replica
|
|
947
|
+
* holds no `App` schema, so the refused apply left nothing to drop. Any other failure leaves the
|
|
948
|
+
* claim retained and unapplied, for the next claim or build to retry.
|
|
949
|
+
*/
|
|
950
|
+
private applyClaimedSchema;
|
|
769
951
|
/**
|
|
770
952
|
* Whether `strandId` is launched but still waiting for its first sync — a joiner whose
|
|
771
953
|
* runtime is up while its database is withheld (status `'syncing'`, or `'idle'` after
|