JuliusBrussee/caveman · error · Error

cohort arms ( / ) are not the variants opportunity named

Error message

${where} cohort arms (${armVariants.get("baseline").id}/${armVariants.get("alternative").id}) are not the variants opportunity ${source.id} named

What it means

A case's cohort arms must be exactly the variant pair its source opportunity names: the "baseline" arm must be source.current_variant_id and the "alternative" arm must be source.alternative_variant_id. This error means the cohort was built from a different variant pair, so the case would describe one comparison but measure another.

Solutions

  1. Rebuild the cohort so its baseline arm is source.current_variant_id and its alternative arm is source.alternative_variant_id.
  2. If the intended pair differs, update the opportunity itself to name the pair the cohort actually uses.
  3. Derive cohort arms programmatically from the opportunity record instead of hard-coding variant ids.

Example fix

// before
arms: { baseline: "variant-old", alternative: "variant-b" } // opportunity names variant-a
// after
arms: { baseline: source.current_variant_id, alternative: source.alternative_variant_id }
Defensive patterns

Strategy: validation

Validate before calling

const source = report.opportunities.find(o => o.id === item.opportunity_id);
if (armVariants.get('baseline').id !== source.current_variant_id || armVariants.get('alternative').id !== source.alternative_variant_id) {
  throw new Error(`cohort arms mismatch for opportunity ${source.id}`);
}

Try / catch

try { validateReport(report); } catch (err) { if (String(err.message).includes('are not the variants opportunity')) { /* rebuild cohort from source opportunity */ } else throw err; }

Prevention

When it happens

Trigger: Running the validator on a report where armVariants.get("baseline").id !== source.current_variant_id or armVariants.get("alternative").id !== source.alternative_variant_id for the case's resolved opportunity.

Common situations: Cohort derivation using stale or differently-derived variant ids after the opportunity was regenerated; swapping baseline/alternative; building the cohort from a hard-coded variant pair.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


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

Appendix: source

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

    // 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`);
    }

    // Every dataset case — recorded or generated — must name a real analysis
    // unit of this case's own task family, and its generator and perturbation
    // must agree. A generated case whose source unit cannot be resolved would be
    // invented evidence wearing an adversarial label.
    const dataset = item.eval_pack.dataset;
    const generatorPerturbation = new Map([
      ["recorded_case.v1", "none"],

View on GitHub (pinned to 3ee70a1026)