JuliusBrussee/caveman · error · Error

causal slice references a workflow variant that is not in…

Error message

${where} causal slice references a workflow variant that is not in this report

What it means

Every case's causal_slice must reference a workflow variant that exists in the report's variant registry (`variantsByID`). If `slice.variant_id` does not resolve, the slice cannot be checked against any variant's nodes/edges, so validation fails fast with this error.

Solutions

  1. Correct slice.variant_id to match a variant id present in the report
  2. Add the referenced workflow variant to the report
  3. Regenerate the causal slice from a variant that ships in this report

Example fix

// before
causal_slice: { variant_id: 'variant-old-refactor', ... }
// after
causal_slice: { variant_id: 'variant-baseline-v2', ... }
Defensive patterns

Strategy: validation

Validate before calling

if (!report.workflow_variants.some(v => v.id === slice.variant_id)) throw new Error('slice variant missing from report');

Type guard

const sliceVariantExists = (slice, variants) => variants.some(v => v.id === slice.variant_id);

Try / catch

try { validateCase(item); } catch (e) { if (String(e.message).includes('not in this report')) remapSliceVariant(item); else throw e; }

Prevention

When it happens

Trigger: `item.causal_slice.variant_id` is not a key of the report's workflow-variants map when running the validator.

Common situations: Typo in variant_id; slice copied from another report; variant deleted from the report after the slice was authored.

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


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

Appendix: source

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

      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`);
    }
    const provenDependency = (edge) => edge.strength === "hard" && (edge.type === "data" || edge.type === "control") && edge.evidence_refs.length > 0;
    const variantEdges = new Map(sliceVariant.edges.map((edge) => [`${edge.from}${edge.to}${edge.type}`, edge]));
    for (const edge of slice.hard_edges) {
      if (!provenDependency(edge)) throw new Error(`${where} hard chain carries an unproven edge ${edge.from}->${edge.to}`);

View on GitHub (pinned to 3ee70a1026)