Next Gen STEP AP242 Native-ish BREP Geometric Modeling Kernel
Add gear inspection and B-spline STEP export support
Yuechen Li05f359c9fe40
diff --git a/Aetheris.CLI.Tests/GearLibraryCliTests.cs b/Aetheris.CLI.Tests/GearLibraryCliTests.csnew file mode 100644index 00000000..bc8f5f24--- /dev/null+++ b/Aetheris.CLI.Tests/GearLibraryCliTests.cs@@ -0,0 +1,47 @@+using System.Text.Json;++namespace Aetheris.CLI.Tests;++public sealed class GearLibraryCliTests+{+ [Fact]+ public void EveryInvalidGearFixtureIsRejectedByTheRealCli()+ {+ var directory = Path.Combine(RepoRoot(), "fixtures", "Invalid", "Gears");+ foreach (var fixture in Directory.GetFiles(directory, "*.firmament").Order(StringComparer.Ordinal))+ {+ var output = new StringWriter(); var error = new StringWriter();+ Assert.Equal(1, CliRunner.Run(["validate", fixture, "--json"], output, error));+ Assert.Contains("firmament-gear-", output.ToString(), StringComparison.Ordinal);+ }+ }++ [Fact]+ public void BuildInspectAndValidateExposeGearEvidence()+ {+ var fixture = Path.Combine(RepoRoot(), "fixtures", "Canonical", "Gears", "spur-basic.firmament");+ var step = Path.Combine(Path.GetTempPath(), $"aetheris-gear-{Guid.NewGuid():N}.step");+ try+ {+ var build = new StringWriter(); var buildError = new StringWriter();+ Assert.Equal(0, CliRunner.Run(["build", fixture, "--out", step, "--json"], build, buildError)); Assert.Empty(buildError.ToString());+ using (var json = JsonDocument.Parse(build.ToString()))+ {+ var report = json.RootElement.GetProperty("gear"); Assert.True(report.GetProperty("stepReimportedManifold").GetBoolean());+ Assert.Equal("SpurGear", report.GetProperty("gears")[0].GetProperty("family").GetString());+ }+ var inspect = new StringWriter(); Assert.Equal(0, CliRunner.Run(["inspect", fixture, "--json"], inspect, new StringWriter()));+ using (var json = JsonDocument.Parse(inspect.ToString())) Assert.Equal("GearLibrary", json.RootElement.GetProperty("domain").GetString());+ var validate = new StringWriter(); Assert.Equal(0, CliRunner.Run(["validate", fixture, "--json"], validate, new StringWriter()));+ using var validation = JsonDocument.Parse(validate.ToString()); Assert.Equal("valid", validation.RootElement.GetProperty("firmamentV2Validation").GetProperty("status").GetString());+ }+ finally { if (File.Exists(step)) File.Delete(step); }+ }++ private static string RepoRoot()+ {+ var directory = new DirectoryInfo(AppContext.BaseDirectory);+ while (directory is not null && !File.Exists(Path.Combine(directory.FullName, "Aetheris.slnx"))) directory = directory.Parent;+ return directory?.FullName ?? throw new DirectoryNotFoundException();+ }+}diff --git a/Aetheris.CLI/CliRunner.cs b/Aetheris.CLI/CliRunner.csindex dd2f3c36..7fc1a466 100644--- a/Aetheris.CLI/CliRunner.cs+++ b/Aetheris.CLI/CliRunner.cs@@ -511,6 +511,7 @@ public static class CliRunnerpatterns = build.Value.Export.Patterns,structural = build.Value.Export.Structural,piping = build.Value.Export.Piping,+ gear = build.Value.Export.Gear,featureCount = (build.Value.Export.Features?.Count ?? 0) + (build.Value.Export.EngineeringFeatures?.Count ?? 0),inlineStepMigration = build.Value.Export.InlineStepMigration,inlineStepReplacementAssist = build.Value.Export.InlineStepReplacementAssist,@@ -537,6 +538,8 @@ public static class CliRunnerstdout.WriteLine($"Structure: {structure.Members.Count} members, {structure.Joints.Count} joints, {structure.CutList.Count} cut-list groups; cut list: {structure.CutListArtifactPath}");if (build.Value.Export.Piping is { } piping)stdout.WriteLine($"Piping system: {piping.Connections.Count} connections, {piping.Routes.Count} routes, {piping.PipeSegments.Count} pipe segments, {piping.Fittings.Count} fittings, {piping.Nozzles.Count} equipment nozzles, {piping.Mates.Count} endpoint mates; routing report: {piping.RoutingReportArtifactPath}");+ if (build.Value.Export.Gear is { } gear)+ stdout.WriteLine($"Gear: {gear.Gears[0].Family} {gear.Gears[0].Name}, {gear.Gears[0].Teeth?.ToString() ?? "n/a"} teeth ({gear.Representation})");foreach (var diagnostic in build.Diagnostics.Where(diagnostic => diagnostic.Severity == KernelDiagnosticSeverity.Warning))stderr.WriteLine($"- [Warning] {diagnostic.Source}: {diagnostic.Message}");}@@ -1411,6 +1414,33 @@ Model CanonicalPanel {else foreach (var diagnostic in section.Diagnostics) stderr.WriteLine("error: " + diagnostic);return section.IsSuccess ? 0 : 1;}+ if (GearAuthoring.IsGearSource(source))+ {+ var gear = GearAuthoring.Parse(source);+ var payload = new+ {+ command = "inspect", success = gear.IsSuccess, input = fullPath, domain = "GearLibrary", model = gear.ModelName, units = "mm",+ gears = gear.Gears.Select(item => new+ {+ item.Name, family = item.Family.ToString(), item.Teeth, module = item.ModuleMm,+ pressureAngle = item.PressureAngleDegrees, pitchDiameter = item.PitchDiameterMm,+ baseDiameter = item.BaseDiameterMm, outsideDiameter = item.AddendumDiameterMm,+ rootDiameter = item.RootDiameterMm, faceWidth = item.FaceWidthMm, boreDiameter = item.BoreDiameterMm,+ axis = item.Axis, phase = item.PhaseDegrees, backlash = item.BacklashMm,+ pitchConeAngle = item.PitchConeAngleDegrees,+ stableToothIds = item.Teeth is { } count ? Enumerable.Range(0, count).Select(index => $"{item.Name}.Tooth{index}") : []+ }),+ interfaces = gear.Interfaces.Select(item => new { item.Name, gearA = item.A.Name, gearB = item.B.Name, item.Kind, item.Compatible,+ expectedCenterDistance = item.ExpectedCenterDistanceMm, item.Ratio, item.RotationSign,+ item.AxisRelation, shaftAngle = item.ShaftAngleDegrees, engagementPhase = item.EngagementPhaseDegrees,+ item.AllowedDirection, item.RejectionReasons }),+ diagnostics = gear.Diagnostics+ };+ if (json) stdout.WriteLine(JsonSerializer.Serialize(payload, JsonOptions));+ else if (gear.IsSuccess) foreach (var item in gear.Gears) stdout.WriteLine($"{item.Family} {item.Name}: {item.Teeth?.ToString() ?? "n/a"} teeth, pitch diameter {item.PitchDiameterMm?.ToString("G12") ?? "n/a"} mm");+ else foreach (var diagnostic in gear.Diagnostics) stderr.WriteLine("error: " + diagnostic);+ return gear.IsSuccess ? 0 : 1;+ }var library = FirmamentStandardLibraryResolver.Resolve(source, out var libraryDiagnostics);var inspectionSource = library?.Source ?? source;var sweepSource = ExpandSweepInspectionSource(source, out var sweepExpansionDiagnostics);@@ -2261,6 +2291,16 @@ Model CanonicalPanel {else stdout.WriteLine($"Firmament V2 SectionChain validation: {payload.status} ({payload.summary.fatalDiagnosticCount} fatal, 0 warning)");return section.IsSuccess ? 0 : 1;}+ if (GearAuthoring.IsGearSource(validationSource))+ {+ var gear = GearAuthoring.Parse(validationSource);+ var payload = new { source = sourcePath, status = gear.IsSuccess ? "valid" : "invalid", domain = "GearLibrary",+ summary = new { fatalDiagnosticCount = gear.Diagnostics.Count, warningDiagnosticCount = 0, gears = gear.Gears.Count, interfaces = gear.Interfaces.Count },+ gears = gear.Gears, interfaces = gear.Interfaces, diagnostics = gear.Diagnostics };+ if (json) stdout.WriteLine(JsonSerializer.Serialize(new { firmamentV2Validation = payload }, JsonOptions));+ else stdout.WriteLine($"Firmament Gear validation: {payload.status} ({payload.summary.fatalDiagnosticCount} fatal, 0 warning)");+ return gear.IsSuccess ? 0 : 1;+ }if (RevolveAuthoringParser.IsRevolveSource(validationSource)){var revolve = RevolveAuthoringParser.Parse(validationSource, out var bindDiagnostics);diff --git a/Aetheris.Kernel.Core/Step242/Step242Exporter.cs b/Aetheris.Kernel.Core/Step242/Step242Exporter.csindex 171bef74..fac688d5 100644--- a/Aetheris.Kernel.Core/Step242/Step242Exporter.cs+++ b/Aetheris.Kernel.Core/Step242/Step242Exporter.cs@@ -819,6 +819,25 @@ public static class Step242Exporterreturn KernelResult<string>.Success(writer.AddEntity("HYPERBOLA", "$", Step242TextWriter.Ref(axisPlacementId), Step242TextWriter.Number(hyperbola.SemiAxisA), Step242TextWriter.Number(hyperbola.SemiAxisB)));}+ if (curve.Kind == CurveGeometryKind.BSpline3 && curve.BSpline3 is BSpline3Curve spline)+ {+ var controlPointIds = spline.ControlPoints+ .Select(point => writer.AddEntity("CARTESIAN_POINT", "$", PointList(point)))+ .Select(Step242TextWriter.Ref)+ .ToArray();+ return KernelResult<string>.Success(writer.AddEntity(+ "B_SPLINE_CURVE_WITH_KNOTS",+ "$",+ spline.Degree.ToString(System.Globalization.CultureInfo.InvariantCulture),+ Step242TextWriter.List(controlPointIds),+ Step242TextWriter.Enum(spline.CurveForm),+ Step242TextWriter.BooleanLogical(spline.ClosedCurve),+ Step242TextWriter.BooleanLogical(spline.SelfIntersect),+ Step242TextWriter.List(spline.KnotMultiplicities.Select(value => value.ToString(System.Globalization.CultureInfo.InvariantCulture)).ToArray()),+ Step242TextWriter.List(spline.KnotValues.Select(Step242TextWriter.Number).ToArray()),+ Step242TextWriter.Enum(spline.KnotSpec)));+ }+return Failure($"Unsupported swept directrix curve kind '{curve.Kind}'.", source);}diff --git a/Aetheris.Kernel.Core/Step242/Step242SubsetDecoder.cs b/Aetheris.Kernel.Core/Step242/Step242SubsetDecoder.csindex 6690491e..c7b59941 100644--- a/Aetheris.Kernel.Core/Step242/Step242SubsetDecoder.cs+++ b/Aetheris.Kernel.Core/Step242/Step242SubsetDecoder.cs@@ -329,6 +329,16 @@ internal static class Step242SubsetDecoder: KernelResult<CurveGeometry>.Success(CurveGeometry.FromHyperbola(hyperbolaResult.Value));}+ var splineConstructor = TryGetConstructor(curveEntity.Instance, "B_SPLINE_CURVE_WITH_KNOTS");+ if (splineConstructor is not null)+ {+ var splineResult = ReadBSplineCurveWithKnots(document,+ new Step242ParsedEntity(curveEntity.Id, new Step242SimpleEntityInstance(splineConstructor)));+ return !splineResult.IsSuccess+ ? KernelResult<CurveGeometry>.Failure(splineResult.Diagnostics)+ : KernelResult<CurveGeometry>.Success(CurveGeometry.FromBSpline(splineResult.Value));+ }+return Failure<CurveGeometry>($"{context}: directrix curve '{curveEntity.Name}' is unsupported.", source);}diff --git a/Aetheris.Kernel.Firmament.Tests/GearLibraryX0Tests.cs b/Aetheris.Kernel.Firmament.Tests/GearLibraryX0Tests.csnew file mode 100644index 00000000..aa5a171f--- /dev/null+++ b/Aetheris.Kernel.Firmament.Tests/GearLibraryX0Tests.cs@@ -0,0 +1,85 @@+using Aetheris.Kernel.Firmament.FirmamentV2;++namespace Aetheris.Kernel.Firmament.Tests;++public sealed class GearLibraryX0Tests+{+ [Fact]+ public void SpurGearOwnsStandardGeometryAndDeterministicStep()+ {+ var source = Fixture("Canonical", "Gears", "spur-basic.firmament");+ var document = GearAuthoring.Parse(File.ReadAllText(source));+ var gear = Assert.Single(document.Gears);+ Assert.True(document.IsSuccess); Assert.Equal(48d, gear.PitchDiameterMm); Assert.Equal(52d, gear.AddendumDiameterMm);+ Assert.Equal(43d, gear.RootDiameterMm); Assert.Equal(48d * Math.Cos(20d * Math.PI / 180d), gear.BaseDiameterMm!.Value, 10);++ var first = FirmamentBuildAndExport.CompileSource(File.ReadAllText(source));+ var second = FirmamentBuildAndExport.CompileSource(File.ReadAllText(source));+ Assert.True(first.IsSuccess); Assert.True(second.IsSuccess);+ Assert.Equal(first.Value!.Gear!.StepSha256, second.Value!.Gear!.StepSha256);+ Assert.True(first.Value.Gear.EnclosedManifold); Assert.True(first.Value.Gear.StepReimportedManifold);+ Assert.Equal(96, first.Value.Gear.Gears[0].InvoluteSpanCount);+ Assert.True(first.Value.Gear.Gears[0].MaximumInvoluteApproximationError < .002d);+ Assert.Contains("B_SPLINE_CURVE_WITH_KNOTS", first.Value.StepText, StringComparison.Ordinal);+ }++ [Theory]+ [InlineData("internal-spur-basic.firmament", "InternalSpurGear", 100)]+ [InlineData("bevel-basic.firmament", "BevelGear", 45)]+ [InlineData("miter-basic.firmament", "MiterGear", 20)]+ [InlineData("ratchet-basic.firmament", "RatchetGear", 60)]+ [InlineData("pawl-basic.firmament", "Pawl", null)]+ public void CanonicalFamiliesMaterializeAndReimport(string file, string family, int? teeth)+ {+ var source = File.ReadAllText(Fixture("Canonical", "Gears", file));+ var result = FirmamentBuildAndExport.CompileSource(source);+ Assert.True(result.IsSuccess, string.Join(Environment.NewLine, result.Diagnostics.Select(item => item.Message)));+ var report = result.Value!.Gear!; var item = Assert.Single(report.Gears);+ Assert.Equal(family, item.Family); Assert.Equal(teeth, item.Teeth);+ Assert.True(report.EnclosedManifold); Assert.True(report.StepReimportSucceeded); Assert.True(report.StepReimportedManifold);+ if (family is "BevelGear" or "MiterGear") { Assert.True(report.Cones > 0); Assert.True(report.BSplineSurfaces > 0); }+ if (family == "InternalSpurGear") Assert.True(item.MaximumInvoluteApproximationError < .00001d);+ }++ [Theory]+ [InlineData("spur-pair.firmament", "ExternalExternal", 72d, -1, 0.5d)]+ [InlineData("internal-spur-pair.firmament", "ExternalInternal", 20d, 1, 1d / 3d)]+ [InlineData("bevel-pair.firmament", "Bevel", null, -1, .5d)]+ [InlineData("miter-pair.firmament", "Bevel", null, -1, 1d)]+ [InlineData("ratchet-pawl.firmament", "RatchetPawl", null, 0, null)]+ public void InterfacesExposeCompatibilityMath(string file, string kind, double? center, int sign, double? ratio)+ {+ var document = GearAuthoring.Parse(File.ReadAllText(Fixture("Canonical", "GearInterfaces", file)));+ Assert.True(document.IsSuccess, string.Join(Environment.NewLine, document.Diagnostics));+ var mesh = Assert.Single(document.Interfaces); Assert.True(mesh.Compatible); Assert.Equal(kind, mesh.Kind);+ Assert.Equal(center, mesh.ExpectedCenterDistanceMm); Assert.Equal(sign, mesh.RotationSign); Assert.Equal(ratio, mesh.Ratio);+ if (kind == "Bevel") { Assert.Equal(90d, mesh.ShaftAngleDegrees); Assert.Equal("Intersecting:90deg", mesh.AxisRelation); }+ else if (kind == "RatchetPawl") { Assert.Equal("Clockwise", mesh.AllowedDirection); Assert.Equal(2d, mesh.EngagementPhaseDegrees); Assert.Equal("EngagementPlane", mesh.AxisRelation); }+ else Assert.Equal("Parallel", mesh.AxisRelation);+ }++ [Theory]+ [InlineData("zero-module.firmament", "firmament-gear-module-invalid")]+ [InlineData("zero-teeth.firmament", "firmament-gear-teeth-invalid")]+ [InlineData("bore-too-large.firmament", "firmament-gear-bore-too-large")]+ [InlineData("internal-ring-too-small.firmament", "firmament-gear-internal-outside-diameter-too-small")]+ [InlineData("incompatible-pair.firmament", "module-mismatch")]+ [InlineData("zero-face-width.firmament", "face-width-invalid")]+ [InlineData("incompatible-pressure-angle.firmament", "pressure-angle-mismatch")]+ [InlineData("impossible-internal-pair.firmament", "internal-tooth-count-not-greater")]+ [InlineData("invalid-bevel-pair.firmament", "pitch-cones-do-not-close")]+ [InlineData("invalid-ratchet.firmament", "ratchet-teeth-below-qualified-range")]+ public void InvalidFixturesHaveTypedDiagnostics(string file, string fragment)+ {+ var document = GearAuthoring.Parse(File.ReadAllText(Fixture("Invalid", "Gears", file)));+ Assert.False(document.IsSuccess); Assert.Contains(document.Diagnostics, item => item.Contains(fragment, StringComparison.Ordinal));+ }++ private static string Fixture(params string[] path) => Path.Combine([RepoRoot(), "fixtures", .. path]);+ private static string RepoRoot()+ {+ var directory = new DirectoryInfo(AppContext.BaseDirectory);+ while (directory is not null && !File.Exists(Path.Combine(directory.FullName, "Aetheris.slnx"))) directory = directory.Parent;+ return directory?.FullName ?? throw new DirectoryNotFoundException();+ }+}diff --git a/Aetheris.Kernel.Firmament/FirmamentBuildAndExport.cs b/Aetheris.Kernel.Firmament/FirmamentBuildAndExport.csindex b2e9d00d..90369501 100644--- a/Aetheris.Kernel.Firmament/FirmamentBuildAndExport.cs+++ b/Aetheris.Kernel.Firmament/FirmamentBuildAndExport.cs@@ -264,6 +264,10 @@ public static class FirmamentBuildAndExportbool allowV1Compatibility = false,FirmamentFrontendSchema? explicitSchema = null){+ if (GearAuthoring.IsGearSource(sourceText))+ {+ return ExportGearSource(sourceText);+ }if (explicitSchema == FirmamentFrontendSchema.SectionChain){var authored = SectionChainAuthoringParser.Compile(sourceText);@@ -629,6 +633,55 @@ public static class FirmamentBuildAndExportreturn ExportV1CompatibilitySource(sourceText);}+ private static KernelResult<FirmamentStepExportResult> ExportGearSource(string sourceText)+ {+ var authored = GearAuthoring.Parse(sourceText);+ if (!authored.IsSuccess)+ return KernelResult<FirmamentStepExportResult>.Failure(authored.Diagnostics.Select(message => new Kernel.Core.Diagnostics.KernelDiagnostic(+ Kernel.Core.Diagnostics.KernelDiagnosticCode.ValidationFailed, Kernel.Core.Diagnostics.KernelDiagnosticSeverity.Error,+ message, "Firmament.GearAir")).ToArray());+ if (authored.Gears.Count != 1)+ return KernelResult<FirmamentStepExportResult>.Failure([new Kernel.Core.Diagnostics.KernelDiagnostic(+ Kernel.Core.Diagnostics.KernelDiagnosticCode.ValidationFailed, Kernel.Core.Diagnostics.KernelDiagnosticSeverity.Error,+ $"{GearAuthoring.Prefix}build-body-count-invalid:expected=1:actual={authored.Gears.Count}:use-Assembly-for-a-gear-train",+ "Firmament.GearAir")]);+ var gear = authored.Gears[0];+ var materialized = GearAuthoring.Materialize(gear, out var materializationDiagnostics);+ if (materialized is null)+ return KernelResult<FirmamentStepExportResult>.Failure(materializationDiagnostics.Select(message => new Kernel.Core.Diagnostics.KernelDiagnostic(+ Kernel.Core.Diagnostics.KernelDiagnosticCode.ValidationFailed, Kernel.Core.Diagnostics.KernelDiagnosticSeverity.Error,+ message, "Firmament.GearBRep")).ToArray());+ var step = Step242Exporter.ExportBody(materialized.Body, new Step242ExportOptions+ {+ ProductName = gear.Name,+ ApplicationName = "Aetheris.Firmament.GearLibrary.X0"+ });+ if (!step.IsSuccess || step.Value is null) return KernelResult<FirmamentStepExportResult>.Failure(step.Diagnostics);+ var reimport = Step242Importer.ImportBody(step.Value);+ var reimportedManifold = reimport.IsSuccess && reimport.Value is not null && FirmamentManifoldChecker.IsManifold(reimport.Value);+ if (!reimportedManifold)+ return KernelResult<FirmamentStepExportResult>.Failure(reimport.Diagnostics.Append(new Kernel.Core.Diagnostics.KernelDiagnostic(+ Kernel.Core.Diagnostics.KernelDiagnosticCode.ValidationFailed, Kernel.Core.Diagnostics.KernelDiagnosticSeverity.Error,+ $"{GearAuthoring.Prefix}step-reimport-not-manifold:{gear.Name}", "Firmament.GearBRep")).ToArray());+ var surfaces = materialized.Body.Topology.Faces.Select(face => materialized.Body.GetFaceSurface(face.Id).Kind).ToArray();+ var item = new FirmamentGearItemReport(gear.Name, gear.Family.ToString(), gear.Teeth, gear.ModuleMm, gear.PressureAngleDegrees,+ gear.PitchDiameterMm, gear.BaseDiameterMm, gear.AddendumDiameterMm, gear.RootDiameterMm, gear.FaceWidthMm,+ gear.BoreDiameterMm, gear.PhaseDegrees, gear.BacklashMm, gear.PitchConeAngleDegrees, gear.Axis,+ materialized.ToothProfileCurveCount, materialized.InvoluteSpanCount, materialized.MaximumInvoluteApproximationErrorMm,+ materialized.ToothConstruction, materialized.StableToothIds);+ var interfaces = authored.Interfaces.Select(value => new FirmamentGearInterfaceReport(value.Name, value.A.Name, value.B.Name,+ value.Kind, value.Compatible, value.ExpectedCenterDistanceMm, value.Ratio, value.RotationSign,+ value.AxisRelation, value.ShaftAngleDegrees, value.EngagementPhaseDegrees, value.AllowedDirection, value.RejectionReasons)).ToArray();+ var hash = Convert.ToHexString(SHA256.HashData(Encoding.UTF8.GetBytes(step.Value))).ToLowerInvariant();+ var report = new FirmamentGearReport(authored.ModelName, [item], interfaces,+ materialized.Body.Topology.Vertices.Count(), materialized.Body.Topology.Edges.Count(), materialized.Body.Topology.Faces.Count(),+ surfaces.Count(kind => kind == SurfaceGeometryKind.Plane), surfaces.Count(kind => kind == SurfaceGeometryKind.Cylinder),+ surfaces.Count(kind => kind == SurfaceGeometryKind.Cone), surfaces.Count(kind => kind == SurfaceGeometryKind.BSplineSurfaceWithKnots),+ surfaces.Count(kind => kind == SurfaceGeometryKind.LinearExtrusion), FirmamentManifoldChecker.IsManifold(materialized.Body),+ true, true, hash, "DeterministicExactBRepAP242", gear.Family is GearFamily.BevelGear or GearFamily.MiterGear ? "BoundedStraightBevel" : "QualifiedX0");+ return KernelResult<FirmamentStepExportResult>.Success(new(step.Value, $"gear:{gear.Name}", 0, "gear", gear.Family.ToString(), Gear: report));+ }+private static FirmamentV2ParseResult ParseSemanticSource(string source, string? sourceDirectory)=> FirmamentV2Parser.Parse(source, sourceDirectory);diff --git a/Aetheris.Kernel.Firmament/FirmamentStepExportResult.cs b/Aetheris.Kernel.Firmament/FirmamentStepExportResult.csindex eec322fc..4c65d5a4 100644--- a/Aetheris.Kernel.Firmament/FirmamentStepExportResult.cs+++ b/Aetheris.Kernel.Firmament/FirmamentStepExportResult.cs@@ -27,7 +27,64 @@ public sealed record FirmamentStepExportResult(IReadOnlyList<FirmamentSemanticPatternReport>? Patterns = null,Aetheris.Kernel.Firmament.Structural.StructuralReport? Structural = null,Aetheris.Kernel.Firmament.Piping.PipingReport? Piping = null,- FirmamentRevolveReport? Revolve = null);+ FirmamentRevolveReport? Revolve = null,+ FirmamentGearReport? Gear = null);++public sealed record FirmamentGearItemReport(+ string Name,+ string Family,+ int? Teeth,+ double? Module,+ double? PressureAngle,+ double? PitchDiameter,+ double? BaseDiameter,+ double? OutsideDiameter,+ double? RootDiameter,+ double FaceWidth,+ double BoreDiameter,+ double Phase,+ double Backlash,+ double? PitchConeAngle,+ IReadOnlyList<double> Axis,+ int ToothProfileCurveCount,+ int InvoluteSpanCount,+ double MaximumInvoluteApproximationError,+ string ToothConstruction,+ IReadOnlyList<string> StableToothIds);++public sealed record FirmamentGearInterfaceReport(+ string Name,+ string GearA,+ string GearB,+ string Kind,+ bool Compatible,+ double? ExpectedCenterDistance,+ double? Ratio,+ int RotationSign,+ string AxisRelation,+ double? ShaftAngle,+ double? EngagementPhase,+ string? AllowedDirection,+ IReadOnlyList<string> RejectionReasons);++public sealed record FirmamentGearReport(+ string Model,+ IReadOnlyList<FirmamentGearItemReport> Gears,+ IReadOnlyList<FirmamentGearInterfaceReport> Interfaces,+ int Vertices,+ int Edges,+ int Faces,+ int Planes,+ int Cylinders,+ int Cones,+ int BSplineSurfaces,+ int LinearExtrusionSurfaces,+ bool EnclosedManifold,+ bool StepReimportSucceeded,+ bool StepReimportedManifold,+ string StepSha256,+ string Representation,+ string Qualification);public sealed record FirmamentRevolveReport(string Profile, string Axis, double SweepRadians, double SweepDegrees, string? Alias,diff --git a/Aetheris.Kernel.Firmament/FirmamentV2/GearAuthoring.cs b/Aetheris.Kernel.Firmament/FirmamentV2/GearAuthoring.csnew file mode 100644index 00000000..51d39e91--- /dev/null+++ b/Aetheris.Kernel.Firmament/FirmamentV2/GearAuthoring.cs@@ -0,0 +1,527 @@+using System.Globalization;+using System.Text.RegularExpressions;+using Aetheris.Kernel.Core.Brep;+using Aetheris.Kernel.Core.Geometry;+using Aetheris.Kernel.Core.Geometry.Curves;+using Aetheris.Kernel.Core.Geometry.Surfaces;+using Aetheris.Kernel.Core.Math;+using Aetheris.Kernel.Firmament.Materializer;++namespace Aetheris.Kernel.Firmament.FirmamentV2;++public enum GearFamily+{+ SpurGear,+ InternalSpurGear,+ BevelGear,+ MiterGear,+ RatchetGear,+ Pawl+}++/// <summary>Finite typed gear AIR. Product details such as hubs remain optional descendants.</summary>+public sealed record GearAir(+ string Name,+ GearFamily Family,+ double? ModuleMm,+ int? Teeth,+ double? PressureAngleDegrees,+ double FaceWidthMm,+ double BoreDiameterMm,+ double PhaseDegrees,+ double BacklashMm,+ double? OutsideDiameterMm,+ double? PitchConeAngleDegrees,+ double? HubDiameterMm,+ double? HubLengthMm,+ double? WidthMm,+ double? LengthMm,+ double? PivotDiameterMm,+ double? NoseLengthMm,+ double? EngagementAngleDegrees,+ double? DriveFaceAngleDegrees,+ IReadOnlyList<double> Axis,+ FirmamentV2SourceSpan SourceSpan)+{+ public double? PitchDiameterMm => ModuleMm is { } module && Teeth is { } teeth ? module * teeth : null;+ public double? PitchRadiusMm => PitchDiameterMm / 2d;+ public double? BaseDiameterMm => PitchDiameterMm is { } pitch && PressureAngleDegrees is { } pressure+ ? pitch * Math.Cos(pressure * Math.PI / 180d) : null;+ public double? AddendumDiameterMm => Family switch+ {+ GearFamily.SpurGear or GearFamily.BevelGear or GearFamily.MiterGear when PitchDiameterMm is { } pitch && ModuleMm is { } module => pitch + 2d * module,+ GearFamily.InternalSpurGear when PitchDiameterMm is { } pitch && ModuleMm is { } module => pitch - 2d * module,+ _ => OutsideDiameterMm+ };+ public double? RootDiameterMm => Family switch+ {+ GearFamily.SpurGear or GearFamily.BevelGear or GearFamily.MiterGear when PitchDiameterMm is { } pitch && ModuleMm is { } module => pitch - 2.5d * module,+ GearFamily.InternalSpurGear when PitchDiameterMm is { } pitch && ModuleMm is { } module => pitch + 2.5d * module,+ _ => null+ };+}++/// <summary>A typed semantic relationship between two subjects of the same authoring domain.</summary>+public sealed record InterfaceAir<T>(+ string Name,+ T A,+ T B,+ string Kind,+ bool Compatible,+ double? ExpectedCenterDistanceMm,+ double? Ratio,+ int RotationSign,+ string AxisRelation,+ double? ShaftAngleDegrees,+ double? EngagementPhaseDegrees,+ string? AllowedDirection,+ IReadOnlyList<string> RejectionReasons,+ FirmamentV2SourceSpan SourceSpan);++public sealed record GearAuthoringDocument(+ string ModelName,+ IReadOnlyList<GearAir> Gears,+ IReadOnlyList<InterfaceAir<GearAir>> Interfaces,+ IReadOnlyList<string> Diagnostics)+{+ public bool IsSuccess => Diagnostics.Count == 0;+}++public sealed record GearMaterialization(+ BrepBody Body,+ int ToothProfileCurveCount,+ int InvoluteSpanCount,+ double MaximumInvoluteApproximationErrorMm,+ string ToothConstruction,+ IReadOnlyList<string> StableToothIds);++/// <summary>+/// Built-in gear family binding and Gear AIR lowering. The author supplies engineering+/// parameters; this compiler-owned implementation constructs and radially replicates teeth.+/// </summary>+public static class GearAuthoring+{+ public const string Prefix = "firmament-gear-";+ private const double Tol = 1e-9;+ private static readonly Regex Header = new(+ @"\b(?<family>SpurGear|InternalSpurGear|BevelGear|MiterGear|RatchetGear|Pawl)\s+(?<name>[A-Za-z_]\w*)\s*\{",+ RegexOptions.CultureInvariant);+ private static readonly Regex InterfaceHeader = new(+ @"\bInterface\s*<\s*Gear\s*>\s+(?<name>[A-Za-z_]\w*)\s*\{",+ RegexOptions.CultureInvariant);++ public static bool IsGearSource(string source) => Header.IsMatch(source) || InterfaceHeader.IsMatch(source);++ public static GearAuthoringDocument Parse(string source)+ {+ ArgumentNullException.ThrowIfNull(source);+ var diagnostics = new List<string>();+ var modelMatch = Regex.Match(source, @"\bModel\s+(?<name>[A-Za-z_]\w*)\s*\{", RegexOptions.CultureInvariant);+ var modelName = modelMatch.Success ? modelMatch.Groups["name"].Value : "GearModel";+ if (!Regex.IsMatch(source, @"\bUnits\s*:\s*mm\b", RegexOptions.CultureInvariant))+ diagnostics.Add(Prefix + "units-invalid:mm-required");++ var gears = new List<GearAir>();+ foreach (Match header in Header.Matches(source))+ {+ var open = source.IndexOf('{', header.Index);+ var close = MatchingBrace(source, open);+ if (close < 0) { diagnostics.Add(Prefix + "declaration-unclosed:" + header.Groups["name"].Value); continue; }+ var family = Enum.Parse<GearFamily>(header.Groups["family"].Value);+ var name = header.Groups["name"].Value;+ var body = source[(open + 1)..close];+ double? module = Length(body, "Module");+ int? teeth = Integer(body, "Teeth");+ double? pressure = Angle(body, "PressureAngle");+ var face = Length(body, family == GearFamily.Pawl ? "Thickness" : "FaceWidth") ?? 0d;+ var bore = Length(body, "BoreDiameter") ?? 0d;+ var gear = new GearAir(name, family, module, teeth, pressure, face, bore,+ Angle(body, "Phase") ?? 0d, Length(body, "Backlash") ?? 0d,+ Length(body, "OutsideDiameter"), Angle(body, "PitchConeAngle"),+ Length(body, "HubDiameter"), Length(body, "HubLength"),+ Length(body, "Width"), Length(body, "Length"), Length(body, "PivotDiameter"),+ Length(body, "NoseLength"), Angle(body, "EngagementAngle"), Angle(body, "DriveFaceAngle"),+ Vector3(body, "Axis") ?? [0d, 0d, 1d],+ new(header.Index, close - header.Index + 1));+ Validate(gear, diagnostics);+ gears.Add(gear);+ }+ foreach (var duplicate in gears.GroupBy(gear => gear.Name, StringComparer.Ordinal).Where(group => group.Count() > 1))+ diagnostics.Add(Prefix + "duplicate-identity:" + duplicate.Key);++ var interfaces = new List<InterfaceAir<GearAir>>();+ foreach (Match header in InterfaceHeader.Matches(source))+ {+ var open = source.IndexOf('{', header.Index); var close = MatchingBrace(source, open);+ if (close < 0) { diagnostics.Add(Prefix + "interface-unclosed:" + header.Groups["name"].Value); continue; }+ var body = source[(open + 1)..close]; var aName = Identifier(body, "A"); var bName = Identifier(body, "B");+ if (aName is null || bName is null) { diagnostics.Add(Prefix + "interface-endpoint-missing:" + header.Groups["name"].Value); continue; }+ var a = gears.SingleOrDefault(gear => gear.Name == aName); var b = gears.SingleOrDefault(gear => gear.Name == bName);+ if (a is null || b is null) { diagnostics.Add(Prefix + "interface-endpoint-unresolved:" + header.Groups["name"].Value); continue; }+ interfaces.Add(BindInterface(header.Groups["name"].Value, a, b,+ Angle(body, "ShaftAngle"), Angle(body, "EngagementPhase"), Identifier(body, "AllowedDirection"),+ new(header.Index, close - header.Index + 1)));+ }+ diagnostics.AddRange(interfaces.Where(item => !item.Compatible).SelectMany(item => item.RejectionReasons.Select(reason => $"{Prefix}interface-incompatible:{item.Name}:{reason}")));+ if (gears.Count == 0) diagnostics.Add(Prefix + "declaration-missing");+ return new(modelName, gears, interfaces, diagnostics.Distinct(StringComparer.Ordinal).Order(StringComparer.Ordinal).ToArray());+ }++ public static GearMaterialization? Materialize(GearAir gear, out IReadOnlyList<string> diagnostics)+ {+ var errors = new List<string>();+ Validate(gear, errors);+ if (errors.Count > 0) { diagnostics = errors; return null; }+ if (gear.Family is GearFamily.BevelGear or GearFamily.MiterGear)+ {+ var bevel = GearBevelLoftMaterializer.TryMaterialize(gear);+ diagnostics = bevel.Diagnostics;+ return bevel.Materialization;+ }++ int involuteCount;+ double maxError;+ var curves = gear.Family switch+ {+ GearFamily.SpurGear => ExternalInvoluteProfile(gear, out involuteCount, out maxError),+ GearFamily.InternalSpurGear => InternalInvoluteProfile(gear, out involuteCount, out maxError),+ GearFamily.RatchetGear => RatchetProfile(gear, out involuteCount, out maxError),+ GearFamily.Pawl => PawlProfile(gear, out involuteCount, out maxError),+ _ => throw new InvalidOperationException()+ };+ var loops = new List<LineArcProfileLoop2D>();+ if (gear.Family == GearFamily.InternalSpurGear)+ {+ loops.Add(new([new LineArcFullCircle2D((0d, 0d), gear.OutsideDiameterMm!.Value / 2d)], false));+ loops.Add(new(curves, true));+ }+ else+ {+ loops.Add(new(curves, false));+ if (gear.BoreDiameterMm > Tol) loops.Add(new([new LineArcFullCircle2D((0d, 0d), gear.BoreDiameterMm / 2d)], true));+ if (gear.Family == GearFamily.Pawl && gear.PivotDiameterMm is > Tol)+ {+ var pivot = Rotate((gear.WidthMm!.Value * .24d, 0d), (gear.EngagementAngleDegrees ?? 0d) * Math.PI / 180d);+ loops.Add(new([new LineArcFullCircle2D(pivot, gear.PivotDiameterMm.Value / 2d)], true));+ }+ }+ var emitted = LineArcProfileExtrudeEmitter.TryEmit(new(loops, gear.FaceWidthMm, LocalStartDepth: 0d, LocalEndDepth: gear.FaceWidthMm));+ errors.AddRange(emitted.Diagnostics.Where(item => item.Contains("Invalid", StringComparison.Ordinal) || item.Contains("Unsupported", StringComparison.Ordinal) || item.Contains("Open", StringComparison.Ordinal)));+ diagnostics = errors;+ if (emitted.Status != LineArcProfileExtrudeStatus.Succeeded || emitted.Body is null) return null;+ var toothIds = gear.Teeth is { } teeth ? Enumerable.Range(0, teeth).Select(index => $"{gear.Name}.Tooth{index}").ToArray() : [$"{gear.Name}.Nose"];+ return new(emitted.Body, curves.Count, involuteCount, maxError,+ gear.Family is GearFamily.SpurGear or GearFamily.InternalSpurGear ? "AnalyticInvolute->CubicHermiteNonRationalBSpline" : "ExactLineArcProfile",+ toothIds);+ }++ private static InterfaceAir<GearAir> BindInterface(string name, GearAir a, GearAir b, double? shaftAngle,+ double? engagementPhase, string? allowedDirection, FirmamentV2SourceSpan span)+ {+ var rejection = new List<string>();+ var ratchetPawl = (a.Family == GearFamily.RatchetGear && b.Family == GearFamily.Pawl)+ || (a.Family == GearFamily.Pawl && b.Family == GearFamily.RatchetGear);+ if (!ratchetPawl && (a.ModuleMm is null || b.ModuleMm is null || Math.Abs(a.ModuleMm.Value - b.ModuleMm.Value) > Tol)) rejection.Add("module-mismatch");+ if (!ratchetPawl && (a.PressureAngleDegrees is null || b.PressureAngleDegrees is null || Math.Abs(a.PressureAngleDegrees.Value - b.PressureAngleDegrees.Value) > Tol)) rejection.Add("pressure-angle-mismatch");+ var internalCount = new[] { a, b }.Count(gear => gear.Family == GearFamily.InternalSpurGear);+ var bevelCount = new[] { a, b }.Count(gear => gear.Family is GearFamily.BevelGear or GearFamily.MiterGear);+ var kind = ratchetPawl ? "RatchetPawl" : internalCount == 1 ? "ExternalInternal" : bevelCount == 2 ? "Bevel" : "ExternalExternal";+ if (ratchetPawl)+ {+ if (allowedDirection is not ("Clockwise" or "CounterClockwise")) rejection.Add("allowed-direction-required");+ if (engagementPhase is null || !double.IsFinite(engagementPhase.Value)) rejection.Add("engagement-phase-required");+ }+ else if (internalCount == 1)+ {+ var internalGear = a.Family == GearFamily.InternalSpurGear ? a : b;+ var externalGear = ReferenceEquals(internalGear, a) ? b : a;+ if (externalGear.Family != GearFamily.SpurGear) rejection.Add("family-mismatch");+ if (internalGear.Teeth <= externalGear.Teeth) rejection.Add("internal-tooth-count-not-greater");+ }+ else if (bevelCount != 0 && bevelCount != 2) rejection.Add("family-mismatch");+ else if (bevelCount == 2)+ {+ var effectiveShaftAngle = shaftAngle ?? 90d;+ var coneA = a.Family == GearFamily.MiterGear ? a.PitchConeAngleDegrees ?? 45d : a.PitchConeAngleDegrees;+ var coneB = b.Family == GearFamily.MiterGear ? b.PitchConeAngleDegrees ?? 45d : b.PitchConeAngleDegrees;+ if (effectiveShaftAngle <= 0d || effectiveShaftAngle >= 180d || !double.IsFinite(effectiveShaftAngle)) rejection.Add("shaft-angle-invalid");+ if (coneA is null || coneB is null || Math.Abs(coneA.Value + coneB.Value - effectiveShaftAngle) > 1e-6) rejection.Add("pitch-cones-do-not-close");+ if ((a.Family == GearFamily.MiterGear || b.Family == GearFamily.MiterGear)+ && (a.Family != GearFamily.MiterGear || b.Family != GearFamily.MiterGear || a.Teeth != b.Teeth)) rejection.Add("miter-requires-equal-pair");+ }+ else if (bevelCount == 0 && (a.Family != GearFamily.SpurGear || b.Family != GearFamily.SpurGear)) rejection.Add("family-mismatch");+ double? center = !ratchetPawl && bevelCount == 0 && a.ModuleMm is { } module && a.Teeth is { } za && b.Teeth is { } zb+ ? module * (internalCount == 1 ? Math.Abs(zb - za) : za + zb) / 2d : null;+ double? ratio = a.Teeth is { } teethA && b.Teeth is { } teethB ? (double)teethA / teethB : null;+ var axisRelation = ratchetPawl ? "EngagementPlane" : bevelCount == 2 ? $"Intersecting:{shaftAngle ?? 90d:R}deg" : "Parallel";+ return new(name, a, b, kind, rejection.Count == 0, center, ratio,+ ratchetPawl ? 0 : internalCount == 1 ? 1 : -1, axisRelation, bevelCount == 2 ? shaftAngle ?? 90d : null,+ engagementPhase, allowedDirection, rejection, span);+ }++ private static void Validate(GearAir gear, List<string> diagnostics)+ {+ void Error(string code) => diagnostics.Add($"{Prefix}{code}:{gear.Name}");+ if (gear.FaceWidthMm <= Tol || !double.IsFinite(gear.FaceWidthMm)) Error("face-width-invalid");+ if (gear.BoreDiameterMm < 0d || !double.IsFinite(gear.BoreDiameterMm)) Error("bore-invalid");+ if (gear.BacklashMm < 0d || !double.IsFinite(gear.BacklashMm)) Error("backlash-invalid");+ if (!double.IsFinite(gear.PhaseDegrees)) Error("phase-invalid");+ if (gear.Axis.Count != 3 || gear.Axis.Any(value => !double.IsFinite(value))+ || Math.Abs(gear.Axis[0]) > Tol || Math.Abs(gear.Axis[1]) > Tol || Math.Abs(gear.Axis[2] - 1d) > Tol) Error("axis-outside-qualified-frame");+ if (gear.HubDiameterMm is not null || gear.HubLengthMm is not null) Error("hub-geometry-not-qualified");+ if (gear.Family == GearFamily.Pawl)+ {+ if (gear.WidthMm is null or <= 0d || gear.LengthMm is null or <= 0d || gear.PivotDiameterMm is null or <= 0d || gear.NoseLengthMm is null or <= 0d) Error("pawl-parameter-invalid");+ else if (gear.PivotDiameterMm >= Math.Min(gear.WidthMm.Value, gear.LengthMm.Value)) Error("pawl-pivot-too-large");+ return;+ }+ if (gear.Teeth is null or <= 0) Error("teeth-invalid");+ if (gear.Family == GearFamily.RatchetGear)+ {+ if (gear.Teeth is < 8) Error("ratchet-teeth-below-qualified-range");+ if (gear.OutsideDiameterMm is null or <= 0d) Error("outside-diameter-invalid");+ else if (gear.BoreDiameterMm >= gear.OutsideDiameterMm) Error("bore-too-large");+ if (gear.DriveFaceAngleDegrees is < -45d or > 45d) Error("drive-face-angle-outside-qualified-range");+ return;+ }+ if (gear.ModuleMm is null or <= 0d || !double.IsFinite(gear.ModuleMm.Value)) Error("module-invalid");+ if (gear.PressureAngleDegrees is null or < 14d or > 30d || !double.IsFinite(gear.PressureAngleDegrees.Value)) Error("pressure-angle-invalid");+ if (gear.Teeth is > 0 && gear.Family != GearFamily.InternalSpurGear && gear.Teeth < 17) Error("undercut-risk:minimum-teeth=17");+ if (gear.PitchRadiusMm is { } pitch && gear.Teeth is { } teeth && gear.BacklashMm >= Math.PI * pitch / teeth) Error("backlash-removes-tooth");+ if (gear.Family == GearFamily.InternalSpurGear)+ {+ if (gear.OutsideDiameterMm is null || gear.RootDiameterMm is null || gear.OutsideDiameterMm <= gear.RootDiameterMm) Error("internal-outside-diameter-too-small");+ }+ else if (gear.RootDiameterMm is { } root && gear.BoreDiameterMm >= root) Error("bore-too-large");+ if (gear.Family is GearFamily.BevelGear or GearFamily.MiterGear)+ {+ var angle = gear.Family == GearFamily.MiterGear ? gear.PitchConeAngleDegrees ?? 45d : gear.PitchConeAngleDegrees;+ if (angle is null or <= 5d or >= 85d) Error("pitch-cone-angle-invalid");+ else if (gear.PitchRadiusMm is { } radius && gear.FaceWidthMm >= radius / Math.Sin(angle.Value * Math.PI / 180d)) Error("face-width-exceeds-cone-distance");+ }+ }++ internal static IReadOnlyList<LineArcProfileCurve2D> ExternalInvoluteProfile(GearAir gear, out int involuteCount, out double maxError)+ {+ var module = gear.ModuleMm!.Value; var teeth = gear.Teeth!.Value; var pressure = gear.PressureAngleDegrees!.Value * Math.PI / 180d;+ var rp = module * teeth / 2d; var rb = rp * Math.Cos(pressure); var ra = rp + module; var rf = rp - 1.25d * module;+ var startRadius = Math.Max(rb, rf); var t0 = InvoluteParameter(rb, startRadius); var ta = InvoluteParameter(rb, ra); var tp = InvoluteParameter(rb, rp);+ var psiPitch = InvoluteAngle(tp); var half = Math.PI / (2d * teeth) - gear.BacklashMm / (2d * rp); var pitch = 2d * Math.PI / teeth;+ var curves = new List<LineArcProfileCurve2D>(); maxError = 0d; involuteCount = 0;+ for (var index = 0; index < teeth; index++)+ {+ var center = gear.PhaseDegrees * Math.PI / 180d + index * pitch;+ var rightRotation = center - half - psiPitch; var leftRotation = center + half + psiPitch;+ var rootRight = Polar(rf, rightRotation + InvoluteAngle(t0)); var baseRight = InvolutePoint(rb, t0, rightRotation, false);+ if (Distance(rootRight, baseRight) > 1e-8) curves.Add(new LineArcLineSegment2D(rootRight, baseRight));+ curves.AddRange(InvoluteBezierSpans(rb, t0, ta, rightRotation, false, out var rightError)); involuteCount += 2; maxError = Math.Max(maxError, rightError);+ var rightTip = InvolutePoint(rb, ta, rightRotation, false); var leftTip = InvolutePoint(rb, ta, leftRotation, true);+ curves.Add(ArcBetween(ra, rightTip, leftTip));+ var left = InvoluteBezierSpans(rb, t0, ta, leftRotation, true, out var leftError).Reverse().Select(Reverse).ToArray(); curves.AddRange(left); involuteCount += 2; maxError = Math.Max(maxError, leftError);+ var baseLeft = InvolutePoint(rb, t0, leftRotation, true); var rootLeft = Polar(rf, leftRotation - InvoluteAngle(t0));+ if (Distance(baseLeft, rootLeft) > 1e-8) curves.Add(new LineArcLineSegment2D(baseLeft, rootLeft));+ var nextCenter = center + pitch; var nextRightRotation = nextCenter - half - psiPitch;+ var nextRootRight = Polar(rf, nextRightRotation + InvoluteAngle(t0));+ curves.Add(ArcBetween(rf, rootLeft, nextRootRight));+ }+ return curves;+ }++ private static IReadOnlyList<LineArcProfileCurve2D> InternalInvoluteProfile(GearAir gear, out int involuteCount, out double maxError)+ {+ var module = gear.ModuleMm!.Value; var teeth = gear.Teeth!.Value; var pressure = gear.PressureAngleDegrees!.Value * Math.PI / 180d;+ var rp = module * teeth / 2d; var rb = rp * Math.Cos(pressure); var tip = rp - module; var root = rp + 1.25d * module;+ var startRadius = Math.Max(rb, tip); var t0 = InvoluteParameter(rb, startRadius); var tr = InvoluteParameter(rb, root); var tp = InvoluteParameter(rb, rp);+ var psiPitch = InvoluteAngle(tp); var half = Math.PI / (2d * teeth) - gear.BacklashMm / (2d * rp); var pitch = 2d * Math.PI / teeth;+ var ccw = new List<LineArcProfileCurve2D>(); maxError = 0d; involuteCount = 0;+ for (var index = 0; index < teeth; index++)+ {+ var center = gear.PhaseDegrees * Math.PI / 180d + index * pitch;+ var rightRotation = center - half + psiPitch; var leftRotation = center + half - psiPitch;+ var tipRight = Polar(tip, rightRotation - InvoluteAngle(t0)); var tipLeft = Polar(tip, leftRotation + InvoluteAngle(t0));+ ccw.Add(ArcBetween(tip, tipRight, tipLeft));+ var baseLeft = InvolutePoint(rb, t0, leftRotation, false);+ if (Distance(tipLeft, baseLeft) > 1e-8) ccw.Add(new LineArcLineSegment2D(tipLeft, baseLeft));+ ccw.AddRange(InvoluteBezierSpans(rb, t0, tr, leftRotation, false, out var leftError)); involuteCount += 2; maxError = Math.Max(maxError, leftError);+ var leftRoot = InvolutePoint(rb, tr, leftRotation, false);+ var nextCenter = center + pitch; var nextRightRotation = nextCenter - half + psiPitch;+ var nextRightRoot = InvolutePoint(rb, tr, nextRightRotation, true);+ ccw.Add(ArcBetween(root, leftRoot, nextRightRoot));+ var right = InvoluteBezierSpans(rb, t0, tr, nextRightRotation, true, out var rightError).Reverse().Select(Reverse).ToArray(); ccw.AddRange(right); involuteCount += 2; maxError = Math.Max(maxError, rightError);+ var baseRight = InvolutePoint(rb, t0, nextRightRotation, true); var nextTipRight = Polar(tip, nextRightRotation - InvoluteAngle(t0));+ if (Distance(baseRight, nextTipRight) > 1e-8) ccw.Add(new LineArcLineSegment2D(baseRight, nextTipRight));+ }+ return ccw.Reverse<LineArcProfileCurve2D>().Select(Reverse).ToArray();+ }++ private static IReadOnlyList<LineArcProfileCurve2D> RatchetProfile(GearAir gear, out int involuteCount, out double maxError)+ {+ involuteCount = 0; maxError = 0d; var teeth = gear.Teeth!.Value; var outer = gear.OutsideDiameterMm!.Value / 2d;+ var root = Math.Max(gear.BoreDiameterMm / 2d + outer * .12d, outer * .78d); var pitch = 2d * Math.PI / teeth; var phase = gear.PhaseDegrees * Math.PI / 180d;+ var driveAngle = (gear.DriveFaceAngleDegrees ?? 0d) * Math.PI / 180d;+ var drive = Math.Atan(Math.Tan(driveAngle) * (outer - root) / outer);+ if (Math.Abs(drive) >= pitch * .25d) drive = Math.CopySign(pitch * .25d, drive);+ var result = new List<LineArcProfileCurve2D>();+ for (var index = 0; index < teeth; index++)+ {+ var a = phase + index * pitch; var tipEnd = a + drive + pitch * .08d; var next = a + pitch;+ result.Add(new LineArcLineSegment2D(Polar(root, a), Polar(outer, a + drive)));+ result.Add(new LineArcCircularArc2D((0d, 0d), outer, a + drive, tipEnd - a - drive));+ result.Add(new LineArcLineSegment2D(Polar(outer, tipEnd), Polar(root, next)));+ }+ return result;+ }++ private static IReadOnlyList<LineArcProfileCurve2D> PawlProfile(GearAir gear, out int involuteCount, out double maxError)+ {+ involuteCount = 0; maxError = 0d; var width = gear.WidthMm!.Value; var length = gear.LengthMm!.Value; var nose = gear.NoseLengthMm!.Value;+ var angle = (gear.EngagementAngleDegrees ?? 0d) * Math.PI / 180d;+ var points = new[] { (-width / 2d, -length * .34d), (width * .28d, -length * .34d), (width / 2d + nose, 0d), (width * .28d, length * .34d), (-width / 2d, length * .34d) }+ .Select(point => Rotate(point, angle)).ToArray();+ return Enumerable.Range(0, points.Length).Select(index => (LineArcProfileCurve2D)new LineArcLineSegment2D(points[index], points[(index + 1) % points.Length])).ToArray();+ }++ private static IReadOnlyList<LineArcCubicBezier2D> InvoluteBezierSpans(double baseRadius, double from, double to, double rotation, bool mirror, out double maximumError)+ {+ const int spans = 2; var result = new List<LineArcCubicBezier2D>(spans); maximumError = 0d;+ for (var index = 0; index < spans; index++)+ {+ var a = from + (to - from) * index / spans; var b = from + (to - from) * (index + 1) / spans; var dt = b - a;+ var p0 = InvolutePoint(baseRadius, a, rotation, mirror); var p3 = InvolutePoint(baseRadius, b, rotation, mirror);+ var d0 = InvoluteDerivative(baseRadius, a, rotation, mirror); var d1 = InvoluteDerivative(baseRadius, b, rotation, mirror);+ var curve = new LineArcCubicBezier2D(p0, Add(p0, Scale(d0, dt / 3d)), Add(p3, Scale(d1, -dt / 3d)), p3); result.Add(curve);+ for (var sample = 1; sample < 8; sample++)+ {+ var u = sample / 8d; var exact = InvolutePoint(baseRadius, a + dt * u, rotation, mirror); var approx = Bezier(curve, u);+ maximumError = Math.Max(maximumError, Distance(exact, approx));+ }+ }+ return result;+ }++ private static (double X, double Y) InvolutePoint(double rb, double t, double rotation, bool mirror)+ {+ var x = rb * (Math.Cos(t) + t * Math.Sin(t)); var y = rb * (Math.Sin(t) - t * Math.Cos(t)); if (mirror) y = -y; return Rotate((x, y), rotation);+ }+ private static (double X, double Y) InvoluteDerivative(double rb, double t, double rotation, bool mirror)+ { var x = rb * t * Math.Cos(t); var y = rb * t * Math.Sin(t); if (mirror) y = -y; return Rotate((x, y), rotation); }+ private static double InvoluteParameter(double rb, double radius) => Math.Sqrt(Math.Max(0d, radius * radius / (rb * rb) - 1d));+ private static double InvoluteAngle(double t) => t - Math.Atan(t);+ private static LineArcCircularArc2D ArcBetween(double radius, (double X, double Y) start, (double X, double Y) end)+ { var a = Math.Atan2(start.Y, start.X); var b = Math.Atan2(end.Y, end.X); while (b <= a) b += 2d * Math.PI; return new((0d, 0d), radius, a, b - a); }+ private static LineArcProfileCurve2D Reverse(LineArcProfileCurve2D curve) => curve switch+ {+ LineArcLineSegment2D line => new LineArcLineSegment2D(line.End, line.Start),+ LineArcCircularArc2D arc => new LineArcCircularArc2D(arc.Center, arc.Radius, arc.StartAngleRadians + arc.SweepAngleRadians, -arc.SweepAngleRadians),+ LineArcCubicBezier2D bezier => new LineArcCubicBezier2D(bezier.End, bezier.Control2, bezier.Control1, bezier.Start),+ _ => throw new InvalidOperationException("gear-profile-reverse-unsupported")+ };+ private static (double X, double Y) Polar(double radius, double angle) => (radius * Math.Cos(angle), radius * Math.Sin(angle));+ private static (double X, double Y) Rotate((double X, double Y) point, double angle) => (point.X * Math.Cos(angle) - point.Y * Math.Sin(angle), point.X * Math.Sin(angle) + point.Y * Math.Cos(angle));+ private static (double X, double Y) Add((double X, double Y) a, (double X, double Y) b) => (a.X + b.X, a.Y + b.Y);+ private static (double X, double Y) Scale((double X, double Y) value, double scale) => (value.X * scale, value.Y * scale);+ private static (double X, double Y) Bezier(LineArcCubicBezier2D curve, double t)+ { var s = 1d - t; return (s*s*s*curve.Start.X + 3*s*s*t*curve.Control1.X + 3*s*t*t*curve.Control2.X + t*t*t*curve.End.X, s*s*s*curve.Start.Y + 3*s*s*t*curve.Control1.Y + 3*s*t*t*curve.Control2.Y + t*t*t*curve.End.Y); }+ private static double Distance((double X, double Y) a, (double X, double Y) b) => Math.Sqrt((a.X-b.X)*(a.X-b.X)+(a.Y-b.Y)*(a.Y-b.Y));+ private static double? Length(string body, string field) => NumberField(body, field, "mm");+ private static double? Angle(string body, string field) => NumberField(body, field, "deg");+ private static double? NumberField(string body, string field, string unit)+ { var match = Regex.Match(body, $@"\b{Regex.Escape(field)}\s*:\s*(?<value>[-+.\deE]+)\s*{unit}\b", RegexOptions.CultureInvariant); return match.Success && double.TryParse(match.Groups["value"].Value, NumberStyles.Float, CultureInfo.InvariantCulture, out var value) ? value : null; }+ private static int? Integer(string body, string field)+ { var match = Regex.Match(body, $@"\b{Regex.Escape(field)}\s*:\s*(?<value>[-+]?\d+)\b", RegexOptions.CultureInvariant); return match.Success && int.TryParse(match.Groups["value"].Value, NumberStyles.Integer, CultureInfo.InvariantCulture, out var value) ? value : null; }+ private static string? Identifier(string body, string field)+ { var match = Regex.Match(body, $@"\b{Regex.Escape(field)}\s*:\s*(?<value>[A-Za-z_]\w*)\b", RegexOptions.CultureInvariant); return match.Success ? match.Groups["value"].Value : null; }+ private static IReadOnlyList<double>? Vector3(string body, string field)+ {+ var match = Regex.Match(body, $@"\b{Regex.Escape(field)}\s*:\s*\[\s*(?<x>[-+.\deE]+)\s*,\s*(?<y>[-+.\deE]+)\s*,\s*(?<z>[-+.\deE]+)\s*\]", RegexOptions.CultureInvariant);+ return match.Success ? [Number(match.Groups["x"].Value), Number(match.Groups["y"].Value), Number(match.Groups["z"].Value)] : null;+ }+ private static double Number(string value) => double.Parse(value, NumberStyles.Float, CultureInfo.InvariantCulture);+ private static int MatchingBrace(string source, int open)+ { var depth = 0; for (var index = open; index >= 0 && index < source.Length; index++) { if (source[index] == '{') depth++; else if (source[index] == '}' && --depth == 0) return index; } return -1; }+}++internal sealed record GearBevelMaterializationResult(GearMaterialization? Materialization, IReadOnlyList<string> Diagnostics);++/// <summary>Implemented in the bounded straight-bevel loft lane; never a scaled extruded mesh.</summary>+internal static class GearBevelLoftMaterializer+{+ public static GearBevelMaterializationResult TryMaterialize(GearAir gear)+ {+ var angle = (gear.Family == GearFamily.MiterGear ? gear.PitchConeAngleDegrees ?? 45d : gear.PitchConeAngleDegrees!.Value) * Math.PI / 180d;+ var outer = GearAuthoring.ExternalInvoluteProfile(gear, out var involuteCount, out var maxError);+ var loops = new List<LineArcProfileLoop2D> { new(outer, false) };+ if (gear.BoreDiameterMm > 1e-9) loops.Add(new([new LineArcFullCircle2D((0d, 0d), gear.BoreDiameterMm / 2d)], true));+ var pitchRadius = gear.PitchRadiusMm!.Value;+ var coneDistance = pitchRadius / Math.Sin(angle);+ var scale = (coneDistance - gear.FaceWidthMm) / coneDistance;+ var axialWidth = gear.FaceWidthMm * Math.Cos(angle);+ var planned = ProfileExtrusionBRepPlanner.TryPlan(new(loops, axialWidth, LocalStartDepth: 0d, LocalEndDepth: axialWidth));+ if (!planned.Succeeded || planned.Plan is null) return new(null, planned.Diagnostics);+ var plan = planned.Plan;++ bool Outer(string source) => source.Contains(".Loop0.", StringComparison.Ordinal);+ Point3D ScaleEnd(Point3D point) => new(point.X * scale, point.Y * scale, point.Z);+ var vertices = plan.Vertices.Select(vertex => vertex.Role == ProfileExtrusionPlanRole.LocalEndVertex && Outer(vertex.SourceStableId)+ ? vertex with { WorldPoint = ScaleEnd(vertex.WorldPoint) } : vertex).ToArray();+ var vertexById = vertices.ToDictionary(vertex => vertex.Id);+ var edgeByCurve = plan.Edges.ToDictionary(edge => edge.CurveId);+ var curves = plan.Curves.Select(curve =>+ {+ var edge = edgeByCurve[curve.Id]; var a = vertexById[edge.StartVertexId].WorldPoint; var b = vertexById[edge.EndVertexId].WorldPoint;+ if (curve.StableId.EndsWith(":curve:longitudinal", StringComparison.Ordinal))+ return curve with { Geometry = CurveGeometry.FromLine(new Line3Curve(a, Direction3D.Create(b - a))), Trim = new(0d, (b - a).Length) };+ if (!curve.StableId.EndsWith(":curve:local-end", StringComparison.Ordinal) || !Outer(curve.SourceStableId)) return curve;+ return curve.Geometry.Kind switch+ {+ CurveGeometryKind.Line3 => curve with { Geometry = CurveGeometry.FromLine(new Line3Curve(a, Direction3D.Create(b - a))), Trim = new(0d, (b - a).Length) },+ CurveGeometryKind.Circle3 when curve.Geometry.Circle3 is { } circle => curve with+ {+ Geometry = CurveGeometry.FromCircle(new Circle3Curve(ScaleEnd(circle.Center), circle.Normal, circle.Radius * scale, circle.XAxis))+ },+ CurveGeometryKind.BSpline3 when curve.Geometry.BSpline3 is { } spline => curve with+ {+ Geometry = CurveGeometry.FromBSpline(new BSpline3Curve(spline.Degree, spline.ControlPoints.Select(ScaleEnd).ToArray(),+ spline.KnotMultiplicities, spline.KnotValues, spline.CurveForm, spline.ClosedCurve, spline.SelfIntersect, spline.KnotSpec))+ },+ _ => curve+ };+ }).ToArray();++ var sideOrdinal = 0;+ var surfaces = plan.Surfaces.Select(surface =>+ {+ if (surface.Role != ProfileExtrusionPlanRole.SideFace) return surface;+ var sourceCurve = loops.SelectMany(loop => loop.Curves).ElementAt(sideOrdinal++);+ if (!Outer(surface.SourceStableId)) return surface;+ SurfaceGeometry geometry = sourceCurve switch+ {+ LineArcLineSegment2D line => PlaneFor(line),+ LineArcCircularArc2D arc => SurfaceGeometry.FromCone(new ConeSurface(new Point3D(0d, 0d, 0d),+ Direction3D.Create(new Vector3D(0d, 0d, -1d)), arc.Radius, angle, Direction3D.Create(new Vector3D(1d, 0d, 0d)))),+ LineArcCubicBezier2D bezier => SurfaceGeometry.FromBSplineSurfaceWithKnots(new BSplineSurfaceWithKnots(3, 1,+ new[] { bezier.Start, bezier.Control1, bezier.Control2, bezier.End }+ .Select(point => (IReadOnlyList<Point3D>)[new Point3D(point.X, point.Y, 0d), new Point3D(point.X * scale, point.Y * scale, axialWidth)]).ToArray(),+ "RULED_SURF", false, false, false, [4, 4], [2, 2], [0d, 1d], [0d, 1d], "PIECEWISE_BEZIER_KNOTS")),+ _ => surface.Geometry+ };+ return surface with { Geometry = geometry };++ SurfaceGeometry PlaneFor(LineArcLineSegment2D line)+ {+ var p0 = new Point3D(line.Start.X, line.Start.Y, 0d); var p1 = new Point3D(line.End.X, line.End.Y, 0d);+ var p2 = new Point3D(line.Start.X * scale, line.Start.Y * scale, axialWidth);+ var normal = Direction3D.Create((p1 - p0).Cross(p2 - p0));+ return SurfaceGeometry.FromPlane(new PlaneSurface(p0, normal, Direction3D.Create(p1 - p0)));+ }+ }).ToArray();++ var transformed = plan with { Vertices = vertices, Curves = curves, Surfaces = surfaces,+ StableId = $"brep-plan:straight-bevel:{gear.Name}:{gear.Teeth}:{gear.FaceWidthMm:R}" };+ var materialized = ProfileExtrusionBRepMaterializer.TryMaterialize(transformed);+ if (!materialized.Succeeded || materialized.Body is null) return new(null, materialized.Diagnostics);+ return new(new(materialized.Body, outer.Count, involuteCount, maxError,+ "AnalyticInvoluteSections->StraightPitchConeRuledNonRationalBSpline",+ Enumerable.Range(0, gear.Teeth!.Value).Select(index => $"{gear.Name}.Tooth{index}").ToArray()), materialized.Diagnostics);+ }+}diff --git a/Aetheris.Kernel.Firmament/Materializer/LineArcProfileExtrudeEmitter.cs b/Aetheris.Kernel.Firmament/Materializer/LineArcProfileExtrudeEmitter.csindex ea34a036..3a8b2db5 100644--- a/Aetheris.Kernel.Firmament/Materializer/LineArcProfileExtrudeEmitter.cs+++ b/Aetheris.Kernel.Firmament/Materializer/LineArcProfileExtrudeEmitter.cs@@ -8,6 +8,16 @@ public sealed record LineArcCircularArc2D((double X, double Y) Center, double Rapublic sealed record LineArcFullCircle2D((double X, double Y) Center, double Radius) : LineArcProfileCurve2D;/// <summary>Exact full planar ellipse; RotationRadians locates its major axis in local XY.</summary>public sealed record LineArcFullEllipse2D((double X, double Y) Center, double MajorRadius, double MinorRadius, double RotationRadians) : LineArcProfileCurve2D;+/// <summary>+/// One non-rational cubic Bezier span. It is stored as a clamped degree-three+/// B-spline during B-rep planning, so faithful authored/generated curves do not+/// have to collapse to line segments before exact STEP export.+/// </summary>+public sealed record LineArcCubicBezier2D(+ (double X, double Y) Start,+ (double X, double Y) Control1,+ (double X, double Y) Control2,+ (double X, double Y) End) : LineArcProfileCurve2D;public sealed record LineArcProfileLoop2D(IReadOnlyList<LineArcProfileCurve2D> Curves, bool IsHole);/// <summary>Local profile and local depth interval. Height-only callers retain the historic centered interval.</summary>diff --git a/Aetheris.Kernel.Firmament/Materializer/ProfileExtrusionBRepPlan.cs b/Aetheris.Kernel.Firmament/Materializer/ProfileExtrusionBRepPlan.csindex 2900f914..0655c9f2 100644--- a/Aetheris.Kernel.Firmament/Materializer/ProfileExtrusionBRepPlan.cs+++ b/Aetheris.Kernel.Firmament/Materializer/ProfileExtrusionBRepPlan.cs@@ -169,6 +169,24 @@ public static class ProfileExtrusionBRepPlannersideSurface = SurfaceGeometry.FromLinearExtrusion(new LinearExtrusionSurface(startEllipse, frame.AxisZ.ToVector() * (end - start)));break;}+ case LineArcCubicBezier2D bezier:+ {+ sv0 = Vertex(bezier.Start, false, segmentSource); sv1 = Vertex(bezier.End, false, segmentSource);+ ev0 = Vertex(bezier.Start, true, segmentSource); ev1 = Vertex(bezier.End, true, segmentSource);+ BSpline3Curve Spline(double depth) => new(3,+ [frame.ToWorld(bezier.Start, depth), frame.ToWorld(bezier.Control1, depth), frame.ToWorld(bezier.Control2, depth), frame.ToWorld(bezier.End, depth)],+ [4, 4], [0d, 1d], "UNSPECIFIED", false, false, "PIECEWISE_BEZIER_KNOTS");+ var startSpline = CurveGeometry.FromBSpline(Spline(start));+ var endSpline = CurveGeometry.FromBSpline(Spline(end));+ startEdge = Edge(prefix + ":edge:local-start", sv0, sv1,+ Curve(prefix + ":curve:local-start", startSpline, new(0d, 1d), segmentSource), segmentSource, ProfileExtrusionPlanRole.LocalStartBoundary);+ endEdge = Edge(prefix + ":edge:local-end", ev0, ev1,+ Curve(prefix + ":curve:local-end", endSpline, new(0d, 1d), segmentSource), segmentSource, ProfileExtrusionPlanRole.LocalEndBoundary);+ startLongitudinal = Vertical(bezier.Start, sv0, ev0, segmentSource);+ endLongitudinal = Vertical(bezier.End, sv1, ev1, segmentSource);+ sideSurface = SurfaceGeometry.FromLinearExtrusion(new LinearExtrusionSurface(startSpline, frame.AxisZ.ToVector() * (end - start)));+ break;+ }default: throw new InvalidOperationException("ProfileExtrusionUnsupportedCurve");}// Loop winding is authored in local Profile coordinates (outer CCW, inner CW).@@ -243,13 +261,15 @@ public static class ProfileExtrusionBRepPlannercase LineArcCircularArc2D arc when !double.IsFinite(arc.Radius) || arc.Radius <= Tol || Math.Abs(arc.SweepAngleRadians) <= Tol: d.Add("ProfileExtrusionUnsupportedCurve: invalid arc"); return false;case LineArcFullCircle2D circle when !double.IsFinite(circle.Radius) || circle.Radius <= Tol: d.Add("ProfileExtrusionUnsupportedCurve: invalid circle"); return false;case LineArcFullEllipse2D ellipse when !double.IsFinite(ellipse.MajorRadius) || !double.IsFinite(ellipse.MinorRadius) || ellipse.MajorRadius <= Tol || ellipse.MinorRadius <= Tol || ellipse.MinorRadius > ellipse.MajorRadius: d.Add("ProfileExtrusionUnsupportedCurve: invalid ellipse"); return false;- case not (LineArcLineSegment2D or LineArcCircularArc2D or LineArcFullCircle2D or LineArcFullEllipse2D): d.Add("ProfileExtrusionUnsupportedCurve"); return false;+ case LineArcCubicBezier2D bezier when !Finite(bezier.Start) || !Finite(bezier.Control1) || !Finite(bezier.Control2) || !Finite(bezier.End) || Distance(bezier.Start, bezier.End) <= Tol: d.Add("ProfileExtrusionUnsupportedCurve: invalid cubic bezier"); return false;+ case not (LineArcLineSegment2D or LineArcCircularArc2D or LineArcFullCircle2D or LineArcFullEllipse2D or LineArcCubicBezier2D): d.Add("ProfileExtrusionUnsupportedCurve"); return false;}}return true;}private static double Distance((double X, double Y) a, (double X, double Y) b) => Math.Sqrt((a.X - b.X) * (a.X - b.X) + (a.Y - b.Y) * (a.Y - b.Y));+ private static bool Finite((double X, double Y) point) => double.IsFinite(point.X) && double.IsFinite(point.Y);}/// <summary>Strict plan consumer. It has no geometric matching, adjacency inference, or semantic planning branch.</summary>diff --git a/Aetheris.Kernel.StandardLibrary.Tests/GearFamilyCatalogTests.cs b/Aetheris.Kernel.StandardLibrary.Tests/GearFamilyCatalogTests.csnew file mode 100644index 00000000..abcecff8--- /dev/null+++ b/Aetheris.Kernel.StandardLibrary.Tests/GearFamilyCatalogTests.cs@@ -0,0 +1,18 @@+using Aetheris.Kernel.StandardLibrary;++namespace Aetheris.Kernel.StandardLibrary.Tests;++public sealed class GearFamilyCatalogTests+{+ [Fact]+ public void AllQualifiedGearFamiliesAreDiscoverableWithoutSourceInspection()+ {+ Assert.Equal(["BevelGear", "InternalSpurGear", "MiterGear", "Pawl", "RatchetGear", "SpurGear"],+ GearFamilyCatalog.Families.Select(item => item.Name).Order(StringComparer.Ordinal));+ Assert.All(GearFamilyCatalog.Families, item =>+ {+ Assert.StartsWith("PowerTransmission.", item.Category, StringComparison.Ordinal);+ Assert.NotEmpty(item.RequiredParameters); Assert.NotEmpty(item.Construction);+ });+ }+}diff --git a/Aetheris.Kernel.StandardLibrary/GearFamilyCatalog.cs b/Aetheris.Kernel.StandardLibrary/GearFamilyCatalog.csnew file mode 100644index 00000000..1b933ae9--- /dev/null+++ b/Aetheris.Kernel.StandardLibrary/GearFamilyCatalog.cs@@ -0,0 +1,23 @@+namespace Aetheris.Kernel.StandardLibrary;++/// <summary>Discoverable public metadata for compiler-owned Firmament gear families.</summary>+public sealed record GearFamilyDescriptor(+ string Name,+ string Category,+ string Qualification,+ IReadOnlyList<string> RequiredParameters,+ IReadOnlyList<string> OptionalParameters,+ string Construction);++public static class GearFamilyCatalog+{+ public static IReadOnlyList<GearFamilyDescriptor> Families { get; } =+ [+ new("SpurGear", "PowerTransmission.Gears", "Supported", ["Module", "Teeth", "PressureAngle", "FaceWidth"], ["BoreDiameter", "Backlash", "Phase"], "Standard full-depth external involute"),+ new("InternalSpurGear", "PowerTransmission.Gears", "Supported", ["Module", "Teeth", "PressureAngle", "FaceWidth", "OutsideDiameter"], ["Backlash", "Phase"], "Standard full-depth internal involute ring"),+ new("BevelGear", "PowerTransmission.Gears", "Bounded", ["Module", "Teeth", "PressureAngle", "FaceWidth", "PitchConeAngle"], ["BoreDiameter", "Phase"], "Straight bevel pitch-cone ruled loft"),+ new("MiterGear", "PowerTransmission.Gears", "Bounded", ["Module", "Teeth", "PressureAngle", "FaceWidth"], ["PitchConeAngle", "BoreDiameter", "Phase"], "Equal-pair straight bevel specialization"),+ new("RatchetGear", "PowerTransmission.Ratchets", "Bounded", ["Teeth", "OutsideDiameter", "FaceWidth"], ["BoreDiameter", "DriveFaceAngle", "Phase"], "Asymmetric line/arc radial tooth profile"),+ new("Pawl", "PowerTransmission.Ratchets", "Bounded", ["Width", "Length", "Thickness", "PivotDiameter", "NoseLength"], ["EngagementAngle"], "Prismatic pawl with axial pivot bore")+ ];+}diff --git a/docs/public/README.md b/docs/public/README.mdindex 621995de..740001a7 100644--- a/docs/public/README.md+++ b/docs/public/README.md@@ -4,7 +4,7 @@ This directory is the only authoritative in-repository guide to behavior shippedStart with [Getting Started](getting-started.md), then use these guides:-- Firmament: [overview](firmament/overview.md), [language style](firmament/language-style.md), [syntax](firmament/syntax.md), [geometry](firmament/geometry.md), [closed 2D boundaries](firmament/boundaries.md), [bounded material offsets](firmament/material-offsets.md), [Revolve](firmament/revolve.md), [bounded mathematical sculpting](firmament/sculpting.md), [Section chains](firmament/section-chains.md), [PlasticShell](firmament/plastic-shell.md), [Circular Sweep](firmament/sweep.md), [Formed Wire](firmament/wire-form.md), [Structural members and weldments](firmament/structural.md), [Semantic piping and local autorouting](firmament/piping.md), [Paperclip Template](firmament/paperclip.md), [Templates](firmament/templates.md), [materials](firmament/materials.md), [PMI](firmament/pmi.md), [Sheet Metal](firmament/sheet-metal.md), [FEA](firmament/fea.md), and [STEP import](firmament/step-import.md)+- Firmament: [overview](firmament/overview.md), [language style](firmament/language-style.md), [syntax](firmament/syntax.md), [geometry](firmament/geometry.md), [Gear Standard Library](firmament/gears.md), [closed 2D boundaries](firmament/boundaries.md), [bounded material offsets](firmament/material-offsets.md), [Revolve](firmament/revolve.md), [bounded mathematical sculpting](firmament/sculpting.md), [Section chains](firmament/section-chains.md), [PlasticShell](firmament/plastic-shell.md), [Circular Sweep](firmament/sweep.md), [Formed Wire](firmament/wire-form.md), [Structural members and weldments](firmament/structural.md), [Semantic piping and local autorouting](firmament/piping.md), [Paperclip Template](firmament/paperclip.md), [Templates](firmament/templates.md), [materials](firmament/materials.md), [PMI](firmament/pmi.md), [Sheet Metal](firmament/sheet-metal.md), [FEA](firmament/fea.md), and [STEP import](firmament/step-import.md)- Non-manufacturing work: [Virtual Sculpture and Sol 1](virtual-sculpture.md)- Standard Library: [product-family index, invocation, authoring, and compatibility](standard-library/README.md)- Interoperability: [Forge Host Protocol v1](forge/interop.md)diff --git a/docs/public/firmament/gears.md b/docs/public/firmament/gears.mdnew file mode 100644index 00000000..3feb7381--- /dev/null+++ b/docs/public/firmament/gears.md@@ -0,0 +1,81 @@+# Gear Standard Library++Firmament can build common gears from engineering parameters. Authors name the family and dimensions; the compiler owns tooth construction, radial ordering, closed BRep materialization, and deterministic AP242 export.++```firmament+Model Drive {+ Units: mm+ SpurGear DriveGear {+ Module: 2mm+ Teeth: 24+ PressureAngle: 20deg+ FaceWidth: 10mm+ BoreDiameter: 8mm+ Backlash: 0.15mm+ Phase: 0deg+ }+}+```++Use `SpurGear` for an external parallel-axis gear and `InternalSpurGear` for a ring. `BevelGear` is the bounded straight-bevel family; `MiterGear` is its equal-tooth 1:1 specialization. `RatchetGear` and `Pawl` describe one-way indexing geometry and are not involute gears. A pinion is a `BevelGear` or `SpurGear` in the smaller-tooth-count role; it is not a separate geometry type.++## Typed gear interfaces++`Interface<Gear>` binds two declared members without repeating a role schema:++```firmament+Model Pair {+ Units: mm+ SpurGear Driver { Module: 2mm Teeth: 24 PressureAngle: 20deg FaceWidth: 10mm BoreDiameter: 8mm }+ SpurGear Driven { Module: 2mm Teeth: 48 PressureAngle: 20deg FaceWidth: 10mm BoreDiameter: 12mm Phase: 3.75deg }+ Interface<Gear> Mesh { A: Driver B: Driven }+}+```++The interface checks family, module, pressure angle, and tooth-count constraints. Inspection reports compatibility, ideal ratio, rotation sign, and parallel-axis center distance. External meshes reverse direction; external/internal meshes retain direction. For bevel pairs, add `ShaftAngle`; pitch-cone angles must sum to it. A miter pair must contain equal tooth counts.++```firmament+Interface<Gear> RightAngle { A: Input B: Output ShaftAngle: 90deg }+```++Ratchet/pawl interfaces reuse the same typed form and add one-way metadata:++```firmament+Interface<Gear> Indexing {+ A: Wheel+ B: Stop+ AllowedDirection: Clockwise+ EngagementPhase: 2deg+}+```++This relationship is ideal geometry and kinematics. It is not a contact, dynamics, torque, wear, or stress solver.++## Parameters and boundaries++| Family | Status | Required | Optional | Boundary |+|---|---|---|---|---|+| `SpurGear` | Supported | `Module`, `Teeth`, `PressureAngle`, `FaceWidth` | `BoreDiameter`, `Backlash`, `Phase` | Standard full-depth external involute; tooth counts below 17 rejected |+| `InternalSpurGear` | Supported | `Module`, `Teeth`, `PressureAngle`, `FaceWidth`, `OutsideDiameter` | `Backlash`, `Phase` | Reversed internal involute flanks and ring stock |+| `BevelGear` | Bounded | `Module`, `Teeth`, `PressureAngle`, `FaceWidth`, `PitchConeAngle` | `BoreDiameter`, `Phase` | Straight bevel only; pitch-cone ruled tooth loft |+| `MiterGear` | Bounded | `Module`, `Teeth`, `PressureAngle`, `FaceWidth` | `PitchConeAngle`, `BoreDiameter`, `Phase` | Equal-pair bevel specialization, normally 45-degree cones |+| `RatchetGear` | Bounded | `Teeth`, `OutsideDiameter`, `FaceWidth` | `BoreDiameter`, `DriveFaceAngle`, `Phase` | At least 8 asymmetric radial teeth |+| `Pawl` | Bounded | `Width`, `Length`, `Thickness`, `PivotDiameter`, `NoseLength` | `EngagementAngle` | Prismatic companion with axial pivot bore |++All lengths are millimetres. Pressure angles from 14 through 30 degrees are admitted. `BoreDiameter: 0mm` intentionally creates a solid member. A positive bore must leave root structure. `Backlash` is a linear reduction of circular tooth thickness at the pitch circle, divided symmetrically between the two flanks; it is not a scale factor.++Gear AIR always carries an explicit axis. Omitted source uses `[0,0,1]`; X0 also accepts `Axis: [0,0,1]` explicitly and rejects other frames until frame-aware gear placement is qualified.++`HubDiameter` and `HubLength` are reserved but fail with `firmament-gear-hub-geometry-not-qualified` in X0. This prevents product-specific hub intent from being discarded. Keyways, set screws, profile shift, custom root fillets, helical/worm/spiral-bevel/hypoid gears, contact, and manufacturing quality classes are deferred.++## Inspect and build++```powershell+aetheris validate fixtures/Canonical/Gears/spur-basic.firmament --json+aetheris inspect fixtures/Canonical/GearInterfaces/spur-pair.firmament --json+aetheris build fixtures/Canonical/Gears/spur-basic.firmament --out artifacts/local/spur.step --json+```++`inspect` reports the authored and derived diameters, axis, phase, backlash, stable `Tooth0` through `ToothN-1` identities, and interface results. `build` adds topology and surface counts, involute approximation error, manifold STEP re-import evidence, and a SHA-256 digest. A build emits one gear body; use the typed interfaces as assembly/placement authority for trains rather than treating a multi-gear source as one fused solid.++See the compact executable examples in [`fixtures/Canonical/Gears`](../../../fixtures/Canonical/Gears) and [`fixtures/Canonical/GearInterfaces`](../../../fixtures/Canonical/GearInterfaces).diff --git a/docs/public/reference/supported-features.md b/docs/public/reference/supported-features.mdindex 4cbd1008..7aa242f2 100644--- a/docs/public/reference/supported-features.md+++ b/docs/public/reference/supported-features.md@@ -5,6 +5,7 @@| Area | Status | Preview 3 boundary ||---|---|---|| Firmament V2 native primitives/profiles | Bounded | Named Box/Cylinder/Frustum/RoundedBox and admitted line/arc profile construction/composition |+| Gear Standard Library | Supported / bounded by family | Supported external/internal standard involute spur gears; bounded straight bevel/miter and ratchet/pawl; typed `Interface<Gear>` compatibility and ideal ratios; deterministic manifold AP242. No contact, dynamics, ratings, helical/worm, spiral-bevel, or qualified hub/keyway geometry. See the [gear guide](../firmament/gears.md). || Bounded mathematical sculpting | Bounded (SURF-X3b subset) | Immutable single-predecessor `BodyState` reconstructed from versioned `BaseConstruction` plus typed replay operations; persistent `OffsetRegion`, `ReplaceRegion`, judged `BlendBoundary`, `HoleFeature`, east-attached `AddSectionChain`, and west/east through-duct `RemoveSectionChain`; atomic replay, semantic support invalidation, locality/preservation evidence, pcurves, AP242 associations, and rational-free STEP. General blend networks and arbitrary SectionChain supports remain unsupported. See the [sculpting guide](../firmament/sculpting.md). || Molded plastic shell | Bounded (MOLD-X0a) | First-class `PlasticShell` IR; exact drafted coaxial-frustum shell; analytic annular standoffs with retained core holes; constant-shell-thickness planar B-rep rib walls with flat tops; one closed product boundary; face-associated AP242 notes; and explicit zero-release-draft warning for constant-section vertical features. The retired polar height field is available only through the non-manufacturing experimental art command. Freeform exterior offsets and general junctions remain unsupported. See the [PlasticShell guide](../firmament/plastic-shell.md). || Virtual Sculpture | Bounded (ART-X0) | The explicit `Mode: Virtual` Sol 1 flagship: deterministic golden-angle/Fibonacci 3D lattice, analytic toroidal frame and eye, exact closed-body AP242 assembly, evidence/preview output, and zero rational product surfaces. This is not manufacturing geometry and does not extend Firmament engineering domains. See [Virtual Sculpture](../virtual-sculpture.md). |diff --git a/docs/public/standard-library/README.md b/docs/public/standard-library/README.mdindex 532ef2fa..35053f2b 100644--- a/docs/public/standard-library/README.md+++ b/docs/public/standard-library/README.md@@ -16,9 +16,13 @@ The Standard Library is a shipped, curated catalog of typed Firmament product fa| Generic Pipe / Elbow90 / Tee | `Standard.Piping` | dimensional, non-standards-claim piping product policies || Pump Cooling Skid | `Standard.Piping.PumpSkid` | equipment-owned nozzle ports, scoped KeepOut exemptions, endpoint mates, deterministic accepted route, AP242 assembly || Electronics Enclosure | `Standard.SheetMetal.ElectronicsEnclosure` | Sheet Metal, DFM, formed STEP, flat STEP, SVG |+| Gear families | compiler-owned `PowerTransmission.Gears` declarations | Spur/internal involute, bounded straight bevel/miter, typed `Interface<Gear>`, deterministic AP242 |+| Ratchet and pawl | compiler-owned `PowerTransmission.Ratchets` declarations | Asymmetric ratchet teeth, pawl/pivot geometry, one-way interface metadata |The namespace taxonomy is intentionally shallow: `Standard.Products.Mechanical`, `.Electronics`, and `.Office` identify ordinary products; `Standard.Structural` owns structure-first weldments; the existing `Standard.SheetMetal` namespace remains stable for manufacturing Templates.+Gear families use concise built-in typed declarations rather than Templates because the compiler must own exact tooth construction and finite radial lowering. Their discoverable metadata lives in `GearFamilyCatalog`; see the [Gear Standard Library guide](../firmament/gears.md).+## Invoke a familyList and describe schemas before binding values:diff --git a/docs/release/GEAR-LIB-X0.md b/docs/release/GEAR-LIB-X0.mdnew file mode 100644index 00000000..3fc73193--- /dev/null+++ b/docs/release/GEAR-LIB-X0.md@@ -0,0 +1,124 @@+# GEAR-LIB-X0 — first-class gear geometry and library families++## Executive verdict++**Accepted.** An Aetheris/Firmament author can request external and internal involute spur gears, bounded straight bevel and miter gears, ratchet wheels, and pawls using ordinary engineering parameters without deriving tooth geometry. `Interface<Gear>` provides typed pair compatibility and ideal kinematics without repeating an Assembly role schema.++Acceptance is geometric and kinematic. It is not a claim of contact simulation, load capacity, AGMA/DIN quality, manufacturing certification, or catalog-part equivalence.++## Authority and construction++Public declarations lower to finite typed Gear AIR. The compiler derives one tooth from module, tooth count, pressure angle, backlash, and standard full-depth proportions, then creates a stable radial sequence `Tooth0..ToothN-1`. It does not emit public per-tooth source and does not copy reference topology.++External and internal flanks use the analytic involute++`x(t) = rb(cos(t) + t sin(t)), y(t) = rb(sin(t) - t cos(t))`.++Each flank is carried by two controlled non-rational cubic Hermite/B-spline spans. Tip and root portions are exact circular arcs; unresolved trochoidal manufacturing fillets use explicit straight base-to-root transitions in X0. Standard addendum is `m`, dedendum is `1.25m`, and clearance is `0.25m`. Backlash is subtracted from circular tooth thickness at the pitch circle, half at each flank. External/internal profiles are extruded along Z by `FaceWidth` through the existing profile extrusion planner. Bores are axial cylindrical inner loops.++Straight bevel/miter construction starts from two involute sections related by the declared pitch cone and face width. Corresponding line portions are planar, circular portions conical, and involute flanks are degree-3-by-1 non-rational ruled B-spline surfaces. This is a bounded pitch-cone approximation, not a scaled already-extruded mesh and not Gleason tooth manufacturing geometry.++## Reference research++All ten supplied STEP files remained in the local Downloads directory. None is copied into fixtures or required at runtime. Aetheris CLI compound analysis supplied body/root count, exact imported bounds, volume, and surface families. Catalog fields are recorded separately from measured CAD evidence. The two `2515...` files declare inch units in STEP; the raw bounds below are inches with millimetre conversions in parentheses. All other bounds are millimetres.++Surface inventory abbreviations are plane/cylinder/cone/torus/B-spline. A rotational pattern matching the catalog tooth count was visible in each gear; the pawl instead provided a single nose/pivot witness.++| Reference | Family and direct CAD evidence | Catalog/inferred engineering values | Generic lesson vs incidental detail |+|---|---|---|---|+| `2664N539` | External spur; 1 body; 21.827 × 21.827 × 20 bounds; P23/C114/Co46/T2/B0; axial bore/hub | Catalog: m1, 20 teeth, 20 pitch diameter, 22 OD, 10 face, 8 bore, 20°; standard root 17.5 inferred | Confirms `d=mz`, `da=d+2m`, axial extrusion. Hub and relief/chamfer faces are product details. |+| `2664N545` | External spur; 1 body; 31.893 × 32.000 × 20; P33/C165/Co66/T2/B0 | Catalog: m1, 30 teeth, 30 pitch diameter, 32 OD, 10 face, 8 bore, 20°; standard root 27.5 inferred | Same tooth law scales with count. Hub and bore treatment remain optional product features. |+| `2664N353_NO THREADS` | External spur; 2 imported roots; 21.827 × 21.827 × 20; P32/C120/Co52/T2/B4 | Catalog: m1, 20 teeth, pitch 20, OD 22, face 10, hub 16 × 10, bore 5, 20° | The no-thread specimen isolates gear/hub geometry; multiple STEP roots and set-screw detail are not gear theory. |+| `2664N313_NO THREADS` | External spur; 2 imported roots; 11 × 11 × 16; P31/C121/Co34/T80/B0 | Catalog: m0.5, 20 teeth, pitch 10, OD 11, face 5, hub 11 × 11, bore 3, 20° | Confirms module scaling at the same tooth count. Hub/set-screw arrangement is catalog-specific. |+| `2696N15` | Internal spur ring; 1 body; 70 × 70 × 5; P2/C206/Co0/T202/B200 | Catalog: m0.5, 100 teeth, pitch 50, OD 70, tooth-tip ID 49, face 5, 20° | Establishes reversed internal flank/tip semantics and independent outer ring stock. |+| `6529K57` | Miter; 1 body; 34.269 × 30.382 × 34.269; P2/C4/Co28/T0/B100; tapered straight teeth | Catalog: m1.5, 20 teeth, 45° pitch cone, 20° pressure, pitch 30, OD 32.8, face 11, bore 8 | Supports a 1:1 constrained straight-bevel family and cone-conforming taper. Hub/set screw is incidental. |+| `2515N337` | Larger straight bevel; 1 body; 1.799 × .477 × 1.800 in (45.69 × 12.12 × 45.72 mm); P3/C4/Co145/T0/B315 | Catalog: m1, 20°, 3:1 pair, 6 face, 8 bore; 45-tooth role and 71.565° pitch cone inferred from ratio/90° shaft convention | Cone and spline populations reject a spur extrusion. Mounting hub/reliefs are product-specific. |+| `2515N333` | Bevel pinion; 1 body; .659 × .493 × .663 in (16.74 × 12.52 × 16.84 mm); P32/C4/Co70/T0/B105 | Catalog: m1, 20°, 3:1 pair, 6 face, 6 bore; 15-tooth role and 18.435° pitch cone inferred | “Pinion” is a pair role, not a separate kernel family. X0 rejects sub-17 ordinary involute members, so this exact low-count catalog member is research evidence rather than a qualified flagship. |+| `6283K75` | Ratchet wheel; 1 body; 40 × 40 × 6; P122/C62/Co124/T0/B0; 60 asymmetric radial teeth and axial bore | Catalog: 60 teeth, 40 OD, 10 bore, 6 face | Ratchets need their own steep-face/ramp profile, not an involute or spur alias. Catalog edge finishes are incidental. |+| `6283K72` | Pawl; 1 body; 38 × 16 × 6; P12/C5/Co5/T0/B0; pivot opening and directed nose | Catalog: for 6 face, 5 shaft, 38 overall length, 30 centre-to-end | Establishes a reusable bounded nose/body/pivot companion; exact outline, chamfers, and material are not copied. |++Catalog facts were checked against the current McMaster family listings for [metric spur gears](https://www.mcmaster.com/products/steel-gear-racks), [internal spur gears](https://www.mcmaster.com/products/internal-spur-gears/), [metal bevel gears](https://www.mcmaster.com/products/metal-bevel-gears/), [miter gears](https://www.mcmaster.com/products/miter-gears), and [ratchet mechanisms](https://www.mcmaster.com/products/ratchet-mechanisms/). These links are research provenance, not runtime dependencies.++## Family matrix++| Family | Qualified | Parameters | Pair semantics | STEP | Notes |+|---|---|---|---|---|---|+| Spur | Supported | module, teeth, pressure, face, bore, backlash, phase | external/external center distance, ratio, opposite sign | Deterministic manifold AP242 | Standard full-depth involute; minimum 17 teeth |+| Internal spur | Supported | module, teeth, pressure, face, outside diameter, backlash, phase | external/internal difference center, ratio, same sign | Deterministic manifold AP242 | Correct internal tip/root and flank orientation |+| Bevel | Bounded | module, teeth, pressure, face, pitch cone, bore, phase | module/pressure, complementary pitch cones, shaft angle, ratio | Deterministic manifold AP242 | Straight pitch-cone ruled approximation only |+| Miter | Bounded | bevel parameters, normally 45° | equal teeth, 1:1, complementary cones | Deterministic manifold AP242 | Constrained bevel implementation, not a second engine |+| Ratchet | Bounded | teeth, OD, face, bore, drive-face angle, phase | ratchet/pawl direction and engagement phase | Deterministic manifold AP242 | Exact asymmetric line/arc profile; minimum 8 teeth |+| Pawl | Bounded | width, length, thickness, pivot, nose, engagement angle | ratchet/pawl direction and engagement phase | Deterministic manifold AP242 | Prismatic body and cylindrical pivot opening |++`GearFamilyCatalog` exposes these six names, categories, fields, qualification, and construction summaries without requiring source inspection. `Gear<T>` remains deferred; `Interface<Gear>` is the deliberately generic public relationship.++## Involute validation++| Witness | Quantity | Theory | Generated/report | Absolute error |+|---|---|---:|---:|---:|+| external m2/z24/20° | pitch diameter | 48 | 48 | 0 |+| | base diameter | 45.1052457977 | 45.1052457977 | < 1e-10 |+| | addendum diameter | 52 | 52 bounds | < 1e-9 radial construction; axis-aligned extrema depend on phase |+| | root diameter | 43 | 43 construction | 0 |+| | maximum sampled cubic-flank deviation | — | 0.001202 mm | bounded below 0.002 mm |+| internal m0.5/z100/20° | pitch diameter | 50 | 50 | 0 |+| | base diameter | 46.9846310393 | 46.9846310393 | < 1e-10 |+| | tooth-tip diameter | 49 | 49 construction | 0 |+| | tooth-root diameter | 51.25 | 51.25 construction | 0 |+| | ring outside diameter | 70 | 70 bounds | < 1e-9 |+| | maximum sampled cubic-flank deviation | — | 0.0000044 mm | bounded below 0.00001 mm |++The standard tooth thickness at pitch is `pi*m/2`. Backlash `b` changes it to `pi*m/2-b`, symmetrically. No arbitrary global scaling occurs.++## Pair and train validation++| Witness | Teeth | Expected ratio `omegaB/omegaA` | Center/axis rule | Verdict |+|---|---:|---:|---|---|+| spur pair | 24:48 | -0.5 | `m(zA+zB)/2 = 72 mm` | compatible |+| external/internal | 20:60 | +1/3 | `m(zRing-zPinion)/2 = 20 mm` | compatible |+| bevel pair | 20:40 | -0.5 ideal sign | 90° shafts; 26.565051177° + 63.434948823° | compatible |+| miter pair | 20:20 | -1 | 90° shafts; 45° + 45° | compatible |+| ratchet/pawl | 60 + pawl | one-way metadata, no continuous ratio | clockwise admitted; 2° engagement phase | compatible |+| three-gear train | 20:30:40 | A→idler -2/3; idler→C -3/4; net A→C +1/2 | centers 25 mm and 35 mm | both interfaces compatible |++These are compatibility and ideal kinematic facts. Pair sources are intentionally validated as multi-member semantic documents; individual bodies build separately and assembly placement consumes the reported interface law.++## Print-oriented witness++The demonstration pair uses module 2, 20/40 teeth, 20° pressure angle, 8 mm face width, 0.15 mm backlash, and 8.4 mm bores for a nominal 8 mm shaft. Pitch-circle tooth thickness is `pi*2/2-0.15 = 2.99159 mm`; the mating space is increased by the same 0.15 mm linear convention. Diameter bore clearance is 0.4 mm. This is **geometrically print-oriented, not manufacturing-certified or printer-universal**. No existing additive minimum-feature checker accepts gear teeth, so these explicit geometric witnesses replace a fabricated DFM result.++## STEP, determinism, and performance++Every single-part flagship exported AP242, re-imported through Aetheris, and returned a closed manifold. Involute side carriers remain non-rational B-splines; circular bores remain cylinders; bevel circular side carriers remain cones. Representative warm-process Release CLI observations on the qualification machine:++| Fixture | Teeth | Build ms | Faces | Edges | STEP bytes |+|---|---:|---:|---:|---:|---:|+| spur-basic | 24 | 458.2 | 195 | 579 | 349,898 |+| internal-spur-basic | 100 | 1,019.7 | 603 | 1,803 | 1,195,023 |+| bevel-basic | 45 | 563.3 | 273 | 813 | 602,626 |+| miter-basic | 20 | 427.6 | 163 | 483 | 326,569 |+| ratchet-basic | 60 | 440.3 | 183 | 543 | 265,693 |+| pawl-basic | — | 332.6 | 8 | 18 | 9,516 |+| spur-high-tooth | 100 | 1,017.8 | 603 | 1,803 | 1,195,439 |++The 100-tooth external stress witness completed in about one second and re-imported manifold. Repeated identical m2/z24 builds produced SHA-256 `0e5299e170548f34c590189a1c39c440651cd6515f539aa9b9fbc4d94351e5d7`.++## Difference Engine readiness++The Difference Engine workload can directly use external spur gears, internal rings, two- and three-member ideal ratios, stable tooth phases/identities, one-way ratchet/pawl metadata, and optional bounded right-angle redirection through straight bevel/miter pairs. It must still supply assembly occurrence placement and prescribed animation from the interface facts.++Remaining gaps are qualified hub/keyway/set-screw specialization, a unified multi-body gear assembly build/export demonstration, gear-contact/interference evaluation, tooth contact dynamics, racks, helical/worm gears, spiral bevel/hypoid geometry, and manufacturing ratings. None blocks ordinary ideal Difference Engine gear trains; contact/load claims remain out of scope.++## Visual review++Exact-BRep wireframes were rendered for the generated spur, internal ring, bevel, miter, ratchet, and pawl bodies, with a magnified involute tooth witness and annotated pair compositions. Matching reference wireframes were rendered for `2664N539`, `2696N15`, `6529K57`, `6283K75`, and `6283K72`.++Manual review found smooth, consistently ordered external involute flanks; even tooth spacing; correct inward-pointing internal teeth; visible bevel/miter tooth taper from large to small section; a steep ratchet locking face with a long ramp; and a pawl nose/pivot relationship consistent with one-way placement. The generated spur deliberately lacks the catalog specimen's trochoidal/rounded root fillet and edge chamfers. The bevel approximation lacks the reference member's product hub, reliefs, and manufactured flank refinements. Pair SVGs are annotated diagnostic compositions driven by interface math, not collision/contact proof.++The reviewable PNG/SVG evidence is generated under `artifacts/local/gear-lib-x0/visuals/`; reference-only renders and measurement JSON are under `artifacts/local/gear-lib-x0/reference-analysis/`. Those ignored artifacts contain no redistributed STEP file.++## Validation inventory++Qualification includes kernel geometry/interface tests, CLI build/inspect/validate tests, Standard Library discovery tests, all canonical gear single-part builds, all pair/train semantic fixtures, the complete invalid fixture corpus, the 100-tooth stress build, STEP re-import and manifold checks, deterministic repeat, public-document links, repository-layout checks, packaged CLI execution outside the repository, Release solution build, and `git diff --check`. Generated STEP, JSON, comparison, and preview evidence stays under ignored `artifacts/local/gear-lib-x0/`.++The repository-wide canonical script passed every new gear/interface fixture but its final verdict remains red because the pre-existing `fixtures/Canonical/Assembly/annular-pair.firmament` uses two `LegacyExplicit` placements that the script's own canonical-source guard forbids. GEAR-LIB-X0 does not weaken that guard or migrate the unrelated assembly. This is the only recorded qualification exception.diff --git a/fixtures/Canonical/GearInterfaces/bevel-pair.firmament b/fixtures/Canonical/GearInterfaces/bevel-pair.firmamentnew file mode 100644index 00000000..20e2611f--- /dev/null+++ b/fixtures/Canonical/GearInterfaces/bevel-pair.firmament@@ -0,0 +1,6 @@+Model BevelPair {+ Units: mm+ BevelGear Pinion { Module: 1mm Teeth: 20 PressureAngle: 20deg FaceWidth: 5mm BoreDiameter: 5mm PitchConeAngle: 26.565051177deg }+ BevelGear Gear { Module: 1mm Teeth: 40 PressureAngle: 20deg FaceWidth: 5mm BoreDiameter: 8mm PitchConeAngle: 63.434948823deg }+ Interface<Gear> Mesh { A: Pinion B: Gear ShaftAngle: 90deg }+}diff --git a/fixtures/Canonical/GearInterfaces/internal-spur-pair.firmament b/fixtures/Canonical/GearInterfaces/internal-spur-pair.firmamentnew file mode 100644index 00000000..88cb1c68--- /dev/null+++ b/fixtures/Canonical/GearInterfaces/internal-spur-pair.firmament@@ -0,0 +1,6 @@+Model InternalSpurPair {+ Units: mm+ SpurGear Pinion { Module: 1mm Teeth: 20 PressureAngle: 20deg FaceWidth: 6mm BoreDiameter: 5mm }+ InternalSpurGear Ring { Module: 1mm Teeth: 60 PressureAngle: 20deg FaceWidth: 6mm OutsideDiameter: 65mm Phase: 3deg }+ Interface<Gear> Mesh { A: Pinion B: Ring }+}diff --git a/fixtures/Canonical/GearInterfaces/miter-pair.firmament b/fixtures/Canonical/GearInterfaces/miter-pair.firmamentnew file mode 100644index 00000000..f99fafbc--- /dev/null+++ b/fixtures/Canonical/GearInterfaces/miter-pair.firmament@@ -0,0 +1,6 @@+Model MiterPair {+ Units: mm+ MiterGear A { Module: 1.5mm Teeth: 20 PressureAngle: 20deg FaceWidth: 8mm BoreDiameter: 8mm PitchConeAngle: 45deg }+ MiterGear B { Module: 1.5mm Teeth: 20 PressureAngle: 20deg FaceWidth: 8mm BoreDiameter: 8mm PitchConeAngle: 45deg Phase: 9deg }+ Interface<Gear> Mesh { A: A B: B ShaftAngle: 90deg }+}diff --git a/fixtures/Canonical/GearInterfaces/print-oriented-spur-pair.firmament b/fixtures/Canonical/GearInterfaces/print-oriented-spur-pair.firmamentnew file mode 100644index 00000000..123b97d2--- /dev/null+++ b/fixtures/Canonical/GearInterfaces/print-oriented-spur-pair.firmament@@ -0,0 +1,6 @@+Model PrintOrientedSpurPair {+ Units: mm+ SpurGear Driver { Module: 2mm Teeth: 20 PressureAngle: 20deg FaceWidth: 8mm BoreDiameter: 8.4mm Backlash: 0.15mm }+ SpurGear Driven { Module: 2mm Teeth: 40 PressureAngle: 20deg FaceWidth: 8mm BoreDiameter: 8.4mm Backlash: 0.15mm Phase: 4.5deg }+ Interface<Gear> Mesh { A: Driver B: Driven }+}diff --git a/fixtures/Canonical/GearInterfaces/ratchet-pawl.firmament b/fixtures/Canonical/GearInterfaces/ratchet-pawl.firmamentnew file mode 100644index 00000000..013412ac--- /dev/null+++ b/fixtures/Canonical/GearInterfaces/ratchet-pawl.firmament@@ -0,0 +1,6 @@+Model RatchetPawl {+ Units: mm+ RatchetGear Wheel { Teeth: 60 OutsideDiameter: 40mm FaceWidth: 6mm BoreDiameter: 10mm DriveFaceAngle: 0deg }+ Pawl Stop { Width: 16mm Length: 38mm Thickness: 6mm PivotDiameter: 5mm NoseLength: 6mm EngagementAngle: 15deg }+ Interface<Gear> OneWay { A: Wheel B: Stop EngagementPhase: 2deg AllowedDirection: Clockwise }+}diff --git a/fixtures/Canonical/GearInterfaces/spur-pair.firmament b/fixtures/Canonical/GearInterfaces/spur-pair.firmamentnew file mode 100644index 00000000..ef421508--- /dev/null+++ b/fixtures/Canonical/GearInterfaces/spur-pair.firmament@@ -0,0 +1,6 @@+Model SpurPair {+ Units: mm+ SpurGear Driver { Module: 2mm Teeth: 24 PressureAngle: 20deg FaceWidth: 10mm BoreDiameter: 8mm }+ SpurGear Driven { Module: 2mm Teeth: 48 PressureAngle: 20deg FaceWidth: 10mm BoreDiameter: 12mm Phase: 3.75deg }+ Interface<Gear> Mesh { A: Driver B: Driven }+}diff --git a/fixtures/Canonical/GearInterfaces/three-gear-train.firmament b/fixtures/Canonical/GearInterfaces/three-gear-train.firmamentnew file mode 100644index 00000000..bcb427cd--- /dev/null+++ b/fixtures/Canonical/GearInterfaces/three-gear-train.firmament@@ -0,0 +1,8 @@+Model ThreeGearTrain {+ Units: mm+ SpurGear A { Module: 1mm Teeth: 20 PressureAngle: 20deg FaceWidth: 6mm BoreDiameter: 5mm }+ SpurGear Idler { Module: 1mm Teeth: 30 PressureAngle: 20deg FaceWidth: 6mm BoreDiameter: 5mm Phase: 6deg }+ SpurGear C { Module: 1mm Teeth: 40 PressureAngle: 20deg FaceWidth: 6mm BoreDiameter: 5mm }+ Interface<Gear> AToIdler { A: A B: Idler }+ Interface<Gear> IdlerToC { A: Idler B: C }+}diff --git a/fixtures/Canonical/Gears/bevel-basic.firmament b/fixtures/Canonical/Gears/bevel-basic.firmamentnew file mode 100644index 00000000..b0387e33--- /dev/null+++ b/fixtures/Canonical/Gears/bevel-basic.firmament@@ -0,0 +1,12 @@+Model BevelBasic {+ Units: mm+ BevelGear RedirectGear {+ Module: 1mm+ Teeth: 45+ PressureAngle: 20deg+ FaceWidth: 6mm+ PitchConeAngle: 71.565051177deg+ BoreDiameter: 8mm+ Phase: 0deg+ }+}diff --git a/fixtures/Canonical/Gears/bevel-pair-gear.firmament b/fixtures/Canonical/Gears/bevel-pair-gear.firmamentnew file mode 100644index 00000000..63fa1bc8--- /dev/null+++ b/fixtures/Canonical/Gears/bevel-pair-gear.firmament@@ -0,0 +1,4 @@+Model BevelPairGear {+ Units: mm+ BevelGear Gear { Module: 1mm Teeth: 40 PressureAngle: 20deg FaceWidth: 5mm BoreDiameter: 8mm PitchConeAngle: 63.434948823deg }+}diff --git a/fixtures/Canonical/Gears/bevel-pair-pinion.firmament b/fixtures/Canonical/Gears/bevel-pair-pinion.firmamentnew file mode 100644index 00000000..7cc5e095--- /dev/null+++ b/fixtures/Canonical/Gears/bevel-pair-pinion.firmament@@ -0,0 +1,4 @@+Model BevelPairPinion {+ Units: mm+ BevelGear Pinion { Module: 1mm Teeth: 20 PressureAngle: 20deg FaceWidth: 5mm BoreDiameter: 5mm PitchConeAngle: 26.565051177deg }+}diff --git a/fixtures/Canonical/Gears/internal-spur-basic.firmament b/fixtures/Canonical/Gears/internal-spur-basic.firmamentnew file mode 100644index 00000000..45676487--- /dev/null+++ b/fixtures/Canonical/Gears/internal-spur-basic.firmament@@ -0,0 +1,11 @@+Model InternalSpurBasic {+ Units: mm+ InternalSpurGear Ring {+ Module: 0.5mm+ Teeth: 100+ PressureAngle: 20deg+ FaceWidth: 5mm+ OutsideDiameter: 70mm+ Phase: 0deg+ }+}diff --git a/fixtures/Canonical/Gears/miter-basic.firmament b/fixtures/Canonical/Gears/miter-basic.firmamentnew file mode 100644index 00000000..5051681b--- /dev/null+++ b/fixtures/Canonical/Gears/miter-basic.firmament@@ -0,0 +1,12 @@+Model MiterBasic {+ Units: mm+ MiterGear EqualRedirect {+ Module: 1.5mm+ Teeth: 20+ PressureAngle: 20deg+ FaceWidth: 11mm+ PitchConeAngle: 45deg+ BoreDiameter: 8mm+ Phase: 0deg+ }+}diff --git a/fixtures/Canonical/Gears/pawl-basic.firmament b/fixtures/Canonical/Gears/pawl-basic.firmamentnew file mode 100644index 00000000..9229d501--- /dev/null+++ b/fixtures/Canonical/Gears/pawl-basic.firmament@@ -0,0 +1,11 @@+Model PawlBasic {+ Units: mm+ Pawl StopPawl {+ Width: 16mm+ Length: 38mm+ Thickness: 6mm+ PivotDiameter: 5mm+ NoseLength: 6mm+ EngagementAngle: 15deg+ }+}diff --git a/fixtures/Canonical/Gears/ratchet-basic.firmament b/fixtures/Canonical/Gears/ratchet-basic.firmamentnew file mode 100644index 00000000..4f1c9e35--- /dev/null+++ b/fixtures/Canonical/Gears/ratchet-basic.firmament@@ -0,0 +1,11 @@+Model RatchetBasic {+ Units: mm+ RatchetGear IndexWheel {+ Teeth: 60+ OutsideDiameter: 40mm+ FaceWidth: 6mm+ BoreDiameter: 10mm+ DriveFaceAngle: 0deg+ Phase: 0deg+ }+}diff --git a/fixtures/Canonical/Gears/spur-basic.firmament b/fixtures/Canonical/Gears/spur-basic.firmamentnew file mode 100644index 00000000..cca5f805--- /dev/null+++ b/fixtures/Canonical/Gears/spur-basic.firmament@@ -0,0 +1,11 @@+Model SpurBasic {+ Units: mm+ SpurGear DriveGear {+ Module: 2mm+ Teeth: 24+ PressureAngle: 20deg+ FaceWidth: 10mm+ BoreDiameter: 8mm+ Phase: 0deg+ }+}diff --git a/fixtures/Canonical/Gears/spur-driven-48.firmament b/fixtures/Canonical/Gears/spur-driven-48.firmamentnew file mode 100644index 00000000..914e3189--- /dev/null+++ b/fixtures/Canonical/Gears/spur-driven-48.firmament@@ -0,0 +1,4 @@+Model SpurDriven48 {+ Units: mm+ SpurGear Driven { Module: 2mm Teeth: 48 PressureAngle: 20deg FaceWidth: 10mm BoreDiameter: 12mm Phase: 3.75deg }+}diff --git a/fixtures/Canonical/Gears/spur-high-tooth.firmament b/fixtures/Canonical/Gears/spur-high-tooth.firmamentnew file mode 100644index 00000000..6007c209--- /dev/null+++ b/fixtures/Canonical/Gears/spur-high-tooth.firmament@@ -0,0 +1,4 @@+Model SpurHighTooth {+ Units: mm+ SpurGear TimingWheel { Module: 0.8mm Teeth: 100 PressureAngle: 20deg FaceWidth: 6mm BoreDiameter: 12mm Backlash: 0.05mm }+}diff --git a/fixtures/Canonical/coverage.json b/fixtures/Canonical/coverage.jsonindex 632734b9..75fe6a14 100644--- a/fixtures/Canonical/coverage.json+++ b/fixtures/Canonical/coverage.json@@ -35,6 +35,8 @@"inlineSTEP": "FEA/inline-step-cantilever.firmament","Assembly": "Assembly/bearing-module.firmament","Piping": "Piping/pump-skid.firmament",+ "Gear": "Gears/spur-basic.firmament",+ "Interface<Gear>": "GearInterfaces/spur-pair.firmament","SurfacePatch": "Sculpting/surf-x1-freeform-housing.firmament","ReplaceRegion": "Sculpting/surf-x1-freeform-housing.firmament","PatchG1": "Sculpting/surf-x1-freeform-housing.firmament",diff --git a/fixtures/Canonical/qualification.json b/fixtures/Canonical/qualification.jsonindex 8b67abcf..d09723c5 100644--- a/fixtures/Canonical/qualification.json+++ b/fixtures/Canonical/qualification.json@@ -19,6 +19,8 @@{ "path": "SectionChain", "operation": "section-chain-build" },{ "path": "Structural", "operation": "build-step" },{ "path": "Piping", "operation": "build-step" },+ { "path": "GearInterfaces", "operation": "validate" },+ { "path": "Gears", "operation": "build-step" },{ "path": "WireForm", "operation": "build-step" },{ "path": "PlasticShell", "operation": "build-step" },{ "path": "Basics", "operation": "build-step" },diff --git a/fixtures/Invalid/Gears/bore-too-large.firmament b/fixtures/Invalid/Gears/bore-too-large.firmamentnew file mode 100644index 00000000..7f5ca7f9--- /dev/null+++ b/fixtures/Invalid/Gears/bore-too-large.firmament@@ -0,0 +1 @@+Model Invalid { Units: mm SpurGear Bad { Module: 1mm Teeth: 24 PressureAngle: 20deg FaceWidth: 5mm BoreDiameter: 30mm } }diff --git a/fixtures/Invalid/Gears/impossible-internal-pair.firmament b/fixtures/Invalid/Gears/impossible-internal-pair.firmamentnew file mode 100644index 00000000..d50c39a1--- /dev/null+++ b/fixtures/Invalid/Gears/impossible-internal-pair.firmament@@ -0,0 +1,6 @@+Model Invalid {+ Units: mm+ SpurGear Pinion { Module: 1mm Teeth: 40 PressureAngle: 20deg FaceWidth: 5mm }+ InternalSpurGear Ring { Module: 1mm Teeth: 30 PressureAngle: 20deg FaceWidth: 5mm OutsideDiameter: 35mm }+ Interface<Gear> BadMesh { A: Pinion B: Ring }+}diff --git a/fixtures/Invalid/Gears/incompatible-pair.firmament b/fixtures/Invalid/Gears/incompatible-pair.firmamentnew file mode 100644index 00000000..dea1b771--- /dev/null+++ b/fixtures/Invalid/Gears/incompatible-pair.firmament@@ -0,0 +1,6 @@+Model Invalid {+ Units: mm+ SpurGear A { Module: 1mm Teeth: 20 PressureAngle: 20deg FaceWidth: 5mm }+ SpurGear B { Module: 2mm Teeth: 20 PressureAngle: 20deg FaceWidth: 5mm }+ Interface<Gear> BadMesh { A: A B: B }+}diff --git a/fixtures/Invalid/Gears/incompatible-pressure-angle.firmament b/fixtures/Invalid/Gears/incompatible-pressure-angle.firmamentnew file mode 100644index 00000000..475898f3--- /dev/null+++ b/fixtures/Invalid/Gears/incompatible-pressure-angle.firmament@@ -0,0 +1,6 @@+Model Invalid {+ Units: mm+ SpurGear A { Module: 1mm Teeth: 20 PressureAngle: 20deg FaceWidth: 5mm }+ SpurGear B { Module: 1mm Teeth: 20 PressureAngle: 25deg FaceWidth: 5mm }+ Interface<Gear> BadMesh { A: A B: B }+}diff --git a/fixtures/Invalid/Gears/internal-ring-too-small.firmament b/fixtures/Invalid/Gears/internal-ring-too-small.firmamentnew file mode 100644index 00000000..0dbb13c6--- /dev/null+++ b/fixtures/Invalid/Gears/internal-ring-too-small.firmament@@ -0,0 +1 @@+Model Invalid { Units: mm InternalSpurGear Bad { Module: 1mm Teeth: 40 PressureAngle: 20deg FaceWidth: 5mm OutsideDiameter: 41mm } }diff --git a/fixtures/Invalid/Gears/invalid-bevel-pair.firmament b/fixtures/Invalid/Gears/invalid-bevel-pair.firmamentnew file mode 100644index 00000000..94b5ba14--- /dev/null+++ b/fixtures/Invalid/Gears/invalid-bevel-pair.firmament@@ -0,0 +1,6 @@+Model Invalid {+ Units: mm+ BevelGear A { Module: 1mm Teeth: 20 PressureAngle: 20deg FaceWidth: 5mm PitchConeAngle: 30deg }+ BevelGear B { Module: 1mm Teeth: 30 PressureAngle: 20deg FaceWidth: 5mm PitchConeAngle: 50deg }+ Interface<Gear> BadMesh { A: A B: B ShaftAngle: 90deg }+}diff --git a/fixtures/Invalid/Gears/invalid-ratchet.firmament b/fixtures/Invalid/Gears/invalid-ratchet.firmamentnew file mode 100644index 00000000..9e0657e4--- /dev/null+++ b/fixtures/Invalid/Gears/invalid-ratchet.firmament@@ -0,0 +1 @@+Model Invalid { Units: mm RatchetGear Bad { Teeth: 4 OutsideDiameter: 0mm FaceWidth: 5mm BoreDiameter: 10mm } }diff --git a/fixtures/Invalid/Gears/zero-face-width.firmament b/fixtures/Invalid/Gears/zero-face-width.firmamentnew file mode 100644index 00000000..fb63d447--- /dev/null+++ b/fixtures/Invalid/Gears/zero-face-width.firmament@@ -0,0 +1 @@+Model Invalid { Units: mm SpurGear Bad { Module: 1mm Teeth: 24 PressureAngle: 20deg FaceWidth: 0mm } }diff --git a/fixtures/Invalid/Gears/zero-module.firmament b/fixtures/Invalid/Gears/zero-module.firmamentnew file mode 100644index 00000000..e755b4c5--- /dev/null+++ b/fixtures/Invalid/Gears/zero-module.firmament@@ -0,0 +1 @@+Model Invalid { Units: mm SpurGear Bad { Module: 0mm Teeth: 24 PressureAngle: 20deg FaceWidth: 5mm BoreDiameter: 4mm } }diff --git a/fixtures/Invalid/Gears/zero-teeth.firmament b/fixtures/Invalid/Gears/zero-teeth.firmamentnew file mode 100644index 00000000..5e79880a--- /dev/null+++ b/fixtures/Invalid/Gears/zero-teeth.firmament@@ -0,0 +1 @@+Model Invalid { Units: mm SpurGear Bad { Module: 1mm Teeth: 0 PressureAngle: 20deg FaceWidth: 5mm BoreDiameter: 4mm } }diff --git a/scripts/Test-CanonicalFixtures.ps1 b/scripts/Test-CanonicalFixtures.ps1index 94a72325..b52b6e5c 100644--- a/scripts/Test-CanonicalFixtures.ps1+++ b/scripts/Test-CanonicalFixtures.ps1@@ -28,7 +28,7 @@ $forbidden = @()$failures = [Collections.Generic.List[string]]::new()-$requiredFeatures = @('Box', 'Cylinder', 'Sphere', 'Cone', 'Torus', 'Profile', 'Sweep', 'WireForm', 'Paperclip', 'Boss', 'Pocket', 'Hole', 'BlindHole', 'Counterbore', 'Countersink', 'Slot', 'Pattern', 'Chamfer', 'Fillet', 'Material', 'PMI', 'Template', 'SheetMetal', 'FEA', 'inlineSTEP', 'Assembly', 'Piping', 'ConstructionStateReplay', 'AddSectionChain', 'RemoveSectionChain', 'PostSectionChainHole')+$requiredFeatures = @('Box', 'Cylinder', 'Sphere', 'Cone', 'Torus', 'Profile', 'Sweep', 'WireForm', 'Paperclip', 'Boss', 'Pocket', 'Hole', 'BlindHole', 'Counterbore', 'Countersink', 'Slot', 'Pattern', 'Chamfer', 'Fillet', 'Material', 'PMI', 'Template', 'SheetMetal', 'FEA', 'inlineSTEP', 'Assembly', 'Piping', 'Gear', 'Interface<Gear>', 'ConstructionStateReplay', 'AddSectionChain', 'RemoveSectionChain', 'PostSectionChainHole')foreach ($feature in $requiredFeatures) {$entry = $coverage.features.$featureif ([string]::IsNullOrWhiteSpace($entry)) { $failures.Add("coverage: missing $feature"); continue }@@ -57,6 +57,7 @@ foreach ($file in Get-ChildItem -LiteralPath $canonicalRoot -Recurse -Filter '*.'fea-solve' { @('fea', $file.FullName, '--out-dir', $outputDirectory, '--json') }'assembly-inspect' { @('asm', 'inspect', $file.FullName, '--json') }'drawing-compile' { @('drawing', 'compile', $file.FullName, '--out-dir', $outputDirectory, '--json') }+ 'validate' { @('validate', $file.FullName, '--json') }default { $failures.Add("${relative}: unknown operation $($action.operation)"); continue }}$output = & dotnet $cli @arguments 2>&1 | Out-String