@optimystic/db-core 1.25.0 → 1.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 (74) hide show
  1. package/dist/src/cluster/structs.d.ts +10 -0
  2. package/dist/src/cluster/structs.d.ts.map +1 -1
  3. package/dist/src/cohort-topic/addressing.d.ts +26 -2
  4. package/dist/src/cohort-topic/addressing.d.ts.map +1 -1
  5. package/dist/src/cohort-topic/addressing.js +35 -4
  6. package/dist/src/cohort-topic/addressing.js.map +1 -1
  7. package/dist/src/cohort-topic/member-engine.d.ts +17 -10
  8. package/dist/src/cohort-topic/member-engine.d.ts.map +1 -1
  9. package/dist/src/cohort-topic/member-engine.js +20 -18
  10. package/dist/src/cohort-topic/member-engine.js.map +1 -1
  11. package/dist/src/cohort-topic/registration/renewal.d.ts +21 -14
  12. package/dist/src/cohort-topic/registration/renewal.d.ts.map +1 -1
  13. package/dist/src/cohort-topic/registration/renewal.js +38 -28
  14. package/dist/src/cohort-topic/registration/renewal.js.map +1 -1
  15. package/dist/src/collection/collection.d.ts +123 -34
  16. package/dist/src/collection/collection.d.ts.map +1 -1
  17. package/dist/src/collection/collection.js +231 -74
  18. package/dist/src/collection/collection.js.map +1 -1
  19. package/dist/src/collection/segments.d.ts +71 -14
  20. package/dist/src/collection/segments.d.ts.map +1 -1
  21. package/dist/src/collection/segments.js +94 -14
  22. package/dist/src/collection/segments.js.map +1 -1
  23. package/dist/src/network/i-key-network.d.ts +28 -0
  24. package/dist/src/network/i-key-network.d.ts.map +1 -1
  25. package/dist/src/network/i-repo.d.ts +16 -0
  26. package/dist/src/network/i-repo.d.ts.map +1 -1
  27. package/dist/src/offline/queue.d.ts +13 -0
  28. package/dist/src/offline/queue.d.ts.map +1 -1
  29. package/dist/src/offline/queue.js +22 -3
  30. package/dist/src/offline/queue.js.map +1 -1
  31. package/dist/src/reactivity/topic-anchor.d.ts.map +1 -1
  32. package/dist/src/reactivity/topic-anchor.js +20 -2
  33. package/dist/src/reactivity/topic-anchor.js.map +1 -1
  34. package/dist/src/transaction/coordinator.d.ts +1 -1
  35. package/dist/src/transaction/coordinator.d.ts.map +1 -1
  36. package/dist/src/transaction/coordinator.js +15 -16
  37. package/dist/src/transaction/coordinator.js.map +1 -1
  38. package/dist/src/transactor/network-transactor.d.ts +16 -3
  39. package/dist/src/transactor/network-transactor.d.ts.map +1 -1
  40. package/dist/src/transactor/network-transactor.js +22 -5
  41. package/dist/src/transactor/network-transactor.js.map +1 -1
  42. package/dist/src/transform/atomic.d.ts +8 -2
  43. package/dist/src/transform/atomic.d.ts.map +1 -1
  44. package/dist/src/transform/atomic.js +10 -4
  45. package/dist/src/transform/atomic.js.map +1 -1
  46. package/dist/src/transform/helpers.d.ts +29 -3
  47. package/dist/src/transform/helpers.d.ts.map +1 -1
  48. package/dist/src/transform/helpers.js +62 -3
  49. package/dist/src/transform/helpers.js.map +1 -1
  50. package/dist/src/transform/tracker.d.ts +57 -5
  51. package/dist/src/transform/tracker.d.ts.map +1 -1
  52. package/dist/src/transform/tracker.js +111 -11
  53. package/dist/src/transform/tracker.js.map +1 -1
  54. package/dist/src/utility/expiring-lru-map.d.ts +16 -0
  55. package/dist/src/utility/expiring-lru-map.d.ts.map +1 -0
  56. package/dist/src/utility/expiring-lru-map.js +39 -0
  57. package/dist/src/utility/expiring-lru-map.js.map +1 -0
  58. package/package.json +1 -1
  59. package/src/cluster/structs.ts +10 -0
  60. package/src/cohort-topic/addressing.ts +42 -4
  61. package/src/cohort-topic/member-engine.ts +35 -28
  62. package/src/cohort-topic/registration/renewal.ts +62 -42
  63. package/src/collection/collection.ts +3462 -3272
  64. package/src/collection/segments.ts +140 -22
  65. package/src/network/i-key-network.ts +30 -0
  66. package/src/network/i-repo.ts +16 -0
  67. package/src/offline/queue.ts +23 -3
  68. package/src/reactivity/topic-anchor.ts +23 -3
  69. package/src/transaction/coordinator.ts +15 -16
  70. package/src/transactor/network-transactor.ts +24 -6
  71. package/src/transform/atomic.ts +12 -5
  72. package/src/transform/helpers.ts +61 -3
  73. package/src/transform/tracker.ts +110 -12
  74. package/src/utility/expiring-lru-map.ts +42 -0
@@ -1,6 +1,5 @@
1
- import { applyOperation, applyOperations, applyTransform, emptyTransforms, blockIdsForTransforms, transformForBlockId } from "./helpers.js";
1
+ import { applyOperation, applyOperations, applyTransform, emptyTransforms, blockIdsForTransforms, shallowCopyTransforms, transformForBlockId } from "./helpers.js";
2
2
  import { BasePins } from "./base-pins.js";
3
- import { ensured } from "../utility/ensured.js";
4
3
  /** The base a source can answer from memory, with the committed revision of that content — the
5
4
  * shared probe behind the unpinned {@link Tracker.peekMaterialized} path, for a source that cannot
6
5
  * report drift and so takes no pins. Returns undefined unless BOTH probes answer. */
@@ -27,6 +26,13 @@ export class Tracker {
27
26
  * detect source changes, so those fall back to always-replay. `gen` is the source generation of
28
27
  * the base block content the memo was built from. */
29
28
  materialized = new Map();
29
+ /** The ids whose staged value (the inserted block, or the update list) only this tracker
30
+ * references, so it may change that value in place. Any other value is shared with a snapshot
31
+ * ({@link shareTransforms}) or was handed in (the constructor, {@link reset}), and
32
+ * {@link stageUpdate} copies it before its first change. One set covers both shapes because
33
+ * {@link stageUpdate} reaches an id's update list only while the id has no staged insert, and
34
+ * only {@link delete}, which removes both, takes an insert away. */
35
+ owned = new Set();
30
36
  constructor(source,
31
37
  /** The collected set of transformations to be applied. Treat as immutable */
32
38
  transforms = emptyTransforms(),
@@ -296,15 +302,12 @@ export class Tracker {
296
302
  insert(block) {
297
303
  const inserts = this.transforms.inserts ??= {};
298
304
  inserts[block.header.id] = structuredClone(block);
305
+ this.owned.add(block.header.id);
299
306
  // Served from `inserts` now, not source+updates — the materialized memo no longer applies.
300
307
  this.materialized.delete(block.header.id);
301
308
  // An insert makes the materialized result base-independent, so any pinned base is moot.
302
309
  this.pins.delete(block.header.id);
303
- const deletes = this.transforms.deletes;
304
- const deleteIndex = deletes?.indexOf(block.header.id) ?? -1;
305
- if (deleteIndex >= 0) {
306
- deletes.splice(deleteIndex, 1);
307
- }
310
+ this.unlistDelete(block.header.id);
308
311
  }
309
312
  update(blockId, op) {
310
313
  if (this.stageUpdate(blockId, op))
@@ -320,7 +323,10 @@ export class Tracker {
320
323
  * the block at a newer revision), and probing would put the newer revision on operations built
321
324
  * for the older one — the wrong base the storage-side guard cannot catch. An adopted pin the
322
325
  * source no longer describes at its revision is judged moved on its next use, like any pin. An
323
- * update the child did NOT pin (a blind one) is pinned here exactly as a direct update would be. */
326
+ * update the child did NOT pin (a blind one) is pinned here exactly as a direct update would be.
327
+ *
328
+ * @returns the child's transforms, as they were. Everything kept here was copied from them, so
329
+ * the caller may keep them: `Collection.stageInto` records them as what the actions staged. */
324
330
  absorb(child) {
325
331
  this.pins.adopt(child.pins);
326
332
  const adopted = new Set(child.pins.ids());
@@ -337,6 +343,61 @@ export class Tracker {
337
343
  this.recheckPin(blockId);
338
344
  }
339
345
  }
346
+ return transform;
347
+ }
348
+ /** Stage the ids in `touched` again from `deltas` alone — the transforms of the units still
349
+ * staged, in staging order — leaving every other id as it is. For taking a committed head
350
+ * segment out of a collection's live tracker (`Collection.subtractCommittedHead`): the source
351
+ * now holds what the head staged over those ids, so each is forgotten here ({@link forget}) and
352
+ * then re-folded from the remaining deltas exactly as {@link absorb} folds a child — deletes,
353
+ * inserts, then updates, one delta after another — over the source as it is now. An id left
354
+ * update-only pins its base from the source now ({@link pinBase}). That is not a re-pin of
355
+ * operations built for another base: the remaining operations were computed against content
356
+ * that included the head's effect, and that content is what the source holds since the head
357
+ * committed. The deltas are left as they are; what is kept here is copied, as {@link absorb}
358
+ * copies. Synchronous, with nothing between the forgetting and the re-folding.
359
+ *
360
+ * NOTE: every touched id is looked up in every delta, so a head commit over a queue of n
361
+ * segments costs O(touched × n) lookups here — the small quadratic term left in a drain. If it
362
+ * ever shows up, keep an id-to-segments index beside the deltas and visit only the deltas that
363
+ * touch the id. */
364
+ refold(touched, deltas) {
365
+ const ids = [...new Set(touched)];
366
+ for (const id of ids)
367
+ this.forget(id);
368
+ for (const delta of deltas) {
369
+ for (const id of ids) {
370
+ if (delta.deletes?.includes(id))
371
+ this.delete(id);
372
+ if (delta.inserts && Object.hasOwn(delta.inserts, id))
373
+ this.insert(delta.inserts[id]);
374
+ for (const op of delta.updates?.[id] ?? []) {
375
+ if (this.stageUpdate(id, op))
376
+ this.pinBase(id);
377
+ else
378
+ this.recheckPin(id);
379
+ }
380
+ }
381
+ }
382
+ }
383
+ /** Drop everything this tracker holds for `id` — its staged insert, update list or delete, the
384
+ * memo, the ownership and the pin — as if nothing had been staged for it. */
385
+ forget(id) {
386
+ if (this.transforms.inserts)
387
+ delete this.transforms.inserts[id];
388
+ if (this.transforms.updates)
389
+ delete this.transforms.updates[id];
390
+ this.unlistDelete(id);
391
+ this.owned.delete(id);
392
+ this.materialized.delete(id);
393
+ this.pins.delete(id);
394
+ }
395
+ /** Take `id` off the staged deletes, if it is there. */
396
+ unlistDelete(id) {
397
+ const deletes = this.transforms.deletes;
398
+ const index = deletes?.indexOf(id) ?? -1;
399
+ if (index >= 0)
400
+ deletes.splice(index, 1);
340
401
  }
341
402
  /** Stage `op` for `blockId` — folded into a staged insert if there is one, else appended to the
342
403
  * id's update list — and keep the materialized memo current. Returns whether this was the FIRST
@@ -344,11 +405,10 @@ export class Tracker {
344
405
  stageUpdate(blockId, op) {
345
406
  const inserted = this.transforms.inserts?.[blockId];
346
407
  if (inserted) {
347
- applyOperation(inserted, op);
408
+ applyOperation(this.ownedInsert(blockId, inserted), op);
348
409
  return false;
349
410
  }
350
- const updates = this.transforms.updates ??= {};
351
- const ops = ensured(updates, blockId, () => []);
411
+ const ops = this.ownedUpdates(blockId);
352
412
  const first = ops.length === 0;
353
413
  ops.push(structuredClone(op));
354
414
  // The memo already equals (base source content + prior ops); applying just the new op
@@ -361,6 +421,28 @@ export class Tracker {
361
421
  }
362
422
  return first;
363
423
  }
424
+ /** `id`'s staged insert, safe to change in place: `applyOperation` mutates it, so a block this
425
+ * tracker does not own is replaced by a clone first. */
426
+ ownedInsert(id, inserted) {
427
+ if (this.owned.has(id))
428
+ return inserted;
429
+ const copy = structuredClone(inserted);
430
+ this.transforms.inserts[id] = copy;
431
+ this.owned.add(id);
432
+ return copy;
433
+ }
434
+ /** `id`'s staged update list, safe to append to. A list this tracker does not own is replaced by
435
+ * a plain array copy, which is enough because a staged operation is never changed once pushed. */
436
+ ownedUpdates(id) {
437
+ const updates = this.transforms.updates ??= {};
438
+ const held = updates[id];
439
+ if (held && this.owned.has(id))
440
+ return held;
441
+ const list = held ? [...held] : [];
442
+ updates[id] = list;
443
+ this.owned.add(id);
444
+ return list;
445
+ }
364
446
  /** Fix the base of `id`'s staged operations at the moment the FIRST of them is staged in this
365
447
  * tracker: the caller just read the block, so the base source describes what the operation was
366
448
  * computed against. Whatever the store held for the id before is replaced (or dropped, when the
@@ -388,6 +470,7 @@ export class Tracker {
388
470
  delete this.transforms.inserts[blockId];
389
471
  if (this.transforms.updates)
390
472
  delete this.transforms.updates[blockId];
473
+ this.owned.delete(blockId);
391
474
  this.materialized.delete(blockId);
392
475
  // A delete materializes to nothing (delete-last-wins), so the pinned base is moot.
393
476
  this.pins.delete(blockId);
@@ -397,6 +480,7 @@ export class Tracker {
397
480
  reset(newTransform = emptyTransforms()) {
398
481
  const oldTransform = this.transforms;
399
482
  this.transforms = newTransform;
483
+ this.owned.clear();
400
484
  this.materialized.clear();
401
485
  // The single reclamation point for pins: a plain reset clears them (empty updates), a
402
486
  // rollback-style reset(transforms) keeps exactly the pins — moved marks included — for ids
@@ -404,6 +488,22 @@ export class Tracker {
404
488
  this.pins.retainOnly(Object.keys(newTransform.updates ?? {}));
405
489
  return oldTransform;
406
490
  }
491
+ /** The staged transforms for a snapshot to keep: new outer maps over the same values, plus a copy
492
+ * of `deletes`. The maps must be new because {@link insert}, {@link update} and {@link delete}
493
+ * write to them; the values can be shared because this tracker gives up owning them here, so it
494
+ * copies each one before changing it again.
495
+ *
496
+ * NOTE: a capture costs one map entry per staged block, across every queued transaction, and the
497
+ * Quereus bridge takes one per statement per written collection. Staged blocks are tree nodes
498
+ * shared by many rows, so their count grows far more slowly than the queue. The first change to a
499
+ * shared update list after a capture also copies that list, whose length grows with the writes
500
+ * staged to the block. If either ever shows in a profile, keep what the sealed segments staged in
501
+ * a layer the captures share; a capture cannot simply leave it out, because `Tree.readView` reads
502
+ * those blocks through the snapshot. */
503
+ shareTransforms() {
504
+ this.owned.clear();
505
+ return shallowCopyTransforms(this.transforms);
506
+ }
407
507
  transformedBlockIds() {
408
508
  return blockIdsForTransforms(this.transforms);
409
509
  }
@@ -1 +1 @@
1
- {"version":3,"file":"tracker.js","sourceRoot":"","sources":["../../../src/transform/tracker.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,cAAc,EAAE,eAAe,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAC5I,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAWhD;;qFAEqF;AACrF,SAAS,UAAU,CAAC,MAAe,EAAE,EAAW;IAC/C,MAAM,GAAG,GAAG,MAAoB,CAAC;IACjC,IAAI,OAAO,GAAG,CAAC,IAAI,KAAK,UAAU,IAAI,OAAO,GAAG,CAAC,iBAAiB,KAAK,UAAU;QAAE,OAAO,SAAS,CAAC;IACpG,MAAM,KAAK,GAAG,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAwB,kCAAkC;IACrF,MAAM,GAAG,GAAG,GAAG,CAAC,iBAAiB,CAAC,EAAE,CAAC,CAAC;IACtC,OAAO,KAAK,KAAK,SAAS,IAAI,GAAG,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC;AAC9E,CAAC;AAED;;GAEG;AACH,MAAM,OAAO,OAAO;IAWD;IAEV;IAMS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;IAC/C,CAAC;IAED,SAAS,CAAC,QAAsB;QAC/B,OAAO,IAAI,CAAC,mBAAmB,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;IAClE,CAAC;CACD"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * An {@link LruMap} whose entries also expire `idleMs` after their last use. The size cap bounds memory
3
+ * while the cache is busy; the idle expiry releases entries a long-lived process stopped asking for even
4
+ * when the cap is never reached. Expiry is judged on lookup, so the map needs no timer and no teardown.
5
+ */
6
+ export declare class ExpiringLruMap<K, V> {
7
+ private readonly idleMs;
8
+ private readonly now;
9
+ private readonly entries;
10
+ constructor(maxSize: number, idleMs: number, now?: () => number);
11
+ /** The live value for `key`, refreshing its recency and its idle clock; `undefined` once expired. */
12
+ get(key: K): V | undefined;
13
+ set(key: K, value: V): this;
14
+ get size(): number;
15
+ }
16
+ //# sourceMappingURL=expiring-lru-map.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"expiring-lru-map.d.ts","sourceRoot":"","sources":["../../../src/utility/expiring-lru-map.ts"],"names":[],"mappings":"AAOA;;;;GAIG;AACH,qBAAa,cAAc,CAAC,CAAC,EAAE,CAAC;IAGF,OAAO,CAAC,QAAQ,CAAC,MAAM;IAAU,OAAO,CAAC,QAAQ,CAAC,GAAG;IAFlF,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAwB;gBAEpC,OAAO,EAAE,MAAM,EAAmB,MAAM,EAAE,MAAM,EAAmB,GAAG,GAAE,MAAM,MAAiB;IAK3G,qGAAqG;IACrG,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,GAAG,SAAS;IAY1B,GAAG,CAAC,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI;IAK3B,IAAI,IAAI,IAAI,MAAM,CAEjB;CACD"}
@@ -0,0 +1,39 @@
1
+ import { LruMap } from './lru-map.js';
2
+ /**
3
+ * An {@link LruMap} whose entries also expire `idleMs` after their last use. The size cap bounds memory
4
+ * while the cache is busy; the idle expiry releases entries a long-lived process stopped asking for even
5
+ * when the cap is never reached. Expiry is judged on lookup, so the map needs no timer and no teardown.
6
+ */
7
+ export class ExpiringLruMap {
8
+ idleMs;
9
+ now;
10
+ entries;
11
+ constructor(maxSize, idleMs, now = Date.now) {
12
+ this.idleMs = idleMs;
13
+ this.now = now;
14
+ if (!(idleMs > 0))
15
+ throw new Error('ExpiringLruMap idleMs must be > 0');
16
+ this.entries = new LruMap(maxSize);
17
+ }
18
+ /** The live value for `key`, refreshing its recency and its idle clock; `undefined` once expired. */
19
+ get(key) {
20
+ const entry = this.entries.get(key);
21
+ if (entry === undefined)
22
+ return undefined;
23
+ const at = this.now();
24
+ if (at - entry.usedAt > this.idleMs) {
25
+ this.entries.delete(key);
26
+ return undefined;
27
+ }
28
+ entry.usedAt = at;
29
+ return entry.value;
30
+ }
31
+ set(key, value) {
32
+ this.entries.set(key, { value, usedAt: this.now() });
33
+ return this;
34
+ }
35
+ get size() {
36
+ return this.entries.size;
37
+ }
38
+ }
39
+ //# sourceMappingURL=expiring-lru-map.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"expiring-lru-map.js","sourceRoot":"","sources":["../../../src/utility/expiring-lru-map.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAOtC;;;;GAIG;AACH,MAAM,OAAO,cAAc;IAGoB;IAAiC;IAF9D,OAAO,CAAwB;IAEhD,YAAY,OAAe,EAAmB,MAAc,EAAmB,MAAoB,IAAI,CAAC,GAAG;QAA7D,WAAM,GAAN,MAAM,CAAQ;QAAmB,QAAG,GAAH,GAAG,CAAyB;QAC1G,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;YAAE,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;QACxE,IAAI,CAAC,OAAO,GAAG,IAAI,MAAM,CAAC,OAAO,CAAC,CAAC;IACpC,CAAC;IAED,qGAAqG;IACrG,GAAG,CAAC,GAAM;QACT,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACpC,IAAI,KAAK,KAAK,SAAS;YAAE,OAAO,SAAS,CAAC;QAC1C,MAAM,EAAE,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QACtB,IAAI,EAAE,GAAG,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;YACrC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YACzB,OAAO,SAAS,CAAC;QAClB,CAAC;QACD,KAAK,CAAC,MAAM,GAAG,EAAE,CAAC;QAClB,OAAO,KAAK,CAAC,KAAK,CAAC;IACpB,CAAC;IAED,GAAG,CAAC,GAAM,EAAE,KAAQ;QACnB,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;QACrD,OAAO,IAAI,CAAC;IACb,CAAC;IAED,IAAI,IAAI;QACP,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;IAC1B,CAAC;CACD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optimystic/db-core",
3
- "version": "1.25.0",
3
+ "version": "1.27.0",
4
4
  "type": "module",
5
5
  "description": "Core database functionality for Optimystic",
6
6
  "main": "dist/src/index.js",
@@ -439,6 +439,16 @@ export interface ClusterConsensusConfig {
439
439
  readRepairWindowMs?: number;
440
440
  /** Per-read probability of triggering read-repair in 'lazy' mode even within the window (0..1). Default 0 (no random check). */
441
441
  readRepairSampleRate?: number;
442
+ /**
443
+ * For 'lazy' mode: how long after a consult that heard from every other member of a held block's
444
+ * cohort and found nothing ahead the block may go without another one, while every commit to it
445
+ * needs every member's promise (two or three members at the default threshold), every member has
446
+ * stayed connected to this node, and this node holds no pending record for the block. Default
447
+ * 300 000 (`DEFAULT_READ_REPAIR_QUIET_WINDOW_MS` in db-p2p); `0` turns it off, and so in effect
448
+ * does any value at or below `readRepairWindowMs`. See docs/transactions.md § Lazy read-repair
449
+ * window. On a node, set through `clusterPolicy.readRepairQuietWindowMs`.
450
+ */
451
+ readRepairQuietWindowMs?: number;
442
452
  /**
443
453
  * How long ONE cohort peer gets to answer ONE read-path request, in milliseconds (default
444
454
  * {@link DEFAULT_COHORT_QUERY_TIMEOUT_MS} = 1000). It sets BOTH per-peer deadlines on the read
@@ -40,6 +40,28 @@
40
40
  */
41
41
 
42
42
  import type { IRingHash, RingCoord, TopicRouteKey } from "./ports.js";
43
+ import { toString as uint8ArrayToString } from "uint8arrays/to-string";
44
+ import { ExpiringLruMap } from "../utility/expiring-lru-map.js";
45
+
46
+ /**
47
+ * Most root coordinates one addressing remembers. A node asks for the root of each watched collection's
48
+ * current tail — 99 distinct tails across two idle parties in the GitHub #57 measurement — so a few hundred
49
+ * covers a busy node with room to spare.
50
+ */
51
+ export const ROOT_COORD_CACHE_SIZE = 512;
52
+
53
+ /**
54
+ * How long a root coordinate is remembered after its last use. A tail stays a collection's tail until the log
55
+ * rolls over, and a live one is asked for at least once per gossip round or renewal (seconds apart), so ten
56
+ * minutes keeps every live tail warm and releases a rotated-away one well before the size cap would.
57
+ */
58
+ export const ROOT_COORD_IDLE_MS = 10 * 60_000;
59
+
60
+ /** Options for {@link HashTierAddressing}. */
61
+ export interface TierAddressingOptions {
62
+ /** Clock for the root-coordinate cache's idle expiry. Defaults to `Date.now`. */
63
+ readonly now?: () => number;
64
+ }
43
65
 
44
66
  /** Tier-addressing surface — derives the ring coordinate for tier `d` of a topic, and the key that routes to it. */
45
67
  export interface TierAddressing {
@@ -102,8 +124,10 @@ export function prefixBits(peerId: Uint8Array, n: number): Uint8Array {
102
124
  export class HashTierAddressing implements TierAddressing {
103
125
  public readonly F: number;
104
126
  private readonly log2F: number;
127
+ /** `rootCoord` answers by root key: callers pass fresh arrays, so the key is the bytes, not the object. */
128
+ private readonly rootCoords: ExpiringLruMap<string, RingCoord>;
105
129
 
106
- constructor(private readonly hash: IRingHash, F: number = DEFAULT_FANOUT) {
130
+ constructor(private readonly hash: IRingHash, F: number = DEFAULT_FANOUT, options: TierAddressingOptions = {}) {
107
131
  if (!Number.isInteger(F) || F < 2) {
108
132
  throw new RangeError(`fan-out F must be an integer ≥ 2, got ${F}`);
109
133
  }
@@ -113,14 +137,27 @@ export class HashTierAddressing implements TierAddressing {
113
137
  }
114
138
  this.F = F;
115
139
  this.log2F = log2F;
140
+ this.rootCoords = new ExpiringLruMap(ROOT_COORD_CACHE_SIZE, ROOT_COORD_IDLE_MS, options.now);
116
141
  }
117
142
 
118
143
  coord0(topicId: Uint8Array): RingCoord {
119
144
  return this.hash.H(this.tier0Key(topicId));
120
145
  }
121
146
 
147
+ /**
148
+ * Cached: a node re-derives the same few roots on every notification, gossip round and recover, and the
149
+ * hash is pure JavaScript on React Native (GitHub #57). Each answer is a copy, so a caller that writes into
150
+ * its coordinate cannot change what the next caller gets.
151
+ */
122
152
  rootCoord(rootKey: Uint8Array): RingCoord {
123
- return this.hash.H(this.rootRouteKey(rootKey));
153
+ const routeKey = this.rootRouteKey(rootKey);
154
+ const cacheKey = uint8ArrayToString(routeKey, "base64url");
155
+ let coord = this.rootCoords.get(cacheKey);
156
+ if (coord === undefined) {
157
+ coord = this.hash.H(routeKey);
158
+ this.rootCoords.set(cacheKey, coord);
159
+ }
160
+ return coord.slice();
124
161
  }
125
162
 
126
163
  coordD(d: number, peerId: Uint8Array, topicId: Uint8Array): RingCoord {
@@ -128,6 +165,7 @@ export class HashTierAddressing implements TierAddressing {
128
165
  }
129
166
 
130
167
  coord(d: number, peerId: Uint8Array, topicId: Uint8Array, rootKey?: Uint8Array): RingCoord {
168
+ if (d === 0 && rootKey !== undefined) return this.rootCoord(rootKey);
131
169
  return this.hash.H(this.routeKey(d, peerId, topicId, rootKey));
132
170
  }
133
171
 
@@ -175,6 +213,6 @@ export class HashTierAddressing implements TierAddressing {
175
213
  }
176
214
 
177
215
  /** Convenience factory mirroring the db-p2p adapter construction style. */
178
- export function createTierAddressing(hash: IRingHash, F: number = DEFAULT_FANOUT): TierAddressing {
179
- return new HashTierAddressing(hash, F);
216
+ export function createTierAddressing(hash: IRingHash, F: number = DEFAULT_FANOUT, options: TierAddressingOptions = {}): TierAddressing {
217
+ return new HashTierAddressing(hash, F, options);
180
218
  }
@@ -11,6 +11,10 @@
11
11
  *
12
12
  * Inbound `RegisterV1` decision pipeline (§Registration mechanics, §Willingness, §Cold-start):
13
13
  *
14
+ * The engine checks no signatures. A live-signer host authenticates a frame before handing it over, with the
15
+ * platform's own verifier, because that check may have to wait and every decision here reads current state
16
+ * synchronously; a key-less host hands frames over unchecked.
17
+ *
14
18
  * 1. **Anti-DoS** — freshness/replay guard, per-(peer,topic) rate limit, and cold-root bootstrap
15
19
  * evidence. A failure short-circuits to `unwilling_cohort` (temporal back-off) or, for a replay,
16
20
  * a silent `no_state` (no state is served and nothing is recorded).
@@ -131,14 +135,6 @@ export interface CohortMemberEngineDeps {
131
135
  readonly replayGuard?: CorrelationReplayGuard;
132
136
  readonly topicBudget?: TopicBudget;
133
137
  readonly bootstrapEvidence?: BootstrapEvidence;
134
- /**
135
- * Optional participant peer-key signature verifier (db-p2p binds it to the peer-sig primitive over
136
- * {@link import("./wire/payloads.js").registerSigningPayload}). A `RegisterV1` whose signature does
137
- * not verify against the claimed `participantCoord` is answered `no_state` (serve nothing, record
138
- * nothing) — a cohort member cannot trust an unsigned/forged `participantCoord`. Verified first so a
139
- * forged frame never reaches (or pollutes) the replay/rate guards. Absent → the gate is skipped.
140
- */
141
- readonly verifyRegisterSig?: (reg: RegisterV1) => boolean;
142
138
  /**
143
139
  * Sink for a freshly threshold-signed promotion/demotion notice produced on an arrival (the `accept`
144
140
  * path's promotion trigger). db-p2p's host wires this to broadcast the notice over the `promote`
@@ -165,10 +161,21 @@ export interface CohortMemberEngineDeps {
165
161
 
166
162
  /** Cohort-side register/renew handler — the body of the FRET activity callback. */
167
163
  export interface CohortMemberEngine {
168
- /** Classify and admit (or decline) an inbound `RegisterV1`, returning the reply to serialize. */
164
+ /**
165
+ * Classify and admit (or decline) an inbound `RegisterV1`, returning the reply to serialize. **The caller has
166
+ * authenticated `reg`** — `participantCoord` is taken as true, and rate limits and records are keyed by it. A
167
+ * forged frame reaching here would spend that peer's budget and could hold its registration.
168
+ */
169
169
  handleRegister(reg: RegisterV1, ctx: RegisterContext, now: number): Promise<RegisterReplyV1>;
170
- /** Handle an inbound `RenewV1` (ping / re-attach), delegating to the renewal cohort side. */
170
+ /**
171
+ * Handle an inbound `RenewV1` (ping / re-attach / withdraw), delegating to the renewal cohort side. **The caller
172
+ * has authenticated a privileged `msg`**: see {@link RenewalCohortSide.onRenew}.
173
+ */
171
174
  handleRenew(msg: RenewV1, now: number): RenewReplyV1;
175
+ /** {@link RenewalCohortSide.refusalBeforeSignature} for this engine's records. */
176
+ refusalBeforeSignature(msg: RenewV1, now: number): RenewReplyV1 | undefined;
177
+ /** {@link RenewalCohortSide.refuseUnauthenticated} for this engine's records. */
178
+ refuseUnauthenticated(msg: RenewV1): RenewReplyV1;
172
179
  /** Evict stale records and gossip each eviction; returns the evicted set. */
173
180
  sweepStale(now: number): readonly RegistrationRecord[];
174
181
  }
@@ -185,7 +192,7 @@ class StoreCohortMemberEngine implements CohortMemberEngine {
185
192
  // Branches before the admission pipeline (and the durable-state anti-DoS guards), so even a
186
193
  // hand-crafted `probe: true, bootstrap: true` frame can never instantiate — defense in depth.
187
194
  if (reg.probe === true) {
188
- return this.handleProbe(reg, topicId, participantId, ctx, now);
195
+ return this.handleProbe(topicId, participantId, ctx, now);
189
196
  }
190
197
 
191
198
  // 1. Anti-DoS gates. A replay/stale frame is answered with NoState (serve nothing, record
@@ -222,22 +229,17 @@ class StoreCohortMemberEngine implements CohortMemberEngine {
222
229
  * classify, never an admission: it persists **no** record, counts **no** arrival, fires **no**
223
230
  * promotion trigger, touches **no** topic budget, and **never** instantiates a cold-start forwarder.
224
231
  *
225
- * DoS posture (`docs/cohort-topic.md` §Anti-DoS): a probe still runs the stateless participant-sig gate
226
- * (forged → `no_state`) and a dedicated probe rate limiter (over-rate → `unwilling_cohort`), but skips
227
- * the replay guard, the bootstrap-evidence gate, and the topic budget — an idempotent read records
228
- * nothing, so it is strictly cheaper than the register it replaces.
232
+ * DoS posture (`docs/cohort-topic.md` §Anti-DoS): a probe arrives authenticated, as a register does, and runs
233
+ * a dedicated probe rate limiter (over-rate → `unwilling_cohort`), but skips the replay guard, the
234
+ * bootstrap-evidence gate, and the topic budget — an idempotent read records nothing, so it is strictly
235
+ * cheaper than the register it replaces.
229
236
  *
230
237
  * Classification mirrors a register's terminal cases so the walk's existing branches drive a probe
231
238
  * unchanged: a served-and-promoted topic answers `promoted(treeTier + 1)` (the walk follows it), a
232
239
  * served topic answers `accepted` with the participant-specific slot assignment + read-only traffic
233
240
  * snapshot, and a topic this cohort does not serve answers `no_state` (the walk steps inward).
234
241
  */
235
- private handleProbe(reg: RegisterV1, topicId: Uint8Array, participantId: Uint8Array, ctx: RegisterContext, now: number): RegisterReplyV1 {
236
- if (this.deps.verifyRegisterSig?.(reg) === false) {
237
- // Unsigned / forged participant signature: serve nothing, exactly like the register path — a
238
- // cohort member never resolves a cohort snapshot for an untrusted `participantCoord`.
239
- return { v: 1, result: "no_state" };
240
- }
242
+ private handleProbe(topicId: Uint8Array, participantId: Uint8Array, ctx: RegisterContext, now: number): RegisterReplyV1 {
241
243
  const rate = this.deps.probeRateLimiter?.check(participantId, topicId, now);
242
244
  if (rate !== undefined && rate.ok === false) {
243
245
  return { v: 1, result: "unwilling_cohort", retryAfterMs: rate.retryAfterMs };
@@ -276,6 +278,14 @@ class StoreCohortMemberEngine implements CohortMemberEngine {
276
278
  return reply;
277
279
  }
278
280
 
281
+ refusalBeforeSignature(msg: RenewV1, now: number): RenewReplyV1 | undefined {
282
+ return this.deps.renewal.refusalBeforeSignature(msg, now);
283
+ }
284
+
285
+ refuseUnauthenticated(msg: RenewV1): RenewReplyV1 {
286
+ return this.deps.renewal.refuseUnauthenticated(msg);
287
+ }
288
+
279
289
  sweepStale(now: number): readonly RegistrationRecord[] {
280
290
  // Reclaim idle (peer, topic) rate-limiter keys on the existing gossip cadence. The limiters' own
281
291
  // hard LRU cap already bounds worst-case footprint; this sweep adds proactive steady-state reclaim
@@ -449,12 +459,9 @@ class StoreCohortMemberEngine implements CohortMemberEngine {
449
459
  tier: Tier,
450
460
  now: number,
451
461
  ): RegisterReplyV1 | undefined {
452
- if (this.deps.verifyRegisterSig?.(reg) === false) {
453
- // Unsigned / forged participant signature: serve nothing and record nothing (the cohort
454
- // cannot trust this participantCoord). Cheap + stateless, so checked first — a forged frame
455
- // cannot consume any downstream guard state.
456
- return { v: 1, result: "no_state" };
457
- }
462
+ // The caller authenticated `reg` before this ran, and the rate limiter must stay behind that check even
463
+ // though it is the cheaper of the two: ahead of it, a forged frame would spend the budget of whichever peer
464
+ // it claims to be, and a stranger could grow the limiter's memory with invented identities.
458
465
  // Rate-check BEFORE the replay guard records anything: a fresh-correlationId spam frame that the
459
466
  // rate limiter would reject must not first insert a `seen` entry (which would let an attacker grow
460
467
  // the replay guard's memory at full attack speed regardless of the rate limit). Running it before
@@ -470,7 +477,7 @@ class StoreCohortMemberEngine implements CohortMemberEngine {
470
477
  if (this.deps.bootstrapEvidence?.verify(reg, tier) === false) {
471
478
  return this.unwillingCohort(reg, now);
472
479
  }
473
- // Replay guard records LAST, so only frames that passed signature + rate + bootstrap ever insert a
480
+ // Replay guard records LAST, so only frames that passed the caller's signature check + rate + bootstrap ever insert a
474
481
  // `seen` entry. An *accepted* frame is still always recorded here, so a genuine replay of a served
475
482
  // correlationId is still caught; only rate-rejected frames (never served, never recorded) skip it.
476
483
  const correlationId = b64urlToBytes(reg.correlationId);