GridQuantizer: opt-in grid snapping for flowchart layouts - #63
Conversation
The transform the grid-alignment metric was built to guard. `GridQuantizer` snaps a laid-out flowchart onto a pixel grid; opt in with `DiagramSpacing(gridSnap: 4)`. - Applied inside `DiagramLayoutEngine.layout(_ chart: Flowchart, …)` — the single dispatch both render paths (CoreGraphics + RenderScene) and the lint IR call — so all three inherit identical snapped geometry and the draw-vs-scene conformance ratchet stays green with no per-path work. - Node/container frames snap origin-down / far-corner-up, so a box only ever grows (never clips its measured label) and its w/h are grid multiples. Edge endpoints are re-anchored onto the snapped node borders — a grown box moves its right/bottom edge independently of the endpoint, so snapping the point alone would detach the arrow — and interior waypoints snap to the nearest grid line, preserving orthogonal routing (a segment's shared coordinate snaps identically at both ends). - `DiagramSpacing.gridSnap` is off by default and included in `fingerprint`, so snapped and unsnapped renders never collide in the render cache. Tests: snapping drives node-coord alignment to 100% (via the metric), keeps the layout lint-clean (no edge-endpoint-detached / edge-occludes-node / nodes-overlap on the subgraph-bearing fixture), never shrinks a box, and is a strict identity when off. 416 tests pass (+5). Default output unchanged → no gallery/perf impact. Other box families (block, C4, architecture, ER, class, state) extend the same pattern in follow-ups; then the metric floors get raised. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014CJYAapHgDn2PWGNABnFtv
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Warning Review limit reachedYou’ve reached a temporary PR review limit under our Fair Usage Limits Policy. Next review available in: 1 minute Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the 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 configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
Comment |
The transform the grid-alignment metric was built to guard — the "then snap" half of the lint-first plan. Flowchart first (highest value, hardest edges); other box families follow.
What
GridQuantizer.quantize(_ layout: FlowchartLayout, unit:), opt in withDiagramSpacing(gridSnap: 4).DiagramLayoutEngine.layout(_ chart: Flowchart, …), the single dispatch both render paths (CoreGraphics +RenderScene) and the lint IR call. All three inherit identical snapped geometry, so the draw-vs-scene conformance ratchet stays green with zero per-path work.gridSnapis inDiagramSpacing.fingerprint, so snapped/unsnapped renders don't collide.Verification
edge-endpoint-detached/edge-occludes-node/nodes-overlapon the (subgraph-bearing) flowchart fixture.gridSnapoff is a strict identity.Scope
Flowchart only; block/C4/architecture/ER/class/state extend the same pattern next, then the metric floors get raised.
🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.