Skip to content

Next Gen STEP AP242 Native-ish BREP Geometric Modeling Kernel

Harden FTC-07 bounded display regression

Yuechen Li7708a09651b5
diff --git a/Aetheris.Kernel.Core.Tests/Step242/Step242Ftc07ViewMaterializationRegressionTests.cs b/Aetheris.Kernel.Core.Tests/Step242/Step242Ftc07ViewMaterializationRegressionTests.cs
index 0e5a032a..5d1be48d 100644
--- a/Aetheris.Kernel.Core.Tests/Step242/Step242Ftc07ViewMaterializationRegressionTests.cs
+++ b/Aetheris.Kernel.Core.Tests/Step242/Step242Ftc07ViewMaterializationRegressionTests.cs
@@ -6,6 +6,8 @@ namespace Aetheris.Kernel.Core.Tests.Step242;
public sealed class Step242Ftc07ViewMaterializationRegressionTests
{
+ private static readonly TimeSpan Ftc07TessellationBudget = TimeSpan.FromSeconds(5);
+ private static readonly TimeSpan Ftc07WallClockGuard = TimeSpan.FromSeconds(30);
private const string RelativePath = "testdata/step242/nist/FTC/nist_ftc_07_asme1_ap242-e2.stp";
[Fact]
@@ -14,10 +16,13 @@ public sealed class Step242Ftc07ViewMaterializationRegressionTests
var body = ImportFixture();
var stopwatch = Stopwatch.StartNew();
- var tessellation = BrepDisplayTessellator.TessellateBounded(body);
+ var tessellation = BrepDisplayTessellator.TessellateBounded(body, executionTimeout: Ftc07TessellationBudget);
stopwatch.Stop();
- Assert.True(stopwatch.Elapsed < TimeSpan.FromSeconds(15), $"FTC-07 display tessellation exceeded the bounded wall clock budget ({stopwatch.Elapsed}).");
+ Assert.True(
+ stopwatch.Elapsed < Ftc07WallClockGuard,
+ $"FTC-07 display tessellation exceeded the bounded wall-clock guard ({stopwatch.Elapsed}); " +
+ $"tessellation budget was {Ftc07TessellationBudget}; diagnostics: {FormatDiagnostics(tessellation.Diagnostics)}");
if (tessellation.IsSuccess)
{
@@ -33,7 +38,7 @@ public sealed class Step242Ftc07ViewMaterializationRegressionTests
{
var body = ImportFixture();
- var tessellation = BrepDisplayTessellator.TessellateBounded(body);
+ var tessellation = BrepDisplayTessellator.TessellateBounded(body, executionTimeout: Ftc07TessellationBudget);
if (tessellation.IsSuccess)
{
return;
@@ -56,7 +61,7 @@ public sealed class Step242Ftc07ViewMaterializationRegressionTests
{
var body = ImportFixture();
- var partial = BrepDisplayTessellator.TessellateBoundedPartial(body);
+ var partial = BrepDisplayTessellator.TessellateBoundedPartial(body, executionTimeout: Ftc07TessellationBudget);
Assert.NotEmpty(partial.FacePatches);
if ((partial.FaceDiagnostics ?? []).Count == 0)
@@ -71,6 +76,11 @@ public sealed class Step242Ftc07ViewMaterializationRegressionTests
diagnostic.Phase is "PlanarTriangulationWithHoles" or "PlanarLoopClassification" or "FaceTessellation" or "TrimLoopSampling" or "FaceDispatch");
}
+ private static string FormatDiagnostics(IReadOnlyList<global::Aetheris.Kernel.Core.Diagnostics.KernelDiagnostic> diagnostics)
+ => diagnostics.Count == 0
+ ? "<none>"
+ : string.Join(" | ", diagnostics.Select(diagnostic => $"{diagnostic.Source ?? diagnostic.Code.ToString()}: {diagnostic.Message}"));
+
private static global::Aetheris.Kernel.Core.Brep.BrepBody ImportFixture()
{
var absolutePath = Path.Combine(Step242CorpusManifestRunner.RepoRoot(), RelativePath.Replace('/', Path.DirectorySeparatorChar));
diff --git a/docs/audits/display-flake-a0-bounded-tessellation-test-hardening.md b/docs/audits/display-flake-a0-bounded-tessellation-test-hardening.md
new file mode 100644
index 00000000..2f21df59
--- /dev/null
+++ b/docs/audits/display-flake-a0-bounded-tessellation-test-hardening.md
@@ -0,0 +1,40 @@
+# DISPLAY-FLAKE-A0 bounded tessellation test hardening
+
+## Failing tests investigated
+
+- `DisplayPreparationFallbackBuilderTests.Build_UnsupportedBody_StaysOnExistingFallbackWithoutScaffoldAttempt`
+- `Step242Ftc07ViewMaterializationRegressionTests.Step242Ftc07ViewMaterialization_CompletesOrReportsBoundedDiagnostic`
+
+## Reproduction results
+
+The broad filtered validation command was rerun after restore/build:
+
+```bash
+dotnet test Aetheris.slnx -f net10.0 --no-build --filter "INLINE-STEP|InlineStep|FirmamentV2|AP242|Build|Step242"
+```
+
+In this environment the broad run passed, including `Aetheris.Kernel.Core.Tests` with 306 matching tests in about 2 minutes. Direct reruns also passed: `DisplayPreparationFallbackBuilderTests` completed 7 tests in under 1 second per run, and `Step242Ftc07ViewMaterializationRegressionTests` completed 3 tests in roughly 22-23 seconds per run.
+
+## Root cause
+
+The FTC-07 regression was asserting a fixed 15-second process wall-clock limit around a test fixture that intentionally exercises the bounded tessellation timeout path. That wall-clock assertion measured scheduler/load overhead in addition to the production tessellation budget. Under broad filtered runs, other matching tests can increase machine load enough for the wall-clock assertion to become brittle even when the implementation still returns the documented bounded result: either display patches or a `Viewer.Tessellation.Timeout` diagnostic.
+
+The display fallback test did not reproduce locally. Its contract remains stable: unsupported non-B-spline bodies should stay on tessellator fallback patches and should not report scaffold rejection reasons.
+
+## Hardening applied
+
+The FTC-07 tests now use an explicit 5-second tessellation budget and keep a separate 30-second wall-clock guard with diagnostic output on failure. This preserves the bounded-behavior contract while avoiding a brittle machine-load threshold. Related FTC-07 regression tests use the same explicit budget so the fixture is validated consistently.
+
+## Before / after behavior
+
+Before, a valid bounded timeout result could still fail if the end-to-end test process exceeded 15 seconds under load. After, the test still fails if materialization hangs past the guard or returns an unexpected result, but it accepts the documented outcomes: successful patches or the bounded `Viewer.Tessellation.Timeout` diagnostic.
+
+## Validation commands
+
+```bash
+dotnet restore Aetheris.slnx
+dotnet build Aetheris.slnx -f net10.0 --no-restore /m:1
+dotnet test Aetheris.Kernel.Core.Tests/Aetheris.Kernel.Core.Tests.csproj -f net10.0 --no-build --filter "DisplayPreparationFallbackBuilderTests"
+dotnet test Aetheris.Kernel.Core.Tests/Aetheris.Kernel.Core.Tests.csproj -f net10.0 --no-build --filter "Step242Ftc07ViewMaterializationRegressionTests"
+dotnet test Aetheris.slnx -f net10.0 --no-build --filter "INLINE-STEP|InlineStep|FirmamentV2|AP242|Build|Step242"
+```