affaan-m/ECC · error · ContractError

is outside its source duration

Error message

{label} is outside its source duration

What it means

_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].

Solutions

  1. Clamp or correct the timestamp to lie within 0..source_duration in the source document.
  2. Verify units: ensure all times are seconds, not milliseconds, and consistent across the document.
  3. Confirm the timestamp belongs to the same media file whose duration is declared.
  4. Convert string timestamps to numbers at authoring time so _is_finite_real passes.

Example fix

// before
"sample_times": ["0.5", 92000, -1.0]  // strings, ms, negative
// after
"sample_times": [0.5, 92.0, 0.0]  // seconds, within duration
Defensive patterns

Strategy: validation

Validate before calling

def times_in_range(times, dur):
    return all(isinstance(t, (int, float)) and not isinstance(t, bool)
               and 0 <= float(t) <= dur for t in times)

Type guard

def is_valid_media_time(t, dur) -> bool:
    return (isinstance(t, (int, float)) and not isinstance(t, bool)
            and math.isfinite(t) and 0 <= t <= dur)

Try / catch

try:
    validate_effect_recipe(recipe, source_duration=dur)
except ContractError as e:
    if 'outside its source duration' in str(e):
        clamp_recipe_times(recipe, dur)
    else:
        raise

Prevention

When it happens

Trigger: 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).

Common situations: 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.

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


AI-assisted analysis of affaan-m/ECC@8321021c54 (2026-09-16). Data as JSON: /api/errors/0ba496b874e759d8. Report an issue: GitHub.

Appendix: source

Thrown at skills/taste-application/scripts/tasteforge/contract.py:34


class ContractError(ValueError):
    """The dry-run bundle is incomplete or has lost taste specificity."""


def _is_finite_real(value: Any) -> bool:
    return isinstance(value, (int, float)) and not isinstance(value, bool) and math.isfinite(value)


def _validate_media_time(value: Any, source_duration: Any, *, label: str) -> None:
    if not _is_finite_real(source_duration):
        raise ContractError(f"{label} has an invalid finite source duration")
    source_duration = cast(float, source_duration)
    if float(source_duration) <= 0:
        raise ContractError(f"{label} has an invalid finite source duration")
    if (not _is_finite_real(value) or float(value) < 0
            or float(value) > float(source_duration)):
        raise ContractError(f"{label} is outside its source duration")


def _validate_numeric_evidence(value: Any, *, label: str) -> None:
    if isinstance(value, bool):
        raise ContractError(f"{label} contains a boolean numeric value")
    if isinstance(value, (int, float)):
        if not math.isfinite(value):
            raise ContractError(f"{label} contains a non-finite numeric value")
    elif isinstance(value, dict):
        for nested in value.values():
            _validate_numeric_evidence(nested, label=label)
    elif isinstance(value, list):
        for nested in value:
            _validate_numeric_evidence(nested, label=label)


def _validate_probe_evidence(probe: Any, source_duration: float, *, label: str) -> None:
    if not isinstance(probe, dict):

View on GitHub (pinned to 8321021c54)