Next Gen STEP AP242 Native-ish BREP Geometric Modeling Kernel
Preserve named Feature application identity across editor reuse
Yuechen Lic8f48b5b0974
diff --git a/Aetheris.CLI/CliRunner.cs b/Aetheris.CLI/CliRunner.csindex be3581d2..d3e83b5d 100644--- a/Aetheris.CLI/CliRunner.cs+++ b/Aetheris.CLI/CliRunner.cs@@ -1760,6 +1760,10 @@ Model CanonicalPanel {invocation.ExpandedSemanticKind,invocation.GeneratedByFeature,invocation.ResultIdentity,+ invocation.ApplicationIdentity,+ invocation.IdentityKind,+ invocation.Pattern,+ invocation.GeneratedResults,invocation.BindingScope,invocation.DefinitionOrigin,invocation.InvocationOrigin,diff --git a/Aetheris.Kernel.Firmament.Tests/FirmamentFeatureIdentityTests.cs b/Aetheris.Kernel.Firmament.Tests/FirmamentFeatureIdentityTests.csnew file mode 100644index 00000000..34661f69--- /dev/null+++ b/Aetheris.Kernel.Firmament.Tests/FirmamentFeatureIdentityTests.cs@@ -0,0 +1,109 @@+using Aetheris.Kernel.Firmament.FirmamentV2;+using Aetheris.Kernel.Firmament.FirmamentV2.Syntax;++namespace Aetheris.Kernel.Firmament.Tests;++public sealed class FirmamentFeatureIdentityTests+{+ private static string Fixture(string name) => File.ReadAllText(FirmamentCorpusHarness.ResolveFixtureFullPath(+ "fixtures/Regression/FeatureIdentity/" + name + ".firmament")).ReplaceLineEndings("\n");++ private static FirmamentV2Document Parse(string source)+ {+ var result = FirmamentV2Parser.Parse(source);+ Assert.True(result.IsSuccess, string.Join("\n", result.Diagnostics));+ return result.Document!;+ }++ [Fact]+ public void NamedCallsKeepIdentityAndPublishWallSelectionWhenReorderedOrMoved()+ {+ var source = Fixture("named-mounts");+ var left = "Feature leftBore = MountHole(center: Layout.leftMount)";+ var right = "Feature rightBore = MountHole(center: Layout.rightMount)";+ var reordered = source.Replace(left, "__left__").Replace(right, left).Replace("__left__", right);+ var baseline = Parse(source);+ foreach (var text in new[] { source, reordered, source.Replace("[-12mm, 0mm]", "[-10mm, 0mm]") })+ {+ var document = Parse(text);+ Assert.Equal(baseline.FeatureInvocations!.Select(i => i.ApplicationIdentity).Order(), document.FeatureInvocations!.Select(i => i.ApplicationIdentity).Order());+ Assert.All(document.FeatureInvocations!, i => Assert.Equal("Named", i.IdentityKind));+ var build = FirmamentBuildAndExport.CompileSource(text);+ Assert.True(build.IsSuccess, string.Join("\n", build.Diagnostics));+ Assert.Equal(new[] { "leftBore", "rightBore" }, document.ModifyBlocks!.Single().SemanticHoles.Select(h => h.Name).Order());+ var projection = Assert.Single(FirmamentFieldProjector.Project(document, text, "mounts.firmament", 1), p => p.SemanticId == "stock.leftBore");+ Assert.Equal(document.FeatureInvocations!.Single(i => i.ResultIdentity == "leftBore").ApplicationIdentity, projection.FeatureApplicationIdentity);+ Assert.StartsWith("MountHole(", text.Substring(projection.ConstructSpan!.Start, projection.ConstructSpan.Length));+ Assert.All(projection.Fields, field => { Assert.False(field.Editable); Assert.Null(field.ValueSpan); });+ var hole = document.ModifyBlocks.Single().SemanticHoles.Single(h => h.Name == "leftBore");+ Assert.Equal(projection.ConstructSpan, hole.SourceSpan);+ var sourceMap = new Aetheris.Kernel.Firmament.Materializer.GeometrySourceMap(build.Value!.RuntimeCorrespondence!);+ Assert.True(sourceMap.TryGetSourceSpan("stock.leftBore", out var geometrySpan));+ Assert.Equal(projection.ConstructSpan, geometrySpan);+ Assert.Equal(text.Contains("[-10mm, 0mm]") ? -10d : -12d, hole.Center.U);+ }+ }++ [Fact]+ public void KeyedPatternReportsActualResultsAndSurvivesInsertionReorderAndRemoval()+ {+ var source = Fixture("keyed-mounts");+ var baseline = Assert.Single(Parse(source).FeatureInvocations!);+ foreach (var text in new[] { source, source.Replace("left => Point2(-12mm, 0mm)\n right => Point2(12mm, 0mm)",+ "right => Point2(12mm, 0mm)\n middle => Point2(0mm, 0mm)\n left => Point2(-12mm, 0mm)"),+ source.Replace(" left => Point2(-12mm, 0mm)\n", "") })+ {+ var document = Parse(text);+ var call = Assert.Single(document.FeatureInvocations!);+ Assert.Equal("KeyedPattern", call.IdentityKind);+ Assert.Equal(baseline.ApplicationIdentity, call.ApplicationIdentity);+ Assert.Contains("mounts.right", call.GeneratedResults);+ Assert.Equal(document.StaticAuthoring!.Patterns!.Single().GeneratedIds, call.GeneratedResults);+ Assert.Equal(call.GeneratedResults.Select(n => n.Replace('.', '_')).Order(), document.ModifyBlocks!.Single().SemanticHoles.Select(h => h.Name).Order());+ var build = FirmamentBuildAndExport.CompileSource(text);+ Assert.True(build.IsSuccess, string.Join("\n", build.Diagnostics));+ Assert.All(FirmamentFieldProjector.Project(document, text, "keyed.firmament", 1).Where(p => p.FeatureApplicationIdentity is not null),+ p => Assert.Equal(call.ApplicationIdentity, p.FeatureApplicationIdentity));+ }+ }++ [Fact]+ public void EditorNamesNewCallsAndPromotesAnExistingCallWithoutChangingGeometry()+ {+ var source = Fixture("named-mounts");+ var pmi = FirmamentLanguageOutlineService.Outline(source, "mounts.firmament", "1").Nodes.Single(n => n.Kind == "Pmi");+ var anonymous = FirmamentLanguageEditService.Apply(source, "mounts.firmament", "1", [new("removeDeclaration") { Node = pmi.Id }])+ .Text.Replace("Feature leftBore = ", "");+ var call = FirmamentSyntaxTraversal.Statements(FirmamentSyntaxParser.Parse(anonymous).Document)+ .OfType<ExpressionStatementSyntax>().Single();+ var promoted = FirmamentLanguageEditService.Apply(anonymous, "mounts.firmament", "1", [new("nameFeature")+ { Span = new(call.Span.Start, call.Span.Length), Name = "leftBore" }]);+ Assert.Contains("Feature leftBore = MountHole(center: Layout.leftMount)", promoted.Text);+ Assert.Contains("MountingPlate/Modify:stock/leftBore", promoted.Nodes);+ var before = FirmamentBuildAndExport.CompileSource(anonymous);+ var after = FirmamentBuildAndExport.CompileSource(promoted.Text);+ Assert.True(before.IsSuccess, string.Join("\n", before.Diagnostics));+ Assert.True(after.IsSuccess, string.Join("\n", after.Diagnostics));+ Assert.Equal(Aetheris.Kernel.Core.Brep.Verification.BrepMassProperties.Evaluate(before.Value!.RuntimeBody!).SignedVolume,+ Aetheris.Kernel.Core.Brep.Verification.BrepMassProperties.Evaluate(after.Value!.RuntimeBody!).SignedVolume, 9);+ var insertion = FirmamentLanguageEditService.Apply(source, "mounts.firmament", "1", [new("insertFeature")+ { Node = "MountingPlate/Box:stock", Source = "MountHole(center: Point2(0mm, 0mm))" }]);+ Assert.Contains("Feature mountHole = MountHole(", insertion.Text);+ Assert.True(FirmamentBuildAndExport.CompileSource(insertion.Text).IsSuccess);+ Assert.Equal(Parse(source).FeatureInvocations!.Single(i => i.ResultIdentity == "leftBore").ApplicationIdentity,+ Parse(insertion.Text).FeatureInvocations!.Single(i => i.ResultIdentity == "leftBore").ApplicationIdentity);+ var lowercase = FirmamentLanguageEditService.Apply(source.Replace("MountHole", "mountHole"), "mounts.firmament", "1", [new("insertFeature")+ { Node = "MountingPlate/Box:stock", Source = "mountHole(center: Point2(0mm, 0mm))" }]);+ Assert.Contains("Feature mountHole2 = mountHole(", lowercase.Text);+ Assert.True(FirmamentBuildAndExport.CompileSource(lowercase.Text).IsSuccess);+ var explicitName = FirmamentLanguageEditService.Apply(source, "mounts.firmament", "1", [new("insertDeclaration")+ { Parent = "MountingPlate/Modify:stock", Source = "MountHole(center: Point2(0mm, 0mm))", Name = "centerBore" }]);+ Assert.Contains("Feature centerBore = MountHole(", explicitName.Text);+ Assert.True(FirmamentBuildAndExport.CompileSource(explicitName.Text).IsSuccess);+ var duplicate = Assert.Throws<FirmamentLanguageEditException>(() => FirmamentLanguageEditService.Apply(anonymous, "mounts.firmament", "1",+ [new("nameFeature") { Span = new(call.Span.Start, call.Span.Length), Name = "rightBore" }]));+ Assert.Equal("edit-name-taken", duplicate.Code);+ Assert.Throws<FirmamentLanguageEditException>(() => FirmamentLanguageEditService.Apply(anonymous, "mounts.firmament", "1",+ [new("nameFeature") { Span = new(call.Span.Start + 1, call.Span.Length), Name = "leftBore" }]));+ }+}diff --git a/Aetheris.Kernel.Firmament.Tests/FirmamentLanguageReuseTests.cs b/Aetheris.Kernel.Firmament.Tests/FirmamentLanguageReuseTests.csindex 21411958..3e70bd28 100644--- a/Aetheris.Kernel.Firmament.Tests/FirmamentLanguageReuseTests.cs+++ b/Aetheris.Kernel.Firmament.Tests/FirmamentLanguageReuseTests.cs@@ -6,7 +6,7 @@ namespace Aetheris.Kernel.Firmament.Tests;/// operations that make them keep the model's geometry.</summary>public sealed class FirmamentLanguageReuseTests{- private const string Bracket = """+ private static readonly string Bracket = """Model WebBracket {Units: mmBox Plate { Size: [50mm, 40mm, 8mm] }@@ -15,7 +15,7 @@ public sealed class FirmamentLanguageReuseTests}}- """;+ """.ReplaceLineEndings("\n");private static FirmamentLanguageEdit Edit(string source, params FirmamentLanguageEditOperation[] operations) =>FirmamentLanguageEditService.Apply(source, "bracket.firmament", "1", operations);@@ -30,7 +30,7 @@ public sealed class FirmamentLanguageReuseTests[Fact]public void Outline_ShowsParameterValuesFeatureSignaturesAndPlacedCalls(){- const string source = """+ var source = """Feature MountHole(center: Point2, diameter: Length = 3.4mm) -> Hole<Shaft> {return Hole<Shaft> { On: +Z Center: center Diameter: diameter End: ThroughAll }}@@ -43,7 +43,7 @@ public sealed class FirmamentLanguageReuseTestsMountHole(center: Point2(-10mm, 0mm), diameter: 5mm)}}- """;+ """.ReplaceLineEndings("\n");var outline = FirmamentLanguageOutlineService.Outline(source, "m", "1");var thickness = outline.Nodes.Single(n => n.Id == "M/Thickness");Assert.Equal("Length", thickness.Annotation);@@ -89,12 +89,12 @@ public sealed class FirmamentLanguageReuseTestsUnits: mmBox Plate { Size: [50mm, 40mm, 8mm] }Modify Plate {- MountHole(center: Point2(0mm, 0mm), diameter: 8mm)+ Feature CenterMount = MountHole(center: Point2(0mm, 0mm), diameter: 8mm)}}- """, result.Text);- Assert.Equal(["WebBracket/Modify:Plate/MountHole"], result.Nodes);+ """.ReplaceLineEndings("\n"), result.Text);+ Assert.Equal(["WebBracket/Modify:Plate/CenterMount"], result.Nodes);Assert.Equal(Step(Bracket), Step(result.Text));}@@ -105,27 +105,27 @@ public sealed class FirmamentLanguageReuseTestsvar two = Edit(extracted,new FirmamentLanguageEditOperation("insertFeature") { Node = "WebBracket/Box:Plate", Source = "MountHole(center: Point2(15mm, 0mm))" },new FirmamentLanguageEditOperation("insertFeature") { Node = "WebBracket/Box:Plate", Source = "EdgeFinish TopBreak { Face: +Z Target: Boundary Kind: Chamfer Distance: 1mm }" });- Assert.Equal(["WebBracket/Modify:Plate/MountHole#2", "WebBracket/Modify:Plate/TopBreak"], two.Nodes);- Assert.Contains(" MountHole(center: Point2(0mm, 0mm))\n MountHole(center: Point2(15mm, 0mm))\n EdgeFinish TopBreak", two.Text);+ Assert.Equal(["WebBracket/Modify:Plate/mountHole", "WebBracket/Modify:Plate/TopBreak"], two.Nodes);+ Assert.Contains(" Feature CenterMount = MountHole(center: Point2(0mm, 0mm))\n Feature mountHole = MountHole(center: Point2(15mm, 0mm))\n EdgeFinish TopBreak", two.Text);Step(two.Text);var moved = Edit(two.Text, new FirmamentLanguageEditOperation("moveDeclaration") { Node = "WebBracket/Modify:Plate/TopBreak", First = true });- Assert.Contains(" Modify Plate {\n EdgeFinish TopBreak { Face: +Z Target: Boundary Kind: Chamfer Distance: 1mm }\n MountHole(center: Point2(0mm, 0mm))", moved.Text);+ Assert.Contains(" Modify Plate {\n EdgeFinish TopBreak { Face: +Z Target: Boundary Kind: Chamfer Distance: 1mm }\n Feature CenterMount = MountHole(center: Point2(0mm, 0mm))", moved.Text);Assert.Equal(["WebBracket/Modify:Plate/TopBreak"], moved.Nodes);- var down = Edit(moved.Text, new FirmamentLanguageEditOperation("moveDeclaration") { Node = "WebBracket/Modify:Plate/MountHole#1", After = "WebBracket/Modify:Plate/MountHole#2" });- Assert.Contains("MountHole(center: Point2(15mm, 0mm))\n MountHole(center: Point2(0mm, 0mm))\n }", down.Text);+ var down = Edit(moved.Text, new FirmamentLanguageEditOperation("moveDeclaration") { Node = "WebBracket/Modify:Plate/CenterMount", After = "WebBracket/Modify:Plate/mountHole" });+ Assert.Contains("Feature mountHole = MountHole(center: Point2(15mm, 0mm))\n Feature CenterMount = MountHole(center: Point2(0mm, 0mm))\n }", down.Text);// A placed call's arguments are its fields.var argued = Edit(down.Text,- new FirmamentLanguageEditOperation("setField") { Node = "WebBracket/Modify:Plate/MountHole#1", Field = "center", Value = "Point2(12mm, 0mm)" },- new FirmamentLanguageEditOperation("setField") { Node = "WebBracket/Modify:Plate/MountHole#1", Field = "diameter", Value = "4mm" });+ new FirmamentLanguageEditOperation("setField") { Node = "WebBracket/Modify:Plate/mountHole", Field = "center", Value = "Point2(12mm, 0mm)" },+ new FirmamentLanguageEditOperation("setField") { Node = "WebBracket/Modify:Plate/mountHole", Field = "diameter", Value = "4mm" });Assert.Contains("MountHole(center: Point2(12mm, 0mm), diameter: 4mm)", argued.Text);Assert.Contains("MountHole(center: Point2(12mm, 0mm))", Edit(argued.Text,- new FirmamentLanguageEditOperation("removeField") { Node = "WebBracket/Modify:Plate/MountHole#1", Field = "diameter" }).Text);+ new FirmamentLanguageEditOperation("removeField") { Node = "WebBracket/Modify:Plate/mountHole", Field = "diameter" }).Text);Assert.Contains("MountHole(diameter: 4mm)", Edit(argued.Text,- new FirmamentLanguageEditOperation("removeField") { Node = "WebBracket/Modify:Plate/MountHole#1", Field = "center" }).Text);+ new FirmamentLanguageEditOperation("removeField") { Node = "WebBracket/Modify:Plate/mountHole", Field = "center" }).Text);- var removed = Edit(down.Text, new FirmamentLanguageEditOperation("removeDeclaration") { Node = "WebBracket/Modify:Plate/MountHole#2" });+ var removed = Edit(down.Text, new FirmamentLanguageEditOperation("removeDeclaration") { Node = "WebBracket/Modify:Plate/CenterMount" });Assert.DoesNotContain("Point2(0mm, 0mm))\n", removed.Text[removed.Text.IndexOf("Modify", StringComparison.Ordinal)..]);Step(removed.Text);}@@ -148,7 +148,7 @@ public sealed class FirmamentLanguageReuseTests[Fact]public void ExtractFeature_WorksForOtherFeatureKindsAndAngles(){- const string source = """+ var source = """Model M {Units: mmBox Plate { Size: [60mm, 40mm, 10mm] }@@ -158,7 +158,7 @@ public sealed class FirmamentLanguageReuseTests}}- """;+ """.ReplaceLineEndings("\n");var sink = Edit(source, new FirmamentLanguageEditOperation("extractFeature") { Node = "M/Modify:Plate/Sink", Name = "FlatHead", Parameters = ["Center", "CountersinkAngle"] });Assert.Contains("Feature FlatHead(center: Point2 = Point2(0mm, 0mm), countersinkAngle: Angle = 90deg) -> Hole<Countersink> {", sink.Text);var both = Edit(sink.Text, new FirmamentLanguageEditOperation("extractFeature") { Node = "M/Modify:Plate/Break", Name = "EdgeBreak", Parameters = ["Distance"] });@@ -166,9 +166,9 @@ public sealed class FirmamentLanguageReuseTests}[Fact]- public void ExtractFeature_RefusesADeclarationSomethingRefersToAndWarnsThatTheNameGoes()+ public void ExtractFeature_PreservesTheNameAndItsPmiReferences(){- const string pmi = """+ var pmi = """Model A3 {Units: mmBox Plate { Size: [100mm, 70mm, 10mm] }@@ -180,13 +180,12 @@ public sealed class FirmamentLanguageReuseTests}}- """;- var refused = Assert.Throws<FirmamentLanguageEditException>(() =>- Edit(pmi, new FirmamentLanguageEditOperation("extractFeature") { Node = "A3/Modify:Plate/Mount", Name = "MountHole", Parameters = ["Center"] }));- Assert.Equal("edit-extract-referenced", refused.Code);- Assert.Contains("A3/Pmi/MountDiameter", refused.Message, StringComparison.Ordinal);+ """.ReplaceLineEndings("\n");+ var extracted = Edit(pmi, new FirmamentLanguageEditOperation("extractFeature") { Node = "A3/Modify:Plate/Mount", Name = "MountHole", Parameters = ["Center"] });+ Assert.Contains("Feature Mount = MountHole(", extracted.Text);+ Assert.Contains("Target: Mount", extracted.Text);+ Assert.Equal(Step(pmi), Step(extracted.Text));+ Assert.Empty(extracted.Warnings);- var edit = Edit(Bracket, new FirmamentLanguageEditOperation("extractFeature") { Node = "WebBracket/Modify:Plate/CenterMount", Name = "MountHole", Parameters = ["Center"] });- Assert.Contains(edit.Warnings, w => w.StartsWith("CenterMount is now a placed MountHole", StringComparison.Ordinal));}}diff --git a/Aetheris.Kernel.Firmament.Tests/FirmamentV2FeatureFunctionTests.cs b/Aetheris.Kernel.Firmament.Tests/FirmamentV2FeatureFunctionTests.csindex cdfb29f4..5b55e9ac 100644--- a/Aetheris.Kernel.Firmament.Tests/FirmamentV2FeatureFunctionTests.cs+++ b/Aetheris.Kernel.Firmament.Tests/FirmamentV2FeatureFunctionTests.cs@@ -28,10 +28,12 @@ public sealed class FirmamentV2FeatureFunctionTestsAssert.Equal(4d, hole.CounterboreDepth);}- [Fact]- public void Feature_ComposesWithBoundedPatternWithoutAddingLoopSyntax()+ [Theory]+ [InlineData(false)]+ [InlineData(true)]+ public void Feature_ComposesWithBoundedPatternWithoutAddingLoopSyntax(bool named){- var parse = FirmamentV2Parser.Parse("""+ var source = """Feature MountHole(Center: Point3, Diameter: Length = 6mm) -> Hole<Shaft> {return Hole<Shaft> {On: Base.Top@@ -59,12 +61,20 @@ public sealed class FirmamentV2FeatureFunctionTests}}}- """);+ """;+ if (named) source = source.Replace("MountHole(Center: Item, Diameter: 6mm)", "Feature mount = MountHole(Center: Item, Diameter: 6mm)");+ var parse = FirmamentV2Parser.Parse(source);Assert.True(parse.IsSuccess, string.Join(Environment.NewLine, parse.Diagnostics));Assert.Equal(4, parse.Document!.ModifyBlocks!.Single().SemanticHoles.Count);Assert.Equal(4, Assert.Single(parse.Document.ConceptIr!.PatternExpansions!).Count);Assert.Single(parse.Document.FeatureInvocations!);+ var invocation = parse.Document.FeatureInvocations![0];+ Assert.Equal("PositionalPattern", invocation.IdentityKind);+ Assert.Equal(parse.Document.ConceptIr.PatternExpansions![0].GeneratedDeclarations, invocation.GeneratedResults);+ Assert.Equal(named ? "mount" : null, invocation.ResultIdentity);+ var build = FirmamentBuildAndExport.CompileSource(source);+ Assert.True(build.IsSuccess, string.Join("\n", build.Diagnostics));}[Fact]diff --git a/Aetheris.Kernel.Firmament.Tests/FunctionalPickupTests.cs b/Aetheris.Kernel.Firmament.Tests/FunctionalPickupTests.csindex 79945420..236702c5 100644--- a/Aetheris.Kernel.Firmament.Tests/FunctionalPickupTests.cs+++ b/Aetheris.Kernel.Firmament.Tests/FunctionalPickupTests.cs@@ -72,6 +72,15 @@ public sealed class FunctionalPickupTestsAssert.Contains("Profile Pad__Call1__Section", expansion.Source);Assert.Contains(Aetheris.Kernel.Firmament.FirmamentV2.Syntax.FirmamentSyntaxTraversal.Declarations(expansion.Document!),d => d.Type.Name.Text == "Boss" && d.Name?.Text == "Pad");+ var inserted = FirmamentV2FeatureExpansion.Expand(source.Replace("Feature Pad = Outer()", "Outer()\n Feature Pad = Outer()"), diagnostics);+ Assert.NotNull(inserted);+ Assert.Empty(diagnostics);+ Assert.Contains("Profile Pad__Call1__Section", inserted.Source);+ Assert.DoesNotContain("Profile Pad__Call3__Section", inserted.Source);+ var padCalls = inserted.Invocations.Where(i => i.ResultIdentity == "Pad").ToArray();+ Assert.Equal(2, padCalls.Length);+ Assert.Single(padCalls.Select(i => i.ApplicationIdentity).Distinct());+ Assert.Single(padCalls.Select(i => i.InvocationOrigin!.SourceSpan).Distinct());}[Theory]diff --git a/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentFieldProjection.cs b/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentFieldProjection.csindex 2a2cf656..83986ce5 100644--- a/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentFieldProjection.cs+++ b/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentFieldProjection.cs@@ -2,6 +2,7 @@ using System.Globalization;using System.Security.Cryptography;using System.Text;using Aetheris.Kernel.Firmament.Materializer;+using Aetheris.Kernel.Firmament.FirmamentV2.Syntax;namespace Aetheris.Kernel.Firmament.FirmamentV2;@@ -13,7 +14,10 @@ public sealed record FirmamentFieldProjection(FirmamentFieldId FieldId, string Nbool Editable, string? ReadOnlyReason);public sealed record FirmamentConstructProjection(FirmamentConstructId ConstructId, string SemanticId,string SourceDocument, string SourceRevision, int BuildRevision, FirmamentV2SourceSpan? ConstructSpan,- IReadOnlyList<FirmamentFieldProjection> Fields);+ IReadOnlyList<FirmamentFieldProjection> Fields)+{+ public string? FeatureApplicationIdentity { get; init; }+}public sealed record FirmamentFieldRewrite(bool Success, string? NewSource, string? NewSourceRevision,FirmamentV2SourceSpan? ReplacedSpan, string? Replacement, string? Code, string? Message);@@ -30,20 +34,39 @@ public static class FirmamentFieldProjector{var revision = RevisionOf(source);var result = new List<FirmamentConstructProjection>();+ var authored = FirmamentSyntaxTraversal.Declarations(FirmamentSyntaxParser.Parse(source).Document).ToArray();+ DeclarationSyntax? Original(string kind, string name)+ {+ var matches = authored.Where(d => d.Type.Name.Text.Equals(kind, StringComparison.OrdinalIgnoreCase) && d.Name?.Text == name).ToArray();+ return matches.Length == 1 ? matches[0] : null;+ }+ static FirmamentV2AuthoredField[] Fields(DeclarationSyntax? declaration, IReadOnlyList<FirmamentV2AuthoredField>? bound) =>+ (declaration?.Body?.Statements.OfType<FieldSyntax>() ?? []).Select(field => new FirmamentV2AuthoredField(+ bound?.FirstOrDefault(f => FirmamentSyntaxFields.SameField(f.Name, field.Name.Text))?.Name ?? field.Name.Text,+ field.Span, field.Value.Span)).ToArray();foreach (var solid in document.Solids){if (solid.Box is not { } box || solid.SourceSpan is null) continue;var schema = FirmamentSemanticSchemas.Get("Box")!;- result.Add(new(schema.Id, solid.Name, sourceDocument, revision, buildRevision, solid.SourceSpan,- schema.Fields.Select(field => ProjectBoxField(field, box, solid.AuthoredFields, source)).ToArray()));+ var declaration = Original(solid.RecordType, solid.Name);+ result.Add(new(schema.Id, solid.Name, sourceDocument, revision, buildRevision, declaration?.Span,+ schema.Fields.Select(field => ProjectBoxField(field, box, Fields(declaration, solid.AuthoredFields), source)).ToArray()));}foreach (var block in document.ModifyBlocks ?? [])foreach (var hole in block.SemanticHoles){- if (hole.SourceSpan is null) continue;+ var application = FirmamentV2FeatureExpansion.ApplicationFor(document, hole.Name);+ if (hole.SourceSpan is null && application is null) continue;var schema = FirmamentSemanticSchemas.Get("Hole")!;- result.Add(new(schema.Id, $"{block.TargetSolid}.{hole.Name}", sourceDocument, revision, buildRevision, hole.SourceSpan,- schema.Fields.Where(field => field.AppliesTo(hole.Variant.ToString())).Select(field => ProjectHoleField(field, hole, source)).ToArray()));+ var declaration = application is null ? Original("Hole", hole.Name) : null;+ var boundHole = hole with { AuthoredFields = Fields(declaration, hole.AuthoredFields) };+ var fields = schema.Fields.Where(field => field.AppliesTo(hole.Variant.ToString())).Select(field => ProjectHoleField(field, boundHole, source));+ if (application is not null)+ fields = fields.Select(field => field with { Editable = false, ReadOnlyReason = "Generated by a Feature; edit the authored call arguments.",+ AuthoredValue = null, DeclarationSpan = null, ValueSpan = null, Origin = "Derived" });+ result.Add(new(schema.Id, $"{block.TargetSolid}.{hole.Name}", sourceDocument, revision, buildRevision,+ declaration?.Span ?? (application?.InvocationOrigin is { LocationNote: null } origin ? origin.SourceSpan : null), fields.ToArray())+ { FeatureApplicationIdentity = application?.ApplicationIdentity });}return result;}diff --git a/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentLanguageEdit.cs b/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentLanguageEdit.csindex 9199c096..4a63ed92 100644--- a/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentLanguageEdit.cs+++ b/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentLanguageEdit.cs@@ -6,7 +6,7 @@ namespace Aetheris.Kernel.Firmament.FirmamentV2;/// <summary>One structural edit, addressed by outline node ids (<see cref="FirmamentLanguageOutlineService"/>)./// <c>Kind</c> is <c>setField</c>, <c>removeField</c>, <c>insertDeclaration</c>, <c>removeDeclaration</c>,-/// <c>renameDeclaration</c>, <c>moveDeclaration</c>, <c>insertFeature</c> or <c>extractFeature</c>.+/// <c>renameDeclaration</c>, <c>moveDeclaration</c>, <c>insertFeature</c> <c>extractFeature</c> or <c>nameFeature</c>./// <c>removeDeclaration</c> and <c>moveDeclaration</c> also take a call node (a placed Feature).</summary>public sealed record FirmamentLanguageEditOperation(string Kind){@@ -22,6 +22,8 @@ public sealed record FirmamentLanguageEditOperation(string Kind)public string? Value { get; init; }/// <summary>renameDeclaration: the new name.</summary>public string? Name { get; init; }+ /// <summary>nameFeature: exact authored statement span of an anonymous call, when Node is absent.</summary>+ public FirmamentOutlineSpan? Span { get; init; }public FirmamentDeclarationSpec? Declaration { get; init; }/// <summary>insertDeclaration and insertFeature: one declaration as source text, used instead of/// <see cref="Declaration"/>. With <see cref="Name"/> its declared name is replaced.</summary>@@ -81,7 +83,9 @@ public static class FirmamentLanguageEditService"renameDeclaration" => RenameDeclaration(text, before, operation, document, warnings),"moveDeclaration" => MoveDeclaration(text, before, operation),"insertFeature" => InsertFeature(text, before, operation),- "extractFeature" => ExtractFeature(text, before, operation, document, warnings),+ "extractFeature" => ExtractFeature(text, before, operation),++ "nameFeature" => NameFeature(text, before, operation),_ => throw new FirmamentLanguageEditException("edit-unknown-operation", $"Unknown edit operation '{operation.Kind}'.")};var after = Parse(next);@@ -124,13 +128,13 @@ public static class FirmamentLanguageEditService// A placed call's fields are its named arguments: `MountHole(center: Point2(0mm, 0mm), diameter: 8mm)`.private static ArgumentSyntax[] Arguments((string Id, string? ParentId, StatementSyntax Statement, bool Call) placed, string name) =>- FirmamentLanguageOutlineService.BareCall(placed.Statement)!.Arguments.Where(a => a.Name?.Text == name).ToArray();+ FirmamentLanguageOutlineService.ApplicationCall(placed.Statement)!.Arguments.Where(a => a.Name?.Text == name).ToArray();private static string SetArgument(string text, (string Id, string? ParentId, StatementSyntax Statement, bool Call) placed, FirmamentLanguageEditOperation op){var name = RequireIdentifier(op.Field, "argument name");var value = RequireValue(op.Value, name);- var call = FirmamentLanguageOutlineService.BareCall(placed.Statement)!;+ var call = FirmamentLanguageOutlineService.ApplicationCall(placed.Statement)!;var matches = Arguments(placed, name);if (matches.Length > 1) throw new FirmamentLanguageEditException("edit-duplicate-field", $"{name} is passed {matches.Length} times; edit it in source.");if (matches.Length == 1) return Replace(text, matches[0].Value.Span.Start, matches[0].Value.Span.Length, value);@@ -141,7 +145,7 @@ public static class FirmamentLanguageEditServiceprivate static string RemoveArgument(string text, (string Id, string? ParentId, StatementSyntax Statement, bool Call) placed, FirmamentLanguageEditOperation op){var name = RequireIdentifier(op.Field, "argument name");- var call = FirmamentLanguageOutlineService.BareCall(placed.Statement)!;+ var call = FirmamentLanguageOutlineService.ApplicationCall(placed.Statement)!;var index = call.Arguments.ToList().FindIndex(a => a.Name?.Text == name);if (index < 0) throw new FirmamentLanguageEditException("edit-field-not-found", $"{placed.Id} does not pass {name}.");var argument = call.Arguments[index];@@ -162,7 +166,14 @@ public static class FirmamentLanguageEditServicevar indent = parent is null ? "" : ChildIndent(text, parent);var call = op.Declaration is null && IsCallSource(op.Source!);if (call && parent is null) throw new FirmamentLanguageEditException("edit-call-scope", "A call is placed inside a body, such as a Modify.");- var snippet = op.Declaration is { } spec ? Write(spec, indent, Unit(text)) : call ? indent + op.Source!.Trim() : FromSource(op.Source!, op.Name, indent);+ var callSource = call ? op.Source!.Trim() : null;+ if (call && op.Name is not null)+ {+ var recipe = (ReferenceSyntax)FirmamentLanguageOutlineService.ApplicationCall(Parse(callSource!).Document.Statements.Single())!.Target;+ var name = ApplicationName(recipe.Name.Text, op.Name, Siblings(FirmamentLanguageOutlineService.Declarations(parse), op.Parent).Select(d => d.Syntax));+ callSource = $"Feature {name} = {callSource}";+ }+ var snippet = op.Declaration is { } spec ? Write(spec, indent, Unit(text)) : call ? indent + callSource : FromSource(op.Source!, op.Name, indent);if (!call) CheckSnippet(snippet);var anchor = Anchor(siblings, op);int at;@@ -191,7 +202,8 @@ public static class FirmamentLanguageEditServiceif (!text.EndsWith(')')) return false;var parse = Parse("Probe Probe {\n" + text + "\n}");var body = parse.Document.Statements.OfType<DeclarationSyntax>().FirstOrDefault()?.Body?.Statements ?? [];- if (!parse.IsSuccess || body.Count != 1 || FirmamentLanguageOutlineService.BareCall(body[0]) is null)+ if (parse.IsSuccess && body.Count == 1 && body[0] is DeclarationSyntax) return false;+ if (!parse.IsSuccess || body.Count != 1 || body[0] is not ExpressionStatementSyntax || FirmamentLanguageOutlineService.ApplicationCall(body[0]) is null)throw new FirmamentLanguageEditException("edit-invalid-declaration", $"'{text}' is not one call.");return true;}@@ -208,6 +220,14 @@ public static class FirmamentLanguageEditServicevar parentId = declarations.First(d => d.Id == id).ParentId;var modify = Siblings(declarations, parentId).LastOrDefault(s => s.Syntax.Type.Name.Text is "Modify" or "modify" && s.Syntax.Name?.Text == bodyName.Text);+ var snippet = Parse(op.Source);+ var call = snippet.Document.Statements.Count == 1 ? snippet.Document.Statements[0] as ExpressionStatementSyntax : null;+ if (snippet.IsSuccess && call?.Value is CallSyntax { Target: ReferenceSyntax recipe })+ {+ var siblings = modify.Syntax is null ? [] : Siblings(declarations, modify.Id).Select(d => d.Syntax).ToArray();+ var name = ApplicationName(recipe.Name.Text, op.Name, siblings);+ op = op with { Source = $"Feature {name} = {op.Source.Trim().TrimEnd(';')}", Name = null };+ }if (modify.Syntax is not null)return InsertDeclaration(text, parse, new("insertDeclaration") { Parent = modify.Id, Source = op.Source, Name = op.Name });var (opened, modifyId) = InsertDeclaration(text, parse,@@ -224,8 +244,7 @@ public static class FirmamentLanguageEditService/// The Feature's body is written one field after another on one line; comments inside the/// original body are not carried over. The result's node is the call./// </summary>- private static (string, string?) ExtractFeature(string text, SyntaxParseResult parse, FirmamentLanguageEditOperation op,- string document, List<string> warnings)+ private static (string, string?) ExtractFeature(string text, SyntaxParseResult parse, FirmamentLanguageEditOperation op){var (id, declaration) = Find(parse, op.Node);var name = RequireIdentifier(op.Name, "Feature name");@@ -237,16 +256,6 @@ public static class FirmamentLanguageEditServicethrow new FirmamentLanguageEditException("edit-extract-shape", "Only a declaration written as fields becomes a Feature; this one has nested declarations or no body.");if (declarations.Any(d => d.ParentId is null && d.Syntax.Name?.Text == name))throw new FirmamentLanguageEditException("edit-name-taken", $"The document already declares {name}.");- // A placed call has no name: whatever names this declaration would stop resolving. That is- // a lexical use, or a name the outline cannot place but the compiler resolves by feature- // name, such as a Pmi Target.- var outline = FirmamentLanguageOutlineService.Outline(text, document, "edit");- var users = outline.Edges.Where(e => e.ToDocument is null && (e.To == id || e.To.StartsWith(id + "/", StringComparison.Ordinal))).Select(e => e.From)- .Concat(declaration.Name is { } own ? outline.Externals.Where(x => x.Name == own.Text).Select(x => x.From) : [])- .Distinct().ToArray();- if (users.Length > 0)- throw new FirmamentLanguageEditException("edit-extract-referenced",- $"{declaration.Name?.Text ?? id} is used by {string.Join(", ", users)}; a placed Feature has no name, so those uses would break.");var fields = body.Statements.Cast<FieldSyntax>().ToArray();var parameters = new List<(string Field, string Name, string Type, string Value)>();foreach (var requested in op.Parameters ?? [])@@ -265,7 +274,9 @@ public static class FirmamentLanguageEditServicevar feature = $"Feature {name}({string.Join(", ", parameters.Select(p => $"{p.Name}: {p.Type} = {p.Value}"))}) -> {kind} {{\n"+ $"{unit}return {kind} {{ {string.Join(" ", fields.Select(f => $"{f.Name.Text}: {ValueOf(f)}"))} }}\n}}";CheckSnippet(feature);- var call = $"{name}({string.Join(", ", parameters.Select(p => $"{p.Name}: {p.Value}"))})";+ var application = ApplicationName(name, declaration.Name?.Text,+ Siblings(declarations, entry.ParentId).Where(d => d.Id != id).Select(d => d.Syntax));+ var call = $"Feature {application} = {name}({string.Join(", ", parameters.Select(p => $"{p.Name}: {p.Value}"))})";// The declaration becomes the call, in place; then the Feature goes before the root that holds it.var end = declaration.Span.Start + declaration.Span.Length;@@ -277,8 +288,6 @@ public static class FirmamentLanguageEditServicevar next = Replace(placed, at, 0, feature + "\n\n");var callStart = declaration.Span.Start + feature.Length + 2;var created = FirmamentLanguageOutlineService.Statements(Parse(next)).FirstOrDefault(d => d.Call && d.Statement.Span.Start == callStart);- if (declaration.Name is { } lost)- warnings.Add($"{lost.Text} is now a placed {name}; the model identifies placements by their order, not by the name {lost.Text}.");return (next, created.Id);}@@ -291,11 +300,45 @@ public static class FirmamentLanguageEditService_ => null};+ private static (string, string?) NameFeature(string text, SyntaxParseResult parse, FirmamentLanguageEditOperation op)+ {+ var requestedSpan = op.Node is not null ? FindStatement(parse, op.Node).Statement.Span : op.Span is { } requested+ ? new FirmamentV2SourceSpan(requested.Start, requested.Length) : null;+ if (requestedSpan is not { } span)+ throw new FirmamentLanguageEditException("edit-input-required", "nameFeature requires an anonymous call node or exact authored statement span.");+ var statement = FirmamentSyntaxTraversal.Statements(parse.Document).OfType<ExpressionStatementSyntax>()+ .SingleOrDefault(s => s.Span.Start == span.Start && (s.Span.Length == span.Length || s.Value.Span.Length == span.Length));+ if (statement?.Value is not CallSyntax { Target: ReferenceSyntax recipe })+ throw new FirmamentLanguageEditException("edit-not-feature-call", "The span no longer identifies one anonymous Feature call; refresh the source revision.");+ var declarations = FirmamentLanguageOutlineService.Declarations(parse);+ var parent = declarations.Where(d => d.Syntax.Span.Start <= span.Start && d.Syntax.Span.Start + d.Syntax.Span.Length >= span.Start + span.Length)+ .OrderBy(d => d.Syntax.Span.Length).FirstOrDefault();+ var name = ApplicationName(recipe.Name.Text, op.Name, Siblings(declarations, parent.Id).Select(d => d.Syntax));+ var next = Replace(text, span.Start, 0, $"Feature {name} = ");+ return (next, FirmamentLanguageOutlineService.Declarations(Parse(next)).Single(d => d.Syntax.Span.Start == span.Start).Id);+ }++ private static string ApplicationName(string recipe, string? requested, IEnumerable<DeclarationSyntax> siblings)+ {+ var names = siblings.Where(d => d.Name is not null).Select(d => d.Name!.Text).ToHashSet(StringComparer.Ordinal);+ names.Add(recipe); // A result must not shadow the callable it invokes.+ if (requested is not null)+ {+ RequireIdentifier(requested, "Feature application name");+ if (names.Contains(requested)) throw new FirmamentLanguageEditException("edit-name-taken", $"A declaration here is already called {requested}.");+ return requested;+ }+ var stem = char.ToLowerInvariant(recipe[0]) + recipe[1..];+ var candidate = stem;+ for (var suffix = 2; names.Contains(candidate); suffix++) candidate = stem + suffix.ToString(System.Globalization.CultureInfo.InvariantCulture);+ return candidate;+ }+private static (string, string?) RemoveDeclaration(string text, SyntaxParseResult parse, FirmamentLanguageEditOperation op,string document, List<string> warnings){var placed = FindStatement(parse, op.Node);- if (placed.Call) return (RemoveStatement(text, placed.Statement.Span), null);+ if (placed.Call && placed.Statement is not DeclarationSyntax) return (RemoveStatement(text, placed.Statement.Span), null);var (id, declaration) = Find(parse, op.Node);var outline = FirmamentLanguageOutlineService.Outline(text, document, "edit");var inside = (string node) => node == id || node.StartsWith(id + "/", StringComparison.Ordinal);diff --git a/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentLanguageOutline.cs b/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentLanguageOutline.csindex e2e99a9a..3c2b22ab 100644--- a/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentLanguageOutline.cs+++ b/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentLanguageOutline.cs@@ -10,8 +10,8 @@ public sealed record FirmamentOutlineNode(string Id, string Kind, string? Varianbool Occurrence, string? ParentId, int Order, FirmamentOutlineSpan Span, FirmamentOutlineSpan? NameSpan, string? SchemaId,IReadOnlyList<string> Parameters, IReadOnlyList<FirmamentOutlineField> Fields, IReadOnlyList<string> Children){- /// <summary>A bare call written in a body (<c>MountHole(center: Point2(10mm, 0mm))</c>): <c>Kind</c> is the- /// callee and <c>Fields</c> are its arguments, positional ones named <c>#1</c>, <c>#2</c>.</summary>+ /// <summary>A bare or named Feature application: <c>Kind</c> is the callee and <c>Fields</c> are its arguments,+ /// positional ones named <c>#1</c>, <c>#2</c>. Named applications retain <c>Name</c> and its stable path.</summary>public bool Call { get; init; }/// <summary>The value a declaration is initialized with (<c>Static Thickness: Length = 8mm</c>), named <c>=</c>./// Absent for object initializers, whose fields are <c>Fields</c>.</summary>@@ -85,8 +85,8 @@ public static class FirmamentLanguageOutlineServicepublic Entry? Parent { get; init; }public required int Order { get; init; }public List<Entry> Children { get; } = [];- public string Kind => Syntax.Type.Name.Text;- public string? Name => Call is null ? Syntax.Name?.Text : null;+ public string Kind => Call?.Target is ReferenceSyntax recipe ? recipe.Name.Text : Syntax.Type.Name.Text;+ public string? Name => Syntax.Name?.Text;}public static FirmamentLanguageOutline Outline(string source, string document, string revision)@@ -144,7 +144,7 @@ public static class FirmamentLanguageOutlineService{var roots = new List<Entry>();Collect(parse.Document.Statements, null, roots);- return Flatten(roots).Where(e => e.Call is null).Select(e => (e.Id, e.Parent?.Id, e.Syntax)).ToArray();+ return Flatten(roots).Where(e => e.Statement is DeclarationSyntax).Select(e => (e.Id, e.Parent?.Id, e.Syntax)).ToArray();}/// <summary>Every outline node's statement, declarations and bare calls, under its outline id.</summary>@@ -155,9 +155,14 @@ public static class FirmamentLanguageOutlineServicereturn Flatten(roots).Select(e => (e.Id, e.Parent?.Id, e.Statement, e.Call is not null)).ToArray();}- /// <summary>A body statement that is just a call of a named Feature or function.</summary>- internal static CallSyntax? BareCall(StatementSyntax statement) =>- statement is ExpressionStatementSyntax { Value: CallSyntax { Target: ReferenceSyntax } call } ? call : null;+ /// <summary>The expression of a bare call or a named Feature application.</summary>+ internal static CallSyntax? ApplicationCall(StatementSyntax statement) =>+ statement switch+ {+ ExpressionStatementSyntax { Value: CallSyntax { Target: ReferenceSyntax } call } => call,+ DeclarationSyntax { Type.Name.Text: "Feature", ResultType: null, Initializer: CallSyntax { Target: ReferenceSyntax } call } => call,+ _ => null+ };internal static bool NameIsUse(DeclarationSyntax declaration) =>declaration.Type.Name.Text is "Modify" or "modify" or "Recognize" || declaration.Modifiers.Any(m => m.Name.Text == "Assert");@@ -171,8 +176,8 @@ public static class FirmamentLanguageOutlineServiceprivate static void Collect(IEnumerable<StatementSyntax> statements, Entry? parent, List<Entry> into){// Inside a body, a bare call is a node too: a reused Feature placed like any other feature.- var items = statements.SelectMany(s => DirectDeclarations(s).Select(d => ((StatementSyntax)d, d, (CallSyntax?)null))- .Concat(parent is null ? [] : DirectCalls(s).Select(c => (c, CallStandIn(BareCall(c)!), BareCall(c))))).ToList();+ var items = statements.SelectMany(s => DirectDeclarations(s).Select(d => ((StatementSyntax)d, d, ApplicationCall(d)))+ .Concat(parent is null ? [] : DirectCalls(s).Select(c => (c, CallStandIn(ApplicationCall(c)!), ApplicationCall(c))))).ToList();var segments = Segments(items.Select(i => i.Item2).ToList());for (var i = 0; i < items.Count; i++){@@ -187,7 +192,7 @@ public static class FirmamentLanguageOutlineServiceprivate static IEnumerable<StatementSyntax> DirectCalls(StatementSyntax statement) => statement switch{StatementBlockSyntax b => b.Body.Statements.SelectMany(DirectCalls),- _ when BareCall(statement) is not null => [statement],+ ExpressionStatementSyntax when ApplicationCall(statement) is not null => [statement],_ => []};@@ -226,7 +231,8 @@ public static class FirmamentLanguageOutlineServiceprivate static FirmamentOutlineNode Node(Entry entry, string source){if (entry.Call is { } call)- return new(entry.Id, entry.Kind, null, [], null, false, entry.Parent?.Id, entry.Order, Span(call.Span), null, null, [],+ return new(entry.Id, entry.Kind, null, [], entry.Name, false, entry.Parent?.Id, entry.Order, Span(entry.Statement.Span),+ entry.Syntax.Name is { } name ? Span(name.Span) : null, null, [],call.Arguments.Select((a, i) => new FirmamentOutlineField(a.Name?.Text ?? "#" + (i + 1), Text(source, a.Value.Span),Shape(a.Value), Span(a.Span), Span(a.Value.Span))).ToArray(), []) { Call = true };var d = entry.Syntax;@@ -323,7 +329,7 @@ public static class FirmamentLanguageOutlineServiceUses(f.Value, "field:" + f.Name.Text, vocab && f.Value is ReferenceSyntax, scoped);break;// A bare call in a body is its own node and resolves its own uses.- case ExpressionStatementSyntax e when scoped is null && BareCall(e) is not null: break;+ case ExpressionStatementSyntax e when scoped is null && ApplicationCall(e) is not null: break;case ExpressionStatementSyntax e: Uses(e.Value, "body", scoped: scoped); break;case ReturnSyntax r: Uses(r.Value, "body", scoped: scoped); break;case MappingSyntax m:diff --git a/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2Ast.cs b/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2Ast.csindex 6eaffaf1..d70cd5a0 100644--- a/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2Ast.cs+++ b/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2Ast.cs@@ -152,6 +152,12 @@ public sealed record FirmamentV2FeatureInvocation(string Feature, int Ordinal, s{public string GeneratedByFeature => Feature;public string? BindingScope { get; init; }+ /// <summary>Lexical application address. Named applications survive sibling reordering.</summary>+ public string? ApplicationIdentity { get; init; }+ public string IdentityKind { get; init; } = "Positional";+ public string? Pattern { get; init; }+ /// <summary>Concrete declaration names, or keyed semantic Pattern identities after lowering.</summary>+ public IReadOnlyList<string> GeneratedResults { get; init; } = [];public FirmamentV2ValueOrigin? DefinitionOrigin { get; init; }public FirmamentV2ValueOrigin? InvocationOrigin { get; init; }public IReadOnlyList<string> ExpansionChain { get; init; } = [];diff --git a/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2FeatureExpansion.cs b/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2FeatureExpansion.csindex 00518653..afb456d4 100644--- a/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2FeatureExpansion.cs+++ b/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2FeatureExpansion.cs@@ -164,12 +164,17 @@ internal static class FirmamentV2FeatureExpansionvar replacements = new Dictionary<StatementSyntax, IReadOnlyList<StatementSyntax>>(ReferenceEqualityComparer.Instance);IReadOnlyList<StatementSyntax> ExpandCall(Definition definition, CallSyntax call, FirmamentBindingScope callScope,- IReadOnlyList<Definition> stack, bool pattern, string? resultName = null)+ IReadOnlyList<Definition> stack, bool pattern, string? resultName = null, string? patternName = null,+ string? applicationIdentity = null, FirmamentV2ValueOrigin? applicationOrigin = null){if (stack.Contains(definition)) { Error(Recursion + ":" + string.Join(":", stack.Append(definition).Select(d => d.Syntax.Name!.Text)), "Recursive Feature invocation is not admitted.", call.Span, definition.Syntax); return []; }if (stack.Count >= MaximumDepth || ordinal >= MaximumInvocations){ Error(Prefix + "expansion-limit", $"Feature expansion is limited to depth {MaximumDepth} and {MaximumInvocations} invocations; no output was truncated.", call.Span, definition.Syntax); return []; }var invocationOrdinal = ordinal++;+ applicationOrigin ??= new(origins.Find(call.Span) is null ? "inline#pre-feature-expansion" : "inline", origins.Find(call.Span) ?? call.Span, definition.Syntax.Name!.Text,+ origins.Find(call.Span) is null ? "Invocation offsets refer to the AST input of Feature expansion; original include/Template mapping is not yet available." : null);+ applicationIdentity ??= callScope.Identity + "/" + (resultName ?? (patternName is not null ? definition.Syntax.Name!.Text+ : definition.Syntax.Name!.Text + "__" + invocationOrdinal.ToString(CultureInfo.InvariantCulture)));var environment = new Dictionary<string, ExpressionSyntax>(StringComparer.Ordinal);var bindings = new Dictionary<string, string>(StringComparer.Ordinal);var supplied = new Dictionary<string, ExpressionSyntax>(StringComparer.Ordinal); var position = 0;@@ -230,7 +235,7 @@ internal static class FirmamentV2FeatureExpansion}if (Failed()) return [];var prefix = resultName is null ? definition.Syntax.Name!.Text + "__" + invocationOrdinal.ToString(CultureInfo.InvariantCulture)- : stack.Count == 0 ? resultName : resultName + "__Call" + invocationOrdinal.ToString(CultureInfo.InvariantCulture);+ : stack.Count == 0 ? resultName : resultName + "__Call" + stack.Count.ToString(CultureInfo.InvariantCulture);var renames = definition.Construction.ToDictionary(d => d.Name!.Text, d => prefix + "__" + d.Name!.Text, StringComparer.Ordinal);var transform = new FirmamentSyntaxSubstitution(environment, renames);var output = definition.Construction.Select(transform.Statement).ToList(); var returned = transform.Expression(definition.Return.Value);@@ -238,21 +243,28 @@ internal static class FirmamentV2FeatureExpansion&& definition.Scope.Resolve("Feature", nestedName.Name.Text) is { } nestedSyntax && definitions.TryGetValue(nestedSyntax, out var nested)){if (!SameType(definition.ResultType, nested.ResultType)) Error(ReturnType + $":{definition.Syntax.Name!.Text}:expected-{definition.ResultType}:actual-{nested.ResultType}", "Delegated Feature result does not match the declared return type.", definition.Return.Span, definition.Syntax);- else output.AddRange(ExpandCall(nested, nestedCall, definition.Scope, stack.Append(definition).ToArray(), pattern, resultName));+ else output.AddRange(ExpandCall(nested, nestedCall, definition.Scope, stack.Append(definition).ToArray(), pattern, resultName, patternName, applicationIdentity, applicationOrigin));}else if (returned is ObjectSyntax { Type: not null, Name: null } obj && SameType(definition.ResultType, TypeName(obj.Type))){- var generated = resultName ?? (pattern ? PatternItemName(obj, definition.Syntax.Name!.Text, invocationOrdinal) : definition.Syntax.Name!.Text + "__" + invocationOrdinal.ToString(CultureInfo.InvariantCulture));+ // Pattern lowering owns the concrete names. Keep its iteration+ // placeholder even when the recipe application has a source name.+ var generated = pattern ? PatternItemName(obj, definition.Syntax.Name!.Text, invocationOrdinal)+ : resultName ?? definition.Syntax.Name!.Text + "__" + invocationOrdinal.ToString(CultureInfo.InvariantCulture);output.Add(new DeclarationSyntax(ToType(obj.Type), new(generated, call.Span), [], [], null, null, [], null, obj.Body, false, definition.Return.Span));}else Error(ReturnType + $":{definition.Syntax.Name!.Text}:expected-{definition.ResultType}", $"Feature '{definition.Syntax.Name!.Text}' must return {definition.ResultType} construction or a Feature with that result type.", definition.Return.Span, definition.Syntax);invocations.Add(new(definition.Syntax.Name!.Text, invocationOrdinal, definition.ResultType, bindings.ToImmutableDictionary(StringComparer.Ordinal), call.Span, definition.ResultType, "ExpandedBeforeFeatureAir", resultName){BindingScope = definition.Scope.Identity,+ ApplicationIdentity = applicationIdentity,+ IdentityKind = patternName is not null ? "PatternRecipe" : resultName is null ? "Positional" : "Named",+ Pattern = patternName,+ GeneratedResults = output.TakeLast(1).OfType<DeclarationSyntax>().Where(d => d.Type.Name.Text == definition.ResultType.Split('<')[0])+ .Select(d => d.Name!.Text).ToArray(),DefinitionOrigin = new(OriginalDefinition(definition.Syntax) is null ? "inline#pre-feature-expansion" : "inline", OriginalDefinition(definition.Syntax) ?? definition.Syntax.Span, definition.Syntax.Name.Text,OriginalDefinition(definition.Syntax) is null ? "Definition is in expanded input; original-file mapping unavailable." : null),- InvocationOrigin = new(origins.Find(call.Span) is null ? "inline#pre-feature-expansion" : "inline", origins.Find(call.Span) ?? call.Span, definition.Syntax.Name.Text,- origins.Find(call.Span) is null ? "Invocation offsets refer to the AST input of Feature expansion; original include/Template mapping is not yet available." : null),+ InvocationOrigin = applicationOrigin,ExpansionChain = stack.Select(d => d.Syntax.Name!.Text).Append(definition.Syntax.Name.Text).ToArray()});// Account only this invocation's own nodes; delegated nodes were already@@ -266,7 +278,7 @@ internal static class FirmamentV2FeatureExpansion}return output;}- void Visit(IReadOnlyList<StatementSyntax> statements, FirmamentBindingScope scope, bool pattern)+ void Visit(IReadOnlyList<StatementSyntax> statements, FirmamentBindingScope scope, bool pattern, string? patternName = null){foreach (var statement in statements){@@ -280,7 +292,7 @@ internal static class FirmamentV2FeatureExpansion{ Error(UnsupportedBody + ":invocation-header", "A named invocation is Feature name = Recipe(arguments), without parameter, type, placement or body clauses.", named.Span); continue; }if (scope.Resolve("Feature", target.Name.Text) is { } declaration && definitions.TryGetValue(declaration, out var definition)){- var nodes = ExpandCall(definition, call, scope, [], pattern, (statement as DeclarationSyntax)?.Name?.Text);+ var nodes = ExpandCall(definition, call, scope, [], pattern, (statement as DeclarationSyntax)?.Name?.Text, patternName);changes.Add((statement.Span, FirmamentSyntaxWriter.Statements(nodes))); replacements[statement] = nodes;}else Error(Unknown + ":" + target.Name.Text, $"Feature '{target.Name.Text}' is not visible in {scope.Identity}.", call.Span);@@ -288,8 +300,9 @@ internal static class FirmamentV2FeatureExpansion// Static mappings contain values (Point2 constructors, for example),// not statements invoking a Feature. Their owner binds those values.else if (statement is DeclarationSyntax { Type.Name.Text: "Static" or "Table" or "Record" or "Enum" }) continue;- else if (statement is DeclarationSyntax { Body: not null } owner) Visit(owner.Body.Statements, bodies[owner.Body], pattern || owner.Type.Name.Text == "Pattern");- else if (statement is MappingSyntax mapping) Visit([mapping.Value], scope, true);+ else if (statement is DeclarationSyntax { Body: not null } owner) Visit(owner.Body.Statements, bodies[owner.Body], pattern || owner.Type.Name.Text == "Pattern",+ owner.Type.Name.Text == "Pattern" ? owner.Name?.Text : patternName);+ else if (statement is MappingSyntax mapping) Visit([mapping.Value], scope, true, patternName);}}Visit(parsed.Document.Statements, root, false);@@ -354,6 +367,14 @@ internal static class FirmamentV2FeatureExpansion}return e;}+ internal static FirmamentV2FeatureInvocation? ApplicationFor(FirmamentV2Document document, string name)+ {+ var matches = document.FeatureInvocations?.Where(i => i.GeneratedResults.Any(result => result == name+ || i.Pattern is not null && (result.Replace('.', '_') == name || result.EndsWith("::" + name, StringComparison.Ordinal))))+ .DistinctBy(i => i.ApplicationIdentity).ToArray() ?? [];+ return matches.Length == 1 ? matches[0] : null;+ }+private static string PatternItemName(ObjectSyntax obj, string feature, int ordinal) => obj.Body.Statements.OfType<FieldSyntax>().FirstOrDefault(f => FirmamentSyntaxFields.SameField(f.Name.Text, "Center"))?.Value is ReferenceSyntax r ? r.Name.Text : feature + "__" + ordinal.ToString(CultureInfo.InvariantCulture);diff --git a/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2Parser.cs b/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2Parser.csindex 800c38c7..c5a4b812 100644--- a/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2Parser.cs+++ b/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2Parser.cs@@ -671,19 +671,48 @@ public static partial class FirmamentV2Parserprivate static FirmamentV2ParseResult WithFeatureMetadata(FirmamentV2ParseResult result,FirmamentV2FeatureExpansion.Result expansion,- FirmamentCompileTimeValues? values = null) =>- result.Document is null- ? result- : result with+ FirmamentCompileTimeValues? values = null)+ {+ if (result.Document is null) return result;+ FirmamentV2FeatureInvocation BindResults(FirmamentV2FeatureInvocation invocation)+ {+ if (invocation.Pattern is null) return invocation;+ var patterns = result.Document.StaticAuthoring?.Patterns?.Where(p => p.Name == invocation.Pattern).ToArray() ?? [];+ if (patterns.Length == 1)+ return invocation with+ {+ GeneratedResults = patterns[0].GeneratedIds,+ IdentityKind = patterns[0].Associations is { Count: > 0 } ? "KeyedPattern" : "PositionalPattern"+ };+ var points = result.Document.ConceptIr?.PatternExpansions?+ .Where(p => p.Pattern.EndsWith("::" + invocation.Pattern, StringComparison.Ordinal)).ToArray() ?? [];+ return points.Length == 1+ ? invocation with { GeneratedResults = points[0].GeneratedDeclarations, IdentityKind = "PositionalPattern" }+ : invocation;+ }+ var document = result.Document with+ {+ FeatureDefinitions = expansion.Definitions,+ FeatureInvocations = expansion.Invocations.Select(BindResults).ToArray(),+ FeatureExpansion = expansion.Metrics,+ DataBindings = values?.DataBindings ?? []+ };+ // The geometry/source-map owner must receive authored call spans, never+ // offsets into the expanded text. Generated fields are not source edits.+ document = document with { ModifyBlocks = document.ModifyBlocks?.Select(block => block with+ {+ SemanticHoles = block.SemanticHoles.Select(hole =>{- Document = result.Document with+ var application = FirmamentV2FeatureExpansion.ApplicationFor(document, hole.Name);+ return application is null ? hole : hole with{- FeatureDefinitions = expansion.Definitions,- FeatureInvocations = expansion.Invocations,- FeatureExpansion = expansion.Metrics,- DataBindings = values?.DataBindings ?? []- }- };+ SourceSpan = application.InvocationOrigin is { LocationNote: null } origin ? origin.SourceSpan : null,+ AuthoredFields = null+ };+ }).ToArray()+ }).ToArray() };+ return result with { Document = document };+ }private static FirmamentV2ParseResult WithPolygonMetadata(FirmamentV2ParseResult result,diff --git a/Aetheris.Web.Runtime/Program.cs b/Aetheris.Web.Runtime/Program.csindex 6d0d5796..b89f98a4 100644--- a/Aetheris.Web.Runtime/Program.cs+++ b/Aetheris.Web.Runtime/Program.cs@@ -365,6 +365,7 @@ public static partial class Program{version = FirmamentFieldProjector.Version,constructId = projection.ConstructId.Value, semanticId = projection.SemanticId,+ projection.FeatureApplicationIdentity,sourceRevision = projection.SourceRevision, buildRevision = projection.BuildRevision,source = projection.ConstructSpan is { } span ? SourceRefAt(projection.SourceDocument, _source, span.Start, span.Length) : null,outputs = FirmamentSemanticSchemas.Get(projection.ConstructId.Value)!.Outputs.Select(item => new@@ -520,7 +521,8 @@ public static partial class Program}semanticConstruct ??= projections.FirstOrDefault(item => item.SemanticId == entityId)?.ConstructId.Value;var featureSources = (build.Value.Features ?? []).ToDictionary(feature => feature.FeatureId,- feature => CompilerSource(feature.FeatureId), StringComparer.Ordinal);+ feature => projections.FirstOrDefault(p => p.SemanticId == feature.FeatureId)?.ConstructSpan is { } span+ ? SourceRefAt(_sourceName, effective, span.Start, span.Length) : CompilerSource(feature.FeatureId), StringComparer.Ordinal);mappingPhase.Dispose();var meshPhase = BuildPerfTrace.Phase("web.mesh-build");var mesh = WebMeshBuilder.Build(Name, definitionId, entityId, displayBody,diff --git a/Aetheris.Web.Runtime/sdk/README.md b/Aetheris.Web.Runtime/sdk/README.mdindex 4493e949..71a10175 100644--- a/Aetheris.Web.Runtime/sdk/README.md+++ b/Aetheris.Web.Runtime/sdk/README.md@@ -85,14 +85,32 @@ Inside a body, a bare call such as `MountHole(center: Point2(10mm, 0mm))` is anoutline node with `call: true`: its `kind` is the callee and its `fields` are thearguments, so `setField`/`removeField` edit arguments and `moveDeclaration`/`removeDeclaration` place and remove it like a feature; `insertFeature` also takes-a call as `source`. Value declarations carry `value` (the initializer, for a+a call as `source`. Named applications also have `call: true`, their declared+`name`, and argument fields, with outline ids that survive reordering.+Value declarations carry `value` (the initializer, for aparameter sheet) and `annotation`; Features carry `signature`.`extractFeature` (`node`, `name`, `parameters`) turns a feature into adocument-level `Feature` whose chosen fields become typed parameters defaulting totheir current values, and leaves a call with those values in its place: the-model builds the same geometry. A placed call has no name, so extraction is-refused (`edit-extract-referenced`) while anything names the declaration,-including a Pmi `Target`, and otherwise warns that the name is not kept.+model builds the same geometry. Extraction writes a named application using the+original declaration name, so+existing references, including a Pmi `Target`, continue to resolve.++`insertFeature` also accepts a bare recipe call as `source`, for example+`MountHole(center: Layout.leftMount)`. It writes `Feature name = Recipe(...)`+into the source. Pass a meaningful `name`, or omit it to allocate an unused+camelCase name in that Modify; existing application names are preserved.+`nameFeature` takes an anonymous call `node` (or its exact authored `span`) and an optional+`name`, and promotes it to the same named form. Use spans from the current source+revision. Duplicate names and spans that do not identify a call reject. Update+authored selectors that referenced its old ordinal-generated name after promotion.+The returned `nodes` contains the resulting named outline node.++Construct projections for Feature-generated holes expose+`featureApplicationIdentity`, navigate to the original call where provenance is+available, and keep expanded fields read-only. Their ordinary admitted output+selectors remain available. This does not confer persistent identity on arbitrary+faces after topology changes.`cad.language.palette()` lists what a visual editor can add(`firmament-palette/1`): bodies (`placement: 'model'`) and features on a bodydiff --git a/Aetheris.Web.Runtime/sdk/src/index.d.ts b/Aetheris.Web.Runtime/sdk/src/index.d.tsindex b47b4be4..d7a7ce49 100644--- a/Aetheris.Web.Runtime/sdk/src/index.d.ts+++ b/Aetheris.Web.Runtime/sdk/src/index.d.ts@@ -52,7 +52,8 @@ export type LanguageEditOperation =| { readonly kind: 'renameDeclaration'; readonly node: string; readonly name: string }| { readonly kind: 'moveDeclaration'; readonly node: string; readonly after?: string; readonly first?: boolean }| { readonly kind: 'insertFeature'; readonly node: string; readonly source: string; readonly name?: string }- | { readonly kind: 'extractFeature'; readonly node: string; readonly name: string; readonly parameters?: readonly string[] };+ | { readonly kind: 'extractFeature'; readonly node: string; readonly name: string; readonly parameters?: readonly string[] }+ | { readonly kind: 'nameFeature'; readonly node?: string; readonly span?: OutlineSpan; readonly name?: string };/** The edited source and the single replacement `[start, start + length)` → `replacement` that produces it from the original. `nodes` holds the outline id each operation left behind (created, renamed or edited), in order; removals add none. */export interface LanguageEdit { readonly document: string; readonly revision: string; readonly text: string; readonly changed: boolean; readonly edit: { readonly start: number; readonly length: number; readonly replacement: string }; readonly nodes: readonly string[]; readonly warnings: readonly string[] }/** Something a visual editor can add. `placement` `model` inserts with `insertDeclaration`; `feature` with `insertFeature` on a body. `source` declares `nameStem`; pass a unique `name` with the insert. Every item is proven to build. */@@ -66,7 +67,7 @@ export interface SemanticConstructSchema { readonly id: string; readonly name: sexport interface SemanticSchema { readonly version: 'firmament-semantic-schema/1'; readonly projectionVersion: 'firmament-field-projection/1'; readonly constructs: readonly SemanticConstructSchema[] }export interface ProjectedValue { readonly valueKind: string; readonly text: string; readonly number?: number | null; readonly components?: readonly number[] | null; readonly unit?: string | null }export interface FieldProjection { readonly fieldId: string; readonly name: string; readonly kind: string; readonly unit: string; readonly effectiveValue: ProjectedValue | null; readonly authoredValue: string | null; readonly origin: 'Authored' | 'Defaulted' | 'Derived' | 'Inherited' | 'Unavailable'; readonly declaration: SourceReference | null; readonly source: SourceReference | null; readonly editable: boolean; readonly readOnlyReason: string | null }-export interface ConstructProjection { readonly version: 'firmament-field-projection/1'; readonly constructId: string; readonly semanticId: string; readonly sourceRevision: string; readonly buildRevision: number; readonly source: SourceReference | null; readonly fields: readonly FieldProjection[]; readonly outputs: readonly SemanticOutputSchema[] }+export interface ConstructProjection { readonly version: 'firmament-field-projection/1'; readonly constructId: string; readonly semanticId: string; readonly featureApplicationIdentity?: string | null; readonly sourceRevision: string; readonly buildRevision: number; readonly source: SourceReference | null; readonly fields: readonly FieldProjection[]; readonly outputs: readonly SemanticOutputSchema[] }export interface FieldRewrite { readonly source: string; readonly sourceRevision: string; readonly replaced: SourceReference; readonly replacement: string }export interface SelectorCandidate { readonly selector: string; readonly kind: string; readonly semanticKey: string | null; readonly outputRole: string | null; readonly source: SourceReference; readonly qualification: SourceAddressability; readonly buildRevision: number }export interface AetherisOptions { readonly worker?: boolean; readonly wasmUrl?: string | URL; readonly diagnostics?: (diagnostics: readonly Diagnostic[]) => void }diff --git a/docs/public/firmament/syntax.md b/docs/public/firmament/syntax.mdindex 943033ec..c3ff2151 100644--- a/docs/public/firmament/syntax.md+++ b/docs/public/firmament/syntax.md@@ -631,6 +631,47 @@ These are context-specific forms, not interchangeable spellings of one loop.A named Feature invocation may use `Feature result = Recipe(...)`; it differsfrom a Feature definition and from a Pattern.+Name editable applications explicitly:++```firmament+Modify stock {+ Feature leftBore = MountHole(center: Layout.leftMount)+ Feature rightBore = MountHole(center: Layout.rightMount)+}+```++Here `MountHole` is the recipe, `leftBore` is the application identity, and+`Layout.leftMount` is the Concept datum that supplies its location. Moving the+datum moves the bore without renaming it. Several operations can share a datum,+so a placement reference does not automatically name its consumers. Reordering+named applications preserves their identities; operation order still determines+construction dependencies. Duplicate names in the consuming scope are errors.++Use the named result with selectors its return kind already supports, such as+`face(leftBore.Wall)` for an admitted Hole wall. Naming a Feature does not grant+new geometry capabilities or guarantee that every face survives a topology edit.+Delegated recipes retain the application's identity and original call provenance;+private construction names do not depend on unrelated calls.++Keyed `Set` Patterns retain their Pattern and element keys when entries move,+are inserted, or are removed. The current mapping emits one result per key;+the Pattern supplies the repeated role and a named recipe result identifies that+role at the call site. Ordered arrays and generated Grid points remain positional.+Inspection reports `applicationIdentity`, `identityKind`, `pattern`, and+`generatedResults`; keyed results reflect the identities produced by Pattern+lowering, rather than the pre-expansion recipe's temporary name.++Anonymous calls remain supported. Their generated `__0`, `__1`, etc. names are+positional and should not be treated as durable public names. Give an application+a source name before attaching persistent editing state or external references.+Editor extraction preserves the original declaration name when replacing it with+a Feature application, including references from PMI. Named call nodes expose+their arguments for structural edits; the name stays unchanged when those values+or their Concept datums change.+After naming an existing anonymous call, update any authored selectors that used+its old generated name. Generated fields are read-only projections: edit the+recipe arguments or owning Concept datum instead of rewriting expanded fields.+In the admitted Set and semantic point Patterns, an iteration symbol substitutesvalue references. It does not rename field labels, declaration names, stringcontents or a similarly spelled identifier. Generated instance identities stilldiff --git a/fixtures/Regression/FeatureIdentity/keyed-mounts.firmament b/fixtures/Regression/FeatureIdentity/keyed-mounts.firmamentnew file mode 100644index 00000000..6fd16dce--- /dev/null+++ b/fixtures/Regression/FeatureIdentity/keyed-mounts.firmament@@ -0,0 +1,16 @@+Model MountingPlate {+ units: mm+ Feature MountHole(center: Point2) -> Hole<Shaft> {+ return Hole<Shaft> { on: +Z center: center diameter: 6mm end: ThroughAll }+ }+ Static sites: Set<Point2> {+ left => Point2(-12mm, 0mm)+ right => Point2(12mm, 0mm)+ }+ Box stock { size: [50mm, 30mm, 8mm] }+ Modify stock {+ Pattern mounts over sites {+ site => Feature bore = MountHole(center: site)+ }+ }+}diff --git a/fixtures/Regression/FeatureIdentity/named-mounts.firmament b/fixtures/Regression/FeatureIdentity/named-mounts.firmamentnew file mode 100644index 00000000..ef1726f2--- /dev/null+++ b/fixtures/Regression/FeatureIdentity/named-mounts.firmament@@ -0,0 +1,18 @@+Model MountingPlate {+ units: mm+ Concept Struct Layout on XY {+ Point2 leftMount { position: [-12mm, 0mm] }+ Point2 rightMount { position: [12mm, 0mm] }+ }+ Feature MountHole(center: Point2) -> Hole<Shaft> {+ return Hole<Shaft> { on: +Z center: center diameter: 6mm end: ThroughAll }+ }+ Box stock { size: [50mm, 30mm, 8mm] }+ Modify stock {+ Feature leftBore = MountHole(center: Layout.leftMount)+ Feature rightBore = MountHole(center: Layout.rightMount)+ }+ Pmi {+ HoleDiameter LeftSize { target: face(leftBore.Wall) value: 6mm }+ }+}