JuliusBrussee/caveman · error · Error
representative trace is not an analysis unit of this report
Error message
${where} representative trace ${trace.analysis_unit_id} is not an analysis unit of this report What it means
The validator rejects a representative trace whose analysis_unit_id does not appear in report.analysis_units. Every trace must reference an analysis unit that actually exists in the report's unit inventory; a dangling id means the fixture references a unit that was never registered or was deleted/renamed.
Solutions
- Add the missing unit to report.analysis_units or correct the trace's analysis_unit_id to an existing unit id
- Regenerate the report fixture so traces and analysis_units come from the same snapshot
- Cross-check every representative trace's analysis_unit_id against the analysis_units id set before validating
Example fix
// before
"representative_traces": [{ "arm": "baseline", "variant_id": "v1", "analysis_unit_id": "unit-99" }]
// analysis_units lacks unit-99
// after
"representative_traces": [{ "arm": "baseline", "variant_id": "v1", "analysis_unit_id": "unit-07" }]
// unit-07 exists in analysis_units Defensive patterns
Strategy: validation
Validate before calling
const unitIds = new Set(report.analysis_units.map((u) => u.id));
for (const item of report.cases) {
for (const t of item.representative_traces) {
if (!unitIds.has(t.analysis_unit_id)) {
throw new Error(`trace references unknown analysis unit ${t.analysis_unit_id}`);
}
}
} Type guard
function unitExists(unitId, report) {
return report.analysis_units.some((u) => u.id === unitId);
} Try / catch
try {
validateReport(report);
} catch (err) {
if (err.message.includes('is not an analysis unit of this report')) {
console.error('Dangling analysis_unit_id in a representative trace.');
process.exitCode = 1;
} else throw err;
} Prevention
- Rename unit ids with a single mechanical find/replace across the whole fixture file
- Validate referential integrity locally before committing fixture changes
- Keep traces and analysis_units generated from the same snapshot
When it happens
Trigger: A representative trace carries an analysis_unit_id that is absent from the report's analysis_units array — typically after deleting or re-id-ing analysis units without updating traces, or referencing a unit from a different report fixture.
Common situations: Hand-renaming unit ids in one section of the fixture but not the traces; copying a case into another report whose analysis_units list differs; a generator bug emitting stale unit ids after a dataset refresh.
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 a member of the cohort's task…
- 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/db12aaeb99b61b9f.
Report an issue: GitHub.
Appendix: source
Thrown at packages/shared/contracts/scripts/validate-continuous-improvement.mjs:162
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) {
throw new Error(`${where} diagnosis manifestation node disagrees with its causal slice`);View on GitHub (pinned to 3ee70a1026)