{"record":{"id":"a6628fa9029f9e72","repo":"affaan-m/ECC","slug":"workers-must-have-unique-slugs-duplicate-work","errorCode":null,"errorMessage":"Workers must have unique slugs — duplicate: ${workerSlug}","messagePattern":"Workers must have unique slugs — duplicate: (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/lib/tmux-worktree-orchestrator.js","lineNumber":203,"sourceCode":"  const coordinationDir = path.join(coordinationRoot, sessionName);\n  const baseRef = config.baseRef || 'HEAD';\n  const defaultLauncher = config.launcherCommand || '';\n\n  if (workers.length === 0) {\n    throw new Error('buildOrchestrationPlan requires at least one worker');\n  }\n\n  const seenSlugs = new Set();\n  const workerPlans = workers.map((worker, index) => {\n    if (!worker || typeof worker.task !== 'string' || worker.task.trim().length === 0) {\n      throw new Error(`Worker ${index + 1} is missing a task`);\n    }\n\n    const workerName = worker.name || `worker-${index + 1}`;\n    const workerSlug = slugify(workerName, `worker-${index + 1}`);\n\n    if (seenSlugs.has(workerSlug)) {\n      throw new Error(`Workers must have unique slugs — duplicate: ${workerSlug}`);\n    }\n    seenSlugs.add(workerSlug);\n\n    const branchName = `orchestrator-${sessionName}-${workerSlug}`;\n    const worktreePath = path.join(worktreeRoot, `${repoName}-${sessionName}-${workerSlug}`);\n    const workerCoordinationDir = path.join(coordinationDir, workerSlug);\n    const taskFilePath = path.join(workerCoordinationDir, 'task.md');\n    const handoffFilePath = path.join(workerCoordinationDir, 'handoff.md');\n    const statusFilePath = path.join(workerCoordinationDir, 'status.md');\n    const launcherCommand = worker.launcherCommand || defaultLauncher;\n    const workerSeedPaths = normalizeSeedPaths(worker.seedPaths, repoRoot);\n    const seedPaths = normalizeSeedPaths([...globalSeedPaths, ...workerSeedPaths], repoRoot);\n    const templateVariables = buildTemplateVariables({\n      branch_name: branchName,\n      handoff_file: handoffFilePath,\n      repo_root: repoRoot,\n      session_name: sessionName,\n      status_file: statusFilePath,","sourceCodeStart":185,"sourceCodeEnd":221,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/scripts/lib/tmux-worktree-orchestrator.js#L185-L221","documentation":"buildOrchestrationPlan validates that every worker in an orchestration plan maps to a distinct slug (derived via slugify from worker.name or a positional fallback). If two workers slugify to the same value, later resources (branch, worktree path, coordination dir) would collide, so the plan is rejected up front with this error.","triggerScenarios":"Calling plan() (which calls buildOrchestrationPlan) with a config where two workers share the same name, or where names differ only by characters that slugify strips/normalizes (e.g. 'Worker 1' and 'worker-1', or 'My Agent!' and 'my-agent').","commonSituations":"Copy-pasting a worker entry in the orchestration config and forgetting to rename it; renaming workers to names that collapse to the same slug after normalization; generating workers programmatically without unique names.","solutions":["Rename the duplicate workers so each has a unique name in the orchestration config.","If workers are generated programmatically, append a unique suffix (e.g. index) to each name.","Check slugify behavior: names differing only in case, punctuation, or whitespace can collapse to the same slug — make names differ alphanumerically."],"exampleFix":"// before\nworkers: [\n  { name: 'Build' },\n  { name: 'Build' }\n]\n// after\nworkers: [\n  { name: 'Build' },\n  { name: 'Test' }\n]","handlingStrategy":"validation","validationCode":"const names = workers.map(w => w.name);\nconst dupes = names.filter((n, i) => names.indexOf(n) !== i);\nif (dupes.length) throw new Error(`duplicate worker names: ${[...new Set(dupes)].join(', ')}`);\nconst slugs = names.map(n => n.toLowerCase().replace(/[^a-z0-9]+/g, '-'));\nif (new Set(slugs).size !== slugs.length) throw new Error('workers collapse to duplicate slugs');","typeGuard":null,"tryCatchPattern":"try {\n  const plan = buildOrchestrationPlan(config);\n} catch (err) {\n  if (String(err.message).includes('unique slugs')) {\n    console.error('Fix worker names in config — duplicates found:', err.message);\n    process.exitCode = 1;\n    return;\n  }\n  throw err;\n}","preventionTips":["Enforce unique worker names in config schema validation (zod/ajv) before planning","Programmatically suffix generated worker names with an index","Keep names distinct alphanumerically, not just by case or punctuation","Add a CI lint that runs buildOrchestrationPlan against config fixtures"],"tags":["configuration","validation","naming"],"backgroundTag":"invalid-identifier-format","analyzedSha":"8321021c54d670126ce3b2969d5deb880b4b0c2a","analyzedAt":"2026-09-16T10:08:13.343Z","contentChangedAt":"2026-09-16T10:08:13.343Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}