JuliusBrussee/caveman · error · Error

representative trace did not run that arm's workflow variant

Error message

${where} representative trace ${trace.analysis_unit_id} did not run that arm's workflow variant

What it means

The validator rejects a representative trace whose analysis_unit_id is not listed in the arm variant's analysis_unit_ids. Even if the unit exists and belongs to the family, the trace claims a run of that arm's workflow variant on that unit; the variant's recorded unit list is the source of truth for which units actually ran it.

Solutions

  1. Choose representative trace units that appear in variant.analysis_unit_ids for that arm, or update the variant's analysis_unit_ids to include the traced unit if it truly ran
  2. Regenerate representative traces from the variants' own analysis_unit_ids lists
  3. Check whether the arm's variant_id was swapped and restore the variant that produced the traced runs

Example fix

// before
"representative_traces": [{ "arm": "alternative", "variant_id": "v-alt", "analysis_unit_id": "unit-42" }]
// v-alt.analysis_unit_ids = ["unit-7","unit-8","unit-9"]
// after
"representative_traces": [{ "arm": "alternative", "variant_id": "v-alt", "analysis_unit_id": "unit-8" }]
Defensive patterns

Strategy: validation

Validate before calling

const variantsByID = new Map(report.workflow_variants.map((v) => [v.id, v]));
for (const item of report.cases) {
  const armVariants = new Map(item.cohort.arms.map((a) => [a.role, variantsByID.get(a.variant_id)]));
  for (const t of item.representative_traces) {
    const v = armVariants.get(t.arm);
    if (v && !v.analysis_unit_ids.includes(t.analysis_unit_id)) {
      throw new Error(`unit ${t.analysis_unit_id} did not run variant ${v.id}`);
    }
  }
}

Type guard

function unitRanVariant(unitId, variant) {
  return variant !== undefined && variant.analysis_unit_ids.includes(unitId);
}

Try / catch

try {
  validateReport(report);
} catch (err) {
  if (err.message.includes("did not run that arm's workflow variant")) {
    console.error('Trace unit not in arm variant analysis_unit_ids; reselect traces.');
    process.exitCode = 1;
  } else throw err;
}

Prevention

When it happens

Trigger: A trace pairs an analysis unit with an arm whose variant did not execute on that unit (unit id missing from variant.analysis_unit_ids) — e.g. after swapping the arm's variant_id, regenerating variants with different unit assignments, or hand-picking trace units that were excluded from that variant's runs.

Common situations: Pointing an arm at a rebuilt variant whose analysis_unit_ids no longer includes the previously traced units; copying traces between cases with different variant assignments; a generator that assigns units to variants but selects representative traces from the whole family.

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/e7674ecaea7bd63a. Report an issue: GitHub.

Appendix: source

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

    for (const arm of item.cohort.arms) {
      const variant = variantsByID.get(arm.variant_id);
      if (!variant) throw new Error(`${where} cohort arm ${arm.role} references a workflow variant that is not in this report`);
      if (variant.task_family_id !== family.id) throw new Error(`${where} cohort arm ${arm.role} uses a variant of another task family`);
      armVariants.set(arm.role, variant);
      comparedUnits += arm.unit_count;
    }
    const excluded = item.cohort.excluded_units.reduce((total, exclusion) => total + exclusion.unit_count, 0);
    if (comparedUnits + excluded !== item.cohort.family_unit_count) {
      throw new Error(`${where} cohort arms (${comparedUnits}) plus exclusions (${excluded}) do not account for its ${item.cohort.family_unit_count} family units`);
    }

    const selectedPerArm = new Map();
    for (const trace of item.representative_traces) {
      const variant = armVariants.get(trace.arm);
      if (!variant || variant.id !== trace.variant_id) throw new Error(`${where} representative trace names a variant that is not that arm's variant`);
      if (!unitsByID.has(trace.analysis_unit_id)) throw new Error(`${where} representative trace ${trace.analysis_unit_id} is not an analysis unit of this report`);
      if (!familyUnits.has(trace.analysis_unit_id)) throw new Error(`${where} representative trace ${trace.analysis_unit_id} is not a member of the cohort's task family`);
      if (!variant.analysis_unit_ids.includes(trace.analysis_unit_id)) throw new Error(`${where} representative trace ${trace.analysis_unit_id} did not run that arm's workflow variant`);
      selectedPerArm.set(trace.arm, (selectedPerArm.get(trace.arm) ?? 0) + 1);
    }
    for (const [arm, count] of selectedPerArm) {
      if (count > 3) throw new Error(`${where} arm ${arm} carries ${count} representative traces, more than three`);
    }

    const slice = item.causal_slice;
    const sliceVariant = variantsByID.get(slice.variant_id);
    if (!sliceVariant) throw new Error(`${where} causal slice references a workflow variant that is not in this report`);
    if (sliceVariant.id !== armVariants.get("baseline").id) throw new Error(`${where} causal slice is not taken from the baseline arm's variant`);
    const sliceNodes = new Set(sliceVariant.nodes.map((node) => node.id));
    if (slice.manifestation_node_id !== "" && !sliceNodes.has(slice.manifestation_node_id)) {
      throw new Error(`${where} manifestation node ${slice.manifestation_node_id} is not a node of variant ${sliceVariant.id}`);
    }
    if (item.diagnosis.manifestation.node_id !== slice.manifestation_node_id) {
      throw new Error(`${where} diagnosis manifestation node disagrees with its causal slice`);
    }
    for (const nodeID of slice.node_chain) {

View on GitHub (pinned to 3ee70a1026)