{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://carbonscott.github.io/lcls2/dev/design/daq-model.schema.json",
  "title": "LCLS-II DAQ design model",
  "description": "The single source of truth for the DAQ design document. The viewer (index.html, viewer.js, viewer.css) renders this file and contains no content of its own. Fields whose description starts with 'PROSE' are reader-facing text. Prose markup: paragraphs are separated by a blank line (\\n\\n); `code` is inline code; [text](https://...) is a link; [[some-id]] or [[some-id|text]] links to another node. Nothing else is markup: **bold**, lists and HTML are shown literally. Fields whose description starts with 'LAYOUT TEXT' are short reader-facing strings of the map and its figures (plain text, no markup). All ids (nodes, edges, tour steps, sources, decisions) are unique across the whole file.",
  "type": "object",
  "additionalProperties": false,
  "required": ["schema_version", "title", "question", "summary", "code_base", "sources", "nodes", "edges", "tour", "map"],
  "properties": {
    "$schema": {"type": "string"},
    "schema_version": {"const": 1},
    "title": {"type": "string", "minLength": 1, "maxLength": 80, "description": "Title shown at the top of the viewer."},
    "question": {"type": "string", "minLength": 1, "description": "PROSE. The question this document answers."},
    "summary": {"type": "string", "minLength": 1, "description": "PROSE. Shown in the top-level view, before any node is opened."},
    "code_base": {
      "type": "object",
      "additionalProperties": false,
      "required": ["repo_url", "commit"],
      "properties": {
        "repo_url": {"type": "string", "pattern": "^https://github\\.com/[^/]+/[^/]+$", "description": "Code links are built as <repo_url>/blob/<commit>/<path>#L<start>-L<end>."},
        "commit": {"type": "string", "pattern": "^[0-9a-f]{40}$", "description": "Full SHA that every code_ref is checked against."}
      }
    },
    "sources": {
      "type": "array",
      "minItems": 1,
      "items": {"$ref": "#/$defs/source"}
    },
    "nodes": {
      "type": "array",
      "minItems": 1,
      "items": {"$ref": "#/$defs/node"}
    },
    "edges": {
      "type": "array",
      "items": {"$ref": "#/$defs/edge"}
    },
    "tour": {
      "type": "object",
      "additionalProperties": false,
      "required": ["title", "intro", "steps"],
      "properties": {
        "title": {"type": "string", "minLength": 1, "maxLength": 80},
        "intro": {"type": "string", "minLength": 1, "description": "PROSE. What the tour follows (one event) and how to use it."},
        "steps": {
          "type": "array",
          "minItems": 1,
          "items": {"$ref": "#/$defs/step"}
        }
      }
    },
    "map": {"$ref": "#/$defs/map", "description": "Layout of the page: the fixed map, the tour on it, the small multiples, the sequence chart and the section texts. Numbers are SVG user units in the viewbox. Content about the DAQ stays in nodes, edges and tour; strings here are short LAYOUT TEXT."}
  },
  "$defs": {
    "id": {"type": "string", "pattern": "^[a-z0-9]+(-[a-z0-9]+)*$", "maxLength": 60},
    "source": {
      "type": "object",
      "additionalProperties": false,
      "required": ["id", "title", "url", "kind"],
      "properties": {
        "id": {"$ref": "#/$defs/id"},
        "title": {"type": "string", "minLength": 1},
        "url": {"type": "string", "minLength": 1, "description": "site-page: a relative URL from the viewer to a page of this site, ../<path>/ (optionally #anchor), where docs/<path>.md or docs/<path>/index.md exists. confluence-*: https://confluence.slac.stanford.edu/pages/viewpage.action?pageId=<digits>. web: an absolute https URL."},
        "kind": {
          "enum": ["site-page", "confluence-public", "confluence-internal", "web"],
          "description": "site-page = a page of this documentation site (in this repo). The other kinds are external sources (outside this repo). confluence-internal = a page in one of SLAC's internal Confluence spaces; summarize it in your own words and link it, never copy it."
        },
        "note": {"type": "string", "description": "PROSE. Optional: what this source is used for."}
      },
      "allOf": [
        {"if": {"properties": {"kind": {"const": "site-page"}}}, "then": {"properties": {"url": {"pattern": "^\\.\\./[a-z0-9_/-]+/(#[a-z0-9_-]+)?$"}}}},
        {"if": {"properties": {"kind": {"enum": ["confluence-public", "confluence-internal"]}}}, "then": {"properties": {"url": {"pattern": "^https://confluence\\.slac\\.stanford\\.edu/pages/viewpage\\.action\\?pageId=[0-9]+$"}}}},
        {"if": {"properties": {"kind": {"const": "web"}}}, "then": {"properties": {"url": {"pattern": "^https://"}}}}
      ]
    },
    "code_ref": {
      "type": "object",
      "additionalProperties": false,
      "required": ["path", "start", "end", "symbol"],
      "properties": {
        "path": {"type": "string", "pattern": "^(?!docs/)(?!\\.{1,2}/)(?!.*/\\.{1,2}(/|$))[A-Za-z0-9_.+-]+(/[A-Za-z0-9_.+-]+)*$", "description": "Repository-relative path of a code file at code_base.commit (not under docs/; no '.' or '..' segments)."},
        "start": {"type": "integer", "minimum": 1},
        "end": {"type": "integer", "minimum": 1, "description": "Inclusive. start <= end <= number of lines in the file, and end - start <= 80 (checked by the validator)."},
        "symbol": {"type": "string", "minLength": 4, "pattern": "[A-Za-z_][A-Za-z0-9_]{2,}", "description": "A string that appears verbatim inside lines start..end (a function, class, variable or key name)."},
        "note": {"type": "string", "description": "PROSE. Optional: what to look for in this code."}
      }
    },
    "decision": {
      "type": "object",
      "additionalProperties": false,
      "required": ["title", "decision", "rationale"],
      "properties": {
        "id": {"$ref": "#/$defs/id"},
        "title": {"type": "string", "minLength": 1, "maxLength": 80},
        "decision": {"type": "string", "minLength": 1, "description": "PROSE. What the design does."},
        "rationale": {"type": "string", "minLength": 1, "description": "PROSE. Why, as stated by the cited sources or visible in the code. Never guessed intent; say so when the reason is not documented."},
        "sources": {"type": "array", "items": {"$ref": "#/$defs/id"}},
        "code_refs": {"type": "array", "items": {"$ref": "#/$defs/code_ref"}}
      }
    },
    "node": {
      "type": "object",
      "additionalProperties": false,
      "required": ["id", "parent", "title", "summary", "prose"],
      "properties": {
        "id": {"$ref": "#/$defs/id"},
        "parent": {"oneOf": [{"type": "null"}, {"$ref": "#/$defs/id"}], "description": "null for a top-level node; otherwise the id of the parent node."},
        "title": {"type": "string", "minLength": 1, "maxLength": 40},
        "summary": {"type": "string", "minLength": 1, "maxLength": 160, "description": "PROSE. One sentence shown on the node's box."},
        "prose": {"type": "string", "minLength": 1, "description": "PROSE. The concept, for scientists and developers alike. Comes first in the viewer."},
        "dev_notes": {"type": "string", "description": "PROSE. Optional: details for developers (processes, classes, files). Shown after prose."},
        "outside_repo": {"type": "boolean", "description": "true if the mechanism is not implemented in this repository (firmware, other repositories, facility services). Such nodes need at least one external source. Missing means false."},
        "decisions": {"type": "array", "items": {"$ref": "#/$defs/decision"}},
        "code_refs": {"type": "array", "items": {"$ref": "#/$defs/code_ref"}},
        "sources": {"type": "array", "items": {"$ref": "#/$defs/id"}},
        "place": {"$ref": "#/$defs/place"},
        "detail": {"$ref": "#/$defs/detail"}
      }
    },
    "edge": {
      "type": "object",
      "additionalProperties": false,
      "required": ["id", "from", "to", "label", "kind"],
      "properties": {
        "id": {"$ref": "#/$defs/id"},
        "from": {"$ref": "#/$defs/id"},
        "to": {"$ref": "#/$defs/id"},
        "label": {"type": "string", "minLength": 1, "maxLength": 30, "description": "Short text drawn on the arrow."},
        "kind": {"enum": ["data", "trigger", "timing", "control", "monitoring"]},
        "prose": {"type": "string", "description": "PROSE. Optional: what flows and how."},
        "code_refs": {"type": "array", "items": {"$ref": "#/$defs/code_ref"}},
        "sources": {"type": "array", "items": {"$ref": "#/$defs/id"}}
      }
    },
    "step": {
      "type": "object",
      "additionalProperties": false,
      "required": ["id", "title", "node", "prose"],
      "properties": {
        "id": {"$ref": "#/$defs/id"},
        "title": {"type": "string", "minLength": 1, "maxLength": 80},
        "node": {"$ref": "#/$defs/id", "description": "The node this step is about; the viewer highlights it in the detail under the tour map."},
        "edges": {"type": "array", "items": {"$ref": "#/$defs/id"}, "description": "Optional edge ids to highlight in this step."},
        "prose": {"type": "string", "minLength": 1, "description": "PROSE. What happens to the event at this step."},
        "code_refs": {"type": "array", "items": {"$ref": "#/$defs/code_ref"}},
        "sources": {"type": "array", "items": {"$ref": "#/$defs/id"}}
      }
    },
    "kind": {"enum": ["data", "trigger", "timing", "control", "monitoring"]},
    "num": {"type": "number"},
    "box_key": {"type": "string", "pattern": "^[a-z0-9]+(-[a-z0-9]+)*(@[0-9]+)?$", "description": "A map box id. In a shared (not per_lane) line, a per_lane box is named with its lane: <box id>@<lane>, lanes counted from 0. In a per_lane line, a per_lane box is named without @ and means the copy in the line's own lane."},
    "text_lines": {"type": "array", "minItems": 1, "items": {"type": "string", "minLength": 1}},
    "map": {
      "type": "object",
      "additionalProperties": false,
      "required": ["viewbox", "default_detail", "kinds", "columns", "bands", "lanes", "lines", "labels", "notes", "omitted", "ladder", "tour", "multiples", "sequence", "sections"],
      "properties": {
        "viewbox": {"type": "object", "additionalProperties": false, "required": ["w", "h"], "properties": {"w": {"type": "number", "exclusiveMinimum": 0}, "h": {"type": "number", "exclusiveMinimum": 0}}},
        "default_detail": {"$ref": "#/$defs/id", "description": "The top-level part (with children) whose detail is shown under the map on #/."},
        "kinds": {
          "type": "array", "minItems": 5, "maxItems": 5,
          "items": {"type": "object", "additionalProperties": false, "required": ["id", "name"], "properties": {
            "id": {"$ref": "#/$defs/kind"},
            "name": {"type": "string", "minLength": 1, "maxLength": 20, "description": "LAYOUT TEXT. The kind's name on the emphasis chips, legends and small multiples."}}}
        },
        "columns": {
          "type": "array", "minItems": 1,
          "items": {"type": "object", "additionalProperties": false, "required": ["n", "name", "x", "w"], "properties": {
            "n": {"type": "integer", "minimum": 1, "description": "Column number, 1 = left; boxes name their column by n."},
            "name": {"type": "string", "minLength": 1, "maxLength": 30, "description": "LAYOUT TEXT. Column heading: one stage of the event's trip (the viewer may print it in capitals)."},
            "x": {"$ref": "#/$defs/num"},
            "w": {"type": "number", "exclusiveMinimum": 0}}}
        },
        "bands": {
          "type": "array", "minItems": 1,
          "items": {"type": "object", "additionalProperties": false, "required": ["id", "y", "h", "labels"], "properties": {
            "id": {"$ref": "#/$defs/id"},
            "y": {"$ref": "#/$defs/num"},
            "h": {"type": "number", "exclusiveMinimum": 0},
            "labels": {"type": "array", "items": {"type": "object", "additionalProperties": false, "required": ["text", "x", "y"], "properties": {
              "text": {"type": "string", "minLength": 1, "maxLength": 60, "description": "LAYOUT TEXT. A band label: the kind of path this band holds (the viewer may print it in capitals)."},
              "x": {"$ref": "#/$defs/num"},
              "y": {"$ref": "#/$defs/num"}}}}}}
        },
        "lanes": {"type": "object", "additionalProperties": false, "required": ["count", "y"], "properties": {
          "count": {"type": "integer", "minimum": 1, "description": "Number of example readout lanes drawn (generic: readout 1, 2, N)."},
          "y": {"type": "array", "minItems": 1, "items": {"$ref": "#/$defs/num"}, "description": "The centre y of each lane; per_lane boxes and lines are drawn once per lane."}}},
        "lines": {"type": "array", "items": {"$ref": "#/$defs/map_line"}},
        "labels": {"type": "array", "items": {"type": "object", "additionalProperties": false, "required": ["line", "text", "x", "y", "anchor"], "properties": {
          "line": {"$ref": "#/$defs/id", "description": "The map line this label names; it is dimmed and emphasized with that line."},
          "text": {"$ref": "#/$defs/text_lines", "description": "LAYOUT TEXT. The label, one string per text line."},
          "x": {"$ref": "#/$defs/num"},
          "y": {"$ref": "#/$defs/num", "description": "Baseline of the first text line."},
          "anchor": {"enum": ["start", "middle", "end"]},
          "out": {"type": "boolean", "description": "true: drawn in the outside-this-repository colour (the label names a mechanism outside this repository)."}}}},
        "notes": {"type": "array", "items": {"type": "object", "additionalProperties": false, "required": ["text", "x", "y"], "properties": {
          "text": {"$ref": "#/$defs/text_lines", "description": "LAYOUT TEXT. A free note on the map (not tied to a line), one string per text line."},
          "x": {"$ref": "#/$defs/num"},
          "y": {"$ref": "#/$defs/num"}}}},
        "omitted": {"type": "array", "items": {"type": "object", "additionalProperties": false, "required": ["edge", "reason"], "properties": {
          "edge": {"$ref": "#/$defs/id", "description": "A cross-part edge that no map line draws."},
          "reason": {"type": "string", "minLength": 1, "description": "LAYOUT TEXT. Why the map does not draw it, and where the reader finds it instead; shown under the map's caption."}}}},
        "ladder": {"type": "object", "additionalProperties": false, "required": ["node", "states", "transitions", "x", "dx", "y", "caption", "note"], "properties": {
          "node": {"$ref": "#/$defs/id", "description": "The node whose state machine the ladder draws."},
          "states": {"type": "array", "minItems": 2, "items": {"type": "string", "minLength": 1}, "description": "LAYOUT TEXT. The states, in order, as named in the code. Station k is drawn at (x + k*dx, y)."},
          "transitions": {"type": "array", "minItems": 1, "items": {"type": "string", "minLength": 1}, "description": "LAYOUT TEXT. The transition from state k to state k+1, as named in the code. Its segment is highlighted as lad-<k>."},
          "x": {"$ref": "#/$defs/num"},
          "dx": {"type": "number", "exclusiveMinimum": 0},
          "y": {"$ref": "#/$defs/num"},
          "caption": {"type": "string", "minLength": 1, "description": "LAYOUT TEXT. Drawn above the ladder."},
          "note": {"type": "string", "minLength": 1, "description": "LAYOUT TEXT. Drawn below the ladder."}}},
        "tour": {"type": "array", "items": {"type": "object", "additionalProperties": false, "required": ["step", "tokens", "highlight"], "properties": {
          "step": {"$ref": "#/$defs/id", "description": "The tour step (same order as tour.steps)."},
          "tokens": {"type": "array", "items": {"type": "object", "additionalProperties": false, "required": ["t", "lane", "x", "y"], "properties": {
            "t": {"enum": ["b", "k", "r", "g", "v", "s"], "description": "Token type: b data, k small-data record, r trigger input or result, g monitored copy, v timing, s control (diamond)."},
            "lane": {"oneOf": [{"type": "null"}, {"type": "integer", "minimum": 0}], "description": "The lane this token belongs to, or null for a token shared by all lanes. x and y are absolute either way."},
            "x": {"$ref": "#/$defs/num"},
            "y": {"$ref": "#/$defs/num"}}}},
          "highlight": {"type": "array", "items": {"type": "string", "pattern": "^(box:)?[a-z0-9]+(-[a-z0-9]+)*$"}, "description": "What the step highlights: a map line id (all lane copies), box:<box id> (all lane copies) or lad-<k> (ladder segment of transitions[k])."}}}},
        "multiples": {"type": "array", "minItems": 1, "items": {"type": "object", "additionalProperties": false, "required": ["kind", "caption"], "properties": {
          "kind": {"enum": ["data", "trigger", "timing", "control", "monitoring", "all"]},
          "title": {"type": "string", "minLength": 1, "maxLength": 40, "description": "LAYOUT TEXT. Panel title; a kind's panel uses the kind's name instead."},
          "caption": {"type": "string", "minLength": 1, "description": "LAYOUT TEXT. What this copy of the map shows."}}}},
        "sequence": {"type": "object", "additionalProperties": false, "required": ["lifelines", "rows"], "properties": {
          "lifelines": {"type": "array", "minItems": 1, "items": {"type": "object", "additionalProperties": false, "required": ["id", "name", "part", "out", "multi"], "properties": {
            "id": {"$ref": "#/$defs/id"},
            "name": {"type": "string", "minLength": 1, "maxLength": 20, "description": "LAYOUT TEXT. The lifeline's heading."},
            "part": {"$ref": "#/$defs/id", "description": "The top-level part this lifeline stands for."},
            "out": {"type": "boolean", "description": "true: drawn as outside this repository."},
            "multi": {"type": "boolean", "description": "true: drawn as several parallel lines (one process per readout)."}}}},
          "rows": {"type": "array", "items": {"type": "object", "additionalProperties": false, "required": ["step", "from", "to", "kind", "label", "dots", "out"], "properties": {
            "step": {"$ref": "#/$defs/id", "description": "The tour step of this row (same order as tour.steps)."},
            "from": {"type": "string", "pattern": "^[a-z0-9]+(-[a-z0-9]+)*$", "description": "A lifeline id, or start (an arrow from outside the chart)."},
            "to": {"$ref": "#/$defs/id"},
            "kind": {"$ref": "#/$defs/kind"},
            "label": {"type": "string", "minLength": 1, "maxLength": 60, "description": "LAYOUT TEXT. The arrow's label in the sequence chart."},
            "dots": {"type": "array", "items": {"$ref": "#/$defs/id"}, "description": "Lifelines the arrow reaches on its way (drawn as dots)."},
            "out": {"type": "boolean", "description": "true: drawn as outside this repository."}}}}}},
        "sections": {"type": "object", "additionalProperties": false, "required": ["map", "tour", "multiples", "sequence", "matrix"], "properties": {
          "map": {"$ref": "#/$defs/section"},
          "tour": {"$ref": "#/$defs/section"},
          "multiples": {"$ref": "#/$defs/section"},
          "sequence": {"$ref": "#/$defs/section"},
          "matrix": {"$ref": "#/$defs/section"}}}
      }
    },
    "section": {
      "type": "object",
      "additionalProperties": false,
      "required": ["eyebrow", "title", "intro"],
      "properties": {
        "eyebrow": {"type": "string", "minLength": 1, "maxLength": 40, "description": "LAYOUT TEXT. Small label above the section title."},
        "title": {"type": "string", "minLength": 1, "maxLength": 80, "description": "LAYOUT TEXT. The section's heading."},
        "intro": {"type": "string", "minLength": 1, "description": "LAYOUT TEXT. What the figure shows and how to read it, for the doc reader."},
        "caption": {"type": "string", "minLength": 1, "description": "LAYOUT TEXT. Caption under the figure (how to use it)."}
      }
    },
    "map_line": {
      "type": "object",
      "additionalProperties": false,
      "required": ["id", "kind", "edges", "d", "arrow", "per_lane", "through", "ends"],
      "properties": {
        "id": {"$ref": "#/$defs/id", "description": "Unique among the map's lines; lad-<k> is reserved for the ladder."},
        "kind": {"$ref": "#/$defs/kind"},
        "edges": {"type": "array", "items": {"$ref": "#/$defs/id"}, "description": "The model edges this line draws."},
        "d": {"type": "string", "minLength": 2, "pattern": "^M[-0-9 .,MLHVC{}y+]*$", "description": "SVG path with absolute M, L, H, V and C commands. It may hold several subpaths (one M each), for example one per lane for a shared line that enters each lane's box; the viewer draws each subpath with its own arrowhead when arrow is end, start or both. Every end point of a subpath lies on the border of one of its ends or through boxes. A per_lane line writes the lane's y as {y} (offsets as {y-28}, {y+28})."},
        "arrow": {"enum": ["end", "start", "both", "none"]},
        "per_lane": {"type": "boolean", "description": "true: drawn once per lane."},
        "through": {"type": "array", "items": {"$ref": "#/$defs/box_key"}, "description": "Boxes the line crosses border to border, with one subpath or across the gap between a subpath that ends on the box's border and one that starts on it (a port is drawn at each crossing)."},
        "ends": {"type": "array", "maxItems": 2, "items": {"$ref": "#/$defs/box_key"}, "description": "Boxes whose borders the line's end points touch."},
        "out": {"type": "boolean", "description": "true: drawn in the outside-this-repository colour."}
      }
    },
    "place": {
      "type": "object",
      "additionalProperties": false,
      "required": ["short", "boxes"],
      "description": "Top-level nodes only: where the part sits on the map.",
      "properties": {
        "short": {"type": "string", "minLength": 1, "maxLength": 20, "description": "LAYOUT TEXT. The part's short name (callout tags, matrix headers, detail tags, sequence chart)."},
        "boxes": {"type": "array", "minItems": 1, "items": {"$ref": "#/$defs/map_box"}}
      }
    },
    "map_box": {
      "type": "object",
      "additionalProperties": false,
      "required": ["id", "node", "column", "span", "band", "slot", "per_lane", "x", "w", "h", "title", "sub", "out"],
      "properties": {
        "id": {"$ref": "#/$defs/id", "description": "Unique on the map."},
        "node": {"$ref": "#/$defs/id", "description": "What the box stands for: the part or one of its descendants."},
        "column": {"type": "integer", "minimum": 1, "description": "First column (map.columns[].n) of the box's cell."},
        "span": {"type": "integer", "minimum": 1, "description": "Number of columns the cell spans."},
        "band": {"$ref": "#/$defs/id", "description": "map.bands[].id of the box's cell."},
        "slot": {"type": "integer", "minimum": 0, "description": "Which cell of (column, band): 0, 1, ... No two boxes share a (column, band, slot)."},
        "per_lane": {"type": "boolean", "description": "true: one copy per lane, centred on the lane's y (then y is omitted)."},
        "x": {"$ref": "#/$defs/num"},
        "y": {"$ref": "#/$defs/num"},
        "w": {"type": "number", "exclusiveMinimum": 0},
        "h": {"type": "number", "exclusiveMinimum": 0},
        "title": {"type": "string", "minLength": 1, "maxLength": 30, "description": "LAYOUT TEXT. The box's title on the map."},
        "sub": {"type": "array", "items": {"type": "string", "minLength": 1}, "description": "LAYOUT TEXT. Lines under the title; for a per_lane box, one line per lane (or one line for all lanes)."},
        "title_x": {"$ref": "#/$defs/num", "description": "Optional x of the title and sub lines (default x + 11), to keep them clear of lines that pass through the box."},
        "out": {"type": "boolean", "description": "true: the box carries the outside-this-repository tag."},
        "mini": {"type": "string", "minLength": 1, "maxLength": 14, "description": "LAYOUT TEXT. Optional shorter title for the small multiples."}
      }
    },
    "detail": {
      "type": "object",
      "additionalProperties": false,
      "required": ["columns", "rows", "sides"],
      "description": "Top-level nodes with children only: the grid of the detail view. Every descendant appears exactly once, as a node item, a group or a kid of a group.",
      "properties": {
        "columns": {"type": "integer", "minimum": 1},
        "rows": {"type": "array", "minItems": 1, "items": {"type": "array", "minItems": 1, "items": {"oneOf": [
          {"type": "object", "additionalProperties": false, "required": ["node", "col"], "properties": {
            "node": {"$ref": "#/$defs/id"},
            "col": {"type": "integer", "minimum": 0}}},
          {"type": "object", "additionalProperties": false, "required": ["group", "col", "span", "kids"], "properties": {
            "group": {"$ref": "#/$defs/id", "description": "A node with children, drawn as a frame around them; groups do not nest."},
            "col": {"type": "integer", "minimum": 0},
            "span": {"type": "integer", "minimum": 1},
            "kids": {"type": "array", "minItems": 1, "items": {"type": "object", "additionalProperties": false, "required": ["node", "col"], "properties": {
              "node": {"$ref": "#/$defs/id"},
              "col": {"type": "integer", "minimum": 0, "description": "A column inside the group's col..col+span-1."}}}}}}
        ]}}},
        "sides": {"type": "object", "propertyNames": {"$ref": "#/$defs/id"}, "additionalProperties": {"enum": ["left", "right", "top", "bottom"]}, "description": "Neighbour top-level part -> the side of the detail where its tags sit. The side must agree with the map: that part's boxes lie on that side of this part's boxes (for a diagonal neighbour, either side that agrees)."}
      }
    }
  }
}
