{"record":{"id":"2a5bad772fdd8c3a","repo":"JuliusBrussee/caveman","slug":"where-diagnosis-manifestation-node-disagrees-wi","errorCode":null,"errorMessage":"${where} diagnosis manifestation node disagrees with its causal slice","messagePattern":"(.+?) diagnosis manifestation node disagrees with its causal slice","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/shared/contracts/scripts/validate-continuous-improvement.mjs","lineNumber":180,"sourceCode":"      if (!unitsByID.has(trace.analysis_unit_id)) throw new Error(`${where} representative trace ${trace.analysis_unit_id} is not an analysis unit of this report`);\n      if (!familyUnits.has(trace.analysis_unit_id)) throw new Error(`${where} representative trace ${trace.analysis_unit_id} is not a member of the cohort's task family`);\n      if (!variant.analysis_unit_ids.includes(trace.analysis_unit_id)) throw new Error(`${where} representative trace ${trace.analysis_unit_id} did not run that arm's workflow variant`);\n      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    }","sourceCodeStart":162,"sourceCodeEnd":198,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/packages/shared/contracts/scripts/validate-continuous-improvement.mjs#L162-L198","documentation":"The diagnosis and the causal slice must agree on where the behavior manifests. The validator throws when `item.diagnosis.manifestation.node_id` differs from `slice.manifestation_node_id`, keeping diagnosis and slice internally consistent.","triggerScenarios":"Validation of a case where the diagnosis manifestation node id is not identical (strict ===) to the causal slice's manifestation_node_id.","commonSituations":"Updating one of the two fields without the other; two tools (diagnosis writer vs slice extractor) run against different graph versions; copy-paste across cases.","solutions":["Set slice.manifestation_node_id to the diagnosis manifestation node id (or vice versa)","Re-run the slice extractor after a diagnosis change","Regenerate both diagnosis and slice from the same variant snapshot"],"exampleFix":"// before\ndiagnosis.manifestation.node_id = 'node_7'; slice.manifestation_node_id = 'node_9'\n// after\ndiagnosis.manifestation.node_id = 'node_7'; slice.manifestation_node_id = 'node_7'","handlingStrategy":"validation","validationCode":"if (item.diagnosis.manifestation.node_id !== item.causal_slice.manifestation_node_id) throw new Error('diagnosis/slice manifestation mismatch');","typeGuard":"const diagnosisMatchesSlice = (item) => item.diagnosis.manifestation.node_id === item.causal_slice.manifestation_node_id;","tryCatchPattern":"try { validateCase(item); } catch (e) { if (String(e.message).includes('disagrees with its causal slice')) syncManifestation(item); else throw e; }","preventionTips":["Write diagnosis and slice in one pipeline step","Use a single source of truth for the manifestation node","Re-run diagnosis when the slice changes (and vice versa)"],"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"}