Hmbown/CodeWhale · error
unexpected schema_version
Error message
unexpected schema_version ${matrix.schema_version} What it means
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.
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
Example fix
// before
{ "schema_version": 3, "cases": [...] }
// after
{ "schema_version": 2, "cases": [...] } Defensive patterns
Strategy: validation
Validate before calling
const matrix = JSON.parse(fs.readFileSync(matrixPath, "utf8"));
if (matrix.schema_version !== 2) throw new Error(`fixture matrix must be schema_version 2, got ${matrix.schema_version}`); Type guard
function isV2Matrix(m) { return m && m.schema_version === 2 && Array.isArray(m.cases); } Try / catch
try {
validateSurvivalContract(matrix);
} catch (e) {
if (e.message.startsWith("unexpected schema_version")) {
console.error(`fixture schema drift: ${e.message} — regenerate or update validator`);
process.exit(1);
}
throw e;
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- Codewhale terminal receipt contained a non-scalar field
- Duplicate .
- Duplicate policy identity.
- Facts must be scalar metadata, not content objects.
- Fleet task ' ' metadata.coordination_contracts must be an…
AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22).
Data as JSON: /api/errors/4689a9d83c48ba5a.
Report an issue: GitHub.
Appendix: source
Thrown at crates/tui/src/compaction/validate_survival_contract.mjs:178
if (checkpoints === 0) return "checkpoint receipt was dropped";
if (checkpoints > 1) return "prior summaries were duplicated";
if (anchors && !replacement.some((message) =>
(message.content ?? []).some((block) => {
if (block.type === "text") return (block.text ?? "").includes(anchors);
if (block.type === "tool_result") {
return (block.content ?? "").includes(anchors);
}
return false;
}),
)) {
return "pinned /anchor text was dropped";
}
return null;
}
function main() {
if (matrix.schema_version !== 2) {
throw new Error(`unexpected schema_version ${matrix.schema_version}`);
}
let failed = 0;
for (const fixture of matrix.cases) {
if (typeof fixture.last_round_start === "number") {
const start = lastRoundStart(fixture.original);
if (start !== fixture.last_round_start) {
failed += 1;
console.error(
`${fixture.id}: last_round_start ${start} != ${fixture.last_round_start}`,
);
}
}
const error = validateSurvivalContract(
fixture.original,
fixture.replacement,
fixture.anchors,
);
const passed = error === null;View on GitHub (pinned to 73e0f67d83)