@serfab/cadre-core 1.11.0 → 1.13.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 +7 -0
- package/dist/cadre-node.js +46 -14
- package/dist/cadre-node.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/membership-connection-gater.d.ts +6 -6
- package/dist/membership-connection-gater.js +6 -6
- package/dist/strand-first-sync-gate.d.ts +5 -4
- package/dist/strand-first-sync-gate.js +5 -4
- package/dist/strand-first-sync-gate.js.map +1 -1
- package/dist/strand-instance-manager.d.ts +41 -1
- package/dist/strand-instance-manager.js +89 -4
- package/dist/strand-instance-manager.js.map +1 -1
- package/dist/strand-reactivity.d.ts +41 -0
- package/dist/strand-reactivity.js +41 -0
- package/dist/strand-reactivity.js.map +1 -0
- package/dist/types.d.ts +19 -0
- package/dist/types.js.map +1 -1
- package/package.json +8 -8
- package/src/cadre-node.ts +8686 -8654
- package/src/index.ts +4 -0
- package/src/membership-connection-gater.ts +570 -570
- package/src/strand-first-sync-gate.ts +392 -391
- package/src/strand-instance-manager.ts +1883 -1789
- package/src/strand-reactivity.ts +53 -0
- package/src/types.ts +20 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which strand nodes are built with Optimystic's change-notification substrate
|
|
3
|
+
* (`NodeOptions.cohortTopic` in `@optimystic/db-p2p`): a node built with it announces every
|
|
4
|
+
* commit whose collection log tail it applied, and gives the strand's tables tagged
|
|
5
|
+
* `"optimystic.network_watch" = true` a network watch, so an app on another machine is woken
|
|
6
|
+
* by a commit instead of polling. Off unless the operator turns it on; `docs/strands.md` →
|
|
7
|
+
* "Change notifications (reactivity)" says what turning it on costs and exposes.
|
|
8
|
+
*
|
|
9
|
+
* "Cohort topic" is Optimystic's name for the substrate and stays inside this module; cadre
|
|
10
|
+
* calls the setting `strandReactivity`.
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* The `createLibp2pNode` options slice for one strand: `{ cohortTopic: { enabled: true } }` when
|
|
14
|
+
* `config.enabled === true` and (`strandIds` is absent, an empty array, or contains `strandId`
|
|
15
|
+
* exactly); otherwise `{}` — no `cohortTopic` key at all, never `{ enabled: false }`, so db-p2p
|
|
16
|
+
* takes its "absent" path unchanged.
|
|
17
|
+
*
|
|
18
|
+
* Fails closed on a JS embedder's mistake: an `enabled` that is not the boolean `true`, or a
|
|
19
|
+
* `strandIds` that is present but not an array, enables nothing.
|
|
20
|
+
*
|
|
21
|
+
* Deliberately no `wantK` or `host` tuning: a reactivity root is the tail block's storage group
|
|
22
|
+
* (`clusterSize` wide), verified at the consensus super-majority, and neither `wantK` nor
|
|
23
|
+
* `cohortTopic.host.minSigs` governs it; the tiers below the root keep db-p2p's defaults.
|
|
24
|
+
*
|
|
25
|
+
* NOTE: with no `host.profile`, db-p2p builds every host as core (forwarder-eligible, 30 s
|
|
26
|
+
* renewal), a `'transaction'` phone included — it does not follow `fretProfile`. If phone-side
|
|
27
|
+
* forwarding load shows up, pass `host: { profile: edgeProfile() }` for transaction nodes, after
|
|
28
|
+
* confirming an edge host still serves its part of a tail block's root group.
|
|
29
|
+
*/
|
|
30
|
+
export function strandCohortTopicOption(config, strandId) {
|
|
31
|
+
return config?.enabled === true && strandSelected(config.strandIds, strandId)
|
|
32
|
+
? { cohortTopic: { enabled: true } }
|
|
33
|
+
: {};
|
|
34
|
+
}
|
|
35
|
+
function strandSelected(strandIds, strandId) {
|
|
36
|
+
if (strandIds === undefined) {
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
return Array.isArray(strandIds) && (strandIds.length === 0 || strandIds.includes(strandId));
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=strand-reactivity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"strand-reactivity.js","sourceRoot":"","sources":["../src/strand-reactivity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAUH;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,uBAAuB,CACrC,MAA0C,EAC1C,QAAgB;IAEhB,OAAO,MAAM,EAAE,OAAO,KAAK,IAAI,IAAI,cAAc,CAAC,MAAM,CAAC,SAAS,EAAE,QAAQ,CAAC;QAC3E,CAAC,CAAC,EAAE,WAAW,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;QACpC,CAAC,CAAC,EAAE,CAAC;AACT,CAAC;AAED,SAAS,cAAc,CAAC,SAAkB,EAAE,QAAgB;IAC1D,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;QAC5B,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,KAAK,CAAC,IAAI,SAAS,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC;AAC9F,CAAC"}
|
package/dist/types.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import type { CircuitRelayServerInit } from '@libp2p/circuit-relay-v2';
|
|
|
3
3
|
import type { IRawStorage, Libp2pConnectionMonitorInit, Libp2pTransports, NoiseCryptoInterface } from '@optimystic/db-p2p';
|
|
4
4
|
import type { IPeerNetwork, IRepo } from '@optimystic/db-core';
|
|
5
5
|
import type { PeerJoinBackfillConfig } from './peer-join-backfill.js';
|
|
6
|
+
import type { StrandReactivityConfig } from './strand-reactivity.js';
|
|
6
7
|
import type { StrandRevocationEnforcementConfig } from './strand-revocation-enforcer.js';
|
|
7
8
|
import type { StrandMembershipReconciliationConfig } from './strand-membership-reconciler.js';
|
|
8
9
|
import type { StrandFirstSyncConfig } from './strand-first-sync-gate.js';
|
|
@@ -763,6 +764,24 @@ export interface CadreNodeConfig {
|
|
|
763
764
|
* separately tuned catch-up — see {@link controlBackfill}.
|
|
764
765
|
*/
|
|
765
766
|
strandBackfill?: PeerJoinBackfillConfig;
|
|
767
|
+
/**
|
|
768
|
+
* Optimystic change notifications on this node's strand nodes (`strand-reactivity.ts`):
|
|
769
|
+
* a strand node built with them announces the commits whose collection log tail it applied,
|
|
770
|
+
* and an sApp table tagged `"optimystic.network_watch" = true` wakes its `Database.watch`
|
|
771
|
+
* subscribers on another machine's commit instead of only on local ones. Default off; with
|
|
772
|
+
* it off every strand node is built exactly as before. `strandIds` narrows it to chosen
|
|
773
|
+
* strands, independently of `strandFilter` (which decides whether a strand runs at all).
|
|
774
|
+
*
|
|
775
|
+
* Frozen when the strand's libp2p node is built: a change takes effect at the next build —
|
|
776
|
+
* a restart, or the strand's next wake from hibernation. Every machine serving the strand
|
|
777
|
+
* should enable it, because a node without it neither announces nor serves as part of the
|
|
778
|
+
* group a notification is rooted at. Enabling registers Optimystic's change-notification
|
|
779
|
+
* protocol handlers on the strand node, which the closed-strand per-stream gate does not
|
|
780
|
+
* cover, and each watched table pays a cold-start proof of work on every node build. Both
|
|
781
|
+
* are spelled out in `docs/strands.md` → "Change notifications (reactivity)". The control
|
|
782
|
+
* node never gets it.
|
|
783
|
+
*/
|
|
784
|
+
strandReactivity?: StrandReactivityConfig;
|
|
766
785
|
/**
|
|
767
786
|
* Tuning for the CONTROL network's peer-join block catch-up (same module,
|
|
768
787
|
* `peer-join-backfill.ts`, wired in `CadreNode.start`): when the control
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAqFA;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAA6C;IAC5E,QAAQ,EAAE;QACR,WAAW,EAAE,QAAQ,EAAS,aAAa;QAC3C,gBAAgB,EAAE,QAAQ,EAAI,kBAAkB;QAChD,eAAe,EAAE,QAAQ,EAAK,MAAM;QACpC,oBAAoB,EAAE,CAAC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,EAAE,UAAU,EAAE,KAAM,EAAE,UAAU,EAAE,KAAM,EAAE,CAAC;CACjC,CAAC,CAAC;AAmBzC;;;GAGG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,EAAE,GAAG,IAAI,CAAC;AAYnD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,OAAO,EACL,gBAAgB,EAChB,uBAAuB,EACvB,2BAA2B,EAC3B,sBAAsB,EACtB,2BAA2B,EAC3B,qBAAqB,EACrB,wBAAwB,EACxB,sBAAsB,EACtB,oBAAoB,EACpB,mBAAmB,EACpB,MAAM,+BAA+B,CAAC;AAEvC;;;;;GAKG;AACH,OAAO,EAAE,2BAA2B,EAAE,MAAM,kBAAkB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@serfab/cadre-core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.13.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Core library for Sereus cadre nodes - manages control networks and strand participation",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
"@libp2p/tcp": "^11.0.28",
|
|
78
78
|
"@libp2p/webrtc": "6.0.33",
|
|
79
79
|
"@libp2p/websockets": "^10.1.21",
|
|
80
|
-
"@optimystic/db-p2p-storage-fs": "^1.
|
|
80
|
+
"@optimystic/db-p2p-storage-fs": "^1.11.0",
|
|
81
81
|
"@types/debug": "^4.1.12",
|
|
82
82
|
"@types/node": "^25.0.10",
|
|
83
83
|
"@vitest/coverage-v8": "^4.0.17",
|
|
@@ -93,12 +93,12 @@
|
|
|
93
93
|
"@libp2p/peer-id": "^6.0.15",
|
|
94
94
|
"@libp2p/peer-record": "^9.0.16",
|
|
95
95
|
"@multiformats/multiaddr": "^13.0.3",
|
|
96
|
-
"@optimystic/db-core": "^1.
|
|
97
|
-
"@optimystic/db-p2p": "^1.
|
|
98
|
-
"@optimystic/quereus-plugin-crypto": "^1.
|
|
99
|
-
"@optimystic/quereus-plugin-optimystic": "^1.
|
|
100
|
-
"@quereus/quereus": "^4.20.
|
|
101
|
-
"@serfab/quereus-plugin-sereus": "^1.
|
|
96
|
+
"@optimystic/db-core": "^1.11.0",
|
|
97
|
+
"@optimystic/db-p2p": "^1.11.0",
|
|
98
|
+
"@optimystic/quereus-plugin-crypto": "^1.11.0",
|
|
99
|
+
"@optimystic/quereus-plugin-optimystic": "^1.11.0",
|
|
100
|
+
"@quereus/quereus": "^4.20.1",
|
|
101
|
+
"@serfab/quereus-plugin-sereus": "^1.13.0",
|
|
102
102
|
"debug": "^4.4.3",
|
|
103
103
|
"libp2p": "^3.3.11",
|
|
104
104
|
"uint8arrays": "^6.1.1"
|