{"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":"validation","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/3ee70a102609e550bd2e68004bf5990a9341c851/packages/shared/contracts/scripts/validate-continuous-improvement.mjs#L249-L285","documentation":"A case with perturbation \"none\" replays a recorded flow, so the validator requires its id to equal its source_unit_id exactly — the replayed case must be identified one-to-one with the recorded analysis unit. Any other id breaks the replay manifest linkage.","triggerScenarios":"A dataset entry has perturbation \"none\" but an id different from its source_unit_id — e.g. a renamed id, or a perturbed case whose perturbation field was reset to \"none\" without reverting its generated id (generator:source form).","commonSituations":"Downgrading a generated case to a replay without renaming its id; hand-renumbering ids; copy-pasting ids from generated cases into replay entries.","solutions":["Set entry.id equal to entry.source_unit_id for all perturbation:\"none\" cases.","If the case is actually perturbed, set perturbation to the generator's registered value and keep the generator:source id form.","Regenerate the dataset so ids are derived correctly."],"exampleFix":"// before\n{ \"id\": \"stale-input-gen:unit_abc\", \"source_unit_id\": \"unit_abc\", \"perturbation\": \"none\" }\n// after\n{ \"id\": \"unit_abc\", \"source_unit_id\": \"unit_abc\", \"perturbation\": \"none\" }","handlingStrategy":"validation","validationCode":"for (const c of dataset.cases) {\n  if (c.perturbation === \"none\" && c.id !== c.source_unit_id) throw new Error(`replay case ${c.id} must equal its source unit id`);\n}","typeGuard":null,"tryCatchPattern":"try {\n  validateContinuousImprovement(report, dataset);\n} catch (e) {\n  if (String(e.message).includes(\"not identified by its source unit\")) {\n    // rename replay case ids to their source unit ids\n  }\n}","preventionTips":["Treat replay case ids as immutable copies of source unit ids.","Never rename ids in replay entries when demoting generated cases."],"tags":["manifest-validation","id-naming-convention","dataset-integrity"],"backgroundTag":"invalid-identifier-format","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"}