Linora

0003. Headless document core in typed arrays (no object per node)

Status: Superseded by 0024 for the storage layout and memory numbers (2026-11-27). Still valid: one headless typed-array doc core shared by browser, doc workers, compactor and (via ScanBatch/StructIndex) the realtime tier; no JS object per node; change feed via drainChanges(); rejection of JS-object, Yjs and Automerge stores.

Context

src/scene.ts is a render store: primitives in z-order with world coordinates, objects as primitive ranges, no ids, no tree, text stored only as glyph primitives. A product needs a document (stable ids, tree, pages, text content) that the server and MCP can load without WebGL. Scale targets: 682K layers (11M primitives) and 5M flat shapes in one page.

Measured/estimated CPU memory today: ~48 B per primitive + ~12 B per object + ~2 B chunk metadata: website 4,000 pages ~560 MB, 5M shapes ~310 MB.

Decision

packages/doc holds one page (used by browsers and doc workers/compactor; the realtime tier uses only its 14 B/node structural index, ADR 0019) as structure-of-arrays columns indexed by a dense Handle (contract: shared/src/doc-api.ts):

Alternatives (per node at 682K / 5M nodes)

Consequences