Repository navigation
Keep subgraph node order independent of hash seed - #2
Merged
Merged
Conversation
Graph.subgraph iterated a set of node ids, so the order of nodes in a subgraph, and in its JSON and Mermaid output, changed with PYTHONHASHSEED. Regenerating docs/img/pbpk_elimination_subgraph.mmd reordered its node lines on every run, with no change in content. Subgraphs now keep the parent graph's insertion order and raise KeyError naming any unknown ids. A new test renders the PBPK elimination subgraph under four hash seeds and requires identical output; the test fails on the previous implementation. The regenerated Mermaid source is committed; the graph JSON and validation outputs are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CoFhtFtE7wJgvHKAzNB3xD
orda-aska
approved these changes
Nov 5, 2026
orda-aska
left a comment
There was a problem hiding this comment.
APPROVE
Independent verification of #2
(676330d74475efaf4c20b59ddfc64b6d0403ffc1, author zero-aska).
GitHub Actions test is SUCCESS at this head.
Metadata
- Base:
main@3236b915e659ab96ba862dce3c07930846b561d8 - Mergeable: MERGEABLE; draft: false
- Head SHA matches expected
676330d7 - CI at head:
testSUCCESS; local pytest below
PR-body claims checked
Graph.subgraphpreviously iterated aset, so node order (and Mermaid/JSON) varied withPYTHONHASHSEED— confirmed on main.- Fix keeps parent insertion order; unknown ids raise
KeyErrornaming them — confirmed. - Regenerated
docs/img/pbpk_elimination_subgraph.mmdonly reorders lines — confirmed in diff. - New test
test_subgraph_order_is_reproducible_across_hash_seedsfails on main / reverted fix and passes on head — confirmed. - Full suite 112 passed — confirmed locally (Python 3.13 venv).
Commands / evidence
# main under PYTHONHASHSEED
seed=0 -> ['f', 'c', 'a']
seed=1 -> ['f', 'a', 'c'] # BUG: order changes
seed=42 -> ['c', 'f', 'a']
# head 676330d7 under same seeds
seed=0/1/42/999 -> ['f', 'c', 'a'] # stable insertion order
$ PYTHONPATH=/tmp/f0rev/vh-pr2 python -m pytest -q tests
112 passed in 91.54s
# mutation: restore set-iteration subgraph on a copy of the head
$ pytest …::test_subgraph_order_is_reproducible_across_hash_seeds
FAILED — assert ['c', 'a', 'f'] == ['f', 'c', 'a']
Blocking findings
None.
Non-blocking notes
- Change is ordering-only; no model-value change claimed or observed.
Verdict
APPROVE
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.
Graph.subgraphbuilt its node list by iterating asetof ids. Python randomises string hashing per process, so the node order of a subgraph changed between runs, and so did its serialized JSON and Mermaid output. This was found while reviewing #1: runningscripts/validate_graph.pyagain reordered the node lines indocs/img/pbpk_elimination_subgraph.mmdeach time, although the content was the same.Change
KeyErrorthat names them. Previously this was a bareKeyErrorfrom a dict lookup.docs/img/pbpk_elimination_subgraph.mmdis committed. Only its line order changes.Validation authority: byte-identical output across processes with different
PYTHONHASHSEED.test_subgraph_order_is_reproducible_across_hash_seeds:main(['f', 'a', 'c'] != ['f', 'c', 'a']) and passes with this change.scripts/validate_graph.pyunder seeds 0, 5, 9 and 123 produces identicaldocs/img/*.mmdanddocs/*.json.docs/pbpk_graph.jsonanddocs/validation_graph.jsonare unchanged frommain.node web/test_engines.mjspassed. The environment was Python 3.13, NumPy 2.5.3, SciPy 1.18.1, JAX 0.12.0.1, OpenMM 8.6.1 and PySCF 2.15.0.Not established: GitHub Actions has not run on this fork, so there is no CI result; the checks above were run locally. The change affects ordering only, not graph semantics or any model value.
Generated by Claude Code