{"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":"exception","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/766dce6b1394ebb56a3090748d5a0240a5aefb36/packages/shared/contracts/scripts/validate-continuous-improvement.mjs#L168-L204","documentation":"When a manifestation node is pinned (manifestation_node_id !== \"\"), it must itself appear in node_chain — a slice that omits the very node it says the failure manifests on is incoherent (validate-continuous-improvement.mjs:185-187). The empty-string sentinel disables the check.","triggerScenarios":"The backward slice was truncated one hop early; the chain was reordered or deduplicated and dropped the manifestation node; the chain was built toward a different endpoint than the manifestation claim.","commonSituations":"Hand-trimming chains for brevity; generators that stop the backward walk at a budget before reaching the manifestation node; editing manifestation_node_id without extending the chain.","solutions":["Append (or insert at the right position) the manifestation node into node_chain.","Better: rebuild the chain backwards from the manifestation node so it ends there by construction.","Re-run the validator."],"exampleFix":"// before\n\"manifestation_node_id\": \"node/exec\",\n\"node_chain\": [\"node/parse\"]\n// after\n\"manifestation_node_id\": \"node/exec\",\n\"node_chain\": [\"node/parse\", \"node/exec\"]","handlingStrategy":"validation","validationCode":"const slicesMissingManifestation = (report) =>\n  report.cases.filter((c) =>\n    c.causal_slice.manifestation_node_id !== '' &&\n    !c.causal_slice.node_chain.includes(c.causal_slice.manifestation_node_id)\n  ).map((c) => c.id);","typeGuard":null,"tryCatchPattern":"try {\n  execFileSync(process.execPath, [VALIDATOR, reportPath, spansPath]);\n} catch (err) {\n  if (/omits its own manifestation/.test(err.message)) {\n    failCI(`node_chain must include the manifestation node: ${err.message}`);\n  } else throw err;\n}","preventionTips":["Construct chains backwards from the manifestation node so it is always the endpoint.","After trimming a chain, assert it still contains the manifestation node before writing the fixture.","Changing manifestation_node_id obligates a chain update in the same edit."],"tags":["fixtures","cross-validation","causal-slice","node-chain","consistency"],"backgroundTag":"required-member-missing","analyzedSha":"766dce6b1394ebb56a3090748d5a0240a5aefb36","analyzedAt":"2026-08-18T03:14:35.516Z","contentChangedAt":"2026-08-18T03:14:35.516Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}