{"record":{"id":"d3b09bcdb809d0ce","repo":"JuliusBrussee/caveman","slug":"canonical-span-fixture-is-empty","errorCode":null,"errorMessage":"canonical span fixture is empty","messagePattern":"canonical span fixture is empty","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/shared/contracts/scripts/validate-continuous-improvement.mjs","lineNumber":334,"sourceCode":"    // The guard grader exists exactly when there is a perturbed case to catch a\n    // candidate on; a required grader with no case behind it is decoration.\n    const perturbed = dataset.cases.some((entry) => entry.perturbation !== \"none\");\n    if (perturbed !== item.eval_pack.graders.includes(\"guard_respected\")) {\n      throw new Error(`${where} guard_respected grader ${perturbed ? \"missing for\" : \"declared without\"} perturbed dataset cases`);\n    }\n    for (const proof of item.replay.trial_proofs) {\n      if (!datasetCaseIDs.has(proof.dataset_case_id)) throw new Error(`${where} replay trial ${proof.id} replays a case outside the composed dataset`);\n      for (const arm of [proof.baseline, proof.candidate]) {\n        const graders = arm.grader_results.map((grader) => grader.grader).sort();\n        const required = [...item.eval_pack.graders].sort();\n        if (graders.join(\",\") !== required.join(\",\")) {\n          throw new Error(`${where} replay trial ${proof.id} graded ${graders.join(\",\")}, want exactly ${required.join(\",\")}`);\n        }\n      }\n    }\n  }\n}\nif (!Array.isArray(spans) || spans.length === 0) throw new Error(\"canonical span fixture is empty\");\nfor (const [index, span] of spans.entries()) {\n  if (!validateSpan(span)) throw new Error(`canonical span ${index}: ${ajv.errorsText(validateSpan.errors)}`);\n}\nif (relationshipCount === 0) throw new Error(\"no theme relationship reached the shared-analysis-unit threshold in any fixture\");\nif (motifCount === 0) throw new Error(\"no workflow motif recurred across two variants of one task family in any fixture\");\nconsole.log(`validated ${reports.length} generated improvement report(s), ${relationshipCount} theme relationship(s), ${motifCount} workflow motif(s) and ${spans.length} canonical spans`);\n","sourceCodeStart":316,"sourceCodeEnd":341,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/packages/shared/contracts/scripts/validate-continuous-improvement.mjs#L316-L341","documentation":"After validating improvement reports, the script requires the canonical span fixture to be a non-empty array; otherwise there are no spans to validate against the span schema. An empty or missing spans value is treated as a broken fixture rather than a vacuous pass.","triggerScenarios":"Running validate-continuous-improvement.mjs when the spans fixture is undefined, not an array, or an empty array — e.g. the fixture file failed to load, exports the wrong key, or its span list was emptied.","commonSituations":"Renaming the export key in the span fixture file; a fixture regeneration script that wrote zero spans; loading the fixture with a path that resolved to an empty/different module.","solutions":["Check that the spans fixture file loads and exports a non-empty array under the key the script reads.","Regenerate the span fixture if a generator produced zero spans.","Verify the fixture path/require at the top of the script points at the intended file.","Inspect the fixture for a schema change that made the loader filter out all spans."],"exampleFix":"// before: export const spans = [];\n// after: fixture regenerated with real spans\nexport const spans = [/* canonical spans */];","handlingStrategy":"validation","validationCode":"import { spans } from \"./fixtures/spans.mjs\";\nif (!Array.isArray(spans) || spans.length === 0)\n  throw new Error(\"span fixture must export a non-empty array\");","typeGuard":"function isNonEmptySpanArray(v) {\n  return Array.isArray(v) && v.length > 0;\n}","tryCatchPattern":"try {\n  const spans = loadSpanFixture();\n  if (!Array.isArray(spans) || spans.length === 0) throw new Error(\"empty span fixture\");\n} catch (err) {\n  console.error(`span fixture unusable: ${err.message}`);\n  process.exit(1);\n}","preventionTips":["Assert non-empty fixtures at generation time, not only at validation time.","Keep export keys stable; rename via search-and-replace across loader and fixture.","Add a smoke test that imports every fixture and checks basic shape."],"tags":["fixture-validation","empty-fixture","spans"],"backgroundTag":"empty-required-field","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"}