Repository navigation
fix(diagram): make rendered diagrams byte-reproducible across runs - #1606
Open
dimitri-yatsenko wants to merge 1 commit into
Open
dimitri-yatsenko wants to merge 1 commit into
dimitri-yatsenko wants to merge 1 commit into
Conversation
Python salts string hashes per process, so iterating a set of table names gives every interpreter a different order. Several places on the rendering path did that. The drawing graph was built with networkx `subgraph()`, which iterates a node subset smaller than half the graph in set order however the nodes were passed in. The entity clusters were emitted by looping over a set of part names. And `to_pydot()` wrote each node's primary-key set into the dot source with `str()`. Two identical runs therefore emitted nodes, edges and clusters in different orders: a committed SVG changed on every regeneration, and a drift check that compares a regenerated figure with the committed one could not tell a real change from reshuffling. The drawing graph is now built directly, with nodes and edges in order of full table name and the primary key stored sorted, and every other set iterated while rendering is sorted first. The notation is unchanged; only the emission order is now fixed, so committed figures need one regeneration. A new test renders the same diagrams in separate interpreters with different PYTHONHASHSEED values and asserts that the dot source, SVG and Mermaid output are identical, on both backends. Closes #1551.
dimitri-yatsenko
requested review from
MilagrosMarin,
lum-agilyti and
ttngu207
October 17, 2026 22:02
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Python salts string hashes per process, so iterating a set of table names gives every interpreter a different order. Several places on the rendering path did that. The drawing graph was built with networkx
subgraph(), which iterates a node subset smaller than half the graph in set order however the nodes were passed in. The entity clusters were emitted by looping over a set of part names. Andto_pydot()wrote each node's primary-key set into the dot source withstr(). Two identical runs therefore emitted nodes, edges and clusters in different orders: a committed SVG changed on every regeneration, and a drift check that compares a regenerated figure with the committed one could not tell a real change from reshuffling.The drawing graph is now built directly, with nodes and edges in order of full table name and the primary key stored sorted, and every other set iterated while rendering is sorted first. The notation is unchanged; only the emission order is now fixed, so committed figures need one regeneration.
A new test renders the same diagrams in separate interpreters with different PYTHONHASHSEED values and asserts that the dot source, SVG and Mermaid output are identical, on both backends.
Closes #1551.