Next Gen STEP AP242 Native-ish BREP Geometric Modeling Kernel
Expand profile authoring parser with concept path support
Yuechen Li5c0cc7bd5401
diff --git a/Aetheris.CLI/CliRunner.cs b/Aetheris.CLI/CliRunner.csindex 96c96f84..acd0e457 100644--- a/Aetheris.CLI/CliRunner.cs+++ b/Aetheris.CLI/CliRunner.cs@@ -448,6 +448,7 @@ public static class CliRunner{parsed.Profile.Name, parsed.Profile.PlaneFrame,constructionPlane = DescribeConstructionPlane(parsed.Profile.EffectiveConstructionPlane),+ conceptPaths = ProfileAuthoringParser.InspectConceptPaths(source),loops = parsed.Profile.Loops.Count,segments = parsed.Profile.Loops.SelectMany(x => x.Segments).Select(x =>{diff --git a/Aetheris.Kernel.Firmament.Tests/ConceptPathAuthoringTests.cs b/Aetheris.Kernel.Firmament.Tests/ConceptPathAuthoringTests.csnew file mode 100644index 00000000..d7405f8e--- /dev/null+++ b/Aetheris.Kernel.Firmament.Tests/ConceptPathAuthoringTests.cs@@ -0,0 +1,86 @@+using Aetheris.Kernel.Firmament.FirmamentV2;+using Aetheris.Kernel.Firmament.Materializer;++namespace Aetheris.Kernel.Firmament.Tests;++public sealed class ConceptPathAuthoringTests+{+ [Fact]+ public void ProfileFromPath_LowersOrderedGuidesIntoOrdinaryResolvedProfile()+ {+ var parsed = ProfileAuthoringParser.Parse(Rectangle("Profile Plate From Outline"));+ var profile = Assert.IsType<ResolvedProfile2D>(parsed.Profile);+ Assert.Equal(["South", "East", "North", "West"], profile.Loops.Single().Segments.Select(x => x.Name));+ Assert.All(profile.Loops.Single().Segments, x => Assert.StartsWith("concept-path:Outline.", x.Provenance.ConceptStableId, StringComparison.Ordinal));+ Assert.True(ResolvedProfile2DValidator.Validate(profile).IsValid);+ Assert.Equal(LineArcProfileExtrudeStatus.Succeeded, ResolvedProfile2DValidator.Extrude(profile, parsed.Height).Status);+ }++ [Fact]+ public void TurnBeforeAdvance_AndTangentArc_UpdateExactEndpointAndHeading()+ {+ var parsed = ProfileAuthoringParser.Parse("""+ Concept Path Outline {+ Start: Point2(0mm, 0mm)+ Heading: 0deg+ Line East { Length: 10mm }+ Arc Corner { Radius: 5mm; Turn: 90deg }+ Line West { Length: 10mm }+ }+ Profile Plate From Outline+ Extrude Solid { Profile: Plate; From: 0mm; To: 1mm }+ """);+ var profile = Assert.IsType<ResolvedProfile2D>(parsed.Profile);+ var arc = Assert.IsType<LineArcCircularArc2D>(profile.Loops.Single().Segments[1].Geometry);+ Assert.Equal(10, arc.Center.X, 9); Assert.Equal(5, arc.Center.Y, 9);+ var last = Assert.IsType<LineArcLineSegment2D>(profile.Loops.Single().Segments[2].Geometry);+ Assert.Equal(15, last.Start.X, 9); Assert.Equal(5, last.Start.Y, 9);+ Assert.Equal(15, last.End.X, 9); Assert.Equal(15, last.End.Y, 9);+ }++ [Theory]+ [InlineData("Line Bad { Turn: 90deg; Heading: 0deg; Length: 1mm }", "concept-path-turn-and-heading:Outline:Bad")]+ [InlineData("Line Bad { To: Start; Length: 1mm }", "concept-path-to-mixed-direction-or-length:Outline:Bad")]+ [InlineData("Line Bad { To: Unknown }", "concept-path-unknown-target:Outline:Bad:Unknown")]+ [InlineData("Arc Bad { Radius: 0mm; Turn: 90deg }", "concept-path-arc-invalid:Outline:Bad")]+ public void InvalidPathSteps_ProduceTypedDiagnostics(string step, string expected)+ {+ var parsed = ProfileAuthoringParser.Parse("Concept Path Outline { Start: Point2(0mm, 0mm) Heading: 0deg " + step + " }\nProfile Plate From Outline\nExtrude Solid { Profile: Plate; From: 0mm; To: 1mm }");+ Assert.Null(parsed.Profile);+ Assert.Contains(expected, parsed.Diagnostics);+ }++ [Fact]+ public void ExplicitLoopFromPath_AndLowLevelSegmentsConsumeSameEmittedGuides()+ {+ var source = Rectangle("""+ Profile Plate {+ Loop Outer {+ Segment SouthEdge { Trace: Outline.South; From: Outline.Start; To: Outline.South.End }+ Segment EastEdge { Trace: Outline.East; From: Outline.South.End; To: Outline.East.End }+ Segment NorthEdge { Trace: Outline.North; From: Outline.East.End; To: Outline.North.End }+ Segment WestEdge { Trace: Outline.West; From: Outline.North.End; To: Outline.West.End }+ }+ }+ """);+ var parsed = ProfileAuthoringParser.Parse(source);+ Assert.True(parsed.Profile is not null, string.Join(Environment.NewLine, parsed.Diagnostics));+ var profile = parsed.Profile;+ Assert.Equal(["SouthEdge", "EastEdge", "NorthEdge", "WestEdge"], profile.Loops.Single().Segments.Select(x => x.Name));+ Assert.True(ResolvedProfile2DValidator.Validate(profile).IsValid);+ }++ private static string Rectangle(string profile) => """+ 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 + """++ Extrude Solid { Profile: Plate; From: 0mm; To: 2mm }+ """;+}diff --git a/Aetheris.Kernel.Firmament/FirmamentV2/ConceptPathAst.cs b/Aetheris.Kernel.Firmament/FirmamentV2/ConceptPathAst.csnew file mode 100644index 00000000..4d31b9cb--- /dev/null+++ b/Aetheris.Kernel.Firmament/FirmamentV2/ConceptPathAst.cs@@ -0,0 +1,18 @@+namespace Aetheris.Kernel.Firmament.FirmamentV2;++/// <summary>Normalized, immutable source model for the Concept Path frontend.</summary>+public sealed record ConceptPathDeclaration(string Name, string SourceSpan, string LocalFrame, ConceptPathStart Start, double InitialHeadingDegrees, IReadOnlyList<ConceptPathStep> Steps, string StableId, string Provenance);+public sealed record ConceptPathStart(double X, double Y, string SourceSpan);+public abstract record ConceptPathStep(string Name, string SourceSpan, string StableGuideId, string StableEndpointId);+public sealed record ConceptPathLine(string Name, string SourceSpan, ConceptPathDirection Direction, double? Length, string? TargetPoint, string StableGuideId, string StableEndpointId) : ConceptPathStep(Name, SourceSpan, StableGuideId, StableEndpointId);+public sealed record ConceptPathArc(string Name, string SourceSpan, double Radius, double TurnDegrees, string StableGuideId, string StableEndpointId) : ConceptPathStep(Name, SourceSpan, StableGuideId, StableEndpointId);+public sealed record ConceptPathClose(string Name, string SourceSpan, string StableGuideId, string StableEndpointId) : ConceptPathStep(Name, SourceSpan, StableGuideId, StableEndpointId);+public abstract record ConceptPathDirection;+public sealed record ContinueHeading : ConceptPathDirection;+public sealed record RelativeTurn(double Degrees) : ConceptPathDirection;+public sealed record AbsoluteHeading(double Degrees) : ConceptPathDirection;+public sealed record ToPoint(string Reference) : ConceptPathDirection;++/// <summary>Compact resolved view used by the existing profile inspection JSON.</summary>+public sealed record ConceptPathInspection(string Name, double StartX, double StartY, double InitialHeadingDegrees, IReadOnlyList<ConceptPathEntryInspection> Entries);+public sealed record ConceptPathEntryInspection(string Name, string Kind, double StartX, double StartY, double EndX, double EndY, double HeadingDegrees, double? Radius, double? SweepDegrees, string GuideId, string EndpointId);diff --git a/Aetheris.Kernel.Firmament/FirmamentV2/ProfileAuthoringParser.cs b/Aetheris.Kernel.Firmament/FirmamentV2/ProfileAuthoringParser.csindex 0841b1eb..31b68def 100644--- a/Aetheris.Kernel.Firmament/FirmamentV2/ProfileAuthoringParser.cs+++ b/Aetheris.Kernel.Firmament/FirmamentV2/ProfileAuthoringParser.cs@@ -4,61 +4,280 @@ using Aetheris.Kernel.Firmament.Materializer;namespace Aetheris.Kernel.Firmament.FirmamentV2;-/// <summary>Bounded parser for the first scaffold-referenced profile source route.</summary>+/// <summary>+/// Binds the small, static Profile authoring language into the single resolved-profile+/// representation used by extrusion. Construction paths are deliberately only another+/// producer of named points and guides; no path-specific materialization exists.+/// </summary>public static class ProfileAuthoringParser{public const string SegmentEndpointMustReferenceNamedPoint = "ProfileSegmentEndpointMustReferenceNamedPoint";- private static readonly Regex Point = new(@"\bPoint2\s+(?<n>\w+)\s*\{\s*Position\s*:\s*(?:\[|Point2\s*\()\s*(?<x>[-+.\d]+)mm\s*,\s*(?<y>[-+.\d]+)mm\s*(?:\]|\))", RegexOptions.Singleline);- private static readonly Regex Line = new(@"\bLine2\s+(?<n>\w+)\s*\{\s*From\s*:\s*(?<a>\w+)\s*;?\s*To\s*:\s*(?<b>\w+)", RegexOptions.Singleline);- private static readonly Regex Circle = new(@"\bCircle2\s+(?<n>\w+)\s*\{\s*Center\s*:\s*(?<c>\w+)\s*;?\s*Radius\s*:\s*(?<r>[-+.\d]+)mm", RegexOptions.Singleline);- private static readonly Regex Rect = new(@"\bRect2\s+(?<n>\w+)\s*\{\s*Center\s*:\s*(?:\[|Point2\s*\()\s*(?<x>[-+.\d]+)mm\s*,\s*(?<y>[-+.\d]+)mm\s*(?:\]|\))\s*;?\s*Size\s*:\s*\[(?<w>[-+.\d]+)mm\s*,\s*(?<h>[-+.\d]+)mm\]", RegexOptions.Singleline);- private static readonly Regex Header = new(@"\bProfile\s+(?<n>\w+)\s+Using\s+(?<layout>\w+)\s*\{(?<body>[\s\S]*)", RegexOptions.CultureInvariant);+ private const double Tolerance = 1e-9;+ private static readonly Regex Point = new(@"\bPoint2\s+(?<n>[A-Za-z_]\w*)\s*\{\s*Position\s*:\s*(?:\[|Point2\s*\()\s*(?<x>[-+.\deE]+)mm\s*,\s*(?<y>[-+.\deE]+)mm\s*(?:\]|\))", RegexOptions.Singleline | RegexOptions.CultureInvariant);+ private static readonly Regex Line = new(@"\bLine2\s+(?<n>[A-Za-z_]\w*)\s*\{\s*From\s*:\s*(?<a>[\w.]+)\s*;?\s*To\s*:\s*(?<b>[\w.]+)", RegexOptions.Singleline | RegexOptions.CultureInvariant);+ private static readonly Regex Circle = new(@"\bCircle2\s+(?<n>[A-Za-z_]\w*)\s*\{\s*Center\s*:\s*(?<c>[\w.]+)\s*;?\s*Radius\s*:\s*(?<r>[-+.\deE]+)mm", RegexOptions.Singleline | RegexOptions.CultureInvariant);+ private 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);- private static readonly Regex Extrude = new(@"\bExtrude\s+\w+\s*\{\s*Profile\s*:\s*(?<p>\w+)\s*;?\s*From\s*:\s*(?<a>[-+.\d]+)mm\s*;?\s*To\s*:\s*(?<b>[-+.\d]+)mm", RegexOptions.Singleline);+ 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 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);++ public static IReadOnlyList<ConceptPathInspection> InspectConceptPaths(string source)+ {+ var diagnostics = new List<string>();+ var points = new Dictionary<string, (double X, double Y)>(StringComparer.Ordinal);+ var guides = new Dictionary<string, LineArcProfileCurve2D>(StringComparer.Ordinal);+ AddOrdinaryGuides(source, points, guides, diagnostics);+ return BindPaths(source, points, guides, diagnostics).Values.Select(path => new ConceptPathInspection(+ path.Name, path.Start.X, path.Start.Y, path.InitialHeading,+ path.Steps.Select(step => new ConceptPathEntryInspection(step.Name, step.Geometry is LineArcCircularArc2D ? "Arc" : "Line", step.Start.X, step.Start.Y, step.End.X, step.End.Y, step.Heading,+ step.Geometry is LineArcCircularArc2D arc ? arc.Radius : null, step.Geometry is LineArcCircularArc2D arc2 ? arc2.SweepAngleRadians * 180d / Math.PI : null, step.GuideName, step.EndpointName)).ToArray())).ToArray();+ }- public static bool IsProfileSource(string source) => Header.IsMatch(source);public static (ResolvedProfile2D? Profile, double Height, IReadOnlyList<string> Diagnostics) Parse(string source){- var d=new List<string>(); var h=Header.Match(source); if(!h.Success)return(null,0,["profile-source-missing-profile"]);- ConstructionPlane? constructionPlane = null;- var planeDeclaration = ConstructionPlaneDeclaration.Matches(source).Cast<Match>().SingleOrDefault(x => string.Equals(x.Groups["name"].Value, h.Groups["layout"].Value, StringComparison.Ordinal));- if (planeDeclaration is not null)+ var diagnostics = new List<string>();+ var profile = FindProfiles(source).FirstOrDefault();+ if (profile is null)+ return (null, 0, ["profile-source-missing-profile"]);++ var points = new Dictionary<string, (double X, double Y)>(StringComparer.Ordinal);+ var guides = new Dictionary<string, LineArcProfileCurve2D>(StringComparer.Ordinal);+ AddOrdinaryGuides(source, points, guides, diagnostics);+ var paths = BindPaths(source, points, guides, diagnostics);++ ConstructionPlane? plane = ResolveConstructionPlane(source, profile.Frame, diagnostics);+ var loops = BindProfileLoops(profile, paths, points, guides, diagnostics);+ var (start, end, height) = ResolveExtrude(source, profile.Name, diagnostics);+ if (diagnostics.Count != 0)+ return (null, height, diagnostics);+ return (new ResolvedProfile2D(profile.Name, profile.Frame ?? "XY", loops, plane ?? ConstructionPlane.WorldXY, start, end), height, diagnostics);+ }++ private static void AddOrdinaryGuides(string source, Dictionary<string, (double X, double Y)> points, Dictionary<string, LineArcProfileCurve2D> guides, List<string> diagnostics)+ {+ foreach (Match match in Point.Matches(source))+ if (TryNumber(match.Groups["x"].Value, out var x) && TryNumber(match.Groups["y"].Value, out var y))+ points[match.Groups["n"].Value] = (x, y);+ foreach (Match match in Rect.Matches(source))+ {+ var name = match.Groups["n"].Value;+ if (!TryNumber(match.Groups["w"].Value, out var width) || !TryNumber(match.Groups["h"].Value, out var height) || !TryNumber(match.Groups["x"].Value, out var x) || !TryNumber(match.Groups["y"].Value, out var y) || width <= 0 || height <= 0)+ { diagnostics.Add($"rect2-invalid-size:{name}"); continue; }+ points[$"{name}.BottomLeft"] = (x - width / 2, y - height / 2);+ points[$"{name}.BottomRight"] = (x + width / 2, y - height / 2);+ points[$"{name}.TopRight"] = (x + width / 2, y + height / 2);+ points[$"{name}.TopLeft"] = (x - width / 2, y + height / 2);+ }+ foreach (Match match in Line.Matches(source))+ {+ var name = match.Groups["n"].Value;+ if (!points.TryGetValue(match.Groups["a"].Value, out var from) || !points.TryGetValue(match.Groups["b"].Value, out var to)) diagnostics.Add($"profile-layout-unresolved-line:{name}");+ else guides[name] = new LineArcLineSegment2D(from, to);+ }+ foreach (Match match in Rect.Matches(source)){- if (!ConceptIrResolver.TryResolvePlane(source, planeDeclaration.Groups["trace"].Value, out var conceptPlane, out var traceDiagnostic) || conceptPlane is null)- d.Add(traceDiagnostic ?? "ConstructionPlaneTraceMissing");- else if (!ConstructionPlane.TryTrace("construction:" + planeDeclaration.Groups["name"].Value, conceptPlane, $"offset:{planeDeclaration.Index}", out constructionPlane, out var frameDiagnostic))- d.Add(frameDiagnostic ?? "ConstructionPlaneFrameInvalid");+ var name = match.Groups["n"].Value;+ if (points.TryGetValue($"{name}.BottomLeft", out var bl) && points.TryGetValue($"{name}.BottomRight", out var br) && points.TryGetValue($"{name}.TopRight", out var tr) && points.TryGetValue($"{name}.TopLeft", out var tl))+ {+ guides[$"{name}.Bottom"] = new LineArcLineSegment2D(bl, br); guides[$"{name}.Right"] = new LineArcLineSegment2D(br, tr);+ guides[$"{name}.Top"] = new LineArcLineSegment2D(tr, tl); guides[$"{name}.Left"] = new LineArcLineSegment2D(tl, bl);+ }}- else constructionPlane = ConstructionPlane.WorldXY; // Existing Concept-layout Profiles retain their global-XY compatibility frame.- var pts=new Dictionary<string,(double X,double Y)>(StringComparer.Ordinal);- foreach(Match m in Point.Matches(source))pts[m.Groups["n"].Value]=(N(m,"x"),N(m,"y"));- foreach (Match m in Rect.Matches(source))+ foreach (Match match in Circle.Matches(source)){- var w=N(m,"w"); var rectHeight=N(m,"h"); var x=N(m,"x"); var y=N(m,"y"); var n=m.Groups["n"].Value;- if (!double.IsFinite(w) || !double.IsFinite(rectHeight) || w<=0 || rectHeight<=0) { d.Add($"rect2-invalid-size:{n}"); continue; }- pts[$"{n}.BottomLeft"]=(x-w/2,y-rectHeight/2); pts[$"{n}.BottomRight"]=(x+w/2,y-rectHeight/2); pts[$"{n}.TopRight"]=(x+w/2,y+rectHeight/2); pts[$"{n}.TopLeft"]=(x-w/2,y+rectHeight/2);+ if (!points.TryGetValue(match.Groups["c"].Value, out var center) || !TryNumber(match.Groups["r"].Value, out var radius) || radius <= 0) { diagnostics.Add($"profile-layout-unresolved-circle:{match.Groups["n"].Value}"); continue; }+ // A circle remains a guide; segments choose its directed arc below.+ guides[match.Groups["n"].Value] = new LineArcFullCircle2D(center, radius);}- var lines=new Dictionary<string,LineArcLineSegment2D>(StringComparer.Ordinal);- foreach(Match m in Line.Matches(source)){if(!pts.TryGetValue(m.Groups["a"].Value,out var a)||!pts.TryGetValue(m.Groups["b"].Value,out var b))d.Add($"profile-layout-unresolved-line:{m.Groups["n"].Value}");else lines[m.Groups["n"].Value]=new(a,b);}- foreach (Match m in Rect.Matches(source))+ }++ private static IReadOnlyDictionary<string, BoundPath> BindPaths(string source, Dictionary<string, (double X, double Y)> points, Dictionary<string, LineArcProfileCurve2D> guides, List<string> diagnostics)+ {+ var result = new Dictionary<string, BoundPath>(StringComparer.Ordinal);+ foreach (var block in FindBlocks(source, @"\bConcept\s+Path\s+(?<name>[A-Za-z_]\w*)\s*\{")){- var n=m.Groups["n"].Value;- if (pts.TryGetValue($"{n}.BottomLeft",out var bl) && pts.TryGetValue($"{n}.BottomRight",out var br) && pts.TryGetValue($"{n}.TopRight",out var tr) && pts.TryGetValue($"{n}.TopLeft",out var tl))- { lines[$"{n}.Bottom"]=new(bl,br); lines[$"{n}.Right"]=new(br,tr); lines[$"{n}.Top"]=new(tr,tl); lines[$"{n}.Left"]=new(tl,bl); }+ var name = block.Match.Groups["name"].Value;+ if (!result.TryAdd(name, default!)) { diagnostics.Add($"concept-path-duplicate:{name}"); 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;+ var headingMatch = Regex.Match(block.Body, @"\bHeading\s*:\s*(?<value>[-+.\deE]+)deg", RegexOptions.CultureInvariant);+ if (headingMatch.Success && (!TryNumber(headingMatch.Groups["value"].Value, out heading) || !double.IsFinite(heading))) { diagnostics.Add($"concept-path-heading-invalid:{name}"); continue; }+ var path = new BoundPath(name, (sx, sy), heading, []);+ if (points.ContainsKey($"{name}.Start") || guides.ContainsKey(name)) { diagnostics.Add($"concept-path-name-collision:{name}"); continue; }+ points[$"{name}.Start"] = path.Start;+ var current = path.Start;+ foreach (var step in FindPathSteps(block.Body))+ {+ if (path.Steps.Any(x => x.Name == step.Name)) { diagnostics.Add($"concept-path-duplicate-step:{name}:{step.Name}"); continue; }+ var guideName = $"{name}.{step.Name}";+ var endpointName = $"{guideName}.End";+ if (guides.ContainsKey(guideName) || points.ContainsKey(endpointName)) { diagnostics.Add($"concept-path-name-collision:{guideName}"); continue; }+ if (!TryBindStep(name, step, current, ref heading, path.Start, points, out var geometry, out var endpoint, out var diagnostic)) { diagnostics.Add(diagnostic!); continue; }+ guides[guideName] = geometry!; points[endpointName] = endpoint; path.Steps.Add(new BoundPathStep(step.Name, guideName, endpointName, geometry!, current, endpoint, heading)); current = endpoint;+ }+ result[name] = path;}- var circles=new Dictionary<string,((double X,double Y) C,double R)>(StringComparer.Ordinal);- foreach(Match m in Circle.Matches(source)){if(!pts.TryGetValue(m.Groups["c"].Value,out var c))d.Add($"profile-layout-unresolved-circle:{m.Groups["n"].Value}");else circles[m.Groups["n"].Value]=(c,N(m,"r"));}- var segments=new List<ResolvedProfileSegment2D>();- foreach (Match rawSegment in Regex.Matches(h.Groups["body"].Value, @"\bSegment\s+(?<name>\w+)\s*\{[\s\S]*?\b(?<endpoint>From|To)\s*:\s*(?<value>\[[^\]]*\]|Point2\s*\([^)]*\))", RegexOptions.CultureInvariant))- d.Add($"{SegmentEndpointMustReferenceNamedPoint}:{rawSegment.Groups["name"].Value}:{rawSegment.Groups["endpoint"].Value}");- foreach(Match m in Segment.Matches(h.Groups["body"].Value))- { var n=m.Groups["n"].Value; if(!pts.TryGetValue(m.Groups["from"].Value,out var a)||!pts.TryGetValue(m.Groups["to"].Value,out var b)){d.Add($"profile-segment-unresolved:{n}");continue;} var trace=m.Groups["trace"].Value; LineArcProfileCurve2D? g=null;- if(lines.TryGetValue(trace,out var line)){if(!OnLine(a,line)||!OnLine(b,line))d.Add($"profile-endpoint-not-on-guide:{n}:{trace}"); g=new LineArcLineSegment2D(a,b);}- else if(circles.TryGetValue(trace,out var circle)){if(!OnCircle(a,circle)||!OnCircle(b,circle)||!m.Groups["sweep"].Success){d.Add($"profile-arc-invalid:{n}:{trace}");continue;}var sa=Math.Atan2(a.Y-circle.C.Y,a.X-circle.C.X);var sw=Math.Atan2(b.Y-circle.C.Y,b.X-circle.C.X)-sa;var ccw=m.Groups["sweep"].Value=="CounterClockwise";while(ccw&&sw<=0)sw+=2*Math.PI;while(!ccw&&sw>=0)sw-=2*Math.PI;g=new LineArcCircularArc2D(circle.C,circle.R,sa,sw);}- else {d.Add($"profile-guide-missing:{n}:{trace}");continue;} segments.Add(new(n,g,new($"profile:{h.Groups["n"].Value}.Outer.{n}",$"concept:{h.Groups["layout"].Value}.{trace}","source",$"Trace({trace})","XY"))); }- var e=Extrude.Match(source);var localStart=e.Success?N(e,"a"):0;var localEnd=e.Success?N(e,"b"):0;var height=e.Success?Math.Abs(localEnd-localStart):0;if(!e.Success||e.Groups["p"].Value!=h.Groups["n"].Value)d.Add("profile-extrude-missing-or-mismatched");- return d.Count>0?(null,height,d):(new ResolvedProfile2D(h.Groups["n"].Value,h.Groups["layout"].Value,[new ResolvedProfileLoop2D("Outer",true,segments)],constructionPlane,localStart,localEnd),height,d);+ return result;}- private static double N(Match m,string n)=>double.Parse(m.Groups[n].Value,CultureInfo.InvariantCulture); private static bool OnLine((double X,double Y)p,LineArcLineSegment2D l)=>Math.Abs((l.End.X-l.Start.X)*(p.Y-l.Start.Y)-(l.End.Y-l.Start.Y)*(p.X-l.Start.X))<1e-7; private static bool OnCircle((double X,double Y)p,((double X,double Y)C,double R)c)=>Math.Abs(Math.Sqrt((p.X-c.C.X)*(p.X-c.C.X)+(p.Y-c.C.Y)*(p.Y-c.C.Y))-c.R)<1e-7;++ private static bool TryBindStep(string path, PathStep step, (double X, double Y) current, ref double headingDegrees, (double X, double Y) start, IReadOnlyDictionary<string, (double X, double Y)> points, out LineArcProfileCurve2D? geometry, out (double X, double Y) endpoint, out string? diagnostic)+ {+ geometry = null; endpoint = default; diagnostic = null;+ var prefix = $"concept-path-{step.Kind.ToLowerInvariant()}-invalid:{path}:{step.Name}";+ if (step.Kind == "Close")+ {+ endpoint = start;+ if (Distance(current, endpoint) <= Tolerance) { diagnostic = $"concept-path-zero-length:{path}:{step.Name}"; return false; }+ geometry = new LineArcLineSegment2D(current, endpoint); headingDegrees = Heading(current, endpoint); return true;+ }+ var body = step.Body;+ var turn = Property(body, "Turn"); var absolute = Property(body, "Heading"); var length = Property(body, "Length"); var to = Property(body, "To");+ if (step.Kind == "Line")+ {+ if (turn is not null && absolute is not null) { diagnostic = $"concept-path-turn-and-heading:{path}:{step.Name}"; return false; }+ if (to is not null && (length is not null || turn is not null || absolute is not null)) { diagnostic = $"concept-path-to-mixed-direction-or-length:{path}:{step.Name}"; return false; }+ if (to is not null)+ {+ var targetName = string.Equals(to, "Start", StringComparison.Ordinal) ? $"{path}.Start" : to;+ if (!points.TryGetValue(targetName, out endpoint)) { diagnostic = $"concept-path-unknown-target:{path}:{step.Name}:{to}"; return false; }+ if (Distance(current, endpoint) <= Tolerance) { diagnostic = $"concept-path-zero-length:{path}:{step.Name}"; return false; }+ geometry = new LineArcLineSegment2D(current, endpoint); headingDegrees = Heading(current, endpoint); return true;+ }+ if (length is null || !TryMeasure(length, "mm", out var distance) || distance <= 0) { diagnostic = $"concept-path-length-invalid:{path}:{step.Name}"; return false; }+ if (turn is not null) { if (!TryMeasure(turn, "deg", out var degrees) || !double.IsFinite(degrees)) { diagnostic = prefix; return false; } headingDegrees += degrees; }+ else if (absolute is not null) { if (!TryMeasure(absolute, "deg", out var degrees) || !double.IsFinite(degrees)) { diagnostic = prefix; return false; } headingDegrees = degrees; }+ endpoint = Advance(current, headingDegrees, distance); geometry = new LineArcLineSegment2D(current, endpoint); return true;+ }+ var radiusText = Property(body, "Radius");+ if (step.Kind != "Arc" || radiusText is null || turn is null || absolute is not null || length is not null || to is not null || !TryMeasure(radiusText, "mm", out var radius) || radius <= 0 || !TryMeasure(turn, "deg", out var sweepDegrees) || !double.IsFinite(sweepDegrees) || Math.Abs(sweepDegrees) <= Tolerance || Math.Abs(sweepDegrees) >= 360d - Tolerance)+ { diagnostic = $"concept-path-arc-invalid:{path}:{step.Name}"; return false; }+ var headingRadians = DegreesToRadians(headingDegrees); var sweepRadians = DegreesToRadians(sweepDegrees); var sign = Math.Sign(sweepRadians);+ (double X, double Y) center = (current.X - sign * radius * Math.Sin(headingRadians), current.Y + sign * radius * Math.Cos(headingRadians));+ var startAngle = Math.Atan2(current.Y - center.Y, current.X - center.X);+ geometry = new LineArcCircularArc2D(center, radius, startAngle, sweepRadians);+ endpoint = (center.Item1 + radius * Math.Cos(startAngle + sweepRadians), center.Item2 + radius * Math.Sin(startAngle + sweepRadians));+ headingDegrees += sweepDegrees;+ return true;+ }++ private static IReadOnlyList<ResolvedProfileLoop2D> BindProfileLoops(ProfileBlock profile, IReadOnlyDictionary<string, BoundPath> paths, IReadOnlyDictionary<string, (double X, double Y)> points, IReadOnlyDictionary<string, LineArcProfileCurve2D> guides, List<string> diagnostics)+ {+ var loops = new List<ResolvedProfileLoop2D>();+ if (profile.FromPath is not null) { AddPathLoop("Outer", true, profile.FromPath, profile, paths, loops, diagnostics); return loops; }+ var loopBlocks = FindBlocks(profile.Body ?? string.Empty, @"\bLoop\s+(?<name>[A-Za-z_]\w*)(?:\s+From\s+(?<path>[A-Za-z_]\w*))?\s*\{").ToList();+ var blockLoopNames = new HashSet<string>(loopBlocks.Select(x => x.Match.Groups["name"].Value), StringComparer.Ordinal);+ foreach (Match loop in Regex.Matches(profile.Body ?? string.Empty, @"\bLoop\s+(?<name>[A-Za-z_]\w*)\s+From\s+(?<path>[A-Za-z_]\w*)\b(?!\s*\{)", RegexOptions.CultureInvariant))+ if (blockLoopNames.Add(loop.Groups["name"].Value))+ AddPathLoop(loop.Groups["name"].Value, string.Equals(loop.Groups["name"].Value, "Outer", StringComparison.Ordinal), loop.Groups["path"].Value, profile, paths, loops, diagnostics);+ foreach (var loop in loopBlocks)+ {+ var loopName = loop.Match.Groups["name"].Value; var fromPath = loop.Match.Groups["path"].Success ? loop.Match.Groups["path"].Value : null;+ var 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)));+ }+ // 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)));+ if (loops.Count == 0) diagnostics.Add($"profile-loop-missing:{profile.Name}");+ return loops;+ }++ 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))+ diagnostics.Add($"{SegmentEndpointMustReferenceNamedPoint}:{raw.Groups["name"].Value}:{raw.Groups["endpoint"].Value}");+ var segments = new List<ResolvedProfileSegment2D>();+ foreach (Match match in Segment.Matches(body))+ {+ var name = match.Groups["n"].Value;+ if (!points.TryGetValue(match.Groups["from"].Value, out var from) || !points.TryGetValue(match.Groups["to"].Value, out var to)) { diagnostics.Add($"profile-segment-unresolved:{name}"); continue; }+ if (!guides.TryGetValue(match.Groups["trace"].Value, out var guide)) { diagnostics.Add($"profile-guide-missing:{name}:{match.Groups["trace"].Value}"); continue; }+ var geometry = SelectGuide(guide, from, to, match.Groups["sweep"].Value, name, match.Groups["trace"].Value, diagnostics);+ if (geometry is not null) segments.Add(SegmentResult(profile, loopName, name, geometry, $"concept:{profile.Frame ?? "XY"}.{match.Groups["trace"].Value}", $"Trace({match.Groups["trace"].Value})"));+ }+ return segments;+ }++ private static void AddPathLoop(string loopName, bool outer, string pathName, ProfileBlock profile, IReadOnlyDictionary<string, BoundPath> paths, List<ResolvedProfileLoop2D> loops, List<string> diagnostics)+ {+ if (!paths.TryGetValue(pathName, out var path)) { diagnostics.Add($"profile-path-missing:{profile.Name}:{pathName}"); return; }+ loops.Add(new ResolvedProfileLoop2D(loopName, outer, path.Steps.Select(step => SegmentResult(profile, loopName, outer ? step.Name : $"{loopName}.{step.Name}", step.Geometry, $"concept-path:{pathName}.{step.Name}", "ConceptPath")).ToArray()));+ }++ private static ResolvedProfileSegment2D SegmentResult(ProfileBlock profile, string loop, string name, LineArcProfileCurve2D geometry, string conceptId, string derivation) => new(name, geometry, new($"profile:{profile.Name}.{loop}.{name}", conceptId, profile.SourceSpan, derivation, profile.Frame ?? "XY"));++ private static LineArcProfileCurve2D? SelectGuide(LineArcProfileCurve2D guide, (double X, double Y) from, (double X, double Y) to, string sweep, string segment, string trace, List<string> diagnostics)+ {+ if (guide is LineArcLineSegment2D line) { if (!OnLine(from, line) || !OnLine(to, line)) diagnostics.Add($"profile-endpoint-not-on-guide:{segment}:{trace}"); return new LineArcLineSegment2D(from, to); }+ if (guide is LineArcFullCircle2D circle)+ {+ if (!OnCircle(from, circle.Center, circle.Radius) || !OnCircle(to, circle.Center, circle.Radius) || string.IsNullOrWhiteSpace(sweep)) { diagnostics.Add($"profile-arc-invalid:{segment}:{trace}"); return null; }+ var start = Math.Atan2(from.Y - circle.Center.Y, from.X - circle.Center.X); var amount = Math.Atan2(to.Y - circle.Center.Y, to.X - circle.Center.X) - start;+ var ccw = sweep == "CounterClockwise"; while (ccw && amount <= 0) amount += 2 * Math.PI; while (!ccw && amount >= 0) amount -= 2 * Math.PI;+ return new LineArcCircularArc2D(circle.Center, circle.Radius, start, amount);+ }+ diagnostics.Add($"profile-guide-missing:{segment}:{trace}"); return null;+ }++ private static ConstructionPlane? ResolveConstructionPlane(string source, string? frame, List<string> diagnostics)+ {+ if (frame is null) return ConstructionPlane.WorldXY;+ var plane = ConstructionPlaneDeclaration.Matches(source).Cast<Match>().SingleOrDefault(x => x.Groups["name"].Value == frame);+ if (plane is null) return ConstructionPlane.WorldXY;+ if (!ConceptIrResolver.TryResolvePlane(source, plane.Groups["trace"].Value, out var conceptPlane, out var traceDiagnostic) || conceptPlane is null) { diagnostics.Add(traceDiagnostic ?? "ConstructionPlaneTraceMissing"); return null; }+ if (!ConstructionPlane.TryTrace("construction:" + frame, conceptPlane, $"offset:{plane.Index}", out var result, out var frameDiagnostic)) diagnostics.Add(frameDiagnostic ?? "ConstructionPlaneFrameInvalid");+ return result;+ }++ private static (double Start, double End, double Height) ResolveExtrude(string source, string profileName, List<string> diagnostics)+ {+ var match = Extrude.Matches(source).Cast<Match>().FirstOrDefault(x => x.Groups["p"].Value == profileName);+ if (match is null || !TryNumber(match.Groups["a"].Value, out var start) || !TryNumber(match.Groups["b"].Value, out var end)) { diagnostics.Add("profile-extrude-missing-or-mismatched"); return default; }+ return (start, end, Math.Abs(end - start));+ }++ private static IEnumerable<ProfileBlock> FindProfiles(string source)+ {+ foreach (var block in FindBlocks(source, @"\bProfile\s+(?<name>[A-Za-z_]\w*)(?:\s+Using\s+(?<frame>[A-Za-z_]\w*))?\s*\{")) yield return new(block.Match.Groups["name"].Value, block.Match.Groups["frame"].Success ? block.Match.Groups["frame"].Value : null, null, block.Body, $"source:{block.Match.Index}");+ foreach (Match match in Regex.Matches(source, @"\bProfile\s+(?<name>[A-Za-z_]\w*)\s+From\s+(?<path>[A-Za-z_]\w*)\b", RegexOptions.CultureInvariant)) yield return new(match.Groups["name"].Value, null, match.Groups["path"].Value, null, $"source:{match.Index}");+ }++ private static IEnumerable<Block> FindBlocks(string source, string headerPattern)+ {+ foreach (Match match in Regex.Matches(source, headerPattern, RegexOptions.CultureInvariant))+ {+ 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]);+ }+ }++ private static IEnumerable<PathStep> FindPathSteps(string body)+ {+ var entries = new List<PathStep>();+ foreach (var block in FindBlocks(body, @"\b(?<kind>Line|Arc)\s+(?<name>[A-Za-z_]\w*)\s*\{")) entries.Add(new(block.Match.Groups["kind"].Value, block.Match.Groups["name"].Value, block.Body, block.Match.Index));+ foreach (Match match in Regex.Matches(body, @"\bClose\s+(?<name>[A-Za-z_]\w*)\b", RegexOptions.CultureInvariant)) entries.Add(new("Close", match.Groups["name"].Value, string.Empty, match.Index));+ return entries.OrderBy(x => x.Index);+ }++ private static string? Property(string body, string name) { var match = Regex.Match(body, $@"\b{name}\s*:\s*(?<v>[A-Za-z_]\w*(?:\.[A-Za-z_]\w*)?|[-+.\deE]+(?:mm|deg)?)", RegexOptions.CultureInvariant); return match.Success ? match.Groups["v"].Value : null; }+ private static bool TryMeasure(string text, string unit, out double value) { value = default; var match = Regex.Match(text, $@"^(?<v>[-+.\deE]+){unit}$", RegexOptions.CultureInvariant); return match.Success && TryNumber(match.Groups["v"].Value, out value); }+ private static bool TryNumber(string text, out double value) => double.TryParse(text, NumberStyles.Float, CultureInfo.InvariantCulture, out value) && double.IsFinite(value);+ private static (double X, double Y) Advance((double X, double Y) point, double heading, double length) { var radians = DegreesToRadians(heading); return (point.X + length * Math.Cos(radians), point.Y + length * Math.Sin(radians)); }+ private static double DegreesToRadians(double value) => value * Math.PI / 180d;+ private static double Heading((double X, double Y) from, (double X, double Y) to) => Math.Atan2(to.Y - from.Y, to.X - from.X) * 180d / Math.PI;+ private static double Distance((double X, double Y) a, (double X, double Y) b) => Math.Sqrt((a.X - b.X) * (a.X - b.X) + (a.Y - b.Y) * (a.Y - b.Y));+ private 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 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 GuideName, string EndpointName, LineArcProfileCurve2D Geometry, (double X, double Y) Start, (double X, double Y) End, double Heading);+ private sealed record BoundPath(string Name, (double X, double Y) Start, double InitialHeading, List<BoundPathStep> Steps);}diff --git a/docs/firmament/concept-path-m1.md b/docs/firmament/concept-path-m1.mdnew file mode 100644index 00000000..0cc65a9a--- /dev/null+++ b/docs/firmament/concept-path-m1.md@@ -0,0 +1,21 @@+# Concept Path M1 design note++Ordered guide adjacency removes repeated endpoint declarations for ordinary outlines while preserving the existing exact guide/Profile pipeline. The new construct is deliberately a Path rather than a Loop: it is an open-capable construction scaffold, and `Profile` alone continues to own closure, winding, material-region, and self-intersection policy.++`Line` and `Arc` are geometry declarations, not `Vector2` actions. `Vector2` stays a value; compiler-local state only exists while the Path lowers. `Turn` is relative to the current heading, whereas `Heading` is absolute in the enclosing local 2D frame. This keeps local editing readable without offering a world-frame bypass.++The lowering emits `Path.Start`, `Path.Step`, and `Path.Step.End` identities into the same maps consumed by normal profile authoring. No path-specific resolved profile, materializer, STEP route, role-Match map, or automatic winding correction is introduced. Branches, cursor moves, arbitrary arc constructions, and role inference remain deferred.++The matched rectangle comparison is materially shorter without concealing connectivity:++| Measure | Low-level rectangle | Concept Path rectangle |+| --- | ---: | ---: |+| repeated endpoint references | 8 | 0 |+| authored point scalar coordinates | 8 | 2 |+| boundary guide declarations | 4 | 4 ordered steps |+| normalized Profile segments | 4 | 4 |+| exact extrusion volume | 400 mm³ | 400 mm³ |++The L-bracket similarly removes coordinate-coincidence arithmetic while retaining locally meaningful turns. The low-level form remains clearer when a profile selects only portions of scaffolding or needs non-path guide composition. For the matched rectangle, canonical STEP hashes are identical as well as topology, bounds, and exact volume.++M1 readability check: the start, initial travel direction, each turn, arc, closure, and consuming Profile are visible in source order. The intentionally open fixture demonstrates that a Path is valid until a Profile consumes it. Focused authoring tests cover first-attempt rectangle, L/arc state transitions, low-level fallback, and typed invalid mixes without parser archaeology.diff --git a/docs/firmament/v2-canonical-authoring.md b/docs/firmament/v2-canonical-authoring.mdindex da22aec1..9c316ad2 100644--- a/docs/firmament/v2-canonical-authoring.md+++ b/docs/firmament/v2-canonical-authoring.md@@ -12,6 +12,10 @@ analyze-to-replacement workflow.Firmament V2 is one language. Backend specialization is not an author-facing dialect. Parse the document first; route its semantics after parsing.+### Concept Path++For ordinary connected line/arc scaffolds, use `Concept Path`: its ordered entries emit named guides and endpoints and can be consumed directly with `Profile Name From PathName`, or with explicit `Loop Outer From` / `Loop Inner From` declarations. It does not replace low-level `Segment` authoring or validate a material boundary. See [Concept Path M1](v2-concept-path.md) and the [canonical fixtures](../../fixtures/FirmamentV2/Canonical/valid/concept-path-rectangle.firmament).+Use this form for ordinary parts:```firmamentdiff --git a/docs/firmament/v2-concept-path.md b/docs/firmament/v2-concept-path.mdnew file mode 100644index 00000000..ab8358dd--- /dev/null+++ b/docs/firmament/v2-concept-path.md@@ -0,0 +1,40 @@+# Firmament V2 Concept Path (M1)++`Concept Path` is the concise frontend for an ordered, contiguous local-2D chain of line and tangent-arc guides. It lowers to the same named points, guides, ordinary `Profile` loops, and `ResolvedProfile2D` route as `Rect2`, `Line2`, `Circle2`, and explicit `Segment` declarations.++It is a **Path**, not a Profile Loop: a Path may be open and has no opinion about closure, winding, material boundaries, or intersections. Those checks remain with `Profile`.++```firmament+Concept Path Outline {+ Start: Point2(-10mm, -5mm)+ Heading: 0deg+ Line South { Length: 20mm }+ Line East { Turn: 90deg; Length: 10mm }+ Line North { Heading: 180deg; Length: 20mm }+ Close West+}+Profile Plate From Outline+```++Coordinates and headings are local to the enclosing construction frame. `Heading` sets the initial or absolute local heading; `Turn` is relative to the current heading and happens before a line advances. A line with neither continues the current heading. `Line { To: Start }` emits a straight guide to the Path start, updates the heading to that line direction, and cannot be mixed with `Length`, `Turn`, or `Heading`. `Close West` is exactly that line-to-start sugar; it emits the ordinary named guide `Outline.West` and endpoint `Outline.West.End`.++Every step emits a guide and endpoint: `Outline.Start`, `Outline.South`, and `Outline.South.End` are all available to normal low-level profile segments.++```firmament+Arc InnerFillet { Radius: 8mm; Turn: 90deg }+```++An arc is an exact circular arc. Its entry point and tangent come from the current Path state; a positive turn is counterclockwise in the local XY frame and a negative turn is clockwise. Radius and turn must be nonzero; full-circle sweeps are not admitted in M1.++The profile shorthand creates one outer loop from every Path guide in declaration order. The expandable form permits holes:++```firmament+Profile Plate {+ Loop Outer From OuterOutline+ Loop Inner From InnerCutout+}+```++Use explicit `Segment { Trace; From; To }` when selecting part of a guide or when the desired boundary is not simply the complete Path. There is no `MoveTo`, branching, subpath, automatic reversal, `Arc To`, spline, or path-level geometry validation in M1.++Canonical examples are maintained under `fixtures/FirmamentV2/Canonical/valid/concept-path-*.firmament`.diff --git a/fixtures/FirmamentV2/Canonical/invalid/concept-path-duplicate-step.firmament b/fixtures/FirmamentV2/Canonical/invalid/concept-path-duplicate-step.firmamentnew file mode 100644index 00000000..625d4c7a--- /dev/null+++ b/fixtures/FirmamentV2/Canonical/invalid/concept-path-duplicate-step.firmament@@ -0,0 +1,3 @@+Concept Path Outline { Start: Point2(0mm, 0mm) Line Edge { Length: 1mm } Line Edge { Turn: 90deg; Length: 1mm } }+Profile Plate From Outline+Extrude Solid { Profile: Plate; From: 0mm; To: 1mm }diff --git a/fixtures/FirmamentV2/Canonical/invalid/concept-path-negative-length.firmament b/fixtures/FirmamentV2/Canonical/invalid/concept-path-negative-length.firmamentnew file mode 100644index 00000000..9165be47--- /dev/null+++ b/fixtures/FirmamentV2/Canonical/invalid/concept-path-negative-length.firmament@@ -0,0 +1,3 @@+Concept Path Outline { Start: Point2(0mm, 0mm) Line Bad { Length: -1mm } }+Profile Plate From Outline+Extrude Solid { Profile: Plate; From: 0mm; To: 1mm }diff --git a/fixtures/FirmamentV2/Canonical/invalid/concept-path-open-profile.firmament b/fixtures/FirmamentV2/Canonical/invalid/concept-path-open-profile.firmamentnew file mode 100644index 00000000..1bcb8183--- /dev/null+++ b/fixtures/FirmamentV2/Canonical/invalid/concept-path-open-profile.firmament@@ -0,0 +1,3 @@+Concept Path Outline { Start: Point2(0mm, 0mm) Line Open { Length: 1mm } }+Profile Plate From Outline+Extrude Solid { Profile: Plate; From: 0mm; To: 1mm }diff --git a/fixtures/FirmamentV2/Canonical/invalid/concept-path-to-and-length.firmament b/fixtures/FirmamentV2/Canonical/invalid/concept-path-to-and-length.firmamentnew file mode 100644index 00000000..ecfef7d7--- /dev/null+++ b/fixtures/FirmamentV2/Canonical/invalid/concept-path-to-and-length.firmament@@ -0,0 +1,3 @@+Concept Path Outline { Start: Point2(0mm, 0mm) Line Bad { To: Start; Length: 1mm } }+Profile Plate From Outline+Extrude Solid { Profile: Plate; From: 0mm; To: 1mm }diff --git a/fixtures/FirmamentV2/Canonical/invalid/concept-path-turn-and-heading.firmament b/fixtures/FirmamentV2/Canonical/invalid/concept-path-turn-and-heading.firmamentnew file mode 100644index 00000000..1d07ad25--- /dev/null+++ b/fixtures/FirmamentV2/Canonical/invalid/concept-path-turn-and-heading.firmament@@ -0,0 +1,3 @@+Concept Path Outline { Start: Point2(0mm, 0mm) Line Bad { Turn: 90deg; Heading: 0deg; Length: 1mm } }+Profile Plate From Outline+Extrude Solid { Profile: Plate; From: 0mm; To: 1mm }diff --git a/fixtures/FirmamentV2/Canonical/invalid/concept-path-unknown-target.firmament b/fixtures/FirmamentV2/Canonical/invalid/concept-path-unknown-target.firmamentnew file mode 100644index 00000000..0028255f--- /dev/null+++ b/fixtures/FirmamentV2/Canonical/invalid/concept-path-unknown-target.firmament@@ -0,0 +1,3 @@+Concept Path Outline { Start: Point2(0mm, 0mm) Line Bad { To: Missing } }+Profile Plate From Outline+Extrude Solid { Profile: Plate; From: 0mm; To: 1mm }diff --git a/fixtures/FirmamentV2/Canonical/invalid/concept-path-wrong-winding.firmament b/fixtures/FirmamentV2/Canonical/invalid/concept-path-wrong-winding.firmamentnew file mode 100644index 00000000..a9b61b3a--- /dev/null+++ b/fixtures/FirmamentV2/Canonical/invalid/concept-path-wrong-winding.firmament@@ -0,0 +1,3 @@+Concept Path Outline { Start: Point2(0mm, 0mm) Heading: 90deg Line A { Length: 1mm } Line B { Turn: -90deg; Length: 1mm } Line C { Turn: -90deg; Length: 1mm } Close D }+Profile Plate From Outline+Extrude Solid { Profile: Plate; From: 0mm; To: 1mm }diff --git a/fixtures/FirmamentV2/Canonical/invalid/concept-path-zero-length.firmament b/fixtures/FirmamentV2/Canonical/invalid/concept-path-zero-length.firmamentnew file mode 100644index 00000000..6092aafd--- /dev/null+++ b/fixtures/FirmamentV2/Canonical/invalid/concept-path-zero-length.firmament@@ -0,0 +1,3 @@+Concept Path Outline { Start: Point2(0mm, 0mm) Line Bad { Length: 0mm } }+Profile Plate From Outline+Extrude Solid { Profile: Plate; From: 0mm; To: 1mm }diff --git a/fixtures/FirmamentV2/Canonical/invalid/concept-path-zero-radius-arc.firmament b/fixtures/FirmamentV2/Canonical/invalid/concept-path-zero-radius-arc.firmamentnew file mode 100644index 00000000..77693747--- /dev/null+++ b/fixtures/FirmamentV2/Canonical/invalid/concept-path-zero-radius-arc.firmament@@ -0,0 +1,3 @@+Concept Path Outline { Start: Point2(0mm, 0mm) Arc Bad { Radius: 0mm; Turn: 90deg } }+Profile Plate From Outline+Extrude Solid { Profile: Plate; From: 0mm; To: 1mm }diff --git a/fixtures/FirmamentV2/Canonical/invalid/concept-path-zero-turn-arc.firmament b/fixtures/FirmamentV2/Canonical/invalid/concept-path-zero-turn-arc.firmamentnew file mode 100644index 00000000..2fadf18a--- /dev/null+++ b/fixtures/FirmamentV2/Canonical/invalid/concept-path-zero-turn-arc.firmament@@ -0,0 +1,3 @@+Concept Path Outline { Start: Point2(0mm, 0mm) Arc Bad { Radius: 1mm; Turn: 0deg } }+Profile Plate From Outline+Extrude Solid { Profile: Plate; From: 0mm; To: 1mm }diff --git a/fixtures/FirmamentV2/Canonical/valid/concept-path-inner-cutout.firmament b/fixtures/FirmamentV2/Canonical/valid/concept-path-inner-cutout.firmamentnew file mode 100644index 00000000..5ec7b3eb--- /dev/null+++ b/fixtures/FirmamentV2/Canonical/valid/concept-path-inner-cutout.firmament@@ -0,0 +1,24 @@+Model ConceptPathInnerCutout {+ Units: mm+ Concept Path OuterOutline {+ Start: Point2(-10mm, -10mm)+ Heading: 0deg+ Line South { Length: 20mm }+ Line East { Turn: 90deg; Length: 20mm }+ Line North { Turn: 90deg; Length: 20mm }+ Close West+ }+ Concept Path InnerCutout {+ Start: Point2(-3mm, -3mm)+ Heading: 90deg+ Line West { Length: 6mm }+ Line North { Turn: -90deg; Length: 6mm }+ Line East { Turn: -90deg; Length: 6mm }+ Close South+ }+ Profile Plate {+ Loop Outer From OuterOutline+ Loop Inner From InnerCutout+ }+ Struct Body { Extrude Plate { Profile: Plate; From: 0mm; To: 2mm } }+}diff --git a/fixtures/FirmamentV2/Canonical/valid/concept-path-l-bracket-arc.firmament b/fixtures/FirmamentV2/Canonical/valid/concept-path-l-bracket-arc.firmamentnew file mode 100644index 00000000..1b71eaf4--- /dev/null+++ b/fixtures/FirmamentV2/Canonical/valid/concept-path-l-bracket-arc.firmament@@ -0,0 +1,14 @@+Model ConceptPathArc {+ Units: mm+ Concept Path RoundedCorner {+ Start: Point2(0mm, 0mm)+ Heading: 0deg+ Line Base { Length: 40mm }+ Line Rise { Turn: 90deg; Length: 20mm }+ Arc OuterFillet { Radius: 10mm; Turn: 90deg }+ Line Top { Length: 30mm }+ Close Left+ }+ Profile Plate From RoundedCorner+ Struct Body { Extrude Plate { Profile: Plate; From: 0mm; To: 2mm } }+}diff --git a/fixtures/FirmamentV2/Canonical/valid/concept-path-l-bracket.firmament b/fixtures/FirmamentV2/Canonical/valid/concept-path-l-bracket.firmamentnew file mode 100644index 00000000..8a4fa620--- /dev/null+++ b/fixtures/FirmamentV2/Canonical/valid/concept-path-l-bracket.firmament@@ -0,0 +1,15 @@+Model ConceptPathLBracket {+ Units: mm+ Concept Path BracketOutline {+ Start: Point2(-40mm, -40mm)+ Heading: 0deg+ Line South { Length: 100mm }+ Line East { Turn: 90deg; Length: 20mm }+ Line Inner { Turn: 90deg; Length: 80mm }+ Line Upright { Turn: -90deg; Length: 90mm }+ Line North { Turn: 90deg; Length: 20mm }+ Close West+ }+ Profile Bracket From BracketOutline+ Struct Body { Extrude Bracket { Profile: Bracket; From: 0mm; To: 10mm } }+}diff --git a/fixtures/FirmamentV2/Canonical/valid/concept-path-low-level-mixed.firmament b/fixtures/FirmamentV2/Canonical/valid/concept-path-low-level-mixed.firmamentnew file mode 100644index 00000000..10135a66--- /dev/null+++ b/fixtures/FirmamentV2/Canonical/valid/concept-path-low-level-mixed.firmament@@ -0,0 +1,20 @@+Model ConceptPathLowLevelMixed {+ Units: mm+ Concept Path Outline {+ Start: Point2(0mm, 0mm)+ Heading: 0deg+ Line South { Length: 20mm }+ Line East { Turn: 90deg; Length: 10mm }+ Line North { Turn: 90deg; Length: 20mm }+ Close West+ }+ Profile Plate {+ Loop Outer {+ Segment South { Trace: Outline.South; From: Outline.Start; To: Outline.South.End }+ Segment East { Trace: Outline.East; From: Outline.South.End; To: Outline.East.End }+ Segment North { Trace: Outline.North; From: Outline.East.End; To: Outline.North.End }+ Segment West { Trace: Outline.West; From: Outline.North.End; To: Outline.West.End }+ }+ }+ Struct Body { Extrude Plate { Profile: Plate; From: 0mm; To: 2mm } }+}diff --git a/fixtures/FirmamentV2/Canonical/valid/concept-path-profile-explicit-loop.firmament b/fixtures/FirmamentV2/Canonical/valid/concept-path-profile-explicit-loop.firmamentnew file mode 100644index 00000000..2a9c6c27--- /dev/null+++ b/fixtures/FirmamentV2/Canonical/valid/concept-path-profile-explicit-loop.firmament@@ -0,0 +1,15 @@+Model ConceptPathExplicitLoop {+ Units: mm+ Concept Path Outline {+ Start: Point2(0mm, 0mm)+ Heading: 0deg+ Line South { Length: 20mm }+ Line East { Turn: 90deg; Length: 10mm }+ Line North { Turn: 90deg; Length: 20mm }+ Close West+ }+ Profile Plate {+ Loop Outer From Outline+ }+ Struct Body { Extrude Plate { Profile: Plate; From: 0mm; To: 2mm } }+}diff --git a/fixtures/FirmamentV2/Canonical/valid/concept-path-rectangle.firmament b/fixtures/FirmamentV2/Canonical/valid/concept-path-rectangle.firmamentnew file mode 100644index 00000000..959aafdd--- /dev/null+++ b/fixtures/FirmamentV2/Canonical/valid/concept-path-rectangle.firmament@@ -0,0 +1,13 @@+Model ConceptPathRectangle {+ Units: mm+ Concept Path Outline {+ Start: Point2(-10mm, -5mm)+ Heading: 0deg+ Line South { Length: 20mm }+ Line East { Turn: 90deg; Length: 10mm }+ Line North { Turn: 90deg; Length: 20mm }+ Close West+ }+ Profile Plate From Outline+ Struct Body { Extrude Plate { Profile: Plate; From: -2mm; To: 0mm } }+}