Repository Public License
1# ADR 0002 — Blueprint and object format23**Status:** accepted (2026-11-22)45## Context6The blueprint is the single artifact the renderer displays, the agent edits, the version system diffs and the publisher packages (spec §6). It must be diffable, patchable by stable ID, and survive format evolution.78## Decision9- **JSON**, with a **canonical serialization**: object keys sorted by Unicode scalar order, no insignificant whitespace, integers printed without a fraction, doubles with the shortest round-tripping representation, `/` not escaped. The SHA-256 of the canonical bytes is the content hash used by snapshots, builds and catalog verification.10- An **AppBlueprint** is a flat **object graph**: `{schemaVersion, id, name, version, entrypoint, permissions, theme, objects[]}`. Every object is a PUOP record (`id`, `type`, `schemaVersion`, `name`, `metadata`, `dataRef`, `inputs`, `outputs`, `capabilities`, `permissions`, `dependencies`, `ui`, `runtime`, `version`, `provenance`, `tests`) plus three structural fields PRISM needs: `props` (component configuration), `children` (ordered child object IDs) and `events` (event name → action list).11- Flat rather than nested, so that every edit is "object X, field Y" — the same shape for agent tools, Design-mode edits, diffs and undo.12- Object kinds by `type` prefix: `prism.page`, `prism.data.table`, `prism.data.query`, and catalog components (`prism.text`, `prism.table`, `prism.chart.line`, …).13- Dynamic values inside `props` are tagged objects: `{"$expr": "state.filter"}` (expression, ADR 0003) and `{"$bind": "state.filter"}` (two-way binding to a state key).14- `schemaVersion` is explicit at blueprint and object level. Loading runs **migrations** registered per version step (`1 → 2 → …`); an unknown newer version is rejected with a clear error rather than half-read.15- **Edits are patches**: a small closed set of operations (`addObject`, `removeObject`, `setProp`, `removeProp`, `setField`, `setEvent`, `moveChild`, `setBlueprintField`). Applying a patch returns a new blueprint value and leaves the old one intact; undo/redo and rollback keep the previous values (blueprints are small), so no inverse patches are needed.16- Three things stay separate: the blueprint (immutable value per version), runtime state (`AppRuntime`), cached query results (invalidated by a data revision counter).1718## Consequences19- Validation is a pure function `validate(blueprint, catalog) → [Issue]` covering schema, reference integrity, cycles, prop types, expressions, queries and permissions; the agent, the editor and the publisher all call the same one.20- A flat graph needs a reachability check (orphans are warnings) and a cycle check on `children` and `dependencies`.21