Skip to content

Edge labels can leave the canvas with a clean showcase receipt, and repair hints can point outside it #235

Description

@Rererr

Problem

A diagram whose edge label overhangs the viewBox ships with the label clipped mid-word, yet deliver --quality showcase returns 9/9 checks, 0 errors, 0 warnings — the receipt approves a visibly broken artifact. The gap covers the fixed canvases: architecture, sequence, data-flow, lifecycle, and schema_version: 1 workflow. (readable-v2 workflow is already safe: the compiler grows its canvas around pinned labels and rejects an authored viewBox that cannot hold the layout.)

Two adjacent defects compound it:

  • suggestLabelObstacleFix derives its labelAt/labelDx/labelDy hints from the obstacle alone. It can propose coordinates outside the canvas — applying the validator's own suggestion produces a clipped label. With an authored labelAt present, the relative-form hint is a no-op (labelPoint short-circuits), and with a pre-existing labelDx the delta lands in the wrong place.
  • archify check on an existing HTML artifact re-runs the composition rules, so the same clipped artifact also passes standalone checking.

Architecture's auto viewBox (autoViewBoxFor) sizes the canvas from components and boundaries only, so a no-meta.viewBox diagram can overhang the renderer's own canvas.

CJK text raises the odds of hitting all of this (full-width glyphs are 2 text units, so labels run wider), but the defect is locale-independent.

Repro

Any showcase diagram with an edge label routed near the right edge and a long enough label: validate --quality showcase exits 0 while the emitted <rect> for the label extends past viewBox[0]. Minimal JSON available on request.

Proposed fix (PR ready)

  1. Where the canvas is derived, size it correctly instead of reporting the author: include connection label rects in architecture's auto viewBox (measured non-breaking — max() only grows a bbox, and every checked-in auto-sized architecture diagram renders byte-identically).
  2. Where the canvas is authored (plus the origin side growth cannot reach), a showcase-level rule composition/label-canvas-containment reports the exact overflow with machine-readable evidence; standard keeps accepting pre-rule documents. Wired into the renderers and into check for artifacts they did not produce.
  3. Repair hints only emit fixes that survive being applied: clamped into the canvas, measured against the document's own labelDx/labelDy, withheld when an authored labelAt outranks them, and stated as replacements, never increments.

All checked-in examples and frozen fixtures validate identically before/after (43 PASS / 10 pre-existing FAIL on both — zero legitimate diagrams newly rejected).

Known adjacent gap (out of scope)

Sequence segment titles are still unbounded (a segment label hundreds of px past the viewBox validates clean) — a distinct geometry, left for a follow-up.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions