Status: Accepted (2026-11-28, DC2). Supersedes decision 1 of 0102 (ids, 8 B/node). Implements the E2 id step of 0024.
The E1 id map stored a Uint32 counter per handle plus a per-client dense counter -> handle table: 8 B per node, the largest part of the doc left to cut (ADR 0024 projects ~0 B for generated content). Gates: memoryReport() bytes/node must drop or hold for both bench scenes; decode/encode, ScanBatch and StructIndex must not regress; canonical snapshots stay byte-stable.
packages/doc/src/idmap.ts; same interface, in memory only, so snapshots and the wire are unchanged.
insertUnique reports a repeated id through segment overlap, without a lookup per node.node packages/doc/bench/run.ts, shared M4 Pro; codec times are medians of 5)| | E1 | E2 | |—|—:|—:| | idMap, both scenes | 8.00 B/node | 0.01 B/node | | 5M shapes after snapshot load | 55.13 B/node | 47.13 B/node | | 5M shapes after generation (1.25x slack) | 62.57 B/node | 53.59 B/node | | 4,000 pages, nodes (content counted separately) | 51.20 B/node | 43.21 B/node | | decodeSnapshot 5M / 4,000 pages | 1,216 / 236 ms | 1,078 / 212 ms | | encodeSnapshot 5M / 4,000 pages | 1,597 / 251 ms | 1,577 / 244 ms | | ScanBatch / StructIndex.check | 47 / 111 ns | 48 / 96 ns (no id map involved) | | apply 100K SETs (2 lookups each) | 7.4 ms | 8.0 ms |
The lookup costs ~3 ns more on the SET path. That is the only regression, and it is far inside the 50 ms target; the memory win was judged worth it.
packages/doc/test/idmap.test.ts: a Map-reference property test with bulk and single creates, removes, handle reuse, restores into old or new handles, and counter gaps. Also by the 100K-batch rule equivalence, the inverse round trips and the codec fuzz (npm test -w @linorahq/doc).