HarnessRouter Community Edition: the self-hosted, Apache-2.0 edition of the unified interface for agent harnesses. Run Codex, Claude Code, Hermes, PI, DSH, and more through one API, with sessions, streaming, files, cancellation, and failure handling. Implements the Unified Harness Protocol (UHP), an open standard. Your keys, your infrastructure.
Python agent-apiagent-frameworkagent-harnessai-agentsai-infrastructurecoding-agentconformance-testingdeepseek-harnessharness-engineeringhermesllmopen-protocolopen-sourceopen-standardpi-coding-agentself-hosteduhpunified-apiunified-harness-protocolunified-interface
fix(media): a sound was the one track nobody checked, and a silent film reported success
richard-epsilla0821eab51e0d
diff --git a/gateway/app.py b/gateway/app.pyindex 8f93b6b5..ca5a00de 100644--- a/gateway/app.py+++ b/gateway/app.py@@ -9746,9 +9746,25 @@ async def _media_tool_call(name: str, args: dict, hid: str, sid: str, org: str,a, b, _ = media_plane.shot_window({"inS": s.get("in_s"), "outS": s.get("out_s")}, m)shots.append({"elementId": eid, "inS": a, "outS": b})- audio = [{"elementId": str(a.get("element_id") or ""),- "startS": float(a.get("start_s") or 0.0),- "gainDb": float(a.get("gain_db") or 0.0)} for a in audio_in]+ # CHECKED THE SAME WAY THE SHOTS ARE. Written blind, a bed naming an element that+ # is gone — an id that changed when the clip was placed again — stayed in the+ # document, was dropped without a word at export, and the film came out silent.+ audio = []+ for i, a in enumerate(audio_in, 1):+ eid = str(a.get("element_id") or "")+ m = media_plane.media_of(by_id.get(eid) or {})+ if not m:+ warnings.append(f"Sound {i} names {eid}, which is not on the canvas.")+ continue+ if m.get("kind") != "audio":+ warnings.append(f"Sound {i} names {eid}, which is a {m.get('kind')} rather "+ f"than a sound. Put it in `shots` or `overlays`.")+ continue+ if m.get("status") != "ready":+ warnings.append(f"Sound {i} ({eid}) is still rendering — export will refuse "+ f"until it lands.")+ audio.append({"elementId": eid, "startS": float(a.get("start_s") or 0.0),+ "gainDb": float(a.get("gain_db") or 0.0)})# A LAYER IS PLACED, NOT QUEUED. An overlay names the moment on the film's clock# where it appears, so adding one never moves the shots underneath it.overlays = []@@ -9843,12 +9859,23 @@ async def _media_export_start(hid: str, sid: str, org: str, entry_id: str,if total > float(cap.get("max_total_s") or 600):raise media_plane.ExportRefused(f"That film is {total:.0f}s and the limit here is {cap.get('max_total_s')}s.")- audio_plan = [{"media_id": str(media_plane.media_of(by_id.get(a.get("elementId")) or {})- .get("mediaId") or ""),- "start_s": float(a.get("startS") or 0.0),- "gain_db": float(a.get("gainDb") or 0.0)}- for a in tl.get("audio") or []]- audio_plan = [a for a in audio_plan if a["media_id"]]+ # The sound under the film. Refused rather than dropped, for the same reason a shot is: a+ # film delivered without the music somebody asked for is not the film, and the silent version+ # used to report success.+ audio_plan: list[dict] = []+ for i, a in enumerate(tl.get("audio") or [], 1):+ m = media_plane.media_of(by_id.get(a.get("elementId")) or {})+ if not m:+ raise media_plane.ExportRefused(+ f"Sound {i} is no longer on the canvas. Take it off the timeline, or put the "+ f"clip back, before the film is cut.")+ if m.get("status") != "ready" or not m.get("mediaId"):+ raise media_plane.ExportRefused(+ f"Sound {i} is still rendering. Everything in the film has to have landed "+ f"before it can be cut.")+ audio_plan.append({"media_id": str(m["mediaId"]),+ "start_s": float(a.get("startS") or 0.0),+ "gain_db": float(a.get("gainDb") or 0.0)})# The layers above the cut. A layer whose clip has not landed is refused for the same reason# a shot is: half a film is not a film, and the alternative is exporting it silently missing.diff --git a/gateway/tests/test_media_mcp.py b/gateway/tests/test_media_mcp.pyindex 8ad4c586..d4d3318c 100644--- a/gateway/tests/test_media_mcp.py+++ b/gateway/tests/test_media_mcp.py@@ -2114,6 +2114,43 @@ def test_a_layer_rides_over_the_cut_without_moving_it(client, harness, session,assert abs(rec["seconds"] - 2.0) < 0.5, rec+def test_a_sound_that_is_no_longer_on_the_canvas_stops_the_export(client, harness, session,+ provider):+ """A film delivered without the music somebody asked for is not the film.++ Audio was the one track written into the timeline without being checked. An id that had gone+ stale — which happens the moment a clip is placed again — stayed in the document, was dropped+ without a word at export, and the silent film reported success. Found by running a real brief+ end to end: the agent noticed its own audio ids had changed. The code never would have.+ """+ tok = _cred(harness, session)+ a, _b = _two_ready_clips(client, tok, provider, session)+ _ok(_call(client, tok, "set_timeline", {"shots": [{"element_id": a}]}))+ # Reach past the tool and put a sound in the document naming something that is not there —+ # exactly the state a re-placed clip leaves behind.+ scene = asyncio.run(app._media_scene_read(session))+ scene["timeline"]["audio"] = [{"elementId": "el_gone", "startS": 0.0, "gainDb": 0.0}]+ asyncio.run(app._media_scene_write(session, scene))++ err = _call(client, tok, "export_timeline", {})+ assert err.get("isError"), err+ assert "Sound 1 is no longer on the canvas" in json.dumps(err), err+++def test_set_timeline_says_when_a_sound_names_the_wrong_thing(client, harness, session, provider):+ """The warning a shot gets, a sound now gets too — including being handed a video."""+ tok = _cred(harness, session)+ a, _b = _two_ready_clips(client, tok, provider, session)+ out = _ok(_call(client, tok, "set_timeline", {+ "shots": [{"element_id": a}],+ "audio": [{"element_id": "el_nope"}, {"element_id": a}]}))+ warned = " ".join(out.get("warnings") or [])+ assert "not on the canvas" in warned, out+ assert "rather than a sound" in warned, out+ scene = asyncio.run(app._media_scene_read(session))+ assert scene["timeline"]["audio"] == [], scene["timeline"]++def test_a_layer_that_has_not_landed_refuses_the_export_like_a_shot(client, harness, session,provider):"""Half a film is not a film. A layer still rendering stops the export saying so, rather