{"record":{"id":"92ae8b7ff89a6f44","repo":"paperclipai/paperclip","slug":"fixture-state-invalid","errorCode":"fixture_state_invalid","errorMessage":"A skill with that name already exists","messagePattern":"A skill with that name already exists","errorType":"error_code","errorClass":"CapabilityMockControlPlaneError","httpStatus":null,"severity":"error","filePath":"packages/paperclip-runner/src/mock-core/capability-mock-control-plane-adapter.ts","lineNumber":729,"sourceCode":"      }\n      case \"create_skill\": {\n        requireText(command.name, \"skill name\");\n        requireText(command.markdown, \"skill markdown\");\n        const document = parseFrontmatterMarkdown(command.markdown);\n        const validMetadata = validateSkillFrontmatter(document.frontmatter);\n        if (!document.hasFrontmatter || !validMetadata || !document.body.trim()\n          || document.frontmatter.name !== command.name\n          || document.frontmatter.description !== command.description.trim()\n          || (command.slug !== undefined && command.slug !== command.name)) {\n          throw new CapabilityMockControlPlaneError(\n            \"invalid_skill_document\",\n            \"Provide a complete SKILL.md with name and description matching the command inputs, a nonempty body, and slug equal to name when supplied\",\n          );\n        }\n        const slug = command.slug ?? command.name;\n        const skills = this.#state.skills ??= [];\n        if (skills.some(skill => skill.companyId === run.companyId && skill.slug === slug)) {\n          throw new CapabilityMockControlPlaneError(\"fixture_state_invalid\", \"A skill with that name already exists\");\n        }\n        const skill = { id: this.#id(\"skill\"), companyId: run.companyId, name: command.name,\n          slug, description: command.description.trim(), markdown: command.markdown, versionId: this.#id(\"skill-version\") };\n        skills.push(skill);\n        entityRefs.push(`skill:${skill.id}`);\n        break;\n      }\n      case \"write_document\": {\n        requireText(command.key, \"document key\");\n        requireText(command.title, \"document title\");\n        const existing = this.#state.documents.find(\n          (document) => document.taskId === task.id && document.key === command.key,\n        );\n        if (existing === undefined && command.baseRevisionId !== null) {\n          throw new CapabilityMockControlPlaneError(\n            \"document_revision_conflict\",\n            \"a new document must use a null base revision\",\n          );","sourceCodeStart":711,"sourceCodeEnd":747,"githubUrl":"https://github.com/paperclipai/paperclip/blob/3f1d897a7c018d76563a21c6e39c3c9b03933622/packages/paperclip-runner/src/mock-core/capability-mock-control-plane-adapter.ts#L711-L747","documentation":"CapabilityMockControlPlaneError with code `fixture_state_invalid`, thrown when a create_skill command would add a skill whose slug already exists within the same company in the mock control-plane state. The adapter enforces per-company uniqueness of skill slugs, mirroring the real control plane's uniqueness constraint.","triggerScenarios":"applyCommand → #executeCommand for create_skill where `this.#state.skills` already contains a skill with the same companyId and the resolved slug (command.slug ?? command.name). Re-running the same fixture command without resetting state, or creating two skills whose names slugify identically.","commonSituations":"Replaying a fixture or test twice against the same adapter state; two skills named 'Deploy App' and 'deploy-app' colliding on slug; forgetting that slug defaults to name so the name check is effectively a slug check.","solutions":["Use a unique skill name (and slug) not already present for that company in the mock state","Reset or rebuild the mock control-plane state between test runs","Check existing skills via the snapshot and pick a non-colliding slug","If re-creating intentionally, delete the existing skill or use an update command instead"],"exampleFix":"// before\nawait applyCommand({ kind: \"create_skill\", name: \"deploy\", ... }); // second run collides\n// after\nconst exists = adapter.snapshot().skills?.some(s => s.companyId === companyId && s.slug === \"deploy\");\nif (!exists) await applyCommand({ kind: \"create_skill\", name: \"deploy\", ... });","handlingStrategy":"try-catch","validationCode":"const slug = command.slug ?? command.name;\nconst exists = adapter.snapshot().skills?.some(s => s.companyId === run.companyId && s.slug === slug);\nif (exists) throw new Error(`Skill slug '${slug}' already exists for company`);","typeGuard":null,"tryCatchPattern":"try {\n  await adapter.applyCommand(cmd);\n} catch (e) {\n  if (e instanceof CapabilityMockControlPlaneError && e.code === \"fixture_state_invalid\"\n    && e.message.includes(\"already exists\")) {\n    cmd.name = `${cmd.name}-${Date.now()}`; // retry with unique slug\n  } else throw e;\n}","preventionTips":["Reset mock state between fixture runs","Slugify names deterministically and check the snapshot before creating","Avoid names that collide after slugification (case, spaces, hyphens)","Prefer update commands over re-creating existing skills"],"tags":["skills","duplicate","mock","conflict"],"backgroundTag":"file-already-exists","analyzedSha":"3f1d897a7c018d76563a21c6e39c3c9b03933622","analyzedAt":"2026-09-18T08:03:59.046Z","contentChangedAt":"2026-09-18T08:03:59.046Z","schemaVersion":2},"datasetVersion":"2026-09-22T16:17:23.217Z"}