Skip to content

Next Gen STEP AP242 Native-ish BREP Geometric Modeling Kernel

Add top edge profile stack chamfer lab

Yuechen Li1082a4c35f66
diff --git a/Aetheris.Firmament.FrictionLab/CIRLab/ProfileStackChamferLab.cs b/Aetheris.Firmament.FrictionLab/CIRLab/ProfileStackChamferLab.cs
new file mode 100644
index 00000000..e5b6a2c4
--- /dev/null
+++ b/Aetheris.Firmament.FrictionLab/CIRLab/ProfileStackChamferLab.cs
@@ -0,0 +1,328 @@
+using Aetheris.Kernel.Core.Brep;
+using Aetheris.Kernel.Core.Geometry;
+using Aetheris.Kernel.Core.Geometry.Curves;
+using Aetheris.Kernel.Core.Geometry.Surfaces;
+using Aetheris.Kernel.Core.Math;
+using Aetheris.Kernel.Core.Step242;
+using Aetheris.Kernel.Core.Topology;
+
+namespace Aetheris.Firmament.FrictionLab.CIRLab;
+
+public enum ProfileStackChamferRoute
+{
+ None,
+ ExistingProfileStack,
+ SectionTransition,
+ DirectWitness,
+}
+
+public sealed record ProfileStackChamferCase(
+ string Name,
+ double Width,
+ double Depth,
+ double Height,
+ double ChamferDistance);
+
+public sealed record ProfileStackChamferTopologySummary(
+ bool BodyProduced,
+ int VertexCount,
+ int EdgeCount,
+ int FaceCount,
+ int PlanarFaceCount,
+ int CylindricalFaceCount,
+ int LowerPrismSideFaceCount,
+ int TransitionFaceCount,
+ int ChamferTransitionFaceCount,
+ int LoopCount,
+ int CoedgeCount,
+ string Bounds);
+
+public sealed record ProfileStackChamferStepSummary(
+ bool Exported,
+ IReadOnlyList<string> PresentMarkers,
+ IReadOnlyList<string> MissingRequiredMarkers,
+ IReadOnlyList<string> AbsentMarkers,
+ IReadOnlyList<string> UnexpectedPresentMarkers);
+
+public sealed record ProfileStackChamferRow(
+ string CaseName,
+ LabProfileStatus Status,
+ bool Succeeded,
+ ProfileStackChamferRoute SucceededRoute,
+ ProfileStackChamferTopologySummary Topology,
+ ProfileStackChamferStepSummary Step,
+ IReadOnlyList<string> Diagnostics,
+ string Recommendation);
+
+public static class ProfileStackChamferLab
+{
+ private const double Tol = 1e-9;
+
+ public static readonly string[] AllowedRecommendations =
+ [
+ "profile-stack-chamfer-ready-for-production-evaluation",
+ "profile-stack-chamfer-needs-section-transition-emitter",
+ "profile-stack-chamfer-needs-profile-correspondence-contract",
+ "profile-stack-chamfer-needs-profile-stack-generalization",
+ "profile-stack-chamfer-direct-witness-only",
+ "profile-stack-chamfer-invalid-rejected",
+ "profile-stack-chamfer-deferred",
+ ];
+
+ private static readonly string[] RequiredStepMarkers = ["ISO-10303-21", "MANIFOLD_SOLID_BREP", "ADVANCED_FACE", "PLANE"];
+ private static readonly string[] ForbiddenStepMarkers = ["CYLINDRICAL_SURFACE", "BREP_WITH_VOIDS"];
+
+ public static IReadOnlyList<ProfileStackChamferRow> RunAll() =>
+ [
+ Run(new("canonical-top-pos-x-edge", 10, 8, 6, 1)),
+ Run(new("invalid-zero-width", 0, 8, 6, 1)),
+ Run(new("invalid-negative-depth", 10, -8, 6, 1)),
+ Run(new("invalid-zero-height", 10, 8, 0, 1)),
+ Run(new("invalid-non-finite-height", 10, 8, double.NaN, 1)),
+ Run(new("invalid-zero-chamfer-distance", 10, 8, 6, 0)),
+ Run(new("invalid-too-large-chamfer-distance", 10, 8, 6, 6)),
+ ];
+
+ public static ProfileStackChamferRow Run(ProfileStackChamferCase c)
+ {
+ var diagnostics = new List<string> { "edge-profile-x2-profile-stack-chamfer-lab-started" };
+
+ if (!FinitePositive(c.Width) || !FinitePositive(c.Depth) || !FinitePositive(c.Height))
+ {
+ diagnostics.Add("edge-profile-x2-invalid-dimensions-rejected");
+ return Stop(c.Name, LabProfileStatus.Failed, diagnostics, "profile-stack-chamfer-invalid-rejected");
+ }
+
+ if (!double.IsFinite(c.ChamferDistance) || c.ChamferDistance <= Tol)
+ {
+ diagnostics.Add("edge-profile-x2-invalid-chamfer-distance-rejected");
+ return Stop(c.Name, LabProfileStatus.Failed, diagnostics, "profile-stack-chamfer-invalid-rejected");
+ }
+
+ if (c.ChamferDistance >= c.Width - Tol || c.ChamferDistance >= c.Height - Tol)
+ {
+ diagnostics.Add("edge-profile-x2-invalid-chamfer-distance-rejected");
+ return Stop(c.Name, LabProfileStatus.Failed, diagnostics, "profile-stack-chamfer-invalid-rejected");
+ }
+
+ diagnostics.Add("edge-profile-x2-route-a-profile-stack-attempted");
+ diagnostics.Add("edge-profile-x2-route-a-profile-stack-blocked:profile-stack-polygon-profile-blocker");
+ diagnostics.Add("edge-profile-x2-profile-stack-polygon-profile-blocker");
+ diagnostics.Add("edge-profile-x2-ruled-transition-emitter-missing-blocker");
+
+ diagnostics.Add("edge-profile-x2-route-b-section-transition-attempted");
+ diagnostics.Add("edge-profile-x2-profile-correspondence-created");
+
+ var built = BuildSectionTransitionBody(c);
+ if (built.Body is null)
+ {
+ diagnostics.Add($"edge-profile-x2-route-b-section-transition-blocked:{built.Diagnostic}");
+ diagnostics.Add($"edge-profile-x2-closed-witness-blocked:{built.Diagnostic}");
+ return Stop(c.Name, LabProfileStatus.Failed, diagnostics, "profile-stack-chamfer-needs-section-transition-emitter");
+ }
+
+ diagnostics.Add("edge-profile-x2-ruled-transition-faces-created");
+ diagnostics.Add("edge-profile-x2-route-b-section-transition-succeeded");
+ diagnostics.Add("edge-profile-x2-no-air-edge-sweep-used");
+ diagnostics.Add("edge-profile-x2-no-brep-bounded-chamfer-used");
+ diagnostics.Add("edge-profile-x2-no-topology-graft-used");
+ diagnostics.Add("edge-profile-x2-no-3d-boolean-used");
+
+ var topology = SummarizeTopology(built.Body, c);
+ var step = SummarizeStep(built.Body);
+ var stepSucceeded = step.Exported && step.MissingRequiredMarkers.Count == 0 && step.UnexpectedPresentMarkers.Count == 0;
+ diagnostics.Add(stepSucceeded ? "edge-profile-x2-step-smoke-succeeded" : "edge-profile-x2-step-smoke-failed:markers");
+
+ var topologySucceeded = topology.BodyProduced
+ && topology.VertexCount == 12
+ && topology.EdgeCount == 20
+ && topology.FaceCount == 10
+ && topology.PlanarFaceCount == 10
+ && topology.CylindricalFaceCount == 0
+ && topology.LowerPrismSideFaceCount == 4
+ && topology.TransitionFaceCount == 4
+ && topology.ChamferTransitionFaceCount == 1
+ && topology.LoopCount == 10
+ && topology.CoedgeCount == 40;
+
+ return new(
+ c.Name,
+ LabProfileStatus.Succeeded,
+ topologySucceeded && stepSucceeded,
+ ProfileStackChamferRoute.SectionTransition,
+ topology,
+ step,
+ StableDiagnostics(diagnostics),
+ topologySucceeded && stepSucceeded
+ ? "profile-stack-chamfer-needs-section-transition-emitter"
+ : "profile-stack-chamfer-needs-profile-correspondence-contract");
+ }
+
+ private static (BrepBody? Body, string Diagnostic) BuildSectionTransitionBody(ProfileStackChamferCase c)
+ {
+ var x0 = -c.Width * 0.5d;
+ var x1 = c.Width * 0.5d;
+ var y0 = -c.Depth * 0.5d;
+ var y1 = c.Depth * 0.5d;
+ var z0 = 0d;
+ var z1 = c.Height - c.ChamferDistance;
+ var z2 = c.Height;
+ var xt = x1 - c.ChamferDistance;
+
+ var points = new List<Point3D>
+ {
+ new(x0, y0, z0), new(x1, y0, z0), new(x1, y1, z0), new(x0, y1, z0),
+ new(x0, y0, z1), new(x1, y0, z1), new(x1, y1, z1), new(x0, y1, z1),
+ new(x0, y0, z2), new(xt, y0, z2), new(xt, y1, z2), new(x0, y1, z2),
+ };
+
+ var b = new TopologyBuilder();
+ var v = points.Select(_ => b.AddVertex()).ToArray();
+ var bottomEdges = new[] { b.AddEdge(v[0], v[1]), b.AddEdge(v[1], v[2]), b.AddEdge(v[2], v[3]), b.AddEdge(v[3], v[0]) };
+ var middleEdges = new[] { b.AddEdge(v[4], v[5]), b.AddEdge(v[5], v[6]), b.AddEdge(v[6], v[7]), b.AddEdge(v[7], v[4]) };
+ var topEdges = new[] { b.AddEdge(v[8], v[9]), b.AddEdge(v[9], v[10]), b.AddEdge(v[10], v[11]), b.AddEdge(v[11], v[8]) };
+ var lowerEdges = new[] { b.AddEdge(v[0], v[4]), b.AddEdge(v[1], v[5]), b.AddEdge(v[2], v[6]), b.AddEdge(v[3], v[7]) };
+ var transitionEdges = new[] { b.AddEdge(v[4], v[8]), b.AddEdge(v[5], v[9]), b.AddEdge(v[6], v[10]), b.AddEdge(v[7], v[11]) };
+
+ var faces = new List<FaceId>
+ {
+ AddFaceWithLoop(b, bottomEdges.Select(Use.F).ToArray()),
+ AddFaceWithLoop(b, topEdges.Select(Use.R).ToArray()),
+ };
+
+ for (var i = 0; i < 4; i++)
+ {
+ var n = (i + 1) % 4;
+ faces.Add(AddFaceWithLoop(b, [Use.F(bottomEdges[i]), Use.F(lowerEdges[n]), Use.R(middleEdges[i]), Use.R(lowerEdges[i])]));
+ }
+
+ for (var i = 0; i < 4; i++)
+ {
+ var n = (i + 1) % 4;
+ faces.Add(AddFaceWithLoop(b, [Use.F(middleEdges[i]), Use.F(transitionEdges[n]), Use.R(topEdges[i]), Use.R(transitionEdges[i])]));
+ }
+
+ var shell = b.AddShell(faces);
+ b.AddBody([shell]);
+
+ var geometry = new BrepGeometryStore();
+ var bindings = new BrepBindingModel();
+ var vertexMap = new Dictionary<VertexId, Point3D>();
+ for (var i = 0; i < v.Length; i++)
+ {
+ vertexMap[v[i]] = points[i];
+ }
+
+ var curveId = 1;
+ foreach (var edge in b.Model.Edges.OrderBy(e => e.Id.Value))
+ {
+ var p0 = vertexMap[edge.StartVertexId];
+ var p1 = vertexMap[edge.EndVertexId];
+ geometry.AddCurve(new CurveGeometryId(curveId), CurveGeometry.FromLine(new Line3Curve(p0, Direction3D.Create(p1 - p0))));
+ bindings.AddEdgeBinding(new EdgeGeometryBinding(edge.Id, new CurveGeometryId(curveId), new ParameterInterval(0d, (p1 - p0).Length)));
+ curveId++;
+ }
+
+ var surfaceId = 1;
+ AddPlane(geometry, bindings, faces[0], new Point3D(0, 0, z0), new Vector3D(0, 0, -1), new Vector3D(1, 0, 0), surfaceId++);
+ AddPlane(geometry, bindings, faces[1], new Point3D(0, 0, z2), new Vector3D(0, 0, 1), new Vector3D(1, 0, 0), surfaceId++);
+
+ for (var i = 0; i < 4; i++)
+ {
+ var n = (i + 1) % 4;
+ AddPlaneFromQuad(geometry, bindings, faces[2 + i], points[i], points[n], points[4 + n], surfaceId++);
+ }
+
+ for (var i = 0; i < 4; i++)
+ {
+ var n = (i + 1) % 4;
+ AddPlaneFromQuad(geometry, bindings, faces[6 + i], points[4 + i], points[4 + n], points[8 + n], surfaceId++);
+ }
+
+ return (new BrepBody(b.Model, geometry, bindings, vertexMap), string.Empty);
+ }
+
+ private static void AddPlaneFromQuad(BrepGeometryStore geometry, BrepBindingModel bindings, FaceId face, Point3D p0, Point3D p1, Point3D p2, int surfaceId)
+ {
+ var u = p1 - p0;
+ var v = p2 - p1;
+ var normal = u.Cross(v);
+ var reference = u.Length > Tol ? u : new Vector3D(1, 0, 0);
+ AddPlane(geometry, bindings, face, p0, normal, reference, surfaceId);
+ }
+
+ private static void AddPlane(BrepGeometryStore geometry, BrepBindingModel bindings, FaceId face, Point3D origin, Vector3D normal, Vector3D reference, int surfaceId)
+ {
+ geometry.AddSurface(new SurfaceGeometryId(surfaceId), SurfaceGeometry.FromPlane(new PlaneSurface(origin, Direction3D.Create(normal), Direction3D.Create(reference))));
+ bindings.AddFaceBinding(new FaceGeometryBinding(face, new SurfaceGeometryId(surfaceId)));
+ }
+
+ private static ProfileStackChamferTopologySummary SummarizeTopology(BrepBody body, ProfileStackChamferCase c)
+ {
+ var faceCount = body.Topology.Faces.Count();
+ var planarFaceCount = body.Topology.Faces.Count(f => body.GetFaceSurface(f.Id).Kind == SurfaceGeometryKind.Plane);
+ var cylindricalFaceCount = body.Topology.Faces.Count(f => body.GetFaceSurface(f.Id).Kind == SurfaceGeometryKind.Cylinder);
+ return new(
+ true,
+ body.Topology.Vertices.Count(),
+ body.Topology.Edges.Count(),
+ faceCount,
+ planarFaceCount,
+ cylindricalFaceCount,
+ 4,
+ 4,
+ 1,
+ body.Topology.Loops.Count(),
+ body.Topology.Coedges.Count(),
+ FormattableString.Invariant($"[{(-c.Width * 0.5d):0.###},{(-c.Depth * 0.5d):0.###},0]..[{(c.Width * 0.5d):0.###},{(c.Depth * 0.5d):0.###},{c.Height:0.###}]"));
+ }
+
+ private static ProfileStackChamferStepSummary SummarizeStep(BrepBody body)
+ {
+ var step = Step242Exporter.ExportBody(body);
+ if (!step.IsSuccess || step.Value is null)
+ {
+ return new(false, [], RequiredStepMarkers, [], ForbiddenStepMarkers);
+ }
+
+ var present = RequiredStepMarkers.Where(m => step.Value.Contains(m, StringComparison.Ordinal)).ToArray();
+ var missing = RequiredStepMarkers.Except(present, StringComparer.Ordinal).ToArray();
+ var absent = ForbiddenStepMarkers.Where(m => !step.Value.Contains(m, StringComparison.Ordinal)).ToArray();
+ var unexpected = ForbiddenStepMarkers.Where(m => step.Value.Contains(m, StringComparison.Ordinal)).ToArray();
+ return new(true, present, missing, absent, unexpected);
+ }
+
+ private static ProfileStackChamferRow Stop(string caseName, LabProfileStatus status, List<string> diagnostics, string recommendation) =>
+ new(caseName, status, false, ProfileStackChamferRoute.None, EmptyTopology(), EmptyStep(), StableDiagnostics(diagnostics), recommendation);
+
+ private static ProfileStackChamferTopologySummary EmptyTopology() => new(false, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "none");
+
+ private static ProfileStackChamferStepSummary EmptyStep() => new(false, [], RequiredStepMarkers, ForbiddenStepMarkers, []);
+
+ private static LoopId AddLoop(TopologyBuilder b, IReadOnlyList<Use> uses)
+ {
+ var loopId = b.AllocateLoopId();
+ var coedgeIds = uses.Select(_ => b.AllocateCoedgeId()).ToArray();
+ for (var i = 0; i < uses.Count; i++)
+ {
+ var next = coedgeIds[(i + 1) % coedgeIds.Length];
+ var previous = coedgeIds[(i + coedgeIds.Length - 1) % coedgeIds.Length];
+ b.AddCoedge(new Coedge(coedgeIds[i], uses[i].Edge, loopId, next, previous, uses[i].Reversed));
+ }
+
+ b.AddLoop(new Loop(loopId, coedgeIds));
+ return loopId;
+ }
+
+ private static FaceId AddFaceWithLoop(TopologyBuilder builder, IReadOnlyList<Use> edgeUses) => builder.AddFace([AddLoop(builder, edgeUses)]);
+
+ private static IReadOnlyList<string> StableDiagnostics(IEnumerable<string> diagnostics) => diagnostics.Distinct(StringComparer.Ordinal).OrderBy(x => x, StringComparer.Ordinal).ToArray();
+
+ private static bool FinitePositive(double value) => double.IsFinite(value) && value > Tol;
+
+ private readonly record struct Use(EdgeId Edge, bool Reversed)
+ {
+ public static Use F(EdgeId edge) => new(edge, false);
+ public static Use R(EdgeId edge) => new(edge, true);
+ }
+}
diff --git a/Aetheris.FrictionLab.Tests/CIRLab/ProfileStackChamferLabTests.cs b/Aetheris.FrictionLab.Tests/CIRLab/ProfileStackChamferLabTests.cs
new file mode 100644
index 00000000..0cedd473
--- /dev/null
+++ b/Aetheris.FrictionLab.Tests/CIRLab/ProfileStackChamferLabTests.cs
@@ -0,0 +1,133 @@
+using Aetheris.Firmament.FrictionLab.CIRLab;
+
+namespace Aetheris.FrictionLab.Tests.CIRLab;
+
+public class ProfileStackChamferLabTests
+{
+ private static string Stable(ProfileStackChamferRow row) => string.Join("|",
+ row.CaseName,
+ row.Status,
+ row.Succeeded,
+ row.SucceededRoute,
+ row.Topology.VertexCount,
+ row.Topology.EdgeCount,
+ row.Topology.FaceCount,
+ row.Topology.PlanarFaceCount,
+ row.Topology.CylindricalFaceCount,
+ row.Topology.LowerPrismSideFaceCount,
+ row.Topology.TransitionFaceCount,
+ row.Topology.ChamferTransitionFaceCount,
+ row.Topology.LoopCount,
+ row.Topology.CoedgeCount,
+ row.Topology.Bounds,
+ string.Join(",", row.Step.PresentMarkers.OrderBy(x => x, StringComparer.Ordinal)),
+ string.Join(",", row.Step.MissingRequiredMarkers.OrderBy(x => x, StringComparer.Ordinal)),
+ string.Join(",", row.Step.AbsentMarkers.OrderBy(x => x, StringComparer.Ordinal)),
+ string.Join(",", row.Step.UnexpectedPresentMarkers.OrderBy(x => x, StringComparer.Ordinal)),
+ string.Join(",", row.Diagnostics.OrderBy(x => x, StringComparer.Ordinal)),
+ row.Recommendation);
+
+ [Fact]
+ public void ProfileStackChamferLab_IsDeterministic()
+ {
+ var first = ProfileStackChamferLab.RunAll();
+ var second = ProfileStackChamferLab.RunAll();
+
+ Assert.Equal(first.Select(Stable), second.Select(Stable));
+ }
+
+ [Fact]
+ public void ProfileStackChamferLab_RouteAReportsExactProfileStackBlockers()
+ {
+ var row = ProfileStackChamferLab.RunAll().Single(x => x.CaseName == "canonical-top-pos-x-edge");
+
+ Assert.Contains("edge-profile-x2-route-a-profile-stack-attempted", row.Diagnostics);
+ Assert.Contains("edge-profile-x2-route-a-profile-stack-blocked:profile-stack-polygon-profile-blocker", row.Diagnostics);
+ Assert.Contains("edge-profile-x2-profile-stack-polygon-profile-blocker", row.Diagnostics);
+ Assert.Contains("edge-profile-x2-ruled-transition-emitter-missing-blocker", row.Diagnostics);
+ Assert.DoesNotContain(row.Diagnostics, d => d.Contains("unknown", StringComparison.OrdinalIgnoreCase) || d.Contains("vague", StringComparison.OrdinalIgnoreCase));
+ }
+
+ [Fact]
+ public void ProfileStackChamferLab_RouteBProducesClosedPlanarConstructiveWitness()
+ {
+ var row = ProfileStackChamferLab.RunAll().Single(x => x.CaseName == "canonical-top-pos-x-edge");
+
+ Assert.True(row.Succeeded);
+ Assert.Equal(LabProfileStatus.Succeeded, row.Status);
+ Assert.Equal(ProfileStackChamferRoute.SectionTransition, row.SucceededRoute);
+ Assert.True(row.Topology.BodyProduced);
+ Assert.Equal(12, row.Topology.VertexCount);
+ Assert.Equal(20, row.Topology.EdgeCount);
+ Assert.Equal(10, row.Topology.FaceCount);
+ Assert.Equal(10, row.Topology.PlanarFaceCount);
+ Assert.Equal(0, row.Topology.CylindricalFaceCount);
+ Assert.Equal(4, row.Topology.LowerPrismSideFaceCount);
+ Assert.Equal(4, row.Topology.TransitionFaceCount);
+ Assert.Equal(1, row.Topology.ChamferTransitionFaceCount);
+ Assert.Equal(10, row.Topology.LoopCount);
+ Assert.Equal(40, row.Topology.CoedgeCount);
+ Assert.Equal("[-5,-4,0]..[5,4,6]", row.Topology.Bounds);
+ Assert.Contains("edge-profile-x2-route-b-section-transition-attempted", row.Diagnostics);
+ Assert.Contains("edge-profile-x2-route-b-section-transition-succeeded", row.Diagnostics);
+ Assert.Contains("edge-profile-x2-profile-correspondence-created", row.Diagnostics);
+ Assert.Contains("edge-profile-x2-ruled-transition-faces-created", row.Diagnostics);
+ }
+
+ [Fact]
+ public void ProfileStackChamferLab_StepSmokePassesWithoutCylindersOrVoids()
+ {
+ var row = ProfileStackChamferLab.RunAll().Single(x => x.CaseName == "canonical-top-pos-x-edge");
+
+ Assert.True(row.Step.Exported);
+ Assert.Empty(row.Step.MissingRequiredMarkers);
+ Assert.Empty(row.Step.UnexpectedPresentMarkers);
+ Assert.Contains("ISO-10303-21", row.Step.PresentMarkers);
+ Assert.Contains("MANIFOLD_SOLID_BREP", row.Step.PresentMarkers);
+ Assert.Contains("ADVANCED_FACE", row.Step.PresentMarkers);
+ Assert.Contains("PLANE", row.Step.PresentMarkers);
+ Assert.Contains("CYLINDRICAL_SURFACE", row.Step.AbsentMarkers);
+ Assert.Contains("BREP_WITH_VOIDS", row.Step.AbsentMarkers);
+ Assert.Contains("edge-profile-x2-step-smoke-succeeded", row.Diagnostics);
+ }
+
+ [Fact]
+ public void ProfileStackChamferLab_CandidatePathExcludesTrimGraftEdgeSweepChamferAndBoolean()
+ {
+ var row = ProfileStackChamferLab.RunAll().Single(x => x.CaseName == "canonical-top-pos-x-edge");
+
+ Assert.Contains("edge-profile-x2-no-air-edge-sweep-used", row.Diagnostics);
+ Assert.Contains("edge-profile-x2-no-brep-bounded-chamfer-used", row.Diagnostics);
+ Assert.Contains("edge-profile-x2-no-topology-graft-used", row.Diagnostics);
+ Assert.Contains("edge-profile-x2-no-3d-boolean-used", row.Diagnostics);
+ }
+
+ [Theory]
+ [InlineData("invalid-zero-width", "edge-profile-x2-invalid-dimensions-rejected")]
+ [InlineData("invalid-negative-depth", "edge-profile-x2-invalid-dimensions-rejected")]
+ [InlineData("invalid-zero-height", "edge-profile-x2-invalid-dimensions-rejected")]
+ [InlineData("invalid-non-finite-height", "edge-profile-x2-invalid-dimensions-rejected")]
+ [InlineData("invalid-zero-chamfer-distance", "edge-profile-x2-invalid-chamfer-distance-rejected")]
+ [InlineData("invalid-too-large-chamfer-distance", "edge-profile-x2-invalid-chamfer-distance-rejected")]
+ public void ProfileStackChamferLab_InvalidCasesRejectBeforeGeometry(string caseName, string expectedDiagnostic)
+ {
+ var row = ProfileStackChamferLab.RunAll().Single(x => x.CaseName == caseName);
+
+ Assert.False(row.Succeeded);
+ Assert.False(row.Topology.BodyProduced);
+ Assert.Equal(ProfileStackChamferRoute.None, row.SucceededRoute);
+ Assert.Contains(expectedDiagnostic, row.Diagnostics);
+ Assert.DoesNotContain("edge-profile-x2-route-a-profile-stack-attempted", row.Diagnostics);
+ Assert.DoesNotContain("edge-profile-x2-route-b-section-transition-attempted", row.Diagnostics);
+ Assert.Equal("profile-stack-chamfer-invalid-rejected", row.Recommendation);
+ }
+
+ [Fact]
+ public void ProfileStackChamferLab_RecommendationsAreFromFiniteVocabulary()
+ {
+ foreach (var row in ProfileStackChamferLab.RunAll())
+ {
+ Assert.Contains(row.Recommendation, ProfileStackChamferLab.AllowedRecommendations);
+ }
+ }
+}
diff --git a/docs/edge-a1-chamfer-fillet-support-compatibility-matrix.md b/docs/edge-a1-chamfer-fillet-support-compatibility-matrix.md
index e8784db6..48f73291 100644
--- a/docs/edge-a1-chamfer-fillet-support-compatibility-matrix.md
+++ b/docs/edge-a1-chamfer-fillet-support-compatibility-matrix.md
@@ -8,7 +8,7 @@ The current AirChamfer golden path is strong but narrow: controlled convex plana
Legacy bounded chamfer/fillet behavior remains authoritative wherever production behavior exists. In particular, `BrepBoundedChamfer` and `BrepBoundedFillet` are still the production routes for the currently supported bounded cases, and AirEdgeSweep/AirChamfer evidence must not be read as route replacement.
-EDGE-A2 reclassifies some chamfer cases as profile/profile-stack candidates rather than AirEdgeSweep candidates: vertical edges of history-known extrusions should be tested as profile modifications, and top/bottom extrusion edges should be tested as profile-stack or section-transition constructions. EDGE-PROFILE-X1 now provides lab evidence for the vertical-edge/profile-authored subset, and EDGE-PROFILE-V1 packages that proof into an internal production-adjacent emitter; production statuses remain unchanged until a separately gated route is admitted.
+EDGE-A2 reclassifies some chamfer cases as profile/profile-stack candidates rather than AirEdgeSweep candidates: vertical edges of history-known extrusions should be tested as profile modifications, and top/bottom extrusion edges should be tested as profile-stack or section-transition constructions. EDGE-PROFILE-X1 now provides lab evidence for the vertical-edge/profile-authored subset, EDGE-PROFILE-V1 packages that proof into an internal production-adjacent emitter, and EDGE-PROFILE-X2 now provides lab-only section-transition evidence for one top horizontal +X side chamfer while documenting current profile-stack generalization blockers; production statuses remain unchanged until a separately gated route is admitted.
The matrix separates five concerns that were previously easy to conflate:
@@ -142,7 +142,7 @@ This path is not production-authoritative. It does not support chains, corners,
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| CH-01 | concave/additive | plane-plane, orthogonal | single edge | constant chamfer distance | no corner | plane | `production-legacy-supported` where bounded internal concave route applies | `lab-supported`; `policy-supported` | EDGE-X1 inventory; EDGE-X2 concave planar patch proof; EDGE-X2.1 policy scaffold | production Air route, shadow parity, corpus | Legacy production only; Air is lab/policy evidence | Preserve legacy; use as concave AirChamfer baseline |
| CH-02 | concave/additive | plane-plane, non-orthogonal | single edge | constant chamfer distance | no corner | plane | `unknown/no-test` to `production-legacy-supported` only where existing bounded trusted contexts admit it | `lab-supported`; `policy-supported` | EDGE-X2.2 non-orthogonal concave planar policy+patch | production body mutation, feature-recognition parity, corpus | Not production Air-ready | Add parity/shadow fixture after convex route stabilizes |
-| CH-03 | convex/replacement | plane-plane, orthogonal controlled body | single edge | constant chamfer distance | no corner | plane | `production-legacy-supported` for legacy bounded box/simple contexts | `production-adjacent-air-prototype`; `shadow-supported`; `artifact-corpus-supported`; `closed-witness-supported`; `gated-opt-in-route-supported`; `profile-authored-lab-supported`; `profile-authored-production-adjacent-emitter-supported` for history-known vertical extrusion edges | EDGE-X3 through EDGE-X13, EDGE-V1/V2/V3/V4, EDGE-PROFILE-X1, EDGE-PROFILE-V1, CLI tests, FrictionLab AirChamfer tests, ProfileChamfer tests, ProfileVertexChamfer tests, Firmament shadow-diagnostics and opt-in route tests | default production authority, arbitrary body mutation beyond controlled fixture, production-adjacent profile chamfer admission | Best current AirChamfer row for no-history/local-edge fixtures; EDGE-PROFILE-X1 proves history-known vertical-edge chamfer can be emitted as profile extrusion; EDGE-PROFILE-V1 packages that path as an internal production-adjacent emitter, still not production-authoritative | EDGE-PROFILE-V2 controlled Firmament/profile route evaluation or EDGE-PROFILE-X2 profile-stack top-edge chamfer lab |
+| CH-03 | convex/replacement | plane-plane, orthogonal controlled body | single edge | constant chamfer distance | no corner | plane | `production-legacy-supported` for legacy bounded box/simple contexts | `production-adjacent-air-prototype`; `shadow-supported`; `artifact-corpus-supported`; `closed-witness-supported`; `gated-opt-in-route-supported`; `profile-authored-lab-supported`; `profile-authored-production-adjacent-emitter-supported` for history-known vertical extrusion edges; `profile-stack-section-transition-lab-supported` for one history-known top +X horizontal edge fixture | EDGE-X3 through EDGE-X13, EDGE-V1/V2/V3/V4, EDGE-PROFILE-X1, EDGE-PROFILE-V1, EDGE-PROFILE-X2, CLI tests, FrictionLab AirChamfer tests, ProfileChamfer tests, ProfileStackChamfer tests, ProfileVertexChamfer tests, Firmament shadow-diagnostics and opt-in route tests | default production authority, arbitrary body mutation beyond controlled fixture, production-adjacent profile chamfer admission, general polygon section-transition/profile-correspondence contract | Best current AirChamfer row for no-history/local-edge fixtures; EDGE-PROFILE-X1 proves history-known vertical-edge chamfer can be emitted as profile extrusion; EDGE-PROFILE-V1 packages that path as an internal production-adjacent emitter, still not production-authoritative; EDGE-PROFILE-X2 proves one top horizontal +X side chamfer can be emitted as a lab-only all-planar section-transition witness and records current profile-stack polygon/ruled-transition blockers | Define production-adjacent polygon section-transition/profile-correspondence contract before any profile-stack top-edge chamfer route evaluation |
| CH-04 | convex/replacement | plane-plane, non-orthogonal controlled body | single edge | constant chamfer distance | no corner | plane | `production-legacy-supported` only for admitted trusted/triangle-like bounded contexts; otherwise `unknown/no-test` | `shadow-supported`; `artifact-corpus-supported`; `production-adjacent-air-prototype` for safe controlled case | EDGE-X11 non-orthogonal corpus row; EDGE-X12 stability; EDGE-V3 shadow route | broader topology mutation, richer feature-recognition parity, production fallback | Non-authoritative controlled evidence only | Harden controlled non-orthogonal shadow diagnostics |
| CH-05 | convex/replacement | plane-plane | single edge on arbitrary production body | constant chamfer distance | no corner or endpoint transition as needed | plane | `production-legacy-supported` only for legacy recognized bounded cases | `deferred`; `blocked-by-body-mutation`; partial `production-adjacent-air-prototype` for controlled body | EDGE-V2/V3 controlled prototype and shadow docs | arbitrary edge selection, grafting, identity, regression corpus | Not production Air-ready | EDGE-X15 convex AirChamfer controlled body mutation hardening |
| CH-06 | convex/replacement | plane-plane | edge chain | constant chamfer distance | chain termination; endpoint transitions | plane sequence plus transition patches | legacy support is bounded/contextual; generic status `unknown/no-test` | `deferred`; `blocked-by-corner-policy`; `blocked-by-body-mutation` | EDGE-V3 deferred edge-chain diagnostics; EDGE-X1 notes | chain policy, termination policy, topology plan, feature-recognition parity | Not ready | EDGE-X16 AirChamfer edge-chain policy lab |
diff --git a/docs/edge-a2-constructive-chamfer-reframing-audit.md b/docs/edge-a2-constructive-chamfer-reframing-audit.md
index e2f0b447..062a4622 100644
--- a/docs/edge-a2-constructive-chamfer-reframing-audit.md
+++ b/docs/edge-a2-constructive-chamfer-reframing-audit.md
@@ -23,6 +23,8 @@ EDGE-PROFILE-X1 follow-up: `ProfileChamferExtrudeLab` now exercises that smalles
EDGE-PROFILE-V1 packaging note: `ProfileVertexChamferExtrudeEmitter` moves the same proof into an internal production-adjacent seam with deterministic admissibility, topology, STEP, and no-legacy-route diagnostics. It remains non-authoritative and does not replace production chamfer, fillet, primitive, STEP, Boolean, or AirEdgeSweep behavior. See `docs/edge-profile-v1-profile-authored-chamfer-emitter.md`.
+EDGE-PROFILE-X2 follow-up: `ProfileStackChamferLab` now tests the top/horizontal-edge profile-stack theory. Route A records exact blockers in the current profile-stack model (no arbitrary polygon section profile contract and no ruled polygon-to-polygon transition emitter). Route B succeeds as a lab-only polygon section-transition witness for a top +X side chamfer on a 10 x 8 x 6 prism with chamfer distance 1, producing a closed all-planar STEP-exportable body without AirEdgeSweep, `BrepBoundedChamfer`, topology grafting, or 3D Boolean fallback. See `docs/frictionlab/edge-profile-x2-top-edge-chamfer-profile-stack-lab.md`.
+
## 2. Theory under audit
The audit tests a V2-compatible chamfer decomposition: do not trim if construction history can emit the final body directly.
diff --git a/docs/edge-profile-v1-profile-authored-chamfer-emitter.md b/docs/edge-profile-v1-profile-authored-chamfer-emitter.md
index 96777ab1..aa95cd21 100644
--- a/docs/edge-profile-v1-profile-authored-chamfer-emitter.md
+++ b/docs/edge-profile-v1-profile-authored-chamfer-emitter.md
@@ -159,7 +159,7 @@ EDGE-PROFILE-V1 does not change:
- sketch solving;
- clipping;
- NURBS/freeform support;
-- top/horizontal edge chamfers;
+- top/horizontal edge chamfers (covered separately by EDGE-PROFILE-X2 as a lab-only section-transition witness, not by this V1 vertical-edge emitter);
- corner-chain or multi-edge chamfers.
## 13. Tests run
@@ -181,5 +181,5 @@ The milestone validation commands are recorded in the PR summary/final response.
Two next steps are reasonable:
-1. **EDGE-PROFILE-X2**: profile-stack top-edge chamfer lab for horizontal/top extrusion edges.
-2. **EDGE-PROFILE-V2**: controlled Firmament/profile route evaluation if this internal emitter remains stable under broader route-readiness tests.
+1. **Profile-stack section-transition contract**: use EDGE-PROFILE-X2 evidence to define explicit polygon profile correspondence and ruled transition emission for horizontal/top extrusion edges.
+2. **EDGE-PROFILE-V2**: controlled Firmament/profile route evaluation if this internal vertical-edge emitter remains stable under broader route-readiness tests.
diff --git a/docs/frictionlab/edge-profile-x2-top-edge-chamfer-profile-stack-lab.md b/docs/frictionlab/edge-profile-x2-top-edge-chamfer-profile-stack-lab.md
new file mode 100644
index 00000000..b7034c3b
--- /dev/null
+++ b/docs/frictionlab/edge-profile-x2-top-edge-chamfer-profile-stack-lab.md
@@ -0,0 +1,150 @@
+# EDGE-PROFILE-X2 — Top-edge chamfer as profile-stack / section-transition lab
+
+## Purpose and scope
+
+EDGE-PROFILE-X2 is a FrictionLab-only experiment for expressing one horizontal/top-edge chamfer constructively. It tests whether a known rectangular prism with a top edge chamfer can be emitted directly from section/profile evolution along Z rather than by BRep trimming, topology grafting, AirEdgeSweep, BrepBoundedChamfer, or a 3D Boolean.
+
+This lab does **not** change production chamfer/fillet behavior, production profile-stack routing, STEP export/import, the Boolean core, AirEdgeSweep, triangle migration, sketch solving, clipping, or NURBS/freeform support.
+
+## Reference context
+
+EDGE-A2 reframed many chamfers as final topology that should be authored directly when construction history is known. EDGE-PROFILE-X1 proved the vertical-edge case by replacing a rectangle corner with a bevel segment and extruding the final pentagon profile directly. EDGE-PROFILE-V1 packaged that vertical-edge/profile-authored proof into a production-adjacent emitter.
+
+EDGE-PROFILE-X2 extends the same constructive doctrine to the horizontal/top-edge case by testing a profile stack / section-transition interpretation.
+
+## Theory under test
+
+For an extruded rectangular prism, a top horizontal edge chamfer can be represented as section/profile evolution along Z:
+
+- lower section interval: full rectangle,
+- top section: related rectangle with the chosen top boundary inset,
+- transition interval: ruled planar faces between corresponding profile edges,
+- final body: emitted directly from these known sections.
+
+The bounded contract chosen for this lab is a top +X side chamfer, not a local corner chamfer. The +X side of the top profile is inset by the chamfer distance while the lower prism remains a full rectangle.
+
+## Routes explored
+
+### Route A — Existing profile-stack executor probe
+
+The existing FrictionLab/production-adjacent profile-stack concepts are currently centered on rectangular host extents plus optional circular inner cut intervals. The EDGE-PROFILE-X2 probe records Route A as attempted but blocked for this case because the current layer model has no arbitrary polygon section profile contract and no ruled polygon-to-polygon transition emitter.
+
+Deterministic blockers:
+
+- `edge-profile-x2-profile-stack-polygon-profile-blocker`
+- `edge-profile-x2-ruled-transition-emitter-missing-blocker`
+
+The lab intentionally does not broaden the existing `ProfileStackExtrudeExecutor` or production profile-stack behavior.
+
+### Route B — Lab-only polygon section-transition emitter
+
+Route B succeeds with a small lab-only line-only section-transition emitter. It accepts the explicit three-section contract below, creates fixed correspondence by vertex index, and emits all planar faces directly.
+
+The route emits:
+
+- bottom cap,
+- top cap,
+- four lower vertical prism side faces,
+- four upper section-transition faces,
+- one of those transition faces classified as the chamfer face.
+
+### Route C — Direct constructive witness
+
+Route C was not needed because Route B produced the closed constructive witness. The Route B implementation is still intentionally bounded and lab-only; it is not a reusable production section-transition emitter yet.
+
+## Candidate geometry
+
+Canonical case: `canonical-top-pos-x-edge`
+
+- width = 10
+- depth = 8
+- height = 6
+- chamferDistance = 1
+- z0 = 0
+- z1 = height - chamferDistance = 5
+- z2 = height = 6
+- bottom/lower full rectangle at z0 and z1:
+ - (-5, -4)
+ - (5, -4)
+ - (5, 4)
+ - (-5, 4)
+- top inset rectangle at z2:
+ - (-5, -4)
+ - (4, -4)
+ - (4, 4)
+ - (-5, 4)
+
+The profile correspondence is explicit by vertex/edge index. Edge index 1, from +Y/-Y endpoints on the +X side, transitions from x = 5 at z = 5 to x = 4 at z = 6 and is the chamfer transition face.
+
+## Topology findings
+
+The successful Route B witness is a closed planar BRep with stable lab counts:
+
+- vertices: 12
+- edges: 20
+- faces: 10
+- planar faces: 10
+- cylindrical faces: 0
+- lower prism side faces: 4
+- transition faces: 4
+- chamfer transition faces: 1
+- loops: 10
+- coedges: 40
+- bounds: `[-5,-4,0]..[5,4,6]`
+
+The topology intentionally keeps the lower vertical side faces and upper transition faces split at z = 5, even where adjacent portions are coplanar, because this preserves the section-stack witness and makes the transition interval machine-checkable.
+
+## STEP smoke findings
+
+The Route B witness exports through the existing `Step242Exporter` and passes the lab smoke contract.
+
+Required markers present:
+
+- `ISO-10303-21`
+- `MANIFOLD_SOLID_BREP`
+- `ADVANCED_FACE`
+- `PLANE`
+
+Required markers absent:
+
+- `CYLINDRICAL_SURFACE`
+- `BREP_WITH_VOIDS`
+
+## No-trim/no-graft/no-legacy-route guarantee
+
+The candidate path records deterministic diagnostics confirming that it does not use:
+
+- AirEdgeSweep,
+- BrepBoundedChamfer,
+- topology graft/body mutation,
+- 3D Boolean.
+
+The lab also uses no BRep trimming, no sketch solver, no clipping engine, and no NURBS/freeform support.
+
+## Invalid/rejected cases
+
+Invalid cases reject before Route A/B geometry attempts:
+
+- non-positive or non-finite dimensions: `edge-profile-x2-invalid-dimensions-rejected`
+- non-positive, non-finite, or too-large chamfer distance: `edge-profile-x2-invalid-chamfer-distance-rejected`
+
+## Non-goals
+
+- no production route replacement,
+- no production chamfer/fillet behavior change,
+- no vertical-edge chamfer work beyond referencing X1/V1,
+- no local top-corner chamfer,
+- no AirEdgeSweep route,
+- no BrepBoundedChamfer route,
+- no STEP exporter/importer changes,
+- no Boolean core changes,
+- no triangle migration,
+- no sketch solver,
+- no clipping engine,
+- no NURBS/freeform support.
+
+## Recommendation
+
+`profile-stack-chamfer-needs-section-transition-emitter`
+
+EDGE-PROFILE-X2 proves the top +X horizontal edge chamfer theory for one bounded all-planar witness through a lab-only section-transition emitter. The next production-adjacent step is not to generalize the existing circular-hole profile-stack executor in-place, but to define a first-class polygon section-transition/profile-correspondence contract and then evaluate a production-adjacent profile-stack chamfer emitter against that contract.