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
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
address review (codex): keep the taste anchors in a music run's audio prompt
[._.]/ Adam Eivy16cb97c1429e
diff --git a/server/services/creativeCommissions/store.js b/server/services/creativeCommissions/store.jsindex 4104d4e567..745686cf2d 100644--- a/server/services/creativeCommissions/store.js+++ b/server/services/creativeCommissions/store.js@@ -70,7 +70,7 @@ import {import { emitRecordUpdated, emitRecordDeleted, autoSubscribeRecordToAllPeers } from '../sharing/recordEvents.js';import { commissionToCron } from './directive.js';import { getAbilityAdapter } from './abilityAdapters.js';-import { normalizeMusicTasteConfig, sanitizeMusicTasteRecipe } from './musicTasteRecipe.js';+import { normalizeMusicTasteConfig, sanitizeMusicTasteRecipe, renderMusicTasteRecipePrompt } from './musicTasteRecipe.js';import {recordFeedback,listFeedbackForCommission,@@ -98,6 +98,27 @@ export const MAX_RUN_PROMPT_LEN = 4000;const clampRunPrompt = (value) => (typeof value === 'string' && value.length > MAX_RUN_PROMPT_LEN? `${value.slice(0, MAX_RUN_PROMPT_LEN - 1)}…`: value);++/**+ * The authoritative audio prompt for a taste-enabled music run.+ *+ * `promptUsed` is a HEAD excerpt of the directive goal, and the music adapter+ * composes that goal as lead + intent, THEN the taste recipe — so once the intent+ * fills the excerpt, the recipe's anchors and its original-work constraint fall off+ * the end and the render loses them. Re-render the recipe from the run's own stored+ * `tasteRecipe` and reserve room for it, the same reserve-then-clamp shape+ * `composeDirectiveGoal` uses for the feedback digest: the bounded, authoritative+ * part is never what truncation eats.+ */+function composeMusicRunPrompt(run) {+ const brief = isStr(run?.promptUsed) ? run.promptUsed : '';+ const taste = renderMusicTasteRecipePrompt(run?.tasteRecipe);+ // Short goals still carry the recipe verbatim in the excerpt — don't say it twice.+ if (!taste || brief.includes(taste)) return brief;+ const reserve = taste.length + 1; // +1 for the joining space+ const head = clampRunPrompt(brief.slice(0, Math.max(0, MAX_RUN_PROMPT_LEN - reserve)));+ return `${head} ${taste}`.trim();+}// Feedback is kept inline on the commission record (not a separate federated// store) — Phase 1's store shape reserved `feedback[]` precisely so Phase 2 adds// the rate surface without a schema change. Capped like runs so a long-lived@@ -758,7 +779,7 @@ export async function getCommissionMusicContextForProject(projectId) {return {commissionId: commission.id,runId: run.id,- prompt: run.promptUsed,+ prompt: composeMusicRunPrompt(run),tasteRecipe: run.tasteRecipe,musicGeneration: run.musicGeneration,};diff --git a/server/services/creativeCommissions/store.test.js b/server/services/creativeCommissions/store.test.jsindex dc0983b2d3..6458e1e870 100644--- a/server/services/creativeCommissions/store.test.js+++ b/server/services/creativeCommissions/store.test.js@@ -359,9 +359,13 @@ describe('recordCommissionRun', () => {engine: 'musicgen', modelId: 'example-model', repo: 'example/model', durationSec: 45,});expect(sanitizeCommission({ ...after, runs: after.runs }).runs[0].tasteRecipe).toEqual(recipe);- expect(await getCommissionMusicContextForProject('cd-taste')).toMatchObject({- commissionId: created.id, runId: run.id, prompt: 'Original bounded directive',- });+ const ctx = await getCommissionMusicContextForProject('cd-taste');+ expect(ctx).toMatchObject({ commissionId: created.id, runId: run.id });+ // The audio prompt carries the brief AND the recipe's authoritative anchors ++ // original-work constraint, re-rendered from the run's own stored recipe.+ expect(ctx.prompt).toContain('Original bounded directive');+ expect(ctx.prompt).toContain('Example Artist');+ expect(ctx.prompt).toContain('do not reproduce source tracks');await recordCommissionMusicOutput(created.id, run.id, {filename: 'music-gen-example.wav', durationSec: 45, engine: 'musicgen', modelId: 'example-model',recipeVersion: 1, sourceHash: 'example-hash', completedAt: '2026-08-16T00:00:00.000Z',@@ -371,6 +375,35 @@ describe('recordCommissionRun', () => {filename: 'music-gen-example.wav', engine: 'musicgen', modelId: 'example-model', sourceHash: 'example-hash',});});++ // The music adapter composes the goal as lead + intent, THEN the taste recipe, so+ // a brief long enough to fill the run-prompt excerpt pushes the recipe off the end.+ // The render must still get the anchors and the original-work constraint.+ it('keeps the taste anchors in the audio prompt when the brief overruns the excerpt', async () => {+ const created = await createCommission({+ ...validInput(),+ targetAbility: 'music',+ brief: { intent: 'ambient', musicTaste: { source: 'digital-twin' } },+ generation: { lengthSeconds: 45 },+ });+ const recipe = {+ version: 1, source: 'digital-twin', window: 'month', anchorCount: 1,+ explorationPercent: 20, explorationCount: 0, explorationDirection: 'balanced',+ anchors: [{ kind: 'artist', name: 'Example Artist', count: 3, source: 'observed' }],+ statedContext: 'Example preference',+ sourceVersion: 'music-taste-v1:example', sourceHash: 'example-hash',+ };+ await recordCommissionRun(created.id, {+ status: 'started', projectId: 'cd-long', tasteRecipe: recipe,+ musicGeneration: { engine: 'musicgen', modelId: 'example-model', repo: 'example/model', durationSec: 45 },+ // A goal whose head alone would consume the entire excerpt budget.+ promptUsed: `Compose an original ~45s music piece. ${'b'.repeat(MAX_RUN_PROMPT_LEN * 2)}`,+ });+ const ctx = await getCommissionMusicContextForProject('cd-long');+ expect(ctx.prompt).toContain('Example Artist');+ expect(ctx.prompt).toContain('do not reproduce source tracks');+ expect(ctx.prompt.length).toBeLessThanOrEqual(MAX_RUN_PROMPT_LEN);+ });});describe('deleteCommission', () => {