Next Gen STEP AP242 Native-ish BREP Geometric Modeling Kernel
Consume WireForm execution statements from admitted AST spans
Yuechen Lic86282e5a158
diff --git a/Aetheris.CLI.Tests/ReleaseAdmissionRegressionTests.cs b/Aetheris.CLI.Tests/ReleaseAdmissionRegressionTests.csindex 8cb40ec4..6ddae095 100644--- a/Aetheris.CLI.Tests/ReleaseAdmissionRegressionTests.cs+++ b/Aetheris.CLI.Tests/ReleaseAdmissionRegressionTests.cs@@ -11,6 +11,9 @@ public sealed class ReleaseAdmissionRegressionTests[InlineData("SectionChain/explicit-sketch-ruled.firmament", "position: [2mm, -2mm]", "position: [2mm, -2deg]")][InlineData("SectionChain/explicit-sketch-ruled.firmament", "Point2 B { position: [2mm, -2mm] }", "Point2 B { position: [2mm, -2mm]; zzUnknownField: 1mm }")][InlineData("WireForm/straight-wire.firmament", "Straight Body {", "Straight Body { zzUnknownField: 1mm;")]+ [InlineData("WireForm/straight-wire.firmament", "Straight Body {", "Straight Ignored; Straight Body {")]+ [InlineData("WireForm/straight-wire.firmament", "Straight Body {", "Straight Body on XZ {")]+ [InlineData("WireForm/straight-wire.firmament", "WireForm Wire {", "WireForm Other { Diameter: 2mm Origin: [0,0,0] Tangent: [1,0,0] Up: [0,1,0] Straight Body { Length: 20mm } } WireForm Wire {")][InlineData("WireForm/straight-wire.firmament", "StartFrame {", "StartFrame { zzUnknownField: 1mm;")][InlineData("WireForm/straight-wire.firmament", "WireForm Wire {", "WireForm Wire { zzUnknownField: 1mm;")][InlineData("WireForm/straight-wire.firmament", "Model StraightWire {", "Model StraightWire { zzUnknownField: 1mm;")]diff --git a/Aetheris.Kernel.Firmament.Tests/WireFormTests.cs b/Aetheris.Kernel.Firmament.Tests/WireFormTests.csindex 4ad793c1..4feeff12 100644--- a/Aetheris.Kernel.Firmament.Tests/WireFormTests.cs+++ b/Aetheris.Kernel.Firmament.Tests/WireFormTests.cs@@ -7,6 +7,23 @@ namespace Aetheris.Kernel.Firmament.Tests;public sealed class WireFormTests{+ [Fact]+ public void CommentedOperationsDoNotCreateGeometryOrProvenance()+ {+ var source = File.ReadAllText(Fixture("Canonical", "WireForm", "straight-wire.firmament"));+ var control = WireFormAuthoring.Parse(source);+ var commented = WireFormAuthoring.Parse(source.Replace("Straight Body {", "/* Straight Phantom { Length: 30mm } */ Straight Body {", StringComparison.Ordinal));+ Assert.True(control.IsSuccess);+ Assert.True(commented.IsSuccess, string.Join("; ", commented.Diagnostics.Select(d => d.Message)));+ Assert.Equal(control.Value.Operations, commented.Value.Operations);+ Assert.Equal("Body", Assert.Single(commented.Value.AuthoredOperations!).Name);+ var built = FirmamentBuildAndExport.CompileSource(source);+ var withComment = FirmamentBuildAndExport.CompileSource(source.Replace("Straight Body {", "/* Straight Phantom { Length: 30mm } */ Straight Body {", StringComparison.Ordinal));+ Assert.True(built.IsSuccess, Messages(built));+ Assert.True(withComment.IsSuccess, Messages(withComment));+ Assert.Equal(built.Value.StepText, withComment.Value.StepText);+ }+[Fact]public void MissingStartFrameBodyProducesAnActionableRefusal(){diff --git a/Aetheris.Kernel.Firmament/Materializer/WireForm.cs b/Aetheris.Kernel.Firmament/Materializer/WireForm.csindex 737c96a5..179fe700 100644--- a/Aetheris.Kernel.Firmament/Materializer/WireForm.cs+++ b/Aetheris.Kernel.Firmament/Materializer/WireForm.cs@@ -136,7 +136,8 @@ public static class WireFormAuthoringreturn false;}- public static bool IsWireFormSource(string source) => Declaration.IsMatch(source) || WireRouteAuthoring.IsSource(source);+ public static bool IsWireFormSource(string source) => FirmamentSyntaxTraversal.Declarations(FirmamentSyntaxParser.Parse(source).Document)+ .Any(d => d.Type.Name.Text == "WireForm") || WireRouteAuthoring.IsSource(source);internal static void BindConstructionScope(DocumentSyntax syntax, string materialKind, List<string> diagnostics){@@ -159,17 +160,27 @@ public static class WireFormAuthoringsource = frontend.Source;if (WireRouteAuthoring.IsSource(source)) return WireRouteAuthoring.Parse(source);var syntax = FirmamentV2.Syntax.FirmamentSyntaxParser.Parse(source);- var scopeDiagnostics = new List<string>();+ var scopeDiagnostics = syntax.Diagnostics.Select(d => d.Code + ": " + d.Message).ToList();BindConstructionScope(syntax.Document, "WireForm", scopeDiagnostics);if (scopeDiagnostics.Count > 0)return Fail(scopeDiagnostics[0].Split(':')[0], string.Join("; ", scopeDiagnostics));- var declaration = Declaration.Match(source);- if (!declaration.Success) return Fail("wireform-declaration-missing", "No WireForm declaration was found.");- var open = source.IndexOf('{', declaration.Index);- var close = MatchingBrace(source, open);- var name = declaration.Groups["name"].Value;- if (close < 0) return Fail("wireform-declaration-malformed", $"WireForm '{name}' has no closing brace.");- var body = source[(open + 1)..close];+ var declarations = FirmamentV2Parser.MechanicalDeclarations(syntax.Document.Statements).Where(d => d.Type.Name.Text == "WireForm").ToArray();+ if (declarations.Length > 1) return Fail("wireform-multiple-bodies-unsupported", "One WireForm product is admitted per part; place separate Parts in an Assembly. No declared wire may be discarded.");+ var declaration = declarations.FirstOrDefault();+ if (declaration?.Name is null || declaration.Body is null)+ return Fail("wireform-declaration-missing", "Expected WireForm Name { ... }.");+ var name = declaration.Name.Text;+ if (UnsupportedHeader(declaration)) return Fail("wireform-header-unsupported", $"WireForm '{name}' does not admit placement, generic, parameter or initializer clauses; author its StartFrame fields explicitly.");+ foreach (var child in declaration.Body.Statements.OfType<DeclarationSyntax>())+ {+ if (child.Body is null)+ return child.Type.Name.Text == "StartFrame"+ ? Fail("wireform-start-frame-invalid", "StartFrame requires a body containing Origin, Tangent and Up.")+ : Fail("wireform-operation-malformed", $"Wire operation '{child.Name?.Text ?? child.Type.Name.Text}' requires a body.");+ if (UnsupportedHeader(child) || child.Type.Name.Text != "StartFrame" && child.Name is null)+ return Fail("wireform-header-unsupported", $"Wire operation '{child.Name?.Text ?? child.Type.Name.Text}' requires a named operation and a field body; placement and parameter clauses are not supported.");+ }+ var body = source.Substring(declaration.Body.ContentSpan.Start, declaration.Body.ContentSpan.Length);var wireFields = new WireFormFields("WireForm", body);var children = wireFields.Declaration.Body!.Statements.OfType<DeclarationSyntax>().Where(d => d.Type.Name.Text is "StartFrame" or "Straight" or "Bend" or "Helix" or "AxisCoil" or "Coil" or "SurfaceCoil" or "Knot")@@ -209,19 +220,16 @@ public static class WireFormAuthoringvar state = new WireState(new(origin.X, origin.Y, origin.Z), tangent, up, 0d);var operations = new List<WireFormOperationAir>();var provenance = new List<WireFormOperationProvenance>();- foreach (Match match in Operation.Matches(body))+ foreach (var operation in declaration.Body.Statements.OfType<DeclarationSyntax>().Where(d => d.Type.Name.Text != "StartFrame")){- var operationOpen = body.IndexOf('{', match.Index);- var operationClose = MatchingBrace(body, operationOpen);- if (operationClose < 0) return Fail("wireform-operation-malformed", $"Operation '{match.Groups["name"].Value}' has no closing brace.");- var operationBody = body[(operationOpen + 1)..operationClose];- var operationName = match.Groups["name"].Value;- var operationFields = new WireFormFields(match.Groups["kind"].Value, operationBody);+ var operationBody = source.Substring(operation.Body!.ContentSpan.Start, operation.Body.ContentSpan.Length);+ var operationName = operation.Name!.Text;+ var operationKind = operation.Type.Name.Text;+ var operationFields = new WireFormFields(operationKind, operationBody);provenance.Add(new(operationName,- new FirmamentV2SourceSpan(open + 1 + match.Index, operationClose - match.Index + 1),- FirmamentV2Parser.ReadAuthoredFields(operationBody, open + 1 + operationOpen + 1)));+ operation.Span, FirmamentV2Parser.ReadAuthoredFields(operationBody, operation.Body.ContentSpan.Start)));var ordinal = operations.Count + 1;- if (match.Groups["kind"].Value == "Straight")+ if (operationKind == "Straight"){if (!TryLength(operationFields.Read("Length"), out var length) || length <= 0d)return Fail("wireform-straight-length-invalid", $"{operationName}: Length must be finite and greater than zero.");@@ -232,19 +240,19 @@ public static class WireFormAuthoringcontinue;}- if (match.Groups["kind"].Value is "Helix" or "AxisCoil" or "Coil")+ if (operationKind is "Helix" or "AxisCoil" or "Coil"){var coil = WireCoilAuthoring.CreateAxis(operationName, ordinal, operationBody, state, diameter);if (!coil.IsSuccess) return KernelResult<WireFormFeatureAir>.Failure(coil.Diagnostics);operations.Add(coil.Value); state = coil.Value.Output; continue;}- if (match.Groups["kind"].Value == "SurfaceCoil")+ if (operationKind == "SurfaceCoil"){var coil = WireCoilAuthoring.CreateSurface(source, operationName, ordinal, operationBody, state, diameter);if (!coil.IsSuccess) return KernelResult<WireFormFeatureAir>.Failure(coil.Diagnostics);operations.Add(coil.Value); state = coil.Value.Output; continue;}- if (match.Groups["kind"].Value == "Knot")+ if (operationKind == "Knot"){if (operations.Count != 0 || Operation.Matches(body).Count != 1)return Fail("wireform-knot-composition-unsupported", $"{operationName}: X2 KnotPath must be the sole closed operation in a WireForm.");@@ -283,6 +291,11 @@ public static class WireFormAuthoringoperations[0] is WireKnotPathAir knot ? knot.FrameClosure.Policy : FrameTransportPolicy, provenance));}+ private static bool UnsupportedHeader(DeclarationSyntax declaration) => declaration.Clauses.Count > 0+ || declaration.Modifiers.Count > 0 || declaration.Type.Arguments.Count > 0 || declaration.Parameters.Count > 0+ || declaration.HasParameterList || declaration.Annotation is not null || declaration.ResultType is not null+ || declaration.Initializer is not null || declaration.Occurrence;+internal static string? Property(string body, string name){var match = Regex.Match(body, $@"\b(?:{Regex.Escape(name)}|{Regex.Escape(FirmamentSourceSpelling.PreferredField(name))})\s*:\s*(?<value>\[[^\]]+\]|[^;\r\n}}]+)", RegexOptions.CultureInvariant);diff --git a/docs/development/reports/2026-10/RELEASE-2.0.0-CLOSEOUT.md b/docs/development/reports/2026-10/RELEASE-2.0.0-CLOSEOUT.mdindex f1c25fa8..9fdf4880 100644--- a/docs/development/reports/2026-10/RELEASE-2.0.0-CLOSEOUT.md+++ b/docs/development/reports/2026-10/RELEASE-2.0.0-CLOSEOUT.md@@ -75,6 +75,13 @@ The final owner review also reproduced a malformed `StartFrame Empty;` crash.It now rejects with `wireform-start-frame-invalid` in both real CLI commands,retaining an explanation and producing no STEP. This is a reader guard, not anew fallback or recovery interpretation.+The follow-up operation check also reproduced `Straight Ignored;` being omitted+when followed by a real operation. WireForm now consumes the existing AST's+root and ordered child spans, instead of rediscovering execution statements by+regex. Missing bodies, unsupported headers and multiple wire products reject.+A commented-out operation contributes neither geometry nor provenance, and its+accepted STEP is byte-identical to the control. The geometry state machine and+coil/knot construction algorithms remain unchanged.CLI diagnostics carry code, severity, explanation, source file, stage and sourcelocation when available. Missing-file diagnostics have no invented span. Legacydiff --git a/docs/public/reference/language/compatibility.md b/docs/public/reference/language/compatibility.mdindex 07927d0a..798ed28f 100644--- a/docs/public/reference/language/compatibility.md+++ b/docs/public/reference/language/compatibility.md@@ -85,3 +85,8 @@ operations, SectionChain guides, assembly occurrences and published Semanticblocks. `validate --parse-only` reports a limited validation level; normalvalidation performs the owning domain admission and required engineeringpreflight, which can take time for swept or spline-heavy geometry.++A WireForm part admits one wire product. Its named operations require field+bodies; unsupported placement or parameter headers reject. Use StartFrame for+the authored frame and an Assembly for separate Parts. Comments never contribute+wire operations or operation provenance.