{"record":{"id":"96a65d128473c3e0","repo":"ruvnet/ruflo","slug":"duplicate-anchor-task-id-task-id","errorCode":null,"errorMessage":"duplicate anchor task id: ${task.id}","messagePattern":"duplicate anchor task id: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"v3/@claude-flow/cli/src/services/harness-project-anchor.ts","lineNumber":102,"sourceCode":"\nfunction parseTasks(path: string): { version: string; tasks: HumanEvalTask[] } {\n  const parsed = JSON.parse(readFileSync(path, 'utf8')) as {\n    schemaVersion?: string;\n    version?: string;\n    tasks?: HumanEvalTask[];\n  };\n  if (parsed.schemaVersion && parsed.schemaVersion !== PROJECT_ANCHOR_SCHEMA) {\n    throw new Error(`unsupported flywheel anchor schema: ${parsed.schemaVersion}`);\n  }\n  if (!Array.isArray(parsed.tasks) || parsed.tasks.length < 4) {\n    throw new Error('project flywheel anchor requires at least 4 labelled tasks');\n  }\n  const ids = new Set<string>();\n  for (const [index, task] of parsed.tasks.entries()) {\n    if (!task || typeof task.id !== 'string' || !/^[A-Za-z0-9._-]{1,128}$/.test(task.id)) {\n      throw new Error(`invalid anchor task id at index ${index}`);\n    }\n    if (ids.has(task.id)) throw new Error(`duplicate anchor task id: ${task.id}`);\n    ids.add(task.id);\n    if (typeof task.q !== 'string' || task.q.trim().length === 0) {\n      throw new Error(`anchor task ${task.id} has no query`);\n    }\n    if (!Array.isArray(task.labels) || task.labels.length === 0 || task.labels.some((label) => typeof label !== 'string' || !label.trim())) {\n      throw new Error(`anchor task ${task.id} requires non-empty string labels`);\n    }\n  }\n  return { version: parsed.version ?? 'project-anchor-v1', tasks: parsed.tasks };\n}\n\nfunction toSelection(\n  path: string,\n  expectedHash: string,\n): FlywheelAnchorSelection {\n  const parsed = parseTasks(path);\n  const actualHash = humanEvalHash(parsed.tasks);\n  if (actualHash !== normalizeHash(expectedHash)) {","sourceCodeStart":84,"sourceCodeEnd":120,"githubUrl":"https://github.com/ruvnet/ruflo/blob/2602b642d92234c710ffbe96bfb33007d481ceab/v3/@claude-flow/cli/src/services/harness-project-anchor.ts#L84-L120","documentation":"Anchor task ids must be unique within the file — validation builds a Set as it walks the tasks and the second occurrence of an id throws, naming the duplicate. Duplicate ids would corrupt receipt correlation and the order-independent corpus hash (`humanEvalHash` sorts by id).","triggerScenarios":"Two tasks sharing an id, typically after merging two anchor files or copy-pasting a task and editing its query but forgetting to change its id.","commonSituations":"Manual curation merges; generators appending tasks without dedupe; refactors that rewrite queries but leave ids untouched.","solutions":["Find the duplicate named in the message and give one of the two tasks a distinct id","Dedupe programmatically when generating anchors from other sources","Re-run after fixing — validation reports one duplicate at a time, so large files may need several passes"],"exampleFix":"// before\n[ { \"id\": \"login\", \"q\": \"...\" }, { \"id\": \"login\", \"q\": \"other...\" } ]\n\n// after\n[ { \"id\": \"login\", \"q\": \"...\" }, { \"id\": \"login-oauth\", \"q\": \"other...\" } ]","handlingStrategy":"validation","validationCode":"import { readFileSync } from 'node:fs';\n\nfunction anchorTaskIdsUnique(file: string): { ok: boolean; duplicate?: string } {\n  const { tasks } = JSON.parse(readFileSync(file, 'utf8'));\n  const seen = new Set<string>();\n  for (const t of tasks ?? []) {\n    if (seen.has(t.id)) return { ok: false, duplicate: t.id };\n    seen.add(t.id);\n  }\n  return { ok: true };\n}","typeGuard":null,"tryCatchPattern":"try {\n  return loadEffectiveFlywheelAnchor(root, opts);\n} catch (e) {\n  if (e instanceof Error && e.message.startsWith('duplicate anchor task id')) {\n    const dup = e.message.split(': ')[1];\n    throw new Error(`Two tasks share id '${dup}' — rename one; ids are lineage correlation keys and must be unique.`);\n  }\n  throw e;\n}","preventionTips":["Dedupe in generators: key a Map by id and fail on collision","After merging anchor files, run a uniqueness check before committing","Rename the id whenever you clone a task to variant it"],"tags":["schema","validation","anchor","uniqueness"],"backgroundTag":"schema-validation-failed","analyzedSha":"2602b642d92234c710ffbe96bfb33007d481ceab","analyzedAt":"2026-08-18T21:34:22.708Z","contentChangedAt":"2026-08-18T21:34:22.708Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}