From 34d6fad9c09d4d17c246943727524f47f203954e Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sun, 7 Jun 2026 05:26:34 +0100 Subject: [PATCH] Add Verse media transport policy --- docs/implementation-plan.md | 8 ++-- docs/network-display-sync.md | 14 +++++-- docs/perfect-machine-module-library.md | 7 ++-- docs/raven-eve-ingest.md | 23 ++++++----- docs/verse-service-contract.md | 35 ++++++++++++++--- src/Mimir.BufferSmoke/Program.cs | 14 ++++++- .../MimirNetworkTransportConfiguration.cs | 38 +++++++++++++++++-- 7 files changed, 111 insertions(+), 28 deletions(-) diff --git a/docs/implementation-plan.md b/docs/implementation-plan.md index decaf75..1ef2a19 100644 --- a/docs/implementation-plan.md +++ b/docs/implementation-plan.md @@ -652,10 +652,12 @@ a named invariant that the native runtime cannot protect yet. retention boundary when choosing a synchronized window. This makes the live metric honest: a five-second buffer target is no longer allowed to masquerade as five seconds of resident samples when body serialization/backpressure - starves a source. The next coherent cut is a CultMesh streaming organ with a - compact typed control lane, a CultCache page/shard append body lane, explicit + starves a source. The next coherent cut is a CultMesh streaming organ over + reliable UDP with a compact typed control lane, typed stream-frame media + envelopes, a CultCache page/shard append body lane, explicit cursors/backpressure, and a lossy latest-state dashboard lane; do not keep - expanding inline base64 capture pages as if they were the final transport. + expanding inline base64 capture pages or SRT/WebSocket bridge edges as if + they were the final transport. Eve now follows the same rule for its own device body: `MimirDistributedWitnessConfigurations.EveLocalSensors` and the `eve-local-sensors` Perfect Machine profile make Eve responsible for local diff --git a/docs/network-display-sync.md b/docs/network-display-sync.md index e68ff0a..653bc69 100644 --- a/docs/network-display-sync.md +++ b/docs/network-display-sync.md @@ -13,7 +13,8 @@ Authority map: - Derived state: Raven display timing is derived from the Raven audio sync signal. The display feed is not a timing authority by itself. - Forbidden writers: OBS, SRT bridge endpoints, frame-event probes, and network - receive timestamps must not decide cross-stream alignment. + receive timestamps must not decide cross-stream alignment. CultMesh reliable + UDP packet arrival is transport evidence only, not clock authority. - Shared path: local cameras, network display frames, mic channels, loopback channels, and Raven audio sync channels all enter `MimirRollingStreamBuffer` first, then the synchronized planner chooses slices. @@ -31,8 +32,8 @@ Practical shape: applies that clock-domain correction to the `raven-display` video buffer. 5. Fensalir receives aligned buffer slices and still owns composition. -`config/mimir-runtime.raven-eve.example.json` is the active setup shape for the -network producer pass: +`config/mimir-runtime.raven-eve.example.json` is the active bridge setup shape +for the network producer pass: - `raven-display` listens for Raven screen capture on SRT port `5200`, decodes through FFmpeg, and emits BGRA video samples into the runtime buffer path. @@ -41,6 +42,13 @@ network producer pass: - `eve-mic` listens for EveCanvas microphone frame-events on WebSocket port `8794`. +The target Verse shape replaces those SRT/WebSocket bridge edges with CultMesh +reliable-UDP lanes: typed `mimir.cultmesh_stream_frame.v1` envelopes for +per-frame media metadata and refs, plus bounded media body shards for payloads +too large to inline. Raven display frames remain media observations entering +the same rolling buffer; Raven sync still comes from audio evidence and +clock-domain correction, not packet arrival. + The older disabled `frame-events` example in `config/mimir-runtime.asio.example.json` remains diagnostic only. It can witness source timestamps and frame identity, but it does not carry pixels. The Scarlett diff --git a/docs/perfect-machine-module-library.md b/docs/perfect-machine-module-library.md index 4f0d91b..d19ca42 100644 --- a/docs/perfect-machine-module-library.md +++ b/docs/perfect-machine-module-library.md @@ -22,7 +22,7 @@ job-interview answer for why it belongs in the body of the machine. | Stereo depth profiles | `Mimir.Runtime` + Fensalir | SGM-shaped stereo disparity/depth profiles with libSGM as provenance for the first D3D12 lane, not a CUDA dependency. | `src/Mimir.Runtime/Synchronization/MimirStereoDepthConfiguration.cs` | | Reservoir strategies | `Mimir.Runtime` + native reservoir + Fensalir | Managed rolling buffers, native shared-edge rings, and derived GPU temporal field storage. | `src/Mimir.Runtime/Synchronization/MimirReservoirConfiguration.cs` | | Distributed witnesses | `Mimir.Runtime` + CultMesh | Raven, phone, microcontroller, Nightwing Eyes/Moves, and remote camera rig configurations for compact timing/path/visual state. | `src/Mimir.Runtime/Synchronization/MimirDistributedWitnessConfiguration.cs` | -| Network transports | `Mimir.Runtime` + CultMesh | Typed timing state, debug windows, SRT bridge media, and experimental browser transport policy plus constraint-based selection. | `src/Mimir.Runtime/Synchronization/MimirNetworkTransportConfiguration.cs`, `src/Mimir.Runtime/Synchronization/MimirNetworkTransportSelector.cs` | +| Network transports | `Mimir.Runtime` + CultMesh | Typed timing state, reliable-UDP Verse media/body lanes, debug windows, SRT bridge media, and experimental browser transport policy plus constraint-based selection. | `src/Mimir.Runtime/Synchronization/MimirNetworkTransportConfiguration.cs`, `src/Mimir.Runtime/Synchronization/MimirNetworkTransportSelector.cs` | | Authority policy | `Mimir.Runtime` | Trust decisions for Starfire loopback, Raven evidence, phone candidates, diagnostic media, and unknown nodes. | `src/Mimir.Runtime/Synchronization/MimirAuthorityPolicyConfiguration.cs`, `src/Mimir.Runtime/Synchronization/MimirAuthorityPolicyEvaluator.cs` | | Audio field configurations | `Mimir.Runtime` | Six-mic, source-based, ambisonic, and hybrid evidence field shapes. | `src/Mimir.Runtime/Synchronization/MimirAudioFieldConfiguration.cs` | | Visual fusion configurations | `Mimir.Runtime` + Fensalir | Sensor roles and fusion modes from cadence proof through full hybrid evidence. | `src/Mimir.Runtime/Synchronization/MimirVisualFusionConfiguration.cs` | @@ -41,8 +41,9 @@ job-interview answer for why it belongs in the body of the machine. program video publication. - Faust owns hot sample movement, alignment, spatialization, separation, and stem generation. -- CultMesh carries typed state surfaces; remote nodes may observe and decode, - but they do not become independent clock authorities. +- CultMesh carries typed state surfaces and reliable-UDP media/body lanes; + remote nodes may observe, decode, and stream media through the Verse, but + they do not become independent clock authorities. - OBS receives final program surfaces and stems. It does not own calibration. ## Verification Surface diff --git a/docs/raven-eve-ingest.md b/docs/raven-eve-ingest.md index 252379a..230e5e0 100644 --- a/docs/raven-eve-ingest.md +++ b/docs/raven-eve-ingest.md @@ -9,18 +9,22 @@ beside Scarlett audio and local camera sources. ## Authority Map - Owner: `Mimir.Runtime` owns decoded samples and rolling-buffer placement. -- Inputs: Raven sends H.264/MPEG-TS over SRT to Starfire port `5200`; Eve sends - camera frame-events over WebSocket port `8793`; Eve sends microphone - frame-events over WebSocket port `8794`; Scarlett/ASIO carries audio and sync - evidence. +- Inputs: Raven currently sends H.264/MPEG-TS over the SRT bridge to Starfire + port `5200`; Eve currently sends camera frame-events over WebSocket port + `8793`; Eve currently sends microphone frame-events over WebSocket port + `8794`; Scarlett/ASIO carries audio and sync evidence. The target Verse shape + is CultMesh reliable UDP: typed stream-frame envelopes plus bounded body + shards for media, with compact state/cursors/backpressure beside them. - Outputs: `raven-display`, `eve-camera`, and `eve-mic` emit `MimirStreamSample` records with video or audio descriptors. - Derived state: network arrival timestamps are capture metadata only. Raven audio-in-Scarlett remains the timing witness for global alignment. -- Forbidden writers: OBS, FFmpeg sender clocks, WebSocket receive time, and SRT - arrival time do not own final sync truth. +- Forbidden writers: OBS, FFmpeg sender clocks, WebSocket receive time, SRT + arrival time, and CultMesh packet arrival time do not own final sync truth. - Cut line: EveCanvas owns Eve's sensors directly. External iOS streaming apps - are fallback tools, not the current architecture. + are fallback tools, not the current architecture. SRT/WebSocket bridge + transports are diagnostics and compatibility edges once the reliable-UDP + Verse media lane exists. ## Starfire Receiver @@ -79,8 +83,9 @@ EveCanvas now starts native AVFoundation capture after permission grants: This is an inspectable first transport, not the final high-throughput shape. When cadence or bandwidth becomes the bottleneck, replace the JSON/base64 event -transport with binary packet framing or VideoToolbox H.264 while preserving the -same source ownership and Mimir runtime sample contract. +transport with CultMesh reliable-UDP media frames and body shards, optionally +carrying VideoToolbox H.264 or another explicit media payload. Preserve the same +source ownership and Mimir runtime sample contract. Deploy EveCanvas after staging: diff --git a/docs/verse-service-contract.md b/docs/verse-service-contract.md index e0aaddd..c4ab30f 100644 --- a/docs/verse-service-contract.md +++ b/docs/verse-service-contract.md @@ -77,6 +77,30 @@ Existing document names such as `mimir.well_snapshot.v1`, and `mimir.fensalir_reservoir_pressure.v1` should be kept as concrete records inside those namespaces until a schema catalog renames them deliberately. +## Transport Lanes + +CultMesh reliable UDP is the default Verse transport for live Mimir network +state and media. TCP/WebSocket, SRT, browser streams, and local pipes are +diagnostic lowerings or external-boundary bridges unless a specific deployment +constraint temporarily promotes them. + +The live lane split is: + +- Typed control/state lane: compact documents such as timing state, command + receipts, health, stream cursors, and backpressure. +- Media stream-frame lane: typed per-frame envelopes such as + `mimir.cultmesh_stream_frame.v1` carrying source identity, capture time, + resource/body refs, payload format, and confidence. +- Media body-shard lane: bounded CultCache media/page shards with hashes, + cursors, receiver acknowledgements, and backpressure. Large bodies do not + travel as inline base64. +- Latest-state dashboard lane: lossy/current Eve surfaces for operators. It + may drop obsolete frames; it does not own durable media bodies. + +Media streams are first-class Verse payloads. They still do not become timing +authority by arrival timestamp. Clock influence comes from decoded anchors, +source-local evidence, calibrated loopback, and explicit clock-domain state. + ## Eve Surfaces Mimir publishes operator presentation as Eve/CultUI DSL, preferably @@ -137,8 +161,9 @@ state. ## Demotion Line Bespoke UI, browser dashboards, retained dashboard node lists, compatibility -WebSockets, JSON status files, JSONL replay logs, screenshot streams, and OBS -bridge scripts are demoted to lowerings, diagnostics, external-boundary export, -or replay witnesses. They may display, transport, inspect, or reconstruct typed -Mimir state. They may not own sensor truth, calibration truth, command state, -reservoir scheduling, program presentation, or synchronization behavior. +WebSockets, SRT/FFmpeg media bridges, JSON status files, JSONL replay logs, +screenshot streams, and OBS bridge scripts are demoted to lowerings, +diagnostics, external-boundary export, or replay witnesses. They may display, +transport, inspect, or reconstruct typed Mimir state. They may not own sensor +truth, calibration truth, command state, reservoir scheduling, program +presentation, media-over-Verse policy, or synchronization behavior. diff --git a/src/Mimir.BufferSmoke/Program.cs b/src/Mimir.BufferSmoke/Program.cs index 0e8d4c4..603c2b7 100644 --- a/src/Mimir.BufferSmoke/Program.cs +++ b/src/Mimir.BufferSmoke/Program.cs @@ -5579,6 +5579,15 @@ static int RunPerfectMachineProfileSmoke() ["mimir.bioacoustic_codebook_state", "mimir.bioacoustic_decoder_state", "mimir.acoustic_path_state"], StringComparer.Ordinal), new HashSet(StringComparer.Ordinal))); + var mediaTransport = new MimirNetworkTransportSelector().Select(new MimirNetworkTransportRequest( + MimirNetworkPayloadKind.MediaStreamFrame, + RequiresClockInfluence: false, + AllowsRawMedia: true, + MaximumLatencyMilliseconds: 50.0, + new HashSet( + ["mimir.cultmesh_stream_frame.v1"], + StringComparer.Ordinal), + new HashSet(StringComparer.Ordinal))); Console.WriteLine( $"perfect-machine-profile-smoke profiles={profiles.Count} calibrationPlans={calibrationPlans.Count} audioFields={audioFields.Count} visualFields={visualFields.Count} stereoDepth={stereoDepthProfiles.Count} computePlans={computePlans.Count} assemblyPlans={assemblyPlans.Count} captureProfiles={captureProfiles.Count} publications={publications.Count} languageProfiles={languageProfiles.Count} pathLearning={pathLearningProfiles.Count} localization={localizationProfiles.Count} benchmarkPanels={benchmarkPanels.Count} actuatorStrategies={actuatorStrategies.Count} cameraIngest={cameraIngestStrategies.Count} reservoirs={reservoirStrategies.Count} distributedWitnesses={distributedWitnesses.Count} networkTransports={networkTransports.Count} authorityPolicies={authorityPolicies.Count} modules={moduleCatalog.Count}"); @@ -5600,6 +5609,8 @@ static int RunPerfectMachineProfileSmoke() $"perfect-machine-authority appliesTo=raven-scarlett-witness decision={authority.Decision} rule={authority.RuleId}"); Console.WriteLine( $"perfect-machine-transport payload=TypedTimingState status={transport.Status} selected={transport.Transport?.Id ?? "none"}"); + Console.WriteLine( + $"perfect-machine-transport payload=MediaStreamFrame status={mediaTransport.Status} selected={mediaTransport.Transport?.Id ?? "none"}"); return profiles.Count >= 6 && calibrationPlans.Count >= 3 && @@ -5618,7 +5629,7 @@ static int RunPerfectMachineProfileSmoke() cameraIngestStrategies.Count >= 4 && reservoirStrategies.Count >= 3 && distributedWitnesses.Count >= 4 && - networkTransports.Count >= 4 && + networkTransports.Count >= 6 && authorityPolicies.Count >= 1 && moduleCatalog.Count >= 17 && codebook.Motifs.Length == MimirBioacousticTimeline.SymbolCount && @@ -5656,6 +5667,7 @@ static int RunPerfectMachineProfileSmoke() localization is { Score: > 0.90 } && authority.Decision == MimirAuthorityDecision.TrustedEvidence && transport.Transport?.Id == MimirNetworkTransportConfigurations.CultMeshTimingState.Id && + mediaTransport.Transport?.Id == MimirNetworkTransportConfigurations.CultMeshStreamFrameMedia.Id && clock is { AnchorCount: >= 4, Confidence: > 0.70 } ? 0 : 1; diff --git a/src/Mimir.Runtime/Synchronization/MimirNetworkTransportConfiguration.cs b/src/Mimir.Runtime/Synchronization/MimirNetworkTransportConfiguration.cs index 530f47c..bf0fcdd 100644 --- a/src/Mimir.Runtime/Synchronization/MimirNetworkTransportConfiguration.cs +++ b/src/Mimir.Runtime/Synchronization/MimirNetworkTransportConfiguration.cs @@ -7,12 +7,16 @@ public enum MimirNetworkPayloadKind CompressedAudioProgramFeed, CompressedVideoProgramFeed, RawVideoDiagnosticWindow, - NativeDashboardState + NativeDashboardState, + MediaStreamFrame, + MediaBodyShard } public enum MimirNetworkTransportKind { CultMeshTypedState, + CultMeshReliableUdpMedia, + CultMeshReliableUdpBody, LanUdpDatagrams, SrtDiagnosticMedia, WebRtcExperimental, @@ -57,17 +61,41 @@ public static class MimirNetworkTransportConfigurations RejectionConditions: ["not-requested", "outside-debug-session", "oversized-window"], "Raw audio can explain failures; it should not become the normal timing authority."); + public static MimirNetworkTransportConfiguration CultMeshStreamFrameMedia { get; } = new( + "cultmesh-reliable-udp-stream-frame", + "Primary Verse media lane: typed per-frame envelopes over CultMesh reliable UDP with capture time, source identity, resource/body refs, and backpressure.", + MimirNetworkTransportKind.CultMeshReliableUdpMedia, + MimirNetworkPayloadKind.MediaStreamFrame, + MayAffectClock: false, + CarriesRawMedia: true, + TargetLatencyMilliseconds: 35.0, + RequiredDocuments: ["mimir.cultmesh_stream_frame.v1"], + RejectionConditions: ["used-as-clock-authority", "missing-source-identity", "missing-backpressure", "schema-version-mismatch"], + "Media is welcome in the Verse, but timing authority still comes from decoded evidence and clock-domain state."); + + public static MimirNetworkTransportConfiguration CultMeshBodyShardLane { get; } = new( + "cultmesh-reliable-udp-body-shard", + "Primary Verse body lane: bounded CultCache media/page shards over CultMesh reliable UDP with hashes, cursors, and receiver backpressure.", + MimirNetworkTransportKind.CultMeshReliableUdpBody, + MimirNetworkPayloadKind.MediaBodyShard, + MayAffectClock: false, + CarriesRawMedia: true, + TargetLatencyMilliseconds: 60.0, + RequiredDocuments: ["mimir.media_body_shard.v1", "mimir.recorder_body_ref.v1"], + RejectionConditions: ["missing-hash", "missing-cursor", "missing-backpressure", "unbounded-body"], + "Large bodies move through shards and refs, not inline base64 and not private transport sidecars."); + public static MimirNetworkTransportConfiguration SrtProgramBridge { get; } = new( "srt-program-bridge", - "Existing LAN media bridge for OBS diagnostics and remote program feeds.", + "Existing LAN media bridge for OBS diagnostics and legacy remote program feeds.", MimirNetworkTransportKind.SrtDiagnosticMedia, MimirNetworkPayloadKind.CompressedVideoProgramFeed, MayAffectClock: false, CarriesRawMedia: true, TargetLatencyMilliseconds: 1500.0, RequiredDocuments: [], - RejectionConditions: ["used-as-clock-authority", "used-for-local-hot-path"], - "Useful bridge. Not the Perfect Machine's synchronization core."); + RejectionConditions: ["used-as-clock-authority", "used-for-local-hot-path", "used-as-verse-media"], + "Useful OBS bridge. Not the Verse media transport and not the Perfect Machine's synchronization core."); public static MimirNetworkTransportConfiguration WebRtcExperiment { get; } = CultMeshTimingState with { @@ -96,6 +124,8 @@ public static class MimirNetworkTransportConfigurations public static IReadOnlyList BuiltIn { get; } = [ CultMeshTimingState, + CultMeshStreamFrameMedia, + CultMeshBodyShardLane, RawAudioDebugWindow, SrtProgramBridge, WebRtcExperiment,