Skip to content

Conversation

kuklyy
Copy link

@kuklyy kuklyy commented Oct 13, 2025

Summary

Fixes #964 by sorting groups alphabetically by ID, making resolve output deterministic.

Changes

  • Sort groups by ID in ResolvedRegistry::try_from_resolved_registry() using itertools::sorted_by()
  • Check for errors before sorting for better performance
  • Added unit test test_groups_sorted_deterministically
  • Updated test snapshots to reflect sorted order

Testing

  • New unit test verifies groups are sorted alphabetically
  • All 76 existing tests pass

kuklyy and others added 5 commits October 13, 2025 11:14
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]>
@kuklyy kuklyy requested a review from a team as a code owner October 13, 2025 09:25
kuklyy and others added 2 commits October 13, 2025 12:06
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]>
Copy link
Contributor

@jsuereth jsuereth left a 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
Copy link

codecov bot commented Oct 22, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.3%. Comparing base (35a2778) to head (6777771).
⚠️ Report is 1 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

Resolve output should be deterministic

2 participants