@optimystic/db-p2p 0.25.1 → 0.27.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 (107) hide show
  1. package/dist/src/cluster/certified-claims.d.ts +17 -3
  2. package/dist/src/cluster/certified-claims.d.ts.map +1 -1
  3. package/dist/src/cluster/certified-claims.js +5 -3
  4. package/dist/src/cluster/certified-claims.js.map +1 -1
  5. package/dist/src/cluster/cluster-repo.d.ts +57 -92
  6. package/dist/src/cluster/cluster-repo.d.ts.map +1 -1
  7. package/dist/src/cluster/cluster-repo.js +149 -201
  8. package/dist/src/cluster/cluster-repo.js.map +1 -1
  9. package/dist/src/cluster/commit-proof.d.ts +16 -0
  10. package/dist/src/cluster/commit-proof.d.ts.map +1 -1
  11. package/dist/src/cluster/commit-proof.js +32 -1
  12. package/dist/src/cluster/commit-proof.js.map +1 -1
  13. package/dist/src/cluster/quorum-restore.d.ts +81 -28
  14. package/dist/src/cluster/quorum-restore.d.ts.map +1 -1
  15. package/dist/src/cluster/quorum-restore.js +148 -51
  16. package/dist/src/cluster/quorum-restore.js.map +1 -1
  17. package/dist/src/cluster/race-resolution.d.ts +89 -0
  18. package/dist/src/cluster/race-resolution.d.ts.map +1 -0
  19. package/dist/src/cluster/race-resolution.js +140 -0
  20. package/dist/src/cluster/race-resolution.js.map +1 -0
  21. package/dist/src/cluster/reconcile-block.d.ts +9 -4
  22. package/dist/src/cluster/reconcile-block.d.ts.map +1 -1
  23. package/dist/src/cluster/reconcile-block.js +28 -11
  24. package/dist/src/cluster/reconcile-block.js.map +1 -1
  25. package/dist/src/cluster/record-operations.d.ts +25 -0
  26. package/dist/src/cluster/record-operations.d.ts.map +1 -0
  27. package/dist/src/cluster/record-operations.js +56 -0
  28. package/dist/src/cluster/record-operations.js.map +1 -0
  29. package/dist/src/cohort-topic/host.d.ts +133 -51
  30. package/dist/src/cohort-topic/host.d.ts.map +1 -1
  31. package/dist/src/cohort-topic/host.js +290 -83
  32. package/dist/src/cohort-topic/host.js.map +1 -1
  33. package/dist/src/libp2p-node-base.d.ts +13 -4
  34. package/dist/src/libp2p-node-base.d.ts.map +1 -1
  35. package/dist/src/libp2p-node-base.js +5 -5
  36. package/dist/src/libp2p-node-base.js.map +1 -1
  37. package/dist/src/repo/cluster-coordinator.d.ts +9 -0
  38. package/dist/src/repo/cluster-coordinator.d.ts.map +1 -1
  39. package/dist/src/repo/cluster-coordinator.js +13 -2
  40. package/dist/src/repo/cluster-coordinator.js.map +1 -1
  41. package/dist/src/repo/coordinator-repo.d.ts +34 -2
  42. package/dist/src/repo/coordinator-repo.d.ts.map +1 -1
  43. package/dist/src/repo/coordinator-repo.js +57 -3
  44. package/dist/src/repo/coordinator-repo.js.map +1 -1
  45. package/dist/src/storage/block-latch.d.ts +5 -4
  46. package/dist/src/storage/block-latch.d.ts.map +1 -1
  47. package/dist/src/storage/block-latch.js +5 -4
  48. package/dist/src/storage/block-latch.js.map +1 -1
  49. package/dist/src/storage/block-storage.d.ts +1 -1
  50. package/dist/src/storage/block-storage.d.ts.map +1 -1
  51. package/dist/src/storage/block-storage.js +11 -3
  52. package/dist/src/storage/block-storage.js.map +1 -1
  53. package/dist/src/storage/cached-raw-storage.d.ts +17 -1
  54. package/dist/src/storage/cached-raw-storage.d.ts.map +1 -1
  55. package/dist/src/storage/cached-raw-storage.js +8 -1
  56. package/dist/src/storage/cached-raw-storage.js.map +1 -1
  57. package/dist/src/storage/cached-store-driver.d.ts +7 -0
  58. package/dist/src/storage/cached-store-driver.d.ts.map +1 -1
  59. package/dist/src/storage/cached-store-driver.js +20 -0
  60. package/dist/src/storage/cached-store-driver.js.map +1 -1
  61. package/dist/src/storage/i-block-storage.d.ts +45 -2
  62. package/dist/src/storage/i-block-storage.d.ts.map +1 -1
  63. package/dist/src/storage/i-block-storage.js +29 -0
  64. package/dist/src/storage/i-block-storage.js.map +1 -1
  65. package/dist/src/storage/i-raw-storage.d.ts +16 -0
  66. package/dist/src/storage/i-raw-storage.d.ts.map +1 -1
  67. package/dist/src/storage/kv-raw-storage.d.ts +5 -1
  68. package/dist/src/storage/kv-raw-storage.d.ts.map +1 -1
  69. package/dist/src/storage/kv-raw-storage.js +8 -1
  70. package/dist/src/storage/kv-raw-storage.js.map +1 -1
  71. package/dist/src/storage/raw-store-driver.d.ts +15 -0
  72. package/dist/src/storage/raw-store-driver.d.ts.map +1 -1
  73. package/dist/src/storage/shared-cache-pool.d.ts +5 -0
  74. package/dist/src/storage/shared-cache-pool.d.ts.map +1 -1
  75. package/dist/src/storage/shared-cache-pool.js +6 -1
  76. package/dist/src/storage/shared-cache-pool.js.map +1 -1
  77. package/dist/src/storage/storage-repo.d.ts.map +1 -1
  78. package/dist/src/storage/storage-repo.js +141 -99
  79. package/dist/src/storage/storage-repo.js.map +1 -1
  80. package/dist/src/storage/with-read-cache.d.ts +9 -5
  81. package/dist/src/storage/with-read-cache.d.ts.map +1 -1
  82. package/dist/src/storage/with-read-cache.js +16 -6
  83. package/dist/src/storage/with-read-cache.js.map +1 -1
  84. package/package.json +2 -2
  85. package/{README.md → readme.md} +2 -2
  86. package/src/cluster/certified-claims.ts +22 -9
  87. package/src/cluster/cluster-repo.ts +199 -212
  88. package/src/cluster/commit-proof.ts +38 -2
  89. package/src/cluster/quorum-restore.ts +183 -56
  90. package/src/cluster/race-resolution.ts +158 -0
  91. package/src/cluster/reconcile-block.ts +34 -11
  92. package/src/cluster/record-operations.ts +59 -0
  93. package/src/cohort-topic/host.ts +423 -118
  94. package/src/libp2p-node-base.ts +18 -9
  95. package/src/repo/cluster-coordinator.ts +1039 -1027
  96. package/src/repo/coordinator-repo.ts +1937 -1855
  97. package/src/storage/block-latch.ts +5 -4
  98. package/src/storage/block-storage.ts +11 -3
  99. package/src/storage/cached-raw-storage.ts +21 -1
  100. package/src/storage/cached-store-driver.ts +23 -0
  101. package/src/storage/i-block-storage.ts +47 -2
  102. package/src/storage/i-raw-storage.ts +17 -0
  103. package/src/storage/kv-raw-storage.ts +8 -1
  104. package/src/storage/raw-store-driver.ts +26 -0
  105. package/src/storage/shared-cache-pool.ts +6 -1
  106. package/src/storage/storage-repo.ts +143 -103
  107. package/src/storage/with-read-cache.ts +16 -6
@@ -140,14 +140,17 @@ const wiringLog = createLogger('node-wiring');
140
140
  /**
141
141
  * Factory function or instance for creating raw storage. The node puts the write-through read
142
142
  * cache in front of the resolved instance (`withReadCache`, unless it is a `MemoryRawStorage` or
143
- * already cached) under a lease, and releases THAT LEASE when it stops; the instance you supplied
144
- * is never disposed. The cache is shared per backing store: two concurrently running nodes handed
143
+ * already read-cached) under a lease, and releases THAT LEASE when it stops; the instance you
144
+ * supplied is never disposed. The cache is shared per backing store: two concurrently running nodes handed
145
145
  * one uncached instance — or two instances that report the same `getStoreIdentity()`, such as two
146
146
  * `FileRawStorage` over one directory — read and write through ONE cache, which is cleared and
147
147
  * unregistered only when the last of them stops. Sequential reuse (a restart over the same
148
148
  * instance) starts cold once the previous node's lease has released. What remains unguarded is
149
- * the cross-process case (Invariant 5 in `packages/db-p2p/docs/storage.md`). A host that builds
150
- * its own `CachedRawStorage` and hands it in keeps owning it; the node never releases it.
149
+ * the cross-process case (Invariant 5 in `packages/db-p2p/docs/storage.md`). A host that attaches
150
+ * its own read cache and hands the result in keeps owning it; the node never releases it. Either
151
+ * documented cache construction is accepted here — `new CachedRawStorage(inner)` or
152
+ * `new KvRawStorage(new CachedStoreDriver(driver))`, the latter preferred when the backend's
153
+ * driver is reachable. Both report `IRawStorage.readCached`, which is what the seam checks.
151
154
  */
152
155
  export type RawStorageProvider = IRawStorage | (() => IRawStorage);
153
156
 
@@ -271,6 +274,12 @@ export type NodeOptions = ClusterPolicyOptions & {
271
274
  * confirms them, so a rebalance never releases them and a ring shift's confirm phase aborts on
272
275
  * them (`docs/arachnode-ring-handoff.md` § Phase B). Clearing the backlog means running the
273
276
  * receivers with this `false` until every such block has been rewritten under current code.
277
+ * That backlog no longer grows from commits: every `CoordinatorRepo.commit` path under current
278
+ * code attaches a proof, solo cohorts included (the lone member self-signs one via
279
+ * `mintSoloCommitProof`). Still uncertifiable: blocks whose last write predates that, blocks
280
+ * committed without a content digest (the retention rule stores no proof for those), and
281
+ * revisions landed by the read-driven promotion in `StorageRepo.get`, which has no proof to
282
+ * attach — the last of those heal when a push back-fills one.
274
283
  */
275
284
  blockTransfer?: { requirePushCertificate?: boolean };
276
285
 
@@ -362,13 +371,13 @@ export type NodeOptions = ClusterPolicyOptions & {
362
371
  /**
363
372
  * Resolve the node's raw storage and put the write-through read cache in front of it. This is
364
373
  * the single place the network node resolves its `IRawStorage`, so it is the single place the
365
- * cache is wired (`withReadCache` states the exclusions: memory storage and already-cached
366
- * storage pass through unchanged). The default is a bare `MemoryRawStorage`, deliberately not
367
- * routed through the helper — nothing to cache.
374
+ * cache is wired (`withReadCache` states the exclusions: memory storage, and storage that
375
+ * already reports `readCached`, pass through unchanged). The default is a bare
376
+ * `MemoryRawStorage`, deliberately not routed through the helper — nothing to cache.
368
377
  *
369
378
  * `lease` is this node's claim on the (possibly shared) cache, and the ONLY thing its stop path
370
- * may release — a host that supplied its own `CachedRawStorage` keeps owning it (see
371
- * {@link ResolvedReadCache}).
379
+ * may release — a host that supplied an already-cached storage, in either documented
380
+ * construction, keeps owning it (see {@link ResolvedReadCache}).
372
381
  */
373
382
  function resolveStorage(provider: RawStorageProvider | undefined, networkName: string): ResolvedReadCache {
374
383
  if (!provider) {