@optimystic/db-core 0.13.5 → 0.14.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.
- 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,238 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Matchmaking — voting-quorum assembler (db-core, discovery-only composition).
|
|
3
|
+
*
|
|
4
|
+
* The voting subsystem's **discovery** flow, built as a thin composition over the matchmaking module
|
|
5
|
+
* (`docs/matchmaking.md` §Voting-quorum assembly). Matchmaking already provides "find the peers": the
|
|
6
|
+
* stable {@link import("./topic-anchor.js").MatchTopicAnchor}, the signed provider registration
|
|
7
|
+
* ({@link MatchmakingProvider}), the single-cohort hang-out walk and the hot-topic multi-cohort sweep,
|
|
8
|
+
* and the reply-side per-entry `registrationSig` re-validation ({@link verifyProviderEntry}). This
|
|
9
|
+
* module adds the small amount of glue that turns that surface into "assemble a quorum of eligible
|
|
10
|
+
* voters for proposal `P`".
|
|
11
|
+
*
|
|
12
|
+
* **No matchmaking wire-protocol change is introduced.** The genuinely voting-layer pieces are injected
|
|
13
|
+
* or left out of scope entirely:
|
|
14
|
+
*
|
|
15
|
+
* - **Eligibility proof minting** — the caller mints an opaque proof (a signature over the proposal from
|
|
16
|
+
* a stake-bearing key, etc.) and supplies the {@link VotingQuorumRequest.verifyEligibility} predicate
|
|
17
|
+
* over it. Matchmaking treats the proof as opaque bytes carried in the provider's `capabilities`.
|
|
18
|
+
* - **The quorum selection rule** (random sample, stake-weighted, geographic) — injected via
|
|
19
|
+
* {@link VotingQuorumRequest.select}; the default is first-`targetSize`.
|
|
20
|
+
* - **Ballots, tally, dispute, ballot privacy** — out of scope; a separate forthcoming voting doc.
|
|
21
|
+
*
|
|
22
|
+
* ## Resolved design decisions (`docs/matchmaking.md` §Voting-quorum assembly)
|
|
23
|
+
*
|
|
24
|
+
* 1. **Reply-side per-entry verification is the default and required path; a client-side reputation
|
|
25
|
+
* pre-filter is optional and additive.** Quorum-assembly *liveness* must never depend on
|
|
26
|
+
* reputation-subsystem *availability*, so reputation is an optimization, never a dependency.
|
|
27
|
+
* Matchmaking forwards each entry's `registrationSig` plus the eligibility proof in `capabilities`,
|
|
28
|
+
* so reply-side verification is effectively free; the cohort returns ineligible entries the
|
|
29
|
+
* coordinator discards (bandwidth bounded by `query_limit_max × swept-cohort-count`).
|
|
30
|
+
* 2. **Flash-vote fairness among competing coordinators is a voting-layer concern; no matchmaking signal
|
|
31
|
+
* is added.** Matchmaking returns an advisory *candidate set*, never an allocation — overlapping sets
|
|
32
|
+
* are expected and quorum non-collision is decided by the voting protocol.
|
|
33
|
+
* 3. **No matchmaking protocol additions are needed.** `AggregateCountV1` is threshold-signed (an
|
|
34
|
+
* attested *registered*-provider count); an attested *eligible*-voter count, if voting needs one, is a
|
|
35
|
+
* voting-layer aggregate computed after discovery+verification, not a matchmaking message.
|
|
36
|
+
* 4. **Quorum-assembler delegation.** The seeker role may be held by the coordinator itself or by a
|
|
37
|
+
* delegated assembler peer; whoever holds it owns `patienceMs` and the reply-side re-validation duty.
|
|
38
|
+
* A delegated assembler returns an already-validated {@link ProviderEntryV1}`[]`; because every entry
|
|
39
|
+
* carries `registrationSig` + the proof in `capabilities`, the set is independently checkable, so the
|
|
40
|
+
* coordinator MAY re-validate (trust-but-verify) on receipt by re-running the verify→select pipeline.
|
|
41
|
+
*
|
|
42
|
+
* ## Architecture seam
|
|
43
|
+
*
|
|
44
|
+
* db-core is transport-free, so the actual discovery I/O (the register/query/renew walk, the root
|
|
45
|
+
* `AggregateCountV1` sweep) is **injected** as a {@link QuorumDiscovery} port — exactly as the seeker
|
|
46
|
+
* walk client and entry verifier are injected elsewhere in this module. db-p2p binds the port to
|
|
47
|
+
* `MatchmakingSeeker.walk` (single-cohort) and `multi-cohort-seeker` (sweep). The assembler itself never
|
|
48
|
+
* dials voters, never collects ballots, never tallies.
|
|
49
|
+
*/
|
|
50
|
+
import { createMatchTopicAnchor } from "./topic-anchor.js";
|
|
51
|
+
import { MatchmakingProvider } from "./provider.js";
|
|
52
|
+
import { verifyProviderEntry } from "./wire.js";
|
|
53
|
+
/** Default concurrent-vote-collection budget for a registered voter — accepts one vote-collection RPC. */
|
|
54
|
+
export const DEFAULT_VOTER_CAPACITY_BUDGET = 1;
|
|
55
|
+
/**
|
|
56
|
+
* Indicative `patienceMs` range for voting-quorum assembly (`docs/matchmaking.md` §Patience budgeting).
|
|
57
|
+
* Advisory only — the layer does not dictate; {@link VotingQuorumAssembler.assembleQuorum} requires a
|
|
58
|
+
* positive budget but does not clamp to this window.
|
|
59
|
+
*/
|
|
60
|
+
export const VOTING_PATIENCE_MIN_MS = 30_000;
|
|
61
|
+
export const VOTING_PATIENCE_MAX_MS = 300_000;
|
|
62
|
+
/**
|
|
63
|
+
* Reserved capability-tag prefix carrying a voter's opaque eligibility proof. The proof is bound into the
|
|
64
|
+
* provider `capabilities`, which {@link import("./wire.js").providerSigningPayload} covers, so the
|
|
65
|
+
* provider's `registrationSig` attests the proof verbatim. The caller's `verifyEligibility` predicate
|
|
66
|
+
* reads it back from the forwarded entry via {@link eligibilityProofOf}.
|
|
67
|
+
*/
|
|
68
|
+
export const ELIGIBILITY_TAG_PREFIX = "voter-eligibility:";
|
|
69
|
+
/** Encode an opaque eligibility proof as the reserved capability tag. */
|
|
70
|
+
export function eligibilityTag(proof) {
|
|
71
|
+
return ELIGIBILITY_TAG_PREFIX + proof;
|
|
72
|
+
}
|
|
73
|
+
/** Extract the eligibility proof from a capability set, or `undefined` if no eligibility tag is present. */
|
|
74
|
+
export function eligibilityProofFromCapabilities(capabilities) {
|
|
75
|
+
const tag = capabilities.find((c) => c.startsWith(ELIGIBILITY_TAG_PREFIX));
|
|
76
|
+
return tag === undefined ? undefined : tag.slice(ELIGIBILITY_TAG_PREFIX.length);
|
|
77
|
+
}
|
|
78
|
+
/** Extract the eligibility proof carried by a forwarded {@link ProviderEntryV1} (`undefined` if absent). */
|
|
79
|
+
export function eligibilityProofOf(entry) {
|
|
80
|
+
return eligibilityProofFromCapabilities(entry.capabilities);
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Discovery-only voting-quorum assembler over the matchmaking module. One instance can act in either
|
|
84
|
+
* role: a voter calls {@link registerEligibleVoter}; a coordinator (or delegated assembler) calls
|
|
85
|
+
* {@link assembleQuorum}. Deps are role-specific and asserted per method, so a coordinator need not
|
|
86
|
+
* supply `sign`/`registerProvider` and a voter need not supply `discovery`/`verifyEntrySig`.
|
|
87
|
+
*/
|
|
88
|
+
export class VotingQuorumAssembler {
|
|
89
|
+
anchor;
|
|
90
|
+
deps;
|
|
91
|
+
clock;
|
|
92
|
+
constructor(deps = {}) {
|
|
93
|
+
this.deps = deps;
|
|
94
|
+
this.anchor = deps.anchor ?? createMatchTopicAnchor();
|
|
95
|
+
this.clock = deps.clock ?? (() => Date.now());
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* The quorum topic anchor for a proposal: `kind = "quorum"`, `label = proposalHash`, yielding
|
|
99
|
+
* `topicId = H("quorum" ‖ proposalHash ‖ "match")` via the matchmaking topic anchor.
|
|
100
|
+
*/
|
|
101
|
+
static quorumTopic(proposalHash) {
|
|
102
|
+
return { kind: "quorum", label: proposalHash };
|
|
103
|
+
}
|
|
104
|
+
/** Resolve the cohort-topic `topicId` for a proposal's quorum topic. */
|
|
105
|
+
topicIdFor(proposalHash) {
|
|
106
|
+
const { kind, label } = VotingQuorumAssembler.quorumTopic(proposalHash);
|
|
107
|
+
return this.anchor.topicId(kind, label);
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Voter side: bind the caller-minted eligibility proof into `capabilities`, build the signed provider
|
|
111
|
+
* registration, and register it at the quorum topic (cohort-topic T2). The proof is opaque to
|
|
112
|
+
* matchmaking; the provider `signature` covers `(topicId, capabilities, capacityBudget)`, so it binds
|
|
113
|
+
* the proof to the registration.
|
|
114
|
+
*/
|
|
115
|
+
async registerEligibleVoter(req) {
|
|
116
|
+
const sign = this.requireSign();
|
|
117
|
+
const registerProvider = this.requireRegisterProvider();
|
|
118
|
+
const topicId = this.topicIdFor(req.proposalHash);
|
|
119
|
+
const capacityBudget = req.capacityBudget ?? DEFAULT_VOTER_CAPACITY_BUDGET;
|
|
120
|
+
const capabilities = mergeEligibilityCapabilities(req.capabilityTags ?? [], req.eligibilityProof);
|
|
121
|
+
const provider = new MatchmakingProvider({
|
|
122
|
+
topicId,
|
|
123
|
+
capabilities,
|
|
124
|
+
capacityBudget,
|
|
125
|
+
contactHint: req.contactHint,
|
|
126
|
+
sign,
|
|
127
|
+
...(req.serviceUntil !== undefined ? { serviceUntil: req.serviceUntil } : {}),
|
|
128
|
+
...(this.deps.randomBytes !== undefined ? { randomBytes: this.deps.randomBytes } : {}),
|
|
129
|
+
});
|
|
130
|
+
await registerProvider({ topicId, appPayloadBytes: await provider.appPayloadBytes() });
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Coordinator / delegated-assembler side: discover → verify → select. Drives the single-cohort walk,
|
|
134
|
+
* escalates to the multi-cohort sweep on a hot topic (`childCohortCount > 0`) or when `preferSweep`,
|
|
135
|
+
* dedups by `participantId`, applies the optional reputation pre-filter, re-validates each entry's
|
|
136
|
+
* `registrationSig` **and** `verifyEligibility`, then applies the selection rule. Passes the *draining*
|
|
137
|
+
* patience budget to each discovery hop (walk, then sweep) — the deadline is fixed at entry and each
|
|
138
|
+
* hop receives the remaining slice — and on exhaustion returns whatever matched with `metTarget = false`.
|
|
139
|
+
* (Both legs honour `patienceMs`: the walk enforces a wall-clock deadline across hops and hang-out; the
|
|
140
|
+
* sweep stops starting new shard queries once the budget drains. The residual is at most one in-flight
|
|
141
|
+
* shard RPC — assembly never blocks materially past `patienceMs`.)
|
|
142
|
+
*/
|
|
143
|
+
async assembleQuorum(req) {
|
|
144
|
+
const discovery = this.requireDiscovery();
|
|
145
|
+
const verifyEntrySig = this.requireVerifyEntrySig();
|
|
146
|
+
const targetSize = requireTargetSize(req.targetSize);
|
|
147
|
+
requirePositivePatience(req.patienceMs);
|
|
148
|
+
const topicId = this.topicIdFor(req.proposalHash);
|
|
149
|
+
const deadline = this.clock() + req.patienceMs;
|
|
150
|
+
const remaining = () => Math.max(0, deadline - this.clock());
|
|
151
|
+
// Step 2: single-cohort walk, then the single-vs-sweep decision.
|
|
152
|
+
const walkSlice = await discovery.walk({ topicId, wantCount: targetSize, patienceMs: remaining() });
|
|
153
|
+
const swept = req.preferSweep === true || walkSlice.childCohortCount > 0;
|
|
154
|
+
const slices = [walkSlice];
|
|
155
|
+
if (swept) {
|
|
156
|
+
slices.push(await discovery.sweep({ topicId, wantCount: targetSize, patienceMs: remaining() }));
|
|
157
|
+
}
|
|
158
|
+
// Step 3: dedup the unioned candidate set by participantId (defensive — promotion/redirect overlap).
|
|
159
|
+
const candidates = dedupByParticipant(slices.flatMap((s) => [...s.entries]));
|
|
160
|
+
// Step 4: optional, additive reputation pre-filter (bandwidth/quality trim; never a dependency).
|
|
161
|
+
const prefiltered = req.reputationPrefilter ? req.reputationPrefilter([...candidates]) : candidates;
|
|
162
|
+
// Step 5: reply-side default — both registrationSig re-validation AND verifyEligibility must pass.
|
|
163
|
+
const eligible = prefiltered.filter((entry) => verifyProviderEntry(topicId, entry, verifyEntrySig) && req.verifyEligibility(entry));
|
|
164
|
+
// Step 6: selection rule (default first targetSize), deduped defensively.
|
|
165
|
+
const select = req.select ?? defaultSelect;
|
|
166
|
+
const quorum = dedupByParticipant(select([...eligible], targetSize));
|
|
167
|
+
return {
|
|
168
|
+
quorum,
|
|
169
|
+
candidates: candidates.length,
|
|
170
|
+
eligible: eligible.length,
|
|
171
|
+
metTarget: quorum.length >= targetSize,
|
|
172
|
+
swept,
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
requireDiscovery() {
|
|
176
|
+
if (this.deps.discovery === undefined) {
|
|
177
|
+
throw new Error("VotingQuorumAssembler.assembleQuorum requires a `discovery` dependency");
|
|
178
|
+
}
|
|
179
|
+
return this.deps.discovery;
|
|
180
|
+
}
|
|
181
|
+
requireVerifyEntrySig() {
|
|
182
|
+
if (this.deps.verifyEntrySig === undefined) {
|
|
183
|
+
throw new Error("VotingQuorumAssembler.assembleQuorum requires a `verifyEntrySig` dependency");
|
|
184
|
+
}
|
|
185
|
+
return this.deps.verifyEntrySig;
|
|
186
|
+
}
|
|
187
|
+
requireSign() {
|
|
188
|
+
if (this.deps.sign === undefined) {
|
|
189
|
+
throw new Error("VotingQuorumAssembler.registerEligibleVoter requires a `sign` dependency");
|
|
190
|
+
}
|
|
191
|
+
return this.deps.sign;
|
|
192
|
+
}
|
|
193
|
+
requireRegisterProvider() {
|
|
194
|
+
if (this.deps.registerProvider === undefined) {
|
|
195
|
+
throw new Error("VotingQuorumAssembler.registerEligibleVoter requires a `registerProvider` dependency");
|
|
196
|
+
}
|
|
197
|
+
return this.deps.registerProvider;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
/** The default selection rule: take the first `targetSize` eligible entries (the discovery order). */
|
|
201
|
+
export function defaultSelect(eligible, targetSize) {
|
|
202
|
+
return eligible.slice(0, targetSize);
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Merge application capability tags with the eligibility proof tag: drop any caller-supplied tag that
|
|
206
|
+
* already uses the reserved prefix (the proof is authoritative), then append exactly one proof tag.
|
|
207
|
+
* Order is preserved end-to-end (the cohort forwards `capabilities` verbatim), so the provider signature
|
|
208
|
+
* reconstructs byte-for-byte on the seeker side.
|
|
209
|
+
*/
|
|
210
|
+
function mergeEligibilityCapabilities(tags, proof) {
|
|
211
|
+
const appTags = tags.filter((tag) => !tag.startsWith(ELIGIBILITY_TAG_PREFIX));
|
|
212
|
+
return [...appTags, eligibilityTag(proof)];
|
|
213
|
+
}
|
|
214
|
+
/** Dedup entries by `participantId`, keeping the first occurrence (preserves discovery/FCFS order). */
|
|
215
|
+
function dedupByParticipant(entries) {
|
|
216
|
+
const seen = new Map();
|
|
217
|
+
for (const entry of entries) {
|
|
218
|
+
if (!seen.has(entry.participantId)) {
|
|
219
|
+
seen.set(entry.participantId, entry);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
return [...seen.values()];
|
|
223
|
+
}
|
|
224
|
+
/** Validate `targetSize` is an integer `>= 1`. */
|
|
225
|
+
function requireTargetSize(targetSize) {
|
|
226
|
+
if (!Number.isInteger(targetSize) || targetSize < 1) {
|
|
227
|
+
throw new RangeError(`voting quorum: targetSize must be an integer >= 1, got ${targetSize}`);
|
|
228
|
+
}
|
|
229
|
+
return targetSize;
|
|
230
|
+
}
|
|
231
|
+
/** Validate `patienceMs` is a finite number `> 0` (the voting 30–300 s range is advisory, not enforced). */
|
|
232
|
+
function requirePositivePatience(patienceMs) {
|
|
233
|
+
if (!Number.isFinite(patienceMs) || patienceMs <= 0) {
|
|
234
|
+
throw new RangeError(`voting quorum: patienceMs must be a finite number > 0, got ${patienceMs}`);
|
|
235
|
+
}
|
|
236
|
+
return patienceMs;
|
|
237
|
+
}
|
|
238
|
+
//# sourceMappingURL=voting-quorum.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"voting-quorum.js","sourceRoot":"","sources":["../../../src/matchmaking/voting-quorum.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AAEH,OAAO,EAAE,sBAAsB,EAAyB,MAAM,mBAAmB,CAAC;AAClF,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAA+C,MAAM,WAAW,CAAC;AAE7F,0GAA0G;AAC1G,MAAM,CAAC,MAAM,6BAA6B,GAAG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UAAU,CAAC,IAAI,UAAU,GAAG,CAAC,EAAE,CAAC;QACrD,MAAM,IAAI,UAAU,CAAC,0DAA0D,UAAU,EAAE,CAAC,CAAC;IAC9F,CAAC;IACD,OAAO,UAAU,CAAC;AACnB,CAAC;AAED,4GAA4G;AAC5G,SAAS,uBAAuB,CAAC,UAAkB;IAClD,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,UAAU,IAAI,CAAC,EAAE,CAAC;QACrD,MAAM,IAAI,UAAU,CAAC,8DAA8D,UAAU,EAAE,CAAC,CAAC;IAClG,CAAC;IACD,OAAO,UAAU,CAAC;AACnB,CAAC"}
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Matchmaking — V1 wire types, codecs, and per-message validation.
|
|
3
|
+
*
|
|
4
|
+
* Transcribed from `docs/matchmaking.md` §Wire formats. Matchmaking reuses the cohort-topic
|
|
5
|
+
* `RegisterV1` / `RenewV1` envelopes **unchanged**; the matchmaking-specific shape lives in two
|
|
6
|
+
* places:
|
|
7
|
+
*
|
|
8
|
+
* 1. **App payloads** ({@link ProviderAppPayloadV1} / {@link SeekerAppPayloadV1}) carried opaquely
|
|
9
|
+
* inside `RegisterV1.appPayload`. These are serialized to UTF-8 JSON bytes and handed to the
|
|
10
|
+
* cohort-topic {@link import("../cohort-topic/service.js").RegisterRequest}`.appPayload` slot,
|
|
11
|
+
* which base64url-encodes them on the wire. They are therefore **not** length-framed here — the
|
|
12
|
+
* cohort-topic `RegisterV1` frame wraps them.
|
|
13
|
+
*
|
|
14
|
+
* 2. **Query-protocol messages** ({@link QueryV1} / {@link QueryReplyV1} / {@link AggregateCountV1})
|
|
15
|
+
* sent as standalone RPCs over the matchmaking application protocol. These ride the same
|
|
16
|
+
* length-prefixed UTF-8 JSON framing as cohort-topic messages ({@link encodeCohortMessage}).
|
|
17
|
+
*
|
|
18
|
+
* Conventions (matching the cohort-topic wire conventions): all JSON, byte fields base64url (no
|
|
19
|
+
* padding), unix-millisecond timestamps, per-message structural validation on decode. Byte fidelity
|
|
20
|
+
* round-trips (encode→decode→encode is stable). The query-protocol producers (cohort-side reply,
|
|
21
|
+
* root-cohort aggregate sweep) land in later tickets; their decoders live here so the seeker side can
|
|
22
|
+
* be unit-tested against fixtures.
|
|
23
|
+
*/
|
|
24
|
+
import type { TopicTrafficV1 } from "../cohort-topic/wire/types.js";
|
|
25
|
+
/** A provider's registration payload (`SubscribeAppPayloadV1.appPayload`, `kind == "match-provider"`). */
|
|
26
|
+
export interface ProviderAppPayloadV1 {
|
|
27
|
+
kind: "match-provider";
|
|
28
|
+
/** Application-defined attribute tags. */
|
|
29
|
+
capabilities: string[];
|
|
30
|
+
/** Concurrent tasks accepted; `0` == "listed but full". */
|
|
31
|
+
capacityBudget: number;
|
|
32
|
+
/** Unix ms, soft expiry hint to seekers. */
|
|
33
|
+
serviceUntil?: number;
|
|
34
|
+
/** Multiaddr or PeerId-based callback. */
|
|
35
|
+
contactHint: string;
|
|
36
|
+
/** base64url, over `(topicId, capabilities, capacityBudget)` — see {@link providerSigningPayload}. */
|
|
37
|
+
signature: string;
|
|
38
|
+
}
|
|
39
|
+
/** A seeker's registration payload (`SubscribeAppPayloadV1.appPayload`, `kind == "match-seeker"`). */
|
|
40
|
+
export interface SeekerAppPayloadV1 {
|
|
41
|
+
kind: "match-seeker";
|
|
42
|
+
/** Number of providers desired. */
|
|
43
|
+
wantCount: number;
|
|
44
|
+
/** Optional capability filter. */
|
|
45
|
+
filter?: CapabilityFilter;
|
|
46
|
+
/** For collective-assembly use. */
|
|
47
|
+
contactHint: string;
|
|
48
|
+
/** Opt into arrival pushes; default false (poll path). */
|
|
49
|
+
pushOnArrival?: boolean;
|
|
50
|
+
/** base64url. */
|
|
51
|
+
signature: string;
|
|
52
|
+
}
|
|
53
|
+
/** A capability filter, evaluated locally at the cohort (advisory — the seeker re-validates). */
|
|
54
|
+
export interface CapabilityFilter {
|
|
55
|
+
/** Tags that must all be present. */
|
|
56
|
+
must: string[];
|
|
57
|
+
/** Tags that must not be present. */
|
|
58
|
+
mustNot: string[];
|
|
59
|
+
/** Skip providers whose `capacityBudget` is below this. */
|
|
60
|
+
minBudget?: number;
|
|
61
|
+
}
|
|
62
|
+
/** A seeker's query against a cohort for the providers/seekers it holds. */
|
|
63
|
+
export interface QueryV1 {
|
|
64
|
+
v: 1;
|
|
65
|
+
/** Topic id, base64url. */
|
|
66
|
+
topicId: string;
|
|
67
|
+
includeProviders: boolean;
|
|
68
|
+
includeSeekers: boolean;
|
|
69
|
+
filter?: CapabilityFilter;
|
|
70
|
+
/** `<= query_limit_max` (256). */
|
|
71
|
+
limit: number;
|
|
72
|
+
/** Requesting PeerId. */
|
|
73
|
+
requesterId: string;
|
|
74
|
+
/** Unix ms. */
|
|
75
|
+
timestamp: number;
|
|
76
|
+
/** base64url. */
|
|
77
|
+
signature: string;
|
|
78
|
+
}
|
|
79
|
+
/** A cohort's advisory reply to a {@link QueryV1} (signed by the cohort primary, not threshold). */
|
|
80
|
+
export interface QueryReplyV1 {
|
|
81
|
+
v: 1;
|
|
82
|
+
providers?: ProviderEntryV1[];
|
|
83
|
+
seekers?: SeekerEntryV1[];
|
|
84
|
+
truncated: boolean;
|
|
85
|
+
/** base64url. */
|
|
86
|
+
cohortEpoch: string;
|
|
87
|
+
/** From cohort-topic; consumed by the hang-out engine (next ticket). */
|
|
88
|
+
topicTraffic: TopicTrafficV1;
|
|
89
|
+
/** Cohort PRIMARY single-member signature (NOT threshold), base64url. */
|
|
90
|
+
signature: string;
|
|
91
|
+
}
|
|
92
|
+
/** A provider entry in a {@link QueryReplyV1}. */
|
|
93
|
+
export interface ProviderEntryV1 {
|
|
94
|
+
/** PeerId. */
|
|
95
|
+
participantId: string;
|
|
96
|
+
capabilities: string[];
|
|
97
|
+
capacityBudget: number;
|
|
98
|
+
contactHint: string;
|
|
99
|
+
/** Unix ms. */
|
|
100
|
+
attachedAt: number;
|
|
101
|
+
/** Provider's original signature, forwarded for seeker re-validation, base64url. */
|
|
102
|
+
registrationSig: string;
|
|
103
|
+
}
|
|
104
|
+
/** A seeker entry in a {@link QueryReplyV1} (collective-assembly discovery). */
|
|
105
|
+
export interface SeekerEntryV1 {
|
|
106
|
+
/** PeerId. */
|
|
107
|
+
participantId: string;
|
|
108
|
+
wantCount: number;
|
|
109
|
+
contactHint: string;
|
|
110
|
+
/** Unix ms. */
|
|
111
|
+
attachedAt: number;
|
|
112
|
+
/** base64url. */
|
|
113
|
+
registrationSig: string;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Root-cohort multi-cohort-sweep summary (`docs/matchmaking.md` §Aggregated provider counts).
|
|
117
|
+
*
|
|
118
|
+
* Unlike {@link QueryReplyV1}, this is **threshold-signed** — it attests a cohort-agreed *registered*
|
|
119
|
+
* provider count, not one primary's advisory view — so it carries the same `(thresholdSig, signers)`
|
|
120
|
+
* envelope the cohort-topic {@link import("../cohort-topic/wire/types.js").PromotionNoticeV1} uses:
|
|
121
|
+
* `signature` is the concatenated cohort multisig blob and `signers` is the distinct `>= minSigs` member
|
|
122
|
+
* subset that produced it. A verifier splits the blob by `signers` and checks the subset against the
|
|
123
|
+
* cohort membership certificate (db-p2p binds the crypto). `signers` is required precisely because a
|
|
124
|
+
* threshold blob is unverifiable without the signer set that aligns chunk `i` ↔ `signers[i]`.
|
|
125
|
+
*/
|
|
126
|
+
export interface AggregateCountV1 {
|
|
127
|
+
v: 1;
|
|
128
|
+
/** Topic id, base64url. */
|
|
129
|
+
topicId: string;
|
|
130
|
+
/** `count` is log-bucketed (see {@link logBucketCount}). */
|
|
131
|
+
bucketCounts: AggregateBucketV1[];
|
|
132
|
+
/** Cohort threshold-signature blob over {@link aggregateCountSigningPayload}, base64url. */
|
|
133
|
+
signature: string;
|
|
134
|
+
/** PeerIds of the `>= minSigs` threshold signers, base64url (aligns the `signature` blob). */
|
|
135
|
+
signers: string[];
|
|
136
|
+
/** base64url. */
|
|
137
|
+
cohortEpoch: string;
|
|
138
|
+
}
|
|
139
|
+
/** One bucketed shard count inside an {@link AggregateCountV1}. */
|
|
140
|
+
export interface AggregateBucketV1 {
|
|
141
|
+
targetTier: number;
|
|
142
|
+
prefixSlot: number;
|
|
143
|
+
/** Log-bucketed. */
|
|
144
|
+
count: number;
|
|
145
|
+
}
|
|
146
|
+
/** Ceiling for an opaque app payload (provider/seeker), guarding decode allocation. */
|
|
147
|
+
export declare const DEFAULT_MAX_APP_PAYLOAD_BYTES: number;
|
|
148
|
+
/** Narrow an already-parsed value to {@link ProviderAppPayloadV1}, throwing on any defect. */
|
|
149
|
+
export declare function validateProviderAppPayloadV1(value: unknown): ProviderAppPayloadV1;
|
|
150
|
+
/** Narrow an already-parsed value to {@link SeekerAppPayloadV1}, throwing on any defect. */
|
|
151
|
+
export declare function validateSeekerAppPayloadV1(value: unknown): SeekerAppPayloadV1;
|
|
152
|
+
/** Serialize a {@link ProviderAppPayloadV1} to the opaque UTF-8 JSON bytes for `RegisterV1.appPayload`. */
|
|
153
|
+
export declare function encodeProviderAppPayload(payload: ProviderAppPayloadV1): Uint8Array;
|
|
154
|
+
/** Decode opaque `RegisterV1.appPayload` bytes back to a validated {@link ProviderAppPayloadV1}. */
|
|
155
|
+
export declare function decodeProviderAppPayload(bytes: Uint8Array, maxBytes?: number): ProviderAppPayloadV1;
|
|
156
|
+
/** Serialize a {@link SeekerAppPayloadV1} to the opaque UTF-8 JSON bytes for `RegisterV1.appPayload`. */
|
|
157
|
+
export declare function encodeSeekerAppPayload(payload: SeekerAppPayloadV1): Uint8Array;
|
|
158
|
+
/** Decode opaque `RegisterV1.appPayload` bytes back to a validated {@link SeekerAppPayloadV1}. */
|
|
159
|
+
export declare function decodeSeekerAppPayload(bytes: Uint8Array, maxBytes?: number): SeekerAppPayloadV1;
|
|
160
|
+
/** Either matchmaking registration payload, discriminated by `kind`. */
|
|
161
|
+
export type MatchAppPayloadV1 = ProviderAppPayloadV1 | SeekerAppPayloadV1;
|
|
162
|
+
/**
|
|
163
|
+
* Decode an opaque `RegisterV1.appPayload` to whichever matchmaking payload it carries, dispatched on
|
|
164
|
+
* `kind` (parsed once — no exception-as-control-flow). The cohort query handler uses this to classify a
|
|
165
|
+
* registration record into a provider vs. seeker entry. Throws {@link CohortWireError} on an unknown
|
|
166
|
+
* `kind` or a malformed payload.
|
|
167
|
+
*/
|
|
168
|
+
export declare function decodeMatchAppPayload(bytes: Uint8Array, maxBytes?: number): MatchAppPayloadV1;
|
|
169
|
+
/** Narrow an already-parsed value to {@link QueryV1}, throwing on any defect. */
|
|
170
|
+
export declare function validateQueryV1(value: unknown): QueryV1;
|
|
171
|
+
/** Narrow an already-parsed value to {@link QueryReplyV1}, throwing on any defect. */
|
|
172
|
+
export declare function validateQueryReplyV1(value: unknown): QueryReplyV1;
|
|
173
|
+
/** Narrow an already-parsed value to {@link AggregateCountV1}, throwing on any defect. */
|
|
174
|
+
export declare function validateAggregateCountV1(value: unknown): AggregateCountV1;
|
|
175
|
+
/** Encode a {@link QueryV1} as a length-prefixed UTF-8 JSON frame. */
|
|
176
|
+
export declare function encodeQueryV1(msg: QueryV1, maxMessageBytes?: number): Uint8Array;
|
|
177
|
+
/** Decode a length-prefixed {@link QueryV1} frame. */
|
|
178
|
+
export declare function decodeQueryV1(bytes: Uint8Array, maxMessageBytes?: number): QueryV1;
|
|
179
|
+
/** Encode a {@link QueryReplyV1} as a length-prefixed UTF-8 JSON frame. */
|
|
180
|
+
export declare function encodeQueryReplyV1(msg: QueryReplyV1, maxMessageBytes?: number): Uint8Array;
|
|
181
|
+
/** Decode a length-prefixed {@link QueryReplyV1} frame. */
|
|
182
|
+
export declare function decodeQueryReplyV1(bytes: Uint8Array, maxMessageBytes?: number): QueryReplyV1;
|
|
183
|
+
/** Encode an {@link AggregateCountV1} as a length-prefixed UTF-8 JSON frame. */
|
|
184
|
+
export declare function encodeAggregateCountV1(msg: AggregateCountV1, maxMessageBytes?: number): Uint8Array;
|
|
185
|
+
/** Decode a length-prefixed {@link AggregateCountV1} frame. */
|
|
186
|
+
export declare function decodeAggregateCountV1(bytes: Uint8Array, maxMessageBytes?: number): AggregateCountV1;
|
|
187
|
+
/**
|
|
188
|
+
* Canonical signed byte image of a provider registration — `(topicId, capabilities, capacityBudget)`
|
|
189
|
+
* per `docs/matchmaking.md` §Wire formats.
|
|
190
|
+
*
|
|
191
|
+
* **Signing scope (resolved):** the signed image deliberately excludes the matchmaking
|
|
192
|
+
* `correlationId`. The advisory trust model (matchmaking.md §Wire formats) requires a seeker to
|
|
193
|
+
* re-validate each forwarded {@link ProviderEntryV1}'s `registrationSig`, and a {@link ProviderEntryV1}
|
|
194
|
+
* carries **no** `correlationId` field — so binding the signature over `correlationId` would leave the
|
|
195
|
+
* seeker unable to reconstruct the exact signed image. Dropping it (option (b) of the implement ticket)
|
|
196
|
+
* keeps the signed image fully self-contained in the forwarded entry: `topicId` (the topic the seeker
|
|
197
|
+
* queried) + `capabilities` + `capacityBudget`. Replay-binding of the *registration* is handled
|
|
198
|
+
* independently by the cohort-topic `RegisterV1` envelope (its own `correlationId` + replay guard +
|
|
199
|
+
* peer-key signature); the matchmaking signature only attests provider authorship of the advertised
|
|
200
|
+
* capabilities, which the participant peer key (the entry's `participantId`) anchors.
|
|
201
|
+
*
|
|
202
|
+
* Determinism comes from an explicitly-ordered array (stable, unlike object key order), exactly like
|
|
203
|
+
* the cohort-topic `registerSigningPayload`. `topicId` is passed as raw bytes and emitted as base64url
|
|
204
|
+
* so signer and verifier agree byte-for-byte.
|
|
205
|
+
*/
|
|
206
|
+
export declare function providerSigningPayload(topicId: Uint8Array, capabilities: readonly string[], capacityBudget: number): Uint8Array;
|
|
207
|
+
/**
|
|
208
|
+
* Canonical signed byte image of a seeker registration — `(topicId, wantCount)`. Mirrors the provider
|
|
209
|
+
* scope (option (b), see {@link providerSigningPayload}): the image excludes `correlationId` so it is
|
|
210
|
+
* fully reconstructable from a forwarded {@link SeekerEntryV1} (`participantId` + `wantCount`) for
|
|
211
|
+
* collective-assembly re-validation.
|
|
212
|
+
*/
|
|
213
|
+
export declare function seekerSigningPayload(topicId: Uint8Array, wantCount: number): Uint8Array;
|
|
214
|
+
/**
|
|
215
|
+
* Verifies a forwarded entry's `registrationSig`. db-core is crypto-free, so the actual peer-key check
|
|
216
|
+
* is injected (db-p2p binds it to {@link import("@optimystic/db-p2p").verifyPeerSig} over the
|
|
217
|
+
* participant's Ed25519 peer key). `signerId` is the entry's `participantId` (a peer-id string); the
|
|
218
|
+
* verifier resolves the public key from it. Returns `false` (never throws) on a malformed signature.
|
|
219
|
+
*/
|
|
220
|
+
export type EntrySigVerifier = (signerId: string, payload: Uint8Array, signature: Uint8Array) => boolean;
|
|
221
|
+
/**
|
|
222
|
+
* Re-validate a forwarded {@link ProviderEntryV1} against the topic it was returned for: reconstruct the
|
|
223
|
+
* provider signing image from the entry's own fields and verify `registrationSig` against the entry's
|
|
224
|
+
* `participantId`. This is the seeker-side check the advisory trust model hinges on — the cohort vouches
|
|
225
|
+
* only for "these were the registrations I held", never for provider authenticity.
|
|
226
|
+
*/
|
|
227
|
+
export declare function verifyProviderEntry(topicId: Uint8Array, entry: ProviderEntryV1, verify: EntrySigVerifier): boolean;
|
|
228
|
+
/** Re-validate a forwarded {@link SeekerEntryV1} (collective-assembly discovery), mirroring {@link verifyProviderEntry}. */
|
|
229
|
+
export declare function verifySeekerEntry(topicId: Uint8Array, entry: SeekerEntryV1, verify: EntrySigVerifier): boolean;
|
|
230
|
+
/**
|
|
231
|
+
* Canonical signed byte image of a {@link QueryReplyV1} — the cohort **primary's** single-member
|
|
232
|
+
* signature (not threshold), per `docs/matchmaking.md` §Wire formats. The primary vouches only for the
|
|
233
|
+
* *set it held*; provider authenticity is re-validated per entry via {@link verifyProviderEntry}. The
|
|
234
|
+
* image binds the epoch, truncation flag, traffic snapshot, and the participant ids of each returned
|
|
235
|
+
* entry (order-sensitive) so a tampered reply is detectable, while staying independent of the
|
|
236
|
+
* advisory per-entry signatures.
|
|
237
|
+
*/
|
|
238
|
+
export declare function queryReplySigningPayload(reply: Omit<QueryReplyV1, "signature">): Uint8Array;
|
|
239
|
+
/**
|
|
240
|
+
* Log-bucket a raw provider count for an {@link AggregateCountV1} bucket: the largest power of two
|
|
241
|
+
* `<= n` (and `0` for `n <= 0`). The root reports bucketed, not exact, per-shard populations
|
|
242
|
+
* (`docs/matchmaking.md` §Multi-cohort sweep) — both to compress the summary and to avoid leaking exact
|
|
243
|
+
* counts.
|
|
244
|
+
*
|
|
245
|
+
* The bucketing rounds **down** and is monotonic non-decreasing, so a consumer summing bucketed counts
|
|
246
|
+
* (`multi-cohort-seeker.selectShards`) *under*-estimates the true population. That bias is the safe
|
|
247
|
+
* direction for shard selection: the real population is always `>=` the reported one, so selecting until
|
|
248
|
+
* the bucketed sum reaches `wantCount` naturally over-provisions rather than under-selecting.
|
|
249
|
+
*/
|
|
250
|
+
export declare function logBucketCount(n: number): number;
|
|
251
|
+
/**
|
|
252
|
+
* Canonical threshold-signed byte image of an {@link AggregateCountV1} — covers the semantic fields
|
|
253
|
+
* (`v`, `topicId`, `cohortEpoch`, and the bucket set) but never the `signature`/`signers` envelope,
|
|
254
|
+
* exactly as the cohort-topic `sig/payloads.ts` builders do for their threshold-signed notices. The
|
|
255
|
+
* bucket set is sorted by `(targetTier, prefixSlot)` so the image is independent of bucket emission
|
|
256
|
+
* order — signer and verifier recompute identical bytes.
|
|
257
|
+
*/
|
|
258
|
+
export declare function aggregateCountSigningPayload(unsigned: Omit<AggregateCountV1, "signature" | "signers">): Uint8Array;
|
|
259
|
+
//# sourceMappingURL=wire.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wire.d.ts","sourceRoot":"","sources":["../../../src/matchmaking/wire.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAUH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAKpE,0GAA0G;AAC1G,MAAM,WAAW,oBAAoB;I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