Validate field resource upload shape
This commit is contained in:
parent
0f78207ac4
commit
f4f07f9da4
3 changed files with 82 additions and 1 deletions
|
|
@ -647,6 +647,7 @@ public static class AquariumFieldEvidenceValidator
|
|||
var claimKeys = new HashSet<string>(StringComparer.Ordinal);
|
||||
var claimsByKey = new Dictionary<string, AquariumFieldClaim>(StringComparer.Ordinal);
|
||||
var resourceKeys = new HashSet<string>(StringComparer.Ordinal);
|
||||
var resourcesByKey = new Dictionary<string, AquariumFieldResourceDeclaration>(StringComparer.Ordinal);
|
||||
foreach (var resource in frame.Resources)
|
||||
{
|
||||
if (!resource.HasIdentity)
|
||||
|
|
@ -674,6 +675,10 @@ public static class AquariumFieldEvidenceValidator
|
|||
{
|
||||
issues.Add(Error(resource.ResourceKey, "Field resource declarations must have unique keys."));
|
||||
}
|
||||
else
|
||||
{
|
||||
resourcesByKey[resource.ResourceKey] = resource;
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var upload in frame.ResourceUploads)
|
||||
|
|
@ -684,10 +689,25 @@ public static class AquariumFieldEvidenceValidator
|
|||
continue;
|
||||
}
|
||||
|
||||
if (!resourceKeys.Contains(upload.ResourceKey))
|
||||
if (!resourcesByKey.TryGetValue(upload.ResourceKey, out var resource))
|
||||
{
|
||||
issues.Add(Error(upload.ResourceKey, $"Field resource upload references unknown resource '{upload.ResourceKey}'."));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (resource.Kind is not (AquariumFieldResourceKind.StructuredBuffer or AquariumFieldResourceKind.CurvePointBuffer) ||
|
||||
resource.StrideBytes != sizeof(float) ||
|
||||
!string.Equals(resource.Format, "Float32", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
issues.Add(Error(upload.ResourceKey, "Float32 field resource uploads require a Float32 structured/curve buffer resource."));
|
||||
}
|
||||
|
||||
var capacity = Math.Max(1, resource.DepthOrCount > 0 ? resource.DepthOrCount : resource.Width);
|
||||
if (upload.Float32Data.Count > capacity)
|
||||
{
|
||||
issues.Add(Error(upload.ResourceKey, $"Field resource upload has {upload.Float32Data.Count} Float32 values but resource capacity is {capacity}."));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var claim in frame.Claims)
|
||||
|
|
|
|||
|
|
@ -249,3 +249,4 @@
|
|||
{"lesson":"TubeField generated mesh dispatch now obeys AquariumFieldLoweringPlan selection authority. D3D12Renderer builds the planned TubeField claim set from backend packets and only expands matching TubeSplineLowerings; unplanned lowerings are counted in debug status instead of rendered. This prevents explicit lowering metadata from bypassing validation/planning. Fensalir build, Aquarium.Engine.Tests, and headless reload passed.","timestamp":"2026-05-26T22:55:00+01:00","files":["src/Aquarium.Engine/Render/D3D12Renderer.cs","state/map.yaml"],"source":"continued migration after generated mesh draw ABI","topic":"tubefield-planned-packet-authority"}
|
||||
{"lesson":"TubeSpline lowering metadata is now bound to claim/resource authority at validation time. AquariumFieldEvidenceValidator rejects a TubeSpline lowering if its claim is not Tube-encoded or if the lowering resource differs from the claim payload resource. This keeps the planned-packet render gate from being the first place split authority is detected. Fensalir build, Aquarium.Engine.Tests (25 tests), and headless reload passed.","timestamp":"2026-05-26T22:58:00+01:00","files":["src/Aquarium.Engine.Contracts/Render/AquariumFieldEvidence.cs","tests/Aquarium.Engine.Tests/FieldEvidenceContractTests.cs","state/map.yaml"],"source":"continued TubeField generated mesh authority tightening","topic":"tubespline-lowering-validation"}
|
||||
{"lesson":"Resource declarations no longer pretend to contain live samples. AquariumFieldEvidenceFrame now has ResourceUploads for per-frame Float32 producer data; validation checks uploads reference declared resources, and D3D12Renderer uploads Float32 data into resolved structured buffers before TubeField compute expansion. This gives Fensalir-owned GPU-resident TubeField resources actual spectrum/sample contents without using CPU tessellation or a fake native handle. Fensalir build, Aquarium.Engine.Tests (27 tests), and headless reload passed.","timestamp":"2026-05-26T23:36:00+01:00","files":["src/Aquarium.Engine.Contracts/Render/AquariumFieldEvidence.cs","src/Aquarium.Engine/Render/D3D12Renderer.cs","tests/Aquarium.Engine.Tests/FieldEvidenceContractTests.cs","state/map.yaml"],"source":"user clarified spectral frames must feed the GPU buffer","topic":"field-resource-float32-uploads"}
|
||||
{"lesson":"Field resource upload validation now checks upload shape, not only existence. Float32 uploads must target declared StructuredBuffer/CurvePointBuffer resources with Float32 format, 4-byte stride, and sufficient element capacity. Oversized or non-Float uploads are validation errors before renderer upload. Fensalir build, Aquarium.Engine.Tests (29 tests), and headless reload passed.","timestamp":"2026-05-26T23:39:00+01:00","files":["src/Aquarium.Engine.Contracts/Render/AquariumFieldEvidence.cs","tests/Aquarium.Engine.Tests/FieldEvidenceContractTests.cs"],"source":"tightened field resource upload contract","topic":"field-resource-upload-validation"}
|
||||
|
|
|
|||
|
|
@ -254,6 +254,66 @@ public sealed class FieldEvidenceContractTests
|
|||
Assert.Contains(report.Issues, issue => issue.Key == "mimir:resource:missing");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ValidatorRejectsOversizedFieldResourceUploads()
|
||||
{
|
||||
var frame = BuildValidTubeEvidenceFrame();
|
||||
frame = new AquariumFieldEvidenceFrame
|
||||
{
|
||||
Resources = [frame.Resources[0] with { DepthOrCount = 2, Width = 2, Format = "Float32", StrideBytes = 4 }],
|
||||
ResourceUploads =
|
||||
[
|
||||
new AquariumFieldResourceUpload
|
||||
{
|
||||
ResourceKey = frame.Resources[0].ResourceKey,
|
||||
Float32Data = [0.0f, 0.5f, 1.0f],
|
||||
},
|
||||
],
|
||||
Domains = frame.Domains,
|
||||
Claims = frame.Claims,
|
||||
Candidates = frame.Candidates,
|
||||
BackendPackets = frame.BackendPackets,
|
||||
TubeSplineLowerings = frame.TubeSplineLowerings,
|
||||
AccumulationWindowSeconds = frame.AccumulationWindowSeconds,
|
||||
PresentationDelaySeconds = frame.PresentationDelaySeconds,
|
||||
};
|
||||
|
||||
var report = AquariumFieldEvidenceValidator.Validate(frame);
|
||||
|
||||
Assert.True(report.HasErrors);
|
||||
Assert.Contains(report.Issues, issue => issue.Key == "mimir:resource:native-ring:asio-ch0");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ValidatorRejectsNonFloatFieldResourceUploads()
|
||||
{
|
||||
var frame = BuildValidTubeEvidenceFrame();
|
||||
frame = new AquariumFieldEvidenceFrame
|
||||
{
|
||||
Resources = [frame.Resources[0] with { Format = "Int16", StrideBytes = 2 }],
|
||||
ResourceUploads =
|
||||
[
|
||||
new AquariumFieldResourceUpload
|
||||
{
|
||||
ResourceKey = frame.Resources[0].ResourceKey,
|
||||
Float32Data = [1.0f],
|
||||
},
|
||||
],
|
||||
Domains = frame.Domains,
|
||||
Claims = frame.Claims,
|
||||
Candidates = frame.Candidates,
|
||||
BackendPackets = frame.BackendPackets,
|
||||
TubeSplineLowerings = frame.TubeSplineLowerings,
|
||||
AccumulationWindowSeconds = frame.AccumulationWindowSeconds,
|
||||
PresentationDelaySeconds = frame.PresentationDelaySeconds,
|
||||
};
|
||||
|
||||
var report = AquariumFieldEvidenceValidator.Validate(frame);
|
||||
|
||||
Assert.True(report.HasErrors);
|
||||
Assert.Contains(report.Issues, issue => issue.Key == "mimir:resource:native-ring:asio-ch0");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ValidatorRejectsTubeSplineLoweringClaimEncodingMismatch()
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue