Skip to content

Next Gen STEP AP242 Native-ish BREP Geometric Modeling Kernel

Expand profile pipelines with subspan geometry and alias support

Yuechen Li58542cd2ecf4
diff --git a/Aetheris.Kernel.Firmament.Tests/ProfilePipelineX1Tests.cs b/Aetheris.Kernel.Firmament.Tests/ProfilePipelineX1Tests.cs
index 3ba666f1..5951fb96 100644
--- a/Aetheris.Kernel.Firmament.Tests/ProfilePipelineX1Tests.cs
+++ b/Aetheris.Kernel.Firmament.Tests/ProfilePipelineX1Tests.cs
@@ -104,7 +104,7 @@ public sealed class ProfilePipelineX1Tests
Profile Plate { Loop Outer {
Stock.Bottom |> Stock.Right |> Stock.Top |> Stock.Left |> Close
} Loop Inner {
- Reverse Cutout.Bottom |> Reverse Cutout.Left |> Reverse Cutout.Top |> Reverse Cutout.Right |> Close
+ Reverse Cutout.Bottom As CutoutBottom |> Reverse Cutout.Left As CutoutLeft |> Reverse Cutout.Top As CutoutTop |> Reverse Cutout.Right As CutoutRight |> Close
} }
Extrude Solid { Profile: Plate; From: 0mm; To: 2mm }
""");
@@ -152,11 +152,11 @@ public sealed class ProfilePipelineX1Tests
}
[Fact]
- public void TraceLoop_NormalizesInnerWindingAndQualifiesInheritedIdentity()
+ public void TraceLoop_NormalizesInnerWindingAndPreservesLeafIdentity()
{
var parsed = ProfileAuthoringParser.Parse("""
Concept Path OuterPath { Start: Point2(0mm, 0mm) Heading: 0deg Line Bottom { Length: 20mm } Line Right { Turn: 90deg; Length: 20mm } Line Top { Turn: 90deg; Length: 20mm } Close Left }
- Concept Path InnerPath { Start: Point2(5mm, 5mm) Heading: 0deg Line Bottom { Length: 10mm } Line Right { Turn: 90deg; Length: 10mm } Line Top { Turn: 90deg; Length: 10mm } Close Left }
+ Concept Path InnerPath { Start: Point2(5mm, 5mm) Heading: 0deg Line InnerBottom { Length: 10mm } Line InnerRight { Turn: 90deg; Length: 10mm } Line InnerTop { Turn: 90deg; Length: 10mm } Close InnerLeft }
Profile Plate { Loop Outer { OuterPath |> TraceLoop } Loop Inner { InnerPath |> TraceLoop } }
Extrude Solid { Profile: Plate; From: 0mm; To: 2mm }
""");
@@ -165,7 +165,7 @@ public sealed class ProfilePipelineX1Tests
Assert.Empty(parsed.Diagnostics);
Assert.All(profile.Loops.Single(loop => !loop.IsOuter).Segments, segment =>
{
- Assert.StartsWith("Inner.", segment.Name, StringComparison.Ordinal);
+ Assert.StartsWith("Inner", segment.Name, StringComparison.Ordinal);
Assert.True(segment.Provenance.Reversed);
});
Assert.True(ResolvedProfile2DValidator.Validate(profile).IsValid);
@@ -174,7 +174,7 @@ public sealed class ProfilePipelineX1Tests
[Theory]
[InlineData("Stock.Bottom |> Stock.Top |> Close", "firmament-profile-pipeline-disconnected:Stock.Top")]
[InlineData("Stock.Bottom |> Stock.Right |> Stock.Top |> Stock.Left |> Stock.Bottom |> Close", "firmament-profile-pipeline-identity-collision:Bottom")]
- [InlineData("Stock.Bottom |> Material |> Close", "firmament-pipeline-stage-type:Material")]
+ [InlineData("Stock.Bottom |> Material |> Close", "firmament-pipeline-unknown-guide:Material")]
[InlineData("Stock.Bottom |> Stock.Right |> Close", "firmament-pipeline-close-open:Outer")]
public void InvalidPipeline_ReportsTypedDiagnostic(string expression, string expected)
{
@@ -205,7 +205,7 @@ public sealed class ProfilePipelineX1Tests
[Theory]
[InlineData("Stock.Bottom + 1mm |> Stock.Right", "firmament-profile-pipeline-expression-required")]
[InlineData("Stock.Bottom |> If(Stock.Right)", "firmament-profile-pipeline-expression-required")]
- [InlineData("Stock.Bottom |> Pattern", "firmament-pipeline-stage-type:Pattern")]
+ [InlineData("Stock.Bottom |> Pattern", "firmament-pipeline-unknown-guide:Pattern")]
public void PipelineGrammar_IsLowPrecedenceQualifiedGeometryOnly(string expression, string expected)
{
var parsed = ProfileAuthoringParser.Parse($$"""
@@ -250,6 +250,225 @@ public sealed class ProfilePipelineX1Tests
Assert.Contains("firmament-pipeline-context-type:Material", parsed.Diagnostics);
}
+ [Fact]
+ public void SubspanPipeline_AuthorsCanonicalLBracketWithPreservedIdentity()
+ {
+ var parsed = ProfileAuthoringParser.Parse("""
+ Rect2 Horizontal { Center: [0mm, -10mm]; Size: [80mm, 20mm] }
+ Rect2 Vertical { Center: [-30mm, 10mm]; Size: [20mm, 60mm] }
+ Point2 Notch { Position: [-20mm, 0mm] }
+ Profile Bracket { Loop Outer {
+ Horizontal.Bottom As South
+ |> Horizontal.Right As East
+ |> Horizontal.Top To Notch As Inner
+ |> Vertical.Right To Vertical.TopRight As Upright
+ |> Vertical.Top As North
+ |> Vertical.Left To Horizontal.BottomLeft As West
+ |> Close
+ } }
+ Extrude Solid { Profile: Bracket; From: 0mm; To: 12mm }
+ """);
+
+ var profile = Assert.IsType<ResolvedProfile2D>(parsed.Profile);
+ Assert.Empty(parsed.Diagnostics);
+ Assert.Equal(["South", "East", "Inner", "Upright", "North", "West"], profile.Loops.Single().Segments.Select(segment => segment.Name));
+ Assert.Equal(new LineArcLineSegment2D((-40, -20), (40, -20)), profile.Loops.Single().Segments[0].Geometry);
+ Assert.Equal(new LineArcLineSegment2D((40, 0), (-20, 0)), profile.Loops.Single().Segments[2].Geometry);
+ }
+
+ [Fact]
+ public void SubspanMigrationOracle_LBracketAndSphereAreCanonicalDumpIdentical()
+ {
+ const string layout = """
+ Rect2 Horizontal { Center: [0mm, -10mm]; Size: [80mm, 20mm] }
+ Rect2 Vertical { Center: [-30mm, 10mm]; Size: [20mm, 60mm] }
+ Point2 Notch { Position: [-20mm, 0mm] }
+ """;
+ var manualBracket = ProfileAuthoringParser.ResolveNamedProfile(layout + """
+ Profile Bracket { Loop Outer {
+ Segment South { Trace: Horizontal.Bottom; From: Horizontal.BottomLeft; To: Horizontal.BottomRight }
+ Segment East { Trace: Horizontal.Right; From: Horizontal.BottomRight; To: Horizontal.TopRight }
+ Segment Inner { Trace: Horizontal.Top; From: Horizontal.TopRight; To: Notch }
+ Segment Upright { Trace: Vertical.Right; From: Notch; To: Vertical.TopRight }
+ Segment North { Trace: Vertical.Top; From: Vertical.TopRight; To: Vertical.TopLeft }
+ Segment West { Trace: Vertical.Left; From: Vertical.TopLeft; To: Horizontal.BottomLeft }
+ } }
+ """, "Bracket", out var manualBracketDiagnostics);
+ var pipelineBracket = ProfileAuthoringParser.ResolveNamedProfile(layout + """
+ Profile Bracket { Loop Outer {
+ Horizontal.Bottom As South |> Horizontal.Right As East |> Horizontal.Top To Notch As Inner
+ |> Vertical.Right To Vertical.TopRight As Upright |> Vertical.Top As North
+ |> Vertical.Left To Horizontal.BottomLeft As West |> Close
+ } }
+ """, "Bracket", out var pipelineBracketDiagnostics);
+
+ const string sphereLayout = """
+ Point2 South { Position: [0mm, -20mm] } Point2 North { Position: [0mm, 20mm] }
+ Point2 Center { Position: [0mm, 0mm] } Concept Circle2 Meridian { Center: Center; Radius: 20mm }
+ Line2 Diameter { From: North; To: South }
+ """;
+ var manualSphere = ProfileAuthoringParser.ResolveNamedProfile(sphereLayout + """
+ Profile SphereSection { Loop Outer {
+ Segment Arc { Trace: Meridian; From: South; To: North; Sweep: CounterClockwise }
+ Segment AxisClosure { Trace: Diameter; From: North; To: South }
+ } }
+ """, "SphereSection", out var manualSphereDiagnostics);
+ var pipelineSphere = ProfileAuthoringParser.ResolveNamedProfile(sphereLayout + """
+ Profile SphereSection { Loop Outer { Meridian From South To North As Arc |> Diameter As AxisClosure |> Close } }
+ """, "SphereSection", out var pipelineSphereDiagnostics);
+
+ Assert.Empty(manualBracketDiagnostics); Assert.Empty(pipelineBracketDiagnostics);
+ Assert.Empty(manualSphereDiagnostics); Assert.Empty(pipelineSphereDiagnostics);
+ Assert.Equal(CanonicalDump(Assert.IsType<ResolvedProfile2D>(manualBracket)), CanonicalDump(Assert.IsType<ResolvedProfile2D>(pipelineBracket)));
+ Assert.Equal(CanonicalDump(Assert.IsType<ResolvedProfile2D>(manualSphere)), CanonicalDump(Assert.IsType<ResolvedProfile2D>(pipelineSphere)));
+ }
+
+ [Fact]
+ public void OpeningSubspan_UsesExplicitFromAndReverseCanSelectNaturalEnd()
+ {
+ var forward = ProfileAuthoringParser.Parse("""
+ Point2 A { Position: [0mm, 0mm] } Point2 B { Position: [10mm, 0mm] }
+ Point2 M { Position: [5mm, 0mm] } Point2 C { Position: [5mm, 5mm] }
+ Line2 Base { From: A; To: B } Line2 MC { From: M; To: C } Line2 CA { From: C; To: A }
+ Profile P { Base From A To M As Partial |> MC |> CA |> Close }
+ Extrude Solid { Profile: P; From: 0mm; To: 1mm }
+ """);
+ var reverse = ProfileAuthoringParser.Parse("""
+ Point2 A { Position: [0mm, 0mm] } Point2 B { Position: [10mm, 0mm] } Point2 C { Position: [0mm, 5mm] }
+ Line2 Base { From: A; To: B } Line2 AC { From: A; To: C } Line2 CB { From: C; To: B }
+ Profile P { Reverse Base To A As Partial |> AC |> CB |> Close }
+ Extrude Solid { Profile: P; From: 0mm; To: 1mm }
+ """);
+
+ Assert.Empty(forward.Diagnostics);
+ Assert.Equal(new LineArcLineSegment2D((0, 0), (5, 0)), Assert.IsType<ResolvedProfile2D>(forward.Profile).Loops.Single().Segments[0].Geometry);
+ Assert.Empty(reverse.Diagnostics);
+ Assert.Equal(new LineArcLineSegment2D((10, 0), (0, 0)), Assert.IsType<ResolvedProfile2D>(reverse.Profile).Loops.Single().Segments[0].Geometry);
+ }
+
+ [Fact]
+ public void CircleSubspan_ExpressesHalfCircleWithoutSweep()
+ {
+ var parsed = ProfileAuthoringParser.Parse("""
+ Point2 South { Position: [0mm, -20mm] } Point2 North { Position: [0mm, 20mm] } Point2 Center { Position: [0mm, 0mm] }
+ Concept Circle2 Meridian { Center: Center; Radius: 20mm }
+ Line2 Diameter { From: North; To: South }
+ Profile SphereSection { Meridian From South To North As Arc |> Diameter As AxisClosure |> Close }
+ Extrude Solid { Profile: SphereSection; From: 0mm; To: 1mm }
+ """);
+
+ var profile = Assert.IsType<ResolvedProfile2D>(parsed.Profile);
+ Assert.Empty(parsed.Diagnostics);
+ var arc = Assert.IsType<LineArcCircularArc2D>(profile.Loops.Single().Segments[0].Geometry);
+ Assert.Equal(Math.PI, arc.SweepAngleRadians, 12);
+ Assert.Equal(["Arc", "AxisClosure"], profile.Loops.Single().Segments.Select(segment => segment.Name));
+ }
+
+ [Fact]
+ public void InlineGuideDeclarations_CoexistWithOneImplicitPipeline()
+ {
+ var parsed = ProfileAuthoringParser.Parse("""
+ Profile SideProfile {
+ Rect2 Outline { Center: [0mm, 0mm]; Size: [20mm, 10mm] }
+ Point2 Witness { Position: [0mm, 0mm] }
+ Outline |> TraceLoop
+ }
+ Extrude Solid { Profile: SideProfile; From: -5mm; To: 5mm }
+ """);
+
+ Assert.Empty(parsed.Diagnostics);
+ Assert.Equal(4, Assert.IsType<ResolvedProfile2D>(parsed.Profile).Loops.Single().Segments.Count);
+ }
+
+ [Fact]
+ public void InlineDeclaration_WithSecondPipeline_IsRejectedAsAmbiguous()
+ {
+ var parsed = ProfileAuthoringParser.Parse("""
+ Profile P {
+ Rect2 A { Center: [0mm, 0mm]; Size: [10mm, 10mm] }
+ Rect2 B { Center: [20mm, 0mm]; Size: [10mm, 10mm] }
+ A |> TraceLoop
+ B |> TraceLoop
+ }
+ Extrude Solid { Profile: P; From: 0mm; To: 1mm }
+ """);
+
+ Assert.Null(parsed.Profile);
+ Assert.Contains("firmament-profile-pipeline-expression-required:P:Outer", parsed.Diagnostics);
+ }
+
+ [Theory]
+ [InlineData("Rect2 Shape { Center: [0mm, 0mm]; Size: [10mm, 6mm] }")]
+ [InlineData("Square2 Shape { Center: [0mm, 0mm]; Size: 10mm }")]
+ [InlineData("Polygon2<Rhombus> Shape { Center: [0mm, 0mm]; Diagonals: [10mm, 6mm] }")]
+ [InlineData("RegularPolygon2<5> Shape { Center: [0mm, 0mm]; Circumradius: 5mm }")]
+ [InlineData("Circle2 Shape { Center: [0mm, 0mm]; Radius: 5mm }")]
+ [InlineData("Ellipse2 Shape { Center: [0mm, 0mm]; AxisLengths: [10mm, 6mm] }")]
+ public void TraceLoop_AdmitsClosedOrderedGuideFamilies(string declaration)
+ {
+ var parsed = ProfileAuthoringParser.Parse($$"""
+ {{declaration}}
+ Profile P { Shape |> TraceLoop }
+ Extrude Solid { Profile: P; From: 0mm; To: 1mm }
+ """);
+
+ Assert.Empty(parsed.Diagnostics);
+ Assert.NotEmpty(Assert.IsType<ResolvedProfile2D>(parsed.Profile).Loops.Single().Segments);
+ }
+
+ [Fact]
+ public void ReverseMidChain_IsPreferenceAndFallsBackToForwardConnectivity()
+ {
+ var parsed = ProfileAuthoringParser.Parse("""
+ Rect2 Stock { Center: [0mm, 0mm]; Size: [10mm, 5mm] }
+ Profile Plate { Stock.Bottom |> Reverse Stock.Right |> Stock.Top |> Stock.Left |> Close }
+ Extrude Solid { Profile: Plate; From: 0mm; To: 1mm }
+ """);
+
+ var profile = Assert.IsType<ResolvedProfile2D>(parsed.Profile);
+ Assert.Empty(parsed.Diagnostics);
+ Assert.False(profile.Loops.Single().Segments[1].Provenance.Reversed);
+ }
+
+ [Fact]
+ public void CrossLoopLeafCollision_IsExplicitAndAliasesResolveIt()
+ {
+ var collision = ProfileAuthoringParser.Parse("""
+ Rect2 OuterBox { Center: [0mm, 0mm]; Size: [20mm, 20mm] }
+ Rect2 InnerBox { Center: [0mm, 0mm]; Size: [6mm, 6mm] }
+ Profile Plate { Loop Outer { OuterBox |> TraceLoop } Loop Inner { InnerBox |> TraceLoop } }
+ Extrude Solid { Profile: Plate; From: 0mm; To: 1mm }
+ """);
+ Assert.Null(collision.Profile);
+ Assert.Contains(collision.Diagnostics, diagnostic => diagnostic.StartsWith("firmament-profile-segment-identity-collision:Bottom:loops=Inner,Outer", StringComparison.Ordinal));
+
+ var aliased = ProfileAuthoringParser.Parse("""
+ Rect2 OuterBox { Center: [0mm, 0mm]; Size: [20mm, 20mm] }
+ Rect2 InnerBox { Center: [0mm, 0mm]; Size: [6mm, 6mm] }
+ Profile Plate { Loop Outer { OuterBox |> TraceLoop } Loop Inner {
+ Reverse InnerBox.Bottom As CutoutBottom |> Reverse InnerBox.Left As CutoutLeft |> Reverse InnerBox.Top As CutoutTop |> Reverse InnerBox.Right As CutoutRight |> Close
+ } }
+ Extrude Solid { Profile: Plate; From: 0mm; To: 1mm }
+ """);
+ Assert.Empty(aliased.Diagnostics);
+ Assert.NotNull(aliased.Profile);
+ }
+
+ [Theory]
+ [InlineData("Stock.Bottom To Missing |> Stock.Right |> Close", "firmament-pipeline-unknown-endpoint:Missing")]
+ [InlineData("Missing |> Close", "firmament-pipeline-unknown-guide:Missing")]
+ [InlineData("Stock.Bottom |> Close |> Stock.Right", "firmament-pipeline-stage-type:Close")]
+ public void PipelineDiagnostics_DistinguishEndpointGuideAndStageErrors(string expression, string expected)
+ {
+ var parsed = ProfileAuthoringParser.Parse($$"""
+ Rect2 Stock { Center: [0mm, 0mm]; Size: [10mm, 5mm] }
+ Profile Plate { {{expression}} }
+ Extrude Solid { Profile: Plate; From: 0mm; To: 1mm }
+ """);
+ Assert.Null(parsed.Profile);
+ Assert.Contains(parsed.Diagnostics, diagnostic => diagnostic.StartsWith(expected, StringComparison.Ordinal));
+ }
+
private static string RectanglePipeline() => """
Rect2 Stock { Center: [0mm, 0mm]; Size: [10mm, 5mm] }
Profile Plate { Loop Outer {
@@ -270,5 +489,8 @@ public sealed class ProfilePipelineX1Tests
""";
private static string Signature(ResolvedProfile2D profile) => string.Join("|", profile.Loops.SelectMany(loop => loop.Segments).Select(segment => segment.Geometry.ToString()));
+ private static string CanonicalDump(ResolvedProfile2D profile) => string.Join("\n", new[] { $"frame:{profile.PlaneFrame}" }.Concat(
+ profile.Loops.SelectMany(loop => new[] { $"loop:{loop.Name}:{loop.IsOuter}" }.Concat(
+ loop.Segments.Select(segment => $"segment:{segment.Name}:{segment.Geometry}")))));
private static bool AreSame(LineArcProfileCurve2D left, LineArcProfileCurve2D right) => left == right;
}
diff --git a/Aetheris.Kernel.Firmament.Tests/SurfaceSpanSupportX1Tests.cs b/Aetheris.Kernel.Firmament.Tests/SurfaceSpanSupportX1Tests.cs
index 8b9e5e98..3496f321 100644
--- a/Aetheris.Kernel.Firmament.Tests/SurfaceSpanSupportX1Tests.cs
+++ b/Aetheris.Kernel.Firmament.Tests/SurfaceSpanSupportX1Tests.cs
@@ -185,7 +185,7 @@ public sealed class SurfaceSpanSupportX1Tests
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 } }
+ Loop Inner { Reverse Inner.Bottom As InnerBottom |> Reverse Inner.Left As InnerLeft |> Reverse Inner.Top As InnerTop |> Reverse Inner.Right As InnerRight |> Close } }
Span<Plane> RingArea { On: TopSupport; Boundary: Ring }
""";
diff --git a/Aetheris.Kernel.Firmament/FirmamentV2/ClosedBoundary2Authoring.cs b/Aetheris.Kernel.Firmament/FirmamentV2/ClosedBoundary2Authoring.cs
index 79c8388d..a94a219e 100644
--- a/Aetheris.Kernel.Firmament/FirmamentV2/ClosedBoundary2Authoring.cs
+++ b/Aetheris.Kernel.Firmament/FirmamentV2/ClosedBoundary2Authoring.cs
@@ -54,8 +54,14 @@ internal static class ClosedBoundary2Authoring
foreach (var shape in shapes)
{
if (shape.LoweredSource is not null) changes.Add((shape.Start, shape.Length, shape.LoweredSource));
- foreach (Match trace in Regex.Matches(source, $@"\b{Regex.Escape(shape.Declaration.Name)}\s*\|>\s*TraceLoop\b", RegexOptions.CultureInvariant))
- if (!Inside(trace.Index, shapes) && !InTemplate(trace.Index)) changes.Add((trace.Index, trace.Length, shape.TraceExpression));
+ foreach (Match trace in Regex.Matches(source, $@"\b{Regex.Escape(shape.Declaration.Name)}(?:\s+As\s+(?<alias>[A-Za-z_]\w*))?\s*\|>\s*TraceLoop\b", RegexOptions.CultureInvariant))
+ {
+ if (Inside(trace.Index, shapes) || InTemplate(trace.Index)) continue;
+ var replacement = shape.TraceExpression;
+ if (trace.Groups["alias"].Success && replacement.Count(character => character == '|') == 1)
+ replacement = replacement.Replace(" |> TraceLoop", $" As {trace.Groups["alias"].Value} |> TraceLoop", StringComparison.Ordinal);
+ changes.Add((trace.Index, trace.Length, replacement));
+ }
foreach (var member in shape.MemberMap)
foreach (Match reference in Regex.Matches(source, $@"\b{Regex.Escape(shape.Declaration.Name)}\s*\.\s*{Regex.Escape(member.Key)}\b", RegexOptions.CultureInvariant))
if (!Inside(reference.Index, shapes) && !InTemplate(reference.Index)) changes.Add((reference.Index, reference.Length, member.Value));
diff --git a/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2Parser.cs b/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2Parser.cs
index 9c1c5057..85c8bbc8 100644
--- a/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2Parser.cs
+++ b/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2Parser.cs
@@ -413,6 +413,13 @@ public static class FirmamentV2Parser
if (Regex.IsMatch(source, @"\bRoundedBox\s+[A-Za-z_]", RegexOptions.CultureInvariant))
return Recognized(ParseRoundedBoxModelingDocument(source, diagnostics));
+ // Standalone Profile documents predate the canonical Model wrapper. Keep that
+ // bounded document form usable when its body uses the preferred pipeline surface,
+ // including inline guide declarations, instead of falling into an unrelated
+ // historical modeling parser merely because a Construction Plane has a Concept owner.
+ if (ProfileAuthoringParser.IsProfileSource(source) && Regex.IsMatch(source, @"\bExtrude\s+[A-Za-z_]\w*\s*\{", RegexOptions.CultureInvariant))
+ return Recognized(ParseStandaloneProfileDocument(source, diagnostics));
+
if (Regex.IsMatch(source, @"\bConcept\s+(?:Struct\s+)?[A-Za-z_]", RegexOptions.CultureInvariant)
|| Regex.IsMatch(source, @"\b(?:Struct|Model)\s+[A-Za-z_][A-Za-z0-9_]*\s*(?::\s*[A-Za-z_][A-Za-z0-9_]*)?\s*\{", RegexOptions.CultureInvariant))
return Recognized(WithFeatureMetadata(
@@ -1792,6 +1799,26 @@ public static class FirmamentV2Parser
return FirmamentV2ParseResult.Failure(diagnostics.Distinct(StringComparer.Ordinal).Order().ToArray());
}
+ private static FirmamentV2ParseResult ParseStandaloneProfileDocument(string source, List<string> diagnostics)
+ {
+ var parsed = ProfileAuthoringParser.Parse(source);
+ diagnostics.AddRange(parsed.Diagnostics);
+ if (parsed.Profile is null || diagnostics.Any(IsFatalDiagnosticCode))
+ return CanonicalFailure(diagnostics, CanonicalDocumentMalformed);
+
+ var profile = parsed.Profile;
+ var extrude = Regex.Match(source, @"\bExtrude\s+(?<name>[A-Za-z_]\w*)\s*\{", RegexOptions.CultureInvariant);
+ var solidName = extrude.Success ? extrude.Groups["name"].Value : profile.Name;
+ var document = new FirmamentV2Document(
+ profile.Name,
+ "mm",
+ [new FirmamentV2SolidBinding(solidName, "Profile", new FirmamentV2AdvancedMaterialRecord("Profile"))],
+ Profiles: [new FirmamentV2ProfileDecl(profile.Name, profile.EffectiveConstructionPlane.StableId, profile.LocalStartDepth ?? 0d, profile.LocalEndDepth ?? parsed.Height, new(0, source.Length))]);
+ diagnostics.Add("firmament-v2-standalone-profile-parsed");
+ diagnostics.Add("firmament-v2-parse-succeeded");
+ return FirmamentV2ParseResult.Success(document, diagnostics.Distinct(StringComparer.Ordinal).Order(StringComparer.Ordinal).ToArray());
+ }
+
private static FirmamentV2ParseResult ParsePhase3ModelingDocument(string source, List<string> diagnostics)
{
var model = Regex.Match(source, @"^\s*Model\s+(?<name>[A-Za-z_][A-Za-z0-9_]*)\s+(?<units>[A-Za-z_][A-Za-z0-9_]*)\b", RegexOptions.CultureInvariant);
@@ -2042,7 +2069,7 @@ public static class FirmamentV2Parser
|| code.StartsWith(ConceptIrResolver.PointProjectionUnsupported, StringComparison.Ordinal)
|| code.StartsWith("firmament-static-", StringComparison.Ordinal);
- public static bool IsFatalDiagnosticCode(string code) => code.StartsWith(RevolveAuthoringParser.Prefix, StringComparison.Ordinal) || code.StartsWith(FirmamentV2FeatureExpansion.Prefix, StringComparison.Ordinal) || code.StartsWith("firmament-pipeline-", StringComparison.Ordinal) || code.StartsWith("firmament-profile-pipeline-", StringComparison.Ordinal) || code.StartsWith("firmament-profile-traceloop-", StringComparison.Ordinal) || code.StartsWith("firmament-boss-", StringComparison.Ordinal) || code.StartsWith("firmament-pocket-", StringComparison.Ordinal) || code.StartsWith("feature-support-", StringComparison.Ordinal) || code.StartsWith("compose-role-cardinality:", StringComparison.Ordinal) || code.StartsWith(ModifyTargetNotBoundToActiveCompose, StringComparison.Ordinal) || code.StartsWith("firmament-v2-assert-volume-", StringComparison.Ordinal) || code.StartsWith(SemanticConstraintMalformed, StringComparison.Ordinal) || code.StartsWith(SemanticConstraintUnsupported, StringComparison.Ordinal) || code.StartsWith(SemanticConstraintDimensionMismatch, StringComparison.Ordinal) || code.StartsWith(SemanticConstraintValidationFailed, StringComparison.Ordinal) || code.StartsWith(PmiProjectionUnknownRequire, StringComparison.Ordinal) || code.StartsWith(PmiProjectionUnsupportedKind, StringComparison.Ordinal) || code.StartsWith(PmiProjectedFieldMustNotOverrideSourceConstraint, StringComparison.Ordinal) || code.StartsWith(AssertVolumeKindUnsupported, StringComparison.Ordinal) || code.StartsWith(CanonicalDeclarationUnknown + ":", StringComparison.Ordinal) || code.StartsWith(CanonicalConstructNotYetSupported + ":", StringComparison.Ordinal) || code.StartsWith(EdgeFinishProfileComposeBoundaryUnsupported, StringComparison.Ordinal) || IsConceptFatalDiagnostic(code) || code is UnknownConstructionPolicy or PrimitiveDoesNotSatisfyHollowConstructible or WallThicknessRequired or WallThicknessMustBePositive or UnsupportedOpening or MultipleOpeningsNotSupported or Phase3EdgeFinishSyntaxInvalid or PrimitiveFieldMissing or PrimitiveFieldUnknown or PrimitiveFieldInvalid or MissingModel or MissingUnits or MissingSolid or UnsupportedConstruct or UnknownRecordType or BoxMissingSize or BoxSizeArity or DegenerateDimension or NameUnresolved or DuplicateName or WithRequiresRecord or WithRequiresBoxRecord or WithFieldNotFound or WithFieldTypeMismatch or WithForwardReference or WithDerivedRecordInvalid or ExposeBlockUnsupported or ExposeRequiresBoxRecord or ExposeAliasDuplicate or ExposeAliasInvalid or SelectorUnsupported or SelectorAxisInvalid or SelectorSubselectorUnsupported or FatArrowOutsideExpose or RawBackendIdReferenceForbidden or ModifyTargetUnresolved or ModifyTargetNotSolid or RegionUnsupported or RegionAttachmentSelectorUnsupported or CutUnsupported or CutToolUnsupported or CylinderRadiusMissing or CylinderRadiusInvalid or CylinderRadiusNotFinite or ThroughSelectorUnsupported or AliasUnresolved or AliasRefTypeUnsupported or SideHoleAliasMustResolveToFace or SideHoleAliasResolvesToUnsupportedFace or SideHoleOnlyPlusXMinusXSupported or SideHoleRouteUnsupported or SideHoleSameFaceUnsupported or SideHoleAxisNotYetSupported or SideHoleRadiusExceedsClearance or CylinderCenterInvalid or CylinderCenterArityInvalid or CylinderCenterNotFinite or SideHoleCenterExceedsClearance or HoleVariantUnknown or HoleEntryFaceMissing or HoleCenterMissing or HoleShaftMissing or HoleEndMissing or HoleDiameterInvalid or HoleDepthInvalid or HoleCounterboreInvalid or HoleCountersinkInvalid or PmiKindUnknown or PmiTargetMissing or PmiTargetUnresolved or PmiDiameterInvalid or PmiDuplicateName or InlineStepUnknownBody or InlineStepUnknownFace or PmiImportedTargetNotFace or PmiImportedTargetRequiresCanonicalStep or PmiInvalidImportedTarget or InlineStepPathMissing or InlineStepPathInvalid or InlineStepFileMissing or InlineStepRequiresCanonical or UnknownRecognitionBody or UnknownRecognitionFace or DuplicateRegion or UnknownRecognitionRegion or InvalidRecognitionKind or InvalidRecognitionConfidence or PmiRecognizedRegionKindMismatch or UnknownReplacementBody or UnknownReplacementRegion or ReplacementKindMismatch or ReplacementFaceUnresolved or ReplacementUnsupportedKind or ReplacementVerificationFailed or ReplacementRadiusInvalid or ReplacementEndUnsupported or LetDuplicateName or LetUnknownType or LetMismatch or LetInvalidLiteral or LetUnitMismatch or LetLiteralOnly or LetRecordDuplicateName or LetRecordDuplicateField or LetReferenceUnknownRecord or LetReferenceUnknownField or LetReferenceNonRecord or LetReferenceRecordUsedAsValue or ExpressionUnknownSymbol or ExpressionUnknownRecord or ExpressionUnknownField or ExpressionRecordUsedAsValue or ExpressionScalarUsedAsRecord or ExpressionTypeMismatch or ExpressionInvalidOperator or ExpressionDivisionByZero or ExpressionCycle or ExpressionUnsupported or ToleranceInvalidType or ToleranceUnitMismatch or ToleranceInvalidLiteral or ToleranceNegativeBilateral or ToleranceMissingMinus or ToleranceMissingPlus or ToleranceUnsupported or RecognitionEvidenceRadiusInvalid or RecognitionEvidenceSurfaceFamilyUnknown or RecognitionEvidenceAxisInvalid or SemanticProposalKindMismatch or SemanticProposalRadiusInvalid or SemanticProposalTargetUnresolved or SemanticProposalEndUnsupported or ConceptUnknownFamily or ConceptUnknownConcept or ConceptMissingRequiredField or ConceptUnknownField or ConceptDuplicateField or ConceptFieldTypeMismatch or ConceptInvalidTarget or ConceptDescriptorUnavailable or PmiDuplicateBlock or PmiDuplicateRecord or PmiDuplicateDatum or PmiUnknownRecordKind or PmiMissingRequiredField or PmiUnknownField or PmiDuplicateField or PmiInvalidTarget or PmiUnknownDatum or PmiDimensionTypeMismatch or PmiDimensionMissingTolerance or PmiToleranceTypeMismatch or StandaloneFillRegionRequired or UnsupportedStandaloneFillPattern or InvalidCellCount or CellSizeMustBePositive or StrutRadiusMustBePositive or NodeRadiusMustBePositive or MaterialBoundsMismatch or StandaloneFillMultipleUnsupported;
+ public static bool IsFatalDiagnosticCode(string code) => code.StartsWith(RevolveAuthoringParser.Prefix, StringComparison.Ordinal) || code.StartsWith(FirmamentV2FeatureExpansion.Prefix, StringComparison.Ordinal) || code.StartsWith("firmament-pipeline-", StringComparison.Ordinal) || code.StartsWith("firmament-profile-pipeline-", StringComparison.Ordinal) || code.StartsWith("firmament-profile-traceloop-", StringComparison.Ordinal) || code.StartsWith("firmament-profile-segment-", StringComparison.Ordinal) || code.StartsWith("firmament-boss-", StringComparison.Ordinal) || code.StartsWith("firmament-pocket-", StringComparison.Ordinal) || code.StartsWith("feature-support-", StringComparison.Ordinal) || code.StartsWith("compose-role-cardinality:", StringComparison.Ordinal) || code.StartsWith(ModifyTargetNotBoundToActiveCompose, StringComparison.Ordinal) || code.StartsWith("firmament-v2-assert-volume-", StringComparison.Ordinal) || code.StartsWith(SemanticConstraintMalformed, StringComparison.Ordinal) || code.StartsWith(SemanticConstraintUnsupported, StringComparison.Ordinal) || code.StartsWith(SemanticConstraintDimensionMismatch, StringComparison.Ordinal) || code.StartsWith(SemanticConstraintValidationFailed, StringComparison.Ordinal) || code.StartsWith(PmiProjectionUnknownRequire, StringComparison.Ordinal) || code.StartsWith(PmiProjectionUnsupportedKind, StringComparison.Ordinal) || code.StartsWith(PmiProjectedFieldMustNotOverrideSourceConstraint, StringComparison.Ordinal) || code.StartsWith(AssertVolumeKindUnsupported, StringComparison.Ordinal) || code.StartsWith(CanonicalDeclarationUnknown + ":", StringComparison.Ordinal) || code.StartsWith(CanonicalConstructNotYetSupported + ":", StringComparison.Ordinal) || code.StartsWith(EdgeFinishProfileComposeBoundaryUnsupported, StringComparison.Ordinal) || IsConceptFatalDiagnostic(code) || code is UnknownConstructionPolicy or PrimitiveDoesNotSatisfyHollowConstructible or WallThicknessRequired or WallThicknessMustBePositive or UnsupportedOpening or MultipleOpeningsNotSupported or Phase3EdgeFinishSyntaxInvalid or PrimitiveFieldMissing or PrimitiveFieldUnknown or PrimitiveFieldInvalid or MissingModel or MissingUnits or MissingSolid or UnsupportedConstruct or UnknownRecordType or BoxMissingSize or BoxSizeArity or DegenerateDimension or NameUnresolved or DuplicateName or WithRequiresRecord or WithRequiresBoxRecord or WithFieldNotFound or WithFieldTypeMismatch or WithForwardReference or WithDerivedRecordInvalid or ExposeBlockUnsupported or ExposeRequiresBoxRecord or ExposeAliasDuplicate or ExposeAliasInvalid or SelectorUnsupported or SelectorAxisInvalid or SelectorSubselectorUnsupported or FatArrowOutsideExpose or RawBackendIdReferenceForbidden or ModifyTargetUnresolved or ModifyTargetNotSolid or RegionUnsupported or RegionAttachmentSelectorUnsupported or CutUnsupported or CutToolUnsupported or CylinderRadiusMissing or CylinderRadiusInvalid or CylinderRadiusNotFinite or ThroughSelectorUnsupported or AliasUnresolved or AliasRefTypeUnsupported or SideHoleAliasMustResolveToFace or SideHoleAliasResolvesToUnsupportedFace or SideHoleOnlyPlusXMinusXSupported or SideHoleRouteUnsupported or SideHoleSameFaceUnsupported or SideHoleAxisNotYetSupported or SideHoleRadiusExceedsClearance or CylinderCenterInvalid or CylinderCenterArityInvalid or CylinderCenterNotFinite or SideHoleCenterExceedsClearance or HoleVariantUnknown or HoleEntryFaceMissing or HoleCenterMissing or HoleShaftMissing or HoleEndMissing or HoleDiameterInvalid or HoleDepthInvalid or HoleCounterboreInvalid or HoleCountersinkInvalid or PmiKindUnknown or PmiTargetMissing or PmiTargetUnresolved or PmiDiameterInvalid or PmiDuplicateName or InlineStepUnknownBody or InlineStepUnknownFace or PmiImportedTargetNotFace or PmiImportedTargetRequiresCanonicalStep or PmiInvalidImportedTarget or InlineStepPathMissing or InlineStepPathInvalid or InlineStepFileMissing or InlineStepRequiresCanonical or UnknownRecognitionBody or UnknownRecognitionFace or DuplicateRegion or UnknownRecognitionRegion or InvalidRecognitionKind or InvalidRecognitionConfidence or PmiRecognizedRegionKindMismatch or UnknownReplacementBody or UnknownReplacementRegion or ReplacementKindMismatch or ReplacementFaceUnresolved or ReplacementUnsupportedKind or ReplacementVerificationFailed or ReplacementRadiusInvalid or ReplacementEndUnsupported or LetDuplicateName or LetUnknownType or LetMismatch or LetInvalidLiteral or LetUnitMismatch or LetLiteralOnly or LetRecordDuplicateName or LetRecordDuplicateField or LetReferenceUnknownRecord or LetReferenceUnknownField or LetReferenceNonRecord or LetReferenceRecordUsedAsValue or ExpressionUnknownSymbol or ExpressionUnknownRecord or ExpressionUnknownField or ExpressionRecordUsedAsValue or ExpressionScalarUsedAsRecord or ExpressionTypeMismatch or ExpressionInvalidOperator or ExpressionDivisionByZero or ExpressionCycle or ExpressionUnsupported or ToleranceInvalidType or ToleranceUnitMismatch or ToleranceInvalidLiteral or ToleranceNegativeBilateral or ToleranceMissingMinus or ToleranceMissingPlus or ToleranceUnsupported or RecognitionEvidenceRadiusInvalid or RecognitionEvidenceSurfaceFamilyUnknown or RecognitionEvidenceAxisInvalid or SemanticProposalKindMismatch or SemanticProposalRadiusInvalid or SemanticProposalTargetUnresolved or SemanticProposalEndUnsupported or ConceptUnknownFamily or ConceptUnknownConcept or ConceptMissingRequiredField or ConceptUnknownField or ConceptDuplicateField or ConceptFieldTypeMismatch or ConceptInvalidTarget or ConceptDescriptorUnavailable or PmiDuplicateBlock or PmiDuplicateRecord or PmiDuplicateDatum or PmiUnknownRecordKind or PmiMissingRequiredField or PmiUnknownField or PmiDuplicateField or PmiInvalidTarget or PmiUnknownDatum or PmiDimensionTypeMismatch or PmiDimensionMissingTolerance or PmiToleranceTypeMismatch or StandaloneFillRegionRequired or UnsupportedStandaloneFillPattern or InvalidCellCount or CellSizeMustBePositive or StrutRadiusMustBePositive or NodeRadiusMustBePositive or MaterialBoundsMismatch or StandaloneFillMultipleUnsupported;
private static IReadOnlyList<FirmamentV2Exposure> ParseExposures(string body, List<string> diagnostics)
{
diff --git a/Aetheris.Kernel.Firmament/FirmamentV2/ProfileAuthoringParser.cs b/Aetheris.Kernel.Firmament/FirmamentV2/ProfileAuthoringParser.cs
index a84bafa3..25141720 100644
--- a/Aetheris.Kernel.Firmament/FirmamentV2/ProfileAuthoringParser.cs
+++ b/Aetheris.Kernel.Firmament/FirmamentV2/ProfileAuthoringParser.cs
@@ -21,7 +21,7 @@ public static class ProfileAuthoringParser
private static readonly Regex ConstructionPlaneDeclaration = new(@"\bConstruction\s+Plane\s+(?<name>\w+)\s*\{\s*Trace\s*:\s*(?<trace>[\w.]+)\s*;?\s*\}", RegexOptions.Singleline | RegexOptions.CultureInvariant);
private static readonly Regex Segment = new(@"\bSegment\s+(?<n>\w+)\s*\{\s*Trace\s*:\s*(?<trace>[\w.]+)\s*;?\s*From\s*:\s*(?<from>[\w.]+)\s*;?\s*To\s*:\s*(?<to>[\w.]+)(?:\s*;?\s*Sweep\s*:\s*(?<sweep>Clockwise|CounterClockwise))?", RegexOptions.Singleline | RegexOptions.CultureInvariant);
private static readonly Regex SpanHeader = new(@"\bSpan\s*<\s*(?<type>[A-Za-z_]\w*)\s*>\s+(?<name>[A-Za-z_]\w*)\s*\{", RegexOptions.CultureInvariant);
- private static readonly Regex Pipeline = new(@"(?<expression>(?:Reverse\s+)?[A-Za-z_]\w*(?:\.[A-Za-z_]\w*)*(?:\s+As\s+[A-Za-z_]\w*)?\s*(?:\|>\s*(?:(?:Reverse\s+)?[A-Za-z_]\w*(?:\.[A-Za-z_]\w*)*(?:\s+As\s+[A-Za-z_]\w*)?|Close|TraceLoop)\s*)+)", RegexOptions.CultureInvariant);
+ private static readonly Regex Pipeline = new(@"(?<expression>(?:Reverse\s+)?[A-Za-z_]\w*(?:\.[A-Za-z_]\w*)*(?:\s+From\s+[A-Za-z_]\w*(?:\.[A-Za-z_]\w*)*)?(?:\s+To\s+[A-Za-z_]\w*(?:\.[A-Za-z_]\w*)*)?(?:\s+As\s+[A-Za-z_]\w*)?\s*(?:\|>\s*(?:(?:Reverse\s+)?[A-Za-z_]\w*(?:\.[A-Za-z_]\w*)*(?:\s+From\s+[A-Za-z_]\w*(?:\.[A-Za-z_]\w*)*)?(?:\s+To\s+[A-Za-z_]\w*(?:\.[A-Za-z_]\w*)*)?(?:\s+As\s+[A-Za-z_]\w*)?|Close|TraceLoop)\s*)+)", RegexOptions.CultureInvariant);
public static bool IsProfileSource(string source) => Regex.IsMatch(source, @"\bProfile\s+[A-Za-z_]\w*", RegexOptions.CultureInvariant);
@@ -379,7 +379,7 @@ public static class ProfileAuthoringParser
if (!result.TryAdd(name, default!)) { diagnostics.Add($"concept-path-duplicate:{name}"); continue; }
if (block.Body.Contains("|>", StringComparison.Ordinal))
{
- var pipelinePath = BindPathPipeline(name, block.Body, guides, diagnostics);
+ var pipelinePath = BindPathPipeline(name, block.Body, points, guides, diagnostics);
if (pipelinePath is not null)
{
result[name] = pipelinePath;
@@ -676,6 +676,12 @@ public static class ProfileAuthoringParser
if (loops.Count == 0 && !string.IsNullOrWhiteSpace(profile.Body))
loops.Add(new ResolvedProfileLoop2D("Outer", true, BindSegments(profile, "Outer", profile.Body, paths, points, guides, diagnostics)));
if (loops.Count == 0) diagnostics.Add($"profile-loop-missing:{profile.Name}");
+ foreach (var collision in loops.SelectMany(loop => loop.Segments.Select(segment => (Loop: loop.Name, Segment: segment.Name)))
+ .GroupBy(entry => entry.Segment, StringComparer.Ordinal).Where(group => group.Select(entry => entry.Loop).Distinct(StringComparer.Ordinal).Count() > 1))
+ {
+ var loopNames = collision.Select(entry => entry.Loop).Distinct(StringComparer.Ordinal).Order(StringComparer.Ordinal);
+ diagnostics.Add($"firmament-profile-segment-identity-collision:{collision.Key}:loops={string.Join(',', loopNames)}:use As alias or rename source guide/stage");
+ }
return loops;
}
@@ -689,6 +695,7 @@ public static class ProfileAuthoringParser
}
var matches = Pipeline.Matches(body).Cast<Match>().ToArray();
var unconsumed = matches.Aggregate(body, (remaining, pipeline) => remaining.Replace(pipeline.Value, string.Empty, StringComparison.Ordinal));
+ unconsumed = RemoveRecognizedProfileDeclarations(unconsumed);
if (matches.Length != 1 || unconsumed.Any(character => !char.IsWhiteSpace(character) && character != ';'))
{
diagnostics.Add($"firmament-profile-pipeline-expression-required:{profile.Name}:{loopName}");
@@ -702,8 +709,13 @@ public static class ProfileAuthoringParser
var stages = ParsePipelineStages(match.Groups["expression"].Value);
if (stages.Count == 2 && stages[1].Kind == PipelineStageKind.TraceLoop)
{
+ if (stages[0].Kind != PipelineStageKind.Trace || stages[0].From is not null || stages[0].To is not null)
+ {
+ diagnostics.Add("firmament-pipeline-stage-type:TraceLoop");
+ return [];
+ }
if (guides.TryGetValue(stages[0].Reference!, out var closedGuide) && closedGuide is LineArcFullCircle2D or LineArcFullEllipse2D)
- return [PipelineSegment(profile, loopName, loopName == "Outer" ? "Boundary" : $"{loopName}.Boundary", closedGuide, $"concept:{profile.Frame ?? "XY"}.{stages[0].Reference}", stages[0].Reference!, false, 0, match.Index)];
+ return [PipelineSegment(profile, loopName, stages[0].Alias ?? "Boundary", closedGuide, $"concept:{profile.Frame ?? "XY"}.{stages[0].Reference}", stages[0].Reference!, false, 0, match.Index)];
if (!paths.TryGetValue(stages[0].Reference!, out var path))
{
diagnostics.Add($"firmament-profile-traceloop-not-loop:{stages[0].Reference}");
@@ -721,7 +733,7 @@ public static class ProfileAuthoringParser
return curves.Select((entry, index) =>
{
var inherited = entry.Step.Curves.Count == 1 ? entry.Step.Name : $"{entry.Step.Name}.curve{entry.Ordinal:D2}";
- var name = string.Equals(loopName, "Outer", StringComparison.Ordinal) ? inherited : $"{loopName}.{inherited}";
+ var name = inherited;
return PipelineSegment(profile, loopName, name, entry.Curve, $"concept-path:{path.Name}.{entry.Step.Name}", $"{path.Name}.{entry.Step.Name}", reversedLoop, index, match.Index);
}).ToArray();
}
@@ -745,19 +757,27 @@ public static class ProfileAuthoringParser
for (var index = 0; index < traceStages.Length; index++)
{
var stage = traceStages[index];
- if (stage.Kind != PipelineStageKind.Trace || !guides.TryGetValue(stage.Reference!, out var source))
+ if (stage.Kind != PipelineStageKind.Trace)
{
diagnostics.Add($"firmament-pipeline-stage-type:{stage.Reference}");
continue;
}
- var oriented = OrientPipelineCurve(source, stage.Reverse, current, stage.Reference!, points, diagnostics, out var reversed);
+ if (!guides.TryGetValue(stage.Reference!, out var source))
+ {
+ diagnostics.Add($"firmament-pipeline-unknown-guide:{stage.Reference}");
+ continue;
+ }
+ bool reversed;
+ var oriented = stage.To is null
+ ? OrientPipelineCurve(source, stage.Reverse, current, stage.Reference!, points, diagnostics, out reversed)
+ : SelectPipelineSubspan(source, stage, current, points, diagnostics, out reversed);
if (oriented is null) continue;
var start = Start(oriented); var end = End(oriented);
first ??= start;
current = end;
currentIdentity = DescribeEndpoint(end, points);
var inheritedName = stage.Reference!.Split('.').Last();
- var name = stage.Alias ?? (string.Equals(loopName, "Outer", StringComparison.Ordinal) ? inheritedName : $"{loopName}.{inheritedName}");
+ var name = stage.Alias ?? inheritedName;
if (!names.Add(name)) { diagnostics.Add($"firmament-profile-pipeline-identity-collision:{name}"); continue; }
result.Add(PipelineSegment(profile, loopName, name, oriented, $"concept:{profile.Frame ?? "XY"}.{stage.Reference}", stage.Reference!, reversed, index, match.Index + stage.Offset));
}
@@ -766,7 +786,7 @@ public static class ProfileAuthoringParser
return result;
}
- private static BoundPath? BindPathPipeline(string name, string body, IReadOnlyDictionary<string, LineArcProfileCurve2D> guides, List<string> diagnostics)
+ private static BoundPath? BindPathPipeline(string name, string body, IReadOnlyDictionary<string, (double X, double Y)> points, IReadOnlyDictionary<string, LineArcProfileCurve2D> guides, List<string> diagnostics)
{
var match = Pipeline.Match(body);
var unconsumed = match.Success ? body.Replace(match.Value, string.Empty, StringComparison.Ordinal) : body;
@@ -786,8 +806,12 @@ public static class ProfileAuthoringParser
(double X, double Y)? current = null;
foreach (var stage in stages)
{
- if (!guides.TryGetValue(stage.Reference!, out var source)) { diagnostics.Add($"firmament-pipeline-stage-type:{stage.Reference}"); continue; }
- var oriented = OrientPipelineCurve(source, stage.Reverse, current, stage.Reference!, null, diagnostics, out var reversed);
+ if (stage.Kind != PipelineStageKind.Trace) { diagnostics.Add($"firmament-pipeline-stage-type:{stage.Reference}"); continue; }
+ if (!guides.TryGetValue(stage.Reference!, out var source)) { diagnostics.Add($"firmament-pipeline-unknown-guide:{stage.Reference}"); continue; }
+ bool reversed;
+ var oriented = stage.To is null
+ ? OrientPipelineCurve(source, stage.Reverse, current, stage.Reference!, points, diagnostics, out reversed)
+ : SelectPipelineSubspan(source, stage, current, points, diagnostics, out reversed);
if (oriented is null) continue;
var stepName = stage.Alias ?? stage.Reference!.Split('.').Last();
if (!names.Add(stepName)) { diagnostics.Add($"firmament-profile-pipeline-identity-collision:{stepName}"); continue; }
@@ -811,17 +835,116 @@ public static class ProfileAuthoringParser
var matchesStart = Distance(current.Value, Start(candidate)) <= Tolerance;
var matchesEnd = Distance(current.Value, End(candidate)) <= Tolerance;
if (matchesStart && matchesEnd) { diagnostics.Add($"firmament-profile-pipeline-orientation-ambiguous:{reference}"); return null; }
- if (explicitReverse)
- {
- if (!matchesStart) diagnostics.Add(Disconnected(current.Value, reference, candidate, points));
- return matchesStart ? candidate : null;
- }
+ if (explicitReverse && matchesStart) return candidate;
if (matchesStart) return candidate;
- if (matchesEnd) { reversed = true; return Reverse(candidate); }
+ if (matchesEnd) { reversed = !explicitReverse; return Reverse(candidate); }
diagnostics.Add(Disconnected(current.Value, reference, candidate, points));
return null;
}
+ private static LineArcProfileCurve2D? SelectPipelineSubspan(
+ LineArcProfileCurve2D source,
+ PipelineStage stage,
+ (double X, double Y)? current,
+ IReadOnlyDictionary<string, (double X, double Y)> points,
+ List<string> diagnostics,
+ out bool reversed)
+ {
+ reversed = false;
+ if (stage.From is not null && !points.TryGetValue(stage.From, out _))
+ {
+ diagnostics.Add($"firmament-pipeline-unknown-endpoint:{stage.From}");
+ return null;
+ }
+ if (stage.To is null || !points.TryGetValue(stage.To, out var end))
+ {
+ diagnostics.Add($"firmament-pipeline-unknown-endpoint:{stage.To}");
+ return null;
+ }
+
+ var start = stage.From is not null
+ ? points[stage.From]
+ : current ?? (stage.Reverse ? End(source) : Start(source));
+ if (current is not null && Distance(current.Value, start) > Tolerance)
+ {
+ diagnostics.Add(Disconnected(current.Value, stage.Reference!, source, points));
+ return null;
+ }
+
+ if (source is LineArcLineSegment2D line)
+ {
+ if (!OnBoundedLine(start, line) || !OnBoundedLine(end, line) || Distance(start, end) <= Tolerance)
+ {
+ diagnostics.Add($"firmament-pipeline-endpoint-not-on-guide:{stage.Reference}:{stage.From ?? DescribeEndpoint(start, points)}:{stage.To}");
+ return null;
+ }
+ var dx = line.End.X - line.Start.X; var dy = line.End.Y - line.Start.Y;
+ reversed = (end.X - start.X) * dx + (end.Y - start.Y) * dy < 0;
+ return new LineArcLineSegment2D(start, end);
+ }
+ if (source is LineArcFullCircle2D circle)
+ {
+ if (!OnCircle(start, circle.Center, circle.Radius) || !OnCircle(end, circle.Center, circle.Radius) || Distance(start, end) <= Tolerance)
+ {
+ diagnostics.Add($"firmament-pipeline-endpoint-not-on-guide:{stage.Reference}:{stage.From ?? DescribeEndpoint(start, points)}:{stage.To}");
+ return null;
+ }
+ var startAngle = Math.Atan2(start.Y - circle.Center.Y, start.X - circle.Center.X);
+ var sweep = Math.Atan2(end.Y - circle.Center.Y, end.X - circle.Center.X) - startAngle;
+ if (stage.Reverse) { while (sweep >= 0) sweep -= 2 * Math.PI; reversed = true; }
+ else while (sweep <= 0) sweep += 2 * Math.PI;
+ return new LineArcCircularArc2D(circle.Center, circle.Radius, startAngle, sweep);
+ }
+ if (source is LineArcCircularArc2D arc)
+ {
+ if (TrySelectArcSubspan(stage.Reverse ? (LineArcCircularArc2D)Reverse(arc) : arc, start, end, out var selected))
+ {
+ reversed = stage.Reverse;
+ return selected;
+ }
+ if (TrySelectArcSubspan(stage.Reverse ? arc : (LineArcCircularArc2D)Reverse(arc), start, end, out selected))
+ {
+ reversed = !stage.Reverse;
+ return selected;
+ }
+ }
+ diagnostics.Add($"firmament-pipeline-endpoint-not-on-guide:{stage.Reference}:{stage.From ?? DescribeEndpoint(start, points)}:{stage.To}");
+ return null;
+ }
+
+ private static bool TrySelectArcSubspan(LineArcCircularArc2D arc, (double X, double Y) start, (double X, double Y) end, out LineArcCircularArc2D? selected)
+ {
+ selected = null;
+ if (!OnCircle(start, arc.Center, arc.Radius) || !OnCircle(end, arc.Center, arc.Radius)) return false;
+ var direction = Math.Sign(arc.SweepAngleRadians);
+ var span = Math.Abs(arc.SweepAngleRadians);
+ double Progress((double X, double Y) point)
+ {
+ var angle = Math.Atan2(point.Y - arc.Center.Y, point.X - arc.Center.X);
+ var delta = direction * (angle - arc.StartAngleRadians);
+ while (delta < 0) delta += 2 * Math.PI;
+ while (delta >= 2 * Math.PI) delta -= 2 * Math.PI;
+ return delta;
+ }
+ var fromProgress = Progress(start); var toProgress = Progress(end);
+ if (fromProgress > span + 1e-7 || toProgress > span + 1e-7 || toProgress <= fromProgress + Tolerance) return false;
+ selected = new LineArcCircularArc2D(arc.Center, arc.Radius, Math.Atan2(start.Y - arc.Center.Y, start.X - arc.Center.X), direction * (toProgress - fromProgress));
+ return true;
+ }
+
+ private static bool OnBoundedLine((double X, double Y) point, LineArcLineSegment2D line) =>
+ OnLine(point, line) && point.X >= Math.Min(line.Start.X, line.End.X) - Tolerance && point.X <= Math.Max(line.Start.X, line.End.X) + Tolerance
+ && point.Y >= Math.Min(line.Start.Y, line.End.Y) - Tolerance && point.Y <= Math.Max(line.Start.Y, line.End.Y) + Tolerance;
+
+ private static string RemoveRecognizedProfileDeclarations(string body)
+ {
+ var declarationPattern = @"\b(?:(?:Concept\s+)?(?:Point2|Line2|Rect2|Square2|Circle2|Ellipse2|Ellipse2Guide|Slot2|RoundedRect2|SmoothRoundedRect2)|(?:Triangle2|Polygon2|RegularPolygon2)\s*<[^>]+>|Concept\s+Path)\s+[A-Za-z_]\w*\s*\{";
+ var blocks = FindBlocks(body, declarationPattern).OrderByDescending(block => block.Match.Index).ToArray();
+ foreach (var block in blocks) body = body.Remove(block.Match.Index, block.EndIndex - block.Match.Index + 1);
+ body = Regex.Replace(body, @"//[^\r\n]*|/\*[\s\S]*?\*/", string.Empty, RegexOptions.CultureInvariant);
+ return body;
+ }
+
private static string Disconnected((double X, double Y) current, string reference, LineArcProfileCurve2D candidate, IReadOnlyDictionary<string, (double X, double Y)>? points) =>
$"firmament-profile-pipeline-disconnected:{reference}:current={DescribeEndpoint(current, points)}:candidates={DescribeEndpoint(Start(candidate), points)},{DescribeEndpoint(End(candidate), points)}";
@@ -842,10 +965,11 @@ public static class ProfileAuthoringParser
else if (raw == "TraceLoop") stages.Add(new(PipelineStageKind.TraceLoop, null, null, false, localOffset));
else
{
- var parsed = Regex.Match(raw, @"^(?<reverse>Reverse\s+)?(?<reference>[A-Za-z_]\w*(?:\.[A-Za-z_]\w*)*)(?:\s+As\s+(?<alias>[A-Za-z_]\w*))?$", RegexOptions.CultureInvariant);
- stages.Add(parsed.Success
- ? new(PipelineStageKind.Trace, parsed.Groups["reference"].Value, parsed.Groups["alias"].Success ? parsed.Groups["alias"].Value : null, parsed.Groups["reverse"].Success, localOffset)
- : new(PipelineStageKind.Invalid, raw, null, false, localOffset));
+ var parsed = Regex.Match(raw, @"^(?<reverse>Reverse\s+)?(?<reference>[A-Za-z_]\w*(?:\.[A-Za-z_]\w*)*)(?:\s+From\s+(?<from>[A-Za-z_]\w*(?:\.[A-Za-z_]\w*)*))?(?:\s+To\s+(?<to>[A-Za-z_]\w*(?:\.[A-Za-z_]\w*)*))?(?:\s+As\s+(?<alias>[A-Za-z_]\w*))?$", RegexOptions.CultureInvariant);
+ stages.Add(parsed.Success && (!parsed.Groups["from"].Success || parsed.Groups["to"].Success)
+ ? new(PipelineStageKind.Trace, parsed.Groups["reference"].Value, parsed.Groups["alias"].Success ? parsed.Groups["alias"].Value : null, parsed.Groups["reverse"].Success, localOffset,
+ parsed.Groups["from"].Success ? parsed.Groups["from"].Value : null, parsed.Groups["to"].Success ? parsed.Groups["to"].Value : null)
+ : new(PipelineStageKind.Invalid, raw, null, false, localOffset, null, null));
}
}
return stages;
@@ -888,7 +1012,7 @@ public static class ProfileAuthoringParser
if (!paths.TryGetValue(pathName, out var path)) { diagnostics.Add($"profile-path-missing:{profile.Name}:{pathName}"); return; }
loops.Add(new ResolvedProfileLoop2D(loopName, outer, path.Steps.SelectMany(step => step.Curves.Select((curve, ordinal) => SegmentResult(
profile, loopName,
- outer ? (step.Curves.Count == 1 ? step.Name : $"{step.Name}.curve{ordinal:D2}") : $"{loopName}.{step.Name}.curve{ordinal:D2}",
+ step.Curves.Count == 1 ? step.Name : $"{step.Name}.curve{ordinal:D2}",
curve, $"concept-path:{pathName}.{step.Name}", $"SemanticProfileMIR:{step.Kind}"))).ToArray()));
}
@@ -990,7 +1114,7 @@ public static class ProfileAuthoringParser
private sealed record BoundPathStep(string Name, string Kind, string GuideName, string EndpointName, IReadOnlyList<LineArcProfileCurve2D> Curves, (double X, double Y) Start, (double X, double Y) End, double Heading, string? SourceReference = null, bool WasReversed = false, int? PipelineIndex = null, string? SourceRange = null);
private sealed record BoundPath(string Name, (double X, double Y) Start, double InitialHeading, List<BoundPathStep> Steps);
private enum PipelineStageKind { Trace, Close, TraceLoop, Invalid }
- private sealed record PipelineStage(PipelineStageKind Kind, string? Reference, string? Alias, bool Reverse, int Offset);
+ private sealed record PipelineStage(PipelineStageKind Kind, string? Reference, string? Alias, bool Reverse, int Offset, string? From = null, string? To = null);
/// <summary>Small deterministic dimensional expression evaluator used after Template specialization.</summary>
/// <remarks>Admits only numeric literals, one requested unit, parentheses, and + - * /.</remarks>
diff --git a/docs/public/firmament/syntax.md b/docs/public/firmament/syntax.md
index decf9650..6d14e3be 100644
--- a/docs/public/firmament/syntax.md
+++ b/docs/public/firmament/syntax.md
@@ -230,9 +230,58 @@ Profile BaseProfile Using Layout {
}
```
-The first stage uses its source direction. Later stages match the current endpoint against the candidate span's endpoints. A unique end match reverses the traced geometry automatically; no match reports `firmament-profile-pipeline-disconnected`, and a degenerate two-way match reports `firmament-profile-pipeline-orientation-ambiguous`. `Reverse Stock.Left` is the explicit escape hatch. `Stock.Bottom As MountingEdge` changes the output segment identity while retaining source provenance. Unrenamed outer spans inherit their source leaf name; inner-loop spans are qualified by the loop name to preserve Profile-wide uniqueness.
+The first stage uses its source direction. Later stages match the current endpoint against the candidate span's endpoints. A unique end match reverses the traced geometry automatically; no match reports `firmament-profile-pipeline-disconnected`, and a degenerate two-way match reports `firmament-profile-pipeline-orientation-ambiguous`. `Reverse Stock.Left` prefers reversed orientation first and then falls back to the normal connectable orientation; on the opening stage it selects the initial direction. `Stock.Bottom As MountingEdge` changes the output segment identity while retaining source provenance.
-`|> Close` validates that the authored chain already closes. It never invents a missing line. A real closed `Concept Path` may be copied as a whole with `Outline |> TraceLoop`; a rectangle, Body, Face, open path, or multi-loop container is not guessed into a loop. `TraceLoop` preserves span identities and normalizes winding for the target outer or inner loop when required.
+To trace only part of a guide, use `Guide To Point`. The current pipeline endpoint is the implicit start. On the opening stage, use `Guide From Start To End`; `Guide To End` may omit `From` when the guide's natural start is intended. Endpoints must be named points on the guide. This is bounded selection, not a general slicing expression:
+
+```firmament
+Profile Bracket Using Layout {
+ Horizontal.Bottom As South
+ |> Horizontal.Right As East
+ |> Horizontal.Top To Notch As Inner
+ |> Vertical.Right To Vertical.TopRight As Upright
+ |> Vertical.Top As North
+ |> Vertical.Left To Horizontal.BottomLeft As West
+ |> Close
+}
+```
+
+The same form traces partial circular arcs. Endpoint order chooses the normal counter-clockwise circle span; `Reverse` selects the clockwise span. No pipeline `Sweep` keyword is needed.
+
+A half-circle revolve meridian uses the same syntax through the ordinary Mechanical schema:
+
+```firmament
+schema Mechanical
+
+Model RevolvedSphere {
+ Units: mm
+ Axis MainAxis { Origin: [0mm, 0mm, 0mm]; Direction: [0, 1, 0] }
+ Point2 South { Position: [0mm, -20mm] }
+ Point2 North { Position: [0mm, 20mm] }
+ Point2 Center { Position: [0mm, 0mm] }
+ Concept Circle2 Meridian { Center: Center; Radius: 20mm }
+ Line2 Diameter { From: North; To: South }
+ Profile SphereSection {
+ Meridian From South To North As Arc
+ |> Diameter As AxisClosure
+ |> Close
+ }
+ Revolve Ball { Profile: SphereSection; About: MainAxis; Angle: full }
+}
+```
+
+`|> Close` validates that the authored chain already closes. It never invents a missing line. Any admitted closed ordered guide family may be copied with `Outline |> TraceLoop`, including `Rect2`, `Square2`, `RoundedRect2`, `Polygon2`, `RegularPolygon2`, a closed `Concept Path`, `Circle2`, and `Ellipse2`. The resulting identities are the family's ordinary named edges; full circles and ellipses retain the single `Boundary` identity. `TraceLoop` normalizes winding for the target outer or inner loop when required.
+
+Recognized guide declarations may appear at the start of an implicit-loop Profile body, followed by exactly one pipeline expression:
+
+```firmament
+Profile SideProfile Using PositiveXWorkplane {
+ Rect2 Outline { Center: [0mm, 0mm]; Size: [20mm, 10mm] }
+ Outline |> TraceLoop
+}
+```
+
+Segment names are Profile-wide identities. Manual `Segment` and pipeline stages both preserve their authored or inherited leaf names; loops do not silently qualify them. If two loops would introduce the same name, binding reports `firmament-profile-segment-identity-collision`. Resolve the collision explicitly with `As` on the pipeline stages (for example, `Cutout.Bottom As CutoutBottom`) or by renaming a manual Segment.
A `Concept Path` may also compose existing named spans and remain open:
@@ -244,9 +293,4 @@ Concept Path Guide {
}
```
-Pipeline source order is semantic order. Stages are limited to geometry references (qualified or unqualified), optional `Reverse`, optional `As`, `Close`, and `TraceLoop` in their admitted contexts. The operator has lower binding precedence than member access and does not admit arithmetic stages, calls, lambdas, conditionals, filtering, mutation, runtime execution, or repetition. Use Feature for a reusable semantic transformation, Pattern for bounded repetition, Template for specialization, and `|>` for finite semantic composition. Manual `Segment { Trace/From/To }` remains the explicit low-level Profile escape hatch, and is not yet
-fully subsumed by `|>`: a pipeline stage always traces a source span end to end, while `Segment`'s
-`From:`/`To:` may select a *partial* span between named interior points, and `Sweep:` may pick an arc
-direction on a partial circle. Profiles that need either - the L-bracket family in
-`Regression/CanonicalGeometry`, and `Canonical/Revolve/sphere.firmament` - have no pipeline spelling
-today. See `docs/development/firmament-v2-language-audit.md` for the proposed sub-span stage.
+Pipeline source order is semantic order. Stages are limited to geometry references (qualified or unqualified), bounded `From`/`To` named endpoints, optional `Reverse`, optional `As`, `Close`, and `TraceLoop` in their admitted contexts. The operator has lower binding precedence than member access and does not admit arithmetic stages, calls, lambdas, conditionals, filtering, mutation, runtime execution, or repetition. Use Feature for a reusable semantic transformation, Pattern for bounded repetition, Template for specialization, and `|>` for finite semantic composition. Manual `Segment { Trace/From/To }` remains supported for compatibility and deliberate low-level parity tests; ordinary canonical Profile authoring does not require it.
diff --git a/docs/release/FIRMAMENT-PIPELINE-X2.md b/docs/release/FIRMAMENT-PIPELINE-X2.md
new file mode 100644
index 00000000..cab635d6
--- /dev/null
+++ b/docs/release/FIRMAMENT-PIPELINE-X2.md
@@ -0,0 +1,81 @@
+# FIRMAMENT-PIPELINE-X2 — pipeline surface coherence and Segment retirement
+
+Date: 2026-09-22
+
+## Executive verdict
+
+**Accepted.** The Firmament V2 Profile pipeline is now a coherent superset of ordinary canonical Profile authoring. Low-level `Segment` remains supported for compatibility, invalid-case coverage, and deliberate parity/identity witnesses; no unexplained production-style canonical or regression fixture requires it.
+
+## Surface contract
+
+### Sub-spans
+
+The admitted bounded form is `Guide To EndPoint`. In a chain, the current endpoint is the implicit start. The opening stage may say `Guide From StartPoint To EndPoint`; `Guide To EndPoint` uses the guide's natural start when that is unambiguous. Both boundaries are named points, and selection is confined to the referenced guide.
+
+Line and circular-arc carriers are supported. A full-circle sub-span is counter-clockwise by default; `Reverse` prefers the clockwise traversal. This removes the pipeline need for low-level `Sweep`. Segment identity remains the inherited guide leaf or explicit `As` alias, and provenance retains the source guide, orientation, pipeline index, and source range.
+
+Migrated fixtures:
+
+- `Regression/CanonicalGeometry/profile-compose-l-bracket.firmament`
+- `Regression/CanonicalGeometry/profile-compose-l-bracket-external-modify-counterbore.firmament`
+- `Regression/CanonicalGeometry/profile-compose-reflex-chamfer-with-counterbore.firmament`
+- `Regression/CanonicalGeometry/profile-compose-reflex-chamfer-with-shaft.firmament`
+- `Canonical/PMI/counterbore-shaft-diameter.firmament`
+- `Canonical/Revolve/sphere.firmament`
+- `Regression/Profile/valid/construction-plane-positive-x.firmament`
+
+The construction-plane fixture also proves that recognized declarations may precede one implicit-loop pipeline expression. A second competing pipeline is rejected.
+
+### Naming
+
+Segment identity is Profile-wide and never silently loop-qualified. Manual and pipeline authoring therefore use the same rule. A repeated name across loops reports:
+
+`firmament-profile-segment-identity-collision:<name>:loops=<loops>:use As alias or rename source guide/stage`
+
+The L-bracket and sphere migrations use `As` to preserve every prior canonical segment name. Four pre-existing annular pipeline sources required an intentional collision migration: their inner full-circle identity changed from the old automatic `Inner.Boundary` to explicit `InnerBoundary` in `Canonical/Assembly/annular-pair.firmament` and the three annular definitions in `DifferenceEngine/parts/Storage.firmament` and `Showcase.firmament`. Repository search found no selector depending on `Inner.Boundary`; assembly/display and Difference Engine regressions pass with the explicit alias.
+
+### TraceLoop
+
+`TraceLoop` is admitted for the closed ordered families supplied by the existing closed-boundary lowering: `Rect2`, `Square2`, `RoundedRect2`, `Polygon2`, `RegularPolygon2`, closed `Concept Path`, `Circle2`, and `Ellipse2` (plus the already supported related closed-boundary families). Linear/path families retain their named edge identities. Full circles and ellipses retain the established single `Boundary` identity; an `As` alias may disambiguate that identity across loops.
+
+The identity-sensitive quadrant decomposition in `Regression/ProfileComposition/mixed-line-arc-additive-overlap.firmament` was intentionally not collapsed to `TraceLoop`.
+
+### Reverse and diagnostics
+
+On the opening stage, `Reverse` selects the initial direction. Mid-chain it is a preference: reversed orientation is tried first, then the ordinary connectable orientation. If neither connects, the normal disconnected-pipeline diagnostic is emitted.
+
+Unknown references now report `firmament-pipeline-unknown-guide:<name>`. `firmament-pipeline-stage-type:<kind>` is reserved for actual stage-kind/position misuse. Unknown or off-guide sub-span endpoints have distinct deterministic diagnostics.
+
+## Corpus audit
+
+The audited `Canonical` and `Regression` trees contain 353 `.firmament` files (219 canonical, 134 regression). X2 rewrote 7 fixtures; together with the preceding X1 rewrite, 46 fixtures have moved from ordinary low-level authoring to the pipeline.
+
+The full `fixtures/` scan finds 193 `Segment` declarations in 23 files:
+
+| Category | Files | Explanation |
+|---|---:|---|
+| Compatibility | 3 | Legacy V1 reconstruction witnesses |
+| Invalid | 14 | Negative diagnostics and failure geometry |
+| Low-level parity / identity witnesses | 6 | Manual parity, explicitly named low-level fixtures, and the quadrant-identity mixed arc witness |
+| Unexplained production-style usage | **0** | Target met |
+
+No compatibility or unrelated invalid fixture was modernized.
+
+## Validation
+
+- Focused pipeline tests: 36/36 passed. These include line and arc sub-spans, opening and mid-chain selection, aliases, invalid endpoints, disconnected stages, inline declarations, ambiguous second pipelines, naming collisions, TraceLoop families, Reverse fallback, exact diagnostics, and manual/pipeline canonical-dump equality for the L-bracket and sphere.
+- Firmament tests: 1,567/1,567 passed, serial Release.
+- Kernel.Core: 1,078/1,080 passed in the full run; the two display-corpus failures both passed in isolated reruns (16/16 orientation corpus and 18/18 NIST display corpus). One failure was the known 5-second load-sensitive STEP display timeout; no timeout was changed.
+- Server tests: 59/59 passed.
+- Full solution: `dotnet build Aetheris.slnx -c Release --no-restore -m:1` succeeded with 0 errors; only existing WebAssembly/trimming warnings were reported.
+- Canonical qualification: every configured action passed, including the migrated PMI and sphere fixtures. The script ended only on the pre-existing source-policy guard `Assembly/annular-pair.firmament: legacy explicit assembly placement`; the guard was not weakened.
+- Artifact truth: the pipeline sphere exported and reimported as one enclosed analytic spherical face with bounds `[-20,20]` on X/Y/Z. The pipeline L-bracket exported and reimported as an enclosed 8-face/18-edge/12-vertex solid with bounds `[-40,-20,0]..[40,40,12]` and exact asserted volume `28,800 mm^3`.
+- Migration oracle: permanent tests compare frame, loop role/order, segment names, and analytic geometry for manual versus pipeline L-bracket and sphere sources; the canonical dumps are equal.
+- Document routing: all seven X2 fixtures validate through the production CLI with no diagnostics. The standalone construction-plane Profile now has an explicit bounded V2 document route instead of falling into the unrelated historical edge-finish parser.
+- Fresh-author checks using only `docs/public/firmament/syntax.md`: L-bracket, inline `Rect2 |> TraceLoop`, collision repair with `As`, and half-circle sphere revolve all selected the preferred pipeline syntax. The first sphere attempt exposed an incomplete documentation example; the guide was corrected and the repeated fresh-author check produced the valid canonical form without `Segment`/`Sweep`.
+
+Generated STEP evidence is under ignored `artifacts/local/firmament-pipeline-x2/`.
+
+## Scope
+
+No conditionals, loops, recursion, macros, arbitrary slicing, new geometry, second parser/IR/executor, or legacy Segment removal was introduced. Geometry continues to lower through the existing Profile, revolve, BRep, tessellation, and STEP authorities. The existing single-owner face-orientation fix and gear-volume regression remain green in the Firmament suite.
diff --git a/fixtures/Canonical/Assembly/annular-pair.firmament b/fixtures/Canonical/Assembly/annular-pair.firmament
index be712e39..d53eee44 100644
--- a/fixtures/Canonical/Assembly/annular-pair.firmament
+++ b/fixtures/Canonical/Assembly/annular-pair.firmament
@@ -1,7 +1,7 @@
Template < R: Length > Struct Sleeve {
Circle2 Outside { Center: [0mm,0mm] Radius: R }
Circle2 Inside { Center: [0mm,0mm] Radius: 15mm }
- Profile Section { Loop Outer { Outside |> TraceLoop } Loop Inner { Inside |> TraceLoop } }
+ Profile Section { Loop Outer { Outside |> TraceLoop } Loop Inner { Inside As InnerBoundary |> TraceLoop } }
Extrude Body { Profile: Section From: -10mm To: 10mm }
}
Assembly AnnularPair {
diff --git a/fixtures/Canonical/PMI/counterbore-shaft-diameter.firmament b/fixtures/Canonical/PMI/counterbore-shaft-diameter.firmament
index daedb8e6..ee5f45dc 100644
--- a/fixtures/Canonical/PMI/counterbore-shaft-diameter.firmament
+++ b/fixtures/Canonical/PMI/counterbore-shaft-diameter.firmament
@@ -22,12 +22,13 @@ Model ProfileComposeLBracketCounterborePmi {
}
Profile Bracket Using Layout { Loop Outer {
- Segment South { Trace: Horizontal.Bottom; From: Horizontal.BottomLeft; To: Horizontal.BottomRight }
- Segment East { Trace: Horizontal.Right; From: Horizontal.BottomRight; To: Horizontal.TopRight }
- Segment Inner { Trace: Horizontal.Top; From: Horizontal.TopRight; To: Notch }
- Segment Upright { Trace: Vertical.Right; From: Notch; To: Vertical.TopRight }
- Segment North { Trace: Vertical.Top; From: Vertical.TopRight; To: Vertical.TopLeft }
- Segment West { Trace: Vertical.Left; From: Vertical.TopLeft; To: Horizontal.BottomLeft }
+ Horizontal.Bottom As South
+ |> Horizontal.Right As East
+ |> Horizontal.Top To Notch As Inner
+ |> Vertical.Right To Vertical.TopRight As Upright
+ |> Vertical.Top As North
+ |> Vertical.Left To Horizontal.BottomLeft As West
+ |> Close
} }
Struct BracketBody {
diff --git a/fixtures/Canonical/Revolve/sphere.firmament b/fixtures/Canonical/Revolve/sphere.firmament
index bbaf7a0b..6a11e6d2 100644
--- a/fixtures/Canonical/Revolve/sphere.firmament
+++ b/fixtures/Canonical/Revolve/sphere.firmament
@@ -9,8 +9,9 @@ Model RevolvedSphere {
Concept Circle2 Meridian { Center: Center; Radius: 20mm }
Line2 Diameter { From: North; To: South }
Profile SphereSection { Loop Outer {
- Segment Arc { Trace: Meridian; From: South; To: North; Sweep: CounterClockwise }
- Segment AxisClosure { Trace: Diameter; From: North; To: South }
+ Meridian From South To North As Arc
+ |> Diameter As AxisClosure
+ |> Close
} }
Revolve Ball { Profile: SphereSection; About: MainAxis; Angle: full }
}
diff --git a/fixtures/DifferenceEngine/parts/Showcase.firmament b/fixtures/DifferenceEngine/parts/Showcase.firmament
index f5ec8152..39e852e6 100644
--- a/fixtures/DifferenceEngine/parts/Showcase.firmament
+++ b/fixtures/DifferenceEngine/parts/Showcase.firmament
@@ -20,7 +20,7 @@ Template < X: Length, Y: Length, Zlow: Length, Zhigh: Length, W: Length, D: Leng
Template < X: Length, Y: Length, R: Length, BoreR: Length, Zlow: Length, Zhigh: Length > Struct PositionedRing {
Circle2 Outside { Center: [X,Y] Radius: R }
Circle2 Inside { Center: [X,Y] Radius: BoreR }
- Profile Section { Loop Outer { Outside |> TraceLoop } Loop Inner { Inside |> TraceLoop } }
+ Profile Section { Loop Outer { Outside |> TraceLoop } Loop Inner { Inside As InnerBoundary |> TraceLoop } }
Extrude Body { Profile: Section From: Zlow To: Zhigh }
}
Template < W: Length > Struct DoubleBearingBridge {
diff --git a/fixtures/DifferenceEngine/parts/Storage.firmament b/fixtures/DifferenceEngine/parts/Storage.firmament
index aac66f7d..c1f91266 100644
--- a/fixtures/DifferenceEngine/parts/Storage.firmament
+++ b/fixtures/DifferenceEngine/parts/Storage.firmament
@@ -4,7 +4,7 @@ Template < Rout: Length, Rin: Length, Zlow: Length, Zhigh: Length >
Struct Annulus {
Circle2 Outside { Center: [0mm,0mm] Radius: Rout }
Circle2 Inside { Center: [0mm,0mm] Radius: Rin }
- Profile Section { Loop Outer { Outside |> TraceLoop } Loop Inner { Inside |> TraceLoop } }
+ Profile Section { Loop Outer { Outside |> TraceLoop } Loop Inner { Inside As InnerBoundary |> TraceLoop } }
Extrude Body { Profile: Section From: Zlow To: Zhigh }
}
@@ -19,7 +19,7 @@ Template < Rout: Length, Rin: Length, PitchR: Length, HoleD: Length, Zlow: Lengt
Struct DecimalIndexPlate {
Circle2 Outside { Center: [0mm,0mm] Radius: Rout }
Circle2 Inside { Center: [0mm,0mm] Radius: Rin }
- Profile Section { Loop Outer { Outside |> TraceLoop } Loop Inner { Inside |> TraceLoop } }
+ Profile Section { Loop Outer { Outside |> TraceLoop } Loop Inner { Inside As InnerBoundary |> TraceLoop } }
Axis IndexAxis { Origin: [0mm,0mm,0mm]; Direction: [0,0,1] }
Compose Body {
Base Stock { Profile: Section From: Zlow To: Zhigh Role: Stock }
diff --git a/fixtures/Regression/CanonicalGeometry/profile-compose-l-bracket-external-modify-counterbore.firmament b/fixtures/Regression/CanonicalGeometry/profile-compose-l-bracket-external-modify-counterbore.firmament
index 15a4e532..c157d114 100644
--- a/fixtures/Regression/CanonicalGeometry/profile-compose-l-bracket-external-modify-counterbore.firmament
+++ b/fixtures/Regression/CanonicalGeometry/profile-compose-l-bracket-external-modify-counterbore.firmament
@@ -22,12 +22,13 @@ Model ProfileComposeLBracketExternalModifyCounterbore {
}
Profile Bracket Using Layout { Loop Outer {
- Segment South { Trace: Horizontal.Bottom; From: Horizontal.BottomLeft; To: Horizontal.BottomRight }
- Segment East { Trace: Horizontal.Right; From: Horizontal.BottomRight; To: Horizontal.TopRight }
- Segment Inner { Trace: Horizontal.Top; From: Horizontal.TopRight; To: Notch }
- Segment Upright { Trace: Vertical.Right; From: Notch; To: Vertical.TopRight }
- Segment North { Trace: Vertical.Top; From: Vertical.TopRight; To: Vertical.TopLeft }
- Segment West { Trace: Vertical.Left; From: Vertical.TopLeft; To: Horizontal.BottomLeft }
+ Horizontal.Bottom As South
+ |> Horizontal.Right As East
+ |> Horizontal.Top To Notch As Inner
+ |> Vertical.Right To Vertical.TopRight As Upright
+ |> Vertical.Top As North
+ |> Vertical.Left To Horizontal.BottomLeft As West
+ |> Close
} }
Struct BracketBody {
diff --git a/fixtures/Regression/CanonicalGeometry/profile-compose-l-bracket.firmament b/fixtures/Regression/CanonicalGeometry/profile-compose-l-bracket.firmament
index 8ecd3f66..588b5489 100644
--- a/fixtures/Regression/CanonicalGeometry/profile-compose-l-bracket.firmament
+++ b/fixtures/Regression/CanonicalGeometry/profile-compose-l-bracket.firmament
@@ -10,12 +10,13 @@ Model ProfileComposeLBracket {
}
Profile Bracket Using Layout { Loop Outer {
- Segment South { Trace: Horizontal.Bottom; From: Horizontal.BottomLeft; To: Horizontal.BottomRight }
- Segment East { Trace: Horizontal.Right; From: Horizontal.BottomRight; To: Horizontal.TopRight }
- Segment Inner { Trace: Horizontal.Top; From: Horizontal.TopRight; To: Notch }
- Segment Upright { Trace: Vertical.Right; From: Notch; To: Vertical.TopRight }
- Segment North { Trace: Vertical.Top; From: Vertical.TopRight; To: Vertical.TopLeft }
- Segment West { Trace: Vertical.Left; From: Vertical.TopLeft; To: Horizontal.BottomLeft }
+ Horizontal.Bottom As South
+ |> Horizontal.Right As East
+ |> Horizontal.Top To Notch As Inner
+ |> Vertical.Right To Vertical.TopRight As Upright
+ |> Vertical.Top As North
+ |> Vertical.Left To Horizontal.BottomLeft As West
+ |> Close
} }
Struct BracketBody {
diff --git a/fixtures/Regression/CanonicalGeometry/profile-compose-reflex-chamfer-with-counterbore.firmament b/fixtures/Regression/CanonicalGeometry/profile-compose-reflex-chamfer-with-counterbore.firmament
index 54c6eed7..f9ef2768 100644
--- a/fixtures/Regression/CanonicalGeometry/profile-compose-reflex-chamfer-with-counterbore.firmament
+++ b/fixtures/Regression/CanonicalGeometry/profile-compose-reflex-chamfer-with-counterbore.firmament
@@ -6,12 +6,13 @@ Model ProfileComposeReflexChamferWithCounterbore {
Point2 Notch { Position: [-20mm, 0mm] }
}
Profile Bracket Using Layout { Loop Outer {
- Segment South { Trace: Horizontal.Bottom; From: Horizontal.BottomLeft; To: Horizontal.BottomRight }
- Segment East { Trace: Horizontal.Right; From: Horizontal.BottomRight; To: Horizontal.TopRight }
- Segment Inner { Trace: Horizontal.Top; From: Horizontal.TopRight; To: Notch }
- Segment Upright { Trace: Vertical.Right; From: Notch; To: Vertical.TopRight }
- Segment North { Trace: Vertical.Top; From: Vertical.TopRight; To: Vertical.TopLeft }
- Segment West { Trace: Vertical.Left; From: Vertical.TopLeft; To: Horizontal.BottomLeft }
+ Horizontal.Bottom As South
+ |> Horizontal.Right As East
+ |> Horizontal.Top To Notch As Inner
+ |> Vertical.Right To Vertical.TopRight As Upright
+ |> Vertical.Top As North
+ |> Vertical.Left To Horizontal.BottomLeft As West
+ |> Close
} }
Struct BracketBody { Compose BracketBody {
Base Stock { Profile: Bracket; From: 0mm; To: 12mm; Role: Stock }
diff --git a/fixtures/Regression/CanonicalGeometry/profile-compose-reflex-chamfer-with-shaft.firmament b/fixtures/Regression/CanonicalGeometry/profile-compose-reflex-chamfer-with-shaft.firmament
index 5141d152..9530916d 100644
--- a/fixtures/Regression/CanonicalGeometry/profile-compose-reflex-chamfer-with-shaft.firmament
+++ b/fixtures/Regression/CanonicalGeometry/profile-compose-reflex-chamfer-with-shaft.firmament
@@ -6,12 +6,13 @@ Model ProfileComposeReflexChamferWithShaft {
Point2 Notch { Position: [-20mm, 0mm] }
}
Profile Bracket Using Layout { Loop Outer {
- Segment South { Trace: Horizontal.Bottom; From: Horizontal.BottomLeft; To: Horizontal.BottomRight }
- Segment East { Trace: Horizontal.Right; From: Horizontal.BottomRight; To: Horizontal.TopRight }
- Segment Inner { Trace: Horizontal.Top; From: Horizontal.TopRight; To: Notch }
- Segment Upright { Trace: Vertical.Right; From: Notch; To: Vertical.TopRight }
- Segment North { Trace: Vertical.Top; From: Vertical.TopRight; To: Vertical.TopLeft }
- Segment West { Trace: Vertical.Left; From: Vertical.TopLeft; To: Horizontal.BottomLeft }
+ Horizontal.Bottom As South
+ |> Horizontal.Right As East
+ |> Horizontal.Top To Notch As Inner
+ |> Vertical.Right To Vertical.TopRight As Upright
+ |> Vertical.Top As North
+ |> Vertical.Left To Horizontal.BottomLeft As West
+ |> Close
} }
Struct BracketBody { Compose BracketBody {
Base Stock { Profile: Bracket; From: 0mm; To: 12mm; Role: Stock }
diff --git a/fixtures/Regression/Profile/valid/construction-plane-positive-x.firmament b/fixtures/Regression/Profile/valid/construction-plane-positive-x.firmament
index f266703f..0d51b5d4 100644
--- a/fixtures/Regression/Profile/valid/construction-plane-positive-x.firmament
+++ b/fixtures/Regression/Profile/valid/construction-plane-positive-x.firmament
@@ -6,10 +6,7 @@ Construction Plane PositiveXWorkplane { Trace: SideLayout.PositiveXDatum }
Profile SideProfile Using PositiveXWorkplane {
Rect2 Outline { Center: [0mm, 0mm]; Size: [20mm, 10mm] }
- Segment Bottom { Trace: Outline.Bottom; From: Outline.BottomLeft; To: Outline.BottomRight }
- Segment Right { Trace: Outline.Right; From: Outline.BottomRight; To: Outline.TopRight }
- Segment Top { Trace: Outline.Top; From: Outline.TopRight; To: Outline.TopLeft }
- Segment Left { Trace: Outline.Left; From: Outline.TopLeft; To: Outline.BottomLeft }
+ Outline |> TraceLoop
}
Extrude Solid { Profile: SideProfile; From: -5mm; To: 5mm }