# ProDesigner Document Format — Specification v1 (draft 1)

**License:** This specification is published under the [Creative Commons Attribution 4.0 International license (CC BY 4.0)](https://creativecommons.org/licenses/by/4.0/). You may copy, adapt and build on it, including commercially, if you credit "ProDesigner" and link to https://www.prodesigner.app/spec/. The license covers this document only; ProDesigner's software and source code are not covered by it and remain proprietary.

**Status:** Draft 1 — founder-reviewed 2026-08-04, open questions resolved (§13)
**Format version:** `1.0.0-draft.1` · **Last updated:** 2026-11-18

References to other ProDesigner documents (other specifications, the decision log, source files) are to the project's own records, which are not published; this document stands on its own for reading and writing the format.

This document specifies the ProDesigner document format: a JSON-based,
human-readable, version-controllable representation of a design document in
which **meaning travels with geometry**. It is the load-bearing wall of the
product. Everything else — importers, editor, transforms — is written against
this spec, and this spec changes before any of them do.

Design goals, in priority order:

1. **Semantic first.** The primary structure is content with meaning
   (articles, headlines, media, relationships), not a tree of rectangles.
2. **Transformable.** The format must contain enough meaning that an AI (or a
   rule engine) can re-express the same content on a different surface —
   print spread → responsive site — without guessing.
3. **Honest about geometry.** Designers' decisions are sacred. Every visual
   property an importer can read is preserved losslessly in the design layer,
   even when we don't yet understand it semantically.
4. **Collaborative by construction.** The document maps 1:1 onto Yjs CRDT
   structures. The JSON file is the serialization of that live document.
5. **Diffable and durable.** Stable IDs, deterministic serialization,
   human-readable JSON. A `.prodoc` in git should produce reviewable diffs.
6. **Open and extensible.** Unknown fields survive round-trips. Extensions
   are namespaced. The spec is published.

---

## 1. Physical form

A ProDesigner document is a **directory package** with extension `.prodoc`:

```
mymagazine.prodoc/
  document.json        # the document (this spec)
  assets/              # binary assets, content-addressed
    sha256-3f8a…c2.jpg
    sha256-9be1…77.png
  proxies/             # optional low-res stand-ins (same naming)
```

Rationale: a directory keeps `document.json` diffable while keeping binaries
out of the JSON. Tooling MAY additionally support a zipped single-file form
(`.prodocz`) for transport; the directory form is canonical.

**Corrected 2026-11-18:** the directory form remains the definition, but no
implementation reads or writes it yet; `.prodocz` (below) is the file form
ProDesigner writes and opens today.

**`.prodocz`, defined 2026-10-19** (`studio-v1.md` Section 9.1, the first
writer): the same package as one ZIP file. Its entries are `document.json`
(first, deflated) and one `assets/…` entry per distinct `file` the
document's `assets` name (stored, not compressed — pictures and fonts are
compressed already), in that path; nothing else is written. A reader skips
`proxies/…` and `.pd/…` entries, refuses any other name, checks each asset's
bytes against its `hash`, and opens a document whose bytes for an asset are
missing with that asset named as missing (never as a blank). Unzipped, a
`.prodocz` is the directory above, byte for byte.

**Corrected 2026-11-18 — earlier saves in the file (added 2026-10-30,
`studio-v1.md` Section 9.1.18).** A writer MAY also write up to 10 earlier
saves of the document, each as `.pd/versions/<time>.json` (deflated, `<time>`
the save's UTC time written compactly as `20261030T161941089Z`, so the names
sort by time), together with any asset files those saves name that the
document itself no longer does. A reader reads those entries as earlier
saves (one that is not a ProDesigner document is left out, never a reason the
file fails to open) and skips every other `.pd/…` entry, every `proxies/…` entry,
folder entries and `__MACOSX/…` entries. So "nothing else is written" above
means nothing but these, and a file carrying earlier saves unzips to the
directory above plus a `.pd/versions/` folder. Asset entries are named
`assets/sha256-<64 hex digits>`, optionally followed by a short extension; a
reader refuses any other name.

`document.json` is UTF-8 JSON, serialized deterministically: object keys in
the order given by this spec (unknown keys last, alphabetically), arrays in
document order, two-space indentation, no trailing whitespace.

## 2. Top-level structure

```json
{
  "format": "prodesigner/document",
  "formatVersion": "1.0.0-draft.1",
  "id": "doc_01j1z3…",
  "meta": { … },
  "content": { … },
  "design": { … },
  "targets": { … },
  "styles": { … },
  "assets": { … },
  "ext": { … }
}
```

| Field | Req | Description |
| --- | --- | --- |
| `format` | ✓ | Always `"prodesigner/document"`. Cheap file-type sniffing. |
| `formatVersion` | ✓ | Semver of this spec. See §9. |
| `id` | ✓ | Stable document ID (§3). |
| `meta` | ✓ | Title, language, provenance of the document itself. |
| `content` | ✓ | The content layer: semantic entities and relationships. |
| `design` | ✓ | The design layer: nodes with geometry and style, grouped into expressions per target. |
| `targets` | ✓ | The target layer: surface definitions (print, web, …). |
| `styles` | ✓ | Shared named styles and design tokens. |
| `assets` | ✓ | Manifest of binary assets, content-addressed. |
| `recipes` |  | How module results were derived, keyed by design-node id (§9, `module-io-v1.md` §5). Additive provenance. |
| `ext` |  | Namespaced extension data (§10). |

### 2.1 `meta`

```json
{
  "title": "Alpine Quarterly — Issue 14",
  "lang": "en-US",
  "created": "2026-08-04T14:00:00Z",
  "modified": "2026-08-04T16:12:09Z",
  "generator": "prodesigner/0.1.0",
  "source": {
    "kind": "idml",
    "file": "alpine-issue14.idml",
    "importedAt": "2026-08-04T14:00:00Z",
    "importerVersion": "importer-idml/0.1.0"
  }
}
```

`source` is present on imported documents and never deleted: knowing where a
document came from matters for support, for the regression suite, and for
trust.

## 3. Identity

Every entity, node, target, style, and asset has an `id`: a prefixed,
lowercase, URL-safe string — `<prefix>_<26-char Crockford ULID>`.
**Corrected 2026-11-18:** readers check only the shape — the prefix, an
underscore and 26 lowercase Crockford base32 characters (`0-9`, `a-z` without
`i`, `l`, `o`, `u`). The reference library mints ULIDs; Studio mints 26 random
characters, so an id's characters carry no time a reader may rely on.

**Example ids in this document are shortened for reading** (`ent_a`, `nod_1`,
`tgt_print`, `doc_01j1z3…`) and are not valid ids; a real id always has the
26 characters after its prefix.

Prefixes: `doc` (document), `ent` (content entity), `nod` (design node),
`tgt` (target), `sty` (style), `ast` (asset), `rel` (relationship).

**The registry is extended by other specs, each naming its own prefix**, and
this list was silently behind the code until 2026-08-26. Also minted on that date:
`rcp` (recipe envelope — `recipe-v1-envelope.md`), `spc` (space —
`sharing-v1.md`), and `dev` (device — `desktop-v1.md` §4.3.2). **Added 2026-10-16:**
`mst` (a master page — `studio-v1.md` Section 3.11). **Reserved 2026-10-19, added to `ID_PATTERN` in the same commit as the build:** `cmp` (a component main — `studio-v1.md` Section 3.23). **Added to `ID_PATTERN` 2026-10-20 with the first picture-layers build:** `lyr` (a layer inside a picture) and `adj` (an adjustment on a layer) — `picture-v1.md` Section 2.1. **Reserved 2026-10-19, added to `ID_PATTERN` in the same commit as the build:** `aud` (a sound track) and `acl` (a sound clip) — `motion-v1.md` Section 2.1. **Added to `ID_PATTERN` 2026-10-20 with the first video build:** `scn` (a scene of a video target) — `motion-v1.md` Section 2.1. **Added to `ID_PATTERN` 2026-10-22 with the Web output:** `frm` (a frame of a web target — §6, `studio-v1.md` Section 4.9.1). **Added to `ID_PATTERN` 2026-10-31 with component variants:** `cst` (a component set — `studio-v1.md` Section 3.23.13). **Added to `ID_PATTERN` 2026-11-05 with video markers (corrected 2026-11-18: this list had left it out):** `mrk` (a marker on a video scene — `motion-v1.md` Section 14). **Not in the registry (corrected 2026-11-18):** the ids of variables, their collections and their modes (`var_…`, `vco_…`, `vmo_…`, §5 `design.variables`) are written in the same shape but are not in `ID_PATTERN`; the validator does not check them, and a reader treats them as plain strings that name things within `design.variables`. `ID_PATTERN` in
`packages/core/src/id.ts` is the enforcing copy; a prefix that is not in both
is a bug in whichever was forgotten.

IDs are minted once — at import or creation — and never reused or renamed.
All cross-references in the document are by ID. This is what makes the format
diffable, what lets corrections and comments survive edits, and what the
CRDT layer keys on.

## 4. The content layer

`content` is the document's meaning: a shallow tree of **semantic entities**
plus typed **relationships**. It contains *no geometry and no styling*.

```json
"content": {
  "root": ["ent_a", "ent_g"],
  "entities": {
    "ent_a": {
      "id": "ent_a",
      "kind": "article",
      "name": "Glacier feature",
      "children": ["ent_b", "ent_c", "ent_d", "ent_e"],
      "attrs": {},
      "provenance": { "source": "rule", "confidence": 0.92 }
    },
    "ent_b": {
      "id": "ent_b",
      "kind": "headline",
      "text": [
        { "t": "The Last ", "marks": [] },
        { "t": "Blue Ice", "marks": ["em"] }
      ],
      "provenance": { "source": "user" }
    },
    "ent_d": {
      "id": "ent_d",
      "kind": "media",
      "attrs": { "mediaKind": "image", "asset": "ast_h", "alt": "Aerial view of a glacier" },
      "provenance": { "source": "llm", "confidence": 0.81, "model": "claude-x" }
    }
  },
  "relationships": [
    { "id": "rel_1", "kind": "illustrates", "from": "ent_d", "to": "ent_a" }
  ]
}
```

### 4.1 Entity kinds (v1 registry)

Kinds are a closed registry per format version; code may not invent kinds —
the spec grows first. v1 registry:

**Structural:** `document-section`, `article`, `sidebar`, `group`
**Text:** `headline`, `subhead`, `kicker`, `byline`, `standfirst`, `body`,
`pullquote`, `caption`, `credit`, `footnote`, `page-furniture` (folios,
running heads), `list`, `list-item`, `table`, `table-row`, `table-cell`
(**the last two added 2026-10-17**, `studio-v1.md` Section 3.13: a `table`'s
`children` are its rows top to bottom, a row's are its cells left to right in
the slots the rows above leave free; a row may carry `attrs.header: true`, a
cell — text-bearing, its `text` as §4.2's — `attrs.colSpan` and
`attrs.rowSpan`, whole numbers, absent 1)
**Media:** `media` (with `attrs.mediaKind`: `image` | `vector` | `video`),
`media-group` (e.g. a gallery)
**Escape hatch:** `unclassified` — content the pipeline could not classify.
An importer MUST emit every piece of content, using `unclassified` rather
than dropping anything. The share of `unclassified` entities in a document
is the classification pipeline's primary quality metric.

### 4.2 Rich text

Text-bearing entities carry `text`: an array of runs
`{ "t": string, "marks": MarkRef[] }`. Marks are either well-known inline
semantics (`em`, `strong`, `sub`, `sup`, `code`, `link:<url>`) or references
to character styles (`sty_…`). Paragraph-level structure is entities
(a `body` entity is one flow; its paragraphs are `text` runs separated by
`"\n\n"` in v1 — kept deliberately simple; revisit in v1.1 if transforms
need paragraph entities).

In the live Yjs document, `text` is a `Y.Text` with the marks as formatting
attributes; the JSON runs are its serialization.

**Paragraph styles — added 2026-10-17** (`studio-v1.md` Section 3.16 is
normative): a run may carry the mark `para:sty_…` (the `Y.Text` attribute
`para`), naming a `text` style for the paragraph the run belongs to. A
paragraph is the text up to and including its `\n`, or the text after the
last `\n`; **its style is the `para` of its last character** (its break,
or the text's last character). Writers put the same `para` on every
character of the paragraph. A `sty_…` mark is a character style on the
characters that carry it. A paragraph with no `para` reads as its frame's
style. Validation: a `para:` mark names a `text` style (error); a `sty_`
mark should (warning). A reader before this date keeps both marks and draws
the text in its frame's style.

**Local character formatting — added 2026-10-27** (`studio-v1.md` Section
3.16.9 is normative): a run may carry any of seven marks of the form
`<name>:<value>` — `font:<family>`, `size:<pt>`, `weight:<100–900>`,
`slant:<italic|normal>`, `color:<sty_…|#rrggbb>`, `tracking:<em>`,
`case:<none|uppercase|lowercase|capitalize>` — each the `Y.Text` string
attribute of its name (`{ size: "24" }`), so concurrent formatting of
overlapping text converges (§11). They resolve after the paragraph style, the
character style and the frame's own overrides: the most specific look wins. A
value a reader cannot parse is ignored for drawing and kept. A reader before
this date keeps each as an unknown mark (§9: it round-trips as a boolean
attribute named as the mark) and draws the text without it.

**Underline and strikethrough — added 2026-10-27** (`studio-v1.md` Section
3.16.10 is normative): two more well-known boolean marks, `underline` and
`strike` (the `Y.Text` attributes `{ underline: true }`,
`{ strike: true }`), after `code` in canonical order. A reader before this
date keeps them as unknown marks with the same attributes and draws no line.

**Kerning, baseline shift, leading, lists and drop caps — added 2026-10-28**
(`studio-v1.md` Section 3.26 is normative): three more local marks after
`case` — `kern:<thousandths of an em>` (space after this character),
`shift:<pt>` (baseline shift, up positive), `leading:<pt>` — and four
**paragraph marks**, read from the paragraph's last character as `para` is
and written on every character of it: `list:<bullet|1|a|A|i|I|none>`,
`liststart:<n>`, `drop:<lines>`, `dropchars:<n>`. Same `Y.Text` string
attributes, same rules for a value a reader cannot parse; a reader before
this date keeps each as an unknown mark and draws the text without it.

### 4.3 Provenance — corrections are training data

Every entity and relationship carries `provenance`:

```json
{ "source": "rule" | "llm" | "user" | "import", "confidence": 0.0–1.0,
  "model": "…", "at": "ISO-8601", "history": [ …previous provenance… ] }
```

When a user corrects a classification, the old provenance is pushed onto
`history` and `source` becomes `"user"` with confidence 1.0. The history is
the training corpus for improving the pipeline. Tools MUST NOT discard it.

## 5. The design layer

`design` is how content is *expressed on a surface*: geometry, z-order, and
styling. Its unit is the **design node**; nodes are grouped into
**expressions**, one per target.

```json
"design": {
  "expressions": {
    "tgt_print": {
      "target": "tgt_print",
      "nodes": {
        "nod_1": {
          "id": "nod_1",
          "type": "frame",
          "entity": "ent_b",
          "page": 0,
          "frame": { "x": 48, "y": 96, "w": 420, "h": 120, "rotation": 0 },
          "z": 3,
          "style": { "ref": "sty_h1", "overrides": { "fontSize": 64 } },
          "raw": { "idml": { "appliedParagraphStyle": "ParagraphStyle/Headline" } }
        }
      }
    }
  }
}
```

Node fields:

| Field | Req | Description |
| --- | --- | --- |
| `type` | ✓ | `frame` (text container), `image`, `shape`, `line`, `group`, `guide`, `table` (**added 2026-10-17** — a grid of rows and columns; `studio-v1.md` Section 3.13), `embed` (**added 2026-09-17** — an HTML embed on a deck screen; `studio-v1.md` §3.4, §10.5; reserved and validated, not rendered live in v1; **corrected 2026-11-18:** it is now drawn as a card in the editor and live, sandboxed, in the presenter and the viewer), `instance` (**added 2026-10-19** — a component's instance; see `component` below) |
| `screen` | ✓* | **Added 2026-09-17.** Index into a `deck` target's screens — the deck's `page` (`studio-v1.md` §3.3). |
| `scene` |  | **Added 2026-10-20, optional and additive** — on a `video` target's node: the `scn_…` id of its scene (`motion-v1.md` Section 2.2). A video's nodes carry `scene`, never `screen`. |
| `webFrame` |  | **Added 2026-10-22, optional and additive** — on a `web` target's node: the `frm_…` id of the frame it stands on (§6, the target's `frames`). A node on a frame carries `webFrame`, never `page` (a frame is not a page: §6); a group's child may leave it to its group. Named `webFrame` because a node's `frame` is its geometry. |
| `name`, `locked`, `hidden`, `fill`, `stroke`, `opacity`, `geometry`, `image`, `animation`, `link` |  | **Added 2026-09-17, all optional and additive** — `studio-v1.md` §3.4 is normative. `fill`/`stroke` are `StyleRef`s (**since 2026-10-19**, `studio-v1.md` Section 3.21.2: a `fill` style or a fill's `overrides` may carry a `gradient` — `linear` or `radial`, 2–32 opaque stops, geometry in the frame's unit square — always beside `value`, the first stop's hex, which an older reader draws flat; **since 2026-10-29** a fill's `overrides` may instead carry a `picture` — `{ "asset": "ast_…", "mode": "tile" \| "stretch", "scale": n }`, an image asset of the document's `assets` tiled from the frame's top-left at its pixels × `scale` (one pixel to one document unit) or stretched across the frame, also beside `value`, which an older reader draws flat (optional and additive; `studio-v1.md` Section 3.40 is normative; a `gradient` wins over it); a stroke's `overrides` may carry `cap`, `join`, `miterLimit`, `dash`, `dashOffset`, `start`, `end` and `headScale`, **absent `cap` and `join` reading as round, forever**); `geometry` gives a `shape` a `rect`/`ellipse`/`path`, and a `path` may carry `fillRule: "nonzero" \| "evenodd"` (**added 2026-10-19, optional and additive; absent is non-zero.** An older reader fills non-zero, so Studio's own commands never write `evenodd` — they orient rings so non-zero paints the same; `studio-v1.md` §3.20.2); a `path` may also carry `live` — `{ "tool": "polygon" \| "star" \| "arc" \| "spiral" \| "qr", … }`, the settings that made its `d` (**added 2026-10-28, optional and additive; `qr` — `text` and `ecc` `L`/`M`/`Q`/`H` — since 2026-10-30**; `studio-v1.md` Section 3.30.2 is normative: `d` is always written and is what every renderer draws, and a reader trusts `live` only while computing it again at the frame's size gives the stored `d`); `image` gives an image node `fit` + `crop`; `animation`/`link` apply on deck expressions only — **since 2026-10-30 `link` also on a web output's nodes** (`to` a frame's `frm_…` id there, a screen's index as a string on a deck), read by `readLink` in `packages/core`: `next`, `prev`, `screen`, or a `url` of `https:`, `http:` or `mailto:`; any other link is a warning and is ignored (optional and additive; `studio-v1.md` Section 10.3.1 is normative). |
| `asset` |  | **Added 2026-08-24.** A per-surface asset override. Normally an image's pixels come from its entity (`attrs.asset`); this shows *different* pixels on this surface only. **Node wins over entity.** A reader that does not know this field shows the entity's original — the wrong picture, not no picture. |
| `entity` |  | The content entity this node expresses. A node without an `entity` is pure decoration (rules, background shapes) — legitimate and preserved. An entity with no node on a given expression simply isn't shown on that surface. |
| `page` | ✓* | Index into the target's pages/screens (print targets). |
| `frame` | ✓ | Geometry in the target's units: `x`, `y`, `w`, `h`, `rotation` (deg). |
| `z` | ✓ | Stacking order within the page. |
| `style` |  | `{ ref?: styleId, overrides?: {…} }` — see §7. |
| `children` |  | For `type: "group"`. **No loop (written down 2026-10-21, a validation rule, no new field):** following `children` from a node never comes back to it — a group never contains itself, directly or through other groups. A document with a loop is invalid (§12, an error on the loop's member with the smallest id, `…nodes.<id>.children`), and a reader still opens it: in each loop **the member with the smallest id loses its parent** and stands at the top level of its page, scene or component (`packages/core` `group-tree.ts`, `breakParentLoops`); nothing is written on read, and the open notice names that member (`studio-v1.md` Section 3.7.1 item 7). Two people dragging each other's groups in at once make exactly this in Yjs, so it is repaired by an edit, never refused on load; a reader that refuses invalid documents (Understand this file, the MCP server) does not refuse one whose only errors are loops (`isGroupLoopIssue`, 2026-10-22). |
| `raw` |  | Importer-preserved source properties we don't yet model, keyed by source format (§3 goal 3: honesty about geometry). Never invented, never silently dropped. |
| `master`, `masterPage`, `masterItem`, `fields` |  | **Added 2026-10-16, all optional and additive** — master pages, `studio-v1.md` Section 3.11 is normative. A node with `master` is drawn on that master (§6), on its page `masterPage` (0 left, 1 right; absent 0), and carries `page: -1`, a page no earlier reader draws. `masterItem` on a page's node names the master item it was released from (that item is not drawn on that page). `fields: true` on a `frame` makes its text's `{page}` read as the page's number. |
| `guide` nodes |  | **Written down 2026-10-21** (the type was in the registry; `studio-v1.md` Section 3.19.9 is normative). A ruler guide on its `page`: vertical at `frame.x` with `w` 0 and `h` the page's height, horizontal at `frame.y` with `h` 0 and `w` the page's width — a reader tells them apart by `w ≤ h`. No `entity`, `style`, `fill` or `stroke`; `locked` and `hidden` as any node's. A guide never prints or exports, and is no object to selection, alignment or text wrap. **`color`** (optional, **added 2026-11-21**, `studio-v1.md` Section 3.19.16 item 7): the colour it is drawn in on screen, one of `magenta`, `green`, `orange`, `red`, `gray`; absent, or a name a reader does not know, it is cyan, the colour every guide had before (cyan itself is never written). |
| `table` |  | **Added 2026-10-17, optional and additive** — tables, `studio-v1.md` Section 3.13 is normative. A node of the new type `table` shows a `table` entity as a grid: `table.columns` (widths in order), `table.rows[rowId].h` (each row's least height; rows grow to fit their text), `table.cells[cellId]` (`fill`, `valign`, `style`), `table.header` (`style`, `fill`, `rule`), `table.rowRule`, `table.columnRule`, `table.border` (stroke references; absent, no line) and `table.inset`; the node's own `style` is every cell's text style that says nothing else. Its `frame.w` is the columns' sum and `frame.h` the stored heights' sum; the drawn table may be taller. A reader before this date draws an unknown node type as a box at its frame. |
| `thread` |  | **Added 2026-10-17, optional and additive** — text threading, `studio-v1.md` Section 3.12 is normative. On a `frame`: `{ "next": "nod_…" }`, the frame its entity's text continues in. The frames of a chain carry one `entity` and show it in order, each the part the frames before it did not hold; a frame named by no other frame is the chain's head. A reader before this date draws every frame from the top of the text. In a frame with `fields`, `{next}` and `{prev}` read as the page the story continues on and came from. |
| `textFrame` |  | **Added 2026-10-17, optional and additive** — a text frame's own layout options, `studio-v1.md` Section 3.14 is normative. On a `frame`: `firstBaseline` — `"line"` (absent: the CSS line box, as before), `"ascent"`, `"cap"`, `"x"` or `"leading"` (where the first baseline sits below the frame's top, InDesign's *First Baseline Offset*); since the same day (`studio-v1.md` Section 3.15) `columns` — a whole number 1–20, absent 1 — and `gutter` — the space between columns in the target's units, absent 12. A reader before this date draws the frame's first line in the CSS line box and its text in one column. **Since 2026-10-19** (`studio-v1.md` Section 3.18.1) `valign` — `"top"` (absent), `"center"`, `"bottom"` or `"justify"` — and `ignoreWrap` — `true` when no text wrap moves the frame's text. A reader before that date sets the text at the frame's top and lets nothing wrap it. **Since 2026-10-28** (`studio-v1.md` Section 3.27.6) `inset` — `{ top, right, bottom, left }`, each ≥ 0 in the target's units, the space between the frame's edges and its text. A reader before that date sets the text at the frame's edges. |
| `wrap` |  | **Added 2026-10-19, optional and additive** — text wrap, `studio-v1.md` Section 3.18.4 is normative. On a `frame`, `image`, `shape`, `line`, `table` or `embed`: `{ "mode": "box" \| "jump" \| "column", "side"?: "both" \| "left" \| "right" \| "largest", "top"?, "right"?, "bottom"?, "left"? }` — the node pushes the text of every text frame on its page away from its box grown by the offsets (target units, absent 0): beside it (`box`, on the side asked), below it (`jump`), or into the next column (`column`). A reader before this date lets text run under the node. |
| `mask` |  | **Added 2026-10-19, optional and additive** — clipping and masks, `studio-v1.md` Section 3.22 is normative (founder: a mask belongs to a layer/node; a clipping group's clipping shape is its top item). On any drawn node: `{ "mode": "clip", "source": "path" \| "top", "path"?: { "d", "fillRule"? }, "off"?, "invert"?, "feather"?, "density"? }`. `feather` (pixels, a Gaussian blur of the mask) and `density` (0–1, the mask's strength) are read inside a picture only (`picture-v1.md` Sections 2.1 and 3.4); on a page node they are ignored. `"path"` holds the mask's shape in the node's own frame; `"top"`, on a `group` only, makes the group's top item (the direct child drawn last) the clipping shape, which keeps its own `fill` and `stroke` (fill drawn behind the members, stroke above them). `"alpha"`/`"luminance"` modes and `"asset"` sources are reserved for pictures with layers. A reader before this date draws the node unmasked — the wrong picture, not a broken file. |
| `blend` |  | **Added 2026-10-19, optional and additive** — `studio-v1.md` Section 3.21.2. On any node but a group: one of the fifteen names `multiply`, `screen`, `overlay`, `darken`, `lighten`, `color-dodge`, `color-burn`, `hard-light`, `soft-light`, `difference`, `exclusion`, `hue`, `saturation`, `color`, `luminosity`; absent is normal. A reader before this date draws normal. |
| `isFrame` |  | **Added 2026-10-31, optional and additive** (`studio-v1.md` Section 3.45 is normative): on a `group`, marks it a frame — its `layoutBg` member is its background and its box, and with Clip content on the group is a clipping group (`mask` `{ mode: "clip", source: "top" }`, the background its top item). Every reader since 2026-10-20 draws it; a reader before this date draws its members and background as a group. |
| `exports` |  | **Added 2026-11-21, optional and additive** (`studio-v1.md` Section 3.19.17 items 2 to 4 are normative): on any node but a guide, the export settings kept on that layer — an array of `{ "format": "png" \| "jpeg" \| "svg", "scale": number (0.1 to 8), "suffix": string (up to 40 characters) }`, one file each, the layer alone cropped to its drawn box. Absent or empty, the layer has none, as every layer had before. A reader lists only the entries it can read and keeps the rest as they are. |
| `layout` (`sides`, `wrap`, `lineGap`, `w`, `h`), `layoutSizing`, a stroke's `align` |  | **Added 2026-11-07, optional and additive** (`studio-v1.md` Sections 3.57.4 and 3.57.5 are normative). On a `group`'s `layout` (Section 3.33's `dir`, `gap`, `pad`, `align`): `sides` `{ top, right, bottom, left }`, each 0–1,000, each side's padding (absent: `pad` on every side; `pad` stays what an older reader reads); `wrap: true`, a row that runs onto new lines at the group's width (a row only); `lineGap`, 0–1,000, between those lines (absent: `gap`); `w` and `h`: `"fixed"`, the group keeps that size (absent: it hugs its members). On a member of a laid-out group: `layoutSizing` `{ w?: "fill", h?: "fill" }`, the member takes the room the group has (absent: its own size). On a stroke's `overrides`: `align: "inside" \| "outside"`, the stroke inside or outside a closed shape's edge (absent: its centre). Members are still written as positions, so every reader draws them where they stand; a reader before this date ignores the fields and draws an aligned stroke on its centre. An unreadable value reads as absent. |
| `textFrame.autoWidth` |  | **Added 2026-11-07, optional and additive** (`studio-v1.md` Section 3.57.8 is normative): `true` beside `autoSize: "height"`, the frame's width follows its text too (its longest line, no line breaks of its own); ignored without `autoSize`. Studio writes the width and the height to `frame`, so every reader draws the box as stored; a reader before this date fits only the height. A field of its own because the validator before this date refuses any `autoSize` but `"height"`. |
| `fills` (on a `shape`) |  | **Added 2026-11-07, optional and additive** (`studio-v1.md` Section 3.57.13 is normative): 2 to 8 fill layers, bottom first, each a fill as `fill` is (a style `ref` and/or `overrides`) plus `opacity` (0–1, absent 1) and `hidden: true`. Written only for two or more; `fill` is always written beside it as the bottom visible layer, without its opacity, so a reader before this date draws that layer. A reader draws `fills` only while `fill` still equals that bottom visible layer: a writer that changed `fill` alone made the stack stale, and `fill` is drawn. Anything else a reader cannot use (one layer, nine, an unreadable layer, a node that is not a shape) reads as absent and is a validator warning, never an error. |
| `design.variables`, a node's `vars` and `varModes`, a page's `varModes` |  | **Added 2026-11-07, optional and additive** (`studio-v1.md` Section 3.57.14 is normative). `design.variables`: `{ collections: [{ id: "vco_…", name, modes: [{ id: "vmo_…", name }] }], vars: { "var_…": { id, collection, name, type: "color" \| "number", values: { [modeId]: hex \| number \| { ref: "sty_…" } \| { alias: "var_…" } } } } }`, 1 to 16 modes a collection, the first its default. A node's `vars`: `{ [field]: { var, was } }` for `fill`, `stroke`, `opacity` (a per cent), `radius`, `strokeWidth`, `gap`, `padTop`, `padRight`, `padBottom`, `padLeft`, `fontSize`; **the field always holds the value**, so every reader draws it; a binding is live only while the field still holds `was`. A group's (or Frame's) and a page's `varModes`: `{ [collectionId]: modeId }`, the nearest one above a node choosing its mode. A reader before this date ignores all of it and draws the fields as written; anything a reader cannot use is a validator warning, never an error. |
| `pageBg` |  | **Added 2026-11-02, optional and additive** (`studio-v1.md` Section 4.11.7 item 4 is normative): on a locked `shape` rectangle, marks it its page's background — one per page, under everything on the page. A reader that does not know it draws the rectangle. |
| `chart` |  | **Added 2026-10-31, optional and additive** (`studio-v1.md` Section 3.48 is normative): on a `group`, the table its children were drawn from — `{ "v": 1, "kind": "column" \| "bar" \| "line" \| "pie" \| "donut", "labels": [string], "series": [{ "name", "values": [number], "colour"? }], "legend": bool, "values": bool, "drawn": { "w", "h" } }`, `colour` a `sty_…` colour style or an sRGB hex. The children are ordinary shapes, lines and text frames; the first, a rectangle with no fill and no stroke, is the chart's area (its box and turn). No renderer reads `chart`: every reader draws the children, and a reader before this date shows the chart as a plain group. A reader reads it leniently (an unknown kind as `column`, a missing value as 0, at most 24 labels and 6 series) and treats a table with no label or no series as no chart. |
| `component`, `overrides` |  | **Added 2026-10-19, optional and additive** — components, `studio-v1.md` Section 3.23 is normative (founder: an instance points to one main by reference, like masters; it may override any property, including the size and position of its parts; components live in the document). A node of the new type **`instance`** carries `component` (a `cmp_…` id in `design.components`) and `overrides`: part path → property path → value (`{ "nod_tagPrice": { "entity": "ent_x", "frame.w": 90 } }`); arrays are whole values, the more specific path wins, and overriding `picture.layers` writes `picture.result` and `asset` in the same override. A reader before this date draws an instance as a box at its frame. **Added 2026-10-31, optional and additive** (`studio-v1.md` Section 3.23.13 is normative): `design.componentSets` keyed by `cst_…` (`{ id, name, props: [names] }`); a main may carry `variant` (`{ set, values: { prop: value } }`) and `properties` (`"<boolean|text|swap>:<part path>"` → `{ name }`). An instance's property values are ordinary overrides (`hidden`, `entity`, `component` on the part), so every reader since 2026-10-20 draws them. |
| `picture` |  | **Added 2026-10-19, optional and additive** — picture editing, `studio-v1.md` Section 3.24 and `picture-v1.md` Section 2 are normative (founder: Photoshop-style layers inside a picture; a mask on each layer; never overwrite the original). On an `image`: `{ w, h, layers, result }` — `layers` a map keyed by `lyr_…` id, ordered by a string `z`, each `pixel` (an `asset` at `x`, `y`, or `source: "original"`) or `adjustment`, with optional `opacity`, `blend`, `mask` (the `mask` field above, every source and mode live inside a picture), `adjust` (a map keyed by `adj_…` id, ordered by `z`: `{ op, params, off? }`), `hidden`, `locked`, `name`; `result: { asset, inputsHash }` the flattened cache. **The node's `asset` names `result.asset`**, so a reader that does not know layers draws the same pixels. An unknown layer `kind` or `op` is skipped when drawing, named in the open notice, and kept |
| `flipX`, `flipY` |  | **Added 2026-10-21, optional and additive; stored as two flat booleans since 2026-10-22** (founder, 2026-10-22: "switch now"; `docs/decisions.md`) — a picture's content mirrored, `studio-v1.md` Section 3.19.8 item 6 is normative (founder, 2026-10-21: pictures only). On an `image`: `flipX: true` mirrors the picture's pixels, as `image.fit` and `crop` place them, across the frame's vertical centre line, `flipY: true` across its horizontal one, inside the frame and before the node's `rotation`. The frame, its `mask` path, its `wrap` and its `crop` (in asset pixels) are not changed by either. **Absent reads unmirrored, and so does any value but `true`; a value that is not a boolean is a warning**; a writer never writes `false` — a flip turned off removes its key. Each is its own key on the node, so two people flipping different axes at once both keep their axis (§11). On any other node type either is a warning and draws nothing different. A reader before 2026-10-21 draws the picture unmirrored — the wrong picture, not a broken file. **`flip` is not a field:** the `flip: { x?, y? }` map this row named on 2026-10-21 was never in a released build, so no reader for it exists; a stray `flip` key is a warning, draws unmirrored and is kept as written (§9) |
| `connect` |  | **Added 2026-11-07, optional and additive** — attached lines, `studio-v1.md` Section 10.4.9 is normative. On a `line`: `{ "from"?: { "node": "nod_…", "side": "top" \| "right" \| "bottom" \| "left" }, "to"?: {…}, "route": "straight" \| "elbow" \| "curved" }`. An end holds the middle of that side of that node (turned with it) when the node is a `shape`, `image`, `frame`, `table`, `embed` or `instance` on the line's page; otherwise, or when absent, the end is where the line's stored path puts it. The line's `frame` and `geometry.d` are always written where the writer last placed it, so a reader that ignores `connect` draws it there. An unknown `route` reads as `straight`. |
| `animation` on a `video` target |  | (`scale` exists only as an animation value, about the node's centre; there is no node `scale` field.) **Added 2026-10-19, optional and additive** — motion, `studio-v1.md` Section 3.25 and `motion-v1.md` Section 2.2 are normative. Every deck field kept with its meaning; on a video target also `start`, `end` (ms from the scene's start), `at` on a build, and `keys`: property path (as `overrides` above) → `[{ t, v, ease? }]`, read in `t` order; `ease` adds `step` and `{ "bezier": [x1, y1, x2, y2] }`; build kinds add `rise`, `pop`, `blur` (an older deck reader draws them as `fade`). Reserved: node type `video` (a person's clip: `asset`, `clip: { in, out, rate?, muted? }`, `poster`) and `slot` — `motion-v1.md` Sections 2.5 and 6, for a later build. **Specified 2026-10-20, decided by the founder 2026-10-20 14:04 ("recommended"), built the same day** (`motion-v1.md` Section 9.2, Sections 9.8 item 1 and 9.10): a clip is not a `video` node but an ordinary `image` node (its `asset` is the poster, the frame at `in`) with an optional `clip: { asset, in, out, muted?, gain? }` (`asset` a `kind: "video"` asset; `rate` stays reserved), read on a video target only, so every reader before it draws the poster; the `video` node type then stays reserved and unused. The clip's `kind: "video"` asset gains optional `duration` (ms), `width`, `height`, `fps` and `hasSound`, as measured when placed; a reader before it keeps them verbatim. **Built 2026-10-20, optional and additive:** `keys` on an `image` node on a video target may name `image.crop.x`, `image.crop.y`, `image.crop.w` and `image.crop.h` (a picture's pan and zoom, in asset pixels; `motion-v1.md` Section 9.2 item 1); absent when unused, and a reader before it keeps the keys and draws the picture's own crop. **Built 2026-10-20, optional and additive:** sound, in the target's `audio` (tracks `aud_…` with `z`, optional `name` and `muted`, absent false; clips `acl_…` with `asset`, `start`, `in`, `out`, optional `gain`, `fadeIn`, `fadeOut`; the ids are in the id pattern) and an asset `kind: "audio"` with optional `duration`, `channels`, `sampleRate`, which a reader before it keeps verbatim (§9); absent when unused |

**The invariant that makes transforms work:** content entities are the stable
spine; design nodes are per-surface projections referencing them by ID. The
transform "make this a website" reads the *content* tree for structure and
the *print* expression for visual intent (hierarchy, scale ratios, palette),
then writes a new expression under a web target. Nothing about print is
mutated.

## 6. The target layer

```json
"targets": {
  "tgt_print": {
    "id": "tgt_print",
    "kind": "print",
    "name": "Magazine spread",
    "units": "pt",
    "pages": [ { "w": 612, "h": 792, "bleed": 9,
                 "margins": { "top": 48, "right": 40, "bottom": 56, "left": 40 },
                 "grid": { "columns": 12, "gutter": 12 } } ]
  },
  "tgt_web": {
    "id": "tgt_web",
    "kind": "web",
    "name": "Responsive site",
    "units": "px",
    "breakpoints": [ { "name": "base", "minWidth": 0 },
                     { "name": "md", "minWidth": 768 },
                     { "name": "lg", "minWidth": 1200 } ],
    "theme": { "colorScheme": "light" }
  }
}
```

Target kinds in v1: `print`, `web`, and — **since 2026-09-17, un-reserved by
`studio-v1.md` §3.3** — `deck` (`units: "px"`, an ordered `screens[]` of one
size, each with an optional `transition` into it and an optional `notes`
entity). A print target may also carry `display.unit` (what rulers show;
geometry stays in `units`), `facing` and `marks` (`studio-v1.md` §3.2).
**Added 2026-10-21, optional and additive (`studio-v1.md` Section 3.19.9):**
a print or deck target's `display` may carry `grid: { step }` — the
document grid's spacing, in the target's units, a positive number. Absent,
the spacing follows the display unit; a reader before this date shows no
grid and loses nothing.
**Added 2026-10-28, optional and additive (`studio-v1.md` Section 3.28.1):**
a text style's or override's properties may carry `composer` (`"paragraph"`,
absent, or `"single"`), `wordSpacing` (`[minimum, desired, maximum]`
percent, absent `[80, 100, 133]`) and `hyphenation` (`{ minWord, before,
after, limit, caps }`, absent 5, 2, 2, 3, true). A reader before this date
keeps them.
**Added 2026-10-28, optional and additive (`studio-v1.md` Section 3.27):**
a print page may carry `bleedSides` (`{ top, right, bottom, left }`, each
≥ 0; present only when the sides differ, and then `bleed` holds the largest
side, so an older reader exports at least that on every side) and `slug`
(the same shape, measured from the trim); a print target may carry `mirror`
(`true`: with `facing`, each page's stored `left` side is its inside and
`right` its outside, so a left-hand page draws them swapped) and
`marks.slug` (`true`: the print PDF includes the slug area). A reader before
this date keeps them and draws a uniform bleed, no slug and literal sides.
**Added 2026-10-16 (`studio-v1.md` Section 3.11):** a print or deck target
may carry `masters[]` — ordered master pages, each `{ id: "mst_…", prefix,
name, pages: [one page, or two for a facing spread] }` — and each page (or
screen) may carry `masters: [{ master: "mst_…", z }]`, the masters it shows,
each at its place in the page's stack. Absent: none.
**Added 2026-10-19 (`studio-v1.md` Section 3.25, `motion-v1.md` Section 2.1; founder: a timeline editor is v1):** `video` — `units: "px"`, `w`, `h`, `fps` (24, 25, 30, 50 or 60), `scenes`, a map keyed by `scn_…` id, each with an `order` number (read ascending, ties by id; changed 2026-10-20 from an ordered list before anything was built, so a concurrent reorder cannot duplicate a scene), `duration` in ms and the deck's `transition` into it (with optional `from` and `ease`; the first scene's is not read), and optional `audio` (sound tracks keyed by `aud_…`, ordered by `z`, each with `clips` keyed by `acl_…`). **A scene's `duration` includes its transitions' overlap: the video's length is `sum(duration) − sum(transition.ms)`.** A reader that predates it keeps the target verbatim and opens the document's other targets (§9). A document may have any number of targets;
imported documents start with one.
**Added 2026-10-21, optional and additive (`studio-v1.md` Section 4.9, the
mode bar; founder, 2026-10-21 09:21 and 10:05):** any target may carry
`color`, the colour mode its output is made in — `{ "mode": "cmyk" }`
(optionally with `"profile"`, a profile name) or `{ "mode": "rgb", "space":
"srgb" | "p3" }`. **Absent, a `print` target reads as `{ "mode": "cmyk" }`
with no profile — device CMYK, what its PDF has always written — and every
other kind as `{ "mode": "rgb", "space": "srgb" }`;** so a document written
before this date reads exactly as it was made, and a writer leaves the field
out while it says the default. `profile` is reserved for the colour-managed
proof and the print PDF's output intent (a later colour-management build); a
reader keeps a profile it does not know and draws nothing differently for it.
**The soft proof's default (2026-10-21, `studio-v1.md` Section 4.10):** a
`cmyk` output with no `profile` is proofed on **FOGRA39L Coated** (ISO
12647-2 coated offset), which a reader that proofs carries. That is a view,
not a value: nothing is written, and the PDF still writes device CMYK.
A value outside these is warned and read as the absent default. A reader
before this date keeps the field verbatim (§9) and draws the target as
before: nothing it renders depends on it yet.

For `web` targets, a design expression's nodes carry `breakpoint` instead of
`page`, and frames may use fluid values (`{ "w": { "pct": 100 } }`) — the
full web-expression grammar is specified in the transform spec
(`docs/spec/transform-web-v1.md`) and stubbed here deliberately:
this version only needs print-side fidelity plus the target declaration.
**Narrowed 2026-10-22 (below):** that responsive grammar is the website
transform's, and is still not v1's editor; a node on a web target's *frame*
carries `webFrame`.

**Added 2026-10-22, optional and additive — the Web output's frames
(`studio-v1.md` Section 4.9.1; the founder's review decisions of
2026-10-21, reopening the target parked on 2026-09-17).** A `web`
target may carry `frames`, a map keyed by `frm_…` id: fixed-size boards at
one device's width, Figma's frames, in the target's `px`, each
`{ "order", "w", "h", "name"? }`. They are read in `order` (ascending, ties
by id), as a video's scenes are; `order` is any finite number, so a frame
moved or inserted between two others takes a number between theirs. `name`
labels the frame (*Desktop*, *Phone*); absent, a reader shows the frame's
number. A node on a frame names it by id in `webFrame` (§5); it carries no
`page`. Studio's Web output starts with two:

```json
"tgt_site": { "id": "tgt_site", "kind": "web", "name": "Web", "units": "px",
  "frames": {
    "frm_desktop": { "order": 0, "w": 1440, "h": 1024, "name": "Desktop" },
    "frm_phone":   { "order": 1, "w": 390,  "h": 844,  "name": "Phone" } } }
```

A frame is drawn as a deck's screen is: px, no bleed, clipped to its edge.
`bleed`, `margins`, `grid` and `masters` are not written on a frame, nor
`facing`, `marks` or `masters` on a web target; a reader keeps any it finds.
**Why frames and not breakpoints** (the reason the target was parked): a
breakpoint `{ name, minWidth }` is a *range* of widths a responsive page
adapts across, with no height; a frame is one *fixed* design at one width
and height. Desktop 1440 and Phone 390 are frames; the breakpoints a
website made from them would declare are a transform's choice. So the two
stay separate fields and neither changes meaning: `breakpoints` keeps the
transform's meaning (`transform-web-v1.md` §5), and a node's `breakpoint`
and fluid values stay reserved for it — Studio writes neither, and a reader
keeps both verbatim (§9). A web target may carry both.

**Why `frames` and not `pages`** (decided 2026-10-22, after a
compatibility check): every Studio since 2026-09-17 can write `pages` on a web target — its
Pages rail adds a print page (`{ w: 612, h: 792, bleed: 9, margins: 36 }`)
to a frameless web target, such as the screen target `migrateDocument` mints
for a pre-2026-08-24 document — and reads them as **print pages in points**
(bleed, margins, Document setup, the print PDF). **A web target's `pages`
keep that reading forever**; frames are a field of their own, so no saved
document reads differently. A web target with no `frames` (the migrator's,
the transform's declaration, one with such pages) reads exactly as before.
A web target with `frames` is drawn by its frames: any `pages` it also
carries, and any of its nodes with no `webFrame` (only a Studio from before
this date writes either there), are kept verbatim and not drawn. **A node
carrying `webFrame` is read by it alone; a `page` beside it (written by a
Studio from before this date, which renumbers pages) is kept and ignored.** A
reader that keeps nodes on no frame says so when it opens the document
(Studio: a notice with the count, and the status bar names them).

The validator requires `frames`, when present, to be an object keyed by
`frm_…` ids, each frame's `order` a finite number and its `w` and `h`
positive numbers, and its `name`, when present, a string (warned and read as
no name otherwise). A node's `webFrame` naming no frame of its target is a
warning, not an error — a peer may remove a frame while another draws on it
(§11) — and that node is drawn on no frame and kept. **Older readers:** a
reader before this date keeps `frames` and `webFrame` verbatim (§9) and
validates the document as before; Studio before it lists the Web output
(as *0 × 0*) and draws nothing on it ("no pages yet") — it opens the file
and re-saves the frames and every `webFrame` untouched, the weaker
forward-compatibility rule (measured on a build of
2026-10-22: its re-save equals the file apart from `meta`).

## 7. Styles and tokens

`styles` holds named, shared design decisions:

```json
"styles": {
  "sty_h1": { "id": "sty_h1", "kind": "text", "name": "Headline",
    "props": { "fontFamily": "Freight Display", "fontSize": 56,
               "lineHeight": 1.05, "fontWeight": 700, "color": "sty_ink" } },
  "sty_ink": { "id": "sty_ink", "kind": "color", "name": "Ink",
    "props": { "value": "#1a1a1a" } }
}
```

Style kinds: `text`, `color`, `stroke`, `fill`, `effect`, `grid`.

**Added 2026-10-17 (`studio-v1.md` Section 3.12):** a `text` style (or a
node's `style.overrides`) may carry `fontFeatures` — an object of
four-letter OpenType feature tags to `1` or `0`, CSS `font-feature-settings`
one to one (`{ "smcp": 1, "liga": 0 }`); `hyphens` — `"manual"` (default)
or `"auto"`; and `lang` — a BCP 47 tag for the text's language (absent: the
document's `meta.lang`, else the page's). All optional and additive; a
reader before this date draws the text without them.

**Added 2026-10-19 (`studio-v1.md` Section 3.18.1):** a `text` style (or a
node's `style.overrides`, or a paragraph style) may carry `spaceBefore`,
`spaceAfter`, `indentLeft`, `indentRight` (points, ≥ 0) and `indentFirst`
(points; negative hangs) — paragraph spacing and indents. All optional and
additive, absent 0; on a character style they are not read; a reader before
this date sets paragraphs with no space between them and no indent.

**Added 2026-10-28 (`studio-v1.md` Section 3.26.1):** a `text` style (or a
node's `style.overrides`) may carry `leading` (points > 0; the more specific
of it and `lineHeight` wins), `baselineShift` (points), `listType`
(`bullet` | `1` | `a` | `A` | `i` | `I`), `listStart` (integer ≥ 0),
`dropLines` (2–10), `dropChars` (1–10) and `tabStops` (an array of
`{ at: <pt ≥ 0>, align: left | center | right | decimal }`). All optional and
additive; a reader before this date draws the text without them.

**Added 2026-09-17 (`studio-v1.md` §3.5–§3.6):** a `color` style carries
`props.space` — `srgb` (default) | `cmyk` (+ `props.cmyk: [c,m,y,k]`) |
`spot` (+ `props.ink: { name, vendor?, code? }`, `props.plate`) — and
`props.value` stays an sRGB hex in every case; `props.overprint` defaults to
knockout. A `text` style carries `props.scope`: `paragraph` (default) |
`character`. The validator enforces the colour shapes (§12).
Styles may reference other styles (tokens) by ID. Node `style.overrides`
holds only the properties that differ — importers should aggressively
factor repeated properties into styles, because shared styles are visual
*meaning* (they become the site's design tokens in the web transform).

## 8. Assets

```json
"assets": {
  "ast_h": {
    "id": "ast_h",
    "kind": "image",
    "hash": "sha256-3f8a…c2",
    "file": "assets/sha256-3f8a…c2.jpg",
    "mime": "image/jpeg",
    "width": 4032, "height": 3024,
    "origin": { "file": "Links/glacier.jpg" },
    "proxy": null
  }
}
```

**Added 2026-09-20 (`studio-v1.md` §10.5):** `kind: "html"` — a
self-contained HTML file an `embed` node shows on a deck screen;
`mime: "text/html"`; `width`/`height` absent. Readers that predate it treat
it as `other` (an unknown kind is kept, never dropped — §9).

**Added 2026-09-17 (`studio-v1.md` §3.6):** `kind: "font"` assets carry
`props` (`family`, `weight`, `style`) and `license: { kind: "google" |
"uploaded" | "system", embeddable?: boolean }`; a PDF export embeds a
subset only when `embeddable` is not `false`.

Assets are content-addressed (`sha256-` prefix + hex digest); the filename
is the hash, so duplicates dedupe and git status is trustworthy. `proxy`
is designed in now (per the plan's local-first commitments) and holds
`{ "file": "proxies/…", "width": …, "height": … }` when implemented —
readers MUST tolerate it being `null` or absent.

**Added 2026-10-16 (`studio-v1.md` Section 7.5 and 8.1; the print
PDF):** a placed file kept whole, beside the picture it shows.

```json
"ast_f": { "id": "ast_f", "kind": "file", "hash": "sha256-7b1d…e0",
           "file": "assets/sha256-7b1d…e0", "mime": "application/pdf" },
"ast_p": { "id": "ast_p", "kind": "image", "hash": "sha256-3f8a…c2",
           "file": "assets/sha256-3f8a…c2", "mime": "image/png",
           "width": 2550, "height": 3300,
           "original": { "asset": "ast_f", "page": 1, "pages": 3 } }
```

- **`kind: "file"`** is a file as the person placed it — a PDF, a
  PDF-compatible Illustrator file, a TIFF — with `mime` its own type and no
  `width`/`height`. Nothing draws it on a page; an exporter reads it. A
  reader that predates it keeps it as `other` (§9).
- An **`image` asset made from such a file carries `original`**:
  `{ "asset": <the file asset's id>, "page": <1-based, the page the picture
  shows>, "pages": <how many the file has> }`. Optional and additive: a
  reader that predates it draws the image exactly as before.

*Why the file is its own asset and the picture is not its `proxy`.* `proxy`
is a smaller stand-in a reader *may* draw instead of the asset — a display
optimisation, with the asset the truth. For a placed PDF the picture is the
only thing a reader before this date can draw, so the picture stays in the
image asset's own slots and the file is the addition (the project's compatibility rule,
that every saved document reopens as it was saved: an older build keeps
showing the picture; a PDF in the picture's slots would be
a blank). And the file is a separate entry, not a field inside the image's,
because the account API counts references by each entry's top-level `hash`
(`apps/api/src/storage.ts` `writeEnvelope`, `syncRefcounts`): a hash nested in
a field would be swept as unreferenced after its grace. `proxy` keeps its
designed meaning for later.

## 9. Versioning and compatibility

`formatVersion` is semver, versioned from day one:

**`recipes`** is a top-level section defined by `module-io-v1.md` §5 — how a
module result was derived, keyed by design-node id. It is additive provenance:
every node is complete without it, and a reader that has never heard of it
renders the document correctly. It is named here only so the root key list is
complete; the normative definition is that spec's.

- **Patch/minor** additions are backward-compatible: new optional fields,
  new entity kinds, new style kinds. Readers MUST ignore unknown *values*
  gracefully (an unknown `kind` renders as `unclassified`/generic).
- **Unknown fields are preserved.** Any field not in this spec MUST
  round-trip untouched (in Yjs, unknown subtrees are stored verbatim).
  This is what lets old tools open new files without destroying them.
- **Major** versions may break; a written migration is mandatory before any
  major bump ships.

## 10. Extensions

Third-party or experimental data lives under `ext`, keyed by reverse-DNS
namespace, at document, entity, node, or style level:

```json
"ext": { "app.prodesigner.labs": { "experimentFlag": true } }
```

Core code never reads `ext`. Extensions that prove out graduate into the
spec by revision, not by convention.

## 11. CRDT mapping (normative summary)

The live document is a `Y.Doc` whose one root map, `prodoc`, mirrors §2:
`meta`, `content`, `design`, `targets`, `styles`, `assets`, `ext` are
`Y.Map`s inside it; ordered collections (`root`, `children`,
`relationships`) are `Y.Array`s; rich text (an entity's runs) is `Y.Text`.
IDs are map keys, so concurrent edits to different entities never conflict;
concurrent edits to the same field resolve by Yjs semantics.
`document.json` is produced by a deterministic walk of the `Y.Doc` (§1);
loading parses JSON into fresh Yjs structures.

**Corrected 2026-11-18 — the mapping exactly as the reference library
builds it.** This section said "top-level maps", which is not how the
library builds it, and listed runs among the `Y.Array`s, which they have not
been since 2026-08-23. Peers must build the same structure to interoperate:

- The `Y.Doc` has **one root map, `prodoc`** (`ydoc.getMap("prodoc")`). It
  holds `format`, `formatVersion` and `id` as plain values, and one entry per
  top-level section — `meta`, `content`, `design`, `targets`, `styles`,
  `assets`, `recipes`, `ext`, and any unknown top-level field (§9) — each
  converted as below. There are no other top-level shared types.
- Conversion is recursive: every JSON object becomes a `Y.Map` with the same
  keys, every JSON array a `Y.Array`, and every string, number, boolean or
  `null` is stored as it is.
- **Except text runs:** a field named `text` whose value is an array of runs
  (`{ t, marks }`, §4.2) becomes **one `Y.Text`**, not a `Y.Array`. Each mark
  becomes a formatting attribute: a boolean mark its own name set to `true`
  (`{ em: true }`); `link:<url>` becomes `{ link: "<url>" }`; a character
  style `sty_…` becomes `{ style: "sty_…" }`; `para:<value>` and each local
  mark of §4.2 (`font`, `size`, `weight`, …, `dropchars`) becomes
  `{ <name>: "<value>" }`; any other mark becomes `{ <mark>: true }`.
  Reading back, the runs are the text's delta, with marks in canonical order
  and adjacent runs with identical marks merged.
- `document.json` is the root map read back the same way.

Sync and persistence (update logs, snapshots) are carried out by the
reference library and the sync service and are not part of the interchange
format.

**Pictures with layers (`picture-v1.md` Section 2.3).** `picture` is a `Y.Map`; `layers` a `Y.Map` of layer `Y.Map`s keyed by id, each layer's `adjust` a `Y.Map` keyed by id; **order is each entry's `z`, and a reorder writes `z`** — never a delete and re-insert, which in a `Y.Array` duplicated a concurrently moved item in 60 of 60 measured trials (2026-10-19). `result` is recomputed by any peer that observes `result.inputsHash` differing from the current layers' hash.

**Motion (`motion-v1.md` Section 2.4).** `animation.keys` is a `Y.Map` of property path → `Y.Array` of key `Y.Map`s, read in `t` order, a key moved by writing `t`. A video target's `audio` and each track's `clips` are `Y.Map`s keyed by id. A video's `scenes` is a `Y.Map` keyed by `scn_…` id, each with `order`, and its nodes name their scene by id (`scene`), so a concurrent reorder writes two `order`s and cannot duplicate a scene. A deck's `screens` stays a `Y.Array` (nodes name a screen by index); a concurrent reorder there can duplicate a screen, a residual named for decks.

**The Web output's frames (2026-10-22, §6).** A web target's `frames` is a
`Y.Map` keyed by `frm_…` id of frame `Y.Map`s, each with `order`, as a
video's scenes are, and its nodes name their frame by id (`webFrame`). So:
two peers adding a frame (or a whole Web output, a new key of `targets`) at
once both land; two editing different fields of one frame merge; **a move
writes the moved frame's `order` and nothing else**, so two peers moving the
same frame at once leave it where one of them put it (never twice), a move
concurrent with a rename keeps both, and a frame inserted before another
concurrent with an object drawn on that other leaves the object on its own
frame. None of the decks' index residuals arises. The one named residual: a
frame removed while a peer draws on it leaves that object naming a frame
that is gone — kept, drawn on no frame, warned by the validator (§6).

**Component sets (`studio-v1.md` Section 3.23.13, 2026-10-31).** `design.componentSets` is a `Y.Map` keyed by `cst_…`; a set's `props` is a `Y.Array` of names (two peers adding a property both stand); a main's `variant.values` and `properties` are `Y.Map`s, one key per property, so concurrent edits of different properties merge and the same one resolves by Yjs semantics. Renaming a property rewrites the key in every variant in one transaction; a peer's concurrent value under the old name stays, dormant (the validator notes it).

**Components (`studio-v1.md` Section 3.23).** `design.components` is a `Y.Map`
keyed by `cmp_…`; each main's `nodes` is a `Y.Map` of node `Y.Map`s and its
`root` a `Y.Array`, as an expression's are. An instance's `overrides` is a
`Y.Map` of part path → `Y.Map` of property path → value, each property path
its own key, so two peers overriding different properties of one part merge
and two writing the same one resolve by Yjs semantics; an array value is
written whole. When both a whole-object key and a deeper key exist, the
deeper is applied after the shallower, so every delivery order draws the
same. **An instance is written with an empty map for every part path
its main has** (measured 2026-10-20: two peers creating the same part's map
at once lose one peer's keys, 40 of 40 trials; seeded, none). A part added
to a main later gets its map on its first override; that first override
made by two peers at once is the named residual.

**A picture's flip (§5, 2026-10-22).** `flipX` and `flipY` are two plain keys of the node's `Y.Map`, each its own last-writer-wins register: one person flipping across and another flipping up and down at the same moment both keep their axis, and turning one axis off deletes only that key. They are not a nested map: measured 2026-10-22 on the earlier `flip: { x?, y? }` shape, two peers creating the map at once kept only one peer's axis, and one peer deleting the emptied map dropped the other's new axis (a compatibility check of that day). `apps/studio/test/flip-content.test.ts` ("two people flipping at once") pins the five cases on the flat keys and keeps the nested map's loss as its control.

## 12. Validation

`packages/core` ships `validateDocument()`, the reference validator.
A document is **valid** when: required top-level fields are present and
well-typed; every ID matches its prefix pattern; every cross-reference
(`entity`, `style.ref`, `asset`, relationship endpoints, `children`)
resolves; `children` make no loop (§5, since 2026-10-21; checked in each
expression and each component main); no ID is defined twice across namespaces; entity kinds and node
types are from the registries (unknown kinds are a *warning*, not an error,
per §9). Importers MUST emit valid documents; the regression suite asserts
it on every fixture.

---

## 13. Resolved questions (founder review, 2026-08-04)

1. **Paragraph model (§4.2): runs-with-`\n\n` stands.** Cheap now; reassess
   only when real transform code demonstrates it needs paragraph entities.
2. **Multiple expressions per target: deferred.** One expression per target
   in v1; variants are separate targets. Parked.
3. **Table model — resolved 2026-10-17 by `studio-v1.md` Section 3.13:** the
   table's meaning is content (`table` → `table-row` → `table-cell` entities,
   §4.1) and its grid is design (one `table` node, §5). Importers keep
   emitting `unclassified` + `raw` for a source table until each importer
   maps its tables into the model (IDML's with the corpus run). The paragraph
   below is the 2026-08-04 position. **Table model: deferred.** Importers emit
   tables as `unclassified` with full `raw` preservation until a real fixture
   forces a proper model.
4. **Color model — resolved 2026-09-17 by `studio-v1.md` §3.5:** the single
   hex stays as every colour's `props.value` (the screen approximation), and
   `props.space` names cmyk/spot with their own data. No licensed swatch
   book ships. The paragraph below is the 2026-08-04 position it grew from.
   **Color model: single hex value stands for v1** (print→web only; we never
   write back to print). Spot/CMYK data is preserved in `raw`. Known and
   accepted: **spot color libraries (Pantone etc.) will be needed** when a
   print-output or brand-color feature arrives — the `raw` preservation is
   what keeps that door open without modeling it now.
