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 auto-review and sound-bed helpers module-private (#8988)

[._.]/ Adam Eivy17a767e45d47
diff --git a/server/services/musicVideo/autoReview.js b/server/services/musicVideo/autoReview.js
index 743325b894..09c52f55a5 100644
--- a/server/services/musicVideo/autoReview.js
+++ b/server/services/musicVideo/autoReview.js
@@ -39,20 +39,20 @@ import { isNonBlankStr, trimTo } from '../../lib/textUtils.js';
import { addExcerptNote, projectExcerpts } from './excerpt.js';
import { projectRevisions } from './revision.js';
-export const AUTO_REVIEW_LIMIT_BOUNDS = Object.freeze({
+const AUTO_REVIEW_LIMIT_BOUNDS = Object.freeze({
maxAttempts: Object.freeze({ min: 1, max: 10 }),
maxGenerations: Object.freeze({ min: 0, max: 100 }),
});
// Statuses: `running` (advancing), `stopped` (paused by the director —
// resumable), `limit-reached` (a limit stopped it — resumable once raised),
// and the terminal `passed` / `needs-human` / `failed` / `canceled`.
-export const AUTO_REVIEW_STATUSES = Object.freeze(['running', 'stopped', 'limit-reached', 'passed', 'needs-human', 'failed', 'canceled']);
+const AUTO_REVIEW_STATUSES = Object.freeze(['running', 'stopped', 'limit-reached', 'passed', 'needs-human', 'failed', 'canceled']);
const RESUMABLE = new Set(['running', 'stopped', 'limit-reached']);
const ACTIVE = new Set(['running', 'stopped', 'limit-reached']);
export const AUTO_REVIEW_CHECKS = Object.freeze(['composition', 'continuity', 'motion', 'audioSync']);
// Draft renders are free, but a window that fails to render every time must
// not loop forever: this many failed renders of one attempt fail the run.
-export const MAX_RENDER_FAILURES = 2;
+const MAX_RENDER_FAILURES = 2;
const MAX_PROJECT_AUTO_REVIEWS = 10;
const MAX_FINDINGS = 20;
const MAX_FINDING_LEN = 500;
@@ -65,7 +65,7 @@ const autoReviewError = (status, code, message, context) =>
export const projectAutoReviews = (project) => (Array.isArray(project?.autoReviews) ? project.autoReviews : []);
/** The run that is still live (running, paused, or waiting on raised limits), if any. */
-export const activeAutoReview = (project) => projectAutoReviews(project).find((r) => ACTIVE.has(r.status)) || null;
+const activeAutoReview = (project) => projectAutoReviews(project).find((r) => ACTIVE.has(r.status)) || null;
const currentAttempt = (run) => run.attempts[run.attempts.length - 1];
@@ -96,7 +96,7 @@ const intIn = (value, { min, max }, name) => {
};
/** Validate a limits object; every limit is REQUIRED — a run never picks its own budget. */
-export function normalizeAutoReviewLimits(limits) {
+function normalizeAutoReviewLimits(limits) {
return {
maxAttempts: intIn(limits?.maxAttempts, AUTO_REVIEW_LIMIT_BOUNDS.maxAttempts, 'maxAttempts'),
maxGenerations: intIn(limits?.maxGenerations, AUTO_REVIEW_LIMIT_BOUNDS.maxGenerations, 'maxGenerations'),
diff --git a/server/services/musicVideo/autoReviewService.js b/server/services/musicVideo/autoReviewService.js
index 60ac64b3fb..1990cee2c0 100644
--- a/server/services/musicVideo/autoReviewService.js
+++ b/server/services/musicVideo/autoReviewService.js
@@ -278,7 +278,7 @@ async function takeSteps(projectId, runId) {
* coalesce onto the in-flight advance, which then takes one more pass.
* Returns `{ project, run, action }`.
*/
-export function advanceAutoReview(projectId, runId) {
+function advanceAutoReview(projectId, runId) {
const live = advancing.get(runId);
if (live) {
live.again = true;
diff --git a/server/services/musicVideo/render.js b/server/services/musicVideo/render.js
index c639cda364..09517733ea 100644
--- a/server/services/musicVideo/render.js
+++ b/server/services/musicVideo/render.js
@@ -164,7 +164,7 @@ export async function resolveMasterAudioPath(project) {
// #8988: resolve the project's explicitly chosen sound-design bed (a
// music-library track) to a verified path under data/music/, or null when the
// song is the sole audio master (the default).
-export async function resolveSoundBed(project) {
+async function resolveSoundBed(project) {
const bed = projectSoundBed(project);
if (!bed) return null;
const track = await getTrack(bed.trackId);
diff --git a/server/services/musicVideo/render.test.js b/server/services/musicVideo/render.test.js
index 40de669b33..f2820c2cf1 100644
--- a/server/services/musicVideo/render.test.js
+++ b/server/services/musicVideo/render.test.js
@@ -21,7 +21,6 @@ import {
excerptBoundaryTimes,
resolveSceneClips,
resolveMasterAudioPath,
- resolveSoundBed,
renderMusicVideo,
} from './render.js';
import { findFfmpeg, probeVideoGeometry } from '../../lib/ffmpeg.js';
@@ -126,12 +125,6 @@ describe('sound-design bed (#8988)', () => {
expect(fc).toContain('[mixa]atrim=start=1:end=3,asetpts=PTS-STARTPTS[outax]');
expect(mapsOf(args)).toEqual(['[outvx]', '[outax]']);
});
-
- it('refuses a render whose chosen bed track no longer resolves', async () => {
- getTrack.mockResolvedValue(null);
- await expect(resolveSoundBed({ soundBed: { trackId: 'trk-gone' } })).rejects.toMatchObject({ code: 'SOUND_BED_MISSING' });
- await expect(resolveSoundBed({})).resolves.toBeNull();
- });
});
describe('excerptBoundaryTimes (#8986)', () => {
diff --git a/server/services/musicVideo/soundBed.js b/server/services/musicVideo/soundBed.js
index 123ab7b886..be25d574a3 100644
--- a/server/services/musicVideo/soundBed.js
+++ b/server/services/musicVideo/soundBed.js
@@ -16,9 +16,9 @@
import { isNonBlankStr } from '../../lib/textUtils.js';
-export const DEFAULT_SOUND_BED_VOLUME = 0.3;
-export const MIN_SOUND_BED_VOLUME = 0.05;
-export const MAX_SOUND_BED_VOLUME = 1;
+const DEFAULT_SOUND_BED_VOLUME = 0.3;
+const MIN_SOUND_BED_VOLUME = 0.05;
+const MAX_SOUND_BED_VOLUME = 1;
const clampVolume = (v) => {
if (typeof v !== 'number' || !Number.isFinite(v)) return DEFAULT_SOUND_BED_VOLUME;