JuliusBrussee/caveman · error · Error
representative trace is not a member of the cohort's task…
Error message
${where} representative trace ${trace.analysis_unit_id} is not a member of the cohort's task family What it means
The validator rejects a representative trace whose analysis_unit_id exists in the report but is not a member of the cohort's task family (absent from family.analysis_unit_ids). Each cohort case studies one task family, so its traces must come from units belonging to that family; this catches traces pulled from units of a different family.
Solutions
- Replace the trace's analysis_unit_id with a unit that belongs to the cohort's task family (is in family.analysis_unit_ids), or move the unit into that family in the fixture
- Update cohort.task_family_id if the traces genuinely belong to a different family
- Regenerate the fixture from the current dataset snapshot so family membership and traces agree
Example fix
// before
"cohort": { "task_family_id": "family-a" },
"representative_traces": [{ "arm": "alternative", "variant_id": "v2", "analysis_unit_id": "unit-b1" }]
// unit-b1 belongs to family-b
// after
"representative_traces": [{ "arm": "alternative", "variant_id": "v2", "analysis_unit_id": "unit-a3" }]
// unit-a3 is in family-a.analysis_unit_ids Defensive patterns
Strategy: validation
Validate before calling
const familiesByID = new Map(report.task_families.map((f) => [f.id, f]));
for (const item of report.cases) {
const famUnits = new Set(familiesByID.get(item.cohort.task_family_id).analysis_unit_ids);
for (const t of item.representative_traces) {
if (!famUnits.has(t.analysis_unit_id)) {
throw new Error(`trace ${t.analysis_unit_id} not in family ${item.cohort.task_family_id}`);
}
}
} Type guard
function unitInFamily(unitId, cohort, familiesByID) {
const family = familiesByID.get(cohort.task_family_id);
return family !== undefined && family.analysis_unit_ids.includes(unitId);
} Try / catch
try {
validateReport(report);
} catch (err) {
if (err.message.includes("not a member of the cohort's task family")) {
console.error('Trace unit belongs to a different task family; regenerate the case.');
process.exitCode = 1;
} else throw err;
} Prevention
- When re-grouping analysis units into families, regenerate all cohort cases from scratch
- Never copy cases between report fixtures with different family membership
- Derive cohort.task_family_id from the traces' units instead of hardcoding it
When it happens
Trigger: A representative trace's analysis_unit_id is in report.analysis_units but not in task_families[cohort.task_family_id].analysis_unit_ids — e.g. after reassigning units between task families, or copying a case from a fixture with different family membership.
Common situations: Re-grouping analysis units into new task families without regenerating cases; a case's cohort.task_family_id changed but traces still reference old-family units; fixtures merged from different dataset snapshots.
Understand the failure class
Background: Record Not Found Errors: "not found", RecordNotFound, and "was not found" — what they mean and how to fix them — this error's family across 28 libraries.
Related errors
- representative trace is not an analysis unit of this report
- 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/2510172331237de1.
Report an issue: GitHub.
Appendix: source
Thrown at packages/shared/contracts/scripts/validate-continuous-improvement.mjs:163
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) {
throw new Error(`${where} diagnosis manifestation node disagrees with its causal slice`);
}View on GitHub (pinned to 3ee70a1026)