Skip to content

Decisions

Where SYMBOL_INTERFACE.html (the guide) is silent, decisions are recorded here, one entry each: what was decided, why, and what it costs if wrong. Concerns about the guide itself are recorded as C<n> entries; the guide is never edited.

D1. Symbol carries a trailing lint_allow field

Decided: Symbol(name, kind, status, reference, elements, ports, nodes, paths, anchors, slots, pole_pitch, lint_allow). The guide's signature stops at pole_pitch. Why: lint(symbol) must apply exemptions and report allow-unknown / allow-unused, and the resolved JSON carries lint_allow ("same schema as the source"), so a loaded bundle needs it. Cost if wrong: one extra trailing field with an empty default; consumers that construct Symbol positionally up to pole_pitch are unaffected.

D2. Purity split: file IO lives in build.py, pure helpers in extra modules

Decided: every module is pure except build.py, which holds all file IO, including load_library and load_bundle (the guide lists only write_build and stale_build there, but says build is the only impure module and both load functions read files). Everything they do besides reading is pure: load.py parses text and decoded data, serialize.py renders canonical JSON, gallery.py renders the gallery README. lint/ is a package with one module per rule group. Why: the purity gate and the guide's "only impure module" rule cannot both hold otherwise. Cost if wrong: moving two functions and re-exporting them.

D3. The pure core never raises; problems are Findings

Decided: parsing, validation and resolution return findings (schema, metadata, id-format, part-*, export-unknown) instead of raising. LibraryError (carrying the findings) is raised only by load_library in build.py. repeat states its preconditions with deal.pre. Why: CLAUDE.md requires every module-level function in a pure module to be @deal.pure and not raise; findings are also how the guide says composition rules are reported. Cost if wrong: a consumer wanting exceptions wraps the result.

D4. The JSON Schema is structural only

Decided: schema/symbol.schema.json checks types, required keys, enums, array shapes and "exactly one shape key". It does not check the id pattern, the grid, positive sizes or the number pattern. Why: those are lint rules (id-format, off-drawing-grid, degenerate, metadata); enforcing them in the schema would make those rules unreachable from a file. The schema carries no $id, because the guide names no canonical host for it; a consumer refers to the file by path. Cost if wrong: a stricter schema is a compatible tightening later; an $id is one added key.

D5. A port on a filled circle or filled closed outline counts as "on geometry"

Decided: for port-off-geometry, "on a circle" includes any point of a filled circle's disk, and "on a closed outline" includes any point of a filled polygon's area. Why: the guide's connection-point symbol has its ports at the centre of a filled dot and is stated to pass port-off-geometry without an exemption. Cost if wrong: connection-point would need one more lint_allow entry. Amended: ids renamed to descriptive keys: ids equal to a closed database's reference numbers point readers at it.

D6. lint takes a base-orientation symbol and evaluates 8 orientations itself

Decided: lint(symbol) expects a symbol in base orientation. Orientation-invariant rules run once (orientation = None); orientation-dependent geometric rules (port-on-body-edge, port-lane-clear, slot-overlap-body, slot-overlap-slot) run on orient(symbol, o) for all 8 o and report the orientation. Base-orientation-only rules (through-axis, pitch-overflow) run once. A lint_allow entry exempts a rule in every orientation and counts as used if the rule fired in at least one. Why: the guide requires "all 8 orientations" and gates "lints clean in all 8 orientations" without saying who loops. Cost if wrong: a data repo loops orient itself; findings would then carry no new information.

D7. Bundle keys are exactly the guide's; a loaded bundle has a bare Library

Decided: bundle.json is {"schema": 1, "standard": ..., "symbols": {...}} and nothing else. load_bundle returns Library(standard, title=standard, number_pattern="", symbols). Why: the guide fixes the bundle format exactly; title and number_pattern come from library.toml, which the bundle does not ship. Cost if wrong: two extra keys in the bundle and one in load_bundle.

D8. The bundle package name is the normalised standard

Decided: src/<package>/bundle.json, with <package> = the standard lowercased with every non-alphanumeric character removed (Example set -> exampleset, Plant set 1.1 -> plantset11). Why: write_build(library, root) gets no package name and library.toml has no key for it. Cost if wrong: an optional package key in library.toml; a rename of the output directory.

D9. Small API shape decisions

  • Slot.box is a (width, height) tuple; slot_box(slot) returns the resolved Box.
  • Text has no anchor field (guide: always middle-anchored, always upright) and carries weight so an element round-trips through the file format losslessly; it is not rendered with it.
  • to_svg has no margin parameter (the guide's signature has none); the margin is a constant.
  • The old Anchor text-anchor enum is removed; Anchor is the composition attachment point.
  • InvalidSymbolError and DuplicateSymbolError are removed with the registry they served. UnknownSymbolError stays for Library.get.
  • Library is a frozen dataclass that holds a mutable Mapping, so hash(library) raises TypeError. A library is never used as a key or in a set, so it stays as it is; the mapping a caller hands in stays theirs to change. Cost if wrong: MappingProxyType in load_library and library_from_bundle.

D10. Fixture layout

Decided: tests/fixtures/guide/ is a mini data repo (library.toml, symbols/) holding the five guide examples verbatim plus operated-by-pushing (the qualifier the push-button example uses; the guide names it but does not define it, so its geometry is ours). A test compares each verbatim file with its code block in the guide. tests/fixtures/broken/<rule-id>/ holds one broken mini library per lint rule (symbols/sym-a.toml is the failing file); tests/fixtures/broken/library.toml is the default library config. Amended: ids renamed to descriptive keys: ids equal to a closed database's reference numbers point readers at it. Why: metadata needs a file stem that matches a number pattern, and composition rules need sibling files, so one directory per rule is uniform. Cost if wrong: renames.

D11. Resolved JSON is explicit

Decided: resolved JSON writes every element key that has a default (weight, style, closed, fill) and every port description, so a consumer in another language needs no defaults. Keys whose default is "absent" (potential, edition, form, pole_pitch, lint_allow when empty) are omitted. Why: the guide says consumers "never implement composition" and should be about thirty lines. Cost if wrong: byte-level diff of every generated file.

D12. Composite nodes

Decided: a composite's own nodes entries may only restate an inherited node (same port set) to add a potential; any other node declaration in a composite is a node-invalid finding. Why: the guide defers merging parts' nodes (section 14) and is silent on composite nodes. Cost if wrong: one more inheritance rule.

C1. Guide example push-button fails pitch-overflow as written

Concern: push-button declares no pole_pitch, so its pitch is 4. Its flattened body extends from x = -2.5 or further (the dashed link from the contact's link anchor at (-0.5, 0) runs 2 M west to (-2.5, 0), and the actuator sits at that end), and the inherited marking slots reach x = 1.75. The extent from section 8 point 6 is therefore at least 4.25 M, more than 4, so pitch-overflow fires. Computed with the fixture operated-by-pushing (its geometry is ours, D10; its push bar runs 0.75 M west of its link anchor): the body box spans x from -3.25 to 0, the slot boxes other than tag reach x = 1.75, and the extent is exactly 5.0 M against the pitch of 4 (tests/test_guide_lint.py asserts this). With pole_pitch = 8 the example lints clean. The guide says the five examples "must load and lint clean" and that only the four atomic ones were machine-checked. Implemented as written; the guide-verbatim fixture is expected to produce exactly that one finding, and a variant with pole_pitch = 8 is clean. Owner to decide: add pole_pitch = 8 to the example, or shorten the link. Amended: ids renamed to descriptive keys: ids equal to a closed database's reference numbers point readers at it.

D13. Box and angle edge cases the guide leaves open

Decided: a symbol without elements has the body box Box(Point(0, 0), Point(0, 0)), so its keep-out box still contains the origin; an element with no points (a polyline with none) has that same origin box as element_box but adds nothing to body_box; orient normalises arc angles into [0, 360) under every orientation, R0 included, so R0 is the identity only for symbols whose arcs are already normalised. Why: body_box must not raise on malformed symbols (the linter reports them), and section 3 says angles are normalised to [0, 360) without exempting R0. Cost if wrong: a slot-only symbol's keep-out box grows to the origin; a symbol with an arc at -90 or 360 reads back as 270 or 0 after orient(symbol, R0).

D14. File-format gaps the schema had to close

Decided: the schema (and validate) require height on a text element; fill on a circle, closed and fill on a polyline, weight and style are optional with the defaults the model already has. A file must contain elements, parts or both. ports is never required. slots is required when kind = "symbol", as section 4's key table says (an empty [slots] table satisfies it; a symbol whose [slots] lacks tag or a marking still reads and trips the slot-missing lint). Reversal: the first version of this entry made slots never required, which deviated from the guide without need; the schema now has if kind = "symbol" then required slots, and validate the same. schema, pole_pitch and repeat accept integral floats (8.0), as JSON Schema's integer does. repeat >= 1 is not a schema rule; the resolver must report it. Unknown keys are errors on every table; the only extra top-level keys are the resolved form's body_box and keepout_box. Why: the guide shows height in every text example and gives it no default; the rest follows section 4 and D4. Cost if wrong: height optional (default 1) is a compatible loosening; the rest is unchanged.

D15. Reading reports through schema findings with pointer locations

Decided: every reading problem is a Finding(rule="schema", ERROR): TOML syntax errors, schema violations, and library.toml problems (missing or non-string standard, title, number_pattern; a pattern that does not compile). location is a JSON Pointer such as /ports/0/dir, with ~ and / in keys escaped; a problem with the whole file has location = None. library.toml may carry unknown keys; they are ignored. Why: the guide names only the schema rule for "the file fails validation" and says nothing of the config file; one rule keeps LibraryError messages uniform. Cost if wrong: a separate config rule id and a check that ignores unknown keys becoming strict.

D16. What repeat does where the guide is silent

Decided: the result lists every node explicitly, one per pole, with the ports prefixed and potential kept; a port in no declared node becomes a one-port node (nodes_of), so a symbol without nodes still yields explicit ones. A slot id starting marking. is renamed per pole (marking.in -> marking.2.in, marking.c.in -> marking.2.c.in); tag, value and any other slot id come from pole 1 only, unprefixed. The dashed link line is normal weight and is appended after every pole's elements; lint_allow is carried over unchanged. Why: the guide names tag and value and the marking. prefix, and says "nodes and paths repeat per pole" without saying how implicit nodes are treated. Cost if wrong: an unknown slot id that should repeat is lost on poles 2..n; resolved JSON of a repeated symbol lists nodes that were implicit before.

D17. Structural problems validate cannot see are schema findings from the resolver

Decided: validate does not know a composite from an atomic file, and repeat states preconditions as contracts, so resolve_library reports these itself, all as rule schema: repeat below 1, above 64 (D22), or on a part whose file has no through path (at /parts/<i>/repeat); ports as an array of tables in a file with parts (/ports); ports as a rename table, or a slot given as a string reference, in a file without parts (/ports, /slots/<id>); two parts with the same as (/parts/<i>/as, the later one). A file with any of them has no symbol. Why: the guide names one rule, schema, for "the file fails validation", and repeat must not be called in violation of its contracts. Cost if wrong: a separate rule id and a fixture for it; a second validate pass in the schema.

D18. What part-anchor covers, and where it points

Decided: besides an unknown anchor and anchors that do not face each other (dA == -dT after orient), part-anchor covers the malformed placements: to that is not part.anchor, names no earlier part, or names an anchor the part lacks (/parts/<i>/to); an unknown attach anchor or attach without to (/parts/<i>/attach); via without length > 0 (/parts/<i>/via); a part after the first with neither or both of attach and at, at together with to, length or via, and to, length or via without attach (/parts/<i>). The first part with none of these sits at the origin. A negative length is placed as written (the guide only bounds it with via). A target that is an anchor of a part that itself failed to place adds no finding. Why: the guide gives the rule one line; every one of these makes the placement undefined. Cost if wrong: a finding moves to another rule or location.

D19. Findings are keyed by file stem, never cascade, and sort deterministically

Decided: Resolution.symbols and .findings are keyed by file stem (the number, when the metadata rule is clean); findings lists only stems that have some. A symbol with only metadata or id-format findings still resolves. A file whose part file is unknown, in a cycle, or itself failed has no symbol, and only the file at fault reports: its users get no finding of their own. part-cycle is reported on every file of the cycle, at the part that leads on, so the result does not depend on which file the walk reaches first. Order: stems sorted, then the finding order of D34, generation order after that. metadata uses re.search with the config's pattern, since the guide's pattern anchors itself; a pattern that does not compile matches nothing. Why: findings on a user of a broken file only repeat what the broken file already says. Cost if wrong: users of broken files also list a finding; a stricter fullmatch for patterns without anchors.

D20. Composite inheritance where the guide is silent

Decided: a composite's own nodes entry that restates an inherited node (same port set, in the composite's port ids) replaces it and carries its potential, or the inherited one if it has none; any other own node is appended, so the linter's node-invalid reports it (D12). A part port exported under two names yields two ports at the same place in one node; paths use the first name. When several inherited paths are through and the composite redeclares none with through = true, the result has no through path (the linter then warns through-missing). Inherited paths keep part order; the composite's own paths follow, and an own path removes the inherited path between the same two nodes. Elements are ordered part by part, a part's via link line before its own elements, then the composite's own elements. The composite keeps its own lint_allow, pole_pitch, status and kind and drops its parts' (resolve._compose): guide section 7's inheritance list covers ports, nodes and paths, anchors, slots and elements and is silent on these four. Section 7 also says the composite "must redeclare the one that stays" when several inherited paths are through; that is enforced only as the through-missing warning, which is what the guide's own rule table makes of it (a warning), not as an error. Why: the guide states the rules of inheritance, not these corners. Cost if wrong: an order change in resolved JSON; nothing else.

D21. load_library reports what it read, by file

Decided: load_library reads library.toml and symbols/*.toml as UTF-8, files in stem order; a file that cannot be read (missing, unreadable, not UTF-8, a directory named x.toml) and a missing symbols/ directory are schema findings located at the file or directory name. It raises one LibraryError holding every finding: library.toml first, then per file, each message prefixed <file name>: because a finding has no file of its own. Rule severity comes from the registry (lint/registry.py, rule_finding): the eight resolver rules were registered with the resolver, the linter's other 25 rules were added later, and all 33 are in one table. Why: a data repo gate needs to know which file a finding is about. Cost if wrong: a file field on Finding instead of a message prefix.

D22. Every number is bounded, repeat is capped, the walk has no recursion limit

Decided: every numeric value in a source or bundle file must be finite with an absolute value of at most 1e6 module units (1e6 M is 2.5 km). Both validators enforce it and stay in agreement: the hand-written validate tests not (-1e6 <= x <= 1e6), so NaN and infinity fail; the JSON Schema has $defs/number and $defs/integer (used by every number and integer key, pole_pitch and repeat included) written as not { anyOf: [exclusiveMinimum 1e6, exclusiveMaximum -1e6] }, because jsonschema's maximum lets NaN through and this form does not (JSON has no NaN; a TOML file does). The schema constant and the enum-like values are unaffected. The resolver also rejects a part repeat above 64, like repeat below 1: a schema finding at /parts/<i>/repeat, part not resolved; a direct call of repeat(symbol, n) is unchanged. The walk over part files uses an explicit stack, so a chain of composites of any depth resolves, with no depth cap; a part-cycle message shows the first 8 files of a cycle and ... when it is longer. _matches in lint/file.py treats a pattern that raises OverflowError or RecursionError as matching nothing, as it does one that is not a valid regex. Why: with bounded input all later arithmetic (orient, boxes, the coming overlap tests, placement sums) is total, so the pure core can keep its promise never to raise (D3); validate accepted integers of up to 4300 digits, which overflowed int + float in placement and made repeat hang. 64 poles is far beyond any real switching device. Cost if wrong: a larger bound is a one-constant change in load.py and the schema; a symbol beyond 2.5 km or a 65-pole device cannot be written until then.

D23. How lint runs the rules, orders findings and treats exemptions

Decided: a rule is one function (Symbol) -> tuple[Finding, ...], one Rule(id, severity, group, orientation_dependent) row in lint/registry.py and one entry in CHECKS in lint/__init__.py. run_checks calls an orientation-dependent rule on orient(symbol, o) for the 8 orientations and stamps o on its findings; any other rule runs once, with no orientation. RULE_IDS and the sort order derive from GUIDE_ORDER, the 33 ids in the guide table's order (a test reads the table out of the guide and compares). Findings sort by rule order, then orientation (none first, then R0 to MR270), then location with numbers as numbers (anchors[2] before elements[0], elements[2] before elements[10]), then generation order. lint_allow removes a rule's findings, of both severities and in every orientation, and an entry counts as used when the rule fired in any of them before the removal. allow-unknown (a rule id outside the 33, or a reason that is empty or only whitespace; two findings if both) and allow-unused (a known rule that did not fire) are added afterwards, so they cannot be exempted; an unknown rule is never also unused; a known rule that does not apply to the symbol (slot-missing on an element) did not fire, so it is unused; duplicate entries for one rule are each judged alone; an entry with an empty reason still exempts and is reported once. A rule only the resolver reports (schema, metadata, part-unknown, part-cycle, part-anchor, part-port-unexported, export-unknown; RESOLVER_RULES in lint/registry.py) never fires in lint and the resolver does not read lint_allow, so an exemption naming one changes nothing and is not reported as unused (C3). id-format is not in that set: lint runs it on a symbol's own ids, so an id-format exemption is judged like any other (one aimed at a part id is reported unused, since only the resolver reports those). The package exports the function lint, which shadows the subpackage as an attribute of graphical_symbols: write from graphical_symbols.lint import ..., never import graphical_symbols.lint as m. Why: the guide says who loops over orientations nowhere (D6) and leaves the exemption corners open. Cost if wrong: a change in ordered, in exempt or in the two exemption functions; a rule row and a CHECKS entry per rule instead of one registration if the two are ever merged.

D24. What the geometry, id and anchor rules count

Decided: off-drawing-grid tests exactly (value * 8 is integral) every line, polyline and closed-outline point, circle and arc centre and radius (not arc angles), text position and height, anchor position, slot point and slot box side; port positions are port-off-wiring-grid's. The exact test is deliberately not units.on_grid, which is public and tolerant (1e-9): a consumer that pre-checks with on_grid can accept a value the rule then rejects. It gives one finding per element, anchor or slot, naming every value off the grid, located at elements[i], anchors[i] or slots.<id>. degenerate also covers a circle or arc radius of zero or less, an arc whose angles are equal modulo 360, and an element equal to an earlier one, which is reported at the later copy (three copies give two findings); "equal" is the dataclass equality of the whole element, so weight and style count (a reversed line or a dashed copy is not a duplicate); an element can have more than one finding. Symbol-level id-format checks port ids and anchor ids (ports[i], anchors[i]; part ids stay the resolver's). point_on_geometry(point, elements, *, endpoints_only) in lint/geometry.py is the one test of "on geometry", tolerance 1e-9: on a line or polyline segment, on a circle or arc curve (an arc's ends included), on a closed polyline's outline, inside a filled circle or filled closed polyline (D5); text is not geometry. anchor-off-geometry uses it whole; endpoints_only keeps only the ends of a line and of an open polyline, for port-off-geometry. A polyline of one point is a dot; a filled open polyline has no area. Why: the guide names the quantities but not the granularity of a finding or the corners. Cost if wrong: locations and message text change; endpoints_only moves if ports are meant to count a polyline's interior vertices.

C2. id-format and repeat disagree about port ids

Concern: section 3 says port ids match ^[a-z][a-z0-9_]*$ and the dot is reserved for namespacing, section 7 says repeat makes the ports 1.in, 2.in, and section 12 says every symbol with a through path lints clean as repeat(symbol, 3). 1.in does not match the pattern, so the three cannot all hold as written. repeat also accepts its own result (it has a through path), and prefixes <k>. again, so repeat(repeat(S, 2), 2) has the ports 1.1.in, 1.2.in, 2.1.in, 2.2.in. Implemented: a port id is valid if it matches the pattern or is one or more pole numbers ([1-9][0-9]*), each followed by a dot, and then such an id ((?:[1-9][0-9]*\.)+ and the pattern, matched in full); anchor ids and part ids get no such form. A source file with an authored port 2.in or 1.2.in therefore passes id-format. Owner to decide: keep this, or have repeat be exempt from the id rule some other way (a lint that knows a symbol was repeated, which its signature cannot).

D25. An arc with a non-finite angle counts as its centre in the boxes

Decided: element_box and body_box reduce an arc's start and end angle modulo 360 before they compute its extent, and an arc whose start or end angle is NaN or infinite has no swept extent, so its extent points are just its centre. Finite angles behave as before. Why: arc_point calls math.cos on the angle, which raises for infinity; body_box is called by the linter on hand-built symbols and must be total (D3, D22). Cost if wrong: a garbage arc shrinks a box to a point instead of being an error; files cannot carry such angles (D22), so only hand-built symbols are affected. arc_point used to raise for an infinite angle; since D32 it returns the centre, and the rule above stays in the boxes.

D26. How overlap is computed and what the wire lane is clipped to

Decided: lint/overlap.py tests a shape against an open rectangle (a slot box or a lane). A line and each segment of a polyline are tested exactly, with Fractions, so touching is decided without rounding; a circle is tested by squared distances (outline: nearest point closer than the radius, farthest point farther; filled: nearest point closer), which are exact on the grid; an arc is cut at the angles where its circle crosses the four lines of the rectangle and at its ends, and the middle of each piece must be more than 1e-9 inside every edge (only the arc uses the tolerance). A closed polyline is its outline, and if filled also its area by the even-odd rule (an outline that misses the rectangle leaves the rectangle wholly inside or wholly outside, so its centre decides); an open polyline is only its segments, however it is filled; a polyline of one point is a dot. A circle or arc whose radius is not positive draws nothing. A text element is element_box shrunk by 1e-9 on every side, because the width factor 0.6 is not a binary fraction and an edge that only touches must stay touching. A rectangle with no area is overlapped by nothing, and any non-finite number makes a shape overlap nothing. The lane of a port is the rectangle from the port to the edge of a frame: the keep-out box united with every port position, grown by 1 M on every side (per symbol). Why: the guide defines overlap but not the arithmetic, and the lane is unbounded. Cost if wrong: the frame margin is one constant; a 1e-9 tolerance on segments would be a change in one function. Consequence to know: an element that overlaps a lane always also pushes the body box past its port, so port-on-body-edge fires with port-lane-clear; a text element does the same, because its box is part of the body box too. Only a slot box can break the lane on its own, which is why the lane fixtures use slot boxes.

D27. What the Ports rules count

Decided: port-duplicate-id, port-off-wiring-grid, port-off-geometry, port-on-body-edge and port-lane-clear give one finding per port at ports[i] (the later port for a duplicate id); the lane finding names the first three offending elements or slots and counts the rest. port-spacing and port-position-shared give one finding per later port, naming the first earlier port it is out of step with (same dir, gap not a multiple of 2 M; same position, different node). The grid and spacing tests are exact (% 1, % 2), so NaN and infinity fail them. port-off-geometry is point_on_geometry with endpoints_only=True (D24): a bend of an open polyline is not an end. port-on-body-edge compares exactly and requires the other coordinate to lie in the side's closed extent. Nodes come from nodes_of; a port id listed by two nodes belongs to the first, and two ports with one id are one node. port-on-body-edge and port-lane-clear are orientation dependent (text boxes and slot boxes do not turn); the other five are invariant, which a property test checks for random grid-multiple symbols in all 8 orientations. Why: the guide names the rules, not their granularity. Cost if wrong: locations and message text change; a per-pair report for spacing and shared positions would list more findings for three or more ports on one side.

D28. What the Connectivity rules count

Decided: nodes come from nodes_of (D27); a port id listed by two nodes belongs to the first. node-invalid gives one finding per offending name at nodes[i]: an unknown port, or a port that an earlier node lists already; a port named twice inside one node counts as listed twice. path-invalid gives one finding per path at paths[i], the first of: an unknown port (both named), two ports of one node (from == to included), a repeat of an earlier path between the same unordered pair of nodes (the earlier one is named). A path that joins one node to itself is not an "earlier path". through-count gives one finding per through path after the first, at the later path. through-axis checks every through path on its own, whatever through-count says: a is the to port's y, which must be positive and whole (a > 0, a % 1 == 0), from must be at (0, -a) facing N and to at (0, a) facing S, all compared exactly (-0.0 is 0); a path that names an unknown port has no through-axis finding (path-invalid reports it), and the first port with an id is the one used. through-missing is one finding for the whole file (no location): kind = "symbol", at least two nodes in nodes_of, no potential on any node, no through path. port-isolated gives one finding per port at ports[i]: the port is named by no path (valid or not), no declared node lists it together with another existing port, and its (first) node has no potential. The fixtures of the Ports and Composition rules gained a potential on their single node or a conductor path so the new warnings do not fire on them; the through-count fixture tolerates path-invalid, because two through paths that are both right on the axis join the same two nodes. Why: the guide names the rules, not the granularity, the corners, or which of two overlapping rules reports a malformed path. Cost if wrong: locations and message text change; a per-symbol through-count finding instead of one per extra path.

D29. What the Slots rules count

Decided: slot-missing (kind symbol only) gives one finding per missing slot, at that slot (slots.tag, slots.marking.<port id>); ports that share an id need one marking slot, and value is never required. slot-unknown-port (every kind) takes a slot whose id starts marking. and looks up the rest of the id (only the first prefix is removed, so marking.1.in names the port 1.in); an empty rest is unknown. slot-overlap-body gives one finding per slot at slots.<id> naming the first three overlapped elements, using overlaps_rect (D26). slot-overlap-slot gives one finding per overlapping pair, at the later slot, naming both; boxes without area overlap nothing. pitch-overflow (kind symbol only, base orientation, run once) has two parts. A pole_pitch that is not a positive multiple of 4 is a finding at pole_pitch. For a symbol with at least one through path the extent is max.x - min.x of body_box united with every slot box whose id is neither tag nor value, and it must be at most the limit: pole_pitch if it is positive (even when it is not a multiple of 4, so a pitch of 6 with an extent of 7 gives both findings), otherwise 4. A symbol without a through path has no extent to check, as the guide says "for a symbol with a through path". A through-path symbol with no elements has the origin box (D13) as its body box. The two orientation-only fixtures rely on the box being upright: two boxes 3 M wide and 1 M tall that stand 2 M apart vertically miss each other and overlap by 1 M once the 2 M step is horizontal; a 1.5 x 3 M box beside a lead lies across it after a quarter turn. Why: the guide names the rules, not their granularity or the corners. Cost if wrong: locations and message text change; the limit for a pole_pitch that is positive but not a multiple of 4 would be 4 instead.

D30. What resolved JSON writes where D11 and the guide are silent

Decided: ports, nodes, paths, anchors, elements and slots are always written, as [] or {} when empty (slots because the schema requires it for kind = "symbol"; the rest so a consumer never tests for absence). nodes follows nodes_of: declared nodes in source order, then one node per port in none. A path always writes through. Slots are a table written in slot-id order, so a JSON object read back gives the slots in that order; a symbol's slot order is not preserved by the round trip, and neither is a node list that was implicit. Text is canonical as json.dumps writes it with indent=2, sort_keys=True and ensure_ascii=False, after every whole float has become an int (-0.0 prints as 0), so a point is four lines; control characters in strings are escaped, so no carriage return can occur. Floats print in Python repr form (0.1, 1e-05), which is valid JSON; grid values (multiples of 0.125) never take an exponent form. NaN and infinity have no JSON form: to_json writes NaN, Infinity and -Infinity as Python's json does and does not raise; both validators reject them (D22), so only a hand-built symbol can carry one. Why: the guide fixes the text rules and the two computed keys and nothing else; json.dumps with those options is what every language's standard pretty-printer produces plus a key sort. Cost if wrong: a byte-level diff of every generated file; compact point arrays would need a hand-written writer.

D31. What the build writes, what stale means, what a bundle may contain

Decided: serialize.py holds build_files(library) -> dict[str, bytes] (path relative to the repo root with /, in path order), package_name (D8) and GENERATED_DIRS; gallery.py holds readme. write_build and stale_build in build.py both call build_files, so they cannot disagree; both return root / <relative path> (relative if root is), ordered by their relative / path; an unreadable file or unwritable path raises OSError. write_build creates directories, writes bytes (never text mode, so no \r on Windows) and deletes nothing. stale_build reports a missing file, a directory where a file belongs, a file with other bytes, and any file, at any depth, under build/resolved, build/svg or build/annotated that the library does not produce; it looks at nothing else. Text UTF-8 cannot encode (a lone surrogate, which JSON can carry) is written as ?. The README has the standard, a one-line note on status and a table (number linking to the resolved JSON, name, kind, status, plain and annotated image); it uses standard and never title, so a library loaded from a bundle builds the same bytes as the one loaded from the sources. A bundle is read by parse_json and validate_bundle (both in load.py, pure) and library_from_bundle; validate_bundle checks every symbol with validate and requires the resolved form (no parts, ports an array, slots tables) and a key that is a file stem and equals the symbol's reference.number. A file stem is letters, digits, _ and - in parts joined by single dots (5.1, PIPE-1.1): the guide says the number is the file stem and later sets (Plant set 1.1, Pipe set) have dots in theirs, so dots must load; a leading, trailing or doubled dot, a separator, a space or an empty name cannot name a file safely. write_build and stale_build raise ValueError for a library with a number that is not a file stem, before reading or writing anything (is_file_stem in load.py is the one test). Why: the guide names the two functions and the layout; the rest keeps output byte-exact and keeps a bundle from a stranger from writing outside the repo. Cost if wrong: a number with another character (a space, +) cannot be a bundle key (relax _STEM in load.py); extras outside the three directories stay unreported (add a directory to GENERATED_DIRS); a data repo that wants stale extras removed writes that loop itself.

D32. to_svg and arc_point are total; what the SVG does with input XML cannot carry

Decided: arc_point returns the arc's centre for a NaN or infinite angle (it used to raise from math.cos), so to_svg never raises for a hand-built symbol. The boxes keep their own rule (D25): an arc with a non-finite angle counts as its centre there even when its other angle is finite, which arc_point alone would not give, so _extent_points still checks it. The number formatter writes NaN and infinity as 0; finite numbers are unchanged (at most 4 decimals, no -0), so a huge value such as 1e300 is written out in full. Text in <title> and in every <text> goes through one function: a character XML 1.0 cannot carry (C0 controls except tab, line feed and carriage return, lone surrogates, U+FFFE, U+FFFF) becomes U+FFFD, not dropped, so the text keeps its length; &, < and > become entities; a carriage return becomes &#13; (a parser reads \r back, no \r byte reaches the file and stale_build stays stable on every platform). A line feed and a tab stay as they are, because XML keeps both in character data. The annotation grid is left out when the view is not finite or would hold more than 10 000 dots (100 by 100 M, 250 mm square at the default module), because a dot per module of a 1e300 symbol would never finish. Why: CLAUDE.md wants every module-level function pure and non-raising; a symbol name can carry "\r" or a NUL from TOML, and a build the sibling repo compares byte for byte must be well-formed XML with LF-only bytes. "Never raises" covers the typed inputs, floats: a Python int beyond float range (10**400) in a hand-built Point is outside the contract (the fields are float) and unreachable from files (numbers are bounded to 1e6, D22). Cost if wrong: a garbage symbol draws garbage numbers instead of an error; a real symbol above 100 by 100 M gets no grid in its annotated SVG (one constant); a \r in a name shows as &#13; in the file.

Decided: the guide says annotate=True draws "the grid, ports with ids and lanes, anchors, slot boxes, and both boxes" and texts maps slot ids to sample strings. Drawn in this order, all inside <g class="annotation">: the grid (grid, a dot at every whole module, D32); body-box (green) and keepout-box (purple), both dashed 0.2/0.2, the keep-out one offset by 0.2 so they alternate where they coincide; per slot, in slot-id order, a translucent slot-box (blue) and its id (slot-id, size 0.3) just above the box; per anchor a teal diamond of half-size 0.2 (anchor) and its id (anchor-id, size 0.4) centred 0.75 M out along the anchor direction; the lane of every port, a red translucent strip 0.5 M wide from the port along its direction to the edge of the view; then per port a red dot (port) and its id (port-id, size 0.6, centred 1 M out). The elements are drawn first, under all of it. The view is the keep-out box united with every port label box, every lane start (0.5 M across), every anchor marker and label and every slot label, plus 1 M on every side; a port or anchor label box is 1 em wide per character (0.6 M per character at size 0.6, 0.4 M at 0.4; the code keeps the half-width, 0.3 and 0.2 M per character), a little wider than the glyphs, a slot label box is 0.6 em per character (0.18 M at size 0.3, the guide's own text width), and each is one font size high. Plain, the view is the body box, plus the slot boxes of the texts that are drawn. Sample text (<g class="samples">, drawn last, in both modes, class sample-text, orange, no stroke, upright, font-family="sans-serif"): the font size is the largest s <= 1 with s <= h and 0.6 * s * characters <= w, rounded down to 4 decimals; a slot with no text, an empty one, a box without a positive size, or an id the symbol has no slot for gets nothing. Vertical placement uses explicit baselines and no dominant-baseline, which several renderers (MuPDF, cairosvg) ignore: E and W put the baseline 0.36 s below the slot point (a capital is about 0.72 s tall, so it is centred on the point), N puts it on the point, S 0.72 s below (the capitals hang from the point). The port id labels use the same 0.36 rule instead of dominant-baseline="central", so they moved 0.216 M down, and so does a symbol's own Text element (its baseline is at.y + 0.36 * height, so the capitals are centred in the text box the guide defines; it was at.y, which put them above the box). Slots are drawn in id order because resolved JSON keeps them in id order (D30): a symbol loaded from a bundle must give the same bytes as the one from the sources. The build (build_files) draws build/annotated/<n>.svg with sample_texts(symbol) from gallery.py: tag is -X1, value is 10 A, marking.<port id> is the 1-based position of the port in symbol.ports (the first, for ports that share an id); the plain build/svg/<n>.svg stays the bare definition. Why: the guide names what is drawn, not how; the gallery must show a filled-in symbol, and a sample text that does not depend on the symbol name keeps the files small and stable. Cost if wrong: every annotated SVG changes (colours, sizes, label places are constants); a different sample changes every annotated file; the 0.6 M per character width is the guide's own text extent, and a real font is a little wider for some strings (marking.out at size 0.3 fits its label box only about).

D34. One finding order for the resolver and the linter

Decided: finding_key in lint/registry.py is the one sort key for a Finding, used by resolve_library (per file) and by lint.ordered. It sorts by the rule's place in the guide's section 9 table (GUIDE_INDEX; a rule outside the table after all of them, by id), then by orientation (none first, then R0 to MR270), then by location with numbers compared as numbers (/parts/2 before /parts/10, elements[2] before elements[10]), then by generation order. A data repo that concatenates LibraryError.findings and lint results and sorts them with finding_key gets the table's order across both. The resolver used to sort by rule id in alphabetical order (id-format before metadata, export-unknown before part-port-unexported). Why: two orders for the same rules had no single rationale, and the table is the guide's own. Cost if wrong: a change in one function; resolver findings of different rules swap places.

C3. lint_allow cannot exempt the rules the resolver reports

Concern: guide section 4 calls lint_allow "the only way to be exempt from a lint rule", section 9 says composition and file rules "are reported the same way", and section 8 says an exemption whose rule would not have fired is itself an error. The resolver's rules (schema, metadata, part-unknown, part-cycle, part-anchor, part-port-unexported, export-unknown, and id-format of a part id) run in resolve_library, outside lint, which never reads lint_allow; the three statements cannot all hold for them. Implemented as: these rules are not exemptable. An entry that names one of the seven that only the resolver reports changes nothing, and allow-unused does not fire for it, so a mistaken entry is inert and does not add a second error next to the original one (id-format is still judged by lint, see D23). Cost if wrong: applying lint_allow in resolve_library to the composite's own findings, and reporting an entry there as unused when the rule did not fire; the two exemption functions in lint/exemptions.py would then serve both places. Owner to decide whether these rules are formally non-exemptable or the resolver should apply lint_allow.

D35. A standard with no letter or digit cannot be built

Decided: write_build and stale_build raise ValueError when package_name(library.standard) is empty (a standard such as ... or -), before reading or writing anything, the same error type as for a number that is not a file stem (D31). load_library and validate still accept such a standard: the check is in the impure shell (_check_names in build.py), not in validate, parse_config and the bundle validator, which would each need a rule for it. Why: D8 makes the package the standard with everything but letters and digits removed, so an empty package would write src/bundle.json instead of src/<package>/bundle.json, silently. Cost if wrong: a schema finding on standard in parse_config and validate_bundle, so load_library reports it, and a matching key in the JSON Schema.

D36. deal is the one runtime dependency, kept for the purity contracts

Decided: every module-level function in a pure module carries @deal.pure, checked at import time, and deal is a runtime dependency of the package, not a dev dependency. No other third-party package is added to src/; jsonschema stays a dev-only dependency of the schema agreement test. This carries forward the reasoning of decision 0008 of the monorepo this toolkit came from from the interval this package spent as packages/graphical-symbols in that workspace, where a boundary test enforced deal as the package's only allowed third-party import; that test does not exist here, so this entry is the record now that the package is its own repository again. Why: scripts/fp_purity_gate.py fails the build when a pure-module function is missing the decorator, and the decorator is a runtime contract, so it cannot be moved to a dev group. Cost if wrong: a second third-party import in src/ with no record here, or deal dropped without a replacement for the purity contracts it checks.

D37. Build-time file access is confined to build.py, load_bundle and load_library

Decided: load_library, load_bundle, write_build and stale_build, and scripts/build.py, read and write symbol source and build files as a build-time tool whose output is tracked data (build/, src/graphical_symbols/bundle.json-shaped output for a consumer, the gallery). No other module reads or writes a file; the pure core takes values and returns values. scripts/fp_purity_gate.py exempts build.py by name, the same way tests/test_boundaries.py in the monorepo this toolkit came from exempted it while this package lived there as packages/graphical-symbols (that workspace's decision 0009, which also recorded electrical_symbols reading its packaged bundle.json at import -- a fact about that package, not this one, and no longer this repository's concern). Why: symbol data is compiled by a developer running the build, not read at render time; the toolkit itself never touches a file outside that build step. Cost if wrong: a file read or write anywhere else in src/ needs a new decision record and a fp_purity_gate.py exemption, which the gate's own can-fail test would then have to prove.

D38. The design guide is package data, read through importlib.resources

Decided: docs/SYMBOL_INTERFACE.html moved (git mv, history kept) to src/graphical_symbols/docs/SYMBOL_INTERFACE.html. Hatch's wheel config already packages everything under src/graphical_symbols/, so the file needs no new build-system entry: it sits at the same relative path in the source tree and in the built wheel. A consumer reads it with importlib.resources.files("graphical_symbols").joinpath("docs/SYMBOL_INTERFACE.html"), which resolves the same way whether the package is installed from an editable source checkout, a git dependency, or a built wheel. tests/test_guide_package_data.py proves the resource resolves and carries the guide's own <title> (not a byte count, which would break on every edit to the guide's prose and tests the wrong property). Why: electrical-symbols compares its data byte for byte against this guide's worked examples (its own D38, the "verbatim gate"), and until this toolkit left the monorepo it came from the two packages shared one copy through a sibling directory. Now they are two repositories; the toolkit's wheel never shipped docs/, so the sibling path stopped resolving. Moving the guide under the package directory keeps exactly one copy, and it is the toolkit's own, which is the only copy a downstream gate can check against and still mean anything (a vendored copy in the downstream package would only prove agreement with itself). Cost if wrong: a consumer with a stale copy or a broken resource path silently stops checking against the real guide; test_guide_package_data.py's can-fail test is the guard against a resource that resolves but is not this file's content.

D39. to_fragment: a placeable <g> fragment beside the standalone document to_svg

Decided: svg.py gains to_fragment(symbol: Symbol) -> str, returning _GROUP_OPEN, one _element(e) per symbol.elements and </g>, joined by newlines with a trailing one -- exactly the plain content group to_svg already builds, reusing _element and _GROUP_OPEN directly rather than a second element-rendering path. No <svg> root, no <title>, no annotations, and no sample texts: the function takes no texts parameter at all, so a slot's sample text can never reach a fragment, not merely because no fixture happens to exercise it. It applies no transform, scale or orientation of its own; the caller places it in its own coordinate system. Exported from graphical_symbols.__init__ alongside to_svg. Why: a consumer's render package assembles a page out of several placed symbols and needs each one as a reusable piece it positions and scales itself, not a whole standalone document; the guide (SYMBOL_INTERFACE.html) defines only the standalone to_svg document and is silent on an embeddable fragment. Cost if wrong: reusing _element/_GROUP_OPEN means any future change to how an element renders is automatically picked up here too; if a future edit ever duplicated that logic instead, the fragment and the document's plain mode could silently drift apart. A wrong function name is a rename in two files (svg.py, __init__.py) and the tests that check it.

D40. A line binds to a port with port; the file's schema integer does not step

Decided: Line gains a trailing field port: str | None = None, written by line = { ..., port = "in" }. It is optional, additive and carries no default that changes an existing file's meaning, so schema (the file-format marker, const 1 in the JSON Schema and _schema_version) stays 1: nothing that validated before stops validating, and nothing that validates now would have validated under the old rule differently. A new lint rule lead-off-port (ERROR, Ports group, guide section 9) fires when the named port does not exist, or when it does but neither end of the line is at the port's position, or the line does not run along the port's facing axis (the coordinate perpendicular to the port's direction must be equal at both ends) -- one finding per offending line, at elements[i]. The resolved JSON writes port only when set (D11's "absent" pattern, like edition and pole_pitch). orient and translate carry port along for free through dataclasses.replace. repeat prefixes a bound lead's port with <k>., the same prefix it gives the port itself, so a repeated symbol's leads stay bound. Composition namespaces a part's bound lead <part>.<child port> while placing it, then rewrites that to the rename map's exported id once _export_ports has computed it; a lead bound to a part port the rename map leaves out keeps the namespaced, unreachable id, which is moot because _export_ports already fails the file on part-port-unexported for that port. A part port the rename map exports under more than one new id ({ a = "c.in", b = "c.in" }) gives a bound lead the first one the map declares: both exported ports still share the child's position and direction, so the choice only decides which one the lead's own metadata names, never where either one draws or routes; test_resolve.py's test_a_lead_on_a_port_exported_twice_follows_the_first_declared_alias pins it. Why: the package version (pyproject.toml, currently 0.1.2) is this repo's only versioning mechanism with a minor/major/patch structure; the work order that asked for this expects the release that carries it to be tagged a minor step (v0.2.0) on that scheme, not on schema, which is a single flat integer with no such structure and no precedent of ever moving off 1. A consumer on the old tag simply never emits port; a consumer that needs it takes the new tag, same as any other public addition here (CLAUDE.md's "coordinated change"). The port-lane-clear guarantee already makes a wire reaching a port along its own axis safe at t = 0; lead-off-port only makes sure a claimed binding actually is that wire, so a downstream renderer (or anything else) can trust element.port without re-deriving it from geometry. Cost if wrong: an unmapped repeat or composition would leave element.port naming a port that no longer exists after flattening, silently turning every downstream reader's binding lookup into "unbound" instead of a loud finding; test_repeat.py and test_resolve.py each gained one test against exactly that. If the owner ever wants schema itself to carry a minor/major split, that is a bigger, separate decision: nothing here depends on it.

D41. Public, plain-markdown docs; v0.3.0; exact git tag; no PyPI for now

Decided (owner 2026-10-01): the repo's documentation is plain markdown in the repo, with no documentation site: README.md (install, one worked example, the concepts), docs/GUIDE.md (the concepts in more depth: how symbols are defined, built, linted and serialized) and AGENTS.md (a pointer for any agent: CLAUDE.md holds the rules; the README and docs/GUIDE.md serve users). Every public name in __all__ carries a short Google-style docstring. The Python examples of the README and docs/GUIDE.md are run by tests/test_readme.py, so they cannot drift. The docs may name the toolkit's users; the rule that nothing names a consumer package covers code, tests and scripts (designer 2026-10-01). The release that carries this is v0.3.0; consumers install by exact git tag (uv add "graphical-symbols @ git+https://github.com/OleJBondahl/graphical-symbols@v0.3.0"). The package is not published to PyPI for now. Why: the toolkit is consumed by an exact tag already (D38's package data, a consumer's pin), a site or an index would add upkeep with no reader today, and the tests keep the examples true. CLAUDE.md stays the one home of the agent rules: a draft AGENTS.md that restated them disagreed with CLAUDE.md about docs/ on the day it was written. Cost if wrong: if a consumer outside the tag workflow appears, PyPI publication is a later, separate decision (trusted publishing and a release workflow); nothing here blocks it. The docs are only as true as their tests: their prose is not run.

Open questions for the owner

  • C1 (push-button fails pitch-overflow as written): add pole_pitch = 8 to the guide's example or shorten the link. The real exampleset operated-by-pushing may change the extent; report the outcome there.
  • C2 (id-format versus repeat's <k>. port ids): keep the prefix form permanently, or change the guide's id pattern.
  • C3 (lint_allow and the seven resolver-only rules): formally non-exemptable, or apply lint_allow in resolve_library.
  • Merging feat/toolkit into main is the owner's call; nothing has been merged.

Known limits, decided not to bound

Each is reachable only from the data repo owner's own files, and the guide is silent. Cost if wrong: add a bound and a schema finding, as D22 did for numbers and repeat.

  • resolve_library: nested composites with two parts each fan out as 2^depth elements (depth 16 is about 2 s; about 40 tiny files would not finish).
  • A catastrophic-backtracking number_pattern in library.toml (for example (a+)+$; the time grows by 4 per 2 characters) can hang re.search. It is the only non-terminating path in the core. ^[a-z][a-z0-9]*(-[a-z0-9]+)*$-style patterns are safe.
  • Lint cost is quadratic in the number of poles of a repeated device (64 poles about 21 s, 24 poles 2.8 s; deal tracing is about 2.2 times of that). The gates need only repeat(s, 3).
  • load_library accepts a file stem or number_pattern that yields a number failing the stem regex (a b.toml, or a Windows device name such as CON); write_build and stale_build then raise ValueError (D31), and build/svg/CON.svg would misbehave on Windows.
  • validate still raises on a mapping key that is a 4300-digit integer (unreachable from TOML or JSON); some private module-level tables (orient._PARTS, load._ELEMENTS, svg._SAMPLE_ALIGN, geometry._RIGHT_ANGLE_COS_SIN) are mutable dicts.
  • In the annotated make-contact the sample text -X1 covers the start of the link anchor label, because the guide's tag slot ends 1 M west of that anchor. Cosmetic, gallery only.

What ../exampleset must do because of these decisions

  • Add .gitattributes with * text=auto eol=lf; without it, on Windows with core.autocrlf=true, tracked build files become CRLF and stale_build reports everything stale.
  • Run write_build again: the Text baseline fix (D33) changed the bytes of every SVG that contains a Text element, so any committed build is stale.
  • Use finding_key (graphical_symbols.lint.registry, D34) to sort the concatenated LibraryError.findings and lint results; wrap load_bundle at import time for LibraryError.
  • Lint repeat(s, 3) for every symbol with a through path, and report the C1 outcome.

D42. The toolkit is symdef, version 0.4.0 (SYMDEF SD1)

Decided: the distribution and the import are both symdef; the first release under the name is 0.4.0, continuing the line of graphical-symbols 0.3.0. The package folder is src/symdef, the repository URL in pyproject.toml is https://github.com/OleJBondahl/symdef (GitHub redirects the old URL). Earlier entries keep the old name as they were written. Why: a short name that is free on PyPI, one name for repository, distribution and import. Cost if wrong: another rename of the same shape; consumers change their pin and imports once more.

D43. requires-python = ">=3.14", tested on 3.14 in just ci (SYMDEF SD2)

Decided: the package supports Python 3.14 and later. Development stays on 3.15 (.python-version, ruff and ty targets). just ci ends with just test314: uv run --python 3.14 --isolated pytest --no-cov, a throwaway environment, so the promise cannot rot. Proof it can fail: a 3.15-only line (lazy import json) in src/symdef/units.py makes the 3.14 run stop with a SyntaxError. Why: more consumers install it; the code already ran on 3.14 (2261 tests pass). Cost if wrong: raise the floor back to 3.15; the extra test run adds about 45 s to the gate.

D44. Published to PyPI by trusted publishing; docs on GitHub Pages (SYMDEF SD3, reverses D41)

Decided (owner 2026-10-07): a tag vX.Y.Z runs .github/workflows/publish.yml: it checks the tag equals the package version, builds with uv build, and uploads with PyPI trusted publishing and attestations, from the GitHub environment pypi, with id-token: write and no token secret. .github/workflows/docs.yml deploys a minimal site (README, guide, decisions and the spec, built by scripts/build_site.py with the dev dependency markdown) to GitHub Pages on the same tag. Every action is pinned by full commit SHA with its version in a comment. A release is cut only from a commit whose local just ci passed; no workflow runs the gate. Why: consumers install by an exact PyPI version instead of a git tag. Cost if wrong: delete the workflows and yank the release; the git tag install still works.

D45. Optional package key in library.toml (SYMDEF SD8, amends D8)

Decided: library.toml may carry package = "name", the data package's folder under src/ (letters, digits and _, not starting with a digit; anything else is a schema finding at /package). LibraryConfig gains package, empty by default. Library does not change: section 11 of the spec fixes its fields, and a test pins them. write_build and stale_build already take the repo root, so they read the key from root/library.toml and pass it to build_files(library, package); a root without a readable library.toml gets the folder D8 makes from the standard. This is the fix D8 named for itself. Why: a data package whose folder is not its standard's squashed name (electrical_symbols for Example set) needs a way to say so. Cost if wrong: drop the key; the default rule is unchanged. A library built in memory and written to a root with no library.toml cannot name its folder.

D46. A set declares its own vocabulary and required slots (SYMDEF SD6 and SD7)

Decided: library.toml gains [vocabulary] (path_kinds, potentials, links, each a list of strings; a missing list is empty) and [rules] required_slots (for example ["tag", "marking.<port>"], where <port> means one slot per port). The toolkit has no built-in list. A symbol file using a path kind, node potential or via link not on its list fails to load with a schema finding that names the word, the file and the line (the first line that quotes the word; line 1 if the word is spelled with an escape). The check runs in load_library, which has the file text. The closed enums PathKind and Potential are gone from symdef.__all__: Path.kind is a str and Node.potential is str | None; JSON output is unchanged. The structural check and schema/symbol.schema.json accept any string there. Vocabulary is a new public name; LibraryConfig and Library gain vocabulary and required_slots (empty by default); lint(symbol, required_slots=()) takes the duty list, and a bundle carries neither. The pole-pitch multiple-of-4 rule stays fixed. [vocabulary] and [rules] are strict tables: an unknown key is a schema finding on library.toml. Why: a set for another domain (pipes, ISA instruments) needs its own words and duties; the toolkit supplies mechanism, not policy. Cost if wrong: a consumer of PathKind or Potential compares strings instead; a set that declares nothing cannot use any path kind.

D47. The surface is every name the docs call; the schema ships in the wheel (SYMDEF SD10 and SD11)

Decided: RULES and finding_key join symdef.__all__ (and finding_key joins symdef.lint.__all__), and a test reads the python blocks of the README and the guide and fails for any from symdef... import name whose name is not in that module's __all__. schema/symbol.schema.json moves to src/symdef/schema/symbol.schema.json, so the wheel carries it, and gains "$id": "https://olejbondahl.github.io/symdef/symbol.schema.json"; the docs site publishes the same file at that address. An editor that reads a #:schema line then completes and checks a symbol file as it is typed. The schema checks structure only; the declared words stay a load check (D46). Why: a user should find every documented name on the surface, and an editor needs a schema it can fetch. Cost if wrong: move the file back; the $id is only an address.

D48. The newcomer's path: symdef init, build and check (SYMDEF SD9)

Decided: a command line symdef ([project.scripts], also python -m symdef) with three verbs on a folder, each also a function: init(root) writes library.toml, one symbol (symbols/resistor.toml) and .gitattributes with LF line ends, and refuses a folder that already holds any of them; build(root) loads, lints and writes build/ and the bundle, raising LibraryError and writing nothing if a file fails to load or lint reports an error; check(root) returns the findings of the gates every set needs and never raises for a bad set. The starter texts live in symdef.starter, are written by code and are loaded, linted and built by a test, so they cannot drift from the format. Both starter files open with the #:schema line of D47. The command exits 0, 1 when it found problems, 2 on bad usage, and prints each distinct finding once. check runs: files load and resolve (a number equals its file stem and fits number_pattern there); every symbol lints clean, warnings included; a symbol with a through path lints clean as repeat(symbol, 3); the build is not stale (stale-build); the packaged bundle holds the source's symbols (bundle-differs) and they lint clean. These are the generic gates 1 to 6 of the first data package's gate file. The bundle already lives in its package (D45), so no relocation exception is left. The functions are symdef.init, symdef.build and symdef.check. build would shadow the module symdef.build, so that module is renamed symdef.files; it stays the impure shell with project, cli and __main__, which scripts/fp_purity_gate.py lists. Why: a newcomer needs a first working set in three commands, and a test needs one call for every gate. Cost if wrong: drop the verbs; the renamed module only matters to code that imported symdef.build, which was not on the public surface.

D49. deal is removed; an AST purity gate replaces it (SYMDEF SD12, amends D36)

Decided (owner 2026-10-07): "remove deal from symdef, as we dont want to bug people with a non dev dependency that is not integral, we should instead just write in the claude and readme that such and such parts of the library is pure". deal leaves completely: no runtime or dev dependency, no @deal.pure, no import deal. The wheel has no dependency. scripts/fp_purity_gate.py now checks purity with the standard library's ast, over every module under src/symdef/ except its IMPURE_MODULES (files.py, project.py, cli.py, __main__.py and the top-level __init__.py). In a pure module it fails on a call to print, input, open, exec or eval; an import of time, datetime, random, secrets, os, io, shutil, subprocess, socket, tempfile, logging, sys or pathlib; a global or nonlocal statement; and an assignment, del or mutating call (append, update, ...) that writes into a name bound at module level. Every kind has a test that makes it fire. Two probes against the real tree: a print() added to a pure function reports calls print(); a list appended to at module level reports mutates module state. The README says which modules are impure and why. The gate is weaker than deal.pure in one way: it cannot prove a function raises nothing, and the runtime wrapper also caught that. repeat's two deal.pre preconditions are now a documented ValueError; the tests that expected deal errors expect ValueError. It is stronger in two: it also forbids file I/O and the clock, and it runs on code no test reaches. The totality of rendering stays covered by tests/test_svg_total.py. The TC001/TC003 ruff ignore stays. Its stated reason was deal's inspect.signature call, but with deal gone ruff's unsafe fixes for those rules still fail: they write lazy import statements, a SyntaxError on 3.14, and 35 test modules failed to collect. The comment in pyproject.toml now says that. Why: users should pay for nothing they did not ask for (lint was 2.6 times slower with the contracts on, the import 13 ms slower, and the package carried a 1.9 MB dependency). Cost if wrong: purity is proved statically only; a function that raises by accident is found by tests, not by a wrapper.

Decided: scripts/build_site.py (run by just site and by docs.yml on a tag) stages the README as the home page, docs/TUTORIAL.md, docs/GUIDE.md, docs/DECISIONS.md, a generated gallery of docs/tutorial-set/ and a generated API reference (every name of symdef.__all__ with its signature and docstring) into the gitignored .site-src/, and builds it with Zensical (dev dependency, zensical==0.0.68, the latest stable) in --strict mode, so a broken link fails the build. The interface spec and the JSON schema are published at the site root, the schema at its $id. tests/test_site.py proves a broken link fails the build; tests/test_tutorial.py runs every symdef command, edit step and python block of the tutorial in an empty folder. The markdown dev dependency goes. The gallery set is the six standard-style fixtures, plus a gate valve, a pump and a check valve drawn here (gate-valve, pump, check-valve, path kind pipe, which shows a set declaring its own word). push-button carries pole_pitch = 8, the fix D-concern C1 names, because symdef check refuses the fixture's pitch overflow; the other five files are byte-equal to the guide fixtures. No page names a user of the toolkit. The README carries the provenance line for every standard-style example: original drawings, unverified. Both workflows run on ubuntu-24.04 with an exact uv version. Why: the site must cover everything a newcomer needs, with no other repository to read. Cost if wrong: Zensical is pre-1.0; the staged Markdown also builds with MkDocs. Amended: ids renamed to descriptive keys: ids equal to a closed database's reference numbers point readers at it.

D51. The interface spec is amended in place for 0.5.0 (SYMDEF SD14)

Decided (owner C1): SYMBOL_INTERFACE.html opens with a dated change list and changes only through a designer-approved spec, with a dated entry in that list and in this file. This amendment records D45 to D49 in it: declared words and required slots (sections 5, 6, 7, 9, 11 and 12), the API list (Vocabulary, init, build, check, lint(symbol, required_slots), Library's two fields; PathKind is gone), the schema location, the generic layout and gates of section 12, no runtime dependency, and a rewrite of sections 1, 12 and 13 that names no predecessor and no user. Section 14's open items stay. The byte-equality test of the guide's code blocks passes against it. Why: the spec was the one file still describing the first design. Cost if wrong: revert the file; code and tests do not read its prose except the code blocks.

D52. The mm output: to_fragment_mm beside to_fragment (SYMDEF-MM)

Decided: to_fragment_mm is a new public function in a new module, svg_mm.py, beside to_fragment. It is not a keyword on to_fragment: to_fragment's contract is module units with the caller scaling, and one function with two units and a mapping argument would blur it. Signature: to_fragment_mm(symbol, *, module_mm, weights_mm, dash_mm, font_family, font_mm, cap_ratio) -> str. Every coordinate and radius is multiplied by module_mm. Stroke widths come from weights_mm, one entry per Weight; a missing weight raises KeyError naming it. Dash lengths come from dash_mm. Text is drawn at font_mm and ignores Text.height; its baseline is y * module_mm + cap_ratio * font_mm / 2. The caller passes the font family. There is no transform and no scale. to_svg and to_fragment bytes are unchanged; the golden fixtures under tests/fixtures/svg_golden prove it. Release 0.6.0. Why: the owner wants every size set in millimetres and rendered exactly, with nothing scaled. Cost if wrong: the function is additive; remove it and its export.

D53. stretch(): a cut line moves everything beyond it

Superseded in part by D67 (0.10.0): "at most one per axis" no longer holds; D69 changes how slots move.

Decided: Symbol.stretch holds at most one Stretch(axis, at) per axis, written [[stretch]] in a file and stretch in the resolved JSON (written only when set, so existing bundles keep their bytes; the bundle schema version stays 1). stretch(symbol, axis, length, offsets=None) in the new stretch.py moves every point whose coordinate is greater than at by length minus the body extent (body_box) along the axis: line and polyline points, ports, anchors and slots; a circle, arc or text lying wholly beyond the cut moves whole, one wholly before it stays, one across it raises ValueError. Offsets place each named port, its bound lead and its marking.<port> slot at a coordinate inside the stretched body on the 1 M wiring grid; the port must face across the axis (N or S for x, E or W for y), and an offset naming no port raises ValueError too. A length equal to the natural extent is allowed. The result drops that axis's stretch, so a frame is stretched on both axes by two calls; no extra API. orient, translate and repeat carry the field unchanged and do not raise; the stretch is applied before them. The lint driver does not clear it: every rule ignores it except stretch-cut (D55), which runs once on the base symbol. A composite does not inherit its parts' stretch; its own [[stretch]] is its own. crosses_cut is the one predicate the function and the lint rule share. Why: the owner chose the stretch value: layout passes one length and symdef builds the symbol. Cost if wrong: the field, the function and the schema key are additive; remove them and the export.

D54. table(): rows with their own ports and slots

Decided: table(row, n, axis, head=None) in the new table.py returns n copies of row, copy k (from 1) stepping by the row's body extent (body_box) along the axis. Ports, bound leads, nodes and paths are prefixed <k>., through the helpers repeat uses (now public in repeat.py as pole_elements and pole_parts). Every slot of every copy is kept: marking.<port> becomes marking.<k>.<port>, any other <id> becomes <k>.<id>. No through path is needed. The cap is repeat's 64, now the constant MAX_REPEAT in repeat.py (the resolver imports it). The result keeps the row's pole_pitch, takes copy 1's anchors and has no stretch. A head keeps its own ids and comes first in the lists; with a stretch on the table's axis it is first stretched to n * step, the rows' total extent on that axis (amendment 2: this is how a cable head spans its k columns stepping along x). A head with no stretch on the axis is not stretched. The head stays where it is authored, relative to row 1, as built, and is never translated. repeat is unchanged. Why: a table is cells with their own text, not poles of one device. Cost if wrong: additive; remove the module and its export. A head that must move is a later keyword.

D55. Lint rule stretch-cut and the schema key

Decided: a second rule beyond the spec's 33, stretch-cut (after lead-off-port, D40): group Geometry, severity error, not orientation dependent, so it runs once on the base symbol and lint_allow may exempt it. It reports, at elements[j], a circle, arc or text a cut crosses (crosses_cut, the predicate stretch itself uses), and, at stretch[i], a cut that does not satisfy body_min <= at < body_max on its axis (a cut at the far edge moves nothing; one at the near edge is legal) and every stretch after the first on one axis. The rule count is 35. symbol.schema.json gains stretch, an array of {axis, at}, both required, axis one of x and y; the file's schema integer does not step, as for port on a line (D40). Under orient the lint driver leaves the field alone; no other rule reads it. Why: a symbol whose cut crosses a circle cannot be stretched, and the error should surface at lint, not at the consumer's build. Cost if wrong: the rule is additive; remove its row, check and the 35 in the counts.

D56. Wire styles and wire()

Decided: a symbol set declares wire styles in library.toml as [[wire]] with id, weight (normal or thick) and style (solid or dashed); the table is optional, and a missing key, an unknown word or a duplicate id is a finding like those of [vocabulary]. WireStyle(id, weight, style) is a new public dataclass; LibraryConfig and Library gain a last field wires. wire(library, style_id, points) in the new wire.py returns an element-kind symbol of one open Polyline of that style (name wire <id>, reference number wire.<id>), with no ports or slots; points may be Points or (x, y) pairs. An unknown id raises KeyError naming it (as to_fragment_mm does for weights), fewer than two points ValueError. The consumer reads a bundle, not the TOML, so bundle.json carries an optional top-level wires array, written only when the library has wires (existing bundles keep their bytes; the bundle schema stays 1), checked by validate_bundle and read by library_from_bundle. A junction dot is an ordinary symbol. Why: the owner ruled that wires are symdef functions and layout names only a style and points. Cost if wrong: additive; remove the module, the dataclass, the field and the bundle key.

D57. Tint fill

Decided: Fill gains TINT = "tint". A file may write fill = "tint" on a closed polyline only; on a circle or an open polyline it is a schema finding, and the JSON schema agrees (a separate fill definition for polylines, with closed = true required beside tint). to_svg, to_fragment and to_fragment_mm take a keyword-only tint: str | None = None, the colour string the caller chooses, drawn as the fill of every tinted shape; with None a tinted shape draws fill="none". The toolkit chooses no colour. So that no value can inject SVG, a colour must be #rgb, #rrggbb or a letters-only name; anything else raises ValueError, whether or not a shape uses it (check_tint in svg.py, shared by the mm output). Output bytes without a tinted shape do not change; the golden fixtures prove it. Why: the consumer passes the colour, as it passes slot texts. Cost if wrong: additive; remove the enum member, the keyword and the check.

D58. The interface spec is amended in place for 0.7.0

Decided (owner C1; model D51): SYMBOL_INTERFACE.html gets a dated change-list row, 2026-10-15, 0.7.0, and the sections that define the new pieces change in place: section 4 ([[stretch]], fill = "tint"), section 7 (stretch and table beside repeat), section 9 (the rule table and count, 35), section 10 (the optional stretch key and the bundle's wires) and section 11 (the API list, [[wire]] of library.toml, tint). docs/GUIDE.md gains "Stretching and tables"; its Python blocks run in tests/test_readme.py. The [[wire]] and wires bundle key are the toolkit's own additions beyond the spec's data model, recorded in D56. The version bump, tag and release are not part of this change. Why: the spec is the one design document and must describe what the code does. Cost if wrong: revert the file; code and tests read only its code blocks and the rule table.

D59. leads(symbol, ports)

Decided: a public free function in leads.py. It removes every Line whose port is not None and not in ports; every other element stays in order, and so does every other field. A listed id that names no port of the symbol raises KeyError naming it; a listed port with no bound lead is fine. Ids are those the symbol holds, so 1.a after table. The caller passes the wired ports: symdef knows no net. Why: a router draws a stub only for a wired port, and a symbol's file cannot know which. Cost if wrong: additive; remove the module, the export and the test.

D60. Style.DASH_DOT and dash_dot_mm

Decided: Style gains DASH_DOT = "dash_dot", accepted wherever dashed is: element style, a [[wire]] style, the loader, the JSON schema and the serialized form. to_fragment draws module units 1 0.25 0.0625 0.25 (the spec fixes none; chosen as a long dash, then a dot of a quarter of a gap's length). to_fragment_mm gains dash_dot_mm: tuple[float, float, float, float] | None = None after dash_mm; drawing a dash-dot element while it is None raises ValueError naming the keyword, and a symbol with none never asks for it. Output without the style is byte-identical. Why: the style words are the file's, the lengths are the caller's, as for dash_mm. Cost if wrong: additive; remove the member, the keyword and the schema entries.

D61. muted

Decided: to_fragment and to_fragment_mm gain a keyword-only muted: str | None = None, the colour of a symbol drawn as not installed (designer ruling, amendment 3: the caller's colour, as tint is, not a fixed grey). It is checked like tint (check_colour, shared); a bad value raises ValueError whether or not it is used. Muted draws the group stroke, every text and every solid or tint fill in that colour; every line style becomes a dash and a gap each of the normal stroke width (Weight.NORMAL.value, or weights_mm[Weight.NORMAL] in mm, a KeyError if absent); a text has no stroke and no dash; an unfilled shape stays unfilled. dash_mm and dash_dot_mm are then not read. With None the bytes are those of 0.7.0. Why: one look for a thing that is not installed, with the colour a drawing convention of the caller. Cost if wrong: additive; remove the keyword and the helper.

D62. The interface spec is amended in place for 0.8.0

Decided: SYMBOL_INTERFACE.html gets a change-list row (2026-10-15, 0.8.0); section 4 names dash_dot and its pattern, section 7 gains leads, section 11 lists leads, muted and dash_dot_mm and the [[wire]] styles. The rule count stays 35. docs/GUIDE.md gains "Bound leads and muted symbols". The version bump, tag and release are not part of this change. Why: the spec is the one design document and must describe what the code does. Cost if wrong: revert the file; tests read only its code blocks and the rule table.

D63. texts in to_fragment and to_fragment_mm

Decided: both gain the keyword-only texts: Mapping[str, str] | None = None. None gives the 0.8.0 bytes (pinned by tests/test_slot_text_identity.py). Otherwise one <text> per slot with a non-empty string, in slot id order (_slots_by_id, the preview's rule), after the elements. Alignment is the preview's: E start and W end, capitals centred on the point; N middle, baseline on it; S middle, baseline one capital below it. One table (SIDE_ALIGN) feeds both functions and the preview. to_fragment_mm draws at font_mm with cap_ratio * font_mm as the capital height and never measures; to_fragment auto-sizes as the preview does (at most 1 M, size 0 draws nothing). Attributes: fill black or the muted colour, stroke="none", font-family="sans-serif" in module units and the caller's family in mm, no class (designer, G6). A key that is no slot id raises KeyError before anything is drawn, also for an empty string. Why: render must not build slot text itself; the preview already fixes the baseline rule. Cost if wrong: additive; remove the keyword, the table and the helpers.

D64. Required slots checked when texts are drawn

Decided: both functions gain required_slots: Sequence[str] = (), shaped as lint's argument and expanded by the same function (required.required_ids, which slot_missing now calls; its findings are unchanged). A missing slot raises ValueError naming the symbol and the slot ids, only when texts is not None; an empty string satisfies it. The kind = "symbol" limit of the lint rule comes with the shared function, so another kind demands nothing here either. Why: designer ruling G1; one rule in one place. Cost if wrong: additive; remove the keyword and the check.

D65. turn = true

Decided: Slot.turn: bool = False (last field), the slot key turn (loader, schema), written by serialize only when true so a set without turned slots keeps its bytes. box is the footprint as drawn; a turned string runs along its height and to_fragment fits it there. No new lint rule. A turned string reads bottom-up: N starts at the point, S ends there, E and W centre on it; the baseline sits half a capital east of the point for N and S, a capital for E and none for W, so the glyphs lie beside the box. The text carries transform="rotate(-90 x y)" about its baseline point, the one transform symdef writes (to_fragment_mm's docstring says so). orient never changes turn; repeat, table, stretch and a composite's slot reference keep it (they copy slots with replace). Why: designer rulings G2 to G5. Cost if wrong: additive; remove the field, the key and the branch. Known: the to_svg preview ignores turn in 0.9.0, so a turned slot drawn flat misleads a symbol author; the fix comes in the next release through the shared SIDE_ALIGN table (designer 2026-10-16).

D66. The interface spec is amended in place for 0.9.0

Decided: SYMBOL_INTERFACE.html gets a change-list row (2026-10-16, 0.9.0), section 6 the turn key and two paragraphs on drawing, section 11 the two keywords. docs/GUIDE.md gains "Drawing slot text". The rule count stays 35. The version bump, tag and release are not part of this change. Why: the spec is the one design document and must describe what the code does. Cost if wrong: revert the file; tests read only its code blocks and the rule table.

D67. Weighted cuts

Decided: Stretch.weight: float = 1 (last field), the file key weight (a number above zero; the loader and the schema refuse zero and below), written by serialize only when not 1. An axis may carry several cuts. stretch sorts the axis's cuts by at, shares length minus the natural extent among them in proportion to their weights, and moves a coordinate by the sum of the shares of the cuts it lies strictly beyond. One cut takes delta itself, not delta * w / w, so a single-cut result is the 0.9.0 bytes. A line or polyline across a cut grows by that cut's share; a circle, arc or text across any cut raises ValueError; one wholly beyond some cuts moves by their shares. offsets is unchanged and runs after the shares. stretch-cut loses its "second stretch per axis" finding and gains "a second cut at the same at", so the rule count stays 35. Why: designer ruling on weighted cuts (Q4, Q5). A title block needs a fixed edge and two growing spans. Cost if wrong: additive; a file without weight and with one cut per axis is unchanged.

D68. Slot side C

Decided: C is not a compass point. Centre (a one-member enum, Centre.C) and SlotSide = Direction | Centre are new in model.py; Slot.side is a SlotSide, so Direction, ports and anchors never see C. The loader takes "C" for a slot side only (its own enum), the schema has a slot_side definition, and serialize writes "C". slot_box of a C slot is [w, h] centred on position, turned or not (box stays the footprint as drawn). Text aligns through the same two tables as the other sides: C is ("middle", 0.5), so the baseline sits half a capital below the point and the capital height is centred on it; a turned C is ("middle", 0.5) east, the glyphs centred across the reading line. orient leaves a C side as it is and moves the point. repeat, table, stretch and a composite's slot reference keep it (they copy with replace). Why: designer ruling Q1 to Q3. A slot side is where text sits and a port side is where a wire leaves; keeping C out of Direction means a port can never be C. Cost if wrong: remove the enum, the schema value and the table entries. Concern (spec): the spec asks for a lint check that a C slot's position is its box's centre. With the box centred on position by definition (Q3) and stretch recomputing position as the new centre, no stored slot can fail it. No such check is in 0.10.0 pending the designer's ruling.

D69. Slots follow the cuts

Decided: stretch moves each corner of a slot's box and its position by the shares of the cuts they lie beyond (stretch_slot.py). A box across a cut grows by that cut's share, and the stored position and box are recomputed so slot_box of the result is exactly the moved corners: the side's own edge follows its corner, and the centred axis takes the middle of the moved corners. A box whose two edges move alike keeps its box and its position moves as in 0.9.0 (same bytes). A turned slot grows along its authored box. The room a slot has after stretching is the stretched symbol's slot_box. Why: designer ruling; a slot that spans a cut must grow with the body. Cost if wrong: a symbol with a slot across a cut changes size; every other output is unchanged.

D70. between elements

Decided: Line.between and Polyline.between (last field, default false), the file key between on those two element tables only (a circle, arc or text with it is a schema finding), written by serialize only when true. table(row, n, ...) draws a between element of the row in rows 1 to n-1 and leaves it out of row n, so n = 1 draws none. The head is unaffected: a between element in a head is drawn as authored, and so is one on a lone symbol. repeat and translate keep the flag (replace). A table without a between element is byte-identical to 0.9.0. Why: designer ruling; a strip has one tick fewer than it has cells. Cost if wrong: additive; remove the field, the key and _row_elements.

D71. The interface spec is amended in place for 0.10.0 (D67 to D70)

Decided: SYMBOL_INTERFACE.html gets a change-list row (2026-10-16, 0.10.0), the stretch and element keys in section 4, side C in section 6, the stretch and table paragraphs in section 7, the stretch-cut row in section 9 and the types in section 11. docs/GUIDE.md gains "Weighted cuts, moving slots and ticks between rows". The rule count stays 35. The version bump, tag and release are not part of this change. Why: the spec is the one design document and must describe what the code does. Cost if wrong: revert the files; tests read only the code blocks and the rule table.

D72. A non-C slot keeps its position across a cut (0.10.1)

Decided: stretch_slot moves the position of every slot but C by its own shift, the shares of the cuts it lies beyond, as in 0.9.0, and grows box by the difference of its edges' shifts. Only a C slot is placed at the middle of its moved edges (D68). So a W, E, N or S box across a cut grows while its position stays where 0.9.0 put it; slot_box of such a result is centred on the position on the centred axis and is no longer the moved corners there. 0.10.0 re-centred every side, which moved the text of marking.<port> slots across a cut. Why: designer spec (position moves with the cuts it lies beyond, D69; only C is centred, D68); found by a byte check against 0.9.0. Cost if wrong: a non-C slot across a cut sits at its box centre again; revert _place.

D73. Font metrics are library data (0.11.0)

Decided: library.toml takes an optional [font] table with units_per_em, cap_height, ascent, descent and default_advance (numbers above zero, all required), an optional thick_factor (default 1: what an advance is multiplied by for Weight.THICK) and a required [font.advances] table of one number per single character. bundle.json gains an optional font object of the same keys, advances an object, written only when the library has a font, with thick_factor only when it is not 1. Library.font and LibraryConfig.font are FontMetrics | None (frozen, slotted, in symdef.font), None when none is declared. text_width(font, text, height, weight=Weight.NORMAL) is the sum of the advances in ems times height; a character not in advances takes default_advance; with font=None it is 0.6 em per character, the measure of 0.10.1, computed in the same order so existing output is byte-identical. body_box, keepout_box and element_box take font=None. cap_height(font, height) is the capital's height in module units (0.72 em with no font). The font is data in the library, never global state; kerning, ligatures and per-weight advance tables are not modelled. Why: font metrics are symdef library data, as the rest of the library is. Cost if wrong: the keys are additive and optional; remove font from the two dataclasses, the loader and the bundle, and font=None from the three box functions.

D74. Slot text: slot_text, slot_box with a text, TextPlacement (0.11.0)

Decided: the module symdef.slottext holds SIDE_ALIGN and TURNED_ALIGN (moved out of svg, which reads them from there) and slot_text(slot, text, height, font) -> TextPlacement(point, anchor, turned). point is the baseline point: the slot point shifted by the table's number in cap heights (south for an upright slot, east for a turned one); font gives the cap height, and None gives 0.72 em. text does not move the point, since the anchor does the aligning; it is in the signature as the ruling gives it. slot_box(slot, text=None, height=None, font=None) with no text is the reserved box of 0.10.1; with a text it is the union of the reserved box and the string's extent (its measured width by one cap height, upright from the anchor, or turned bottom-up with the caps to the west of the point). A text without a height raises ValueError. Why: the caller reads slot text placement from symdef, not its own copy. Cost if wrong: additive; the new parameters default to the old behaviour. Revert slottext.py and the three parameters.

D73 amended: the library's settings are [font] and [grid] in library.toml

Decided: the [font] table of D73 also takes a required name (a string; it changes no measure), and library.toml gains an optional [grid] table with module_mm (a number above zero) and divisions_per_module (an integer power of two, so a division is exact in floating point and the off-grid test stays an exact multiply). Grid(module_mm, divisions_per_module) (frozen, slotted, in symdef.units, with division = 1 / divisions_per_module) is Library.grid; a library with no [grid] has DEFAULT_GRID, 2.5 mm and 8 divisions, which are DEFAULT_MODULE_MM and GRID_DIVISION of 0.10.1, so every constant keeps its value. The bundle gains an optional grid object, written only when the grid is not the default, so existing bundles stay byte-identical. lint(symbol, required_slots=(), grid=DEFAULT_GRID) and off_drawing_grid(symbol, grid=DEFAULT_GRID) check the drawing grid against the library's own; check and build pass library.grid. The wiring grid (port-off-wiring-grid) is a separate rule and is unchanged. to_fragment_mm keeps its module_mm keyword; a caller passes library.grid.module_mm. Why: one settings file, frozen in the loaded library. Cost if wrong: both tables are optional; revert Grid, the two keys and the grid argument.

D75: grid divisions are helpers that take the grid

Decided: to_divisions(grid, v) -> int, from_divisions(grid, n) -> float and ceil_divisions(grid, v) -> int in symdef.units, exported. The grid comes first, as the amended D73 rules; there is no public DIVISIONS_PER_MODULE constant, a caller reads grid.divisions_per_module. to_divisions raises ValueError naming the value (repr) when v is not a whole number of divisions, and for NaN or infinity. ceil_divisions is the one round-up rule: it counts a value within 1e-9 divisions above a multiple as that multiple, so float noise from a measured extent adds no division. GRID_DIVISION and snap stay unchanged. Why: the grid is library data, so the helpers take it. Cost if wrong: additive. Move the tolerance by editing _DIVISION_TOLERANCE; remove the three functions to revert.

D76: turning helpers are public; orient_box turns a box about the origin

Decided: orient_point and orient_direction join __all__, and orient_box(box, orientation) -> Box is new in symdef.orient. It turns the box's two corners as points (mirror x first for an MR orientation, then clockwise quarter turns) and re-bounds them, about the symbol's origin, as orient does. For any symbol and all eight orientations orient_box(body_box(s), o) equals body_box(orient(s, o)); a test asserts it on a non-square symbol. Why: a caller turns a box once, in symdef, not by its own copy of the maths. Cost if wrong: additive; remove orient_box and the two exports.

D77: small accessors, and nodes_of public

Decided: Box.union(*boxes) (a static method; one box gives itself, none raises ValueError), slots_box(symbol) (the union of the slots' reserved boxes without the body; the origin box when there are no slots), pole_pitch(symbol) (the effective pitch: the symbol's own, else the default 4 that repeat already uses, imported from one constant) and pole_port(k, port_id) (the id a port takes in pole k, "<k>.<port_id>"; repeat now builds every pole id through it). All four and nodes_of (every node, the declared ones then one per unlisted port) join __all__, each with a docstring and a test. Why: the caller reads these facts from symdef, not a copy. Cost if wrong: additive; repeat's output is byte-identical (the tests of D0 to D72 stay green).

D78: a loaded library's symbols are read-only

Decided: load_library and load_bundle wrap Library.symbols in a MappingProxyType, so assigning into it raises TypeError. The field is typed Mapping[str, Symbol] (it already was); no writer of .symbols exists in the repository. A Library built by hand keeps whatever mapping its caller passes. Why: a library is a frozen value, as the other records are. Cost if wrong: a caller that edited a loaded library's symbols must copy them first; drop the wrap to revert.

D79: the grid helpers read the grid, and Grid checks itself

Decided: Grid.__post_init__ raises ValueError naming the value and the fix when module_mm is not a finite number above zero or divisions_per_module is not a power of two; the two rules are units.module_error and units.divisions_error, and the loader's [grid] checks call them, so there is no second copy. snap(v, grid) and on_grid(v, tol, grid) take the grid as a trailing argument (as lint does), defaulting to DEFAULT_GRID; a call without a grid is byte-identical to 0.10.1. FontMetrics.advances and SIDE_ALIGN/TURNED_ALIGN are read-only mappings (MappingProxyType). This replaces D75's "snap stays unchanged". Why: a library's grid is data, so every grid function must read it; a grid that is built by hand must not be able to hold an inexact division; frozen records hold no mutable contents. Cost if wrong: additive for callers; drop the trailing argument to revert.

D80: symdef raises its own errors

Decided: the base error is SymdefError (renamed from GraphicalSymbolsError, no alias). Under it sit InvalidValueError (a bad argument or malformed data; replaces every ValueError raised by symdef), UnknownNameError (a name not in the set it was looked up in; replaces every KeyError), UnknownSymbolError and LibraryError. They are plain subclasses: none inherits the builtin it replaces, so except ValueError no longer catches symdef. A message gives the cause, the value and the valid values or the fix. No FileError: symdef raises no OSError itself, the reads and writes of files let pathlib's own propagate and the docstrings say so; project.init raises InvalidValueError for an existing file (review round 1; it first kept FileExistsError). The OSError that write_build and stale_build let propagate (disk errors) is a documented exception. to_fragment_mm raises UnknownNameError (not a bare dict KeyError) for a weight missing from weights_mm. tests/test_errors.py walks the package with ast and fails on a raise of any builtin exception class. The loader's own except ValueError clauses around standard-library parsers stay. Why: one base to catch, named causes, and a clean break while there are no other callers to keep. Cost if wrong: a consumer that caught the builtins must catch SymdefError or the subclass; add a second base to a class to revert one.

D82: measure, and the font holds one advance table per weight

Decided (font part, committed first): FontMetrics.advances is a read-only mapping from Weight to a read-only mapping of character to advance, one table for every Weight; a font missing one raises InvalidValueError naming it. thick_factor is removed. text_width reads the table of the weight it is given, so a bold text differs glyph by glyph from a regular one. library.toml's [font] takes [font.advances.normal] and [font.advances.thick], both required, each a table of single characters to numbers above zero; the bundle's font.advances is an object with the keys normal and thick, each such a table. default_advance stays one number for both. Why: a bold face is not a scaled regular face, so a factor mismeasures it. Cost if wrong: a library with a font must write a second table; a bundle written by 0.11 does not load (its advances is flat). Fonts were new in 0.11, so the break is free.

D81: GridPoint, GridBox and GridPort are their own types

Decided: symdef.gridtypes holds three frozen slotted types whose coordinates are whole grid divisions: GridPoint(x, y), GridBox(min, max) with width, height and GridBox.union (the shape of Box.union), and GridPort(id, x, y, direction). A coordinate that is not an int (a bool too) raises InvalidValueError. They do not subclass Point or Box. Why: divisions are a second unit; a float-typed Point could carry either unit unnoticed. Cost if wrong: additive; drop the module to revert.

measure(symbol, orientation, library, texts=None, text_height=None) -> Measure (module symdef.gridmeasure, so the function does not shadow its own module). It orients the symbol, then reads body_box, slot_box (with library.font) and the ports, and returns a frozen Measure: body, keepout (the body united with every slot box, text included) as GridBox; slots as id to GridBox; ports as id to GridPort with the direction after the turn; slots and ports are read-only. Choices: slot text comes from the optional texts (slot id to string) with text_height; a text given without a height raises InvalidValueError naming text_height, a key that is no slot raises UnknownNameError; a slot with no string is its reserved box. An extent rounds outward (min = -ceil_divisions(-min), max = ceil_divisions(max)), so a body already on the grid is exact; a port is a position and goes through to_divisions, so an off-grid port raises naming the port and the value. A slot's text is measured in the normal weight; a body Text uses its own weight's table. Why: SB12: layout gets the data from symdef and converts nothing. Cost if wrong: additive; delete the module and the exports to revert.

D83: to_placed_fragment draws a symbol at a grid position

Decided: to_placed_fragment(symbol, orientation, at, library, *, tint, muted, texts, required_slots) in symdef.svg_placed orients the symbol, draws it with to_fragment, and wraps it in one <g transform="translate(X Y)">, X and Y being at (a GridPoint) turned into module units by from_divisions(library.grid, n). to_fragment, to_fragment_mm and to_svg are unchanged, so every golden is byte-identical; to_fragment_mm is listed in the changelog for removal in 0.13, once its callers use the placed call. Why: SB12: the renderer places a symbol with no unit conversion of its own. Cost if wrong: additive; delete the module and the export to revert.

D84: two doors, symdef for consumers and symdef.authoring for authors

Decided: symdef.authoring holds nine names: build, check, init, lint, write_build, stale_build, RULES, finding_key and LibraryConfig. They leave symdef.__all__; the two __all__ sets are disjoint and from symdef import build raises ImportError. The rule: a name goes to the author door when no consumer-side call takes or returns it. A consumer's import census (2026-10-16) found no consumer import of these nine. LibraryError stays on the consumer door: load_library and load_bundle raise it. Finding and Severity stay there too, since they ride on LibraryError.findings; so does Status, a Symbol field a consumer building one sets. The symdef CLI imports from symdef.project, unchanged. symdef.authoring only re-exports, so the purity gate needs no entry for it. Why: a consumer's surface is what it draws with; the authoring verbs are noise there and a second reason for a major bump when one changes. Cost if wrong: breaking for an author who imports from symdef: change the import path.

D85: a surface snapshot and a changelog

Decided: surface.toml at the repo root lists, sorted, the __all__ of symdef and symdef.authoring; scripts/write_surface.py writes it and tests/test_surface.py fails on any difference. docs/CHANGELOG.md has one section per version, newest first, with one line per name added, removed, moved or widened. tests/test_changelog.py requires a section for LIBRARY_VERSION, as the newest, with a line. The rule: a surface.toml diff comes with a changelog line in the same commit. The first entry is the retroactive Slot.side widening to Direction | Centre, in 0.10.0. Why: a consumer pins a version and needs to see what moved; the snapshot makes a silent move a red test. Cost if wrong: additive; delete the file, the script and the two tests to revert.

D86: two wire pitches in Grid, and a map of text heights in the font

Decided: Grid gains wire_pitch (default 8) and wire_pitch_fine (default 4), in divisions; module_mm stays the fixed symbol size. [grid] takes wire_pitch and wire_pitch_fine and refuses a third pitch key (unknown key), a pitch that is not a whole number above zero, and a fine pitch that does not divide the standard one. Every port of a resolved symbol must sit on the standard pitch: resolve_library adds the port-off-wiring-grid finding (the lint rule, reused, exempt through lint_allow) at load, so a library with an off-pitch port does not load. electrical_symbols was measured first: 76 symbols, 117 ports, none off a 1 M pitch. FontMetrics gains heights, a read-only map from a name to a capital height in millimetres, read from [font.heights] and carried by the bundle (written only when not empty). symdef does not interpret the names. measure is unchanged and takes no module_mm. Why: a consumer's GRID-HOME needs the pitches and the text heights as library data. A default of 8/4 with 8 divisions is 1 M and 0.5 M; a library with 4 divisions and no pitch keys gets a standard pitch of 2 M. Cost if wrong: additive for a library that sets nothing; the loader check is new for one that has an off-pitch port (set wire_pitch or move the port).

D87: measure_font, and [font] may name its files

Decided: measure_font(regular: bytes, bold: bytes) -> FontMetrics (new module fontmeasure) measures two TTFs with fontTools. The advances are hmtx widths for ASCII, Latin-1 and eight symbols, the regular face for Weight.NORMAL and the bold face for Weight.THICK. cap_height is the top of the glyph H, descent the depth of the glyph p, ascent the OS/2 typographic ascender, all from the regular face. default_advance is the largest regular advance of the covered set (1843 for the house face). name is the regular face's family name (name id 1). A face without H or p, faces that differ in units per em, and bytes that are not a TTF raise InvalidValueError; the first names the glyph. [font] takes either the literal metrics or name and files = { regular, bold }, never both; symdef build reads the files, relative to library.toml, in files.py and writes the measured table into the bundle. The measure takes bytes, so symdef reads no file at runtime. fonttools==4.67.0 is a runtime dependency, ruled by the designer (spec SETTINGS ST5); CLAUDE.md's "no runtime dependency" line is out of date and the designer edits it. fontmeasure.py is in the purity gate's IMPURE_MODULES only because fontTools needs a BytesIO; it touches no file. Why: a consumer font must come from its files with one function (spec SETTINGS ST5). Cost if wrong: the tables of the house font are tested exactly against an independent copy; a different default-advance rule moves only characters outside the covered set.

D88: Library.with_settings

Decided: Library.with_settings(*, module_mm=None, font=None, heights=None, lines=None) returns a replaced library. font is the pair of TTF bytes, measured by measure_font; the library's heights are kept unless heights is given. Grid and FontMetrics run their own checks, a height or width must be a number above zero, a wire weight needs a width, and then the rule text-outside-body runs over every symbol of the result (D90, which replaced text-too-large here) and a hit raises InvalidValueError naming the symbol. The logic is the free function symdef.settings.with_settings; the method delegates through a deferred import because settings imports model. The concern that text-too-large reads no font was ruled in D90: text-outside-body measures with the font. Why: spec SETTINGS ST4. Cost if wrong: additive; the font-aware rule would be a lint-rule change in a later release.

D89: [lines], a width in millimetres per weight

Decided: library.toml takes [lines] with normal and thick as millimetres above zero. Library.lines is a read-only Mapping[Weight, float], empty when the table is absent, and the bundle carries lines only when not empty, so existing bundles keep their bytes. With the table present, a [[wire]] weight without a width is a load error (lines_problems), and with_settings(lines=...) runs the same check. Nothing in drawing reads lines. Why: spec SETTINGS ST4; the millimetres lived in the consumer. Weight.value * module_mm already equals them (0.1 and 0.2 of 2.5 mm). Cost if wrong: additive.

D90: text-outside-body, the font-aware check that replaces text-too-large at build

Decided: text-outside-body (symdef.lint.textbody.text_outside_body(symbol, font, module_mm)) checks a fixed Text anchored inside the symbol's body, the union of its non-Text elements, and requires its extent to lie wholly inside that box, measured with the library font at the text's height and weight. A text anchored outside the body, or a symbol with no other element, is not checked. It is a library-level check outside the per-symbol lint registry: not one of the 35 guide-table rules, not in __all__: lint() takes no font, so a registered rule could not measure. Two call sites run it: load_library (and so symdef build) with the library font when it has one, raising LibraryError naming the symbol; and Library.with_settings, instead of text-too-large; text-too-large stays for authoring. Why: designer ruling 2026-10-16 (b), spec SETTINGS ST4 amendment 2. text-too-large compared height with 1 M and read no font, so a consumer font could never fail the build. Cost if wrong: additive; the free function can move into the lint registry later.

D91: measure(attach=), a coil's contact-table room is measured by symdef

Decided: measure(symbol, orientation, library, texts=None, text_height=None, *, attach=None) takes attach, a map of slot id to a Symbol. The attached symbol's keepout_box size is placed at the turned slot's point and side, as a slot's reserved box is (E grows right and W left, centred on y; N grows up and S down, centred on x; C centred both ways), and united with the slot's box (slot_box, with its text when given). The result is Measure.slots[slot_id], and so part of Measure.keepout. As with a slot's box, only the point and side are turned with the view, never the attached box. A key of attach that is not a slot id of the symbol raises UnknownNameError naming the key and the slot ids, as texts does. An empty or absent attach returns exactly what measure returned before. The caller builds the attached symbol with table(row, n, "y"), and tiers as table(that, tiers, "y"). Why: designer ruling 2026-10-16 (SYMDEF-LAYER Part D Q1 a). The room for a coil's contact table is a drawn size, and symdef owns drawn sizes (owner 2026-10-16), so the consumer's layer only copies fields. Cost if wrong: additive; a new keyword with a default.

D92: FontMetrics.family, read from the font file

Decided: FontMetrics has a field family, the family name a renderer resolves the font by. An empty family at construction means name, so .family is never empty. measure_font(regular, bold) sets it from the regular face's name ID 16 (typographic family), else name ID 1; name stays ID 1. The literal-table [font] form, which has no bytes, takes an optional family, default name. The files form takes its family from the bytes; a family key beside files is a schema finding saying the family comes from the font file. The bundle's font object writes and reads family. Why: designer ruling 2026-10-16. Typst resolves a font by its typographic family (ID 16); symdef recorded ID 1, which is "DejaVu Sans Condensed" for the house face (ID 16 is "DejaVu Sans", ID 17 "Condensed"), and Typst does not resolve it. A family read from the bytes cannot disagree with the face that is drawn and measured. Cost if wrong: additive; a new field with a default.

D93: [font] heights beside files

Decided: [font] with files takes heights, a table of names to capital heights in mm, each above zero, beside name and files. LibraryConfig.font_heights holds them between the parse and the read; files.py puts them on the measured FontMetrics.heights. symdef does not interpret the names (D73). family beside files stays refused (D92). heights and files without name is still "missing required key 'name'". Any other key beside files is refused with a message that names the key and the fix: "K is not a key of the files form (name, files, heights); remove it, or drop files and give the measured tables". The bundle needed no change: heights already round-trips. Why: designer ruling 2026-10-16 (SYMDEF-0.16). The consumer's text sizes are not in the font bytes; the files form could not carry them, so a files-form library had no heights. Cost if wrong: additive; a key that was refused is accepted. The reworded error is the only changed text.

D94: fitted_table, a table sized by its texts

Decided: fitted_table(row, axis, texts, library, text_height, *, head=None, head_texts=None) returns table(row, len(texts), axis, head) with each column as wide as its widest text. texts holds one mapping of slot id to text for each row. Each text is set in library.font at text_height (module units), and the widest over all rows and head_texts is rounded up to whole grid divisions. A column is a row slot with a [[stretch]] cut across its box on the other axis; the cut grows by the rounded width less the slot's reserved extent, never below zero, so the row's pads stay. The growth goes through stretch, and the head grows at the same cuts. A column never shrinks below the row's natural slot box. Errors raise InvalidValueError or UnknownNameError, each naming the thing and the fix: no font; a text height not above zero; a text for a slot the row lacks; a slot with no cut across its box; a head with no cut where the rows grow; head_texts without head. Why: owner 2026-10-18 chose the text-sized table: the contact table's width follows its texts today, and the measure belongs in symdef, which owns the font and the drawn sizes. Cost if wrong: additive; a new function, and nothing existing changes.

D95: marker fit: multi-line slot text, fitted_symbol, closed wires

Decided: (1) slot_lines(slot, text, height, font) -> tuple[TextPlacement, ...] returns one placement per \n line. Under the default "cap" text-block rule the rows are LINE_PITCH = 1.5 cap heights apart (one cap height and half of one more); the "grid" rule is in the Rule line below. The block is centred on the slot point across the stacking direction (south, or east for a turned slot, west to east), except that it grows away from the point on the side where the text already leaves it: N up, S down, a turned W west, a turned E east. text_box is the union of the lines' boxes, and to_fragment and to_fragment_mm draw one <text> per line; a one-line text is placed as in 0.17, byte for byte. to_fragment's sample size also divides the box height by the number of lines. (2) fitted_symbol(symbol, texts, library, text_height) grows the cut across each named slot's box on x and on y so the slot holds its text as text_box measures it, rounded up to whole grid divisions, through stretch; it shares _growth and _grown with fitted_table, with a lenient mode: a text that fits needs no cut, and a slot that must grow and has no cut raises InvalidValueError. (3) The marker stub needs no source: wire already draws a port-to-marker polyline in any [[wire]] style, a data package names its style marker; a test and a guide sentence cover it. (4) wire(..., *, closed=False): closed=True emits Polyline(..., closed=True) with no fill and needs three points. Measured: the same rectangle rendered through to_fragment_mm and cairosvg, open with a repeated first vertex against closed, at 0.8 mm, differs in a 16 px square at the closing corner (two butt caps against a mitred join), so the keyword is needed. The text-outside-body lint (D90) measures fixed Text elements, which stay one line; the block is measured through slot_box(slot, text, ...), which uses text_box. Rule: [font] text_block = "cap" | "grid" (default "cap", today's pitch and cap-centred baseline) sets how a text block is placed; "grid" is the consumer's renderer's rule: row pitch = text height rounded up to whole divisions, block top snapped down to a division, baseline = top + ascent * height (Ruling 6). slot_text, slot_lines, text_box and slot_box take grid for it. Why: designer ruling 2026-10-18 (SYMDEF-0.18, Ruling 5, M1 to M4): the marker drawings need a symbol fitted to its texts, multi-line slot text, a stub in a wire style, and a closed outline that joins at its corner. Cost if wrong: additive. The only changed behaviour is a slot text containing a newline, formerly one <text> with the newline in it.

D96: "grid" centres a text at the edge plus half the divisions, floored

Decided: under text_block = "grid", a text anchored "middle" (side N, S, C; for a turned slot E, W, C) sits at the slot box's start edge plus floor(length / 2) whole divisions along the text, in the symbol's own frame before orientation; an offset from the edge, not a floor of the absolute coordinate. "cap" is unchanged. Why: designer ruling 2026-10-18 (Ruling 13, A1/A2): the consumer's renderer centres at box + width // 2, so an odd width left a half-division gap against symdef's true centre. Cost if wrong: a "grid" text on an odd-division box moves half a division; "cap" and even widths are unchanged.

D97: [grid] stretch_split = "whole", a multi-cut growth in whole divisions

Decided: Grid.stretch_split is "weight" (default, today's split) or "whole", set by [grid] stretch_split and written to the bundle's grid only when "whole". stretch(symbol, axis, length, offsets=None, *, grid=None) and table(..., *, grid=None) take the library's grid; fitted_table and fitted_symbol pass library.grid. With "whole" the growth must be a whole number of divisions (within 1e-9, else InvalidValueError naming the symbol, the growth and the fix; nothing is rounded). Cuts sorted by at, near to far: each cut but the last takes floor(growth * weight / total weight) divisions, the last the remainder, so shares sum to the growth. Two equal cuts give the near one floor(g / 2). A single cut takes all of it. fitted_table stretches with weights equal to each cut's own growth, which are whole divisions, so its output is identical under both values. The setting is on Grid, not [font]: the rule is about grid divisions and Grid already travels as library.grid to the functions that take a grid (D95); a library with no [font] still has a grid. Why: designer Ruling 13 (A1/A2) and Ruling 15 (2026-10-18): the consumer's renderer splits a growth in whole divisions with the near half floored, so a weighted split puts a cut a fraction of a division off. Opt-in by library setting, so no existing library changes bytes. For three or more cuts the designer ruled: near cuts floor their weighted share, the far cut takes the remainder. Cost if wrong: additive and opt-in; nothing existing changes. Grid gains a field, so its repr and equality see it; a table or stretch call without grid is unchanged.

D98: a symbol declares its body and keep-out box (body, keepout)

Decided: a symbol file may carry body = [x0, y0, x1, y1] and keepout = [x0, y0, x1, y1], four numbers each, x0 < x1 and y0 < y1. Symbol gains body: Box | None and keepout: Box | None (default None, at the end). body_box returns the declared body exactly (whatever the elements and the font); keepout_box returns the declared keepout if there is one, else the body (declared or measured) united with the slot boxes as before. The keys are body and keepout, not body_box and keepout_box: those two stay the computed, ignored keys of the resolved JSON, so a resolved file never reads as a declaration. The resolved JSON writes body and keepout only when set; its body_box and keepout_box then give the declared boxes. An undeclared symbol is byte-identical to 0.20 in the API, the JSON and every SVG. Units: module units, not grid divisions. Every coordinate in a symbol file is in M (spec: files never contain millimetres), and symbol_from_data and symbol_to_data know no grid, so divisions would need the library grid threaded through the loader, the resolver and the round trip. The order said "grid divisions"; a data author converts (a division is 1/8 M by default). A box off the 0.125 M grid is not reported: off-drawing-grid is not extended. Validation: the shape (four numbers) is the schema's and the loader's; x0 < x1 and y0 < y1 is the loader's alone, a schema finding at /body or /keepout naming the symbol and the fix (the JSON schema cannot say it). keepout is not required to contain body. Orient and translate carry a declared box as the box of its two moved corners. stretch moves each edge by the shift of its coordinate, as a line end: an edge past a cut moves with the cut, one before it stays; the natural extent it reads is the declared body's. repeat declares the union of the translated pole boxes; table the union of the stretched head's box and the translated row boxes, and its row step is the row's declared body (that is how a framed table keeps its size). Composites: a composite's own body and keepout apply. A part that declares either, in a composite that declares neither, is a schema finding at /parts/<n> (declare it on the composite or drop the part's): a part's box is neither silently lost nor silently united. With the composite's own box, the part's stays the part's. Lint: new rule element-outside-body, group Geometry, ERROR, not orientation-dependent, after stretch-cut: 36 rules. It fires for each line, polyline, circle or arc whose element_box leaves a declared body (tolerance 1e-9), naming the symbol and the element. A text is left to text-outside-body, which has the font and now measures against the declared body when there is one (a symbol with a declared body and only texts is then checked). lint_allow works as for any rule. Where body_box stands for "the body" every caller follows the declared box: gridmeasure, fitted, table, stretch, the port-on-body-edge, slot-overlap-body and stretch-cut rules, and the annotated SVG's body rectangle. The plain SVG view holds the declared body united with the element extent, so an exempted element is never clipped. No caller keeps the element extent on purpose except element-outside-body and text-outside-body's shape box (when undeclared). Spec concerns, spec not edited beyond rows: section 9 prose and tables say "35" in the 0.7.0 change row only (history); section 11's Symbol(...) line already omits lint_allow and now omits body and keepout; the definition of the body as the union of element extents (section 3) is now the undeclared case. The root CLAUDE.md still says "the 35 lint rules". Why: designer ruling 2026-10-18 (Ruling 57, TABLE-LOOK A): a framed table cannot be small because the frame polylines set the body; a declared body keeps the size while the data drops the frames. Cost if wrong: additive; an undeclared symbol is unchanged. Symbol gains two fields, so its repr and equality see them, and the lint rule count moves to 36.

D99: wire(..., lanes=1, pitch=None), parallel lanes in one symbol

Decided: wire takes keyword-only lanes: int = 1 and pitch: float | None = None. It still returns one element Symbol; elements holds one Polyline per lane, lane 0 first, all in the style's weight and style. Lane 0 lies on points. Lane k is the points moved k * pitch: every corner gets +y if a run at it is horizontal and +x if a run at it is vertical, so a corner between a horizontal and a vertical run moves both ways, which is the mitre (the outer lane runs longer, the inner shorter). The side is fixed by the axis of the run and not by its direction: a horizontal run going left still steps towards +y. pitch is in module units and defaults to library.grid.wire_pitch converted with from_divisions; pitch=None and an explicit value are the only two sources, so a style carries no lane pitch. lanes=1 returns exactly what wire returned before, whatever pitch is (a pitch of 0 or less still raises). Errors, all InvalidValueError naming the value and the fix: lanes below 1; pitch of 0 or less; closed=True with lanes above 1. Added by this decision: with lanes above 1 every run must be horizontal or vertical and have a length, else the same error, because "towards +y or +x" and a mitre are defined for axis-aligned runs only. Why: designer Ruling 62 (BUNDLE-DRAW step 0): a bundle's trunk is one straight multi-lane wire, and render would otherwise offset the polyline itself, which is drawing geometry outside symdef. Returning one symbol keeps the return type of wire; a tuple of symbols would change it. Cost if wrong: additive. A slanted run with lanes is refused rather than guessed; a later slanted offset would be a further decision.

D100: text_tag and corner_text, free text in millimetres

Decided: two new top-level names in freetext.py. text_tag(content, point, height_mm, *, anchor, font_family, turn=False, weight=Weight.NORMAL, tint=None, muted=None) -> str returns one <text> in mm at the baseline point; it calls the private slot_text_tag that the slot texts use, which gained bold (default False, so every slot text is byte-identical). Weight.THICK writes font-weight="bold", the face whose advances text_width uses for THICK. The fill is muted, else tint, else #000; a bad colour raises InvalidValueError as in to_fragment_mm. font_family is escaped with quoteattr. corner_text(box, corner, height, font) -> TextPlacement (corner is "NW", "NE", "SW" or "SE") gives the point, anchor and turned=False that text_tag takes: W corners start at the box's west edge and E corners end at its east edge; N corners put the capital top on the north edge (baseline = north + cap_height(font, height)), S corners put the baseline on the south edge. It works in the box's unit. Deviation from the order: text_tag has no cap_ratio, since the point is already a baseline and the tag needs no cap; corner_text takes font (as slot_text does) in its place, so a caller whose cap setting is not the font's 0.72 em passes a FontMetrics with its cap_height, or places the point itself. Why: designer Ruling 67 (RENDER-TEXTS step 0): render draws a free text (a drawn text with a box and a corner) and symdef had no call for it; a private import was rejected. Cost if wrong: additive. The corner rule (hang inside the box) is a guess at what the caller's boxes mean; a different rule is a new function.

D101: keepout_box is the body plus its bound leads

Decided: keepout_box returns the union of body_box and the extent of every Line whose port is set; a declared keepout still wins. Slots stay text slots: slot_box and slots_box are unchanged and no slot enlarges the keep-out. Consequences inside symdef: lint/ports.py _lane_frame now unites the keep-out with the slot boxes itself, so the port-lane check still sees every slot; Measure.keepout is still the body united with the slots (it is a measure result, not keepout_box); the resolved JSON keepout_box and the 0.9 stretch goldens' JSON files carry the new box (the SVG goldens are unchanged). Why: designer ruling 2026-10-18: "keepout_box = body plus leads only, with the slots staying text slots", from the owner rule that an attached text, a designation in a corner, never sets a row's width. Cost if wrong: a behaviour change for any caller that read the keep-out as the room of the labels; it reads slot_box for that. Measure.keepout keeps the old union, so the grid measure is unaffected.

D102: only_ports(symbol, ports) and stretch_to_ports(symbol, axis, edge, n, *, grid=DEFAULT_GRID)

Decided: two new top-level names. only_ports (in leads.py) keeps the listed ports with their bound leads and marking.<port> slots and drops every other port, its lead and its marking slot; other elements, slots and anchors stay; a declared keepout stays as declared; an unknown id raises UnknownNameError naming the id and the symbol. It is meant to run before stretch. stretch_to_ports (in stretch_ports.py) returns (length, offsets) for stretch(symbol, axis, length, offsets, grid=grid): the first n ports declared on edge, in order along the axis, take the first one's coordinate plus k times the grid's wire_pitch (in module units); the length is the margin from the body's low side to the first port, plus (n-1) pitches, plus the margin from the last declared port to the high side, never below the natural extent. It raises InvalidValueError naming the symbol, the edge, n and the declared count for n below 1 or above the declared count, for a symbol with no cut on the axis, and for an edge not parallel to the axis. The helper's name is my choice; the order gave stretch_to_ports as an example. Why: designer rulings 2026-10-18: only_ports "is general: any symbol with spare ports, not only supplies"; "(c)... stretch this symbol so its edge carries n ports on the pitch is toolkit geometry that any symdef user needs". Cost if wrong: additive. The margin rule (the symbol's own end margins) and "the first n ports" are guesses where the ruling is silent; a different layout of the ports is a new option. When the first port lies right of a cut, its absolute place in the stretched body is its natural one.

D103: the 0.22 release scope

Decided: symdef 0.22.0 holds D101 (keep-out), D102 (only_ports and stretch_to_ports) and nothing else. Designation corners as library data are not in 0.22. Why: designer ruling 2026-10-18: "Designation corners as library data are not in 0.22." Cost if wrong: a later release adds them; nothing here blocks it.

D104: an edge port pattern: Port.pattern, pattern_ports, rule port-pattern

Decided: a port table may say pattern = true (Port.pattern: bool = False; the bundle writes the key only when true, so every other output is byte-identical). It is one port that stands for n along its edge. pattern_ports(symbol, edge, n, *, grid=DEFAULT_GRID) (new module edge_pattern.py) replaces it by n copies, copy k at the first coordinate plus (k-1) wire pitches along the edge's axis (x for N and S, y for E and W), id pole_port(k, id) (k.<id>, as repeat numbers poles), each with its bound lead and its marking.k.<id> slot; n runs 1 to MAX_REPEAT. The order is stretch_to_ports, stretch, pattern_ports: bound leads count in body_box, so expanding first would widen the natural extent and shorten the growth without any error. pattern_ports raises InvalidValueError if the last copy lies past the body's high side. stretch_to_ports on an edge with a pattern port takes n up to MAX_REPEAT and returns {id: first} and the length natural plus (n-1) pitches; other edges are unchanged. New lint rule port-pattern (ERROR, Ports; 37 rules): the pattern port is the only port on its edge, the symbol has a cut on the edge's axis, and no node or path names it. port-isolated skips a pattern port, since it is wired as its copies. repeat and table carry the flag through replace and are not otherwise changed. The spec's section 9 and change list carry the rule and the key. Why: designer ruling (2026-10-19): a block box needs n ports per edge, n given at the call, not 16 or 24 declared per edge. Cost if wrong: additive. A pattern with other ports on its edge, and nodes or paths on a pattern port, are refused and could be allowed later by a further decision. The body-too-short check uses the high side only; a pattern whose first port lies left of the body is not checked.

D105: the 0.23 release scope

Decided: symdef 0.23.0 holds D104 (edge port pattern) and nothing else. Why: work order SYMDEF-0-23. Cost if wrong: a later release adds more; nothing here blocks it.

D106: repeat of a symbol with no through path

Decided: repeat (and the composite file's repeat key) no longer refuses a symbol with no through path. Pole 1's path keeps through only if it had it, so a symbol with none gives poles with none. The schema finding "repeat needs a part with a through path" (D17) goes. Why: designer ruling item 7; the limit sat in symdef (repeat.py, resolve.py), not only in a consumer. Cost if wrong: a repeat of a symbol meant to carry a through path no longer warns; lint through-missing still reports a kind = symbol file that lacks one.

D107: pitch and positions for a pattern port

Decided: pattern_ports and stretch_to_ports take keyword-only pitch (module units, a whole multiple of the wire pitch, at least one) or positions (n coordinates along the edge, strictly increasing, each gap a whole multiple of the wire pitch, inside the body). Both together raise. Copy k then stands at the first coordinate plus (k-1) pitches, or at positions[k-1]; its lead and marking slot move with it. stretch_to_ports grows the length by the last coordinate less the declared one. The default is the wire pitch, so every call that gives neither is unchanged. Positions replace stretch offsets for the copies: the order stays stretch_to_ports, stretch, pattern_ports. Why: designer ruling item 1 (marking text between neighbours, spreading to meet columns). Cost if wrong: additive keywords. Positions off the wire-pitch multiple are refused; a finer pitch would be a further option.

D108: named ports and one pattern port on an edge

Decided: lint port-pattern allows named ports on the pattern port's edge and instead reports two pattern ports on one edge. stretch_to_ports on such an edge counts only pattern copies and returns offsets for all of the edge's ports: left of the pattern port they keep their coordinate, right of it they move by the run's growth. pattern_ports raises if a copy is less than one wire pitch from a named port of the edge. Why: designer ruling item 2 (a supply's plus, minus and sig beside a run of outputs). Cost if wrong: the 0.23 rule text changes; a symbol that relied on the old refusal now lints clean.

D109: tables of unlike rows, gaps, alignment and a step that fits its text

Decided: table takes a symbol or a sequence of n rows (each placed with its body low edge at a running cursor and stepped by its own extent; equal rows give exactly today's offsets), keyword-only gaps (n-1 extra spaces) or positions (each row's low edge, not overlapping; never both) and head_align ("start", "center", "end": the narrower of head and rows sits in the wider; a head wider than the rows is not stretched then). Rows keep their ports numbered k.<id> as pole_port numbers poles. fitted_table takes fit: "cross" is unchanged; "step" grows the rows along the stepping axis to their widest text and fits the head's texts along both axes, so a table whose texts run along the stepping axis has marking boxes that never overlap. The implementation sits in table_rows.py. Why: designer ruling item 6; cable and connector drawings. Cost if wrong: additive keywords. A turned (orient) table is fitted before it is turned; slot text boxes do not turn, so the step is fitted in the unturned frame.

D110: the 0.24 release scope

Decided: symdef 0.24.0 holds D106 to D109 (items 7, 1, 2, 6) and nothing else. Items 3, 4, 5 and 8 of the ruling are the second half and are not in this release. Why: work order SYMDEF-0-24: the first half is released when ready. Also in 0.24.0: lint rule port-pattern ignores a node that is only the pattern port itself, the implicit single-port node a built bundle writes, so symdef check passes on its reload; a node or path naming it with another port is still refused. Cost if wrong: a later release adds the rest.

D111: measure takes a stretch

Decided: measure gains keyword-only stretch, a mapping from an axis to a body length in module units. Each axis is stretched as stretch(symbol, axis, length, grid=library.grid) does, then the symbol is turned and measured, so the result equals measuring the stretched symbol. The order of the axes does not change the result (a test holds both orders). It takes no offsets: a caller who must place ports calls stretch. No new public name. Why: work order STRETCH-MEASURE, designer rulings: a consumer that only sizes a stretched symbol should not build a drawn symbol. Cost if wrong: an additive keyword; a later offsets would be a further option.

D112: no file names an application that uses the toolkit

Decided: no tracked file (code, tests, docs, README, DECISIONS, CLAUDE.md) names an application that uses symdef; a consumer is "a consumer". tests/test_standalone.py lowercases every word of every tracked file and fails on a word whose SHA-256 is in its list of application-name hashes (both names, plural forms; a possessive splits into the name and "s"). The test spells neither name. Git history is unchanged. No package data changes, so no release. Why: designer ruling (owner 2026-10-22): the toolkit is shared standalone, and the application keeps its name to itself. Cost if wrong: a new application name needs its hash in the test's list.

D113: tag_roots and TextRoot

Decided: new tag_roots(symbol, orientation, library, *, gap, marking_height) returns four TextRoot(x, y, h, v) (top-left, bottom-left, top-right, bottom-right), in whole divisions of library.grid, in the frame measure uses; it lives in tagroots.py. Gaps in the spec, settled: - Signature: the turn is an Orientation and the grid and font come from library, as in measure. - marking_height is the height slot_text takes, in its unit. symdef still does not interpret height names (D73, D93). - "Top edge" means a port whose turned direction is N; the leftmost has the least x. The root's y is the baseline slot_text gives its marking.<port> slot (the one function, so the two cannot drift), rounded to the nearest division, halves up. A turned marking slot gives the y of its anchor point. - The gap in divisions is floor(gap * pole_pitch(symbol) * divisions_per_module + 0.5), halves up (a test pins 2.5 to 3). - The clamp: if the point (root x, baseline) has body.min.x <= x <= body.max.x and body.min.y < y < body.max.y, y is the body's top edge. - A top port with no marking.<port> slot gives y at the body's top edge, h = "right". - A tag slot (its measured box) wholly inside the body gives its own root in all four entries: x at its box's start edge (the max x for side W, with h = "right"; the min x otherwise, with h = "left") and y at the baseline slot_text gives it at marking_height, v = "baseline". - No tag slot raises UnknownNameError naming the symbol; a negative gap or a marking_height not above zero raises InvalidValueError. Why: designer rulings and its amendments of 2026-10-23: a consumer needs the root of a tag as data of the symbol, so it does no arithmetic on pins and slots itself. Cost if wrong: additive; a later keyword can change a rounding or the tag-slot rule, which moves the roots a consumer reads.

D114: em_height, the inverse of the capital height

Decided: new top-level em_height(font, cap) -> float in font.py, beside cap_height: the text height (em size) whose capital is cap tall, in the same unit; cap * units_per_em / font.cap_height, or cap / 0.72 with no font. cap_height(font, em_height(font, c)) == c within rounding. It rides 0.25.0; the version stays. Why: designer ruling: the conversion from capital height to em size happens once, in symdef's font measure, never in a consumer. Cost if wrong: additive; a font with cap_height 0 cannot occur (a [font] table requires a positive one).

D115: line weights and dashes are library data

Decided: Weight gains RULE = 0.072 (0.18 mm at the 2.5 mm module; to_fragment is the only reader of Weight.value). [lines] takes normal, thick and rule; a [[wire]] weight may be rule, a symbol element's weight stays normal or thick (the schema and the validator are unchanged). New [dash] table: a name maps to lengths in mm, an even count of at least 2, each above zero, read into LibraryConfig.dash and Library.dash (read-only, tuples). The keys dashed (exactly 2 lengths) and dash_dot (exactly 4) are the patterns the closed Style enum needs; any other key is free data for a consumer. A library with a symbol element or wire style in the style dashed or dash_dot and no such key fails to load (LibraryError, a schema finding at /dash naming the key); an empty or absent [dash] is legal when nothing is dashed, and there is no fallback for an old library. A bad pattern is a finding at /dash/<name>. The bundle gains an optional dash object of arrays, written only when non-empty and checked the same way; the bundle schema number stays 1 (an older loader rejects the unknown key, as _table rejects every unknown key). Library.with_settings(dash=) replaces the whole table after the same checks and raises InvalidValueError; None keeps it. The per-weight advances tables stay per text weight: one constant, TEXT_WEIGHTS = (NORMAL, THICK), drives every loop over them, so the bundle's font.advances is byte-identical. Why: designer spec SYMDEF-0.26 (L1, L2, L5) and rulings; owner 2026-10-23: "should not symdef handle wires as well?... easier for us to set global settings for symdef, that we also can present to consumers... to change the symbols and wires and tables line thickness and stuff". Text never prints at RULE, so a text weight table for it would be dead data. Cost if wrong: the rule value and the two key names are guesses a consumer's data repeats; a renamed key is a breaking change to every library. tests/fixtures/guide, docs/tutorial-set and tests/fixtures/broken gained a [dash] table and stretch_0_9/tutorial.bundle.json its dash object.

D116: drawing calls read the library

Decided: to_fragment_mm gains the keyword-only library: Library | None = None. weights_mm and dash_mm become optional. Per call, an argument that is given wins, whole; else library.lines (widths), library.dash["dashed"] and library.dash["dash_dot"]; else an error naming the missing weight or key and both ways to give it: UnknownNameError for a weight or dashed, and InvalidValueError for dash_dot as before, since a 0.8.0 test pins that type. An explicit call is byte-identical to 0.25.0. A muted symbol takes its dash from the normal width, from whichever source gave the widths. to_fragment, to_svg and to_placed_fragment draw in module units with the code weights (Weight.value) and stay out of scope: a consumer cannot set them. wire, table and fitted_table return Symbols with a Weight per line and need no change; their width reaches the SVG through to_fragment_mm. Library has __len__, so an empty library is falsy; the code tests library is not None. Why: designer rulings (a) and the spec's L2: one home for a line width, the library. Cost if wrong: additive keyword; a module-unit call that a consumer needs configurable is a further keyword on it.

D117: the shapes and the text are written from values

Decided: new top-level rect_mm, outline_mm and line_mm in shapes_mm.py, all pure, all returning str in mm on an absolute sheet, all taking library=. weight is required on each, with no default; its width is library.lines[weight] (UnknownNameError naming what the library has). dash is a key of library.dash or None (UnknownNameError naming the key and "pass a library with that [dash] key"); the pattern prints space-separated (4 1). stroke is required on each and fill on rect_mm: each is written as given after the #rgb, #rrggbb or colour-name check (InvalidValueError), and the shapes lean on no stylesheet rule. outline_mm has no fill: solid it is one <rect fill="none">, dashed it is four <line> edges in the order top, bottom, left, right, each from its left or top end, so facing dashes start at the same corner. classes is an optional class attribute, escaped by quoteattr and left out when empty. A negative width or height raises InvalidValueError. Every drawn number goes through _num: at most four decimals, half-even on the binary float (0.15625 prints as 0.1562, 0.46875 as 0.4688); the consumer's shortest-decimal printer is not needed and the difference is below a micron. text_tag gains keyword-only classes="", at="baseline" and font=None. at="top" takes the point as the top of the em box (baseline = point + ascent / units_per_em x height, along y, or along x when turn); at="centre" takes it as the middle (that less half the height), which is the upward-centred form with turn=True. It is its own formula, not TURNED_ALIGN (that shifts by the cap height and differs by about 0.1 mm at 3.4 mm). top and centre need font (InvalidValueError), and so does an at that is not one of the three. corner_text is not used for the consumer's text, since its cap-top placement would move every text. The defaults of text_tag and slot_text_tag leave their output byte-identical. The 0.27 output is not byte-identical to a consumer's own writer (inline widths, fill and font attributes, 4 1 dashes); the bar is visual identity, shown by a PNG pair: one block drawn both ways rendered to the same pixels (a cairosvg render at 12 px per mm: 0 of 301716 pixels differ). Why: designer spec SYMDEF-0.26-LINES L4, (c) and (d): symdef formats every drawn number and writes the stroke widths, from the library; colours and fills arrive as values. The module is 2.5 mm (a grid unit 0.3125 mm), so a half grid is 0.15625 mm. Cost if wrong: additive. A shape keyword or a fourth at value is a further keyword; a renamed call is a break for the one consumer pinned to 0.27.0.

D118: no sized svg call and no polyline call

Decided: symdef adds no sized_svg_mm: the <svg> root, its size and its margin come from the consumer's sheet code, margin_mm a required value there, and symdef holds no margin default. It adds no polyline_mm: a polyline wire is wire(library, style_id, points) drawn by to_fragment_mm(..., library=), the one spelling, and a cable's line styles are [[wire]] styles of the library (weight and solid or dashed). The wire's <g> writes fill="none" stroke="#000"; a wire of another colour needs a later change. Why: one spelling for a wire; the sheet root is the sheet's. Cost if wrong: additive; a consumer that needs a coloured wire or a class on a wire asks for a keyword on to_fragment_mm.

D119: each face carries its own default advance

Decided: FontMetrics.default_advance is a Mapping[Weight, float], one number per text weight, required for every weight in TEXT_WEIGHTS like advances (a missing weight raises InvalidValueError naming it). library.toml takes [font.default_advance] with normal and thick (numbers above zero, both required); a single number is a schema finding at /font/default_advance. The bundle's font.default_advance is an object with the same two keys. measure_font derives each from its own face: the largest advance of that face's table (1843 regular and 2033 bold for the house face). text_width(..., weight=Weight.THICK) charges the bold default for a character its bold table does not list. This supersedes the "stays one number for both" line of D73 and D87's regular-only default. Why: a bold face is not a scaled regular face (D73), so one shared default under-measured every unlisted bold glyph (33 diffs, all bold unknown glyphs, in a consumer's text-measure check). Cost if wrong: a breaking change to the font format and to FontMetrics(...) construction: every library with a literal [font] and every caller building FontMetrics by hand writes the default per weight. The files form needs no change.

D120: the unit-outline margin is a grid value

Decided: no value in the library data fits. The unit-outline symbol declares no body or keepout (it is a stretchable frame), its label slot sits 0.25 module inside a corner (a label inset, not a gap to enclosed content), and [lines], [dash] and [font] size nothing between a frame and its contents. So [grid] gains the optional outline_margin, a whole number of divisions, 0 or more, with no default (a library that declares none has Grid.declared_outline_margin = None, as D118 holds no margin default), and Grid.outline_margin reads it: that property raises InvalidValueError naming outline_margin, [grid] and library.toml when none is declared, so no caller can use a missing margin by accident. It is how far a unit outline stands off the boxes it encloses, on all four sides. The bundle writes it only when it is set; a bad value is a schema finding at /grid/outline_margin and a Grid(...) raises InvalidValueError. Why: B2: the outline drawn on a page needs its margin from library data, not a constant in an application; the grid is where on-grid distances (the pitches) already live, and divisions keep the value exact. Cost if wrong: additive (a field declared_outline_margin after stretch_split, None, and the raising property outline_margin); the value a consumer sets is its own and unchecked against what it draws; a margin per outline kind, or one in millimetres, is a further key.

D121: repeat takes its pole-prefix format from its caller

Decided: repeat(symbol, n, *, port_format) renames each port, node and path end, bound lead and marking slot (marking. plus the formatted id) by port_format, a template with exactly the fields {k} (the pole, from 1) and {port}. It is required: None, a non-string, a malformed template or other fields raise InvalidValueError naming port_format and an example; there is no fallback spelling. The part-file data op takes it from the library (D123, which replaces the per-entry key this entry first gave it). table, fitted_table, edge_pattern and pole_port(k, port_id) keep <k>. (rows and copies, not poles; ROW_PORT_FORMAT), and gate 3 repeats with the same spelling because lint accepts a prefixed port only as <n>.<id>. Why: a pole prefix is an electrical convention, so symdef holds none for poles; the caller states it. Cost if wrong: breaking for every repeat(...) call and every part file with repeat. A library-wide format (a library.toml key) would remove the repeated value from each part; it is a further key, and lint's <n>. rule would then need the format too.

D122: the sheet wrapper and the bold group live in symdef

Decided: new top-level sheet_svg(width_mm, height_mm, body, *, margin_mm) -> str and bold_layer(fragment) -> str in sheet_svg.py, pure. sheet_svg writes the <svg> root in millimetres around body, the page widened by margin_mm on every side; margin_mm is required and symdef holds no margin default. bold_layer wraps a fragment in one <g font-weight="bold">. Both write their numbers as Python prints them, which is what the code they replace did, so a consumer's output stays byte-identical. This supersedes the "no sized_svg_mm" half of D118: the root and its margin are no longer the consumer's to write, the margin value still is. Why: the wrapper and the bold group carry nothing electrical, and a drawn thing is symdef's, not an application's. Cost if wrong: additive; a number format the shapes use (four decimals) would be a change to these two, and so a break for the page bytes.

D123: port_format is one library-wide key

Decided: library.toml takes a top-level port_format, the template of D121 (a string with exactly the fields {k} and {port}; any other value is a schema finding at /port_format), carried as LibraryConfig.port_format and Library.port_format (last field, None when undeclared). repeat, table, fitted_table, pattern_ports and pole_port all require the format as a value with no default (table and pattern_ports rename a row's or copy's ports, bound leads and slots by it; pole_port(k, port_id, port_format) is the one function that fills it in, and format_port and ROW_PORT_FORMAT are gone); every caller passes library.port_format, and no "{k}.{port}" literal is left in the code. A part's repeat = N passes it to repeat. A part entry has no port_format key (unknown key, as any other). A library that uses repeat and declares no key fails to load: a schema finding at /parts/<i>/repeat naming port_format, library.toml and an example. Gate 3 repeats with it and is skipped when the library declares none. The bundle carries it as the optional port_format string, checked as in library.toml, so a library loaded from a bundle repeats and tables the same way. Why: B2: the format is the library's one electrical convention, stated once like [font] and [grid], not on every part and not twice (rows and copies had a second, fixed spelling). Cost if wrong: a further library.toml key; lint's <n>. rule does not follow a custom format.

D124: a library has a font

Decided: Library.font and LibraryConfig.font are FontMetrics, declared field(kw_only=True) with no default, so the positional order of the other fields stays. parse_config refuses a library.toml with no [font] (a schema finding at the root that names the key and both forms), _BUNDLE requires font, bundle_to_data always writes it, and library_from_bundle reads it. The font is None guards in fitted_table, fitted_symbol, with_settings and bundle_to_data are deleted. For the [font] files form the parse cannot measure TTFs, so LibraryConfig.font holds an unmeasured placeholder (one unit per em, empty tables, the file's name, heights and text_block); load_library replaces it by the measured metrics, and font_files, font_name, font_heights and font_text_block stay as they were. The starter set, the tutorial set and the fixtures declare the neutral literal font: 1000 units per em, cap height 720, empty advance tables, default advance 600 for both weights, which measures what no font measured before (0.6 em per character, capital 0.72 em). Why: an application that holds a Library should not branch on a missing font; the optional font was a second measure for the same text (KI-125). Cost if wrong: breaking for every library and every Library(...) call without a font; the functions that take FontMetrics | None as an argument (text_width, slot_text, body_box) still do, since this order does not name them.

D125: group_mm

Decided: group_mm(body, at, *, classes="") -> str in shapes_mm.py, exported from symdef: <g class="..." transform="translate(x y)">body</g>, at an (x, y) pair in mm, numbers by the shared four-decimal format, class first and left out when empty, body written as given. It takes a fragment, not a symbol: to_placed_fragment stays the call for a symbol. No rotation or scale: a caller that needs them draws the symbol turned. Why: applications typed the same group literal in three places. Cost if wrong: an additive function; a rotate argument would be a later keyword.

D126: Orientation.half_turn

Decided: a read-only property Orientation.half_turn returns the orientation turned a further half turn clockwise, mirror kept: R0 gives R180, R90 gives R270, MR0 gives MR180, and it is its own inverse. It is a property beside Direction.opposite, not a function, and adds no public name to surface.toml. A map from a side to an orientation is not added: which way a symbol faces at R0 is that symbol's data. Why: an application flipping a symbol to the other side typed the pair R0/R180 by hand. Cost if wrong: an additive member of an enum; none to remove.

D127: port_format is required for every library

Decided: library.toml without the top-level port_format is refused by parse_config with a schema finding at the root that names the key and the fix ("add port_format to library.toml"), and a bundle without it is invalid. LibraryConfig.port_format and Library.port_format are str, declared field(kw_only=True) with no default, so the positional order of the other fields stays; bundle_to_data always writes the key, library_from_bundle reads it. The port_format is None branches in resolve (the repeat finding) and project (the through-repeat gate) are deleted. The starter set, the tutorial set and the fixtures declare the key. Why: a ruling asks for validation whenever a library has repeat or table symbols. D124 settled the same choice for the font: an application holding a Library should not branch on a missing value, and a library that uses repeat today (D123) failed at the first part, not at load. The precedent chose "required for every library" over a named error on access: a dataclass field cannot hold an optional value behind a str accessor without a second private field, and the accessor would still raise at the point of use, far from the file. A table symbol is built by a function call, not a data key, so the file cannot say which libraries will use one; requiring the key everywhere is the only check that covers it. The error names the library file; it cannot name a symbol, since the check runs before any symbol is read. Cost if wrong: breaking for every library.toml without the key and every Library(...) or LibraryConfig(...) call without port_format; a library that never repeats still declares a template.

D128: text_divisions

Decided: New top-level text_divisions(grid, font, cap_height_mm) -> int in font.py: the em box of a text whose capital is cap_height_mm tall, in whole grid divisions, ceil_divisions(grid, em_height(font, cap_height_mm / grid.module_mm)). It measures the em box, not the capital's ink. No symdef code composed the two calls before, so nothing else changed. Why: an application stating text sizes in capital heights in mm repeated the same three-step conversion to get a grid size. Cost if wrong: an additive function; none to remove.

D129: reference_cell

Decided: (SY4). New top-level reference_cell(columns, rows, width, height, point) -> tuple[str, str] in refgrid.py, and ReferenceCellError(InvalidValueError) in errors.py. The page frame's reference grid is the content box (width by height whole grid divisions, origin at its min corner) cut evenly into one cell per label; columns run left to right, rows top to bottom (smallest y first). It returns the labels of the cell holding point (a GridPoint), as given. symdef holds no page-frame record, so the frame passes its own data as plain values: the labels, which stay the frame's (letters, numbers or a printed form), and the extent. A shared edge belongs to the cell on its max side and the far edge of the box to the last cell, so a point on the border of a sheet has a cell. A point outside the box raises ReferenceCellError naming the point and the grid; there is no clamp. An empty label list or an extent below one raises InvalidValueError. Cell index is min(at * count // extent, count - 1) per axis. Nothing is drawn. Why: an application stored the cell of a point with its own arithmetic that clamped silently; the arithmetic is the frame's. Cost if wrong: an additive function and one error subclass; a record that carried the frame's labels and extent would be a later keyword-compatible wrapper.

D130: floor_divisions

Decided: (SY4), amended by a later ruling. New top-level floor_divisions(grid, mm) -> int in units.py: a length in millimetres rounded DOWN to whole grid divisions, the mirror of ceil_divisions, with the same tolerance (a value within 1e-9 below a division counts as that division). first built it rounding up, a second spelling of ceil_divisions under a name that says the opposite; refused that. A negative or non-finite length raises InvalidValueError; 0 gives 0. Why: an application converted a printed text floor in mm to divisions with its own arithmetic. Cost if wrong: an additive function; none to remove.

D131: Corner, a slot side that grows to a corner

Decided: (C1). New public enum Corner (NE, SE, SW, NW) in model.py, exported at the top level, and SlotSide = Direction | Centre | Corner. Direction is not widened, so a port or an anchor can never be a corner. The value is the unit vector of the growth, with dx, dy and the two halves horizontal and vertical as Directions. With a corner side position is the box's opposite corner: an SE slot grows east and south from its north-west corner (side_box). Text anchors by the east or west half and its baseline by the north or south half (SIDE_ALIGN, TURNED_ALIGN); a block stacks away from the side (_before, now (1 - dx or dy) / 2, byte-identical for the old sides). orient turns a corner by turning its two halves and adding them. The data name is NE, SE, SW or NW: load, serialize and the JSON schema accept it. Every old side keeps its meaning and every old symbol builds to the same bytes. Why: a one-axis side centres a multi-line box on the other axis, so it sticks out of a body that grows on one side only. Cost if wrong: an additive enum and four data names; a reader of the schema that lists the sides must add them.

D132: a corner slot grows with the body

Decided: (C2, C4). fitted_symbol needs no corner branch: it reads a slot's box through slot_box and moves it through stretch_slot, and both take the edges from side_box, so a corner slot is grown by the one rule every slot follows. A cut across the box moves each edge by the shift of its coordinate, the edge beyond the cut by the growth and the other not at all; the position moves with its own edge. An SE slot with its point above the cut therefore grows down, and the body below the cut moves down by the same amount, so the box stays inside the body and the tip is unmoved. An NE slot grows the same way (down), its point being the edge that moves. The text block is placed by the corner (D131), so it fills the grown box. A turned view is the unturned fit passed through orient (the corner turns with it); a slot with turn = True grows along its height as before. No code of fitted.py or stretch_slot.py changes: the property tests in tests/test_slot_corner.py (1 to 8 lines, four corners, R0 and R90) prove the rule. Why: a second growth rule beside side_box would be a second place for one geometry, and could drift from it. Cost if wrong: none to remove; a later wish for a corner slot to grow towards its own side against the body would need its own rule.

D133: a stretch cut may cross a slot outside the body

Decided: (C3). The stretch-cut placement check in lint/geometry.py (_cut_placement) is replaced, not joined by a second check: a cut is placed when body_min <= at < body_max on its axis or when at lies strictly inside the box of some slot on that axis (the same strict test fitted_symbol uses to find the cut across a slot). The finding for a cut that is neither says so and names the fix. stretch itself never refused such a cut, so nothing else changes: the points beyond the cut move, a declared keepout has the edge beyond the cut moved and so grows, and the body, lying wholly beyond the cut, moves without growing. A cut that crosses the body and a slot does both. Why: a slot outside the body (a tag above a terminal) must be able to grow, and a keepout that holds it grows with it. Cost if wrong: a symbol that relied on the lint refusing a cut off the body but across a slot now passes; the cut moves the slot's far edge as intended.

D134: text_footprint, and a turned corner_text

Decided: (amends an earlier ruling). A turn = true slot keeps box as the footprint as drawn, so it declares (thickness, reading length) and no reader swaps it; slot_box, side_box, measure and the render are unchanged. Two additions give a caller that footprint. New top-level text_footprint(font, text, cap_height_mm, grid, *, turn=False) -> (width, height) in font.py: the width of the one-line text and its em box (text_divisions), each in whole divisions; with turn the two are exchanged. corner_text gains the keyword turn=False (as text_tag has), not a second function or a corner value; turned, it is the same rule rotated a quarter counter-clockwise: S corners start the text at the south edge, N corners end it at the north edge, W corners put the capitals' top on the west edge and E corners the baseline on the east edge, with turned=True. Why: a consumer sized a turned tag slot with the upright measure and got the box turned the wrong way; the spec's box is already the footprint, so the fix is a measure that returns it. Cost if wrong: two additive changes; text_footprint is a new public name (no one-line measure of both extents existed to extend).

D135: a Polyline or Arc may bind a port

Decided: port: str | None = None is a trailing field on Polyline and Arc, and the file key port is accepted on polyline and arc; a Circle has none and the key is refused by the schema. Line, Polyline and Arc share no base class, so one function, geometry.bound_port(element), reads the port of any element, and every site that tested isinstance(e, Line) and e.port calls it: leads, keepout_box, repeat, composition (namespace, export), stretch offsets and pattern_ports. The last two move a stroke with orient.map_element (now public), so a polyline or arc moves every point. pattern_ports copies a bound stroke per pole with its port renamed, one rule for every bound stroke. lead-off-port requires one end of a bound polyline (first or last point) or arc (an end of its sweep) at the port's position and makes no axis check; a Line keeps both checks. Why: a lead drawn as a polyline could not be hidden with its port, so a hidden port left its ink and its body extent. Cost if wrong: additive, minor 0.33.0; no shipped symbol binds a non-line, so no existing data changes. Binding a closed polyline or a full arc is allowed and reaches the port only through its end points.

D136: text_footprint measures a block of lines

Decided: text_footprint(font, text, cap_height_mm, grid, *, turn=False) splits text on \n. The width is the widest line's; the height is the block height under the font's text_block rule, with LINE_PITCH (now defined in font.py, imported by slottext) as the one pitch: "cap" is one em box plus LINE_PITCH cap heights for each further line, "grid" is a whole row of divisions for each line. The height is the em box plus the extra lines' pitch, so it contains the drawn block (cap height plus the extra lines), which is about 0.28 em smaller. font.extra_lines(count, pitch) is the one function for the extent a block adds beyond its first line, (count - 1) * pitch; text_footprint and the slot text block (stack_shifts, the grid rows) call it. One line gives the old result. turn exchanges the two. No second footprint name. Why: a block of lines is the library's measure and the pitch is library data; a caller that sums line footprints needs the pitch and the rule, and measured a two-line tag as 102x8 (the newline counted as a glyph) instead of 52x16. Cost if wrong: behaviour widened for a text holding \n, minor 0.34.0; a text without \n measures as before.

D137: ink_boxes, the drawn ink as one box per group

Decided: ink_boxes(symbol, texts=None, height=None, font=None, grid=DEFAULT_GRID) returns InkBoxes(body, leads, texts). body is elements_box of the elements that bind no port (None when there are none), leads is element_box of each bound element in element order, and texts maps each slot id given in texts to the extent of that string where slot_text places it, without the slot's reserved box (the text_box of slot_box). Nothing declared enlarges a box: not body, not keepout, not a slot's box. A text without a height raises InvalidValueError; a slot id the symbol lacks raises UnknownNameError. Why: keepout_box is one box and may be larger than the ink, and body_box is the declared body when set; no existing name gives the ink of each group, and text_box is not public. A caller that keeps a label off a lead or a slot text but lets it stand beside the body needs the groups apart. Cost if wrong: additive, minor 0.35.0; two new names.

D138: ink_boxes(..., on_grid=True) returns GridBox rounded outward

Decided: ink_boxes takes one keyword-only option, on_grid: bool = False. Set, the body, each lead and each slot text is a GridBox of grid, rounded outward (min down, max up) by gridtypes.round_out, the function measure uses for its body and slot boxes (it was gridmeasure._extent, moved, not copied). InkBoxes is generic over its box type (InkBoxes[Box] or InkBoxes[GridBox]) and ink_boxes is overloaded on on_grid, so a caller's type checker sees which. Unset, the result is unchanged. A body with no ink stays None. Why: a caller that keeps boxes apart on the grid had to round the float boxes itself, a second copy of the rounding that can drift from measure's, and a text's float ink can sit off the grid. Cost if wrong: additive keyword, minor 0.36.0 (D135, D137 precedent); InkBoxes gains a type parameter, which breaks no call.

D139: text_boxes_prefix, and text_box measures each distinct line once

Decided: (S1, S2). text_box measures each distinct line string once per call, in a dict local to the call (no module state, so the purity gate holds); slot_lines builds its placements without a replace per line. A new public text_boxes_prefix(slot, lines, height, font, grid=DEFAULT_GRID) -> tuple[Box,...] returns, for each k from 1 to len(lines), the box text_box gives the first k lines joined by newlines, measuring each distinct line once for all of them. A line holding a newline raises InvalidValueError; no lines give (). The results are byte-identical to the old text_box: the whole suite passes unchanged and a test compares each prefix with text_box over every list of up to three lines, in the cap and grid rules, upright and turned. Why: a caller that sizes a stack of lines one line at a time measured every prefix again, so the cost grew with the square of the stack. The size rule for stacked text is symdef's, so the caller should not copy it. Cost if wrong: additive name, minor 0.37.0. The per-call memo does not help a caller that calls text_box once per prefix; that caller uses text_boxes_prefix.

D140: Measure.ink, the drawn ink of a measured symbol

Decided: (K1, K3). Measure gains a last field ink: GridBox, set by measure: the GridBox.union of ink_boxes(turned, texts, text_height, font, grid, on_grid=True), so the body (if it has any ink), each bound lead and each given text, each rounded outward. An empty slot adds nothing and a slot's reserved box reserves nothing. A symbol in attach under a slot id adds its box placed at the turned slot's point and side, rounded outward, as slots[id] holds it. With no ink at all ink is the origin box that body_box gives a symbol with no elements. A declared body does not enlarge it. keepout, body and slots are unchanged. The attached box is placed by one function that slots and ink both call. Why: keepout holds every reserved slot box, which is room a caller may not want to give to a string that is not drawn there; the ink was only available as separate float boxes from ink_boxes, so a caller rounded and united them itself. Cost if wrong: additive field, minor 0.38.0; Measure is built by measure alone, and a caller that constructs one by hand adds the field.

D141: sheet_svg writes its numbers as the shapes do

Decided: sheet_svg formats the width, height, viewBox origin and the widened sizes with the number formatter the shapes use (svg._num: at most four decimals, no trailing zeros, no negative zero), so sheet_svg(420.0, 297.0, body, margin_mm=5.0) gives width="430mm" and viewBox="-5 -5 430 307" where it gave 430.0mm and -5.0 -5.0 430.0 307.0. No new name and no second formatter: sheet_svg is the function a caller uses, so it writes the root and no f-string is needed. This supersedes D122's "numbers as Python prints them". bold_layer writes no number. Why: the root's integer mm values printed as floats, so a caller that wanted the shapes' spelling wrote the root itself. Cost if wrong: the page bytes change for a float input (5.0 becomes 5, a value past four decimals is rounded); an integer input is unchanged.

D142: to_fragment_mm takes cap_ratio from the library's font when none is given

Decided: (Q4b). cap_ratio becomes an optional keyword of to_fragment_mm. None takes library.font.cap_height / library.font.units_per_em; a value given wins, as weights_mm and dash_mm do (D116); neither a value nor a library raises InvalidValueError naming cap_ratio and library. Why: a caller that already passes the library computed the same ratio from the same font to hand it back. Cost if wrong: no new name, minor 0.39.0. Every call that gives cap_ratio draws the same bytes as before; a call that gave neither was a TypeError and is now an InvalidValueError.

D143: reference_labels, the labels of a reference grid

Decided: (C8.1). A function beside reference_cell returns the column labels and the row labels of a frame of n by m cells: each kind is "letters" (A to Z) or "numbers" (1, 2,...), the rows counted "top_down" or "bottom_up" (the top row then carries the highest). The kinds and the order are closed Literal values, refused with InvalidValueError naming the known ones; more than 26 letters, or a count below 1, raises the same. Why: reference_cell returns labels as given and made none, so each caller wrote the same letters-and-numbers rule. Cost if wrong: additive name, minor 0.39.0. No type is added for the kinds; a caller passes the strings, and a third kind is a new decision.

D144: reference_origin, the inverse of reference_cell

Decided: (C8.2). reference_origin(columns, rows, width, height, cell) takes the grid reference_cell takes and cell, a (column label, row label) pair, and returns the cell's min corner as a GridPoint: the first whole division that reference_cell places in the cell (ceil(index * extent / count) per axis), so reference_cell(..., reference_origin(..., c, r)) == (c, r) for every cell. An unknown label raises InvalidValueError listing the known ones; a grid with more labels than divisions on an axis raises it too, since such a cell holds no whole division. Why: a caller that links to a cell needs its corner and computed it again from the same cell rule, off the grid. Cost if wrong: additive name, minor 0.39.0. The corner is on the grid, rounded up; a caller that wants the exact fractional corner of a cell divides the box itself.

D145: text_tag stacks a multi-line text as slot text does

Decided: no new name. A content with line breaks gives one <text> per line, joined, stacked through slottext.row_shifts, the function stack_shifts now calls, so slot text and free text share one pitch (LINE_PITCH cap heights), one reading order and one upright rule. The first line sits at point and the next ones after it (east of it with turn); with at="centre" the block is centred on point. A one-line content draws the same bytes as before. text_footprint already measures the block. Deviation: text_tag takes no grid, so a font whose text_block is "grid" is stacked by the cap rule, not in whole divisions as slot_lines does. A caller that needs grid rows places each line itself. Why: a consumer sets two-line reference tags; the caller measures the tag text and checks its ink against the keep, so no lint rule is added. Cost if wrong: minor 0.40.0, a changed result for a call that gave a newline (one tag with a raw line feed before). The grid-font case is a later decision if a caller needs it.