Skip to content

Editorial diagram design for Claude Code, Codex, GitHub Copilot, Cursor, Factory Droid, Qoder, and Pi. 45 diagram types. Self-contained HTML + SVG. No shadows. No Mermaid slop.

feat: add Streamgraph as a Line variant (#140)

0xDarkMatter76557bed21f1
diff --git a/.github/pr-visual-proof/140/dark.png b/.github/pr-visual-proof/140/dark.png
new file mode 100644
index 0000000..0eecff1
Binary files /dev/null and b/.github/pr-visual-proof/140/dark.png differ
diff --git a/.github/pr-visual-proof/140/full.png b/.github/pr-visual-proof/140/full.png
new file mode 100644
index 0000000..1ffae51
Binary files /dev/null and b/.github/pr-visual-proof/140/full.png differ
diff --git a/.github/pr-visual-proof/140/light.png b/.github/pr-visual-proof/140/light.png
new file mode 100644
index 0000000..d6a71ef
Binary files /dev/null and b/.github/pr-visual-proof/140/light.png differ
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 6d84f56..ee1910b 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -303,6 +303,16 @@ jobs:
id: slopegraph_tests
run: python scripts/test-verify-slopegraph.py
+ - name: Verify streamgraph stack and baseline
+ if: always()
+ id: streamgraph
+ run: python scripts/verify-streamgraph.py --all
+
+ - name: Verify streamgraph checker
+ if: always()
+ id: streamgraph_tests
+ run: python scripts/test-verify-streamgraph.py
+
- name: Verify sankey flow conservation
if: always()
id: sankey
@@ -455,6 +465,8 @@ jobs:
echo "| Dumbbell Checker | ${{ steps.dumbbell_tests.outcome == 'success' && '✅ Passed' || (steps.dumbbell_tests.outcome == 'skipped' && '⏭️ Skipped' || '❌ Failed') }} |" >> $GITHUB_STEP_SUMMARY
echo "| Slopegraph Shared Scale | ${{ steps.slopegraph.outcome == 'success' && '✅ Passed' || (steps.slopegraph.outcome == 'skipped' && '⏭️ Skipped' || '❌ Failed') }} |" >> $GITHUB_STEP_SUMMARY
echo "| Slopegraph Checker | ${{ steps.slopegraph_tests.outcome == 'success' && '✅ Passed' || (steps.slopegraph_tests.outcome == 'skipped' && '⏭️ Skipped' || '❌ Failed') }} |" >> $GITHUB_STEP_SUMMARY
+ echo "| Streamgraph Stack & Baseline | ${{ steps.streamgraph.outcome == 'success' && '✅ Passed' || (steps.streamgraph.outcome == 'skipped' && '⏭️ Skipped' || '❌ Failed') }} |" >> $GITHUB_STEP_SUMMARY
+ echo "| Streamgraph Checker | ${{ steps.streamgraph_tests.outcome == 'success' && '✅ Passed' || (steps.streamgraph_tests.outcome == 'skipped' && '⏭️ Skipped' || '❌ Failed') }} |" >> $GITHUB_STEP_SUMMARY
echo "| Sankey Flow Conservation | ${{ steps.sankey.outcome == 'success' && '✅ Passed' || (steps.sankey.outcome == 'skipped' && '⏭️ Skipped' || '❌ Failed') }} |" >> $GITHUB_STEP_SUMMARY
echo "| Sankey Checker | ${{ steps.sankey_tests.outcome == 'success' && '✅ Passed' || (steps.sankey_tests.outcome == 'skipped' && '⏭️ Skipped' || '❌ Failed') }} |" >> $GITHUB_STEP_SUMMARY
echo "| Waterfall Running-Total Conservation | ${{ steps.waterfall.outcome == 'success' && '✅ Passed' || (steps.waterfall.outcome == 'skipped' && '⏭️ Skipped' || '❌ Failed') }} |" >> $GITHUB_STEP_SUMMARY
diff --git a/.maintainer-policy.json b/.maintainer-policy.json
index 7028de5..fee4685 100644
--- a/.maintainer-policy.json
+++ b/.maintainer-policy.json
@@ -78,6 +78,8 @@
"python3 scripts/test-verify-dumbbell.py",
"python3 scripts/verify-slopegraph.py --all",
"python3 scripts/test-verify-slopegraph.py",
+ "python3 scripts/verify-streamgraph.py --all",
+ "python3 scripts/test-verify-streamgraph.py",
"python3 scripts/verify-ridgeline.py --all",
"python3 scripts/test-verify-ridgeline.py",
"python3 scripts/verify-sankey.py --all",
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index ae3474f..5d70432 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -68,6 +68,8 @@ Every validation gate below must pass before a PR is ready. They also run automa
| Dumbbell checker behaves (pass + adversarial cases) | `python3 scripts/test-verify-dumbbell.py` |
| Slopegraph axes share one scale and every endpoint matches its printed value | `python3 scripts/verify-slopegraph.py --all` |
| Slopegraph checker behaves (pass + adversarial cases) | `python3 scripts/test-verify-slopegraph.py` |
+| Streamgraph layers tile one shared scale on a symmetric baseline and every total is a sum | `python3 scripts/verify-streamgraph.py --all` |
+| Streamgraph checker behaves (pass + adversarial cases) | `python3 scripts/test-verify-streamgraph.py` |
| Ridgeline ridges share one amplitude and every printed range matches its bins | `python3 scripts/verify-ridgeline.py --all` |
| Ridgeline checker behaves (pass + adversarial cases) | `python3 scripts/test-verify-ridgeline.py` |
| Sankey flow conservation and ribbon geometry | `python3 scripts/verify-sankey.py --all` |
@@ -137,6 +139,8 @@ python3 scripts/test-plugin-package.py \
&& python3 scripts/test-verify-dumbbell.py \
&& python3 scripts/verify-slopegraph.py --all \
&& python3 scripts/test-verify-slopegraph.py \
+ && python3 scripts/verify-streamgraph.py --all \
+ && python3 scripts/test-verify-streamgraph.py \
&& python3 scripts/verify-ridgeline.py --all \
&& python3 scripts/test-verify-ridgeline.py \
&& python3 scripts/verify-sankey.py --all \
@@ -162,6 +166,7 @@ python3 scripts/test-plugin-package.py \
- **`build-readme-thumbs.py --check`:** a README preview is missing, stale, corrupt, the wrong size, orphaned, or no longer links to its full PNG. Install the pinned renderer with `python3 -m pip install Pillow==12.1.1`, run `python3 scripts/build-readme-thumbs.py`, inspect the preview changes, and commit the WebPs plus `docs/screenshots/thumbs/manifest.json`.
- **`verify-marimekko.py`:** a column is drawn off its category's share of the width, a segment off its series' share of the column, the columns do not share one plot height or one gutter, segments leave a gap or overlap, a series changes order between columns, a second segment wears the accent, anything positions a segment or a bound label from a `transform` attribute, an inline `style`, or a `<style>` rule, or a label, caption or key disagrees with the rect it binds. Fix the geometry or the declaration so they state one thing — never widen a column or pad a segment to fit a label, and never drop a category or a series to tidy the grid.
- **`verify-slopegraph.py`:** the two axes disagree about scale or origin, or an endpoint is drawn somewhere other than where its own declared value belongs. Fix the coordinate, never the label — and never move a point to stop two endpoint labels colliding, because crowded labels mean the values really are close.
+- **`verify-streamgraph.py`:** a layer's drawn thickness disagrees with its declared values, the stack has a gap or overlap, the envelope drifts off its midline, a boundary curve bends away from where its vertices put it, or a legend entry prints a name other than the layer it binds. Fix the geometry or the declaration so they state one thing — never bridge a zero period, float a band to open room, or reshape a curve between vertices to smooth the story.
- **`verify-ridgeline.py`:** a ridge is drawn on its own amplitude, a baseline sits off the stack's pitch or away from its drawn rule, a ridge is sampled on its own x positions, or a printed range is wider than the bins it claims. Fix the geometry or the declaration so they state one thing — never renormalise a single ridge to make it readable, and never move a baseline to buy one ridge headroom.
- **`verify-bubble.py`:** a bubble is drawn off the shared axis scale its peers describe, its radius disagrees with the one area constant (`r = K·√size`), a second bubble wears the accent, an overlapping smaller bubble is painted under a larger one, or a bound label/tick disagrees with the mark it names. Fix the geometry, never the binding — and never nudge a bubble to open up space, because crowded bubbles mean the values really are close.
- **`verify-bump.py`:** a vertex sits off the rank grid the figure itself declares, a snapshot's ranks are not a permutation of 1..N, a segment curves or arrives by a relative command, or an endpoint label is missing a coordinate, drawn inboard of the end it names, or off the gutter its peers share. Fix the geometry or the declaration, never the label — and never nudge a vertex off its row to dodge a label collision, because a rank between two ranks is not a rank.
diff --git a/scripts/test-maintainer-policy.py b/scripts/test-maintainer-policy.py
index dc7c2f7..eefb0c5 100644
--- a/scripts/test-maintainer-policy.py
+++ b/scripts/test-maintainer-policy.py
@@ -25,6 +25,8 @@ REQUIRED_COMMANDS = {
"python3 scripts/verify-polar.py",
"python3 scripts/verify-sankey.py --all",
"python3 scripts/test-verify-sankey.py",
+ "python3 scripts/verify-streamgraph.py --all",
+ "python3 scripts/test-verify-streamgraph.py",
"python3 scripts/verify-bump.py --all",
"python3 scripts/test-verify-bump.py",
"python3 scripts/verify-marimekko.py --all",
diff --git a/scripts/test-verify-streamgraph.py b/scripts/test-verify-streamgraph.py
new file mode 100644
index 0000000..4bdcfb3
--- /dev/null
+++ b/scripts/test-verify-streamgraph.py
@@ -0,0 +1,974 @@
+#!/usr/bin/env python3
+"""Adversarial cases for verify-streamgraph.py, both polarities.
+
+Every case is named for exactly what it asserts, and the negative half matters
+as much as the positive: a checker that fires on an honest pinch-to-zero, on
+honest rounding, or on the other shipped example types gets widened or switched
+off, and then it guards nothing.
+
+Fixtures are built from the same math the shipped example uses - a symmetric
+baseline, one shared scale, Catmull-Rom boundaries at 1/6 chord - so a mutation
+breaks exactly the invariant its case names. Fixtures live in a per-process
+temporary directory; two cases at the end hold that isolation in place.
+
+Exit: 0 all pass, 1 any failure.
+"""
+
+from __future__ import annotations
+
+import re
+import shutil
+import sys
+import tempfile
+from pathlib import Path
+
+ROOT = Path(__file__).resolve().parent.parent
+sys.path.insert(0, str(ROOT / "scripts"))
+
+verify = __import__("verify-streamgraph")
+
+SHIPPED = ROOT / "skills/diagram-design/assets/example-streamgraph.html"
+
+HEAD = """<!DOCTYPE html>
+<html lang="en"><head><meta charset="UTF-8"><title>t</title></head><body>
+<svg viewBox="0 0 1000 500" xmlns="http://www.w3.org/2000/svg" role="img"
+ aria-labelledby="streamgraph-title streamgraph-desc">
+ <title id="streamgraph-title">t</title>
+ <desc id="streamgraph-desc">Streamgraph fixture.</desc>
+"""
+TAIL = "</svg></body></html>\n"
+# The same head with nothing in the accessible text that names the type, so
+# a file under a non-streamgraph name is in scope only if its markup is.
+PLAIN_HEAD = HEAD.replace("Streamgraph fixture.", "A figure.")
+
+# The shared geometry the shipped example uses: 1.25px per unit about y=230.
+SCALE = 1.25
+MIDLINE = 230.0
+XS = [80 + 80 * i for i in range(6)]
+PERIODS = ["W01", "W02", "W03", "W04", "W05", "W06"]
+
+# Stack order bottom-first. Names deliberately digit-free: the legend prints
+# one numeric token per entry, and a digit in a name is ambiguous by design.
+ROWS = [
+ ("Docs", [8, 9, 7, 6, 0, 0]),
+ ("Unit", [58, 60, 62, 61, 64, 66]),
+ ("Suite", [12, 15, 19, 26, 34, 45]),
+]
+
+
+def boundaries(rows, scale=SCALE, midline=MIDLINE, shift=None):
+ """boundary[0] = envelope bottom, boundary[k] = top of layer k-1.
+
+ shift, when given, is a per-period y offset applied to the whole stack -
+ the tool for building a drifting or bottom-pinned baseline whose layers
+ still tile and still match their declared thicknesses.
+ """
+ periods = len(rows[0][1])
+ totals = [sum(values[i] for _, values in rows) for i in range(periods)]
+ offsets = shift or [0.0] * periods
+ out = [[round(midline + totals[i] * scale / 2 + offsets[i], 1)
+ for i in range(periods)]]
+ running = [midline + totals[i] * scale / 2 + offsets[i] for i in range(periods)]
+ for _name, values in rows:
+ running = [running[i] - values[i] * scale for i in range(periods)]
+ out.append([round(y, 1) for y in running])
+ return out
+
+
+def fmt(value):
+ text = ("%.1f" % value).rstrip("0").rstrip(".")
+ return text if text else "0"
+
+
+def catmull_segments(points):
+ segments = []
+ count = len(points)
+ for i in range(count - 1):
+ p0 = points[i - 1] if i > 0 else points[i]
+ p1, p2 = points[i], points[i + 1]
+ p3 = points[i + 2] if i + 2 < count else points[i + 1]
+ c1 = (p1[0] + (p2[0] - p0[0]) / 6.0, p1[1] + (p2[1] - p0[1]) / 6.0)
+ c2 = (p2[0] - (p3[0] - p1[0]) / 6.0, p2[1] - (p3[1] - p1[1]) / 6.0)
+ segments.append("C %s %s, %s %s, %s %s" % (
+ fmt(round(c1[0], 1)), fmt(round(c1[1], 1)),
+ fmt(round(c2[0], 1)), fmt(round(c2[1], 1)),
+ fmt(p2[0]), fmt(p2[1])))
+ return segments
+
+
+def layer_path(top_pts, bottom_pts):
+ rev = list(reversed(bottom_pts))
+ parts = ["M %s %s" % (fmt(top_pts[0][0]), fmt(top_pts[0][1]))]
+ parts.extend(catmull_segments(top_pts))
+ parts.append("L %s %s" % (fmt(rev[0][0]), fmt(rev[0][1])))
+ parts.extend(catmull_segments(rev))
+ parts.append("Z")
+ return " ".join(parts)
+
+
+def layer_markup(name, values, top_pts, bottom_pts, quote='"'):
+ d = layer_path(top_pts, bottom_pts)
+ q = quote
+ return (" <path data-layer=%s%s%s data-values=%s%s%s d=%s%s%s "
+ "fill=%s#2d3142%s/>\n"
+ % (q, name, q, q, ",".join(str(v) for v in values), q, q, d, q,
+ q, q))
+
+
+def captions(xs=None, periods=None):
+ xs = XS if xs is None else xs
+ periods = PERIODS[:len(xs)] if periods is None else periods
+ out = ""
+ for i, (x, period) in enumerate(zip(xs, periods)):
+ out += (' <text data-period="%s" data-index="%d" x="%g" y="440">%s'
+ "</text>\n" % (period, i, x, period))
+ return out
+
+
+def legend(rows):
+ out = ""
+ for name, values in rows:
+ total = sum(values)
+ out += (' <text data-layer="%s" data-total="%g" x="40" y="496">'
+ "%s · %g min</text>\n" % (name, total, name, total))
+ return out
+
+
+def figure(rows=None, shift=None, quote='"'):
+ """The layer paths + captions + legend for an honest figure."""
+ rows = ROWS if rows is None else rows
+ bounds = boundaries(rows, shift=shift)
+ body = ""
+ for k, (name, values) in enumerate(rows):
+ top = list(zip(XS, bounds[k + 1]))
+ bottom = list(zip(XS, bounds[k]))
+ body += layer_markup(name, values, top, bottom, quote=quote)
+ return body + captions() + legend(rows)
+
+
+def document(*blocks):
+ return HEAD + "".join(blocks) + TAIL
+
+
+class Harness:
+ def __init__(self):
+ self.failures = 0
+ self.count = 0
+ self.dir = Path(tempfile.mkdtemp(prefix="streamgraph-fixtures-"))
+
+ def close(self):
+ shutil.rmtree(self.dir, ignore_errors=True)
+
+ def path_for(self, name):
+ return self.dir / name
+
+ def run(self, source, name="example-streamgraph-fixture.html"):
+ path = self.path_for(name)
+ path.write_text(source, encoding="utf-8")
+ try:
+ return verify.check(path)
+ finally:
+ path.unlink()
+
+ def expect_clean(self, label, source, name=None):
+ self.count += 1
+ found = self.run(source, name) if name else self.run(source)
+ if found:
+ self.failures += 1
+ print("FAIL %s" % label)
+ for item in found:
+ print(" unexpected: %s" % item)
+ else:
+ print("ok %s" % label)
+
+ def expect_finding(self, label, source, pattern, name=None):
+ self.count += 1
+ found = self.run(source, name) if name else self.run(source)
+ if not found:
+ self.failures += 1
+ print("FAIL %s\n expected a finding, got none" % label)
+ return
+ if not any(re.search(pattern, item) for item in found):
+ self.failures += 1
+ print("FAIL %s\n no finding matched %r" % (label, pattern))
+ for item in found:
+ print(" got: %s" % item)
+ return
+ print("ok %s" % label)
+
+ def expect_only_one(self, label, source, pattern):
+ """A single defect must produce a single finding, not a cascade."""
+ self.count += 1
+ found = self.run(source)
+ if len(found) == 1 and re.search(pattern, found[0]):
+ print("ok %s" % label)
+ return
+ self.failures += 1
+ print("FAIL %s\n expected exactly one finding matching %r, got %d"
+ % (label, pattern, len(found)))
+ for item in found:
+ print(" got: %s" % item)
+
+ def expect_out_of_scope(self, label, source, name):
+ """Not merely finding-free - genuinely outside this checker's scope."""
+ self.count += 1
+ path = self.path_for(name)
+ path.write_text(source, encoding="utf-8")
+ try:
+ detected = verify.looks_like_streamgraph(path, source)
+ found = verify.check(path)
+ finally:
+ path.unlink()
+ if detected or found:
+ self.failures += 1
+ print("FAIL %s\n detected=%s findings=%d"
+ % (label, detected, len(found)))
+ return
+ print("ok %s" % label)
+
+ def check(self, label, condition, detail=""):
+ self.count += 1
+ if condition:
+ print("ok %s" % label)
+ return
+ self.failures += 1
+ print("FAIL %s%s" % (label, ("\n " + detail) if detail else ""))
+
+
+def main():
+ h = Harness()
+ try:
+ return run_cases(h)
+ finally:
+ h.close()
+
+
+def run_cases(h):
+ # ── Negative half: honest figures must stay silent ────────────────────
+ h.expect_clean("an honest streamgraph reports nothing", document(figure()))
+
+ h.expect_clean(
+ "the shipped light example reports nothing",
+ SHIPPED.read_text(encoding="utf-8"), name="example-streamgraph.html",
+ )
+
+ # The pinch is data: Docs holds two zero periods in the default rows, and a
+ # figure where one period's TOTAL is zero must also pass - both boundaries
+ # of every layer meet on the midline there.
+ h.expect_clean(
+ "a period where every layer is zero pinches the whole stream and passes",
+ document(figure(rows=[("Docs", [8, 6, 0, 5, 8, 9]),
+ ("Unit", [30, 20, 0, 24, 30, 33])])),
+ )
+
+ h.expect_clean(
+ "an honest figure written with single-quoted attributes is parsed",
+ document(figure(quote="'")),
+ )
+
+ # The rotated value-axis caption carries a transform and is not bound.
+ h.expect_clean(
+ "the rotated value-axis caption's transform is not reported",
+ document(' <text transform="rotate(-90 24 230)" x="24" y="230">'
+ "BUILD MINUTES PER WEEK</text>\n" + figure()),
+ )
+
+ h.expect_clean(
+ "a CSS text-transform declaration is not read as a transform",
+ HEAD + "<style>.eyebrow { text-transform: uppercase; }</style>\n"
+ + figure() + TAIL,
+ )
+
+ h.expect_clean(
+ "scenery paths without data-layer are skipped silently",
+ document(figure()
+ + ' <path d="M 0 0 L 4 4 Z" fill="#2d3142"/>\n'),
+ )
+
+ h.expect_clean(
+ "a commented-out layer is ignored, not read as data",
+ document(figure()
+ + ' <!-- old draft: <path data-layer="ghost" data-values="1,2" '
+ 'd="M 0 0 Z"/> -->\n'),
+ )
+
+ # A comment is not markup: an old draft of a layer inside <!-- --> must
+ # not pull a file that is otherwise not a streamgraph into scope, or the
+ # fail-closed rule fires on a perfectly honest line chart.
+ h.expect_out_of_scope(
+ "a data-layer that appears only inside an HTML comment does not claim the file",
+ PLAIN_HEAD
+ + ' <!-- old draft: <path data-layer="ghost" data-values="1,2" '
+ 'd="M 0 0 Z"/> -->\n'
+ + ' <path d="M 0 0 L 4 4 Z" fill="#2d3142"/>\n' + TAIL,
+ "example-line-fixture.html",
+ )
+
+ # The other polarity: bytes that say data-layer= in LIVE markup claim the
+ # file even when a broken quote leaves the parser no data-layer attribute
+ # at all. The browser draws no layer; the checker must say so, not skip.
+ h.expect_finding(
+ "a broken-quoted data-layer that is the file's only signal fails closed, not skipped",
+ PLAIN_HEAD
+ + ' <path data-note="x data-layer="Docs" data-values="1,2,3" d="M 0 0 Z"/>\n'
+ + TAIL,
+ r"presents as a streamgraph but declares 0 verifiable layer",
+ name="figure.html",
+ )
+
+ # The detector must not drag the other example types into scope.
+ for other in ("example-line.html", "example-slopegraph.html",
+ "example-sankey.html", "example-treemap.html"):
+ path = ROOT / "skills/diagram-design/assets" / other
+ if path.exists():
+ h.expect_out_of_scope(
+ "%s is not detected as a streamgraph at all" % other,
+ path.read_text(encoding="utf-8"), other)
+
+ # ── Positive half: each lie must be named as itself ───────────────────
+
+ # 2. One scale. The geometry stays where it is; the declaration changes.
+ # The legend is kept consistent with the mutated declaration, so the only
+ # lie left is the one between the values and the drawn thickness.
+ inflated = document(figure()).replace(
+ 'data-values="8,9,7,6,0,0"', 'data-values="8,9,12,6,0,0"', 1).replace(
+ 'data-total="30"', 'data-total="35"', 1).replace(
+ ">Docs · 30 min<", ">Docs · 35 min<", 1)
+ h.expect_only_one(
+ "a declared value the drawn thickness contradicts reports as one point",
+ inflated, r"'Docs' draws .* at period 2 where its declared value 12",
+ )
+
+ zero_lie = document(figure()).replace(
+ 'data-values="8,9,7,6,0,0"', 'data-values="8,9,7,6,4,0"', 1).replace(
+ 'data-total="30"', 'data-total="34"', 1).replace(
+ ">Docs · 30 min<", ">Docs · 34 min<", 1)
+ h.expect_only_one(
+ "a zero-thickness pinch declared as a nonzero value is reported",
+ zero_lie, r"'Docs' draws .* period 4 .* declared value 4",
+ )
+
+ # 3. Tiled stack. Shift the TOP layer up 6px whole: its thicknesses and
+ # curves survive, the seam against its neighbour does not.
+ rows = ROWS
+ bounds = boundaries(rows)
+ shifted_body = ""
+ for k, (name, values) in enumerate(rows):
+ lift = 6.0 if name == "Suite" else 0.0
+ top = [(x, y - lift) for x, y in zip(XS, bounds[k + 1])]
+ bottom = [(x, y - lift) for x, y in zip(XS, bounds[k])]
+ shifted_body += layer_markup(name, values, top, bottom)
+ h.expect_only_one(
+ "a layer floated 6px off its neighbour reports as one seam, not a cascade",
+ document(shifted_body + captions() + legend(rows)),
+ r"'Suite'.*bottom boundary sits 6\.0 px above layer 'Unit'",
+ )
+
+ # A per-period reorder: at one period two layers exchange places in the
+ # stack while every thickness stays true to its declared value and the
+ # envelope stays centred. The only lie is the order - and it must surface
+ # through the seam checks, or the fixed-order guarantee is decorative.
+ swap_at = 3
+ crossed_body = ""
+ positions = {}
+ for i in range(len(ROWS[0][1])):
+ order = ["Docs", "Unit", "Suite"]
+ if i == swap_at:
+ order = ["Docs", "Suite", "Unit"]
+ total = sum(values[i] for _name, values in ROWS)
+ y = MIDLINE + total * SCALE / 2
+ for name in order:
+ values = dict(ROWS)[name]
+ positions.setdefault(name, {})[i] = (round(y - values[i] * SCALE, 1),
+ round(y, 1))
+ y -= values[i] * SCALE
+ for name, values in ROWS:
+ top = [(XS[i], positions[name][i][0]) for i in range(len(values))]
+ bottom = [(XS[i], positions[name][i][1]) for i in range(len(values))]
+ crossed_body += layer_markup(name, values, top, bottom)
+ h.expect_finding(
+ "two layers exchanged at one period are reported as a broken seam",
+ document(crossed_body + captions() + legend(ROWS)),
+ r"must tile with no gaps and no overlaps, in one fixed order",
+ )
+
+ # 4. Symmetric baseline. Pin the envelope bottom to y=420: every layer
+ # still tiles and every thickness still matches, so the only lie left is
+ # the baseline - and it must be named alone.
+ periods = len(ROWS[0][1])
+ totals = [sum(values[i] for _, values in ROWS) for i in range(periods)]
+ pinned = [420.0 - (MIDLINE + totals[i] * SCALE / 2) for i in range(periods)]
+ h.expect_only_one(
+ "a bottom-pinned baseline reports as asymmetric and stops there",
+ document(figure(shift=pinned)),
+ r"baseline is not symmetric",
+ )
+
+ # 5. Determined curves. Bulge one control point 8px.
+ honest_doc = document(figure())
+ match = re.search(r"C ([\d.]+) ([\d.]+),", honest_doc)
+ assert match is not None
+ bulged = honest_doc.replace(
+ match.group(0),
+ "C %s %s," % (match.group(1), float(match.group(2)) - 8.0), 1)
+ h.expect_only_one(
+ "a control point pulled 8px off Catmull-Rom is reported as editorialising",
+ bulged, r"bends away from its vertices",
+ )
+
+ # Shared columns.
+ offgrid_body = ""
+ for k, (name, values) in enumerate(rows):
+ xs = [x + (12 if name == "Unit" else 0) for x in XS]
+ top = list(zip(xs, bounds[k + 1]))
+ bottom = list(zip(xs, bounds[k]))
+ offgrid_body += layer_markup(name, values, top, bottom)
+ h.expect_finding(
+ "a layer sampling its own period columns is reported",
+ document(offgrid_body + captions() + legend(rows)),
+ r"must share one set of period columns",
+ )
+
+ # Transforms move the rendered mark away from the checked coordinates.
+ h.expect_finding(
+ "a transform on a layer path is reported",
+ document(figure()).replace(
+ ' <path data-layer="Docs"',
+ ' <path transform="translate(0 80)" data-layer="Docs"', 1),
+ r"layer 'Docs' carries transform",
+ )
+
+ h.expect_finding(
+ "a transform on a bound label is reported",
+ document(figure()).replace(
+ ' <text data-period="W01"',
+ ' <text transform="translate(0 40)" data-period="W01"', 1),
+ r"bound label.*carries transform",
+ )
+
+ h.expect_finding(
+ "an ancestor <g> transform over the layers is reported",
+ document(' <g transform="translate(0 60)">\n' + figure() + " </g>\n"),
+ r"carries an ancestor <g>/<svg> transform",
+ )
+
+ h.expect_finding(
+ "a CSS transform declaration is reported",
+ HEAD + "<style>path { transform: translateY(40px); }</style>\n"
+ + figure() + TAIL,
+ r"a CSS `transform` declaration",
+ )
+
+ # 6. Legend bindings.
+ h.expect_only_one(
+ "a printed total that contradicts its binding is reported",
+ document(figure()).replace(">Docs · 30 min<", ">Docs · 28 min<", 1),
+ r"legend entry for 'Docs' prints .* but declares 30",
+ )
+
+ h.expect_finding(
+ "a declared total that is not the sum of the values is reported",
+ document(figure()).replace('data-total="30"', 'data-total="34"', 1)
+ .replace(">Docs · 30 min<", ">Docs · 34 min<", 1),
+ r"'Docs' declares a total of 34 but its values sum to 30",
+ )
+
+ h.expect_finding(
+ "a layer with no legend entry is reported, not dropped from the reading",
+ document(figure()).replace(
+ ' <text data-layer="Docs" data-total="30" x="40" y="496">'
+ "Docs · 30 min</text>\n", "", 1),
+ r"'Docs' has no legend entry",
+ )
+
+ h.expect_finding(
+ "a legend entry for a layer no path declares is reported",
+ document(figure()
+ + ' <text data-layer="Ghost" data-total="9" x="40" y="496">'
+ "Ghost · 9 min</text>\n"),
+ r"names layer 'Ghost', which no path declares",
+ )
+
+ h.expect_finding(
+ "a second legend entry for one layer is reported",
+ document(figure()
+ + ' <text data-layer="Docs" data-total="30" x="40" y="496">'
+ "Docs · 30 min</text>\n"),
+ r"a second legend entry for layer 'Docs'",
+ )
+
+ digit_rows = [("Docs", ROWS[0][1]), ("Unit", ROWS[1][1]), ("E2E", ROWS[2][1])]
+ h.expect_finding(
+ "a digit in a layer name makes its legend total ambiguous and is reported",
+ document(figure(rows=digit_rows)),
+ r"prints more than one numeric token",
+ )
+
+ # The wrong-name case: data-layer and data-total both stay correct, so
+ # every numeric check passes and only the string a reader actually sees is
+ # wrong. This is the shape a legend lies in.
+ h.expect_only_one(
+ "a legend entry printing another layer's name is reported",
+ document(figure()).replace(
+ 'y="496">Docs · 30 min<', 'y="496">Unit · 30 min<', 1),
+ r"legend entry for 'Docs' prints 'Unit · 30 min', which does not name",
+ )
+
+ h.expect_only_one(
+ "a legend entry naming two layers at once is reported",
+ document(figure()).replace(
+ 'y="496">Docs · 30 min<', 'y="496">Docs and Unit · 30 min<', 1),
+ r"legend entry for 'Docs' also prints 'Unit'",
+ )
+
+ # And the check must not tighten into "the name and nothing else": the
+ # shipped entries annotate with · focal and · paused.
+ h.expect_clean(
+ "a legend entry may annotate beyond its layer name and its total",
+ document(figure()).replace(
+ 'y="496">Docs · 30 min<', 'y="496">Docs · 30 min · paused<', 1),
+ )
+
+ # Period caption bindings.
+ h.expect_finding(
+ "a missing period caption is reported",
+ document(figure()).replace(
+ ' <text data-period="W03" data-index="2" x="240" y="440">W03</text>\n',
+ "", 1),
+ r"no caption for period 2",
+ )
+
+ h.expect_finding(
+ "two captions for one column are reported",
+ document(figure()
+ + ' <text data-period="W02" data-index="1" x="160" y="440">W02'
+ "</text>\n"),
+ r"a second caption for period 1",
+ )
+
+ h.expect_only_one(
+ "a caption drawn off its column is reported",
+ document(figure()).replace(
+ 'data-index="2" x="240"', 'data-index="2" x="320.5"', 1),
+ r"caption for period 2 .* drawn at x=320\.5 but its column is at x=240",
+ )
+
+ h.expect_finding(
+ "a caption whose text contradicts its binding is reported",
+ document(figure()).replace(
+ 'data-index="2" x="240" y="440">W03', 'data-index="2" x="240" y="440">W04', 1),
+ r"caption for period 2 reads 'W04' but declares data-period='W03'",
+ )
+
+ h.expect_finding(
+ "a caption index that names no column is reported",
+ document(figure()
+ + ' <text data-period="W09" data-index="8" x="720" y="440">W09'
+ "</text>\n"),
+ r"data-index='8', which is not a column",
+ )
+
+ h.expect_finding(
+ "a caption carrying only half its binding is reported",
+ document(figure()).replace(' data-period="W01"', "", 1),
+ r"must carry both data-index .* and data-period",
+ )
+
+ # 7. Fail closed, and read what is actually there.
+ h.expect_finding(
+ "a file named example-streamgraph with no layers is reported, not passed",
+ document(' <path d="M 0 0 L 4 4 Z" fill="#2d3142"/>\n'),
+ r"presents as a streamgraph but declares 0 verifiable layer",
+ name="example-streamgraph-empty.html",
+ )
+
+ h.expect_finding(
+ "a file whose desc says streamgraph but declares no layers is reported",
+ document(' <path d="M 0 0 L 4 4 Z" fill="#2d3142"/>\n'),
+ r"presents as a streamgraph but declares 0 verifiable layer",
+ name="figure.html",
+ )
+
+ h.expect_finding(
+ "a streamgraph declared only in a desc past 4000 chars is still detected",
+ "<!doctype html><style>/*" + ("x" * 4200) + "*/</style>"
+ + '<svg role="img"><title>t</title>'
+ + "<desc>Streamgraph of build minutes with no declared layers.</desc>"
+ + '<path d="M 0 0 Z"/></svg>',
+ r"presents as a streamgraph but declares 0 verifiable layer",
+ name="figure.html",
+ )
+
+ h.expect_finding(
+ "a layer missing data-values is reported rather than dropped",
+ document(figure()).replace(' data-values="8,9,7,6,0,0"', "", 1),
+ r"'Docs' is missing data-values",
+ )
+
+ h.expect_finding(
+ "a declared value that is not a finite number is reported",
+ document(figure()).replace(
+ 'data-values="8,9,7,6,0,0"', 'data-values="8,nine,7,6,0,0"', 1),
+ r"'Docs' declares a value that is not a finite number",
+ )
+
+ h.expect_finding(
+ "a NaN value is reported, not silently accepted",
+ document(figure()).replace(
+ 'data-values="8,9,7,6,0,0"', 'data-values="8,nan,7,6,0,0"', 1),
+ r"'Docs' declares a value that is not a finite number",
+ )
+
+ h.expect_finding(
+ "a negative value is reported",
+ document(figure()).replace(
+ 'data-values="8,9,7,6,0,0"', 'data-values="8,-9,7,6,0,0"', 1),
+ r"'Docs' declares a negative value",
+ )
+
+ h.expect_finding(
+ "a value count that disagrees with the drawn periods is reported",
+ document(figure()).replace(
+ 'data-values="8,9,7,6,0,0"', 'data-values="8,9,7,6,0"', 1),
+ r"'Docs' declares 5 values but draws 6 period vertices",
+ )
+
+ h.expect_finding(
+ "a second path declaring the same layer is reported",
+ document(figure() + layer_markup(
+ "Docs", ROWS[0][1],
+ list(zip(XS, boundaries(ROWS)[1])), list(zip(XS, boundaries(ROWS)[0])))),
+ r"a second path declares data-layer='Docs'",
+ )
+
+ h.expect_finding(
+ "a relative path command is refused rather than half-parsed",
+ document(figure()).replace('d="M ', 'd="m ', 1),
+ r"uses path command 'm'",
+ )
+
+ h.expect_finding(
+ "a shorthand or axis-aligned command is refused rather than half-parsed",
+ document(
+ ' <path data-layer="Docs" data-values="1,2,3" '
+ 'd="M 80 100 H 160 L 240 100 L 240 120 L 160 120 L 80 120 Z"/>\n'
+ + figure(rows=ROWS[1:])),
+ r"uses path command 'H'",
+ )
+
+ h.expect_finding(
+ "a path with two subpaths is refused",
+ document(
+ ' <path data-layer="Docs" data-values="1,2,3" '
+ 'd="M 80 100 L 160 100 Z M 80 120 L 160 120 Z"/>\n'
+ + figure(rows=ROWS[1:])),
+ r"exactly one",
+ )
+
+ # The browser reads an unquoted value up to the next whitespace or `>`,
+ # so `d=M08Z/` is the path (slash included) and the tag is not
+ # self-closing. The checker reads exactly that and reports what it finds.
+ h.expect_finding(
+ "an unquoted layer is read as the browser reads it, and its bad path is reported",
+ document(figure()
+ + " <path data-layer=unquoted data-values=1,2 d=M08Z/>\n"),
+ r"'unquoted''s path contains characters outside absolute M/C/L/Z",
+ )
+
+ h.expect_finding(
+ "a single-quoted layer with a contradicted value is still reported",
+ document(figure(quote="'")).replace(
+ "data-values='8,9,7,6,0,0'", "data-values='8,9,12,6,0,0'", 1),
+ r"'Docs' draws .* period 2",
+ )
+
+ h.expect_finding(
+ "a figure with a single verifiable layer fails closed",
+ document(figure(rows=ROWS[:1])),
+ r"declares 1 verifiable layer",
+ )
+
+ # 8. Duplicate attributes are read the way the browser reads them.
+ # HTML drops a repeated attribute and keeps the first, so a last-wins
+ # reader validates bytes that are not in the document. Chromium confirms
+ # it on the shipped example: append a second d and the parsed DOM keeps
+ # d="M 0 0 Z" while the real path is absent.
+ h.check(
+ "attrs_of keeps the first of a duplicated attribute",
+ verify.attrs_of(' d="first" data-x="1" d="second" data-x="2"')
+ == {"d": "first", "data-x": "1"},
+ detail=repr(verify.attrs_of(' d="first" d="second"')),
+ )
+
+ h.expect_finding(
+ "a duplicated d is read first-wins, so an invalid first d is reported",
+ document(figure()).replace(' d="', ' d="M 0 0 Z" d="', 1),
+ r"layer 'Docs'.s path must contain exactly one L",
+ )
+
+ h.expect_only_one(
+ "a duplicated data-values is read first-wins, so a dishonest first list "
+ "is reported",
+ document(figure()).replace(
+ 'data-values="8,9,7,6,0,0"',
+ 'data-values="0,0,6,7,9,8" data-values="8,9,7,6,0,0"', 1),
+ r"'Docs' draws .* thickness at period",
+ )
+
+ h.expect_finding(
+ "a duplicated data-total is read first-wins, so a dishonest first total "
+ "is reported",
+ document(figure()).replace(
+ 'data-total="30"', 'data-total="34" data-total="30"', 1),
+ r"'Docs' declares a total of 34 but its values sum to 30",
+ )
+
+ # The rule is first-wins, not "a repeated attribute is an error": when the
+ # first value is the honest one the browser draws an honest figure, and so
+ # this checker must stay silent.
+ h.expect_clean(
+ "a duplicated attribute whose first value is honest still passes",
+ document(figure()).replace(
+ ' fill="#2d3142"/>', ' d="M 0 0 Z" fill="#2d3142"/>', 1),
+ )
+
+ # 9. Markup is read as the browser reads it. A regex tag matcher stops at
+ # the first `>` it sees, so a quoted `>` before an attribute hid that
+ # attribute from the checker while Chromium honoured it. Every case here
+ # is a shape the browser parses one way; the checker must parse it the
+ # same way, in both polarities.
+ h.expect_finding(
+ "an ancestor <g> hiding its transform behind a quoted > is still reported",
+ document(' <g data-note=">" transform="translate(0 -80)">\n' + figure()
+ + " </g>\n"),
+ r"layer 'Docs' carries an ancestor <g>/<svg> transform",
+ )
+
+ h.expect_finding(
+ "an ancestor <g> hiding an inline style transform behind a quoted > is reported",
+ document(' <g data-note=">" style="translate: 0 80px">\n' + figure()
+ + " </g>\n"),
+ r"layer 'Docs' carries an ancestor <g>/<svg> style transform",
+ )
+
+ h.expect_clean(
+ "an honest layer with a quoted > before its bindings is parsed and passes",
+ document(figure()).replace(
+ ' <path data-layer="Docs"', ' <path data-note=">" data-layer="Docs"', 1),
+ )
+
+ h.expect_finding(
+ "a dishonest layer with a quoted > before its bindings is still reported",
+ document(figure()).replace(
+ ' <path data-layer="Docs" data-values="8,9,7,6,0,0"',
+ ' <path data-note=">" data-layer="Docs" data-values="8,9,12,6,0,0"', 1),
+ r"'Docs' draws .* period 2 where its declared value 12",
+ )
+
+ h.expect_only_one(
+ "a legend entry with a quoted > before its bindings is still bound and checked",
+ document(figure()).replace(
+ ' <text data-layer="Docs" data-total="30" x="40" y="496">Docs · 30 min<',
+ ' <text data-note=">" data-layer="Docs" data-total="30" x="40" y="496">'
+ "Docs · 28 min<", 1),
+ r"legend entry for 'Docs' prints .* but declares 30",
+ )
+
+ h.expect_finding(
+ "a caption hiding a transform behind a quoted > is reported",
+ document(figure()).replace(
+ ' <text data-period="W01"',
+ ' <text data-note=">" transform="translate(0 40)" data-period="W01"', 1),
+ r"bound label \(W01\) carries transform",
+ )
+
+ # Three carriers reach the renderer; the `transform` attribute is only the
+ # most visible. Each is refused on the element and on an ancestor.
+ h.expect_finding(
+ "an inline style transform on a layer path is reported",
+ document(figure()).replace(
+ ' <path data-layer="Docs"',
+ ' <path style="transform: translateY(80px)" data-layer="Docs"', 1),
+ r"layer 'Docs' carries style=.*\(the transform property\)",
+ )
+
+ h.expect_finding(
+ "an inline translate property on a bound label is reported",
+ document(figure()).replace(
+ ' <text data-period="W01"',
+ ' <text style="translate: 0 40px" data-period="W01"', 1),
+ r"bound label \(W01\) carries style=.*\(the translate property\)",
+ )
+
+ h.expect_finding(
+ "an inline CSS d property on a layer replaces the verified path and is reported",
+ document(figure()).replace(
+ ' <path data-layer="Docs"',
+ ' <path style="d: path(\'M 0 0 L 4 4 Z\')" data-layer="Docs"', 1),
+ r"layer 'Docs' carries style=.*\(the d property\)",
+ )
+
+ h.expect_finding(
+ "a vendor-prefixed transform on an ancestor group's inline style is reported",
+ document(' <g style="-webkit-transform: translateY(80px)">\n' + figure()
+ + " </g>\n"),
+ r"carries an ancestor <g>/<svg> style transform",
+ )
+
+ h.expect_clean(
+ "an inline text-transform on a bound label is not read as a transform",
+ document(figure()).replace(
+ ' <text data-period="W01"',
+ ' <text style="text-transform: uppercase; display: block" data-period="W01"', 1),
+ )
+
+ h.expect_finding(
+ "a CSS translate declaration in a style block is reported",
+ HEAD + "<style>path { translate: 0 80px; }</style>\n" + figure() + TAIL,
+ r"a CSS `translate` declaration",
+ )
+
+ h.expect_finding(
+ "a vendor-prefixed CSS transform declaration in a style block is reported",
+ HEAD + "<style>.layer {\n -webkit-transform: translateY(80px);\n}</style>\n"
+ + figure() + TAIL,
+ r"a CSS `transform` declaration",
+ )
+
+ # A CSS comment is whitespace to the tokenizer, so `/**/transform:` IS
+ # the transform property. The guard's regex allows only whitespace before
+ # the property name, and a comment there was a free pass through every
+ # carrier - inline on the element, inline on an ancestor, and in a rule.
+ h.expect_finding(
+ "a CSS comment before an inline transform on a layer path is not a free pass",
+ document(figure()).replace(
+ ' <path data-layer="Docs"',
+ ' <path style="/**/transform: translateX(80px)" data-layer="Docs"', 1),
+ r"layer 'Docs' carries style=.*\(the transform property\)",
+ )
+
+ h.expect_finding(
+ "a CSS comment before an inline translate on a bound label is not a free pass",
+ document(figure()).replace(
+ ' <text data-period="W01"',
+ ' <text style="/* nudge */translate: 0 40px" data-period="W01"', 1),
+ r"bound label \(W01\) carries style=.*\(the translate property\)",
+ )
+
+ h.expect_finding(
+ "a CSS comment before an ancestor <g>'s inline transform is not a free pass",
+ document(' <g style="/**/transform: translateY(80px)">\n' + figure()
+ + " </g>\n"),
+ r"carries an ancestor <g>/<svg> style transform",
+ )
+
+ h.expect_finding(
+ "a CSS comment before a transform declaration in a style block is not a free pass",
+ HEAD + "<style>path { /**/ transform: translateY(40px); }</style>\n"
+ + figure() + TAIL,
+ r"a CSS `transform` declaration",
+ )
+
+ # And the other polarity: a declaration that lives entirely inside a
+ # comment is not a declaration, even when a line break inside the comment
+ # puts `transform:` at what the regex alone would read as a boundary.
+ h.expect_clean(
+ "a transform inside a CSS comment is not read as a declaration",
+ HEAD + "<style>path {\n /*\n transform: translateY(40px);\n */\n"
+ " fill: #2d3142;\n}</style>\n" + figure() + TAIL,
+ )
+
+ # First-wins on an ancestor, both polarities: the browser applies the
+ # first `style`, so the checker must report exactly when that one moves.
+ h.expect_clean(
+ "a duplicated style on an ancestor keeps the browser's first, honest value",
+ document(' <g style="opacity: 1" style="transform: translateY(80px)">\n'
+ + figure() + " </g>\n"),
+ )
+
+ h.expect_finding(
+ "a duplicated style on an ancestor keeps the browser's first, dishonest value",
+ document(' <g style="transform: translateY(80px)" style="opacity: 1">\n'
+ + figure() + " </g>\n"),
+ r"carries an ancestor <g>/<svg> style transform",
+ )
+
+ h.expect_clean(
+ "a self-closing <g/> with a transform encloses nothing and is not reported",
+ document(' <g transform="translate(0 80)"/>\n' + figure()),
+ )
+
+ h.expect_clean(
+ "a commented-out ancestor transform is not read as live markup",
+ document(' <!-- <g transform="translate(0 80)"> -->\n' + figure()),
+ )
+
+ h.expect_clean(
+ "an end tag inside a quoted attribute does not end the legend entry's text",
+ document(figure()).replace(
+ 'y="496">Docs · 30 min<',
+ 'y="496"><tspan data-note="</text>">Docs</tspan> · 30 min<', 1),
+ )
+
+ h.expect_finding(
+ "upper-case tag and attribute names are read case-insensitively, as the browser does",
+ document(figure()).replace(
+ ' <path data-layer="Docs" data-values="8,9,7,6,0,0"',
+ ' <PATH DATA-LAYER="Docs" DATA-VALUES="8,9,12,6,0,0"', 1),
+ r"'Docs' draws .* period 2 where its declared value 12",
+ )
+
+ h.expect_clean(
+ "an entity in a layer name is unescaped consistently in path, legend and text",
+ document(figure()).replace("Docs", "R&amp;D"),
+ )
+
+ h.expect_finding(
+ "a broken attribute quote never crashes the checker and never passes",
+ document(figure()).replace('data-values="8,9,7,6,0,0"', 'data-values="8,9,7,6,0,0', 1),
+ r".",
+ )
+
+ # ── The fixture-isolation fix, held in place ──────────────────────────
+ sentinel = ROOT / "example-streamgraph-fixture.html"
+ existed = sentinel.exists()
+ if not existed:
+ sentinel.write_text("KEEP ME\n", encoding="utf-8")
+ try:
+ h.run(document(figure()))
+ h.run(document(figure()), name="example-streamgraph-fixture.html")
+ h.check(
+ "a pre-existing file sharing a fixture name is never touched",
+ sentinel.exists() and sentinel.read_text(encoding="utf-8") == "KEEP ME\n",
+ "%s was overwritten or deleted by the harness" % sentinel,
+ )
+ finally:
+ if not existed and sentinel.exists():
+ sentinel.unlink()
+
+ other = Harness()
+ try:
+ h.check(
+ "two harnesses use different directories, so parallel runs cannot collide",
+ other.dir != h.dir and not str(other.dir).startswith(str(ROOT)),
+ "dirs %s and %s" % (h.dir, other.dir),
+ )
+ finally:
+ other.close()
+
+ h.check(
+ "fixtures are written outside the repository",
+ not str(h.dir).startswith(str(ROOT)),
+ "fixture dir %s is inside %s" % (h.dir, ROOT),
+ )
+
+ print()
+ if h.failures:
+ print("%d of %d case(s) failed." % (h.failures, h.count))
+ return 1
+ print("OK streamgraph checker: %d case(s), both polarities" % h.count)
+ return 0
+
+
+if __name__ == "__main__":
+ raise SystemExit(main())
diff --git a/scripts/verify-streamgraph.py b/scripts/verify-streamgraph.py
new file mode 100644
index 0000000..f2123b1
--- /dev/null
+++ b/scripts/verify-streamgraph.py
@@ -0,0 +1,1045 @@
+#!/usr/bin/env python3
+"""Verify that a streamgraph's drawn layers match the values they declare.
+
+A streamgraph makes two claims at once: **the envelope is the total** and **each
+layer's thickness is its share**, both on one shared scale about one symmetric
+midline. Break any of that and nothing errors - the figure renders, the legend
+is present, and the lie is in the geometry. `lint-skin.py` reads colors and
+fonts, `verify-geometry.py` reads label masks against later-painted nodes, and
+neither compares a drawn boundary against the values sitting in the markup.
+
+Seven invariants, in the spirit of ADR 0005 and the slopegraph checker:
+
+1. SHARED COLUMNS - every layer's on-curve vertices sit at the same period
+ x-positions. A layer sampled on its own grid cannot be stacked against the
+ others, so a mismatch is reported and cross-layer geometry is not attempted.
+
+2. ONE SCALE - per-period thickness must equal the declared value times one
+ figure-wide scale. The scale is derived robustly (median of thickness/value
+ over nonzero values), so a single dishonest band does not drag the scale it
+ is measured against. A zero value must pinch to zero thickness - the pinch
+ is data.
+
+3. TILED STACK - each layer's bottom boundary is the previous layer's top, no
+ gaps, no overlaps, in one fixed order. A per-period reordering, a silently
+ inflated band, or a dropped sliver all break the tiling and are reported as
+ the geometry they are.
+
+4. SYMMETRIC BASELINE - envelope top and bottom must average to one constant
+ midline at every period (baseline = -total/2). A midline that drifts turns
+ layer wiggle into fake growth; a baseline pinned to the bottom is a stacked
+ area presenting as a streamgraph.
+
+5. DETERMINED CURVES - boundaries are cubic Beziers whose control points must
+ sit where uniform Catmull-Rom at 1/6 chord puts them, computed from the
+ on-curve vertices. Vertices carry the data; this pins the drawing *between*
+ vertices to the vertices, so a curve cannot be reshaped to editorialise
+ while every vertex stays true. Paths must be plain absolute M/C/L/Z -
+ anything else is refused rather than half-parsed.
+
+6. LABELS BOUND TO MEANING - each legend entry binds its layer and its printed
+ total, the total must equal the sum of that layer's declared values, and the
+ entry's visible text must name the layer it binds and no other. Each period
+ caption binds its column index and its visible text. Unbound, captions can be
+ exchanged or a layer quietly dropped from the legend - and a right datum under
+ a wrong string is still a wrong figure: an entry reading one layer's name over
+ another's data-layer clears every numeric check and labels the wrong band.
+
+7. FAIL CLOSED - a file that presents as a streamgraph but yields nothing
+ parseable is a finding, never a pass. A checker that reports OK because it
+ found nothing to compare is the bug, not the gate.
+
+Markup is read through the stdlib html.parser.HTMLParser, never a regex, so a
+tag is recognized exactly when a browser would recognize it: a quoted `>`
+inside an attribute value does not end the tag, a repeated attribute keeps its
+FIRST value and the rest are not in the document at all, unquoted values and
+upper-case names parse as their canonical form, and a comment's contents are
+never live markup. The regex tag matcher this replaced stopped at the first
+`>` it saw, so `<g data-note=">" transform="translate(0 -80)">` hid its
+transform from the checker while Chromium applied it to every layer inside -
+the same fail-open shape verify-block-registry.py retired for the same reason.
+
+No transform may move verified geometry or a bound label, and a transform
+reaches the renderer by three carriers: the `transform` attribute, an inline
+`style="..."`, and a rule in a <style> block. All three are refused, on the
+element and on any ancestor <g>/<svg>, following verify-beeswarm.py; the
+property set in CSS_MOVES_MARK_RE is the invariant, adapted to what moves a
+path (`d`) and a label (`x`/`y`) rather than a circle. CSS text is read the
+way the CSS tokenizer reads it: a `/* */` comment is whitespace, so
+`style="/**/transform: ..."` is the transform property, not a free pass.
+
+The basis for geometry is the `data-values` list each layer's path declares,
+never the rendered text. A layer whose legend entry is missing stays in the
+verified set and its missing entry is itself reported.
+
+WHAT THIS DOES NOT CHECK, deliberately:
+
+- **Absolute truth.** Every check is internal consistency; a figure wrong by a
+ constant factor everywhere is self-consistent and passes. The source line is
+ where scale and bucket size are stated to a reader, and prose is not parsed.
+- **The layer and period budgets.** 2-6 layers and 3-24 periods are editorial
+ guidance in type-line.md, not geometry; a 30-period stream that tiles
+ honestly is honest.
+- **Colour.** The accent-plus-ramp rule is `lint-skin.py`'s beat.
+- **Scenery.** A <path> that declares no data-layer is decoration by contract
+ and is not compared against anything; the guarantee here is that every tag
+ that DOES declare a binding is read exactly as the browser reads it.
+
+Usage:
+ python3 scripts/verify-streamgraph.py --all
+ python3 scripts/verify-streamgraph.py skills/diagram-design/assets/example-streamgraph.html
+
+Exit: 0 clean, 1 findings, 2 usage.
+"""
+
+from __future__ import annotations
+
+import argparse
+import math
+import re
+import sys
+from html.parser import HTMLParser
+from pathlib import Path
+
+ROOT = Path(__file__).resolve().parent.parent
+ASSET_DIR = ROOT / "skills/diagram-design/assets"
+
+# Every CSS property that can move or reshape a verified mark WITHOUT touching
+# the attributes this checker reads. The enumeration IS the invariant - it is
+# copied from verify-beeswarm.py, where it had already been wrong twice
+# (`transform:` alone missed `style="transform: ..."`, and once that was fixed
+# `style="translate: 80px 0"` walked past it because CSS Transforms Level 2
+# splits the transform into four properties). Three families reach a mark:
+#
+# transform / translate / rotate / scale the four transform properties;
+# the individual three compose WITH `transform`, so each is its own door
+# d / x / y SVG geometry properties. CSS wins
+# over the presentation attribute, so `style="d: path(...)"` on a layer
+# replaces the very path that was verified, and x/y do the same to a
+# bound label - a more direct lie than any transform
+# offset and its path/distance/position/anchor/rotate longhands
+# CSS motion path, which places the element somewhere else entirely
+#
+# Anchored to a declaration start, so `text-transform:` (the editorial skin
+# uses it), `display:` and `--custom:` never match, and the `rotate` inside
+# `transform: rotate(45deg)` is read once as the property and never as the
+# function in its value. A vendor prefix is optional so `-webkit-transform:`
+# is not a free pass.
+CSS_MOVES_MARK_RE = re.compile(
+ r"(?:^|[{;}\n])\s*(?:-(?:webkit|moz|ms|o)-)?"
+ r"(?P<prop>transform|translate|rotate|scale"
+ r"|d|x|y"
+ r"|offset(?:-(?:path|distance|position|anchor|rotate))?)"
+ r"\s*:",
+ re.IGNORECASE,
+)
+# CSS Syntax Level 3 section 4.3.2: a `/* ... */` comment is consumed as if
+# it were whitespace, so the tokenizer sees `/**/transform:` as the transform
+# property at a declaration start. CSS_MOVES_MARK_RE allows only whitespace
+# between the boundary and the name, so the comment must be turned into the
+# whitespace it is BEFORE the regex runs, or a comment is a free pass
+# through the guard. Non-greedy and DOTALL: a comment may span lines and
+# the first `*/` ends it, as in the tokenizer.
+CSS_COMMENT_RE = re.compile(r"/\*.*?\*/", re.DOTALL)
+# Detection reads raw text, and a commented-out tag is not in the document
+# a browser builds - stripped before the raw signal is consulted so an old
+# draft in a comment cannot claim an unrelated file for this checker.
+HTML_COMMENT_RE = re.compile(r"<!--.*?-->", re.DOTALL)
+# The complete numeric token a legend may print. Matching only the first
+# fragment is how "512,000" once agreed with metadata that said 512.
+NUMBER_RE = re.compile(
+ r"[-+]?(?:\d{1,3}(?:,\d{3})+(?:\.\d+)?|\d+(?:\.\d+)?|\.\d+)(?:[eE][-+]?\d+)?"
+)
+DIGIT_RE = re.compile(r"\d")
+# Detection only - deliberately a text search over the raw text (HTML
+# comments removed), so a file that so much as mentions a layer binding in
+# live markup is held to the contract even when the parser finds no complete
+# layer - that is check_source's fail-closed case, not a skip.
+DECLARES_LAYER_RE = re.compile(r"\bdata-layer\s*=", re.IGNORECASE)
+# Path grammar: absolute M/C/L/Z and numbers only. Relative commands, arcs,
+# shorthand curves and H/V would need a transform stack this checker refuses
+# to half-implement; a partial parse looks like coverage without being it.
+PATH_TOKEN_RE = re.compile(r"[MCLZmclzHhVvSsQqTtAa]|[-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?")
+
+# Boundary coordinates ship rounded to 0.1px and adjacent layers may round a
+# shared boundary independently; 1.0px of thickness slack clears honest
+# rounding and still catches the smallest dishonest nudge worth making. At the
+# shipped 1.25px-per-minute scale that is 0.8 of one build-minute.
+RESIDUAL_TOLERANCE = 1.0 # px, per-period thickness vs the shared scale
+STACK_TOLERANCE = 0.5 # px, between one layer's bottom and its neighbour's top
+MIDLINE_TOLERANCE = 1.0 # px, envelope midline drift across periods
+CONTROL_TOLERANCE = 0.75 # px, control point vs Catmull-Rom at 1/6 chord
+VALUE_TOLERANCE = 0.001 # printed/declared totals vs the sum of values
+CAPTION_TOLERANCE = 0.5 # px, period caption x vs its column
+
+GROUP_TAGS = ("g", "svg") # the only ancestors whose transform is inherited
+BODY_TAGS = ("text", "title", "desc", "style") # elements whose character data is read
+
+
+# === PARSING =================================================================
+
+
+class Element:
+ """One start tag this checker cares about, as the browser tokenized it."""
+
+ __slots__ = ("tag", "attrs", "offset", "line", "body", "ancestor")
+
+ def __init__(self, tag, attrs, offset, line, ancestor):
+ self.tag = tag
+ self.attrs = attrs # first-wins dict, names lower-cased, values unescaped
+ self.offset = offset # byte offset of `<` in the source, for ordering
+ self.line = line
+ self.body = "" # character data up to the matching end tag
+ self.ancestor = ancestor # how the nearest transformed <g>/<svg> moves it, or None
+
+
+class Layer:
+ __slots__ = ("name", "values", "top", "bottom", "line", "controls")
+
+ def __init__(self, name, values, top, bottom, line):
+ self.name = name
+ self.values = values # per-period, left to right
+ self.top = top # on-curve points, left to right
+ self.bottom = bottom # on-curve points, left to right
+ self.line = line
+ self.controls = [] # (boundary, segment, (c1, c2)) as drawn
+
+
+def first_wins(attrs) -> dict:
+ """Attributes as the browser keeps them: on a repeat, the FIRST wins.
+
+ HTML parsing drops a duplicate attribute rather than overwriting the one
+ already on the token, so a second `d` on a path is not merely ignored -
+ it is not in the document at all. A dict comprehension does the opposite,
+ and that gap is a fail-open every caller inherits: a path carrying an
+ invalid first `d` and a valid second renders the invalid geometry while a
+ last-wins reader checks, and passes, bytes the browser threw away.
+ Confirmed in Chromium against the shipped example - the parsed DOM keeps
+ `d="M 0 0 Z"` and the real path is absent. A present-but-valueless
+ attribute is an empty string, not an absent attribute.
+ """
+ seen = {}
+ for name, value in attrs:
+ seen.setdefault(name, "" if value is None else value)
+ return seen
+
+
+class _Scanner(HTMLParser):
+ """Collect paths, texts, title/desc and style elements with ancestry.
+
+ HTMLParser already lowercases tag and attribute names, tolerates unquoted
+ values and whitespace around `=`, unescapes entities, keeps a quoted `>`
+ inside the value it belongs to, and never invokes handle_starttag for
+ tag-like text inside a comment or inside <script>/<style> raw text - each
+ of those is exactly a case a regex tag matcher mishandles. Ancestry is
+ tracked for <g>/<svg> only, the elements whose transform a child inherits.
+ """
+
+ def __init__(self, source: str):
+ super().__init__(convert_charrefs=True)
+ self.paths: list = []
+ self.texts: list = []
+ self.named: list = [] # <title> and <desc>
+ self.styles: list = []
+ self.error = None
+ self._groups: list = [] # (tag, how) per open <g>/<svg>
+ self._open: list = [] # (tag, Element) per open body element
+ self._line_starts = [0]
+ for index, char in enumerate(source):
+ if char == "\n":
+ self._line_starts.append(index + 1)
+ try:
+ self.feed(source)
+ self.close()
+ except Exception as exc: # noqa: BLE001 - any parser failure fails closed
+ self.error = "%s: %s" % (type(exc).__name__, exc)
+
+ def _offset(self) -> int:
+ line, column = self.getpos()
+ return self._line_starts[line - 1] + column
+
+ def _ancestor(self):
+ for _tag, how in reversed(self._groups):
+ if how is not None:
+ return how
+ return None
+
+ def handle_starttag(self, tag, attrs):
+ self._start(tag, first_wins(attrs), closes=False)
+
+ def handle_startendtag(self, tag, attrs):
+ self._start(tag, first_wins(attrs), closes=True)
+
+ def _start(self, tag, attrs, closes):
+ if tag in GROUP_TAGS:
+ if not closes:
+ how = None
+ if "transform" in attrs:
+ how = "an ancestor <g>/<svg> transform"
+ elif transform_carrier(attrs) is not None:
+ how = "an ancestor <g>/<svg> style transform"
+ self._groups.append((tag, how))
+ return
+ if tag != "path" and tag not in BODY_TAGS:
+ return
+ element = Element(tag, attrs, self._offset(), self.getpos()[0], self._ancestor())
+ if tag == "path":
+ self.paths.append(element)
+ return
+ if tag == "text":
+ self.texts.append(element)
+ elif tag == "style":
+ self.styles.append(element)
+ else:
+ self.named.append(element)
+ if not closes:
+ self._open.append((tag, element))
+
+ def handle_endtag(self, tag):
+ stack = self._groups if tag in GROUP_TAGS else self._open if tag in BODY_TAGS else None
+ if stack is None:
+ return
+ # Pop back to the matching open tag - an unclosed inner element ends
+ # with its parent, as it does in the browser's tree.
+ for index in range(len(stack) - 1, -1, -1):
+ if stack[index][0] == tag:
+ del stack[index:]
+ return
+
+ def handle_data(self, data):
+ if self._open:
+ # Innermost only: a <title> tooltip inside a <text> is not part of
+ # the rendered label, and the browser does not draw it either.
+ self._open[-1][1].body += data
+
+
+def parse_document(source: str) -> _Scanner:
+ return _Scanner(source)
+
+
+def attrs_of(raw: str) -> dict:
+ """First-wins attributes of one tag's raw attribute text, via the parser."""
+
+ class _One(HTMLParser):
+ def __init__(self):
+ super().__init__(convert_charrefs=True)
+ self.attrs = {}
+
+ def handle_starttag(self, tag, attrs):
+ self.attrs = first_wins(attrs)
+
+ handle_startendtag = handle_starttag
+
+ scanner = _One()
+ scanner.feed("<x " + raw + ">")
+ scanner.close()
+ return scanner.attrs
+
+
+def strip_css_comments(text: str) -> str:
+ """CSS text with every `/* ... */` replaced by the whitespace it is.
+
+ Each comment becomes one space plus the newlines it contained, so the
+ result tokenizes as the browser tokenizes the original AND keeps every
+ line number where it was: the <style> finding reports the line of the
+ declaration by counting newlines up to the match, and a comment that
+ swallowed its newlines would shift that line.
+ """
+ return CSS_COMMENT_RE.sub(lambda found: " " + "\n" * found.group().count("\n"), text)
+
+
+def transform_carrier(attrs: dict):
+ """How this element carries a transform, phrased for the finding, or None.
+
+ A transform reaches the renderer by three carriers and the `transform`
+ ATTRIBUTE is only the most visible one. Reading the attribute alone lets
+ `style="transform: translateY(...)"` on a layer, a bound label or an
+ ancestor group move the rendered mark after its raw coordinates were
+ validated. The third carrier, a rule in a <style> block, is reported
+ separately because nothing here can tell which marks such a rule selects.
+ """
+ if "transform" in attrs:
+ return "transform=%r" % attrs["transform"]
+ style = attrs.get("style")
+ if style is not None:
+ found = CSS_MOVES_MARK_RE.search(strip_css_comments(style))
+ if found is not None:
+ return "style=%r (the %s property)" % (style, found.group("prop").lower())
+ return None
+
+
+def plain(body: str) -> str:
+ return body.strip()
+
+
+def number(value):
+ """A finite float, or None - NaN satisfies every tolerance check silently."""
+ if value is None:
+ return None
+ try:
+ parsed = float(str(value).replace(",", ""))
+ except (TypeError, ValueError):
+ return None
+ return parsed if math.isfinite(parsed) else None
+
+
+def printed_number(body: str):
+ """(value, reason) for a label's visible text - one complete token only."""
+ match = NUMBER_RE.search(body)
+ if match is None:
+ return None, "prints no number"
+ outside = body[:match.start()] + body[match.end():]
+ if DIGIT_RE.search(outside):
+ return None, "prints more than one numeric token"
+ value = number(match.group())
+ if value is None:
+ return None, "prints a number this checker cannot read"
+ return value, None
+
+
+def median(values: list) -> float:
+ ordered = sorted(values)
+ middle = len(ordered) // 2
+ if len(ordered) % 2:
+ return ordered[middle]
+ return (ordered[middle - 1] + ordered[middle]) / 2.0
+
+
+def named_text(doc: _Scanner) -> str:
+ return " ".join(plain(element.body) for element in doc.named).casefold()
+
+
+def looks_like_streamgraph(path: Path, source: str) -> bool:
+ """Does this file present itself as a streamgraph?
+
+ Deliberately generous, and searched whole-document: anything that claims
+ the type in its name, its accessible description, or its markup is held to
+ the contract even if it declares nothing parseable - that combination is
+ the fail-closed case, not a pass. HTML comments are not markup, so a
+ commented-out draft of a layer cannot pull another example type into
+ scope; a mangled tag whose bytes still say `data-layer=` can, and then
+ the parser finding no complete layer is exactly what is reported.
+ """
+ if path.name.startswith("example-streamgraph"):
+ return True
+ if DECLARES_LAYER_RE.search(HTML_COMMENT_RE.sub(" ", source)):
+ return True
+ described = named_text(parse_document(source))
+ return "streamgraph" in described or "stream graph" in described
+
+
+def parse_path_points(d: str):
+ """((top_points, bottom_points_as_drawn, controls), reason).
+
+ controls is [(sequence, segment_index, (c1, c2))] where sequence is "top"
+ or "bottom" and segment_index counts C commands within that boundary.
+ Only absolute M/C/L/Z are accepted; the exact structure is one M (start of
+ the top boundary), C segments to its end, one L (drop to the bottom
+ boundary), C segments back, and Z.
+ """
+ tokens = PATH_TOKEN_RE.findall(d)
+ if "".join(tokens).replace(" ", "") != re.sub(r"[\s,]+", "", d):
+ return None, "contains characters outside absolute M/C/L/Z path data"
+ position = 0
+
+ def take_numbers(count):
+ nonlocal position
+ taken = []
+ while len(taken) < count and position < len(tokens):
+ value = number(tokens[position])
+ if value is None:
+ return None
+ taken.append(value)
+ position += 1
+ return taken if len(taken) == count else None
+
+ sequences = [] # list of (command, coords)
+ while position < len(tokens):
+ command = tokens[position]
+ position += 1
+ if command in ("M", "L"):
+ coords = take_numbers(2)
+ elif command == "C":
+ coords = take_numbers(6)
+ elif command == "Z":
+ coords = []
+ elif command.isalpha():
+ return None, "uses path command %r - only absolute M/C/L/Z are verifiable" % command
+ else:
+ return None, "has a number where a command was expected"
+ if coords is None:
+ return None, "has a malformed %s command" % command
+ sequences.append((command, coords))
+
+ if not sequences or sequences[0][0] != "M" or sequences[-1][0] != "Z":
+ return None, "must begin with M and end with Z"
+ if sum(1 for c, _ in sequences if c == "M") != 1:
+ return None, "must contain exactly one subpath"
+ if sum(1 for c, _ in sequences if c == "L") != 1:
+ return None, "must contain exactly one L (the join between boundaries)"
+ if sum(1 for c, _ in sequences if c == "Z") != 1:
+ return None, "must contain exactly one Z"
+
+ top, bottom, controls = [], [], []
+ current, boundary = top, "top"
+ top.append(tuple(sequences[0][1]))
+ for command, coords in sequences[1:-1]:
+ if command == "C":
+ c1, c2, end = tuple(coords[0:2]), tuple(coords[2:4]), tuple(coords[4:6])
+ controls.append((boundary, len(current) - 1, (c1, c2)))
+ current.append(end)
+ elif command == "L":
+ if boundary == "bottom":
+ return None, "must contain exactly one L"
+ current, boundary = bottom, "bottom"
+ bottom.append(tuple(coords))
+ if len(top) < 3 or len(bottom) != len(top):
+ return None, ("draws %d top and %d bottom vertices - both boundaries need "
+ "one on-curve vertex per period, at least three periods"
+ % (len(top), len(bottom)))
+ return (top, bottom, controls), None
+
+
+def parse_layers(doc: _Scanner, findings: list, name: str) -> list:
+ """Layer paths, with anything unparseable reported rather than dropped."""
+ layers = []
+ seen = set()
+ for element in doc.paths:
+ attrs = element.attrs
+ label = attrs.get("data-layer")
+ if label is None:
+ # A <path> with no data-layer is scenery by contract. The parser
+ # reads every tag the browser reads, so there is no "declared but
+ # unparseable" case left to report here.
+ continue
+ line = element.line
+ if label in seen:
+ findings.append(
+ "%s:%d: a second path declares data-layer=%r — one layer, one path"
+ % (name, line, label)
+ )
+ continue
+ missing = [key for key in ("data-values", "d") if key not in attrs]
+ if missing:
+ findings.append(
+ "%s:%d: layer %r is missing %s — a layer must declare its values "
+ "and its geometry or it cannot be verified"
+ % (name, line, label, ", ".join(missing))
+ )
+ continue
+ values = [number(token) for token in attrs["data-values"].split(",")]
+ if any(value is None for value in values):
+ findings.append(
+ "%s:%d: layer %r declares a value that is not a finite number — "
+ "cannot verify its thickness" % (name, line, label)
+ )
+ continue
+ if any(value < 0 for value in values):
+ findings.append(
+ "%s:%d: layer %r declares a negative value — a streamgraph layer "
+ "is a magnitude; encode direction some other way" % (name, line, label)
+ )
+ continue
+ parsed, reason = parse_path_points(attrs["d"])
+ if parsed is None:
+ findings.append("%s:%d: layer %r's path %s" % (name, line, label, reason))
+ continue
+ top, bottom, controls = parsed
+ if len(values) != len(top):
+ findings.append(
+ "%s:%d: layer %r declares %d values but draws %d period vertices — "
+ "every period needs exactly one declared value"
+ % (name, line, label, len(values), len(top))
+ )
+ continue
+ xs_top = [p[0] for p in top]
+ xs_bottom = [p[0] for p in bottom]
+ if xs_top != sorted(xs_top) or len(set(xs_top)) != len(xs_top):
+ findings.append(
+ "%s:%d: layer %r's top boundary does not run left to right across "
+ "distinct period columns" % (name, line, label)
+ )
+ continue
+ if xs_bottom != sorted(xs_bottom, reverse=True) or \
+ sorted(round(x, 3) for x in xs_bottom) != [round(x, 3) for x in xs_top]:
+ findings.append(
+ "%s:%d: layer %r's bottom boundary does not mirror its top boundary's "
+ "period columns right to left" % (name, line, label)
+ )
+ continue
+ seen.add(label)
+ # Store bottom left-to-right; remember the drawn order for controls.
+ layer = Layer(label, values, top, list(reversed(bottom)), line)
+ layer.controls = controls
+ layers.append(layer)
+ return layers
+
+
+# === CHECKS ==================================================================
+
+
+def is_bound_label(attrs: dict) -> bool:
+ return "data-layer" in attrs or "data-period" in attrs or "data-index" in attrs
+
+
+def check_transforms(doc: _Scanner, findings: list, name: str) -> None:
+ """No transform may move verified geometry or a bound label.
+
+ Rejected rather than resolved, following verify-slopegraph.py: a partial
+ implementation of the SVG transform stack is worse than an honest
+ refusal, because it looks like coverage. All three carriers are held to
+ that rule - the `transform` attribute, an inline `style="transform: ..."`,
+ and a rule in a <style> block - on the element and on every <g>/<svg>
+ above it, because a gate that closes one of three doorways guards nothing.
+ """
+
+ def report(element, what, how):
+ findings.append(
+ "%s:%d: %s carries %s — this checker validates raw path and label "
+ "coordinates, so a transform moves the rendered mark away from the "
+ "number it was checked against. Bake the offset into the coordinates "
+ "instead" % (name, element.line, what, how)
+ )
+
+ def check_element(element, what):
+ how = transform_carrier(element.attrs)
+ if how is None:
+ how = element.ancestor
+ if how is not None:
+ report(element, what, how)
+
+ for element in doc.paths:
+ if "data-layer" in element.attrs:
+ check_element(element, "layer %r" % element.attrs["data-layer"])
+
+ for element in doc.texts:
+ if is_bound_label(element.attrs):
+ check_element(element, "a bound label (%s)" % plain(element.body)[:20])
+
+ for element in doc.styles:
+ # Comments become whitespace before the search (a `/**/` prefix is
+ # not a declaration boundary the regex knows), with newlines kept so
+ # the reported line is the declaration's line in the source.
+ body = strip_css_comments(element.body)
+ found = CSS_MOVES_MARK_RE.search(body)
+ if found:
+ findings.append(
+ "%s:%d: a CSS `%s` declaration — this checker cannot tell which "
+ "marks it applies to, and one that positions verified geometry "
+ "invalidates every coordinate here. Remove it, or bake the offset "
+ "into the coordinates"
+ % (name, element.line + body.count("\n", 0, found.start()),
+ found.group("prop").lower())
+ )
+
+
+def check_columns(layers: list, findings: list, name: str) -> bool:
+ """Every layer must sample the same period columns. False stops geometry."""
+ reference = [round(p[0], 3) for p in layers[0].top]
+ agreed = True
+ for layer in layers[1:]:
+ columns = [round(p[0], 3) for p in layer.top]
+ if columns != reference:
+ findings.append(
+ "%s:%d: layer %r samples periods at %s but %r samples %s — every "
+ "layer must share one set of period columns or the stack cannot "
+ "be verified"
+ % (name, layer.line, layer.name,
+ "/".join("%g" % c for c in columns[:4]) + ("…" if len(columns) > 4 else ""),
+ layers[0].name,
+ "/".join("%g" % c for c in reference[:4]) + ("…" if len(reference) > 4 else ""))
+ )
+ agreed = False
+ return agreed
+
+
+def check_scale(layers: list, findings: list, name: str) -> None:
+ """Per-period thickness must equal value times one shared scale."""
+ ratios = []
+ for layer in layers:
+ for i, value in enumerate(layer.values):
+ thickness = layer.bottom[i][1] - layer.top[i][1]
+ if value > 0:
+ ratios.append(thickness / value)
+ if not ratios:
+ findings.append(
+ "%s: every declared value is zero, so the scale cannot be derived and "
+ "no thickness here is verifiable" % name
+ )
+ return
+ scale = median(ratios)
+ if scale <= 0:
+ findings.append(
+ "%s: the derived scale is not positive — layers draw their bottom "
+ "boundary above their top, which is a folded geometry, not a stream"
+ % name
+ )
+ return
+ for layer in layers:
+ worst = None
+ for i, value in enumerate(layer.values):
+ thickness = layer.bottom[i][1] - layer.top[i][1]
+ drift = abs(thickness - value * scale)
+ if drift > RESIDUAL_TOLERANCE and (worst is None or drift > worst[1]):
+ worst = (i, drift, thickness, value)
+ if worst is not None:
+ i, drift, thickness, value = worst
+ findings.append(
+ "%s:%d: layer %r draws %.1f px of thickness at period %d where its "
+ "declared value %g belongs at %.1f px on the shared scale — off by "
+ "%.1f px. A zero must pinch to zero, and no band may be inflated "
+ "to smooth the flow"
+ % (name, layer.line, layer.name, thickness, i, value, value * scale, drift)
+ )
+
+
+def stacked_order(layers: list) -> list:
+ """Layers bottom of the stack first, by mean bottom-boundary y (SVG y grows
+ downward, so the bottom-most layer has the largest bottom y)."""
+ return sorted(
+ layers,
+ key=lambda layer: -sum(p[1] for p in layer.bottom) / len(layer.bottom),
+ )
+
+
+def check_stack(layers: list, findings: list, name: str) -> None:
+ """Layers must tile: each bottom is the previous top; envelope centred."""
+ ordered = stacked_order(layers)
+ for below, above in zip(ordered, ordered[1:]):
+ worst = None
+ for i in range(len(below.top)):
+ gap = above.bottom[i][1] - below.top[i][1]
+ if abs(gap) > STACK_TOLERANCE and (worst is None or abs(gap) > abs(worst[1])):
+ worst = (i, gap)
+ if worst is not None:
+ i, gap = worst
+ findings.append(
+ "%s:%d: layer %r's bottom boundary sits %.1f px %s layer %r's top at "
+ "period %d — the stack must tile with no gaps and no overlaps, in "
+ "one fixed order, and no layer may be dropped from it silently"
+ % (name, above.line, above.name, abs(gap),
+ "below" if gap > 0 else "above", below.name, i)
+ )
+
+ envelope_bottom = ordered[0].bottom
+ envelope_top = ordered[-1].top
+ midlines = [(envelope_top[i][1] + envelope_bottom[i][1]) / 2.0
+ for i in range(len(envelope_top))]
+ centre = median(midlines)
+ worst = None
+ for i, midline in enumerate(midlines):
+ drift = abs(midline - centre)
+ if drift > MIDLINE_TOLERANCE and (worst is None or drift > worst[1]):
+ worst = (i, drift)
+ if worst is not None:
+ i, drift = worst
+ findings.append(
+ "%s:%d: the baseline is not symmetric — the envelope midline drifts "
+ "%.1f px off centre at period %d. A streamgraph centres every period "
+ "on one midline (baseline = -total/2); a drifting or bottom-pinned "
+ "baseline is a different chart wearing this one's name"
+ % (name, ordered[0].line, drift, i)
+ )
+
+
+def check_controls(layers: list, findings: list, name: str) -> None:
+ """Control points must sit where Catmull-Rom at 1/6 chord puts them."""
+ for layer in layers:
+ boundaries = {
+ "top": layer.top,
+ "bottom": list(reversed(layer.bottom)), # as drawn, right to left
+ }
+ worst = None
+ for boundary, segment, (c1, c2) in layer.controls:
+ points = boundaries[boundary]
+ i = segment
+ p0 = points[i - 1] if i > 0 else points[i]
+ p1, p2 = points[i], points[i + 1]
+ p3 = points[i + 2] if i + 2 < len(points) else points[i + 1]
+ expected_c1 = (p1[0] + (p2[0] - p0[0]) / 6.0, p1[1] + (p2[1] - p0[1]) / 6.0)
+ expected_c2 = (p2[0] - (p3[0] - p1[0]) / 6.0, p2[1] - (p3[1] - p1[1]) / 6.0)
+ drift = max(abs(c1[0] - expected_c1[0]), abs(c1[1] - expected_c1[1]),
+ abs(c2[0] - expected_c2[0]), abs(c2[1] - expected_c2[1]))
+ if drift > CONTROL_TOLERANCE and (worst is None or drift > worst[2]):
+ worst = (boundary, i, drift)
+ if worst is not None:
+ boundary, i, drift = worst
+ findings.append(
+ "%s:%d: layer %r's %s boundary bends away from its vertices — a "
+ "control point sits %.1f px from where Catmull-Rom at 1/6 chord "
+ "puts it (segment %d). The curve between vertices is determined "
+ "by the vertices; it is not free to editorialise"
+ % (name, layer.line, layer.name, boundary, drift, i)
+ )
+
+
+def layers_named_in(body: str, names) -> set:
+ """Which declared layer names the visible text actually prints.
+
+ Longest candidate first at each position, so a layer called "Unit" is
+ not reported as appearing inside a sibling called "Unit tests".
+ """
+ ordered = sorted(names, key=len, reverse=True)
+ found = set()
+ index = 0
+ while index < len(body):
+ for candidate in ordered:
+ if candidate and body.startswith(candidate, index):
+ found.add(candidate)
+ index += len(candidate)
+ break
+ else:
+ index += 1
+ return found
+
+
+def check_legend(layers: list, doc: _Scanner, findings: list, name: str) -> None:
+ """Every layer in the legend with its total; every total a sum, not a typo."""
+ declared = {layer.name: layer for layer in layers}
+ entries = {}
+ for element in doc.texts:
+ attrs = element.attrs
+ label = attrs.get("data-layer")
+ if label is None:
+ continue
+ if label not in declared:
+ findings.append(
+ "%s:%d: a legend entry names layer %r, which no path declares — a "
+ "label with no band is not verifiable and reads as data"
+ % (name, element.line, label)
+ )
+ continue
+ if label in entries:
+ findings.append(
+ "%s:%d: a second legend entry for layer %r — one layer, one entry, "
+ "or the figure states two totals for one band"
+ % (name, element.line, label)
+ )
+ continue
+ entries[label] = (attrs.get("data-total"), plain(element.body), element.line)
+
+ for layer in layers:
+ entry = entries.get(layer.name)
+ if entry is None:
+ findings.append(
+ "%s:%d: layer %r has no legend entry (a <text> with data-layer and "
+ "data-total) — a streamgraph names every layer and prints its "
+ "total, or a band can be dropped from the reading silently"
+ % (name, layer.line, layer.name)
+ )
+ continue
+ declared_total, body, line = entry
+ total = number(declared_total)
+ if total is None:
+ findings.append(
+ "%s:%d: the legend entry for %r has no readable data-total — the "
+ "printed total must be bound to the number it claims to state"
+ % (name, line, layer.name)
+ )
+ continue
+ expected = sum(layer.values)
+ if abs(total - expected) > VALUE_TOLERANCE:
+ findings.append(
+ "%s:%d: layer %r declares a total of %g but its values sum to %g — "
+ "the total is a sum, not a typed number"
+ % (name, line, layer.name, total, expected)
+ )
+ shown, reason = printed_number(body)
+ if shown is None:
+ findings.append(
+ "%s:%d: the legend entry for %r %s (%r) — print exactly one "
+ "complete total per entry, and keep digits out of layer names"
+ % (name, line, layer.name, reason, body[:28])
+ )
+ elif abs(shown - total) > VALUE_TOLERANCE:
+ findings.append(
+ "%s:%d: the legend entry for %r prints %r but declares %g — the "
+ "label and the binding must state one number"
+ % (name, line, layer.name, body[:28], total)
+ )
+
+ # The number is bound; the NAME must be bound too. An entry reading
+ # "Unit · 688 min" above data-layer="End-to-end" with End-to-end's
+ # real total satisfies every check above and still hands the reader
+ # the wrong band. A hidden datum being right is not the figure being
+ # right - the visible string is what anyone actually reads.
+ printed = layers_named_in(body, declared)
+ if layer.name not in printed:
+ findings.append(
+ "%s:%d: the legend entry for %r prints %r, which does not name "
+ "that layer — bind the visible name as well as the number, or "
+ "an entry can label the wrong band while its data-layer and its "
+ "total stay right"
+ % (name, line, layer.name, body[:28])
+ )
+ elif printed - {layer.name}:
+ findings.append(
+ "%s:%d: the legend entry for %r also prints %s — one entry names "
+ "one band, or the reader cannot tell which band it labels"
+ % (name, line, layer.name,
+ ", ".join(repr(other)
+ for other in sorted(printed - {layer.name})))
+ )
+
+
+def check_captions(layers: list, doc: _Scanner, findings: list, name: str) -> None:
+ """Each period caption must sit on its own column and read its binding."""
+ columns = [p[0] for p in layers[0].top]
+ count = len(columns)
+ seen = {}
+ for element in doc.texts:
+ attrs = element.attrs
+ if "data-index" not in attrs and "data-period" not in attrs:
+ continue
+ index_raw = attrs.get("data-index")
+ period = attrs.get("data-period")
+ line = element.line
+ if index_raw is None or period is None:
+ findings.append(
+ "%s:%d: a period caption must carry both data-index (its column) "
+ "and data-period (its text) — half a binding can still be swapped"
+ % (name, line)
+ )
+ continue
+ index = number(index_raw)
+ if index is None or index != int(index) or not 0 <= int(index) < count:
+ findings.append(
+ "%s:%d: a period caption declares data-index=%r, which is not a "
+ "column of this figure (0–%d)"
+ % (name, line, index_raw, count - 1)
+ )
+ continue
+ index = int(index)
+ if index in seen:
+ findings.append(
+ "%s:%d: a second caption for period %d — one column, one caption"
+ % (name, line, index)
+ )
+ continue
+ seen[index] = (number(attrs.get("x")), period, plain(element.body), line)
+
+ for index in range(count):
+ if index not in seen:
+ findings.append(
+ "%s: no caption for period %d (data-index=%r) — every bucket is "
+ "named, or the reader cannot place the pinch this figure keeps"
+ % (name, index, index)
+ )
+ continue
+ x, period, body, line = seen[index]
+ expected = columns[index]
+ if x is None or abs(x - expected) > CAPTION_TOLERANCE:
+ findings.append(
+ "%s:%d: the caption for period %d (%r) is drawn at x=%s but its "
+ "column is at x=%g — a caption off its column renames the bucket"
+ % (name, line, index, body[:16],
+ "%g" % x if x is not None else "?", expected)
+ )
+ if body != period:
+ findings.append(
+ "%s:%d: the caption for period %d reads %r but declares "
+ "data-period=%r — the visible text and its binding must agree"
+ % (name, line, index, body[:16], period)
+ )
+
+
+# === DRIVER ==================================================================
+
+
+def check_source(path: Path, raw: str) -> list:
+ """Findings for one already-read document."""
+ findings: list = []
+ doc = parse_document(raw)
+ if doc.error is not None:
+ findings.append(
+ "%s: presents as a streamgraph but could not be parsed as HTML (%s) — "
+ "refusing to report OK on a file this checker could not read"
+ % (path.name, doc.error)
+ )
+ return findings
+ layers = parse_layers(doc, findings, path.name)
+
+ if len(layers) < 2:
+ findings.append(
+ "%s: presents as a streamgraph but declares %d verifiable layer(s) — "
+ "every band needs data-layer with data-values and an absolute M/C/L/Z "
+ "path. Refusing to report OK on a file this checker could not read"
+ % (path.name, len(layers))
+ )
+ return findings
+
+ check_transforms(doc, findings, path.name)
+ if check_columns(layers, findings, path.name):
+ check_scale(layers, findings, path.name)
+ check_stack(layers, findings, path.name)
+ check_controls(layers, findings, path.name)
+ check_captions(layers, doc, findings, path.name)
+ check_legend(layers, doc, findings, path.name)
+ return findings
+
+
+def check(path: Path) -> list:
+ """Findings for one file on disk, or [] if it is not a streamgraph."""
+ raw = path.read_text(encoding="utf-8")
+ if not looks_like_streamgraph(path, raw):
+ return []
+ return check_source(path, raw)
+
+
+def targets(args: argparse.Namespace) -> list:
+ if args.all:
+ return sorted(ASSET_DIR.glob("example-*.html"))
+ return [Path(p) for p in args.paths]
+
+
+def main() -> int:
+ parser = argparse.ArgumentParser(
+ description="Verify streamgraph layers against the values they declare."
+ )
+ parser.add_argument("paths", nargs="*", help="HTML files to check")
+ parser.add_argument(
+ "--all", action="store_true",
+ help="check every shipped example that presents as a streamgraph",
+ )
+ args = parser.parse_args()
+ if not args.all and not args.paths:
+ parser.print_help()
+ return 2
+
+ findings: list = []
+ checked = 0
+ skipped = 0
+ for path in targets(args):
+ if not path.is_file():
+ print("error: %s is not a readable file" % path, file=sys.stderr)
+ return 2
+ try:
+ raw = path.read_text(encoding="utf-8")
+ except (OSError, UnicodeDecodeError) as error:
+ print("error: cannot read %s: %s" % (path, error), file=sys.stderr)
+ return 2
+ if not looks_like_streamgraph(path, raw):
+ skipped += 1
+ continue
+ findings.extend(check_source(path, raw))
+ checked += 1
+
+ for finding in findings:
+ print(finding)
+ tail = " (%d file(s) skipped as out of scope)" % skipped if skipped else ""
+ if findings:
+ print("\n%d streamgraph finding(s) across %d file(s).%s"
+ % (len(findings), checked, tail))
+ return 1
+ if not checked:
+ print("OK streamgraph: no streamgraph found to check%s" % tail)
+ return 0
+ print("OK streamgraph: %d file(s), one shared scale on a symmetric baseline, a "
+ "tiled stack with determined curves, no transforms on verified geometry, "
+ "and every total and caption bound to what it describes%s"
+ % (checked, tail))
+ return 0
+
+
+if __name__ == "__main__":
+ raise SystemExit(main())
diff --git a/skills/diagram-design/SKILL.md b/skills/diagram-design/SKILL.md
index 8cdb571..6570381 100644
--- a/skills/diagram-design/SKILL.md
+++ b/skills/diagram-design/SKILL.md
@@ -101,7 +101,7 @@ The pattern owns semantic primitives and its tighter budget; the type owns layou
| Quantitative comparison across categories | **Bar chart** | [type-bar.md](references/type-bar.md) |
| A start total bridged to an end total by signed contributions (budget bridge, headcount deltas) | **Waterfall** | [type-waterfall.md](references/type-waterfall.md) |
| Part-of-whole where the relative sizes are the story, or a two-way split where column width and segment height are both shares (marimekko) | **Treemap** | [type-treemap.md](references/type-treemap.md) |
-| Continuous trends over time, change between exactly two states (slopegraph), one distribution per series (ridgeline), or rank movement across several snapshots (bump) | **Line chart** | [type-line.md](references/type-line.md) |
+| Continuous trends over time, change between exactly two states (slopegraph), one distribution per series (ridgeline), rank movement across several snapshots (bump), or total composition across periods (streamgraph) | **Line chart** | [type-line.md](references/type-line.md) |
| Tasks and phases on a timeline | **Gantt** | [type-gantt.md](references/type-gantt.md) |
| Distribution and correlation between two variables, three with area-sized marks (bubble), or one variable with a dot per item (beeswarm) | **Scatter plot** | [type-scatter.md](references/type-scatter.md) |
| End-to-end data stack on a container cluster | **High-Level** | [type-high-level.md](references/type-high-level.md) |
diff --git a/skills/diagram-design/assets/example-streamgraph-dark.html b/skills/diagram-design/assets/example-streamgraph-dark.html
new file mode 100644
index 0000000..1ae4ad3
--- /dev/null
+++ b/skills/diagram-design/assets/example-streamgraph-dark.html
@@ -0,0 +1,99 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <meta charset="UTF-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
+ <title>Build minutes by pipeline, twelve weeks · Streamgraph · dark</title>
+ <link href="https://fonts.googleapis.com/css2?family=Instrument+Serif:ital@0;1&family=Geist:wght@400;500;600&family=Geist+Mono:wght@400;500;600&display=swap" rel="stylesheet">
+ <style>
+ *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
+ :root {
+ --color-paper: #2d3142;
+ --color-ink: #f5f5f5;
+ --color-muted: #bfc0c0;
+ --color-accent: #f08a59;
+ --font-sans: 'Geist', system-ui, sans-serif;
+ --font-serif: 'Instrument Serif', serif;
+ --font-mono: 'Geist Mono', ui-monospace, monospace;
+ }
+ body { font-family: var(--font-sans); background: var(--color-paper); color: var(--color-ink); min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 3rem 2rem; }
+ .frame { max-width: 1200px; width: 100%; }
+ .eyebrow { font-family: var(--font-mono); font-size: 0.66rem; font-weight: 500; letter-spacing: 0.18em; text-transform: uppercase; color: var(--color-muted); margin-bottom: 0.5rem; }
+ h1 { font-family: var(--font-serif); font-size: clamp(1.5rem, 2.4vw + 0.75rem, 2rem); font-weight: 400; letter-spacing: -0.02em; line-height: 1.15; margin-bottom: 1.5rem; }
+ svg { width: 100%; min-width: 760px; display: block; }
+ </style>
+</head>
+<body>
+ <div class="frame">
+ <p class="eyebrow">Streamgraph · Diagram Design</p>
+ <h1>Where the extra build minutes went</h1>
+
+ <svg viewBox="0 0 1000 500" xmlns="http://www.w3.org/2000/svg" role="img" aria-labelledby="streamgraph-dark-title streamgraph-dark-desc">
+ <title id="streamgraph-dark-title">Where the extra build minutes went</title>
+ <desc id="streamgraph-dark-desc">Streamgraph of weekly CI build minutes by pipeline across twelve weeks, stacked on a symmetric baseline so the envelope height reads as the total; the end-to-end suite grows from 12 to 118 minutes a week and passes the unit suite in week eight, while the docs pipeline pauses to zero in weeks five and six.</desc>
+ <defs>
+ <pattern id="dots" width="22" height="22" patternUnits="userSpaceOnUse">
+ <circle cx="1" cy="1" r="0.9" fill="rgba(245,245,245,0.10)"/>
+ </pattern>
+ </defs>
+
+ <rect width="100%" height="100%" fill="#2d3142"/>
+ <rect width="100%" height="100%" fill="url(#dots)" opacity="0.55"/>
+
+ <!-- Symmetric baseline: every period is centred on y=230, so the top and
+ bottom of the envelope always average to the midline and the envelope
+ height IS the weekly total at 1.25px per minute. Boundaries are
+ Catmull-Rom smoothed (control points at 1/6 chord) with every vertex
+ on its true stacked value; scripts/verify-streamgraph.py enforces
+ both against the values each layer declares. -->
+ <text transform="rotate(-90 24 230)" x="24" y="230" fill="#bfc0c0" font-size="7" font-family="'Geist Mono', monospace" letter-spacing="0.14em" text-anchor="middle">BUILD MINUTES PER WEEK</text>
+
+ <!-- No y-axis ticks: the form is about the shape of the envelope and the
+ layers inside it; per-pipeline totals are printed in the legend. -->
+ <path data-layer="Docs" data-values="8,9,7,6,0,0,5,7,8,8,9,9" d="M 80 297.5 C 93.3 298.1, 133.3 299.4, 160 301.2 C 186.7 303, 213.3 305.9, 240 308.1 C 266.7 310.3, 293.3 311.3, 320 314.4 C 346.7 317.5, 373.3 323, 400 326.9 C 426.7 330.8, 453.3 334.9, 480 337.5 C 506.7 340.1, 533.3 339.7, 560 342.5 C 586.7 345.3, 613.3 350.8, 640 354.4 C 666.7 358, 693.3 361.4, 720 364.4 C 746.7 367.4, 773.3 369.4, 800 372.5 C 826.7 375.6, 853.3 379.8, 880 383.1 C 906.7 386.4, 946.7 390.9, 960 392.5 L 960 403.8 C 946.7 402.2, 906.7 397.9, 880 394.4 C 853.3 390.8, 826.7 385.8, 800 382.5 C 773.3 379.2, 746.7 377.6, 720 374.4 C 693.3 371.2, 666.7 367.4, 640 363.1 C 613.3 358.8, 586.7 353.1, 560 348.8 C 533.3 344.5, 506.7 341.1, 480 337.5 C 453.3 333.9, 426.7 329.5, 400 326.9 C 373.3 324.3, 346.7 323.6, 320 321.9 C 293.3 320.2, 266.7 318.5, 240 316.9 C 213.3 315.3, 186.7 314.1, 160 312.5 C 133.3 310.9, 93.3 308.3, 80 307.5 Z" fill="rgba(245,245,245,0.30)" stroke="#2d3142" stroke-width="1"/>
+ <path data-layer="Integration" data-values="34,36,38,42,44,47,49,52,54,56,59,61" d="M 80 255 C 93.3 255.2, 133.3 255.3, 160 256.2 C 186.7 257.1, 213.3 259.7, 240 260.6 C 266.7 261.6, 293.3 260, 320 261.9 C 346.7 263.8, 373.3 269.1, 400 271.9 C 426.7 274.7, 453.3 277.2, 480 278.8 C 506.7 280.4, 533.3 279.4, 560 281.2 C 586.7 283, 613.3 286.8, 640 289.4 C 666.7 292, 693.3 294.7, 720 296.9 C 746.7 299.1, 773.3 300.4, 800 302.5 C 826.7 304.6, 853.3 307.1, 880 309.4 C 906.7 311.7, 946.7 315.1, 960 316.2 L 960 392.5 C 946.7 390.9, 906.7 386.4, 880 383.1 C 853.3 379.8, 826.7 375.6, 800 372.5 C 773.3 369.4, 746.7 367.4, 720 364.4 C 693.3 361.4, 666.7 358, 640 354.4 C 613.3 350.8, 586.7 345.3, 560 342.5 C 533.3 339.7, 506.7 340.1, 480 337.5 C 453.3 334.9, 426.7 330.8, 400 326.9 C 373.3 323, 346.7 317.5, 320 314.4 C 293.3 311.3, 266.7 310.3, 240 308.1 C 213.3 305.9, 186.7 303, 160 301.2 C 133.3 299.4, 93.3 298.1, 80 297.5 Z" fill="rgba(245,245,245,0.62)" stroke="#2d3142" stroke-width="1"/>
+ <path data-layer="Unit" data-values="58,60,62,61,64,66,65,68,70,69,72,74" d="M 80 182.5 C 93.3 182.3, 133.3 181.1, 160 181.2 C 186.7 181.3, 213.3 182.4, 240 183.1 C 266.7 183.8, 293.3 184.1, 320 185.6 C 346.7 187.1, 373.3 190.1, 400 191.9 C 426.7 193.7, 453.3 194.8, 480 196.2 C 506.7 197.5, 533.3 198.6, 560 200 C 586.7 201.4, 613.3 202.8, 640 204.4 C 666.7 206, 693.3 207.4, 720 209.4 C 746.7 211.4, 773.3 214.5, 800 216.2 C 826.7 217.9, 853.3 218.1, 880 219.4 C 906.7 220.7, 946.7 223.1, 960 223.8 L 960 316.2 C 946.7 315.1, 906.7 311.7, 880 309.4 C 853.3 307.1, 826.7 304.6, 800 302.5 C 773.3 300.4, 746.7 299.1, 720 296.9 C 693.3 294.7, 666.7 292, 640 289.4 C 613.3 286.8, 586.7 283, 560 281.2 C 533.3 279.4, 506.7 280.4, 480 278.8 C 453.3 277.2, 426.7 274.7, 400 271.9 C 373.3 269.1, 346.7 263.8, 320 261.9 C 293.3 260, 266.7 261.6, 240 260.6 C 213.3 259.7, 186.7 257.1, 160 256.2 C 133.3 255.3, 93.3 255.2, 80 255 Z" fill="rgba(245,245,245,0.78)" stroke="#2d3142" stroke-width="1"/>
+ <!-- End-to-end FOCAL: the accent marks the editorially focal layer --
+ the pipeline whose growth is the story -- and it is also the one
+ eating the budget. Every other layer rides the ink-opacity ramp,
+ strongest tone on the largest pipeline. -->
+ <path data-layer="End-to-end" data-values="12,15,19,26,34,45,58,72,85,96,108,118" d="M 80 167.5 C 93.3 166.7, 133.3 163.8, 160 162.5 C 186.7 161.2, 213.3 161, 240 159.4 C 266.7 157.8, 293.3 154.8, 320 153.1 C 346.7 151.4, 373.3 151.6, 400 149.4 C 426.7 147.2, 453.3 143.7, 480 140 C 506.7 136.3, 533.3 131.8, 560 127.5 C 586.7 123.2, 613.3 118.5, 640 114.4 C 666.7 110.3, 693.3 106.1, 720 103.1 C 746.7 100.1, 773.3 99.3, 800 96.2 C 826.7 93.1, 853.3 87.7, 880 84.4 C 906.7 81.1, 946.7 77.6, 960 76.2 L 960 223.8 C 946.7 223.1, 906.7 220.7, 880 219.4 C 853.3 218.1, 826.7 217.9, 800 216.2 C 773.3 214.5, 746.7 211.4, 720 209.4 C 693.3 207.4, 666.7 206, 640 204.4 C 613.3 202.8, 586.7 201.4, 560 200 C 533.3 198.6, 506.7 197.5, 480 196.2 C 453.3 194.8, 426.7 193.7, 400 191.9 C 373.3 190.1, 346.7 187.1, 320 185.6 C 293.3 184.1, 266.7 183.8, 240 183.1 C 213.3 182.4, 186.7 181.3, 160 181.2 C 133.3 181.1, 93.3 182.3, 80 182.5 Z" fill="#f08a59" stroke="#2d3142" stroke-width="1"/>
+ <path data-layer="Lint" data-values="12,12,13,12,13,14,13,14,14,15,15,16" d="M 80 152.5 C 93.3 151.7, 133.3 149.1, 160 147.5 C 186.7 145.9, 213.3 144.7, 240 143.1 C 266.7 141.5, 293.3 139.8, 320 138.1 C 346.7 136.4, 373.3 135.7, 400 133.1 C 426.7 130.5, 453.3 126.2, 480 122.5 C 506.7 118.8, 533.3 115.5, 560 111.2 C 586.7 106.9, 613.3 101.2, 640 96.9 C 666.7 92.6, 693.3 88.8, 720 85.6 C 746.7 82.4, 773.3 80.8, 800 77.5 C 826.7 74.2, 853.3 69.1, 880 65.6 C 906.7 62, 946.7 57.8, 960 56.2 L 960 76.2 C 946.7 77.6, 906.7 81.1, 880 84.4 C 853.3 87.7, 826.7 93.1, 800 96.2 C 773.3 99.3, 746.7 100.1, 720 103.1 C 693.3 106.1, 666.7 110.3, 640 114.4 C 613.3 118.5, 586.7 123.2, 560 127.5 C 533.3 131.8, 506.7 136.3, 480 140 C 453.3 143.7, 426.7 147.2, 400 149.4 C 373.3 151.6, 346.7 151.4, 320 153.1 C 293.3 154.8, 266.7 157.8, 240 159.4 C 213.3 161, 186.7 161.2, 160 162.5 C 133.3 163.8, 93.3 166.7, 80 167.5 Z" fill="rgba(245,245,245,0.46)" stroke="#2d3142" stroke-width="1"/>
+
+ <!-- One landmark, one hairline: the week the end-to-end suite becomes the
+ largest pipeline. Nothing else is annotated -- the shape is the story. -->
+ <line x1="640" y1="52" x2="640" y2="92" stroke="rgba(245,245,245,0.35)" stroke-width="1"/>
+ <text x="640" y="44" fill="#bfc0c0" font-size="7" font-family="'Geist Mono', monospace" letter-spacing="0.14em" text-anchor="middle">END-TO-END PASSES UNIT</text>
+
+ <text data-period="W01" data-index="0" x="80" y="440" fill="#bfc0c0" font-size="8" font-family="'Geist Mono', monospace" letter-spacing="0.08em" text-anchor="middle">W01</text>
+ <text data-period="W02" data-index="1" x="160" y="440" fill="#bfc0c0" font-size="8" font-family="'Geist Mono', monospace" letter-spacing="0.08em" text-anchor="middle">W02</text>
+ <text data-period="W03" data-index="2" x="240" y="440" fill="#bfc0c0" font-size="8" font-family="'Geist Mono', monospace" letter-spacing="0.08em" text-anchor="middle">W03</text>
+ <text data-period="W04" data-index="3" x="320" y="440" fill="#bfc0c0" font-size="8" font-family="'Geist Mono', monospace" letter-spacing="0.08em" text-anchor="middle">W04</text>
+ <text data-period="W05" data-index="4" x="400" y="440" fill="#bfc0c0" font-size="8" font-family="'Geist Mono', monospace" letter-spacing="0.08em" text-anchor="middle">W05</text>
+ <text data-period="W06" data-index="5" x="480" y="440" fill="#bfc0c0" font-size="8" font-family="'Geist Mono', monospace" letter-spacing="0.08em" text-anchor="middle">W06</text>
+ <text data-period="W07" data-index="6" x="560" y="440" fill="#bfc0c0" font-size="8" font-family="'Geist Mono', monospace" letter-spacing="0.08em" text-anchor="middle">W07</text>
+ <text data-period="W08" data-index="7" x="640" y="440" fill="#bfc0c0" font-size="8" font-family="'Geist Mono', monospace" letter-spacing="0.08em" text-anchor="middle">W08</text>
+ <text data-period="W09" data-index="8" x="720" y="440" fill="#bfc0c0" font-size="8" font-family="'Geist Mono', monospace" letter-spacing="0.08em" text-anchor="middle">W09</text>
+ <text data-period="W10" data-index="9" x="800" y="440" fill="#bfc0c0" font-size="8" font-family="'Geist Mono', monospace" letter-spacing="0.08em" text-anchor="middle">W10</text>
+ <text data-period="W11" data-index="10" x="880" y="440" fill="#bfc0c0" font-size="8" font-family="'Geist Mono', monospace" letter-spacing="0.08em" text-anchor="middle">W11</text>
+ <text data-period="W12" data-index="11" x="960" y="440" fill="#bfc0c0" font-size="8" font-family="'Geist Mono', monospace" letter-spacing="0.08em" text-anchor="middle">W12</text>
+
+ <!-- Legend -->
+ <line x1="40" y1="462" x2="960" y2="462" stroke="rgba(245,245,245,0.10)" stroke-width="0.8"/>
+ <text x="40" y="478" fill="#bfc0c0" font-size="8" font-family="'Geist Mono', monospace" letter-spacing="0.18em">LEGEND</text>
+ <text x="960" y="478" fill="#bfc0c0" font-size="8" font-family="'Geist Mono', monospace" letter-spacing="0.06em" text-anchor="end">BUILD MINUTES PER WEEK BY PIPELINE · WEEKLY BUCKETS · SYMMETRIC BASELINE, ENVELOPE HEIGHT = WEEKLY TOTAL · ILLUSTRATIVE FIGURES, NOT A MEASURED PROJECT</text>
+
+ <rect x="40" y="488" width="16" height="8" fill="#f08a59"/>
+ <text data-layer="End-to-end" data-total="688" x="64" y="496" fill="#bfc0c0" font-size="8.5" font-family="'Geist', sans-serif">End-to-end · 688 min · focal</text>
+ <rect x="264" y="488" width="16" height="8" fill="rgba(245,245,245,0.78)"/>
+ <text data-layer="Unit" data-total="789" x="288" y="496" fill="#bfc0c0" font-size="8.5" font-family="'Geist', sans-serif">Unit · 789 min</text>
+ <rect x="424" y="488" width="16" height="8" fill="rgba(245,245,245,0.62)"/>
+ <text data-layer="Integration" data-total="572" x="448" y="496" fill="#bfc0c0" font-size="8.5" font-family="'Geist', sans-serif">Integration · 572 min</text>
+ <rect x="624" y="488" width="16" height="8" fill="rgba(245,245,245,0.46)"/>
+ <text data-layer="Lint" data-total="163" x="648" y="496" fill="#bfc0c0" font-size="8.5" font-family="'Geist', sans-serif">Lint · 163 min</text>
+ <rect x="784" y="488" width="16" height="8" fill="rgba(245,245,245,0.30)"/>
+ <text data-layer="Docs" data-total="76" x="808" y="496" fill="#bfc0c0" font-size="8.5" font-family="'Geist', sans-serif">Docs · 76 min · paused</text>
+ </svg>
+ </div>
+</body>
+</html>
diff --git a/skills/diagram-design/assets/example-streamgraph-full.html b/skills/diagram-design/assets/example-streamgraph-full.html
new file mode 100644
index 0000000..337c413
--- /dev/null
+++ b/skills/diagram-design/assets/example-streamgraph-full.html
@@ -0,0 +1,129 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <meta charset="UTF-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
+ <title>Build minutes by pipeline, twelve weeks · Streamgraph</title>
+ <link href="https://fonts.googleapis.com/css2?family=Instrument+Serif:ital@0;1&family=Geist:wght@400;500;600&family=Geist+Mono:wght@400;500;600&display=swap" rel="stylesheet">
+ <style>
+ *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
+ :root { --color-paper:#f5f5f5; --color-paper-2:#ececec; --color-ink:#2d3142; --color-muted:#4f5d75; --color-soft:#7a8399; --color-rule:rgba(45,49,66,0.12); --color-accent:#eb6c36; --font-sans:'Geist',system-ui,sans-serif; --font-serif:'Instrument Serif',serif; --font-mono:'Geist Mono',ui-monospace,monospace; }
+ body { font-family: var(--font-sans); background: var(--color-paper); min-height: 100vh; padding: 3rem 2rem; color: var(--color-ink); }
+ .container { max-width: 1200px; margin: 0 auto; }
+ .header { margin-bottom: 2.5rem; }
+ .header-eyebrow { font-family: var(--font-mono); font-size: 0.66rem; font-weight: 500; letter-spacing: 0.18em; text-transform: uppercase; color: var(--color-muted); margin-bottom: 0.75rem; }
+ h1 { font-family: var(--font-serif); font-size: clamp(1.75rem, 3vw + 1rem, 2.5rem); font-weight: 400; letter-spacing: -0.02em; line-height: 1.1; margin-bottom: 0.5rem; }
+ .subtitle { font-size: 1rem; line-height: 1.55; color: var(--color-muted); max-width: 58ch; }
+ .diagram-container { background: var(--color-paper-2); border-radius: 8px; border: 1px solid var(--color-rule); padding: 1.5rem; overflow-x: auto; }
+ svg { width: 100%; min-width: 760px; display: block; }
+ .cards { display: grid; grid-template-columns: 1.1fr 1fr 0.9fr; gap: 1rem; margin-top: 1.5rem; }
+ @media (max-width: 720px) { .cards { grid-template-columns: 1fr; } }
+ .card { background: #fff; border-radius: 6px; border: 1px solid var(--color-rule); padding: 1.25rem; }
+ .card .eyebrow { font-family: var(--font-mono); font-size: 0.5rem; letter-spacing: 0.18em; text-transform: uppercase; color: var(--color-muted); margin-bottom: 0.5rem; }
+ .card-header { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.875rem; padding-bottom: 0.875rem; border-bottom: 1px solid rgba(45,49,66,0.08); }
+ .card-dot { width: 7px; height: 7px; border-radius: 50%; }
+ .card-dot.coral { background: var(--color-accent); }
+ .card-dot.ink-strong { background: rgba(45,49,66,0.78); }
+ .card-dot.ink-light { background: rgba(45,49,66,0.30); }
+ .card h3 { font-size: 0.875rem; font-weight: 600; }
+ .card p { color: var(--color-muted); font-size: 0.8125rem; line-height: 1.55; }
+ .footer { margin-top: 2rem; padding-top: 1.5rem; border-top: 1px solid rgba(45,49,66,0.10); font-family: var(--font-mono); font-size: 0.72rem; letter-spacing: 0.06em; color: var(--color-muted); display: flex; justify-content: space-between; flex-wrap: wrap; gap: 0.5rem; }
+ </style>
+</head>
+<body>
+ <div class="container">
+ <div class="header">
+ <p class="header-eyebrow">Streamgraph · Diagram Design</p>
+ <h1>Where the extra build minutes went</h1>
+ <p class="subtitle">Weekly CI build minutes per pipeline, stacked on a symmetric baseline so the height of the whole stream is the week's total. The build roughly doubled in twelve weeks, from 124 to 278 minutes, and almost all of the growth is one layer: the end-to-end suite, up from 12 to 118 minutes a week.</p>
+ </div>
+ <div class="diagram-container">
+ <svg viewBox="0 0 1000 500" xmlns="http://www.w3.org/2000/svg" role="img" aria-labelledby="streamgraph-full-title streamgraph-full-desc">
+ <title id="streamgraph-full-title">Where the extra build minutes went</title>
+ <desc id="streamgraph-full-desc">Streamgraph of weekly CI build minutes by pipeline across twelve weeks, stacked on a symmetric baseline so the envelope height reads as the total; the end-to-end suite grows from 12 to 118 minutes a week and passes the unit suite in week eight, while the docs pipeline pauses to zero in weeks five and six.</desc>
+ <defs>
+ <pattern id="dots" width="22" height="22" patternUnits="userSpaceOnUse">
+ <circle cx="1" cy="1" r="0.9" fill="rgba(45,49,66,0.10)"/>
+ </pattern>
+ </defs>
+
+ <rect width="100%" height="100%" fill="#f5f5f5"/>
+ <rect width="100%" height="100%" fill="url(#dots)" opacity="0.55"/>
+
+ <!-- Symmetric baseline: every period is centred on y=230, so the top and
+ bottom of the envelope always average to the midline and the envelope
+ height IS the weekly total at 1.25px per minute. Boundaries are
+ Catmull-Rom smoothed (control points at 1/6 chord) with every vertex
+ on its true stacked value; scripts/verify-streamgraph.py enforces
+ both against the values each layer declares. -->
+ <text transform="rotate(-90 24 230)" x="24" y="230" fill="#4f5d75" font-size="7" font-family="'Geist Mono', monospace" letter-spacing="0.14em" text-anchor="middle">BUILD MINUTES PER WEEK</text>
+
+ <!-- No y-axis ticks: the form is about the shape of the envelope and the
+ layers inside it; per-pipeline totals are printed in the legend. -->
+ <path data-layer="Docs" data-values="8,9,7,6,0,0,5,7,8,8,9,9" d="M 80 297.5 C 93.3 298.1, 133.3 299.4, 160 301.2 C 186.7 303, 213.3 305.9, 240 308.1 C 266.7 310.3, 293.3 311.3, 320 314.4 C 346.7 317.5, 373.3 323, 400 326.9 C 426.7 330.8, 453.3 334.9, 480 337.5 C 506.7 340.1, 533.3 339.7, 560 342.5 C 586.7 345.3, 613.3 350.8, 640 354.4 C 666.7 358, 693.3 361.4, 720 364.4 C 746.7 367.4, 773.3 369.4, 800 372.5 C 826.7 375.6, 853.3 379.8, 880 383.1 C 906.7 386.4, 946.7 390.9, 960 392.5 L 960 403.8 C 946.7 402.2, 906.7 397.9, 880 394.4 C 853.3 390.8, 826.7 385.8, 800 382.5 C 773.3 379.2, 746.7 377.6, 720 374.4 C 693.3 371.2, 666.7 367.4, 640 363.1 C 613.3 358.8, 586.7 353.1, 560 348.8 C 533.3 344.5, 506.7 341.1, 480 337.5 C 453.3 333.9, 426.7 329.5, 400 326.9 C 373.3 324.3, 346.7 323.6, 320 321.9 C 293.3 320.2, 266.7 318.5, 240 316.9 C 213.3 315.3, 186.7 314.1, 160 312.5 C 133.3 310.9, 93.3 308.3, 80 307.5 Z" fill="rgba(45,49,66,0.30)" stroke="#f5f5f5" stroke-width="1"/>
+ <path data-layer="Integration" data-values="34,36,38,42,44,47,49,52,54,56,59,61" d="M 80 255 C 93.3 255.2, 133.3 255.3, 160 256.2 C 186.7 257.1, 213.3 259.7, 240 260.6 C 266.7 261.6, 293.3 260, 320 261.9 C 346.7 263.8, 373.3 269.1, 400 271.9 C 426.7 274.7, 453.3 277.2, 480 278.8 C 506.7 280.4, 533.3 279.4, 560 281.2 C 586.7 283, 613.3 286.8, 640 289.4 C 666.7 292, 693.3 294.7, 720 296.9 C 746.7 299.1, 773.3 300.4, 800 302.5 C 826.7 304.6, 853.3 307.1, 880 309.4 C 906.7 311.7, 946.7 315.1, 960 316.2 L 960 392.5 C 946.7 390.9, 906.7 386.4, 880 383.1 C 853.3 379.8, 826.7 375.6, 800 372.5 C 773.3 369.4, 746.7 367.4, 720 364.4 C 693.3 361.4, 666.7 358, 640 354.4 C 613.3 350.8, 586.7 345.3, 560 342.5 C 533.3 339.7, 506.7 340.1, 480 337.5 C 453.3 334.9, 426.7 330.8, 400 326.9 C 373.3 323, 346.7 317.5, 320 314.4 C 293.3 311.3, 266.7 310.3, 240 308.1 C 213.3 305.9, 186.7 303, 160 301.2 C 133.3 299.4, 93.3 298.1, 80 297.5 Z" fill="rgba(45,49,66,0.62)" stroke="#f5f5f5" stroke-width="1"/>
+ <path data-layer="Unit" data-values="58,60,62,61,64,66,65,68,70,69,72,74" d="M 80 182.5 C 93.3 182.3, 133.3 181.1, 160 181.2 C 186.7 181.3, 213.3 182.4, 240 183.1 C 266.7 183.8, 293.3 184.1, 320 185.6 C 346.7 187.1, 373.3 190.1, 400 191.9 C 426.7 193.7, 453.3 194.8, 480 196.2 C 506.7 197.5, 533.3 198.6, 560 200 C 586.7 201.4, 613.3 202.8, 640 204.4 C 666.7 206, 693.3 207.4, 720 209.4 C 746.7 211.4, 773.3 214.5, 800 216.2 C 826.7 217.9, 853.3 218.1, 880 219.4 C 906.7 220.7, 946.7 223.1, 960 223.8 L 960 316.2 C 946.7 315.1, 906.7 311.7, 880 309.4 C 853.3 307.1, 826.7 304.6, 800 302.5 C 773.3 300.4, 746.7 299.1, 720 296.9 C 693.3 294.7, 666.7 292, 640 289.4 C 613.3 286.8, 586.7 283, 560 281.2 C 533.3 279.4, 506.7 280.4, 480 278.8 C 453.3 277.2, 426.7 274.7, 400 271.9 C 373.3 269.1, 346.7 263.8, 320 261.9 C 293.3 260, 266.7 261.6, 240 260.6 C 213.3 259.7, 186.7 257.1, 160 256.2 C 133.3 255.3, 93.3 255.2, 80 255 Z" fill="rgba(45,49,66,0.78)" stroke="#f5f5f5" stroke-width="1"/>
+ <!-- End-to-end FOCAL: the accent marks the editorially focal layer --
+ the pipeline whose growth is the story -- and it is also the one
+ eating the budget. Every other layer rides the ink-opacity ramp,
+ strongest tone on the largest pipeline. -->
+ <path data-layer="End-to-end" data-values="12,15,19,26,34,45,58,72,85,96,108,118" d="M 80 167.5 C 93.3 166.7, 133.3 163.8, 160 162.5 C 186.7 161.2, 213.3 161, 240 159.4 C 266.7 157.8, 293.3 154.8, 320 153.1 C 346.7 151.4, 373.3 151.6, 400 149.4 C 426.7 147.2, 453.3 143.7, 480 140 C 506.7 136.3, 533.3 131.8, 560 127.5 C 586.7 123.2, 613.3 118.5, 640 114.4 C 666.7 110.3, 693.3 106.1, 720 103.1 C 746.7 100.1, 773.3 99.3, 800 96.2 C 826.7 93.1, 853.3 87.7, 880 84.4 C 906.7 81.1, 946.7 77.6, 960 76.2 L 960 223.8 C 946.7 223.1, 906.7 220.7, 880 219.4 C 853.3 218.1, 826.7 217.9, 800 216.2 C 773.3 214.5, 746.7 211.4, 720 209.4 C 693.3 207.4, 666.7 206, 640 204.4 C 613.3 202.8, 586.7 201.4, 560 200 C 533.3 198.6, 506.7 197.5, 480 196.2 C 453.3 194.8, 426.7 193.7, 400 191.9 C 373.3 190.1, 346.7 187.1, 320 185.6 C 293.3 184.1, 266.7 183.8, 240 183.1 C 213.3 182.4, 186.7 181.3, 160 181.2 C 133.3 181.1, 93.3 182.3, 80 182.5 Z" fill="#eb6c36" stroke="#f5f5f5" stroke-width="1"/>
+ <path data-layer="Lint" data-values="12,12,13,12,13,14,13,14,14,15,15,16" d="M 80 152.5 C 93.3 151.7, 133.3 149.1, 160 147.5 C 186.7 145.9, 213.3 144.7, 240 143.1 C 266.7 141.5, 293.3 139.8, 320 138.1 C 346.7 136.4, 373.3 135.7, 400 133.1 C 426.7 130.5, 453.3 126.2, 480 122.5 C 506.7 118.8, 533.3 115.5, 560 111.2 C 586.7 106.9, 613.3 101.2, 640 96.9 C 666.7 92.6, 693.3 88.8, 720 85.6 C 746.7 82.4, 773.3 80.8, 800 77.5 C 826.7 74.2, 853.3 69.1, 880 65.6 C 906.7 62, 946.7 57.8, 960 56.2 L 960 76.2 C 946.7 77.6, 906.7 81.1, 880 84.4 C 853.3 87.7, 826.7 93.1, 800 96.2 C 773.3 99.3, 746.7 100.1, 720 103.1 C 693.3 106.1, 666.7 110.3, 640 114.4 C 613.3 118.5, 586.7 123.2, 560 127.5 C 533.3 131.8, 506.7 136.3, 480 140 C 453.3 143.7, 426.7 147.2, 400 149.4 C 373.3 151.6, 346.7 151.4, 320 153.1 C 293.3 154.8, 266.7 157.8, 240 159.4 C 213.3 161, 186.7 161.2, 160 162.5 C 133.3 163.8, 93.3 166.7, 80 167.5 Z" fill="rgba(45,49,66,0.46)" stroke="#f5f5f5" stroke-width="1"/>
+
+ <!-- One landmark, one hairline: the week the end-to-end suite becomes the
+ largest pipeline. Nothing else is annotated -- the shape is the story. -->
+ <line x1="640" y1="52" x2="640" y2="92" stroke="rgba(45,49,66,0.35)" stroke-width="1"/>
+ <text x="640" y="44" fill="#4f5d75" font-size="7" font-family="'Geist Mono', monospace" letter-spacing="0.14em" text-anchor="middle">END-TO-END PASSES UNIT</text>
+
+ <text data-period="W01" data-index="0" x="80" y="440" fill="#4f5d75" font-size="8" font-family="'Geist Mono', monospace" letter-spacing="0.08em" text-anchor="middle">W01</text>
+ <text data-period="W02" data-index="1" x="160" y="440" fill="#4f5d75" font-size="8" font-family="'Geist Mono', monospace" letter-spacing="0.08em" text-anchor="middle">W02</text>
+ <text data-period="W03" data-index="2" x="240" y="440" fill="#4f5d75" font-size="8" font-family="'Geist Mono', monospace" letter-spacing="0.08em" text-anchor="middle">W03</text>
+ <text data-period="W04" data-index="3" x="320" y="440" fill="#4f5d75" font-size="8" font-family="'Geist Mono', monospace" letter-spacing="0.08em" text-anchor="middle">W04</text>
+ <text data-period="W05" data-index="4" x="400" y="440" fill="#4f5d75" font-size="8" font-family="'Geist Mono', monospace" letter-spacing="0.08em" text-anchor="middle">W05</text>
+ <text data-period="W06" data-index="5" x="480" y="440" fill="#4f5d75" font-size="8" font-family="'Geist Mono', monospace" letter-spacing="0.08em" text-anchor="middle">W06</text>
+ <text data-period="W07" data-index="6" x="560" y="440" fill="#4f5d75" font-size="8" font-family="'Geist Mono', monospace" letter-spacing="0.08em" text-anchor="middle">W07</text>
+ <text data-period="W08" data-index="7" x="640" y="440" fill="#4f5d75" font-size="8" font-family="'Geist Mono', monospace" letter-spacing="0.08em" text-anchor="middle">W08</text>
+ <text data-period="W09" data-index="8" x="720" y="440" fill="#4f5d75" font-size="8" font-family="'Geist Mono', monospace" letter-spacing="0.08em" text-anchor="middle">W09</text>
+ <text data-period="W10" data-index="9" x="800" y="440" fill="#4f5d75" font-size="8" font-family="'Geist Mono', monospace" letter-spacing="0.08em" text-anchor="middle">W10</text>
+ <text data-period="W11" data-index="10" x="880" y="440" fill="#4f5d75" font-size="8" font-family="'Geist Mono', monospace" letter-spacing="0.08em" text-anchor="middle">W11</text>
+ <text data-period="W12" data-index="11" x="960" y="440" fill="#4f5d75" font-size="8" font-family="'Geist Mono', monospace" letter-spacing="0.08em" text-anchor="middle">W12</text>
+
+ <!-- Legend -->
+ <line x1="40" y1="462" x2="960" y2="462" stroke="rgba(45,49,66,0.10)" stroke-width="0.8"/>
+ <text x="40" y="478" fill="#4f5d75" font-size="8" font-family="'Geist Mono', monospace" letter-spacing="0.18em">LEGEND</text>
+ <text x="960" y="478" fill="#4f5d75" font-size="8" font-family="'Geist Mono', monospace" letter-spacing="0.06em" text-anchor="end">BUILD MINUTES PER WEEK BY PIPELINE · WEEKLY BUCKETS · SYMMETRIC BASELINE, ENVELOPE HEIGHT = WEEKLY TOTAL · ILLUSTRATIVE FIGURES, NOT A MEASURED PROJECT</text>
+
+ <rect x="40" y="488" width="16" height="8" fill="#eb6c36"/>
+ <text data-layer="End-to-end" data-total="688" x="64" y="496" fill="#4f5d75" font-size="8.5" font-family="'Geist', sans-serif">End-to-end · 688 min · focal</text>
+ <rect x="264" y="488" width="16" height="8" fill="rgba(45,49,66,0.78)"/>
+ <text data-layer="Unit" data-total="789" x="288" y="496" fill="#4f5d75" font-size="8.5" font-family="'Geist', sans-serif">Unit · 789 min</text>
+ <rect x="424" y="488" width="16" height="8" fill="rgba(45,49,66,0.62)"/>
+ <text data-layer="Integration" data-total="572" x="448" y="496" fill="#4f5d75" font-size="8.5" font-family="'Geist', sans-serif">Integration · 572 min</text>
+ <rect x="624" y="488" width="16" height="8" fill="rgba(45,49,66,0.46)"/>
+ <text data-layer="Lint" data-total="163" x="648" y="496" fill="#4f5d75" font-size="8.5" font-family="'Geist', sans-serif">Lint · 163 min</text>
+ <rect x="784" y="488" width="16" height="8" fill="rgba(45,49,66,0.30)"/>
+ <text data-layer="Docs" data-total="76" x="808" y="496" fill="#4f5d75" font-size="8.5" font-family="'Geist', sans-serif">Docs · 76 min · paused</text>
+ </svg>
+ </div>
+ <div class="cards">
+ <div class="card">
+ <p class="eyebrow">FOCAL · END-TO-END</p>
+ <div class="card-header"><span class="card-dot coral"></span><h3>The end-to-end suite is the growth</h3></div>
+ <p>12 minutes a week in week one, 118 in week twelve — it passes the unit suite in week eight and ends as the largest pipeline. Every other layer is roughly flat, so the widening of the whole stream is this one band widening.</p>
+ </div>
+ <div class="card">
+ <div class="card-header"><span class="card-dot ink-strong"></span><h3>The envelope is the total, by construction</h3></div>
+ <p>Each week is centred on one midline, top and bottom of the stream averaging back to it, so the stream's height is the week's total at 1.25px per minute. The smoothing bends only the drawing between weeks — every vertex sits on its true stacked value, which is what the verifier checks.</p>
+ </div>
+ <div class="card">
+ <div class="card-header"><span class="card-dot ink-light"></span><h3>The docs pinch is data, not a defect</h3></div>
+ <p>The docs pipeline ran nothing in weeks five and six, so its band pinches to zero thickness and reopens. The zero weeks stay in the domain — resampling or bridging them would erase the pause the layer exists to show.</p>
+ </div>
+ </div>
+ <div class="footer">
+ <span>build minutes per week by pipeline · weekly buckets · illustrative</span>
+ <span>example · diagram design</span>
+ </div>
+ </div>
+</body>
+</html>
diff --git a/skills/diagram-design/assets/example-streamgraph.html b/skills/diagram-design/assets/example-streamgraph.html
new file mode 100644
index 0000000..85368a9
--- /dev/null
+++ b/skills/diagram-design/assets/example-streamgraph.html
@@ -0,0 +1,99 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <meta charset="UTF-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
+ <title>Build minutes by pipeline, twelve weeks · Streamgraph</title>
+ <link href="https://fonts.googleapis.com/css2?family=Instrument+Serif:ital@0;1&family=Geist:wght@400;500;600&family=Geist+Mono:wght@400;500;600&display=swap" rel="stylesheet">
+ <style>
+ *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
+ :root {
+ --color-paper: #f5f5f5;
+ --color-ink: #2d3142;
+ --color-muted: #4f5d75;
+ --color-accent: #eb6c36;
+ --font-sans: 'Geist', system-ui, sans-serif;
+ --font-serif: 'Instrument Serif', serif;
+ --font-mono: 'Geist Mono', ui-monospace, monospace;
+ }
+ body { font-family: var(--font-sans); background: var(--color-paper); color: var(--color-ink); min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 3rem 2rem; }
+ .frame { max-width: 1200px; width: 100%; }
+ .eyebrow { font-family: var(--font-mono); font-size: 0.66rem; font-weight: 500; letter-spacing: 0.18em; text-transform: uppercase; color: var(--color-muted); margin-bottom: 0.5rem; }
+ h1 { font-family: var(--font-serif); font-size: clamp(1.5rem, 2.4vw + 0.75rem, 2rem); font-weight: 400; letter-spacing: -0.02em; line-height: 1.15; margin-bottom: 1.5rem; }
+ svg { width: 100%; min-width: 760px; display: block; }
+ </style>
+</head>
+<body>
+ <div class="frame">
+ <p class="eyebrow">Streamgraph · Diagram Design</p>
+ <h1>Where the extra build minutes went</h1>
+
+ <svg viewBox="0 0 1000 500" xmlns="http://www.w3.org/2000/svg" role="img" aria-labelledby="streamgraph-title streamgraph-desc">
+ <title id="streamgraph-title">Where the extra build minutes went</title>
+ <desc id="streamgraph-desc">Streamgraph of weekly CI build minutes by pipeline across twelve weeks, stacked on a symmetric baseline so the envelope height reads as the total; the end-to-end suite grows from 12 to 118 minutes a week and passes the unit suite in week eight, while the docs pipeline pauses to zero in weeks five and six.</desc>
+ <defs>
+ <pattern id="dots" width="22" height="22" patternUnits="userSpaceOnUse">
+ <circle cx="1" cy="1" r="0.9" fill="rgba(45,49,66,0.10)"/>
+ </pattern>
+ </defs>
+
+ <rect width="100%" height="100%" fill="#f5f5f5"/>
+ <rect width="100%" height="100%" fill="url(#dots)" opacity="0.55"/>
+
+ <!-- Symmetric baseline: every period is centred on y=230, so the top and
+ bottom of the envelope always average to the midline and the envelope
+ height IS the weekly total at 1.25px per minute. Boundaries are
+ Catmull-Rom smoothed (control points at 1/6 chord) with every vertex
+ on its true stacked value; scripts/verify-streamgraph.py enforces
+ both against the values each layer declares. -->
+ <text transform="rotate(-90 24 230)" x="24" y="230" fill="#4f5d75" font-size="7" font-family="'Geist Mono', monospace" letter-spacing="0.14em" text-anchor="middle">BUILD MINUTES PER WEEK</text>
+
+ <!-- No y-axis ticks: the form is about the shape of the envelope and the
+ layers inside it; per-pipeline totals are printed in the legend. -->
+ <path data-layer="Docs" data-values="8,9,7,6,0,0,5,7,8,8,9,9" d="M 80 297.5 C 93.3 298.1, 133.3 299.4, 160 301.2 C 186.7 303, 213.3 305.9, 240 308.1 C 266.7 310.3, 293.3 311.3, 320 314.4 C 346.7 317.5, 373.3 323, 400 326.9 C 426.7 330.8, 453.3 334.9, 480 337.5 C 506.7 340.1, 533.3 339.7, 560 342.5 C 586.7 345.3, 613.3 350.8, 640 354.4 C 666.7 358, 693.3 361.4, 720 364.4 C 746.7 367.4, 773.3 369.4, 800 372.5 C 826.7 375.6, 853.3 379.8, 880 383.1 C 906.7 386.4, 946.7 390.9, 960 392.5 L 960 403.8 C 946.7 402.2, 906.7 397.9, 880 394.4 C 853.3 390.8, 826.7 385.8, 800 382.5 C 773.3 379.2, 746.7 377.6, 720 374.4 C 693.3 371.2, 666.7 367.4, 640 363.1 C 613.3 358.8, 586.7 353.1, 560 348.8 C 533.3 344.5, 506.7 341.1, 480 337.5 C 453.3 333.9, 426.7 329.5, 400 326.9 C 373.3 324.3, 346.7 323.6, 320 321.9 C 293.3 320.2, 266.7 318.5, 240 316.9 C 213.3 315.3, 186.7 314.1, 160 312.5 C 133.3 310.9, 93.3 308.3, 80 307.5 Z" fill="rgba(45,49,66,0.30)" stroke="#f5f5f5" stroke-width="1"/>
+ <path data-layer="Integration" data-values="34,36,38,42,44,47,49,52,54,56,59,61" d="M 80 255 C 93.3 255.2, 133.3 255.3, 160 256.2 C 186.7 257.1, 213.3 259.7, 240 260.6 C 266.7 261.6, 293.3 260, 320 261.9 C 346.7 263.8, 373.3 269.1, 400 271.9 C 426.7 274.7, 453.3 277.2, 480 278.8 C 506.7 280.4, 533.3 279.4, 560 281.2 C 586.7 283, 613.3 286.8, 640 289.4 C 666.7 292, 693.3 294.7, 720 296.9 C 746.7 299.1, 773.3 300.4, 800 302.5 C 826.7 304.6, 853.3 307.1, 880 309.4 C 906.7 311.7, 946.7 315.1, 960 316.2 L 960 392.5 C 946.7 390.9, 906.7 386.4, 880 383.1 C 853.3 379.8, 826.7 375.6, 800 372.5 C 773.3 369.4, 746.7 367.4, 720 364.4 C 693.3 361.4, 666.7 358, 640 354.4 C 613.3 350.8, 586.7 345.3, 560 342.5 C 533.3 339.7, 506.7 340.1, 480 337.5 C 453.3 334.9, 426.7 330.8, 400 326.9 C 373.3 323, 346.7 317.5, 320 314.4 C 293.3 311.3, 266.7 310.3, 240 308.1 C 213.3 305.9, 186.7 303, 160 301.2 C 133.3 299.4, 93.3 298.1, 80 297.5 Z" fill="rgba(45,49,66,0.62)" stroke="#f5f5f5" stroke-width="1"/>
+ <path data-layer="Unit" data-values="58,60,62,61,64,66,65,68,70,69,72,74" d="M 80 182.5 C 93.3 182.3, 133.3 181.1, 160 181.2 C 186.7 181.3, 213.3 182.4, 240 183.1 C 266.7 183.8, 293.3 184.1, 320 185.6 C 346.7 187.1, 373.3 190.1, 400 191.9 C 426.7 193.7, 453.3 194.8, 480 196.2 C 506.7 197.5, 533.3 198.6, 560 200 C 586.7 201.4, 613.3 202.8, 640 204.4 C 666.7 206, 693.3 207.4, 720 209.4 C 746.7 211.4, 773.3 214.5, 800 216.2 C 826.7 217.9, 853.3 218.1, 880 219.4 C 906.7 220.7, 946.7 223.1, 960 223.8 L 960 316.2 C 946.7 315.1, 906.7 311.7, 880 309.4 C 853.3 307.1, 826.7 304.6, 800 302.5 C 773.3 300.4, 746.7 299.1, 720 296.9 C 693.3 294.7, 666.7 292, 640 289.4 C 613.3 286.8, 586.7 283, 560 281.2 C 533.3 279.4, 506.7 280.4, 480 278.8 C 453.3 277.2, 426.7 274.7, 400 271.9 C 373.3 269.1, 346.7 263.8, 320 261.9 C 293.3 260, 266.7 261.6, 240 260.6 C 213.3 259.7, 186.7 257.1, 160 256.2 C 133.3 255.3, 93.3 255.2, 80 255 Z" fill="rgba(45,49,66,0.78)" stroke="#f5f5f5" stroke-width="1"/>
+ <!-- End-to-end FOCAL: the accent marks the editorially focal layer --
+ the pipeline whose growth is the story -- and it is also the one
+ eating the budget. Every other layer rides the ink-opacity ramp,
+ strongest tone on the largest pipeline. -->
+ <path data-layer="End-to-end" data-values="12,15,19,26,34,45,58,72,85,96,108,118" d="M 80 167.5 C 93.3 166.7, 133.3 163.8, 160 162.5 C 186.7 161.2, 213.3 161, 240 159.4 C 266.7 157.8, 293.3 154.8, 320 153.1 C 346.7 151.4, 373.3 151.6, 400 149.4 C 426.7 147.2, 453.3 143.7, 480 140 C 506.7 136.3, 533.3 131.8, 560 127.5 C 586.7 123.2, 613.3 118.5, 640 114.4 C 666.7 110.3, 693.3 106.1, 720 103.1 C 746.7 100.1, 773.3 99.3, 800 96.2 C 826.7 93.1, 853.3 87.7, 880 84.4 C 906.7 81.1, 946.7 77.6, 960 76.2 L 960 223.8 C 946.7 223.1, 906.7 220.7, 880 219.4 C 853.3 218.1, 826.7 217.9, 800 216.2 C 773.3 214.5, 746.7 211.4, 720 209.4 C 693.3 207.4, 666.7 206, 640 204.4 C 613.3 202.8, 586.7 201.4, 560 200 C 533.3 198.6, 506.7 197.5, 480 196.2 C 453.3 194.8, 426.7 193.7, 400 191.9 C 373.3 190.1, 346.7 187.1, 320 185.6 C 293.3 184.1, 266.7 183.8, 240 183.1 C 213.3 182.4, 186.7 181.3, 160 181.2 C 133.3 181.1, 93.3 182.3, 80 182.5 Z" fill="#eb6c36" stroke="#f5f5f5" stroke-width="1"/>
+ <path data-layer="Lint" data-values="12,12,13,12,13,14,13,14,14,15,15,16" d="M 80 152.5 C 93.3 151.7, 133.3 149.1, 160 147.5 C 186.7 145.9, 213.3 144.7, 240 143.1 C 266.7 141.5, 293.3 139.8, 320 138.1 C 346.7 136.4, 373.3 135.7, 400 133.1 C 426.7 130.5, 453.3 126.2, 480 122.5 C 506.7 118.8, 533.3 115.5, 560 111.2 C 586.7 106.9, 613.3 101.2, 640 96.9 C 666.7 92.6, 693.3 88.8, 720 85.6 C 746.7 82.4, 773.3 80.8, 800 77.5 C 826.7 74.2, 853.3 69.1, 880 65.6 C 906.7 62, 946.7 57.8, 960 56.2 L 960 76.2 C 946.7 77.6, 906.7 81.1, 880 84.4 C 853.3 87.7, 826.7 93.1, 800 96.2 C 773.3 99.3, 746.7 100.1, 720 103.1 C 693.3 106.1, 666.7 110.3, 640 114.4 C 613.3 118.5, 586.7 123.2, 560 127.5 C 533.3 131.8, 506.7 136.3, 480 140 C 453.3 143.7, 426.7 147.2, 400 149.4 C 373.3 151.6, 346.7 151.4, 320 153.1 C 293.3 154.8, 266.7 157.8, 240 159.4 C 213.3 161, 186.7 161.2, 160 162.5 C 133.3 163.8, 93.3 166.7, 80 167.5 Z" fill="rgba(45,49,66,0.46)" stroke="#f5f5f5" stroke-width="1"/>
+
+ <!-- One landmark, one hairline: the week the end-to-end suite becomes the
+ largest pipeline. Nothing else is annotated -- the shape is the story. -->
+ <line x1="640" y1="52" x2="640" y2="92" stroke="rgba(45,49,66,0.35)" stroke-width="1"/>
+ <text x="640" y="44" fill="#4f5d75" font-size="7" font-family="'Geist Mono', monospace" letter-spacing="0.14em" text-anchor="middle">END-TO-END PASSES UNIT</text>
+
+ <text data-period="W01" data-index="0" x="80" y="440" fill="#4f5d75" font-size="8" font-family="'Geist Mono', monospace" letter-spacing="0.08em" text-anchor="middle">W01</text>
+ <text data-period="W02" data-index="1" x="160" y="440" fill="#4f5d75" font-size="8" font-family="'Geist Mono', monospace" letter-spacing="0.08em" text-anchor="middle">W02</text>
+ <text data-period="W03" data-index="2" x="240" y="440" fill="#4f5d75" font-size="8" font-family="'Geist Mono', monospace" letter-spacing="0.08em" text-anchor="middle">W03</text>
+ <text data-period="W04" data-index="3" x="320" y="440" fill="#4f5d75" font-size="8" font-family="'Geist Mono', monospace" letter-spacing="0.08em" text-anchor="middle">W04</text>
+ <text data-period="W05" data-index="4" x="400" y="440" fill="#4f5d75" font-size="8" font-family="'Geist Mono', monospace" letter-spacing="0.08em" text-anchor="middle">W05</text>
+ <text data-period="W06" data-index="5" x="480" y="440" fill="#4f5d75" font-size="8" font-family="'Geist Mono', monospace" letter-spacing="0.08em" text-anchor="middle">W06</text>
+ <text data-period="W07" data-index="6" x="560" y="440" fill="#4f5d75" font-size="8" font-family="'Geist Mono', monospace" letter-spacing="0.08em" text-anchor="middle">W07</text>
+ <text data-period="W08" data-index="7" x="640" y="440" fill="#4f5d75" font-size="8" font-family="'Geist Mono', monospace" letter-spacing="0.08em" text-anchor="middle">W08</text>
+ <text data-period="W09" data-index="8" x="720" y="440" fill="#4f5d75" font-size="8" font-family="'Geist Mono', monospace" letter-spacing="0.08em" text-anchor="middle">W09</text>
+ <text data-period="W10" data-index="9" x="800" y="440" fill="#4f5d75" font-size="8" font-family="'Geist Mono', monospace" letter-spacing="0.08em" text-anchor="middle">W10</text>
+ <text data-period="W11" data-index="10" x="880" y="440" fill="#4f5d75" font-size="8" font-family="'Geist Mono', monospace" letter-spacing="0.08em" text-anchor="middle">W11</text>
+ <text data-period="W12" data-index="11" x="960" y="440" fill="#4f5d75" font-size="8" font-family="'Geist Mono', monospace" letter-spacing="0.08em" text-anchor="middle">W12</text>
+
+ <!-- Legend -->
+ <line x1="40" y1="462" x2="960" y2="462" stroke="rgba(45,49,66,0.10)" stroke-width="0.8"/>
+ <text x="40" y="478" fill="#4f5d75" font-size="8" font-family="'Geist Mono', monospace" letter-spacing="0.18em">LEGEND</text>
+ <text x="960" y="478" fill="#4f5d75" font-size="8" font-family="'Geist Mono', monospace" letter-spacing="0.06em" text-anchor="end">BUILD MINUTES PER WEEK BY PIPELINE · WEEKLY BUCKETS · SYMMETRIC BASELINE, ENVELOPE HEIGHT = WEEKLY TOTAL · ILLUSTRATIVE FIGURES, NOT A MEASURED PROJECT</text>
+
+ <rect x="40" y="488" width="16" height="8" fill="#eb6c36"/>
+ <text data-layer="End-to-end" data-total="688" x="64" y="496" fill="#4f5d75" font-size="8.5" font-family="'Geist', sans-serif">End-to-end · 688 min · focal</text>
+ <rect x="264" y="488" width="16" height="8" fill="rgba(45,49,66,0.78)"/>
+ <text data-layer="Unit" data-total="789" x="288" y="496" fill="#4f5d75" font-size="8.5" font-family="'Geist', sans-serif">Unit · 789 min</text>
+ <rect x="424" y="488" width="16" height="8" fill="rgba(45,49,66,0.62)"/>
+ <text data-layer="Integration" data-total="572" x="448" y="496" fill="#4f5d75" font-size="8.5" font-family="'Geist', sans-serif">Integration · 572 min</text>
+ <rect x="624" y="488" width="16" height="8" fill="rgba(45,49,66,0.46)"/>
+ <text data-layer="Lint" data-total="163" x="648" y="496" fill="#4f5d75" font-size="8.5" font-family="'Geist', sans-serif">Lint · 163 min</text>
+ <rect x="784" y="488" width="16" height="8" fill="rgba(45,49,66,0.30)"/>
+ <text data-layer="Docs" data-total="76" x="808" y="496" fill="#4f5d75" font-size="8.5" font-family="'Geist', sans-serif">Docs · 76 min · paused</text>
+ </svg>
+ </div>
+</body>
+</html>
diff --git a/skills/diagram-design/assets/index.html b/skills/diagram-design/assets/index.html
index f08804c..b670b85 100644
--- a/skills/diagram-design/assets/index.html
+++ b/skills/diagram-design/assets/index.html
@@ -316,6 +316,9 @@
<button class="tab new" data-type="ridgeline" data-parent-type="line">
<span class="eyebrow">21</span>Line · ridgeline
</button>
+ <button class="tab new" data-type="streamgraph" data-parent-type="line">
+ <span class="eyebrow">21</span>Line · streamgraph
+ </button>
<button class="tab new" data-type="bump" data-parent-type="line">
<span class="eyebrow">21</span>Line · bump
</button>
diff --git a/skills/diagram-design/references/type-line.md b/skills/diagram-design/references/type-line.md
index f0b287b..810707c 100644
--- a/skills/diagram-design/references/type-line.md
+++ b/skills/diagram-design/references/type-line.md
@@ -41,6 +41,7 @@
- **Slopegraph:** exactly two states, several series, read as slope and rank change. Full spec below.
- **Ridgeline:** one distribution per series, stacked with deliberate overlap on one shared amplitude. Full spec below.
+- **Streamgraph:** many periods, few layers, read as a total and its composition breathing. Full spec below.
- **Bump chart:** rank movement across 3–6 ordered snapshots, position only. Full spec below.
### Slopegraph
@@ -203,6 +204,76 @@ The binding contract is the slopegraph's, applied to areas: the outline declares
- A legend that says "darker is faster", which is false on one of the two skins.
- Fewer than 3 ridges (that is a histogram or a pair of small multiples) or more than 12.
- Reading traffic off ridge height, or shipping a figure whose source line lets a reader do so.
+### Streamgraph
+
+**Best for:** how a total and its composition breathe across many periods — build minutes by pipeline, traffic by service, error budget by subsystem. The symmetric baseline makes the envelope the hero: the stream's height at any period *is* the total, and each layer keeps its share inside it. No other line form gives both at once — a plain multi-series line loses the total, a 100%-stacked area loses it on purpose.
+
+Not for: exact per-period values (the reader gets shape, not numbers — use a **bar chart** or print a table); two or three periods (that is the parent line chart, or a **slopegraph**); a single series (the parent chart's area fill already does this against a zero baseline); or ranking stories (a bump chart reads rank, a stream reads volume).
+
+#### Layout conventions
+
+- **Period columns** evenly spaced across the plot, `x` 80 → 960 inside the `0 0 1000 500` viewBox — the parent chart's margins. The shipped example runs 12 weekly columns at 80px pitch. Budget: **3–24 periods, 2–6 layers**. Below 3 periods there is no flow to show; above 6 layers the ramp runs out of distinguishable tones.
+- **Symmetric baseline at `y=230`**, the vertical middle of the 40 → 420 plot. Each period's stack is centred on it: envelope top and bottom always average back to the midline, so the silhouette is the total mirrored about a constant axis. The baseline is a *derived* line, not a drawn one — do not paint it.
+- **One shared linear scale** for every layer at every period. The shipped example uses 1.25px per build-minute; state the scale or the bucket size in the source line so the reader can calibrate the envelope.
+- **Boundaries are Catmull-Rom smoothed, control points at 1/6 chord, vertices on true values.** Smoothing bends only the *drawing between* periods; every on-curve vertex sits exactly where the stacked value puts it, which is what lets `scripts/verify-streamgraph.py` read the geometry back. Between-vertex overshoot near a sharp change is the honest cost of smoothing — never move a vertex to tame it.
+- **Stack order is fixed for the whole figure, largest totals innermost** — the two biggest layers hug the midline, smaller ones ride the outer edges where the curvature is. Order never changes per period.
+- **Layer boundaries get a 1px `paper` hairline** so adjacent tones separate where they run thin.
+- **Period captions** in Geist Mono 8px, centred under each column at `y=440`, tracked `0.08em`.
+- **No y-axis ticks and no gridlines.** The form is about the shape of the envelope; per-layer totals are printed in the legend, and a tick grid would invite reading precise values off a curve that cannot deliver them.
+- **Annotate at most one landmark period** — a short hairline above the envelope and a mono label, as the shipped example marks the week the focal layer becomes the largest. More than one and the shape stops being the hero.
+- **Legend keys are 16×8 rects** (area fills, like the parent chart), one entry per layer **with its total** — `Unit · 789 min`. The legend is where the numbers live. House rhythm as everywhere: rule at `y=462`, `LEGEND` at `478`, keys at `488` with text at `496`.
+- **4px grid** applies to the designed constants — columns, caption baselines, legend rows. Boundary `y` values are data-scaled and exempt.
+
+#### Colour
+
+- **One accent layer — the editorially focal series — and an `ink` opacity ramp for the rest**, never the series palette. Layers are named in the legend, so hue would re-encode what the labels already say. The shipped ramp runs 0.78 → 0.30, **strongest tone on the largest layer**; adjacent tones in the stack need at least ~0.15 of separation or the hairline is doing all the work.
+- Fills may run lighter than a line could: these are areas bounded by `paper` hairlines with no text on them, so the 3:1 stroke floor that binds the slopegraph ramp does not bind here. What does bind: every fill must still be `ink` at opacity (or `accent`), and no text ever sits on a layer.
+- **Legend wording must be skin-neutral** — "strongest tone", never "darkest". The ramp inverts on dark paper.
+- **Layer names must not contain digits.** The legend prints one number per entry (the total) and the checker refuses a label carrying two numeric tokens — `E2E` fails, `End-to-end` passes.
+
+#### Honest-data rule
+
+**The envelope is a claim about the total, and the layers are a claim about its parts.** Both are enforced by `scripts/verify-streamgraph.py` against the values each layer declares.
+
+- **Zero-sum baseline, stated.** Every period centres on one midline — baseline = −total/2, the classic silhouette. Say so in the source line. A baseline that drifts per period to minimise wiggle re-orders what the eye reads as growth; a baseline pinned to the bottom is a stacked area wearing a costume. Neither is this type.
+- **One scale, every layer, every period.** A layer drawn at its own scale makes its share a lie while the envelope stays plausible.
+- **Zero periods stay in the domain — the pinch IS data.** The shipped docs pipeline runs nothing in weeks five and six, so its band pinches to zero thickness and reopens. Never bridge, resample, or drop a zero to prettify the flow.
+- **No layer dropped silently.** Every drawn layer appears in the legend with its total, and every legend entry has a drawn layer. A stream that quietly loses a small series overstates every share that remains.
+- **State the bucket size** (weekly, daily, per release) in the source line. Resampling to a coarser bucket smooths the story; the reader deserves to know which story they got.
+- **Totals are sums, not typed numbers.** The legend total must equal the sum of the layer's declared per-period values — one number, three statements (values, geometry, print), zero chances to disagree.
+
+#### Declaring the values
+
+**Each layer's path declares its per-period values, and the drawn geometry must put every vertex where those values stack.** Same contract as the slopegraph: every meaningful visible string is bound to an attribute stating the same thing.
+
+```svg
+<!-- A layer: closed region, top boundary left-to-right, then bottom back.
+ Absolute M/C/L/Z only; on-curve vertices at every period column. -->
+<path data-layer="Docs" data-values="8,9,7,6,0,0,5,7,8,8,9,9"
+ d="M 80 297.5 C … L 960 403.8 C … Z"
+ fill="rgba(45,49,66,0.30)" stroke="#f5f5f5" stroke-width="1"/>
+
+<!-- Period captions: data-index places the column, data-period binds the text -->
+<text data-period="W05" data-index="4" x="400" y="440" fill="#4f5d75" font-size="8" font-family="'Geist Mono', monospace" letter-spacing="0.08em" text-anchor="middle">W05</text>
+
+<!-- Legend entries: data-total binds the printed per-layer total -->
+<text data-layer="Docs" data-total="76" x="808" y="496" fill="#4f5d75" font-size="8.5" font-family="'Geist', sans-serif">Docs · 76 min · paused</text>
+```
+
+What the checker holds against those bindings: every layer's on-curve vertices sit at the shared period columns; per-period thickness matches `data-values` on one shared scale; layers tile with no gap or overlap; the envelope stays centred on one midline; control points sit where Catmull-Rom at 1/6 chord puts them (so the curve between vertices is determined by the vertices, not free to editorialise); each legend entry names its own layer and no other, and its total matches both its printed text and the sum of the declared values; and each period caption sits on its own column reading exactly its `data-period`. Paths must use plain absolute `M`/`C`/`L`/`Z` — anything else is refused rather than half-parsed, and **no `transform`** may touch a layer path, a bound label, or an ancestor group, for the same reason as the slopegraph: the checker reads raw coordinates.
+
+#### Anti-patterns
+
+- A wiggle-minimised baseline that reorders layers per period — the legend stops meaning anything.
+- A bottom-pinned baseline presented as a streamgraph — that is a stacked area; the symmetric silhouette is the type.
+- One hue per layer instead of the ink ramp plus a single accent.
+- Y-axis ticks, or reading a precise value off a layer's thickness — totals live in the legend.
+- Bridging or dropping zero periods, or resampling to a bucket the source line does not state.
+- More than 6 layers (indistinguishable tones) or fewer than 3 periods (no flow to show).
+- Text on a layer fill, or a layer name carrying digits.
+- Moving a vertex off its true value to tame smoothing overshoot or open room for an annotation.
+- A `transform` on a layer path, a bound label, an ancestor group, or in CSS.
+- An unbound visible string: a period caption, a legend name or a legend total with no attribute stating the same thing. An entry printing one layer's name above another's `data-layer` satisfies every number in the figure and still hands the reader the wrong band.
### Bump chart
@@ -257,6 +328,9 @@ The binding contract is the slopegraph's, one level up: the path declares its ra
- `assets/example-ridgeline.html` — ridgeline, minimal light
- `assets/example-ridgeline-dark.html` — ridgeline, minimal dark
- `assets/example-ridgeline-full.html` — ridgeline, full editorial
+- `assets/example-streamgraph.html` — streamgraph, minimal light
+- `assets/example-streamgraph-dark.html` — streamgraph, minimal dark
+- `assets/example-streamgraph-full.html` — streamgraph, full editorial
- `assets/example-bump.html` — bump chart, minimal light
- `assets/example-bump-dark.html` — bump chart, minimal dark
- `assets/example-bump-full.html` — bump chart, full editorial