Skip to content

Make snap area config export deterministic - #1804

Open
arhxam wants to merge 2 commits into
rxhanson:mainfrom
arhxam:codex/deterministic-config-export
Open

Make snap area config export deterministic#1804
arhxam wants to merge 2 commits into
rxhanson:mainfrom
arhxam:codex/deterministic-config-export

Conversation

@arhxam

@arhxam arhxam commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Summary

  • serialize snap-area dictionaries in a stable Directional.rawValue order
  • preserve Rectangle's existing alternating key/value JSON schema
  • canonicalize previously persisted valid snap-area JSON during config export
  • preserve raw export behavior for unset, malformed, and unrelated JSON defaults

Fixes #1468.

Verification

  • JSONDefaultSerializationTests: 5/5 passing
  • full RectangleTests: 210 tests run; the same 22 pre-existing assertions fail as on main, confined to ActiveSideSplitRatiosCooperativeTests, CooperativeCornerResizeTests, and HalfSplitCornerCalculationTests
  • git diff --check origin/main...HEAD

AI assistance

AI tooling assisted with investigation, implementation, and test generation. The final diff was reviewed against the issue, independently code-reviewed twice, and verified locally.

@rxhanson

rxhanson commented Aug 13, 2026

Copy link
Copy Markdown
Owner

Thanks for contributing, sorry for the delay on reviewing this.

Typically to guarantee sorted keys when encoding JSON, we can add .sortedKeys to the encoder in JSONDefault, something like this:

encoder.outputFormatting = [.prettyPrinted, .sortedKeys]

I'm guessing that codex was looking to impact the least amount of defaults in Rectangle (unless there's something I'm missing). If that's the case, I'd prefer just adding this .sortedKeys line to sort all of the JSONDefaults when they're saved and not having a special cased struct in place.

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.

Config export ordering is non-deterministic

2 participants