JuliusBrussee/caveman · error · Error

change set or eval pack is bound to another case

Error message

${where} change set or eval pack is bound to another case

What it means

Each improvement case's change_set and eval_pack carry a case_id that must point back at the case itself (item.id). This error means one of them references a different case, so the proposal or evaluation would be attributed to the wrong investigation. The validator throws to keep every artifact bound to exactly one case.

Solutions

  1. Set change_set.case_id and eval_pack.case_id to the owning case's item.id.
  2. If the artifacts intentionally belong to another case, move them to that case's record instead of embedding them here.
  3. When cloning cases, rewrite all embedded *_case_id fields in the same step.

Example fix

// before
{ "id": "case-7", "change_set": { "case_id": "case-6" } }
// after
{ "id": "case-7", "change_set": { "case_id": "case-7" } }
Defensive patterns

Strategy: validation

Validate before calling

for (const item of report.cases) {
  if (item.status === 'diagnosis_only') continue;
  if (item.change_set.case_id !== item.id || item.eval_pack.case_id !== item.id) throw new Error(`case ${item.id}: embedded case_id mismatch`);
}

Try / catch

try { validateReport(report); } catch (err) { if (String(err.message).includes('bound to another case')) { /* rewrite embedded case_id fields */ } else throw err; }

Prevention

When it happens

Trigger: Running the validator on a report where change_set.case_id or eval_pack.case_id differs from item.id for any non-diagnosis_only case.

Common situations: Duplicating a case and editing its id but not the embedded change_set/eval_pack case_ids; copying an eval_pack from a sibling case; automated case cloning with incomplete field rewriting.

Related errors


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

Appendix: source

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

      }
    }
    const upstream = new Set(item.diagnosis.root_cause_hypothesis.upstream_node_ids);
    for (const nodeID of upstream) {
      if (!slice.node_chain.includes(nodeID) || nodeID === slice.manifestation_node_id) {
        throw new Error(`${where} diagnosis upstream node ${nodeID} is not an upstream node of its causal slice`);
      }
    }

    // A case that proposes nothing must carry nothing: no operator, no eval
    // pack, no replay. Anything else would present an abstention as a proposal.
    if (item.status === "diagnosis_only") {
      if (item.change_set.operator_id !== "" || item.eval_pack.id !== "" || item.replay.status !== "not_run") {
        throw new Error(`${where} is diagnosis-only but carries a change set, eval pack or replay`);
      }
      continue;
    }
    if (item.change_set.case_id !== item.id || item.eval_pack.case_id !== item.id) {
      throw new Error(`${where} change set or eval pack is bound to another case`);
    }

    // The case must investigate the pair its own opportunity named. A cohort
    // built from a differently-derived pair would describe one comparison and
    // measure another.
    const source = report.opportunities.find((opportunity) => opportunity.id === item.opportunity_id);
    if (!source) throw new Error(`${where} names an opportunity that is not in this report`);
    if (armVariants.get("baseline").id !== source.current_variant_id || armVariants.get("alternative").id !== source.alternative_variant_id) {
      throw new Error(`${where} cohort arms (${armVariants.get("baseline").id}/${armVariants.get("alternative").id}) are not the variants opportunity ${source.id} named`);
    }

    // Every required grader is one the recorded interpreter actually computes.
    // `json_schema` is deliberately absent: over a typed interpreter result it
    // could only assert that a hash is non-empty, which is a grader that cannot
    // fail and therefore inflates how much a replay was checked.
    const knownGraders = new Set(["exact_match", "tool_order", "tool_count", "guard_respected"]);
    for (const grader of item.eval_pack.graders) {
      if (!knownGraders.has(grader)) throw new Error(`${where} requires grader ${grader}, which the recorded interpreter does not compute`);

View on GitHub (pinned to 3ee70a1026)