Repository navigation
Compare every variant of a multi-variant source, deterministically - #39
Merged
anakanemison merged 1 commit intoNov 9, 2026
Conversation
anakanemison
force-pushed
the
mschaller/u04-deterministic-variants
branch
from
October 26, 2026 13:30
ddb5b91 to
7bf197e
Compare
armandomontanez
approved these changes
Oct 28, 2026
armandomontanez
left a comment
Contributor
There was a problem hiding this comment.
Ideally we correlate various invocations with specific parts of build targets and use that to map the diffing behavior, but that's an entirely different work order.
Comment on lines
+93
to
+94
| # (diff._diff_variants; extra Bazel defines stay benign WARN under the | ||
| # asymmetric-subset rule). Only ever use for codegen |
Contributor
There was a problem hiding this comment.
diff._diff_variants; is odd here. Is this the intention?
Suggested change
| # (diff._diff_variants; extra Bazel defines stay benign WARN under the | |
| # asymmetric-subset rule). Only ever use for codegen | |
| # (extra Bazel defines stay benign WARN under the asymmetric-subset | |
| # rule in `diff._diff_variants()`). Only ever use for codegen |
Contributor
Author
There was a problem hiding this comment.
Nope, need to invest in de-slopifying skills. Fixed.
_union_tus pooled library TUs into one source-keyed map with dict.setdefault while iterating a set of target names. When one source is compiled into several libraries with different flags (a full and a lite build of the same file, a hardened variant), only one variant per side was compared, and which one depended on set iteration order, that is, on PYTHONHASHSEED. The verdict was not reproducible. Measured in any2bazel-lab: the same MySQL Server models gave 4,715 to 4,817 errors over 10 hash seeds, a different error set each time, and the final models of a Blender migration converged under 2 of 8 seeds. Projects without multi-variant sources were unaffected (50 recorded verdicts identical under 20 seeds). Pooling now keeps every distinct variant per source, visiting targets in sorted order. Each CMake variant is compared with its best-matching Bazel variant: fewest errors, then warnings, then the smallest symmetric difference of the two TUs' define, flag and include sets, then a stable text order. Every CMake variant must be matched by some Bazel variant and nothing is suppressed; an extra Bazel-only variant is tolerated, like an extra Bazel flag. The distance term keeps a tie from choosing a variant that only adds flags (-w, -Wno-error=...) over an exact one. A source with one variant per side takes exactly the old path, and on every single-variant verdict the lab has recorded, the result is unchanged. Executables and the opt-in test union use the same pairing, and the Java source union is visited in sorted order too. One consequence for source_map users: a token that collapses several CMake TUs (an AUTOMOC bundle, say) now yields one comparison, and so possibly one discrepancy, per distinct CMake TU, so the worklist can grow. The source_map comment in config.py says so. In the lab's later QGIS run with this change, the differ gave the same verdict under three seeds. Lab-Proposal: P14 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
anakanemison
force-pushed
the
mschaller/u04-deterministic-variants
branch
from
November 2, 2026 17:50
7bf197e to
8fdabc2
Compare
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.
When one source compiles into several libraries with different flags, the differ compared only one variant per side, and which one depended on set iteration order, that is, on
PYTHONHASHSEED. Pooling now keeps every variant, visits targets in sorted order, and compares each CMake variant with its best-matching Bazel variant (fewest errors, then warnings, then the smallest difference, then a stable order). A source with one variant per side takes the old path unchanged.In any2bazel-lab, the same MySQL Server models gave 4,715 to 4,817 errors over 10 seeds, and a Blender migration's final models converged under 2 of 8. With this change, a later QGIS run's verdict was the same under three seeds. A
source_maptoken that collapses several CMake TUs now yields one comparison per distinct TU, so the worklist can grow.Stacked on #38 (tracking issue: #35).
pytest tests/: 140 passed (132 onmain). Lab proposal: P14.🤖 Generated with Claude Code