Skip to content

Grid-alignment metric (lint-first baseline for grid snapping) - #62

Merged
clintecker merged 1 commit into
mainfrom
feat/grid-alignment-metric
Aug 12, 2026
Merged

Grid-alignment metric (lint-first baseline for grid snapping)#62
clintecker merged 1 commit into
mainfrom
feat/grid-alignment-metric

Conversation

@clintecker

@clintecker clintecker commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator

The lint-first first step of the grid-alignment work (from the layout R&D artifact). Measures, doesn't move.

What

  • DiagramLayoutLinter.gridAlignment(_:unit:) -> GridAlignment? — fraction of a box-family diagram's node coordinates on a pixel grid (default 4px), or nil for families a grid doesn't apply to (pie/radar/timeline/sequence/mindmap).
  • report(_:) appends a non-gating grid: line for box families.
  • GridAlignmentTests records a per-type floor the layout can only ratchet up — the draw-vs-scene conformance ratchet's discipline, inverted. A layout change that de-aligns boxes fails CI; when a GridQuantizer lands, alignment jumps and floors rise.

Why not a warning

Today's box layouts sit far below full alignment (flowchart 22%, block 9%, state 8% of coords on the 4px grid under the test measurer) — a LayoutViolation warning would fire on every box-family diagram and drown the correctness stream. So it's a separate measurement the ratchet tracks, surfaced in report() for human eyes.

Scope / safety

Pure measurement — no geometry changes, so no gallery/perf impact. Box families only (flowchart/block/c4/architecture/er/class/state). 411 tests pass (+4). DocC updated.

🤖 Generated with Claude Code


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

The "lint-first" half of the grid work (before any snapping): a measurement,
not a transform. `DiagramLayoutLinter.gridAlignment(_:unit:)` reports the
fraction of a box-family diagram's node coordinates that sit on a pixel grid
(default 4px), or nil for families a grid doesn't apply to (pie/radar/timeline/
sequence). `report(_:)` appends a non-gating `grid:` line for box families.

Deliberately NOT a LayoutViolation: today every box-family layout sits well
below full alignment (flowchart 22%, block 9%, state 8% of coords on grid under
the test measurer), so a warning would fire on all of them and drown the
correctness stream. Instead GridAlignmentTests records a per-type FLOOR the
layout can only ratchet UP — mirroring the draw-vs-scene conformance ratchet
(ceilings that only fall; here, floors that only rise). A layout change that
de-aligns boxes now fails CI; when a GridQuantizer lands, alignment jumps toward
1.0 and the floors get raised.

Pure measurement — no geometry changes, so no gallery/perf impact. 411 tests
pass (+4).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014CJYAapHgDn2PWGNABnFtv
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You’ve reached a temporary PR review limit under our Fair Usage Limits Policy.

Your recent review volume is higher than typical usage, so adaptive limits are currently applied.

Next review available in: 2 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b3377d65-e067-403c-9176-0af9b9094204

📥 Commits

Reviewing files that changed from the base of the PR and between 21172d9 and 0e96c7f.

📒 Files selected for processing (4)
  • Sources/MermaidLayout/DiagramScene.swift
  • Sources/MermaidLayout/GridAlignment.swift
  • Sources/MermaidLayout/MermaidLayout.docc/SceneGeometryAndLinting.md
  • Tests/MermaidLayoutTests/GridAlignmentTests.swift

Comment @coderabbitai help to get the list of available commands.

@clintecker
clintecker merged commit 0150f2a into main Aug 12, 2026
16 checks passed
@clintecker
clintecker deleted the feat/grid-alignment-metric branch August 12, 2026 18:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant