{"record":{"id":"a4b8628d83a3f284","repo":"JuliusBrussee/caveman","slug":"where-generated-case-list-disagrees-with-the-co","errorCode":null,"errorMessage":"${where} generated case list disagrees with the composed dataset","messagePattern":"(.+?) generated case list disagrees with the composed dataset","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/shared/contracts/scripts/validate-continuous-improvement.mjs","lineNumber":308,"sourceCode":"    // tests nothing while counting as adversarial coverage.\n    const confidenceGuard = item.change_set.applicability.all.some((condition) =>\n      condition === \"failure_location_confidence >= 0.90\" ||\n      condition === \"symbol_resolution == unique\" ||\n      condition === \"targeted_test_reproduces == true\");\n    const perturbations = new Set(dataset.cases.map((entry) => entry.perturbation));\n    for (const [perturbation, label] of [[\"guard_threshold_boundary\", \"boundary\"], [\"stale_input\", \"stale-input\"]]) {\n      if (perturbations.has(perturbation) !== confidenceGuard) {\n        throw new Error(`${where} ${confidenceGuard ? \"omits\" : \"generated\"} a ${label} case ${confidenceGuard ? \"for\" : \"against\"} a change set that ${confidenceGuard ? \"declares\" : \"declares no\"} confidence guard`);\n      }\n    }\n    const expectedTargets = Math.min(4, dataset.target_failure_cases.length);\n    const expectedPriors = Math.min(2, dataset.prior_success_cases.length);\n    if (roleCounts.target_failure !== expectedTargets) throw new Error(`${where} dataset carries ${roleCounts.target_failure} target-failure cases, want ${expectedTargets}`);\n    if (roleCounts.prior_success !== expectedPriors) throw new Error(`${where} dataset carries ${roleCounts.prior_success} prior-success cases, want ${expectedPriors}`);\n    if (roleCounts.boundary > 1) throw new Error(`${where} dataset carries ${roleCounts.boundary} boundary cases, want at most one`);\n    if (roleCounts.adversarial > (confidenceGuard ? 2 : 1)) throw new Error(`${where} dataset carries ${roleCounts.adversarial} adversarial cases`);\n    if (roleCounts.boundary !== dataset.boundary_cases.length) throw new Error(`${where} boundary case list disagrees with the composed dataset`);\n    if (roleCounts.adversarial !== dataset.generated_cases.length) throw new Error(`${where} generated case list disagrees with the composed dataset`);\n    const composed = roleCounts.target_failure + roleCounts.prior_success + roleCounts.boundary + roleCounts.adversarial;\n    if (composed !== dataset.cases.length) throw new Error(`${where} dataset roles (${composed}) do not account for its ${dataset.cases.length} cases`);\n    if (dataset.replay_case_ids.length !== datasetCaseIDs.size) throw new Error(`${where} replay manifest carries ${dataset.replay_case_ids.length} ids for ${datasetCaseIDs.size} dataset cases`);\n    for (const datasetCaseID of dataset.replay_case_ids) {\n      if (!datasetCaseIDs.has(datasetCaseID)) throw new Error(`${where} replay manifest case ${datasetCaseID} is not a composed dataset case`);\n    }\n\n    // The guard grader exists exactly when there is a perturbed case to catch a\n    // candidate on; a required grader with no case behind it is decoration.\n    const perturbed = dataset.cases.some((entry) => entry.perturbation !== \"none\");\n    if (perturbed !== item.eval_pack.graders.includes(\"guard_respected\")) {\n      throw new Error(`${where} guard_respected grader ${perturbed ? \"missing for\" : \"declared without\"} perturbed dataset cases`);\n    }\n    for (const proof of item.replay.trial_proofs) {\n      if (!datasetCaseIDs.has(proof.dataset_case_id)) throw new Error(`${where} replay trial ${proof.id} replays a case outside the composed dataset`);\n      for (const arm of [proof.baseline, proof.candidate]) {\n        const graders = arm.grader_results.map((grader) => grader.grader).sort();\n        const required = [...item.eval_pack.graders].sort();","sourceCodeStart":290,"sourceCodeEnd":326,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/packages/shared/contracts/scripts/validate-continuous-improvement.mjs#L290-L326","documentation":"Analogous to the boundary check: the generated_cases array must contain exactly as many entries as the composed dataset has adversarial-role cases. The validator throws when these two lists disagree, since generated_cases is supposed to be the source of the dataset's adversarial cases.","triggerScenarios":"validate-continuous-improvement.mjs computes roleCounts.adversarial from dataset.cases and it differs from dataset.generated_cases.length — generated cases were added/removed without updating the composed cases, or a case's role was changed.","commonSituations":"Hand-editing roles in cases[]; regenerating cases but reusing a stale generated_cases list; merge conflicts that keep one side of each array.","solutions":["Make dataset.generated_cases match the adversarial-role entries in dataset.cases exactly (same count, ideally same entries).","Rebuild the composed dataset from generated_cases/target_failure_cases/prior_success_cases with the canonical composer.","Check for merge conflicts that kept mismatched halves of the two arrays."],"exampleFix":"// before: generated_cases has 2 entries but only 1 adversarial case composed\n// after: derive the list from the composed cases\ndataset.generated_cases = dataset.cases.filter((c) => c.role === \"adversarial\");","handlingStrategy":"validation","validationCode":"const adversarialInCases = dataset.cases.filter((c) => c.role === \"adversarial\");\nif (adversarialInCases.length !== dataset.generated_cases.length)\n  throw new Error(\"generated_cases out of sync with composed cases\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Compose cases[] from generated_cases with a script, never by hand.","Resolve merge conflicts in fixture files by regenerating rather than hand-merging.","Run validation after every fixture edit."],"tags":["fixture-validation","dataset","consistency"],"backgroundTag":"internal-invariant-violation","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"}