{"record":{"id":"45848419c77ae4dc","repo":"affaan-m/ECC","slug":"source-audio-placement-must-preserve-native-timing","errorCode":null,"errorMessage":"source/audio placement must preserve native timing","messagePattern":"source/audio placement must preserve native timing","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"skills/taste-application/scripts/tasteforge/integration.py","lineNumber":261,"sourceCode":"    if not track.startswith(\"audio\" if audio else \"video\"):\n        raise ValueError(\"wrong source/audio track kind\")\n    if track not in tracks or index >= len(tracks[track]):\n        raise ValueError(\"source binding has no native clip\")\n    clip = tracks[track][index]\n    _artifact(item[\"media\"])\n    if item[\"media\"][\"path\"] != clip[\"path\"]:\n        raise ValueError(\"source path does not match native clip\")\n    if _rate(item[\"fps\"]) != _rate(baseline[\"fps\"]):\n        raise ValueError(\"source fps/retime ambiguity\")\n    duration = clip[\"end\"] - clip[\"start\"]\n    capacity = _integer(item[\"media_frames\"], 1)\n    if capacity != clip[\"left_offset\"] + duration + clip[\"right_offset\"]:\n        raise ValueError(\"source capacity does not match native offsets\")\n    source = _range(item[\"source_range\"], [clip[\"left_offset\"], clip[\"left_offset\"] + duration])\n    target = _range(item[\"timeline_range\"], [clip[\"start\"], clip[\"end\"]])\n    mapped = [clip[\"start\"] + f - clip[\"left_offset\"] for f in source]\n    if mapped != target or (audio and target != [clip[\"start\"], clip[\"end\"]]):\n        raise ValueError(\"source/audio placement must preserve native timing\")\n    return track, index\n\n\ndef _preserved_stack(protected: Any, tracks: dict, bounds: list[int]) -> list[dict]:\n    if not isinstance(protected, list) or not protected:\n        raise ValueError(\"protected intervals must be explicit and nonempty\")\n    for item in protected:\n        _object(item, {\"range\", \"reason\"})\n        _range(item[\"range\"], bounds)\n        _text(item[\"reason\"])\n        if not any(_overlap(item[\"range\"], [c[\"start\"], c[\"end\"]])\n                   for key, clips in tracks.items() if key.startswith(\"video\") for c in clips):\n            raise ValueError(\"protected interval has no original video stack\")\n    return [{\"track\": track, \"clip_index\": index, \"clip\": copy.deepcopy(clip),\n             \"clip_sha256\": _digest(clip)}\n            for track, clips in sorted(tracks.items()) for index, clip in enumerate(clips)\n            if any(_overlap(p[\"range\"], [clip[\"start\"], clip[\"end\"]]) for p in protected)]\n","sourceCodeStart":243,"sourceCodeEnd":279,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/skills/taste-application/scripts/tasteforge/integration.py#L243-L279","documentation":"Raised by _binding when the binding's source_range does not map onto its declared timeline_range under the clip's native offset mapping (mapped = clip.start + f - left_offset), or when an audio binding's timeline_range is not the clip's full [start, end]. Placement must preserve the native clip's timing exactly.","triggerScenarios":"source_range that starts after left_offset or extends past left_offset+duration; timeline_range shifted, trimmed, or speed-changed relative to [clip.start, clip.end]; an audio binding with a partial timeline_range.","commonSituations":"Templates applying speed ramps or trims that native application cannot represent; bindings generated with slip/slide edits; audio elements trimmed to a sub-range of the underlying clip.","solutions":["Set source_range within [left_offset, left_offset+duration] and timeline_range = [clip['start'] + f - clip['left_offset'] for f in source_range].","For audio bindings, ensure timeline_range equals exactly [clip['start'], clip['end']] with no trimming.","Remove or externalize any speed/retime edits so the mapping is identity before calling build_application_bundle."],"exampleFix":"// before\nsource_range=[10, 50], timeline_range=[0, 40]  # shifted, not native-aligned\n// after\nsource_range=[10, 50], timeline_range=[clip['start'] - clip['left_offset'] + 10, clip['start'] - clip['left_offset'] + 50]","handlingStrategy":"validation","validationCode":"for item in bindings:\n    clip = snapshot['timeline_readback'][item['track']][item['clip_index']]\n    duration = clip['end'] - clip['start']\n    src = item['source_range']; tgt = item['timeline_range']\n    assert clip['left_offset'] <= src[0] and src[1] <= clip['left_offset'] + duration\n    mapped = [clip['start'] + f - clip['left_offset'] for f in src]\n    assert mapped == tgt, 'placement does not preserve native timing'","typeGuard":"def placement_is_native(item, clip) -> bool:\n    src = item['source_range']; tgt = item['timeline_range']\n    mapped = [clip['start'] + f - clip['left_offset'] for f in src]\n    return mapped == tgt","tryCatchPattern":"try:\n    bundle = build_application_bundle(...)\nexcept ValueError as e:\n    if 'source/audio placement must preserve native timing' in str(e):\n        log.error('non-native placement; remove speed/trim edits from binding', item=item)\n    raise","preventionTips":["Model speed changes and audio trims outside the native application path","Compute timeline_range by mapping source_range through the clip offset","Verify mapped == timeline_range in unit tests for every generated binding"],"tags":["binding","timing","validation"],"backgroundTag":"invalid-state-transition","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"}