Architecture decision record · ADR-0015

How codegen classifies a contract type

The classifier uses these rules in this order:

Status
Accepted
Deciders
Joe Gaudet
Created
Updated
PRD
PRD
Related
None

Context

A contract does not say if an object is an entity, a shape or a value. The generator must decide, and the app must be able to see and change the decision.

Decision drivers

Not recorded in the original ADR.

Options considered

Not recorded in the original ADR.

Decision

The classifier uses these rules in this order:

  1. An explicit mark wins: x-millwork: entity | shape | value in OpenAPI, a @millwork(kind: ...) directive in GraphQL, or the classify map in the config.
  2. Entity: a JSON:API resource object, a GraphQL object type with id: ID!, or an OpenAPI object with an id property that an operation gives at the top level of a response (also inside an array or a data property).
  3. Value: every property is readOnly.
  4. Shape: every other object.
  • An inline object gets the name of its parent plus the property name, in PascalCase. A title or x-millwork-name replaces it.
  • Two types with the same structure and different names stay two types.
  • millwork-codegen explain prints the rule and the source of each decision.

Consequences

  • The default is a shape, because a form can edit a shape. A wrong default costs little.
  • An app with an unusual API uses marks or the config, not changes to the generated files.

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/0015-codegen-classification.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/0015-codegen-classification.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/0015-codegen-classification.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.