@serfab/cadre-core 1.19.0 → 1.20.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/dist/cadre-node.d.ts +118 -16
- package/dist/cadre-node.js +210 -31
- package/dist/cadre-node.js.map +1 -1
- package/dist/control-database.d.ts +2 -1
- package/dist/control-database.js +128 -126
- package/dist/control-database.js.map +1 -1
- package/dist/control-protocol-guard.js +3 -2
- package/dist/control-protocol-guard.js.map +1 -1
- package/dist/control-read-retry.d.ts +19 -16
- package/dist/control-read-retry.js +22 -54
- package/dist/control-read-retry.js.map +1 -1
- package/dist/control-retry.d.ts +50 -6
- package/dist/control-retry.js +53 -6
- package/dist/control-retry.js.map +1 -1
- package/dist/control-stream.js +2 -1
- package/dist/control-stream.js.map +1 -1
- package/dist/control-write-retry.d.ts +24 -16
- package/dist/control-write-retry.js +58 -30
- package/dist/control-write-retry.js.map +1 -1
- package/dist/describe-thrown.d.ts +12 -0
- package/dist/describe-thrown.js +59 -0
- package/dist/describe-thrown.js.map +1 -0
- package/dist/edge-node/config.d.ts +8 -2
- package/dist/edge-node/config.js +5 -1
- package/dist/edge-node/config.js.map +1 -1
- package/dist/edge-node/dissolve.d.ts +1 -1
- package/dist/edge-node/dissolve.js +1 -1
- package/dist/edge-node/dissolve.js.map +1 -1
- package/dist/edge-node/edge-join.js +4 -1
- package/dist/edge-node/edge-join.js.map +1 -1
- package/dist/edge-node/edge-node.d.ts +10 -0
- package/dist/edge-node/edge-node.js +54 -9
- package/dist/edge-node/edge-node.js.map +1 -1
- package/dist/edge-node/options.d.ts +11 -2
- package/dist/edge-node/options.js +11 -4
- package/dist/edge-node/options.js.map +1 -1
- package/dist/edge-node/platform.d.ts +15 -3
- package/dist/edge-node/strand-move.d.ts +0 -2
- package/dist/edge-node/strand-move.js +1 -4
- package/dist/edge-node/strand-move.js.map +1 -1
- package/dist/edge-node/strands.js +5 -3
- package/dist/edge-node/strands.js.map +1 -1
- package/dist/enrollment.js +2 -1
- package/dist/enrollment.js.map +1 -1
- package/dist/index.d.ts +6 -2
- package/dist/index.js +9 -1
- package/dist/index.js.map +1 -1
- package/dist/member-redemption.js +3 -9
- package/dist/member-redemption.js.map +1 -1
- package/dist/node-local-snapshot.js +2 -1
- package/dist/node-local-snapshot.js.map +1 -1
- package/dist/peer-dial.js +3 -2
- package/dist/peer-dial.js.map +1 -1
- package/dist/pending-join-runner.d.ts +29 -2
- package/dist/pending-join-runner.js +60 -20
- package/dist/pending-join-runner.js.map +1 -1
- package/dist/push-notifier-apns.js +8 -7
- package/dist/push-notifier-apns.js.map +1 -1
- package/dist/push-notifier-fcm.js +6 -5
- package/dist/push-notifier-fcm.js.map +1 -1
- package/dist/push-notifier-shared.d.ts +0 -2
- package/dist/push-notifier-shared.js +4 -4
- package/dist/push-notifier-shared.js.map +1 -1
- package/dist/relay-reservation.js +4 -3
- package/dist/relay-reservation.js.map +1 -1
- package/dist/strand-addr-protocol.js +2 -1
- package/dist/strand-addr-protocol.js.map +1 -1
- package/dist/strand-app-schema-report.d.ts +53 -0
- package/dist/strand-app-schema-report.js +77 -0
- package/dist/strand-app-schema-report.js.map +1 -0
- package/dist/strand-database.d.ts +60 -0
- package/dist/strand-database.js +93 -0
- package/dist/strand-database.js.map +1 -1
- package/dist/strand-first-sync-gate.js +4 -3
- package/dist/strand-first-sync-gate.js.map +1 -1
- package/dist/strand-formation-protocol.js +4 -3
- package/dist/strand-formation-protocol.js.map +1 -1
- package/dist/strand-instance-manager.d.ts +73 -2
- package/dist/strand-instance-manager.js +112 -9
- package/dist/strand-instance-manager.js.map +1 -1
- package/dist/strand-membership-reconciler.d.ts +13 -1
- package/dist/strand-membership-reconciler.js +25 -16
- package/dist/strand-membership-reconciler.js.map +1 -1
- package/dist/strand-membership-writer.d.ts +16 -2
- package/dist/strand-membership-writer.js +54 -8
- package/dist/strand-membership-writer.js.map +1 -1
- package/dist/strand-move.js +4 -6
- package/dist/strand-move.js.map +1 -1
- package/dist/strand-offline.d.ts +102 -0
- package/dist/strand-offline.js +97 -0
- package/dist/strand-offline.js.map +1 -0
- package/dist/types.d.ts +37 -0
- package/dist/types.js.map +1 -1
- package/package.json +8 -8
- package/src/cadre-node.ts +230 -31
- package/src/control-database.ts +5594 -5592
- package/src/control-protocol-guard.ts +3 -2
- package/src/control-read-retry.ts +22 -58
- package/src/control-retry.ts +54 -6
- package/src/control-stream.ts +2 -1
- package/src/control-write-retry.ts +58 -30
- package/src/describe-thrown.ts +60 -0
- package/src/edge-node/config.ts +11 -2
- package/src/edge-node/dissolve.ts +2 -1
- package/src/edge-node/edge-join.ts +2 -1
- package/src/edge-node/edge-node.ts +57 -7
- package/src/edge-node/options.ts +20 -4
- package/src/edge-node/platform.ts +15 -3
- package/src/edge-node/strand-move.ts +1 -5
- package/src/edge-node/strands.ts +74 -72
- package/src/enrollment.ts +2 -1
- package/src/index.ts +27 -1
- package/src/member-redemption.ts +3 -9
- package/src/node-local-snapshot.ts +2 -1
- package/src/peer-dial.ts +605 -604
- package/src/pending-join-runner.ts +68 -22
- package/src/push-notifier-apns.ts +8 -7
- package/src/push-notifier-fcm.ts +6 -5
- package/src/push-notifier-shared.ts +5 -5
- package/src/relay-reservation.ts +1212 -1211
- package/src/strand-addr-protocol.ts +2 -1
- package/src/strand-app-schema-report.ts +115 -0
- package/src/strand-database.ts +123 -1
- package/src/strand-first-sync-gate.ts +600 -599
- package/src/strand-formation-protocol.ts +4 -3
- package/src/strand-instance-manager.ts +137 -10
- package/src/strand-membership-reconciler.ts +942 -928
- package/src/strand-membership-writer.ts +61 -14
- package/src/strand-move.ts +594 -597
- package/src/strand-offline.ts +178 -0
- package/src/types.ts +36 -0
|
@@ -33,6 +33,7 @@ import { decodeLengthPrefixedFrame } from './seed-bootstrap.js';
|
|
|
33
33
|
import { orderSignalingFirst } from './peer-record.js';
|
|
34
34
|
import { withDeadline, exchangeFrame, readStreamToEnd, replyAndClose } from './control-stream.js';
|
|
35
35
|
import { relayedRequestBudgetMs } from './link-budget.js';
|
|
36
|
+
import { toError } from './describe-thrown.js';
|
|
36
37
|
const log = debug('sereus:cadre:strand-addr');
|
|
37
38
|
/** Protocol id for the control-network strand-address RPC (parallel to `/sereus/strand-wake/1.0.0`). */
|
|
38
39
|
export const STRAND_ADDR_PROTOCOL = '/sereus/strand-addr/1.0.0';
|
|
@@ -273,7 +274,7 @@ async function dialOneSibling(node, peer, request, options) {
|
|
|
273
274
|
return siblingAnswer(response);
|
|
274
275
|
}
|
|
275
276
|
catch (err) {
|
|
276
|
-
const error =
|
|
277
|
+
const error = toError(err);
|
|
277
278
|
// Matched by name, as libp2p's own error classes are compared across package copies.
|
|
278
279
|
if (error.name === 'UnsupportedProtocolError') {
|
|
279
280
|
log('Strand-addr refused by %s via %s: it does not serve %s', peer.peerId, describeTarget(target), protocolId);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"strand-addr-protocol.js","sourceRoot":"","sources":["../src/strand-addr-protocol.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEnD,OAAO,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAsB,YAAY,EAAE,aAAa,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACtH,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"strand-addr-protocol.js","sourceRoot":"","sources":["../src/strand-addr-protocol.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;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ACD,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,GAAG,KAAgC,CAAC;IAC1E,OAAO,OAAO,MAAM,KAAK,QAAQ,IAAI,oBAAoB,CAAC,GAAG,CAAC,MAAM,CAAC;WAChE,OAAO,QAAQ,KAAK,QAAQ;WAC5B,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,UAAU,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC;AACzF,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { AppSchemaWait, SereusPluginResult } from '@serfab/quereus-plugin-sereus';
|
|
2
|
+
/**
|
|
3
|
+
* `StrandDatabase.appSchemaState()`: whether the database runs the `App` schema its launch was
|
|
4
|
+
* given. While the apply is held back the database runs the earlier schema: `'waiting-for-queue'`
|
|
5
|
+
* while queued offline transactions refuse it, `'waiting-for-cohort'` while the strand's members
|
|
6
|
+
* cannot be reached. `'failed'` when a later retry failed for another reason.
|
|
7
|
+
*/
|
|
8
|
+
export type StrandAppSchemaState = 'applied' | 'waiting-for-queue' | 'waiting-for-cohort' | 'failed';
|
|
9
|
+
/** `strand:app-schema-deferred`: why the `App` schema apply was held back. */
|
|
10
|
+
export interface StrandAppSchemaDeferred {
|
|
11
|
+
readonly strandId: string;
|
|
12
|
+
/** `'queue'`: queued offline transactions refused it. `'cohort'`: the strand's members could not be reached. */
|
|
13
|
+
readonly waitingFor: AppSchemaWait;
|
|
14
|
+
/** The queued transactions that refused it; empty when {@link waitingFor} is `'cohort'`. */
|
|
15
|
+
readonly transactionIds: readonly string[];
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Where a strand database reports its `App` schema apply. Retained with the launch config and handed
|
|
19
|
+
* to every database built for the launch, so the reports outlive hibernation and every other rebuild.
|
|
20
|
+
*/
|
|
21
|
+
export interface StrandAppSchemaListeners {
|
|
22
|
+
onAppSchemaDeferred?: (event: StrandAppSchemaDeferred) => void;
|
|
23
|
+
onAppSchemaApplied?: (event: {
|
|
24
|
+
strandId: string;
|
|
25
|
+
}) => void;
|
|
26
|
+
onAppSchemaFailed?: (event: {
|
|
27
|
+
strandId: string;
|
|
28
|
+
error: Error;
|
|
29
|
+
}) => void;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* What one strand database reports about its `App` schema apply. Built once `connectToStrand` has
|
|
33
|
+
* returned and released first when the database closes, so nothing from a closing connection reaches
|
|
34
|
+
* the app. Events begin at publication, when the app gets the database: a retry that landed before
|
|
35
|
+
* then is not announced, and one that failed before then is announced at publication.
|
|
36
|
+
*/
|
|
37
|
+
export declare class StrandAppSchemaReport {
|
|
38
|
+
private readonly strandId;
|
|
39
|
+
private readonly listeners;
|
|
40
|
+
private readonly result;
|
|
41
|
+
private state;
|
|
42
|
+
private error;
|
|
43
|
+
private wasPublished;
|
|
44
|
+
private released;
|
|
45
|
+
constructor(strandId: string, listeners: StrandAppSchemaListeners, result: Pick<SereusPluginResult, 'appSchema' | 'appSchemaWaitingFor' | 'appSchemaDeferredBy'>);
|
|
46
|
+
appSchemaState(): StrandAppSchemaState;
|
|
47
|
+
/** The database was handed to the app: report an apply still waiting or already failed. */
|
|
48
|
+
published(): void;
|
|
49
|
+
release(): void;
|
|
50
|
+
/** A cancelled retry (the database closed first) reports nothing. */
|
|
51
|
+
private settle;
|
|
52
|
+
private reportFailed;
|
|
53
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import debug from 'debug';
|
|
2
|
+
import { toError } from './describe-thrown.js';
|
|
3
|
+
const log = debug('sereus:cadre:strand-app-schema');
|
|
4
|
+
const WAITING_STATE = {
|
|
5
|
+
queue: 'waiting-for-queue',
|
|
6
|
+
cohort: 'waiting-for-cohort'
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* What one strand database reports about its `App` schema apply. Built once `connectToStrand` has
|
|
10
|
+
* returned and released first when the database closes, so nothing from a closing connection reaches
|
|
11
|
+
* the app. Events begin at publication, when the app gets the database: a retry that landed before
|
|
12
|
+
* then is not announced, and one that failed before then is announced at publication.
|
|
13
|
+
*/
|
|
14
|
+
export class StrandAppSchemaReport {
|
|
15
|
+
constructor(strandId, listeners, result) {
|
|
16
|
+
this.strandId = strandId;
|
|
17
|
+
this.listeners = listeners;
|
|
18
|
+
this.result = result;
|
|
19
|
+
this.wasPublished = false;
|
|
20
|
+
this.released = false;
|
|
21
|
+
// `appSchema` is absent without an `App` schema (a storage replica), which has nothing to defer.
|
|
22
|
+
const waitingFor = result.appSchemaWaitingFor;
|
|
23
|
+
this.state = waitingFor ? WAITING_STATE[waitingFor] : 'applied';
|
|
24
|
+
if (waitingFor) {
|
|
25
|
+
void result.appSchema?.then((outcome) => this.settle(outcome)).catch((error) => {
|
|
26
|
+
log('strand %s: reporting the deferred app schema apply failed: %O', strandId, error);
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
appSchemaState() {
|
|
31
|
+
return this.state;
|
|
32
|
+
}
|
|
33
|
+
/** The database was handed to the app: report an apply still waiting or already failed. */
|
|
34
|
+
published() {
|
|
35
|
+
if (this.released || this.wasPublished) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
this.wasPublished = true;
|
|
39
|
+
const waitingFor = this.result.appSchemaWaitingFor;
|
|
40
|
+
if (waitingFor && this.state === WAITING_STATE[waitingFor]) {
|
|
41
|
+
this.listeners.onAppSchemaDeferred?.({
|
|
42
|
+
strandId: this.strandId,
|
|
43
|
+
waitingFor,
|
|
44
|
+
transactionIds: this.result.appSchemaDeferredBy ?? []
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
else if (this.error) {
|
|
48
|
+
this.reportFailed(this.error);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
release() {
|
|
52
|
+
this.released = true;
|
|
53
|
+
}
|
|
54
|
+
/** A cancelled retry (the database closed first) reports nothing. */
|
|
55
|
+
settle(outcome) {
|
|
56
|
+
if (this.released || outcome.state === 'cancelled') {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
if (outcome.state === 'applied') {
|
|
60
|
+
this.state = 'applied';
|
|
61
|
+
if (this.wasPublished) {
|
|
62
|
+
this.listeners.onAppSchemaApplied?.({ strandId: this.strandId });
|
|
63
|
+
}
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
this.state = 'failed';
|
|
67
|
+
this.error = toError(outcome.error);
|
|
68
|
+
log('strand %s: the deferred app schema apply failed; the database keeps the earlier schema: %O', this.strandId, outcome.error);
|
|
69
|
+
if (this.wasPublished) {
|
|
70
|
+
this.reportFailed(this.error);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
reportFailed(error) {
|
|
74
|
+
this.listeners.onAppSchemaFailed?.({ strandId: this.strandId, error });
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=strand-app-schema-report.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"strand-app-schema-report.js","sourceRoot":"","sources":["../src/strand-app-schema-report.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAG/C,MAAM,GAAG,GAAG,KAAK,CAAC,gCAAgC,CAAC,CAAC;AA6BpD,MAAM,aAAa,GAAgD;IACjE,KAAK,EAAE,mBAAmB;IAC1B,MAAM,EAAE,oBAAoB;CAC7B,CAAC;AAEF;;;;;GAKG;AACH,MAAM,OAAO,qBAAqB;IAMhC,YACmB,QAAgB,EAChB,SAAmC,EACnC,MAA6F;QAF7F,aAAQ,GAAR,QAAQ,CAAQ;QAChB,cAAS,GAAT,SAAS,CAA0B;QACnC,WAAM,GAAN,MAAM,CAAuF;QANxG,iBAAY,GAAG,KAAK,CAAC;QACrB,aAAQ,GAAG,KAAK,CAAC;QAOvB,iGAAiG;QACjG,MAAM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OAAyB;QACtC,IAAI,IAAI,CAAC,QAAQ,IAAI,OAAO,CAAC,KAAK,KAAK,WAAW,EAAE,CAAC;YACnD,OAAO;QACT,CAAC;QACD,IAAI,OAAO,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;YAChC,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC;YACvB,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;gBACtB,IAAI,CAAC,SAAS,CAAC,kBAAkB,EAAE,CAAC,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;YACnE,CAAC;YACD,OAAO;QACT,CAAC;QACD,IAAI,CAAC,KAAK,GAAG,QAAQ,CAAC;QACtB,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QACpC,GAAG,CAAC,4FAA4F,EAAE,IAAI,CAAC,QAAQ,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;QAChI,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;YACtB,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAChC,CAAC;IACH,CAAC;IAEO,YAAY,CAAC,KAAY;QAC/B,IAAI,CAAC,SAAS,CAAC,iBAAiB,EAAE,CAAC,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC;IACzE,CAAC;CACF"}
|
|
@@ -2,9 +2,12 @@ import { Database } from '@quereus/quereus';
|
|
|
2
2
|
import type { SereusPluginResult } from '@serfab/quereus-plugin-sereus';
|
|
3
3
|
import type { Libp2p } from '@libp2p/interface';
|
|
4
4
|
import type { IRepo } from '@optimystic/db-core';
|
|
5
|
+
import type { IKVStore } from '@optimystic/db-p2p';
|
|
5
6
|
import type { SAppConfig } from './types.js';
|
|
6
7
|
import type { StrandCommitDurability, StrandCommitListeners } from './strand-commit-durability.js';
|
|
7
8
|
import type { TableChangeWatch, TableChangeWatchOptions } from './table-change-watch.js';
|
|
9
|
+
import type { StrandOfflineListeners, StrandOfflineMode, StrandOfflineQueue } from './strand-offline.js';
|
|
10
|
+
import { type StrandAppSchemaListeners, type StrandAppSchemaState } from './strand-app-schema-report.js';
|
|
8
11
|
export interface StrandDatabaseConfig extends StrandCommitListeners {
|
|
9
12
|
/** The strand ID */
|
|
10
13
|
strandId: string;
|
|
@@ -54,6 +57,26 @@ export interface StrandDatabaseConfig extends StrandCommitListeners {
|
|
|
54
57
|
* fixture that hand-drives the membership writers sees only the rows it wrote. Defaults to false.
|
|
55
58
|
*/
|
|
56
59
|
bindFounderPeer?: boolean;
|
|
60
|
+
/**
|
|
61
|
+
* Turn on the connection's offline queue (docs/strands.md → "Offline mode"). Absent: no queue,
|
|
62
|
+
* and {@link StrandDatabase.offline} is undefined.
|
|
63
|
+
*/
|
|
64
|
+
offline?: StrandDatabaseOffline;
|
|
65
|
+
/** Where to report the `App` schema apply when it is held back (docs/strands.md → "An app schema upgrade waits for the queue or the cohort"). */
|
|
66
|
+
appSchema?: StrandAppSchemaListeners;
|
|
67
|
+
}
|
|
68
|
+
/** {@link StrandDatabaseConfig.offline}: one build's journal, the strand's mode, and where to report. */
|
|
69
|
+
export interface StrandDatabaseOffline extends StrandOfflineListeners {
|
|
70
|
+
/**
|
|
71
|
+
* This build's journal, resolved by {@link StrandDatabase.initialize}, so a launch released while
|
|
72
|
+
* it resolves is caught like one released during the rest of the build. A throw fails initialize.
|
|
73
|
+
*/
|
|
74
|
+
journal: () => IKVStore | Promise<IKVStore>;
|
|
75
|
+
/**
|
|
76
|
+
* The strand's mode, read at the end of {@link StrandDatabase.initialize} and at every
|
|
77
|
+
* {@link StrandDatabase.applyOfflineMode}, never captured, so the newest choice wins.
|
|
78
|
+
*/
|
|
79
|
+
mode: () => StrandOfflineMode;
|
|
57
80
|
}
|
|
58
81
|
/**
|
|
59
82
|
* StrandDatabase manages the sApp schema for a strand using Quereus with the
|
|
@@ -80,6 +103,9 @@ export declare class StrandDatabase {
|
|
|
80
103
|
private initialized;
|
|
81
104
|
private readonly commits;
|
|
82
105
|
private unsubscribeCommits;
|
|
106
|
+
private offlineQueue;
|
|
107
|
+
private offlineReport;
|
|
108
|
+
private appSchemaReport;
|
|
83
109
|
/** Subscriptions handed out by {@link watchTables}. */
|
|
84
110
|
private readonly tableWatches;
|
|
85
111
|
constructor(config: StrandDatabaseConfig);
|
|
@@ -90,6 +116,19 @@ export declare class StrandDatabase {
|
|
|
90
116
|
*/
|
|
91
117
|
initialize(): Promise<void>;
|
|
92
118
|
private subscribeToCommits;
|
|
119
|
+
private followOffline;
|
|
120
|
+
/**
|
|
121
|
+
* Put the queue in the strand's current mode ({@link StrandDatabaseOffline.mode}). It sets the
|
|
122
|
+
* acknowledgement of transactions begun from now on; an open one keeps the one it began with.
|
|
123
|
+
* No-op without a queue, and before {@link initialize} has composed one (it applies the mode itself).
|
|
124
|
+
*/
|
|
125
|
+
applyOfflineMode(): void;
|
|
126
|
+
/**
|
|
127
|
+
* The database was handed to the app (`StrandInstanceManager.publishDatabase`): report the
|
|
128
|
+
* queue's state, since restored transactions' `queued` statuses were delivered before anything
|
|
129
|
+
* subscribed, and an `App` schema apply still held back.
|
|
130
|
+
*/
|
|
131
|
+
reportPublished(): void;
|
|
93
132
|
/**
|
|
94
133
|
* Run the founder membership bootstrap against the freshly-composed strand DB.
|
|
95
134
|
*
|
|
@@ -163,6 +202,27 @@ export declare class StrandDatabase {
|
|
|
163
202
|
* snapshot: read again after `strand:commit-held` to see the change.
|
|
164
203
|
*/
|
|
165
204
|
commitDurability(transactionId: string): StrandCommitDurability | undefined;
|
|
205
|
+
/**
|
|
206
|
+
* The strand connection's offline queue (docs/strands.md → "Offline mode"), or `undefined` on a
|
|
207
|
+
* node without `strandOffline`. The mode is set through `CadreNode.setStrandOfflineMode`, which
|
|
208
|
+
* outlives this database; listeners taken here die with it, as {@link watchTables} subscriptions do.
|
|
209
|
+
*/
|
|
210
|
+
get offline(): StrandOfflineQueue | undefined;
|
|
211
|
+
/**
|
|
212
|
+
* Whether this database runs the `App` schema its launch was given. `'waiting-for-queue'` or
|
|
213
|
+
* `'waiting-for-cohort'` while the apply is held back, so `StrandInstance.sAppInfo` names a version
|
|
214
|
+
* whose new tables or columns are not here yet; check this before relying on them.
|
|
215
|
+
*/
|
|
216
|
+
appSchemaState(): StrandAppSchemaState;
|
|
217
|
+
/**
|
|
218
|
+
* The transaction ids the offline queue lists (`entries()`, the ones a restore has not put back
|
|
219
|
+
* yet included), or `undefined` with no queue: none configured, not composed yet, or closed.
|
|
220
|
+
* Unlike {@link offline} it does not require {@link initialize} to have finished, so the manager
|
|
221
|
+
* can read a database still being built or about to close.
|
|
222
|
+
*/
|
|
223
|
+
queuedTransactionIds(): readonly string[] | undefined;
|
|
224
|
+
/** {@link discardQueued} on this database's queue; `undefined` with no queue, as {@link queuedTransactionIds}. */
|
|
225
|
+
discardQueuedTransactions(): readonly string[] | undefined;
|
|
166
226
|
/**
|
|
167
227
|
* The Optimystic transactor this strand's connection resolved to — always
|
|
168
228
|
* `'network'` here, since cadre-core passes no `transactor` option and takes
|
package/dist/strand-database.js
CHANGED
|
@@ -5,6 +5,8 @@ import { bootstrapFounderMembership } from './strand-membership-writer.js';
|
|
|
5
5
|
import { strandMemberKeyPair } from './strand-member-key.js';
|
|
6
6
|
import { StrandCommitRecord } from './strand-commit-durability.js';
|
|
7
7
|
import { TableWatchRegistry } from './table-change-watch.js';
|
|
8
|
+
import { discardQueued, StrandOfflineReport } from './strand-offline.js';
|
|
9
|
+
import { StrandAppSchemaReport } from './strand-app-schema-report.js';
|
|
8
10
|
const log = debug('sereus:cadre:strand-db');
|
|
9
11
|
const timing = debug('sereus:cadre:timing');
|
|
10
12
|
/**
|
|
@@ -31,6 +33,9 @@ export class StrandDatabase {
|
|
|
31
33
|
this.createEmptyCollections = null;
|
|
32
34
|
this.initialized = false;
|
|
33
35
|
this.unsubscribeCommits = null;
|
|
36
|
+
this.offlineQueue = null;
|
|
37
|
+
this.offlineReport = null;
|
|
38
|
+
this.appSchemaReport = null;
|
|
34
39
|
/** Subscriptions handed out by {@link watchTables}. */
|
|
35
40
|
this.tableWatches = new TableWatchRegistry();
|
|
36
41
|
this.config = config;
|
|
@@ -54,6 +59,7 @@ export class StrandDatabase {
|
|
|
54
59
|
this.founderSApp();
|
|
55
60
|
}
|
|
56
61
|
log('Initializing StrandDatabase for strand: %s (%s)', sid, sAppConfig ? `sApp: ${sAppConfig.id} v${sAppConfig.version}` : 'storage replica');
|
|
62
|
+
const offline = this.config.offline && { journal: await this.config.offline.journal() };
|
|
57
63
|
this.db = new Database();
|
|
58
64
|
// Delegate to the shared composition. The node is injected, so:
|
|
59
65
|
// - `connectToStrand` never creates or stops a node; `StrandInstanceManager`
|
|
@@ -74,20 +80,33 @@ export class StrandDatabase {
|
|
|
74
80
|
libp2pNode: this.config.libp2pNode,
|
|
75
81
|
coordinatedRepo: this.config.coordinatedRepo,
|
|
76
82
|
enableCache: true,
|
|
83
|
+
offline,
|
|
77
84
|
});
|
|
78
85
|
this.shutdownStrand = result.shutdown;
|
|
79
86
|
this.resolvedTransactor = result.transactor;
|
|
80
87
|
this.createEmptyCollections = result.createEmptyCollections;
|
|
81
88
|
// Before the founder bootstrap, so its commits are reported like any other.
|
|
82
89
|
this.subscribeToCommits(result);
|
|
90
|
+
this.followOffline(result);
|
|
91
|
+
this.appSchemaReport = new StrandAppSchemaReport(sid, this.config.appSchema ?? {}, result);
|
|
83
92
|
timing('[strandDb:%s] connectToStrand: %dms (hydrated tables=%d, indexes=%d)', sid, Math.round(performance.now() - t0), result.hydrated?.tables ?? 0, result.hydrated?.indexes ?? 0);
|
|
84
93
|
// Founder-only: write the one-time membership bootstrap now that the schema is
|
|
85
94
|
// applied (connectToStrand has returned). A throw here propagates out of
|
|
86
95
|
// initialize(), and the caller closes this half-built database (close() runs the
|
|
87
96
|
// composition's shutdown). Joiners skip this — their rows arrive via sync.
|
|
97
|
+
// NOTE: a bootstrap with rows to write while `hydrate` restored queued transactions is refused
|
|
98
|
+
// (`StrandOfflineQueueBusyError`), failing every build, so that queue could never drain. Not
|
|
99
|
+
// reachable today: rows are written only while the founding is incomplete (Member empty, or no
|
|
100
|
+
// Manager and none retired), and an incomplete founding fails the build before the database is
|
|
101
|
+
// ever published for the app to queue in. If a founder is ever published with its founding
|
|
102
|
+
// incomplete, skip the bootstrap here while the queue is non-empty and run it once the queue drains.
|
|
88
103
|
if (this.config.founder === true) {
|
|
89
104
|
await this.bootstrapFounder();
|
|
90
105
|
}
|
|
106
|
+
// After `hydrate` restored the queue and after the founder bootstrap (its `Strand` writes are
|
|
107
|
+
// network-acknowledged in either mode); before the first-sync probe, so in offline mode a read
|
|
108
|
+
// the cohort cannot answer is served from this machine's copy there as it is to the app.
|
|
109
|
+
this.applyOfflineMode();
|
|
91
110
|
this.initialized = true;
|
|
92
111
|
log('StrandDatabase for strand %s initialized successfully', sid);
|
|
93
112
|
}
|
|
@@ -99,6 +118,40 @@ export class StrandDatabase {
|
|
|
99
118
|
unsubscribeHeld();
|
|
100
119
|
};
|
|
101
120
|
}
|
|
121
|
+
followOffline(result) {
|
|
122
|
+
const { offline } = this.config;
|
|
123
|
+
if (!offline) {
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
this.offlineQueue = result.offline ?? null;
|
|
127
|
+
this.offlineReport = new StrandOfflineReport(this.config.strandId, offline, result.offline);
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Put the queue in the strand's current mode ({@link StrandDatabaseOffline.mode}). It sets the
|
|
131
|
+
* acknowledgement of transactions begun from now on; an open one keeps the one it began with.
|
|
132
|
+
* No-op without a queue, and before {@link initialize} has composed one (it applies the mode itself).
|
|
133
|
+
*/
|
|
134
|
+
applyOfflineMode() {
|
|
135
|
+
const queue = this.offlineQueue;
|
|
136
|
+
if (!queue || !this.config.offline) {
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
if (this.config.offline.mode() === 'offline') {
|
|
140
|
+
queue.enter();
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
queue.exit();
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* The database was handed to the app (`StrandInstanceManager.publishDatabase`): report the
|
|
148
|
+
* queue's state, since restored transactions' `queued` statuses were delivered before anything
|
|
149
|
+
* subscribed, and an `App` schema apply still held back.
|
|
150
|
+
*/
|
|
151
|
+
reportPublished() {
|
|
152
|
+
this.offlineReport?.published();
|
|
153
|
+
this.appSchemaReport?.published();
|
|
154
|
+
}
|
|
102
155
|
/**
|
|
103
156
|
* Run the founder membership bootstrap against the freshly-composed strand DB.
|
|
104
157
|
*
|
|
@@ -188,6 +241,10 @@ export class StrandDatabase {
|
|
|
188
241
|
*/
|
|
189
242
|
async attachAppSchema(sAppConfig) {
|
|
190
243
|
this.ensureInitialized();
|
|
244
|
+
// NOTE: unlike the connect-time apply (`applyAppSchemaAfterQueue`), this is not deferred behind
|
|
245
|
+
// the offline queue: a replica writes no app transactions, so no queued transaction wrote an
|
|
246
|
+
// `App` table and `QueuedEntriesBlockSchemaChangeError` cannot refuse it. If a replica ever
|
|
247
|
+
// writes app rows offline, route this through the deferral instead of throwing.
|
|
191
248
|
await applyAppSchema(this.db, sAppConfig.schema);
|
|
192
249
|
this.config.sAppConfig = sAppConfig;
|
|
193
250
|
log('StrandDatabase for strand %s attached sApp %s v%s', this.config.strandId, sAppConfig.id, sAppConfig.version);
|
|
@@ -222,6 +279,37 @@ export class StrandDatabase {
|
|
|
222
279
|
this.ensureInitialized();
|
|
223
280
|
return this.commits.get(transactionId);
|
|
224
281
|
}
|
|
282
|
+
/**
|
|
283
|
+
* The strand connection's offline queue (docs/strands.md → "Offline mode"), or `undefined` on a
|
|
284
|
+
* node without `strandOffline`. The mode is set through `CadreNode.setStrandOfflineMode`, which
|
|
285
|
+
* outlives this database; listeners taken here die with it, as {@link watchTables} subscriptions do.
|
|
286
|
+
*/
|
|
287
|
+
get offline() {
|
|
288
|
+
this.ensureInitialized();
|
|
289
|
+
return this.offlineQueue ?? undefined;
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* Whether this database runs the `App` schema its launch was given. `'waiting-for-queue'` or
|
|
293
|
+
* `'waiting-for-cohort'` while the apply is held back, so `StrandInstance.sAppInfo` names a version
|
|
294
|
+
* whose new tables or columns are not here yet; check this before relying on them.
|
|
295
|
+
*/
|
|
296
|
+
appSchemaState() {
|
|
297
|
+
this.ensureInitialized();
|
|
298
|
+
return this.appSchemaReport?.appSchemaState() ?? 'applied';
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* The transaction ids the offline queue lists (`entries()`, the ones a restore has not put back
|
|
302
|
+
* yet included), or `undefined` with no queue: none configured, not composed yet, or closed.
|
|
303
|
+
* Unlike {@link offline} it does not require {@link initialize} to have finished, so the manager
|
|
304
|
+
* can read a database still being built or about to close.
|
|
305
|
+
*/
|
|
306
|
+
queuedTransactionIds() {
|
|
307
|
+
return this.offlineQueue?.entries().map((entry) => entry.transactionId);
|
|
308
|
+
}
|
|
309
|
+
/** {@link discardQueued} on this database's queue; `undefined` with no queue, as {@link queuedTransactionIds}. */
|
|
310
|
+
discardQueuedTransactions() {
|
|
311
|
+
return this.offlineQueue ? discardQueued(this.offlineQueue) : undefined;
|
|
312
|
+
}
|
|
225
313
|
/**
|
|
226
314
|
* The Optimystic transactor this strand's connection resolved to — always
|
|
227
315
|
* `'network'` here, since cadre-core passes no `transactor` option and takes
|
|
@@ -243,6 +331,11 @@ export class StrandDatabase {
|
|
|
243
331
|
// First, so an event from the closing connection reaches no app handler or table watch.
|
|
244
332
|
this.unsubscribeCommits?.();
|
|
245
333
|
this.unsubscribeCommits = null;
|
|
334
|
+
this.offlineReport?.release();
|
|
335
|
+
this.offlineReport = null;
|
|
336
|
+
this.appSchemaReport?.release();
|
|
337
|
+
this.appSchemaReport = null;
|
|
338
|
+
this.offlineQueue = null;
|
|
246
339
|
this.tableWatches.disposeAll();
|
|
247
340
|
if (this.shutdownStrand) {
|
|
248
341
|
await this.shutdownStrand();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"strand-database.js","sourceRoot":"","sources":["../src/strand-database.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"strand-database.js","sourceRoot":"","sources":["../src/strand-database.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAMhF,OAAO,EAAE,0BAA0B,EAAE,MAAM,+BAA+B,CAAC;AAC3E,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAEnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAE7D,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAEzE,OAAO,EAAE,qBAAqB,EAA4D,MAAM,+BAA+B,CAAC;AAEhI,MAAM,GAAG,GAAG,KAAK,CAAC,wBAAwB,CAAC,CAAC;AAC5C,MAAM,MAAM,GAAG,KAAK,CAAC,qBAAqB,CAAC,CAAC;AA0E5C;;;;;;;;;;;;;;;GAeG;AACH,MAAM,OAAO,cAAc;IAezB,YAAY,MAA4B;QAdhC,OAAE,GAAoB,IAAI,CAAC;QAC3B,mBAAc,GAA0C,IAAI,CAAC;QAC7D,uBAAkB,GAA4C,IAAI,CAAC;QACnE,2BAAsB,GAAwD,IAAI,CAAC;QAEnF,gBAAW,GAAG,KAAK,CAAC;QAEpB,uBAAkB,G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imeoutScheduler } from './timeout-scheduler.js';
|
|
74
|
+
import { describeThrown } from './describe-thrown.js';
|
|
74
75
|
const log = debug('sereus:cadre:strand-first-sync');
|
|
75
76
|
/**
|
|
76
77
|
* How long a gated launch goes without probing when no data lands in the strand's store: the
|
|
@@ -268,7 +269,7 @@ async function headerHeld(db, label) {
|
|
|
268
269
|
return false;
|
|
269
270
|
}
|
|
270
271
|
catch (error) {
|
|
271
|
-
log('[%s] Header probe failed (treated as not yet held): %s', label,
|
|
272
|
+
log('[%s] Header probe failed (treated as not yet held): %s', label, describeThrown(error));
|
|
272
273
|
return false;
|
|
273
274
|
}
|
|
274
275
|
}
|
|
@@ -286,7 +287,7 @@ async function tableReadable(db, table, label) {
|
|
|
286
287
|
return true;
|
|
287
288
|
}
|
|
288
289
|
catch (error) {
|
|
289
|
-
log('[%s] %s probe failed (treated as not yet synced): %s', label, qualifiedName(table),
|
|
290
|
+
log('[%s] %s probe failed (treated as not yet synced): %s', label, qualifiedName(table), describeThrown(error));
|
|
290
291
|
return false;
|
|
291
292
|
}
|
|
292
293
|
}
|
|
@@ -469,7 +470,7 @@ export class StrandFirstSyncGate {
|
|
|
469
470
|
return await strandFirstSyncComplete(this.deps.database.getDatabase(), this.deps.label, this.progress);
|
|
470
471
|
}
|
|
471
472
|
catch (error) {
|
|
472
|
-
log('[%s] first-sync probe threw (treated as not yet synced): %s', this.deps.label,
|
|
473
|
+
log('[%s] first-sync probe threw (treated as not yet synced): %s', this.deps.label, describeThrown(error));
|
|
473
474
|
return false;
|
|
474
475
|
}
|
|
475
476
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"strand-first-sync-gate.js","sourceRoot":"","sources":["../src/strand-first-sync-gate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqEG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EA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UAAU,CAAC,CAAC;QACvG,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,SAAS,EAAE,CAAC;QACpC,gFAAgF;QAChF,IAAI,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,MAAM,IAAI,CAAC,IAAI;YAAE,OAAO;QACjD,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QACnB,IAAI,CAAC,IAAI,EAAE,CAAC;QACZ,GAAG,CAAC,qGAAqG,EAAE,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC5H,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC;IAC3B,CAAC;CACF"}
|
|
@@ -29,6 +29,7 @@ import { ed25519PublicKeyB64FromPeerId } from './ed25519-key.js';
|
|
|
29
29
|
import { trailingPeerId } from './peer-dial.js';
|
|
30
30
|
import { formationDeadlines, resolveProvisionTimeoutMs, responderClampReserveMs, splitProvisionBudget } from './strand-formation-deadlines.js';
|
|
31
31
|
import { FormationRejectedError, FormationUnreachableError } from './strand-formation-rejection.js';
|
|
32
|
+
import { describeThrown, toError } from './describe-thrown.js';
|
|
32
33
|
const log = debug('sereus:cadre:formation-proto');
|
|
33
34
|
/** Protocol id for the native formation transport (parallel to `/sereus/seed/1.0.0`). */
|
|
34
35
|
export const FORMATION_PROTOCOL = '/sereus/formation/1.0.0';
|
|
@@ -610,7 +611,7 @@ async function releaseFormationConnection(connection) {
|
|
|
610
611
|
}
|
|
611
612
|
catch (error) {
|
|
612
613
|
log('closing the formation connection to %s failed; aborting it: %o', connection.remotePeer.toString(), error);
|
|
613
|
-
connection.abort(
|
|
614
|
+
connection.abort(toError(error));
|
|
614
615
|
}
|
|
615
616
|
}
|
|
616
617
|
const NO_RESPONDER_ADDRS = 'No responder addresses available for formation';
|
|
@@ -694,14 +695,14 @@ function noMachineReached(failures) {
|
|
|
694
695
|
function describeAllAddressesFailed(error) {
|
|
695
696
|
if (!(error instanceof AggregateError))
|
|
696
697
|
return error;
|
|
697
|
-
const reasons = error.errors.map(
|
|
698
|
+
const reasons = error.errors.map(describeThrown);
|
|
698
699
|
return new FormationUnreachableError(`Formation could not reach the inviter at any of the ${reasons.length} addresses tried: ${reasons.join('; ')}`, { cause: error });
|
|
699
700
|
}
|
|
700
701
|
/** Report a failure that came before any answer as {@link FormationUnreachableError}, keeping its message. */
|
|
701
702
|
function asUnreachable(error) {
|
|
702
703
|
if (error instanceof FormationUnreachableError)
|
|
703
704
|
return error;
|
|
704
|
-
return new FormationUnreachableError(
|
|
705
|
+
return new FormationUnreachableError(describeThrown(error), { cause: error });
|
|
705
706
|
}
|
|
706
707
|
/**
|
|
707
708
|
* Open the formation stream, send the contact, and read back the one result frame, closing
|