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(type): add architecture containment scopes (#403)
Matt Van Horna3af885602bf
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex 7d24209..54ec848 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -428,6 +428,16 @@ jobs:id: architecture_delta_testsrun: python scripts/test-verify-architecture-delta.py+ - name: Verify architecture containment scopes+ if: always()+ id: architecture_containment+ run: python scripts/verify-architecture-containment.py --all++ - name: Verify architecture containment checker+ if: always()+ id: architecture_containment_tests+ run: python scripts/test-verify-architecture-containment.py+- name: Verify exploded examples match their builderif: always()id: exploded_build@@ -590,6 +600,8 @@ jobs:echo "| Beeswarm Checker | ${{ steps.beeswarm_tests.outcome == 'success' && '✅ Passed' || (steps.beeswarm_tests.outcome == 'skipped' && '⏭️ Skipped' || '❌ Failed') }} |" >> $GITHUB_STEP_SUMMARYecho "| Architecture Delta Snapshots & Ledger | ${{ steps.architecture_delta.outcome == 'success' && '✅ Passed' || (steps.architecture_delta.outcome == 'skipped' && '⏭️ Skipped' || '❌ Failed') }} |" >> $GITHUB_STEP_SUMMARYecho "| Architecture Delta Checker | ${{ steps.architecture_delta_tests.outcome == 'success' && '✅ Passed' || (steps.architecture_delta_tests.outcome == 'skipped' && '⏭️ Skipped' || '❌ Failed') }} |" >> $GITHUB_STEP_SUMMARY+ echo "| Architecture Containment Scopes | ${{ steps.architecture_containment.outcome == 'success' && '✅ Passed' || (steps.architecture_containment.outcome == 'skipped' && '⏭️ Skipped' || '❌ Failed') }} |" >> $GITHUB_STEP_SUMMARY+ echo "| Architecture Containment Checker | ${{ steps.architecture_containment_tests.outcome == 'success' && '✅ Passed' || (steps.architecture_containment_tests.outcome == 'skipped' && '⏭️ Skipped' || '❌ Failed') }} |" >> $GITHUB_STEP_SUMMARYecho "| Exploded Examples Match Builder | ${{ steps.exploded_build.outcome == 'success' && '✅ Passed' || (steps.exploded_build.outcome == 'skipped' && '⏭️ Skipped' || '❌ Failed') }} |" >> $GITHUB_STEP_SUMMARYecho "| Exploded Axonometric Geometry | ${{ steps.exploded.outcome == 'success' && '✅ Passed' || (steps.exploded.outcome == 'skipped' && '⏭️ Skipped' || '❌ Failed') }} |" >> $GITHUB_STEP_SUMMARYecho "| Exploded Axonometric Checker | ${{ steps.exploded_tests.outcome == 'success' && '✅ Passed' || (steps.exploded_tests.outcome == 'skipped' && '⏭️ Skipped' || '❌ Failed') }} |" >> $GITHUB_STEP_SUMMARYdiff --git a/.maintainer-policy.json b/.maintainer-policy.jsonindex b26f9b9..5121d05 100644--- a/.maintainer-policy.json+++ b/.maintainer-policy.json@@ -76,6 +76,8 @@"python3 scripts/test-verify-geometry.py","python3 scripts/verify-architecture-delta.py --all","python3 scripts/test-verify-architecture-delta.py",+ "python3 scripts/verify-architecture-containment.py --all",+ "python3 scripts/test-verify-architecture-containment.py","python3 scripts/build-exploded-examples.py --check","python3 scripts/verify-exploded.py --all","python3 scripts/test-verify-exploded.py",diff --git a/CONTRIBUTING.md b/CONTRIBUTING.mdindex fb5440f..bf99da3 100644--- a/CONTRIBUTING.md+++ b/CONTRIBUTING.md@@ -67,6 +67,8 @@ Every validation gate below must pass before a PR is ready. They also run automa| Label geometry checker behaves (pass + adversarial cases) | `python3 scripts/test-verify-geometry.py` || Architecture delta snapshots preserve identity, ledger coverage, signatures, positions, and relationship endpoints | `python3 scripts/verify-architecture-delta.py --all` || Architecture delta checker behaves (pass + adversarial cases) | `python3 scripts/test-verify-architecture-delta.py` |+| Architecture containment IDs, parents, geometry, PaaS placement, and peerings | `python3 scripts/verify-architecture-containment.py --all` |+| Architecture containment checker behaves (pass + adversarial cases) | `python3 scripts/test-verify-architecture-containment.py` || Exploded examples are what the builder produces | `python3 scripts/build-exploded-examples.py --check` || Exploded axonometric silhouettes match their declared boxes, gaps are equal, and labels sit in one clear column | `python3 scripts/verify-exploded.py --all` || Exploded axonometric checker behaves (pass + adversarial cases) | `python3 scripts/test-verify-exploded.py` |@@ -169,6 +171,8 @@ python3 scripts/test-plugin-package.py \&& python3 scripts/test-verify-geometry.py \&& python3 scripts/verify-architecture-delta.py --all \&& python3 scripts/test-verify-architecture-delta.py \+ && python3 scripts/verify-architecture-containment.py --all \+ && python3 scripts/test-verify-architecture-containment.py \&& python3 scripts/build-exploded-examples.py --check \&& python3 scripts/verify-exploded.py --all \&& python3 scripts/test-verify-exploded.py \@@ -223,6 +227,7 @@ python3 scripts/test-plugin-package.py \- **`verify-skin-polarity.py`:** a legend key or caption names the ramp's direction by lightness (`darker is larger`) in a file whose ramp composites the other way. `ink` is a role, not a colour — it resolves near-black on light paper and near-white on dark — so one set of opacities runs darker as it strengthens in the light skin and lighter in the dark one. Name the direction by contrast against the paper (`stronger contrast is larger`), which survives the skin swap, and ship the same sentence in every variant; never invert the word for one file. The gate also fails closed on a claim it cannot substantiate — no resolvable paper colour, fewer than three rank-bearing ramp members, or a ramp that is not strictly ordered — and on wording it cannot parse: a tone word within six words of a magnitude word that no supported sentence form binds. Rephrase that as `<tone> <is|means|represents> <magnitude>` (`stronger contrast is larger`), because a claim the gate cannot read is a claim nothing checks.- **`verify-geometry.py`:** a label mask overlaps a node declared later in the document, so the node fill clips the label at render time. Move the label to a free segment of its connector — keep the 6–10px gap from the stroke required by SKILL.md §6, and do not shrink the mask to sneak under the check. It also fails an arrowed connector with a diagonal straight segment, a segment lying on a node's border, an endpoint within 8px of a node corner, a port closer to another on the same edge than rule 4 allows (12px, or 8px on an edge under 48px), a straight run stacked on another connector, or path data it cannot parse. Reroute the connector so it leaves each box perpendicular to the edge it starts on, from its own port; do not drop the marker or the node stroke to get past the check.- **`verify-architecture-delta.py`:** a stable ID, snapshot membership, status, signature, position, endpoint, or ledger target disagrees with the declared migration. Follow `type-architecture-delta.md`: record every changed object in the center ledger, retain unchanged positions on matching grids, and distinguish CHANGED, MOVED, and REWIRED by what actually differs. Fix the diagram and metadata together; never suppress the ledger entry to hide an unaccounted change.+- **`verify-architecture-containment.py`:** a nested Architecture figure with `data-grammar="architecture-containment"` has a duplicate ID, an unresolved or cyclic parent, a child drawn outside its declared parent, an admin band that is not a dashed rx=4 rectangle, a traffic box that is not a solid rx=8 rectangle, a managed PaaS box sitting inside a traffic scope, an endpoint that is not inside one, a peering that does not join two traffic scopes, mixed sibling axes, or off-grid bounds. Follow `type-architecture.md` Containment: keep administrative and traffic shapes distinct, put managed services in the admin band that owns them, and put only the private endpoint in the subnet.- **`verify-exploded.py`:** a part's silhouette is off the projection of the box it declares, a level sits at two heights, the gaps differ or fall under max(0.5 x top-face height, 3 x part thickness), a leader bends, starts off its part, or crosses another part, labels crowd or leave the column, or an animated lift disagrees with the geometry. Change the model in `scripts/build-exploded-examples.py` and rebuild; never nudge a drawn coordinate, and never shrink a gap to fit the canvas.- **`verify-axonometric-plan.py`:** a box's silhouette is off the projection of its declared footprint, a box stands outside the plate, floats above it, or shares floor with another, a box is painted after one in front of it, or a tag is off its plan point, stands on a room or roof it does not name, overlaps another tag, runs past two words, or is missing or doubled for a room or building. Change the plan in `scripts/build-axonometric-plan-examples.py` and rebuild; move a tag to open floor rather than shrinking it.- **`verify-block-registry.py`:** a Traceable block decomposition diagram (`semantic-patterns.md` § 8) has a duplicate `data-block-id`, a `data-block-parent` that doesn't resolve to another block's id in the same file, a blank `data-block-id`, a missing or blank `data-block-name`, or a cycle in the parent chain. Fix the diagram's attributes — the checker mirrors the source rather than validating semantics, so a passing file is only as correct as the IDs and parents actually authored on it.diff --git a/README.md b/README.mdindex f0ee83e..fbde28c 100644--- a/README.md+++ b/README.md@@ -300,6 +300,8 @@ The model already understood the content. What it was missing was taste, so I wrSeveral types have named variants that share their reference: Line covers slopegraph, ridgeline, streamgraph and bump; Scatter covers bubble and beeswarm; Treemap covers marimekko.+Architecture can nest administrative bands and traffic boxes in one snapshot when the hierarchy itself is the claim: dashed rx=4 bands for billing and permissions, solid rx=8 boxes for networks, and managed services outside every subnet. See the [containment example](skills/diagram-design/assets/example-architecture-containment.html) and [type-architecture.md](skills/diagram-design/references/type-architecture.md).+Architecture delta compares synchronized topologies through a Before · Changes · After ledger of added, removed, changed, moved, and rewired objects. See its [reference](skills/diagram-design/references/type-architecture-delta.md) and [order-fulfilment example](skills/diagram-design/assets/example-architecture-delta.html). Attribute-only comparisons remain tables; a single snapshot uses Architecture.Exploded axonometric draws one object in 2:1 dimetric projection with its parts lifted apart at equal gaps: a [phone teardown](skills/diagram-design/assets/example-exploded-phone.html), an [unboxing](skills/diagram-design/assets/example-exploded-unboxing.html), an [app stack](skills/diagram-design/assets/example-exploded.html), an [AI agent stack](skills/diagram-design/assets/example-exploded-ai-stack.html), or a [mechanical keyboard](skills/diagram-design/assets/example-exploded-keyboard.html). Every coordinate comes from one projection function, and the [animated phone](skills/diagram-design/assets/example-exploded-phone-animated.html) opens assembled and explodes once. See its [reference](skills/diagram-design/references/type-exploded.md).@@ -628,6 +630,7 @@ At startup, the agent sees only the skill name and description. When a request m|---|---|| "Make me a flowchart" | `SKILL.md` + `references/type-flowchart.md` || "Build an architecture diagram" | `SKILL.md` + `references/type-architecture.md` |+| "Show nested admin vs traffic scopes" | `SKILL.md` + `references/type-architecture.md` || "Show what was added, removed, changed, moved, or rewired in this migration" | `SKILL.md` + `references/type-architecture-delta.md` || "Show what's inside this device, exploded" | `SKILL.md` + `references/type-exploded.md` || "Draw our office floor plan" | `SKILL.md` + `references/type-axonometric-plan.md` |diff --git a/docs/pr-previews/architecture-containment/architecture-containment-dark.png b/docs/pr-previews/architecture-containment/architecture-containment-dark.pngnew file mode 100644index 0000000..82430a3Binary files /dev/null and b/docs/pr-previews/architecture-containment/architecture-containment-dark.png differdiff --git a/docs/pr-previews/architecture-containment/architecture-containment-full.png b/docs/pr-previews/architecture-containment/architecture-containment-full.pngnew file mode 100644index 0000000..d83043dBinary files /dev/null and b/docs/pr-previews/architecture-containment/architecture-containment-full.png differdiff --git a/docs/pr-previews/architecture-containment/architecture-containment-light.png b/docs/pr-previews/architecture-containment/architecture-containment-light.pngnew file mode 100644index 0000000..6070574Binary files /dev/null and b/docs/pr-previews/architecture-containment/architecture-containment-light.png differdiff --git a/scripts/test-verify-architecture-containment.py b/scripts/test-verify-architecture-containment.pynew file mode 100644index 0000000..8b9bdfb--- /dev/null+++ b/scripts/test-verify-architecture-containment.py@@ -0,0 +1,437 @@+#!/usr/bin/env python3+"""Adversarial and legal Architecture containment fixtures (ADR 0005).++Synthetic fixtures exercise the public contract independently of the shipped+layout; all three published variants and CLI discovery are checked as well.+Run: python3 scripts/test-verify-architecture-containment.py+"""++from __future__ import annotations++import importlib.util+import os+import subprocess+import sys+import tempfile+import unittest+from pathlib import Path++ROOT = Path(__file__).resolve().parent.parent+CHECKER = ROOT / "scripts/verify-architecture-containment.py"+SPEC = importlib.util.spec_from_file_location("architecture_containment_verifier", CHECKER)+checker = importlib.util.module_from_spec(SPEC)+sys.modules[SPEC.name] = checker+SPEC.loader.exec_module(checker)+++def scope(identity, kind, x, y, w, h, parent=None, rx=None, dashed=None):+ if rx is None:+ rx = 4 if kind == "admin" else 8+ if dashed is None:+ dashed = kind == "admin"+ parent_attr = f' data-parent="{parent}"' if parent else ""+ dash_attr = ' stroke-dasharray="4,4"' if dashed else ""+ return (f'<rect data-role="bounds" data-scope-id="{identity}" data-scope-kind="{kind}"'+ f'{parent_attr} x="{x}" y="{y}" width="{w}" height="{h}" rx="{rx}"'+ f' fill="none" stroke="#000"{dash_attr}/>')+++def node(identity, kind, x, y, parent, target=None, size=40):+ target_attr = f' data-target="{target}"' if target else ""+ return (f'<g data-node-id="{identity}" data-kind="{kind}" data-parent="{parent}"{target_attr}>'+ f'<rect data-role="bounds" x="{x}" y="{y}" width="{size}" height="{size}"/>'+ f'<text>{identity}</text></g>')+++def fixture():+ parts = [+ '<html><head><style>svg {width:100%;height:auto} body {margin:0}</style></head><body>',+ '<svg data-grammar="architecture-containment" viewBox="0 0 400 280">',+ scope("subscription", "admin", 16, 16, 368, 248),+ scope("rg", "admin", 24, 24, 352, 232, parent="subscription"),+ scope("hub", "traffic", 32, 88, 160, 144, parent="rg"),+ scope("spoke", "traffic", 208, 88, 160, 144, parent="rg"),+ node("sql", "managed", 32, 36, "rg"),+ node("app", "compute", 56, 144, "hub"),+ node("pe", "endpoint", 232, 144, "spoke", target="sql"),+ '<line data-peering="hub-spoke" data-from="hub" data-to="spoke" x1="192" y1="112" x2="208" y2="112"/>',+ "</svg></body></html>",+ ]+ return "\n".join(parts)+++GOOD = fixture()+SYNTHETIC_PATH = Path("synthetic-architecture-containment.html")+++class ContractTests(unittest.TestCase):+ def clean(self, source):+ self.assertEqual(checker.check_source(SYNTHETIC_PATH, source), [])++ def rejects(self, source, reason):+ self.assertNotEqual(source, GOOD, "fixture mutation did not apply")+ findings = checker.check_source(SYNTHETIC_PATH, source)+ self.assertTrue(findings, "invalid diagram accepted")+ self.assertIn(reason, "\n".join(findings))++ def test_synthetic_is_clean(self):+ self.clean(GOOD)++ def test_files_without_grammar_are_skipped(self):+ source = GOOD.replace('data-grammar="architecture-containment"', "")+ self.assertEqual(checker.check_source(SYNTHETIC_PATH, source), [])+ self.assertFalse(checker.looks_like_containment(source))++ def test_comments_entities_and_unquoted_attributes(self):+ source = GOOD.replace("</svg>", "<!-- <rect data-scope-id=\"bogus\"/> --></svg>")+ source = source.replace("<text>sql</text>", "<text>sql>db</text>")+ source = source.replace('data-scope-kind="admin"', "DATA-SCOPE-KIND=admin")+ self.clean(source)++ def test_duplicate_scope_id(self):+ self.rejects(GOOD.replace('data-scope-id="hub"', 'data-scope-id="spoke"', 1), "duplicate ID")++ def test_duplicate_node_id(self):+ self.rejects(GOOD.replace('data-node-id="app"', 'data-node-id="sql"', 1), "duplicate ID")++ def test_scope_and_node_share_one_namespace(self):+ self.rejects(GOOD.replace('data-node-id="app"', 'data-node-id="hub"', 1), "duplicate ID")++ def test_unresolved_parent(self):+ self.rejects(GOOD.replace('data-parent="rg"', 'data-parent="missing"', 1), "does not match any data-scope-id")++ def test_blank_parent_on_nested_scope(self):+ self.rejects(GOOD.replace('data-parent="subscription"', 'data-parent=""', 1), "data-parent")++ def test_parent_cycle(self):+ source = GOOD.replace(+ 'data-scope-id="subscription"',+ 'data-scope-id="subscription" data-parent="rg"',+ 1,+ )+ self.rejects(source, "parent cycle")++ def test_child_outside_parent(self):+ self.rejects(GOOD.replace('x="32" y="88" width="160" height="144"', 'x="0" y="88" width="160" height="144"', 1), "not geometrically inside parent")++ def test_admin_must_be_dashed_rx4_band(self):+ self.rejects(GOOD.replace('rx="4"', 'rx="8"', 1), "admin band must use rx=4")+ self.rejects(GOOD.replace(' stroke-dasharray="4,4"', "", 1), "admin band must use a dashed stroke")+ tall = GOOD.replace(+ 'data-scope-id="subscription" data-scope-kind="admin" x="16" y="16" width="368" height="248"',+ 'data-scope-id="subscription" data-scope-kind="admin" x="16" y="16" width="120" height="248"',+ 1,+ )+ self.rejects(tall, "admin band must be a horizontal rectangle")++ def test_traffic_must_be_solid_rx8_box(self):+ self.rejects(GOOD.replace('rx="8"', 'rx="4"', 1), "traffic box must use rx=8")+ dashed = GOOD.replace(+ 'data-scope-id="hub" data-scope-kind="traffic" data-parent="rg" x="32" y="88" width="160" height="144" rx="8" fill="none" stroke="#000"',+ 'data-scope-id="hub" data-scope-kind="traffic" data-parent="rg" x="32" y="88" width="160" height="144" rx="8" fill="none" stroke="#000" stroke-dasharray="4,4"',+ 1,+ )+ self.rejects(dashed, "traffic box must use a solid stroke")++ def test_managed_must_not_sit_inside_traffic(self):+ self.rejects(GOOD.replace('x="32" y="36"', 'x="56" y="144"'), "must not sit inside traffic scope")++ def test_managed_must_parent_to_admin(self):+ self.rejects(GOOD.replace('data-node-id="sql" data-kind="managed" data-parent="rg"',+ 'data-node-id="sql" data-kind="managed" data-parent="hub"'),+ "managed node must parent to an admin band")++ def test_endpoint_must_parent_to_traffic_and_target_managed(self):+ self.rejects(GOOD.replace('data-parent="spoke" data-target="sql"',+ 'data-parent="rg" data-target="sql"'),+ "endpoint node must parent to a traffic box")+ self.rejects(GOOD.replace('data-target="sql"', 'data-target="app"'), "must name a managed node")+ self.rejects(GOOD.replace(' data-target="sql"', ""), "endpoint must declare data-target")++ def test_peering_must_join_traffic_scopes(self):+ self.rejects(GOOD.replace('data-from="hub" data-to="spoke"', 'data-from="rg" data-to="spoke"'),+ "peering data-from and data-to must name traffic scopes")+ self.rejects(GOOD.replace('data-from="hub" data-to="spoke"', 'data-from="hub" data-to="hub"'),+ "two distinct traffic scopes")++ def test_sibling_axis_and_overlap(self):+ mixed = GOOD.replace(+ 'data-scope-id="spoke" data-scope-kind="traffic" data-parent="rg" x="208" y="88"',+ 'data-scope-id="spoke" data-scope-kind="traffic" data-parent="rg" x="208" y="120"',+ 1,+ )+ self.rejects(mixed, "sibling traffic scopes must share one axis")+ overlap = GOOD.replace(+ 'data-scope-id="spoke" data-scope-kind="traffic" data-parent="rg" x="208" y="88" width="160" height="144"',+ 'data-scope-id="spoke" data-scope-kind="traffic" data-parent="rg" x="80" y="88" width="160" height="144"',+ 1,+ )+ self.rejects(overlap, "overlap")++ def test_off_grid_bounds(self):+ self.rejects(GOOD.replace('x="32" y="88"', 'x="33" y="88"'), "4px grid")++ def test_unknown_kinds_and_duplicate_attributes(self):+ self.rejects(GOOD.replace('data-scope-kind="traffic"', 'data-scope-kind="vpc"', 1), "data-scope-kind")+ self.rejects(GOOD.replace('data-kind="compute"', 'data-kind="vm"', 1), "data-kind")+ self.rejects(GOOD.replace('data-scope-id="hub"', 'data-scope-id="hub" DATA-SCOPE-ID="ignored"', 1),+ "duplicate attributes")++ def test_empty_and_invalid_ids(self):+ for value in ("", " hub", "1hub", "hub spoke"):+ with self.subTest(value=value):+ self.rejects(GOOD.replace('data-scope-id="hub"', f'data-scope-id="{value}"', 1), "identity")++ def test_budget(self):+ extra_admin = GOOD.replace(+ "</svg>",+ scope("extra-admin", "admin", 16, 16, 368, 40) + "</svg>",+ )+ self.rejects(extra_admin, "admin budget")+ extra_traffic = GOOD.replace(+ "</svg>",+ scope("a", "traffic", 32, 88, 40, 40, parent="rg")+ + scope("b", "traffic", 80, 88, 40, 40, parent="rg")+ + scope("c", "traffic", 128, 88, 40, 40, parent="rg")+ + "</svg>",+ )+ self.rejects(extra_traffic, "traffic budget")+ extra_nodes = GOOD+ for identity in ("n1", "n2", "n3", "n4", "n5", "n6"):+ extra_nodes = extra_nodes.replace("</svg>", node(identity, "compute", 56, 144, "hub") + "</svg>")+ self.rejects(extra_nodes, "node budget")++ # Item 1: transforms and positional CSS move rendered geometry away from+ # the raw x/y/width/height the checker reads, so they are rejected.+ def test_transform_attribute_on_node_group(self):+ self.rejects(GOOD.replace('<g data-node-id="sql"', '<g transform="translate(0,264)" data-node-id="sql"', 1),+ "moves checked bounds")++ def test_inline_style_transform_on_node_group(self):+ self.rejects(GOOD.replace('<g data-node-id="sql"', '<g style="transform:translate(0px,264px)" data-node-id="sql"', 1),+ "moves checked bounds")++ def test_ancestor_group_transform(self):+ source = GOOD.replace('<g data-node-id="sql"', '<g transform="translate(0,264)"><g data-node-id="sql"', 1)+ source = source.replace("<text>sql</text></g>", "<text>sql</text></g></g>", 1)+ self.rejects(source, "moves checked bounds")++ def test_transform_attribute_on_scope_bounds(self):+ self.rejects(GOOD.replace('<rect data-role="bounds" data-scope-id="hub"',+ '<rect transform="translate(400,0)" data-role="bounds" data-scope-id="hub"', 1),+ "moves checked bounds")++ def test_positional_inline_css_on_bounds(self):+ for style in ("translate: 0 100px", "x: 0px", "rotate: 90deg", "position:absolute;top:10px", "margin-left: 4px"):+ with self.subTest(style=style):+ self.rejects(GOOD.replace('<rect data-role="bounds" x="56" y="144"',+ f'<rect style="{style}" data-role="bounds" x="56" y="144"', 1),+ "moves checked bounds")++ def test_nested_svg_viewport_ancestor(self):+ source = GOOD.replace('<g data-node-id="sql"', '<svg x="0" y="264"><g data-node-id="sql"', 1)+ source = source.replace("<text>sql</text></g>", "<text>sql</text></g></svg>", 1)+ self.rejects(source, "moves checked bounds")++ def test_stylesheet_rule_transforming_checked_element(self):+ for rule in ('[data-node-id="sql"] { transform: translate(0, 264px); }',+ "svg g { translate: 0 264px }",+ "rect { x: 0 }"):+ with self.subTest(rule=rule):+ self.rejects(GOOD.replace("body {margin:0}", "body {margin:0} " + rule, 1), "moves checked bounds")++ def test_geometry_animation(self):+ self.rejects(GOOD.replace("<text>sql</text></g>",+ '<text>sql</text><animateTransform attributeName="transform" type="translate" to="0 264"/></g>', 1),+ "moves checked bounds")++ def test_harmless_page_css_is_clean(self):+ source = GOOD.replace("body {margin:0}", "body {margin:0} .card li { position: relative; left: 0; transform: none }", 1)+ self.clean(source)++ def test_page_only_style_rules_are_clean(self):+ # The full selector is matched against the element and its real+ # ancestors, so rules that cannot reach a checked element pass.+ for rule in (":root { height: 100% }",+ "html, body { height: 100% }",+ ".card rect { x: 0 }",+ "svg { width: 100% }",+ "#other rect { transform: translate(4px, 0) }",+ "body > rect { x: 0 }",+ "rect::after { transform: scale(2) }",+ 'g[data-kind="vm"] { translate: 0 8px }'):+ with self.subTest(rule=rule):+ self.clean(GOOD.replace("body {margin:0}", "body {margin:0} " + rule, 1))++ def test_style_rule_through_page_ancestor(self):+ wrapped = GOOD.replace("<svg data-grammar", '<div class="card"><svg data-grammar', 1)+ wrapped = wrapped.replace("</svg>", "</svg></div>", 1)+ self.clean(wrapped)+ for rule in (".card rect { x: 0 }",+ "body > .card rect { x: 0 }",+ 'div.card > svg > g[data-kind="managed"] { transform: translate(0, 264px) }',+ "h1 + .card rect { x: 0 }",+ ":not(.other) rect { x: 0 }"):+ with self.subTest(rule=rule):+ self.rejects(wrapped.replace("body {margin:0}", "body {margin:0} " + rule, 1),+ "moves checked bounds")++ @staticmethod+ def omitted_tag_pages():+ # Valid HTML may omit <html>, <head> and <body>; a browser implies them.+ no_html = GOOD.replace("<html>", "", 1).replace("</html>", "", 1)+ no_body = GOOD.replace("<body>", "", 1).replace("</body>", "", 1)+ neither = no_html.replace("<body>", "", 1).replace("</body>", "", 1)+ bare = neither.replace("<head>", "", 1).replace("</head>", "", 1)+ pages = {"no-html": no_html, "no-body": no_body, "neither": neither, "bare": bare}+ for page in pages.values():+ assert page != GOOD and "body {margin:0}" in page+ return pages++ def test_omitted_html_and_body_still_anchor_style_rules(self):+ for label, page in self.omitted_tag_pages().items():+ with self.subTest(page=label):+ self.clean(page)+ for rule in ('body [data-node-id="sql"] { transform: translate(0,108px) }',+ 'html [data-node-id="sql"] { transform: translate(0,108px) }',+ ':root [data-node-id="sql"] { transform: translate(0,108px) }',+ 'html > body > svg [data-node-id="sql"] { transform: translate(0,108px) }'):+ with self.subTest(page=label, rule=rule):+ self.rejects(page.replace("body {margin:0}", "body {margin:0} " + rule, 1),+ "moves checked bounds")++ def test_omitted_tag_pages_keep_page_only_rules_clean(self):+ for label, page in self.omitted_tag_pages().items():+ for rule in (":root { height: 100% }", "body > rect { x: 0 }", "head rect { x: 0 }",+ "html > rect { x: 0 }", ":root > g { transform: translate(4px, 0) }"):+ with self.subTest(page=label, rule=rule):+ self.clean(page.replace("body {margin:0}", "body {margin:0} " + rule, 1))++ def test_child_combinator_outside_svg_survives_implied_end_tags(self):+ # A browser closes the <p> at <div>, so body > .card matches; the+ # stdlib parser nests the div in the p, so the checker must not trust it.+ source = GOOD.replace("<svg data-grammar", '<p>intro<div class="card"><svg data-grammar', 1)+ source = source.replace("</svg>", "</svg></div>", 1)+ self.clean(source)+ self.rejects(source.replace("body {margin:0}", "body {margin:0} body > .card rect { x: 0 }", 1),+ "moves checked bounds")++ # Item 2: a scope or node enclosed by another scope must declare its+ # parent, and that parent must be the innermost enclosing scope.+ def test_missing_parent_on_enclosed_scope(self):+ self.rejects(GOOD.replace(' data-parent="subscription"', "", 1), "data-parent is required")++ def test_parent_must_be_innermost_enclosing_scope(self):+ self.rejects(GOOD.replace('data-scope-id="hub" data-scope-kind="traffic" data-parent="rg"',+ 'data-scope-id="hub" data-scope-kind="traffic" data-parent="subscription"', 1),+ "innermost enclosing scope")+ self.rejects(GOOD.replace('data-node-id="sql" data-kind="managed" data-parent="rg"',+ 'data-node-id="sql" data-kind="managed" data-parent="subscription"', 1),+ "innermost enclosing scope")++ def test_shipped_missing_parent_cannot_hide_misaligned_sibling(self):+ path = ROOT / "skills/diagram-design/assets/example-architecture-containment.html"+ source = path.read_text(encoding="utf-8")+ mutated = source.replace('data-scope-id="vnet-hub" data-scope-kind="traffic" data-parent="rg"',+ 'data-scope-id="vnet-hub" data-scope-kind="traffic"', 1)+ self.assertNotEqual(mutated, source)+ findings = "\n".join(checker.check_source(path, mutated))+ self.assertIn("data-parent is required", findings)+ mutated = source.replace(' data-parent="subscription"', "", 1)+ self.assertNotEqual(mutated, source)+ self.assertIn("data-parent is required", "\n".join(checker.check_source(path, mutated)))++ # Item 3: stroke-dasharray is parsed, not merely tested for presence.+ def test_dasharray_none_is_solid(self):+ for value in ("none", "0", "0,0", " 0 0 "):+ with self.subTest(value=value):+ self.rejects(GOOD.replace('stroke-dasharray="4,4"', f'stroke-dasharray="{value}"', 1),+ "admin band must use a dashed stroke")+ traffic = GOOD.replace(+ 'data-scope-id="hub" data-scope-kind="traffic" data-parent="rg" x="32" y="88" width="160" height="144" rx="8" fill="none" stroke="#000"',+ f'data-scope-id="hub" data-scope-kind="traffic" data-parent="rg" x="32" y="88" width="160" height="144" rx="8" fill="none" stroke="#000" stroke-dasharray="{value}"',+ 1,+ )+ self.assertNotEqual(traffic, GOOD)+ self.clean(traffic)++ def test_dasharray_resolves_style_and_inheritance(self):+ self.rejects(GOOD.replace(' stroke-dasharray="4,4"', ' stroke-dasharray="4,4" style="stroke-dasharray: none"', 1),+ "admin band must use a dashed stroke")+ inherited = GOOD.replace('<rect data-role="bounds" data-scope-id="hub"',+ '<g stroke-dasharray="4 4"><rect data-role="bounds" data-scope-id="hub"', 1)+ inherited = inherited.replace(+ '<rect data-role="bounds" data-scope-id="spoke"', '</g><rect data-role="bounds" data-scope-id="spoke"', 1)+ self.rejects(inherited, "traffic box must use a solid stroke")+ self.rejects(GOOD.replace("body {margin:0}", "body {margin:0} rect { stroke-dasharray: none }", 1),+ "overrides the checked stroke-dasharray")++ # Item 4: bounds are rects, not any element that happens to carry x/y/width/height.+ def test_scope_bounds_must_be_rect(self):+ self.rejects(GOOD.replace('<rect data-role="bounds" data-scope-id="hub"', '<image data-role="bounds" data-scope-id="hub"', 1),+ "bounds must be a <rect>")++ def test_node_bounds_must_be_rect(self):+ self.rejects(GOOD.replace('<rect data-role="bounds" x="56" y="144"', '<image data-role="bounds" x="56" y="144"', 1),+ "bounds must be a <rect>")++ # Item 5: nested sibling traffic scopes take the axis perpendicular to+ # their parent's own axis (type-architecture.md, Sibling axis).+ @staticmethod+ def nested(first, second):+ return GOOD.replace("</svg>", scope("n1", "traffic", *first, parent="hub")+ + scope("n2", "traffic", *second, parent="hub") + "</svg>", 1)++ def test_nested_siblings_take_perpendicular_axis(self):+ # hub and spoke form a row in rg, so hub's own children stack in a column.+ self.clean(self.nested((112, 100, 72, 56), (112, 164, 72, 56)))++ def test_nested_siblings_on_parent_axis_rejected(self):+ self.rejects(self.nested((112, 100, 32, 120), (152, 100, 32, 120)), "perpendicular")++ def test_all_shipped_variants(self):+ for suffix in ("", "-dark", "-full"):+ path = ROOT / f"skills/diagram-design/assets/example-architecture-containment{suffix}.html"+ with self.subTest(variant=suffix):+ self.assertTrue(path.is_file(), f"missing shipped variant: {path.name}")+ source = path.read_text(encoding="utf-8")+ self.assertEqual(checker.check_source(path, source), [])+ self.assertIn('data-grammar="architecture-containment"', source)+ self.assertIn('data-kind="managed"', source)+ self.assertIn('data-kind="endpoint"', source)+ self.assertIn("data-peering=", source)++ def test_shipped_boundary_labels_use_soft(self):+ # type-architecture.md: zone labels use `soft`, never ink at an opacity.+ soft = {"": "#5a6580", "-dark": "#949eb2", "-full": "#5a6580"}+ for suffix, colour in soft.items():+ path = ROOT / f"skills/diagram-design/assets/example-architecture-containment{suffix}.html"+ scanner = checker.Scanner()+ scanner.finish(path.read_text(encoding="utf-8"))+ labels = [item for item in scanner.nodes+ if item.tag == "text" and item.attrs.get("letter-spacing") == "0.14em"]+ with self.subTest(variant=suffix):+ self.assertEqual(len(labels), 6)+ self.assertEqual({item.attrs.get("fill") for item in labels}, {colour})++ def test_cli_discovery_and_failures(self):+ env = {**os.environ, "PYTHONIOENCODING": "utf-8"}+ for args in ([], ["--all"]):+ result = subprocess.run([sys.executable, str(CHECKER), *args], capture_output=True, text=True, env=env)+ self.assertEqual(result.returncode, 0, result.stdout + result.stderr)+ self.assertIn("3 file(s)", result.stdout)+ with tempfile.TemporaryDirectory() as directory:+ path = Path(directory) / "diagram.html"+ path.write_text(GOOD, encoding="utf-8")+ result = subprocess.run([sys.executable, str(CHECKER), str(path)], capture_output=True, text=True, env=env)+ self.assertEqual(result.returncode, 0, result.stdout + result.stderr)+ path.write_text(GOOD.replace('data-kind="managed"', 'data-kind="compute"', 1), encoding="utf-8")+ result = subprocess.run([sys.executable, str(CHECKER), str(path)], capture_output=True, text=True, env=env)+ self.assertEqual(result.returncode, 1)+ path.unlink()+ result = subprocess.run([sys.executable, str(CHECKER), str(path)], capture_output=True, text=True, env=env)+ self.assertEqual(result.returncode, 2)+++if __name__ == "__main__":+ unittest.main(verbosity=2)diff --git a/scripts/verify-architecture-containment.py b/scripts/verify-architecture-containment.pynew file mode 100644index 0000000..6c8e190--- /dev/null+++ b/scripts/verify-architecture-containment.py@@ -0,0 +1,863 @@+#!/usr/bin/env python3+"""Verify the Architecture containment HTML contract using only the stdlib.++Checks unique IDs, resolving parents, no cycles, geometric containment,+innermost-scope parents (only the outermost scope may omit data-parent),+<rect> bounds, admin-band vs traffic-box shapes with stroke-dasharray resolved+as rendered, PaaS placement, endpoint targets, declared peerings, sibling axes+(nested children perpendicular to their parent's), and the 4px grid. Geometry+is read from raw x/y/width/height, so a transform, moving inline CSS, nested+<svg> viewport, matching <style> rule, or geometry animation on a checked+element or its ancestors is a finding. External stylesheets and script are not+evaluated. Files without data-grammar="architecture-containment" are skipped.+This verifies authored declarations, not whether they describe an external+system.++Usage: python3 scripts/verify-architecture-containment.py [--all | FILE ...]+No arguments and --all check every shipped architecture-containment example.+Exit: 0 clean, 1 contract findings, 2 unreadable input/usage.+"""++from __future__ import annotations++import argparse+import math+import re+import sys+from dataclasses import dataclass, field+from html.parser import HTMLParser+from pathlib import Path++ROOT = Path(__file__).resolve().parent.parent+ASSET_DIR = ROOT / "skills/diagram-design/assets"+NUMBER = r"[-+]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][-+]?\d+)?"+NUMBER_RE = re.compile(NUMBER)+ID_RE = re.compile(r"[A-Za-z][A-Za-z0-9_.:-]*\Z")+VOID = {"area", "base", "br", "col", "embed", "hr", "img", "input", "link", "meta", "param", "source", "track", "wbr"}+GRAMMAR = "architecture-containment"+SCOPE_KINDS = {"admin", "traffic"}+NODE_KINDS = {"compute", "endpoint", "managed"}+ADMIN_RX = 4.0+TRAFFIC_RX = 8.0+GRID = 4.0+EPS = 1e-6+MAX_COORDINATE = 1e7+MAX_ADMIN = 2+MAX_TRAFFIC = 4+MAX_NODES = 8+++@dataclass(eq=False)+class Node:+ tag: str+ attrs: dict[str, str]+ line: int+ parent: Node | None = None+ children: list[Node] = field(default_factory=list)+ content: list[str | Node] = field(default_factory=list)+ duplicates: set[str] = field(default_factory=set)++ def ancestors(self):+ parent = self.parent+ while parent is not None:+ yield parent+ parent = parent.parent+++class Scanner(HTMLParser):+ """HTML parsing honors unquoted attrs, entities, comments and raw style text."""++ def __init__(self):+ super().__init__(convert_charrefs=True)+ self.root = Node("document", {}, 1)+ self.stack = [self.root]+ self.nodes: list[Node] = []+ self.errors: list[str] = []++ def handle_starttag(self, tag, attrs):+ values = {}+ duplicates = set()+ for name, value in attrs:+ if name in values:+ duplicates.add(name)+ values.setdefault(name, value or "")+ node = Node(tag, values, self.getpos()[0], self.stack[-1], duplicates=duplicates)+ self.stack[-1].children.append(node)+ self.stack[-1].content.append(node)+ self.nodes.append(node)+ if tag not in VOID:+ self.stack.append(node)++ def handle_startendtag(self, tag, attrs):+ self.handle_starttag(tag, attrs)+ if tag not in VOID:+ self.handle_endtag(tag)++ def handle_endtag(self, tag):+ indexes = [i for i, node in enumerate(self.stack) if node.tag == tag]+ in_svg = any(node.tag == "svg" for node in self.stack)+ if not indexes:+ if in_svg:+ self.errors.append(f"line {self.getpos()[0]}: malformed SVG closing tag {tag}")+ return+ index = indexes[-1]+ if in_svg and index != len(self.stack) - 1:+ self.errors.append(f"line {self.getpos()[0]}: malformed SVG nesting at {tag}")+ del self.stack[index:]++ def handle_data(self, data):+ self.stack[-1].content.append(data)++ def finish(self, source):+ self.feed(source)+ self.close()+ if any(node.tag == "svg" for node in self.stack):+ self.errors.append("unclosed SVG")+++@dataclass+class Box:+ node: Node+ identity: str+ x: float+ y: float+ w: float+ h: float+ rx: float | None+ dashed: bool+ kind: str+ parent_id: str | None+ target: str | None = None++ @property+ def right(self) -> float:+ return self.x + self.w++ @property+ def bottom(self) -> float:+ return self.y + self.h+++def number(raw: str) -> float:+ if not NUMBER_RE.fullmatch(raw.strip()):+ raise ValueError("missing, malformed or non-finite number")+ value = float(raw)+ if not math.isfinite(value) or abs(value) > MAX_COORDINATE:+ raise ValueError("number must be finite and within 10,000,000 units")+ return value+++def on_grid(value: float) -> bool:+ ratio = value / GRID+ return math.isfinite(ratio) and abs(ratio - round(ratio)) <= EPS+++def within_box(inner: Box, outer: Box) -> bool:+ return (inner.x + EPS >= outer.x and inner.y + EPS >= outer.y+ and inner.right <= outer.right + EPS and inner.bottom <= outer.bottom + EPS)+++def overlaps(a: Box, b: Box) -> bool:+ return (a.x < b.right - EPS and a.right > b.x + EPS+ and a.y < b.bottom - EPS and a.bottom > b.y + EPS)+++def identity_ok(raw: str) -> bool:+ return bool(raw) and ID_RE.fullmatch(raw) is not None+++def split_top(text: str, separators: str) -> list[str]:+ """Split on separators outside quotes, brackets and parentheses."""+ parts, depth, quote, start = [], 0, "", 0+ for index, char in enumerate(text):+ if quote:+ if char == quote:+ quote = ""+ elif char in "\"'":+ quote = char+ elif char in "([":+ depth += 1+ elif char in ")]":+ depth = max(0, depth - 1)+ elif depth == 0 and char in separators:+ parts.append(text[start:index])+ start = index + 1+ parts.append(text[start:])+ return parts+++def declarations(text: str) -> dict[str, str]:+ """Parse a CSS declaration block; later declarations win, as in CSS."""+ result = {}+ for part in split_top(re.sub(r"/\*.*?\*/", "", text, flags=re.S), ";"):+ name, colon, value = part.partition(":")+ name = name.strip().lower()+ if colon and name and not name.startswith("--"):+ result[name] = re.sub(r"!\s*important\s*$", "", value.strip(), flags=re.I).strip()+ return result+++GROUP_AT_RULES = {"media", "supports", "layer", "container", "scope", "document"}+++def css_rules(text: str) -> list[tuple[str, dict[str, str]]]:+ """Return (selector list, declarations) for every style rule, recursing into+ conditional group at-rules and skipping @keyframes, @font-face and the like."""+ text = re.sub(r"/\*.*?\*/", "", text, flags=re.S)+ rules: list[tuple[str, dict[str, str]]] = []+ index, start, quote = 0, 0, ""+ while index < len(text):+ char = text[index]+ if quote:+ if char == quote:+ quote = ""+ elif char in "\"'":+ quote = char+ elif char == ";":+ start = index + 1+ elif char == "{":+ depth, close, inner_quote = 1, index + 1, ""+ while close < len(text) and depth:+ inner = text[close]+ if inner_quote:+ if inner == inner_quote:+ inner_quote = ""+ elif inner in "\"'":+ inner_quote = inner+ elif inner == "{":+ depth += 1+ elif inner == "}":+ depth -= 1+ close += 1+ prelude, body = text[start:index].strip(), text[index + 1:close - 1]+ if prelude.startswith("@"):+ name = prelude[1:].split(None, 1)[0].lower() if len(prelude) > 1 else ""+ if name in GROUP_AT_RULES:+ rules.extend(css_rules(body))+ elif prelude:+ rules.append((prelude, declarations(body)))+ index = start = close+ continue+ index += 1+ return rules+++# Properties that can move or reshape rendered geometry away from the raw+# x/y/width/height attributes this checker reads.+MOVING_PROPERTIES = {"transform", "translate", "rotate", "scale", "offset", "zoom",+ "x", "y", "width", "height", "rx", "ry", "animation", "animation-name"}+# CSS box positioning does not move SVG graphics today, but it has no place on a+# checked element either, so inline uses are rejected rather than trusted.+BOX_PROPERTIES = {"position", "left", "top", "right", "bottom", "inset", "margin"}+NEUTRAL_VALUES = {"none", "initial", "unset"}+TRANSFORM_FAMILY = {"transform", "translate", "rotate", "scale", "offset-path"}+MOVING_ANIMATION_ATTRS = {"x", "y", "width", "height", "rx", "ry", "transform", "style", "class", "stroke-dasharray"}+MOVES = "moves checked bounds away from their declared x/y/width/height"+++def moving_property(name: str, value: str, inline: bool) -> bool:+ if name in TRANSFORM_FAMILY and value.strip().lower() in NEUTRAL_VALUES:+ return False+ if name in MOVING_PROPERTIES or name.startswith("offset-"):+ return True+ return inline and (name in BOX_PROPERTIES or name.startswith(("margin-", "inset-")))+++LEGACY_PSEUDO_ELEMENTS = {"before", "after", "first-line", "first-letter"}+ATTRIBUTE_RE = re.compile(r"""\[\s*([\w-]+)\s*(?:([~|^$*]?=)\s*("[^"]*"|'[^']*'|[^\s\]]+)\s*([iIsS])?\s*)?\]\Z""")+++def balanced_end(text: str, index: int, opening: str, closing: str) -> int:+ """Index just past the bracket that closes text[index], honouring quotes."""+ depth, quote = 0, ""+ for position in range(index, len(text)):+ char = text[position]+ if quote:+ if char == quote:+ quote = ""+ elif char in "\"'":+ quote = char+ elif char == opening:+ depth += 1+ elif char == closing:+ depth -= 1+ if depth == 0:+ return position + 1+ return len(text)+++def selector_parts(selector: str) -> list[tuple[str, str]] | None:+ """Split one complex selector into (combinator, compound) pairs, left to+ right; the first combinator is empty. None when it cannot be parsed."""+ parts: list[tuple[str, str]] = []+ combinator, current, index = "", "", 0+ text = selector.strip()+ while index < len(text):+ char = text[index]+ if char in "([":+ close = balanced_end(text, index, char, ")" if char == "(" else "]")+ current += text[index:close]+ index = close+ continue+ if char in "\"'":+ return None+ if char.isspace() or char in ">+~":+ if current:+ parts.append((combinator, current))+ current, combinator = "", " "+ if char in ">+~":+ if combinator not in ("", " "):+ return None+ combinator = char+ index += 1+ continue+ current += char+ index += 1+ if not current:+ return None+ parts.append((combinator, current))+ return parts+++def match_attribute(token: str, node: Node) -> bool | None:+ match = ATTRIBUTE_RE.match(token)+ if not match:+ return None+ name, operator, raw, flag = match.groups()+ value = node.attrs.get(name.lower())+ if value is None:+ return False+ if not operator:+ return True+ expected = raw[1:-1] if raw[:1] in "\"'" else raw+ if flag and flag.lower() == "i":+ value, expected = value.lower(), expected.lower()+ if operator == "=":+ return value == expected+ if operator == "~=":+ return expected in value.split()+ if operator == "|=":+ return value == expected or value.startswith(expected + "-")+ if operator == "^=":+ return bool(expected) and value.startswith(expected)+ if operator == "$=":+ return bool(expected) and value.endswith(expected)+ return bool(expected) and expected in value+++def match_compound(compound: str, node: Node, parent_of) -> bool | None:+ """True or False when every part can be evaluated; None (may match) when a+ part such as :not() or :hover cannot. Any definite failure wins."""+ if "\\" in compound or "|" in compound.split("[")[0]:+ return None+ results: list[bool | None] = []+ index = 0+ head = re.match(r"\*|[A-Za-z][\w-]*", compound)+ if head:+ results.append(head.group(0) == "*" or head.group(0).lower() == node.tag)+ index = head.end()+ while index < len(compound):+ char = compound[index]+ if char in ".#":+ name = re.match(r"[\w-]+", compound[index + 1:])+ if not name:+ return None if False not in results else False+ value = name.group(0)+ if char == ".":+ results.append(value in node.attrs.get("class", "").split())+ else:+ results.append(node.attrs.get("id") == value)+ index += 1 + len(value)+ elif char == "[":+ close = balanced_end(compound, index, "[", "]")+ results.append(match_attribute(compound[index:close], node))+ index = close+ elif char == ":":+ element = compound.startswith("::", index)+ name = re.match(r"[\w-]+", compound[index + (2 if element else 1):])+ if not name:+ return None if False not in results else False+ label = name.group(0).lower()+ index += (2 if element else 1) + len(name.group(0))+ if index < len(compound) and compound[index] == "(":+ index = balanced_end(compound, index, "(", ")")+ if element or label in LEGACY_PSEUDO_ELEMENTS:+ results.append(False) # pseudo-elements never box SVG graphics+ elif label == "root":+ results.append(node.tag == "html" and parent_of(node) is None)+ else:+ results.append(None)+ else:+ return None if False not in results else False+ if False in results:+ return False+ return True if all(result is True for result in results) else None+++def selector_may_match(parts: list[tuple[str, str]], index: int, node: Node | None, element: Node,+ parent_of) -> bool:+ """Right-to-left match of parts[:index + 1] ending at node. node is None for+ a sibling we do not evaluate; element then supplies the shared parent."""+ if node is not None and match_compound(parts[index][1], node, parent_of) is False:+ return False+ if index == 0:+ return True+ combinator = parts[index][0]+ anchor = node if node is not None else element+ if combinator in "+~":+ # Sibling selectors are honoured conservatively: the sibling compound+ # is assumed to match and the rest is checked against the shared parent.+ return selector_may_match(parts, index - 1, None, anchor, parent_of)+ candidates: list[Node] = []+ current = parent_of(anchor)+ while current is not None:+ candidates.append(current)+ if combinator == ">" and in_svg(current):+ break+ current = parent_of(current)+ return any(selector_may_match(parts, index - 1, candidate, candidate, parent_of) for candidate in candidates)+++HEAD_TAGS = {"head", "title", "meta", "link", "style", "script", "base", "noscript", "template"}+++def ancestry(scanner: Scanner):+ """Parent lookup that adds the <html> and <body> a browser implies when a+ valid page omits those optional tags, so :root, html and body selectors+ resolve the way they do in the rendered page."""+ real_html = next((node for node in scanner.nodes if node.tag == "html"), None)+ has_body = any(node.tag == "body" for node in scanner.nodes)+ implied_html = None if real_html else Node("html", {}, 0)+ implied_body = None if has_body else Node("body", {}, 0)+ html = real_html or implied_html++ def parent_of(node: Node) -> Node | None:+ if node is html:+ return None+ if node is implied_body:+ return html+ parent = node.parent+ if parent is None:+ return None+ if parent.tag == "document":+ parent = html+ if parent is html and implied_body is not None and node.tag not in HEAD_TAGS | {"body"}:+ return implied_body+ return parent++ return parent_of+++def in_svg(node: Node) -> bool:+ """SVG nesting is checked for malformation, so a parent inside the SVG is+ exact. HTML around it may rely on implied end tags, so a child combinator+ that reaches outside the SVG is treated as a descendant combinator."""+ return node.tag == "svg" or any(item.tag == "svg" for item in node.ancestors())+++def rule_may_match(selector: str, node: Node, parent_of) -> bool:+ parts = selector_parts(selector)+ if parts is None:+ return True+ return selector_may_match(parts, len(parts) - 1, node, node, parent_of)+++def dash_value(raw: str) -> bool | None:+ """True dashed, False solid, None when unspecified, inherited or invalid."""+ value = raw.strip().lower()+ if value in ("", "inherit"):+ return None+ if value in ("none", "initial", "unset", "revert"):+ return False+ lengths = []+ for token in re.split(r"[\s,]+", value):+ match = re.fullmatch(f"({NUMBER})(px|%|em|rem|ex|ch|pt|pc|mm|cm|in|vw|vh)?", token)+ if not match or float(match.group(1)) < 0:+ return None+ lengths.append(float(match.group(1)))+ return any(length > 0 for length in lengths)+++def is_dashed(node: Node, root: Node) -> bool:+ """Resolve stroke-dasharray as rendered: inline style beats the attribute,+ and the property inherits from ancestors up to the diagram SVG."""+ current: Node | None = node+ while current is not None:+ for raw in (declarations(current.attrs.get("style", "")).get("stroke-dasharray"),+ current.attrs.get("stroke-dasharray")):+ if raw is not None:+ resolved = dash_value(raw)+ if resolved is not None:+ return resolved+ if current is root:+ break+ current = current.parent+ return False+++def parse_box(node: Node, identity: str, kind: str, parent_id: str | None, target: str | None = None,+ root: Node | None = None) -> Box:+ attrs = node.attrs+ x = number(attrs.get("x", ""))+ y = number(attrs.get("y", ""))+ w = number(attrs.get("width", ""))+ h = number(attrs.get("height", ""))+ rx_raw = attrs.get("rx")+ rx = number(rx_raw) if rx_raw not in (None, "") else None+ dashed = is_dashed(node, root if root is not None else node)+ if w <= 0 or h <= 0:+ raise ValueError("bounds width and height must be positive")+ return Box(node, identity, x, y, w, h, rx, dashed, kind, parent_id, target)+++def looks_like_containment(source: str) -> bool:+ scanner = Scanner()+ scanner.finish(source)+ return any(node.tag == "svg" and node.attrs.get("data-grammar") == GRAMMAR+ for node in scanner.nodes)+++def check_source(path: Path, source: str) -> list[str]:+ scanner = Scanner()+ scanner.finish(source)+ findings: list[str] = []+ roots = [node for node in scanner.nodes+ if node.tag == "svg" and node.attrs.get("data-grammar") == GRAMMAR]+ if not roots:+ return []++ def fail(node: Node, message: str) -> None:+ findings.append(f"{path.name}:{node.line}: {message}")++ if len(roots) != 1:+ fail(roots[0], 'require exactly one svg data-grammar="architecture-containment"')+ return findings+ root = roots[0]+ findings.extend(f"{path.name}: {error}" for error in scanner.errors)+ for node in scanner.nodes:+ if node is root or root in node.ancestors():+ if node.duplicates:+ fail(node, f"duplicate attributes: {', '.join(sorted(node.duplicates))}")++ scopes: dict[str, Box] = {}+ nodes: dict[str, Box] = {}+ ids: dict[str, Node] = {}+ checked: list[Node] = []++ def register(identity: str, carrier: Node) -> bool:+ if not identity_ok(identity):+ fail(carrier, "identity must be a single XML Name starting with a letter")+ return False+ if identity in ids:+ fail(carrier, f'duplicate ID "{identity}"')+ return False+ ids[identity] = carrier+ return True++ for node in scanner.nodes:+ if root not in node.ancestors() and node is not root:+ continue+ attrs = node.attrs+ if "data-scope-id" in attrs:+ identity = attrs.get("data-scope-id", "")+ kind = attrs.get("data-scope-kind", "")+ if "data-parent" in attrs:+ parent_id = attrs.get("data-parent", "")+ if not identity_ok(parent_id):+ fail(node, "data-parent must name the enclosing scope")+ parent_id = parent_id or None+ else:+ parent_id = None+ if attrs.get("data-role") != "bounds":+ fail(node, "scope bounds must declare data-role=\"bounds\"")+ if kind not in SCOPE_KINDS:+ fail(node, "data-scope-kind must be admin or traffic")+ if not register(identity, node):+ continue+ checked.append(node)+ if node.tag != "rect":+ fail(node, f"scope bounds must be a <rect>, not <{node.tag}>")+ continue+ try:+ box = parse_box(node, identity, kind, parent_id, root=root)+ except ValueError as error:+ fail(node, str(error))+ continue+ if kind == "admin":+ if box.rx is None or abs(box.rx - ADMIN_RX) > EPS:+ fail(node, "admin band must use rx=4")+ if not box.dashed:+ fail(node, "admin band must use a dashed stroke")+ if box.w + EPS < box.h:+ fail(node, "admin band must be a horizontal rectangle")+ elif kind == "traffic":+ if box.rx is None or abs(box.rx - TRAFFIC_RX) > EPS:+ fail(node, "traffic box must use rx=8")+ if box.dashed:+ fail(node, "traffic box must use a solid stroke")+ for value in (box.x, box.y, box.w, box.h):+ if not on_grid(value):+ fail(node, "scope bounds must sit on the 4px grid")+ break+ scopes[identity] = box+ elif "data-node-id" in attrs:+ identity = attrs.get("data-node-id", "")+ kind = attrs.get("data-kind", "")+ parent_id = attrs.get("data-parent", "")+ target = attrs.get("data-target")+ target = target if target not in (None, "") else None+ if kind not in NODE_KINDS:+ fail(node, "data-kind must be compute, endpoint, or managed")+ if not identity_ok(parent_id):+ fail(node, "data-parent must name the enclosing scope")+ if not register(identity, node):+ continue+ checked.append(node)+ bounds = [child for child in node.children if child.attrs.get("data-role") == "bounds"]+ if len(bounds) != 1:+ fail(node, "node must expose exactly one data-role=\"bounds\" rect")+ continue+ checked.append(bounds[0])+ if bounds[0].tag != "rect":+ fail(bounds[0], f"node bounds must be a <rect>, not <{bounds[0].tag}>")+ continue+ try:+ box = parse_box(bounds[0], identity, kind, parent_id, target, root=root)+ except ValueError as error:+ fail(bounds[0], str(error))+ continue+ box.node = node+ for value in (box.x, box.y, box.w, box.h):+ if not on_grid(value):+ fail(bounds[0], "node bounds must sit on the 4px grid")+ break+ if kind == "endpoint":+ if not identity_ok(target or ""):+ fail(node, "endpoint must declare data-target naming a managed node")+ elif target is not None:+ fail(node, "only an endpoint may declare data-target")+ nodes[identity] = box++ if not any(box.kind == "admin" for box in scopes.values()):+ fail(root, "containment requires at least one admin band")+ if not any(box.kind == "traffic" for box in scopes.values()):+ fail(root, "containment requires at least one traffic box")+ admin_count = sum(1 for box in scopes.values() if box.kind == "admin")+ traffic_count = sum(1 for box in scopes.values() if box.kind == "traffic")+ if admin_count > MAX_ADMIN:+ fail(root, "admin budget is 2 bands")+ if traffic_count > MAX_TRAFFIC:+ fail(root, "traffic budget is 4 scopes")+ if len(nodes) > MAX_NODES:+ fail(root, "node budget is 8")++ known_scopes = set(scopes)++ def innermost_parent(box: Box, label: str) -> None:+ """Only an unenclosed (outermost) box may omit data-parent, and a declared+ parent that encloses the box must be the innermost scope that does."""+ enclosing = [scope for scope in scopes.values() if scope is not box and within_box(box, scope)]+ if not enclosing:+ return+ smallest = min(scope.w * scope.h for scope in enclosing)+ innermost = sorted(scope.identity for scope in enclosing if scope.w * scope.h <= smallest + EPS)+ if box.parent_id is None:+ fail(box.node, f'data-parent is required: {label} "{box.identity}" sits inside scope "{innermost[0]}"')+ elif box.parent_id in scopes and within_box(box, scopes[box.parent_id]) and box.parent_id not in innermost:+ fail(box.node, f'data-parent "{box.parent_id}" is not the innermost enclosing scope of '+ f'{label} "{box.identity}"; use "{innermost[0]}"')++ for box in scopes.values():+ innermost_parent(box, "scope")+ if box.parent_id is None:+ continue+ if not identity_ok(box.parent_id) or box.parent_id not in known_scopes:+ fail(box.node, f'data-parent "{box.parent_id}" does not match any data-scope-id')+ continue+ parent = scopes[box.parent_id]+ if not within_box(box, parent):+ fail(box.node, f'scope "{box.identity}" is not geometrically inside parent "{box.parent_id}"')++ parent_of = {box.identity: box.parent_id for box in scopes.values()}+ reported: set[str] = set()+ for identity in scopes:+ if identity in reported:+ continue+ chain: list[str] = []+ current: str | None = identity+ while current is not None:+ if current in chain:+ cycle = chain[chain.index(current):] + [current]+ reported.update(cycle)+ fail(scopes[identity].node, f'parent cycle: {" -> ".join(cycle)}')+ break+ chain.append(current)+ if current not in known_scopes:+ break+ current = parent_of.get(current)++ traffic = {identity: box for identity, box in scopes.items() if box.kind == "traffic"}+ managed = {identity: box for identity, box in nodes.items() if box.kind == "managed"}++ for box in nodes.values():+ if box.parent_id not in known_scopes:+ fail(box.node, f'data-parent "{box.parent_id}" does not match any data-scope-id')+ continue+ parent = scopes[box.parent_id]+ if not within_box(box, parent):+ fail(box.node, f'node "{box.identity}" is not geometrically inside parent "{box.parent_id}"')+ innermost_parent(box, "node")+ if box.kind == "managed":+ if parent.kind != "admin":+ fail(box.node, "managed node must parent to an admin band")+ for traffic_id, traffic_box in traffic.items():+ if overlaps(box, traffic_box) or within_box(box, traffic_box):+ fail(box.node, f'managed node "{box.identity}" must not sit inside traffic scope "{traffic_id}"')+ break+ elif box.kind in {"compute", "endpoint"}:+ if parent.kind != "traffic":+ fail(box.node, f'{box.kind} node must parent to a traffic box')+ if not within_box(box, parent):+ fail(box.node, f'{box.kind} node "{box.identity}" must sit inside its traffic parent')+ if box.kind == "endpoint":+ if box.target not in managed:+ fail(box.node, f'data-target "{box.target}" must name a managed node')++ siblings: dict[str | None, list[Box]] = {}+ for box in scopes.values():+ if box.kind != "traffic":+ continue+ siblings.setdefault(box.parent_id, []).append(box)++ def row_axis(parent_id: str, seen: frozenset[str] = frozenset()) -> bool:+ """True when children of parent_id form a row. The first traffic level+ follows its parent's aspect; nested children take the perpendicular axis."""+ parent = scopes[parent_id]+ grandparent = parent.parent_id+ if parent.kind == "traffic" and grandparent in scopes and grandparent not in seen:+ return not row_axis(grandparent, seen | {parent_id})+ return parent.w + EPS >= parent.h++ for parent_id, group in siblings.items():+ if len(group) < 2 or parent_id not in scopes:+ continue+ row = row_axis(parent_id)+ origins = {round(item.y, 6) for item in group} if row else {round(item.x, 6) for item in group}+ if len(origins) > 1:+ if scopes[parent_id].kind == "traffic":+ axis = "a row sharing one y" if row else "a column sharing one x"+ fail(group[0].node, f'nested sibling traffic scopes in "{parent_id}" must take the axis '+ f'perpendicular to their parent\'s: {axis}')+ else:+ fail(group[0].node, "sibling traffic scopes must share one axis")+ for index, left in enumerate(group):+ for right in group[index + 1:]:+ if overlaps(left, right):+ fail(left.node, f'sibling traffic scopes "{left.identity}" and "{right.identity}" overlap')++ for node in scanner.nodes:+ if root not in node.ancestors() and node is not root:+ continue+ if "data-peering" not in node.attrs:+ continue+ peering = node.attrs.get("data-peering", "")+ source = node.attrs.get("data-from", "")+ target = node.attrs.get("data-to", "")+ if not identity_ok(peering):+ fail(node, "data-peering must be a single XML Name starting with a letter")+ if source not in traffic or target not in traffic:+ fail(node, "peering data-from and data-to must name traffic scopes")+ elif source == target:+ fail(node, "peering must join two distinct traffic scopes")++ check_moved_geometry(scanner, root, checked, fail)+ return findings+++def check_moved_geometry(scanner: Scanner, root: Node, checked: list[Node], fail) -> None:+ """Containment is read from raw x/y/width/height, so nothing may move a+ checked element or any ancestor inside the diagram SVG: no transform+ attribute, no moving inline CSS, no nested viewport, no matching+ stylesheet rule, and no geometry animation."""+ affected: list[Node] = []+ seen: set[int] = set()+ for node in checked:+ for item in (node, *node.ancestors()):+ if item is root:+ break+ if id(item) not in seen:+ seen.add(id(item))+ affected.append(item)+ for node in affected:+ if "transform" in node.attrs:+ fail(node, f'transform attribute on <{node.tag}> {MOVES}')+ for name, value in declarations(node.attrs.get("style", "")).items():+ if moving_property(name, value, inline=True):+ fail(node, f'inline style "{name}" on <{node.tag}> {MOVES}')+ if node.tag == "svg":+ fail(node, f"nested <svg> viewport {MOVES}")++ parent_of = ancestry(scanner)+ for style in (node for node in scanner.nodes if node.tag == "style"):+ text = "".join(part for part in style.content if isinstance(part, str))+ for selector_list, decls in css_rules(text):+ moving = sorted(name for name, value in decls.items()+ if name == "stroke-dasharray" or moving_property(name, value, inline=False))+ if not moving:+ continue+ for selector in split_top(selector_list, ","):+ if selector.strip() and any(rule_may_match(selector, node, parent_of) for node in affected):+ effect = ("overrides the checked stroke-dasharray" if moving == ["stroke-dasharray"]+ else MOVES)+ fail(style, f'<style> rule "{selector.strip()}" sets {", ".join(moving)} on a checked '+ f'element and {effect}')+ break++ by_id = {node.attrs["id"]: node for node in scanner.nodes if node.attrs.get("id")}+ for node in scanner.nodes:+ if node.tag not in {"animate", "animatetransform", "animatemotion", "set"}:+ continue+ if root not in node.ancestors():+ continue+ href = node.attrs.get("href") or node.attrs.get("xlink:href") or ""+ target = by_id.get(href[1:]) if href.startswith("#") else node.parent+ if target is None or id(target) not in seen:+ continue+ attribute = node.attrs.get("attributename", "").strip().lower()+ if node.tag in {"animatetransform", "animatemotion"} or attribute in MOVING_ANIMATION_ATTRS:+ fail(node, f"<{node.tag}> on a checked element {MOVES}")+++def main() -> int:+ parser = argparse.ArgumentParser(description=__doc__)+ parser.add_argument("paths", nargs="*", help="HTML files to check")+ parser.add_argument("--all", action="store_true", help="check every shipped architecture containment example")+ args = parser.parse_args()+ if args.all and args.paths:+ parser.error("use --all or explicit paths, not both")+ targets = sorted(ASSET_DIR.glob("example-*.html")) if args.all or not args.paths else [Path(value) for value in args.paths]+ checked, findings = 0, []+ for path in targets:+ try:+ source = path.read_text(encoding="utf-8")+ except (OSError, UnicodeError) as error:+ print(f"error: cannot read {path}: {error}", file=sys.stderr)+ return 2+ if not looks_like_containment(source):+ continue+ checked += 1+ findings.extend(check_source(path, source))+ if not checked:+ print("error: no architecture containment diagrams found", file=sys.stderr)+ return 1+ for finding in findings:+ print(finding)+ if findings:+ print(f"{len(findings)} architecture containment finding(s) across {checked} file(s).")+ return 1+ print(f"OK architecture containment: {checked} file(s); IDs, parents, geometry, PaaS placement and peerings agree.")+ return 0+++if __name__ == "__main__":+ raise SystemExit(main())diff --git a/skills/diagram-design/SKILL.md b/skills/diagram-design/SKILL.mdindex 45dc9ea..359a320 100644--- a/skills/diagram-design/SKILL.md+++ b/skills/diagram-design/SKILL.md@@ -84,7 +84,7 @@ The pattern owns semantic primitives and its tighter budget; the type owns layou| If you're showing… | Use | Reference ||---|---|---|-| Components + connections in one system snapshot | **Architecture** | [type-architecture.md](references/type-architecture.md) |+| Components + connections in one snapshot; nested admin vs traffic scopes | **Architecture** | [type-architecture.md](references/type-architecture.md) || Structural change between synchronized Before / After topologies, with a Changes ledger | **Architecture delta** | [type-architecture-delta.md](references/type-architecture-delta.md) || Legacy IT landscape by phase or department; shows the *before* state | **IT current-state** | [type-it-state.md](references/type-it-state.md) || Decision logic with branches | **Flowchart** | [type-flowchart.md](references/type-flowchart.md) |diff --git a/skills/diagram-design/assets/example-architecture-containment-dark.html b/skills/diagram-design/assets/example-architecture-containment-dark.htmlnew file mode 100644index 0000000..cd57438--- /dev/null+++ b/skills/diagram-design/assets/example-architecture-containment-dark.html@@ -0,0 +1,205 @@+<!DOCTYPE html>+<html lang="en">+<head>+ <meta charset="UTF-8">+ <meta name="viewport" content="width=device-width, initial-scale=1.0">+ <title>The database is not in the subnet · Architecture</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%; }+ .diagram-container { width: 100%; overflow-x: auto; }+ .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;+ color: var(--color-ink);+ margin-bottom: 1.5rem;+ }+ svg { width: 100%; min-width: 1000px; display: block; }+ @media print {+ .diagram-container { overflow-x: visible; }+ svg { min-width: 0; }+ }+ </style>+</head>+<body>+ <div class="frame">+ <p class="eyebrow">Architecture · containment</p>+ <h1>The database is not in the subnet</h1>+ <div class="diagram-container">+ <svg viewBox="0 0 1000 704" xmlns="http://www.w3.org/2000/svg" role="img"+ aria-labelledby="architecture-containment-dark-title architecture-containment-dark-desc"+ data-grammar="architecture-containment">+ <title id="architecture-containment-dark-title">The database is not in the subnet</title>+ <desc id="architecture-containment-dark-desc">Nested administrative bands hold two peered virtual networks; private endpoints sit inside a subnet while their managed database and vault sit outside every traffic boundary.</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>+ <marker id="arrow" markerWidth="8" markerHeight="6" refX="7" refY="3" orient="auto"><polygon points="0 0, 8 3, 0 6" fill="#bfc0c0"/></marker>+ <marker id="arrow-accent" markerWidth="8" markerHeight="6" refX="7" refY="3" orient="auto"><polygon points="0 0, 8 3, 0 6" fill="#f08a59"/></marker>+ <marker id="arrow-link" markerWidth="8" markerHeight="6" refX="7" refY="3" orient="auto"><polygon points="0 0, 8 3, 0 6" fill="#739fdf"/></marker>+ </defs>++ <rect width="100%" height="100%" fill="#2d3142"/>+ <rect width="100%" height="100%" fill="url(#dots)" opacity="0.55"/>++ <!-- Scopes, outer first. Admin = band (rx=4, dashed). Traffic = box (rx=8, solid). -->+ <rect data-role="bounds" data-scope-id="subscription" data-scope-kind="admin"+ x="40" y="24" width="920" height="600" rx="4"+ fill="rgba(245,245,245,0.015)" stroke="rgba(245,245,245,0.22)" stroke-width="0.8" stroke-dasharray="4,4"/>+ <rect x="56" y="28" width="108" height="12" rx="2" fill="#2d3142"/>+ <text x="110" y="37" fill="#949eb2" font-size="7" font-family="'Geist Mono', monospace"+ text-anchor="middle" letter-spacing="0.14em">SUBSCRIPTION</text>++ <rect data-role="bounds" data-scope-id="rg" data-scope-kind="admin" data-parent="subscription"+ x="56" y="56" width="888" height="552" rx="4"+ fill="rgba(245,245,245,0.02)" stroke="rgba(245,245,245,0.28)" stroke-width="0.8" stroke-dasharray="4,4"/>+ <rect x="72" y="60" width="116" height="12" rx="2" fill="#2d3142"/>+ <text x="130" y="69" fill="#949eb2" font-size="7" font-family="'Geist Mono', monospace"+ text-anchor="middle" letter-spacing="0.14em">RESOURCE GROUP</text>++ <rect data-role="bounds" data-scope-id="vnet-hub" data-scope-kind="traffic" data-parent="rg"+ x="80" y="168" width="400" height="400" rx="8"+ fill="rgba(245,245,245,0.02)" stroke="rgba(245,245,245,0.20)" stroke-width="0.8"/>+ <rect x="96" y="172" width="64" height="12" rx="2" fill="#2d3142"/>+ <text x="128" y="181" fill="#949eb2" font-size="7" font-family="'Geist Mono', monospace"+ text-anchor="middle" letter-spacing="0.14em">VNET-HUB</text>++ <rect data-role="bounds" data-scope-id="vnet-spoke" data-scope-kind="traffic" data-parent="rg"+ x="520" y="168" width="400" height="400" rx="8"+ fill="rgba(245,245,245,0.02)" stroke="rgba(245,245,245,0.20)" stroke-width="0.8"/>+ <rect x="536" y="172" width="80" height="12" rx="2" fill="#2d3142"/>+ <text x="576" y="181" fill="#949eb2" font-size="7" font-family="'Geist Mono', monospace"+ text-anchor="middle" letter-spacing="0.14em">VNET-SPOKE</text>++ <rect data-role="bounds" data-scope-id="snet-app" data-scope-kind="traffic" data-parent="vnet-hub"+ x="104" y="208" width="352" height="336" rx="8"+ fill="rgba(245,245,245,0.03)" stroke="rgba(245,245,245,0.28)" stroke-width="0.8"/>+ <rect x="120" y="212" width="64" height="12" rx="2" fill="#2d3142"/>+ <text x="152" y="221" fill="#949eb2" font-size="7" font-family="'Geist Mono', monospace"+ text-anchor="middle" letter-spacing="0.14em">SNET-APP</text>++ <rect data-role="bounds" data-scope-id="snet-pe" data-scope-kind="traffic" data-parent="vnet-spoke"+ x="544" y="208" width="352" height="336" rx="8"+ fill="rgba(245,245,245,0.03)" stroke="rgba(245,245,245,0.28)" stroke-width="0.8"/>+ <rect x="560" y="212" width="56" height="12" rx="2" fill="#2d3142"/>+ <text x="588" y="221" fill="#949eb2" font-size="7" font-family="'Geist Mono', monospace"+ text-anchor="middle" letter-spacing="0.14em">SNET-PE</text>++ <!-- Paths behind nodes -->+ <line data-peering="hub-spoke" data-from="vnet-hub" data-to="vnet-spoke"+ x1="480" y1="196" x2="520" y2="196"+ stroke="#bfc0c0" stroke-width="1.2" stroke-dasharray="4,3"/>+ <path d="M 360,376 H 496 Q 504,376 504,368 V 320 Q 504,312 512,312 H 564"+ fill="none" stroke="#f08a59" stroke-width="1.4" marker-end="url(#arrow-accent)"/>+ <path d="M 636,280 V 160 Q 636,152 628,152 H 168 Q 160,152 160,144"+ fill="none" stroke="#739fdf" stroke-width="1" stroke-dasharray="4,3" marker-end="url(#arrow-link)"/>+ <path d="M 804,280 V 144 Q 804,136 796,136 H 352 Q 344,136 344,144"+ fill="none" stroke="#739fdf" stroke-width="1" stroke-dasharray="4,3" marker-end="url(#arrow-link)"/>++ <!-- Labels -->+ <rect x="468" y="176" width="64" height="12" rx="2" fill="#2d3142"/>+ <text x="500" y="185" fill="#bfc0c0" font-size="8" font-family="'Geist Mono', monospace" text-anchor="middle" letter-spacing="0.08em">PEERING</text>+ <rect x="400" y="356" width="72" height="12" rx="2" fill="#2d3142"/>+ <text x="436" y="365" fill="#f08a59" font-size="8" font-family="'Geist Mono', monospace" text-anchor="middle" letter-spacing="0.08em">SQL:1433</text>+ <rect x="648" y="200" width="56" height="12" rx="2" fill="#2d3142"/>+ <text x="676" y="209" fill="#739fdf" font-size="8" font-family="'Geist Mono', monospace" text-anchor="middle" letter-spacing="0.08em">PRIVATE</text>+ <rect x="816" y="200" width="56" height="12" rx="2" fill="#2d3142"/>+ <text x="844" y="209" fill="#739fdf" font-size="8" font-family="'Geist Mono', monospace" text-anchor="middle" letter-spacing="0.08em">PRIVATE</text>++ <!-- Managed PaaS — inside the resource group, outside every traffic scope -->+ <g data-node-id="sql" data-kind="managed" data-parent="rg">+ <rect data-role="bounds" x="80" y="80" width="160" height="64" rx="6" fill="#2d3142"/>+ <rect x="80" y="80" width="160" height="64" rx="6" fill="rgba(245,245,245,0.05)" stroke="#bfc0c0" stroke-width="1"/>+ <rect x="88" y="88" width="28" height="12" rx="2" fill="transparent" stroke="rgba(191,192,192,0.50)" stroke-width="0.8"/>+ <text x="102" y="97" fill="#bfc0c0" font-size="7" font-family="'Geist Mono', monospace" text-anchor="middle" letter-spacing="0.08em">DB</text>+ <text x="160" y="116" fill="#f5f5f5" font-size="12" font-weight="600" font-family="'Geist', sans-serif" text-anchor="middle">SQL</text>+ <text x="160" y="132" fill="#bfc0c0" font-size="9" font-family="'Geist Mono', monospace" text-anchor="middle">managed</text>+ </g>+ <g data-node-id="kv" data-kind="managed" data-parent="rg">+ <rect data-role="bounds" x="264" y="80" width="160" height="64" rx="6" fill="#2d3142"/>+ <rect x="264" y="80" width="160" height="64" rx="6" fill="rgba(245,245,245,0.05)" stroke="#bfc0c0" stroke-width="1"/>+ <rect x="272" y="88" width="24" height="12" rx="2" fill="transparent" stroke="rgba(191,192,192,0.50)" stroke-width="0.8"/>+ <text x="284" y="97" fill="#bfc0c0" font-size="7" font-family="'Geist Mono', monospace" text-anchor="middle" letter-spacing="0.08em">KV</text>+ <text x="344" y="116" fill="#f5f5f5" font-size="12" font-weight="600" font-family="'Geist', sans-serif" text-anchor="middle">Key Vault</text>+ <text x="344" y="132" fill="#bfc0c0" font-size="9" font-family="'Geist Mono', monospace" text-anchor="middle">managed</text>+ </g>++ <!-- Compute inside the app subnet -->+ <g data-node-id="app" data-kind="compute" data-parent="snet-app">+ <rect data-role="bounds" x="200" y="344" width="160" height="64" rx="6" fill="#2d3142"/>+ <rect x="200" y="344" width="160" height="64" rx="6" fill="rgba(240,138,89,0.08)" stroke="#f08a59" stroke-width="1"/>+ <rect x="208" y="352" width="32" height="12" rx="2" fill="transparent" stroke="rgba(240,138,89,0.50)" stroke-width="0.8"/>+ <text x="224" y="361" fill="#f08a59" font-size="7" font-family="'Geist Mono', monospace" text-anchor="middle" letter-spacing="0.08em">APP</text>+ <text x="280" y="380" fill="#f5f5f5" font-size="12" font-weight="600" font-family="'Geist', sans-serif" text-anchor="middle">Checkout API</text>+ <text x="280" y="396" fill="#bfc0c0" font-size="9" font-family="'Geist Mono', monospace" text-anchor="middle">snet-app</text>+ </g>++ <!-- Private endpoints inside the spoke subnet -->+ <g data-node-id="pe-sql" data-kind="endpoint" data-parent="snet-pe" data-target="sql">+ <rect data-role="bounds" x="564" y="280" width="144" height="64" rx="6" fill="#2d3142"/>+ <rect x="564" y="280" width="144" height="64" rx="6" fill="rgba(245,245,245,0.04)" stroke="#f5f5f5" stroke-width="1"/>+ <rect x="572" y="288" width="24" height="12" rx="2" fill="transparent" stroke="rgba(245,245,245,0.40)" stroke-width="0.8"/>+ <text x="584" y="297" fill="#f5f5f5" font-size="7" font-family="'Geist Mono', monospace" text-anchor="middle" letter-spacing="0.08em">PE</text>+ <text x="636" y="316" fill="#f5f5f5" font-size="12" font-weight="600" font-family="'Geist', sans-serif" text-anchor="middle">PE · SQL</text>+ <text x="636" y="332" fill="#bfc0c0" font-size="9" font-family="'Geist Mono', monospace" text-anchor="middle">snet-pe</text>+ </g>+ <g data-node-id="pe-kv" data-kind="endpoint" data-parent="snet-pe" data-target="kv">+ <rect data-role="bounds" x="732" y="280" width="144" height="64" rx="6" fill="#2d3142"/>+ <rect x="732" y="280" width="144" height="64" rx="6" fill="rgba(245,245,245,0.04)" stroke="#f5f5f5" stroke-width="1"/>+ <rect x="740" y="288" width="24" height="12" rx="2" fill="transparent" stroke="rgba(245,245,245,0.40)" stroke-width="0.8"/>+ <text x="752" y="297" fill="#f5f5f5" font-size="7" font-family="'Geist Mono', monospace" text-anchor="middle" letter-spacing="0.08em">PE</text>+ <text x="804" y="316" fill="#f5f5f5" font-size="12" font-weight="600" font-family="'Geist', sans-serif" text-anchor="middle">PE · Vault</text>+ <text x="804" y="332" fill="#bfc0c0" font-size="9" font-family="'Geist Mono', monospace" text-anchor="middle">snet-pe</text>+ </g>++ <!-- Legend -->+ <line x1="80" y1="640" x2="920" y2="640" stroke="rgba(245,245,245,0.10)" stroke-width="0.8"/>+ <text x="80" y="656" fill="#bfc0c0" font-size="8" font-family="'Geist Mono', monospace" letter-spacing="0.18em">LEGEND</text>+ <rect x="80" y="664" width="28" height="10" rx="2" fill="rgba(245,245,245,0.015)" stroke="rgba(245,245,245,0.22)" stroke-width="0.8" stroke-dasharray="4,4"/>+ <text x="116" y="672" fill="#bfc0c0" font-size="8.5" font-family="'Geist', sans-serif">Admin band</text>+ <rect x="220" y="664" width="28" height="10" rx="2" fill="rgba(245,245,245,0.02)" stroke="rgba(245,245,245,0.20)" stroke-width="0.8"/>+ <text x="256" y="672" fill="#bfc0c0" font-size="8.5" font-family="'Geist', sans-serif">Traffic box</text>+ <rect x="360" y="664" width="14" height="10" rx="2" fill="rgba(245,245,245,0.05)" stroke="#bfc0c0" stroke-width="1"/>+ <text x="380" y="672" fill="#bfc0c0" font-size="8.5" font-family="'Geist', sans-serif">Managed PaaS</text>+ <rect x="500" y="664" width="14" height="10" rx="2" fill="rgba(245,245,245,0.04)" stroke="#f5f5f5" stroke-width="1"/>+ <text x="520" y="672" fill="#bfc0c0" font-size="8.5" font-family="'Geist', sans-serif">Private endpoint</text>+ <rect x="656" y="664" width="14" height="10" rx="2" fill="rgba(240,138,89,0.08)" stroke="#f08a59" stroke-width="1"/>+ <text x="676" y="672" fill="#bfc0c0" font-size="8.5" font-family="'Geist', sans-serif">Workload</text>+ </svg>+ </div>+ </div>+</body>+</html>diff --git a/skills/diagram-design/assets/example-architecture-containment-full.html b/skills/diagram-design/assets/example-architecture-containment-full.htmlnew file mode 100644index 0000000..0b9fdf3--- /dev/null+++ b/skills/diagram-design/assets/example-architecture-containment-full.html@@ -0,0 +1,224 @@+<!DOCTYPE html>+<html lang="en">+<head>+ <meta charset="UTF-8">+ <meta name="viewport" content="width=device-width, initial-scale=1.0">+ <title>The database is not in the subnet · Architecture</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: #5a6580;+ --color-rule: rgba(45,49,66,0.12);+ --color-accent: #bf4520; --color-accent-tint: rgba(191,69,32,0.08);+ --color-link: #2e5aa8;+ --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: 1000px; display: block; }+ .cards { display: grid; grid-template-columns: 1.1fr 1fr 0.9fr; gap: 1rem; margin-top: 1.5rem; }+ @media (max-width: 820px) { .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.ink { background: var(--color-ink); } .card-dot.muted { background: var(--color-muted); } .card-dot.coral { background: var(--color-accent); }+ .card h3 { font-size: 0.875rem; font-weight: 600; letter-spacing: -0.005em; }+ .card p, .card ul { color: var(--color-muted); font-size: 0.8125rem; line-height: 1.55; list-style: none; }+ .card li { margin-bottom: 0.3rem; padding-left: 0.875rem; position: relative; }+ .card li::before { content: '—'; position: absolute; left: 0; color: rgba(45,49,66,0.25); font-size: 0.75rem; }+ .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-soft); display: flex; justify-content: space-between; flex-wrap: wrap; gap: 0.5rem; }+ @media print {+ .diagram-container { overflow-x: visible; }+ svg { min-width: 0; }+ }+ </style>+</head>+<body>+ <div class="container">+ <div class="header">+ <p class="header-eyebrow">Architecture · containment</p>+ <h1>The database is not in the subnet</h1>+ <p class="subtitle">Administrative bands hold the subscription and resource group. Traffic boxes hold the networks. Managed SQL and Key Vault sit in the group, not behind a subnet's rules — only their private endpoints do.</p>+ </div>++ <div class="diagram-container">+ <svg viewBox="0 0 1000 704" xmlns="http://www.w3.org/2000/svg" role="img"+ aria-labelledby="architecture-containment-full-title architecture-containment-full-desc"+ data-grammar="architecture-containment">+ <title id="architecture-containment-full-title">The database is not in the subnet</title>+ <desc id="architecture-containment-full-desc">Nested administrative bands hold two peered virtual networks; private endpoints sit inside a subnet while their managed database and vault sit outside every traffic boundary.</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>+ <marker id="arrow" markerWidth="8" markerHeight="6" refX="7" refY="3" orient="auto"><polygon points="0 0, 8 3, 0 6" fill="#4f5d75"/></marker>+ <marker id="arrow-accent" markerWidth="8" markerHeight="6" refX="7" refY="3" orient="auto"><polygon points="0 0, 8 3, 0 6" fill="#bf4520"/></marker>+ <marker id="arrow-link" markerWidth="8" markerHeight="6" refX="7" refY="3" orient="auto"><polygon points="0 0, 8 3, 0 6" fill="#2e5aa8"/></marker>+ </defs>++ <rect width="100%" height="100%" fill="#f5f5f5"/>+ <rect width="100%" height="100%" fill="url(#dots)" opacity="0.55"/>++ <!-- Scopes, outer first. Admin = band (rx=4, dashed). Traffic = box (rx=8, solid). -->+ <rect data-role="bounds" data-scope-id="subscription" data-scope-kind="admin"+ x="40" y="24" width="920" height="600" rx="4"+ fill="rgba(45,49,66,0.015)" stroke="rgba(45,49,66,0.22)" stroke-width="0.8" stroke-dasharray="4,4"/>+ <rect x="56" y="28" width="108" height="12" rx="2" fill="#f5f5f5"/>+ <text x="110" y="37" fill="#5a6580" font-size="7" font-family="'Geist Mono', monospace"+ text-anchor="middle" letter-spacing="0.14em">SUBSCRIPTION</text>++ <rect data-role="bounds" data-scope-id="rg" data-scope-kind="admin" data-parent="subscription"+ x="56" y="56" width="888" height="552" rx="4"+ fill="rgba(45,49,66,0.02)" stroke="rgba(45,49,66,0.28)" stroke-width="0.8" stroke-dasharray="4,4"/>+ <rect x="72" y="60" width="116" height="12" rx="2" fill="#f5f5f5"/>+ <text x="130" y="69" fill="#5a6580" font-size="7" font-family="'Geist Mono', monospace"+ text-anchor="middle" letter-spacing="0.14em">RESOURCE GROUP</text>++ <rect data-role="bounds" data-scope-id="vnet-hub" data-scope-kind="traffic" data-parent="rg"+ x="80" y="168" width="400" height="400" rx="8"+ fill="rgba(45,49,66,0.02)" stroke="rgba(45,49,66,0.20)" stroke-width="0.8"/>+ <rect x="96" y="172" width="64" height="12" rx="2" fill="#f5f5f5"/>+ <text x="128" y="181" fill="#5a6580" font-size="7" font-family="'Geist Mono', monospace"+ text-anchor="middle" letter-spacing="0.14em">VNET-HUB</text>++ <rect data-role="bounds" data-scope-id="vnet-spoke" data-scope-kind="traffic" data-parent="rg"+ x="520" y="168" width="400" height="400" rx="8"+ fill="rgba(45,49,66,0.02)" stroke="rgba(45,49,66,0.20)" stroke-width="0.8"/>+ <rect x="536" y="172" width="80" height="12" rx="2" fill="#f5f5f5"/>+ <text x="576" y="181" fill="#5a6580" font-size="7" font-family="'Geist Mono', monospace"+ text-anchor="middle" letter-spacing="0.14em">VNET-SPOKE</text>++ <rect data-role="bounds" data-scope-id="snet-app" data-scope-kind="traffic" data-parent="vnet-hub"+ x="104" y="208" width="352" height="336" rx="8"+ fill="rgba(45,49,66,0.03)" stroke="rgba(45,49,66,0.28)" stroke-width="0.8"/>+ <rect x="120" y="212" width="64" height="12" rx="2" fill="#f5f5f5"/>+ <text x="152" y="221" fill="#5a6580" font-size="7" font-family="'Geist Mono', monospace"+ text-anchor="middle" letter-spacing="0.14em">SNET-APP</text>++ <rect data-role="bounds" data-scope-id="snet-pe" data-scope-kind="traffic" data-parent="vnet-spoke"+ x="544" y="208" width="352" height="336" rx="8"+ fill="rgba(45,49,66,0.03)" stroke="rgba(45,49,66,0.28)" stroke-width="0.8"/>+ <rect x="560" y="212" width="56" height="12" rx="2" fill="#f5f5f5"/>+ <text x="588" y="221" fill="#5a6580" font-size="7" font-family="'Geist Mono', monospace"+ text-anchor="middle" letter-spacing="0.14em">SNET-PE</text>++ <!-- Paths behind nodes -->+ <line data-peering="hub-spoke" data-from="vnet-hub" data-to="vnet-spoke"+ x1="480" y1="196" x2="520" y2="196"+ stroke="#4f5d75" stroke-width="1.2" stroke-dasharray="4,3"/>+ <path d="M 360,376 H 496 Q 504,376 504,368 V 320 Q 504,312 512,312 H 564"+ fill="none" stroke="#bf4520" stroke-width="1.4" marker-end="url(#arrow-accent)"/>+ <path d="M 636,280 V 160 Q 636,152 628,152 H 168 Q 160,152 160,144"+ fill="none" stroke="#2e5aa8" stroke-width="1" stroke-dasharray="4,3" marker-end="url(#arrow-link)"/>+ <path d="M 804,280 V 144 Q 804,136 796,136 H 352 Q 344,136 344,144"+ fill="none" stroke="#2e5aa8" stroke-width="1" stroke-dasharray="4,3" marker-end="url(#arrow-link)"/>++ <!-- Labels -->+ <rect x="468" y="176" width="64" height="12" rx="2" fill="#f5f5f5"/>+ <text x="500" y="185" fill="#4f5d75" font-size="8" font-family="'Geist Mono', monospace" text-anchor="middle" letter-spacing="0.08em">PEERING</text>+ <rect x="400" y="356" width="72" height="12" rx="2" fill="#f5f5f5"/>+ <text x="436" y="365" fill="#bf4520" font-size="8" font-family="'Geist Mono', monospace" text-anchor="middle" letter-spacing="0.08em">SQL:1433</text>+ <rect x="648" y="200" width="56" height="12" rx="2" fill="#f5f5f5"/>+ <text x="676" y="209" fill="#2e5aa8" font-size="8" font-family="'Geist Mono', monospace" text-anchor="middle" letter-spacing="0.08em">PRIVATE</text>+ <rect x="816" y="200" width="56" height="12" rx="2" fill="#f5f5f5"/>+ <text x="844" y="209" fill="#2e5aa8" font-size="8" font-family="'Geist Mono', monospace" text-anchor="middle" letter-spacing="0.08em">PRIVATE</text>++ <!-- Managed PaaS — inside the resource group, outside every traffic scope -->+ <g data-node-id="sql" data-kind="managed" data-parent="rg">+ <rect data-role="bounds" x="80" y="80" width="160" height="64" rx="6" fill="#f5f5f5"/>+ <rect x="80" y="80" width="160" height="64" rx="6" fill="rgba(45,49,66,0.05)" stroke="#4f5d75" stroke-width="1"/>+ <rect x="88" y="88" width="28" height="12" rx="2" fill="transparent" stroke="rgba(79,93,117,0.50)" stroke-width="0.8"/>+ <text x="102" y="97" fill="#4f5d75" font-size="7" font-family="'Geist Mono', monospace" text-anchor="middle" letter-spacing="0.08em">DB</text>+ <text x="160" y="116" fill="#2d3142" font-size="12" font-weight="600" font-family="'Geist', sans-serif" text-anchor="middle">SQL</text>+ <text x="160" y="132" fill="#4f5d75" font-size="9" font-family="'Geist Mono', monospace" text-anchor="middle">managed</text>+ </g>+ <g data-node-id="kv" data-kind="managed" data-parent="rg">+ <rect data-role="bounds" x="264" y="80" width="160" height="64" rx="6" fill="#f5f5f5"/>+ <rect x="264" y="80" width="160" height="64" rx="6" fill="rgba(45,49,66,0.05)" stroke="#4f5d75" stroke-width="1"/>+ <rect x="272" y="88" width="24" height="12" rx="2" fill="transparent" stroke="rgba(79,93,117,0.50)" stroke-width="0.8"/>+ <text x="284" y="97" fill="#4f5d75" font-size="7" font-family="'Geist Mono', monospace" text-anchor="middle" letter-spacing="0.08em">KV</text>+ <text x="344" y="116" fill="#2d3142" font-size="12" font-weight="600" font-family="'Geist', sans-serif" text-anchor="middle">Key Vault</text>+ <text x="344" y="132" fill="#4f5d75" font-size="9" font-family="'Geist Mono', monospace" text-anchor="middle">managed</text>+ </g>++ <!-- Compute inside the app subnet -->+ <g data-node-id="app" data-kind="compute" data-parent="snet-app">+ <rect data-role="bounds" x="200" y="344" width="160" height="64" rx="6" fill="#f5f5f5"/>+ <rect x="200" y="344" width="160" height="64" rx="6" fill="rgba(191,69,32,0.08)" stroke="#bf4520" stroke-width="1"/>+ <rect x="208" y="352" width="32" height="12" rx="2" fill="transparent" stroke="rgba(191,69,32,0.50)" stroke-width="0.8"/>+ <text x="224" y="361" fill="#bf4520" font-size="7" font-family="'Geist Mono', monospace" text-anchor="middle" letter-spacing="0.08em">APP</text>+ <text x="280" y="380" fill="#2d3142" font-size="12" font-weight="600" font-family="'Geist', sans-serif" text-anchor="middle">Checkout API</text>+ <text x="280" y="396" fill="#4f5d75" font-size="9" font-family="'Geist Mono', monospace" text-anchor="middle">snet-app</text>+ </g>++ <!-- Private endpoints inside the spoke subnet -->+ <g data-node-id="pe-sql" data-kind="endpoint" data-parent="snet-pe" data-target="sql">+ <rect data-role="bounds" x="564" y="280" width="144" height="64" rx="6" fill="#f5f5f5"/>+ <rect x="564" y="280" width="144" height="64" rx="6" fill="#ffffff" stroke="#2d3142" stroke-width="1"/>+ <rect x="572" y="288" width="24" height="12" rx="2" fill="transparent" stroke="rgba(45,49,66,0.40)" stroke-width="0.8"/>+ <text x="584" y="297" fill="#2d3142" font-size="7" font-family="'Geist Mono', monospace" text-anchor="middle" letter-spacing="0.08em">PE</text>+ <text x="636" y="316" fill="#2d3142" font-size="12" font-weight="600" font-family="'Geist', sans-serif" text-anchor="middle">PE · SQL</text>+ <text x="636" y="332" fill="#4f5d75" font-size="9" font-family="'Geist Mono', monospace" text-anchor="middle">snet-pe</text>+ </g>+ <g data-node-id="pe-kv" data-kind="endpoint" data-parent="snet-pe" data-target="kv">+ <rect data-role="bounds" x="732" y="280" width="144" height="64" rx="6" fill="#f5f5f5"/>+ <rect x="732" y="280" width="144" height="64" rx="6" fill="#ffffff" stroke="#2d3142" stroke-width="1"/>+ <rect x="740" y="288" width="24" height="12" rx="2" fill="transparent" stroke="rgba(45,49,66,0.40)" stroke-width="0.8"/>+ <text x="752" y="297" fill="#2d3142" font-size="7" font-family="'Geist Mono', monospace" text-anchor="middle" letter-spacing="0.08em">PE</text>+ <text x="804" y="316" fill="#2d3142" font-size="12" font-weight="600" font-family="'Geist', sans-serif" text-anchor="middle">PE · Vault</text>+ <text x="804" y="332" fill="#4f5d75" font-size="9" font-family="'Geist Mono', monospace" text-anchor="middle">snet-pe</text>+ </g>++ <!-- Legend -->+ <line x1="80" y1="640" x2="920" y2="640" stroke="rgba(45,49,66,0.10)" stroke-width="0.8"/>+ <text x="80" y="656" fill="#4f5d75" font-size="8" font-family="'Geist Mono', monospace" letter-spacing="0.18em">LEGEND</text>+ <rect x="80" y="664" width="28" height="10" rx="2" fill="rgba(45,49,66,0.015)" stroke="rgba(45,49,66,0.22)" stroke-width="0.8" stroke-dasharray="4,4"/>+ <text x="116" y="672" fill="#4f5d75" font-size="8.5" font-family="'Geist', sans-serif">Admin band</text>+ <rect x="220" y="664" width="28" height="10" rx="2" fill="rgba(45,49,66,0.02)" stroke="rgba(45,49,66,0.20)" stroke-width="0.8"/>+ <text x="256" y="672" fill="#4f5d75" font-size="8.5" font-family="'Geist', sans-serif">Traffic box</text>+ <rect x="360" y="664" width="14" height="10" rx="2" fill="rgba(45,49,66,0.05)" stroke="#4f5d75" stroke-width="1"/>+ <text x="380" y="672" fill="#4f5d75" font-size="8.5" font-family="'Geist', sans-serif">Managed PaaS</text>+ <rect x="500" y="664" width="14" height="10" rx="2" fill="#ffffff" stroke="#2d3142" stroke-width="1"/>+ <text x="520" y="672" fill="#4f5d75" font-size="8.5" font-family="'Geist', sans-serif">Private endpoint</text>+ <rect x="656" y="664" width="14" height="10" rx="2" fill="rgba(191,69,32,0.08)" stroke="#bf4520" stroke-width="1"/>+ <text x="676" y="672" fill="#4f5d75" font-size="8.5" font-family="'Geist', sans-serif">Workload</text>+ </svg>+ </div>++ <div class="cards">+ <div class="card">+ <p class="eyebrow">THE HEADLINE</p>+ <div class="card-header"><span class="card-dot coral"></span><h3>The database is not in the subnet</h3></div>+ <p>SQL and Key Vault belong to the resource group. Packets reach them through private endpoints in the spoke subnet, not because the databases sit behind that subnet's rules.</p>+ </div>+ <div class="card">+ <div class="card-header"><span class="card-dot ink"></span><h3>What sits where</h3></div>+ <ul>+ <li>Checkout API in snet-app</li>+ <li>Private endpoints in snet-pe</li>+ <li>Hub and spoke joined by peering</li>+ </ul>+ </div>+ <div class="card">+ <div class="card-header"><span class="card-dot muted"></span><h3>Two shapes, two meanings</h3></div>+ <p>Dashed rx=4 bands are administrative. Solid rx=8 boxes are traffic. Greyscale still has to tell them apart.</p>+ </div>+ </div>++ <div class="footer">+ <span>checkout api · architecture containment</span>+ <span>example · schematic skill</span>+ </div>+ </div>+</body>+</html>diff --git a/skills/diagram-design/assets/example-architecture-containment.html b/skills/diagram-design/assets/example-architecture-containment.htmlnew file mode 100644index 0000000..ab1dff6--- /dev/null+++ b/skills/diagram-design/assets/example-architecture-containment.html@@ -0,0 +1,205 @@+<!DOCTYPE html>+<html lang="en">+<head>+ <meta charset="UTF-8">+ <meta name="viewport" content="width=device-width, initial-scale=1.0">+ <title>The database is not in the subnet · Architecture</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: #bf4520;+ --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%; }+ .diagram-container { width: 100%; overflow-x: auto; }+ .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;+ color: var(--color-ink);+ margin-bottom: 1.5rem;+ }+ svg { width: 100%; min-width: 1000px; display: block; }+ @media print {+ .diagram-container { overflow-x: visible; }+ svg { min-width: 0; }+ }+ </style>+</head>+<body>+ <div class="frame">+ <p class="eyebrow">Architecture · containment</p>+ <h1>The database is not in the subnet</h1>+ <div class="diagram-container">+ <svg viewBox="0 0 1000 704" xmlns="http://www.w3.org/2000/svg" role="img"+ aria-labelledby="architecture-containment-title architecture-containment-desc"+ data-grammar="architecture-containment">+ <title id="architecture-containment-title">The database is not in the subnet</title>+ <desc id="architecture-containment-desc">Nested administrative bands hold two peered virtual networks; private endpoints sit inside a subnet while their managed database and vault sit outside every traffic boundary.</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>+ <marker id="arrow" markerWidth="8" markerHeight="6" refX="7" refY="3" orient="auto"><polygon points="0 0, 8 3, 0 6" fill="#4f5d75"/></marker>+ <marker id="arrow-accent" markerWidth="8" markerHeight="6" refX="7" refY="3" orient="auto"><polygon points="0 0, 8 3, 0 6" fill="#bf4520"/></marker>+ <marker id="arrow-link" markerWidth="8" markerHeight="6" refX="7" refY="3" orient="auto"><polygon points="0 0, 8 3, 0 6" fill="#2e5aa8"/></marker>+ </defs>++ <rect width="100%" height="100%" fill="#f5f5f5"/>+ <rect width="100%" height="100%" fill="url(#dots)" opacity="0.55"/>++ <!-- Scopes, outer first. Admin = band (rx=4, dashed). Traffic = box (rx=8, solid). -->+ <rect data-role="bounds" data-scope-id="subscription" data-scope-kind="admin"+ x="40" y="24" width="920" height="600" rx="4"+ fill="rgba(45,49,66,0.015)" stroke="rgba(45,49,66,0.22)" stroke-width="0.8" stroke-dasharray="4,4"/>+ <rect x="56" y="28" width="108" height="12" rx="2" fill="#f5f5f5"/>+ <text x="110" y="37" fill="#5a6580" font-size="7" font-family="'Geist Mono', monospace"+ text-anchor="middle" letter-spacing="0.14em">SUBSCRIPTION</text>++ <rect data-role="bounds" data-scope-id="rg" data-scope-kind="admin" data-parent="subscription"+ x="56" y="56" width="888" height="552" rx="4"+ fill="rgba(45,49,66,0.02)" stroke="rgba(45,49,66,0.28)" stroke-width="0.8" stroke-dasharray="4,4"/>+ <rect x="72" y="60" width="116" height="12" rx="2" fill="#f5f5f5"/>+ <text x="130" y="69" fill="#5a6580" font-size="7" font-family="'Geist Mono', monospace"+ text-anchor="middle" letter-spacing="0.14em">RESOURCE GROUP</text>++ <rect data-role="bounds" data-scope-id="vnet-hub" data-scope-kind="traffic" data-parent="rg"+ x="80" y="168" width="400" height="400" rx="8"+ fill="rgba(45,49,66,0.02)" stroke="rgba(45,49,66,0.20)" stroke-width="0.8"/>+ <rect x="96" y="172" width="64" height="12" rx="2" fill="#f5f5f5"/>+ <text x="128" y="181" fill="#5a6580" font-size="7" font-family="'Geist Mono', monospace"+ text-anchor="middle" letter-spacing="0.14em">VNET-HUB</text>++ <rect data-role="bounds" data-scope-id="vnet-spoke" data-scope-kind="traffic" data-parent="rg"+ x="520" y="168" width="400" height="400" rx="8"+ fill="rgba(45,49,66,0.02)" stroke="rgba(45,49,66,0.20)" stroke-width="0.8"/>+ <rect x="536" y="172" width="80" height="12" rx="2" fill="#f5f5f5"/>+ <text x="576" y="181" fill="#5a6580" font-size="7" font-family="'Geist Mono', monospace"+ text-anchor="middle" letter-spacing="0.14em">VNET-SPOKE</text>++ <rect data-role="bounds" data-scope-id="snet-app" data-scope-kind="traffic" data-parent="vnet-hub"+ x="104" y="208" width="352" height="336" rx="8"+ fill="rgba(45,49,66,0.03)" stroke="rgba(45,49,66,0.28)" stroke-width="0.8"/>+ <rect x="120" y="212" width="64" height="12" rx="2" fill="#f5f5f5"/>+ <text x="152" y="221" fill="#5a6580" font-size="7" font-family="'Geist Mono', monospace"+ text-anchor="middle" letter-spacing="0.14em">SNET-APP</text>++ <rect data-role="bounds" data-scope-id="snet-pe" data-scope-kind="traffic" data-parent="vnet-spoke"+ x="544" y="208" width="352" height="336" rx="8"+ fill="rgba(45,49,66,0.03)" stroke="rgba(45,49,66,0.28)" stroke-width="0.8"/>+ <rect x="560" y="212" width="56" height="12" rx="2" fill="#f5f5f5"/>+ <text x="588" y="221" fill="#5a6580" font-size="7" font-family="'Geist Mono', monospace"+ text-anchor="middle" letter-spacing="0.14em">SNET-PE</text>++ <!-- Paths behind nodes -->+ <line data-peering="hub-spoke" data-from="vnet-hub" data-to="vnet-spoke"+ x1="480" y1="196" x2="520" y2="196"+ stroke="#4f5d75" stroke-width="1.2" stroke-dasharray="4,3"/>+ <path d="M 360,376 H 496 Q 504,376 504,368 V 320 Q 504,312 512,312 H 564"+ fill="none" stroke="#bf4520" stroke-width="1.4" marker-end="url(#arrow-accent)"/>+ <path d="M 636,280 V 160 Q 636,152 628,152 H 168 Q 160,152 160,144"+ fill="none" stroke="#2e5aa8" stroke-width="1" stroke-dasharray="4,3" marker-end="url(#arrow-link)"/>+ <path d="M 804,280 V 144 Q 804,136 796,136 H 352 Q 344,136 344,144"+ fill="none" stroke="#2e5aa8" stroke-width="1" stroke-dasharray="4,3" marker-end="url(#arrow-link)"/>++ <!-- Labels -->+ <rect x="468" y="176" width="64" height="12" rx="2" fill="#f5f5f5"/>+ <text x="500" y="185" fill="#4f5d75" font-size="8" font-family="'Geist Mono', monospace" text-anchor="middle" letter-spacing="0.08em">PEERING</text>+ <rect x="400" y="356" width="72" height="12" rx="2" fill="#f5f5f5"/>+ <text x="436" y="365" fill="#bf4520" font-size="8" font-family="'Geist Mono', monospace" text-anchor="middle" letter-spacing="0.08em">SQL:1433</text>+ <rect x="648" y="200" width="56" height="12" rx="2" fill="#f5f5f5"/>+ <text x="676" y="209" fill="#2e5aa8" font-size="8" font-family="'Geist Mono', monospace" text-anchor="middle" letter-spacing="0.08em">PRIVATE</text>+ <rect x="816" y="200" width="56" height="12" rx="2" fill="#f5f5f5"/>+ <text x="844" y="209" fill="#2e5aa8" font-size="8" font-family="'Geist Mono', monospace" text-anchor="middle" letter-spacing="0.08em">PRIVATE</text>++ <!-- Managed PaaS — inside the resource group, outside every traffic scope -->+ <g data-node-id="sql" data-kind="managed" data-parent="rg">+ <rect data-role="bounds" x="80" y="80" width="160" height="64" rx="6" fill="#f5f5f5"/>+ <rect x="80" y="80" width="160" height="64" rx="6" fill="rgba(45,49,66,0.05)" stroke="#4f5d75" stroke-width="1"/>+ <rect x="88" y="88" width="28" height="12" rx="2" fill="transparent" stroke="rgba(79,93,117,0.50)" stroke-width="0.8"/>+ <text x="102" y="97" fill="#4f5d75" font-size="7" font-family="'Geist Mono', monospace" text-anchor="middle" letter-spacing="0.08em">DB</text>+ <text x="160" y="116" fill="#2d3142" font-size="12" font-weight="600" font-family="'Geist', sans-serif" text-anchor="middle">SQL</text>+ <text x="160" y="132" fill="#4f5d75" font-size="9" font-family="'Geist Mono', monospace" text-anchor="middle">managed</text>+ </g>+ <g data-node-id="kv" data-kind="managed" data-parent="rg">+ <rect data-role="bounds" x="264" y="80" width="160" height="64" rx="6" fill="#f5f5f5"/>+ <rect x="264" y="80" width="160" height="64" rx="6" fill="rgba(45,49,66,0.05)" stroke="#4f5d75" stroke-width="1"/>+ <rect x="272" y="88" width="24" height="12" rx="2" fill="transparent" stroke="rgba(79,93,117,0.50)" stroke-width="0.8"/>+ <text x="284" y="97" fill="#4f5d75" font-size="7" font-family="'Geist Mono', monospace" text-anchor="middle" letter-spacing="0.08em">KV</text>+ <text x="344" y="116" fill="#2d3142" font-size="12" font-weight="600" font-family="'Geist', sans-serif" text-anchor="middle">Key Vault</text>+ <text x="344" y="132" fill="#4f5d75" font-size="9" font-family="'Geist Mono', monospace" text-anchor="middle">managed</text>+ </g>++ <!-- Compute inside the app subnet -->+ <g data-node-id="app" data-kind="compute" data-parent="snet-app">+ <rect data-role="bounds" x="200" y="344" width="160" height="64" rx="6" fill="#f5f5f5"/>+ <rect x="200" y="344" width="160" height="64" rx="6" fill="rgba(191,69,32,0.08)" stroke="#bf4520" stroke-width="1"/>+ <rect x="208" y="352" width="32" height="12" rx="2" fill="transparent" stroke="rgba(191,69,32,0.50)" stroke-width="0.8"/>+ <text x="224" y="361" fill="#bf4520" font-size="7" font-family="'Geist Mono', monospace" text-anchor="middle" letter-spacing="0.08em">APP</text>+ <text x="280" y="380" fill="#2d3142" font-size="12" font-weight="600" font-family="'Geist', sans-serif" text-anchor="middle">Checkout API</text>+ <text x="280" y="396" fill="#4f5d75" font-size="9" font-family="'Geist Mono', monospace" text-anchor="middle">snet-app</text>+ </g>++ <!-- Private endpoints inside the spoke subnet -->+ <g data-node-id="pe-sql" data-kind="endpoint" data-parent="snet-pe" data-target="sql">+ <rect data-role="bounds" x="564" y="280" width="144" height="64" rx="6" fill="#f5f5f5"/>+ <rect x="564" y="280" width="144" height="64" rx="6" fill="#ffffff" stroke="#2d3142" stroke-width="1"/>+ <rect x="572" y="288" width="24" height="12" rx="2" fill="transparent" stroke="rgba(45,49,66,0.40)" stroke-width="0.8"/>+ <text x="584" y="297" fill="#2d3142" font-size="7" font-family="'Geist Mono', monospace" text-anchor="middle" letter-spacing="0.08em">PE</text>+ <text x="636" y="316" fill="#2d3142" font-size="12" font-weight="600" font-family="'Geist', sans-serif" text-anchor="middle">PE · SQL</text>+ <text x="636" y="332" fill="#4f5d75" font-size="9" font-family="'Geist Mono', monospace" text-anchor="middle">snet-pe</text>+ </g>+ <g data-node-id="pe-kv" data-kind="endpoint" data-parent="snet-pe" data-target="kv">+ <rect data-role="bounds" x="732" y="280" width="144" height="64" rx="6" fill="#f5f5f5"/>+ <rect x="732" y="280" width="144" height="64" rx="6" fill="#ffffff" stroke="#2d3142" stroke-width="1"/>+ <rect x="740" y="288" width="24" height="12" rx="2" fill="transparent" stroke="rgba(45,49,66,0.40)" stroke-width="0.8"/>+ <text x="752" y="297" fill="#2d3142" font-size="7" font-family="'Geist Mono', monospace" text-anchor="middle" letter-spacing="0.08em">PE</text>+ <text x="804" y="316" fill="#2d3142" font-size="12" font-weight="600" font-family="'Geist', sans-serif" text-anchor="middle">PE · Vault</text>+ <text x="804" y="332" fill="#4f5d75" font-size="9" font-family="'Geist Mono', monospace" text-anchor="middle">snet-pe</text>+ </g>++ <!-- Legend -->+ <line x1="80" y1="640" x2="920" y2="640" stroke="rgba(45,49,66,0.10)" stroke-width="0.8"/>+ <text x="80" y="656" fill="#4f5d75" font-size="8" font-family="'Geist Mono', monospace" letter-spacing="0.18em">LEGEND</text>+ <rect x="80" y="664" width="28" height="10" rx="2" fill="rgba(45,49,66,0.015)" stroke="rgba(45,49,66,0.22)" stroke-width="0.8" stroke-dasharray="4,4"/>+ <text x="116" y="672" fill="#4f5d75" font-size="8.5" font-family="'Geist', sans-serif">Admin band</text>+ <rect x="220" y="664" width="28" height="10" rx="2" fill="rgba(45,49,66,0.02)" stroke="rgba(45,49,66,0.20)" stroke-width="0.8"/>+ <text x="256" y="672" fill="#4f5d75" font-size="8.5" font-family="'Geist', sans-serif">Traffic box</text>+ <rect x="360" y="664" width="14" height="10" rx="2" fill="rgba(45,49,66,0.05)" stroke="#4f5d75" stroke-width="1"/>+ <text x="380" y="672" fill="#4f5d75" font-size="8.5" font-family="'Geist', sans-serif">Managed PaaS</text>+ <rect x="500" y="664" width="14" height="10" rx="2" fill="#ffffff" stroke="#2d3142" stroke-width="1"/>+ <text x="520" y="672" fill="#4f5d75" font-size="8.5" font-family="'Geist', sans-serif">Private endpoint</text>+ <rect x="656" y="664" width="14" height="10" rx="2" fill="rgba(191,69,32,0.08)" stroke="#bf4520" stroke-width="1"/>+ <text x="676" y="672" fill="#4f5d75" font-size="8.5" font-family="'Geist', sans-serif">Workload</text>+ </svg>+ </div>+ </div>+</body>+</html>diff --git a/skills/diagram-design/assets/index.html b/skills/diagram-design/assets/index.htmlindex 6841ad6..07284fd 100644--- a/skills/diagram-design/assets/index.html+++ b/skills/diagram-design/assets/index.html@@ -220,6 +220,9 @@<button class="tab" data-type="paved-road-animated" data-parent-type="architecture" data-single><span class="eyebrow">01c</span>Secure paved road · animated</button>+ <button class="tab" data-type="architecture-containment" data-parent-type="architecture">+ <span class="eyebrow">01d</span>Architecture · containment+ </button><button class="tab" data-type="architecture-delta"><span class="eyebrow">02</span>Architecture delta</button>diff --git a/skills/diagram-design/references/layout-budget.md b/skills/diagram-design/references/layout-budget.mdindex 6be585f..3f3239e 100644--- a/skills/diagram-design/references/layout-budget.md+++ b/skills/diagram-design/references/layout-budget.md@@ -22,6 +22,7 @@ These are the per-type limits. The universal rows in SKILL.md §7 (9 nodes, 12 a| Limit | Rule ||---|---|| Max unique components / relationships / ledger entries (architecture delta) | 8 / 10 / 8 |+| Max admin bands / traffic scopes / nodes (architecture containment) | 2 / 4 / 8 || Max lifelines (sequence) | 5 || Max combined fragments (sequence) | 1 (default); 2 only if each is single-region `opt`/`loop` || Max `alt` regions (sequence) | 2 |diff --git a/skills/diagram-design/references/type-architecture.md b/skills/diagram-design/references/type-architecture.mdindex 9bab208..139082e 100644--- a/skills/diagram-design/references/type-architecture.md+++ b/skills/diagram-design/references/type-architecture.md@@ -67,15 +67,51 @@ Rules:- Leave 12–16px above the first enclosed node — the eyebrow label sits in this margin.- Zone fill: `ink @ 0.02` (2% ink wash). Any stronger competes with node fills.- **Zone label: `soft`, never ink at an opacity.** A zone eyebrow is a boundary label, and `soft` is the boundary-label role in [`style-guide.md`](style-guide.md). An opacity such as `ink @ 0.40` composites differently on every `paper`; on a light warm paper it falls near 2.2:1, unreadable at 7px. The role carries its own contrast contract under any skin.-- Max 3 zones per diagram. More and it reads like a swimlane (use that type instead).+- Max 3 **flat** zones per diagram. More and it reads like a swimlane (use that type instead). Nested administrative and traffic scopes under **Containment** below are not this cap — they nest, so the cap is sibling traffic scopes at one level.- Dark mode: the roles invert with the skin, so nothing is swapped by hand. Take `ink`, `soft`, and `paper` from the dark column in [`style-guide.md`](style-guide.md); opacities stay the same.+## Containment++Use this section when **the network hierarchy itself carries the meaning** — the reader must see what sits inside which scope, and a flattened zone label (`VNET · SNET-APP`) would lie about that hierarchy. Connectors stay Architecture; containment geometry comes from Nested (consistent insets, eyebrow per level, fills stepping up inward). This is a variant of Architecture, not a new type and not a provider-specific grammar.++Two scope kinds, never interchangeable:++| Kind | What it is | Shape | `data-scope-kind` |+|---|---|---|---|+| **Administrative** | Billing, permissions, lifecycle. Holds no traffic. | Horizontal **band** — a full-width containment rect with a 24px header | `admin` |+| **Traffic** | A boundary packets do not cross without an explicit rule. | **Box** — the existing zone rect (`rx=8`) | `traffic` |++Provider-neutral metadata (no vendor prefix):++- `data-grammar="architecture-containment"` on the root `<svg>` — files without it are ordinary Architecture and this contract does not apply.+- `data-scope-id` + `data-scope-kind` on every scope's bounds rect (`data-role="bounds"`). Bounds are always a `<rect>`, for scopes and nodes alike.+- `data-parent` on every nested scope and every node, naming the innermost enclosing `data-scope-id`. Only the outermost scope, which no other scope encloses, may omit it.+- Nodes: `data-node-id`, `data-kind` of `compute` (workloads inside a traffic scope), `endpoint` (private endpoint inside a traffic scope), or `managed` (PaaS that belongs to an administrative scope).+- An `endpoint` carries `data-target` naming the `managed` node it reaches.+- A peering path carries `data-peering`, `data-from`, and `data-to` naming the two traffic scopes it joins.++**PaaS placement (normative).** A managed service is never inside a traffic scope. It sits in the administrative band that owns it. What lives in the subnet is its private endpoint. Drawing a database inside a subnet tells the reader it sits behind that subnet's security rules, which it does not. `scripts/verify-architecture-containment.py` fails a `managed` node whose bounds fall inside any `traffic` scope, and an `endpoint` that is not inside one.++**Sibling axis.** Sibling traffic scopes at one level share one axis. Directly under an administrative band the parent's aspect chooses it: wider than tall (or square) → a row sharing one `y`; taller than wide → a column sharing one `x`. Nested children take the perpendicular axis: siblings inside a traffic scope that sits in a row form a column, and their own children form a row again. Do not mix axes at one level.++**Budget** (tightens Architecture's flat 3-zone cap; see `layout-budget.md`): ≤2 administrative bands, ≤4 traffic scopes, ≤8 nodes, 2 accent elements. Split per subscription when a figure exceeds that.++**Draw scopes in place.** Containment is read from each bounds rect's own `x`, `y`, `width`, and `height`. Do not position a scope or node with a `transform` attribute, a moving inline style (`transform`, `translate`, `x`, `y`, `position`, `margin`, and similar), a nested `<svg>`, a `<style>` rule, or an animation, on the element or any group around it. The checker fails each of those. It does not evaluate external stylesheets or script, so keep containment geometry out of both.++`scripts/verify-architecture-containment.py` checks unique IDs, resolving innermost parents, geometric containment, `<rect>` bounds, the admin-band vs traffic-box shapes (with `stroke-dasharray` resolved as rendered, so `none` or all-zero dashes count as solid), PaaS placement, endpoint targets, sibling axes, declared peerings, and the moved-geometry rule above. Files without `data-grammar="architecture-containment"` are skipped.+## Anti-patterns- Every box in coral ("this is important too") — hierarchy collapses.- Bidirectional arrow when one direction is obvious from context.- Legend floating inside the diagram area.+- Flattening two containment levels into one zone eyebrow (`VNET · SNET-APP`) — the hierarchy is the claim.+- A managed PaaS box drawn inside a subnet or VPC — only its private endpoint belongs there.+- Colour as the only distinction between an administrative band and a traffic box — the shapes must differ, because greyscale still has to tell them apart.## Examples- `assets/example-architecture.html` — minimal light- `assets/example-architecture-dark.html` — minimal dark- `assets/example-architecture-full.html` — full editorial+- `assets/example-architecture-containment.html` — nested admin/traffic scopes, light+- `assets/example-architecture-containment-dark.html` — nested admin/traffic scopes, dark+- `assets/example-architecture-containment-full.html` — nested admin/traffic scopes, full editorial