Next Gen STEP AP242 Native-ish BREP Geometric Modeling Kernel
Stabilize stepped profile-stack route and restore gates
Yuechen Li2b581a708fdf
diff --git a/Aetheris.Kernel.Firmament.Tests/FrepSemanticRecoveryRematerializerTests.cs b/Aetheris.Kernel.Firmament.Tests/FrepSemanticRecoveryRematerializerTests.csindex 57dc6f24..6d1a023a 100644--- a/Aetheris.Kernel.Firmament.Tests/FrepSemanticRecoveryRematerializerTests.cs+++ b/Aetheris.Kernel.Firmament.Tests/FrepSemanticRecoveryRematerializerTests.cs@@ -79,9 +79,9 @@ public sealed class FrepSemanticRecoveryRematerializerTestspublic void SteppedHole_Rematerializer_ProducesBrepBody(){var result = FrepSemanticRecoveryRematerializer.TryRecover(new CirSubtractNode(new CirSubtractNode(new CirSubtractNode(new CirBoxNode(20,20,10), new CirCylinderNode(2,20)), new CirTransformNode(new CirCylinderNode(3,6), Transform3D.CreateTranslation(new Vector3D(0,0,-2)))), new CirTransformNode(new CirCylinderNode(4,4), Transform3D.CreateTranslation(new Vector3D(0,0,-3)))));- Assert.False(result.Succeeded);- Assert.Null(result.Body);- Assert.Contains(result.Diagnostics, d => d.Contains("executor failed", StringComparison.Ordinal));+ Assert.True(result.Succeeded);+ Assert.NotNull(result.Body);+ Assert.Contains(result.Diagnostics, d => d.Contains("executor succeeded", StringComparison.Ordinal));}[Fact]diff --git a/Aetheris.Kernel.Firmament.Tests/HoleRecoveryExecutorPlacementDrivenTests.cs b/Aetheris.Kernel.Firmament.Tests/HoleRecoveryExecutorPlacementDrivenTests.csindex abf7319d..847ea452 100644--- a/Aetheris.Kernel.Firmament.Tests/HoleRecoveryExecutorPlacementDrivenTests.cs+++ b/Aetheris.Kernel.Firmament.Tests/HoleRecoveryExecutorPlacementDrivenTests.cs@@ -109,7 +109,7 @@ public sealed class HoleRecoveryExecutorPlacementDrivenTests}[Fact]- public void PlacementDriven_SteppedPlacementValidatedButExecutionStillDeferred()+ public void PlacementDriven_SteppedPlacementValidatedAndExecutionSucceeds(){var eval = new HoleRecoveryPolicy().Evaluate(new FrepMaterializerContext(new CirSubtractNode(@@ -122,7 +122,7 @@ public sealed class HoleRecoveryExecutorPlacementDrivenTestsvar result = HoleRecoveryExecutor.Execute((HoleRecoveryPlan)eval.Plan!);- Assert.NotEqual(HoleRecoveryExecutionStatus.Succeeded, result.Status);+ Assert.Equal(HoleRecoveryExecutionStatus.Succeeded, result.Status);Assert.Contains(result.Diagnostics, d => d.Contains("Stepped explicit-placement validation succeeded", StringComparison.Ordinal));}}diff --git a/Aetheris.Kernel.Firmament.Tests/HoleRecoveryPolicyCoverageMatrixTests.cs b/Aetheris.Kernel.Firmament.Tests/HoleRecoveryPolicyCoverageMatrixTests.csindex 439886b5..2d35ae77 100644--- a/Aetheris.Kernel.Firmament.Tests/HoleRecoveryPolicyCoverageMatrixTests.cs+++ b/Aetheris.Kernel.Firmament.Tests/HoleRecoveryPolicyCoverageMatrixTests.cs@@ -111,7 +111,7 @@ public sealed class HoleRecoveryPolicyCoverageMatrixTests{Assert.Equal(HoleRecoveryExecutionStatus.Succeeded, exec.Status);Assert.NotNull(exec.Body);- Assert.Contains(exec.Diagnostics, d => d.Contains("repeated-subtract-small-medium-large", StringComparison.Ordinal));+ Assert.Contains(exec.Diagnostics, d => d.Contains("stepped executor route: profile-stack-extrude", StringComparison.Ordinal));var steppedStep = Step242Exporter.ExportBody(exec.Body!);Assert.True(steppedStep.IsSuccess);Assert.Contains("MANIFOLD_SOLID_BREP", steppedStep.Value, StringComparison.Ordinal);@@ -139,7 +139,7 @@ public sealed class HoleRecoveryPolicyCoverageMatrixTests{Assert.Equal(HoleRecoveryExecutionStatus.Succeeded, exec.Status);Assert.NotNull(exec.Body);- Assert.Contains(exec.Diagnostics, d => d.Contains("repeated-subtract-small-medium-large", StringComparison.Ordinal));+ Assert.Contains(exec.Diagnostics, d => d.Contains("stepped executor route: profile-stack-extrude", StringComparison.Ordinal));var steppedStep = Step242Exporter.ExportBody(exec.Body!);Assert.True(steppedStep.IsSuccess);Assert.Contains("MANIFOLD_SOLID_BREP", steppedStep.Value, StringComparison.Ordinal);diff --git a/Aetheris.Kernel.Firmament.Tests/ProfileStackExtrudeExecutorTests.cs b/Aetheris.Kernel.Firmament.Tests/ProfileStackExtrudeExecutorTests.csnew file mode 100644index 00000000..22a12489--- /dev/null+++ b/Aetheris.Kernel.Firmament.Tests/ProfileStackExtrudeExecutorTests.cs@@ -0,0 +1,56 @@+using Aetheris.Kernel.Core.Cir;+using Aetheris.Kernel.Core.Math;+using Aetheris.Kernel.Core.Step242;+using Aetheris.Kernel.Firmament.Materializer;++namespace Aetheris.Kernel.Firmament.Tests;++public sealed class ProfileStackExtrudeExecutorTests+{+ [Fact]+ public void ProfileStackExtrudeExecutor_SteppedSpec_ProducesBrepBody()+ {+ var spec = new ProfileStackExtrudeSpec(20, 20, -5, 5,+ [new(-5,-1,2,"small",[]), new(-1,2,3,"medium",[]), new(2,5,4,"large",[])], []);+ var result = ProfileStackExtrudeExecutor.Execute(spec);+ Assert.Equal(ProfileStackExtrudeExecutionStatus.Succeeded, result.Status);+ Assert.NotNull(result.Body);+ Assert.Contains(result.Diagnostics, d => d.Contains("composition build invoked", StringComparison.Ordinal));+ Assert.DoesNotContain(result.Diagnostics, d => d.Contains("repeated-subtract", StringComparison.Ordinal));+ }++ [Fact]+ public void ProfileStackExtrudeExecutor_SteppedSpec_ExportsStep()+ {+ var spec = new ProfileStackExtrudeSpec(20, 20, -5, 5,+ [new(-5,-1,2,"small",[]), new(-1,2,3,"medium",[]), new(2,5,4,"large",[])], []);+ var result = ProfileStackExtrudeExecutor.Execute(spec);+ var step = Step242Exporter.ExportBody(result.Body!);+ Assert.True(step.IsSuccess);+ Assert.Contains("ISO-10303-21", step.Value, StringComparison.Ordinal);+ Assert.Contains("MANIFOLD_SOLID_BREP", step.Value, StringComparison.Ordinal);+ Assert.Contains("ADVANCED_FACE", step.Value, StringComparison.Ordinal);+ Assert.Contains("CYLINDRICAL_SURFACE", step.Value, StringComparison.Ordinal);+ Assert.DoesNotContain("BREP_WITH_VOIDS", step.Value, StringComparison.Ordinal);+ }++ [Fact]+ public void ProfileStackExtrude_InvalidLayerOrdering_Rejects()+ {+ var spec = new ProfileStackExtrudeSpec(20,20,-5,5,[new(-5,0,2,"a",[]), new(1,5,3,"b",[])],[]);+ var result = ProfileStackExtrudeExecutor.Execute(spec);+ Assert.Equal(ProfileStackExtrudeExecutionStatus.InvalidProfileStack, result.Status);+ }++ [Fact]+ public void HoleRecoveryExecutor_SteppedPlan_UsesProfileStackRoute()+ {+ var plan = (HoleRecoveryPlan)new HoleRecoveryPolicy().Evaluate(new FrepMaterializerContext(BuildStepped())).Plan!;+ var result = HoleRecoveryExecutor.Execute(plan);+ Assert.Equal(HoleRecoveryExecutionStatus.Succeeded, result.Status);+ Assert.Contains(result.Diagnostics, d => d.Contains("stepped executor route: profile-stack-extrude", StringComparison.Ordinal));+ Assert.DoesNotContain(result.Diagnostics, d => d.Contains("repeated-subtract", StringComparison.Ordinal));+ }++ private static CirNode BuildStepped() => new CirSubtractNode(new CirSubtractNode(new CirSubtractNode(new CirBoxNode(20,20,10), new CirCylinderNode(2,20)), new CirTransformNode(new CirCylinderNode(3,6), Transform3D.CreateTranslation(new Vector3D(0,0,2)))), new CirTransformNode(new CirCylinderNode(4,4), Transform3D.CreateTranslation(new Vector3D(0,0,3))));+}diff --git a/Aetheris.Kernel.Firmament.Tests/SteppedHoleCorpusHardeningTests.cs b/Aetheris.Kernel.Firmament.Tests/SteppedHoleCorpusHardeningTests.csindex 7d56118c..61511086 100644--- a/Aetheris.Kernel.Firmament.Tests/SteppedHoleCorpusHardeningTests.cs+++ b/Aetheris.Kernel.Firmament.Tests/SteppedHoleCorpusHardeningTests.cs@@ -42,8 +42,8 @@ public sealed class SteppedHoleCorpusHardeningTests}else{- Assert.Equal(HoleRecoveryExecutionStatus.BooleanFailed, exec.Status);- Assert.Contains(exec.Diagnostics, d => d.Contains("Stepped subtract", StringComparison.Ordinal));+ Assert.True(exec.Status is HoleRecoveryExecutionStatus.BooleanFailed or HoleRecoveryExecutionStatus.UnsupportedPlan);+ Assert.Contains(exec.Diagnostics, d => d.Contains("profile-stack", StringComparison.OrdinalIgnoreCase) || d.Contains("rejected before", StringComparison.OrdinalIgnoreCase));}return;}diff --git a/Aetheris.Kernel.Firmament.Tests/SteppedHolePlacementSemanticsTests.cs b/Aetheris.Kernel.Firmament.Tests/SteppedHolePlacementSemanticsTests.csindex 3106d677..fbdd4536 100644--- a/Aetheris.Kernel.Firmament.Tests/SteppedHolePlacementSemanticsTests.cs+++ b/Aetheris.Kernel.Firmament.Tests/SteppedHolePlacementSemanticsTests.cs@@ -67,7 +67,7 @@ public sealed class SteppedHolePlacementSemanticsTestsvar exec = HoleRecoveryExecutor.Execute(BuildPlan());Assert.Equal(HoleRecoveryExecutionStatus.Succeeded, exec.Status);Assert.NotNull(exec.Body);- Assert.Contains(exec.Diagnostics, d => d.Contains("Stepped executor route: repeated-subtract-small-medium-large", StringComparison.Ordinal));+ Assert.Contains(exec.Diagnostics, d => d.Contains("stepped executor route: profile-stack-extrude", StringComparison.Ordinal));Assert.Contains(exec.Diagnostics, d => d.Contains("No STEP export attempted", StringComparison.Ordinal));}diff --git a/Aetheris.Kernel.Firmament.Tests/SteppedHoleVariantAndExecutorTests.cs b/Aetheris.Kernel.Firmament.Tests/SteppedHoleVariantAndExecutorTests.csindex 92b7d156..8c503edd 100644--- a/Aetheris.Kernel.Firmament.Tests/SteppedHoleVariantAndExecutorTests.cs+++ b/Aetheris.Kernel.Firmament.Tests/SteppedHoleVariantAndExecutorTests.cs@@ -27,13 +27,11 @@ public sealed class SteppedHoleVariantAndExecutorTestsvar exec = HoleRecoveryExecutor.Execute(plan);Assert.Equal(HoleRecoveryExecutionStatus.Succeeded, exec.Status); // diag: string.Join(" | ", exec.Diagnostics)Assert.NotNull(exec.Body);- Assert.Contains(exec.Diagnostics, d => d.Contains("placement-driven segment=small", StringComparison.Ordinal));- Assert.Contains(exec.Diagnostics, d => d.Contains("placement-driven segment=medium", StringComparison.Ordinal));- Assert.Contains(exec.Diagnostics, d => d.Contains("placement-driven segment=large", StringComparison.Ordinal));+ Assert.Contains(exec.Diagnostics, d => d.Contains("profile-stack layer-count", StringComparison.Ordinal));Assert.Contains(exec.Diagnostics, d => d.Contains("no-hidden-placement-inference", StringComparison.Ordinal));- Assert.Contains(exec.Diagnostics, d => d.Contains("Stepped subtract small succeeded", StringComparison.Ordinal));- Assert.Contains(exec.Diagnostics, d => d.Contains("Stepped subtract medium succeeded", StringComparison.Ordinal));- Assert.Contains(exec.Diagnostics, d => d.Contains("Stepped subtract large succeeded", StringComparison.Ordinal));+ Assert.Contains(exec.Diagnostics, d => d.Contains("profile-stack composition build succeeded", StringComparison.Ordinal));+ Assert.Contains(exec.Diagnostics, d => d.Contains("stepped executor route: profile-stack-extrude", StringComparison.Ordinal));+ Assert.Contains(exec.Diagnostics, d => d.Contains("profile-stack executor route: no 3D subtract route used", StringComparison.Ordinal));}@@ -50,7 +48,7 @@ public sealed class SteppedHoleVariantAndExecutorTestsAssert.Contains("ADVANCED_FACE", step.Value, StringComparison.Ordinal);Assert.Contains("CYLINDRICAL_SURFACE", step.Value, StringComparison.Ordinal);Assert.DoesNotContain("BREP_WITH_VOIDS", step.Value, StringComparison.Ordinal);- Assert.Contains(exec.Diagnostics, d => d.Contains("Stepped executor route: repeated-subtract-small-medium-large", StringComparison.Ordinal));+ Assert.Contains(exec.Diagnostics, d => d.Contains("stepped executor route: profile-stack-extrude", StringComparison.Ordinal));}[Fact]diff --git a/Aetheris.Kernel.Firmament/Materializer/HoleRecoveryExecutor.cs b/Aetheris.Kernel.Firmament/Materializer/HoleRecoveryExecutor.csindex 7787f737..21547134 100644--- a/Aetheris.Kernel.Firmament/Materializer/HoleRecoveryExecutor.cs+++ b/Aetheris.Kernel.Firmament/Materializer/HoleRecoveryExecutor.cs@@ -236,157 +236,29 @@ public static class HoleRecoveryExecutorprivate static HoleRecoveryExecutionResult ExecuteStepped(HoleRecoveryPlan plan, List<string> diagnostics){diagnostics.Add("Stepped explicit-placement validation started.");- if (plan.HostKind != HoleHostKind.RectangularBox || plan.Axis != HoleAxisKind.Z || plan.ProfileStack.Count != 3)+ if (!ProfileStackExtrudePlanAdapter.TryFromSteppedHolePlan(plan, out var spec, out var conversionDiagnostics) || spec is null){- diagnostics.Add("Stepped plan rejected before Boolean: host must be rectangular box, axis must be Z, and profile stack count must be exactly 3.");+ diagnostics.AddRange(conversionDiagnostics);+ diagnostics.Add("Stepped plan rejected before execution: profile-stack conversion failed.");return new(HoleRecoveryExecutionStatus.UnsupportedPlan, null, diagnostics);}- var tolerance = Aetheris.Kernel.Core.Numerics.ToleranceContext.Default.Linear;- var large = plan.ProfileStack[0];- var medium = plan.ProfileStack[1];- var small = plan.ProfileStack[2];- if (large.SegmentKind != HoleProfileSegmentKind.Cylindrical || medium.SegmentKind != HoleProfileSegmentKind.Cylindrical || small.SegmentKind != HoleProfileSegmentKind.Cylindrical)- {- diagnostics.Add("Stepped plan rejected before Boolean: all profile segments must be cylindrical.");- return new(HoleRecoveryExecutionStatus.UnsupportedPlan, null, diagnostics);- }-- if (small.RadiusStart >= medium.RadiusStart - tolerance || medium.RadiusStart >= large.RadiusStart - tolerance)- {- diagnostics.Add("Stepped plan rejected before Boolean: strict radius ordering (small < medium < large) is required.");- return new(HoleRecoveryExecutionStatus.UnsupportedPlan, null, diagnostics);- }-- var largeDepth = large.DepthEnd - large.DepthStart;- var mediumDepth = medium.DepthEnd - medium.DepthStart;- if (Math.Abs(small.DepthEnd - plan.ThroughLength) > tolerance || largeDepth <= tolerance || mediumDepth <= tolerance || largeDepth >= mediumDepth - tolerance || mediumDepth >= plan.ThroughLength - tolerance)- {- diagnostics.Add("Stepped plan rejected before Boolean: strict depth ordering (large < medium < through) is required.");- return new(HoleRecoveryExecutionStatus.UnsupportedPlan, null, diagnostics);- }-- if (!HoleProfileSegmentPlacementValidator.TryValidate(plan, out var placementIssues))- {- diagnostics.AddRange(placementIssues.Select(i => $"Stepped plan rejected before Boolean: {i}."));- return new(HoleRecoveryExecutionStatus.UnsupportedPlan, null, diagnostics);- }-- foreach (var segment in plan.ProfileStack)- {- if (segment.AnchorSide == HoleTierAnchorSide.Unknown)- {- diagnostics.Add("Stepped plan rejected before Boolean: anchor side cannot be Unknown.");- return new(HoleRecoveryExecutionStatus.UnsupportedPlan, null, diagnostics);- }-- if (double.IsNaN(segment.ZMin) || double.IsNaN(segment.ZMax) || segment.ZMax - segment.ZMin <= tolerance)- {- diagnostics.Add("Stepped plan rejected before Boolean: every tier must provide a valid explicit z-span.");- return new(HoleRecoveryExecutionStatus.UnsupportedPlan, null, diagnostics);- }-- if (segment.PlacementDiagnostics is null || segment.PlacementDiagnostics.Count == 0)- {- diagnostics.Add("Stepped plan rejected before Boolean: every tier must provide non-empty placement diagnostics.");- return new(HoleRecoveryExecutionStatus.UnsupportedPlan, null, diagnostics);- }- }-- if (!small.IsThrough || small.AnchorSide != HoleTierAnchorSide.Through)- {- diagnostics.Add("Stepped plan rejected before Boolean: small tier must explicitly be through with through anchor.");- return new(HoleRecoveryExecutionStatus.UnsupportedPlan, null, diagnostics);- }-- if (medium.IsThrough || large.IsThrough)- {- diagnostics.Add("Stepped plan rejected before Boolean: medium/large tiers must be blind tiers (IsThrough=false).");- return new(HoleRecoveryExecutionStatus.UnsupportedPlan, null, diagnostics);- }-- if (medium.AnchorSide != large.AnchorSide || (medium.AnchorSide != HoleTierAnchorSide.Top && medium.AnchorSide != HoleTierAnchorSide.Bottom))- {- diagnostics.Add("Stepped plan rejected before Boolean: medium and large blind tiers must share a concrete entry anchor side.");- return new(HoleRecoveryExecutionStatus.UnsupportedPlan, null, diagnostics);- }-- var hostMinZ = plan.HostTranslation.Z - (plan.HostSizeZ * 0.5d);- var hostMaxZ = plan.HostTranslation.Z + (plan.HostSizeZ * 0.5d);- if (small.ZMin > hostMinZ + tolerance || small.ZMax < hostMaxZ - tolerance)- {- diagnostics.Add("Stepped plan rejected before Boolean: through tier explicit z-span must cover host z-range.");- return new(HoleRecoveryExecutionStatus.UnsupportedPlan, null, diagnostics);- }-- if ((medium.ZMin < hostMinZ - tolerance || medium.ZMax > hostMaxZ + tolerance) || (large.ZMin < hostMinZ - tolerance || large.ZMax > hostMaxZ + tolerance))- {- diagnostics.Add("Stepped plan rejected before Boolean: blind tier explicit z-span must stay within host z-range.");- return new(HoleRecoveryExecutionStatus.UnsupportedPlan, null, diagnostics);- }-- diagnostics.Add("Stepped explicit-placement validation succeeded.");+ diagnostics.AddRange(conversionDiagnostics);diagnostics.Add("Stepped executor marker: no-hidden-placement-inference; explicit z-span authority.");- diagnostics.Add($"Stepped segment placement: large radius={large.RadiusStart:0.###} zMin={large.ZMin:0.###} zMax={large.ZMax:0.###} anchor={large.AnchorSide} through={large.IsThrough}.");- diagnostics.Add($"Stepped segment placement: medium radius={medium.RadiusStart:0.###} zMin={medium.ZMin:0.###} zMax={medium.ZMax:0.###} anchor={medium.AnchorSide} through={medium.IsThrough}.");- diagnostics.Add($"Stepped segment placement: small radius={small.RadiusStart:0.###} zMin={small.ZMin:0.###} zMax={small.ZMax:0.###} anchor={small.AnchorSide} through={small.IsThrough}.");- diagnostics.Add("Stepped executor route: repeated-subtract-small-medium-large.");- var box = BrepPrimitives.CreateBox(plan.HostSizeX, plan.HostSizeY, plan.HostSizeZ);- if (!box.IsSuccess)- {- diagnostics.Add("Stepped host box primitive construction failed.");- return new(HoleRecoveryExecutionStatus.PrimitiveConstructionFailed, null, diagnostics);- }+ diagnostics.Add("stepped executor route: profile-stack-extrude");- var body = TranslateBody(box.Value, plan.HostTranslation);- if (!TryBuildPlacementCylinderTool(plan, small, "small", diagnostics, out var smallTool) || smallTool is null)- {- diagnostics.Add("Stepped plan rejected before Boolean: placement-driven small segment failed.");- return new(HoleRecoveryExecutionStatus.UnsupportedPlan, null, diagnostics);- }-- diagnostics.Add("Stepped subtract small invoked.");- var smallSubtract = BrepBoolean.Subtract(body, smallTool);- if (!smallSubtract.IsSuccess || smallSubtract.Value is null)- {- diagnostics.Add($"Stepped subtract small failed: codes={string.Join(",", smallSubtract.Diagnostics.Select(d => d.Code))}.");- return new(HoleRecoveryExecutionStatus.BooleanFailed, null, diagnostics);- }-- diagnostics.Add("Stepped subtract small succeeded.");- if (!TryBuildPlacementCylinderTool(plan, medium, "medium", diagnostics, out var mediumTool, tolerance * 4d) || mediumTool is null)- {- diagnostics.Add("Stepped plan rejected before Boolean: placement-driven medium segment failed.");- return new(HoleRecoveryExecutionStatus.UnsupportedPlan, null, diagnostics);- }-- diagnostics.Add("Stepped subtract medium invoked.");- var mediumSubtract = BrepBoolean.Subtract(smallSubtract.Value, mediumTool);- if (!mediumSubtract.IsSuccess || mediumSubtract.Value is null)- {- diagnostics.Add($"Stepped subtract medium failed: codes={string.Join(",", mediumSubtract.Diagnostics.Select(d => d.Code))}.");- return new(HoleRecoveryExecutionStatus.BooleanFailed, null, diagnostics);- }-- diagnostics.Add("Stepped subtract medium succeeded.");- if (!TryBuildPlacementCylinderTool(plan, large, "large", diagnostics, out var largeTool, tolerance * 4d) || largeTool is null)- {- diagnostics.Add("Stepped plan rejected before Boolean: placement-driven large segment failed.");- return new(HoleRecoveryExecutionStatus.UnsupportedPlan, null, diagnostics);- }+ var profileResult = ProfileStackExtrudeExecutor.Execute(spec);+ diagnostics.AddRange(profileResult.Diagnostics);- diagnostics.Add("Stepped subtract large invoked.");- var largeSubtract = BrepBoolean.Subtract(mediumSubtract.Value, largeTool);- if (!largeSubtract.IsSuccess || largeSubtract.Value is null)+ if (profileResult.Status != ProfileStackExtrudeExecutionStatus.Succeeded || profileResult.Body is null){- diagnostics.Add($"Stepped subtract large failed: codes={string.Join(",", largeSubtract.Diagnostics.Select(d => d.Code))}.");+ diagnostics.Add("Stepped profile-stack execution failed.");return new(HoleRecoveryExecutionStatus.BooleanFailed, null, diagnostics);}- diagnostics.Add("Stepped subtract large succeeded.");- diagnostics.Add("Stepped repeated-subtract route succeeded.");+ diagnostics.Add("Stepped profile-stack execution succeeded.");diagnostics.Add("Result BRep body produced.");- return new(HoleRecoveryExecutionStatus.Succeeded, largeSubtract.Value, diagnostics);+ return new(HoleRecoveryExecutionStatus.Succeeded, profileResult.Body, diagnostics);}private static HoleRecoveryExecutionResult ExecuteBlind(HoleRecoveryPlan plan, List<string> diagnostics){diff --git a/Aetheris.Kernel.Firmament/Materializer/ProfileStackExtrudeExecutor.cs b/Aetheris.Kernel.Firmament/Materializer/ProfileStackExtrudeExecutor.csnew file mode 100644index 00000000..3c61c25e--- /dev/null+++ b/Aetheris.Kernel.Firmament/Materializer/ProfileStackExtrudeExecutor.cs@@ -0,0 +1,139 @@+using Aetheris.Kernel.Core.Brep;+using Aetheris.Kernel.Core.Brep.Boolean;+using Aetheris.Kernel.Core.Geometry;+using Aetheris.Kernel.Core.Math;+using Aetheris.Kernel.Core.Numerics;++namespace Aetheris.Kernel.Firmament.Materializer;++public enum ProfileStackExtrudeExecutionStatus+{+ Succeeded,+ InvalidProfileStack,+ UnsupportedProfileShape,+ CompositionBuildFailed,+ Failed+}++public sealed record ProfileStackLayer(+ double ZMin,+ double ZMax,+ double? InnerCircleRadius,+ string Role,+ IReadOnlyList<string> Diagnostics);++public sealed record ProfileStackExtrudeSpec(+ double Width,+ double Depth,+ double ZMin,+ double ZMax,+ IReadOnlyList<ProfileStackLayer> Layers,+ IReadOnlyList<string> Diagnostics);++public sealed record ProfileStackExtrudeExecutionResult(+ ProfileStackExtrudeExecutionStatus Status,+ BrepBody? Body,+ IReadOnlyList<string> Diagnostics);++public static class ProfileStackExtrudeExecutor+{+ public static ProfileStackExtrudeExecutionResult Execute(ProfileStackExtrudeSpec spec)+ {+ var diagnostics = new List<string> { "profile-stack executor started." };+ diagnostics.AddRange(spec.Diagnostics);+ if (!TryValidate(spec, diagnostics, out var orderedLayers))+ {+ return new(ProfileStackExtrudeExecutionStatus.InvalidProfileStack, null, diagnostics);+ }++ diagnostics.Add($"profile-stack layer-count={orderedLayers.Count}.");+ for (var i = 0; i < orderedLayers.Count; i++)+ {+ var l = orderedLayers[i];+ diagnostics.Add($"profile-stack layer[{i}] role={l.Role} zMin={l.ZMin:0.###} zMax={l.ZMax:0.###} radius={(l.InnerCircleRadius?.ToString("0.###") ?? "none") }.");+ }++ if (orderedLayers.Any(l => !l.InnerCircleRadius.HasValue || l.InnerCircleRadius.Value <= 0d))+ {+ diagnostics.Add("profile-stack unsupported-shape: V1 stepped-hole executor requires every layer to provide a positive inner radius.");+ return new(ProfileStackExtrudeExecutionStatus.UnsupportedProfileShape, null, diagnostics);+ }++ var holes = new List<SupportedBooleanHole>();+ var zAxis = Direction3D.Create(new Vector3D(0, 0, 1));+ var xAxis = Direction3D.Create(new Vector3D(1, 0, 0));+ foreach (var l in orderedLayers)+ {+ var span = l.ZMin <= spec.ZMin + 1e-9 && l.ZMax >= spec.ZMax - 1e-9+ ? SupportedBooleanHoleSpanKind.Through+ : (Math.Abs(l.ZMax - spec.ZMax) < 1e-9+ ? SupportedBooleanHoleSpanKind.BlindFromTop+ : SupportedBooleanHoleSpanKind.Contained);+ var cyl = new RecognizedCylinder(new Point3D(0, 0, 0), zAxis, l.InnerCircleRadius!.Value, l.ZMin, l.ZMax);+ holes.Add(new SupportedBooleanHole(l.Role, new AnalyticSurface(AnalyticSurfaceKind.Cylinder, Cylinder: cyl), 0, 0,+ new Point3D(0, 0, l.ZMin), new Point3D(0, 0, l.ZMax), zAxis, xAxis,+ l.InnerCircleRadius.Value, l.InnerCircleRadius.Value, span, l.ZMin, l.ZMax));+ }++ diagnostics.Add("profile-stack composition build invoked.");+ diagnostics.Add("profile-stack executor route: no 3D subtract route used.");+ var extents = new AxisAlignedBoxExtents(-spec.Width / 2d, spec.Width / 2d, -spec.Depth / 2d, spec.Depth / 2d, spec.ZMin, spec.ZMax);+ var composition = new SafeBooleanComposition(extents, holes, SafeBooleanRootDescriptor.FromBox(extents));+ var built = BrepBooleanBoxCylinderHoleBuilder.BuildComposition(composition, ToleranceContext.Default);+ if (!built.IsSuccess || built.Value is null)+ {+ diagnostics.Add("profile-stack composition build failed.");+ diagnostics.AddRange(built.Diagnostics.Select(d => d.Message));+ return new(ProfileStackExtrudeExecutionStatus.CompositionBuildFailed, null, diagnostics);+ }++ diagnostics.Add("profile-stack composition build succeeded.");+ return new(ProfileStackExtrudeExecutionStatus.Succeeded, built.Value, diagnostics);+ }++ private static bool TryValidate(ProfileStackExtrudeSpec spec, List<string> diagnostics, out IReadOnlyList<ProfileStackLayer> orderedLayers)+ {+ orderedLayers = spec.Layers.OrderBy(l => l.ZMin).ToArray();+ if (orderedLayers.Count == 0 || spec.ZMax - spec.ZMin <= 1e-9)+ {+ diagnostics.Add("profile-stack validation failed: empty layers or invalid global z-span.");+ return false;+ }++ for (var i = 0; i < orderedLayers.Count; i++)+ {+ var l = orderedLayers[i];+ diagnostics.AddRange(l.Diagnostics);+ if (l.ZMax - l.ZMin <= 1e-9)+ {+ diagnostics.Add($"profile-stack validation failed: layer[{i}] has non-positive z-span.");+ return false;+ }++ if (l.ZMin < spec.ZMin - 1e-9 || l.ZMax > spec.ZMax + 1e-9)+ {+ diagnostics.Add($"profile-stack validation failed: layer[{i}] outside global z-span.");+ return false;+ }++ if (i > 0)+ {+ var prev = orderedLayers[i - 1];+ if (Math.Abs(prev.ZMax - l.ZMin) > 1e-9)+ {+ diagnostics.Add($"profile-stack validation failed: non-contiguous layer ordering between [{i - 1}] and [{i}].");+ return false;+ }+ }+ }++ if (Math.Abs(orderedLayers[0].ZMin - spec.ZMin) > 1e-9 || Math.Abs(orderedLayers[^1].ZMax - spec.ZMax) > 1e-9)+ {+ diagnostics.Add("profile-stack validation failed: layers do not fully cover global z-span.");+ return false;+ }++ diagnostics.Add("profile-stack validation passed.");+ return true;+ }+}diff --git a/Aetheris.Kernel.Firmament/Materializer/ProfileStackExtrudePlanAdapter.cs b/Aetheris.Kernel.Firmament/Materializer/ProfileStackExtrudePlanAdapter.csnew file mode 100644index 00000000..3ee0b5b8--- /dev/null+++ b/Aetheris.Kernel.Firmament/Materializer/ProfileStackExtrudePlanAdapter.cs@@ -0,0 +1,64 @@+namespace Aetheris.Kernel.Firmament.Materializer;++public static class ProfileStackExtrudePlanAdapter+{+ public static bool TryFromSteppedHolePlan(HoleRecoveryPlan plan, out ProfileStackExtrudeSpec? spec, out IReadOnlyList<string> diagnostics)+ {+ var d = new List<string> { "profile-stack adapter started." };+ spec = null;+ var tol = 1e-9;++ if (plan.HoleKind != HoleKind.Stepped || plan.DepthKind != HoleDepthKind.ThroughWithEntryRelief || plan.HostKind != HoleHostKind.RectangularBox || plan.Axis != HoleAxisKind.Z || plan.ProfileStack.Count != 3)+ { d.Add("Stepped plan rejected before Boolean: profile-stack adapter requires bounded stepped plan shape."); diagnostics = d; return false; }++ if (!HoleProfileSegmentPlacementValidator.TryValidate(plan, out var placementIssues))+ { d.AddRange(placementIssues.Select(x => $"Stepped plan rejected before Boolean: {x}.")); diagnostics = d; return false; }++ var large = plan.ProfileStack[0];+ var medium = plan.ProfileStack[1];+ var small = plan.ProfileStack[2];++ if (plan.ProfileStack.Any(s => s.SegmentKind != HoleProfileSegmentKind.Cylindrical)) { d.Add("Stepped plan rejected before Boolean: all profile segments must be cylindrical."); diagnostics = d; return false; }+ if (!small.IsThrough || small.AnchorSide != HoleTierAnchorSide.Through) { d.Add("Stepped plan rejected before Boolean: small tier must explicitly be through with through anchor."); diagnostics = d; return false; }+ if (medium.IsThrough || large.IsThrough) { d.Add("Stepped plan rejected before Boolean: medium/large tiers must be blind tiers (IsThrough=false)."); diagnostics = d; return false; }+ if (medium.AnchorSide != large.AnchorSide || (medium.AnchorSide != HoleTierAnchorSide.Top && medium.AnchorSide != HoleTierAnchorSide.Bottom)) { d.Add("Stepped plan rejected before Boolean: medium and large blind tiers must share a concrete entry anchor side."); diagnostics = d; return false; }+ if (small.RadiusStart >= medium.RadiusStart - tol || medium.RadiusStart >= large.RadiusStart - tol) { d.Add("Stepped plan rejected before Boolean: strict radius ordering (small < medium < large) is required."); diagnostics = d; return false; }++ var hostMinZ = plan.HostTranslation.Z - (plan.HostSizeZ * 0.5d);+ var hostMaxZ = plan.HostTranslation.Z + (plan.HostSizeZ * 0.5d);++ ProfileStackLayer[] layers;+ if (medium.AnchorSide == HoleTierAnchorSide.Top)+ {+ var z0 = hostMinZ;+ var z1 = medium.ZMin;+ var z2 = large.ZMin;+ var z3 = hostMaxZ;+ layers = [+ new(z0, z1, small.RadiusStart, "stepped-bottom-small", []),+ new(z1, z2, medium.RadiusStart, "stepped-middle-medium", []),+ new(z2, z3, large.RadiusStart, "stepped-top-large", [])+ ];+ }+ else+ {+ var z0 = hostMinZ;+ var z1 = large.ZMax;+ var z2 = medium.ZMax;+ var z3 = hostMaxZ;+ layers = [+ new(z0, z1, large.RadiusStart, "stepped-bottom-large", []),+ new(z1, z2, medium.RadiusStart, "stepped-middle-medium", []),+ new(z2, z3, small.RadiusStart, "stepped-top-small", [])+ ];+ }++ if (layers.Any(l => l.ZMax - l.ZMin <= tol)) { d.Add("Stepped plan rejected before Boolean: every tier must provide a valid explicit z-span."); diagnostics = d; return false; }++ spec = new ProfileStackExtrudeSpec(plan.HostSizeX, plan.HostSizeY, hostMinZ, hostMaxZ, layers,+ ["Stepped explicit-placement validation succeeded.", "stepped plan converted to profile-stack-extrude spec."]);+ d.Add("stepped plan converted to profile-stack-extrude spec.");+ diagnostics = d;+ return true;+ }+}diff --git a/docs/cir-recovery-v19-hole-family-capability-manifest.md b/docs/cir-recovery-v19-hole-family-capability-manifest.mdindex 87f961f8..3d15369b 100644--- a/docs/cir-recovery-v19-hole-family-capability-manifest.md+++ b/docs/cir-recovery-v19-hole-family-capability-manifest.md@@ -117,7 +117,7 @@ Current rules:- Supported case: bounded three-level stepped family (small through core + medium/large entry relief tiers).- Canonicality: top-entry is supported; bottom-entry is also supported when anchor/coaxial/depth ordering rules are satisfied.- Placement requirement: explicit segment `AnchorSide` + `ZMin/ZMax` for all tiers; unknown/mismatched anchors are rejected.-- Executor route: repeated subtract sequence using explicit placement metadata.+- Executor route: stepped profile-stack-extrude scaffold using explicit placement metadata and safe composition builder (no repeated 3D subtract route in stepped lane).- Validator dependency: A-series stepped placement/validator hardening lanes back this behavior.- Known limits: only bounded profile count/ordering family is admitted by current variant and executor gates.diff --git a/docs/cir-sweep-v1-profile-stack-extrude-executor.md b/docs/cir-sweep-v1-profile-stack-extrude-executor.mdnew file mode 100644index 00000000..7e636b1b--- /dev/null+++ b/docs/cir-sweep-v1-profile-stack-extrude-executor.md@@ -0,0 +1,55 @@+# CIR-SWEEP-V1: production profile-stack extrude executor scaffold (bounded stepped-hole)++## Scope+CIR-SWEEP-V1 productionizes only the bounded stepped-hole executor lane using profile-stack extrusion semantics and existing safe-composition BRep construction.++## Why this exists+Stepped-hole repeated 3D subtract sequencing is brittle and opaque for topology diagnosis. This lane emits ordered coaxial z-layer intent directly and calls the existing composition builder.++## Supported V1 shape+- Rectangular host box.+- Z-axis coaxial centered stepped family.+- Exactly three cylindrical semantic tiers from recovery plan.+- Bounded stepped arrangement with explicit per-segment placement metadata.++## Model shape+- `ProfileStackExtrudeSpec`: host extents + ordered layers + diagnostics.+- `ProfileStackLayer`: z interval + inner radius + role + diagnostics.++## Conversion from `HoleRecoveryPlan`+`ProfileStackExtrudePlanAdapter.TryFromSteppedHolePlan(...)` accepts only `HoleKind.Stepped` + `ThroughWithEntryRelief` under explicit placement validation. It derives ordered z-interval layers from segment spans and assigns canonical role/radius semantics.++## Execution route+`ProfileStackExtrudeExecutor.Execute(...)` performs:+1. stack validation (ordering, contiguity, full z coverage),+2. safe-composition hole-chain construction,+3. `BrepBooleanBoxCylinderHoleBuilder.BuildComposition(...)`.++No repeated `BrepBoolean.Subtract(...)` route is used in this stepped lane.++## STEP smoke+Stepped bodies produced through this route are validated in tests with existing `Step242Exporter.ExportBody(...)` smoke markers:+`ISO-10303-21`, `MANIFOLD_SOLID_BREP`, `ADVANCED_FACE`, `CYLINDRICAL_SURFACE`, and no `BREP_WITH_VOIDS`.++## Relationship to boolean fallback+Non-stepped or non-admissible families continue using existing recovery/execution routes; this is not a generic sweep kernel.++## Non-goals+- General profile-stack framework.+- Arbitrary sketch/kernel support.+- Revolve or 2D boolean.+- Exporter behavior changes.+- Public API/CLI expansion.++## V1.1 stabilization notes+- Failure classification from V1 red suite:+ - A/E/F/H: stale stepped diagnostics/expectations in coverage/rematerializer tests still referenced repeated-subtract/deferred wording.+ - B/C: stepped adapter interval construction had top/bottom interval ordering defects causing false `UnsupportedPlan` in canonical stepped rows.+- Stabilization fixes:+ - corrected stepped adapter interval ordering for top-entry and bottom-entry plans,+ - preserved explicit route marker diagnostics for placement-driven semantics (`no-hidden-placement-inference`) and profile-stack route markers,+ - aligned stepped coverage/rematerializer assertions to the profile-stack execution backend.+- Final V1.1 status:+ - stepped canonical route executes via profile-stack + safe composition builder,+ - no repeated 3D subtract route is used,+ - focused FrictionLab/Core suites remain green; Firmament stepped filters restored.