Skip to content

fix(api): round-trip the key cancel location attribute - #299

Merged
webern merged 2 commits into
mainfrom
cancel-location
Jul 5, 2026
Merged

fix(api): round-trip the key cancel location attribute#299
webern merged 2 commits into
mainfrom
cancel-location

Conversation

@webern

@webern webern commented Jul 5, 2026

Copy link
Copy Markdown
Owner

Human Summary

Looks like fairly straightforward, and correct fix to a missing attribute in the API.

Summary

The api round-trip dropped the key cancel element's location attribute (classifier signature attr:cancel@location): MeasureReader read the cancel fifths value but ignored the attribute, and PropertiesWriter never emitted it.

  • KeyData.h gains enum class CancelLocation { unspecified, left, right, beforeBarline } and a KeyData::cancelLocation field (default unspecified, meaning the attribute is absent), plus the matching equality macro line. This follows the existing convention for absent-able enums (unspecified sentinel, never std::optional).
  • Converter gains cancelLocationMap and the two convert overloads bridging core::CancelLocation.
  • MeasureReader::parseAttributes reads the attribute when a cancel is present; PropertiesWriter::writeTraditionalKey writes it when cancelLocation is not unspecified. As before, the cancel element itself is only emitted when cancel != 0, so a location without a cancel is ignored.

Non-breaking: additive field with a default that preserves existing behavior.

Testing

  • New unit tests in KeyDataTest.cpp: core-level write check + serialize/deserialize survival (CancelLocationBeforeBarline), attribute-absent behavior (CancelLocationUnspecified), read path from XML mirroring the synthetic fixture (CancelLocationFromXml), and equality coverage (KeyDataEquality_change_cancelLocation). All fail before the fix.
  • Full suite passes: make test (4503 assertions in 350 test cases).
  • make discover-api-roundtrip before/after diff shows exactly one file changed: synthetic/cancel.location.3.0.xml FAIL -> PASS, attributable to this fix. It is now pinned in roundtrip-baseline.txt (121 -> 122 files).
  • make test-api-roundtrip regression gate: 122 passed, 0 failed (of 122 pinned).
  • make fmt and make check pass.

References

The api round-trip dropped the location attribute of the key cancel
element: the reader parsed the cancel fifths value but ignored the
attribute, and the writer never emitted it.

Add api::CancelLocation (unspecified/left/right/beforeBarline) and
KeyData::cancelLocation, bridge it with Converter::cancelLocationMap,
read it in MeasureReader::parseAttributes, and write it in
PropertiesWriter::writeTraditionalKey when a cancel is present.

Pin synthetic/cancel.location.3.0.xml in roundtrip-baseline.txt now
that it survives the strict compare (121 -> 122 pinned files).

Closes #272
@webern webern added bug software defect api Affects the mx::api layer impl Affects the mx::impl layer ai Issues opened by, or through, a coding agent. labels Jul 5, 2026 — with Claude
# Conflicts:
#	src/include/mx/api/KeyData.h
@github-actions

github-actions Bot commented Jul 5, 2026

Copy link
Copy Markdown

Coverage report

Core-dev coverage src/private/mx/core/

Metric Coverage Covered / Total
Lines 77.8% 28487 / 36626
Functions 74.2% 6349 / 8551
Branches 50.6% 22632 / 44725

API coverage src/private/mx/{api,impl,utility}/

Metric Coverage Covered / Total
Lines 78.7% 6125 / 7784
Functions 64.3% 2094 / 3255
Branches 47.9% 5213 / 10876

Core HTML report | API HTML report

Commit f7230dea627a0585bcd1d1473fdef00d4e719338.

@github-actions

github-actions Bot commented Jul 5, 2026

Copy link
Copy Markdown

gen-quality gen/

gen-quality: 84.5 / 100   (floor 84.5, +0.0)

  structure     86.5  x0.50   [fn 90.5 / file 82.6]
  cyclomatic    88.4  x0.25
  cognitive     76.6  x0.25

  409 functions across 31 files, 7702 lines (largest file 1044)
  max cc 56  max cognitive 44  max fn loc 152

Worst offenders (top 5 per axis; full lists in score.json):
  cyclomatic gen/xsd/analyze.py:311     report                             56
  cyclomatic gen/plates/build.py:956    _validate_config_against_ir        35
  cyclomatic gen/press/context.py:145   plate_context                      34
  cyclomatic gen/__main__.py:46         _ir                                23
  cyclomatic gen/tests/test_ir.py:102   _check_references                  20
  cognitive  gen/xsd/analyze.py:311     report                             44
  cognitive  gen/ir/resolve.py:119      flat_elements                      40
  cognitive  gen/tests/test_ir.py:102   _check_references                  38
  cognitive  gen/press/context.py:145   plate_context                      37
  cognitive  gen/xsd/analyze.py:207     _sccs                              37
  size       gen/xsd/analyze.py:311     report                             152
  size       gen/press/context.py:145   plate_context                      96
  size       gen/plates/build.py:533    _value_plate                       89
  size       gen/plates/build.py:956    _validate_config_against_ir        89
  size       gen/ir/resolve.py:119      flat_elements                      78

Commit f7230dea627a0585bcd1d1473fdef00d4e719338.

@webern
webern marked this pull request as ready for review July 5, 2026 11:13
@webern
webern merged commit 511f8f4 into main Jul 5, 2026
7 checks passed
@webern
webern deleted the cancel-location branch July 5, 2026 11:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai Issues opened by, or through, a coding agent. api Affects the mx::api layer bug software defect impl Affects the mx::impl layer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

api: round-trip drops key cancel location attribute

1 participant