# YAML spec — draft 0.21

> **Draft.** This specification is unfinished and changes between versions without notice. Files written to it
> may need changing later. The catalog and the example racks on portspec.dev are written in this format and are
> the best check of what works today: see https://portspec.dev/llms.txt.

*Status: fourteenth draft, 2026-11-15. Nothing here is implemented. It records the decisions taken so far and marks
what is still open. It replaces the statements in `portspec-plan.md` that say device and rack state is JSON.*

*Changes from 0.20: a rack, a rack's shelf, panel and ring, a device, a link and a scene each take a `title` and
a `description`: what the thing is called and what it is for, as words for people (9.5). They are never drawn
on the equipment. A scene's `title` was there already; the rest is new. A device keeps its `name`, the unit's
own name that `{name}` writes in its port labels, and is called by it when it has no title (9.1). A file's
aliases stand for at most 100,000 values (3.4).*

*Changes from 0.19: cables are drawn as physical cables, solved together in space, and that is the only way
they are drawn (10.4). A model's `depth` is the box cables keep clear of (5.6); a socket can say which way its
cable leaves (5.1); a cable type can be flat (10.1); a route can give the length a cable is drawn with, and a
point in `via`, a ring and a loose end how far they stand out from the face (9.3, 10, 11.4). Routes through
rings and brush panels are drawn; a cable that changes sides goes through its rack's brush panel when the route
names none, or round the side. Seen from the rear, devices line up by their fronts. Cables that cannot be laid
are an error, `cables-do-not-fit`. The built-in cable types are real cables, with measured jackets, a free
and a tightest bend radius (`bend-radius`, `min-bend-radius`) and weights (10.1).*

*Changes from 0.18: the server template draws towers and 5U chassis, dense drive bays, rear drive bays, a
front I/O panel, cards with more than one kind of port, and OCP and LOM plates; presets for towers and five
built for a purpose (6.3).*

*Changes from 0.17: the server template draws the library's server builder (6.3): six styles and their presets,
drive bays by size, access and orientation, a bezel, an I/O shield laid out by lists or by a layout, cards of any of
six cage types, upright cards, hot-swap or ATX supplies in a row or a stack. It takes the model's ports and
never invents one.*

*Also changed from 0.16: a port is drawn with the library's own drawing and a renderer draws nothing itself
(5.3); stops in a row or column (7.1); a sequence's shapes take their own size, and a pattern's gap may be below
0 (7.9); the library's service sockets are ports (5.3, 7.12).*

*Changes from 0.16, to make hand-made faces shorter: a face has `defaults`, the settings its containers, ports,
captions, patterns and parts start from (6.2); a cutout part writes its mask's keys among its own options, and a
fan's grille may be the mask itself (7.9, 7.6); a container part may hold ports, which each use names, and takes
the use's settings over its own (7.7).*

*Changes from 0.15: items take a `margin` and `align-self`, and containers padding on each side (3.6.2); an
`overlay` lays its entries over one another (3.6, 7.1); ports and parts take a caption on any side, and text may
run over several lines (7.11); a grid passes lights, rotation and label settings to its ports, and can turn
every other row (7.3); a port's printed label and lights outside the socket (7.5); light lists (7.6); a logo
drawn from a path, and a fan behind a grille cut in the face (7.6); assemblies: power supply, drive bay and fan
modules, handles, knockouts, rating plates and ground studs (7.10); content on a rack device's ears (6.7); a
body's corner radius and edge (6.6); cutouts gain sequences of shapes, single diagonal slots, arc slots, pointed
hexagons, column offsets, alternate row counts, phase, slot ends, clipped openings and round regions (7.9).
Where the library differs today is listed in 7.12.*

*Changes from 0.14: cutouts, patterns of repeated openings in a face, written as a `mask` with a `pattern` or as
a ready-made `cutout-<pattern>` part (7.9); the library's mains and power connectors are listed (5.3).*

*Changes from 0.13: a model may have a body, the silhouette of its chassis, for computers and other devices that
are not a rectangular panel (6.6); two aluminium materials (6.2); the library's new port, USB and power primitives
are listed (5.3).*

*Changes from 0.12: a port may take its drawing from either bank of the library's primitives, ports or blocks,
or from its socket artwork (5.3). The list of socket drawings is corrected to the library's names.*

*Changes from 0.11, after a third review: layout keeps content, requested and allocated sizes apart and decides
overflow in one place (3.6.4); a written cross size is exact and `stretch` does not override it (3.6.2); a
GitHub source is pinned by commit only (4.2); a bundle escapes braces and writes out every default that depends
on an id (4.8); a port type has at most one of connector and cage (5.2, 10.2); one device at most stands
directly on another (9.1); cable ends are lists of what they accept (10.1); a rack's opening is checked against
a device's body (9.1, 9.3).*

*Changes from 0.10, after a second review: containers are drawn in two stages, measure then allocate, with
grids and expanding spaces covered (3.6.4); a bundle is an export of the resolved result with its own marker,
shared-namespace renaming and an equivalence promise in place of byte equality (4.8); relative paths and pins
are defined for each kind of source (4.2); the default cable has a tie rule (10.3); shelves have physical rules
for pinned devices and for rack clearance (9.1); placeholders are filled at two defined moments (3.2); faces
and scenes refer to one container schema (7.2, 11.2); eight smaller corrections; conformance classes (21).*

*Changes from 0.9: stickers are a fourth kind of marking (9.4); the scene defaults of this spec are adopted, and
the library changes to match (3.6.5).*

*Changes from 0.8: one section defines containers, alignment and the steps by which they are drawn, with the
defaults and the differences from the library today (3.6); racks, shelves and shelving can be limited or
unlimited in size, and shelves take alignment settings (9.3); a cable to the hidden side goes round a rack side
or through a brush opening (11.4); cable types carry their drawing settings, so users can define new cables in
full (10.1); compatibility checks are defined but not run in the first implementation (10.3, 14); labels and
notes take the library's placement options (9.4).*

*Changes from 0.7, after review: import visibility has one rule (4.3, 4.4); ranges and inheritance are defined
by port id, and faces have explicit override rules (section 8); identity, bundles and images are defined (4.8);
devices can join ports inside themselves (5.5); cable ends, endpoints, occupancy and the default cable are
defined (10.1 to 10.3); models have a fixed mounting class and placement has a validity table (5.6, 9.1); the
automatic picture is an overview outside the id namespace, and scene rules are completed (11.4, 11.5, 12.3);
the server template and exact ranges are unambiguous (6.3, 6.4); a YAML profile and ordering rules (3.4);
unknown keys are errors, with `x-` extensions and a statement of what the version fixes (3.5); `collect` has
one selector shape (4.7); a conformance suite and a scope table (21, 22). Device-level `view` is removed.*

*Changes from 0.6: three top-level sections are removed. Port settings are written inside the device (9.2).
Sticky notes are written on the thing they are stuck to (9.4). The list of primitives is a published
reference, not a section (5.3). Section 3.3 says why each remaining section is at the top level.*

*Changes from 0.5: `*` anywhere in an import path (4.2); `collect` takes entries from imports, with regex
filters (4.7), and imports are no longer passed on (4.3); port types are a defined vocabulary with the drawing
on the type (5.2); primitives are listed (5.3); modules have a type and a drawing (5.4); three kinds of label
(9.4); faces have an exact form beside the two layout forms, with a coverage table (6.1, 6.4, 7.8, 20).*

*Changes from 0.4: imports are rewritten (section 4). They are an ordered list with optional unique names; a
bare reference takes the first match in order; a file is closed, so it never sees the file that imports it and
no file can change another. `include` is gone. Faces can be defined on their own and referenced (section 6),
which replaces attaching faces to an imported model.*

*Changes from 0.3: section 3.2 defines substitution in full: ranges, placeholders, where each is allowed and
what is not in the format.*

*Changes from 0.2: racks, devices, port settings and links are defined at the top level of a file, not inside a
scene (section 9). A scene is now only a picture: what to show, where it stands, how cables are drawn
(section 11). Showing a device in several scenes needs no special rule (section 12).*

*Changes from 0.1: imports are defined in full (section 4); face layout has a simple form and an extended form
with exact rules (section 7); scenes have the same two layout forms (section 11).*

## 1. What this is

One YAML format that describes hardware and how it is put together: device models, their faces, racks, placed
devices, the cables between them, and the scenes that show them. Users write it, the catalog is written in it,
and the rack builder saves it.

A compiler turns the YAML into the faceplate library's JSON scene document. That JSON is the library's internal
contract. Users never see it, there is no way to embed it, and it may change with the library as long as the
compiler changes with it.

The format has two goals, in this order:

1. Describe topology: what exists, where it sits, what connects to what.
2. Stay short and readable. A model implies everything it can; a file only states what differs.

## 2. Decisions this draft rests on

| Decision | Consequence |
| --- | --- |
| YAML is the only public format | Saved racks, downloads, exports and repository files are YAML |
| JSON stays inside the library | No raw-JSON escape hatch; the YAML must reach the library's whole authoring surface |
| A model has a technical part and a faces part | Either can be supplied separately; a model without faces draws as a generic device |
| Layout is flow first | Rows, columns and grids; anchored placement only as an exception |
| Every layout has a simple form and an extended form | The simple form is defined as an expansion into the extended one |
| A face may be defined in more than one way | Generated, layout (simple or full), exact, or template |
| Models can be referenced and overwritten | `extends`, with fixed merge rules |
| What describes one unit goes on the instance | Labels, fitted modules and plugs need no new model |
| Files can import other files | An ordered list; a bare reference takes the first match; names are optional and unique |
| A file is closed | It never sees the file that imports it, and no file can change another |
| Devices, racks and links are defined at the top level | They belong to no scene; a scene only shows them |
| Cable routing hints are part of the format | Kept apart from the fact that a cable exists, and kept per scene |

## 3. Document

```yaml
network: 1
imports: []     # other files, in order                     section 4
collect: {}     # entries taken from imports                4.7
bundle: {}      # marks a bundle; written by tools          4.8
types: {}       # port types                                5.2
models: {}      # device types                              sections 5–8
faces: {}       # faces defined on their own                6.5
modules: {}     # transceivers and adapters                 5.4
parts: {}       # reusable drawing parts                    7.7
cables: {}      # cable types                               10.1
racks: {}       # racks, shelves, tables                    9.3
devices: {}     # the units that exist                      9.1
links: {}       # cables                                    section 10
scenes: {}      # what is shown, and where                  sections 11–12
```

- `network: 1` is the format version and the only required key.
- `types`, `models`, `faces`, `modules`, `parts` and `cables` are **definitions**: used many times.
- `racks`, `devices` and `links` are **what exists**: each entry is one real thing, defined once.
- `scenes` are **pictures** of what exists. They define nothing.
- A file may hold any mix of the three. A catalog file has only definitions.
- An unknown section or key is an error. Extensions use keys that start with `x-` (3.5).

### 3.1 Ids and references

| Thing | Form | Example |
| --- | --- | --- |
| Model | `vendor/code`, or a bare word for a generic one | `mikrotik/crs326-24g-2s-plus-rm`, `nas` |
| Module, part, cable type, scene, rack, device, link | a bare word | `core`, `main`, `cat6` |
| Port of a device | `device/port` | `core/ether1` |
| Shelf or top of a rack | `rack/shelf` | `main/tray`, `main/top` |
| Something from a named import | `name:…` | `cat:mikrotik/crs326-24g-2s-plus-rm`, `site:core/ether1` |

A reference without a name is looked up in this file, then in its imports in order (4.4).

Bare words use lower-case letters, digits, `-`, `+` and `.`. Only model ids contain `/` of their own.

### 3.2 Substitution

Two things in the format produce text or ids from a pattern: **ranges** and **placeholders**. This section is
the whole of it. Anything not listed here is not substituted and is read as written.

#### Ranges

A range stands for a run of ids.

```text
ether1..24      # ether1, ether2, … ether24
port01..12      # port01, port02, … port12
sfp28-1..16     # sfp28-1 … sfp28-16
```

| Rule | |
| --- | --- |
| Form | a prefix, a first number, `..`, a last number. Nothing after the last number |
| Numbers | whole, not negative, first not greater than last |
| Padding | if the first number is written with leading zeros, every number is padded to that width |
| Size | at most 512 ids |
| One per id | `a1..2-b1..2` is an error |

| A range is allowed | Example |
| --- | --- |
| As a key in a model's `ports` | `ether1..24: { type: 1000base-t }` |
| As an entry in a face layout, and in a grid's `ports` | `- sfp1..2` |
| As a key in an exact face's `ports` | `sfp28-1..16: { x: 96, … }` |
| As a key in a device's `ports` | `ether20..23: { plug: true }` |
| In a `passthrough` entry | `[1..24, r1..24]` |
| In a server template's lists of ports | `network: [eth0..1]` |

A range is **not** allowed in a device, rack, link, scene, model, module, part or cable id, in the device part
of a port reference, in the `ends` of a link, or in any value other than those above. A key that overlaps
another key of the same map after expansion (`ether1..8` and `ether8` written side by side) is an error. A model
that extends another may name a single port of an inherited range; that is an override, not an overlap
(section 8).

#### Placeholders

A placeholder is a name in braces inside a text value. It is replaced once; the result is not read again.
Each placeholder is filled at one defined moment (the last column), which is what makes inherited and shared
faces come out right.

| Placeholder | Is | Available | Filled |
| --- | --- | --- | --- |
| `{n}` | the number at the end of this id: for `ether20..23` it is 20, 21, 22, 23. It is not the position in the range | in the value of a key written as a range | When that range is expanded, in the layer that wrote it |
| `{id}` | the full id after expansion (`ether7`) | in the value of a key written as a range | The same |
| `{name}` | the model's `name` | in a model's faces and in `parts` used there. In a device's `ports` it is the device's name | When the face is bound to the final model, after `extends`. A face inherited by a model named Office prints Office |
| `{vendor}` | the model's `vendor` | in a model's faces and in `parts` used there | The same |
| `{model}` | the model's id without the vendor (`crs326-24g-2s-plus-rm`) | in a model's faces and in `parts` used there | The same |
| `{device}` | the device's id | in a device's `ports` | On the device |

`{n}` takes two optional forms and no others:

| Written | Result for port 7 | Use |
| --- | --- | --- |
| `{n+1}`, `{n-1}` | 8, 6 | a panel numbered from 0 while the ids start at 1, or the reverse |
| `{n:02}` | 07 | fixed width |
| `{n-1:02}` | 06 | both |

| A placeholder is allowed in | |
| --- | --- |
| `label`, `group` and `native` of a port in a model | `label: "SFP+ {n}"`, `native: "Gi1/0/{n}"` |
| The text of a printed label on a port (9.4) | `label: "D-{n:02}"` |
| `text` and the short label of a part or block in a face | `- label: "{name}"` |
| `label` of a plug | `plug: { label: "spare {n}" }` |

Everywhere else braces are plain characters: ids, references, `model`, `extends`, `type`, paths, addresses,
hashes, colours, numbers, and every key.

#### Not in the format

- No variables of your own, no environment values, and nothing read from outside the file.
- No arithmetic beyond `+` and `-` a whole number on `{n}`. No conditions, no loops, no functions.
- No placeholder inside a placeholder, and no second pass over the result.
- No substitution that produces an id or a reference. Ranges are the only way to produce ids.

#### Rules

- An unknown placeholder, or one used where it is not available, is an error. It is never left in the output.
- Write `{{` and `}}` for a literal brace.
- A YAML value that starts with `{` must be quoted, or YAML reads it as a map: `label: "{n}"`.
- Order: within each map as written, ranges are expanded and `{n}` and `{id}` filled first. Layers of `extends`
  are merged afterwards, port by port (section 8). The model placeholders are filled last, when a face is bound
  to the model that finally uses it. A face in the `faces` section has no model until then.

### 3.3 Why each section exists

A section is at the top level only when its entries are used from more than one place, or stand on their own.
Anything that belongs to one thing is written inside that thing.

| Section | Top level because | Could it be nested? |
| --- | --- | --- |
| `imports`, `collect`, `bundle` | They are about the file | No |
| `types` | Every model's ports name them | No |
| `models` | Many devices use one model | No |
| `faces` | A face can be shared, and can live in a different file from its model | Also allowed inside a model |
| `modules` | Fitted on many ports | No |
| `parts` | Used in many faces | No |
| `cables` | Named by many links | No |
| `racks` | Many devices name one rack | No |
| `devices` | Links and scenes name them | No |
| `links` | A link joins two devices, so it belongs to neither | No |
| `scenes` | A scene shows many things | No |

Written inside the thing they belong to, and not sections: a device's port settings, labels and notes (9.2,
9.4); a rack's shelves, panels and rings (9.3); a scene's layout, routes, notes and stickers (section 11); a
thing's title and description (9.5). The list of primitives is a published reference, not a section (5.3).

### 3.4 YAML profile

A file is read the same way by every tool. These rules are part of the format.

| Rule | |
| --- | --- |
| Version | YAML 1.2, core schema, UTF-8 |
| Documents | exactly one per file |
| Keys | text. A key that YAML would read as a number, such as a port named `1`, is taken as the text written |
| Duplicate keys | an error, including keys that become equal after range expansion within one map (3.2) |
| Ids and references | wherever the format expects an id or a reference, the scalar is taken as the text written, quoted or not |
| Versions | must be quoted: `version: "2026.11"`. An unquoted version is an error, because `2026.10` would be read as the number 2026.1 |
| Anchors and aliases | allowed; expanded before anything else. The merge key `<<` is not supported |
| Tags | custom tags are an error |
| Size | at most 16 MiB per file and 64 levels of nesting. Its aliases stand for at most 100,000 values, each value counted every time an alias repeats it: a few anchors that hold aliases of one another would otherwise stand for millions |

**Order.** The order of keys in a map never changes the result. Where order matters, the format uses a list or
an explicit field:

| Where order matters | How it is written |
| --- | --- |
| Imports, and so first match | `imports` is a list |
| Entries in a layout | `layout` and `children` are lists |
| Which block is drawn over which | `blocks` in an exact face is a list |
| Devices side by side on a shelf | `x`, or `order`; then by id (9.1) |
| Shelves in a shelving unit | `level` on each shelf (9.3) |
| The automatic overview | by id (11.5) |

Where this section says "by id", it means alphabetical order of the id, compared character by character.

### 3.5 Versions and extensions

**What `network: 1` fixes.** A file marked `network: 1` is read by these, and none of them changes without a
new number: the grammar; every default in this document; the resolution and merge rules; the checks and whether
each is an error or a notice; the built-in rack types, cable types and generic models; and the list of
primitives with their default sizes.

| Change | Allowed within `network: 1` |
| --- | --- |
| A new optional key, a new primitive, a new built-in, a new notice | Yes, when no existing valid file draws or checks differently |
| A changed default, default size, merge rule, or a notice that becomes an error | No; that is `network: 2` |
| A new or changed catalog model or type | Not a format change. The catalog has its own version, which imports pin |

**Unknown keys are errors.** A top-level section or a key the format does not define is an error, with a
suggestion when it is close to a known one. `devcies:` is reported, not ignored.

**Extensions.** A key that starts with `x-` is allowed wherever the format defines the keys: at the top level
and inside any entry. Tools keep it on save and do not interpret it, unless it is their own. In a map whose
keys are your own ids (`devices`, `models`, a model's `ports`, and the like) every key is an id: `devices.x-core`
is an ordinary device called `x-core`.

```yaml
x-inventory:
  core: { serial: HC1234567 }
devices:
  core: { model: office/core, x-asset-tag: A-0042 }
```

**Reserved sections.** The names in section 16 are reserved for later parts of the format. A tool that does not
implement one keeps it on save and must say so: its report states "not checked: `vlans`" and never "valid".
A tool may claim a file is valid only for the sections it checked.

### 3.6 Containers and alignment

Everything that arranges other things is a **container**, and every container follows the rules of this
section. A face arranges ports and parts; a shelf arranges devices; a scene arranges racks. They use the same
words with the same meaning, and they are drawn by the same steps.

The spec and the faceplate library are kept in step on this section: where they differ today, 3.6.5 says so
and says which one changes.

#### 3.6.1 The containers

| Container | Arranges | Direction | Where it is written |
| --- | --- | --- | --- |
| Face row, face column | Ports, parts, nested containers | As written | A face's `layout` (section 7) |
| Face grid | The same, in equal cells | Rows of cells | 7.3 |
| Face overlay | The same, laid over one another | None: every entry has the whole box | `overlay` in a face (7.1) |
| Shelf | Devices standing on it | Row, left to right | A rack's `shelves`, a rack of type `shelf`, a rack's `top` (9.3) |
| Stack | Devices standing on a device | Column, upward | `on` on a device (9.1) |
| Shelving | Shelves | Column | A rack of type `shelving` (9.3) |
| Rack with rails | Devices, shelves and panels at rack units | Fixed positions, not flow | `u` (9.1) |
| Scene group | Racks, free-standing devices, scenes, nested groups | As written | A scene's `layout` (section 11) |
| Scene grid | The same, in equal cells | Rows of cells | 11.1 |

A rack with rails is the one container that does not flow: each thing sits at the unit it names.

#### 3.6.2 The settings

| Setting | Meaning | Values |
| --- | --- | --- |
| `gap` | The least distance between neighbours along the direction | millimetres |
| `padding` | Space kept clear inside the container's edges | millimetres, `{ x, y }`, or `{ top, right, bottom, left }` |
| `justify` | Where the items go along the direction when there is space left | `start`, `end`, `center`, `space-between` |
| `align` | Where each item goes across the direction | `start`, `center`, `end`, `stretch` |
| `width`, `height` | The container's size (3.6.3) | millimetres, `grow`, or `fill` |
| `grow` | The share of its parent's spare space a nested container takes | a number; 0 is none |
| `fit` | `contain`: scale the contents to the container. Faces only; hardware never scales | `contain` |
| `position` | Take one item out of the flow and pin it to the container (7.4) | edges and offsets |
| `order` | An item's turn, where the items are not written as a list | a number |
| `margin` | Space kept clear around one item, outside it. Set on the item | millimetres, or `{ top, right, bottom, left }` |
| `align-self` | Where this one item goes across the direction, in place of its container's `align`. Set on the item | `start`, `center`, `end` |

`padding` and `margin` are 0 or more. In the map forms a side that is not written is 0, and `{ x, y }` cannot be
mixed with the names of sides. `margin` and `align-self` are faces only for now: shelves and scenes do not take
them.

| `justify` | Result |
| --- | --- |
| `start` | Items packed at the start, `gap` apart; the space left is at the end |
| `end` | Packed at the end |
| `center` | Packed in the middle; the space left is split equally before and after |
| `space-between` | First item at the start edge, last at the end edge, the space left shared equally between neighbours. One item alone goes to the start |

| `align` | Result |
| --- | --- |
| `start` | Against the top of a row, or the left of a column |
| `center` | Centred across |
| `end` | Against the bottom of a row, or the right of a column. In a row of hardware this stands everything on one line |
| `stretch` | A nested container with no size written across is widened to the full cross size. A container with a number written across keeps that number exactly. A port, part or device is never stretched. Whatever is not stretched is centred |

#### 3.6.3 Limited and unlimited size

A container's size along each axis is written one of three ways.

| Written | Kind | The container is | If the contents need more |
| --- | --- | --- | --- |
| a number | Limited | that size | an error |
| `grow` | Unlimited | as large as its contents and padding need | it grows |
| `fill` | Given | what its parent allocates to it (3.6.4, stage 2) | an error |

A number together with `grow: 1` (the share setting of 3.6.2) is a **starting size** along the parent's
direction: the container is at least that large and takes its share of the parent's spare space on top. In
every other case a number is exact, and nothing, including `align: stretch`, changes it.

| Thing | Axis | Written as | Default |
| --- | --- | --- | --- |
| A rack with rails | height | `units: 12` or `units: grow` | required |
| A rack shelf | width | `width` | `fill`: the rack's opening |
| A rack of type `shelf` | width | `width` | `grow` |
| A `shelving` or `cabinet` | width, height | `width`, `height` | `grow` |
| A rack's `top` | width | not written | the rack's width |
| A face | width, height | the model's size | fixed by the model |
| A nested face container | either | `width`, `height` | `grow` |
| A scene, a scene group | either | `size`, `width`, `height` | `grow` |

A rack with `units: grow` is as tall as it needs to be (9.1 says what counts). Units are still counted from
the bottom, so adding a device at the top never moves the ones below.

#### 3.6.4 How a container is drawn

A container is drawn in two stages. The first works from the leaves up and finds what each thing needs. The
second works from the root down and gives each thing its place. Three values are kept apart throughout:

| Value | Is |
| --- | --- |
| **Content size** | What a container's contents need, without its own padding |
| **Requested size** | The number written for an axis, if one was written. Otherwise there is none |
| **Allocated size** | The outer size the container is finally given |

**Stage 1: measure, from the inside out.** Nothing is rejected in this stage.

Each item has a **natural size**, its outer size when nothing constrains it:

| Item | Natural size |
| --- | --- |
| A port, a part | The size of its drawing, or the size written on it |
| A device | Its model's size, with everything stacked on it |
| A space | Its `space` along the direction, nothing across |
| A row or column | Its content size plus its padding. Content size along the direction: the sum of what its flow items ask for, plus one `gap` between each pair of neighbours. Across: the largest that a flow item asks for |
| An overlay | Its content size plus its padding. Content size on each axis: the largest that a flow item asks for |
| A grid | Its content size plus its padding. Content width: columns × cell width + (columns − 1) × `gap`. Content height: rows × cell height + (rows − 1) × `gap`. Cell width is the largest, over its items, of what the item asks for, less the gaps it spans, divided by the columns it spans; cell height likewise |

What an item **asks for** on an axis is its requested size if it has one, and its natural size if it does not,
plus its `margin` on both sides of that axis. An item written `grow` or `fill` on an axis has no requested size
there. A margin is always outside the item: the item itself is placed inside its margin, at its own size.

A pinned item (`position`) is left out of its container's content size, with one exception for hardware on a
shelf (9.1). A pinned item takes no `margin`: its offsets say the same, and both together are an error.

So eight 10 by 10 items in a grid of 4 columns and 2 rows with a gap of 2 have a content size of 46 by 22.

**Stage 2: allocate and place, from the outside in.**

1. **Allocated size.** The root is allocated its fixed size (a face) or what it asks for (a scene). Any other
   container is allocated its size by its parent, in steps 4 and 5.
2. **Inner size.** The allocated size less the padding.
3. **Space left** along the direction:

   ```text
   inner length − the sum of what the flow items ask for − the gaps between them
   ```

   A container 100 wide holding 40 of content has 60 left. A container with 40 of content and 10 of padding on
   each side has a natural size of 60, is allocated 60, has an inner length of 40, and has nothing left.
4. **Too small.** If the space left is negative, on either axis, the contents do not fit. With `fit: contain`
   on a face container, the contents are scaled down by the same factor on both axes until they do, and the
   space left is worked out again. Without it, this is an error. This is the only place overflow is decided.
5. **Along the direction.** If any flow item has a share (`grow` above 0, or `fill` on this axis, which counts
   as a share of 1), the space left is divided among those items in proportion to their shares and added to
   what they ask for; nothing remains for `justify`. Only nested containers and spaces may have a share.
   `{ space: 0, grow: 1 }`, written `grow` in the short form, is the usual one. A port, a part and a device
   never take a share. If no item has a share, each item is allocated what it asks for and the items are
   placed by `justify`.
6. **Across the direction.** An item with a requested size across keeps exactly that size. A nested container
   with none gets the full inner cross size when it is written `fill` across or when `align` is `stretch`.
   Everything else is allocated what it asks for. Whatever is narrower than the inner cross size is placed by
   its own `align-self` if it has one, and by the container's `align` if not; with `stretch`, such items are
   centred.
7. **Grids.** The inner box is divided into equal cells after taking `gap` between rows and between columns.
   Each item gets its cell, or the cells it spans with the gaps between them, as its region. A nested
   container with no requested size fills the region. Other items keep what they ask for and are placed in the
   region by `justify` (across) and `align` (down). An item that asks for more than its region is too small in
   the sense of step 4.
8. **Overlays.** Every flow item of an overlay is given the whole inner box as its region, and is placed in it
   as in a grid cell: by `justify` across and by `align` (or its own `align-self`) down. A nested container
   written `fill` on an axis takes the whole inner size on that axis. `space-between` is not allowed on an
   overlay. Items are drawn in list order, so a later one is over an earlier one. Spaces mean nothing in an
   overlay and are an error there.
9. **Pinned items.** Each is placed by its `position` against the container's allocated box. Two opposite
   edges stretch a pinned container that has no requested size on that axis.
10. **Order.** Flow items are taken in list order, or by `order` and then by id where they are not a list.
11. **Rounding.** Positions are rounded to 0.01 mm at the end, not along the way.

#### 3.6.5 Defaults, and where the library differs today

| Container | `gap` | `padding` | `justify` | `align` |
| --- | --- | --- | --- | --- |
| Face, the root | 2 | `{ x: 12, y: 4 }` | `start` | `center` |
| Face row, column, grid | 2 | 0 | `start` | `center` |
| Shelf | 12 | `{ x: 8, y: 0 }` | `start` | `end` |
| Stack | 0 | 0 | `start` | `center` |
| Shelving | 24 | 0 | `start` | `stretch` |
| Scene group | 60 | 0; 35 at the root | `start` | `end` |

| Point | This spec | The library today | To be the same |
| --- | --- | --- | --- |
| Face and shelf defaults | As above | The same | Nothing to do |
| `padding` and `fill` on a face container | Yes | Yes | Nothing to do |
| `margin`, `align-self`, padding by side | Yes, on faces | Yes | Nothing to do |
| Overlay | `overlay` | `direction: stack` | Compiler maps; the spec keeps "stack" for devices standing on a device |
| Scene group `gap` | 60 | 20 | Decided 2026-11-10: the library adopts 60 |
| Scene group `align` | `end` | `center` | Decided 2026-11-10: the library adopts `end` |
| Root scene `padding` | 35 | 0 | Decided 2026-11-10: the library adopts 35 |
| `units: grow` on a rack | Yes | Units are required | Library adds it |
| `width: grow` and `fill` as words | Yes | Omitting `width` means one or the other by context | Compiler maps; no library change |
| Shelving as one rack with levels | Yes | A column of shelves inside an enclosure | Compiler builds it |
| Settings on a stack | Defaults only | `gap`, `justify`, `align`, `padding` on a stack | Add to the spec when needed |
| More `justify` values, such as equal space around every item | No | No | Add to both if wanted |

## 4. Imports

### 4.1 Writing an import

`imports` is a list, because its order matters. An entry is a source, with or without a name.

```yaml
imports:
  - ./site-models.yaml
  - ./models/*.yaml
  - { name: cat,  catalog: portspec, version: "2026.11" }
  - { name: lab,  url: https://example.com/lab.network.yaml, hash: sha256-… }
  - { name: repo, github: acme/network, path: racks/hq.network.yaml, ref: 4f2c1d9a8b3e6c7d0f1a2b3c4d5e6f7a8b9c0d1e }
```

- A name is optional. Two imports may not have the same name. An import without a name has none: there is no
  default name taken from the file.
- A name is a bare word (3.1) and may not be a name the format uses for a section.

### 4.2 Where a file may come from

| Source | Written as | Pin required |
| --- | --- | --- |
| A file beside this one | a relative path, which may hold `*` | no |
| The portspec catalog | `{ catalog: portspec, version }` | the version |
| A portspec workspace or short link | `{ portspec: workspace/slug, version }` | the version |
| A GitHub repository | `{ github: owner/repo, path, ref }` | `ref`, which must be a full commit id. A tag or a branch is an error, because it can move |
| Any HTTPS address | `{ url, hash }` | the hash |

Not allowed: plain HTTP, absolute local paths, a relative path that leaves the directory of the root file, and
`data:` addresses outside a bundle (4.8).

**Relative paths inside an imported file.** A file may import or name images by relative path. Where that
path leads depends on where the file itself came from, and the pin is inherited where the source cannot change.

| The file came from | A relative path in it means | Its pin |
| --- | --- | --- |
| Local disk | A file beside it | none needed |
| A GitHub repository | The same repository at the same `ref` | inherited: the `ref` |
| The portspec catalog | The same catalog at the same version | inherited: the version |
| A portspec workspace | The same workspace at the same version | inherited: the version |
| A plain HTTPS address | The address relative to the file's own | not inherited: the entry must carry its own `hash`, written `{ path: ./types.yaml, hash: sha256-… }` |

Inheriting a pin is safe only because these pins cannot move: a commit id names one tree for ever, and a
published catalog or workspace version is never changed after it is published. That is why a GitHub `ref` may
not be a tag: the root file's bytes could stay the same while a file it imports by relative path changed.

A relative path never leaves its source: not above the repository root, the catalog root, or the directory of
the first file fetched from an HTTPS host.

**`*` in a path.** A `*` stands for any run of characters other than `/`. It may appear anywhere in a file name
or a directory name, and more than once: `./models/*.yaml`, `./catalog/*/crs3*-*.yaml`.

- The matches are taken in alphabetical order of their whole relative path, compared character by character,
  so the order is the same on every machine.
- Each match is one import, in that order, at that place in the list.
- A name on the entry is shared by all its matches: `{ name: mt, path: ./catalog/mikrotik/*.yaml }` makes
  `mt:id` search those files in their order.
- A pattern that matches nothing is an error.
- `*` is allowed in local paths, in the `path` of a `github` source, and in relative paths inside a file from
  a repository, the catalog or a workspace. It is not allowed for plain HTTPS, where a folder cannot be listed.

### 4.3 What a file offers

A file offers its own entries in every section: `types`, `models`, `faces`, `modules`, `parts`, `cables`,
`racks`, `devices`, `links` and `scenes`. Its own entries include the ones it collects (4.7). That is all.

Imports are not passed on. If A imports B and B imports C, A sees C's entries only if B collects them.

### 4.4 Resolving a reference

A reference is looked up among entries of the kind it asks for: `model:` looks only at models, a link end only
at devices and their ports, a scene layout at racks, devices and scenes.

| Written | Looked up in |
| --- | --- |
| `name:id` | only what the import called `name` offers (4.3) |
| `id` | 1. this file's own entries; 2. what each import of this file offers, in the order written, named or not; 3. the built-ins |

- The first match is used. A later match is not an error.
- If nothing matches, it is an error that lists the places searched.
- When a bare reference matches in more than one place, the compiler reports which one it took, as a notice.
  Write the name to make the choice explicit.
- Two entries of one kind with the same id **in one file** are an error.

**Model aliases.** In each place searched, ids are tried before aliases: a model whose id matches wins over one
whose alias matches. If no id matches there, an alias may. Two models in one file claiming the same alias are
an error. Aliases work in qualified references too (`cat:EDGE-24G`).

### 4.5 A file is closed

A reference written inside a file is resolved from that file only: its own entries, its own imports, the
built-ins. It never sees the file that imports it, or that file's other imports.

```text
root.yaml       imports a.yaml, b.yaml       defines model  office/core
  a.yaml        imports c.yaml               uses  model: office/core      → error: a.yaml cannot see root.yaml
  b.yaml                                     defines model  nas
    c.yaml                                   uses  model: nas              → error: c.yaml cannot see b.yaml
```

Consequences:

- **A file means the same thing wherever it is imported.** It can be checked on its own. What its hash does
  and does not cover is in 4.6.
- **No file can change another.** An importing file cannot add to, replace or remove anything in a file it
  imports. In particular it cannot give an imported model new faces, set port labels on an imported device, or
  re-mount an imported device. Port settings, labels and notes are written inside the device, rack or link
  they belong to, so there is nowhere to write them for an imported one.
- **Defining an id that an import also has does not change the import.** References in this file now find the
  local entry first; references inside the imported file still find their own.
- **To change something imported, make your own.** A new model that `extends` the imported one (section 8) is a
  new entry in this file.
- **Inherited and collected entries keep their scope.** Whatever a reference meant in the file that wrote it,
  it still means after `extends` or `collect` carries it into another file.

What an importing file *may* do with imported things, because none of it changes them:

| Allowed | Example |
| --- | --- |
| Use an imported definition | `model: cat:mikrotik/crs326-24g-2s-plus-rm`, `extends:`, `module:`, `cable:` |
| Show an imported rack, device or scene in a scene | `layout: [site:rack-a]` |
| Link a port of an imported device | `ends: [core/sfp1, site:edge/sfp1]` |
| Mount its own device in an imported rack | `in: site:rack-a` |
| Give an imported link a route in its own scene | `routes: { site:riser: { … } }` |

The whole surface is still checked together: a port takes one link and a rack unit takes one device, counted
across every file.

### 4.6 Loading

- The loader fetches, checks pins, checks each file on its own, and builds the surface. The compiler and the
  renderer see only the result, and never fetch.
- A remote import without its pin is an error. A fetched file whose hash differs is an error.
- **Cycles are not permitted.** A file that reaches itself through any chain of imports is an error, and the
  message lists the chain.
- The same file reached twice by different paths is loaded once.
- Depth is limited to 8 and the number of files to 2,048.
- On the hosted service: a public scene may not import a private file, unless it is published as a bundle; and
  remote sources are limited to an allowed list of hosts and a size limit.

**What a hash covers.** A file's hash covers its own bytes. Its meaning also depends on what it imports and on
the images it names. Remote imports and remote images are pinned, so they cannot change underneath it. Local
files beside it are not pinned and can. Only a bundle (4.8) has one hash that covers everything.

### 4.7 Collecting entries from imports

A section can take entries from imports and make them its own, without listing them. This is how a catalog file
offers every model of every file it imports.

```yaml
imports:
  - { name: mt, path: ./catalog/mikrotik/*.yaml }
  - { name: ub, path: ./catalog/ubiquiti/*.yaml }
  - ./generic.yaml

collect:
  types:   all
  models:  { from: [mt, ub], where: { role: "^switch$" }, where-not: { id: "-legacy$" } }
  modules: { from: all }
```

`collect` has one key per section, and each has one selector.

| Key | Meaning | Default |
| --- | --- | --- |
| `from` | `all`, or a list of import names | `all` |
| `where` | A map from a field to a regular expression. An entry passes when every field matches | pass |
| `where-not` | The same map. An entry passes when no field in it matches | pass |

`all` on its own is short for `{ from: all }`. There is no other short form.

| Rule | |
| --- | --- |
| Fields | `id`, or any field of the entry whose value is text or a number. The value tested is the one the entry has after its own `extends` is applied. A default that nobody wrote is not a field and does not match |
| Match | anywhere in the value; use `^` and `$` to match the whole value |
| Syntax | RE2: no back-references and no look-around, so a match takes bounded time |
| Case | sensitive; start the expression with `(?i)` for the other |
| Order | Entries are taken in import order, then by id. `from: [ub, mt]` does not change that order |

**What collecting does.**

- A collected entry becomes an entry of this file, under the same id. Files that import this one see it.
- It is the **same entry**, not a copy (4.8). The references inside it are still resolved from the file that
  wrote it (4.5).
- An entry this file writes itself comes before a collected one with the same id.
- When two imports offer the same id, the first in import order is collected and the compiler reports it as a
  notice.
- Only whole entries are collected. A filter cannot take part of a model.
- An unnamed import can be collected only through `all`. Give it a name to select it.

### 4.8 Identity, bundles and images

**Identity.** An entry is one thing however many names reach it. Its identity is the file that wrote it, its
section and its id. `east:core` and `west:core` are two devices. A device that file B collects from file C is
one device, whether it is reached as `b:core` or `c:core`. Checks that count (one link per port, one device per
rack unit, shown once per scene) count identities, not names.

**Images.** An image is written one way everywhere: as a path, or as a map.

```text
image: ./acme.svg
image: { src: ./crs326-front.png, crop: { x: 112, y: 290, width: 1778, height: 178 }, fit: fill }
image: { src: https://example.com/logo.svg, hash: sha256-… }
```

| Field | Meaning | Default |
| --- | --- | --- |
| `src` | A path or an HTTPS address. A path is resolved from the file that wrote it, by the rules of 4.2. Required | |
| `hash` | Content hash. Required where 4.2 requires a pin | none |
| `crop` | The part of the image to use, in the image's own pixels | all of it |
| `fit` | `contain`, `cover` or `fill` | `contain` for logos and labels, `fill` otherwise |

Images are fetched by the loader with the files, never by the renderer.

**Bundles.** A bundle is a root file's whole meaning written as one file that needs nothing else. It is an
export of the **resolved result**, not the source files glued together.

A bundle is marked by a top-level `bundle` section. Its presence changes three rules: `imports` and `collect`
are not allowed; an image `src` may be a `data:` address or a path inside the package; and the overview is
taken from the bundle section. A file without `bundle` may not use `data:` addresses.

```yaml
network: 1
bundle:
  of: racks/hq.network.yaml
  overview: [main, wall, ap]
```

What a bundle writes down, so that nothing depends on a rule that renaming or flattening would change:

| Before | In the bundle |
| --- | --- |
| A link with no `cable` | The cable that was chosen, written out |
| Devices on a shelf ordered by id | Each given the `order` it had |
| Text with placeholders | The text as it was filled in |
| The overview shows only the root file's own hardware | `bundle.overview` lists exactly those racks and devices, in their order |
| Model aliases, `extends`, face references | The final model, written whole |
| A reference that meant something by its file's scope | The id of the entry it meant |
| A default that comes from an id, such as a module's or a cable type's `name`, or a device's name in a list | The value it had, written out, so a renamed id does not change what is shown |

The rule behind the table: **anything whose value depended on an id, on a scope or on order is written out as
the value it had.** The rows are examples, not the whole list.

**Braces.** Text in a bundle has already been filled in. It is written with every literal brace doubled, so
`{{name}}` in a source file, which shows as `{name}`, is written `{{name}}` again and shows the same. A bundle
therefore holds no placeholders, only doubled braces.

**Ids in a bundle.**

1. Racks, devices and scenes share one set of names, because a layout names all three (12.4). Every other
   section has its own set.
2. The root file's own entries take their ids first.
3. Every other entry, in the order its file was loaded and then by section and id, takes its own id if that
   name is free in its set.
4. Otherwise it takes `<import>.<id>`, where `<import>` is the name of the import that leads to its file from
   the root, or `i<N>` for the Nth unnamed import; a longer chain joins the names with `.`, shortest unique
   chain first. `east:core` and `west:core` become `east.core` and `west.core`.
5. If that name is taken too, it takes the same name with `.2`, then `.3`, and so on, until one is free.
6. Every reference is rewritten to the new id.

**What is promised.** A bundle draws the same pictures and resolves to the same surface as the files it came
from: the same devices, ports, positions, links, cables and text. It is not promised to be the same bytes from
one tool to another. Two bundles are compared by their resolved surface.

**Two bundle forms.**

| Form | What it is | Use |
| --- | --- | --- |
| Single file | One YAML file; each image's `src` is a `data:` address holding the image | Short links, sharing, anything up to the size limit |
| Package | A ZIP holding `bundle.network.yaml` and `assets/<hash>.<ext>`; each `src` is that relative path | Large racks with photographs |

## 5. Models: the technical part

A model is a type of device. The catalog is a set of models, one file per model at the path that is its id
(`catalog/mikrotik/crs326-24g-2s-plus-rm.yaml`), gathered by an index file that imports them with `*` and collects them (4.7).

```yaml
models:
  acme/edge-24:
    name: Edge 24
    vendor: Acme
    role: switch
    aliases: [EDGE-24G, acme/edge24]
    size: { units: 1, depth: 180 }
    weight: 2.4
    power: { max: 45, inlets: 1 }
    ports:
      ether1..24: { type: 1000base-t, poe: at }
      sfp1..2:    { type: 10gbase-x-sfpp, label: "SFP+ {n}" }
      console:    { type: rj45, role: console }
      psu:        { type: iec-c14, role: power, side: rear }
    source: { url: https://example.com/edge-24, checked: 2026-11-09, licence: own-render }
```

| Field | Meaning |
| --- | --- |
| `name` | The name people use |
| `vendor` | Display name of the maker |
| `role` | `router`, `switch`, `ap`, `server`, `nas`, `modem`, `panel`, `outlet`, `pdu`, `ups`, `host`, `other` |
| `aliases` | Other ids and spellings that resolve to this model (4.4) |
| `mount` | How it is mounted: `19in`, `10in` or `none` (5.6) |
| `size` | `units` for rack gear; `width`, `height`, `depth` in millimetres otherwise (5.6) |
| `weight` | Kilograms |
| `power` | `max` in watts, `inlets`, optional `poe-budget` in watts |
| `ports` | See 5.1 |
| `passthrough` | Ports joined inside the device (5.5) |
| `source` | Where the data came from, when it was checked, and the licence of any image |

A model must have at least a `role` or a `ports` map. Everything else has a default.

### 5.1 Ports

A port is anything a cable plugs into: network ports, console, USB and power.

| Field | Meaning |
| --- | --- |
| `type` | A port type (5.2). Required |
| `speed` | Only when it differs from the type's |
| `poe` | `af`, `at`, `bt`, `passive`; add `-in` for a powered port |
| `role` | `console`, `management`, `power`, `uplink`. Omitted for an ordinary data port |
| `side` | `front` (default) or `rear` |
| `label` | The manufacturer's label: the text printed on the panel. Default: the number at the end of the id |
| `native` | The name the device's own software uses, when it cannot be the id: `native: "Gi1/0/{n}"` |
| `group` | A caption for a block of ports ("1G Ethernet") |
| `primitive` | The drawing to use when the type's is wrong: a primitive from either bank or socket artwork (5.3), or a part id |
| `cable-direction` | Which way a cable leaves the socket: `[x, y, z]`, right, down and out of the face (10.4). Not all 0, and `z` not below 0. Default `[0, 0, 1]`, straight out |
| `cable-offset` | How far in front of the face the plug's opening sits, millimetres (10.4). Default 0 |

- **Ids.** A port id is a bare word (3.1), unique within a model, front and rear together. Use the device's own
  name when it fits (`ether1`, `sfp-sfpplus1`). When it does not, as with `Gi1/0/1`, choose an id and put the
  real name in `native`. Later sections that carry configuration use `native`, falling back to the id.
- **Ranges and placeholders.** `ether1..24` declares `ether1` to `ether24`, and `{n}` in a label is the number.
  Section 3.2 has the full rules.
- **Labels.** A model holds only the manufacturer's labels. Your own printed labels and sticky notes are
  written on the unit (9.4).

### 5.2 Port types

`type` names an entry in the `types` section. A type is a full definition, not just a word: it says what the
port is, what fits it, and how it is drawn.

```yaml
types:
  1000base-t:
    name: 1000BASE-T
    family: ethernet
    speed: 1G
    connector: rj45
    primitive: rj45
  10gbase-x-sfpp:
    name: SFP+ (10GE)
    family: ethernet
    speed: 10G
    cage: sfp+
    primitive: sfp+
  iec-c14:
    name: IEC C14 inlet
    family: power
    connector: c14
    primitive: iec-c14
  bnc-75:
    name: BNC 75 Ω
    family: video
    connector: bnc
    primitive: bnc-socket        # a part defined in `parts`
```

| Field | Meaning |
| --- | --- |
| `name` | The name shown in port tables |
| `family` | `ethernet`, `fibre-channel`, `infiniband`, `wireless`, `mobile`, `serial`, `usb`, `power`, `video`, `audio`, `passive`, `other` |
| `speed` | Nominal speed, when the type has one |
| `connector` | What a cable end must be to plug in: `rj45`, `lc`, `sc`, `mpo`, `c13`, `c14`, `usb-a`, … Absent for a cage |
| `cage` | For a pluggable port: `sfp`, `sfp+`, `sfp28`, `sfp56`, `qsfp`, `qsfp+`, `qsfp28`, `qsfp56`, `qsfp-dd`, `osfp`. A module must fit it |
| `primitive` | How the port is drawn: a primitive from either bank or socket artwork (5.3), or a part id (7.7) |
| `netbox` | The NetBox interface, console or power type it corresponds to, when the id differs |
| `extends` | Another type to start from |

- **Where the vocabulary comes from.** The portspec catalog ships a types file with a full entry for every type
  it uses. Its ids are NetBox's interface, console-port and power-port type names, so data moves to and from
  NetBox without a table. The types file is YAML in this format, imported like any other file, and it is the
  only place the mapping from type to drawing is written.
- **Your own types.** Add entries to `types` in your file. A type you define is found before the catalog's with
  the same id (4.4), which is also how you redraw a standard type for your own files.
- **Checks use the type.** A module must fit the port's `cage`, and a cable must fit what the port presents.
  Sections 10.2 and 10.3 define both.
- A `type` that names no entry is an error. There is no silent fallback to a generic drawing.
- A type has at most one of `connector` and `cage`, never both. A type with neither, such as a radio or a
  virtual interface, has nowhere to plug a cable: its ports can be declared and drawn, and cannot be an end of
  a link or take a module or a plug.

### 5.3 Primitives

A primitive is one drawing the library knows how to make. Types, modules and face layouts name primitives.
The list is not a section of a file. It is a reference published with the spec and generated from the library,
with each primitive's default size, which flow layout depends on.

The library keeps its drawings in two banks:

| Bank | What it holds | The set |
| --- | --- | --- |
| Ports | Things a cable plugs into | Network: `rj45`, `sfp`, `sfp+`, `sfp28`, `sfp56`, `qsfp`, `qsfp+`, `qsfp28`, `qsfp56`, `qsfp-dd`, `osfp`. Access: `gpon` (an SC/APC receptacle). Power: `power-c14`, `power-c20`, `power-dc`, `dc-jack`, `iec-c6`, `iec-c8`, `iec-c13`, `iec-c16`, `iec-c19`, `iec-c20`, `iec-c22`, `nema-1-15p`, `nema-5-15p`, `nema-l5-30p`, `europlug-type-c`, `mains-type-g`, `molex-micro-fit-1x2`, `molex-micro-fit-2x2`, `molex-micro-fit-2x4`, `ubiquiti-smartpower`. USB: `usb-a`, `usb-c`, `usb-b`, `usb-b-3`, `usb-powered-b-3`, `usb-mini-a`, `usb-mini-b`, `usb-mini-ab`, `usb-micro-b`, `usb-micro-ab`, `usb-micro-b-3`, `usb-micro-ab-3`. Service: `serial-de9`, `rj11`, `vga`. Coax: `coax-f`, `coax-bnc`, `coax-n`, `coax-sma`, `coax-rp-sma`, `coax-iec-male`, `coax-iec-female`. Passive: `rj45-coupler`, `lc-coupler`, `sc-coupler`, `mpo-coupler`. Open: `custom`, `custom-cage` |
| Blocks | Everything else on a panel | The part kinds listed in 7.6, among them `dc-jack`, `power`, and the USB family: `usb-a`, `usb-c`, `usb-b`, `usb-b-3`, `usb-powered-b-3`, `usb-mini-a`, `usb-mini-b`, `usb-mini-ab`, `usb-micro-b`, `usb-micro-ab`, `usb-micro-b-3`, `usb-micro-ab-3`, and mains and power connectors: `iec-c6`, `iec-c8`, `iec-c20`, `nema-1-15p`, `nema-5-15p`, `europlug-type-c`, `mains-type-g`, `molex-micro-fit-2x2` |
| Modules | What sits in a cage | `copper`, `lc`, `sc`, `mpo`, `dac`, `sfp-reducer` |
| Assemblies | Parts the library builds from several drawings, at a measured size | `psu-module`, `drive-bay`, `fan-module`, `handle`, `knockout`, `rating-plate`, `ground-stud` (7.10) |

**A port is drawn with a drawing of the library, and a renderer draws nothing of its own.** The `primitive` of a
type, or of a port, names one of the library's ports:

```yaml
types:
  1000base-t:    { connector: rj45, primitive: rj45 }
  iec-60320-c14: { connector: c14, primitive: power-c14 }
  usb-c:         { connector: usb-c, primitive: usb-c }
  console-de-9:  { connector: de-9, primitive: serial-de9 }
```

- **A renderer does not draw.** It makes no picture of its own for a port and lays no artwork on a plain one. What
  is on the face is what the library draws for the name.
- **To the YAML it makes no difference how the library keeps a drawing.** What makes a port a port is that the
  model declares it. Should a type name a drawing the library keeps as a part, the port is handed over as that
  part; what only a port can do then waits (a cable ending there is not drawn, `cable-end-not-a-port`, and the
  port's printed label, lights, module and plug are left out), and the file does not change when the library
  catches up.
- A name the library does not have is drawn as its plain port, and a tool says so (`no-port-drawing`, a notice).
- A port's size and the way it turns are the library's: turned a quarter, a port's box turns with it. A face does
  not write `width` or `height` on a port to correct a drawing; a wrong size is a fault in the library.
- **A socket nothing plugs into is decoration**, written in a layout with its `-part` name: `- usb-c-part`.
- A file cannot add a primitive, because a primitive needs code in the library.

### 5.4 Modules

Transceivers and adapters are defined once and fitted on a unit (section 9.2).

```yaml
modules:
  s+rj10:
    name: S+RJ10
    fits: [sfp+, sfp28]
    type: 10gbase-t
  s+85dlc03d:
    name: S+85DLC03D
    fits: [sfp+, sfp28]
    type: 10gbase-sr
    mark: SR
  qsa:
    name: QSFP28 to SFP28 adapter
    fits: [qsfp28]
    cage: sfp28
    primitive: sfp-reducer
  odd-optic:
    name: Vendor optic
    fits: [sfp+]
    type: 10gbase-lr
    primitive: my-optic            # a part with its own image
```

| Field | Meaning | Default |
| --- | --- | --- |
| `name` | The name shown | the id |
| `fits` | The cages it goes into. Required | |
| `type` | The port type the port becomes with this module fitted. Its `connector` and `speed` are what cables and checks see | required, unless `cage` is set |
| `cage` | For an adapter: the cage it presents instead. A further module can then be fitted | none |
| `primitive` | How it is drawn in the cage: a module primitive (5.3) or a part id | from the connector of `type`: `rj45` → `copper`, `lc` → `lc`, `sc` → `sc`, `mpo` → `mpo`; a direct-attach type → `dac`; with `cage` → `sfp-reducer` |
| `mark` | Short text drawn on it | none |
| `vendor`, `source` | As for a model | none |

A module has exactly one of `type` and `cage`. A module's `type` must be a type with a `connector`, so every
chain of adapters ends in something a cable plugs into.

### 5.5 Connections inside a device

A patch panel, a wall outlet and a coupler join ports inside themselves: what goes in the front comes out the
back. `passthrough` states which ports are joined. It is separate from `links`, which are cables outside.

```yaml
models:
  panel-24:
    role: panel
    size: { units: 1 }
    ports:
      1..24:  { type: 8p8c }
      r1..24: { type: 8p8c-idc, side: rear }
    passthrough:
      - [1..24, r1..24]

  wall-outlet-2:
    role: outlet
    mount: none
    ports:
      a:  { type: 8p8c }
      b:  { type: 8p8c }
      ra: { type: 8p8c-idc, side: rear }
      rb: { type: 8p8c-idc, side: rear }
    passthrough:
      - [a, ra]
      - [b, rb]
```

| Entry | Means |
| --- | --- |
| `[a, b]` | These two ports are one conductor |
| `[a, b, c]` | These ports are all joined, as on a splitter |
| `[1..24, r1..24]` | Two ranges of equal length, joined pairwise in order: `1` with `r1`, `2` with `r2` |

- A port is in at most one entry. A port in none is not joined to anything.
- A path follows links and passthroughs: switch port, cord, panel front, panel rear, permanent run, outlet rear,
  outlet front, cord, host. That is one continuous path.
- `passthrough` is allowed on any model, and expected on roles `panel` and `outlet`.
- Not in this version: mapping individual fibres or channels through a cassette, such as one MPO to six LC
  pairs (section 22).

### 5.6 Mounting and size

A model has one mounting class and one size. Neither changes with where a unit is put.

| `mount` | What it is | Width of the body | Default when |
| --- | --- | --- | --- |
| `19in` | Mounts on 19-inch rails | 440 mm | `size.units` is given |
| `10in` | Mounts on 10-inch rails | 222 mm | never; write it |
| `none` | Stands on a surface | `size.width` | `size.units` is not given |

| `size` field | Meaning | Default |
| --- | --- | --- |
| `units` | Height in rack units, for `19in` and `10in` | 1 |
| `width`, `height` | Millimetres. For rack gear they follow from `mount` and `units` and may not be written. With a body, the size of the whole illustration (6.6) | for `none`: the body's own size when the model has a body; otherwise by role, from the published table of generic sizes |
| `depth` | Millimetres. The box behind each face that cables keep clear of (10.4); not otherwise checked | for drawing, 40 |

A `19in` device does not fit a `10in` rack, and a `10in` or `none` device goes in a `19in` rack only on a shelf
(9.1). Hardware is never scaled to fit.

## 6. Models: faces

Faces say what the device looks like. They only place ports that section 5 declared; they never give a port a
type or a speed, and the technical part never holds a coordinate or a colour.

```yaml
models:
  acme/edge-24:
    faces:
      front:
        finish: white
        layout:
          - logo: Acme
          - console
          - grid: { ports: ether1..24, rows: 2, order: odd-top }
          - grow
          - sfp1..2
          - leds: [power, fault]
      rear:
        layout: [fan, fan, grow, psu]
```

A face may also be defined on its own and named by a model (6.5). That is how the faces and the technical part
are kept in separate files.

### 6.1 Ways to define a face

Each face uses exactly one of these. Together they cover everything the library can draw: the two layout forms
cover its layout language, and the exact form covers its coordinate language. Section 20 lists every library
feature and where it is written.

| Form | Written as | What it is | Use |
| --- | --- | --- | --- |
| Generated | nothing | Drawn from the port list | The fallback |
| Layout, simple | `layout:` in the short form (7.1) | A short way to write the layout language | Most devices |
| Layout, full | `layout:` in the extended form (7.8) | The complete layout language, defined in 7.2 to 7.8 | Anything the short form does not say |
| Exact | `exact:` (6.4) | The library's coordinate language: every port and block at a position | Panels drawn to the millimetre, down to vents and screws; tracing over an image |
| Template | `template: server` (6.3) | The library's server builder | Servers by drive bays, cards and power supplies |

The simple and full layout forms may be mixed at any depth. A face may not mix layout and exact.

### 6.2 Face fields

| Field | Meaning | Default |
| --- | --- | --- |
| `finish` | `white`, `black`, `stainless-steel` | `white` |
| `background` | A colour, a material (`powder-white`, `powder-black`, `plastic-white`, `plastic-black`, `stainless-steel`, `brushed-aluminum`, `anodized-aluminum`, `wood`), a material with a tint as `{ material, color }`, or an image | from `finish` |
| `padding` | Millimetres, `{ x, y }`, or `{ top, right, bottom, left }` | `{ x: 12, y: 4 }` |
| `mounting-holes` | `true` or `false` | `true` for rack gear |
| `ears` | What is on the rack ears, left and right (6.7). Front face of rack gear only | nothing |
| `defaults` | What the entries of this face's layout start from (below). With a `layout` only | nothing |
| `layout` / `exact` / `template` | The form (6.1) | generated |

Each face has its own fields. A `finish`, `background` or `padding` written on the rear is the rear's alone. One
the rear does not write is the front's, so a device painted one colour all round writes it once; a rear
`background` wins over a rear `finish`. Nothing written on the rear changes the front.

**Defaults.** A measured face repeats itself: every row has no gap, no port prints its number, every caption is
one size. `defaults` says such a thing once, for the whole face:

```yaml
faces:
  front:
    defaults:
      container: { gap: 0, align: start }
      port: { label-position: none, lights: link-activity }
      caption: { gap: 0.6, text-style: { size: 1.8 } }
      pattern: { margin: 0 }
      indicator: { width: 2.6, height: 2.6 }
    layout:
      - row: [ether1, ether2]                 # no gap, no numbers
      - row: { gap: 4, items: [sfp1, sfp2] }   # its own gap
      - indicator: { id: pwr, caption: PWR }   # 2.6 square, the caption 1.8 high and 0.6 away
```

| Key | Gives a default to | It may hold |
| --- | --- | --- |
| `container` | Every row, column and overlay of the face, the root included. A grid takes the `gap` only | `gap`, `justify`, `align` |
| `port` | Every port the face places, in a grid or on its own | The options of 7.5, except those that say where or what one port is: `cell`, `span`, `position`, `margin`, `primitive` |
| `caption` | Every caption (7.11) | A caption's settings |
| `pattern` | Every pattern of openings (7.9): in a cutout, a `mask` part, a fan's grille and an assembly's vent | The settings every pattern shares: `columns`, `rows`, `gap-x`, `gap-y`, `row-offset`, `column-offset`, `alternate-columns`, `phase-x`, `phase-y`, `clip`, `margin` |
| a part kind (7.6), such as `label` or `indicator` | Every part of that kind, a light list (`leds`) and an assembly (7.10) included | The part's options |

- What an entry writes wins over the default. Maps merge by key, so a caption that writes its `side` keeps the
  default's `text-style`; a single value or a list replaces.
- Defaults reach everything laid out on the face: the ears (6.7), and the inside of a part the face uses (7.7).
- A default is not a new built-in: it applies to this face only, and a face without `defaults` is drawn as before.
- The rear has its own `defaults`. A rear that writes none starts from the front's, as with `finish`; a rear that
  writes `defaults: {}` starts from nothing.
- Through `extends`, `defaults` merge by key like the other face fields (section 8).
- `defaults` beside `exact` or `template`, or on a face with no form, is an error.

### 6.3 Template: server

A server's faces follow a plan: drive bays and controls at the front; at the rear an I/O shield, expansion
cards and power supplies, and on some a second bank of drive bays. Rack servers and towers both follow it. The template draws that plan from a few keys, in one of the library's server styles.
It is given the ids of ports the model declares. It never invents a port: how many sockets the shield, a card or
the supplies have follows from the lists.

```yaml
models:
  acme/r2:
    role: server
    mount: 19in
    size: { units: 2 }
    ports:
      bmc:     { type: 1000base-t, role: management, side: rear }
      eth0..1: { type: 1000base-t, side: rear }
      usb1..2: { type: usb-a, side: rear }
      sfp1..2: { type: 10gbase-x-sfpp, side: rear }
      psu1..2: { type: iec-60320-c14, role: power, side: rear }
    faces:
      front: { template: server, style: dell, drives: { count: 8, rows: 2 } }
      rear:
        template: server
        motherboard: { usb: [usb1..2], network: [eth0..1], management: bmc, display: vga }
        cards: [{ ports: [sfp1..2] }, blank]
        power-supplies: [psu1..2]
```

The rear above writes no `style` and takes the front's, as it takes the front's `finish` (6.2).

A tower is a model that is not rack gear. This one has a front panel with two USB ports and a card with two RJ45
and two SFP28:

```yaml
  acme/t1:
    role: server
    size: { width: 200, height: 430 }
    ports:
      fusb1..2: { type: usb-a }
      eth0:     { type: 1000base-t, side: rear }
      nic1..2:  { type: 1000base-t, side: rear }
      sfp1..2:  { type: 25gbase-x-sfp28, side: rear }
      psu1:     { type: iec-60320-c14, role: power, side: rear }
    faces:
      front: { template: server, preset: dell-tower, front-io: { usb: [fusb1..2] } }
      rear:
        template: server
        motherboard: { network: [eth0] }
        cards: [{ ports: [nic1..2, sfp1..2] }]
        power-supplies: [psu1]
```

**Either face.**

| Key | Value | Default |
| --- | --- | --- |
| `template` | `server`. Required: it is what makes the face a template | |
| `style` | `generic`, `dell`, `hp`, `apple`, `rosewill`, `silverstone`, `supermicro`. Drawings in the manner of these makers, not their products | the front's, then `generic` |
| `preset` | A style with the drive bays and supplies the library gives it at one size: `<style>-<units>u` for each style but `generic` at 1 to 6 units (`dell-2u`), `<style>-tower` (`hp-tower`), and five built for a purpose: `hp-2u-24sff`, `supermicro-4u-24lff`, `supermicro-4u-36lff` (24 bays at the front, 12 at the rear), `dell-2u-ocp`, `hp-2u-lom`. Not with `style` | none |
| `label` | The model text a `generic` front prints | the model's `name` |
| `logo` | An image (4.8), or `false` for none | the style's mark |

**Front.**

| Key | Value | Default |
| --- | --- | --- |
| `drives` | A number of drive bays, or `{ count, rows, size, access, orientation, layout }`. Bays are not ports | the preset's, or 4 per unit (4 on a tower) |
| `drives.count` | 0 to 48. Required in the map | |
| `drives.rows` | 1 to 16, and no more than `count` | as many as the bays need |
| `drives.size` | `2.5` or `3.5` | `2.5` |
| `drives.layout` | `standard`: 72 × 16 mm or 106 × 30 mm carriers, 3 mm apart. `dense`: 72 × 16 or 102 × 26.5, 1 mm apart, with a narrower control strip, so 24 2.5" bays fit a 2U front and 24 3.5" a 4U one. `auto`: standard, and dense where standard does not fit | `auto` |
| `drives.access` | `hot` (a carrier with a release and a light) or `cold` (a cover) | `hot` |
| `drives.orientation` | `horizontal`, or `vertical` for carriers standing on end | `horizontal`; `vertical` for dense 2.5" bays where they fit |
| `bezel` | `true` draws a removable grille over the bays. The bays are still there, behind it | `false` |
| `service-usb` | A front port, drawn as the USB socket beside the power button; `false` for none. Not with `front-io` | a socket that is decoration |
| `front-io` | A front panel of ports above or beside the bays: `{ usb, network, display, placement, width, height }`, or `{ layout, placement, width, height }`. It takes the place of the service socket | none |
| `front-io.usb`, `.network`, `.display` | As on the motherboard (below): USB ports, RJ45 ports, a VGA port | none |
| `front-io.layout` | The panel's content in the layout language (section 7). Not with the three keys above | |
| `front-io.placement` | `top`, a strip above the bays (20 mm high), or `side`, a column beside them (80 mm wide) | `top` |
| `front-io.width`, `.height` | The panel's size in millimetres | as `placement` says |

**Rear.**

| Key | Value | Default |
| --- | --- | --- |
| `rear-drives` | Drive bays on the rear, written as `drives`. They take the rear's height first, before the shield, cards and supplies | none |
| `motherboard` | The I/O shield: `{ usb, network, management, display, width, height }`, or `{ layout, width, height }`. `false` or left out: no shield | none |
| `motherboard.usb` | A list of ports drawn as USB (`usb-a`, `usb-c`, and the other `usb-` drawings), in pairs one above the other | none |
| `motherboard.network` | A list of RJ45 ports | none |
| `motherboard.management` | One RJ45 port, printed `MGMT` | none |
| `motherboard.display` | A port drawn as `vga`; or `vga` for a socket that is decoration; or `false` | `false` |
| `motherboard.layout` | The shield's content in the layout language (section 7), for a shield the four keys above do not describe. Not with them | |
| `motherboard.width`, `.height` | The shield's size in millimetres | wide enough for its sockets; 37 high, or the face's full height at 1U |
| `cards` | A list, one per expansion slot: `{ ports, slot, label, lights }`, or `blank` for an empty PCIe bracket. At most two PCIe slots per unit (twelve on a tower), and twelve cards in all | none |
| `cards[].ports` | A list of ports, each drawn as `rj45`, `sfp`, `sfp+`, `sfp28`, `qsfp+` or `qsfp28`. One card may hold several drawings, such as two RJ45 and two SFP28; at most eight runs of one drawing | |
| `cards[].slot` | `pcie`, a bracket; `ocp`, an OCP mezzanine plate (100 × 28 mm); `lom`, a LAN-on-motherboard plate (90 × 24 mm). OCP and LOM plates stack below the brackets and do not count as PCIe slots | `pcie` |
| `cards[].label` | Printed before each port's number: `label: SFP` prints `SFP 1`, `SFP 2` | the number alone |
| `cards[].lights` | The ports' lights (7.5) | `link` on RJ45, none on cages |
| `card-layout` | `horizontal`, or `vertical` for PCIe cards standing upright side by side | `vertical` from 3U in the `rosewill`, `silverstone` and `supermicro` styles when the rear has no bays; else `horizontal` |
| `power-supplies` | A list of 0 to 4 inlet ports, one per supply, drawn as `power-c14`, `power-c20` or `power-dc` | none |
| `power-supply-type` | `hot-swap`, for removable modules, or `atx`, one fixed supply with its fan (3U and up, or a tower) | `atx` on a tower, and from 3U in the `rosewill` and `silverstone` styles; else `hot-swap` |
| `psu-layout` | `row` or `stack`, for hot-swap modules | `stack` on a tower and in the `dell` and `supermicro` styles; else `row` |

- **Every port of the face's side is placed exactly once**, in the template's lists or in a `layout`.
  A port not in them is `port-not-placed`; a port named twice is `port-placed-twice`; a port of the other side is
  `port-on-other-side`; a name that is not a port of the model is `unknown-port`.
- **A list takes ports of the drawing it is for.** An SFP+ port in `network`, or a DE-9 on a card, is
  `template-port-type`. A port that fits no list goes in `motherboard.layout` or `front-io.layout`.
- **Labels.** A port whose model writes its `label` (5.1) prints it. Otherwise the template's: `MGMT`, `LAN 1` and on
  for `network`, each card port's number.
- **What else is drawn is the template's**: the chassis, drive carriers and their lights, the power button and
  status lights, vents and fans, card brackets, the supplies' handles and lights. They are parts, and nothing
  connects to them.
- **Ports keep their drawing.** A port is drawn with its own drawing (5.3) in the place the template gives it,
  with its module or plug (9.2). A cage the device fills with no module is drawn empty.
- **Rack server or tower.** On rack gear of 1 to 6 units, `19in` or `10in`, the template draws a rack server as
  wide as the mount. On a model that is not rack gear it draws a tower, `size.width` by `size.height`, 200 × 430
  mm when the model gives none; a tower's rear stacks the shield, the cards and the supplies one above the other.
  Rack gear of another height, a rack preset on a tower or a tower preset on rack gear, or a preset of another
  height, is `template-size`. The template draws its own chassis: a model's `body` (6.6) is not used beside it.
- **Fixed sizes, explicit errors.** Carriers, cards and supplies keep their size: a request that does not fit,
  such as 30 bays in 1U, ten RJ45 on one card, or rear bays that leave no room for the supplies, is
  `template-does-not-fit`, and the message says what does fit.
- **Face fields.** Beside a template a face takes `finish` and `background` (6.2); the template keeps its own
  padding and has no mounting holes. A template's rear is bare steel unless the rear writes its own `finish` or
  `background`: unlike other faces, it does not take the front's. `padding` or `mounting-holes` beside it is `not-with-template`, and `ears`
  or `defaults` beside it is an error as for any face that is not a layout (`ears-not-allowed`,
  `defaults-not-allowed`).
- **The keys of the other face** are `unknown-key`: `drives` or `front-io` on a rear, `cards` on a front. A template key on a
  face without `template` is `unknown-key` too.
- Through `extends`, a template is one unit like any face's content (section 8): an upper layer that changes
  `drives` writes the whole template.

### 6.4 Exact

Every port and every block is given a position and a size. This is the form the hand-drawn catalog faces use.

```yaml
faces:
  front:
    finish: white
    mounting-holes: false
    exact:
      image: ./crs326-front.png
      ports:
        console:         { x: 21.5, y: 24, width: 14, height: 11, label-position: none }
        ether1..24:      { x: 40, y: 9.5, pitch: { x: 14.5, y: 14.5 }, rows: 2, order: odd-top, groups: 4, group-gap: 5.5 }
        sfp-sfpplus1..2: { x: 231, y: 26, pitch: { x: 21.5 } }
      blocks:
        - { id: inset,  kind: panel, x: 3, y: 2, width: 437, height: 39, color: "#dadddc" }
        - { id: brand,  kind: logo, text: MikroTik, x: 5, y: 4, width: 31, height: 7 }
        - { id: model,  kind: label, text: "{model}", x: 375, y: 12.5, width: 61, height: 5 }
        - { id: power,  kind: indicator, x: 20.8, y: 38.2, width: 2, height: 2, color: "#5db66f" }
        - { id: reset,  kind: button, x: 27.7, y: 38.2, width: 1.8, height: 1.8, shape: round }
        - { id: intake, kind: vent-slots, x: 300, y: 8, width: 60, height: 20 }
        - { kind: screw, x: 6, y: 20 }
```

- Positions are millimetres from the top-left of the face to the top-left of the item.
- `ports` is a map keyed by port id; its order does not matter. A single port takes `x`, `y` and the options of
  7.5.
- `blocks` is a list. A later block is drawn over an earlier one, and ports are drawn over all blocks. `id` is
  optional. `kind` is a part kind (7.6) or a part id (7.7); the options are those of 7.6.
- `image` is drawn under everything, at the size of the face (4.8).
- Nothing is laid out for you, so nothing moves if the face is given another size.

**A range of ports.** A range takes the position of its first cell and these fields:

| Field | Meaning | Default |
| --- | --- | --- |
| `x`, `y` | Top-left of the cell in column 0, row 0. Required | |
| `pitch` | `{ x, y }`: distance from one cell's left edge to the next column's, and from one cell's top edge to the next row's | the drawing's width plus 2, and its height plus 2 |
| `rows` | Number of rows | 1 |
| `order` | As in 7.3 | `row-major` |
| `groups` | Columns per block | no blocks |
| `group-gap` | Extra distance between blocks, added to `pitch.x` | 0 |

With the column c and row r that 7.3 gives port i, its cell is at:

```text
x  =  x0 + c × pitch.x + (c ÷ groups, rounded down) × group-gap
y  =  y0 + r × pitch.y
```

### 6.5 Faces defined on their own

```yaml
faces:
  crs326-front:
    finish: white
    layout:
      - logo: MikroTik
      - grid: { ports: ether1..24, rows: 2, order: odd-top, groups: 4 }
      - grow
      - sfp-sfpplus1..2

models:
  mikrotik/crs326-24g-2s-plus-rm:
    ports: { … }
    faces: { front: crs326-front, rear: other:crs326-rear }
```

- A face in `faces` has the same fields as a face written inside a model.
- A model names a face by reference, so the face may come from an import. The model is the one that points;
  a faces file cannot attach itself to a model in another file (4.5).
- The face places ports by id. It is checked against each model that uses it, and a port the model lacks is an
  error there.
- To draw a catalog model differently, write a model that `extends` it and names your own face.

### 6.6 Body

A body is the silhouette of a device's chassis: a laptop, a tower, a display on a stand. It is for devices
that are not a rectangular panel. It is written once for the whole device, beside `front` and `rear`.

```yaml
models:
  office-laptop:
    name: Office laptop
    role: host
    ports:
      usb-c1..2: { type: usb-c, side: rear }
    faces:
      body: laptop
      front:
        background: { material: anodized-aluminum, color: "#929aa3" }
```

| Body | Is |
| --- | --- |
| `rectangle` | The plain panel. The default, and the same as writing no body |
| `laptop`, `mini-pc`, `compact-workstation`, `sff-desktop`, `tower-desktop`, `all-in-one` | Generic computer shapes |
| `macbook-air`, `macbook-pro`, `mac-mini`, `mac-studio`, `imac`, `thinkpad` | Recognisable shapes of those product lines. They are illustrations, not a generation's measurements |

The list is the library's and is published with the spec, like the primitives (5.3).

A body may also be written as a map, to say how its case is shaped:

```yaml
faces:
  body: { type: rectangle, corner-radius: 8, edge-profile: rounded }
```

| Key | Meaning | Default |
| --- | --- | --- |
| `type` | A body from the list above | `rectangle` |
| `corner-radius` | The radius of the case's outer corners, millimetres. At most half the shorter edge | 0 |
| `edge-profile` | `flat`, `rounded`, `beveled`: how the case's edge is drawn. It does not change the size | `flat` |

`body: laptop` is short for `body: { type: laptop }`. The radius applies to the outer rectangle, or to the
rectangular parts of a named body. A desktop unit with rounded corners is a `rectangle` with a radius.

- **A body changes the drawing of the chassis and nothing else.** It adds no port, no screen and no part, and
  moves none. Ports are still declared in the technical part and placed by the faces, in any of the forms of 6.1.
- **Size.** A model's `size` is the size of the whole illustration, with a laptop's deck or a display's stand.
  A model with a body and no `size` takes the body's own size, which is published with the list.
- **Rack gear is a rectangle.** A model with `mount: 19in` or `10in` may not have another body `type`. It may
  have a `corner-radius` and an `edge-profile`.
- **Front and rear.** A laptop is drawn open from the front; from the rear it shows its lid and a strip for its
  ports. Sockets on the sides of a real laptop are placed on that strip.
- **Screens.** A display is an ordinary `screen` part in the front face. By convention its id is `display`.
- **Inheritance.** A model that extends another keeps its body. Writing `body` replaces it, map and all;
  `body: null` goes back to the plain rectangle. Neither touches the faces (section 8).
- A body the list does not have is an error.

### 6.7 Ears

Rack gear is drawn between its ears: a `19in` face is 440 mm wide, a `10in` face 222 mm (5.6). Some devices
carry buttons, lights, a logo or a badge on the ears themselves. `ears` on the front face says what.

```yaml
faces:
  front:
    ears:
      left:
        column: { gap: 3, items: [{ button: { id: power, shape: round } }, { leds: { items: [{ id: status, text: STATUS }, { id: alert, text: ALERT }] } }] }
      right: [{ logo: Synology }]
    layout:
      - grid: { items: [ … ] }
```

| Key | Meaning |
| --- | --- |
| `left`, `right` | A layout, as `layout` is (section 7): a list, or a single container |

- The ears are outside the face, each as wide as the mount's ear: 21.3 mm for `19in`, 16 mm for `10in`, and as
  tall as the face. Their padding is 0, and their content is centred unless it says otherwise.
- Ears are on the front of rack gear only. `ears` on a rear face, on a model with no rack `mount`, or with the
  `exact` or `template` form is an error.
- A port may be placed on an ear. It counts as placed on its face, once, like any other (6.1).
- Ids on an ear are those of the face; a part id may not appear on an ear and on the face both.
- Where `ears` is not written, the ears are drawn plain, with their mounting holes.

## 7. Face layout

A layout is a tree. Its leaves are ports, parts and spaces; its branches are rows, columns and grids. There are
two ways to write it. Both may be mixed at any depth, and the simple form is defined as an expansion into the
extended one.

### 7.1 The simple form

`layout` is a list, laid out as a row. Each entry is one of these:

| Entry | Means |
| --- | --- |
| `ether1` | Place this port |
| `sfp1..2` | Place these ports in order |
| `{ ether1: { lights: link } }` | Place a port with drawing options (7.5) |
| `fan` | A part with its defaults (7.6) |
| `{ logo: Acme }` | A part with a label |
| `{ fan: { grille: mesh, width: 40 } }` | A part with options |
| `{ leds: [power, fault] }` | A row of indicators with these ids |
| `{ leds: { items: [ … ] } }` | A light list: lights with their names printed beside them (7.6) |
| `grow` | Space that takes what is left |
| `{ space: 6 }` | Fixed space, millimetres |
| `{ to: 120 }` | A stop: what follows starts 120 mm from the start of this row or column (below) |
| `{ row: [ … ] }` | A nested row |
| `{ column: [ … ] }` | A nested column |
| `{ grid: { … } }` | A grid (7.3) |
| `{ overlay: [ … ] }` | Entries laid over one another in one box (3.6.4) |

A bare word is a port if the model declares a port of that id, then a part id from `parts`, then a part kind.
A model whose port id equals a part kind must use the extended form for that part.

A row, column or overlay takes options by writing its entries under `items`:

```yaml
- column:
    gap: 4
    align: start
    items:
      - row: [sfp1, sfp2]
      - row: [sfp3, sfp4]
```

`layout` may also be a single container instead of a list: `layout: { column: [ … ] }`.

**Stops.** A measured face knows where things start, not how far apart they are. `{ to: 120 }` in a row or
column moves the place the next entry goes to 120 mm from the start of that container's content, inside its
padding, so a measurement read off a photo is written as it was read:

```yaml
- row: [logo, { to: 96 }, ether1..8, { to: 228.6 }, sfp1, sfp2]
```

- A stop takes nothing but `to`. It is for a container whose entries are packed from the start (`justify:
  start`, the default); with another `justify` it is an error.
- A stop behind what is already placed is an error: entries do not overlap.
- The `gap` is not added after a stop: the next entry starts exactly there.
- A stop means nothing in an overlay or a grid, and is an error there.

### 7.2 Container options

`row`, `column`, `grid` and `overlay` in a face are containers. Their settings, their values and the way they are drawn
are those of section 3.6 and are not repeated here. What is particular to a face:

| Setting | In a face |
| --- | --- |
| `gap`, `padding`, `justify`, `align`, `grow`, `position` | As in 3.6. Defaults: `gap` 2, `padding` 0 (the face itself has `{ x: 12, y: 4 }`), `justify: start`, `align: center` |
| `margin`, `align-self` | As in 3.6.2, on the container as an item of its parent. Every port and part takes them too (7.5, 7.6) |
| `width`, `height` | As in 3.6.3: a number, `grow` or `fill`. Default `grow` |
| `fit` | `contain` is allowed here, and only here |
| `repeat` | Lay the entries out this many times. Not allowed around port placements; use a range or a grid. A repeated container may not have pinned entries of its own |
| `background` | A colour, a material or an image behind the container |

### 7.3 Grid

For ports, the simple form:

```yaml
- grid: { ports: ether1..24, rows: 2, order: odd-top, groups: 8, gap: 2 }
```

| Field | Meaning | Default |
| --- | --- | --- |
| `ports` | A range, or a list of ids and ranges | required |
| `rows` | Number of rows | 1 |
| `columns` | Instead of `rows` | follows from `rows` |
| `order` | How the ports fill the cells | `row-major` |
| `groups` | Split into blocks of this many columns, with a wider gap between blocks | one block |
| `gap` | Between cells, millimetres | 2 |
| `group-gap` | Between blocks, millimetres | three times `gap` |
| `lights`, `rotation`, `label-position`, `caption` | Given to every port in the grid, as if written on each (7.5) | none |
| `mirror-rows` | `true`: the ports of the second, fourth, … row are turned 180 degrees and their labels printed below them | `false` |

`mirror-rows` is how most switches are built: the lower row of jacks is upside down, with its numbers under it.
A `rotation` or `label-position` written on the grid applies to the other rows; on the turned rows, `rotation`
is added to the half turn. To set something on one port only, place it on its own or give the grid's options
to each port with `items`.

```yaml
- grid: { ports: port-1..48, rows: 2, order: odd-top, groups: 12, lights: link-activity, mirror-rows: true }
```

With N ports, R rows and C columns (C is N divided by R, rounded up), port number i, counting from 0, goes to:

| `order` | Column | Row | Seen on |
| --- | --- | --- | --- |
| `row-major` | i mod C | i ÷ C | Patch panels |
| `odd-top` | i ÷ R | i mod R | Most switches: 1 above 2 |
| `odd-bottom` | i ÷ R | R − 1 − (i mod R) | MikroTik SFP cages: 1 below 2 |

For anything else, list the items. They fill row by row unless an item says where it goes:

```yaml
- grid:
    columns: 4
    rows: 2
    items:
      - { screen: { cell: [0, 0], span: [2, 2] } }
      - mgmt
      - usb-c
      - { vent-slots: { cell: [2, 1], span: [2, 1] } }
```

- Cells are equal. `cell` is `[column, row]` counted from 0 at the top left; `span` is `[columns, rows]`.
- A cell may hold a row, a column or another grid.
- Overlapping cells, or a cell outside the grid, are an error.

### 7.4 Position

`position` pins an entry to its container instead of placing it in the flow.

```yaml
- label: { text: CORE ROUTER, position: bottom-right }
- vent-mesh: { width: 60, height: 20, position: { right: 8, top: 4 } }
```

| Written as | Means |
| --- | --- |
| `top-left`, `top`, `top-right`, `left`, `center`, `right`, `bottom-left`, `bottom`, `bottom-right` | Against that edge or corner, no offset |
| `{ left, right, top, bottom }` | Millimetres inward from those edges. Negative moves outward |
| `{ …, align-x, align-y }` | `start`, `center`, `end` within the region the edges leave |

Two opposite edges stretch a container between them. A container with `repeat` above 1 may not have pinned
entries of its own. A pinned entry takes no `margin` (3.6.4).

### 7.5 Options on a placed port

| Option | Meaning |
| --- | --- |
| `lights` | `link`, `link-activity`, or a list of lights with `id`, `position`, `shape`, `placement` and `offset` |
| `label` | The port's printed label, in place of the one the model gives it (5.1) or its number |
| `label-position` | `above`, `below`, `left`, `right`, `none` |
| `caption` | Text beside the port, on any side, as well as its label (7.11) |
| `rotation` | 0, 90, 180, 270. It turns any drawing: a port primitive, a block or socket artwork |
| `margin`, `align-self` | As in 3.6.2 |
| `width`, `height` | When the default size of the drawing is wrong |
| `primitive` | Another drawing for this port: a primitive (5.3) or a part id |
| `cell`, `span`, `position` | Where it goes, in a grid or pinned |

Which lights a port has is part of the model. Whether a light is lit is not in the file.

**A light away from the jack.** A light is drawn inside the port's drawing unless it says otherwise.
`placement: outside` puts it outside, against the corner its `position` names (`top-left`, `top-right`,
`bottom-left`, `bottom-right`; the `integrated-` positions are inside only), and `offset: { x, y }` moves it
from there, in millimetres. It stays the port's light, with the same id, wherever it is drawn:

```yaml
- ether1..8: { lights: [{ id: link, position: bottom-left, placement: outside, offset: { x: 0, y: 4 } }] }
```

**The printed label.** A port is labelled by the model's `label` (5.1), or else by the number at the end of its
id. `label` on a placed port replaces that on this face only: `{ sfp-sfpplus1: { label: "SFP 49" } }`. An empty
string prints nothing, as `label-position: none` does.

### 7.6 Part kinds

| Group | Kinds |
| --- | --- |
| Text and marks | `logo`, `label`, `image`, `panel`, `blank` |
| Controls and lights | `indicator`, `power-light`, `button`, `button-square`, `screen`, `leds` (a light list) |
| Sockets that are not ports | `usb-a`, `usb-c`, `dc-jack`, `power` |
| Airflow | `vent`, `vent-slots`, `vent-mesh`, `vent-honeycomb`, `vent-rings`, `vent-chevron`, `fan`, `fan-slots`, `fan-mesh`, `fan-honeycomb`, `fan-rings` |
| Mechanical | `screw`, `screw-black`, `screw-white`, `mask`, `mask-chevron`, `expansion-slot`, `motherboard-io` |
| Cutouts (7.9) | `cutout-chevron`, `cutout-chevron-inverted`, `cutout-round-inline`, `cutout-round-staggered`, `cutout-horizontal-slots`, `cutout-vertical-slots`, `cutout-square-grid`, `cutout-hex-grid`, `cutout-diagonal-slots`, `cutout-slash`, `cutout-backslash`, `cutout-sequence`, `cutout-arc-slots` |
| Assemblies (7.10) | `psu-module`, `drive-bay`, `fan-module`, `handle`, `knockout`, `rating-plate`, `ground-stud` |
| Open | `custom-block` |

Part options: `id`, `text` (or the short label form), `text-style` (size, line height, align, weight), `caption`
(7.11), `width`, `height`, `rotation`, `finish`, `color`, `shape`, `grille`, `image`, `mask`, `screen`
(resolution only), `margin`, `align-self`, and `cell`, `span`, `position`.

- **A logo drawn from a path.** `logo` takes `path`, SVG path data, with an optional `view-box` (default
  `{ x: 0, y: 0, width: 100, height: 100 }`), as well as `text` or `image`. A logo has one of the three. The path
  is filled in the logo's colour and scaled into its `width` and `height`.
- **A fan behind a grille in the face.** On a `fan` part, `grille` is a named grille (`slots`, `mesh`,
  `honeycomb`, `rings`, `chevron`), drawn on the fan, or `{ mask: … }`: a mask (7.8, 7.9) cut in the face itself,
  with the fan seen turning behind it. That is how most fans look from outside a case:

  ```yaml
  - fan: { width: 40, height: 40, grille: { mask: { pattern: { preset: hex-grid, size: 2.5, clip: true }, shape: { ring: { outer: 38, inner: 12 } } } } }
  - fan: { width: 40, height: 40, grille: { pattern: { preset: hex-grid, size: 2.5, clip: true }, shape: { ring: { outer: 38, inner: 12 } } } }
  ```

  The two lines say the same: a `grille` map with no `mask` in it is the mask.

**Light lists.** `leds` written as a list is a row of bare lights. Written as a map, it is a list of lights with
their names printed beside them, as on most status panels:

```yaml
- leds:
    id: status
    direction: column
    text-side: right
    items:
      - { id: user,  text: USER }
      - { id: fault, text: FAULT, color: "#d83b2d" }
      - { id: pwr2,  text: PWR 2 }
```

| Key | Meaning | Default |
| --- | --- | --- |
| `items` | The lights in order, each `{ id, text, color }`. `id` is required and unique in the list; `text` is the printed name | required, 1 or more |
| `direction` | `row` or `column` | `column` |
| `gap` | Between lights, millimetres | 2 |
| `text-side` | Where each name is printed: `above`, `below`, `left`, `right` | `right` |
| `text-style`, `color`, `shape` | For every light and name in the list | the indicator's |
| `id` | The list's id | `leds` |

Each light is an `indicator` 2.5 mm square with the id `<list id>/<item id>` (`status/fault`), and can be
addressed like any other. Its name is its caption (7.11), on `text-side`, so each light and its name take the
room a captioned part does, and the list lays them out `gap` apart. In a column the lights line up on the side
away from their names: on the left, or on the right when `text-side` is `left`. In a row they line up at the top. Two lists on one face need different ids. A light list also takes `margin`, `align-self`, `caption`,
`cell`, `span` and `position`.

The default size of every part and port drawing is published with the spec and versioned with it, because flow
layout depends on it.

### 7.7 Your own parts

A file can define parts and use them by id in any layout, its own or an importing file's.

```yaml
parts:
  alarm-block: { kind: custom-block, width: 18, height: 12, text: ALARM, color: "#b3261e" }
  brand:       { kind: logo, image: ./acme.svg, width: 42, height: 10 }
  fan-bank:    { row: { gap: 3, items: [fan-mesh, fan-mesh, fan-mesh] } }
  bnc:         { kind: custom, width: 10, height: 10, image: ./bnc.svg }
```

- A part with `kind` is one drawing with fixed options. A part with `row`, `column`, `grid` or `overlay` is a
  fragment.
- A part whose `kind` is a port drawing (`custom`, `custom-cage`, or any port primitive) is named as the
  `primitive` of a type, a port or a module.
- A fragment may use other parts, but never itself, directly or through others.
- A part is looked up as any reference is (4.4): in the file that wrote the face, then in its imports, or in one
  import by name (`acme:fan-bank`). A part's id is tried before a part kind of the same name.

**Using a part.** A use may add options, and they are laid over the part's own: over the drawing's options for a
part with `kind`, over the container's settings for a fragment. So one part serves two places that differ in a
width or a margin:

```yaml
- brand                                   # as defined
- brand: { width: 30 }                    # narrower here
- fan-bank: { margin: { left: 8 } }
```

**A fragment that holds ports.** A fragment does not name a model's ports, because it does not know which model
will use it. It lists names of its own in `ports`, places them like ports, and each use says which port of the
model each name is:

```yaml
parts:
  supply:
    ports: [inlet]
    row:
      background: "#7d7d7d"
      height: 40
      gap: 3
      items:
        - fan-rings: { width: 42, height: 30 }
        - column: [{ inlet: { label-position: none } }, { leds: [ac, dc] }]

models:
  acme/switch:
    ports:
      psu1..2: { type: c14, side: rear }
    faces:
      rear:
        layout:
          - supply: { inlet: psu1, width: 74.8 }
          - supply: { id: right, inlet: psu2, width: 77.5, margin: { left: 1 } }
```

- `ports` is a list of bare names, each different, on a fragment only. A name is a word of the part's own: it
  hides a port of the model with the same id while the part is laid out.
- A use gives every name a port of the model. A name left out, or a port the model does not have, is an error. A
  port placed through a part counts as placed (6.1): once, on the face of its side.
- This is a binding and not a substitution: nothing in the part's text is rewritten, and no id is made from a
  placeholder (3.2).
- **Ids.** What is inside a used part is named under the use, as with an assembly (7.10): `right/ac`, `right/dc`.
  A use with no `id` is named by the part and its turn among that part's uses on the face: `supply-1`,
  `supply-2`. Ports keep their own ids.
- A fragment used inside another passes its ports on by the same rule: the inner use names the outer part's names.
- A part is laid out with the `defaults` of the face that uses it (6.2), so a part meant for several models
  writes what it depends on.
- `{name}`, `{vendor}` and `{model}` in a part are those of the model that uses it (3.2).

### 7.8 The extended form

Every simple entry expands into this form. Use it directly for anything the simple form does not say.

This section, with 7.2 to 7.6, is the contract. The keys were chosen to match the faceplate library's so the
compiler stays thin, but the library is free to change inside; when it does, the compiler adapts and this
section does not.

```yaml
layout:
  direction: row
  gap: 4
  children:
    - primitive: logo
      label: Acme
    - port: console
      primitive: rj45
      lights: link-activity
    - direction: column
      grow: 1
      children:
        - layout: grid
          columns: 12
          rows: 2
          children:
            - { port: ether1, cell: [0, 0] }
            - { port: ether2, cell: [0, 1] }
    - space: 0
      grow: 1
    - primitive: vent-mesh
      id: intake
      width: 60
      height: 20
      position: { right: 8, top: 4 }
```

| Simple | Extended |
| --- | --- |
| a list | `{ direction: row, children: [ … ] }` |
| `{ row: … }`, `{ column: … }` | `{ direction: …, children: [ … ] }` plus the options |
| `ether1` | `{ port: ether1 }`; the drawing comes from the port's type, or the port's own `primitive` |
| `sfp1..2` | one `{ port: … }` per port |
| `fan` | `{ primitive: fan }` |
| `{ logo: Acme }` | `{ primitive: logo, label: Acme }` |
| `{ leds: [a, b] }` | a row of `{ primitive: indicator, id: … }` |
| `{ leds: { items, … } }` | `{ primitive: leds, items: [ … ], … }` |
| `{ overlay: … }` | `{ direction: overlay, children: [ … ] }` plus the options |
| `{ grid: { ports, …, mirror-rows } }` | as above, with the grid's port options and the turned rows written on each port |
| `grow` | `{ space: 0, grow: 1 }` |
| `{ grid: { ports, … } }` | a row of grids, one per group, each port given its `cell` by the table in 7.3 and the grid's port options |
| a part id | the part's definition |
| `position: top-right` | `position: { top: 0, right: 0 }` |

An entry is in the extended form when it has `primitive`, `port`, `children`, `direction` or `layout`.

**Everything in the full form.**

| On | Keys |
| --- | --- |
| A container | `id`, `direction` (`row`, `column`, `overlay`), `children`, and the settings of 3.6.2 and 7.2: `gap`, `padding`, `justify`, `align`, `grow`, `width`, `height`, `fit`, `repeat`, `background`, `position`, `margin`, `align-self`, `layout` |
| `layout` on a container | `grid` with `columns` and `rows`; `motherboard-io` and `expansion-slots`, the library's two framed rear-panel layouts |
| A child of a grid | `cell`, `span` |
| A port entry | `port`, `primitive`, `width`, `height`, `label`, `label-position`, `caption`, `text-style`, `rotation`, `lights`, `cage`, `passive`, `image`, `margin`, `align-self`, `cell`, `span`, `position` |
| A block entry | `primitive`, `id`, `label`, `text-style`, `caption`, `width`, `height`, `rotation`, `finish`, `color`, `shape`, `grille`, `mask`, `image`, `path`, `view-box`, `screen`, `background`, `margin`, `align-self`, `cell`, `span`, `position` |
| A light list | `primitive: leds`, `id`, `items`, `direction`, `gap`, `text-side`, `text-style`, `color`, `shape`, `caption`, `margin`, `align-self`, `cell`, `span`, `position` |
| An assembly | The block entry's keys, and those of its kind in 7.10 |
| `caption` | `text`, `side`, `gap`, `text-style`; or the text alone (7.11) |
| `margin`, `padding` | a number, `{ x, y }` (padding only), or `{ top, right, bottom, left }` |
| A space | `space`, `grow` |
| `position` | `left`, `right`, `top`, `bottom`, `align-x`, `align-y` |
| `lights` | `link`, `link-activity`, or a list of `{ id, position, placement, offset, x, y, width, height, shape, color }` |
| `mask` | One shape: `pattern` (7.9), or `path` with an optional `view-box`, or `image` with `mode: alpha` or `luminance`. Then `shape`, `depth`, `interior`, `rotation` |
| `pattern` | A pattern's name, or `preset` with the settings of its row in 7.9 and `columns`, `rows`, `gap-x`, `gap-y`, `row-offset`, `column-offset`, `alternate-columns`, `phase-x`, `phase-y`, `clip`, `margin`, and `ends` where 7.9 allows it |
| `background` | a colour, a material, or `{ material, finish, color, image, texture-scale }` |
| `image` | a path or address, with optional `crop` and `fit: contain`, `cover` or `fill` |
| `text-style` | `size`, `line-height`, `align`, `weight` |
| `screen` | `resolution` only |

Keys are written with hyphens in YAML (`label-position`, `text-style`, `align-x`); the compiler maps them to
the library's names. Ids in a repeated container follow the library's rule: the container's id, the turn
counted from 1, then the entry's id (`bank/2/fan`).

### 7.9 Cutouts

A cutout is a region of a face with a pattern of openings in it: a row of chevrons, a field of round holes, a
bank of slots. The openings are real holes in the panel. It works on the front and on the rear, in every way of
defining a face.

```yaml
faces:
  front:
    layout:
      - cutout-chevron: { width: 96, height: 12 }
      - ether1..4
      - grow
      - cutout-vertical-slots:
          width: 70
          height: 26
          mask: { pattern: { length: 20, thickness: 2, gap-x: 3 }, depth: 1 }
  rear:
    layout:
      - mask:
          width: 96
          height: 24
          mask:
            pattern: { preset: round-staggered, size: 3, gap-x: 2, gap-y: 2, margin: 1 }
            depth: 0.8
      - mask: { width: 30, height: 60, mask: { pattern: hex-grid, rotation: 90 } }
```

**Two sizes.** The part's `width` and `height` are the region. The pattern's measurements are one opening. A
region never stretches its openings: a 3 mm hole stays 3 mm, and a wider region holds more of them. All
measurements are millimetres.

**The patterns.** This list is part of the format.

| Pattern | Openings | Settings of one opening |
| --- | --- | --- |
| `chevron` | V shapes in a row | `length`, `height`, `thickness` |
| `chevron-inverted` | The same, pointing up | `length`, `height`, `thickness` |
| `round-inline` | Round holes in straight rows | `size` |
| `round-staggered` | Round holes, every other row shifted | `size` |
| `horizontal-slots` | Slots lying flat, with round ends | `length`, `thickness` |
| `vertical-slots` | Slots standing up | `length`, `thickness` |
| `square-grid` | Square holes | `size` |
| `hex-grid` | Hexagonal holes, flat or pointed at the top | `size`, `orientation` |
| `diagonal-slots` | Slots leaning 45 degrees | `length`, `thickness` |
| `slash` | Single slots rising to the right, `/`, in a box `length` wide and `height` tall | `length`, `height`, `thickness` |
| `backslash` | The same, falling, `\` | `length`, `height`, `thickness` |
| `sequence` | A short list of shapes, repeated | `items`, `pitch`, `length`, `height`, `thickness` |
| `arc-slots` | Curved slots on rings around the region's centre, for fan grilles | `rings`, `segments`, `thickness`, `gap` |

`size` is a hole's diameter, or the width of a square or hexagon; a pointed hexagon's `size` is its width across
the flats. `length` is a slot's length or a chevron's width, `height` a chevron's or a single slot's height,
`thickness` a slot's width or a chevron's band. A pattern takes only the settings in its row; another one is an
error.

- **`orientation`** is `flat` (the default: a flat edge at the top) or `pointy` (a point at the top). Turning a
  flat pattern with `rotation: 90` also turns its rows into columns; `pointy` does not.
- **A sequence** repeats `items` in order, every `pitch` millimetres: the shapes are spread evenly within one
  pitch. Each item is `{ shape }`, one of `chevron`, `chevron-inverted`, `slash`, `backslash`, drawn with the
  sequence's `length`, `height` and `thickness`, or with its own where the item writes them:
  `{ shape: chevron, length: 11 }`. 1 to 100 items. Each shape has its share of the pitch. A strip of V / Λ \ every 25.85 mm:

  ```yaml
  - cutout-sequence:
      width: 226.9
      height: 5.4
      mask:
        pattern:
          items: [{ shape: chevron }, { shape: slash }, { shape: chevron-inverted }, { shape: backslash }]
          pitch: 25.85
          length: 6
          height: 5.3
          thickness: 1.1
          clip: true
  ```


- **Arc slots** are `rings` rings of `segments` slots each, `thickness` wide, with `gap` clear between rings and
  between the slots of a ring. The rings fill the region's circle from its edge inwards.

Every pattern also takes:

| Setting | Meaning | Default |
| --- | --- | --- |
| `columns`, `rows` | How many openings across and down: whole numbers, 1 or more | as many whole openings as fit; chevrons, inline holes and both straight slots have one row |
| `gap-x`, `gap-y` | Clear space between neighbouring openings. Below 0, neighbours are closer than an opening is wide, as staggered columns of a honeycomb are; the pitch must stay above 0 | the pattern's own |
| `row-offset` | How far every other row is shifted, as a part of the horizontal pitch, 0 to 1 | 0; 0.5 for `round-staggered` and `hex-grid` |
| `column-offset` | How far every other column is shifted down, as a part of the vertical pitch, 0 to 1 | 0 |
| `alternate-columns` | `-1`, `0` or `1`: the second, fourth, … rows have one opening fewer, the same, or one more, centred on the rows between | 0 |
| `phase-x`, `phase-y` | Shift the whole pattern inside the region, as a part of the pitch, 0 to 1 | 0 |
| `clip` | `true`: openings carry on to the region's edge and are cut there, instead of whole openings being centred. `margin` is then 0 unless written | `false` |
| `ends` | The ends of a slot: `round`, `square` (cut square across the slot) or `cut` (cut level with the region's top and bottom). Slots, `slash`, `backslash`, `sequence` and `arc-slots` only | `round` |
| `margin` | The border kept uncut inside the region | 1 |

With these, most patterns of the hand-made faces are one cutout each: the CRS326's rows of 9 and 10 pointed hexagons
are `{ preset: hex-grid, orientation: pointy, columns: 10, alternate-columns: -1 }`; the MS120's staggered
columns are `column-offset: 0.5`.

**A round region.** A mask's `shape` cuts the pattern only inside a circle or a ring, centred in the region:
`shape: circle` is the largest circle the region holds; `shape: { ring: { outer, inner } }` is a ring with those
diameters in millimetres, `0 ≤ inner < outer`, and `outer` no larger than the region's shorter side. Openings
that cross the edge are cut there when `clip` is `true`, and left out when it is not. `shape` works with a
`pattern`, a `path` and an `image`; a mask with a `shape` and none of them is the plain circle or ring, cut out.
The defaults of each pattern are published with the spec, with the primitives (5.3).

**Writing one.**

- `cutout-<pattern>` is a part of its own, with the pattern's defaults: `- cutout-hex-grid`.
- To change a setting, give the part a `pattern`. On a `cutout-<pattern>` part the pattern's name is already known
  and `preset` is left out; a different `preset` there is an error.
- **The short form.** A cutout part, `cutout-<pattern>` or `mask`, writes the mask's keys among its own options:
  `pattern`, `path`, `view-box`, `image`, `mode`, `shape`, `depth`, `interior`. The long form puts the same keys
  in a `mask` map. A part uses one form or the other; the same key in both places is an error.

  ```yaml
  - cutout-horizontal-slots: { width: 74.4, height: 4, pattern: { length: 74.4, thickness: 1.8, columns: 1 } }
  - mask: { width: 30, height: 30, pattern: hex-grid, shape: circle, depth: 0 }
  # the same, in the long form
  - cutout-horizontal-slots: { width: 74.4, height: 4, mask: { pattern: { length: 74.4, thickness: 1.8, columns: 1 } } }
  - mask: { width: 30, height: 30, mask: { pattern: hex-grid, shape: circle, depth: 0 } }
  ```

  `rotation` is the one key the short form does not take: among a part's options it turns the part. To turn the
  pattern inside a region that stays as written, use the long form, `mask: { rotation: 90, pattern: … }`.
- The `mask` part takes any pattern: `pattern: { preset: round-staggered, size: 3 }`. When only the name is
  needed, `pattern: round-staggered` is the short form.
- In the exact form a cutout is a block: `{ kind: cutout-square-grid, x: 220, y: 8, width: 90, height: 28 }`.
- The defaults of the four newer patterns: `slash` and `backslash` 4 by 5 with `thickness` 0.7; `sequence` the
  MikroTik strip above at 4 by 5, `thickness` 0.7; `arc-slots` 3 rings of 8, `thickness` 1, `gap` 1. Every pattern's
  defaults are published with the primitives (5.3).

**The rest of a mask** applies to a pattern as to a path: `depth` is the wall's depth, 0.6 by default and 0 for a
flat opening; `interior` is the colour seen through the holes, and `transparent` shows what is behind the face;
`rotation` turns the pattern by 0, 90, 180 or 270 inside the region, which stays as written.

A mask has exactly one source of openings: a `pattern`, a `path` or an `image`, or only a `shape`. `view-box`
belongs to a path and `mode` to an image.

**Errors.** A reader refuses:

- a pattern it does not know, and a setting the pattern does not take;
- a count (`columns`, `rows`, `rings`, `segments`) that is not a whole number from 1 to 10,000;
- a measurement (`size`, `length`, `height`, `thickness`, `pitch`) that is not above 0, a `gap` or `margin` below 0, and a
  `gap-x` or `gap-y` that is not a number;
- `row-offset`, `column-offset`, `phase-x` or `phase-y` outside 0 to 1, and `alternate-columns` other than -1, 0
  or 1;
- an `orientation`, an `ends` or a sequence shape it does not know, `clip` that is not `true` or `false`, and a
  sequence with no items or more than 100;
- a `shape` that is not `circle` or a ring, and a ring whose diameters are not `0 ≤ inner < outer`;
- a mask with two sources, or with no source and no shape.

The renderer checks what needs the pattern's defaults or the region's size: a slot thicker than it is long, a
chevron or single slot whose band closes its opening, a sequence `pitch` too short for its shapes, a ring wider
than its region, counts that do not fit, a region too small for one opening, and more than 10,000 openings in a
region.

**`mask` is two words here.** In a list of parts, an entry whose only key is `mask` is the part. Inside a part's
options, `mask` is the option that holds the shape. The short form avoids the second.

A region inside a container with `fit: contain` is scaled with it, openings and gaps included. An outline that
no regular pattern describes is still a `path` or an `image`.

### 7.10 Assemblies

An assembly is a part the library builds from several drawings at a measured size: a frame with a handle,
latch, vent and lights. `width` and `height` are the whole assembly as measured on the device; the drawings
inside keep their own sizes and are placed within it.

```yaml
faces:
  rear:
    layout:
      - psu-module: { id: supply1, port: psu1, width: 100, height: 40, handle: { style: loop, side: right }, latch: { side: left, color: "#80b841" } }
      - drive-bay: { id: bay1, width: 101.1, height: 26.9, vent: { preset: horizontal-slots, length: 10, thickness: 1.4 } }
      - fan-module: { id: fan1, width: 40, height: 40, grille: { mask: { pattern: { preset: hex-grid, size: 2 } } } }
```

| Kind | Is | Its own options |
| --- | --- | --- |
| `psu-module` | A hot-swap power supply: frame, inlet, handle, latch, vent, and AC and DC lights | `port`, `inlet`, `inlet-position`, `inlet-rotation`, `orientation`, `handle`, `latch`, `vent`, `vent-region`, `lights` |
| `drive-bay` | A drive caddy: frame, latch button, release switch, handle, vent and a status light | `orientation`, `handle`, `latch`, `vent`, `color` |
| `fan-module` | A fan tray: frame, four captive screws, a fan turning behind its grille, and a status light. At least 24 × 24 | `grille`, `color` |
| `handle` | A pull handle | `handle`, `color` |
| `knockout` | A round scored disc in the panel | `punched`, `color` |
| `rating-plate` | A framed plate of printed text, with a QR code | `text` (several lines, 7.11), `qr` |
| `ground-stud` | A screw with the earth symbol ⏚ | |

A `psu-module` must hold its inlet with 2 mm clear all round; there is no other least size.

| Option | Meaning | Default |
| --- | --- | --- |
| `port` | `psu-module` only: the id of the model's port that is the supply's inlet. The port is drawn there with its own drawing, and counts as placed on this face | none: the inlet is drawn as a part |
| `inlet` | `psu-module` only: the inlet's drawing, `c14`, `c20` or `dc` | `c14` |
| `inlet-position` | `psu-module` only: where the inlet sits in the frame, as a `position` (7.4) | at the left, centred down; with `vertical`, at the bottom, centred across |
| `inlet-rotation` | `psu-module` only: 0, 90, 180, 270. The inlet keeps its size and turns | 0 |
| `vent-region` | `psu-module` only: `{ x, y, width, height }` within the frame, millimetres, for the vent | what the inlet, handle and latch leave |
| `orientation` | `horizontal` or `vertical`. On a supply, `vertical` puts the vent above the inlet; on a drive bay, the long side runs down and the mechanics turn with it | `horizontal` |
| `handle` | `loop`, `flat` or `none`, or `{ style, side }` with `side` one of `left`, `right`, `top`, `bottom` | `loop`, on the right |
| `latch` | `{ side, color }`, or `false` for none | on the left, green |
| `vent` | A pattern (7.9), as in a mask's `pattern`, or `false` for none | the kind's own |
| `grille` | `fan-module` only: `{ mask: … }`, as on a fan (7.6) | hexagons |
| `lights` | `psu-module` only: a list of `{ id, position, shape, color }` in place of the AC and DC lights, or `[]` | `ac`, `dc` |
| `punched` | `knockout` only: `true` cuts the disc out, as an opening | `false` |
| `qr` | `rating-plate` only: an image (7.8) holding the code, quiet zone included. Nothing is generated | none |

- **Ids.** An assembly's inner parts are named under its id: `<id>/frame`, `<id>/handle`, `<id>/latch`,
  `<id>/vent`, and its lights and fan (`supply1/ac`, `supply1/dc`, `bay1/status`, `fan1/fan`). An assembly in a
  face therefore needs an `id` when there are two of the same kind.
- **Ports.** Only `psu-module` holds a port, and only through `port`. The port must be on the face's side, and
  is placed once, there or elsewhere, never both. It keeps its own id, and is drawn with the assembly's `inlet`
  at that drawing's own size. A supply with no `port` draws its inlet as a part that nothing connects to.
- **Forms.** Assemblies are written in the layout form, simple or extended. In the exact form they are an error
  for now.
- Every assembly also takes the block options of 7.6: `margin`, `align-self`, `caption`, `cell`, `span`,
  `position`, `rotation`.

### 7.11 Captions and text

**Captions.** Any port, part, light list or assembly can carry a caption: text printed beside it, on one side.
A caption is part of the item: its size counts in what the item asks for (3.6.4), so neighbours keep clear of it.

```yaml
- console: { caption: { text: CONSOLE, side: above } }
- psu-module: { id: supply1, port: psu1, width: 100, height: 40, caption: "PSU 1" }
```

| Key | Meaning | Default |
| --- | --- | --- |
| `text` | What is printed. It may hold line breaks | required |
| `side` | `above`, `below`, `left`, `right` | `below` |
| `gap` | Between the item and the text, millimetres | 1 |
| `text-style` | As for a label: `size`, `line-height`, `align`, `weight` | type 2.5 mm |

`caption: "PSU 1"` is short for `caption: { text: "PSU 1" }`. A port's `label` (its printed number) and its
caption are separate: a port may have both.

**Size.** A caption's type is 2.5 mm unless its `text-style` says otherwise. Its text is as tall as its lines:
1.2 times the type size for the first, and `line-height` for each one after. It is as wide as its longest line,
which the renderer measures from its font. Above or below, the item and its caption are as wide as the wider of
the two, and as tall as the item, the `gap` and the text together; the item is centred across. Left or right,
the same with the axes exchanged, and the item centred down.

**Several lines.** The text of a label, a logo, a caption, a light's name and a rating plate may hold line
breaks, written as a YAML block or with `\n`:

```yaml
- rating-plate:
    width: 60
    height: 18
    text: |
      M/N USW-Pro-24
      Ubiquiti Inc.
      CE UKCA
```

`text-style.line-height` is the distance between lines in millimetres, 1.2 times the type size by default.
Text that needs more lines than its part's height holds is an error for the renderer.

**Symbols.** Every renderer draws these in any text, whatever the font: ⚡ (power), ⊖ and ⊕ (polarity),
● (a dot) and ⏚ (earth).

### 7.12 Where the library differs today

The library was brought in line on 2026-11-11: ears are outside the face, a sequence's shapes take their own
size, sockets are ports, stops exist. What is left is naming, which the compiler maps:

| Point | This spec | The library | To be the same |
| --- | --- | --- | --- |
| A supply's inlet port | `port` | `portId`, defaulting to the assembly's id | Compiler maps |
| A light list's name | `leds` | `indicators` | Compiler maps |
| Overlay | `overlay` | `direction: stack` | Compiler maps |
| A part on an ear | Its own id | `ears/left/<id>`, `ears/right/<id>` | Compiler maps |
| A server template's ports | The model's ids, given in lists | Its own: `network-1`, `management`, `slot-1/port-1`, `psu-1-input` | Compiler maps |
| A server template's counts | Follow from the lists; nothing listed, nothing drawn | Defaults: two USB, two LAN, a management port, VGA, a card, one or two supplies | Compiler writes every count |

## 8. Overwriting a model

```yaml
models:
  office/core:
    extends: cat:mikrotik/crs326-24g-2s-plus-rm
    name: Office core
    ports:
      sfp-sfpplus2: null
      ether24: { poe: bt }
      ether1..8: { group: Desks }
    faces:
      front: { finish: black }
```

A model with `extends` is a new model in this file. The model it extends is not changed (4.5). The result is
built in layers: the base model, then this one on top.

**Scope.** Everything inherited keeps the meaning it had in the file that wrote it. If the base says
`type: optical` and means its own file's `optical`, the derived model's port has that type even when the
derived file defines another `optical`. The same holds for `module`, `primitive`, face and part references,
and images.

**Ports.**

1. In each layer, ranges are expanded first. Two keys in one layer that give the same port id are an error
   (`ether1..8` and `ether8` in the same `ports` map).
2. Placeholders in a layer are filled with the numbers from that layer's own range.
3. The layers are then merged port by port, by id. A field written in the upper layer replaces the same field
   below; other fields are kept.
4. `null` removes the port. Removing a port that the base does not have is an error.

So in the example, `ether24` keeps its type and label from the base's `ether1..24` and gains PoE; `ether1` to
`ether8` gain a group; `sfp-sfpplus2` is gone.

**Other fields.** Maps merge by key. Single values replace. Lists replace as a whole. `null` removes a field.
`passthrough` is a list and so replaces as a whole; an entry that names a removed port is an error.

**Body.** `faces.body` is a single value: the upper layer's replaces the inherited one, and `null` removes it
(6.6). It is handled apart from the two faces.

**Faces.** Each face, `front` and `rear`, is handled on its own.

1. A face written by reference is resolved first, in the file that wrote the reference. From here on it is
   treated exactly as if it had been written inline.
2. The face's settings merge: `finish`, `background`, `padding`, `mounting-holes`.
3. The face's content is one unit. It is whichever of `layout`, `exact` or `template` the face has, whole,
   however it is spelled. If the upper layer writes any one of them, it replaces the inherited content
   entirely, including when it is a different form. If the upper layer writes none, the inherited content is
   kept.
4. An upper layer that names a face by reference replaces the whole face, settings and content.
5. `front: null` removes the face; the model then draws that side as generated.
6. Model placeholders in the face (`{name}`, `{vendor}`, `{model}`) are filled now, from the merged model.
7. After merging, the face is checked against the merged ports: it must place every port of its side exactly
   once. Removing a port that an inherited face places is therefore an error until the face is replaced.

So `front: { finish: black }` repaints an inherited face whether the base wrote it inline or by reference.

- An `extends` cycle is an error.
- Changing one part inside an inherited layout is not in this version. Restate the content.

## 9. What exists

Racks, devices and links are written at the top level of a file. A device's port settings are written inside
the device. They are the facts: each is
defined once, in one place, and belongs to no scene. Scenes (section 11) only show them.

### 9.1 Devices

```yaml
devices:
  core:  { model: cat:mikrotik/crs326-24g-2s-plus-rm, title: Core switch, in: main, u: 9 }
  nas:   { model: nas-4bay, in: main/tray, order: 1 }
  ont:   { model: modem, in: main/tray, order: 2 }
  modem: { model: dsl-modem, on: nas }
  pc:    { model: mini-pc, in: main/top }
  ap:    { model: wifi-router }
```

| Field | Meaning |
| --- | --- |
| `model` | A model id. Required |
| `title` | What people call this unit (9.5). Without one it is called by its `name`, and with neither by its model's `name` |
| `description` | What it is for, in a sentence or a few (9.5) |
| `name` | The unit's own name. `{name}` writes it in the unit's port labels, where a unit with no name is its id (3.2) |
| `label` | A printed label stuck on it (9.4) |
| `note` | A sticky note on it (9.4) |
| `sticker` | A sticker on it (9.4) |
| `ports` | Settings for this unit's ports (9.2) |
| `in` | A rack, a rack's shelf (`main/tray`), or the top of a rack (`main/top`) |
| `u` | The lowest rack unit it occupies, counted from the bottom, starting at 1 |
| `on` | Another device this one stands on |
| `x` | Millimetres from the left edge of its shelf to its left edge |
| `order` | Its turn among the devices on the same shelf, when `x` is not given. Default 0 |

- A device id is unique in its file. Another file reaches it as `core`, or as `name:core` through a named
  import (4.4).
- Where a device is mounted is a fact about the device, so it is written here and not in a scene. Which side
  of it is shown is a choice of the picture, so it is written in the scene (11.2).

**Where a device can be.** Exactly one row applies; any other combination is an error.

| Written | Means | Allowed for | Must hold |
| --- | --- | --- | --- |
| `in: rack`, `u` | Mounted on the rails | A model whose `mount` equals the rack's `width` class (9.3) | The rack type has rails; the units it needs are inside the rack and free; its body is no wider than the rack's `opening` |
| `in: rack/shelf` | Standing on a rack shelf | Any model | The shelf holds its row, or is unlimited; `x` or `order` optional |
| `in: rack/top` | Standing on top of the rack | Any model | The top holds its row; `x` or `order` optional |
| `in: rack`, no `u` | Standing on a `shelf` or the top of a table | Any model | The rack type is `shelf` or `ikea-lack`; as for a shelf |
| `on: device` | Standing on that device | Any model | No `in`, `u`, `x` or `order`; no cycle |
| none of these | Free-standing | Any model | A scene's layout places it |

**What takes rack units.**

| Thing | Units it takes |
| --- | --- |
| A mounted device | its model's `size.units`, upward from `u` |
| A rack shelf | its `units` (default 1), upward from its `u` |
| A panel | its `units` (default 1), upward from its `u` |
| A device on a shelf or on a device | none of its own |

Two things may not take the same unit of one rack.

**On a shelf.** A shelf is a container (3.6). Its devices stand in a row, in increasing `order` and then by id,
placed by the shelf's `gap`, `justify`, `align` and `padding` (9.3). A device with `x` is pinned at that
distance from the shelf's left edge and takes no part in the row.

A shelf holds real things, so it has rules a drawing container does not:

- **No overlap.** No two devices on a shelf may overlap, pinned or not. The row does not move aside for a
  pinned device; an overlap is an error.
- **Width.** A limited shelf must hold its row and every pinned device within its width. An unlimited shelf is
  as wide as the larger of its row and the right edge of its right-most pinned device, plus padding.
- **Height.** What stands on a shelf has a height: the tallest device there, with everything stacked on it.
  Above a rack shelf it must fit below the next taken unit, or below the top of the rack when nothing is above.
- **A growing rack.** With `units: grow`, the rack is as tall as the highest taken unit, or the top of the
  tallest thing standing on any of its shelves rounded up to a whole unit, whichever is higher.
- **Shelving and cabinets.** With `height: grow`, each level is as tall as what stands on it.

**Stacks.** A device with `on` stands centred on the device below. At most one device stands directly on
another: two devices with the same `on` are an error. A stack may be several high, written as `a on base`,
then `b on a`. `a on b` with
`b on a`, or any longer cycle, is an error. A stack is shown and moved as one: a scene that shows a device
brings everything standing on it.

### 9.2 Ports on a device

Settings for one unit's ports are written inside the device, keyed by port id. A key may be a range (3.2).

```yaml
devices:
  core:
    model: office/core
    in: main
    u: 9
    ports:
      ether24:     { label: UPLINK }
      sfp1:        { module: s+rj10 }
      ether20..23: { plug: true }
```

| Field | Meaning |
| --- | --- |
| `label` | A printed label for the port, shown beside the manufacturer's (9.4) |
| `note` | A sticky note on the port (9.4) |
| `sticker` | A sticker on the port (9.4) |
| `module` | A module id, or `{ module: qsa, holds: … }` for a module inside an adapter |
| `plug` | `true` for a dust plug, or `{ color, label }` |

- A port that the model does not have is an error. Adding or removing ports is done on the model (section 8).
- There is no other place for these settings. A device is described whole in its own entry, so collecting or
  importing a device brings its port settings with it, and no file can set ports on a device it did not define.
- Elsewhere a port is still named `device/port`: in a link's `ends`, and in a rack or scene that refers to it.

### 9.3 Racks

```yaml
racks:
  main:
    type: rack-cabinet
    units: 12
    door: glass
    shelves: { tray: { u: 3 } }
    panels:
      brush-6: { u: 6, type: brush }
      vent-1:  { u: 1, type: vent, grille: mesh }
    rings:
      left-3: { side: left, u: 3 }
  wall:  { type: open-rack, units: 6, width: 10in }
  table: { type: ikea-lack, units: 8 }
  desk:  { type: shelf, surface: wood, width: 700 }
  store:
    type: shelving
    shelves: { upper: { level: 3 }, middle: { level: 2 }, lower: { level: 1 } }
```

| Type | What it is | Rails |
| --- | --- | --- |
| `open-rack` | Bare rails in an open frame | Yes |
| `rack-cabinet` | Framed rack with side panels and a door | Yes |
| `ikea-lack` | A table with gear in the legs, on top, or both | Yes, in the legs |
| `cabinet` | General enclosure for shelves and desktop devices | No |
| `shelving` | A column of shelves | No |
| `shelf` | One board that devices stand on | No |

| Field | Meaning | Default |
| --- | --- | --- |
| `units` | Height in rack units, for the types that have rails: a number, or `grow` for a rack as tall as it needs to be. Required for them | |
| `width` | With rails: the mounting class, `19in` or `10in`. Without rails: millimetres, or `grow` | `19in`; `grow` |
| `opening`, `rail-width` | With rails: the clear width between the rails and the width of each rail, millimetres, for an unusual cabinet. They do not change the mounting class. A device's body must still pass through: a body wider than `opening` is an error, checked apart from the class | 454.6 and 14 for `19in`; 236 and 9 for `10in` |
| `door` | `none`, `open`, `glass`, `mesh`, `solid` | by type |
| `finish` | `white`, `black`, `stainless-steel` | by type |
| `mounting` | `rails` or `legs` | by type |
| `shelves` | A map of shelves by id. In a rack with rails each has `u` and optional `units`. In `shelving` each has `level`, counted from the bottom starting at 1. Every shelf also takes the shelf settings below, and a `title` and a `description` (9.5) | none |
| `top` | Shelf settings for the top of the rack | defaults |
| `height` | For `shelving` and `cabinet`: millimetres, or `grow` | `grow` |
| `surface` | For a shelf: `metal` or `wood`, or `{ material, color, thickness }` | black metal |
| `panels` | A map of blanks, vents and brush strips by id; each has `u`, `type` (`blank`, `vent`, `brush`), optional `units`, `grille`, `finish`, `title`, `description` | none |
| `rings` | A map of cable rings by id; each has `side` (`left`, `right`), `u`, and optional `z`: how far in front of the face it holds its cables, millimetres (10.4), 32 by default. A ring stands just outside the frame on its side, level with the middle of unit `u`. It also takes a `title` and a `description` | none |
| `rear-cables` | `left`, `right` or `nearest` | `nearest` |
| `frame` | Overrides for the enclosure: `frame`, `top`, `bottom`, `background`, `interior` | by type |
| `title` | What the rack is called (9.5) | its id |
| `description` | What it is for, in a sentence or a few (9.5) | none |
| `note` | A sticky note on the rack (9.4) | none |
| `sticker` | A sticker on the rack (9.4) | none |

- Shelves, panels and rings are named, so a route can pass through them: `main/brush-6`, `main/left-3`.
  Their ids, and the word `top`, are unique within a rack.
- Every rack has a `top`: `in: main/top` stands a device on it.
- Panels have no ports, so they are not devices. Patch panels have ports, so they are models and devices.
- `units` is required for a rack with rails, as a number or as `grow`. A numbered rack never grows to fit what
  is put in it; that is what `grow` is for (3.6.3).

**Shelf settings.** A shelf is a container. These are written on a shelf in `shelves`, on `top`, or on a rack
of type `shelf`.

```yaml
racks:
  main:
    units: grow
    shelves:
      tray: { u: 3, justify: space-between, padding: { x: 20, y: 0 } }
    top: { justify: center, gap: 30 }
  desk: { type: shelf, width: grow, gap: 40, surface: wood }
  wide: { type: shelf, width: 1200, justify: end }
```

| Setting | Meaning | Default |
| --- | --- | --- |
| `width` | Millimetres (limited), `grow` (unlimited) or `fill` (the rack's opening) | `fill` in a rack; `grow` on its own |
| `gap` | Least distance between devices | 12 |
| `justify` | `start`, `end`, `center`, `space-between` | `start` |
| `align` | `start`, `center`, `end`: where a short device sits against a tall one | `end`, on the board |
| `padding` | Clear space at the edges | `{ x: 8, y: 0 }` |
| `surface` | `metal` or `wood`, or `{ material, color, thickness }` | black metal |

To spread devices across the full width, use `justify: space-between`. To keep them a fixed distance apart, set
`gap`. Section 3.6 says exactly how each is drawn.

### 9.4 Labels and notes

There are four kinds of marking, and each has one place.

| Kind | Who made it | Written | Can be on |
| --- | --- | --- | --- |
| Manufacturer's label | The maker, printed on the panel | In the model: a port's `label`, and `label` and `logo` parts in a face | A port, the panel |
| Printed label | You, on a label printer | `label` on a device, on a port in `ports`, or on a link | A device, a port, a cord |
| Sticky note | You, by hand | `note` on a device, a port, a link or a rack; `notes` in a scene | A device, a port, a cord, a rack, or a spot in a scene |
| Sticker | You: a symbol or a picture | `sticker` on a device, a port or a rack; `stickers` in a scene | A device, a port, a rack, or a spot in a scene |

All four are on the equipment or in the picture. What a thing is called and what it is for, said in words and
stuck on nothing, are its title and description (9.5).

**Printed labels.**

```yaml
devices:
  core:
    model: office/core
    title: Core switch
    label: SW-CORE-01
    in: main
    u: 9
    ports:
      ether24:    { label: UPLINK }
      ether1..8:  { label: { text: "D-{n:02}", color: yellow } }
links:
  uplink: { ends: [core/ether24, modem/lan], label: { text: ISP-1, at: both } }
```

| Field | Meaning | Default |
| --- | --- | --- |
| `text` | What is printed. The short form `label: SW-CORE-01` is the text alone | required, or `icon` on a cord |
| `color` | Tape colour: a name or a hex colour | white |
| `size` | Text height, millimetres | by what it is on |
| `anchor` | On a device or port: `top`, `bottom`, `left`, `right` (just outside that edge) or `center` (over it) | `center` on a device; `top` on a port |
| `offset` | `{ x, y }` in millimetres, added after `anchor` | none |
| `rotation` | Degrees | 0 |
| `width`, `height` | Size of the tape, millimetres | fitted to the text |
| `side` | On a device: `front` or `rear` | `front` |
| `at` | On a link: `from`, `to` or `both` ends | `both` |

- A printed label never replaces the manufacturer's label. A port shows both.
- A device's `title` is what lists and pictures call it. Its `label` is the physical label stuck on it. Either
  may be left out.
- Placeholders in the text follow 3.2.

**Sticky notes.** A note is written on the thing it is stuck to, with `note`. A note that belongs to one
picture only is written in that scene.

```yaml
devices:
  core:
    model: office/core
    note: "Do not power off before 18:00"
    ports:
      ether7: { note: flaky }
links:
  uplink: { ends: [core/ether24, modem/lan], note: { text: "replace with cat6a", color: pink } }
racks:
  main: { units: 12, note: "Key is with reception" }

scenes:
  closet:
    notes:
      todo: { text: "Tidy this rack", position: { right: 40, top: 40 } }
```

| Field | Meaning | Default |
| --- | --- | --- |
| `text` | The note. May have line breaks. The short form `note: flaky` is the text alone | required |
| `color` | `yellow`, `pink`, `green`, `blue`, or a hex colour | `yellow` |
| `position` | In a scene's `notes` only: where it sits in the scene, as in 7.4 | required there |

- `note` may be a list when a thing carries several.
- A note on a device, port, link or rack is drawn in every scene that shows that thing.
- A note in a scene's `notes` belongs to that picture only.
- A scene can leave all notes out with `notes: false`.
- Notes and printed labels never change a model.

**Stickers.** A sticker is a symbol or a picture with no text: a warning triangle on a power supply, an asset
tag with a QR code, a coloured dot.

```yaml
devices:
  ups:
    model: ups-2u
    sticker: { icon: warning, anchor: right }
    ports:
      outlet1: { sticker: { icon: power, color: red } }
  core:
    model: office/core
    sticker:
      - { icon: lock }
      - { image: ./asset-0042.png, width: 20, height: 20, anchor: left }
racks:
  main: { units: 12, sticker: { icon: info } }

scenes:
  closet:
    stickers:
      fire: { image: ./fire-exit.svg, width: 60, height: 30, position: top-right }
```

| Field | Meaning | Default |
| --- | --- | --- |
| `icon` | One of the built-in symbols: `network`, `fiber`, `power`, `warning`, `lock`, `info` | one of `icon` and `image` is required |
| `image` | Your own picture (4.8) | |
| `color` | The symbol's colour. An image keeps its own | by icon |
| `background` | The sticker's paper colour | white |
| `width`, `height` | Millimetres | 10 by 10 |
| `anchor`, `offset`, `rotation`, `side` | As for a printed label | `center` on a device; `top` on a port |
| `position` | In a scene's `stickers` only, as in 7.4 | required there |

- `sticker` may be one sticker or a list.
- The short form `sticker: warning` is the icon alone.
- A cord has no sticker. A printed label on a cord may take `icon` in place of `text`.
- A sticker on a device, port or rack is drawn in every scene that shows that thing. A sticker in a scene's
  `stickers` belongs to that picture only.
- Markings stuck to equipment are drawn under cables and behind a cabinet door, as real ones are. Markings
  placed in a scene are drawn over everything.

### 9.5 Titles and descriptions

A rack, a rack's shelf, panel or ring, a device, a link and a scene may each say what it is called and what it
is for.

```yaml
racks:
  main:
    type: rack-cabinet
    title: Comms cabinet
    description: By the door of the server room. The key is with reception.
    units: 12
    shelves: { tray: { u: 3, title: The provider's shelf } }
devices:
  core:
    model: office/core
    title: Core switch
    description: Feeds the first floor.
    in: main
    u: 9
links:
  uplink: { ends: [core/ether24, modem/lan], title: Uplink to the provider }
scenes:
  closet:
    title: Comms closet
    description: |
      The cabinet as it stands today.
      The modem moves to the tray in December.
    layout: [main]
```

| Field | Meaning |
| --- | --- |
| `title` | What people call it. One line |
| `description` | What it is, or what it is for: a sentence or a few. May have line breaks |

- **Plain text.** Both are read as the characters written, so `title: 2026` is the title "2026". There is no
  markup in them and no placeholder: braces are plain characters (3.2). A line break at the very end, which a
  block scalar leaves, is not part of the text.
- **Not empty.** A thing with no title has no `title` key; `title: ""` is an error. The same for a description.
- **Words, not facts.** They change nothing that is checked and nothing that is drawn on the equipment. What is
  stuck on a device is a label, a note or a sticker (9.4).
- **Where they show.** A tool that names a thing uses its title: in a list, in a message, beside the picture.
  It shows a description where there is room for one. A picture carries them where its format has a place for
  words: an SVG has its scene's title and description as its `<title>` and `<desc>`, and each device's title as
  the `<title>` of that device's drawing.
- **With no title** a thing is called by its id. A device is called by its `name` (9.1), and with no name by its
  model's `name`. These are defaults that come from an id, so a bundle writes them out (4.8).
- **Who takes neither.** A device's port, the top of a rack, a route, and the definitions: models, types,
  modules, cable types, parts and faces. A port has its label and its note (9.2); a definition has its `name`.
  The overview (11.5) is not a scene and has neither.
- **A scene in a scene.** A scene placed in another (12.1) keeps its title and description to itself. The
  picture is called by the scene that is drawn.

## 10. Links

A link is one cable. Two ends are a complete link. Links are written at the top level, like devices.

```yaml
links:
  uplink: { ends: [core/ether24, modem/lan] }
  store:  { ends: [core/ether1, nas/network-1], cable: cat6, color: blue, length: 0.5 }
  fibre:  { ends: [core/sfp-sfpplus1, edge/sfp1], cable: lc-sc }
  spare:  { ends: [core/ether2, { loose: 300 }], cable: cat6 }
```

| Field | Meaning |
| --- | --- |
| `ends` | Two port references, or one and `{ loose: mm }` for a cable hanging free; `{ loose: mm, z: mm }` holds the free end that far in front of the face (10.4), 32 by default. The first is `from` and the second is `to`, wherever those words are used: a label's `at`, a route's `from-exit` and `to-exit`, and which end of a cable with two different ends goes where |
| `cable` | A cable type (10.1). Default: chosen by 10.3 |
| `color` | A name or a hex colour |
| `length` | Metres, for the patch schedule. It does not change the drawing; a route's `length` does (11.4) |
| `label` | A printed label on the cord (9.4) |
| `note` | A sticky note on the cord (9.4) |
| `title` | What the cable is called (9.5) |
| `description` | What it is for, in a sentence or a few (9.5) |

An end may be a port of a device from an import (4.5).

### 10.1 Cable types

A cable type says what is at each end, so that a tool can tell what it plugs into.

```yaml
cables:
  cat6-blue: { extends: cat6, color: blue }
  lc-sc:     { name: LC to SC duplex, ends: [lc, sc] }
  dac-1m:    { name: SFP+ DAC, ends: [[sfp+, sfp28], [sfp+, sfp28]], into: cage }
```

| Field | Meaning | Default |
| --- | --- | --- |
| `name` | The name shown | the id |
| `ends` | Two entries, one per end. Each is the list of endpoints that end accepts; a single name is short for a list of one. Required | |
| `into` | What kind of endpoint the names in `ends` are. `connector`: connectors, as a port type or module presents them (`rj45`, `lc`). `cage`: empty cages (`sfp+`, `sfp28`), for a cable whose end is itself the module | `connector` |
| `default` | `true`: this type may be chosen when a link names no cable (10.3) | `false` |
| `color` | Default colour of the jacket | by type |
| `connector-color` | Colour of the plugs | by type |
| `width` | Thickness of a round cable, or the width of a flat one, millimetres | by type |
| `cross-section` | `round` or `flat` | `round` |
| `thickness` | A flat cable's thickness, millimetres, above 0 | 1.4 |
| `roll` | A flat cable's turn about its length, degrees | 0 |
| `stiffness`, `weight`, `flexibility` | How the cable hangs and bends | by type |
| `slack` | How far it hangs, millimetres: the starting shape from which its length is found when no route gives one (10.4) | 18 |
| `end-length` | Straight run out of each plug before it bends, millimetres | by type |
| `min-bend-radius` | The tightest it may bend, millimetres: a crowded cable may go down to this, never below | by type |
| `bend-radius` | The radius it bends at when free, millimetres, from its datasheet: its loops and hangs are this round | `min-bend-radius` |
| `extends` | Another cable type to start from | |

Built in:

| Id | Ends | Into | Default |
| --- | --- | --- | --- |
| `cat6`, `cat6-flex`, `cat6-stiff`, `cat6-flat` | `rj45`, `rj45` | connector | `cat6` |
| `lc-duplex` | `lc`, `lc` | connector | yes |
| `sc-simplex` | `sc`, `sc` | connector | yes |
| `mpo` | `mpo`, `mpo` | connector | yes |
| `dac` | any of `sfp`, `sfp+`, `sfp28` at each end | cage | yes |
| `dac-qsfp` | any of `qsfp+`, `qsfp28` at each end | cage | yes |
| `iec-power` | `c13`, `c14` | connector | yes |

Each built-in type is a real cable of its kind: its jacket, both bend radii and its weight are measured values
from a manufacturer's datasheet (a 24 AWG Cat 6 patch cord is 5.66 mm thick and bends at 26.4 mm when free; a
2 mm LC duplex cord 10 mm at the tightest). A renderer draws it that way unless the type says otherwise. For
copper the tightest radius is about twice the jacket, since a cord crowded at a switch does bend tighter than
its installation guideline; for fibre, direct-attach and coax it is the datasheet's, as tighter bends cost
signal.

**Your own cables.** Any file can define cable types, from nothing or with `extends`. A cable type carries
everything about how the cable is drawn, so a new one is complete in YAML. These settings are written on the
type and not on a link: a link chooses a type and may change `color`, and a route may change `slack` and give
`length`.

### 10.2 What is at a port

A port presents at most one **endpoint**, worked out in this order:

| The port | Its endpoint |
| --- | --- |
| Has a type with neither `connector` nor `cage` | none; it cannot be an end of a link |
| Has a fixed connector (its type has `connector`) | that connector |
| Is a cage with no module | the empty cage |
| Is a cage with a module that has a `type` | the connector of that type |
| Is a cage with an adapter (`cage`) and nothing in it | the adapter's empty cage |
| Is a cage with an adapter holding a module | that module's connector, and so on down the chain |

An endpoint holds at most one thing: a cable end, or a dust plug. So:

| Case | Result |
| --- | --- |
| A module and a link | Valid |
| A module and a plug, no link | Valid; the plug is in the module's socket |
| A plug and a link on the same port | Error |
| Two links on the same port | Error |
| A module that does not fit the cage, or the adapter's cage | Error |

### 10.3 Does the cable fit, and which one

**Fit.** A cable end fits an endpoint when:

- the cable type is `into: connector`, the endpoint is a connector, and that connector is in the cable end's
  list; or
- the cable type is `into: cage`, the endpoint is an empty cage, and that cage is in the cable end's list.

A link is valid when one end of the cable fits one endpoint and the other end fits the other. For a cable with
two different ends, the first entry of the cable's `ends` goes with the first entry of the link's `ends`; if
that does not fit and the other way round does, it is an error that says to swap them.

**Not run yet.** The fit rule is defined here so files mean one thing, but the first implementation draws and
does not judge: it does not run the fit check, the module check of 10.2, or the mount-width check of 9.1. It
uses the rule only to choose a default cable. A link that names its `cable` is drawn as written.

This is physical fit only. In this version nothing checks that speeds agree, that optics match in wavelength or
mode, or that a module suits its host. Those checks are named in section 22.

**Default.** When a link names no `cable`:

1. Take the places a cable type can come from, in resolution order (4.4): this file, each import in order,
   the built-ins.
2. A cable type whose id is also defined in an earlier place is shadowed and takes no part.
3. Go through the places in order. In each, look at the cable types with `default: true` that fit both
   endpoints.
4. The first place that has any decides. If it has exactly one, that is the cable. If it has more than one, it
   is an error that names them, and the link must name its `cable`.
5. If no place has one, it is an error and the link must name its `cable`. A link with a `loose` end must
   always name it.

### 10.4 How cables are drawn

A cable is drawn as the physical thing: a jacket of fixed length, laid in space together with every other cable
in the scene. There is no other way to draw one; a renderer does not fall back to a flat line.

- **Space.** Millimetres. `x` runs right and `y` down, as on the face; `z` comes out of the face in view, which
  lies at `z` 0. A device is a box from its face back to its `depth` (5.6). In a scene drawn from the rear, `z`
  comes out of the rear. Devices still line up by their fronts there: those in one rack, or on one shelving or
  cabinet, have their fronts level with the deepest one's, so a shallow device's rear sits back between deeper
  neighbours, and a rack's panels are with the fronts.
- **Ends.** A cable leaves each plug in a straight line, `end-length` long, along its socket's
  `cable-direction`, from `cable-offset` in front of the face (5.1). A loose end hangs from its `z` (10).
- **Length.** A route's `length` is the jacket's length in that scene (11.4). Without one, the length is found
  once, from a starting shape that hangs by `slack`, and then kept.
- **Bends and contact.** A free cable bends at its `bend-radius`; crowded, it bends no tighter than its
  `min-bend-radius`, nor tighter than its own thickness allows. It does not pass through another cable, a plug, a ring, a panel or a device's box.
- **Changing sides.** A cable with one end on the front and the other on the rear goes through a brush panel:
  the one its route names, or, when it names none and both ends are in one rack with a brush panel, the panel
  nearest its path. Otherwise it goes round the side of its rack, or of its device when that is not in a rack.
- **Rings and points.** A cable goes through the rings, brush panels and points of its route in order (11.4).
  A ring holds it at the ring's `z`; a point at its `z`, or at the cable's own depth when it has none.
- **Drawn.** Where cables cross, the one nearer is drawn over the other; a cable behind a device is hidden by
  it.

**When the cables cannot be laid** at their lengths and bend radii without one passing through another, or
through a device or a ring, the scene is not drawn. That is the error `cables-do-not-fit`, on one of the links
it concerns. A longer or shorter `length`, a different `slack`, a ring's `z` or a point in `via` usually lets
it be laid.

When a crowded scene cannot be laid as the real cables it has, a renderer may draw it otherwise, with a notice
instead of the error: with each cable bending as tight as its own thickness allows (`cables-bent-tighter`), or
with supple stand-ins for the built-in cable types (`cables-drawn-supple`). A cable whose every end is on the far
side of the view (rear ports in a front view, front ports in a rear view) runs behind the devices and is mostly
hidden; when even that does not fit, a renderer may also leave such cables out, with a notice for each one,
`far-cable-not-drawn`.

## 11. Scenes

A scene is a picture of some of what exists. It defines nothing: no device, rack, port setting or link is
written in a scene. It says what to show, where each thing stands, and how the cables are drawn.

```yaml
scenes:
  closet:
    title: Comms closet
    layout: [main, wall, ap]
    routes:
      store: { via: [main/left-3], from-exit: down }
```

| Field | Meaning |
| --- | --- |
| `title` | What the picture is called (9.5) |
| `description` | What it shows, in a sentence or a few (9.5) |
| `layout` | What is shown and where (11.1 to 11.3) |
| `notes` | Sticky notes for this picture only, or `false` to hide all notes (9.4) |
| `stickers` | Stickers for this picture only (9.4) |
| `routes` | How links are drawn here (11.4) |
| `background` | Behind the whole scene |
| `size` | `{ width, height }` in millimetres, when the scene should be larger than its contents |
| `view` | `front` (default) or `rear`, for every rack and device in the scene; an entry can override it (12.3) |

A file with no `scenes` is still drawable: see the overview (11.5).

### 11.1 Layout, the simple form

The layout places top-level things: racks, devices and other scenes. A device that is mounted in a rack comes
with its rack. It has the same two forms as a face layout, with the same words.

```yaml
layout:
  - main
  - wall
  - column: [ap, desk]
```

| Entry | Means |
| --- | --- |
| `main` | A rack, a device, or a scene, by id |
| `{ main: { view: rear } }` | The same, with options |
| `{ row: [ … ] }`, `{ column: [ … ] }` | A nested group; options go beside `items`, as in 7.1 |
| `{ grid: { columns, rows, items } }` | Equal cells; an item may give `cell` and `span` |
| `grow`, `{ space: 200 }` | Spare or fixed space |

What an entry shows:

| Named | Shown |
| --- | --- |
| A rack | The rack with everything mounted in it |
| A free-standing device | The device |
| A device that is mounted in a rack | The device alone, outside its rack, with its label, port labels, modules and plugs |
| A scene | Everything that scene shows, with its layout (section 12) |

A scene shows only what its layout names. Nothing is added by default once `layout` is written.

### 11.2 Layout options

Groups in a scene are containers. Their settings, their values and the way they are drawn are those of section
3.6 and are not repeated here. What is particular to a scene:

| Setting | On | In a scene |
| --- | --- | --- |
| `gap`, `padding`, `justify`, `align`, `grow`, `position` | group, entry | As in 3.6. Defaults: `gap` 60, `padding` 0 (35 at the root), `justify: start`, `align: end` |
| `width`, `height` | group | As in 3.6.3: a number, `grow` or `fill`. Default `grow` |
| `fit` | | Not available. A device and a rack keep their physical size |
| `background` | group | A colour, a material or an image |
| `frame` | group | An enclosure drawn around the group, for this scene only: a rack type that has no rails, with its options |
| `cell`, `span` | entry | In a grid |
| `view` | entry | `front` or `rear` (12.3) |

### 11.3 Layout, the extended form

```yaml
layout:
  direction: row
  gap: 80
  padding: 35
  align: end
  children:
    - item: main
    - direction: column
      gap: 0
      align: stretch
      children:
        - item: ap
        - item: desk
    - item: wall
      position: { right: 0, bottom: 0 }
```

| Simple | Extended |
| --- | --- |
| a list | `{ direction: row, children: [ … ] }` |
| `main` | `{ item: main }` |
| `{ row: … }`, `{ column: … }` | `{ direction: …, children: [ … ] }` plus the options |
| `{ grid: … }` | `{ layout: grid, columns, rows, children: [ … ] }` with a `cell` on each child |
| `grow` | `{ space: 0, grow: 1 }` |

### 11.4 Routes

A route says how one scene draws one link. Routes are per scene, because the same link is drawn differently
where the devices stand differently.

```yaml
routes:
  store:  { via: [main/left-3], from-exit: down }
  uplink: { via: [main/brush-6], slack: 40 }
  riser:  { hide: true }
```

| Field | Meaning |
| --- | --- |
| `via` | In order: a rack's ring or brush panel by id, or a point `{ x, y }` or `{ x, y, z }` (10.4). A brush panel is for a cable that changes sides; for one that does not it is left out, with a notice |
| `from-exit`, `to-exit` | `up`, `down`, `left`, `right` |
| `slack` | How far it hangs, millimetres, in place of the cable type's (10.1) |
| `length` | The length the cable is drawn with in this scene, millimetres, above 0 (10.4) |
| `hide` | `true`: do not draw this link in this scene |

**When a link is drawn.** A link is drawn in a scene when the device at each of its ends is present in that
scene. Present means the device is there, whichever side is in view.

| Case | Drawn |
| --- | --- |
| Both devices present, both ports on the side in view | As a cable between the two sockets |
| A port is on the side not in view | The cable crosses from front to back through a brush panel: the one the route names in `via`, or the rack's nearest one when it names none. A rack without one is passed round its left or right side, as `rear-cables` says (10.4). The part behind is hidden by what stands in front of it |
| One end is `loose` | When the device at the other end is present; the cable hangs from it |
| Only one of the two devices is present | Not drawn |

A link between a front port and a rear port is one cable that makes this crossing. Without a route it goes
round the side; `via: [main/brush-6]` sends it through that opening. A device outside a rack uses its own edge.

**Coordinates.** A point in `via` is in millimetres from the top-left of the scene that wrote the route. When
that scene is placed inside another (12.1), its routes move with it; nothing is recalculated by the author.

**A route written in two scenes.** When scene A places scene B and both write a route for the same link, A's
route is used in A, whole. Routes are not merged field by field. B drawn on its own still uses B's route.

A link with no route is drawn by the library's defaults. A tool that does not draw ignores `routes` and keeps
them on save.

### 11.5 The overview

A file is always drawable, with or without scenes. The **overview** is the picture a tool shows when none is
asked for.

- It is not a scene. It has no id, cannot be named in a layout, and takes no name away from racks or devices:
  a rack called `main` is fine.
- It shows the file's own racks, by id, then its own free-standing devices, by id, in one row.
- It does not show racks or devices from imports. Write a scene to show those.
- It uses the front view, shows all notes, and has no routes.

## 12. Scenes built from other scenes

Because devices are defined at the top level, any scene can show any device. Nothing is ever redefined, and
there is no copy.

### 12.1 Placing a whole scene

```yaml
devices:
  core: { model: cat:mikrotik/crs326-24g-2s-plus-rm, in: rack-a, u: 9 }
  edge: { model: cat:mikrotik/crs326-24g-2s-plus-rm, in: rack-b, u: 4 }
links:
  riser: { ends: [core/sfp1, edge/sfp1], cable: lc-duplex }

scenes:
  closet-a: { title: Closet A, layout: [rack-a] }
  closet-b: { title: Closet B, layout: [rack-b] }
  floor:
    title: First floor
    layout:
      - closet-a
      - { space: 600 }
      - closet-b
```

- `floor` draws both closets, each with its own layout and its own routes.
- `riser` is drawn in `floor` because both its ends are shown there. It is not drawn in either closet.
- A route written in `floor` wins over one written in a placed scene.
- A placed scene may itself place scenes. A scene may not place itself, directly or through others.

### 12.2 Showing single devices

```yaml
scenes:
  uplinks:
    title: Uplink path
    layout:
      - core
      - edge
      - site:antenna
    routes:
      riser: { from-exit: up }
```

`core` and `edge` are mounted in racks; here they are drawn alone, side by side, with the link between them.
Put several in a `row` or `column` with a `frame` to draw them on a shelf or in a cabinet for this scene only.

### 12.3 Rules

- **Once per scene.** A device, a rack or a scene is shown at most once in a scene, counting what placed scenes
  bring with them and counting by identity (4.8). Showing a rack and one of its devices in the same scene is an
  error.
- **A scene changes no facts.** It may not set a model, a label, a port setting, a mounting position or a link.
- **Other files.** A scene may show a rack, a device or a scene from an import, by bare id or with the
  import's name: `rack-a`, `site:rack-a`.
- **View.** A layout entry's own `view` wins. Otherwise a rack or device takes the `view` of the scene whose
  layout names it, so a placed scene keeps its own view inside a scene with another. `view` on an entry that
  places a scene replaces that scene's own `view`; entries inside it that state a view keep theirs.
- **Notes.** `notes: false` on a scene hides every note in it, including those in scenes it places. A scene
  cannot turn back on what a scene that places it has hidden.
- **Routes.** As in 11.4: the outer scene's route for a link replaces the inner one.

### 12.4 Names

| Thing | In its own file, or by first match from an importing file | With the import's name |
| --- | --- | --- |
| Device | `core` | `site:core` |
| Port | `core/ether1` | `site:core/ether1` |
| Rack, shelf, ring | `main`, `main/tray`, `main/left-3` | `site:main`, `site:main/tray`, `site:main/left-3` |
| Link | `riser` | `site:riser` |
| Scene | `closet-a` | `site:closet-a` |

A device, a rack and a scene may not share an id in one file, because a layout names all three the same way.

## 13. Fallbacks

| The model has | It draws as | Reported as |
| --- | --- | --- |
| Technical part and faces | The device as drawn | — |
| Technical part only | A face generated from its ports | Notice: generated face |
| A role only | A generic box for the role | Notice: generic device |
| Faces only | — | Error: faces place ports that do not exist |

## 14. Compiling and checking

1. Read each file under the YAML profile (3.4). Load the root file and its imports; check pins; refuse cycles.
2. Check each file against the schema: unknown keys are errors, `x-` keys are kept (3.5).
3. In each file, resolve every reference from that file alone (4.4, 4.5), and apply `collect`.
4. Build models: expand ranges and fill placeholders in each layer, merge layers by port id, then merge faces
   (section 8). Expand simple layouts into full ones.
5. Check meaning:
   - every placed port exists, and every port with a side is placed exactly once on that face;
   - each device is in exactly one allowed position (9.1), fits, and shares no rack unit;
   - `on` has no cycle; parts do not contain themselves; scenes do not contain themselves;
   - each port holds at most one link, and not a link and a plug together (10.2);
   - a device, a rack and a scene do not share an id;
   - every name in a scene resolves, and nothing is shown twice in one scene.
6. For the scene being drawn, or the overview, emit the library's scene document and run the library's own
   parser on it.

Every message names the YAML file, line and key. A problem the library finds in the compiled JSON is mapped
back to the YAML that produced it; a JSON path is never shown.

Checks count identities, not names (4.8).

**Checks defined but not run in the first implementation.** A module fits its cage; a cable fits its two
endpoints; a device's `mount` matches its rack's width. They are compatibility checks, they are more work than
drawing needs, and they come after it. Until then a tool reports them as "not checked", as 3.5 requires.

## 15. Not in the format

- State: whether a light is on, fan speed, what a screen shows.
- Render settings: schematic or photorealistic, resolution, animation.
- How things are painted: photo sources, artwork, light geometry.
- Cable physics on a link. They belong to the cable type (10.1).
- Computed positions. They are an export.

## 16. Reserved sections

These names are reserved for later parts of the format: `sites`, `vlans`, `subnets`, `hosts`, `policy`,
`validation`, `inventory`. The Wiremap plan already has the first six. Until a version of this document defines
them, a tool handles them as 3.5 says: kept on save, and reported as not checked.

When they are defined, per-port network settings (VLANs, addresses) go inside the device's `ports`, beside the
settings of 9.2, so a port still has one place. `inventory` is keyed by device id.

## 17. Open questions

| # | Question | Proposed |
| --- | --- | --- |
| 1 | The version key. The Wiremap plan uses `network: 1` | Keep it |
| 2 | Section names `models`, `scenes`, `racks`, `devices`, `links`, `routes` | As drafted |
| 3 | `racks` also holds shelves, shelving and tables. Rename it | Keep `racks`; it is the word people search for |
| 4 | The section name `cables` holds cable types, while `links` are the cables. Rename to `cable-types` | Open; it reads better but is longer |
| 5 | A printed label shown beside the manufacturer's label, or replacing it | Beside |
| 6 | The keywords `collect`, `where`, `where-not`, `passthrough`, `native`, `order` | As drafted |
| 7 | Bundle renaming uses `.` between import name and id (`east.core`) | As drafted; `.` is already allowed in ids |
| 8 | The `10in` numbers: a 222 mm body, a 236 mm opening and 9 mm rails | Unconfirmed; check against real 10-inch gear |
| 9 | Stamping: one definition of a closet used as two sets of devices | Later (section 22) |
| 10 | Ranges in links, to patch a run of ports in one entry | Later; it needs a rule for link ids |
| 11 | Variables of your own for repeated text | Later |
| 12 | Showing a rack with only some of its devices | Later; show the devices alone instead |
| 13 | Changing one part of an inherited face layout | Later |
| 14 | A lock file instead of pins written in `imports` | Pins in the file for now |
| 15 | File extension | `.network.yaml` for every file |

## 18. Library work this draft assumes

These need confirming against the library or adding to it. None has been checked by building anything.

Confirmed present in the library, by reading its types: internal connections between ports of a passive device
(`portLinks`), front and rear sides, adapters and plugs, rings, brush openings, free cable ends, scene
containers, a cable crossing to the rear round a rack side or through a brush passage, and notes, printed
labels, cable labels and stickers (`annotations`). Cables solved in space with fixed lengths, bend limits and
collision checks (`cableGeometry: '3d'`), socket directions (`cablePose`), chassis depth, flat jackets, and
depth on rings, points and free ends. Rings are placed by coordinate in a rack; the compiler lays the rack out
to find where unit `u` is.

Not confirmed:

- Unit numbering from the bottom: the library counts `at` from the top starting at 0; the compiler converts.
- `in: rack/top`: the library does this with a column that holds a row above the rack; the compiler builds it.
- A device shown alone outside its rack keeps its fitted modules and plugs.
- A link drawn between devices that sit in different nested groups of a scene; one link drawn with different
  routes in two scenes; a cable to a port on the side not in view.
- One device compiled into several scenes: each scene is compiled to its own library document.
- Grid `groups` and port `order`: the library's grid has equal cells, so the compiler assigns the cells.
- A DAC as a cable that goes into an empty cage.
- The differences listed in 3.6.5.
- A module drawn with a part of the user's own instead of a built-in adapter drawing.
- A wall-mount rack type. The portspec plan lists it; the library's enclosure presets do not have it.
- `10in` as a named width, and a 222 mm body for `10in` devices.
- A published list of primitives with default sizes, and a table of generic sizes by role, generated from the
  library so they cannot drift.
- A description in a picture. The library takes a title for the picture and a label for each device, which
  carry the titles of 9.5; it has no setting for a description, so the compiler writes the SVG's `<desc>`
  itself.
- A source map from compiled JSON back to YAML lines.

## 19. A complete small example

```yaml
network: 1
imports:
  - { name: cat, catalog: portspec, version: "2026.11" }

models:
  office/core:
    extends: cat:mikrotik/crs326-24g-2s-plus-rm
    faces: { front: { finish: black } }

racks:
  main:
    type: rack-cabinet
    units: 10
    shelves: { tray: { u: 3 } }
    panels: { brush-6: { u: 6, type: brush } }
    rings: { left-8: { side: left, u: 8 } }
  desk: { type: shelf, surface: wood, width: 900 }

devices:
  core:
    model: office/core
    title: Core switch
    description: Feeds the office and the hypervisor.
    label: SW-01
    in: main
    u: 9
    ports:
      ether24:     { label: UPLINK }
      sfp1:        { module: cat:s+rj10 }
      ether20..23: { plug: true }
  host:  { model: cat:server-1u, title: Hypervisor, in: main, u: 8 }
  modem: { model: cat:dsl-modem, in: main/tray, note: "ISP support: see wiki" }
  pc:    { model: cat:mini-pc, in: desk }

links:
  uplink: { ends: [core/ether24, modem/lan] }
  host-1: { ends: [core/ether1, host/network-1], cable: cat6, color: blue }
  pc-1:   { ends: [pc/network-1, core/ether2], length: 12 }

scenes:
  closet:
    title: Comms closet
    description: The cabinet by the door, from the front.
    layout: [main]
    routes:
      host-1: { via: [main/left-8] }
  office:
    title: Office
    layout:
      - closet
      - { space: 800 }
      - desk
  wiring:
    title: Core and hypervisor
    layout: [core, host]
```

## 20. Coverage of the library's languages

This table is the check that nothing the library can draw is out of reach. The left column is the library's
authoring surface; the right is where it is written here.

| Library | Here |
| --- | --- |
| Faceplate: size, finish, background, padding, mounting holes, active or passive | Model `size`; face fields (6.2); passive follows from role `panel` |
| Faceplate: front and rear content | `faces.front`, `faces.rear` |
| Device bodies: laptops, desktops, all-in-ones and named product shapes | `faces.body` (6.6) |
| Faceplate: corner radius and edge profile | `body` as a map (6.6) |
| Faceplate: content on the ears | `ears` on the front face (6.7) |
| Internal connections of a passive device (`portLinks`) | `passthrough` (5.5) |
| Layout language: rows, columns, gap, justify, align, grow, fit, repeat, sizes, backgrounds | 7.2, and the full form (7.8) |
| Layout language: padding on containers, `fill` sizes, margins, per-item alignment | 3.6.2, 3.6.3, 7.2 |
| Layout language: stacked children (`direction: stack`) | `overlay` (3.6.4, 7.1) |
| Layout language: grid, cells, spans | 7.3, 7.8 |
| Layout language: anchored position | 7.4 |
| Layout language: spacers | `grow`, `space` (7.1) |
| Layout language: `motherboard-io`, `expansion-slots` | Full form (7.8) |
| Coordinate language: ports and blocks at exact positions | Exact form (6.4) |
| Face or panel image, crop and fit | `image` (6.4, 7.8) |
| Port primitives and cages | Types and primitives (5.2, 5.3) |
| Custom ports with built-in socket artwork (power, DC, USB, VGA) | Port primitives for sockets (5.3) |
| Block primitives: logos, labels, panels, indicators, buttons, screens, USB, DC, power, vents, fans, masks, screws, custom | Part kinds (7.6) |
| Grille styles, shapes, finishes, materials, colours, text style | Options in 7.6 and 7.8 |
| Masks by path or image | `mask` (7.8) |
| Cutout patterns: thirteen presets with physical measurements, offsets, phase, ends, clipping | `mask.pattern` and the `cutout-<pattern>` parts (7.9) |
| Circular and ring mask regions | `shape` on a mask (7.9) |
| Fans behind a grille cut in the face | `grille: { mask }` on a fan (7.6) |
| Port lights: presets, custom positions, lights outside the socket | `lights` (7.5, 7.8) |
| Captions on any primitive; multi-line text and line height; vector symbol fallbacks | `caption`, `text`, `text-style` (7.11) |
| Indicator lists | `leds` as a map (7.6) |
| Logo vector artwork | `path` and `view-box` on a logo (7.6) |
| Measured hardware modules: PSU, drive bay, fan module, handle, knockout, rating plate, ground stud | Assemblies (7.10) |
| Custom primitives with artwork | Parts with an image (7.7). Artwork recipes stay inside the library |
| Server builder: six styles with 47 presets, rack 1–6U and towers, standard and dense drive bays at the front and rear, bezel, front I/O, I/O shield, PCIe, OCP and LOM cards with mixed ports, hot-swap and ATX supplies | `template: server` (6.3) |
| Server artwork as images (`server-<style>-drive-hot` and the rest) | Not in the format: artwork recipes stay inside the library |
| Adapters, nested adapters, plugs | Modules (5.4); `module` and `plug` on a port (9.2) |
| Racks, enclosures, doors, rails, fasteners, spacers, brush openings | Racks (9.3) |
| Shelves, stacks, tabletop rows | Rack type `shelf`, `on:`, `in: rack/top` (9.1, 9.3) |
| Scene containers: row, column, grid, position, backgrounds, frames | Scene layout (section 11) |
| Cords, cable types with their drawing settings, free ends | Links and cable types (section 10) |
| Notes, printed labels, cable labels | Labels and notes (9.4) |
| The picture's title, and the label each device's drawing goes by | `title` on a scene and on a device (9.5). A scene's `description` is written into the SVG by the compiler |
| Stickers with an image or icon | Stickers (9.4) |
| Rings, passages, exits, slack, via points | Routes (11.4), `rings` on a rack (9.3) |
| Cable length, chassis depth, socket pose, flat jackets, depth of rings, points and free ends | Routes (11.4), `size.depth` (5.6), ports (5.1), cable types (10.1), how cables are drawn (10.4) |
| `cableGeometry: '2d'` | Not reachable: cables are always solved in space (10.4) |
| Light state, blink, fan speed, screen content, slideshows | Not in the format (section 15) |
| Cable settings on a single cord | On the cable type only (10.1) |
| Render options, photo registry, artwork recipes | Not in the format (section 15) |

Rows marked "not in the format" are left out on purpose. Any other library feature missing from this table is
a gap in the draft.

## 21. Conformance suite

The spec is published with a set of test files. A tool conforms, in one of the classes below, when it gives
the expected result for every case of that class.

| Class | Must do | A tool that stops here says |
| --- | --- | --- |
| Reader | Read files under the YAML profile, load imports, resolve references, apply `collect` and `extends` | "read", never "valid" |
| Renderer | The above, plus every check needed to draw (section 14, step 5) and the layout steps of 3.6 | "drawn"; compatibility "not checked" |
| Validator | The above, plus the compatibility checks of 10.2, 10.3 and 9.1 | "valid" |

| Kind of case | Holds | Expected |
| --- | --- | --- |
| Valid | A file, or a folder of files with imports | The resolved surface as data: every identity, each model's final ports and faces, every device's position, every link's endpoints and chosen cable, each scene's contents |
| Invalid | The same | The check that fails, and the file, line and key it names |
| Bundle | A folder of files | That the bundle resolves to the same surface as the files |
| Layout | A face or a scene | The rectangle of every port, block, device and rack, to 0.01 mm |

The first version covers at least:

- a range overridden by a single port, and a port removed from an inherited range (section 8);
- an inherited face written by reference, repainted, and replaced by another form;
- `{name}` in an inherited face, printing the derived model's name;
- the same id in two imports, taken by first match and by name;
- `A → B → C` with and without `collect`;
- a remote file with a relative import, with and without its hash;
- two imports that each have a device `core`, bundled; a root rack and an imported device both called `main`,
  bundled; a root device already called `east.core`, bundled;
- a bundle whose overview, shelf order, default cables and filled text match the source;
- a device collected through two files, counted once;
- a switch, a patch panel with `passthrough`, a wall outlet and a host as one path;
- a module and a plug; a plug and a link; a DAC in an empty cage; a cable with two different ends, both ways
  round;
- a link with no `cable` where one default fits, where none fits, where two in the same file fit, and where
  two imports each offer one;
- a grid at its natural size with two rows; a container written `fill` inside one written `grow`; a row with
  an expanding space; a number with a share;
- every row of the placement table in 9.1, and each way to break it;
- padding with no space left; a wide container with space left; a container too small with and without
  `fit: contain`; a child with a number across under `align: stretch`;
- a pinned device overlapping another on a shelf; an unlimited shelf with only pinned devices;
- two devices `on` the same device; a three-high stack;
- a `19in` device in a `19in` rack whose `opening` is narrower than its body;
- a GitHub source with a tag for `ref`;
- a radio port named as a link end;
- a bundle of a file with `{{name}}` in a label, and of a file whose module name defaulted to a renamed id;
- a rack with `units: grow` whose tallest thing stands on a shelf;
- a file with a rack called `main` and no scenes;
- a hanging cable, a rear port in a front view, and a route overridden by an outer scene;
- a route through a ring and through a brush panel; a point with `z`; a drawn `length`; a flat cable; a loose
  end with `z`; a socket's `cable-direction`; each written wrong; cables that cannot be laid;
- an unknown top-level key, an unquoted version, a duplicate key, an `x-` key kept on save, and a device
  called `x-core`;
- every cutout pattern and every pattern setting, accepted and refused; a ring region and a circle;
- a body written as a map, and each way to break it; ears on a rack device's front, and on a rear, a desktop
  device and an exact face;
- margins, `align-self`, padding by side, `fill`, and an overlay, laid out; a pinned item with a margin;
- captions on each side, several lines of text, the symbols; a light list; a grid with `mirror-rows`; a light
  outside its port; a port's label written on the face;
- every assembly, a supply whose inlet is a port, and a port placed both in a supply and elsewhere;
- a title and a description on everything that takes them; on a port and on the top of a rack; empty, of two
  lines, written as a list, and written as a number;
- a server template in each style, with each key of 6.3; a shield laid out by `layout`; a port in the wrong
  list, on the other side, named twice and left out; a template that does not fit; one on a desktop device.

## 22. What this version covers and what it leaves for later

| Topic | In `network: 1` |
| --- | --- |
| Patch panels, outlets and couplers with one-to-one or joined ports | Yes (5.5) |
| Fibre cassettes and any device that maps channels, such as MPO to LC | Later |
| Breakout cables, one end to several | Later. A link has two ends |
| Rack and tower servers drawn from a plan | Yes: the server template (6.3) |
| Blade chassis, and a server's drive bays as things you can fill | Later. A bay is drawn, not a port |
| Chassis with line cards, and modules that add ports to a device | Later. A module here changes what one cage presents; it adds no ports |
| Combo ports: one interface with a jack and a cage, either in use | Later. Each connector is a port of its own; the second is drawn as a part |
| Front and rear of the same rack in one picture | Later. A thing is shown once per scene; use two scenes |
| Physical fit of cables and modules | Defined (10.2, 10.3); not run by the first implementation |
| Speed, wavelength, fibre mode and vendor compatibility | Later |
| Cables as physical things: length, bends, contact, depth | Yes (10.4). Cables are always solved in space |
| Depth and weight checks | Later. `depth` keeps cables clear of a device (10.4); whether a device fits a rack's depth, and `weight`, are not checked |
| Variables of your own, stamping a scene as copies, ranges in links | Later (section 17) |
| Titles and descriptions | Yes (9.5): on racks and their parts, devices, links and scenes. On a port and on a definition: later |
| Network settings, checks and inventory | Later (section 16) |
