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

test: pin Python argparse choice lists to their JS exports (#9142)

Adam Eivybc2c65560d86
diff --git a/client/src/lib/muscriptorModels.js b/client/src/lib/muscriptorModels.js
index 1c5604a71c..9cf944e91a 100644
--- a/client/src/lib/muscriptorModels.js
+++ b/client/src/lib/muscriptorModels.js
@@ -5,9 +5,9 @@
// MIDI button's size <select>.
// Larger tiers are higher quality but slower and pull a bigger weight file on
// first use; `medium` is the balanced default. The server's z.enum in
-// server/lib/musicVideoValidation.js and MUSCRIPTOR_MODELS in
-// server/services/audioMidiTranscription.js must match these values — add a
-// tier here and to the server set together.
+// server/lib/musicVideoValidation.js imports MUSCRIPTOR_MODELS from
+// server/lib/muscriptorModels.js, which a parity test pins to the Python
+// runner's choices — add a tier there and here together.
export const MUSCRIPTOR_MODELS = ['small', 'medium', 'large'];
export const DEFAULT_MUSCRIPTOR_MODEL = 'medium';
diff --git a/server/lib/README.md b/server/lib/README.md
index d7a39ca817..a3519f5bfe 100644
--- a/server/lib/README.md
+++ b/server/lib/README.md
@@ -789,3 +789,4 @@ The barrel `server/lib/index.js` is a machine-checkable enumeration of every pub
| `authorLimits.js` | Author record length caps shared by the authors sanitizer and client editors. |
| `trackLimits.js` | Track record length/count caps shared by the tracks sanitizer and client editors. |
| `shellLimits.js` | `MAX_TOTAL_SESSIONS` shell-session cap shared by the shell service and the Shell UI. |
+| `muscriptorModels.js` | `MUSCRIPTOR_MODELS` (`small`/`medium`/`large`) — MuScriptor size tiers shared by route schemas and `audioMidiTranscription.js`; pinned to the Python runner's argparse choices. |
diff --git a/server/lib/index.js b/server/lib/index.js
index 7312c0b9cf..ab04bf7687 100644
--- a/server/lib/index.js
+++ b/server/lib/index.js
@@ -771,3 +771,4 @@ export * as authorLimits from './authorLimits.js';
export * as trackLimits from './trackLimits.js';
export * from './shellLimits.js';
export * from './layeredIntelligenceRejectionLabels.js';
+export * from './muscriptorModels.js';
diff --git a/server/lib/muscriptorModels.js b/server/lib/muscriptorModels.js
new file mode 100644
index 0000000000..dd381f2758
--- /dev/null
+++ b/server/lib/muscriptorModels.js
@@ -0,0 +1,4 @@
+// MuScriptor model sizes (weights auto-download on first use). Pure leaf shared
+// by the route schemas and services/audioMidiTranscription.js; a parity test
+// pins it to `--model` choices in scripts/transcribe_muscriptor.py.
+export const MUSCRIPTOR_MODELS = Object.freeze(['small', 'medium', 'large']);
diff --git a/server/lib/musicVideoValidation.js b/server/lib/musicVideoValidation.js
index b3d0b106a7..c9e9fe7191 100644
--- a/server/lib/musicVideoValidation.js
+++ b/server/lib/musicVideoValidation.js
@@ -16,6 +16,7 @@ import {
MUSIC_VIDEO_AUTOMATION_GUIDANCE_MAX,
MUSIC_VIDEO_AUTOMATION_TOOL_IDS,
} from './musicVideoAutomation.js';
+import { MUSCRIPTOR_MODELS } from './muscriptorModels.js';
import { IMAGE_GEN_MODES, VIDEO_GEN_MODES } from './generationModes.js';
// A project is authored hands-on (director) or seeded by the AI planner
@@ -657,7 +658,7 @@ export const musicVideoManualAnalysisSchema = z.object({
// `model` picks the MuScriptor size tier; the service clamps unknown values to
// its default, this only types the field.
export const musicVideoTranscribeMidiRequestSchema = z.object({
- model: z.enum(['small', 'medium', 'large']).optional(),
+ model: z.enum(MUSCRIPTOR_MODELS).optional(),
}).strict();
// The persisted MIDI-transcription pointer (a .mid basename under data/music/,
diff --git a/server/services/audioMidiTranscription.js b/server/services/audioMidiTranscription.js
index f37cc3e502..272927b0cc 100644
--- a/server/services/audioMidiTranscription.js
+++ b/server/services/audioMidiTranscription.js
@@ -30,6 +30,7 @@ import { fileURLToPath } from 'url';
import { tmpdir } from 'os';
import { PATHS, shortId, importFileToDir } from '../lib/fileUtils.js';
import { broadcastSse, attachSseClient as attachSse, closeJobAfterDelay } from '../lib/sseUtils.js';
+import { MUSCRIPTOR_MODELS } from '../lib/muscriptorModels.js';
import { killWithEscalation } from '../lib/killWithEscalation.js';
import { hfChildEnv } from './hfToken.js';
import { isGatedRepoError, extractGatedRepo } from '../lib/hfErrors.js';
@@ -44,7 +45,7 @@ const MUSCRIPTOR_SCRIPT = join(__dirname, '../../scripts/transcribe_muscriptor.p
// MuScriptor model sizes (weights auto-download on first use). Medium is the
// library default — a quality/speed balance; small is the CPU-friendly tier.
-export const MUSCRIPTOR_MODELS = Object.freeze(['small', 'medium', 'large']);
+export { MUSCRIPTOR_MODELS };
export const DEFAULT_MUSCRIPTOR_MODEL = 'medium';
/** Clamp a requested model size onto the known set (route validates shape; this guards the value). */
diff --git a/server/services/videoGen/pythonChoices.parity.test.js b/server/services/videoGen/pythonChoices.parity.test.js
new file mode 100644
index 0000000000..7b5ab3c90b
--- /dev/null
+++ b/server/services/videoGen/pythonChoices.parity.test.js
@@ -0,0 +1,35 @@
+import { describe, it, expect } from 'vitest';
+import { readFileSync } from 'fs';
+import { join, dirname } from 'path';
+import { fileURLToPath } from 'url';
+import { VIDEO_STREAMING_MODES } from '../../lib/videoStreamingMode.js';
+import { MUSCRIPTOR_MODELS } from '../../lib/muscriptorModels.js';
+import { FASTVIDEO_FAMILIES } from './renderArgs.js';
+
+// These value sets are declared in a Python helper's argparse `choices=` (the
+// helper must run standalone) and again in JS. Pin each pair so adding or
+// renaming a value on one side fails here, not at render time with argparse
+// exit code 2.
+const scriptsDir = join(dirname(fileURLToPath(import.meta.url)), '..', '..', '..', 'scripts');
+const strings = (text) => [...text.matchAll(/["']([^"']+)["']/g)].map(([, v]) => v);
+const read = (name) => readFileSync(join(scriptsDir, name), 'utf8');
+
+describe('Python argparse choices match their JS exports', () => {
+ it('LTX-2 streaming modes', () => {
+ const m = read('generate_ltx2.py').match(/^STREAMING_MODE_CHOICES = \(([^)]*)\)/m);
+ expect(m).not.toBeNull();
+ expect(strings(m[1])).toEqual([...VIDEO_STREAMING_MODES]);
+ });
+
+ it('FastVideo families', () => {
+ const m = read('generate_fastvideo.py').match(/"--family",\s*choices=\(([^)]*)\)/);
+ expect(m).not.toBeNull();
+ expect(strings(m[1])).toEqual([...FASTVIDEO_FAMILIES]);
+ });
+
+ it('MuScriptor model sizes', () => {
+ const m = read('transcribe_muscriptor.py').match(/"--model",\s*default="[^"]*",\s*choices=\[([^\]]*)\]/);
+ expect(m).not.toBeNull();
+ expect(strings(m[1])).toEqual([...MUSCRIPTOR_MODELS]);
+ });
+});