Repository navigation
feat(spec): the entries of each section and the regions under cases: are sorted by name as a spec loads, so every output lists them in that order - #921
Closed
FBumann wants to merge 3 commits into
Conversation
…loads, so every output lists them in that order `to_spec` sorts the entries of every section, and of each kind under `given:`, by name. The program, the typeset document, `to_yaml()` and the canonical form list them in that order, so the order a file lists its entries in changes nothing. The legend lists the dimensions by name, and a shared first letter goes to the first dimension by name. The canonical form no longer sorts the entries itself. Five tests that expected file order now expect name order, and the golden output, the generated pages, `several-files.md` and `first-spec.md` are rewritten from what the code prints. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JzRHmodLpxhaZRQc9sgBdZ
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JzRHmodLpxhaZRQc9sgBdZ
…oads The regions are proved apart rather than tried in turn, so their order means nothing. The spec held them as the file wrote them, so two files that state one spec wrote two canonical texts and printed their rows in two orders. The canonical form, `to_yaml()` and the typeset document now list them by name, with `otherwise:` last, and an overlap refusal names the two cases in name order. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JzRHmodLpxhaZRQc9sgBdZ
cases: are sorted by name as a spec loads, so every output lists them in that order
FBumann
added this pull request to stack #917
October 21, 2026 07:17
This was referenced Oct 21, 2026
Contributor
Author
Note The following content was generated by AI. Superseded by #924, which squashes #914, #916 and #921 into one commit on Generated by Claude Code |
FBumann
removed this pull request from stack #917
October 21, 2026 07:37
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.
Note
The following content was generated by AI.
What this changes
to_specsorts by name the entries of every section, those under each kind ofgiven:, and the regions undercases:. The program, the typeset document,to_yaml()and the canonical form all list them in that order.Stacked on #918.
given:to_yaml()cases:otherwise:still lastdimensions:periodprints aspandplantasl, whatever the order_sorted_entriesis now_canonical_entries, and the form's "regions as written" exception is gone.docs/reference/language/file.mdstates the rule.dimensions.mdagain says the order ofdimensions:changes nothing, which is now true.named.mdsays the cases print sorted by name.reading.md,glossary.md,typeset.mdand five docstrings no longer say "file order".Why
One rule: no order a file writes reaches a value a reader sees. Since #914 and #916 this held for
dims:lists and relation sides, but entries and regions kept the file's order, and the letters followeddimensions:. The regions are proved apart rather than tried in turn, so their order meant nothing, but two files that differ only in it wrote two canonical texts. A declared order for entries can come later.Method, tests, gate output, mutation table
Method. A
field_validator('*')onSpecand onGivenSpec, and afield_validator('cases')onExpressionSpec, sort a mapping by key through one helper,_by_name. None of them touchesmodel_fields_set, so #918's writer still writes only the fields the file wrote.Tests.
test_the_order_a_file_lists_its_entries_in_reaches_no_value_of_the_specruns on every example. It reverses every section's entries and asserts the sameto_yaml()and the same key order in ten program sections.==is not enough, because dict equality ignores order.test_the_order_a_file_lists_its_entries_in_prints_nowhereasserts the same typeset text in all three formats.test_the_order_of_the_regions_under_cases_is_no_differencereverses the regions ofcommitment.yamland asserts one canonical text, oneto_yaml()and one LaTeX document. Thethe-regions-under-casescase oftest_an_order_the_form_keeps_is_a_difference_in_the_textasserted the opposite and is removed.test_the_definitions_print_sorted_by_name(was…_in_file_order, and now writes its six entries in reverse),test_program_structure, the two assumption-order tests intest_loweringandtest_piecewise, and the overlap message intest_cases_split_by_a_named_condition_are_proved_apart_through_its_condition.docs/several-files.mdand the second printed block ofdocs/first-spec.mdwere rewritten from what the code prints.first-spec.md's legend was already stale since feat(language)!: every entry is indexed by its dimensions sorted by name, whatever order the file writes them in #914 (𝒯 × 𝒢), and it is now𝒢 × 𝒯.Gates on
098a799:pixi run lint: passed.pixi run test: 3550 passed, 1 skipped.pixi run docs-build: passed.compile-tex: not run, because Tectonic cannot download its bundle in the sandbox. CI runs it.Mutation table. Each validator was changed by hand to return its input, and the suite ran.
__pycache__was dropped before and after each run. Rows 1 and 2 ran on8e21fb5, restored withgit checkout --, with the full suite. Row 3 ran before its commit, withtests/test_canonical.pyonly, and was restored by editing the line back. Each time the tree came back as it was.GivenSpeckeeps the file's ordertest_the_order_a_file_lists_its_entries_in_reaches_no_value_of_the_spec[pypsa/cost.yaml]Speckeeps the file's ordertest_two_files_that_mean_the_same_thing_write_the_same_textExpressionSpec.caseskeeps the file's ordertest_the_order_of_the_regions_under_cases_is_no_differenceNot done
curve_link0,curve_link1), so sorting the links would rename those rows.examples/keep their authors' order. They are inputs.exclude={'version'}) and feat(language)!: every entry is indexed by its dimensions sorted by name, whatever order the file writes them in #914's relation key order are not part of this PR.where:each name the other (a: {where: b},b: {where: a}) load. That is not changed here.🤖 Generated with Claude Code
https://claude.ai/code/session_01JzRHmodLpxhaZRQc9sgBdZ