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 r2): reserve digest space in goal clamp, reject blank feedback window
[._.]/ Adam Eivyc64d4bf79685
diff --git a/client/src/pages/CreativeCommissions.jsx b/client/src/pages/CreativeCommissions.jsxindex b845ee0283..1dca0a126f 100644--- a/client/src/pages/CreativeCommissions.jsx+++ b/client/src/pages/CreativeCommissions.jsx@@ -159,6 +159,14 @@ export default function CreativeCommissions() {const handleSave = async () => {if (!form.name.trim()) { toast.error('Name is required'); return; }if (!form.brief.intent.trim()) { toast.error('Brief intent is required'); return; }+ // A cleared number input is '', which Number() coerces to 0 — and 0 is the+ // valid "disable conditioning" value, so a blank field would silently turn+ // feedback off. Reject it instead of guessing intent.+ const fw = Number(form.feedbackWindow);+ if (form.feedbackWindow === '' || !Number.isInteger(fw) || fw < 0 || fw > 50) {+ toast.error('Feedback window must be a whole number from 0 to 50');+ return;+ }const payload = toPayload(form);setSaving(true);try {diff --git a/server/services/creativeCommissions/directive.js b/server/services/creativeCommissions/directive.jsindex 5259b562c8..6f43558d05 100644--- a/server/services/creativeCommissions/directive.js+++ b/server/services/creativeCommissions/directive.js@@ -18,9 +18,14 @@// headroom under the CD schema limit.export const MAX_DIGEST_NOTE_LEN = 300;export const MAX_DIRECTIVE_GOAL_LEN = 4500;+// The digest is the whole point of the feedback loop, so it gets a reserved+// slice of the goal budget the brief text can't eat into (see+// buildCommissionDirective). Bounded on its own too, so 50 reactions can't blow+// the reservation.+export const MAX_DIGEST_LEN = 1500;-const clampNote = (note) =>- note.length > MAX_DIGEST_NOTE_LEN ? `${note.slice(0, MAX_DIGEST_NOTE_LEN - 1)}…` : note;+const clamp = (s, max) => (s.length > max ? `${s.slice(0, Math.max(0, max - 1))}…` : s);+const clampNote = (note) => clamp(note, MAX_DIGEST_NOTE_LEN);/*** Compose a 5-field cron (`minute hour dayOfMonth month dayOfWeek`) from a@@ -81,7 +86,7 @@ export function renderFeedbackDigest(feedback, windowSize = 5) {if (likes.length) parts.push(`Recent likes: ${likes.join('; ')}.`);if (dislikes.length) parts.push(`Recent dislikes: ${dislikes.join('; ')}.`);parts.push('Steer toward the likes and away from the dislikes.');- return parts.join(' ');+ return clamp(parts.join(' '), MAX_DIGEST_LEN);}/**@@ -101,17 +106,24 @@ export function buildCommissionDirective(commission) {if (brief.styleSpec) lines.push(`Style: ${brief.styleSpec}.`);const digest = renderFeedbackDigest(commission?.feedback, commission?.feedbackWindow ?? 5);- if (digest) lines.push(digest);const constraints = {};if (brief.constraints?.universeId) constraints.universeId = brief.constraints.universeId;if (brief.constraints?.seriesId) constraints.seriesId = brief.constraints.seriesId;- // Hard-cap the goal so an internally-composed directive (scheduler path, which- // skips the route's 5000-char validation) can never exceed what the CD planner- // should receive.- let goal = lines.join(' ');- if (goal.length > MAX_DIRECTIVE_GOAL_LEN) goal = `${goal.slice(0, MAX_DIRECTIVE_GOAL_LEN - 1)}…`;+ // Compose the goal under the CD's 5000-char cap (the scheduler feeds this+ // straight into createProject, skipping the route's input validation). RESERVE+ // room for the digest first, then clamp the BRIEF text into whatever remains —+ // truncating the tail of the whole string would drop the digest (appended last)+ // whenever a long intent/style fills the budget, silently killing the feedback+ // signal. The digest is bounded (MAX_DIGEST_LEN) so the reservation is finite.+ const briefText = lines.join(' ');+ const reserve = digest ? digest.length + 1 : 0; // +1 for the joining space+ const briefBudget = Math.max(0, MAX_DIRECTIVE_GOAL_LEN - reserve);+ const clampedBrief = clamp(briefText, briefBudget);+ let goal = digest ? `${clampedBrief} ${digest}`.trim() : clampedBrief;+ // Final safety net (defensive — brief+reserve already fits): clamp the whole.+ goal = clamp(goal, MAX_DIRECTIVE_GOAL_LEN);return {goal,diff --git a/server/services/creativeCommissions/directive.test.js b/server/services/creativeCommissions/directive.test.jsindex 727bf2848e..b941b83697 100644--- a/server/services/creativeCommissions/directive.test.js+++ b/server/services/creativeCommissions/directive.test.js@@ -128,4 +128,18 @@ describe('buildCommissionDirective', () => {});expect(directive.goal.length).toBeLessThanOrEqual(4500);});++ it('keeps the feedback digest even when the brief text is very long (digest is reserved, brief is clamped)', () => {+ // A 2000-char intent + 3000-char style would fill the whole 4500 budget; the+ // digest must survive (it is appended last, but reserved for) rather than+ // being truncated away — otherwise ratings stop steering the run.+ const directive = buildCommissionDirective({+ targetAbility: 'video',+ brief: { intent: 'x'.repeat(2000), styleSpec: 'y'.repeat(3000) },+ feedback: [{ rating: 'down', note: 'less horror' }],+ feedbackWindow: 5,+ });+ expect(directive.goal.length).toBeLessThanOrEqual(4500);+ expect(directive.goal).toContain('Recent dislikes: less horror.');+ });});