{"record":{"id":"7b5e501a0e51f328","repo":"JuliusBrussee/caveman","slug":"at-replays-a-recorded-flow-but-is-not-identifie","errorCode":null,"errorMessage":"${at} replays a recorded flow but is not identified by its source unit","messagePattern":"(.+?) replays a recorded flow but is not identified by its source unit","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/shared/contracts/scripts/validate-continuous-improvement.mjs","lineNumber":267,"sourceCode":"      [\"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      }\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    //","sourceCodeStart":249,"sourceCodeEnd":285,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/27d5a3981a347890211bb1bf2439e5c821a63bc9/packages/shared/contracts/scripts/validate-continuous-improvement.mjs#L249-L285","documentation":"Thrown when a dataset case has perturbation \"none\" (a recorded replay) but its id is not exactly its source_unit_id. Recorded cases are identified by the unit they replay; any other id breaks the 1:1 correspondence between a replayed flow and its provenance.","triggerScenarios":"Renaming a recorded case's id (e.g., adding a prefix or suffix) while keeping perturbation \"none\"; reusing a generated-case id format for a recorded case.","commonSituations":"Hand-editing ids for readability; merging datasets where ids were namespaced.","solutions":["Set the entry's id equal to its source_unit_id.","If a distinct id is genuinely needed, the case is not a plain replay — model it as a generated case with an explicit generator and matching perturbation."],"exampleFix":"// before\n{id: \"replay-unit-07\", source_unit_id: \"unit-07\", perturbation: \"none\"}\n\n// after\n{id: \"unit-07\", source_unit_id: \"unit-07\", perturbation: \"none\"}","handlingStrategy":"validation","validationCode":"const recordedIdsOk = dataset.cases\n  .filter((c) => c.perturbation === \"none\")\n  .every((c) => c.id === c.source_unit_id);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Emit recorded-case ids as a copy of source_unit_id in the composer; never hand-rename them.","If a case needs a distinct identity, model it as a generated case with an explicit generator."],"tags":["validation","dataset","naming-convention"],"backgroundTag":null,"analyzedSha":"27d5a3981a347890211bb1bf2439e5c821a63bc9","analyzedAt":"2026-08-15T09:26:11.751Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}