JuliusBrussee/caveman · error · Error

replays a recorded flow but is not identified by its source…

Error message

${at} replays a recorded flow but is not identified by its source unit

What it means

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.

Solutions

  1. Set entry.id equal to entry.source_unit_id for all perturbation:"none" cases.
  2. If the case is actually perturbed, set perturbation to the generator's registered value and keep the generator:source id form.
  3. Regenerate the dataset so ids are derived correctly.

Example fix

// before
{ "id": "stale-input-gen:unit_abc", "source_unit_id": "unit_abc", "perturbation": "none" }
// after
{ "id": "unit_abc", "source_unit_id": "unit_abc", "perturbation": "none" }
Defensive patterns

Strategy: validation

Validate before calling

for (const c of dataset.cases) {
  if (c.perturbation === "none" && c.id !== c.source_unit_id) throw new Error(`replay case ${c.id} must equal its source unit id`);
}

Try / catch

try {
  validateContinuousImprovement(report, dataset);
} catch (e) {
  if (String(e.message).includes("not identified by its source unit")) {
    // rename replay case ids to their source unit ids
  }
}

Prevention

When it happens

Trigger: 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).

Common situations: Downgrading a generated case to a replay without renaming its id; hand-renumbering ids; copy-pasting ids from generated cases into replay entries.

Understand the failure class

Background: "invalid id" errors: invalid identifier format — why libraries reject IDs before lookup, and how to fix them — this error's family across 37 libraries.

Related errors


AI-assisted analysis of JuliusBrussee/caveman@3ee70a1026 (2026-09-20). Data as JSON: /api/errors/7b5e501a0e51f328. Report an issue: GitHub.

Appendix: source

Thrown at packages/shared/contracts/scripts/validate-continuous-improvement.mjs:267

      ["recorded_case.v1", "none"],
      ["boundary_guard_threshold.v1", "guard_threshold_boundary"],
      ["adversarial_misleading_tool_output.v1", "misleading_tool_output"],
      ["adversarial_stale_input.v1", "stale_input"],
    ]);
    const roleCounts = { target_failure: 0, prior_success: 0, boundary: 0, adversarial: 0 };
    const recordedSources = new Set();
    const datasetCaseIDs = new Set();
    for (const entry of dataset.cases) {
      const at = `${where} dataset case ${entry.id}`;
      if (datasetCaseIDs.has(entry.id)) throw new Error(`${at} appears twice in the dataset`);
      datasetCaseIDs.add(entry.id);
      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`);
      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}`);
      if (generatorPerturbation.get(entry.generator) !== entry.perturbation) {
        throw new Error(`${at} generator ${entry.generator} disagrees with perturbation ${entry.perturbation}`);
      }
      if (entry.perturbation === "none" && entry.id !== entry.source_unit_id) {
        throw new Error(`${at} replays a recorded flow but is not identified by its source unit`);
      }
      if (entry.perturbation !== "none" && entry.id !== `${entry.generator}:${entry.source_unit_id}`) {
        throw new Error(`${at} is a generated case whose id does not name its generator and source unit`);
      }
      roleCounts[entry.role] += 1;
      if (entry.role === "target_failure" || entry.role === "prior_success") recordedSources.add(entry.source_unit_id);
    }
    for (const entry of dataset.cases) {
      // Leakage: a generated case must not perturb a unit the manifest already
      // replays unperturbed.
      if (entry.perturbation !== "none" && recordedSources.has(entry.source_unit_id)) {
        throw new Error(`${where} generated case ${entry.id} perturbs a unit the dataset already replays unperturbed`);
      }
    }

    // Manifest composition arithmetic (spec 18.2): target-failure + prior-success
    // + one boundary + up to two adversarial, each capped and each recomputable.
    //

View on GitHub (pinned to 3ee70a1026)