Architecture decision record · ADR-0001

Codecs use kind: 'field' and kind: 'array'

Each codec registers as a Transformation and the field uses kind: 'field'.

Status
Accepted
Deciders
Joe Gaudet
Created
Updated
PRD
PRD
Related
None

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>, for kind: '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

  • serialize gets the value object as it is, so isValue checks and instanceof work.
  • The read of a kind: 'field' value is not memoized by WarpDrive. ADR 0002 adds a memo.
  • kind: 'object' spreads the value before serialize. 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 bigint in the raw value survives structuredClone, but JSON.stringify throws. Then the request body fails, and the nested revert check (it uses JSON.stringify in a try) keeps a change that it must clear.

Confirmation

Evidence

  • packages/warp-drive/tests/spikes/s6-raw-values.test.ts
  • packages/warp-drive/tests/spikes/s1-field-kinds.test.ts (Transformation and array:<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.

QuestionAnswerSource
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

DateAuthorChange
2026-12-01Joe GaudetStatus in the Markdown file: Accepted (M0, spikes S1 and S6).
2026-12-01Joe GaudetCommit 0a16254: Build Millwork 1.0 (#1)
2026-12-04Joe 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.