Fix unstable ordering of generated index fields - #75
Merged
Conversation
The generator built each entity index by iterating entity.all_fields(), which returns a set. The resulting index field order was therefore arbitrary and changed from one generation to the next (visible across runs with different hash seeds). Order the index fields by the keys declared on the slice schema instead, via a new get_key_fields helper shared by the three index-generation sites. Add a regression test asserting RootFolder's index lists its fields in the declared ["root", "name"] order. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Claude opening this PR on behalf of Guillaume.
Problem
The generator built each entity index by iterating
entity.all_fields(), which returns a set. The resulting index field order was arbitrary and changed from one generation to the next — reproducible by running the tests with differentPYTHONHASHSEEDvalues.Fix
Order the index fields by the keys declared on the slice schema (parent relation first, then keys in declared order), via a new
get_key_fieldshelper shared by the three index-generation sites ingenerator.py.Test
Added
tests/test_generator.py::test_index_field_order_matches_keys, assertingRootFolder's generated index lists its fields in the declared["root", "name"]order (rootlocal,nameinherited — a case where set iteration is very unlikely to match). Confirmed the test fails on the old code under some hash seeds and passes deterministically with the fix.🤖 Generated with Claude Code