Next Gen STEP AP242 Native-ish BREP Geometric Modeling Kernel
Perforation: one realization per opening shape, congruence-verified STEP
Claude7881dc4a3515
diff --git a/AGENTS.md b/AGENTS.mdindex 4cf91c22..1bb7b8fe 100644--- a/AGENTS.md+++ b/AGENTS.md@@ -58,11 +58,20 @@ Iterate with the fast lane and gate on the full one:```dotnet test Aetheris.Kernel.Core.Tests -c Release --no-build --filter "Category!=SlowCorpus"-dotnet test Aetheris.slnx -c Release --no-build -m:1 -- RunConfiguration.MaxCpuCount=1+dotnet test Aetheris.slnx -c Release --no-build```-Never report a change as verified on the fast lane alone - it omits the corpus-driven tests,-which are the ones that catch interchange regressions.+The full lane runs test projects in parallel; that is the day-to-day gate. Never report a change+as verified on the fast lane alone - it omits the corpus-driven tests, which are the ones that+catch interchange regressions.++The serial lane is an optional determinism check, not a daily gate. Run it when a change touches+shared static state (caches, memos, ambient context), test isolation, or ordering, or when a+parallel-lane failure looks order-dependent:++```+dotnet test Aetheris.slnx -c Release --no-build -m:1 -- RunConfiguration.MaxCpuCount=1+```When a test needs a STEP corpus file, take it from `Step242Corpus` (`Body`, `Import` or `Text`)rather than reading and importing it again. See CONTRIBUTING.md for when a test genuinely needsdiff --git a/Aetheris.CLI.Tests/ImportedFeatureAssistanceTests.cs b/Aetheris.CLI.Tests/ImportedFeatureAssistanceTests.csindex 16ecad2d..3b8d0a71 100644--- a/Aetheris.CLI.Tests/ImportedFeatureAssistanceTests.cs+++ b/Aetheris.CLI.Tests/ImportedFeatureAssistanceTests.cs@@ -89,10 +89,7 @@ public sealed class ImportedFeatureAssistanceTestsAssert.Contains("Source.MountHole.exit.Y", authored);if (!remove) Assert.Contains("diameter: Source.MountHole.diameter", authored);Assert.True(File.Exists(Path.Combine(directory,"firmament.lock.toml")));- stdout.GetStringBuilder().Clear();- Assert.Equal(0, CliRunner.Run(["validate", source, "--locked", "--json"], stdout, stderr));- using var validation = JsonDocument.Parse(stdout.ToString());- Assert.Equal("Built", validation.RootElement.GetProperty("firmamentV2Validation").GetProperty("validationLevel").GetString());+ // The plan's admission already reported Built; a locked build re-checks the receipt and compiles once more.stdout.GetStringBuilder().Clear();Assert.Equal(0, CliRunner.Run(["build", source, "--locked", "--output", Path.Combine(directory,"revision.step"), "--json"], stdout, stderr));using var build = JsonDocument.Parse(stdout.ToString());diff --git a/Aetheris.FEA.Tests/ExperimentalShellX1AuthorityTests.cs b/Aetheris.FEA.Tests/ExperimentalShellX1AuthorityTests.csindex 16fb0a3b..81591aee 100644--- a/Aetheris.FEA.Tests/ExperimentalShellX1AuthorityTests.cs+++ b/Aetheris.FEA.Tests/ExperimentalShellX1AuthorityTests.cs@@ -35,6 +35,12 @@ public sealed class ExperimentalShellX1AuthorityTestsAssert.InRange(result.Equilibrium.ResidualNewton.Length,0,1e-5);Assert.InRange(result.StrainEnergy!.RelativeResidual,0,1e-6);Assert.True(double.IsFinite(result.MaximumDisplacementMeters)&&result.MaximumDisplacementMeters>0);+ // Determinism is a property of the native shell route, not of model size: repeat the cheapest native solve.+ var repeat=Aetheris.FEA.Mechanics.LinearElasticSolver.Solve(compiled.Analysis!,new(RelativeResidualTolerance:1e-8,MaximumIterations:10000));+ Assert.True(repeat.IsSuccess);+ Assert.Equal(result.MaximumDisplacementMeters,repeat.MaximumDisplacementMeters);+ Assert.Equal(result.ExperimentalShell.DeterministicDiscretizationHash,repeat.ExperimentalShell!.DeterministicDiscretizationHash);+ Assert.Equal(result.Solver.ResidualHistory,repeat.Solver.ResidualHistory);}[Fact]@@ -64,11 +70,6 @@ public sealed class ExperimentalShellX1AuthorityTestsAssert.True(result.IsSuccess,string.Join("; ",result.Diagnostics.Select(x=>x.Code+":"+x.Message)));Assert.Equal(180,result.ExperimentalShell!.NativeSheetMetal!.SharedDisplacementDegreesOfFreedom);Assert.InRange(result.Equilibrium.ResidualNewton.Length,0,1e-5);- var repeat=Aetheris.FEA.Mechanics.LinearElasticSolver.Solve(analysis,new(RelativeResidualTolerance:1e-8,MaximumIterations:10000));- Assert.True(repeat.IsSuccess);- Assert.Equal(result.MaximumDisplacementMeters,repeat.MaximumDisplacementMeters);- Assert.Equal(result.ExperimentalShell.DeterministicDiscretizationHash,repeat.ExperimentalShell!.DeterministicDiscretizationHash);- Assert.Equal(result.Solver.ResidualHistory,repeat.Solver.ResidualHistory);}[Fact]diff --git a/Aetheris.Kernel.Core.Tests/Brep/BrepHollowRadialCutPatternCongruenceTests.cs b/Aetheris.Kernel.Core.Tests/Brep/BrepHollowRadialCutPatternCongruenceTests.csnew file mode 100644index 00000000..ce2cc773--- /dev/null+++ b/Aetheris.Kernel.Core.Tests/Brep/BrepHollowRadialCutPatternCongruenceTests.cs@@ -0,0 +1,71 @@+using Aetheris.Kernel.Core.Brep;+using Aetheris.Kernel.Core.Brep.Features;+using Aetheris.Kernel.Core.Geometry;+using Aetheris.Kernel.Core.Step242;++namespace Aetheris.Kernel.Core.Tests.Brep;++/// <summary>Openings of one radius are realized once and placed rigidly, so identical holes carry identical+/// representations, and an exported pattern adds exactly N times what one opening adds.</summary>+public sealed class BrepHollowRadialCutPatternCongruenceTests+{+ private static readonly Lazy<(ThinWalledBodyRealization Host, HollowRadialCutPlacement[] Placements)> Grid = new(() =>+ {+ var host = ThinWalledBodyBRepPlanner.CreateCylinder(56, 142, 0.8).Value!;+ var placements = Enumerable.Range(0, 3).SelectMany(row => Enumerable.Range(0, 5).Select(column =>+ new HollowRadialCutPlacement($"r{row}c{column}", 4.5, 30 + row * 20, (9 + column * 72) * System.Math.PI / 180))).ToArray();+ return (host, placements);+ });++ [Fact]+ public void CongruentOpeningsShareOneRealizationAndStayOnTheirExactCurves()+ {+ var (host, placements) = Grid.Value;+ var built = BrepHollowRadialCutPattern.Build(host, placements);+ Assert.True(built.IsSuccess, string.Join("; ", built.Diagnostics.Select(d => d.Message)));+ var body = built.Value.Body;+ var curves = body.Geometry.Curves.Select(c => c.Value).Where(c => c.CertifiedIntersection is not null).Select(c => c.CertifiedIntersection!).ToArray();+ Assert.Equal(2 * placements.Length, curves.Length);++ // One representation shape per radius: same span count and control-point count for every outer and inner curve.+ Assert.Single(curves.Select(c => (c.SegmentCount, c.Curve.ControlPoints.Count)).Distinct());+ Assert.All(curves, c => Assert.Equal(curves[0].Curve.KnotValues, c.Curve.KnotValues));++ // A placed copy is still within its certified bound of its own exact intersection.+ foreach (var curve in curves)+ {+ var domain = curve.Authority.Domain;+ for (var i = 0; i <= 32; i++)+ {+ // The realized spline is parameterized by the exact curve's own parameter.+ var t = domain.Start + (domain.End - domain.Start) * i / 32d;+ var distance = (curve.Curve.Evaluate(t) - curve.Authority.Evaluate(t)).Length;+ Assert.True(distance <= curve.CertifiedDeviationBoundMm + 1e-12, $"deviation {distance} exceeds {curve.CertifiedDeviationBoundMm}");+ }+ }+ }++ [Fact]+ public void ExportedPatternEntitiesAreLinearInTheOpeningCount()+ {+ var (host, placements) = Grid.Value;+ var options = new Step242ExportOptions { ProductName = "p", ApplicationName = "test", BrepExportPreflightMode = BrepExportPreflightMode.Enforce, BrepExportPreflightPolicy = BrepExportPreflightPolicy.TrustedProductionRoute };+ IReadOnlyDictionary<string, int> Census(int n) =>+ Step242EntityCensus.Count(Step242Exporter.ExportBody(BrepHollowRadialCutPattern.Build(host, placements[..n]).Value!.Body, options).Value!);+ var one = Census(1); var two = Census(2);+ Assert.Null(Step242EntityCensus.LinearMismatch(one, two, Census(placements.Length), placements.Length));+ }++ [Fact]+ public void CensusNamesTheEntityTypeAMissingInstanceDropped()+ {+ var one = new Dictionary<string, int> { ["ADVANCED_FACE"] = 6, ["CYLINDRICAL_SURFACE"] = 3, ["CARTESIAN_POINT"] = 40 };+ var two = new Dictionary<string, int> { ["ADVANCED_FACE"] = 7, ["CYLINDRICAL_SURFACE"] = 4, ["CARTESIAN_POINT"] = 70 };+ var five = new Dictionary<string, int> { ["ADVANCED_FACE"] = 10, ["CYLINDRICAL_SURFACE"] = 6, ["CARTESIAN_POINT"] = 1 };+ var mismatch = Step242EntityCensus.LinearMismatch(one, two, five, 5);+ Assert.Equal("CYLINDRICAL_SURFACE: expected 7 for 5 congruent instances, found 6", mismatch);+ // Shared leaf geometry (points, directions, vectors) is deduplicated by the writer and not counted.+ var complete = new Dictionary<string, int> { ["ADVANCED_FACE"] = 10, ["CYLINDRICAL_SURFACE"] = 7, ["CARTESIAN_POINT"] = 1 };+ Assert.Null(Step242EntityCensus.LinearMismatch(one, two, complete, 5));+ }+}diff --git a/Aetheris.Kernel.Core/Brep/Features/BrepHollowRadialCutPattern.cs b/Aetheris.Kernel.Core/Brep/Features/BrepHollowRadialCutPattern.csindex a0c49fd3..8e43a7c8 100644--- a/Aetheris.Kernel.Core/Brep/Features/BrepHollowRadialCutPattern.cs+++ b/Aetheris.Kernel.Core/Brep/Features/BrepHollowRadialCutPattern.cs@@ -127,6 +127,7 @@ public static class BrepHollowRadialCutPatternvar edgeNames = new Dictionary<string, IReadOnlyList<EdgeId>>(StringComparer.Ordinal);var certificates = new Dictionary<string, HollowRadialCutCertificate>(StringComparer.Ordinal);var nextCurve = blended ? 9 : 7; var nextSurface = blended ? 8 : 6;+ var templates = new Dictionary<double, OpeningTemplate>();foreach (var placement in placements){var canonicalAngle = Normalize(placement.AngleRadians);@@ -140,14 +141,32 @@ public static class BrepHollowRadialCutPatternif (!outerAuthority.IsSuccess) return InstanceFailure(placement, outerAuthority.Diagnostics);var innerAuthority = CylinderCylinderIntersectionCurve.Create(inner, tool, center, CylinderIntersectionBranch.PositiveCutterAxis, full, tolerance: tol);if (!innerAuthority.IsSuccess) return InstanceFailure(placement, innerAuthority.Diagnostics);- var outerCurve = CylinderIntersectionCurveRealizer.Realize(outerAuthority.Value, tol);- if (!outerCurve.IsSuccess) return InstanceFailure(placement, outerCurve.Diagnostics);- var innerCurve = CylinderIntersectionCurveRealizer.Realize(innerAuthority.Value, tol);- if (!innerCurve.IsSuccess) return InstanceFailure(placement, innerCurve.Diagnostics);- var outerUv = CylinderIntersectionPcurveRealizer.Realize(outerCurve.Value, tol);- if (!outerUv.IsSuccess) return InstanceFailure(placement, outerUv.Diagnostics);- var innerUv = CylinderIntersectionPcurveRealizer.Realize(innerCurve.Value, tol);- if (!innerUv.IsSuccess) return InstanceFailure(placement, innerUv.Diagnostics);+ // Openings of one radius are congruent: a rotation about the host axis and a shift along it. The+ // first is realized adaptively; every other is that realization moved rigidly, so identical holes+ // carry identical representations and the realization cost is paid once per radius.+ KernelResult<QualifiedCylinderIntersectionRepresentation> outerCurve, innerCurve;+ KernelResult<QualifiedCylinderIntersectionPcurves> outerUv, innerUv;+ if (templates.TryGetValue(placement.Radius, out var template)+ && Place(template.Outer, outerAuthority.Value, canonicalAngle - template.Angle, placement.Z - template.Z) is { } placedOuter+ && Place(template.Inner, innerAuthority.Value, canonicalAngle - template.Angle, placement.Z - template.Z) is { } placedInner)+ {+ outerCurve = KernelResult<QualifiedCylinderIntersectionRepresentation>.Success(placedOuter.Edge);+ innerCurve = KernelResult<QualifiedCylinderIntersectionRepresentation>.Success(placedInner.Edge);+ outerUv = KernelResult<QualifiedCylinderIntersectionPcurves>.Success(placedOuter);+ innerUv = KernelResult<QualifiedCylinderIntersectionPcurves>.Success(placedInner);+ }+ else+ {+ outerCurve = CylinderIntersectionCurveRealizer.Realize(outerAuthority.Value, tol);+ if (!outerCurve.IsSuccess) return InstanceFailure(placement, outerCurve.Diagnostics);+ innerCurve = CylinderIntersectionCurveRealizer.Realize(innerAuthority.Value, tol);+ if (!innerCurve.IsSuccess) return InstanceFailure(placement, innerCurve.Diagnostics);+ outerUv = CylinderIntersectionPcurveRealizer.Realize(outerCurve.Value, tol);+ if (!outerUv.IsSuccess) return InstanceFailure(placement, outerUv.Diagnostics);+ innerUv = CylinderIntersectionPcurveRealizer.Realize(innerCurve.Value, tol);+ if (!innerUv.IsSuccess) return InstanceFailure(placement, innerUv.Diagnostics);+ templates.TryAdd(placement.Radius, new(canonicalAngle, placement.Z, outerUv.Value, innerUv.Value));+ }var o0 = V(outerAuthority.Value.Evaluate(0)); var oPi = V(outerAuthority.Value.Evaluate(System.Math.PI));var i0 = V(innerAuthority.Value.Evaluate(0)); var iPi = V(innerAuthority.Value.Evaluate(System.Math.PI));var outerFirst = builder.AddEdge(o0, oPi); var outerSecond = builder.AddEdge(oPi, o0);@@ -274,6 +293,47 @@ public static class BrepHollowRadialCutPatternnew HollowRadialCutTopologyMap(faceNames, loopNames, edgeNames), certificates, seamAngle));}+ private sealed record OpeningTemplate(double Angle, double Z, QualifiedCylinderIntersectionPcurves Outer, QualifiedCylinderIntersectionPcurves Inner);++ /// <summary>+ /// Moves a realized opening curve and its pcurves to another congruent opening on the same host: the 3D curve+ /// rotates about +Z by <paramref name="angle"/> and shifts by <paramref name="dz"/>; the host pcurve shifts in+ /// (u, v) by the exact authority's own offset; the cutter pcurve lives in the cutter's frame and is unchanged.+ /// Rigid motion preserves every analytic bound; the numerical allowance grows by the transform's round-off.+ /// Returns null when the exact authorities disagree with that model, so the caller realizes the instance itself.+ /// </summary>+ private static QualifiedCylinderIntersectionPcurves? Place(QualifiedCylinderIntersectionPcurves template,+ CylinderCylinderIntersectionCurve authority, double angle, double dz)+ {+ var source = template.Edge.Authority;+ var probes = new[] { source.Domain.Start, (source.Domain.Start + source.Domain.End) / 2, source.Domain.End };+ var (cos, sin) = (System.Math.Cos(angle), System.Math.Sin(angle));+ Point3D Move(Point3D p) => new(p.X * cos - p.Y * sin, p.X * sin + p.Y * cos, p.Z + dz);+ var hostShift = authority.EvaluateHostPcurve(probes[0]);+ var hostOrigin = source.EvaluateHostPcurve(probes[0]);+ var (du, dv) = (hostShift.U - hostOrigin.U, hostShift.V - hostOrigin.V);+ foreach (var t in probes)+ {+ var exact = authority.Evaluate(t); var moved = Move(source.Evaluate(t));+ var host = authority.EvaluateHostPcurve(t); var sourceHost = source.EvaluateHostPcurve(t);+ var tool = authority.EvaluateToolPcurve(t); var sourceTool = source.EvaluateToolPcurve(t);+ if ((exact - moved).Length > 1e-9 || System.Math.Abs(host.U - sourceHost.U - du) > 1e-12 || System.Math.Abs(host.V - sourceHost.V - dv) > 1e-9+ || System.Math.Abs(tool.U - sourceTool.U) > 1e-12 || System.Math.Abs(tool.V - sourceTool.V) > 1e-9) return null;+ }++ static BSpline3Curve Map(BSpline3Curve curve, Func<Point3D, Point3D> map) => new(curve.Degree, curve.ControlPoints.Select(map).ToArray(),+ curve.KnotMultiplicities, curve.KnotValues, curve.CurveForm, curve.ClosedCurve, curve.SelfIntersect, curve.KnotSpec);+ var scale = template.Edge.Curve.ControlPoints.Max(p => System.Math.Abs(p.X) + System.Math.Abs(p.Y) + System.Math.Abs(p.Z)) + System.Math.Abs(dz);+ var roundOff = 8 * 2.2204460492503131e-16 * scale;+ var edge = template.Edge with { Authority = authority, Curve = Map(template.Edge.Curve, Move), NumericalAllowanceMm = template.Edge.NumericalAllowanceMm + roundOff };+ return template with+ {+ Edge = edge,+ Host = Map(template.Host, p => new Point3D(p.X + du, p.Y + dv, p.Z)),+ NumericalAllowanceMm = template.NumericalAllowanceMm + roundOff+ };+ }+private static double Normalize(double value) { value %= 2 * System.Math.PI; return value < 0 ? value + 2 * System.Math.PI : value; }private static double AngularDistance(double a, double b) { var d = System.Math.Abs(a - b); return System.Math.Min(d, 2 * System.Math.PI - d); }private static KernelResult<HollowRadialCutPatternResult> InstanceFailure(HollowRadialCutPlacement placement,diff --git a/Aetheris.Kernel.Core/Step242/Step242EntityCensus.cs b/Aetheris.Kernel.Core/Step242/Step242EntityCensus.csnew file mode 100644index 00000000..25ff3e45--- /dev/null+++ b/Aetheris.Kernel.Core/Step242/Step242EntityCensus.cs@@ -0,0 +1,56 @@+namespace Aetheris.Kernel.Core.Step242;++/// <summary>+/// Per-type entity counts of an exported STEP file, and the congruence check that a pattern of N identical+/// instances adds exactly N times what one instance adds. The writer shares leaf geometry (points, directions,+/// vectors) between entities that happen to coincide, so those leaf types are not counted against the+/// prediction; every entity that refers to them is.+/// </summary>+public static class Step242EntityCensus+{+ private static readonly HashSet<string> SharedLeafTypes = new(StringComparer.Ordinal) { "CARTESIAN_POINT", "DIRECTION", "VECTOR" };++ /// <summary>Counts simple instances (<c>#n=TYPE(...)</c>) by type; complex instances (<c>#n=(...)</c>) are not counted.</summary>+ public static IReadOnlyDictionary<string, int> Count(string stepText)+ {+ ArgumentNullException.ThrowIfNull(stepText);+ var counts = new Dictionary<string, int>(StringComparer.Ordinal);+ var span = stepText.AsSpan();+ var position = 0;+ while (position < span.Length)+ {+ var lineEnd = span[position..].IndexOf('\n');+ var line = lineEnd < 0 ? span[position..] : span.Slice(position, lineEnd);+ position = lineEnd < 0 ? span.Length : position + lineEnd + 1;+ line = line.TrimStart();+ if (line.Length < 4 || line[0] != '#') continue;+ var equals = line.IndexOf('=');+ if (equals < 0) continue;+ var rest = line[(equals + 1)..].TrimStart();+ var open = rest.IndexOf('(');+ if (open <= 0) continue;+ var type = rest[..open].TrimEnd().ToString();+ counts[type] = counts.GetValueOrDefault(type) + 1;+ }++ return counts;+ }++ /// <summary>+ /// Null when <paramref name="full"/> holds exactly <c>one + (n - 1) * (two - one)</c> entities of every type+ /// other than the shared leaf types; otherwise the first type that differs.+ /// </summary>+ public static string? LinearMismatch(IReadOnlyDictionary<string, int> one, IReadOnlyDictionary<string, int> two,+ IReadOnlyDictionary<string, int> full, int n)+ {+ foreach (var type in one.Keys.Concat(two.Keys).Concat(full.Keys).Distinct(StringComparer.Ordinal).Order(StringComparer.Ordinal))+ {+ if (SharedLeafTypes.Contains(type)) continue;+ var expected = one.GetValueOrDefault(type) + (n - 1) * (two.GetValueOrDefault(type) - one.GetValueOrDefault(type));+ var actual = full.GetValueOrDefault(type);+ if (actual != expected) return $"{type}: expected {expected} for {n} congruent instances, found {actual}";+ }++ return null;+ }+}diff --git a/Aetheris.Kernel.Firmament.Tests/FirmamentPerforationTests.cs b/Aetheris.Kernel.Firmament.Tests/FirmamentPerforationTests.csindex 64acf6a0..c8b94b3a 100644--- a/Aetheris.Kernel.Firmament.Tests/FirmamentPerforationTests.cs+++ b/Aetheris.Kernel.Firmament.Tests/FirmamentPerforationTests.cs@@ -163,6 +163,8 @@ public sealed class FirmamentPerforationTestsvar report = Assert.IsType<FirmamentPerforationReport>(built.Value.Perforation);Assert.Equal(report.Rows * report.Columns, report.InstanceCount);Assert.Equal(133, report.InstanceCount);+ // 133 congruent openings are verified by one- and two-opening STEP round trips plus an exact census.+ Assert.Equal("congruent-specimens", report.VerificationBasis);Assert.Equal(report.InstanceCount * 3, built.Value.RuntimeCorrespondence!.Descendants.Count);var first = built.Value.RuntimeCorrespondence.Descendants.Where(d => d.SourceStableId == "perforation:Body.Vents.Row0.Col0").ToArray();Assert.Contains(first, d => d.Role == Aetheris.Kernel.Firmament.Materializer.SemanticTopologyRole.HoleWallFace && d.Face is not null);diff --git a/Aetheris.Kernel.Firmament.Tests/Ftc09ImportedEditingTests.cs b/Aetheris.Kernel.Firmament.Tests/Ftc09ImportedEditingTests.csindex 479abc97..4a8a42f0 100644--- a/Aetheris.Kernel.Firmament.Tests/Ftc09ImportedEditingTests.cs+++ b/Aetheris.Kernel.Firmament.Tests/Ftc09ImportedEditingTests.cs@@ -18,6 +18,8 @@ public sealed class Ftc09ImportedEditingTests}}static string Source(bool remove) => File.ReadAllText(Path.Combine(DirectoryPath, remove ? "ftc09-round-remove.firmament" : "ftc09-round-move.firmament"));+ // Read-only reuse of one compile of the golden move edit; the placement tests transform copies of its body.+ static readonly Lazy<FirmamentStepExportResult> GoldenMove = new(() => FirmamentBuildAndExport.CompileSource(Source(false), DirectoryPath).Value);static FirmamentV2ValidationReport Validate(string source) => FirmamentBuildAdmissionValidation.Admit(FirmamentV2ValidationReportBuilder.Build(FirmamentV2Parser.Parse(source, DirectoryPath), "revision.firmament", sourceText: source), source, DirectoryPath);@@ -65,7 +67,7 @@ public sealed class Ftc09ImportedEditingTests[InlineData(2)]public void PrincipalXAndZ_UseTheSameCertificateAfterRigidPlacement(int axis){- var built = FirmamentBuildAndExport.CompileSource(Source(false), DirectoryPath).Value;+ var built = GoldenMove.Value;var transform = axis == 0 ? Core.Math.Transform3D.CreateRotationZ(double.Pi / 2): Core.Math.Transform3D.CreateRotationX(double.Pi / 2);var placed = Aetheris.Kernel.Firmament.Assembly.FirmasmAssemblyExecutor.TransformBody(built.RuntimeBody!, transform);@@ -111,9 +113,17 @@ public sealed class Ftc09ImportedEditingTests"remove-field" => source.Replace("within:", "wthin:"),_ => source[..source.LastIndexOf('}')] + "Pmi { HoleDiameter Old { target: Source.region(\"MountHole\"); value: 6.35mm } } }"};+ // Validation admits by running the same compilation in memory, so one compile per case proves the+ // rejection; BuildAgreesWithValidationOnAnInvalidIntent covers the build entry point once.var validation = Validate(source);Assert.Equal("invalid", validation.Status);- Assert.False(FirmamentBuildAndExport.CompileSource(source, DirectoryPath).IsSuccess);Assert.Contains(validation.Diagnostics, d => d.SourceSpan is not null && d.Severity is "error" or "fatal");}++ [Fact]+ public void BuildAgreesWithValidationOnAnInvalidIntent()+ {+ var source = Source(false).Replace("Source.MountHole.diameter", "Source.MountHole.diammeter");+ Assert.False(FirmamentBuildAndExport.CompileSource(source, DirectoryPath).IsSuccess);+ }}diff --git a/Aetheris.Kernel.Firmament/FirmamentBuildAndExport.cs b/Aetheris.Kernel.Firmament/FirmamentBuildAndExport.csindex 916afa77..6954fa4e 100644--- a/Aetheris.Kernel.Firmament/FirmamentBuildAndExport.cs+++ b/Aetheris.Kernel.Firmament/FirmamentBuildAndExport.cs@@ -2620,33 +2620,71 @@ public static partial class FirmamentBuildAndExportif (!cylindricalStep.IsSuccess || cylindricalStep.Value is null)return Failure("perforation-cylindrical-step-export-failed: " + string.Join(" | ", cylindricalStep.Diagnostics.Select(d => d.Message)));var stepExportMilliseconds = Stopwatch.GetElapsedTime(stepExportStart).TotalMilliseconds;+ // The reimport proves that the STEP text faithfully encodes the body validated above. Openings of a+ // pattern are congruent (one realization moved rigidly) and proven disjoint at compile time, so a+ // one- and a two-opening specimen prove the encoding of an opening, alone and sharing host faces; the+ // full file must then hold exactly the entities N congruent openings add. Re-importing every opening+ // would re-prove the same opening N times.+ string? Verify(string stepText, int openings)+ {+ var imported = Step242Importer.ImportBody(stepText);+ if (!imported.IsSuccess || imported.Value is null || !FirmamentManifoldChecker.IsManifold(imported.Value))+ return "perforation-cylindrical-step-reimport-invalid: " + string.Join(" | ", imported.Diagnostics.Select(d => d.Message));+ var importedCylinders = imported.Value.Geometry.Surfaces+ .Where(pair => pair.Value.Kind == SurfaceGeometryKind.Cylinder)+ .Select(pair => pair.Value.Cylinder!.Value.Radius).ToArray();+ var importedPlanes = imported.Value.Geometry.Surfaces+ .Where(pair => pair.Value.Kind == SurfaceGeometryKind.Plane)+ .Select(pair => pair.Value.Plane!.Value.Origin.Z).ToArray();+ var importedTori = imported.Value.Geometry.Surfaces+ .Where(pair => pair.Value.Kind == SurfaceGeometryKind.Torus)+ .Select(pair => pair.Value.Torus!.Value).ToArray();+ if (imported.Value.Topology.Faces.Count() != openings + (hollow.BottomBlendRadius > 0 ? 7 : 5) ||+ importedCylinders.Length != openings + 2 ||+ importedPlanes.Length != 3 ||+ importedTori.Length != (hollow.BottomBlendRadius > 0 ? 2 : 0) ||+ (hollow.BottomBlendRadius > 0 &&+ (importedTori.Any(torus => System.Math.Abs(torus.MajorRadius - (cylinder.Radius - hollow.BottomBlendRadius)) > 1e-6) ||+ !importedTori.Any(torus => System.Math.Abs(torus.MinorRadius - hollow.BottomBlendRadius) < 1e-6) ||+ !importedTori.Any(torus => System.Math.Abs(torus.MinorRadius - (hollow.BottomBlendRadius - hollow.WallThickness)) < 1e-6))) ||+ !new[] { 0d, hollow.WallThickness, cylinder.Height }.All(z => importedPlanes.Any(p => System.Math.Abs(p - z) < 1e-6)) ||+ importedCylinders.Count(r => System.Math.Abs(r - feature.Diameter / 2) < 1e-6) != openings ||+ importedCylinders.Count(r => System.Math.Abs(r - cylinder.Radius) < 1e-6) != 1 ||+ importedCylinders.Count(r => System.Math.Abs(r - (cylinder.Radius - hollow.WallThickness)) < 1e-6) != 1)+ return "perforation-cylindrical-step-reimport-invalid: opening count or analytic radii changed";+ return null;+ }var stepReimportStart = Stopwatch.GetTimestamp();- var cylindricalImport = Step242Importer.ImportBody(cylindricalStep.Value);- if (!cylindricalImport.IsSuccess || cylindricalImport.Value is null || !FirmamentManifoldChecker.IsManifold(cylindricalImport.Value))- return Failure("perforation-cylindrical-step-reimport-invalid: " + string.Join(" | ", cylindricalImport.Diagnostics.Select(d => d.Message)));+ string verificationBasis;+ if (placements.Length <= 2)+ {+ if (Verify(cylindricalStep.Value, placements.Length) is { } reimportFailure) return Failure(reimportFailure);+ verificationBasis = "full-reimport";+ }+ else+ {+ var specimenCounts = new List<IReadOnlyDictionary<string, int>>();+ foreach (var openings in new[] { 1, 2 })+ {+ var specimen = BrepHollowRadialCutPattern.Build(hollowBody.Value, placements[..openings]);+ var specimenStep = specimen.IsSuccess && specimen.Value is not null+ ? Step242Exporter.ExportBody(specimen.Value.Body, new Step242ExportOptions+ {+ ProductName = cylindricalFeatureId, ApplicationName = "Aetheris.Firmament.Perforation.Cylindrical",+ BrepExportPreflightMode = BrepExportPreflightMode.Enforce, BrepExportPreflightPolicy = BrepExportPreflightPolicy.TrustedProductionRoute,+ })+ : null;+ if (specimenStep is not { IsSuccess: true, Value: { } specimenText })+ return Failure($"perforation-cylindrical-specimen-invalid: the {openings}-opening specimen did not build and export");+ if (Verify(specimenText, openings) is { } specimenFailure) return Failure(specimenFailure);+ specimenCounts.Add(Step242EntityCensus.Count(specimenText));+ }+ var full = Step242EntityCensus.Count(cylindricalStep.Value);+ if (Step242EntityCensus.LinearMismatch(specimenCounts[0], specimenCounts[1], full, placements.Length) is { } mismatch)+ return Failure($"perforation-cylindrical-step-congruence-invalid: {mismatch}");+ verificationBasis = "congruent-specimens";+ }var stepReimportMilliseconds = Stopwatch.GetElapsedTime(stepReimportStart).TotalMilliseconds;- var importedCylinders = cylindricalImport.Value.Geometry.Surfaces- .Where(pair => pair.Value.Kind == SurfaceGeometryKind.Cylinder)- .Select(pair => pair.Value.Cylinder!.Value.Radius).ToArray();- var importedPlanes = cylindricalImport.Value.Geometry.Surfaces- .Where(pair => pair.Value.Kind == SurfaceGeometryKind.Plane)- .Select(pair => pair.Value.Plane!.Value.Origin.Z).ToArray();- var importedTori = cylindricalImport.Value.Geometry.Surfaces- .Where(pair => pair.Value.Kind == SurfaceGeometryKind.Torus)- .Select(pair => pair.Value.Torus!.Value).ToArray();- if (cylindricalImport.Value.Topology.Faces.Count() != placements.Length + (hollow.BottomBlendRadius > 0 ? 7 : 5) ||- importedCylinders.Length != placements.Length + 2 ||- importedPlanes.Length != 3 ||- importedTori.Length != (hollow.BottomBlendRadius > 0 ? 2 : 0) ||- (hollow.BottomBlendRadius > 0 &&- (importedTori.Any(torus => System.Math.Abs(torus.MajorRadius - (cylinder.Radius - hollow.BottomBlendRadius)) > 1e-6) ||- !importedTori.Any(torus => System.Math.Abs(torus.MinorRadius - hollow.BottomBlendRadius) < 1e-6) ||- !importedTori.Any(torus => System.Math.Abs(torus.MinorRadius - (hollow.BottomBlendRadius - hollow.WallThickness)) < 1e-6))) ||- !new[] { 0d, hollow.WallThickness, cylinder.Height }.All(z => importedPlanes.Any(p => System.Math.Abs(p - z) < 1e-6)) ||- importedCylinders.Count(r => System.Math.Abs(r - feature.Diameter / 2) < 1e-6) != placements.Length ||- importedCylinders.Count(r => System.Math.Abs(r - cylinder.Radius) < 1e-6) != 1 ||- importedCylinders.Count(r => System.Math.Abs(r - (cylinder.Radius - hollow.WallThickness)) < 1e-6) != 1)- return Failure("perforation-cylindrical-step-reimport-invalid: opening count or analytic radii changed");var cylindricalDescendants = placements.SelectMany(placement => new[]{new SemanticTopologyDescendant($"material:perforation:{placement.StableId}:wall", "Face", SemanticTopologyRole.HoleWallFace,@@ -2680,7 +2718,8 @@ public static partial class FirmamentBuildAndExportc.InnerHostPcurveBoundMm, c.InnerToolPcurveBoundMm }.Max()),PatternBuildMilliseconds = patternBuildMilliseconds,StepExportMilliseconds = stepExportMilliseconds,- StepReimportMilliseconds = stepReimportMilliseconds+ StepReimportMilliseconds = stepReimportMilliseconds,+ VerificationBasis = verificationBasis};return KernelResult<FirmamentStepExportResult>.Success(new FirmamentStepExportResult(cylindricalStep.Value,cylindricalFeatureId, 0, "perforation-cylindrical", "local-radial-through-wall", Perforation: cylindricalReport)diff --git a/Aetheris.Kernel.Firmament/FirmamentStepExportResult.cs b/Aetheris.Kernel.Firmament/FirmamentStepExportResult.csindex 964c6d09..8e2c21ef 100644--- a/Aetheris.Kernel.Firmament/FirmamentStepExportResult.cs+++ b/Aetheris.Kernel.Firmament/FirmamentStepExportResult.cs@@ -90,6 +90,9 @@ public sealed record FirmamentPerforationReport(public double? PatternBuildMilliseconds { get; init; }public double? StepExportMilliseconds { get; init; }public double? StepReimportMilliseconds { get; init; }+ /// <summary>How the STEP text was verified: "full-reimport", or "congruent-specimens" (one- and two-opening+ /// specimens round-tripped, plus an exact per-entity count of the full file).</summary>+ public string? VerificationBasis { get; init; }}public sealed record FirmamentGearItemReport(diff --git a/docs/development/reports/2026-11/TEST-LANE-AND-PATTERN-SPEED.md b/docs/development/reports/2026-11/TEST-LANE-AND-PATTERN-SPEED.mdnew file mode 100644index 00000000..8b712adf--- /dev/null+++ b/docs/development/reports/2026-11/TEST-LANE-AND-PATTERN-SPEED.md@@ -0,0 +1,42 @@+# Test lane and pattern build speed++## What changed++- **STEP import memo keyed by (text, policy).** It used to skip any import with an `ImportPolicy`, which every+ inline-STEP and edit path passes. FTC-09 edit tests: 91 s to 21 s; CLI build: 10.0 s to 8.0 s.+- **Congruent perforation openings share one realization.** `BrepHollowRadialCutPattern` realizes one opening+ per radius (exact curves, host and cutter pcurves, certificates). It places every other opening by rigid+ motion, checked against that instance's exact authority, and falls back to full realization if the check+ fails. Identical holes now get identical representations; before, adaptive span selection varied with+ position.+- **Perforation STEP verification by congruence.** One- and two-opening specimens are exported and+ round-tripped with the full analytic checks. The full file must then hold exactly+ `count(1) + (N − 1) × (count(2) − count(1))` entities of every type except the writer's shared leaf geometry+ (`Step242EntityCensus`). Patterns of two or fewer openings still reimport in full. The report records+ `VerificationBasis`. The full body is still validated in memory first (bindings, every pcurve at 129 samples,+ preflight, manifold).+- **Test trims.** FTC-09 invalid-intent cases compile once (validation runs the build), with one build+ agreement test. The FTC-09 placement cases share one compile. The CLI plan/lock test drops a redundant+ `validate --locked`. FEA determinism repeats the cheap single-bend solve instead of the two-bend channel.+- **`AGENTS.md`:** the full lane is parallel by default; the serial lane is an optional determinism check.+ The CI workflows still run serially.++## Evidence++133-opening perforated sleeve (`FirmamentPerforationTests` source):++| | cold | warm, fresh geometry |+| --- | --- | --- |+| before | 8.4 s | 3.76 s (export 1.28, reimport 2.32) |+| after | 4.6 s | 2.19 s (export 1.44, verification 0.55) |++The exported STEP is 18.6 MB: each intersection curve is a cubic B-spline accurate to the kernel's linear+tolerance (about 25 spans). Export is now writer-bound. Faster float formatting was tried and dropped: the+current format caps output at 15 significant digits, and the alternative was both different and slower.++Full lane, this 2-core container: serial 855 s; parallel 603 s, all 20 assemblies green, peak about 3.7 GB.++## Verdict++Success for the import memo and the perforation route. The remaining perforation cost is STEP serialization of+dense exact curves, which is a representation decision (tolerance or span merging), not redundant work.