Next Gen STEP AP242 Native-ish BREP Geometric Modeling Kernel
Extrude cuts its Modify features; unsupported ones reject where they are written
Claude1547048f6fea
diff --git a/Aetheris.Kernel.Firmament.Tests/FirmamentSemanticSchemaTests.cs b/Aetheris.Kernel.Firmament.Tests/FirmamentSemanticSchemaTests.csindex 795da549..41e17f6a 100644--- a/Aetheris.Kernel.Firmament.Tests/FirmamentSemanticSchemaTests.cs+++ b/Aetheris.Kernel.Firmament.Tests/FirmamentSemanticSchemaTests.cs@@ -86,14 +86,30 @@ public sealed class FirmamentSemanticSchemaTests}[Fact]- public void ModifyFeaturesOnAPlainExtrude_RejectInsteadOfVanishing()+ public void ModifyFeaturesOnAPlainExtrude_AreCutLikeCompose(){- var source = "Model M { units: mm Profile P = Rect2 { center: [0mm, 0mm]; size: [50mm, 40mm] } Extrude Plate { profile: P; from: 0mm; to: 8mm } "- + "Modify Plate { Hole<Shaft> H { on: +Z center: Point2(0mm, 0mm) diameter: 6mm end: ThroughAll } } }";+ var source = "Model M { units: mm Profile P = RoundedRect2 { center: [0mm, 0mm]; size: [50mm, 40mm]; radius: 3mm } Extrude Plate { profile: P; from: 0mm; to: 8mm } "+ + "Modify Plate { Hole<Shaft> A { on: +Z center: Point2(19mm, 14mm) diameter: 5.5mm end: ThroughAll } Hole<Shaft> B { on: +Z center: Point2(-19mm, -14mm) diameter: 5.5mm end: ThroughAll } } }";+ var build = FirmamentBuildAndExport.CompileSource(source);+ Assert.True(build.IsSuccess, string.Join(';', build.Diagnostics.Select(d => d.Message)));+ var compose = FirmamentBuildAndExport.CompileSource(source.Replace("Extrude Plate { profile: P; from: 0mm; to: 8mm }", "Compose Plate { Base Plate { profile: P; from: 0mm; to: 8mm } }"));+ Assert.True(compose.IsSuccess);+ // Same prism, same cuts: both spellings report the same drilled features.+ static string Holes(FirmamentStepExportResult r) => string.Join(';', r.Features!.Select(f => $"{f.Name}:{f.Diameter}:{f.LocalU}:{f.LocalV}"));+ Assert.Equal("A:5.5:19:14;B:5.5:-19:-14", Holes(build.Value));+ Assert.Equal(Holes(compose.Value), Holes(build.Value));+ }++ [Fact]+ public void UnsupportedModifyFeaturesOnProfileBodies_RejectAtTheirDeclaration()+ {+ var source = "Model M {\n units: mm\n Profile P = Rect2 { center: [0mm, 0mm]; size: [60mm, 40mm] }\n Extrude Plate { profile: P; from: 0mm; to: 4mm }\n"+ + " Modify Plate {\n Perforation Vent { on: +Z; diameter: 4mm; layout: Grid; pitch: 8mm; margin: 6mm }\n }\n}";var build = FirmamentBuildAndExport.CompileSource(source);Assert.False(build.IsSuccess);- var diagnostic = Assert.Single(build.Diagnostics, d => d.Message.Contains("Compose Plate", StringComparison.Ordinal));- Assert.Contains("Hole H would not be cut", diagnostic.Message, StringComparison.Ordinal);+ var diagnostic = Assert.Single(build.Diagnostics.Select(d => FirmamentBuildAdmissionValidation.Present(d, "plate.firmament", source)), d => d.Code == Aetheris.Kernel.Firmament.Materializer.PrismaticProfileCompositionParser.ComposeModifyFeatureUnsupported);+ Assert.Equal(6, diagnostic.Line);+ Assert.StartsWith("Perforation is not supported on a Profile-based body", diagnostic.Message, StringComparison.Ordinal);}[Fact]diff --git a/Aetheris.Kernel.Firmament/FirmamentBuildAndExport.cs b/Aetheris.Kernel.Firmament/FirmamentBuildAndExport.csindex ddf3bbac..8365ff92 100644--- a/Aetheris.Kernel.Firmament/FirmamentBuildAndExport.cs+++ b/Aetheris.Kernel.Firmament/FirmamentBuildAndExport.cs@@ -769,6 +769,8 @@ public static partial class FirmamentBuildAndExport// parse-failed is a result status, used only when the producer supplied no explanation.var errors = parse.Diagnostics.Where(FirmamentV2Parser.IsFatalDiagnosticCode).Where(code => code != "firmament-v2-parse-failed" && !syntaxCodes.Contains(code)).Concat(parse.SyntaxDiagnostics.Select(d => d.Code + ": " + d.Message)).Distinct(StringComparer.Ordinal).ToArray();+ // A bare code is redundant beside the same code with its parameters and explanation.+ errors = errors.Where(code => code.Contains(':') || !errors.Any(other => other.StartsWith(code + ":", StringComparison.Ordinal))).ToArray();if (errors.Length == 0) errors = ["firmament-v2-parse-failed"];return KernelResult<FirmamentStepExportResult>.Failure(errors.Select(code => new KernelDiagnostic(KernelDiagnosticCode.ValidationFailed, KernelDiagnosticSeverity.Error, code, "FirmamentV2.Parse")).ToArray());@@ -1177,7 +1179,7 @@ public static partial class FirmamentBuildAndExportif (emitted.Body is null || emitted.Correspondence is null) return Fail("MissingCorrespondenceEvidence");var composedCurves = stack.Slabs.MaxBy(s => s.To)!.Region.Outer.Loops.Single().Segments.Select(segment => segment.Geometry).ToArray();if (!IsAdmittedPrimitiveBoundary(composedCurves))- return Fail($"{EdgeFinishProfileComposeBoundaryUnsupported}:host={stack.Feature.Name}:construction=Compose:face=+Z:target=Boundary:supported=primitive-box-or-explicit-semantic-chain:Profile/Compose polygon-boundary materialization is not implemented.");+ return Fail($"{EdgeFinishProfileComposeBoundaryUnsupported}:host={stack.Feature.Name}:construction=Compose:face=+Z:target=Boundary: EdgeFinish on a Profile-based body is supported on four-sided boundaries; this boundary has curved or extra segments. Use Box stock for a rounded or chamfered rim, or shape the corners in the Profile itself.");var selections = SemanticSelectionSourceParser.Parse(source, parsed.Profiles.Values.First(), stack.Feature.Name, out var diagnostics);if (diagnostics.Count != 0 || selections.Count != 1) return Fail(diagnostics.FirstOrDefault() ?? "SemanticSourceNotFound");var selection = SemanticTopologySelectionResolver.Resolve(emitted.Body, emitted.Correspondence, selections[0]);@@ -1291,7 +1293,7 @@ public static partial class FirmamentBuildAndExport}if (emitted.Body is null || emitted.Correspondence is null) return Fail("NoMaterializedDescendants");if (!IsAdmittedPrimitiveBoundary(profile.Loops.Single().Segments.Select(segment => segment.Geometry).ToArray()))- return Fail($"{EdgeFinishProfileComposeBoundaryUnsupported}:host={profile.Name}:construction=Profile:face=+Z:target=Boundary:supported=primitive-box-or-explicit-semantic-chain:Profile/Compose polygon-boundary materialization is not implemented.");+ return Fail($"{EdgeFinishProfileComposeBoundaryUnsupported}:host={profile.Name}:construction=Profile:face=+Z:target=Boundary: EdgeFinish on a Profile-based body is supported on four-sided boundaries; this boundary has curved or extra segments. Use Box stock for a rounded or chamfered rim, or shape the corners in the Profile itself.");var selections = SemanticSelectionSourceParser.Parse(source, profile, profile.Name, out var selectionDiagnostics);if (selectionDiagnostics.Count > 0 || selections.Count != 1) return Fail(selectionDiagnostics.FirstOrDefault() ?? "SemanticSourceNotFound");var selection = SemanticTopologySelectionResolver.Resolve(emitted.Body, emitted.Correspondence, selections[0]);diff --git a/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentBuildAdmissionValidation.cs b/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentBuildAdmissionValidation.csindex 4d92813c..4860b4e1 100644--- a/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentBuildAdmissionValidation.cs+++ b/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentBuildAdmissionValidation.cs@@ -73,6 +73,33 @@ public static class FirmamentBuildAdmissionValidation}, source, sourceFile) with { Code = code, Message = FirmamentInterop.FirmamentV2DiagnosticAdapter.MessageFor(diagnostic.Message) };}+ /// <summary>+ /// Producer codes name what they reject as <c>code:Kind:Name</c> or <c>key=Name</c> parameters. When those+ /// parameters name exactly one declaration in the source, that declaration is the diagnostic's location.+ /// </summary>+ internal static FirmamentV2SourceSpan? NamedDeclaration(string code, string source)+ {+ var parameters = code.Split(": ", 2)[0].Split(':').Skip(1)+ .Select(part => part.Contains('=') ? part[(part.IndexOf('=') + 1)..] : part).ToArray();+ if (parameters.Length == 0) return null;+ var declarations = Syntax.FirmamentSyntaxTraversal.Declarations(Syntax.FirmamentSyntaxParser.Parse(source).Document)+ .Where(d => d.Name is not null).ToArray();+ // A Kind:Name pair is the most specific; otherwise the first parameter that names one declaration.+ for (var i = 0; i + 1 < parameters.Length; i++)+ {+ var pair = declarations.Where(d => d.Type.Name.Text == parameters[i] && d.Name!.Text == parameters[i + 1]).ToArray();+ if (pair.Length == 1) return pair[0].Name!.Span;+ }+ foreach (var parameter in parameters)+ {+ // "Modify Plate" repeats its target's name; the target is the declaration meant.+ var named = declarations.Where(d => d.Name!.Text == parameter).ToArray();+ if (named.Length > 1) named = named.Where(d => d.Type.Name.Text != "Modify").ToArray();+ if (named.Length == 1) return named[0].Name!.Span;+ }+ return null;+ }+public static FirmamentV2ValidationDiagnostic Locate(FirmamentV2ValidationDiagnostic diagnostic, string? source, string sourceFile){@@ -96,6 +123,8 @@ public static class FirmamentBuildAdmissionValidation? Syntax.FirmamentSyntaxFields.SameField(token.Text, subject) && index + 1 < tokens.Length && tokens[index + 1].Text == ":": token.Text == subject)).ToArray();var exact = matches.Length == 1;+ if (!exact && NamedDeclaration(diagnostic.Code, source) is { } named)+ return Locate(diagnostic with { SourceSpan = named, LocationNote = null }, source, sourceFile);var token = exact ? matches[0] : tokens.FirstOrDefault(token => token.Shape == "identifier"&& token.Text is "Model" or "model" or "Struct" or "Concept" or "Profile" or "Template" or "Assembly" or "Scene");if (token is null) return diagnostic with { SourceFile = sourceFile, LocationNote = "The producer supplied no original-source location." };diff --git a/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentInterop/FirmamentV2DiagnosticAdapter.cs b/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentInterop/FirmamentV2DiagnosticAdapter.csindex a5147f95..1136f951 100644--- a/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentInterop/FirmamentV2DiagnosticAdapter.cs+++ b/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentInterop/FirmamentV2DiagnosticAdapter.cs@@ -84,6 +84,9 @@ public static class FirmamentV2DiagnosticAdapter=> $"Unknown field '{diagnosticCode.Split(':')[^1]}' in {diagnosticCode.Split(':')[1]}. Check this construct's documented fields.",_ when diagnosticCode.StartsWith(FirmamentV2Parser.CanonicalDeclarationUnknown + ":", StringComparison.Ordinal)=> $"Unknown statement '{diagnosticCode.Split(':')[^1]}'{(diagnosticCode.Split(':').Length > 2 ? " in " + diagnosticCode.Split(':')[1] : "")}. Use an admitted construct in this context.",+ // Producers write "code[:parameters]: explanation"; the explanation is the message.+ _ when diagnosticCode.IndexOf(": ", StringComparison.Ordinal) is > 0 and var split && !diagnosticCode[..split].Any(char.IsWhiteSpace)+ => diagnosticCode[(split + 2)..],_ => diagnosticCode};}diff --git a/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2Parser.cs b/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2Parser.csindex 567ae6ec..9a9f5c8d 100644--- a/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2Parser.cs+++ b/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2Parser.cs@@ -77,7 +77,6 @@ public static partial class FirmamentV2Parserpublic const string AssertVolumeToleranceNegative = "firmament-v2-assert-volume-tolerance-negative";public const string CanonicalConstructNotYetSupported = "firmament-v2-canonical-construct-not-yet-supported";public const string EdgeFinishProfileComposeBoundaryUnsupported = "EdgeFinishProfileComposeBoundaryUnsupported";- public const string ExtrudeModifyFeatureUnsupported = "firmament-v2-extrude-modify-feature-unsupported";public const string CanonicalFieldUnknown = "firmament-v2-canonical-field-unknown";public const string SelectionMalformed = "firmament-v2-selection-malformed";public const string SelectionDuplicateName = "firmament-v2-selection-duplicate-name";@@ -1226,6 +1225,23 @@ public static partial class FirmamentV2Parser/// production profile and section-stack readers remain semantic adapters; this/// method owns the root, units, disposition, and normalized declaration list./// </summary>+ /// <summary>+ /// Rewrites <c>Extrude X { profile: P; from: a; to: b }</c> as <c>Compose X { Base X { ... } }</c> in the+ /// adapter source. Field text is carried verbatim, so expressions and unknown fields report as they would on Base.+ /// </summary>+ private static string ExtrudeAsCompose(string adapterSource, DeclarationSyntax extrude, int shift, string source)+ {+ var start = extrude.Span.Start + shift;+ var fields = string.Join("; ", (extrude.Body?.Statements.OfType<FieldSyntax>() ?? [])+ .Select(f => $"{f.Name.Text}: {source.Substring(f.Value.Span.Start, f.Value.Span.Length)}"));+ var name = extrude.Name?.Text ?? "Body";+ var text = $"Compose {name} {{ Base {name} {{ {fields} }} }}";+ if (start < 0 || start + extrude.Span.Length > adapterSource.Length+ || adapterSource.Substring(start, extrude.Span.Length) != source.Substring(extrude.Span.Start, extrude.Span.Length))+ throw new InvalidOperationException("Extrude declaration does not map into the adapter source.");+ return adapterSource[..start] + text + adapterSource[(start + extrude.Span.Length)..];+ }+private static FirmamentV2ParseResult BindMechanicalConstruction(string source, DeclarationSyntax model, List<string> diagnostics, IReadOnlyList<ConceptIrTemplateInstantiation>? templateInstantiations, FirmamentCompileTimeValues? compileTime = null){source = MechanicalConstructionSource(source, model, diagnostics);@@ -1247,6 +1263,18 @@ public static partial class FirmamentV2Parserif (TryParseExactCoaxialTemplateDocument(adapterSource, model.Name!.Text, templateInstantiations, diagnostics, out var exactDocument))return FirmamentV2ParseResult.Success(exactDocument!, diagnostics.Append("firmament-v2-exact-coaxial-template-parsed").Append("firmament-v2-parse-succeeded").Distinct(StringComparer.Ordinal).Order().ToArray());+ // A single Extrude with holes, perforations or patterns is the same prism as+ // Compose { Base }; give it that construction so its Modify features are cut.+ // Edge finishes alone keep the plain profile route, which owns them.+ if (declarations.Count(d => d.Type.Name.Text == "Extrude") == 1 && declarations.All(d => d.Type.Name.Text != "Compose")+ && declarations.Where(d => d.Type.Name.Text == "Modify").SelectMany(d => d.Body?.Statements.OfType<DeclarationSyntax>() ?? [])+ .Any(d => d.Type.Name.Text != "EdgeFinish"))+ {+ var extrude = declarations.Single(d => d.Type.Name.Text == "Extrude");+ adapterSource = ExtrudeAsCompose(adapterSource, extrude, model.Span.Start - bodySpan.Start, source);+ declarations = MechanicalDeclarations(FirmamentSyntaxParser.Parse(adapterSource).Document.Statements).ToArray();+ }+if (declarations.Any(d => d.Type.Name.Text == "Compose")){var composition = PrismaticProfileCompositionParser.Parse(adapterSource);@@ -1274,7 +1302,7 @@ public static partial class FirmamentV2Parser&& !ProfileBoundaryChamferSourceBinder.HasSemanticProfileBoundaryFinish(body)&& composition.Profiles.Values.Any(profile => profile.Loops.Single().Segments.Count != 4)){- diagnostics.Add($"{EdgeFinishProfileComposeBoundaryUnsupported}:host={feature.Name}:construction=Compose:face=+Z:target=Boundary:supported=primitive-box-or-explicit-semantic-chain:Profile/Compose polygon-boundary materialization is not implemented.");+ diagnostics.Add($"{EdgeFinishProfileComposeBoundaryUnsupported}:host={feature.Name}:construction=Compose:face=+Z:target=Boundary: EdgeFinish on a Profile-based body is supported on four-sided boundaries; this boundary has curved or extra segments. Use Box stock for a rounded or chamfered rim, or shape the corners in the Profile itself.");return CanonicalFailure(diagnostics, EdgeFinishProfileComposeBoundaryUnsupported);}if (diagnostics.Any(IsFatalDiagnosticCode)) return CanonicalFailure(diagnostics, CanonicalDocumentMalformed);@@ -1308,19 +1336,6 @@ public static partial class FirmamentV2Parserreturn CanonicalFailure(diagnostics, CanonicalDocumentMalformed);}var resolved = profile.Profile;- // A plain Extrude lowers its Profile alone. Holes, perforations and- // patterns in a Modify block would otherwise be admitted and then- // never cut; reject them and name the construction that cuts them.- if (declarations.Where(d => d.Type.Name.Text == "Modify").SelectMany(d => d.Body?.Statements.OfType<DeclarationSyntax>() ?? [])- .FirstOrDefault(d => d.Type.Name.Text != "EdgeFinish") is { } dropped)- {- var extrude = declarations.First(d => d.Type.Name.Text == "Extrude");- var message = $"Extrude {extrude.Name?.Text} lowers only its Profile, so {dropped.Type.Name.Text} {dropped.Name?.Text} would not be cut. "- + $"Build the body with Compose for holes and other Modify features: Compose {extrude.Name?.Text} {{ Base Stock {{ Profile: {resolved.Name}; From: ...; To: ...; Role: Stock }} }}.";- diagnostics.Add($"{ExtrudeModifyFeatureUnsupported}: {message}");- return CanonicalFailure(diagnostics, CanonicalDocumentMalformed) with- { SyntaxDiagnostics = [new(ExtrudeModifyFeatureUnsupported, "fatal", message) { SourceSpan = dropped.Span, Stage = "Capability" }] };- }var profileSelectionDiagnostics = new List<string>();var profileSelections = ParseCanonicalSelections(body, bodySpan.Start, profileSelectionDiagnostics);ValidateCanonicalSelectionSources(body, profileSelections, [resolved.Name], profileSelectionDiagnostics);@@ -1338,7 +1353,7 @@ public static partial class FirmamentV2Parser&& !ProfileBoundaryChamferSourceBinder.HasSemanticProfileBoundaryFinish(body)&& resolved.Loops.Single().Segments.Count != 4){- diagnostics.Add($"{EdgeFinishProfileComposeBoundaryUnsupported}:host={resolved.Name}:construction=Profile:face=+Z:target=Boundary:supported=primitive-box-or-explicit-semantic-chain:Profile/Compose polygon-boundary materialization is not implemented.");+ diagnostics.Add($"{EdgeFinishProfileComposeBoundaryUnsupported}:host={resolved.Name}:construction=Profile:face=+Z:target=Boundary: EdgeFinish on a Profile-based body is supported on four-sided boundaries; this boundary has curved or extra segments. Use Box stock for a rounded or chamfered rim, or shape the corners in the Profile itself.");return CanonicalFailure(diagnostics, EdgeFinishProfileComposeBoundaryUnsupported);}if (diagnostics.Any(IsFatalDiagnosticCode)) return CanonicalFailure(diagnostics, CanonicalDocumentMalformed);diff --git a/Aetheris.Kernel.Firmament/FirmamentV2/ProfileAuthoringDeclarations.cs b/Aetheris.Kernel.Firmament/FirmamentV2/ProfileAuthoringDeclarations.csindex 87642fab..27191dc6 100644--- a/Aetheris.Kernel.Firmament/FirmamentV2/ProfileAuthoringDeclarations.cs+++ b/Aetheris.Kernel.Firmament/FirmamentV2/ProfileAuthoringDeclarations.cs@@ -9,14 +9,14 @@ namespace Aetheris.Kernel.Firmament.FirmamentV2;public static class ProfileSemanticDeclaration { }[FirmamentConstruct("Extrude", "Extrude", Context = "Model", Entry = "Extrude Plate { profile: Outline; from: 0mm; to: 8mm }",- Description = "A plain prism from a Profile along its layout normal. Holes and other Modify features are not admitted on an Extrude; use Compose with a Base for those.")]+ Description = "A prism from a Profile along its layout normal. A Modify on it takes Hole, Slot, Pattern and EdgeFinish, as on Compose; use Compose for Boss and Pocket.")][FirmamentField("Profile", "Profile", FirmamentSchemaValueKind.Profile, Required = true, Description = "Name of the Profile to extrude.")][FirmamentField("From", "From", FirmamentSchemaValueKind.Length, Required = true, Description = "Start height along the layout normal.")][FirmamentField("To", "To", FirmamentSchemaValueKind.Length, Required = true, Description = "End height; greater than From.")]public static class ExtrudeSemanticDeclaration { }[FirmamentConstruct("Compose", "Compose", Context = "Model", Entry = "Compose Plate {\n Base Stock { Profile: Outline; From: 0mm; To: 8mm; Role: Stock }\n}",- Description = "A Profile-based body built from a Base and optional Boss, Pocket and Hole operations. A later Modify on the Compose name admits holes and top-rim chamfers; Fillet finishes are rejected on Compose bodies, so round corners in the Profile instead.")]+ Description = "A Profile-based body built from a Base and optional Boss, Pocket and Hole operations. A later Modify on the Compose name takes Hole, Slot, Pattern and top-rim chamfers on four-sided boundaries; round vertical corners in the Profile (RoundedRect2).")]public static class ComposeSemanticDeclaration { }[FirmamentConstruct("ComposeBase", "Base", Context = "Compose", Entry = "Base Stock { Profile: Outline; From: 0mm; To: 8mm; Role: Stock }",diff --git a/Aetheris.Kernel.Firmament/FirmamentV2/SemanticConstructDeclarations.cs b/Aetheris.Kernel.Firmament/FirmamentV2/SemanticConstructDeclarations.csindex d91c20bd..f97f4608 100644--- a/Aetheris.Kernel.Firmament/FirmamentV2/SemanticConstructDeclarations.cs+++ b/Aetheris.Kernel.Firmament/FirmamentV2/SemanticConstructDeclarations.cs@@ -15,7 +15,7 @@ public static class EllipsoidSemanticDeclaration { }public static class PolyhedronSemanticDeclaration { }[FirmamentConstruct("Hole", "Hole", Context = "Modify body", Entry = "Modify Body { Hole<Shaft> H { On: +Z; Center: Point2(0mm, 0mm); Diameter: 6mm; End: ThroughAll } }", Description = "Semantic drilled hole.")]-[FirmamentField("On", "On", FirmamentSchemaValueKind.FaceSelector, Required = true, Choices = ["+Z", "-Z"], Description = "Entry face. Top/+Z and bottom/-Z are admitted on Box and Compose stock (not on a plain Extrude). Other selectors require their specific supported body lane. Center X/Y are coordinates in this face's local frame, not screen coordinates.")]+[FirmamentField("On", "On", FirmamentSchemaValueKind.FaceSelector, Required = true, Choices = ["+Z", "-Z"], Description = "Entry face. Top/+Z and bottom/-Z are admitted on Box, Extrude and Compose stock. Other selectors require their specific supported body lane. Center X/Y are coordinates in this face's local frame, not screen coordinates.")][FirmamentField("Center", "Center", FirmamentSchemaValueKind.Point, Required = true, Description = "Center in the support face.")][FirmamentField("Diameter", "Diameter", FirmamentSchemaValueKind.Length, Required = true, Description = "Shaft diameter.", SourceEditable = true, ProjectionMember = nameof(ProjectDiameter))][FirmamentField("End", "End", FirmamentSchemaValueKind.String, Required = true, Choices = ["ThroughAll", "Blind(5mm)"], Description = "ThroughAll cuts through the body. Blind(5mm) cuts to a finite depth; edit the expression for another depth.")]@@ -30,7 +30,7 @@ public static class HoleSemanticDeclarationpublic static double ProjectDiameter(FirmamentV2SemanticHoleDecl instance) => instance.ShaftDiameter;}-[FirmamentConstruct("EdgeFinish", "EdgeFinish", Context = "Modify body", Entry = "EdgeFinish TopChamfer { Face: +Z; Target: Boundary; Kind: Chamfer; Distance: 1mm }", Description = "An exact fillet or chamfer on an admitted boundary. Preview checks host, selector and feature combinations.")]+[FirmamentConstruct("EdgeFinish", "EdgeFinish", Context = "Modify body", Entry = "EdgeFinish TopChamfer { Face: +Z; Target: Boundary; Kind: Chamfer; Distance: 1mm }", Description = "An exact fillet or chamfer on an admitted boundary: the edges around one face. To round the vertical edges of a plate or block, round the corners of its Profile instead (Extrude or Compose on RoundedRect2). Preview checks host, selector and feature combinations.")][FirmamentField("Face", "Face", FirmamentSchemaValueKind.FaceSelector, Choices = ["+Z", "-Z", "+X", "-X", "+Y", "-Y"], Description = "Support face whose boundary is finished. Supported faces depend on the body and existing features.")][FirmamentField("Target", "Target", FirmamentSchemaValueKind.Choice, Required = true, Choices = ["Boundary", "AllEdges"], Description = "Boundary finishes the selected face perimeter. AllEdges is a uniform fillet on supported Box or Polyhedron stock only; omit Face for AllEdges.")][FirmamentField("Kind", "Kind", FirmamentSchemaValueKind.Choice, Choices = ["Chamfer", "Fillet"], Description = "Chamfer makes a bevel; Fillet makes a circular round. May also be specified by EdgeFinish<Chamfer> or EdgeFinish<Fillet>.")]diff --git a/Aetheris.Kernel.Firmament/Materializer/PrismaticProfileComposition.cs b/Aetheris.Kernel.Firmament/Materializer/PrismaticProfileComposition.csindex 673a978f..449920de 100644--- a/Aetheris.Kernel.Firmament/Materializer/PrismaticProfileComposition.cs+++ b/Aetheris.Kernel.Firmament/Materializer/PrismaticProfileComposition.cs@@ -1134,6 +1134,8 @@ public static class PrismaticProfileCompositionParser// The canonical Modify form is body-level syntax. Bind feature declarations// targeting this Compose body into the existing section-stack feature path so// they cannot be admitted and then silently omitted from exported geometry.+ public const string ComposeModifyFeatureUnsupported = "compose-modify-feature-unsupported";+private static string BindExternalModifyFeatures(string source, string composeName, string composeBody, List<string> diagnostics){var boundFeatures = new List<string>();@@ -1143,7 +1145,10 @@ public static class PrismaticProfileCompositionParser.Where(d => d.Type.Name.Text == "Modify" && d.Name?.Text == composeName))foreach (var statement in modifySyntax.Body?.Statements ?? [])if (statement is FirmamentV2.Syntax.FieldSyntax field) diagnostics.Add($"{FirmamentV2Parser.CanonicalFieldUnknown}:Modify:{field.Name.Text}");- else if (statement is not FirmamentV2.Syntax.DeclarationSyntax) diagnostics.Add(FirmamentV2Parser.CanonicalModifyMalformed);+ else if (statement is not FirmamentV2.Syntax.DeclarationSyntax feature) diagnostics.Add(FirmamentV2Parser.CanonicalModifyMalformed);+ // Only these lower into the section stack. Anything else would be admitted and never cut.+ else if (feature.Type.Name.Text is not ("Hole" or "Slot" or "Pattern" or "EdgeFinish"))+ diagnostics.Add($"{ComposeModifyFeatureUnsupported}:{feature.Type.Name.Text}:{feature.Name?.Text}: {feature.Type.Name.Text} is not supported on a Profile-based body; Modify on Compose or Extrude takes Hole, Slot, Pattern and EdgeFinish. Use a Pattern of Hole for a grid of openings.");foreach (Match modify in ModifyHead.Matches(source)){var body = Block(source, source.IndexOf('{', modify.Index));diff --git a/Aetheris.Web.Runtime/Program.cs b/Aetheris.Web.Runtime/Program.csindex 21642896..af86c3bd 100644--- a/Aetheris.Web.Runtime/Program.cs+++ b/Aetheris.Web.Runtime/Program.cs@@ -620,17 +620,20 @@ public static partial class Programvar featureNodes = (build.Value.EngineeringFeatures ?? []).Select(feature => new WebTreeNode(feature.FeatureId, feature.Kind, feature.Name, entityId, [], true,projections.FirstOrDefault(item => item.SemanticId == feature.FeatureId)?.ConstructSpan is { } span? SourceRefAt(_sourceName, effective, span.Start, span.Length) : null))- .Concat((build.Value.Features ?? []).Select(feature => new WebTreeNode(feature.FeatureId, feature.Kind, feature.Name, entityId, [], true, featureSources[feature.FeatureId], feature.Diameter))).ToArray();+ .Concat((build.Value.Features ?? []).Select(feature => new WebTreeNode(feature.FeatureId, feature.Kind, feature.Name, entityId, [], true, featureSources[feature.FeatureId], feature.Diameter,+ HolePlacement: new(feature.PlacementFace, feature.LocalU, feature.LocalV, feature.ResolvedPoint3)))).ToArray();var projectedBodySource = projections.FirstOrDefault(item => item.SemanticId == entityId)?.ConstructSpan is { } bodySpan? SourceRefAt(_sourceName, effective, bodySpan.Start, bodySpan.Length) : null;// The tree shows the names the source declares (`Model Bracket`, `Extrude body`); the file// stem is only a fallback, so a part has one name in the editor, the tree and the viewport.var modelName = Regex.Match(effective, @"\bModel\s+([A-Za-z_]\w*)\s*\{") is { Success: true } model ? model.Groups[1].Value : Name;+ var owner = MaterialOwner(effective, entityId);var bodyName = projections.FirstOrDefault(item => item.SemanticId == entityId)?.ConstructSpan is { } named&& Regex.Match(effective.Substring(named.Start, Math.Min(named.Length, effective.Length - named.Start)), @"^\s*(?:[A-Z]\w*\s+)*?[A-Z]\w*(?:<[^>]*>)?\s+([A-Za-z_]\w*)\s*[{;]") is { Success: true } declared- ? declared.Groups[1].Value : modelName;+ ? declared.Groups[1].Value : owner?.Name?.Text ?? modelName;var body = new WebTreeNode(entityId, build.Value.ExportedBodyCategory, bodyName, Id, featureNodes.Select(item => item.Id).ToArray(), true,- boxSource ?? projectedBodySource ?? SourceRef(_sourceName, 0, effective.Length), SemanticConstruct: semanticConstruct);+ boxSource ?? projectedBodySource ?? (owner is null ? null : SourceRefAt(_sourceName, effective, owner.Span.Start, owner.Span.Length))+ ?? SourceRef(_sourceName, 0, effective.Length), SemanticConstruct: semanticConstruct);var root = new WebTreeNode(Id, "Model", modelName, null, [body.Id], true, SourceRef(_sourceName, 0, effective.Length));var tree = new { rootId = root.Id, nodes = new[] { root, body }.Concat(featureNodes).ToArray() };var expectedPmi = Aetheris.Kernel.Firmament.Drawing.FirmamentDrawingCompiler.AuthoredPmiNames(build.Value);@@ -749,6 +752,19 @@ public static partial class Program}).ToArray();private static WebSourceRef SourceRef(string source, int start, int length) => new(source, 1, 1, start, length);++ /// <summary>+ /// The declaration that owns a part's material: the one named like the built entity, else the single+ /// Compose or Extrude. Profile-built bodies carry compiler ids (a Profile name, the Model) rather than this name.+ /// </summary>+ private static Aetheris.Kernel.Firmament.FirmamentV2.Syntax.DeclarationSyntax? MaterialOwner(string source, string entityId)+ {+ var declarations = Aetheris.Kernel.Firmament.FirmamentV2.Syntax.FirmamentSyntaxTraversal.Declarations(+ Aetheris.Kernel.Firmament.FirmamentV2.Syntax.FirmamentSyntaxParser.Parse(source).Document)+ .Where(d => d.Name is not null && d.Type.Name.Text is not ("Model" or "Modify" or "Profile" or "Static" or "Concept")).ToArray();+ var owners = declarations.Where(d => d.Type.Name.Text is "Compose" or "Extrude").ToArray();+ return declarations.FirstOrDefault(d => d.Name!.Text == entityId) ?? (owners.Length == 1 ? owners[0] : null);+ }private static WebSourceRef SourceRefAt(string name, string text, int start, int length){var prefix = text[..start];@@ -904,7 +920,10 @@ internal static class WebMeshBuilderinternal sealed record WebPropertyValue(double Value, string Unit);internal sealed record WebSourceRef(string Source, int Line, int Column, int Start, int Length);internal sealed record WebProperty(string Id, string OwnerEntityId, string Name, string Type, string Unit, double Value, bool Writable, int Start, int Length, WebSourceRef Source);-internal sealed record WebTreeNode(string Id, string Kind, string Name, string? ParentId, IReadOnlyList<string> Children, bool Visible, WebSourceRef? Source, double? HoleDiameterMm = null, string? SemanticConstruct = null);+internal sealed record WebTreeNode(string Id, string Kind, string Name, string? ParentId, IReadOnlyList<string> Children, bool Visible, WebSourceRef? Source, double? HoleDiameterMm = null, string? SemanticConstruct = null,+ WebHolePlacement? HolePlacement = null);+/// <summary>Where a built hole sits: its support face, the center in that face's local frame, and the world point when resolved.</summary>+internal sealed record WebHolePlacement(string Face, double U, double V, IReadOnlyList<double>? PointMm);internal sealed record WebDiagnostic(string Severity, string Code, string Message, WebSourceRef? Source = null, string? Details = null);internal sealed record WebBuildResult(bool Success, int Revision, object? Model, IReadOnlyList<WebDiagnostic> Diagnostics, bool RetainedPreviousGeometry,object? Tree = null, object? Mesh = null, IReadOnlyList<string>? EntityIds = null, object? Timings = null, object? Changes = null, string? StepText = null,diff --git a/Aetheris.Web.Runtime/sdk/src/index.d.ts b/Aetheris.Web.Runtime/sdk/src/index.d.tsindex eb0e42aa..2b48466c 100644--- a/Aetheris.Web.Runtime/sdk/src/index.d.ts+++ b/Aetheris.Web.Runtime/sdk/src/index.d.ts@@ -4,7 +4,7 @@ export interface SourceReference { readonly source: string; readonly line: numbeexport interface Diagnostic { readonly severity: DiagnosticSeverity; readonly code: string; readonly message: string; readonly source?: SourceReference; readonly details?: string }export interface UnitValue { readonly value: number; readonly unit: Unit }export interface EditableProperty { readonly id: string; readonly ownerEntityId: string; readonly name: string; readonly type: 'Length' | 'Angle' | 'Integer' | 'Number' | 'Boolean' | 'Enum'; readonly unit: Unit; readonly value: number; readonly writable: boolean; readonly source: SourceReference }-export interface ModelTreeNode { readonly id: string; readonly kind: string; readonly name: string; readonly parentId?: string; readonly children: readonly string[]; readonly visible: boolean; readonly source?: SourceReference; readonly holeDiameterMm?: number | null; readonly semanticConstruct?: string | null }+export interface ModelTreeNode { readonly id: string; readonly kind: string; readonly name: string; readonly parentId?: string; readonly children: readonly string[]; readonly visible: boolean; readonly source?: SourceReference; readonly holeDiameterMm?: number | null; readonly semanticConstruct?: string | null; /** A hole's support face, its center in that face's local frame, and the world point when resolved. */ readonly holePlacement?: { readonly face: string; readonly u: number; readonly v: number; readonly pointMm: readonly number[] | null } | null }export interface ModelTree { readonly rootId: string; readonly nodes: readonly ModelTreeNode[] }export type SourceAddressability = 'AuthoredStable' | 'DerivedStable' | 'ImportedStable' | 'RuntimeOnly' | 'Ambiguous' | 'Unstable';export interface MeshRange { readonly startTriangle: number; readonly triangleCount: number; readonly faceId: string; readonly semanticEntityId: string | null; readonly semanticTopologyId?: string | null; readonly topologyKind?: 'Face'; readonly outputRole?: string | null; readonly originFeature?: string | null; readonly sourceAddressability?: SourceAddressability; readonly selector?: string | null; readonly selectorReason?: string | null; readonly source?: SourceReference | null; readonly buildRevision?: number }diff --git a/docs/development/reports/2026-10/extrude-modify-and-profile-schema.md b/docs/development/reports/2026-10/extrude-modify-and-profile-schema.mdindex aaed3edd..bb806e68 100644--- a/docs/development/reports/2026-10/extrude-modify-and-profile-schema.md+++ b/docs/development/reports/2026-10/extrude-modify-and-profile-schema.md@@ -1,29 +1,32 @@-# Extrude with Modify features rejects; Profile constructs join the schema+# Extrude takes Modify features; Profile constructs join the schema## What changed-- A single `Extrude` lowers only its Profile. A `Modify` on it holding a Hole, Perforation or- Pattern was admitted and then never cut: the build succeeded with the feature missing.- It now rejects with `firmament-v2-extrude-modify-feature-unsupported`, naming the dropped- feature and the `Compose { Base ... }` form that does cut it. EdgeFinish on an Extrude keeps- its existing profile-boundary route.-- The semantic schema declares the everyday part path: `Profile`, `Extrude`, `Compose`, `Base`,- `Rect2`, `RoundedRect2`, `Circle2` and `Slot2`, with field kinds and buildable entries.- Completion offers them as construct entries. The Hole `On` help now says Box and Compose stock.+- A single `Extrude` with holes, slots or patterns in a `Modify` used to build without them: the+ plain profile route lowered only the Profile. It now builds as `Compose name { Base name { ... } }`+ (field text carried verbatim), so the features are cut exactly as on Compose. Edge finishes alone+ keep the plain profile route.+- `Perforation` in a Modify on a Compose (or Extrude) body was silently ignored. Every Modify feature+ the section stack cannot lower now rejects (`compose-modify-feature-unsupported`) at its declaration.+- The semantic schema declares `Profile`, `Extrude`, `Compose`, `Base`, `Rect2`, `RoundedRect2`,+ `Circle2` and `Slot2` with buildable entries; EdgeFinish help points at Profile corner rounding.+- Diagnostics: codes naming a declaration (`code:Kind:Name`, `host=Name`) are located at it; the+ message is the producer's explanation, not the raw code; a bare code beside its explained form is+ dropped. The EdgeFinish-on-Profile-boundary rejection explains what is supported.+- Web runtime: Profile-built bodies are named and located by their declaration; hole tree nodes+ carry support face, local center and world point.-Found while an agent used Helios through MCP: the hole vanished without a diagnostic, and the-schema gave no route to a Profile-based body (see HeliosCAD+Found while an agent used Helios through MCP (HeliosCAD`docs/development/reports/2026-10/agent-dogfooding-mcp.md`).## Evidence-- `FirmamentSemanticSchemaTests.ProfileWorkflowEntries_BuildAsWritten` compiles every new entry- in its documented host, including Compose with a Modify hole.-- `ModifyFeaturesOnAPlainExtrude_RejectInsteadOfVanishing`.-- No fixture used Extrude with Modify holes; the one Extrude + Modify fixture is an EdgeFinish.-- Targeted subset (schema, completion, profile, outline, sketch, IntelliDraft, hole, grammar): 510 pass.+- `ModifyFeaturesOnAPlainExtrude_AreCutLikeCompose`: same holes and centres as the Compose spelling.+- `UnsupportedModifyFeaturesOnProfileBodies_RejectAtTheirDeclaration`: line of the Perforation.+- `ProfileWorkflowEntries_BuildAsWritten`; the reference example in solids-and-features builds.+- Full `Aetheris.Kernel.Firmament.Tests`: 3,213 pass.## Verdict-Success. The location of this rejection in CLI/web output is the document anchor (line 1); the-parser's feature span is not carried through the string-code admission path.+Success. Not done: an EdgeFinish target for the vertical edges of a Box. It would rebuild the Box as+a Compose and lose Box-only features such as side holes; the Profile spelling is exact and documented.diff --git a/docs/public/reference/language/solids-and-features.md b/docs/public/reference/language/solids-and-features.mdindex 7dc3a1c9..80a5b27b 100644--- a/docs/public/reference/language/solids-and-features.md+++ b/docs/public/reference/language/solids-and-features.md@@ -37,10 +37,11 @@ different construction.patterns. `Modify Base {}` with no features is a valid no-op, as long as `Base`exists.-A plain `Extrude` takes only edge finishes in its Modify. Holes, perforations and-patterns need a Profile-based `Compose` body (`Compose Plate { Base Stock { profile:-Outline; from: 0mm; to: 8mm } }`); on an `Extrude` they reject rather than build-without the feature.+On a single `Extrude`, Modify takes the same features as on a `Compose` body:+holes, slots, patterns and edge finishes. The Extrude builds as+`Compose name { Base name { ... } }`. `Perforation` is for Box and hollow+Cylinder stock; on Extrude and Compose bodies it rejects at its declaration+(use a `Pattern` of holes for a grid of openings).Angular mold `Draft` is not currently a V2 `Modify` feature. Its bounded legacyoperation does not imply support on the modern authoring path.@@ -120,6 +121,21 @@ In a Compose body, all three variants are supported on the `+Z` support with`kind` are given, they must agree. A bare `Fillet name { ... }` is not an edgefinish.+An edge finish works on the edges around one face. To round the vertical edges+of a plate or block, round the corners of its outline instead; the result is+exact and holes still apply:++```firmament+Model Plate {+ units: mm+ Profile Outline = RoundedRect2 { center: [0mm, 0mm]; size: [50mm, 40mm]; radius: 3mm }+ Extrude Plate { profile: Outline; from: 0mm; to: 8mm }+ Modify Plate {+ Hole<Shaft> Corner { on: +Z; center: Point2(19mm, 14mm); diameter: 5.5mm; end: ThroughAll }+ }+}+```+What you can select depends on the body:| Body | Selection |