Move sync buffers into Mimir runtime
This commit is contained in:
parent
5f61e76df3
commit
2d179d9e2f
20 changed files with 445 additions and 3 deletions
|
|
@ -16,6 +16,12 @@
|
|||
"d3d12Bridge": "Aquarium.Engine",
|
||||
"defaultReservoirSeconds": 5.0,
|
||||
"runtimeState": "in-memory-localcast-runtime",
|
||||
"syncBuffers": {
|
||||
"owner": "Mimir.Runtime",
|
||||
"defaultDurationSeconds": 5.0,
|
||||
"layout": "one-rolling-buffer-per-configured-audio-or-video-stream",
|
||||
"sourceAdapter": "IMimirStreamSource"
|
||||
},
|
||||
"uiAuthority": "debug-settings-output-management",
|
||||
"ingest": {
|
||||
"videoFeeds": "local-or-networked-producers",
|
||||
|
|
|
|||
|
|
@ -50,6 +50,10 @@ latency, and confidence.
|
|||
- `Mimir.slnx` contains `src/Mimir.App` and `src/Mimir.Runtime`.
|
||||
`Mimir.App` launches `AquariumHost` from Aquarium Engine, and
|
||||
`Mimir.Runtime` supplies the Aquarium client runtime factory.
|
||||
- `Mimir.Runtime` now owns `MimirSynchronizationHub`,
|
||||
`MimirRollingStreamBuffer`, stream descriptors, and the `IMimirStreamSource`
|
||||
adapter seam. It initializes one bounded rolling buffer per configured
|
||||
audio/video stream and polls registered local/network sources each frame.
|
||||
- `config/perfect-machine.example.json` declares the contract shape for six cameras, six microphones, reservoir typed views, native authorities, outputs, and the demotion of bridge scripts to tooling.
|
||||
- `native/reservoir` is the first native Rust crate. It implements one
|
||||
shared-edge five-second rolling buffer with typed views and proves that
|
||||
|
|
|
|||
|
|
@ -82,6 +82,33 @@ The first cut should be deliberately boring:
|
|||
Aquarium's LocalCast runtime until Mimir-specific ingest workers replace the
|
||||
remaining diagnostic source.
|
||||
|
||||
## Synchronization Runtime
|
||||
|
||||
`Mimir.Runtime` now owns the first synchronization spine:
|
||||
|
||||
- `MimirRuntime` is the Aquarium client runtime. It wraps the current
|
||||
Aquarium `LocalCastRuntime` visual path and adds a Mimir-owned synchronization
|
||||
hub.
|
||||
- `MimirSynchronizationHub` owns stream source polling and appends samples into
|
||||
bounded buffers.
|
||||
- `MimirRollingStreamBuffer` owns one stream's short history and evicts samples
|
||||
outside the configured window.
|
||||
- `IMimirStreamSource` is the adapter seam for local devices and network feeds.
|
||||
|
||||
The default buffer duration is five seconds. It can be overridden with
|
||||
`MIMIR_SYNC_BUFFER_SECONDS` or `MIMIR_RESERVOIR_SECONDS`.
|
||||
|
||||
Configured stream ids can be declared with comma- or semicolon-separated
|
||||
environment variables:
|
||||
|
||||
- `MIMIR_LOCAL_VIDEO_STREAMS`
|
||||
- `MIMIR_LOCAL_AUDIO_STREAMS`
|
||||
- `MIMIR_NETWORK_VIDEO_STREAMS`
|
||||
- `MIMIR_NETWORK_AUDIO_STREAMS`
|
||||
|
||||
These create buffers immediately. Capture adapters still need to register
|
||||
`IMimirStreamSource` implementations to feed live samples into those buffers.
|
||||
|
||||
## Cut Line
|
||||
|
||||
Do not add a new registry, bridge daemon, JSON live store, OBS plugin, or
|
||||
|
|
|
|||
|
|
@ -65,6 +65,9 @@ Local and networked video/audio feeds are producers into that one runtime
|
|||
window; they do not own clocks or private synchronization buffers. Mimir owns
|
||||
`Mimir.slnx`; `src/Mimir.App` references Aquarium Engine as the host/windowing
|
||||
and D3D12 bridge, while `src/Mimir.Runtime` provides the Aquarium client runtime.
|
||||
`Mimir.Runtime` owns the first synchronization hub: one five-second default
|
||||
rolling buffer per configured audio/video stream, source polling through
|
||||
`IMimirStreamSource`, and runtime UI readouts for stream/buffer health.
|
||||
|
||||
```mermaid
|
||||
flowchart TD
|
||||
|
|
|
|||
|
|
@ -44,6 +44,12 @@ Get-Content .\state\evidence.jsonl -Tail 8
|
|||
- `Mimir.slnx` is the repo-owned C# app surface. `src/Mimir.App` references
|
||||
Aquarium Engine as the windowing/rendering/D3D12 host and loads
|
||||
`src/Mimir.Runtime` as the Aquarium client runtime assembly.
|
||||
- `src/Mimir.Runtime` now wraps Aquarium's LocalCast visual runtime in
|
||||
`MimirRuntime` and owns `MimirSynchronizationHub`: one configurable rolling
|
||||
buffer per audio/video stream, defaulting to five seconds. Stream ids can be
|
||||
declared with `MIMIR_LOCAL_VIDEO_STREAMS`, `MIMIR_LOCAL_AUDIO_STREAMS`,
|
||||
`MIMIR_NETWORK_VIDEO_STREAMS`, and `MIMIR_NETWORK_AUDIO_STREAMS`; real capture
|
||||
adapters feed buffers through `IMimirStreamSource`.
|
||||
- The reservoir is now one native time-ordered rolling buffer with typed
|
||||
indexes/views. The previous typed-ring crate is gone.
|
||||
- Native reservoir samples carry provenance flags; diagnostic/fallback samples
|
||||
|
|
|
|||
114
src/Mimir.Runtime/MimirRuntime.cs
Normal file
114
src/Mimir.Runtime/MimirRuntime.cs
Normal file
|
|
@ -0,0 +1,114 @@
|
|||
using Aquarium.Engine;
|
||||
using Aquarium.Engine.Audio;
|
||||
using Aquarium.Engine.Input;
|
||||
using Aquarium.Engine.Render;
|
||||
using Aquarium.Engine.Ui;
|
||||
using Aquarium.LocalCast;
|
||||
using Mimir.Runtime.Synchronization;
|
||||
|
||||
namespace Mimir.Runtime;
|
||||
|
||||
public sealed class MimirRuntime : IAquariumRuntime
|
||||
{
|
||||
private readonly LocalCastRuntime visualRuntime;
|
||||
private readonly MimirSynchronizationHub synchronization;
|
||||
private readonly AquariumUiDocument ui;
|
||||
private int lastPollCount;
|
||||
|
||||
public MimirRuntime(AquariumRuntimeOptions options)
|
||||
: this(options, MimirSynchronizationSettings.FromEnvironment())
|
||||
{
|
||||
}
|
||||
|
||||
public MimirRuntime(AquariumRuntimeOptions options, MimirSynchronizationSettings settings)
|
||||
: this(options, settings, [])
|
||||
{
|
||||
}
|
||||
|
||||
public MimirRuntime(
|
||||
AquariumRuntimeOptions options,
|
||||
MimirSynchronizationSettings settings,
|
||||
IEnumerable<IMimirStreamSource> streamSources)
|
||||
{
|
||||
Options = options;
|
||||
visualRuntime = new LocalCastRuntime(options);
|
||||
synchronization = new MimirSynchronizationHub(settings);
|
||||
foreach (var source in streamSources)
|
||||
{
|
||||
synchronization.AddSource(source);
|
||||
}
|
||||
|
||||
ui = CreateUi();
|
||||
}
|
||||
|
||||
public AquariumRuntimeOptions Options { get; }
|
||||
|
||||
public AquariumFrame Frame => visualRuntime.Frame;
|
||||
|
||||
public GraphicsSettings GraphicsSettings
|
||||
{
|
||||
get => visualRuntime.GraphicsSettings;
|
||||
set => visualRuntime.GraphicsSettings = value;
|
||||
}
|
||||
|
||||
public AquariumRenderPlan RenderPlan => visualRuntime.RenderPlan;
|
||||
|
||||
public AquariumUiDocument Ui => ui;
|
||||
|
||||
public AquariumAudioDocument Audio => visualRuntime.Audio;
|
||||
|
||||
public AquariumSynthDocument Synth => visualRuntime.Synth;
|
||||
|
||||
public void RegisterStreamSource(IMimirStreamSource source)
|
||||
{
|
||||
synchronization.AddSource(source);
|
||||
}
|
||||
|
||||
public void Start()
|
||||
{
|
||||
Console.WriteLine($"Mimir runtime sync buffers: {synchronization.Summary()} @ {synchronization.Settings.BufferDuration.TotalSeconds:0.###}s");
|
||||
visualRuntime.Start();
|
||||
}
|
||||
|
||||
public void Update(float deltaSeconds, InputState input)
|
||||
{
|
||||
lastPollCount = synchronization.PollSources();
|
||||
visualRuntime.Update(deltaSeconds, input);
|
||||
}
|
||||
|
||||
public AquariumFrame ComposeFrame(AquariumFrame frame, AquariumFrameInput input)
|
||||
{
|
||||
return visualRuntime.ComposeFrame(frame, input);
|
||||
}
|
||||
|
||||
public void FlushState()
|
||||
{
|
||||
visualRuntime.FlushState();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
synchronization.Dispose();
|
||||
visualRuntime.Dispose();
|
||||
}
|
||||
|
||||
private AquariumUiDocument CreateUi()
|
||||
{
|
||||
return new AquariumUiDocument()
|
||||
.Panel("Mimir Sync", 18.0f, 82.0f, 390.0f, panel =>
|
||||
{
|
||||
panel.Section("Rolling Buffers");
|
||||
panel.Readout("Window", () => $"{synchronization.Settings.BufferDuration.TotalSeconds:0.###}s");
|
||||
panel.Readout("Streams", synchronization.Summary);
|
||||
panel.Readout("Sources", () => $"{synchronization.SourceCount}");
|
||||
panel.Readout("Last poll", () => $"{lastPollCount} samples");
|
||||
panel.Readout("Ingested", () => $"{synchronization.IngestedSamples}");
|
||||
foreach (var buffer in synchronization.Buffers.Buffers)
|
||||
{
|
||||
panel.Readout(
|
||||
buffer.Descriptor.SourceId,
|
||||
() => $"{buffer.Descriptor.Kind}/{buffer.Descriptor.Origin} {buffer.Count} samples edge {buffer.EdgeNs}");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,4 @@
|
|||
using Aquarium.Engine;
|
||||
using Aquarium.LocalCast;
|
||||
|
||||
namespace Mimir.Runtime;
|
||||
|
||||
|
|
@ -7,6 +6,6 @@ public sealed class MimirRuntimeFactory : IAquariumRuntimeFactory
|
|||
{
|
||||
public IAquariumRuntime Create(AquariumRuntimeOptions options)
|
||||
{
|
||||
return new LocalCastRuntime(options);
|
||||
return new MimirRuntime(options);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
8
src/Mimir.Runtime/Synchronization/IMimirStreamSource.cs
Normal file
8
src/Mimir.Runtime/Synchronization/IMimirStreamSource.cs
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
namespace Mimir.Runtime.Synchronization;
|
||||
|
||||
public interface IMimirStreamSource : IDisposable
|
||||
{
|
||||
MimirStreamDescriptor Descriptor { get; }
|
||||
|
||||
bool TryRead(out MimirStreamSample sample);
|
||||
}
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
namespace Mimir.Runtime.Synchronization;
|
||||
|
||||
public sealed class MimirRollingStreamBuffer
|
||||
{
|
||||
private readonly Queue<MimirStreamSample> samples = new();
|
||||
|
||||
public MimirRollingStreamBuffer(MimirStreamDescriptor descriptor, TimeSpan duration)
|
||||
{
|
||||
Descriptor = descriptor;
|
||||
Duration = duration > TimeSpan.Zero ? duration : TimeSpan.FromSeconds(5);
|
||||
}
|
||||
|
||||
public MimirStreamDescriptor Descriptor { get; }
|
||||
|
||||
public TimeSpan Duration { get; }
|
||||
|
||||
public long EdgeNs { get; private set; }
|
||||
|
||||
public long WindowStartNs => Math.Max(0, EdgeNs - DurationNs);
|
||||
|
||||
public int Count => samples.Count;
|
||||
|
||||
public MimirStreamSample? Latest { get; private set; }
|
||||
|
||||
private long DurationNs => checked((long)(Duration.TotalSeconds * 1_000_000_000.0));
|
||||
|
||||
public void Append(MimirStreamSample sample)
|
||||
{
|
||||
if (!string.Equals(sample.SourceId, Descriptor.SourceId, StringComparison.Ordinal)
|
||||
|| sample.Kind != Descriptor.Kind
|
||||
|| sample.Origin != Descriptor.Origin)
|
||||
{
|
||||
throw new ArgumentException("Sample does not belong to this stream buffer.", nameof(sample));
|
||||
}
|
||||
|
||||
EdgeNs = Math.Max(EdgeNs, sample.TimestampNs);
|
||||
samples.Enqueue(sample);
|
||||
Latest = sample;
|
||||
EvictExpired();
|
||||
}
|
||||
|
||||
public IReadOnlyList<MimirStreamSample> Snapshot()
|
||||
{
|
||||
return samples.ToArray();
|
||||
}
|
||||
|
||||
private void EvictExpired()
|
||||
{
|
||||
var windowStart = WindowStartNs;
|
||||
while (samples.Count > 0 && samples.Peek().TimestampNs < windowStart)
|
||||
{
|
||||
samples.Dequeue();
|
||||
}
|
||||
}
|
||||
}
|
||||
31
src/Mimir.Runtime/Synchronization/MimirStreamBufferSet.cs
Normal file
31
src/Mimir.Runtime/Synchronization/MimirStreamBufferSet.cs
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
namespace Mimir.Runtime.Synchronization;
|
||||
|
||||
public sealed class MimirStreamBufferSet
|
||||
{
|
||||
private readonly Dictionary<string, MimirRollingStreamBuffer> buffers = new(StringComparer.Ordinal);
|
||||
|
||||
public MimirStreamBufferSet(TimeSpan defaultDuration)
|
||||
{
|
||||
DefaultDuration = defaultDuration > TimeSpan.Zero ? defaultDuration : TimeSpan.FromSeconds(5);
|
||||
}
|
||||
|
||||
public TimeSpan DefaultDuration { get; }
|
||||
|
||||
public IReadOnlyCollection<MimirRollingStreamBuffer> Buffers => buffers.Values;
|
||||
|
||||
public MimirRollingStreamBuffer EnsureBuffer(MimirStreamDescriptor descriptor)
|
||||
{
|
||||
if (!buffers.TryGetValue(descriptor.BufferKey, out var buffer))
|
||||
{
|
||||
buffer = new MimirRollingStreamBuffer(descriptor, DefaultDuration);
|
||||
buffers.Add(descriptor.BufferKey, buffer);
|
||||
}
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
public void Append(MimirStreamSample sample)
|
||||
{
|
||||
EnsureBuffer(new MimirStreamDescriptor(sample.SourceId, sample.Kind, sample.Origin)).Append(sample);
|
||||
}
|
||||
}
|
||||
10
src/Mimir.Runtime/Synchronization/MimirStreamDescriptor.cs
Normal file
10
src/Mimir.Runtime/Synchronization/MimirStreamDescriptor.cs
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
namespace Mimir.Runtime.Synchronization;
|
||||
|
||||
public sealed record MimirStreamDescriptor(
|
||||
string SourceId,
|
||||
MimirStreamKind Kind,
|
||||
MimirStreamOrigin Origin,
|
||||
bool Enabled = true)
|
||||
{
|
||||
public string BufferKey => $"{Kind}:{Origin}:{SourceId}";
|
||||
}
|
||||
13
src/Mimir.Runtime/Synchronization/MimirStreamKind.cs
Normal file
13
src/Mimir.Runtime/Synchronization/MimirStreamKind.cs
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
namespace Mimir.Runtime.Synchronization;
|
||||
|
||||
public enum MimirStreamKind
|
||||
{
|
||||
Audio,
|
||||
Video,
|
||||
}
|
||||
|
||||
public enum MimirStreamOrigin
|
||||
{
|
||||
LocalDevice,
|
||||
Network,
|
||||
}
|
||||
11
src/Mimir.Runtime/Synchronization/MimirStreamSample.cs
Normal file
11
src/Mimir.Runtime/Synchronization/MimirStreamSample.cs
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
namespace Mimir.Runtime.Synchronization;
|
||||
|
||||
public readonly record struct MimirStreamSample(
|
||||
string SourceId,
|
||||
MimirStreamKind Kind,
|
||||
MimirStreamOrigin Origin,
|
||||
long TimestampNs,
|
||||
long ArrivalNs,
|
||||
ulong Sequence,
|
||||
ulong PayloadHandle,
|
||||
int ByteLength = 0);
|
||||
74
src/Mimir.Runtime/Synchronization/MimirSynchronizationHub.cs
Normal file
74
src/Mimir.Runtime/Synchronization/MimirSynchronizationHub.cs
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
namespace Mimir.Runtime.Synchronization;
|
||||
|
||||
public sealed class MimirSynchronizationHub : IDisposable
|
||||
{
|
||||
private readonly List<IMimirStreamSource> sources = [];
|
||||
private ulong ingestedSamples;
|
||||
|
||||
public MimirSynchronizationHub(MimirSynchronizationSettings settings)
|
||||
{
|
||||
Settings = settings;
|
||||
Buffers = new MimirStreamBufferSet(settings.BufferDuration);
|
||||
foreach (var stream in settings.Streams.Where(stream => stream.Enabled))
|
||||
{
|
||||
Buffers.EnsureBuffer(stream);
|
||||
}
|
||||
}
|
||||
|
||||
public MimirSynchronizationSettings Settings { get; }
|
||||
|
||||
public MimirStreamBufferSet Buffers { get; }
|
||||
|
||||
public ulong IngestedSamples => ingestedSamples;
|
||||
|
||||
public int SourceCount => sources.Count;
|
||||
|
||||
public void AddSource(IMimirStreamSource source)
|
||||
{
|
||||
ObjectDisposedException.ThrowIf(disposed, this);
|
||||
sources.Add(source);
|
||||
Buffers.EnsureBuffer(source.Descriptor);
|
||||
}
|
||||
|
||||
public int PollSources(int maxSamplesPerSource = 256)
|
||||
{
|
||||
ObjectDisposedException.ThrowIf(disposed, this);
|
||||
var consumed = 0;
|
||||
foreach (var source in sources)
|
||||
{
|
||||
for (var index = 0; index < maxSamplesPerSource && source.TryRead(out var sample); index++)
|
||||
{
|
||||
Buffers.Append(sample);
|
||||
consumed++;
|
||||
ingestedSamples++;
|
||||
}
|
||||
}
|
||||
|
||||
return consumed;
|
||||
}
|
||||
|
||||
public string Summary()
|
||||
{
|
||||
var audio = Buffers.Buffers.Count(buffer => buffer.Descriptor.Kind == MimirStreamKind.Audio);
|
||||
var video = Buffers.Buffers.Count(buffer => buffer.Descriptor.Kind == MimirStreamKind.Video);
|
||||
return $"{video} video / {audio} audio buffers";
|
||||
}
|
||||
|
||||
private bool disposed;
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (disposed)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (var source in sources)
|
||||
{
|
||||
source.Dispose();
|
||||
}
|
||||
|
||||
sources.Clear();
|
||||
disposed = true;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
namespace Mimir.Runtime.Synchronization;
|
||||
|
||||
public sealed class MimirSynchronizationSettings
|
||||
{
|
||||
public TimeSpan BufferDuration { get; init; } = TimeSpan.FromSeconds(5);
|
||||
|
||||
public IReadOnlyList<MimirStreamDescriptor> Streams { get; init; } = [];
|
||||
|
||||
public static MimirSynchronizationSettings FromEnvironment()
|
||||
{
|
||||
var duration = ReadDuration();
|
||||
var streams = new List<MimirStreamDescriptor>();
|
||||
AddStreams(streams, Environment.GetEnvironmentVariable("MIMIR_LOCAL_VIDEO_STREAMS"), MimirStreamKind.Video, MimirStreamOrigin.LocalDevice);
|
||||
AddStreams(streams, Environment.GetEnvironmentVariable("MIMIR_LOCAL_AUDIO_STREAMS"), MimirStreamKind.Audio, MimirStreamOrigin.LocalDevice);
|
||||
AddStreams(streams, Environment.GetEnvironmentVariable("MIMIR_NETWORK_VIDEO_STREAMS"), MimirStreamKind.Video, MimirStreamOrigin.Network);
|
||||
AddStreams(streams, Environment.GetEnvironmentVariable("MIMIR_NETWORK_AUDIO_STREAMS"), MimirStreamKind.Audio, MimirStreamOrigin.Network);
|
||||
|
||||
return new MimirSynchronizationSettings
|
||||
{
|
||||
BufferDuration = duration,
|
||||
Streams = streams,
|
||||
};
|
||||
}
|
||||
|
||||
private static TimeSpan ReadDuration()
|
||||
{
|
||||
var raw = Environment.GetEnvironmentVariable("MIMIR_SYNC_BUFFER_SECONDS")
|
||||
?? Environment.GetEnvironmentVariable("MIMIR_RESERVOIR_SECONDS");
|
||||
return double.TryParse(raw, out var seconds) && double.IsFinite(seconds) && seconds > 0.0
|
||||
? TimeSpan.FromSeconds(Math.Clamp(seconds, 0.25, 60.0))
|
||||
: TimeSpan.FromSeconds(5);
|
||||
}
|
||||
|
||||
private static void AddStreams(
|
||||
ICollection<MimirStreamDescriptor> streams,
|
||||
string? raw,
|
||||
MimirStreamKind kind,
|
||||
MimirStreamOrigin origin)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(raw))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (var sourceId in raw.Split([',', ';'], StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries))
|
||||
{
|
||||
streams.Add(new MimirStreamDescriptor(sourceId, kind, origin));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -97,3 +97,4 @@
|
|||
{"ts": "2026-05-21T09:26:02+00:00", "type": "implementation", "status": "ok", "note": "Repository content now presents the public project as Mimir: prose/docs/config examples/OBS source names/default Spout sender/Faust metadata/tool descriptions migrated from LocalCastBridge branding, while lowercase localcast package/schema/ABI contracts remain until a deliberate code rename cut."}
|
||||
{"ts": "2026-05-21T12:09:51+00:00", "type": "decision", "status": "ok", "note": "Viable stream app cut pinned: Aquarium hosts one five-second in-memory LocalcastRuntime, local/networked feeds append as producers, Aquarium owns runtime UI/debug/settings/output management, Faust/native audio builds synchronized stems, and OBS receives program outputs rather than raw feed sync."}
|
||||
{"ts": "2026-05-21T12:14:26+00:00", "type": "implementation", "status": "ok", "note": "Mimir now owns a C# app solution: Mimir.slnx contains src/Mimir.App, which launches AquariumHost from Aquarium Engine, and src/Mimir.Runtime, which provides the Aquarium runtime factory over Aquarium.LocalCast. Aquarium Engine remains the windowing/rendering/D3D12 library reference."}
|
||||
{"ts": "2026-05-21T12:33:01+00:00", "type": "implementation", "status": "ok", "note": "Mimir.Runtime now owns the first synchronization spine: MimirRuntime wraps Aquarium LocalCast rendering, initializes per-stream rolling buffers through MimirSynchronizationHub, polls registered IMimirStreamSource adapters each update, and defaults buffer duration to five seconds with env overrides for local/network audio/video stream ids."}
|
||||
|
|
|
|||
|
|
@ -71,6 +71,11 @@ accepted_design:
|
|||
- `Mimir.slnx` owns the app surface. `src/Mimir.App` launches Aquarium Engine
|
||||
as the host/window/D3D12 library, and `src/Mimir.Runtime` provides Mimir's
|
||||
Aquarium client runtime factory.
|
||||
- `Mimir.Runtime` owns the first synchronization spine:
|
||||
`MimirSynchronizationHub`, `MimirRollingStreamBuffer`, stream descriptors,
|
||||
and `IMimirStreamSource`. It initializes one bounded rolling buffer per
|
||||
configured audio/video stream and drains registered local/network sources
|
||||
into those buffers each Aquarium update.
|
||||
- `native/reservoir` is the first native Rust crate. It now uses one
|
||||
time-ordered rolling buffer with typed views, so retention has exactly one
|
||||
owner while Aquarium/Faust still get kind-scoped queries.
|
||||
|
|
@ -112,6 +117,8 @@ active_subgoals:
|
|||
- Build the viable Aquarium-hosted stream app around one five-second
|
||||
`LocalcastRuntime`: ingest local/networked video and audio producers,
|
||||
expose runtime UI, and emit synchronized OBS program outputs.
|
||||
- Implement concrete local device and network `IMimirStreamSource` adapters
|
||||
that feed the Mimir runtime buffers with live audio/video samples.
|
||||
- Bind Aquarium/Faust to the rolling-buffer `LocalcastRuntime` and
|
||||
`LocalcastProducer` C ABI described by
|
||||
`native/reservoir/include/localcast_reservoir.h`.
|
||||
|
|
|
|||
|
|
@ -11,5 +11,8 @@ No active scratch subgoal.
|
|||
OBS receives synchronized program outputs.
|
||||
- Mimir app scaffold now lives in `Mimir.slnx` with `src/Mimir.App` and
|
||||
`src/Mimir.Runtime`; Aquarium Engine remains an external project reference.
|
||||
- Synchronization ownership started moving into `Mimir.Runtime`: hub, stream
|
||||
descriptors, per-stream rolling buffers, settings, and source adapter seam are
|
||||
in C# now; concrete capture adapters are next.
|
||||
- Keep scratch short and disposable.
|
||||
- Promote only durable lessons into `state/evidence.jsonl` or the map.
|
||||
|
|
|
|||
|
|
@ -24,11 +24,29 @@ class MimirAppContractTests(unittest.TestCase):
|
|||
def test_runtime_references_localcast_runtime_client(self):
|
||||
runtime_project = (ROOT / "src" / "Mimir.Runtime" / "Mimir.Runtime.csproj").read_text(encoding="utf-8-sig")
|
||||
factory = (ROOT / "src" / "Mimir.Runtime" / "MimirRuntimeFactory.cs").read_text(encoding="utf-8")
|
||||
runtime = (ROOT / "src" / "Mimir.Runtime" / "MimirRuntime.cs").read_text(encoding="utf-8")
|
||||
|
||||
self.assertIn("Aquarium.Engine.Contracts.csproj", runtime_project)
|
||||
self.assertIn("Aquarium.LocalCast.csproj", runtime_project)
|
||||
self.assertIn("IAquariumRuntimeFactory", factory)
|
||||
self.assertIn("new LocalCastRuntime(options)", factory)
|
||||
self.assertIn("new MimirRuntime(options)", factory)
|
||||
self.assertIn("new LocalCastRuntime(options)", runtime)
|
||||
|
||||
def test_runtime_owns_synchronization_buffers(self):
|
||||
runtime = (ROOT / "src" / "Mimir.Runtime" / "MimirRuntime.cs").read_text(encoding="utf-8")
|
||||
hub = (ROOT / "src" / "Mimir.Runtime" / "Synchronization" / "MimirSynchronizationHub.cs").read_text(encoding="utf-8")
|
||||
buffer = (ROOT / "src" / "Mimir.Runtime" / "Synchronization" / "MimirRollingStreamBuffer.cs").read_text(encoding="utf-8")
|
||||
settings = (ROOT / "src" / "Mimir.Runtime" / "Synchronization" / "MimirSynchronizationSettings.cs").read_text(encoding="utf-8")
|
||||
|
||||
self.assertIn("MimirSynchronizationHub", runtime)
|
||||
self.assertIn("PollSources", runtime)
|
||||
self.assertIn("RegisterStreamSource", runtime)
|
||||
self.assertIn("MimirStreamBufferSet", hub)
|
||||
self.assertIn("TryRead(out var sample)", hub)
|
||||
self.assertIn("EvictExpired", buffer)
|
||||
self.assertIn("TimeSpan.FromSeconds(5)", settings)
|
||||
self.assertIn("MIMIR_NETWORK_VIDEO_STREAMS", settings)
|
||||
self.assertIn("MIMIR_LOCAL_AUDIO_STREAMS", settings)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
|
|||
|
|
@ -16,6 +16,8 @@ class PerfectMachineContractTests(unittest.TestCase):
|
|||
self.assertEqual("Mimir.slnx", data["viableStreamApp"]["solution"])
|
||||
self.assertEqual("Aquarium.Engine", data["viableStreamApp"]["windowingRenderingLibrary"])
|
||||
self.assertEqual("in-memory-localcast-runtime", data["viableStreamApp"]["runtimeState"])
|
||||
self.assertEqual("Mimir.Runtime", data["viableStreamApp"]["syncBuffers"]["owner"])
|
||||
self.assertEqual("one-rolling-buffer-per-configured-audio-or-video-stream", data["viableStreamApp"]["syncBuffers"]["layout"])
|
||||
self.assertEqual("producers-not-clock-authorities", data["viableStreamApp"]["ingest"]["networkFeedsAre"])
|
||||
self.assertEqual("Aquarium", data["authorities"]["denseVisualFusion"])
|
||||
self.assertEqual("Faust", data["authorities"]["hotAudioDsp"])
|
||||
|
|
|
|||
Loading…
Reference in a new issue