Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

refactor: keep AI song parts aligned with editor pickers (#9338)

[._.]/ Adam Eivy2555965e9f03
diff --git a/client/src/lib/songCraft.js b/client/src/lib/songCraft.js
index db1d8a188d..2653b31a86 100644
--- a/client/src/lib/songCraft.js
+++ b/client/src/lib/songCraft.js
@@ -1,10 +1,16 @@
+import {
+ RHYTHM_SHAPES as SHARED_RHYTHM_SHAPES,
+ VOICE_LAYERS as SHARED_VOICE_LAYERS,
+ HARMONY_PARTS as SHARED_HARMONY_PARTS,
+} from '../../../server/lib/songCraftParts.js';
+
// Canonical a cappella song-craft reference data: dirge rhythm shapes, the
// layer-building ladder, a learning sequence, musical-notation help, and the
// movable-do solfège scale. The Songs Guide page renders directly from these
// arrays (rhythm shapes, layer ladder, learning steps, notation, solfège), and
// the Song editor reuses RHYTHM_SHAPES and VOICE_LAYERS for its picker options
// so the editor and the docs never drift. Keep this module pure (no React, no
-// imports) — it is mirrored into the client lib barrel and unit-tested.
+// side effects) — shared vocabulary comes from a pure server/lib leaf.
// --- Rhythm shapes ---------------------------------------------------------
// A "rhythm shape" is the felt pulse + note-length feel a song leans on. A
@@ -13,62 +19,43 @@
// the typical tempo band, `feel` the conductor's count, and `count` a spoken
// counting pattern the singer can tap. `dirge` marks the shapes that suit a
// lament so the guide can highlight the slow family the user asked about.
-export const RHYTHM_SHAPES = [
- {
- id: 'slow-4-4',
- label: 'Slow 4/4 ballad',
- dirge: true,
+const RHYTHM_SHAPES_PRESENTATION = {
+ 'slow-4-4': {
bpm: { min: 56, max: 76, label: '56–76 BPM' },
- feel: 'Four even beats per bar, weight on 1 and 3.',
count: '1 — 2 — 3 — 4',
note: 'The default lament pulse. "500 Miles" lives here: long sustained vowels on the downbeats, lyrics breathing across the bar rather than chopping it up.',
},
- {
- id: 'dirge-6-8',
- label: 'Compound 6/8 dirge',
- dirge: true,
+ 'dirge-6-8': {
bpm: { min: 40, max: 60, label: '40–60 BPM (dotted-quarter pulse)' },
- feel: 'Two slow pulses per bar, each split into three — a swaying funeral-march lilt.',
count: 'ONE-and-a Two-and-a',
note: 'The rocking 6/8 underpins many spirituals and laments. Conduct in 2, sing in 6 — the triple subdivision gives the grief a heave-and-settle.',
},
- {
- id: 'rubato-free',
- label: 'Rubato / free-time lament',
- dirge: true,
+ 'rubato-free': {
bpm: { min: null, max: null, label: 'No fixed tempo — follow the lead' },
- feel: 'Pulse stretches and contracts with the phrase; the lead breathes, the layers follow.',
count: 'Follow the words, not a click',
note: 'Used for the most exposed laments. Drop the metronome: cadence on the lyric, let the harmony swell and release with the lead singer.',
},
- {
- id: 'cut-time-march',
- label: 'Cut-time processional',
- dirge: true,
+ 'cut-time-march': {
bpm: { min: 60, max: 84, label: '60–84 BPM (half-note pulse)' },
- feel: 'Two broad pulses per bar — a walking, processional tread.',
count: 'ONE . . . TWO . . .',
note: 'A dirge that moves. The half-note pulse keeps it solemn but gives a forward, funeral-procession walk under the melody.',
},
- {
- id: 'driving-4-4',
- label: 'Driving 4/4 (uptempo)',
- dirge: false,
+ 'driving-4-4': {
bpm: { min: 96, max: 132, label: '96–132 BPM' },
- feel: 'Steady, energetic four — backbeat emphasis on 2 and 4.',
count: '1 2 3 4 with a clap on 2 & 4',
note: 'Not a dirge — the contrast point. Useful when a set needs to lift out of the laments; clap or stomp the backbeat to drive it.',
},
- {
- id: 'waltz-3-4',
- label: 'Waltz 3/4',
- dirge: false,
+ 'waltz-3-4': {
bpm: { min: 84, max: 144, label: '84–144 BPM' },
- feel: 'Three beats per bar, strong downbeat then two lighter beats.',
count: 'ONE two three',
note: 'A lilting triple meter. Slowed right down it can read as a tender lament; kept moving it sways.',
},
-];
+};
+
+export const RHYTHM_SHAPES = SHARED_RHYTHM_SHAPES.map((part) => ({
+ ...RHYTHM_SHAPES_PRESENTATION[part.id],
+ ...part,
+}));
// Human-readable label for a rhythm shape id — `Slow 4/4 ballad · dirge
// (56–76 BPM)`. Shared by the editor's <select> options and the read-only
@@ -92,56 +79,37 @@ export const rhythmShapeLabel = (id) => {
// inner voices → upper voices); `voices` names the typical SATB-ish home.
// songCraft.test.js guards that every layer id+label still exists in
// HARMONY_PARTS so the two vocabularies can't drift apart.
-export const VOICE_LAYERS = [
- {
- id: 'melody',
- label: 'Melody',
+const VOICE_LAYERS_PRESENTATION = {
+ 'melody': {
order: 1,
- voices: 'Any — the tune everyone knows',
- role: 'The lead — the song itself. Everyone learns this first so the harmony has a home to orbit.',
advice: 'Lock the lead before adding anything. If the melody is shaky, every layer above it wobbles.',
},
- {
- id: 'bass',
- label: 'Bass',
+ 'bass': {
order: 2,
- voices: 'Bass',
- role: 'The harmonic floor — the root of each chord with the fifth as gentle movement.',
advice: 'Add the bass second. It defines the chord under the melody and gives the upper voices their tuning reference.',
},
- {
- id: 'mid-harmony-1',
- label: 'Mid Harmony I',
+ 'mid-harmony-1': {
order: 3,
- voices: 'Alto / Tenor',
- role: 'The main moving inner voice — a third/sixth below the melody but landing on chord tones.',
advice: 'The richest harmony, so build it first among the inner voices. Move smoothly and favour common tones between chords.',
},
- {
- id: 'mid-harmony-2',
- label: 'Mid Harmony II',
+ 'mid-harmony-2': {
order: 4,
- voices: 'Alto',
- role: 'A low inner pad — sustained chord tones below the melody (often the 3rd or 5th of the chord).',
advice: 'Fills the chord under Mid Harmony I. Sustain and move by step; do not chase the melody.',
},
- {
- id: 'high-harmony-2',
- label: 'High Harmony II',
+ 'high-harmony-2': {
order: 5,
- voices: 'Soprano / Tenor',
- role: 'A sustained upper chord tone with gentle suspensions — carries the leading tone that pulls back to the tonic.',
advice: 'A held pad above the inner voices. Keep the dominant-7 third so it resolves up to the tonic.',
},
- {
- id: 'high-harmony-1',
- label: 'High Harmony I',
+ 'high-harmony-1': {
order: 6,
- voices: 'Soprano',
- role: 'The sparse top descant — mostly sustained high chord tones, entering on the emotional phrases.',
advice: 'The shimmer on top. Save it for the climaxes; rest through the opening and enter late.',
},
-];
+};
+
+export const VOICE_LAYERS = SHARED_VOICE_LAYERS.map((part) => ({
+ ...VOICE_LAYERS_PRESENTATION[part.id],
+ ...part,
+}));
// --- Harmony parts (sheet-music variations) --------------------------------
// The set of sheet-music parts a song can carry beyond its base melody. The
@@ -158,70 +126,32 @@ export const VOICE_LAYERS = [
//
// `order` lays the stack low→high for the View-tab switcher; `range` and
// `voicing` are the per-voice rules the derive prompt and the UI hint inject.
-// Mirrored (id/label/role/order/range/voicing) in server/lib/songCraftRef.js so
-// the AI prompt and the editor agree.
-export const HARMONY_PARTS = [
- {
- id: 'melody',
- label: 'Melody',
- role: 'melody',
- order: 0,
- range: 'as written',
- derivable: false,
- voicing: 'The lead — carries the lyric and rhythmic detail. The base every harmony targets.',
+// Identity and voicing come from the same vocabulary the AI prompts use.
+const HARMONY_PARTS_PRESENTATION = {
+ 'melody': {
advice: 'This is the base score. Lock it first; every derived part is voiced against its chords and phrasing.',
},
- {
- id: 'bass',
- label: 'Bass',
- role: 'bass',
- order: 1,
- range: 'G2–D3 (down to E2)',
- derivable: true,
- voicing: 'Root of each chord, with the fifth as gentle movement — a hymn-like root–fifth–root drone.',
+ 'bass': {
advice: 'The harmonic floor and tuning reference. Long tones or soft pulses on beats 1 and 3; keep it simple.',
},
- {
- id: 'mid-harmony-2',
- label: 'Mid Harmony II',
- role: 'harmony',
- order: 2,
- range: 'B2–E4',
- derivable: true,
- voicing: 'Low inner pad — sustained chord tones below the melody (often the 3rd or 5th of the chord).',
+ 'mid-harmony-2': {
advice: 'Fills the chord under Mid Harmony I. Sustain and move by step; do not chase the melody.',
},
- {
- id: 'mid-harmony-1',
- label: 'Mid Harmony I',
- role: 'harmony',
- order: 3,
- range: 'D3–G4',
- derivable: true,
- voicing: 'The main moving inner voice — a third/sixth below the melody but landing on chord tones.',
+ 'mid-harmony-1': {
advice: 'The richest harmony. Move smoothly, favour common tones between chords, hold on a chord tone when the melody passes through a non-chord note.',
},
- {
- id: 'high-harmony-2',
- label: 'High Harmony II',
- role: 'harmony',
- order: 4,
- range: 'G3–B4',
- derivable: true,
- voicing: 'Sustained upper chord tone with gentle suspensions — carries the leading tone (the F# on D7) that pulls back to G.',
+ 'high-harmony-2': {
advice: 'A held pad above the inner voices. Keep the dominant-7 third (F# under D7) — it resolves up to the tonic.',
},
- {
- id: 'high-harmony-1',
- label: 'High Harmony I',
- role: 'harmony',
- order: 5,
- range: 'B3–E5',
- derivable: true,
- voicing: 'Sparse top descant — mostly sustained high chord tones, entering on the emotional phrases.',
+ 'high-harmony-1': {
advice: 'The shimmer on top. Save it for the climaxes; rest through the opening and enter late, mostly long notes.',
},
-];
+};
+
+export const HARMONY_PARTS = SHARED_HARMONY_PARTS.map((part) => ({
+ ...HARMONY_PARTS_PRESENTATION[part.id],
+ ...part,
+}));
// The parts the AI derive tool generates from the base melody (everything except
// the melody itself, which is the input). Declaration order is low→high.
diff --git a/client/src/lib/songCraft.test.js b/client/src/lib/songCraft.test.js
index b228c399e4..da9c7fe108 100644
--- a/client/src/lib/songCraft.test.js
+++ b/client/src/lib/songCraft.test.js
@@ -13,7 +13,21 @@ import {
harmonyPartOrder,
} from './songCraft.js';
+import * as promptVocabulary from '../../../server/lib/songCraftRef.js';
+
describe('songCraft reference data', () => {
+ // Catches one-sided edits to prompt/picker ids, order, or shared semantics.
+ it('matches AI prompt vocabulary in order and every shared field', () => {
+ for (const [name, picker] of Object.entries({ RHYTHM_SHAPES, VOICE_LAYERS, HARMONY_PARTS })) {
+ const prompt = promptVocabulary[name];
+ const sharedFields = [...new Set(prompt.flatMap((part) => Object.keys(part)))];
+ const projection = picker.map((part) => Object.fromEntries(sharedFields.map((field) => [field, part[field]])));
+ expect(projection, name).toEqual(prompt);
+ }
+ expect(DIRGE_RHYTHM_SHAPES.map((part) => part.id)).toEqual(promptVocabulary.DIRGE_RHYTHM_SHAPES.map((part) => part.id));
+ expect(DERIVABLE_HARMONY_PARTS.map((part) => part.id)).toEqual(promptVocabulary.DERIVABLE_HARMONY_PARTS.map((part) => part.id));
+ });
+
it('every rhythm shape carries id, label, bpm band, feel, count and a boolean dirge flag', () => {
const ids = new Set();
for (const s of RHYTHM_SHAPES) {
diff --git a/server/lib/README.md b/server/lib/README.md
index 83ec5bc83e..2cacc841f1 100644
--- a/server/lib/README.md
+++ b/server/lib/README.md
@@ -515,7 +515,8 @@ The barrel `server/lib/index.js` is a machine-checkable enumeration of every pub
| Module | Purpose |
|---|---|
| `curatedGenomeMarkers.js` | SNP classification logic (`classifyGenotype`, `formatGenotype`, `resolveApoeHaplotype`) + `MARKER_CATEGORIES`; loads the ~116-marker dataset from the co-located `curatedGenomeMarkers.json` at module init. |
-| `songCraftRef.js` | Server-side mirror of the a cappella rhythm-shape + voice-layer vocabulary (`RHYTHM_SHAPES`, `VOICE_LAYERS`, `DIRGE_RHYTHM_SHAPES`) injected into the song generate/evaluate prompts so the model returns ids the editor pickers understand. Mirrors `client/src/lib/songCraft.js`. |
+| `songCraftParts.js` | Pure shared rhythm-shape, voice-layer, and harmony-part vocabulary used by AI prompts, browser pickers, and bundled scores. |
+| `songCraftRef.js` | Shared song vocabulary re-exports plus derived dirge and derivable-harmony subsets for AI prompts and bundled scores. |
## Domain utilities
diff --git a/server/lib/index.js b/server/lib/index.js
index b6dbfea1f4..26e111e62c 100644
--- a/server/lib/index.js
+++ b/server/lib/index.js
@@ -473,6 +473,7 @@ export * from './xmlEntities.js';
// === Curated static data ===
export * from './curatedGenomeMarkers.js';
+export * as songCraftParts from './songCraftParts.js';
export * from './songCraftRef.js';
// === Domain utilities ===
diff --git a/server/lib/songCraftParts.js b/server/lib/songCraftParts.js
new file mode 100644
index 0000000000..eb6fb5393c
--- /dev/null
+++ b/server/lib/songCraftParts.js
@@ -0,0 +1,30 @@
+/** Shared song vocabulary for AI prompts, editor pickers, and bundled scores.
+ * Pure data with no imports; presentation and teaching notes stay client-side.
+ */
+
+export const RHYTHM_SHAPES = [
+ { id: 'slow-4-4', label: 'Slow 4/4 ballad', dirge: true, feel: 'Four even beats per bar, weight on 1 and 3.' },
+ { id: 'dirge-6-8', label: 'Compound 6/8 dirge', dirge: true, feel: 'Two slow pulses per bar, each split into three — a swaying funeral-march lilt.' },
+ { id: 'rubato-free', label: 'Rubato / free-time lament', dirge: true, feel: 'Pulse stretches and contracts with the phrase; the lead breathes, the layers follow.' },
+ { id: 'cut-time-march', label: 'Cut-time processional', dirge: true, feel: 'Two broad pulses per bar — a walking, processional tread.' },
+ { id: 'driving-4-4', label: 'Driving 4/4 (uptempo)', dirge: false, feel: 'Steady, energetic four — backbeat emphasis on 2 and 4.' },
+ { id: 'waltz-3-4', label: 'Waltz 3/4', dirge: false, feel: 'Three beats per bar, strong downbeat then two lighter beats.' },
+];
+
+export const VOICE_LAYERS = [
+ { id: 'melody', label: 'Melody', voices: 'Any — the tune everyone knows', role: 'The lead — the song itself. Everyone learns this first so the harmony has a home to orbit.' },
+ { id: 'bass', label: 'Bass', voices: 'Bass', role: 'The harmonic floor — the root of each chord with the fifth as gentle movement.' },
+ { id: 'mid-harmony-1', label: 'Mid Harmony I', voices: 'Alto / Tenor', role: 'The main moving inner voice — a third/sixth below the melody but landing on chord tones.' },
+ { id: 'mid-harmony-2', label: 'Mid Harmony II', voices: 'Alto', role: 'A low inner pad — sustained chord tones below the melody (often the 3rd or 5th of the chord).' },
+ { id: 'high-harmony-2', label: 'High Harmony II', voices: 'Soprano / Tenor', role: 'A sustained upper chord tone with gentle suspensions — carries the leading tone that pulls back to the tonic.' },
+ { id: 'high-harmony-1', label: 'High Harmony I', voices: 'Soprano', role: 'The sparse top descant — mostly sustained high chord tones, entering on the emotional phrases.' },
+];
+
+export const HARMONY_PARTS = [
+ { id: 'melody', label: 'Melody', role: 'melody', order: 0, range: 'as written', derivable: false, voicing: 'The lead — carries the lyric and rhythmic detail. The base every harmony targets.' },
+ { id: 'bass', label: 'Bass', role: 'bass', order: 1, range: 'G2–D3 (down to E2)', derivable: true, voicing: 'Root of each chord, with the fifth as gentle movement — a hymn-like root–fifth–root drone.' },
+ { id: 'mid-harmony-2', label: 'Mid Harmony II', role: 'harmony', order: 2, range: 'B2–E4', derivable: true, voicing: 'Low inner pad — sustained chord tones below the melody (often the 3rd or 5th of the chord).' },
+ { id: 'mid-harmony-1', label: 'Mid Harmony I', role: 'harmony', order: 3, range: 'D3–G4', derivable: true, voicing: 'The main moving inner voice — a third/sixth below the melody but landing on chord tones.' },
+ { id: 'high-harmony-2', label: 'High Harmony II', role: 'harmony', order: 4, range: 'G3–B4', derivable: true, voicing: 'Sustained upper chord tone with gentle suspensions — carries the leading tone (the F# on D7) that pulls back to G.' },
+ { id: 'high-harmony-1', label: 'High Harmony I', role: 'harmony', order: 5, range: 'B3–E5', derivable: true, voicing: 'Sparse top descant — mostly sustained high chord tones, entering on the emotional phrases.' },
+];
diff --git a/server/lib/songCraftRef.js b/server/lib/songCraftRef.js
index 20d313ced9..66cf7323e8 100644
--- a/server/lib/songCraftRef.js
+++ b/server/lib/songCraftRef.js
@@ -1,65 +1,12 @@
-/**
- * Server-side mirror of the a cappella song-craft vocabulary.
- *
- * The full reference data (BPM bands, counts, learning steps, notation help,
- * solfège) lives client-side in `client/src/lib/songCraft.js` and is rendered
- * by the Songs Guide. The server only needs the *vocabulary* — the rhythm-shape
- * and voice-layer ids/labels/roles — so it can inject them into the AI
- * generate/evaluate prompts and the model returns ids the editor pickers already
- * understand. Kept as a deliberate, small mirror (not a shared import: client
- * and server are separate packages) — `server/services/rounds.js` already
- * documents this mirror relationship for the sanitizer's id vocabulary.
- *
- * Pure data, no imports. If you add/rename a shape or layer id here, mirror it
- * in `client/src/lib/songCraft.js` (and vice versa) so generated ids resolve in
- * the UI. Unknown ids are tolerated downstream (free-text fallback), so a brief
- * drift can't 400 — but it costs picker resolution until reconciled.
+/** Song vocabulary injected into the generate/evaluate/derive prompts.
+ * The browser enriches the same pure data with guide-only presentation fields.
*/
+import { RHYTHM_SHAPES, VOICE_LAYERS, HARMONY_PARTS } from './songCraftParts.js';
-// Rhythm shapes: { id, label, dirge, feel }. `dirge` marks the slow/lament
-// family the workbench is built around. Mirrors RHYTHM_SHAPES in songCraft.js.
-export const RHYTHM_SHAPES = [
- { id: 'slow-4-4', label: 'Slow 4/4 ballad', dirge: true, feel: 'Four even beats per bar, weight on 1 and 3.' },
- { id: 'dirge-6-8', label: 'Compound 6/8 dirge', dirge: true, feel: 'Two slow pulses per bar, each split into three — a swaying funeral-march lilt.' },
- { id: 'rubato-free', label: 'Rubato / free-time lament', dirge: true, feel: 'Pulse stretches and contracts with the phrase; the lead breathes, the layers follow.' },
- { id: 'cut-time-march', label: 'Cut-time processional', dirge: true, feel: 'Two broad pulses per bar — a walking, processional tread.' },
- { id: 'driving-4-4', label: 'Driving 4/4 (uptempo)', dirge: false, feel: 'Steady, energetic four — backbeat emphasis on 2 and 4.' },
- { id: 'waltz-3-4', label: 'Waltz 3/4', dirge: false, feel: 'Three beats per bar, strong downbeat then two lighter beats.' },
-];
-
-// Voice layers in foundation-first build order: { id, label, voices, role }.
-// SAME vocabulary as HARMONY_PARTS (ids + labels match) so recording "take types"
-// stay in step with the parts the derive tool generates. Mirrors VOICE_LAYERS in
-// songCraft.js.
-export const VOICE_LAYERS = [
- { id: 'melody', label: 'Melody', voices: 'Any — the tune everyone knows', role: 'The lead — the song itself. Everyone learns this first so the harmony has a home to orbit.' },
- { id: 'bass', label: 'Bass', voices: 'Bass', role: 'The harmonic floor — the root of each chord with the fifth as gentle movement.' },
- { id: 'mid-harmony-1', label: 'Mid Harmony I', voices: 'Alto / Tenor', role: 'The main moving inner voice — a third/sixth below the melody but landing on chord tones.' },
- { id: 'mid-harmony-2', label: 'Mid Harmony II', voices: 'Alto', role: 'A low inner pad — sustained chord tones below the melody (often the 3rd or 5th of the chord).' },
- { id: 'high-harmony-2', label: 'High Harmony II', voices: 'Soprano / Tenor', role: 'A sustained upper chord tone with gentle suspensions — carries the leading tone that pulls back to the tonic.' },
- { id: 'high-harmony-1', label: 'High Harmony I', voices: 'Soprano', role: 'The sparse top descant — mostly sustained high chord tones, entering on the emotional phrases.' },
-];
+export { RHYTHM_SHAPES, VOICE_LAYERS, HARMONY_PARTS };
// The dirge-family shapes (the lament the workbench centers on), in order.
export const DIRGE_RHYTHM_SHAPES = RHYTHM_SHAPES.filter((s) => s.dirge);
-// Sheet-music harmony parts: { id, label, role, order, range, derivable, voicing }.
-// The base score is the `melody`; the derivable parts are what the AI derive tool
-// produces from it. The voicing model is CHORD-TONE (each voice targets a chord
-// tone and moves smoothly), NOT parallel-interval tracking of the melody — see
-// client/src/lib/songCraft.js for the full rationale. Injected into the derive
-// prompt so the model voices each part correctly and returns ids the editor's
-// switcher understands. Mirrors HARMONY_PARTS in songCraft.js — keep
-// id/label/role/order/range/voicing in sync.
-export const HARMONY_PARTS = [
- { id: 'melody', label: 'Melody', role: 'melody', order: 0, range: 'as written', derivable: false, voicing: 'The lead — carries the lyric and rhythmic detail. The base every harmony targets.' },
- { id: 'bass', label: 'Bass', role: 'bass', order: 1, range: 'G2–D3 (down to E2)', derivable: true, voicing: 'Root of each chord, with the fifth as gentle movement — a hymn-like root–fifth–root drone.' },
- { id: 'mid-harmony-2', label: 'Mid Harmony II', role: 'harmony', order: 2, range: 'B2–E4', derivable: true, voicing: 'Low inner pad — sustained chord tones below the melody (often the 3rd or 5th of the chord).' },
- { id: 'mid-harmony-1', label: 'Mid Harmony I', role: 'harmony', order: 3, range: 'D3–G4', derivable: true, voicing: 'The main moving inner voice — a third/sixth below the melody but landing on chord tones.' },
- { id: 'high-harmony-2', label: 'High Harmony II', role: 'harmony', order: 4, range: 'G3–B4', derivable: true, voicing: 'Sustained upper chord tone with gentle suspensions — carries the leading tone (the F# on D7) that pulls back to G.' },
- { id: 'high-harmony-1', label: 'High Harmony I', role: 'harmony', order: 5, range: 'B3–E5', derivable: true, voicing: 'Sparse top descant — mostly sustained high chord tones, entering on the emotional phrases.' },
-];
-
-// The parts the derive tool generates (all but the melody, which is the input),
-// declaration order low→high.
+// The parts the derive tool generates, in declaration order low→high.
export const DERIVABLE_HARMONY_PARTS = HARMONY_PARTS.filter((p) => p.derivable);
diff --git a/server/services/rounds.js b/server/services/rounds.js
index 147feb7ed5..ddd1cd467d 100644
--- a/server/services/rounds.js
+++ b/server/services/rounds.js
@@ -20,6 +20,7 @@
import { join } from 'path';
import { randomUUID } from 'crypto';
import { PATHS, readJSONFile, atomicWrite } from '../lib/fileUtils.js';
+import { HARMONY_PARTS } from '../lib/songCraftRef.js';
import { createFileWriteQueue } from '../lib/fileWriteQueue.js';
import { sanitizeRound as sanitizeRoundRecord } from '../lib/roundsValidation.js';
@@ -57,10 +58,10 @@ export const sanitizeRound = (raw) => sanitizeRoundRecord(raw, BUILTIN_ROUND_IDS
// hymn-like root–fifth bass, two sustained inner pads, a sustained upper pad
// that carries the F#→G leading tone on D7, and a sparse top descant that enters
// late. Kept as a named export so SEED_ROUNDS and migration 076 share ONE source
-// (no drift). Voicing roles/ranges mirror songCraft.js HARMONY_PARTS.
-export const SEED_500_MILES_SCORE_PARTS = [
- {
- id: 'part-500-bass', label: 'Bass', role: 'bass',
+// (no drift). Part labels and roles come from the shared harmony vocabulary.
+const SEED_500_MILES_PART_SCORES = {
+ 'bass': {
+ id: 'part-500-bass',
score: [
'clef: bass', 'key: G', 'time: 4/4', 'tempo: 68', '',
'| rh [G] G2h(you) |',
@@ -73,8 +74,8 @@ export const SEED_500_MILES_SCORE_PARTS = [
'| [G] G2w(miles) |',
].join('\n'),
},
- {
- id: 'part-500-mid-2', label: 'Mid Harmony II', role: 'mid-harmony-2',
+ 'mid-harmony-2': {
+ id: 'part-500-mid-2',
score: [
'clef: treble', 'key: G', 'time: 4/4', 'tempo: 68', '',
'| rw |',
@@ -87,8 +88,8 @@ export const SEED_500_MILES_SCORE_PARTS = [
'| [G] G3w(miles) |',
].join('\n'),
},
- {
- id: 'part-500-mid-1', label: 'Mid Harmony I', role: 'mid-harmony-1',
+ 'mid-harmony-1': {
+ id: 'part-500-mid-1',
score: [
'clef: treble', 'key: G', 'time: 4/4', 'tempo: 68', '',
'| rw |',
@@ -101,8 +102,8 @@ export const SEED_500_MILES_SCORE_PARTS = [
'| [G] D4w(miles) |',
].join('\n'),
},
- {
- id: 'part-500-high-2', label: 'High Harmony II', role: 'high-harmony-2',
+ 'high-harmony-2': {
+ id: 'part-500-high-2',
score: [
'clef: treble', 'key: G', 'time: 4/4', 'tempo: 68', '',
'| rw |',
@@ -115,8 +116,8 @@ export const SEED_500_MILES_SCORE_PARTS = [
'| [G] G4w(miles) |',
].join('\n'),
},
- {
- id: 'part-500-high-1', label: 'High Harmony I', role: 'high-harmony-1',
+ 'high-harmony-1': {
+ id: 'part-500-high-1',
score: [
'clef: treble', 'key: G', 'time: 4/4', 'tempo: 68', '',
'| rw |',
@@ -129,7 +130,13 @@ export const SEED_500_MILES_SCORE_PARTS = [
'| [G] B4w(miles) |',
].join('\n'),
},
-];
+};
+
+// The worked example keeps its fixed staff set and notes as the vocabulary grows.
+export const SEED_500_MILES_SCORE_PARTS = Object.entries(SEED_500_MILES_PART_SCORES).map(([partId, score]) => {
+ const part = HARMONY_PARTS.find((p) => p.id === partId);
+ return { ...score, label: part.label, role: part.id };
+});
// Reference performances for the built-in "500 Miles" — TikTok clips the user
// pointed at as worked examples for the Reference material section. Kept as a