Skip to content

d2dagre: upgrade to Dagre 3.1.1 - #2844

Draft
alixander wants to merge 3 commits into
masterfrom
agent/dagre-3.1.1-integration
Draft

d2dagre: upgrade to Dagre 3.1.1#2844
alixander wants to merge 3 commits into
masterfrom
agent/dagre-3.1.1-integration

Conversation

@alixander

@alixander alixander commented Aug 11, 2026

Copy link
Copy Markdown
Collaborator

Depends on d2lang/dagro#3.

Summary

  • upgrade D2's native Dagro dependency from the Dagre 0.8.5 compatibility target to Dagre 3.1.1 behavior
  • keep parallel-edge and degenerate-intersection outputs finite through Dagro's narrow compatibility fixes, including multiple reversed partners for one forward dummy
  • normalize repeated modern self-loop control points before D2's curve and arrowhead processing
  • update the Go module floor to Go 1.26.5 and refresh Dagro notices and plugin help
  • accept the intentional layout-output changes across D2's Dagre-backed golden suites

The dependency is pinned to the signed head of the draft Dagro PR until that PR is merged and tagged. It must be replaced with the resulting release tag before this PR merges.

Compatibility and visual review

This is a layout-behavior update, not an output-compatible engine swap.

The primary E2E corpus changes 59 of 313 Dagre cases; 254 remain byte-identical. Across those 59 cases:

  • no diagram semantics or styles change after stripping geometry
  • 48 diagrams move nodes, 11 resize containers, and 58 reroute edges
  • no new shape-box overlaps or non-finite SVG attributes appear
  • us_map, grid_edge_across_cell, and investigate improve under the crossing proxy
  • nesting_power is materially more compact but has busier cross-container routes and is the main visual tradeoff to review

The accepted testdata contains 59 board JSON files, their 59 paired SVGs, and 15 additional Dagre-backed sketch/dark-theme/CLI SVGs.

Modern Dagre self-loops can contain repeated points that create zero-length tangents downstream. The adapter removes consecutive duplicates and uses center sentinels only for chopping loops to their node borders. The regression test requires finite, border-connected routes; the change affects only the ten self-loop routes that needed normalization.

During acceptance review, the natural D2 source a.b -> c -> a.b <- c exposed an upgrade-only panic in a compound graph with one forward and two reverse edges. Dagro now preserves every reversed partner, matches JavaScript's missing-map and root insertion semantics, and returns three finite routes connected to their source and destination borders. The D2 test pins that exact source and topology.

Differential evidence

Dagro's pinned corpus covers all 313 D2 Dagre E2E cases, 349 ordered adapter calls, and 311 unique raw layouts:

  • 308 finite official Dagre 3.1.1 results match bit-for-bit
  • one official result is non-finite and two official layouts throw
  • those three captured cases use explicit, named finite compatibility expectations
  • a fourth synthetic minimized case pins the composition of the compatibility corrections
  • 300 / 300 deterministic D2-profile layouts match the reproducibly source-built compatibility oracle exactly

Validation

  • full CI=1 go test -mod=readonly -count=1 ./... against the pushed Dagro revision
  • full native build and vet
  • targeted Dagre adapter unit, race, and vet gates
  • clean 313-case D2 E2E suite
  • Go 1.26.5 js/wasm build
  • d2.js build, 39 unit tests, and 2 ESM/CJS integration tests
  • synchronized root/npm notices, tidy diff, module verification, and repository diff checks

Performance is effectively unchanged within noisy measurements. Full D2 stripped native size grows by 0.051%, optimized WASM by 0.065%, and optimized-WASM gzip size by 0.041%.

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