From 231573ed79ce1425939363306ce6b1e99c735ac3 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Thu, 11 Jun 2026 17:00:49 +0100 Subject: [PATCH] Move wand fusion authority to Mimir --- docs/implementation-plan.md | 17 +++--- docs/perfect-machine-module-library.md | 12 ++-- notes/current-system-map.md | 42 ++++++++------ src/Mimir.BufferSmoke/Program.cs | 19 ++++++- .../Synchronization/MimirModuleLibrary.cs | 10 +++- .../MimirTrackingObservation.cs | 56 +++++++++++++++++++ state/evidence.jsonl | 1 + state/map.yaml | 25 +++++---- 8 files changed, 138 insertions(+), 44 deletions(-) diff --git a/docs/implementation-plan.md b/docs/implementation-plan.md index f3c69db..6010b14 100644 --- a/docs/implementation-plan.md +++ b/docs/implementation-plan.md @@ -34,11 +34,14 @@ a named invariant that the native runtime cannot protect yet. and video/tracking streams. - `MimirNativeIngestStreamSource` for direct push ingest into runtime buffers. - `MimirStreamKind.Tracking` plus `MimirTrackingObservation` carry PS Move - pose/button/battery/confidence samples as typed - `mimir.move_tracking_observation.v1` documents. Starfire and Nightwing both - have USB-attached Moves; Starfire can feed local tracking streams, while - Muninn on Nightwing publishes remote tracking streams. Odin owns discovery and - schema projection, not pose capture or Mimir fusion. + evidence samples as typed `mimir.move_tracking_observation.v1` documents. + Starfire and Nightwing both have USB-attached Moves. Muninn daemons publish + source-local glowing-orb marker candidates and controller/IMU/button state; + Odin owns discovery and schema projection, not pose fusion. +- `mimir.move_controller_pose.v1` is Mimir's resolved wand pose contract. + Mimir owns calibration, association, triangulation, IMU fusion, prediction, + confidence, and latency accounting for those poses before Fensalir consumes + them as interactive controller input. - `scripts/start-nightwing-move-tracking.ps1` is the narrow live Nightwing bring-up path: it starts the `/eve/periwinkle` receiver/recorder on Starfire, stages the Nightwing Eye/Move Python worker, keeps a heartbeat for field @@ -57,8 +60,8 @@ a named invariant that the native runtime cannot protect yet. `E:\Projects\Odin\crates\muninn-move-tracker` and publishes/feeds `muninn.move_marker_candidate.v1` records. Mimir consumes those candidate streams; it does not own raw optical extraction. Final pose, stereo - triangulation, calibration, association, IMU fusion, and prediction remain - separate later owners. + triangulation, calibration, association, IMU fusion, and prediction belong to + Mimir. - `MimirProcessStreamSource` for bridge/network command edges. - `MimirFrameEventProcessStreamSource` for temporary JSON-line frame metadata from native probes into the same rolling buffers Fensalir inspects. One probe diff --git a/docs/perfect-machine-module-library.md b/docs/perfect-machine-module-library.md index 1c6a313..1e30e44 100644 --- a/docs/perfect-machine-module-library.md +++ b/docs/perfect-machine-module-library.md @@ -13,7 +13,8 @@ job-interview answer for why it belongs in the body of the machine. | Bioacoustic clock solver | `Mimir.Runtime` | Fits canonical source time from decoded word anchors for local, Raven, phone, and microcontroller witnesses. | `src/Mimir.Runtime/Synchronization/MimirBioacousticClockHypothesis.cs` | | Alignment actuator | `Mimir.Runtime` + Faust | Converts sync state into bounded fractional-delay, gain, and sample-rate-offset controls; Faust moves samples. | `src/Mimir.Runtime/Synchronization/MimirAudioAlignmentActuator.cs` | | Audio actuator strategies | `Mimir.Runtime` + Faust | Integer baseline, Farrow fractional delay, variable ASRC, and hybrid delay/ASRC strategy profiles. | `src/Mimir.Runtime/Synchronization/MimirAudioActuatorConfiguration.cs` | -| CultMesh contracts | `Mimir.Runtime` | Typed codebook, decoder, acoustic path, actuator, program, and Move tracking observation documents for distributed Mimir nodes. | `src/Mimir.Runtime/Synchronization/MimirCultMeshContracts.cs`, `src/Mimir.Runtime/Synchronization/MimirTrackingObservation.cs` | +| CultMesh contracts | `Mimir.Runtime` | Typed codebook, decoder, acoustic path, actuator, program, Move evidence, and Mimir-fused Move controller pose documents for distributed Mimir nodes. | `src/Mimir.Runtime/Synchronization/MimirCultMeshContracts.cs`, `src/Mimir.Runtime/Synchronization/MimirTrackingObservation.cs` | +| Move controller fusion | `Mimir.Runtime` + Fensalir | Mimir fuses Muninn marker candidates plus controller/IMU/button feeds into `mimir.move_controller_pose.v1`; Fensalir consumes the resolved pose stream for interactive environments. | `src/Mimir.Runtime/Synchronization/MimirTrackingObservation.cs` | | Acoustic path learning | `Mimir.Runtime` | Calibration stages for usable bands, confusion, global delay, group delay, and codebook adaptation. | `src/Mimir.Runtime/Synchronization/MimirAcousticPathLearningConfiguration.cs` | | Acoustic localization | `Mimir.Runtime` + Fensalir | Pairwise TDOA, SRP-PHAT grid, sparse source, and visual-constrained localization profiles plus a small SRP/TDOA scorer. | `src/Mimir.Runtime/Synchronization/MimirAcousticLocalizationConfiguration.cs`, `src/Mimir.Runtime/Synchronization/MimirAcousticLocalizationSolver.cs` | | Benchmark panels | `Mimir.Runtime` | Decoder golf and meatspace acceptance degradation panels with receipt roots and thresholds. | `src/Mimir.Runtime/Synchronization/MimirBenchmarkPanelConfiguration.cs` | @@ -42,9 +43,12 @@ job-interview answer for why it belongs in the body of the machine. stem generation. - CultMesh carries typed state surfaces; remote nodes may observe and decode, but they do not become independent clock authorities. -- USB-attached Moves on Starfire and Nightwing publish - `mimir.move_tracking_observation.v1` as tracking streams. Muninn emits the - witness, Odin discovers/projects it, and Mimir owns buffering plus fusion. +- USB-attached Moves on Starfire and Nightwing publish source-local Muninn + evidence streams: glowing-orb marker candidates and controller/IMU/button + state. Odin discovers/projects those streams. Mimir owns buffering, + calibration, association, triangulation, IMU fusion, prediction, and + `mimir.move_controller_pose.v1` publication. Fensalir consumes that resolved + pose stream for interactive environments. - OBS may receive compatibility program surfaces and stems. It does not own calibration, composition, preview/control, or publication. diff --git a/notes/current-system-map.md b/notes/current-system-map.md index 9ffc0bf..6513587 100644 --- a/notes/current-system-map.md +++ b/notes/current-system-map.md @@ -45,11 +45,12 @@ Ownership: becoming independent clock authorities. - `Mimir.Runtime` owns app-level stream buffers and synchronization. - Native capture workers own device reads. -- Move tracking observations are stream samples, not program controls. USB - Moves plugged into Starfire produce local tracking streams; USB Moves plugged - into Nightwing are published by Muninn on Nightwing as remote tracking - streams. Odin owns discovery/schema projection for those streams and does not - own pose capture or Mimir fusion. +- Move tracking observations are stream samples, not program controls. Muninn + daemons on Starfire and Nightwing publish source-local optical marker + candidates plus controller/IMU/button state for USB-attached Moves. Odin owns + discovery/schema projection for those streams. Mimir owns calibration, + association, triangulation, IMU fusion, prediction, and the resolved + Fensalir-facing wand pose stream. - Mimir owns program composition, source subscription policy, preview/control state, stats, and publication intent. - Fensalir owns dense visual fusion, material/brush/splat reconciliation, @@ -99,16 +100,18 @@ one process with declared accepted source ids, not one process per camera. ## Move Tracking Starfire and Nightwing both have PS Move controllers directly attached over -USB. Mimir represents those controller poses as `MimirStreamKind.Tracking` -buffers carrying typed `mimir.move_tracking_observation.v1` samples. Each -sample names the stream, device, producer, host, Odin discovery provider, -tracking space, calibration id, source timestamp, pose, velocity, buttons, -battery, latency, and confidence. +USB. Muninn represents what each local body can honestly observe: +`muninn.move_marker_candidate.v1` for glowing orb candidates from cameras and +`muninn.move_controller_state.v1` for controller/IMU/button/battery state from +USB-attached Moves. Mimir drinks those feeds into `MimirStreamKind.Tracking` +buffers and publishes resolved `mimir.move_controller_pose.v1` documents for +Fensalir interaction once calibration and fusion have earned a pose. Authority: -- Starfire-local Move tracking is a local Mimir/Muninn tracking stream. -- Nightwing Move tracking is emitted by Muninn on Nightwing over the typed +- Starfire-local Move evidence is published by Muninn/Mimir local producers as + typed observation streams. +- Nightwing Move evidence is emitted by Muninn on Nightwing over the typed observation path. - Structured PS Move light pulses are Muninn output commands. Mimir requests them by sending `muninn.move_light_command.v1` over CultNet/CultMesh to the @@ -117,9 +120,12 @@ Authority: hardware behavior before Muninn is available on that host. - Odin discovers and projects the stream/schema surface for operator and agent access. -- Mimir owns subscription, rolling retention, clock alignment, and later fusion - with cameras/audio/Leap/Fensalir. OBS and dashboard summaries do not own this - state. +- Mimir owns subscription, rolling retention, clock alignment, calibration, + controller association, triangulation, IMU fusion, prediction, and resolved + wand pose publication. OBS and dashboard summaries do not own this state. +- Fensalir consumes Mimir's resolved Move controller poses as interactive input + for environments; it does not synthesize controller truth from raw Muninn + evidence. Smoke proof: `dotnet run --project .\src\Mimir.BufferSmoke\Mimir.BufferSmoke.csproj -- --move-tracking-contract-smoke` consumes one Starfire Move and one Nightwing @@ -146,9 +152,9 @@ Odin's Muninn organ owns the Move optical extraction stage for sensor stream exposure. Its Rust crate lives in `E:\Projects\Odin\crates\muninn-move-tracker` and publishes/feeds `muninn.move_marker_candidate.v1` records. Mimir consumes those Muninn candidate streams into tracking buffers; it does not own raw -optical extraction. Stereo triangulation, camera calibration, controller -association, IMU fusion, prediction, and final 6DoF pose remain separate later -owners. +optical extraction. Mimir is now the explicit owner for stereo triangulation, +camera calibration, controller association, IMU fusion, prediction, and final +6DoF wand pose. ## Program Composition diff --git a/src/Mimir.BufferSmoke/Program.cs b/src/Mimir.BufferSmoke/Program.cs index eb631d4..637aea9 100644 --- a/src/Mimir.BufferSmoke/Program.cs +++ b/src/Mimir.BufferSmoke/Program.cs @@ -857,7 +857,7 @@ static async Task RunBioacousticContestantsAsync( foreach (var decoder in decoders) { - var index = BuildCepstralContestantWordIndex(sampleRate, decoder.Decoder, renderer); + var index = BuildCepstralContestantWordIndex(sampleRate, decoder.Decoder, renderer); foreach (var degradation in degradations) { var degraded = RoundTripThroughDegradedCepstrum(source, sampleRate, degradation, out var analysis); @@ -1701,6 +1701,17 @@ static async Task RunPerfectMachineContractSmokeAsync(string outputPath) hostId: "nightwing", latencyMilliseconds: 4.6, battery01: 0.67); + var fusedMovePose = MimirMoveControllerPoseDocument.FromObservation( + nightwingMove, + "move:right", + [ + "muninn:nightwing:ps3-eye-0:move-marker-candidates", + "muninn:nightwing:ps3-eye-1:move-marker-candidates", + "muninn:nightwing:move-usb:controller-state", + "muninn:starfire:move-usb:controller-state" + ], + ["optical-marker-candidate", "optical-marker-candidate", "imu-controller-state", "imu-controller-state"], + "mimir-move-stage-calibration-v1"); Directory.CreateDirectory(Path.GetDirectoryName(Path.GetFullPath(outputPath)) ?? "."); using var cache = await CultCacheMessagePack.OpenAsync(outputPath, new CultCacheOpenOptions @@ -1743,10 +1754,14 @@ static async Task RunPerfectMachineContractSmokeAsync(string outputPath) nightwingMove, new CultRecordHandle(new CultRecordKey($"mimir-move-tracking:{nightwingMove.ObservationId}"))) .ConfigureAwait(false); + await cache.UpsertAsync( + fusedMovePose, + new CultRecordHandle(new CultRecordKey($"mimir-move-controller-pose:{fusedMovePose.PoseId}"))) + .ConfigureAwait(false); await cache.FlushAsync().ConfigureAwait(false); Console.WriteLine( - $"perfect-machine-contract-smoke path={outputPath} codebookMotifs={codebook.Motifs.Length} decoder={decoder.Configuration.Id} pathBands={pathState.BandResponses.Length} actuatorControls={actuator.FaustControls.Length} sceneLayers={scene.Layers.Length} programOutput={output.OutputId} eveCommands={eveSurface.CommandTopics.Length} moveTracking=2 hosts={starfireMove.HostId},{nightwingMove.HostId}"); + $"perfect-machine-contract-smoke path={outputPath} codebookMotifs={codebook.Motifs.Length} decoder={decoder.Configuration.Id} pathBands={pathState.BandResponses.Length} actuatorControls={actuator.FaustControls.Length} sceneLayers={scene.Layers.Length} programOutput={output.OutputId} eveCommands={eveSurface.CommandTopics.Length} moveTracking=2 fusedMovePose={fusedMovePose.PoseId} authority={fusedMovePose.FusionAuthorityId} consumer={fusedMovePose.ConsumerContract} hosts={starfireMove.HostId},{nightwingMove.HostId}"); return 0; } diff --git a/src/Mimir.Runtime/Synchronization/MimirModuleLibrary.cs b/src/Mimir.Runtime/Synchronization/MimirModuleLibrary.cs index 1b84f06..18af289 100644 --- a/src/Mimir.Runtime/Synchronization/MimirModuleLibrary.cs +++ b/src/Mimir.Runtime/Synchronization/MimirModuleLibrary.cs @@ -47,9 +47,15 @@ public static class MimirModuleLibrary new( "cultmesh-contracts", "Mimir.Runtime", - "Typed state documents for codebooks, decoder state, acoustic path state, actuator state, program state, and Move tracking observations.", - ["mimir.bioacoustic_codebook_state", "mimir.bioacoustic_decoder_state", "mimir.acoustic_path_state", "mimir.actuator_state", "mimir.move_tracking_observation"], + "Typed state documents for codebooks, decoder state, acoustic path state, actuator state, program state, Move evidence, and Mimir-fused Move controller poses.", + ["mimir.bioacoustic_codebook_state", "mimir.bioacoustic_decoder_state", "mimir.acoustic_path_state", "mimir.actuator_state", "mimir.move_tracking_observation", "mimir.move_controller_pose"], ["dotnet run --project .\\src\\Mimir.BufferSmoke\\Mimir.BufferSmoke.csproj -- --perfect-machine-contract-smoke"]), + new( + "move-controller-fusion", + "Mimir.Runtime + Fensalir", + "Mimir fuses Muninn marker candidates, controller IMU/button state, calibration, and timing into resolved wand poses; Fensalir consumes those poses for interaction.", + ["mimir.move_controller_pose.v1", "muninn.move_marker_candidate.v1", "muninn.move_controller_state.v1"], + ["dotnet run --project .\\src\\Mimir.BufferSmoke\\Mimir.BufferSmoke.csproj -- --move-tracking-contract-smoke"]), new( "path-learning", "Mimir.Runtime", diff --git a/src/Mimir.Runtime/Synchronization/MimirTrackingObservation.cs b/src/Mimir.Runtime/Synchronization/MimirTrackingObservation.cs index fc18182..a2774cb 100644 --- a/src/Mimir.Runtime/Synchronization/MimirTrackingObservation.cs +++ b/src/Mimir.Runtime/Synchronization/MimirTrackingObservation.cs @@ -98,3 +98,59 @@ public sealed record MimirTrackingObservation( double.IsFinite(battery01) ? Math.Clamp(battery01, 0.0, 1.0) : double.NaN, buttons ?? []); } + +[CultDocument("mimir.move_controller_pose", "mimir.move_controller_pose.v1")] +[MessagePackObject] +public sealed record MimirMoveControllerPoseDocument( + [property: Key(0)] + [property: CultName] + string PoseId, + [property: Key(1)] string WandId, + [property: Key(2)] string TrackingSpaceId, + [property: Key(3)] string CalibrationId, + [property: Key(4)] string FusionAuthorityId, + [property: Key(5)] long SourceTimestampNs, + [property: Key(6)] long EstimatedAtNs, + [property: Key(7)] ulong Sequence, + [property: Key(8)] MimirVector3Snapshot PositionMeters, + [property: Key(9)] MimirQuaternionSnapshot Orientation, + [property: Key(10)] MimirVector3Snapshot LinearVelocityMetersPerSecond, + [property: Key(11)] MimirVector3Snapshot AngularVelocityRadiansPerSecond, + [property: Key(12)] double Confidence, + [property: Key(13)] double LatencyMilliseconds, + [property: Key(14)] double Battery01, + [property: Key(15)] MimirTrackingButtonSnapshot[] Buttons, + [property: Key(16)] string[] EvidenceStreamIds, + [property: Key(17)] string[] EvidenceKinds, + [property: Key(18)] string ConsumerContract) +{ + public static MimirMoveControllerPoseDocument FromObservation( + MimirTrackingObservation observation, + string wandId, + string[] evidenceStreamIds, + string[] evidenceKinds, + string calibrationId, + string trackingSpaceId = "mimir-stage-space", + string fusionAuthorityId = "mimir.runtime.move-fusion", + string consumerContract = "fensalir.move-controller-input") => + new( + $"{wandId}:{observation.Sequence}", + wandId, + trackingSpaceId, + calibrationId, + fusionAuthorityId, + observation.SourceTimestampNs, + observation.ArrivalTimestampNs, + observation.Sequence, + observation.PositionMeters, + observation.Orientation, + observation.LinearVelocityMetersPerSecond, + observation.AngularVelocityRadiansPerSecond, + Math.Clamp(observation.Confidence, 0.0, 1.0), + Math.Max(0.0, observation.LatencyMilliseconds), + double.IsFinite(observation.Battery01) ? Math.Clamp(observation.Battery01, 0.0, 1.0) : double.NaN, + observation.Buttons, + evidenceStreamIds, + evidenceKinds, + consumerContract); +} diff --git a/state/evidence.jsonl b/state/evidence.jsonl index 9f5c7d5..5734bb7 100644 --- a/state/evidence.jsonl +++ b/state/evidence.jsonl @@ -129,3 +129,4 @@ {"ts": "2026-06-10T20:33:54+01:00", "type": "implementation", "status": "ok", "note": "Added native/move_tracker as Rust-orchestrated PS Move optical candidate extraction: Rust owns dispatch/FFI/CPU mirror; HLSL owns 16px-tile luma reduction. Scope is marker candidates only, before calibration/triangulation/IMU fusion/prediction."} {"ts": "2026-06-10T20:49:06+01:00", "type": "decision", "status": "ok", "note": "Corrected Move optical candidate ownership: the Rust/HLSL tracker moved out of Mimir and into Odin's Muninn organ at E:\\Projects\\Odin\\crates\\muninn-move-tracker. Mimir consumes muninn.move_marker_candidate.v1 streams and no longer owns raw optical extraction."} {"ts": "2026-06-11T07:57:05+01:00", "type": "decision", "status": "ok", "note": "PS Move structured light ownership moved to Odin/Muninn: Mimir requests muninn.move_light_command.v1 over CultNet/CultMesh; Muninn serve consumes host-addressed pending commands, writes local HID report 0x06, and updates command state. Nightwing direct HID launcher path is opt-in smoke/bootstrap only."} +{"ts": "2026-06-11T16:59:31+01:00", "type": "decision", "status": "ok", "note": "Move sensor fusion authority moved to Mimir: Muninn publishes source-local marker candidates and controller/IMU/button state, Odin discovers/projects schemas, Mimir owns calibration, association, triangulation, IMU fusion, prediction, confidence, latency, and mimir.move_controller_pose.v1 for Fensalir interaction."} diff --git a/state/map.yaml b/state/map.yaml index 639b97c..bd2c12b 100644 --- a/state/map.yaml +++ b/state/map.yaml @@ -33,9 +33,10 @@ constraints: memory. - Networked feeds are producers into the live runtime, not independent clock authorities. - - USB-attached Moves on Starfire and Nightwing are tracking witnesses. Odin - may discover/project their stream schemas, but it does not own pose capture - or Mimir fusion. + - USB-attached Moves on Starfire and Nightwing are tracking witnesses. Muninn + publishes source-local marker candidates plus controller/IMU/button state. + Odin may discover/project their stream schemas, but it does not own pose + capture or Mimir fusion. - CultMesh/CultNet is the default Raven-to-Starfire media transit. OBS may consume a Starfire-local UDP MPEG-TS egress as a compatibility sink, but Mimir owns program selection, composition, preview/control, and publication. @@ -84,11 +85,13 @@ accepted_design: device timestamp, and optional native/GPU handle. - `MimirAudioBlockDescriptor` carries sample rate, channels, sample format, frame count, timestamp, and optional native handle. - - `MimirTrackingObservation` carries typed PS Move pose/button/battery/ - confidence samples as `mimir.move_tracking_observation.v1`; Starfire Moves - are local tracking streams, Nightwing Moves are emitted by Muninn on - Nightwing, Odin owns discovery/schema projection, and Mimir owns buffering - and fusion. + - `MimirTrackingObservation` carries typed PS Move evidence samples as + `mimir.move_tracking_observation.v1`; Starfire Moves are local tracking + streams, Nightwing Moves are emitted by Muninn on Nightwing, Odin owns + discovery/schema projection, and Mimir owns buffering and fusion. + - `mimir.move_controller_pose.v1` is Mimir's resolved wand pose contract for + Fensalir-facing interaction. Mimir owns calibration, association, + triangulation, IMU fusion, prediction, confidence, and latency accounting. - `scripts/start-nightwing-move-tracking.ps1` restores the live Nightwing Eye/Move witness path: Starfire owns the `/eve/periwinkle` receiver and recorder, Nightwing owns PS Move HID report `0x06` LED writes and PS3 Eye @@ -98,9 +101,9 @@ accepted_design: - Odin's Muninn organ owns Move optical candidate extraction in `E:\Projects\Odin\crates\muninn-move-tracker` and publishes/feeds `muninn.move_marker_candidate.v1` records. Mimir consumes those candidate - streams; it does not own raw optical extraction. Calibration, multi-camera - association, triangulation, IMU fusion, prediction, and final 6DoF pose are - still separate owners. + streams; it does not own raw optical extraction. Mimir explicitly owns + calibration, multi-camera association, triangulation, IMU fusion, + prediction, and final 6DoF wand pose. - `MimirFrameEventProcessStreamSource` is a temporary diagnostic adapter for JSON-line video frame and audio block metadata from native probes into runtime rolling buffers; it does not carry pixels/audio payloads or own the