{"record":{"id":"73c29a671b61cea4","repo":"JuliusBrussee/caveman","slug":"where-hard-chain-carries-an-unproven-edge-edg","errorCode":null,"errorMessage":"${where} hard chain carries an unproven edge ${edge.from}->${edge.to}","messagePattern":"(.+?) hard chain carries an unproven edge (.+?)->(.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/shared/contracts/scripts/validate-continuous-improvement.mjs","lineNumber":191,"sourceCode":"    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`);\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`);","sourceCodeStart":173,"sourceCodeEnd":209,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/packages/shared/contracts/scripts/validate-continuous-improvement.mjs#L173-L209","documentation":"An edge listed in `slice.hard_edges` must be a proven dependency: strength 'hard', type 'data' or 'control', and at least one evidence_ref (the `provenDependency` predicate). Anything failing that predicate is labeled an unproven edge and must not sit in the hard chain.","triggerScenarios":"`slice.hard_edges` contains an edge whose strength is not 'hard', whose type is not 'data'/'control', or whose evidence_refs array is empty.","commonSituations":"Promoting a 'soft' adjacency into the hard chain by hand; evidence_refs stripped during dedup; an observation-typed edge misclassified as data/control.","solutions":["Move the unproven edge to slice.unproven_adjacencies","Add valid evidence_refs and set strength 'hard' if the dependency is genuinely proven","Fix the edge's type to 'data' or 'control' if it is misclassified"],"exampleFix":"// before\nhard_edges: [{from:'a',to:'b',type:'data',strength:'soft',evidence_refs:[]}]\n// after\nunproven_adjacencies: [{from:'a',to:'b',type:'data',strength:'soft',evidence_refs:[]}]","handlingStrategy":"validation","validationCode":"const proven = (e) => e.strength === 'hard' && (e.type === 'data' || e.type === 'control') && e.evidence_refs.length > 0;\nconst bad = slice.hard_edges.filter(e => !proven(e));\nif (bad.length) throw new Error(`unproven hard edges: ${bad.map(e => e.from + '->' + e.to)}`);","typeGuard":"const isProvenEdge = (e) => e.strength === 'hard' && (e.type === 'data' || e.type === 'control') && Array.isArray(e.evidence_refs) && e.evidence_refs.length > 0;","tryCatchPattern":"try { validateCase(item); } catch (e) { if (String(e.message).includes('unproven edge')) demoteToUnprovenAdjacencies(item); else throw e; }","preventionTips":["Only move an edge into hard_edges after attaching evidence_refs","Keep a single provenDependency predicate shared by writer and validator","Classify observation/soft edges into unproven_adjacencies at authoring time"],"tags":["validation","causal-analysis"],"backgroundTag":"invalid-enum-value","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"}