@optimystic/db-p2p 0.17.0 → 0.18.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.
Files changed (66) hide show
  1. package/dist/src/cluster/block-transfer-service.d.ts +10 -0
  2. package/dist/src/cluster/block-transfer-service.d.ts.map +1 -1
  3. package/dist/src/cluster/block-transfer-service.js +2 -1
  4. package/dist/src/cluster/block-transfer-service.js.map +1 -1
  5. package/dist/src/cluster/cluster-policy.d.ts +112 -0
  6. package/dist/src/cluster/cluster-policy.d.ts.map +1 -0
  7. package/dist/src/cluster/cluster-policy.js +88 -0
  8. package/dist/src/cluster/cluster-policy.js.map +1 -0
  9. package/dist/src/cluster/cluster-repo.d.ts +35 -11
  10. package/dist/src/cluster/cluster-repo.d.ts.map +1 -1
  11. package/dist/src/cluster/cluster-repo.js +88 -19
  12. package/dist/src/cluster/cluster-repo.js.map +1 -1
  13. package/dist/src/cluster/quorum-restore.d.ts +25 -3
  14. package/dist/src/cluster/quorum-restore.d.ts.map +1 -1
  15. package/dist/src/cluster/quorum-restore.js +27 -3
  16. package/dist/src/cluster/quorum-restore.js.map +1 -1
  17. package/dist/src/cluster/reconcile-block.d.ts +10 -2
  18. package/dist/src/cluster/reconcile-block.d.ts.map +1 -1
  19. package/dist/src/cluster/reconcile-block.js +38 -18
  20. package/dist/src/cluster/reconcile-block.js.map +1 -1
  21. package/dist/src/cluster/spread-on-churn.d.ts.map +1 -1
  22. package/dist/src/cluster/spread-on-churn.js +8 -0
  23. package/dist/src/cluster/spread-on-churn.js.map +1 -1
  24. package/dist/src/inbound-authorization.d.ts +6 -0
  25. package/dist/src/inbound-authorization.d.ts.map +1 -1
  26. package/dist/src/inbound-authorization.js +6 -0
  27. package/dist/src/inbound-authorization.js.map +1 -1
  28. package/dist/src/libp2p-key-network.d.ts +14 -0
  29. package/dist/src/libp2p-key-network.d.ts.map +1 -1
  30. package/dist/src/libp2p-key-network.js +54 -4
  31. package/dist/src/libp2p-key-network.js.map +1 -1
  32. package/dist/src/libp2p-node-base.d.ts +22 -23
  33. package/dist/src/libp2p-node-base.d.ts.map +1 -1
  34. package/dist/src/libp2p-node-base.js +22 -19
  35. package/dist/src/libp2p-node-base.js.map +1 -1
  36. package/dist/src/repo/cluster-coordinator.d.ts +21 -3
  37. package/dist/src/repo/cluster-coordinator.d.ts.map +1 -1
  38. package/dist/src/repo/cluster-coordinator.js +27 -5
  39. package/dist/src/repo/cluster-coordinator.js.map +1 -1
  40. package/dist/src/repo/coordinator-repo.d.ts +60 -26
  41. package/dist/src/repo/coordinator-repo.d.ts.map +1 -1
  42. package/dist/src/repo/coordinator-repo.js +218 -65
  43. package/dist/src/repo/coordinator-repo.js.map +1 -1
  44. package/dist/src/storage/storage-repo.d.ts +9 -0
  45. package/dist/src/storage/storage-repo.d.ts.map +1 -1
  46. package/dist/src/storage/storage-repo.js +56 -4
  47. package/dist/src/storage/storage-repo.js.map +1 -1
  48. package/dist/src/testing/mesh-harness.d.ts +10 -0
  49. package/dist/src/testing/mesh-harness.d.ts.map +1 -1
  50. package/dist/src/testing/mesh-harness.js +14 -1
  51. package/dist/src/testing/mesh-harness.js.map +1 -1
  52. package/package.json +2 -2
  53. package/readme.md +20 -0
  54. package/src/cluster/block-transfer-service.ts +9 -1
  55. package/src/cluster/cluster-policy.ts +152 -0
  56. package/src/cluster/cluster-repo.ts +93 -22
  57. package/src/cluster/quorum-restore.ts +28 -3
  58. package/src/cluster/reconcile-block.ts +52 -19
  59. package/src/cluster/spread-on-churn.ts +8 -0
  60. package/src/inbound-authorization.ts +6 -0
  61. package/src/libp2p-key-network.ts +54 -4
  62. package/src/libp2p-node-base.ts +42 -43
  63. package/src/repo/cluster-coordinator.ts +30 -6
  64. package/src/repo/coordinator-repo.ts +235 -73
  65. package/src/storage/storage-repo.ts +58 -6
  66. package/src/testing/mesh-harness.ts +15 -1
@@ -54,6 +54,16 @@ export interface BlockTransferServiceComponents {
54
54
  unhandle: (...args: any[]) => Promise<void>;
55
55
  };
56
56
  repo: IBlockReplicaStore;
57
+ /**
58
+ * Optional libp2p component logger. Supplied by the node factory so authorization denials
59
+ * land on the same `logger.forComponent(...).error` sink as the repo/cluster/sync services;
60
+ * without it they fall back to this module's `debug` logger.
61
+ */
62
+ logger?: {
63
+ forComponent: (name: string) => {
64
+ error: (message: string, ...args: unknown[]) => void;
65
+ };
66
+ };
57
67
  }
58
68
  /**
59
69
  * Libp2p service that handles incoming block transfer requests.
@@ -1 +1 @@
1
- {"version":3,"file":"block-transfer-service.d.ts","sourceRoot":"","sources":["../../../src/cluster/block-transfer-service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAc,SAAS,EAAU,MAAM,mBAAmB,CAAC;AACvE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAK7G,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAGvD,OAAO,EAAqE,KAAK,8BAA8B,EAAE,MAAM,6BAA6B,CAAC;AAQrJ,eAAO,MAAM,0BAA0B,GAAI,iBAAgB,MAAW,KAAG,MACJ,CAAC;AAEtE,iCAAiC;AACjC,MAAM,WAAW,oBAAoB;IACpC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IACtB,kCAAkC;IAClC,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,0BAA0B;IAC1B,MAAM,EAAE,WAAW,GAAG,aAAa,GAAG,UAAU,CAAC;IACjD,uDAAuD;IACvD,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACnC;;;;;OAKG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,QAAQ,CAAA;KAAE,CAAC,CAAC;CAChE;AAED,+BAA+B;AAC/B,MAAM,WAAW,qBAA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AAC,aAAa,CAAC,EAAE,MAAM,CAAC;QAAC,iBAAiB,CAAC,EAAE,MAAM,CAAA;KAAE,GACpF,OAAO,CAAC,qBAAqB,CAAC;IAKjC;;;;;;;;;;;;OAYG;IACG,UAAU,CACf,QAAQ,EAAE,MAAM,EAAE,EAClB,gBAAgB,EAAE,UAAU,EAAE,EAC9B,MAAM,GAAE,oBAAoB,CAAC,QAAQ,CAAe,EACpD,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,QAAQ,CAAA;KAAE,CAAC,EAC/D,OAAO,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,WAAW,CAAC;QAAC,aAAa,CAAC,EAAE,MAAM,CAAC;QAAC,iBAAiB,CAAC,EAAE,MAAM,CAAA;KAAE,GACpF,OAAO,CAAC,qBAAqB,CAAC;CAQjC"}
@@ -28,7 +28,8 @@ export class BlockTransferService {
28
28
  this.protocol = buildBlockTransferProtocol(init.protocolPrefix ?? '');
29
29
  this.repo = components.repo;
30
30
  this.registrar = components.registrar;
31
- this.authorization = createInboundStreamAuthorization(init, this.protocol, (msg, ...args) => log(msg, ...args));
31
+ const componentLog = components.logger?.forComponent('db-p2p:block-transfer');
32
+ this.authorization = createInboundStreamAuthorization(init, this.protocol, componentLog ? (msg, ...args) => componentLog.error(msg, ...args) : (msg, ...args) => log(msg, ...args));
32
33
  }
33
34
  async start() {
34
35
  if (this.running)
@@ -1 +1 @@
1
- {"version":3,"file":"block-transfer-service.js","sourceRoot":"","sources":["../../../src/cluster/block-transfer-service.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC/B,OAAO,KAAK,EAAE,MAAM,oBAAoB,CAAC;AACzC,OAAO,EAAE,UAAU,IAAI,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACrE,OAAO,EAAE,QAAQ,IAAI,UAAU,EAAE,MAAM,uBAAuB,CAAC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,MAAM,EAAE,SAAS,EAAE,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC;QACzH,OAAO,MAAM,IAAI,CAAC,cAAc,CAAwB,OAAO,EAAE,IAAI,CAAC,QAAQ,EAAE,EAAE,GAAG,OAAO,EAAE,aAAa,EAAE,uBAAuB,EAAE,CAAC,CAAC;IACzI,CAAC;CACD"}
@@ -0,0 +1,112 @@
1
+ import { type ClusterConsensusConfig } from "@optimystic/db-core";
2
+ /**
3
+ * Resolves the operator-facing cluster knobs (`clusterSize`, `clusterPolicy.*`) into the concrete
4
+ * numbers the consensus and block-restoration paths run on.
5
+ *
6
+ * Extracted from `createLibp2pNodeBase` rather than left inline so the composition root's defaults
7
+ * are assertable without booting a libp2p node — the layer a real deployment actually uses, and
8
+ * therefore the layer where a default that relaxed the repair corroboration floor to a single voter
9
+ * survived unnoticed (see `test/cluster-policy.spec.ts`).
10
+ *
11
+ * ## Why two size yardsticks, not one
12
+ *
13
+ * One operator field — `clusterPolicy.assumedClusterSize`, "the smallest cohort this deployment can
14
+ * genuinely field" — feeds two consumers whose failure modes point in opposite directions, so its
15
+ * *default* cannot serve both:
16
+ *
17
+ * - **Membership admission gate** (`cluster/cluster-repo.ts`, `admitMembership`) reads it only on its
18
+ * fallback path, when this node has no confident network-size estimate. Too small: a
19
+ * partition-induced downsize slips past while the node is unconfident. Too large: the node refuses
20
+ * legitimate writes — unavailability. It wants a *permissive* default, because an unconfigured
21
+ * two-node mesh must still be able to transact. It gets {@link minAbsoluteClusterSize} (2).
22
+ * - **Repair corroboration floor** (`corroboratorCapacity` in `cluster/quorum-restore.ts`, called by
23
+ * `CoordinatorRepo.queryClusterForLatest` and `createReconcileBlock`) reads it on *every* repair,
24
+ * unconditionally. Too small: a shrunken — and always unauthenticated — cohort view buys a lone
25
+ * peer full trust. Too large: a block stays unrepaired, degraded rather than dead. It wants a
26
+ * *strict* default. It gets {@link ResolvedClusterPolicy.repairCorroborationClusterSize}, which
27
+ * falls back to `clusterSize` (the configured replication factor).
28
+ *
29
+ * A single explicit `clusterPolicy.assumedClusterSize` still sets BOTH — an operator declaring their
30
+ * real cohort size means it for both consumers. Only the unconfigured case diverges.
31
+ *
32
+ * So a genuine two-node mesh needs exactly one setting to self-repair: either
33
+ * `clusterPolicy.assumedClusterSize: 2` (which does not lower the replication factor) or an honest
34
+ * `clusterSize: 2`. Writes and voting still work with zero configuration.
35
+ *
36
+ * ## Future
37
+ *
38
+ * Deriving the yardstick from observation (the largest peer group this node has ever seen for the
39
+ * key) would remove the trade entirely and subsume both values. Filed as backlog
40
+ * `feat-admission-floor-from-observed-cohort-high-water-mark`; do not build it here.
41
+ */
42
+ /**
43
+ * Absolute floor below which no cohort is safe, whatever the size references say. Named rather than
44
+ * inlined because the admission gate's `assumedClusterSize` defaults to exactly this value — the two
45
+ * must not drift.
46
+ */
47
+ export declare const minAbsoluteClusterSize = 2;
48
+ /**
49
+ * The operator-facing cluster knobs. `NodeOptions` (`libp2p-node-base.ts`) intersects this rather
50
+ * than restating it, so a knob added here is one `resolveClusterPolicy` is guaranteed to see — a
51
+ * second declaration would compile fine and be silently dropped.
52
+ */
53
+ export interface ClusterPolicyOptions {
54
+ /**
55
+ * Desired cluster size per key (default 10) — the replication factor / target cohort breadth
56
+ * the coordinator aims for. NOT a statement about how many peers actually exist, so the
57
+ * membership admission gate is never measured against it (see `cluster/cluster-repo.ts`).
58
+ *
59
+ * The read-repair/reconcile corroboration floor DOES fall back to it when
60
+ * `clusterPolicy.assumedClusterSize` is absent — the strict direction, so an unconfigured node
61
+ * cannot have its floor talked down by a shrunken cohort view. A deployment that genuinely runs
62
+ * fewer peers than this should declare `clusterPolicy.assumedClusterSize`.
63
+ */
64
+ clusterSize?: number;
65
+ clusterPolicy?: {
66
+ allowDownsize?: boolean;
67
+ /** Acceptable relative difference (e.g. 0.5 = +/-50%). */
68
+ sizeTolerance?: number;
69
+ /** Fraction of peers needed for super-majority (default {@link DEFAULT_SUPER_MAJORITY_THRESHOLD}). */
70
+ superMajorityThreshold?: number;
71
+ /**
72
+ * Opt in to transacting below the safe cluster-size floor when FRET has no confident
73
+ * network-size estimate — the membership-admission and coordinator small-cluster gates both
74
+ * fail closed without it. Default false. Turn on only for single-node / local dev meshes that
75
+ * knowingly run undersized.
76
+ */
77
+ allowUnvalidatedSmallCluster?: boolean;
78
+ /**
79
+ * The smallest cohort this deployment can genuinely field — normally the number of nodes you
80
+ * actually run, capped at `clusterSize`. Two consumers read it: the membership admission gate,
81
+ * on its fallback path when the node has no confident network-size estimate; and the
82
+ * read-repair/reconcile corroboration floor (`corroboratorCapacity`), unconditionally.
83
+ *
84
+ * Declaring it sets BOTH. Leaving it unset does NOT — see the module doc for why the two
85
+ * defaults point in opposite directions. A large deployment should still set this to its real
86
+ * cohort size, otherwise the admission gate cannot police a partition-induced downsize while
87
+ * its size estimate is unconfident; a genuine two-node mesh needs it (or an honest
88
+ * `clusterSize: 2`) to self-repair.
89
+ */
90
+ assumedClusterSize?: number;
91
+ };
92
+ }
93
+ /** Everything a node's consensus + restoration paths need, with every default already applied. */
94
+ export type ResolvedClusterPolicy = ClusterConsensusConfig & {
95
+ /** Replication factor / target cohort breadth. Always concrete after resolution. */
96
+ clusterSize: number;
97
+ /**
98
+ * Yardstick the repair corroboration floor measures a (possibly shrunken, always unauthenticated)
99
+ * cohort view against — see `corroboratorCapacity` in `cluster/quorum-restore.ts`.
100
+ *
101
+ * Deliberately distinct from {@link ClusterConsensusConfig.assumedClusterSize}, which the
102
+ * membership admission gate reads: the two share an operator field but not a default, because
103
+ * over- and under-stating them cost opposite things. See the module doc.
104
+ */
105
+ repairCorroborationClusterSize: number;
106
+ };
107
+ /**
108
+ * Apply every cluster-policy default a node needs. Pure — same options in, same numbers out — so the
109
+ * composition root's behavior is unit-testable (`test/cluster-policy.spec.ts`).
110
+ */
111
+ export declare function resolveClusterPolicy(options: ClusterPolicyOptions): ResolvedClusterPolicy;
112
+ //# sourceMappingURL=cluster-policy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cluster-policy.d.ts","sourceRoot":"","sources":["../../../src/cluster/cluster-policy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoC,KAAK,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAEpG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AAEH;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,IAAI,CAAC;AAExC;;;;GAIG;AACH,MAAM,WAAW,oBAAoB;IACpC;;;;;;;;;OASG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE;QACf,aAAa,CAAC,EAAE,OAAO,CAAC;QACxB,0DAA0D;QAC1D,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,sGAAsG;QACtG,sBAAsB,CAAC,EAAE,MAAM,CAAC;QAChC;;;;;WAKG;QACH,4BAA4B,CAAC,EAAE,OAAO,CAAC;QACvC;;;;;;;;;;;WAWG;QACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;KAC5B,CAAC;CACF;AAED,kGAAkG;AAClG,MAAM,MAAM,qBAAqB,GAAG,sBAAsB,GAAG;IAC5D,oFAAoF;IACpF,WAAW,EAAE,MAAM,CAAC;IACpB;;;;;;;OAOG;IACH,8BAA8B,EAAE,MAAM,CAAC;CACvC,CAAC;AAEF;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,oBAAoB,GAAG,qBAAqB,CAoCzF"}
@@ -0,0 +1,88 @@
1
+ import { DEFAULT_SUPER_MAJORITY_THRESHOLD } from "@optimystic/db-core";
2
+ /**
3
+ * Resolves the operator-facing cluster knobs (`clusterSize`, `clusterPolicy.*`) into the concrete
4
+ * numbers the consensus and block-restoration paths run on.
5
+ *
6
+ * Extracted from `createLibp2pNodeBase` rather than left inline so the composition root's defaults
7
+ * are assertable without booting a libp2p node — the layer a real deployment actually uses, and
8
+ * therefore the layer where a default that relaxed the repair corroboration floor to a single voter
9
+ * survived unnoticed (see `test/cluster-policy.spec.ts`).
10
+ *
11
+ * ## Why two size yardsticks, not one
12
+ *
13
+ * One operator field — `clusterPolicy.assumedClusterSize`, "the smallest cohort this deployment can
14
+ * genuinely field" — feeds two consumers whose failure modes point in opposite directions, so its
15
+ * *default* cannot serve both:
16
+ *
17
+ * - **Membership admission gate** (`cluster/cluster-repo.ts`, `admitMembership`) reads it only on its
18
+ * fallback path, when this node has no confident network-size estimate. Too small: a
19
+ * partition-induced downsize slips past while the node is unconfident. Too large: the node refuses
20
+ * legitimate writes — unavailability. It wants a *permissive* default, because an unconfigured
21
+ * two-node mesh must still be able to transact. It gets {@link minAbsoluteClusterSize} (2).
22
+ * - **Repair corroboration floor** (`corroboratorCapacity` in `cluster/quorum-restore.ts`, called by
23
+ * `CoordinatorRepo.queryClusterForLatest` and `createReconcileBlock`) reads it on *every* repair,
24
+ * unconditionally. Too small: a shrunken — and always unauthenticated — cohort view buys a lone
25
+ * peer full trust. Too large: a block stays unrepaired, degraded rather than dead. It wants a
26
+ * *strict* default. It gets {@link ResolvedClusterPolicy.repairCorroborationClusterSize}, which
27
+ * falls back to `clusterSize` (the configured replication factor).
28
+ *
29
+ * A single explicit `clusterPolicy.assumedClusterSize` still sets BOTH — an operator declaring their
30
+ * real cohort size means it for both consumers. Only the unconfigured case diverges.
31
+ *
32
+ * So a genuine two-node mesh needs exactly one setting to self-repair: either
33
+ * `clusterPolicy.assumedClusterSize: 2` (which does not lower the replication factor) or an honest
34
+ * `clusterSize: 2`. Writes and voting still work with zero configuration.
35
+ *
36
+ * ## Future
37
+ *
38
+ * Deriving the yardstick from observation (the largest peer group this node has ever seen for the
39
+ * key) would remove the trade entirely and subsume both values. Filed as backlog
40
+ * `feat-admission-floor-from-observed-cohort-high-water-mark`; do not build it here.
41
+ */
42
+ /**
43
+ * Absolute floor below which no cohort is safe, whatever the size references say. Named rather than
44
+ * inlined because the admission gate's `assumedClusterSize` defaults to exactly this value — the two
45
+ * must not drift.
46
+ */
47
+ export const minAbsoluteClusterSize = 2;
48
+ /**
49
+ * Apply every cluster-policy default a node needs. Pure — same options in, same numbers out — so the
50
+ * composition root's behavior is unit-testable (`test/cluster-policy.spec.ts`).
51
+ */
52
+ export function resolveClusterPolicy(options) {
53
+ // undefined here means "the operator said nothing", which is the only case where the two
54
+ // yardsticks below diverge.
55
+ //
56
+ // NOTE: a declared value is passed through unvalidated. The admission gate floors a degenerate one
57
+ // (0, negative, NaN, Infinity) itself — see `cluster-repo.admissionFloor` and its specs — but
58
+ // `corroboratorCapacity` does not: NaN there makes every quorum comparison false, so repair
59
+ // silently declines forever. Fail-safe, and unreachable through the reference-peer CLI (which
60
+ // rejects non-positive integers). If another composition root starts accepting unvalidated config,
61
+ // clamp here rather than in each consumer.
62
+ const declaredCohortSize = options.clusterPolicy?.assumedClusterSize;
63
+ const clusterSize = options.clusterSize ?? 10;
64
+ return {
65
+ superMajorityThreshold: options.clusterPolicy?.superMajorityThreshold ?? DEFAULT_SUPER_MAJORITY_THRESHOLD,
66
+ simpleMajorityThreshold: 0.51,
67
+ minAbsoluteClusterSize,
68
+ allowClusterDownsize: options.clusterPolicy?.allowDownsize ?? true,
69
+ clusterSizeTolerance: options.clusterPolicy?.sizeTolerance ?? 0.5,
70
+ // Fail closed by default (an undersized cluster with no confident network-size estimate is
71
+ // rejected); embedders running knowingly-small meshes opt in through clusterPolicy.
72
+ allowUnvalidatedSmallCluster: options.clusterPolicy?.allowUnvalidatedSmallCluster ?? false,
73
+ partitionDetectionWindow: 60000,
74
+ // Replication factor / target cohort breadth — what the coordinator aims for when selecting a
75
+ // cohort. Deliberately NOT the membership admission gate's yardstick: it says nothing about how
76
+ // many peers actually exist, so an unconfigured small mesh would refuse every write.
77
+ clusterSize,
78
+ // Membership admission gate, fallback path only (no confident network-size estimate). Defaults
79
+ // permissive so a two- or three-node mesh transacts unconfigured; the cost of that default is
80
+ // bounded to the gate, since the repair floor no longer reads this field.
81
+ assumedClusterSize: declaredCohortSize ?? minAbsoluteClusterSize,
82
+ // Repair corroboration floor, every repair. Defaults strict — to the replication factor — so an
83
+ // unconfigured node cannot have its floor talked down to a single voter by a shrunken cohort
84
+ // view. A genuinely small mesh declares its size (either field) to regain self-repair.
85
+ repairCorroborationClusterSize: declaredCohortSize ?? clusterSize
86
+ };
87
+ }
88
+ //# sourceMappingURL=cluster-policy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cluster-policy.js","sourceRoot":"","sources":["../../../src/cluster/cluster-policy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gCAAgC,EAA+B,MAAM,qBAAqB,CAAC;AAEpG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AAEH;;;;GAIG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,CAAC;AA+DxC;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAAC,OAA6B;IACjE,yFAAyF;IACzF,4BAA4B;IAC5B,EAAE;IACF,mGAAmG;IACnG,8FAA8F;IAC9F,4FAA4F;IAC5F,8FAA8F;IAC9F,mGAAmG;IACnG,2CAA2C;IAC3C,MAAM,kBAAkB,GAAG,OAAO,CAAC,aAAa,EAAE,kBAAkB,CAAC;IACrE,MAAM,WAAW,GAAG,OAAO,CAAC,WAAW,IAAI,EAAE,CAAC;IAE9C,OAAO;QACN,sBAAsB,EAAE,OAAO,CAAC,aAAa,EAAE,sBAAsB,IAAI,gCAAgC;QACzG,uBAAuB,EAAE,IAAI;QAC7B,sBAAsB;QACtB,oBAAoB,EAAE,OAAO,CAAC,aAAa,EAAE,aAAa,IAAI,IAAI;QAClE,oBAAoB,EAAE,OAAO,CAAC,aAAa,EAAE,aAAa,IAAI,GAAG;QACjE,2FAA2F;QAC3F,oFAAoF;QACpF,4BAA4B,EAAE,OAAO,CAAC,aAAa,EAAE,4BAA4B,IAAI,KAAK;QAC1F,wBAAwB,EAAE,KAAK;QAC/B,8FAA8F;QAC9F,gGAAgG;QAChG,qFAAqF;QACrF,WAAW;QACX,+FAA+F;QAC/F,8FAA8F;QAC9F,0EAA0E;QAC1E,kBAAkB,EAAE,kBAAkB,IAAI,sBAAsB;QAChE,gGAAgG;QAChG,6FAA6F;QAC7F,uFAAuF;QACvF,8BAA8B,EAAE,kBAAkB,IAAI,WAAW;KACjE,CAAC;AACH,CAAC"}
@@ -68,9 +68,10 @@ export type ExpectedClusterView = {
68
68
  * Independently derive this member's own view of a block's responsible cluster. Injected so
69
69
  * {@link ClusterMember} stays transport-agnostic — the composition root supplies it from
70
70
  * `IKeyNetwork.findCluster` + FRET (mirroring how the coordinator derives the cluster). Absent on nodes
71
- * that cannot derive a view (no FRET, unit tests): with no derived view AND no configured full-size
72
- * reference the gate preserves legacy approve behavior, but a configured `clusterSize` still lets the gate
73
- * fail closed on an unjustified downsize. See {@link ClusterMember} admission gate.
71
+ * that cannot derive a view (no FRET, unit tests): with no derived view AND no asserted
72
+ * {@link ClusterConsensusConfig.assumedClusterSize} the gate preserves legacy approve behavior, but an
73
+ * asserted size still lets the gate fail closed on an unjustified downsize. See {@link ClusterMember}
74
+ * admission gate.
74
75
  */
75
76
  export type DeriveExpectedClusterCallback = (blockId: BlockId) => Promise<ExpectedClusterView>;
76
77
  /** Stable reject reason a member emits when a declared peer set fails the membership admission gate. */
@@ -141,8 +142,8 @@ export declare class ClusterMember implements ICluster {
141
142
  private readonly minAbsoluteClusterSize;
142
143
  private readonly clusterSizeTolerance;
143
144
  private readonly membershipAdmissionFraction;
144
- /** Configured full cluster size, or undefined when unknown (then the gate cannot judge a downsize). */
145
- private readonly configuredClusterSize;
145
+ /** Operator-asserted smallest genuine cohort size, or undefined when unknown. */
146
+ private readonly assumedClusterSize;
146
147
  private readonly allowUnvalidatedSmallCluster;
147
148
  constructor(storageRepo: IRepo, peerNetwork: IPeerNetwork, peerId: PeerId, privateKey: PrivateKey, protocolPrefix?: string | undefined, _partitionDetector?: PartitionDetector, fretService?: FretService | undefined, validator?: ITransactionValidator | undefined, reputation?: IPeerReputation | undefined, consensusConfig?: ClusterConsensusConfig, stateStore?: ITransactionStateStore | undefined, reconcileBlock?: ReconcileBlockCallback | undefined, onCommitCertificate?: CommitCertificateSink | undefined, onInvalidate?: InvalidationApplySink | undefined, recomputeArbitratorSet?: RecomputeArbitratorSetCapability | undefined, deriveExpectedCluster?: DeriveExpectedClusterCallback | undefined);
148
149
  /**
@@ -240,14 +241,37 @@ export declare class ClusterMember implements ICluster {
240
241
  * of a peer or two is absorbed, a wholesale-disjoint or half-size set is not.
241
242
  *
242
243
  * **Fail-closed posture.** When the member cannot confidently derive `E` (no capability, low FRET
243
- * confidence — exactly what a partition induces), it must refuse any *downsizing* decision: a
244
- * below-full-size `D` is rejected against the configured full `clusterSize`. With NEITHER a confident
245
- * view NOR a configured full size the gate cannot judge a downsize at all, so it preserves the legacy
246
- * approve behavior (backward-compatible for nodes/tests with no derivation wired). `allowUnvalidatedSmallCluster`
247
- * is the explicit opt-in (single-node / local dev knowingly below the safe floor), matching the
248
- * coordinator's `validateSmallCluster` semantics.
244
+ * confidence — exactly what a partition induces), it must refuse any *downsizing* decision — but it
245
+ * needs a size reference to judge "downsize" against, and it may NOT borrow `clusterSize` for that:
246
+ * `clusterSize` is the replication factor (what a cohort should aim for), not a claim about how many
247
+ * peers exist, so a small deployment configured with the default 10 would refuse every write. The
248
+ * fallback yardstick is instead {@link ClusterConsensusConfig.assumedClusterSize} the operator's own
249
+ * assertion of the smallest cohort this deployment can genuinely field — run through the SAME
250
+ * {@link admissionFloor} as the confident path, so the fallback can never be stricter than the measured
251
+ * path (it was: it demanded the full configured size, with no fraction and no slack for churn or a peer
252
+ * not yet discovered). With NEITHER a confident view NOR an asserted size the gate cannot judge a
253
+ * downsize at all, so it preserves the legacy approve behavior (backward-compatible for nodes/tests with
254
+ * no derivation wired). `allowUnvalidatedSmallCluster` is the explicit opt-in (single-node / local dev
255
+ * knowingly below the safe floor), matching the coordinator's `validateSmallCluster` semantics.
249
256
  */
250
257
  private admitMembership;
258
+ /**
259
+ * The smallest declared peer set admissible against a cohort-size reference `k`, whether `k` is
260
+ * measured (the confident path's `kEst`) or asserted (`assumedClusterSize`). One function so the
261
+ * fallback can never be stricter than the measured path — which it was, demanding the full configured
262
+ * size with no fraction and no slack. Clamped at `minAbsoluteClusterSize`, so a degenerate `k` of 0, 1
263
+ * or negative yields the absolute floor rather than a floor that admits everything. A non-finite scaled
264
+ * size (a `NaN` or `Infinity` config value) is likewise treated as no usable reference rather than
265
+ * propagating: an unguarded `NaN` floor fails EVERY comparison, which would silently make the node
266
+ * reject every unconfident write.
267
+ *
268
+ * NOTE: partition safety needs `2 · membershipAdmissionFraction · superMajorityThreshold > 1` — each
269
+ * side of a split must recruit `fraction · threshold · K` distinct honest members, and two sides cannot
270
+ * both find them in one K-peer cluster. At the shipped defaults (0.75 · 0.67) that product is 1.005 —
271
+ * true, but with almost no margin. If either default is ever lowered, re-check Theorem 2 in
272
+ * `docs/correctness.md` before shipping it.
273
+ */
274
+ private admissionFloor;
251
275
  /**
252
276
  * Derive this member's own view of the record's block cluster via the injected capability, or
253
277
  * `undefined` when it cannot (no capability, no coordinating block id, or a derivation error — all of
@@ -1 +1 @@
1
- {"version":3,"file":"cluster-repo.d.ts","sourceRoot":"","sources":["../../../src/cluster/cluster-repo.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,aAAa,EAAE,YAAY,EAA0B,qBAAqB,EAAE,sBAAsB,EAAgB,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAiB,UAAU,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAC/O,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAGxD,OAAO,EAAiC,KAAK,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAGxG,OAAO,KAAK,EAAE,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iB;YAejB,gBAAgB;YA+BhB,gBAAgB;IAM9B,OAAO,CAAC,wBAAwB;YAwBlB,mBAAmB;IAejC,OAAO,CAAC,cAAc;IAKtB,OAAO,CAAC,gBAAgB;IAqBxB,iEAAiE;IACjE,OAAO,CAAC,uBAAuB;IAS/B;;;OAGG;IACG,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAAC;IAoC1C;;;OAGG;IACG,2BAA2B,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;CAUxE"}
@@ -96,8 +96,8 @@ export class ClusterMember {
96
96
  minAbsoluteClusterSize;
97
97
  clusterSizeTolerance;
98
98
  membershipAdmissionFraction;
99
- /** Configured full cluster size, or undefined when unknown (then the gate cannot judge a downsize). */
100
- configuredClusterSize;
99
+ /** Operator-asserted smallest genuine cohort size, or undefined when unknown. */
100
+ assumedClusterSize;
101
101
  allowUnvalidatedSmallCluster;
102
102
  constructor(storageRepo, peerNetwork, peerId, privateKey, protocolPrefix,
103
103
  // Reserved for partition-healing (backlog ticket 6.5-partition-healing); held but not yet consumed.
@@ -120,8 +120,17 @@ export class ClusterMember {
120
120
  this.minAbsoluteClusterSize = consensusConfig?.minAbsoluteClusterSize ?? 3;
121
121
  this.clusterSizeTolerance = consensusConfig?.clusterSizeTolerance ?? 0.5;
122
122
  this.membershipAdmissionFraction = consensusConfig?.membershipAdmissionFraction ?? 0.75;
123
- this.configuredClusterSize = consensusConfig?.clusterSize;
123
+ this.assumedClusterSize = consensusConfig?.assumedClusterSize;
124
124
  this.allowUnvalidatedSmallCluster = consensusConfig?.allowUnvalidatedSmallCluster ?? false;
125
+ // State the resolved gate parameters once, so an operator diagnosing a membership rejection can see
126
+ // what this node actually resolved. A fact, not a warning: `assumedClusterSize < clusterSize` is the
127
+ // normal default state, so warning on it would fire for every node and be ignored.
128
+ log('cluster-member:admission-config', {
129
+ assumedClusterSize: this.assumedClusterSize,
130
+ minAbsoluteClusterSize: this.minAbsoluteClusterSize,
131
+ membershipAdmissionFraction: this.membershipAdmissionFraction,
132
+ allowUnvalidatedSmallCluster: this.allowUnvalidatedSmallCluster
133
+ });
125
134
  // Periodically clean up expired transactions (.unref() so tests/short-lived processes can exit)
126
135
  this.expirationInterval = setInterval(() => this.queueExpiredTransactions(), 60000);
127
136
  this.expirationInterval.unref();
@@ -657,12 +666,18 @@ export class ClusterMember {
657
666
  * of a peer or two is absorbed, a wholesale-disjoint or half-size set is not.
658
667
  *
659
668
  * **Fail-closed posture.** When the member cannot confidently derive `E` (no capability, low FRET
660
- * confidence — exactly what a partition induces), it must refuse any *downsizing* decision: a
661
- * below-full-size `D` is rejected against the configured full `clusterSize`. With NEITHER a confident
662
- * view NOR a configured full size the gate cannot judge a downsize at all, so it preserves the legacy
663
- * approve behavior (backward-compatible for nodes/tests with no derivation wired). `allowUnvalidatedSmallCluster`
664
- * is the explicit opt-in (single-node / local dev knowingly below the safe floor), matching the
665
- * coordinator's `validateSmallCluster` semantics.
669
+ * confidence — exactly what a partition induces), it must refuse any *downsizing* decision — but it
670
+ * needs a size reference to judge "downsize" against, and it may NOT borrow `clusterSize` for that:
671
+ * `clusterSize` is the replication factor (what a cohort should aim for), not a claim about how many
672
+ * peers exist, so a small deployment configured with the default 10 would refuse every write. The
673
+ * fallback yardstick is instead {@link ClusterConsensusConfig.assumedClusterSize} the operator's own
674
+ * assertion of the smallest cohort this deployment can genuinely field — run through the SAME
675
+ * {@link admissionFloor} as the confident path, so the fallback can never be stricter than the measured
676
+ * path (it was: it demanded the full configured size, with no fraction and no slack for churn or a peer
677
+ * not yet discovered). With NEITHER a confident view NOR an asserted size the gate cannot judge a
678
+ * downsize at all, so it preserves the legacy approve behavior (backward-compatible for nodes/tests with
679
+ * no derivation wired). `allowUnvalidatedSmallCluster` is the explicit opt-in (single-node / local dev
680
+ * knowingly below the safe floor), matching the coordinator's `validateSmallCluster` semantics.
666
681
  */
667
682
  async admitMembership(record) {
668
683
  const ourId = this.peerId.toString();
@@ -689,28 +704,40 @@ export class ClusterMember {
689
704
  && derived.confidence > ClusterMember.MembershipConfidenceThreshold
690
705
  && derivedSize > 0;
691
706
  if (!confident) {
692
- // Fail closed for downsizing under low/absent confidence. A full-size (or larger) declared set is
693
- // still admitted there is nothing to shrink. Without a configured full-size reference we cannot
694
- // tell a downsize from a legitimate small cluster, so we preserve legacy approve behavior.
695
- if (this.configuredClusterSize === undefined) {
707
+ // Fail closed for downsizing under low/absent confidence, measured against the operator's asserted
708
+ // cohort size rather than the replication factor. With no asserted size the gate cannot tell a
709
+ // downsize from a legitimately small cluster at all, so it preserves legacy approve behavior.
710
+ if (this.assumedClusterSize === undefined) {
696
711
  return { admit: true };
697
712
  }
698
- if (declared.length >= this.configuredClusterSize) {
713
+ const floor = this.admissionFloor(this.assumedClusterSize);
714
+ if (declared.length >= floor) {
699
715
  return { admit: true };
700
716
  }
701
717
  log('cluster-member:admission-reject', {
702
718
  messageHash: record.messageHash,
703
719
  reason: 'low-confidence-downsize',
704
720
  declaredSize: declared.length,
705
- configuredClusterSize: this.configuredClusterSize,
721
+ floor,
722
+ assumedClusterSize: this.assumedClusterSize,
706
723
  confidence: derived?.confidence
707
724
  });
708
- return { admit: false, reason: `${MEMBERSHIP_NOT_ADMITTED}:low-confidence-downsize` };
725
+ // The numbers ride along in the reason: this rejection is caused by *local* configuration, and
726
+ // without them a coordinator (or an operator reading a dispute record) has no hint which knob did it.
727
+ // NOTE: two honest members with different local config now emit *different* reason strings for the
728
+ // same record. Nothing compares reasons across peers today (`disputeEvidence.rejectReasons` is a
729
+ // per-peer map, and the signed payload hashes the string each vote carries); if anything ever groups
730
+ // or dedupes dispute reasons by string equality, group on the `membership-not-admitted:<variant>`
731
+ // prefix, not the whole string.
732
+ return {
733
+ admit: false,
734
+ reason: `${MEMBERSHIP_NOT_ADMITTED}:low-confidence-downsize (declared=${declared.length}, floor=${floor}, assumedClusterSize=${this.assumedClusterSize})`
735
+ };
709
736
  }
710
737
  const expected = Object.keys(derived.peers ?? {});
711
738
  const kEst = expected.length;
712
739
  // Predicate 2: floor derived from the member's OWN confident estimate.
713
- const floor = Math.max(this.minAbsoluteClusterSize, Math.ceil(this.membershipAdmissionFraction * kEst));
740
+ const floor = this.admissionFloor(kEst);
714
741
  if (declared.length < floor) {
715
742
  log('cluster-member:admission-reject', {
716
743
  messageHash: record.messageHash,
@@ -719,7 +746,10 @@ export class ClusterMember {
719
746
  floor,
720
747
  kEst
721
748
  });
722
- return { admit: false, reason: `${MEMBERSHIP_NOT_ADMITTED}:below-floor` };
749
+ return {
750
+ admit: false,
751
+ reason: `${MEMBERSHIP_NOT_ADMITTED}:below-floor (declared=${declared.length}, floor=${floor}, kEst=${kEst})`
752
+ };
723
753
  }
724
754
  // Predicate 3: consistency with the derived view within tolerance.
725
755
  const symmetricDiff = ClusterMember.symmetricDifferenceSize(declared, expected);
@@ -737,6 +767,26 @@ export class ClusterMember {
737
767
  }
738
768
  return { admit: true };
739
769
  }
770
+ /**
771
+ * The smallest declared peer set admissible against a cohort-size reference `k`, whether `k` is
772
+ * measured (the confident path's `kEst`) or asserted (`assumedClusterSize`). One function so the
773
+ * fallback can never be stricter than the measured path — which it was, demanding the full configured
774
+ * size with no fraction and no slack. Clamped at `minAbsoluteClusterSize`, so a degenerate `k` of 0, 1
775
+ * or negative yields the absolute floor rather than a floor that admits everything. A non-finite scaled
776
+ * size (a `NaN` or `Infinity` config value) is likewise treated as no usable reference rather than
777
+ * propagating: an unguarded `NaN` floor fails EVERY comparison, which would silently make the node
778
+ * reject every unconfident write.
779
+ *
780
+ * NOTE: partition safety needs `2 · membershipAdmissionFraction · superMajorityThreshold > 1` — each
781
+ * side of a split must recruit `fraction · threshold · K` distinct honest members, and two sides cannot
782
+ * both find them in one K-peer cluster. At the shipped defaults (0.75 · 0.67) that product is 1.005 —
783
+ * true, but with almost no margin. If either default is ever lowered, re-check Theorem 2 in
784
+ * `docs/correctness.md` before shipping it.
785
+ */
786
+ admissionFloor(k) {
787
+ const scaled = Math.ceil(this.membershipAdmissionFraction * k);
788
+ return Math.max(this.minAbsoluteClusterSize, Number.isFinite(scaled) ? scaled : 0);
789
+ }
740
790
  /**
741
791
  * Derive this member's own view of the record's block cluster via the injected capability, or
742
792
  * `undefined` when it cannot (no capability, no coordinating block id, or a derivation error — all of
@@ -792,6 +842,20 @@ export class ClusterMember {
792
842
  const blockResults = await this.storageRepo.get({ blockIds });
793
843
  for (const blockId of blockIds) {
794
844
  const blockResult = blockResults[blockId];
845
+ if (blockResult?.unavailable !== undefined) {
846
+ // This member cannot establish the block's revision, so it cannot judge
847
+ // staleness. Vote reject rather than approve on an answer it knows is a
848
+ // guess — approving would let a stale pend reach consensus on the strength
849
+ // of a member that could not check it. (Before StorageRepo caught
850
+ // materialization faults per block, this read threw out of the promise
851
+ // handler; rejecting keeps the fail-closed posture with a signed reason.)
852
+ log('cluster-member:validation-block-unavailable', {
853
+ messageHash: record.messageHash,
854
+ blockId,
855
+ reason: blockResult.unavailable
856
+ });
857
+ return { valid: false, reason: `block ${blockId} unavailable (${blockResult.unavailable}): cannot verify revision` };
858
+ }
795
859
  const latestRev = blockResult?.state?.latest?.rev;
796
860
  if (latestRev !== undefined && latestRev >= pendRequest.rev) {
797
861
  log('cluster-member:validation-stale-revision', {
@@ -1169,7 +1233,12 @@ export class ClusterMember {
1169
1233
  async reconcileOneBlock(messageHash, blockId, committed, cohortPeerIds) {
1170
1234
  try {
1171
1235
  await this.withReconcileTimeout(this.reconcileBlock(blockId, committed, cohortPeerIds), blockId);
1172
- log('cluster-member:consensus-commit-reconciled', { messageHash, blockId, rev: committed.rev });
1236
+ // "attempted", not "reconciled": the callback returns void, and a quorum decline is a
1237
+ // normal, non-throwing outcome — so reaching here means the pass ran to completion, NOT
1238
+ // that anything was restored. `reconcile:restored` (reconcile-block.ts) is the line that
1239
+ // says the bytes actually landed; `reconcile:no-rev-quorum` / `reconcile:no-content-quorum`
1240
+ // say they did not.
1241
+ log('cluster-member:consensus-commit-reconcile-attempted', { messageHash, blockId, rev: committed.rev });
1173
1242
  }
1174
1243
  catch (err) {
1175
1244
  log('cluster-member:consensus-commit-reconcile-failed', {