Architecture decision record · ADR-0014

Codegen is a separate package with one intermediate form

A new package @millwork-ts/codegen holds the CLI millwork-codegen, the readers, the intermediate form (the contract IR), the classifier and the emitters.

Status
Accepted
Deciders
Joe Gaudet
Created
Updated
PRD
PRD
Related
None

Context

The user wants one API contract (OpenAPI, JSON:API or GraphQL) to give the WarpDrive schemas, the Millwork shapes and values, the Real Enums, the Formwright validators and the Harnessed mocks. Core must stay free of peers, Ember and WarpDrive.

Decision drivers

Not recorded in the original ADR.

Options considered

Not recorded in the original ADR.

Decision

  • A new package @millwork-ts/codegen holds the CLI millwork-codegen, the readers, the intermediate form (the contract IR), the classifier and the emitters. It runs in Node only.
  • The generator does not import a target library. It writes source text that imports them.
  • Each reader writes the same IR. Each emitter reads only the IR. A new reader or emitter does not change the others.
  • A new package @millwork-ts/contract holds the small run-time helpers that generated code needs: the Real Enums codec bridge and the normalizer that turns a REST or GraphQL response into a JSON:API document. It has no peers except core.
  • The default WarpDrive door is SchemaRecord (Polaris). door: 'legacy' gives legacy-mode schemas with withDefaults. Only one door is on in one run.
  • The generated files start with a "do not edit" line. --check fails when they differ from the contract.

Consequences

  • An app adds two dev and run-time packages. It does not add a peer to core.
  • An emitter can only use what the IR records. Data that the IR drops is not in the output.

Confirmation

Not recorded in the original ADR.

Interview record

Each question of the interview with its answer and its source. A fact from the code or a document, a question that the author did not ask, and an assumption are rows too.

QuestionAnswerSource
Where does the text of this page come from?From the Markdown file docs/adr/0014-codegen-package.md at commit c8154b0. The text of each section is the text of the Markdown file. A section that the Markdown file does not have says so.Document: docs/adr/0014-codegen-package.md

Changelog

DateAuthorChange
2026-12-03Joe GaudetStatus in the Markdown file: Accepted (codegen C0).
2026-12-03Joe GaudetCommit 7b66d71: Add codegen: one contract gives WarpDrive, Millwork, real-enums, Formwright and harnessed code (#7)
2026-12-04Joe Gaudet (agent)Converted from docs/adr/0014-codegen-package.md to this page. The text is the text of the Markdown file.

The adr skill of skillsaw wrote this page. The HTML in this file is the source of truth. The diagrams are the Mermaid sources in it.