Skip to content

Next Gen STEP AP242 Native-ish BREP Geometric Modeling Kernel

Harden bounded blind-hole recovery coverage

Yuechen Li53f3fdaa743d
diff --git a/Aetheris.Kernel.Firmament.Tests/BlindHoleVariantHardeningTests.cs b/Aetheris.Kernel.Firmament.Tests/BlindHoleVariantHardeningTests.cs
new file mode 100644
index 00000000..8d0e9be9
--- /dev/null
+++ b/Aetheris.Kernel.Firmament.Tests/BlindHoleVariantHardeningTests.cs
@@ -0,0 +1,139 @@
+using Aetheris.Kernel.Core.Cir;
+using Aetheris.Kernel.Core.Math;
+using Aetheris.Kernel.Core.Step242;
+using Aetheris.Kernel.Firmament.Materializer;
+
+namespace Aetheris.Kernel.Firmament.Tests;
+
+public sealed class BlindHoleVariantHardeningTests
+{
+ [Fact]
+ public void BlindHole_TopEntry_AdmitsExecutesAndExports()
+ {
+ var eval = new HoleRecoveryPolicy().Evaluate(new FrepMaterializerContext(BuildTopEntryBlindHole()));
+ Assert.True(eval.Admissible);
+ Assert.Contains("selected-variant:BlindHoleVariant", eval.Evidence);
+ Assert.Contains(eval.EvaluationsFor(nameof(BlindHoleVariant)), d => d.Contains("entry face detected: top(+Z)", StringComparison.OrdinalIgnoreCase));
+
+ var plan = Assert.IsType<HoleRecoveryPlan>(eval.Plan);
+ var execution = HoleRecoveryExecutor.Execute(plan);
+ Assert.Equal(HoleRecoveryExecutionStatus.Succeeded, execution.Status);
+
+ var step = Step242Exporter.ExportBody(execution.Body!, new Step242ExportOptions { ProductName = "v9-blind-top" });
+ Assert.True(step.IsSuccess, string.Join(" | ", step.Diagnostics.Select(d => d.Message)));
+ Assert.Contains("MANIFOLD_SOLID_BREP", step.Value, StringComparison.Ordinal);
+ Assert.DoesNotContain("BREP_WITH_VOIDS", step.Value, StringComparison.Ordinal);
+ }
+
+ [Fact]
+ public void BlindHole_BottomEntry_AdmitsExecutesAndExports()
+ {
+ var eval = new HoleRecoveryPolicy().Evaluate(new FrepMaterializerContext(BuildBottomEntryBlindHole()));
+ Assert.True(eval.Admissible);
+ Assert.Contains("selected-variant:BlindHoleVariant", eval.Evidence);
+ Assert.Contains(eval.EvaluationsFor(nameof(BlindHoleVariant)), d => d.Contains("entry face detected: bottom(-Z)", StringComparison.OrdinalIgnoreCase));
+
+ var execution = HoleRecoveryExecutor.Execute(Assert.IsType<HoleRecoveryPlan>(eval.Plan));
+ Assert.Equal(HoleRecoveryExecutionStatus.Succeeded, execution.Status);
+
+ var step = Step242Exporter.ExportBody(execution.Body!, new Step242ExportOptions { ProductName = "v9-blind-bottom" });
+ Assert.True(step.IsSuccess, string.Join(" | ", step.Diagnostics.Select(d => d.Message)));
+ Assert.DoesNotContain("BREP_WITH_VOIDS", step.Value, StringComparison.Ordinal);
+ }
+
+ [Fact]
+ public void BlindHole_TranslatedInput_AdmitsExecutesAndExports()
+ {
+ var root = new CirSubtractNode(
+ new CirTransformNode(new CirBoxNode(20d, 20d, 10d), Transform3D.CreateTranslation(new Vector3D(7d, -4d, 5d))),
+ new CirTransformNode(new CirCylinderNode(2d, 4d), Transform3D.CreateTranslation(new Vector3D(8d, -3d, 8d))));
+
+ var eval = new HoleRecoveryPolicy().Evaluate(new FrepMaterializerContext(root));
+ Assert.True(eval.Admissible);
+ Assert.Contains("selected-variant:BlindHoleVariant", eval.Evidence);
+ Assert.Contains(eval.EvaluationsFor(nameof(BlindHoleVariant)), d => d.Contains("translated geometry normalized", StringComparison.OrdinalIgnoreCase));
+
+ var execution = HoleRecoveryExecutor.Execute(Assert.IsType<HoleRecoveryPlan>(eval.Plan));
+ Assert.Equal(HoleRecoveryExecutionStatus.Succeeded, execution.Status);
+
+ var step = Step242Exporter.ExportBody(execution.Body!, new Step242ExportOptions { ProductName = "v9-blind-translated" });
+ Assert.True(step.IsSuccess, string.Join(" | ", step.Diagnostics.Select(d => d.Message)));
+ Assert.DoesNotContain("BREP_WITH_VOIDS", step.Value, StringComparison.Ordinal);
+ }
+
+ [Fact]
+ public void BlindHole_DoesNotStealThroughHole()
+ {
+ var eval = new HoleRecoveryPolicy().Evaluate(new FrepMaterializerContext(new CirSubtractNode(new CirBoxNode(20, 10, 8), new CirCylinderNode(2, 20))));
+ Assert.Contains("selected-variant:ThroughHoleVariant", eval.Evidence);
+ Assert.DoesNotContain("selected-variant:BlindHoleVariant", eval.Evidence);
+ Assert.Contains(eval.EvaluationsFor(nameof(BlindHoleVariant)), d => d.Contains("through-hole rejected as not blind", StringComparison.OrdinalIgnoreCase));
+ }
+
+ [Fact]
+ public void BlindHole_DoesNotStealCounterbore()
+ {
+ var eval = new HoleRecoveryPolicy().Evaluate(new FrepMaterializerContext(BuildCounterbore()));
+ Assert.True(eval.Admissible);
+ Assert.Contains("selected-variant:CounterboreVariant", eval.Evidence);
+ Assert.DoesNotContain("selected-variant:BlindHoleVariant", eval.Evidence);
+ }
+
+ [Fact]
+ public void BlindHole_RejectsNearThroughWithinTolerance()
+ {
+ var tol = Aetheris.Kernel.Core.Numerics.ToleranceContext.Default.Linear;
+ var boxDepth = 10d;
+ var cylHeight = boxDepth - (tol * 0.25d);
+ var cylCenterZ = (boxDepth * 0.5d) - (cylHeight * 0.5d);
+ var root = new CirSubtractNode(new CirBoxNode(20d, 20d, boxDepth), new CirTransformNode(new CirCylinderNode(2d, cylHeight), Transform3D.CreateTranslation(new Vector3D(0d, 0d, cylCenterZ))));
+
+ var eval = new HoleRecoveryPolicy().Evaluate(new FrepMaterializerContext(root));
+ Assert.False(eval.Admissible);
+ Assert.Contains(eval.RejectionReasons, r => r.Contains("Unsupported", StringComparison.Ordinal));
+ }
+
+ [Fact]
+ public void BlindHole_RejectsNoEntryOpening()
+ {
+ var root = new CirSubtractNode(new CirBoxNode(20d, 20d, 10d), new CirCylinderNode(2d, 4d));
+ var eval = new HoleRecoveryPolicy().Evaluate(new FrepMaterializerContext(root));
+ Assert.False(eval.Admissible);
+ Assert.Contains("UnsupportedMissingEntryFace", string.Join("|", eval.RejectionReasons), StringComparison.Ordinal);
+ }
+
+ [Fact]
+ public void BlindHole_RejectsTangentOrGrazingRadius()
+ {
+ var root = new CirSubtractNode(new CirBoxNode(20d, 20d, 10d), new CirTransformNode(new CirCylinderNode(10d, 4d), Transform3D.CreateTranslation(new Vector3D(0d, 0d, 3d))));
+ var eval = new HoleRecoveryPolicy().Evaluate(new FrepMaterializerContext(root));
+ Assert.False(eval.Admissible);
+ Assert.Contains("UnsupportedTangentOrOutsideClearance", string.Join("|", eval.RejectionReasons), StringComparison.Ordinal);
+ Assert.Contains(eval.EvaluationsFor(nameof(BlindHoleVariant)), d => d.Contains("tangent/grazing", StringComparison.OrdinalIgnoreCase));
+ }
+
+ [Fact]
+ public void BlindHole_RejectsUnsupportedTransform()
+ {
+ var rotated = new CirSubtractNode(
+ new CirBoxNode(20d, 20d, 10d),
+ new CirTransformNode(new CirCylinderNode(2d, 4d), Transform3D.CreateRotationX(Math.PI / 6d) * Transform3D.CreateTranslation(new Vector3D(0d, 0d, 3d))));
+
+ var eval = new HoleRecoveryPolicy().Evaluate(new FrepMaterializerContext(rotated));
+ Assert.False(eval.Admissible);
+ var remat = FrepSemanticRecoveryRematerializer.TryRecover(rotated);
+ Assert.False(remat.Succeeded);
+ Assert.Null(remat.Body);
+ }
+
+ private static CirNode BuildTopEntryBlindHole()
+ => new CirSubtractNode(new CirBoxNode(20d, 20d, 10d), new CirTransformNode(new CirCylinderNode(2d, 4d), Transform3D.CreateTranslation(new Vector3D(0d, 0d, 3d))));
+
+ private static CirNode BuildBottomEntryBlindHole()
+ => new CirSubtractNode(new CirBoxNode(20d, 20d, 10d), new CirTransformNode(new CirCylinderNode(2d, 4d), Transform3D.CreateTranslation(new Vector3D(0d, 0d, -3d))));
+
+ private static CirNode BuildCounterbore()
+ => new CirSubtractNode(
+ new CirSubtractNode(new CirBoxNode(20, 20, 10), new CirCylinderNode(2, 20)),
+ new CirTransformNode(new CirCylinderNode(4, 4), Transform3D.CreateTranslation(new Vector3D(0, 0, -3))));
+}
diff --git a/Aetheris.Kernel.Firmament/Materializer/HoleRecoveryPolicy.cs b/Aetheris.Kernel.Firmament/Materializer/HoleRecoveryPolicy.cs
index 427a0f20..8b07b71f 100644
--- a/Aetheris.Kernel.Firmament/Materializer/HoleRecoveryPolicy.cs
+++ b/Aetheris.Kernel.Firmament/Materializer/HoleRecoveryPolicy.cs
@@ -81,7 +81,7 @@ internal sealed class ThroughHoleVariant : IHoleRecoveryVariant
internal sealed class BlindHoleVariant : IHoleRecoveryVariant
{
- private const double Score = 1050d;
+ private const double Score = 900d;
public string Name => nameof(BlindHoleVariant);
public HoleRecoveryVariantEvaluation Evaluate(FrepMaterializerContext context)
@@ -89,7 +89,12 @@ internal sealed class BlindHoleVariant : IHoleRecoveryVariant
var recognition = CirBoxCylinderRecognizer.Recognize(new CirBoxCylinderRecognizerInput(context.Root, context.ReplayLog, context.SourceLabel));
if (recognition.Success)
{
- return new(Name, false, 0d, null, ["blind-hole", "rectangular-box-host"], ["UnsupportedThroughHole"], ["BlindHoleVariant rejected: recognizer admitted through-hole span."]);
+ var throughDiagnostics = new List<string>(recognition.Diagnostics)
+ {
+ "Blind-hole variant evaluated and rejected: recognizer admitted through-hole span.",
+ "through-hole rejected as not blind."
+ };
+ return new(Name, false, 0d, null, ["blind-hole", "rectangular-box-host"], ["UnsupportedThroughHole", "NotBlindThroughSpan"], throughDiagnostics);
}
if (recognition.Reason is not CirBoxCylinderRecognitionReason.UnsupportedNotThroughHole)
@@ -129,6 +134,7 @@ internal sealed class BlindHoleVariant : IHoleRecoveryVariant
{
rejection = "UnsupportedHostNotBoxOrTransform";
diagnostics.Add("Blind-hole host must be box with translation-only transform.");
+ diagnostics.Add("unsupported transform rejected.");
return false;
}
@@ -136,6 +142,7 @@ internal sealed class BlindHoleVariant : IHoleRecoveryVariant
{
rejection = "UnsupportedToolNotCylinderOrTransform";
diagnostics.Add("Blind-hole tool must be cylinder with translation-only transform.");
+ diagnostics.Add("unsupported transform rejected.");
return false;
}
@@ -147,10 +154,12 @@ internal sealed class BlindHoleVariant : IHoleRecoveryVariant
var entersTop = Math.Abs(cylMaxZ - boxMaxZ) <= tol;
var entersBottom = Math.Abs(cylMinZ - boxMinZ) <= tol;
+ diagnostics.Add($"translated geometry normalized: hostT=({hostT.X:R},{hostT.Y:R},{hostT.Z:R}), toolT=({toolT.X:R},{toolT.Y:R},{toolT.Z:R}).");
if (!entersTop && !entersBottom)
{
rejection = "UnsupportedMissingEntryFace";
diagnostics.Add("Blind-hole cylinder must intersect exactly one entry face.");
+ diagnostics.Add("entry face not reached; blind-hole rejected.");
return false;
}
@@ -158,6 +167,7 @@ internal sealed class BlindHoleVariant : IHoleRecoveryVariant
{
rejection = "UnsupportedThroughFullDepth";
diagnostics.Add("Blind-hole cylinder intersects both entry faces (through-hole). ");
+ diagnostics.Add("through-hole rejected as not blind.");
return false;
}
@@ -166,6 +176,7 @@ internal sealed class BlindHoleVariant : IHoleRecoveryVariant
{
rejection = "UnsupportedBottomOutsideHost";
diagnostics.Add("Blind-hole bottom cap is outside host bounds.");
+ diagnostics.Add("opposite face reached or exceeded; blind-hole rejected as near-through or through.");
return false;
}
@@ -181,11 +192,15 @@ internal sealed class BlindHoleVariant : IHoleRecoveryVariant
{
rejection = "UnsupportedTangentOrOutsideClearance";
diagnostics.Add("Blind-hole cylinder radius must satisfy strict XY clearance.");
+ diagnostics.Add("tangent/grazing radius rejected.");
return false;
}
var depth = entersTop ? (boxMaxZ - cylMinZ) : (cylMaxZ - boxMinZ);
- diagnostics.Add($"Blind entry face detected: {(entersTop ? "Top(+Z)" : "Bottom(-Z)")}.");
+ diagnostics.Add($"Blind entry face detected: {(entersTop ? "top(+Z)" : "bottom(-Z)")}.");
+ diagnostics.Add("entry face reached.");
+ diagnostics.Add("blind bottom inside host.");
+ diagnostics.Add("opposite face not reached.");
diagnostics.Add($"Blind depth computed: {depth:R}.");
diagnostics.Add("Blind-hole plan produced.");
diff --git a/docs/cir-recovery-v8-blind-hole-variant-executor-step.md b/docs/cir-recovery-v8-blind-hole-variant-executor-step.md
index 16e5d47f..a6ddff05 100644
--- a/docs/cir-recovery-v8-blind-hole-variant-executor-step.md
+++ b/docs/cir-recovery-v8-blind-hole-variant-executor-step.md
@@ -68,3 +68,5 @@ Stable rejection/defer diagnostics remain for:
## Recommended V9
Generalize bounded blind-hole coverage to additional entry-side and transform compositions with explicit admissibility/score tuning and shape-lab updates before any generic stack executor work.
+
+> V9 note: follow-up hardening for entry-side, translation, tolerance, and transform-rejection coverage is tracked in `docs/cir-recovery-v9-blind-hole-hardening.md`.
diff --git a/docs/cir-recovery-v9-blind-hole-hardening.md b/docs/cir-recovery-v9-blind-hole-hardening.md
new file mode 100644
index 00000000..08e6ef0e
--- /dev/null
+++ b/docs/cir-recovery-v9-blind-hole-hardening.md
@@ -0,0 +1,73 @@
+# CIR-RECOVERY-V9: bounded blind-hole hardening pass
+
+## Scope
+
+V9 hardens the bounded `BlindHoleVariant`/`HoleRecoveryExecutor` route introduced in V8 without expanding family scope.
+
+Included:
+
+- explicit top-entry (`+Z`) and bottom-entry (`-Z`) blind-hole coverage,
+- translation-wrapper normalization diagnostics and translated-case regression tests,
+- non-ambiguity assertions versus through-hole and counterbore variants,
+- boundary/tolerance rejection tightening around near-through and no-entry states,
+- unsupported non-translation transform rejection diagnostics.
+
+Excluded (non-goals):
+
+- countersink implementation,
+- counterbore behavior changes,
+- generic profile-stack/generic blind-hole executors,
+- STEP exporter behavior changes,
+- public API/CLI expansion,
+- topology naming/provenance expansion (SEM-A0 preserved).
+
+## Entry-side behavior
+
+`BlindHoleVariant` now emits explicit diagnostics for detected entry side:
+
+- `top(+Z)` entry,
+- `bottom(-Z)` entry.
+
+The bounded executor continues to infer placement from plan geometry and executes both sides using the same primitive+subtract route.
+
+## Translation support
+
+V9 explicitly validates translated `Subtract(translated box, translated cylinder)` blind-hole inputs.
+Diagnostics include normalized host/tool translation traces. Execution and STEP smoke remain manifold-solid and avoid `BREP_WITH_VOIDS`.
+
+## Boundary and tolerance policy
+
+V9 preserves conservative admission:
+
+- reject if the tool fails to reach exactly one entry face,
+- reject if it effectively reaches both entry/exit faces (near-through/through in tolerance band),
+- reject if blind bottom exits host bounds,
+- reject tangent/grazing XY clearance.
+
+New diagnostics distinguish entry-face reach, opposite-face reach/reject, and tangent/grazing rejection.
+
+## Non-ambiguity versus other hole variants
+
+Tests assert:
+
+- simple through-hole selects `ThroughHoleVariant`,
+- canonical counterbore selects `CounterboreVariant`,
+- blind-hole variant is evaluated but inadmissible with explicit reasons when not blind.
+
+Scoring remains deterministic; ambiguity handling is admissibility-first (explicit rejection), not score-only.
+
+## Unsupported transforms
+
+Non-translation transforms (for example rotation-wrapped tool cylinders) remain unsupported by bounded blind-hole recognition and now emit explicit `unsupported transform rejected` diagnostics.
+No false rematerialization fallback success is expected.
+
+## STEP export status
+
+No exporter changes were made. V9 smoke stays on existing exporter API and conventions:
+
+- expected: `MANIFOLD_SOLID_BREP`,
+- not expected: `BREP_WITH_VOIDS` for this bounded open-blind topology.
+
+## Next milestone
+
+CIR-RECOVERY-V10 should begin bounded countersink recognition/plan/execution hardening, reusing the same policy-family judgment path and admissibility-first diagnostics discipline.