Next Gen STEP AP242 Native-ish BREP Geometric Modeling Kernel
Verify derived variant semantic hole AP242 fixture
Yuechen Li2e32c5310a85
diff --git a/Aetheris.CLI.Tests/FirmamentV2SourceCompositionStepPipelineTests.cs b/Aetheris.CLI.Tests/FirmamentV2SourceCompositionStepPipelineTests.csindex 5ac65ef8..bca83539 100644--- a/Aetheris.CLI.Tests/FirmamentV2SourceCompositionStepPipelineTests.cs+++ b/Aetheris.CLI.Tests/FirmamentV2SourceCompositionStepPipelineTests.cs@@ -17,7 +17,8 @@ public sealed class FirmamentV2SourceCompositionStepPipelineTestspublic static TheoryData<string, string, double> CompositeCases => new(){{ "Composite/valid/composite-v2-two-independent-holes-step-verified.valid.firmfixture", "composite-v2-two-independent-holes-step-verified", 480d - 2d * Math.PI * 1d * 1d * 6d },- { "Composite/valid/composite-v2-adjacent-non-overlapping-holes-step-verified.valid.firmfixture", "composite-v2-adjacent-non-overlapping-holes-step-verified", 480d - 2d * Math.PI * 1d * 1d * 6d }+ { "Composite/valid/composite-v2-adjacent-non-overlapping-holes-step-verified.valid.firmfixture", "composite-v2-adjacent-non-overlapping-holes-step-verified", 480d - 2d * Math.PI * 1d * 1d * 6d },+ { "Composite/valid/composite-v2-hole-plus-derived-variant-step-verified.valid.firmfixture", "composite-v2-hole-plus-derived-variant-step-verified", 12d * 8d * 6d - Math.PI * 1d * 1d * 6d }};[Theory]@@ -29,7 +30,17 @@ public sealed class FirmamentV2SourceCompositionStepPipelineTestsvar (stepText, fixtureText) = BuildAndReadStep(fixturePath, stepPath, fixtureId);AssertStageHonesty(fixtureText, "multi-feature-composition", 4);- Assert.Contains("AirHoleFeature(SimpleShaft) x2", fixtureText, StringComparison.Ordinal);+ if (fixtureId.Contains("derived-variant", StringComparison.Ordinal))+ {+ Assert.Contains("with derivation + AirHoleFeature(SimpleShaft)", fixtureText, StringComparison.Ordinal);+ Assert.Contains("solid base: Box { size: [10, 8, 6] }", fixtureText, StringComparison.Ordinal);+ Assert.Contains("solid wider: base with { size: [12, 8, 6] }", fixtureText, StringComparison.Ordinal);+ Assert.Contains("modify wider", fixtureText, StringComparison.Ordinal);+ }+ else+ {+ Assert.Contains("AirHoleFeature(SimpleShaft) x2", fixtureText, StringComparison.Ordinal);+ }Assert.True(CountStepEntities(stepText, "ADVANCED_FACE") > 0, fixtureId + " emits real STEP advanced faces");Assert.True(CountStepEntities(stepText, "VERTEX_POINT") > 0, fixtureId + " emits STEP vertex topology marker");@@ -38,13 +49,19 @@ public sealed class FirmamentV2SourceCompositionStepPipelineTestsvar import = Step242Importer.ImportBody(stepText);Assert.True(import.IsSuccess, string.Join(Environment.NewLine, import.Diagnostics.Select(d => d.Message)));var body = import.Value;- Assert.Equal(2, body.Topology.Faces.Count(f => body.TryGetFaceSurface(f.Id, out var surface) && surface?.Kind == SurfaceGeometryKind.Cylinder));+ var expectedCylinderFaceCount = fixtureId.Contains("derived-variant", StringComparison.Ordinal) ? 1 : 2;+ Assert.Equal(expectedCylinderFaceCount, body.Topology.Faces.Count(f => body.TryGetFaceSurface(f.Id, out var surface) && surface?.Kind == SurfaceGeometryKind.Cylinder));var volume = StepAnalyzer.AnalyzeVolume(stepPath);Assert.True(volume.Success, fixtureId + " volume analysis succeeds");Assert.True(volume.Exact, fixtureId + " volume should use exact semantic multi-hole interval analysis");Assert.Equal("analytic-box-minus-z-hole", volume.Method);Assert.InRange(Math.Abs(volume.Volume - expectedVolume), 0d, 1e-8);+ if (fixtureId.Contains("derived-variant", StringComparison.Ordinal))+ {+ var staleBaseVolume = 10d * 8d * 6d - Math.PI * 1d * 1d * 6d;+ Assert.True(Math.Abs(volume.Volume - staleBaseVolume) > 1d, "derived-variant-plus-hole volume must not reuse stale base 10 x 8 x 6 dimensions");+ }}[Fact]diff --git a/Aetheris.Kernel.Firmament.Tests/FirmamentV2ParserTests.cs b/Aetheris.Kernel.Firmament.Tests/FirmamentV2ParserTests.csindex c03093cb..7c3c688b 100644--- a/Aetheris.Kernel.Firmament.Tests/FirmamentV2ParserTests.cs+++ b/Aetheris.Kernel.Firmament.Tests/FirmamentV2ParserTests.cs@@ -138,6 +138,30 @@ public sealed class FirmamentV2ParserTestsAssert.Equal(["base.leftMount", "base.rightMount"], lowered.Select(h => h.FeatureId).ToArray());Assert.All(lowered, h => Assert.Equal(AirHoleStackKind.SimpleShaft, h.Stack.Kind));}+ [Fact]+ public void FirmamentV2Parser_DerivedCompositeHole_LowersSelectedDerivedSolidAndAirHoleFeature()+ {+ var result = FirmamentV2Parser.Parse(Source("Composite/valid/composite-v2-hole-plus-derived-variant-step-verified.valid.firmfixture"));+ Assert.True(result.IsSuccess, string.Join(", ", result.Diagnostics));+ var document = result.Document!;+ Assert.Equal([10, 8, 6], document.Solids.Single(s => s.Name == "base").Box!.Size);+ Assert.Equal([12, 8, 6], document.Solids.Single(s => s.Name == "wider").Box!.Size);+ Assert.Equal("wider", document.Solid.Name);++ var modify = Assert.Single(document.ModifyBlocks!);+ Assert.Equal("wider", modify.TargetSolid);+ var hole = Assert.Single(modify.SemanticHoles);+ Assert.Equal(FirmamentV2SemanticHoleVariant.Shaft, hole.Variant);+ Assert.Equal(2, hole.ShaftDiameter);++ var lowered = Assert.Single(FirmamentV2SemanticHoleLowering.LowerSemanticHoles(document));+ Assert.Equal("wider.mount", lowered.FeatureId);+ Assert.Equal("wider", lowered.TargetBodyId);+ Assert.Equal(AirHoleStackKind.SimpleShaft, lowered.Stack.Kind);+ Assert.Equal(nameof(AirHoleFeature), lowered.Provenance.RouteName);+ Assert.Contains("target-solid:wider", lowered.Provenance.Notes);+ }+[Fact]public void FirmamentV2Parser_SemanticFaceAlias_ResolvesBeforeHoleLowering()diff --git a/Aetheris.Kernel.Firmament/FirmamentBuildAndExport.cs b/Aetheris.Kernel.Firmament/FirmamentBuildAndExport.csindex 9a7dcfc2..cea09b6c 100644--- a/Aetheris.Kernel.Firmament/FirmamentBuildAndExport.cs+++ b/Aetheris.Kernel.Firmament/FirmamentBuildAndExport.cs@@ -91,7 +91,14 @@ public static class FirmamentBuildAndExportreturn null;}- if (document.Solids.Count != 1 || document.Solid.Primitive is not FirmamentV2BoxRecord box || box.Size.Count != 3)+ var modifyTargets = document.ModifyBlocks.Select(m => m.TargetSolid).Distinct(StringComparer.Ordinal).ToArray();+ if (modifyTargets.Length != 1)+ {+ return null;+ }++ var targetSolid = document.Solids.SingleOrDefault(s => string.Equals(s.Name, modifyTargets[0], StringComparison.Ordinal));+ if (targetSolid?.Primitive is not FirmamentV2BoxRecord box || box.Size.Count != 3){return null;}diff --git a/docs/implementation/step-v2-x4-multi-feature-composition-ap242.md b/docs/implementation/step-v2-x4-multi-feature-composition-ap242.mdindex fd4c5bb5..651be809 100644--- a/docs/implementation/step-v2-x4-multi-feature-composition-ap242.md+++ b/docs/implementation/step-v2-x4-multi-feature-composition-ap242.md@@ -13,7 +13,7 @@ Invalid Tier 4 fixture:- `fixtures/FirmamentV2/Composite/invalid/composite-v2-overlapping-holes-rejected-with-clear-diagnostic.invalid.firmfixture`-The optional derived-variant plus hole case remains deferred for this milestone. X4 intentionally proves multi-hole composition on one selected Box first; combining derivation selection and feature composition can be promoted later without broadening this slice.+The optional derived-variant plus hole case was deferred from X4 and is promoted separately by STEP-V2-X5; see `docs/implementation/step-v2-x5-derived-variant-plus-hole-ap242.md`. X4 intentionally proved multi-hole composition on one selected Box first.## Command path and verification@@ -56,4 +56,4 @@ These fixtures satisfy the MVP readiness contract for this bounded multi-feature- General feature conflict resolution.- Patterns, hole groups, new hole variants, threads/taps, up-to-face/up-to-next, side-hole reroute, chamfer/fillet/draft, PMI, and DFM enforcement.-- Derived variant plus hole AP242 verification, until composition on derived selected solids is promoted as its own bounded slice.+- Derived variant plus hole AP242 verification was promoted by STEP-V2-X5; remaining deferred items stay limited to broader semantics and unsupported feature families.diff --git a/docs/implementation/step-v2-x5-derived-variant-plus-hole-ap242.md b/docs/implementation/step-v2-x5-derived-variant-plus-hole-ap242.mdnew file mode 100644index 00000000..5afd1361--- /dev/null+++ b/docs/implementation/step-v2-x5-derived-variant-plus-hole-ap242.md@@ -0,0 +1,77 @@+# STEP-V2-X5 — derived variant plus semantic hole AP242 verification++STEP-V2-X5 closes the deferred Tier 4 composition case `composite-v2-hole-plus-derived-variant-step-verified`. It proves that a Firmament V2 `with`-derived selected Box can consume an existing semantic `hole<shaft>` and reach AP242 `step-verified` through the real build/export path.++## Fixture++- `fixtures/FirmamentV2/Composite/valid/composite-v2-hole-plus-derived-variant-step-verified.valid.firmfixture`++The source composition is intentionally narrow:++1. `solid base: Box { size: [10, 8, 6] }`+2. `solid wider: base with { size: [12, 8, 6] }`+3. `modify wider { hole<shaft> mount { on: face(+Z); center: [0, 0]; radius: 1; end: throughAll } }`++No new hole families, parser syntax, pattern/group semantics, side-hole reroute, or exporter behavior are introduced.++## Command path++The verification path is the real CLI path:++```bash+aetheris build fixtures/FirmamentV2/Composite/valid/composite-v2-hole-plus-derived-variant-step-verified.valid.firmfixture --out <temp>/composite-v2-hole-plus-derived-variant.step --json+```++The implementation path is:++```text+FirmamentV2Parser+ -> selected with-derived Box record (`wider`, 12 x 8 x 6)+ -> semantic hole<shaft> on `modify wider`+ -> FirmamentV2SemanticHoleLowering+ -> AirHoleFeature(SimpleShaft)+ -> AirHoleSimpleShaftMaterializer+ -> real BrepBody+ -> Step242Exporter.ExportBody+```++The output is not a hardcoded STEP template and is not trace-only output.++## AP242 verification checks++The integration test requires all of the following before the fixture can honestly claim `current-stage: step-verified`:++- the real `aetheris build` path succeeds;+- an AP242 file containing `ISO-10303-21` is emitted;+- `ADVANCED_FACE` count is greater than zero;+- `VERTEX_POINT` count is greater than zero;+- trace-only markers are absent;+- `Step242Importer` reimports the emitted file;+- topology evidence includes one cylindrical wall face for the shaft;+- exact volume analysis succeeds with method `analytic-box-minus-z-hole`.++## Volume formula and stale-state guard++The independent expected volume is based on the derived selected solid, not the base solid:++```text+derived box volume = 12 * 8 * 6 = 576+shaft removed volume = pi * 1^2 * 6 = 6pi+expected volume = 576 - 6pi = 557.1504440784612+```++The test also computes the stale-base alternative:++```text+10 * 8 * 6 - 6pi+```++and asserts the analyzed AP242 volume is not that value. This catches regressions where the semantic hole materializer accidentally uses the base `10 x 8 x 6` record after the fixture selected `wider`.++## Relationship to MVP readiness, X3, and X4++STEP-V2-X3 proved `with` derivation, chained derivation, and semantic face aliases. STEP-V2-X4 proved bounded multi-hole composition and deterministic overlap rejection. X5 composes the already-supported X3 derivation selection with the already-supported X2/X4 semantic shaft hole path, satisfying the remaining Tier 4 derived-variant-plus-hole MVP checklist item.++## Deferred++Still deferred: new hole semantics, counterbore/countersink expansion beyond existing paths, hole groups/patterns, threads/taps, drill tips, up-to-face/up-to-next, arbitrary datum placement, non-planar entry faces, side-hole reroute, chamfer/fillet/draft, PMI, DFM enforcement, generic 3D Boolean authoring, generic conflict resolution, new exporter behavior, or a V2-only exporter.diff --git a/fixtures/FirmamentV2/Composite/valid/composite-v2-hole-plus-derived-variant-step-verified.valid.firmfixture b/fixtures/FirmamentV2/Composite/valid/composite-v2-hole-plus-derived-variant-step-verified.valid.firmfixturenew file mode 100644index 00000000..33d07ba6--- /dev/null+++ b/fixtures/FirmamentV2/Composite/valid/composite-v2-hole-plus-derived-variant-step-verified.valid.firmfixture@@ -0,0 +1,36 @@+// fixture-id: composite-v2-hole-plus-derived-variant-step-verified+// case: composite-v2-hole-plus-derived-variant-step-verified+// category: Composite+// syntax-version: FirmamentV2+// validity: valid+// implementation: parser-backed+// expected: valid+// expected-stage: step-verified+// current-stage: step-verified+// expected-feature-air: with derivation + AirHoleFeature(SimpleShaft)+// dimensions: base box 10 x 8 x 6; derived box 12 x 8 x 6; shaft radius 1; through depth 6+// units: mm+// tier: 4+// mvp-required: true+// feature-area: multi-feature-composition+// build-command: aetheris build+// expected-volume: 557.1504440784612+// expected-volume-formula: 12 * 8 * 6 - pi * 1^2 * 6+// expected-topology: advanced_face>0, vertex_point>0, cylindrical-wall-face-count=1+// roundtrip-required: true+// parser-backed: true+// stale-state-guard: volume must use derived 12 x 8 x 6 box, not stale base 10 x 8 x 6 box+// notes: STEP-V2-X5 fixture; real build/export path composes selected with-derived Box dimensions, semantic AirHoleFeature lowering, AirHoleSimpleShaftMaterializer, Step242Exporter, reimport, topology markers, and analytic volume.+model CompositeV2HolePlusDerivedVariantStepVerified {+ units mm+ solid base: Box { size: [10, 8, 6] }+ solid wider: base with { size: [12, 8, 6] }+ modify wider {+ hole<shaft> mount {+ on: face(+Z)+ center: [0, 0]+ radius: 1+ end: throughAll+ }+ }+}