{"record":{"id":"9011f5b8c3156a6f","repo":"affaan-m/ECC","slug":"cadence-has-no-measured-shot-durations-to-plan-from","errorCode":null,"errorMessage":"cadence has no measured shot durations to plan from","messagePattern":"cadence has no measured shot durations to plan from","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"skills/taste-application/scripts/tasteforge/apply.py","lineNumber":116,"sourceCode":"\n\n\ndef plan_shots(cadence: dict[str, Any], target_duration: float) -> list[float]:\n    \"\"\"Propose shot durations filling ``target_duration`` at this cadence.\n\n    Samples from the reference's own shot-length distribution (seeded, like\n    the recovered ``Cadence.plan_shots``) so the plan inherits rhythm\n    variance instead of flattening into evenly spaced clips.\n    \"\"\"\n    target_duration = _positive(target_duration, \"target duration\")\n    durations = [\n        _positive(s[\"duration\"], \"cadence shot duration\")\n        for s in cadence.get(\"shots\", [])\n        if isinstance(s, dict) and _positive(s.get(\"duration\"), \"cadence shot duration\") > _MIN_SHOT\n    ]\n    if not durations:\n        if \"mean_shot\" not in cadence:\n            raise ValueError(\"cadence has no measured shot durations to plan from\")\n        durations = [max(_positive(cadence.get(\"mean_shot\"), \"mean shot duration\"), 1.0)]\n\n    rng = random.Random(7)  # deterministic, mirrors numpy default_rng(7)\n    out: list[float] = []\n    acc = 0.0\n    while acc < target_duration:\n        d = rng.choice(durations)\n        remaining = target_duration - acc\n        if remaining < d * 0.5:\n            break\n        d = min(d, remaining)\n        out.append(round(d, 3))\n        acc += d\n    if not out:\n        out = [round(target_duration, 3)]\n    return out\n\n","sourceCodeStart":98,"sourceCodeEnd":134,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/skills/taste-application/scripts/tasteforge/apply.py#L98-L134","documentation":"`plan_shots` builds shot durations from `cadence['shots']` when available; if the cadence has no usable measured shots AND no `mean_shot` fallback value, there is nothing to plan from, so it raises. Note the inner loop already validates each shot duration via `_positive`, so only valid positive shots are kept.","triggerScenarios":"`plan_shots({}, 10.0)` or a cadence.json like `{}` / `{\"shots\": []}` / `{\"shots\": [{\"duration\": 0}]}` (all filtered out) with no `mean_shot` key present.","commonSituations":"An interrupted measurement pipeline that wrote an empty cadence.json; a pack built before any shots were detected; hand-authored cadence files that omit both `shots` and `mean_shot`; all shot durations filtered out because they were 0/invalid.","solutions":["Provide `mean_shot` in the cadence dict as a fallback (a positive number)","Regenerate cadence.json by running the measurement step on the source edit so `shots` is populated","Guard before calling: `if not cadence.get('shots') and 'mean_shot' not in cadence: raise`","Fix the shot detector so at least some valid (positive, > _MIN_SHOT) durations are produced"],"exampleFix":"// before\nplan_shots({}, 10.0)\n// after\nplan_shots({\"mean_shot\": 2.5}, 10.0)","handlingStrategy":"type-guard","validationCode":"if not isinstance(cadence, dict) or not (cadence.get(\"shots\") or \"mean_shot\" in cadence):\n    raise ValueError(\"cadence has no shots or mean_shot\")","typeGuard":"def has_plannable_cadence(cadence) -> bool:\n    return isinstance(cadence, dict) and (\n        any(isinstance(s, dict) and isinstance(s.get(\"duration\"), (int, float))\n            for s in cadence.get(\"shots\", []))\n        or isinstance(cadence.get(\"mean_shot\"), (int, float))\n    )","tryCatchPattern":"try:\n    planned = plan_shots(cadence, target)\nexcept ValueError as exc:\n    if \"no measured shot durations\" in str(exc):\n        planned = plan_shots({\"mean_shot\": DEFAULT_MEAN_SHOT}, target)\n    else:\n        raise","preventionTips":["Always run the cadence measurement step before applying","Validate cadence.json against a schema requiring shots or mean_shot","Provide a mean_shot default for packs with no measurable shots"],"tags":["cadence","empty","missing-data"],"backgroundTag":"missing-required-argument","analyzedSha":"8321021c54d670126ce3b2969d5deb880b4b0c2a","analyzedAt":"2026-09-16T10:08:13.343Z","contentChangedAt":"2026-09-16T10:08:13.343Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}