1---
2title: Looping the Generation of Local Emulators
3date: 2026-08-20T16:00:00Z
4draft: true
5excerpt: The live test suite that generates our IaC and SDKs is also an executable spec of the cloud. Point it at an emulator and every red test is a fidelity bug with a repro. alchemy dev now emulates 219 resources across ~39 AWS services on your machine, with no AWS account.
6---
7
8In [Looping the Generation of IaC and SDKs](/blog/2026-07-02-cloudflare-resource-factory)
9we described the loop that builds Alchemy: fleets of AI agents
10write resources and their live tests, run them against the real
11cloud, and every API behavior the SDK's types don't capture
12becomes a typed patch to the generated SDK. The resource is the
13product; the truthful SDK is the byproduct.
14
15The loop now has a second byproduct: a **local emulator**. What
16makes it possible is the tests, and they cover both halves of the
17cloud. The resource tests exercise the **control plane**: deploy
18a resource, verify it out-of-band against the raw API, mutate it,
19prove its destruction. The binding tests exercise the **data
20plane**: a deployed function actually calling `putObject`,
21`getItem`, `sendMessage` against the resources bound to it.
22Together, thousands of them are an **executable specification of
23the cloud**. Every consistency quirk, undocumented error code,
24and misused HTTP status the factory ever caught is pinned as an
25assertion.
26
27An emulator has to satisfy the same specification. So we
28extended the factory: point the same suite at a local emulator,
29and every red test is a fidelity bug that arrives with its own
30reproduction. This is how `alchemy dev` for AWS works. Your
31stack runs on your machine with no AWS account and no
32credentials. It shipped in
33[2.0.0-beta.75](/blog/2026-08-25-beta-75).
34
35## We forked floci
36
37We [forked](https://github.com/alchemy-run/floci)
38[floci](https://floci.io)'s AWS implementation because they've
39already laid a great foundation for local development but don't
40have full coverage. They're adding more every day, but we want
41to automate the emulator's development and will push for 100%
42next release. In this version we focused on patching services
43floci already supported, and added MicroVMs, a new service that
44is very important to alchemy.
45
46The patches span about 30 services: Lambda's streaming Function
47URLs, ELBv2's ALB data plane, AppSync's Velocity template
48directives, EC2, IAM, SES, Cognito, Athena, event-source
49mappings. Every one of them exists because an alchemy test
50failed against the emulator after passing against AWS.
51
52We'd like to contribute these upstream, but the factory is a
53fully automated fan-out, with fleets of agents producing fixes
54faster than any maintainer could reasonably review. Flooding the
55floci team with that maintenance burden isn't fair to them. It's
56easier to let alchemy's flywheel drive the fork directly.
57
58## The flywheel
59
60What drives the fork is the test suite. The harness has one
61switch that points it at the emulator instead of live AWS:
62
63```sh
64pnpm test:aws:floci
65```
66
67It runs the same test suite that normally runs against live AWS,
68except every call goes to floci instead. Nothing is mocked: each
69Lambda still cold-starts in its own Docker container.
70
71Agents run the suite and fix every red test. The fix always goes
72in the fork, never in alchemy: we don't loosen a test or
73special-case lifecycle code to tolerate the emulator, so the
74suite stays a single source of truth that both AWS and floci
75have to satisfy. Each fix lands with a conformance test in the
76emulator's own suite.
77
78For example: a live test asserts that a streaming Function URL
79delivers its first bytes before the handler finishes. floci
80buffered the stream, the test went red, the fix landed in the
81fork, and streaming now behaves the same locally as in
82`us-east-1`.
83
84The same goes for coverage gaps. Some operations in floci throw
85`UnsupportedOperation`. We never work around one in alchemy; we
86patch floci to support the operation. We're strict about this.
87
88## Results
89
90`alchemy dev` now emulates **219 resources across ~39 AWS
91services** locally, with **396 tests green** against the
92emulator. Several services pass their full live suite: DynamoDB
93(105 tests), S3 (51), Step Functions (31), Cognito (19), and
94others. Next release we'll run the flywheel until the emulator
95conforms to 100% of what alchemy supports.
96
97The result is [`alchemy dev` for AWS](/aws/local-development).
98It also makes the factory cheaper: generation waves can now
99iterate against floci with no rate limits, no
100eventual-consistency stalls, and no leaked cloud resources,
101touching the real cloud only to certify.
102
103## Three artifacts per cloud
104
105The end state we're building toward is a flywheel that, for each
106cloud provider, produces three artifacts from one loop:
107
1081. **Infrastructure-as-Code**: typed resources and bindings in
109 Alchemy, with lifecycle logic whose error handling is
110 verified against the live API.
1112. **A refined spec and Effect-native SDK**: distilled, where
112 every behavior a live test observes becomes a typed patch to
113 the provider's spec, compounding for every future consumer.
1143. **A local emulator**: held conformant to the same test suite
115 that certifies the IaC, so `alchemy dev` is a faithful copy
116 of `alchemy deploy`.
117
118Each artifact makes the others cheaper. The refined SDK types
119make lifecycle code generable. The lifecycle tests make the
120emulator convergeable. The emulator makes the tests and your
121dev loop free to run. And in the limit, the refined spec is
122the substrate for all three: an emulator is just another
123consumer of a spec, and every patch that teaches the spec what
124the API really does is a piece of the emulator nobody has to
125hand-write.
126
127Cloudflare already runs this way: its Workers simulators are
128built on workerd itself and held to the same live suites. AWS
129now joins it. The next provider the factory brings up will ship
130all three artifacts together.
131
132- [2.0.0-beta.75 — the release AWS local dev shipped in](/blog/2026-08-25-beta-75)
133- [AWS local development](/aws/local-development)
134- [Looping the Generation of IaC and SDKs — the first post in this series](/blog/2026-07-02-cloudflare-resource-factory)
135- [alchemy-run/floci — the fork](https://github.com/alchemy-run/floci)
136- [distilled — the generated, patchable SDK](https://github.com/alchemy-run/distilled)