<object label="REST API" id="webshop.api"
bausteinsicht_id="webshop.api"
bausteinsicht_kind="container">
<mxCell ... />
</object>
Sync Specification
Overview
Bausteinsicht synchronizes bidirectionally between:
-
JSON Model (source of truth for structure and metadata)
-
draw.io XML (source of truth for layout/positioning)
The sync process reads both files, detects changes relative to a last-sync state, and applies non-conflicting changes in both directions.
Validation Before Sync
Before any sync cycle begins, the model is validated using model.Validate().
If validation errors are found (e.g., invalid view include/exclude patterns, dangling references), sync aborts with an error message listing all validation failures.
This prevents silent data loss from typos such as a trailing dot in an element ID ("customer.") which would otherwise silently remove elements from draw.io (#176).
ID Mapping Strategy
Element IDs
Every element in the JSON model has a unique key (variable name) that serves as its ID.
Nested elements use dot notation: webshop.api.auth.
In draw.io, the ID is stored in two places for reliability:
-
idattribute on<object>— used by draw.io as the cell identifier -
bausteinsicht_idattribute on<object>— redundant copy that survives if draw.io reassigns cell IDs
When views are used, cell IDs are scoped to ensure file-wide uniqueness: <viewID>--<elementID> (e.g., context—customer).
The bausteinsicht_id attribute always stores the un-scoped element ID.
Duplicate bausteinsicht_id Handling
An element is normally drawn on several view pages with the same bausteinsicht_id; a duplicate on the same page (a copy-paste) is not another view: the first occurrence on a page wins during draw.io element extraction.
Across pages, an edit on any page counts (#684): the first page whose title, description or technology differs from the last-synced state is the edit and wins over pages that still show the old values, whatever the page order is. If two pages were edited differently, the first edited page wins and the run warns and names the ignored values; the same rule applies to the label of a connector drawn on several pages.
So that no page stays behind, the run writes the edits that reverse sync took over to every page before it ends (the forward pipeline with those changes, run after reverse sync); a differing page is therefore always an edit, never a stale view.
A duplicate on the same page is a copy made in draw.io (copying a shape copies its attributes). At the start of every run the first cell with the ID on a page stays the element; each further cell loses its bausteinsicht_id and is an unmanaged shape from then on, handled like any shape drawn in draw.io (reverse sync may import it as a new element). The run warns once per copy: duplicate bausteinsicht_id "<id>" on page "<page>": the copy (cell "<cell>") is now an unmanaged shape. The next run finds nothing to report (#722, #213).
Relationship IDs
Connector cells use a derived ID: rel-<from>-<to>-<index> where <index> is the 0-based position of the relationship in the model’s relationship array.
The index disambiguates multiple relationships between the same element pair (#142).
<mxCell id="rel-customer-webshop.api-0" value="uses"
edge="1" source="customer" target="webshop.api" ... />
When multiple relationships exist between the same pair (e.g., customer → webshop.api at indices 0 and 3), each gets a distinct connector ID:
<mxCell id="rel-customer-webshop.api-0" value="uses" ... />
<mxCell id="rel-customer-webshop.api-3" value="manages" ... />
ID Matching Priority
During reverse sync, elements are matched in this order:
-
bausteinsicht_idattribute (most reliable) -
idattribute on<object>(fallback if bausteinsicht_id missing) -
Unmatched elements with no Bausteinsicht attributes are treated as new
Sync Directions
Forward Sync (Model → draw.io)
Triggered when the JSON model changes.
| Change Type | Action |
|---|---|
New element |
Create |
Updated element (title) |
Update the title sub-cell’s |
Updated element (description) |
Update |
Updated element (technology) |
Update |
Updated element (kind) |
Update |
Updated element (link) |
Set or clear the |
Deleted element |
Remove |
New relationship |
Create |
Updated relationship (label) |
Update |
Deleted relationship |
Remove the connector |
New view |
Create new |
Deleted view |
Remove the orphaned |
Reverse Sync (draw.io → Model)
Triggered when the draw.io file changes.
| Change Type | Detection Method | Action |
|---|---|---|
Element renamed |
Title sub-cell |
Update model element title. Empty titles are rejected (#150). |
Element description changed |
|
Update model element description |
Element technology changed |
|
Update model element technology |
Element link changed |
(not detected — |
(n/a — link changes propagate forward only) |
New element (from draw.io) |
|
Generate ID via |
New element with an unknown |
|
Imported under that ID. The title is the shape’s title (sub-cell or label); if it has none, the ID is the title, because a model element needs one. The kind is the shape’s |
New relationship (from draw.io) |
|
Add relationship to model, capturing the connector label from |
Element deleted in draw.io |
Known |
Remove from model together with everything that refers to it (same handling as |
Relationship deleted in draw.io |
Connector with known |
Remove relationship from model. |
Relationship direction swap |
Deleted(a→b) paired with Added(b→a) detected in draw.io changes |
Update the existing relationship in-place (swap |
Element moved (position only) |
|
No model change. Layout is a draw.io concern. |
Label Format: Text Sub-Cells
New elements use grouped text sub-cells instead of a single HTML label. The parent element has label="" and three child <mxCell> elements for title, technology, and description. Each sub-cell has independent font size, color, weight, and positioning — matching PlantUML-level typography quality.
<!-- Parent element: label is empty -->
<object label="" id="containers--webshop.api" ...>
<mxCell style="...;container=1;" vertex="1" parent="1">
<mxGeometry x="200" y="150" width="240" height="150" as="geometry" />
</mxCell>
</object>
<!-- Child sub-cells (parent references the element's cell ID) -->
<mxCell id="containers--webshop.api-title" value="REST API"
style="text;html=1;fontSize=14;fontStyle=1;fontColor=#ffffff;..." vertex="1"
parent="containers--webshop.api">
<mxGeometry x="0" y="20" width="240" height="30" as="geometry" />
</mxCell>
<mxCell id="containers--webshop.api-tech" value="[Spring Boot]"
style="text;html=1;fontSize=11;fontStyle=2;fontColor=#CCCCCC;..." vertex="1"
parent="containers--webshop.api">
<mxGeometry x="0" y="55" width="240" height="20" as="geometry" />
</mxCell>
<mxCell id="containers--webshop.api-desc" value="Handles all HTTP requests"
style="text;html=1;fontSize=10;fontColor=#BBBBBB;..." vertex="1"
parent="containers--webshop.api">
<mxGeometry x="0" y="80" width="240" height="40" as="geometry" />
</mxCell>
Sub-cell rules:
-
Title sub-cell: Always created. Plain text (no HTML formatting needed).
-
Technology sub-cell: Only created when technology is non-empty. Value is
[bracketed]. -
Description sub-cell: Only created when description is non-empty.
-
All sub-cells use
movable=0;resizable=0;deletable=0;editable=0;to prevent accidental manipulation. -
Long text (#718). The title and technology cells carry
whiteSpace=wrap, so a long text wraps instead of being cut off at the cell width. The height of the wrapped text is estimated from the cell width and the font (about 0.55 em per Latin character, 0.6 em in bold, one em for CJK characters and emoji, a line is 1.2 em plus 4 px). If the text needs more than the cell has, the cell grows to that height, the cells below it move down by the same amount and the shape grows with them. This happens when an element is created, when its title or technology is updated, and inlayout(for files written before this rule). Cells and shapes never shrink: a shorter title leaves the room, and a shape the user has enlarged keeps its size. The description cell keeps its template height; its text is shortened to 120 characters and the full text is in the tooltip.
During reverse sync, ReadElementFields extracts values from sub-cells first. If no sub-cells are found, it falls back to parsing the HTML label (backward compatibility).
Legacy HTML Label Format (Backward Compatible)
Older draw.io files may use a single HTML label attribute instead of sub-cells. The HTML label parser (ParseLabel) supports these formats:
<!-- Title only -->
<b>REST API</b>
<!-- Title + Technology -->
<b>REST API</b><br><font color="#CCCCCC"><i>[Spring Boot]</i></font>
<!-- Title + Technology + Description -->
<b>REST API</b><br><font color="#CCCCCC"><i>[Spring Boot]</i></font><br><font color="#BBBBBB" style="font-size:11px">Handles all HTTP requests</font>
Legacy color codes (#666666 for technology, #999999 for description) are also recognized for backward compatibility.
Empty Title Rejection
Reverse sync rejects empty title updates from draw.io. If a user clears the label in draw.io, the update is ignored and a warning is emitted (#150).
Scope Boundary Handling
When a view defines a scope element, the scope element is rendered as a boundary/swimlane on the view page.
Boundary Creation
-
Look up the scope element’s kind in the model (e.g.,
system) -
Derive the boundary kind by appending
_boundary(e.g.,system_boundary) -
Look up the boundary template style in the template set
-
Create the boundary element with the scope element’s title, technology, and description
-
The scope element is included in the view’s element filter so that connectors targeting the boundary element are rendered correctly (#217)
Child Parenting
Children of the scope element (identified by dot-notation prefix, e.g., shop.api is a child of shop) are parented to the scope boundary cell.
Their parent attribute on <mxCell> is set to the scoped cell ID of the boundary, so they appear visually inside the swimlane.
Child coordinates are relative to the boundary’s top-left.
Drill-Down Navigation
Elements that have a detail view (a view whose scope matches the element) receive interactive drill-down navigation.
Forward Link
On any view page where the element appears, the link attribute is set to data:page/id,view-<viewID>.
Clicking the element in draw.io navigates to its detail view (#198).
Several views with the same scope. If more than one view has the element as its scope, the link goes to the view that shows the most elements below the scope (normally the overview that includes the whole subtree). If several views show the same number, the one with the smallest view key wins. The choice depends only on the model, never on map iteration order, so repeated syncs write the same link (#661).
User-Defined Links and Drill-Down Priority
An element may carry a user-defined link field in the model (e.g. "link": "architecture.adoc#sec-api").
This link is written to the draw.io <object> during forward sync and is preserved in SVG export as a native <a href> element, making it clickable in HTML and PDF documentation pipelines.
Priority rule: If the element also has a scoped detail view, the auto-generated drill-down link (data:page/id,…) takes priority over the user-defined link (ADR-009). The drill-down link is applied last and overwrites the user-defined value. A sync warning is emitted when this occurs:
element <id>: user-defined link overridden by drill-down link (ADR-009)
Elements that carry a link but have no matching scoped view retain the user-defined link unchanged.
Reverse sync: The link attribute is never read back from draw.io into the model. It is model-authoritative by design; manual edits to the link in draw.io are silently overwritten on the next sync.
Back-Navigation Button
Detail views (views with a scope) get a back-navigation button that links to the parent view.
The parent view is identified as a view whose resolved element set includes the scope element; if several qualify, the one with the smallest view key is used, so the button is the same on every sync (#661).
The button is an <object> with:
-
id="nav-back-<viewID>" -
label="← <parentViewTitle>" -
link="data:page/id,view-<parentViewID>" -
A small rounded rectangle at position (20, 20) with
width=140,height=30
Back-navigation buttons are excluded from reverse sync element import (#205).
Lifted Connector Deduplication
When a view does not include an endpoint of a relationship, the endpoint is "lifted" to the nearest visible ancestor in the element hierarchy.
For example, if the model has a relationship shop.api → db but only shop and db are on the view, the connector is lifted to shop → db.
Self-Referencing Relationships
True self-loops (where from == to in the model) are rendered as connectors.
However, when lifting causes both endpoints to collapse to the same element (e.g., shop.api → shop.db lifted to shop → shop), the resulting self-reference is skipped because it does not represent a meaningful relationship at the view’s abstraction level (#111, #212).
Lifting onto the Scope Boundary
On a view with a scope, the scope element is drawn as the boundary around all other elements.
If lifting moves an endpoint onto that boundary (e.g., shop.web → shop.lib.core on a view that includes shop.web but not shop.lib), the connector is skipped: the boundary encloses the whole page, so the edge says nothing, and the relationship is shown on a view that includes both endpoints.
Such a relationship also does not count as visible on that view (see reverse-sync deletion detection, #167).
A relationship that targets the scope element in the model (shop.web → shop) is still drawn to the boundary (AC-9.4, #217).
A relationship between the scope element and an element that is not part of the scope (user → shop on a view of shop that also shows user, in either direction) is not drawn either: it belongs to the parent view.
The same rule decides both whether the connector is drawn and whether the relationship counts as visible on the view, so a connector that was never drawn is never read as a user deletion; before (#736), the second sync removed such a relationship from the model.
Two-Pass Deduplication
Relationships are processed in two passes to ensure correct deduplication (#197):
-
Pass 1 — Direct relationships: Only non-lifted relationships are processed. Each direct relationship records its
from→topair in a seen-set. -
Pass 2 — Lifted relationships: Only lifted relationships are processed. A lifted relationship is skipped if:
-
Its
from→topair already exists from a direct relationship in Pass 1 (direct suppresses lifted). -
Its
from→topair already exists from another lifted relationship (first lifted wins, duplicates deduplicated).
-
This ensures that when a direct relationship (e.g., api→db) and a lifted relationship (e.g., api.catalog→db lifted to api→db) map to the same pair, only one connector is created with the direct relationship’s label (#142, #197).
Relationship or Element Deleted in draw.io
A relationship counts as deleted in draw.io only if its connector is gone from every page; if another page still shows it, the model wins and the connector comes back (reverse sync never deletes on the strength of a single page). Removing a relationship from the model shifts the array index of every relationship behind it, and it can free a pair for a lifted connector of another relationship. Within the same run, forward sync therefore does not draw the connector of a relationship that reverse sync is going to remove, and after reverse sync a second forward pass without changes renumbers the connectors, adds the lifted ones that are now due and drops the superfluous ones, so the next sync finds nothing to do and the model does not drift (#719).
A relationship that is removed from the model (for example with remove relationship) leaves its lifted connector on the view pages until the next sync. That connector carries the index the relationship had at the last sync. Reverse sync does not import it as a new relationship: a connector whose endpoints are a lifted view of a relationship that the last sync knew under this index, and that is gone from the model, belongs to the removed relationship. The model wins and the forward pass removes the connector (#760).
The same holds for an element deleted on every page: forward sync does not draw it again in the same run (it would otherwise leave a shape that no model element owns, which the next sync imports as a new element of the wrong kind, #720), and the second forward pass runs after every run in which something was deleted in draw.io, so an element that reverse sync had to keep (scope of a view, named by a constraint) is drawn again at once.
Connector Reconciliation
Every forward sync derives the full set of connectors a view page should carry from the model, using the rules above: all direct relationships, plus the lowest-index lifted relationship for each pair not covered by a direct one.
Missing connectors from this set are created; connectors Bausteinsicht created earlier (cell IDs rel-<view>--…) that are not in the set are removed.
This also removes lifted connectors left behind when a relationship is deleted or its index in the relationships array shifts: their cell ID carries the lifted endpoints and the old index, so a lookup by the model endpoints misses them.
User-drawn connectors carry other cell IDs and are never removed by this step.
Relationship Technology Label
A relationship’s technology is shown on its connector as a second label [technology] (#642). The label is a child cell of the connector: <mxCell id="<connector cell ID>-tech" vertex="1" connectable="0" parent="<connector cell ID>" style="edgeLabel;…"> with a relative geometry that places it below the connector’s own label. The connector’s value stays the plain relationship label, so reverse sync reads only the label and the technology never turns into a label change.
Like the doc-link icons, the labels are not part of the sync state. Every forward sync reconciles them from the model: a label is created or updated for each connector whose relationship has a technology (for a lifted connector, the technology of the relationship that gives the connector its label), and labels without a technology, without a connector, or whose connector was removed or re-keyed are deleted or re-attached. The model is authoritative: a label deleted or edited in draw.io comes back on the next sync, and the technology can only be changed in the model. Without views (single-page mode) the same applies to the one page, with unscoped connector IDs. The label is positioned independently of the connector’s own label: sync only creates it, updates its text and keeps it attached, and never changes the position of an existing label, so a user can move it in draw.io.
Connector cell IDs carry the relationship’s index in the relationships array, so inserting or removing a relationship renames every following connector, and a new lower-index relationship can take over a lifted pair.
Before changes are applied, an expected connector that is missing on the page takes over a no-longer-expected managed connector with the same source and target: the cell gets the new ID, the current label and the dashed style of its relationship kind, and keeps its waypoints and label position.
Model-side label and kind changes are applied to view connectors through their page-scoped cell IDs.
Placement Strategy for New Elements
New elements from forward sync are placed using a simple side-by-side algorithm:
-
Find the bounding box of everything on the page: the existing elements and also the metadata box, the legend and the doc-link icon row of the view (cells without a
bausteinsicht_id), so that a new element is never placed on top of an info box (#824) -
Place new elements in a row below that content
-
Use a fixed spacing (40px horizontal gap, 40px below existing)
-
Set a visual marker on new elements (
strokeColor=#FF0000;dashed=1;)
New elements from reverse sync (added in draw.io) keep their draw.io position.
Container Handling
Forward Sync
When generating a view that includes a container element and its children:
-
Create the container as a
swimlanestyle element -
Create children with
parent="<container-id>" -
Child coordinates are relative to the container’s top-left (offset by
startSizeheader height) -
Connectors between elements always use
parent="1"(the layer)
Reverse Sync
When detecting containment from draw.io:
-
If a shape has
parentpointing to another shape (not"1"), it is a child -
Map the parent-child relationship to the model hierarchy
-
If a new element is placed inside a container in draw.io, add it as a child of that container in the model
View Reconciliation
After forward sync applies element and relationship changes, a reconciliation step removes elements from a view page that are no longer in the view’s resolved element set. This handles cases where view include/exclude rules change without corresponding model element changes (#102).
Reconciliation Rules
-
Elements with a
bausteinsicht_idthat is not in the view’s resolved set are removed along with their connectors. -
The scope boundary element is excluded from reconciliation (handled separately).
-
Elements without a
bausteinsicht_id(user-added shapes in draw.io) are preserved — they are not subject to view filtering (#115). -
In no-views mode, orphaned elements (whose
bausteinsicht_idis not in the model at all) are removed (#110).
Orphaned View Page Removal
When views are deleted from the model, their corresponding draw.io <diagram> pages are removed.
Pages are identified as view-managed if their id starts with the "view-" prefix.
Non-view pages (e.g., default template pages without the prefix) are preserved (#143).
New Page Population
When a new view is added to the model, forward sync creates the <diagram> page and populates it with all elements from the view’s resolved set.
This is necessary because elements that already exist in the sync state are not emitted as "Added" in the ChangeSet — they are only detected as changes relative to the last-sync state.
The population step iterates over the resolved element set and creates any element not already present on the page.
The scope boundary element is excluded (handled by createScopeBoundary separately).
Elements expected only on newly created pages are excluded from draw.io-side deletion detection to prevent false "deleted from draw.io" changes (#184, #188, #189).
Conflict Detection
Last-Sync State File
A .bausteinsicht-sync file stores the state after each successful sync:
{
"timestamp": "2026-02-28T12:00:00Z",
"model_hash": "sha256:abc123...",
"drawio_hash": "sha256:def456...",
"elements": {
"webshop.api": {
"title": "REST API",
"description": "Handles all HTTP requests",
"technology": "Spring Boot",
"kind": "container"
}
},
"relationships": [
{
"from": "customer",
"to": "webshop.api",
"index": 0,
"label": "uses",
"kind": "sync"
}
]
}
ElementState Fields
| Field | Description |
|---|---|
|
Element title (always present) |
|
Element description (omitted if empty) |
|
Technology label (omitted if empty) |
|
Element kind from the specification (e.g., |
RelationshipState Fields
| Field | Description |
|---|---|
|
Source element ID |
|
Target element ID |
|
0-based position in the model’s relationship array (for disambiguation) |
|
Relationship label (omitted if empty) |
|
Relationship kind (omitted if empty) |
This file should be committed to version control alongside the model and draw.io files.
Three-Way Merge Logic
With the last-sync state, changes are detected as:
-
Model change: model differs from last-sync, draw.io matches last-sync
-
draw.io change: draw.io differs from last-sync, model matches last-sync
-
Conflict: both model and draw.io differ from last-sync for the same field
-
No change: both match last-sync
Conflict Resolution (v1)
For the initial version, conflicts produce warnings:
WARNING: Conflict detected for element "webshop.api":
Field: title
Model value: "REST API v2"
draw.io value: "Backend API"
Last sync: "REST API"
-> Keeping model value. Edit draw.io manually if needed.
In v1, the model value wins on conflict. This is the safer default since the JSON model is the declared source of truth for structure.
JSONC Comment Preservation
When reverse sync writes changes back to the model file, a PatchSave approach is used to preserve JSONC comments, formatting, and key ordering.
PatchSave Approach
For simple field value changes (title, description, technology), PatchSave locates the target value in the raw JSONC text by walking the JSON path and replaces only the value bytes.
The rest of the document — including // single-line comments, /* */ block comments, whitespace, and key ordering — is preserved.
For structural changes (new elements, new relationships), InsertObjectEntry and AppendArrayEntry are used to insert new JSON entries before the closing } or ] of the target container, preserving surrounding comments and detecting indentation from context.
When structural changes cannot be applied via patching (e.g., element deletion), a full Save is used which re-serializes the model and does not preserve comments.
Sync Algorithm
Template Application
During forward sync, new elements receive their visual style and sub-cell styles from a template.
Template Lookup
-
Read the template draw.io file
-
Find elements marked with
bausteinsicht_template="<kind>"on their<object> -
Extract the
stylestring,width, andheightfrom the template element’s<mxCell> -
Find child
<mxCell>elements withparentmatching the template’sid— these define sub-cell styles for title (-title), technology (-tech), and description (-desc) -
Apply element style and sub-cell styles to the new element
Template Element Example
<!-- In the template file -->
<object label=""
id="template-container"
bausteinsicht_template="container">
<mxCell style="rounded=1;whiteSpace=wrap;html=1;
fillColor=#438DD5;strokeColor=#3C7FC0;container=1;"
vertex="1" parent="1">
<mxGeometry x="0" y="0" width="240" height="150" as="geometry" />
</mxCell>
</object>
<!-- Sub-cell style templates -->
<mxCell id="template-container-title" value="Title"
style="text;html=1;fontSize=14;fontStyle=1;fontColor=#ffffff;..."
vertex="1" parent="template-container">
<mxGeometry x="0" y="20" width="240" height="30" as="geometry" />
</mxCell>
<mxCell id="template-container-tech" value="[Technology]"
style="text;html=1;fontSize=11;fontStyle=2;fontColor=#CCCCCC;..."
vertex="1" parent="template-container">
<mxGeometry x="0" y="55" width="240" height="20" as="geometry" />
</mxCell>
<mxCell id="template-container-desc" value="Description"
style="text;html=1;fontSize=10;fontColor=#BBBBBB;..."
vertex="1" parent="template-container">
<mxGeometry x="0" y="80" width="240" height="40" as="geometry" />
</mxCell>
The bausteinsicht_template attribute identifies which element kind this template applies to.
The element style, dimensions, and sub-cell styles (font size, color, position) are all copied to new elements of that kind.
Connector Template
Relationship connectors also use template styles. The connector template is identified by bausteinsicht_template="relationship" on the <mxCell>:
<!-- In the template file -->
<mxCell bausteinsicht_template="relationship"
style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;
endArrow=block;endFill=1;strokeColor=#666666;"
edge="1" parent="1">
<mxGeometry relative="1" as="geometry" />
</mxCell>
|
Note
|
Unlike element templates which use <object> wrappers, the connector template is a bare <mxCell> since connectors do not need custom metadata attributes.
|
Layout Modes
Each view chooses how its fresh-page layout is computed via its layout field; an out-of-set value is rejected by validation (BR-014). computeLayout (internal/sync/layout.go) runs only when a page is first populated or rebuilt with --relayout; incremental additions to an existing page use cursor-based placement (computePlacement) regardless of layout. computeLayout dispatches on the field:
-
layered(the default, also used whenlayoutis empty) — elements are arranged in horizontal rows grouped by kind, in the specification’s element order. A view’s scoped children are additionally grouped into BFS rows by relationship distance from actors (row 1 = elements connected to an actor, row 2 = elements connected to row 1, and so on), and within each row, elements are ordered to minimize edge crossings with the rows immediately above and below (internal/sync/layout.go:minimizeCrossings— a barycenter-method sweep from Sugiyama-style layered graph drawing, #607). This crossing minimization only has rows to work with when the BFS seed exists: views with no actor in scope (e.g. a container-level view scoped to internal packages only) collapse to a single unordered row, alphabetically sorted. All other elements (outside the scoped-children BFS) are ordered alphabetically. -
grid— all elements are placed in a simple grid; useful for overview pages. -
none— the legacy horizontal-row placement; sync does not arrange beyond a single row, leaving layout to the user.
Sync only places elements that are new to a page; it never moves elements already positioned (see Placement Strategy for New Elements). The sync --relayout flag (ForwardOptions.Relayout) overrides this: it clears and re-lays-out all view pages from scratch, deliberately discarding the hand-tuned positions of managed elements. clearPageElements removes only Bausteinsicht-managed cells (bausteinsicht_id objects and rel-… connectors), so any shape you drew yourself is left untouched.
Status and Decision Badges
When an element carries decisions (linked ADR IDs), forward sync renders one decision badge per decision as a child cell near the element’s top-right corner (the X offset is derived from the element’s width attribute, which defaults to 100 when absent — as it is on generated cells whose size lives in the child <mxGeometry> — so the placement approximates the top-right rather than tracking the exact width). The entry point is synchronizeDecisionBadges, which clears stale badges and then calls AddDecisionBadges (internal/sync/). Each badge is coloured by the referenced ADR’s status (DecisionBadgeColor: blue = active, yellow = proposed, grey = superseded/deprecated) and carries a bausteinsicht_decision_id attribute.
|
Note
|
A status badge renderer (AddStatusBadge, coloured by the element’s lifecycle status via StatusColor) is implemented and unit-tested but is not currently wired into forward sync — no production code calls it. Whether to wire it up (render a lifecycle badge alongside decision badges) or remove it is an open decision; until then, element status is validated (BR-029–BR-031) but not visualised.
|
Tag-Based Styling
An element’s tags can drive its visual style. For each tag, applyTagStyles (internal/sync/forward.go) looks up the matching TagDefinition in specification.tags and merges its style properties into the element’s draw.io style string. Tag styles layer on top of the template style, so a tag can override fill colour, stroke, or font without changing the template. Tags that resolve to no TagDefinition, or definitions without a style, leave the base style unchanged.
Metadata and Legend Boxes
Forward sync can add two informational boxes to each view page:
-
a metadata box (
createMetadata) showing the view’s title and description, the model path, the sync timestamp, and theconfig.author/config.repovalues; -
a legend (
createLegend) showing the element kinds used in the view.
Both are enabled by default and switched off per model via config.metadata: false and config.legend: false — the gate is Config.Metadata == nil || *Config.Metadata, so an unset value means on. The metadata box additionally needs the sync to supply the model path and timestamp, which the normal sync / watch path always does. The boxes are keyed by metadata-<viewID> / legend-<viewID> cell IDs and are updated in place on subsequent syncs rather than duplicated.
The boxes sit below the content of the page: when a box is created, its y is the bottom of the lowest element plus 80. A new element that is added to a page later is placed below the boxes (see "Placement Strategy for New Elements"), never on top of them (#824). Later syncs only update the label and do not move the box; layout moves the boxes (and the doc-link icon row of the view, which hangs on the metadata box) below the laid-out content (#772, see the layout command).
The sync time in the metadata box (Last synced: YYYY-MM-DD HH:MM) is the time of the last sync that changed the page. A sync that changes nothing on a page leaves the page, and so the diagram file, byte-identical, however much later it runs: the time is neither compared nor rewritten on its own. It is written when the box is created, when the other text of the box changes (title, description, source, repository, author), and when the sync changed anything else on the page (the page is compared before and after, without the metadata box); the summary then counts the page as updated. An idempotent sync therefore prints Already in sync. No changes., does not make a running watch run again and leaves no diff in git (#731, #761).
Edge Cases
Element appears in multiple views
The same element ID may appear in multiple <diagram> pages.
Each page has its own <object> with independent position and a scoped cell ID (<viewID>--<elementID>).
Changes to metadata (title, description) in one view propagate to all views during sync.
Orphaned connectors
If a connector’s source or target references an element not present on the current page, the connector is removed with a warning.
Empty views
A view with no matching elements generates a <diagram> with only the base cells and a text note: "No elements match this view’s include criteria."
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.