Use CultMesh stream for Muninn Move evidence

This commit is contained in:
Meta Vens 2026-06-11 20:28:30 +01:00
commit 07852766fd
8 changed files with 172 additions and 0 deletions

View file

@ -49,6 +49,9 @@ a named invariant that the native runtime cannot protect yet.
controller-state document schemas and normalizes them into native Move
evidence samples. It does not associate markers to controllers or synthesize
pose.
- The realtime Move witness path uses CultMesh streaming, not CultCache polling:
Muninn publishes shared-memory stream frames, Mimir consumes the latest read
lease, normalizes the frame, and admits it to native `move_evidence`.
- `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

View file

@ -64,6 +64,7 @@ dotnet run --no-build --project .\src\Mimir.BufferSmoke\Mimir.BufferSmoke.csproj
dotnet run --no-build --project .\src\Mimir.BufferSmoke\Mimir.BufferSmoke.csproj -- --move-tracking-contract-smoke
dotnet run --no-build --project .\src\Mimir.BufferSmoke\Mimir.BufferSmoke.csproj -- --move-native-reservoir-smoke --native-reservoir .\native\reservoir\target\debug\localcast_reservoir.dll
dotnet run --no-build --project .\src\Mimir.BufferSmoke\Mimir.BufferSmoke.csproj -- --muninn-move-evidence-smoke --native-reservoir .\native\reservoir\target\debug\localcast_reservoir.dll
dotnet run --no-build --project .\src\Mimir.BufferSmoke\Mimir.BufferSmoke.csproj -- --muninn-move-cultmesh-stream-smoke --native-reservoir .\native\reservoir\target\debug\localcast_reservoir.dll
dotnet run --no-build --project .\src\Mimir.BufferSmoke\Mimir.BufferSmoke.csproj -- --perfect-machine-manifest
dotnet run --no-build --project .\src\Mimir.BufferSmoke\Mimir.BufferSmoke.csproj -- --bioacoustic-actuator-self-test
```

View file

@ -11,6 +11,7 @@
<ItemGroup>
<ProjectReference Include="..\..\..\CultLib\src\GameCult.Caching.MessagePack\GameCult.Caching.MessagePack.csproj" />
<ProjectReference Include="..\..\..\CultLib\src\GameCult.Mesh\GameCult.Mesh.csproj" />
<ProjectReference Include="..\Mimir.Runtime\Mimir.Runtime.csproj" />
</ItemGroup>

View file

@ -4,6 +4,7 @@ using System.Security.Cryptography;
using System.Text.Json;
using GameCult.Caching;
using GameCult.Caching.MessagePack;
using GameCult.Mesh;
using MessagePack;
using Mimir.Runtime.Synchronization;
@ -108,6 +109,12 @@ if (args.Any(arg => string.Equals(arg, "--muninn-move-evidence-smoke", StringCom
ParseStringOption(args, "--native-reservoir", DefaultNativeReservoirPath()));
}
if (args.Any(arg => string.Equals(arg, "--muninn-move-cultmesh-stream-smoke", StringComparison.OrdinalIgnoreCase)))
{
return RunMuninnMoveCultMeshStreamSmoke(
ParseStringOption(args, "--native-reservoir", DefaultNativeReservoirPath()));
}
if (args.Any(arg => string.Equals(arg, "--import-obs-program-scene", StringComparison.OrdinalIgnoreCase)))
{
return await ImportObsProgramSceneAsync(
@ -1618,6 +1625,93 @@ static int RunMuninnMoveEvidenceSmoke(string nativeReservoirPath)
: 1;
}
static int RunMuninnMoveCultMeshStreamSmoke(string nativeReservoirPath)
{
if (!File.Exists(nativeReservoirPath))
{
Console.Error.WriteLine($"muninn-move-cultmesh-stream-smoke missing-native path={nativeReservoirPath}");
return 1;
}
var streamId = "muninn:nightwing:move-evidence";
var catalog = CultMesh.CreateStreamCatalog();
catalog.Declare(MimirMuninnMoveEvidenceAdapter.CreateStreamDescriptor(
streamId,
"mimir-live",
"muninn:nightwing",
"muninn:nightwing:clock"));
using var ring = catalog.CreateSharedMemoryRing(streamId, slotCount: 4, slotByteLength: 8192);
var frame = new MimirMuninnMoveEvidenceStreamFrame(
"nightwing-move-frame:78",
"muninn:nightwing",
1_781_202_600_004_000_000,
[
new MuninnMoveMarkerCandidateDocument(
StreamId: "nightwing:ps3-eye-0:move-marker-candidates",
HostId: "nightwing",
CameraId: "ps3-eye-0",
FrameSequence: 9003,
SourceIdHash: 0xA11CE,
TileX: 19,
TileY: 7,
CenterXPx: 314.0f,
CenterYPx: 119.0f,
RadiusPx: 12.25f,
AreaPx: 470,
MeanLuma: 0.61f,
PeakLuma: 253,
Score: 0.87f,
ObservedAt: "2026-06-11T18:30:00.0040000Z")
],
[
new MuninnMoveControllerStateDocument(
StreamId: "nightwing:move-usb:move-controller-state",
HostId: "nightwing",
MoveId: "move-usb",
Sequence: 78,
SourceTimestampNs: 1_781_202_600_004_000_000,
AccelerometerXyz: [-0.01f, 0.10f, 0.99f],
GyroscopeXyz: [0.02f, -0.01f, 0.04f],
MagnetometerXyz: [0.0f, 0.0f, 0.0f],
TriggerValue: 0.5f,
Buttons: ["move"],
Battery01: float.NaN,
ObservedAt: "2026-06-11T18:30:00.0040000Z")
]);
var payload = MimirMuninnMoveEvidenceAdapter.SerializeStreamFrame(frame);
if (!ring.TryPublishCopy(payload, frame.PublishedAtNs, durationNs: 0, out var published))
{
Console.Error.WriteLine("muninn-move-cultmesh-stream-smoke publish-failed");
return 1;
}
catalog.PublishFrame(published);
using var runtime = new MimirNativeReservoirRuntime(nativeReservoirPath);
var admitted = MimirMuninnMoveEvidenceAdapter.TryAdmitLatestCultMeshFrame(
ring,
runtime,
"mimir:muninn-move-cultmesh-stream-smoke",
"mimir-move-stage-calibration-v1",
"mimir-stage-space",
out var handle,
out var sampleCount);
var status = runtime.Status;
var latest = catalog.LatestFrame(streamId);
Console.WriteLine(
$"muninn-move-cultmesh-stream-smoke stream={streamId} bytes={payload.Length} publishedSeq={published.Sequence} latestSeq={latest?.Sequence.ToString() ?? "none"} samples={sampleCount} payload=0x{handle.PayloadHandle:X} total={status.TotalSampleCount} moveEvidence={status.MoveEvidenceCount} edgeNs={status.EdgeNs}");
return admitted &&
payload.Length > 0 &&
sampleCount == 2 &&
latest?.Sequence == published.Sequence &&
handle.PayloadHandle != 0 &&
status.TotalSampleCount.ToUInt64() == 1 &&
status.MoveEvidenceCount.ToUInt64() == 1
? 0
: 1;
}
static MoveTrackingSmokeContext BuildMoveTrackingSmokeHub()
{
var starfireDescriptor = new MimirStreamDescriptor(

View file

@ -13,6 +13,7 @@
<ItemGroup>
<ProjectReference Include="..\..\..\Fensalir\src\Aquarium.Engine.Contracts\Aquarium.Engine.Contracts.csproj" />
<ProjectReference Include="..\..\..\CultLib\src\GameCult.Caching.MessagePack\GameCult.Caching.MessagePack.csproj" />
<ProjectReference Include="..\..\..\CultLib\src\GameCult.Mesh\GameCult.Mesh.csproj" />
</ItemGroup>
</Project>

View file

@ -1,4 +1,5 @@
using GameCult.Caching;
using GameCult.Mesh;
using MessagePack;
namespace Mimir.Runtime.Synchronization;
@ -38,8 +39,76 @@ public sealed record MuninnMoveControllerStateDocument(
[property: Key(10)] float Battery01,
[property: Key(11)] string ObservedAt);
[MessagePackObject]
public sealed record MimirMuninnMoveEvidenceStreamFrame(
[property: Key(0)] string FrameId,
[property: Key(1)] string ProducerPeerId,
[property: Key(2)] long PublishedAtNs,
[property: Key(3)] MuninnMoveMarkerCandidateDocument[] MarkerCandidates,
[property: Key(4)] MuninnMoveControllerStateDocument[] ControllerStates);
public static class MimirMuninnMoveEvidenceAdapter
{
public const string StreamMetadataSchemaId = "mimir.muninn_move_evidence_stream_frame.v1";
public static CultMeshStreamDescriptor CreateStreamDescriptor(
string streamId,
string verseId,
string ownerPeerId,
string clockDomainId) =>
new(
streamId,
verseId,
ownerPeerId,
CultMeshStreamKind.Bytes,
new CultMeshStreamClock(clockDomainId, sourceId: streamId, confidence: 1.0, evidenceKind: "muninn-move-evidence"),
[CultMeshStreamBodyTransport.SharedMemory, CultMeshStreamBodyTransport.CultCachePage],
label: "Muninn Move evidence",
requiredAccess: CultMeshStreamAccess.Read,
maxInFlightFrames: 4,
metadataSchemaId: StreamMetadataSchemaId);
public static byte[] SerializeStreamFrame(
MimirMuninnMoveEvidenceStreamFrame frame) =>
MessagePackSerializer.Serialize(frame);
public static MimirMuninnMoveEvidenceStreamFrame DeserializeStreamFrame(
ReadOnlyMemory<byte> bytes) =>
MessagePackSerializer.Deserialize<MimirMuninnMoveEvidenceStreamFrame>(bytes);
public static bool TryAdmitLatestCultMeshFrame(
CultMeshSharedMemoryFrameRing ring,
MimirNativeReservoirRuntime runtime,
string producerSourceId,
string calibrationId,
string trackingSpaceId,
out MimirNativeSampleHandle handle,
out int sampleCount)
{
ArgumentNullException.ThrowIfNull(ring);
ArgumentNullException.ThrowIfNull(runtime);
handle = default;
sampleCount = 0;
if (!ring.TryAcquireLatestRead(out var lease))
{
return false;
}
using (lease)
{
var frame = DeserializeStreamFrame(lease.Memory[..lease.Handle.ByteLength]);
var samples = BuildNativeSamples(frame.MarkerCandidates, frame.ControllerStates);
sampleCount = samples.Count;
if (sampleCount == 0)
{
return false;
}
handle = runtime.AdmitMoveEvidence(producerSourceId, samples, calibrationId, trackingSpaceId);
return true;
}
}
public static IReadOnlyList<MimirNativeMoveEvidenceSample> BuildNativeSamples(
IEnumerable<MuninnMoveMarkerCandidateDocument> markerCandidates,
IEnumerable<MuninnMoveControllerStateDocument> controllerStates)

View file

@ -133,3 +133,4 @@
{"ts": "2026-06-11T18:47:43+01:00", "type": "implementation", "status": "ok", "note": "Added native reservoir Move evidence admission: LocalcastMoveEvidenceSample and LocalcastMoveEvidenceBufferDescriptor define a fixed compute-upload ABI, SampleKind move_evidence enters the shared rolling window, malformed buffers are rejected before live admission, and Mimir docs/maps now route Muninn marker/controller witnesses through native buffers before Mimir pose fusion and Fensalir consumption."}
{"ts": "2026-06-11T19:27:48+01:00", "type": "implementation", "status": "ok", "note": "Connected Mimir.Runtime to the native Move evidence reservoir: MimirNativeReservoirRuntime loads localcast_reservoir, pins Move evidence sample/descriptor batches, admits them through localcast_producer_push_move_evidence_buffer, and BufferSmoke --move-native-reservoir-smoke proves a marker plus controller-state batch enters the native move_evidence view."}
{"ts": "2026-06-11T19:58:56+01:00", "type": "implementation", "status": "ok", "note": "Added Mimir-side Muninn Move evidence normalization: muninn.move_marker_candidate.v1 and muninn.move_controller_state.v1 documents now map into native Move evidence samples, and BufferSmoke --muninn-move-evidence-smoke proves two optical candidates plus one controller-state record enter the native move_evidence reservoir view."}
{"ts": "2026-06-11T20:26:19+01:00", "type": "correction", "status": "ok", "note": "Corrected the Move witness live path from CultCache polling to CultMesh streaming: MimirMuninnMoveEvidenceAdapter now creates/consumes Muninn Move shared-memory stream frames, BufferSmoke --muninn-move-cultmesh-stream-smoke proves a CultMesh latest-frame read lease normalizes into native move_evidence, and CultCache remains receipt/debug state rather than the hot tracking feed."}

View file

@ -98,6 +98,8 @@ 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.
- 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
Fensalir-facing interaction. Mimir owns calibration, association,
triangulation, IMU fusion, prediction, confidence, and latency accounting.