@rikalabs/akter 0.1.0-alpha.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/CHANGELOG.md +15 -0
- package/LICENSE +202 -0
- package/NOTICE +8 -0
- package/README.md +116 -0
- package/dist/actor/codecs.d.ts +77 -0
- package/dist/actor/codecs.js +87 -0
- package/dist/actor/connections.d.ts +34 -0
- package/dist/actor/connections.js +145 -0
- package/dist/actor/definition.d.ts +893 -0
- package/dist/actor/definition.js +147 -0
- package/dist/actor/descriptor.d.ts +172 -0
- package/dist/actor/descriptor.js +367 -0
- package/dist/actor/handles.d.ts +77 -0
- package/dist/actor/handles.js +265 -0
- package/dist/actor/jobs.d.ts +10 -0
- package/dist/actor/jobs.js +137 -0
- package/dist/actor/layers.d.ts +41 -0
- package/dist/actor/layers.js +177 -0
- package/dist/actor/reads.d.ts +47 -0
- package/dist/actor/reads.js +224 -0
- package/dist/actor/served.d.ts +120 -0
- package/dist/actor/served.js +72 -0
- package/dist/actor/turns.d.ts +13 -0
- package/dist/actor/turns.js +332 -0
- package/dist/actor/workflows.d.ts +16 -0
- package/dist/actor/workflows.js +37 -0
- package/dist/client/calls.d.ts +47 -0
- package/dist/client/calls.js +425 -0
- package/dist/client/clock.d.ts +56 -0
- package/dist/client/clock.js +119 -0
- package/dist/client/fleet-page.d.ts +15 -0
- package/dist/client/fleet-page.js +13 -0
- package/dist/client/fleet.d.ts +29 -0
- package/dist/client/fleet.js +51 -0
- package/dist/client/index.d.ts +17 -0
- package/dist/client/index.js +6 -0
- package/dist/client/make.d.ts +157 -0
- package/dist/client/make.js +221 -0
- package/dist/client/offline/queue.d.ts +118 -0
- package/dist/client/offline/queue.js +292 -0
- package/dist/client/offline/store.d.ts +74 -0
- package/dist/client/offline/store.js +78 -0
- package/dist/client/optimistic.d.ts +57 -0
- package/dist/client/optimistic.js +136 -0
- package/dist/client/report.d.ts +2 -0
- package/dist/client/report.js +8 -0
- package/dist/client/sessions/connection.d.ts +118 -0
- package/dist/client/sessions/connection.js +162 -0
- package/dist/client/sessions/feed.d.ts +42 -0
- package/dist/client/sessions/feed.js +43 -0
- package/dist/client/sessions/sse.d.ts +47 -0
- package/dist/client/sessions/sse.js +112 -0
- package/dist/client/sessions/stream.d.ts +28 -0
- package/dist/client/sessions/stream.js +35 -0
- package/dist/client/sessions/watch.d.ts +34 -0
- package/dist/client/sessions/watch.js +40 -0
- package/dist/client/transport.d.ts +37 -0
- package/dist/client/transport.js +66 -0
- package/dist/contexts/command.d.ts +132 -0
- package/dist/contexts/command.js +20 -0
- package/dist/contexts/connection.d.ts +68 -0
- package/dist/contexts/connection.js +0 -0
- package/dist/contexts/job.d.ts +49 -0
- package/dist/contexts/job.js +0 -0
- package/dist/contexts/workflow.d.ts +147 -0
- package/dist/contexts/workflow.js +22 -0
- package/dist/errors/actor.d.ts +200 -0
- package/dist/errors/actor.js +271 -0
- package/dist/errors/content.d.ts +19 -0
- package/dist/errors/content.js +14 -0
- package/dist/errors/database.d.ts +22 -0
- package/dist/errors/database.js +23 -0
- package/dist/errors/events.d.ts +17 -0
- package/dist/errors/events.js +14 -0
- package/dist/errors/subscription.d.ts +12 -0
- package/dist/errors/subscription.js +8 -0
- package/dist/errors/workflow.d.ts +28 -0
- package/dist/errors/workflow.js +17 -0
- package/dist/handles/actors.d.ts +17 -0
- package/dist/handles/actors.js +7 -0
- package/dist/handles/content.d.ts +59 -0
- package/dist/handles/content.js +36 -0
- package/dist/handles/intents.d.ts +164 -0
- package/dist/handles/intents.js +214 -0
- package/dist/handles/run.d.ts +31 -0
- package/dist/handles/run.js +21 -0
- package/dist/handles/workflow.d.ts +27 -0
- package/dist/handles/workflow.js +23 -0
- package/dist/identity/caller.d.ts +105 -0
- package/dist/identity/caller.js +68 -0
- package/dist/identity/child.d.ts +18 -0
- package/dist/identity/child.js +39 -0
- package/dist/identity/command.d.ts +19 -0
- package/dist/identity/command.js +21 -0
- package/dist/identity/connection.d.ts +24 -0
- package/dist/identity/connection.js +29 -0
- package/dist/identity/content.d.ts +18 -0
- package/dist/identity/content.js +12 -0
- package/dist/identity/digest.d.ts +4 -0
- package/dist/identity/digest.js +5 -0
- package/dist/identity/execution.d.ts +32 -0
- package/dist/identity/execution.js +63 -0
- package/dist/identity/mint.d.ts +51 -0
- package/dist/identity/mint.js +76 -0
- package/dist/identity/version.d.ts +2 -0
- package/dist/identity/version.js +3 -0
- package/dist/index.d.ts +159 -0
- package/dist/index.js +97 -0
- package/dist/members/blob.d.ts +43 -0
- package/dist/members/blob.js +29 -0
- package/dist/members/command.d.ts +109 -0
- package/dist/members/command.js +61 -0
- package/dist/members/connection.d.ts +55 -0
- package/dist/members/connection.js +49 -0
- package/dist/members/event.d.ts +36 -0
- package/dist/members/event.js +24 -0
- package/dist/members/job.d.ts +157 -0
- package/dist/members/job.js +67 -0
- package/dist/members/payload.d.ts +93 -0
- package/dist/members/payload.js +145 -0
- package/dist/members/reducer.d.ts +64 -0
- package/dist/members/reducer.js +27 -0
- package/dist/members/stream.d.ts +36 -0
- package/dist/members/stream.js +14 -0
- package/dist/members/subscription.d.ts +182 -0
- package/dist/members/subscription.js +91 -0
- package/dist/members/workflow.d.ts +99 -0
- package/dist/members/workflow.js +2 -0
- package/dist/policies/access.d.ts +35 -0
- package/dist/policies/access.js +6 -0
- package/dist/policies/command.d.ts +127 -0
- package/dist/policies/command.js +45 -0
- package/dist/policies/job.d.ts +28 -0
- package/dist/policies/job.js +60 -0
- package/dist/policies/schedules.d.ts +33 -0
- package/dist/policies/schedules.js +131 -0
- package/dist/protocol/frames.d.ts +66 -0
- package/dist/protocol/frames.js +55 -0
- package/dist/protocol/inspection.d.ts +807 -0
- package/dist/protocol/inspection.js +243 -0
- package/dist/protocol/wire.d.ts +184 -0
- package/dist/protocol/wire.js +150 -0
- package/dist/runtime/actors.d.ts +155 -0
- package/dist/runtime/actors.js +4 -0
- package/dist/runtime/admission.d.ts +34 -0
- package/dist/runtime/admission.js +72 -0
- package/dist/runtime/adoption/backfill.d.ts +27 -0
- package/dist/runtime/adoption/backfill.js +144 -0
- package/dist/runtime/adoption/enforce.d.ts +55 -0
- package/dist/runtime/adoption/enforce.js +241 -0
- package/dist/runtime/adoption/observe.d.ts +43 -0
- package/dist/runtime/adoption/observe.js +139 -0
- package/dist/runtime/adoption/plan.d.ts +45 -0
- package/dist/runtime/adoption/plan.js +192 -0
- package/dist/runtime/adoption/startup.d.ts +32 -0
- package/dist/runtime/adoption/startup.js +76 -0
- package/dist/runtime/adoption/status.d.ts +23 -0
- package/dist/runtime/adoption/status.js +47 -0
- package/dist/runtime/adoption/target.d.ts +33 -0
- package/dist/runtime/adoption/target.js +49 -0
- package/dist/runtime/connections/holder.d.ts +221 -0
- package/dist/runtime/connections/holder.js +816 -0
- package/dist/runtime/connections/owner.d.ts +263 -0
- package/dist/runtime/connections/owner.js +896 -0
- package/dist/runtime/connections/protocol.d.ts +441 -0
- package/dist/runtime/connections/protocol.js +222 -0
- package/dist/runtime/connections/reads.d.ts +24 -0
- package/dist/runtime/connections/reads.js +19 -0
- package/dist/runtime/connections/streams.d.ts +62 -0
- package/dist/runtime/connections/streams.js +128 -0
- package/dist/runtime/connections/transport.d.ts +40 -0
- package/dist/runtime/connections/transport.js +68 -0
- package/dist/runtime/connections/watch.d.ts +52 -0
- package/dist/runtime/connections/watch.js +159 -0
- package/dist/runtime/content/grant.d.ts +34 -0
- package/dist/runtime/content/grant.js +58 -0
- package/dist/runtime/content/store.d.ts +63 -0
- package/dist/runtime/content/store.js +294 -0
- package/dist/runtime/cron/key.d.ts +2 -0
- package/dist/runtime/cron/key.js +2 -0
- package/dist/runtime/cron/schedule.d.ts +69 -0
- package/dist/runtime/cron/schedule.js +144 -0
- package/dist/runtime/database/bounded.d.ts +43 -0
- package/dist/runtime/database/bounded.js +108 -0
- package/dist/runtime/database/connection.d.ts +8 -0
- package/dist/runtime/database/connection.js +18 -0
- package/dist/runtime/database/coordination.d.ts +19 -0
- package/dist/runtime/database/coordination.js +72 -0
- package/dist/runtime/database/flock.d.ts +10 -0
- package/dist/runtime/database/flock.js +60 -0
- package/dist/runtime/database/gate.d.ts +26 -0
- package/dist/runtime/database/gate.js +54 -0
- package/dist/runtime/database/keepalive.d.ts +11 -0
- package/dist/runtime/database/keepalive.js +22 -0
- package/dist/runtime/database/migrations.d.ts +177 -0
- package/dist/runtime/database/migrations.js +1018 -0
- package/dist/runtime/database/neki/migrations.d.ts +31 -0
- package/dist/runtime/database/neki/migrations.js +276 -0
- package/dist/runtime/database/neki/session.d.ts +23 -0
- package/dist/runtime/database/neki/session.js +31 -0
- package/dist/runtime/database/pglite.d.ts +21 -0
- package/dist/runtime/database/pglite.js +74 -0
- package/dist/runtime/database/replica.d.ts +41 -0
- package/dist/runtime/database/replica.js +51 -0
- package/dist/runtime/database/shards.d.ts +21 -0
- package/dist/runtime/database/shards.js +37 -0
- package/dist/runtime/database/snapshot.d.ts +7 -0
- package/dist/runtime/database/snapshot.js +7 -0
- package/dist/runtime/database/tenancy.d.ts +69 -0
- package/dist/runtime/database/tenancy.js +145 -0
- package/dist/runtime/database/transient.d.ts +10 -0
- package/dist/runtime/database/transient.js +25 -0
- package/dist/runtime/drain.d.ts +132 -0
- package/dist/runtime/drain.js +109 -0
- package/dist/runtime/entity/mailbox.d.ts +86 -0
- package/dist/runtime/entity/mailbox.js +121 -0
- package/dist/runtime/entity/register.d.ts +424 -0
- package/dist/runtime/entity/register.js +669 -0
- package/dist/runtime/events/append.d.ts +192 -0
- package/dist/runtime/events/append.js +128 -0
- package/dist/runtime/events/cursor.d.ts +2 -0
- package/dist/runtime/events/cursor.js +5 -0
- package/dist/runtime/events/replay.d.ts +20 -0
- package/dist/runtime/events/replay.js +45 -0
- package/dist/runtime/feeds.d.ts +26 -0
- package/dist/runtime/feeds.js +100 -0
- package/dist/runtime/fleet/checks.d.ts +17 -0
- package/dist/runtime/fleet/checks.js +106 -0
- package/dist/runtime/fleet/maintainer.d.ts +38 -0
- package/dist/runtime/fleet/maintainer.js +383 -0
- package/dist/runtime/fleet/pgoutput.d.ts +41 -0
- package/dist/runtime/fleet/pgoutput.js +102 -0
- package/dist/runtime/fleet/setup.d.ts +36 -0
- package/dist/runtime/fleet/setup.js +58 -0
- package/dist/runtime/fleet/subscribe.d.ts +42 -0
- package/dist/runtime/fleet/subscribe.js +147 -0
- package/dist/runtime/index.d.ts +66 -0
- package/dist/runtime/index.js +37 -0
- package/dist/runtime/inspector/http.d.ts +19 -0
- package/dist/runtime/inspector/http.js +36 -0
- package/dist/runtime/inspector/layer.d.ts +46 -0
- package/dist/runtime/inspector/layer.js +180 -0
- package/dist/runtime/inspector/queries.d.ts +711 -0
- package/dist/runtime/inspector/queries.js +494 -0
- package/dist/runtime/jobs/attempt.d.ts +254 -0
- package/dist/runtime/jobs/attempt.js +413 -0
- package/dist/runtime/jobs/isolation.d.ts +20 -0
- package/dist/runtime/jobs/isolation.js +10 -0
- package/dist/runtime/jobs/progress.d.ts +95 -0
- package/dist/runtime/jobs/progress.js +144 -0
- package/dist/runtime/layer.d.ts +260 -0
- package/dist/runtime/layer.js +876 -0
- package/dist/runtime/members.d.ts +381 -0
- package/dist/runtime/members.js +8 -0
- package/dist/runtime/operators/audit.d.ts +64 -0
- package/dist/runtime/operators/audit.js +56 -0
- package/dist/runtime/operators/auth.d.ts +29 -0
- package/dist/runtime/operators/auth.js +42 -0
- package/dist/runtime/operators/export.d.ts +68 -0
- package/dist/runtime/operators/export.js +137 -0
- package/dist/runtime/operators/grants.d.ts +45 -0
- package/dist/runtime/operators/grants.js +40 -0
- package/dist/runtime/operators/repair.d.ts +206 -0
- package/dist/runtime/operators/repair.js +226 -0
- package/dist/runtime/operators/routes.d.ts +35 -0
- package/dist/runtime/operators/routes.js +190 -0
- package/dist/runtime/operators/seed.d.ts +123 -0
- package/dist/runtime/operators/seed.js +123 -0
- package/dist/runtime/payloads/versions.d.ts +65 -0
- package/dist/runtime/payloads/versions.js +240 -0
- package/dist/runtime/peering/authority.d.ts +42 -0
- package/dist/runtime/peering/authority.js +132 -0
- package/dist/runtime/peering/credentials.d.ts +21 -0
- package/dist/runtime/peering/credentials.js +13 -0
- package/dist/runtime/peering/transport.d.ts +51 -0
- package/dist/runtime/peering/transport.js +175 -0
- package/dist/runtime/queries.d.ts +18 -0
- package/dist/runtime/queries.js +169 -0
- package/dist/runtime/readiness.d.ts +36 -0
- package/dist/runtime/readiness.js +44 -0
- package/dist/runtime/registration.d.ts +58 -0
- package/dist/runtime/registration.js +186 -0
- package/dist/runtime/request.d.ts +158 -0
- package/dist/runtime/request.js +102 -0
- package/dist/runtime/retry.d.ts +8 -0
- package/dist/runtime/retry.js +11 -0
- package/dist/runtime/runner.d.ts +93 -0
- package/dist/runtime/runner.js +122 -0
- package/dist/runtime/storage/codec.d.ts +39 -0
- package/dist/runtime/storage/codec.js +41 -0
- package/dist/runtime/storage/generation.d.ts +69 -0
- package/dist/runtime/storage/generation.js +49 -0
- package/dist/runtime/storage/placements.d.ts +15 -0
- package/dist/runtime/storage/placements.js +38 -0
- package/dist/runtime/storage/platform.d.ts +6 -0
- package/dist/runtime/storage/platform.js +9 -0
- package/dist/runtime/storage/retention.d.ts +73 -0
- package/dist/runtime/storage/retention.js +158 -0
- package/dist/runtime/subscriptions/identity.d.ts +31 -0
- package/dist/runtime/subscriptions/identity.js +45 -0
- package/dist/runtime/subscriptions/relay.d.ts +175 -0
- package/dist/runtime/subscriptions/relay.js +763 -0
- package/dist/runtime/subscriptions/storage.d.ts +40 -0
- package/dist/runtime/subscriptions/storage.js +98 -0
- package/dist/runtime/sweeps.d.ts +39 -0
- package/dist/runtime/sweeps.js +54 -0
- package/dist/runtime/telemetry/defects.d.ts +57 -0
- package/dist/runtime/telemetry/defects.js +43 -0
- package/dist/runtime/telemetry/metrics.d.ts +52 -0
- package/dist/runtime/telemetry/metrics.js +138 -0
- package/dist/runtime/telemetry/routes.d.ts +19 -0
- package/dist/runtime/telemetry/routes.js +18 -0
- package/dist/runtime/telemetry/sampler.d.ts +26 -0
- package/dist/runtime/telemetry/sampler.js +101 -0
- package/dist/runtime/telemetry/spans.d.ts +38 -0
- package/dist/runtime/telemetry/spans.js +44 -0
- package/dist/runtime/telemetry/usage.d.ts +52 -0
- package/dist/runtime/telemetry/usage.js +30 -0
- package/dist/runtime/topology/admission.d.ts +13 -0
- package/dist/runtime/topology/admission.js +36 -0
- package/dist/runtime/topology/locks.d.ts +56 -0
- package/dist/runtime/topology/locks.js +81 -0
- package/dist/runtime/topology/messages.d.ts +15 -0
- package/dist/runtime/topology/messages.js +32 -0
- package/dist/runtime/turn/admission.d.ts +22 -0
- package/dist/runtime/turn/admission.js +41 -0
- package/dist/runtime/turn/blobs.d.ts +38 -0
- package/dist/runtime/turn/blobs.js +215 -0
- package/dist/runtime/turn/execute.d.ts +208 -0
- package/dist/runtime/turn/execute.js +972 -0
- package/dist/runtime/turn/group.d.ts +165 -0
- package/dist/runtime/turn/group.js +326 -0
- package/dist/runtime/turn/hooks.d.ts +44 -0
- package/dist/runtime/turn/hooks.js +28 -0
- package/dist/runtime/turn/outbox.d.ts +159 -0
- package/dist/runtime/turn/outbox.js +269 -0
- package/dist/runtime/turn/pipeline.d.ts +68 -0
- package/dist/runtime/turn/pipeline.js +83 -0
- package/dist/runtime/turn/receipt.d.ts +81 -0
- package/dist/runtime/turn/receipt.js +32 -0
- package/dist/runtime/turn/relay.d.ts +179 -0
- package/dist/runtime/turn/relay.js +685 -0
- package/dist/runtime/turn/rows.d.ts +43 -0
- package/dist/runtime/turn/rows.js +592 -0
- package/dist/runtime/workflows/compatibility.d.ts +125 -0
- package/dist/runtime/workflows/compatibility.js +285 -0
- package/dist/runtime/workflows/engine.d.ts +107 -0
- package/dist/runtime/workflows/engine.js +826 -0
- package/dist/runtime/workflows/manifest.d.ts +34 -0
- package/dist/runtime/workflows/manifest.js +39 -0
- package/dist/runtime/workflows/steps.d.ts +33 -0
- package/dist/runtime/workflows/steps.js +152 -0
- package/dist/serve/api.d.ts +99 -0
- package/dist/serve/api.js +403 -0
- package/dist/serve/assertion/binding.d.ts +41 -0
- package/dist/serve/assertion/binding.js +92 -0
- package/dist/serve/assertion/verify.d.ts +93 -0
- package/dist/serve/assertion/verify.js +189 -0
- package/dist/serve/auth.d.ts +200 -0
- package/dist/serve/auth.js +92 -0
- package/dist/serve/clock.d.ts +10 -0
- package/dist/serve/clock.js +25 -0
- package/dist/serve/jwt.d.ts +65 -0
- package/dist/serve/jwt.js +202 -0
- package/dist/serve/layer.d.ts +98 -0
- package/dist/serve/layer.js +809 -0
- package/dist/serve/mcp/endpoint.d.ts +39 -0
- package/dist/serve/mcp/endpoint.js +187 -0
- package/dist/serve/mcp/tools.d.ts +37 -0
- package/dist/serve/mcp/tools.js +125 -0
- package/dist/serve/origin.d.ts +6 -0
- package/dist/serve/origin.js +21 -0
- package/dist/serve/sessions/feed.d.ts +79 -0
- package/dist/serve/sessions/feed.js +115 -0
- package/dist/serve/sessions/socket.d.ts +56 -0
- package/dist/serve/sessions/socket.js +212 -0
- package/dist/serve/sessions/sse.d.ts +27 -0
- package/dist/serve/sessions/sse.js +26 -0
- package/dist/serve/sessions/stream.d.ts +9 -0
- package/dist/serve/sessions/stream.js +9 -0
- package/dist/serve/sessions/watch.d.ts +12 -0
- package/dist/serve/sessions/watch.js +11 -0
- package/dist/serve/wire.d.ts +16 -0
- package/dist/serve/wire.js +50 -0
- package/dist/state/blob.d.ts +71 -0
- package/dist/state/blob.js +0 -0
- package/dist/state/migration.d.ts +53 -0
- package/dist/state/migration.js +29 -0
- package/dist/tables/fleet.d.ts +170 -0
- package/dist/tables/fleet.js +214 -0
- package/dist/tables/owned.d.ts +250 -0
- package/dist/tables/owned.js +233 -0
- package/dist/testing/actor-test.d.ts +360 -0
- package/dist/testing/actor-test.js +337 -0
- package/dist/testing/cluster.d.ts +93 -0
- package/dist/testing/cluster.js +296 -0
- package/dist/testing/conformance/access.d.ts +5 -0
- package/dist/testing/conformance/access.js +531 -0
- package/dist/testing/conformance/admission.d.ts +11 -0
- package/dist/testing/conformance/admission.js +182 -0
- package/dist/testing/conformance/adoption.d.ts +2 -0
- package/dist/testing/conformance/adoption.js +1019 -0
- package/dist/testing/conformance/assertions.d.ts +202 -0
- package/dist/testing/conformance/assertions.js +849 -0
- package/dist/testing/conformance/batches.d.ts +41 -0
- package/dist/testing/conformance/batches.js +388 -0
- package/dist/testing/conformance/blobs.d.ts +14 -0
- package/dist/testing/conformance/blobs.js +405 -0
- package/dist/testing/conformance/capacity.d.ts +8 -0
- package/dist/testing/conformance/capacity.js +433 -0
- package/dist/testing/conformance/client.d.ts +5 -0
- package/dist/testing/conformance/client.js +719 -0
- package/dist/testing/conformance/cold-serve.d.ts +16 -0
- package/dist/testing/conformance/cold-serve.js +254 -0
- package/dist/testing/conformance/connections/actors.d.ts +1143 -0
- package/dist/testing/conformance/connections/actors.js +180 -0
- package/dist/testing/conformance/connections/harness.d.ts +1754 -0
- package/dist/testing/conformance/connections/harness.js +142 -0
- package/dist/testing/conformance/connections/holders.d.ts +4 -0
- package/dist/testing/conformance/connections/holders.js +165 -0
- package/dist/testing/conformance/connections/lifecycle.d.ts +4 -0
- package/dist/testing/conformance/connections/lifecycle.js +113 -0
- package/dist/testing/conformance/connections/limits.d.ts +4 -0
- package/dist/testing/conformance/connections/limits.js +127 -0
- package/dist/testing/conformance/connections/reauthorization.d.ts +4 -0
- package/dist/testing/conformance/connections/reauthorization.js +170 -0
- package/dist/testing/conformance/connections/resync.d.ts +4 -0
- package/dist/testing/conformance/connections/resync.js +360 -0
- package/dist/testing/conformance/connections/takeover.d.ts +4 -0
- package/dist/testing/conformance/connections/takeover.js +287 -0
- package/dist/testing/conformance/connections.d.ts +4 -0
- package/dist/testing/conformance/connections.js +15 -0
- package/dist/testing/conformance/content-blobs.d.ts +16 -0
- package/dist/testing/conformance/content-blobs.js +534 -0
- package/dist/testing/conformance/counter.d.ts +16 -0
- package/dist/testing/conformance/counter.js +813 -0
- package/dist/testing/conformance/cron.d.ts +5 -0
- package/dist/testing/conformance/cron.js +665 -0
- package/dist/testing/conformance/drain.d.ts +26 -0
- package/dist/testing/conformance/drain.js +540 -0
- package/dist/testing/conformance/effect-control.d.ts +38 -0
- package/dist/testing/conformance/effect-control.js +1059 -0
- package/dist/testing/conformance/effects.d.ts +23 -0
- package/dist/testing/conformance/effects.js +432 -0
- package/dist/testing/conformance/events.d.ts +28 -0
- package/dist/testing/conformance/events.js +335 -0
- package/dist/testing/conformance/export.d.ts +2 -0
- package/dist/testing/conformance/export.js +368 -0
- package/dist/testing/conformance/fleet.d.ts +444 -0
- package/dist/testing/conformance/fleet.js +1009 -0
- package/dist/testing/conformance/groups.d.ts +7 -0
- package/dist/testing/conformance/groups.js +353 -0
- package/dist/testing/conformance/heap.d.ts +3 -0
- package/dist/testing/conformance/heap.js +149 -0
- package/dist/testing/conformance/http.d.ts +2809 -0
- package/dist/testing/conformance/http.js +1234 -0
- package/dist/testing/conformance/inspection-views.d.ts +8 -0
- package/dist/testing/conformance/inspection-views.js +272 -0
- package/dist/testing/conformance/inspector.d.ts +7 -0
- package/dist/testing/conformance/inspector.js +650 -0
- package/dist/testing/conformance/mint.d.ts +58 -0
- package/dist/testing/conformance/mint.js +692 -0
- package/dist/testing/conformance/multi-runner.d.ts +8 -0
- package/dist/testing/conformance/multi-runner.js +403 -0
- package/dist/testing/conformance/neki/plan.d.ts +19 -0
- package/dist/testing/conformance/neki/plan.js +30 -0
- package/dist/testing/conformance/observability.d.ts +3 -0
- package/dist/testing/conformance/observability.js +343 -0
- package/dist/testing/conformance/offline.d.ts +4 -0
- package/dist/testing/conformance/offline.js +474 -0
- package/dist/testing/conformance/operator-harness.d.ts +57 -0
- package/dist/testing/conformance/operator-harness.js +78 -0
- package/dist/testing/conformance/operator.d.ts +3 -0
- package/dist/testing/conformance/operator.js +379 -0
- package/dist/testing/conformance/outbox-cross-shard.d.ts +14 -0
- package/dist/testing/conformance/outbox-cross-shard.js +160 -0
- package/dist/testing/conformance/outbox.d.ts +36 -0
- package/dist/testing/conformance/outbox.js +437 -0
- package/dist/testing/conformance/payload-migrations.d.ts +3 -0
- package/dist/testing/conformance/payload-migrations.js +612 -0
- package/dist/testing/conformance/pipeline.d.ts +3 -0
- package/dist/testing/conformance/pipeline.js +1040 -0
- package/dist/testing/conformance/placement.d.ts +22 -0
- package/dist/testing/conformance/placement.js +539 -0
- package/dist/testing/conformance/platform.d.ts +40 -0
- package/dist/testing/conformance/platform.js +101 -0
- package/dist/testing/conformance/progress.d.ts +39 -0
- package/dist/testing/conformance/progress.js +666 -0
- package/dist/testing/conformance/properties.d.ts +6 -0
- package/dist/testing/conformance/properties.js +295 -0
- package/dist/testing/conformance/protocols.d.ts +4 -0
- package/dist/testing/conformance/protocols.js +618 -0
- package/dist/testing/conformance/provider/advertise.d.ts +21 -0
- package/dist/testing/conformance/provider/advertise.js +44 -0
- package/dist/testing/conformance/read-your-writes.d.ts +20 -0
- package/dist/testing/conformance/read-your-writes.js +192 -0
- package/dist/testing/conformance/reducers.d.ts +8 -0
- package/dist/testing/conformance/reducers.js +258 -0
- package/dist/testing/conformance/relay.d.ts +42 -0
- package/dist/testing/conformance/relay.js +1115 -0
- package/dist/testing/conformance/restore.d.ts +43 -0
- package/dist/testing/conformance/restore.js +341 -0
- package/dist/testing/conformance/retention.d.ts +14 -0
- package/dist/testing/conformance/retention.js +463 -0
- package/dist/testing/conformance/rls.d.ts +24 -0
- package/dist/testing/conformance/rls.js +576 -0
- package/dist/testing/conformance/simulation.d.ts +31 -0
- package/dist/testing/conformance/simulation.js +167 -0
- package/dist/testing/conformance/single-shard.d.ts +2 -0
- package/dist/testing/conformance/single-shard.js +125 -0
- package/dist/testing/conformance/singleton.d.ts +3 -0
- package/dist/testing/conformance/singleton.js +293 -0
- package/dist/testing/conformance/statements.d.ts +60 -0
- package/dist/testing/conformance/statements.js +108 -0
- package/dist/testing/conformance/streams.d.ts +7 -0
- package/dist/testing/conformance/streams.js +280 -0
- package/dist/testing/conformance/subscriptions/access.d.ts +4 -0
- package/dist/testing/conformance/subscriptions/access.js +98 -0
- package/dist/testing/conformance/subscriptions/actors.d.ts +4910 -0
- package/dist/testing/conformance/subscriptions/actors.js +372 -0
- package/dist/testing/conformance/subscriptions/cluster.d.ts +4 -0
- package/dist/testing/conformance/subscriptions/cluster.js +89 -0
- package/dist/testing/conformance/subscriptions/delivery.d.ts +4 -0
- package/dist/testing/conformance/subscriptions/delivery.js +253 -0
- package/dist/testing/conformance/subscriptions/deploys.d.ts +4 -0
- package/dist/testing/conformance/subscriptions/deploys.js +162 -0
- package/dist/testing/conformance/subscriptions/epochs.d.ts +4 -0
- package/dist/testing/conformance/subscriptions/epochs.js +169 -0
- package/dist/testing/conformance/subscriptions/failures.d.ts +4 -0
- package/dist/testing/conformance/subscriptions/failures.js +108 -0
- package/dist/testing/conformance/subscriptions/feeds.d.ts +4 -0
- package/dist/testing/conformance/subscriptions/feeds.js +218 -0
- package/dist/testing/conformance/subscriptions/harness.d.ts +124 -0
- package/dist/testing/conformance/subscriptions/harness.js +143 -0
- package/dist/testing/conformance/subscriptions/operator.d.ts +4 -0
- package/dist/testing/conformance/subscriptions/operator.js +128 -0
- package/dist/testing/conformance/subscriptions/retention.d.ts +4 -0
- package/dist/testing/conformance/subscriptions/retention.js +288 -0
- package/dist/testing/conformance/subscriptions/routing.d.ts +4 -0
- package/dist/testing/conformance/subscriptions/routing.js +179 -0
- package/dist/testing/conformance/subscriptions.d.ts +4 -0
- package/dist/testing/conformance/subscriptions.js +19 -0
- package/dist/testing/conformance/tables.d.ts +125 -0
- package/dist/testing/conformance/tables.js +664 -0
- package/dist/testing/conformance/transports/actors.d.ts +1907 -0
- package/dist/testing/conformance/transports/actors.js +163 -0
- package/dist/testing/conformance/transports/client.d.ts +3 -0
- package/dist/testing/conformance/transports/client.js +237 -0
- package/dist/testing/conformance/transports/feeds.d.ts +3 -0
- package/dist/testing/conformance/transports/feeds.js +232 -0
- package/dist/testing/conformance/transports/harness.d.ts +93 -0
- package/dist/testing/conformance/transports/harness.js +84 -0
- package/dist/testing/conformance/transports/streams.d.ts +3 -0
- package/dist/testing/conformance/transports/streams.js +96 -0
- package/dist/testing/conformance/transports/websocket.d.ts +3 -0
- package/dist/testing/conformance/transports/websocket.js +384 -0
- package/dist/testing/conformance/transports/wire.d.ts +141 -0
- package/dist/testing/conformance/transports/wire.js +204 -0
- package/dist/testing/conformance/transports.d.ts +3 -0
- package/dist/testing/conformance/transports.js +11 -0
- package/dist/testing/conformance/watch.d.ts +59 -0
- package/dist/testing/conformance/watch.js +879 -0
- package/dist/testing/conformance/workflow-engine.d.ts +97 -0
- package/dist/testing/conformance/workflow-engine.js +253 -0
- package/dist/testing/conformance/workflow-versions.d.ts +3 -0
- package/dist/testing/conformance/workflow-versions.js +545 -0
- package/dist/testing/conformance/workflows/access.d.ts +4 -0
- package/dist/testing/conformance/workflows/access.js +147 -0
- package/dist/testing/conformance/workflows/actors.d.ts +2317 -0
- package/dist/testing/conformance/workflows/actors.js +305 -0
- package/dist/testing/conformance/workflows/basics.d.ts +4 -0
- package/dist/testing/conformance/workflows/basics.js +144 -0
- package/dist/testing/conformance/workflows/engine.d.ts +4 -0
- package/dist/testing/conformance/workflows/engine.js +80 -0
- package/dist/testing/conformance/workflows/guards.d.ts +4 -0
- package/dist/testing/conformance/workflows/guards.js +172 -0
- package/dist/testing/conformance/workflows/harness.d.ts +14 -0
- package/dist/testing/conformance/workflows/harness.js +44 -0
- package/dist/testing/conformance/workflows/recovery.d.ts +4 -0
- package/dist/testing/conformance/workflows/recovery.js +181 -0
- package/dist/testing/conformance/workflows/starts.d.ts +4 -0
- package/dist/testing/conformance/workflows/starts.js +57 -0
- package/dist/testing/conformance/workflows/suspension.d.ts +4 -0
- package/dist/testing/conformance/workflows/suspension.js +106 -0
- package/dist/testing/conformance/workflows/waits.d.ts +4 -0
- package/dist/testing/conformance/workflows/waits.js +284 -0
- package/dist/testing/conformance/workflows.d.ts +4 -0
- package/dist/testing/conformance/workflows.js +19 -0
- package/dist/testing/conformance.d.ts +330 -0
- package/dist/testing/conformance.js +364 -0
- package/dist/testing/database.d.ts +31 -0
- package/dist/testing/database.js +70 -0
- package/dist/testing/foundation.d.ts +41 -0
- package/dist/testing/foundation.js +517 -0
- package/dist/testing/index.d.ts +20 -0
- package/dist/testing/index.js +12 -0
- package/dist/testing/property.d.ts +40 -0
- package/dist/testing/property.js +95 -0
- package/dist/testing/simulate-cluster.d.ts +112 -0
- package/dist/testing/simulate-cluster.js +257 -0
- package/dist/testing/simulate.d.ts +90 -0
- package/dist/testing/simulate.js +127 -0
- package/package.json +1 -0
|
@@ -0,0 +1,692 @@
|
|
|
1
|
+
import { Cause, Effect, Exit, Fiber, Layer, Schema } from "effect";
|
|
2
|
+
import { SqlClient } from "effect/sql";
|
|
3
|
+
import { Actor, Actors, CurrentCaller, Intent, NotCreated, System, Unauthorized, } from "../../index.js";
|
|
4
|
+
import { deriveMintId } from "../../identity/mint.js";
|
|
5
|
+
import { InternalActors } from "../../runtime/actors.js";
|
|
6
|
+
import { Outcome } from "../../runtime/request.js";
|
|
7
|
+
import { routingKey } from "../../runtime/storage/codec.js";
|
|
8
|
+
import { ActorTest } from "../actor-test.js";
|
|
9
|
+
import { enqueue, holding, transactions } from "./batches.js";
|
|
10
|
+
import { CLAIM_LEASE } from "./outbox.js";
|
|
11
|
+
class Refused extends Schema.TaggedError()("Refused", {}) {
|
|
12
|
+
}
|
|
13
|
+
const Open = Actor.command("Open", { payload: Schema.String, error: Refused });
|
|
14
|
+
const Title = Actor.command("Title", { success: Schema.String });
|
|
15
|
+
const childState = Actor.state({
|
|
16
|
+
title: Schema.String.pipe(Schema.withDecodingDefault(Effect.succeed(""))),
|
|
17
|
+
});
|
|
18
|
+
const Task = Actor.make("MintTask", {
|
|
19
|
+
state: childState,
|
|
20
|
+
api: { Open, Title },
|
|
21
|
+
createdBy: Open,
|
|
22
|
+
});
|
|
23
|
+
const Note = Actor.make("MintNote", {
|
|
24
|
+
placement: "actor",
|
|
25
|
+
state: Actor.state({
|
|
26
|
+
title: Schema.String.pipe(Schema.withDecodingDefault(Effect.succeed(""))),
|
|
27
|
+
opens: Schema.Int.pipe(Schema.withDecodingDefault(Effect.succeed(0))),
|
|
28
|
+
}),
|
|
29
|
+
api: { Open, Title },
|
|
30
|
+
createdBy: Open,
|
|
31
|
+
});
|
|
32
|
+
const Ids = Schema.Array(Schema.String);
|
|
33
|
+
const Plan = Actor.command("Plan", { payload: Schema.Int, success: Ids });
|
|
34
|
+
const PlanMixed = Actor.command("PlanMixed", { success: Ids });
|
|
35
|
+
const PlanLater = Actor.command("PlanLater", { success: Schema.String });
|
|
36
|
+
const PlanAcross = Actor.command("PlanAcross", { success: Schema.String });
|
|
37
|
+
const PlanThenRefuse = Actor.command("PlanThenRefuse", { error: Refused });
|
|
38
|
+
const PlanDelayed = Actor.command("PlanDelayed", { success: Ids });
|
|
39
|
+
const PlanDelayedThenRefuse = Actor.command("PlanDelayedThenRefuse", { error: Refused });
|
|
40
|
+
const PlanThenDie = Actor.command("PlanThenDie");
|
|
41
|
+
const PlanRefusedChild = Actor.command("PlanRefusedChild", { success: Schema.String });
|
|
42
|
+
const MintOnly = Actor.command("MintOnly");
|
|
43
|
+
const MintUnmintable = Actor.command("MintUnmintable");
|
|
44
|
+
const Escape = Actor.command("Escape");
|
|
45
|
+
const Steal = Actor.command("Steal");
|
|
46
|
+
const PlanKeyed = Actor.command("PlanKeyed");
|
|
47
|
+
const PlanStagedFirst = Actor.command("PlanStagedFirst", {
|
|
48
|
+
payload: Schema.String,
|
|
49
|
+
success: Schema.String,
|
|
50
|
+
});
|
|
51
|
+
const Planner = Actor.make("MintPlanner", {
|
|
52
|
+
key: Schema.String,
|
|
53
|
+
api: {
|
|
54
|
+
Plan,
|
|
55
|
+
PlanMixed,
|
|
56
|
+
PlanLater,
|
|
57
|
+
PlanAcross,
|
|
58
|
+
PlanThenRefuse,
|
|
59
|
+
PlanDelayed,
|
|
60
|
+
PlanDelayedThenRefuse,
|
|
61
|
+
PlanThenDie,
|
|
62
|
+
PlanRefusedChild,
|
|
63
|
+
MintOnly,
|
|
64
|
+
MintUnmintable,
|
|
65
|
+
Escape,
|
|
66
|
+
Steal,
|
|
67
|
+
PlanStagedFirst,
|
|
68
|
+
PlanKeyed,
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
const SoloPlan = Actor.command("SoloPlan", { success: Schema.String });
|
|
72
|
+
const SoloPlanner = Actor.make("MintSoloPlanner", { key: Actor.singleton, api: { SoloPlan } });
|
|
73
|
+
const Former = Actor.make("MintFormerChild", { state: childState, api: { Open, Title } });
|
|
74
|
+
const Job = Actor.make("MintNamedJob", {
|
|
75
|
+
key: Schema.String,
|
|
76
|
+
state: childState,
|
|
77
|
+
api: { Open, Title },
|
|
78
|
+
createdBy: Open,
|
|
79
|
+
});
|
|
80
|
+
const runs = [];
|
|
81
|
+
let escaped = Effect.succeed("");
|
|
82
|
+
const openTask = Effect.fnUntraced(function* (title) {
|
|
83
|
+
const id = yield* (yield* Planner.Turn).mint(Task);
|
|
84
|
+
yield* (yield* Task.intents(id)).Open(title);
|
|
85
|
+
return id;
|
|
86
|
+
});
|
|
87
|
+
const openNote = Effect.fnUntraced(function* (title) {
|
|
88
|
+
const id = yield* (yield* Planner.Turn).mint(Note);
|
|
89
|
+
yield* (yield* Note.intents(id)).Open(title);
|
|
90
|
+
return id;
|
|
91
|
+
});
|
|
92
|
+
export const mintLayer = Layer.mergeAll(Task.toLayer(Effect.succeed({
|
|
93
|
+
Open: Effect.fnUntraced(function* (title) {
|
|
94
|
+
yield* (yield* Task.Turn).state.set({ title });
|
|
95
|
+
if (title === "refuse")
|
|
96
|
+
return yield* Refused.make({});
|
|
97
|
+
}),
|
|
98
|
+
Title: Effect.fnUntraced(function* () {
|
|
99
|
+
return (yield* Task.Turn).state.title;
|
|
100
|
+
}),
|
|
101
|
+
})), Note.toLayer(Effect.succeed({
|
|
102
|
+
Open: Effect.fnUntraced(function* (title) {
|
|
103
|
+
const turn = yield* Note.Turn;
|
|
104
|
+
yield* turn.state.set({ title, opens: turn.state.opens + 1 });
|
|
105
|
+
}),
|
|
106
|
+
Title: Effect.fnUntraced(function* () {
|
|
107
|
+
return (yield* Note.Turn).state.title;
|
|
108
|
+
}),
|
|
109
|
+
})), Planner.toLayer(Effect.succeed({
|
|
110
|
+
Plan: Effect.fnUntraced(function* (count) {
|
|
111
|
+
const ids = [];
|
|
112
|
+
for (let index = 0; index < count; index++)
|
|
113
|
+
ids.push(yield* openTask(`task ${index}`));
|
|
114
|
+
runs.push(ids);
|
|
115
|
+
return ids;
|
|
116
|
+
}),
|
|
117
|
+
PlanMixed: Effect.fnUntraced(function* () {
|
|
118
|
+
const ids = [yield* openTask("task"), yield* openNote("note")];
|
|
119
|
+
return ids;
|
|
120
|
+
}),
|
|
121
|
+
PlanLater: Effect.fnUntraced(function* () {
|
|
122
|
+
const id = yield* (yield* Planner.Turn).mint(Task);
|
|
123
|
+
yield* (yield* Task.intents(id)).Open("later").pipe(Intent.after("1 hour"));
|
|
124
|
+
return id;
|
|
125
|
+
}),
|
|
126
|
+
PlanAcross: Effect.fnUntraced(function* () {
|
|
127
|
+
const id = yield* (yield* Planner.Turn).mint(Note);
|
|
128
|
+
yield* (yield* Note.intents(id)).Open("across").pipe(Intent.after("1 minute"));
|
|
129
|
+
return id;
|
|
130
|
+
}),
|
|
131
|
+
PlanThenRefuse: Effect.fnUntraced(function* () {
|
|
132
|
+
runs.push([yield* openTask("refused")]);
|
|
133
|
+
return yield* Refused.make({});
|
|
134
|
+
}),
|
|
135
|
+
PlanDelayed: Effect.fnUntraced(function* () {
|
|
136
|
+
const id = yield* (yield* Planner.Turn).mint(Task);
|
|
137
|
+
yield* (yield* Task.intents(id)).Open("delayed").pipe(Intent.after("1 hour"));
|
|
138
|
+
runs.push([id]);
|
|
139
|
+
return [id];
|
|
140
|
+
}),
|
|
141
|
+
PlanDelayedThenRefuse: Effect.fnUntraced(function* () {
|
|
142
|
+
const id = yield* (yield* Planner.Turn).mint(Task);
|
|
143
|
+
yield* (yield* Task.intents(id)).Open("delayed").pipe(Intent.after("1 hour"));
|
|
144
|
+
runs.push([id]);
|
|
145
|
+
return yield* Refused.make({});
|
|
146
|
+
}),
|
|
147
|
+
PlanThenDie: Effect.fnUntraced(function* () {
|
|
148
|
+
runs.push([yield* openTask("died")]);
|
|
149
|
+
return yield* Effect.die(new Error("Planner defect after minting"));
|
|
150
|
+
}),
|
|
151
|
+
PlanRefusedChild: () => openTask("refuse"),
|
|
152
|
+
MintOnly: Effect.fnUntraced(function* () {
|
|
153
|
+
yield* (yield* Planner.Turn).mint(Task);
|
|
154
|
+
}),
|
|
155
|
+
MintUnmintable: Effect.fnUntraced(function* () {
|
|
156
|
+
const unmintable = Planner;
|
|
157
|
+
yield* (yield* Planner.Turn).mint(unmintable);
|
|
158
|
+
}),
|
|
159
|
+
Escape: Effect.fnUntraced(function* () {
|
|
160
|
+
escaped = (yield* Planner.Turn).mint(Task);
|
|
161
|
+
}),
|
|
162
|
+
Steal: () => Effect.asVoid(Effect.suspend(() => escaped)),
|
|
163
|
+
PlanKeyed: Effect.fnUntraced(function* () {
|
|
164
|
+
const id = yield* (yield* Planner.Turn).mint(Task);
|
|
165
|
+
runs.push([id]);
|
|
166
|
+
yield* (yield* Task.intents(id)).Open("keyed").pipe(Intent.key("slot"));
|
|
167
|
+
}),
|
|
168
|
+
PlanStagedFirst: Effect.fnUntraced(function* (known) {
|
|
169
|
+
yield* (yield* Task.intents(known)).Open("staged first");
|
|
170
|
+
return yield* (yield* Planner.Turn).mint(Task);
|
|
171
|
+
}),
|
|
172
|
+
})), SoloPlanner.toLayer(Effect.succeed({
|
|
173
|
+
SoloPlan: Effect.fnUntraced(function* () {
|
|
174
|
+
const id = yield* (yield* SoloPlanner.Turn).mint(Task);
|
|
175
|
+
yield* (yield* Task.intents(id)).Open("solo");
|
|
176
|
+
return id;
|
|
177
|
+
}),
|
|
178
|
+
})), Job.toLayer(Effect.succeed({
|
|
179
|
+
Open: Effect.fnUntraced(function* (title) {
|
|
180
|
+
yield* (yield* Job.Turn).state.set({ title });
|
|
181
|
+
}),
|
|
182
|
+
Title: Effect.fnUntraced(function* () {
|
|
183
|
+
return (yield* Job.Turn).state.title;
|
|
184
|
+
}),
|
|
185
|
+
})), Former.toLayer(Effect.succeed({
|
|
186
|
+
Open: Effect.fnUntraced(function* (title) {
|
|
187
|
+
yield* (yield* Former.Turn).state.set({ title });
|
|
188
|
+
}),
|
|
189
|
+
Title: Effect.fnUntraced(function* () {
|
|
190
|
+
return (yield* Former.Turn).state.title;
|
|
191
|
+
}),
|
|
192
|
+
})));
|
|
193
|
+
const task = (id) => Task.get(id);
|
|
194
|
+
const note = (id) => Note.get(id);
|
|
195
|
+
const expected = (parent, commandId, ordinal, child = "MintTask") => deriveMintId({ parent, commandId, ordinal, child });
|
|
196
|
+
/** The System caller a parent's creating intent carries, rebuilt outside any turn. */
|
|
197
|
+
const proven = (parent, commandId, ordinal = 0) => System.make({ source: "actor", ref: parent, mint: { commandId, ordinal } });
|
|
198
|
+
/** Opens a task as `caller`, which the handle binds when it is acquired, and returns its failure. */
|
|
199
|
+
const openAs = (id, title, caller) => task(id).pipe(Effect.flatMap((child) => child.Open(title)), Effect.provideService(CurrentCaller, caller), Effect.flip);
|
|
200
|
+
const created = Effect.fnUntraced(function* (actor, id) {
|
|
201
|
+
const test = yield* ActorTest;
|
|
202
|
+
return yield* test.receiptsFor({ tenant: test.tenant, actor, id }, "Open");
|
|
203
|
+
});
|
|
204
|
+
/**
|
|
205
|
+
* Gives the last command enqueued behind a held turn time to finish its
|
|
206
|
+
* `queued` hook, which the batch waits for, so every waiting command is in
|
|
207
|
+
* the next batch.
|
|
208
|
+
*/
|
|
209
|
+
const settle = Effect.sleep("500 millis");
|
|
210
|
+
/** Plans one task whose creating intent is due in an hour, and returns the task's id. */
|
|
211
|
+
export const planLaterTask = (parent) => Planner.get(parent).pipe(Effect.flatMap((planner) => planner.PlanLater()));
|
|
212
|
+
/** The title of a created minted task. */
|
|
213
|
+
export const mintedTitle = (id) => task(id).pipe(Effect.flatMap((child) => child.Title()));
|
|
214
|
+
/** Mints one child from a tenant-placed planner, for the single-shard statement check. */
|
|
215
|
+
export const mintWorkload = Effect.gen(function* () {
|
|
216
|
+
yield* (yield* Planner.get("p-shard")).Plan(1);
|
|
217
|
+
}).pipe(Effect.orDie);
|
|
218
|
+
/** Selects a child in the opposite routing-key half from its tenant-placed parent. */
|
|
219
|
+
export const planAcrossShard = Effect.fnUntraced(function* (scenario) {
|
|
220
|
+
const planner = yield* Planner.get(scenario);
|
|
221
|
+
const actors = yield* Actors;
|
|
222
|
+
const parentKey = routingKey({ ref: planner.ref, placement: "tenant" });
|
|
223
|
+
for (let attempt = 0; attempt < 256; attempt++) {
|
|
224
|
+
const commandId = yield* actors.mintCommandId;
|
|
225
|
+
const id = yield* expected(planner.ref, commandId, 0, "MintNote");
|
|
226
|
+
const ref = { ...planner.ref, actor: "MintNote", id };
|
|
227
|
+
const childKey = routingKey({ ref, placement: "actor" });
|
|
228
|
+
if (parentKey < 0n === childKey < 0n)
|
|
229
|
+
continue;
|
|
230
|
+
yield* planner.PlanAcross().pipe(Actor.commandId(commandId));
|
|
231
|
+
return { planner, ref, parentKey, childKey, commandId };
|
|
232
|
+
}
|
|
233
|
+
return yield* Effect.die(new Error("No minted child in the opposite routing-key half"));
|
|
234
|
+
});
|
|
235
|
+
/** Minted-id cases: ids derive from the command id and ordinal, stay stable across a rerun after a crash, and create each child once. */
|
|
236
|
+
export const mintConformance = [
|
|
237
|
+
{
|
|
238
|
+
name: "creates a child across routing keys only from a committed relay delivery and replays it after a crash before outbox deletion",
|
|
239
|
+
run: ({ expect, environment, fixture }) => environment.run(Effect.gen(function* () {
|
|
240
|
+
const test = yield* ActorTest;
|
|
241
|
+
const internal = yield* InternalActors;
|
|
242
|
+
const { planner, ref, parentKey, childKey, commandId } = yield* planAcrossShard("cross-mint");
|
|
243
|
+
const caller = proven(planner.ref, commandId);
|
|
244
|
+
const forged = {
|
|
245
|
+
ref,
|
|
246
|
+
caller,
|
|
247
|
+
command: "Open",
|
|
248
|
+
commandId: yield* (yield* Actors).mintCommandId,
|
|
249
|
+
payload: yield* Schema.encodeEffect(Schema.fromJsonString(Schema.Struct({ value: Schema.String })))({ value: "forged" }),
|
|
250
|
+
};
|
|
251
|
+
const denied = { reason: Unauthorized.make({ code: "access_denied" }) };
|
|
252
|
+
expect(parentKey < 0n).toBe(childKey >= 0n);
|
|
253
|
+
expect(yield* internal.deliver(forged).pipe(Effect.flip)).toMatchObject(denied);
|
|
254
|
+
for (const intent of [
|
|
255
|
+
{ ...planner.ref, tenant: "another-tenant" },
|
|
256
|
+
{ ...planner.ref, actor: "MintSoloPlanner" },
|
|
257
|
+
{ ...planner.ref, id: "another-parent" },
|
|
258
|
+
])
|
|
259
|
+
expect(yield* internal.deliver({ ...forged, intent }).pipe(Effect.flip)).toMatchObject(denied);
|
|
260
|
+
expect(yield* internal.execute({ ...forged, intent: planner.ref }).pipe(Effect.flip)).toMatchObject(denied);
|
|
261
|
+
expect(yield* internal
|
|
262
|
+
.deliver({
|
|
263
|
+
...forged,
|
|
264
|
+
intent: planner.ref,
|
|
265
|
+
caller: proven(planner.ref, commandId, 1),
|
|
266
|
+
})
|
|
267
|
+
.pipe(Effect.flip)).toMatchObject(denied);
|
|
268
|
+
expect(yield* created(ref.actor, ref.id)).toBe(0);
|
|
269
|
+
yield* test.crashNext("beforeOutboxDelete");
|
|
270
|
+
const pause = yield* test.pauseNext("beforeOutboxDelete");
|
|
271
|
+
yield* test.advance("1 minute");
|
|
272
|
+
expect(yield* created(ref.actor, ref.id)).toBe(1);
|
|
273
|
+
expect(yield* test.inspect(ref)).toMatchObject({
|
|
274
|
+
state: { title: "across", opens: 1 },
|
|
275
|
+
receipts: 1,
|
|
276
|
+
});
|
|
277
|
+
expect(yield* test.inspect(planner.ref)).toMatchObject({ outbox: 1 });
|
|
278
|
+
const delivery = fixture.deliveries.get(ref.id);
|
|
279
|
+
expect(delivery.intent).toEqual(planner.ref);
|
|
280
|
+
expect(yield* internal.execute(delivery).pipe(Effect.flip)).toMatchObject(denied);
|
|
281
|
+
expect(yield* internal
|
|
282
|
+
.execute({
|
|
283
|
+
...forged,
|
|
284
|
+
commandId: yield* (yield* Actors).mintCommandId,
|
|
285
|
+
caller: System.make({ source: "process" }),
|
|
286
|
+
intent: planner.ref,
|
|
287
|
+
})
|
|
288
|
+
.pipe(Effect.flip)).toMatchObject(denied);
|
|
289
|
+
const draining = yield* test.advance(CLAIM_LEASE).pipe(Effect.forkChild);
|
|
290
|
+
yield* pause.reached;
|
|
291
|
+
expect(yield* created(ref.actor, ref.id)).toBe(1);
|
|
292
|
+
expect(yield* test.inspect(ref)).toMatchObject({
|
|
293
|
+
state: { title: "across", opens: 1 },
|
|
294
|
+
receipts: 1,
|
|
295
|
+
});
|
|
296
|
+
yield* pause.release;
|
|
297
|
+
yield* Fiber.join(draining);
|
|
298
|
+
expect(yield* test.inspect(planner.ref)).toMatchObject({ outbox: 0 });
|
|
299
|
+
expect(yield* internal.deliver(delivery)).toEqual(Outcome.cases.Success.make({ value: '{"value":null}' }));
|
|
300
|
+
expect(yield* created(ref.actor, ref.id)).toBe(1);
|
|
301
|
+
expect(yield* test.inspect(ref)).toMatchObject({
|
|
302
|
+
state: { title: "across", opens: 1 },
|
|
303
|
+
receipts: 1,
|
|
304
|
+
});
|
|
305
|
+
})),
|
|
306
|
+
},
|
|
307
|
+
{
|
|
308
|
+
name: "mints ids from the command id and ordinal and creates each child once from its intent",
|
|
309
|
+
run: ({ expect, environment }) => environment.run(Effect.gen(function* () {
|
|
310
|
+
const test = yield* ActorTest;
|
|
311
|
+
const planner = yield* Planner.get("derive");
|
|
312
|
+
const commandId = yield* (yield* Actors).mintCommandId;
|
|
313
|
+
const held = [yield* test.pauseNext("afterClaim"), yield* test.pauseNext("afterClaim")];
|
|
314
|
+
const ids = yield* planner.Plan(2).pipe(Actor.commandId(commandId));
|
|
315
|
+
expect(ids).toEqual([
|
|
316
|
+
yield* expected(planner.ref, commandId, 0),
|
|
317
|
+
yield* expected(planner.ref, commandId, 1),
|
|
318
|
+
]);
|
|
319
|
+
expect(new Set(ids).size).toBe(2);
|
|
320
|
+
for (const pause of held)
|
|
321
|
+
yield* pause.reached;
|
|
322
|
+
expect(yield* test.inspect(planner.ref)).toMatchObject({
|
|
323
|
+
receipts: 1,
|
|
324
|
+
outbox: 2,
|
|
325
|
+
});
|
|
326
|
+
for (const id of ids)
|
|
327
|
+
expect(yield* created("MintTask", id)).toBe(0);
|
|
328
|
+
for (const pause of held)
|
|
329
|
+
yield* pause.release;
|
|
330
|
+
yield* test.advance(0);
|
|
331
|
+
for (const [index, id] of ids.entries()) {
|
|
332
|
+
expect(yield* (yield* task(id)).Title()).toBe(`task ${index}`);
|
|
333
|
+
expect(yield* created("MintTask", id)).toBe(1);
|
|
334
|
+
}
|
|
335
|
+
expect(yield* test.inspect(planner.ref)).toMatchObject({ outbox: 0 });
|
|
336
|
+
expect(yield* planner.Plan(2).pipe(Actor.commandId(commandId))).toEqual(ids);
|
|
337
|
+
})),
|
|
338
|
+
},
|
|
339
|
+
{
|
|
340
|
+
name: "mints distinct ids per parent, per ordinal, and per child type from one command id",
|
|
341
|
+
run: ({ expect, environment }) => environment.run(Effect.gen(function* () {
|
|
342
|
+
const test = yield* ActorTest;
|
|
343
|
+
const commandId = yield* (yield* Actors).mintCommandId;
|
|
344
|
+
const first = yield* Planner.get("distinct-a");
|
|
345
|
+
const second = yield* Planner.get("distinct-b");
|
|
346
|
+
const a = yield* first.PlanMixed().pipe(Actor.commandId(commandId));
|
|
347
|
+
const b = yield* second.PlanMixed().pipe(Actor.commandId(commandId));
|
|
348
|
+
expect(a).toEqual([
|
|
349
|
+
yield* expected(first.ref, commandId, 0),
|
|
350
|
+
yield* expected(first.ref, commandId, 1, "MintNote"),
|
|
351
|
+
]);
|
|
352
|
+
expect(new Set([...a, ...b]).size).toBe(4);
|
|
353
|
+
yield* test.advance(0);
|
|
354
|
+
expect(yield* (yield* task(a[0])).Title()).toBe("task");
|
|
355
|
+
expect(yield* (yield* note(a[1])).Title()).toBe("note");
|
|
356
|
+
expect(yield* (yield* note(b[1])).Title()).toBe("note");
|
|
357
|
+
})),
|
|
358
|
+
},
|
|
359
|
+
{
|
|
360
|
+
name: "mints the same ids when a beforeCommit crash reruns the command",
|
|
361
|
+
run: ({ expect, environment }) => environment.run(Effect.gen(function* () {
|
|
362
|
+
const test = yield* ActorTest;
|
|
363
|
+
const planner = yield* Planner.get("crash-before");
|
|
364
|
+
const before = runs.length;
|
|
365
|
+
yield* test.crashNext("beforeCommit");
|
|
366
|
+
const ids = yield* planner.Plan(2);
|
|
367
|
+
expect(runs.slice(before)).toEqual([ids, ids]);
|
|
368
|
+
yield* test.advance(0);
|
|
369
|
+
for (const id of ids)
|
|
370
|
+
expect(yield* created("MintTask", id)).toBe(1);
|
|
371
|
+
expect(yield* test.inspect(planner.ref)).toMatchObject({
|
|
372
|
+
receipts: 1,
|
|
373
|
+
outbox: 0,
|
|
374
|
+
});
|
|
375
|
+
})),
|
|
376
|
+
},
|
|
377
|
+
{
|
|
378
|
+
name: "replays minted ids after an afterCommit crash and creates each child once",
|
|
379
|
+
run: ({ expect, environment }) => environment.run(Effect.gen(function* () {
|
|
380
|
+
const test = yield* ActorTest;
|
|
381
|
+
const planner = yield* Planner.get("crash-after");
|
|
382
|
+
const commandId = yield* (yield* Actors).mintCommandId;
|
|
383
|
+
const before = runs.length;
|
|
384
|
+
yield* test.crashNext("afterCommit");
|
|
385
|
+
const ids = yield* planner.Plan(2).pipe(Actor.commandId(commandId));
|
|
386
|
+
expect(yield* planner.Plan(2).pipe(Actor.commandId(commandId))).toEqual(ids);
|
|
387
|
+
expect(runs.slice(before)).toEqual([ids]);
|
|
388
|
+
yield* test.advance(0);
|
|
389
|
+
for (const id of ids)
|
|
390
|
+
expect(yield* created("MintTask", id)).toBe(1);
|
|
391
|
+
expect(yield* test.inspect(planner.ref)).toMatchObject({
|
|
392
|
+
receipts: 1,
|
|
393
|
+
outbox: 0,
|
|
394
|
+
});
|
|
395
|
+
})),
|
|
396
|
+
},
|
|
397
|
+
{
|
|
398
|
+
name: "mints per command when several commands wait at one parent",
|
|
399
|
+
run: ({ expect, environment }) => environment.run(Effect.gen(function* () {
|
|
400
|
+
const test = yield* ActorTest;
|
|
401
|
+
const planner = yield* Planner.get("queued");
|
|
402
|
+
const actors = yield* Actors;
|
|
403
|
+
const commandIds = [yield* actors.mintCommandId, yield* actors.mintCommandId];
|
|
404
|
+
const pause = yield* test.pauseNext("beforeCommit");
|
|
405
|
+
const first = yield* planner
|
|
406
|
+
.Plan(1)
|
|
407
|
+
.pipe(Actor.commandId(commandIds[0]), Effect.forkChild);
|
|
408
|
+
yield* pause.reached;
|
|
409
|
+
const second = yield* planner
|
|
410
|
+
.Plan(1)
|
|
411
|
+
.pipe(Actor.commandId(commandIds[1]), Effect.forkChild);
|
|
412
|
+
yield* pause.release;
|
|
413
|
+
expect(yield* Fiber.join(first)).toEqual([
|
|
414
|
+
yield* expected(planner.ref, commandIds[0], 0),
|
|
415
|
+
]);
|
|
416
|
+
expect(yield* Fiber.join(second)).toEqual([
|
|
417
|
+
yield* expected(planner.ref, commandIds[1], 0),
|
|
418
|
+
]);
|
|
419
|
+
})),
|
|
420
|
+
},
|
|
421
|
+
{
|
|
422
|
+
name: "turn batch: commands that mint share one transaction, mint the ids each would mint alone, and a declared failure in the batch creates no child",
|
|
423
|
+
requiresIndependentConnections: true,
|
|
424
|
+
timeoutMs: 60_000,
|
|
425
|
+
run: ({ expect, environment }) => environment.run(Effect.gen(function* () {
|
|
426
|
+
const test = yield* ActorTest;
|
|
427
|
+
const actors = yield* Actors;
|
|
428
|
+
const planner = yield* Planner.get("batch-shared");
|
|
429
|
+
const [lone, one, refused, two] = yield* Effect.forEach(Array.from({ length: 4 }), () => actors.mintCommandId);
|
|
430
|
+
const [loneChild, oneChild, rolledBack, twoChild] = yield* Effect.forEach([lone, one, refused, two], (id) => expected(planner.ref, id, 0));
|
|
431
|
+
yield* test.advance(0);
|
|
432
|
+
const before = runs.length;
|
|
433
|
+
const first = yield* holding(planner.PlanDelayed().pipe(Actor.commandId(lone)));
|
|
434
|
+
const [a, r, b] = yield* enqueue([
|
|
435
|
+
planner.PlanDelayed().pipe(Actor.commandId(one), Effect.exit),
|
|
436
|
+
planner.PlanDelayedThenRefuse().pipe(Actor.commandId(refused), Effect.exit),
|
|
437
|
+
planner.PlanDelayed().pipe(Actor.commandId(two), Effect.exit),
|
|
438
|
+
]);
|
|
439
|
+
yield* settle;
|
|
440
|
+
yield* first.release;
|
|
441
|
+
yield* Fiber.join(first.fiber);
|
|
442
|
+
expect(yield* Fiber.join(a)).toEqual(Exit.succeed([oneChild]));
|
|
443
|
+
expect(yield* Fiber.join(r)).toEqual(Exit.fail(Refused.make({})));
|
|
444
|
+
expect(yield* Fiber.join(b)).toEqual(Exit.succeed([twoChild]));
|
|
445
|
+
const committed = yield* transactions(planner.ref);
|
|
446
|
+
expect(new Set([one, refused, two].map((id) => committed.get(id))).size).toBe(1);
|
|
447
|
+
expect(committed.get(one)).not.toBe(committed.get(lone));
|
|
448
|
+
expect(new Set([loneChild, oneChild, twoChild, rolledBack]).size).toBe(4);
|
|
449
|
+
expect(new Set(runs.slice(before).flat())).toEqual(new Set([loneChild, oneChild, twoChild, rolledBack]));
|
|
450
|
+
expect(yield* test.inspect(planner.ref)).toMatchObject({ receipts: 4, outbox: 3 });
|
|
451
|
+
const settled = runs.length;
|
|
452
|
+
expect(yield* planner.PlanDelayed().pipe(Actor.commandId(two))).toEqual([twoChild]);
|
|
453
|
+
expect(runs.length).toBe(settled);
|
|
454
|
+
yield* test.advance("1 hour");
|
|
455
|
+
for (const id of [loneChild, oneChild, twoChild])
|
|
456
|
+
expect(yield* created("MintTask", id)).toBe(1);
|
|
457
|
+
expect(yield* created("MintTask", rolledBack)).toBe(0);
|
|
458
|
+
expect(yield* openAs(rolledBack, "rolled back", proven(planner.ref, refused))).toMatchObject({ reason: Unauthorized.make({ code: "access_denied" }) });
|
|
459
|
+
expect(yield* test.inspect(planner.ref)).toMatchObject({ outbox: 0 });
|
|
460
|
+
})),
|
|
461
|
+
},
|
|
462
|
+
{
|
|
463
|
+
name: "turn batch: a crash before the shared commit reruns each minting command alone with the same ids, and a crash after it replays them, each child created once",
|
|
464
|
+
requiresIndependentConnections: true,
|
|
465
|
+
timeoutMs: 120_000,
|
|
466
|
+
run: ({ expect, environment }) => environment.run(Effect.gen(function* () {
|
|
467
|
+
const test = yield* ActorTest;
|
|
468
|
+
const actors = yield* Actors;
|
|
469
|
+
const planner = yield* Planner.get("batch-crash");
|
|
470
|
+
const [lone, between, ...ids] = yield* Effect.forEach(Array.from({ length: 8 }), () => actors.mintCommandId);
|
|
471
|
+
const derived = yield* Effect.forEach([lone, between, ...ids], (id) => expected(planner.ref, id, 0));
|
|
472
|
+
const [loneChild, betweenChild] = derived;
|
|
473
|
+
const early = derived.slice(2, 5);
|
|
474
|
+
const late = derived.slice(5);
|
|
475
|
+
yield* test.advance(0);
|
|
476
|
+
const before = runs.length;
|
|
477
|
+
const first = yield* holding(planner.PlanDelayed().pipe(Actor.commandId(lone)));
|
|
478
|
+
const beforeCrash = yield* enqueue(ids
|
|
479
|
+
.slice(0, 3)
|
|
480
|
+
.map((id) => planner.PlanDelayed().pipe(Actor.commandId(id), Effect.orDie)));
|
|
481
|
+
yield* settle;
|
|
482
|
+
yield* test.crashNext("beforeCommit");
|
|
483
|
+
yield* first.release;
|
|
484
|
+
yield* Fiber.join(first.fiber);
|
|
485
|
+
expect(yield* Effect.forEach(beforeCrash, Fiber.join)).toEqual(early.map((id) => [id]));
|
|
486
|
+
const executions = (id) => runs.slice(before).filter(([only]) => only === id).length;
|
|
487
|
+
expect(early.map(executions).some((count) => count > 1)).toBe(true);
|
|
488
|
+
let committed = yield* transactions(planner.ref);
|
|
489
|
+
expect(new Set(ids.slice(0, 3).map((id) => committed.get(id))).size).toBe(3);
|
|
490
|
+
const second = yield* holding(planner.PlanDelayed().pipe(Actor.commandId(between)));
|
|
491
|
+
const afterCrash = yield* enqueue(ids.slice(3).map((id) => planner.PlanDelayed().pipe(Actor.commandId(id), Effect.orDie)));
|
|
492
|
+
yield* settle;
|
|
493
|
+
const shared = yield* test.pauseNext("beforeCommit");
|
|
494
|
+
yield* second.release;
|
|
495
|
+
yield* Fiber.join(second.fiber);
|
|
496
|
+
yield* shared.reached;
|
|
497
|
+
yield* test.crashNext("afterCommit");
|
|
498
|
+
yield* shared.release;
|
|
499
|
+
expect(yield* Effect.forEach(afterCrash, Fiber.join)).toEqual(late.map((id) => [id]));
|
|
500
|
+
expect(late.map(executions)).toEqual([1, 1, 1]);
|
|
501
|
+
committed = yield* transactions(planner.ref);
|
|
502
|
+
expect(new Set(ids.slice(3).map((id) => committed.get(id))).size).toBe(1);
|
|
503
|
+
const children = new Set([loneChild, betweenChild, ...early, ...late]);
|
|
504
|
+
expect(children.size).toBe(8);
|
|
505
|
+
expect(new Set(runs.slice(before).flat())).toEqual(children);
|
|
506
|
+
yield* test.advance("1 hour");
|
|
507
|
+
for (const id of children)
|
|
508
|
+
expect(yield* created("MintTask", id)).toBe(1);
|
|
509
|
+
expect(yield* test.inspect(planner.ref)).toMatchObject({ receipts: 8, outbox: 0 });
|
|
510
|
+
})),
|
|
511
|
+
},
|
|
512
|
+
{
|
|
513
|
+
name: "creates no child from a declared failure, a defect, or a mint without a creating intent",
|
|
514
|
+
run: ({ expect, environment }) => environment.run(Effect.gen(function* () {
|
|
515
|
+
const test = yield* ActorTest;
|
|
516
|
+
const planner = yield* Planner.get("rollback");
|
|
517
|
+
const before = runs.length;
|
|
518
|
+
const refusedId = yield* (yield* Actors).mintCommandId;
|
|
519
|
+
expect(yield* planner.PlanThenRefuse().pipe(Actor.commandId(refusedId), Effect.flip)).toBeInstanceOf(Refused);
|
|
520
|
+
const rolledBack = yield* expected(planner.ref, refusedId, 0);
|
|
521
|
+
expect(yield* openAs(rolledBack, "rolled back", proven(planner.ref, refusedId))).toMatchObject({ reason: Unauthorized.make({ code: "access_denied" }) });
|
|
522
|
+
const died = yield* planner.PlanThenDie().pipe(Effect.exit);
|
|
523
|
+
expect(Exit.isFailure(died) && Cause.pretty(died.cause)).toContain("Planner defect");
|
|
524
|
+
const commandId = yield* (yield* Actors).mintCommandId;
|
|
525
|
+
const unstaged = yield* planner.MintOnly().pipe(Actor.commandId(commandId), Effect.exit);
|
|
526
|
+
const orphan = yield* expected(planner.ref, commandId, 0);
|
|
527
|
+
expect(Exit.isFailure(unstaged) && Cause.pretty(unstaged.cause)).toContain(`Minted actor MintTask/${orphan} has no creating intent`);
|
|
528
|
+
yield* test.advance(0);
|
|
529
|
+
expect(yield* test.inspect(planner.ref)).toMatchObject({
|
|
530
|
+
receipts: 1,
|
|
531
|
+
outbox: 0,
|
|
532
|
+
});
|
|
533
|
+
for (const [id] of runs.slice(before))
|
|
534
|
+
expect(yield* created("MintTask", id)).toBe(0);
|
|
535
|
+
})),
|
|
536
|
+
},
|
|
537
|
+
{
|
|
538
|
+
name: "refuses a proven creating call while its parent's turn has not committed",
|
|
539
|
+
requiresIndependentConnections: true,
|
|
540
|
+
run: ({ expect, environment }) => environment.run(Effect.gen(function* () {
|
|
541
|
+
const test = yield* ActorTest;
|
|
542
|
+
const planner = yield* Planner.get("uncommitted");
|
|
543
|
+
const commandId = yield* (yield* Actors).mintCommandId;
|
|
544
|
+
const id = yield* expected(planner.ref, commandId, 0);
|
|
545
|
+
const pause = yield* test.pauseNext("beforeCommit");
|
|
546
|
+
const parent = yield* planner.Plan(1).pipe(Actor.commandId(commandId), Effect.forkChild);
|
|
547
|
+
yield* pause.reached;
|
|
548
|
+
expect(yield* openAs(id, "early", proven(planner.ref, commandId))).toMatchObject({
|
|
549
|
+
reason: Unauthorized.make({ code: "access_denied" }),
|
|
550
|
+
});
|
|
551
|
+
expect(yield* created("MintTask", id)).toBe(0);
|
|
552
|
+
yield* pause.release;
|
|
553
|
+
expect(yield* Fiber.join(parent)).toEqual([id]);
|
|
554
|
+
yield* test.advance(0);
|
|
555
|
+
expect(yield* created("MintTask", id)).toBe(1);
|
|
556
|
+
expect(yield* (yield* task(id)).Title()).toBe("task 0");
|
|
557
|
+
expect(yield* test.inspect(planner.ref)).toMatchObject({ outbox: 0 });
|
|
558
|
+
})),
|
|
559
|
+
},
|
|
560
|
+
{
|
|
561
|
+
name: "keeps a minted child uncreated when its creating turn fails with a declared error",
|
|
562
|
+
run: ({ expect, environment }) => environment.run(Effect.gen(function* () {
|
|
563
|
+
const test = yield* ActorTest;
|
|
564
|
+
const planner = yield* Planner.get("child-refuses");
|
|
565
|
+
const id = yield* planner.PlanRefusedChild();
|
|
566
|
+
yield* test.advance(0);
|
|
567
|
+
expect(yield* created("MintTask", id)).toBe(1);
|
|
568
|
+
expect(yield* test.inspect(planner.ref)).toMatchObject({ receipts: 1, outbox: 0 });
|
|
569
|
+
expect(yield* (yield* task(id)).Title().pipe(Effect.flip)).toMatchObject({
|
|
570
|
+
reason: NotCreated.make({}),
|
|
571
|
+
});
|
|
572
|
+
})),
|
|
573
|
+
},
|
|
574
|
+
{
|
|
575
|
+
name: "refuses a minted child's creating command without its parent's mint proof",
|
|
576
|
+
run: ({ expect, environment }) => environment.run(Effect.gen(function* () {
|
|
577
|
+
const test = yield* ActorTest;
|
|
578
|
+
const planner = yield* Planner.get("forged");
|
|
579
|
+
const other = yield* Planner.get("forged-other");
|
|
580
|
+
const commandId = yield* (yield* Actors).mintCommandId;
|
|
581
|
+
const id = yield* planner.PlanLater().pipe(Actor.commandId(commandId));
|
|
582
|
+
const child = yield* task(id);
|
|
583
|
+
const denied = {
|
|
584
|
+
reason: Unauthorized.make({ code: "access_denied" }),
|
|
585
|
+
};
|
|
586
|
+
expect(yield* child.Open("client").pipe(Effect.flip)).toMatchObject(denied);
|
|
587
|
+
const forged = System.make({
|
|
588
|
+
source: "actor",
|
|
589
|
+
ref: other.ref,
|
|
590
|
+
onBehalfOf: { subject: "alice" },
|
|
591
|
+
mint: { commandId, ordinal: 0 },
|
|
592
|
+
});
|
|
593
|
+
const impostor = yield* task(id).pipe(Effect.provideService(CurrentCaller, forged));
|
|
594
|
+
expect(yield* impostor.Open("impostor").pipe(Effect.flip)).toMatchObject(denied);
|
|
595
|
+
const uncommitted = yield* (yield* Actors).mintCommandId;
|
|
596
|
+
expect(yield* openAs(yield* expected(planner.ref, uncommitted, 0), "never planned", proven(planner.ref, uncommitted))).toMatchObject(denied);
|
|
597
|
+
expect(yield* openAs(id, "proven early", proven(planner.ref, commandId))).toMatchObject(denied);
|
|
598
|
+
const sql = yield* SqlClient.SqlClient;
|
|
599
|
+
const [row] = yield* sql `
|
|
600
|
+
SELECT intent_id, scheduled_at_ms::text AS scheduled FROM actor_outbox
|
|
601
|
+
WHERE target_type = 'MintTask' AND target_id = ${id}`.pipe(Effect.orDie);
|
|
602
|
+
const presented = yield* (yield* Actors).mintCommandId;
|
|
603
|
+
const move = (from, to, scheduled) => sql `UPDATE actor_outbox SET intent_id = ${to}, scheduled_at_ms = ${scheduled}::bigint
|
|
604
|
+
WHERE intent_id = ${from}`.pipe(Effect.orDie);
|
|
605
|
+
yield* move(row.intent_id, presented, "0");
|
|
606
|
+
for (const title of ["later", "hijacked"])
|
|
607
|
+
expect(yield* task(id).pipe(Actor.as(proven(planner.ref, commandId)), Effect.flatMap((forger) => forger.Open(title).pipe(Actor.commandId(presented))), Effect.flip)).toMatchObject(denied);
|
|
608
|
+
yield* move(presented, row.intent_id, row.scheduled);
|
|
609
|
+
expect(yield* created("MintTask", id)).toBe(0);
|
|
610
|
+
yield* test.advance("1 hour");
|
|
611
|
+
expect(yield* child.Title()).toBe("later");
|
|
612
|
+
expect(yield* created("MintTask", id)).toBe(1);
|
|
613
|
+
yield* child.Open("reopened");
|
|
614
|
+
expect(yield* child.Title()).toBe("reopened");
|
|
615
|
+
})),
|
|
616
|
+
},
|
|
617
|
+
{
|
|
618
|
+
name: "gives the proof to a creating intent staged before its child was minted",
|
|
619
|
+
run: ({ expect, environment }) => environment.run(Effect.gen(function* () {
|
|
620
|
+
const planner = yield* Planner.get("staged-first");
|
|
621
|
+
const commandId = yield* (yield* Actors).mintCommandId;
|
|
622
|
+
const known = yield* expected(planner.ref, commandId, 0);
|
|
623
|
+
expect(yield* planner.PlanStagedFirst(known).pipe(Actor.commandId(commandId))).toBe(known);
|
|
624
|
+
yield* (yield* ActorTest).advance(0);
|
|
625
|
+
expect(yield* (yield* task(known)).Title()).toBe("staged first");
|
|
626
|
+
expect(yield* created("MintTask", known)).toBe(1);
|
|
627
|
+
})),
|
|
628
|
+
},
|
|
629
|
+
{
|
|
630
|
+
name: "mints from a singleton parent with an empty parent id",
|
|
631
|
+
run: ({ expect, environment }) => environment.run(Effect.gen(function* () {
|
|
632
|
+
const solo = yield* SoloPlanner.get();
|
|
633
|
+
const commandId = yield* (yield* Actors).mintCommandId;
|
|
634
|
+
const id = yield* solo.SoloPlan().pipe(Actor.commandId(commandId));
|
|
635
|
+
expect(id).toBe(yield* expected({ ...solo.ref, id: "" }, commandId, 0));
|
|
636
|
+
yield* (yield* ActorTest).advance(0);
|
|
637
|
+
expect(yield* (yield* task(id)).Title()).toBe("solo");
|
|
638
|
+
})),
|
|
639
|
+
},
|
|
640
|
+
{
|
|
641
|
+
name: "creates a named actor whose declared key is a UUIDv8 without a mint proof",
|
|
642
|
+
run: ({ expect, environment }) => environment.run(Effect.gen(function* () {
|
|
643
|
+
const planner = yield* Planner.get("named");
|
|
644
|
+
const id = yield* expected(planner.ref, "named", 0);
|
|
645
|
+
const job = yield* Job.get(id);
|
|
646
|
+
yield* job.Open("named");
|
|
647
|
+
expect(yield* job.Title()).toBe("named");
|
|
648
|
+
})),
|
|
649
|
+
},
|
|
650
|
+
{
|
|
651
|
+
name: "reaches a minted id on an unkeyed actor that no longer declares policy.createdBy",
|
|
652
|
+
run: ({ expect, environment }) => environment.run(Effect.gen(function* () {
|
|
653
|
+
const planner = yield* Planner.get("former");
|
|
654
|
+
const id = yield* expected(planner.ref, "former", 0, "MintFormerChild");
|
|
655
|
+
const child = yield* Former.get(id);
|
|
656
|
+
yield* child.Open("kept");
|
|
657
|
+
expect(yield* child.Title()).toBe("kept");
|
|
658
|
+
})),
|
|
659
|
+
},
|
|
660
|
+
{
|
|
661
|
+
name: "keeps create() children open to any authorized caller of the creating command",
|
|
662
|
+
run: ({ expect, environment }) => environment.run(Effect.gen(function* () {
|
|
663
|
+
const child = yield* Task.create();
|
|
664
|
+
yield* child.Open("direct");
|
|
665
|
+
expect(yield* child.Title()).toBe("direct");
|
|
666
|
+
})),
|
|
667
|
+
},
|
|
668
|
+
{
|
|
669
|
+
name: "rejects a mint capability that escaped its turn, a keyed creating intent, and an actor that cannot be minted",
|
|
670
|
+
run: ({ expect, environment }) => environment.run(Effect.gen(function* () {
|
|
671
|
+
const planner = yield* Planner.get("escape");
|
|
672
|
+
yield* planner.Escape();
|
|
673
|
+
const stolen = yield* planner.Steal().pipe(Effect.exit);
|
|
674
|
+
expect(Exit.isFailure(stolen) && Cause.pretty(stolen.cause)).toContain("Mint capability escaped its turn");
|
|
675
|
+
const keyed = yield* planner.PlanKeyed().pipe(Effect.exit);
|
|
676
|
+
expect(Exit.isFailure(keyed) && Cause.pretty(keyed.cause)).toContain(`Minted actor MintTask/${runs.at(-1)[0]} has a keyed creating intent`);
|
|
677
|
+
expect(yield* (yield* ActorTest).inspect(planner.ref)).toMatchObject({ outbox: 0 });
|
|
678
|
+
const unmintable = yield* planner.MintUnmintable().pipe(Effect.exit);
|
|
679
|
+
expect(Exit.isFailure(unmintable) && Cause.pretty(unmintable.cause)).toContain("turn.mint needs an unkeyed actor that declares createdBy");
|
|
680
|
+
})),
|
|
681
|
+
},
|
|
682
|
+
];
|
|
683
|
+
/** Minted-id actors. */
|
|
684
|
+
export const mintSuite = {
|
|
685
|
+
fixture: () => ({ deliveries: new Map(), onTurn: undefined }),
|
|
686
|
+
layer: () => mintLayer,
|
|
687
|
+
turn: (fixture) => (point, request) => Effect.sync(() => {
|
|
688
|
+
if (point === "afterClaim")
|
|
689
|
+
fixture.deliveries.set(request.ref.id, request);
|
|
690
|
+
fixture.onTurn?.(point, request);
|
|
691
|
+
}),
|
|
692
|
+
};
|