JuliusBrussee/caveman · error · Error

${where} representative trace ${trace.analysis_unit_id} did

Error message

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

What it means

The strongest of the three trace checks: the unit must be listed in the arm variant's own analysis_unit_ids — the recorded run must actually have executed that arm's workflow variant (validate-continuous-improvement.mjs:164). Family membership alone is not enough: within one family different units ran different variants, and a representative trace must come from one that ran this arm's variant.

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 766dce6b13)

Solutions

  1. Pick a trace unit that appears in the arm variant's analysis_unit_ids.
  2. If the attribution is wrong, fix variant.analysis_unit_ids so it lists the units that actually ran it.
  3. Re-run the validator; errors 609 and 610 for the same trace are fixed by the same edit.

Example fix

// before — unit-code-7 is in wf-build-02's analysis_unit_ids, not wf-build-01's
{ "arm": "baseline", "variant_id": "wf-build-01", "analysis_unit_id": "unit-code-7" }
// after
{ "arm": "baseline", "variant_id": "wf-build-01", "analysis_unit_id": "unit-code-1" }
Defensive patterns

Strategy: validation

Validate before calling

const tracesOutsideArmVariant = (report) => {
  const byID = new Map(report.workflow_variants.map((v) => [v.id, v]));
  return report.cases.flatMap((c) => {
    const armVariant = new Map(c.cohort.arms.map((a) => [a.role, byID.get(a.variant_id)]));
    return c.representative_traces
      .filter((t) => !armVariant.get(t.arm)?.analysis_unit_ids.includes(t.analysis_unit_id))
      .map((t) => `${c.id}:${t.analysis_unit_id}`);
  });
};

Try / catch

try {
  execFileSync(process.execPath, [VALIDATOR, reportPath, spansPath]);
} catch (err) {
  if (/did not run that arm's workflow variant/.test(err.message)) {
    failCI(`trace unit ran a different variant of the family: ${err.message}`);
  } else throw err;
}

Prevention

When it happens

Trigger: The trace cites a unit that ran the alternative variant but is filed under the baseline arm; variant.analysis_unit_ids is stale after runs were re-attributed between variants of the same family; a trace copied between arms of a cohort whose variants share a family.

Common situations: Two variants of one family with overlapping unit pools; re-attributing runs between variants in the generator without refreshing traces; hand-picking an interesting unit without checking which variant executed it.

Related errors


AI-assisted analysis of JuliusBrussee/caveman@766dce6b13 (2026-08-18). Data as JSON: /api/errors/e7674ecaea7bd63a. Report an issue: GitHub.