From c3babfaa577b38f90e9176d7875776419651e322 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Wed, 17 Jun 2026 06:48:44 +0100 Subject: [PATCH] Project Muninn Move identity roster --- src/Mimir.BufferSmoke/Program.cs | 33 ++++++- .../MimirMuninnMoveEvidence.cs | 89 +++++++++++++++++++ state/evidence.jsonl | 1 + state/map.yaml | 6 ++ 4 files changed, 127 insertions(+), 2 deletions(-) diff --git a/src/Mimir.BufferSmoke/Program.cs b/src/Mimir.BufferSmoke/Program.cs index eab405c..6c66c9d 100644 --- a/src/Mimir.BufferSmoke/Program.cs +++ b/src/Mimir.BufferSmoke/Program.cs @@ -1653,14 +1653,35 @@ static int RunMuninnMoveIdentitySmoke() State: "usb-visible", Detail: "Muninn discovered this PS Move on a local USB/HID input path.", ObservedAt: "2026-06-17T02:24:16.0000000Z"); + var nightwingWaiting = new MuninnMoveIdentityDocument( + IdentityId: "nightwing:move-000704a800d0:move-identity", + HostId: "nightwing", + MoveId: "move-000704a800d0", + SourcePath: "bluetooth:00:07:04:A8:00:D0", + BluetoothHostAddress: "5C:93:A2:9C:A8:A8", + State: "bluetooth-waiting", + Detail: "Muninn sees this trusted PS Move in BlueZ and will attempt bounded pickup while disconnected.", + ObservedAt: "2026-06-17T02:24:20.0000000Z"); + var connected = new MuninnMoveIdentityDocument( + IdentityId: "nightwing:move-000704a6be5f:move-identity", + HostId: "nightwing", + MoveId: "move-000704a6be5f", + SourcePath: "bluetooth:00:07:04:A6:BE:5F", + BluetoothHostAddress: "5C:93:A2:9C:A8:A8", + State: "bluetooth-connected", + Detail: "Muninn sees this PS Move connected through BlueZ.", + ObservedAt: "2026-06-17T02:24:19.0000000Z"); var encoded = MessagePackSerializer.Serialize(identity); var decoded = MessagePackSerializer.Deserialize(encoded); var snapshot = MimirMuninnMoveEvidenceAdapter.BuildIdentitySnapshots([decoded]).Single(); var expectedHash = MimirMuninnMoveEvidenceAdapter.Fnva64("starfire:move-000704a800d0"); + var roster = MimirMuninnMoveEvidenceAdapter.BuildIdentityRoster([decoded, nightwingWaiting, connected]); + var rotating = roster.Single(entry => entry.MoveId == "move-000704a800d0"); + var pickedUp = roster.Single(entry => entry.MoveId == "move-000704a6be5f"); Console.WriteLine( - $"muninn-move-identity-smoke identity={snapshot.IdentityId} move={snapshot.MoveId} source={snapshot.SourcePath} bluetoothHost={snapshot.BluetoothHostAddress} state={snapshot.State} observedNs={snapshot.ObservedAtNs} controllerHash=0x{snapshot.ControllerIdHash:X}"); + $"muninn-move-identity-smoke identity={snapshot.IdentityId} move={snapshot.MoveId} source={snapshot.SourcePath} bluetoothHost={snapshot.BluetoothHostAddress} state={snapshot.State} observedNs={snapshot.ObservedAtNs} controllerHash=0x{snapshot.ControllerIdHash:X} roster={roster.Count} rotating={rotating.StateSummary} usbHosts={string.Join(',', rotating.UsbHostIds)} pickupHosts={string.Join(',', rotating.BluetoothPickupHostIds)} pickedUp={pickedUp.StateSummary}"); return snapshot.IdentityId == identity.IdentityId && snapshot.HostId == "starfire" && @@ -1669,7 +1690,15 @@ static int RunMuninnMoveIdentitySmoke() snapshot.BluetoothHostAddress == "5C:93:A2:9C:A8:A8" && snapshot.State == "usb-visible" && snapshot.ObservedAtNs > 0 && - snapshot.ControllerIdHash == expectedHash + snapshot.ControllerIdHash == expectedHash && + roster.Count == 2 && + rotating.HasUsbWitness && + rotating.UsbHostIds.SequenceEqual(["starfire"]) && + rotating.BluetoothPickupHostIds.SequenceEqual(["nightwing"]) && + rotating.StateSummary == "usb-visible+bluetooth-waiting" && + rotating.SourcePaths.Length == 2 && + pickedUp.StateSummary == "bluetooth-connected" && + pickedUp.BluetoothPickupHostIds.SequenceEqual(["nightwing"]) ? 0 : 1; } diff --git a/src/Mimir.Runtime/Synchronization/MimirMuninnMoveEvidence.cs b/src/Mimir.Runtime/Synchronization/MimirMuninnMoveEvidence.cs index e953a51..06323c6 100644 --- a/src/Mimir.Runtime/Synchronization/MimirMuninnMoveEvidence.cs +++ b/src/Mimir.Runtime/Synchronization/MimirMuninnMoveEvidence.cs @@ -63,6 +63,19 @@ public sealed record MimirMuninnMoveIdentitySnapshot( ulong ObservedAtNs, ulong ControllerIdHash); +public sealed record MimirMuninnMoveRosterEntry( + string MoveId, + ulong ControllerIdHash, + string LatestHostId, + string LatestState, + string StateSummary, + string BluetoothHostAddress, + bool HasUsbWitness, + string[] UsbHostIds, + string[] BluetoothPickupHostIds, + string[] SourcePaths, + ulong ObservedAtNs); + [MessagePackObject] public sealed record MimirMuninnMoveEvidenceStreamFrame( [property: Key(0)] string FrameId, @@ -160,6 +173,17 @@ public static class MimirMuninnMoveEvidenceAdapter .ToArray(); } + public static IReadOnlyList BuildIdentityRoster( + IEnumerable identities) + { + ArgumentNullException.ThrowIfNull(identities); + return BuildIdentitySnapshots(identities) + .GroupBy(identity => identity.MoveId, StringComparer.Ordinal) + .Select(ToRosterEntry) + .OrderBy(entry => entry.MoveId, StringComparer.Ordinal) + .ToArray(); + } + public static MimirMuninnMoveIdentitySnapshot ToIdentitySnapshot(MuninnMoveIdentityDocument identity) { ArgumentNullException.ThrowIfNull(identity); @@ -175,6 +199,71 @@ public static class MimirMuninnMoveEvidenceAdapter ControllerIdHash: Fnva64($"{identity.HostId}:{identity.MoveId}")); } + private static MimirMuninnMoveRosterEntry ToRosterEntry( + IGrouping group) + { + var snapshots = group + .OrderByDescending(identity => identity.ObservedAtNs) + .ThenBy(identity => identity.HostId, StringComparer.Ordinal) + .ThenBy(identity => identity.SourcePath, StringComparer.Ordinal) + .ToArray(); + var latest = snapshots[0]; + var usbHostIds = snapshots + .Where(IsUsbVisible) + .Select(identity => identity.HostId) + .Distinct(StringComparer.Ordinal) + .Order(StringComparer.Ordinal) + .ToArray(); + var pickupHostIds = snapshots + .Where(IsBluetoothPickupState) + .Select(identity => identity.HostId) + .Distinct(StringComparer.Ordinal) + .Order(StringComparer.Ordinal) + .ToArray(); + var sourcePaths = snapshots + .Select(identity => identity.SourcePath) + .Where(path => !string.IsNullOrWhiteSpace(path)) + .Distinct(StringComparer.Ordinal) + .Order(StringComparer.Ordinal) + .ToArray(); + + return new MimirMuninnMoveRosterEntry( + MoveId: group.Key, + ControllerIdHash: Fnva64($"move:{group.Key}"), + LatestHostId: latest.HostId, + LatestState: latest.State, + StateSummary: string.Join("+", snapshots.Select(identity => identity.State) + .Where(state => !string.IsNullOrWhiteSpace(state)) + .Distinct(StringComparer.Ordinal) + .OrderBy(StateRank) + .ThenBy(state => state, StringComparer.Ordinal)), + BluetoothHostAddress: snapshots + .Select(identity => identity.BluetoothHostAddress) + .FirstOrDefault(address => !string.IsNullOrWhiteSpace(address)) ?? string.Empty, + HasUsbWitness: usbHostIds.Length > 0, + UsbHostIds: usbHostIds, + BluetoothPickupHostIds: pickupHostIds, + SourcePaths: sourcePaths, + ObservedAtNs: latest.ObservedAtNs); + } + + private static bool IsUsbVisible(MimirMuninnMoveIdentitySnapshot identity) => + identity.State.Equals("usb-visible", StringComparison.OrdinalIgnoreCase); + + private static bool IsBluetoothPickupState(MimirMuninnMoveIdentitySnapshot identity) => + identity.State.Equals("bluetooth-waiting", StringComparison.OrdinalIgnoreCase) || + identity.State.Equals("bluetooth-connected", StringComparison.OrdinalIgnoreCase); + + private static int StateRank(string state) => + state.ToLowerInvariant() switch + { + "usb-visible" => 0, + "bluetooth-connected" => 1, + "bluetooth-waiting" => 2, + "bluetooth-known" => 3, + _ => 9 + }; + public static MimirNativeMoveEvidenceSample ToNativeSample(MuninnMoveMarkerCandidateDocument marker) { ArgumentNullException.ThrowIfNull(marker); diff --git a/state/evidence.jsonl b/state/evidence.jsonl index 18b1786..5f0676a 100644 --- a/state/evidence.jsonl +++ b/state/evidence.jsonl @@ -144,3 +144,4 @@ {"ts":"2026-06-16T00:12:00+01:00","type":"correction","status":"ok","note":"Source audit found Mimir.CultMeshMedia still using older C# CultMesh.StartNodeAsync/CultMesh.ConnectClient entrypoints while CultLib now exposes C# CultMesh.CreateRudpServer/CreateRudpClient/CreateRudpClientForAuthorizedPeer. Updated maps to treat the media bridge's current transport path as migration debt: typed program/media documents should move to explicit CultNet RUDP helpers, with OBS-local UDP preserved only as compatibility egress."} {"ts": "2026-06-16T18:05:56+01:00", "type": "verification", "status": "ok", "note": "Mimir.CultMeshMedia migrated from old CultMesh node/client transport to explicit CultNet RUDP relay/send/recv path; local smoke artifacts/rudp-media-smoke-20260616-180404 proved 32 MPEG-TS chunks reached Starfire-local UDP sink over RUDP (packets=32 bytes=42112)."} {"ts": "2026-06-17T03:45:44+01:00", "type": "decision", "status": "ok", "note": "Muninn Move identity is now a typed provenance/provisioning lane: Mimir consumes muninn.move_identity.v1 as identity snapshots while controller-state/marker evidence remains the only native reservoir motion evidence. Verified with Mimir.BufferSmoke --muninn-move-identity-smoke and --muninn-move-evidence-smoke."} +{"ts": "2026-06-17T05:33:48+01:00", "type": "implementation", "status": "ok", "note": "Added Mimir Move identity roster projection from muninn.move_identity.v1. The roster groups identity records by physical Move so a blind USB rotation can show Starfire/Nightwing USB witnesses and Nightwing Bluetooth waiting/connected pickup state together while keeping identity-only rows out of the native motion reservoir. Verified with Mimir.BufferSmoke --muninn-move-identity-smoke and Mimir.Runtime build."} diff --git a/state/map.yaml b/state/map.yaml index e3baf7e..8faf5b0 100644 --- a/state/map.yaml +++ b/state/map.yaml @@ -110,6 +110,12 @@ accepted_design: `muninn.move_marker_candidate.v1` and `muninn.move_controller_state.v1` document shapes and maps them into native Move evidence samples without claiming association or pose authority. + - `MimirMuninnMoveEvidenceAdapter` also consumes + `muninn.move_identity.v1` records into a deduped Move roster projection. + The roster can show a controller as USB-visible on one Muninn host and + Bluetooth-waiting/connected on Nightwing at the same time, so blind USB + rotation remains inspectable without promoting identity-only records into + motion evidence. - Realtime Muninn Move witnesses enter over CultMesh streaming frames. CultCache remains persistence/receipt/debug state, not the hot tracking feed. - `mimir.move_controller_pose.v1` is Mimir's resolved wand pose contract for