JuliusBrussee/caveman · error · Error

guard_respected grader perturbed dataset cases

Error message

${where} guard_respected grader ${perturbed ? "missing for" : "declared without"} perturbed dataset cases

What it means

The guard_respected grader must exist exactly when the composed dataset contains at least one case with a perturbation other than "none": the grader is the mechanism that catches candidates breaking under perturbation, so declaring it without perturbed cases is decoration, and omitting it with perturbed cases leaves them unguarded. The validator throws on either side of the mismatch.

Solutions

  1. If cases are perturbed, add "guard_respected" to item.eval_pack.graders.
  2. If no case is perturbed, remove "guard_respected" from eval_pack.graders.
  3. Adjust perturbation fields on dataset.cases to match the intended guard configuration.
  4. Regenerate the eval pack and dataset together so the grader set is derived from the cases.

Example fix

// before: perturbed case added, graders lack guard_respected
// after:
item.eval_pack.graders.push("guard_respected");
Defensive patterns

Strategy: validation

Validate before calling

const perturbed = dataset.cases.some((c) => c.perturbation !== "none");
const declared = item.eval_pack.graders.includes("guard_respected");
if (perturbed !== declared) throw new Error("guard_respected grader / perturbed cases mismatch");

Prevention

When it happens

Trigger: validate-continuous-improvement.mjs computes perturbed = dataset.cases.some(c => c.perturbation !== "none") and it differs from item.eval_pack.graders.includes("guard_respected").

Common situations: Adding a perturbed case but forgetting to add guard_respected to eval_pack.graders; removing all perturbations while the grader list still declares it; an editor stripping perturbation values to "none".

Understand the failure class

Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.

Related errors


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

Appendix: source

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

    const expectedPriors = Math.min(2, dataset.prior_success_cases.length);
    if (roleCounts.target_failure !== expectedTargets) throw new Error(`${where} dataset carries ${roleCounts.target_failure} target-failure cases, want ${expectedTargets}`);
    if (roleCounts.prior_success !== expectedPriors) throw new Error(`${where} dataset carries ${roleCounts.prior_success} prior-success cases, want ${expectedPriors}`);
    if (roleCounts.boundary > 1) throw new Error(`${where} dataset carries ${roleCounts.boundary} boundary cases, want at most one`);
    if (roleCounts.adversarial > (confidenceGuard ? 2 : 1)) throw new Error(`${where} dataset carries ${roleCounts.adversarial} adversarial cases`);
    if (roleCounts.boundary !== dataset.boundary_cases.length) throw new Error(`${where} boundary case list disagrees with the composed dataset`);
    if (roleCounts.adversarial !== dataset.generated_cases.length) throw new Error(`${where} generated case list disagrees with the composed dataset`);
    const composed = roleCounts.target_failure + roleCounts.prior_success + roleCounts.boundary + roleCounts.adversarial;
    if (composed !== dataset.cases.length) throw new Error(`${where} dataset roles (${composed}) do not account for its ${dataset.cases.length} cases`);
    if (dataset.replay_case_ids.length !== datasetCaseIDs.size) throw new Error(`${where} replay manifest carries ${dataset.replay_case_ids.length} ids for ${datasetCaseIDs.size} dataset cases`);
    for (const datasetCaseID of dataset.replay_case_ids) {
      if (!datasetCaseIDs.has(datasetCaseID)) throw new Error(`${where} replay manifest case ${datasetCaseID} is not a composed dataset case`);
    }

    // The guard grader exists exactly when there is a perturbed case to catch a
    // candidate on; a required grader with no case behind it is decoration.
    const perturbed = dataset.cases.some((entry) => entry.perturbation !== "none");
    if (perturbed !== item.eval_pack.graders.includes("guard_respected")) {
      throw new Error(`${where} guard_respected grader ${perturbed ? "missing for" : "declared without"} perturbed dataset cases`);
    }
    for (const proof of item.replay.trial_proofs) {
      if (!datasetCaseIDs.has(proof.dataset_case_id)) throw new Error(`${where} replay trial ${proof.id} replays a case outside the composed dataset`);
      for (const arm of [proof.baseline, proof.candidate]) {
        const graders = arm.grader_results.map((grader) => grader.grader).sort();
        const required = [...item.eval_pack.graders].sort();
        if (graders.join(",") !== required.join(",")) {
          throw new Error(`${where} replay trial ${proof.id} graded ${graders.join(",")}, want exactly ${required.join(",")}`);
        }
      }
    }
  }
}
if (!Array.isArray(spans) || spans.length === 0) throw new Error("canonical span fixture is empty");
for (const [index, span] of spans.entries()) {
  if (!validateSpan(span)) throw new Error(`canonical span ${index}: ${ajv.errorsText(validateSpan.errors)}`);
}
if (relationshipCount === 0) throw new Error("no theme relationship reached the shared-analysis-unit threshold in any fixture");

View on GitHub (pinned to 3ee70a1026)