@optimystic/db-p2p 0.21.0 → 0.24.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 (219) hide show
  1. package/dist/src/cluster/client.d.ts +10 -0
  2. package/dist/src/cluster/client.d.ts.map +1 -1
  3. package/dist/src/cluster/client.js +30 -1
  4. package/dist/src/cluster/client.js.map +1 -1
  5. package/dist/src/cluster/cluster-policy.d.ts +13 -2
  6. package/dist/src/cluster/cluster-policy.d.ts.map +1 -1
  7. package/dist/src/cluster/cluster-policy.js +51 -4
  8. package/dist/src/cluster/cluster-policy.js.map +1 -1
  9. package/dist/src/cluster/cluster-repo.d.ts +42 -17
  10. package/dist/src/cluster/cluster-repo.d.ts.map +1 -1
  11. package/dist/src/cluster/cluster-repo.js +229 -122
  12. package/dist/src/cluster/cluster-repo.js.map +1 -1
  13. package/dist/src/cluster/cluster-size-coupling.d.ts +28 -0
  14. package/dist/src/cluster/cluster-size-coupling.d.ts.map +1 -0
  15. package/dist/src/cluster/cluster-size-coupling.js +35 -0
  16. package/dist/src/cluster/cluster-size-coupling.js.map +1 -0
  17. package/dist/src/cluster/quorum-restore.d.ts +6 -0
  18. package/dist/src/cluster/quorum-restore.d.ts.map +1 -1
  19. package/dist/src/cluster/quorum-restore.js +1 -1
  20. package/dist/src/cluster/quorum-restore.js.map +1 -1
  21. package/dist/src/cluster/reconcile-block.d.ts.map +1 -1
  22. package/dist/src/cluster/reconcile-block.js +15 -3
  23. package/dist/src/cluster/reconcile-block.js.map +1 -1
  24. package/dist/src/cluster/service.d.ts +32 -1
  25. package/dist/src/cluster/service.d.ts.map +1 -1
  26. package/dist/src/cluster/service.js +43 -2
  27. package/dist/src/cluster/service.js.map +1 -1
  28. package/dist/src/cohort-topic/stream-util.d.ts +22 -6
  29. package/dist/src/cohort-topic/stream-util.d.ts.map +1 -1
  30. package/dist/src/cohort-topic/stream-util.js +56 -10
  31. package/dist/src/cohort-topic/stream-util.js.map +1 -1
  32. package/dist/src/dispute/dispute-service.d.ts.map +1 -1
  33. package/dist/src/dispute/dispute-service.js +9 -3
  34. package/dist/src/dispute/dispute-service.js.map +1 -1
  35. package/dist/src/index.d.ts +5 -0
  36. package/dist/src/index.d.ts.map +1 -1
  37. package/dist/src/index.js +5 -0
  38. package/dist/src/index.js.map +1 -1
  39. package/dist/src/libp2p-key-network.d.ts +134 -7
  40. package/dist/src/libp2p-key-network.d.ts.map +1 -1
  41. package/dist/src/libp2p-key-network.js +174 -37
  42. package/dist/src/libp2p-key-network.js.map +1 -1
  43. package/dist/src/libp2p-node-base.d.ts +3 -2
  44. package/dist/src/libp2p-node-base.d.ts.map +1 -1
  45. package/dist/src/libp2p-node-base.js +859 -778
  46. package/dist/src/libp2p-node-base.js.map +1 -1
  47. package/dist/src/libp2p-node-rn.d.ts +2 -2
  48. package/dist/src/libp2p-node-rn.d.ts.map +1 -1
  49. package/dist/src/libp2p-node-rn.js.map +1 -1
  50. package/dist/src/libp2p-node.d.ts +2 -2
  51. package/dist/src/libp2p-node.d.ts.map +1 -1
  52. package/dist/src/libp2p-node.js.map +1 -1
  53. package/dist/src/logger.d.ts +17 -1
  54. package/dist/src/logger.d.ts.map +1 -1
  55. package/dist/src/logger.js +19 -2
  56. package/dist/src/logger.js.map +1 -1
  57. package/dist/src/network/network-manager-service.d.ts +2 -0
  58. package/dist/src/network/network-manager-service.d.ts.map +1 -1
  59. package/dist/src/network/network-manager-service.js +4 -0
  60. package/dist/src/network/network-manager-service.js.map +1 -1
  61. package/dist/src/optimystic-node.d.ts +35 -0
  62. package/dist/src/optimystic-node.d.ts.map +1 -0
  63. package/dist/src/optimystic-node.js +2 -0
  64. package/dist/src/optimystic-node.js.map +1 -0
  65. package/dist/src/owned-block-seed.d.ts +6 -3
  66. package/dist/src/owned-block-seed.d.ts.map +1 -1
  67. package/dist/src/owned-block-seed.js +16 -3
  68. package/dist/src/owned-block-seed.js.map +1 -1
  69. package/dist/src/peer-address-book.d.ts +72 -0
  70. package/dist/src/peer-address-book.d.ts.map +1 -0
  71. package/dist/src/peer-address-book.js +123 -0
  72. package/dist/src/peer-address-book.js.map +1 -0
  73. package/dist/src/repo/client.d.ts.map +1 -1
  74. package/dist/src/repo/client.js +11 -2
  75. package/dist/src/repo/client.js.map +1 -1
  76. package/dist/src/repo/cluster-coordinator.d.ts +30 -0
  77. package/dist/src/repo/cluster-coordinator.d.ts.map +1 -1
  78. package/dist/src/repo/cluster-coordinator.js +95 -3
  79. package/dist/src/repo/cluster-coordinator.js.map +1 -1
  80. package/dist/src/repo/coordinator-repo.d.ts +78 -14
  81. package/dist/src/repo/coordinator-repo.d.ts.map +1 -1
  82. package/dist/src/repo/coordinator-repo.js +266 -81
  83. package/dist/src/repo/coordinator-repo.js.map +1 -1
  84. package/dist/src/rn.d.ts +5 -0
  85. package/dist/src/rn.d.ts.map +1 -1
  86. package/dist/src/rn.js +5 -0
  87. package/dist/src/rn.js.map +1 -1
  88. package/dist/src/storage/block-storage.d.ts.map +1 -1
  89. package/dist/src/storage/block-storage.js +57 -5
  90. package/dist/src/storage/block-storage.js.map +1 -1
  91. package/dist/src/storage/cached-raw-storage.d.ts +83 -0
  92. package/dist/src/storage/cached-raw-storage.d.ts.map +1 -0
  93. package/dist/src/storage/cached-raw-storage.js +152 -0
  94. package/dist/src/storage/cached-raw-storage.js.map +1 -0
  95. package/dist/src/storage/cached-store-driver.d.ts +186 -0
  96. package/dist/src/storage/cached-store-driver.d.ts.map +1 -0
  97. package/dist/src/storage/cached-store-driver.js +775 -0
  98. package/dist/src/storage/cached-store-driver.js.map +1 -0
  99. package/dist/src/storage/i-block-storage.d.ts +20 -1
  100. package/dist/src/storage/i-block-storage.d.ts.map +1 -1
  101. package/dist/src/storage/i-raw-storage.d.ts +12 -5
  102. package/dist/src/storage/i-raw-storage.d.ts.map +1 -1
  103. package/dist/src/storage/shared-cache-pool.d.ts +234 -0
  104. package/dist/src/storage/shared-cache-pool.d.ts.map +1 -0
  105. package/dist/src/storage/shared-cache-pool.js +354 -0
  106. package/dist/src/storage/shared-cache-pool.js.map +1 -0
  107. package/dist/src/storage/storage-repo.d.ts +56 -3
  108. package/dist/src/storage/storage-repo.d.ts.map +1 -1
  109. package/dist/src/storage/storage-repo.js +124 -18
  110. package/dist/src/storage/storage-repo.js.map +1 -1
  111. package/dist/src/testing/raw-storage-conformance.d.ts +2 -1
  112. package/dist/src/testing/raw-storage-conformance.d.ts.map +1 -1
  113. package/dist/src/testing/raw-storage-conformance.js +52 -2
  114. package/dist/src/testing/raw-storage-conformance.js.map +1 -1
  115. package/package.json +3 -3
  116. package/readme.md +668 -653
  117. package/src/cluster/block-transfer.ts +424 -424
  118. package/src/cluster/client.ts +119 -88
  119. package/src/cluster/cluster-error.ts +64 -64
  120. package/src/cluster/cluster-policy.ts +203 -152
  121. package/src/cluster/cluster-repo.ts +245 -125
  122. package/src/cluster/cluster-size-coupling.ts +45 -0
  123. package/src/cluster/commit-cert.ts +139 -139
  124. package/src/cluster/i-transaction-state-store.ts +43 -43
  125. package/src/cluster/memory-transaction-state-store.ts +56 -56
  126. package/src/cluster/peer-key-binding.ts +37 -37
  127. package/src/cluster/persistent-transaction-state-store.ts +92 -92
  128. package/src/cluster/quorum-restore.ts +223 -223
  129. package/src/cluster/reconcile-block.ts +203 -191
  130. package/src/cluster/service.ts +293 -241
  131. package/src/cluster/supermajority-coupling.ts +37 -37
  132. package/src/cohort-topic/bootstrap-evidence-builder.ts +122 -122
  133. package/src/cohort-topic/bootstrap-evidence-verifiers.ts +132 -132
  134. package/src/cohort-topic/bootstrap-parent-reference.ts +159 -159
  135. package/src/cohort-topic/change-bridge.ts +109 -109
  136. package/src/cohort-topic/cohort-gossip-driver.ts +231 -231
  137. package/src/cohort-topic/cohort-gossip-transport.ts +84 -84
  138. package/src/cohort-topic/fret-trust-anchor.ts +153 -153
  139. package/src/cohort-topic/host.ts +2901 -2901
  140. package/src/cohort-topic/index.ts +13 -13
  141. package/src/cohort-topic/membership-publish-sink.ts +20 -20
  142. package/src/cohort-topic/membership-source.ts +68 -68
  143. package/src/cohort-topic/peer-codec.ts +31 -31
  144. package/src/cohort-topic/peer-sig.ts +86 -86
  145. package/src/cohort-topic/protocols.ts +71 -71
  146. package/src/cohort-topic/reactivity-membership-gate.ts +77 -77
  147. package/src/cohort-topic/size-estimator.ts +16 -16
  148. package/src/cohort-topic/stream-util.ts +135 -87
  149. package/src/cohort-topic/threshold-crypto.ts +239 -239
  150. package/src/cohort-topic/topic-router.ts +77 -77
  151. package/src/dispute/arbitrator-selection.ts +138 -138
  152. package/src/dispute/cascade.ts +524 -524
  153. package/src/dispute/dispute-service.ts +11 -5
  154. package/src/dispute/invalidation.ts +625 -625
  155. package/src/inbound-authorization.ts +190 -190
  156. package/src/index.ts +52 -47
  157. package/src/libp2p-key-network.ts +1120 -958
  158. package/src/libp2p-node-base.ts +1675 -1591
  159. package/src/libp2p-node-rn.ts +30 -30
  160. package/src/libp2p-node.ts +36 -36
  161. package/src/logger.ts +19 -2
  162. package/src/matchmaking/aggregate-counts.ts +104 -104
  163. package/src/matchmaking/index.ts +20 -20
  164. package/src/matchmaking/module.ts +363 -363
  165. package/src/matchmaking/protocols.ts +51 -51
  166. package/src/matchmaking/provider-manager.ts +95 -95
  167. package/src/matchmaking/query-handler.ts +88 -88
  168. package/src/matchmaking/query-transport.ts +492 -492
  169. package/src/matchmaking/seeker-manager.ts +64 -64
  170. package/src/matchmaking/seeker-walk-client.ts +293 -293
  171. package/src/matchmaking/traffic-validation.ts +195 -195
  172. package/src/network/network-manager-service.ts +5 -0
  173. package/src/optimystic-node.ts +36 -0
  174. package/src/owned-block-seed.ts +53 -40
  175. package/src/peer-address-book.ts +149 -0
  176. package/src/protocol-limits.ts +33 -33
  177. package/src/reactivity/forwarder-host.ts +438 -438
  178. package/src/reactivity/index.ts +19 -19
  179. package/src/reactivity/notify-transport.ts +144 -144
  180. package/src/reactivity/origination-manager.ts +192 -192
  181. package/src/reactivity/protocols.ts +61 -61
  182. package/src/reactivity/push-state-gossip.ts +291 -291
  183. package/src/reactivity/recover-transport.ts +408 -408
  184. package/src/reactivity/rotation-rereg-scheduler.ts +256 -256
  185. package/src/reactivity/subscriber-registry.ts +96 -96
  186. package/src/reactivity/subscription-manager.ts +450 -450
  187. package/src/reactivity/topic-bytes.ts +37 -37
  188. package/src/repo/client.ts +12 -2
  189. package/src/repo/cluster-coordinator.ts +99 -3
  190. package/src/repo/coordinator-repo.ts +305 -82
  191. package/src/repo/types.ts +7 -7
  192. package/src/rn.ts +39 -34
  193. package/src/rpc-deadline.ts +45 -45
  194. package/src/storage/arachnode-partition.ts +74 -74
  195. package/src/storage/block-storage.ts +59 -6
  196. package/src/storage/cached-raw-storage.ts +180 -0
  197. package/src/storage/cached-store-driver.ts +859 -0
  198. package/src/storage/i-block-storage.ts +20 -1
  199. package/src/storage/i-kv-store.ts +8 -8
  200. package/src/storage/i-raw-storage.ts +12 -5
  201. package/src/storage/kv-raw-storage.ts +135 -135
  202. package/src/storage/memory-kv-store.ts +28 -28
  203. package/src/storage/memory-storage.ts +25 -25
  204. package/src/storage/memory-store-driver.ts +157 -157
  205. package/src/storage/raw-store-codec.ts +42 -42
  206. package/src/storage/raw-store-driver.ts +80 -80
  207. package/src/storage/ring-selector.ts +317 -317
  208. package/src/storage/ring-shift-coordinator.ts +271 -271
  209. package/src/storage/shared-cache-pool.ts +452 -0
  210. package/src/storage/storage-repo.ts +1014 -903
  211. package/src/testing/cohort-topic-mesh-harness.ts +663 -663
  212. package/src/testing/index.ts +8 -8
  213. package/src/testing/matchmaking-mesh-harness.ts +475 -475
  214. package/src/testing/raw-storage-conformance.ts +453 -397
  215. package/src/testing/reactivity-mesh-harness.ts +922 -922
  216. package/dist/src/storage/restoration-coordinator-v2.d.ts +0 -67
  217. package/dist/src/storage/restoration-coordinator-v2.d.ts.map +0 -1
  218. package/dist/src/storage/restoration-coordinator-v2.js +0 -172
  219. package/dist/src/storage/restoration-coordinator-v2.js.map +0 -1
@@ -0,0 +1,775 @@
1
+ import { defaultCachePool, SharedCachePool, CacheStoreHandle, } from "./shared-cache-pool.js";
2
+ /** True when `[lo, hi]` is entirely inside one covered interval. `covered` is sorted and disjoint. */
3
+ function coversRange(covered, lo, hi) {
4
+ for (const [a, b] of covered) {
5
+ if (lo >= a && hi <= b)
6
+ return true;
7
+ if (a > lo)
8
+ break;
9
+ }
10
+ return false;
11
+ }
12
+ /**
13
+ * Add `[lo, hi]` to the sorted disjoint interval list, merging overlaps AND integer
14
+ * adjacency (`[1,3]` + `[4,6]` → `[1,6]`), so contiguous point coverage from successive
15
+ * `putRevision` calls collapses into one interval instead of accumulating per-rev entries.
16
+ */
17
+ function addCovered(covered, lo, hi) {
18
+ const merged = [];
19
+ let newLo = lo;
20
+ let newHi = hi;
21
+ let inserted = false;
22
+ for (const [a, b] of covered) {
23
+ if (b < newLo - 1) {
24
+ merged.push([a, b]);
25
+ }
26
+ else if (a > newHi + 1) {
27
+ if (!inserted) {
28
+ merged.push([newLo, newHi]);
29
+ inserted = true;
30
+ }
31
+ merged.push([a, b]);
32
+ }
33
+ else {
34
+ newLo = Math.min(newLo, a);
35
+ newHi = Math.max(newHi, b);
36
+ }
37
+ }
38
+ if (!inserted) {
39
+ merged.push([newLo, newHi]);
40
+ }
41
+ return merged;
42
+ }
43
+ /** Approximate bytes for JS-object bookkeeping, charged so tiny/negative entries are not free. */
44
+ const CHAR_BYTES = 2;
45
+ /** Fixed cost of one pool entry: entry object + owner map slot + queue map slot (key string charged separately). */
46
+ const ENTRY_BASE = 256;
47
+ /** Per-revision cost inside a revision map: map slot + boxed rev + Uint8Array header. */
48
+ const REV_SLOT = 56;
49
+ /** Per-interval cost of the coverage list. */
50
+ const INTERVAL_SLOT = 56;
51
+ /** Per-id cost inside a pending-id set (id characters charged separately). */
52
+ const ID_SLOT = 40;
53
+ function idsContent(ids) {
54
+ let sum = 0;
55
+ for (const id of ids)
56
+ sum += ID_SLOT + id.length * CHAR_BYTES;
57
+ return sum;
58
+ }
59
+ /**
60
+ * Write-through coherent cache over any {@link RawStoreDriver}, bounded by a shared
61
+ * {@link SharedCachePool}. Wrap a backend's driver with this before handing it to
62
+ * `KvRawStorage` and every read the kernel issues is served from memory while the entry
63
+ * stays resident in the pool — the pool's 2Q admission keeps hot per-store entries
64
+ * protected while one-off bulk scans die in probation (see the pool's class doc).
65
+ *
66
+ * **Coherence, not eviction policy.** Every save stores its value INTO the cache as it writes
67
+ * the inner driver, rather than invalidating. The cache therefore always holds the last
68
+ * durable value for resident entries and never needs to re-read a key it has seen while that
69
+ * entry survives. This is what a plain invalidate-on-write memo cannot achieve at this seam:
70
+ * the hot reads exist to observe the writes, so invalidation lands between nearly every read
71
+ * pair (measured: only a 23% cut).
72
+ *
73
+ * **Why this is sound** — the invariants in `docs/storage.md` ("Invariants", 1–5):
74
+ * 1. every backend write funnels through `IRawStorage` (and thus this driver) in-process, so
75
+ * the cache sees every mutation;
76
+ * 2. every writer of `meta.latest` holds the per-block commit latch, and each cache update is
77
+ * synchronous with its inner write (no `await` between the inner call resolving and the
78
+ * cache mutation), so latch-protected read-after-write sees the new value exactly as a
79
+ * driver read would;
80
+ * 3. committed revisions and materializations are append-only.
81
+ *
82
+ * **Precondition: one process owns the store** (Invariant 5). A second process writing the
83
+ * same backend bypasses this wrapper and makes cached values stale in ways that feed
84
+ * consensus decisions. Not enforced in code — see docs/storage.md.
85
+ *
86
+ * **The cache is always clean, never dirty.** No write is deferred, reordered, or coalesced;
87
+ * the inner driver's durable state never depends on cache contents. Eviction of ANY entry at
88
+ * ANY instant is therefore correct — the next read falls through — which is precisely what
89
+ * lets the shared pool evict freely, without pins, dirty tracking, or an exhaustion error.
90
+ * Keep it that way: if a change here ever needs a dirty or pinned entry, the design has gone
91
+ * wrong — stop and reconsider.
92
+ *
93
+ * **Pool discipline** (the one rule new code here must follow): mutate this wrapper's own
94
+ * state FIRST, then make the pool call (`admit`/`updated`/`touch`/`drop`) LAST, and never
95
+ * touch cache state after the pool call — pool mutations can synchronously evict any entry,
96
+ * including the one just written. The eviction callback ({@link onPoolEvict}) removes only
97
+ * the wrapper's reference and never calls back into the pool.
98
+ *
99
+ * **Values are cached as bytes**, exactly the encoded value the kernel wrote or the driver
100
+ * returned. The kernel decodes fresh objects from those bytes on every read, so the
101
+ * clone-on-read/clone-on-write discipline stays structural (same argument as the codec
102
+ * boundary itself), and an entry's byte size feeds the pool's budget directly.
103
+ * NOTE: every cache hit still pays one JSON.parse in the kernel; if decode ever shows up hot
104
+ * on large materialized blocks, cache decoded objects plus an explicit clone instead.
105
+ *
106
+ * **Do not wrap `MemoryStoreDriver`.** The memory driver already holds the same byte
107
+ * references in maps; wrapping it duplicates every map entry (the bytes themselves are
108
+ * shared, so no byte copy — but the bookkeeping is pure overhead with nothing to save).
109
+ */
110
+ export class CachedStoreDriver {
111
+ inner;
112
+ pool;
113
+ blocks = new Map();
114
+ store;
115
+ /**
116
+ * Optional passthroughs are wired only when the inner driver provides them, mirroring
117
+ * `KvRawStorage`'s constructor: feature-detection above this wrapper must observe the
118
+ * inner driver's true capability. `listBlockIds` deliberately bypasses the cache — it
119
+ * enumerates the inner metadata keyspace, which funnelled writes keep authoritative.
120
+ * `close` is the deliberate exception (a real method below): releasing the store's pool
121
+ * registration is THIS wrapper's own capability, needed whether or not the inner driver
122
+ * has anything to close.
123
+ */
124
+ listBlockIds;
125
+ approximateBytesUsed;
126
+ constructor(inner, pool = defaultCachePool(), label) {
127
+ this.inner = inner;
128
+ this.pool = pool;
129
+ this.store = pool.registerStore(label);
130
+ if (inner.listBlockIds) {
131
+ this.listBlockIds = () => inner.listBlockIds();
132
+ }
133
+ if (inner.approximateBytesUsed) {
134
+ this.approximateBytesUsed = () => inner.approximateBytesUsed();
135
+ }
136
+ }
137
+ /**
138
+ * Drop every cached entry (releasing their pool residency) and this store's ghost keys —
139
+ * pre-clear recency must not fast-track post-clear refills into the protected queue.
140
+ * Always safe (the cache is clean — see class doc); the next read of each key re-consults
141
+ * the inner driver. In-flight enumerations notice the identity change of their entry
142
+ * objects and decline to claim completeness.
143
+ */
144
+ clear() {
145
+ for (const s of this.blocks.values()) {
146
+ if (s.meta)
147
+ this.pool.drop(s.meta);
148
+ if (s.revs)
149
+ this.pool.drop(s.revs);
150
+ if (s.pendList)
151
+ this.pool.drop(s.pendList);
152
+ for (const e of s.pending.values())
153
+ this.pool.drop(e);
154
+ for (const e of s.transactions.values())
155
+ this.pool.drop(e);
156
+ for (const e of s.materialized.values())
157
+ this.pool.drop(e);
158
+ }
159
+ this.blocks.clear();
160
+ this.pool.purgeGhosts(this.store);
161
+ }
162
+ /**
163
+ * Release this store entirely: drop all entries, unregister from the pool (the store id
164
+ * is never reused), and close the inner driver if it can be closed. A departed workspace
165
+ * that skips this leaks only cold entries the pool will evict under pressure — but call
166
+ * it; on a long-lived provider node the polite release is what keeps occupancy honest.
167
+ */
168
+ async close() {
169
+ this.clear();
170
+ this.pool.unregisterStore(this.store);
171
+ await this.inner.close?.();
172
+ }
173
+ /** This store's live pool occupancy; pool-wide numbers come from `SharedCachePool.stats()`. */
174
+ storeStats() {
175
+ return { id: this.store.id, label: this.store.label, bytes: this.store.bytes, entries: this.store.entries };
176
+ }
177
+ /**
178
+ * Pool eviction callback: remove OUR reference to the entry (identity-checked, so a stale
179
+ * callback can never delete a successor) and reap the block state if that emptied it.
180
+ * Runs synchronously inside a pool mutation — must not call back into the pool.
181
+ */
182
+ onPoolEvict(entry) {
183
+ const s = this.blocks.get(entry.blockId);
184
+ if (s === undefined)
185
+ return;
186
+ switch (entry.cls) {
187
+ case 'meta':
188
+ if (s.meta === entry)
189
+ s.meta = undefined;
190
+ break;
191
+ case 'revs':
192
+ if (s.revs === entry)
193
+ s.revs = undefined;
194
+ break;
195
+ case 'pendList':
196
+ if (s.pendList === entry)
197
+ s.pendList = undefined;
198
+ break;
199
+ case 'pending':
200
+ evictFromMap(s.pending, entry);
201
+ break;
202
+ case 'tx':
203
+ evictFromMap(s.transactions, entry);
204
+ break;
205
+ case 'mat':
206
+ evictFromMap(s.materialized, entry);
207
+ break;
208
+ }
209
+ this.dropIfEmpty(entry.blockId, s);
210
+ }
211
+ /**
212
+ * NOTE: this allocates an entry for EVERY block id touched, including ids that turn out
213
+ * not to exist (the proven-absent negative is the point). The shared pool charges those
214
+ * negatives — and the bare bookkeeping of empty container entries — against its budget
215
+ * (`ENTRY_BASE` + key), and {@link dropIfEmpty} reaps block states whose last entry is
216
+ * gone, so a remote peer streaming probes for nonexistent blocks (`StorageRepo.get` is
217
+ * reachable with an arbitrary block-id list) churns the probation queue instead of
218
+ * growing this map without bound.
219
+ */
220
+ state(blockId) {
221
+ let s = this.blocks.get(blockId);
222
+ if (!s) {
223
+ s = { pending: new Map(), transactions: new Map(), materialized: new Map() };
224
+ this.blocks.set(blockId, s);
225
+ }
226
+ return s;
227
+ }
228
+ /** Reap a block state holding no entries, so evictions and declined fills leave nothing behind. */
229
+ dropIfEmpty(blockId, s) {
230
+ if (s.meta === undefined && s.revs === undefined && s.pendList === undefined
231
+ && s.pending.size === 0 && s.transactions.size === 0 && s.materialized.size === 0
232
+ && this.blocks.get(blockId) === s) {
233
+ this.blocks.delete(blockId);
234
+ }
235
+ }
236
+ /**
237
+ * An inner read threw after {@link state} allocated: reap the (uncharged) empty state so
238
+ * a stream of probes against a throwing backend cannot grow `blocks` for free.
239
+ */
240
+ reapOnThrow(blockId, started) {
241
+ if (this.blocks.get(blockId) === started)
242
+ this.dropIfEmpty(blockId, started);
243
+ }
244
+ /**
245
+ * Install or update a point entry (meta / pending / tx / mat) as the LAST step of a write
246
+ * or read-miss fill. Handles the pool's large-value bypass: an over-limit value is not
247
+ * cached, and an existing entry growing over the limit is dropped to unknown (holding the
248
+ * stale prior value would be wrong; holding the oversized one would defeat the bypass).
249
+ */
250
+ cachePoint(blockId, s, cls, actionId, bytes, existing, attach, detach) {
251
+ const len = bytes === null ? 0 : bytes.length;
252
+ if (existing !== undefined) {
253
+ const charge = existing.base + len;
254
+ if (!this.pool.admits(charge)) {
255
+ detach();
256
+ this.pool.drop(existing);
257
+ this.dropIfEmpty(blockId, s);
258
+ return;
259
+ }
260
+ existing.value = bytes;
261
+ this.pool.updated(existing, charge);
262
+ return;
263
+ }
264
+ const key = this.pool.keyFor(this.store, cls, blockId, actionId);
265
+ const base = ENTRY_BASE + key.length * CHAR_BYTES;
266
+ if (!this.pool.admits(base + len)) {
267
+ this.dropIfEmpty(blockId, s);
268
+ return;
269
+ }
270
+ const entry = {
271
+ key, store: this.store, owner: this, cls, blockId, actionId,
272
+ value: bytes, base, charge: base + len, where: 'none',
273
+ };
274
+ attach(entry);
275
+ this.pool.admit(entry);
276
+ }
277
+ /**
278
+ * Cache a read-miss result into one of the map-backed entry classes, under BOTH fill
279
+ * guards. `started` is the state object the read began on:
280
+ *
281
+ * - **value guard** — fill only while the entry is still unknown, so a newer funnelled
282
+ * write that landed during the inner read is not clobbered by this older value;
283
+ * - **identity guard** — decline entirely if `clear()` (or the empty-state reaper)
284
+ * swapped the state object during the inner read. Without it a resumed read reinstalls
285
+ * its pre-clear value into the fresh state, and the newer write that superseded it went
286
+ * out with the old state — so the stale value would then be served forever. The
287
+ * revision and pending-list paths make the same identity check against their own pool
288
+ * entries.
289
+ */
290
+ fillMiss(blockId, started, map, cls, actionId, bytes) {
291
+ // `blocks.get`, not `state()` — a declined fill must not resurrect the block entry.
292
+ if (this.blocks.get(blockId) !== started)
293
+ return;
294
+ if (map.get(actionId) !== undefined)
295
+ return;
296
+ this.cachePoint(blockId, started, cls, actionId, bytes ?? null, undefined, e => map.set(actionId, e), () => map.delete(actionId));
297
+ }
298
+ // --- metadata ---
299
+ async getMetadata(blockId) {
300
+ const s = this.state(blockId);
301
+ const hit = s.meta;
302
+ if (hit !== undefined) {
303
+ this.pool.touch(hit);
304
+ return hit.value ?? undefined;
305
+ }
306
+ let bytes;
307
+ try {
308
+ bytes = await this.inner.getMetadata(blockId);
309
+ }
310
+ catch (err) {
311
+ this.reapOnThrow(blockId, s);
312
+ throw err;
313
+ }
314
+ // Same two fill guards as {@link fillMiss} (value + state identity), spelled out here
315
+ // because metadata is a property rather than a map entry. Caching the miss (`null`) is
316
+ // deliberate: everything that creates metadata funnels through this wrapper, so a
317
+ // confirmed miss stays provably absent until a funnelled write overwrites it —
318
+ // repeated probes of not-yet-created blocks are a real cold-start pattern.
319
+ if (this.blocks.get(blockId) === s && s.meta === undefined) {
320
+ this.cachePoint(blockId, s, 'meta', undefined, bytes ?? null, undefined, e => { s.meta = e; }, () => { s.meta = undefined; });
321
+ }
322
+ return bytes;
323
+ }
324
+ async putMetadata(blockId, value) {
325
+ try {
326
+ await this.inner.putMetadata(blockId, value);
327
+ }
328
+ catch (err) {
329
+ // The inner write failed with the backend in an unknown state — drop to unknown so
330
+ // the next read consults the driver. Same recovery shape on every write path below.
331
+ const s = this.blocks.get(blockId);
332
+ const m = s?.meta;
333
+ if (s !== undefined && m !== undefined) {
334
+ s.meta = undefined;
335
+ this.pool.drop(m);
336
+ this.dropIfEmpty(blockId, s);
337
+ }
338
+ throw err;
339
+ }
340
+ const s = this.state(blockId);
341
+ this.cachePoint(blockId, s, 'meta', undefined, value, s.meta, e => { s.meta = e; }, () => { s.meta = undefined; });
342
+ }
343
+ // --- revisions ---
344
+ /**
345
+ * Get or eagerly admit the block's revision-map entry. Eager (before any inner await) so
346
+ * the fill guards have a stable identity to check across the await; the empty container
347
+ * is charged its base cost, so probe streams pay for their bookkeeping. Returns
348
+ * `undefined` when the pool bypasses even the base charge (absurdly small budget) — the
349
+ * callers then pass straight through to the inner driver, uncached.
350
+ */
351
+ ensureRevs(blockId) {
352
+ const s = this.state(blockId);
353
+ if (s.revs !== undefined)
354
+ return s.revs;
355
+ const key = this.pool.keyFor(this.store, 'revs', blockId);
356
+ const base = ENTRY_BASE + key.length * CHAR_BYTES;
357
+ if (!this.pool.admits(base)) {
358
+ this.dropIfEmpty(blockId, s);
359
+ return undefined;
360
+ }
361
+ const entry = {
362
+ key, store: this.store, owner: this, cls: 'revs', blockId, actionId: undefined,
363
+ value: { byRev: new Map(), covered: [], gen: 0 }, base, charge: base, where: 'none',
364
+ };
365
+ s.revs = entry;
366
+ this.pool.admit(entry);
367
+ return entry;
368
+ }
369
+ async getRevision(blockId, rev) {
370
+ const entry = this.ensureRevs(blockId);
371
+ if (entry === undefined)
372
+ return this.inner.getRevision(blockId, rev);
373
+ const revs = entry.value;
374
+ if (coversRange(revs.covered, rev, rev)) {
375
+ this.pool.touch(entry);
376
+ return revs.byRev.get(rev);
377
+ }
378
+ const bytes = await this.inner.getRevision(blockId, rev);
379
+ const current = this.blocks.get(blockId)?.revs;
380
+ if (current === entry && !coversRange(revs.covered, rev, rev)) {
381
+ let charge = entry.charge;
382
+ if (bytes !== undefined) {
383
+ revs.byRev.set(rev, bytes);
384
+ charge += REV_SLOT + bytes.length;
385
+ }
386
+ const before = revs.covered.length;
387
+ revs.covered = addCovered(revs.covered, rev, rev);
388
+ charge += (revs.covered.length - before) * INTERVAL_SLOT;
389
+ this.pool.updated(entry, charge);
390
+ }
391
+ return bytes;
392
+ }
393
+ async putRevision(blockId, rev, value) {
394
+ try {
395
+ await this.inner.putRevision(blockId, rev, value);
396
+ }
397
+ catch (err) {
398
+ const s = this.blocks.get(blockId);
399
+ const entry = s?.revs;
400
+ if (s !== undefined && entry !== undefined) {
401
+ s.revs = undefined;
402
+ this.pool.drop(entry);
403
+ this.dropIfEmpty(blockId, s);
404
+ }
405
+ throw err;
406
+ }
407
+ const entry = this.ensureRevs(blockId);
408
+ if (entry === undefined)
409
+ return;
410
+ const revs = entry.value;
411
+ const had = revs.byRev.get(rev);
412
+ revs.byRev.set(rev, value);
413
+ let charge = entry.charge + (had !== undefined ? value.length - had.length : REV_SLOT + value.length);
414
+ const before = revs.covered.length;
415
+ revs.covered = addCovered(revs.covered, rev, rev);
416
+ charge += (revs.covered.length - before) * INTERVAL_SLOT;
417
+ revs.gen++;
418
+ this.pool.updated(entry, charge);
419
+ }
420
+ async *rangeRevisions(blockId, lo, hi, reverse) {
421
+ const entry = this.ensureRevs(blockId);
422
+ if (entry === undefined) {
423
+ const drained = [];
424
+ for await (const item of this.inner.rangeRevisions(blockId, lo, hi, reverse)) {
425
+ drained.push(item);
426
+ }
427
+ yield* drained;
428
+ return;
429
+ }
430
+ const revs = entry.value;
431
+ if (coversRange(revs.covered, lo, hi)) {
432
+ this.pool.touch(entry);
433
+ // Snapshot before yielding (drain-before-yield): concurrent writes during the
434
+ // consumer's awaits must not mutate what this iteration yields.
435
+ // NOTE: this walks every integer in [lo, hi], not just the present revs — fine
436
+ // while revisions are dense (one per commit) and callers bound `hi` by a real
437
+ // `latest.rev`. If a sparse or very wide range ever appears here, iterate
438
+ // `byRev`'s keys sorted instead.
439
+ const out = [];
440
+ if (reverse) {
441
+ for (let rev = hi; rev >= lo; rev--) {
442
+ const bytes = revs.byRev.get(rev);
443
+ if (bytes !== undefined)
444
+ out.push([rev, bytes]);
445
+ }
446
+ }
447
+ else {
448
+ for (let rev = lo; rev <= hi; rev++) {
449
+ const bytes = revs.byRev.get(rev);
450
+ if (bytes !== undefined)
451
+ out.push([rev, bytes]);
452
+ }
453
+ }
454
+ yield* out;
455
+ return;
456
+ }
457
+ const gen = revs.gen;
458
+ const drained = [];
459
+ for await (const item of this.inner.rangeRevisions(blockId, lo, hi, reverse)) {
460
+ drained.push(item);
461
+ }
462
+ // Claim coverage of [lo, hi] only if nothing mutated the map during the drain (gen
463
+ // unchanged, same entry — clear() and pool eviction both swap the entry). A write that
464
+ // landed mid-drain may be missing from `drained`, and recording coverage anyway would
465
+ // turn that miss into a provably-wrong "rev absent" answer forever after.
466
+ const current = this.blocks.get(blockId)?.revs;
467
+ if (current === entry && revs.gen === gen) {
468
+ let charge = entry.charge;
469
+ for (const [rev, bytes] of drained) {
470
+ const had = revs.byRev.get(rev);
471
+ revs.byRev.set(rev, bytes);
472
+ charge += had !== undefined ? bytes.length - had.length : REV_SLOT + bytes.length;
473
+ }
474
+ const before = revs.covered.length;
475
+ revs.covered = addCovered(revs.covered, lo, hi);
476
+ charge += (revs.covered.length - before) * INTERVAL_SLOT;
477
+ this.pool.updated(entry, charge);
478
+ }
479
+ yield* drained;
480
+ }
481
+ // --- pending ---
482
+ /** Same eager-admission shape (and bypass fallback) as {@link ensureRevs}, for the pending-id set. */
483
+ ensurePendList(blockId) {
484
+ const s = this.state(blockId);
485
+ if (s.pendList !== undefined)
486
+ return s.pendList;
487
+ const key = this.pool.keyFor(this.store, 'pendList', blockId);
488
+ const base = ENTRY_BASE + key.length * CHAR_BYTES;
489
+ if (!this.pool.admits(base)) {
490
+ this.dropIfEmpty(blockId, s);
491
+ return undefined;
492
+ }
493
+ const entry = {
494
+ key, store: this.store, owner: this, cls: 'pendList', blockId, actionId: undefined,
495
+ value: { ids: new Set(), complete: false, gen: 0 }, base, charge: base, where: 'none',
496
+ };
497
+ s.pendList = entry;
498
+ this.pool.admit(entry);
499
+ return entry;
500
+ }
501
+ /** Mirror a funnelled pend into the id set, if one is resident. Re-reads the entry — the write that preceded this call may have evicted it. */
502
+ notePendListAdd(blockId, actionId) {
503
+ const entry = this.blocks.get(blockId)?.pendList;
504
+ if (entry === undefined)
505
+ return;
506
+ const list = entry.value;
507
+ let charge = entry.charge;
508
+ if (!list.ids.has(actionId)) {
509
+ list.ids.add(actionId);
510
+ charge += ID_SLOT + actionId.length * CHAR_BYTES;
511
+ }
512
+ list.gen++;
513
+ this.pool.updated(entry, charge);
514
+ }
515
+ notePendListRemove(blockId, actionId) {
516
+ const entry = this.blocks.get(blockId)?.pendList;
517
+ if (entry === undefined)
518
+ return;
519
+ const list = entry.value;
520
+ let charge = entry.charge;
521
+ if (list.ids.delete(actionId)) {
522
+ charge -= ID_SLOT + actionId.length * CHAR_BYTES;
523
+ }
524
+ list.gen++;
525
+ this.pool.updated(entry, charge);
526
+ }
527
+ /** Failed pending write: the affected value entry AND the id set drop to unknown. */
528
+ dropPendingState(blockId, actionId) {
529
+ const s = this.blocks.get(blockId);
530
+ if (s === undefined)
531
+ return;
532
+ const p = s.pending.get(actionId);
533
+ if (p !== undefined) {
534
+ s.pending.delete(actionId);
535
+ this.pool.drop(p);
536
+ }
537
+ const list = s.pendList;
538
+ if (list !== undefined) {
539
+ s.pendList = undefined;
540
+ this.pool.drop(list);
541
+ }
542
+ this.dropIfEmpty(blockId, s);
543
+ }
544
+ async getPending(blockId, actionId) {
545
+ const s = this.state(blockId);
546
+ const cached = s.pending.get(actionId);
547
+ if (cached !== undefined) {
548
+ this.pool.touch(cached);
549
+ return cached.value ?? undefined;
550
+ }
551
+ let bytes;
552
+ try {
553
+ bytes = await this.inner.getPending(blockId, actionId);
554
+ }
555
+ catch (err) {
556
+ this.reapOnThrow(blockId, s);
557
+ throw err;
558
+ }
559
+ this.fillMiss(blockId, s, s.pending, 'pending', actionId, bytes);
560
+ return bytes;
561
+ }
562
+ async putPending(blockId, actionId, value) {
563
+ try {
564
+ await this.inner.putPending(blockId, actionId, value);
565
+ }
566
+ catch (err) {
567
+ this.dropPendingState(blockId, actionId);
568
+ throw err;
569
+ }
570
+ const s = this.state(blockId);
571
+ this.cachePoint(blockId, s, 'pending', actionId, value, s.pending.get(actionId), e => s.pending.set(actionId, e), () => s.pending.delete(actionId));
572
+ this.notePendListAdd(blockId, actionId);
573
+ }
574
+ async deletePending(blockId, actionId) {
575
+ try {
576
+ await this.inner.deletePending(blockId, actionId);
577
+ }
578
+ catch (err) {
579
+ this.dropPendingState(blockId, actionId);
580
+ throw err;
581
+ }
582
+ const s = this.state(blockId);
583
+ this.cachePoint(blockId, s, 'pending', actionId, null, s.pending.get(actionId), e => s.pending.set(actionId, e), () => s.pending.delete(actionId));
584
+ this.notePendListRemove(blockId, actionId);
585
+ }
586
+ async *listPendingActionIds(blockId) {
587
+ const entry = this.ensurePendList(blockId);
588
+ if (entry === undefined) {
589
+ const drained = [];
590
+ for await (const id of this.inner.listPendingActionIds(blockId)) {
591
+ drained.push(id);
592
+ }
593
+ yield* drained;
594
+ return;
595
+ }
596
+ const list = entry.value;
597
+ if (list.complete) {
598
+ this.pool.touch(entry);
599
+ yield* Array.from(list.ids);
600
+ return;
601
+ }
602
+ // One full enumeration seeds completeness; funnelled writes maintain it from then on.
603
+ // Completeness is NEVER inferred from metadata birth: at the raw layer a pending
604
+ // record CAN exist for a block with no metadata (the conformance suite writes exactly
605
+ // that), so only an actual drain of the inner driver proves the set.
606
+ const gen = list.gen;
607
+ const drained = [];
608
+ for await (const id of this.inner.listPendingActionIds(blockId)) {
609
+ drained.push(id);
610
+ }
611
+ const current = this.blocks.get(blockId)?.pendList;
612
+ if (current === entry && list.gen === gen) {
613
+ let charge = entry.charge - idsContent(list.ids);
614
+ list.ids = new Set(drained);
615
+ list.complete = true;
616
+ charge += idsContent(list.ids);
617
+ this.pool.updated(entry, charge);
618
+ }
619
+ yield* drained;
620
+ }
621
+ // --- transactions ---
622
+ async getTransaction(blockId, actionId) {
623
+ const s = this.state(blockId);
624
+ const cached = s.transactions.get(actionId);
625
+ if (cached !== undefined) {
626
+ this.pool.touch(cached);
627
+ return cached.value ?? undefined;
628
+ }
629
+ let bytes;
630
+ try {
631
+ bytes = await this.inner.getTransaction(blockId, actionId);
632
+ }
633
+ catch (err) {
634
+ this.reapOnThrow(blockId, s);
635
+ throw err;
636
+ }
637
+ this.fillMiss(blockId, s, s.transactions, 'tx', actionId, bytes);
638
+ return bytes;
639
+ }
640
+ async putTransaction(blockId, actionId, value) {
641
+ try {
642
+ await this.inner.putTransaction(blockId, actionId, value);
643
+ }
644
+ catch (err) {
645
+ this.dropMapEntry(blockId, 'transactions', actionId);
646
+ throw err;
647
+ }
648
+ const s = this.state(blockId);
649
+ this.cachePoint(blockId, s, 'tx', actionId, value, s.transactions.get(actionId), e => s.transactions.set(actionId, e), () => s.transactions.delete(actionId));
650
+ }
651
+ // --- materialized ---
652
+ async getMaterialized(blockId, actionId) {
653
+ const s = this.state(blockId);
654
+ const cached = s.materialized.get(actionId);
655
+ if (cached !== undefined) {
656
+ this.pool.touch(cached);
657
+ return cached.value ?? undefined;
658
+ }
659
+ let bytes;
660
+ try {
661
+ bytes = await this.inner.getMaterialized(blockId, actionId);
662
+ }
663
+ catch (err) {
664
+ this.reapOnThrow(blockId, s);
665
+ throw err;
666
+ }
667
+ this.fillMiss(blockId, s, s.materialized, 'mat', actionId, bytes);
668
+ return bytes;
669
+ }
670
+ async putMaterialized(blockId, actionId, value) {
671
+ try {
672
+ await this.inner.putMaterialized(blockId, actionId, value);
673
+ }
674
+ catch (err) {
675
+ this.dropMapEntry(blockId, 'materialized', actionId);
676
+ throw err;
677
+ }
678
+ const s = this.state(blockId);
679
+ this.cachePoint(blockId, s, 'mat', actionId, value, s.materialized.get(actionId), e => s.materialized.set(actionId, e), () => s.materialized.delete(actionId));
680
+ }
681
+ async deleteMaterialized(blockId, actionId) {
682
+ try {
683
+ await this.inner.deleteMaterialized(blockId, actionId);
684
+ }
685
+ catch (err) {
686
+ this.dropMapEntry(blockId, 'materialized', actionId);
687
+ throw err;
688
+ }
689
+ // A delete through the funnel is a PROVEN absence, not an unknown.
690
+ const s = this.state(blockId);
691
+ this.cachePoint(blockId, s, 'mat', actionId, null, s.materialized.get(actionId), e => s.materialized.set(actionId, e), () => s.materialized.delete(actionId));
692
+ }
693
+ /** Error-path invalidation of one map-backed entry (write failed → unknown). */
694
+ dropMapEntry(blockId, which, actionId) {
695
+ const s = this.blocks.get(blockId);
696
+ if (s === undefined)
697
+ return;
698
+ const map = s[which];
699
+ const e = map.get(actionId);
700
+ if (e !== undefined) {
701
+ map.delete(actionId);
702
+ this.pool.drop(e);
703
+ this.dropIfEmpty(blockId, s);
704
+ }
705
+ }
706
+ // --- promote (the single hardest coherence point — see "Invariant P" on
707
+ // `IBlockStorage.promotePendingTransaction`, src/storage/i-block-storage.ts) ---
708
+ /**
709
+ * The inner driver performs the atomic pending → committed move; this wrapper then mirrors
710
+ * it as one synchronous cache mutation sequence. When the pending transform was never
711
+ * cached — pended before this wrapper attached, or its entry EVICTED by the pool — the
712
+ * committed entry is INVALIDATED rather than synthesized: fabricating it would recreate
713
+ * exactly the phantom-record class Invariant P exists to prevent. Invalidation also
714
+ * removes any cached negative for the committed entry, which the promote has just made
715
+ * stale.
716
+ *
717
+ * Eviction landing between the three coupled mutations is safe by construction: the inner
718
+ * atomic move has already resolved before the first cache mutation, so each of the three
719
+ * entries (pending value, pending-id set, committed value) steps from one individually
720
+ * coherent state to another — an eviction merely turns one of those steps into "unknown,
721
+ * fall through", never into a fabricated value.
722
+ */
723
+ async promote(blockId, actionId) {
724
+ try {
725
+ await this.inner.promote(blockId, actionId);
726
+ }
727
+ catch (err) {
728
+ // On the contract's missing-pend throw the inner state is unchanged, but the throw
729
+ // may also be a mid-operation fault whose outcome is unknown ("exactly one of the
730
+ // two states") — drop all three affected entries to unknown rather than guess.
731
+ const s = this.blocks.get(blockId);
732
+ if (s !== undefined) {
733
+ const p = s.pending.get(actionId);
734
+ if (p !== undefined) {
735
+ s.pending.delete(actionId);
736
+ this.pool.drop(p);
737
+ }
738
+ const t = s.transactions.get(actionId);
739
+ if (t !== undefined) {
740
+ s.transactions.delete(actionId);
741
+ this.pool.drop(t);
742
+ }
743
+ const list = s.pendList;
744
+ if (list !== undefined) {
745
+ s.pendList = undefined;
746
+ this.pool.drop(list);
747
+ }
748
+ this.dropIfEmpty(blockId, s);
749
+ }
750
+ throw err;
751
+ }
752
+ const s = this.state(blockId);
753
+ const pendingBytes = s.pending.get(actionId)?.value;
754
+ this.cachePoint(blockId, s, 'pending', actionId, null, s.pending.get(actionId), e => s.pending.set(actionId, e), () => s.pending.delete(actionId));
755
+ this.notePendListRemove(blockId, actionId);
756
+ if (pendingBytes instanceof Uint8Array) {
757
+ // The block state may have been reaped by an eviction the mutations above caused;
758
+ // re-fetch (or re-create) it before installing the committed value.
759
+ const s2 = this.blocks.get(blockId) ?? this.state(blockId);
760
+ this.cachePoint(blockId, s2, 'tx', actionId, pendingBytes, s2.transactions.get(actionId), e => s2.transactions.set(actionId, e), () => s2.transactions.delete(actionId));
761
+ }
762
+ else {
763
+ // Unknown (never observed, or evicted) — or a cached negative that promote just
764
+ // contradicted, which the funnel makes unreachable but is handled identically for
765
+ // safety. Invalidate; never synthesize.
766
+ this.dropMapEntry(blockId, 'transactions', actionId);
767
+ }
768
+ }
769
+ }
770
+ function evictFromMap(map, entry) {
771
+ if (entry.actionId !== undefined && map.get(entry.actionId) === entry) {
772
+ map.delete(entry.actionId);
773
+ }
774
+ }
775
+ //# sourceMappingURL=cached-store-driver.js.map