Repository navigation
feat(domain): verify handlers that sleep, race, time out and run fibers - #3743
Merged
Merged
Conversation
… on a virtual clock
… on time and fibers
…library on the handler's timeline
…e timeline, and one that never ends is stopped
Contributor
Website Preview DeployedURL: https://pr-3743-alchemy-website-preview.testing-2b2.workers.dev Built from commit This comment updates automatically with each push. |
Contributor
|
Install the packages built from this commit: alchemypnpm install https://pkg.alchemy.run/alchemy/pr:3743:42a543f@alchemy.run (36)pnpm install https://pkg.alchemy.run/@alchemy.run/better-auth/pr:3743:42a543fpnpm install https://pkg.alchemy.run/@alchemy.run/git/pr:3743:42a543fpnpm install https://pkg.alchemy.run/@alchemy.run/drizzle/pr:3743:42a543fpnpm install https://pkg.alchemy.run/@alchemy.run/acme/pr:3743:42a543fpnpm install https://pkg.alchemy.run/@alchemy.run/archil/pr:3743:42a543fpnpm install https://pkg.alchemy.run/@alchemy.run/boat/pr:3743:42a543fpnpm install https://pkg.alchemy.run/@alchemy.run/axiom/pr:3743:42a543fpnpm install https://pkg.alchemy.run/@alchemy.run/doppler/pr:3743:42a543fpnpm install https://pkg.alchemy.run/@alchemy.run/infisical/pr:3743:42a543fpnpm install https://pkg.alchemy.run/@alchemy.run/1password/pr:3743:42a543fpnpm install https://pkg.alchemy.run/@alchemy.run/turso/pr:3743:42a543fpnpm install https://pkg.alchemy.run/@alchemy.run/convex/pr:3743:42a543fpnpm install https://pkg.alchemy.run/@alchemy.run/e2b/pr:3743:42a543fpnpm install https://pkg.alchemy.run/@alchemy.run/daytona/pr:3743:42a543fpnpm install https://pkg.alchemy.run/@alchemy.run/modal/pr:3743:42a543fpnpm install https://pkg.alchemy.run/@alchemy.run/planetscale/pr:3743:42a543fpnpm install https://pkg.alchemy.run/@alchemy.run/neon/pr:3743:42a543fpnpm install https://pkg.alchemy.run/@alchemy.run/prisma/pr:3743:42a543fpnpm install https://pkg.alchemy.run/@alchemy.run/hetzner/pr:3743:42a543fpnpm install https://pkg.alchemy.run/@alchemy.run/digitalocean/pr:3743:42a543fpnpm install https://pkg.alchemy.run/@alchemy.run/railway/pr:3743:42a543fpnpm install https://pkg.alchemy.run/@alchemy.run/fly/pr:3743:42a543fpnpm install https://pkg.alchemy.run/@alchemy.run/github/pr:3743:42a543fpnpm install https://pkg.alchemy.run/@alchemy.run/stripe/pr:3743:42a543fpnpm install https://pkg.alchemy.run/@alchemy.run/cloudflare/pr:3743:42a543fpnpm install https://pkg.alchemy.run/@alchemy.run/gcp/pr:3743:42a543fpnpm install https://pkg.alchemy.run/@alchemy.run/aws/pr:3743:42a543fpnpm install https://pkg.alchemy.run/@alchemy.run/domain/pr:3743:42a543fpnpm install https://pkg.alchemy.run/@alchemy.run/kubernetes/pr:3743:42a543fpnpm install https://pkg.alchemy.run/@alchemy.run/docker/pr:3743:42a543fpnpm install https://pkg.alchemy.run/@alchemy.run/redis/pr:3743:42a543fpnpm install https://pkg.alchemy.run/@alchemy.run/sql/pr:3743:42a543fpnpm install https://pkg.alchemy.run/@alchemy.run/cloudflare-runtime/pr:3743:42a543fpnpm install https://pkg.alchemy.run/@alchemy.run/frontend-frameworks/pr:3743:42a543fpnpm install https://pkg.alchemy.run/@alchemy.run/node-utils/pr:3743:42a543fpnpm install https://pkg.alchemy.run/@alchemy.run/pkg/pr:3743:42a543fTransitive Dependencies (30)pnpm install https://pkg.alchemy.run/@distilled.cloud/aws/pr:3743:42a543fpnpm install https://pkg.alchemy.run/@distilled.cloud/acme/pr:3743:42a543fpnpm install https://pkg.alchemy.run/@distilled.cloud/archil/pr:3743:42a543fpnpm install https://pkg.alchemy.run/@distilled.cloud/core/pr:3743:42a543fpnpm install https://pkg.alchemy.run/@distilled.cloud/boat-dev/pr:3743:42a543fpnpm install https://pkg.alchemy.run/@distilled.cloud/axiom/pr:3743:42a543fpnpm install https://pkg.alchemy.run/@distilled.cloud/doppler/pr:3743:42a543fpnpm install https://pkg.alchemy.run/@distilled.cloud/infisical/pr:3743:42a543fpnpm install https://pkg.alchemy.run/@distilled.cloud/turso/pr:3743:42a543fpnpm install https://pkg.alchemy.run/@distilled.cloud/convex/pr:3743:42a543fpnpm install https://pkg.alchemy.run/@distilled.cloud/e2b/pr:3743:42a543fpnpm install https://pkg.alchemy.run/@distilled.cloud/daytona/pr:3743:42a543fpnpm install https://pkg.alchemy.run/@distilled.cloud/modal/pr:3743:42a543fpnpm install https://pkg.alchemy.run/@distilled.cloud/planetscale/pr:3743:42a543fpnpm install https://pkg.alchemy.run/@distilled.cloud/neon/pr:3743:42a543fpnpm install https://pkg.alchemy.run/@distilled.cloud/s3/pr:3743:42a543fpnpm install https://pkg.alchemy.run/@distilled.cloud/prisma/pr:3743:42a543fpnpm install https://pkg.alchemy.run/@distilled.cloud/hetzner/pr:3743:42a543fpnpm install https://pkg.alchemy.run/@distilled.cloud/digitalocean/pr:3743:42a543fpnpm install https://pkg.alchemy.run/@distilled.cloud/railway/pr:3743:42a543fpnpm install https://pkg.alchemy.run/@distilled.cloud/fly-io/pr:3743:42a543fpnpm install https://pkg.alchemy.run/@distilled.cloud/github/pr:3743:42a543fpnpm install https://pkg.alchemy.run/@distilled.cloud/stripe/pr:3743:42a543fpnpm install https://pkg.alchemy.run/@distilled.cloud/aws4signer/pr:3743:42a543fpnpm install https://pkg.alchemy.run/@distilled.cloud/cloudflare/pr:3743:42a543fpnpm install https://pkg.alchemy.run/@distilled.cloud/iceberg/pr:3743:42a543fpnpm install https://pkg.alchemy.run/@distilled.cloud/gcp/pr:3743:42a543fpnpm install https://pkg.alchemy.run/@alchemy.run/effect-cluster/pr:3743:42a543fpnpm install https://pkg.alchemy.run/@alchemy.run/rivet/pr:3743:42a543fpnpm install https://pkg.alchemy.run/@distilled.cloud/rivet/pr:3743:42a543fPublished |
…e, and the report's lines pinned to the docs
…try across fibers
…hore, ScopedCache and Pool.makeWithTTL
…n out once it is rounded
…sts written as classes
…ore of arrays and objects
…n, Array, JSON and the rest
…on how deep functions call
…ns, and classes the prover reads
… in four CI parts
Each path through a decision is replayed through the real decide and evolve. A path the prover read wrongly is Misread, and one where decide throws is reported as dying.
…al-time # Conflicts: # pnpm-lock.yaml
Contributor
Website Preview DeployedURL: https://pr-3743-alchemy-website-preview.testing-2b2.workers.dev Built from commit This comment updates automatically with each push. |
The prover's tests, fixtures and coverage gate live with the package. The bank example keeps the tests of its own domain, and CI runs both.
This was referenced Dec 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A handler that sleeps, sets a time limit, races two effects or starts a fiber is now proved, for every duration an input can give:
The prover does not model these. It hands the library the handler's effects and lets the library run them, on time that passes only when no fiber can run. What a race, a time limit, an interrupt or a finalizer does is then what the deployed handler does, by being the same code. Supported this way:
The same holds for what a stream is made of, for a scope the code holds, and for random numbers a seed decides:
More of the language and of plain values is read too:
Optics, sinks, channels and filters are the library's own, composed as it composes them:
Aggregate.predictruns a handler on the same clock, so a prediction of one that waits is made at once:Still reported, each with its reason:
A handler that waits again and again without end is now reported (
waits more than 10000 times: the handler would never end). This is what a stream's own time limit does in a handler:Stream.timeoutworks out its deadline from the clock, and a handler's clock stays at the time the command is handled at.The report's assumptions gain one line: code between two waits takes no time, so a time limit never stops a computation that does not wait.
A path no input takes is no longer reported when the prover stops on it.
Code the library runs at once (a
Stream.partitionQueuefilter, anEffect.callbackregister function, a cache'stimeToLive) takes both sides of a branch an input decides. A side no input takes is dropped when its path is checked. Before, such a branch asked the solver from inside a synchronous run and left the question running.Every function of a module the prover reads is now modelled or reported with a reason, and a test holds it to that:
RequestResolver.persistedkeeps results in a Persistence store outside the handler, so it is reported.Effect.timed,Sink.timedandSink.withDurationmeasure with the machine's clock, not the handler's, so they are reported.A policy's handler that waits is followed by the search of the model too. A test now pins each line of a report that the docs and the skill quote to a message the prover says.
A finalizer that fails now fails the effect, as the library's does. Before, the prover read it as a defect:
Uint8Array([1])withoutnewis reported, as the language throws on it.JSON.stringifyof a bigint is reported instead of stopping the prover.A schema's class, an event or a schema's
make, given a value that may not fit, throws on the inputs that don't, as the real constructor does. Before, the prover dropped those inputs. Acatcharound the constructor is read on them, and a handler or a decision that dies is reported, once its real code throws on the same inputs:Every path through a decision is now run on the real
decideandevolve, as an aggregate command's already was. A path the prover reads wrongly marks its rulesMisread, andDecisionReportgainsagreementanddies.The prover's tests and fixtures move from the bank example to
packages/domain/test. The example keeps the tests of its own domain (Bank.*,Address,Consumer), and CI runs both.Every function and every branch of the models, the library, the interpreter and the timeline runs in a test.
pnpm test:coverageinpackages/domainfails below 100% of either; a branch the code cannot take says why with av8 ignorehint. It also runs each modelled function misused, with nothing, too little and the wrong kinds of values, runs the streams and channels those calls make, and each must be reported or read without stopping the prover.Branches the tests found wrong, now fixed:
The prover reads
namespace Outer.Inner { ... }.A policy that races a wait an input decides against a limit is read on both sides of it. Two waits that never end are not a tie.