{"record":{"id":"05c25ec4071a02a3","repo":"JuliusBrussee/caveman","slug":"at-names-source-unit-entry-source-unit-id-th-05c25e","errorCode":null,"errorMessage":"${at} names source unit ${entry.source_unit_id} that is not a member of task family ${family.id}","messagePattern":"(.+?) names source unit (.+?) that is not a member of task family (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/shared/contracts/scripts/validate-continuous-improvement.mjs","lineNumber":262,"sourceCode":"    // unit of this case's own task family, and its generator and perturbation\n    // must agree. A generated case whose source unit cannot be resolved would be\n    // invented evidence wearing an adversarial label.\n    const dataset = item.eval_pack.dataset;\n    const generatorPerturbation = new Map([\n      [\"recorded_case.v1\", \"none\"],\n      [\"boundary_guard_threshold.v1\", \"guard_threshold_boundary\"],\n      [\"adversarial_misleading_tool_output.v1\", \"misleading_tool_output\"],\n      [\"adversarial_stale_input.v1\", \"stale_input\"],\n    ]);\n    const roleCounts = { target_failure: 0, prior_success: 0, boundary: 0, adversarial: 0 };\n    const recordedSources = new Set();\n    const datasetCaseIDs = new Set();\n    for (const entry of dataset.cases) {\n      const at = `${where} dataset case ${entry.id}`;\n      if (datasetCaseIDs.has(entry.id)) throw new Error(`${at} appears twice in the dataset`);\n      datasetCaseIDs.add(entry.id);\n      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      }","sourceCodeStart":244,"sourceCodeEnd":280,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/packages/shared/contracts/scripts/validate-continuous-improvement.mjs#L244-L280","documentation":"The dataset case's source unit exists in the report (passed the unitsByID check) but is not a member of the task family currently being validated (familyUnits). This validator enforces that every dataset case's source belongs to the same task family as the dataset's declared family id, so cross-family sources are rejected.","triggerScenarios":"A dataset declaring family X contains a case whose source_unit_id resolves to a unit that belongs to a different family in the report — typically after reassigning units to families in the report, or mixing cases copied from another family's dataset.","commonSituations":"Hand-editing family membership in the report; merging datasets across families; a family's unit set was narrowed and old cases were left behind.","solutions":["Move or remove the offending case so every case's source unit belongs to the declared family.","Regenerate the dataset scoped to family ${family.id} from the current report.","If the family assignment is wrong, update the family's unit membership in the report.","Check you are not validating one family's dataset against another family's configuration."],"exampleFix":"// before\ndataset.family = \"auth-family\"; case.source_unit_id = \"unit-from-billing-family\";\n// after\n// keep only cases whose source_unit_id is listed in the auth-family unit set,\n// or reassign the unit to auth-family in the report","handlingStrategy":"validation","validationCode":"const familyUnits = new Set(report.units.filter(u => u.family_id === family.id).map(u => u.id));\nfor (const c of dataset.cases) {\n  if (!familyUnits.has(c.source_unit_id)) throw new Error(`case ${c.id} outside family ${family.id}`);\n}","typeGuard":null,"tryCatchPattern":"try {\n  validateContinuousImprovement(report, dataset);\n} catch (e) {\n  if (String(e.message).includes(\"not a member of task family\")) {\n    // filter cases to family membership or fix family assignment\n  }\n}","preventionTips":["Scope dataset generation per family; never merge datasets across families.","Verify family membership in the report before composing cases."],"tags":["manifest-validation","family-membership","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"}