{"record":{"id":"939f08a2b8b3c8c0","repo":"JuliusBrussee/caveman","slug":"where-hard-chain-edge-edge-from-edge-to-939f08","errorCode":null,"errorMessage":"${where} hard chain edge ${edge.from}->${edge.to} is outside the slice's node chain","messagePattern":"(.+?) hard chain edge (.+?)->(.+?) is outside the slice's node chain","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/shared/contracts/scripts/validate-continuous-improvement.mjs","lineNumber":194,"sourceCode":"    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`);\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","sourceCodeStart":176,"sourceCodeEnd":212,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/packages/shared/contracts/scripts/validate-continuous-improvement.mjs#L176-L212","documentation":"Hard-chain edges must lie entirely within the slice's declared node_chain, not merely within the variant. An edge touching a node outside `slice.node_chain` means the chain and the hard edges describe different subgraphs, so validation throws.","triggerScenarios":"`slice.hard_edges` contains an edge where `from` or `to` is absent from `slice.node_chain` (even though it exists in the variant).","commonSituations":"Adding an edge to the hard chain without extending node_chain; chain pruned after edges were authored; two authors editing chain and edges independently.","solutions":["Add the missing endpoint node ids to slice.node_chain","Remove the out-of-chain edge from hard_edges (or move it to unproven_adjacencies)","Regenerate chain and hard_edges together from one slice extraction run"],"exampleFix":"// before\nnode_chain: ['node_1','node_2'], hard_edges: [{from:'node_2',to:'node_5',...}]\n// after\nnode_chain: ['node_1','node_2','node_5'], hard_edges: [{from:'node_2',to:'node_5',...}]","handlingStrategy":"validation","validationCode":"const chain = new Set(slice.node_chain);\nconst bad = slice.hard_edges.filter(e => !chain.has(e.from) || !chain.has(e.to));\nif (bad.length) throw new Error(`edges outside node chain: ${bad.map(e => e.from + '->' + e.to)}`);","typeGuard":"const edgesInChain = (slice) => { const c = new Set(slice.node_chain); return slice.hard_edges.every(e => c.has(e.from) && c.has(e.to)); };","tryCatchPattern":"try { validateCase(item); } catch (e) { if (String(e.message).includes(\"outside the slice's node chain\")) extendChainOrPruneEdges(item); else throw e; }","preventionTips":["Generate node_chain and hard_edges in the same extraction pass","Never edit chain and edges independently","Add a consistency check to the fixture authoring script"],"tags":["validation","consistency"],"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"}