JuliusBrussee/caveman · error · Error

names source unit that is not an analysis unit of this…

Error message

${at} names source unit ${entry.source_unit_id} that is not an analysis unit of this report

What it means

This validator checks a continuous-improvement dataset manifest against an analysis report. Each dataset case names a source unit via source_unit_id; this throw fires when that id does not exist in the report's set of analysis units (unitsByID). The library throws it because a case replaying a flow that the report never analyzed is meaningless and would silently produce bogus comparisons.

Solutions

  1. Regenerate the dataset from the current analysis report so source_unit_id values match existing units.
  2. Find the offending case id printed at the start of the message and correct its source_unit_id to an existing unit in the report.
  3. If the unit was intentionally removed, remove the dependent dataset case too.
  4. Verify you are validating against the intended report file (stale report path).

Example fix

// before
{ "id": "case-1", "source_unit_id": "unit_abc123" }  // unit_abc123 no longer in report
// after
{ "id": "case-1", "source_unit_id": "unit_def456" }  // id present in current report's units
Defensive patterns

Strategy: validation

Validate before calling

const unitIds = new Set(report.units.map(u => u.id));
for (const c of dataset.cases) {
  if (!unitIds.has(c.source_unit_id)) throw new Error(`case ${c.id}: unknown source unit ${c.source_unit_id}`);
}

Try / catch

try {
  validateContinuousImprovement(report, dataset);
} catch (e) {
  if (String(e.message).includes("not an analysis unit")) {
    // regenerate dataset from current report before proceeding
  }
}

Prevention

When it happens

Trigger: Running the validator when any dataset.cases[] entry has a source_unit_id absent from unitsByID — e.g. the manifest was edited by hand, or the dataset was generated against an older/newer analysis report whose unit ids changed.

Common situations: Regenerating the analysis report (unit ids get re-hashed) without regenerating the dataset; typos in a hand-authored manifest; copying cases between datasets from different reports or task families.

Understand the failure class

Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.

Related errors


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

Appendix: source

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

    // Every dataset case — recorded or generated — must name a real analysis
    // unit of this case's own task family, and its generator and perturbation
    // must agree. A generated case whose source unit cannot be resolved would be
    // invented evidence wearing an adversarial label.
    const dataset = item.eval_pack.dataset;
    const generatorPerturbation = new Map([
      ["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`);

View on GitHub (pinned to 3ee70a1026)