{"record":{"id":"6efa04ffabbb2fce","repo":"JuliusBrussee/caveman","slug":"where-adjacency-edge-from-edge-to-appear","errorCode":null,"errorMessage":"${where} adjacency ${edge.from}->${edge.to} appears in both the hard chain and the unproven list","messagePattern":"(.+?) adjacency (.+?)->(.+?) appears in both the hard chain and the unproven list","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/shared/contracts/scripts/validate-continuous-improvement.mjs","lineNumber":203,"sourceCode":"    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\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) {","sourceCodeStart":185,"sourceCodeEnd":221,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/packages/shared/contracts/scripts/validate-continuous-improvement.mjs#L185-L221","documentation":"A causal slice maintains two disjoint edge lists: the proven hard chain and the unproven adjacencies. This error fires when the same edge (identical from, to, and type) appears in both lists, which would let an unproven claim masquerade as proven. The validator rejects the report to keep the two classifications mutually exclusive.","triggerScenarios":"Running the validator on a report where an entry of unproven_adjacencies is duplicated verbatim in slice.hard_edges (same from/to/type triple).","commonSituations":"Merging slices from two reports without deduplication; adding a newly proven edge to the hard chain but forgetting to delete its stale entry in the unproven list; template-generated slices with placeholder edges filled into both arrays.","solutions":["Delete the edge from unproven_adjacencies (the hard chain entry wins once it is proven).","If the edge is not actually proven, remove it from hard_edges instead and keep it only in unproven_adjacencies.","Add a pre-submission check that no from/to/type key exists in both arrays."],"exampleFix":"// before\n\"hard_edges\": [{ \"from\": \"a\", \"to\": \"b\", \"type\": \"causes\" }],\n\"unproven_adjacencies\": [{ \"from\": \"a\", \"to\": \"b\", \"type\": \"causes\" }]\n// after\n\"hard_edges\": [{ \"from\": \"a\", \"to\": \"b\", \"type\": \"causes\" }],\n\"unproven_adjacencies\": []","handlingStrategy":"validation","validationCode":"const hardKeys = new Set(slice.hard_edges.map(e => `${e.from} ${e.to} ${e.type}`));\nfor (const e of slice.unproven_adjacencies) {\n  if (hardKeys.has(`${e.from} ${e.to} ${e.type}`)) throw new Error(`edge ${e.from}->${e.to} in both lists`);\n}","typeGuard":null,"tryCatchPattern":"try { validateReport(report); } catch (err) { if (String(err.message).includes('appears in both the hard chain and the unproven list')) { /* deduplicate */ } else throw err; }","preventionTips":["Treat hard_edges and unproven_adjacencies as one partition of edges; build them from a single source list.","Deduplicate by from/to/type key when merging slices.","Add a pre-commit lint that checks the disjointness of the two arrays."],"tags":["validation","duplicate-entry","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"}