Skip to content

Port D2's ELK compatibility surface to ELK.js 0.12 - #3

Merged
alixander merged 2 commits into
mainfrom
agent/elk-0.12-d2-surface
Aug 11, 2026
Merged

alixander merged 2 commits into
mainfrom
agent/elk-0.12-d2-surface

Conversation

@alixander

Copy link
Copy Markdown
Contributor

Summary

This updates elk-go from the ELK.js 0.8.2 behavior target to the exact official ELK.js 0.12.0 release.

The scope is deliberately limited to what D2 uses:

  • all 11 algorithms bundled by ELK.js 0.12
  • D2's Layered profile, including compounds, ports, labels, self-loops, model order, all directions, and orthogonal routing
  • D2-exposed spacing and padding options
  • ELK 0.12 option metadata needed for lookup and serialization

DisCo and its Polyomino-only metadata are removed because ELK.js no longer bundles that provider.

Compatibility evidence

The differential oracle is pinned to ELK.js commit ff5771d7 and SHA-256 1222e44f…07b3.

Against that official bundle:

  • 11/11 provider layouts are bit-exact
  • 15/15 curated D2 fixtures are bit-exact
  • 322/322 captured D2 graphs are bit-exact after the documented 0.12 profile migration
  • deterministic D2-profile random cases are bit-exact
  • IDs, element order, topology, edge sections, field presence, and coordinates are compared exactly

CI runs tests, race detection, and vet on Go 1.23 and 1.26, plus the pinned Node 24.19 oracle gates. Architecture-sensitive V8 math behavior has explicit amd64 and arm64 expectations.

Scope boundary

This is not a general implementation of every expert ELK option combination. Metadata presence is not an execution guarantee. Known unsupported Layered strategies are documented and return errors instead of silently selecting another algorithm.

Performance and size

Compared with elk-go v0.1.1, benchmarks establish no material CPU regression. The dense 250-node/1,000-edge stable case changes by +4.56% B/op and +1.20% allocs/op.

In full D2 integration builds, the upgrade changes stripped native size by +0.51% and optimized WASM size by +1.11%. Execution remains native, self-contained Go with no Go module dependencies.

Provenance and licensing

The source map pins the corresponding ELK 0.12, ELK.js, GWT, and V8/fdlibm inputs. EPL-2.0, Apache-2.0, BSD-3-Clause, and Sun permission notices are preserved in the repository, with the historical 0.8 implementation provenance retained separately.

Validation

  • go test ./... -count=1
  • go vet ./...
  • go test -race ./...
  • exact 322-graph D2 corpus differential against official ELK.js 0.12
  • native and js/wasm builds on Go 1.26.5

@alixander
alixander marked this pull request as ready for review August 11, 2026 02:05
@alixander
alixander merged commit 61fb787 into main Aug 11, 2026
3 checks passed
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