Blocks & layout
Metadata-bearing rune structure is fully explicit. There is no canonical render order, no auto-derived preamble wrapper, and no implicit nesting. Three orthogonal pieces on RuneConfig describe the whole picture:
metaFields — a pure data manifest. One entry per meta-bearing field, describing what the field means. No layout, no placement.blocks — named metadata blocks projected from metaFields. Each block picks which fields it contains and one layout primitive (bar, definition-list or lead).layout — the recursive skeleton tree. A map keyed by container name; an entry either creates a wrapper element or orders an existing one. This is the only thing that decides where anything renders, and it builds the preamble / content / media grouping, so no rune assembles it by hand in TypeScript.
The shape a field renders as (chip vs. bare text, link, rating widget, icon) is intrinsic to the field's metaType and decorations — it does not change with the block's layout primitive. The primitive only controls the geometry around the fields.
Each entry describes one field. All keys are optional.
metaFields: {
status: { metaType: 'status',
sentimentMap: { done: 'positive', blocked: 'negative' } },
priority: { metaType: 'category', label: 'Priority',
sentimentMap: { high: 'caution', medium: 'neutral' } },
created: { metaType: 'temporal', label: 'Created', tag: 'time',
condition: 'created', transform: 'duration' },
tags: { metaType: 'tag', label: 'Tags', condition: 'tags', splitOn: ',' },
}
| Field | Type | Description |
|---|
metaType | 'status' | 'category' | 'quantity' | 'temporal' | 'tag' | 'id' | 'code' | Semantic kind. Drives intrinsic render shape and typography. Emits data-meta-type |
label | string | Human-readable label. Used as the <dt> in a definition-list, and as link/icon text where applicable. Bar fields are unlabelled |
sentimentMap | Record<string, 'positive' | 'negative' | 'caution' | 'neutral'> | Maps the resolved value to a sentiment. Emits data-meta-sentiment when matched; with no map, or no match for the value, the attribute is omitted and the value renders neutrally. Never changes shape — color only |
condition | string | Field renders only when the named modifier has a truthy value |
renderWhenEmpty | boolean | Loosen condition to test presence instead of truthiness — render when the modifier is defined, even if the value is "". Lets an empty-but-present value still project a block (e.g. codegroup title="" renders the window chrome without a filename) |
href | string | Render the field as a link. The named modifier holds the URL |
rating | { total?: string } | Render the field as a rating widget. The field value is the filled count; total names the modifier holding the max (default 5) |
icon | { group: string } | Decorate with a leading icon. The field's value selects the glyph within group |
tag | string | Element tag override. Default span; use time for a temporal field so the engine emits <time datetime="…">…</time> |
splitOn | string | Treat the value as a delimited collection — split on this character, one element per item. Used for tags-style fields |
transform | 'duration' | 'uppercase' | 'capitalize' | Value transform applied before rendering. duration turns ISO 8601 (PT30M) into readable text (30m) |
i18nKey | string | Pins the label's translation key. By default it is derived as {scope}.{block}.{fieldName}; set this to keep a key stable across a block or field rename |
A block selects fields from metaFields and a layout primitive. The block's data-name is its key, so it gets the BEM element class .rf-{block}__{blockName}.
interface BlockDef {
fields: (string | { field: string; align?: 'start' | 'end' })[];
layout: 'bar' | 'definition-list' | 'lead';
wrap?: boolean;
}
fields — ordered list of metaFields keys. An entry may be a bare string or { field, align } to right-align a field within a bar (see below).layout — the primitive: bar, definition-list or lead.wrap — bar only; defaults true. Set false to keep the row on one line.
blocks: {
meta: { fields: ['status', { field: 'priority', align: 'end' }], layout: 'bar' },
details: { fields: ['created', 'tags'], layout: 'definition-list' },
}
layout — the recursive skeleton
layout is the skeleton tree. It is keyed by container name; the reserved key 'root' is the entry point — the rune's own element, which already exists. Each entry is a LayoutEntry:
type LayoutEntry =
| string[] // order children; create no wrapper
| { tag?: string; children: string[]; attrs?: Record<string, string> };
layout?: Record<string, LayoutEntry>;
The two forms divide two separate jobs — the transform labels slots (semantics), layout nests them (presentation):
- An entry with a
tag creates a wrapper element. Its key becomes the wrapper's data-name (→ .rf-{block}__{key} via the BEM pass, and a data-section via the sections map). attrs adds static attributes. The transform never builds this wrapper — layout does. - An entry without a
tag (or a bare array) orders an existing container of that name in place — the transform built the container; layout reorders / injects into it.
Name resolution
Each child name in a children list (or root) resolves, in order:
- a
layout entry with a tag → create the wrapper and recurse (its children pull from the same flat slot pool); - a
layout entry without a tag → reorder the existing container of that name; - a projected block (a
blocks entry) → project the metadata block; - a transform-emitted node carrying that
data-name → place it; - otherwise → skip.
Each slot is placed at most once (diamond references resolve to the first placement); a reference cycle (a → b → a) warns and skips to break the loop. Unlisted transform children append after the listed ones, in transform order — rune content is never dropped. Omitting layout entirely renders the transform tree verbatim.
Flat emit + declarative grouping
The idiom: the transform emits a flat bag of data-name slots — headline, blurb, eyebrow, media, ingredients, … — and layout composes them into the nested skeleton. The recipe content + media split, fully declarative:
layout: {
root: ['media', 'content'],
content: { tag: 'div', children: ['preamble', 'metadata', 'ingredients', 'steps', 'tips'] },
preamble: { tag: 'header', children: ['eyebrow', 'headline', 'blurb'] },
}
root places the media slot and creates the content column; content creates the column <div> and fills it with the preamble header, the projected metadata block, and the body slots; preamble creates the <header> and fills it with the page-section header slots. None of these wrappers exist in the transform output — layout builds them all.
A tag-entry subsumes projection.group (a wrapper that creates a container is a group) and projection.relocate (you place a slot wherever you name it — no separate move op). Both are deprecated; see Projection.
Intrinsic field render shape
The shape a field value renders as is decided by its metaType and any decorations, independently of the block's layout primitive.
Pill vs. bare
The engine emits one value element for every field, carrying its data-meta-type (and data-meta-sentiment when mapped), and no class. The base stylesheet decides the look from the type:
- Pill:
[data-meta-type] ∈ {status, category, tag}. - Bare inline text:
id, quantity, temporal, code, or no metaType.
id / code → monospace.quantity / temporal → tabular-nums.id additionally renders in the primary color (semantic emphasis).
A theme restyles the pill by those same selectors. Geometry around the values comes from [data-zone-layout]. Only the {% badge %} rune keeps the .rf-badge class, and the pill rule covers it too.
Rich renderings (decorations)
When a field carries href, rating, or icon, it renders richer than a plain value. Precedence, highest first: link > rating > icon > chip > bare.
href → <a data-meta-type="link"> with label (or the value) as text. Bare — no chip.rating → <span data-meta-type="rating"> containing total mark <span>s; the first value of them carry data-filled="true", the rest data-filled="false". CSS draws the stars/dots.icon → a leading empty <span data-icon-group="{group}" data-icon="{value}"> (glyph supplied by CSS mask-image) followed by <span data-meta-value>{label or value}</span>.
Sentiment and split
sentimentMap only adds data-meta-sentiment (color). It never changes the shape.splitOn fans a delimited value into one chip / element per item.
Layout primitives — emitted DOM
LayoutPrimitive is 'bar' | 'definition-list' | 'lead'.
bar
A horizontal flex row of fields, each in its intrinsic shape. Bar fields are unlabelled (eyebrow-style).
<div class="rf-work__meta" data-name="meta" data-zone-layout="bar">
<span data-meta-type="status"
data-meta-sentiment="positive" data-field="status">done</span>
<span data-meta-type="category"
data-meta-sentiment="caution" data-align="end" data-field="priority">high</span>
</div>
- Each value names its field with
data-field, as a definition-list row does, so a theme can address one value ([data-field="priority"]) without a class per rune. lead values carry it too. - A field with
align: 'end' gets data-align="end". In CSS that field takes margin-left: auto, pushing it (and everything after it) to the right edge. wrap defaults true. Set wrap: false → data-wrap="false" keeps the row on one line.
definition-list
A <dl> with one <div data-name="row" data-field="{name}"> per field, each holding a <dt data-meta-label> and a <dd>.
<dl class="rf-work__details" data-name="details" data-zone-layout="definition-list">
<div data-name="row" data-field="created">
<dt data-meta-label>Created</dt>
<dd><time data-meta-type="temporal">3 days ago</time></dd>
</div>
<div data-name="row" data-field="tags">
<dt data-meta-label>Tags</dt>
<dd data-multi-value>
<span data-meta-type="tag">api</span>
<span data-meta-type="tag">docs</span>
</dd>
</div>
</dl>
- Chip-type fields render the value as a chip inside the
<dd>. - Bare types render plain in the
<dd>, carrying data-meta-type. - A multi-value (
splitOn) <dd> gets data-multi-value. - The
data-field="{name}" lets themes target a specific row.
lead
A byline: a lead value with secondary values beneath it, as a quote's attribution or a person's name over their role. The fields render in a column, each in its intrinsic shape and unlabelled, like bar. The first field present carries data-lead.
<div class="rf-{block}__byline" data-name="byline" data-zone-layout="lead">
<span data-lead>Ada Lovelace</span>
<span>CTO</span>
<span>Analytical Engines</span>
</div>
- The skeleton lays the fields out in a column. Lumina sets the whole block small (
--rf-text-sm), as fine print, emphasizes [data-lead] by weight and mutes the rest, by :not([data-lead]). - Nothing ranks the values (
data-meta-rank), so a compact container hides none of them.
ladder
A list of peer items, each free to arrange its own inside. It is not a blocks layout: a composition's template places it with {% group layout="ladder" %}, and cast's list mode emits it.
<ol data-name="steps" data-zone-layout="ladder" data-sequence="numbered">
<li><span data-name="ordinal" data-meta-type="quantity">1</span>…</li>
<li><span data-name="ordinal" data-meta-type="quantity">2</span>…</li>
</ol>
- An
<ol> with data-sequence when the rune declares a sequence; its markers and gutter are the sequence dimension's. - Otherwise a
<ul>, which the skeleton resets and flows in a column. Spacing between items is the theme's.
Composable rune handles
Each layout primitive also ships as a standalone authoring rune so authors can compose the same shape in prose without a plugin to project it:
{% bar %} — bar layout in the rune body.{% deflist %} — definition-list layout; a markdown list where each - **Term:** value becomes a <dt>/<dd> pair.
Same DOM, same CSS, same chip primitive as the projected versions.
Worked examples
These are the canonical configs from the shipped runes.
Hint — flat rune, single icon-decorated field
metaFields: { hintType: { icon: { group: 'hint' } } },
blocks: { header: { fields: ['hintType'], layout: 'bar' } },
layout: { root: ['header'] },
The header block projects the single hintType field as an icon-decorated value in a bar at the top of the rune.
Budget — bar with a right-aligned field
metaFields: {
duration: { metaType: 'category', condition: 'duration' },
currency: { metaType: 'category', condition: 'currency' },
},
blocks: { meta: { fields: ['duration', { field: 'currency', align: 'end' }], layout: 'bar' } },
layout: {
root: ['meta', 'preamble'],
preamble: { tag: 'header', children: ['headline', 'blurb', 'image'] },
},
currency is pushed to the right edge of the bar; the meta block renders above the rune's preamble header. The transform's categories and footer aren't named in layout, so they append after — content is never dropped.
Event — labelled def-list plus a bar-wrapped CTA link
metaFields: {
date: { metaType: 'temporal', label: 'Date', condition: 'date' },
endDate: { metaType: 'temporal', label: 'Ends', condition: 'endDate' },
location: { metaType: 'category', label: 'Location', condition: 'location' },
register: { label: 'Register', href: 'url', condition: 'url' },
},
blocks: {
metadata: { fields: ['date', 'endDate', 'location'], layout: 'definition-list' },
register: { fields: ['register'], layout: 'bar' },
},
layout: {
root: ['preamble', 'metadata', 'body', 'register'],
preamble: { tag: 'header', children: ['eyebrow', 'headline', 'blurb', 'image'] },
},
root orders the preamble wrapper, the projected blocks (metadata, register), and the body slot. The preamble entry creates the <header> and fills it with the flat header slots — so headline / blurb are addressable by name instead of being buried in a hand-built wrapper. The register field renders as a link (href), so it appears as bare link text inside its bar — no chip.
Character / Recipe — creating a content column + preamble
blocks: { metadata: { fields: ['role', 'status'], layout: 'definition-list' } },
layout: {
root: ['portrait', 'content'],
content: { tag: 'div', children: ['preamble', 'metadata', 'sections'] },
preamble: { tag: 'header', children: ['name'] },
},
The transform emits flat slots only. root places the portrait slot and creates the content column; the content entry creates the column <div> and fills it with the preamble header, the projected metadata def-list, and the sections slot; preamble creates the <header> around the title. No wrapper is pre-built in the transform.
Theme overrides
Themes override a rune's metaFields, blocks, or layout by inner key via mergeThemeConfig. A theme can override a single field, a single block, or a single container's order without restating the whole map.
// Theme override on a rune config
Character: {
// Re-point one field's sentiment without touching the others
metaFields: {
status: { sentimentMap: { active: 'positive', retired: 'neutral' } },
},
// Swap one block's primitive
blocks: {
metadata: { fields: ['role', 'status', 'faction'], layout: 'bar' },
},
// Reshape one container without restating root (restate the wrapper
// entry so its `tag` is preserved)
layout: {
content: { tag: 'div', children: ['metadata', 'preamble', 'sections'] },
},
}
Each inner key is merged onto the rune's existing map, so unrelated fields, blocks, and containers are inherited unchanged. A layout entry is replaced as a whole, so restate its tag when overriding a wrapper-creating container.
variants — modifier-keyed config deltas
Some runes need their structure to vary by a modifier: a feature tiles its definitions as a grid when media is stacked but stacks them in a column when media is beside; a card in media-position="cover" regroups media + header into an overlay band with the body flowing below. The transform is flat/semantic (it never branches structure) and CSS can reposition but not restructure, so this gap is filled by engine config variants: modifier-keyed config deltas merged over the base config per instance.
// on RuneConfig
variants?: Record<string /* modifier (axis) */, Record<string /* value */, Partial<RuneConfig>>>;
The outer key is a declared modifier name (the axis); the inner key is a modifier value; the payload is a partial RuneConfig merged over base. A recipe's cover variant:
variants: {
'media-position': {
cover: {
layout: {
root: ['cover-band', 'body'],
'cover-band': { tag: 'div', children: ['media', 'preamble'] },
body: { tag: 'div', children: ['metadata', 'ingredients', 'steps', 'tips'] },
},
},
},
},
Selection rides the modifier system. Per instance the engine resolves each axis's modifier value (with its default) and merges variants[axis][value] over base — in variants declaration order — before layout assembly. There is no separate condition language and no defaultVariants: the modifier's own default already determines the active value. The merge reuses the same by-key semantics as a theme override (a delta's layout.root replaces the array; new wrapper keys are added; base keys the variant no longer references simply go unused), and the layout assembler itself is unchanged — variants only choose which static config it is fed.
What a delta may override. A delta restructures/redecorates a rune; it cannot redefine it. It may set the assembly/decoration fields (layout, structure, styles, contentWrapper, staticModifiers, autoLabel, editHints, …) but not identity fields (block, the modifiers axis definitions, sections). Every axis must be a declared modifier — both invariants are checked at config load (a missing modifier or an identity-field override is a config error).
Themes extend variants. variants is part of RuneConfig, so mergeThemeConfig merges it like any other field — a theme can add a new axis or override a single axis/value delta. For example a theme can give its card a media-position="cover" variant the base theme doesn't ship.
Consumer prerequisite — the flat-slot model. Because a variant restructures by merging a layout delta and re-running flat-slot assembly, the rune must emit flat data-name slots and carry a base layout for the delta to override (see layout — the recursive skeleton above). A rune that pre-assembles its structure in the transform has no loose slots to regroup and no base layout to merge into — variants cannot reach it. (card, bento-cell, and recipe are all on the flat-slot model.)
compoundVariants (cross-axis deltas) is a reserved future extension, intentionally not implemented.
Tooling. refrakt contracts enumerates a per-variant structure under each rune's variants[axis][value] (the base merged with the delta), and the CSS-coverage derivation folds in selectors a variant introduces. refrakt inspect <rune> --<modifier>=<value> renders a variant by passing the selecting modifier value — no new flag needed.
Projection — reshaping unowned trees
projection reshapes the output tree by data-name after assembly. It is the escape hatch for bending a tree a theme does not own — a theme adjusting a third-party rune's output without that rune declaring layout. The boundary: layout is a rune/theme declaring its own intended structure; projection is post-hoc surgery on someone else's.
hide — drop elements by data-name (the default is append-not-drop, so removal is explicit). Retained.group — deprecated. A wrapper that creates a container is a group; use a layout tag-entry instead.relocate — deprecated. You place a slot wherever you name it in the layout tree; there is no separate move op.
The contract generator emits a deprecation warning for group / relocate, and they carry @deprecated JSDoc.
Contracts
generateStructureContract surfaces each block as an addressable element:
{
"tag": "div",
"selector": ".rf-work__meta",
"source": "block",
"layout": "bar",
"fields": ["status", "priority"]
}
tag is div for a bar block and dl for a definition-list.
It also surfaces every layout-created wrapper — the whole declarative skeleton, not just projected blocks. A tag-entry becomes an element carrying its child membership:
{
"tag": "header",
"selector": ".rf-recipe__preamble",
"source": "layout",
"children": ["eyebrow", "headline", "blurb"]
}
The rune's childOrder is computed from layout.root (the listed names) followed by a {content} sentinel that stands in for the appended, unlisted transform children; the per-wrapper children lists describe the nested membership below that.
Background: Block-and-layout rune assembly model · Declarative structure assembly
SPEC-080shipped
Block-and-layout rune assembly model
Refine the SPEC-079 zone model into a smaller, orthogonal contract for how metadata-bearing and media-bearing runes are assembled. A rune transform emits a tree of named blocks; the theme projects metadata blocks from a field manifest and composes the final tree by placing block names into containers. Field shape (chip vs bare), block grouping, layout geometry, and final placement become four independent axes instead of the overlapping zones / zoneLayouts / contentSlots / order / zoneHost / zoneHostPlacement surface that has accreted on RuneConfig.
This supersedes the placement-related parts of SPEC-079 (zones shape, zoneHost, zoneHostPlacement, eyebrow left/right slots). The data-manifest idea (metaFields) and the plugin-declares-data / theme-declares-presentation split from SPEC-079 are kept and extended.
- Released in
- v0.17.0
themerunesstructuremetadatablockslayoutbardefinition-listeyebrowapirecipelumina
Terminology
"Eyebrow" was overloaded across a position, a geometry, and a rune. We split the word's three meanings so each axis is named for what it is:
eyebrow — a position only. The kicker slot above the heading, in the canonical order eyebrow → title → blurb → metadata → body. Positional, the traditional editorial meaning. It names no geometry and no rune.bar — a geometry. A horizontal flex row of fields with wrap + per- field align. It is position-neutral (an eyebrow kicker, a metadata strip, a footer row are all bars). bar replaces both split and chip-row — which were the same geometry differing only in wrap/alignment, and where "chip-row" became a misnomer once field shape went intrinsic (a bare field stays bare). The other layout primitive is definition-list (labeled pairs).bar — the rune. The eyebrow rune created on the SPEC-079 branch (unreleased) is renamed bar: a position-agnostic authoring handle for a two-aligned row. Where it lands is placement, not the rune's identity.
Problem
The SPEC-079 implementation shipped and works, but iterating on recipe, howto, faction, realm, and character surfaced four structural issues in RuneConfig.
1. Placement-concept proliferation. There are now ~6 fields that influence where a node lands or in what order:
order — sequence of canonical positionszoneHost + zoneHostPlacement — nest projected zones into a container, before/after its leading headerprojection.{hide,group,relocate} — post-hoc tree surgery by data-namecontentWrapper — wrap content childrensections — assign data-section roles- legacy
slots + structure — the pre-SPEC-079 assembly model
zoneHost/zoneHostPlacement were added to nest the metadata def-list into a split rune's content column (recipe), then to flip it above the header. But zoneHostPlacement is just ordering re-expressed in a second coordinate system, and projection.relocate already overlaps zoneHost. When two fields can accomplish the same move, theme authors don't know which is canonical and we maintain both.
2. zoneHost exists because of "hybrid" runes. Recipe, faction, etc. hand-assemble content + media in their transform and only project the metadata zone. The engine owns one position and must thread it into a structure it didn't build, anchored to a <header> it locates heuristically. That bridge is fragile (find-the-header, before/after) and can't express "put the metadata over the image."
3. chip vs plain rendering is decided inconsistently. The MetaField doc says "the shape around the value (chip vs plain text) comes from the layout primitive," but two contradictory rules exist:
- Legacy
structure (what api still uses): metaType present → .rf-badge. So method/auth are chips and path (no metaType) is a bare <code>. - SPEC-079 layouts:
chip-row makes everything a chip; split / definition-list make a chip only when sentimentMap is present.
The same field renders differently depending on layout (id is a chip in chip-row, plain in definition-list). api's correct look only survives because it is still on the legacy path.
4. Block definitions are not uniform. definition-list and chip-row take a flat fields: [], but eyebrow's split took { left: [], right: [] }. The structural left/right split bakes a presentation decision (which side a field hugs) into the data manifest.
Model
Two phases with clean ownership.
The transform builds the rune's semantic structure as addressable blocks. Recipe already does this:
media
content
preamble (eyebrow + title + blurb, as authored)
ingredients
steps
Block data-names are the addressing API. Containers (e.g. content) hold an ordered child list. The transform knows nothing about metadata projection or theme placement.
Two sub-steps:
(a) Define metadata blocks from the field manifest, each with a layout.
(b) Compose the final tree by naming, per container, the ordered child blocks — transform-built or metadata-projected:
media
content
metadata ← projected, placed here by the theme
preamble
ingredients
steps
tags ← projected (illustrative future block)
Because placement targets any container, a theme can put metadata into media to overlay it on the image — a capability zoneHost could not express.
Four orthogonal axes
The test of the design: these four concerns never overlap.
- Field shape — intrinsic to the field. Whether a value renders as a chip (
.rf-badge) or bare inline text is a property of the field, not the layout. Driven by the metaType taxonomy (below). A field renders the same way in every layout. - Block — grouping + layout. A named block is a flat list of fields plus a layout primitive (and optional per-field align). Plugin ships defaults, theme overrides.
- Layout — geometry only.
definition-list (dt/dd grid) and bar (horizontal flex row; wrap + per-field align). bar replaces both split and chip-row. Layouts arrange fields; they never decide a field's shape. - Placement / CSS — position. The
layout map decides which container a block sits in and its order among siblings; final visual nudges (e.g. right-aligning a field) live in CSS.
Contract
// PLUGIN: pure data manifest. `metaType` now also implies render shape.
metaFields?: Record<string, {
metaType?:
// chip-rendered (.rf-badge)
| 'status' | 'category' | 'tag'
// bare-rendered (inline, data-meta-type drives typography)
| 'id' | 'quantity' | 'temporal' | 'code';
label?: string;
sentimentMap?: Record<string, 'positive'|'negative'|'caution'|'neutral'>;
condition?: string;
tag?: string;
splitOn?: string;
transform?: 'duration' | 'uppercase' | 'capitalize';
// ── Rich field renderings (a field is one source value → one rendering,
// which may be multi-node). Each is a small, opt-in rendering swap. ──
// Link: the named modifier's value is the URL, the field's label (or
// value) is the link text. Bare (no chip). Source/repo links etc.
href?: string;
// Icon decoration: prefixes the value with an icon from
// `config.icons[group][value]` (engine renders the placeholder; lumina
// draws it via mask-image keyed on the value). The icon is part of THIS
// field — not a separate field. Covers hint type, etc.
icon?: { group: string };
// Rating: the value is a count; `total` names the modifier holding the
// max (default 5). Renders `total` marks, `value` of them filled.
rating?: { total?: string };
// Render shape (chip vs bare) is derived from metaType — no per-field
// override. If a real case ever needs one, revisit then.
}>;
// THEME-overridable: metadata fields grouped into named blocks + layout.
blocks?: Record<string, {
fields: (string | { field: string; align?: 'start' | 'end' })[];
layout: 'definition-list' | 'bar';
/** `bar` only: wrap onto multiple lines (chip-row behaviour). Default true. */
wrap?: boolean;
}>;
// THEME-overridable: the projected tree — ordered child block names per
// container. A key is a container's `data-name`, or the reserved key `root`
// for the rune's own top-level children (flat runes with no content/media
// wrapper place their blocks here). Projected (metadata) blocks appear ONLY
// where named — no canonical/default placement. Transform-built blocks the
// theme didn't name are appended in transform order (rune content is never
// dropped). Omitting `layout` renders the transform tree verbatim.
// `root` is reserved; `data-name="root"` is not a valid block name.
layout?: Record<string /* 'root' | container data-name */, string[] /* block names */>;
metaFields, sections, mediaSlots, editHints, modifiers, styles keep their roles. zones, zoneLayouts, contentSlots, order, zoneHost, zoneHostPlacement, and the legacy slots / structure are removed once all runes migrate. The split and chip-row layout primitives collapse into bar, and the unreleased eyebrow rune is renamed bar (the word eyebrow survives only as a position name).
Reverses the SPEC-079 statement that shape comes from the layout. Shape is intrinsic to the field:
- Chip-rendered (
buildChip → .rf-badge): status, category, tag. - Bare-rendered (
buildPlainValue → inline, data-meta-type): id, quantity, temporal, and a new code type (monospace inline, e.g. an API path). sentimentMap is orthogonal: it only adds colour to whichever shape the field already has.
Every layout iterates its fields and calls buildChip / buildPlainValue purely from the field — never from the layout. Consequence: the horizontal bar no longer forces every field into a chip; it "arranges fields (each in its own shape) in a row," which also removes the id-chip-vs-plain inconsistency. wrap: true (default) gives the old chip-row behaviour; wrap: false plus per-field align gives the old split/eyebrow bar.
Bar alignment (no left/right slots)
"Left/right" is alignment, and alignment is presentation. Project the bar as a flat field list; order + a per-field align: 'end' express the right-hand group; one shared rule does the work:
[data-zone-layout="bar"] [data-align="end"] { margin-left: auto; }
margin-left: auto in a flex row pushes the field and everything after it to the right edge — which covers the universal "left cluster / right cluster" bar. Three distinct alignment groups are an escape-hatch CSS job, not new config.
Case study — api (bar in the eyebrow position, mixed shapes)
api is visually a bar in the eyebrow position today ([method] [path] … [auth]) but is still on the legacy structure path. Target — note the block is named for its position (eyebrow) while its layout is the geometry (bar):
metaFields: {
method: { metaType: 'category', sentimentMap: { GET:'positive', POST:'neutral', DELETE:'negative', /*…*/ } }, // chip
path: { metaType: 'code' }, // bare <code>
auth: { metaType: 'status', condition: 'auth' }, // chip
}
blocks: {
eyebrow: { fields: ['method', 'path', { field: 'auth', align: 'end' }], layout: 'bar', wrap: false },
}
layout: { content: ['eyebrow', 'body'] }
method/auth are chips and path is bare because of their types, in any layout — no layout-specific or slot-specific logic. api is the recommended first prototype: tiny, no media/split complexity, already visually an eyebrow.
Case study — recipe (the hardest: split media + content)
media
content
metadata (def-list; theme places it above preamble)
preamble
ingredients
steps
blocks: { metadata: { fields: ['prepTime','cookTime','servings','difficulty'], layout: 'definition-list' } } and layout: { content: ['metadata','preamble','ingredients','steps'] }. "Above vs below the header" is just the block's position in the content list — no zoneHostPlacement. Faction/realm use the same with metadata after preamble; character keeps a floated portrait and places metadata after the title.
Case study — a flat rune (no content/media containers)
Many runes have no content/media wrapper — their blocks sit directly under the rune root. The reserved root key addresses that top level:
<article data-rune="work"> ← the rune root
eyebrow (bar: id + status)
title
metadata (projected here)
body
layout: { root: ['eyebrow', 'title', 'metadata', 'body'] }. No wrapper element is introduced; the projected metadata block is placed among the root's own children, and unnamed transform blocks append as usual. A rune may mix both — { root: [...], content: [...] } — when it has a container and top-level blocks.
Acceptance Criteria
RuneConfig exposes blocks and layout; zones, zoneLayouts, contentSlots, order, zoneHost, zoneHostPlacement are removed.- Field shape (chip vs bare) is decided from the field's
metaType, identically across definition-list and bar. No per-field override. - Every block in the rendered tree is placed by an explicit
layout entry; there is no implicit/default placement, even for simple runes. - A
code metaType renders monospace inline with no chip geometry. bar is the single horizontal layout (split and chip-row removed), with a wrap knob and per-field align; right-alignment is align: 'end' driving one shared [data-zone-layout="bar"] [data-align="end"] { margin-left: auto } rule (no left/right wrappers).- The unreleased
eyebrow rune is renamed bar; eyebrow remains only a position name in the canonical order. layout placement is sparse: unnamed transform blocks append in transform order; metadata blocks appear only when named; a block name absent from the tree is skipped.layout addresses both nested containers (by data-name) and the rune's top-level children (the reserved root key), so flat runes — with no content/media container — place projected blocks via root.- A theme can place a metadata block into the
media container (overlay). - api, recipe, howto, faction, realm, character render equivalently to today (modulo intended changes) through the new model.
- Block names are surfaced in the generated structure contracts as the stable addressing API.
Migration
- Split/media runes (recipe, howto, faction, realm, character) already build a named-block tree; they migrate by moving
zones+zoneLayouts → blocks and zoneHost(+placement)/order → layout. - The plan family (work, spec, bug, decision, milestone) leans on the dispatcher +
contentSlots + canonical order; converging them means their transforms build their own block tree. This is the bulk of the work. - Ship behind the new fields with the legacy
slots/structure and SPEC-079 paths intact; remove them once every rune is migrated. - api first as the isolated proof of the
bar layout + intrinsic-shape mechanism.
Resolved decisions
Eyebrow vs bar. eyebrow is a position only. The horizontal geometry is bar (one primitive; wrap + per-field align), absorbing both split and chip-row. The unreleased eyebrow rune is renamed bar. (See Terminology.)
Vocabulary: block. The addressable node in a rune's tree is a block. region (page layout) and zone (SPEC-079) are not reused for this.
No per-field shape override. Render shape is derived from metaType alone (chip types vs bare types). No as field ships now; revisit only if a real case demands a shape that contradicts the semantic type.
Explicit placement, no magic defaults. There is no canonical/default placement (e.g. "metadata after preamble"). Every projected block appears only where an explicit layout entry names it — including simple runes. A rune with no layout renders its transform tree verbatim (projected blocks don't appear). Within a container layout addresses, transform-built blocks the theme didn't name are appended in transform order, so the rune's own content is never silently dropped.
projection stays. projection (hide/group/relocate) is retained as the deep-surgery escape hatch alongside postTransform; it is not subsumed into layout, which is deliberately shallow (ordered block names per container). Revisit if layout ever proves it can absorb the real cases.
A field is one source → one rendering; no fan-out / fan-in. Rich renderings (href, icon, rating, splitOn) let a single field render to multiple DOM nodes, and decorations (sentiment, icon) enrich it — but the model deliberately has no "one value → multiple separate fields" (fan-out) or "multiple values → one element" (fan-in) primitive. The two genuinely-different needs go where they already belong: composing several values into one is transform data-shaping (derive a single modifier); placing one value in two spots is just two fields reading the same modifier. This keeps fields as the single projection unit and avoids two symmetric config mechanisms.
structure is fully replaceable. Its uses decompose into: metadata → blocks; data-driven chrome (icon/label/rating) → rich field renderings; pure decoration (e.g. codegroup window-dots) → CSS. So WORK-320 can remove the structure path entirely (no repeat/injection mechanism survives).
Open Questions
None outstanding — see Resolved decisions.
SPEC-081shipped
Declarative structure assembly
Make a rune's structural skeleton — the preamble header, the content / media columns, and any other theme-variable grouping — declarative and rune-owned, instead of hand-built imperatively in rune transform TypeScript. SPEC-080 made metadata assembly declarative (metaFields + blocks + layout); this completes the arc by moving the structural skeleton onto the same declarative footing, so a theme can reshape structure without running rune code.
Sibling to SPEC-082 (typed node data channel); both extend SPEC-080 and harden the rune output contract before third-party themes depend on its current shape. The two are independent and can land in either order. (This spec was originally drafted alongside the data-channel concern; that half is now SPEC-082.)
- Released in
- v0.18.0
themerunescontractstructureassemblytransformenginedeclarativegrouping
Background — why the two layers stay
The schema transform produces a semantic IR (this is a hint of type warning; this is the eyebrow; these are the metadata fields); the engine produces the presentational tree (BEM classes, wrappers, projected blocks). That IR is the stable contract, and four things depend on it being theme- and framework-agnostic:
- Framework fan-out. One IR renders through svelte / astro / nuxt / next / react / vue / eleventy. Shaping structure earlier would multiply it to themes × frameworks.
- Cross-page pipeline reads the pre-engine tree. Registry,
extractTitle, breadcrumbs run before BEM / structure mangling — entities are semantic, not presentational. - Static contracts.
contracts/structures.json is derivable because structure is declared in config, not built imperatively. - Editor +
refrakt inspect read the semantic tree / the deterministic config→structure mapping.
So this spec does not move structure-building into theme-hooked transform code (see Non-goals). It moves the imperative skeleton-building that currently lives in the rune transform onto the declarative config layer the engine already interprets.
Problem
The rune transform conflates two jobs:
- Content interpretation (must stay in the transform): deciding which authored child is the headline, splitting the body on
---, collecting list items as ingredients, pulling the eyebrow paragraph. This parses arbitrary authored Markdown; it cannot be config. - Structural assembly (should be declarative): wrapping headline + blurb in a
preamble <header>, building the content-column / media-column split, nesting the metadata def-list inside the content column. This is presentation hand-built in TypeScript.
Because the transform pre-builds part of the skeleton and the engine projects the rest into it, every redesign (slots → zones → zoneHost → blocks/layout) was an attempt to give the engine vocabulary to place things into a tree it did not author. Premature nesting also causes concrete bugs: the event rune wrapped headline + blurb in a preamble <header>, so layout could not address them individually — listing headline / blurb in the root did nothing and preamble silently appended last.
Direction
- The transform emits a flat bag of
data-name-labelled slots (headline, blurb, eyebrow, media, body, ingredients, …) — interpretation only, no wrappers. - A declarative grouping primitive composes those slots into the nested skeleton, theme-overridable.
- Guiding rule: labelling is semantics (transform); nesting / grouping is presentation (declarative).
Grouping is recursive layout
Rather than a separate groups map (which splits the tree definition across two places that must agree, and forces cross-references to nest a group inside a group), make layout itself a recursive, name-keyed tree. Today layout can only order children within a container that already exists; the change is to let an entry also create a container:
type LayoutEntry =
| string[] // order children; create no wrapper
| { tag?: string; children: string[]; attrs?: Record<string, string> };
layout?: Record<string, LayoutEntry>;
root is the entry point — the rune's own element, which already exists.- An entry with
tag creates a wrapper element; its key becomes the wrapper's data-name (→ .rf-{block}__{key} via the existing BEM pass, and a data-section via the existing sections map). - An entry without
tag (or a bare array) orders an existing container. - Each child name resolves, in order: (1) a
layout entry → recurse / create; (2) a blocks entry → project the metadata block; (3) a transform-emitted node with that data-name → place it; (4) otherwise skip. Transform nodes never referenced anywhere still append at the end (the "never drop content" rule), unless explicitly hidden.
The event preamble grouping — the source of the bug above — becomes declarative instead of hand-built in the schema:
layout: {
root: ['preamble', 'metadata', 'body', 'register'], // metadata, register = blocks; body = slot
preamble: { tag: 'header', children: ['headline', 'blurb'] },
}
The recipe / character content + media split, fully declarative:
layout: {
root: ['content', 'media'],
content: { tag: 'div', children: ['preamble', 'metadata', 'body'] },
preamble: { tag: 'header', children: ['name'] },
}
This subsumes projection.group (a tag entry is a group) and projection.relocate (you place a slot wherever you name it — no separate move op). What remains of projection is hide (explicit drop, since the default is append-not-drop) and its real role: reshaping a tree you don't own — a theme bending a third-party rune's output by data-name without the rune declaring layout. So the boundary is: layout is the rune / theme declaring its intended structure; projection is post-hoc surgery on someone else's structure. Both kept, boundary drawn correctly.
The machinery is partly prototyped: composeContainer already orders / injects by data-name, and projection.group already wraps data-name children into a new element — the work is generalising those into the recursive resolver above.
The computation boundary
Flattening the skeleton forces a sharper question about computation — and the right line is not "structure is declarative, everything computed stays in postTransform." It is:
- Semantic derivation → the rune transform. Anything that is a fact about the content, theme-invariant, belongs in the semantic IR.
- Presentation-dependent computation →
postTransform. Only things that genuinely need the assembled, theme-shaped tree — reading a resolved class, injecting a decorative element keyed off final structure.
Budget's grand / per-category / per-day totals are currently computed in the engine's postTransform. That is the wrong layer: the sum of the line items is the same number under every theme — it is data, not presentation. Three consequences:
- Cross-page invisibility. The registry / aggregate phases read the pre-engine tree. A total computed post-engine cannot be queried — a
collection of budgets cannot sort by total, aggregate cannot sum across them. Computed in the transform, the total is a first-class entity field. - It lives in the theme layer.
postTransform sits in the rune's engine config (coreConfig / a plugin's theme.runes); a presentation override should never be able to perturb a number that must be invariant. - No actual engine dependency. Budget's
postTransform reads data-currency / data-duration / data-show-per-day and the BudgetCategory children — but those are just the authored attributes and the schema's own parsed children, all available in the transform. It reads them from data-* only because it happens to run post-engine.
So the split is: the transform computes the numbers (grand, per-category, per-day) and emits them as semantic data — typed entries in the SPEC-082 fields bag (total: 4200, perDay: 600) and per-category totals on the category nodes. The theme renders and places them via blocks + layout (a total metaField → a block placed in a footer container), exactly like any other field; currency formatting is deterministic from authored data, so it rides a field transform, not imperative code. Budget's postTransform shrinks to nothing.
Caveat — semantic HTML grouping
<figure> / <figcaption>, <dl> / <dt> / <dd> and similar are genuine semantics and can stay wherever they read best in the transform; only theme-variable grouping needs to move to declarative layout.
Benefits
- Eliminates the "layout names don't match because they're buried in a wrapper" bug class (the
event bug). - A flatter pre-engine tree is easier for the cross-page pipeline (
extractTitle finds a top-level headline). - Structure becomes fully theme-overridable without a theme running rune code.
generateStructureContract can describe the whole skeleton, not just projected blocks.
Non-goals
- Do not collapse the two layers or let themes run code at the rune transform stage. That sacrifices the portable IR, the pre-engine pipeline reads, the static contracts, inspect, and the editor — rejected after analysis (see Background).
- Do not remove
projection / postTransform. projection remains the escape hatch for reshaping trees a theme does not own; postTransform remains for presentation-dependent computation only (see The computation boundary). - Do not revise the SPEC-080 field / block / layout vocabulary. This builds on it; it does not re-open it.
Open questions
- Cycle / diamond resolution. The recursive
layout resolver must place each transform node once and detect reference cycles (a → b → a) — decide warn-and-skip vs hard error. projection.group / relocate deprecation. They are subsumed by recursive layout; deprecate immediately, or keep as thin aliases for a release?- How far to push. Which runes' transforms become pure interpretation + flat emit, and which keep structural code (genuinely presentation-dependent cases)?
- Contract surface. What does
generateStructureContract emit for a declaratively-grouped skeleton (nested element entries, wrapper membership)?
Relationship to other specs
Builds on SPEC-080 (block-and-layout model); sibling to SPEC-082 (typed node data channel). SPEC-080 made metadata assembly declarative; this makes the structural skeleton declarative and rune-owned. Together with SPEC-082 they make the rune output contract something a third-party theme can build against with confidence.