@optimystic/db-core 1.5.1 → 1.7.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.
@@ -205,6 +205,19 @@ export type ClusterRecord = {
205
205
  * 0.75 = 3/4: chosen because the coordinator (which actually commits) already used it and the type documents it.
206
206
  */
207
207
  export declare const DEFAULT_SUPER_MAJORITY_THRESHOLD = 0.75;
208
+ /**
209
+ * Single source of truth for the default per-peer cohort read deadline, in milliseconds — how long
210
+ * one cohort peer gets to answer one read-path request (the latest-revision query, and the archive
211
+ * fetch that follows it). Placed beside {@link DEFAULT_SUPER_MAJORITY_THRESHOLD} for the same
212
+ * reason: every tier that falls back to a default references THIS constant, so the coordinator and
213
+ * the node's archive fetch cannot silently default differently.
214
+ *
215
+ * 1000 = 1s: the value both deadlines were hardcoded at, so a node that declares nothing behaves
216
+ * exactly as before. It is a LAN-shaped budget — a relayed link whose round trip is near 1.8s
217
+ * cannot finish a fresh stream inside it, which is what
218
+ * {@link ClusterConsensusConfig.cohortQueryTimeoutMs} exists to raise.
219
+ */
220
+ export declare const DEFAULT_COHORT_QUERY_TIMEOUT_MS = 1000;
208
221
  export interface ClusterConsensusConfig {
209
222
  /** Super-majority threshold for promises (default {@link DEFAULT_SUPER_MAJORITY_THRESHOLD} = 0.75 = 3/4) */
210
223
  superMajorityThreshold: number;
@@ -285,6 +298,30 @@ export interface ClusterConsensusConfig {
285
298
  readRepairWindowMs?: number;
286
299
  /** Per-read probability of triggering read-repair in 'lazy' mode even within the window (0..1). Default 0 (no random check). */
287
300
  readRepairSampleRate?: number;
301
+ /**
302
+ * How long ONE cohort peer gets to answer ONE read-path request, in milliseconds (default
303
+ * {@link DEFAULT_COHORT_QUERY_TIMEOUT_MS} = 1000). It sets BOTH per-peer deadlines on the read
304
+ * path — the latest-revision query (`CoordinatorRepo.queryClusterForLatest`) and the archive
305
+ * fetch the acquisition runs (`fetchArchiveFromPeer` in `libp2p-node-base.ts`) — because they
306
+ * are the same kind of round trip to the same peer over the same protocol, and raising one while
307
+ * the other still expires would fix nothing.
308
+ *
309
+ * Raise it for a deployment whose links are slower than a LAN: two phones reaching each other
310
+ * only through a public circuit relay have a round trip near 1.8s, and every fresh stream (dial
311
+ * or reuse, protocol select, send, receive) must fit inside this budget or the peer counts as
312
+ * silent. In a two-member cohort one late answer is the whole quorum, so the consult declines
313
+ * every time and a rejoining node never catches up.
314
+ *
315
+ * Fractional values are accepted — this is a duration, not a count of peers. A value that is not
316
+ * a finite number above zero, or is large enough that the deadlines derived from it overflow the
317
+ * 32-bit delay `setTimeout` accepts (roughly 4.97 days, the one way a unit mix-up shows up), is a
318
+ * configuration error and throws at node construction rather than silently falling back to the
319
+ * default (see `resolveCohortQueryTimeoutMs` in db-p2p's `cluster/cluster-policy.ts`).
320
+ *
321
+ * The whole-pass reconcile bound is derived from this rather than declared separately; see
322
+ * `reconcilePassTimeoutMs` in the same module.
323
+ */
324
+ cohortQueryTimeoutMs?: number;
288
325
  /**
289
326
  * When FRET has no confident network-size estimate, allow an undersized cluster
290
327
  * (peerCount < minAbsoluteClusterSize) to proceed anyway. Default false: with no
@@ -1 +1 @@
1
- {"version":3,"file":"structs.d.ts","sourceRoot":"","sources":["../../../src/cluster/structs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAErE;;;;;;;GAOG;AACH,MAAM,MAAM,SAAS,GAClB;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,GACtC;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,CAAA;CAAE;AAC9D;;;;;GAKG;GACD;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC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C,EAAE,MAAM,CAAC;IACrC,6EAA6E;IAC7E,wBAAwB,EAAE,MAAM,CAAC;IACjC,yDAAyD;IACzD,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,sEAAsE;IACtE,2BAA2B,CAAC,EAAE,MAAM,CAAC;IACrC;;;;OAIG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;;;OAKG;IACH,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,sFAAsF;IACtF,6BAA6B,CAAC,EAAE,MAAM,CAAC;IACvC,wEAAwE;IACxE,iCAAiC,CAAC,EAAE,MAAM,CAAC;IAC3C,sDAAsD;IACtD,iCAAiC,CAAC,EAAE,MAAM,CAAC;IAC3C,gEAAgE;IAChE,+BAA+B,CAAC,EAAE,MAAM,CAAC;IACzC,iFAAiF;IACjF,+BAA+B,CAAC,EAAE,MAAM,CAAC;IACzC;;;;;;;OAOG;IACH,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC,yPAAyP;IACzP,cAAc,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,UAAU,CAAC;IAC7C,4GAA4G;IAC5G,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,gIAAgI;IAChI,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B;;;;;OAKG;IACH,4BAA4B,CAAC,EAAE,OAAO,CAAC;IACvC;;;OAGG;IACH,uBAAuB,CAAC,EAAE,uBAAuB,CAAC;CAClD;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,uBAAuB,GAAG,QAAQ,GAAG,QAAQ,CAAC"}
@@ -33,4 +33,17 @@ export function clusterVoteVerificationPayload(hash, signature) {
33
33
  * 0.75 = 3/4: chosen because the coordinator (which actually commits) already used it and the type documents it.
34
34
  */
35
35
  export const DEFAULT_SUPER_MAJORITY_THRESHOLD = 0.75;
36
+ /**
37
+ * Single source of truth for the default per-peer cohort read deadline, in milliseconds — how long
38
+ * one cohort peer gets to answer one read-path request (the latest-revision query, and the archive
39
+ * fetch that follows it). Placed beside {@link DEFAULT_SUPER_MAJORITY_THRESHOLD} for the same
40
+ * reason: every tier that falls back to a default references THIS constant, so the coordinator and
41
+ * the node's archive fetch cannot silently default differently.
42
+ *
43
+ * 1000 = 1s: the value both deadlines were hardcoded at, so a node that declares nothing behaves
44
+ * exactly as before. It is a LAN-shaped budget — a relayed link whose round trip is near 1.8s
45
+ * cannot finish a fresh stream inside it, which is what
46
+ * {@link ClusterConsensusConfig.cohortQueryTimeoutMs} exists to raise.
47
+ */
48
+ export const DEFAULT_COHORT_QUERY_TIMEOUT_MS = 1000;
36
49
  //# sourceMappingURL=structs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"structs.js","sourceRoot":"","sources":["../../../src/cluster/structs.ts"],"names":[],"mappings":"AAyCA;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,yBAAyB,CAAC,IAAY,EAAE,IAAuB,EAAE,KAAc;IAC9F,OAAO,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,IAAI,GAAG,GAAG,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AACjF,CAAC;AAED,8GAA8G;AAC9G,MAAM,UAAU,8BAA8B,CAAC,IAAY,EAAE,SAAoB;IAChF,QAAQ,SAAS,CAAC,IAAI,EAAE,CAAC;QACxB,KAAK,QAAQ,CAAC,CAAC,OAAO,yBAAyB,CAAC,IAAI,EAAE,QAAQ,EAAE,SAAS,CAAC,YAAY,CAAC,CAAC;QACxF,KAAK,UAAU,CAAC,CAAC,OAAO,yBAAyB,CAAC,IAAI,EAAE,UAAU,EAAE,SAAS,CAAC,YAAY,CAAC,CAAC;QAC5F,KAAK,MAAM,CAAC,CAAC,OAAO,yBAAyB,CAAC,IAAI,EAAE,MAAM,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AAG,IAAI,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optimystic/db-core",
3
- "version": "1.5.1",
3
+ "version": "1.7.0",
4
4
  "type": "module",
5
5
  "description": "Core database functionality for Optimystic",
6
6
  "main": "dist/src/index.js",
@@ -201,6 +201,20 @@ export type ClusterRecord = {
201
201
  */
202
202
  export const DEFAULT_SUPER_MAJORITY_THRESHOLD = 0.75;
203
203
 
204
+ /**
205
+ * Single source of truth for the default per-peer cohort read deadline, in milliseconds — how long
206
+ * one cohort peer gets to answer one read-path request (the latest-revision query, and the archive
207
+ * fetch that follows it). Placed beside {@link DEFAULT_SUPER_MAJORITY_THRESHOLD} for the same
208
+ * reason: every tier that falls back to a default references THIS constant, so the coordinator and
209
+ * the node's archive fetch cannot silently default differently.
210
+ *
211
+ * 1000 = 1s: the value both deadlines were hardcoded at, so a node that declares nothing behaves
212
+ * exactly as before. It is a LAN-shaped budget — a relayed link whose round trip is near 1.8s
213
+ * cannot finish a fresh stream inside it, which is what
214
+ * {@link ClusterConsensusConfig.cohortQueryTimeoutMs} exists to raise.
215
+ */
216
+ export const DEFAULT_COHORT_QUERY_TIMEOUT_MS = 1000;
217
+
204
218
  export interface ClusterConsensusConfig {
205
219
  /** Super-majority threshold for promises (default {@link DEFAULT_SUPER_MAJORITY_THRESHOLD} = 0.75 = 3/4) */
206
220
  superMajorityThreshold: number;
@@ -281,6 +295,30 @@ export interface ClusterConsensusConfig {
281
295
  readRepairWindowMs?: number;
282
296
  /** Per-read probability of triggering read-repair in 'lazy' mode even within the window (0..1). Default 0 (no random check). */
283
297
  readRepairSampleRate?: number;
298
+ /**
299
+ * How long ONE cohort peer gets to answer ONE read-path request, in milliseconds (default
300
+ * {@link DEFAULT_COHORT_QUERY_TIMEOUT_MS} = 1000). It sets BOTH per-peer deadlines on the read
301
+ * path — the latest-revision query (`CoordinatorRepo.queryClusterForLatest`) and the archive
302
+ * fetch the acquisition runs (`fetchArchiveFromPeer` in `libp2p-node-base.ts`) — because they
303
+ * are the same kind of round trip to the same peer over the same protocol, and raising one while
304
+ * the other still expires would fix nothing.
305
+ *
306
+ * Raise it for a deployment whose links are slower than a LAN: two phones reaching each other
307
+ * only through a public circuit relay have a round trip near 1.8s, and every fresh stream (dial
308
+ * or reuse, protocol select, send, receive) must fit inside this budget or the peer counts as
309
+ * silent. In a two-member cohort one late answer is the whole quorum, so the consult declines
310
+ * every time and a rejoining node never catches up.
311
+ *
312
+ * Fractional values are accepted — this is a duration, not a count of peers. A value that is not
313
+ * a finite number above zero, or is large enough that the deadlines derived from it overflow the
314
+ * 32-bit delay `setTimeout` accepts (roughly 4.97 days, the one way a unit mix-up shows up), is a
315
+ * configuration error and throws at node construction rather than silently falling back to the
316
+ * default (see `resolveCohortQueryTimeoutMs` in db-p2p's `cluster/cluster-policy.ts`).
317
+ *
318
+ * The whole-pass reconcile bound is derived from this rather than declared separately; see
319
+ * `reconcilePassTimeoutMs` in the same module.
320
+ */
321
+ cohortQueryTimeoutMs?: number;
284
322
  /**
285
323
  * When FRET has no confident network-size estimate, allow an undersized cluster
286
324
  * (peerCount < minAbsoluteClusterSize) to proceed anyway. Default false: with no