{"record":{"id":"f3ea8dafe19c2665","repo":"affaan-m/ECC","slug":"no-repeat-plan-requires-more-unique-source-clips","errorCode":null,"errorMessage":"no-repeat plan requires more unique source clips","messagePattern":"no-repeat plan requires more unique source clips","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"skills/taste-application/scripts/tasteforge/apply.py","lineNumber":91,"sourceCode":"        assigned = boundary\n    if assigned < target_frames:\n        frame_counts.append(target_frames - assigned)\n\n    rate = timeline.fps_fraction(fps)\n    sources: dict[str, tuple[dict[str, Any], int]] = {}\n    for clip in media:\n        path = str(Path(clip[\"path\"]).expanduser().resolve())\n        # Floor rational capacity: rounding up could read past the source end.\n        capacity = math.floor(Fraction(str(clip[\"duration\"])) * rate)\n        # Accept a boundary serialized as a float only when the frame duration\n        # itself compares within the supplied duration; no broad epsilon.\n        if float((capacity + 1) / rate) <= clip[\"duration\"]:\n            capacity += 1\n        if path in sources:\n            raise ValueError(\"no-repeat media must contain unique normalized source paths\")\n        sources[path] = ({**clip, \"path\": path}, capacity)\n    if len(sources) < len(frame_counts):\n        raise ValueError(\"no-repeat plan requires more unique source clips\")\n    assignments = []\n    for (clip, capacity), count in zip(sources.values(), frame_counts):\n        if capacity < count:\n            raise ValueError(\"source clip is too short for its no-repeat cadence slot\")\n        assignments.append((clip, count))\n    return assignments\n\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 = [","sourceCodeStart":73,"sourceCodeEnd":109,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/skills/taste-application/scripts/tasteforge/apply.py#L73-L109","documentation":"After building the unique-source map, `_strict_assign` requires at least one unique media clip per planned frame count. If there are fewer unique sources than frame slots, a strict no-repeat plan is impossible and it raises. This is the count-level failure, distinct from the per-slot capacity failure (937).","triggerScenarios":"Calling `apply_local` with e.g. 2 unique media clips while the target duration and cadence produce 5 frame slots: `len(sources) < len(frame_counts)`.","commonSituations":"Very long target duration planned from many short shots but only a handful of source clips supplied; user expects clips to loop but the strict no-repeat mode forbids it; media folder only partially copied.","solutions":["Add more unique source clips to the media list","Shorten the target duration so fewer frame slots are needed","Switch to a mode that permits repeats if strict no-repeat is not a requirement","Use a slower shot cadence (longer mean_shot) so fewer slots are planned"],"exampleFix":"# before: 2 clips, target needs 5 slots\napply_local(media=media2, target=30.0)\n# after: add clips or reduce target\napply_local(media=media5, target=10.0)","handlingStrategy":"validation","validationCode":"unique = {norm(c[\"path\"]): c for c in media}\nplanned = plan_shots(cadence, target)\nif len(unique) < len(planned):\n    raise ValueError(\"need at least one unique clip per cadence slot\")","typeGuard":null,"tryCatchPattern":"try:\n    report = apply_local(...)\nexcept ValueError as exc:\n    if \"more unique source clips\" in str(exc):\n        target = shrink_target_to_fit(len(media), cadence, fps)\n        report = apply_local(...)  # retry with shorter target\n    else:\n        raise","preventionTips":["Estimate the number of slots (target / mean_shot) and ensure media count covers it","Warn users when the strict no-repeat mode has few unique sources","Shorten target duration or lengthen mean_shot when the media library is small"],"tags":["media","no-repeat","capacity"],"backgroundTag":"empty-result-set","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"}