{"record":{"id":"93a38b81af1a93f2","repo":"affaan-m/ECC","slug":"harness-capability-catalog-contains-duplicate-inst","errorCode":null,"errorMessage":"Harness capability catalog contains duplicate install target ids","messagePattern":"Harness capability catalog contains duplicate install target ids","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"scripts/lib/harness-capabilities.js","lineNumber":278,"sourceCode":"  }\n}\n\nfunction expectedRootForAdapter(adapter) {\n  const homeDir = path.resolve('/__ecc_catalog_home__');\n  const projectRoot = path.resolve('/__ecc_catalog_project__');\n  const absoluteRoot = adapter.resolveRoot({ homeDir, projectRoot, env: {} });\n  const baseRoot = adapter.kind === 'home' ? homeDir : projectRoot;\n  const prefix = adapter.kind === 'home' ? '~/' : './';\n  return `${prefix}${path.relative(baseRoot, absoluteRoot).replace(/\\\\/g, '/')}`;\n}\n\nfunction validateCatalog() {\n  const adapters = listInstallTargetAdapters();\n  const adapterByTarget = new Map(adapters.map(adapter => [adapter.target, adapter]));\n  const catalogTargetIds = HARNESS_CAPABILITIES.flatMap(harness => harness.targetIds);\n\n  if (new Set(catalogTargetIds).size !== catalogTargetIds.length) {\n    throw new Error('Harness capability catalog contains duplicate install target ids');\n  }\n\n  const supported = [...SUPPORTED_INSTALL_TARGETS].sort();\n  const registered = adapters.map(adapter => adapter.target).sort();\n  const catalogued = [...catalogTargetIds].sort();\n  if (\n    JSON.stringify(catalogued) !== JSON.stringify(supported)\n    || JSON.stringify(catalogued) !== JSON.stringify(registered)\n  ) {\n    throw new Error('Harness capability catalog is out of sync with install targets');\n  }\n\n  for (const harness of HARNESS_CAPABILITIES) {\n    for (const declaredScope of harness.scopes) {\n      const adapter = adapterByTarget.get(declaredScope.targetId);\n      if (!adapter || expectedRootForAdapter(adapter) !== declaredScope.root) {\n        throw new Error(\n          `Harness capability root is out of sync for target ${declaredScope.targetId}`","sourceCodeStart":260,"sourceCodeEnd":296,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/scripts/lib/harness-capabilities.js#L260-L296","documentation":"validateCatalog enforces that every install-target id across HARNESS_CAPABILITIES is unique; it throws when new Set(catalogTargetIds).size !== catalogTargetIds.length. This is a startup consistency invariant ensuring each target id maps to exactly one capability entry.","triggerScenarios":"Editing HARNESS_CAPABILITIES and listing the same targetId under two harnesses (copy-paste when adding a new harness or target); merging branches that both added the same target id.","commonSituations":"Contributors adding a new harness entry in scripts/lib/harness-capabilities.js and accidentally duplicating an existing targetIds entry; a rename left the old id in place alongside the new one; the project's own test suite catches it first.","solutions":["Search HARNESS_CAPABILITIES for the duplicated targetId and remove it from the wrong harness.","If two harnesses legitimately share an install surface, factor it into one harness entry instead of duplicating the id.","Run the catalog tests (`npm test`) after edits to catch duplicates immediately.","Regenerate any derived catalogs (`npm run catalog:sync`) after fixing."],"exampleFix":"// before\nconst HARNESS_CAPABILITIES = [\n  { id: 'codex', targetIds: ['agents'] },\n  { id: 'cursor', targetIds: ['agents'] }, // duplicate\n];\n\n// after\nconst HARNESS_CAPABILITIES = [\n  { id: 'codex', targetIds: ['agents'] },\n  { id: 'cursor', targetIds: ['cursor-rules'] },\n];","handlingStrategy":"validation","validationCode":"const ids = HARNESS_CAPABILITIES.flatMap(h => h.targetIds);\nif (new Set(ids).size !== ids.length) {\n  const dupes = ids.filter((id, i) => ids.indexOf(id) !== i);\n  throw new Error(`Duplicate target ids: ${[...new Set(dupes)].join(', ')}`);\n}","typeGuard":null,"tryCatchPattern":"try {\n  validateCatalog();\n} catch (e) {\n  if (/duplicate install target ids/.test(e.message)) {\n    console.error('Catalog edit introduced a duplicate targetId — remove it before shipping.');\n  }\n  throw e;\n}","preventionTips":["Run the catalog tests locally before every PR touching harness-capabilities.js.","Grep for the new targetId across HARNESS_CAPABILITIES before adding it.","Remove old targetIds when renaming instead of keeping both."],"tags":["config","invariant","catalog","duplicate"],"backgroundTag":"internal-invariant-violation","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"}