{"record":{"id":"4689a9d83c48ba5a","repo":"Hmbown/CodeWhale","slug":"unexpected-schema-version-matrix-schema-version","errorCode":null,"errorMessage":"unexpected schema_version ${matrix.schema_version}","messagePattern":"unexpected schema_version (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/compaction/validate_survival_contract.mjs","lineNumber":178,"sourceCode":"  if (checkpoints === 0) return \"checkpoint receipt was dropped\";\n  if (checkpoints > 1) return \"prior summaries were duplicated\";\n  if (anchors && !replacement.some((message) =>\n    (message.content ?? []).some((block) => {\n      if (block.type === \"text\") return (block.text ?? \"\").includes(anchors);\n      if (block.type === \"tool_result\") {\n        return (block.content ?? \"\").includes(anchors);\n      }\n      return false;\n    }),\n  )) {\n    return \"pinned /anchor text was dropped\";\n  }\n  return null;\n}\n\nfunction main() {\n  if (matrix.schema_version !== 2) {\n    throw new Error(`unexpected schema_version ${matrix.schema_version}`);\n  }\n  let failed = 0;\n  for (const fixture of matrix.cases) {\n    if (typeof fixture.last_round_start === \"number\") {\n      const start = lastRoundStart(fixture.original);\n      if (start !== fixture.last_round_start) {\n        failed += 1;\n        console.error(\n          `${fixture.id}: last_round_start ${start} != ${fixture.last_round_start}`,\n        );\n      }\n    }\n    const error = validateSurvivalContract(\n      fixture.original,\n      fixture.replacement,\n      fixture.anchors,\n    );\n    const passed = error === null;","sourceCodeStart":160,"sourceCodeEnd":196,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/compaction/validate_survival_contract.mjs#L160-L196","documentation":"The compaction survival-contract validator checks a fixture matrix against schema_version 2 and throws this plain Error when the matrix declares any other version. The validator's fixture logic is version-specific; an unrecognized schema means results would be meaningless, so it fails loudly instead of guessing.","triggerScenarios":"Running validate_survival_contract.mjs with a matrix file whose top-level schema_version is not exactly 2: hand-edited fixture file, fixture generated by a newer/older generator, or a copy from another branch where the schema moved.","commonSituations":"Fixture matrix regenerated by a tool bumping schema_version to 3; stale checked-in fixtures after a schema migration; contributor editing schema_version without updating the validator; merging branches where one bumped the schema.","solutions":["Regenerate or update the matrix file so schema_version is 2","If the schema legitimately changed to a new version, update this validator's parsing logic and the version check together","Check out the fixture matrix from the branch that matches this validator","Diff the matrix against a known-good fixture to spot schema drift","Confirm no merge accidentally combined an old matrix with a new validator"],"exampleFix":"// before\n{ \"schema_version\": 3, \"cases\": [...] }\n// after\n{ \"schema_version\": 2, \"cases\": [...] }","handlingStrategy":"validation","validationCode":"const matrix = JSON.parse(fs.readFileSync(matrixPath, \"utf8\"));\nif (matrix.schema_version !== 2) throw new Error(`fixture matrix must be schema_version 2, got ${matrix.schema_version}`);","typeGuard":"function isV2Matrix(m) { return m && m.schema_version === 2 && Array.isArray(m.cases); }","tryCatchPattern":"try {\n  validateSurvivalContract(matrix);\n} catch (e) {\n  if (e.message.startsWith(\"unexpected schema_version\")) {\n    console.error(`fixture schema drift: ${e.message} — regenerate or update validator`);\n    process.exit(1);\n  }\n  throw e;\n}","preventionTips":["Regenerate fixture matrices with the generator matching the validator's version","Never hand-edit schema_version; bump it only with a validator update","Diff fixtures against a known-good matrix after merges","Pin matrix generation and validation to the same tooling version"],"tags":["schema","validation","fixtures"],"backgroundTag":"schema-validation-failed","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}