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): guard non-agent commission pins + honest default label
Adam Eivy53845fd533e4
diff --git a/client/src/pages/CreativeCommissions.jsx b/client/src/pages/CreativeCommissions.jsxindex 411ddec487..00e3e9706f 100644--- a/client/src/pages/CreativeCommissions.jsx+++ b/client/src/pages/CreativeCommissions.jsx@@ -687,23 +687,23 @@ function CommissionForm({ form, patchForm, runs, feedback, onRate, saving, onSav// plan). Mirrors SeriesLlmPicker: fetches the provider list, drives the shared// ProviderModelSelector, and reports changes up to form state via `onChange`.// Only agent-harness (CLI/TUI) providers are offered — an API-type provider-// injected into a CoS agent task trips the server's harness-boundary guard. The-// empty option names the actual active provider so an unset pin makes it clear-// what will process the run, rather than an opaque "default".+// injected into a CoS agent task trips the server's harness-boundary guard.+//+// The empty option deliberately does NOT name a specific provider: an unset pin+// resolves at fire time to `settings.creativeDirector.{treatment,plan}` (falling+// back to the active provider only when those stages are themselves unassigned),+// so naming the registry's active provider here would misreport the processor on+// installs that assign the CD stages separately. Label it neutrally; the section+// helper text points the user at their Creative Director assignment.function AssignmentPicker({ assignment, onChange }) {const [providers, setProviders] = useState([]);- const [activeProviderId, setActiveProviderId] = useState(null);useEffect(() => {getProviders({ silent: true })- .then((data) => {- setProviders((data?.providers || []).filter(isProcessProvider));- setActiveProviderId(data?.activeProvider || null);- })- .catch(() => { /* dropdowns fall back to the "default provider" option */ });+ .then((data) => setProviders((data?.providers || []).filter(isProcessProvider)))+ .catch(() => { /* dropdowns fall back to the "install default" option */ });}, []);- const providerLabel = (pid) => providers.find((p) => p.id === pid)?.name || pid || 'auto-resolved';const availableModels = useMemo(() => {const p = providers.find((x) => x.id === assignment.providerId);return p?.models || [];@@ -720,7 +720,7 @@ function AssignmentPicker({ assignment, onChange }) {label="Provider"modelDisabled={availableModels.length === 0}alwaysShowModel- emptyProviderOption={`Install default (${providerLabel(activeProviderId)})`}+ emptyProviderOption="Install default (Creative Director assignment)"emptyModelOption="Default model"/>);diff --git a/server/services/creativeCommissions/scheduler.js b/server/services/creativeCommissions/scheduler.jsindex 78ec487e1e..8e8276044d 100644--- a/server/services/creativeCommissions/scheduler.js+++ b/server/services/creativeCommissions/scheduler.js@@ -207,10 +207,31 @@ export async function runScheduledCommission(commissionId) {// Evaluation is deliberately left inheriting the default: it's a vision API// call, not a CoS agent, and pinning it to a CLI/TUI agent provider would// trip agentBridge's harness-boundary guard.- const pin = commission.assignment?.providerId- ? { providerId: commission.assignment.providerId, ...(commission.assignment.model ? { model: commission.assignment.model } : {}) }- : null;- const modelOverrides = pin ? { treatment: pin, plan: pin } : {};+ //+ // Guard the pin at fire time: treatment/plan run as CoS agent tasks, which+ // only accept an agent-harness (cli/tui) provider — an api-type or removed+ // provider trips agentBridge's harness-boundary guard and the task never+ // processes (the run would record `started` but silently produce nothing).+ // The UI only offers agent-harness providers, but a direct REST write or a+ // provider whose type later changed to `api` could slip a bad pin past it.+ // Resolve the provider now and DROP an unusable pin (falling back to the+ // install default) so the commission still generates rather than stalling.+ // Fail open: an unresolvable provider (toolkit hiccup) also falls back.+ let modelOverrides = {};+ if (commission.assignment?.providerId) {+ const [{ getProviderById }, { PROVIDER_TYPES }] = await Promise.all([+ import('../providers.js'),+ import('../../lib/aiToolkit/constants.js'),+ ]);+ const provider = await getProviderById(commission.assignment.providerId).catch(() => null);+ const agentCapable = provider?.type === PROVIDER_TYPES.CLI || provider?.type === PROVIDER_TYPES.TUI;+ if (agentCapable) {+ const pin = { providerId: commission.assignment.providerId, ...(commission.assignment.model ? { model: commission.assignment.model } : {}) };+ modelOverrides = { treatment: pin, plan: pin };+ } else {+ console.warn(`⚠️ Creative commission ${commissionId} pins non-agent provider '${commission.assignment.providerId}' (${provider?.type || 'missing'}) — falling back to the default CD assignment`);+ }+ }// createProject prefixes "Creative Director: " (19 chars) before a// mediaCollections name capped at 80, so cap our derived name at 61 — a long// commission name would otherwise fail the collection create on every run.diff --git a/server/services/creativeCommissions/scheduler.test.js b/server/services/creativeCommissions/scheduler.test.jsindex 57a28cff1e..9259b238bc 100644--- a/server/services/creativeCommissions/scheduler.test.js+++ b/server/services/creativeCommissions/scheduler.test.js@@ -38,6 +38,13 @@ vi.mock('../creativeDirector/local.js', () => ({ createProject: (...a) => createvi.mock('../creativeDirector/planAdvance.js', () => ({ advanceAfterPlanStepSettled: (...a) => advanceMock(...a) }));vi.mock('../videoGen/local.js', () => ({ defaultVideoModelId: () => 'ltx-default' }));+// Provider resolution for the fire-time pin guard (dynamic-imported inside the+// fire handler). Default: an agent-capable (tui) provider, so a pinned+// commission fans its override onto both stages. Tests override per-case.+const getProviderByIdMock = vi.fn(async (id) => ({ id, type: 'tui' }));+vi.mock('../providers.js', () => ({ getProviderById: (...a) => getProviderByIdMock(...a) }));+vi.mock('../../lib/aiToolkit/constants.js', () => ({ PROVIDER_TYPES: { CLI: 'cli', TUI: 'tui', API: 'api' } }));+const loadStateMock = vi.fn(async () => ({ config: {} }));vi.mock('../cosState.js', () => ({ loadState: (...a) => loadStateMock(...a) }));const creativeModeMock = vi.fn(() => 'execute');@@ -177,6 +184,29 @@ describe('runScheduledCommission gates', () => {}));});+ it('drops a pin to a non-agent (api) provider and still generates on the default', async () => {+ // A CoS treatment/plan task only accepts a cli/tui provider; an api pin+ // would be rejected by the harness-boundary guard mid-fire. The guard drops+ // it so the run proceeds on the install default instead of stalling.+ getProviderByIdMock.mockResolvedValueOnce({ id: 'gpt-4o', type: 'api' });+ getCommissionMock.mockResolvedValue(videoCommission({+ assignment: { providerId: 'gpt-4o', model: 'gpt-4o' },+ }));+ await runScheduledCommission('commission-1');+ expect(createProjectMock).toHaveBeenCalledWith(expect.objectContaining({ modelOverrides: {} }));+ // The commission still fires (falls back to default), it doesn't skip.+ expect(advanceMock).toHaveBeenCalledWith('cd-xyz');+ });++ it('drops a pin to a removed/unresolvable provider (fails open to the default)', async () => {+ getProviderByIdMock.mockResolvedValueOnce(null);+ getCommissionMock.mockResolvedValue(videoCommission({+ assignment: { providerId: 'ghost-provider', model: null },+ }));+ await runScheduledCommission('commission-1');+ expect(createProjectMock).toHaveBeenCalledWith(expect.objectContaining({ modelOverrides: {} }));+ });+it('does NOT surface when the fire is skipped (nothing was generated)', async () => {creativeModeMock.mockReturnValue('off');getCommissionMock.mockResolvedValue(videoCommission());