JuliusBrussee/caveman · error · Error
arm carries representative traces, more than three
Error message
${where} arm ${arm} carries ${count} representative traces, more than three What it means
The continuous-improvement report validator enforces that each cohort arm carries at most three representative traces. When a case's representative_traces list contains more than three traces for the same arm (baseline or alternative), the validator throws so reports stay compact and comparable. It is a report-authoring contract, not a runtime failure.
Solutions
- Trim representative_traces per arm to at most 3, keeping the most representative ones
- Fix the report generator to cap per-arm selection at 3 traces
- Verify each trace's `arm` label is not duplicated or mislabeled, inflating one arm's count
Example fix
// before
representative_traces: [t1, t2, t3, t4].map(t => ({...t, arm: 'baseline'}))
// after
representative_traces: [t1, t2, t3].map(t => ({...t, arm: 'baseline'})) Defensive patterns
Strategy: validation
Validate before calling
const perArm = new Map();
for (const t of item.representative_traces) perArm.set(t.arm, (perArm.get(t.arm) ?? 0) + 1);
if ([...perArm.values()].some(c => c > 3)) throw new Error('more than three representative traces in an arm'); Type guard
const hasAtMostThreePerArm = (traces) => {
const counts = {};
for (const t of traces) counts[t.arm] = (counts[t.arm] ?? 0) + 1;
return Object.values(counts).every(c => c <= 3);
}; Try / catch
try { validateReport(report); } catch (e) { if (String(e.message).includes('more than three')) trimTraces(report); else throw e; } Prevention
- Cap per-arm trace sampling at 3 in the report generator
- Assert per-arm counts in CI before committing fixtures
- Deduplicate traces when merging cohorts
When it happens
Trigger: Running `validate-continuous-improvement.mjs` against a report fixture where any single arm has 4+ entries in `case.representative_traces` (counted per `trace.arm` in selectedPerArm).
Common situations: Hand-editing report fixtures and appending traces; a report generator that dumps all traces instead of a sampled subset; merging two cohorts without deduplication.
Understand the failure class
Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.
Related errors
- canonical span
- expected exactly 2 agent conformance fixtures, found
- ${fixtureFiles[index]}…
- no theme relationship reached the shared-analysis-unit…
- no workflow motif recurred across two variants of one task…
AI-assisted analysis of JuliusBrussee/caveman@3ee70a1026 (2026-09-20).
Data as JSON: /api/errors/905f2edbaf240caa.
Report an issue: GitHub.
Appendix: source
Thrown at packages/shared/contracts/scripts/validate-continuous-improvement.mjs:168
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) {
if (!sliceNodes.has(nodeID)) throw new Error(`${where} causal slice node ${nodeID} is not a node of variant ${sliceVariant.id}`);
}
if (slice.manifestation_node_id !== "" && !slice.node_chain.includes(slice.manifestation_node_id)) {
throw new Error(`${where} causal slice omits its own manifestation node`);View on GitHub (pinned to 3ee70a1026)