Skip to content

fix: DirectionWriter respects orderedComponents#254

Merged
webern merged 4 commits into
mainfrom
fix-direction-order
Jun 28, 2026
Merged

fix: DirectionWriter respects orderedComponents#254
webern merged 4 commits into
mainfrom
fix-direction-order

Conversation

@webern

@webern webern commented Jun 28, 2026

Copy link
Copy Markdown
Owner

Summary

  • Split DirectionWriter::getDirectionLikeThings() into two emission paths:
    fixed-order (existing behavior when orderedComponents is empty) and ordered
    dispatch (uses the component order the reader recorded from parsed XML).
  • Extract each per-kind emission block into a private helper method on
    DirectionWriter, called by both paths to avoid ~400 lines of duplication.
  • Ordered dispatch loops over orderedComponents, bounds-checks each index, and
    calls the appropriate helper. Words are bundled on first encounter; chords are
    skipped (emitted via createHarmonyElements).
  • Add doc comment on DirectionData::orderedComponents explaining its
    round-trip role and the "do not populate programmatically" contract.

Corpus impact

Discovery mode (94 PASS / 737 FAIL) shows no new files unlocked by this fix
alone. Files with interleaved direction-types (e.g. ly31a_Directions.xml,
ly31c_MetronomeMarks.xml) still fail due to other blockers:

  • ly31a_Directions.xml: child count mismatch at .../note (unrelated to
    direction ordering)
  • ly31c_MetronomeMarks.xml: attribute count mismatch at
    .../direction-type/metronome (missing metronome attributes, not ordering)

This fix is a prerequisite for those files to eventually pass — the ordering
divergence was one of multiple blockers, not the sole blocker. A synthetic
round-trip test that isolates the ordering behavior would strengthen coverage
here.

Fixes #206

webern added 4 commits June 28, 2026 18:04
Split DirectionWriter::getDirectionLikeThings() into two
emission paths: fixed-order (existing behavior, used when
orderedComponents is empty) and ordered dispatch (uses the
component order the reader recorded from parsed XML).

Each per-kind emission block is extracted into a private
helper method, called by both paths to avoid duplication.

Fixes #206
@github-actions

Copy link
Copy Markdown

Coverage report

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

Metric Coverage Covered / Total
Lines 77.8% 28487 / 36624
Functions 74.3% 6349 / 8550
Branches 50.6% 22632 / 44725

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

Metric Coverage Covered / Total
Lines 78.5% 6003 / 7647
Functions 63.6% 2022 / 3177
Branches 47.7% 5082 / 10665

Core HTML report | API HTML report

Commit e73aa71ee444c48062e2a72bbe782e4a7e7b991a.

@github-actions

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 e73aa71ee444c48062e2a72bbe782e4a7e7b991a.

Base automatically changed from fix-words-color to main June 28, 2026 19:26
@webern webern merged commit 1d58cf1 into main Jun 28, 2026
7 checks passed
@webern webern deleted the fix-direction-order branch June 28, 2026 19:27
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.

impl: DirectionWriter ignores orderedComponents — interleaved direction-type children lose original order on write

1 participant