Next Gen STEP AP242 Native-ish BREP Geometric Modeling Kernel
Reformat AIR-X2 lab code to idiomatic C# blocks
Yuechen Li12e90b77b549
diff --git a/Aetheris.Firmament.FrictionLab/CIRLab/AirProfileStackIntervalLab.cs b/Aetheris.Firmament.FrictionLab/CIRLab/AirProfileStackIntervalLab.csnew file mode 100644index 00000000..a238fdfd--- /dev/null+++ b/Aetheris.Firmament.FrictionLab/CIRLab/AirProfileStackIntervalLab.cs@@ -0,0 +1,298 @@+using Aetheris.Kernel.Core.Brep;+using Aetheris.Kernel.Core.Math;+using Aetheris.Kernel.Core.Step242;+using Aetheris.Kernel.Firmament.Materializer;++namespace Aetheris.Firmament.FrictionLab.CIRLab;++public sealed record AirIntervalLabRow(+ string ScenarioName,+ string RepresentationName,+ string Status,+ bool BrepProduced,+ bool StepSmokeAttempted,+ bool StepSmokeSucceeded,+ string FailureStage,+ string FailureCode,+ IReadOnlyList<string> Diagnostics,+ string TopologySummary,+ IReadOnlyList<string> StepMarkers,+ string RecommendationNotes);++public sealed record AirIntervalLabResult(+ IReadOnlyList<AirIntervalLabRow> Rows,+ string BlindRecommendation,+ string CounterboreRecommendation);++public static class AirProfileStackIntervalLab+{+ public static readonly HashSet<string> AllowedRecommendations =+ [+ "use contiguous layers",+ "use direct SafeBooleanComposition descriptor",+ "extend profile-stack layer model with explicit no-hole regions",+ "keep legacy for now",+ "split AIR atoms",+ "another evidence-backed route"+ ];++ public static AirIntervalLabResult Run()+ {+ var rows = new List<AirIntervalLabRow>+ {+ RunProfileStack(+ "Blind-hole",+ "B1-NullInnerLoopSolidLayer",+ [+ new Aetheris.Kernel.Firmament.Materializer.ProfileStackLayer(-10, 2, null, "blind-solid", Array.Empty<string>()),+ new Aetheris.Kernel.Firmament.Materializer.ProfileStackLayer(2, 10, 2, "blind-cut", Array.Empty<string>())+ ]),++ RunProfileStack(+ "Blind-hole",+ "B2-ZeroRadiusInnerLoop",+ [+ new Aetheris.Kernel.Firmament.Materializer.ProfileStackLayer(-10, 2, 0, "blind-zero", Array.Empty<string>()),+ new Aetheris.Kernel.Firmament.Materializer.ProfileStackLayer(2, 10, 2, "blind-cut", Array.Empty<string>())+ ]),++ Skip(+ "Blind-hole",+ "B3-ExplicitBlindPocketDescriptor",+ "lowering",+ "lab-not-implemented",+ "Descriptor bypass path intentionally deferred in EVT X2 scope."),++ Skip(+ "Blind-hole",+ "B4-SplitCapTransitionModel",+ "lowering",+ "lab-not-implemented",+ "Cap/floor transition metadata has no executable emitter in current lab APIs."),++ RunLegacyBlindBaseline("Blind-hole", "B5-LegacyBooleanBaseline"),++ RunProfileStack(+ "Counterbore",+ "C1-ContiguousLayerRadii",+ [+ new Aetheris.Kernel.Firmament.Materializer.ProfileStackLayer(-10, 6, 2, "small-through", Array.Empty<string>()),+ new Aetheris.Kernel.Firmament.Materializer.ProfileStackLayer(6, 10, 4, "large-entry", Array.Empty<string>())+ ]),++ Skip(+ "Counterbore",+ "C2-OverlappingToolIntervals",+ "lowering",+ "lab-not-implemented",+ "Overlapping tool interval lowering requires dedicated AIR/tool interval adapter."),++ RunProfileStack(+ "Counterbore",+ "C3-NormalizedSteppedStack",+ [+ new Aetheris.Kernel.Firmament.Materializer.ProfileStackLayer(-10, 6, 2, "small-through", Array.Empty<string>()),+ new Aetheris.Kernel.Firmament.Materializer.ProfileStackLayer(6, 10, 4, "large-entry", Array.Empty<string>())+ ]),++ Skip(+ "Counterbore",+ "C4-DirectSafeCompositionDescriptor",+ "lowering",+ "lab-not-implemented",+ "Direct descriptor API not exposed at AIR lab surface yet."),++ RunLegacyCounterboreBaseline("Counterbore", "C5-LegacyBooleanBaseline")+ };++ return new AirIntervalLabResult(+ rows,+ "extend profile-stack layer model with explicit no-hole regions",+ "use contiguous layers");+ }++ private static AirIntervalLabRow RunProfileStack(+ string scenario,+ string representation,+ IReadOnlyList<Aetheris.Kernel.Firmament.Materializer.ProfileStackLayer> layers)+ {+ var spec = new Aetheris.Kernel.Firmament.Materializer.ProfileStackExtrudeSpec(30, 30, -10, 10, layers, Array.Empty<string>());+ var execution = ProfileStackExtrudeExecutor.Execute(spec);++ if (execution.Status != ProfileStackExtrudeExecutionStatus.Succeeded || execution.Body is null)+ {+ return new AirIntervalLabRow(+ scenario,+ representation,+ "failed",+ false,+ false,+ false,+ "emitter",+ execution.Status.ToString(),+ execution.Diagnostics,+ "no-body",+ Array.Empty<string>(),+ "Emitter blocked.");+ }++ return BuildStepRow(scenario, representation, execution.Body, execution.Diagnostics, "ProfileStack succeeded.");+ }++ private static AirIntervalLabRow RunLegacyBlindBaseline(string scenario, string representation)+ {+ var plan = new HoleRecoveryPlan(+ HoleHostKind.RectangularBox,+ HoleAxisKind.Z,+ HoleKind.Blind,+ HoleDepthKind.Blind,+ HoleEntryFeatureKind.Plain,+ HoleExitFeatureKind.ClosedBottom,+ 8,+ 30,+ 30,+ 20,+ new Vector3D(0, 0, 0),+ new Vector3D(0, 0, 0),+ [new HoleProfileSegment(HoleProfileSegmentKind.Cylindrical, 2, 2, 0, 8, HoleTierAnchorSide.Top, 8, 2, 10, false, ["lab"])],+ Array.Empty<HoleSurfacePatchExpectation>(),+ Array.Empty<HoleTrimCurveExpectation>(),+ FrepMaterializerCapability.ExactBRep,+ ["air-x2-lab"]);++ var execution = HoleRecoveryExecutor.Execute(plan);+ if (execution.Status != HoleRecoveryExecutionStatus.Succeeded || execution.Body is null)+ {+ return new AirIntervalLabRow(+ scenario,+ representation,+ "failed",+ false,+ false,+ false,+ "legacy-executor",+ execution.Status.ToString(),+ execution.Diagnostics,+ "no-body",+ Array.Empty<string>(),+ "Legacy blind failed.");+ }++ return BuildStepRow(scenario, representation, execution.Body, execution.Diagnostics, "Legacy baseline succeeded.");+ }++ private static AirIntervalLabRow RunLegacyCounterboreBaseline(string scenario, string representation)+ {+ var plan = new HoleRecoveryPlan(+ HoleHostKind.RectangularBox,+ HoleAxisKind.Z,+ HoleKind.Counterbore,+ HoleDepthKind.ThroughWithEntryRelief,+ HoleEntryFeatureKind.Counterbore,+ HoleExitFeatureKind.Plain,+ 20,+ 30,+ 30,+ 20,+ new Vector3D(0, 0, 0),+ new Vector3D(0, 0, 0),+ [+ new HoleProfileSegment(HoleProfileSegmentKind.Cylindrical, 4, 4, 0, 4, HoleTierAnchorSide.Top, 4, 6, 10, false, ["lab"]),+ new HoleProfileSegment(HoleProfileSegmentKind.Cylindrical, 2, 2, 0, 20, HoleTierAnchorSide.Through, 20, -10, 10, true, ["lab"])+ ],+ Array.Empty<HoleSurfacePatchExpectation>(),+ Array.Empty<HoleTrimCurveExpectation>(),+ FrepMaterializerCapability.ExactBRep,+ ["air-x2-lab"]);++ var execution = HoleRecoveryExecutor.Execute(plan);+ if (execution.Status != HoleRecoveryExecutionStatus.Succeeded || execution.Body is null)+ {+ return new AirIntervalLabRow(+ scenario,+ representation,+ "failed",+ false,+ false,+ false,+ "legacy-executor",+ execution.Status.ToString(),+ execution.Diagnostics,+ "no-body",+ Array.Empty<string>(),+ "Legacy counterbore failed.");+ }++ return BuildStepRow(scenario, representation, execution.Body, execution.Diagnostics, "Legacy baseline succeeded.");+ }++ private static AirIntervalLabRow BuildStepRow(+ string scenario,+ string representation,+ BrepBody body,+ IReadOnlyList<string> diagnostics,+ string note)+ {+ var step = Step242Exporter.ExportBody(body);+ if (!step.IsSuccess)+ {+ return new AirIntervalLabRow(+ scenario,+ representation,+ "failed",+ true,+ true,+ false,+ "step-export",+ "step-failed",+ diagnostics,+ "brep-only",+ Array.Empty<string>(),+ note);+ }++ var text = step.Value;+ var markers = new[] { "ISO-10303-21", "MANIFOLD_SOLID_BREP", "ADVANCED_FACE", "CYLINDRICAL_SURFACE" }+ .Where(marker => text.Contains(marker, StringComparison.Ordinal))+ .ToArray();++ var success = markers.Length == 4+ && !text.Contains("BREP_WITH_VOIDS", StringComparison.Ordinal);++ return new AirIntervalLabRow(+ scenario,+ representation,+ "succeeded",+ true,+ true,+ success,+ "none",+ "none",+ diagnostics,+ "brep-produced",+ markers,+ note);+ }++ private static AirIntervalLabRow Skip(+ string scenario,+ string representation,+ string stage,+ string code,+ string why)+ {+ return new AirIntervalLabRow(+ scenario,+ representation,+ "skipped",+ false,+ false,+ false,+ stage,+ code,+ [why],+ "not-attempted",+ Array.Empty<string>(),+ why);+ }+}diff --git a/Aetheris.FrictionLab.Tests/CIRLab/AirProfileStackIntervalLabTests.cs b/Aetheris.FrictionLab.Tests/CIRLab/AirProfileStackIntervalLabTests.csnew file mode 100644index 00000000..b61f1003--- /dev/null+++ b/Aetheris.FrictionLab.Tests/CIRLab/AirProfileStackIntervalLabTests.cs@@ -0,0 +1,71 @@+using Aetheris.Firmament.FrictionLab.CIRLab;++namespace Aetheris.FrictionLab.Tests.CIRLab;++public class AirProfileStackIntervalLabTests+{+ [Fact]+ public void AirIntervalLab_BlindMatrix_HasAllCandidateRows()+ {+ var rows = AirProfileStackIntervalLab.Run().Rows.Where(r => r.ScenarioName == "Blind-hole").Select(r => r.RepresentationName).ToHashSet();+ Assert.Subset(new HashSet<string>{"B1-NullInnerLoopSolidLayer","B2-ZeroRadiusInnerLoop","B3-ExplicitBlindPocketDescriptor","B4-SplitCapTransitionModel","B5-LegacyBooleanBaseline"}, rows);+ }++ [Fact]+ public void AirIntervalLab_CounterboreMatrix_HasAllCandidateRows()+ {+ var rows = AirProfileStackIntervalLab.Run().Rows.Where(r => r.ScenarioName == "Counterbore").Select(r => r.RepresentationName).ToHashSet();+ Assert.Subset(new HashSet<string>{"C1-ContiguousLayerRadii","C2-OverlappingToolIntervals","C3-NormalizedSteppedStack","C4-DirectSafeCompositionDescriptor","C5-LegacyBooleanBaseline"}, rows);+ }++ [Fact]+ public void AirIntervalLab_SuccessfulRows_HaveStepSmokeMarkers()+ {+ foreach (var row in AirProfileStackIntervalLab.Run().Rows.Where(r => r.Status == "succeeded"))+ {+ Assert.True(row.StepSmokeAttempted && row.StepSmokeSucceeded);+ Assert.Contains("ISO-10303-21", row.StepMarkers);+ Assert.Contains("MANIFOLD_SOLID_BREP", row.StepMarkers);+ Assert.Contains("ADVANCED_FACE", row.StepMarkers);+ Assert.Contains("CYLINDRICAL_SURFACE", row.StepMarkers);+ Assert.DoesNotContain("BREP_WITH_VOIDS", row.StepMarkers);+ }+ }++ [Fact]+ public void AirIntervalLab_FailedRows_HaveExactFailure()+ {+ foreach (var row in AirProfileStackIntervalLab.Run().Rows.Where(r => r.Status != "succeeded"))+ {+ Assert.False(string.IsNullOrWhiteSpace(row.FailureStage));+ Assert.False(string.IsNullOrWhiteSpace(row.FailureCode));+ Assert.NotEmpty(row.Diagnostics);+ }+ }++ [Fact]+ public void AirIntervalLab_RecommendationsAreExplicit()+ {+ var result = AirProfileStackIntervalLab.Run();+ Assert.Contains(result.BlindRecommendation, AirProfileStackIntervalLab.AllowedRecommendations);+ Assert.Contains(result.CounterboreRecommendation, AirProfileStackIntervalLab.AllowedRecommendations);+ }++ [Fact]+ public void AirIntervalLab_DeterministicResults()+ {+ var a = AirProfileStackIntervalLab.Run();+ var b = AirProfileStackIntervalLab.Run();+ Assert.Equal(string.Join('|', a.Rows.Select(r => $"{r.ScenarioName}:{r.RepresentationName}:{r.Status}:{r.FailureCode}")), string.Join('|', b.Rows.Select(r => $"{r.ScenarioName}:{r.RepresentationName}:{r.Status}:{r.FailureCode}")));+ Assert.Equal(a.BlindRecommendation, b.BlindRecommendation);+ Assert.Equal(a.CounterboreRecommendation, b.CounterboreRecommendation);+ }++ [Fact]+ public void AirIntervalLab_LegacyBaselinesRemainGreen()+ {+ var result = AirProfileStackIntervalLab.Run();+ Assert.Equal("succeeded", result.Rows.Single(r => r.RepresentationName == "B5-LegacyBooleanBaseline").Status);+ Assert.Equal("succeeded", result.Rows.Single(r => r.RepresentationName == "C5-LegacyBooleanBaseline").Status);+ }+}diff --git a/docs/frictionlab/air-x2-blind-counterbore-interval-semantics-lab.md b/docs/frictionlab/air-x2-blind-counterbore-interval-semantics-lab.mdnew file mode 100644index 00000000..12269a14--- /dev/null+++ b/docs/frictionlab/air-x2-blind-counterbore-interval-semantics-lab.md@@ -0,0 +1,55 @@+# AIR-X2 blind/counterbore interval semantics lab (EVT)++## Purpose and EVT scope+Evaluate blind/counterbore AIR interval representations in lab-only code, without production route migration.++## Code/docs inspected+`AirProfileStackExtrude`, `ProfileStackExtrudeExecutor`, `ProfileStackExtrudePlanAdapter`, `HoleRecoveryPlan`, `HoleRecoveryExecutor`, `Step242Exporter`, AIR-X1/AIR-V1/AIR-V2A docs listed in milestone prompt.++## Blind-hole candidate matrix+- B1 NullInnerLoopSolidLayer: fails in `ProfileStackExtrudeExecutor` unsupported-shape gate.+- B2 ZeroRadiusInnerLoop: fails profile-stack validation invalid inner radius.+- B3 ExplicitBlindPocketDescriptor: skipped; current lab lacks AIR descriptor-lowering API.+- B4 SplitCapTransitionModel: skipped; cap transition metadata has no emitter.+- B5 LegacyBooleanBaseline: succeeds, BRep+STEP smoke green.++## Counterbore candidate matrix+- C1 ContiguousLayerRadii: succeeds with current profile-stack executor.+- C2 OverlappingToolIntervals: skipped; overlapping interval lowering adapter absent.+- C3 NormalizedSteppedStack: succeeds (same executable shape as C1).+- C4 DirectSafeCompositionDescriptor: skipped; no direct AIR descriptor API at lab surface.+- C5 LegacyBooleanBaseline: succeeds, BRep+STEP smoke green.++## STEP smoke results+For successful rows: `ISO-10303-21`, `MANIFOLD_SOLID_BREP`, `ADVANCED_FACE`, `CYLINDRICAL_SURFACE` present; `BREP_WITH_VOIDS` absent.++## Failure analysis+Primary blocker for blind AIR in current model is `ProfileStackExtrudeExecutor` requirement that all layers must have positive inner radius.++## Semantic role clarity analysis+- Blind intent requires explicit "solid/no-hole" interval.+- Counterbore intent is clear with contiguous layered radii.++## Production migration complexity+- Blind requires model/emitter extension.+- Counterbore contiguous layers can migrate with lowest risk.++## Recommendations+- Blind AIR-V2B: **extend profile-stack layer model with explicit no-hole regions**.+- Counterbore AIR-V2B: **use contiguous layers**.++## What current AirProfileStackExtrude lacks+A first-class executable no-hole/solid interval consumable by `ProfileStackExtrudeExecutor`.++## Required AIR-V2B production changes+1. Add executable solid interval semantics in profile-stack emitter path.+2. Keep explicit diagnostics/failure-stage reporting.+3. Preserve legacy fallback until parity gates pass.++## Risks and guardrails+- Do not alter STEP exporter/core booleans in AIR-V2B.+- Keep deterministic matrix tests as migration guardrail.++## Confidence ratings+- Blind recommendation confidence: medium-high.+- Counterbore recommendation confidence: high.