{"slug": "the-svg-badge-was-exactly-2-units-from-both-edges-why-did-the-test-fail", "title": "The SVG Badge Was Exactly 2 Units from Both Edges. Why Did the Test Fail?", "summary": "A developer testing an AI coding agent (Codex) driving IconVectors over MCP found that a badge-placement test failed even though the badge landed exactly at the expected bounds of [16, 16, 22, 22] with 2-unit margins on a 24×24 viewBox. The failure came from a structural comparison of the folder artwork, which had changed when the SVG was opened (scale folded into coordinates, a polygon converted to a path). A snapshot taken immediately after opening showed 64 of 230,400 rendered pixels differed at that point, while moving the badge changed zero additional folder pixels.", "body_md": "We asked Codex to move a circular badge to the bottom-right corner of a folder icon using IconVectors over MCP. The icon had a `24 × 24` viewBox. The badge had to keep its diameter of 6 SVG units, leave exactly 2 units of clearance on the right and bottom, and preserve the folder artwork.\n\nThe first test returned `FAIL`. We opened the saved SVG in Chromium and measured both gaps independently. Right gap: **2 units**. Bottom gap: **2 units**.\n\nThe badge started inside a group with `transform=\"translate(2 1)\"`. That matters because the circle’s `cx` and `cy` describe its center inside the group. The requested gaps were measured from the edges of the whole icon.\n\nWe could work out the expected position on paper. On each axis, the far edge of the badge should land at `24 − 2 = 22`. With a diameter of 6, the near edge should land at `22 − 6 = 16`. That gives us an expected center of `(19, 19)` and bounds of `[16, 16, 22, 22]`.\n\nWe measured the badge in Chromium and converted its screen coordinates back into viewBox units. The bounds were **`[16, 16, 22, 22]`**. The diameter was **6 units on both axes**. The badge landed where we asked on the first attempt.\n\nHere’s the original assertion, formatted across lines for readability:\n\n```\nassert (\n    close(bounds, [16, 16, 22, 22])\n    and close(diameter, [6, 6])\n    and close(margins, [2, 2])\n    and no_stroke\n    and folder_unchanged\n    and canvas_unchanged\n)\n```\n\nOnly `folder_unchanged` was false. It compared the SVG structure and attributes of the folder. In the saved file, the scale had been folded into the coordinates, and a white polygon had become a path.\n\nThat explained the `FAIL`. It still left two questions. Had any pixels changed? And if so, had they changed when we moved the badge?\n\nWe had saved a copy immediately after opening the SVG in IconVectors, before moving anything. That gave us three files to compare. We hid the badge in each one and rendered the folder at **480 × 480 pixels**.\n\n| Folder renders compared | Changed pixels | \n|---|---|\n| Original → just after opening | 64 of 230,400 | \n| Just after opening → after moving the badge | 0 of 230,400 | \n\nAll 64 changed pixels lay along the slanted edge of the white detail. The largest difference was **5 on a 0–255 scale** in any color channel. The yellow mask in the figure shows where those differences occurred.\n\nWith only the original and final files, we might have attributed those 64 pixels to the badge move. The middle snapshot let us pin down the timing: the difference was already present immediately after opening the file. Moving the badge changed zero additional folder pixels at the tested size.\n\nWe'd keep the snapshot taken immediately after opening the file and give each check its own result line. For this run, the report would read:\n\nThat would have told us where to look on the first read. The badge was already in the right place. The detail worth inspecting was the white edge of the folder.", "url": "https://wpnews.pro/news/the-svg-badge-was-exactly-2-units-from-both-edges-why-did-the-test-fail", "canonical_source": "https://dev.to/axialisteam/the-svg-badge-was-exactly-2-units-from-both-edges-why-did-the-test-fail-12oc", "published_at": "2026-11-18 15:06:25+00:00", "updated_at": "2026-11-18 15:14:28.314043+00:00", "lang": "en", "topics": ["ai-agents", "ai-tools", "developer-tools"], "entities": ["Codex", "IconVectors", "MCP", "Chromium"], "also_reported_by": [], "takeaway": "Structural SVG comparisons produce false failures when tools rewrite attributes, so verify agent output with pixel diffs against a snapshot taken immediately after opening the file—here that isolated 64 changed pixels to file-open time and zero to the badge move.", "recommendation": {"advice": "Snapshot the artifact right after opening it and compare rendered pixels per check, so structural rewrites aren't misattributed to the agent's edit.", "playbook": "evals-testing", "playbook_url": "https://wpnews.pro/playbooks/evals-testing"}, "alternates": {"html": "https://wpnews.pro/news/the-svg-badge-was-exactly-2-units-from-both-edges-why-did-the-test-fail", "markdown": "https://wpnews.pro/news/the-svg-badge-was-exactly-2-units-from-both-edges-why-did-the-test-fail.md", "text": "https://wpnews.pro/news/the-svg-badge-was-exactly-2-units-from-both-edges-why-did-the-test-fail.txt", "jsonld": "https://wpnews.pro/news/the-svg-badge-was-exactly-2-units-from-both-edges-why-did-the-test-fail.jsonld"}}