Next Gen STEP AP242 Native-ish BREP Geometric Modeling Kernel
Add bounded planar span support semantics
Yuechen Li5161fb1be1d5
diff --git a/Aetheris.CLI.Tests/SurfaceSpanSupportCliTests.cs b/Aetheris.CLI.Tests/SurfaceSpanSupportCliTests.csnew file mode 100644index 00000000..00d65467--- /dev/null+++ b/Aetheris.CLI.Tests/SurfaceSpanSupportCliTests.cs@@ -0,0 +1,105 @@+using System.Text.Json;++namespace Aetheris.CLI.Tests;++public sealed class SurfaceSpanSupportCliTests+{+ private static readonly string RepoRoot = FindRepoRoot();++ [Fact]+ public void InspectSpans_ReportsResolvedSurfaceDomainAndExpandedConsumers()+ {+ var source = Fixture("Canonical", "Span", "plane-hole-support.firmament");+ var stdout = new StringWriter(); var stderr = new StringWriter();+ var exit = Aetheris.CLI.CliRunner.Run(["inspect-spans", source, "--json"], stdout, stderr);++ Assert.Equal(0, exit);+ Assert.True(string.IsNullOrWhiteSpace(stderr.ToString()), stderr.ToString());+ using var json = JsonDocument.Parse(stdout.ToString());+ var span = Assert.Single(json.RootElement.GetProperty("spans").EnumerateArray());+ Assert.Equal("MountingArea", span.GetProperty("spanId").GetString());+ Assert.Equal("TopSupport", span.GetProperty("parentId").GetString());+ Assert.Equal(2880d, span.GetProperty("area").GetDouble(), 8);+ Assert.Equal(4, span.GetProperty("consumerReferences").GetArrayLength());+ Assert.Equal("Valid", span.GetProperty("validity").GetString());+ }++ [Fact]+ public void InspectCompose_ReportsPatternFeatureSpanAndParentSupport()+ {+ var source = Fixture("Canonical", "Span", "plane-hole-support.firmament");+ var stdout = new StringWriter(); var stderr = new StringWriter();+ var exit = Aetheris.CLI.CliRunner.Run(["inspect-compose", source, "--json"], stdout, stderr);++ Assert.Equal(0, exit);+ Assert.True(string.IsNullOrWhiteSpace(stderr.ToString()), stderr.ToString());+ using var json = JsonDocument.Parse(stdout.ToString());+ var holes = json.RootElement.GetProperty("composition").GetProperty("counterboreHoles").EnumerateArray().ToArray();+ Assert.Equal(4, holes.Length);+ Assert.All(holes, hole =>+ {+ var support = hole.GetProperty("support");+ Assert.Equal("Span<Plane>", support.GetProperty("kind").GetString());+ Assert.Equal("MountingArea", support.GetProperty("id").GetString());+ Assert.Equal("TopSupport", support.GetProperty("parent").GetString());+ Assert.True(support.GetProperty("boundaryMargin").GetDouble() > 0d);+ });+ }++ [Fact]+ public void Validate_CrossingPatternInstance_FailsWithTypedMarginDiagnostic()+ {+ var source = Fixture("Invalid", "Span", "plane-hole-footprint-crossing.firmament");+ var stdout = new StringWriter(); var stderr = new StringWriter();+ var exit = Aetheris.CLI.CliRunner.Run(["validate", source, "--json"], stdout, stderr);++ Assert.Equal(1, exit);+ using var json = JsonDocument.Parse(stdout.ToString());+ var diagnostics = json.RootElement.GetProperty("firmamentV2Validation").GetProperty("diagnostics").EnumerateArray();+ Assert.Contains(diagnostics, item => item.GetProperty("code").GetString()!+ .StartsWith("firmament-feature-footprint-outside-span:MountPattern_3:MountingArea", StringComparison.Ordinal));+ }++ [Fact]+ public void Build_CrossingPatternInstance_IsAtomicAndWritesNoStep()+ {+ var output = Path.Combine(Path.GetTempPath(), $"invalid-span-{Guid.NewGuid():N}.step");+ try+ {+ var stdout = new StringWriter(); var stderr = new StringWriter();+ var exit = Aetheris.CLI.CliRunner.Run([+ "build", Fixture("Invalid", "Span", "plane-hole-footprint-crossing.firmament"), "--output", output, "--json"+ ], stdout, stderr);++ Assert.Equal(1, exit);+ Assert.False(File.Exists(output));+ Assert.Contains("firmament-feature-footprint-outside-span:MountPattern_3:MountingArea", stdout.ToString() + stderr, StringComparison.Ordinal);+ }+ finally { if (File.Exists(output)) File.Delete(output); }+ }++ [Theory]+ [InlineData("plane-boundary-open.firmament", "firmament-span-surface-boundary-open:InvalidArea")]+ [InlineData("plane-boundary-off-parent.firmament", "firmament-span-surface-boundary-off-parent:InvalidArea")]+ public void Validate_InvalidSurfaceBoundary_IsFatal(string file, string expected)+ {+ var stdout = new StringWriter(); var stderr = new StringWriter();+ var exit = Aetheris.CLI.CliRunner.Run(["validate", Fixture("Invalid", "Span", file), "--json"], stdout, stderr);++ Assert.Equal(1, exit);+ using var json = JsonDocument.Parse(stdout.ToString());+ var report = json.RootElement.GetProperty("firmamentV2Validation");+ Assert.Equal("invalid", report.GetProperty("status").GetString());+ Assert.Contains(report.GetProperty("diagnostics").EnumerateArray(), item =>+ item.GetProperty("code").GetString() == expected && item.GetProperty("severity").GetString() == "fatal");+ }++ private static string Fixture(params string[] parts) => Path.Combine([RepoRoot, "fixtures", .. parts]);++ private static string FindRepoRoot()+ {+ var directory = new DirectoryInfo(AppContext.BaseDirectory);+ while (directory is not null && !File.Exists(Path.Combine(directory.FullName, "Aetheris.slnx"))) directory = directory.Parent;+ return directory?.FullName ?? throw new DirectoryNotFoundException("Repository root was not found.");+ }+}diff --git a/Aetheris.CLI/CliRunner.cs b/Aetheris.CLI/CliRunner.csindex 7fd2d79d..166a2829 100644--- a/Aetheris.CLI/CliRunner.cs+++ b/Aetheris.CLI/CliRunner.cs@@ -1943,10 +1943,10 @@ Model CanonicalPanel {placement = new { stack.Feature.Placement.Name, anchor = new[] { stack.Feature.Placement.AnchorX, stack.Feature.Placement.AnchorY, stack.Feature.Placement.AnchorZ }, profilePlane = stack.Feature.Placement.ProfilePlane, stack.Feature.Placement.Axis, stack.Feature.Placement.ReferenceDirection, stack.Feature.Placement.IsExplicit },signatures = new { composition = CompositionSignature(stack), profiles = parsed.Profiles.OrderBy(x => x.Key, StringComparer.Ordinal).ToDictionary(x => x.Key, x => ProfileSignature(x.Value), StringComparer.Ordinal) },operations = stack.Feature.Operations.Select(x => new { x.Name, intent = x.Intent.ToString(), profile = x.ProfileReference, x.From, x.To, x.SemanticRole, x.SourceSpan, x.SemanticFeatureId, x.SemanticFeatureKind, x.Diameter, signature = Hash($"{x.Intent}|{x.ProfileReference}|{x.From:R}|{x.To:R}|{x.SemanticRole}|{x.SemanticFeatureId}|{x.Diameter:R}") }),- shaftHoles = (stack.Feature.ShaftHoles ?? []).Select(x => new { x.Name, x.StableId, profile = x.ProfileReference, center = new[] { x.CenterX, x.CenterY }, x.Diameter, x.From, x.To, endCondition = "ThroughAll", x.SemanticRole, x.SourceSpan }),- counterboreHoles = (stack.Feature.CounterboreHoles ?? []).Select(x => new { x.Name, x.StableId, shaftProfile = x.ShaftProfileReference, counterboreProfile = x.CounterboreProfileReference, center = new[] { x.CenterX, x.CenterY }, x.Diameter, x.CounterboreDiameter, x.CounterboreDepth, x.From, x.To, endCondition = "ThroughAll", x.SemanticRole, x.SourceSpan }),- bosses = (stack.Feature.Bosses ?? []).Select(x => new { x.Name, x.StableId, host = x.Host, on = x.SupportFace, profile = x.ProfileReference, x.Height, x.From, x.To, materialEffect = "Add", lowering = "PrismaticSectionStack/Add" }),- pockets = (stack.Feature.Pockets ?? []).Select(x => new { x.Name, x.StableId, host = x.Host, on = x.SupportFace, profile = x.ProfileReference, x.Depth, x.HostThickness, x.RemainingFloor, x.MinimumFloorThickness, x.MinimumFloorPolicySource, x.From, x.To, materialEffect = "Remove", lowering = "PrismaticSectionStack/Remove" }),+ shaftHoles = (stack.Feature.ShaftHoles ?? []).Select(x => new { x.Name, x.StableId, profile = x.ProfileReference, center = new[] { x.CenterX, x.CenterY }, x.Diameter, x.From, x.To, endCondition = "ThroughAll", x.SemanticRole, x.SourceSpan, support = x.SupportSpan is null ? null : new { kind = "Span<Plane>", id = x.SupportSpan, parent = x.ParentSupport, boundaryMargin = x.SupportBoundaryMargin } }),+ counterboreHoles = (stack.Feature.CounterboreHoles ?? []).Select(x => new { x.Name, x.StableId, shaftProfile = x.ShaftProfileReference, counterboreProfile = x.CounterboreProfileReference, center = new[] { x.CenterX, x.CenterY }, x.Diameter, x.CounterboreDiameter, x.CounterboreDepth, x.From, x.To, endCondition = "ThroughAll", x.SemanticRole, x.SourceSpan, support = x.SupportSpan is null ? null : new { kind = "Span<Plane>", id = x.SupportSpan, parent = x.ParentSupport, boundaryMargin = x.SupportBoundaryMargin } }),+ bosses = (stack.Feature.Bosses ?? []).Select(x => new { x.Name, x.StableId, host = x.Host, on = x.SupportFace, profile = x.ProfileReference, x.Height, x.From, x.To, support = x.SupportSpan is null ? null : new { kind = "Span<Plane>", id = x.SupportSpan, parent = x.ParentSupport }, materialEffect = "Add", lowering = "PrismaticSectionStack/Add" }),+ pockets = (stack.Feature.Pockets ?? []).Select(x => new { x.Name, x.StableId, host = x.Host, on = x.SupportFace, profile = x.ProfileReference, x.Depth, x.HostThickness, x.RemainingFloor, x.MinimumFloorThickness, x.MinimumFloorPolicySource, x.From, x.To, support = x.SupportSpan is null ? null : new { kind = "Span<Plane>", id = x.SupportSpan, parent = x.ParentSupport }, materialEffect = "Remove", lowering = "PrismaticSectionStack/Remove" }),capsuleSlots = (stack.Feature.CapsuleSlots ?? []).Select(x => new { x.Name, x.StableId, kind = "Slot<Capsule>", profile = x.ProfileReference, center = new[] { x.CenterX, x.CenterY }, direction = new[] { x.DirectionX, x.DirectionY }, x.Length, x.Width, radius = x.Radius, straightSpan = x.StraightSpan, endCenters = new[] { new[] { x.CenterX - x.DirectionX * x.StraightSpan / 2d, x.CenterY - x.DirectionY * x.StraightSpan / 2d }, new[] { x.CenterX + x.DirectionX * x.StraightSpan / 2d, x.CenterY + x.DirectionY * x.StraightSpan / 2d } }, x.From, x.To, x.Extent, x.SemanticRole, x.SourceSpan, segments = parsed.Profiles[x.ProfileReference].Loops.Single().Segments.Select(s => s.Name) }),roundedRectangleSlots = (stack.Feature.RoundedRectangleSlots ?? []).Select(x => new { x.Name, x.StableId, kind = "Slot<RoundedRectangle>", profile = x.ProfileReference, center = new[] { x.CenterX, x.CenterY }, direction = new[] { x.DirectionX, x.DirectionY }, x.Length, x.Width, x.CornerRadius, x.From, x.To, x.Extent, x.SemanticRole, x.SourceSpan, segments = parsed.Profiles[x.ProfileReference].Loops.Single().Segments.Select(s => s.Name) }),criticalLevels = stack.Feature.CriticalLevels,diff --git a/Aetheris.Kernel.Firmament.Tests/GeometricSpanX1Tests.cs b/Aetheris.Kernel.Firmament.Tests/GeometricSpanX1Tests.csindex c867c547..d375e668 100644--- a/Aetheris.Kernel.Firmament.Tests/GeometricSpanX1Tests.cs+++ b/Aetheris.Kernel.Firmament.Tests/GeometricSpanX1Tests.cs@@ -62,8 +62,10 @@ public sealed class GeometricSpanX1Testspublic void PlaneSpan_PreservesPlaneAndBoundaryIdentity_WithoutCreatingAFace(){var source = """+ Concept Struct Plate { TopPlane: Plane { Origin: [0mm,0mm,0mm]; Normal: [0,0,1]; Up: [0,1,0] } }Construction Plane MountPlane { Trace: Plate.TopPlane }- Profile MountBoundary { Loop Outer { } }+ Rect2 Boundary { Center: [0mm,0mm]; Size: [10mm,10mm] }+ Profile MountBoundary { Loop Outer { Boundary.Bottom |> Boundary.Right |> Boundary.Top |> Boundary.Left |> Close } }Span<Plane> MountArea { On: MountPlane; Boundary: MountBoundary }""";var span = Assert.Single(ProfileAuthoringParser.InspectGeometricSpans(source).Spans);diff --git a/Aetheris.Kernel.Firmament.Tests/SurfaceSpanSupportX1Tests.cs b/Aetheris.Kernel.Firmament.Tests/SurfaceSpanSupportX1Tests.csnew file mode 100644index 00000000..8b9e5e98--- /dev/null+++ b/Aetheris.Kernel.Firmament.Tests/SurfaceSpanSupportX1Tests.cs@@ -0,0 +1,218 @@+using Aetheris.Kernel.Firmament.FirmamentV2;+using Aetheris.Kernel.Firmament.Materializer;++namespace Aetheris.Kernel.Firmament.Tests;++public sealed class SurfaceSpanSupportX1Tests+{+ [Fact]+ public void PlaneSpan_ResolvesValidBoundaryAreaFrameNormalAndConsumers()+ {+ var inspection = ProfileAuthoringParser.InspectGeometricSpans(Source(Holes(valid: true)));+ var span = Assert.Single(inspection.Spans, item => item.SpanId == "MountingArea");++ Assert.Empty(inspection.Diagnostics);+ Assert.Equal(2880d, span.Area!.Value, 8);+ Assert.Equal([0d, 0d, 1d], span.Normal!);+ Assert.Equal("construction:TopSupport", span.LocalFrame);+ Assert.Equal(["Hole:H1", "Hole:H2", "Hole:H3", "Hole:H4"], span.ConsumerReferences);+ Assert.True(PlanarSpanContainment.ContainsPoint(span, 0, 0));+ Assert.False(PlanarSpanContainment.ContainsPoint(span, 35, 25)); // inside AABB, outside diamond+ Assert.True(PlanarSpanContainment.ContainsCircle(span, 16, 9, 8, out var margin));+ Assert.True(margin > 0);+ }++ [Fact]+ public void CounterboreOnSpan_PreservesBoundedAndParentSupport_AndUsesExistingLowering()+ {+ var parsed = PrismaticProfileCompositionParser.Parse(Source(Holes(valid: true)));+ Assert.Empty(parsed.Diagnostics);+ var feature = Assert.IsType<PrismaticProfileCompositionFeature>(parsed.Feature);+ Assert.All(feature.CounterboreHoles!, hole =>+ {+ Assert.Equal("MountingArea", hole.SupportSpan);+ Assert.Equal("TopSupport", hole.ParentSupport);+ Assert.True(hole.SupportBoundaryMargin > 0);+ });+ var stack = Assert.IsType<PrismaticSectionStackConstruction>(PrismaticSectionStackCompiler.Normalize(parsed, out var diagnostics));+ Assert.Empty(diagnostics);+ Assert.True(stack.AnalyticVolume > 0);+ }++ [Fact]+ public void FootprintCrossingSpanBoundary_FailsTypedAndProducesNoConstruction()+ {+ var parsed = PrismaticProfileCompositionParser.Parse(Source(Holes(valid: false)));+ Assert.Null(parsed.Feature);+ Assert.Contains(parsed.Diagnostics, item => item.StartsWith("firmament-feature-footprint-outside-span:H4:MountingArea", StringComparison.Ordinal));+ Assert.Null(PrismaticSectionStackCompiler.Normalize(parsed, out _));+ }++ [Fact]+ public void SameHoleOnWholeParentPasses_WhileOnSpanFails()+ {+ var bounded = PrismaticProfileCompositionParser.Parse(Source(SingleHole("MountingArea", 30, 20)));+ var whole = PrismaticProfileCompositionParser.Parse(Source(SingleHole("+Z", 30, 20)));+ Assert.Null(bounded.Feature);+ Assert.Contains(bounded.Diagnostics, item => item.StartsWith("firmament-feature-footprint-outside-span:Outside:MountingArea", StringComparison.Ordinal));+ Assert.NotNull(whole.Feature);+ Assert.DoesNotContain(whole.Diagnostics, item => item.StartsWith("firmament-feature-footprint-outside-span:", StringComparison.Ordinal));+ }++ [Fact]+ public void BoundaryEdit_ReevaluatesExistingHoleWithoutStaleFallback()+ {+ var wide = PrismaticProfileCompositionParser.Parse(Source(SingleHole("MountingArea", 12, 7)));+ var narrowSource = Source(SingleHole("MountingArea", 12, 7)).Replace("[0mm,32mm]", "[0mm,18mm]", StringComparison.Ordinal);+ var narrow = PrismaticProfileCompositionParser.Parse(narrowSource);+ Assert.NotNull(wide.Feature);+ Assert.Null(narrow.Feature);+ Assert.Contains(narrow.Diagnostics, item => item.StartsWith("firmament-feature-footprint-outside-span:Outside:MountingArea", StringComparison.Ordinal));+ }++ [Fact]+ public void CounterborePattern_ValidatesEveryExpandedInstanceAndIdentifiesFailure()+ {+ var validSource = File.ReadAllText(Fixture("Canonical", "Span", "plane-hole-support.firmament"));+ var invalidSource = File.ReadAllText(Fixture("Invalid", "Span", "plane-hole-footprint-crossing.firmament"));++ var valid = FirmamentBuildAndExport.CompileSource(validSource);+ Assert.True(valid.IsSuccess, string.Join(Environment.NewLine, valid.Diagnostics.Select(item => item.Message)));+ Assert.Equal(4, valid.Value.Features!.Count);+ Assert.All(valid.Value.Features, hole => Assert.Equal("MountingArea", hole.SupportSpan));+ var span = Assert.Single(ProfileAuthoringParser.InspectGeometricSpans(validSource).Spans, item => item.SpanId == "MountingArea");+ Assert.Equal(["Hole:MountPattern_0", "Hole:MountPattern_1", "Hole:MountPattern_2", "Hole:MountPattern_3"], span.ConsumerReferences);++ var invalid = FirmamentBuildAndExport.CompileSource(invalidSource);+ Assert.False(invalid.IsSuccess);+ Assert.Contains(invalid.Diagnostics, item => item.Message.StartsWith("firmament-feature-footprint-outside-span:MountPattern_3:MountingArea", StringComparison.Ordinal));+ }++ [Fact]+ public void BossAndPocketOnSpan_UseActualProfileFootprintsAndRetainSupportIdentity()+ {+ var parsed = PrismaticProfileCompositionParser.Parse(ProfileFeatureSource(outside: false));+ var feature = Assert.IsType<PrismaticProfileCompositionFeature>(parsed.Feature);+ var boss = Assert.Single(feature.Bosses!);+ var pocket = Assert.Single(feature.Pockets!);+ Assert.Equal(("MountingArea", "TopSupport"), (boss.SupportSpan, boss.ParentSupport));+ Assert.Equal(("MountingArea", "TopSupport"), (pocket.SupportSpan, pocket.ParentSupport));++ var invalid = PrismaticProfileCompositionParser.Parse(ProfileFeatureSource(outside: true));+ Assert.Null(invalid.Feature);+ Assert.Contains(invalid.Diagnostics, item => item == "firmament-feature-footprint-outside-span:Pad:MountingArea:profile=PadProfile");+ }++ [Fact]+ public void ArcBoundaryAndInnerLoop_UseAnalyticProfileContainment()+ {+ var circular = ProfileAuthoringParser.InspectGeometricSpans(CircularSpanSource());+ var disk = Assert.Single(circular.Spans);+ Assert.True(PlanarSpanContainment.ContainsCircle(disk, 0, 0, 8, out var insideMargin));+ Assert.Equal(12d, insideMargin, 8);+ Assert.False(PlanarSpanContainment.ContainsCircle(disk, 13, 0, 8, out var crossingMargin));+ Assert.True(crossingMargin < 0);++ var ring = ProfileAuthoringParser.InspectGeometricSpans(RingSpanSource());+ var ringSpan = Assert.Single(ring.Spans);+ Assert.Equal(1400d, ringSpan.Area!.Value, 8);+ Assert.False(PlanarSpanContainment.ContainsPoint(ringSpan, 0, 0));+ Assert.True(PlanarSpanContainment.ContainsPoint(ringSpan, 15, 0));+ }++ [Fact]+ public void ParentPlaneAndHostMoveTogether_ContainmentAndRelativeFeatureSupportRemainStable()+ {+ var original = PrismaticProfileCompositionParser.Parse(Source(SingleHole("MountingArea", 0, 0)));+ var movedSource = Source(SingleHole("MountingArea", 0, 0))+ .Replace("0mm,0mm,8mm", "0mm,0mm,18mm", StringComparison.Ordinal)+ .Replace("From: 0mm; To: 8mm", "From: 10mm; To: 18mm", StringComparison.Ordinal);+ var moved = PrismaticProfileCompositionParser.Parse(movedSource);++ var first = Assert.Single(original.Feature!.CounterboreHoles!);+ var second = Assert.Single(moved.Feature!.CounterboreHoles!);+ Assert.Equal((0d, 8d), (first.From, first.To));+ Assert.Equal((10d, 18d), (second.From, second.To));+ Assert.Equal(first.SupportBoundaryMargin, second.SupportBoundaryMargin);+ Assert.Equal("TopSupport", second.ParentSupport);+ }++ [Fact]+ public void SpanSupportAndEquivalentWholePlaneSupport_ExportIdenticalGeometry()+ {+ var boundedSource = File.ReadAllText(Fixture("Canonical", "Span", "plane-hole-support.firmament"));+ var wholePlaneSource = boundedSource.Replace("On: MountingArea", "On: +Z", StringComparison.Ordinal);+ var bounded = FirmamentBuildAndExport.CompileSource(boundedSource);+ var whole = FirmamentBuildAndExport.CompileSource(wholePlaneSource);++ Assert.True(bounded.IsSuccess, string.Join(Environment.NewLine, bounded.Diagnostics.Select(item => item.Message)));+ Assert.True(whole.IsSuccess, string.Join(Environment.NewLine, whole.Diagnostics.Select(item => item.Message)));+ Assert.Equal(bounded.Value.StepText, whole.Value.StepText);+ Assert.All(bounded.Value.Features!, feature => Assert.Equal("MountingArea", feature.SupportSpan));+ Assert.All(whole.Value.Features!, feature => Assert.Null(feature.SupportSpan));+ }++ private static string Fixture(params string[] parts) =>+ Path.GetFullPath(Path.Combine([AppContext.BaseDirectory, "../../../../fixtures", .. parts]));++ private static string ProfileFeatureSource(bool outside) => Source($$"""+ Rect2 PadShape { Center: [{{(outside ? 35 : -10)}}mm, 0mm]; Size: [10mm, 8mm] }+ Rect2 PocketShape { Center: [10mm, 0mm]; Size: [8mm, 6mm] }+ Profile PadProfile { Loop Outer { PadShape.Bottom |> PadShape.Right |> PadShape.Top |> PadShape.Left |> Close } }+ Profile PocketProfile { Loop Outer { PocketShape.Bottom |> PocketShape.Right |> PocketShape.Top |> PocketShape.Left |> Close } }+ Boss Pad { On: MountingArea; Profile: PadProfile; Height: 3mm }+ Pocket Recess { On: MountingArea; Profile: PocketProfile; Depth: 2mm; MinimumFloorThickness: 1mm }+ """);++ private static string CircularSpanSource() => """+ Concept Struct Supports { Top: Plane { Origin: [0mm,0mm,0mm]; Normal: [0,0,1]; Up: [0,1,0] } }+ Construction Plane TopSupport { Trace: Supports.Top }+ Point2 C { Position: [0mm,0mm] } Point2 E { Position: [20mm,0mm] }+ Point2 N { Position: [0mm,20mm] } Point2 W { Position: [-20mm,0mm] } Point2 S { Position: [0mm,-20mm] }+ Circle2 Rim { Center: C; Radius: 20mm }+ Profile Disk { Loop Outer {+ Segment Q1 { Trace: Rim; From: E; To: N; Sweep: CounterClockwise }+ Segment Q2 { Trace: Rim; From: N; To: W; Sweep: CounterClockwise }+ Segment Q3 { Trace: Rim; From: W; To: S; Sweep: CounterClockwise }+ Segment Q4 { Trace: Rim; From: S; To: E; Sweep: CounterClockwise }+ } }+ Span<Plane> WorkArea { On: TopSupport; Boundary: Disk }+ """;++ private static string RingSpanSource() => """+ Concept Struct Supports { Top: Plane { Origin: [0mm,0mm,0mm]; Normal: [0,0,1]; Up: [0,1,0] } }+ Construction Plane TopSupport { Trace: Supports.Top }+ Rect2 Outer { Center: [0mm,0mm]; Size: [40mm,40mm] }+ Rect2 Inner { Center: [0mm,0mm]; Size: [20mm,10mm] }+ Profile Ring { Loop Outer { Outer.Bottom |> Outer.Right |> Outer.Top |> Outer.Left |> Close }+ Loop Inner { Reverse Inner.Bottom |> Reverse Inner.Left |> Reverse Inner.Top |> Reverse Inner.Right |> Close } }+ Span<Plane> RingArea { On: TopSupport; Boundary: Ring }+ """;++ private static string Holes(bool valid) => string.Join('\n', new[]+ {+ SingleHole("MountingArea", -16, -9, "H1"), SingleHole("MountingArea", 16, -9, "H2"),+ SingleHole("MountingArea", -16, 9, "H3"), SingleHole("MountingArea", valid ? 16 : 28, 9, "H4")+ });++ private static string SingleHole(string support, double x, double y, string name = "Outside") => $$"""+ Hole<Counterbore> {{name}} { On: {{support}}; Center: [{{x}}mm, {{y}}mm]; Diameter: 8mm; CounterboreDiameter: 16mm; CounterboreDepth: 3mm; End: ThroughAll }+ """;++ private static string Source(string holes) => $$"""+ Concept Struct Supports { Top: Plane { Origin: [0mm,0mm,8mm]; Normal: [0,0,1]; Up: [0,1,0] } }+ Construction Plane TopSupport { Trace: Supports.Top }+ Rect2 Stock { Center: [0mm,0mm]; Size: [100mm,80mm] }+ Profile StockProfile { Loop Outer { Stock.Bottom |> Stock.Right |> Stock.Top |> Stock.Left |> Close } }+ Point2 South { Position: [0mm,-32mm] } Point2 East { Position: [45mm,0mm] }+ Point2 North { Position: [0mm,32mm] } Point2 West { Position: [-45mm,0mm] }+ Line2 SE { From: South; To: East } Line2 EN { From: East; To: North }+ Line2 NW { From: North; To: West } Line2 WS { From: West; To: South }+ Profile MountBoundary { Loop Outer { SE |> EN |> NW |> WS |> Close } }+ Span<Plane> MountingArea { On: TopSupport; Boundary: MountBoundary }+ Compose Plate {+ Base StockBody { Profile: StockProfile; From: 0mm; To: 8mm; Role: Stock }+ {{holes}}+ }+ """;+}diff --git a/Aetheris.Kernel.Firmament/FirmamentBuildAndExport.cs b/Aetheris.Kernel.Firmament/FirmamentBuildAndExport.csindex 939e0658..d460eaf4 100644--- a/Aetheris.Kernel.Firmament/FirmamentBuildAndExport.cs+++ b/Aetheris.Kernel.Firmament/FirmamentBuildAndExport.cs@@ -2182,11 +2182,12 @@ public static class FirmamentBuildAndExportprivate static IReadOnlyList<FirmamentEngineeringFeatureReport> EngineeringFeatureReports(PrismaticProfileCompositionFeature feature) =>(feature.Bosses ?? []).Select(item => new FirmamentEngineeringFeatureReport(item.Name, "Boss", item.StableId, item.Host, item.SupportFace, item.ProfileReference,- item.Height, "Height", "Add", MaterializationRoute: "PrismaticSectionStack/Add"))+ item.Height, "Height", "Add", MaterializationRoute: "PrismaticSectionStack/Add",+ SupportSpan: item.SupportSpan, ParentSupport: item.ParentSupport)).Concat((feature.Pockets ?? []).Select(item => new FirmamentEngineeringFeatureReport(item.Name, "Pocket", item.StableId, item.Host, item.SupportFace, item.ProfileReference,item.Depth, "Depth", "Remove", item.RemainingFloor, item.MinimumFloorThickness,- item.MinimumFloorPolicySource, "PrismaticSectionStack/Remove")))+ item.MinimumFloorPolicySource, "PrismaticSectionStack/Remove", item.SupportSpan, item.ParentSupport))).OrderBy(item => item.FeatureId, StringComparer.Ordinal).ToArray();@@ -2194,11 +2195,13 @@ public static class FirmamentBuildAndExport(feature.ShaftHoles ?? []).Select(item => new FirmamentHoleFeatureReport(item.Name, "Hole<Shaft>", item.StableId, item.Diameter, item.CenterX, item.CenterY,null, "ProfileCompose.Center", null, null, "+Z", item.SourceSpan,- "PrismaticSectionStack/Remove", "SemanticShaftProfile", "ThroughAll"))+ "PrismaticSectionStack/Remove", "SemanticShaftProfile", "ThroughAll",+ SupportSpan: item.SupportSpan, ParentSupport: item.ParentSupport, SupportBoundaryMargin: item.SupportBoundaryMargin)).Concat((feature.CounterboreHoles ?? []).Select(item => new FirmamentHoleFeatureReport(item.Name, "Hole<Counterbore>", item.StableId, item.Diameter, item.CenterX, item.CenterY,null, "ProfileCompose.Center", null, null, "+Z", item.SourceSpan,- "PrismaticSectionStack/Remove", "SemanticCounterboreProfiles", "ThroughAll")))+ "PrismaticSectionStack/Remove", "SemanticCounterboreProfiles", "ThroughAll",+ SupportSpan: item.SupportSpan, ParentSupport: item.ParentSupport, SupportBoundaryMargin: item.SupportBoundaryMargin))).OrderBy(item => item.FeatureId, StringComparer.Ordinal).ToArray();diff --git a/Aetheris.Kernel.Firmament/FirmamentStepExportResult.cs b/Aetheris.Kernel.Firmament/FirmamentStepExportResult.csindex 8fa36e3c..a5319230 100644--- a/Aetheris.Kernel.Firmament/FirmamentStepExportResult.cs+++ b/Aetheris.Kernel.Firmament/FirmamentStepExportResult.cs@@ -118,7 +118,9 @@ public sealed record FirmamentEngineeringFeatureReport(double? RemainingFloor = null,double? MinimumFloorThickness = null,string? PolicySource = null,- string MaterializationRoute = "PrismaticSectionStack");+ string MaterializationRoute = "PrismaticSectionStack",+ string? SupportSpan = null,+ string? ParentSupport = null);public sealed record FirmamentStandardPartReport(string Family,@@ -248,7 +250,10 @@ public sealed record FirmamentHoleFeatureReport(int ConicalFaces = 0,int PlanarFaces = 0,string? StepSha256 = null,- bool StepReimportSucceeded = false);+ bool StepReimportSucceeded = false,+ string? SupportSpan = null,+ string? ParentSupport = null,+ double? SupportBoundaryMargin = null);public sealed record FirmamentAirChamferReport(FirmamentAirChamferFeatureReport Feature,diff --git a/Aetheris.Kernel.Firmament/FirmamentV2/CanonicalStaticAuthoring.cs b/Aetheris.Kernel.Firmament/FirmamentV2/CanonicalStaticAuthoring.csindex c9ef2b86..6486e61c 100644--- a/Aetheris.Kernel.Firmament/FirmamentV2/CanonicalStaticAuthoring.cs+++ b/Aetheris.Kernel.Firmament/FirmamentV2/CanonicalStaticAuthoring.cs@@ -231,7 +231,7 @@ internal static class CanonicalStaticAuthoringprivate static string? Instantiate(Template template, IReadOnlyDictionary<string, string> values, string id, bool patterned, List<string> diagnostics){- var declaration = Regex.Match(template.Body, @"\b(?<kind>Hole\s*<\s*Shaft\s*>|Slot\s*<\s*(?:Capsule|RoundedRectangle)\s*>|Profile|StandardPart)\s+(?<name>[A-Za-z_]\w*)(?<tail>\s+Using\s+[A-Za-z_]\w*)?\s*\{", RegexOptions.CultureInvariant);+ var declaration = Regex.Match(template.Body, @"\b(?<kind>Hole\s*<\s*(?:Shaft|Counterbore)\s*>|Slot\s*<\s*(?:Capsule|RoundedRectangle)\s*>|Profile|StandardPart)\s+(?<name>[A-Za-z_]\w*)(?<tail>\s+Using\s+[A-Za-z_]\w*)?\s*\{", RegexOptions.CultureInvariant);if (!declaration.Success) { diagnostics.Add(Prefix + "template-output-unsupported:" + template.Name); return null; }var kind = declaration.Groups["kind"].Value;if (patterned && string.Equals(kind, "Profile", StringComparison.Ordinal))diff --git a/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2Parser.cs b/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2Parser.csindex 19018630..75cb4531 100644--- a/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2Parser.cs+++ b/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2Parser.cs@@ -928,7 +928,7 @@ public static class FirmamentV2Parser/// and feature semantics, never the spelling that introduced them./// </summary>private static bool ContainsCanonicalAdvancedDeclaration(string source) =>- Regex.IsMatch(source, @"\b(?:Concept|Struct|Construction\s+Plane|Profile|Compose|Selection|Template|Enum|Pattern|Require|Match)\b", RegexOptions.CultureInvariant);+ Regex.IsMatch(source, @"\b(?:Concept|Struct|Construction\s+Plane|Profile|Span|Compose|Selection|Template|Enum|Pattern|Require|Match)\b", RegexOptions.CultureInvariant);/// <summary>/// Canonical roots have one owner for every declaration-shaped block. This@@ -944,7 +944,7 @@ public static class FirmamentV2Parservar known = new HashSet<string>(StringComparer.Ordinal){- "Box", "Cylinder", "Cone", "Sphere", "Torus", "RoundedBox", "Frustum", "StandardPart", "ExactCoaxialPart", "Concept", "Struct", "Construction", "Profile", "Compose", "Boss", "Pocket", "EdgeFinish",+ "Box", "Cylinder", "Cone", "Sphere", "Torus", "RoundedBox", "Frustum", "StandardPart", "ExactCoaxialPart", "Concept", "Struct", "Construction", "Profile", "Span", "Compose", "Boss", "Pocket", "EdgeFinish","Record", "Static", "Template", "template", "ProfileDelta", "Selection", "InlineStep", "Recognize", "Replace", "Pmi", "Modify", "Match", "Require", "Assert"};var compatibilityOnly = new HashSet<string>(StringComparer.Ordinal)diff --git a/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2ValidationReport.cs b/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2ValidationReport.csindex 330f9e0d..013c76ca 100644--- a/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2ValidationReport.cs+++ b/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2ValidationReport.cs@@ -304,7 +304,12 @@ public static class FirmamentV2ValidationReportBuilder}private static FirmamentV2ValidationDiagnostic ToParserDiagnostic(string code) =>- new(code, FirmamentV2Parser.IsFatalDiagnosticCode(code) ? "fatal" : "warning", Message(code));+ new(code, IsFatal(code) ? "fatal" : "warning", Message(code));++ private static bool IsFatal(string code) =>+ code.StartsWith("firmament-span-", StringComparison.Ordinal)+ || code.StartsWith("firmament-feature-footprint-outside-span:", StringComparison.Ordinal)+ || FirmamentV2Parser.IsFatalDiagnosticCode(code);private static bool IsParserTraceDiagnostic(string code) =>code is "firmament-v2-parser-invoked" or "firmament-v2-parse-succeeded"diff --git a/Aetheris.Kernel.Firmament/FirmamentV2/GeometricSpan.cs b/Aetheris.Kernel.Firmament/FirmamentV2/GeometricSpan.csindex 2c961786..40559d27 100644--- a/Aetheris.Kernel.Firmament/FirmamentV2/GeometricSpan.cs+++ b/Aetheris.Kernel.Firmament/FirmamentV2/GeometricSpan.cs@@ -20,8 +20,72 @@ public sealed record GeometricSpanView(string? BoundaryProfile,double? Length,string Provenance,- [property: JsonIgnore] LineArcProfileCurve2D? Geometry = null);+ [property: JsonIgnore] LineArcProfileCurve2D? Geometry = null,+ double? Area = null,+ double[]? Normal = null,+ string? LocalFrame = null,+ IReadOnlyList<string>? ConsumerReferences = null,+ string Validity = "Valid",+ [property: JsonIgnore] ResolvedProfile2D? Boundary = null,+ [property: JsonIgnore] ConstructionPlane? ParentPlane = null);public sealed record GeometricSpanInspection(IReadOnlyList<GeometricSpanView> Spans,IReadOnlyList<string> Diagnostics);++/// <summary>Deterministic support-domain predicates over the existing Profile authority.</summary>+public static class PlanarSpanContainment+{+ // Points on the authored boundary are valid support points. Footprints require their+ // complete closed disk to remain inside or on the boundary within kernel tolerance.+ public const double Tolerance = 1e-7d;++ public static bool ContainsPoint(GeometricSpanView span, double x, double y)+ {+ if (span.Boundary is null) return false;+ return ProfileArrangementBuilder.PointInProfile(span.Boundary, (x, y))+ is ArrangementPointLocation.Inside or ArrangementPointLocation.OnBoundary;+ }++ public static bool ContainsCircle(GeometricSpanView span, double x, double y, double radius, out double boundaryMargin)+ {+ boundaryMargin = double.NaN;+ if (span.Boundary is null || !double.IsFinite(radius) || radius < 0d || !ContainsPoint(span, x, y)) return false;+ var distances = span.Boundary.Loops.SelectMany(loop => loop.Segments)+ .Select(segment => DistanceToCurve((x, y), segment.Geometry)).ToArray();+ if (distances.Length == 0 || distances.Any(distance => !double.IsFinite(distance))) return false;+ boundaryMargin = distances.Min() - radius;+ return boundaryMargin >= -Tolerance;+ }++ private static double DistanceToCurve((double X, double Y) point, LineArcProfileCurve2D curve) => curve switch+ {+ LineArcLineSegment2D line => DistanceToSegment(point, line.Start, line.End),+ LineArcCircularArc2D arc => DistanceToArc(point, arc),+ LineArcFullCircle2D circle => Math.Abs(Distance(point, circle.Center) - circle.Radius),+ _ => double.NaN+ };++ private static double DistanceToSegment((double X, double Y) point, (double X, double Y) start, (double X, double Y) end)+ {+ var dx = end.X - start.X; var dy = end.Y - start.Y; var extent = dx * dx + dy * dy;+ if (extent <= Tolerance * Tolerance) return Distance(point, start);+ var t = Math.Clamp(((point.X - start.X) * dx + (point.Y - start.Y) * dy) / extent, 0d, 1d);+ return Distance(point, (start.X + t * dx, start.Y + t * dy));+ }++ private static double DistanceToArc((double X, double Y) point, LineArcCircularArc2D arc)+ {+ var angle = Math.Atan2(point.Y - arc.Center.Y, point.X - arc.Center.X);+ var delta = angle - arc.StartAngleRadians;+ if (arc.SweepAngleRadians >= 0d) while (delta < 0d) delta += 2d * Math.PI; else while (delta > 0d) delta -= 2d * Math.PI;+ if (delta / arc.SweepAngleRadians is >= -Tolerance and <= 1d + Tolerance)+ return Math.Abs(Distance(point, arc.Center) - arc.Radius);+ var a = (arc.Center.X + arc.Radius * Math.Cos(arc.StartAngleRadians), arc.Center.Y + arc.Radius * Math.Sin(arc.StartAngleRadians));+ var b = (arc.Center.X + arc.Radius * Math.Cos(arc.StartAngleRadians + arc.SweepAngleRadians), arc.Center.Y + arc.Radius * Math.Sin(arc.StartAngleRadians + arc.SweepAngleRadians));+ return Math.Min(Distance(point, a), Distance(point, b));+ }++ private static double Distance((double X, double Y) a, (double X, double Y) b) =>+ Math.Sqrt((a.X - b.X) * (a.X - b.X) + (a.Y - b.Y) * (a.Y - b.Y));+}diff --git a/Aetheris.Kernel.Firmament/FirmamentV2/ProfileAuthoringParser.cs b/Aetheris.Kernel.Firmament/FirmamentV2/ProfileAuthoringParser.csindex aefd1603..fedf15c8 100644--- a/Aetheris.Kernel.Firmament/FirmamentV2/ProfileAuthoringParser.cs+++ b/Aetheris.Kernel.Firmament/FirmamentV2/ProfileAuthoringParser.cs@@ -30,6 +30,10 @@ public static class ProfileAuthoringParser{ArgumentNullException.ThrowIfNull(source);var diagnostics = new List<string>();+ var expansion = FirmamentV2TemplateExpansion.Expand(source, diagnostics);+ if (expansion is not null) source = expansion.Source;+ var staticExpansion = CanonicalStaticAuthoring.Expand(source, diagnostics);+ if (staticExpansion is not null) source = staticExpansion.Source;var points = new Dictionary<string, (double X, double Y)>(StringComparer.Ordinal);var guides = new Dictionary<string, LineArcProfileCurve2D>(StringComparer.Ordinal);AddOrdinaryGuides(source, points, guides, diagnostics, applySpans: false);@@ -37,6 +41,33 @@ public static class ProfileAuthoringParserreturn new(spans, diagnostics.Distinct(StringComparer.Ordinal).Order(StringComparer.Ordinal).ToArray());}+ /// <summary>Resolves one named Profile without requiring an Extrude consumer.</summary>+ public static ResolvedProfile2D? ResolveNamedProfile(string source, string profileName, out IReadOnlyList<string> reportedDiagnostics)+ {+ ArgumentNullException.ThrowIfNull(source);+ ArgumentException.ThrowIfNullOrWhiteSpace(profileName);+ var diagnostics = new List<string>();+ var expansion = FirmamentV2TemplateExpansion.Expand(source, diagnostics);+ if (expansion is not null) source = expansion.Source;+ var declaration = FindProfiles(source).FirstOrDefault(profile => profile.Name == profileName);+ if (declaration is null) { reportedDiagnostics = [$"profile-source-missing-profile:{profileName}"]; return null; }+ var points = new Dictionary<string, (double X, double Y)>(StringComparer.Ordinal);+ var guides = new Dictionary<string, LineArcProfileCurve2D>(StringComparer.Ordinal);+ AddOrdinaryGuides(source, points, guides, diagnostics, applySpans: false);+ var paths = BindPaths(source, points, guides, diagnostics);+ var plane = ResolveConstructionPlane(source, declaration.Frame, diagnostics);+ var loops = BindProfileLoops(declaration, paths, points, guides, diagnostics);+ var profile = plane is null || loops.Count == 0 ? null : new ResolvedProfile2D(declaration.Name, declaration.Frame ?? "XY", loops, plane);+ if (profile is not null)+ {+ var validation = ResolvedProfile2DValidator.Validate(profile);+ diagnostics.AddRange(validation.Diagnostics);+ if (!validation.IsValid) profile = null;+ }+ reportedDiagnostics = diagnostics.Distinct(StringComparer.Ordinal).ToArray();+ return profile;+ }+internal static IReadOnlyList<string> ValidatePipelineContexts(string source){var allowed = FindBlocks(source, @"\b(?:Profile\s+[A-Za-z_]\w*(?:\s+Using\s+[A-Za-z_]\w*)?|Concept\s+Path\s+[A-Za-z_]\w*)\s*\{").ToArray();@@ -236,12 +267,35 @@ public static class ProfileAuthoringParserif (type == "Plane"){var boundary = Property(body, "Boundary");- var knownPlanes = ConstructionPlaneDeclaration.Matches(source).Cast<Match>()- .Select(match => match.Groups["name"].Value).ToHashSet(StringComparer.Ordinal);- if (!knownPlanes.Contains(parent)) { diagnostics.Add($"firmament-span-parent-not-found:{name}"); continue; }- if (boundary is null || !FindProfiles(source).Any(profile => profile.Name == boundary))- { diagnostics.Add($"firmament-span-boundary-not-closed:{name}"); continue; }- result.Add(new(name, type, parent, "Plane", $"Boundary:{boundary}", "Forward", null, null, boundary, null, $"span:{name};parent:{parent};boundary:{boundary}"));+ var planeDiagnostics = new List<string>();+ var parentPlane = ResolveConstructionPlane(source, parent, planeDiagnostics);+ if (!ConstructionPlaneDeclaration.Matches(source).Cast<Match>().Any(match => match.Groups["name"].Value == parent) || parentPlane is null)+ { diagnostics.Add($"firmament-span-parent-not-found:{name}"); continue; }+ if (boundary is null) { diagnostics.Add($"firmament-span-surface-boundary-open:{name}"); continue; }+ var boundaryProfile = ResolveNamedProfile(source, boundary, out var boundaryDiagnostics);+ if (boundaryProfile is null)+ {+ diagnostics.Add(boundaryDiagnostics.Any(item => item.Contains("self-intersection", StringComparison.Ordinal))+ ? $"firmament-span-surface-self-intersection:{name}"+ : $"firmament-span-surface-boundary-open:{name}");+ continue;+ }+ // An unqualified XY Profile is interpreted in the parent-local 2D frame by+ // the Span declaration. An explicitly qualified different frame is invalid.+ if (!string.Equals(boundaryProfile.PlaneFrame, "XY", StringComparison.Ordinal)+ && !string.Equals(boundaryProfile.PlaneFrame, parent, StringComparison.Ordinal)+ && !IsWorldXyLayout(source, boundaryProfile.PlaneFrame))+ { diagnostics.Add($"firmament-span-surface-boundary-off-parent:{name}"); continue; }+ var area = boundaryProfile.Loops.Sum(loop =>+ (loop.IsOuter ? 1d : -1d) * Math.Abs(PrismaticSectionStackCompiler.ProfileArea(boundaryProfile with { Loops = [loop] })));+ if (!double.IsFinite(area) || area <= Tolerance) { diagnostics.Add($"firmament-span-surface-domain-invalid:{name}"); continue; }+ var normal = parentPlane.AxisZ.ToVector();+ var orientation = string.Equals(Property(body, "Orientation"), "Reverse", StringComparison.Ordinal) ? "Reverse" : "Forward";+ var consumers = FindSpanConsumers(source, name);+ result.Add(new(name, type, parent, "Plane", $"Boundary:{boundary}", orientation, null, null, boundary, null,+ $"span:{name};parent:{parent};boundary:{boundary}", Area: area,+ Normal: orientation == "Reverse" ? [-normal.X, -normal.Y, -normal.Z] : [normal.X, normal.Y, normal.Z],+ LocalFrame: parentPlane.StableId, ConsumerReferences: consumers, Boundary: boundaryProfile, ParentPlane: parentPlane));continue;}@@ -273,6 +327,23 @@ public static class ProfileAuthoringParserreturn result;}+ private static bool IsWorldXyLayout(string source, string frame) =>+ Regex.IsMatch(source, $@"\bConcept\s+Struct\s+{Regex.Escape(frame)}\s+On\s+XY\s*\{{", RegexOptions.CultureInvariant);++ private static IReadOnlyList<string> FindSpanConsumers(string source, string spanName)+ {+ var consumers = new List<string>();+ foreach (var kind in new[] { "Hole", "Boss", "Pocket", "Fixed", "Force", "Pressure", "Traction" })+ foreach (Match header in Regex.Matches(source, $@"\b{kind}(?:\s*<[^>]+>)?\s+(?<name>[A-Za-z_]\w*)\s*\{{", RegexOptions.CultureInvariant))+ {+ var open = source.IndexOf('{', header.Index, header.Length);+ var close = FindMatchingBrace(source, open);+ if (close > open && string.Equals(Property(source[(open + 1)..close], "On") ?? Property(source[(open + 1)..close], "region"), spanName, StringComparison.Ordinal))+ consumers.Add($"{kind}:{header.Groups["name"].Value}");+ }+ return consumers.Order(StringComparer.Ordinal).ToArray();+ }+private static double CurveLength(LineArcProfileCurve2D curve) => curve switch{LineArcLineSegment2D line => Distance(line.Start, line.End),diff --git a/Aetheris.Kernel.Firmament/Materializer/PrismaticProfileComposition.cs b/Aetheris.Kernel.Firmament/Materializer/PrismaticProfileComposition.csindex 00b5eb3f..9b963331 100644--- a/Aetheris.Kernel.Firmament/Materializer/PrismaticProfileComposition.cs+++ b/Aetheris.Kernel.Firmament/Materializer/PrismaticProfileComposition.cs@@ -18,15 +18,18 @@ public sealed record PrismaticProfileOperation(/// <summary>First-class connected material addition lowered through the section-stack Add operation.</summary>public sealed record PrismaticBossFeature(string Name, string StableId, string Host, string SupportFace, string ProfileReference,- double Height, double From, double To, string SourceSpan);+ double Height, double From, double To, string SourceSpan,+ string? SupportSpan = null, string? ParentSupport = null);/// <summary>First-class finite material removal lowered through the section-stack Remove operation.</summary>public sealed record PrismaticPocketFeature(string Name, string StableId, string Host, string SupportFace, string ProfileReference,double Depth, double HostThickness, double RemainingFloor, double MinimumFloorThickness,- string MinimumFloorPolicySource, double From, double To, string SourceSpan);+ string MinimumFloorPolicySource, double From, double To, string SourceSpan,+ string? SupportSpan = null, string? ParentSupport = null);public sealed record PrismaticShaftHoleFeature(string Name, string StableId, string ProfileReference, double CenterX, double CenterY, double Diameter,- double From, double To, string SemanticRole, string SourceSpan);+ double From, double To, string SemanticRole, string SourceSpan,+ string? SupportSpan = null, string? ParentSupport = null, double? SupportBoundaryMargin = null);/// <summary>/// A bounded stepped through cavity in an admitted +Z prismatic compose host./// The two profile references are planner-owned section cuts, not Boolean tools.@@ -34,7 +37,8 @@ public sealed record PrismaticShaftHoleFeature(public sealed record PrismaticCounterboreHoleFeature(string Name, string StableId, string ShaftProfileReference, string CounterboreProfileReference,double CenterX, double CenterY, double Diameter, double CounterboreDiameter, double CounterboreDepth,- double From, double To, string SemanticRole, string SourceSpan);+ double From, double To, string SemanticRole, string SourceSpan,+ string? SupportSpan = null, string? ParentSupport = null, double? SupportBoundaryMargin = null);/// <summary>Source-owned transverse blind drill; its cavity is planned after host construction.</summary>public sealed record PrismaticConstructionPlaneBlindDrillFeature(string Name, string StableId, string ConstructionPlaneId, string SourceConceptPlaneId,@@ -120,7 +124,7 @@ public static class PrismaticProfileCompositionParserprivate static readonly Regex HoleDiameter = new(@"\bDiameter\s*:\s*(?<d>[-+.\d]+)mm", RegexOptions.CultureInvariant | RegexOptions.IgnoreCase);private static readonly Regex HoleCounterboreDiameter = new(@"\bCounterboreDiameter\s*:\s*(?<d>[-+.\d]+)mm", RegexOptions.CultureInvariant | RegexOptions.IgnoreCase);private static readonly Regex HoleCounterboreDepth = new(@"\bCounterboreDepth\s*:\s*(?<d>[-+.\d]+)mm", RegexOptions.CultureInvariant | RegexOptions.IgnoreCase);- private static readonly Regex HoleOn = new(@"\bOn\s*:\s*(?<face>[+-][XYZ])", RegexOptions.CultureInvariant | RegexOptions.IgnoreCase);+ private static readonly Regex HoleOn = new(@"\bOn\s*:\s*(?<face>[+-][XYZ]|[A-Za-z_]\w*)", RegexOptions.CultureInvariant | RegexOptions.IgnoreCase);private static readonly Regex HoleEnd = new(@"\bEnd\s*:\s*(?<end>\w+)", RegexOptions.CultureInvariant | RegexOptions.IgnoreCase);private static readonly Regex HoleDepthEnd = new(@"\bEnd\s*:\s*(?<kind>ShaftDepth|TotalDepth)\s*\(\s*(?<depth>[-+.\d]+)mm\s*\)", RegexOptions.CultureInvariant | RegexOptions.IgnoreCase);private static readonly Regex HoleFrom = new(@"\bFrom\s*:\s*(?<plane>\w+)", RegexOptions.CultureInvariant | RegexOptions.IgnoreCase);@@ -221,6 +225,9 @@ public static class PrismaticProfileCompositionParservar composeBody = Block(source, compose.Index + compose.Length - 1);if (composeBody is null) return new(null, profiles, diagnostics.Append("compose-source-unclosed-compose").ToArray());composeBody = BindExternalModifyFeatures(source, compose.Groups["n"].Value, composeBody, diagnostics);+ var spanInspection = ProfileAuthoringParser.InspectGeometricSpans(source);+ diagnostics.AddRange(spanInspection.Diagnostics);+ var surfaceSpans = spanInspection.Spans.Where(span => span.SpanType == "Plane").ToDictionary(span => span.SpanId, StringComparer.Ordinal);var placementMatch = Placement.Match(composeBody);var placement = new PrismaticProfilePlacement("LegacyImplicitWorldXY", 0d, 0d, 0d, "XY", "+Z", "+X", false);if (placementMatch.Success)@@ -263,16 +270,21 @@ public static class PrismaticProfileCompositionParservar profileName = profileMatch.Groups["profile"].Value; var face = support.Groups["face"].Value; var height = N(heightMatch, "value");if (!names.Add(name)) { diagnostics.Add($"compose-duplicate-operation:{name}"); continue; }if (!profiles.TryGetValue(profileName, out var bossProfile)) { diagnostics.Add($"firmament-boss-invalid-profile:{name}:profile={profileName}"); continue; }- if (!IsTopSelector(face)) { diagnostics.Add($"firmament-boss-invalid-target:{name}:On={face}:supported=Top-or-<feature>.Top"); continue; }if (!double.IsFinite(height) || height <= 0d) { diagnostics.Add($"firmament-boss-height-must-be-positive:{name}:height={height:R}mm"); continue; }- var candidates = ResolveTopSupports(face, stock, operations, bossProfile, profiles);+ surfaceSpans.TryGetValue(face, out var supportSpan);+ if (supportSpan is null && !IsTopSelector(face)) { diagnostics.Add($"firmament-boss-invalid-target:{name}:On={face}:supported=Top-or-<feature>.Top-or-Span<Plane>"); continue; }+ if (supportSpan is not null && !IsProfileFootprintInsideSpan(supportSpan, bossProfile, profiles))+ { diagnostics.Add($"firmament-feature-footprint-outside-span:{name}:{face}:profile={profileName}"); continue; }+ var candidates = supportSpan is null+ ? ResolveTopSupports(face, stock, operations, bossProfile, profiles)+ : ResolveSpanTopSupports(supportSpan, operations, bossProfile, profiles);if (candidates.Count == 0) { diagnostics.Add(face.EndsWith(".Top", StringComparison.Ordinal)? $"feature-support-not-found:{name}:{face}:host={compose.Groups["n"].Value}:profile={profileName}": $"firmament-boss-disconnected-from-host:{name}:host={compose.Groups["n"].Value}:profile={profileName}:support=Top"); continue; }if (candidates.Count > 1) { diagnostics.Add($"feature-support-ambiguous:Top:feature={name}:candidates={string.Join(",", candidates.Select(x => x.Name).Order(StringComparer.Ordinal))}"); continue; }var selectedSupport = candidates[0];var stableId = $"boss:{compose.Groups["n"].Value}.{name}"; var sourceSpan = $"offset:{header.Index}";- bosses.Add(new(name, stableId, compose.Groups["n"].Value, face, profileName, height, selectedSupport.To, selectedSupport.To + height, sourceSpan));+ bosses.Add(new(name, stableId, compose.Groups["n"].Value, face, profileName, height, selectedSupport.To, selectedSupport.To + height, sourceSpan, supportSpan?.SpanId, supportSpan?.ParentId));operations.Add(new(name, PrismaticProfileIntent.Add, profileName, selectedSupport.To, selectedSupport.To + height, "Boss", sourceSpan, stableId, "Boss"));}@@ -286,9 +298,14 @@ public static class PrismaticProfileCompositionParservar profileName = profileMatch.Groups["profile"].Value; var face = support.Groups["face"].Value; var depth = N(depthMatch, "value");if (!names.Add(name)) { diagnostics.Add($"compose-duplicate-operation:{name}"); continue; }if (!profiles.TryGetValue(profileName, out var pocketProfile)) { diagnostics.Add($"firmament-pocket-invalid-profile:{name}:profile={profileName}"); continue; }- if (!IsTopSelector(face)) { diagnostics.Add($"firmament-pocket-invalid-target:{name}:On={face}:supported=Top-or-<feature>.Top"); continue; }if (!double.IsFinite(depth) || depth <= 0d) { diagnostics.Add($"firmament-pocket-depth-must-be-positive:{name}:depth={depth:R}mm"); continue; }- var candidates = ResolveTopSupports(face, stock, operations, pocketProfile, profiles, requireContainment: true);+ surfaceSpans.TryGetValue(face, out var supportSpan);+ if (supportSpan is null && !IsTopSelector(face)) { diagnostics.Add($"firmament-pocket-invalid-target:{name}:On={face}:supported=Top-or-<feature>.Top-or-Span<Plane>"); continue; }+ if (supportSpan is not null && !IsProfileFootprintInsideSpan(supportSpan, pocketProfile, profiles))+ { diagnostics.Add($"firmament-feature-footprint-outside-span:{name}:{face}:profile={profileName}"); continue; }+ var candidates = supportSpan is null+ ? ResolveTopSupports(face, stock, operations, pocketProfile, profiles, requireContainment: true)+ : ResolveSpanTopSupports(supportSpan, operations, pocketProfile, profiles);if (candidates.Count == 0) { diagnostics.Add($"feature-support-not-found:{name}:{face}:profile={profileName}:footprint-must-be-enclosed-by-support"); continue; }if (candidates.Count > 1) { diagnostics.Add($"feature-support-ambiguous:Top:feature={name}:candidates={string.Join(",", candidates.Select(x => x.Name).Order(StringComparer.Ordinal))}"); continue; }var selectedSupport = candidates[0];@@ -310,7 +327,7 @@ public static class PrismaticProfileCompositionParsercontinue;}var stableId = $"pocket:{compose.Groups["n"].Value}.{name}"; var sourceSpan = $"offset:{header.Index}";- pockets.Add(new(name, stableId, compose.Groups["n"].Value, face, profileName, depth, hostThickness, remaining, minimumFloor, policySource, selectedSupport.To - depth, selectedSupport.To, sourceSpan));+ pockets.Add(new(name, stableId, compose.Groups["n"].Value, face, profileName, depth, hostThickness, remaining, minimumFloor, policySource, selectedSupport.To - depth, selectedSupport.To, sourceSpan, supportSpan?.SpanId, supportSpan?.ParentId));operations.Add(new(name, PrismaticProfileIntent.Remove, profileName, selectedSupport.To - depth, selectedSupport.To, "Pocket", sourceSpan, stableId, "Pocket"));}}@@ -358,8 +375,10 @@ public static class PrismaticProfileCompositionParser{if (!end.Success || !string.Equals(end.Groups["end"].Value, "ThroughAll", StringComparison.OrdinalIgnoreCase)){ diagnostics.Add($"ComposeCounterboreEndUnsupported:{name}:supported=ThroughAll"); continue; }- if (!on.Success || !string.Equals(on.Groups["face"].Value, "+Z", StringComparison.OrdinalIgnoreCase))- { diagnostics.Add($"ComposeCounterboreAxisUnsupported:{name}:supported=+Z"); continue; }+ var supportName = on.Success ? on.Groups["face"].Value : null;+ surfaceSpans.TryGetValue(supportName ?? string.Empty, out var supportSpan);+ if (!on.Success || (!string.Equals(supportName, "+Z", StringComparison.OrdinalIgnoreCase) && supportSpan is null))+ { diagnostics.Add($"ComposeCounterboreAxisUnsupported:{name}:supported=+Z-or-Span<Plane>"); continue; }if (!center.Success || !diameter.Success || !counterboreDiameter.Success || !counterboreDepth.Success){ diagnostics.Add($"ComposeCounterboreMissingRequiredField:{name}"); continue; }var counterboreX = N(center, "x"); var counterboreY = N(center, "y"); var shaftDiameter = N(diameter, "d"); var boreDiameter = N(counterboreDiameter, "d"); var boreDepth = N(counterboreDepth, "d");@@ -372,6 +391,17 @@ public static class PrismaticProfileCompositionParservar counterboreStableId = $"hole:{compose.Groups["n"].Value}.{name}";if (!CircleContainedInBaseProfile(operations, profiles, counterboreX, counterboreY, boreDiameter / 2d)){ diagnostics.Add($"ComposeCounterboreFootprintLeavesProfileMaterial:{name}:radius={boreDiameter / 2d:R}"); continue; }+ double? supportMargin = null;+ if (supportSpan is not null)+ {+ var parentNormal = supportSpan.ParentPlane!.AxisZ.ToVector();+ if (Math.Abs(parentNormal.X) > 1e-8d || Math.Abs(parentNormal.Y) > 1e-8d || parentNormal.Z < 1d - 1e-8d+ || Math.Abs(supportSpan.ParentPlane.Origin.Z - materialTo) > 1e-7d)+ { diagnostics.Add($"firmament-feature-support-parent-mismatch:{name}:{supportSpan.SpanId}"); continue; }+ if (!PlanarSpanContainment.ContainsCircle(supportSpan, counterboreX, counterboreY, boreDiameter / 2d, out var margin))+ { diagnostics.Add($"firmament-feature-footprint-outside-span:{name}:{supportSpan.SpanId}:center=[{counterboreX:R},{counterboreY:R}]:radius={boreDiameter / 2d:R}:margin={margin:R}"); continue; }+ supportMargin = margin;+ }if (IntersectsExistingCircularCavity(shaftHoles, counterboreHoles, counterboreX, counterboreY, boreDiameter / 2d)){ diagnostics.Add($"ComposeCounterboreIntersectsExistingCavity:{name}"); continue; }var shaftProfile = $"{name}ShaftProfile"; var boreProfile = $"{name}CounterboreProfile";@@ -379,7 +409,7 @@ public static class PrismaticProfileCompositionParserprofiles.Add(shaftProfile, CircleProfile(shaftProfile, counterboreX, counterboreY, shaftDiameter / 2d, counterboreStableId, $"offset:{header.Index}"));profiles.Add(boreProfile, CircleProfile(boreProfile, counterboreX, counterboreY, boreDiameter / 2d, counterboreStableId, $"offset:{header.Index}"));var counterboreSourceSpan = $"offset:{header.Index}"; var counterboreSemanticRole = role.Success ? role.Groups["role"].Value : "CounterboreHole";- counterboreHoles.Add(new(name, counterboreStableId, shaftProfile, boreProfile, counterboreX, counterboreY, shaftDiameter, boreDiameter, boreDepth, materialFrom, materialTo, counterboreSemanticRole, counterboreSourceSpan));+ counterboreHoles.Add(new(name, counterboreStableId, shaftProfile, boreProfile, counterboreX, counterboreY, shaftDiameter, boreDiameter, boreDepth, materialFrom, materialTo, counterboreSemanticRole, counterboreSourceSpan, supportSpan?.SpanId, supportSpan?.ParentId, supportMargin));operations.Add(new($"{name}Shaft", PrismaticProfileIntent.Remove, shaftProfile, materialFrom, materialTo, counterboreSemanticRole, counterboreSourceSpan, counterboreStableId, "Hole<Counterbore>", shaftDiameter));operations.Add(new($"{name}Counterbore", PrismaticProfileIntent.Remove, boreProfile, materialTo - boreDepth, materialTo, counterboreSemanticRole, counterboreSourceSpan, counterboreStableId, "Hole<Counterbore>", boreDiameter));continue;@@ -394,6 +424,19 @@ public static class PrismaticProfileCompositionParservar profileName = $"{name}ShaftProfile";if (profiles.ContainsKey(profileName)) { diagnostics.Add($"compose-hole-profile-name-collision:{name}:{profileName}"); continue; }var stableId = $"hole:{compose.Groups["n"].Value}.{name}";+ GeometricSpanView? shaftSupport = null; double? shaftSupportMargin = null;+ if (on.Success && !string.Equals(on.Groups["face"].Value, "+Z", StringComparison.OrdinalIgnoreCase))+ {+ if (!surfaceSpans.TryGetValue(on.Groups["face"].Value, out shaftSupport))+ { diagnostics.Add($"compose-hole-support-not-found:{name}:{on.Groups["face"].Value}"); continue; }+ var parentNormal = shaftSupport.ParentPlane!.AxisZ.ToVector();+ if (Math.Abs(parentNormal.X) > 1e-8d || Math.Abs(parentNormal.Y) > 1e-8d || parentNormal.Z < 1d - 1e-8d+ || Math.Abs(shaftSupport.ParentPlane.Origin.Z - materialTo) > 1e-7d)+ { diagnostics.Add($"firmament-feature-support-parent-mismatch:{name}:{shaftSupport.SpanId}"); continue; }+ if (!PlanarSpanContainment.ContainsCircle(shaftSupport, x, y, d / 2d, out var margin))+ { diagnostics.Add($"firmament-feature-footprint-outside-span:{name}:{shaftSupport.SpanId}:center=[{x:R},{y:R}]:radius={d / 2d:R}:margin={margin:R}"); continue; }+ shaftSupportMargin = margin;+ }var holeProfile = CircleProfile(profileName, x, y, d / 2d, stableId, $"offset:{header.Index}");var validation = ResolvedProfile2DValidator.Validate(holeProfile);diagnostics.AddRange(validation.Diagnostics);@@ -401,7 +444,7 @@ public static class PrismaticProfileCompositionParserprofiles.Add(profileName, holeProfile);var semanticRole = role.Success ? role.Groups["role"].Value : "ShaftHole";var sourceSpan = $"offset:{header.Index}";- shaftHoles.Add(new(name, stableId, profileName, x, y, d, materialFrom, materialTo, semanticRole, sourceSpan));+ shaftHoles.Add(new(name, stableId, profileName, x, y, d, materialFrom, materialTo, semanticRole, sourceSpan, shaftSupport?.SpanId, shaftSupport?.ParentId, shaftSupportMargin));operations.Add(new(name, PrismaticProfileIntent.Remove, profileName, materialFrom, materialTo, semanticRole, sourceSpan, stableId, "Hole<Shaft>", d));}// Source order must not decide whether an intersecting shaft/counterbore@@ -450,6 +493,33 @@ public static class PrismaticProfileCompositionParserprivate static bool IsTopSelector(string selector) => selector is "Top" or "+Z" || selector.EndsWith(".Top", StringComparison.Ordinal);+ private static IReadOnlyList<PrismaticProfileOperation> ResolveSpanTopSupports(+ GeometricSpanView span,+ IReadOnlyList<PrismaticProfileOperation> operations,+ ResolvedProfile2D footprint,+ IReadOnlyDictionary<string, ResolvedProfile2D> profiles)+ {+ if (span.ParentPlane is null) return [];+ var top = span.ParentPlane.Origin.Z;+ return operations.Where(operation => operation.Intent != PrismaticProfileIntent.Remove+ && Math.Abs(operation.To - top) <= PlanarSpanContainment.Tolerance+ && IsPocketFootprintInsideStock(operation, footprint, profiles))+ .ToArray();+ }++ private static bool IsProfileFootprintInsideSpan(+ GeometricSpanView span,+ ResolvedProfile2D footprint,+ IReadOnlyDictionary<string, ResolvedProfile2D> profiles)+ {+ if (span.Boundary is null) return false;+ var available = profiles.ContainsKey(span.Boundary.Name)+ ? profiles+ : new Dictionary<string, ResolvedProfile2D>(profiles, StringComparer.Ordinal) { [span.Boundary.Name] = span.Boundary };+ var support = new PrismaticProfileOperation("SpanSupport", PrismaticProfileIntent.Base, span.Boundary.Name, 0d, 1d, "SpanSupport", span.Provenance);+ return IsPocketFootprintInsideStock(support, footprint, available);+ }+private static IReadOnlyList<PrismaticProfileOperation> ResolveTopSupports(string selector,PrismaticProfileOperation stock,diff --git a/docs/public/firmament/spans.md b/docs/public/firmament/spans.mdindex ecb5d6b6..5aeb93e2 100644--- a/docs/public/firmament/spans.md+++ b/docs/public/firmament/spans.md@@ -14,15 +14,38 @@ Span<Line> MountingEdge {Use the resulting name wherever a normal pipeline guide is accepted. `Orientation: Reverse` reverses traversal; it does not change the bounded domain. Curve inspection reports the parent, endpoint domain, orientation, length, and provenance through `aetheris inspect-spans part.firmament --json`.-`Span<Plane>` is the bounded surface lane. Its boundary is a named Profile and it remains a semantic view: X1 does not create an independent face, infer a boundary from BRep edges, accept holes, or support arbitrary trimmed/freeform surfaces.+`Span<Plane>` represents a bounded semantic region on an existing planar support. It preserves the parent support identity and constrains where dependent features may apply. Its closed, non-self-intersecting boundary is an ordinary named Profile evaluated in parent-local 2D coordinates.```firmamentSpan<Plane> MountArea {On: MountPlaneBoundary: MountBoundary}++Hole<Counterbore> MountHole {+ On: MountArea+ Center: [16mm, 9mm]+ Diameter: 8mm+ CounterboreDiameter: 16mm+ CounterboreDepth: 3mm+ End: ThroughAll+}```-`MountPlane` must be a named `Construction Plane`; a span never finds a nearby BRep face to replace a missing parent.+`MountPlane` must be a named `Construction Plane`; a span never finds a nearby BRep face to replace a missing parent. `Hole`, `Boss`, and `Pocket` accept a planar Span on the current prismatic top support. Hole containment checks the complete shaft/counterbore disk, and Boss/Pocket containment checks the actual Profile footprint. Pattern expansion validates every generated feature independently.++Points on the boundary are boundary-valid. Containment uses the same `1e-7 mm` analytic line/arc tolerance as the Profile arrangement engine. Inner Profile loops are excluded and contribute negatively to inspected area. Invalid or missing parents and boundaries fail; consumers never fall back to the whole plane.++A `Span<Plane>` is not automatically a BRep Face. It may describe a region inside one Face, and STEP export continues through the parent body's existing topology without splitting that face merely to carry a name. `inspect-spans --json` reports the boundary, area, inherited normal and frame, consumers, and validity. Feature inspection retains both the Span and its parent support.++The current FEA frontend requires an exact `BoundaryRegionCapability` backed by a continuum or BRep region, and current PMI records target admitted faces, holes, or recognized regions. Planar Span binding for those consumers is not yet qualified; neither silently expands a Span to its parent face.++The constraint-first ladder is:++```text+Concept<T> what must be true+Span<T> bounded subset where it is true+Feature semantic transformation applied against those constraints+````Span<T>` is a built-in closed language type, not Template generic programming. Other types—including `Material`, `Body`, and `Feature`—are rejected during binding. A Span is contiguous; use separate named spans for separate intervals.diff --git a/docs/release/LANG-SPAN-SURFACE-X1.md b/docs/release/LANG-SPAN-SURFACE-X1.mdnew file mode 100644index 00000000..fb3c2c1b--- /dev/null+++ b/docs/release/LANG-SPAN-SURFACE-X1.md@@ -0,0 +1,82 @@+# LANG-SPAN-SURFACE-X1 — bounded surface support semantics++## Executive verdict++**Meaningful progression.** `Span<Plane>` is now a real bounded engineering support for `Hole`, `Boss`, `Pocket`, and finite Pattern expansion without becoming separate topology. Feature placement, containment, provenance, STEP export/reimport, determinism, and packaged-CLI parity are qualified. FEA selection and PMI association remain deferred because their current authorities require exact analysis/BRep region bindings or admitted face/hole targets; substituting the parent face would violate the bounded-support law.++## Pre-change audit++At baseline commit `e920321e`, `GeometricSpanView` stored Span identity/type, parent identity/type, textual domain, orientation, endpoints or boundary Profile name, optional curve length, provenance, and an internal curve for curve spans. `Span<Plane>` retained only the names of a Construction Plane and boundary Profile. The boundary was semantic-only: it was not resolved, validated, measured, or materialized. Consumers could not distinguish bounded support from the parent because no feature, FEA, or PMI consumer bound the Span.++The reusable authorities were already present: `ResolvedProfile2DValidator` owns closed, planar, non-self-intersecting Profile validity; `ProfileArrangementBuilder.PointInProfile` owns analytic line/arc point classification including inner loops; Profile arrangement already proves actual Profile containment for prismatic features; and Hole/Boss/Pocket already lower through the section-stack construction. Surface containment therefore belongs at semantic consumer binding, before BodyState mutation, using those authorities. No new geometry backend is needed.++FEA normalizes a `SemanticReference` only when it carries `BoundaryRegionCapability` and an `ExactAnalysisRegionBinding`, `ExactBrepFaceBinding`, or `ExactBrepRegionBinding`. PMI validation admits face selectors, named holes, aliases, and recognized regions. Neither baseline seam represented a bounded Profile domain, so neither could be honestly enabled by name recognition alone.++## Semantics and policy++A planar Span contains the points lying on its referenced Construction Plane and inside its referenced Profile. It retains the parent object, resolved boundary, inherited local frame and normal, orientation, boundary identity, area, provenance, and consumers. It does not copy the plane. Rebinding resolves both names on every compile, so parent/boundary edits propagate and missing or invalid identities fail.++The boundary must pass ordinary Profile validation. A Profile authored in `XY` or in a `Concept Struct ... On XY` layout is interpreted as parent-local 2D geometry; an explicitly different Construction Plane is rejected with `firmament-span-surface-boundary-off-parent:<span>`. Exact boundary points are boundary-valid under the Profile arrangement tolerance (`1e-7 mm`). Area is deterministic outer-loop area minus inner-loop areas.++Point containment delegates to the established arrangement classifier. Circular Hole footprints additionally use exact minimum distance to bounded line, arc, and circle curves, so center-inside is insufficient. Boss/Pocket profiles use the existing arrangement-based full-footprint containment proof. The nonrectangular diamond and circular-arc tests prevent AABB substitution; the ring test proves inner-loop exclusion.++## Support matrix++| Consumer | Span accepted | Containment | Provenance retained | External artifact |+| --- | --- | --- | --- | --- |+| Hole Shaft/Counterbore | yes | complete circular footprint; largest counterbore governs | Span and parent, plus signed boundary margin | existing AP242 body geometry; no Span reconstruction |+| Boss | yes | actual Profile footprint | Span and parent | existing AP242 body geometry |+| Pocket | yes | actual Profile footprint | Span and parent | existing AP242 body geometry |+| Pattern | yes | every expanded instance | generated instance plus Span and parent | finite Pattern report and existing geometry |+| FEA Fixed | no | deferred | no fallback | none |+| FEA Force/Pressure/Traction | no | deferred | no fallback | none |+| PMI | no | deferred | no fallback | AP242 remains face/hole-level only |++Boss/Pocket support is qualified only for the existing prismatic top-support route. Imported faces and nonplanar surfaces remain outside X1.++## Topology and semantics++```text+Plate.Top Face+ one topological face++MountingArea Span<Plane>+ parent: TopSupport+ boundary: MountBoundary+ semantic bounded region within the top support+```++No face is split. The Span is semantic support authority; it becomes product geometry only indirectly when an admitted feature changes the body.++## Feature evidence++The canonical flagship is `fixtures/Canonical/Span/plane-hole-support.firmament`: a 100 x 80 x 8 mm plate, a 2,880 mm2 diamond mounting Span, and a finite four-instance Pattern of M8 counterbores. Each instance preserves `SupportSpan=MountingArea`, `ParentSupport=TopSupport`, and a positive 1.4715918833 mm minimum margin. It lowers through the existing `PrismaticSectionStack/Remove` route and materializes an enclosed manifold.++`fixtures/Invalid/Span/plane-hole-footprint-crossing.firmament` moves Pattern instance 3 so the 16 mm counterbore disk crosses the diamond. Compilation fails before construction with `firmament-feature-footprint-outside-span:MountPattern_3:MountingArea`, center `[28,9]`, radius `8`, and margin `-5.482693553`; no STEP is emitted. Tests also prove that the same location on whole `+Z` support passes, shrinking only the boundary invalidates a previously valid feature, and moving the parent plane and host together preserves local containment while moving feature extents.++Boss and Pocket witnesses validate rectangular Profile footprints, preserve both support identities, and use their existing Add/Remove lowering. A profile crossing the Span produces the same typed footprint diagnostic.++## Export and determinism evidence++The flagship exports through the existing AP242 path. Reinspection reports one enclosed manifold body, 46 faces, 116 edges, and 76 vertices; surfaces are 14 planes and 32 cylinders, curves are 52 lines and 64 circles, with zero B-spline, rational, unsupported, or faceted fallback. Two repository exports and a fresh `dotnet publish` CLI export were byte-identical at SHA-256 `B894DF6FA97216F2DF847CB503A81248991E67970A7E198D9CC3828E264913D2`.++STEP intentionally carries the resulting body geometry, not an invented sub-face association. Rich Span identity remains in source/build inspection.++## Deferred analysis and PMI++FEA cannot be qualified by passing `MountingArea` as a path string: quadrature and node selection obtain exact selected area and normal from `IPlanarBoundaryDomainCapability`, while semantic normalization requires an exact analysis/BRep region binding. A bounded Profile-to-continuum binding and empty-selection policy are the next real work. Applying the load or constraint to the parent face would be incorrect.++PMI has no generic annotation/leader record in the admitted grammar. Datum and geometric-tolerance targets ultimately require current face/recognized-region semantics, while HoleDiameter targets holes. X1 therefore reports Span consumers for features only and makes no AP242 sub-face association claim.++## Validation++Local qualification completed:++- Release solution build: passed, zero warnings and zero errors.+- Firmament suite: 1,366 passed, zero failed or skipped; focused surface-Span lane: 10 passed.+- CLI suite: 416 passed, zero failed or skipped; focused surface-Span CLI lane: 6 passed.+- FEA regression suite: 27 passed, zero failed or skipped.+- Canonical and invalid CLI validation, `inspect-spans`, feature inspection, actual materialization, STEP export/reimport, deterministic repeat, and fresh packaged-CLI parity: passed.+- Repository layout guard: passed for 3,988 tracked files; `git diff --check`: passed.++Future bounded work is `LANG-SPAN-SURFACE-X2` for cylinder/cone/B-spline domains, `LANG-REGION-X1` for composite or disconnected regions, and `IMPORT-SPAN-X1` for imported BRep supports. None is implemented here.diff --git a/docs/release/LANG-SPAN-X1.md b/docs/release/LANG-SPAN-X1.mdindex 9a0ac5db..cdcd1c4a 100644--- a/docs/release/LANG-SPAN-X1.md+++ b/docs/release/LANG-SPAN-X1.md@@ -1,5 +1,7 @@# LANG-SPAN-X1 — geometric span views+> Subsequent planar-support qualification: [LANG-SPAN-SURFACE-X1](LANG-SPAN-SURFACE-X1.md). This document retains the original curve-view milestone verdict.+## Verdict**Meaningful progression.** Firmament can now name a bounded curve view over an existing planar line or circle guide and compose that view into the established Profile/Path pipeline without creating a copied guide. It also has a semantic `Span<Plane>` declaration that retains a named boundary Profile, but planar support validation and feature/FEA consumption are intentionally not claimed yet.diff --git a/fixtures/Canonical/Span/plane-hole-support.firmament b/fixtures/Canonical/Span/plane-hole-support.firmamentnew file mode 100644index 00000000..73e60192--- /dev/null+++ b/fixtures/Canonical/Span/plane-hole-support.firmament@@ -0,0 +1,56 @@+schema Mechanical++Model PlaneHoleSupport {+ Units: mm++ Concept Struct Supports {+ Top: Plane { Origin: [0mm,0mm,8mm]; Normal: [0,0,1]; Up: [0,1,0] }+ }+ Construction Plane TopSupport { Trace: Supports.Top }++ Record MountSpec { Center: Point2 }+ Static Mounts: MountSpec[] = [+ MountSpec { Center: Point2(-16mm, -9mm) }+ MountSpec { Center: Point2(16mm, -9mm) }+ MountSpec { Center: Point2(-16mm, 9mm) }+ MountSpec { Center: Point2(16mm, 9mm) }+ ]+ Template<spec: MountSpec> M8Counterbore {+ Hole<Counterbore> Mount {+ On: MountingArea+ Center: spec.Center+ Diameter: 8mm+ CounterboreDiameter: 16mm+ CounterboreDepth: 3mm+ End: ThroughAll+ }+ }++ Concept Struct Layout On XY {+ Rect2 Stock { Center: [0mm,0mm]; Size: [100mm,80mm] }+ Point2 South { Position: [0mm,-32mm] }+ Point2 East { Position: [45mm,0mm] }+ Point2 North { Position: [0mm,32mm] }+ Point2 West { Position: [-45mm,0mm] }+ Line2 SE { From: South; To: East }+ Line2 EN { From: East; To: North }+ Line2 NW { From: North; To: West }+ Line2 WS { From: West; To: South }+ }++ Profile StockProfile Using Layout {+ Loop Outer { Stock.Bottom |> Stock.Right |> Stock.Top |> Stock.Left |> Close }+ }+ Profile MountBoundary Using Layout {+ Loop Outer { SE |> EN |> NW |> WS |> Close }+ }++ Span<Plane> MountingArea { On: TopSupport; Boundary: MountBoundary }++ Struct Part {+ Compose Plate {+ Base StockBody { Profile: StockProfile; From: 0mm; To: 8mm; Role: Stock }+ Pattern MountPattern Over Mounts { M8Counterbore<Current> }+ }+ }+}diff --git a/fixtures/Invalid/Span/plane-boundary-off-parent.firmament b/fixtures/Invalid/Span/plane-boundary-off-parent.firmamentnew file mode 100644index 00000000..0ac85e93--- /dev/null+++ b/fixtures/Invalid/Span/plane-boundary-off-parent.firmament@@ -0,0 +1,16 @@+schema Mechanical++Model OffParentSurfaceSpanBoundary {+ Units: mm+ Concept Struct Supports {+ Top: Plane { Origin: [0mm,0mm,8mm]; Normal: [0,0,1]; Up: [0,1,0] }+ Offset: Plane { Origin: [0mm,0mm,9mm]; Normal: [0,0,1]; Up: [0,1,0] }+ }+ Construction Plane TopSupport { Trace: Supports.Top }+ Construction Plane OffsetSupport { Trace: Supports.Offset }+ Concept Struct Layout On XY { Rect2 Stock { Center: [0mm,0mm]; Size: [40mm,30mm] } }+ Profile StockProfile Using Layout { Loop Outer { Stock.Bottom |> Stock.Right |> Stock.Top |> Stock.Left |> Close } }+ Profile OffsetBoundary Using OffsetSupport { Loop Outer { Stock.Bottom |> Stock.Right |> Stock.Top |> Stock.Left |> Close } }+ Span<Plane> InvalidArea { On: TopSupport; Boundary: OffsetBoundary }+ Struct Part { Compose Body { Base StockBody { Profile: StockProfile; From: 0mm; To: 8mm; Role: Stock } } }+}diff --git a/fixtures/Invalid/Span/plane-boundary-open.firmament b/fixtures/Invalid/Span/plane-boundary-open.firmamentnew file mode 100644index 00000000..728543c9--- /dev/null+++ b/fixtures/Invalid/Span/plane-boundary-open.firmament@@ -0,0 +1,14 @@+schema Mechanical++Model OpenSurfaceSpanBoundary {+ Units: mm+ Concept Struct Supports { Top: Plane { Origin: [0mm,0mm,8mm]; Normal: [0,0,1]; Up: [0,1,0] } }+ Construction Plane TopSupport { Trace: Supports.Top }+ Concept Struct Layout On XY {+ Rect2 Stock { Center: [0mm,0mm]; Size: [40mm,30mm] }+ }+ Profile StockProfile Using Layout { Loop Outer { Stock.Bottom |> Stock.Right |> Stock.Top |> Stock.Left |> Close } }+ Profile OpenBoundary Using Layout { Loop Outer { Stock.Bottom |> Stock.Right |> Stock.Top } }+ Span<Plane> InvalidArea { On: TopSupport; Boundary: OpenBoundary }+ Struct Part { Compose Body { Base StockBody { Profile: StockProfile; From: 0mm; To: 8mm; Role: Stock } } }+}diff --git a/fixtures/Invalid/Span/plane-hole-footprint-crossing.firmament b/fixtures/Invalid/Span/plane-hole-footprint-crossing.firmamentnew file mode 100644index 00000000..134597f8--- /dev/null+++ b/fixtures/Invalid/Span/plane-hole-footprint-crossing.firmament@@ -0,0 +1,56 @@+schema Mechanical++Model InvalidPlaneHoleSupport {+ Units: mm++ Concept Struct Supports {+ Top: Plane { Origin: [0mm,0mm,8mm]; Normal: [0,0,1]; Up: [0,1,0] }+ }+ Construction Plane TopSupport { Trace: Supports.Top }++ Record MountSpec { Center: Point2 }+ Static Mounts: MountSpec[] = [+ MountSpec { Center: Point2(-16mm, -9mm) }+ MountSpec { Center: Point2(16mm, -9mm) }+ MountSpec { Center: Point2(-16mm, 9mm) }+ MountSpec { Center: Point2(28mm, 9mm) }+ ]+ Template<spec: MountSpec> M8Counterbore {+ Hole<Counterbore> Mount {+ On: MountingArea+ Center: spec.Center+ Diameter: 8mm+ CounterboreDiameter: 16mm+ CounterboreDepth: 3mm+ End: ThroughAll+ }+ }++ Concept Struct Layout On XY {+ Rect2 Stock { Center: [0mm,0mm]; Size: [100mm,80mm] }+ Point2 South { Position: [0mm,-32mm] }+ Point2 East { Position: [45mm,0mm] }+ Point2 North { Position: [0mm,32mm] }+ Point2 West { Position: [-45mm,0mm] }+ Line2 SE { From: South; To: East }+ Line2 EN { From: East; To: North }+ Line2 NW { From: North; To: West }+ Line2 WS { From: West; To: South }+ }++ Profile StockProfile Using Layout {+ Loop Outer { Stock.Bottom |> Stock.Right |> Stock.Top |> Stock.Left |> Close }+ }+ Profile MountBoundary Using Layout {+ Loop Outer { SE |> EN |> NW |> WS |> Close }+ }++ Span<Plane> MountingArea { On: TopSupport; Boundary: MountBoundary }++ Struct Part {+ Compose Plate {+ Base StockBody { Profile: StockProfile; From: 0mm; To: 8mm; Role: Stock }+ Pattern MountPattern Over Mounts { M8Counterbore<Current> }+ }+ }+}