ADR-011: Emmett/TypeScript as First Code Generation Target
Context
Weltenwanderer needs at least one code generation target to be useful. Candidates evaluated:
| Option | Stack match | Event store | Boilerplate | Ecosystem |
|---|---|---|---|---|
| Emmett/TypeScript | Yes (Bun/TS) | Built-in | Low | Large |
| Axon 5 (Java) | No | Built-in | Medium | Large |
| PostgreSQL native SQL | Partial | Manual | High | N/A |
| Custom runtime | N/A | Manual | Very high | None |
The choice of first target shapes generator abstractions that all future targets must fit within.
Decision
Emmett/TypeScript is the first and initially only code generation target. Per-decider output consists of: a decider class, smart constructors (from validate constraints), event/state union types, and Emmett wiring. The generator architecture is designed to accommodate future targets (Axon 5, PostgreSQL, WASM) via separate generator packages, but only Emmett is implemented in Phase 4.
Level 2 verification uses fast-check (TypeScript property-based testing) against the generated code, consistent with the TypeScript-first choice.
Consequences
Positive
- TypeScript matches the compiler’s own stack — no language boundary in the toolchain.
- Emmett provides event store, projection setup, and decider wiring, reducing generated boilerplate.
- fast-check enables property-based Level 2 verification without a second language runtime.
- Large TypeScript ecosystem for consumers of generated code.
Negative
- First target biases generator abstractions toward TypeScript patterns; future targets may need adapters.
- Emmett-specific wiring code (e.g.,
CommandHandler,EventStoretypes) may not generalize. - Java/SQL targets require separate generator packages with their own test suites.