Architecture decision record · ADR-0010
The class form is the main form; the JSON form has equal power
The class form is the main form: class Address extends Shape with @field.
Context
Plan decision 7 has two declaration forms: a class with decorated fields, and a JSON schema.
Open question 1 asks which form is the source of truth. Open question 2 asks if a value class
needs with({...}).
Decision drivers
Not recorded in the original ADR.
Options considered
Not recorded in the original ADR.
Decision
- The class form is the main form:
class Address extends Shapewith@field. The JSON formshape({ type, fields })andvalue({ type, fields })gives a class with the same power. - Both forms make the same internal definition. A test compares them with
definitionOf. @fieldworks with standard decorators (@field accessor city!: string) and with the legacy decorators that Ember compiles (@field declare city: string). Standard decorators keep the fields inSymbol.metadata. Core setsSymbol.metadatatoSymbol.for('Symbol.metadata')when the runtime has none (the same key as esbuild and Babel), so tsc output works too.- Each class has a static
typename. Minifiers rename classes, so the name is not taken from the class. - A
Valueis immutable: a write throws aTypeError.with({...})gives a copy. A value class is also a codec (Price.codec), sovalueField('price', Price)and the legacy transforms use it with no extra code. equalscompares field by field with each codecequals.shapeSchema(Class)gives the Standard Schema of a shape or value class, with each issue path.toStandardSchema(codec)stays for codecs. The codec function and its signature did not change.- A polymorphic field takes a map of discriminator values to classes. The key is
$typeby default, and thediscriminatoroption changes it. The discriminator stays in the raw value.
Consequences
- An app can declare shapes in JSON (for example from a server schema) with no loss.
- The plan used
toStandardSchema(Address). The name isshapeSchema(Address).
Confirmation
Evidence
packages/core/tests/shapes/shape.test.ts,packages/core/tests/shapes/schema.test.ts
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.
| Question | Answer | Source |
|---|---|---|
| Where does the text of this page come from? | From the Markdown file docs/adr/0010-declaration-forms.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/0010-declaration-forms.md |
Changelog
| Date | Author | Change |
|---|---|---|
| 2026-12-01 | Joe Gaudet | Status in the Markdown file: Accepted (M3). This answers open questions 1 and 2 of the plan. |
| 2026-12-01 | Joe Gaudet | Commit 0a16254: Build Millwork 1.0 (#1) |
| 2026-12-04 | Joe Gaudet (agent) | Converted from docs/adr/0010-declaration-forms.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.