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

feat([issue-709]): promote an Ask answer into a goal from the Review Hub queue

[._.]/ Adam Eivy71773ca56d3f
diff --git a/client/src/pages/Review.jsx b/client/src/pages/Review.jsx
index d7dd5ef39a..fb28f6ac76 100644
--- a/client/src/pages/Review.jsx
+++ b/client/src/pages/Review.jsx
@@ -220,11 +220,11 @@ export default function Review() {
if (ok) handleQueueDismiss(item.id);
};
- const handleQueuePromoteAsk = async (item, target) => {
+ const handleQueuePromoteAsk = async (item, target, goalId) => {
if (resolvingQueueIds.has(item.id)) return;
setResolvingQueueIds(prev => new Set(prev).add(item.id));
// The helper toasts on failure (default), so don't add a custom catch toast.
- const ok = await api.promoteAskReviewQueueItem(item.id, target).then(() => true).catch(() => false);
+ const ok = await api.promoteAskReviewQueueItem(item.id, target, goalId ? { goalId } : {}).then(() => true).catch(() => false);
setResolvingQueueIds(prev => {
const next = new Set(prev);
next.delete(item.id);
@@ -547,13 +547,18 @@ function QueueMetaChips({ meta }) {
}
// Promote-target label for the Ask picker buttons.
-const PROMOTE_TARGET_LABEL = { brain: 'Brain', task: 'Task' };
+const PROMOTE_TARGET_LABEL = { brain: 'Brain', task: 'Task', goal: 'Goal' };
function QueueRow({ item, onDrill, onDismiss, onResolve, onPromoteAsk, resolving = false }) {
const config = QUEUE_SOURCE_CONFIG[item.source] || { icon: Inbox, color: 'text-gray-400' };
const Icon = config.icon;
const borderTone = QUEUE_SEVERITY_STYLE[item.severity] || QUEUE_SEVERITY_STYLE.normal;
const promoteTargets = Array.isArray(item.promoteTargets) ? item.promoteTargets : [];
+ const goalOptions = Array.isArray(item.goalOptions) ? item.goalOptions : [];
+ // The goal target needs a goalId, so it's rendered as a picker rather than a
+ // one-click button — split it out from the simple brain/task targets.
+ const simpleTargets = promoteTargets.filter(t => t !== 'goal');
+ const showGoalPicker = promoteTargets.includes('goal') && goalOptions.length > 0;
return (
<div className={`flex items-start gap-3 p-3 rounded-lg border bg-port-card ${borderTone}`}>
@@ -590,7 +595,7 @@ function QueueRow({ item, onDrill, onDismiss, onResolve, onPromoteAsk, resolving
{item.action}
</button>
)}
- {promoteTargets.length > 0 && onPromoteAsk && promoteTargets.map(target => (
+ {onPromoteAsk && simpleTargets.map(target => (
<button
key={target}
onClick={() => onPromoteAsk(item, target)}
@@ -602,6 +607,28 @@ function QueueRow({ item, onDrill, onDismiss, onResolve, onPromoteAsk, resolving
{PROMOTE_TARGET_LABEL[target] || target}
</button>
))}
+ {showGoalPicker && onPromoteAsk && (
+ <label className="inline-flex items-center gap-1 text-xs">
+ <span className="sr-only">Promote the latest answer to a goal</span>
+ <select
+ defaultValue=""
+ disabled={resolving}
+ onChange={(e) => {
+ const goalId = e.target.value;
+ if (!goalId) return;
+ onPromoteAsk(item, 'goal', goalId);
+ e.target.value = '';
+ }}
+ className="px-2 py-1 rounded-md text-xs font-medium text-port-accent bg-port-accent/10 hover:bg-port-accent/20 border border-port-accent/30 transition-colors disabled:opacity-40 disabled:cursor-not-allowed focus:outline-none"
+ title="Promote the latest answer into a goal's progress"
+ >
+ <option value="">→ Goal…</option>
+ {goalOptions.map(g => (
+ <option key={g.id} value={g.id}>{g.title}</option>
+ ))}
+ </select>
+ </label>
+ )}
<button
onClick={() => onDrill(item)}
className="p-1.5 text-gray-500 hover:text-port-accent transition-colors"
diff --git a/client/src/services/apiReview.js b/client/src/services/apiReview.js
index a8c73f77d6..ea4ac462e0 100644
--- a/client/src/services/apiReview.js
+++ b/client/src/services/apiReview.js
@@ -18,11 +18,12 @@ export const resolveReviewQueueItem = (id, options = {}) => request('/review/que
body: JSON.stringify({ id }),
...options
});
-// Promote an Ask row's latest assistant answer into Brain or a CoS task in
-// place (id is `ask:<conversationId>`, target is 'brain' | 'task')
-export const promoteAskReviewQueueItem = (id, target, options = {}) => request('/review/queue/promote-ask', {
+// Promote an Ask row's latest assistant answer into Brain, a CoS task, or a
+// Goal's progress in place (id is `ask:<conversationId>`, target is
+// 'brain' | 'task' | 'goal'; goalId is required for the 'goal' target).
+export const promoteAskReviewQueueItem = (id, target, { goalId, ...options } = {}) => request('/review/queue/promote-ask', {
method: 'POST',
- body: JSON.stringify({ id, target }),
+ body: JSON.stringify({ id, target, ...(goalId ? { goalId } : {}) }),
...options
});
export const createReviewTodo = (data) => request('/review/todo', {
diff --git a/server/routes/review.js b/server/routes/review.js
index 5417735961..758293d63f 100644
--- a/server/routes/review.js
+++ b/server/routes/review.js
@@ -65,17 +65,23 @@ router.post('/queue/resolve', asyncHandler(async (req, res) => {
const promoteAskQueueSchema = z.object({
id: z.string().min(1).max(500),
- target: z.enum(['brain', 'task'])
+ target: z.enum(['brain', 'task', 'goal']),
+ // Required when target === 'goal' (cross-field rule below); the row supplies
+ // it from the goal picker. Ignored for brain/task.
+ goalId: z.string().min(1).max(200).optional()
+}).refine((v) => v.target !== 'goal' || !!v.goalId, {
+ message: 'goalId is required when target is "goal"',
+ path: ['goalId']
});
// POST /api/review/queue/promote-ask — promote an Ask row's latest assistant
-// answer into Brain or a CoS task, in place, without leaving the Review Hub.
-// The `id` is the row's `ask:<conversationId>`; the service finds the latest
-// assistant turn so the client doesn't track turn ids. Goal targets stay a
-// drill-down (they need a goalId choice the queue row can't supply).
+// answer into Brain, a CoS task, or a Goal's progress, in place, without
+// leaving the Review Hub. The `id` is the row's `ask:<conversationId>`; the
+// service finds the latest assistant turn so the client doesn't track turn ids.
+// Goal promotion supplies a `goalId` picked inline from the row's goalOptions.
router.post('/queue/promote-ask', asyncHandler(async (req, res) => {
- const { id, target } = validateRequest(promoteAskQueueSchema, req.body);
- const result = await promoteAskQueueItem(id, target);
+ const { id, target, goalId } = validateRequest(promoteAskQueueSchema, req.body);
+ const result = await promoteAskQueueItem(id, target, goalId);
res.json(result);
}));
diff --git a/server/services/askPromote.js b/server/services/askPromote.js
index c8e80059b9..33345e1bfe 100644
--- a/server/services/askPromote.js
+++ b/server/services/askPromote.js
@@ -115,11 +115,12 @@ export async function promoteTurnById({ conversationId, turnId, target, priority
/**
* Promote the conversation's *latest* assistant turn — the entry point the
- * Review Queue uses, so the client doesn't need to know turn ids. Restricted
- * to brain/task targets (goal needs a goalId the queue row can't supply; the
- * user drills into /ask for that). 404s when no assistant turn exists.
+ * Review Queue uses, so the client doesn't need to know turn ids. Supports
+ * brain/task/goal; the `goal` target requires a `goalId` (the queue row carries
+ * `goalOptions` so the UI can supply it, then delegates the goal-not-found 404
+ * to promoteTurnContent). 404s when no assistant turn exists.
*/
-export async function promoteLatestAssistantTurn({ conversationId, target, priority }) {
+export async function promoteLatestAssistantTurn({ conversationId, target, priority, goalId }) {
const conv = await convs.getConversation(conversationId);
if (!conv) throw new ServerError('Conversation not found', { status: 404, code: 'NOT_FOUND' });
@@ -128,5 +129,5 @@ export async function promoteLatestAssistantTurn({ conversationId, target, prior
throw new ServerError('Conversation has no assistant answer to promote', { status: 404, code: 'NO_ASSISTANT_TURN' });
}
- return promoteTurnContent({ conversationId, turn, target, priority });
+ return promoteTurnContent({ conversationId, turn, target, priority, goalId });
}
diff --git a/server/services/askPromote.test.js b/server/services/askPromote.test.js
index b743467902..4ad90005bd 100644
--- a/server/services/askPromote.test.js
+++ b/server/services/askPromote.test.js
@@ -72,6 +72,25 @@ describe('askPromote.promoteLatestAssistantTurn', () => {
expect(result).toMatchObject({ target: 'task', ref: { type: 'task', id: 'task-1' } });
});
+ it('logs the latest answer as a goal progress entry with the supplied goalId', async () => {
+ convs.getConversation.mockResolvedValue({ id: 'conv-1', turns: [
+ { id: 't2', role: 'assistant', content: 'progress note' },
+ ] });
+ identityService.addProgressEntry.mockResolvedValue({ id: 'entry-1' });
+
+ const result = await promoteLatestAssistantTurn({ conversationId: 'conv-1', target: 'goal', goalId: 'g1' });
+ expect(identityService.addProgressEntry).toHaveBeenCalledWith('g1', expect.objectContaining({ note: 'progress note' }));
+ expect(convs.setPromoted).toHaveBeenCalledWith('conv-1', true);
+ expect(result).toMatchObject({ target: 'goal', ref: { type: 'goal', id: 'g1', entryId: 'entry-1' } });
+ });
+
+ it('404s when the goal target references a missing goal', async () => {
+ convs.getConversation.mockResolvedValue({ id: 'conv-1', turns: [{ id: 't2', role: 'assistant', content: 'note' }] });
+ identityService.addProgressEntry.mockResolvedValue(null);
+ await expect(promoteLatestAssistantTurn({ conversationId: 'conv-1', target: 'goal', goalId: 'gone' }))
+ .rejects.toMatchObject({ status: 404 });
+ });
+
it('404s when the conversation has no assistant turn', async () => {
convs.getConversation.mockResolvedValue({ id: 'conv-1', turns: [{ id: 't1', role: 'user', content: 'q' }] });
await expect(promoteLatestAssistantTurn({ conversationId: 'conv-1', target: 'brain' }))
diff --git a/server/services/reviewQueue.js b/server/services/reviewQueue.js
index 13fc690d98..9a0b2e8188 100644
--- a/server/services/reviewQueue.js
+++ b/server/services/reviewQueue.js
@@ -30,6 +30,7 @@ import * as cosTaskStore from './cosTaskStore.js';
import * as messageDrafts from './messageDrafts.js';
import * as proactiveAlerts from './proactiveAlerts.js';
import * as backup from './backup.js';
+import * as identity from './identity.js';
import { promoteLatestAssistantTurn } from './askPromote.js';
import { ServerError } from '../lib/errorHandler.js';
@@ -57,6 +58,21 @@ export function __resetAlertsCache() {
alertsCache = { data: null, timestamp: 0 };
}
+// Active goals are fetched once per buildQueue() (not per Ask row) so the
+// inline goal picker on Ask rows has targets to offer. getGoals() lazily
+// migrates the store, so we read it once and reuse the result while gathering.
+// A goal-store failure degrades to "no goal targets" rather than sinking Ask.
+async function getActiveGoalOptions() {
+ const data = await identity.getGoals().catch((err) => {
+ console.error(`❌ Review queue: goal options failed: ${err.message}`);
+ return null;
+ });
+ const goals = Array.isArray(data?.goals) ? data.goals : [];
+ return goals
+ .filter((g) => g.status === 'active' && typeof g.id === 'string' && g.id)
+ .map((g) => ({ id: g.id, title: g.title || '(untitled goal)' }));
+}
+
/**
* Producer registry. Each entry knows how to gather its raw items and map one
* into the normalized queue shape. `gather` returns the raw list (already
@@ -112,11 +128,14 @@ const PRODUCERS = [
},
// Inline promote targets the UI can offer without a per-turn drill-down.
// The queue picks the conversation's latest assistant turn server-side, so
- // brain/task need no extra choice; goal needs a goalId, so it stays a
- // drill-down only.
+ // brain/task need no extra choice. `goal` also promotes the latest turn but
+ // needs a goalId, so the row additionally carries `goalOptions` and the UI
+ // renders a goal picker; goal is only offered when at least one active goal
+ // exists (gatherContext.goalOptions, populated once per buildQueue).
promoteTargets: ['brain', 'task'],
- map(conv) {
+ map(conv, index, ctx) {
const turnCount = Number.isFinite(conv.turnCount) ? conv.turnCount : null;
+ const goalOptions = Array.isArray(ctx?.goalOptions) ? ctx.goalOptions : [];
return {
id: `ask:${conv.id}`,
title: 'Ask answer ready to promote',
@@ -124,6 +143,10 @@ const PRODUCERS = [
timestamp: conv.updatedAt || conv.createdAt || null,
severity: 'normal',
drillTo: `/ask/${conv.id}`,
+ // Only advertise the goal target (and its picker options) when there's
+ // at least one active goal to promote into — an empty picker would be a
+ // dead-end button.
+ ...(goalOptions.length ? { promoteTargets: ['brain', 'task', 'goal'], goalOptions } : {}),
...(turnCount != null ? { meta: { turnCount } } : {})
};
}
@@ -262,22 +285,28 @@ const SEVERITY_ORDER = { critical: 0, high: 1, normal: 2 };
* Gather one producer into normalized, capped rows. Never throws — a failing
* producer degrades to `{ items: [], total: 0, error }` so the aggregate still
* returns the healthy sources.
+ *
+ * `ctx` carries cross-producer data computed once per buildQueue (e.g. the
+ * active-goal options the Ask producer's goal picker offers), passed through to
+ * `map`. A row's `map()` may also override `promoteTargets` (the Ask row adds
+ * `goal` only when goals exist), so the map result is spread AFTER the
+ * producer-level default.
*/
-async function gatherProducer(producer) {
+async function gatherProducer(producer, ctx = {}) {
const raw = await producer.gather();
const list = Array.isArray(raw) ? raw : [];
const items = list.slice(0, PER_SOURCE_LIMIT).map((item, index) => ({
source: producer.source,
sourceLabel: producer.label,
- ...producer.map(item, index),
- // Inline-action verb when the producer declares one resolve primitive; the
- // UI shows an accept/promote button only for rows that carry it.
- ...(producer.action && producer.resolve ? { action: producer.action } : {}),
- // Inline promote targets (Ask rows) — the UI renders a compact target
- // picker for rows that carry a non-empty list.
+ // Producer-level default promote targets — the row's map() may override
+ // this (Ask adds `goal` + `goalOptions` when active goals exist).
...(Array.isArray(producer.promoteTargets) && producer.promoteTargets.length
? { promoteTargets: producer.promoteTargets }
- : {})
+ : {}),
+ ...producer.map(item, index, ctx),
+ // Inline-action verb when the producer declares one resolve primitive; the
+ // UI shows an accept/promote button only for rows that carry it.
+ ...(producer.action && producer.resolve ? { action: producer.action } : {})
}));
return { items, total: list.length };
}
@@ -309,15 +338,24 @@ export async function resolveQueueItem(queueItemId) {
return { source, id: queueItemId, resolved: true };
}
+// Targets the queue can promote an Ask answer into directly. brain/task pick
+// the latest assistant turn with no extra input; goal additionally needs a
+// goalId (the row carries `goalOptions` so the UI can supply it). Goal is in
+// the allow-list even though the row only advertises it when active goals
+// exist — a request with a stale goalId still validates here and 404s in the
+// orchestration if the goal is gone.
+const ASK_PROMOTE_TARGETS = ['brain', 'task', 'goal'];
+
/**
* Promote an Ask queue row's latest assistant answer into a chosen target
- * (brain/task). `queueItemId` is the row id (`ask:<conversationId>`); `target`
- * must be one of the Ask producer's declared `promoteTargets`. The service
- * picks the conversation's latest assistant turn so the client doesn't carry
- * turn ids — a conversation with no assistant answer 404s. Reuses the same
- * promote orchestration the per-turn Ask route uses (no duplication).
+ * (brain/task/goal). `queueItemId` is the row id (`ask:<conversationId>`);
+ * `target` must be one of `ASK_PROMOTE_TARGETS`. For the `goal` target,
+ * `goalId` is required (validated, then resolved against the goal store).
+ * The service picks the conversation's latest assistant turn so the client
+ * doesn't carry turn ids — a conversation with no assistant answer 404s.
+ * Reuses the same promote orchestration the per-turn Ask route uses.
*/
-export async function promoteAskQueueItem(queueItemId, target) {
+export async function promoteAskQueueItem(queueItemId, target, goalId) {
const sep = String(queueItemId).indexOf(':');
const source = sep === -1 ? queueItemId : queueItemId.slice(0, sep);
const conversationId = sep === -1 ? '' : queueItemId.slice(sep + 1);
@@ -325,12 +363,14 @@ export async function promoteAskQueueItem(queueItemId, target) {
if (source !== 'ask') {
throw new ServerError(`Promote is only supported for Ask rows, got "${source}"`, { status: 400, code: 'BAD_REQUEST' });
}
- const allowed = PRODUCERS_BY_SOURCE.ask.promoteTargets || [];
- if (!allowed.includes(target)) {
+ if (!ASK_PROMOTE_TARGETS.includes(target)) {
throw new ServerError(`Unsupported promote target "${target}" for Ask`, { status: 400, code: 'BAD_REQUEST' });
}
+ if (target === 'goal' && !goalId) {
+ throw new ServerError('goalId is required to promote into a goal', { status: 400, code: 'VALIDATION_ERROR' });
+ }
- const result = await promoteLatestAssistantTurn({ conversationId, target });
+ const result = await promoteLatestAssistantTurn({ conversationId, target, goalId });
return { source, id: queueItemId, promoted: true, target: result.target, ref: result.ref };
}
@@ -341,8 +381,13 @@ export async function promoteAskQueueItem(queueItemId, target) {
* a source that failed to load.
*/
export async function buildQueue() {
+ // Fetch active goals once (not per Ask row) so the goal picker on Ask rows
+ // has targets. A failure here degrades to no goal targets, not a sunk queue.
+ const goalOptions = await getActiveGoalOptions();
+ const ctx = { goalOptions };
+
const results = await Promise.all(PRODUCERS.map(async (producer) => {
- return gatherProducer(producer)
+ return gatherProducer(producer, ctx)
.then(r => ({ source: producer.source, label: producer.label, ...r, error: null }))
.catch(err => {
console.error(`❌ Review queue: ${producer.source} source failed: ${err.message}`);
diff --git a/server/services/reviewQueue.test.js b/server/services/reviewQueue.test.js
index 9afc276afe..74982812e9 100644
--- a/server/services/reviewQueue.test.js
+++ b/server/services/reviewQueue.test.js
@@ -12,6 +12,9 @@ const backup = { getState: vi.fn() };
// stack in transitively (askPromote imports all three). The promoteAskQueueItem
// suite drives this mock directly.
const askPromote = { promoteLatestAssistantTurn: vi.fn() };
+// getGoals feeds the Ask row's inline goal picker (goalOptions); default to no
+// active goals so existing cases see the brain/task-only target list.
+const identity = { getGoals: vi.fn() };
vi.mock('./brain.js', () => brain);
vi.mock('./askConversations.js', () => askConversations);
@@ -19,6 +22,7 @@ vi.mock('./cosTaskStore.js', () => cosTaskStore);
vi.mock('./messageDrafts.js', () => messageDrafts);
vi.mock('./proactiveAlerts.js', () => proactiveAlerts);
vi.mock('./backup.js', () => backup);
+vi.mock('./identity.js', () => identity);
vi.mock('./askPromote.js', () => askPromote);
const { buildQueue, resolveQueueItem, promoteAskQueueItem, __resetAlertsCache } = await import('./reviewQueue.js');
@@ -31,6 +35,7 @@ function resetEmpty() {
messageDrafts.listDrafts.mockResolvedValue([]);
proactiveAlerts.generateAlerts.mockResolvedValue({ alerts: [] });
backup.getState.mockResolvedValue({ status: 'ok', error: null });
+ identity.getGoals.mockResolvedValue({ goals: [] });
}
describe('reviewQueue.buildQueue', () => {
@@ -209,9 +214,37 @@ describe('reviewQueue.buildQueue', () => {
askConversations.listConversations.mockResolvedValue([{ id: 'a1', title: 'promote me', promoted: false, turnCount: 1 }]);
brain.getInboxLog.mockResolvedValue([{ id: 'b1', capturedText: 'classify', capturedAt: '2026-06-03T10:00:00.000Z' }]);
const queue = await buildQueue();
- expect(queue.items.find(i => i.source === 'ask').promoteTargets).toEqual(['brain', 'task']);
+ const ask = queue.items.find(i => i.source === 'ask');
+ // No active goals → goal target is not offered and no picker options ride along.
+ expect(ask.promoteTargets).toEqual(['brain', 'task']);
+ expect(ask.goalOptions).toBeUndefined();
expect(queue.items.find(i => i.source === 'brain').promoteTargets).toBeUndefined();
});
+
+ it('adds the goal target + active-goal options to Ask rows when goals exist', async () => {
+ askConversations.listConversations.mockResolvedValue([{ id: 'a1', title: 'promote me', promoted: false, turnCount: 1 }]);
+ identity.getGoals.mockResolvedValue({
+ goals: [
+ { id: 'g1', title: 'Ship inbox zero', status: 'active' },
+ { id: 'g2', title: 'Archived idea', status: 'archived' }, // filtered out (not active)
+ { title: 'No id', status: 'active' } // filtered out (no id)
+ ]
+ });
+ const queue = await buildQueue();
+ const ask = queue.items.find(i => i.source === 'ask');
+ expect(ask.promoteTargets).toEqual(['brain', 'task', 'goal']);
+ expect(ask.goalOptions).toEqual([{ id: 'g1', title: 'Ship inbox zero' }]);
+ });
+
+ it('degrades to no goal target when the goal store fails', async () => {
+ askConversations.listConversations.mockResolvedValue([{ id: 'a1', title: 'promote me', promoted: false, turnCount: 1 }]);
+ identity.getGoals.mockRejectedValue(new Error('goals unreadable'));
+ const queue = await buildQueue();
+ const ask = queue.items.find(i => i.source === 'ask');
+ // Ask still surfaces; just without the goal option.
+ expect(ask.promoteTargets).toEqual(['brain', 'task']);
+ expect(ask.goalOptions).toBeUndefined();
+ });
});
describe('reviewQueue.promoteAskQueueItem', () => {
@@ -222,14 +255,26 @@ describe('reviewQueue.promoteAskQueueItem', () => {
it('promotes the latest assistant turn to brain via the shared promote helper', async () => {
askPromote.promoteLatestAssistantTurn.mockResolvedValue({ target: 'brain', ref: { type: 'brain', id: 'note-1' } });
const result = await promoteAskQueueItem('ask:conv-1', 'brain');
- expect(askPromote.promoteLatestAssistantTurn).toHaveBeenCalledWith({ conversationId: 'conv-1', target: 'brain' });
+ expect(askPromote.promoteLatestAssistantTurn).toHaveBeenCalledWith({ conversationId: 'conv-1', target: 'brain', goalId: undefined });
expect(result).toMatchObject({ source: 'ask', id: 'ask:conv-1', promoted: true, target: 'brain', ref: { type: 'brain', id: 'note-1' } });
});
it('promotes to task target', async () => {
askPromote.promoteLatestAssistantTurn.mockResolvedValue({ target: 'task', ref: { type: 'task', id: 't-1' } });
await promoteAskQueueItem('ask:conv-2', 'task');
- expect(askPromote.promoteLatestAssistantTurn).toHaveBeenCalledWith({ conversationId: 'conv-2', target: 'task' });
+ expect(askPromote.promoteLatestAssistantTurn).toHaveBeenCalledWith({ conversationId: 'conv-2', target: 'task', goalId: undefined });
+ });
+
+ it('promotes to a goal target with the supplied goalId', async () => {
+ askPromote.promoteLatestAssistantTurn.mockResolvedValue({ target: 'goal', ref: { type: 'goal', id: 'g1', entryId: 'e1' } });
+ const result = await promoteAskQueueItem('ask:conv-9', 'goal', 'g1');
+ expect(askPromote.promoteLatestAssistantTurn).toHaveBeenCalledWith({ conversationId: 'conv-9', target: 'goal', goalId: 'g1' });
+ expect(result).toMatchObject({ source: 'ask', id: 'ask:conv-9', promoted: true, target: 'goal' });
+ });
+
+ it('rejects a goal target with no goalId (400) before touching the helper', async () => {
+ await expect(promoteAskQueueItem('ask:conv-1', 'goal')).rejects.toMatchObject({ status: 400 });
+ expect(askPromote.promoteLatestAssistantTurn).not.toHaveBeenCalled();
});
it('rejects a non-ask row with a 400', async () => {
@@ -237,8 +282,8 @@ describe('reviewQueue.promoteAskQueueItem', () => {
expect(askPromote.promoteLatestAssistantTurn).not.toHaveBeenCalled();
});
- it('rejects an unsupported target (goal) with a 400', async () => {
- await expect(promoteAskQueueItem('ask:conv-1', 'goal')).rejects.toMatchObject({ status: 400 });
+ it('rejects a genuinely unsupported target with a 400', async () => {
+ await expect(promoteAskQueueItem('ask:conv-1', 'calendar')).rejects.toMatchObject({ status: 400 });
expect(askPromote.promoteLatestAssistantTurn).not.toHaveBeenCalled();
});