Status: Accepted (2026-11-28, DC2; shape agreed with R1 realtime, EN2 engine, ED1 editor). Changes shared/src/ops.ts, codec.ts, doc-api.ts, messages.ts: PROTOCOL_VERSION 3, DOC_RULES_VERSION 3.
Moving a selection writes one SET {x, y} per top-level node: ~19 B per node on the wire, one SetOp (four JS objects) per node in the editor, the sync client and every replica, and a 50K-ops-per-message split. The editor refused moves of more than 200K nodes (ADR 0502). The 5M-shape scene cannot be moved at all.
TRANSFORM = 6: {ids: Float64Array (strictly ascending), dx, dy}. For every listed node that exists: x = fround(x + dx), y = fround(y + dy), clamped to ±MAX_COORD, -0 stored as +0. dx/dy are parent-space; subtrees follow, being parent-relative.
6 idlist dx:f64 dy:f64, where idlist is the DELETE id format (1 B per id for consecutive ids).| Stateless: ROOT listed -> ROOT_IMMUTABLE; | dx | or | dy | > 2·MAX_COORD (NaN included) -> BAD_VALUE. No per-node kind check: x/y apply to every kind but PAGE, and only ROOT is a PAGE. |
SET_GEOMETRY = 7: {ids, x?, y?, w?, h?, rotation?: Float32Array}, absolute values aligned with ids.
7 idlist cols:u8 (f32 * n) per set bit (1 x, 2 y, 4 w, 8 h, 16 rotation; other bits are a framing error).Math.fround in the rules. A page-space affine (scale about an anchor, lines keeping their endpoints, text re-measured, paths scaled) would need Math.cos/sin/atan2/hypot. ECMAScript leaves those implementation-approximated, so V8 and JavaScriptCore can differ by an ulp and replicas would diverge. Re-measuring text would also tie DOC_RULES_VERSION to the font metrics. So the editor computes resize results itself and sends them as SET_GEOMETRY (plus per-node SETs for TEXT_SIZING and POINTS). Nodes under rotated parents get one TRANSFORM per distinct local delta.DocCore.apply(..., {inverse: true}) returns the exact inverse: SET_GEOMETRY {x, y} of the old values, sharing ids when every id was live. The sync client reverts pending ops with it.inverseOfTransform undo a TRANSFORM relatively: TRANSFORM(ids, -dx, -dy), sharing the same ids array. This keeps undo at 1 B per id on the wire, adds no 8 B/node old-value copy to the undo stack, keeps peers’ concurrent moves, and lets the engine GPU-bake it.test/transform.test.ts.ChangeSet.transforms: {roots: Int32Array, dx, dy}[] lists each TRANSFORM in apply order (EN2). The roots and their descendants are not put in changed for it, so the engine bakes the translation on the GPU and then re-derives whatever changed lists. Roots created in the same drain window are left out; they are in created. SET_GEOMETRY marks its nodes GEOMETRY-changed as usual.MAX_BATCH_EXTRAS (1,048,576) ids plus block nodes. Server cost stays proportional to message bytes: id ranges were deliberately not run-length encoded, because a few bytes could then expand into 8M ids. The sync client splits oversized TRANSFORM / SET_GEOMETRY ops into id-range chunks at commit.node packages/doc/bench/run.ts --only move, 200K top-level nodes of a 1M-shape page, medians of 10, shared M4 Pro)| Stage | TRANSFORM | 200K SETs {x, y} | |—|—:|—:| | OPS payload | 195 KiB, 1 message (1.00 B/node) | 3,711 KiB, 4 messages (19.0 B/node) | | Editor build + encode | 0.0 + 0.9 ms | 8.1 + 15.5 ms | | Gateway ScanBatch + owner StructIndex.check | 1.6 + 0.0 ms | 10.4 + 8.3 ms | | Author apply (local, with inverse) | 7.3 ms | 51.6 ms | | Replica decode + apply (sequenced) | 1.2 + 6.8 ms | 12.6 + 22.2 ms | | Undo sent | 195 KiB (relative) | 3,711 KiB |
shared/src/api.ts) has no transform entries yet. opsToJson expands SET_GEOMETRY into sets and throws on TRANSFORM.packages/doc/test/transform.test.ts (equivalence, determinism over the wire, exact inverses, relative undo drift, change feed, verdicts, clamping, the batch cap), the 100K-batch rule equivalence (22K accepted bulk ops) and shared/test/codec.test.ts.