Ignore stale Muninn Move identities in live roster
This commit is contained in:
parent
8042885c6d
commit
d9005e340b
3 changed files with 45 additions and 6 deletions
|
|
@ -1718,19 +1718,38 @@ static int RunMuninnMoveIdentitySmoke()
|
|||
State: "bluetooth-unreachable",
|
||||
Detail: "Muninn sees this trusted PS Move in BlueZ and will attempt bounded pickup while disconnected. Last pickup attempt: Failed to connect: org.bluez.Error.Failed br-connection-create-socket",
|
||||
ObservedAt: "2026-06-17T02:24:22.0000000Z");
|
||||
var staleUsb = new MuninnMoveIdentityDocument(
|
||||
IdentityId: "starfire:move-000704a99999:move-identity",
|
||||
HostId: "starfire",
|
||||
MoveId: "move-000704a99999",
|
||||
SourcePath: @"windows-psmove:\\?\hid#vid_054c&pid_03d5&col01#old#{guid}",
|
||||
BluetoothHostAddress: "5C:93:A2:9C:A8:A8",
|
||||
State: "usb-visible",
|
||||
Detail: "Old USB observation retained in CultCache history.",
|
||||
ObservedAt: "2026-06-17T02:20:00.0000000Z");
|
||||
var freshWaitingAfterStaleUsb = new MuninnMoveIdentityDocument(
|
||||
IdentityId: "nightwing:move-000704a99999:move-identity",
|
||||
HostId: "nightwing",
|
||||
MoveId: "move-000704a99999",
|
||||
SourcePath: "bluetooth:00:07:04:A9:99:99",
|
||||
BluetoothHostAddress: "5C:93:A2:9C:A8:A8",
|
||||
State: "bluetooth-waiting",
|
||||
Detail: "Fresh Bluetooth pickup witness after stale USB observation.",
|
||||
ObservedAt: "2026-06-17T02:24:30.0000000Z");
|
||||
|
||||
var encoded = MessagePackSerializer.Serialize(identity);
|
||||
var decoded = MessagePackSerializer.Deserialize<MuninnMoveIdentityDocument>(encoded);
|
||||
var snapshot = MimirMuninnMoveEvidenceAdapter.BuildIdentitySnapshots([decoded]).Single();
|
||||
var expectedHash = MimirMuninnMoveEvidenceAdapter.Fnva64("starfire:move-000704a800d0");
|
||||
var roster = MimirMuninnMoveEvidenceAdapter.BuildIdentityRoster([decoded, nightwingWaiting, connected, pickupReady, unreachable]);
|
||||
var roster = MimirMuninnMoveEvidenceAdapter.BuildIdentityRoster([decoded, nightwingWaiting, connected, pickupReady, unreachable, staleUsb, freshWaitingAfterStaleUsb]);
|
||||
var rotating = roster.Single(entry => entry.MoveId == "move-000704a800d0");
|
||||
var pickedUp = roster.Single(entry => entry.MoveId == "move-000704a6be5f");
|
||||
var ready = roster.Single(entry => entry.MoveId == "move-000704a39772");
|
||||
var blocked = roster.Single(entry => entry.MoveId == "move-000704a12345");
|
||||
var staleReleased = roster.Single(entry => entry.MoveId == "move-000704a99999");
|
||||
|
||||
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} roster={roster.Count} rotating={rotating.StateSummary}/{rotating.PickupReadiness} usbHosts={string.Join(',', rotating.UsbHostIds)} pickupHosts={string.Join(',', rotating.BluetoothPickupHostIds)} pickedUp={pickedUp.StateSummary}/{pickedUp.PickupReadiness} ready={ready.StateSummary}/{ready.PickupReadiness} blocked={blocked.StateSummary}/{blocked.PickupReadiness}");
|
||||
$"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}/{rotating.PickupReadiness} usbHosts={string.Join(',', rotating.UsbHostIds)} pickupHosts={string.Join(',', rotating.BluetoothPickupHostIds)} pickedUp={pickedUp.StateSummary}/{pickedUp.PickupReadiness} ready={ready.StateSummary}/{ready.PickupReadiness} blocked={blocked.StateSummary}/{blocked.PickupReadiness} staleReleased={staleReleased.StateSummary}/{staleReleased.PickupReadiness}");
|
||||
|
||||
return snapshot.IdentityId == identity.IdentityId &&
|
||||
snapshot.HostId == "starfire" &&
|
||||
|
|
@ -1740,7 +1759,7 @@ static int RunMuninnMoveIdentitySmoke()
|
|||
snapshot.State == "usb-visible" &&
|
||||
snapshot.ObservedAtNs > 0 &&
|
||||
snapshot.ControllerIdHash == expectedHash &&
|
||||
roster.Count == 4 &&
|
||||
roster.Count == 5 &&
|
||||
rotating.HasUsbWitness &&
|
||||
rotating.UsbHostIds.SequenceEqual(["starfire"]) &&
|
||||
rotating.BluetoothPickupHostIds.SequenceEqual(["nightwing"]) &&
|
||||
|
|
@ -1760,7 +1779,11 @@ static int RunMuninnMoveIdentitySmoke()
|
|||
blocked.PickupReadiness == "bluetooth-unreachable" &&
|
||||
!blocked.IsBluetoothPickupReady &&
|
||||
blocked.BluetoothPickupHostIds.Length == 0 &&
|
||||
blocked.UsbBlockingHostIds.Length == 0
|
||||
blocked.UsbBlockingHostIds.Length == 0 &&
|
||||
staleReleased.StateSummary == "bluetooth-waiting" &&
|
||||
staleReleased.PickupReadiness == "pickup-ready" &&
|
||||
staleReleased.IsBluetoothPickupReady &&
|
||||
staleReleased.UsbBlockingHostIds.Length == 0
|
||||
? 0
|
||||
: 1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -89,6 +89,8 @@ public sealed record MimirMuninnMoveEvidenceStreamFrame(
|
|||
|
||||
public static class MimirMuninnMoveEvidenceAdapter
|
||||
{
|
||||
private const ulong LiveIdentityWindowNs = 60_000_000_000UL;
|
||||
|
||||
public const string StreamMetadataSchemaId = "mimir.muninn_move_evidence_stream_frame.v1";
|
||||
|
||||
public static CultMeshStreamDescriptor CreateStreamDescriptor(
|
||||
|
|
@ -205,12 +207,19 @@ public static class MimirMuninnMoveEvidenceAdapter
|
|||
private static MimirMuninnMoveRosterEntry ToRosterEntry(
|
||||
IGrouping<string, MimirMuninnMoveIdentitySnapshot> group)
|
||||
{
|
||||
var snapshots = group
|
||||
var orderedSnapshots = group
|
||||
.OrderByDescending(identity => identity.ObservedAtNs)
|
||||
.ThenBy(identity => identity.HostId, StringComparer.Ordinal)
|
||||
.ThenBy(identity => identity.SourcePath, StringComparer.Ordinal)
|
||||
.ToArray();
|
||||
var latest = snapshots[0];
|
||||
var latest = orderedSnapshots[0];
|
||||
var snapshots = orderedSnapshots
|
||||
.Where(identity => IsLiveIdentitySnapshot(identity, latest.ObservedAtNs))
|
||||
.ToArray();
|
||||
if (snapshots.Length == 0)
|
||||
{
|
||||
snapshots = [latest];
|
||||
}
|
||||
var usbHostIds = snapshots
|
||||
.Where(IsUsbVisible)
|
||||
.Select(identity => identity.HostId)
|
||||
|
|
@ -300,6 +309,12 @@ public static class MimirMuninnMoveEvidenceAdapter
|
|||
private static bool IsUsbVisible(MimirMuninnMoveIdentitySnapshot identity) =>
|
||||
identity.State.Equals("usb-visible", StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
private static bool IsLiveIdentitySnapshot(MimirMuninnMoveIdentitySnapshot identity, ulong latestObservedAtNs) =>
|
||||
identity.ObservedAtNs <= 0 ||
|
||||
latestObservedAtNs <= 0 ||
|
||||
identity.ObservedAtNs > latestObservedAtNs ||
|
||||
latestObservedAtNs - identity.ObservedAtNs <= LiveIdentityWindowNs;
|
||||
|
||||
private static bool IsBluetoothPickupState(MimirMuninnMoveIdentitySnapshot identity) =>
|
||||
identity.State.Equals("bluetooth-waiting", StringComparison.OrdinalIgnoreCase) ||
|
||||
identity.State.Equals("bluetooth-connected", StringComparison.OrdinalIgnoreCase);
|
||||
|
|
|
|||
Loading…
Reference in a new issue