Skip to content

Fix unstable ordering of generated index fields - #75

Merged
edvgui merged 1 commit into
masterfrom
fix-index-field-order
Jul 25, 2026
Merged

Fix unstable ordering of generated index fields#75
edvgui merged 1 commit into
masterfrom
fix-index-field-order

Conversation

@edvgui

@edvgui edvgui commented Jul 25, 2026

Copy link
Copy Markdown
Owner

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 different PYTHONHASHSEED values.

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_fields helper shared by the three index-generation sites in generator.py.

Test

Added tests/test_generator.py::test_index_field_order_matches_keys, asserting RootFolder's generated index lists its fields in the declared ["root", "name"] order (root local, name inherited — 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

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>
@edvgui edvgui self-assigned this Jul 25, 2026
@edvgui
edvgui merged commit c733ae5 into master Jul 25, 2026
7 checks passed
@edvgui
edvgui deleted the fix-index-field-order branch July 25, 2026 09:11
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.

1 participant