From 320afc42c1617473c1412984bf85ba6d6f2eda08 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Tue, 19 May 2026 09:23:17 +0100 Subject: [PATCH] Move render JSON behind diagnostics --- docs/obs-spout-streaming.md | 9 ++++++--- docs/sensor-fusion-architecture.md | 9 +++++---- docs/typed-visual-state.md | 2 +- localcast/diagnostics/render_frame_json.py | 15 +++++++++++++++ localcast/diagnostics/spout_output.py | 5 +++-- localcast/sensor_fusion/render_bridge.py | 10 ---------- scripts/sensor_fusion.py | 3 ++- state/evidence.jsonl | 1 + 8 files changed, 33 insertions(+), 21 deletions(-) create mode 100644 localcast/diagnostics/render_frame_json.py diff --git a/docs/obs-spout-streaming.md b/docs/obs-spout-streaming.md index 0889518..719ef0d 100644 --- a/docs/obs-spout-streaming.md +++ b/docs/obs-spout-streaming.md @@ -2,9 +2,9 @@ ## Objective -Publish the live visual fusion state as a named GPU texture that OBS can receive through the Spout2 plugin. +Publish the diagnostic visual fusion state as a named GPU texture that OBS can receive through the Spout2 plugin. -This is the deadline stream surface. It is not a preview window and it is not a desktop-capture workaround. LocalCastBridge emits a typed render-frame packet; the Spout sink turns that packet into a GPU texture named for OBS. +This is the deadline diagnostic stream surface. It is not a preview window and it is not a desktop-capture workaround. LocalCastBridge emits a typed render-frame packet; the Spout sink turns that packet into a GPU texture named for OBS. ## Current Mechanism @@ -18,7 +18,10 @@ flowchart TD F --> G["OBS Spout2 Capture"] ``` -Aquarium Engine remains the intended authority for dense brush/splat rendering. The useful boundary is the typed `localcast.visual.render_frame` CultCache document: Aquarium can replace the OpenGL renderer behind the same packet contract without changing capture, fusion, timing, or OBS ingestion. +Aquarium Engine remains the intended authority for dense brush/splat rendering. +The useful diagnostic boundary is the typed `localcast.visual.render_frame` +CultCache document; the production boundary should be the native typed packet +and CultNet schema, not Python file polling. The deadline sink borrows the Zyphos brush rule rather than pretending points are enough: each render point lowers into a compact anisotropic screen brush with center, radii, rotation, and color. That shape mirrors Aquarium's bounded brush/splat direction while keeping the stream path simple enough to verify under pressure. diff --git a/docs/sensor-fusion-architecture.md b/docs/sensor-fusion-architecture.md index d5e6c44..cde959f 100644 --- a/docs/sensor-fusion-architecture.md +++ b/docs/sensor-fusion-architecture.md @@ -136,9 +136,10 @@ LocalCastBridge TrackCache ``` `RenderFramePacket` is the diagnostic Python in-process shape. The diagnostic -file boundary is a typed CultCache MessagePack document. The production live -boundary is native typed state plus CultNet `document_put`; JSON render-frame -files are compatibility scaffolding only. +file boundary is a typed CultCache MessagePack document. Compatibility JSON +read/write now lives under `localcast.diagnostics.render_frame_json`; the +production packet module does not own file serialization. The production live +boundary is native typed state plus CultNet `document_put`. Clap calibration events use the same typed-state rule. A clap is not every sharp audio transient. The detector first finds a sharp broadband audio onset in the @@ -191,7 +192,7 @@ The Spout/audio overlay applies the same rule at the consumer boundary. If the v 8. Record an observation run from the two PS3 Eyes into typed CultCache docs. 9. Feed `RenderFramePacket` and the multi-LOD scene cache into Aquarium Engine. 10. Publish the render target as a Spout2 sender and receive it in OBS. -11. Replace compatibility JSON render-frame paths once no deadline script depends on them. +11. Delete compatibility JSON render-frame paths once no diagnostic script depends on them. ## References diff --git a/docs/typed-visual-state.md b/docs/typed-visual-state.md index 119a8c1..8584052 100644 --- a/docs/typed-visual-state.md +++ b/docs/typed-visual-state.md @@ -114,7 +114,7 @@ That does not make the SRT feed disappear into the point renderer. It makes the - Keep: typed CultCache document contracts and MessagePack payloads. - Keep temporarily: JSON heartbeat for human shell checks. -- Cut next: JSON render-frame polling once no script depends on it. +- Cut next: JSON render-frame polling now that it is isolated under diagnostics. - Do not add a second scene authority. Sensor fusion owns world claims; renderer owns pixels. - Do not make OBS synchronize separate sources. Aquarium receives synchronized visual/audio documents and emits the OBS-facing package. - Do not treat the neighbor SRT video feed as untimed scenery. It is a presentation artifact and belongs in the same sync status as audio and render frames. diff --git a/localcast/diagnostics/render_frame_json.py b/localcast/diagnostics/render_frame_json.py new file mode 100644 index 0000000..2cc1dd2 --- /dev/null +++ b/localcast/diagnostics/render_frame_json.py @@ -0,0 +1,15 @@ +from __future__ import annotations + +import json +from pathlib import Path + +from localcast.sensor_fusion.render_bridge import RenderFramePacket + + +def write_render_frame_json(path: Path, frame: RenderFramePacket) -> None: + path.parent.mkdir(parents=True, exist_ok=True) + path.write_text(json.dumps(frame.to_dict(), indent=2), encoding="utf-8") + + +def load_render_frame_json(path: Path) -> RenderFramePacket: + return RenderFramePacket.from_dict(json.loads(path.read_text(encoding="utf-8"))) diff --git a/localcast/diagnostics/spout_output.py b/localcast/diagnostics/spout_output.py index 5d542d7..d243ae6 100644 --- a/localcast/diagnostics/spout_output.py +++ b/localcast/diagnostics/spout_output.py @@ -12,7 +12,8 @@ import numpy as np from localcast.sensor_fusion.audio_overlay import AudioVisualSyncStatus, overlay_audio_events, with_remote_video_status from localcast.sensor_fusion.media_artifacts import remote_video_artifact_for_present_time -from localcast.sensor_fusion.render_bridge import RenderFramePacket, RenderPointPacket, load_render_frame +from localcast.sensor_fusion.render_bridge import RenderFramePacket, RenderPointPacket +from localcast.diagnostics.render_frame_json import load_render_frame_json from localcast.diagnostics.visual_cache import CultStreamStatus, get_live_render_frame, put_stream_status @@ -71,7 +72,7 @@ class RenderFrameFileSource: if self.path.exists(): mtime_ns = self.path.stat().st_mtime_ns if self._frame is None or mtime_ns != self._mtime_ns: - self._frame = load_render_frame(self.path) + self._frame = load_render_frame_json(self.path) self._mtime_ns = mtime_ns return self._frame if not self.demo_if_missing: diff --git a/localcast/sensor_fusion/render_bridge.py b/localcast/sensor_fusion/render_bridge.py index 7d10589..a541674 100644 --- a/localcast/sensor_fusion/render_bridge.py +++ b/localcast/sensor_fusion/render_bridge.py @@ -1,8 +1,6 @@ from __future__ import annotations from dataclasses import dataclass -import json -from pathlib import Path import numpy as np @@ -90,10 +88,6 @@ class RenderFramePacket: "points": [point.to_dict() for point in self.points], } - def write_json(self, path: Path) -> None: - path.parent.mkdir(parents=True, exist_ok=True) - path.write_text(json.dumps(self.to_dict(), indent=2), encoding="utf-8") - @staticmethod def from_dict(data: dict) -> "RenderFramePacket": return RenderFramePacket( @@ -111,10 +105,6 @@ class RenderFramePacket: ) -def load_render_frame(path: Path) -> RenderFramePacket: - return RenderFramePacket.from_dict(json.loads(path.read_text(encoding="utf-8"))) - - def lower_points_to_render_frame( points: tuple[TriangulatedPoint, ...], config: RenderBridgeConfig, diff --git a/scripts/sensor_fusion.py b/scripts/sensor_fusion.py index eec5dbf..148582f 100644 --- a/scripts/sensor_fusion.py +++ b/scripts/sensor_fusion.py @@ -15,6 +15,7 @@ from localcast.sensor_fusion import ( load_fusion_config, lower_points_to_render_frame, ) +from localcast.diagnostics.render_frame_json import write_render_frame_json @@ -49,7 +50,7 @@ def fuse_file(args) -> None: created_monotonic_ns=args.created_ns, ) render_frame_output = Path(args.render_frame_json) - frame.write_json(render_frame_output) + write_render_frame_json(render_frame_output, frame) summary = { "output": str(output), "render_frame_json": None if render_frame_output is None else str(render_frame_output), diff --git a/state/evidence.jsonl b/state/evidence.jsonl index 6995637..2828ebd 100644 --- a/state/evidence.jsonl +++ b/state/evidence.jsonl @@ -59,3 +59,4 @@ {"ts": "2026-05-19T08:07:19+00:00", "type": "implementation", "status": "ok", "note": "Native reservoir ABI now exposes indexed reads over the total rolling buffer and typed views via localcast_reservoir_sample_at and localcast_reservoir_view_sample_at, allowing Aquarium/Faust consumers to walk the live window without owning private histories."} {"ts": "2026-05-19T09:11:35+01:00", "type": "implementation", "status": "ok", "note": "Native reservoir provenance guard added: LocalcastSampleHandle now carries flags/reserved fields, diagnostic samples are rejected by localcast_reservoir_push and LocalcastRuntime producer calls, and tests prove fallback/diagnostic handles cannot enter the live rolling buffer."} {"ts": "2026-05-19T09:25:00+01:00", "type": "implementation", "status": "partial", "note": "Python visual CultCache file adapter quarantined under localcast.diagnostics.visual_cache and removed from localcast.sensor_fusion exports; diagnostic producer/Spout/tests now import it explicitly. Import guard passed, but bundled Python cannot run visual-cache round-trip tests because msgpack is not installed."} +{"ts": "2026-05-19T09:36:00+01:00", "type": "implementation", "status": "ok", "note": "RenderFramePacket no longer owns JSON file serialization. Compatibility JSON load/write moved to localcast.diagnostics.render_frame_json, diagnostic Spout and sparse-fusion scripts import it explicitly, and tests/import guards prove the production packet module is typed data only."}