Next Gen STEP AP242 Native-ish BREP Geometric Modeling Kernel
Add countersink support to combined edge finishes
Yuechen Li81bf27685f8c
diff --git a/Aetheris.Kernel.Core/Brep/Features/CombinedTopBoundaryEdgeFinishThroughHoleBuilder.cs b/Aetheris.Kernel.Core/Brep/Features/CombinedTopBoundaryEdgeFinishThroughHoleBuilder.csindex 4ae9010f..21650262 100644--- a/Aetheris.Kernel.Core/Brep/Features/CombinedTopBoundaryEdgeFinishThroughHoleBuilder.cs+++ b/Aetheris.Kernel.Core/Brep/Features/CombinedTopBoundaryEdgeFinishThroughHoleBuilder.cs@@ -19,10 +19,18 @@ public sealed record CombinedTopBoundaryEdgeFinishThroughHole(double CenterY,double Radius,double? CounterboreRadius = null,- double? CounterboreDepth = null)+ double? CounterboreDepth = null,+ double? CountersinkRadius = null,+ double? CountersinkAngleDegrees = null){public bool IsCounterbore => CounterboreRadius is not null;- public double EntryRadius => CounterboreRadius ?? Radius;+ public bool IsCountersink => CountersinkRadius is not null;+ public double EntryRadius => CountersinkRadius ?? CounterboreRadius ?? Radius;+ public double? ReliefDepth => CounterboreDepth ?? (CountersinkRadius is { } radius && CountersinkAngleDegrees is { } angle+ ? (radius - Radius) / System.Math.Tan(angle * System.Math.PI / 360d) : null);+ public double RemovedVolume(double height) => System.Math.PI * Radius * Radius * height+ + (IsCounterbore ? System.Math.PI * (EntryRadius * EntryRadius - Radius * Radius) * ReliefDepth!.Value : 0d)+ + (IsCountersink ? System.Math.PI / 3d * (EntryRadius - Radius) * (EntryRadius + 2d * Radius) * ReliefDepth!.Value : 0d);}public enum TopBoundaryEdgeFinishKind { Chamfer, Fillet }@@ -44,10 +52,11 @@ public sealed record CombinedTopBoundaryEdgeFinishThroughHolePlan(get{var height = ZMax - ZMin;- var lowerHeight = height - FinishSize;var bottomArea = Width * Depth;- var topArea = (Width - (2d * FinishSize)) * (Depth - (2d * FinishSize));- var finishedHost = (bottomArea * lowerHeight) + (FinishSize / 3d * (bottomArea + topArea + System.Math.Sqrt(bottomArea * topArea)));+ // Integrate (Width-2t)(Depth-2t). Rectangular offsets are not+ // homothetic pyramids unless Width == Depth.+ var finishedHost = bottomArea * height - (Width + Depth) * FinishSize * FinishSize+ + 4d / 3d * FinishSize * FinishSize * FinishSize;if (FinishKind == TopBoundaryEdgeFinishKind.Fillet){// Integrate the retained rectangle (W-2s)(D-2s), where@@ -58,10 +67,7 @@ public sealed record CombinedTopBoundaryEdgeFinishThroughHolePlan(var overlap = r * r * r * (5d / 3d - System.Math.PI / 2d);finishedHost = bottomArea * height - 2d * (Width + Depth) * section + 4d * overlap;}- var removed = Holes.Sum(h => System.Math.PI * h.Radius * h.Radius * height- + (h.CounterboreRadius is { } reliefRadius && h.CounterboreDepth is { } reliefDepth- ? System.Math.PI * (reliefRadius * reliefRadius - h.Radius * h.Radius) * reliefDepth- : 0d));+ var removed = Holes.Sum(h => h.RemovedVolume(height));return finishedHost - removed;}}@@ -112,6 +118,14 @@ public static class CombinedTopBoundaryEdgeFinishThroughHoleBuilder// The periodic circle and its longitudinal seam share endpoint identities.// Coincident but distinct seam/circle vertices produce invalid STEP wires.var seamTop = b.AddVertex(); var seamBottom = b.AddVertex();+ if (h.IsCountersink)+ {+ // The cone and shaft share one throat circle and seam endpoint.+ var throat = b.AddVertex(); var throatCircle = b.AddEdge(throat, throat);+ return new HoleTopology(h, seamTop, seamBottom, throat, throat,+ b.AddEdge(seamTop, seamTop), b.AddEdge(seamBottom, seamBottom), throatCircle, throatCircle,+ b.AddEdge(seamTop, throat), b.AddEdge(throat, seamBottom));+ }if (!h.IsCounterbore)return new HoleTopology(h, seamTop, seamBottom, null, null,b.AddEdge(seamTop, seamTop), b.AddEdge(seamBottom, seamBottom), null, null, b.AddEdge(seamTop, seamBottom), null);@@ -140,23 +154,32 @@ public static class CombinedTopBoundaryEdgeFinishThroughHoleBuilderlowerFaces[i] = b.AddFace([AddLoop(b, [Forward(bottomEdges[i]), Forward(lowerEdges[next]), Reversed(shoulderEdges[i]), Reversed(lowerEdges[i])])]);finishFaces[i] = b.AddFace([AddLoop(b, [Forward(shoulderEdges[i]), Forward(finishEdges[next]), Reversed(topEdges[i]), Reversed(finishEdges[i])])]);}- var holeFaces = new List<(HoleTopology Hole, FaceId Face, double Radius, double ZMin, double ZMax)>();+ var holeFaces = new List<(HoleTopology Hole, FaceId Face, double Radius, double ZMin, double ZMax, bool Cone)>();var shoulderFaces = new List<(HoleTopology Hole, FaceId Face)>();foreach (var hole in holes){+ if (hole.Hole.IsCountersink)+ {+ var throatZ = plan.ZMax - hole.Hole.ReliefDepth!.Value;+ var cone = b.AddFace([AddLoop(b, [Forward(hole.UpperSeam), Forward(hole.ShoulderInnerCircle!.Value), Reversed(hole.UpperSeam), Reversed(hole.TopCircle)])]);+ var shaft = b.AddFace([AddLoop(b, [Forward(hole.LowerSeam!.Value), Forward(hole.BottomCircle), Reversed(hole.LowerSeam.Value), Reversed(hole.ShoulderInnerCircle.Value)])]);+ holeFaces.Add((hole, cone, hole.Hole.Radius, throatZ, plan.ZMax, true));+ holeFaces.Add((hole, shaft, hole.Hole.Radius, plan.ZMin, throatZ, false));+ continue;+ }if (!hole.Hole.IsCounterbore){var face=b.AddFace([AddLoop(b, [Forward(hole.UpperSeam), Forward(hole.BottomCircle), Reversed(hole.UpperSeam), Reversed(hole.TopCircle)])]);- holeFaces.Add((hole,face,hole.Hole.Radius,plan.ZMin,plan.ZMax));+ holeFaces.Add((hole,face,hole.Hole.Radius,plan.ZMin,plan.ZMax,false));continue;}var shoulderZ=plan.ZMax-hole.Hole.CounterboreDepth!.Value;var boreFace=b.AddFace([AddLoop(b,[Forward(hole.UpperSeam),Forward(hole.ShoulderOuterCircle!.Value),Reversed(hole.UpperSeam),Reversed(hole.TopCircle)])]);var shoulderFace=b.AddFace([AddLoop(b,[Reversed(hole.ShoulderOuterCircle.Value)]),AddLoop(b,[Forward(hole.ShoulderInnerCircle!.Value)])]);var shaftFace=b.AddFace([AddLoop(b,[Forward(hole.LowerSeam!.Value),Forward(hole.BottomCircle),Reversed(hole.LowerSeam.Value),Reversed(hole.ShoulderInnerCircle.Value)])]);- holeFaces.Add((hole,boreFace,hole.Hole.CounterboreRadius!.Value,shoulderZ,plan.ZMax));+ holeFaces.Add((hole,boreFace,hole.Hole.CounterboreRadius!.Value,shoulderZ,plan.ZMax,false));shoulderFaces.Add((hole,shoulderFace));- holeFaces.Add((hole,shaftFace,hole.Hole.Radius,plan.ZMin,shoulderZ));+ holeFaces.Add((hole,shaftFace,hole.Hole.Radius,plan.ZMin,shoulderZ,false));}var shell = b.AddShell([bottomFace, topFace, .. lowerFaces, .. finishFaces, .. holeFaces.Select(x=>x.Face), .. shoulderFaces.Select(x=>x.Face)]);b.AddBody([shell]);@@ -220,13 +243,24 @@ public static class CombinedTopBoundaryEdgeFinishThroughHoleBuildervar centerBottom = new Point3D(hole.Hole.CenterX, hole.Hole.CenterY, plan.ZMin);geometry.AddCurve(topCurve, CurveGeometry.FromCircle(new Circle3Curve(centerTop, zAxis, hole.Hole.EntryRadius, xAxis)));geometry.AddCurve(bottomCurve, CurveGeometry.FromCircle(new Circle3Curve(centerBottom, zAxis, hole.Hole.Radius, xAxis)));- var upperZMin=hole.Hole.IsCounterbore?plan.ZMax-hole.Hole.CounterboreDepth!.Value:plan.ZMin;- geometry.AddCurve(seamCurve, CurveGeometry.FromLine(new Line3Curve(new Point3D(hole.Hole.CenterX + hole.Hole.EntryRadius, hole.Hole.CenterY, upperZMin), zAxis)));+ var upperZMin=hole.Hole.ReliefDepth is { } reliefDepth ? plan.ZMax-reliefDepth : plan.ZMin;+ var seamStart = new Point3D(hole.Hole.CenterX + (hole.Hole.IsCountersink ? hole.Hole.Radius : hole.Hole.EntryRadius), hole.Hole.CenterY, upperZMin);+ var seamVector = new Vector3D(hole.Hole.IsCountersink ? hole.Hole.EntryRadius-hole.Hole.Radius : 0d, 0d, plan.ZMax-upperZMin);+ geometry.AddCurve(seamCurve, CurveGeometry.FromLine(new Line3Curve(seamStart, hole.Hole.IsCountersink ? Direction3D.Create(seamVector) : zAxis)));bindings.AddEdgeBinding(new EdgeGeometryBinding(hole.TopCircle, topCurve, new ParameterInterval(0d, 2d * System.Math.PI)));bindings.AddEdgeBinding(new EdgeGeometryBinding(hole.BottomCircle, bottomCurve, new ParameterInterval(0d, 2d * System.Math.PI)));- bindings.AddEdgeBinding(new EdgeGeometryBinding(hole.UpperSeam, seamCurve, new ParameterInterval(0d, plan.ZMax - upperZMin), OrientedEdgeSense: false));+ bindings.AddEdgeBinding(new EdgeGeometryBinding(hole.UpperSeam, seamCurve, new ParameterInterval(0d, hole.Hole.IsCountersink ? seamVector.Length : plan.ZMax-upperZMin), OrientedEdgeSense: false));vertexPoints[hole.SeamTopVertex] = new Point3D(hole.Hole.CenterX + hole.Hole.EntryRadius, hole.Hole.CenterY, plan.ZMax);vertexPoints[hole.SeamBottomVertex] = new Point3D(hole.Hole.CenterX + hole.Hole.Radius, hole.Hole.CenterY, plan.ZMin);+ if (hole.Hole.IsCountersink)+ {+ var throatCurve = new CurveGeometryId(edgeCurve++); var lowerSeamCurve = new CurveGeometryId(edgeCurve++);+ geometry.AddCurve(throatCurve, CurveGeometry.FromCircle(new Circle3Curve(new(hole.Hole.CenterX, hole.Hole.CenterY, upperZMin), zAxis, hole.Hole.Radius, xAxis)));+ geometry.AddCurve(lowerSeamCurve, CurveGeometry.FromLine(new Line3Curve(new(hole.Hole.CenterX+hole.Hole.Radius, hole.Hole.CenterY, plan.ZMin), zAxis)));+ bindings.AddEdgeBinding(new(hole.ShoulderInnerCircle!.Value, throatCurve, new(0d, 2d*System.Math.PI)));+ bindings.AddEdgeBinding(new(hole.LowerSeam!.Value, lowerSeamCurve, new(0d, upperZMin-plan.ZMin), OrientedEdgeSense: false));+ vertexPoints[hole.ShoulderInnerVertex!.Value] = new(hole.Hole.CenterX+hole.Hole.Radius, hole.Hole.CenterY, upperZMin);+ }if (hole.Hole.IsCounterbore){var shoulderZ=upperZMin;@@ -243,7 +277,12 @@ public static class CombinedTopBoundaryEdgeFinishThroughHoleBuilder}foreach(var wall in holeFaces){- var sid=new SurfaceGeometryId(surface++);geometry.AddSurface(sid,SurfaceGeometry.FromCylinder(new CylinderSurface(new(wall.Hole.Hole.CenterX,wall.Hole.Hole.CenterY,wall.ZMin),zAxis,wall.Radius,xAxis)));bindings.AddFaceBinding(new(wall.Face,sid,IsAlignedWithSurface:false));+ var sid = new SurfaceGeometryId(surface++);+ var origin = new Point3D(wall.Hole.Hole.CenterX, wall.Hole.Hole.CenterY, wall.ZMin);+ geometry.AddSurface(sid, wall.Cone+ ? SurfaceGeometry.FromCone(new ConeSurface(origin, zAxis, wall.Radius, wall.Hole.Hole.CountersinkAngleDegrees!.Value * System.Math.PI / 360d, xAxis))+ : SurfaceGeometry.FromCylinder(new CylinderSurface(origin, zAxis, wall.Radius, xAxis)));+ bindings.AddFaceBinding(new(wall.Face,sid,IsAlignedWithSurface:false));}foreach(var shoulderBinding in shoulderFaces)BindPlane(shoulderBinding.Face,new(shoulderBinding.Hole.Hole.CenterX,shoulderBinding.Hole.Hole.CenterY,plan.ZMax-shoulderBinding.Hole.Hole.CounterboreDepth!.Value),new Vector3D(1,0,0),new Vector3D(0,1,0));@@ -272,10 +311,16 @@ public static class CombinedTopBoundaryEdgeFinishThroughHoleBuilder{if ((hole.CounterboreRadius is null) != (hole.CounterboreDepth is null))return Failure($"CombinedFeaturePlanChainInvalid: counterbore '{hole.FeatureId}' requires both radius and depth.");+ if ((hole.CountersinkRadius is null) != (hole.CountersinkAngleDegrees is null) || hole.IsCounterbore && hole.IsCountersink)+ return Failure($"CombinedFeaturePlanChainInvalid: countersink '{hole.FeatureId}' requires one entry radius and included angle, without counterbore fields.");if (!double.IsFinite(hole.CenterX) || !double.IsFinite(hole.CenterY) || !double.IsFinite(hole.Radius) || hole.Radius <= Tol)return Failure($"CombinedFeaturePlanChainInvalid: hole '{hole.FeatureId}' has invalid cylinder data.");if (hole.IsCounterbore && (hole.CounterboreRadius is not { } cr || !double.IsFinite(cr) || hole.CounterboreDepth is not { } cd || !double.IsFinite(cd) || cr <= hole.Radius + Tol || cd <= Tol || hole.CounterboreDepth >= plan.ZMax-plan.ZMin-Tol))return Failure($"CombinedFeaturePlanChainInvalid: counterbore '{hole.FeatureId}' has invalid relief dimensions.");+ if (hole.IsCountersink && (hole.CountersinkRadius is not { } sr || !double.IsFinite(sr) || sr <= hole.Radius + Tol+ || hole.CountersinkAngleDegrees is not { } angle || !double.IsFinite(angle) || angle <= 0d || angle >= 180d+ || hole.ReliefDepth is not { } depth || !double.IsFinite(depth) || depth <= Tol || depth >= plan.ZMax-plan.ZMin-Tol))+ return Failure($"CombinedFeaturePlanChainInvalid: countersink '{hole.FeatureId}' must have a finite relief entirely above a positive shaft span.");if (System.Math.Abs(hole.CenterX) + hole.EntryRadius >= plan.Width / 2d - plan.FinishSize - Tol || System.Math.Abs(hole.CenterY) + hole.EntryRadius >= plan.Depth / 2d - plan.FinishSize - Tol)return Failure($"CombinedFeatureInteractionUnsupported: hole '{hole.FeatureId}' intersects or splits the selected outer top-boundary finish band; move the hole inward or reduce its entry radius or the finish size.");}diff --git a/Aetheris.Kernel.Firmament.Tests/CombinedCountersinkTests.cs b/Aetheris.Kernel.Firmament.Tests/CombinedCountersinkTests.csnew file mode 100644index 00000000..7e4a443c--- /dev/null+++ b/Aetheris.Kernel.Firmament.Tests/CombinedCountersinkTests.cs@@ -0,0 +1,147 @@+using Aetheris.Kernel.Core.Brep;+using Aetheris.Kernel.Core.Brep.Verification;+using Aetheris.Kernel.Core.Geometry;+using Aetheris.Kernel.Core.Step242;+using Aetheris.Kernel.Firmament.FirmamentV2;+using Aetheris.Kernel.Firmament.Materializer;++namespace Aetheris.Kernel.Firmament.Tests;++public sealed class CombinedCountersinkTests+{+ private static string Source(string name) => FirmamentCorpusHarness.ReadFixtureText($"fixtures/Regression/CombinedFeatures/{name}.firmament");++ [Theory]+ [InlineData("Fillet", 60d)]+ [InlineData("Fillet", 90d)]+ [InlineData("Fillet", 120d)]+ [InlineData("Chamfer", 60d)]+ [InlineData("Chamfer", 90d)]+ [InlineData("Chamfer", 120d)]+ public void CountersinkRetainsItsConeShaftAndEngineeringVolume(string kind, double angle)+ {+ var source = Source("countersink-fillet").Replace("90deg", $"{angle}deg")+ .Replace("kind: Fillet; radius:", $"kind: {kind}; {(kind == "Fillet" ? "radius" : "distance")}:");+ var result = FirmamentBuildAndExport.CompileSource(source);+ Assert.True(result.IsSuccess, string.Join(';', result.Diagnostics.Select(d => d.Message)));+ var report = FirmamentBuildAdmissionValidation.Admit(FirmamentV2ValidationReportBuilder.Build(FirmamentV2Parser.Parse(source)), source);+ Assert.Equal("valid", report.Status);+ Assert.Equal("Built", report.ValidationLevel);+ var imported = Step242Importer.ImportBody(result.Value.StepText);+ Assert.True(imported.IsSuccess);+ var body = imported.Value;+ Assert.Equal(12, body.Topology.Faces.Count());+ var cone = Assert.Single(body.Geometry.Surfaces, s => s.Value.Kind == SurfaceGeometryKind.Cone).Value.Cone!.Value;+ Assert.Equal(angle * Math.PI / 360d, cone.SemiAngleRadians, 12);+ var depth = 3 / Math.Tan(angle * Math.PI / 360d);+ Assert.Equal(10 - depth, cone.PlacementOrigin.Z, 9);+ Assert.Equal(3d, cone.PlacementRadius, 9);+ Assert.True(BrepExportPreflight.Validate(body).IsValid);+ Assert.True(result.Value.Combined!.ReimportedManifold);+ var host = kind == "Fillet" ? 24000 - 200 * (1 - Math.PI / 4) + 4 * (5d / 3 - Math.PI / 2)+ : 60 * 40 * 9 + (2400d + 4 * 59 * 39 + 58 * 38) / 6d;+ var removed = Math.PI * 9 * 10 + Math.PI * depth / 3 * (36 + 18 - 18);+ Assert.Equal(host - removed, result.Value.Combined!.FinalAnalyticVolume, 8);+ // The interactive verifier defaults to sixteen segments; use an+ // independent, finer boundary estimate for engineering-volume proof.+ var mass = BrepMassProperties.Evaluate(body, new(.01, Math.PI / 90, .01, MinimumSegments: 64, MaximumSegments: 256));+ Assert.True(mass.IsEnclosed);+ Assert.InRange(mass.AbsoluteVolume, (host - removed) * .9999, (host - removed) * 1.0001);+ var feature = Assert.Single(result.Value.Features!);+ Assert.Equal(1, feature.ConicalFaces);+ Assert.Equal(1, feature.CylindricalFaces);+ var walls = result.Value.RuntimeCorrespondence!.Descendants.Where(d => d.Role == SemanticTopologyRole.HoleWallFace).ToArray();+ Assert.Equal(2, walls.Length);+ Assert.Contains(walls, d => result.Value.RuntimeBody!.GetFaceSurface(d.Face!.Value).Kind == SurfaceGeometryKind.Cone);+ Assert.Equal(result.Value.StepText, FirmamentBuildAndExport.CompileSource(source).Value.StepText);+ }++ [Theory]+ [InlineData("center: Point2(0mm, 0mm)", "center: Point2(25mm, 0mm)")]+ [InlineData("countersinkAngle: 90deg", "countersinkAngle: 20deg")]+ [InlineData("end: ThroughAll", "end: Blind(8mm)")]+ [InlineData("on: +Z", "on: -Z")]+ public void UnsupportedInteractionsRejectAtTheFeature(string oldText, string newText)+ {+ var source = Source("countersink-fillet").Replace(oldText, newText);+ var result = FirmamentBuildAndExport.CompileSource(source);+ Assert.False(result.IsSuccess);+ var diagnostics = result.Diagnostics.Select(d => FirmamentBuildAdmissionValidation.Present(d, "test.firmament", source));+ Assert.All(diagnostics, d => Assert.True(d.Line > 1, d.Message));+ var report = FirmamentBuildAdmissionValidation.Admit(FirmamentV2ValidationReportBuilder.Build(FirmamentV2Parser.Parse(source)), source);+ Assert.Equal("invalid", report.Status);+ }++ [Fact]+ public void MixedHoleStacksKeepEachFeatureAndItsCorrespondence()+ {+ var source = Source("countersink-fillet").Replace(" EdgeFinish", """+ Hole<Shaft> Plain { on: +Z; center: [-15mm,0mm]; diameter: 4mm; end: ThroughAll }+ Hole<Counterbore> Bore { on: +Z; center: [15mm,0mm]; diameter: 3mm; counterboreDiameter: 8mm; counterboreDepth: 2mm; end: ThroughAll }+ EdgeFinish+ """.TrimEnd());+ var built = FirmamentBuildAndExport.CompileSource(source);+ Assert.True(built.IsSuccess, string.Join(';', built.Diagnostics.Select(d => d.Message)));+ Assert.Equal(3, built.Value.Features!.Count);+ var descendants = built.Value.RuntimeCorrespondence!.Descendants;+ Assert.Equal(3, descendants.Count(d => d.Role == SemanticTopologyRole.HoleEntryLoop));+ Assert.Equal(3, descendants.Count(d => d.Role == SemanticTopologyRole.HoleExitLoop));+ foreach (var feature in built.Value.Features)+ {+ var walls = descendants.Where(d => d.Role == SemanticTopologyRole.HoleWallFace && d.ParentStableId == feature.FeatureId).ToArray();+ Assert.Equal(feature.CylindricalFaces + feature.ConicalFaces, walls.Length);+ Assert.Equal(feature.ConicalFaces, walls.Count(w => built.Value.RuntimeBody!.GetFaceSurface(w.Face!.Value).Kind == SurfaceGeometryKind.Cone));+ }+ var host = 24000 - 200 * (1 - Math.PI / 4) + 4 * (5d / 3 - Math.PI / 2);+ var removed = Math.PI * (9 + 4 + 2.25) * 10 + Math.PI * 36 + Math.PI * (16 - 2.25) * 2;+ Assert.Equal(host - removed, built.Value.Combined!.FinalAnalyticVolume, 8);+ }++ [Fact]+ public void CountersinkFinishPreservesExplicitAp242DiameterPmi()+ {+ var source = FirmamentCorpusHarness.ReadFixtureText("fixtures/Canonical/PMI/multiple-hole-dimensions-with-chamfer.firmament")+ .Replace("Hole<Shaft> MountLeft {", "Hole<Countersink> MountLeft { CountersinkDiameter: 12mm CountersinkAngle: 90deg");+ var build = FirmamentBuildAndExport.CompileSource(source);+ Assert.True(build.IsSuccess, string.Join(';', build.Diagnostics.Select(d => d.Message)));+ var pmi = Step242SemanticPmiInspector.Inspect(build.Value.StepText);+ Assert.True(pmi.Success);+ Assert.Equal(1, pmi.DatumCount);+ Assert.Equal(2, pmi.DimensionCount);+ Assert.Equal(2, build.Value.DimensionInspection!.Count);+ Assert.All(build.Value.DimensionInspection!, dimension => Assert.Equal(8d, dimension.Value));+ Assert.Equal(1, build.Value.Features!.Sum(f => f.ConicalFaces));+ }++ [Theory]+ [InlineData(true)]+ [InlineData(false)]+ public void TwoMaterialBodiesCannotSilentlyExportOnlyTheLast(bool features)+ {+ var source = Source("two-bodies");+ if (!features) source = source[..source.IndexOf(" Modify Base", StringComparison.Ordinal)] + "}";+ var build = FirmamentBuildAndExport.CompileSource(source);+ Assert.False(build.IsSuccess);+ var diagnostic = Assert.Single(FirmamentLanguageAnalysisService.Analyze(source, "two.firmament", "1").Diagnostics);+ Assert.Equal("firmament-v2-multiple-material-bodies-unsupported", diagnostic.Code);+ Assert.Equal(source.IndexOf("Box Extra", StringComparison.Ordinal), diagnostic.Start);+ Assert.Contains("Assembly", diagnostic.Message);+ var report = FirmamentBuildAdmissionValidation.Admit(FirmamentV2ValidationReportBuilder.Build(FirmamentV2Parser.Parse(source)), source);+ Assert.Equal("invalid", report.Status);+ }++ [Fact]+ public void CompatibilitySpellingRejectsIndependentBodiesButKeepsRecordDerivation()+ {+ var source = Source("two-bodies-compatibility");+ var rejected = FirmamentBuildAndExport.CompileSource(source);+ Assert.False(rejected.IsSuccess);+ var diagnostic = Assert.Single(FirmamentLanguageAnalysisService.Analyze(source, "two.firmament", "1").Diagnostics);+ Assert.Equal("firmament-v2-multiple-material-bodies-unsupported", diagnostic.Code);+ Assert.Equal(source.IndexOf("solid Extra", StringComparison.Ordinal), diagnostic.Start);+ var legitimate = FirmamentCorpusHarness.ReadFixtureText("fixtures/Regression/RecordDerivation/valid/box-with-size-variant-v2.valid.firmfixture");+ var derived = FirmamentBuildAndExport.CompileSource(legitimate);+ Assert.True(derived.IsSuccess, string.Join(';', derived.Diagnostics.Select(d => d.Message)));+ Assert.Equal(2, FirmamentV2Parser.Parse(legitimate).Document!.Solids.Count);+ }+}diff --git a/Aetheris.Kernel.Firmament.Tests/FirmamentLanguagePaletteTests.cs b/Aetheris.Kernel.Firmament.Tests/FirmamentLanguagePaletteTests.csindex cdd25090..93c0134e 100644--- a/Aetheris.Kernel.Firmament.Tests/FirmamentLanguagePaletteTests.cs+++ b/Aetheris.Kernel.Firmament.Tests/FirmamentLanguagePaletteTests.cs@@ -25,12 +25,20 @@ public sealed class FirmamentLanguagePaletteTests"feature" => new FirmamentLanguageEditOperation("insertFeature") { Node = "PaletteHost/Plate", Source = item.Source, Name = item.NameStem + "1" },_ => throw new InvalidOperationException(item.Placement)};- var edit = FirmamentLanguageEditService.Apply(Host, "host.firmament", "1", [operation]);+ var host = item.RequiresEmptyModel ? "Model PaletteHost {\n Units: mm\n}\n" : Host;+ var edit = FirmamentLanguageEditService.Apply(host, "host.firmament", "1", [operation]);Assert.Single(edit.Nodes);Assert.EndsWith("/" + item.NameStem + "1", edit.Nodes[0], StringComparison.Ordinal);var build = FirmamentBuildAndExport.CompileSource(edit.Text);Assert.True(build.IsSuccess, $"{item.Id} did not build:\n{edit.Text}\n{string.Join("\n", build.Diagnostics.Select(d => d.Message))}");+ if (item.RequiresEmptyModel)+ {+ var occupied = FirmamentLanguageEditService.Apply(Host, "host.firmament", "1", [operation]);+ var rejected = FirmamentBuildAndExport.CompileSource(occupied.Text);+ Assert.False(rejected.IsSuccess);+ Assert.Contains(rejected.Diagnostics, d => d.Message.Contains("multiple-material-bodies-unsupported", StringComparison.Ordinal));+ }}[Theory]@@ -47,20 +55,20 @@ public sealed class FirmamentLanguagePaletteTestsAssert.True(build.IsSuccess, $"{first} + {second} did not build:\n{edit.Text}\n{string.Join("\n", build.Diagnostics.Select(d => d.Message))}");}- /// <summary>Current kernel limit, pinned so it is noticed when it lifts: the combined hole and- /// edge-finish route admits only shaft or counterbore through holes from the top face.</summary>- [Fact]- public void CountersinkWithAnEdgeFinish_IsRefusedByTheCombinedRouteForNow()+ [Theory]+ [InlineData("chamfer")]+ [InlineData("fillet")]+ public void CountersinkWithAnEdgeFinish_BuildsThroughThePalette(string finish){var items = FirmamentLanguagePaletteService.Palette().Items;var edit = FirmamentLanguageEditService.Apply(Host, "host.firmament", "1",[new("insertFeature") { Node = "PaletteHost/Plate", Source = items.Single(i => i.Id == "countersink").Source },- new("insertFeature") { Node = "PaletteHost/Box:Plate", Source = items.Single(i => i.Id == "chamfer").Source },+ new("insertFeature") { Node = "PaletteHost/Box:Plate", Source = items.Single(i => i.Id == finish).Source },]);var build = FirmamentBuildAndExport.CompileSource(edit.Text);- Assert.False(build.IsSuccess);- Assert.Contains(build.Diagnostics, d => d.Message.Contains("CombinedFeaturePlanChainInvalid", StringComparison.Ordinal));+ Assert.True(build.IsSuccess, string.Join(';', build.Diagnostics.Select(d => d.Message)));+ Assert.Equal(1, Assert.Single(build.Value.Features!).ConicalFaces);}[Fact]diff --git a/Aetheris.Kernel.Firmament.Tests/SemanticAuthorityConvergenceTests.cs b/Aetheris.Kernel.Firmament.Tests/SemanticAuthorityConvergenceTests.csindex 18d94e40..08e3ee44 100644--- a/Aetheris.Kernel.Firmament.Tests/SemanticAuthorityConvergenceTests.cs+++ b/Aetheris.Kernel.Firmament.Tests/SemanticAuthorityConvergenceTests.cs@@ -64,7 +64,7 @@ public sealed class SemanticAuthorityConvergenceTestsAssert.True(build.IsSuccess,string.Join("; ",build.Diagnostics.Select(x=>x.Message)));Assert.Equal("CombinedHoleEdgeFinish",build.Value!.Combined!.Route);var bottomArea=10d*15d;var topArea=8d*13d;- var chamferedHost=bottomArea*19d+(bottomArea+topArea+Math.Sqrt(bottomArea*topArea))/3d;+ var chamferedHost=bottomArea*19d+(bottomArea+4d*9d*14d+topArea)/6d;var expected=chamferedHost-Math.PI*2d*2d*20d-Math.PI*(3.5d*3.5d-2d*2d)*3d;Assert.Equal(expected,build.Value.Combined.FinalAnalyticVolume,6);var imported=Step242Importer.ImportBody(build.Value.StepText);Assert.True(imported.IsSuccess,string.Join("; ",imported.Diagnostics.Select(x=>x.Message)));diff --git a/Aetheris.Kernel.Firmament/FirmamentBuildAndExport.cs b/Aetheris.Kernel.Firmament/FirmamentBuildAndExport.csindex 5de51e86..75d27036 100644--- a/Aetheris.Kernel.Firmament/FirmamentBuildAndExport.cs+++ b/Aetheris.Kernel.Firmament/FirmamentBuildAndExport.cs@@ -1365,21 +1365,21 @@ public static class FirmamentBuildAndExportreturn null;}- if (document.Solids.Count != 1 || modifies.Count != 1 || modifies[0].Regions.Count != 0 || modifies[0].TargetSolid != document.Solids[0].Name)+ if (modifies.Count != 1 || modifies[0].Regions.Count != 0){- return CombinedFailure("CombinedFeatureHostUnsupported: CombinedHoleEdgeFinish requires one Box host and one empty-of-Regions Modify context.");+ return CombinedFailure("CombinedFeatureHostUnsupported: Put the holes and one top-boundary finish in one Modify on a Box, without Region operations.", sourceSpan: holesDeclared[0].SourceSpan);}var modify = modifies[0];- var solid = document.Solids[0];- if (solid.Primitive is not FirmamentV2BoxRecord box || box.Size.Count != 3)+ var solid = document.Solids.SingleOrDefault(s => s.Name == modify.TargetSolid);+ if (solid is not { Primitive: FirmamentV2BoxRecord box } || box.Size.Count != 3){- return CombinedFailure($"CombinedFeatureHostUnsupported: host '{solid.Name}' is not an admitted Box.");+ return CombinedFailure($"CombinedFeatureHostUnsupported: Modify target '{modify.TargetSolid}' must resolve to an admitted Box for combined holes and a boundary finish.", sourceSpan: solid?.SourceSpan ?? holesDeclared[0].SourceSpan);}if (finishes.Length != 1){- return CombinedFailure($"CombinedFeatureThirdFamilyUnsupported: CombinedHoleEdgeFinish X1 admits exactly one EdgeFinish (actual={finishes.Length}).");+ return CombinedFailure($"CombinedFeatureThirdFamilyUnsupported: This Box plan admits one top-boundary EdgeFinish (actual={finishes.Length}).", sourceSpan: finishes[1].SourceSpan);}var finish = finishes[0];@@ -1392,7 +1392,7 @@ public static class FirmamentBuildAndExportvar holes = FirmamentV2SemanticHoleLowering.LowerSemanticHoles(document);if (holes.Count != holesDeclared.Length || holes.Count == 0){- return CombinedFailure("CombinedFeaturePlanChainInvalid: semantic Hole lowering did not preserve the admitted source hole set.");+ return CombinedFailure("CombinedFeaturePlanChainInvalid: semantic Hole lowering did not preserve the admitted source hole set.", sourceSpan: holesDeclared[0].SourceSpan);}// Hole is intentionally the first construction stage. Existing materialization@@ -1409,14 +1409,17 @@ public static class FirmamentBuildAndExport}var combinedHoles = new List<CombinedTopBoundaryEdgeFinishThroughHole>(holes.Count);- foreach (var (hole, stage) in holes.Zip(holeStages))+ for (var i = 0; i < holes.Count; i++){- if (hole.EndCondition is not AirHoleEndCondition.ThroughAll || hole.Stack.Kind is not (AirHoleStackKind.SimpleShaft or AirHoleStackKind.Counterbore) || hole.Placement is not AirFaceLocalHolePlacement placement || hole.Axis.Direction.Z < 1d - 1e-9)+ var hole = holes[i];+ if (hole.EndCondition is not AirHoleEndCondition.ThroughAll || hole.Stack.Kind is not (AirHoleStackKind.SimpleShaft or AirHoleStackKind.Counterbore or AirHoleStackKind.Countersink) || hole.Placement is not AirFaceLocalHolePlacement placement || hole.Axis.Direction.Z < 1d - 1e-9){- return CombinedFailure($"CombinedFeaturePlanChainInvalid: Hole '{hole.FeatureId}' is outside the shared combined route; only top/+Z shaft or counterbore ThroughAll holes are admitted.");+ return CombinedFailure($"CombinedFeaturePlanChainInvalid: Hole '{hole.FeatureId}' cannot share this boundary finish. Use a top/+Z ThroughAll shaft, counterbore or countersink; blind and side-entry combined holes are not admitted.", sourceSpan: holesDeclared[i].SourceSpan);}var counterbore=hole.Stack.Components.OfType<AirHoleCounterboreComponent>().SingleOrDefault();- combinedHoles.Add(new CombinedTopBoundaryEdgeFinishThroughHole(hole.FeatureId, placement.U, placement.V, hole.Shaft.Radius,counterbore?.Radius,counterbore?.Depth));+ var countersink = hole.Stack.Components.OfType<AirHoleCountersinkComponent>().SingleOrDefault();+ combinedHoles.Add(new CombinedTopBoundaryEdgeFinishThroughHole(hole.FeatureId, placement.U, placement.V, hole.Shaft.Radius,+ counterbore?.Radius,counterbore?.Depth,countersink?.EntryDiameter / 2d,countersink?.AngleDegrees));}// Preserve the existing chamfer admission and realization unchanged. Fillet@@ -1487,6 +1490,8 @@ public static class FirmamentBuildAndExportdescendants.Add(new($"combined:{source}:counterbore-wall", "Face", SemanticTopologyRole.HoleWallFace, source, Face: new FaceId(wallFaceId++), ParentStableId: holes[i].FeatureId));wallFaceId++; // annular shoulder, not a shaft wall}+ if (combinedHoles[i].IsCountersink)+ descendants.Add(new($"combined:{source}:countersink-wall", "Face", SemanticTopologyRole.HoleWallFace, source, Face: new FaceId(wallFaceId++), ParentStableId: holes[i].FeatureId));descendants.Add(new($"combined:{source}:shaft-wall", "Face", SemanticTopologyRole.HoleWallFace, source, Face: new FaceId(wallFaceId++), ParentStableId: holes[i].FeatureId));}for (var side = 0; side < 4; side++)@@ -1498,8 +1503,7 @@ public static class FirmamentBuildAndExportreturn CombinedFailure("CombinedFeaturePlanChainInvalid: final plan lost Hole mouth or exit correspondence.");}- var holeRemoved = combinedHoles.Sum(h => System.Math.PI * h.Radius * h.Radius * (host.ZMax - host.ZMin)- +(h.CounterboreRadius is { } reliefRadius&&h.CounterboreDepth is { } reliefDepth?System.Math.PI*(reliefRadius*reliefRadius-h.Radius*h.Radius)*reliefDepth:0d));+ var holeRemoved = combinedHoles.Sum(h => h.RemovedVolume(host.ZMax - host.ZMin));var report = new FirmamentCombinedFeaturePlanReport("CombinedHoleEdgeFinish", "Succeeded", finalPlan.ParentHostPlanId!, finalPlan.AppliedFeatureIds, finalPlan.PlanId, "Disjoint",descendants.Count(d => d.SourceStableId.StartsWith("hole:", StringComparison.Ordinal)),@@ -1507,7 +1511,7 @@ public static class FirmamentBuildAndExportbox.Size[0] * box.Size[1] * (host.ZMax - host.ZMin), holeRemoved, finalPlan.AnalyticVolume,Convert.ToHexString(SHA256.HashData(Encoding.UTF8.GetBytes(step.Value))), body.Topology.Vertices.Count(), body.Topology.Edges.Count(), body.Topology.Faces.Count(),body.Geometry.Surfaces.Count(s => s.Value.Kind == SurfaceGeometryKind.Plane), body.Geometry.Surfaces.Count(s => s.Value.Kind == SurfaceGeometryKind.Cylinder), true, true);- var featureReports = holes.Select(h => new FirmamentHoleFeatureReport(h.Name, "Hole", h.FeatureId, h.Shaft.Diameter, h.Placement.U, h.Placement.V, null, null, null, null, "top", null, nameof(AirHoleSimpleShaftMaterializer), "HoleChangedBRepPlan", h.Stack.Kind.ToString(), "CombinedHoleEdgeFinish", h.Stack.Kind==AirHoleStackKind.Counterbore?2:1, 0, h.Stack.Kind==AirHoleStackKind.Counterbore?1:0, report.StepSha256, true)).ToArray();+ var featureReports = holes.Select(h => new FirmamentHoleFeatureReport(h.Name, "Hole", h.FeatureId, h.Shaft.Diameter, h.Placement.U, h.Placement.V, null, null, null, null, "top", null, nameof(AirHoleSimpleShaftMaterializer), "HoleChangedBRepPlan", h.Stack.Kind.ToString(), "CombinedHoleEdgeFinish", h.Stack.Kind==AirHoleStackKind.Counterbore?2:1, h.Stack.Kind==AirHoleStackKind.Countersink?1:0, h.Stack.Kind==AirHoleStackKind.Counterbore?1:0, report.StepSha256, true)).ToArray();return KernelResult<FirmamentStepExportResult>.Success(new FirmamentStepExportResult(step.Value,document.ModelName,diff --git a/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentLanguagePalette.cs b/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentLanguagePalette.csindex ce40ddfe..d45109f5 100644--- a/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentLanguagePalette.cs+++ b/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentLanguagePalette.cs@@ -5,7 +5,7 @@ namespace Aetheris.Kernel.Firmament.FirmamentV2;/// inserted with <c>insertFeature</c>). <c>Source</c> is one declaration named <c>NameStem</c>; editors/// pass a unique name with the insert.</summary>public sealed record FirmamentPaletteItem(string Id, string Label, string Category, string Description,- string Placement, string NameStem, string Source);+ string Placement, string NameStem, string Source, bool RequiresEmptyModel = false);public sealed record FirmamentLanguagePalette(string Version, IReadOnlyList<FirmamentPaletteItem> Items);@@ -22,9 +22,9 @@ public static class FirmamentLanguagePaletteServiceprivate static readonly FirmamentPaletteItem[] Catalog =[new("box", "Box", "Bodies", "A rectangular block, centered on the origin.", "model", "Block",- "Box Block { Size: [40mm, 30mm, 10mm] }"),+ "Box Block { Size: [40mm, 30mm, 10mm] }", RequiresEmptyModel: true),new("cylinder", "Cylinder", "Bodies", "A round bar standing on the XY plane.", "model", "Bar",- "Cylinder Bar { Radius: 10mm Height: 20mm }"),+ "Cylinder Bar { Radius: 10mm Height: 20mm }", RequiresEmptyModel: true),new("hole", "Hole", "Holes", "A drilled through hole from the top face.", "feature", "Hole","Hole<Shaft> Hole { On: +Z Center: Point2(0mm, 0mm) Diameter: 6mm End: ThroughAll }"),diff --git a/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2MechanicalBinding.cs b/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2MechanicalBinding.csindex e5fff8f4..b3f65b02 100644--- a/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2MechanicalBinding.cs+++ b/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2MechanicalBinding.cs@@ -19,6 +19,20 @@ public static partial class FirmamentV2Parserinternal static bool IsPrimitiveDeclaration(DeclarationSyntax d) => d.Type.Name.Text is"Box" or "Cylinder" or "Cone" or "Sphere" or "Torus" or "RoundedBox" or "Frustum" or "StandardPart" or "ExactCoaxialPart";+ private static FirmamentV2ParseResult? RejectMultipleMaterialBodies(IReadOnlyList<DeclarationSyntax> bodies,+ string model, List<string> diagnostics)+ {+ if (bodies.Count <= 1) return null;+ const string code = "firmament-v2-multiple-material-bodies-unsupported";+ diagnostics.Add(code);+ return CanonicalFailure(diagnostics, CanonicalDocumentMalformed) with+ {+ SyntaxDiagnostics = [new(code, "fatal",+ $"Model '{model}' declares {bodies.Count} material bodies ({string.Join(", ", bodies.Select(d => d.Name?.Text))}). The current Model exporter admits one body. Use separate Parts in an Assembly for separate objects, or Compose for admitted material operations on one body.")+ { SourceSpan = bodies[1].Span, Stage = "Capability" }]+ };+ }+/// <summary>Mechanical syntax has one owner. Selection of a material lowerer/// follows declared material bodies; unused construction data cannot select a grammar.</summary>private static FirmamentV2ParseResult BindMechanicalModel(DocumentSyntax syntax, DeclarationSyntax model,@@ -28,6 +42,8 @@ public static partial class FirmamentV2Parserif (model.Body is null || model.Name is null) return CanonicalFailure(diagnostics, CanonicalDocumentMalformed);if (model.Clauses.Count > 0 || model.Type.Arguments.Count > 0)return CanonicalFailure(diagnostics, "firmament-v2-mechanical-root-header-unsupported: Use the admitted Model/Struct header and declare placement in its owning construct.");+ var materialBodies = MechanicalDeclarations(model.Body.Statements).Where(d => IsPrimitiveDeclaration(d) || d.Type.Name.Text == "InlineStep").ToArray();+ if (RejectMultipleMaterialBodies(materialBodies, model.Name.Text, diagnostics) is { } rejectedBodies) return rejectedBodies;if (model.Annotation is not null){if (syntax.Statements.Concat(model.Body.Statements).OfType<DeclarationSyntax>().Any(d => d.Type.Name.Text == "Static"))diff --git a/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2Parser.cs b/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2Parser.csindex 04a78f1a..800c38c7 100644--- a/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2Parser.cs+++ b/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2Parser.cs@@ -613,6 +613,16 @@ public static partial class FirmamentV2Parserif (compatibilityCore) diagnostics.AddRange(syntax.Diagnostics.Select(d => d.Code));var byName = BindCompatibilitySolids(syntax, compatibilityModel, source, sourceDirectory, diagnostics);+ // A referenced record prototype is compile-time data, not another output+ // body. Preserve legitimate `with` derivation while rejecting unrelated+ // material that the last-body exporter would otherwise discard.+ var prototypes = byName.Values.Select(s => s.DerivedFrom).OfType<string>().ToHashSet(StringComparer.Ordinal);+ var outputs = byName.Keys.Where(name => !prototypes.Contains(name)).ToHashSet(StringComparer.Ordinal);+ if (v2AdmissionCandidate && compatibilityModel?.Body is { } compatibilityBody &&+ RejectMultipleMaterialBodies(compatibilityBody.Statements.OfType<DeclarationSyntax>()+ .Where(d => d.Type.Name.Text == "solid" && d.Name is not null && outputs.Contains(d.Name.Text)).ToArray(),+ compatibilityModel.Name?.Text ?? "<unnamed>", diagnostics) is { } rejectedBodies)+ return rejectedBodies with { ParserRoute = compatibilityCore ? "UnifiedCompatibility" : "CompatibilityExtensions", OwnsUnifiedAdmission = compatibilityCore, BoundSource = source, DiagnosticSource = source };var solids = byName.Values.ToList();var appearsStandaloneLattice = compatibilityModel?.Body?.Statements.OfType<DeclarationSyntax>().Any(d => d.Type.Name.Text == "fill") == true;if (solids.Count == 0 && !appearsStandaloneLattice) diagnostics.Add(MissingSolid);diff --git a/Aetheris.Web.Runtime/sdk/README.md b/Aetheris.Web.Runtime/sdk/README.mdindex 48fd759c..39bc4e08 100644--- a/Aetheris.Web.Runtime/sdk/README.md+++ b/Aetheris.Web.Runtime/sdk/README.md@@ -85,6 +85,12 @@ decision.(`firmament-palette/1`): bodies (`placement: 'model'`) and features on a body(`placement: 'feature'`), each a declaration `source` with starting values.Every item is proven to build by the kernel's tests.+Body starters have `requiresEmptyModel: true`: they start a Model without an+existing material body. Separate objects belong in Parts of an Assembly;+adding an independent second body to an occupied Model rejects at that+declaration. A referenced legacy `with` prototype is compile-time data and+does not count as a second output body. Hole centers remain explicit source+values; the palette does not invent non-overlapping placements.Production AOT preserves the semantic provenance record metadata used by thereflection JSON bridge. Package generation clears its owned AOT publish outputdiff --git a/Aetheris.Web.Runtime/sdk/src/index.d.ts b/Aetheris.Web.Runtime/sdk/src/index.d.tsindex 2e58056d..c628ecfd 100644--- a/Aetheris.Web.Runtime/sdk/src/index.d.ts+++ b/Aetheris.Web.Runtime/sdk/src/index.d.ts@@ -54,7 +54,7 @@ export type LanguageEditOperation =/** The edited source and the single replacement `[start, start + length)` → `replacement` that produces it from the original. `nodes` holds the outline id each operation left behind (created, renamed or edited), in order; removals add none. */export interface LanguageEdit { readonly document: string; readonly revision: string; readonly text: string; readonly changed: boolean; readonly edit: { readonly start: number; readonly length: number; readonly replacement: string }; readonly nodes: readonly string[]; readonly warnings: readonly string[] }/** Something a visual editor can add. `placement` `model` inserts with `insertDeclaration`; `feature` with `insertFeature` on a body. `source` declares `nameStem`; pass a unique `name` with the insert. Every item is proven to build. */-export interface PaletteItem { readonly id: string; readonly label: string; readonly category: string; readonly description: string; readonly placement: 'model' | 'feature'; readonly nameStem: string; readonly source: string }+export interface PaletteItem { readonly id: string; readonly label: string; readonly category: string; readonly description: string; readonly placement: 'model' | 'feature'; readonly nameStem: string; readonly source: string; readonly requiresEmptyModel?: boolean }export interface LanguagePalette { readonly version: 'firmament-palette/1'; readonly items: readonly PaletteItem[] }export interface LanguageHover { readonly document: string; readonly revision: string; readonly start: number; readonly length: number; readonly title: string; readonly description: string }export interface LanguageFormat { readonly document: string; readonly revision: string; readonly text: string; readonly changed: boolean }diff --git a/docs/public/firmament/syntax.md b/docs/public/firmament/syntax.mdindex 391af422..943033ec 100644--- a/docs/public/firmament/syntax.md+++ b/docs/public/firmament/syntax.md@@ -482,6 +482,13 @@ base material interval and admitted operations inside it. Compose does notreopen a separately declared Box, and neither construct admits arbitrary Booleanor feature combinations.+The current engineering exporter admits one material body per Model. A second+Box, Cylinder or other material body is rejected at its declaration, even if+the bodies have no Modify operations. It is never silently discarded. Use+separate Parts in an Assembly for separate objects, or the admitted Compose+operations for material belonging to one body. Palette body entries marked+`requiresEmptyModel` start an empty Model; feature entries operate on its body.+In a primitive Model, `Modify Base {}` is a valid no-op once `Base` resolves toan existing body. Deleting its last feature leaves the same stock geometry;an unresolved target still rejects. An empty Modify does not create a feature.@@ -504,13 +511,16 @@ variant applicability from the shared schema.For a Box top-boundary chamfer or fillet, the selector is `face: +Z` plus`target: Boundary`. A fillet uses `radius`; a chamfer uses `distance`.-One such finish can coexist with disjoint top `ThroughAll` shaft or counterbore-holes in the same Modify. The hole entry circles must stay strictly inside the+One such finish can coexist with disjoint top `ThroughAll` shaft, counterbore+or countersink holes in the same Modify. The hole entry circles must stay strictly inside theinset top face. Fillets retain sharp vertical stock corners and join their fourcylindrical blends on exact elliptical seams; this is not a whole-box rounding.A profile-composed finish names its Profile boundary and support instead.The generic variant has the same capability checks as `kind`.A bare `Fillet corners { ... }` is not an alternative EdgeFinish declaration.+For a combined countersink, its conical relief must end above a positive shaft+span. Blind or side-entry holes sharing a boundary finish remain unsupported;+their diagnostic points to the Hole declaration.Read the [feature support and examples](geometry.md) before combining operations.A feature's existence does not imply that every combination is admitted.diff --git a/docs/release/FIRMAMENT-CLAUDE-COMBINED-FEEDBACK.md b/docs/release/FIRMAMENT-CLAUDE-COMBINED-FEEDBACK.mdnew file mode 100644index 00000000..b521ee6c--- /dev/null+++ b/docs/release/FIRMAMENT-CLAUDE-COMBINED-FEEDBACK.md@@ -0,0 +1,123 @@+# Claude combined-feature authoring follow-up++Date: 2026-10-16. Starting commit: `dfff36de`.++Verdict: **Meaningful progression.** The countersink/finish capability and+reported compiler diagnostic gaps are repaired. General multi-body Model+export remains unsupported; its previously silent body loss is now rejected.++## Findings and dispositions++| Report | Current reproduction | Disposition |+| --- | --- | --- |+| A second body breaks a hole-plus-finish Model | Confirmed. The combined route required a single Box in the whole document. More seriously, removing Modify accepted two independent Boxes and exported only the last one. | Independent output bodies now reject at the second declaration in canonical and retained lowercase V2. The diagnostic explains separate Parts in an Assembly and admitted Compose operations. General multi-body Model export remains unsupported. |+| Countersink cannot share Modify with EdgeFinish | Confirmed. The Hole stage materialized correctly, then the combined route excluded its stack kind. | Top/+Z ThroughAll countersinks now compose with a top-boundary chamfer or fillet through the existing final-plan owner. |+| Errors still point to 1:1 | Confirmed for the combined-stack capability rejection: the producer omitted its available Hole span. | The combined rejection now retains the Hole span; host, context and excess-finish rejection also retain the relevant available construct span. The body-cardinality diagnostic is source-located and classified as capability admission. |+| Hole completion is type-blind | Not reproduced in the current compiler/public SDK/WASM. Shaft, Counterbore and Countersink completion and bound-field inspection pass their variant checks. | Retain the previous shared-schema fix and additive `variants` metadata. A schema-driven Helios control must honor that metadata or use compiler completion. This pass does not claim qualification of the deployed Helios UI. |+| Every palette hole begins at the origin | Confirmed by the catalog; this is explicit source, not a compiler placement bug. | Preserve the default. Do not invent a center or silently separate overlapping holes. Face picking and editor placement remain a separate UI decision. |++## Geometry ownership++`CombinedTopBoundaryEdgeFinishThroughHoleBuilder` remains the analytic+materializer. A countersink adds a cone joined to a cylindrical shaft at one+shared throat circle. Its longitudinal seam is a generator with the correct+slant length. No annular counterbore shoulder is substituted for the cone.+The existing AIR Hole materializer still supplies the initial semantic and+host proof, and the same final plan admits the boundary finish.++Admission checks the full entry radius against the inset top face and other+hole entry circles. The derived cone depth must leave a positive shaft span.+Blind holes, side entry, relief reaching the opposite face, overlapping mouths+and contact with the finish band remain explicit rejections.++Source identities, entry/exit loops and cone/shaft wall correspondence survive+mixed shaft, counterbore and countersink stacks. Hole reports distinguish+cylindrical and conical faces. Explicit AP242 HoleDiameter PMI still refers to+the authored shaft diameter, not the countersink mouth diameter.++Volume qualification also found that the existing chamfer report used the+homothetic-frustum formula for unequal rectangular sides. Its report now+integrates `(width - 2t)(depth - 2t)` exactly. This corrects analytic report+values; it does not change the already emitted chamfer BRep or STEP geometry.++## Body admission and compatibility++The source check lives in the existing semantic binder, before a construction+adapter can discard a material declaration. Both modern and lowercase V2 use+the same cardinality diagnostic. A legacy `with` prototype referenced by a+derived record is compile-time input, not a second independent output request;+the existing derivation fixture remains admitted with its two bound records.++The combined feature route selects its actual Modify target instead of assuming+the first bound record is its host. It retains the one-Modify/one-finish family+boundary. No multi-body exporter, source rewriting pass or parser route is added.++The palette's Box and Cylinder entries now carry `requiresEmptyModel: true`.+Their old occupied-host tests had passed through the last-body omission. They+are now tested as empty-Model starters, with explicit rejection checks in+occupied Models. Feature palette entries remain qualified against an existing+Box. The old countersink-refusal test is replaced by positive chamfer and+fillet construction tests. No frozen geometry oracle was changed.++## Qualification++Focused tests passed: **181**. Coverage includes:++- 60°, 90° and 120° countersinks with chamfer and fillet;+- exact cone dimensions and surface families after STEP reimport;+- manifold enclosure and an independent refined boundary-volume estimate;+- mixed-hole identity/correspondence and explicit AP242 PMI;+- unsupported intersections, depth and entry direction with source diagnostics;+- independent second-body rejection and legitimate legacy record derivation;+- current variant-aware completion and semantic field projection.++The real browser/WASM harness passes both countersink finishes, current Hole+variant help, source-located combined rejection, second-body rejection with and+without Modify, and palette body requirements. Its existing seven-time Motion+proof still matches all 1,232 native matrix components exactly and retains the+last-valid graph and shared geometry.++Final qualification:++- Release solution build passed, with existing analyzer/interop warnings.+- Full serial solution suite: **5,229 passed across 20 assemblies, zero failures**.+- Core fast lane: **1,076 passed**. Focused lane: **181 passed**. SDK Node tests:+ **14 passed**.+- Claude authoring corpus: **32/32 passed**, without recording new references.+- Frozen STEP replay: **26/26 byte-identical artifacts**. All nine scoped+ authoring outcomes held.+- Real public-SDK/WASM proof passed both countersink finishes, three Hole+ variants, source-located failures and both second-body rejections. Motion+ parity and last-valid retention remained green.+- Six real CLI validate/build pairs produced their expected outcomes. Accepted+ fillet/countersink STEP has 12 faces: six planes, five cylinders and one cone.+ The entry-at-23.5mm witness, whose mouth stays inside the stock but intersects+ the finish band, rejects with a located interaction diagnostic. Rejected+ inputs emitted no STEP artifact.+- The preserved before-artifact for the two-body plain Model contains just+ the 8 × 6 × 4mm Extra Box, with bounds `[-4,-3,0]..[4,3,4]`; its requested+ 60 × 40 × 10mm Base was absent. The same source now rejects at Extra on line 4.+- Diff checks passed. No task-owned dotnet, testhost or aetheris hosts remained+ at closeout.++Local evidence is under ignored `artifacts/local/claude-combined-feedback/`,+including `full.log`, `focused.log`, `browser.log`, `x4.log`, `cli.json`, the+original CLI failures, before/after geometry inspection and the frozen replay.+Reusable source specimens live under `fixtures/Regression/CombinedFeatures/`.++The code-quality pass kept cardinality in one shared semantic helper, retained+record-prototype dependencies, and kept countersink geometry in the existing+bounded builder. No regex dispatch, global source rewrite, duplicated field+schema or diagnostic-fatality allowlist was introduced.++## Remaining boundary++General multi-body Model authoring has not been implemented. Merely lifting+the old Box-count guard would silently omit another body in the current export+contract. Supporting that feature requires an explicit product/geometry result+that carries every body through display, source identity and interchange.+Independent Parts in an Assembly already have that ownership model.++Helios must consume the refreshed runtime and use the applicability/context+metadata. Its deployed asset selection, viewport failure and future face-pick+placement are not certified by the compiler/WASM qualification here.diff --git a/fixtures/Regression/CombinedFeatures/README.md b/fixtures/Regression/CombinedFeatures/README.mdnew file mode 100644index 00000000..added4cc--- /dev/null+++ b/fixtures/Regression/CombinedFeatures/README.md@@ -0,0 +1,17 @@+# Combined-feature authoring feedback++- `countersink-fillet.firmament`: admitted conical countersink plus top boundary+ fillet. Tests vary the included angle and finish, check analytic geometry and+ independently estimated volume, round-trip STEP, and retain all hole sources.+- `two-bodies.firmament`: unsupported independent material bodies. It must reject+ at Extra, with an Assembly/Compose explanation, rather than silently exporting+ only the last body. Removing Modify must not make it valid.+- `two-bodies-compatibility.firmament`: the same rejected intent in the retained+ lowercase V2 spelling. The existing record-derivation fixture remains admitted:+ its referenced prototype is compile-time data, not another output request.++The original two-body and countersink failures were reproduced with the real CLI.+The old palette countersink refusal test is now a positive chamfer/fillet geometry+test. Body palette entries are qualified in empty Models; insertion into occupied+Models explicitly rejects. Existing source fixtures and frozen geometry references+are not rewritten to accommodate the new capability.diff --git a/fixtures/Regression/CombinedFeatures/countersink-fillet.firmament b/fixtures/Regression/CombinedFeatures/countersink-fillet.firmamentnew file mode 100644index 00000000..3fa3dfbe--- /dev/null+++ b/fixtures/Regression/CombinedFeatures/countersink-fillet.firmament@@ -0,0 +1,15 @@+Model CountersinkFinish {+ units: mm+ Box Base { size: [60mm, 40mm, 10mm] }+ Modify Base {+ Hole<Countersink> Mount {+ on: +Z+ center: Point2(0mm, 0mm)+ diameter: 6mm+ countersinkDiameter: 12mm+ countersinkAngle: 90deg+ end: ThroughAll+ }+ EdgeFinish Finish { face: +Z; target: Boundary; kind: Fillet; radius: 1mm }+ }+}diff --git a/fixtures/Regression/CombinedFeatures/two-bodies-compatibility.firmament b/fixtures/Regression/CombinedFeatures/two-bodies-compatibility.firmamentnew file mode 100644index 00000000..d793687f--- /dev/null+++ b/fixtures/Regression/CombinedFeatures/two-bodies-compatibility.firmament@@ -0,0 +1,5 @@+model TwoBodies {+ units mm+ solid Base: Box { size: [60, 40, 10] }+ solid Extra: Box { size: [8, 6, 4] }+}diff --git a/fixtures/Regression/CombinedFeatures/two-bodies.firmament b/fixtures/Regression/CombinedFeatures/two-bodies.firmamentnew file mode 100644index 00000000..8140d21c--- /dev/null+++ b/fixtures/Regression/CombinedFeatures/two-bodies.firmament@@ -0,0 +1,9 @@+Model TwoBodies {+ units: mm+ Box Base { size: [60mm, 40mm, 10mm] }+ Box Extra { size: [8mm, 6mm, 4mm] }+ Modify Base {+ Hole<Shaft> Mount { on: +Z; center: Point2(0mm, 0mm); diameter: 6mm; end: ThroughAll }+ EdgeFinish Finish { face: +Z; target: Boundary; kind: Fillet; radius: 1mm }+ }+}diff --git a/scripts/qualify-assembly-motion-browser.mts b/scripts/qualify-assembly-motion-browser.mtsindex 462e6f39..a8a9128e 100644--- a/scripts/qualify-assembly-motion-browser.mts+++ b/scripts/qualify-assembly-motion-browser.mts@@ -14,6 +14,8 @@ const fixture = resolve(repo, 'fixtures/Canonical/AssemblyInterfaces/articulatedconst source = await readFile(fixture, 'utf8');const holeSource = await readFile(resolve(repo, 'fixtures/Regression/LanguageService/hole-variant.firmament'), 'utf8');const emptyModifySource = await readFile(resolve(repo, 'fixtures/Regression/LanguageService/empty-modify.firmament'), 'utf8');+const combinedSource = await readFile(resolve(repo, 'fixtures/Regression/CombinedFeatures/countersink-fillet.firmament'), 'utf8');+const twoBodiesSource = await readFile(resolve(repo, 'fixtures/Regression/CombinedFeatures/two-bodies.firmament'), 'utf8');const documents = {'motion.firmament': source,'articulated-subassemblies.firmament': await readFile(resolve(repo, 'fixtures/Canonical/AssemblyInterfaces/articulated-subassemblies.firmament'), 'utf8'),@@ -42,7 +44,7 @@ try {browser = await chromium.launch({ executablePath: 'C:/Program Files (x86)/Microsoft/Edge/Application/msedge.exe', headless: true });const page = await browser.newPage();await page.goto(`http://127.0.0.1:${address.port}/`);- const result = await page.evaluate(async ({ source, documents, times, expected, holeSource, emptyModifySource }) => {+ const result = await page.evaluate(async ({ source, documents, times, expected, holeSource, emptyModifySource, combinedSource, twoBodiesSource }) => {const { Aetheris } = await import('/Aetheris.Web.Runtime/sdk/src/index.js');const cad = await Aetheris.create({ wasmUrl: new URL('/Aetheris.Web.Runtime/bin/Release/net10.0/wwwroot/', location.href) });try {@@ -102,10 +104,30 @@ try {const empty = await cad.compile(emptyModifySource, { sourceName: 'bracket.firmament' });if (!empty.model) throw new Error('Empty Modify rejected: ' + JSON.stringify(empty.diagnostics));await empty.model.dispose();+ const palette = await cad.language.palette();+ if (palette.items.some((item: {placement: string; requiresEmptyModel?: boolean}) => item.placement === 'model' && !item.requiresEmptyModel))+ throw new Error('Body starter lost its empty-Model requirement');+ for (const finish of ['Fillet', 'Chamfer']) {+ const authored = combinedSource.replace('kind: Fillet; radius:', `kind: ${finish}; ${finish === 'Fillet' ? 'radius' : 'distance'}:`);+ const built = await cad.compile(authored, { sourceName: 'combined.firmament' });+ if (!built.model) throw new Error('Countersink finish rejected: ' + JSON.stringify(built.diagnostics));+ try {+ const bad = await built.model.setSource(authored.replace('end: ThroughAll', 'end: Blind(8mm)'));+ if (bad.success || !bad.diagnostics.length || bad.diagnostics.some((d: {source?: {line: number}}) => !d.source || d.source.line <= 1))+ throw new Error('Unsupported combined hole lost its feature location: ' + JSON.stringify(bad.diagnostics));+ } finally { await built.model.dispose(); }+ }+ for (const authored of [twoBodiesSource, twoBodiesSource.slice(0, twoBodiesSource.indexOf(' Modify Base')) + '}']) {+ const rejected = await cad.compile(authored, { sourceName: 'two.firmament' });+ if (rejected.model || !rejected.diagnostics.some((d: {code: string; source?: {start: number}}) =>+ d.code === 'firmament-v2-multiple-material-bodies-unsupported' && d.source?.start === authored.indexOf('Box Extra')))+ throw new Error('Second body was dropped or its rejection lost the declaration span');+ }return { status: 'pass', runtime: 'real browser WASM via public SDK', samples: times.length, compared, maximumError: maximum,- sharedDefinitionsRetained: true, lastValidGraphRetained: true, holeVariants: 3, emptyModify: 'pass', locatedFieldError: 'pass' };+ sharedDefinitionsRetained: true, lastValidGraphRetained: true, holeVariants: 3, emptyModify: 'pass', locatedFieldError: 'pass',+ countersinkFinishes: 2, bodyCardinality: 'rejected at second declaration', paletteBodyRequirement: 'pass' };} finally { await cad.dispose(); }- }, { source, documents, times, expected, holeSource, emptyModifySource });+ }, { source, documents, times, expected, holeSource, emptyModifySource, combinedSource, twoBodiesSource });const output = resolve(repo, 'artifacts/local/v8-relations');await mkdir(output, { recursive: true });await writeFile(resolve(output, 'motion-browser.json'), JSON.stringify(result, null, 2));