Next Gen STEP AP242 Native-ish BREP Geometric Modeling Kernel
Improve safe boolean degenerate diagnostics
Yuechen Li8fdfc9d7b4cb
diff --git a/Aetheris.Kernel.Core.Tests/Brep/Boolean/BrepBooleanSafeCompositionGraphValidatorTests.cs b/Aetheris.Kernel.Core.Tests/Brep/Boolean/BrepBooleanSafeCompositionGraphValidatorTests.csindex 89d4e1dc..9cacc71c 100644--- a/Aetheris.Kernel.Core.Tests/Brep/Boolean/BrepBooleanSafeCompositionGraphValidatorTests.cs+++ b/Aetheris.Kernel.Core.Tests/Brep/Boolean/BrepBooleanSafeCompositionGraphValidatorTests.cs@@ -17,6 +17,7 @@ public sealed class BrepBooleanSafeCompositionGraphValidatorTestsnew AxisAlignedBoxExtents(-20d, 20d, -15d, 15d, 0d, 12d),[new SupportedBooleanHole(+ "hole_a",new AnalyticSurface(AnalyticSurfaceKind.Cylinder,Cylinder: new RecognizedCylinder(@@ -77,6 +78,7 @@ public sealed class BrepBooleanSafeCompositionGraphValidatorTestsAssert.NotNull(diagnostic);Assert.Equal(BooleanDiagnosticCode.HoleInterference, diagnostic!.Code);Assert.Equal("BrepBoolean.AnalyticHole.HoleInterference", diagnostic.Source);+ Assert.Contains("previously accepted hole", diagnostic.Message, StringComparison.Ordinal);}[Fact]@@ -100,7 +102,7 @@ public sealed class BrepBooleanSafeCompositionGraphValidatorTestsAssert.NotNull(diagnostic);Assert.Equal(BooleanDiagnosticCode.UnsupportedAnalyticSurfaceKind, diagnostic!.Code);Assert.Equal("BrepBoolean.UnsupportedAnalyticSurfaceKind", diagnostic.Source);- Assert.Equal("Boolean Subtract: analytic hole surface kind 'Sphere' is recognized but not implemented for M13 reconstruction.", diagnostic.Message);+ Assert.Equal("Boolean Subtract does not support analytic tool surface kind 'Sphere' in the safe boolean family. Use a cylinder or cone through-hole instead.", diagnostic.Message);}private static BrepBody TransformBody(BrepBody body, Transform3D transform)diff --git a/Aetheris.Kernel.Core.Tests/Brep/Boolean/BrepBooleanTests.cs b/Aetheris.Kernel.Core.Tests/Brep/Boolean/BrepBooleanTests.csindex 1de9b991..55a87850 100644--- a/Aetheris.Kernel.Core.Tests/Brep/Boolean/BrepBooleanTests.cs+++ b/Aetheris.Kernel.Core.Tests/Brep/Boolean/BrepBooleanTests.cs@@ -270,7 +270,7 @@ public sealed class BrepBooleanTestsvar diagnostic = Assert.Single(result.Diagnostics);Assert.Equal(KernelDiagnosticCode.NotImplemented, diagnostic.Code);Assert.Equal("BrepBoolean.AnalyticHole.AxisNotAligned", diagnostic.Source);- Assert.Equal("Boolean Subtract: analytic hole candidate failed diagnostic AxisNotAligned (cylinder axis is not aligned with the box Z axis.).", diagnostic.Message);+ Assert.Equal("Boolean Subtract requires the cylinder axis to be parallel to world Z; the current cylinder axis is not aligned with the box Z axis. Rotate or redefine the tool so both cylinder caps stay on a world-Z through-hole axis.", diagnostic.Message);}[Fact]@@ -285,7 +285,7 @@ public sealed class BrepBooleanTestsvar diagnostic = Assert.Single(result.Diagnostics);Assert.Equal(KernelDiagnosticCode.NotImplemented, diagnostic.Code);Assert.Equal("BrepBoolean.AnalyticHole.NotFullySpanning", diagnostic.Source);- Assert.Equal("Boolean Subtract: analytic hole candidate failed diagnostic NotFullySpanning (cylinder does not fully span the box Z range.).", diagnostic.Message);+ Assert.Equal("Boolean Subtract does not reach both box boundary planes; partial-depth cylinder cuts are outside the supported safe boolean family. Extend the cylinder so it spans the full box Z range.", diagnostic.Message);}[Fact]@@ -300,7 +300,7 @@ public sealed class BrepBooleanTestsvar diagnostic = Assert.Single(result.Diagnostics);Assert.Equal(KernelDiagnosticCode.NotImplemented, diagnostic.Code);Assert.Equal("BrepBoolean.AnalyticHole.RadiusExceedsBoundary", diagnostic.Source);- Assert.Equal("Boolean Subtract: analytic hole candidate failed diagnostic RadiusExceedsBoundary (cylinder radial footprint exceeds the box XY boundary.).", diagnostic.Message);+ Assert.Equal("Boolean Subtract extends outside the box side-wall footprint. Reduce the cylinder radius or move the center farther inside the box XY boundary.", diagnostic.Message);}[Fact]@@ -315,7 +315,7 @@ public sealed class BrepBooleanTestsvar diagnostic = Assert.Single(result.Diagnostics);Assert.Equal(KernelDiagnosticCode.NotImplemented, diagnostic.Code);Assert.Equal("BrepBoolean.AnalyticHole.TangentContact", diagnostic.Source);- Assert.Equal("Boolean Subtract: analytic hole candidate failed diagnostic TangentContact (cylinder is tangent to the box XY boundary.).", diagnostic.Message);+ Assert.Equal("Boolean Subtract is tangent to a box side wall; tangent analytic-hole cases are rejected to avoid zero-thickness geometry. Move the hole inward or reduce the radius.", diagnostic.Message);}[Fact]@@ -399,7 +399,7 @@ public sealed class BrepBooleanTestsvar diagnostic = Assert.Single(result.Diagnostics);Assert.Equal(KernelDiagnosticCode.NotImplemented, diagnostic.Code);Assert.Equal("BrepBoolean.AnalyticHole.AxisNotAligned", diagnostic.Source);- Assert.Equal("Boolean Subtract: analytic hole candidate failed diagnostic AxisNotAligned (cone axis is not aligned with the box Z axis.).", diagnostic.Message);+ Assert.Equal("Boolean Subtract requires the cone axis to be parallel to world Z; the current cone axis is not aligned with the box Z axis. Rotate or redefine the tool so the cone reconstructs as a world-Z through-hole.", diagnostic.Message);}[Fact]@@ -414,7 +414,7 @@ public sealed class BrepBooleanTestsvar diagnostic = Assert.Single(result.Diagnostics);Assert.Equal(KernelDiagnosticCode.NotImplemented, diagnostic.Code);Assert.Equal("BrepBoolean.AnalyticHole.NotFullySpanning", diagnostic.Source);- Assert.Equal("Boolean Subtract: analytic hole candidate failed diagnostic NotFullySpanning (cone does not fully span the box Z range.).", diagnostic.Message);+ Assert.Equal("Boolean Subtract does not reach both box boundary planes; partial-depth cone cuts are outside the supported safe boolean family. Extend the cone so it spans the full box Z range.", diagnostic.Message);}[Fact]@@ -429,7 +429,7 @@ public sealed class BrepBooleanTestsvar diagnostic = Assert.Single(result.Diagnostics);Assert.Equal(KernelDiagnosticCode.NotImplemented, diagnostic.Code);Assert.Equal("BrepBoolean.AnalyticHole.RadiusExceedsBoundary", diagnostic.Source);- Assert.Equal("Boolean Subtract: analytic hole candidate failed diagnostic RadiusExceedsBoundary (cone top-plane cross-section exceeds the box XY boundary.).", diagnostic.Message);+ Assert.Equal("Boolean Subtract has top boundary circle extending outside the box side-wall footprint. Reduce the boundary radius or move the cone center farther inside the box XY boundary.", diagnostic.Message);}[Fact]@@ -444,7 +444,33 @@ public sealed class BrepBooleanTestsvar diagnostic = Assert.Single(result.Diagnostics);Assert.Equal(KernelDiagnosticCode.NotImplemented, diagnostic.Code);Assert.Equal("BrepBoolean.AnalyticHole.TangentContact", diagnostic.Source);- Assert.Equal("Boolean Subtract: analytic hole candidate failed diagnostic TangentContact (cone top-plane cross-section is tangent to the box XY boundary.).", diagnostic.Message);+ Assert.Equal("Boolean Subtract has top boundary circle tangent to a box side wall; tangent analytic-hole cases are rejected to avoid zero-thickness geometry. Move the cone inward or reduce the boundary radius at that plane.", diagnostic.Message);+ }++ [Fact]+ public void ValidateThroughHole_ConeBoundarySectionDegenerates_ReturnsDegenerateBoundarySectionDiagnostic()+ {+ var box = new AxisAlignedBoxExtents(-20d, 20d, -15d, 15d, 0d, 12d);+ var cone = new RecognizedCone(+ new Point3D(0d, 0d, 0d),+ Direction3D.Create(new Vector3D(0d, 0d, 1d)),+ 0d,+ 20d,+ System.Math.Atan(0.5d),+ 0d,+ 10d);++ var result = BrepBooleanCylinderRecognition.ValidateThroughHole(+ box,+ cone,+ ToleranceContext.Default,+ out var diagnostic);++ Assert.False(result);+ Assert.NotNull(diagnostic);+ Assert.Equal(BooleanDiagnosticCode.DegenerateBoundarySection, diagnostic!.Code);+ Assert.Equal("BrepBoolean.AnalyticHole.DegenerateBoundarySection", diagnostic.Source);+ Assert.Equal("Boolean Subtract cannot produce circular sections on both box boundary planes because the apex or cone termination lands inside the box span. Move the apex outside the box span or lengthen the cone.", diagnostic.Message);}[Fact]@@ -530,7 +556,7 @@ public sealed class BrepBooleanTestsvar diagnostic = Assert.Single(second.Diagnostics);Assert.Equal(KernelDiagnosticCode.NotImplemented, diagnostic.Code);Assert.Equal("BrepBoolean.AnalyticHole.HoleInterference", diagnostic.Source);- Assert.Equal("Boolean Subtract: analytic hole candidate failed diagnostic HoleInterference (analytic hole footprint overlaps an existing composed hole).", diagnostic.Message);+ Assert.Equal("Boolean Subtract overlaps previously accepted hole <unknown>; overlapping safe-hole composition is not supported. Separate the hole centers or reduce one of the boundary radii.", diagnostic.Message);}[Fact]@@ -549,7 +575,7 @@ public sealed class BrepBooleanTestsvar diagnostic = Assert.Single(second.Diagnostics);Assert.Equal(KernelDiagnosticCode.NotImplemented, diagnostic.Code);Assert.Equal("BrepBoolean.AnalyticHole.TangentContact", diagnostic.Source);- Assert.Equal("Boolean Subtract: analytic hole candidate failed diagnostic TangentContact (analytic hole footprint is tangent to an existing composed hole.).", diagnostic.Message);+ Assert.Equal("Boolean Subtract would be tangent to previously accepted hole <unknown>; tangent safe-hole composition is rejected to avoid zero-thickness geometry.", diagnostic.Message);}[Fact]@@ -593,7 +619,7 @@ public sealed class BrepBooleanTestsvar diagnostic = Assert.Single(result.Diagnostics);Assert.Equal(KernelDiagnosticCode.NotImplemented, diagnostic.Code);Assert.Equal("BrepBoolean.UnsupportedAnalyticSurfaceKind", diagnostic.Source);- Assert.Equal("Boolean Subtract: analytic hole surface kind 'Sphere' is recognized but not implemented for M13 reconstruction.", diagnostic.Message);+ Assert.Equal("Boolean Subtract does not support analytic tool surface kind 'Sphere' in the safe boolean family. Use a cylinder or cone through-hole instead.", diagnostic.Message);}[Fact]@@ -748,7 +774,7 @@ public sealed class BrepBooleanTestsif (operation == BooleanOperation.Subtract){Assert.Equal("BrepBoolean.UnsupportedAnalyticSurfaceKind", diagnostic.Source);- Assert.Equal($"Boolean {operation}: analytic hole surface kind 'Torus' is recognized but not implemented for M13 reconstruction.", diagnostic.Message);+ Assert.Equal($"Boolean {operation} does not support analytic tool surface kind 'Torus' in the safe boolean family. Use a cylinder or cone through-hole instead.", diagnostic.Message);}else{diff --git a/Aetheris.Kernel.Core/Brep/Boolean/BooleanDiagnostic.cs b/Aetheris.Kernel.Core/Brep/Boolean/BooleanDiagnostic.csindex 0f1c8f4a..e54f810c 100644--- a/Aetheris.Kernel.Core/Brep/Boolean/BooleanDiagnostic.cs+++ b/Aetheris.Kernel.Core/Brep/Boolean/BooleanDiagnostic.cs@@ -6,6 +6,7 @@ public enum BooleanDiagnosticCode{AxisNotAligned,NotFullySpanning,+ DegenerateBoundarySection,RadiusExceedsBoundary,TangentContact,MultiBodyResult,diff --git a/Aetheris.Kernel.Core/Brep/Boolean/BrepBooleanCylinderRecognition.cs b/Aetheris.Kernel.Core/Brep/Boolean/BrepBooleanCylinderRecognition.csindex ab5169b5..919d85dc 100644--- a/Aetheris.Kernel.Core/Brep/Boolean/BrepBooleanCylinderRecognition.cs+++ b/Aetheris.Kernel.Core/Brep/Boolean/BrepBooleanCylinderRecognition.cs@@ -152,13 +152,13 @@ public static class BrepBooleanCylinderRecognition&& ToleranceMath.AlmostEqual(double.Abs(axis.Z), 1d, tolerance);}- public static bool ValidateThroughHole(AxisAlignedBoxExtents box, in RecognizedCylinder cylinder, ToleranceContext tolerance, out BooleanDiagnostic? diagnostic)+ public static bool ValidateThroughHole(AxisAlignedBoxExtents box, in RecognizedCylinder cylinder, ToleranceContext tolerance, out BooleanDiagnostic? diagnostic, string? featureId = null){diagnostic = null;if (!ValidateAxisAlignedZ(cylinder, tolerance)){- diagnostic = CreateAxisNotAlignedDiagnostic(BooleanOperation.Subtract.ToString(), "cylinder axis is not aligned with the box Z axis.");+ diagnostic = CreateAxisNotAlignedDiagnostic(BooleanOperation.Subtract.ToString(), featureId, "requires the cylinder axis to be parallel to world Z; the current cylinder axis is not aligned with the box Z axis. Rotate or redefine the tool so both cylinder caps stay on a world-Z through-hole axis.");return false;}@@ -166,7 +166,7 @@ public static class BrepBooleanCylinderRecognitionvar maxCenter = cylinder.MaxCenter;if (!ToleranceMath.AlmostEqual(minCenter.X, maxCenter.X, tolerance) || !ToleranceMath.AlmostEqual(minCenter.Y, maxCenter.Y, tolerance)){- diagnostic = CreateAxisNotAlignedDiagnostic(BooleanOperation.Subtract.ToString(), "cylinder cap centers are not vertically aligned in XY.");+ diagnostic = CreateAxisNotAlignedDiagnostic(BooleanOperation.Subtract.ToString(), featureId, "requires one vertical through-hole centerline; the cylinder cap centers drift in XY instead of staying on a single world-Z axis. Rebuild the tool so the cap centers share the same X/Y location.");return false;}@@ -177,7 +177,7 @@ public static class BrepBooleanCylinderRecognitionif (minZ > (box.MinZ + tolerance.Linear) || maxZ < (box.MaxZ - tolerance.Linear)){- diagnostic = CreateNotFullySpanningDiagnostic(BooleanOperation.Subtract.ToString(), "cylinder does not fully span the box Z range.");+ diagnostic = CreateNotFullySpanningDiagnostic(BooleanOperation.Subtract.ToString(), featureId, "does not reach both box boundary planes; partial-depth cylinder cuts are outside the supported safe boolean family. Extend the cylinder so it spans the full box Z range.");return false;}@@ -193,7 +193,7 @@ public static class BrepBooleanCylinderRecognition|| ToleranceMath.AlmostEqual(maxFootprintY, box.MaxY, tolerance);if (tangentContact){- diagnostic = CreateTangentContactDiagnostic(BooleanOperation.Subtract.ToString(), "cylinder is tangent to the box XY boundary.");+ diagnostic = CreateTangentContactDiagnostic(BooleanOperation.Subtract.ToString(), featureId, "is tangent to a box side wall; tangent analytic-hole cases are rejected to avoid zero-thickness geometry. Move the hole inward or reduce the radius.");return false;}@@ -202,14 +202,14 @@ public static class BrepBooleanCylinderRecognition|| minFootprintY < (box.MinY - tolerance.Linear)|| maxFootprintY > (box.MaxY + tolerance.Linear)){- diagnostic = CreateRadiusExceedsBoundaryDiagnostic(BooleanOperation.Subtract.ToString(), "cylinder radial footprint exceeds the box XY boundary.");+ diagnostic = CreateRadiusExceedsBoundaryDiagnostic(BooleanOperation.Subtract.ToString(), featureId, "extends outside the box side-wall footprint. Reduce the cylinder radius or move the center farther inside the box XY boundary.");return false;}return true;}- public static bool ValidateThroughHole(AxisAlignedBoxExtents box, in RecognizedCone cone, ToleranceContext tolerance, out BooleanDiagnostic? diagnostic)+ public static bool ValidateThroughHole(AxisAlignedBoxExtents box, in RecognizedCone cone, ToleranceContext tolerance, out BooleanDiagnostic? diagnostic, string? featureId = null){diagnostic = null;@@ -218,7 +218,7 @@ public static class BrepBooleanCylinderRecognition|| !ToleranceMath.AlmostZero(axis.Y, tolerance)|| !ToleranceMath.AlmostEqual(double.Abs(axis.Z), 1d, tolerance)){- diagnostic = CreateAxisNotAlignedDiagnostic(BooleanOperation.Subtract.ToString(), "cone axis is not aligned with the box Z axis.");+ diagnostic = CreateAxisNotAlignedDiagnostic(BooleanOperation.Subtract.ToString(), featureId, "requires the cone axis to be parallel to world Z; the current cone axis is not aligned with the box Z axis. Rotate or redefine the tool so the cone reconstructs as a world-Z through-hole.");return false;}@@ -226,7 +226,7 @@ public static class BrepBooleanCylinderRecognitionvar maxCenter = cone.MaxCenter;if (!ToleranceMath.AlmostEqual(minCenter.X, maxCenter.X, tolerance) || !ToleranceMath.AlmostEqual(minCenter.Y, maxCenter.Y, tolerance)){- diagnostic = CreateAxisNotAlignedDiagnostic(BooleanOperation.Subtract.ToString(), "cone cap centers are not vertically aligned in XY.");+ diagnostic = CreateAxisNotAlignedDiagnostic(BooleanOperation.Subtract.ToString(), featureId, "requires one vertical through-hole centerline; the cone boundary circles do not share a single X/Y center. Rebuild the cone so both boundary sections stay on one world-Z axis.");return false;}@@ -238,13 +238,13 @@ public static class BrepBooleanCylinderRecognition|| topAxisParameter < (cone.MinAxisParameter - tolerance.Linear)|| topAxisParameter > (cone.MaxAxisParameter + tolerance.Linear)){- diagnostic = CreateNotFullySpanningDiagnostic(BooleanOperation.Subtract.ToString(), "cone does not fully span the box Z range.");+ diagnostic = CreateNotFullySpanningDiagnostic(BooleanOperation.Subtract.ToString(), featureId, "does not reach both box boundary planes; partial-depth cone cuts are outside the supported safe boolean family. Extend the cone so it spans the full box Z range.");return false;}if (bottomAxisParameter <= tolerance.Linear || topAxisParameter <= tolerance.Linear){- diagnostic = CreateNotFullySpanningDiagnostic(BooleanOperation.Subtract.ToString(), "cone apex or termination prevents circular through-hole sections at both box Z boundary planes.");+ diagnostic = CreateDegenerateBoundarySectionDiagnostic(BooleanOperation.Subtract.ToString(), featureId, "cannot produce circular sections on both box boundary planes because the apex or cone termination lands inside the box span. Move the apex outside the box span or lengthen the cone.");return false;}@@ -255,12 +255,12 @@ public static class BrepBooleanCylinderRecognitionif (bottomRadius <= tolerance.Linear || topRadius <= tolerance.Linear){- diagnostic = CreateNotFullySpanningDiagnostic(BooleanOperation.Subtract.ToString(), "cone cross-sections at the box Z boundary planes must be non-degenerate circles.");+ diagnostic = CreateDegenerateBoundarySectionDiagnostic(BooleanOperation.Subtract.ToString(), featureId, "requires non-degenerate circular sections where the cone meets the two box boundary planes. Increase the boundary radii at those planes by moving the apex farther away or changing the cone taper.");return false;}- if (!ValidateCircleInsideBoxFootprint(box, centerX, centerY, bottomRadius, tolerance, out diagnostic, "cone bottom-plane cross-section")- || !ValidateCircleInsideBoxFootprint(box, centerX, centerY, topRadius, tolerance, out diagnostic, "cone top-plane cross-section"))+ if (!ValidateCircleInsideBoxFootprint(box, centerX, centerY, bottomRadius, tolerance, out diagnostic, "bottom boundary circle", featureId)+ || !ValidateCircleInsideBoxFootprint(box, centerX, centerY, topRadius, tolerance, out diagnostic, "top boundary circle", featureId)){return false;}@@ -286,7 +286,8 @@ public static class BrepBooleanCylinderRecognitiondouble radius,ToleranceContext tolerance,out BooleanDiagnostic? diagnostic,- string circleLabel)+ string circleLabel,+ string? featureId){diagnostic = null;@@ -302,7 +303,7 @@ public static class BrepBooleanCylinderRecognition|| ToleranceMath.AlmostEqual(maxFootprintY, box.MaxY, tolerance);if (tangentContact){- diagnostic = CreateTangentContactDiagnostic(BooleanOperation.Subtract.ToString(), $"{circleLabel} is tangent to the box XY boundary.");+ diagnostic = CreateTangentContactDiagnostic(BooleanOperation.Subtract.ToString(), featureId, $"has {circleLabel} tangent to a box side wall; tangent analytic-hole cases are rejected to avoid zero-thickness geometry. Move the cone inward or reduce the boundary radius at that plane.");return false;}@@ -311,7 +312,7 @@ public static class BrepBooleanCylinderRecognition|| minFootprintY < (box.MinY - tolerance.Linear)|| maxFootprintY > (box.MaxY + tolerance.Linear)){- diagnostic = CreateRadiusExceedsBoundaryDiagnostic(BooleanOperation.Subtract.ToString(), $"{circleLabel} exceeds the box XY boundary.");+ diagnostic = CreateRadiusExceedsBoundaryDiagnostic(BooleanOperation.Subtract.ToString(), featureId, $"has {circleLabel} extending outside the box side-wall footprint. Reduce the boundary radius or move the cone center farther inside the box XY boundary.");return false;}@@ -319,32 +320,61 @@ public static class BrepBooleanCylinderRecognition}public static BooleanDiagnostic CreateAxisNotAlignedDiagnostic(string operation, string detail)+ => CreateAxisNotAlignedDiagnostic(operation, null, detail);++ public static BooleanDiagnostic CreateAxisNotAlignedDiagnostic(string operation, string? featureId, string detail)=> new(BooleanDiagnosticCode.AxisNotAligned,- $"Boolean {operation}: analytic hole candidate failed diagnostic AxisNotAligned ({detail}).",+ CreateBooleanMessage(operation, featureId, detail),"BrepBoolean.AnalyticHole.AxisNotAligned");public static BooleanDiagnostic CreateNotFullySpanningDiagnostic(string operation, string detail)+ => CreateNotFullySpanningDiagnostic(operation, null, detail);++ public static BooleanDiagnostic CreateNotFullySpanningDiagnostic(string operation, string? featureId, string detail)=> new(BooleanDiagnosticCode.NotFullySpanning,- $"Boolean {operation}: analytic hole candidate failed diagnostic NotFullySpanning ({detail}).",+ CreateBooleanMessage(operation, featureId, detail),"BrepBoolean.AnalyticHole.NotFullySpanning");+ public static BooleanDiagnostic CreateDegenerateBoundarySectionDiagnostic(string operation, string? featureId, string detail)+ => new(+ BooleanDiagnosticCode.DegenerateBoundarySection,+ CreateBooleanMessage(operation, featureId, detail),+ "BrepBoolean.AnalyticHole.DegenerateBoundarySection");+public static BooleanDiagnostic CreateRadiusExceedsBoundaryDiagnostic(string operation, string detail)+ => CreateRadiusExceedsBoundaryDiagnostic(operation, null, detail);++ public static BooleanDiagnostic CreateRadiusExceedsBoundaryDiagnostic(string operation, string? featureId, string detail)=> new(BooleanDiagnosticCode.RadiusExceedsBoundary,- $"Boolean {operation}: analytic hole candidate failed diagnostic RadiusExceedsBoundary ({detail}).",+ CreateBooleanMessage(operation, featureId, detail),"BrepBoolean.AnalyticHole.RadiusExceedsBoundary");public static BooleanDiagnostic CreateTangentContactDiagnostic(string operation, string detail)+ => CreateTangentContactDiagnostic(operation, null, detail);++ public static BooleanDiagnostic CreateTangentContactDiagnostic(string operation, string? featureId, string detail)=> new(BooleanDiagnosticCode.TangentContact,- $"Boolean {operation}: analytic hole candidate failed diagnostic TangentContact ({detail}).",+ CreateBooleanMessage(operation, featureId, detail),"BrepBoolean.AnalyticHole.TangentContact");public static BooleanDiagnostic CreateUnsupportedAnalyticSurfaceKindDiagnostic(string operation, AnalyticSurfaceKind kind)+ => CreateUnsupportedAnalyticSurfaceKindDiagnostic(operation, kind, null);++ public static BooleanDiagnostic CreateUnsupportedAnalyticSurfaceKindDiagnostic(string operation, AnalyticSurfaceKind kind, string? featureId)=> new(BooleanDiagnosticCode.UnsupportedAnalyticSurfaceKind,- $"Boolean {operation}: analytic hole surface kind '{kind}' is recognized but not implemented for M13 reconstruction.",+ CreateBooleanMessage(operation, featureId, $"does not support analytic tool surface kind '{kind}' in the safe boolean family. Use a cylinder or cone through-hole instead."),"BrepBoolean.UnsupportedAnalyticSurfaceKind");++ public static string CreateBooleanMessage(string operation, string? featureId, string detail)+ {+ var subject = string.IsNullOrWhiteSpace(featureId)+ ? $"Boolean {operation}"+ : $"Boolean feature '{featureId}' ({operation.ToLowerInvariant()})";+ return $"{subject} {detail}";+ }}diff --git a/Aetheris.Kernel.Core/Brep/Boolean/BrepBooleanSafeComposition.cs b/Aetheris.Kernel.Core/Brep/Boolean/BrepBooleanSafeComposition.csindex bfd2cf20..7b077e1d 100644--- a/Aetheris.Kernel.Core/Brep/Boolean/BrepBooleanSafeComposition.cs+++ b/Aetheris.Kernel.Core/Brep/Boolean/BrepBooleanSafeComposition.cs@@ -24,6 +24,7 @@ public sealed record SafeBooleanComposition(}public readonly record struct SupportedBooleanHole(+ string? FeatureId,AnalyticSurface Surface,double CenterX,double CenterY,diff --git a/Aetheris.Kernel.Core/Brep/Boolean/BrepBooleanSafeCompositionGraphValidator.cs b/Aetheris.Kernel.Core/Brep/Boolean/BrepBooleanSafeCompositionGraphValidator.csindex 51344136..dd6b5e1f 100644--- a/Aetheris.Kernel.Core/Brep/Boolean/BrepBooleanSafeCompositionGraphValidator.cs+++ b/Aetheris.Kernel.Core/Brep/Boolean/BrepBooleanSafeCompositionGraphValidator.cs@@ -10,12 +10,13 @@ public static class BrepBooleanSafeCompositionGraphValidatorAnalyticSurface surface,ToleranceContext tolerance,out SafeBooleanComposition updatedComposition,- out BooleanDiagnostic? diagnostic)+ out BooleanDiagnostic? diagnostic,+ string? nextFeatureId = null){updatedComposition = composition;diagnostic = null;- if (!TryCreateSupportedHole(composition.OuterBox, surface, tolerance, out var nextHole, out diagnostic))+ if (!TryCreateSupportedHole(composition.OuterBox, surface, tolerance, out var nextHole, out diagnostic, nextFeatureId)){return false;}@@ -31,7 +32,8 @@ public static class BrepBooleanSafeCompositionGraphValidator{diagnostic = BrepBooleanCylinderRecognition.CreateTangentContactDiagnostic(BooleanOperation.Subtract.ToString(),- "analytic hole footprint is tangent to an existing composed hole.");+ nextFeatureId,+ $"would be tangent to previously accepted hole {FormatFeatureRef(existingHole.FeatureId)}; tangent safe-hole composition is rejected to avoid zero-thickness geometry.");return false;}@@ -39,7 +41,10 @@ public static class BrepBooleanSafeCompositionGraphValidator{diagnostic = new BooleanDiagnostic(BooleanDiagnosticCode.HoleInterference,- "Boolean Subtract: analytic hole candidate failed diagnostic HoleInterference (analytic hole footprint overlaps an existing composed hole).",+ BrepBooleanCylinderRecognition.CreateBooleanMessage(+ BooleanOperation.Subtract.ToString(),+ nextFeatureId,+ $"overlaps previously accepted hole {FormatFeatureRef(existingHole.FeatureId)}; overlapping safe-hole composition is not supported. Separate the hole centers or reduce one of the boundary radii."),"BrepBoolean.AnalyticHole.HoleInterference");return false;}@@ -57,18 +62,20 @@ public static class BrepBooleanSafeCompositionGraphValidatorAnalyticSurface surface,ToleranceContext tolerance,out SupportedBooleanHole hole,- out BooleanDiagnostic? diagnostic)+ out BooleanDiagnostic? diagnostic,+ string? featureId){switch (surface.Kind){case AnalyticSurfaceKind.Cylinder when surface.Cylinder is RecognizedCylinder cylinder:- if (!BrepBooleanCylinderRecognition.ValidateThroughHole(outerBox, cylinder, tolerance, out diagnostic))+ if (!BrepBooleanCylinderRecognition.ValidateThroughHole(outerBox, cylinder, tolerance, out diagnostic, featureId)){hole = default;return false;}hole = new SupportedBooleanHole(+ featureId,surface,cylinder.MinCenter.X,cylinder.MinCenter.Y,@@ -77,7 +84,7 @@ public static class BrepBooleanSafeCompositionGraphValidatorreturn true;case AnalyticSurfaceKind.Cone when surface.Cone is RecognizedCone cone:- if (!BrepBooleanCylinderRecognition.ValidateThroughHole(outerBox, cone, tolerance, out diagnostic))+ if (!BrepBooleanCylinderRecognition.ValidateThroughHole(outerBox, cone, tolerance, out diagnostic, featureId)){hole = default;return false;@@ -87,6 +94,7 @@ public static class BrepBooleanSafeCompositionGraphValidatorvar topAxisParameter = AxisParameterAtZ(cone, outerBox.MaxZ, tolerance);var boundaryBottomCenter = cone.PointAtAxisParameter(bottomAxisParameter);hole = new SupportedBooleanHole(+ featureId,surface,boundaryBottomCenter.X,boundaryBottomCenter.Y,@@ -99,7 +107,8 @@ public static class BrepBooleanSafeCompositionGraphValidatordefault:diagnostic = BrepBooleanCylinderRecognition.CreateUnsupportedAnalyticSurfaceKindDiagnostic(BooleanOperation.Subtract.ToString(),- surface.Kind);+ surface.Kind,+ featureId);hole = default;return false;}@@ -115,4 +124,7 @@ public static class BrepBooleanSafeCompositionGraphValidatorreturn (z - cone.AxisOrigin.Z) / axisZ;}++ private static string FormatFeatureRef(string? featureId)+ => string.IsNullOrWhiteSpace(featureId) ? "<unknown>" : $"'{featureId}'";}diff --git a/Aetheris.Kernel.Firmament.Tests/FirmamentBooleanCanonicalSuccessTests.cs b/Aetheris.Kernel.Firmament.Tests/FirmamentBooleanCanonicalSuccessTests.csindex 4768256c..02bb3282 100644--- a/Aetheris.Kernel.Firmament.Tests/FirmamentBooleanCanonicalSuccessTests.cs+++ b/Aetheris.Kernel.Firmament.Tests/FirmamentBooleanCanonicalSuccessTests.cs@@ -163,12 +163,12 @@ public sealed class FirmamentBooleanCanonicalSuccessTests}[Theory]- [InlineData("testdata/firmament/fixtures/m13a-unsupported-overlapping-composed-holes.firmament", "hole_b", "HoleInterference")]- [InlineData("testdata/firmament/fixtures/m13a-unsupported-tangent-composed-holes.firmament", "hole_b", "TangentContact")]- [InlineData("testdata/firmament/fixtures/m13a-unsupported-composed-add-ordering.firmament", "joined", "violates safe subtract feature-graph ordering")]+ [InlineData("testdata/firmament/fixtures/m13a-unsupported-overlapping-composed-holes.firmament", "hole_b", "overlaps previously accepted hole")]+ [InlineData("testdata/firmament/fixtures/m13a-unsupported-tangent-composed-holes.firmament", "hole_b", "would be tangent to previously accepted hole")]+ [InlineData("testdata/firmament/fixtures/m13a-unsupported-composed-add-ordering.firmament", "joined", "cannot continue the safe subtract chain rooted at 'hole_a'")][InlineData("testdata/firmament/fixtures/m13a-unsupported-composed-subtract-sphere.firmament", "cavity", "unsupported follow-on tool kind 'sphere'")][InlineData("testdata/firmament/fixtures/m13a-unsupported-composed-subtract-box.firmament", "notch", "unsupported follow-on tool kind 'box'")]- [InlineData("testdata/firmament/fixtures/m13b-invalid-composed-reenter-safe-family.firmament", "hole", "outside that supported family")]+ [InlineData("testdata/firmament/fixtures/m13b-invalid-composed-reenter-safe-family.firmament", "hole", "cannot re-enter the safe subtract family from 'joined'")]public void SequentialCompositionOutsideSafeSubset_RemainsRejectedWithoutFallback(string fixturePath, string expectedFeatureId, string expectedMessageFragment){var result = FirmamentCorpusHarness.Compile(FirmamentCorpusHarness.ReadFixtureText(fixturePath));@@ -224,9 +224,9 @@ public sealed class FirmamentBooleanCanonicalSuccessTestsprivate static bool HasExpectedMixedPrimitiveFailure(string message)=> message.Contains("M13 only supports recognized axis-aligned boxes from BrepPrimitives.CreateBox(...).", StringComparison.Ordinal)|| message.Contains("sequential safe composition only supports subtracting supported cylinder/cone through-holes", StringComparison.Ordinal)- || message.Contains("feature-graph ordering", StringComparison.Ordinal)+ || message.Contains("safe subtract", StringComparison.Ordinal)|| message.Contains("unsupported follow-on tool kind", StringComparison.Ordinal)- || message.Contains("analytic hole candidate failed diagnostic", StringComparison.Ordinal)+ || message.Contains("Boolean feature", StringComparison.Ordinal)|| message.Contains("analytic hole surface kind", StringComparison.Ordinal);private static int CountOccurrences(string text, string token)diff --git a/Aetheris.Kernel.Firmament.Tests/FirmamentBooleanRequiredFieldValidationTests.cs b/Aetheris.Kernel.Firmament.Tests/FirmamentBooleanRequiredFieldValidationTests.csindex 43dadb10..17c6b92d 100644--- a/Aetheris.Kernel.Firmament.Tests/FirmamentBooleanRequiredFieldValidationTests.cs+++ b/Aetheris.Kernel.Firmament.Tests/FirmamentBooleanRequiredFieldValidationTests.cs@@ -147,7 +147,7 @@ public sealed class FirmamentBooleanRequiredFieldValidationTestsAssert.Contains(result.Compilation.Diagnostics, diagnostic =>diagnostic.Code == Aetheris.Kernel.Core.Diagnostics.KernelDiagnosticCode.NotImplemented&& (diagnostic.Message.Contains("M13 only supports recognized axis-aligned boxes from BrepPrimitives.CreateBox(...).", StringComparison.Ordinal)- || diagnostic.Message.Contains("analytic hole surface kind", StringComparison.Ordinal)));+ || diagnostic.Message.Contains("analytic tool surface kind", StringComparison.Ordinal)));}[Fact]diff --git a/Aetheris.Kernel.Firmament.Tests/FirmamentBuildAndExportTests.cs b/Aetheris.Kernel.Firmament.Tests/FirmamentBuildAndExportTests.csindex 6cac275e..f411ec5a 100644--- a/Aetheris.Kernel.Firmament.Tests/FirmamentBuildAndExportTests.cs+++ b/Aetheris.Kernel.Firmament.Tests/FirmamentBuildAndExportTests.cs@@ -249,8 +249,8 @@ public sealed class FirmamentBuildAndExportTestsprivate static bool HasExpectedMixedPrimitiveFailure(string message)=> message.Contains("M13 only supports recognized axis-aligned boxes from BrepPrimitives.CreateBox(...).", StringComparison.Ordinal)|| message.Contains("sequential safe composition only supports subtracting supported cylinder/cone through-holes", StringComparison.Ordinal)- || message.Contains("feature-graph ordering", StringComparison.Ordinal)+ || message.Contains("safe subtract", StringComparison.Ordinal)|| message.Contains("unsupported follow-on tool kind", StringComparison.Ordinal)- || message.Contains("analytic hole candidate failed diagnostic", StringComparison.Ordinal)+ || message.Contains("Boolean feature", StringComparison.Ordinal)|| message.Contains("analytic hole surface kind", StringComparison.Ordinal);}diff --git a/Aetheris.Kernel.Firmament.Tests/FirmamentPrimitiveExecutionTests.cs b/Aetheris.Kernel.Firmament.Tests/FirmamentPrimitiveExecutionTests.csindex c30cd372..d21de805 100644--- a/Aetheris.Kernel.Firmament.Tests/FirmamentPrimitiveExecutionTests.cs+++ b/Aetheris.Kernel.Firmament.Tests/FirmamentPrimitiveExecutionTests.cs@@ -278,7 +278,7 @@ public sealed class FirmamentPrimitiveExecutionTestsdiagnostic.Code == Aetheris.Kernel.Core.Diagnostics.KernelDiagnosticCode.NotImplemented&& (diagnostic.Message.Contains("M13 only supports recognized axis-aligned boxes from BrepPrimitives.CreateBox(...).", StringComparison.Ordinal)|| diagnostic.Message.Contains("analytic hole surface kind", StringComparison.Ordinal)- || diagnostic.Message.Contains("analytic hole candidate failed diagnostic", StringComparison.Ordinal)));+ || diagnostic.Message.Contains("Boolean feature", StringComparison.Ordinal)));}[Fact]diff --git a/Aetheris.Kernel.Firmament.Tests/FirmamentSafeSubtractFeatureGraphValidationTests.cs b/Aetheris.Kernel.Firmament.Tests/FirmamentSafeSubtractFeatureGraphValidationTests.csindex f2a51c9d..4effb798 100644--- a/Aetheris.Kernel.Firmament.Tests/FirmamentSafeSubtractFeatureGraphValidationTests.cs+++ b/Aetheris.Kernel.Firmament.Tests/FirmamentSafeSubtractFeatureGraphValidationTests.cs@@ -17,14 +17,15 @@ public sealed class FirmamentSafeSubtractFeatureGraphValidationTests}[Theory]- [InlineData("testdata/firmament/fixtures/m13a-unsupported-composed-add-ordering.firmament", "violates safe subtract feature-graph ordering", "firmament.feature-graph")]- [InlineData("testdata/firmament/fixtures/m13a-unsupported-overlapping-composed-holes.firmament", "HoleInterference", "BrepBoolean.AnalyticHole.HoleInterference")]- [InlineData("testdata/firmament/fixtures/m13a-unsupported-tangent-composed-holes.firmament", "TangentContact", "BrepBoolean.AnalyticHole.TangentContact")]- [InlineData("testdata/firmament/fixtures/m13a-unsupported-composed-subtract-sphere.firmament", "unsupported follow-on tool kind 'sphere'", "firmament.feature-graph")]- [InlineData("testdata/firmament/fixtures/m13a-unsupported-composed-subtract-box.firmament", "unsupported follow-on tool kind 'box'", "firmament.feature-graph")]- [InlineData("testdata/firmament/fixtures/m13b-invalid-composed-reenter-safe-family.firmament", "outside that supported family", "firmament.feature-graph")]+ [InlineData("testdata/firmament/fixtures/m13a-unsupported-composed-add-ordering.firmament", KernelDiagnosticCode.ValidationFailed, "Boolean feature 'joined' (add) cannot continue the safe subtract chain rooted at 'hole_a'", "firmament.feature-graph.invalid-composition-order")]+ [InlineData("testdata/firmament/fixtures/m13a-unsupported-overlapping-composed-holes.firmament", KernelDiagnosticCode.NotImplemented, "Boolean feature 'hole_b' (subtract) overlaps previously accepted hole <unknown>", "BrepBoolean.AnalyticHole.HoleInterference")]+ [InlineData("testdata/firmament/fixtures/m13a-unsupported-tangent-composed-holes.firmament", KernelDiagnosticCode.NotImplemented, "Boolean feature 'hole_b' (subtract) would be tangent to previously accepted hole <unknown>", "BrepBoolean.AnalyticHole.TangentContact")]+ [InlineData("testdata/firmament/fixtures/m13a-unsupported-composed-subtract-sphere.firmament", KernelDiagnosticCode.ValidationFailed, "Boolean feature 'cavity' (subtract) uses unsupported follow-on tool kind 'sphere'", "firmament.feature-graph.unsupported-follow-on-kind")]+ [InlineData("testdata/firmament/fixtures/m13a-unsupported-composed-subtract-box.firmament", KernelDiagnosticCode.ValidationFailed, "Boolean feature 'notch' (subtract) uses unsupported follow-on tool kind 'box'", "firmament.feature-graph.unsupported-follow-on-kind")]+ [InlineData("testdata/firmament/fixtures/m13b-invalid-composed-reenter-safe-family.firmament", KernelDiagnosticCode.ValidationFailed, "Boolean feature 'hole' (subtract) cannot re-enter the safe subtract family from 'joined'", "firmament.feature-graph.invalid-composition-order")]public void FeatureGraphValidator_FailsDeterministically_ForUnsupportedSequentialComposition(string fixturePath,+ KernelDiagnosticCode expectedCode,string expectedMessage,string expectedSource){@@ -32,7 +33,7 @@ public sealed class FirmamentSafeSubtractFeatureGraphValidationTestsAssert.False(result.Compilation.IsSuccess);Assert.Contains(result.Compilation.Diagnostics, diagnostic =>- diagnostic.Code == KernelDiagnosticCode.NotImplemented+ diagnostic.Code == expectedCode&& diagnostic.Message.Contains(expectedMessage, StringComparison.Ordinal)&& diagnostic.Source == expectedSource);Assert.DoesNotContain(result.Compilation.Diagnostics, diagnostic =>diff --git a/Aetheris.Kernel.Firmament.Tests/FirmamentStepExporterTests.cs b/Aetheris.Kernel.Firmament.Tests/FirmamentStepExporterTests.csindex 64825e10..11d4dbfc 100644--- a/Aetheris.Kernel.Firmament.Tests/FirmamentStepExporterTests.cs+++ b/Aetheris.Kernel.Firmament.Tests/FirmamentStepExporterTests.cs@@ -158,7 +158,7 @@ public sealed class FirmamentStepExporterTestsAssert.Equal(first.Diagnostics, second.Diagnostics);Assert.Contains(first.Diagnostics, diagnostic => diagnostic.Message.Contains("Requested boolean feature 'hole' (subtract) could not be executed.", StringComparison.Ordinal));Assert.Contains(first.Diagnostics, diagnostic => diagnostic.Source == "BrepBoolean.AnalyticHole.NotFullySpanning"- && diagnostic.Message.Contains("analytic hole candidate failed diagnostic NotFullySpanning", StringComparison.Ordinal));+ && diagnostic.Message.Contains("Boolean feature 'hole' (subtract) does not reach both box boundary planes", StringComparison.Ordinal));Assert.DoesNotContain(first.Diagnostics, diagnostic => diagnostic.Message.Contains("requires at least one executed primitive or boolean body", StringComparison.Ordinal));}@@ -229,9 +229,9 @@ public sealed class FirmamentStepExporterTestsprivate static bool HasExpectedMixedPrimitiveFailure(string message)=> message.Contains("M13 only supports recognized axis-aligned boxes from BrepPrimitives.CreateBox(...).", StringComparison.Ordinal)|| message.Contains("sequential safe composition only supports subtracting supported cylinder/cone through-holes", StringComparison.Ordinal)- || message.Contains("feature-graph ordering", StringComparison.Ordinal)+ || message.Contains("safe subtract", StringComparison.Ordinal)|| message.Contains("unsupported follow-on tool kind", StringComparison.Ordinal)- || message.Contains("analytic hole candidate failed diagnostic", StringComparison.Ordinal)+ || message.Contains("Boolean feature", StringComparison.Ordinal)|| message.Contains("analytic hole surface kind", StringComparison.Ordinal);private static int CountOccurrences(string text, string token)diff --git a/Aetheris.Kernel.Firmament/Execution/FirmamentPrimitiveExecutor.cs b/Aetheris.Kernel.Firmament/Execution/FirmamentPrimitiveExecutor.csindex ff8205e7..563c0994 100644--- a/Aetheris.Kernel.Firmament/Execution/FirmamentPrimitiveExecutor.cs+++ b/Aetheris.Kernel.Firmament/Execution/FirmamentPrimitiveExecutor.cs@@ -57,7 +57,7 @@ internal static class FirmamentPrimitiveExecutorreturn KernelResult<FirmamentPrimitiveExecutionResult>.Failure([CreateBooleanExecutionFailureDiagnostic(boolean),- .. featureGraphValidation.Diagnostics+ .. WithBooleanContext(boolean, featureGraphValidation.Diagnostics)]);}@@ -73,7 +73,7 @@ internal static class FirmamentPrimitiveExecutorreturn KernelResult<FirmamentPrimitiveExecutionResult>.Failure([CreateBooleanExecutionFailureDiagnostic(boolean),- .. booleanResult.Diagnostics+ .. WithBooleanContext(boolean, booleanResult.Diagnostics)]);}@@ -95,6 +95,21 @@ internal static class FirmamentPrimitiveExecutorreturn KernelResult<FirmamentPrimitiveExecutionResult>.Success(new FirmamentPrimitiveExecutionResult(executedPrimitives, executedBooleans));}++ private static IReadOnlyList<KernelDiagnostic> WithBooleanContext(FirmamentLoweredBoolean boolean, IReadOnlyList<KernelDiagnostic> diagnostics)+ => diagnostics.Select(diagnostic =>+ {+ if (diagnostic.Message.Contains($"Boolean feature '{boolean.FeatureId}'", StringComparison.Ordinal))+ {+ return diagnostic;+ }++ return diagnostic with+ {+ Message = $"Boolean feature '{boolean.FeatureId}' ({boolean.Kind.ToString().ToLowerInvariant()}): {diagnostic.Message}"+ };+ }).ToArray();+private static KernelDiagnostic CreateBooleanExecutionFailureDiagnostic(FirmamentLoweredBoolean boolean)=> new(KernelDiagnosticCode.NotImplemented,diff --git a/Aetheris.Kernel.Firmament/Validation/FirmamentSafeSubtractFeatureGraphValidator.cs b/Aetheris.Kernel.Firmament/Validation/FirmamentSafeSubtractFeatureGraphValidator.csindex 3cd33896..9ed91c2d 100644--- a/Aetheris.Kernel.Firmament/Validation/FirmamentSafeSubtractFeatureGraphValidator.cs+++ b/Aetheris.Kernel.Firmament/Validation/FirmamentSafeSubtractFeatureGraphValidator.cs@@ -31,13 +31,17 @@ internal static class FirmamentSafeSubtractFeatureGraphValidatorif (boolean.Kind != FirmamentLoweredBooleanKind.Subtract){return Failure(- $"Boolean op '{boolean.FeatureId}' at index {boolean.OpIndex} violates safe subtract feature-graph ordering: composed hole chains can only continue with 'subtract', but got '{boolean.Kind.ToString().ToLowerInvariant()}'.");+ KernelDiagnosticCode.ValidationFailed,+ $"Boolean feature '{boolean.FeatureId}' ({boolean.Kind.ToString().ToLowerInvariant()}) cannot continue the safe subtract chain rooted at '{boolean.PrimaryReferenceFeatureId}' because only follow-on subtract operations are supported after a safe-hole composition has started.",+ "firmament.feature-graph.invalid-composition-order");}if (!usesSupportedSafeHoleTool){return Failure(- $"Boolean op '{boolean.FeatureId}' at index {boolean.OpIndex} uses unsupported follow-on tool kind '{boolean.Tool.OpName}' after safe subtract composition began; only nested 'cylinder' or 'cone' subtract tools are supported.");+ KernelDiagnosticCode.ValidationFailed,+ $"Boolean feature '{boolean.FeatureId}' (subtract) uses unsupported follow-on tool kind '{boolean.Tool.OpName}' after safe subtract composition began on '{boolean.PrimaryReferenceFeatureId}'. Only nested cylinder or cone through-hole tools are supported in that chain.",+ "firmament.feature-graph.unsupported-follow-on-kind");}return ValidateSupportedSafeSubtract(boolean, executionBodiesByFeatureId, tolerance);@@ -59,7 +63,9 @@ internal static class FirmamentSafeSubtractFeatureGraphValidatorif (boolean.Kind == FirmamentLoweredBooleanKind.Subtract && usesSupportedSafeHoleTool){return Failure(- $"Boolean op '{boolean.FeatureId}' at index {boolean.OpIndex} violates safe subtract feature-graph ordering: nested 'cylinder'/'cone' through-hole composition can only start from a box or continue from a previously validated safe subtract result, but '{boolean.PrimaryReferenceFeatureId}' is outside that supported family.");+ KernelDiagnosticCode.ValidationFailed,+ $"Boolean feature '{boolean.FeatureId}' (subtract) cannot re-enter the safe subtract family from '{boolean.PrimaryReferenceFeatureId}'. Safe-hole composition may start only from a box root or continue from a previously validated safe subtract result.",+ "firmament.feature-graph.invalid-composition-order");}return KernelResult<FirmamentSafeSubtractFeatureGraphValidation>.Success(@@ -75,14 +81,16 @@ internal static class FirmamentSafeSubtractFeatureGraphValidator{if (!executionBodiesByFeatureId.TryGetValue(boolean.PrimaryReferenceFeatureId, out var leftBody)){- return Failure($"Boolean op '{boolean.FeatureId}' at index {boolean.OpIndex} could not resolve left feature '{boolean.PrimaryReferenceFeatureId}' for feature-graph validation.");+ return Failure(KernelDiagnosticCode.ValidationFailed, $"Boolean feature '{boolean.FeatureId}' ({boolean.Kind.ToString().ToLowerInvariant()}) could not resolve left feature '{boolean.PrimaryReferenceFeatureId}' for safe subtract feature-graph validation.", "firmament.feature-graph.unresolved-left");}var resolvedTolerance = tolerance ?? ToleranceContext.Default;if (!BrepBooleanSafeComposition.TryRecognize(leftBody, resolvedTolerance, out var composition, out _)){return Failure(- $"Boolean op '{boolean.FeatureId}' at index {boolean.OpIndex} violates safe subtract feature-graph ordering: left feature '{boolean.PrimaryReferenceFeatureId}' is not a recognized base box or previously validated safe subtract composition.");+ KernelDiagnosticCode.ValidationFailed,+ $"Boolean feature '{boolean.FeatureId}' (subtract) cannot use '{boolean.PrimaryReferenceFeatureId}' as a safe subtract input because that earlier result is not a recognized base box or previously validated safe-hole composition.",+ "firmament.feature-graph.invalid-composition-order");}var toolBodyResult = FirmamentBooleanToolBodyFactory.CreateBody(boolean.Tool);@@ -94,7 +102,9 @@ internal static class FirmamentSafeSubtractFeatureGraphValidatorif (!BrepBooleanAnalyticSurfaceRecognition.TryRecognizeAnalyticSurface(toolBodyResult.Value, resolvedTolerance, out var analyticSurface, out var reason)){return Failure(- $"Boolean op '{boolean.FeatureId}' at index {boolean.OpIndex} could not recognize nested tool op '{boolean.Tool.OpName}' as an analytic hole candidate for safe subtract feature-graph validation ({reason}).");+ KernelDiagnosticCode.ValidationFailed,+ $"Boolean feature '{boolean.FeatureId}' (subtract) could not recognize nested tool op '{boolean.Tool.OpName}' as an analytic through-hole candidate for safe subtract validation ({reason}).",+ "firmament.feature-graph.unrecognized-analytic-hole");}if (!BrepBooleanSafeCompositionGraphValidator.TryValidateNextSubtract(@@ -102,7 +112,8 @@ internal static class FirmamentSafeSubtractFeatureGraphValidatoranalyticSurface,resolvedTolerance,out _,- out var diagnostic))+ out var diagnostic,+ boolean.FeatureId)){return KernelResult<FirmamentSafeSubtractFeatureGraphValidation>.Failure([diagnostic!.ToKernelDiagnostic()]);}@@ -117,14 +128,14 @@ internal static class FirmamentSafeSubtractFeatureGraphValidator=> string.Equals(tool.OpName, "cylinder", StringComparison.Ordinal)|| string.Equals(tool.OpName, "cone", StringComparison.Ordinal);- private static KernelResult<FirmamentSafeSubtractFeatureGraphValidation> Failure(string message)+ private static KernelResult<FirmamentSafeSubtractFeatureGraphValidation> Failure(KernelDiagnosticCode code, string message, string source)=> KernelResult<FirmamentSafeSubtractFeatureGraphValidation>.Failure([new KernelDiagnostic(- KernelDiagnosticCode.NotImplemented,+ code,KernelDiagnosticSeverity.Error,message,- Source: "firmament.feature-graph")+ Source: source)]);}