diff --git a/src/Mimir.Runtime/Synchronization/MimirRuntimeConfiguration.cs b/src/Mimir.Runtime/Synchronization/MimirRuntimeConfiguration.cs index da51f54..8eb8478 100644 --- a/src/Mimir.Runtime/Synchronization/MimirRuntimeConfiguration.cs +++ b/src/Mimir.Runtime/Synchronization/MimirRuntimeConfiguration.cs @@ -129,9 +129,10 @@ public sealed class MimirRuntimeConfiguration private static MimirStreamSourceFactory? TryCreateSourceFactory(MimirStreamConfig stream, string? configDirectory) { var descriptor = ToDescriptor(stream); + var diagnostics = ToDiagnostics(stream, configDirectory); if (string.Equals(stream.Adapter, "native", StringComparison.OrdinalIgnoreCase)) { - return new MimirStreamSourceFactory(descriptor, () => new MimirNativeIngestStreamSource(descriptor)); + return new MimirStreamSourceFactory(descriptor, () => new MimirNativeIngestStreamSource(descriptor), diagnostics); } if (string.Equals(stream.Adapter, "asio", StringComparison.OrdinalIgnoreCase)) @@ -148,7 +149,8 @@ public sealed class MimirRuntimeConfiguration ResolveCommand(stream.Command, configDirectory), stream.DriverClsid, stream.SampleRate, - stream.AcceptSourceIds))); + stream.AcceptSourceIds)), + diagnostics); #pragma warning restore CA1416 } @@ -172,7 +174,8 @@ public sealed class MimirRuntimeConfiguration stream.MinimumFramesPerSecond, stream.QueueDepth, ParsePixelFormat(stream.PixelFormat))), - UtcNowNs)); + UtcNowNs), + diagnostics); } if (string.Equals(stream.Adapter, "ps3eye", StringComparison.OrdinalIgnoreCase) @@ -192,7 +195,8 @@ public sealed class MimirRuntimeConfiguration stream.Width, stream.Height, stream.FramesPerSecond)), - UtcNowNs)); + UtcNowNs), + diagnostics); } if (string.Equals(stream.Adapter, "mf-gpu", StringComparison.OrdinalIgnoreCase) @@ -214,7 +218,8 @@ public sealed class MimirRuntimeConfiguration stream.InputFormat, stream.OutputFormat, stream.MinimumFramesPerSecond)), - UtcNowNs)); + UtcNowNs), + diagnostics); } if (string.Equals(stream.Adapter, "frame-events", StringComparison.OrdinalIgnoreCase) @@ -232,7 +237,8 @@ public sealed class MimirRuntimeConfiguration stream.Arguments, stream.AcceptSourceIds.Length > 0 ? new HashSet(stream.AcceptSourceIds, StringComparer.Ordinal) - : null))); + : null)), + diagnostics); } if (string.Equals(stream.Adapter, "ffmpeg-rawvideo", StringComparison.OrdinalIgnoreCase) @@ -252,7 +258,8 @@ public sealed class MimirRuntimeConfiguration stream.Height, ParsePixelFormat(stream.PixelFormat), stream.FrameBytes, - stream.StrideBytes))); + stream.StrideBytes)), + diagnostics); } if (string.Equals(stream.Adapter, "ffmpeg-pcmaudio", StringComparison.OrdinalIgnoreCase) @@ -271,7 +278,8 @@ public sealed class MimirRuntimeConfiguration stream.SampleRate, stream.Channels, ParseAudioSampleFormat(stream.SampleFormat), - stream.BlockFrames))); + stream.BlockFrames)), + diagnostics); } if (!string.Equals(stream.Adapter, "process", StringComparison.OrdinalIgnoreCase)) @@ -289,9 +297,27 @@ public sealed class MimirRuntimeConfiguration new MimirProcessStreamSourceOptions( ResolveCommand(stream.Command, configDirectory), stream.Arguments, - Math.Max(1024, stream.ChunkBytes)))); + Math.Max(1024, stream.ChunkBytes))), + diagnostics); } + private static MimirStreamSourceDiagnostics ToDiagnostics(MimirStreamConfig stream, string? configDirectory) => + new( + stream.Adapter, + ResolveCommand(stream.Command, configDirectory), + stream.PathNeedle, + stream.Width, + stream.Height, + stream.InputFormat, + stream.OutputFormat, + stream.PixelFormat, + stream.MinimumFramesPerSecond, + stream.FramesPerSecond, + stream.SampleRate, + stream.Channels, + stream.QueueDepth, + stream.AcceptSourceIds); + private static string ResolveCommand(string command, string? configDirectory) { if (string.IsNullOrWhiteSpace(command) @@ -358,7 +384,24 @@ public sealed class MimirRuntimeConfiguration public sealed record MimirStreamSourceFactory( MimirStreamDescriptor Descriptor, - Func Create); + Func Create, + MimirStreamSourceDiagnostics? Diagnostics = null); + +public sealed record MimirStreamSourceDiagnostics( + string Adapter, + string Command, + string PathNeedle, + int Width, + int Height, + string InputFormat, + string OutputFormat, + string PixelFormat, + double MinimumFramesPerSecond, + int FramesPerSecond, + int SampleRate, + int Channels, + int QueueDepth, + IReadOnlyList AcceptSourceIds); public sealed class MimirRuntimeConfigFile { diff --git a/src/Mimir.Well/Program.cs b/src/Mimir.Well/Program.cs index 36b34c8..8e78919 100644 --- a/src/Mimir.Well/Program.cs +++ b/src/Mimir.Well/Program.cs @@ -1471,7 +1471,7 @@ internal static class MimirWellSnapshot liveSources = hub.SourceCount, sourceErrors, sourceHealth = runtimeConfig.SourceFactories - .Select(factory => SourceHealthSnapshot(factory.Descriptor, hub.Buffers.Buffers, sourceErrors, startedAt)) + .Select(factory => SourceHealthSnapshot(factory, hub.Buffers.Buffers, sourceErrors, startedAt)) .ToArray(), buffers = hub.Buffers.Buffers.Select(BufferSnapshot).ToArray(), synchronizedFrame = new @@ -1653,11 +1653,13 @@ internal static class MimirWellSnapshot } private static object SourceHealthSnapshot( - MimirStreamDescriptor descriptor, + MimirStreamSourceFactory factory, IEnumerable buffers, IReadOnlyList sourceErrors, DateTimeOffset startedAt) { + var descriptor = factory.Descriptor; + var diagnostics = factory.Diagnostics; var matchingBuffers = buffers .Where(buffer => string.Equals(buffer.Descriptor.SourceId, descriptor.SourceId, StringComparison.Ordinal)) .ToArray(); @@ -1700,12 +1702,33 @@ internal static class MimirWellSnapshot Kind = descriptor.Kind.ToString(), Origin = descriptor.Origin.ToString(), descriptor.Label, + configured = diagnostics is null + ? null + : new + { + diagnostics.Adapter, + diagnostics.Command, + diagnostics.PathNeedle, + diagnostics.Width, + diagnostics.Height, + diagnostics.InputFormat, + diagnostics.OutputFormat, + diagnostics.PixelFormat, + diagnostics.MinimumFramesPerSecond, + diagnostics.FramesPerSecond, + diagnostics.SampleRate, + diagnostics.Channels, + diagnostics.QueueDepth, + acceptSourceIds = diagnostics.AcceptSourceIds, + }, status, reason = status switch { "create-error" => "source creation failed; see sourceErrors", "stalled" => "source emitted samples earlier but latest sample is stale", "waiting-network" => "network source listener is configured but no producer samples have arrived", + "waiting-device-samples" when descriptor.Kind == MimirStreamKind.Video && IsKsCamera(diagnostics) => + KsCameraWaitingReason(diagnostics), "waiting-device-samples" => "local device source is configured but has not emitted a sample", _ => "samples arriving", }, @@ -1717,6 +1740,14 @@ internal static class MimirWellSnapshot }; } + private static bool IsKsCamera(MimirStreamSourceDiagnostics? diagnostics) => + string.Equals(diagnostics?.Adapter, "ks-camera", StringComparison.OrdinalIgnoreCase); + + private static string KsCameraWaitingReason(MimirStreamSourceDiagnostics? diagnostics) => + diagnostics is null + ? "KS camera opened but no frames have arrived; verify device ownership/driver" + : $"KS camera opened but no frames have arrived; verify device ownership/driver for {diagnostics.Width}x{diagnostics.Height} {diagnostics.InputFormat}"; + private static string? TryReadAnonymousString(object value, params string[] names) { var type = value.GetType(); diff --git a/state/evidence.jsonl b/state/evidence.jsonl index 3ee3aa1..ecfe91e 100644 --- a/state/evidence.jsonl +++ b/state/evidence.jsonl @@ -369,3 +369,4 @@ {"ts": "2026-06-03T04:13:02+01:00", "type": "implementation", "status": "ok", "note": "2026-06-03: ASIO readiness repair: Mimir now derives ASIO block times from native device timestamps, preserves local-epoch timestamps in the canonical mapper, sorts planner samples chronologically, keeps frames visible when overlap pinches, and lets the latency controller chase FutureSampleOnly slices downward. Live Well reached repeated 6/6 Ready frames at roughly 75-80 ms presentation delay with ASIO distances reported around 32-36 ms."} {"ts": "2026-06-03T04:40:48+01:00", "type": "implementation", "status": "ok", "note": "2026-06-03: Source health and process-clock repair: FFmpeg/process/frame-event sources now use UTC arrival timestamps instead of Stopwatch-domain timestamps; Well sourceHealth distinguishes live, stalled, waiting-network, and waiting-device-samples. Live verification after restart reached repeated 6/6 Ready frames, while streamPressure exposed the next bottleneck: inline WebSocket body lane published ~66 MB across 53 Well snapshots at ~82 ms average publish cost."} {"ts": "2026-06-03T04:55:12+01:00", "type": "implementation", "status": "ok", "note": "Well live-loop stall was caused by inline complex-contour matched-filter analysis running inside the drinking/publish cadence. Mimir.Well now follows the app runtime authority: complex contour may be configured/published but only runs inline when MIMIR_COMPLEX_CONTOUR_RUNTIME_INLINE is truthy; otherwise it logs suppression and leaves the heavy decoder for a worker-owned path. Live verification in online-verse-daemons-20260602-233914 after restart reached seq 122->140 over ~4.4s with 6/6 Ready, publish avg <0.3 ms, zero dropped documents, and adaptive delay near 40 ms."} +{"ts": "2026-06-03T05:10:12+01:00", "type": "observation", "status": "ok", "note": "Kiyo Pro source-health diagnosis: after stopping Well, direct native KS smoke through mimir_camera_capture.dll produced 0 frames for Kiyo Pro across 640x480 YUY2, 640x480 MJPG, and 1920x1080 MJPG, while Kiyo basic produced 107 frames in 3s through the same DLL. MF/GPU fallback probe hung under the live stack. Added source factory diagnostics to Well snapshots so Odin sees adapter/path/mode and starved KS-camera reason; live restart showed Kiyo Pro waiting-device-samples with reason 'KS camera opened but no frames...' for 640x480 YUY2, while Leap and Kiyo basic stayed live and Well held 6/6 Ready at 40 ms."}