@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,110 @@
|
|
|
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
|
+
import { type BlockFillTrackerInit, type CohortTopicService, type CollectionChangeEvent, type NotificationV1, type RotationHintV1 } from "@optimystic/db-core";
|
|
19
|
+
/** Per-collection origination context the manager resolves at emit time. */
|
|
20
|
+
export interface OriginationCollectionContext {
|
|
21
|
+
/** Current tail block id the reactivity topic is anchored on (raw bytes). */
|
|
22
|
+
readonly tailId: Uint8Array;
|
|
23
|
+
/** Per-collection delta budget (bytes); `0` ⇒ omit `delta` (Edge / collection declines deltas). */
|
|
24
|
+
readonly deltaMaxBytes: number;
|
|
25
|
+
/** Optional bounded delta to attach (raw bytes). */
|
|
26
|
+
readonly delta?: Uint8Array;
|
|
27
|
+
/** Optional tail-rotation pre-announce (rotation ticket supplies it). */
|
|
28
|
+
readonly rotationHint?: RotationHintV1;
|
|
29
|
+
}
|
|
30
|
+
/** Construction inputs for a {@link ReactivityOriginationManager}. */
|
|
31
|
+
export interface ReactivityOriginationManagerOptions {
|
|
32
|
+
/** The cohort-topic substrate whose `onLocalCommit` hook this manager installs. */
|
|
33
|
+
readonly service: CohortTopicService;
|
|
34
|
+
/**
|
|
35
|
+
* Resolve the per-collection origination context (tail id, delta budget) for a change event. Returns
|
|
36
|
+
* `undefined` to skip origination for this collection (e.g. this node is not the tail primary for it).
|
|
37
|
+
*/
|
|
38
|
+
readonly resolveContext: (event: CollectionChangeEvent) => OriginationCollectionContext | undefined;
|
|
39
|
+
/** Fan the built notification out to direct subscribers and child cohorts (the reactivity transport). */
|
|
40
|
+
readonly emit: (notification: NotificationV1) => void;
|
|
41
|
+
/**
|
|
42
|
+
* Start the **outgoing** tail's drain when this manager observes a collection's tail id **change**
|
|
43
|
+
* between commits (the authoritative, observable live-node rotation signal — the pre-announce
|
|
44
|
+
* `rotationHint{ newTailId }` cannot be built on a live node because the successor tail id is not knowable
|
|
45
|
+
* at the filling commit; see `docs/reactivity.md` §Tail rotation and the `6.5-block-id-derivation` gate).
|
|
46
|
+
* The node binds this to {@link import("./forwarder-host.js").ReactivityForwarderHost.markRotated} so the
|
|
47
|
+
* old cohort's recover serve begins redirecting. `oldTopicId` is the **previous** tail's reactivity topic
|
|
48
|
+
* id (`reactivityTopicId` over the resolved tail bytes — the SAME encoding a subscriber subscribes under).
|
|
49
|
+
* Absent ⇒ origination is unchanged (rotation observation is inert), preserving existing callers/tests.
|
|
50
|
+
*/
|
|
51
|
+
readonly markRotated?: (oldTopicId: Uint8Array, redirect: {
|
|
52
|
+
newTailId: string;
|
|
53
|
+
effectiveAtRevision: number;
|
|
54
|
+
}, now: number) => void;
|
|
55
|
+
/**
|
|
56
|
+
* Per-collection {@link BlockFillTracker} tuning for the anticipatory **warm-up** signal. The warm-up is
|
|
57
|
+
* best-effort and **signal-only** on a live node (the next `tailId` is not knowable, so no successor coord
|
|
58
|
+
* is fabricated — the bias is logged, never acted on; `docs/reactivity.md` §Anticipatory warm-up). Defaults
|
|
59
|
+
* to the db-core block-fill defaults.
|
|
60
|
+
*/
|
|
61
|
+
readonly blockFill?: BlockFillTrackerInit;
|
|
62
|
+
/** Wall clock (unix ms) stamped on each notification. Default `Date.now`. */
|
|
63
|
+
readonly clock?: () => number;
|
|
64
|
+
}
|
|
65
|
+
/** Installs and drives the reactivity origination hook on a {@link CohortTopicService}. */
|
|
66
|
+
export declare class ReactivityOriginationManager {
|
|
67
|
+
private readonly service;
|
|
68
|
+
private readonly resolveContext;
|
|
69
|
+
private readonly emit;
|
|
70
|
+
private readonly markRotated?;
|
|
71
|
+
private readonly blockFill?;
|
|
72
|
+
private readonly clock;
|
|
73
|
+
/** Last-seen reactivity tail anchor (base64url of the resolved tail bytes) per collection — the rotation signal. */
|
|
74
|
+
private readonly lastSeenTail;
|
|
75
|
+
/** Per-collection block-fill tracker driving the anticipatory warm-up signal (signal-only on a live node). */
|
|
76
|
+
private readonly fillTrackers;
|
|
77
|
+
constructor(options: ReactivityOriginationManagerOptions);
|
|
78
|
+
/** Install the origination hook (overwrites any prior `onLocalCommit`). */
|
|
79
|
+
install(): void;
|
|
80
|
+
/** Build + emit the notification for one committed change; isolates throws so commit is never broken. */
|
|
81
|
+
private originate;
|
|
82
|
+
/**
|
|
83
|
+
* Track the collection's reactivity tail and drive the rotation + warm-up signals. Isolated so a fault
|
|
84
|
+
* here never blocks the notification emit. Only reached for commits this node originates (a defined `ctx`),
|
|
85
|
+
* so a tail-less (read-driven) commit never records or clears the last-seen tail (the early-return holds).
|
|
86
|
+
*/
|
|
87
|
+
private observeTail;
|
|
88
|
+
/**
|
|
89
|
+
* Feed the per-collection {@link BlockFillTracker} one commit. The `warmup` signal is **best-effort and
|
|
90
|
+
* signal-only** on a live node: the next `tailId` is not knowable (block ids are random until
|
|
91
|
+
* `6.5-block-id-derivation`), so the anticipatory pre-dial bias is logged, never fabricated into a
|
|
92
|
+
* successor coord (`docs/reactivity.md` §Anticipatory warm-up). The `filling` signal cannot pre-announce a
|
|
93
|
+
* hint on a live node for the same reason — it is logged only.
|
|
94
|
+
*/
|
|
95
|
+
private trackBlockFill;
|
|
96
|
+
/**
|
|
97
|
+
* Detect a tail rotation by comparing the resolved tail anchor against the last-seen one for the
|
|
98
|
+
* collection. The first commit records the baseline (no rotation). On a **change**, the previous tail's
|
|
99
|
+
* reactivity topic has rotated to this one: fire {@link markRotated} for the OLD topic so the old cohort's
|
|
100
|
+
* recover serve begins redirecting to the new tree.
|
|
101
|
+
*
|
|
102
|
+
* **Encoding contract.** `ctx.tailId` is the reactivity tail anchor bytes the node resolved
|
|
103
|
+
* (`reactivityTailBytes(event.tailId)` in production — the SAME utf8 encoding origination's membership gate
|
|
104
|
+
* and a subscriber's `reactivityTopicId(reactivityTailBytes(tail))` use, NOT the double-hashing
|
|
105
|
+
* `blockIdToBytes`). So `oldTopicId = reactivityTopicId(oldAnchorBytes)` is byte-identical to the topic a
|
|
106
|
+
* subscriber subscribed under — a mismatch would silently never redirect.
|
|
107
|
+
*/
|
|
108
|
+
private detectTailRotation;
|
|
109
|
+
}
|
|
110
|
+
//# sourceMappingURL=origination-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"origination-manager.d.ts","sourceRoot":"","sources":["../../../src/reactivity/origination-manager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAMN,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,EACvB,KAAK,qBAAqB,EAE1B,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,MAAM,qBAAqB,CAAC;AAM7B,4EAA4E;AAC5E,MAAM,WAAW,4BAA4B;IAC5C,6EAA6E;IAC7E,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;IAC5B,mGAAmG;IACnG,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,oDAAoD;IACpD,QAAQ,CAAC,KAAK,CAAC,EAAE,UAAU,CAAC;IAC5B,yEAAyE;IACzE,QAAQ,CAAC,YAAY,CAAC,EAAE,cAAc,CAAC;CACvC;AAED,sEAAsE;AACtE,MAAM,WAAW,mCAAmC;IACnD,mFAAmF;IACnF,QAAQ,CAAC,OAAO,EAAE,kBAAkB,CAAC;IACrC;;;OAGG;IACH,QAAQ,CAAC,cAAc,EAAE,CAAC,KAAK,EAAE,qBAAqB,KAAK,4BAA4B,GAAG,SAAS,CAAC;IACpG,yGAAyG;IACzG,QAAQ,CAAC,IAAI,EAAE,CAAC,YAAY,EAAE,cAAc,KAAK,IAAI,CAAC;IACtD;;;;;;;;;OASG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC,UAAU,EAAE,UAAU,EAAE,QAAQ,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,mBAAmB,EAAE,MAAM,CAAA;KAAE,EAAE,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IACnI;;;;;OAKG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,oBAAoB,CAAC;IAC1C,6EAA6E;IAC7E,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,MAAM,CAAC;CAC9B;AAED,2FAA2F;AAC3F,qBAAa,4BAA4B;IACxC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAqB;IAC7C,OAAO,CAAC,QAAQ,CAAC,cAAc,CAA6E;IAC5G,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAyC;IAC9D,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,CAA8G;IAC3I,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAuB;IAClD,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAe;IAErC,oHAAoH;IACpH,OAAO,CAAC,QAAQ,CAAC,YAAY,CAA6B;IAC1D,8GAA8G;IAC9G,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAuC;gBAExD,OAAO,EAAE,mCAAmC;IASxD,2EAA2E;IAC3E,OAAO,IAAI,IAAI;IAIf,yGAAyG;IACzG,OAAO,CAAC,SAAS;IAuBjB;;;;OAIG;IACH,OAAO,CAAC,WAAW;IASnB;;;;;;OAMG;IACH,OAAO,CAAC,cAAc;IAetB;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,kBAAkB;CAU1B"}
|
|
@@ -0,0 +1,129 @@
|
|
|
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
|
+
import { buildNotificationV1, bytesToB64url, b64urlToBytes, reactivityTopicId, BlockFillTracker, } from "@optimystic/db-core";
|
|
19
|
+
import { peerIdToBytes } from "../cohort-topic/peer-codec.js";
|
|
20
|
+
import { createLogger } from "../logger.js";
|
|
21
|
+
const log = createLogger("reactivity-origination");
|
|
22
|
+
/** Installs and drives the reactivity origination hook on a {@link CohortTopicService}. */
|
|
23
|
+
export class ReactivityOriginationManager {
|
|
24
|
+
service;
|
|
25
|
+
resolveContext;
|
|
26
|
+
emit;
|
|
27
|
+
markRotated;
|
|
28
|
+
blockFill;
|
|
29
|
+
clock;
|
|
30
|
+
/** Last-seen reactivity tail anchor (base64url of the resolved tail bytes) per collection — the rotation signal. */
|
|
31
|
+
lastSeenTail = new Map();
|
|
32
|
+
/** Per-collection block-fill tracker driving the anticipatory warm-up signal (signal-only on a live node). */
|
|
33
|
+
fillTrackers = new Map();
|
|
34
|
+
constructor(options) {
|
|
35
|
+
this.service = options.service;
|
|
36
|
+
this.resolveContext = options.resolveContext;
|
|
37
|
+
this.emit = options.emit;
|
|
38
|
+
this.markRotated = options.markRotated;
|
|
39
|
+
this.blockFill = options.blockFill;
|
|
40
|
+
this.clock = options.clock ?? (() => Date.now());
|
|
41
|
+
}
|
|
42
|
+
/** Install the origination hook (overwrites any prior `onLocalCommit`). */
|
|
43
|
+
install() {
|
|
44
|
+
this.service.onLocalCommit = (event, commitCert) => this.originate(event, commitCert);
|
|
45
|
+
}
|
|
46
|
+
/** Build + emit the notification for one committed change; isolates throws so commit is never broken. */
|
|
47
|
+
originate(event, commitCert) {
|
|
48
|
+
try {
|
|
49
|
+
const ctx = this.resolveContext(event);
|
|
50
|
+
if (ctx === undefined) {
|
|
51
|
+
return; // not the origination point for this collection (tail-less / non-member)
|
|
52
|
+
}
|
|
53
|
+
// Observe the tail (rotation detection + block-fill warm-up) BEFORE emit, fully isolated so neither
|
|
54
|
+
// ever blocks the notification — the delivery-critical path.
|
|
55
|
+
this.observeTail(event, ctx);
|
|
56
|
+
const notification = buildNotificationV1(event, commitCert, {
|
|
57
|
+
tailId: bytesToB64url(ctx.tailId),
|
|
58
|
+
timestamp: this.clock(),
|
|
59
|
+
deltaMaxBytes: ctx.deltaMaxBytes,
|
|
60
|
+
delta: ctx.delta,
|
|
61
|
+
rotationHint: ctx.rotationHint,
|
|
62
|
+
encodeSigner: (s) => bytesToB64url(peerIdToBytes(s)),
|
|
63
|
+
});
|
|
64
|
+
this.emit(notification);
|
|
65
|
+
}
|
|
66
|
+
catch (err) {
|
|
67
|
+
log("origination failed for collection=%s rev=%d: %o", event.collectionId, event.rev, err);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Track the collection's reactivity tail and drive the rotation + warm-up signals. Isolated so a fault
|
|
72
|
+
* here never blocks the notification emit. Only reached for commits this node originates (a defined `ctx`),
|
|
73
|
+
* so a tail-less (read-driven) commit never records or clears the last-seen tail (the early-return holds).
|
|
74
|
+
*/
|
|
75
|
+
observeTail(event, ctx) {
|
|
76
|
+
try {
|
|
77
|
+
this.trackBlockFill(event);
|
|
78
|
+
this.detectTailRotation(event, ctx);
|
|
79
|
+
}
|
|
80
|
+
catch (err) {
|
|
81
|
+
log("rotation/warm-up observation failed for collection=%s rev=%d (isolated): %o", event.collectionId, event.rev, err);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Feed the per-collection {@link BlockFillTracker} one commit. The `warmup` signal is **best-effort and
|
|
86
|
+
* signal-only** on a live node: the next `tailId` is not knowable (block ids are random until
|
|
87
|
+
* `6.5-block-id-derivation`), so the anticipatory pre-dial bias is logged, never fabricated into a
|
|
88
|
+
* successor coord (`docs/reactivity.md` §Anticipatory warm-up). The `filling` signal cannot pre-announce a
|
|
89
|
+
* hint on a live node for the same reason — it is logged only.
|
|
90
|
+
*/
|
|
91
|
+
trackBlockFill(event) {
|
|
92
|
+
const key = event.collectionId;
|
|
93
|
+
let tracker = this.fillTrackers.get(key);
|
|
94
|
+
if (tracker === undefined) {
|
|
95
|
+
tracker = new BlockFillTracker(this.blockFill);
|
|
96
|
+
this.fillTrackers.set(key, tracker);
|
|
97
|
+
}
|
|
98
|
+
const signal = tracker.onCommit();
|
|
99
|
+
if (signal.kind === "warmup") {
|
|
100
|
+
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);
|
|
101
|
+
}
|
|
102
|
+
else if (signal.kind === "filling") {
|
|
103
|
+
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);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Detect a tail rotation by comparing the resolved tail anchor against the last-seen one for the
|
|
108
|
+
* collection. The first commit records the baseline (no rotation). On a **change**, the previous tail's
|
|
109
|
+
* reactivity topic has rotated to this one: fire {@link markRotated} for the OLD topic so the old cohort's
|
|
110
|
+
* recover serve begins redirecting to the new tree.
|
|
111
|
+
*
|
|
112
|
+
* **Encoding contract.** `ctx.tailId` is the reactivity tail anchor bytes the node resolved
|
|
113
|
+
* (`reactivityTailBytes(event.tailId)` in production — the SAME utf8 encoding origination's membership gate
|
|
114
|
+
* and a subscriber's `reactivityTopicId(reactivityTailBytes(tail))` use, NOT the double-hashing
|
|
115
|
+
* `blockIdToBytes`). So `oldTopicId = reactivityTopicId(oldAnchorBytes)` is byte-identical to the topic a
|
|
116
|
+
* subscriber subscribed under — a mismatch would silently never redirect.
|
|
117
|
+
*/
|
|
118
|
+
detectTailRotation(event, ctx) {
|
|
119
|
+
const key = event.collectionId;
|
|
120
|
+
const newTailB64 = bytesToB64url(ctx.tailId);
|
|
121
|
+
const lastTailB64 = this.lastSeenTail.get(key);
|
|
122
|
+
if (lastTailB64 !== undefined && lastTailB64 !== newTailB64) {
|
|
123
|
+
const oldTopicId = reactivityTopicId(b64urlToBytes(lastTailB64));
|
|
124
|
+
this.markRotated?.(oldTopicId, { newTailId: newTailB64, effectiveAtRevision: event.rev }, this.clock());
|
|
125
|
+
}
|
|
126
|
+
this.lastSeenTail.set(key, newTailB64);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
//# sourceMappingURL=origination-manager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"origination-manager.js","sourceRoot":"","sources":["../../../src/reactivity/origination-manager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EACN,mBAAmB,EACnB,aAAa,EACb,aAAa,EACb,iBAAiB,EACjB,gBAAgB,GAOhB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,MAAM,GA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
|
+
* 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
|
+
/** Base path for the reactivity protocol family. */
|
|
19
|
+
export declare const REACTIVITY_BASE: "/optimystic/reactivity/1.0.0";
|
|
20
|
+
/** `NotificationV1` — change-notification fan-out down the reactivity tree (one-way). */
|
|
21
|
+
export declare const PROTOCOL_REACTIVITY_NOTIFY: "/optimystic/reactivity/1.0.0/notify";
|
|
22
|
+
/** `PushStateGossipV1` — intra-cohort push-state convergence (one-way) [used by reactivity-pushstate-gossip]. */
|
|
23
|
+
export declare const PROTOCOL_REACTIVITY_PUSH_STATE_GOSSIP: "/optimystic/reactivity/1.0.0/push-state-gossip";
|
|
24
|
+
/** `RecoverRequestV1`/`RecoverReplyV1` — backfill/resume recovery RPC (request-reply) [used by reactivity-recover-rpc-transport]. */
|
|
25
|
+
export declare const PROTOCOL_REACTIVITY_RECOVER: "/optimystic/reactivity/1.0.0/recover";
|
|
26
|
+
/** The reactivity protocol IDs in registration order. */
|
|
27
|
+
export interface ReactivityProtocols {
|
|
28
|
+
readonly notify: string;
|
|
29
|
+
readonly pushStateGossip: string;
|
|
30
|
+
readonly recover: string;
|
|
31
|
+
}
|
|
32
|
+
/** Default (network-agnostic) protocol IDs, matching `docs/reactivity.md`. */
|
|
33
|
+
export declare const DEFAULT_REACTIVITY_PROTOCOLS: ReactivityProtocols;
|
|
34
|
+
/**
|
|
35
|
+
* Namespaced reactivity protocol IDs for `networkName` (mirrors FRET's `makeProtocols`, which inserts the
|
|
36
|
+
* network segment even for `"default"` → `/optimystic/default/...`). Note this does NOT equal
|
|
37
|
+
* {@link DEFAULT_REACTIVITY_PROTOCOLS}: the canonical, network-agnostic IDs omit the segment entirely
|
|
38
|
+
* (`/optimystic/reactivity/1.0.0/...`); use those unless you need per-network namespacing.
|
|
39
|
+
*/
|
|
40
|
+
export declare function makeReactivityProtocols(networkName?: string): ReactivityProtocols;
|
|
41
|
+
/** All reactivity protocol IDs as an array (for `node.handle` / `unhandle` over the set). */
|
|
42
|
+
export declare function reactivityProtocolList(p: ReactivityProtocols): string[];
|
|
43
|
+
//# sourceMappingURL=protocols.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protocols.d.ts","sourceRoot":"","sources":["../../../src/reactivity/protocols.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,oDAAoD;AACpD,eAAO,MAAM,eAAe,EAAG,8BAAuC,CAAC;AAEvE,yFAAyF;AACzF,eAAO,MAAM,0BAA0B,uCAAuC,CAAC;AAC/E,iHAAiH;AACjH,eAAO,MAAM,qCAAqC,kDAAkD,CAAC;AACrG,qIAAqI;AACrI,eAAO,MAAM,2BAA2B,wCAAwC,CAAC;AAEjF,yDAAyD;AACzD,MAAM,WAAW,mBAAmB;IACnC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CACzB;AAED,8EAA8E;AAC9E,eAAO,MAAM,4BAA4B,EAAE,mBAI1C,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,WAAW,SAAY,GAAG,mBAAmB,CAOpF;AAED,6FAA6F;AAC7F,wBAAgB,sBAAsB,CAAC,CAAC,EAAE,mBAAmB,GAAG,MAAM,EAAE,CAEvE"}
|
|
@@ -0,0 +1,50 @@
|
|
|
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
|
+
/** Base path for the reactivity protocol family. */
|
|
19
|
+
export const REACTIVITY_BASE = "/optimystic/reactivity/1.0.0";
|
|
20
|
+
/** `NotificationV1` — change-notification fan-out down the reactivity tree (one-way). */
|
|
21
|
+
export const PROTOCOL_REACTIVITY_NOTIFY = `${REACTIVITY_BASE}/notify`;
|
|
22
|
+
/** `PushStateGossipV1` — intra-cohort push-state convergence (one-way) [used by reactivity-pushstate-gossip]. */
|
|
23
|
+
export const PROTOCOL_REACTIVITY_PUSH_STATE_GOSSIP = `${REACTIVITY_BASE}/push-state-gossip`;
|
|
24
|
+
/** `RecoverRequestV1`/`RecoverReplyV1` — backfill/resume recovery RPC (request-reply) [used by reactivity-recover-rpc-transport]. */
|
|
25
|
+
export const PROTOCOL_REACTIVITY_RECOVER = `${REACTIVITY_BASE}/recover`;
|
|
26
|
+
/** Default (network-agnostic) protocol IDs, matching `docs/reactivity.md`. */
|
|
27
|
+
export const DEFAULT_REACTIVITY_PROTOCOLS = {
|
|
28
|
+
notify: PROTOCOL_REACTIVITY_NOTIFY,
|
|
29
|
+
pushStateGossip: PROTOCOL_REACTIVITY_PUSH_STATE_GOSSIP,
|
|
30
|
+
recover: PROTOCOL_REACTIVITY_RECOVER,
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Namespaced reactivity protocol IDs for `networkName` (mirrors FRET's `makeProtocols`, which inserts the
|
|
34
|
+
* network segment even for `"default"` → `/optimystic/default/...`). Note this does NOT equal
|
|
35
|
+
* {@link DEFAULT_REACTIVITY_PROTOCOLS}: the canonical, network-agnostic IDs omit the segment entirely
|
|
36
|
+
* (`/optimystic/reactivity/1.0.0/...`); use those unless you need per-network namespacing.
|
|
37
|
+
*/
|
|
38
|
+
export function makeReactivityProtocols(networkName = "default") {
|
|
39
|
+
const base = `/optimystic/${networkName}/reactivity/1.0.0`;
|
|
40
|
+
return {
|
|
41
|
+
notify: `${base}/notify`,
|
|
42
|
+
pushStateGossip: `${base}/push-state-gossip`,
|
|
43
|
+
recover: `${base}/recover`,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
/** All reactivity protocol IDs as an array (for `node.handle` / `unhandle` over the set). */
|
|
47
|
+
export function reactivityProtocolList(p) {
|
|
48
|
+
return [p.notify, p.pushStateGossip, p.recover];
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=protocols.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protocols.js","sourceRoot":"","sources":["../../../src/reactivity/protocols.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,oDAAoD;AACpD,MAAM,CAAC,MAAM,eAAe,GAAG,8BAAuC,CAAC;AAEvE,yFAAyF;AACzF,MAAM,CAAC,MAAM,0BAA0B,GAAG,GAAG,eAAe,SAAkB,CAAC;AAC/E,iHAAiH;AACjH,MAAM,CAAC,MAAM,qCAAqC,GAAG,GAAG,eAAe,oBAA6B,CAAC;AACrG,qIAAqI;AACrI,MAAM,CAAC,MAAM,2BAA2B,GAAG,GAAG,eAAe,UAAmB,CAAC;AASjF,8EAA8E;AAC9E,MAAM,CAAC,MAAM,4BAA4B,GAAwB;IAChE,MAAM,EAAE,0BAA0B;IAClC,eAAe,EAAE,qCAAqC;IACtD,OAAO,EAAE,2BAA2B;CACpC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,UAAU,uBAAuB,CAAC,WAAW,GAAG,SAAS;IAC9D,MAAM,IAAI,GAAG,eAAe,WAAW,mBAAmB,CAAC;IAC3D,OAAO;QACN,MAAM,EAAE,GAAG,IAAI,SAAS;QACxB,eAAe,EAAE,GAAG,IAAI,oBAAoB;QAC5C,OAAO,EAAE,GAAG,IAAI,UAAU;KAC1B,CAAC;AACH,CAAC;AAED,6FAA6F;AAC7F,MAAM,UAAU,sBAAsB,CAAC,CAAsB;IAC5D,OAAO,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,eAAe,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC;AACjD,CAAC"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reactivity — `PushState` intra-cohort gossip driver (`docs/reactivity.md` §Replay window,
|
|
3
|
+
* §Forwarder-cohort state).
|
|
4
|
+
*
|
|
5
|
+
* The forwarder-cohort replay ring + dedupe window are the substrate that makes the doc's "**any** cohort
|
|
6
|
+
* member — not just the primary — can serve a replay/backfill" property real: a member that missed an
|
|
7
|
+
* origin dial still ends up holding the entry, so a backfill (12.4) survives a primary failover. The
|
|
8
|
+
* db-core {@link PushState} already owns the codec ({@link encodePushStateGossipV1} /
|
|
9
|
+
* {@link decodePushStateGossipV1}, {@link PushState.serializeGossip} / {@link PushState.mergeGossip}); this
|
|
10
|
+
* driver is the **replication** layer that actually broadcasts and merges that state over libp2p on a
|
|
11
|
+
* periodic cadence — the backstop to the live fan-out ({@link import("./forwarder-host.js")}).
|
|
12
|
+
*
|
|
13
|
+
* **Transport reuse.** Rather than stand up a new transport, this rides the cohort gossip transport's
|
|
14
|
+
* {@link import("../cohort-topic/cohort-gossip-transport.js").FretCohortGossipTransport.broadcastOver}
|
|
15
|
+
* seam — the same one the promote-notice broadcast reuses — so the cohort peer resolution, self-exclusion,
|
|
16
|
+
* and per-peer failure swallowing are shared. Frames ride the dedicated
|
|
17
|
+
* {@link PROTOCOL_REACTIVITY_PUSH_STATE_GOSSIP} (one-way), fanned to the FRET-assembled cohort around each
|
|
18
|
+
* served collection's cohort coord. Inbound frames arrive on this node's `push-state-gossip` protocol
|
|
19
|
+
* handler (registered by the node-wiring ticket) and route to {@link ReactivityPushStateGossipDriver.deliver}.
|
|
20
|
+
*
|
|
21
|
+
* **Cadence.** Its own unref'd timer (parallel to the cohort host's single `setInterval`), reusing
|
|
22
|
+
* {@link DEFAULT_GOSSIP_INTERVAL_MS} and the host's re-entrancy / `stopped` / `unref` discipline verbatim.
|
|
23
|
+
* Reactivity collections are not 1:1 with the host's per-`CoordEngine` tick and the forwarder host owns the
|
|
24
|
+
* live {@link PushState} set, so a separate timer is the clean seam now; a future consolidation could fold
|
|
25
|
+
* this into the host tick via a hook, but a separate unref'd timer cannot pin an idle process.
|
|
26
|
+
*
|
|
27
|
+
* The **driver** touches neither the libp2p node assembly nor FRET cohort assembly — it depends only on the
|
|
28
|
+
* `broadcastOver` seam + db-core codec, so it is unit-testable with a fake transport and real `PushState`s.
|
|
29
|
+
* The co-located {@link registerPushStateGossipHandler} (the inbound protocol-handler registration) does
|
|
30
|
+
* bind libp2p, mirroring {@link import("./notify-transport.js").registerNotifyHandler} — the driver class
|
|
31
|
+
* stays pure; only that one helper reaches the node.
|
|
32
|
+
*/
|
|
33
|
+
import { type PushState, type PushStateGossipV1, type RingCoord } from "@optimystic/db-core";
|
|
34
|
+
import type { Libp2p } from "libp2p";
|
|
35
|
+
import type { FretCohortGossipTransport } from "../cohort-topic/cohort-gossip-transport.js";
|
|
36
|
+
/** A live forwarder collection to gossip: its {@link PushState} and the cohort coord to broadcast to. */
|
|
37
|
+
export interface ReactivityGossipCollection {
|
|
38
|
+
readonly pushState: PushState;
|
|
39
|
+
readonly cohortCoord: RingCoord;
|
|
40
|
+
}
|
|
41
|
+
/** A truncation event: a collection's serialized replay ring exceeded the frame bound and was clipped. */
|
|
42
|
+
export interface PushStateGossipTruncation {
|
|
43
|
+
readonly collectionId: string;
|
|
44
|
+
readonly topicId: string;
|
|
45
|
+
/** Most-recent replay entries kept in the broadcast frame. */
|
|
46
|
+
readonly kept: number;
|
|
47
|
+
/** Replay entries the ring actually held this round. */
|
|
48
|
+
readonly total: number;
|
|
49
|
+
/** Bytes of the broadcast (clipped) frame. */
|
|
50
|
+
readonly frameBytes: number;
|
|
51
|
+
/** The configured per-frame ceiling. */
|
|
52
|
+
readonly maxBytes: number;
|
|
53
|
+
}
|
|
54
|
+
/** Construction inputs for a {@link ReactivityPushStateGossipDriver}. */
|
|
55
|
+
export interface ReactivityPushStateGossipDriverDeps {
|
|
56
|
+
/** Reuse the node's cohort gossip transport (`broadcastOver`) — no new transport. */
|
|
57
|
+
readonly gossipTransport: Pick<FretCohortGossipTransport, "broadcastOver">;
|
|
58
|
+
/** The live forwarder collections to gossip each round, with the cohort coord to broadcast to. */
|
|
59
|
+
readonly liveCollections: () => Iterable<ReactivityGossipCollection>;
|
|
60
|
+
/** Resolve the collection owning an inbound frame (by collectionId/topicId) → its {@link PushState}, or undefined. */
|
|
61
|
+
readonly pushStateForGossip: (g: PushStateGossipV1) => PushState | undefined;
|
|
62
|
+
/** Inbound authenticity gate: is `fromPeerId` a member of the cohort for the frame's coord? Absent ⇒ accept all. */
|
|
63
|
+
readonly isCohortMember?: (fromPeerId: string, g: PushStateGossipV1) => boolean;
|
|
64
|
+
/** Cadence interval. Default {@link DEFAULT_GOSSIP_INTERVAL_MS}. */
|
|
65
|
+
readonly intervalMs?: number;
|
|
66
|
+
/** Per-frame ceiling (frame, including the length prefix, stays within this). Default {@link DEFAULT_STREAM_MAX_BYTES}. */
|
|
67
|
+
readonly maxBytes?: number;
|
|
68
|
+
/** Reserved for parity with the cohort host's tick discipline; unused today (gossip carries its own `receivedAt`). */
|
|
69
|
+
readonly clock?: () => number;
|
|
70
|
+
/** Observe a clipped (over-bound) frame, in addition to the "no silent cap" log. Test/diagnostic seam. */
|
|
71
|
+
readonly onTruncate?: (info: PushStateGossipTruncation) => void;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Drives {@link PushState} convergence across a forwarder cohort: each round it broadcasts every live
|
|
75
|
+
* collection's serialized push-state to the cohort (clipped to the frame bound), and each inbound frame is
|
|
76
|
+
* gated, resolved to the owning collection, and merged. Build one per node and bind its inbound
|
|
77
|
+
* {@link ReactivityPushStateGossipDriver.deliver} to the `push-state-gossip` protocol handler.
|
|
78
|
+
*/
|
|
79
|
+
export declare class ReactivityPushStateGossipDriver {
|
|
80
|
+
private readonly gossipTransport;
|
|
81
|
+
private readonly liveCollections;
|
|
82
|
+
private readonly pushStateForGossip;
|
|
83
|
+
private readonly isCohortMember?;
|
|
84
|
+
private readonly intervalMs;
|
|
85
|
+
private readonly maxBytes;
|
|
86
|
+
private readonly onTruncate?;
|
|
87
|
+
private timer?;
|
|
88
|
+
private stopped;
|
|
89
|
+
/** Re-entrancy guard mirroring the host tick: skip a round that overlaps a slow prior one. */
|
|
90
|
+
private rounding;
|
|
91
|
+
constructor(deps: ReactivityPushStateGossipDriverDeps);
|
|
92
|
+
/** Begin the unref'd cadence timer. Idempotent; a no-op once {@link stop} has run. */
|
|
93
|
+
start(): void;
|
|
94
|
+
/**
|
|
95
|
+
* One round: broadcast each live collection's serialized {@link PushState} to its cohort, clipped to the
|
|
96
|
+
* frame bound. Per-collection isolated (one collection's fault never skips the rest) and `stopped`-gated
|
|
97
|
+
* mid-loop, mirroring the host tick.
|
|
98
|
+
*/
|
|
99
|
+
round(): void;
|
|
100
|
+
/**
|
|
101
|
+
* Inbound handler body: decode → membership gate → resolve owning collection → merge. Never throws on a
|
|
102
|
+
* bad frame (a malformed/forged/foreign frame is logged and dropped), so a stream handler can call it
|
|
103
|
+
* directly. `mergeGossip` independently guards a collection/topic mismatch, so the resolve step is a fast
|
|
104
|
+
* pre-filter, not the only line of defense.
|
|
105
|
+
*/
|
|
106
|
+
deliver(fromPeerId: string, frame: Uint8Array): void;
|
|
107
|
+
/** Stop the cadence: short-circuit any in-flight/future round and clear the timer. */
|
|
108
|
+
stop(): void;
|
|
109
|
+
/** Serialize one collection, clip to the frame bound, and broadcast to its cohort. */
|
|
110
|
+
private broadcastOne;
|
|
111
|
+
/**
|
|
112
|
+
* Build the broadcast frame for one serialized push-state, kept within {@link maxBytes}.
|
|
113
|
+
*
|
|
114
|
+
* The whole replay ring (`W` up to 256 full `NotificationV1`s) can exceed the frame bound. When it does,
|
|
115
|
+
* keep the full (small) dedupe window and the **most-recent-N** replay entries that fit — sliced from the
|
|
116
|
+
* high-revision end, since a lagging subscriber backfills the newest gap first and older revisions roll
|
|
117
|
+
* to the parent checkpoint anyway. Frame size is monotone in the entry count, so binary-search the
|
|
118
|
+
* high-water N rather than re-encoding per entry.
|
|
119
|
+
*/
|
|
120
|
+
private boundedFrame;
|
|
121
|
+
/** Encode `g` with only its most-recent `keep` replay entries retained (the full dedupe window is kept). */
|
|
122
|
+
private encodeSlice;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Register the inbound push-state-gossip protocol handler: read one bounded frame and hand it to
|
|
126
|
+
* {@link ReactivityPushStateGossipDriver.deliver} (which decodes, membership-gates, and merges), then close.
|
|
127
|
+
* One-way — no reply frame, matching the cohort-topic gossip handlers. A read error aborts the stream and
|
|
128
|
+
* {@link ReactivityPushStateGossipDriver.deliver} swallows a decode/forge/foreign failure, so the handler
|
|
129
|
+
* never throws on the stream. Mirrors {@link import("./notify-transport.js").registerNotifyHandler}.
|
|
130
|
+
*/
|
|
131
|
+
export declare function registerPushStateGossipHandler(node: Libp2p, protocol: string, driver: Pick<ReactivityPushStateGossipDriver, "deliver">, maxBytes?: number): void;
|
|
132
|
+
//# sourceMappingURL=push-state-gossip.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"push-state-gossip.d.ts","sourceRoot":"","sources":["../../../src/reactivity/push-state-gossip.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,OAAO,EAGN,KAAK,SAAS,EACd,KAAK,iBAAiB,EACtB,KAAK,SAAS,EACd,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGrC,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,4CAA4C,CAAC;AAW5F,yGAAyG;AACzG,MAAM,WAAW,0BAA0B;IAC1C,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAC9B,QAAQ,CAAC,WAAW,EAAE,SAAS,CAAC;CAChC;AAED,0GAA0G;AAC1G,MAAM,WAAW,yBAAyB;IACzC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,8DAA8D;IAC9D,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,wDAAwD;IACxD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,8CAA8C;IAC9C,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,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