Skip to content

Fix: ChoiceType serialization is now deterministic#1708

Merged
JPercival merged 1 commit intomainfrom
fix/choicetype-deterministic-serialization
Mar 18, 2026
Merged

Fix: ChoiceType serialization is now deterministic#1708
JPercival merged 1 commit intomainfrom
fix/choicetype-deterministic-serialization

Conversation

@JPercival
Copy link
Copy Markdown
Contributor

Summary

  • ChoiceType stored its types in insertion order, making toString() and equality non-deterministic
  • Sort types alphabetically by toString() in flattenChoices() so serialization is stable regardless of construction order
  • Updated all tests that depended on the previous arbitrary ordering

Test plan

  • ./gradlew build -x detekt passes (detekt failure is pre-existing JDK 25 incompatibility)
  • ./gradlew spotlessCheck passes
  • CI passes

🤖 Generated with Claude Code

ChoiceType stored its types in insertion order, making toString() and
equality non-deterministic. Sort types alphabetically by toString() in
flattenChoices() so serialization is stable regardless of construction order.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown

Related Issues

The following open issues may be related to this PR:

Issue Title Score Matched Terms
#895 Integrate code generation into the cql-engine build 10 arbitrary, com, code, types, build, https, java (path), src (path), fhir (path), main (path), org (path), cql (path), model (path), hl7 (path)
#1430 Correctly support CQL to FHIR (and vice versa) type mapping 9.5 com, code, types, build, https, type (path), cqframework (path), java (path), src (path), fhir (path), main (path), org (path), cql (path), hl7 (path)
#568 cql-to-elm --input . --verify fails inside Examples/ folder 9 "gradlew build", gradlew, build, jdk, order, type (path), java (path), src (path), cql (path)
#1677 CQL build has circular dependencies 9 "gradlew build", gradlew, code, failure, build, jdk, kotlin (path), cql (path)
#1133 ToList is not implemented according to the spec 9 com, code, types, https, type (path), cqframework (path), java (path), src (path), fhir (path), main (path), org (path), cql (path), hl7 (path), test (path)

Tip: If this PR addresses any of these issues, please link them using Closes #NNN or Refs #NNN in the PR description.

@github-actions
Copy link
Copy Markdown

Formatting check succeeded!

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 18, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 61.96%. Comparing base (75aa1b6) to head (4bd4a56).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##               main    #1708   +/-   ##
=========================================
  Coverage     61.96%   61.96%           
  Complexity     3940     3940           
=========================================
  Files           210      210           
  Lines         20367    20367           
  Branches       3879     3879           
=========================================
  Hits          12621    12621           
  Misses         6139     6139           
  Partials       1607     1607           

☔ 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@sonarqubecloud
Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
0.0% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

Copy link
Copy Markdown
Contributor

@c-schuler c-schuler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@JPercival JPercival merged commit c02ba23 into main Mar 18, 2026
9 of 10 checks passed
@JPercival JPercival deleted the fix/choicetype-deterministic-serialization branch March 18, 2026 19:29
JPercival pushed a commit that referenced this pull request Mar 25, 2026
…fter #1708  (#1711)

* ChoiceTypeSpecifier matching should be order-independent

* Spotless

* ChoiceTypeSpecifier ordering match ChoiceType sort order

* Addressing sonar issue
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.

2 participants