{"record":{"id":"22cc651e15ceb533","repo":"JuliusBrussee/caveman","slug":"where-replay-manifest-case-datasetcaseid-is","errorCode":null,"errorMessage":"${where} replay manifest case ${datasetCaseID} is not a composed dataset case","messagePattern":"(.+?) replay manifest case (.+?) is not a composed dataset case","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/shared/contracts/scripts/validate-continuous-improvement.mjs","lineNumber":313,"sourceCode":"    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();\n        if (graders.join(\",\") !== required.join(\",\")) {\n          throw new Error(`${where} replay trial ${proof.id} graded ${graders.join(\",\")}, want exactly ${required.join(\",\")}`);\n        }\n      }\n    }","sourceCodeStart":295,"sourceCodeEnd":331,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/packages/shared/contracts/scripts/validate-continuous-improvement.mjs#L295-L331","documentation":"Every id in dataset.replay_case_ids must correspond to an actual composed dataset case. The validator throws when the manifest references an id that does not exist in datasetCaseIDs, i.e. a dangling replay reference to a case that was removed, renamed, or never composed.","triggerScenarios":"Iterating dataset.replay_case_ids, validate-continuous-improvement.mjs hits an id absent from datasetCaseIDs — typically after case ids were renamed or a case deleted while the manifest kept the old id.","commonSituations":"Renaming case ids in a refactor; reverting dataset.cases in git while keeping a newer replay_case_ids; a typo in one manifest id.","solutions":["Replace the stale id in replay_case_ids with the current id of the intended case.","Rebuild replay_case_ids from dataset.cases.map(c => c.id) to eliminate all dangling references.","Diff the fixture's cases and replay_case_ids against the last validated version to find the rename."],"exampleFix":"// before: replay_case_ids contains \"case-3-old\"\n// after: ids renamed\ndataset.replay_case_ids = dataset.replay_case_ids.map((id) =>\n  id === \"case-3-old\" ? \"case-3\" : id,\n);","handlingStrategy":"validation","validationCode":"const idSet = new Set(dataset.cases.map((c) => c.id));\nconst dangling = dataset.replay_case_ids.filter((id) => !idSet.has(id));\nif (dangling.length) throw new Error(`dangling replay ids: ${dangling.join(\", \")}`);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Rename case ids with a project-wide search including replay_case_ids.","Rebuild the manifest from cases after any id change.","Run the validator before committing."],"tags":["fixture-validation","replay-manifest","dangling-reference"],"backgroundTag":"record-not-found","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"}