@moltzap/client 2026.812.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-server.d.ts → harness-mcp-http.d.ts} +9 -8
- package/dist/harness-mcp-http.d.ts.map +1 -0
- package/dist/{harness-mcp-server.js → harness-mcp-http.js} +38 -60
- 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 +24 -49
- package/dist/harness-mcp-wire.d.ts.map +1 -1
- package/dist/harness-mcp-wire.js +381 -124
- package/dist/harness-mcp-wire.js.map +1 -1
- package/dist/index.d.ts +4 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -10
- 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 +24 -52
- 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 -16
- package/dist/channel-base/index.js.map +0 -1
- package/dist/channel-core-enrichment.d.ts +0 -38
- package/dist/channel-core-enrichment.d.ts.map +0 -1
- package/dist/channel-core-enrichment.js +0 -217
- 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 -306
- package/dist/channel-core.d.ts.map +0 -1
- package/dist/channel-core.js +0 -365
- package/dist/channel-core.js.map +0 -1
- package/dist/config.d.ts +0 -33
- package/dist/config.d.ts.map +0 -1
- package/dist/config.js +0 -51
- package/dist/config.js.map +0 -1
- package/dist/config.test-utils.d.ts +0 -24
- package/dist/config.test-utils.d.ts.map +0 -1
- package/dist/config.test-utils.js +0 -57
- package/dist/config.test-utils.js.map +0 -1
- package/dist/harness/client-runtime.d.ts +0 -31
- package/dist/harness/client-runtime.d.ts.map +0 -1
- package/dist/harness/client-runtime.js +0 -121
- 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 -301
- package/dist/harness/runtime.d.ts.map +0 -1
- package/dist/harness/runtime.js +0 -165
- package/dist/harness/runtime.js.map +0 -1
- package/dist/harness-client.d.ts +0 -47
- package/dist/harness-client.d.ts.map +0 -1
- package/dist/harness-client.js +0 -76
- package/dist/harness-client.js.map +0 -1
- package/dist/harness-context-projection.d.ts +0 -35
- package/dist/harness-context-projection.d.ts.map +0 -1
- package/dist/harness-context-projection.js +0 -123
- package/dist/harness-context-projection.js.map +0 -1
- package/dist/harness-mcp-server.d.ts.map +0 -1
- package/dist/harness-mcp-server.js.map +0 -1
- package/dist/local-paths.d.ts +0 -11
- package/dist/local-paths.d.ts.map +0 -1
- package/dist/local-paths.js +0 -21
- package/dist/local-paths.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-catalog.d.ts +0 -35
- package/dist/moltzapd-catalog.d.ts.map +0 -1
- package/dist/moltzapd-catalog.js +0 -117
- package/dist/moltzapd-catalog.js.map +0 -1
- package/dist/moltzapd-child-ipc.d.ts +0 -26
- package/dist/moltzapd-child-ipc.d.ts.map +0 -1
- package/dist/moltzapd-child-ipc.js +0 -31
- package/dist/moltzapd-child-ipc.js.map +0 -1
- package/dist/moltzapd-child.d.ts +0 -55
- package/dist/moltzapd-child.d.ts.map +0 -1
- package/dist/moltzapd-child.js +0 -225
- package/dist/moltzapd-child.js.map +0 -1
- package/dist/moltzapd-main.d.ts +0 -3
- package/dist/moltzapd-main.d.ts.map +0 -1
- package/dist/moltzapd-main.js +0 -18
- package/dist/moltzapd-main.js.map +0 -1
- package/dist/moltzapd-registration.d.ts +0 -40
- package/dist/moltzapd-registration.d.ts.map +0 -1
- package/dist/moltzapd-registration.js +0 -59
- package/dist/moltzapd-registration.js.map +0 -1
- package/dist/moltzapd.d.ts +0 -85
- package/dist/moltzapd.d.ts.map +0 -1
- package/dist/moltzapd.js +0 -150
- 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/notification/trace.d.ts +0 -10
- package/dist/notification/trace.d.ts.map +0 -1
- package/dist/notification/trace.js +0 -34
- package/dist/notification/trace.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/presentation/index.d.ts +0 -3
- package/dist/presentation/index.d.ts.map +0 -1
- package/dist/presentation/index.js +0 -3
- package/dist/presentation/index.js.map +0 -1
- package/dist/presentation/state.d.ts +0 -77
- package/dist/presentation/state.d.ts.map +0 -1
- package/dist/presentation/state.js +0 -211
- package/dist/presentation/state.js.map +0 -1
- package/dist/profile.d.ts +0 -106
- package/dist/profile.d.ts.map +0 -1
- package/dist/profile.js +0 -171
- package/dist/profile.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.d.ts +0 -228
- package/dist/service.d.ts.map +0 -1
- package/dist/service.js +0 -485
- 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 -82
- 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 -56
- package/dist/test-utils/index.d.ts.map +0 -1
- package/dist/test-utils/index.js +0 -67
- package/dist/test-utils/index.js.map +0 -1
- package/dist/test-utils/process/reserve-port.d.ts +0 -20
- package/dist/test-utils/process/reserve-port.d.ts.map +0 -1
- package/dist/test-utils/process/reserve-port.js +0 -41
- package/dist/test-utils/process/reserve-port.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,65 @@
|
|
|
1
|
+
/** @file Private lifecycle composition for one registered endpoint daemon. */
|
|
2
|
+
import { NodeFileSystem } from "@effect/platform-node";
|
|
3
|
+
import { Effect } from "effect";
|
|
4
|
+
import packageJson from "../../../package.json" with { type: "json" };
|
|
5
|
+
import { noHistoryExport } from "../../endpoint/engine-types.js";
|
|
6
|
+
import { makeEndpointEngine } from "../../endpoint/engine.js";
|
|
7
|
+
import { makeRouterWorker } from "../../endpoint/router-worker/index.js";
|
|
8
|
+
import { acquireHarnessMcpHttpServer } from "../../harness-mcp-http.js";
|
|
9
|
+
import { makeHarnessMcpHttpHandler } from "../../harness-mcp-wire.js";
|
|
10
|
+
import { DaemonRuntimeError, prepareDaemonActivation, } from "./activation.js";
|
|
11
|
+
import { makeDaemonController } from "./controller.js";
|
|
12
|
+
import { makeHistoryExport } from "./history-export.js";
|
|
13
|
+
const DAEMON_IMPLEMENTATION = {
|
|
14
|
+
name: "moltzapd",
|
|
15
|
+
version: packageJson.version,
|
|
16
|
+
};
|
|
17
|
+
const productionDependencies = {
|
|
18
|
+
makeWorker: (input) => makeRouterWorker(input),
|
|
19
|
+
makeEngine: makeEndpointEngine,
|
|
20
|
+
makeHandler: makeHarnessMcpHttpHandler,
|
|
21
|
+
acquireListener: ({ port, handler }) => acquireHarnessMcpHttpServer({ port, handler }).pipe(Effect.asVoid),
|
|
22
|
+
makeHistoryExport: (path) => makeHistoryExport(path).pipe(Effect.provide(NodeFileSystem.layer)),
|
|
23
|
+
};
|
|
24
|
+
const runtimeFailure = (phase) => new DaemonRuntimeError({ phase });
|
|
25
|
+
/** Closed daemon startup and supervision failure. */
|
|
26
|
+
export { DaemonRuntimeError };
|
|
27
|
+
/**
|
|
28
|
+
* Run all daemon-owned protocol and MCP resources until a supervised failure.
|
|
29
|
+
* @param input Daemon-owned persistence and fixed endpoint configuration.
|
|
30
|
+
* @param input.store Durable endpoint store owned by this daemon process.
|
|
31
|
+
* @param input.bootstrap Validated identity, network, and listener configuration.
|
|
32
|
+
* @param dependencies Replaceable process edges used by focused lifecycle tests.
|
|
33
|
+
* @returns A scoped process effect that ends only when a supervised resource fails.
|
|
34
|
+
*/
|
|
35
|
+
export const runDaemonRuntime = (input, dependencies = productionDependencies) => Effect.gen(function* () {
|
|
36
|
+
const preparation = yield* prepareDaemonActivation(input);
|
|
37
|
+
const exportPath = input.bootstrap.configuration.historyExport;
|
|
38
|
+
const historyExport = exportPath === undefined
|
|
39
|
+
? noHistoryExport
|
|
40
|
+
: yield* dependencies.makeHistoryExport(exportPath);
|
|
41
|
+
const controller = yield* makeDaemonController({
|
|
42
|
+
...input,
|
|
43
|
+
historyExport,
|
|
44
|
+
management: preparation.management,
|
|
45
|
+
dependencies,
|
|
46
|
+
});
|
|
47
|
+
yield* controller.initializeAtStart(preparation.registration);
|
|
48
|
+
const handler = yield* dependencies
|
|
49
|
+
.makeHandler({
|
|
50
|
+
implementation: DAEMON_IMPLEMENTATION,
|
|
51
|
+
operations: controller.operations,
|
|
52
|
+
onSubscriptionActiveChange: controller.subscriptionChanged,
|
|
53
|
+
})
|
|
54
|
+
.pipe(Effect.mapError(() => runtimeFailure("storage")));
|
|
55
|
+
yield* controller.installHandler(handler);
|
|
56
|
+
yield* controller.runSubscriptions.pipe(Effect.forkScoped);
|
|
57
|
+
yield* dependencies
|
|
58
|
+
.acquireListener({
|
|
59
|
+
port: input.bootstrap.configuration.mcpPort,
|
|
60
|
+
handler,
|
|
61
|
+
})
|
|
62
|
+
.pipe(Effect.mapError(() => runtimeFailure("listener")));
|
|
63
|
+
return yield* controller.awaitFailure;
|
|
64
|
+
}).pipe(Effect.withSpan("runDaemonRuntime"));
|
|
65
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/daemon/runtime/index.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAK9E,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,MAAM,EAAc,MAAM,QAAQ,CAAC;AAG5C,OAAO,WAAW,MAAM,uBAAuB,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AACtE,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,uCAAuC,CAAC;AACzE,OAAO,EAAE,2BAA2B,EAAE,MAAM,2BAA2B,CAAC;AACxE,OAAO,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AACtE,OAAO,EAEL,kBAAkB,EAClB,uBAAuB,GACxB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD,MAAM,qBAAqB,GAAG;IAC5B,IAAI,EAAE,UAAU;IAChB,OAAO,EAAE,WAAW,CAAC,OAAO;CACJ,CAAC;AAE3B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CAAC;IACH,KAAK,CAAC,CAAC,UAAU,CAAC,iBAAiB,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC;IAC9D,MAAM,OAAO,GAAG,KAAK,CAAC,CAAC,YAAY;SAChC,WAAW,CAAC;QACX,cAAc,EAAE,qBAAqB;QACrC,UAAU,EAAE,UAAU,CAAC,UAAU;QACjC,0BAA0B,EAAE,UAAU,CAAC,mBAAmB;KAC3D,CAAC;SACD,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;IAC1D,KAAK,CAAC,CAAC,UAAU,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;IAC1C,KAAK,CAAC,CAAC,UAAU,CAAC,gBAAgB,CAAC,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IAC3D,KAAK,CAAC,CAAC,YAAY;SAChB,eAAe,CAAC;QACf,IAAI,EAAE,KAAK,CAAC,SAAS,CAAC,aAAa,CAAC,OAAO;QAC3C,OAAO;KACR,CAAC;SACD,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;IAC3D,OAAO,KAAK,CAAC,CAAC,UAAU,CAAC,YAAY,CAAC;AACxC,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,kBAAkB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/** @file Protocol acquisition, supervision, and pending-delivery reconciliation. */
|
|
2
|
+
import type { VerifiedAgentCard } from "@moltzap/identity";
|
|
3
|
+
import { Registry } from "@moltzap/identity/registry";
|
|
4
|
+
import { Router } from "@moltzap/router";
|
|
5
|
+
import { Cause, type Context, Deferred, Effect, Scope } from "effect";
|
|
6
|
+
import type { HistoryExportPort } from "../../endpoint/engine-types.js";
|
|
7
|
+
import type { EndpointEngine } from "../../endpoint/engine.js";
|
|
8
|
+
import type { EndpointStore } from "../../endpoint/store.js";
|
|
9
|
+
import type { DaemonBootstrap } from "../configuration.js";
|
|
10
|
+
import { type RouterWorker } from "../../endpoint/router-worker/index.js";
|
|
11
|
+
import { DaemonActivationError, type DaemonRuntimeDependencies, DaemonRuntimeError } from "./activation.js";
|
|
12
|
+
/** Subscription publisher installed after the MCP handler is acquired. */
|
|
13
|
+
export type RuntimeSubscriptionHandler = Effect.Effect.Success<ReturnType<DaemonRuntimeDependencies["makeHandler"]>>;
|
|
14
|
+
/** Engine and Router worker active for the daemon's immutable identity. */
|
|
15
|
+
interface ActiveProtocol {
|
|
16
|
+
readonly agentCard: VerifiedAgentCard;
|
|
17
|
+
readonly worker: RouterWorker;
|
|
18
|
+
readonly engine: EndpointEngine;
|
|
19
|
+
}
|
|
20
|
+
/** Mutable controller state shared with supervised protocol resources. */
|
|
21
|
+
export interface ProtocolState {
|
|
22
|
+
activeProtocol?: ActiveProtocol;
|
|
23
|
+
subscriptionActive: boolean;
|
|
24
|
+
handler?: RuntimeSubscriptionHandler;
|
|
25
|
+
readonly publishedDeliveries: Set<string>;
|
|
26
|
+
}
|
|
27
|
+
/** Dependencies and owned resources available to one protocol lifecycle. */
|
|
28
|
+
export interface ProtocolEnvironment {
|
|
29
|
+
readonly store: EndpointStore;
|
|
30
|
+
readonly bootstrap: DaemonBootstrap;
|
|
31
|
+
readonly historyExport: HistoryExportPort;
|
|
32
|
+
readonly dependencies: DaemonRuntimeDependencies;
|
|
33
|
+
readonly registry: Context.Tag.Service<typeof Registry>;
|
|
34
|
+
readonly router: Context.Tag.Service<typeof Router>;
|
|
35
|
+
readonly daemonScope: Scope.Scope;
|
|
36
|
+
readonly fatal: Deferred.Deferred<never, DaemonRuntimeError>;
|
|
37
|
+
readonly state: ProtocolState;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Publish newly durable messages while one active native subscriber exists.
|
|
41
|
+
* @param environment Protocol resources and controller-owned delivery state.
|
|
42
|
+
* @param deliveryGate Serializes pending reads with subscription changes.
|
|
43
|
+
* @returns Completion after every currently publishable delivery is offered.
|
|
44
|
+
*/
|
|
45
|
+
export declare const publishPendingMessages: (environment: ProtocolEnvironment, deliveryGate: Effect.Semaphore) => Effect.Effect<void>;
|
|
46
|
+
/**
|
|
47
|
+
* Propagate interruption and convert other background failures to daemon failure.
|
|
48
|
+
* @param fatal Process-wide failure signal.
|
|
49
|
+
* @param cause Background fiber cause to classify.
|
|
50
|
+
* @returns An effect that preserves interruption or waits after signaling fatal.
|
|
51
|
+
*/
|
|
52
|
+
export declare const failFromBackgroundCause: <E>(fatal: Deferred.Deferred<never, DaemonRuntimeError>, cause: Cause.Cause<E>) => Effect.Effect<never, E>;
|
|
53
|
+
/**
|
|
54
|
+
* Acquire and supervise the protocol resources for one immutable daemon identity.
|
|
55
|
+
* @param environment Daemon-owned dependencies and resource scope.
|
|
56
|
+
* @param activationGate Serializes registration and restart activation.
|
|
57
|
+
* @param reconciler Publishes durable pending deliveries after transitions.
|
|
58
|
+
* @param agentCard Verified local identity to activate.
|
|
59
|
+
* @returns Completion after engine and worker fibers are running.
|
|
60
|
+
*/
|
|
61
|
+
export declare const initializeProtocol: (environment: ProtocolEnvironment, activationGate: Effect.Semaphore, reconciler: Effect.Effect<void>, agentCard: VerifiedAgentCard) => Effect.Effect<void, DaemonActivationError>;
|
|
62
|
+
export {};
|
|
63
|
+
//# sourceMappingURL=protocol.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../../../src/daemon/runtime/protocol.ts"],"names":[],"mappings":"AAAA,oFAAoF;AAEpF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AACtD,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,KAAK,O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,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,QAAQ,CAAC,CAAC;IACxD,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,MAAM,CAAC,CAAC;IACpD,QAAQ,CAAC,WAAW,EAAE,KAAK,CAAC,KAAK,CAAC;IAClC,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,QAAQ,CAAC,KAAK,EAAE,kBAAkB,CAAC,CAAC;IAC7D,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC;CAC/B;AA4BD;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,gBACpB,mBAAmB,gBAClB,MAAM,CAAC,SAAS,KAC7B,MAAM,CAAC,MAAM,CAAC,IAAI,CAmClB,CAAC;AAEJ;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,GAAI,CAAC,SAChC,QAAQ,CAAC,QAAQ,CAAC,KAAK,EAAE,kBAAkB,CAAC,SAC5C,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,KACpB,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAOxB,CAAC;AAmHF;;;;;;;GAOG;AACH,eAAO,MAAM,kBAAkB,gBAChB,mBAAmB,kBAChB,MAAM,CAAC,SAAS,cACpB,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,aACpB,iBAAiB,KAC3B,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,qBAAqB,CAuCI,CAAC"}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/** @file Protocol acquisition, supervision, and pending-delivery reconciliation. */
|
|
2
|
+
import { Registry } from "@moltzap/identity/registry";
|
|
3
|
+
import { Router } from "@moltzap/router";
|
|
4
|
+
import { Cause, Deferred, Effect, Scope } from "effect";
|
|
5
|
+
import { decodeOuterBody } from "../../endpoint/representation.js";
|
|
6
|
+
import { RouterWorkerPayloadInvalidError, } from "../../endpoint/router-worker/index.js";
|
|
7
|
+
import { DaemonActivationError, DaemonRuntimeError, recoverPinnedSenderCards, } from "./activation.js";
|
|
8
|
+
const signStructurallyValidAction = () => Effect.succeed("sign");
|
|
9
|
+
const activationFailure = (reason) => new DaemonActivationError({ reason });
|
|
10
|
+
const runtimeFailure = (phase) => new DaemonRuntimeError({ phase });
|
|
11
|
+
const mapWorkerInitializationError = (error) => activationFailure(error._tag === "RouterWorkerTransportError" ? "upstream" : "representation");
|
|
12
|
+
/**
|
|
13
|
+
* Publish newly durable messages while one active native subscriber exists.
|
|
14
|
+
* @param environment Protocol resources and controller-owned delivery state.
|
|
15
|
+
* @param deliveryGate Serializes pending reads with subscription changes.
|
|
16
|
+
* @returns Completion after every currently publishable delivery is offered.
|
|
17
|
+
*/
|
|
18
|
+
export const publishPendingMessages = (environment, deliveryGate) => deliveryGate.withPermits(1)(Effect.suspend(() => {
|
|
19
|
+
const protocol = environment.state.activeProtocol;
|
|
20
|
+
if (!environment.state.subscriptionActive || protocol === undefined) {
|
|
21
|
+
return Effect.void;
|
|
22
|
+
}
|
|
23
|
+
return protocol.engine.readPendingMessages().pipe(Effect.flatMap((messages) => Effect.sync(() => {
|
|
24
|
+
const handler = environment.state.handler;
|
|
25
|
+
if (handler === undefined) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
for (const pending of messages) {
|
|
29
|
+
if (environment.state.publishedDeliveries.has(pending.deliveryToken)) {
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
const event = pending;
|
|
33
|
+
if (!handler.publish(event)) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
environment.state.publishedDeliveries.add(pending.deliveryToken);
|
|
37
|
+
}
|
|
38
|
+
})), Effect.catchAll(() => Deferred.fail(environment.fatal, runtimeFailure("storage")).pipe(Effect.asVoid)));
|
|
39
|
+
}));
|
|
40
|
+
/**
|
|
41
|
+
* Propagate interruption and convert other background failures to daemon failure.
|
|
42
|
+
* @param fatal Process-wide failure signal.
|
|
43
|
+
* @param cause Background fiber cause to classify.
|
|
44
|
+
* @returns An effect that preserves interruption or waits after signaling fatal.
|
|
45
|
+
*/
|
|
46
|
+
export const failFromBackgroundCause = (fatal, cause) => {
|
|
47
|
+
if (Cause.isInterruptedOnly(cause)) {
|
|
48
|
+
return Effect.failCause(cause);
|
|
49
|
+
}
|
|
50
|
+
return Deferred.fail(fatal, runtimeFailure("listener")).pipe(Effect.zipRight(Effect.never));
|
|
51
|
+
};
|
|
52
|
+
const superviseBackground = (environment, effect) => effect.pipe(Effect.catchAllCause((cause) => failFromBackgroundCause(environment.fatal, cause)), Effect.interruptible, Effect.forkIn(environment.daemonScope), Effect.asVoid);
|
|
53
|
+
const makeWorkerCallbacks = (awaitEngine, publishPending) => ({
|
|
54
|
+
pinSenderCard: () => awaitEngine.pipe(Effect.asVoid),
|
|
55
|
+
decodePayload: (message) => decodeOuterBody(message.body).pipe(Effect.catchTag("ClientRepresentationError", () => Effect.fail(new RouterWorkerPayloadInvalidError()))),
|
|
56
|
+
acceptPayload: (ingress) => awaitEngine.pipe(Effect.flatMap((engine) => engine.acceptRouterIngress(ingress)), Effect.tap(() => publishPending)),
|
|
57
|
+
acceptRecoveryPayload: (ingress) => awaitEngine.pipe(Effect.flatMap((engine) => engine.acceptRecoveryIngress(ingress)), Effect.tap(() => publishPending)),
|
|
58
|
+
abandonVolatileFolds: (reason) => awaitEngine.pipe(Effect.flatMap((engine) => engine.abandonVolatileFolds(reason))),
|
|
59
|
+
recoverCertifiedHistory: (recovery) => awaitEngine.pipe(Effect.flatMap((engine) => engine.recoverCertifiedHistory(recovery)), Effect.tap(() => publishPending)),
|
|
60
|
+
});
|
|
61
|
+
const acquireProtocolWorker = (input) => input.environment.dependencies
|
|
62
|
+
.makeWorker({
|
|
63
|
+
callerAgentId: input.agentCard.agentId,
|
|
64
|
+
callerAgentCard: input.agentCard,
|
|
65
|
+
pinnedSenderCards: input.pinnedSenderCards,
|
|
66
|
+
signingAuthority: input.environment.bootstrap.signingAuthority,
|
|
67
|
+
outbox: input.environment.store,
|
|
68
|
+
callbacks: makeWorkerCallbacks(input.awaitEngine, input.publishPending),
|
|
69
|
+
})
|
|
70
|
+
.pipe(Effect.provideService(Registry, input.environment.registry), Effect.provideService(Router, input.environment.router), Effect.mapError(mapWorkerInitializationError));
|
|
71
|
+
const mapEngineInitializationError = (error) => activationFailure(error.reason === "identity" ? "representation" : error.reason);
|
|
72
|
+
const acquireProtocolEngine = (environment, agentCard, worker) => environment.dependencies
|
|
73
|
+
.makeEngine({
|
|
74
|
+
localAgentCard: agentCard,
|
|
75
|
+
signingAuthority: environment.bootstrap.signingAuthority,
|
|
76
|
+
registrySignerPublicKey: environment.bootstrap.configuration.registrySignerPublicKey,
|
|
77
|
+
registry: environment.registry,
|
|
78
|
+
store: environment.store,
|
|
79
|
+
routerWorker: worker,
|
|
80
|
+
actionPolicy: signStructurallyValidAction,
|
|
81
|
+
historyExport: environment.historyExport,
|
|
82
|
+
})
|
|
83
|
+
.pipe(Scope.extend(environment.daemonScope), Effect.mapError(mapEngineInitializationError));
|
|
84
|
+
const checkExistingProtocol = (agentCard, activeProtocol) => {
|
|
85
|
+
if (activeProtocol === undefined) {
|
|
86
|
+
return Effect.succeed(false);
|
|
87
|
+
}
|
|
88
|
+
if (activeProtocol.agentCard.agentId !== agentCard.agentId ||
|
|
89
|
+
activeProtocol.agentCard.publicKey.x !== agentCard.publicKey.x) {
|
|
90
|
+
return Effect.fail(activationFailure("representation"));
|
|
91
|
+
}
|
|
92
|
+
return Effect.succeed(true);
|
|
93
|
+
};
|
|
94
|
+
const retainActiveProtocol = (state, protocol) => {
|
|
95
|
+
state.activeProtocol = protocol;
|
|
96
|
+
};
|
|
97
|
+
/**
|
|
98
|
+
* Acquire and supervise the protocol resources for one immutable daemon identity.
|
|
99
|
+
* @param environment Daemon-owned dependencies and resource scope.
|
|
100
|
+
* @param activationGate Serializes registration and restart activation.
|
|
101
|
+
* @param reconciler Publishes durable pending deliveries after transitions.
|
|
102
|
+
* @param agentCard Verified local identity to activate.
|
|
103
|
+
* @returns Completion after engine and worker fibers are running.
|
|
104
|
+
*/
|
|
105
|
+
export const initializeProtocol = (environment, activationGate, reconciler, agentCard) => activationGate
|
|
106
|
+
.withPermits(1)(Effect.gen(function* () {
|
|
107
|
+
const alreadyActive = yield* checkExistingProtocol(agentCard, environment.state.activeProtocol);
|
|
108
|
+
if (alreadyActive) {
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
const pinnedSenderCards = yield* recoverPinnedSenderCards({
|
|
112
|
+
store: environment.store,
|
|
113
|
+
localAgentCard: agentCard,
|
|
114
|
+
bootstrap: environment.bootstrap,
|
|
115
|
+
});
|
|
116
|
+
const engineReady = yield* Deferred.make();
|
|
117
|
+
const awaitEngine = Deferred.await(engineReady);
|
|
118
|
+
const worker = yield* acquireProtocolWorker({
|
|
119
|
+
environment,
|
|
120
|
+
agentCard,
|
|
121
|
+
pinnedSenderCards,
|
|
122
|
+
awaitEngine,
|
|
123
|
+
publishPending: reconciler,
|
|
124
|
+
});
|
|
125
|
+
const engine = yield* acquireProtocolEngine(environment, agentCard, worker);
|
|
126
|
+
retainActiveProtocol(environment.state, { agentCard, worker, engine });
|
|
127
|
+
yield* Deferred.succeed(engineReady, engine);
|
|
128
|
+
yield* superviseBackground(environment, worker.run);
|
|
129
|
+
yield* superviseBackground(environment, engine.runOutbound);
|
|
130
|
+
yield* reconciler.pipe(Effect.mapError(() => activationFailure("upstream")));
|
|
131
|
+
}))
|
|
132
|
+
.pipe(Effect.withSpan("initializeProtocol"));
|
|
133
|
+
//# sourceMappingURL=protocol.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protocol.js","sourceRoot":"","sources":["../../../src/daemon/runtime/protocol.ts"],"names":[],"mappings":"AAAA,oFAAoF;AAGpF,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AACtD,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,KAAK,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CAAC,GAAG,EAAE,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAC,CACrD,CAAC;AACJ,CAAC,CAAC,CACH;KACA,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,oBAAoB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/** @file Private address resolution from runtime names to immutable cards. */
|
|
2
|
+
import type { Registry } from "@moltzap/identity/registry";
|
|
3
|
+
import { type VerifiedAgentCard } from "@moltzap/identity";
|
|
4
|
+
import { type Context, Effect } from "effect";
|
|
5
|
+
import { AgentAddress, GroupAddress, type MessageAddressInput, SendError } from "../../contract.js";
|
|
6
|
+
/** Minimal Registry capability required by address resolution. */
|
|
7
|
+
export type AddressRegistryPort = Pick<Context.Tag.Service<typeof Registry>, "lookup">;
|
|
8
|
+
/** Resolved deterministic membership for a direct destination. */
|
|
9
|
+
interface ResolvedDirectAddress {
|
|
10
|
+
readonly kind: "direct";
|
|
11
|
+
readonly address: AgentAddress;
|
|
12
|
+
readonly memberCards: readonly [VerifiedAgentCard, VerifiedAgentCard];
|
|
13
|
+
}
|
|
14
|
+
/** Resolved deterministic membership for a fixed group destination. */
|
|
15
|
+
interface ResolvedGroupAddress {
|
|
16
|
+
readonly kind: "group";
|
|
17
|
+
readonly address: GroupAddress;
|
|
18
|
+
readonly memberCards: readonly [
|
|
19
|
+
VerifiedAgentCard,
|
|
20
|
+
VerifiedAgentCard,
|
|
21
|
+
VerifiedAgentCard,
|
|
22
|
+
...VerifiedAgentCard[]
|
|
23
|
+
];
|
|
24
|
+
}
|
|
25
|
+
/** Address resolution retains both the runtime spelling and private cards. */
|
|
26
|
+
export type ResolvedMessageAddress = ResolvedDirectAddress | ResolvedGroupAddress;
|
|
27
|
+
interface ResolveMessageAddressInput {
|
|
28
|
+
readonly localAgentCard: VerifiedAgentCard;
|
|
29
|
+
readonly registry: AddressRegistryPort;
|
|
30
|
+
readonly to: MessageAddressInput;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Resolve one explicit runtime destination to canonical immutable membership.
|
|
34
|
+
* @param input Local verified identity, Registry lookup, and validated input.
|
|
35
|
+
* @returns The canonical runtime address and AgentId-ordered verified cards.
|
|
36
|
+
*/
|
|
37
|
+
export declare function resolveMessageAddress(input: ResolveMessageAddressInput): Effect.Effect<ResolvedMessageAddress, SendError>;
|
|
38
|
+
export {};
|
|
39
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/endpoint/addressing/index.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAE9E,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAa,KAAK,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtE,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,EAAU,MAAM,QAAQ,CAAC;AACtD,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,KAAK,mBAAmB,EACxB,SAAS,EACV,MAAM,mBAAmB,CAAC;AAO3B,kEAAkE;AAClE,MAAM,MAAM,mBAAmB,GAAG,IAAI,CACpC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,QAAQ,CAAC,EACpC,QAAQ,CACT,CAAC;AAEF,kEAAkE;AAClE,UAAU,qBAAqB;IAC7B,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,QAAQ,CAAC,OAAO,EAAE,YAAY,CAAC;IAC/B,QAAQ,CAAC,WAAW,EAAE,SAAS,CAAC,iBAAiB,EAAE,iBAAiB,CAAC,CAAC;CACvE;AAED,uEAAuE;AACvE,UAAU,oBAAoB;IAC5B,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,OAAO,EAAE,YAAY,CAAC;IAC/B,QAAQ,CAAC,WAAW,EAAE,SAAS;QAC7B,iBAAiB;QACjB,iBAAiB;QACjB,iBAAiB;QACjB,GAAG,iBAAiB,EAAE;KACvB,CAAC;CACH;AAED,8EAA8E;AAC9E,MAAM,MAAM,sBAAsB,GAC9B,qBAAqB,GACrB,oBAAoB,CAAC;AAEzB,UAAU,0BAA0B;IAClC,QAAQ,CAAC,cAAc,EAAE,iBAAiB,CAAC;IAC3C,QAAQ,CAAC,QAAQ,EAAE,mBAAmB,CAAC;IACvC,QAAQ,CAAC,EAAE,EAAE,mBAAmB,CAAC;CAClC;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,0BAA0B,GAChC,MAAM,CAAC,MAAM,CAAC,sBAAsB,EAAE,SAAS,CAAC,CAIlD"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/** @file Private address resolution from runtime names to immutable cards. */
|
|
2
|
+
import { AgentName } from "@moltzap/identity";
|
|
3
|
+
import { Effect, Schema } from "effect";
|
|
4
|
+
import { AgentAddress, GroupAddress, SendError, } from "../../contract.js";
|
|
5
|
+
import { compareAgentIds } from "../representation.js";
|
|
6
|
+
const AGENT_ADDRESS_PREFIX = "agent:";
|
|
7
|
+
const GROUP_ADDRESS_PREFIX = "group:";
|
|
8
|
+
const MAXIMUM_GROUP_MEMBERS = 32;
|
|
9
|
+
/**
|
|
10
|
+
* Resolve one explicit runtime destination to canonical immutable membership.
|
|
11
|
+
* @param input Local verified identity, Registry lookup, and validated input.
|
|
12
|
+
* @returns The canonical runtime address and AgentId-ordered verified cards.
|
|
13
|
+
*/
|
|
14
|
+
export function resolveMessageAddress(input) {
|
|
15
|
+
return input.to.startsWith(AGENT_ADDRESS_PREFIX)
|
|
16
|
+
? resolveDirect(input)
|
|
17
|
+
: resolveGroup(input);
|
|
18
|
+
}
|
|
19
|
+
function invalidAddress() {
|
|
20
|
+
return new SendError({ reason: "invalid-address" });
|
|
21
|
+
}
|
|
22
|
+
function invalidMembership() {
|
|
23
|
+
return new SendError({ reason: "membership-invalid" });
|
|
24
|
+
}
|
|
25
|
+
function mapRegistryFailure(error) {
|
|
26
|
+
return new SendError({
|
|
27
|
+
reason: error._tag === "VersionMismatchError"
|
|
28
|
+
? "version-mismatch"
|
|
29
|
+
: "network-unavailable",
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
function compareAscii(left, right) {
|
|
33
|
+
const sharedLength = Math.min(left.length, right.length);
|
|
34
|
+
for (let index = 0; index < sharedLength; index += 1) {
|
|
35
|
+
const difference = left.charCodeAt(index) - right.charCodeAt(index);
|
|
36
|
+
if (difference !== 0) {
|
|
37
|
+
return difference;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return left.length - right.length;
|
|
41
|
+
}
|
|
42
|
+
function orderMemberCards(cards) {
|
|
43
|
+
const ordered = cards.slice();
|
|
44
|
+
ordered.sort((left, right) => compareAgentIds(left.agentId, right.agentId));
|
|
45
|
+
return ordered;
|
|
46
|
+
}
|
|
47
|
+
function decodeAgentName(value) {
|
|
48
|
+
return Schema.decodeUnknown(AgentName)(value).pipe(Effect.mapError(invalidAddress));
|
|
49
|
+
}
|
|
50
|
+
function lookupCard(registry, agentName) {
|
|
51
|
+
return registry.lookup({ agentName }).pipe(Effect.mapError(mapRegistryFailure), Effect.flatMap((result) => {
|
|
52
|
+
if (result.kind === "not_found") {
|
|
53
|
+
return Effect.fail(new SendError({ reason: "unknown-agent" }));
|
|
54
|
+
}
|
|
55
|
+
return result.agentCard.agentName === agentName
|
|
56
|
+
? Effect.succeed(result.agentCard)
|
|
57
|
+
: Effect.fail(new SendError({ reason: "unknown-agent" }));
|
|
58
|
+
}));
|
|
59
|
+
}
|
|
60
|
+
function resolveDirect(input) {
|
|
61
|
+
return Effect.gen(function* () {
|
|
62
|
+
const agentName = yield* decodeAgentName(input.to.slice(AGENT_ADDRESS_PREFIX.length));
|
|
63
|
+
if (agentName === input.localAgentCard.agentName) {
|
|
64
|
+
return yield* invalidMembership();
|
|
65
|
+
}
|
|
66
|
+
const remoteCard = yield* lookupCard(input.registry, agentName);
|
|
67
|
+
const ordered = orderMemberCards([input.localAgentCard, remoteCard]);
|
|
68
|
+
const first = ordered[0];
|
|
69
|
+
const second = ordered[1];
|
|
70
|
+
if (first === undefined || second === undefined) {
|
|
71
|
+
return yield* Effect.dieMessage("direct membership lost a member");
|
|
72
|
+
}
|
|
73
|
+
const address = yield* Schema.decodeUnknown(AgentAddress)(input.to).pipe(Effect.mapError(invalidAddress));
|
|
74
|
+
return {
|
|
75
|
+
kind: "direct",
|
|
76
|
+
address,
|
|
77
|
+
memberCards: [first, second],
|
|
78
|
+
};
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
function resolveGroup(input) {
|
|
82
|
+
return Effect.gen(function* () {
|
|
83
|
+
const explicitNames = yield* Effect.forEach(input.to.slice(GROUP_ADDRESS_PREFIX.length).split(","), decodeAgentName, { concurrency: 1 });
|
|
84
|
+
if (new Set(explicitNames).size !== explicitNames.length) {
|
|
85
|
+
return yield* invalidMembership();
|
|
86
|
+
}
|
|
87
|
+
const completeNames = explicitNames.includes(input.localAgentCard.agentName)
|
|
88
|
+
? explicitNames
|
|
89
|
+
: [...explicitNames, input.localAgentCard.agentName];
|
|
90
|
+
if (completeNames.length < 3 ||
|
|
91
|
+
completeNames.length > MAXIMUM_GROUP_MEMBERS) {
|
|
92
|
+
return yield* invalidMembership();
|
|
93
|
+
}
|
|
94
|
+
const resolved = yield* Effect.forEach(completeNames, (agentName) => agentName === input.localAgentCard.agentName
|
|
95
|
+
? Effect.succeed(input.localAgentCard)
|
|
96
|
+
: lookupCard(input.registry, agentName), { concurrency: 1 });
|
|
97
|
+
const ordered = orderMemberCards(resolved);
|
|
98
|
+
const first = ordered[0];
|
|
99
|
+
const second = ordered[1];
|
|
100
|
+
const third = ordered[2];
|
|
101
|
+
if (first === undefined || second === undefined || third === undefined) {
|
|
102
|
+
return yield* Effect.dieMessage("group membership lost a member");
|
|
103
|
+
}
|
|
104
|
+
const canonicalNames = completeNames.slice();
|
|
105
|
+
canonicalNames.sort(compareAscii);
|
|
106
|
+
const address = yield* Schema.decodeUnknown(GroupAddress)(`${GROUP_ADDRESS_PREFIX}${canonicalNames.join(",")}`).pipe(Effect.mapError(invalidAddress));
|
|
107
|
+
return {
|
|
108
|
+
kind: "group",
|
|
109
|
+
address,
|
|
110
|
+
memberCards: [first, second, third, ...ordered.slice(3)],
|
|
111
|
+
};
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/endpoint/addressing/index.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAG9E,OAAO,EAAE,SAAS,EAA0B,MAAM,mBAAmB,CAAC;AACtE,OAAO,EAAgB,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACtD,OAAO,EACL,YAAY,EACZ,YAAY,EAEZ,SAAS,GACV,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,MAAM,oBAAoB,GAAG,QAAQ,CAAC;AACtC,MAAM,oBAAoB,GAAG,QAAQ,CAAC;AACtC,MAAM,qBAAqB,GAAG,EAAE,CAAC;AAsCjC;;;;GAIG;AACH,MAAM,UAAU,qBAAqB,CACnC,KAAiC;IAEjC,OAAO,KAAK,CAAC,EAAE,CAAC,UAAU,CAAC,oBAAoB,CAAC;QAC9C,CAAC,CAAC,aAAa,CAAC,KAAK,CAAC;QACtB,CAAC,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;AAC1B,CAAC;AAED,SAAS,cAAc;IACrB,OAAO,IAAI,SAAS,CAAC,EAAE,MAAM,EAAE,iBAAiB,EAAE,CAAC,CAAC;AACtD,CAAC;AAED,SAAS,iBAAiB;IACxB,OAAO,IAAI,SAAS,CAAC,EAAE,MAAM,EAAE,oBAAoB,EAAE,CAAC,CAAC;AACzD,CAAC;AAED,SAAS,kBAAkB,CAAC,KAAgC;IAC1D,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
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** @file Recovery of durable certified-record dissemination obligations. */
|
|
2
|
+
import { Effect } from "effect";
|
|
3
|
+
import type { EngineRuntime } from "./engine-types.js";
|
|
4
|
+
import { RouterWorkerPersistenceError } from "./router-worker/index.js";
|
|
5
|
+
/**
|
|
6
|
+
* Attach every durable certification obligation that lacks an outer envelope.
|
|
7
|
+
* @param runtime Recovered engine state and durable protocol dependencies.
|
|
8
|
+
* @returns Completion after every obligation has one exact retained outbox row.
|
|
9
|
+
*/
|
|
10
|
+
export declare function resumeDisseminationObligations(runtime: EngineRuntime): Effect.Effect<void, RouterWorkerPersistenceError>;
|
|
11
|
+
//# sourceMappingURL=engine-dissemination.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engine-dissemination.d.ts","sourceRoot":"","sources":["../../src/endpoint/engine-dissemination.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAE5E,OAAO,EAAE,MAAM,EAAU,MAAM,QAAQ,CAAC;AACxC,OAAO,KAAK,EAAoB,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAazE,OAAO,EAAE,4BAA4B,EAAE,MAAM,0BAA0B,CAAC;AAOxE;;;;GAIG;AACH,wBAAgB,8BAA8B,CAC5C,OAAO,EAAE,aAAa,GACrB,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,4BAA4B,CAAC,CAanD"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/** @file Recovery of durable certified-record dissemination obligations. */
|
|
2
|
+
import { Effect, Schema } from "effect";
|
|
3
|
+
import { makeActionCertifiedRecord, recordAnchorHash, } from "./engine-durability.js";
|
|
4
|
+
import { queueCertifiedPacket } from "./engine-send.js";
|
|
5
|
+
import { ConversationId, RecordHash, } from "./representation.js";
|
|
6
|
+
import { RouterWorkerPersistenceError } from "./router-worker/index.js";
|
|
7
|
+
/**
|
|
8
|
+
* Attach every durable certification obligation that lacks an outer envelope.
|
|
9
|
+
* @param runtime Recovered engine state and durable protocol dependencies.
|
|
10
|
+
* @returns Completion after every obligation has one exact retained outbox row.
|
|
11
|
+
*/
|
|
12
|
+
export function resumeDisseminationObligations(runtime) {
|
|
13
|
+
return runtime.gate.withPermits(1)(runtime.input.store.recover().pipe(Effect.mapError(persistenceFailure), Effect.flatMap((recovery) => Effect.forEach(recovery.disseminationObligations, (obligation) => attachObligation(runtime, obligation), { concurrency: 1, discard: true }))));
|
|
14
|
+
}
|
|
15
|
+
function attachObligation(runtime, obligation) {
|
|
16
|
+
return Effect.gen(function* () {
|
|
17
|
+
const { fold, recordHash } = yield* obligationFold(runtime, obligation);
|
|
18
|
+
const packet = yield* packetForObligation(fold, obligation, recordHash);
|
|
19
|
+
yield* Effect.uninterruptible(queueCertifiedPacket(runtime, fold.conversation, packet).pipe(Effect.mapError(persistenceFailure), Effect.zipRight(markQueued(fold, obligation.kind))));
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
function obligationFold(runtime, obligation) {
|
|
23
|
+
return Effect.all({
|
|
24
|
+
conversationId: Schema.decodeUnknown(ConversationId)(obligation.conversationId).pipe(Effect.mapError(persistenceFailure)),
|
|
25
|
+
recordHash: Schema.decodeUnknown(RecordHash)(obligation.recordHash).pipe(Effect.mapError(persistenceFailure)),
|
|
26
|
+
}).pipe(Effect.flatMap(({ conversationId, recordHash }) => {
|
|
27
|
+
const fold = runtime.recordFolds.get(recordHash);
|
|
28
|
+
return fold !== undefined &&
|
|
29
|
+
fold.conversation.conversationId === conversationId &&
|
|
30
|
+
fold.recordHash === recordHash
|
|
31
|
+
? Effect.succeed({ fold, recordHash })
|
|
32
|
+
: Effect.fail(persistenceFailure());
|
|
33
|
+
}));
|
|
34
|
+
}
|
|
35
|
+
function packetForObligation(fold, obligation, recordHash) {
|
|
36
|
+
switch (obligation.kind) {
|
|
37
|
+
case "action-certified-record":
|
|
38
|
+
return recordAnchorHash(fold).pipe(Effect.mapError(persistenceFailure), Effect.flatMap((anchorHash) => makeActionCertifiedRecord(fold, anchorHash).pipe(Effect.mapError(persistenceFailure))), Effect.filterOrFail((record) => record.recordHash === recordHash, persistenceFailure));
|
|
39
|
+
case "certified-record": {
|
|
40
|
+
const record = fold.certifiedRecord;
|
|
41
|
+
return record !== undefined &&
|
|
42
|
+
record.actionCertifiedRecord.recordHash === recordHash
|
|
43
|
+
? Effect.succeed(record)
|
|
44
|
+
: Effect.fail(persistenceFailure());
|
|
45
|
+
}
|
|
46
|
+
default: {
|
|
47
|
+
const exhaustive = obligation.kind;
|
|
48
|
+
return exhaustive;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
function markQueued(fold, kind) {
|
|
53
|
+
return Effect.sync(() => {
|
|
54
|
+
switch (kind) {
|
|
55
|
+
case "action-certified-record":
|
|
56
|
+
fold.actionCertifiedRecordQueued = true;
|
|
57
|
+
return;
|
|
58
|
+
case "certified-record":
|
|
59
|
+
fold.certifiedRecordQueued = true;
|
|
60
|
+
return;
|
|
61
|
+
default: {
|
|
62
|
+
const exhaustive = kind;
|
|
63
|
+
return exhaustive;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
function persistenceFailure() {
|
|
69
|
+
return new RouterWorkerPersistenceError();
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=engine-dissemination.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engine-dissemination.js","sourceRoot":"","sources":["../../src/endpoint/engine-dissemination.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAE5E,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGxC,OAAO,EACL,yBAAyB,EACzB,gBAAgB,GACjB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAGL,cAAc,EACd,UAAU,GACX,MAAM,qBAAqB,CAAC;AAC7B,OAAO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EAAE,CAAC,MAAM,CAAC,UAAU,KAAK,UAAU,EAC5C,kBAAkB,CACnB,CACF,CAAC;QACJ,KAAK,kBAAkB,EAAE,CAAC;YACxB,MAAM,MAAM,GAAG,IAAI,CAAC,eAAe,CAAC;YACpC,OAAO,MAAM,KAAK,SAAS;gBACzB,MAAM,CAAC,qBAAqB,CAAC,UAAU,KAAK,UAAU;gBACtD,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC;gBACxB,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,kBAAkB,EAAE,CAAC,CAAC;QACxC,CAAC;QACD,SAAS,CAAC;YACR,MAAM,UAAU,GAAU,UAAU,CAAC,IAAI,CAAC;YAC1C,OAAO,UAAU,CAAC;QACpB,CAAC;IACH,CAAC;AACH,CAAC;AAED,SAAS,UAAU,CACjB,IAAsB,EACtB,IAAqC;IAErC,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE;QACtB,QAAQ,IAAI,EAAE,CAAC;YACb,KAAK,yBAAyB;gBAC5B,IAAI,CAAC,2BAA2B,GAAG,IAAI,CAAC;gBACxC,OAAO;YACT,KAAK,kBAAkB;gBACrB,IAAI,CAAC,qBAAqB,GAAG,IAAI,CAAC;gBAClC,OAAO;YACT,SAAS,CAAC;gBACR,MAAM,UAAU,GAAU,IAAI,CAAC;gBAC/B,OAAO,UAAU,CAAC;YACpB,CAAC;QACH,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC;AAED,SAAS,kBAAkB;IACzB,OAAO,IAAI,4BAA4B,EAAE,CAAC;AAC5C,CAAC"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/** @file Record certification, evidence persistence, and host projection. */
|
|
2
|
+
import { type AgentId, SignedMessage } from "@moltzap/identity";
|
|
3
|
+
import { Effect } from "effect";
|
|
4
|
+
import type { EngineActionFold, EngineConversation, EngineRuntime } from "./engine-types.js";
|
|
5
|
+
import type { InboundDeliveryInput, ProtocolEvidence, StagedRecord, CertifiedRecord as StoredCertifiedRecord } from "./store.js";
|
|
6
|
+
import { type InboundMessage as InboundMessageValue } from "../contract.js";
|
|
7
|
+
import { type ActionCertifiedRecord, type AnchorHash, type CertifiedRecord, ClientRepresentationError, type RecordCore } from "./representation.js";
|
|
8
|
+
/**
|
|
9
|
+
* Resolve the immutable Router anchor bound when one action fold is created.
|
|
10
|
+
* @param fold Selected action and its action-specific Router anchor.
|
|
11
|
+
* @returns The canonical anchor hash committed by the record core.
|
|
12
|
+
*/
|
|
13
|
+
export declare const recordAnchorHash: (fold: EngineActionFold) => Effect.Effect<AnchorHash, ClientRepresentationError>;
|
|
14
|
+
/**
|
|
15
|
+
* Convert one verified inner signature into its durable evidence row.
|
|
16
|
+
* @param conversationId Private conversation that owns the evidence.
|
|
17
|
+
* @param kind Evidence statement family retained by the store.
|
|
18
|
+
* @param subjectId Hash named by the evidence statement.
|
|
19
|
+
* @param message Verified self-addressed evidence message.
|
|
20
|
+
* @returns Canonical durable evidence without changing its signer bytes.
|
|
21
|
+
*/
|
|
22
|
+
export declare const protocolEvidence: (conversationId: string, kind: ProtocolEvidence["kind"], subjectId: string, message: SignedMessage) => Effect.Effect<ProtocolEvidence, ClientRepresentationError>;
|
|
23
|
+
/**
|
|
24
|
+
* Build the action-certified record after its threshold is reached.
|
|
25
|
+
* @param fold In-memory fold containing verified action evidence.
|
|
26
|
+
* @param anchorHash Completed anchor bound by the record core.
|
|
27
|
+
* @returns One evidence-independent record core with its action certificate.
|
|
28
|
+
*/
|
|
29
|
+
export declare const makeActionCertifiedRecord: (fold: EngineActionFold, anchorHash: RecordCore["anchorHash"]) => Effect.Effect<ActionCertifiedRecord, ClientRepresentationError>;
|
|
30
|
+
/**
|
|
31
|
+
* Add a durability certificate without changing the certified record hash.
|
|
32
|
+
* @param actionCertifiedRecord Action-certified core being finalized.
|
|
33
|
+
* @param fold In-memory fold containing verified durability evidence.
|
|
34
|
+
* @returns One complete certified record with mergeable durability votes.
|
|
35
|
+
*/
|
|
36
|
+
export declare const makeCertifiedRecord: (actionCertifiedRecord: ActionCertifiedRecord, fold: EngineActionFold) => Effect.Effect<CertifiedRecord, ClientRepresentationError>;
|
|
37
|
+
/**
|
|
38
|
+
* Convert one verified record core to the store's evidence-free staging row.
|
|
39
|
+
* @param record Verified action-certified record from the protocol fold.
|
|
40
|
+
* @returns Canonical evidence-free row used for atomic staging.
|
|
41
|
+
*/
|
|
42
|
+
export declare const stagedRecord: (record: ActionCertifiedRecord) => Effect.Effect<StagedRecord, ClientRepresentationError>;
|
|
43
|
+
/**
|
|
44
|
+
* Convert a complete wire record into one complete store promotion row.
|
|
45
|
+
* @param record Complete certified wire record.
|
|
46
|
+
* @param fold In-memory fold retaining verified signer messages.
|
|
47
|
+
* @returns Store promotion data with separate action and durability evidence.
|
|
48
|
+
*/
|
|
49
|
+
export declare const storedCertifiedRecord: (record: CertifiedRecord, fold: EngineActionFold) => Effect.Effect<StoredCertifiedRecord, ClientRepresentationError>;
|
|
50
|
+
/** The store's canonical pending delivery beside the message it encodes. */
|
|
51
|
+
export interface InboundDeliveryProjection {
|
|
52
|
+
readonly input: InboundDeliveryInput;
|
|
53
|
+
readonly message: InboundMessageValue;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Encode the remote projection atomically retained during promotion.
|
|
57
|
+
* The recipient is the local agent that owns the pending delivery, which
|
|
58
|
+
* `AgentId` cannot express and nothing here checks. The result carries both
|
|
59
|
+
* the canonical input that record promotion commits atomically and the
|
|
60
|
+
* decoded message it was encoded from.
|
|
61
|
+
*/
|
|
62
|
+
export declare const inboundDelivery: (conversation: EngineConversation, record: CertifiedRecord, recipientAgentId: AgentId) => Effect.Effect<InboundDeliveryProjection, ClientRepresentationError>;
|
|
63
|
+
/**
|
|
64
|
+
* Record one durable inbound delivery in the history export: exactly the
|
|
65
|
+
* host-visible message the store now holds. When no export is configured the
|
|
66
|
+
* no-op port records nothing.
|
|
67
|
+
*/
|
|
68
|
+
export declare const exportInbound: (runtime: EngineRuntime, message: InboundMessageValue) => Effect.Effect<void>;
|
|
69
|
+
//# sourceMappingURL=engine-durability.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engine-durability.d.ts","sourceRoot":"","sources":["../../src/endpoint/engine-durability.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAE7E,OAAO,EACL,KAAK,OAAO,EAEZ,aAAa,EACd,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAY,MAAM,EAAU,MAAM,QAAQ,CAAC;AAClD,OAAO,KAAK,EACV,gBAAgB,EAChB,kBAAkB,EAClB,aAAa,EACd,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EACV,oBAAoB,EACpB,gBAAgB,EAChB,YAAY,EACZ,eAAe,IAAI,qBAAqB,EACzC,MAAM,YAAY,CAAC;AACpB,OAAO,EAIL,KAAK,cAAc,IAAI,mBAAmB,EAC3C,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,KAAK,qBAAqB,EAC1B,KAAK,UAAU,EACf,KAAK,eAAe,EACpB,yBAAyB,EAKzB,KAAK,UAAU,EAEhB,MAAM,qBAAqB,CAAC;AA2B7B;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,SACrB,gBAAgB,KACrB,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE,yBAAyB,CAGV,CAAC;AA0B7C;;;;;;;GAOG;AACH,eAAO,MAAM,gBAAgB,mBACX,MAAM,QAChB,gBAAgB,CAAC,MAAM,CAAC,aACnB,MAAM,WACR,aAAa,KACrB,MAAM,CAAC,MAAM,CAAC,gBAAgB,EAAE,yBAAyB,CASzD,CAAC;AAEJ;;;;;GAKG;AACH,eAAO,MAAM,yBAAyB,SAC9B,gBAAgB,cACV,UAAU,CAAC,YAAY,CAAC,KACnC,MAAM,CAAC,MAAM,CAAC,qBAAqB,EAAE,yBAAyB,CAyBV,CAAC;AAExD;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,0BACP,qBAAqB,QACtC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