JuliusBrussee/caveman · error · Error

references workflow variant that is not in this report

Error message

${where} references workflow variant ${variantID} that is not in this report

What it means

Each variant id listed in a motif's variant_ids must exist in the same report's workflow_variants. The validator builds a map of variant ids and throws when a motif references a variant the report does not carry, enforcing intra-report referential integrity.

Solutions

  1. Remove or correct the stale variantID in the motif's variant_ids.
  2. Regenerate the report so motifs and variants stay in sync.
  3. Re-add the missing workflow variant if it should be present.

Example fix

// before
{ "variant_ids": ["v1", "v-deleted"] }
// after
{ "variant_ids": ["v1"] }
Defensive patterns

Strategy: validation

Validate before calling

const variantIDs = new Set(report.workflow_variants.map(v => v.id));
for (const m of report.motifs) for (const id of m.variant_ids) if (!variantIDs.has(id)) throw new Error(`motif ${m.id}: unknown variant ${id}`);

Type guard

const allVariantsExist = (motif, report) => motif.variant_ids.every(id => report.workflow_variants.some(v => v.id === id));

Try / catch

try { validateContinuousImprovement(report); } catch (e) { if (String(e.message).includes('not in this report')) { console.error('Remove stale variant ids or regenerate the report'); } else throw e; }

Prevention

When it happens

Trigger: A motif lists a variantID absent from report.workflow_variants — a typo, a variant deleted from the report, or a motif copied from another report fixture.

Common situations: Pruning variants during report regeneration while motifs still reference them; renaming variant ids; cross-report fixture copy-paste.

Understand the failure class

Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.

Related errors


AI-assisted analysis of JuliusBrussee/caveman@3ee70a1026 (2026-09-20). Data as JSON: /api/errors/f88da5c4ea54c855. Report an issue: GitHub.

Appendix: source

Thrown at packages/shared/contracts/scripts/validate-continuous-improvement.mjs:116

    if (Math.abs(relationship.probability_a_given_b - expectedAGivenB) > 1e-9) {
      throw new Error(`${where} probability_a_given_b ${relationship.probability_a_given_b} != ${expectedAGivenB}`);
    }
  }
  relationshipCount += report.relationships.length;

  // A motif is a structural count over variants this report carries, so every
  // part of it must be re-derivable from those variants.
  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]));

View on GitHub (pinned to 3ee70a1026)