Architecture decision record · ADR-0001
Codecs use kind: 'field' and kind: 'array'
Each codec registers as a Transformation and the field uses kind: 'field'.
Context
A codec turns a raw wire value into a rich value object (for example a Money or a
DateTime). WarpDrive gives three field kinds that run a Transformation: field, object and
array. The research said that kind: 'object' removes the prototype of a class instance.
Decision drivers
Not recorded in the original ADR.
Options considered
Not recorded in the original ADR.
Decision
- Each codec registers as a Transformation and the field uses
kind: 'field'. - Each codec also registers as
array:<name>, forkind: 'array'. WarpDrive runs that Transformation on each element. - Millwork does not use
kind: 'object'for a codec. - Each raw value in the cache is JSON: a primitive, a plain object or an array. A codec never
puts a
bigint, a class instance or a function into the cache.
Consequences
serializegets the value object as it is, soisValuechecks andinstanceofwork.- The read of a
kind: 'field'value is not memoized by WarpDrive. ADR 0002 adds a memo. kind: 'object'spreads the value beforeserialize. On read, it wraps the hydrated value in a managed object. Both lose the class.- A nested cache write copies the raw value with
structuredClone. A class in the raw value loses its prototype. A function makes the write throw. - A
bigintin the raw value survivesstructuredClone, butJSON.stringifythrows. Then the request body fails, and the nested revert check (it usesJSON.stringifyin atry) keeps a change that it must clear.
Confirmation
Evidence
packages/warp-drive/tests/spikes/s6-raw-values.test.tspackages/warp-drive/tests/spikes/s1-field-kinds.test.ts(Transformation andarray:<name>)
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/0001-codec-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/0001-codec-field-kind.md |
Changelog
| Date | Author | Change |
|---|---|---|
| 2026-12-01 | Joe Gaudet | Status in the Markdown file: Accepted (M0, spikes S1 and S6). |
| 2026-12-01 | Joe Gaudet | Commit 0a16254: Build Millwork 1.0 (#1) |
| 2026-12-04 | Joe Gaudet (agent) | Converted from docs/adr/0001-codec-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.