@serfab/quereus-plugin-sereus 0.8.1 → 0.10.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.
@@ -1 +1 @@
1
- {"version":3,"file":"strand-schema.js","sourceRoot":"","sources":["../src/strand-schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4I5B,CAAC"}
1
+ {"version":3,"file":"strand-schema.js","sourceRoot":"","sources":["../src/strand-schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuf5B,CAAC"}
package/dist/types.d.ts CHANGED
@@ -18,6 +18,15 @@ export interface StrandConnectionOptions {
18
18
  enableCache?: boolean;
19
19
  /** FRET profile (default: 'edge') */
20
20
  fretProfile?: 'edge' | 'core';
21
+ /**
22
+ * Number of nodes Optimystic is told this strand's replication cluster should
23
+ * have. Ignored when {@link libp2pNode} is injected (the injected node was
24
+ * built with its own value). Every peer on the strand should use the same
25
+ * number — see `resolveStrandClusterSize`. Defaults to
26
+ * `DEFAULT_STRAND_CLUSTER_SIZE` (4 — the smallest breadth whose 0.75
27
+ * super-majority still commits with one holder offline).
28
+ */
29
+ clusterSize?: number;
21
30
  /** Inject an existing libp2p node instead of creating one */
22
31
  libp2pNode?: Libp2p;
23
32
  /** Required when libp2pNode is provided */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@serfab/quereus-plugin-sereus",
3
- "version": "0.8.1",
3
+ "version": "0.10.0",
4
4
  "type": "module",
5
5
  "description": "Quereus plugin that connects to a Sereus strand for SQL access",
6
6
  "main": "dist/index.js",
@@ -67,13 +67,13 @@
67
67
  "@libp2p/circuit-relay-v2": "^4.1.3",
68
68
  "@libp2p/interface": "^3.1.0",
69
69
  "@libp2p/websockets": "^10.1.3",
70
- "@optimystic/db-core": "^0.14.1",
71
- "@optimystic/db-p2p": "^0.14.1",
72
- "@optimystic/db-p2p-storage-fs": "^0.14.1",
73
- "@optimystic/db-p2p-storage-web": "^0.14.1",
74
- "@optimystic/quereus-plugin-crypto": "^0.14.1",
75
- "@optimystic/quereus-plugin-optimystic": "^0.14.1",
76
- "@quereus/quereus": "^4.2.1",
70
+ "@optimystic/db-core": "^0.22.0",
71
+ "@optimystic/db-p2p": "^0.22.0",
72
+ "@optimystic/db-p2p-storage-fs": "^0.22.0",
73
+ "@optimystic/db-p2p-storage-web": "^0.22.0",
74
+ "@optimystic/quereus-plugin-crypto": "^0.22.0",
75
+ "@optimystic/quereus-plugin-optimystic": "^0.22.0",
76
+ "@quereus/quereus": "^4.10.0",
77
77
  "debug": "^4.4.3"
78
78
  },
79
79
  "quereus": {
@@ -0,0 +1,248 @@
1
+ import type { NodeOptions } from '@optimystic/db-p2p';
2
+
3
+ /**
4
+ * Smallest cluster size Optimystic will honour — its own `minAbsoluteClusterSize`,
5
+ * and the smallest value that reaches the cluster path at all (a lone node writes to
6
+ * local storage without forming a cluster). A validation floor, not a default.
7
+ */
8
+ export const MIN_CLUSTER_SIZE = 2;
9
+
10
+ /**
11
+ * How many nodes each block of the **control** (cadre membership) database is replicated
12
+ * to. Chosen to exceed any party's node count, so in practice every control block lands
13
+ * on every member of the party.
14
+ *
15
+ * **Why full replication here.** Every control node reads the whole control database —
16
+ * membership, peer addresses, the strand list — so a member left out of a block's cohort is
17
+ * a member that may never learn the fact, and at a cohort of two the *read repair* that is
18
+ * supposed to make that safe cannot converge (it can ask exactly one peer, and that peer may
19
+ * be the member that also missed the write). Measured: 4 failures in 10 runs of the
20
+ * control-DB replication scenario at size 2, 0 in 20 at size 3 and 0 in 10 at size 8.
21
+ *
22
+ * **Why this number, and why a constant.** Optimystic caps a cohort at the peers that
23
+ * actually serve the network and downsizes a cohort it cannot fill (`allowDownsize: true`,
24
+ * which Cadre passes), so any value at or above the party's node count yields the same
25
+ * behaviour: cohort = whole party. 16 is roughly twice the largest deployment the product
26
+ * documents (`docs/architecture.md` → "Enterprise (Multi-Node Mixed)", 7 nodes) — headroom
27
+ * without pretending to support arbitrarily large parties; a party genuinely running more
28
+ * than 16 nodes is back to partial replication for its control database and should raise
29
+ * this. It is a constant rather than the live member count because Optimystic freezes the
30
+ * value at libp2p-node construction, before the `ControlDatabase` holding the `CadrePeer`
31
+ * rows exists, and because a per-node derivation lets two members disagree.
32
+ *
33
+ * A cadre is one party by construction, so the owner-blind cohort-selection question that
34
+ * applies to strand networks (see {@link DEFAULT_STRAND_CLUSTER_SIZE} below) is not a question
35
+ * here: "replicate to the whole party" already is the whole intent, and there is no party
36
+ * diversity for this breadth to buy or fail to buy.
37
+ *
38
+ * Canonical explanation of all of the above — the read-repair mechanics, what whole-party
39
+ * breadth does and does not remove, and what the wider cohort costs in write availability —
40
+ * is `docs/architecture.md` → "Replication cluster size". Keep it there, not here.
41
+ *
42
+ * **Deliberately not `clusterPolicy.assumedClusterSize`.** That option means "the smallest
43
+ * cohort this deployment can genuinely field", and it feeds both the membership admission
44
+ * gate's low-confidence path *and* the read-repair/reconcile corroboration floor. A Cadre
45
+ * party legitimately runs one or two nodes, so Cadre leaves it at Optimystic's default of 2;
46
+ * asserting 16 there would make the admission gate demand `ceil(0.75 x 16) = 12` declared
47
+ * peers and refuse every real party's writes.
48
+ *
49
+ * NOTE: cohort selection overfetches proportionally to this number —
50
+ * `Libp2pKeyPeerNetwork.membershipOverfetch` asks FRET for
51
+ * `max(clusterSize * 4, clusterSize + 16)` candidates and does a peerStore protocol lookup
52
+ * per candidate, so 16 requests a 64-peer proximity band. Free today, because the result is
53
+ * bounded by the peers FRET actually knows (2 in a 3-node party). If control-network cohort
54
+ * selection ever shows up as slow on a large mesh, look here first.
55
+ */
56
+ export const CONTROL_REPLICATION_BREADTH = 16;
57
+
58
+ /**
59
+ * Cluster consensus policy every CONTROL-network libp2p node runs — production
60
+ * (`CadreNode.buildControlNodeOptions`) and the integration harness alike. One definition so
61
+ * the two cannot drift: the object literal used to be hand-copied at both sites, and the copy
62
+ * at the harness had picked up a `superMajorityThreshold` override production never had.
63
+ *
64
+ * `superMajorityThreshold` is deliberately ABSENT. Omitting it makes both the cluster member
65
+ * and the coordinator fall back to Optimystic's `DEFAULT_SUPER_MAJORITY_THRESHOLD` (0.75) —
66
+ * the bar a real party commits control writes against. Setting it here, or at any one
67
+ * consumer, reintroduces exactly the divergence this constant exists to prevent. The absence
68
+ * is a researched decision, not an inherited default: no threshold both relaxes the
69
+ * three-node unanimity bar and satisfies Optimystic's partition-safety condition at the
70
+ * shipped admission fraction — see `docs/architecture.md` → "Replication cluster size".
71
+ *
72
+ * `sizeTolerance` only makes sense alongside `allowDownsize`: a fixed
73
+ * {@link CONTROL_REPLICATION_BREADTH}-wide target is unsatisfiable by any real (2-7 node)
74
+ * party, so the cohort must be allowed to shrink to the party that actually exists.
75
+ *
76
+ * NOT for strand networks: {@link STRAND_CLUSTER_POLICY} is a structurally identical object
77
+ * for a different network with different reasoning. The shape match is a coincidence; keep
78
+ * them separate.
79
+ *
80
+ * `assumedClusterSize` is REQUIRED here, and 2 is not a guess — it is the smallest party we
81
+ * support. The field feeds two Optimystic consumers with opposite failure modes, and only one
82
+ * of them defaults to something workable for us:
83
+ *
84
+ * - The membership admission gate already defaults to 2 (`minAbsoluteClusterSize`), so naming
85
+ * it changes nothing there.
86
+ * - The read-repair / reconcile corroboration floor does NOT. Absent this field it falls back
87
+ * to `clusterSize` — which for the control network is {@link CONTROL_REPLICATION_BREADTH},
88
+ * 16. `corroboratorCapacity(peers, 16)` is then `max(peers, 15)`, so the floor of two
89
+ * distinct non-self corroborators binds. A two-node party fields exactly one, can never
90
+ * reach two, and so can never repair a block: `cluster-fetch:no-quorum` forever.
91
+ *
92
+ * Declaring 2 does NOT lower the replication factor — that stays at
93
+ * {@link CONTROL_REPLICATION_BREADTH}. It states the cohort size we can genuinely field, which
94
+ * is what the corroboration floor is asking. See Optimystic's `cluster/cluster-policy.ts`
95
+ * ("Why two size yardsticks, not one") and `corroboratorCapacity` in `cluster/quorum-restore.ts`.
96
+ *
97
+ * The `satisfies` is load-bearing: without it a mistyped or obsolete key would compile at both
98
+ * this definition and every consumer, because TypeScript only excess-property-checks fresh
99
+ * object literals, not a shared constant handed to `clusterPolicy`.
100
+ */
101
+ export const CONTROL_CLUSTER_POLICY = Object.freeze({
102
+ allowDownsize: true,
103
+ sizeTolerance: 0.5,
104
+ assumedClusterSize: 2,
105
+ } satisfies NonNullable<NodeOptions['clusterPolicy']>);
106
+
107
+ /**
108
+ * Default number of nodes a **strand** network is told its replication cluster should have.
109
+ *
110
+ * Strand data is application data, where partial replication is a legitimate choice: only
111
+ * the control database's every-member-reads-all-of-it character forces full replication
112
+ * ({@link CONTROL_REPLICATION_BREADTH}). So the question here is not "everyone" but "how
113
+ * few is too few", and the answer is four.
114
+ *
115
+ * **Why four.** A write commits when a super-majority of the cohort approves, and that bar is
116
+ * Optimystic's `DEFAULT_SUPER_MAJORITY_THRESHOLD` of 0.75 — which Cadre selects by naming no
117
+ * threshold at all (see {@link CONTROL_CLUSTER_POLICY}). Approvals needed is
118
+ * `ceil(cohort x 0.75)`, so:
119
+ *
120
+ * | copies | approvals needed | holders that may be offline |
121
+ * |--------|------------------|-----------------------------|
122
+ * | 2 | 2 | 0 |
123
+ * | 3 | 3 | 0 |
124
+ * | 4 | 3 | 1 |
125
+ * | 5 | 4 | 1 |
126
+ * | 6 | 5 | 1 |
127
+ *
128
+ * Four is the smallest breadth that lets a write commit while one holder is away. At two or
129
+ * three every holder must be awake for every write, which for a workspace shared between
130
+ * phones and laptops is the ordinary case, not the rare one. Six buys no more fault tolerance
131
+ * than four and costs more overfetch (see the NOTE below).
132
+ *
133
+ * **It is also a correctness floor, not only a durability one — but the floor is measured in
134
+ * machines, not in this number.** A node that has fallen behind and can ask exactly one peer
135
+ * whether it is current has Optimystic accept that single answer as the cluster's truth
136
+ * (`corroboratorCapacity` in `db-p2p/src/cluster/quorum-restore.ts` lowers the corroboration
137
+ * floor to one when the cohort cannot hold a second voter). If that peer is also behind it
138
+ * honestly reports the stale revision, the reader concludes it is current, and re-arms its
139
+ * repair window forever. Measured on the control-DB replication scenario: 4 failures in 10 runs
140
+ * at breadth 2, 0 in 20 at breadth 3, 0 in 10 at breadth 8. What lifts the floor off a single
141
+ * voter is a *third machine*, not a wider target: `corroboratorCapacity` takes the cohort peers
142
+ * actually present against {@link STRAND_CLUSTER_POLICY}'s declared `assumedClusterSize`, so a
143
+ * three-machine strand needs two corroborators whatever this number says, and a two-machine one
144
+ * cannot supply them however wide the target is. The underlying Optimystic behaviour is unfixed
145
+ * — `backlog/debt-read-repair-single-voter-corroboration` — so a two-machine strand still takes
146
+ * the exposure. Raising this number does not buy the way out; adding a machine does.
147
+ *
148
+ * **Why not derived from the party or member count.** The strand's `Member` rows live *in* the
149
+ * strand database, which runs on the strand libp2p node, whose cluster size is frozen at
150
+ * construction — reading the list to configure the node needs the node to exist. Open strands
151
+ * have no member list at all. The count also changes in the unsafe direction: a node that
152
+ * restarted after someone joined derives a wider expected cohort than one that did not, and the
153
+ * membership admission gate's confident path is what rejects the *wider* view. And a `Member` is
154
+ * a party, not a machine; cohort width consumes machines. Full reasoning in
155
+ * `docs/architecture.md` → "Replication cluster size".
156
+ *
157
+ * **Four machines, not four parties.** This number counts machines, and today that is not the
158
+ * same as counting independent holders. Cohort selection upstream is owner-blind — it
159
+ * picks nodes by hash proximity with no concept of which peer belongs to which party
160
+ * (`optimystic/tickets/backlog/feat-cohort-selection-owner-aware-placement`) — and on the
161
+ * cadre-driven path, the one that resolves a seed for itself, a strand's libp2p mesh is seeded
162
+ * from exactly one party's own control-database peer rows (`CadreNode.resolveCohortSeed`), so
163
+ * the cohort actually formed is that one party's machines. Four copies are, on that path, four
164
+ * machines belonging to one party — one failure domain, one witness. A cross-party mesh is not
165
+ * forbidden, only undiscoverable: it takes hand-supplied addresses
166
+ * (`StrandConnectionOptions.bootstrapNodes`) or a hand-written dial (see the doc). Tracked:
167
+ * `backlog/feat-strand-party-identity`. Full reasoning: `docs/architecture.md` →
168
+ * "Replication cluster size".
169
+ *
170
+ * Raising or lowering it per strand is still the embedder's call
171
+ * ({@link resolveStrandClusterSize}, `CadreNodeConfig.strandClusterSize`,
172
+ * `StrandConnectionOptions.clusterSize`) — but every node on one strand must agree, so a change
173
+ * means restarting all of them. There is no smaller-than-{@link MIN_CLUSTER_SIZE} option.
174
+ *
175
+ * NOTE: cohort selection overfetches proportionally — `Libp2pKeyPeerNetwork.membershipOverfetch`
176
+ * asks FRET for `max(clusterSize * 4, clusterSize + 16)` candidates and does one peerStore
177
+ * protocol lookup per candidate, so 4 requests a 20-peer band (was 18 at breadth 2). Negligible,
178
+ * and bounded by the peers FRET actually knows. If strand cohort selection ever shows up as slow,
179
+ * look here first.
180
+ */
181
+ export const DEFAULT_STRAND_CLUSTER_SIZE = 4;
182
+
183
+ /**
184
+ * Cluster consensus policy every STRAND-network libp2p node runs — production
185
+ * (`StrandInstanceManager.buildStrandRuntime`) and the plugin's own networked e2e mesh alike.
186
+ * One definition so the two cannot drift; the literal used to be hand-copied at both sites.
187
+ *
188
+ * Structurally identical to {@link CONTROL_CLUSTER_POLICY} and deliberately separate from it:
189
+ * that one is the control database's, whose breadth is fixed at
190
+ * {@link CONTROL_REPLICATION_BREADTH} for reasons that do not apply to application data.
191
+ *
192
+ * `superMajorityThreshold` is ABSENT for the same reason it is absent there: omitting it is how
193
+ * both the coordinator and the cluster member select Optimystic's
194
+ * `DEFAULT_SUPER_MAJORITY_THRESHOLD` (0.75), the bar {@link DEFAULT_STRAND_CLUSTER_SIZE}'s
195
+ * copies/approvals table is computed against.
196
+ *
197
+ * `sizeTolerance` only makes sense alongside `allowDownsize`: a {@link
198
+ * DEFAULT_STRAND_CLUSTER_SIZE}-wide target is unsatisfiable by a strand of one, two or three
199
+ * machines, so the cohort must be allowed to shrink to the mesh that actually exists.
200
+ *
201
+ * `assumedClusterSize` is REQUIRED, and {@link MIN_CLUSTER_SIZE} is not a guess — it is the
202
+ * smallest strand that reaches the cluster path at all. Absent this field the read-repair /
203
+ * reconcile corroboration floor falls back to `clusterSize`, so
204
+ * `corroboratorCapacity(peers, 4)` is `max(peers, 3)` and two distinct non-self corroborators
205
+ * become mandatory. A two-machine strand fields exactly one peer, can never reach two, and so
206
+ * can never repair a block — `cluster-fetch:no-quorum` forever, which is a read that never
207
+ * catches up and a `create table` that dies with `Missing block` on the joining node. Declaring
208
+ * the honest floor does NOT lower the replication factor (that stays at
209
+ * {@link DEFAULT_STRAND_CLUSTER_SIZE}) and does not relax anything a strand with three or more
210
+ * machines does: `corroboratorCapacity` takes the MAX of the cohort actually present and this
211
+ * number, so the relaxed branch is reachable only by a cohort that is genuinely that small. See
212
+ * Optimystic's `cluster/cluster-policy.ts` ("Why two size yardsticks, not one").
213
+ *
214
+ * The `satisfies` is load-bearing for the same reason as {@link CONTROL_CLUSTER_POLICY}'s.
215
+ */
216
+ export const STRAND_CLUSTER_POLICY = Object.freeze({
217
+ allowDownsize: true,
218
+ sizeTolerance: 0.5,
219
+ assumedClusterSize: MIN_CLUSTER_SIZE,
220
+ } satisfies NonNullable<NodeOptions['clusterPolicy']>);
221
+
222
+ /**
223
+ * Resolve the cluster size to hand `createLibp2pNode` for a **strand** network, applying
224
+ * {@link DEFAULT_STRAND_CLUSTER_SIZE} and rejecting values Optimystic cannot honour. The
225
+ * control network does not route through here — it uses the fixed
226
+ * {@link CONTROL_REPLICATION_BREADTH}.
227
+ *
228
+ * Leaving the value unset is NOT the same as passing the default: Optimystic's own fallback
229
+ * is 10, so every strand node-creating path must route through here.
230
+ *
231
+ * Every node on the same strand should resolve to the same value: the membership admission
232
+ * gate's *confident* path compares a coordinator's declared set against the member's own
233
+ * cohort view, and that view is bounded by this number, so a member configured much higher
234
+ * can reject a smaller declared set as a downsize. Divergence is a live hazard whenever FRET
235
+ * has a confident network-size estimate — not the unconditional refusal earlier revisions of
236
+ * this comment described. See `docs/architecture.md` → "Replication cluster size".
237
+ */
238
+ export function resolveStrandClusterSize(configured?: number): number {
239
+ if (configured === undefined) {
240
+ return DEFAULT_STRAND_CLUSTER_SIZE;
241
+ }
242
+ if (!Number.isInteger(configured) || configured < MIN_CLUSTER_SIZE) {
243
+ throw new Error(
244
+ `clusterSize must be an integer >= ${MIN_CLUSTER_SIZE} (Optimystic's minimum cluster size); got ${configured}`
245
+ );
246
+ }
247
+ return configured;
248
+ }
@@ -6,6 +6,7 @@ import type { IRepo } from '@optimystic/db-core';
6
6
  import type { IRawStorage } from '@optimystic/db-p2p';
7
7
  import type { StrandConnectionOptions, SereusPluginResult, Libp2pNodeWithRepo } from './types.js';
8
8
  import { STRAND_SCHEMA } from './strand-schema.js';
9
+ import { resolveStrandClusterSize } from './cluster-size.js';
9
10
 
10
11
  const log = debug('sereus:plugin:strand');
11
12
  const timing = debug('sereus:plugin:strand:timing');
@@ -74,6 +75,12 @@ export interface CreateNodeContext {
74
75
  fretProfile: 'edge' | 'core';
75
76
  /** libp2p listening port (Node TCP). Browser transports ignore it. */
76
77
  port: number;
78
+ /**
79
+ * Resolved replication cluster size. Already defaulted — pass it to
80
+ * `createLibp2pNode` verbatim; omitting it falls back to Optimystic's own
81
+ * default of 10, which gates writes on any smaller party.
82
+ */
83
+ clusterSize: number;
77
84
  /** Resolved persistent storage to back the node, if any. */
78
85
  storage?: IRawStorage;
79
86
  }
@@ -139,6 +146,10 @@ export async function composeStrand(
139
146
  mode,
140
147
  } = options;
141
148
 
149
+ // Resolve (and validate) up front so a nonsense value fails before any plugin
150
+ // registration or node creation has happened.
151
+ const clusterSize = resolveStrandClusterSize(options.clusterSize);
152
+
142
153
  // Resolve the transactor. `mode` is the public knob: bootstrap -> local,
143
154
  // networked -> network. The legacy `transactor` override (used by unit
144
155
  // tests with `'test'`) only applies when `mode` is unspecified.
@@ -209,7 +220,7 @@ export async function composeStrand(
209
220
  coordinatedRepo = options.coordinatedRepo;
210
221
  log('Using injected libp2p node');
211
222
  } else {
212
- const created = await platform.createNode({ networkName, bootstrapNodes, fretProfile, port, storage });
223
+ const created = await platform.createNode({ networkName, bootstrapNodes, fretProfile, port, clusterSize, storage });
213
224
  createdNode = created;
214
225
  node = created;
215
226
  const repo = (created as Libp2pNodeWithRepo).coordinatedRepo;
@@ -254,7 +265,7 @@ export async function composeStrand(
254
265
  //
255
266
  // This ticket only makes the tables present and their constraints active;
256
267
  // nothing here writes membership rows. Founder bootstrap (Header, founding
257
- // Authority/Member, invite/peer flows) is owned by the lifecycle ticket
268
+ // Manager/Member, invite/peer flows) is owned by the lifecycle ticket
258
269
  // `strand-membership-lifecycle-population`.
259
270
  log('Applying Strand membership schema for strand %s', strandId);
260
271
  await db.exec(`
@@ -42,13 +42,14 @@ export async function connectToStrandBrowser(
42
42
  const dbHandle = await openOptimysticWebDb(`sereus-strand-${strandId}`);
43
43
  return new IndexedDBRawStorage(dbHandle);
44
44
  },
45
- async createNode({ networkName, bootstrapNodes, fretProfile, storage }) {
45
+ async createNode({ networkName, bootstrapNodes, fretProfile, clusterSize, storage }) {
46
46
  return createLibp2pNode({
47
47
  transports: [webSockets(), circuitRelayTransport()],
48
48
  listenAddrs: [],
49
49
  bootstrapNodes,
50
50
  networkName,
51
51
  fretProfile,
52
+ clusterSize,
52
53
  ...(storage && { storage }),
53
54
  }) as Promise<Libp2p>;
54
55
  },
package/src/connect.ts CHANGED
@@ -20,7 +20,7 @@ export async function connectToStrand(
20
20
  async registerCrypto(database) {
21
21
  await registerPlugin(database, cryptoPlugin);
22
22
  },
23
- async createNode({ networkName, bootstrapNodes, fretProfile, port, storage }) {
23
+ async createNode({ networkName, bootstrapNodes, fretProfile, port, clusterSize, storage }) {
24
24
  // Dynamically import to keep the module cross-platform friendly: this
25
25
  // pulls the Node-only `@optimystic/db-p2p` (TCP) entry, and is only
26
26
  // reached when actually creating a node (never for injected nodes).
@@ -30,6 +30,7 @@ export async function connectToStrand(
30
30
  bootstrapNodes,
31
31
  networkName,
32
32
  fretProfile,
33
+ clusterSize,
33
34
  ...(storage && { storage }),
34
35
  }) as Promise<Libp2p>;
35
36
  },
package/src/index.ts CHANGED
@@ -1,2 +1,10 @@
1
1
  export { connectToStrand } from './connect.js';
2
+ export {
3
+ MIN_CLUSTER_SIZE,
4
+ CONTROL_REPLICATION_BREADTH,
5
+ CONTROL_CLUSTER_POLICY,
6
+ DEFAULT_STRAND_CLUSTER_SIZE,
7
+ STRAND_CLUSTER_POLICY,
8
+ resolveStrandClusterSize
9
+ } from './cluster-size.js';
2
10
  export type { StrandConnectionOptions, SereusPluginResult } from './types.js';