{"record":{"id":"3031b9eaa39d39a3","repo":"JuliusBrussee/caveman","slug":"where-causal-slice-omits-its-own-manifestation","errorCode":null,"errorMessage":"${where} causal slice omits its own manifestation node","messagePattern":"(.+?) causal slice omits its own manifestation node","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/shared/contracts/scripts/validate-continuous-improvement.mjs","lineNumber":186,"sourceCode":"      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`);\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      }","sourceCodeStart":168,"sourceCodeEnd":204,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/packages/shared/contracts/scripts/validate-continuous-improvement.mjs#L168-L204","documentation":"If the slice declares a manifestation node (non-empty manifestation_node_id), that node must also appear in the slice's own node_chain; otherwise the backward slice does not actually reach the manifestation point and the report is incoherent.","triggerScenarios":"Validation where `slice.manifestation_node_id !== ''` and `slice.node_chain` does not include that node id.","commonSituations":"Chain truncated during editing; chain rebuilt from a different root than the manifestation node; slice extractor bug that drops the terminal node.","solutions":["Append the manifestation node id to node_chain","Clear/fix manifestation_node_id if the slice intentionally has no manifestation point","Fix the slice extractor to always include the manifestation node as the chain terminus"],"exampleFix":"// before\nmanifestation_node_id: 'node_9', node_chain: ['node_1','node_4']\n// after\nmanifestation_node_id: 'node_9', node_chain: ['node_1','node_4','node_9']","handlingStrategy":"validation","validationCode":"if (slice.manifestation_node_id !== '' && !slice.node_chain.includes(slice.manifestation_node_id)) throw new Error('chain omits manifestation node');","typeGuard":"const chainReachesManifestation = (slice) => slice.manifestation_node_id === '' || slice.node_chain.includes(slice.manifestation_node_id);","tryCatchPattern":"try { validateCase(item); } catch (e) { if (String(e.message).includes('omits its own manifestation node')) appendManifestationToChain(item); else throw e; }","preventionTips":["Always terminate node_chain at the manifestation node","Keep slice extraction as one atomic function producing chain + manifestation together","Unit-test the slice extractor for chain completeness"],"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"}