{"record":{"id":"f71c07e7f450dbce","repo":"JuliusBrussee/caveman","slug":"agent-conformance-fixtures-must-cover-claude-and-pi","errorCode":null,"errorMessage":"agent conformance fixtures must cover claude and pi","messagePattern":"agent conformance fixtures must cover claude and pi","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/shared/contracts/scripts/validate-schemas.mjs","lineNumber":62,"sourceCode":"const 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]) {\n  if (JSON.stringify(claude[key]) !== JSON.stringify(pi[key])) {\n    throw new Error(`agent conformance mismatch: ${key}`);\n  }\n}\nif (claude.build_sha256 === pi.build_sha256) {\n  throw new Error(\"adapter-specific build_sha256 values must differ\");\n}","sourceCodeStart":44,"sourceCodeEnd":80,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/packages/shared/contracts/scripts/validate-schemas.mjs#L44-L80","documentation":"The build-time validator in packages/shared/contracts/scripts/validate-schemas.mjs loads exactly two agent conformance fixtures (sorted by filename) and destructures them as [claude, pi]. It requires the first fixture's `harness` field to be \"claude\" and the second to be \"pi\"; otherwise the script throws this error. This guarantees the static contract fixtures actually cover both adapter harnesses before cross-checking their shared fields.","triggerScenarios":"Running the contracts build/validate script when: (1) one of the two fixture files in packages/shared/contracts/fixtures/agent/ has a `harness` value other than \"claude\"/\"pi\" (e.g. a typo like \"p1\" or a placeholder), (2) a new harness fixture is added or one is removed so sorted order puts the wrong file first (fixtures.length !== 2 would throw first, but renaming a file while keeping two files changes the [claude, pi] assignment), or (3) a fixture is regenerated with an omitted or renamed `harness` key (the schema must still have passed, so likely an added optional-key path or a schema edit).","commonSituations":"Regenerating fixtures for a new adapter version and accidentally setting harness to the adapter package name; adding a third fixture file named so it sorts before claude-conformance.json (pairing with the adjacent fixture-count error); hand-editing a fixture while debugging schema changes and leaving `harness` as \"\" or \"test\"; copying pi-conformance.json as a template for a new claude fixture and forgetting to change `harness` back.","solutions":["Open packages/shared/contracts/fixtures/agent/*.json and set `harness` to \"claude\" in claude-conformance.json and \"pi\" in pi-conformance.json.","If you added/renamed fixture files, ensure exactly two .json files exist and their names sort as claude-conformance.json then pi-conformance.json.","If a new harness is genuinely required, update validate-schemas.mjs (and adapter-conformance.schema.json enum) to model more than two harnesses instead of relying on the [claude, pi] destructure.","Re-run the validation script (contracts build/test) and confirm the fixtures also pass adapter-conformance.schema.json, whose `harness` enum must include the value you set."],"exampleFix":"// before (packages/shared/contracts/fixtures/agent/pi-conformance.json)\n\"harness\": \"p1\"\n\n// after\n\"harness\": \"pi\"","handlingStrategy":"validation","validationCode":"import { readdir, readFile } from \"node:fs/promises\";\nconst files = (await readdir(\"packages/shared/contracts/fixtures/agent\")).filter(f => f.endsWith(\".json\")).sort();\nconst harnesses = await Promise.all(files.map(async f => JSON.parse(await readFile(`packages/shared/contracts/fixtures/agent/${f}`, \"utf8\")).harness));\nif (JSON.stringify(harnesses) !== JSON.stringify([\"claude\", \"pi\"])) {\n  throw new Error(`fixture order/harness wrong: ${files} -> ${harnesses}`);\n}","typeGuard":"function isConformanceFixture(v) {\n  return typeof v === \"object\" && v !== null && (v.harness === \"claude\" || v.harness === \"pi\");\n}","tryCatchPattern":"try {\n  await runValidationScript();\n} catch (err) {\n  if (err.message === \"agent conformance fixtures must cover claude and pi\") {\n    console.error(\"Check fixtures/agent/*.json: harness must be 'claude' then 'pi' in sorted order.\");\n    process.exit(1);\n  }\n  throw err;\n}","preventionTips":["Always regenerate claude and pi fixtures together from one script, never by hand-editing one file.","Never add or rename fixture files without checking the sorted-order assumption [claude, pi] in validate-schemas.mjs.","Keep `harness` values in sync with the enum in adapter-conformance.schema.json."],"tags":["build","fixtures","schema-validation","node"],"backgroundTag":"invalid-enum-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"}