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
fix([cos-task-id-uniqueness-validation]): pre-scan raw ids so dedup never renames a distinct task
[._.]/ Adam Eivy931fdd17b971
diff --git a/server/lib/taskParser.js b/server/lib/taskParser.jsindex 8b82536129..de77ddfaea 100644--- a/server/lib/taskParser.js+++ b/server/lib/taskParser.js@@ -173,6 +173,20 @@ export function parseTasksMarkdown(content) {let currentTask = null;let currentSection = null;+ // Pre-scan every task line's normalized id so suffix assignment below can+ // avoid colliding with any *stable, user-authored* id present in the file —+ // not just ids we've parsed so far. Without this a duplicate could grab+ // `task-001-dup2` only for a real later `task-001-dup2` to be bumped to+ // `task-001-dup2-dup2`, needlessly mutating an id the user chose. We rename+ // the duplicate, never the unique original.+ const rawIds = new Set();+ for (const line of lines) {+ if (line.startsWith('- [')) {+ const parsed = parseTaskLine(line);+ if (parsed) rawIds.add(parsed.id);+ }+ }+// Push a fully-parsed task, guaranteeing its id is unique across the file.// Duplicate ids corrupt downstream consumers that key on id — most notably// reorderTasks' `new Map(tasks.map(t => [t.id, t]))`, which silently collapses@@ -186,7 +200,9 @@ export function parseTasksMarkdown(content) {if (seenIds.has(task.id)) {const originalId = task.id;let suffix = 2;- while (seenIds.has(`${originalId}-dup${suffix}`)) suffix++;+ // Skip suffixes already taken AND any raw id in the file, so we never+ // rename a distinct task that happens to look like a generated suffix.+ while (seenIds.has(`${originalId}-dup${suffix}`) || rawIds.has(`${originalId}-dup${suffix}`)) suffix++;task.id = `${originalId}-dup${suffix}`;console.warn(`⚠️ Duplicate task id "${originalId}" in tasks markdown — renamed to "${task.id}"`);}diff --git a/server/lib/taskParser.test.js b/server/lib/taskParser.test.jsindex b2006907c7..793b2421de 100644--- a/server/lib/taskParser.test.js+++ b/server/lib/taskParser.test.js@@ -213,7 +213,7 @@ describe('Task Parser', () => {expect(byId.size).toBe(3);});- it('should not collide a suffixed id with a real later task carrying that suffix', () => {+ it('should rename the duplicate, never a distinct task that looks like a suffix', () => {const markdown = `# Tasks## Pending@@ -222,13 +222,13 @@ describe('Task Parser', () => {- [ ] #task-001-dup2 | MEDIUM | C already named like a suffix`;const tasks = parseTasksMarkdown(markdown);- const ids = tasks.map(t => t.id);- // The renamed first duplicate takes `task-001-dup2`; the real `task-001-dup2`- // then collides and suffixes off its own id (`task-001-dup2-dup2`) — the key- // point is every id stays distinct, never a re-collision.- expect(new Set(ids).size).toBe(ids.length);- expect(ids).toEqual(['task-001', 'task-001-dup2', 'task-001-dup2-dup2']);+ // The duplicate of task-001 skips `-dup2` (a real id elsewhere in the file)+ // and takes `-dup3`; the user-authored `task-001-dup2` keeps its stable id.+ expect(tasks.map(t => t.id)).toEqual(['task-001', 'task-001-dup3', 'task-001-dup2']);+ expect(tasks.map(t => t.description)).toEqual(['A', 'B', 'C already named like a suffix']);+ // Still no re-collision.+ expect(new Set(tasks.map(t => t.id)).size).toBe(tasks.length);});});