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): scope addTask duplicate check by metadata.app
[._.]/ Adam Eivy17ef1826a8df
diff --git a/server/services/cos.js b/server/services/cos.jsindex 4cddc3dc2e..9049169ad6 100644--- a/server/services/cos.js+++ b/server/services/cos.js@@ -2367,11 +2367,17 @@ export async function addTask(taskData, taskType = 'user', { raw = false } = {})tasks = parseTasksMarkdown(content);}- // Reject duplicate: same first-line description already pending or in_progress.+ // Reject duplicate: same first-line description AND same target app already+ // pending or in_progress. The `metadata.app` scope matters — the same+ // description against two different apps is two different pieces of work+ // (e.g. "fix the failing test" in PortOS vs in BookLoom), and collapsing+ // them silently drops the second dispatch.const normalizedDesc = firstLine(taskData.description).toLowerCase();+ const targetApp = taskData.app || null;const duplicate = tasks.find(t =>(t.status === 'pending' || t.status === 'in_progress') &&- firstLine(t.description).toLowerCase() === normalizedDesc+ firstLine(t.description).toLowerCase() === normalizedDesc &&+ (t.metadata?.app || null) === targetApp);if (duplicate) {console.log(`⚠️ Duplicate task rejected: "${normalizedDesc.substring(0, 60)}" matches ${duplicate.id}`);diff --git a/server/services/cos.test.js b/server/services/cos.test.jsindex 658f63ab61..8a1e0a0161 100644--- a/server/services/cos.test.js+++ b/server/services/cos.test.js@@ -852,4 +852,19 @@ describe('addTask — first-line dedup', () => {expect(fnBody).toMatch(/firstLine\(taskData\.description\)/);expect(fnBody).toMatch(/firstLine\(t\.description\)/);});++ it('addTask scopes dedup by metadata.app (regression guard)', () => {+ // Same description against two different apps must NOT trip the+ // duplicate check — surfaced by codex review of the+ // [voice-code-agent-target-managed-app] PR. Without this scope, the+ // voice tool happily speaks "Queued in BookLoom" while returning the+ // matched PortOS task.+ const start = COS_SRC.indexOf('export async function addTask');+ const end = COS_SRC.indexOf('export async function', start + 1);+ const fnBody = COS_SRC.slice(start, end === -1 ? undefined : end);+ // The dedup `tasks.find(...)` predicate must compare the candidate's+ // `metadata?.app` (or null) against the new task's `taskData.app`.+ expect(fnBody).toMatch(/t\.metadata\?\.app\s*\|\|\s*null/);+ expect(fnBody).toMatch(/taskData\.app\s*\|\|\s*null/);+ });});