Skip to content

Next Gen STEP AP242 Native-ish BREP Geometric Modeling Kernel

Add V4.1 Firmament export semantic recovery regressions

Yuechen Li573208e2d0cc
diff --git a/Aetheris.Kernel.Firmament.Tests/FirmamentStepExporterTests.cs b/Aetheris.Kernel.Firmament.Tests/FirmamentStepExporterTests.cs
index bcdda40c..a3e6a18d 100644
--- a/Aetheris.Kernel.Firmament.Tests/FirmamentStepExporterTests.cs
+++ b/Aetheris.Kernel.Firmament.Tests/FirmamentStepExporterTests.cs
@@ -233,7 +233,7 @@ public sealed class FirmamentStepExporterTests
[Fact]
- public void CirOnly_BoxMinusCylinder_ExportSucceedsAfterRematerialization()
+ public void FirmamentStepExporter_CirOnlyBoxCylinder_ExportsViaSemanticRecovery()
{
var compiler = new FirmamentCompiler();
var source = FirmamentCorpusHarness.ReadFixtureText("testdata/firmament/examples/boolean_box_cylinder_hole.firmament");
@@ -257,7 +257,38 @@ public sealed class FirmamentStepExporterTests
var export = FirmamentStepExporter.Export(cirOnlyArtifact);
Assert.True(export.IsSuccess, string.Join(" | ", export.Diagnostics.Select(d => d.Message)));
- Assert.Contains("PRODUCT_DEFINITION", export.Value.StepText, StringComparison.Ordinal);
+ Assert.Contains("ISO-10303-21", export.Value.StepText, StringComparison.Ordinal);
+ Assert.Contains("MANIFOLD_SOLID_BREP", export.Value.StepText, StringComparison.Ordinal);
+ Assert.Contains("ADVANCED_FACE", export.Value.StepText, StringComparison.Ordinal);
+ Assert.Contains("CYLINDRICAL_SURFACE", export.Value.StepText, StringComparison.Ordinal);
+
+ var remat = NativeGeometryRematerializer.TryRematerialize(artifact.PrimitiveLoweringPlan!, cirOnlyState);
+ Assert.True(remat.IsSuccess, string.Join(" | ", remat.Diagnostics.Select(d => d.Message)));
+ Assert.Contains(remat.Value.TransitionEvents, e => e.Message.Contains("semantic recovery policy", StringComparison.Ordinal));
+ }
+
+ [Fact]
+ public void FirmamentStepExporter_CirOnlyTranslatedBoxCylinder_ExportsViaSemanticRecovery()
+ {
+ var plan = new FirmamentPrimitiveLoweringPlan(
+ [new FirmamentLoweredPrimitive(0, "base", FirmamentLoweredPrimitiveKind.Box, new FirmamentLoweredBoxParameters(20, 20, 10), new FirmamentLoweredPlacement(new FirmamentLoweredPlacementOriginAnchor(), true, [4d, 1d, 3d], null, null, null, []))],
+ [new FirmamentLoweredBoolean(1, "hole", FirmamentLoweredBooleanKind.Subtract, "from", "base", new FirmamentLoweredToolOp("cylinder", new Dictionary<string, string> { { "op", "cylinder" }, { "radius", "3" }, { "height", "20" } }, "op cylinder radius=3 height=20"), new FirmamentLoweredPlacement(new FirmamentLoweredPlacementOriginAnchor(), true, [4d, 1d, 3d], null, null, null, []))],
+ []);
+ var cirOnlyState = new NativeGeometryState(NativeGeometryExecutionMode.CirOnly, NativeGeometryMaterializationAuthority.PendingRematerialization, null, "hole", BuildReplayLogForTranslatedBoxMinusCylinder(), [], new NativeGeometryCirMirrorState(CirMirrorStatus.NotAttempted, null, []));
+ var cirOnlyArtifact = new FirmamentCompilationArtifact(
+ PrimitiveLoweringPlan: plan,
+ PrimitiveExecutionResult: new FirmamentPrimitiveExecutionResult([], [], cirOnlyState));
+
+ var export = FirmamentStepExporter.Export(cirOnlyArtifact);
+ Assert.True(export.IsSuccess, string.Join(" | ", export.Diagnostics.Select(d => d.Message)));
+ Assert.Contains("ISO-10303-21", export.Value.StepText, StringComparison.Ordinal);
+ Assert.Contains("MANIFOLD_SOLID_BREP", export.Value.StepText, StringComparison.Ordinal);
+ Assert.Contains("ADVANCED_FACE", export.Value.StepText, StringComparison.Ordinal);
+ Assert.Contains("CYLINDRICAL_SURFACE", export.Value.StepText, StringComparison.Ordinal);
+
+ var remat = NativeGeometryRematerializer.TryRematerialize(plan, cirOnlyState);
+ Assert.True(remat.IsSuccess, string.Join(" | ", remat.Diagnostics.Select(d => d.Message)));
+ Assert.Contains(remat.Value.TransitionEvents, e => e.Message.Contains("semantic recovery policy", StringComparison.Ordinal));
}
@@ -279,13 +310,36 @@ public sealed class FirmamentStepExporterTests
}
[Fact]
- public void Export_CirOnlyState_Fails_Clearly_Without_Materializer()
+ public void FirmamentStepExporter_CirOnlyUnsupportedBoxSphere_FailsClearly()
{
- var export = ExportFixture("testdata/firmament/fixtures/m10l-unsupported-box-subtract-sphere-touching-boundary.firmament");
+ var compiler = new FirmamentCompiler();
+ var source = FirmamentCorpusHarness.ReadFixtureText("testdata/firmament/fixtures/m10l-unsupported-box-subtract-sphere-touching-boundary.firmament");
+ var compiled = compiler.Compile(new FirmamentCompileRequest(new FirmamentSourceDocument(source)));
+ Assert.True(compiled.Compilation.IsSuccess);
+
+ var artifact = compiled.Compilation.Value;
+ var execution = artifact.PrimitiveExecutionResult!;
+ var cirOnlyState = execution.NativeGeometryState with
+ {
+ ExecutionMode = NativeGeometryExecutionMode.CirOnly,
+ MaterializationAuthority = NativeGeometryMaterializationAuthority.PendingRematerialization,
+ MaterializedBody = null
+ };
+ var cirOnlyArtifact = artifact with
+ {
+ PrimitiveExecutionResult = execution with { NativeGeometryState = cirOnlyState }
+ };
+
+ var export = FirmamentStepExporter.Export(cirOnlyArtifact);
Assert.False(export.IsSuccess);
Assert.Contains(export.Diagnostics, d => d.Message.Contains("unavailable for CirOnly state", StringComparison.Ordinal));
Assert.Contains(export.Diagnostics, d => d.Message.Contains("valid and analyzable in CIR", StringComparison.Ordinal));
Assert.Contains(export.Diagnostics, d => d.Message.Contains("CIR→BRep materializer", StringComparison.Ordinal));
+
+ var remat = NativeGeometryRematerializer.TryRematerialize(artifact.PrimitiveLoweringPlan!, cirOnlyState);
+ Assert.False(remat.IsSuccess);
+ Assert.Contains(remat.Diagnostics, d => d.Message.Contains("selectedPolicy='none'", StringComparison.Ordinal));
+ Assert.DoesNotContain(remat.Diagnostics, d => d.Message.Contains("semantic recovery policy", StringComparison.Ordinal));
}
[Fact]
@@ -372,6 +426,11 @@ public sealed class FirmamentStepExporterTests
new NativeGeometryReplayOperation(0, "base", "primitive:box", null, null, null, null, new NativeGeometryResolvedPlacement(NativeGeometryPlacementKind.None, null, null, Vector3D.Zero, Vector3D.Zero, true, null), null),
new NativeGeometryReplayOperation(1, "notch", "boolean:subtract", "base", "box", "tool", null, new NativeGeometryResolvedPlacement(NativeGeometryPlacementKind.None, null, null, Vector3D.Zero, Vector3D.Zero, true, null), null)
]);
+ private static NativeGeometryReplayLog BuildReplayLogForTranslatedBoxMinusCylinder()
+ => new([
+ new NativeGeometryReplayOperation(0, "base", "primitive:box", null, null, null, null, new NativeGeometryResolvedPlacement(NativeGeometryPlacementKind.Offset, null, null, Vector3D.Zero, new Vector3D(4d, 1d, 3d), true, null), null),
+ new NativeGeometryReplayOperation(1, "hole", "boolean:subtract", "base", "cylinder", "tool", null, new NativeGeometryResolvedPlacement(NativeGeometryPlacementKind.Offset, null, null, Vector3D.Zero, new Vector3D(4d, 1d, 3d), true, null), null)
+ ]);
private static bool HasExpectedMixedPrimitiveFailure(string message)
=> message.Contains("bounded boolean family only supports recognized axis-aligned boxes from BrepPrimitives.CreateBox(...).", StringComparison.Ordinal)
diff --git a/docs/cir-recovery-v41-firmament-export-regression.md b/docs/cir-recovery-v41-firmament-export-regression.md
new file mode 100644
index 00000000..999e77fb
--- /dev/null
+++ b/docs/cir-recovery-v41-firmament-export-regression.md
@@ -0,0 +1,58 @@
+# CIR-RECOVERY-V4.1: FirmamentStepExporter regression for semantic recovery rematerialization
+
+## Purpose
+
+Prove end-to-end that existing `FirmamentStepExporter` CirOnly export flow now benefits from V4 semantic rematerialization wiring for canonical `Subtract(Box,Cylinder)` without changing STEP exporter behavior.
+
+## Export path used
+
+This regression exercises the existing path:
+
+`FirmamentStepExporter` -> `NativeGeometryRematerializer.TryRematerialize` -> `FrepSemanticRecoveryRematerializer` -> `ThroughHoleRecoveryPolicy` -> `ThroughHoleRecoveryExecutor` -> recovered BRep -> existing `Step242Exporter.ExportBody`.
+
+No special export path was added.
+
+## Test coverage
+
+Added/updated exporter regression tests:
+
+- `FirmamentStepExporter_CirOnlyBoxCylinder_ExportsViaSemanticRecovery`
+- `FirmamentStepExporter_CirOnlyTranslatedBoxCylinder_ExportsViaSemanticRecovery`
+- `FirmamentStepExporter_CirOnlyUnsupportedBoxSphere_FailsClearly`
+
+Assertions include STEP markers for successful paths:
+
+- `ISO-10303-21`
+- `MANIFOLD_SOLID_BREP`
+- `ADVANCED_FACE`
+- `CYLINDRICAL_SURFACE`
+
+## Semantic recovery diagnostics visibility
+
+`FirmamentStepExporter.Export(...)` result does not expose rematerializer semantic diagnostic stream directly.
+
+Therefore V4.1 verifies semantic path usage by asserting rematerialized state transition events contain semantic recovery transition messaging (`semantic recovery policy`).
+
+For unsupported CirOnly cases, V4.1 verifies rematerializer failure diagnostics include semantic attempt summary (`selectedPolicy='none'`) and exporter retains existing clear CirOnly-unavailable failure behavior.
+
+## Unsupported behavior
+
+Unsupported CirOnly `Subtract(Box,Sphere)` remains unsupported:
+
+- semantic recovery does not produce false success,
+- rematerialization fails clearly,
+- exporter returns existing CirOnly unavailable diagnostic behavior,
+- no STEP payload is produced.
+
+## Non-goals preserved
+
+- no `Step242Exporter` behavior change,
+- no special-case exporter route,
+- no new recovery policy,
+- no boolean behavior changes,
+- no public API/CLI changes,
+- no topology naming expansion (SEM-A0 guardrails preserved).
+
+## Next milestone recommendation (CIR-RECOVERY-V5)
+
+Add bounded diagnostic surfacing from rematerializer semantic decisions into exporter-visible diagnostics/metadata (without changing exporter semantics), so semantic path evidence is observable without indirect state assertions.