Rule handbook metadata
- Rule
DET.DIAGRAM.LABELS· lanedeterministic- Page status
- stale
- page_version
fb6f4aaa3d5b13909aef3d1985ad765661706eb320f25cc39dd286ab46784aa6- generated_at
- 2026-05-19T22:35:00.000Z
- registry_fingerprint
6773fda516344e110b5a7b1435e655e1264e773825ca8bbe62194189891c42ba
How this rule is fixed
Pilot deterministic fixer: handbook_after · harness mode standalone · verify expect_rule_clean.
- Harness:
apply-harness-fixture-remediation.pycopies the After example HTML from this handbook page onto the defect fixture, theninvoke-det-ruleset-remediation-verify.shre-audits and expects zero findings for this rule. - Production sites:
run-website-ux-remediation-loop.shrunshandbook_html_patch(HTML patches inlib/ux-deterministic-fixers/fixers/patches/) before invoking the Cursor agent when the quality gate still fails.
Detection module: docs/design/ux-audit/deterministic-design-rules.md#det-diagram-labels. Scroll down for Before / After examples and Evidence and remediation steps.
Purpose
Kitchen Sink diagrams teach mechanism through visible node names, not only modal legends or alt text. Catalog entries in js/ks-diagram-catalog.js declare items[].node strings (for example Step A on linear, Stage 1 / Gate 1 on gate). Template SVGs under assets/svg/template-*.svg and rendered tiles (ks_diagram_tile_html, forge-diagram, ks-diagram-tile, data-diagram-key) must surface those strings in readable <text> / <tspan> nodes—or, for ASCII figures, in .forge-diagram-ascii-pre lines—so sighted readers and zoomed UI see the same vocabulary as the catalog contract.
This deterministic rule complements DET.DIAGRAM.ALT (informative vs decorative exposure) and DET.DIAGRAM.ASSET_REGISTRY (registered keys and paths). It does not judge arrow direction or gate symbology (AI.DIAGRAM.SEMANTIC_ACCURACY). Coverage thresholds: at least 2 characters per label token; for catalog keys with legend entries, at least 2 matching nodes or 50% of legend nodes (whichever is higher). Placeholder tokens such as [subtitle] and [Title - …] do not count as readable labels.
Plan: Open js/ks-diagram-catalog.js for the tile's data-diagram-key; list items[].node values. Do: Mirror those strings in SVG <text> (or ASCII body) when customizing assets/svg/template-*.svg or page copy. Check: Re-run auditor metrics (diagramLabelsReport, diagramLabelsRepoReport) or compare DevTools text nodes to the catalog modal legend. Act: Fix template SVG, catalog legend, or generator wiring—never rely on alt alone when the on-surface labels are empty or abbreviated.
Passing signals
- Linear template:
data-diagram-key="linear"tile shows SVG text Step A, Step B, Step C, Step D matching catalog nodes (seeassets/svg/template-linear-flow.svg). - Gate template:
data-diagram-key="gate"tile exposes Stage 1, Gate 1, Stage 2, Gate 2, Stage 3 as readable<text>(not only diamond G glyphs) when the catalog lists full gate names. - Catalog coverage: For a key with N legend nodes, at least
max(2, ceil(N × 0.5))node strings appear in fetched SVG or inlinesvgtext (substring match allowed). - ASCII parity:
figure.forge-diagram-ascii/.forge-diagram-ascii-prelines include catalog node tokens whendata-diagram-keyis set. - Repo scan clean:
scanRepoDiagramLabelsreports norepoIssuesfor registeredtemplate-*.svgfiles mapped ingenerator/pages/_diagram_gallery.py. - Decorative skip: Tiles with
aria-hidden="true"orrole="presentation"are excluded; charts under[data-ks-chart]/.ks-chart-mountare out of scope. - Readable minimum: Each counted label is at least 2 characters after trim and is not a lone bracketed placeholder (
[subtitle],[Footer note - …]).
Failing signals
diagram-labels-no-readable-text: Visibledata-diagram-keytile (for examplelinear) whose SVG/ASCII surface has only placeholders or empty<text>nodes—no catalog node strings on the rendered surface.diagram-labels-legend-gap: Some labels exist but fewer than required matches (for example only Step A on a four-nodelinearlegend; Stage 1–Stage 3 without Gate 1 / Gate 2 ongate).- Abbreviated gate glyphs: Catalog lists Gate 1 but SVG shows only G inside diamonds—legend keys do not appear on the surface.
- Alt-only naming: Informative
altdescribes nodes while SVG text stays generic; this rule still fails because it inspects on-diagram text, notalt. - Catalog drift: Renamed legend nodes in
js/ks-diagram-catalog.jswithout updatingassets/svg/template-*.svg(or the reverse). - Unkeyed tiles: Diagrams without
data-diagram-keyare not scored for legend alignment (fix registry first underDET.DIAGRAM.ASSET_REGISTRY).
Before example
Before (failing example)
Diagram label coverage
Catalog keys without on-surface names
Modal legend lists Step A–D, but the SVG surface only shows [subtitle] placeholders.
Catalog legend requires Gate 1 and Gate 2; diamonds only show G.
Failing KS markup: catalog key linear with template SVG whose visible text is only bracket placeholders (diagram-labels-no-readable-text). Second tile uses key gate but surface text abbreviates gates to G while the catalog expects Gate 1 / Gate 2 (diagram-labels-legend-gap).
After example
After (passing example)
Diagram label coverage
Legend keys visible on the tile
Step A, Step B, Step C, Step D (matches catalog nodes)
Surface text includes Stage 1, Gate 1, Stage 2, Gate 2, Stage 3 per catalog.
Passing KS markup: linear tile uses registered template-linear-flow.svg with catalog node strings on the surface; gate tile spells out full gate names.
Passing ASCII diagram (catalog-aligned node tokens in .forge-diagram-ascii-pre):
<figure
class="forge-diagram forge-diagram-ascii breathe-static mb-0"
data-diagram-key="gate"
role="figure"
hash="Asc"
data-ks-hash="Asc"
>
<div class="forge-diagram-ascii-canvas">
<pre class="forge-code forge-diagram-ascii-pre"><code class="language-text">[ Stage 1 ] --> [ Gate 1 ] --> [ Stage 2 ] --> [ Gate 2 ] --> [ Stage 3 ]</code></pre>
</div>
<figcaption class="forge-diagram-ascii-caption forge-support small mt-2 mb-0">
ASCII gate chain uses the same node names as js/ks-diagram-catalog.js.
</figcaption>
</figure>
Evidence and remediation
Evidence: Auditor metrics diagramLabelsReport (DOM) and diagramLabelsRepoReport (repo template scan). Violations include kind (diagram-labels-no-readable-text, diagram-labels-legend-gap), key, selectorHint (for example motion.div.forge-diagram[key=linear]), matched / required / legendCount, and svg=assets/svg/template-….svg for template issues. Findings default to warn under visualCatalogGovernance. Capture outer HTML for the diagram root plus fetched SVG source or inline svg subtree.
Remediate (in order):
diagram-labels-no-readable-text: Add<text>/<tspan>labels (at least 2 characters) for catalogitems[].nodestrings inassets/svg/template-*.svg, or embed matching tokens in.forge-diagram-ascii-pre. Remove reliance on[subtitle]-only surfaces for informative diagrams.diagram-labels-legend-gap: Align abbreviated glyphs (for example G) with full legend names (Gate 1), or updatejs/ks-diagram-catalog.jswhen the shorter form is intentional—then re-run repo scan.- Gallery wiring: Ensure
generator/pages/_diagram_gallery.pymaps the key to the SVG you edited; runDET.DIAGRAM.ASSET_REGISTRYif the key or path is new. - Generator path: Prefer
render_ks_diagram_block(key="linear")/ks_diagram_tile_htmlover hand-rolled tiles sodata-diagram-keyand asset paths stay registered. - Follow-on: After labels pass, verify
DET.DIAGRAM.ALTandDET.HASH.MARKERS; useAI.DIAGRAM.SEMANTIC_ACCURACYwhen labels exist but topology disagrees with prose.