@optimystic/db-p2p 0.13.4 → 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/README.md +6 -6
- package/dist/src/cluster/block-transfer-service.d.ts +67 -8
- package/dist/src/cluster/block-transfer-service.d.ts.map +1 -1
- package/dist/src/cluster/block-transfer-service.js +101 -62
- package/dist/src/cluster/block-transfer-service.js.map +1 -1
- package/dist/src/cluster/client.d.ts +18 -1
- package/dist/src/cluster/client.d.ts.map +1 -1
- package/dist/src/cluster/client.js +55 -39
- package/dist/src/cluster/client.js.map +1 -1
- package/dist/src/cluster/cluster-error.d.ts +38 -0
- package/dist/src/cluster/cluster-error.d.ts.map +1 -0
- package/dist/src/cluster/cluster-error.js +51 -0
- package/dist/src/cluster/cluster-error.js.map +1 -0
- package/dist/src/cluster/cluster-repo.d.ts +135 -3
- package/dist/src/cluster/cluster-repo.d.ts.map +1 -1
- package/dist/src/cluster/cluster-repo.js +333 -58
- package/dist/src/cluster/cluster-repo.js.map +1 -1
- package/dist/src/cluster/commit-cert.d.ts +63 -0
- package/dist/src/cluster/commit-cert.d.ts.map +1 -0
- package/dist/src/cluster/commit-cert.js +108 -0
- package/dist/src/cluster/commit-cert.js.map +1 -0
- package/dist/src/cluster/service.d.ts +46 -11
- package/dist/src/cluster/service.d.ts.map +1 -1
- package/dist/src/cluster/service.js +97 -33
- package/dist/src/cluster/service.js.map +1 -1
- package/dist/src/cluster/spread-on-churn.d.ts +13 -0
- package/dist/src/cluster/spread-on-churn.d.ts.map +1 -1
- package/dist/src/cluster/spread-on-churn.js +34 -4
- package/dist/src/cluster/spread-on-churn.js.map +1 -1
- package/dist/src/cohort-topic/bootstrap-evidence-builder.d.ts +59 -0
- package/dist/src/cohort-topic/bootstrap-evidence-builder.d.ts.map +1 -0
- package/dist/src/cohort-topic/bootstrap-evidence-builder.js +79 -0
- package/dist/src/cohort-topic/bootstrap-evidence-builder.js.map +1 -0
- package/dist/src/cohort-topic/bootstrap-evidence-verifiers.d.ts +81 -0
- package/dist/src/cohort-topic/bootstrap-evidence-verifiers.d.ts.map +1 -0
- package/dist/src/cohort-topic/bootstrap-evidence-verifiers.js +93 -0
- package/dist/src/cohort-topic/bootstrap-evidence-verifiers.js.map +1 -0
- package/dist/src/cohort-topic/bootstrap-parent-reference.d.ts +108 -0
- package/dist/src/cohort-topic/bootstrap-parent-reference.d.ts.map +1 -0
- package/dist/src/cohort-topic/bootstrap-parent-reference.js +108 -0
- package/dist/src/cohort-topic/bootstrap-parent-reference.js.map +1 -0
- package/dist/src/cohort-topic/change-bridge.d.ts +65 -0
- package/dist/src/cohort-topic/change-bridge.d.ts.map +1 -0
- package/dist/src/cohort-topic/change-bridge.js +76 -0
- package/dist/src/cohort-topic/change-bridge.js.map +1 -0
- package/dist/src/cohort-topic/cohort-gossip-driver.d.ts +74 -0
- package/dist/src/cohort-topic/cohort-gossip-driver.d.ts.map +1 -0
- package/dist/src/cohort-topic/cohort-gossip-driver.js +87 -0
- package/dist/src/cohort-topic/cohort-gossip-driver.js.map +1 -0
- package/dist/src/cohort-topic/cohort-gossip-transport.d.ts +42 -0
- package/dist/src/cohort-topic/cohort-gossip-transport.d.ts.map +1 -0
- package/dist/src/cohort-topic/cohort-gossip-transport.js +57 -0
- package/dist/src/cohort-topic/cohort-gossip-transport.js.map +1 -0
- package/dist/src/cohort-topic/fret-trust-anchor.d.ts +100 -0
- package/dist/src/cohort-topic/fret-trust-anchor.d.ts.map +1 -0
- package/dist/src/cohort-topic/fret-trust-anchor.js +115 -0
- package/dist/src/cohort-topic/fret-trust-anchor.js.map +1 -0
- package/dist/src/cohort-topic/host.d.ts +573 -0
- package/dist/src/cohort-topic/host.d.ts.map +1 -0
- package/dist/src/cohort-topic/host.js +1460 -0
- package/dist/src/cohort-topic/host.js.map +1 -0
- package/dist/src/cohort-topic/index.d.ts +14 -0
- package/dist/src/cohort-topic/index.d.ts.map +1 -0
- package/dist/src/cohort-topic/index.js +14 -0
- package/dist/src/cohort-topic/index.js.map +1 -0
- package/dist/src/cohort-topic/membership-publish-sink.d.ts +14 -0
- package/dist/src/cohort-topic/membership-publish-sink.d.ts.map +1 -0
- package/dist/src/cohort-topic/membership-publish-sink.js +17 -0
- package/dist/src/cohort-topic/membership-publish-sink.js.map +1 -0
- package/dist/src/cohort-topic/membership-source.d.ts +36 -0
- package/dist/src/cohort-topic/membership-source.d.ts.map +1 -0
- package/dist/src/cohort-topic/membership-source.js +58 -0
- package/dist/src/cohort-topic/membership-source.js.map +1 -0
- package/dist/src/cohort-topic/peer-codec.d.ts +18 -0
- package/dist/src/cohort-topic/peer-codec.d.ts.map +1 -0
- package/dist/src/cohort-topic/peer-codec.js +26 -0
- package/dist/src/cohort-topic/peer-codec.js.map +1 -0
- package/dist/src/cohort-topic/peer-sig.d.ts +52 -0
- package/dist/src/cohort-topic/peer-sig.d.ts.map +1 -0
- package/dist/src/cohort-topic/peer-sig.js +83 -0
- package/dist/src/cohort-topic/peer-sig.js.map +1 -0
- package/dist/src/cohort-topic/protocols.d.ts +49 -0
- package/dist/src/cohort-topic/protocols.d.ts.map +1 -0
- package/dist/src/cohort-topic/protocols.js +58 -0
- package/dist/src/cohort-topic/protocols.js.map +1 -0
- package/dist/src/cohort-topic/reactivity-membership-gate.d.ts +49 -0
- package/dist/src/cohort-topic/reactivity-membership-gate.d.ts.map +1 -0
- package/dist/src/cohort-topic/reactivity-membership-gate.js +42 -0
- package/dist/src/cohort-topic/reactivity-membership-gate.js.map +1 -0
- package/dist/src/cohort-topic/size-estimator.d.ts +16 -0
- package/dist/src/cohort-topic/size-estimator.d.ts.map +1 -0
- package/dist/src/cohort-topic/size-estimator.js +16 -0
- package/dist/src/cohort-topic/size-estimator.js.map +1 -0
- package/dist/src/cohort-topic/stream-util.d.ts +19 -0
- package/dist/src/cohort-topic/stream-util.d.ts.map +1 -0
- package/dist/src/cohort-topic/stream-util.js +76 -0
- package/dist/src/cohort-topic/stream-util.js.map +1 -0
- package/dist/src/cohort-topic/threshold-crypto.d.ts +94 -0
- package/dist/src/cohort-topic/threshold-crypto.d.ts.map +1 -0
- package/dist/src/cohort-topic/threshold-crypto.js +178 -0
- package/dist/src/cohort-topic/threshold-crypto.js.map +1 -0
- package/dist/src/cohort-topic/topic-router.d.ts +41 -0
- package/dist/src/cohort-topic/topic-router.d.ts.map +1 -0
- package/dist/src/cohort-topic/topic-router.js +63 -0
- package/dist/src/cohort-topic/topic-router.js.map +1 -0
- package/dist/src/dispute/cascade.d.ts +179 -0
- package/dist/src/dispute/cascade.d.ts.map +1 -0
- package/dist/src/dispute/cascade.js +315 -0
- package/dist/src/dispute/cascade.js.map +1 -0
- package/dist/src/dispute/client.d.ts +2 -1
- package/dist/src/dispute/client.d.ts.map +1 -1
- package/dist/src/dispute/client.js +12 -3
- package/dist/src/dispute/client.js.map +1 -1
- package/dist/src/dispute/dispute-service.d.ts +41 -1
- package/dist/src/dispute/dispute-service.d.ts.map +1 -1
- package/dist/src/dispute/dispute-service.js +147 -21
- package/dist/src/dispute/dispute-service.js.map +1 -1
- package/dist/src/dispute/index.d.ts +2 -0
- package/dist/src/dispute/index.d.ts.map +1 -1
- package/dist/src/dispute/index.js +2 -0
- package/dist/src/dispute/index.js.map +1 -1
- package/dist/src/dispute/invalidation.d.ts +266 -0
- package/dist/src/dispute/invalidation.d.ts.map +1 -0
- package/dist/src/dispute/invalidation.js +405 -0
- package/dist/src/dispute/invalidation.js.map +1 -0
- package/dist/src/dispute/types.d.ts +14 -0
- package/dist/src/dispute/types.d.ts.map +1 -1
- package/dist/src/dispute/types.js.map +1 -1
- package/dist/src/index.d.ts +4 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +4 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/libp2p-key-network.d.ts +8 -1
- package/dist/src/libp2p-key-network.d.ts.map +1 -1
- package/dist/src/libp2p-key-network.js +67 -8
- package/dist/src/libp2p-key-network.js.map +1 -1
- package/dist/src/libp2p-node-base.d.ts +57 -3
- package/dist/src/libp2p-node-base.d.ts.map +1 -1
- package/dist/src/libp2p-node-base.js +523 -6
- package/dist/src/libp2p-node-base.js.map +1 -1
- package/dist/src/matchmaking/aggregate-counts.d.ts +67 -0
- package/dist/src/matchmaking/aggregate-counts.d.ts.map +1 -0
- package/dist/src/matchmaking/aggregate-counts.js +60 -0
- package/dist/src/matchmaking/aggregate-counts.js.map +1 -0
- package/dist/src/matchmaking/index.d.ts +20 -0
- package/dist/src/matchmaking/index.d.ts.map +1 -0
- package/dist/src/matchmaking/index.js +20 -0
- package/dist/src/matchmaking/index.js.map +1 -0
- package/dist/src/matchmaking/module.d.ts +181 -0
- package/dist/src/matchmaking/module.d.ts.map +1 -0
- package/dist/src/matchmaking/module.js +221 -0
- package/dist/src/matchmaking/module.js.map +1 -0
- package/dist/src/matchmaking/protocols.d.ts +37 -0
- package/dist/src/matchmaking/protocols.d.ts.map +1 -0
- package/dist/src/matchmaking/protocols.js +42 -0
- package/dist/src/matchmaking/protocols.js.map +1 -0
- package/dist/src/matchmaking/provider-manager.d.ts +52 -0
- package/dist/src/matchmaking/provider-manager.d.ts.map +1 -0
- package/dist/src/matchmaking/provider-manager.js +74 -0
- package/dist/src/matchmaking/provider-manager.js.map +1 -0
- package/dist/src/matchmaking/query-handler.d.ts +34 -0
- package/dist/src/matchmaking/query-handler.d.ts.map +1 -0
- package/dist/src/matchmaking/query-handler.js +62 -0
- package/dist/src/matchmaking/query-handler.js.map +1 -0
- package/dist/src/matchmaking/query-transport.d.ts +180 -0
- package/dist/src/matchmaking/query-transport.d.ts.map +1 -0
- package/dist/src/matchmaking/query-transport.js +315 -0
- package/dist/src/matchmaking/query-transport.js.map +1 -0
- package/dist/src/matchmaking/seeker-manager.d.ts +39 -0
- package/dist/src/matchmaking/seeker-manager.d.ts.map +1 -0
- package/dist/src/matchmaking/seeker-manager.js +49 -0
- package/dist/src/matchmaking/seeker-manager.js.map +1 -0
- package/dist/src/matchmaking/seeker-walk-client.d.ts +127 -0
- package/dist/src/matchmaking/seeker-walk-client.d.ts.map +1 -0
- package/dist/src/matchmaking/seeker-walk-client.js +189 -0
- package/dist/src/matchmaking/seeker-walk-client.js.map +1 -0
- package/dist/src/matchmaking/traffic-validation.d.ts +128 -0
- package/dist/src/matchmaking/traffic-validation.d.ts.map +1 -0
- package/dist/src/matchmaking/traffic-validation.js +105 -0
- package/dist/src/matchmaking/traffic-validation.js.map +1 -0
- package/dist/src/network/network-manager-service.d.ts +4 -2
- package/dist/src/network/network-manager-service.d.ts.map +1 -1
- package/dist/src/network/network-manager-service.js +9 -3
- package/dist/src/network/network-manager-service.js.map +1 -1
- package/dist/src/protocol-client.d.ts +25 -0
- package/dist/src/protocol-client.d.ts.map +1 -1
- package/dist/src/protocol-client.js +126 -4
- package/dist/src/protocol-client.js.map +1 -1
- package/dist/src/reactivity/forwarder-host.d.ts +198 -0
- package/dist/src/reactivity/forwarder-host.d.ts.map +1 -0
- package/dist/src/reactivity/forwarder-host.js +355 -0
- package/dist/src/reactivity/forwarder-host.js.map +1 -0
- package/dist/src/reactivity/index.d.ts +19 -0
- package/dist/src/reactivity/index.d.ts.map +1 -0
- package/dist/src/reactivity/index.js +19 -0
- package/dist/src/reactivity/index.js.map +1 -0
- package/dist/src/reactivity/notify-transport.d.ts +70 -0
- package/dist/src/reactivity/notify-transport.d.ts.map +1 -0
- package/dist/src/reactivity/notify-transport.js +111 -0
- package/dist/src/reactivity/notify-transport.js.map +1 -0
- package/dist/src/reactivity/origination-manager.d.ts +110 -0
- package/dist/src/reactivity/origination-manager.d.ts.map +1 -0
- package/dist/src/reactivity/origination-manager.js +129 -0
- package/dist/src/reactivity/origination-manager.js.map +1 -0
- package/dist/src/reactivity/protocols.d.ts +43 -0
- package/dist/src/reactivity/protocols.d.ts.map +1 -0
- package/dist/src/reactivity/protocols.js +50 -0
- package/dist/src/reactivity/protocols.js.map +1 -0
- package/dist/src/reactivity/push-state-gossip.d.ts +132 -0
- package/dist/src/reactivity/push-state-gossip.d.ts.map +1 -0
- package/dist/src/reactivity/push-state-gossip.js +231 -0
- package/dist/src/reactivity/push-state-gossip.js.map +1 -0
- package/dist/src/reactivity/recover-transport.d.ts +167 -0
- package/dist/src/reactivity/recover-transport.d.ts.map +1 -0
- package/dist/src/reactivity/recover-transport.js +308 -0
- package/dist/src/reactivity/recover-transport.js.map +1 -0
- package/dist/src/reactivity/rotation-rereg-scheduler.d.ts +142 -0
- package/dist/src/reactivity/rotation-rereg-scheduler.d.ts.map +1 -0
- package/dist/src/reactivity/rotation-rereg-scheduler.js +223 -0
- package/dist/src/reactivity/rotation-rereg-scheduler.js.map +1 -0
- package/dist/src/reactivity/subscriber-registry.d.ts +47 -0
- package/dist/src/reactivity/subscriber-registry.d.ts.map +1 -0
- package/dist/src/reactivity/subscriber-registry.js +87 -0
- package/dist/src/reactivity/subscriber-registry.js.map +1 -0
- package/dist/src/reactivity/subscription-manager.d.ts +221 -0
- package/dist/src/reactivity/subscription-manager.d.ts.map +1 -0
- package/dist/src/reactivity/subscription-manager.js +302 -0
- package/dist/src/reactivity/subscription-manager.js.map +1 -0
- package/dist/src/reactivity/topic-bytes.d.ts +32 -0
- package/dist/src/reactivity/topic-bytes.d.ts.map +1 -0
- package/dist/src/reactivity/topic-bytes.js +34 -0
- package/dist/src/reactivity/topic-bytes.js.map +1 -0
- package/dist/src/repo/client.d.ts.map +1 -1
- package/dist/src/repo/client.js +51 -19
- package/dist/src/repo/client.js.map +1 -1
- package/dist/src/repo/cluster-coordinator.d.ts +9 -0
- package/dist/src/repo/cluster-coordinator.d.ts.map +1 -1
- package/dist/src/repo/cluster-coordinator.js +65 -22
- package/dist/src/repo/cluster-coordinator.js.map +1 -1
- package/dist/src/repo/coordinator-repo.d.ts +20 -0
- package/dist/src/repo/coordinator-repo.d.ts.map +1 -1
- package/dist/src/repo/coordinator-repo.js +101 -16
- package/dist/src/repo/coordinator-repo.js.map +1 -1
- package/dist/src/repo/service.d.ts +46 -1
- package/dist/src/repo/service.d.ts.map +1 -1
- package/dist/src/repo/service.js +79 -45
- package/dist/src/repo/service.js.map +1 -1
- package/dist/src/rpc-deadline.d.ts +37 -0
- package/dist/src/rpc-deadline.d.ts.map +1 -0
- package/dist/src/rpc-deadline.js +31 -0
- package/dist/src/rpc-deadline.js.map +1 -0
- package/dist/src/storage/block-storage.d.ts +2 -0
- package/dist/src/storage/block-storage.d.ts.map +1 -1
- package/dist/src/storage/block-storage.js +95 -2
- package/dist/src/storage/block-storage.js.map +1 -1
- package/dist/src/storage/i-block-storage.d.ts +25 -0
- package/dist/src/storage/i-block-storage.d.ts.map +1 -1
- package/dist/src/storage/storage-repo.d.ts +53 -2
- package/dist/src/storage/storage-repo.d.ts.map +1 -1
- package/dist/src/storage/storage-repo.js +193 -9
- package/dist/src/storage/storage-repo.js.map +1 -1
- package/dist/src/sync/client.d.ts +4 -1
- package/dist/src/sync/client.d.ts.map +1 -1
- package/dist/src/sync/client.js +5 -2
- package/dist/src/sync/client.js.map +1 -1
- package/dist/src/testing/cohort-topic-mesh-harness.d.ts +219 -0
- package/dist/src/testing/cohort-topic-mesh-harness.d.ts.map +1 -0
- package/dist/src/testing/cohort-topic-mesh-harness.js +467 -0
- package/dist/src/testing/cohort-topic-mesh-harness.js.map +1 -0
- package/dist/src/testing/matchmaking-mesh-harness.d.ts +187 -0
- package/dist/src/testing/matchmaking-mesh-harness.d.ts.map +1 -0
- package/dist/src/testing/matchmaking-mesh-harness.js +358 -0
- package/dist/src/testing/matchmaking-mesh-harness.js.map +1 -0
- package/dist/src/testing/mesh-harness.d.ts.map +1 -1
- package/dist/src/testing/mesh-harness.js +23 -1
- package/dist/src/testing/mesh-harness.js.map +1 -1
- package/dist/src/testing/reactivity-mesh-harness.d.ts +298 -0
- package/dist/src/testing/reactivity-mesh-harness.d.ts.map +1 -0
- package/dist/src/testing/reactivity-mesh-harness.js +663 -0
- package/dist/src/testing/reactivity-mesh-harness.js.map +1 -0
- package/package.json +7 -4
- package/src/cluster/block-transfer-service.ts +133 -68
- package/src/cluster/client.ts +64 -45
- package/src/cluster/cluster-error.ts +64 -0
- package/src/cluster/cluster-repo.ts +405 -55
- package/src/cluster/commit-cert.ts +139 -0
- package/src/cluster/service.ts +116 -44
- package/src/cluster/spread-on-churn.ts +328 -285
- package/src/cohort-topic/bootstrap-evidence-builder.ts +122 -0
- package/src/cohort-topic/bootstrap-evidence-verifiers.ts +132 -0
- package/src/cohort-topic/bootstrap-parent-reference.ts +159 -0
- package/src/cohort-topic/change-bridge.ts +109 -0
- package/src/cohort-topic/cohort-gossip-driver.ts +144 -0
- package/src/cohort-topic/cohort-gossip-transport.ts +74 -0
- package/src/cohort-topic/fret-trust-anchor.ts +153 -0
- package/src/cohort-topic/host.ts +2175 -0
- package/src/cohort-topic/index.ts +13 -0
- package/src/cohort-topic/membership-publish-sink.ts +20 -0
- package/src/cohort-topic/membership-source.ts +68 -0
- package/src/cohort-topic/peer-codec.ts +31 -0
- package/src/cohort-topic/peer-sig.ts +86 -0
- package/src/cohort-topic/protocols.ts +71 -0
- package/src/cohort-topic/reactivity-membership-gate.ts +77 -0
- package/src/cohort-topic/size-estimator.ts +16 -0
- package/src/cohort-topic/stream-util.ts +87 -0
- package/src/cohort-topic/threshold-crypto.ts +239 -0
- package/src/cohort-topic/topic-router.ts +77 -0
- package/src/dispute/cascade.ts +517 -0
- package/src/dispute/client.ts +12 -2
- package/src/dispute/dispute-service.ts +171 -24
- package/src/dispute/index.ts +42 -0
- package/src/dispute/invalidation.ts +587 -0
- package/src/dispute/types.ts +14 -0
- package/src/index.ts +4 -0
- package/src/libp2p-key-network.ts +67 -9
- package/src/libp2p-node-base.ts +633 -14
- package/src/matchmaking/aggregate-counts.ts +104 -0
- package/src/matchmaking/index.ts +20 -0
- package/src/matchmaking/module.ts +363 -0
- package/src/matchmaking/protocols.ts +51 -0
- package/src/matchmaking/provider-manager.ts +95 -0
- package/src/matchmaking/query-handler.ts +88 -0
- package/src/matchmaking/query-transport.ts +483 -0
- package/src/matchmaking/seeker-manager.ts +64 -0
- package/src/matchmaking/seeker-walk-client.ts +293 -0
- package/src/matchmaking/traffic-validation.ts +195 -0
- package/src/network/network-manager-service.ts +9 -2
- package/src/protocol-client.ts +119 -5
- package/src/reactivity/forwarder-host.ts +438 -0
- package/src/reactivity/index.ts +19 -0
- package/src/reactivity/notify-transport.ts +144 -0
- package/src/reactivity/origination-manager.ts +192 -0
- package/src/reactivity/protocols.ts +61 -0
- package/src/reactivity/push-state-gossip.ts +291 -0
- package/src/reactivity/recover-transport.ts +408 -0
- package/src/reactivity/rotation-rereg-scheduler.ts +256 -0
- package/src/reactivity/subscriber-registry.ts +96 -0
- package/src/reactivity/subscription-manager.ts +450 -0
- package/src/reactivity/topic-bytes.ts +37 -0
- package/src/repo/client.ts +54 -19
- package/src/repo/cluster-coordinator.ts +66 -26
- package/src/repo/coordinator-repo.ts +99 -15
- package/src/repo/service.ts +90 -42
- package/src/rpc-deadline.ts +45 -0
- package/src/storage/block-storage.ts +106 -3
- package/src/storage/i-block-storage.ts +27 -0
- package/src/storage/storage-repo.ts +209 -13
- package/src/sync/client.ts +5 -2
- package/src/testing/cohort-topic-mesh-harness.ts +613 -0
- package/src/testing/matchmaking-mesh-harness.ts +475 -0
- package/src/testing/mesh-harness.ts +22 -2
- package/src/testing/reactivity-mesh-harness.ts +922 -0
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reactivity notify transport — the one-way `NotificationV1` delivery primitive (`docs/reactivity.md`
|
|
3
|
+
* §Propagation).
|
|
4
|
+
*
|
|
5
|
+
* Unlike the cohort-gossip transport (which *broadcasts* a frame to a FRET-assembled cohort), notify is
|
|
6
|
+
* **unicast**: the fan-out orchestration above this layer (the `reactivity-forwarder-host` ticket) decides
|
|
7
|
+
* who to dial and calls {@link ReactivityNotifyTransport.send} once per named target. This module owns only
|
|
8
|
+
* the framing + dial + inbound-decode plumbing — no fan-out, no role decision, no gossip.
|
|
9
|
+
*
|
|
10
|
+
* The db-core `NotificationV1` codec ({@link encodeNotificationV1} / {@link decodeNotificationV1}) does the
|
|
11
|
+
* length-prefixed JSON framing; this layer rides one self-delimiting frame each way over the notify
|
|
12
|
+
* protocol, reusing the cohort-topic {@link sendOneWay} / {@link readAllBounded} stream lifecycle so the
|
|
13
|
+
* two protocol families behave identically on the wire.
|
|
14
|
+
*
|
|
15
|
+
* Failure isolation is the load-bearing property: notify is fire-and-forget and hint-only, so a dead /
|
|
16
|
+
* unreachable target's rejection is swallowed (logged), never propagated to the caller's fan-out loop or a
|
|
17
|
+
* commit. There is no reply frame — a handler that tried to send one back would desync the dialer's
|
|
18
|
+
* {@link sendOneWay} (which closes after send).
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
import type { NotificationV1, PeerRef } from "@optimystic/db-core";
|
|
22
|
+
import { encodeNotificationV1, decodeNotificationV1 } from "@optimystic/db-core";
|
|
23
|
+
import type { Libp2p } from "libp2p";
|
|
24
|
+
import type { Connection, Stream } from "@libp2p/interface";
|
|
25
|
+
import { peerIdFromString } from "@libp2p/peer-id";
|
|
26
|
+
import { readAllBounded } from "p2p-fret";
|
|
27
|
+
import { peerIdToBytes } from "../cohort-topic/peer-codec.js";
|
|
28
|
+
import { sendOneWay, DEFAULT_STREAM_MAX_BYTES } from "../cohort-topic/stream-util.js";
|
|
29
|
+
import { PROTOCOL_REACTIVITY_NOTIFY } from "./protocols.js";
|
|
30
|
+
import { createLogger } from "../logger.js";
|
|
31
|
+
|
|
32
|
+
const log = createLogger("reactivity-notify");
|
|
33
|
+
|
|
34
|
+
/** One-way `NotificationV1` transport: unicast send, inbound subscribe, and the host's deliver seam. */
|
|
35
|
+
export interface ReactivityNotifyTransport {
|
|
36
|
+
/**
|
|
37
|
+
* Frame `n` ({@link encodeNotificationV1}) and dial `target` (peer-id string) over the notify protocol.
|
|
38
|
+
* Fire-and-forget, failure-isolated: a dead/unreachable target's rejection is swallowed (logged), never
|
|
39
|
+
* propagated to the caller's fan-out loop.
|
|
40
|
+
*/
|
|
41
|
+
send(target: string, n: NotificationV1): Promise<void>;
|
|
42
|
+
/** Subscribe to inbound notifications (after decode); returns an unsubscribe handle. */
|
|
43
|
+
onNotification(handler: (from: PeerRef, n: NotificationV1) => void): () => void;
|
|
44
|
+
/** Feed an inbound notify frame (called by the host's notify protocol handler). */
|
|
45
|
+
deliver(fromPeerId: string, frame: Uint8Array): void;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** Construction options for {@link Libp2pReactivityNotifyTransport}. */
|
|
49
|
+
export interface ReactivityNotifyTransportOptions {
|
|
50
|
+
/** Notify protocol ID; default {@link PROTOCOL_REACTIVITY_NOTIFY}. */
|
|
51
|
+
readonly notifyProtocol?: string;
|
|
52
|
+
/** Per-frame ceiling for the inbound decode bound. Default {@link DEFAULT_STREAM_MAX_BYTES}. */
|
|
53
|
+
readonly maxBytes?: number;
|
|
54
|
+
/** This node's peer-id string; when set, {@link Libp2pReactivityNotifyTransport.send} never dials self. */
|
|
55
|
+
readonly selfPeerId?: string;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* libp2p-backed {@link ReactivityNotifyTransport}: {@link send} frames + dials a single target over
|
|
60
|
+
* `/optimystic/reactivity/1.0.0/notify` (fire-and-forget, failure-isolated); inbound frames arrive through
|
|
61
|
+
* the host's notify protocol handler ({@link registerNotifyHandler}), which calls {@link deliver}.
|
|
62
|
+
* Subscribers registered via {@link onNotification} see every decoded notification.
|
|
63
|
+
*/
|
|
64
|
+
export class Libp2pReactivityNotifyTransport implements ReactivityNotifyTransport {
|
|
65
|
+
private readonly handlers = new Set<(from: PeerRef, n: NotificationV1) => void>();
|
|
66
|
+
private readonly notifyProtocol: string;
|
|
67
|
+
private readonly maxBytes: number;
|
|
68
|
+
private readonly selfPeerId?: string;
|
|
69
|
+
|
|
70
|
+
constructor(private readonly node: Libp2p, options: ReactivityNotifyTransportOptions = {}) {
|
|
71
|
+
this.notifyProtocol = options.notifyProtocol ?? PROTOCOL_REACTIVITY_NOTIFY;
|
|
72
|
+
this.maxBytes = options.maxBytes ?? DEFAULT_STREAM_MAX_BYTES;
|
|
73
|
+
this.selfPeerId = options.selfPeerId;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
send(target: string, n: NotificationV1): Promise<void> {
|
|
77
|
+
if (this.selfPeerId !== undefined && target === this.selfPeerId) {
|
|
78
|
+
// Never dial self; a co-located subscriber is delivered in-process by the forwarder host.
|
|
79
|
+
return Promise.resolve();
|
|
80
|
+
}
|
|
81
|
+
try {
|
|
82
|
+
const frame = encodeNotificationV1(n);
|
|
83
|
+
return sendOneWay(this.node, peerIdFromString(target), this.notifyProtocol, frame).catch((err: unknown) => {
|
|
84
|
+
// Best-effort, failure-isolated: a dead/unreachable target must not break the fan-out or a commit.
|
|
85
|
+
log("send to %s failed (swallowed): %o", target, err);
|
|
86
|
+
});
|
|
87
|
+
} catch (err) {
|
|
88
|
+
// Malformed notification or peer-id string: log + drop, never reject (reactivity is hint-only).
|
|
89
|
+
log("dropped a send to %s: %o", target, err);
|
|
90
|
+
return Promise.resolve();
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
onNotification(handler: (from: PeerRef, n: NotificationV1) => void): () => void {
|
|
95
|
+
this.handlers.add(handler);
|
|
96
|
+
return () => this.handlers.delete(handler);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/** Feed an inbound notify frame (called by the host's notify protocol handler). */
|
|
100
|
+
deliver(fromPeerId: string, frame: Uint8Array): void {
|
|
101
|
+
let n: NotificationV1;
|
|
102
|
+
try {
|
|
103
|
+
n = decodeNotificationV1(frame, this.maxBytes);
|
|
104
|
+
} catch (err) {
|
|
105
|
+
// A malformed frame must never throw out of a stream handler: log + drop.
|
|
106
|
+
log("dropped an undecodable inbound frame from %s: %o", fromPeerId, err);
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
const from: PeerRef = { id: peerIdToBytes(fromPeerId) };
|
|
110
|
+
for (const handler of this.handlers) {
|
|
111
|
+
handler(from, n);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Register the inbound notify protocol handler: read one bounded frame and hand it to
|
|
118
|
+
* {@link ReactivityNotifyTransport.deliver}, then close. One-way — no reply frame (notify is strictly
|
|
119
|
+
* fire-and-forget; a reply would desync the dialer's {@link sendOneWay}). Mirrors the cohort-topic
|
|
120
|
+
* one-way handlers: a read error aborts the stream, and {@link ReactivityNotifyTransport.deliver}
|
|
121
|
+
* swallows a decode failure, so the handler never throws on the stream.
|
|
122
|
+
*/
|
|
123
|
+
export function registerNotifyHandler(
|
|
124
|
+
node: Libp2p,
|
|
125
|
+
protocol: string,
|
|
126
|
+
transport: ReactivityNotifyTransport,
|
|
127
|
+
maxBytes = DEFAULT_STREAM_MAX_BYTES,
|
|
128
|
+
): void {
|
|
129
|
+
void node.handle(protocol, (stream: Stream, connection: Connection) => {
|
|
130
|
+
void (async (): Promise<void> => {
|
|
131
|
+
try {
|
|
132
|
+
const frame = await readAllBounded(stream, maxBytes);
|
|
133
|
+
transport.deliver(connection.remotePeer.toString(), frame);
|
|
134
|
+
await stream.close();
|
|
135
|
+
} catch {
|
|
136
|
+
try {
|
|
137
|
+
stream.abort(new Error("reactivity notify stream handler error"));
|
|
138
|
+
} catch {
|
|
139
|
+
/* already aborted */
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
})();
|
|
143
|
+
});
|
|
144
|
+
}
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reactivity — notification origination manager (db-p2p, wires to the cohort-topic substrate).
|
|
3
|
+
*
|
|
4
|
+
* Installs the substrate's {@link CohortTopicService.onLocalCommit} origination hook so a commit landing
|
|
5
|
+
* on a node that is a tail-cohort member for the collection's reactivity topic emits a signed
|
|
6
|
+
* {@link NotificationV1} (`docs/reactivity.md` §Notification origination). The local-change-notifier
|
|
7
|
+
* bridge ([local-change-notifier-bridge]) supplies the {@link CollectionChangeEvent} + pass-through
|
|
8
|
+
* {@link CommitCert}; this manager calls db-core's {@link buildNotificationV1} (which reuses the commit
|
|
9
|
+
* cert's threshold signature **unchanged** — reactivity never re-signs) and hands the result to the
|
|
10
|
+
* injected {@link emit} transport, which fans it out to direct subscribers and child cohorts.
|
|
11
|
+
*
|
|
12
|
+
* The cluster keys its commit votes by **peer-id string**; the cohort-topic membership verifier compares
|
|
13
|
+
* signers as the member-id **bytes** (UTF-8 of the peer-id string, base64url on the wire). So this
|
|
14
|
+
* manager supplies `encodeSigner = s ⇒ bytesToB64url(peerIdToBytes(s))`, the inverse the subscriber's
|
|
15
|
+
* {@link createNotificationVerifier} default (`b64urlToBytes`) consumes — closing the encoding loop end
|
|
16
|
+
* to end.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import {
|
|
20
|
+
buildNotificationV1,
|
|
21
|
+
bytesToB64url,
|
|
22
|
+
b64urlToBytes,
|
|
23
|
+
reactivityTopicId,
|
|
24
|
+
BlockFillTracker,
|
|
25
|
+
type BlockFillTrackerInit,
|
|
26
|
+
type CohortTopicService,
|
|
27
|
+
type CollectionChangeEvent,
|
|
28
|
+
type CommitCert,
|
|
29
|
+
type NotificationV1,
|
|
30
|
+
type RotationHintV1,
|
|
31
|
+
} from "@optimystic/db-core";
|
|
32
|
+
import { peerIdToBytes } from "../cohort-topic/peer-codec.js";
|
|
33
|
+
import { createLogger } from "../logger.js";
|
|
34
|
+
|
|
35
|
+
const log = createLogger("reactivity-origination");
|
|
36
|
+
|
|
37
|
+
/** Per-collection origination context the manager resolves at emit time. */
|
|
38
|
+
export interface OriginationCollectionContext {
|
|
39
|
+
/** Current tail block id the reactivity topic is anchored on (raw bytes). */
|
|
40
|
+
readonly tailId: Uint8Array;
|
|
41
|
+
/** Per-collection delta budget (bytes); `0` ⇒ omit `delta` (Edge / collection declines deltas). */
|
|
42
|
+
readonly deltaMaxBytes: number;
|
|
43
|
+
/** Optional bounded delta to attach (raw bytes). */
|
|
44
|
+
readonly delta?: Uint8Array;
|
|
45
|
+
/** Optional tail-rotation pre-announce (rotation ticket supplies it). */
|
|
46
|
+
readonly rotationHint?: RotationHintV1;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** Construction inputs for a {@link ReactivityOriginationManager}. */
|
|
50
|
+
export interface ReactivityOriginationManagerOptions {
|
|
51
|
+
/** The cohort-topic substrate whose `onLocalCommit` hook this manager installs. */
|
|
52
|
+
readonly service: CohortTopicService;
|
|
53
|
+
/**
|
|
54
|
+
* Resolve the per-collection origination context (tail id, delta budget) for a change event. Returns
|
|
55
|
+
* `undefined` to skip origination for this collection (e.g. this node is not the tail primary for it).
|
|
56
|
+
*/
|
|
57
|
+
readonly resolveContext: (event: CollectionChangeEvent) => OriginationCollectionContext | undefined;
|
|
58
|
+
/** Fan the built notification out to direct subscribers and child cohorts (the reactivity transport). */
|
|
59
|
+
readonly emit: (notification: NotificationV1) => void;
|
|
60
|
+
/**
|
|
61
|
+
* Start the **outgoing** tail's drain when this manager observes a collection's tail id **change**
|
|
62
|
+
* between commits (the authoritative, observable live-node rotation signal — the pre-announce
|
|
63
|
+
* `rotationHint{ newTailId }` cannot be built on a live node because the successor tail id is not knowable
|
|
64
|
+
* at the filling commit; see `docs/reactivity.md` §Tail rotation and the `6.5-block-id-derivation` gate).
|
|
65
|
+
* The node binds this to {@link import("./forwarder-host.js").ReactivityForwarderHost.markRotated} so the
|
|
66
|
+
* old cohort's recover serve begins redirecting. `oldTopicId` is the **previous** tail's reactivity topic
|
|
67
|
+
* id (`reactivityTopicId` over the resolved tail bytes — the SAME encoding a subscriber subscribes under).
|
|
68
|
+
* Absent ⇒ origination is unchanged (rotation observation is inert), preserving existing callers/tests.
|
|
69
|
+
*/
|
|
70
|
+
readonly markRotated?: (oldTopicId: Uint8Array, redirect: { newTailId: string; effectiveAtRevision: number }, now: number) => void;
|
|
71
|
+
/**
|
|
72
|
+
* Per-collection {@link BlockFillTracker} tuning for the anticipatory **warm-up** signal. The warm-up is
|
|
73
|
+
* best-effort and **signal-only** on a live node (the next `tailId` is not knowable, so no successor coord
|
|
74
|
+
* is fabricated — the bias is logged, never acted on; `docs/reactivity.md` §Anticipatory warm-up). Defaults
|
|
75
|
+
* to the db-core block-fill defaults.
|
|
76
|
+
*/
|
|
77
|
+
readonly blockFill?: BlockFillTrackerInit;
|
|
78
|
+
/** Wall clock (unix ms) stamped on each notification. Default `Date.now`. */
|
|
79
|
+
readonly clock?: () => number;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/** Installs and drives the reactivity origination hook on a {@link CohortTopicService}. */
|
|
83
|
+
export class ReactivityOriginationManager {
|
|
84
|
+
private readonly service: CohortTopicService;
|
|
85
|
+
private readonly resolveContext: (event: CollectionChangeEvent) => OriginationCollectionContext | undefined;
|
|
86
|
+
private readonly emit: (notification: NotificationV1) => void;
|
|
87
|
+
private readonly markRotated?: (oldTopicId: Uint8Array, redirect: { newTailId: string; effectiveAtRevision: number }, now: number) => void;
|
|
88
|
+
private readonly blockFill?: BlockFillTrackerInit;
|
|
89
|
+
private readonly clock: () => number;
|
|
90
|
+
|
|
91
|
+
/** Last-seen reactivity tail anchor (base64url of the resolved tail bytes) per collection — the rotation signal. */
|
|
92
|
+
private readonly lastSeenTail = new Map<string, string>();
|
|
93
|
+
/** Per-collection block-fill tracker driving the anticipatory warm-up signal (signal-only on a live node). */
|
|
94
|
+
private readonly fillTrackers = new Map<string, BlockFillTracker>();
|
|
95
|
+
|
|
96
|
+
constructor(options: ReactivityOriginationManagerOptions) {
|
|
97
|
+
this.service = options.service;
|
|
98
|
+
this.resolveContext = options.resolveContext;
|
|
99
|
+
this.emit = options.emit;
|
|
100
|
+
this.markRotated = options.markRotated;
|
|
101
|
+
this.blockFill = options.blockFill;
|
|
102
|
+
this.clock = options.clock ?? ((): number => Date.now());
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/** Install the origination hook (overwrites any prior `onLocalCommit`). */
|
|
106
|
+
install(): void {
|
|
107
|
+
this.service.onLocalCommit = (event, commitCert): void => this.originate(event, commitCert);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/** Build + emit the notification for one committed change; isolates throws so commit is never broken. */
|
|
111
|
+
private originate(event: CollectionChangeEvent, commitCert: CommitCert): void {
|
|
112
|
+
try {
|
|
113
|
+
const ctx = this.resolveContext(event);
|
|
114
|
+
if (ctx === undefined) {
|
|
115
|
+
return; // not the origination point for this collection (tail-less / non-member)
|
|
116
|
+
}
|
|
117
|
+
// Observe the tail (rotation detection + block-fill warm-up) BEFORE emit, fully isolated so neither
|
|
118
|
+
// ever blocks the notification — the delivery-critical path.
|
|
119
|
+
this.observeTail(event, ctx);
|
|
120
|
+
const notification = buildNotificationV1(event, commitCert, {
|
|
121
|
+
tailId: bytesToB64url(ctx.tailId),
|
|
122
|
+
timestamp: this.clock(),
|
|
123
|
+
deltaMaxBytes: ctx.deltaMaxBytes,
|
|
124
|
+
delta: ctx.delta,
|
|
125
|
+
rotationHint: ctx.rotationHint,
|
|
126
|
+
encodeSigner: (s) => bytesToB64url(peerIdToBytes(s)),
|
|
127
|
+
});
|
|
128
|
+
this.emit(notification);
|
|
129
|
+
} catch (err) {
|
|
130
|
+
log("origination failed for collection=%s rev=%d: %o", event.collectionId, event.rev, err);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Track the collection's reactivity tail and drive the rotation + warm-up signals. Isolated so a fault
|
|
136
|
+
* here never blocks the notification emit. Only reached for commits this node originates (a defined `ctx`),
|
|
137
|
+
* so a tail-less (read-driven) commit never records or clears the last-seen tail (the early-return holds).
|
|
138
|
+
*/
|
|
139
|
+
private observeTail(event: CollectionChangeEvent, ctx: OriginationCollectionContext): void {
|
|
140
|
+
try {
|
|
141
|
+
this.trackBlockFill(event);
|
|
142
|
+
this.detectTailRotation(event, ctx);
|
|
143
|
+
} catch (err) {
|
|
144
|
+
log("rotation/warm-up observation failed for collection=%s rev=%d (isolated): %o", event.collectionId, event.rev, err);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Feed the per-collection {@link BlockFillTracker} one commit. The `warmup` signal is **best-effort and
|
|
150
|
+
* signal-only** on a live node: the next `tailId` is not knowable (block ids are random until
|
|
151
|
+
* `6.5-block-id-derivation`), so the anticipatory pre-dial bias is logged, never fabricated into a
|
|
152
|
+
* successor coord (`docs/reactivity.md` §Anticipatory warm-up). The `filling` signal cannot pre-announce a
|
|
153
|
+
* hint on a live node for the same reason — it is logged only.
|
|
154
|
+
*/
|
|
155
|
+
private trackBlockFill(event: CollectionChangeEvent): void {
|
|
156
|
+
const key = event.collectionId;
|
|
157
|
+
let tracker = this.fillTrackers.get(key);
|
|
158
|
+
if (tracker === undefined) {
|
|
159
|
+
tracker = new BlockFillTracker(this.blockFill);
|
|
160
|
+
this.fillTrackers.set(key, tracker);
|
|
161
|
+
}
|
|
162
|
+
const signal = tracker.onCommit();
|
|
163
|
+
if (signal.kind === "warmup") {
|
|
164
|
+
log("block-fill warm-up for collection=%s (%d committed, %d remaining) — anticipatory pre-dial is signal-only on a live node (successor tail not knowable; gated on 6.5-block-id-derivation)", key, signal.count, signal.remaining);
|
|
165
|
+
} else if (signal.kind === "filling") {
|
|
166
|
+
log("block-fill filling commit for collection=%s (%d committed) — no live pre-announce (successor tail id not knowable; rotation observed on the next commit's tail-id change)", key, signal.count);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Detect a tail rotation by comparing the resolved tail anchor against the last-seen one for the
|
|
172
|
+
* collection. The first commit records the baseline (no rotation). On a **change**, the previous tail's
|
|
173
|
+
* reactivity topic has rotated to this one: fire {@link markRotated} for the OLD topic so the old cohort's
|
|
174
|
+
* recover serve begins redirecting to the new tree.
|
|
175
|
+
*
|
|
176
|
+
* **Encoding contract.** `ctx.tailId` is the reactivity tail anchor bytes the node resolved
|
|
177
|
+
* (`reactivityTailBytes(event.tailId)` in production — the SAME utf8 encoding origination's membership gate
|
|
178
|
+
* and a subscriber's `reactivityTopicId(reactivityTailBytes(tail))` use, NOT the double-hashing
|
|
179
|
+
* `blockIdToBytes`). So `oldTopicId = reactivityTopicId(oldAnchorBytes)` is byte-identical to the topic a
|
|
180
|
+
* subscriber subscribed under — a mismatch would silently never redirect.
|
|
181
|
+
*/
|
|
182
|
+
private detectTailRotation(event: CollectionChangeEvent, ctx: OriginationCollectionContext): void {
|
|
183
|
+
const key = event.collectionId;
|
|
184
|
+
const newTailB64 = bytesToB64url(ctx.tailId);
|
|
185
|
+
const lastTailB64 = this.lastSeenTail.get(key);
|
|
186
|
+
if (lastTailB64 !== undefined && lastTailB64 !== newTailB64) {
|
|
187
|
+
const oldTopicId = reactivityTopicId(b64urlToBytes(lastTailB64));
|
|
188
|
+
this.markRotated?.(oldTopicId, { newTailId: newTailB64, effectiveAtRevision: event.rev }, this.clock());
|
|
189
|
+
}
|
|
190
|
+
this.lastSeenTail.set(key, newTailB64);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reactivity libp2p protocol IDs (`docs/reactivity.md` §Propagation / §Notification origination).
|
|
3
|
+
*
|
|
4
|
+
* The reactivity family rides the same FRET/libp2p node as the cohort-topic substrate it is layered on:
|
|
5
|
+
*
|
|
6
|
+
* - `notify` — `NotificationV1` fan-out down the reactivity tree (one-way, fire-and-forget).
|
|
7
|
+
* - `push-state-gossip` — `PushStateGossipV1` intra-cohort push-state convergence (one-way). Declared
|
|
8
|
+
* here so one place owns the family; the `reactivity-pushstate-gossip` ticket
|
|
9
|
+
* consumes it.
|
|
10
|
+
* - `recover` — `RecoverRequestV1`/`RecoverReplyV1` backfill/resume recovery RPC
|
|
11
|
+
* (request-reply, one frame each way). Consumed by `reactivity-recover-rpc-transport`.
|
|
12
|
+
*
|
|
13
|
+
* The default (network-agnostic) IDs omit the network segment; {@link makeReactivityProtocols} mirrors
|
|
14
|
+
* FRET's `makeProtocols(networkName)` so a named network namespaces its reactivity protocols the same way
|
|
15
|
+
* FRET namespaces its routing protocols (and the cohort-topic family namespaces via
|
|
16
|
+
* {@link import("../cohort-topic/protocols.js").makeCohortTopicProtocols}).
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
/** Base path for the reactivity protocol family. */
|
|
20
|
+
export const REACTIVITY_BASE = "/optimystic/reactivity/1.0.0" as const;
|
|
21
|
+
|
|
22
|
+
/** `NotificationV1` — change-notification fan-out down the reactivity tree (one-way). */
|
|
23
|
+
export const PROTOCOL_REACTIVITY_NOTIFY = `${REACTIVITY_BASE}/notify` as const;
|
|
24
|
+
/** `PushStateGossipV1` — intra-cohort push-state convergence (one-way) [used by reactivity-pushstate-gossip]. */
|
|
25
|
+
export const PROTOCOL_REACTIVITY_PUSH_STATE_GOSSIP = `${REACTIVITY_BASE}/push-state-gossip` as const;
|
|
26
|
+
/** `RecoverRequestV1`/`RecoverReplyV1` — backfill/resume recovery RPC (request-reply) [used by reactivity-recover-rpc-transport]. */
|
|
27
|
+
export const PROTOCOL_REACTIVITY_RECOVER = `${REACTIVITY_BASE}/recover` as const;
|
|
28
|
+
|
|
29
|
+
/** The reactivity protocol IDs in registration order. */
|
|
30
|
+
export interface ReactivityProtocols {
|
|
31
|
+
readonly notify: string;
|
|
32
|
+
readonly pushStateGossip: string;
|
|
33
|
+
readonly recover: string;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** Default (network-agnostic) protocol IDs, matching `docs/reactivity.md`. */
|
|
37
|
+
export const DEFAULT_REACTIVITY_PROTOCOLS: ReactivityProtocols = {
|
|
38
|
+
notify: PROTOCOL_REACTIVITY_NOTIFY,
|
|
39
|
+
pushStateGossip: PROTOCOL_REACTIVITY_PUSH_STATE_GOSSIP,
|
|
40
|
+
recover: PROTOCOL_REACTIVITY_RECOVER,
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Namespaced reactivity protocol IDs for `networkName` (mirrors FRET's `makeProtocols`, which inserts the
|
|
45
|
+
* network segment even for `"default"` → `/optimystic/default/...`). Note this does NOT equal
|
|
46
|
+
* {@link DEFAULT_REACTIVITY_PROTOCOLS}: the canonical, network-agnostic IDs omit the segment entirely
|
|
47
|
+
* (`/optimystic/reactivity/1.0.0/...`); use those unless you need per-network namespacing.
|
|
48
|
+
*/
|
|
49
|
+
export function makeReactivityProtocols(networkName = "default"): ReactivityProtocols {
|
|
50
|
+
const base = `/optimystic/${networkName}/reactivity/1.0.0`;
|
|
51
|
+
return {
|
|
52
|
+
notify: `${base}/notify`,
|
|
53
|
+
pushStateGossip: `${base}/push-state-gossip`,
|
|
54
|
+
recover: `${base}/recover`,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** All reactivity protocol IDs as an array (for `node.handle` / `unhandle` over the set). */
|
|
59
|
+
export function reactivityProtocolList(p: ReactivityProtocols): string[] {
|
|
60
|
+
return [p.notify, p.pushStateGossip, p.recover];
|
|
61
|
+
}
|