Memo keys, and new raw values
A kind: 'field' value is memoized by record and field, while the raw value is the same reference.
Context
ADR 0002 keys the memo by record and field. Two items were open:
kind: 'array'callshydrate(rawItem, options, record)with no index. So all elements share one slot. A primitive element (for example a decimal string) has no object key.- A push with equal JSON gives a new raw reference. Is the old value kept when
equalsis true?
Decision drivers
Not recorded in the original ADR.
Options considered
Not recorded in the original ADR.
Decision
A
kind: 'field'value is memoized by record and field, while the raw value is the same reference.An
array:<name>element is memoized by record and field, and then:- by the raw element itself when it is an object (
WeakMap<raw, value>); - by its value when it is a primitive (
Map<primitive, value>). Equal primitives give equal immutable values, so they can share one value. The map starts again at 1000 entries.
- by the raw element itself when it is an object (
A new raw reference always gives a new value, also when the JSON is equal. Millwork does not compare with
equalson read.The memo key is the Transformation name and the field name (
options.field). Two fields with the same raw value and different Transformations never share a value.A field with no
options.field(no options, or options that you write by hand) is keyed by its options object. WarpDrive gives the same options object on each read, so the memo stays. With no options at all, the key is the Transformation name only. This is correct: the same codec with no options gives an equal value for the same raw value. We did not skip the memo for these fields, because thenrecord.a === record.ais false.
Consequences
record.total === record.total, andrecord.prices[0] === record.prices[0].- Two equal primitive elements give the same value object. This is correct for immutable values.
- A push from the server gives a new value, so code that compares by reference sees new data.
The cost of
equalson each read is not paid.
Confirmation
Evidence
packages/warp-drive/tests/transformation.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/0008-memo-keys.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/0008-memo-keys.md |
Changelog
| Date | Author | Change |
|---|---|---|
| 2026-12-01 | Joe Gaudet | Status in the Markdown file: Accepted (M2). This closes the two open items of ADR 0002. |
| 2026-12-01 | Joe Gaudet | Commit 0a16254: Build Millwork 1.0 (#1) |
| 2026-12-04 | Joe Gaudet (agent) | Converted from docs/adr/0008-memo-keys.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.