{"record":{"id":"da1047bfd0963d83","repo":"JuliusBrussee/caveman","slug":"where-causal-slice-node-nodeid-is-not-a-node","errorCode":null,"errorMessage":"${where} causal slice node ${nodeID} is not a node of variant ${sliceVariant.id}","messagePattern":"(.+?) causal slice node (.+?) is not a node of variant (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/shared/contracts/scripts/validate-continuous-improvement.mjs","lineNumber":183,"sourceCode":"      selectedPerArm.set(trace.arm, (selectedPerArm.get(trace.arm) ?? 0) + 1);\n    }\n    for (const [arm, count] of selectedPerArm) {\n      if (count > 3) throw new Error(`${where} arm ${arm} carries ${count} representative traces, more than three`);\n    }\n\n    const slice = item.causal_slice;\n    const sliceVariant = variantsByID.get(slice.variant_id);\n    if (!sliceVariant) throw new Error(`${where} causal slice references a workflow variant that is not in this report`);\n    if (sliceVariant.id !== armVariants.get(\"baseline\").id) throw new Error(`${where} causal slice is not taken from the baseline arm's variant`);\n    const sliceNodes = new Set(sliceVariant.nodes.map((node) => node.id));\n    if (slice.manifestation_node_id !== \"\" && !sliceNodes.has(slice.manifestation_node_id)) {\n      throw new Error(`${where} manifestation node ${slice.manifestation_node_id} is not a node of variant ${sliceVariant.id}`);\n    }\n    if (item.diagnosis.manifestation.node_id !== slice.manifestation_node_id) {\n      throw new Error(`${where} diagnosis manifestation node disagrees with its causal slice`);\n    }\n    for (const nodeID of slice.node_chain) {\n      if (!sliceNodes.has(nodeID)) throw new Error(`${where} causal slice node ${nodeID} is not a node of variant ${sliceVariant.id}`);\n    }\n    if (slice.manifestation_node_id !== \"\" && !slice.node_chain.includes(slice.manifestation_node_id)) {\n      throw new Error(`${where} causal slice omits its own manifestation node`);\n    }\n    const provenDependency = (edge) => edge.strength === \"hard\" && (edge.type === \"data\" || edge.type === \"control\") && edge.evidence_refs.length > 0;\n    const variantEdges = new Map(sliceVariant.edges.map((edge) => [`${edge.from}\u0000${edge.to}\u0000${edge.type}`, edge]));\n    for (const edge of slice.hard_edges) {\n      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`);","sourceCodeStart":165,"sourceCodeEnd":201,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/packages/shared/contracts/scripts/validate-continuous-improvement.mjs#L165-L201","documentation":"Validation error in the continuous-improvement contract validator: a causal slice in the report names a node id that is not a member of the variant the slice claims to be taken from. The slice is therefore not a faithful subgraph of that variant's graph.","triggerScenarios":"`slice.node_chain` contains a node id not present in `sliceVariant.nodes` while validating the report.","commonSituations":"Chain authored from an older variant revision; hallucinated/typo'd node ids in an LLM-generated slice; variant graph refactored after the slice was written.","solutions":["Remove or correct the offending node id in node_chain","Regenerate node_chain from the current variant's graph","Pin the report fixture to the variant revision the chain was authored against"],"exampleFix":"// before\nnode_chain: ['node_1', 'node_2', 'node_renamed_3']\n// after\nnode_chain: ['node_1', 'node_2', 'node_3']","handlingStrategy":"validation","validationCode":"const nodeIds = new Set(variant.nodes.map(n => n.id));\nconst bad = slice.node_chain.filter(id => !nodeIds.has(id));\nif (bad.length) throw new Error(`chain nodes not in variant: ${bad}`);","typeGuard":"const chainInVariant = (slice, variant) => slice.node_chain.every(id => variant.nodes.some(n => n.id === id));","tryCatchPattern":"try { validateCase(item); } catch (e) { if (String(e.message).includes('is not a node of variant')) rebuildNodeChain(item); else throw e; }","preventionTips":["Build node_chain by walking the variant graph, never by hand","Rebuild slices after variant graph refactors","Add a fixture lint that checks all referenced ids against the graph"],"tags":["validation","graph-reference"],"backgroundTag":"entity-not-found","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"}