@optimystic/db-core 0.13.5 → 0.14.1
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.
- package/dist/src/cluster/structs.d.ts +13 -0
- package/dist/src/cluster/structs.d.ts.map +1 -1
- package/dist/src/cohort-topic/addressing.d.ts +53 -0
- package/dist/src/cohort-topic/addressing.d.ts.map +1 -0
- package/dist/src/cohort-topic/addressing.js +95 -0
- package/dist/src/cohort-topic/addressing.js.map +1 -0
- package/dist/src/cohort-topic/antidos/bootstrap-evidence-envelope.d.ts +105 -0
- package/dist/src/cohort-topic/antidos/bootstrap-evidence-envelope.d.ts.map +1 -0
- package/dist/src/cohort-topic/antidos/bootstrap-evidence-envelope.js +197 -0
- package/dist/src/cohort-topic/antidos/bootstrap-evidence-envelope.js.map +1 -0
- package/dist/src/cohort-topic/antidos/bootstrap-evidence.d.ts +50 -0
- package/dist/src/cohort-topic/antidos/bootstrap-evidence.d.ts.map +1 -0
- package/dist/src/cohort-topic/antidos/bootstrap-evidence.js +62 -0
- package/dist/src/cohort-topic/antidos/bootstrap-evidence.js.map +1 -0
- package/dist/src/cohort-topic/antidos/index.d.ts +6 -0
- package/dist/src/cohort-topic/antidos/index.d.ts.map +1 -0
- package/dist/src/cohort-topic/antidos/index.js +6 -0
- package/dist/src/cohort-topic/antidos/index.js.map +1 -0
- package/dist/src/cohort-topic/antidos/rate-limiter.d.ts +95 -0
- package/dist/src/cohort-topic/antidos/rate-limiter.d.ts.map +1 -0
- package/dist/src/cohort-topic/antidos/rate-limiter.js +146 -0
- package/dist/src/cohort-topic/antidos/rate-limiter.js.map +1 -0
- package/dist/src/cohort-topic/antidos/replay-guard.d.ts +37 -0
- package/dist/src/cohort-topic/antidos/replay-guard.d.ts.map +1 -0
- package/dist/src/cohort-topic/antidos/replay-guard.js +78 -0
- package/dist/src/cohort-topic/antidos/replay-guard.js.map +1 -0
- package/dist/src/cohort-topic/antidos/topic-budget.d.ts +50 -0
- package/dist/src/cohort-topic/antidos/topic-budget.d.ts.map +1 -0
- package/dist/src/cohort-topic/antidos/topic-budget.js +95 -0
- package/dist/src/cohort-topic/antidos/topic-budget.js.map +1 -0
- package/dist/src/cohort-topic/antiflood/index.d.ts +3 -0
- package/dist/src/cohort-topic/antiflood/index.d.ts.map +1 -0
- package/dist/src/cohort-topic/antiflood/index.js +3 -0
- package/dist/src/cohort-topic/antiflood/index.js.map +1 -0
- package/dist/src/cohort-topic/antiflood/invariants.d.ts +70 -0
- package/dist/src/cohort-topic/antiflood/invariants.d.ts.map +1 -0
- package/dist/src/cohort-topic/antiflood/invariants.js +86 -0
- package/dist/src/cohort-topic/antiflood/invariants.js.map +1 -0
- package/dist/src/cohort-topic/antiflood/jitter.d.ts +65 -0
- package/dist/src/cohort-topic/antiflood/jitter.d.ts.map +1 -0
- package/dist/src/cohort-topic/antiflood/jitter.js +75 -0
- package/dist/src/cohort-topic/antiflood/jitter.js.map +1 -0
- package/dist/src/cohort-topic/coldstart.d.ts +117 -0
- package/dist/src/cohort-topic/coldstart.d.ts.map +1 -0
- package/dist/src/cohort-topic/coldstart.js +127 -0
- package/dist/src/cohort-topic/coldstart.js.map +1 -0
- package/dist/src/cohort-topic/dmax.d.ts +44 -0
- package/dist/src/cohort-topic/dmax.d.ts.map +1 -0
- package/dist/src/cohort-topic/dmax.js +70 -0
- package/dist/src/cohort-topic/dmax.js.map +1 -0
- package/dist/src/cohort-topic/gossip/bus.d.ts +85 -0
- package/dist/src/cohort-topic/gossip/bus.d.ts.map +1 -0
- package/dist/src/cohort-topic/gossip/bus.js +146 -0
- package/dist/src/cohort-topic/gossip/bus.js.map +1 -0
- package/dist/src/cohort-topic/gossip/index.d.ts +4 -0
- package/dist/src/cohort-topic/gossip/index.d.ts.map +1 -0
- package/dist/src/cohort-topic/gossip/index.js +4 -0
- package/dist/src/cohort-topic/gossip/index.js.map +1 -0
- package/dist/src/cohort-topic/gossip/records.d.ts +12 -0
- package/dist/src/cohort-topic/gossip/records.d.ts.map +1 -0
- package/dist/src/cohort-topic/gossip/records.js +41 -0
- package/dist/src/cohort-topic/gossip/records.js.map +1 -0
- package/dist/src/cohort-topic/gossip/view.d.ts +39 -0
- package/dist/src/cohort-topic/gossip/view.d.ts.map +1 -0
- package/dist/src/cohort-topic/gossip/view.js +30 -0
- package/dist/src/cohort-topic/gossip/view.js.map +1 -0
- package/dist/src/cohort-topic/index.d.ts +21 -0
- package/dist/src/cohort-topic/index.d.ts.map +1 -0
- package/dist/src/cohort-topic/index.js +21 -0
- package/dist/src/cohort-topic/index.js.map +1 -0
- package/dist/src/cohort-topic/load/barometer.d.ts +78 -0
- package/dist/src/cohort-topic/load/barometer.d.ts.map +1 -0
- package/dist/src/cohort-topic/load/barometer.js +93 -0
- package/dist/src/cohort-topic/load/barometer.js.map +1 -0
- package/dist/src/cohort-topic/load/index.d.ts +2 -0
- package/dist/src/cohort-topic/load/index.d.ts.map +1 -0
- package/dist/src/cohort-topic/load/index.js +2 -0
- package/dist/src/cohort-topic/load/index.js.map +1 -0
- package/dist/src/cohort-topic/member-engine.d.ts +134 -0
- package/dist/src/cohort-topic/member-engine.d.ts.map +1 -0
- package/dist/src/cohort-topic/member-engine.js +264 -0
- package/dist/src/cohort-topic/member-engine.js.map +1 -0
- package/dist/src/cohort-topic/membership/index.d.ts +4 -0
- package/dist/src/cohort-topic/membership/index.d.ts.map +1 -0
- package/dist/src/cohort-topic/membership/index.js +4 -0
- package/dist/src/cohort-topic/membership/index.js.map +1 -0
- package/dist/src/cohort-topic/membership/publisher.d.ts +82 -0
- package/dist/src/cohort-topic/membership/publisher.d.ts.map +1 -0
- package/dist/src/cohort-topic/membership/publisher.js +107 -0
- package/dist/src/cohort-topic/membership/publisher.js.map +1 -0
- package/dist/src/cohort-topic/membership/source.d.ts +31 -0
- package/dist/src/cohort-topic/membership/source.d.ts.map +1 -0
- package/dist/src/cohort-topic/membership/source.js +32 -0
- package/dist/src/cohort-topic/membership/source.js.map +1 -0
- package/dist/src/cohort-topic/membership/verifier.d.ts +96 -0
- package/dist/src/cohort-topic/membership/verifier.d.ts.map +1 -0
- package/dist/src/cohort-topic/membership/verifier.js +250 -0
- package/dist/src/cohort-topic/membership/verifier.js.map +1 -0
- package/dist/src/cohort-topic/ports.d.ts +149 -0
- package/dist/src/cohort-topic/ports.d.ts.map +1 -0
- package/dist/src/cohort-topic/ports.js +25 -0
- package/dist/src/cohort-topic/ports.js.map +1 -0
- package/dist/src/cohort-topic/promotion.d.ts +135 -0
- package/dist/src/cohort-topic/promotion.d.ts.map +1 -0
- package/dist/src/cohort-topic/promotion.js +269 -0
- package/dist/src/cohort-topic/promotion.js.map +1 -0
- package/dist/src/cohort-topic/registration/bytes.d.ts +16 -0
- package/dist/src/cohort-topic/registration/bytes.d.ts.map +1 -0
- package/dist/src/cohort-topic/registration/bytes.js +32 -0
- package/dist/src/cohort-topic/registration/bytes.js.map +1 -0
- package/dist/src/cohort-topic/registration/handoff.d.ts +69 -0
- package/dist/src/cohort-topic/registration/handoff.d.ts.map +1 -0
- package/dist/src/cohort-topic/registration/handoff.js +98 -0
- package/dist/src/cohort-topic/registration/handoff.js.map +1 -0
- package/dist/src/cohort-topic/registration/index.d.ts +7 -0
- package/dist/src/cohort-topic/registration/index.d.ts.map +1 -0
- package/dist/src/cohort-topic/registration/index.js +7 -0
- package/dist/src/cohort-topic/registration/index.js.map +1 -0
- package/dist/src/cohort-topic/registration/renewal.d.ts +115 -0
- package/dist/src/cohort-topic/registration/renewal.d.ts.map +1 -0
- package/dist/src/cohort-topic/registration/renewal.js +306 -0
- package/dist/src/cohort-topic/registration/renewal.js.map +1 -0
- package/dist/src/cohort-topic/registration/sharding.d.ts +31 -0
- package/dist/src/cohort-topic/registration/sharding.d.ts.map +1 -0
- package/dist/src/cohort-topic/registration/sharding.js +48 -0
- package/dist/src/cohort-topic/registration/sharding.js.map +1 -0
- package/dist/src/cohort-topic/registration/store.d.ts +13 -0
- package/dist/src/cohort-topic/registration/store.d.ts.map +1 -0
- package/dist/src/cohort-topic/registration/store.js +72 -0
- package/dist/src/cohort-topic/registration/store.js.map +1 -0
- package/dist/src/cohort-topic/registration/types.d.ts +71 -0
- package/dist/src/cohort-topic/registration/types.d.ts.map +1 -0
- package/dist/src/cohort-topic/registration/types.js +27 -0
- package/dist/src/cohort-topic/registration/types.js.map +1 -0
- package/dist/src/cohort-topic/ring-hash.d.ts +27 -0
- package/dist/src/cohort-topic/ring-hash.d.ts.map +1 -0
- package/dist/src/cohort-topic/ring-hash.js +45 -0
- package/dist/src/cohort-topic/ring-hash.js.map +1 -0
- package/dist/src/cohort-topic/service.d.ts +157 -0
- package/dist/src/cohort-topic/service.d.ts.map +1 -0
- package/dist/src/cohort-topic/service.js +237 -0
- package/dist/src/cohort-topic/service.js.map +1 -0
- package/dist/src/cohort-topic/sig/index.d.ts +3 -0
- package/dist/src/cohort-topic/sig/index.d.ts.map +1 -0
- package/dist/src/cohort-topic/sig/index.js +3 -0
- package/dist/src/cohort-topic/sig/index.js.map +1 -0
- package/dist/src/cohort-topic/sig/payloads.d.ts +25 -0
- package/dist/src/cohort-topic/sig/payloads.d.ts.map +1 -0
- package/dist/src/cohort-topic/sig/payloads.js +25 -0
- package/dist/src/cohort-topic/sig/payloads.js.map +1 -0
- package/dist/src/cohort-topic/sig/threshold.d.ts +33 -0
- package/dist/src/cohort-topic/sig/threshold.d.ts.map +1 -0
- package/dist/src/cohort-topic/sig/threshold.js +51 -0
- package/dist/src/cohort-topic/sig/threshold.js.map +1 -0
- package/dist/src/cohort-topic/tiers.d.ts +58 -0
- package/dist/src/cohort-topic/tiers.d.ts.map +1 -0
- package/dist/src/cohort-topic/tiers.js +49 -0
- package/dist/src/cohort-topic/tiers.js.map +1 -0
- package/dist/src/cohort-topic/traffic.d.ts +90 -0
- package/dist/src/cohort-topic/traffic.d.ts.map +1 -0
- package/dist/src/cohort-topic/traffic.js +146 -0
- package/dist/src/cohort-topic/traffic.js.map +1 -0
- package/dist/src/cohort-topic/walk.d.ts +123 -0
- package/dist/src/cohort-topic/walk.d.ts.map +1 -0
- package/dist/src/cohort-topic/walk.js +150 -0
- package/dist/src/cohort-topic/walk.js.map +1 -0
- package/dist/src/cohort-topic/willingness.d.ts +123 -0
- package/dist/src/cohort-topic/willingness.d.ts.map +1 -0
- package/dist/src/cohort-topic/willingness.js +143 -0
- package/dist/src/cohort-topic/willingness.js.map +1 -0
- package/dist/src/cohort-topic/wire/codec.d.ts +42 -0
- package/dist/src/cohort-topic/wire/codec.d.ts.map +1 -0
- package/dist/src/cohort-topic/wire/codec.js +163 -0
- package/dist/src/cohort-topic/wire/codec.js.map +1 -0
- package/dist/src/cohort-topic/wire/index.d.ts +6 -0
- package/dist/src/cohort-topic/wire/index.d.ts.map +1 -0
- package/dist/src/cohort-topic/wire/index.js +6 -0
- package/dist/src/cohort-topic/wire/index.js.map +1 -0
- package/dist/src/cohort-topic/wire/payloads.d.ts +38 -0
- package/dist/src/cohort-topic/wire/payloads.d.ts.map +1 -0
- package/dist/src/cohort-topic/wire/payloads.js +102 -0
- package/dist/src/cohort-topic/wire/payloads.js.map +1 -0
- package/dist/src/cohort-topic/wire/types.d.ts +304 -0
- package/dist/src/cohort-topic/wire/types.d.ts.map +1 -0
- package/dist/src/cohort-topic/wire/types.js +16 -0
- package/dist/src/cohort-topic/wire/types.js.map +1 -0
- package/dist/src/cohort-topic/wire/validate.d.ts +25 -0
- package/dist/src/cohort-topic/wire/validate.d.ts.map +1 -0
- package/dist/src/cohort-topic/wire/validate.js +427 -0
- package/dist/src/cohort-topic/wire/validate.js.map +1 -0
- package/dist/src/collection/collection.d.ts +58 -1
- package/dist/src/collection/collection.d.ts.map +1 -1
- package/dist/src/collection/collection.js +76 -0
- package/dist/src/collection/collection.js.map +1 -1
- package/dist/src/collections/tree/tree.d.ts +58 -2
- package/dist/src/collections/tree/tree.d.ts.map +1 -1
- package/dist/src/collections/tree/tree.js +59 -2
- package/dist/src/collections/tree/tree.js.map +1 -1
- package/dist/src/index.d.ts +3 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +3 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/log/log.d.ts +42 -4
- package/dist/src/log/log.d.ts.map +1 -1
- package/dist/src/log/log.js +71 -3
- package/dist/src/log/log.js.map +1 -1
- package/dist/src/log/struct.d.ts +122 -2
- package/dist/src/log/struct.d.ts.map +1 -1
- package/dist/src/log/struct.js.map +1 -1
- package/dist/src/matchmaking/capability-filter.d.ts +24 -0
- package/dist/src/matchmaking/capability-filter.d.ts.map +1 -0
- package/dist/src/matchmaking/capability-filter.js +37 -0
- package/dist/src/matchmaking/capability-filter.js.map +1 -0
- package/dist/src/matchmaking/config.d.ts +77 -0
- package/dist/src/matchmaking/config.d.ts.map +1 -0
- package/dist/src/matchmaking/config.js +69 -0
- package/dist/src/matchmaking/config.js.map +1 -0
- package/dist/src/matchmaking/index.d.ts +21 -0
- package/dist/src/matchmaking/index.d.ts.map +1 -0
- package/dist/src/matchmaking/index.js +21 -0
- package/dist/src/matchmaking/index.js.map +1 -0
- package/dist/src/matchmaking/multi-cohort-seeker.d.ts +133 -0
- package/dist/src/matchmaking/multi-cohort-seeker.d.ts.map +1 -0
- package/dist/src/matchmaking/multi-cohort-seeker.js +142 -0
- package/dist/src/matchmaking/multi-cohort-seeker.js.map +1 -0
- package/dist/src/matchmaking/provider.d.ts +70 -0
- package/dist/src/matchmaking/provider.d.ts.map +1 -0
- package/dist/src/matchmaking/provider.js +93 -0
- package/dist/src/matchmaking/provider.js.map +1 -0
- package/dist/src/matchmaking/query-eval.d.ts +53 -0
- package/dist/src/matchmaking/query-eval.d.ts.map +1 -0
- package/dist/src/matchmaking/query-eval.js +69 -0
- package/dist/src/matchmaking/query-eval.js.map +1 -0
- package/dist/src/matchmaking/seeker-walk.d.ts +95 -0
- package/dist/src/matchmaking/seeker-walk.d.ts.map +1 -0
- package/dist/src/matchmaking/seeker-walk.js +75 -0
- package/dist/src/matchmaking/seeker-walk.js.map +1 -0
- package/dist/src/matchmaking/seeker.d.ts +51 -0
- package/dist/src/matchmaking/seeker.d.ts.map +1 -0
- package/dist/src/matchmaking/seeker.js +62 -0
- package/dist/src/matchmaking/seeker.js.map +1 -0
- package/dist/src/matchmaking/topic-anchor.d.ts +54 -0
- package/dist/src/matchmaking/topic-anchor.d.ts.map +1 -0
- package/dist/src/matchmaking/topic-anchor.js +67 -0
- package/dist/src/matchmaking/topic-anchor.js.map +1 -0
- package/dist/src/matchmaking/voting-quorum.d.ts +233 -0
- package/dist/src/matchmaking/voting-quorum.d.ts.map +1 -0
- package/dist/src/matchmaking/voting-quorum.js +238 -0
- package/dist/src/matchmaking/voting-quorum.js.map +1 -0
- package/dist/src/matchmaking/wire.d.ts +259 -0
- package/dist/src/matchmaking/wire.d.ts.map +1 -0
- package/dist/src/matchmaking/wire.js +484 -0
- package/dist/src/matchmaking/wire.js.map +1 -0
- package/dist/src/network/i-repo.d.ts +9 -0
- package/dist/src/network/i-repo.d.ts.map +1 -1
- package/dist/src/network/repo-protocol.d.ts +3 -1
- package/dist/src/network/repo-protocol.d.ts.map +1 -1
- package/dist/src/network/struct.d.ts +23 -1
- package/dist/src/network/struct.d.ts.map +1 -1
- package/dist/src/reactivity/backfill.d.ts +118 -0
- package/dist/src/reactivity/backfill.d.ts.map +1 -0
- package/dist/src/reactivity/backfill.js +137 -0
- package/dist/src/reactivity/backfill.js.map +1 -0
- package/dist/src/reactivity/backpressure.d.ts +99 -0
- package/dist/src/reactivity/backpressure.d.ts.map +1 -0
- package/dist/src/reactivity/backpressure.js +153 -0
- package/dist/src/reactivity/backpressure.js.map +1 -0
- package/dist/src/reactivity/checkpoint.d.ts +165 -0
- package/dist/src/reactivity/checkpoint.d.ts.map +1 -0
- package/dist/src/reactivity/checkpoint.js +232 -0
- package/dist/src/reactivity/checkpoint.js.map +1 -0
- package/dist/src/reactivity/config.d.ts +131 -0
- package/dist/src/reactivity/config.d.ts.map +1 -0
- package/dist/src/reactivity/config.js +135 -0
- package/dist/src/reactivity/config.js.map +1 -0
- package/dist/src/reactivity/dedupe.d.ts +51 -0
- package/dist/src/reactivity/dedupe.d.ts.map +1 -0
- package/dist/src/reactivity/dedupe.js +90 -0
- package/dist/src/reactivity/dedupe.js.map +1 -0
- package/dist/src/reactivity/forwarder.d.ts +50 -0
- package/dist/src/reactivity/forwarder.d.ts.map +1 -0
- package/dist/src/reactivity/forwarder.js +52 -0
- package/dist/src/reactivity/forwarder.js.map +1 -0
- package/dist/src/reactivity/index.d.ts +34 -0
- package/dist/src/reactivity/index.d.ts.map +1 -0
- package/dist/src/reactivity/index.js +34 -0
- package/dist/src/reactivity/index.js.map +1 -0
- package/dist/src/reactivity/notification.d.ts +72 -0
- package/dist/src/reactivity/notification.d.ts.map +1 -0
- package/dist/src/reactivity/notification.js +92 -0
- package/dist/src/reactivity/notification.js.map +1 -0
- package/dist/src/reactivity/policy.d.ts +59 -0
- package/dist/src/reactivity/policy.d.ts.map +1 -0
- package/dist/src/reactivity/policy.js +64 -0
- package/dist/src/reactivity/policy.js.map +1 -0
- package/dist/src/reactivity/push-state.d.ts +140 -0
- package/dist/src/reactivity/push-state.d.ts.map +1 -0
- package/dist/src/reactivity/push-state.js +270 -0
- package/dist/src/reactivity/push-state.js.map +1 -0
- package/dist/src/reactivity/recover.d.ts +75 -0
- package/dist/src/reactivity/recover.d.ts.map +1 -0
- package/dist/src/reactivity/recover.js +105 -0
- package/dist/src/reactivity/recover.js.map +1 -0
- package/dist/src/reactivity/replay-buffer.d.ts +57 -0
- package/dist/src/reactivity/replay-buffer.d.ts.map +1 -0
- package/dist/src/reactivity/replay-buffer.js +88 -0
- package/dist/src/reactivity/replay-buffer.js.map +1 -0
- package/dist/src/reactivity/resume.d.ts +214 -0
- package/dist/src/reactivity/resume.d.ts.map +1 -0
- package/dist/src/reactivity/resume.js +358 -0
- package/dist/src/reactivity/resume.js.map +1 -0
- package/dist/src/reactivity/rotation.d.ts +283 -0
- package/dist/src/reactivity/rotation.d.ts.map +1 -0
- package/dist/src/reactivity/rotation.js +265 -0
- package/dist/src/reactivity/rotation.js.map +1 -0
- package/dist/src/reactivity/subscriber.d.ts +66 -0
- package/dist/src/reactivity/subscriber.d.ts.map +1 -0
- package/dist/src/reactivity/subscriber.js +75 -0
- package/dist/src/reactivity/subscriber.js.map +1 -0
- package/dist/src/reactivity/subscription.d.ts +52 -0
- package/dist/src/reactivity/subscription.d.ts.map +1 -0
- package/dist/src/reactivity/subscription.js +28 -0
- package/dist/src/reactivity/subscription.js.map +1 -0
- package/dist/src/reactivity/topic-anchor.d.ts +46 -0
- package/dist/src/reactivity/topic-anchor.d.ts.map +1 -0
- package/dist/src/reactivity/topic-anchor.js +61 -0
- package/dist/src/reactivity/topic-anchor.js.map +1 -0
- package/dist/src/reactivity/verify.d.ts +41 -0
- package/dist/src/reactivity/verify.d.ts.map +1 -0
- package/dist/src/reactivity/verify.js +48 -0
- package/dist/src/reactivity/verify.js.map +1 -0
- package/dist/src/reactivity/wire-validate.d.ts +28 -0
- package/dist/src/reactivity/wire-validate.d.ts.map +1 -0
- package/dist/src/reactivity/wire-validate.js +79 -0
- package/dist/src/reactivity/wire-validate.js.map +1 -0
- package/dist/src/reactivity/wire.d.ts +102 -0
- package/dist/src/reactivity/wire.d.ts.map +1 -0
- package/dist/src/reactivity/wire.js +129 -0
- package/dist/src/reactivity/wire.js.map +1 -0
- package/dist/src/transaction/coordinator.d.ts +9 -5
- package/dist/src/transaction/coordinator.d.ts.map +1 -1
- package/dist/src/transaction/coordinator.js +48 -25
- package/dist/src/transaction/coordinator.js.map +1 -1
- package/dist/src/transactor/change-notifier.d.ts +74 -0
- package/dist/src/transactor/change-notifier.d.ts.map +1 -0
- package/dist/src/transactor/change-notifier.js +4 -0
- package/dist/src/transactor/change-notifier.js.map +1 -0
- package/dist/src/transactor/index.d.ts +1 -0
- package/dist/src/transactor/index.d.ts.map +1 -1
- package/dist/src/transactor/index.js +1 -0
- package/dist/src/transactor/index.js.map +1 -1
- package/dist/src/transactor/network-transactor.d.ts +34 -2
- package/dist/src/transactor/network-transactor.d.ts.map +1 -1
- package/dist/src/transactor/network-transactor.js +113 -13
- package/dist/src/transactor/network-transactor.js.map +1 -1
- package/package.json +2 -2
- package/src/cluster/structs.ts +13 -0
- package/src/cohort-topic/addressing.ts +112 -0
- package/src/cohort-topic/antidos/bootstrap-evidence-envelope.ts +253 -0
- package/src/cohort-topic/antidos/bootstrap-evidence.ts +94 -0
- package/src/cohort-topic/antidos/index.ts +5 -0
- package/src/cohort-topic/antidos/rate-limiter.ts +210 -0
- package/src/cohort-topic/antidos/replay-guard.ts +109 -0
- package/src/cohort-topic/antidos/topic-budget.ts +145 -0
- package/src/cohort-topic/antiflood/index.ts +2 -0
- package/src/cohort-topic/antiflood/invariants.ts +108 -0
- package/src/cohort-topic/antiflood/jitter.ts +117 -0
- package/src/cohort-topic/coldstart.ts +204 -0
- package/src/cohort-topic/dmax.ts +88 -0
- package/src/cohort-topic/gossip/bus.ts +217 -0
- package/src/cohort-topic/gossip/index.ts +3 -0
- package/src/cohort-topic/gossip/records.ts +45 -0
- package/src/cohort-topic/gossip/view.ts +66 -0
- package/src/cohort-topic/index.ts +20 -0
- package/src/cohort-topic/load/barometer.ts +134 -0
- package/src/cohort-topic/load/index.ts +1 -0
- package/src/cohort-topic/member-engine.ts +409 -0
- package/src/cohort-topic/membership/index.ts +3 -0
- package/src/cohort-topic/membership/publisher.ts +171 -0
- package/src/cohort-topic/membership/source.ts +41 -0
- package/src/cohort-topic/membership/verifier.ts +345 -0
- package/src/cohort-topic/ports.ts +157 -0
- package/src/cohort-topic/promotion.ts +384 -0
- package/src/cohort-topic/registration/bytes.ts +37 -0
- package/src/cohort-topic/registration/handoff.ts +154 -0
- package/src/cohort-topic/registration/index.ts +6 -0
- package/src/cohort-topic/registration/renewal.ts +423 -0
- package/src/cohort-topic/registration/sharding.ts +61 -0
- package/src/cohort-topic/registration/store.ts +81 -0
- package/src/cohort-topic/registration/types.ts +76 -0
- package/src/cohort-topic/ring-hash.ts +50 -0
- package/src/cohort-topic/service.ts +390 -0
- package/src/cohort-topic/sig/index.ts +2 -0
- package/src/cohort-topic/sig/payloads.ts +39 -0
- package/src/cohort-topic/sig/threshold.ts +64 -0
- package/src/cohort-topic/tiers.ts +74 -0
- package/src/cohort-topic/traffic.ts +211 -0
- package/src/cohort-topic/walk.ts +255 -0
- package/src/cohort-topic/willingness.ts +237 -0
- package/src/cohort-topic/wire/codec.ts +204 -0
- package/src/cohort-topic/wire/index.ts +16 -0
- package/src/cohort-topic/wire/payloads.ts +117 -0
- package/src/cohort-topic/wire/types.ts +343 -0
- package/src/cohort-topic/wire/validate.ts +478 -0
- package/src/collection/collection.ts +93 -1
- package/src/collections/tree/tree.ts +84 -3
- package/src/index.ts +3 -0
- package/src/log/log.ts +86 -7
- package/src/log/struct.ts +126 -2
- package/src/matchmaking/capability-filter.ts +45 -0
- package/src/matchmaking/config.ts +98 -0
- package/src/matchmaking/index.ts +21 -0
- package/src/matchmaking/multi-cohort-seeker.ts +234 -0
- package/src/matchmaking/provider.ts +123 -0
- package/src/matchmaking/query-eval.ts +105 -0
- package/src/matchmaking/seeker-walk.ts +127 -0
- package/src/matchmaking/seeker.ts +86 -0
- package/src/matchmaking/topic-anchor.ts +90 -0
- package/src/matchmaking/voting-quorum.ts +394 -0
- package/src/matchmaking/wire.ts +680 -0
- package/src/network/i-repo.ts +9 -0
- package/src/network/repo-protocol.ts +3 -2
- package/src/network/struct.ts +24 -1
- package/src/reactivity/backfill.ts +220 -0
- package/src/reactivity/backpressure.ts +191 -0
- package/src/reactivity/checkpoint.ts +308 -0
- package/src/reactivity/config.ts +172 -0
- package/src/reactivity/dedupe.ts +132 -0
- package/src/reactivity/forwarder.ts +87 -0
- package/src/reactivity/index.ts +34 -0
- package/src/reactivity/notification.ts +123 -0
- package/src/reactivity/policy.ts +79 -0
- package/src/reactivity/push-state.ts +343 -0
- package/src/reactivity/recover.ts +153 -0
- package/src/reactivity/replay-buffer.ts +141 -0
- package/src/reactivity/resume.ts +549 -0
- package/src/reactivity/rotation.ts +415 -0
- package/src/reactivity/subscriber.ts +132 -0
- package/src/reactivity/subscription.ts +66 -0
- package/src/reactivity/topic-anchor.ts +71 -0
- package/src/reactivity/verify.ts +73 -0
- package/src/reactivity/wire-validate.ts +87 -0
- package/src/reactivity/wire.ts +224 -0
- package/src/transaction/coordinator.ts +53 -27
- package/src/transactor/change-notifier.ts +80 -0
- package/src/transactor/index.ts +1 -0
- package/src/transactor/network-transactor.ts +133 -15
|
@@ -0,0 +1,427 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cohort-topic substrate — per-message structural validation.
|
|
3
|
+
*
|
|
4
|
+
* Each validator narrows an already-parsed `unknown` (the output of `JSON.parse` on a decoded
|
|
5
|
+
* frame) to a concrete V1 interface, throwing {@link CohortWireError} on any structural defect:
|
|
6
|
+
* missing required field, wrong `v`, out-of-enum discriminant, a byte field that does not decode
|
|
7
|
+
* as base64url, or an out-of-range numeric. Validators never return partial data — they either
|
|
8
|
+
* narrow cleanly or throw.
|
|
9
|
+
*/
|
|
10
|
+
import { b64urlToBytes } from "./codec.js";
|
|
11
|
+
/** Thrown for any malformed, oversized, or structurally invalid cohort-topic frame. */
|
|
12
|
+
export class CohortWireError extends Error {
|
|
13
|
+
constructor(message) {
|
|
14
|
+
super(message);
|
|
15
|
+
this.name = "CohortWireError";
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
function fail(message) {
|
|
19
|
+
throw new CohortWireError(message);
|
|
20
|
+
}
|
|
21
|
+
/** Set `obj[key]` only when `value` is defined — keeps absent optionals off the decoded object. */
|
|
22
|
+
function assignDefined(obj, key, value) {
|
|
23
|
+
if (value !== undefined) {
|
|
24
|
+
obj[key] = value;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
function asObject(value, what) {
|
|
28
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
29
|
+
fail(`${what}: expected an object`);
|
|
30
|
+
}
|
|
31
|
+
return value;
|
|
32
|
+
}
|
|
33
|
+
function requireV1(obj, what) {
|
|
34
|
+
if (obj["v"] !== 1) {
|
|
35
|
+
fail(`${what}: expected v === 1, got ${JSON.stringify(obj["v"])}`);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
function reqString(obj, key, what) {
|
|
39
|
+
const value = obj[key];
|
|
40
|
+
if (typeof value !== "string") {
|
|
41
|
+
fail(`${what}: field "${key}" must be a string`);
|
|
42
|
+
}
|
|
43
|
+
return value;
|
|
44
|
+
}
|
|
45
|
+
function optString(obj, key, what) {
|
|
46
|
+
const value = obj[key];
|
|
47
|
+
if (value === undefined) {
|
|
48
|
+
return undefined;
|
|
49
|
+
}
|
|
50
|
+
if (typeof value !== "string") {
|
|
51
|
+
fail(`${what}: field "${key}" must be a string when present`);
|
|
52
|
+
}
|
|
53
|
+
return value;
|
|
54
|
+
}
|
|
55
|
+
function reqFiniteNumber(obj, key, what) {
|
|
56
|
+
const value = obj[key];
|
|
57
|
+
if (typeof value !== "number" || !Number.isFinite(value)) {
|
|
58
|
+
fail(`${what}: field "${key}" must be a finite number`);
|
|
59
|
+
}
|
|
60
|
+
return value;
|
|
61
|
+
}
|
|
62
|
+
function optFiniteNumber(obj, key, what) {
|
|
63
|
+
const value = obj[key];
|
|
64
|
+
if (value === undefined) {
|
|
65
|
+
return undefined;
|
|
66
|
+
}
|
|
67
|
+
if (typeof value !== "number" || !Number.isFinite(value)) {
|
|
68
|
+
fail(`${what}: field "${key}" must be a finite number when present`);
|
|
69
|
+
}
|
|
70
|
+
return value;
|
|
71
|
+
}
|
|
72
|
+
function reqBool(obj, key, what) {
|
|
73
|
+
const value = obj[key];
|
|
74
|
+
if (typeof value !== "boolean") {
|
|
75
|
+
fail(`${what}: field "${key}" must be a boolean`);
|
|
76
|
+
}
|
|
77
|
+
return value;
|
|
78
|
+
}
|
|
79
|
+
function optBool(obj, key, what) {
|
|
80
|
+
const value = obj[key];
|
|
81
|
+
if (value === undefined) {
|
|
82
|
+
return undefined;
|
|
83
|
+
}
|
|
84
|
+
if (typeof value !== "boolean") {
|
|
85
|
+
fail(`${what}: field "${key}" must be a boolean when present`);
|
|
86
|
+
}
|
|
87
|
+
return value;
|
|
88
|
+
}
|
|
89
|
+
function reqStringArray(obj, key, what) {
|
|
90
|
+
const value = obj[key];
|
|
91
|
+
if (!Array.isArray(value) || value.some((entry) => typeof entry !== "string")) {
|
|
92
|
+
fail(`${what}: field "${key}" must be an array of strings`);
|
|
93
|
+
}
|
|
94
|
+
return value;
|
|
95
|
+
}
|
|
96
|
+
function optStringArray(obj, key, what) {
|
|
97
|
+
if (obj[key] === undefined) {
|
|
98
|
+
return undefined;
|
|
99
|
+
}
|
|
100
|
+
return reqStringArray(obj, key, what);
|
|
101
|
+
}
|
|
102
|
+
function tier(value, what) {
|
|
103
|
+
if (!Number.isInteger(value) || value < 0 || value > 3) {
|
|
104
|
+
fail(`${what}: tier must be an integer in 0..3, got ${value}`);
|
|
105
|
+
}
|
|
106
|
+
return value;
|
|
107
|
+
}
|
|
108
|
+
/** Assert a base64url string decodes cleanly; returns it unchanged. */
|
|
109
|
+
function b64urlField(value, key, what) {
|
|
110
|
+
try {
|
|
111
|
+
b64urlToBytes(value);
|
|
112
|
+
}
|
|
113
|
+
catch {
|
|
114
|
+
fail(`${what}: field "${key}" is not valid base64url`);
|
|
115
|
+
}
|
|
116
|
+
return value;
|
|
117
|
+
}
|
|
118
|
+
function reqEnum(obj, key, allowed, what) {
|
|
119
|
+
const value = obj[key];
|
|
120
|
+
if (typeof value !== "string" || !allowed.includes(value)) {
|
|
121
|
+
fail(`${what}: field "${key}" must be one of ${allowed.join(" | ")}`);
|
|
122
|
+
}
|
|
123
|
+
return value;
|
|
124
|
+
}
|
|
125
|
+
const REGISTER_RESULTS = [
|
|
126
|
+
"accepted",
|
|
127
|
+
"no_state",
|
|
128
|
+
"promoted",
|
|
129
|
+
"unwilling_member",
|
|
130
|
+
"unwilling_cohort",
|
|
131
|
+
];
|
|
132
|
+
export function validateRegisterV1(value) {
|
|
133
|
+
const what = "RegisterV1";
|
|
134
|
+
const obj = asObject(value, what);
|
|
135
|
+
requireV1(obj, what);
|
|
136
|
+
const out = {
|
|
137
|
+
v: 1,
|
|
138
|
+
topicId: b64urlField(reqString(obj, "topicId", what), "topicId", what),
|
|
139
|
+
tier: tier(reqFiniteNumber(obj, "tier", what), what),
|
|
140
|
+
treeTier: reqFiniteNumber(obj, "treeTier", what),
|
|
141
|
+
participantCoord: b64urlField(reqString(obj, "participantCoord", what), "participantCoord", what),
|
|
142
|
+
ttl: reqFiniteNumber(obj, "ttl", what),
|
|
143
|
+
timestamp: reqFiniteNumber(obj, "timestamp", what),
|
|
144
|
+
correlationId: b64urlField(reqString(obj, "correlationId", what), "correlationId", what),
|
|
145
|
+
signature: b64urlField(reqString(obj, "signature", what), "signature", what),
|
|
146
|
+
};
|
|
147
|
+
const bootstrap = optBool(obj, "bootstrap", what);
|
|
148
|
+
if (bootstrap !== undefined) {
|
|
149
|
+
out.bootstrap = bootstrap;
|
|
150
|
+
}
|
|
151
|
+
const probe = optBool(obj, "probe", what);
|
|
152
|
+
if (probe !== undefined) {
|
|
153
|
+
out.probe = probe;
|
|
154
|
+
}
|
|
155
|
+
const appPayload = optString(obj, "appPayload", what);
|
|
156
|
+
if (appPayload !== undefined) {
|
|
157
|
+
out.appPayload = b64urlField(appPayload, "appPayload", what);
|
|
158
|
+
}
|
|
159
|
+
// Bootstrap-evidence envelope (base64url; present only on a `bootstrap: true` register). A non-string
|
|
160
|
+
// is rejected as malformed; an empty string is treated as absent so it normalizes to the same signed
|
|
161
|
+
// image placeholder as a missing field (see `registerSigningPayload`'s `normalizeEvidence`).
|
|
162
|
+
const bootstrapEvidence = optString(obj, "bootstrapEvidence", what);
|
|
163
|
+
if (bootstrapEvidence !== undefined && bootstrapEvidence !== "") {
|
|
164
|
+
out.bootstrapEvidence = b64urlField(bootstrapEvidence, "bootstrapEvidence", what);
|
|
165
|
+
}
|
|
166
|
+
return out;
|
|
167
|
+
}
|
|
168
|
+
function validateTopicTrafficV1(value) {
|
|
169
|
+
const what = "TopicTrafficV1";
|
|
170
|
+
const obj = asObject(value, what);
|
|
171
|
+
return {
|
|
172
|
+
windowSeconds: reqFiniteNumber(obj, "windowSeconds", what),
|
|
173
|
+
arrivalsPerMin: reqFiniteNumber(obj, "arrivalsPerMin", what),
|
|
174
|
+
queriesPerMin: reqFiniteNumber(obj, "queriesPerMin", what),
|
|
175
|
+
directParticipants: reqFiniteNumber(obj, "directParticipants", what),
|
|
176
|
+
childCohortCount: reqFiniteNumber(obj, "childCohortCount", what),
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
export function validateRegisterReplyV1(value) {
|
|
180
|
+
const what = "RegisterReplyV1";
|
|
181
|
+
const obj = asObject(value, what);
|
|
182
|
+
requireV1(obj, what);
|
|
183
|
+
const out = {
|
|
184
|
+
v: 1,
|
|
185
|
+
result: reqEnum(obj, "result", REGISTER_RESULTS, what),
|
|
186
|
+
};
|
|
187
|
+
assignDefined(out, "primary", optString(obj, "primary", what));
|
|
188
|
+
assignDefined(out, "backups", optStringArray(obj, "backups", what));
|
|
189
|
+
const cohortEpoch = optString(obj, "cohortEpoch", what);
|
|
190
|
+
if (cohortEpoch !== undefined) {
|
|
191
|
+
out.cohortEpoch = b64urlField(cohortEpoch, "cohortEpoch", what);
|
|
192
|
+
}
|
|
193
|
+
assignDefined(out, "cohortMembers", optStringArray(obj, "cohortMembers", what));
|
|
194
|
+
if (obj["topicTraffic"] !== undefined) {
|
|
195
|
+
out.topicTraffic = validateTopicTrafficV1(obj["topicTraffic"]);
|
|
196
|
+
}
|
|
197
|
+
assignDefined(out, "targetTier", optFiniteNumber(obj, "targetTier", what));
|
|
198
|
+
assignDefined(out, "candidateMembers", optStringArray(obj, "candidateMembers", what));
|
|
199
|
+
assignDefined(out, "retryAfterMs", optFiniteNumber(obj, "retryAfterMs", what));
|
|
200
|
+
assignDefined(out, "reason", optString(obj, "reason", what));
|
|
201
|
+
return out;
|
|
202
|
+
}
|
|
203
|
+
export function validateRenewV1(value) {
|
|
204
|
+
const what = "RenewV1";
|
|
205
|
+
const obj = asObject(value, what);
|
|
206
|
+
requireV1(obj, what);
|
|
207
|
+
const out = {
|
|
208
|
+
v: 1,
|
|
209
|
+
topicId: b64urlField(reqString(obj, "topicId", what), "topicId", what),
|
|
210
|
+
participantId: reqString(obj, "participantId", what),
|
|
211
|
+
correlationId: b64urlField(reqString(obj, "correlationId", what), "correlationId", what),
|
|
212
|
+
timestamp: reqFiniteNumber(obj, "timestamp", what),
|
|
213
|
+
signature: b64urlField(reqString(obj, "signature", what), "signature", what),
|
|
214
|
+
};
|
|
215
|
+
assignDefined(out, "reattach", optBool(obj, "reattach", what));
|
|
216
|
+
assignDefined(out, "withdraw", optBool(obj, "withdraw", what));
|
|
217
|
+
return out;
|
|
218
|
+
}
|
|
219
|
+
export function validateRenewReplyV1(value) {
|
|
220
|
+
const what = "RenewReplyV1";
|
|
221
|
+
const obj = asObject(value, what);
|
|
222
|
+
requireV1(obj, what);
|
|
223
|
+
const out = {
|
|
224
|
+
v: 1,
|
|
225
|
+
result: reqEnum(obj, "result", ["ok", "unknown_registration", "primary_moved", "withdrawn"], what),
|
|
226
|
+
};
|
|
227
|
+
assignDefined(out, "newPrimary", optString(obj, "newPrimary", what));
|
|
228
|
+
assignDefined(out, "newBackups", optStringArray(obj, "newBackups", what));
|
|
229
|
+
const cohortEpoch = optString(obj, "cohortEpoch", what);
|
|
230
|
+
if (cohortEpoch !== undefined) {
|
|
231
|
+
out.cohortEpoch = b64urlField(cohortEpoch, "cohortEpoch", what);
|
|
232
|
+
}
|
|
233
|
+
return out;
|
|
234
|
+
}
|
|
235
|
+
export function validatePromotionNoticeV1(value) {
|
|
236
|
+
const what = "PromotionNoticeV1";
|
|
237
|
+
const obj = asObject(value, what);
|
|
238
|
+
requireV1(obj, what);
|
|
239
|
+
return {
|
|
240
|
+
v: 1,
|
|
241
|
+
topicId: b64urlField(reqString(obj, "topicId", what), "topicId", what),
|
|
242
|
+
fromTier: tier(reqFiniteNumber(obj, "fromTier", what), what),
|
|
243
|
+
toTier: tier(reqFiniteNumber(obj, "toTier", what), what),
|
|
244
|
+
effectiveAt: reqFiniteNumber(obj, "effectiveAt", what),
|
|
245
|
+
thresholdSig: b64urlField(reqString(obj, "thresholdSig", what), "thresholdSig", what),
|
|
246
|
+
signers: reqStringArray(obj, "signers", what),
|
|
247
|
+
cohortEpoch: b64urlField(reqString(obj, "cohortEpoch", what), "cohortEpoch", what),
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
export function validateDemotionNoticeV1(value) {
|
|
251
|
+
const what = "DemotionNoticeV1";
|
|
252
|
+
const obj = asObject(value, what);
|
|
253
|
+
requireV1(obj, what);
|
|
254
|
+
return {
|
|
255
|
+
v: 1,
|
|
256
|
+
topicId: b64urlField(reqString(obj, "topicId", what), "topicId", what),
|
|
257
|
+
tier: tier(reqFiniteNumber(obj, "tier", what), what),
|
|
258
|
+
parentCohortCoord: b64urlField(reqString(obj, "parentCohortCoord", what), "parentCohortCoord", what),
|
|
259
|
+
effectiveAt: reqFiniteNumber(obj, "effectiveAt", what),
|
|
260
|
+
thresholdSig: b64urlField(reqString(obj, "thresholdSig", what), "thresholdSig", what),
|
|
261
|
+
signers: reqStringArray(obj, "signers", what),
|
|
262
|
+
cohortEpoch: b64urlField(reqString(obj, "cohortEpoch", what), "cohortEpoch", what),
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
function validateCohortTopicSummary(value) {
|
|
266
|
+
const what = "CohortTopicSummary";
|
|
267
|
+
const obj = asObject(value, what);
|
|
268
|
+
return {
|
|
269
|
+
topicId: b64urlField(reqString(obj, "topicId", what), "topicId", what),
|
|
270
|
+
tier: tier(reqFiniteNumber(obj, "tier", what), what),
|
|
271
|
+
directParticipants: reqFiniteNumber(obj, "directParticipants", what),
|
|
272
|
+
arrivalsPerMin: reqFiniteNumber(obj, "arrivalsPerMin", what),
|
|
273
|
+
queriesPerMin: reqFiniteNumber(obj, "queriesPerMin", what),
|
|
274
|
+
promoted: reqBool(obj, "promoted", what),
|
|
275
|
+
childCohortCount: reqFiniteNumber(obj, "childCohortCount", what),
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
function validateGossipRecordV1(value) {
|
|
279
|
+
const what = "GossipRecordV1";
|
|
280
|
+
const obj = asObject(value, what);
|
|
281
|
+
const out = {
|
|
282
|
+
topicId: b64urlField(reqString(obj, "topicId", what), "topicId", what),
|
|
283
|
+
participantId: b64urlField(reqString(obj, "participantId", what), "participantId", what),
|
|
284
|
+
tier: tier(reqFiniteNumber(obj, "tier", what), what),
|
|
285
|
+
primary: b64urlField(reqString(obj, "primary", what), "primary", what),
|
|
286
|
+
backups: reqStringArray(obj, "backups", what).map((b) => b64urlField(b, "backups", what)),
|
|
287
|
+
attachedAt: reqFiniteNumber(obj, "attachedAt", what),
|
|
288
|
+
lastPing: reqFiniteNumber(obj, "lastPing", what),
|
|
289
|
+
ttl: reqFiniteNumber(obj, "ttl", what),
|
|
290
|
+
};
|
|
291
|
+
const appState = optString(obj, "appState", what);
|
|
292
|
+
if (appState !== undefined) {
|
|
293
|
+
out.appState = b64urlField(appState, "appState", what);
|
|
294
|
+
}
|
|
295
|
+
return out;
|
|
296
|
+
}
|
|
297
|
+
function validateGossipRecordRefV1(value) {
|
|
298
|
+
const what = "GossipRecordRefV1";
|
|
299
|
+
const obj = asObject(value, what);
|
|
300
|
+
return {
|
|
301
|
+
topicId: b64urlField(reqString(obj, "topicId", what), "topicId", what),
|
|
302
|
+
participantId: b64urlField(reqString(obj, "participantId", what), "participantId", what),
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
/** `willingnessBits` carries exactly 4 bits (T0..T3) as a single hex nibble. */
|
|
306
|
+
const WILLINGNESS_RE = /^[0-9a-fA-F]$/;
|
|
307
|
+
export function validateCohortGossipV1(value) {
|
|
308
|
+
const what = "CohortGossipV1";
|
|
309
|
+
const obj = asObject(value, what);
|
|
310
|
+
requireV1(obj, what);
|
|
311
|
+
const willingnessBits = reqString(obj, "willingnessBits", what);
|
|
312
|
+
if (!WILLINGNESS_RE.test(willingnessBits)) {
|
|
313
|
+
fail(`${what}: field "willingnessBits" must be a single hex nibble (4 bits)`);
|
|
314
|
+
}
|
|
315
|
+
const loadBuckets = obj["loadBuckets"];
|
|
316
|
+
if (!Array.isArray(loadBuckets) || loadBuckets.length !== 4) {
|
|
317
|
+
fail(`${what}: field "loadBuckets" must be an array of length 4`);
|
|
318
|
+
}
|
|
319
|
+
for (const bucket of loadBuckets) {
|
|
320
|
+
if (typeof bucket !== "number" || !Number.isInteger(bucket) || bucket < 0 || bucket > 7) {
|
|
321
|
+
fail(`${what}: each loadBuckets entry must be an integer in 0..7`);
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
const summaries = obj["topicSummaries"];
|
|
325
|
+
if (!Array.isArray(summaries)) {
|
|
326
|
+
fail(`${what}: field "topicSummaries" must be an array`);
|
|
327
|
+
}
|
|
328
|
+
const out = {
|
|
329
|
+
v: 1,
|
|
330
|
+
fromMember: reqString(obj, "fromMember", what),
|
|
331
|
+
coord: b64urlField(reqString(obj, "coord", what), "coord", what),
|
|
332
|
+
cohortEpoch: b64urlField(reqString(obj, "cohortEpoch", what), "cohortEpoch", what),
|
|
333
|
+
willingnessBits,
|
|
334
|
+
loadBuckets: loadBuckets,
|
|
335
|
+
windowSeconds: reqFiniteNumber(obj, "windowSeconds", what),
|
|
336
|
+
topicSummaries: summaries.map(validateCohortTopicSummary),
|
|
337
|
+
timestamp: reqFiniteNumber(obj, "timestamp", what),
|
|
338
|
+
signature: b64urlField(reqString(obj, "signature", what), "signature", what),
|
|
339
|
+
};
|
|
340
|
+
const records = obj["records"];
|
|
341
|
+
if (records !== undefined) {
|
|
342
|
+
if (!Array.isArray(records)) {
|
|
343
|
+
fail(`${what}: field "records" must be an array when present`);
|
|
344
|
+
}
|
|
345
|
+
out.records = records.map(validateGossipRecordV1);
|
|
346
|
+
}
|
|
347
|
+
const evicted = obj["evicted"];
|
|
348
|
+
if (evicted !== undefined) {
|
|
349
|
+
if (!Array.isArray(evicted)) {
|
|
350
|
+
fail(`${what}: field "evicted" must be an array when present`);
|
|
351
|
+
}
|
|
352
|
+
out.evicted = evicted.map(validateGossipRecordRefV1);
|
|
353
|
+
}
|
|
354
|
+
return out;
|
|
355
|
+
}
|
|
356
|
+
const SIGN_KINDS = ["membership", "promotion", "demotion", "rotation"];
|
|
357
|
+
export function validateSignRequestV1(value) {
|
|
358
|
+
const what = "SignRequestV1";
|
|
359
|
+
const obj = asObject(value, what);
|
|
360
|
+
requireV1(obj, what);
|
|
361
|
+
return {
|
|
362
|
+
v: 1,
|
|
363
|
+
kind: reqEnum(obj, "kind", SIGN_KINDS, what),
|
|
364
|
+
coord: b64urlField(reqString(obj, "coord", what), "coord", what),
|
|
365
|
+
cohortEpoch: b64urlField(reqString(obj, "cohortEpoch", what), "cohortEpoch", what),
|
|
366
|
+
payload: b64urlField(reqString(obj, "payload", what), "payload", what),
|
|
367
|
+
};
|
|
368
|
+
}
|
|
369
|
+
export function validateSignReplyV1(value) {
|
|
370
|
+
const what = "SignReplyV1";
|
|
371
|
+
const obj = asObject(value, what);
|
|
372
|
+
requireV1(obj, what);
|
|
373
|
+
// Discriminated by `refused`: a refusal carries a reason; an endorsement carries signer + signature.
|
|
374
|
+
if (obj["refused"] !== undefined) {
|
|
375
|
+
if (obj["refused"] !== true) {
|
|
376
|
+
fail(`${what}: field "refused" must be true when present`);
|
|
377
|
+
}
|
|
378
|
+
return { v: 1, refused: true, reason: reqString(obj, "reason", what) };
|
|
379
|
+
}
|
|
380
|
+
return {
|
|
381
|
+
v: 1,
|
|
382
|
+
signer: b64urlField(reqString(obj, "signer", what), "signer", what),
|
|
383
|
+
signature: b64urlField(reqString(obj, "signature", what), "signature", what),
|
|
384
|
+
};
|
|
385
|
+
}
|
|
386
|
+
export function validateMembershipCertV1(value) {
|
|
387
|
+
const what = "MembershipCertV1";
|
|
388
|
+
const obj = asObject(value, what);
|
|
389
|
+
requireV1(obj, what);
|
|
390
|
+
const out = {
|
|
391
|
+
v: 1,
|
|
392
|
+
cohortCoord: b64urlField(reqString(obj, "cohortCoord", what), "cohortCoord", what),
|
|
393
|
+
cohortEpoch: b64urlField(reqString(obj, "cohortEpoch", what), "cohortEpoch", what),
|
|
394
|
+
members: reqStringArray(obj, "members", what),
|
|
395
|
+
stabilizedAt: reqFiniteNumber(obj, "stabilizedAt", what),
|
|
396
|
+
thresholdSig: b64urlField(reqString(obj, "thresholdSig", what), "thresholdSig", what),
|
|
397
|
+
signers: reqStringArray(obj, "signers", what),
|
|
398
|
+
};
|
|
399
|
+
const attestation = optString(obj, "fretAttestation", what);
|
|
400
|
+
if (attestation !== undefined) {
|
|
401
|
+
out.fretAttestation = b64urlField(attestation, "fretAttestation", what);
|
|
402
|
+
}
|
|
403
|
+
validateRotationAttestation(obj, out, what);
|
|
404
|
+
return out;
|
|
405
|
+
}
|
|
406
|
+
/**
|
|
407
|
+
* Validate the optional rotation attestation as an all-or-nothing group: either all three of
|
|
408
|
+
* `prevEpoch`/`rotationSig`/`rotationSigners` are present (and well-formed) or all are absent. A
|
|
409
|
+
* partial set is a {@link CohortWireError}. `rotationSigners` is validated only as a string array (its
|
|
410
|
+
* elements are decoded per-element later, mirroring `signers`).
|
|
411
|
+
*/
|
|
412
|
+
function validateRotationAttestation(obj, out, what) {
|
|
413
|
+
const prevEpoch = optString(obj, "prevEpoch", what);
|
|
414
|
+
const rotationSig = optString(obj, "rotationSig", what);
|
|
415
|
+
const rotationSigners = optStringArray(obj, "rotationSigners", what);
|
|
416
|
+
const presentCount = [prevEpoch, rotationSig, rotationSigners].filter((v) => v !== undefined).length;
|
|
417
|
+
if (presentCount === 0) {
|
|
418
|
+
return;
|
|
419
|
+
}
|
|
420
|
+
if (presentCount !== 3) {
|
|
421
|
+
fail(`${what}: rotation attestation requires all of prevEpoch, rotationSig, rotationSigners — or none`);
|
|
422
|
+
}
|
|
423
|
+
out.prevEpoch = b64urlField(prevEpoch, "prevEpoch", what);
|
|
424
|
+
out.rotationSig = b64urlField(rotationSig, "rotationSig", what);
|
|
425
|
+
out.rotationSigners = rotationSigners;
|
|
426
|
+
}
|
|
427
|
+
//# sourceMappingURL=validate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate.js","sourceRoot":"","sources":["../../../../src/cohort-topic/wire/validate.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAoB3C,uFAAuF;AACvF,MAAM,OAAO,eAAgB,SAAQ,KAAK;IACzC,YAAY,OAAe;QAC1B,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;IAC/B,CAAC;CACD;AAED,SAAS,IAAI,CAAC,OAAe;IAC5B,MAAM,IAAI,eAAe,CAAC,OAAO,CAAC,CAAC;AACpC,CAAC;AAED,mGAAmG;AACnG,SAAS,aAAa,CAAsC,GAAM,EAAE,GAAM,EAAE,KAAuB;IAClG,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACzB,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IAClB,CAAC;AACF,CAAC;AAED,SAAS,QAAQ,CAAC,KAAc,EAAE,IAAY;IAC7C,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACzE,IAAI,CAAC,GAAG,IAAI,sBAAsB,CAAC,CAAC;IACrC,CAAC;IACD,OAAO,KAAgC,CAAC;AACzC,CAAC;AAED,SAAS,SAAS,CAAC,GAA4B,EAAE,IAAY;IAC5D,IAAI,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;QACpB,IAAI,CAAC,GAAG,IAAI,2BAA2B,IA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C;IACD,2BAA2B,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;IAC5C,OAAO,GAAG,CAAC;AACZ,CAAC;AAED;;;;;GAKG;AACH,SAAS,2BAA2B,CAAC,GAA4B,EAAE,GAAqB,EAAE,IAAY;IACrG,MAAM,SAAS,GAAG,SAAS,CAAC,GAAG,EAAE,WAAW,EAAE,IAAI,CAAC,CAAC;IACpD,MAAM,WAAW,GAAG,SAAS,CAAC,GAAG,EAAE,aAAa,EAAE,IAAI,CAAC,CAAC;IACxD,MAAM,eAAe,GAAG,cAAc,CAAC,GAAG,EAAE,iBAAiB,EAAE,IAAI,CAAC,CAAC;IACrE,MAAM,YAAY,GAAG,CAAC,SAAS,EAAE,WAAW,EAAE,eAAe,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,SAAS,CAAC,CAAC,MAAM,CAAC;IACrG,IAAI,YAAY,KAAK,CAAC,EAAE,CAAC;QACxB,OAAO;IACR,CAAC;IACD,IAAI,YAAY,KAAK,CAAC,EAAE,CAAC;QACxB,IAAI,CAAC,GAAG,IAAI,0FAA0F,CAAC,CAAC;IACzG,CAAC;IACD,GAAG,CAAC,SAAS,GAAG,WAAW,CAAC,SAAU,EAAE,WAAW,EAAE,IAAI,CAAC,CAAC;IAC3D,GAAG,CAAC,WAAW,GAAG,WAAW,CAAC,WAAY,EAAE,aAAa,EAAE,IAAI,CAAC,CAAC;IACjE,GAAG,CAAC,eAAe,GAAG,eAAgB,CAAC;AACxC,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { IBlock, Action, ActionType, ActionHandler, BlockId, ITransactor, BlockStore } from "../index.js";
|
|
1
|
+
import type { IBlock, Action, ActionType, ActionHandler, BlockId, ITransactor, BlockStore, Transforms } from "../index.js";
|
|
2
2
|
import { Tracker, CacheSource, TransactorSource } from "../index.js";
|
|
3
3
|
import type { CollectionId, ICollection } from "./index.js";
|
|
4
4
|
import type { ReadDependency } from "../transaction/transaction.js";
|
|
@@ -13,6 +13,14 @@ export type CollectionInitOptions<TAction> = {
|
|
|
13
13
|
*/
|
|
14
14
|
filterConflict?: (action: Action<TAction>, potential: Action<TAction>[]) => Action<TAction> | undefined;
|
|
15
15
|
};
|
|
16
|
+
/** A point-in-time copy of a collection's staged (un-synced) state, produced by
|
|
17
|
+
* {@link Collection.snapshotPending} and consumed by {@link Collection.restorePending}. */
|
|
18
|
+
export interface CollectionSnapshot<TAction> {
|
|
19
|
+
/** Deep-cloned tracker transforms at snapshot time. */
|
|
20
|
+
transforms: Transforms;
|
|
21
|
+
/** Pending actions queued at snapshot time. */
|
|
22
|
+
pending: Action<TAction>[];
|
|
23
|
+
}
|
|
16
24
|
export declare class Collection<TAction> implements ICollection<TAction> {
|
|
17
25
|
readonly id: CollectionId;
|
|
18
26
|
readonly transactor: ITransactor;
|
|
@@ -37,6 +45,55 @@ export declare class Collection<TAction> implements ICollection<TAction> {
|
|
|
37
45
|
/** Load external changes and update our context to the latest log revision - resolve any conflicts with our pending actions. */
|
|
38
46
|
update(): Promise<void>;
|
|
39
47
|
private updateInternal;
|
|
48
|
+
/** Capture the current staged state — tracker transforms plus the pending
|
|
49
|
+
* action queue — so it can be restored later via {@link restorePending}.
|
|
50
|
+
*
|
|
51
|
+
* Use to bracket a unit of staged DML that may need to be rolled back. Unlike
|
|
52
|
+
* a blanket "reset to empty", restoring this snapshot preserves any structural
|
|
53
|
+
* baseline that predates the staged DML — most importantly a brand-new
|
|
54
|
+
* collection's header/root blocks, which live in the tracker (uncommitted)
|
|
55
|
+
* until the first sync. Resetting such a collection to empty would leave it
|
|
56
|
+
* unreadable; restoring the snapshot returns it to its prior (readable) state.
|
|
57
|
+
*
|
|
58
|
+
* The returned snapshot is deep-cloned and independent of subsequent mutations.
|
|
59
|
+
* Synchronous and latch-free: intended to bracket transaction-scoped staging,
|
|
60
|
+
* when no concurrent act/sync is in flight. */
|
|
61
|
+
snapshotPending(): CollectionSnapshot<TAction>;
|
|
62
|
+
/** Restore the staged state captured by {@link snapshotPending}, discarding any
|
|
63
|
+
* mutations staged since. Reads through the collection then observe exactly the
|
|
64
|
+
* snapshot state again; storage is untouched because nothing was ever synced. */
|
|
65
|
+
restorePending(snapshot: CollectionSnapshot<TAction>): void;
|
|
66
|
+
/** A read-only {@link Tracker} over this collection's committed source cache,
|
|
67
|
+
* seeded with a (deep-copied) set of pre-transaction transforms. Reads through it
|
|
68
|
+
* observe committed state plus exactly those transforms — and crucially NOT the
|
|
69
|
+
* mutations staged into this collection's live tracker afterward. Used to build a
|
|
70
|
+
* committed read view (see {@link Tree.readView}) that excludes a transaction's
|
|
71
|
+
* own in-flight rows. The returned tracker shares the source cache (committed
|
|
72
|
+
* blocks) but has its own independent transform set; it is never sync()'d. */
|
|
73
|
+
createReadTracker(transforms: Transforms): Tracker<IBlock>;
|
|
74
|
+
/** The staged (not-yet-synced) actions queued by {@link act}.
|
|
75
|
+
*
|
|
76
|
+
* Exposed so a {@link TransactionCoordinator} can append them to the log at
|
|
77
|
+
* commit time — mirroring what {@link sync} does internally — when the actions
|
|
78
|
+
* were staged directly into this collection (e.g. through a Tree's stage())
|
|
79
|
+
* rather than applied via the coordinator's own action path. */
|
|
80
|
+
getPendingActions(): Action<TAction>[];
|
|
81
|
+
/** Drop the staged actions after they have been committed through a
|
|
82
|
+
* coordinator. Counterpart to {@link getPendingActions}; {@link sync} clears
|
|
83
|
+
* its own pending inline, so this is only needed when commit was orchestrated
|
|
84
|
+
* externally. */
|
|
85
|
+
clearPendingActions(): void;
|
|
86
|
+
/** Fold a just-committed set of transforms into this collection's read cache
|
|
87
|
+
* so subsequent reads (and stages) through THIS instance observe the committed
|
|
88
|
+
* state, mirroring what {@link sync} does inline after a successful transact.
|
|
89
|
+
*
|
|
90
|
+
* Needed when commit was orchestrated externally (a coordinator): the tracker
|
|
91
|
+
* is reset to empty, but the cache still holds the pre-commit blocks. Without
|
|
92
|
+
* this, a collection that already had committed state (e.g. a pre-synced index
|
|
93
|
+
* tree, or any collection on its second commit) keeps serving the stale prior
|
|
94
|
+
* revision because {@link update} sees its rev is already current and refetches
|
|
95
|
+
* nothing. Call BEFORE resetting the tracker (the transforms are read live). */
|
|
96
|
+
applyCommittedToCache(transforms: Transforms): void;
|
|
40
97
|
/** Push our pending actions to the transactor */
|
|
41
98
|
sync(): Promise<void>;
|
|
42
99
|
private syncInternal;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collection.d.ts","sourceRoot":"","sources":["../../../src/collection/collection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,aAAa,EAAE,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"collection.d.ts","sourceRoot":"","sources":["../../../src/collection/collection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,aAAa,EAAE,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC3H,OAAO,EAAe,OAAO,EAAkB,WAAW,EAAqB,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACrH,OAAO,KAAK,EAAyB,YAAY,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACnF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAOpE,MAAM,MAAM,qBAAqB,CAAC,OAAO,IAAI;IAC5C,OAAO,EAAE,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC;IACpD,iBAAiB,EAAE,CAAC,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,UAAU,CAAC,MAAM,CAAC,KAAK,MAAM,CAAC;IACtE;;;;;OAKG;IACH,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,EAAE,SAAS,EAA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qBAAqB,CAAC,OAAO,CAAC;IAwB5G,GAAG,CAAC,GAAG,OAAO,EAAE,MAAM,CAAC,OAAO,CAAC,EAAE;YASzB,WAAW;YAKX,gBAAgB;IAc9B,gIAAgI;IAC1H,MAAM;YASE,cAAc;IAmD5B;;;;;;;;;;;;mDAY+C;IAC/C,eAAe,IAAI,kBAAkB,CAAC,OAAO,CAAC;IAI9C;;qFAEiF;IACjF,cAAc,CAAC,QAAQ,EAAE,kBAAkB,CAAC,OAAO,CAAC,GAAG,IAAI;IAK3D;;;;;;kFAM8E;IAC9E,iBAAiB,CAAC,UAAU,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC;IAI1D;;;;;oEAKgE;IAChE,iBAAiB,IAAI,MAAM,CAAC,OAAO,CAAC,EAAE;IAItC;;;qBAGiB;IACjB,mBAAmB,IAAI,IAAI;IAI3B;;;;;;;;;oFASgF;IAChF,qBAAqB,CAAC,UAAU,EAAE,UAAU,GAAG,IAAI;IAInD,iDAAiD;IAC3C,IAAI;YASI,YAAY;IA2CpB,aAAa;IAUZ,SAAS,CAAC,OAAO,UAAO,GAAG,qBAAqB,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;YAY1D,aAAa;IAQ3B,mBAAmB,IAAI,cAAc,EAAE;IAIvC,qBAAqB,IAAI,IAAI;IAI7B;;;;OAIG;IACH,SAAS,CAAC,gBAAgB,CAAC,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,EAAE,SAAS,EAAE,MAAM,CAAC,OAAO,CAAC,EAAE;IAahF;;;;;OAKG;mBACkB,gBAAgB;CAiBrC"}
|
|
@@ -105,6 +105,20 @@ export class Collection {
|
|
|
105
105
|
this.sourceCache.clear(entry.blockIds);
|
|
106
106
|
anyConflicts = anyConflicts || this.tracker.conflicts(new Set(entry.blockIds)).length > 0;
|
|
107
107
|
}
|
|
108
|
+
// React to durable invalidations that landed since we last synced. getFrom intentionally skips
|
|
109
|
+
// invalidation entries (they are not pending/committed actions), so surface them separately: an
|
|
110
|
+
// invalidation reverted committed content this client may have read, so treat it like a stale
|
|
111
|
+
// read — drop the reverted blocks from the read cache and replay pending work against the reverted
|
|
112
|
+
// base (docs/right-is-right.md §Client notification). De-duped across cascade children by reverted
|
|
113
|
+
// block; over-inclusive by design (over-invalidation just resubmits — it never wrongly retains).
|
|
114
|
+
const invalidations = log ? await log.getInvalidationsFrom(actionContext?.rev ?? 0) : [];
|
|
115
|
+
if (invalidations.length > 0) {
|
|
116
|
+
const revertedBlockIds = [...new Set(invalidations.flatMap(inv => inv.reverted.map(r => r.blockId)))];
|
|
117
|
+
this.sourceCache.clear(revertedBlockIds);
|
|
118
|
+
if (this.pending.length > 0) {
|
|
119
|
+
anyConflicts = true;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
108
122
|
// On conflicts, clear related caching and block-tracking and replay logical operations
|
|
109
123
|
if (anyConflicts) {
|
|
110
124
|
await this.replayActions();
|
|
@@ -112,6 +126,68 @@ export class Collection {
|
|
|
112
126
|
// Update our context to the latest
|
|
113
127
|
this.source.actionContext = latest?.context;
|
|
114
128
|
}
|
|
129
|
+
/** Capture the current staged state — tracker transforms plus the pending
|
|
130
|
+
* action queue — so it can be restored later via {@link restorePending}.
|
|
131
|
+
*
|
|
132
|
+
* Use to bracket a unit of staged DML that may need to be rolled back. Unlike
|
|
133
|
+
* a blanket "reset to empty", restoring this snapshot preserves any structural
|
|
134
|
+
* baseline that predates the staged DML — most importantly a brand-new
|
|
135
|
+
* collection's header/root blocks, which live in the tracker (uncommitted)
|
|
136
|
+
* until the first sync. Resetting such a collection to empty would leave it
|
|
137
|
+
* unreadable; restoring the snapshot returns it to its prior (readable) state.
|
|
138
|
+
*
|
|
139
|
+
* The returned snapshot is deep-cloned and independent of subsequent mutations.
|
|
140
|
+
* Synchronous and latch-free: intended to bracket transaction-scoped staging,
|
|
141
|
+
* when no concurrent act/sync is in flight. */
|
|
142
|
+
snapshotPending() {
|
|
143
|
+
return { transforms: copyTransforms(this.tracker.transforms), pending: [...this.pending] };
|
|
144
|
+
}
|
|
145
|
+
/** Restore the staged state captured by {@link snapshotPending}, discarding any
|
|
146
|
+
* mutations staged since. Reads through the collection then observe exactly the
|
|
147
|
+
* snapshot state again; storage is untouched because nothing was ever synced. */
|
|
148
|
+
restorePending(snapshot) {
|
|
149
|
+
this.tracker.reset(copyTransforms(snapshot.transforms));
|
|
150
|
+
this.pending = [...snapshot.pending];
|
|
151
|
+
}
|
|
152
|
+
/** A read-only {@link Tracker} over this collection's committed source cache,
|
|
153
|
+
* seeded with a (deep-copied) set of pre-transaction transforms. Reads through it
|
|
154
|
+
* observe committed state plus exactly those transforms — and crucially NOT the
|
|
155
|
+
* mutations staged into this collection's live tracker afterward. Used to build a
|
|
156
|
+
* committed read view (see {@link Tree.readView}) that excludes a transaction's
|
|
157
|
+
* own in-flight rows. The returned tracker shares the source cache (committed
|
|
158
|
+
* blocks) but has its own independent transform set; it is never sync()'d. */
|
|
159
|
+
createReadTracker(transforms) {
|
|
160
|
+
return new Tracker(this.sourceCache, copyTransforms(transforms));
|
|
161
|
+
}
|
|
162
|
+
/** The staged (not-yet-synced) actions queued by {@link act}.
|
|
163
|
+
*
|
|
164
|
+
* Exposed so a {@link TransactionCoordinator} can append them to the log at
|
|
165
|
+
* commit time — mirroring what {@link sync} does internally — when the actions
|
|
166
|
+
* were staged directly into this collection (e.g. through a Tree's stage())
|
|
167
|
+
* rather than applied via the coordinator's own action path. */
|
|
168
|
+
getPendingActions() {
|
|
169
|
+
return this.pending;
|
|
170
|
+
}
|
|
171
|
+
/** Drop the staged actions after they have been committed through a
|
|
172
|
+
* coordinator. Counterpart to {@link getPendingActions}; {@link sync} clears
|
|
173
|
+
* its own pending inline, so this is only needed when commit was orchestrated
|
|
174
|
+
* externally. */
|
|
175
|
+
clearPendingActions() {
|
|
176
|
+
this.pending = [];
|
|
177
|
+
}
|
|
178
|
+
/** Fold a just-committed set of transforms into this collection's read cache
|
|
179
|
+
* so subsequent reads (and stages) through THIS instance observe the committed
|
|
180
|
+
* state, mirroring what {@link sync} does inline after a successful transact.
|
|
181
|
+
*
|
|
182
|
+
* Needed when commit was orchestrated externally (a coordinator): the tracker
|
|
183
|
+
* is reset to empty, but the cache still holds the pre-commit blocks. Without
|
|
184
|
+
* this, a collection that already had committed state (e.g. a pre-synced index
|
|
185
|
+
* tree, or any collection on its second commit) keeps serving the stale prior
|
|
186
|
+
* revision because {@link update} sees its rev is already current and refetches
|
|
187
|
+
* nothing. Call BEFORE resetting the tracker (the transforms are read live). */
|
|
188
|
+
applyCommittedToCache(transforms) {
|
|
189
|
+
this.sourceCache.transformCache(transforms);
|
|
190
|
+
}
|
|
115
191
|
/** Push our pending actions to the transactor */
|
|
116
192
|
async sync() {
|
|
117
193
|
const release = await Latches.acquire(this.latchId);
|