{"record":{"id":"f3e69272827a5e64","repo":"tinyhumansai/openhuman","slug":"branch-id-segment-m-1-does-not-match-agent-i","errorCode":null,"errorMessage":"branch id segment \"${m[1]}\" does not match agent id \"${agent.id}\"","messagePattern":"branch id segment \"(.+?)\" does not match agent id \"(.+?)\"","errorType":"validation","errorClass":"SpecError","httpStatus":null,"severity":"error","filePath":"scripts/agent-batch/lib.mjs","lineNumber":124,"sourceCode":"    if (!Number.isInteger(agent.issue) || agent.issue <= 0) {\n      throw new SpecError(\"issue must be a positive integer\", `${at}.issue`);\n    }\n    if (seenIssue.has(agent.issue)) {\n      throw new SpecError(`duplicate issue #${agent.issue}`, `${at}.issue`);\n    }\n    seenIssue.add(agent.issue);\n    if (typeof agent.title !== \"string\" || agent.title.trim().length === 0) {\n      throw new SpecError(\"title must be a non-empty string\", `${at}.title`);\n    }\n    const m = BRANCH_RE.exec(agent.branch);\n    if (!m) {\n      throw new SpecError(\n        `branch must match cursor/<id>-<issue>-<slug> (got \"${agent.branch}\")`,\n        `${at}.branch`,\n      );\n    }\n    if (m[1] !== agent.id) {\n      throw new SpecError(\n        `branch id segment \"${m[1]}\" does not match agent id \"${agent.id}\"`,\n        `${at}.branch`,\n      );\n    }\n    if (Number(m[2]) !== agent.issue) {\n      throw new SpecError(\n        `branch issue segment \"${m[2]}\" does not match agent issue ${agent.issue}`,\n        `${at}.branch`,\n      );\n    }\n    if (seenBranch.has(agent.branch)) {\n      throw new SpecError(`duplicate branch \"${agent.branch}\"`, `${at}.branch`);\n    }\n    seenBranch.add(agent.branch);\n    if (!Array.isArray(agent.owned_paths) || agent.owned_paths.length === 0) {\n      throw new SpecError(\n        \"owned_paths must be a non-empty array\",\n        `${at}.owned_paths`,","sourceCodeStart":106,"sourceCodeEnd":142,"githubUrl":"https://github.com/tinyhumansai/openhuman/blob/a221052e0df5b1f7598fceba7329fd1af95d6699/scripts/agent-batch/lib.mjs#L106-L142","documentation":"After BRANCH_RE matches, capture group 1 (the id segment of the branch) must equal the agent's id field exactly. This keeps branch names self-describing so tooling can map a checked-out branch back to its agent without a lookup table. The mismatched pair is printed as \"<branchSegment> vs <agentId>\" with path \"agents[i].branch\" — note the path is .branch, not .id, because the branch is considered the wrong side.","triggerScenarios":"Agent {\"id\": \"a01\", \"branch\": \"cursor/a02-5313-fix-ci\"} — branch cut from another agent's template without updating the id segment; renumbering ids (e.g. a1 → a01, error 188 fix) without regenerating branches.","commonSituations":"Duplicating an agent entry and updating id but not branch, or vice versa; inserting a new agent at the top and shifting ids without touching branch strings.","solutions":["Edit the branch's id segment to equal the agent's id: cursor/a02-... → cursor/a01-...","Alternatively fix the agent's id if the branch was the correct one","Derive branches programmatically: `cursor/${a.id}-${a.issue}-${slugify(a.title)}` so they can never drift"],"exampleFix":"// before\n{ \"id\": \"a01\", \"issue\": 5312, \"branch\": \"cursor/a02-5312-fix-ci-timeout\" }\n\n// after\n{ \"id\": \"a01\", \"issue\": 5312, \"branch\": \"cursor/a01-5312-fix-ci-timeout\" }","handlingStrategy":"validation","validationCode":"import { BRANCH_RE } from \"./scripts/agent-batch/lib.mjs\";\nfor (const [i, a] of spec.agents.entries()) {\n  const m = BRANCH_RE.exec(a.branch);\n  if (!m || m[1] !== a.id) console.error(`agents[${i}].branch id segment must equal agent.id`);\n}","typeGuard":null,"tryCatchPattern":"try {\n  validateSpec(spec);\n} catch (e) {\n  if (e instanceof SpecError && /branch id segment/.test(e.message)) {\n    console.error(`regenerate the branch from the agent fields: ${e.message}`);\n    process.exit(1);\n  }\n  throw e;\n}","preventionTips":["Single-source the branch: compute it from id/issue/title so segments cannot disagree","When renumbering ids, search-and-replace 'cursor/aNN-' across the spec file"],"tags":["validation","json","spec","agent-batch","consistency"],"backgroundTag":null,"analyzedSha":"a221052e0df5b1f7598fceba7329fd1af95d6699","analyzedAt":"2026-08-16T12:47:06.542Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}