JuliusBrussee/caveman · error · Error

replay manifest case is not a composed dataset case

Error message

${where} replay manifest case ${datasetCaseID} is not a composed dataset case

What it means

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.

Solutions

  1. Replace the stale id in replay_case_ids with the current id of the intended case.
  2. Rebuild replay_case_ids from dataset.cases.map(c => c.id) to eliminate all dangling references.
  3. Diff the fixture's cases and replay_case_ids against the last validated version to find the rename.

Example fix

// before: replay_case_ids contains "case-3-old"
// after: ids renamed
dataset.replay_case_ids = dataset.replay_case_ids.map((id) =>
  id === "case-3-old" ? "case-3" : id,
);
Defensive patterns

Strategy: validation

Validate before calling

const idSet = new Set(dataset.cases.map((c) => c.id));
const dangling = dataset.replay_case_ids.filter((id) => !idSet.has(id));
if (dangling.length) throw new Error(`dangling replay ids: ${dangling.join(", ")}`);

Prevention

When it happens

Trigger: 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.

Common situations: Renaming case ids in a refactor; reverting dataset.cases in git while keeping a newer replay_case_ids; a typo in one manifest id.

Understand the failure class

Background: Record Not Found Errors: "not found", RecordNotFound, and "was not found" — what they mean and how to fix them — this error's family across 28 libraries.

Related errors


AI-assisted analysis of JuliusBrussee/caveman@3ee70a1026 (2026-09-20). Data as JSON: /api/errors/22cc651e15ceb533. Report an issue: GitHub.

Appendix: source

Thrown at packages/shared/contracts/scripts/validate-continuous-improvement.mjs:313

    const perturbations = new Set(dataset.cases.map((entry) => entry.perturbation));
    for (const [perturbation, label] of [["guard_threshold_boundary", "boundary"], ["stale_input", "stale-input"]]) {
      if (perturbations.has(perturbation) !== confidenceGuard) {
        throw new Error(`${where} ${confidenceGuard ? "omits" : "generated"} a ${label} case ${confidenceGuard ? "for" : "against"} a change set that ${confidenceGuard ? "declares" : "declares no"} confidence guard`);
      }
    }
    const expectedTargets = Math.min(4, dataset.target_failure_cases.length);
    const expectedPriors = Math.min(2, dataset.prior_success_cases.length);
    if (roleCounts.target_failure !== expectedTargets) throw new Error(`${where} dataset carries ${roleCounts.target_failure} target-failure cases, want ${expectedTargets}`);
    if (roleCounts.prior_success !== expectedPriors) throw new Error(`${where} dataset carries ${roleCounts.prior_success} prior-success cases, want ${expectedPriors}`);
    if (roleCounts.boundary > 1) throw new Error(`${where} dataset carries ${roleCounts.boundary} boundary cases, want at most one`);
    if (roleCounts.adversarial > (confidenceGuard ? 2 : 1)) throw new Error(`${where} dataset carries ${roleCounts.adversarial} adversarial cases`);
    if (roleCounts.boundary !== dataset.boundary_cases.length) throw new Error(`${where} boundary case list disagrees with the composed dataset`);
    if (roleCounts.adversarial !== dataset.generated_cases.length) throw new Error(`${where} generated case list disagrees with the composed dataset`);
    const composed = roleCounts.target_failure + roleCounts.prior_success + roleCounts.boundary + roleCounts.adversarial;
    if (composed !== dataset.cases.length) throw new Error(`${where} dataset roles (${composed}) do not account for its ${dataset.cases.length} cases`);
    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`);
    for (const datasetCaseID of dataset.replay_case_ids) {
      if (!datasetCaseIDs.has(datasetCaseID)) throw new Error(`${where} replay manifest case ${datasetCaseID} is not a composed dataset case`);
    }

    // The guard grader exists exactly when there is a perturbed case to catch a
    // candidate on; a required grader with no case behind it is decoration.
    const perturbed = dataset.cases.some((entry) => entry.perturbation !== "none");
    if (perturbed !== item.eval_pack.graders.includes("guard_respected")) {
      throw new Error(`${where} guard_respected grader ${perturbed ? "missing for" : "declared without"} perturbed dataset cases`);
    }
    for (const proof of item.replay.trial_proofs) {
      if (!datasetCaseIDs.has(proof.dataset_case_id)) throw new Error(`${where} replay trial ${proof.id} replays a case outside the composed dataset`);
      for (const arm of [proof.baseline, proof.candidate]) {
        const graders = arm.grader_results.map((grader) => grader.grader).sort();
        const required = [...item.eval_pack.graders].sort();
        if (graders.join(",") !== required.join(",")) {
          throw new Error(`${where} replay trial ${proof.id} graded ${graders.join(",")}, want exactly ${required.join(",")}`);
        }
      }
    }

View on GitHub (pinned to 3ee70a1026)