Skip to content

Next Gen STEP AP242 Native-ish BREP Geometric Modeling Kernel

Make native Forge string binding and cut-list export reflection-free

Yuechen Li03ff13d052de
diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml
index 3e73524b..87ea7e7c 100644
--- a/.github/workflows/dotnet.yml
+++ b/.github/workflows/dotnet.yml
@@ -191,6 +191,7 @@ jobs:
$forge = (Resolve-Path extracted/Aetheris-win-x64/forge-host/Aetheris.Forge.Host.exe)
& $forge info
& $forge list
+ ./scripts/Test-ForgeHostTemplates.ps1 -ExecutablePath $forge -OutputDirectory artifacts/local/native-forge-templates
& $forge invoke Standard.SheetMetal.ElectronicsEnclosure --request extracted/Aetheris-win-x64/samples/forge-interop-x1/request.json --out forge-out
if (-not (Test-Path forge-out/*.step) -or -not (Test-Path forge-out/*.svg)) { throw 'NativeAOT Forge artifacts missing.' }
Copy-Item '${{ github.workspace }}/fixtures/Regression/Assembly/bearing-module-family-with-legacy-placement.firmament' assembly.firmament
diff --git a/Aetheris.Kernel.Firmament/Assembly/AssemblyPmiAuthoring.cs b/Aetheris.Kernel.Firmament/Assembly/AssemblyPmiAuthoring.cs
index d06cf964..ce24c364 100644
--- a/Aetheris.Kernel.Firmament/Assembly/AssemblyPmiAuthoring.cs
+++ b/Aetheris.Kernel.Firmament/Assembly/AssemblyPmiAuthoring.cs
@@ -88,7 +88,7 @@ internal static class AssemblyPmiAuthoring
var owned = new Aetheris.Kernel.Firmament.FirmamentV2.Syntax.FirmamentSyntaxFields(note, errors);
var target = owned.Reference("Target");
var text = owned.Take("Text") is Aetheris.Kernel.Firmament.FirmamentV2.Syntax.LiteralSyntax { Kind: Aetheris.Kernel.Firmament.FirmamentV2.Syntax.LiteralKind.String } literal
- ? JsonSerializer.Deserialize<string>(literal.Raw) : null;
+ ? JsonSerializer.Deserialize(literal.Raw, FirmamentJsonContext.Default.String) : null;
owned.Complete();
if (errors.Count > 0 || target is null || string.IsNullOrWhiteSpace(text) || text.Any(char.IsControl))
Error("pmi-note-invalid", string.Join(" | ", errors), note.Span);
diff --git a/Aetheris.Kernel.Firmament/FirmamentJsonContext.cs b/Aetheris.Kernel.Firmament/FirmamentJsonContext.cs
new file mode 100644
index 00000000..9b33c7ac
--- /dev/null
+++ b/Aetheris.Kernel.Firmament/FirmamentJsonContext.cs
@@ -0,0 +1,8 @@
+using System.Text.Json.Serialization;
+
+namespace Aetheris.Kernel.Firmament;
+
+// Language string literals use JSON escaping, including in NativeAOT hosts.
+// Keep their primitive metadata explicit instead of relying on reflection.
+[JsonSerializable(typeof(string))]
+internal partial class FirmamentJsonContext : JsonSerializerContext;
diff --git a/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentCompileTimeValues.cs b/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentCompileTimeValues.cs
index 9d8fa5c1..ec05e090 100644
--- a/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentCompileTimeValues.cs
+++ b/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentCompileTimeValues.cs
@@ -463,7 +463,7 @@ internal sealed partial class FirmamentCompileTimeValues(string source)
private static string Nominal(FirmamentV2BoundLet value) => value.Type switch
{
FirmamentV2PrimitiveType.Bool => (bool)value.Value.Value ? "true" : "false",
- FirmamentV2PrimitiveType.String => System.Text.Json.JsonSerializer.Serialize(value.Value.Value),
+ FirmamentV2PrimitiveType.String => System.Text.Json.JsonSerializer.Serialize((string)value.Value.Value, FirmamentJsonContext.Default.String),
_ => value.Value.NumericValue!.Value.ToString("R", System.Globalization.CultureInfo.InvariantCulture) + value.Value.Unit
};
diff --git a/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentConcepts.cs b/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentConcepts.cs
index c01f79d2..a2d0ec8c 100644
--- a/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentConcepts.cs
+++ b/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentConcepts.cs
@@ -230,7 +230,7 @@ internal sealed class FirmamentConcepts
Value Eval(ExpressionSyntax child) => Evaluate(child, scope, stack, depth + 1, typeOnly);
if (e is SequenceSyntax { Kind: SequenceKind.Tuple, Items.Count: 1 } group) return Eval(group.Items[0].Value);
if (e is LiteralSyntax { Kind: LiteralKind.Boolean } boolean) return new("Bool", bool.Parse(boolean.Raw), e);
- if (e is LiteralSyntax { Kind: LiteralKind.String } text) return new("String", System.Text.Json.JsonSerializer.Deserialize<string>(text.Raw)!, e);
+ if (e is LiteralSyntax { Kind: LiteralKind.String } text) return new("String", System.Text.Json.JsonSerializer.Deserialize(text.Raw, FirmamentJsonContext.Default.String)!, e);
if (e is ReferenceSyntax or MemberSyntax)
{
var name = FirmamentSyntaxValues.Reference(e)!;
diff --git a/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2ImportedEditingBinding.cs b/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2ImportedEditingBinding.cs
index 95f5d3b7..1733a16e 100644
--- a/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2ImportedEditingBinding.cs
+++ b/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2ImportedEditingBinding.cs
@@ -250,7 +250,7 @@ public static partial class FirmamentV2Parser
return FirmamentSyntaxFields.Object(obj.Type is null ? obj with { Type = new ReferenceSyntax(new(type, obj.Span), obj.Span) } : obj, null, diagnostics);
}
private static string? StringValue(ExpressionSyntax? value) => value is LiteralSyntax { Kind: LiteralKind.String } literal
- ? System.Text.Json.JsonSerializer.Deserialize<string>(literal.Raw) : null;
+ ? System.Text.Json.JsonSerializer.Deserialize(literal.Raw, FirmamentJsonContext.Default.String) : null;
private static Point3D? Point(ExpressionSyntax? value) => value is CallSyntax { Target: ReferenceSyntax { Name.Text: "Point3" } }
&& FirmamentSyntaxValues.Vector(value, "mm", out var xyz) && xyz.Length == 3 ? new(xyz[0], xyz[1], xyz[2]) : null;
}
diff --git a/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2StaticValues.cs b/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2StaticValues.cs
index 3b2c4c51..6a11f40a 100644
--- a/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2StaticValues.cs
+++ b/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2StaticValues.cs
@@ -183,7 +183,7 @@ public static partial class FirmamentV2Parser
try
{
object value = inferred == FirmamentV2PrimitiveType.String
- ? System.Text.Json.JsonSerializer.Deserialize<string>(literal.Raw)!
+ ? System.Text.Json.JsonSerializer.Deserialize(literal.Raw, FirmamentJsonContext.Default.String)!
: bool.Parse(literal.Raw);
return new FirmamentV2LiteralExpression(new(inferred.Value, value, Raw: literal.Raw));
}
@@ -239,7 +239,7 @@ public static partial class FirmamentV2Parser
}, value.Type switch
{
FirmamentV2PrimitiveType.Bool => (bool)value.Value.Value ? "true" : "false",
- FirmamentV2PrimitiveType.String => System.Text.Json.JsonSerializer.Serialize(value.Value.Value),
+ FirmamentV2PrimitiveType.String => System.Text.Json.JsonSerializer.Serialize((string)value.Value.Value, FirmamentJsonContext.Default.String),
_ => value.Value.NumericValue!.Value.ToString("R", CultureInfo.InvariantCulture)
}, span);
return value.Value.Unit is { } unit ? new QuantitySyntax(literal, new(unit, span), span) : literal;
diff --git a/Aetheris.Kernel.Firmament/FirmamentV2/Syntax/FirmamentSyntaxParser.cs b/Aetheris.Kernel.Firmament/FirmamentV2/Syntax/FirmamentSyntaxParser.cs
index 7c9838a6..e7dd23c1 100644
--- a/Aetheris.Kernel.Firmament/FirmamentV2/Syntax/FirmamentSyntaxParser.cs
+++ b/Aetheris.Kernel.Firmament/FirmamentV2/Syntax/FirmamentSyntaxParser.cs
@@ -219,7 +219,7 @@ public static class FirmamentSyntaxParser
if (name is null && type.Name.Text is "RecoveredRegion" or "RecoveredBend" or "RecoveredCut" && Current.Kind==SyntaxTokenKind.String)
{
var token=Current;at++;
- name=new(System.Text.Json.JsonSerializer.Deserialize<string>(token.Text)!,token.Span);
+ name=new(System.Text.Json.JsonSerializer.Deserialize(token.Text,FirmamentJsonContext.Default.String)!,token.Span);
}
ExpressionSyntax? target = null;
if (type.Name.Text is "CornerProfile" or "EdgeProfile" && name is not null)
diff --git a/Aetheris.Kernel.Firmament/FirmamentV2/Syntax/FirmamentSyntaxValues.cs b/Aetheris.Kernel.Firmament/FirmamentV2/Syntax/FirmamentSyntaxValues.cs
index 2825e5f4..89940d74 100644
--- a/Aetheris.Kernel.Firmament/FirmamentV2/Syntax/FirmamentSyntaxValues.cs
+++ b/Aetheris.Kernel.Firmament/FirmamentV2/Syntax/FirmamentSyntaxValues.cs
@@ -10,7 +10,7 @@ public static class FirmamentSyntaxValues
MemberSyntax m when Reference(m.Target) is { } target => target + "." + m.Member.Text,
UnarySyntax { Operator: UnaryOperator.Positive } u when Reference(u.Operand) is { } axis => "+" + axis,
UnarySyntax { Operator: UnaryOperator.Negative } u when Reference(u.Operand) is { } axis => "-" + axis,
- LiteralSyntax { Kind: LiteralKind.String } s => System.Text.Json.JsonSerializer.Deserialize<string>(s.Raw),
+ LiteralSyntax { Kind: LiteralKind.String } s => System.Text.Json.JsonSerializer.Deserialize(s.Raw, FirmamentJsonContext.Default.String),
_ => null
};
diff --git a/Aetheris.Kernel.Firmament/Modules/FirmamentMetadata.cs b/Aetheris.Kernel.Firmament/Modules/FirmamentMetadata.cs
index 683a5649..40181aa8 100644
--- a/Aetheris.Kernel.Firmament/Modules/FirmamentMetadata.cs
+++ b/Aetheris.Kernel.Firmament/Modules/FirmamentMetadata.cs
@@ -32,5 +32,5 @@ internal static class FirmamentMetadata
value.Fields.ToDictionary(p => p.Key, p => String(p.Value), StringComparer.Ordinal),
value.Fields.ToDictionary(p => p.Key, p => TypeOf(p.Key), StringComparer.Ordinal));
}
- internal static string String(string value) => value.StartsWith('"') ? JsonSerializer.Deserialize<string>(value)! : value;
+ internal static string String(string value) => value.StartsWith('"') ? JsonSerializer.Deserialize(value, FirmamentJsonContext.Default.String)! : value;
}
diff --git a/Aetheris.Kernel.Firmament/Modules/FirmamentModuleResources.cs b/Aetheris.Kernel.Firmament/Modules/FirmamentModuleResources.cs
index d085a4ea..11a84355 100644
--- a/Aetheris.Kernel.Firmament/Modules/FirmamentModuleResources.cs
+++ b/Aetheris.Kernel.Firmament/Modules/FirmamentModuleResources.cs
@@ -57,7 +57,7 @@ internal sealed partial class FirmamentModuleGraph
path = reference.Path;
var folder = Path.GetDirectoryName(module.Path);
var relative = Path.GetRelativePath(string.IsNullOrEmpty(folder) ? "." : folder, path).Replace('\\', '/');
- module.Edits.Add(new(from[0].Span, "path: " + JsonSerializer.Serialize(relative) + ";"));
+ module.Edits.Add(new(from[0].Span, "path: " + JsonSerializer.Serialize(relative, FirmamentJsonContext.Default.String) + ";"));
}
else if (paths is [{ Value: LiteralSyntax { Kind: LiteralKind.String } literal }])
{
@@ -70,7 +70,7 @@ internal sealed partial class FirmamentModuleGraph
&& (d.Name?.Text == step.Name?.Text || d.Name?.Text.StartsWith(step.Name!.Text + ".", StringComparison.Ordinal) == true))) SurgicalAssets.Add(Relative(path));
var locked = Locked?.Dependencies.SingleOrDefault(d => d.Path == Relative(path));
if (locked is not null && !fields.Any(f => f.Name.Text is "sha256" or "Sha256" or "textSha256" or "TextSha256"))
- module.Edits.Add(new(new(step.Body.Span.Start + 1, 0), "\nsha256: " + JsonSerializer.Serialize(locked.Sha256) + ";\n"));
+ module.Edits.Add(new(new(step.Body.Span.Start + 1, 0), "\nsha256: " + JsonSerializer.Serialize(locked.Sha256, FirmamentJsonContext.Default.String) + ";\n"));
}
}
}
diff --git a/Aetheris.Kernel.Firmament/Structural/StructuralAuthoring.cs b/Aetheris.Kernel.Firmament/Structural/StructuralAuthoring.cs
index 5b9bbf58..acf4db06 100644
--- a/Aetheris.Kernel.Firmament/Structural/StructuralAuthoring.cs
+++ b/Aetheris.Kernel.Firmament/Structural/StructuralAuthoring.cs
@@ -168,10 +168,9 @@ public static class StructuralAuthoring
return FirmamentDomainDiagnostics.Present(messages,frontend,"Firmament.Structural");
}
- public static string CutListJson(StructuralReport report) => JsonSerializer.Serialize(new
- {
- schema = "aetheris:structural-cut-list:x2", structure = report.Structure, units = new { length = "mm", mass = "kg" }, entries = report.CutList
- }, new JsonSerializerOptions { WriteIndented = true, PropertyNamingPolicy = JsonNamingPolicy.CamelCase });
+ public static string CutListJson(StructuralReport report) => JsonSerializer.Serialize(
+ new StructuralCutListDocument("aetheris:structural-cut-list:x2", report.Structure, new("mm", "kg"), report.CutList),
+ StructuralJsonContext.Default.StructuralCutListDocument);
private sealed record Parsed(string Name, IReadOnlyList<StructuralNodeAir> Nodes, IReadOnlyList<StructuralPathAir> Paths, IReadOnlyList<StructuralSectionAir> Sections, IReadOnlyList<StructuralMemberAir> Members, IReadOnlyList<StructuralJointAir> Joints, IReadOnlyList<StructuralWeldAir> Welds, IReadOnlyDictionary<string, ResolvedMaterial> Materials);
private sealed record MemberEnds(StructuralEndPlane Start, StructuralEndPlane End);
diff --git a/Aetheris.Kernel.Firmament/Structural/StructuralCutListJson.cs b/Aetheris.Kernel.Firmament/Structural/StructuralCutListJson.cs
new file mode 100644
index 00000000..10c39cdb
--- /dev/null
+++ b/Aetheris.Kernel.Firmament/Structural/StructuralCutListJson.cs
@@ -0,0 +1,12 @@
+using System.Text.Json.Serialization;
+
+namespace Aetheris.Kernel.Firmament.Structural;
+
+internal sealed record StructuralCutListUnits(string Length, string Mass);
+internal sealed record StructuralCutListDocument(
+ string Schema, string Structure, StructuralCutListUnits Units,
+ IReadOnlyList<StructuralCutListEntry> Entries);
+
+[JsonSourceGenerationOptions(PropertyNamingPolicy = JsonKnownNamingPolicy.CamelCase, WriteIndented = true)]
+[JsonSerializable(typeof(StructuralCutListDocument))]
+internal partial class StructuralJsonContext : JsonSerializerContext;
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.md
index 5b1608da..3333eede 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
@@ -255,6 +255,18 @@ ElectronicsEnclosure invocation, producing AP242, flat AP242 and SVG. Existing
trim/AOT analysis warnings are retained; this is execution evidence for the
qualified host path, not a claim that every library API is AOT-safe.
+Broader native execution then reproduced ten product-template crashes in
+compile-time string binding; the five Sheet Metal defaults passed. Language
+string JSON now uses explicit generated primitive metadata at its existing
+readers/writers. All fifteen public templates then built STEP. Requesting every
+advertised artifact isolated one remaining reflection-based serializer: the
+workbench cut list. Its owner now uses a typed generated JSON contract with the
+same keys, units, ordering and indentation. The native catalog probe now builds
+all fifteen templates and all 26 advertised artifacts, checks their byte/hash
+receipts, and rejects a complete invalid standoff record with the real
+`firmament-concept-requirement-failed` diagnostic and no artifacts. The probe
+runs against the extracted NativeAOT executable in the Windows release gate.
+
## Executive verdict
**Meaningful progression.** The managed compiler family is publicly released;
diff --git a/scripts/Test-ForgeHostTemplates.ps1 b/scripts/Test-ForgeHostTemplates.ps1
new file mode 100644
index 00000000..19a5b05f
--- /dev/null
+++ b/scripts/Test-ForgeHostTemplates.ps1
@@ -0,0 +1,59 @@
+param(
+ [Parameter(Mandatory)][string]$ExecutablePath,
+ [Parameter(Mandatory)][string]$OutputDirectory
+)
+$ErrorActionPreference = 'Stop'
+$PSNativeCommandUseErrorActionPreference = $false
+$hostExecutable = (Resolve-Path -LiteralPath $ExecutablePath).Path
+$output = [IO.Path]::GetFullPath($OutputDirectory)
+if (Test-Path -LiteralPath $output) { throw 'Use a fresh Forge qualification directory.' }
+New-Item -ItemType Directory -Path $output | Out-Null
+
+function Invoke-Forge([string[]]$HostArguments, [string]$LogPath) {
+ $PSNativeCommandUseErrorActionPreference = $false
+ & $hostExecutable @HostArguments > $LogPath 2>&1
+ if ($LASTEXITCODE -ne 0) { throw "Forge failed ($LASTEXITCODE): $($HostArguments -join ' '). See $LogPath" }
+ return Get-Content -LiteralPath $LogPath -Raw | ConvertFrom-Json
+}
+
+$catalog = Invoke-Forge @('list') (Join-Path $output 'catalog.json')
+if ($catalog.protocolVersion -ne 1 -or $catalog.templates.Count -eq 0) { throw 'Forge did not expose the public template catalog.' }
+$rows = @()
+foreach ($template in $catalog.templates) {
+ $directory = Join-Path $output "template-$($rows.Count)"
+ New-Item -ItemType Directory -Path $directory | Out-Null
+ $description = Invoke-Forge @('describe', $template.id) (Join-Path $directory 'description.json')
+ if (@($description.parameters | Where-Object required).Count -ne 0) {
+ throw "Add an explicit qualification request for required parameters in $($template.id)."
+ }
+ $request = Join-Path $directory 'request.json'
+ @{ protocolVersion = 1; arguments = @{}; artifacts = @($description.artifacts) } | ConvertTo-Json -Depth 4 | Set-Content -LiteralPath $request
+ $result = Invoke-Forge @('invoke', $template.id, '--request', $request, '--out', $directory) (Join-Path $directory 'result.json')
+ if (-not $result.success -or $result.artifacts.Count -ne $description.artifacts.Count) { throw "Forge did not build all advertised artifacts for $($template.id). See $directory/result.json" }
+ foreach ($artifact in $result.artifacts) {
+ $path = Join-Path $directory $artifact.path
+ $file = Get-Item -LiteralPath $path
+ if ($file.Length -eq 0 -or $file.Length -ne $artifact.size -or (Get-FileHash -LiteralPath $path -Algorithm SHA256).Hash.ToLowerInvariant() -ne $artifact.sha256) {
+ throw "Forge artifact receipt mismatch for $($template.id): $($artifact.path)"
+ }
+ if ($artifact.kind -eq 'StepAp242' -and [IO.File]::ReadAllText($path) -notmatch '^ISO-10303-21;') {
+ throw "Forge did not emit STEP for $($template.id)."
+ }
+ }
+ $rows += [pscustomobject]@{ template = $template.id; artifacts = $result.artifacts; identity = $result.identity }
+ Write-Output "Qualified $($template.id)"
+}
+$rows | ConvertTo-Json -Depth 10 | Set-Content -LiteralPath (Join-Path $output 'summary.json')
+
+# A complete but physically invalid record must reach semantic rejection, not
+# crash on string binding or emit plausible fallback geometry.
+$invalidRequest = Join-Path $output 'invalid-standoff.json'
+[IO.File]::WriteAllText($invalidRequest, '{"protocolVersion":1,"arguments":{"P":{"OuterDiameter":"1mm","BoreDiameter":"4.2mm","Length":"25mm","Material":"Standard.Materials.StainlessSteel.304_Annealed"}},"artifacts":["StepAp242"]}')
+$invalidLog = Join-Path $output 'invalid-standoff-result.json'
+& $hostExecutable invoke Standard.Products.Mechanical.Standoff --request $invalidRequest --out (Join-Path $output 'invalid-artifacts') > $invalidLog 2>&1
+if ($LASTEXITCODE -ne 4) { throw "Invalid standoff did not return semantic rejection. See $invalidLog" }
+$invalid = Get-Content -LiteralPath $invalidLog -Raw | ConvertFrom-Json
+if ($invalid.success -or $invalid.artifacts.Count -ne 0 -or -not ($invalid.diagnostics.code -contains 'firmament-concept-requirement-failed')) {
+ throw "Invalid standoff did not preserve its semantic diagnostic and artifact refusal. See $invalidLog"
+}
+Write-Output "Qualified $($rows.Count) public Forge templates with their declared defaults."