JuliusBrussee/caveman · error · Error

generated case list disagrees with the composed dataset

Error message

${where} generated case list disagrees with the composed dataset

What it means

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.

Solutions

  1. Make dataset.generated_cases match the adversarial-role entries in dataset.cases exactly (same count, ideally same entries).
  2. Rebuild the composed dataset from generated_cases/target_failure_cases/prior_success_cases with the canonical composer.
  3. Check for merge conflicts that kept mismatched halves of the two arrays.

Example fix

// before: generated_cases has 2 entries but only 1 adversarial case composed
// after: derive the list from the composed cases
dataset.generated_cases = dataset.cases.filter((c) => c.role === "adversarial");
Defensive patterns

Strategy: validation

Validate before calling

const adversarialInCases = dataset.cases.filter((c) => c.role === "adversarial");
if (adversarialInCases.length !== dataset.generated_cases.length)
  throw new Error("generated_cases out of sync with composed cases");

Prevention

When it happens

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

Common situations: Hand-editing roles in cases[]; regenerating cases but reusing a stale generated_cases list; merge conflicts that keep one side of each array.

Understand the failure class

Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.

Related errors


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

Appendix: source

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

    // tests nothing while counting as adversarial coverage.
    const confidenceGuard = item.change_set.applicability.all.some((condition) =>
      condition === "failure_location_confidence >= 0.90" ||
      condition === "symbol_resolution == unique" ||
      condition === "targeted_test_reproduces == true");
    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();

View on GitHub (pinned to 3ee70a1026)