{"record":{"id":"0b631d5011673519","repo":"JuliusBrussee/caveman","slug":"where-generated-case-entry-id-perturbs-a-uni","errorCode":null,"errorMessage":"${where} generated case ${entry.id} perturbs a unit the dataset already replays unperturbed","messagePattern":"(.+?) generated case (.+?) perturbs a unit the dataset already replays unperturbed","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/shared/contracts/scripts/validate-continuous-improvement.mjs","lineNumber":279,"sourceCode":"      if (!unitsByID.has(entry.source_unit_id)) throw new Error(`${at} names source unit ${entry.source_unit_id} that is not an analysis unit of this report`);\n      if (!familyUnits.has(entry.source_unit_id)) throw new Error(`${at} names source unit ${entry.source_unit_id} that is not a member of task family ${family.id}`);\n      if (generatorPerturbation.get(entry.generator) !== entry.perturbation) {\n        throw new Error(`${at} generator ${entry.generator} disagrees with perturbation ${entry.perturbation}`);\n      }\n      if (entry.perturbation === \"none\" && entry.id !== entry.source_unit_id) {\n        throw new Error(`${at} replays a recorded flow but is not identified by its source unit`);\n      }\n      if (entry.perturbation !== \"none\" && entry.id !== `${entry.generator}:${entry.source_unit_id}`) {\n        throw new Error(`${at} is a generated case whose id does not name its generator and source unit`);\n      }\n      roleCounts[entry.role] += 1;\n      if (entry.role === \"target_failure\" || entry.role === \"prior_success\") recordedSources.add(entry.source_unit_id);\n    }\n    for (const entry of dataset.cases) {\n      // Leakage: a generated case must not perturb a unit the manifest already\n      // replays unperturbed.\n      if (entry.perturbation !== \"none\" && recordedSources.has(entry.source_unit_id)) {\n        throw new Error(`${where} generated case ${entry.id} perturbs a unit the dataset already replays unperturbed`);\n      }\n    }\n\n    // Manifest composition arithmetic (spec 18.2): target-failure + prior-success\n    // + one boundary + up to two adversarial, each capped and each recomputable.\n    //\n    // The boundary and stale-input generators perturb the localization evidence\n    // a confidence guard reads. A ChangeSet whose applicability never reads that\n    // evidence has no threshold to sit beside, so those two cases must NOT be\n    // generated for it — a \"boundary\" case against a guard that does not exist\n    // tests nothing while counting as adversarial coverage.\n    const confidenceGuard = item.change_set.applicability.all.some((condition) =>\n      condition === \"failure_location_confidence >= 0.90\" ||\n      condition === \"symbol_resolution == unique\" ||\n      condition === \"targeted_test_reproduces == true\");\n    const perturbations = new Set(dataset.cases.map((entry) => entry.perturbation));\n    for (const [perturbation, label] of [[\"guard_threshold_boundary\", \"boundary\"], [\"stale_input\", \"stale-input\"]]) {\n      if (perturbations.has(perturbation) !== confidenceGuard) {","sourceCodeStart":261,"sourceCodeEnd":297,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/packages/shared/contracts/scripts/validate-continuous-improvement.mjs#L261-L297","documentation":"Leakage guard: if the dataset already replays a unit unperturbed (role target_failure or prior_success), a generated case must not perturb that same unit — doing so would let perturbed and unperturbed views of the same flow coexist and leak information across roles. The validator collects such recorded source ids in a first pass and rejects violations in a second pass.","triggerScenarios":"A case with perturbation != \"none\" whose source_unit_id was added to recordedSources (i.e. some case with role target_failure or prior_success replays that unit with perturbation \"none\").","commonSituations":"Appending generated cases to a manifest without noticing a replay of the same unit already exists; generators reusing popular units; merging two datasets.","solutions":["Remove the generated case that targets an already-replayed unit.","Point the generated case at a different source unit not replayed unperturbed.","If the unperturbed replay is unnecessary, drop it so the perturbed case is allowed."],"exampleFix":"// before\ncases: [{id:\"unit_1\",perturbation:\"none\"},{id:\"gen:unit_1\",perturbation:\"stale_input\"}] // leak\n// after\ncases: [{id:\"unit_1\",perturbation:\"none\"},{id:\"gen:unit_2\",perturbation:\"stale_input\"}]","handlingStrategy":"validation","validationCode":"const replayed = new Set(dataset.cases.filter(c => c.perturbation === \"none\" && [\"target_failure\",\"prior_success\"].includes(c.role)).map(c => c.source_unit_id));\nfor (const c of dataset.cases) {\n  if (c.perturbation !== \"none\" && replayed.has(c.source_unit_id)) throw new Error(`leak: ${c.id} perturbs a replayed unit`);\n}","typeGuard":null,"tryCatchPattern":"try {\n  validateContinuousImprovement(report, dataset);\n} catch (e) {\n  if (String(e.message).includes(\"already replays unperturbed\")) {\n    // drop or retarget the leaking generated case\n  }\n}","preventionTips":["Have generators exclude units already replayed unperturbed.","Deduplicate source units across roles before composing perturbed cases."],"tags":["manifest-validation","data-leakage","dataset-integrity"],"backgroundTag":"invalid-argument-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"}