Clarify Muninn Move pickup readiness
This commit is contained in:
parent
c3babfaa57
commit
ff0920b327
2 changed files with 63 additions and 4 deletions
|
|
@ -1671,17 +1671,27 @@ static int RunMuninnMoveIdentitySmoke()
|
|||
State: "bluetooth-connected",
|
||||
Detail: "Muninn sees this PS Move connected through BlueZ.",
|
||||
ObservedAt: "2026-06-17T02:24:19.0000000Z");
|
||||
var pickupReady = new MuninnMoveIdentityDocument(
|
||||
IdentityId: "nightwing:move-000704a39772:move-identity",
|
||||
HostId: "nightwing",
|
||||
MoveId: "move-000704a39772",
|
||||
SourcePath: "bluetooth:00:07:04:A3:97:72",
|
||||
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:21.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]);
|
||||
var roster = MimirMuninnMoveEvidenceAdapter.BuildIdentityRoster([decoded, nightwingWaiting, connected, pickupReady]);
|
||||
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");
|
||||
|
||||
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} usbHosts={string.Join(',', rotating.UsbHostIds)} pickupHosts={string.Join(',', rotating.BluetoothPickupHostIds)} pickedUp={pickedUp.StateSummary}");
|
||||
$"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}");
|
||||
|
||||
return snapshot.IdentityId == identity.IdentityId &&
|
||||
snapshot.HostId == "starfire" &&
|
||||
|
|
@ -1691,14 +1701,22 @@ static int RunMuninnMoveIdentitySmoke()
|
|||
snapshot.State == "usb-visible" &&
|
||||
snapshot.ObservedAtNs > 0 &&
|
||||
snapshot.ControllerIdHash == expectedHash &&
|
||||
roster.Count == 2 &&
|
||||
roster.Count == 3 &&
|
||||
rotating.HasUsbWitness &&
|
||||
rotating.UsbHostIds.SequenceEqual(["starfire"]) &&
|
||||
rotating.BluetoothPickupHostIds.SequenceEqual(["nightwing"]) &&
|
||||
rotating.UsbBlockingHostIds.SequenceEqual(["starfire"]) &&
|
||||
rotating.StateSummary == "usb-visible+bluetooth-waiting" &&
|
||||
rotating.PickupReadiness == "usb-owned" &&
|
||||
!rotating.IsBluetoothPickupReady &&
|
||||
rotating.SourcePaths.Length == 2 &&
|
||||
pickedUp.StateSummary == "bluetooth-connected" &&
|
||||
pickedUp.BluetoothPickupHostIds.SequenceEqual(["nightwing"])
|
||||
pickedUp.PickupReadiness == "bluetooth-connected" &&
|
||||
pickedUp.BluetoothPickupHostIds.SequenceEqual(["nightwing"]) &&
|
||||
ready.StateSummary == "bluetooth-waiting" &&
|
||||
ready.PickupReadiness == "pickup-ready" &&
|
||||
ready.IsBluetoothPickupReady &&
|
||||
ready.UsbBlockingHostIds.Length == 0
|
||||
? 0
|
||||
: 1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -69,10 +69,13 @@ public sealed record MimirMuninnMoveRosterEntry(
|
|||
string LatestHostId,
|
||||
string LatestState,
|
||||
string StateSummary,
|
||||
string PickupReadiness,
|
||||
bool IsBluetoothPickupReady,
|
||||
string BluetoothHostAddress,
|
||||
bool HasUsbWitness,
|
||||
string[] UsbHostIds,
|
||||
string[] BluetoothPickupHostIds,
|
||||
string[] UsbBlockingHostIds,
|
||||
string[] SourcePaths,
|
||||
ulong ObservedAtNs);
|
||||
|
||||
|
|
@ -220,6 +223,18 @@ public static class MimirMuninnMoveEvidenceAdapter
|
|||
.Distinct(StringComparer.Ordinal)
|
||||
.Order(StringComparer.Ordinal)
|
||||
.ToArray();
|
||||
var waitingPickupHostIds = snapshots
|
||||
.Where(identity => identity.State.Equals("bluetooth-waiting", StringComparison.OrdinalIgnoreCase))
|
||||
.Select(identity => identity.HostId)
|
||||
.Distinct(StringComparer.Ordinal)
|
||||
.Order(StringComparer.Ordinal)
|
||||
.ToArray();
|
||||
var hasConnectedBluetooth = snapshots.Any(identity =>
|
||||
identity.State.Equals("bluetooth-connected", StringComparison.OrdinalIgnoreCase));
|
||||
var pickupReadiness = ResolvePickupReadiness(
|
||||
usbHostIds,
|
||||
waitingPickupHostIds,
|
||||
hasConnectedBluetooth);
|
||||
var sourcePaths = snapshots
|
||||
.Select(identity => identity.SourcePath)
|
||||
.Where(path => !string.IsNullOrWhiteSpace(path))
|
||||
|
|
@ -237,16 +252,42 @@ public static class MimirMuninnMoveEvidenceAdapter
|
|||
.Distinct(StringComparer.Ordinal)
|
||||
.OrderBy(StateRank)
|
||||
.ThenBy(state => state, StringComparer.Ordinal)),
|
||||
PickupReadiness: pickupReadiness,
|
||||
IsBluetoothPickupReady: pickupReadiness == "pickup-ready",
|
||||
BluetoothHostAddress: snapshots
|
||||
.Select(identity => identity.BluetoothHostAddress)
|
||||
.FirstOrDefault(address => !string.IsNullOrWhiteSpace(address)) ?? string.Empty,
|
||||
HasUsbWitness: usbHostIds.Length > 0,
|
||||
UsbHostIds: usbHostIds,
|
||||
BluetoothPickupHostIds: pickupHostIds,
|
||||
UsbBlockingHostIds: usbHostIds.Length > 0 ? usbHostIds : [],
|
||||
SourcePaths: sourcePaths,
|
||||
ObservedAtNs: latest.ObservedAtNs);
|
||||
}
|
||||
|
||||
private static string ResolvePickupReadiness(
|
||||
string[] usbHostIds,
|
||||
string[] waitingPickupHostIds,
|
||||
bool hasConnectedBluetooth)
|
||||
{
|
||||
if (usbHostIds.Length > 0)
|
||||
{
|
||||
return "usb-owned";
|
||||
}
|
||||
|
||||
if (hasConnectedBluetooth)
|
||||
{
|
||||
return "bluetooth-connected";
|
||||
}
|
||||
|
||||
if (waitingPickupHostIds.Length > 0)
|
||||
{
|
||||
return "pickup-ready";
|
||||
}
|
||||
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
private static bool IsUsbVisible(MimirMuninnMoveIdentitySnapshot identity) =>
|
||||
identity.State.Equals("usb-visible", StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue