smoosic 2.0.3 → 2.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (245) hide show
  1. package/build/smoosic.js +395 -67
  2. package/changes.md +85 -0
  3. package/package.json +98 -82
  4. package/release/smoosic.js +395 -67
  5. package/specs/032-split-multimeasure-rests/checklists/requirements.md +40 -0
  6. package/specs/032-split-multimeasure-rests/contracts/grouping-contract.md +53 -0
  7. package/specs/032-split-multimeasure-rests/data-model.md +70 -0
  8. package/specs/032-split-multimeasure-rests/plan.md +81 -0
  9. package/specs/032-split-multimeasure-rests/quickstart.md +46 -0
  10. package/specs/032-split-multimeasure-rests/research.md +63 -0
  11. package/specs/032-split-multimeasure-rests/spec.md +127 -0
  12. package/specs/032-split-multimeasure-rests/tasks.md +174 -0
  13. package/specs/033-key-distance-transposition/checklists/requirements.md +35 -0
  14. package/specs/033-key-distance-transposition/contracts/spelling-api.md +36 -0
  15. package/specs/033-key-distance-transposition/data-model.md +49 -0
  16. package/specs/033-key-distance-transposition/plan.md +87 -0
  17. package/specs/033-key-distance-transposition/quickstart.md +40 -0
  18. package/specs/033-key-distance-transposition/research.md +82 -0
  19. package/specs/033-key-distance-transposition/spec.md +132 -0
  20. package/specs/033-key-distance-transposition/tasks.md +139 -0
  21. package/specs/034-smz-compressed-scores/checklists/requirements.md +35 -0
  22. package/specs/034-smz-compressed-scores/contracts/archive-api.md +30 -0
  23. package/specs/034-smz-compressed-scores/data-model.md +48 -0
  24. package/specs/034-smz-compressed-scores/plan.md +89 -0
  25. package/specs/034-smz-compressed-scores/quickstart.md +44 -0
  26. package/specs/034-smz-compressed-scores/research.md +86 -0
  27. package/specs/034-smz-compressed-scores/spec.md +137 -0
  28. package/specs/034-smz-compressed-scores/tasks.md +148 -0
  29. package/specs/035-paste-special/checklists/requirements.md +35 -0
  30. package/specs/035-paste-special/contracts/paste-special-api.md +50 -0
  31. package/specs/035-paste-special/data-model.md +47 -0
  32. package/specs/035-paste-special/plan.md +83 -0
  33. package/specs/035-paste-special/quickstart.md +51 -0
  34. package/specs/035-paste-special/research.md +97 -0
  35. package/specs/035-paste-special/spec.md +170 -0
  36. package/specs/035-paste-special/tasks.md +149 -0
  37. package/specs/036-autosave-recovery/checklists/requirements.md +36 -0
  38. package/specs/036-autosave-recovery/contracts/autosave-api.md +111 -0
  39. package/specs/036-autosave-recovery/data-model.md +70 -0
  40. package/specs/036-autosave-recovery/plan.md +87 -0
  41. package/specs/036-autosave-recovery/quickstart.md +65 -0
  42. package/specs/036-autosave-recovery/research.md +105 -0
  43. package/specs/036-autosave-recovery/spec.md +143 -0
  44. package/specs/036-autosave-recovery/tasks.md +165 -0
  45. package/specs/037-fix-new-part-dialog/checklists/requirements.md +38 -0
  46. package/specs/037-fix-new-part-dialog/contracts/create-part-api.md +84 -0
  47. package/specs/037-fix-new-part-dialog/data-model.md +68 -0
  48. package/specs/037-fix-new-part-dialog/plan.md +83 -0
  49. package/specs/037-fix-new-part-dialog/quickstart.md +58 -0
  50. package/specs/037-fix-new-part-dialog/research.md +86 -0
  51. package/specs/037-fix-new-part-dialog/spec.md +144 -0
  52. package/specs/037-fix-new-part-dialog/tasks.md +174 -0
  53. package/specs/038-per-measure-beam-groups/checklists/requirements.md +36 -0
  54. package/specs/038-per-measure-beam-groups/contracts/beam-groups-api.md +74 -0
  55. package/specs/038-per-measure-beam-groups/data-model.md +75 -0
  56. package/specs/038-per-measure-beam-groups/plan.md +84 -0
  57. package/specs/038-per-measure-beam-groups/quickstart.md +53 -0
  58. package/specs/038-per-measure-beam-groups/research.md +72 -0
  59. package/specs/038-per-measure-beam-groups/spec.md +146 -0
  60. package/specs/038-per-measure-beam-groups/tasks.md +132 -0
  61. package/specs/039-measure-fill-submenu/checklists/requirements.md +35 -0
  62. package/specs/039-measure-fill-submenu/contracts/measure-fill-api.md +56 -0
  63. package/specs/039-measure-fill-submenu/data-model.md +79 -0
  64. package/specs/039-measure-fill-submenu/plan.md +81 -0
  65. package/specs/039-measure-fill-submenu/quickstart.md +62 -0
  66. package/specs/039-measure-fill-submenu/research.md +68 -0
  67. package/specs/039-measure-fill-submenu/spec.md +153 -0
  68. package/specs/039-measure-fill-submenu/tasks.md +121 -0
  69. package/specs/040-dynamics-dialog-cleanup/checklists/requirements.md +36 -0
  70. package/specs/040-dynamics-dialog-cleanup/contracts/dynamics-dialog.md +52 -0
  71. package/specs/040-dynamics-dialog-cleanup/data-model.md +48 -0
  72. package/specs/040-dynamics-dialog-cleanup/plan.md +89 -0
  73. package/specs/040-dynamics-dialog-cleanup/quickstart.md +69 -0
  74. package/specs/040-dynamics-dialog-cleanup/research.md +80 -0
  75. package/specs/040-dynamics-dialog-cleanup/spec.md +120 -0
  76. package/specs/040-dynamics-dialog-cleanup/tasks.md +114 -0
  77. package/specs/041-delete-special/checklists/requirements.md +35 -0
  78. package/specs/041-delete-special/contracts/delete-special-api.md +41 -0
  79. package/specs/041-delete-special/data-model.md +40 -0
  80. package/specs/041-delete-special/plan.md +93 -0
  81. package/specs/041-delete-special/quickstart.md +41 -0
  82. package/specs/041-delete-special/research.md +75 -0
  83. package/specs/041-delete-special/spec.md +136 -0
  84. package/specs/041-delete-special/tasks.md +106 -0
  85. package/src/application/application.ts +13 -2
  86. package/src/application/exports.ts +401 -395
  87. package/src/application/generateVexTests.ts +2 -2
  88. package/src/render/sui/NoteEntryCaret.ts +117 -16
  89. package/src/render/sui/autosave.ts +265 -0
  90. package/src/render/sui/formatter.ts +12 -2
  91. package/src/render/sui/scoreChangeState.ts +8 -3
  92. package/src/render/sui/scoreView.ts +47 -2
  93. package/src/render/sui/scoreViewOperations.ts +2706 -2555
  94. package/src/render/sui/staffLineGeometry.ts +82 -0
  95. package/src/render/vex/vxMeasure.ts +22 -8
  96. package/src/render/vex/vxNote.ts +2 -4
  97. package/src/smo/data/measure.ts +58 -1
  98. package/src/smo/data/measureModifiers.ts +81 -1
  99. package/src/smo/data/music.ts +169 -359
  100. package/src/smo/data/note.ts +1 -1
  101. package/src/smo/data/noteModifiers.ts +12 -0
  102. package/src/smo/data/score.ts +167 -2
  103. package/src/smo/data/scoreModifiers.ts +46 -1
  104. package/src/smo/data/systemStaff.ts +43 -0
  105. package/src/smo/xform/beamers.ts +80 -6
  106. package/src/smo/xform/copypaste.ts +207 -47
  107. package/src/smo/xform/measureFill.ts +89 -0
  108. package/src/smo/xform/operations.ts +403 -61
  109. package/src/smo/xform/selections.ts +7 -0
  110. package/src/ui/components/dialogs/beamGroups.vue +106 -0
  111. package/src/ui/components/dialogs/deleteSpecial.vue +38 -0
  112. package/src/ui/components/dialogs/dynamics.vue +16 -3
  113. package/src/ui/components/dialogs/fileUpload.vue +2 -2
  114. package/src/ui/components/dialogs/hairpin.vue +3 -3
  115. package/src/ui/components/dialogs/newPart.vue +148 -184
  116. package/src/ui/components/dialogs/pasteSpecial.vue +49 -0
  117. package/src/ui/components/dialogs/recovery.vue +66 -0
  118. package/src/ui/components/dialogs/save.vue +11 -4
  119. package/src/ui/components/dialogs/scorePreferences.vue +23 -1
  120. package/src/ui/components/dialogs/slur.vue +6 -6
  121. package/src/ui/components/dialogs/tempo.vue +11 -3
  122. package/src/ui/components/dialogs/timeSignature.vue +5 -0
  123. package/src/ui/components/dialogs/volta.vue +3 -3
  124. package/src/ui/dialogs/annotationVue.ts +1 -1
  125. package/src/ui/dialogs/beamGroupsVue.ts +69 -0
  126. package/src/ui/dialogs/createPartHelpers.ts +68 -0
  127. package/src/ui/dialogs/deleteSpecial.ts +57 -0
  128. package/src/ui/dialogs/dynamicsVue.ts +87 -60
  129. package/src/ui/dialogs/factory.ts +0 -2
  130. package/src/ui/dialogs/fileDialogs.ts +63 -22
  131. package/src/ui/dialogs/instrument.ts +37 -30
  132. package/src/ui/dialogs/pasteSpecial.ts +59 -0
  133. package/src/ui/dialogs/preferences.ts +41 -40
  134. package/src/ui/dialogs/recovery.ts +49 -0
  135. package/src/ui/fileio/fileInput.ts +12 -3
  136. package/src/ui/fileio/scoreArchive.ts +151 -0
  137. package/src/ui/fileio/xhrLoader.ts +26 -0
  138. package/src/ui/i18n/language.ts +1 -1
  139. package/src/ui/menus/beams.ts +181 -112
  140. package/src/ui/menus/edit.ts +44 -6
  141. package/src/ui/menus/file.ts +21 -1
  142. package/src/ui/menus/measure.ts +40 -1
  143. package/tests/autosave.ts +332 -0
  144. package/tests/beamDotted.ts +56 -0
  145. package/tests/beamGroups.ts +338 -0
  146. package/tests/createPart.ts +292 -0
  147. package/tests/deleteSpecial.ts +350 -0
  148. package/tests/dynamicsFontSize.ts +132 -0
  149. package/tests/keyDistanceTransposition.ts +351 -0
  150. package/tests/measureFill.ts +295 -0
  151. package/tests/movePart.ts +94 -0
  152. package/tests/multimeasureRest.ts +338 -0
  153. package/tests/pasteIntoMeasure.ts +103 -0
  154. package/tests/pasteSpecial.ts +541 -0
  155. package/tests/quickBeam.ts +126 -0
  156. package/tests/scoreArchive.ts +218 -0
  157. package/tests/scoreChangeState.ts +2 -0
  158. package/tests/staffLineGeometry.ts +179 -0
  159. package/tests/timeSignatureDisplay.ts +58 -0
  160. package/tools/smoosic-schema.json +37 -0
  161. package/typedoc.ts +1 -1
  162. package/types/src/application/exports.d.ts +453 -447
  163. package/types/src/common/promiseHelpers.d.ts +30 -30
  164. package/types/src/common/vex.d.ts +224 -224
  165. package/types/src/render/sui/NoteEntryCaret.d.ts +107 -107
  166. package/types/src/render/sui/autosave.d.ts +99 -0
  167. package/types/src/render/sui/scoreView.d.ts +23 -0
  168. package/types/src/render/sui/scoreViewOperations.d.ts +759 -639
  169. package/types/src/render/sui/svgHelpers.d.ts +88 -88
  170. package/types/src/render/sui/svgPageMap.d.ts +344 -344
  171. package/types/src/render/sui/textEdit.d.ts +96 -96
  172. package/types/src/render/sui/textRender.d.ts +199 -199
  173. package/types/src/render/vex/smoAdapter.d.ts +47 -47
  174. package/types/src/render/vex/vxMeasure.d.ts +97 -97
  175. package/types/src/render/vex/vxNote.d.ts +56 -56
  176. package/types/src/render/vex/vxSystem.d.ts +71 -71
  177. package/types/src/smo/data/measure.d.ts +30 -0
  178. package/types/src/smo/data/measureModifiers.d.ts +568 -513
  179. package/types/src/smo/data/music.d.ts +74 -32
  180. package/types/src/smo/data/note.d.ts +498 -498
  181. package/types/src/smo/data/noteModifiers.d.ts +615 -606
  182. package/types/src/smo/data/score.d.ts +476 -421
  183. package/types/src/smo/data/scoreModifiers.d.ts +30 -0
  184. package/types/src/smo/data/scoreText.d.ts +334 -334
  185. package/types/src/smo/data/systemStaff.d.ts +14 -0
  186. package/types/src/smo/xform/beamers.d.ts +23 -1
  187. package/types/src/smo/xform/copypaste.d.ts +138 -2
  188. package/types/src/smo/xform/measureFill.d.ts +21 -0
  189. package/types/src/smo/xform/operations.d.ts +245 -129
  190. package/types/src/smo/xform/selections.d.ts +154 -154
  191. package/types/src/smo/xform/undo.d.ts +142 -142
  192. package/types/src/ui/buttons/button.d.ts +100 -100
  193. package/types/src/ui/buttons/ribbon.d.ts +70 -70
  194. package/types/src/ui/common.d.ts +76 -76
  195. package/types/src/ui/components/dialogs/chordText.d.ts +28 -28
  196. package/types/src/ui/components/dialogs/textBlockAtomNode.d.ts +20 -20
  197. package/types/src/ui/components/dialogs/textGroupHtml.d.ts +29 -29
  198. package/types/src/ui/composable/draggable.d.ts +15 -15
  199. package/types/src/ui/dialogs/adapter.d.ts +120 -120
  200. package/types/src/ui/dialogs/annotationVue.d.ts +9 -9
  201. package/types/src/ui/dialogs/audioSettings.d.ts +32 -32
  202. package/types/src/ui/dialogs/beamGroupsVue.d.ts +20 -0
  203. package/types/src/ui/dialogs/chordChangeVue.d.ts +8 -8
  204. package/types/src/ui/dialogs/createPartHelpers.d.ts +29 -0
  205. package/types/src/ui/dialogs/customTupletsVue.d.ts +9 -9
  206. package/types/src/ui/dialogs/deleteSpecial.d.ts +8 -0
  207. package/types/src/ui/dialogs/dialog.d.ts +203 -203
  208. package/types/src/ui/dialogs/dynamicsVue.d.ts +10 -10
  209. package/types/src/ui/dialogs/factory.d.ts +15 -15
  210. package/types/src/ui/dialogs/fileDialogs.d.ts +4 -4
  211. package/types/src/ui/dialogs/hairpin.d.ts +35 -35
  212. package/types/src/ui/dialogs/hairpinVue.d.ts +7 -7
  213. package/types/src/ui/dialogs/instrument.d.ts +3 -3
  214. package/types/src/ui/dialogs/keySignatureVue.d.ts +7 -7
  215. package/types/src/ui/dialogs/libraryVue.d.ts +15 -15
  216. package/types/src/ui/dialogs/lyricVue.d.ts +8 -8
  217. package/types/src/ui/dialogs/pasteSpecial.d.ts +8 -0
  218. package/types/src/ui/dialogs/pedalMarkingVue.d.ts +7 -7
  219. package/types/src/ui/dialogs/recovery.d.ts +8 -0
  220. package/types/src/ui/dialogs/rehearsalMark.d.ts +25 -25
  221. package/types/src/ui/dialogs/rehearsalMarkVue.d.ts +7 -7
  222. package/types/src/ui/dialogs/slur.d.ts +57 -57
  223. package/types/src/ui/dialogs/slurVue.d.ts +7 -7
  224. package/types/src/ui/dialogs/tempo.d.ts +50 -50
  225. package/types/src/ui/dialogs/tempoVue.d.ts +10 -10
  226. package/types/src/ui/dialogs/textBlockVue.d.ts +8 -8
  227. package/types/src/ui/dialogs/textBracket.d.ts +35 -35
  228. package/types/src/ui/dialogs/textBracketVue.d.ts +7 -7
  229. package/types/src/ui/dialogs/tie.d.ts +41 -41
  230. package/types/src/ui/dialogs/volta.d.ts +40 -40
  231. package/types/src/ui/dialogs/voltaVue.d.ts +7 -7
  232. package/types/src/ui/fileio/fileInput.d.ts +7 -1
  233. package/types/src/ui/fileio/library.d.ts +40 -40
  234. package/types/src/ui/fileio/scoreArchive.d.ts +55 -0
  235. package/types/src/ui/fileio/xhrLoader.d.ts +7 -0
  236. package/types/src/ui/menus/file.d.ts +8 -8
  237. package/types/src/ui/menus/language.d.ts +7 -7
  238. package/types/src/ui/menus/manager.d.ts +58 -58
  239. package/types/src/ui/menus/menu.d.ts +159 -159
  240. package/types/src/ui/menus/partSelection.d.ts +14 -14
  241. package/types/src/ui/menus/score.d.ts +8 -8
  242. package/types/src/ui/menus/staffModifier.d.ts +17 -17
  243. package/types/typedoc.d.ts +147 -147
  244. package/src/ui/dialogs/dynamics.ts +0 -141
  245. package/types/src/ui/dialogs/dynamics.d.ts +0 -37
@@ -0,0 +1,40 @@
1
+ # Specification Quality Checklist: Split Multimeasure Rests at Landmarks
2
+
3
+ **Purpose**: Validate specification completeness and quality before proceeding to planning
4
+
5
+ **Created**: 2026-10-22
6
+
7
+ **Feature**: [spec.md](../spec.md)
8
+
9
+ ## Content Quality
10
+
11
+ - [x] No implementation details (languages, frameworks, APIs)
12
+ - [x] Focused on user value and business needs
13
+ - [x] Written for non-technical stakeholders
14
+ - [x] All mandatory sections completed
15
+
16
+ ## Requirement Completeness
17
+
18
+ - [x] No [NEEDS CLARIFICATION] markers remain
19
+ - [x] Requirements are testable and unambiguous
20
+ - [x] Success criteria are measurable
21
+ - [x] Success criteria are technology-agnostic (no implementation details)
22
+ - [x] All acceptance scenarios are defined
23
+ - [x] Edge cases are identified
24
+ - [x] Scope is clearly bounded
25
+ - [x] Dependencies and assumptions identified
26
+
27
+ ## Feature Readiness
28
+
29
+ - [x] All functional requirements have clear acceptance criteria
30
+ - [x] User scenarios cover primary flows
31
+ - [x] Feature meets measurable outcomes defined in Success Criteria
32
+ - [x] No implementation details leak into specification
33
+
34
+ ## Notes
35
+
36
+ - The Input line quotes the request verbatim, so it names the code files. The rest of the spec uses behavioral terms.
37
+ - From a first read of the code: the grouping step treats a rehearsal mark, repeat symbol or instrument change on a measure as disqualifying that measure from starting a multimeasure rest, which would leave it as a lone rest bar between two multimeasure rests (User Stories 1 and 3). Key and time signature changes appear to be handled in the grouping step already (they only end a rest), so the reported problem for those may be in drawing the signature at the start of the second rest (User Story 2). The plan phase must establish exactly where each case fails before changing anything.
38
+ - Clarified by the user (2026-10-22): landmarks are either start landmarks (rehearsal mark, key/time/tempo change, Segno, Coda, start-repeat or double barline, instrument change), which break the rest before their measure and are shown at the beginning of the next block, or end landmarks (D.S., D.C., To Coda, Fine, end-repeat or double barline), which break the rest after their measure and are shown on the block they end. Tempo, key and time changes are all landmarks.
39
+ - Defaults chosen without asking: text annotations are not landmarks; measures under a repeat-ending bracket keep today's behavior; a single remaining empty measure stays an ordinary rest bar, including a measure that carries both kinds of landmark.
40
+ - Ready for `/speckit-clarify` or `/speckit-plan`.
@@ -0,0 +1,53 @@
1
+ # Contract: Multimeasure Rest Grouping
2
+
3
+ Headless cases G1 to G24 are verified by `tests/multimeasureRest.ts` (`npm run test:multimeasure-rest`). Manual cases M1 to M10 are in [quickstart.md](../quickstart.md). Spec references: [spec.md](../spec.md).
4
+
5
+ ## Test scores used by G-cases
6
+
7
+ A one-staff score of 12 measures in 4/4 containing only rests (so a run of 12), exposed as a part with `expandMultimeasureRests` false. Each case adds the landmarks named, calls `SmoOperation.computeMultipartRest`, and reads the blocks as a list of `start:length` for measures that have `multimeasureLength > 0`, plus the list of measures with `hideMultimeasure`. Measure numbers below are 1-based as in the spec, 0-based in the test.
8
+
9
+ ## Headless cases
10
+
11
+ | ID | Case | Expected | Spec |
12
+ |----|------|----------|------|
13
+ | G1 | No landmarks | one block `1:12`; measures 2 to 12 hidden | FR-001, SC-004 |
14
+ | G2 | Rehearsal mark on measure 6 | blocks `1:5`, `6:7`; measure 6 not hidden, no lone bar | US1.1, FR-003, FR-006 |
15
+ | G3 | Rehearsal mark on measure 1 | one block `1:12` | US1.2 |
16
+ | G4 | Rehearsal mark on measure 12, nothing after | blocks `1:11`; measure 12 is an ordinary bar (no length, not hidden) | US1.3, FR-007 |
17
+ | G5 | Rehearsal marks on 4 and 8 | blocks `1:3`, `4:4`, `8:5` | US1.4 |
18
+ | G6 | Key signature change at measure 5 | blocks `1:4`, `5:8` | US2.1 |
19
+ | G7 | Time signature change at measure 5 | blocks `1:4`, `5:8` | US2.2 |
20
+ | G8 | Tempo change (displayed) at measure 5 | blocks `1:4`, `5:8` | US2.3, clarification |
21
+ | G9 | Tempo change with `display` false | one block `1:12` | research §2 |
22
+ | G10 | Key change and rehearsal mark both on measure 5 | blocks `1:4`, `5:8`, one split only | US2.4 |
23
+ | G11 | Segno on measure 5 | blocks `1:4`, `5:8` | US3.2 |
24
+ | G12 | Coda on measure 9 | blocks `1:8`, `9:4` | US3.2 |
25
+ | G13 | D.S. al Coda on measure 4 | blocks `1:4` (measure 4 included, last of block), `5:8`; the end symbol is recorded on measure 1 | US3.1, FR-005 |
26
+ | G14 | To Coda on measure 6 | blocks `1:6`, `7:6`; end symbol recorded on measure 1 | US3.1 |
27
+ | G15 | D.C. al Fine on measure 1 | measure 1 alone (ordinary bar with the symbol), then block `2:11` | edge case |
28
+ | G16 | End-repeat barline on the end of measure 4 | blocks `1:4`, `5:8`; `multimeasureEndBarline` of measure 1 is the repeat barline | US3.3 |
29
+ | G17 | Start-repeat barline on the start of measure 5 | blocks `1:4`, `5:8` | US3.4 |
30
+ | G18 | Double bar as the end barline of measure 4, and separately as the start barline of measure 5 | blocks `1:4`, `5:8` in both cases | US3.3, US3.4 |
31
+ | G19 | Instrument change at measure 7 | blocks `1:6`, `7:6` | FR-004 |
32
+ | G20 | Rehearsal mark and D.S. both on measure 5 | blocks `1:4`, `5:1` (ordinary bar with both), `6:7` | edge case, FR-007 |
33
+ | G21 | `expandMultimeasureRests` true with landmarks | no block anywhere | FR-010 |
34
+ | G22 | A volta ending over measures 5 to 6 | measures 5 and 6 are ordinary bars; blocks before and after | FR-010 |
35
+ | G23 | Two staves, rehearsal mark on measure 6 of the second staff only | both staves have blocks `1:5`, `6:7` | FR-008 |
36
+ | G24 | Regrouping after removing the rehearsal mark | back to one block `1:12`; no stale length, hidden flag or end symbol on any measure | FR-011, SC-005 |
37
+
38
+ Counts: the lengths of the blocks plus the ordinary bars add up to 12 in every case (FR-009), checked inside each case.
39
+
40
+ ## Manual cases
41
+
42
+ | ID | Case | Expected | Spec |
43
+ |----|------|----------|------|
44
+ | M1 | Part view, 10 empty measures, rehearsal mark on measure 6 | two multimeasure rests, the mark over the second, no bar between | US1.1 |
45
+ | M2 | Key change at measure 5 | new key signature at the start of the second rest | US2.1 |
46
+ | M3 | Time signature change at measure 5 | new time signature at the start of the second rest | US2.2 |
47
+ | M4 | Tempo change at measure 5 | tempo marking over the second rest | US2.3 |
48
+ | M5 | D.S. al Coda on measure 4, Coda on measure 9 | the D.S. over the first rest, the Coda sign at the start of the last rest after the barline | US3 |
49
+ | M6 | End repeat bar after measure 4 | repeat barline at the end of the first rest, once | US3.3, FR-007a |
50
+ | M7 | Add then remove a rehearsal mark | rests regroup on the next full layout; no stale bar | FR-011 |
51
+ | M8 | Two-staff part | same grouping on both staves | FR-008 |
52
+ | M9 | "Expand multimeasure rests" on | every measure shown | FR-010 |
53
+ | M10 | Print preview | same grouping | edge case |
@@ -0,0 +1,70 @@
1
+ # Data Model: Split Multimeasure Rests at Landmarks
2
+
3
+ No serialized data changes (constitution Principle #1). The grouping result is runtime state on each measure's `svg` record.
4
+
5
+ ## Measure grouping state (`measure.svg`)
6
+
7
+ | Field | Type | Meaning | Change |
8
+ |-------|------|---------|--------|
9
+ | `multimeasureLength` | number | On a block's first measure, the number of measures in the block (at least 2); 0 on every other measure | existing; now always reset |
10
+ | `hideMultimeasure` | boolean | True on every measure of a block except the first | existing |
11
+ | `multimeasureEndBarline` | number | The block's end barline, taken from the block's last measure | existing; now always reset |
12
+ | `multimeasureEndSymbol` | `SmoRepeatSymbol \| null` | The end-type repeat symbol (D.S., D.C., To Coda, Fine) of the block's last measure, to draw over the block's rest; null if none | **new**, runtime only |
13
+
14
+ All four are set for every staff, so the staves of a part always share the same grouping.
15
+
16
+ ## Landmark classification (new helpers on `SmoScore`)
17
+
18
+ ```ts
19
+ isMultimeasureBlocked(measureIndex): boolean
20
+ // a volta ending covers the measure on any staff, or (legacy) measureIndex is 0 on a multi-staff part
21
+
22
+ isMultimeasureStartLandmark(measureIndex): boolean
23
+ // any staff: rehearsal mark; repeat symbol Segno or Coda; instrument map entry at measureIndex > 0;
24
+ // start barline that is not singleBar/noBar.
25
+ // staff 0: key signature or time signature differs from the previous measure;
26
+ // displayed tempo differs from the previous measure's tempo.
27
+
28
+ isMultimeasureEndLandmark(measureIndex): boolean
29
+ // any staff: repeat symbol ToCoda, DcAlCoda, DcAlFine, DsAlCoda, DsAlFine or Fine;
30
+ // end barline that is not singleBar/noBar.
31
+ ```
32
+
33
+ All three are pure reads of the score; none changes it. `isMultimeasureRest` (existing, public) is left as it is.
34
+
35
+ ## Grouping algorithm (`SmoOperation.computeMultipartRest`)
36
+
37
+ ```text
38
+ if the part expands multimeasure rests: return (unchanged)
39
+ i = 0
40
+ while i < measureCount:
41
+ if blocked(i) or not restMeasure(i): reset(i); i += 1; continue
42
+ j = i + 1
43
+ closed = endLandmark(i)
44
+ while not closed and j < measureCount and restMeasure(j) and not blocked(j)
45
+ and not restBreak(j) and not startLandmark(j):
46
+ closed = endLandmark(j); j += 1
47
+ if j - i >= 2: block [i, j)
48
+ else: reset(i)
49
+ i = j
50
+ for each block [key, end): on every staff
51
+ measure[key]: length = end - key; endBarline = measure[end-1] end barline;
52
+ endSymbol = end-type symbol of measure[end-1] or null; hide = false
53
+ measures key+1 .. end-1: hide = true; length = 0; endBarline = single; endSymbol = null
54
+ reset(m) on every staff: length = 0; hide = false; endBarline = single; endSymbol = null
55
+ ```
56
+
57
+ `restMeasure(m)` is the existing rule: every staff has only rests in the measure, or the measure's `format.forceRest` is set. `restBreak(m)` is the existing `format.restBreak` flag.
58
+
59
+ ### Equivalence with today's behavior
60
+
61
+ For a score whose runs of rests contain no rehearsal mark, repeat symbol, instrument entry, tempo change or special barline, the new loop produces the same blocks as the old one: a key or time change still ends a block and starts the next; `restBreak` still ends a block; voltas and `forceRest` are unchanged.
62
+
63
+ ## Drawing inputs (read-only)
64
+
65
+ | Reader | Uses |
66
+ |--------|------|
67
+ | `vxSystem.renderMeasure` | `hideMultimeasure` (skip), unchanged |
68
+ | `vxMeasure.createMeasureModifiers` | `multimeasureLength`, `multimeasureEndBarline`, and the new `multimeasureEndSymbol` |
69
+ | `formatter` | `hideMultimeasure`, unchanged; `layout()` now calls the grouping first for parts |
70
+ | `tracker` | `multimeasureLength`, `hideMultimeasure` for navigation, unchanged |
@@ -0,0 +1,81 @@
1
+ # Implementation Plan: Split Multimeasure Rests at Landmarks
2
+
3
+ **Branch**: `032-split-multimeasure-rests` | **Date**: 2026-10-22 | **Spec**: [spec.md](./spec.md)
4
+
5
+ **Input**: Feature specification from `/specs/032-split-multimeasure-rests/spec.md`
6
+
7
+ ## Summary
8
+
9
+ `SmoOperation.computeMultipartRest` groups empty measures into multimeasure blocks using `SmoScore.isMultimeasureRest`, which treats a rehearsal mark, repeat symbol or instrument change as disqualifying a measure from being in a block at all, including starting one. That is the lone-rest-bar bug: the block ends before the landmark measure, the landmark measure fails the "can start a block" test and is drawn as a single ordinary rest, and a new block starts after it. The grouping loop is rewritten around two kinds of landmark. **Start landmarks** (rehearsal mark, key, time and tempo changes, Segno and Coda, a non-plain start barline, an instrument change) end the current block before their measure and may start the next one. **End landmarks** (D.S., D.C., To Coda, Fine, a non-plain end barline) are allowed on the last measure of a block and end it after that measure. Volta endings keep today's behavior. The classification lives in new `SmoScore` helpers so it can be tested headlessly, the old `isMultimeasureRest` is left in place for outside users, and `computeMultipartRest` also resets stale runtime flags on measures that no longer start a block. On the drawing side, the block's last measure is hidden, so an end symbol (D.S. and the like) on it would vanish; its symbol is recorded on the block's first measure and `vxMeasure.ts` draws it there. Because the grouping is only computed when a part is first shown, the layout step now recomputes it for parts so landmark edits take effect on the next full layout.
10
+
11
+ ## Technical Context
12
+
13
+ **Language/Version**: TypeScript (built by `build/build.js`).
14
+
15
+ **Primary Dependencies**: None new. Existing `SmoScore`, `SmoSystemStaff` (`isRehearsal`, `isRepeatSymbol`, `getVoltasForMeasure`, `measureInstrumentMap`), `SmoMeasure` (`getStartBarline`, `getEndBarline`, `getRepeatSymbol`, `getTempo`), `SmoRepeatSymbol`, `SmoTempo.eq`, and the VexFlow wrappers in `vxMeasure.ts`.
16
+
17
+ **Storage**: None. Block information is runtime state on `measure.svg`; no serialized field changes.
18
+
19
+ **Testing**: A headless script `tests/multimeasureRest.ts` (`npm run test:multimeasure-rest`) that builds in-memory scores of empty measures with each landmark and checks the block lengths, hidden flags, end barlines and recorded end symbols that `computeMultipartRest` produces. Drawing (symbols over the rest, signatures at the start of the second block) cannot be run headlessly and is verified manually (quickstart.md).
20
+
21
+ **Target Platform**: Browser application; tests run under Node.
22
+
23
+ **Project Type**: Single project (library + application).
24
+
25
+ **Performance Goals**: No regression. The grouping is O(measures × staves); it is now also run at the start of a full layout for parts, which already costs far more.
26
+
27
+ **Constraints**: Scores with no landmark inside a run of rests must group exactly as today (SC-004). Volta endings and `expandMultimeasureRests` keep their behavior. No serialized data changes. The existing public `SmoScore.isMultimeasureRest` keeps its signature and result.
28
+
29
+ **Scale/Scope**: One algorithm rewritten, four small helpers, one new runtime field, one drawing change, one layout hook, one test.
30
+
31
+ ## Constitution Check
32
+
33
+ *GATE: Must pass before Phase 0 research. Re-check after Phase 1 design.*
34
+
35
+ - **Principle #1 (Serialization)**: PASS. Only ephemeral `measure.svg` fields change; the score format is untouched, so legacy scores load and group by the new rules.
36
+ - **Principle #2 (Music transformation logic regression testing)**: PASS. The grouping rules are pure score logic in `src/smo` and get a headless regression script with a contract case list.
37
+ - **Principle #3 (Rendering performance)**: PASS. The extra grouping pass is linear and runs at most once per full layout, before measurements; no DOM measurement or repaint logic is added.
38
+ - **Principle #4 (Logical dependencies)**: PASS. Landmark classification and grouping stay in `src/smo`. The render layer only reads the resulting `svg` fields. The `svg` mixin is ephemeral, which the principle allows.
39
+
40
+ No violations; Complexity Tracking is not needed. Re-check after Phase 1: unchanged, still PASS.
41
+
42
+ ## Project Structure
43
+
44
+ ### Documentation (this feature)
45
+
46
+ ```text
47
+ specs/032-split-multimeasure-rests/
48
+ ├── plan.md
49
+ ├── research.md
50
+ ├── data-model.md
51
+ ├── quickstart.md
52
+ ├── contracts/
53
+ │ └── grouping-contract.md
54
+ ├── checklists/
55
+ │ └── requirements.md
56
+ └── tasks.md # created later by /speckit-tasks
57
+ ```
58
+
59
+ ### Source Code (repository root)
60
+
61
+ ```text
62
+ src/
63
+ ├── smo/
64
+ │ ├── data/
65
+ │ │ ├── score.ts # SmoScore: isMultimeasureStartLandmark / isMultimeasureEndLandmark /
66
+ │ │ │ # isMultimeasureBlocked; isMultimeasureRest left unchanged (deprecated note)
67
+ │ │ └── measure.ts # SvgMeasureInfo: multimeasureEndSymbol (runtime)
68
+ │ └── xform/operations.ts # computeMultipartRest rewritten around the two landmark kinds
69
+ ├── render/
70
+ │ ├── vex/vxMeasure.ts # draw the block's end symbol over the multimeasure rest
71
+ │ └── sui/formatter.ts # run computeMultipartRest at the start of a layout for parts
72
+ tests/
73
+ └── multimeasureRest.ts # NEW headless regression script
74
+ package.json # add "test:multimeasure-rest"
75
+ ```
76
+
77
+ **Structure Decision**: Keep the classification next to the existing rule (`SmoScore`) and the algorithm where it is (`SmoOperation.computeMultipartRest`), so callers do not change. The only render-layer changes are drawing the recorded end symbol and triggering the grouping at layout.
78
+
79
+ ## Complexity Tracking
80
+
81
+ *No Constitution Check violations; table not needed.*
@@ -0,0 +1,46 @@
1
+ # Quickstart: Validating Multimeasure Rest Splitting
2
+
3
+ Contract cases are in [contracts/grouping-contract.md](./contracts/grouping-contract.md); structures and the algorithm are in [data-model.md](./data-model.md).
4
+
5
+ ## 1. Headless regression test
6
+
7
+ ```bash
8
+ npm run test:multimeasure-rest
9
+ ```
10
+
11
+ Expected: every case G1 to G24 prints `PASS`, the run ends with `all checks passed`, and the exit code is 0.
12
+
13
+ ## 2. Type check, build, existing tests
14
+
15
+ ```bash
16
+ npx tsc --noEmit -p tsconfig.json
17
+ npm run build
18
+ npm run test:select-voice
19
+ npm run test:voice-copy-paste
20
+ npm run test:promise-helpers
21
+ npm run test:score-change-state
22
+ npm run test:page-divisions
23
+ npm run test:global-layout-reposition
24
+ npm run test:text-drag-placement
25
+ npm run test:attached-text
26
+ npm run test:rehearsal-measure-number
27
+ ```
28
+
29
+ Expected: no errors; all scripts pass.
30
+
31
+ ## 3. Manual check in the app
32
+
33
+ Prerequisite: build and open the app. Make a score with a single staff and 12 empty measures, then create a part for the staff (Parts menu) and show the part, so multimeasure rests are on (the part's "Expand Multimeasure Rests" is off).
34
+
35
+ 1. With no markings, the part shows one multimeasure rest numbered 12.
36
+ 2. Put a rehearsal mark on measure 6: the part now shows a rest of 5, then a rest of 7 with the mark above it. There is no single bar between them.
37
+ 3. Move the mark to measure 1, then to measure 12: the rest is one block of 12, then a block of 11 plus a single ordinary bar with the mark.
38
+ 4. Remove the mark: back to one rest of 12, with nothing left over.
39
+ 5. Change the key signature at measure 5: a rest of 4, then a rest of 8 that begins with the new key signature. Repeat with the time signature, and with a displayed tempo change (the tempo shows over the second rest).
40
+ 6. Put a D.S. al Coda on measure 4 and a Coda sign on measure 9: the first rest is measures 1 to 4 with the D.S. al Coda shown over it; measures 5 to 8 are a rest of 4; measures 9 to 12 are a rest of 4 with the Coda sign at its start, after the barline.
41
+ 7. Set an end-repeat barline at the end of measure 4: the first rest ends with the repeat barline. Set a start-repeat on measure 5 instead: the second rest begins with it. Neither barline is drawn twice.
42
+ 8. Put a rehearsal mark and a D.S. on the same measure: that measure is a single ordinary bar with both, between two rests.
43
+ 9. Add a second staff to the part (include the next stave): both staves show the same grouping.
44
+ 10. Turn on "Expand Multimeasure Rests" in Part Properties: every measure appears individually.
45
+ 11. Print preview: same grouping as on screen.
46
+ 12. Check which of the edits above regroup immediately (a full layout) and which only after the part is shown again; note any that do not.
@@ -0,0 +1,63 @@
1
+ # Research: Split Multimeasure Rests at Landmarks
2
+
3
+ Findings from reading the code. No NEEDS CLARIFICATION items remained after the spec and the user's clarifications.
4
+
5
+ ## 1. Where the lone rest bar comes from
6
+
7
+ **Finding**: `computeMultipartRest` (operations.ts) walks the measures: if `isMultimeasureRest(i, true, forceRest)` it extends `j` while `isMultimeasureRest(j, false, forceRest)` and no `restBreak`, and records a block only when `j - i >= 2`; otherwise it advances by one and clears `hideMultimeasure`. `SmoScore.isMultimeasureRest` returns false, for both the "start" and "continue" calls, if any staff has a volta on the measure, a repeat symbol (`isRepeatSymbol`), a rehearsal mark, or (staff index above 0) an instrument entry on the measure. Only the key and time signature checks, and the previous-measure repeat check, are skipped for a start. So a rehearsal mark on measure 6 of a run of rests ends the block at measure 5 (6 fails to continue), then 6 fails the *start* test too, so it is stepped over as an ordinary rest bar, and a new block starts at 7: the lone bar between two multimeasure rests.
8
+
9
+ **Decision**: Separate "can this measure be in a block at all" (volta, forced) from "does this measure break the run before it" (start landmarks) and "does this measure close the run after it" (end landmarks), and rewrite the loop around those.
10
+
11
+ ## 2. Which landmarks are already handled
12
+
13
+ **Finding**: Key and time signature differences are only tested when continuing (`!start`), so a key or time change already ends one block and starts the next with no lone bar. The reported problem for those two is therefore in the drawing (does the second block show the new signature?) rather than in the grouping, or it is a different path; the manual check in quickstart.md covers it. A tempo change is not tested at all today, so a tempo change inside a run of rests does not split it.
14
+
15
+ **Decision**: Keep the key/time rule, add tempo (a change from the previous measure's tempo, counted only if the new tempo is displayed, since otherwise there is nothing for the player to see). Verify the signature drawing by hand, and fix it in the drawing code only if it fails.
16
+
17
+ ## 3. Start versus end landmarks
18
+
19
+ **Finding**: `SmoRepeatSymbol.symbols` are Coda, Segno, ToCoda, DcAlCoda, DcAlFine, DsAlCoda, DsAlFine, Fine. `SmoBarline` start and end barlines are per measure (`getStartBarline`, `getEndBarline`); today `SmoSystemStaff.isRepeat(index)` mixes them: it is true if the *next* measure's start barline is special, or this measure's end barline is special, or this measure has a repeat symbol, and the loop uses it as "measure i-1 closes a run" (`!start && isRepeat(measureIndex - 1)`).
20
+
21
+ **Decision**:
22
+
23
+ - Start landmark at measure m (any staff): rehearsal mark; repeat symbol Segno or Coda; tempo change (displayed); key signature change; time signature change; start barline that is not a single bar or no bar; an instrument map entry at m > 0.
24
+ - End landmark at measure m (any staff): repeat symbol ToCoda, DC/DS al Coda/Fine, or Fine; end barline that is not a single bar or no bar.
25
+ - Blocked (never in a block, as today): a volta ending covering the measure on any staff; and the quirk below.
26
+ - A block is a start measure followed by every following rest measure that is not blocked, has no `restBreak`, and has no start landmark, stopping after the first measure that has an end landmark. A start measure that is itself an end measure closes at once (a single bar).
27
+ - Key and time comparisons stay against the previous measure on staff 0, as today. Tempo likewise compares staff 0.
28
+
29
+ ## 4. A legacy quirk kept on purpose
30
+
31
+ **Finding**: The instrument test is `measureInstrumentMap[measureIndex] && i > 0`: for any staff after the first, an instrument entry on the measure counts. Every staff has an entry at measure 0, so in a multi-staff part measure 0 can never start a block today (it is shown as an ordinary bar and a block starts at measure 1). That looks accidental but changes the look of every multi-staff part's first bar.
32
+
33
+ **Decision**: Do not change it here (SC-004 says scores without landmarks inside rests look as before). Measure 0 of a multi-staff part stays "blocked" from starting a block. An instrument entry at m > 0 on any staff, including the first, becomes a start landmark. Flag the quirk to the maintainer as a separate question.
34
+
35
+ ## 5. Why an end symbol vanishes
36
+
37
+ **Finding**: `SuiRenderState`/`vxSystem.renderMeasure` returns immediately for any measure with `svg.hideMultimeasure`, and `vxMeasure.createMeasureModifiers` draws the repeat symbol (`VF.Repetition`) from the measure's own `getRepeatSymbol()` only when `firstInColumn`. In a block, every measure after the first is hidden. A D.S. on the last measure of a block is on a hidden measure, so it is never drawn. The start measure's `svg` also carries `multimeasureEndBarline`, copied from the last measure's end barline, which is how an end repeat bar is already shown at the end of a block.
38
+
39
+ **Decision**: Record the last measure's end-type symbol on the block's first measure as a runtime field `svg.multimeasureEndSymbol`, and draw it in `createMeasureModifiers` over the multimeasure rest (position from the symbol's own x/y offset, as for any symbol). Do the same for the VexFlow export path (`toVex.ts`) only if it draws repeat symbols; check during implementation.
40
+
41
+ ## 6. Stale flags
42
+
43
+ **Finding**: For a measure that is not a block start, the current code resets only `hideMultimeasure`; `multimeasureLength`, `multimeasureEndBarline` can keep values from an earlier grouping.
44
+
45
+ **Decision**: For every measure on every staff that is not a block start, set `multimeasureLength = 0`, reset `multimeasureEndBarline` to a single bar, and clear `multimeasureEndSymbol`. For a block start, set all three from the block.
46
+
47
+ ## 7. When the grouping is computed
48
+
49
+ **Finding**: `computeMultipartRest` is called only from `SuiScoreView.setView` (when a part is exposed) and `updatePartInfo`. Landmark edits in an exposed part therefore do not regroup until the part is re-exposed or its info is updated. The grouping only applies to parts (`expandMultimeasureRests` is set true for new full scores, and the loop is skipped when it is).
50
+
51
+ **Decision**: Also call `SmoOperation.computeMultipartRest(this.score)` at the start of `SuiLayoutFormatter.layout()` when `score.isPartExposed()`. Every full layout then reflects the current landmarks and rest content. Edits that only re-render single columns without a full layout (an existing limitation, for example typing a note into an already grouped measure) are out of scope; the manual check lists which landmark edits do a full layout.
52
+
53
+ ## 8. The public `isMultimeasureRest`
54
+
55
+ **Finding**: `SmoScore.isMultimeasureRest(measureIndex, start, forceRest)` is public and exported with the library, though the only caller in `src/` is `computeMultipartRest`.
56
+
57
+ **Decision**: Leave it unchanged (same behavior for outside callers), mark it as superseded in its doc comment, and implement the new rule with new helpers. The same approach was used for `PromiseHelpers` in spec 029.
58
+
59
+ ## 9. Barline between blocks
60
+
61
+ **Finding**: A block's end barline comes from the last measure (`multimeasureEndBarline`) and its start barline from its first measure; hidden measures contribute neither, so a barline between two blocks is drawn once at the end of the first and once at the start of the second only if the user set both, exactly as for adjacent ordinary measures.
62
+
63
+ **Decision**: No special handling beyond the grouping rules. FR-007a is met by construction; confirm by hand.
@@ -0,0 +1,127 @@
1
+ # Feature Specification: Split Multimeasure Rests at Landmarks
2
+
3
+ **Feature Branch**: `032-split-multimeasure-rests`
4
+
5
+ **Created**: 2026-10-22
6
+
7
+ **Status**: Draft
8
+
9
+ **Input**: User description: "operations.ts computeMultipartRest and the logic in vxSystem, vxMeasure is not handling the case where a multimeasure rest is broken up because of a key signature, rehearsal mark, or other landmark. The score should display the landmark but it should not render a measure of rest between 2 multimeasure rests."
10
+
11
+ ## Clarifications
12
+
13
+ ### Session 2026-10-22
14
+
15
+ - Q: Where do landmarks that mark the end of a section (D.S., D.C., To Coda, Fine, an end-repeat or double barline) break the rest, and where are they shown? → A: The rest is broken after the measure that carries them, and they are shown on the first block (the symbol over that block's rest, the barline at its end).
16
+ - Q: Where do landmarks that mark the start of a section (Segno, Coda, a start-repeat or double barline, rehearsal mark) break the rest, and where are they shown? → A: The rest is broken before the measure that carries them, and they are shown at the beginning of the next block, after the separating barline.
17
+ - Q: Are tempo, key signature and time signature changes landmarks? → A: Yes, all three. Each is a start landmark: the rest is broken before the measure with the change and the change is shown at the start of the next block. (This replaces the earlier assumption that a tempo change does not split a rest.)
18
+
19
+ ## User Scenarios & Testing *(mandatory)*
20
+
21
+ ### User Story 1 - A rehearsal mark inside a long rest starts the next multimeasure rest (Priority: P1)
22
+
23
+ A composer or arranger has a part with many empty measures in a row. Normally these are shown as one multimeasure rest (a thick bar with a count, such as "10"). They put a rehearsal mark (for example "B") on measure 6, in the middle of the rest. The part should now show a multimeasure rest for measures 1 to 5, then a second multimeasure rest for measures 6 to 10 that carries the rehearsal mark "B". Today the rest is broken in the wrong way: the measure with the rehearsal mark is drawn as a separate, ordinary measure of rest in between, so the player sees a rest of 5, a single rest bar, and then a rest of 4.
24
+
25
+ **Why this priority**: Rehearsal marks are the most common reason to break a long rest, and every part with a rest of more than a few bars and rehearsal letters is affected. The extra single bar is a visible engraving error and misleads the player about the count.
26
+
27
+ **Independent Test**: Make 10 empty measures, put a rehearsal mark on measure 6, and view the score. You should see exactly two multimeasure rests: one for measures 1 to 5 and one for measures 6 to 10, with the rehearsal mark shown above the second. No ordinary rest measure appears between them.
28
+
29
+ **Acceptance Scenarios**:
30
+
31
+ 1. **Given** a run of empty measures with a rehearsal mark on a measure in the middle, **When** the score is displayed, **Then** the measures before the mark form one multimeasure rest and the mark's measure and the measures after it (up to the next break) form the next one, with the mark displayed.
32
+ 2. **Given** a rehearsal mark on the very first measure of a run of rests, **When** the score is displayed, **Then** the whole run is one multimeasure rest that starts with the mark.
33
+ 3. **Given** a rehearsal mark on a measure that is followed by music (not rests), **When** the score is displayed, **Then** that measure is shown as an ordinary measure of rest with its mark, because a single bar is not a multimeasure rest.
34
+ 4. **Given** two rehearsal marks in a run of rests, **When** the score is displayed, **Then** each mark begins its own multimeasure rest and no single-bar rest appears between them.
35
+
36
+ ---
37
+
38
+ ### User Story 2 - Key, time signature and tempo changes inside a long rest (Priority: P1)
39
+
40
+ The same rule applies when the key signature, time signature or tempo changes during a run of empty measures. The measures before the change form one multimeasure rest; the measure with the change starts the next multimeasure rest, and the new signature or tempo is shown at its start. There is never a lone ordinary rest measure between them.
41
+
42
+ **Why this priority**: Key and time changes during a rest are normal in orchestral parts (a movement may change key while a part is tacet), and the player must see the new signature before they play again.
43
+
44
+ **Independent Test**: Make 8 empty measures, change the key signature at measure 5, and view the score. Expect a multimeasure rest for measures 1 to 4, then a multimeasure rest for measures 5 to 8 that begins with the new key signature, with no single rest bar between them. Repeat for a time signature change.
45
+
46
+ **Acceptance Scenarios**:
47
+
48
+ 1. **Given** a run of empty measures with a key signature change at one measure, **When** the score is displayed, **Then** the rest is split into two multimeasure rests at that measure, and the new key signature is displayed at the start of the second.
49
+ 2. **Given** a time signature change inside a run of empty measures, **When** the score is displayed, **Then** the same split occurs and the new time signature is displayed at the start of the second.
50
+ 3. **Given** a run of empty measures with a tempo change at one measure, **When** the score is displayed, **Then** the same split occurs and the new tempo is displayed at the start of the second.
51
+ 4. **Given** a run of empty measures with both a key signature change and a rehearsal mark on the same measure, **When** the score is displayed, **Then** one split is made there, and both are displayed.
52
+
53
+ ---
54
+
55
+ ### User Story 3 - Landmarks that end a section break the rest after their measure (Priority: P1)
56
+
57
+ Some markings belong to the end of a measure, not its start: D.S. and D.C. (al Coda, al Fine), To Coda, Fine, and an end-repeat or double barline. When one of these is on an empty measure inside a run of rests, the rest is broken after that measure: the measure with the marking is the last bar of its block, the marking is shown over that block's rest (or, for a barline, at the end of the block), and the next block begins on the following measure. Markings that belong to the start of a measure (Segno, Coda, a start-repeat or double barline) are handled as in User Story 1: the rest is broken before that measure, and the marking is shown at the beginning of the next block, after the separating barline.
58
+
59
+ **Why this priority**: Without this rule, a "D.S. al Coda" in the middle of a long rest would either be lost or would force a lone rest bar. Players rely on seeing the instruction where the music ends, and on a Segno or Coda sign where the music resumes.
60
+
61
+ **Independent Test**: Make 12 empty measures. Put a D.S. al Coda on measure 4 and a Coda sign on measure 9. View the score. Expect a multimeasure rest for measures 1 to 4 with the D.S. al Coda shown over it, a multimeasure rest for measures 5 to 8, and a multimeasure rest for measures 9 to 12 with the Coda sign shown at its start, after the barline. No ordinary rest bar appears between them.
62
+
63
+ **Acceptance Scenarios**:
64
+
65
+ 1. **Given** a D.S., D.C., To Coda or Fine marking on an empty measure inside a run of rests, **When** the score is displayed, **Then** the rest is broken after that measure and the marking is displayed over the multimeasure rest that ends with it.
66
+ 2. **Given** a Segno or Coda sign on an empty measure inside a run of rests, **When** the score is displayed, **Then** the rest is broken before that measure and the sign is displayed at the beginning of the multimeasure rest that starts with it, after the barline that separates the blocks.
67
+ 3. **Given** an end-repeat barline or a double barline at the end of an empty measure inside a run of rests, **When** the score is displayed, **Then** the rest is broken after that measure and the barline is drawn at the end of the block that ends with it.
68
+ 4. **Given** a start-repeat barline or a double barline at the start of an empty measure inside a run of rests, **When** the score is displayed, **Then** the rest is broken before that measure and the barline is drawn at the start of the block that begins with it.
69
+ 5. **Given** a rest that is broken at a barline, **When** the score is displayed, **Then** the barline appears once, between the two blocks, and not both at the end of the first block and again at the start of the second.
70
+
71
+ ---
72
+
73
+ ### Edge Cases
74
+
75
+ - What happens when a start landmark sits on the last measure of the run of rests, so only one measure would follow it? That measure is a single bar and is shown as an ordinary measure of rest, as today, because there is nothing to merge it with.
76
+ - What happens when an end landmark (such as D.S.) is on the first measure of a run of rests? That measure is a single bar, shown as an ordinary measure of rest with the marking, and the rest continues after it.
77
+ - What happens when one measure carries both a start landmark and an end landmark (for example a rehearsal mark and a D.S.)? That measure is a block of its own, shown as an ordinary measure of rest with both markings, between the blocks before and after it. This is unavoidable, and is the only case where a single rest bar appears between multimeasure rests.
78
+ - What happens when the measure after a split is followed by notes? The measure carrying the landmark is an ordinary rest bar, and the music follows.
79
+ - What happens when the run of rests has start landmarks on consecutive measures (for example marks on 5 and 6)? Measure 5 is a single bar with its mark; measure 6 starts the next multimeasure rest, if the rest continues.
80
+ - What happens when a part with more than one staff is displayed (for example a piano part)? A landmark on any staff splits the rest on all staves, since all staves must have the same measure groupings, and each staff shows the landmark it has.
81
+ - What happens when a part is displayed with "expand multimeasure rests" turned on? Every rest measure is shown individually, as today, and nothing changes.
82
+ - What happens when the user adds or removes a landmark? The grouping updates at the next display, with no leftover single-bar rest.
83
+ - What happens when a measure that is part of a repeat ending (volta bracket) is empty? These keep the behavior they have today: measures under an ending bracket are shown individually. This feature does not change how endings are shown.
84
+ - What happens when the score is printed or exported to an image? The same grouping is used.
85
+
86
+ ## Requirements *(mandatory)*
87
+
88
+ ### Functional Requirements
89
+
90
+ - **FR-001**: A run of consecutive empty measures MUST be shown as a multimeasure rest, unless multimeasure rests are turned off for the score or part.
91
+ - **FR-002**: A landmark that belongs to the start of a measure (a start landmark) MUST end the multimeasure rest that precedes that measure: the measures before it are one multimeasure rest and the landmark's measure is not part of that rest.
92
+ - **FR-003**: The measure carrying a start landmark MUST start a new multimeasure rest that includes it and the empty measures that follow it, up to the next break. The landmark MUST be displayed at the beginning of that rest, after the barline that separates the blocks.
93
+ - **FR-004**: The start landmarks are: a rehearsal mark, a key signature change, a time signature change, a tempo change, a Segno or Coda sign, a start-repeat barline or a double barline at the start of a measure, and a change of instrument.
94
+ - **FR-005**: A landmark that belongs to the end of a measure (an end landmark) MUST end the multimeasure rest at that measure: the measure carrying it is the last bar of its block, and the next block begins on the following measure. The landmark MUST be displayed on the block that ends with it: a D.S., D.C., To Coda or Fine marking over the rest, and an end-repeat or double barline at the end of the block.
95
+ - **FR-005a**: The end landmarks are: a D.S. or D.C. marking (al Coda or al Fine), To Coda, Fine, and an end-repeat barline or a double barline at the end of a measure.
96
+ - **FR-006**: The system MUST NOT draw an ordinary measure of rest between two multimeasure rests merely because the second begins at a start landmark or the first ends at an end landmark.
97
+ - **FR-007**: A measure that is the only empty measure in its block (for example, a start landmark followed by music, an end landmark right after another break, or a measure carrying both kinds) MUST be shown as an ordinary measure of rest with its landmarks.
98
+ - **FR-007a**: A barline that falls between two blocks MUST be drawn once, between them, as the end of the first block or the start of the second as appropriate, and MUST NOT be repeated at both.
99
+ - **FR-008**: The grouping MUST be the same on every staff of the displayed score, and a landmark on any staff MUST split the rest on all of them.
100
+ - **FR-009**: The count shown on each multimeasure rest MUST be the number of measures it spans, and the sum of the counts of adjacent rests plus any single bars between them MUST equal the number of empty measures.
101
+ - **FR-010**: Turning on "expand multimeasure rests" for a part MUST continue to show every measure individually, and measures under a repeat ending MUST keep their current behavior.
102
+ - **FR-011**: The grouping MUST be recomputed whenever the displayed measures change (editing, adding or removing a landmark, changing the part), so that no stale single-bar rest or hidden measure remains.
103
+
104
+ ### Key Entities
105
+
106
+ - **Multimeasure rest**: A group of two or more consecutive empty measures drawn as one measure with a count.
107
+ - **Start landmark**: A marking that belongs to the beginning of a measure: rehearsal mark, key, time or tempo change, Segno, Coda, start-repeat or double barline, instrument change.
108
+ - **End landmark**: A marking that belongs to the end of a measure: D.S., D.C., To Coda, Fine, end-repeat or double barline.
109
+ - **Break**: The point between two measures at which one multimeasure rest ends and the next begins: just before a measure with a start landmark, or just after a measure with an end landmark.
110
+
111
+ ## Success Criteria *(mandatory)*
112
+
113
+ ### Measurable Outcomes
114
+
115
+ - **SC-001**: In a run of N empty measures with B breaks (each start landmark not on the first measure and each end landmark not on the last measure adds one), the score shows B + 1 blocks, a block of two or more measures is one multimeasure rest, no block of two or more measures is drawn as separate rests, and the measures shown add up to N.
116
+ - **SC-002**: Each start landmark is visible at the beginning of the block it starts, and each end landmark on the block it ends, in 100% of cases.
117
+ - **SC-003**: With "expand multimeasure rests" on, the score shows N separate measures, as before, in 100% of cases.
118
+ - **SC-004**: Scores with no landmarks inside their runs of empty measures display exactly as they did before this change.
119
+ - **SC-005**: After adding or removing a landmark, the displayed grouping matches a fresh display of the same score in 100% of cases.
120
+
121
+ ## Assumptions
122
+
123
+ - "Empty measure" means a measure that contains only rests, as the application already defines it for multimeasure rests.
124
+ - Which measures count as a landmark is the set in FR-004 and FR-005a. Text annotations are not landmarks and do not split a rest. Measures covered by a repeat ending bracket keep today's behavior and are out of scope.
125
+ - Multi-staff scores always keep the same grouping on all staves, since the staves share their measures' positions.
126
+ - The rule applies equally when a part is displayed, since a part is just a score showing selected staves.
127
+ - The count shown on a multimeasure rest and its end barline follow the existing rules; only where a rest starts and ends changes.