{"record":{"id":"d12a230665131366","repo":"JuliusBrussee/caveman","slug":"fixturefiles-index-ajv-errorstext-validateadapterconformance","errorCode":null,"errorMessage":"${fixtureFiles[index]}: ${ajv.errorsText(validateAdapterConformance.errors)}","messagePattern":"\\$\\{fixtureFiles\\[index\\]\\}: \\$\\{ajv\\.errorsText\\(validateAdapterConformance\\.errors\\)\\}","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/shared/contracts/scripts/validate-schemas.mjs","lineNumber":55,"sourceCode":"  .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}\nconst [claude, pi] = fixtures;\nif (claude.harness !== \"claude\" || pi.harness !== \"pi\") {\n  throw new Error(\"agent conformance fixtures must cover claude and pi\");\n}\n\nfor (const key of [\n  \"normalized_context_digest\",\n  \"plan_sha256\",\n  \"ordered_transform_ids\",\n  \"provider_visible_digest\",\n  \"recovery_handles\",\n  \"accounting_method\",\n  \"failure_fallback\",\n]) {","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/packages/shared/contracts/scripts/validate-schemas.mjs#L37-L73","documentation":"When a harness fixture fails the adapter-conformance schema, the script throws with the fixture filename plus AJV's errorsText, pinpointing every schema violation (missing required harness fields, wrong types, invalid enum values). This is the fixture-level conformance gate before the script also asserts claude.harness === \"claude\" and pi.harness === \"pi\".","triggerScenarios":"Running scripts/validate-schemas.mjs when validateAdapterConformance(fixture) returns false for any fixture — the fixture's structure or content violates the adapter-conformance schema (bad/missing harness id, malformed step records, wrong types).","commonSituations":"A harness's recorded transcript format changed and fixtures were regenerated in a new shape; hand-edited fixture introduced a typo; schema gained a new required field not yet present in older fixtures.","solutions":["Read the errorsText after the filename in the message to find each violating dataPath and keyword","Update the named fixture to satisfy the schema (add required fields, fix types/enums)","Regenerate the fixture from the harness capture tooling if the transcript format changed","If the contract intentionally changed, update the schema and both fixtures in the same commit"],"exampleFix":"// before (claude.json)\n{ \"harness\": \"Claude\", \"steps\": [] }\n// after\n{ \"harness\": \"claude\", \"steps\": [{ \"type\": \"tool_call\", \"name\": \"read_file\" }] }","handlingStrategy":"validation","validationCode":"const validate = ajv.getSchema('https://caveman.so/schemas/adapter-conformance.schema.json');\nfor (const f of fixtures) if (!validate(f)) console.error(validate.errors.map(e => `${e.instancePath} ${e.message}`).join('\\n'));","typeGuard":"const looksConformant = (f) => typeof f?.harness === 'string' && Array.isArray(f?.steps);","tryCatchPattern":"try { validateFixtures(fixtures); } catch (e) { if (/\\.json: /.test(e.message)) { console.error('Conformance violations:', e.message); process.exitCode = 1; } else throw e; }","preventionTips":["Regenerate fixtures with official capture tooling after harness format changes","Update schema and fixtures in the same commit","Run schema validation locally before pushing fixture edits"],"tags":["schema","validation","fixtures","ajv"],"backgroundTag":"schema-validation-failed","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"}