Next Gen STEP AP242 Native-ish BREP Geometric Modeling Kernel
Move SDF display lowering into Fields
Yuechen Lieace02240a10
diff --git a/Aetheris.Continuum.Tests/Backends/Sdf/FieldProjectBoundaryTests.cs b/Aetheris.Continuum.Tests/Backends/Sdf/FieldProjectBoundaryTests.csnew file mode 100644index 00000000..42a9ae88--- /dev/null+++ b/Aetheris.Continuum.Tests/Backends/Sdf/FieldProjectBoundaryTests.cs@@ -0,0 +1,41 @@+using Aetheris.Continuum.Backends.Sdf;+using Aetheris.Kernel.Core.Math;++namespace Aetheris.Continuum.Tests.Backends.Sdf;++public sealed class FieldProjectBoundaryTests+{+ [Fact]+ public void Native_fields_have_one_owner_without_a_compiler_or_application_dependency()+ {+ var assembly = typeof(SdfNode).Assembly;+ Assert.Equal("Aetheris.Fields", assembly.GetName().Name);+ Assert.Equal(assembly, typeof(CirVisualTsLowerer).Assembly);+ string[] referenced = assembly.GetReferencedAssemblies().Select(item => item.Name!).ToArray();+ Assert.DoesNotContain(referenced, name => name.StartsWith("Copeland.", StringComparison.Ordinal));+ Assert.DoesNotContain("Aetheris.Continuum", referenced);+ Assert.DoesNotContain("Aetheris.Kernel.StandardLibrary", referenced);+ Assert.Contains("Aetheris.Kernel.Core", referenced);+ }++ [Fact]+ public void Continuum_preserves_existing_assembly_qualified_type_resolution()+ {+ var resolved = Type.GetType("Aetheris.Continuum.Backends.Sdf.SdfSphereNode, Aetheris.Continuum", throwOnError: true);+ Assert.Equal(typeof(SdfSphereNode), resolved);+ }++ [Fact]+ public void Safe_exterior_bound_is_distinct_from_exact_distance_and_retains_provenance()+ {+ var composed = new SdfSubtractNode(new SdfBoxNode(2, 2, 2), new SdfSphereNode(1));+ var result = CirVisualTsLowerer.Lower(composed);+ Assert.True(result.Success);+ Assert.True(result.Program!.ConservativeExteriorStep);+ Assert.Equal("AGPL-3.0-only", result.Program.SourceLicense);+ Assert.False(SdfCapabilityAnalyzer.Analyze(composed).HasFlag(SdfFieldCapabilities.ExactEuclideanSignedDistance));+ var scaled = CirVisualTsLowerer.Lower(new SdfTransformNode(composed, Transform3D.CreateScale(.5)));+ Assert.False(scaled.Success);+ Assert.Contains("transform-not-rigid", scaled.FallbackReason);+ }+}diff --git a/Aetheris.Continuum/Aetheris.Continuum.csproj b/Aetheris.Continuum/Aetheris.Continuum.csprojindex 3985f960..2567802f 100644--- a/Aetheris.Continuum/Aetheris.Continuum.csproj+++ b/Aetheris.Continuum/Aetheris.Continuum.csproj@@ -7,6 +7,7 @@</PropertyGroup><ItemGroup>+ <ProjectReference Include="..\Aetheris.Fields\Aetheris.Fields.csproj" /><ProjectReference Include="..\Aetheris.Kernel.Core\Aetheris.Kernel.Core.csproj" /><ProjectReference Include="..\Aetheris.Kernel.StandardLibrary\Aetheris.Kernel.StandardLibrary.csproj" /></ItemGroup>diff --git a/Aetheris.Continuum/SdfFieldForwarders.cs b/Aetheris.Continuum/SdfFieldForwarders.csnew file mode 100644index 00000000..420f31c6--- /dev/null+++ b/Aetheris.Continuum/SdfFieldForwarders.cs@@ -0,0 +1,33 @@+using System.Runtime.CompilerServices;+using Aetheris.Continuum.Backends.Sdf;++// Keep the original assembly entry points while field implementation has one owner.+[assembly: TypeForwardedTo(typeof(SdfNodeKind))]+[assembly: TypeForwardedTo(typeof(SdfBounds))]+[assembly: TypeForwardedTo(typeof(SdfNode))]+[assembly: TypeForwardedTo(typeof(SdfBoxNode))]+[assembly: TypeForwardedTo(typeof(SdfCylinderNode))]+[assembly: TypeForwardedTo(typeof(SdfConeNode))]+[assembly: TypeForwardedTo(typeof(SdfSphereNode))]+[assembly: TypeForwardedTo(typeof(SdfTorusNode))]+[assembly: TypeForwardedTo(typeof(SdfUnionNode))]+[assembly: TypeForwardedTo(typeof(SdfSubtractNode))]+[assembly: TypeForwardedTo(typeof(SdfIntersectNode))]+[assembly: TypeForwardedTo(typeof(SdfTransformNode))]+[assembly: TypeForwardedTo(typeof(SdfVolumeEstimator))]+[assembly: TypeForwardedTo(typeof(SdfTapeOpCode))]+[assembly: TypeForwardedTo(typeof(SdfTapeInstruction))]+[assembly: TypeForwardedTo(typeof(SdfTapeBoxPayload))]+[assembly: TypeForwardedTo(typeof(SdfTapeCylinderPayload))]+[assembly: TypeForwardedTo(typeof(SdfTapeSpherePayload))]+[assembly: TypeForwardedTo(typeof(SdfTapeTorusPayload))]+[assembly: TypeForwardedTo(typeof(SdfTapeConePayload))]+[assembly: TypeForwardedTo(typeof(FieldInterval))]+[assembly: TypeForwardedTo(typeof(SdfRegionClassification))]+[assembly: TypeForwardedTo(typeof(SdfTape))]+[assembly: TypeForwardedTo(typeof(SdfTapeLowerer))]+[assembly: TypeForwardedTo(typeof(SdfFieldCapabilities))]+[assembly: TypeForwardedTo(typeof(SdfCapabilityAnalyzer))]+[assembly: TypeForwardedTo(typeof(CirVisualTsProgram))]+[assembly: TypeForwardedTo(typeof(CirVisualTsLoweringResult))]+[assembly: TypeForwardedTo(typeof(CirVisualTsLowerer))]diff --git a/Aetheris.Fields/Aetheris.Fields.csproj b/Aetheris.Fields/Aetheris.Fields.csprojnew file mode 100644index 00000000..2fa6de49--- /dev/null+++ b/Aetheris.Fields/Aetheris.Fields.csproj@@ -0,0 +1,12 @@+<Project Sdk="Microsoft.NET.Sdk">+ <PropertyGroup>+ <TargetFramework>net10.0</TargetFramework>+ <Description>Native analytic SDF expressions, deterministic evaluation tape, and Visual TypeScript field source lowering. No application or shader compiler dependency.</Description>+ <PackageReadmeFile>Aetheris.Fields.README.md</PackageReadmeFile>+ </PropertyGroup>+ <ItemGroup>+ <ProjectReference Include="../Aetheris.Kernel.Core/Aetheris.Kernel.Core.csproj" />+ <None Include="../docs/public/fields.md" Pack="true" PackagePath="/Aetheris.Fields.README.md" />+ <None Include="../LICENSE" Pack="true" PackagePath="licenses/" />+ </ItemGroup>+</Project>diff --git a/Aetheris.Continuum/Backends/Sdf/CirVisualTsLowerer.cs b/Aetheris.Fields/CirVisualTsLowerer.cssimilarity index 94%rename from Aetheris.Continuum/Backends/Sdf/CirVisualTsLowerer.csrename to Aetheris.Fields/CirVisualTsLowerer.csindex 1ef50993..8fc689a2 100644--- a/Aetheris.Continuum/Backends/Sdf/CirVisualTsLowerer.cs+++ b/Aetheris.Fields/CirVisualTsLowerer.cs@@ -5,7 +5,13 @@ using Aetheris.Kernel.Core.Math;namespace Aetheris.Continuum.Backends.Sdf;-public sealed record CirVisualTsProgram(string StructuralHash, string FieldSource, SdfBounds Bounds);+public sealed record CirVisualTsProgram(string StructuralHash, string FieldSource, SdfBounds Bounds)+{+ // The admitted rigid primitive/Boolean family is 1-Lipschitz in source units.+ // This is an exterior stepping bound, not a promise of exact Euclidean distance.+ public bool ConservativeExteriorStep { get; internal init; }+ public string SourceLicense => "AGPL-3.0-only";+}public sealed record CirVisualTsLoweringResult(CirVisualTsProgram? Program, string? FallbackReason){@@ -15,7 +21,7 @@ public sealed record CirVisualTsLoweringResult(CirVisualTsProgram? Program, stri/// <summary>Specializes the existing CIR tape into Visual TypeScript source. No shader-side tape interpreter.</summary>public static class CirVisualTsLowerer{- public const string CompatibilityVersion = "cir-visual-ts/1";+ public const string CompatibilityVersion = "cir-visual-ts/2";public static CirVisualTsLoweringResult Lower(SdfNode root){@@ -27,7 +33,7 @@ public static class CirVisualTsLowerer}SdfTape tape = SdfTapeLowerer.Lower(root);var source = new StringBuilder();- source.AppendLine("function Field(x: f32, y: f32, z: f32): f32 {");+ source.AppendLine("export function Field(x: f32, y: f32, z: f32): f32 {");foreach (SdfTapeInstruction instruction in tape.Instructions){string value = instruction.OpCode switch@@ -43,7 +49,10 @@ public static class CirVisualTsLowerersource.AppendLine("}");string field = source.ToString().Replace("\r\n", "\n", StringComparison.Ordinal);string hash = Convert.ToHexString(SHA256.HashData(Encoding.UTF8.GetBytes(CompatibilityVersion + "\n" + field))).ToLowerInvariant();- return new(new CirVisualTsProgram(hash, field, root.Bounds), null);+ return new(new CirVisualTsProgram(hash, field, root.Bounds)+ {+ ConservativeExteriorStep = true,+ }, null);}private static string? Validate(SdfNode node)diff --git a/Aetheris.Continuum/Backends/Sdf/SdfFieldCapabilities.cs b/Aetheris.Fields/SdfFieldCapabilities.cssimilarity index 100%rename from Aetheris.Continuum/Backends/Sdf/SdfFieldCapabilities.csrename to Aetheris.Fields/SdfFieldCapabilities.csdiff --git a/Aetheris.Continuum/Backends/Sdf/SdfNode.cs b/Aetheris.Fields/SdfNode.cssimilarity index 100%rename from Aetheris.Continuum/Backends/Sdf/SdfNode.csrename to Aetheris.Fields/SdfNode.csdiff --git a/Aetheris.Continuum/Backends/Sdf/SdfNodes.cs b/Aetheris.Fields/SdfNodes.cssimilarity index 100%rename from Aetheris.Continuum/Backends/Sdf/SdfNodes.csrename to Aetheris.Fields/SdfNodes.csdiff --git a/Aetheris.Continuum/Backends/Sdf/SdfTape.cs b/Aetheris.Fields/SdfTape.cssimilarity index 100%rename from Aetheris.Continuum/Backends/Sdf/SdfTape.csrename to Aetheris.Fields/SdfTape.csdiff --git a/Aetheris.slnx b/Aetheris.slnxindex 6e608956..96034d1b 100644--- a/Aetheris.slnx+++ b/Aetheris.slnx@@ -27,6 +27,7 @@<Project Path="Aetheris.Modules.BuiltIn/Aetheris.Modules.BuiltIn.csproj" /><Project Path="Aetheris.Modules.Tests/Aetheris.Modules.Tests.csproj" /><Project Path="Aetheris.Continuum/Aetheris.Continuum.csproj" />+ <Project Path="Aetheris.Fields/Aetheris.Fields.csproj" /><Project Path="Aetheris.Collaboration/Aetheris.Collaboration.csproj" /><Project Path="Aetheris.Collaboration.Tests/Aetheris.Collaboration.Tests.csproj" /><Project Path="Aetheris.FEA/Aetheris.FEA.csproj" />diff --git a/docs/public/fields.md b/docs/public/fields.mdnew file mode 100644index 00000000..4a3b3517--- /dev/null+++ b/docs/public/fields.md@@ -0,0 +1,40 @@+# Aetheris.Fields++`Aetheris.Fields` owns analytic SDF expressions, their deterministic CPU evaluation+tape, capability declarations, and specialized Visual TypeScript field source.+Its only project dependency is `Aetheris.Kernel.Core`. It does not depend on+Continuum analysis, Firmament, Copeland, SQLite, the CAD application, or a renderer.++The existing `Aetheris.Continuum.Backends.Sdf` namespace is retained for source+compatibility. `Aetheris.Continuum` references this library and forwards the moved+public types for previously compiled callers. Broader CIR adapters, integration,+region planning and analysis remain in Continuum.++The source lowerer now exports `Field` as an importable VTS function. Its hash+domain is `cir-visual-ts/2`; rebuild retained v1 display/shader artifacts rather+than treating an old cache identity as a new program. The admitted exterior-step+flag is set by successful lowering, not by manually constructing a program.++Build or pack the small library directly:++```powershell+dotnet build Aetheris.Fields -c Release -m:1+dotnet pack Aetheris.Fields -c Release -o artifacts/local/field-packages+```++Building the complete Firmament/application stack still restores its explicitly+pinned `Copeland.TS.Backend.Wgsl` package family. That is a downstream display+compiler dependency, not a dependency of native fields. Applications consuming+only fields need no Copeland checkout or compiler packages.++The library is `AGPL-3.0-only`, as declared by Aetheris package metadata. Exported+field source specializes Aetheris implementation code; consumers must preserve its+AGPL provenance rather than treating generated shaders as a licence boundary.+Geometry data, third-party assets and application code retain their own licences.++`CirVisualTsLowerer` admits bounded primitives and rigid Boolean compositions.+It rejects nonrigid transforms explicitly. Exact Euclidean signed distance,+sign-correct occupancy and a conservative exterior step bound are different+properties: Boolean fields can provide safe exterior stepping without being+exact Euclidean distance everywhere. Floating-point error and ray-budget policies+belong to the consuming tracer and require validation in its coordinate range.diff --git a/docs/public/project-boundaries.md b/docs/public/project-boundaries.mdnew file mode 100644index 00000000..56f01abc--- /dev/null+++ b/docs/public/project-boundaries.md@@ -0,0 +1,44 @@+# Geometry, field and display-compiler boundaries++`Aetheris.Kernel.Core` owns native geometry and BRep operations and has no project+or package dependency. `Aetheris.Fields` owns the analytic field expression tree,+deterministic evaluator tape, capability analysis and Visual TypeScript source+lowering. It depends only on Core. Both are AGPL-3.0-only libraries.++`Aetheris.Continuum` owns broader analysis, discretization and solver coordination.+It consumes Fields and retains the existing public field namespace and assembly+type forwarding. `Aetheris.Kernel.Firmament` owns authoring and display-artifact+coordination; its shader compiler is the pinned Copeland WGSL backend.++The current backend pin is `0.1.0-preview.1-a3.16c0ce996358af80`. Its seven NuGet+packages are Copeland.Markdown, Copeland.Profile, Copeland.SpanAllocation,+Copeland.TS, Copeland.TS.Mir, Copeland.TS.Workspace and Copeland.TS.Backend.Wgsl.+They are package dependencies for this downstream display path, not embedded+Copeland source projects or a dependency of native field evaluation. Building+the complete application restores them; packaging Fields/Core does not.++Consumers that need fields should reference `Aetheris.Fields`, not Continuum or+Firmament. See [fields](fields.md) for the package build, numerical admission and+source provenance contracts. GPU compilation remains the consuming renderer's+responsibility; Fields emits VTS source without depending on a shader compiler.++## Licence composition++Aetheris components retain AGPL-3.0-only. Copeland packages retain their own GPL+grants; no extraction here changes those licences. [GPLv3 section 13](https://www.gnu.org/licenses/gpl-3.0.html#section13)+and [AGPLv3 section 13](https://www.gnu.org/licenses/agpl-3.0.html#section13) allow+their combination. Each part retains its licence; corresponding-source and+notice requirements apply to conveyed combined builds, and AGPL's network-source+clause applies to the combination where its conditions are met.++Analytic shader implementation emitted from the field evaluator is conservatively+treated as AGPL-derived. Its provenance is retained with the generated source.+Artist assets and authored geometry descriptions retain their own terms; this+does not assert that all CAD exports acquire AGPL. A package/shader bake is not+a mechanism for silently removing the evaluator's licence boundary.++Aurelian's optional package adapter lives in Copeland at+`src/Integrations/Aurelian.Lighting.Aetheris`. Its own adapter/tracing source is+GPL, and the Aetheris dependency/emitted evaluator is AGPL. Aurelian's core does+not acquire a direct CAD project dependency. Existing humanoid and full bake+development bridges have separate, explicit source-checkout dependencies.