Architecture decision record · ADR-0007

A shape is a kind: 'field' with a Millwork Transformation

shapeField, shapeArrayField and the polymorphic forms make a kind: 'field' field with type: 'millwork:shape'.

Status
Accepted
Deciders
Joe Gaudet
Created
Updated
PRD
PRD
Related
None

Context

ADR 0005 says that a shape reads through WarpDrive and writes through its own setter. A schema-object field gives back a WarpDrive object. That object has the WarpDrive setters, which use the nested setAttr path (S2 bugs 1 and 2). Its polymorphic setter throws. It has no class methods and no Tracked API.

Decision drivers

Not recorded in the original ADR.

Options considered

Not recorded in the original ADR.

Decision

  • shapeField, shapeArrayField and the polymorphic forms make a kind: 'field' field with type: 'millwork:shape'. transformations() registers this one Transformation.
  • The field options are JSON. They name the shape by its static type: { field: 'items', shape: 'line-item', array: true, key: 'sku' }, or { field: 'payment', shape: { card: 'card', bank: 'bank' }, discriminator: '$type' }. The helpers register the classes in the core name registry.
  • hydrate gives the instance of the shape class. A core Slot keeps one instance for each record and field, and for each member key of a shape array.
  • Each read of a shape field reads the record field first. That read consumes the field signal and calls hydrate, which gives the slot the latest raw value. So a shape that the app keeps in a variable reads fresh data, and a template that reads it renders again.
  • A shape write makes the next whole top-level raw value and sets it through the record (record[field] = new RawWrite(next)). WarpDrive then throws on an immutable Polaris record, permits the write on a legacy-mode record, and notifies the signal.
  • Before the write, core compares the next raw value with the remote raw value, field by field with each codec equals. When they are equal, it writes the remote reference, so the cache clears the change.
  • A field with no raw value gives an empty shape, so the app can write into it. A polymorphic field with no raw value (or an unknown discriminator) gives undefined.

Consequences

  • The three S2 scenarios pass through the Millwork API in both modes (packages/warp-drive/tests/shapes.test.ts). The test.fails spikes stay as they are.
  • The schema does not show the nested fields to WarpDrive tools. The Millwork class holds them.
  • valueField uses the same equals check, so a set of an equal value clears the change.
  • The Ember example app shows that a template renders again after a shape write, a value write, a rollback and a push (examples/ember-app).

Confirmation

Evidence

  • packages/warp-drive/tests/shapes.test.ts, packages/warp-drive/tests/transformation.test.ts
  • examples/ember-app/tests/integration/order-editor-test.gts

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/0007-shape-field-kind.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/0007-shape-field-kind.md

Changelog

DateAuthorChange
2026-12-01Joe GaudetStatus in the Markdown file: Accepted (M3). This changes plan section 4.4: a shape does not use schema-object, and a shape array does not use schema-array.
2026-12-01Joe GaudetCommit 0a16254: Build Millwork 1.0 (#1)
2026-12-04Joe Gaudet (agent)Converted from docs/adr/0007-shape-field-kind.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.