{"record":{"id":"3e6c0ac4fb9a736f","repo":"JuliusBrussee/caveman","slug":"where-diagnosis-upstream-node-nodeid-is-not","errorCode":null,"errorMessage":"${where} diagnosis upstream node ${nodeID} is not an upstream node of its causal slice","messagePattern":"(.+?) diagnosis upstream node (.+?) is not an upstream node of its causal slice","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/shared/contracts/scripts/validate-continuous-improvement.mjs","lineNumber":209,"sourceCode":"      if (!provenDependency(edge)) throw new Error(`${where} hard chain carries an unproven edge ${edge.from}->${edge.to}`);\n      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}`);\n      if (!slice.node_chain.includes(edge.from) || !slice.node_chain.includes(edge.to)) {\n        throw new Error(`${where} hard chain edge ${edge.from}->${edge.to} is outside the slice's node chain`);\n      }\n      const source = variantEdges.get(`${edge.from}\u0000${edge.to}\u0000${edge.type}`);\n      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}`);\n    }\n    for (const edge of slice.unproven_adjacencies) {\n      // The whole point of the separate list: nothing in it may read as proven.\n      if (provenDependency(edge)) throw new Error(`${where} unproven adjacency ${edge.from}->${edge.to} is in fact a proven hard dependency`);\n      if (slice.hard_edges.some((hard) => hard.from === edge.from && hard.to === edge.to && hard.type === edge.type)) {\n        throw new Error(`${where} adjacency ${edge.from}->${edge.to} appears in both the hard chain and the unproven list`);\n      }\n    }\n    const upstream = new Set(item.diagnosis.root_cause_hypothesis.upstream_node_ids);\n    for (const nodeID of upstream) {\n      if (!slice.node_chain.includes(nodeID) || nodeID === slice.manifestation_node_id) {\n        throw new Error(`${where} diagnosis upstream node ${nodeID} is not an upstream node of its causal slice`);\n      }\n    }\n\n    // A case that proposes nothing must carry nothing: no operator, no eval\n    // pack, no replay. Anything else would present an abstention as a proposal.\n    if (item.status === \"diagnosis_only\") {\n      if (item.change_set.operator_id !== \"\" || item.eval_pack.id !== \"\" || item.replay.status !== \"not_run\") {\n        throw new Error(`${where} is diagnosis-only but carries a change set, eval pack or replay`);\n      }\n      continue;\n    }\n    if (item.change_set.case_id !== item.id || item.eval_pack.case_id !== item.id) {\n      throw new Error(`${where} change set or eval pack is bound to another case`);\n    }\n\n    // The case must investigate the pair its own opportunity named. A cohort\n    // built from a differently-derived pair would describe one comparison and\n    // measure another.","sourceCodeStart":191,"sourceCodeEnd":227,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/packages/shared/contracts/scripts/validate-continuous-improvement.mjs#L191-L227","documentation":"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).","triggerScenarios":"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.","commonSituations":"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.","solutions":["Replace the offending node ID with the correct upstream node that exists in slice.node_chain.","Remove the manifestation node ID from upstream_node_ids — only strictly-upstream nodes belong there.","Regenerate the diagnosis against the current slice so chain membership and IDs are consistent."],"exampleFix":"// before\n\"upstream_node_ids\": [\"parse\", \"manifestation\"]\n// after\n\"upstream_node_ids\": [\"parse\"]","handlingStrategy":"validation","validationCode":"const chainSet = new Set(slice.node_chain);\nfor (const id of item.diagnosis.root_cause_hypothesis.upstream_node_ids) {\n  if (!chainSet.has(id) || id === slice.manifestation_node_id) throw new Error(`upstream node ${id} invalid for slice`);\n}","typeGuard":null,"tryCatchPattern":"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; }","preventionTips":["Generate upstream_node_ids by slicing node_chain up to the manifestation index.","Never include the manifestation node in its own upstream list.","Regenerate diagnoses after any node id rename."],"tags":["validation","diagnosis","causal-slice"],"backgroundTag":"schema-validation-failed","analyzedSha":"3ee70a102609e550bd2e68004bf5990a9341c851","analyzedAt":"2026-09-20T15:53:39.229Z","contentChangedAt":"2026-09-20T15:53:39.229Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}