JuliusBrussee/caveman · error · Error

diagnosis upstream node is not an upstream node of its…

Error message

${where} diagnosis upstream node ${nodeID} is not an upstream node of its causal slice

What it means

The diagnosis's root_cause_hypothesis.upstream_node_ids must name nodes that are genuinely upstream of the manifestation within this slice's node_chain — i.e. present in the chain and not equal to the manifestation node itself. This error means a listed upstream node is either not in the slice's node chain at all, or is the manifestation node (which cannot be its own upstream cause).

Solutions

  1. Replace the offending node ID with the correct upstream node that exists in slice.node_chain.
  2. Remove the manifestation node ID from upstream_node_ids — only strictly-upstream nodes belong there.
  3. Regenerate the diagnosis against the current slice so chain membership and IDs are consistent.

Example fix

// before
"upstream_node_ids": ["parse", "manifestation"]
// after
"upstream_node_ids": ["parse"]
Defensive patterns

Strategy: validation

Validate before calling

const chainSet = new Set(slice.node_chain);
for (const id of item.diagnosis.root_cause_hypothesis.upstream_node_ids) {
  if (!chainSet.has(id) || id === slice.manifestation_node_id) throw new Error(`upstream node ${id} invalid for slice`);
}

Try / catch

try { validateReport(report); } catch (err) { if (String(err.message).includes('is not an upstream node of its causal slice')) { /* fix upstream_node_ids */ } else throw err; }

Prevention

When it happens

Trigger: Running the validator on a report where diagnosis.root_cause_hypothesis.upstream_node_ids contains an ID absent from slice.node_chain, or containing slice.manifestation_node_id.

Common situations: Node IDs renamed in the variant after the diagnosis was written; copying upstream IDs from a different slice's diagnosis; misunderstanding the schema and including the manifestation node as its own cause.

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


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

Appendix: source

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

      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`);
      }
    }

    // A case that proposes nothing must carry nothing: no operator, no eval
    // pack, no replay. Anything else would present an abstention as a proposal.
    if (item.status === "diagnosis_only") {
      if (item.change_set.operator_id !== "" || item.eval_pack.id !== "" || item.replay.status !== "not_run") {
        throw new Error(`${where} is diagnosis-only but carries a change set, eval pack or replay`);
      }
      continue;
    }
    if (item.change_set.case_id !== item.id || item.eval_pack.case_id !== item.id) {
      throw new Error(`${where} change set or eval pack is bound to another case`);
    }

    // The case must investigate the pair its own opportunity named. A cohort
    // built from a differently-derived pair would describe one comparison and
    // measure another.

View on GitHub (pinned to 3ee70a1026)