@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,517 @@
|
|
|
1
|
+
import { Cause, Deferred, Effect, Exit, Fiber, Layer, Logger, Option, References, Schema, } from "effect";
|
|
2
|
+
import { SqlClient, SqlError } from "effect/sql";
|
|
3
|
+
import { Actor, Caller, NotCreated, Principal, System, Timeout, User } from "../index.js";
|
|
4
|
+
import { Actors } from "../handles/actors.js";
|
|
5
|
+
import { Outcome, Request } from "../runtime/request.js";
|
|
6
|
+
import { compress, decompress } from "../runtime/storage/codec.js";
|
|
7
|
+
import { VERSION_KEY } from "../state/migration.js";
|
|
8
|
+
import { ActorTest, executeForTest } from "./actor-test.js";
|
|
9
|
+
export const foundationFixture = () => ({
|
|
10
|
+
creates: 0,
|
|
11
|
+
privateRuns: 0,
|
|
12
|
+
slowIds: [],
|
|
13
|
+
slowFirst: Effect.never,
|
|
14
|
+
deliveryRuns: 0,
|
|
15
|
+
deliveryHold: Effect.void,
|
|
16
|
+
defects: [],
|
|
17
|
+
timeouts: [],
|
|
18
|
+
});
|
|
19
|
+
/**
|
|
20
|
+
* Captures the runtime's deterministic-defect log records, which replace the
|
|
21
|
+
* removed defect hook, and the diagnostics of each delivery that timed out.
|
|
22
|
+
*/
|
|
23
|
+
export const defectRecorder = (fixture) => Logger.make((options) => {
|
|
24
|
+
const message = Array.isArray(options.message) ? options.message[0] : options.message;
|
|
25
|
+
const annotations = options.fiber.getRef(References.CurrentLogAnnotations);
|
|
26
|
+
if (message === "Delivery timed out")
|
|
27
|
+
fixture.timeouts.push({
|
|
28
|
+
actor: annotations["actor"],
|
|
29
|
+
id: annotations["id"],
|
|
30
|
+
commandId: annotations["commandId"],
|
|
31
|
+
activation: annotations["activation"],
|
|
32
|
+
turnSessions: annotations["turnSessions"],
|
|
33
|
+
restarting: annotations["restarting"],
|
|
34
|
+
});
|
|
35
|
+
if (message !== "Deterministic actor defect")
|
|
36
|
+
return;
|
|
37
|
+
fixture.defects.push({
|
|
38
|
+
actor: String(annotations["actor"]),
|
|
39
|
+
id: String(annotations["id"]),
|
|
40
|
+
command: String(annotations["command"]),
|
|
41
|
+
cause: Cause.pretty(options.cause),
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
const Ping = Actor.command("Ping", { success: Schema.String });
|
|
45
|
+
const Minted = Actor.make("Minted", { api: { Ping } });
|
|
46
|
+
const Named = Actor.make("Named", { key: Schema.NonEmptyString, api: { Ping } });
|
|
47
|
+
const Singleton = Actor.make("Singleton", { key: Actor.singleton, api: { Ping } });
|
|
48
|
+
class CreationRejected extends Schema.TaggedError()("CreationRejected", {}) {
|
|
49
|
+
}
|
|
50
|
+
const Create = Actor.command("Create", { payload: Schema.Boolean, error: CreationRejected });
|
|
51
|
+
const Read = Actor.command("Read", { success: Schema.Finite });
|
|
52
|
+
const Created = Actor.make("Created", {
|
|
53
|
+
key: Schema.NonEmptyString,
|
|
54
|
+
state: Actor.state({ count: Schema.Finite.pipe(Schema.withDecodingDefault(Effect.succeed(0))) }),
|
|
55
|
+
api: { Create, Read },
|
|
56
|
+
createdBy: Create,
|
|
57
|
+
});
|
|
58
|
+
const SetText = Actor.command("SetText", { payload: Schema.String, success: Schema.String });
|
|
59
|
+
const Small = Actor.make("Small", {
|
|
60
|
+
key: Schema.NonEmptyString,
|
|
61
|
+
state: Actor.state({ text: Schema.String.pipe(Schema.withDecodingDefault(Effect.succeed(""))) }),
|
|
62
|
+
api: { SetText },
|
|
63
|
+
policy: { maxStateBytes: 15, executionTimeout: "500 millis" },
|
|
64
|
+
});
|
|
65
|
+
const Attribution = Schema.Struct({ caller: Caller, principal: Schema.NullOr(Principal) });
|
|
66
|
+
const Who = Actor.command("Who", { success: Attribution });
|
|
67
|
+
const Internal = Actor.command("Internal", { success: Attribution });
|
|
68
|
+
const Private = Actor.make("Private", {
|
|
69
|
+
key: Schema.NonEmptyString,
|
|
70
|
+
api: { Who },
|
|
71
|
+
internal: { Internal },
|
|
72
|
+
});
|
|
73
|
+
const Bump = Actor.command("Bump", { success: Schema.Finite });
|
|
74
|
+
const Slow = Actor.make("Slow", {
|
|
75
|
+
key: Schema.NonEmptyString,
|
|
76
|
+
state: Actor.state({ count: Schema.Finite.pipe(Schema.withDecodingDefault(Effect.succeed(0))) }),
|
|
77
|
+
api: { Read, Bump },
|
|
78
|
+
policy: { executionTimeout: "500 millis" },
|
|
79
|
+
});
|
|
80
|
+
const DeliveryActor = Actor.make("DeliveryActor", {
|
|
81
|
+
key: Schema.NonEmptyString,
|
|
82
|
+
state: Actor.state({ count: Schema.Finite.pipe(Schema.withDecodingDefault(Effect.succeed(0))) }),
|
|
83
|
+
api: { Bump },
|
|
84
|
+
policy: { deliveryTimeout: "100 millis" },
|
|
85
|
+
});
|
|
86
|
+
const ProfileV0 = { name: Schema.String };
|
|
87
|
+
const ProfileV1 = { first: Schema.String, last: Schema.String };
|
|
88
|
+
const ProfileV2 = {
|
|
89
|
+
first: Schema.String.pipe(Schema.withDecodingDefault(Effect.succeed(""))),
|
|
90
|
+
last: Schema.String.pipe(Schema.withDecodingDefault(Effect.succeed(""))),
|
|
91
|
+
tags: Schema.Array(Schema.String).pipe(Schema.withDecodingDefault(Effect.succeed([]))),
|
|
92
|
+
};
|
|
93
|
+
class Rename extends Schema.TaggedError()("Rename", {}) {
|
|
94
|
+
}
|
|
95
|
+
const Describe = Actor.command("Describe", {
|
|
96
|
+
payload: Schema.Boolean,
|
|
97
|
+
success: Schema.String,
|
|
98
|
+
error: Rename,
|
|
99
|
+
});
|
|
100
|
+
const Show = Actor.query("Show", { success: Schema.String });
|
|
101
|
+
const Profile = Actor.make("Profile", {
|
|
102
|
+
key: Schema.NonEmptyString,
|
|
103
|
+
state: Actor.state(ProfileV2, {
|
|
104
|
+
migrations: [
|
|
105
|
+
Actor.migration(ProfileV0, ProfileV1, ({ name }) => {
|
|
106
|
+
if (name === "unreadable")
|
|
107
|
+
throw new Error("Unreadable profile");
|
|
108
|
+
const [first = "", ...rest] = name.split(" ");
|
|
109
|
+
return { first, last: rest.join(" ") };
|
|
110
|
+
}),
|
|
111
|
+
Actor.migration(ProfileV1, ProfileV2, (v1) => ({ ...v1, tags: [] })),
|
|
112
|
+
],
|
|
113
|
+
}),
|
|
114
|
+
api: { Describe, Show },
|
|
115
|
+
});
|
|
116
|
+
const storedVersion = Effect.fnUntraced(function* (ref) {
|
|
117
|
+
const sql = yield* SqlClient.SqlClient;
|
|
118
|
+
const [row] = yield* sql `SELECT value FROM actor_state
|
|
119
|
+
WHERE tenant_id = ${ref.tenant} AND actor_type = ${ref.actor} AND actor_id = ${ref.id}
|
|
120
|
+
AND key = ${VERSION_KEY}`;
|
|
121
|
+
return row === undefined ? undefined : decompress(row.value);
|
|
122
|
+
}, Effect.orDie);
|
|
123
|
+
const attribution = (turn) => ({
|
|
124
|
+
caller: turn.caller,
|
|
125
|
+
principal: Option.getOrNull(turn.principal),
|
|
126
|
+
});
|
|
127
|
+
/** Handlers for the foundation actors; `fixture` supplies the observable state cases assert on. */
|
|
128
|
+
export const foundationLayer = (fixture) => Layer.mergeAll(Minted.toLayer(Effect.succeed({ Ping: () => Effect.succeed("minted") })), Named.toLayer(Effect.succeed({ Ping: () => Effect.succeed("named") })), Singleton.toLayer(Effect.succeed({ Ping: () => Effect.succeed("singleton") })), Created.toLayer(Effect.succeed({
|
|
129
|
+
Create: Effect.fnUntraced(function* (accept) {
|
|
130
|
+
const turn = yield* Created.Turn;
|
|
131
|
+
fixture.creates += 1;
|
|
132
|
+
yield* turn.state.set({ count: 23 });
|
|
133
|
+
if (!accept)
|
|
134
|
+
return yield* CreationRejected.make({});
|
|
135
|
+
}),
|
|
136
|
+
Read: Effect.fnUntraced(function* () {
|
|
137
|
+
return (yield* Created.Turn).state.count;
|
|
138
|
+
}),
|
|
139
|
+
})), Small.toLayer(Effect.succeed({
|
|
140
|
+
SetText: Effect.fnUntraced(function* (text) {
|
|
141
|
+
const turn = yield* Small.Turn;
|
|
142
|
+
yield* turn.state.set({ text });
|
|
143
|
+
return turn.state.text;
|
|
144
|
+
}),
|
|
145
|
+
})), Private.toLayer(Effect.succeed({
|
|
146
|
+
Who: Effect.fnUntraced(function* () {
|
|
147
|
+
return attribution(yield* Private.Turn);
|
|
148
|
+
}),
|
|
149
|
+
Internal: Effect.fnUntraced(function* () {
|
|
150
|
+
fixture.privateRuns += 1;
|
|
151
|
+
return attribution(yield* Private.Turn);
|
|
152
|
+
}),
|
|
153
|
+
})), Slow.toLayer(Effect.succeed({
|
|
154
|
+
Read: Effect.fnUntraced(function* () {
|
|
155
|
+
return (yield* Slow.Turn).state.count;
|
|
156
|
+
}),
|
|
157
|
+
Bump: Effect.fnUntraced(function* () {
|
|
158
|
+
const turn = yield* Slow.Turn;
|
|
159
|
+
fixture.slowIds.push(turn.commandId);
|
|
160
|
+
yield* turn.state.set({ count: turn.state.count + 1 });
|
|
161
|
+
if (fixture.slowIds.length === 1)
|
|
162
|
+
yield* fixture.slowFirst;
|
|
163
|
+
return turn.state.count;
|
|
164
|
+
}),
|
|
165
|
+
})), Profile.toLayer(Effect.succeed({
|
|
166
|
+
Describe: Effect.fnUntraced(function* (fail) {
|
|
167
|
+
const turn = yield* Profile.Turn;
|
|
168
|
+
if (fail)
|
|
169
|
+
return yield* Rename.make({});
|
|
170
|
+
yield* turn.state.set({ tags: [...turn.state.tags, "seen"] });
|
|
171
|
+
return `${turn.state.first}|${turn.state.last}|${turn.state.tags.join(",")}`;
|
|
172
|
+
}),
|
|
173
|
+
})), Profile.toQueryLayer(Effect.succeed({
|
|
174
|
+
Show: Effect.fnUntraced(function* () {
|
|
175
|
+
const { state } = yield* Profile.Read;
|
|
176
|
+
return `${state.first}|${state.last}|${state.tags.join(",")}`;
|
|
177
|
+
}),
|
|
178
|
+
})), DeliveryActor.toLayer(Effect.succeed({
|
|
179
|
+
Bump: Effect.fnUntraced(function* () {
|
|
180
|
+
const turn = yield* DeliveryActor.Turn;
|
|
181
|
+
fixture.deliveryRuns += 1;
|
|
182
|
+
yield* turn.state.set({ count: turn.state.count + 1 });
|
|
183
|
+
yield* fixture.deliveryHold;
|
|
184
|
+
return turn.state.count;
|
|
185
|
+
}),
|
|
186
|
+
})));
|
|
187
|
+
/** Identity, admission, receipts, state migration, and blob cases every backend must pass. A receipt retry may wait for PGlite's busy connection, so its delivery deadline covers that wait as well as the RPC reply. */
|
|
188
|
+
export const foundationConformance = [
|
|
189
|
+
{
|
|
190
|
+
name: "resolves all identity modes without writes and receipts stateless commands",
|
|
191
|
+
run: ({ environment, expect }) => environment.run(Effect.gen(function* () {
|
|
192
|
+
const test = yield* ActorTest;
|
|
193
|
+
const minted = yield* Minted.create();
|
|
194
|
+
expect(Schema.is(Schema.String.check(Schema.isUUID(7)))(minted.ref.id)).toBe(true);
|
|
195
|
+
const other = yield* Minted.create();
|
|
196
|
+
expect(minted.ref.id).not.toBe(other.ref.id);
|
|
197
|
+
const named = yield* Named.get("chosen");
|
|
198
|
+
const singleton = yield* Singleton.get();
|
|
199
|
+
expect((yield* Singleton.get()).ref).toEqual(singleton.ref);
|
|
200
|
+
for (const handle of [minted, other, named, singleton])
|
|
201
|
+
expect(yield* test.inspect(handle.ref)).toEqual({
|
|
202
|
+
generation: undefined,
|
|
203
|
+
state: {},
|
|
204
|
+
receipts: 0,
|
|
205
|
+
events: 0,
|
|
206
|
+
outbox: 0,
|
|
207
|
+
jobs: 0,
|
|
208
|
+
});
|
|
209
|
+
expect(yield* minted.Ping()).toBe("minted");
|
|
210
|
+
expect(yield* named.Ping()).toBe("named");
|
|
211
|
+
const call = singleton.Ping();
|
|
212
|
+
expect(yield* call).toBe("singleton");
|
|
213
|
+
expect(yield* call).toBe("singleton");
|
|
214
|
+
expect(yield* test.inspect(singleton.ref)).toEqual({
|
|
215
|
+
generation: "1",
|
|
216
|
+
state: {},
|
|
217
|
+
receipts: 1,
|
|
218
|
+
events: 0,
|
|
219
|
+
outbox: 0,
|
|
220
|
+
jobs: 0,
|
|
221
|
+
});
|
|
222
|
+
})),
|
|
223
|
+
},
|
|
224
|
+
{
|
|
225
|
+
name: "gates creation, rolls back failed creation, and replays its error receipt",
|
|
226
|
+
run: ({ environment, expect, fixture }) => environment.run(Effect.gen(function* () {
|
|
227
|
+
const test = yield* ActorTest;
|
|
228
|
+
const actor = yield* Created.get("creation");
|
|
229
|
+
expect(yield* actor.Read().pipe(Effect.flip)).toMatchObject({
|
|
230
|
+
reason: NotCreated.make({}),
|
|
231
|
+
});
|
|
232
|
+
expect(yield* test.inspect(actor.ref)).toEqual({
|
|
233
|
+
generation: undefined,
|
|
234
|
+
state: {},
|
|
235
|
+
receipts: 0,
|
|
236
|
+
events: 0,
|
|
237
|
+
outbox: 0,
|
|
238
|
+
jobs: 0,
|
|
239
|
+
});
|
|
240
|
+
const reject = actor.Create(false);
|
|
241
|
+
const before = fixture.creates;
|
|
242
|
+
expect(yield* reject.pipe(Effect.flip)).toBeInstanceOf(CreationRejected);
|
|
243
|
+
expect(yield* reject.pipe(Effect.flip)).toBeInstanceOf(CreationRejected);
|
|
244
|
+
expect(fixture.creates - before).toBe(1);
|
|
245
|
+
expect(yield* test.inspect(actor.ref)).toEqual({
|
|
246
|
+
generation: "1",
|
|
247
|
+
state: {},
|
|
248
|
+
receipts: 1,
|
|
249
|
+
events: 0,
|
|
250
|
+
outbox: 0,
|
|
251
|
+
jobs: 0,
|
|
252
|
+
});
|
|
253
|
+
expect(yield* actor.Read().pipe(Effect.flip)).toMatchObject({
|
|
254
|
+
reason: NotCreated.make({}),
|
|
255
|
+
});
|
|
256
|
+
yield* actor.Create(true);
|
|
257
|
+
expect(yield* actor.Read()).toBe(23);
|
|
258
|
+
})),
|
|
259
|
+
},
|
|
260
|
+
...["beforeCommit", "afterCommit"].map((point) => ({
|
|
261
|
+
name: `keeps creation marker and receipt atomic across ${point} crash`,
|
|
262
|
+
run: ({ environment, expect, fixture }) => environment.run(Effect.gen(function* () {
|
|
263
|
+
const test = yield* ActorTest;
|
|
264
|
+
const actor = yield* Created.get(`creation-${point}`);
|
|
265
|
+
const before = fixture.creates;
|
|
266
|
+
yield* test.crashNext(point);
|
|
267
|
+
yield* actor.Create(true);
|
|
268
|
+
expect(fixture.creates - before).toBe(point === "beforeCommit" ? 2 : 1);
|
|
269
|
+
expect(yield* test.inspect(actor.ref)).toMatchObject({
|
|
270
|
+
state: { count: 23 },
|
|
271
|
+
receipts: 1,
|
|
272
|
+
});
|
|
273
|
+
expect(yield* actor.Read()).toBe(23);
|
|
274
|
+
})),
|
|
275
|
+
})),
|
|
276
|
+
{
|
|
277
|
+
name: "retains creation and singleton receipt identity across runtime restart",
|
|
278
|
+
run: ({ environment, expect }) => Effect.runPromise(Effect.gen(function* () {
|
|
279
|
+
const saved = yield* Effect.promise(() => environment.run(Effect.gen(function* () {
|
|
280
|
+
const actor = yield* Created.get("restart-created");
|
|
281
|
+
yield* actor.Create(true);
|
|
282
|
+
const singleton = yield* Singleton.get();
|
|
283
|
+
const id = yield* (yield* Actors).mintCommandId;
|
|
284
|
+
expect(yield* singleton.Ping().pipe(Actor.commandId(id))).toBe("singleton");
|
|
285
|
+
return { tenant: actor.ref.tenant, id, singleton: singleton.ref };
|
|
286
|
+
})));
|
|
287
|
+
yield* environment.restart;
|
|
288
|
+
yield* Effect.promise(() => environment.run(Effect.gen(function* () {
|
|
289
|
+
expect(yield* (yield* Created.get("restart-created").pipe(Actor.tenant(saved.tenant))).Read()).toBe(23);
|
|
290
|
+
const singleton = yield* Singleton.get().pipe(Actor.tenant(saved.tenant));
|
|
291
|
+
expect(singleton.ref).toEqual(saved.singleton);
|
|
292
|
+
const test = yield* ActorTest;
|
|
293
|
+
const before = yield* test.inspect(singleton.ref);
|
|
294
|
+
expect(yield* singleton.Ping().pipe(Actor.commandId(saved.id))).toBe("singleton");
|
|
295
|
+
expect(yield* test.inspect(singleton.ref)).toEqual({
|
|
296
|
+
...before,
|
|
297
|
+
generation: String(Number(before.generation) + 1),
|
|
298
|
+
});
|
|
299
|
+
})));
|
|
300
|
+
})),
|
|
301
|
+
},
|
|
302
|
+
{
|
|
303
|
+
name: "enforces UTF-8 state bytes and records deterministic defects without user hooks",
|
|
304
|
+
run: ({ environment, expect, fixture }) => environment.run(Effect.gen(function* () {
|
|
305
|
+
const test = yield* ActorTest;
|
|
306
|
+
const actor = yield* Small.get("bytes");
|
|
307
|
+
expect(yield* actor.SetText("éé")).toBe("éé");
|
|
308
|
+
const before = yield* test.inspect(actor.ref);
|
|
309
|
+
const defects = fixture.defects.length;
|
|
310
|
+
const failure = yield* actor.SetText("ééa").pipe(Effect.exit);
|
|
311
|
+
expect(Exit.isFailure(failure) && Cause.pretty(failure.cause)).toContain("policy.maxStateBytes");
|
|
312
|
+
expect(yield* test.inspect(actor.ref)).toEqual(before);
|
|
313
|
+
expect(fixture.defects.length).toBe(defects + 1);
|
|
314
|
+
expect(fixture.defects.at(-1)).toMatchObject({
|
|
315
|
+
actor: "Small",
|
|
316
|
+
id: "bytes",
|
|
317
|
+
command: "SetText",
|
|
318
|
+
});
|
|
319
|
+
expect(fixture.defects.at(-1).cause).toContain("policy.maxStateBytes");
|
|
320
|
+
expect(yield* actor.SetText("abc")).toBe("abc");
|
|
321
|
+
expect((yield* test.inspect(actor.ref)).generation).toBe(before.generation);
|
|
322
|
+
const sql = yield* SqlClient.SqlClient;
|
|
323
|
+
yield* sql `UPDATE actor_state SET value = ${compress("13")} WHERE tenant_id = ${actor.ref.tenant} AND actor_type = 'Small' AND actor_id = 'bytes'`;
|
|
324
|
+
yield* test.invalidate(actor.ref);
|
|
325
|
+
expect(Exit.isFailure(yield* actor.SetText("ok").pipe(Effect.exit))).toBe(true);
|
|
326
|
+
expect(fixture.defects.length).toBe(defects + 2);
|
|
327
|
+
expect(yield* test.inspect(actor.ref)).toMatchObject({ state: { text: 13 }, receipts: 2 });
|
|
328
|
+
})),
|
|
329
|
+
},
|
|
330
|
+
{
|
|
331
|
+
name: "upcasts seeded old state through the migration chain and commits the current shape",
|
|
332
|
+
run: ({ environment, expect }) => environment.run(Effect.gen(function* () {
|
|
333
|
+
const test = yield* ActorTest;
|
|
334
|
+
const profile = yield* Profile.get("ada");
|
|
335
|
+
yield* test.seed(profile.ref, { name: "Ada King Lovelace" }, 0);
|
|
336
|
+
expect(yield* profile.Show()).toBe("Ada|King Lovelace|");
|
|
337
|
+
expect((yield* test.inspect(profile.ref)).state).toEqual({ name: "Ada King Lovelace" });
|
|
338
|
+
expect(yield* profile.Describe(true).pipe(Effect.flip)).toEqual(Rename.make({}));
|
|
339
|
+
expect((yield* test.inspect(profile.ref)).state).toEqual({ name: "Ada King Lovelace" });
|
|
340
|
+
expect(yield* storedVersion(profile.ref)).toBe(undefined);
|
|
341
|
+
expect(yield* profile.Describe(false)).toBe("Ada|King Lovelace|seen");
|
|
342
|
+
expect((yield* test.inspect(profile.ref)).state).toEqual({
|
|
343
|
+
first: "Ada",
|
|
344
|
+
last: "King Lovelace",
|
|
345
|
+
tags: ["seen"],
|
|
346
|
+
});
|
|
347
|
+
expect(yield* storedVersion(profile.ref)).toBe("2");
|
|
348
|
+
const mid = yield* Profile.get("grace");
|
|
349
|
+
yield* test.seed(mid.ref, { first: "Grace", last: "Hopper" }, 1);
|
|
350
|
+
expect(yield* mid.Describe(false)).toBe("Grace|Hopper|seen");
|
|
351
|
+
expect((yield* test.inspect(mid.ref)).state).toEqual({
|
|
352
|
+
first: "Grace",
|
|
353
|
+
last: "Hopper",
|
|
354
|
+
tags: ["seen"],
|
|
355
|
+
});
|
|
356
|
+
expect(yield* storedVersion(mid.ref)).toBe("2");
|
|
357
|
+
const fresh = yield* Profile.get("new");
|
|
358
|
+
expect(yield* fresh.Describe(false)).toBe("||seen");
|
|
359
|
+
expect((yield* test.inspect(fresh.ref)).state).toEqual({ tags: ["seen"] });
|
|
360
|
+
expect(yield* storedVersion(fresh.ref)).toBe("2");
|
|
361
|
+
})),
|
|
362
|
+
},
|
|
363
|
+
{
|
|
364
|
+
name: "rolls back unknown stored versions and failing upcasts as deterministic defects",
|
|
365
|
+
run: ({ environment, expect }) => environment.run(Effect.gen(function* () {
|
|
366
|
+
const test = yield* ActorTest;
|
|
367
|
+
const future = yield* Profile.get("future");
|
|
368
|
+
yield* test.seed(future.ref, { first: "Ada" }, 3);
|
|
369
|
+
const futureExit = yield* future.Describe(false).pipe(Effect.exit);
|
|
370
|
+
expect(Exit.isFailure(futureExit) && Cause.pretty(futureExit.cause)).toContain("Stored state version 3 is unknown");
|
|
371
|
+
expect(yield* test.inspect(future.ref)).toMatchObject({
|
|
372
|
+
state: { first: "Ada" },
|
|
373
|
+
receipts: 0,
|
|
374
|
+
});
|
|
375
|
+
const broken = yield* Profile.get("broken");
|
|
376
|
+
yield* test.seed(broken.ref, { name: "unreadable" }, 0);
|
|
377
|
+
const brokenExit = yield* broken.Describe(false).pipe(Effect.exit);
|
|
378
|
+
expect(Exit.isFailure(brokenExit) && Cause.pretty(brokenExit.cause)).toContain("Unreadable profile");
|
|
379
|
+
expect(yield* test.inspect(broken.ref)).toMatchObject({
|
|
380
|
+
state: { name: "unreadable" },
|
|
381
|
+
receipts: 0,
|
|
382
|
+
});
|
|
383
|
+
expect(yield* storedVersion(broken.ref)).toBe(undefined);
|
|
384
|
+
})),
|
|
385
|
+
},
|
|
386
|
+
{
|
|
387
|
+
name: "hides internal commands and binds System principal and receipt access",
|
|
388
|
+
run: ({ environment, expect, fixture }) => environment.run(Effect.gen(function* () {
|
|
389
|
+
const test = yield* ActorTest;
|
|
390
|
+
const actor = yield* Private.get("private");
|
|
391
|
+
expect(Object.keys(actor).sort()).toEqual(["Who", "ref"]);
|
|
392
|
+
expect(Object.keys(Private.api)).toEqual(["Who"]);
|
|
393
|
+
expect(yield* actor.Who()).toEqual({
|
|
394
|
+
caller: User.make({ subject: "alice" }),
|
|
395
|
+
principal: { subject: "alice" },
|
|
396
|
+
});
|
|
397
|
+
const bound = yield* test.actor(Private, "private");
|
|
398
|
+
const id = yield* (yield* Actors).mintCommandId;
|
|
399
|
+
const expected = {
|
|
400
|
+
caller: System.make({ source: "actor", onBehalfOf: { subject: "alice" } }),
|
|
401
|
+
principal: { subject: "alice" },
|
|
402
|
+
};
|
|
403
|
+
expect(yield* bound.system.Internal().pipe(Actor.commandId(id))).toEqual(expected);
|
|
404
|
+
expect(yield* bound.system.Internal().pipe(Actor.commandId(id))).toEqual(expected);
|
|
405
|
+
const actors = yield* Actors;
|
|
406
|
+
const attempts = fixture.privateRuns;
|
|
407
|
+
const denied = yield* executeForTest(Request.make({
|
|
408
|
+
ref: actor.ref,
|
|
409
|
+
caller: User.make({ subject: "alice" }),
|
|
410
|
+
command: "Internal",
|
|
411
|
+
commandId: yield* actors.mintCommandId,
|
|
412
|
+
payload: "{}",
|
|
413
|
+
}));
|
|
414
|
+
expect(Outcome.guards.Defect(denied)).toBe(true);
|
|
415
|
+
expect(fixture.defects.at(-1)).toMatchObject({
|
|
416
|
+
actor: "Private",
|
|
417
|
+
command: "Internal",
|
|
418
|
+
});
|
|
419
|
+
for (const caller of [
|
|
420
|
+
System.make({ source: "workflow", onBehalfOf: { subject: "alice" } }),
|
|
421
|
+
System.make({ source: "actor", ref: actor.ref, onBehalfOf: { subject: "alice" } }),
|
|
422
|
+
System.make({ source: "actor", onBehalfOf: { subject: "bob" } }),
|
|
423
|
+
])
|
|
424
|
+
expect(yield* executeForTest(Request.make({
|
|
425
|
+
ref: actor.ref,
|
|
426
|
+
caller,
|
|
427
|
+
command: "Internal",
|
|
428
|
+
commandId: id,
|
|
429
|
+
payload: "{}",
|
|
430
|
+
})).pipe(Effect.flip)).toMatchObject({ reason: { code: "receipt_access_denied" } });
|
|
431
|
+
expect(fixture.privateRuns).toBe(attempts);
|
|
432
|
+
expect((yield* bound.inspect).receipts).toBe(2);
|
|
433
|
+
})),
|
|
434
|
+
},
|
|
435
|
+
...["execution timeout", "retryable SQL defect"].map((failure) => ({
|
|
436
|
+
name: `retries the same command after ${failure} without a partial commit`,
|
|
437
|
+
run: ({ environment, expect, fixture }) => environment.run(Effect.gen(function* () {
|
|
438
|
+
const actor = yield* Slow.get(failure);
|
|
439
|
+
const test = yield* ActorTest;
|
|
440
|
+
expect(yield* actor.Read()).toBe(0);
|
|
441
|
+
const before = yield* test.inspect(actor.ref);
|
|
442
|
+
fixture.slowIds = [];
|
|
443
|
+
fixture.slowFirst =
|
|
444
|
+
failure === "execution timeout"
|
|
445
|
+
? Effect.never
|
|
446
|
+
: Effect.die(SqlError.SqlError.make({
|
|
447
|
+
reason: SqlError.DeadlockError.make({
|
|
448
|
+
cause: new Error("injected deadlock"),
|
|
449
|
+
}),
|
|
450
|
+
}));
|
|
451
|
+
const id = yield* (yield* Actors).mintCommandId;
|
|
452
|
+
expect(yield* actor.Bump().pipe(Actor.commandId(id))).toBe(1);
|
|
453
|
+
expect(fixture.slowIds).toEqual([id, id]);
|
|
454
|
+
expect(yield* test.inspect(actor.ref)).toEqual({
|
|
455
|
+
state: { count: 1 },
|
|
456
|
+
receipts: 2,
|
|
457
|
+
events: 0,
|
|
458
|
+
outbox: 0,
|
|
459
|
+
jobs: 0,
|
|
460
|
+
generation: String(Number(before.generation) + 1),
|
|
461
|
+
});
|
|
462
|
+
})),
|
|
463
|
+
})),
|
|
464
|
+
{
|
|
465
|
+
name: "delivery timeout stops waiting while the admitted command commits once",
|
|
466
|
+
run: ({ environment, expect, fixture }) => environment.run(Effect.gen(function* () {
|
|
467
|
+
const actor = yield* DeliveryActor.get("delivery");
|
|
468
|
+
const reached = yield* Deferred.make();
|
|
469
|
+
const release = yield* Deferred.make();
|
|
470
|
+
fixture.deliveryHold = Deferred.succeed(reached, undefined).pipe(Effect.andThen(Deferred.await(release)));
|
|
471
|
+
fixture.deliveryRuns = 0;
|
|
472
|
+
fixture.timeouts.length = 0;
|
|
473
|
+
const id = yield* (yield* Actors).mintCommandId;
|
|
474
|
+
const pending = yield* actor.Bump().pipe(Actor.commandId(id), Effect.forkScoped);
|
|
475
|
+
yield* Deferred.await(reached);
|
|
476
|
+
expect(yield* Fiber.join(pending).pipe(Effect.flip)).toMatchObject({
|
|
477
|
+
reason: Timeout.make({ commandId: id }),
|
|
478
|
+
isRetryable: true,
|
|
479
|
+
});
|
|
480
|
+
expect(fixture.timeouts[0]).toMatchObject({
|
|
481
|
+
actor: actor.ref.actor,
|
|
482
|
+
id: actor.ref.id,
|
|
483
|
+
commandId: id,
|
|
484
|
+
activation: { handlers: 1, building: false, worker: "turn", mailbox: 0, batch: 1 },
|
|
485
|
+
restarting: [],
|
|
486
|
+
});
|
|
487
|
+
const sessions = fixture.timeouts[0]?.turnSessions;
|
|
488
|
+
if (sessions !== undefined)
|
|
489
|
+
expect(sessions).toMatchObject({ leased: 1, waiting: 0 });
|
|
490
|
+
const retry = yield* actor
|
|
491
|
+
.Bump()
|
|
492
|
+
.pipe(Actor.commandId(id), Effect.flip, Effect.timeout("2 seconds"), Effect.ensuring(Deferred.succeed(release, undefined)));
|
|
493
|
+
expect(retry).toMatchObject({ reason: Timeout.make({ commandId: id }) });
|
|
494
|
+
yield* Deferred.succeed(release, undefined);
|
|
495
|
+
const test = yield* ActorTest;
|
|
496
|
+
yield* test
|
|
497
|
+
.inspect(actor.ref)
|
|
498
|
+
.pipe(Effect.repeat({ while: (state) => state.receipts === 0, times: 100 }), Effect.timeout("5 seconds"));
|
|
499
|
+
expect(yield* actor.Bump().pipe(Actor.commandId(id))).toBe(1);
|
|
500
|
+
expect(fixture.deliveryRuns).toBe(1);
|
|
501
|
+
expect(yield* test.inspect(actor.ref)).toEqual({
|
|
502
|
+
state: { count: 1 },
|
|
503
|
+
receipts: 1,
|
|
504
|
+
events: 0,
|
|
505
|
+
outbox: 0,
|
|
506
|
+
jobs: 0,
|
|
507
|
+
generation: "1",
|
|
508
|
+
});
|
|
509
|
+
})),
|
|
510
|
+
},
|
|
511
|
+
];
|
|
512
|
+
/** Foundation actors; its logger records deterministic defects and delivery timeouts for the cases to read. */
|
|
513
|
+
export const foundationSuite = {
|
|
514
|
+
fixture: foundationFixture,
|
|
515
|
+
layer: foundationLayer,
|
|
516
|
+
logger: defectRecorder,
|
|
517
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export { ActorTest, cleanup, sweepContent } from "./actor-test.ts";
|
|
2
|
+
export type { FaultOptions, TestActorOptions, TestConnection, TestMessage } from "./actor-test.ts";
|
|
3
|
+
export { ActorCluster } from "./cluster.ts";
|
|
4
|
+
export { checkBatchLaw } from "./property.ts";
|
|
5
|
+
export { disposableDatabase, testDatabase } from "./database.ts";
|
|
6
|
+
export { SIMULATION_SEEDS, simulationSeeds } from "./simulate.ts";
|
|
7
|
+
export type { Simulation, SimulationFault, SimulationOptions, SimulationReport, SimulationStep, } from "./simulate.ts";
|
|
8
|
+
export { CLUSTER_SIMULATION_SEEDS, clusterSimulationSeeds, FAILOVER_SIMULATION_SEEDS, failoverSimulationSeeds, NIGHTLY_CLUSTER_SIMULATION_SEEDS, NIGHTLY_FAILOVER_SIMULATION_SEEDS, } from "./simulate-cluster.ts";
|
|
9
|
+
export type { ClusterSimulation, ClusterSimulationFault, ClusterSimulationOptions, ClusterSimulationReport, ClusterSimulationStep, } from "./simulate-cluster.ts";
|
|
10
|
+
export type { ClusterOptions, RunnerServices } from "./cluster.ts";
|
|
11
|
+
export { conformance, describeConformance } from "./conformance.ts";
|
|
12
|
+
export type { ConformanceBackend, ConformanceCase, ConformanceConnection, ConformanceContext, ConformanceDatabase, ConformanceEnvironment, ConformanceExpect, ConformanceAccess, ConformanceGroup, ConformanceSuite, ConformanceMatchers, ConformanceRegistrar, ConformanceRuntime, ConformanceServices, } from "./conformance.ts";
|
|
13
|
+
export { edgeKey } from "./conformance/assertions.ts";
|
|
14
|
+
export type { ConformanceEdge, EdgeKey, EdgeRunner, HostedEdge } from "./conformance/assertions.ts";
|
|
15
|
+
export { describeWorkflowEngine, engineCases, engineFixture, Flake, probeBody, ProbeInput, } from "./conformance/workflow-engine.ts";
|
|
16
|
+
export type { EngineCase, EngineCaseContext, EngineFixture, EnginePrimitives, EngineRun, Scenario, WorkflowEngineDriver, } from "./conformance/workflow-engine.ts";
|
|
17
|
+
export { CleanupHooks, TurnHooks } from "../runtime/turn/hooks.ts";
|
|
18
|
+
export { TurnPoolSettings } from "../runtime/turn/pipeline.ts";
|
|
19
|
+
export type { TurnPoint } from "../runtime/turn/hooks.ts";
|
|
20
|
+
export { InternalActors } from "../runtime/actors.ts";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export { ActorTest, cleanup, sweepContent } from "./actor-test.js";
|
|
2
|
+
export { ActorCluster } from "./cluster.js";
|
|
3
|
+
export { checkBatchLaw } from "./property.js";
|
|
4
|
+
export { disposableDatabase, testDatabase } from "./database.js";
|
|
5
|
+
export { SIMULATION_SEEDS, simulationSeeds } from "./simulate.js";
|
|
6
|
+
export { CLUSTER_SIMULATION_SEEDS, clusterSimulationSeeds, FAILOVER_SIMULATION_SEEDS, failoverSimulationSeeds, NIGHTLY_CLUSTER_SIMULATION_SEEDS, NIGHTLY_FAILOVER_SIMULATION_SEEDS, } from "./simulate-cluster.js";
|
|
7
|
+
export { conformance, describeConformance } from "./conformance.js";
|
|
8
|
+
export { edgeKey } from "./conformance/assertions.js";
|
|
9
|
+
export { describeWorkflowEngine, engineCases, engineFixture, Flake, probeBody, ProbeInput, } from "./conformance/workflow-engine.js";
|
|
10
|
+
export { CleanupHooks, TurnHooks } from "../runtime/turn/hooks.js";
|
|
11
|
+
export { TurnPoolSettings } from "../runtime/turn/pipeline.js";
|
|
12
|
+
export { InternalActors } from "../runtime/actors.js";
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
import { Arbitrary } from "effect";
|
|
3
|
+
import type { AnyReducer } from "../members/reducer.ts";
|
|
4
|
+
/** The seed every property runs under unless `PROPERTY_SEED` overrides it. */
|
|
5
|
+
export declare const PROPERTY_SEED = "56";
|
|
6
|
+
/** Generated cases per property unless `PROPERTY_RUNS` overrides it. */
|
|
7
|
+
export declare const PROPERTY_RUNS = 1000;
|
|
8
|
+
/**
|
|
9
|
+
* Checks `options.property` against `options.arbitrary` for a bounded, seeded number of runs
|
|
10
|
+
* and dies with the seed and the shrunk counterexample if it fails, so a
|
|
11
|
+
* failure reproduces with `PROPERTY_SEED=<seed>`. Returns the executed runs.
|
|
12
|
+
*/
|
|
13
|
+
export declare const checkProperty: <A, E = never, R = never>(options: {
|
|
14
|
+
readonly name: string;
|
|
15
|
+
readonly arbitrary: Arbitrary.Arbitrary<A>;
|
|
16
|
+
readonly property: (value: A) => boolean | Effect.Effect<boolean, E, R>;
|
|
17
|
+
readonly runs?: number | undefined;
|
|
18
|
+
}) => Effect.Effect<number, never, R>;
|
|
19
|
+
type ReducerState = Parameters<AnyReducer["reduce"]>[0];
|
|
20
|
+
type ReducerInput = Parameters<AnyReducer["reduce"]>[1];
|
|
21
|
+
/**
|
|
22
|
+
* Checks a batch reducer's ordered fold law over generated states and input
|
|
23
|
+
* lists: reducing the inputs one at a time, in order, and reducing their
|
|
24
|
+
* in-order combination once must both succeed with a valid state, and the two
|
|
25
|
+
* states must be equal. The law is about order-preserving folding, not
|
|
26
|
+
* commutativity, so an order-sensitive combine such as appending passes. A
|
|
27
|
+
* reducer that fails or throws for either path fails the check, because the
|
|
28
|
+
* runtime only folds calls whose reduction cannot fail. States and inputs
|
|
29
|
+
* default to their schemas' arbitraries; lists hold 1 to `maxInputs` inputs
|
|
30
|
+
* (default 8). Returns the executed runs, and dies with a reproducible seed on
|
|
31
|
+
* failure.
|
|
32
|
+
*/
|
|
33
|
+
export declare const checkBatchLaw: (options: {
|
|
34
|
+
readonly reducer: AnyReducer;
|
|
35
|
+
readonly state?: Arbitrary.Arbitrary<ReducerState>;
|
|
36
|
+
readonly input?: Arbitrary.Arbitrary<ReducerInput>;
|
|
37
|
+
readonly maxInputs?: number;
|
|
38
|
+
readonly runs?: number;
|
|
39
|
+
}) => Effect.Effect<number>;
|
|
40
|
+
export {};
|