Add online Verse observation daemons
This commit is contained in:
parent
8436918658
commit
583bf2c140
9 changed files with 519 additions and 2 deletions
|
|
@ -6,6 +6,7 @@
|
|||
<Project Path="src/Mimir.EveDialogue/Mimir.EveDialogue.csproj" />
|
||||
<Project Path="src/Mimir.EveDashboard/Mimir.EveDashboard.csproj" />
|
||||
<Project Path="src/Mimir.EveSensorReceiver/Mimir.EveSensorReceiver.csproj" />
|
||||
<Project Path="src/Mimir.VerseRecorder/Mimir.VerseRecorder.csproj" />
|
||||
<Project Path="src/Mimir.PsMoveProbe/Mimir.PsMoveProbe.csproj" />
|
||||
<Project Path="src/Mimir.WasapiLoopback/Mimir.WasapiLoopback.csproj" />
|
||||
<Project Path="src/Mimir.Runtime/Mimir.Runtime.csproj" />
|
||||
|
|
|
|||
|
|
@ -569,6 +569,20 @@ a named invariant that the native runtime cannot protect yet.
|
|||
typed `mimir.move_controller_observation_state`,
|
||||
`mimir.camera_feature_track_state`, and `mimir.visual_marker_state` rather
|
||||
than becoming a raw-media or camera-placement authority.
|
||||
`Mimir.EveSensorReceiver` is now the first always-on typed observation relay
|
||||
for that split. It accepts Eve/CultMesh-compatible witness observations on
|
||||
`/eve/periwinkle`, normalizes them for the existing text ledger, and also
|
||||
serves a WebSocket subscriber lane on `/eve/periwinkle/subscribe`.
|
||||
`Mimir.VerseRecorder` subscribes to that lane and writes a timestamped
|
||||
`session.json` plus `observations.jsonl` under
|
||||
`C:\Users\Meta\Videos\Mimir\VerseCaptures` by default. The online supervisor
|
||||
`scripts/start-online-verse-daemons.ps1` starts the relay, recorder,
|
||||
Nightwing Eyes/Move witness, music-synced Move gesture worker, and a local
|
||||
Starfire `Mimir.BufferSmoke` runtime capture worker from
|
||||
`config/mimir-runtime.mvp-leap-eyes-kiyo.local.json`. This cut records typed
|
||||
observation evidence and keeps local rolling capture alive; raw camera/audio
|
||||
payloads, aligned source windows, and stem descriptors still need a runtime
|
||||
publisher bridge from `MimirSynchronizationHub` into the same Verse surface.
|
||||
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
|
||||
|
|
|
|||
|
|
@ -195,6 +195,18 @@ Get-Content .\state\evidence.jsonl -Tail 8
|
|||
Native program-output recording/streaming should replace those actuators
|
||||
behind the same owner.
|
||||
- OBS receives final program surfaces; it does not own synchronization.
|
||||
- The first online Verse capture daemon pair exists. `Mimir.EveSensorReceiver`
|
||||
now has a subscriber WebSocket path beside its observation ingest path, and
|
||||
`Mimir.VerseRecorder` writes subscribed observations to
|
||||
`C:\Users\Meta\Videos\Mimir\VerseCaptures\<session>\session.json` plus
|
||||
`observations.jsonl`. `scripts/start-online-verse-daemons.ps1` supervises
|
||||
the local relay, recorder, Nightwing typed Eyes/Move witness, the
|
||||
music-synced Move gesture worker, and a Starfire `Mimir.BufferSmoke`
|
||||
runtime capture host for the MVP Leap/Eyes/Kiyo config. Treat this as the
|
||||
typed observation/witness ledger. The next coherent cut is a
|
||||
`MimirSynchronizationHub` publisher that emits aligned source windows, stem
|
||||
descriptors, sync states, and actuator state into the same Verse surface
|
||||
instead of leaving raw media/stem truth in local process memory only.
|
||||
|
||||
## Current Pressure
|
||||
|
||||
|
|
|
|||
191
scripts/start-online-verse-daemons.ps1
Normal file
191
scripts/start-online-verse-daemons.ps1
Normal file
|
|
@ -0,0 +1,191 @@
|
|||
param(
|
||||
[string]$NightwingHost = "nightwing",
|
||||
[string]$WitnessUrl = "ws://192.168.1.66:8796/eve/periwinkle",
|
||||
[string]$SubscribeUrl = "ws://127.0.0.1:8796/eve/periwinkle/subscribe",
|
||||
[string]$ConfigPath = "E:\Projects\Mimir\config\mimir-runtime.mvp-leap-eyes-kiyo.local.json",
|
||||
[string]$RecorderRoot = "C:\Users\Meta\Videos\Mimir\VerseCaptures",
|
||||
[int]$DurationSeconds = 0,
|
||||
[int]$MoveFps = 120,
|
||||
[int]$MoveFftSize = 256,
|
||||
[string[]]$Move = @(
|
||||
"move-00-07-04-a3-97-72-usb=/dev/hidraw1:#35ff6c",
|
||||
"move-00-07-04-a6-be-5f=/dev/hidraw2:#ff2a00",
|
||||
"move-00-06-f5-23-e2-d1=/dev/hidraw3:#00a8ff"
|
||||
),
|
||||
[switch]$SkipRuntime,
|
||||
[switch]$SkipMoves,
|
||||
[switch]$SkipNightwing,
|
||||
[switch]$DryRun
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
$repo = Split-Path -Parent $PSScriptRoot
|
||||
$runId = Get-Date -Format "yyyyMMdd-HHmmss"
|
||||
$runDir = Join-Path $repo "artifacts\runtime\online-verse-daemons-$runId"
|
||||
New-Item -ItemType Directory -Force -Path $runDir | Out-Null
|
||||
New-Item -ItemType Directory -Force -Path $RecorderRoot | Out-Null
|
||||
|
||||
function Start-LoggedProcess {
|
||||
param(
|
||||
[string]$Name,
|
||||
[string]$FilePath,
|
||||
[string[]]$ArgumentList,
|
||||
[hashtable]$Environment = @{}
|
||||
)
|
||||
|
||||
$stdout = Join-Path $runDir "$Name.out.log"
|
||||
$stderr = Join-Path $runDir "$Name.err.log"
|
||||
if ($DryRun) {
|
||||
Write-Host "DRY $Name`: $FilePath $($ArgumentList -join ' ')"
|
||||
return $null
|
||||
}
|
||||
|
||||
$previous = @{}
|
||||
foreach ($key in $Environment.Keys) {
|
||||
$previous[$key] = [Environment]::GetEnvironmentVariable($key, "Process")
|
||||
[Environment]::SetEnvironmentVariable($key, [string]$Environment[$key], "Process")
|
||||
}
|
||||
try {
|
||||
$process = Start-Process `
|
||||
-FilePath $FilePath `
|
||||
-ArgumentList $ArgumentList `
|
||||
-WorkingDirectory $repo `
|
||||
-WindowStyle Hidden `
|
||||
-RedirectStandardOutput $stdout `
|
||||
-RedirectStandardError $stderr `
|
||||
-PassThru
|
||||
} finally {
|
||||
foreach ($key in $Environment.Keys) {
|
||||
[Environment]::SetEnvironmentVariable($key, $previous[$key], "Process")
|
||||
}
|
||||
}
|
||||
Set-Content -Path (Join-Path $runDir "$Name.pid") -Value $process.Id
|
||||
Write-Host "$Name pid=$($process.Id) stdout=$stdout stderr=$stderr"
|
||||
return $process
|
||||
}
|
||||
|
||||
$manifest = [ordered]@{
|
||||
kind = "mimir.online_verse_daemon_supervisor.v1"
|
||||
runId = $runId
|
||||
runDir = $runDir
|
||||
witnessUrl = $WitnessUrl
|
||||
subscribeUrl = $SubscribeUrl
|
||||
recorderRoot = $RecorderRoot
|
||||
configPath = $ConfigPath
|
||||
startedAt = (Get-Date).ToString("o")
|
||||
durationSeconds = $DurationSeconds
|
||||
moves = $Move
|
||||
processes = @{}
|
||||
}
|
||||
|
||||
Write-Host "Online Verse daemon run: $runDir"
|
||||
|
||||
if (-not $DryRun) {
|
||||
Get-CimInstance Win32_Process |
|
||||
Where-Object { $_.CommandLine -match "Mimir.EveSensorReceiver" -and $_.CommandLine -match "--port 8796" } |
|
||||
ForEach-Object {
|
||||
try { Stop-Process -Id $_.ProcessId -Force -ErrorAction Stop } catch {}
|
||||
}
|
||||
}
|
||||
|
||||
$receiver = Start-LoggedProcess `
|
||||
-Name "verse-relay" `
|
||||
-FilePath "dotnet" `
|
||||
-ArgumentList @(
|
||||
"run",
|
||||
"--project",
|
||||
(Join-Path $repo "src\Mimir.EveSensorReceiver\Mimir.EveSensorReceiver.csproj"),
|
||||
"--",
|
||||
"--port", "8796",
|
||||
"--path", "/eve/periwinkle",
|
||||
"--subscribe-path", "/eve/periwinkle/subscribe",
|
||||
"--source-id", "nightwing-witness",
|
||||
"--type", "cultmesh-observation"
|
||||
)
|
||||
if ($receiver) { $manifest.processes["verseRelayPid"] = $receiver.Id }
|
||||
|
||||
Start-Sleep -Milliseconds 900
|
||||
|
||||
$recorderArgs = @(
|
||||
"run",
|
||||
"--project",
|
||||
(Join-Path $repo "src\Mimir.VerseRecorder\Mimir.VerseRecorder.csproj"),
|
||||
"--",
|
||||
"--url", $SubscribeUrl,
|
||||
"--out-dir", $RecorderRoot
|
||||
)
|
||||
if ($DurationSeconds -gt 0) {
|
||||
$recorderArgs += "--seconds"
|
||||
$recorderArgs += "$DurationSeconds"
|
||||
}
|
||||
$recorder = Start-LoggedProcess -Name "verse-recorder" -FilePath "dotnet" -ArgumentList $recorderArgs
|
||||
if ($recorder) { $manifest.processes["verseRecorderPid"] = $recorder.Id }
|
||||
|
||||
if (-not $SkipNightwing) {
|
||||
if ($DryRun) {
|
||||
Write-Host "DRY Nightwing stage and witness start on $NightwingHost"
|
||||
} else {
|
||||
scp (Join-Path $repo "tools\nw_eye_cap.py") "${NightwingHost}:/tmp/nw_eye_cap.py" | Out-Null
|
||||
scp (Join-Path $repo "tools\nw_move_hint.py") "${NightwingHost}:/tmp/nw_move_hint.py" | Out-Null
|
||||
scp (Join-Path $repo "tools\nightwing_typed_witness_publisher.py") "${NightwingHost}:/tmp/nightwing_typed_witness_publisher.py" | Out-Null
|
||||
$remoteLog = "~/.local/state/gamecult/mimir-online-verse-witness-$runId.log"
|
||||
$remotePid = "~/.local/state/gamecult/mimir-online-verse-witness-$runId.pid"
|
||||
$remote = "mkdir -p ~/.local/state/gamecult; pkill -f '/tmp/nightwing_typed_witness_publisher.py.*--track-eyes' || true; nohup python3 /tmp/nightwing_typed_witness_publisher.py --url '$WitnessUrl' --track-eyes --interval 0.10 --eye-devices /dev/video2,/dev/video3 --eye-window-seconds 0.08 --tracking-stride 6 > $remoteLog 2>&1 < /dev/null & sleep 0.2; pgrep -n -f '/tmp/nightwing_typed_witness_publisher.py.*--track-eyes' > $remotePid; cat $remotePid"
|
||||
$nightwingPid = ssh $NightwingHost $remote
|
||||
$manifest.processes["nightwingWitnessPid"] = ($nightwingPid | Select-Object -First 1)
|
||||
$manifest.processes["nightwingWitnessLog"] = $remoteLog
|
||||
}
|
||||
}
|
||||
|
||||
if (-not $SkipMoves) {
|
||||
if (-not $DryRun) {
|
||||
Get-CimInstance Win32_Process |
|
||||
Where-Object { $_.CommandLine -match "online_move_music_sync.py" } |
|
||||
ForEach-Object {
|
||||
try { Stop-Process -Id $_.ProcessId -Force -ErrorAction Stop } catch {}
|
||||
}
|
||||
}
|
||||
|
||||
$moveArgs = @(
|
||||
".\tools\online_move_music_sync.py",
|
||||
"--duration", $(if ($DurationSeconds -gt 0) { "$DurationSeconds" } else { "31536000" }),
|
||||
"--out-dir", (Join-Path $runDir "move-sync"),
|
||||
"--device", "Realtek",
|
||||
"--fps", "$MoveFps",
|
||||
"--fft-size", "$MoveFftSize",
|
||||
"--onset-cooldown-seconds", "0.065",
|
||||
"--warmup-seconds", "0.25"
|
||||
)
|
||||
foreach ($spec in $Move) {
|
||||
$moveArgs += "--move"
|
||||
$moveArgs += $spec
|
||||
}
|
||||
$python = "C:\Users\Meta\.cache\codex-runtimes\codex-primary-runtime\dependencies\python\python.exe"
|
||||
$moveProcess = Start-LoggedProcess -Name "move-sync" -FilePath $python -ArgumentList $moveArgs
|
||||
if ($moveProcess) { $manifest.processes["moveSyncPid"] = $moveProcess.Id }
|
||||
}
|
||||
|
||||
if (-not $SkipRuntime) {
|
||||
$runtime = Start-LoggedProcess `
|
||||
-Name "mimir-runtime" `
|
||||
-FilePath "dotnet" `
|
||||
-ArgumentList @(
|
||||
"run",
|
||||
"--project",
|
||||
(Join-Path $repo "src\Mimir.BufferSmoke\Mimir.BufferSmoke.csproj"),
|
||||
"--",
|
||||
"--seconds", $(if ($DurationSeconds -gt 0) { "$DurationSeconds" } else { "31536000" }),
|
||||
"--poll-ms", "5",
|
||||
"--sync-reference", "asio-ch2",
|
||||
"--require-samples"
|
||||
) `
|
||||
-Environment @{
|
||||
"MIMIR_RUNTIME_CONFIG" = $ConfigPath
|
||||
"MIMIR_SYNC_TELEMETRY_SECONDS" = "1"
|
||||
}
|
||||
if ($runtime) { $manifest.processes["mimirRuntimePid"] = $runtime.Id }
|
||||
}
|
||||
|
||||
$manifestPath = Join-Path $runDir "supervisor.json"
|
||||
$manifest | ConvertTo-Json -Depth 6 | Set-Content -Path $manifestPath
|
||||
Write-Host "Supervisor manifest: $manifestPath"
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
|
|
@ -14,7 +15,8 @@ internal sealed record EveSensorReceiverOptions(
|
|||
int Port,
|
||||
string Path,
|
||||
string SourceId,
|
||||
string ExpectedType)
|
||||
string ExpectedType,
|
||||
string SubscribePath)
|
||||
{
|
||||
public static EveSensorReceiverOptions Parse(string[] args)
|
||||
{
|
||||
|
|
@ -22,7 +24,8 @@ internal sealed record EveSensorReceiverOptions(
|
|||
ParseInt(args, "--port", 8793),
|
||||
ParseString(args, "--path", "/eve/camera"),
|
||||
ParseString(args, "--source-id", "eve-camera"),
|
||||
ParseString(args, "--type", "video-frame"));
|
||||
ParseString(args, "--type", "video-frame"),
|
||||
ParseString(args, "--subscribe-path", ParseString(args, "--path", "/eve/camera") + "/subscribe"));
|
||||
}
|
||||
|
||||
private static string ParseString(IReadOnlyList<string> args, string name, string fallback)
|
||||
|
|
@ -48,6 +51,8 @@ internal sealed class EveSensorReceiver(EveSensorReceiverOptions options) : IDis
|
|||
{
|
||||
private readonly TcpListener listener = new(IPAddress.Any, options.Port);
|
||||
private readonly CancellationTokenSource stopping = new();
|
||||
private readonly ConcurrentDictionary<int, WebSocketSubscriber> subscribers = new();
|
||||
private int nextSubscriberId;
|
||||
|
||||
public async Task RunAsync()
|
||||
{
|
||||
|
|
@ -72,11 +77,21 @@ internal sealed class EveSensorReceiver(EveSensorReceiverOptions options) : IDis
|
|||
options.SourceId,
|
||||
options.ExpectedType,
|
||||
options.Path,
|
||||
options.SubscribePath,
|
||||
Subscribers = subscribers.Count,
|
||||
});
|
||||
await WriteHttpResponseAsync(stream, "200 OK", "application/json", Encoding.UTF8.GetBytes(health)).ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (string.Equals(request.Path, options.SubscribePath, StringComparison.Ordinal)
|
||||
&& request.Headers.TryGetValue("Sec-WebSocket-Key", out var subscriberKey))
|
||||
{
|
||||
await WriteWebSocketHandshakeAsync(stream, subscriberKey).ConfigureAwait(false);
|
||||
await SubscribeAsync(stream).ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!string.Equals(request.Path, options.Path, StringComparison.Ordinal)
|
||||
|| !request.Headers.TryGetValue("Sec-WebSocket-Key", out var key))
|
||||
{
|
||||
|
|
@ -101,6 +116,7 @@ internal sealed class EveSensorReceiver(EveSensorReceiverOptions options) : IDis
|
|||
{
|
||||
Console.WriteLine(normalizedObservation);
|
||||
Console.Out.Flush();
|
||||
await BroadcastAsync(normalizedObservation).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
continue;
|
||||
|
|
@ -116,6 +132,71 @@ internal sealed class EveSensorReceiver(EveSensorReceiverOptions options) : IDis
|
|||
{
|
||||
Console.WriteLine(normalized);
|
||||
Console.Out.Flush();
|
||||
await BroadcastAsync(normalized).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async Task SubscribeAsync(NetworkStream stream)
|
||||
{
|
||||
var id = Interlocked.Increment(ref nextSubscriberId);
|
||||
var subscriber = new WebSocketSubscriber(id, stream);
|
||||
subscribers[id] = subscriber;
|
||||
Console.Error.WriteLine($"Eve sensor receiver subscriber {id} connected on {options.SubscribePath}.");
|
||||
try
|
||||
{
|
||||
await subscriber.SendTextAsync(JsonSerializer.Serialize(new
|
||||
{
|
||||
type = "mimir-verse-subscription",
|
||||
status = "connected",
|
||||
options.Path,
|
||||
options.SubscribePath,
|
||||
options.SourceId,
|
||||
options.ExpectedType,
|
||||
})).ConfigureAwait(false);
|
||||
|
||||
while (!stopping.IsCancellationRequested)
|
||||
{
|
||||
var frame = await ReceiveFrameAsync(stream).ConfigureAwait(false);
|
||||
if (frame.Opcode == 0x8)
|
||||
{
|
||||
await WriteCloseFrameAsync(stream).ConfigureAwait(false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (IOException)
|
||||
{
|
||||
}
|
||||
catch (SocketException)
|
||||
{
|
||||
}
|
||||
finally
|
||||
{
|
||||
subscribers.TryRemove(id, out _);
|
||||
Console.Error.WriteLine($"Eve sensor receiver subscriber {id} disconnected.");
|
||||
}
|
||||
}
|
||||
|
||||
private async Task BroadcastAsync(string normalized)
|
||||
{
|
||||
foreach (var pair in subscribers.ToArray())
|
||||
{
|
||||
try
|
||||
{
|
||||
await pair.Value.SendTextAsync(normalized).ConfigureAwait(false);
|
||||
}
|
||||
catch (IOException)
|
||||
{
|
||||
subscribers.TryRemove(pair.Key, out _);
|
||||
}
|
||||
catch (SocketException)
|
||||
{
|
||||
subscribers.TryRemove(pair.Key, out _);
|
||||
}
|
||||
catch (ObjectDisposedException)
|
||||
{
|
||||
subscribers.TryRemove(pair.Key, out _);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -374,3 +455,46 @@ internal sealed class EveSensorReceiver(EveSensorReceiverOptions options) : IDis
|
|||
internal sealed record HttpRequest(string Path, IReadOnlyDictionary<string, string> Headers);
|
||||
|
||||
internal sealed record WebSocketFrame(int Opcode, byte[] Payload);
|
||||
|
||||
internal sealed class WebSocketSubscriber(int id, NetworkStream stream)
|
||||
{
|
||||
private readonly SemaphoreSlim writeLock = new(1, 1);
|
||||
|
||||
public int Id => id;
|
||||
|
||||
public async Task SendTextAsync(string text)
|
||||
{
|
||||
var payload = Encoding.UTF8.GetBytes(text);
|
||||
var header = new List<byte> { 0x81 };
|
||||
if (payload.Length < 126)
|
||||
{
|
||||
header.Add((byte)payload.Length);
|
||||
}
|
||||
else if (payload.Length <= ushort.MaxValue)
|
||||
{
|
||||
header.Add(126);
|
||||
header.Add((byte)(payload.Length >> 8));
|
||||
header.Add((byte)(payload.Length & 0xff));
|
||||
}
|
||||
else
|
||||
{
|
||||
header.Add(127);
|
||||
for (var shift = 56; shift >= 0; shift -= 8)
|
||||
{
|
||||
header.Add((byte)(((ulong)payload.Length >> shift) & 0xff));
|
||||
}
|
||||
}
|
||||
|
||||
await writeLock.WaitAsync().ConfigureAwait(false);
|
||||
try
|
||||
{
|
||||
await stream.WriteAsync(header.ToArray()).ConfigureAwait(false);
|
||||
await stream.WriteAsync(payload).ConfigureAwait(false);
|
||||
await stream.FlushAsync().ConfigureAwait(false);
|
||||
}
|
||||
finally
|
||||
{
|
||||
writeLock.Release();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
12
src/Mimir.VerseRecorder/Mimir.VerseRecorder.csproj
Normal file
12
src/Mimir.VerseRecorder/Mimir.VerseRecorder.csproj
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<AssemblyName>Mimir.VerseRecorder</AssemblyName>
|
||||
<RootNamespace>Mimir.VerseRecorder</RootNamespace>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
151
src/Mimir.VerseRecorder/Program.cs
Normal file
151
src/Mimir.VerseRecorder/Program.cs
Normal file
|
|
@ -0,0 +1,151 @@
|
|||
using System.Net.WebSockets;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
|
||||
var options = VerseRecorderOptions.Parse(args);
|
||||
Directory.CreateDirectory(options.OutputDirectory);
|
||||
var runId = DateTimeOffset.Now.ToString("yyyyMMdd-HHmmss");
|
||||
var runDirectory = Path.Combine(options.OutputDirectory, runId);
|
||||
Directory.CreateDirectory(runDirectory);
|
||||
var jsonlPath = Path.Combine(runDirectory, "observations.jsonl");
|
||||
var sessionPath = Path.Combine(runDirectory, "session.json");
|
||||
|
||||
await File.WriteAllTextAsync(
|
||||
sessionPath,
|
||||
JsonSerializer.Serialize(
|
||||
new
|
||||
{
|
||||
kind = "mimir.verse_recorder_session.v1",
|
||||
runId,
|
||||
options.Url,
|
||||
startedAt = DateTimeOffset.Now.ToString("O"),
|
||||
options.Seconds,
|
||||
observations = jsonlPath,
|
||||
},
|
||||
new JsonSerializerOptions { WriteIndented = true }));
|
||||
|
||||
Console.Error.WriteLine($"Mimir Verse recorder subscribing to {options.Url}");
|
||||
Console.Error.WriteLine($"Writing {jsonlPath}");
|
||||
|
||||
using var stopping = new CancellationTokenSource();
|
||||
if (options.Seconds > 0)
|
||||
{
|
||||
stopping.CancelAfter(TimeSpan.FromSeconds(options.Seconds));
|
||||
}
|
||||
|
||||
Console.CancelKeyPress += (_, eventArgs) =>
|
||||
{
|
||||
eventArgs.Cancel = true;
|
||||
stopping.Cancel();
|
||||
};
|
||||
|
||||
var count = 0L;
|
||||
var lastMeter = DateTimeOffset.UtcNow;
|
||||
await using var output = new StreamWriter(new FileStream(jsonlPath, FileMode.Create, FileAccess.Write, FileShare.Read), Encoding.UTF8);
|
||||
|
||||
while (!stopping.IsCancellationRequested)
|
||||
{
|
||||
using var socket = new ClientWebSocket();
|
||||
try
|
||||
{
|
||||
await socket.ConnectAsync(options.Url, stopping.Token);
|
||||
while (socket.State == WebSocketState.Open && !stopping.IsCancellationRequested)
|
||||
{
|
||||
var text = await ReceiveTextAsync(socket, stopping.Token);
|
||||
if (text == null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
await output.WriteLineAsync(text);
|
||||
count++;
|
||||
if (DateTimeOffset.UtcNow - lastMeter >= TimeSpan.FromSeconds(options.MeterSeconds))
|
||||
{
|
||||
await output.FlushAsync();
|
||||
Console.Error.WriteLine($"verse-recorder observations={count} path={jsonlPath}");
|
||||
lastMeter = DateTimeOffset.UtcNow;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (OperationCanceledException) when (stopping.IsCancellationRequested)
|
||||
{
|
||||
break;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.Error.WriteLine($"verse-recorder reconnect after {ex.GetType().Name}: {ex.Message}");
|
||||
try
|
||||
{
|
||||
await Task.Delay(TimeSpan.FromSeconds(options.ReconnectSeconds), stopping.Token);
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
await output.FlushAsync();
|
||||
Console.Error.WriteLine($"verse-recorder complete observations={count} path={jsonlPath}");
|
||||
|
||||
static async Task<string?> ReceiveTextAsync(ClientWebSocket socket, CancellationToken stopping)
|
||||
{
|
||||
var buffer = new byte[64 * 1024];
|
||||
using var memory = new MemoryStream();
|
||||
while (true)
|
||||
{
|
||||
var result = await socket.ReceiveAsync(buffer, stopping);
|
||||
if (result.MessageType == WebSocketMessageType.Close)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
memory.Write(buffer, 0, result.Count);
|
||||
if (result.EndOfMessage)
|
||||
{
|
||||
return Encoding.UTF8.GetString(memory.ToArray());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal sealed record VerseRecorderOptions(
|
||||
Uri Url,
|
||||
string OutputDirectory,
|
||||
double Seconds,
|
||||
double ReconnectSeconds,
|
||||
double MeterSeconds)
|
||||
{
|
||||
public static VerseRecorderOptions Parse(string[] args)
|
||||
{
|
||||
var defaultOutput = Path.Combine(
|
||||
Environment.GetFolderPath(Environment.SpecialFolder.MyVideos),
|
||||
"Mimir",
|
||||
"VerseCaptures");
|
||||
return new VerseRecorderOptions(
|
||||
new Uri(ParseString(args, "--url", "ws://127.0.0.1:8796/eve/periwinkle/subscribe")),
|
||||
ParseString(args, "--out-dir", defaultOutput),
|
||||
ParseDouble(args, "--seconds", 0.0),
|
||||
ParseDouble(args, "--reconnect-seconds", 2.0),
|
||||
ParseDouble(args, "--meter-seconds", 5.0));
|
||||
}
|
||||
|
||||
private static string ParseString(IReadOnlyList<string> args, string name, string fallback)
|
||||
{
|
||||
for (var index = 0; index < args.Count - 1; index++)
|
||||
{
|
||||
if (string.Equals(args[index], name, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return args[index + 1];
|
||||
}
|
||||
}
|
||||
|
||||
return fallback;
|
||||
}
|
||||
|
||||
private static double ParseDouble(IReadOnlyList<string> args, string name, double fallback)
|
||||
{
|
||||
return double.TryParse(ParseString(args, name, ""), out var value)
|
||||
? value
|
||||
: fallback;
|
||||
}
|
||||
}
|
||||
|
|
@ -335,3 +335,4 @@
|
|||
{"ts": "2026-06-01T14:51:58+01:00", "type": "decision", "status": "ok", "note": "2026-06-01: Eve is the portable dashboard authority. The C# CultUI-shaped Aquarium UI contract is a reference API for retained dashboard documents; Fensalir Direct2D/D3D12 are native lowerings of that document, not the owner. The Mimir editor now uses edge-to-edge headerless panels with fixed output controls and an expanding inspector through that shared document model."}
|
||||
{"ts": "2026-06-01T17:38:44+01:00", "type": "implementation", "status": "ok", "note": "2026-06-01: Eve/CultUI retained elements now carry typed CultCache/CultMesh binding descriptors (document schema/id, field path, value kind, access, authority, optional command id). Mimir binds editor output controls, selected-layer inspector fields, audio strips, and preview placement to those descriptors while native callbacks remain local lowering actuators."}
|
||||
{"ts": "2026-06-01T17:42:27+01:00", "type": "verification", "status": "ok", "note": "2026-06-01: Release builds passed for Fensalir Aquarium.Engine, Mimir.EveDashboard, and Mimir.App after adding typed Eve/CultUI binding descriptors. Mimir.BufferSmoke --scene-editor-smoke passed with preview/source placement interactions intact."}
|
||||
{"ts": "2026-06-01T21:06:07+01:00", "type": "implementation", "status": "ok", "note": "Added the first online Verse observation daemon stack: Mimir.EveSensorReceiver now serves a /eve/periwinkle/subscribe WebSocket lane, Mimir.VerseRecorder subscribes and writes session.json plus observations.jsonl under C:\\Users\\Meta\\Videos\\Mimir\\VerseCaptures, and scripts/start-online-verse-daemons.ps1 supervises relay, recorder, Nightwing Eyes/Move witness publication, music-synced Move gestures, and a local BufferSmoke runtime capture worker. Live run online-verse-daemons-20260601-210106 had relay, recorder, Move sync, BufferSmoke, and Nightwing witness running, with observations.jsonl past 1000 records and growing. This captures typed witness observations; raw aligned source windows/stems still need a MimirSynchronizationHub Verse publisher."}
|
||||
|
|
|
|||
|
|
@ -308,6 +308,17 @@ invariants:
|
|||
Machine profile emit typed Move observation, camera feature-track, and
|
||||
visual marker state; raw Eye media from Nightwing is diagnostic only and
|
||||
Nightwing does not own camera placement or the canonical clock.
|
||||
`Mimir.EveSensorReceiver` now has the first subscriber lane for this
|
||||
witness stream: `/eve/periwinkle` ingests typed observations and
|
||||
`/eve/periwinkle/subscribe` broadcasts normalized records to live
|
||||
subscribers. `Mimir.VerseRecorder` subscribes and writes a session manifest
|
||||
plus JSONL observation ledger under `C:\Users\Meta\Videos\Mimir\VerseCaptures`.
|
||||
`scripts/start-online-verse-daemons.ps1` supervises relay, recorder,
|
||||
Nightwing Eyes/Move witness publication, music-synced Move gestures, and a
|
||||
local `Mimir.BufferSmoke` runtime capture worker. This owns observation
|
||||
capture, not raw aligned media/stem publication yet; the next owner cut is
|
||||
a `MimirSynchronizationHub` Verse publisher for aligned source windows,
|
||||
sync states, stems, and actuator state.
|
||||
Eve follows the same distributed-witness rule for its own body:
|
||||
`eve-local-sensor-witness` / `eve-local-sensors` owns Eve camera, Eve mic,
|
||||
local flash/chirp decode, feature tracks, visual markers, and local frustum
|
||||
|
|
|
|||
Loading…
Reference in a new issue