{"record":{"id":"e0cb40a7f00ba461","repo":"JuliusBrussee/caveman","slug":"expected-exactly-2-agent-conformance-fixtures-fou","errorCode":null,"errorMessage":"expected exactly 2 agent conformance fixtures, found ${fixtureFiles.length}","messagePattern":"expected exactly 2 agent conformance fixtures, found (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/shared/contracts/scripts/validate-schemas.mjs","lineNumber":41,"sourceCode":"    throw new Error(`${file}: missing $id`);\n  }\n  schemas.push(schema);\n}\n\nconst ajv = new Ajv2020({ allErrors: true, strict: true });\najv.addSchema(schemas);\nfor (const schema of schemas) {\n  const validate = ajv.getSchema(schema.$id);\n  if (!validate) throw new Error(`schema failed to compile: ${schema.$id}`);\n}\n\nconst agentFixtureRoot = path.join(packageRoot, \"fixtures\", \"agent\");\nconst fixtureFiles = (await readdir(agentFixtureRoot))\n  .filter((name) => name.endsWith(\".json\"))\n  .sort();\n\nif (fixtureFiles.length !== 2) {\n  throw new Error(`expected exactly 2 agent conformance fixtures, found ${fixtureFiles.length}`);\n}\n\nconst fixtures = await Promise.all(\n  fixtureFiles.map(async (file) => JSON.parse(await readFile(path.join(agentFixtureRoot, file), \"utf8\"))),\n);\nconst validateAdapterConformance = ajv.getSchema(\n  \"https://caveman.so/schemas/adapter-conformance.schema.json\",\n);\nif (!validateAdapterConformance) {\n  throw new Error(\"adapter conformance schema failed to compile\");\n}\nfor (const [index, fixture] of fixtures.entries()) {\n  if (!validateAdapterConformance(fixture)) {\n    throw new Error(\n      `${fixtureFiles[index]}: ${ajv.errorsText(validateAdapterConformance.errors)}`,\n    );\n  }\n}","sourceCodeStart":23,"sourceCodeEnd":59,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/packages/shared/contracts/scripts/validate-schemas.mjs#L23-L59","documentation":"The script pins the agent conformance fixture set to exactly two files — one for the claude harness and one for the pi harness (later destructured as const [claude, pi]). Any other count means the fixture set drifted from the contract, so it throws with the actual count found.","triggerScenarios":"Running scripts/validate-schemas.mjs when packages/shared/contracts/fixtures/agent contains more or fewer than two *.json files — e.g. adding a third harness fixture, a leftover scratch JSON, or deleting one of the two required fixtures.","commonSituations":"Adding a new harness (e.g. codex) fixture without updating the script's expected count/destructuring; a test artifact .json file left in the directory; renaming a fixture while a copy remains.","solutions":["Remove any stray non-conformance .json files from fixtures/agent so exactly the claude and pi fixtures remain","If a third harness is intentional, update the script to expect 3 and destructure the new fixture","Restore a deleted fixture from git history","Consider a glob/subdirectory if scratch files keep landing in the fixtures dir"],"exampleFix":"# before\nfixtures/agent/claude.json fixtures/agent/pi.json fixtures/agent/scratch.json\n# after\nfixtures/agent/claude.json fixtures/agent/pi.json","handlingStrategy":"validation","validationCode":"const fixtureFiles = (await readdir(agentFixtureRoot)).filter(n => n.endsWith('.json'));\nconst expected = ['claude.json', 'pi.json'];\nif (fixtureFiles.length !== 2 || !expected.every(f => fixtureFiles.includes(f))) {\n  throw new Error(`fixtures/agent must contain exactly ${expected.join(', ')}; found ${fixtureFiles}`);\n}","typeGuard":null,"tryCatchPattern":"try { loadAgentFixtures(); } catch (e) { if (e.message.includes('expected exactly 2 agent conformance fixtures')) { console.error('Fixture set drifted:', e.message); process.exitCode = 1; } else throw e; }","preventionTips":["Keep scratch files out of fixtures/agent directories","Update expected-count and destructuring together when adding a harness","Add a directory listing check to the fixture generator"],"tags":["fixtures","validation","filesystem"],"backgroundTag":"invalid-argument-value","analyzedSha":"3ee70a102609e550bd2e68004bf5990a9341c851","analyzedAt":"2026-09-20T15:53:39.229Z","contentChangedAt":"2026-09-20T15:53:39.229Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}