@optimystic/db-core 1.20.1 → 1.22.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 (77) hide show
  1. package/dist/src/btree/btree.d.ts +36 -4
  2. package/dist/src/btree/btree.d.ts.map +1 -1
  3. package/dist/src/btree/btree.js +86 -18
  4. package/dist/src/btree/btree.js.map +1 -1
  5. package/dist/src/cohort-topic/gossip/bus.d.ts +15 -14
  6. package/dist/src/cohort-topic/gossip/bus.d.ts.map +1 -1
  7. package/dist/src/cohort-topic/gossip/bus.js +15 -16
  8. package/dist/src/cohort-topic/gossip/bus.js.map +1 -1
  9. package/dist/src/cohort-topic/ports.d.ts +30 -4
  10. package/dist/src/cohort-topic/ports.d.ts.map +1 -1
  11. package/dist/src/cohort-topic/ports.js +14 -0
  12. package/dist/src/cohort-topic/ports.js.map +1 -1
  13. package/dist/src/cohort-topic/registration/renewal.d.ts +27 -1
  14. package/dist/src/cohort-topic/registration/renewal.d.ts.map +1 -1
  15. package/dist/src/cohort-topic/registration/renewal.js +15 -4
  16. package/dist/src/cohort-topic/registration/renewal.js.map +1 -1
  17. package/dist/src/cohort-topic/service.d.ts +21 -4
  18. package/dist/src/cohort-topic/service.d.ts.map +1 -1
  19. package/dist/src/cohort-topic/service.js +208 -18
  20. package/dist/src/cohort-topic/service.js.map +1 -1
  21. package/dist/src/cohort-topic/willingness.d.ts +1 -1
  22. package/dist/src/cohort-topic/willingness.js +1 -1
  23. package/dist/src/cohort-topic/wire/codec.d.ts +3 -1
  24. package/dist/src/cohort-topic/wire/codec.d.ts.map +1 -1
  25. package/dist/src/cohort-topic/wire/codec.js +7 -1
  26. package/dist/src/cohort-topic/wire/codec.js.map +1 -1
  27. package/dist/src/cohort-topic/wire/index.d.ts +1 -1
  28. package/dist/src/cohort-topic/wire/index.d.ts.map +1 -1
  29. package/dist/src/cohort-topic/wire/index.js +1 -1
  30. package/dist/src/cohort-topic/wire/index.js.map +1 -1
  31. package/dist/src/cohort-topic/wire/types.d.ts +17 -1
  32. package/dist/src/cohort-topic/wire/types.d.ts.map +1 -1
  33. package/dist/src/cohort-topic/wire/validate.d.ts +15 -1
  34. package/dist/src/cohort-topic/wire/validate.d.ts.map +1 -1
  35. package/dist/src/cohort-topic/wire/validate.js +39 -0
  36. package/dist/src/cohort-topic/wire/validate.js.map +1 -1
  37. package/dist/src/collection/collection.d.ts +43 -5
  38. package/dist/src/collection/collection.d.ts.map +1 -1
  39. package/dist/src/collection/collection.js +60 -13
  40. package/dist/src/collection/collection.js.map +1 -1
  41. package/dist/src/collection/struct.d.ts +6 -0
  42. package/dist/src/collection/struct.d.ts.map +1 -1
  43. package/dist/src/collection/struct.js.map +1 -1
  44. package/dist/src/collections/tree/tree.d.ts +3 -1
  45. package/dist/src/collections/tree/tree.d.ts.map +1 -1
  46. package/dist/src/collections/tree/tree.js +11 -5
  47. package/dist/src/collections/tree/tree.js.map +1 -1
  48. package/dist/src/network/struct.d.ts +15 -0
  49. package/dist/src/network/struct.d.ts.map +1 -1
  50. package/dist/src/network/struct.js.map +1 -1
  51. package/dist/src/testing/test-transactor.js +6 -2
  52. package/dist/src/testing/test-transactor.js.map +1 -1
  53. package/dist/src/transaction/coordinator.d.ts +6 -0
  54. package/dist/src/transaction/coordinator.d.ts.map +1 -1
  55. package/dist/src/transaction/coordinator.js +6 -0
  56. package/dist/src/transaction/coordinator.js.map +1 -1
  57. package/dist/src/transactor/network-transactor.d.ts.map +1 -1
  58. package/dist/src/transactor/network-transactor.js +1 -0
  59. package/dist/src/transactor/network-transactor.js.map +1 -1
  60. package/package.json +1 -1
  61. package/src/btree/btree.ts +92 -18
  62. package/src/cohort-topic/gossip/bus.ts +25 -26
  63. package/src/cohort-topic/ports.ts +31 -4
  64. package/src/cohort-topic/registration/renewal.ts +40 -5
  65. package/src/cohort-topic/service.ts +251 -21
  66. package/src/cohort-topic/willingness.ts +1 -1
  67. package/src/cohort-topic/wire/codec.ts +12 -0
  68. package/src/cohort-topic/wire/index.ts +3 -0
  69. package/src/cohort-topic/wire/types.ts +20 -0
  70. package/src/cohort-topic/wire/validate.ts +45 -0
  71. package/src/collection/collection.ts +3098 -3039
  72. package/src/collection/struct.ts +463 -456
  73. package/src/collections/tree/tree.ts +15 -7
  74. package/src/network/struct.ts +770 -755
  75. package/src/testing/test-transactor.ts +5 -2
  76. package/src/transaction/coordinator.ts +6 -0
  77. package/src/transactor/network-transactor.ts +1897 -1896
@@ -1016,12 +1016,15 @@ function committedAt(blockState: BlockState, pin: number | undefined): { block:
1016
1016
  return block ? { block, rev: blockState.latestRev } : undefined;
1017
1017
  }
1018
1018
 
1019
- /** Returns the materialized block at the highest revision ≤ the given revision, together with
1020
- * that revision — the caller reports it as {@link GetBlockResult.materialized}. */
1019
+ /** Returns the block as it stood at the highest revision ≤ the given revision that committed it,
1020
+ * together with that revision — the caller reports it as {@link GetBlockResult.materialized} — or
1021
+ * `undefined` when that revision deleted it, as storage answers a tombstone: a committed revision
1022
+ * with no materialized block is a delete, never a reason to serve the content before it. */
1021
1023
  function latestMaterializedAt(blockState: BlockState, maxRev: number): { block: IBlock, rev: number } | undefined {
1022
1024
  for (let rev = maxRev; rev >= 0; rev--) {
1023
1025
  const block = blockState.materializedBlocks.get(rev);
1024
1026
  if (block) return { block, rev };
1027
+ if (blockState.revisionActions.has(rev)) return undefined;
1025
1028
  }
1026
1029
  return undefined;
1027
1030
  }
@@ -1458,6 +1458,12 @@ export class TransactionCoordinator {
1458
1458
  *
1459
1459
  * This clears pending transforms from all collections. Useful for
1460
1460
  * cleaning up after validation or when starting a new transaction.
1461
+ *
1462
+ * NOTE: resets each tracker directly, so the collection's `onViewChanged` is not called and a
1463
+ * reader part-way through a descent of one of these collections is not told to read again. Its
1464
+ * one caller is the Quereus validator, which no composition root wires today; if validation ever
1465
+ * runs beside live reads of the same collections, reset through a `Collection` method that
1466
+ * calls `viewChanged` instead.
1461
1467
  */
1462
1468
  resetTransforms(): void {
1463
1469
  for (const collection of this.collections.values()) {