Next Gen STEP AP242 Native-ish BREP Geometric Modeling Kernel
Expose profile pipeline provenance and validate pipeline contexts
Yuechen Lid621469d7ebc
diff --git a/Aetheris.CLI/CliRunner.cs b/Aetheris.CLI/CliRunner.csindex 086f9eaa..f8e5b16b 100644--- a/Aetheris.CLI/CliRunner.cs+++ b/Aetheris.CLI/CliRunner.cs@@ -1646,7 +1646,7 @@ Model CanonicalPanel {arcSegments = profile.Loops.SelectMany(x => x.Segments).Count(x => x.Geometry is LineArcCircularArc2D),validation.IsValid, validation.SignedArea, validation.Diagnostics,junctions = DescribeProfileJunctions(profile, source, profile.Name),- provenance = profile.Loops.SelectMany(x => x.Segments).Select(x => new { x.Name, x.Provenance.StableId, x.Provenance.ConceptStableId, x.Provenance.Derivation })+ provenance = profile.Loops.SelectMany(x => x.Segments).Select(x => new { x.Name, x.Provenance.StableId, x.Provenance.ConceptStableId, x.Provenance.Derivation, x.Provenance.TracedFrom, x.Provenance.Reversed, x.Provenance.PipelineIndex, x.Provenance.InvocationSourceRange })};}).ToArray();stdout.WriteLine(JsonSerializer.Serialize(new { profiles, expansion = composition.Expansion, diagnostics = composition.Diagnostics }, JsonOptions));@@ -1669,7 +1669,7 @@ Model CanonicalPanel {segments = parsed.Profile.Loops.SelectMany(x => x.Segments).Select(x =>{var guide = DescribeProfileGuide(x.Provenance.ConceptStableId);- return new { x.Name, guide = guide.Name, guideKind = guide.Kind, parentGuide = guide.Parent, stableId = x.Provenance.StableId, derivation = x.Provenance.Derivation, geometry = x.Geometry.GetType().Name };+ return new { x.Name, guide = guide.Name, guideKind = guide.Kind, parentGuide = guide.Parent, stableId = x.Provenance.StableId, derivation = x.Provenance.Derivation, tracedFrom = x.Provenance.TracedFrom, reversed = x.Provenance.Reversed, pipelineIndex = x.Provenance.PipelineIndex, invocationSourceRange = x.Provenance.InvocationSourceRange, geometry = x.Geometry.GetType().Name };}),validation.IsValid, validation.SignedArea, validation.Diagnostics,junctions = DescribeProfileJunctions(parsed.Profile, source, parsed.Profile.Name),diff --git a/Aetheris.Kernel.Firmament.Tests/ProfilePipelineX1Tests.cs b/Aetheris.Kernel.Firmament.Tests/ProfilePipelineX1Tests.csnew file mode 100644index 00000000..6c9119d7--- /dev/null+++ b/Aetheris.Kernel.Firmament.Tests/ProfilePipelineX1Tests.cs@@ -0,0 +1,275 @@+using Aetheris.Kernel.Firmament.FirmamentV2;+using Aetheris.Kernel.Firmament.Materializer;++namespace Aetheris.Kernel.Firmament.Tests;++public sealed class ProfilePipelineX1Tests+{+ [Fact]+ public void RectanglePipeline_InheritsIdentityOrientsAndLowersToExistingProfile()+ {+ var parsed = ProfileAuthoringParser.Parse(RectanglePipeline());++ var profile = Assert.IsType<ResolvedProfile2D>(parsed.Profile);+ Assert.Empty(parsed.Diagnostics);+ Assert.Equal(["Bottom", "Right", "Top", "Left"], profile.Loops.Single().Segments.Select(segment => segment.Name));+ Assert.Equal([false, false, false, false], profile.Loops.Single().Segments.Select(segment => segment.Provenance.Reversed));+ Assert.Equal([0, 1, 2, 3], profile.Loops.Single().Segments.Select(segment => segment.Provenance.PipelineIndex));+ Assert.All(profile.Loops.Single().Segments, segment => Assert.NotNull(segment.Provenance.TracedFrom));+ Assert.True(ResolvedProfile2DValidator.Validate(profile).IsValid);+ Assert.Equal(LineArcProfileExtrudeStatus.Succeeded, ResolvedProfile2DValidator.Extrude(profile, parsed.Height).Status);+ }++ [Fact]+ public void PipelineAndManualProfile_HaveIdenticalGeometryAndTopologyPlan()+ {+ var pipeline = Assert.IsType<ResolvedProfile2D>(ProfileAuthoringParser.Parse(RectanglePipeline()).Profile);+ var manual = Assert.IsType<ResolvedProfile2D>(ProfileAuthoringParser.Parse(RectangleManual()).Profile);++ Assert.Equal(Signature(manual), Signature(pipeline));+ var pipelineResult = ResolvedProfile2DValidator.Extrude(pipeline, 2);+ var manualResult = ResolvedProfile2DValidator.Extrude(manual, 2);+ Assert.Equal(LineArcProfileExtrudeStatus.Succeeded, pipelineResult.Status);+ Assert.Equal(manualResult.Body!.Topology.Faces.Count(), pipelineResult.Body!.Topology.Faces.Count());+ Assert.Equal(manualResult.Body.Topology.Edges.Count(), pipelineResult.Body.Topology.Edges.Count());+ Assert.Equal(manualResult.Body.Topology.Vertices.Count(), pipelineResult.Body.Topology.Vertices.Count());+ }++ [Fact]+ public void Reverse_IsReadableExplicitOrientationEscapeHatch()+ {+ var parsed = ProfileAuthoringParser.Parse("""+ Point2 A { Position: [0mm, 0mm] } Point2 B { Position: [4mm, 0mm] }+ Point2 C { Position: [4mm, 3mm] } Point2 D { Position: [0mm, 3mm] }+ Line2 AB { From: A; To: B } Line2 CB { From: C; To: B }+ Line2 DC { From: D; To: C } Line2 AD { From: A; To: D }+ Profile Plate { Loop Outer { AB |> Reverse CB |> Reverse DC |> Reverse AD |> Close } }+ Extrude Solid { Profile: Plate; From: 0mm; To: 1mm }+ """);++ var profile = Assert.IsType<ResolvedProfile2D>(parsed.Profile);+ Assert.Empty(parsed.Diagnostics);+ Assert.Equal([false, true, true, true], profile.Loops.Single().Segments.Select(segment => segment.Provenance.Reversed));+ Assert.True(ResolvedProfile2DValidator.Validate(profile).IsValid);+ }++ [Fact]+ public void Continuation_AutomaticallyReversesAUniquelyMatchingSpan()+ {+ var parsed = ProfileAuthoringParser.Parse("""+ Point2 A { Position: [0mm, 0mm] } Point2 B { Position: [4mm, 0mm] }+ Point2 C { Position: [4mm, 3mm] } Point2 D { Position: [0mm, 3mm] }+ Line2 AB { From: A; To: B } Line2 CB { From: C; To: B }+ Line2 DC { From: D; To: C } Line2 AD { From: A; To: D }+ Profile Plate { Loop Outer { AB |> CB |> DC |> AD |> Close } }+ Extrude Solid { Profile: Plate; From: 0mm; To: 1mm }+ """);++ var profile = Assert.IsType<ResolvedProfile2D>(parsed.Profile);+ Assert.Empty(parsed.Diagnostics);+ Assert.Equal([false, true, true, true], profile.Loops.Single().Segments.Select(segment => segment.Provenance.Reversed));+ Assert.True(ResolvedProfile2DValidator.Validate(profile).IsValid);+ }++ [Fact]+ public void LineArcPipeline_IsNotRectangleSpecific()+ {+ var parsed = ProfileAuthoringParser.Parse("""+ Concept Path Stadium {+ Start: Point2(0mm, 0mm) Heading: 0deg+ Line Bottom { Length: 10mm }+ Arc Right { Radius: 5mm; Turn: 180deg }+ Line Top { Length: 10mm }+ Arc Left { Radius: 5mm; Turn: 180deg }+ }+ Profile Plate { Loop Outer {+ Stadium.Bottom |> Stadium.Right |> Stadium.Top |> Stadium.Left |> Close+ } }+ Extrude Solid { Profile: Plate; From: 0mm; To: 2mm }+ """);++ var profile = Assert.IsType<ResolvedProfile2D>(parsed.Profile);+ Assert.Empty(parsed.Diagnostics);+ Assert.Equal(2, profile.Loops.Single().Segments.Count(segment => segment.Geometry is LineArcLineSegment2D));+ Assert.Equal(2, profile.Loops.Single().Segments.Count(segment => segment.Geometry is LineArcCircularArc2D));+ Assert.True(ResolvedProfile2DValidator.Validate(profile).IsValid);+ }++ [Fact]+ public void OuterAndInnerPipelines_PreserveHoleOrientationAndIdentity()+ {+ var parsed = ProfileAuthoringParser.Parse("""+ Rect2 Stock { Center: [0mm, 0mm]; Size: [20mm, 20mm] }+ Rect2 Cutout { Center: [0mm, 0mm]; Size: [6mm, 6mm] }+ 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+ } }+ Extrude Solid { Profile: Plate; From: 0mm; To: 2mm }+ """);++ var profile = Assert.IsType<ResolvedProfile2D>(parsed.Profile);+ Assert.Empty(parsed.Diagnostics);+ Assert.Equal(2, profile.Loops.Count);+ Assert.True(ResolvedProfile2DValidator.Validate(profile).IsValid);+ Assert.Equal(LineArcProfileExtrudeStatus.Succeeded, ResolvedProfile2DValidator.Extrude(profile, parsed.Height).Status);+ }++ [Fact]+ public void ConceptPathPipeline_MayRemainOpenAndRetainsProvenance()+ {+ var source = """+ Rect2 Stock { Center: [0mm, 0mm]; Size: [10mm, 5mm] }+ Concept Path Guide { Stock.Bottom |> Stock.Right |> Stock.Top As Return }+ """;++ var path = Assert.IsType<ResolvedConceptPath2D>(ProfileAuthoringParser.ResolveConceptPath(source, "Guide", out var diagnostics));+ Assert.Empty(diagnostics);+ Assert.Equal(["Bottom", "Right", "Return"], path.Segments.Select(segment => segment.Name));+ Assert.Equal(["Stock.Bottom", "Stock.Right", "Stock.Top"], path.Segments.Select(segment => segment.TracedFrom));+ Assert.False(AreSame(path.Segments[0].Geometry, path.Segments[^1].Geometry));+ }++ [Fact]+ public void TraceLoop_RequiresAndNormalizesARealClosedConceptPath()+ {+ var source = """+ Concept Path Outline {+ Start: Point2(0mm, 0mm) Heading: 0deg+ Line South { Length: 10mm } Line East { Turn: 90deg; Length: 5mm }+ Line North { Turn: 90deg; Length: 10mm } Close West+ }+ Profile Plate { Outline |> TraceLoop }+ Extrude Solid { Profile: Plate; From: 0mm; To: 2mm }+ """;++ var parsed = ProfileAuthoringParser.Parse(source);+ var profile = Assert.IsType<ResolvedProfile2D>(parsed.Profile);+ Assert.Empty(parsed.Diagnostics);+ Assert.Equal(["South", "East", "North", "West"], profile.Loops.Single().Segments.Select(segment => segment.Name));+ Assert.True(ResolvedProfile2DValidator.Validate(profile).IsValid);+ }++ [Fact]+ public void TraceLoop_NormalizesInnerWindingAndQualifiesInheritedIdentity()+ {+ 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 }+ Profile Plate { Loop Outer { OuterPath |> TraceLoop } Loop Inner { InnerPath |> TraceLoop } }+ Extrude Solid { Profile: Plate; From: 0mm; To: 2mm }+ """);++ var profile = Assert.IsType<ResolvedProfile2D>(parsed.Profile);+ Assert.Empty(parsed.Diagnostics);+ Assert.All(profile.Loops.Single(loop => !loop.IsOuter).Segments, segment =>+ {+ Assert.StartsWith("Inner.", segment.Name, StringComparison.Ordinal);+ Assert.True(segment.Provenance.Reversed);+ });+ Assert.True(ResolvedProfile2DValidator.Validate(profile).IsValid);+ }++ [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 |> TraceLoop", "firmament-profile-traceloop-not-loop:Stock")]+ [InlineData("Stock.Bottom |> Stock.Right |> Close", "firmament-pipeline-close-open:Outer")]+ public void InvalidPipeline_ReportsTypedDiagnostic(string expression, string expected)+ {+ var parsed = ProfileAuthoringParser.Parse($$"""+ Rect2 Stock { Center: [0mm, 0mm]; Size: [10mm, 5mm] }+ Profile Plate { Loop Outer { {{expression}} } }+ Extrude Solid { Profile: Plate; From: 0mm; To: 1mm }+ """);++ Assert.Null(parsed.Profile);+ Assert.Contains(parsed.Diagnostics, diagnostic => diagnostic.StartsWith(expected, StringComparison.Ordinal));+ }++ [Fact]+ public void DegenerateAttachment_RejectsAmbiguousOrientation()+ {+ var parsed = ProfileAuthoringParser.Parse("""+ Point2 A { Position: [0mm, 0mm] } Point2 B { Position: [1mm, 0mm] }+ Line2 AB { From: A; To: B } Line2 Same { From: B; To: B }+ Profile Plate { Loop Outer { AB |> Same |> Close } }+ Extrude Solid { Profile: Plate; From: 0mm; To: 1mm }+ """);++ Assert.Null(parsed.Profile);+ Assert.Contains("firmament-profile-pipeline-orientation-ambiguous:Same", parsed.Diagnostics);+ }++ [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")]+ public void PipelineGrammar_IsLowPrecedenceQualifiedGeometryOnly(string expression, string expected)+ {+ var parsed = ProfileAuthoringParser.Parse($$"""+ Rect2 Stock { Center: [0mm, 0mm]; Size: [10mm, 5mm] }+ Profile Plate { Loop Outer { {{expression}} } }+ Extrude Solid { Profile: Plate; From: 0mm; To: 1mm }+ """);++ Assert.Null(parsed.Profile);+ Assert.Contains(parsed.Diagnostics, diagnostic => diagnostic.StartsWith(expected, StringComparison.Ordinal));+ }++ [Fact]+ public void PipelineEliminatesManualTraceEndpointContradiction()+ {+ var manual = ProfileAuthoringParser.Parse("""+ Rect2 Stock { Center: [0mm, 0mm]; Size: [10mm, 5mm] }+ Profile Plate { Loop Outer {+ Segment Bottom { Trace: Stock.Bottom; From: Stock.TopLeft; To: Stock.TopRight }+ } }+ Extrude Solid { Profile: Plate; From: 0mm; To: 1mm }+ """);+ var pipeline = ProfileAuthoringParser.Parse(RectanglePipeline());++ Assert.Null(manual.Profile);+ Assert.Contains(manual.Diagnostics, diagnostic => diagnostic.StartsWith("profile-endpoint-not-on-guide:Bottom:Stock.Bottom", StringComparison.Ordinal));+ Assert.NotNull(pipeline.Profile);+ }++ [Fact]+ public void PipelineOutsideProfileOrPath_IsContextTypedError()+ {+ var parsed = FirmamentV2Parser.Parse("""+ Model InvalidPipe {+ Units: mm+ Box Body { Size: [10mm, 10mm, 10mm] }+ Material |> Close+ }+ """);++ Assert.Null(parsed.Document);+ Assert.Contains("firmament-pipeline-context-type:Material", parsed.Diagnostics);+ }++ private static string RectanglePipeline() => """+ Rect2 Stock { Center: [0mm, 0mm]; Size: [10mm, 5mm] }+ Profile Plate { Loop Outer {+ Stock.Bottom |> Stock.Right |> Stock.Top |> Stock.Left |> Close+ } }+ Extrude Solid { Profile: Plate; From: 0mm; To: 2mm }+ """;++ private static string RectangleManual() => """+ Rect2 Stock { Center: [0mm, 0mm]; Size: [10mm, 5mm] }+ Profile Plate { Loop Outer {+ Segment Bottom { Trace: Stock.Bottom; From: Stock.BottomLeft; To: Stock.BottomRight }+ Segment Right { Trace: Stock.Right; From: Stock.BottomRight; To: Stock.TopRight }+ Segment Top { Trace: Stock.Top; From: Stock.TopRight; To: Stock.TopLeft }+ Segment Left { Trace: Stock.Left; From: Stock.TopLeft; To: Stock.BottomLeft }+ } }+ Extrude Solid { Profile: Plate; From: 0mm; To: 2mm }+ """;++ private static string Signature(ResolvedProfile2D profile) => string.Join("|", profile.Loops.SelectMany(loop => loop.Segments).Select(segment => segment.Geometry.ToString()));+ private static bool AreSame(LineArcProfileCurve2D left, LineArcProfileCurve2D right) => left == right;+}diff --git a/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentSemanticValues.cs b/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentSemanticValues.csindex 27783582..489bd7e7 100644--- a/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentSemanticValues.cs+++ b/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentSemanticValues.cs@@ -106,6 +106,13 @@ public static class FirmamentSemanticValuesvar exposedProfileName = exposedProfileNames.Length == 1 ? exposedProfileNames[0] : null;values.Add(new SemanticValue(inspection.Provenance ?? "concept-path:" + inspection.Name, new(bindings.Count > 0 ? "SemanticProfile" : "ConceptPath"), capabilities, bindings, members, provenance, authoredSpan, expansion is null ? null : span, exposedName: exposedProfileName ?? inspection.Name));}+ var pathBackedProfileNames = inspections.SelectMany(inspection => inspection.Consumers ?? []).Where(consumer => consumer.Kind == "Profile").Select(consumer => consumer.Name).ToHashSet(StringComparer.Ordinal);+ foreach (var profile in profiles.Values.Where(profile => !pathBackedProfileNames.Contains(profile.Name)).OrderBy(profile => profile.Name, StringComparer.Ordinal))+ {+ var match = Regex.Match(expanded, $@"\bProfile\s+{Regex.Escape(profile.Name)}\b", RegexOptions.CultureInvariant);+ var span = new SemanticSourceSpan(sourceIdentity, match.Success ? match.Index : 0, match.Success ? DeclarationLength(expanded, match.Index) : 0);+ values.Add(FromProfile(profile, span, [new("profile-pipeline", profile.Name, "finite semantic composition lowered before consumption", span)], profile.Name));+ }values.AddRange(CanonicalPrimitiveSemanticValues(expanded, sourceIdentity));return values;}diff --git a/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2Parser.cs b/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2Parser.csindex 1dec6f68..19018630 100644--- a/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2Parser.cs+++ b/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2Parser.cs@@ -305,6 +305,15 @@ public static class FirmamentV2ParsersourceText=ProfileModificationTemplateLibrary.Source+Environment.NewLine+Regex.Replace(sourceText,@"\bUse\s+Profile\.Modifications\s*;",string.Empty,RegexOptions.CultureInvariant);var diagnostics = new List<string> { "firmament-v2-parser-invoked" };var source = StripLineComments(sourceText);+ var pipelineContextDiagnostics = ProfileAuthoringParser.ValidatePipelineContexts(source);+ if (pipelineContextDiagnostics.Count > 0)+ {+ diagnostics.AddRange(pipelineContextDiagnostics);+ diagnostics.Add("firmament-v2-parse-failed");+ return FirmamentV2ParseResult.Failure(+ diagnostics.Distinct(StringComparer.Ordinal).Order().ToArray(),+ FirmamentV2ParseDisposition.RecognizedInvalid);+ }var v2AdmissionCandidate = IsV2AdmissionCandidate(source);conceptCatalog ??= FirmamentV2ForgeConceptRegistry.Catalog;@@ -2007,7 +2016,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(FirmamentV2FeatureExpansion.Prefix, 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(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;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.csindex 04b2637a..e233e7da 100644--- a/Aetheris.Kernel.Firmament/FirmamentV2/ProfileAuthoringParser.cs+++ b/Aetheris.Kernel.Firmament/FirmamentV2/ProfileAuthoringParser.cs@@ -19,10 +19,21 @@ public static class ProfileAuthoringParserprivate static readonly Regex Rect = new(@"\bRect2\s+(?<n>[A-Za-z_]\w*)\s*\{\s*Center\s*:\s*(?:\[|Point2\s*\()\s*(?<x>[-+.\deE]+)mm\s*,\s*(?<y>[-+.\deE]+)mm\s*(?:\]|\))\s*;?\s*Size\s*:\s*\[(?<w>[-+.\deE]+)mm\s*,\s*(?<h>[-+.\deE]+)mm\]", RegexOptions.Singleline | RegexOptions.CultureInvariant);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 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 Extrude = new(@"\bExtrude\s+\w+\s*\{\s*Profile\s*:\s*(?<p>\w+)\s*;?\s*From\s*:\s*(?<a>[-+.\deE]+)mm\s*;?\s*To\s*:\s*(?<b>[-+.\deE]+)mm", RegexOptions.Singleline | RegexOptions.CultureInvariant);public static bool IsProfileSource(string source) => Regex.IsMatch(source, @"\bProfile\s+[A-Za-z_]\w*", RegexOptions.CultureInvariant);+ 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();+ return Pipeline.Matches(source).Cast<Match>()+ .Where(pipeline => !allowed.Any(block => pipeline.Index >= block.Match.Index && pipeline.Index < block.EndIndex))+ .Select(pipeline => $"firmament-pipeline-context-type:{ParsePipelineStages(pipeline.Groups["expression"].Value)[0].Reference}")+ .Distinct(StringComparer.Ordinal)+ .ToArray();+ }+/// <summary>/// Resolves one domain-neutral Concept Path without converting it into a closed Profile./// Sweep and other ordered-path consumers use this boundary so authored line/arc identity@@ -46,7 +57,11 @@ public static class ProfileAuthoringParserstep.Curves.Count == 1 ? step.Name : $"{step.Name}.curve{ordinal:D2}",step.Kind,curve,- $"concept-path:{path.Name}.{step.Name}"))).ToArray(),+ $"concept-path:{path.Name}.{step.Name}",+ step.SourceReference,+ step.WasReversed,+ step.PipelineIndex,+ step.SourceRange))).ToArray(),$"concept-path:{path.Name}");}@@ -117,7 +132,9 @@ public static class ProfileAuthoringParser/// </summary>internal static IReadOnlyDictionary<string, ResolvedProfile2D> BindPathDerivedProfiles(string source, List<string> diagnostics){- var authoredProfiles = FindProfiles(source).Where(candidate => candidate.FromPath is not null).ToArray();+ // This is the canonical semantic-profile adapter used by Compose and SectionChain.+ // Its historical name remains source-compatible; pipeline syntax is erased here too.+ var authoredProfiles = FindProfiles(source).Where(candidate => candidate.FromPath is not null || candidate.Body?.Contains("|>", StringComparison.Ordinal) == true).ToArray();if (authoredProfiles.Length == 0) return new Dictionary<string, ResolvedProfile2D>();var points = new Dictionary<string, (double X, double Y)>(StringComparer.Ordinal);var guides = new Dictionary<string, LineArcProfileCurve2D>(StringComparer.Ordinal);@@ -186,6 +203,21 @@ public static class ProfileAuthoringParser{var name = block.Match.Groups["name"].Value;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);+ if (pipelinePath is not null)+ {+ result[name] = pipelinePath;+ points[$"{name}.Start"] = pipelinePath.Start;+ foreach (var step in pipelinePath.Steps)+ {+ if (step.Curves.Count == 1) guides[$"{name}.{step.Name}"] = step.Curves[0];+ points[$"{name}.{step.Name}.End"] = step.End;+ }+ }+ continue;+ }var startMatch = Regex.Match(block.Body, @"\bStart\s*:\s*Point2\s*\(\s*(?<x>[-+.\deE]+)mm\s*,\s*(?<y>[-+.\deE]+)mm\s*\)", RegexOptions.CultureInvariant);if (!startMatch.Success || !TryNumber(startMatch.Groups["x"].Value, out var sx) || !TryNumber(startMatch.Groups["y"].Value, out var sy)) { diagnostics.Add($"concept-path-start-invalid:{name}"); continue; }var heading = 0d;@@ -464,15 +496,199 @@ public static class ProfileAuthoringParservar fromInsideMatch = Regex.Match(loop.Body, @"^\s*From\s*:\s*(?<path>[A-Za-z_]\w*)\b", RegexOptions.CultureInvariant);var fromInside = fromInsideMatch.Success ? fromInsideMatch.Groups["path"].Value : null;if (fromPath is not null || fromInside is not null) { AddPathLoop(loopName, string.Equals(loopName, "Outer", StringComparison.Ordinal), fromPath ?? fromInside!, profile, paths, loops, diagnostics); continue; }- loops.Add(new ResolvedProfileLoop2D(loopName, string.Equals(loopName, "Outer", StringComparison.Ordinal), BindLowLevelSegments(profile, loopName, loop.Body, points, guides, diagnostics)));+ loops.Add(new ResolvedProfileLoop2D(loopName, string.Equals(loopName, "Outer", StringComparison.Ordinal), BindSegments(profile, loopName, loop.Body, paths, points, guides, diagnostics)));}// The first Profile frontend permitted direct segments without an explicit Loop.if (loops.Count == 0 && !string.IsNullOrWhiteSpace(profile.Body))- loops.Add(new ResolvedProfileLoop2D("Outer", true, BindLowLevelSegments(profile, "Outer", profile.Body, points, guides, diagnostics)));+ 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}");return loops;}+ private static IReadOnlyList<ResolvedProfileSegment2D> BindSegments(ProfileBlock profile, string loopName, string body, IReadOnlyDictionary<string, BoundPath> paths, IReadOnlyDictionary<string, (double X, double Y)> points, IReadOnlyDictionary<string, LineArcProfileCurve2D> guides, List<string> diagnostics)+ {+ if (!body.Contains("|>", StringComparison.Ordinal)) return BindLowLevelSegments(profile, loopName, body, points, guides, diagnostics);+ if (Segment.IsMatch(body))+ {+ diagnostics.Add($"firmament-profile-pipeline-mixed-authoring:{profile.Name}:{loopName}");+ return [];+ }+ var matches = Pipeline.Matches(body).Cast<Match>().ToArray();+ var unconsumed = matches.Aggregate(body, (remaining, pipeline) => remaining.Replace(pipeline.Value, string.Empty, StringComparison.Ordinal));+ if (matches.Length != 1 || unconsumed.Any(character => !char.IsWhiteSpace(character) && character != ';'))+ {+ diagnostics.Add($"firmament-profile-pipeline-expression-required:{profile.Name}:{loopName}");+ return [];+ }+ return BindProfilePipeline(profile, loopName, matches[0], paths, points, guides, diagnostics);+ }++ private static IReadOnlyList<ResolvedProfileSegment2D> BindProfilePipeline(ProfileBlock profile, string loopName, Match match, IReadOnlyDictionary<string, BoundPath> paths, IReadOnlyDictionary<string, (double X, double Y)> points, IReadOnlyDictionary<string, LineArcProfileCurve2D> guides, List<string> diagnostics)+ {+ var stages = ParsePipelineStages(match.Groups["expression"].Value);+ if (stages.Count == 2 && stages[1].Kind == PipelineStageKind.TraceLoop)+ {+ if (!paths.TryGetValue(stages[0].Reference!, out var path))+ {+ diagnostics.Add($"firmament-profile-traceloop-not-loop:{stages[0].Reference}");+ return [];+ }+ if (!IsClosed(path.Steps.SelectMany(step => step.Curves).ToArray()))+ {+ diagnostics.Add($"firmament-profile-traceloop-not-loop:{stages[0].Reference}");+ return [];+ }+ var curves = path.Steps.SelectMany(step => step.Curves.Select((curve, ordinal) => (Step: step, Curve: curve, Ordinal: ordinal))).ToList();+ var wantCounterClockwise = string.Equals(loopName, "Outer", StringComparison.Ordinal);+ var reversedLoop = (SignedArea(curves.Select(x => x.Curve)) > 0) != wantCounterClockwise;+ if (reversedLoop) curves = curves.AsEnumerable().Reverse().Select(x => (x.Step, Reverse(x.Curve), x.Ordinal)).ToList();+ 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}";+ return PipelineSegment(profile, loopName, name, entry.Curve, $"concept-path:{path.Name}.{entry.Step.Name}", $"{path.Name}.{entry.Step.Name}", reversedLoop, index, match.Index);+ }).ToArray();+ }+ if (stages.Any(stage => stage.Kind == PipelineStageKind.TraceLoop))+ {+ diagnostics.Add("firmament-pipeline-stage-type:TraceLoop");+ return [];+ }+ var close = stages.LastOrDefault()?.Kind == PipelineStageKind.Close;+ if (stages.Any(stage => stage.Kind == PipelineStageKind.Close && stage != stages[^1]))+ {+ diagnostics.Add("firmament-pipeline-stage-type:Close");+ return [];+ }+ var traceStages = close ? stages.Take(stages.Count - 1).ToArray() : stages.ToArray();+ var result = new List<ResolvedProfileSegment2D>();+ var names = new HashSet<string>(StringComparer.Ordinal);+ (double X, double Y)? first = null;+ (double X, double Y)? current = null;+ string? currentIdentity = null;+ for (var index = 0; index < traceStages.Length; index++)+ {+ var stage = traceStages[index];+ if (stage.Kind != PipelineStageKind.Trace || !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!, points, diagnostics, out var 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}");+ 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));+ }+ if (close && first is not null && current is not null && Distance(first.Value, current.Value) > Tolerance)+ diagnostics.Add($"firmament-pipeline-close-open:{loopName}:first={DescribeEndpoint(first.Value, points)}:current={currentIdentity}");+ return result;+ }++ private static BoundPath? BindPathPipeline(string name, string body, 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;+ if (!match.Success || unconsumed.Any(character => !char.IsWhiteSpace(character) && character != ';'))+ {+ diagnostics.Add($"firmament-path-pipeline-expression-required:{name}");+ return null;+ }+ var stages = ParsePipelineStages(match.Groups["expression"].Value);+ if (stages.Any(stage => stage.Kind is PipelineStageKind.Close or PipelineStageKind.TraceLoop))+ {+ diagnostics.Add($"firmament-pipeline-stage-type:{stages.First(stage => stage.Kind is PipelineStageKind.Close or PipelineStageKind.TraceLoop).Kind}");+ return null;+ }+ var steps = new List<BoundPathStep>();+ var names = new HashSet<string>(StringComparer.Ordinal);+ (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 (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; }+ var start = Start(oriented); var end = End(oriented);+ steps.Add(new(stepName, oriented is LineArcCircularArc2D ? "ArcTransition" : "Span", $"{name}.{stepName}", $"{name}.{stepName}.End", [oriented], start, end, Heading(start, end), stage.Reference, reversed, steps.Count, $"offset:{match.Index + stage.Offset}"));+ current = end;+ }+ return steps.Count == 0 ? null : new BoundPath(name, steps[0].Start, Heading(steps[0].Start, steps[0].End), steps);+ }++ private static LineArcProfileCurve2D? OrientPipelineCurve(LineArcProfileCurve2D source, bool explicitReverse, (double X, double Y)? current, string reference, IReadOnlyDictionary<string, (double X, double Y)>? points, List<string> diagnostics, out bool reversed)+ {+ reversed = explicitReverse;+ var candidate = explicitReverse ? Reverse(source) : source;+ if (candidate is LineArcFullCircle2D)+ {+ diagnostics.Add($"firmament-profile-pipeline-orientation-ambiguous:{reference}");+ return null;+ }+ if (current is null) return candidate;+ 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 (matchesStart) return candidate;+ if (matchesEnd) { reversed = true; return Reverse(candidate); }+ diagnostics.Add(Disconnected(current.Value, reference, candidate, points));+ return null;+ }++ 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)}";++ private static string DescribeEndpoint((double X, double Y) point, IReadOnlyDictionary<string, (double X, double Y)>? points) =>+ points?.Where(entry => Distance(entry.Value, point) <= Tolerance).Select(entry => entry.Key).OrderByDescending(x => x.Contains('.')).ThenBy(x => x, StringComparer.Ordinal).FirstOrDefault() ?? $"Point2({point.X:R}mm,{point.Y:R}mm)";++ private static ResolvedProfileSegment2D PipelineSegment(ProfileBlock profile, string loop, string name, LineArcProfileCurve2D geometry, string conceptId, string tracedFrom, bool reversed, int index, int offset) =>+ new(name, geometry, new($"profile:{profile.Name}.{loop}.{name}", conceptId, profile.SourceSpan, $"PipelineTrace({tracedFrom});reversed={reversed.ToString().ToLowerInvariant()};pipelineIndex={index}", profile.Frame ?? "XY", tracedFrom, reversed, index, $"offset:{offset}"));++ private static IReadOnlyList<PipelineStage> ParsePipelineStages(string expression)+ {+ var stages = new List<PipelineStage>();+ var offset = 0;+ foreach (var raw in expression.Split("|>", StringSplitOptions.TrimEntries))+ {+ var localOffset = expression.IndexOf(raw, offset, StringComparison.Ordinal); offset = localOffset + raw.Length;+ if (raw == "Close") stages.Add(new(PipelineStageKind.Close, null, null, false, localOffset));+ 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));+ }+ }+ return stages;+ }++ private static bool IsClosed(IReadOnlyList<LineArcProfileCurve2D> curves) => curves.Count > 0 && Distance(Start(curves[0]), End(curves[^1])) <= Tolerance && curves.Zip(curves.Skip(1)).All(pair => Distance(End(pair.First), Start(pair.Second)) <= Tolerance);+ private static double SignedArea(IEnumerable<LineArcProfileCurve2D> curves) => curves.Sum(curve => curve switch+ {+ LineArcLineSegment2D line => (line.Start.X * line.End.Y - line.End.X * line.Start.Y) / 2d,+ LineArcCircularArc2D arc => (arc.Radius * arc.Center.X * (Math.Sin(arc.StartAngleRadians + arc.SweepAngleRadians) - Math.Sin(arc.StartAngleRadians)) + arc.Radius * arc.Center.Y * (Math.Cos(arc.StartAngleRadians) - Math.Cos(arc.StartAngleRadians + arc.SweepAngleRadians)) + arc.Radius * arc.Radius * arc.SweepAngleRadians) / 2d,+ _ => 0d+ });+ private static LineArcProfileCurve2D Reverse(LineArcProfileCurve2D curve) => curve switch+ {+ LineArcLineSegment2D line => new LineArcLineSegment2D(line.End, line.Start),+ LineArcCircularArc2D arc => new LineArcCircularArc2D(arc.Center, arc.Radius, arc.StartAngleRadians + arc.SweepAngleRadians, -arc.SweepAngleRadians),+ _ => curve+ };+private static IReadOnlyList<ResolvedProfileSegment2D> BindLowLevelSegments(ProfileBlock profile, string loopName, string body, IReadOnlyDictionary<string, (double X, double Y)> points, IReadOnlyDictionary<string, LineArcProfileCurve2D> guides, List<string> diagnostics){foreach (Match raw in Regex.Matches(body, @"\bSegment\s+(?<name>\w+)\s*\{[\s\S]*?\b(?<endpoint>From|To)\s*:\s*(?<value>\[[^\]]*\]|Point2\s*\([^)]*\))", RegexOptions.CultureInvariant))@@ -542,7 +758,7 @@ public static class ProfileAuthoringParser{var open = source.IndexOf('{', match.Index, match.Length); var depth = 0; var end = -1;for (var index = open; index >= 0 && index < source.Length; index++) { if (source[index] == '{') depth++; else if (source[index] == '}' && --depth == 0) { end = index; break; } }- if (open >= 0 && end > open) yield return new(match, source[(open + 1)..end]);+ if (open >= 0 && end > open) yield return new(match, source[(open + 1)..end], end);}}@@ -576,11 +792,13 @@ public static class ProfileAuthoringParserprivate static bool OnLine((double X, double Y) point, LineArcLineSegment2D line) => Math.Abs((line.End.X - line.Start.X) * (point.Y - line.Start.Y) - (line.End.Y - line.Start.Y) * (point.X - line.Start.X)) < 1e-7;private static bool OnCircle((double X, double Y) point, (double X, double Y) center, double radius) => Math.Abs(Distance(point, center) - radius) < 1e-7;- private sealed record Block(Match Match, string Body);+ private sealed record Block(Match Match, string Body, int EndIndex);private sealed record ProfileBlock(string Name, string? Frame, string? FromPath, string? Body, string SourceSpan);private sealed record PathStep(string Kind, string Name, string Body, int Index);- 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);+ 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);/// <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/Aetheris.Kernel.Firmament/FirmamentV2/ResolvedConceptPath2D.cs b/Aetheris.Kernel.Firmament/FirmamentV2/ResolvedConceptPath2D.csindex 37448857..36a6a522 100644--- a/Aetheris.Kernel.Firmament/FirmamentV2/ResolvedConceptPath2D.cs+++ b/Aetheris.Kernel.Firmament/FirmamentV2/ResolvedConceptPath2D.cs@@ -12,4 +12,8 @@ public sealed record ResolvedConceptPathSegment2D(string Name,string SemanticKind,LineArcProfileCurve2D Geometry,- string StableId);+ string StableId,+ string? TracedFrom = null,+ bool Reversed = false,+ int? PipelineIndex = null,+ string? InvocationSourceRange = null);diff --git a/Aetheris.Kernel.Firmament/Materializer/PrismaticProfileComposition.cs b/Aetheris.Kernel.Firmament/Materializer/PrismaticProfileComposition.csindex fa1ea6d4..00b5eb3f 100644--- a/Aetheris.Kernel.Firmament/Materializer/PrismaticProfileComposition.cs+++ b/Aetheris.Kernel.Firmament/Materializer/PrismaticProfileComposition.cs@@ -174,6 +174,9 @@ public static class PrismaticProfileCompositionParser{var body = Block(source, header.Index + header.Length - 1);if (body is null) { diagnostics.Add($"compose-profile-unclosed:{header.Groups["n"].Value}"); continue; }+ // Pipeline authoring is normalized by ProfileAuthoringParser below and+ // enters Compose through the ordinary ProfileCapability boundary.+ if (body.Contains("|>", StringComparison.Ordinal)) continue;foreach (Match rawSegment in Regex.Matches(body, @"\bSegment\s+(?<name>\w+)\s*\{[\s\S]*?\b(?<endpoint>From|To)\s*:\s*(?<value>\[[^\]]*\]|Point2\s*\([^)]*\))", RegexOptions.CultureInvariant))diagnostics.Add($"{SegmentEndpointMustReferenceNamedPoint}:{rawSegment.Groups["name"].Value}:{rawSegment.Groups["endpoint"].Value}");var segments = new List<ResolvedProfileSegment2D>();diff --git a/Aetheris.Kernel.Firmament/Materializer/ResolvedProfile2D.cs b/Aetheris.Kernel.Firmament/Materializer/ResolvedProfile2D.csindex d4d9960b..ec25b9ab 100644--- a/Aetheris.Kernel.Firmament/Materializer/ResolvedProfile2D.cs+++ b/Aetheris.Kernel.Firmament/Materializer/ResolvedProfile2D.cs@@ -1,7 +1,16 @@namespace Aetheris.Kernel.Firmament.Materializer;/// <summary>Immutable, resolved material boundary. It is neither a sketch nor a constraint solver.</summary>-public sealed record ProfileSegmentProvenance(string StableId, string ConceptStableId, string SourceSpan, string Derivation, string SourceFrame);+public sealed record ProfileSegmentProvenance(+ string StableId,+ string ConceptStableId,+ string SourceSpan,+ string Derivation,+ string SourceFrame,+ string? TracedFrom = null,+ bool Reversed = false,+ int? PipelineIndex = null,+ string? InvocationSourceRange = null);public sealed record ResolvedProfileSegment2D(string Name, LineArcProfileCurve2D Geometry, ProfileSegmentProvenance Provenance);public sealed record ResolvedProfileLoop2D(string Name, bool IsOuter, IReadOnlyList<ResolvedProfileSegment2D> Segments);public sealed record ResolvedProfile2D(string Name, string PlaneFrame, IReadOnlyList<ResolvedProfileLoop2D> Loops, ConstructionPlane? ConstructionPlane = null, double? LocalStartDepth = null, double? LocalEndDepth = null)diff --git a/docs/public/firmament/geometry.md b/docs/public/firmament/geometry.mdindex f7b9e7d3..27597437 100644--- a/docs/public/firmament/geometry.md+++ b/docs/public/firmament/geometry.md@@ -40,10 +40,11 @@ Model BossPlate {Circle2 BossCircle { Center: C; Radius: 8mm }}Profile BaseProfile Using Layout { Loop Outer {- Segment Bottom { Trace: Stock.Bottom; From: Stock.BottomLeft; To: Stock.BottomRight }- Segment Right { Trace: Stock.Right; From: Stock.BottomRight; To: Stock.TopRight }- Segment Top { Trace: Stock.Top; From: Stock.TopRight; To: Stock.TopLeft }- Segment Left { Trace: Stock.Left; From: Stock.TopLeft; To: Stock.BottomLeft }+ Stock.Bottom+ |> Stock.Right+ |> Stock.Top+ |> Stock.Left+ |> Close} }Profile BossProfile Using Layout { Loop Outer {Segment Q1 { Trace: BossCircle; From: E; To: N; Sweep: CounterClockwise }@@ -98,16 +99,18 @@ Model PocketBlock {Rect2 Recess { Center: [0mm, 0mm]; Size: [20mm, 14mm] }}Profile BaseProfile Using Layout { Loop Outer {- Segment Bottom { Trace: Stock.Bottom; From: Stock.BottomLeft; To: Stock.BottomRight }- Segment Right { Trace: Stock.Right; From: Stock.BottomRight; To: Stock.TopRight }- Segment Top { Trace: Stock.Top; From: Stock.TopRight; To: Stock.TopLeft }- Segment Left { Trace: Stock.Left; From: Stock.TopLeft; To: Stock.BottomLeft }+ Stock.Bottom+ |> Stock.Right+ |> Stock.Top+ |> Stock.Left+ |> Close} }Profile PocketProfile Using Layout { Loop Outer {- Segment Bottom { Trace: Recess.Bottom; From: Recess.BottomLeft; To: Recess.BottomRight }- Segment Right { Trace: Recess.Right; From: Recess.BottomRight; To: Recess.TopRight }- Segment Top { Trace: Recess.Top; From: Recess.TopRight; To: Recess.TopLeft }- Segment Left { Trace: Recess.Left; From: Recess.TopLeft; To: Recess.BottomLeft }+ Recess.Bottom+ |> Recess.Right+ |> Recess.Top+ |> Recess.Left+ |> Close} }Struct Block { Compose Body {Base Stock { Profile: BaseProfile; From: 0mm; To: 10mm; Role: Stock }@@ -122,6 +125,8 @@ The canonical [Boss + Pocket block](../../../fixtures/Canonical/Features/Boss/boFor readable local geometry, start with the [line/arc Concept Path](../../../fixtures/Canonical/Profiles/concept-path-line-arc-profile.firmament). The [profile-delta recess](../../../fixtures/Canonical/Profiles/profile-delta-recess-extrusion.firmament) then shows that semantic `ProfileDelta` programming is not Sheet-Metal-specific: a Table row, `with` override, and typed Template modify an ordinary extruded profile.+For geometry that already exposes named spans, prefer the finite [Profile pipeline flagship](../../../fixtures/Canonical/Pipeline/profile-pipeline-flagship.firmament). `Stock.Bottom |> Stock.Right |> Stock.Top |> Stock.Left |> Close` inherits segment identities and derives endpoint continuity and orientation from the named source geometry. The [mixed line/arc witness](../../../fixtures/Canonical/Pipeline/line-arc-profile.firmament), [inner-loop witness](../../../fixtures/Canonical/Pipeline/profile-with-inner-loop.firmament), [open Concept Path](../../../fixtures/Canonical/Pipeline/open-path.firmament), and [whole-loop trace](../../../fixtures/Canonical/Pipeline/traceloop-profile.firmament) exercise the same resolved Profile/Path boundary. Use manual `Segment` declarations when bespoke endpoints, circle-arc sweep selection, or debugging requires explicit low-level control.+Sheet Metal has its own `Hole Name` syntax for planar circular openings; countersink and counterbore forms are Model-domain features and deliberately fail in Sheet Metal rather than being ignored.## Intentional Boolean boundarydiff --git a/docs/public/firmament/syntax.md b/docs/public/firmament/syntax.mdindex 13f5a82b..391a379f 100644--- a/docs/public/firmament/syntax.md+++ b/docs/public/firmament/syntax.md@@ -73,6 +73,7 @@ Use each abstraction for its single role:| `Feature` | Function-like reusable semantic construction. || `Pattern` | Bounded finite geometric repetition; it is the loop substitute. || `Template` | Compile-time product/configuration specialization; it is the structural branch substitute. |+| `|>` | Finite semantic composition of compatible Profile/Path geometry. || `Concept` | Semantic contract or capability. || `Record` / `Struct` | Typed data and semantic structure. |@@ -127,3 +128,35 @@ Feature M8Counterbore(Center: Point2) -> Hole<Counterbore> {Structurally different edge finishes should be separate Features in X1—for example, `StandardChamfer` and `StandardFillet`. A caller may instead select a specialized product with Template where that owning Template grammar admits the returned construction. Feature itself cannot branch between them.For X1, Feature is supported by the `Mechanical` frontend. `WireForm`, `Sweep`, and `SectionChain` reject Feature declarations explicitly; shared cross-schema Feature IR and module/library packaging are deferred.++## Finite Profile and Path composition++`|>` composes compatible semantic geometry in a finite authoring pipeline. In a Profile loop, each source span is traced in authored order and automatically oriented to continue from the preceding endpoint:++```firmament+Profile BaseProfile Using Layout {+ Loop Outer {+ Stock.Bottom+ |> Stock.Right+ |> Stock.Top+ |> Stock.Left+ |> Close+ }+}+```++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.++`|> 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.++A `Concept Path` may also compose existing named spans and remain open:++```firmament+Concept Path Guide {+ Stock.Bottom+ |> Stock.Right+ |> Stock.Top As Return+}+```++Pipeline source order is semantic order. Stages are limited to qualified geometry references, 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.diff --git a/docs/public/reference/supported-features.md b/docs/public/reference/supported-features.mdindex 3fd630d0..2f5a92d7 100644--- a/docs/public/reference/supported-features.md+++ b/docs/public/reference/supported-features.md@@ -10,6 +10,7 @@| Virtual Sculpture | Bounded (ART-X0) | The explicit `Mode: Virtual` Sol 1 flagship: deterministic golden-angle/Fibonacci 3D lattice, analytic toroidal frame and eye, exact closed-body AP242 assembly, evidence/preview output, and zero rational product surfaces. This is not manufacturing geometry and does not extend Firmament engineering domains. See [Virtual Sculpture](../virtual-sculpture.md). || Firmament V2 analytic primitives | Bounded | Direct named Sphere, Cone (including zero-radius pointed end), and Torus routes round-trip through AP242; legacy `solid` declarations remain compatibility inputs, not canonical authoring || Circular Sweep | Bounded (X0) | Open planar XY Concept Path, tangent line/arc segments, constant circular diameter, analytic cylinder/torus faces, capped solid; no general 3D/variable/rail/twist sweep |+| Profile/Path `|>` composition | Supported (LANG-PIPELINE-X1) | finite qualified span chains, automatic continuity orientation, `Reverse`, `As`, validating `Close`, real-loop-only `TraceLoop`, inherited identity/provenance; no general function pipe or control flow || Wire coils | Bounded (WIRE-X1) | Semantic AxisCoil plus Cylinder/Frustum/Sphere SurfaceCoil, explicit handedness/clearance, constant circular wire, evaluable winding authority, deterministic cubic non-rational STEP tube; no variable pitch/section, arbitrary support, intentional contact, dynamics, or knots || Formed Wire | Bounded (WIRE-X0) | One open, continuous, unbranched constant circular wire; explicit 3D StartFrame; ordered Straight and signed planar Bend operations through ±180° in current local Up/Right planes; exact line/arc centerline, ideal cut length/volume/mass, analytic cylinders/tori/caps, terminals, and fail-closed no-contact validation. No coils, knots, branches, variable section, springback, or intentional contact. See [guide](../firmament/wire-form.md). || SectionChain loft substrate | Bounded (SURF-X4 subset) | Firmament authoring lowers into ordered framed, same-topology semantic SectionChain IR; explicit G0 ruled or default G1 local polynomial transitions; shared edges and tangent fields; Cap/Open; strict pcurves; deterministic intersection checks; persistent typed BodyState Add/Remove through documented planar housing lanes; no generic CSG authoring, rational product surface, or faceted fallback. See [Section chains](../firmament/section-chains.md). |diff --git a/docs/release/LANG-PIPELINE-X1.md b/docs/release/LANG-PIPELINE-X1.mdnew file mode 100644index 00000000..ae3cfa66--- /dev/null+++ b/docs/release/LANG-PIPELINE-X1.md@@ -0,0 +1,91 @@+# LANG-PIPELINE-X1 — Profile / Path composition pipelines++## Executive verdict++Accepted. Firmament can derive Profiles and open Concept Paths from existing named semantic geometry without restating span endpoints or ordinary segment identity. Pipeline syntax is erased by the typed Profile/Path binder and lowers to the existing `ResolvedProfile2D` / `ResolvedConceptPath2D`, AIR, BRep, and STEP routes. It introduces no runtime pipeline or general control flow.++## Authority audit++1. A traceable span already carries analytic line/arc geometry, stable source identity, ordered endpoints, and source-container provenance. Named Point2 values and Concept Path endpoints provide semantic endpoint identities; the existing `1e-9` binder tolerance supplies the bounded geometric fallback.+2. `From`/`To` was required because the manual Segment grammar selected a guide plus an independently authored directed subspan. This remains useful for bespoke circle arcs, explicit endpoint choice, and debugging, but it redundantly restates a complete line/path span.+3. Manual orientation was resolved by `SelectGuide`; path orientation was fixed during `BindPaths`. X1 resolves pipeline orientation in `ProfileAuthoringParser` immediately before constructing the same `ResolvedProfileSegment2D` values.+4. Source span identity supplies the default output identity. Outer-loop `Stock.Bottom` becomes `Bottom`; inner-loop defaults are loop-qualified because the existing Profile validator requires Profile-wide uniqueness. `As` overrides output identity without changing provenance.+5. Manual `Segment { Trace/From/To/Sweep }`, `Profile ... From <ConceptPath>`, and `Loop ... From <ConceptPath>` remain available as low-level/whole-path authoring.++No parallel Profile representation, BRep backend, materializer, generic `Pipe<T>`, or runtime stage exists.++## Hero before / after++The flagship contains `BaseProfile`, `PadProfile`, and `CutoutProfile`. Each previous rectangle required four Segment blocks and repeated eight endpoint references:++```firmament+Profile BaseProfile Using Layout { Loop Outer {+ Segment Bottom { Trace: Stock.Bottom; From: Stock.BottomLeft; To: Stock.BottomRight }+ Segment Right { Trace: Stock.Right; From: Stock.BottomRight; To: Stock.TopRight }+ Segment Top { Trace: Stock.Top; From: Stock.TopRight; To: Stock.TopLeft }+ Segment Left { Trace: Stock.Left; From: Stock.TopLeft; To: Stock.BottomLeft }+} }+```++X1 states the engineering idea directly:++```firmament+Profile BaseProfile Using Layout { Loop Outer {+ Stock.Bottom+ |> Stock.Right+ |> Stock.Top+ |> Stock.Left+ |> Close+} }+```++Across the three rectangle Profiles, the canonical pipeline removes 12 Segment declarations and 24 repeated endpoint references. The safety result matters more than line count: `Trace: Stock.Bottom` can no longer contradict separately typed `From`/`To` values, and source names no longer need duplicate declarations.++## Semantics and safety++- Context typing: pipelines are admitted only as qualified geometry chains inside Profile loops or Concept Path declarations.+- Ordering: source order is semantic order; the binder never searches or reorders spans.+- Orientation: first-stage source direction is canonical. Each later stage attaches by endpoint identity/established tolerance; a unique end match reverses it.+- Explicit control: `Reverse <span>` requires that exact direction to connect. `<span> As <name>` provides bounded renaming.+- Identity: source leaf identity is inherited. Collisions fail as `firmament-profile-pipeline-identity-collision`; numeric suffixes are never synthesized.+- Closure: `Close` validates equality of final and first endpoint and adds no geometry.+- Whole-loop tracing: `<closed Concept Path> |> TraceLoop` copies ordered spans, preserves provenance, and normalizes outer/inner winding. Non-loop inputs fail typed.+- Provenance: ordinary Profile segments expose `tracedFrom`, `reversed`, `pipelineIndex`, and invocation source range through `inspect-profile --json`.+- Diagnostics: disconnected chains name the current and candidate endpoints; ambiguous degeneracy, invalid stages, identity collisions, invalid TraceLoop sources, and open Close are distinct diagnostics.++Manual Segment authoring remains the escape hatch for unusual subspans, explicit full-circle arc endpoints/sweep, mixed low-level work, and diagnosis.++## Control-flow boundary++`|>` is finite semantic composition. It does not introduce conditionals, loops, lambdas, filtering, mutation, arbitrary Feature calls, runtime data flow, nearest-neighbor path finding, or Pattern behavior. Feature remains reusable semantic transformation; Pattern remains bounded repetition; Template remains compile-time specialization.++## Qualification witnesses++- `fixtures/Canonical/Pipeline/profile-pipeline-flagship.firmament`: three Profile Compose/STEP product route.+- `rectangle-profile.firmament`: focused inherited-identity extrusion.+- `line-arc-profile.firmament`: mixed analytic Line/Arc chain.+- `profile-with-inner-loop.firmament`: opposite-winding hole.+- `open-path.firmament`: pipeline-authored open Concept Path through the real analytic Sweep/STEP route.+- `traceloop-profile.firmament`: real closed-loop copy.+- `manual-profile-parity.firmament`: low-level parity source.+- `fixtures/Invalid/Pipeline`: CLI-build witnesses for ambiguity, an open `Close`, disconnection, inherited-identity collision, invalid `TraceLoop`, a pipeline outside Profile/Path, and a wrong-type stage. Focused tests also cover precedence and control-flow rejection.++There is intentionally no fabricated “ambiguous loops” fixture: the current traceable whole-loop authority is one named `Concept Path`, which owns exactly one ordered chain. Profiles and Bodies are rejected as TraceLoop sources rather than treated as implicit loop containers. If a future semantic boundary value can expose multiple loops, selecting it without `.Outer`/a named loop must add the specified ambiguity diagnostic before admission.++## Schema and interaction boundary++Mechanical is the qualified schema. Template-specialized ordinary geometry continues through the same expansion-before-bind path. Feature, Pattern, and Template grammars remain unchanged, and pipeline stages cannot invoke them. Sweep can consume an open pipeline-authored Concept Path through its existing resolved-path contract; SectionChain can consume pipeline-derived Profiles through its existing Profile capability adapter. WireForm retains its own forming program. No new schema fallback is introduced.++## Validation++Validation evidence is generated under ignored `artifacts/local/lang-pipeline-x1/`.++- `dotnet build Aetheris.slnx --configuration Release --no-restore`: succeeded with 0 warnings and 0 errors.+- `dotnet test Aetheris.slnx --configuration Release --no-restore`: 3,308 passed, 0 failed, 0 skipped. The pre-existing empty `Aetheris.FrictionLab.Tests` assembly reported no discoverable tests.+- All seven canonical pipeline fixtures built through the CLI; all seven invalid fixtures failed with their typed pipeline diagnostics.+- Pipeline, repeat pipeline, manual-parity, and separately published packaged-CLI STEP exports all have SHA-256 `51A435DD2F558890FAA13A8E50CBA2A42B26A0A2AD12EC095AFAD7A9DA6B58DD`.+- The flagship STEP reimports as one enclosed-manifold body with 15 faces, 36 edges, 24 vertices, and bounds `[-20,-12,0]` to `[20,12,12]`.+- The packaged CLI was published to a temporary directory and executed with the repository outside its working directory.+- Public-document link tests are included in the 410 passing CLI tests. The repository information-architecture guard passed for 3,960 tracked files, and `git diff --check` passed.++The legacy mapping formatter does not format modern canonical V2 Profile bodies, so X1 adds no false formatter route. Public examples use one stage per line for long chains, and the shipped VS Code grammar recognizes `|>` as an operator.diff --git a/fixtures/Canonical/Features/Boss/boss-pocket-block.firmament b/fixtures/Canonical/Features/Boss/boss-pocket-block.firmamentindex 8a50a536..80f610b9 100644--- a/fixtures/Canonical/Features/Boss/boss-pocket-block.firmament+++ b/fixtures/Canonical/Features/Boss/boss-pocket-block.firmament@@ -14,10 +14,11 @@ Model BossPocketMountingBlock {}Profile BaseProfile Using Layout { Loop Outer {- Segment Bottom { Trace: Stock.Bottom; From: Stock.BottomLeft; To: Stock.BottomRight }- Segment Right { Trace: Stock.Right; From: Stock.BottomRight; To: Stock.TopRight }- Segment Top { Trace: Stock.Top; From: Stock.TopRight; To: Stock.TopLeft }- Segment Left { Trace: Stock.Left; From: Stock.TopLeft; To: Stock.BottomLeft }+ Stock.Bottom+ |> Stock.Right+ |> Stock.Top+ |> Stock.Left+ |> Close} }Profile BossProfile Using Layout { Loop Outer {Segment Q1 { Trace: BossCircle; From: BossEast; To: BossNorth; Sweep: CounterClockwise }@@ -26,16 +27,18 @@ Model BossPocketMountingBlock {Segment Q4 { Trace: BossCircle; From: BossSouth; To: BossEast; Sweep: CounterClockwise }} }Profile PocketProfile Using Layout { Loop Outer {- Segment Bottom { Trace: Recess.Bottom; From: Recess.BottomLeft; To: Recess.BottomRight }- Segment Right { Trace: Recess.Right; From: Recess.BottomRight; To: Recess.TopRight }- Segment Top { Trace: Recess.Top; From: Recess.TopRight; To: Recess.TopLeft }- Segment Left { Trace: Recess.Left; From: Recess.TopLeft; To: Recess.BottomLeft }+ Recess.Bottom+ |> Recess.Right+ |> Recess.Top+ |> Recess.Left+ |> Close} }Profile RectBossProfile Using Layout { Loop Outer {- Segment Bottom { Trace: BossPad.Bottom; From: BossPad.BottomLeft; To: BossPad.BottomRight }- Segment Right { Trace: BossPad.Right; From: BossPad.BottomRight; To: BossPad.TopRight }- Segment Top { Trace: BossPad.Top; From: BossPad.TopRight; To: BossPad.TopLeft }- Segment Left { Trace: BossPad.Left; From: BossPad.TopLeft; To: BossPad.BottomLeft }+ BossPad.Bottom+ |> BossPad.Right+ |> BossPad.Top+ |> BossPad.Left+ |> Close} }Struct MountingBlock {diff --git a/fixtures/Canonical/Pipeline/line-arc-profile.firmament b/fixtures/Canonical/Pipeline/line-arc-profile.firmamentnew file mode 100644index 00000000..574431c9--- /dev/null+++ b/fixtures/Canonical/Pipeline/line-arc-profile.firmament@@ -0,0 +1,22 @@+schema Mechanical++Concept Path Stadium {+ Start: Point2(0mm, 0mm)+ Heading: 0deg+ Line Bottom { Length: 30mm }+ Arc Right { Radius: 8mm; Turn: 180deg }+ Line Top { Length: 30mm }+ Arc Left { Radius: 8mm; Turn: 180deg }+}++Profile StadiumProfile {+ Loop Outer {+ Stadium.Bottom+ |> Stadium.Right+ |> Stadium.Top+ |> Stadium.Left+ |> Close+ }+}++Extrude Solid { Profile: StadiumProfile; From: 0mm; To: 5mm }diff --git a/fixtures/Canonical/Pipeline/manual-profile-parity.firmament b/fixtures/Canonical/Pipeline/manual-profile-parity.firmamentnew file mode 100644index 00000000..b12909b1--- /dev/null+++ b/fixtures/Canonical/Pipeline/manual-profile-parity.firmament@@ -0,0 +1,36 @@+schema Mechanical++Model ProfilePipelineFlagship {+ Units: mm++ Concept Struct Layout On XY {+ Rect2 Stock { Center: [0mm, 0mm]; Size: [40mm, 24mm] }+ Rect2 Pad { Center: [-10mm, 0mm]; Size: [10mm, 10mm] }+ Rect2 Cutout { Center: [10mm, 0mm]; Size: [8mm, 8mm] }+ }++ Profile BaseProfile Using Layout { Loop Outer {+ Segment Bottom { Trace: Stock.Bottom; From: Stock.BottomLeft; To: Stock.BottomRight }+ Segment Right { Trace: Stock.Right; From: Stock.BottomRight; To: Stock.TopRight }+ Segment Top { Trace: Stock.Top; From: Stock.TopRight; To: Stock.TopLeft }+ Segment Left { Trace: Stock.Left; From: Stock.TopLeft; To: Stock.BottomLeft }+ } }+ Profile PadProfile Using Layout { Loop Outer {+ Segment Bottom { Trace: Pad.Bottom; From: Pad.BottomLeft; To: Pad.BottomRight }+ Segment Right { Trace: Pad.Right; From: Pad.BottomRight; To: Pad.TopRight }+ Segment Top { Trace: Pad.Top; From: Pad.TopRight; To: Pad.TopLeft }+ Segment Left { Trace: Pad.Left; From: Pad.TopLeft; To: Pad.BottomLeft }+ } }+ Profile CutoutProfile Using Layout { Loop Outer {+ Segment Bottom { Trace: Cutout.Bottom; From: Cutout.BottomLeft; To: Cutout.BottomRight }+ Segment Right { Trace: Cutout.Right; From: Cutout.BottomRight; To: Cutout.TopRight }+ Segment Top { Trace: Cutout.Top; From: Cutout.TopRight; To: Cutout.TopLeft }+ Segment Left { Trace: Cutout.Left; From: Cutout.TopLeft; To: Cutout.BottomLeft }+ } }++ Struct Part { Compose Body {+ Base StockBody { Profile: BaseProfile; From: 0mm; To: 8mm; Role: Stock }+ Add RaisedPad { Profile: PadProfile; From: 8mm; To: 12mm; Role: Boss }+ Remove ThroughCutout { Profile: CutoutProfile; From: 0mm; To: 8mm; Role: ThroughCut }+ } }+}diff --git a/fixtures/Canonical/Pipeline/open-path.firmament b/fixtures/Canonical/Pipeline/open-path.firmamentnew file mode 100644index 00000000..5de3c03b--- /dev/null+++ b/fixtures/Canonical/Pipeline/open-path.firmament@@ -0,0 +1,25 @@+schema Sweep++Model PipelineSweep {+ Units: mm++ Concept Path Source {+ Start: Point2(0mm, 0mm)+ Heading: 90deg+ Line LeftLeg { Length: 25mm }+ Arc Return { Radius: 6mm; Turn: -180deg }+ Line RightLeg { Length: 25mm }+ }++ Concept Path Centerline {+ Source.LeftLeg+ |> Source.Return+ |> Source.RightLeg+ }++ Sweep Wire {+ Path: Centerline+ Diameter: 1.2mm+ Material: Standard.Materials.StainlessSteel.304_Annealed+ }+}diff --git a/fixtures/Canonical/Pipeline/profile-pipeline-flagship.firmament b/fixtures/Canonical/Pipeline/profile-pipeline-flagship.firmamentnew file mode 100644index 00000000..546f9e1c--- /dev/null+++ b/fixtures/Canonical/Pipeline/profile-pipeline-flagship.firmament@@ -0,0 +1,37 @@+schema Mechanical++Model ProfilePipelineFlagship {+ Units: mm++ Concept Struct Layout On XY {+ Rect2 Stock { Center: [0mm, 0mm]; Size: [40mm, 24mm] }+ Rect2 Pad { Center: [-10mm, 0mm]; Size: [10mm, 10mm] }+ Rect2 Cutout { Center: [10mm, 0mm]; Size: [8mm, 8mm] }+ }++ Profile BaseProfile Using Layout {+ Loop Outer {+ Stock.Bottom+ |> Stock.Right+ |> Stock.Top+ |> Stock.Left+ |> Close+ }+ }++ Profile PadProfile Using Layout {+ Loop Outer { Pad.Bottom |> Pad.Right |> Pad.Top |> Pad.Left |> Close }+ }++ Profile CutoutProfile Using Layout {+ Loop Outer { Cutout.Bottom |> Cutout.Right |> Cutout.Top |> Cutout.Left |> Close }+ }++ Struct Part {+ Compose Body {+ Base StockBody { Profile: BaseProfile; From: 0mm; To: 8mm; Role: Stock }+ Add RaisedPad { Profile: PadProfile; From: 8mm; To: 12mm; Role: Boss }+ Remove ThroughCutout { Profile: CutoutProfile; From: 0mm; To: 8mm; Role: ThroughCut }+ }+ }+}diff --git a/fixtures/Canonical/Pipeline/profile-with-inner-loop.firmament b/fixtures/Canonical/Pipeline/profile-with-inner-loop.firmamentnew file mode 100644index 00000000..cad2c87a--- /dev/null+++ b/fixtures/Canonical/Pipeline/profile-with-inner-loop.firmament@@ -0,0 +1,11 @@+schema Mechanical++Rect2 Stock { Center: [0mm, 0mm]; Size: [40mm, 30mm] }+Rect2 Cutout { Center: [0mm, 0mm]; Size: [16mm, 10mm] }++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 }+}++Extrude Solid { Profile: Plate; From: 0mm; To: 4mm }diff --git a/fixtures/Canonical/Pipeline/rectangle-profile.firmament b/fixtures/Canonical/Pipeline/rectangle-profile.firmamentnew file mode 100644index 00000000..4dfa701d--- /dev/null+++ b/fixtures/Canonical/Pipeline/rectangle-profile.firmament@@ -0,0 +1,15 @@+schema Mechanical++Rect2 Stock { Center: [0mm, 0mm]; Size: [40mm, 24mm] }++Profile BaseProfile {+ Loop Outer {+ Stock.Bottom+ |> Stock.Right+ |> Stock.Top+ |> Stock.Left+ |> Close+ }+}++Extrude Solid { Profile: BaseProfile; From: 0mm; To: 8mm }diff --git a/fixtures/Canonical/Pipeline/traceloop-profile.firmament b/fixtures/Canonical/Pipeline/traceloop-profile.firmamentnew file mode 100644index 00000000..e99a5c92--- /dev/null+++ b/fixtures/Canonical/Pipeline/traceloop-profile.firmament@@ -0,0 +1,13 @@+schema Mechanical++Concept Path Outline {+ Start: Point2(0mm, 0mm)+ Heading: 0deg+ Line Bottom { Length: 30mm }+ Line Right { Turn: 90deg; Length: 20mm }+ Line Top { Turn: 90deg; Length: 30mm }+ Close Left+}++Profile Plate { Outline |> TraceLoop }+Extrude Solid { Profile: Plate; From: 0mm; To: 5mm }diff --git a/fixtures/Invalid/Pipeline/ambiguous-orientation.firmament b/fixtures/Invalid/Pipeline/ambiguous-orientation.firmamentnew file mode 100644index 00000000..bffb739c--- /dev/null+++ b/fixtures/Invalid/Pipeline/ambiguous-orientation.firmament@@ -0,0 +1,7 @@+schema Mechanical+Point2 A { Position: [0mm, 0mm] }+Point2 B { Position: [1mm, 0mm] }+Line2 AB { From: A; To: B }+Line2 Same { From: B; To: B }+Profile Plate { Loop Outer { AB |> Same |> Close } }+Extrude Solid { Profile: Plate; From: 0mm; To: 1mm }diff --git a/fixtures/Invalid/Pipeline/close-open.firmament b/fixtures/Invalid/Pipeline/close-open.firmamentnew file mode 100644index 00000000..1b86f753--- /dev/null+++ b/fixtures/Invalid/Pipeline/close-open.firmament@@ -0,0 +1,4 @@+schema Mechanical+Rect2 Stock { Center: [0mm, 0mm]; Size: [10mm, 4mm] }+Profile Plate { Loop Outer { Stock.Bottom |> Stock.Right |> Close } }+Extrude Solid { Profile: Plate; From: 0mm; To: 1mm }diff --git a/fixtures/Invalid/Pipeline/disconnected.firmament b/fixtures/Invalid/Pipeline/disconnected.firmamentnew file mode 100644index 00000000..7f24dd0d--- /dev/null+++ b/fixtures/Invalid/Pipeline/disconnected.firmament@@ -0,0 +1,4 @@+schema Mechanical+Rect2 Stock { Center: [0mm, 0mm]; Size: [40mm, 30mm] }+Profile Plate { Loop Outer { Stock.Bottom |> Stock.Top |> Close } }+Extrude Solid { Profile: Plate; From: 0mm; To: 5mm }diff --git a/fixtures/Invalid/Pipeline/duplicate-inherited-identity.firmament b/fixtures/Invalid/Pipeline/duplicate-inherited-identity.firmamentnew file mode 100644index 00000000..83f42553--- /dev/null+++ b/fixtures/Invalid/Pipeline/duplicate-inherited-identity.firmament@@ -0,0 +1,5 @@+schema Mechanical+Rect2 A { Center: [0mm, 0mm]; Size: [10mm, 4mm] }+Rect2 B { Center: [10mm, 0mm]; Size: [10mm, 4mm] }+Profile Plate { Loop Outer { A.Bottom |> B.Bottom |> Close } }+Extrude Solid { Profile: Plate; From: 0mm; To: 1mm }diff --git a/fixtures/Invalid/Pipeline/traceloop-non-loop.firmament b/fixtures/Invalid/Pipeline/traceloop-non-loop.firmamentnew file mode 100644index 00000000..bf94d8b7--- /dev/null+++ b/fixtures/Invalid/Pipeline/traceloop-non-loop.firmament@@ -0,0 +1,4 @@+schema Mechanical+Rect2 Stock { Center: [0mm, 0mm]; Size: [10mm, 4mm] }+Profile Plate { Loop Outer { Stock |> TraceLoop } }+Extrude Solid { Profile: Plate; From: 0mm; To: 1mm }diff --git a/fixtures/Invalid/Pipeline/wrong-context.firmament b/fixtures/Invalid/Pipeline/wrong-context.firmamentnew file mode 100644index 00000000..646d3ff4--- /dev/null+++ b/fixtures/Invalid/Pipeline/wrong-context.firmament@@ -0,0 +1,6 @@+schema Mechanical+Model WrongPipelineContext {+ Units: mm+ Box Body { Size: [10mm, 10mm, 10mm] }+ Material |> Close+}diff --git a/fixtures/Invalid/Pipeline/wrong-stage-type.firmament b/fixtures/Invalid/Pipeline/wrong-stage-type.firmamentnew file mode 100644index 00000000..c76bad71--- /dev/null+++ b/fixtures/Invalid/Pipeline/wrong-stage-type.firmament@@ -0,0 +1,4 @@+schema Mechanical+Rect2 Stock { Center: [0mm, 0mm]; Size: [40mm, 30mm] }+Profile Plate { Loop Outer { Stock.Bottom |> Material |> Close } }+Extrude Solid { Profile: Plate; From: 0mm; To: 5mm }diff --git a/tools/vscode-firmament/syntaxes/firmament.tmLanguage.json b/tools/vscode-firmament/syntaxes/firmament.tmLanguage.jsonindex 1e0fb25f..46dd5499 100644--- a/tools/vscode-firmament/syntaxes/firmament.tmLanguage.json+++ b/tools/vscode-firmament/syntaxes/firmament.tmLanguage.json@@ -110,6 +110,6 @@}]},- "operators": { "patterns": [{ "name": "keyword.operator.firmament", "match": "==|!=|<=|>=|=>|[=+\\-*/<>]" }] }+ "operators": { "patterns": [{ "name": "keyword.operator.firmament", "match": "\\|>|==|!=|<=|>=|=>|[=+\\-*/<>]" }] }}}