JuliusBrussee/caveman · error · Error
dataset carries adversarial cases
Error message
${where} dataset carries ${roleCounts.adversarial} adversarial cases What it means
The continuous-improvement fixture validator caps how many adversarial cases a composed dataset may carry: at most 1 normally, or 2 when a confidence guard is active. If roleCounts.adversarial exceeds that cap, the validator throws to reject the fixture before it is used to generate improvement reports. This prevents datasets from being dominated by adversarial cases instead of target-failure/prior-success evidence.
Solutions
- Count adversarial cases in dataset.generated_cases and remove entries until at most 1 (or 2 with the confidence guard) remain.
- If the guard was recently disabled, confirm confidenceGuard matches the fixture and re-cap accordingly.
- Regenerate the fixture with the canonical composition script instead of hand-editing.
- If the cap is intentionally too strict, update the validator and the fixture spec together in the same PR.
Example fix
// before: dataset.generated_cases has 3 adversarial cases // after: keep at most 1 (or 2 when the confidence guard is on) dataset.generated_cases = dataset.generated_cases.slice(0, 1);
Defensive patterns
Strategy: validation
Validate before calling
const adversarial = dataset.cases.filter((c) => c.role === "adversarial").length;
const cap = confidenceGuard ? 2 : 1;
if (adversarial > cap) throw new Error(`too many adversarial cases: ${adversarial} > ${cap}`); Prevention
- Derive generated_cases programmatically instead of hand-editing fixtures.
- Add a CI lint that asserts the adversarial cap before validation.
- When toggling the confidence guard, update affected fixtures in the same change.
When it happens
Trigger: Running scripts/validate-continuous-improvement.mjs against a fixture whose generated_cases (composed dataset) yield more adversarial-role cases than the allowed cap: >2 with confidenceGuard enabled, >1 without.
Common situations: Hand-edited fixture JSON that adds extra adversarial examples; a generator script that appends generated cases without checking the cap; merging fixtures from branches where each added one adversarial case.
Understand the failure class
Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.
Related errors
- boundary case list disagrees with the composed dataset
- dataset roles ( ) do not account for its cases
- generated case list disagrees with the composed dataset
- appears twice in the dataset
- canonical span fixture is empty
AI-assisted analysis of JuliusBrussee/caveman@3ee70a1026 (2026-09-20).
Data as JSON: /api/errors/7100f2fd64bb9873.
Report an issue: GitHub.
Appendix: source
Thrown at packages/shared/contracts/scripts/validate-continuous-improvement.mjs:306
// evidence has no threshold to sit beside, so those two cases must NOT be
// generated for it — a "boundary" case against a guard that does not exist
// tests nothing while counting as adversarial coverage.
const confidenceGuard = item.change_set.applicability.all.some((condition) =>
condition === "failure_location_confidence >= 0.90" ||
condition === "symbol_resolution == unique" ||
condition === "targeted_test_reproduces == true");
const perturbations = new Set(dataset.cases.map((entry) => entry.perturbation));
for (const [perturbation, label] of [["guard_threshold_boundary", "boundary"], ["stale_input", "stale-input"]]) {
if (perturbations.has(perturbation) !== confidenceGuard) {
throw new Error(`${where} ${confidenceGuard ? "omits" : "generated"} a ${label} case ${confidenceGuard ? "for" : "against"} a change set that ${confidenceGuard ? "declares" : "declares no"} confidence guard`);
}
}
const expectedTargets = Math.min(4, dataset.target_failure_cases.length);
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]) {View on GitHub (pinned to 3ee70a1026)