-
Notifications
You must be signed in to change notification settings - Fork 52
fix: make resolve output deterministic by sorting groups #982
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
fix: make resolve output deterministic by sorting groups #982
Conversation
Fixes open-telemetry#964 Added sorting of groups by id in the ResolvedRegistry::try_from_resolved_registry method. This ensures that the output of `weaver registry resolve` is deterministic and byte-for-byte identical across multiple runs, enabling diff checking and reproducible builds. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Optimize error handling by checking if errors occurred before sorting groups. This avoids unnecessary sorting operation when we're going to return an error anyway. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Added test to verify that groups in resolved registry are sorted alphabetically by ID, ensuring deterministic output across runs. - Added test_groups_sorted_deterministically test - Test creates registry with non-alphabetical groups (zebra, apple, middle) - Verifies output is sorted (apple, middle, zebra) - Confirms sorting is stable across multiple conversions - Updated test snapshots to reflect new sorted order 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Refactored group sorting to use itertools::sorted_by() in the iterator chain instead of a separate sort_by() call after collection. - Added itertools::Itertools import - Changed groups from mutable to immutable - Added .sorted_by() call in iterator chain before .collect() - Removed separate groups.sort_by() call This makes the code more functional and idiomatic while maintaining the same deterministic sorting behavior. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Removed explicit type annotation from groups variable as it was not present in the original code and the type can be inferred. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Resolved conflicts by removing expected output files that will be regenerated by tests.
After merging main, regenerated expected output files with sorted groups. The registry.md files now reflect the deterministic alphabetical sorting of groups by ID implemented in the earlier commits. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the fix! I think this is definitely a win for idempotent builds.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #982 +/- ##
=======================================
- Coverage 78.3% 78.3% -0.1%
=======================================
Files 77 77
Lines 6121 6122 +1
=======================================
- Hits 4798 4795 -3
- Misses 1323 1327 +4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Summary
Fixes #964 by sorting groups alphabetically by ID, making resolve output deterministic.
Changes
ResolvedRegistry::try_from_resolved_registry()
usingitertools::sorted_by()
test_groups_sorted_deterministically
Testing