JuliusBrussee/caveman · error · Error
support run count !=
Error message
${where} support run count ${motif.support_run_count} != ${runs} What it means
support_run_count must equal the sum of eligible_runs over the motif's supporting variants. The validator accumulates runs during iteration and throws when the stored count diverges, ensuring the motif's run totals are re-derivable from the report's variants.
Solutions
- Set support_run_count to the sum of eligible_runs across variant_ids.
- Regenerate the report so support_run_count is recomputed from variants.
- Fix eligible_runs values if the variant counts are the stale fields.
Example fix
// before variants eligible_runs 10 + 15, motif.support_run_count = 20 // after motif.support_run_count = 25
Defensive patterns
Strategy: validation
Validate before calling
const runs = motif.variant_ids.reduce((n, id) => n + report.workflow_variants.find(v => v.id === id).eligible_runs, 0);
if (motif.support_run_count !== runs) throw new Error(`motif ${motif.id}: support_run_count must be ${runs}`); Type guard
const runCountConsistent = (motif, report) => motif.support_run_count === motif.variant_ids.reduce((n, id) => n + (report.workflow_variants.find(v => v.id === id)?.eligible_runs ?? 0), 0);
Try / catch
try { validateContinuousImprovement(report); } catch (e) { if (String(e.message).includes('support run count')) { console.error('Recompute support_run_count from variant eligible_runs'); } else throw e; } Prevention
- Sum eligible_runs programmatically when writing support_run_count
- Recompute all motif aggregates whenever variant run counts change
- Keep aggregates derived, never hand-maintained
When it happens
Trigger: motif.support_run_count !== sum(variant.eligible_runs for variantID in motif.variant_ids) — typically after editing variant eligible_runs or the motif's variant list without recomputing the total.
Common situations: Updating variant run counts during report regeneration; adding/removing supporting variants without recomputing; hand-rounded or stale totals in fixtures.
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
- carries more shared unit ids than its shared unit count
- support variant count disagrees with its variant ids
- operations are not a contiguous subsequence of variant 's…
- probability_a_given_b !=
- probability_b_given_a !=
AI-assisted analysis of JuliusBrussee/caveman@3ee70a1026 (2026-09-20).
Data as JSON: /api/errors/681906fa727565ef.
Report an issue: GitHub.
Appendix: source
Thrown at packages/shared/contracts/scripts/validate-continuous-improvement.mjs:124
const variantsByID = new Map(report.workflow_variants.map((variant) => [variant.id, variant]));
const familyIDs = new Set(report.task_families.map((family) => family.id));
for (const motif of report.motifs) {
const where = `report fixture ${reportPaths[index]}: motif ${motif.id}`;
if (!familyIDs.has(motif.task_family_id)) throw new Error(`${where} references a task family that is not in this report`);
if (motif.support_variant_count !== motif.variant_ids.length) throw new Error(`${where} support variant count disagrees with its variant ids`);
let runs = 0;
let weighted = 0;
for (const variantID of motif.variant_ids) {
const variant = variantsByID.get(variantID);
if (!variant) throw new Error(`${where} references workflow variant ${variantID} that is not in this report`);
if (variant.task_family_id !== motif.task_family_id) throw new Error(`${where} supporting variant ${variantID} belongs to another task family`);
if (!contiguouslyContains(variant.signature, motif.operations)) {
throw new Error(`${where} operations are not a contiguous subsequence of variant ${variantID}'s signature`);
}
runs += variant.eligible_runs;
weighted += (motif.operations.length / variant.signature.length) * variant.eligible_runs;
}
if (motif.support_run_count !== runs) throw new Error(`${where} support run count ${motif.support_run_count} != ${runs}`);
const expectedShare = runs > 0 ? weighted / runs : 0;
if (Math.abs(motif.structural_cost_share - expectedShare) > 1e-6) {
throw new Error(`${where} structural_cost_share ${motif.structural_cost_share} != ${expectedShare}`);
}
}
motifCount += report.motifs.length;
// The causal investigation of every case: the cohort's arms, the traces it
// selected from them, and the backward hard-dependency slice.
const unitsByID = new Map(report.analysis_units.map((unit) => [unit.id, unit]));
const familiesByID = new Map(report.task_families.map((family) => [family.id, family]));
for (const item of report.cases) {
const where = `report fixture ${reportPaths[index]}: case ${item.id}`;
const family = familiesByID.get(item.cohort.task_family_id);
if (!family) throw new Error(`${where} cohort references a task family that is not in this report`);
const familyUnits = new Set(family.analysis_unit_ids);
if (item.cohort.family_unit_count !== familyUnits.size) throw new Error(`${where} cohort family unit count disagrees with the task family`);
const roles = item.cohort.arms.map((arm) => arm.role);View on GitHub (pinned to 3ee70a1026)