{"record":{"id":"0ba496b874e759d8","repo":"affaan-m/ECC","slug":"label-is-outside-its-source-duration","errorCode":null,"errorMessage":"{label} is outside its source duration","messagePattern":"(.+?) is outside its source duration","errorType":"validation","errorClass":"ContractError","httpStatus":null,"severity":"error","filePath":"skills/taste-application/scripts/tasteforge/contract.py","lineNumber":34,"sourceCode":"\n\nclass ContractError(ValueError):\n    \"\"\"The dry-run bundle is incomplete or has lost taste specificity.\"\"\"\n\n\ndef _is_finite_real(value: Any) -> bool:\n    return isinstance(value, (int, float)) and not isinstance(value, bool) and math.isfinite(value)\n\n\ndef _validate_media_time(value: Any, source_duration: Any, *, label: str) -> None:\n    if not _is_finite_real(source_duration):\n        raise ContractError(f\"{label} has an invalid finite source duration\")\n    source_duration = cast(float, source_duration)\n    if float(source_duration) <= 0:\n        raise ContractError(f\"{label} has an invalid finite source duration\")\n    if (not _is_finite_real(value) or float(value) < 0\n            or float(value) > float(source_duration)):\n        raise ContractError(f\"{label} is outside its source duration\")\n\n\ndef _validate_numeric_evidence(value: Any, *, label: str) -> None:\n    if isinstance(value, bool):\n        raise ContractError(f\"{label} contains a boolean numeric value\")\n    if isinstance(value, (int, float)):\n        if not math.isfinite(value):\n            raise ContractError(f\"{label} contains a non-finite numeric value\")\n    elif isinstance(value, dict):\n        for nested in value.values():\n            _validate_numeric_evidence(nested, label=label)\n    elif isinstance(value, list):\n        for nested in value:\n            _validate_numeric_evidence(nested, label=label)\n\n\ndef _validate_probe_evidence(probe: Any, source_duration: float, *, label: str) -> None:\n    if not isinstance(probe, dict):","sourceCodeStart":16,"sourceCodeEnd":52,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/skills/taste-application/scripts/tasteforge/contract.py#L16-L52","documentation":"_validate_media_time raises this when the time value itself is invalid: not a finite real number, negative, or greater than the source duration. It ensures every media timestamp (sample times, scene changes, cut points) lies within [0, source_duration].","triggerScenarios":"validate_genre_specs / validate_effect_recipe / validate_provenance / validate_artifact_receipt called with a time value that is None, a string, NaN/Inf, negative, or exceeding the declared source duration (e.g. timestamp 95.0 against a 90.0s source).","commonSituations":"Hand-tuned cut points beyond the clip length, timestamps in milliseconds confused with seconds, probe entries copied from a different (longer) source file, or string-typed timestamps in JSON.","solutions":["Clamp or correct the timestamp to lie within 0..source_duration in the source document.","Verify units: ensure all times are seconds, not milliseconds, and consistent across the document.","Confirm the timestamp belongs to the same media file whose duration is declared.","Convert string timestamps to numbers at authoring time so _is_finite_real passes."],"exampleFix":"// before\n\"sample_times\": [\"0.5\", 92000, -1.0]  // strings, ms, negative\n// after\n\"sample_times\": [0.5, 92.0, 0.0]  // seconds, within duration","handlingStrategy":"validation","validationCode":"def times_in_range(times, dur):\n    return all(isinstance(t, (int, float)) and not isinstance(t, bool)\n               and 0 <= float(t) <= dur for t in times)","typeGuard":"def is_valid_media_time(t, dur) -> bool:\n    return (isinstance(t, (int, float)) and not isinstance(t, bool)\n            and math.isfinite(t) and 0 <= t <= dur)","tryCatchPattern":"try:\n    validate_effect_recipe(recipe, source_duration=dur)\nexcept ContractError as e:\n    if 'outside its source duration' in str(e):\n        clamp_recipe_times(recipe, dur)\n    else:\n        raise","preventionTips":["Keep all timestamps in seconds consistently (not ms)","Clamp cut/sample times to [0, duration] when authoring","Never copy timestamps between media files with different durations","Convert string timestamps to numbers at document-creation time"],"tags":["python","validation","numeric","media"],"backgroundTag":"value-out-of-range","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"}