JuliusBrussee/caveman · error · Error
representative trace names a variant that is not that arm's…
Error message
${where} representative trace names a variant that is not that arm's variant What it means
This validator error fires when a representative trace's arm/variant pair is inconsistent with the cohort's declared arms. The validator builds armVariants (role -> variant) from cohort.arms, then for each trace requires that trace.variant_id equals the variant registered for trace.arm. A missing arm lookup or a mismatched variant id means the trace claims a workflow variant that its own arm does not use.
Solutions
- Set each trace's arm and variant_id to match cohort.arms exactly (trace.arm resolves to an arm whose arm.variant_id === trace.variant_id)
- Regenerate representative traces from the cohort's current arms rather than copying them from an older fixture
- Grep the fixture for the variant id to find traces still pointing at a retired variant
- Verify arm role strings are exactly baseline and alternative with no casing or spacing differences
Example fix
// before
"arms": [{ "role": "baseline", "variant_id": "v-new" }],
"representative_traces": [
{ "arm": "baseline", "variant_id": "v-old", "analysis_unit_id": "u1" }
]
// after
"arms": [{ "role": "baseline", "variant_id": "v-new" }],
"representative_traces": [
{ "arm": "baseline", "variant_id": "v-new", "analysis_unit_id": "u1" }
] Defensive patterns
Strategy: validation
Validate before calling
const armVariants = new Map(cohort.arms.map((a) => [a.role, a.variant_id]));
for (const t of item.representative_traces) {
if (armVariants.get(t.arm) !== t.variant_id) {
throw new Error(`trace ${t.analysis_unit_id}: arm ${t.arm} does not use variant ${t.variant_id}`);
}
} Type guard
function traceMatchesArms(trace, arms) {
const arm = arms.find((a) => a.role === trace.arm);
return arm !== undefined && arm.variant_id === trace.variant_id;
} Try / catch
try {
validateReport(report);
} catch (err) {
if (err.message.includes("not that arm's variant")) {
console.error('Trace arm/variant mismatch; re-derive traces from cohort.arms.');
process.exitCode = 1;
} else throw err;
} Prevention
- When swapping an arm's variant_id, update or regenerate all representative traces in the same change
- Keep arm role strings canonical (baseline/alternative) and avoid manual renames
- Copy cases only via the generator, never by hand-editing trace blocks
When it happens
Trigger: A representative trace references an arm name that is not one of the cohort arms (variant lookup returns undefined) or carries a variant_id that differs from the variant assigned to that arm in cohort.arms — e.g. after renaming arm roles, swapping a variant id, or copying traces between cases.
Common situations: Hand-editing arm role strings ('control' vs 'baseline'); pointing an arm at a new variant id and forgetting to update existing representative traces; duplicating a case and leaving traces from the original cohort's variants; typos in trace.arm so armVariants.get returns undefined.
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
- representative trace did not run that arm's workflow variant
- canonical span
- expected exactly 2 agent conformance fixtures, found
- ${fixtureFiles[index]}…
- no theme relationship reached the shared-analysis-unit…
AI-assisted analysis of JuliusBrussee/caveman@3ee70a1026 (2026-09-20).
Data as JSON: /api/errors/b4ee4fa07b661e5d.
Report an issue: GitHub.
Appendix: source
Thrown at packages/shared/contracts/scripts/validate-continuous-improvement.mjs:161
if (roles.join(",") !== "baseline,alternative") throw new Error(`${where} cohort arms are not baseline then alternative`);
const armVariants = new Map();
let comparedUnits = 0;
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) {View on GitHub (pinned to 3ee70a1026)