From 8636519bc1c48773b022819c9aec4e29ca30a726 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Tue, 26 May 2026 23:45:00 +0100 Subject: [PATCH] Verify runtime spectrum resource upload --- docs/fensalir-rendering-rebuild-migration.md | 5 +- docs/implementation-plan.md | 6 +- notes/current-system-map.md | 4 +- src/Mimir.BufferSmoke/Program.cs | 80 ++++++++++++++++++++ state/evidence.jsonl | 1 + state/map.yaml | 3 + 6 files changed, 96 insertions(+), 3 deletions(-) diff --git a/docs/fensalir-rendering-rebuild-migration.md b/docs/fensalir-rendering-rebuild-migration.md index da81be9..48aa07a 100644 --- a/docs/fensalir-rendering-rebuild-migration.md +++ b/docs/fensalir-rendering-rebuild-migration.md @@ -230,7 +230,10 @@ matching TubeSpline metadata for audio spectrum/waveform Tube claims. That is engine ownership, not a reason for Mimir to create a parallel renderer. Mimir also uploads normalized spectral frames as Float32 data into a Fensalir-owned structured buffer resource, so the TubeField path consumes live -GPU buffer contents rather than an empty declaration. +GPU buffer contents rather than an empty declaration. The runtime-level receipt +is `Mimir.BufferSmoke --mimir-spectrum-upload-smoke`: it boots Mimir's frame +path, advances spectrum analysis, and verifies one Float32 upload, one planned +TubeField packet, and no live legacy spline/buffer-field dashboard input. ### 3. Calibration Constraint diff --git a/docs/implementation-plan.md b/docs/implementation-plan.md index 42074f6..dbcb7e0 100644 --- a/docs/implementation-plan.md +++ b/docs/implementation-plan.md @@ -141,7 +141,11 @@ a named invariant that the native runtime cannot protect yet. into a row-major Float32 matrix, attaches that as a field resource upload, and Fensalir copies it into the resolved GPU structured buffer before TubeField compute reads. The old `AquariumBufferFieldFrame` / `ReservoirSplats` - dashboard path is also silent. + dashboard path is also silent. `Mimir.BufferSmoke + --mimir-spectrum-upload-smoke` boots `MimirRuntime`, advances the synthetic + spectrum preview path, and verifies that the frame contains the Float32 + resource upload plus planned TubeField packet while legacy spline and buffer + field inputs stay empty. - `MimirFensalirFieldLowering` now emits `AquariumFieldResourceDeclaration` rows for live native/GPU payload views. Observation claims reference `mimir:resource:*` keys, and Fensalir validation/planning can reject or defer diff --git a/notes/current-system-map.md b/notes/current-system-map.md index 942bed6..93cc213 100644 --- a/notes/current-system-map.md +++ b/notes/current-system-map.md @@ -380,7 +380,9 @@ Mimir declares the rolling resource, publishes a Tube claim plus expansion, and TubeField material rendering. The spectrum resource is not just a handle: Mimir uploads the current spectral amplitudes as row-major Float32 data into a Fensalir-owned GPU structured buffer before TubeField compute reads -it. +it. `Mimir.BufferSmoke --mimir-spectrum-upload-smoke` verifies this through the +actual `MimirRuntime` frame path and confirms the legacy direct spline and +buffer-field dashboard inputs are empty. ## Known Risks diff --git a/src/Mimir.BufferSmoke/Program.cs b/src/Mimir.BufferSmoke/Program.cs index c057ae5..b163bc8 100644 --- a/src/Mimir.BufferSmoke/Program.cs +++ b/src/Mimir.BufferSmoke/Program.cs @@ -2,10 +2,13 @@ using System.Diagnostics; using System.Numerics; using System.Security.Cryptography; using System.Text.Json; +using Aquarium.Engine; +using Aquarium.Engine.Input; using Aquarium.Engine.Render; using GameCult.Caching; using GameCult.Caching.MessagePack; using MessagePack; +using Mimir.Runtime; using Mimir.Runtime.Synchronization; if (args.Any(arg => string.Equals(arg, "--chirplet-self-test", StringComparison.OrdinalIgnoreCase))) @@ -100,6 +103,11 @@ if (args.Any(arg => string.Equals(arg, "--fensalir-field-dsl-resource-smoke", St return RunFensalirFieldDslResourceSmoke(); } +if (args.Any(arg => string.Equals(arg, "--mimir-spectrum-upload-smoke", StringComparison.OrdinalIgnoreCase))) +{ + return RunMimirSpectrumUploadSmoke(); +} + if (args.Any(arg => string.Equals(arg, "--perfect-machine-contract-smoke", StringComparison.OrdinalIgnoreCase))) { return await RunPerfectMachineContractSmokeAsync( @@ -619,6 +627,78 @@ tubespline id=spectrum-trail resource=spectrum domain=mimir:domain:spectrum conf : 1; } +static int RunMimirSpectrumUploadSmoke() +{ + var previousSyntheticPreview = Environment.GetEnvironmentVariable("MIMIR_SYNTHETIC_SPECTRUM_PREVIEW"); + Environment.SetEnvironmentVariable("MIMIR_SYNTHETIC_SPECTRUM_PREVIEW", "1"); + try + { + var settings = new MimirSynchronizationSettings + { + BufferDuration = TimeSpan.FromSeconds(5), + Audio = new MimirAudioSynchronizationSettings + { + Mode = MimirAudioSyncMode.Passive, + ReferenceSourceId = "loopback-scarlett-speakers", + }, + }; + using var runtime = new MimirRuntime(new AquariumRuntimeOptions(Headless: true, CultCachePath: null), settings); + runtime.OnSceneReady(); + runtime.Update(0.0f, new InputState()); + + var frame = runtime.Frame; + var field = frame.Scene.FieldEvidenceFrame; + var upload = field.ResourceUploads.SingleOrDefault(upload => + string.Equals(upload.ResourceKey, "mimir:resource:spectrum:field-upload", StringComparison.Ordinal)); + var matchingResources = field.Resources + .Where(resource => string.Equals(resource.ResourceKey, "mimir:resource:spectrum:field-upload", StringComparison.Ordinal)) + .ToArray(); + var matchingLowerings = field.TubeSplineLowerings + .Where(lowering => string.Equals(lowering.ResourceKey, "mimir:resource:spectrum:field-upload", StringComparison.Ordinal)) + .ToArray(); + var matchingClaims = field.Claims + .Where(claim => string.Equals(claim.ClaimKey, "intent:mimir:spectrum:field-upload", StringComparison.Ordinal)) + .ToArray(); + var resource = matchingResources.FirstOrDefault(); + var lowering = matchingLowerings.FirstOrDefault(); + var claim = matchingClaims.FirstOrDefault(); + var validation = AquariumFieldEvidenceValidator.Validate(field); + var plan = AquariumFieldLoweringPlanner.Plan(field); + + Console.WriteLine( + $"mimir-spectrum-upload-smoke resources={field.Resources.Count} uploads={field.ResourceUploads.Count} claims={field.Claims.Count} tubeLowerings={field.TubeSplineLowerings.Count} planned={plan.Packets.Count} errors={validation.HasErrors} legacySplines={frame.Scene.SplineFrame.Splines.Count} bufferFields={frame.Scene.BufferFieldFrame.SplineTubeFields.Count + frame.Scene.BufferFieldFrame.TextureSplineFields.Count} uploadFloats={upload?.Float32Data.Count ?? 0}"); + + return + !validation.HasErrors && + !frame.Scene.SplineFrame.HasInput && + !frame.Scene.BufferFieldFrame.HasInput && + upload is not null && + matchingResources.Length == 1 && + matchingLowerings.Length == 1 && + matchingClaims.Length == 1 && + upload.Version == resource.Version && + upload.Float32Data.Count == resource.DepthOrCount && + resource.Kind == AquariumFieldResourceKind.StructuredBuffer && + resource.Residency == AquariumFieldResourceResidency.GpuResident && + resource.Access == AquariumFieldShaderAccess.ShaderResource && + string.Equals(resource.Format, "Float32", StringComparison.OrdinalIgnoreCase) && + resource.StrideBytes == sizeof(float) && + lowering.Width * lowering.Height == upload.Float32Data.Count && + lowering.ClaimKey == claim.ClaimKey && + claim.PayloadHandle == resource.ResourceKey && + plan.Packets.Any(packet => + packet.Backend == AquariumFieldBackendKind.TubeField && + string.Equals(packet.ClaimKey, claim.ClaimKey, StringComparison.Ordinal) && + string.Equals(packet.PayloadHandle, resource.ResourceKey, StringComparison.Ordinal)) + ? 0 + : 1; + } + finally + { + Environment.SetEnvironmentVariable("MIMIR_SYNTHETIC_SPECTRUM_PREVIEW", previousSyntheticPreview); + } +} + static int RunChirpBinSelfTest() { var timeline = MimirChirpBinTimeline.Default; diff --git a/state/evidence.jsonl b/state/evidence.jsonl index 28c6129..1c81c92 100644 --- a/state/evidence.jsonl +++ b/state/evidence.jsonl @@ -158,3 +158,4 @@ {"ts": "2026-05-26T23:03:00+01:00", "type": "implementation", "status": "ok", "note": "Mimir's typed Fensalir surface-intent lowering now emits AquariumFieldTubeSplineLowering metadata for audio spectrum/waveform Tube claims. The hardware-free field evidence smoke now proves one resource, three claims, one TubeSpline lowering, one planned TubeField packet, and two deferred non-backend claims; the DSL smoke still proves resource-bound TubeSpline lowering with ramp binding."} {"ts": "2026-05-26T23:18:00+01:00", "type": "correction", "status": "ok", "note": "Silenced the legacy direct spectrum spline path. MimirRuntime now submits AquariumSplineFrame.Empty and the old BuildSpectrumSplineFrame/direct spline styling helpers were deleted, so live spectrum visualization authority is FieldEvidence TubeField only. Mimir build and both Fensalir field smokes passed."} {"ts": "2026-05-26T23:36:00+01:00", "type": "implementation", "status": "ok", "note": "Mimir now feeds spectral frames into the GPU buffer path. Current audio spectra are normalized into a row-major Float32 matrix, declared as mimir:resource:spectrum:field-upload, attached as a field ResourceUpload, and consumed by the TubeField claim/lowering. Fensalir now uploads ResourceUpload Float32 data into resolved structured buffers before TubeField compute runs. Mimir build, Fensalir build/tests/headless reload, and both field smokes passed."} +{"ts": "2026-05-26T23:44:26+01:00", "type": "verification", "status": "ok", "note": "Added Mimir.BufferSmoke --mimir-spectrum-upload-smoke to exercise the actual MimirRuntime frame path. The smoke verifies one Float32 spectrum ResourceUpload, one declared GPU structured buffer, one Tube claim/lowering, one planned TubeField packet, and no legacy AquariumSplineFrame or AquariumBufferFieldFrame dashboard input."} diff --git a/state/map.yaml b/state/map.yaml index ccbf330..c130454 100644 --- a/state/map.yaml +++ b/state/map.yaml @@ -356,6 +356,9 @@ accepted_design: into a row-major Float32 matrix, declared as `mimir:resource:spectrum:field-upload`, uploaded into a Fensalir-owned GPU-resident structured buffer, and consumed by the TubeField lowering. + `Mimir.BufferSmoke --mimir-spectrum-upload-smoke` verifies the live + `MimirRuntime` frame path emits that Float32 upload and planned TubeField + packet while direct spline and buffer-field dashboard inputs remain empty. - `config/perfect-machine.example.json` declares live owners, sensors, reservoir views, and runtime policy. - `src/Mimir.Runtime/Synchronization` now includes the Perfect Machine module