Plan field evidence backend lowerings
This commit is contained in:
parent
ef206f2ab4
commit
172abb8d5f
3 changed files with 151 additions and 0 deletions
|
|
@ -254,6 +254,25 @@ public readonly record struct AquariumFieldLoweringRequest(
|
|||
Guide.IsReusable;
|
||||
}
|
||||
|
||||
public sealed class AquariumFieldLoweringPlan
|
||||
{
|
||||
public static AquariumFieldLoweringPlan Empty { get; } = new([], []);
|
||||
|
||||
public AquariumFieldLoweringPlan(
|
||||
IReadOnlyList<AquariumFieldBackendPacket> packets,
|
||||
IReadOnlyList<AquariumFieldLoweringRequest> deferredRequests)
|
||||
{
|
||||
Packets = packets;
|
||||
DeferredRequests = deferredRequests;
|
||||
}
|
||||
|
||||
public IReadOnlyList<AquariumFieldBackendPacket> Packets { get; }
|
||||
|
||||
public IReadOnlyList<AquariumFieldLoweringRequest> DeferredRequests { get; }
|
||||
|
||||
public bool HasPackets => Packets.Count > 0;
|
||||
}
|
||||
|
||||
public sealed class AquariumFieldEvidenceValidationReport
|
||||
{
|
||||
public static AquariumFieldEvidenceValidationReport Empty { get; } = new([]);
|
||||
|
|
@ -420,3 +439,54 @@ public static class AquariumFieldEvidenceNormalizer
|
|||
return requests;
|
||||
}
|
||||
}
|
||||
|
||||
public static class AquariumFieldLoweringPlanner
|
||||
{
|
||||
public static AquariumFieldLoweringPlan Plan(AquariumFieldEvidenceFrame frame)
|
||||
{
|
||||
var requests = AquariumFieldEvidenceNormalizer.BuildLoweringRequests(frame);
|
||||
if (requests.Count == 0)
|
||||
{
|
||||
return AquariumFieldLoweringPlan.Empty;
|
||||
}
|
||||
|
||||
var packets = new List<AquariumFieldBackendPacket>(requests.Count);
|
||||
var deferred = new List<AquariumFieldLoweringRequest>();
|
||||
foreach (var request in requests)
|
||||
{
|
||||
if (!TrySelectBackend(request, out var backend))
|
||||
{
|
||||
deferred.Add(request);
|
||||
continue;
|
||||
}
|
||||
|
||||
packets.Add(new AquariumFieldBackendPacket(
|
||||
PacketKey: $"packet:{request.RequestKey}",
|
||||
ClaimKey: request.ClaimKey,
|
||||
DomainKey: request.DomainKey,
|
||||
Layer: request.Layer,
|
||||
Encoding: request.Encoding,
|
||||
Backend: backend,
|
||||
Support: request.Support,
|
||||
Guide: request.Guide,
|
||||
PayloadHandle: request.PayloadHandle));
|
||||
}
|
||||
|
||||
return new AquariumFieldLoweringPlan(packets, deferred);
|
||||
}
|
||||
|
||||
public static bool TrySelectBackend(AquariumFieldLoweringRequest request, out AquariumFieldBackendKind backend)
|
||||
{
|
||||
backend = request.Encoding switch
|
||||
{
|
||||
AquariumFieldEncoding.Height or AquariumFieldEncoding.Sdf2D => AquariumFieldBackendKind.SurfacePage,
|
||||
AquariumFieldEncoding.Sdf3D => AquariumFieldBackendKind.DirectSdf,
|
||||
AquariumFieldEncoding.Density or AquariumFieldEncoding.Extinction => AquariumFieldBackendKind.VolumeSplat,
|
||||
AquariumFieldEncoding.Tube => AquariumFieldBackendKind.TubeField,
|
||||
AquariumFieldEncoding.Mesh => AquariumFieldBackendKind.Mesh,
|
||||
_ => AquariumFieldBackendKind.Unknown,
|
||||
};
|
||||
|
||||
return backend != AquariumFieldBackendKind.Unknown;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -230,3 +230,4 @@
|
|||
{"lesson":"Phase 1 rendering rebuild contracts now exist in Aquarium.Engine.Contracts. AquariumFieldEvidenceFrame carries neutral field domains, claims, candidates, backend packets, support, proposal policy, and guide validity, and AquariumSceneState has a FieldEvidenceFrame slot. The contract tests prove reusable evidence must name identity, layer, encoding, backend, support, proposal, and guide; pixel-only/debug packets cannot pretend to write reusable field evidence. dotnet test tests/Aquarium.Engine.Tests/Aquarium.Engine.Tests.csproj --no-restore and dotnet build Fensalir.sln --no-restore passed.","timestamp":"2026-05-26T13:48:00+01:00","files":["src/Aquarium.Engine.Contracts/Render/AquariumFieldEvidence.cs","src/Aquarium.Engine.Contracts/Render/AquariumRenderPlan.cs","tests/Aquarium.Engine.Tests/FieldEvidenceContractTests.cs"],"source":"parallel Phase 1 Mimir/Fensalir rendering rebuild implementation","topic":"field-evidence-contracts"}
|
||||
{"lesson":"AquariumFieldEvidenceValidator now gives the field-evidence contract a falsification seam before backend lowering. It rejects missing domain/claim identity, inverted domains, unknown claim/domain references, invalid support/proposal, non-selectable candidates, and backend packets that cannot write reusable evidence. This keeps pixel-only/debug paths from silently becoming production field authority. dotnet test tests/Aquarium.Engine.Tests/Aquarium.Engine.Tests.csproj --no-restore passed with 10 tests.","timestamp":"2026-05-26T14:06:00+01:00","files":["src/Aquarium.Engine.Contracts/Render/AquariumFieldEvidence.cs","tests/Aquarium.Engine.Tests/FieldEvidenceContractTests.cs"],"source":"continued rendering rebuild Phase 1","topic":"field-evidence-validation"}
|
||||
{"lesson":"AquariumFieldEvidenceNormalizer now builds pending lowering requests from valid claims and candidates without choosing a backend. This preserves the rebuild membrane: Mimir and other producers may publish field evidence and surface intent, while Fensalir later selects direct SDF, mesh, splat, page, tube, or debug lowerings. Invalid evidence yields no lowering requests. dotnet test tests/Aquarium.Engine.Tests/Aquarium.Engine.Tests.csproj --no-restore passed with 12 tests, and both Fensalir.sln and Mimir.slnx built cleanly.","timestamp":"2026-05-26T14:23:00+01:00","files":["src/Aquarium.Engine.Contracts/Render/AquariumFieldEvidence.cs","tests/Aquarium.Engine.Tests/FieldEvidenceContractTests.cs"],"source":"continued rendering rebuild Phase 1","topic":"field-evidence-normalizer"}
|
||||
{"lesson":"AquariumFieldLoweringPlanner now converts pending lowering requests into backend packets only for unambiguous encodings: height/SDF2D to surface pages, SDF3D to direct SDF, density/extinction to volume splats, tube to tube field, and mesh to mesh. Ambiguous feature/confidence/material-style evidence is deferred instead of guessed. This keeps backend selection in Fensalir while avoiding new hidden policy. Engine tests passed with 14 tests; Fensalir.sln built cleanly, and Mimir.slnx still builds against the contract.","timestamp":"2026-05-26T14:42:00+01:00","files":["src/Aquarium.Engine.Contracts/Render/AquariumFieldEvidence.cs","tests/Aquarium.Engine.Tests/FieldEvidenceContractTests.cs"],"source":"continued rendering rebuild Phase 1","topic":"field-evidence-lowering-planner"}
|
||||
|
|
|
|||
|
|
@ -207,6 +207,86 @@ public sealed class FieldEvidenceContractTests
|
|||
Assert.Empty(requests);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void LoweringPlannerSelectsOnlyObviousBackends()
|
||||
{
|
||||
var frame = BuildValidTubeEvidenceFrame();
|
||||
|
||||
var plan = AquariumFieldLoweringPlanner.Plan(frame);
|
||||
|
||||
Assert.True(plan.HasPackets);
|
||||
Assert.Empty(plan.DeferredRequests);
|
||||
Assert.Single(plan.Packets);
|
||||
Assert.Equal(AquariumFieldBackendKind.TubeField, plan.Packets[0].Backend);
|
||||
Assert.True(plan.Packets[0].IsEvidenceWriter);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void LoweringPlannerDefersAmbiguousFeatureEvidence()
|
||||
{
|
||||
var support = new AquariumFieldSupport(
|
||||
Vector3.Zero,
|
||||
Vector3.One,
|
||||
Matrix4x4.Identity,
|
||||
1.0f,
|
||||
0.0f,
|
||||
0.0f,
|
||||
0.0f);
|
||||
var proposal = new AquariumFieldProposalPolicy(
|
||||
AquariumFieldProposalKind.SensorObservation,
|
||||
1.0f,
|
||||
1.0f,
|
||||
1,
|
||||
1u);
|
||||
var frame = new AquariumFieldEvidenceFrame
|
||||
{
|
||||
Domains =
|
||||
[
|
||||
new AquariumFieldDomain(
|
||||
"mimir:observation:feature",
|
||||
"",
|
||||
AquariumFieldDomainKind.CameraSensor,
|
||||
Matrix4x4.Identity,
|
||||
Matrix4x4.Identity,
|
||||
Vector3.Zero,
|
||||
Vector3.One,
|
||||
Vector3.Zero,
|
||||
"Mimir.Runtime")
|
||||
],
|
||||
Claims =
|
||||
[
|
||||
new AquariumFieldClaim(
|
||||
"claim:feature",
|
||||
"mimir:observation:feature",
|
||||
"mimir",
|
||||
AquariumFieldLayer.Form,
|
||||
AquariumFieldEncoding.Feature,
|
||||
support,
|
||||
proposal,
|
||||
"",
|
||||
0,
|
||||
1.0f)
|
||||
],
|
||||
Candidates =
|
||||
[
|
||||
new AquariumFieldCandidate(
|
||||
"candidate:feature",
|
||||
"claim:feature",
|
||||
AquariumFieldLayer.Form,
|
||||
AquariumFieldEncoding.Feature,
|
||||
proposal,
|
||||
AquariumFieldGuide.Valid(1.0f))
|
||||
],
|
||||
};
|
||||
|
||||
var plan = AquariumFieldLoweringPlanner.Plan(frame);
|
||||
|
||||
Assert.False(plan.HasPackets);
|
||||
Assert.Empty(plan.Packets);
|
||||
Assert.Single(plan.DeferredRequests);
|
||||
Assert.Equal("claim:feature", plan.DeferredRequests[0].ClaimKey);
|
||||
}
|
||||
|
||||
private static AquariumFieldEvidenceFrame BuildValidTubeEvidenceFrame()
|
||||
{
|
||||
var support = new AquariumFieldSupport(
|
||||
|
|
|
|||
Loading…
Reference in a new issue