@moltzap/client 2026.811.0 → 2026.902.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/LICENSE +202 -21
- package/NOTICE +19 -0
- package/README.md +50 -0
- package/bin/moltzapd +9 -0
- package/dist/client-runtime.d.ts +10 -0
- package/dist/client-runtime.d.ts.map +1 -0
- package/dist/client-runtime.js +218 -0
- package/dist/client-runtime.js.map +1 -0
- package/dist/contract.d.ts +338 -0
- package/dist/contract.d.ts.map +1 -0
- package/dist/contract.js +213 -0
- package/dist/contract.js.map +1 -0
- package/dist/contract.types-check.d.ts +99 -0
- package/dist/contract.types-check.d.ts.map +1 -0
- package/dist/contract.types-check.js +7 -0
- package/dist/contract.types-check.js.map +1 -0
- package/dist/daemon/configuration.d.ts +46 -0
- package/dist/daemon/configuration.d.ts.map +1 -0
- package/dist/daemon/configuration.js +69 -0
- package/dist/daemon/configuration.js.map +1 -0
- package/dist/daemon/management.d.ts +23 -0
- package/dist/daemon/management.d.ts.map +1 -0
- package/dist/daemon/management.js +489 -0
- package/dist/daemon/management.js.map +1 -0
- package/dist/daemon/registration.d.ts +72 -0
- package/dist/daemon/registration.d.ts.map +1 -0
- package/dist/daemon/registration.js +109 -0
- package/dist/daemon/registration.js.map +1 -0
- package/dist/daemon/runtime/activation.d.ts +95 -0
- package/dist/daemon/runtime/activation.d.ts.map +1 -0
- package/dist/daemon/runtime/activation.js +99 -0
- package/dist/daemon/runtime/activation.js.map +1 -0
- package/dist/daemon/runtime/controller.d.ts +34 -0
- package/dist/daemon/runtime/controller.d.ts.map +1 -0
- package/dist/daemon/runtime/controller.js +106 -0
- package/dist/daemon/runtime/controller.js.map +1 -0
- package/dist/daemon/runtime/history-export.d.ts +23 -0
- package/dist/daemon/runtime/history-export.d.ts.map +1 -0
- package/dist/daemon/runtime/history-export.js +47 -0
- package/dist/daemon/runtime/history-export.js.map +1 -0
- package/dist/daemon/runtime/index.d.ts +24 -0
- package/dist/daemon/runtime/index.d.ts.map +1 -0
- package/dist/daemon/runtime/index.js +65 -0
- package/dist/daemon/runtime/index.js.map +1 -0
- package/dist/daemon/runtime/protocol.d.ts +63 -0
- package/dist/daemon/runtime/protocol.d.ts.map +1 -0
- package/dist/daemon/runtime/protocol.js +133 -0
- package/dist/daemon/runtime/protocol.js.map +1 -0
- package/dist/endpoint/addressing/index.d.ts +39 -0
- package/dist/endpoint/addressing/index.d.ts.map +1 -0
- package/dist/endpoint/addressing/index.js +114 -0
- package/dist/endpoint/addressing/index.js.map +1 -0
- package/dist/endpoint/engine-dissemination.d.ts +11 -0
- package/dist/endpoint/engine-dissemination.d.ts.map +1 -0
- package/dist/endpoint/engine-dissemination.js +71 -0
- package/dist/endpoint/engine-dissemination.js.map +1 -0
- package/dist/endpoint/engine-durability.d.ts +69 -0
- package/dist/endpoint/engine-durability.d.ts.map +1 -0
- package/dist/endpoint/engine-durability.js +210 -0
- package/dist/endpoint/engine-durability.js.map +1 -0
- package/dist/endpoint/engine-send.d.ts +50 -0
- package/dist/endpoint/engine-send.d.ts.map +1 -0
- package/dist/endpoint/engine-send.js +422 -0
- package/dist/endpoint/engine-send.js.map +1 -0
- package/dist/endpoint/engine-types.d.ts +132 -0
- package/dist/endpoint/engine-types.d.ts.map +1 -0
- package/dist/endpoint/engine-types.js +13 -0
- package/dist/endpoint/engine-types.js.map +1 -0
- package/dist/endpoint/engine.d.ts +14 -0
- package/dist/endpoint/engine.d.ts.map +1 -0
- package/dist/endpoint/engine.js +280 -0
- package/dist/endpoint/engine.js.map +1 -0
- package/dist/endpoint/protocol/evidence.d.ts +37 -0
- package/dist/endpoint/protocol/evidence.d.ts.map +1 -0
- package/dist/endpoint/protocol/evidence.js +80 -0
- package/dist/endpoint/protocol/evidence.js.map +1 -0
- package/dist/endpoint/protocol/index.d.ts +26 -0
- package/dist/endpoint/protocol/index.d.ts.map +1 -0
- package/dist/endpoint/protocol/index.js +543 -0
- package/dist/endpoint/protocol/index.js.map +1 -0
- package/dist/endpoint/recovery/barrier.d.ts +23 -0
- package/dist/endpoint/recovery/barrier.d.ts.map +1 -0
- package/dist/endpoint/recovery/barrier.js +47 -0
- package/dist/endpoint/recovery/barrier.js.map +1 -0
- package/dist/endpoint/recovery/index.d.ts +29 -0
- package/dist/endpoint/recovery/index.d.ts.map +1 -0
- package/dist/endpoint/recovery/index.js +489 -0
- package/dist/endpoint/recovery/index.js.map +1 -0
- package/dist/endpoint/recovery/reanchor/empty.d.ts +22 -0
- package/dist/endpoint/recovery/reanchor/empty.d.ts.map +1 -0
- package/dist/endpoint/recovery/reanchor/empty.js +163 -0
- package/dist/endpoint/recovery/reanchor/empty.js.map +1 -0
- package/dist/endpoint/recovery/reanchor/index.d.ts +30 -0
- package/dist/endpoint/recovery/reanchor/index.d.ts.map +1 -0
- package/dist/endpoint/recovery/reanchor/index.js +479 -0
- package/dist/endpoint/recovery/reanchor/index.js.map +1 -0
- package/dist/endpoint/recovery/state.d.ts +130 -0
- package/dist/endpoint/recovery/state.d.ts.map +1 -0
- package/dist/endpoint/recovery/state.js +296 -0
- package/dist/endpoint/recovery/state.js.map +1 -0
- package/dist/endpoint/recovery/store-evidence.d.ts +17 -0
- package/dist/endpoint/recovery/store-evidence.d.ts.map +1 -0
- package/dist/endpoint/recovery/store-evidence.js +79 -0
- package/dist/endpoint/recovery/store-evidence.js.map +1 -0
- package/dist/endpoint/recovery/store.d.ts +56 -0
- package/dist/endpoint/recovery/store.d.ts.map +1 -0
- package/dist/endpoint/recovery/store.js +499 -0
- package/dist/endpoint/recovery/store.js.map +1 -0
- package/dist/endpoint/representation-canonical.d.ts +17 -0
- package/dist/endpoint/representation-canonical.d.ts.map +1 -0
- package/dist/endpoint/representation-canonical.js +48 -0
- package/dist/endpoint/representation-canonical.js.map +1 -0
- package/dist/endpoint/representation-codec.d.ts +51 -0
- package/dist/endpoint/representation-codec.d.ts.map +1 -0
- package/dist/endpoint/representation-codec.js +159 -0
- package/dist/endpoint/representation-codec.js.map +1 -0
- package/dist/endpoint/representation-schemas.d.ts +1831 -0
- package/dist/endpoint/representation-schemas.d.ts.map +1 -0
- package/dist/endpoint/representation-schemas.js +195 -0
- package/dist/endpoint/representation-schemas.js.map +1 -0
- package/dist/endpoint/representation-verification.d.ts +79 -0
- package/dist/endpoint/representation-verification.d.ts.map +1 -0
- package/dist/endpoint/representation-verification.js +420 -0
- package/dist/endpoint/representation-verification.js.map +1 -0
- package/dist/endpoint/representation.d.ts +6 -0
- package/dist/endpoint/representation.d.ts.map +1 -0
- package/dist/endpoint/representation.js +8 -0
- package/dist/endpoint/representation.js.map +1 -0
- package/dist/endpoint/router-worker/index.d.ts +16 -0
- package/dist/endpoint/router-worker/index.d.ts.map +1 -0
- package/dist/endpoint/router-worker/index.js +547 -0
- package/dist/endpoint/router-worker/index.js.map +1 -0
- package/dist/endpoint/router-worker/types.d.ts +183 -0
- package/dist/endpoint/router-worker/types.d.ts.map +1 -0
- package/dist/endpoint/router-worker/types.js +31 -0
- package/dist/endpoint/router-worker/types.js.map +1 -0
- package/dist/endpoint/store/anchors.d.ts +83 -0
- package/dist/endpoint/store/anchors.d.ts.map +1 -0
- package/dist/endpoint/store/anchors.js +471 -0
- package/dist/endpoint/store/anchors.js.map +1 -0
- package/dist/endpoint/store/database/index.d.ts +6 -0
- package/dist/endpoint/store/database/index.d.ts.map +1 -0
- package/dist/endpoint/store/database/index.js +6 -0
- package/dist/endpoint/store/database/index.js.map +1 -0
- package/dist/endpoint/store/database/schema.d.ts +44 -0
- package/dist/endpoint/store/database/schema.d.ts.map +1 -0
- package/dist/endpoint/store/database/schema.js +345 -0
- package/dist/endpoint/store/database/schema.js.map +1 -0
- package/dist/endpoint/store/database/values.d.ts +119 -0
- package/dist/endpoint/store/database/values.d.ts.map +1 -0
- package/dist/endpoint/store/database/values.js +194 -0
- package/dist/endpoint/store/database/values.js.map +1 -0
- package/dist/endpoint/store/deliveries.d.ts +38 -0
- package/dist/endpoint/store/deliveries.d.ts.map +1 -0
- package/dist/endpoint/store/deliveries.js +124 -0
- package/dist/endpoint/store/deliveries.js.map +1 -0
- package/dist/endpoint/store/dissemination.d.ts +27 -0
- package/dist/endpoint/store/dissemination.d.ts.map +1 -0
- package/dist/endpoint/store/dissemination.js +139 -0
- package/dist/endpoint/store/dissemination.js.map +1 -0
- package/dist/endpoint/store/index.d.ts +15 -0
- package/dist/endpoint/store/index.d.ts.map +1 -0
- package/dist/endpoint/store/index.js +76 -0
- package/dist/endpoint/store/index.js.map +1 -0
- package/dist/endpoint/store/management.d.ts +42 -0
- package/dist/endpoint/store/management.d.ts.map +1 -0
- package/dist/endpoint/store/management.js +259 -0
- package/dist/endpoint/store/management.js.map +1 -0
- package/dist/endpoint/store/outbound.d.ts +62 -0
- package/dist/endpoint/store/outbound.d.ts.map +1 -0
- package/dist/endpoint/store/outbound.js +278 -0
- package/dist/endpoint/store/outbound.js.map +1 -0
- package/dist/endpoint/store/records.d.ts +56 -0
- package/dist/endpoint/store/records.d.ts.map +1 -0
- package/dist/endpoint/store/records.js +352 -0
- package/dist/endpoint/store/records.js.map +1 -0
- package/dist/endpoint/store/rows/index.d.ts +138 -0
- package/dist/endpoint/store/rows/index.d.ts.map +1 -0
- package/dist/endpoint/store/rows/index.js +307 -0
- package/dist/endpoint/store/rows/index.js.map +1 -0
- package/dist/endpoint/store/types.d.ts +223 -0
- package/dist/endpoint/store/types.d.ts.map +1 -0
- package/dist/endpoint/store/types.js +15 -0
- package/dist/endpoint/store/types.js.map +1 -0
- package/dist/endpoint/store.d.ts +10 -0
- package/dist/endpoint/store.d.ts.map +1 -0
- package/dist/endpoint/store.js +6 -0
- package/dist/endpoint/store.js.map +1 -0
- package/dist/harness-mcp-contract.d.ts +101 -0
- package/dist/harness-mcp-contract.d.ts.map +1 -0
- package/dist/harness-mcp-contract.js +61 -0
- package/dist/harness-mcp-contract.js.map +1 -0
- package/dist/harness-mcp-http.d.ts +19 -0
- package/dist/harness-mcp-http.d.ts.map +1 -0
- package/dist/{harness-mcp-server.js → harness-mcp-http.js} +43 -71
- package/dist/harness-mcp-http.js.map +1 -0
- package/dist/harness-mcp-subscription.d.ts +12 -7
- package/dist/harness-mcp-subscription.d.ts.map +1 -1
- package/dist/harness-mcp-subscription.js +113 -100
- package/dist/harness-mcp-subscription.js.map +1 -1
- package/dist/harness-mcp-wire.d.ts +26 -19
- package/dist/harness-mcp-wire.d.ts.map +1 -1
- package/dist/harness-mcp-wire.js +380 -67
- package/dist/harness-mcp-wire.js.map +1 -1
- package/dist/index.d.ts +4 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -8
- package/dist/index.js.map +1 -1
- package/dist/management-runtime.d.ts +217 -0
- package/dist/management-runtime.d.ts.map +1 -0
- package/dist/management-runtime.js +127 -0
- package/dist/management-runtime.js.map +1 -0
- package/dist/server.d.ts +16 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +46 -0
- package/dist/server.js.map +1 -0
- package/dist/server.types-check.d.ts +23 -0
- package/dist/server.types-check.d.ts.map +1 -0
- package/dist/server.types-check.js +7 -0
- package/dist/server.types-check.js.map +1 -0
- package/package.json +45 -47
- package/dist/agent-client.d.ts +0 -5
- package/dist/agent-client.d.ts.map +0 -1
- package/dist/agent-client.js +0 -3
- package/dist/agent-client.js.map +0 -1
- package/dist/auth.d.ts +0 -37
- package/dist/auth.d.ts.map +0 -1
- package/dist/auth.js +0 -79
- package/dist/auth.js.map +0 -1
- package/dist/bounded-map.d.ts +0 -32
- package/dist/bounded-map.d.ts.map +0 -1
- package/dist/bounded-map.js +0 -79
- package/dist/bounded-map.js.map +0 -1
- package/dist/channel-base/format-cross-conv.d.ts +0 -43
- package/dist/channel-base/format-cross-conv.d.ts.map +0 -1
- package/dist/channel-base/format-cross-conv.js +0 -65
- package/dist/channel-base/format-cross-conv.js.map +0 -1
- package/dist/channel-base/format-group-block.d.ts +0 -48
- package/dist/channel-base/format-group-block.d.ts.map +0 -1
- package/dist/channel-base/format-group-block.js +0 -62
- package/dist/channel-base/format-group-block.js.map +0 -1
- package/dist/channel-base/index.d.ts +0 -12
- package/dist/channel-base/index.d.ts.map +0 -1
- package/dist/channel-base/index.js +0 -13
- package/dist/channel-base/index.js.map +0 -1
- package/dist/channel-core-enrichment.d.ts +0 -14
- package/dist/channel-core-enrichment.d.ts.map +0 -1
- package/dist/channel-core-enrichment.js +0 -143
- package/dist/channel-core-enrichment.js.map +0 -1
- package/dist/channel-core-test-support.d.ts +0 -75
- package/dist/channel-core-test-support.d.ts.map +0 -1
- package/dist/channel-core-test-support.js +0 -74
- package/dist/channel-core-test-support.js.map +0 -1
- package/dist/channel-core.d.ts +0 -304
- package/dist/channel-core.d.ts.map +0 -1
- package/dist/channel-core.js +0 -363
- package/dist/channel-core.js.map +0 -1
- package/dist/cli/adapters.d.ts +0 -21
- package/dist/cli/adapters.d.ts.map +0 -1
- package/dist/cli/adapters.js +0 -111
- package/dist/cli/adapters.js.map +0 -1
- package/dist/cli/commands/agents.d.ts +0 -11
- package/dist/cli/commands/agents.d.ts.map +0 -1
- package/dist/cli/commands/agents.js +0 -27
- package/dist/cli/commands/agents.js.map +0 -1
- package/dist/cli/commands/conversations.d.ts +0 -18
- package/dist/cli/commands/conversations.d.ts.map +0 -1
- package/dist/cli/commands/conversations.js +0 -33
- package/dist/cli/commands/conversations.js.map +0 -1
- package/dist/cli/commands/messages.d.ts +0 -41
- package/dist/cli/commands/messages.d.ts.map +0 -1
- package/dist/cli/commands/messages.js +0 -39
- package/dist/cli/commands/messages.js.map +0 -1
- package/dist/cli/commands/register.d.ts +0 -46
- package/dist/cli/commands/register.d.ts.map +0 -1
- package/dist/cli/commands/register.js +0 -103
- package/dist/cli/commands/register.js.map +0 -1
- package/dist/cli/commands/send.d.ts +0 -53
- package/dist/cli/commands/send.d.ts.map +0 -1
- package/dist/cli/commands/send.js +0 -57
- package/dist/cli/commands/send.js.map +0 -1
- package/dist/cli/commands/start.d.ts +0 -34
- package/dist/cli/commands/start.d.ts.map +0 -1
- package/dist/cli/commands/start.js +0 -59
- package/dist/cli/commands/start.js.map +0 -1
- package/dist/cli/commands/status.d.ts +0 -7
- package/dist/cli/commands/status.d.ts.map +0 -1
- package/dist/cli/commands/status.js +0 -16
- package/dist/cli/commands/status.js.map +0 -1
- package/dist/cli/commands/test-transport.d.ts +0 -28
- package/dist/cli/commands/test-transport.d.ts.map +0 -1
- package/dist/cli/commands/test-transport.js +0 -40
- package/dist/cli/commands/test-transport.js.map +0 -1
- package/dist/cli/index.d.ts +0 -3
- package/dist/cli/index.d.ts.map +0 -1
- package/dist/cli/index.js +0 -105
- package/dist/cli/index.js.map +0 -1
- package/dist/cli/output.d.ts +0 -14
- package/dist/cli/output.d.ts.map +0 -1
- package/dist/cli/output.js +0 -19
- package/dist/cli/output.js.map +0 -1
- package/dist/cli/socket-client.d.ts +0 -28
- package/dist/cli/socket-client.d.ts.map +0 -1
- package/dist/cli/socket-client.js +0 -63
- package/dist/cli/socket-client.js.map +0 -1
- package/dist/cli/transport.d.ts +0 -132
- package/dist/cli/transport.d.ts.map +0 -1
- package/dist/cli/transport.js +0 -127
- package/dist/cli/transport.js.map +0 -1
- package/dist/config.d.ts +0 -33
- package/dist/config.d.ts.map +0 -1
- package/dist/config.js +0 -45
- package/dist/config.js.map +0 -1
- package/dist/config.test-utils.d.ts +0 -18
- package/dist/config.test-utils.d.ts.map +0 -1
- package/dist/config.test-utils.js +0 -53
- package/dist/config.test-utils.js.map +0 -1
- package/dist/harness/client-runtime.d.ts +0 -24
- package/dist/harness/client-runtime.d.ts.map +0 -1
- package/dist/harness/client-runtime.js +0 -107
- package/dist/harness/client-runtime.js.map +0 -1
- package/dist/harness/index.d.ts +0 -5
- package/dist/harness/index.d.ts.map +0 -1
- package/dist/harness/index.js +0 -5
- package/dist/harness/index.js.map +0 -1
- package/dist/harness/runtime.d.ts +0 -149
- package/dist/harness/runtime.d.ts.map +0 -1
- package/dist/harness/runtime.js +0 -68
- package/dist/harness/runtime.js.map +0 -1
- package/dist/harness-client.d.ts +0 -43
- package/dist/harness-client.d.ts.map +0 -1
- package/dist/harness-client.js +0 -21
- package/dist/harness-client.js.map +0 -1
- package/dist/harness-mcp-server.d.ts +0 -19
- package/dist/harness-mcp-server.d.ts.map +0 -1
- package/dist/harness-mcp-server.js.map +0 -1
- package/dist/local-daemon-rpc.d.ts +0 -1170
- package/dist/local-daemon-rpc.d.ts.map +0 -1
- package/dist/local-daemon-rpc.js +0 -178
- package/dist/local-daemon-rpc.js.map +0 -1
- package/dist/local-history.d.ts +0 -75
- package/dist/local-history.d.ts.map +0 -1
- package/dist/local-history.js +0 -82
- package/dist/local-history.js.map +0 -1
- package/dist/local-paths.d.ts +0 -22
- package/dist/local-paths.d.ts.map +0 -1
- package/dist/local-paths.js +0 -33
- package/dist/local-paths.js.map +0 -1
- package/dist/local-socket-server.d.ts +0 -33
- package/dist/local-socket-server.d.ts.map +0 -1
- package/dist/local-socket-server.js +0 -100
- package/dist/local-socket-server.js.map +0 -1
- package/dist/message-rendering.d.ts +0 -4
- package/dist/message-rendering.d.ts.map +0 -1
- package/dist/message-rendering.js +0 -8
- package/dist/message-rendering.js.map +0 -1
- package/dist/moltzapd.d.ts +0 -38
- package/dist/moltzapd.d.ts.map +0 -1
- package/dist/moltzapd.js +0 -78
- package/dist/moltzapd.js.map +0 -1
- package/dist/notification/__tests__/subscribe-signatures.types-check.d.ts +0 -53
- package/dist/notification/__tests__/subscribe-signatures.types-check.d.ts.map +0 -1
- package/dist/notification/__tests__/subscribe-signatures.types-check.js +0 -29
- package/dist/notification/__tests__/subscribe-signatures.types-check.js.map +0 -1
- package/dist/notification/errors.d.ts +0 -41
- package/dist/notification/errors.d.ts.map +0 -1
- package/dist/notification/errors.js +0 -24
- package/dist/notification/errors.js.map +0 -1
- package/dist/notification/index.d.ts +0 -6
- package/dist/notification/index.d.ts.map +0 -1
- package/dist/notification/index.js +0 -6
- package/dist/notification/index.js.map +0 -1
- package/dist/notification/stream.d.ts +0 -75
- package/dist/notification/stream.d.ts.map +0 -1
- package/dist/notification/stream.js +0 -30
- package/dist/notification/stream.js.map +0 -1
- package/dist/pagination.d.ts +0 -52
- package/dist/pagination.d.ts.map +0 -1
- package/dist/pagination.js +0 -51
- package/dist/pagination.js.map +0 -1
- package/dist/profile.d.ts +0 -104
- package/dist/profile.d.ts.map +0 -1
- package/dist/profile.js +0 -163
- package/dist/profile.js.map +0 -1
- package/dist/refs.d.ts +0 -18
- package/dist/refs.d.ts.map +0 -1
- package/dist/refs.js +0 -18
- package/dist/refs.js.map +0 -1
- package/dist/service-event-trace.d.ts +0 -15
- package/dist/service-event-trace.d.ts.map +0 -1
- package/dist/service-event-trace.js +0 -35
- package/dist/service-event-trace.js.map +0 -1
- package/dist/service-helpers.d.ts +0 -55
- package/dist/service-helpers.d.ts.map +0 -1
- package/dist/service-helpers.js +0 -108
- package/dist/service-helpers.js.map +0 -1
- package/dist/service-local-daemon.d.ts +0 -32
- package/dist/service-local-daemon.d.ts.map +0 -1
- package/dist/service-local-daemon.js +0 -153
- package/dist/service-local-daemon.js.map +0 -1
- package/dist/service.d.ts +0 -299
- package/dist/service.d.ts.map +0 -1
- package/dist/service.js +0 -789
- package/dist/service.js.map +0 -1
- package/dist/test-utils/channel-service-fixture.d.ts +0 -53
- package/dist/test-utils/channel-service-fixture.d.ts.map +0 -1
- package/dist/test-utils/channel-service-fixture.js +0 -178
- package/dist/test-utils/channel-service-fixture.js.map +0 -1
- package/dist/test-utils/fake-service.d.ts +0 -84
- package/dist/test-utils/fake-service.d.ts.map +0 -1
- package/dist/test-utils/fake-service.js +0 -108
- package/dist/test-utils/fake-service.js.map +0 -1
- package/dist/test-utils/harness.d.ts +0 -27
- package/dist/test-utils/harness.d.ts.map +0 -1
- package/dist/test-utils/harness.js +0 -33
- package/dist/test-utils/harness.js.map +0 -1
- package/dist/test-utils/ids.d.ts +0 -21
- package/dist/test-utils/ids.d.ts.map +0 -1
- package/dist/test-utils/ids.js +0 -68
- package/dist/test-utils/ids.js.map +0 -1
- package/dist/test-utils/index.d.ts +0 -54
- package/dist/test-utils/index.d.ts.map +0 -1
- package/dist/test-utils/index.js +0 -65
- package/dist/test-utils/index.js.map +0 -1
- package/dist/test-utils/standalone-provisioning.d.ts +0 -22
- package/dist/test-utils/standalone-provisioning.d.ts.map +0 -1
- package/dist/test-utils/standalone-provisioning.js +0 -17
- package/dist/test-utils/standalone-provisioning.js.map +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/** @file Shared volatile state for catch-up and Router re-anchor runs. */
|
|
2
|
+
import { type AgentId, type SignedMessage as SignedMessageValue } from "@moltzap/identity";
|
|
3
|
+
import { Deferred, Effect, Queue } from "effect";
|
|
4
|
+
import type { EngineRuntime } from "../engine-types.js";
|
|
5
|
+
import type { EndpointRecovery } from "../store.js";
|
|
6
|
+
import { type AnchorHash as AnchorHashValue, type CatchUpRequest as CatchUpRequestValue, type ConversationId as ConversationIdValue, type DirectPacket, type ReanchorVoteStatement as ReanchorVoteStatementValue, type RecordHash as RecordHashValue, type VerifiedMembership } from "../representation.js";
|
|
7
|
+
import { RouterWorkerPersistenceError, type RouterWorkerRecovery, RouterWorkerRecoveryError, type RouterWorkerRecoverySend } from "../router-worker/index.js";
|
|
8
|
+
/** Mutable state scoped to one authenticated catch-up and re-anchor run. */
|
|
9
|
+
export interface ActiveRecoveryState {
|
|
10
|
+
readonly recovery: RouterWorkerRecovery;
|
|
11
|
+
readonly outbound: Queue.Queue<RouterWorkerRecoverySend>;
|
|
12
|
+
readonly completion: Deferred.Deferred<undefined, RouterWorkerRecoveryError>;
|
|
13
|
+
readonly memberships: Map<ConversationIdValue, VerifiedMembership>;
|
|
14
|
+
readonly pendingRequests: Map<ConversationIdValue, CatchUpRequestValue>;
|
|
15
|
+
readonly incompleteResponders: Map<ConversationIdValue, Set<AgentId>>;
|
|
16
|
+
readonly acceptedSuccessors: Map<string, RecordHashValue | AnchorHashValue>;
|
|
17
|
+
readonly observedHeads: Map<ConversationIdValue, Set<RecordHashValue>>;
|
|
18
|
+
readonly pendingVotes: Map<ConversationIdValue, Map<AnchorHashValue, Map<AgentId, PendingReanchorVote>>>;
|
|
19
|
+
readonly positionsReady: Set<ConversationIdValue>;
|
|
20
|
+
readonly completedConversations: Set<ConversationIdValue>;
|
|
21
|
+
pendingOutbound: number;
|
|
22
|
+
}
|
|
23
|
+
/** One verified re-anchor vote retained until its ancestry is resolved. */
|
|
24
|
+
export interface PendingReanchorVote {
|
|
25
|
+
readonly message: SignedMessageValue;
|
|
26
|
+
readonly statement: ReanchorVoteStatementValue;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Resolve the latest durable position for one fixed conversation.
|
|
30
|
+
* @param runtime Engine whose endpoint store owns the conversation.
|
|
31
|
+
* @param conversationId Private conversation identity to locate.
|
|
32
|
+
* @returns The complete recovery snapshot and its matching position row.
|
|
33
|
+
*/
|
|
34
|
+
export declare const durablePosition: (runtime: EngineRuntime, conversationId: ConversationIdValue) => Effect.Effect<{
|
|
35
|
+
recovery: EndpointRecovery;
|
|
36
|
+
position: import("../store.js").ConversationPosition | undefined;
|
|
37
|
+
}, RouterWorkerPersistenceError, never>;
|
|
38
|
+
/**
|
|
39
|
+
* Queue a signed catch-up request at the engine's current durable position.
|
|
40
|
+
* @param runtime Engine participating in active recovery.
|
|
41
|
+
* @param conversationId Private conversation identity to reconcile.
|
|
42
|
+
* @returns Completion after the request is stored in the recovery queue.
|
|
43
|
+
*/
|
|
44
|
+
export declare const requestCertifiedHistory: (runtime: EngineRuntime, conversationId: ConversationIdValue) => Effect.Effect<void, RouterWorkerPersistenceError>;
|
|
45
|
+
/**
|
|
46
|
+
* Queue one signed recovery packet for all fixed members.
|
|
47
|
+
* @param runtime Engine whose recovery queue owns the packet.
|
|
48
|
+
* @param membership Verified fixed membership for the outer envelope.
|
|
49
|
+
* @param packet Closed recovery packet to route.
|
|
50
|
+
* @returns Completion after the outer envelope enters the durable queue.
|
|
51
|
+
*/
|
|
52
|
+
export declare function queueRecoveryPacket(runtime: EngineRuntime, membership: VerifiedMembership, packet: DirectPacket): Effect.Effect<void, RouterWorkerPersistenceError>;
|
|
53
|
+
/**
|
|
54
|
+
* Queue one stable inner evidence message for all fixed members.
|
|
55
|
+
* @param runtime Engine whose recovery queue owns the evidence.
|
|
56
|
+
* @param membership Verified fixed membership for the outer envelope.
|
|
57
|
+
* @param evidence Stable self-addressed evidence to relay.
|
|
58
|
+
* @returns Completion after the outer envelope enters the durable queue.
|
|
59
|
+
*/
|
|
60
|
+
export declare function queueRecoveryEvidence(runtime: EngineRuntime, membership: VerifiedMembership, evidence: SignedMessageValue): Effect.Effect<void, RouterWorkerPersistenceError>;
|
|
61
|
+
/**
|
|
62
|
+
* Mark one fixed conversation reconciled and complete an idle recovery run.
|
|
63
|
+
* @param runtime Engine participating in active recovery.
|
|
64
|
+
* @param conversationId Conversation whose verified position is complete.
|
|
65
|
+
* @returns Completion after any newly idle run is released.
|
|
66
|
+
*/
|
|
67
|
+
export declare function markConversationRecovered(runtime: EngineRuntime, conversationId: ConversationIdValue): Effect.Effect<void>;
|
|
68
|
+
/**
|
|
69
|
+
* Validate every stored fixed membership against current engine state.
|
|
70
|
+
* @param runtime Engine whose recovered conversations are authoritative.
|
|
71
|
+
* @param recovery Store snapshot to validate.
|
|
72
|
+
* @returns One unique verified membership per recovered conversation.
|
|
73
|
+
*/
|
|
74
|
+
export declare function recoverMemberships(runtime: EngineRuntime, recovery: EndpointRecovery): Effect.Effect<Map<ConversationIdValue, VerifiedMembership>, RouterWorkerRecoveryError>;
|
|
75
|
+
/**
|
|
76
|
+
* Determine whether one observed record belongs to the retained head ancestry.
|
|
77
|
+
* @param recovery Complete verified recovery snapshot.
|
|
78
|
+
* @param conversationId Conversation whose record chain is examined.
|
|
79
|
+
* @param observed Record hash reported by a fixed member.
|
|
80
|
+
* @param head Locally retained certified head.
|
|
81
|
+
* @returns Whether the observed record is the head or one of its ancestors.
|
|
82
|
+
*/
|
|
83
|
+
export declare function observedHeadIsResolved(recovery: EndpointRecovery, conversationId: ConversationIdValue, observed: RecordHashValue, head: RecordHashValue): boolean;
|
|
84
|
+
/**
|
|
85
|
+
* Determine whether one observed anchor belongs to the retained anchor chain.
|
|
86
|
+
* @param recovery Complete verified recovery snapshot.
|
|
87
|
+
* @param conversationId Conversation whose anchor chain is examined.
|
|
88
|
+
* @param observed Anchor hash reported by a fixed member.
|
|
89
|
+
* @param current Locally retained current anchor.
|
|
90
|
+
* @returns Whether the observed anchor is current or one of its ancestors.
|
|
91
|
+
*/
|
|
92
|
+
export declare function observedAnchorIsResolved(recovery: EndpointRecovery, conversationId: ConversationIdValue, observed: AnchorHashValue, current: AnchorHashValue): boolean;
|
|
93
|
+
/**
|
|
94
|
+
* Allocate all volatile state for one bounded recovery session.
|
|
95
|
+
* @param recovery RouterWorker callbacks and discontinuity anchor.
|
|
96
|
+
* @param memberships Verified memberships that must be reconciled.
|
|
97
|
+
* @returns Fresh queues, indexes, and completion signal for the run.
|
|
98
|
+
*/
|
|
99
|
+
export declare const makeRecoveryState: (recovery: RouterWorkerRecovery, memberships: Map<ConversationIdValue, VerifiedMembership>) => Effect.Effect<ActiveRecoveryState>;
|
|
100
|
+
/**
|
|
101
|
+
* Account for one sent recovery envelope and release an idle run.
|
|
102
|
+
* @param state Active recovery session whose envelope committed.
|
|
103
|
+
* @returns Completion after the pending count and waiter are updated.
|
|
104
|
+
*/
|
|
105
|
+
export declare function outboundCommitted(state: ActiveRecoveryState): Effect.Effect<void>;
|
|
106
|
+
/**
|
|
107
|
+
* Release a recovery run whose conversations and outbound queue are complete.
|
|
108
|
+
* @param state Active recovery session to examine.
|
|
109
|
+
* @returns Completion after the session waiter is released when idle.
|
|
110
|
+
*/
|
|
111
|
+
export declare function completeRecoveryIfIdle(state: ActiveRecoveryState): Effect.Effect<void>;
|
|
112
|
+
/**
|
|
113
|
+
* Return the active recovery owned by an engine, when one exists.
|
|
114
|
+
* @param runtime Engine whose recovery state is requested.
|
|
115
|
+
* @returns The active run, or `undefined` while the engine is not recovering.
|
|
116
|
+
*/
|
|
117
|
+
export declare function currentRecoveryState(runtime: EngineRuntime): ActiveRecoveryState | undefined;
|
|
118
|
+
/**
|
|
119
|
+
* Install the only active recovery for an engine.
|
|
120
|
+
* @param runtime Engine beginning a recovery run.
|
|
121
|
+
* @param state Volatile state owned by that run.
|
|
122
|
+
*/
|
|
123
|
+
export declare function installRecoveryState(runtime: EngineRuntime, state: ActiveRecoveryState): void;
|
|
124
|
+
/**
|
|
125
|
+
* Clear an engine recovery only when it still owns the supplied state.
|
|
126
|
+
* @param runtime Engine completing or aborting recovery.
|
|
127
|
+
* @param state Run that must still be active before removal.
|
|
128
|
+
*/
|
|
129
|
+
export declare function clearRecoveryState(runtime: EngineRuntime, state: ActiveRecoveryState): void;
|
|
130
|
+
//# sourceMappingURL=state.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../../src/endpoint/recovery/state.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAE1E,OAAO,EACL,KAAK,OAAO,EAGZ,KAAK,aAAa,IAAI,kBAAkB,EACzC,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAU,MAAM,QAAQ,CAAC;AACzD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAEL,KAAK,UAAU,IAAI,eAAe,EAElC,KAAK,cAAc,IAAI,mBAAmB,EAC1C,KAAK,cAAc,IAAI,mBAAmB,EAE1C,KAAK,YAAY,EAIjB,KAAK,qBAAqB,IAAI,0BAA0B,EAExD,KAAK,UAAU,IAAI,eAAe,EAGlC,KAAK,kBAAkB,EAExB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,4BAA4B,EAC5B,KAAK,oBAAoB,EAC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AClB,oBAAoB,eACjB,GAAG,CAAC,mBAAmB,EAAE,kBAAkB,CAAC,KACxD,MAAM,CAAC,MAAM,CAAC,mBAAmB,CAmBW,CAAC;AAEhD;;;;GAIG;AACH,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,mBAAmB,GACzB,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAIrB;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,mBAAmB,GACzB,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAMrB;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,aAAa,GACrB,mBAAmB,GAAG,SAAS,CAEjC;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,aAAa,EACtB,KAAK,EAAE,mBAAmB,GACzB,IAAI,CAEN;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,aAAa,EACtB,KAAK,EAAE,mBAAmB,GACzB,IAAI,CAIN"}
|
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
/** @file Shared volatile state for catch-up and Router re-anchor runs. */
|
|
2
|
+
import { MOLTZAP_VERSION, SignedMessage, } from "@moltzap/identity";
|
|
3
|
+
import { Deferred, Effect, Queue, Schema } from "effect";
|
|
4
|
+
import { AnchorHash, CatchUpRequest, decodeCanonical, encodeCanonical, memberCard, MembershipDescriptor, RecordHash, signOuterEvidence, signOuterPacket, verifyMembershipDescriptor, } from "../representation.js";
|
|
5
|
+
import { RouterWorkerPersistenceError, RouterWorkerRecoveryError, } from "../router-worker/index.js";
|
|
6
|
+
const activeRecoveries = new WeakMap();
|
|
7
|
+
/**
|
|
8
|
+
* Resolve the latest durable position for one fixed conversation.
|
|
9
|
+
* @param runtime Engine whose endpoint store owns the conversation.
|
|
10
|
+
* @param conversationId Private conversation identity to locate.
|
|
11
|
+
* @returns The complete recovery snapshot and its matching position row.
|
|
12
|
+
*/
|
|
13
|
+
export const durablePosition = (runtime, conversationId) => runtime.input.store.recover().pipe(Effect.mapError(persistenceFailure), Effect.map((recovery) => ({
|
|
14
|
+
recovery,
|
|
15
|
+
position: recovery.positions.find((candidate) => candidate.conversationId === conversationId),
|
|
16
|
+
})));
|
|
17
|
+
/**
|
|
18
|
+
* Queue a signed catch-up request at the engine's current durable position.
|
|
19
|
+
* @param runtime Engine participating in active recovery.
|
|
20
|
+
* @param conversationId Private conversation identity to reconcile.
|
|
21
|
+
* @returns Completion after the request is stored in the recovery queue.
|
|
22
|
+
*/
|
|
23
|
+
export const requestCertifiedHistory = (runtime, conversationId) => Effect.gen(function* () {
|
|
24
|
+
const state = currentRecoveryState(runtime);
|
|
25
|
+
const membership = state?.memberships.get(conversationId);
|
|
26
|
+
if (state === undefined || membership === undefined) {
|
|
27
|
+
return yield* Effect.fail(persistenceFailure());
|
|
28
|
+
}
|
|
29
|
+
const { position } = yield* durablePosition(runtime, conversationId);
|
|
30
|
+
if (position === undefined) {
|
|
31
|
+
return yield* Effect.fail(persistenceFailure());
|
|
32
|
+
}
|
|
33
|
+
const knownRecordHash = yield* decodeKnownRecordHash(position);
|
|
34
|
+
const knownAnchorHash = yield* decodeKnownAnchorHash(position);
|
|
35
|
+
const request = yield* makeCatchUpRequest(runtime, membership, knownRecordHash, knownAnchorHash);
|
|
36
|
+
yield* Effect.sync(() => {
|
|
37
|
+
state.pendingRequests.set(conversationId, request);
|
|
38
|
+
state.incompleteResponders.set(conversationId, new Set());
|
|
39
|
+
});
|
|
40
|
+
yield* queueRecoveryPacket(runtime, membership, request);
|
|
41
|
+
}).pipe(Effect.withSpan("requestCertifiedHistory"));
|
|
42
|
+
/**
|
|
43
|
+
* Queue one signed recovery packet for all fixed members.
|
|
44
|
+
* @param runtime Engine whose recovery queue owns the packet.
|
|
45
|
+
* @param membership Verified fixed membership for the outer envelope.
|
|
46
|
+
* @param packet Closed recovery packet to route.
|
|
47
|
+
* @returns Completion after the outer envelope enters the durable queue.
|
|
48
|
+
*/
|
|
49
|
+
export function queueRecoveryPacket(runtime, membership, packet) {
|
|
50
|
+
return signOuterPacket({
|
|
51
|
+
packet,
|
|
52
|
+
membership,
|
|
53
|
+
agentCard: runtime.input.localAgentCard,
|
|
54
|
+
signingAuthority: runtime.input.signingAuthority,
|
|
55
|
+
}).pipe(Effect.mapError(persistenceFailure), Effect.flatMap((message) => enqueueOuter(runtime, membership.descriptor.conversationId, message)));
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Queue one stable inner evidence message for all fixed members.
|
|
59
|
+
* @param runtime Engine whose recovery queue owns the evidence.
|
|
60
|
+
* @param membership Verified fixed membership for the outer envelope.
|
|
61
|
+
* @param evidence Stable self-addressed evidence to relay.
|
|
62
|
+
* @returns Completion after the outer envelope enters the durable queue.
|
|
63
|
+
*/
|
|
64
|
+
export function queueRecoveryEvidence(runtime, membership, evidence) {
|
|
65
|
+
return signOuterEvidence({
|
|
66
|
+
evidence,
|
|
67
|
+
membership,
|
|
68
|
+
agentCard: runtime.input.localAgentCard,
|
|
69
|
+
signingAuthority: runtime.input.signingAuthority,
|
|
70
|
+
}).pipe(Effect.mapError(persistenceFailure), Effect.flatMap((message) => enqueueOuter(runtime, membership.descriptor.conversationId, message)));
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Mark one fixed conversation reconciled and complete an idle recovery run.
|
|
74
|
+
* @param runtime Engine participating in active recovery.
|
|
75
|
+
* @param conversationId Conversation whose verified position is complete.
|
|
76
|
+
* @returns Completion after any newly idle run is released.
|
|
77
|
+
*/
|
|
78
|
+
export function markConversationRecovered(runtime, conversationId) {
|
|
79
|
+
const state = currentRecoveryState(runtime);
|
|
80
|
+
if (state === undefined) {
|
|
81
|
+
return Effect.void;
|
|
82
|
+
}
|
|
83
|
+
return Effect.sync(() => {
|
|
84
|
+
state.completedConversations.add(conversationId);
|
|
85
|
+
}).pipe(Effect.zipRight(completeRecoveryIfIdle(state)));
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Validate every stored fixed membership against current engine state.
|
|
89
|
+
* @param runtime Engine whose recovered conversations are authoritative.
|
|
90
|
+
* @param recovery Store snapshot to validate.
|
|
91
|
+
* @returns One unique verified membership per recovered conversation.
|
|
92
|
+
*/
|
|
93
|
+
export function recoverMemberships(runtime, recovery) {
|
|
94
|
+
return Effect.forEach(recovery.memberships, (stored) => recoverMembership(runtime, stored), { concurrency: 1 }).pipe(Effect.flatMap((entries) => uniqueMembershipMap(entries)), Effect.withSpan("recoverMemberships"));
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Determine whether one observed record belongs to the retained head ancestry.
|
|
98
|
+
* @param recovery Complete verified recovery snapshot.
|
|
99
|
+
* @param conversationId Conversation whose record chain is examined.
|
|
100
|
+
* @param observed Record hash reported by a fixed member.
|
|
101
|
+
* @param head Locally retained certified head.
|
|
102
|
+
* @returns Whether the observed record is the head or one of its ancestors.
|
|
103
|
+
*/
|
|
104
|
+
export function observedHeadIsResolved(recovery, conversationId, observed, head) {
|
|
105
|
+
let cursor = head;
|
|
106
|
+
while (cursor !== undefined) {
|
|
107
|
+
if (cursor === observed) {
|
|
108
|
+
return true;
|
|
109
|
+
}
|
|
110
|
+
cursor = previousRecordHash(recovery, conversationId, cursor);
|
|
111
|
+
}
|
|
112
|
+
return false;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Determine whether one observed anchor belongs to the retained anchor chain.
|
|
116
|
+
* @param recovery Complete verified recovery snapshot.
|
|
117
|
+
* @param conversationId Conversation whose anchor chain is examined.
|
|
118
|
+
* @param observed Anchor hash reported by a fixed member.
|
|
119
|
+
* @param current Locally retained current anchor.
|
|
120
|
+
* @returns Whether the observed anchor is current or one of its ancestors.
|
|
121
|
+
*/
|
|
122
|
+
export function observedAnchorIsResolved(recovery, conversationId, observed, current) {
|
|
123
|
+
let cursor = current;
|
|
124
|
+
while (cursor !== undefined) {
|
|
125
|
+
if (cursor === observed) {
|
|
126
|
+
return true;
|
|
127
|
+
}
|
|
128
|
+
cursor = previousAnchorHash(recovery, conversationId, cursor);
|
|
129
|
+
}
|
|
130
|
+
return false;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Allocate all volatile state for one bounded recovery session.
|
|
134
|
+
* @param recovery RouterWorker callbacks and discontinuity anchor.
|
|
135
|
+
* @param memberships Verified memberships that must be reconciled.
|
|
136
|
+
* @returns Fresh queues, indexes, and completion signal for the run.
|
|
137
|
+
*/
|
|
138
|
+
export const makeRecoveryState = (recovery, memberships) => Effect.gen(function* () {
|
|
139
|
+
return {
|
|
140
|
+
recovery,
|
|
141
|
+
outbound: yield* Queue.unbounded(),
|
|
142
|
+
completion: yield* Deferred.make(),
|
|
143
|
+
memberships,
|
|
144
|
+
pendingRequests: new Map(),
|
|
145
|
+
incompleteResponders: new Map(),
|
|
146
|
+
acceptedSuccessors: new Map(),
|
|
147
|
+
observedHeads: new Map(),
|
|
148
|
+
pendingVotes: new Map(),
|
|
149
|
+
positionsReady: new Set(),
|
|
150
|
+
completedConversations: new Set(),
|
|
151
|
+
pendingOutbound: 0,
|
|
152
|
+
};
|
|
153
|
+
}).pipe(Effect.withSpan("makeRecoveryState"));
|
|
154
|
+
/**
|
|
155
|
+
* Account for one sent recovery envelope and release an idle run.
|
|
156
|
+
* @param state Active recovery session whose envelope committed.
|
|
157
|
+
* @returns Completion after the pending count and waiter are updated.
|
|
158
|
+
*/
|
|
159
|
+
export function outboundCommitted(state) {
|
|
160
|
+
return Effect.sync(() => {
|
|
161
|
+
state.pendingOutbound -= 1;
|
|
162
|
+
}).pipe(Effect.zipRight(completeRecoveryIfIdle(state)));
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Release a recovery run whose conversations and outbound queue are complete.
|
|
166
|
+
* @param state Active recovery session to examine.
|
|
167
|
+
* @returns Completion after the session waiter is released when idle.
|
|
168
|
+
*/
|
|
169
|
+
export function completeRecoveryIfIdle(state) {
|
|
170
|
+
return Effect.suspend(() => recoveryIsIdle(state)
|
|
171
|
+
? Deferred.succeed(state.completion, undefined).pipe(Effect.asVoid)
|
|
172
|
+
: Effect.void);
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Return the active recovery owned by an engine, when one exists.
|
|
176
|
+
* @param runtime Engine whose recovery state is requested.
|
|
177
|
+
* @returns The active run, or `undefined` while the engine is not recovering.
|
|
178
|
+
*/
|
|
179
|
+
export function currentRecoveryState(runtime) {
|
|
180
|
+
return activeRecoveries.get(runtime);
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Install the only active recovery for an engine.
|
|
184
|
+
* @param runtime Engine beginning a recovery run.
|
|
185
|
+
* @param state Volatile state owned by that run.
|
|
186
|
+
*/
|
|
187
|
+
export function installRecoveryState(runtime, state) {
|
|
188
|
+
activeRecoveries.set(runtime, state);
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Clear an engine recovery only when it still owns the supplied state.
|
|
192
|
+
* @param runtime Engine completing or aborting recovery.
|
|
193
|
+
* @param state Run that must still be active before removal.
|
|
194
|
+
*/
|
|
195
|
+
export function clearRecoveryState(runtime, state) {
|
|
196
|
+
if (activeRecoveries.get(runtime) === state) {
|
|
197
|
+
activeRecoveries.delete(runtime);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
function recoveryIsIdle(state) {
|
|
201
|
+
return (state.completedConversations.size === state.memberships.size &&
|
|
202
|
+
state.pendingOutbound === 0);
|
|
203
|
+
}
|
|
204
|
+
function enqueueOuter(runtime, conversationId, message) {
|
|
205
|
+
const state = currentRecoveryState(runtime);
|
|
206
|
+
if (state !== undefined) {
|
|
207
|
+
return Effect.sync(() => {
|
|
208
|
+
state.pendingOutbound += 1;
|
|
209
|
+
}).pipe(Effect.zipRight(Queue.offer(state.outbound, { conversationId, message })), Effect.asVoid);
|
|
210
|
+
}
|
|
211
|
+
return encodeCanonical(SignedMessage, message).pipe(Effect.mapError(persistenceFailure), Effect.flatMap((canonicalSignedMessage) => runtime.input.store.enqueueOutbound({
|
|
212
|
+
conversationId,
|
|
213
|
+
messageId: message.messageId,
|
|
214
|
+
canonicalSignedMessage,
|
|
215
|
+
})), Effect.mapError(persistenceFailure), Effect.flatMap((outbound) => Effect.sync(() => {
|
|
216
|
+
if (!runtime.outbound.includes(outbound.outboundId)) {
|
|
217
|
+
runtime.outbound.push(outbound.outboundId);
|
|
218
|
+
}
|
|
219
|
+
})), Effect.zipRight(runtime.outboundSignal.offer(undefined)), Effect.asVoid);
|
|
220
|
+
}
|
|
221
|
+
function makeCatchUpRequest(runtime, membership, knownRecordHash, knownAnchorHash) {
|
|
222
|
+
return Schema.decodeUnknown(CatchUpRequest)({
|
|
223
|
+
moltzapVersion: MOLTZAP_VERSION,
|
|
224
|
+
kind: "catch_up_request",
|
|
225
|
+
conversationId: membership.descriptor.conversationId,
|
|
226
|
+
membershipHash: membership.hash,
|
|
227
|
+
requesterAgentId: runtime.input.localAgentCard.agentId,
|
|
228
|
+
knownRecordHash,
|
|
229
|
+
knownAnchorHash,
|
|
230
|
+
}).pipe(Effect.mapError(persistenceFailure));
|
|
231
|
+
}
|
|
232
|
+
function decodeKnownRecordHash(position) {
|
|
233
|
+
if (position.headRecordHash === undefined) {
|
|
234
|
+
return Effect.succeed(null);
|
|
235
|
+
}
|
|
236
|
+
return Schema.decodeUnknown(RecordHash)(position.headRecordHash).pipe(Effect.mapError(persistenceFailure));
|
|
237
|
+
}
|
|
238
|
+
function decodeKnownAnchorHash(position) {
|
|
239
|
+
if (position.headRecordHash === undefined) {
|
|
240
|
+
return Effect.succeed(null);
|
|
241
|
+
}
|
|
242
|
+
return Schema.decodeUnknown(AnchorHash)(position.currentAnchorHash).pipe(Effect.mapError(persistenceFailure));
|
|
243
|
+
}
|
|
244
|
+
function recoverMembership(runtime, stored) {
|
|
245
|
+
return decodeCanonical(MembershipDescriptor, stored.canonicalMembership).pipe(Effect.flatMap((descriptor) => verifyMembershipDescriptor(descriptor, runtime.input.registrySignerPublicKey)), Effect.flatMap((membership) => {
|
|
246
|
+
if (!recoveredMembershipMatches(runtime, stored, membership)) {
|
|
247
|
+
return Effect.fail(recoveryFailure());
|
|
248
|
+
}
|
|
249
|
+
const entry = [
|
|
250
|
+
membership.descriptor.conversationId,
|
|
251
|
+
membership,
|
|
252
|
+
];
|
|
253
|
+
return Effect.succeed(entry);
|
|
254
|
+
}), Effect.mapError(recoveryFailure));
|
|
255
|
+
}
|
|
256
|
+
function recoveredMembershipMatches(runtime, stored, membership) {
|
|
257
|
+
const conversationId = membership.descriptor.conversationId;
|
|
258
|
+
const retained = runtime.conversations.get(conversationId);
|
|
259
|
+
return [
|
|
260
|
+
conversationId === stored.conversationId,
|
|
261
|
+
membership.hash === stored.membershipHash,
|
|
262
|
+
memberCard(membership, runtime.input.localAgentCard.agentId) !== undefined,
|
|
263
|
+
retained?.membership.hash === membership.hash,
|
|
264
|
+
].every((matches) => matches);
|
|
265
|
+
}
|
|
266
|
+
function uniqueMembershipMap(entries) {
|
|
267
|
+
const memberships = new Map(entries);
|
|
268
|
+
return memberships.size === entries.length
|
|
269
|
+
? Effect.succeed(memberships)
|
|
270
|
+
: Effect.fail(recoveryFailure());
|
|
271
|
+
}
|
|
272
|
+
function previousRecordHash(recovery, conversationId, recordHash) {
|
|
273
|
+
for (const candidate of recovery.certifiedRecords) {
|
|
274
|
+
if (candidate.conversationId === conversationId &&
|
|
275
|
+
candidate.recordHash === recordHash) {
|
|
276
|
+
return candidate.previousRecordHash;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
return undefined;
|
|
280
|
+
}
|
|
281
|
+
function previousAnchorHash(recovery, conversationId, anchorHash) {
|
|
282
|
+
for (const candidate of recovery.anchors) {
|
|
283
|
+
if (candidate.conversationId === conversationId &&
|
|
284
|
+
candidate.anchorHash === anchorHash) {
|
|
285
|
+
return candidate.previousAnchorHash;
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
return undefined;
|
|
289
|
+
}
|
|
290
|
+
function persistenceFailure() {
|
|
291
|
+
return new RouterWorkerPersistenceError();
|
|
292
|
+
}
|
|
293
|
+
function recoveryFailure() {
|
|
294
|
+
return new RouterWorkerRecoveryError();
|
|
295
|
+
}
|
|
296
|
+
//# sourceMappingURL=state.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state.js","sourceRoot":"","sources":["../../../src/endpoint/recovery/state.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAE1E,OAAO,EAEL,eAAe,EACf,aAAa,GAEd,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGzD,OAAO,EACL,UAAU,EAEV,cAAc,EAGd,eAAe,EAEf,eAAe,EACf,UAAU,EACV,oBAAoB,EAEpB,UAAU,EAEV,iBAAiB,EACjB,eAAe,EAEf,0BAA0B,GAC3B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,4BAA4B,EAE5B,yBAAyB,GAE1B,MAAM,2BAA2B,CAAC;AA2BnC,MAAM,gBAAgB,GAAG,IAAI,OAAO,EAAsC,CAAC;AAE3E;;;;;GAKG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAC7B,OAAsB,EACtB,cAAmC,EACnC,EAAE,CACF,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,IAAI,CAChC,MAAM,CAAC,QAAQ,CAAC,kBAAkB,CAAC,EACnC,MAAM,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;IACxB,QAAQ;IACR,QAAQ,EAAE,QAAQ,CAAC,SAAS,CAAC,IAAI,CAC/B,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,cAAc,KAAK,cAAc,CAC3D;CACF,CAAC,CAAC,CACJ,CAAC;AAEJ;;;;;GAKG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,CACrC,OAA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ACnB,CAAC;AAED,SAAS,kBAAkB,CACzB,QAA0B,EAC1B,cAAmC,EACnC,UAAkB;IAElB,KAAK,MAAM,SAAS,IAAI,QAAQ,CAAC,OAAO,EAAE,CAAC;QACzC,IACE,SAAS,CAAC,cAAc,KAAK,cAAc;YAC3C,SAAS,CAAC,UAAU,KAAK,UAAU,EACnC,CAAC;YACD,OAAO,SAAS,CAAC,kBAAkB,CAAC;QACtC,CAAC;IACH,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAS,kBAAkB;IACzB,OAAO,IAAI,4BAA4B,EAAE,CAAC;AAC5C,CAAC;AAED,SAAS,eAAe;IACtB,OAAO,IAAI,yBAAyB,EAAE,CAAC;AACzC,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** @file Verified reconstruction of active protocol evidence from store rows. */
|
|
2
|
+
import { Effect, type ParseResult } from "effect";
|
|
3
|
+
import type { EngineActionFold } from "../engine-types.js";
|
|
4
|
+
import type { EndpointRecovery } from "../store.js";
|
|
5
|
+
import { type ActionHash, type ClientRepresentationError, type RecordHash as RecordHashValue } from "../representation.js";
|
|
6
|
+
import { RouterWorkerPersistenceError } from "../router-worker/index.js";
|
|
7
|
+
type StoredEvidenceError = ClientRepresentationError | ParseResult.ParseError | RouterWorkerPersistenceError;
|
|
8
|
+
/**
|
|
9
|
+
* Restore only evidence whose signer, subject, and conversation still match.
|
|
10
|
+
* @param recovery Complete endpoint-store snapshot.
|
|
11
|
+
* @param actionFolds Active folds indexed by verified action hash.
|
|
12
|
+
* @param recordFolds Active folds indexed by verified record hash.
|
|
13
|
+
* @returns Completion after every relevant row is verified and installed.
|
|
14
|
+
*/
|
|
15
|
+
export declare function recoverFoldEvidence(recovery: EndpointRecovery, actionFolds: Map<ActionHash, EngineActionFold>, recordFolds: Map<RecordHashValue, EngineActionFold>): Effect.Effect<void, StoredEvidenceError>;
|
|
16
|
+
export {};
|
|
17
|
+
//# sourceMappingURL=store-evidence.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store-evidence.d.ts","sourceRoot":"","sources":["../../../src/endpoint/recovery/store-evidence.ts"],"names":[],"mappings":"AAAA,iFAAiF;AAGjF,OAAO,EAAE,MAAM,EAAE,KAAK,WAAW,EAAU,MAAM,QAAQ,CAAC;AAC1D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,KAAK,EAAE,gBAAgB,EAAoB,MAAM,aAAa,CAAC;AACtE,OAAO,EACL,KAAK,UAAU,EAEf,KAAK,yBAAyB,EAI9B,KAAK,UAAU,IAAI,eAAe,EAEnC,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,4BAA4B,EAAE,MAAM,2BAA2B,CAAC;AAEzE,KAAK,mBAAmB,GACpB,yBAAyB,GACzB,WAAW,CAAC,UAAU,GACtB,4BAA4B,CAAC;AAOjC;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,gBAAgB,EAC1B,WAAW,EAAE,GAAG,CAAC,UAAU,EAAE,gBAAgB,CAAC,EAC9C,WAAW,EAAE,GAAG,CAAC,eAAe,EAAE,gBAAgB,CAAC,GAClD,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,mBAAmB,CAAC,CAiB1C"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/** @file Verified reconstruction of active protocol evidence from store rows. */
|
|
2
|
+
import { SignedMessage } from "@moltzap/identity";
|
|
3
|
+
import { Effect, Schema } from "effect";
|
|
4
|
+
import { ActionHash as ActionHashSchema, decodeCanonical, RecordHash, verifyStableEvidence, } from "../representation.js";
|
|
5
|
+
import { RouterWorkerPersistenceError } from "../router-worker/index.js";
|
|
6
|
+
/**
|
|
7
|
+
* Restore only evidence whose signer, subject, and conversation still match.
|
|
8
|
+
* @param recovery Complete endpoint-store snapshot.
|
|
9
|
+
* @param actionFolds Active folds indexed by verified action hash.
|
|
10
|
+
* @param recordFolds Active folds indexed by verified record hash.
|
|
11
|
+
* @returns Completion after every relevant row is verified and installed.
|
|
12
|
+
*/
|
|
13
|
+
export function recoverFoldEvidence(recovery, actionFolds, recordFolds) {
|
|
14
|
+
return Effect.forEach(recovery.evidence, (row) => {
|
|
15
|
+
if (row.kind === "catch-up" || row.kind === "reanchor") {
|
|
16
|
+
return Effect.void;
|
|
17
|
+
}
|
|
18
|
+
return foldForEvidence(row, actionFolds, recordFolds).pipe(Effect.flatMap((target) => target === undefined
|
|
19
|
+
? Effect.fail(persistenceFailure())
|
|
20
|
+
: restoreFoldEvidence(row, target)));
|
|
21
|
+
}, { concurrency: 1, discard: true });
|
|
22
|
+
}
|
|
23
|
+
function foldForEvidence(row, actionFolds, recordFolds) {
|
|
24
|
+
switch (row.kind) {
|
|
25
|
+
case "action":
|
|
26
|
+
return Schema.decodeUnknown(ActionHashSchema)(row.subjectId).pipe(Effect.map((hash) => actionFolds.get(hash)), Effect.map((fold) => fold === undefined ? undefined : { fold, kind: "action" }));
|
|
27
|
+
case "durability":
|
|
28
|
+
return Schema.decodeUnknown(RecordHash)(row.subjectId).pipe(Effect.map((hash) => recordFolds.get(hash)), Effect.map((fold) => fold === undefined ? undefined : { fold, kind: "durability" }));
|
|
29
|
+
case "catch-up":
|
|
30
|
+
case "reanchor":
|
|
31
|
+
return Effect.succeed(undefined);
|
|
32
|
+
default: {
|
|
33
|
+
const exhaustive = row.kind;
|
|
34
|
+
return exhaustive;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
function restoreFoldEvidence(row, target) {
|
|
39
|
+
return decodeCanonical(SignedMessage, row.canonicalEvidence).pipe(Effect.flatMap((message) => Schema.encode(SignedMessage)(message)), Effect.flatMap((representation) => verifyStableEvidence({
|
|
40
|
+
representation,
|
|
41
|
+
membership: target.fold.conversation.membership,
|
|
42
|
+
})), Effect.flatMap((verified) => foldEvidenceMatches(row, target, verified.statement)
|
|
43
|
+
? Effect.sync(() => {
|
|
44
|
+
const evidence = target.kind === "action"
|
|
45
|
+
? target.fold.actionEvidence
|
|
46
|
+
: target.fold.durabilityEvidence;
|
|
47
|
+
evidence.set(verified.message.senderAgentId, verified.message);
|
|
48
|
+
})
|
|
49
|
+
: Effect.fail(persistenceFailure())));
|
|
50
|
+
}
|
|
51
|
+
function foldEvidenceMatches(row, target, statement) {
|
|
52
|
+
if (row.conversationId !== target.fold.conversation.conversationId ||
|
|
53
|
+
row.evidenceKey !== statement.signerAgentId) {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
return target.kind === "action"
|
|
57
|
+
? actionEvidenceMatches(row, target.fold, statement)
|
|
58
|
+
: durabilityEvidenceMatches(row, target.fold, statement);
|
|
59
|
+
}
|
|
60
|
+
function actionEvidenceMatches(row, fold, statement) {
|
|
61
|
+
if (row.kind !== "action" || statement.kind !== "action_signature") {
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
return (row.subjectId === fold.actionHash &&
|
|
65
|
+
statement.actionHash === fold.actionHash);
|
|
66
|
+
}
|
|
67
|
+
function durabilityEvidenceMatches(row, fold, statement) {
|
|
68
|
+
if (row.kind !== "durability" || statement.kind !== "durability_vote") {
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
return (row.subjectId === fold.recordHash &&
|
|
72
|
+
statement.recordHash === fold.recordHash &&
|
|
73
|
+
statement.conversationId === fold.conversation.conversationId &&
|
|
74
|
+
statement.membershipHash === fold.conversation.membership.hash);
|
|
75
|
+
}
|
|
76
|
+
function persistenceFailure() {
|
|
77
|
+
return new RouterWorkerPersistenceError();
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=store-evidence.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store-evidence.js","sourceRoot":"","sources":["../../../src/endpoint/recovery/store-evidence.ts"],"names":[],"mappings":"AAAA,iFAAiF;AAEjF,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,O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AC,UAAU,KAAK,IAAI,CAAC,UAAU,CACzC,CAAC;AACJ,CAAC;AAED,SAAS,yBAAyB,CAChC,GAAqB,EACrB,IAAsB,EACtB,SAAiC;IAEjC,IAAI,GAAG,CAAC,IAAI,KAAK,YAAY,IAAI,SAAS,CAAC,IAAI,KAAK,iBAAiB,EAAE,CAAC;QACtE,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,CACL,GAAG,CAAC,SAAS,KAAK,IAAI,CAAC,UAAU;QACjC,SAAS,CAAC,UAAU,KAAK,IAAI,CAAC,UAAU;QACxC,SAAS,CAAC,cAAc,KAAK,IAAI,CAAC,YAAY,CAAC,cAAc;QAC7D,SAAS,CAAC,cAAc,KAAK,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,IAAI,CAC/D,CAAC;AACJ,CAAC;AAED,SAAS,kBAAkB;IACzB,OAAO,IAAI,4BAA4B,EAAE,CAAC;AAC5C,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/** @file Verified reconstruction of endpoint history from one store snapshot. */
|
|
2
|
+
import { Effect, type ParseResult } from "effect";
|
|
3
|
+
import type { EndpointEngineInput, EngineActionFold, EngineConversation, EngineRuntime } from "../engine-types.js";
|
|
4
|
+
import type { EndpointRecovery, StoredOutboundMessage } from "../store.js";
|
|
5
|
+
import { type ActionHash, type CertifiedRecord, type ClientRepresentationError, type ConversationId as ConversationIdValue, type RecordHash as RecordHashValue, type VerifiedMembership } from "../representation.js";
|
|
6
|
+
import { RouterWorkerPersistenceError, RouterWorkerRecoveryError } from "../router-worker/index.js";
|
|
7
|
+
type RecoveryStoreError = ClientRepresentationError | ParseResult.ParseError | RouterWorkerPersistenceError;
|
|
8
|
+
/** Complete process-local projections recovered before protocol work resumes. */
|
|
9
|
+
interface RecoveredEngineState {
|
|
10
|
+
readonly conversations: Map<ConversationIdValue, EngineConversation>;
|
|
11
|
+
readonly actionFolds: Map<ActionHash, EngineActionFold>;
|
|
12
|
+
readonly recordFolds: Map<RecordHashValue, EngineActionFold>;
|
|
13
|
+
readonly completedPostIds: Set<string>;
|
|
14
|
+
readonly postIntents: ReadonlyArray<EndpointRecovery["postIntents"][number]>;
|
|
15
|
+
readonly outboundMessages: readonly StoredOutboundMessage[];
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Rebuild only state whose hashes, signatures, and cross-fields still verify.
|
|
19
|
+
* @param input Engine dependencies used to verify persisted representation.
|
|
20
|
+
* @param recovery Complete store snapshot captured before engine startup.
|
|
21
|
+
* @returns Verified conversations, folds, and durable post intents.
|
|
22
|
+
*/
|
|
23
|
+
export declare const recoverEngineState: (input: EndpointEngineInput, recovery: EndpointRecovery) => Effect.Effect<RecoveredEngineState, RecoveryStoreError>;
|
|
24
|
+
/**
|
|
25
|
+
* Reconstruct one complete certified record from separately retained evidence.
|
|
26
|
+
* @param input Engine dependencies used for Registry signature verification.
|
|
27
|
+
* @param stored Durable record core and signer-attributed evidence rows.
|
|
28
|
+
* @param routerAnchor Verified anchor named by the durable record core.
|
|
29
|
+
* @returns The complete record after all hashes and store projections match.
|
|
30
|
+
*/
|
|
31
|
+
export declare const recordFromStore: (input: EndpointEngineInput, stored: EndpointRecovery["certifiedRecords"][number], routerAnchor: EngineConversation["currentAnchor"]) => Effect.Effect<CertifiedRecord, RecoveryStoreError>;
|
|
32
|
+
/**
|
|
33
|
+
* Decode and verify one durable genesis or completed re-anchor row.
|
|
34
|
+
* @param membership Fixed membership that owns the anchor.
|
|
35
|
+
* @param stored Durable anchor row and canonical representation.
|
|
36
|
+
* @returns A verified anchor usable for record reconstruction.
|
|
37
|
+
*/
|
|
38
|
+
export declare function decodeStoredAnchor(membership: VerifiedMembership, stored: EndpointRecovery["anchors"][number]): Effect.Effect<EngineConversation["currentAnchor"], RouterWorkerPersistenceError>;
|
|
39
|
+
/**
|
|
40
|
+
* Verify every retained current outer envelope before Router resumption.
|
|
41
|
+
* @param input Engine identity and signature-verification dependencies.
|
|
42
|
+
* @param outbounds Exact pending rows recovered in durable insertion order.
|
|
43
|
+
* @param memberships Verified membership for each retained conversation.
|
|
44
|
+
* @returns The unchanged rows after canonical bytes and attribution verify.
|
|
45
|
+
*/
|
|
46
|
+
export declare function verifyStoredOutbounds(input: EndpointEngineInput, outbounds: readonly StoredOutboundMessage[], memberships: ReadonlyMap<ConversationIdValue, VerifiedMembership>): Effect.Effect<readonly StoredOutboundMessage[], RecoveryStoreError>;
|
|
47
|
+
/**
|
|
48
|
+
* Verify that every recovered record and anchor forms one gap-free history.
|
|
49
|
+
* @param runtime Engine used for Registry and conversation verification.
|
|
50
|
+
* @param recovery Complete store snapshot to verify.
|
|
51
|
+
* @param memberships Verified fixed memberships keyed by conversation.
|
|
52
|
+
* @returns Completion only when every retained history is complete and unique.
|
|
53
|
+
*/
|
|
54
|
+
export declare function verifyRecoveredHistory(runtime: EngineRuntime, recovery: EndpointRecovery, memberships: Map<ConversationIdValue, VerifiedMembership>): Effect.Effect<void, RouterWorkerRecoveryError>;
|
|
55
|
+
export {};
|
|
56
|
+
//# sourceMappingURL=store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../../src/endpoint/recovery/store.ts"],"names":[],"mappings":"AAAA,iFAAiF;AAOjF,OAAO,EAAE,MAAM,EAAE,KAAK,WAAW,EAAU,MAAM,QAAQ,CAAC;AAC1D,OAAO,KAAK,EACV,mBAAmB,EACnB,gBAAgB,EAEhB,kBAAkB,EAClB,aAAa,EACd,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EACV,gBAAgB,EAEhB,qBAAqB,EACtB,MAAM,aAAa,CAAC;AACrB,OAAO,EAIL,KAAK,UAAU,EAIf,KAAK,eAAe,EACpB,KAAK,yBAAyB,EAK9B,KAAK,cAAc,IAAI,mBAAmB,EAS1C,KAAK,UAAU,IAAI,eAAe,EAElC,KAAK,kBAAkB,EAOxB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,4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