FigCraft document model, automation surfaces and NUIF adoption path
Document status:
reviewed. Canonical source.
Summary
FigCraft is a native Rust interface-design application (version 0.18.1, self-described
early alpha, MIT OR Apache-2.0). It has one Figma-shaped persistent document model,
a .figcraft ZIP archive containing serde JSON, and a single command registry
shared by menus, figcraft-cli, a JSON control channel, an MCP server and WASM
plugins. No FigCraft or craft-libs source mentions NUIF, and no NUIF source mentions
FigCraft at the reviewed revisions.
Repository interpretation: FigCraft and NUIF are complementary. FigCraft covers a
broad authored feature set but re-mints layer identity on most imports, drops
unknown serialized fields and reports import loss as untyped strings. NUIF profile 0
implements stable identity, byte-exact opaque preservation, typed fidelity and
HostAdapterReport, but its typed model covers about a dozen of roughly 70 compared
FigCraft concepts and its resource limits are far below observed FigCraft file sizes.
A FigCraft integration is therefore an adapter over FigCraft’s own model, not a
replacement document model.
Evidence
Source statements at FigCraft d4d4b57 and craft-libs ea9407b3:
- Model: one
Nodestruct with about 45 property fields across 16 node kinds (crates/doc/src/node.rslines 451–574). Typed component properties (boolean, text, instance swap, variant, slot) and materialized instance children with 22 override groups (crates/engine/src/assets/components.rslines 66–95). Variables are typed, grouped in collections with ordered modes, aliases,ColorAlphaandColorMixvalues, scopes and per-platform code syntax (crates/doc/src/styles.rslines 80–288). Vector networks carry regions and per-vertex radii (crates/doc/src/vector.rslines 38–193). - Identity: node ids are document-scoped
u64counters, orclient << 32 | counterin live sessions; the document has no document id; duplicate, paste, instantiation and.fig, REST and Sketch imports mint new ids (crates/doc/src/lib.rslines 59–164). The Penpot importer retainspenpot.id, bounded source JSON up to 16 KiB per key and fingerprints inpluginData(crates/format/src/penpot.rslines 660–723). - Resolved state: auto layout writes computed child
transform,widthandheightinto authored fields (crates/layout/src/lib.rslines 114–150). - Serialization:
.figcraftstoresdocument.jsonwith defaults omitted, images by SHA-256, an optional thumbnail and version snapshots; one documentversion: 1; newer versions are refused; older files rely on serde defaults, aliases and arepair()pass; the serde model has no catch-all, so unknown keys are ignored (craft-libscrates/figcraft-format/src/lib.rs; FigCraftcrates/doc/src/node.rs). Decompression is bounded at packed size × 16, clamped to 512 MiB–4 GiB, with 20,000 images and a 6 GiB unpacked archive limit (craft-libscrates/figcraft-format/src/lib.rslines 729–767). A test records a 900,000-layer file of 1.48 GB JSON and 244 MB packed (crates/format/src/large_tests.rslines 216–230). Fonts are identified by family and style names; no font binaries are stored (docs/penpot.mdlines 48–53). - Import loss: REST import emits at most 200 deduplicated warning strings without
entity or property pointers (
crates/format/src/rest.rslines 72–75). - Automation:
command.batchis atomic, is one undo step and resolves{"$ref"}and{"$step"}ids created earlier in the batch (crates/engine/src/session/undo.rslines 196–258).node.createaccepts no caller-supplied id (crates/engine/src/cmd/create.rslines 60–65). Undo isArcsnapshots, not operation inverses (docs/architecture.md). Control-channel events cover comments only and the loopback channel has no token (docs/control-protocol.md; open pull request 1473 adds one). Revision preconditions and document events exist only in unmerged external pull request 1995. - Formats are free functions in
figcraft-formatdispatched by extension inload_any(crates/engine/src/cmd/file/load.rslines 99–157); there is no format trait or registry. - Plugins run under wasmi with no WASI, file or network access, only
figcraftmodule imports, at most 100,000 host calls per run and one saved file of at most 16 MB (docs/plugins.md). wasm-bindgen glue such asnuif-wasmis therefore refused at instantiation. - Collaboration: a central server orders per-property last-writer-wins changes over
stable ids;
collab.diffreturns create/set/delete changes and a documented test asserts that applyingdiff(a, b)toareproducesb(docs/collab-protocol.md). - Governance: pull request 845 was closed with a maintainer statement that a second
token system next to variables is more than FigCraft should carry, while a DTCG
import/export of variables would be welcome; issue 1687 tracks that export. A
craft-libs crate must serve more than one application (craft-libs
AGENTS.md). craft-libs describescraft-figma-restas the neutral model for design files (crates/figma-rest/README.mdlines 3–10): a Figma-REST-shaped record model with unknown-field retention, without cross-tool correspondence, typed fidelity or semantic operations. - Release cadence: 20 tagged releases from v0.2.0 (2026-10-10) to v0.18.1 (2026-11-12) on the public release list.
Native observations with figcraft-cli 0.18.1 on synthetic files
(2026-11-20): pluginData survives save and reload, branch creation, edits on
the branch and branch.merge (including layers created on the branch, whose
ids use the client << 32 form); edit.duplicate and edit.copy with
edit.paste copy pluginData verbatim to the new layers. Variables and
collections copied from a library carry ids prefixed with the library id and
are refused by variable.set in the consuming file; changes are made in the
library file, published with library.publish and pulled with
library.acceptUpdates.
NUIF statements at local revision af36b8c:
- Profile-0 limits are compile-time constants: 8,192 entities, tokens and assets
(
crates/nuif-core/src/lib.rslines 15–27) and 16 MiB codec input (crates/nuif-codec/src/lib.rsline 15). - Spec 07 line 25 loads a newer-schema entity as
Unknown; spec 08 line 125 makes reading a newer record an error. The core decodes withdeny_unknown_fields, rejects newer schema versions and has no registered migrations. - The DTCG profile carries only flat boolean, string and number tokens and names a
token-model RFC as prerequisite (
adapters/dtcg/PROFILE.md). - No persistent correspondence record exists in core, API or package code; spec 06 requires three-way merge and no implementation exists.
Dependency observations from lockfile comparison (no build was run): both
workspaces use edition 2024 and resolver 3 and share identical versions of serde,
png, harfrust 0.13.3 and wasm-bindgen 0.2.129. NUIF declares rust-version 1.97
against FigCraft 1.95; at the reviewed revision the exact pin zip =9.0.3 would
have downgraded FigCraft’s zip 9.1.1 through nuif-penpot (NUIF now pins
9.8.1), and skrifa =0.46.2 would add a fourth skrifa version; nuif-text has
font-test-data as a normal dependency. The set nuif-core, nuif-codec,
nuif-protocol, nuif-adapter adds about seven crates absent from FigCraft’s
lockfile.
Mechanism
Concept mapping at the reviewed revisions, by repository interpretation:
| Concept | Mapping |
|---|---|
Child order, names, padding, single gap, start/center/end cross alignment, fixed size, rectangle, full ellipse, one solid sRGB fill, SHA-256 image bytes, fixed and fr grid tracks | Exact in restricted form |
| Instance to main component reference | Exact link only; NUIF has no parameters, overrides or materialization |
| Variables, collections, modes, aliases, styles | Absent from NUIF typed model; flat tokens only |
| Strokes, multiple fills, gradients, effects, blend modes, rotation, radius, opacity, visibility, clipping, masks, vector networks, booleans | Absent from NUIF typed model |
| Multi-run text, soft wrap, name-based fonts | Absent; NUIF text is single-run bound to exact font bytes |
| Wrap, space-between, baseline alignment, min/max, absolute children, constraints | Absent or approximated in NUIF layout |
| Variant sets | Conflict: FigCraft uses sibling components; NUIF draft uses parameter configurations |
| Layout results | Conflict: FigCraft writes resolved values into authored fields |
| Stable identity, document id, unknown-field retention, typed fidelity | Present in NUIF; absent or partial in FigCraft |
Integration surfaces, in order of first use:
- NUIF-owned
nuif-figcrafthost adapter onfigcraft-cliand MCP: snapshot fromvariable.list,inspect_documentandnode.get; atomiccommand.batchorfigcraft-cli runwrite plans; NUIF ids inpluginData["nuif.id"]plus a NUIF-side correspondence record. Requires no FigCraft change. - Reverse direction by state diff (
collab.diffor snapshot comparison) rather than translation of UI-level commands. - In-process
figcraft-format::nuifmodule embeddingnuif-core,nuif-codec,nuif-protocolandnuif-adapter, once NUIF profiles cover most of a real file. - Collaboration-protocol bridge for live synchronization.
NUIF relevance
Borrowable: FigCraft’s atomic batches map one NUIF transaction to one undo step;
pluginData is an accepted place for bounded foreign identity; variable
codeSyntax.WEB values can act as correspondence keys to CSS custom properties.
Required NUIF work before a first FigCraft profile: a format-evolution decision resolving spec 07 and spec 08; a token-model RFC with colour and dimension types, collections, ordered modes and aliases; a retentive CSS custom-property token profile; then visual-property, text, layout and component RFCs argued against Penpot, HTML/CSS and Figma together so FigCraft semantics do not enter the core by popularity. Whole-file interchange additionally needs a measured larger resource profile; synchronization needs persistent correspondence, diff-to-patch and three-way merge.
Implementation status at 2026-11-20: proposed RFC 0014 resolves the spec 07
and spec 08 conflict with a minimum-envelope-version rule; proposed RFC 0015
adds typed token collections, ordered modes, aliases and mode selection.
nuif-css-tokens-0 imports custom properties from several stylesheets into one
or more collections with base-scope cascade, var() fallbacks and rem, and
writes value edits, mode overrides and new tokens back as span edits.
nuif-figcraft-variables-0 imports variable.list snapshots, links existing
files by codeSyntax.WEB or name, and plans collection, mode and value changes
(optionally by resolved value, leaving the host’s alias structure intact),
verified against a simulated host. nuif css-tokens and nuif figcraft
expose both on the command line. Local native trials with figcraft-cli 0.18.1 passed four scenarios (create, host edit, host addition with id
remapping, linking an existing file); a macOS CI job pins and verifies the CLI
release. nuif-figcraft-nodes-0 maps frames with freeform or stack auto layout,
rectangles, ellipses, sizing and one solid fill, carries other layers as opaque
entities, and keeps identity in pluginData with duplicate repair; a native
layer scenario passed. Proposed RFC 0016 adds visibility, group opacity,
centre-pivot rotation, corner radii, one solid stroke and clipping (envelope
version 3); the layer profile maps all but rotation. Proposed RFC 0017 adds
name-identified linked font faces and text style (envelope version 4), and the
layer profile maps plain single-style text to Text entities with one shared
linked face per family and style; a native text restyle and caption creation
passed. Proposed RFC 0018 adds component parameters, variants as enum
configurations over one definition tree, bindings, instance state and a
deterministic expansion (envelope version 5). The layer profile maps
standalone components with boolean and text properties and their instances;
bindings come from the saved file, and the import compares NUIF’s expansion
with the host’s materialized children. A native scenario (bindings, identity,
a property change and a new instance) passed with the expansion equal to the
host’s children. A component set whose variants correspond one to one maps
as one component with an enum parameter per variant property, the first
variant as definition tree and the others as override sets; node.get
returns set variants and nested instances only as childCount, so snapshots
carry them as separate results that the adapter merges. A native set
scenario (variant switch, creation from the set) passed. Instance overrides
are planned with node.set on the corresponding materialized child and
removed with component.resetOverride; a native override scenario passed.
Instance-swap properties map to component parameters bound to nested
instances; a native swap scenario passed. FigCraft turns layers
counter-clockwise about their centre and reports the rotated origin, rounded
to 0.01 px for other angles; right-angle rotations of freeform layers convert
exactly and a native rotation scenario passed. Property definitions are
planned with component.addProperty, deleteProperty, editProperty and
bindProperty; FigCraft keeps an instance’s shown value when a default
changes and sets a bound layer to the default, so plans re-set affected
instance values and refuse bindings whose layer does not show the default. A
native definition scenario passed. Slot properties and variant edits remain
open.
A read-only dry run on a copy of a private production design-system file
(about 10,700 layers, 89 component sets, 1,364 instances; no data retained in
the repository) imported and planned without error once opaque layers were
fingerprinted, but mapped little of the file: 15 of 89 sets, 114 instances
and few text layers. Nearly all text binds properties to variables
(boundVariables, about 1,900 layers) or uses named text styles (styles
and textStyleRanges, about 1,700), which the profile does not map, and sets
whose variants contain such text cannot be shown to correspond. Variable
bindings on layer properties and named styles are therefore the next
coverage step; they need a token-binding contract in the core model.
Proposed RFC 0019 adds that contract: authoritative token bindings on entity
properties whose literals equal the token’s value in the entity’s modes,
with a refresh whose undo is exact. The layer profile maps boundVariables
through the variables correspondence, reads explicit modes from the saved
file’s var_modes (which node.get omits), keeps bindings that disagree
with the host as an extension, and plans variable.bind; a native binding
scenario passed.
Further rounds added named-style preservation, binding and parameter overrides (RFC 0018 amendments), nested swaps, sections and an import that keeps a component opaque when validation rejects its overrides. A repeat of the read-only dry run on the same private file then mapped about 680 of roughly 925 instances, 37 of 89 component sets (151 variants) and about 410 token bindings with no validation errors; the remaining sets mostly differ in structure between variants or use properties outside the profile.
Local figcraft-cli 0.18.1 probes on 2026-11-20 found that FigCraft rounds
each line pitch to whole pixels (12 px Inter at Auto is 15 px; two 13 px
lines are 32 px) and centres the line box. node.get does not report
textAlignVertical, textCase, paragraph spacing or indent, or OpenType
features, and inspect.properties reports only paragraph spacing, so a
snapshot cannot show that a text uses their defaults. The text mapping is
therefore approximated. Plans never write those properties and refuse a
non-top vertical alignment because the result could not be verified. Editing
a text’s characters adds overrides: ["characters"], which FigCraft uses to
keep text edits through instance swaps.
Component probes with the same CLI found three read surfaces of different
completeness. node.get reports a component’s componentPropertyDefinitions
(boolean and text; variant properties live in variant names such as
Size=Large and in component.properties), an instance’s mainComponent,
non-variant componentProperties, materialized children with their own ids,
and overrides as group names (fills, padding, textStyle, …) on the
instance and on each changed child. It does not report which layer a property
drives, nor which main-component layer a materialized child copies. The saved
file is a zip whose document.json (format: "figcraft", version: 1)
records both: prop_refs (for example {"characters": "Text"}) on bound
layers and source on materialized instance children, together with text
case and the other properties node.get omits. Generated component code
(inspect.componentCode) shows the bindings only as source text.
Carrying every FigCraft-only property as an opaque preserved_unrenderable
extension would give FigCraft lossless self-round-trips with current code but no
value to other consumers, and approaches the stop condition “semantic model
requires pervasive vendor-specific exceptions” in docs/roadmap.md. It is
acceptable only as a bridge retired by neutral RFCs.
An adapter maintained by NUIF does not meet the vendor-adoption evidence bar in
docs/STANDARDS-ROADMAP.md, which requires a maintainer outside the reference-core
implementation.
Open questions
- How should duplicated
nuif.idvalues be resolved when a duplicate and its original are both edited before the next import? - What fraction of large real FigCraft files is image bytes rather than layers?
- Can components, variables and paint travel through neutral NUIF profiles, or only
through FigCraft-namespaced extensions? Tracked as
nuif:question:figcraft-host-fit. - Which FigCraft surface provides a stable snapshot of saved
Documentstate rather than the presentation format returned bynode.get? - Could
node.getreport vertical alignment, case, paragraph spacing and indent, and OpenType features, so that plain text can be verified as lossless? - Should component bindings be read from the saved
document.json, whose format is versioned but undocumented, or shouldnode.getreportprop_refsandsource?