JuliusBrussee/caveman · error · Error

hard chain edge -> names a node outside variant

Error message

${where} hard chain edge ${edge.from}->${edge.to} names a node outside variant ${sliceVariant.id}

What it means

Both endpoints of every hard-chain edge must be nodes of the slice's variant. The validator checks `sliceNodes.has(edge.from) && sliceNodes.has(edge.to)` and throws if either endpoint references a node outside the variant graph.

Solutions

  1. Remove the cross-variant edge from hard_edges
  2. Inline the sub-workflow's nodes into the variant or remap the edge to in-variant node ids
  3. Regenerate the slice from the current variant graph

Example fix

// before
hard_edges: [{from:'shared_init',to:'node_2',type:'data',strength:'hard',evidence_refs:['e1']}]
// after
hard_edges: [{from:'node_1',to:'node_2',type:'data',strength:'hard',evidence_refs:['e1']}]
Defensive patterns

Strategy: validation

Validate before calling

const nodeIds = new Set(variant.nodes.map(n => n.id));
const bad = slice.hard_edges.filter(e => !nodeIds.has(e.from) || !nodeIds.has(e.to));
if (bad.length) throw new Error(`edges naming nodes outside variant: ${bad.map(e => e.from + '->' + e.to)}`);

Type guard

const edgesInVariant = (slice, variant) => { const ids = new Set(variant.nodes.map(n => n.id)); return slice.hard_edges.every(e => ids.has(e.from) && ids.has(e.to)); };

Try / catch

try { validateCase(item); } catch (e) { if (String(e.message).includes('names a node outside variant')) inlineSubworkflowNodes(item); else throw e; }

Prevention

When it happens

Trigger: A hard edge in `slice.hard_edges` has a `from` or `to` id not present among `sliceVariant.nodes`.

Common situations: Cross-variant edge copied into the slice; node ids from a shared/sub-workflow not inlined into this variant; stale ids after graph refactor.

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/e950076f4d729e01. Report an issue: GitHub.

Appendix: source

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

    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}`);
      if (!sliceNodes.has(edge.from) || !sliceNodes.has(edge.to)) throw new Error(`${where} hard chain edge ${edge.from}->${edge.to} names a node outside variant ${sliceVariant.id}`);
      if (!slice.node_chain.includes(edge.from) || !slice.node_chain.includes(edge.to)) {
        throw new Error(`${where} hard chain edge ${edge.from}->${edge.to} is outside the slice's node chain`);
      }
      const source = variantEdges.get(`${edge.from}${edge.to}${edge.type}`);
      if (!source || source.strength !== "hard") throw new Error(`${where} hard chain edge ${edge.from}->${edge.to} is not a hard edge of variant ${sliceVariant.id}`);
    }
    for (const edge of slice.unproven_adjacencies) {
      // The whole point of the separate list: nothing in it may read as proven.
      if (provenDependency(edge)) throw new Error(`${where} unproven adjacency ${edge.from}->${edge.to} is in fact a proven hard dependency`);
      if (slice.hard_edges.some((hard) => hard.from === edge.from && hard.to === edge.to && hard.type === edge.type)) {
        throw new Error(`${where} adjacency ${edge.from}->${edge.to} appears in both the hard chain and the unproven list`);
      }
    }
    const upstream = new Set(item.diagnosis.root_cause_hypothesis.upstream_node_ids);
    for (const nodeID of upstream) {
      if (!slice.node_chain.includes(nodeID) || nodeID === slice.manifestation_node_id) {
        throw new Error(`${where} diagnosis upstream node ${nodeID} is not an upstream node of its causal slice`);
      }

View on GitHub (pinned to 3ee70a1026)