# Keeping a model light: tips for writers and AI agents

*Informative. The rules are [Part III, 15](https://openeik.org/spec/0.8/code-base#15), part of 0.5, which a model of 0.4 has as the proposal `weight`; where this guide and the specification differ, the specification wins.*

This guide is for every app and every AI agent that writes OpenEik: models, views, detail items and issued drawings. Read it before you draw.

OpenEik allows every heavy form. A hatch of a million little lines is a valid model. It is also, nearly always, a wrong choice that someone else pays for: every reader, every host, every review and every print of that model reads the million lines again. One building can weigh a thousand times more in one model than in another, only by how it is said. Each tip below says what to write, what not to write, and what the difference cost in real models.

## The short list

| Instead of | Write | Why |
|---|---|---|
| a hatch as hundreds of `line` items | one `region` with a `pattern`, or the material's or layer's `pattern` where it is a cut | one item for hundreds; every cut of the material draws it, and it follows the shape when the shape changes |
| insulation as its waves or zigzag | one `insulation` item: `a`, `b`, `width`, `insulationKind` | a strip 6 m long is one item, drawn as 90 strokes or 450 curves when it is drawn |
| a circle as a closed line of 100 points | an item of the kind `circle`, its box `a` and `b` | exact, and 2 points for 100 |
| an arc as 400 chords | its two ends and a bulge, `bulges` (from 0.5) | exact, and 2 points for 400; in a model of 0.4 without the proposal, `curveKind: "arc"` and chords no finer than the paper |
| a path as one item per segment | one `line` with its `points` (up to 500) | one item for a whole chain |
| a fill and its outline as two items | one item with `filled: true` | half the items |
| the same item twice | once | the second draws nothing |
| coordinates to 17 digits | to three decimals of a millimetre | a third of the bytes or less, nothing lost |
| boards, courses, tiles or seams as detail lines | the material's `surface` | lines must be redrawn after every edit; a surface follows the element |
| a symbol drawn again as its lines at each place | a `symbol`, a `component` or a detail family's instance, a row of them with `repeat` | one definition, one item per place or one per row |
| a group of elements written again at each place | an original and its copies (Part II, 10) | the copies' elements are derived, never stored |
| a type for each element | one type for each build-up | fewer records, faster checks, a shorter summary for an agent |
| a heavy parametric kind for a simple thing | the category and kind that draw what the thing is | a rack drawn as a bookshelf is drawn with its books |
| an issued SVG that strokes each hatch line | one `pattern` in `defs`, filled by `url(#…)` | a few hundred bytes for megabytes |
| an issued SVG that repeats a shape | one group in `defs` and a `use` at each place; `marker` for arrowheads and ticks | one definition |

## Drawing: say what it is

**Hatches.** A hatch is a pattern, not lines. Where it is the cut of a material or a layer, give the material or the layer its `pattern` and draw nothing: every plan and section that cuts it draws the hatch. Where it is a free area, write one `region` with a `pattern` (and `spacing` where it has one):

```json
{"a": [100, 200], "b": [1000, 420], "color": "#897c57", "id": "insulation-region", "kind": "region", "pattern": "diagonal", "spacing": 40}
```

*Not this:* 300 `line` items 7.6 mm long, side by side. *Cost:* in the reference implementation, one plan was 374 MB of markup, 369 MB of it insulation drawn wave by wave along every wall, about 3.3 MB a wall.

**Insulation.** Batts and boards are an `insulation` item along a line, with its width; `insulationKind` `bulge` or `zigzag` says how it is drawn:

```json
{"a": [100, 310], "b": [1000, 310], "color": "#26313b", "id": "batting-detail", "insulationKind": "zigzag", "kind": "insulation", "width": 200}
```

*Not this:* the waves as lines or curves. *Cost:* a strip 5 990 mm long is one item; drawn out it is 90 strokes or 450 curves, and 400 waves of 100 points each along 6 m of wall when drawn at a pitch the paper cannot show.

**Paths.** A chain of segments that meet end to end is one `line` with its `points`. A shape with a fill is one item with `filled: true`, not a fill and an outline. *Cost:* a drafting view converted from a PDF, each segment its own item and each fill twice, held 11 402 items, 2.6 MB of a 5.4 MB model.

**Converting a PDF or DXF.** Join each path's segments into one line, keep a fill with its outline, and write a hatch you recognise by its pattern. Mark the view with `source` (the file and the page): a reader then knows where its lines came from.

**Repeated marks and parts.** A symbol, a fixture or a fastener drawn more than once is a `symbol`, a `component` or a detail family's instance (`familyInstance`) at each place, and a row of them one item with `repeat`. Never its lines again.

**Materials in elevation.** Boards, brick courses, tiles and seams are the material's `surface`. Never draw them as detail lines: they would have to be redrawn after every edit of the wall.

## Curves: exact where you can, coarse where you cannot

- **A full circle or an ellipse** is an item of the kind `circle`: its box, `a` and `b`. Exact, two points.
- **A section with round corners or arcs** is a `custom` section whose outline has `[x, y, r]` corners and `{"through": [x, y]}` points (Part II, 5.2), or a `rectangle` with a `radius`, a `round` or a `CHS`. Never a polygon of its chords.
- **An arc in a detail line** is exact from 0.5, and in a model of 0.4 with the proposal `weight`: give the line's `bulges`, one number for each of its `points`, the bulge of the segment from that point to the next, as a DXF polyline does. A bulge is `tan(θ / 4)` for an arc through `θ`, positive counter-clockwise (v up), 0 for a straight segment; 1 is a half circle. An open line's last bulge is 0; a region's, a mask's or a closed line's is the segment back to its first point. Write a bulge to nine decimals (a bulge is no length), and leave `curveKind` out: the points are no chords.

  ```json
  {"a": [0, 0], "b": [3000, 1000], "bulges": [1, 0, 0], "color": "#26313b", "id": "kerb", "kind": "line", "points": [[0, 0], [2000, 0], [3000, 1000]]}
  ```

  That is a half circle of radius 1 000 mm from [0, 0] to [2000, 0], bulging below it, and then a straight segment. An issued drawing draws it as one path, `M0 0A1000 1000 0 0 1 2000 0L3000 1000` (`itemPathData` in `@openeik/tools/weight`). A converter that reads DXF polylines writes their bulges as it reads them.
- **In a model of 0.4 without the proposal**, a detail line's arc has no exact form: write its chords, mark the line `curveKind: "arc"` (or `"circle"`), and make the chords no finer than the paper shows, each within 0.1 mm of the arc on the paper at the largest scale its view is drawn at.

How many chords: an arc of radius `r` through an angle `θ` needs `θ / (2 arccos(1 − t / r))` chords to stay within `t` of it, `t` being 0.1 mm times the scale.

| Circle of radius | at 1 : 100 (t = 10 mm) | at 1 : 50 (t = 5 mm) | at 1 : 20 (t = 2 mm) | at 1 : 5 (t = 0.5 mm) |
|---|---|---|---|---|
| 100 mm | 7 | 10 | 16 | 32 |
| 1 000 mm | 23 | 32 | 50 | 100 |
| 5 000 mm | 50 | 71 | 112 | 223 |

- **An element's plan points** (a curved wall, a round slab, terrain): within 1 mm of the curve, which is 0.1 mm on paper at 1 : 10. A circle of radius 1 000 mm is 71 points.
- **Leave the straight pieces to output.** A compiler, a bridge and a renderer cut arcs into pieces as they need to. Never store the pieces in place of a curve you have.

## Numbers

Round lengths and coordinates you work out to three decimals of a millimetre (`1234.567`, not `1234.5670000000002`). A thousandth of a millimetre is finer than anything built or printed. Do not round a number you read and did not change: the record keeps its value and its hash.

## Elements and types

- **A group that stands again**, a flat, a house of a terrace, a bay of a hall, is an original and its copies (`project/originals/`, `project/copies/`): `{"id": "c-2", "of": "house-a", "at": [12000, 0]}` for each other place. The copies' elements are derived. *Cost:* a site of 28 houses stored 1 948 elements, 1 271 as copies; drawn in full, one edit of a pair of houses took 0.8 s at 8 places, 2.2 s at 16 and 6.9 s at 32.
- **Repeats by rule.** Studs, joists, rafters and battens come from a framing family or a layer's rule. Write the rule, not each piece.
- **One type for each build-up.** Elements that share a build-up name one type. *Cost:* a model of 8 041 elements and 6 978 types took 1.6 s for every command, and its summary for an agent was 372 000 tokens.
- **The kind that fits.** Choose a category and a kind whose body draws what the thing is. *Cost:* 35 storage racks written as a bookshelf, drawn with its books, were 159 936 triangles each, 5.6 million in all; a pallet rack is columns and beams.

- **Shapes as shapes.** A declared body of one outline between two heights is a `prism` (its outline, bottom and top), a round one a `cylinder`; never a `mesh` of its triangles. A shape every element of a type has is declared once, on the type.

## Commands

- **Change in place.** To change a wall, a view or an item, `update` it. Do not delete it and create one nearly the same: the record loses its id, its history and what names it, and every diff and merge sees two changes for one.
- **Send a patch.** Send the members that change (Part V, 4), not the whole record, the whole list or every item of a chunk to change a few of them.
- A command processor may answer either with an advisory in its answer's `warnings`, `weight-rebuild` or `weight-full-replace`. The command is accepted all the same: it is advice, never a refusal. An application's own advice carries its prefix (`acme:copied-geometry`).
- **Read the advice, and send what it gives.** Each advisory names the record, the command that does the same lighter, ready to run, and what it saves:

  ```text
  Command 0 (update wall-a): the patch sends 7 members of the record, 6 of them as they were, to change 1 (height): a patch
  of what changes writes the same (Part III, 15.8, rule 2). Send instead, as one command or a batch:
  {"kind":"update","id":"wall-a","expectedRevision":0,"patch":{"height":2800}}; it saves 6 members, 111 bytes.
  Advice, never a refusal; see guides/weight.md#commands [weight-full-replace, III.15.8.2]
  ```

  It is judged against the record as it was, so resending what you read back unchanged is no fault; it comes once for each record in your session, and then is only counted. It never tells you to make elements you wrote apart into a group: whether they are one is a question for the whole model, and for your person.
- **Watch the weight line.** From 0.5, and in a model of 0.4 with the proposal `weight`, an accepted batch's answer carries `weight`: what the batch wrote, by kind, and the heavy forms in what it wrote, each with its compact form (Part V, 9.1). A hatch you placed stroke by stroke shows there at once, with the region that draws it; change it before you go on.

## Issued drawings (SVG)

The issued SVG profile (Part XIV, 6) has the tools to repeat; use them.

- **Hatches** as one `pattern` in `defs`, and each region filled with `url(#…)`. Never stroke each line of a hatch.
- **Repeated shapes** as one group in `defs` and a `use` at each place. **Arrowheads, ticks and dots** at a line's end as a `marker`.
- **Circles** as `circle` or `ellipse`; **arcs** as a path's `A`, not chords.
- **Draw only what the viewport shows.** Leave out what lies outside the crop before you draw it (Part XIV, 6.12, rule 26). *Cost:* 363 MB of one 374 MB plan lay outside its sheet's crop.
- **No hatch finer than the paper.** Strokes or waves at least 1 mm apart on the paper; at 0.3 mm they print as a grey band. *Cost:* one house's plan went from 11.2 MB (9.4 MB hatch, 240 000 points) to 4.1 MB (130 000 points).
- **Pictures at the size they print**: no more than 24 pixels to the millimetre of paper (600 dots an inch). Each sheet carries its own copy. *Cost:* one 219 kB title-block picture in each of 26 sheets was 5.7 MB of a 46.8 MB issue.

## Reading and hosting

- **Read what you need.** Read a version's tree, then fetch the records your task needs by their hashes. Ask a host for a part; ask for the whole only when you mean it (Part VII, 5). *Cost:* one plan read as data was 3.7 to 8.2 million tokens; a client fetched a 15.8 MB model each time a sheet opened.
- **Versions are trees.** Keep each record once for every version that holds it. *Cost:* 44 whole copies of one project, 57 MB, held 1.9 MB of distinct records; one snapshot of 5.5 MB was written where 48 kB had changed.
- **Page lists, and say there is more.** A list of versions that stopped at 300 without a word hid a project's 1 075.
- **Read sets, not redrawing.** Tell whether an issued drawing is current by its read set (Part XIV, 9). *Cost:* drawing 36 sheets to tell whether they were current took 640 s of CPU; with read sets, none.
- **Hold large lists in a form that does not fail.** A view may hold 50 000 items; a building hundreds of thousands of bodies. A browser failed on 162 380 bodies spread into one call.

## Check your work

After you write, run the quality checks:

```sh
openeik check ./house --quality
```

Each weight warning names the form, the compact one and what it saves, for example:

```text
drawings/architecture/views/drafting/d-1/details/0003.json /12: 2737 strokes in 12 sets of like strokes, the largest 429 of
about 7.6 mm at 0°: a hatch drawn as its strokes. One region with a pattern (or the material's or the layer's pattern,
where it is a cut; an insulation item, where it is insulation) draws it as one item for 2737 [weight-hatch-strokes, III.15.1]
```

| Code | Finds | Write instead |
|---|---|---|
| `weight-hatch-strokes` | 100 or more parallel strokes of one length in a view | a `region` with a `pattern`, a material's or layer's `pattern`, an `insulation` item |
| `weight-split-path` | 200 or more points where two lines of one style meet end to end | one `line` per path |
| `weight-duplicate-items` | 10 or more items that repeat another exactly | each once |
| `weight-arc-points` | 64 or more points on one circle: a full circle, or an arc four times finer than its paper | a `circle` item; the arc exact, its ends and `bulges` |
| `weight-precision` | 1 000 or more numbers in a view to more than three decimals | three decimals |
| `weight-copies` | a group of elements that stands again as it is at 3 places or more, 24 records or more in all, of any kinds (nine portal frames of three members) | an original and copies |
| `weight-mesh-prism` | 10 or more declared meshes or polyhedra of one outline between two heights | a `prism` |
| `weight-shared-shape` | 10 or more elements of one type that carry the same declared geometry of their own | the shape on the type, once |
| `weight-same-types` | 20 or more types that repeat another but for id and name | one type per build-up |
| `weight-svg-path` | an issued SVG path of 20 000 or more segments | `pattern`, `use`, arcs |
| `weight-svg-hatch` | 500 or more like strokes in an issued SVG, outside its patterns | one `pattern` |

The examples in this repository and the whole conformance suite give none of them: if you get one, you wrote a heavy form.

**In your app, before you write.** The same detectors are pure functions of plain records in `@openeik/tools/weight`, so an app or an agent's host can check what it is about to write, and get the compact form back ready to write:

```js
import { weightOfDetails, weightOfElements } from "@openeik/tools/weight";

for (const f of weightOfDetails(items, { scale: 50 })) {
  // f.code "weight-hatch-strokes", f.ids the strokes, f.saves {items: 119},
  // f.compact {kind: "region", a, b, color, pattern: "diagonal", spacing}: write it in their place
}
const found = weightOfElements(model.elements, { types: model.types }); // copies, prisms, shapes on types, types again
```

Each finding is `{code, ids, count, compact, saves, message}`; thresholds are an option (`thresholds: {hatchStrokes: 50}`), with the defaults above.

## When the heavy form is right

Sometimes it is: a surveyed outline whose points are the survey, a scanned drawing kept as it was traced, two groups of elements that are about to change apart. Keep it, and say so once, so that you and the next agent are not told again:

```sh
openeik check ./house --quality --accept weight-hatch-strokes:drawings/architecture/views/drafting/survey/
```

`--accept <code>` keeps a warning everywhere; `<code>:<path>` only under that path (`checkFolder(…, {quality: true, accept: [...]})` in code).

`--accept` is your check's alone. To say it in the model, for every tool and agent that reads it, give one record of the heavy form a `weightAccepted` (from 0.5, or with the proposal `weight` in a model of 0.4): an element, a type or a detail item, any one of the records the form is made of.

```json
{"a": [0, 0], "b": [40, 40], "color": "#26313b", "id": "survey-0001", "kind": "line",
 "weightAccepted": [{"at": "2026-11-05T10:00:00Z", "by": {"agent": {"name": "a-drawing-agent", "version": "2.0"}, "actingFor": "person-a1"}, "code": "weight-hatch-strokes", "reason": "The survey's strokes, kept as traced, as the person asked."}]}
```

`code` is the warning's code (or your application's own, `acme:...`), `reason` one to 200 characters for people, `by` who keeps it, a person or an agent and the person it acts for, and `at` when. The check then says nothing of that set of strokes, and still finds any other in the view. Write it only for a form you wrote, or on your person's word.

**An agent fixes what it wrote, and asks about the rest.** If a warning points at something you did not write in this task, do not "fix" it: it may be heavy on purpose. Tell your person what the warning says and let them decide.
