Separate editor presentation from reservoir work

This commit is contained in:
Meta Vens 2026-06-02 17:24:35 +01:00
commit 20493337eb
8 changed files with 190 additions and 38 deletions

View file

@ -0,0 +1,52 @@
# Fensalir Reservoir Daemon
## Objective
Move heavy field reconstruction out of the interactive Mimir editor. The editor
should present synced video feeds and controls responsively. A separate
Fensalir reservoir daemon should drink from the Well, spend whatever CPU/GPU
budget is assigned, and publish typed reservoir/program surfaces.
## Authority Map
Owner: the Fensalir reservoir daemon owns reservoir work selection, GPU
residency, temporal reuse, fusion kernels, worker scheduling, and publication of
reservoir-derived program surfaces.
Inputs: typed Well pages, configured composite state, live timing policy,
feature-signal documents, calibration state, Fensalir-owned texture leases, and
explicit budget settings.
Outputs: typed CultMesh/CultCache reservoir status, program texture/fence
surfaces, optional diagnostic Eve surfaces, and OBS-facing shared texture or
plugin feeds.
Derived state: Mimir editor telemetry, preview rectangles, Odin/Eve dashboard
rows, and OBS plugin status are observers. They do not decide reservoir work.
Forbidden writers: the interactive editor render loop must not run temporal
reservoir history just because it is presenting a backbuffer. Field diagnostics
must be opt-in. A camera `FieldEvidenceFrame` claim must not impersonate a flat
video compositor.
Shared paths: direct user placement, configured Well composites, OBS output,
daemon diagnostics, and future Eve room lowerings must all reference the same
source ids, timing state, and placement/composite document. Manual UI placement
and daemon program output may differ only through an explicit selected
composite/version.
Deletion line: old app-hosted reservoir proof visuals remain diagnostic only.
They cannot be the default Mimir program output while the current goal is synced
video presentation.
## Current Scar
On 2026-06-02 the Mimir editor became unresponsive because Fensalir ran
reservoir history presentation on a video-only frame. The renderer now gates
that pass behind source-derived reservoir-producing input, and the live
video-only app log showed `reservoir-update n/a`.
The remaining gap is real: Fensalir still lacks a flat program-layer video
backend that draws Fensalir-owned camera texture leases as 2D synced layers.
That backend is separate from the reservoir daemon. Build it as the editor's
presentation path; do not smuggle it through field diagnostics.

View file

@ -23,11 +23,28 @@ For the source-level ownership map, read [[code-algorithm-map|Code Algorithm Map
Fensalir is not a conventional renderer bolted onto Mimir. It is the engine-side
field/evidence machine. Mimir must submit synchronized buffers, constraints,
surface intent, and calibration evidence; Fensalir lowers them into claims with
travel/depth, metadata, control, and reservoir-guide lanes. Any path that only
paints pixels is a fallback/debug draw and must not be mistaken for the
spatiotemporal machine. The shared Fensalir spatiotemporal reservoir is the
organ that owns temporally reused field presentation; TubeField is only the
current rolling-buffer tube claim/candidate producer feeding that organ.
travel/depth, metadata, control, and reservoir-guide lanes. The shared Fensalir
spatiotemporal reservoir is the organ that owns temporally reused field
presentation; TubeField is only the current rolling-buffer tube claim/candidate
producer feeding that organ.
That organ should live as a Fensalir reservoir daemon for production: it drinks
typed Well pages/configured composites, owns reservoir budgets and CPU/GPU work
allocation, and publishes typed reservoir/program surfaces. The Mimir editor is
not that daemon. For the current OBS-shaped cut, the editor is a thin synced
video compositor/control surface and must stay responsive even while the
reservoir worker is absent, paused, or saturated. Field diagnostics, Leap
surface splats, spectrum tubes, and reservoir proof visuals are opt-in
diagnostics or daemon outputs, not default editor presentation.
Any path that only paints pixels is not the spatiotemporal machine, but the
editor still needs a real flat video compositor backend. The current
`FieldEvidenceFrame` camera resources are typed declarations/claims; they do
not by themselves draw Fensalir-owned live camera texture leases as program
layers. Until Fensalir has that 2D textured-quad/program-layer backend, the
editor can be responsive and still fail to show synced video. Do not paper over
that with reservoir diagnostics.
Because Fensalir often samples visible field candidates directly rather than
lighting samples after a known primary hit, claim producers may need
deterministic local visibility generation before reservoir reuse. Reservoir

View file

@ -339,32 +339,40 @@ static bool open_source_texture(MimirProgramTextureSource *ctx)
return ctx->source_textures.size() == ctx->ring_count;
}
static void open_producer_fence(MimirProgramTextureSource *ctx)
static bool open_producer_fence(MimirProgramTextureSource *ctx)
{
const auto wide_name = utf8_to_wide(ctx->fence_name);
if (wide_name.empty()) {
return;
return true;
}
HANDLE fence_handle = nullptr;
HRESULT hr = ctx->d3d12_device->OpenSharedHandleByName(wide_name.c_str(), GENERIC_ALL, &fence_handle);
if (FAILED(hr)) {
log_retry_failure(ctx, "OpenSharedHandleByName producer fence failed", hr);
return;
return true;
}
hr = ctx->d3d12_device->OpenSharedHandle(fence_handle, IID_PPV_ARGS(&ctx->producer_fence));
CloseHandle(fence_handle);
if (FAILED(hr)) {
log_retry_failure(ctx, "OpenSharedHandle producer fence failed", hr);
return;
ctx->producer_fence.Reset();
return true;
}
ctx->last_producer_fence_value = ctx->producer_fence->GetCompletedValue();
if (ctx->last_producer_fence_value == UINT64_MAX) {
log_retry_failure(ctx, "producer fence opened in device-removed state");
ctx->producer_fence.Reset();
return false;
}
blog(LOG_INFO,
"Mimir OBS program texture producer fence opened %s value=%llu",
ctx->fence_name.c_str(),
static_cast<unsigned long long>(ctx->last_producer_fence_value));
return true;
}
static bool read_producer_fence(MimirProgramTextureSource *ctx, uint64_t *completed)
@ -376,7 +384,7 @@ static bool read_producer_fence(MimirProgramTextureSource *ctx, uint64_t *comple
*completed = ctx->producer_fence->GetCompletedValue();
if (*completed == UINT64_MAX) {
blog(LOG_WARNING, "Mimir OBS program texture: producer fence reported device removal");
log_retry_failure(ctx, "producer fence reported device removal");
return false;
}
@ -459,7 +467,10 @@ static bool ensure_bridge(MimirProgramTextureSource *ctx)
return false;
}
open_producer_fence(ctx);
if (!open_producer_fence(ctx)) {
release_bridge(ctx);
return false;
}
blog(LOG_INFO, "Mimir OBS program texture source opened %s (%ux%u ring=%u)",
ctx->texture_name.c_str(),
@ -478,6 +489,7 @@ static bool copy_source_to_bridge(MimirProgramTextureSource *ctx)
uint64_t completed_producer_value = 0;
if (!read_producer_fence(ctx, &completed_producer_value)) {
release_bridge(ctx);
return false;
}

View file

@ -23,10 +23,14 @@ flowchart TD
C["Leap timing/IR driver"] --> R
D["network feed producers"] --> R
R --> N["native reservoir handles"]
N --> E["Fensalir GPU fusion + UI"]
R --> W["Mimir Well typed pages + timing state"]
W --> D["Fensalir reservoir daemon"]
N --> D
D --> E["Fensalir GPU fusion surfaces"]
R --> U["Mimir editor thin synced-video UI"]
N --> F["Faust/native DSP"]
E --> G["Spout2/program video"]
E --> V["EVE native shared-texture stream"]
U --> V["EVE/native shared-texture program stream"]
F --> H["program stems + spatial bed"]
G --> I["OBS"]
H --> I
@ -41,10 +45,21 @@ Ownership:
phones, microcontrollers, Raven, and Starfire can participate without
becoming independent clock authorities.
- `Mimir.Runtime` owns app-level stream buffers and synchronization.
- `Mimir.Well` owns typed live pages, configured composites, timing pressure,
feature signals, and capture-body publication. It is the source the heavy
reservoir worker drinks from; it is not a renderer.
- Native capture workers own device reads.
- Fensalir owns dense visual fusion, material/brush/splat reconciliation,
D3D12 interop, runtime UI, Spout2 publication, and the completed backbuffer
texture copied into the EVE shared D3D12 program-output surface.
- The future Fensalir reservoir daemon owns dense visual fusion,
material/brush/splat reconciliation, reservoir budgets, job scheduling, GPU
residency, and any CPU/GPU worker share thrown at field reconstruction. It
drinks from the Well and publishes typed reservoir/program surfaces.
- The Mimir editor owns only responsive 2D synced-video presentation controls
and program-layer placement for the current cut. It must not accidentally run
reservoir history work just because a frame is being drawn.
- Fensalir's in-app renderer owns D3D12 interop and lowering of explicit
surfaces. A flat video compositor backend is still missing: current
FieldEvidence camera resources are declarations/claims, not a production
textured-quad draw path.
- Faust/native DSP owns hot audio alignment, suppression, separation,
spatialization, and stem generation.
- OBS owns broadcast controls.

View file

@ -63,6 +63,8 @@ public sealed class MimirRuntime : IAquariumRuntime, IAquariumRuntimeServicesRec
private readonly int spectrumTubeSubdivisions;
private readonly int spectrumSourceLaneCapacity;
private readonly bool obsProofVisualEnabled;
private readonly bool diagnosticFieldOutputEnabled;
private readonly bool inlineComplexContourRuntimeEnabled;
private readonly float calibrationGain;
private readonly float watermarkGain;
private readonly bool syntheticSpectrumPreview;
@ -90,6 +92,7 @@ public sealed class MimirRuntime : IAquariumRuntime, IAquariumRuntimeServicesRec
private IReadOnlyList<MimirAudioSpectrumSnapshot> lastAudioSpectra = [];
private MimirObsStemPublicationSnapshot lastObsStemPublication = MimirObsStemPublicationSnapshot.Empty;
private MimirScheduledBioacousticProbeFrame? lastBioacousticProbeSchedule;
private bool inlineComplexContourRuntimeSuppressionLogged;
private long spectrumHistorySequence;
private long audioActuatorFrameSequence;
private bool audioActuatorProgramQueued;
@ -145,10 +148,15 @@ public sealed class MimirRuntime : IAquariumRuntime, IAquariumRuntimeServicesRec
spectrumTubeSubdivisions = ParseSpectrumTubeSubdivisions();
spectrumSourceLaneCapacity = ParseSpectrumSourceLaneCapacity();
obsProofVisualEnabled = IsTruthy(Environment.GetEnvironmentVariable("MIMIR_OBS_PROOF_VISUAL"));
inlineComplexContourRuntimeEnabled = IsTruthy(Environment.GetEnvironmentVariable("MIMIR_COMPLEX_CONTOUR_RUNTIME_INLINE"));
calibrationGain = settings.Audio.CalibrationGain;
watermarkGain = settings.Audio.WatermarkGain;
syntheticSpectrumPreview = IsTruthy(Environment.GetEnvironmentVariable("MIMIR_SYNTHETIC_SPECTRUM_PREVIEW"));
syntheticSingleTubePreview = IsTruthy(Environment.GetEnvironmentVariable("MIMIR_SYNTHETIC_SINGLE_TUBE_PREVIEW"));
diagnosticFieldOutputEnabled =
syntheticSpectrumPreview ||
syntheticSingleTubePreview ||
IsTruthy(Environment.GetEnvironmentVariable("MIMIR_FIELD_DIAGNOSTICS"));
if (syntheticSingleTubePreview)
{
GraphicsSettings = new GraphicsSettings(
@ -228,13 +236,13 @@ public sealed class MimirRuntime : IAquariumRuntime, IAquariumRuntimeServicesRec
new AquariumSceneState
{
TraceHeightFieldSurface = false,
UseStudioBackground = !syntheticSingleTubePreview,
UseStarfieldBackground = obsProofVisualEnabled,
UseStudioBackground = diagnosticFieldOutputEnabled && !syntheticSingleTubePreview,
UseStarfieldBackground = diagnosticFieldOutputEnabled && obsProofVisualEnabled,
SdfObjects = MergeSdfObjects(
obsProofVisualEnabled ? BuildObsProofSdfObjects(runtimeSeconds) : [],
diagnosticFieldOutputEnabled && obsProofVisualEnabled ? BuildObsProofSdfObjects(runtimeSeconds) : [],
[]),
SdfLights = MergeSdfLights(
obsProofVisualEnabled ? BuildObsProofSdfLights(runtimeSeconds) : [],
diagnosticFieldOutputEnabled && obsProofVisualEnabled ? BuildObsProofSdfLights(runtimeSeconds) : [],
[]),
FieldEvidenceFrame = fieldEvidenceFrame,
BufferFieldFrame = AquariumBufferFieldFrame.Empty,
@ -322,7 +330,18 @@ public sealed class MimirRuntime : IAquariumRuntime, IAquariumRuntimeServicesRec
sceneEditor.PlacementForSource(window.StreamId)));
}
var frame = fieldLowering.BuildFieldEvidenceFrame(windows, observations, constraints, intents);
var frame = fieldLowering.BuildFieldEvidenceFrame(
windows,
observations,
constraints,
intents,
includeObservationClaims: diagnosticFieldOutputEnabled,
includeCalibrationClaims: diagnosticFieldOutputEnabled);
if (!diagnosticFieldOutputEnabled)
{
return frame;
}
frame = AddSpectrumFieldEvidence(frame);
return AddLeapGeometryFieldEvidence(frame, windows);
}
@ -1393,10 +1412,15 @@ public sealed class MimirRuntime : IAquariumRuntime, IAquariumRuntimeServicesRec
var stopwatch = Stopwatch.StartNew();
synchronization.AnalyzeAudioSynchronizationStep(audioSyncSettings.ReferenceSourceId, audioSyncSettings.Mode);
if (synchronization.ComplexContourRuntimeEnabled)
if (synchronization.ComplexContourRuntimeEnabled && inlineComplexContourRuntimeEnabled)
{
synchronization.AnalyzeComplexContourSynchronizationStep(audioSyncSettings.ReferenceSourceId, runtimeSeconds);
}
else if (synchronization.ComplexContourRuntimeEnabled && !inlineComplexContourRuntimeSuppressionLogged)
{
inlineComplexContourRuntimeSuppressionLogged = true;
Console.WriteLine("mimir-complex-contour-runtime inline=false reason=render-thread-budget set MIMIR_COMPLEX_CONTOUR_RUNTIME_INLINE=1 to run the heavy matched filter inline");
}
stopwatch.Stop();
lastAudioSyncAnalysisMilliseconds = stopwatch.Elapsed.TotalMilliseconds;
lastAudioSynchronizationReports = synchronization.AudioSynchronizationReports;

View file

@ -17,7 +17,9 @@ public sealed class MimirFensalirFieldLowering(MimirFensalirLoweringOptions? opt
IEnumerable<MimirRollingStreamWindow> windows,
IEnumerable<MimirObservation> observations,
IEnumerable<MimirCalibrationConstraint> calibrationConstraints,
IEnumerable<MimirSurfaceIntent> surfaceIntents)
IEnumerable<MimirSurfaceIntent> surfaceIntents,
bool includeObservationClaims = true,
bool includeCalibrationClaims = true)
{
var observationByKey = observations.ToDictionary(static observation => observation.ObservationKey, StringComparer.Ordinal);
var domains = new List<AquariumFieldDomain>();
@ -35,25 +37,31 @@ public sealed class MimirFensalirFieldLowering(MimirFensalirLoweringOptions? opt
AddResource(resources, seenResources, ResourceForWindow(window));
}
foreach (var observation in observations)
if (includeObservationClaims)
{
var domain = DomainForObservation(observation);
AddDomain(domains, seenDomains, domain);
AddResource(resources, seenResources, ResourceForObservation(observation));
foreach (var observation in observations)
{
var domain = DomainForObservation(observation);
AddDomain(domains, seenDomains, domain);
AddResource(resources, seenResources, ResourceForObservation(observation));
var claim = ClaimForObservation(observation, domain.DomainKey);
claims.Add(claim);
candidates.Add(CandidateForClaim(claim, AquariumFieldGuide.Valid(claim.Confidence)));
var claim = ClaimForObservation(observation, domain.DomainKey);
claims.Add(claim);
candidates.Add(CandidateForClaim(claim, AquariumFieldGuide.Valid(claim.Confidence)));
}
}
foreach (var constraint in calibrationConstraints)
if (includeCalibrationClaims)
{
var domain = DomainForCalibrationConstraint(constraint);
AddDomain(domains, seenDomains, domain);
foreach (var constraint in calibrationConstraints)
{
var domain = DomainForCalibrationConstraint(constraint);
AddDomain(domains, seenDomains, domain);
var claim = ClaimForCalibrationConstraint(constraint, domain.DomainKey);
claims.Add(claim);
candidates.Add(CandidateForClaim(claim, AquariumFieldGuide.Valid(claim.Confidence)));
var claim = ClaimForCalibrationConstraint(constraint, domain.DomainKey);
claims.Add(claim);
candidates.Add(CandidateForClaim(claim, AquariumFieldGuide.Valid(claim.Confidence)));
}
}
foreach (var intent in surfaceIntents)

View file

@ -358,3 +358,4 @@
{"ts": "2026-06-02T15:15:52+01:00", "type": "verification", "status": "ok", "note": "Fixed EveDashboard Well sparsity regression: MimirLiveStatsSnapshot now searches telemetry lines as well as observation lines for mimir.well_snapshot.v1. Nightwing tmux pane gamecult-visible-ops:ops.1 then lowered Well 8/8 sources, seq 108, frame ready 6/6, poll/publish pressure, buffers, and clock-domain rows from the saved Well relay."}
{"ts": "2026-06-02T15:18:04+01:00", "type": "verification", "status": "ok", "note": "Fixed EveDashboard Move Score sparsity regression: fallback trace discovery now scans the tail of the newest move online-sync.jsonl for the latest parseable live_score/score_gesture frame instead of trusting the last line. Nightwing TUI then rendered Move Score with bpm 119, F# major/F# chord, source score summaries, and active voices from the saved move-sync trace."}
{"ts": "2026-06-02T16:14:03+01:00", "type": "implementation", "status": "ok", "note": "Added Mimir.WellObsDaemon and scripts/start-well-obs-daemon.ps1. The daemon tails Well capture pages with inline audio bodies, applies configuredComposite audio mute/solo/gain selection, publishes well_composite plus per-source well_<source> stems into the existing Local\\\\MimirObsStemBus OBS plugin ABI, and refuses metadata-only bodies. Smoke fixture published well_composite/well_asio_ch0/well_asio_ch1 into a test map with expected Float32 samples; launcher smoke recorded real daemon PID and supervisor manifest."}
{"ts": "2026-06-02T17:22:39+01:00", "type": "implementation", "status": "ok", "note": "2026-06-02: Mimir editor responsiveness scar/fix. Fensalir reservoir history is now gated by source-derived reservoir-producing inputs instead of running on every scene presentation. Live video-only editor run artifacts/runtime/program-texture-video-only-fast-20260602-172059 showed reservoir-update n/a and CPU frame about 8-9 ms. Remaining gap is architectural: FieldEvidenceFrame camera Texture2D declarations are not a flat video compositor backend, so live synced camera feeds need an explicit Fensalir 2D program-layer draw path or a separate Fensalir reservoir daemon output surface."}

View file

@ -52,6 +52,18 @@ invariants:
- Mimir publishes physical observations, calibration constraints, and surface
intent. Fensalir owns field claims, selected lowerings, evidence reservoirs,
temporal guide lanes, and program presentation.
- The production reservoir owner should be a Fensalir daemon that drinks typed
Well pages/configured composites, owns reservoir budgets, job scheduling,
GPU residency, and CPU/GPU worker share, then publishes typed
reservoir/program surfaces. The Mimir editor is not this daemon.
- `FieldEvidenceFrame` is not a flat video compositor. Camera Texture2D
resources and claims are typed evidence declarations; they do not draw live
Fensalir-owned texture leases as 2D program layers until Fensalir has an
explicit video compositor backend.
- Fensalir reservoir history presentation must be source-derived: it runs only
when reservoir-producing inputs are active. A responsive synced-video
editor frame must not pay reservoir history cost just because the renderer
is presenting a backbuffer.
- The Mimir editor is currently a 2D program mixer. `MimirSceneEditorState`
owns normalized video-layer placement for synced video streams and emits
only video-source preview items; camera/SDF/model authoring has no live UI
@ -678,7 +690,12 @@ accepted_design:
complete: OBS consumes final Mimir/Fensalir program surfaces and stems
through the native plugin, raw feeds remain debug inputs, and the ledger
records the live texture, texture ring, producer-fence, and consumer-fence
proofs.
proofs. The OBS program-texture source treats a producer fence that opens
or later reports `UINT64_MAX` as a dead producer handle: it releases the
bridge and retries instead of preserving a stale white/empty program path.
This keeps OBS as a reconnecting consumer; producer lifetime still belongs
to Fensalir/Mimir, and a producer restart publishes the fresh texture/fence
pair OBS consumes.
`Mimir.WellObsDaemon` is the first Well-to-OBS daemon for the tightest
configured composite. It tails a Well relay/log, reads synchronized
`mimir.well_capture_page.v1` pages with inline audio bodies, applies the
@ -830,7 +847,13 @@ accepted_design:
loads `complexContourChannelModelPath`, extracts Float32 windows from the
rolling buffers, and publishes `evidence=complex-contour` reports. The
synthetic runtime-shaped proof `--complex-contour-runtime-self-test` at
192 kHz recovers a 693.5-sample delay with about 0.219 us error.
192 kHz recovers a 693.5-sample delay with about 0.219 us error. A live
dump on 2026-06-02 showed the heavy matched-filter analyzer running
`MimirComplexContourMatchedFilterBank.ScoreAt` inline on the Fensalir render
thread at 192 kHz, hanging the app. Runtime complex-contour analysis is now
suppressed on the render thread by default; `MIMIR_COMPLEX_CONTOUR_RUNTIME_INLINE=1`
is a diagnostic override, and the proper live owner is a bounded worker/job
lane that returns reports to the runtime without owning frame cadence.
`MimirCalibratedAudioCompositeBuilder` is the first diagnostic composite
owner for corrected mic streams: it consumes audio samples plus
`MimirAudioSynchronizationState` delay/confidence and measured band