Next Gen STEP AP242 Native-ish BREP Geometric Modeling Kernel
Add AIR-X1 friction lab for minimal profile IR and profile-stack extrude
Yuechen Li255e18ae89d1
diff --git a/Aetheris.Firmament.FrictionLab/CIRLab/AirProfileStackExtrudeLab.cs b/Aetheris.Firmament.FrictionLab/CIRLab/AirProfileStackExtrudeLab.csnew file mode 100644index 00000000..565949bd--- /dev/null+++ b/Aetheris.Firmament.FrictionLab/CIRLab/AirProfileStackExtrudeLab.cs@@ -0,0 +1,132 @@+using Aetheris.Kernel.Core.Brep;+using Aetheris.Kernel.Core.Step242;+using Aetheris.Kernel.Firmament.Materializer;++namespace Aetheris.Firmament.FrictionLab.CIRLab;++public sealed record AirRectangleProfile(double Width, double Height);+public sealed record AirCenteredCircleLoop(double Radius);+public sealed record AirProfileRegion2D(AirRectangleProfile OuterRectangle, AirCenteredCircleLoop? InnerCircle, string SemanticRole);+public sealed record AirProfileStackLayer(double ZMin, double ZMax, AirProfileRegion2D Region, string LayerRole, IReadOnlyList<string> Diagnostics);+public sealed record AirProfileStackExtrude(IReadOnlyList<AirProfileStackLayer> Layers, double GlobalZMin, double GlobalZMax, IReadOnlyList<string> Diagnostics);++public sealed record AirScenarioResult(+ string Scenario,+ bool Success,+ string Status,+ IReadOnlyList<string> Diagnostics,+ IReadOnlyList<string> LayerRoles,+ IReadOnlyList<string> StepMarkers,+ bool HasBrepWithVoids);++public sealed record AirProfileStackExtrudeLabResult(+ AirProfileStackExtrude ThroughHole,+ AirProfileStackExtrude SteppedHole,+ AirProfileStackExtrude BlindHole,+ AirProfileStackExtrude Counterbore,+ AirScenarioResult ThroughHoleResult,+ AirScenarioResult SteppedHoleResult,+ AirScenarioResult BlindHoleResult,+ AirScenarioResult CounterboreResult,+ IReadOnlyList<string> MappingFindings,+ string MappingRecommendation,+ string DeferredFieldsSummary);++public static class AirProfileStackExtrudeLab+{+ public static AirProfileStackExtrudeLabResult Run()+ {+ var through = BuildThrough();+ var stepped = BuildStepped();+ var blind = BuildBlind();+ var counterbore = BuildCounterbore();++ return new(+ through,+ stepped,+ blind,+ counterbore,+ Execute("through-hole", through),+ Execute("stepped-hole", stepped),+ Execute("blind-hole", blind),+ Execute("counterbore", counterbore),+ [+ "mapping-option: HoleRecoveryPlan -> AIR gives complete semantic role/anchor diagnostics early.",+ "mapping-option: ProfileStackExtrudeSpec -> AIR is narrower and aligns directly to existing emitter contract.",+ "current-executor-contract: contiguous full-height layers with positive inner radius in every layer.",+ "blind/counterbore blocker category: emitter-side (ProfileStackExtrudeExecutor V2 shape gate), not AIR-model-side."+ ],+ "recommendation: AIR-V1 should normalize HoleRecoveryPlan -> ProfileStackExtrudeSpec -> AIR for executable cylindrical lanes, while preserving HoleRecoveryPlan diagnostics/provenance on AIR nodes.",+ "deferred-fields: arbitrary 2D loops, non-centered circles, multiple inner loops, loop orientation, 2D boolean provenance, non-rectangular outers.");+ }++ public static bool TryMapFromProfileStackSpec(Aetheris.Kernel.Firmament.Materializer.ProfileStackExtrudeSpec spec, out AirProfileStackExtrude? air, out IReadOnlyList<string> diagnostics)+ {+ var d = new List<string> { "air-map: source=ProfileStackExtrudeSpec" };+ var layers = new List<AirProfileStackLayer>();+ foreach (var layer in spec.Layers.OrderBy(l => l.ZMin))+ {+ var region = new AirProfileRegion2D(new AirRectangleProfile(spec.Width, spec.Depth),+ layer.InnerCircleRadius.HasValue ? new AirCenteredCircleLoop(layer.InnerCircleRadius.Value) : null,+ layer.Role);+ layers.Add(new AirProfileStackLayer(layer.ZMin, layer.ZMax, region, layer.Role, layer.Diagnostics));+ }++ air = new AirProfileStackExtrude(layers, spec.ZMin, spec.ZMax, spec.Diagnostics.Append("mapped-from-profile-stack-spec").ToArray());+ diagnostics = d;+ return true;+ }++ private static AirScenarioResult Execute(string name, AirProfileStackExtrude air)+ {+ var diagnostics = new List<string> { $"air-scenario:{name}" };+ var ordered = air.Layers.OrderBy(x => x.ZMin).ToArray();+ var kernelLayers = ordered.Select(x => new Aetheris.Kernel.Firmament.Materializer.ProfileStackLayer(x.ZMin, x.ZMax, x.Region.InnerCircle?.Radius, x.LayerRole, x.Diagnostics)).ToArray();+ var spec = new Aetheris.Kernel.Firmament.Materializer.ProfileStackExtrudeSpec(ordered[0].Region.OuterRectangle.Width, ordered[0].Region.OuterRectangle.Height, air.GlobalZMin, air.GlobalZMax, kernelLayers, air.Diagnostics);+ var emitted = ProfileStackExtrudeExecutor.Execute(spec);+ diagnostics.AddRange(emitted.Diagnostics);++ if (emitted.Status != ProfileStackExtrudeExecutionStatus.Succeeded || emitted.Body is null)+ {+ return new AirScenarioResult(name, false, $"blocker:emitter:{emitted.Status}", diagnostics, ordered.Select(x => x.LayerRole).ToArray(), [], false);+ }++ var step = Step242Exporter.ExportBody(emitted.Body);+ if (!step.IsSuccess)+ {+ diagnostics.AddRange(step.Diagnostics.Select(d => d.Message));+ return new AirScenarioResult(name, false, "blocker:step-export", diagnostics, ordered.Select(x => x.LayerRole).ToArray(), [], false);+ }++ var text = step.Value;+ var markers = new[] { "ISO-10303-21", "MANIFOLD_SOLID_BREP", "ADVANCED_FACE", "CYLINDRICAL_SURFACE" }+ .Where(m => text.Contains(m, StringComparison.Ordinal)).ToArray();+ return new AirScenarioResult(name, true, "success", diagnostics, ordered.Select(x => x.LayerRole).ToArray(), markers, text.Contains("BREP_WITH_VOIDS", StringComparison.Ordinal));+ }++ private static AirProfileStackExtrude BuildThrough() =>+ new([+ new AirProfileStackLayer(-10, 10,+ new AirProfileRegion2D(new AirRectangleProfile(30, 30), new AirCenteredCircleLoop(2), "rectangle-minus-circle"),+ "through-core", [])+ ], -10, 10, ["scenario=through-hole"]);++ private static AirProfileStackExtrude BuildStepped() =>+ new([+ new AirProfileStackLayer(-10, 2, new AirProfileRegion2D(new AirRectangleProfile(30, 30), new AirCenteredCircleLoop(2), "small-core"), "stepped-layer-small", []),+ new AirProfileStackLayer(2, 6, new AirProfileRegion2D(new AirRectangleProfile(30, 30), new AirCenteredCircleLoop(3), "medium-relief"), "stepped-layer-medium", []),+ new AirProfileStackLayer(6, 10, new AirProfileRegion2D(new AirRectangleProfile(30, 30), new AirCenteredCircleLoop(4), "large-relief"), "stepped-layer-large", [])+ ], -10, 10, ["scenario=stepped-hole"]);++ private static AirProfileStackExtrude BuildBlind() =>+ new([+ new AirProfileStackLayer(-10, 2, new AirProfileRegion2D(new AirRectangleProfile(30, 30), null, "solid-zone"), "blind-solid-lower", []),+ new AirProfileStackLayer(2, 10, new AirProfileRegion2D(new AirRectangleProfile(30, 30), new AirCenteredCircleLoop(2), "blind-cut"), "blind-cut-upper", [])+ ], -10, 10, ["scenario=blind-hole"]);++ private static AirProfileStackExtrude BuildCounterbore() =>+ new([+ new AirProfileStackLayer(-10, 6, new AirProfileRegion2D(new AirRectangleProfile(30, 30), new AirCenteredCircleLoop(2), "deep-small"), "counterbore-deep-small", []),+ new AirProfileStackLayer(6, 10, new AirProfileRegion2D(new AirRectangleProfile(30, 30), new AirCenteredCircleLoop(4), "entry-large"), "counterbore-entry-large", [])+ ], -10, 10, ["scenario=counterbore"]);+}diff --git a/Aetheris.FrictionLab.Tests/CIRLab/AirProfileStackExtrudeLabTests.cs b/Aetheris.FrictionLab.Tests/CIRLab/AirProfileStackExtrudeLabTests.csnew file mode 100644index 00000000..a41e4b6a--- /dev/null+++ b/Aetheris.FrictionLab.Tests/CIRLab/AirProfileStackExtrudeLabTests.cs@@ -0,0 +1,81 @@+using Aetheris.Firmament.FrictionLab.CIRLab;+using Aetheris.Kernel.Firmament.Materializer;++namespace Aetheris.FrictionLab.Tests.CIRLab;++public class AirProfileStackExtrudeLabTests+{+ [Fact]+ public void AirProfileIr_RepresentsRectangleWithCircularHole()+ {+ var r = AirProfileStackExtrudeLab.Run().ThroughHole.Layers.Single().Region;+ Assert.Equal(30, r.OuterRectangle.Width);+ Assert.NotNull(r.InnerCircle);+ Assert.Equal(2, r.InnerCircle!.Radius);+ }++ [Fact]+ public void AirProfileStack_ThroughHole_EmitsStepOrReportsExactBlocker()+ {+ var result = AirProfileStackExtrudeLab.Run().ThroughHoleResult;+ Assert.True(result.Success || result.Status.StartsWith("blocker:emitter:", StringComparison.Ordinal));+ if (result.Success)+ {+ Assert.Contains("ISO-10303-21", result.StepMarkers);+ Assert.DoesNotContain("BREP_WITH_VOIDS", result.StepMarkers);+ }+ }++ [Fact]+ public void AirProfileStack_SteppedHole_EmitsStep()+ {+ var result = AirProfileStackExtrudeLab.Run().SteppedHoleResult;+ Assert.True(result.Success, string.Join("\n", result.Diagnostics));+ Assert.Contains("ISO-10303-21", result.StepMarkers);+ Assert.Contains("MANIFOLD_SOLID_BREP", result.StepMarkers);+ Assert.DoesNotContain("BREP_WITH_VOIDS", result.StepMarkers);+ }++ [Fact]+ public void AirProfileStack_BlindHole_FeasibilityRecorded()+ {+ var result = AirProfileStackExtrudeLab.Run().BlindHoleResult;+ Assert.True(result.Success || result.Status.StartsWith("blocker:emitter:", StringComparison.Ordinal));+ }++ [Fact]+ public void AirProfileStack_Counterbore_FeasibilityRecorded()+ {+ var result = AirProfileStackExtrudeLab.Run().CounterboreResult;+ Assert.True(result.Success || result.Status.StartsWith("blocker:emitter:", StringComparison.Ordinal));+ }++ [Fact]+ public void AirProfileStack_ReportContainsDecisionGradeMapping()+ {+ var result = AirProfileStackExtrudeLab.Run();+ Assert.NotEmpty(result.MappingFindings);+ Assert.Contains("HoleRecoveryPlan", result.MappingRecommendation, StringComparison.Ordinal);+ Assert.Contains("ProfileStackExtrudeSpec", result.MappingRecommendation, StringComparison.Ordinal);+ }++ [Fact]+ public void AirProfileStack_DeterministicResults()+ {+ var a = AirProfileStackExtrudeLab.Run();+ var b = AirProfileStackExtrudeLab.Run();+ Assert.Equal(a.ThroughHoleResult.Status, b.ThroughHoleResult.Status);+ Assert.Equal(a.SteppedHoleResult.Status, b.SteppedHoleResult.Status);+ Assert.Equal(string.Join("|", a.SteppedHoleResult.LayerRoles), string.Join("|", b.SteppedHoleResult.LayerRoles));+ }++ [Fact]+ public void AirProfileStack_MapsFromKernelProfileStackSpec()+ {+ var spec = new Aetheris.Kernel.Firmament.Materializer.ProfileStackExtrudeSpec(20, 20, -5, 5,+ [new Aetheris.Kernel.Firmament.Materializer.ProfileStackLayer(-5, 5, 2, "through", [])], []);+ Assert.True(AirProfileStackExtrudeLab.TryMapFromProfileStackSpec(spec, out var air, out _));+ Assert.NotNull(air);+ Assert.Single(air!.Layers);+ }+}diff --git a/docs/frictionlab/air-x1-profile-ir-profile-stack-extrude-lab.md b/docs/frictionlab/air-x1-profile-ir-profile-stack-extrude-lab.mdnew file mode 100644index 00000000..725ea39f--- /dev/null+++ b/docs/frictionlab/air-x1-profile-ir-profile-stack-extrude-lab.md@@ -0,0 +1,98 @@+# AIR-X1: minimal Profile IR + AirProfileStackExtrude EVT lab++## 1) Purpose and EVT scope+AIR-X1 is an EVT-only architecture proof for the first AIR atom (`AirProfileStackExtrude`) and a minimal Profile IR sufficient for current bounded cylindrical hole-family profile-stack scenarios. This lab is confined to FrictionLab code/tests and does not change production routing.++## 2) Code/docs inspected+Inspected before implementation:+- AIR docs: `docs/air-a0-atomic-intermediate-representation-kickoff.md`, `docs/air-a0-architecture-probe-report.md`.+- Sweep/profile-stack docs: `docs/frictionlab/cir-sweep-x0-profile-stack-extrude-lab.md`, `docs/cir-sweep-v1-profile-stack-extrude-executor.md`, `docs/cir-sweep-v2-cylindrical-hole-profile-stack-migration.md`.+- Hole-family production: `HoleRecoveryPolicy`, `HoleRecoveryPlan`, `HoleProfileSegment`, `HoleRecoveryExecutor`, `ProfileStackExtrudeSpec`, `ProfileStackLayer`, `ProfileStackExtrudeExecutor`, `ProfileStackExtrudePlanAdapter`, `FrepSemanticRecoveryRematerializer`, and V19 manifest.+- BRep/STEP: `BrepBody`, `TopologyModel`, `BrepBooleanBoxCylinderHoleBuilder`, `Step242Exporter.ExportBody`.+- Tests: FrictionLab profile-stack tests, placement semantics and executor tests, coverage matrix/rematerializer tests.++## 3) Minimal Profile IR proposal+Proposed minimal EVT profile IR:+- `AirRectangleProfile(Width, Height)`+- `AirCenteredCircleLoop(Radius)` (optional inner loop)+- `AirProfileRegion2D(OuterRectangle, InnerCircle?, SemanticRole)`+- `AirProfileStackLayer(ZMin, ZMax, Region, LayerRole, Diagnostics)`+- `AirProfileStackExtrude(Layers, GlobalZMin, GlobalZMax, Diagnostics)`++This is intentionally bounded (rectangle outer + optional centered circle inner + ordered z-layers).++## 4) Profile IR type/field table+Essential now:+- Outer rectangle extents (host region)+- Optional centered circular inner loop+- Layer z interval+- Layer semantic role+- Diagnostics++Deferred intentionally:+- arbitrary polygon/arc loops+- multiple inner loops and loop orientation+- non-centered loops+- 2D boolean provenance+- topology naming or sketch editing operations++## 5) Mapping from `HoleRecoveryPlan`+Observations:+- `HoleRecoveryPlan.ProfileStack` already carries per-segment z span, radius, anchor/through semantics and diagnostics.+- AIR mapping from plan is richest in semantic provenance (best for intent traceability).+- For executable cylindrical lanes, plan can first normalize into `ProfileStackExtrudeSpec` under current adapter validation.++## 6) Mapping from `ProfileStackExtrudeSpec`+Implemented prototype mapper:+- `TryMapFromProfileStackSpec(ProfileStackExtrudeSpec -> AirProfileStackExtrude)`+- preserves per-layer role/z/radius and carries diagnostics.++Recommendation:+- AIR-V1 should accept plan-origin provenance but normalize execution contract through `HoleRecoveryPlan -> ProfileStackExtrudeSpec -> AIR`.++## 7) Scenario results+- Through-hole: represented and emitted successfully (success path).+- Stepped-hole: represented and emitted successfully (flagship X1 proof).+- Blind-hole: representable in AIR model (solid+cut layers), blocked by current executor shape gate requiring positive radius in every layer.+- Counterbore: representable in AIR model as layered radii, emitted in this contiguous-layer encoding.++## 8) STEP smoke results+Successful scenarios verified markers:+- `ISO-10303-21`+- `MANIFOLD_SOLID_BREP`+- `ADVANCED_FACE`+- `CYLINDRICAL_SURFACE`+- no `BREP_WITH_VOIDS`++## 9) Current production path comparison+- Through-hole profile-stack active in production and aligns directly with AIR-X1 representation.+- Stepped-hole profile-stack active in production and aligns directly with AIR-X1 representation.+- Blind-hole remains legacy in production; AIR can represent it, but current ProfileStack executor contract blocks no-hole intervals.+- Counterbore remains legacy in production by adapter policy, though AIR-X1 contiguous stack representation can emit in lab.++## 10) What Profile IR does not support yet+- Generic 2D sketch kernel+- arbitrary loop classes+- conical/chamfer/countersink profile primitives+- cross-axis and interacting feature resolution++## 11) Recommended AIR-V1 DVT scope+- Formalize `AirProfileStackExtrude` around cylindrical contiguous stacks.+- Preserve plan provenance from `HoleRecoveryPlan` in AIR diagnostics.+- Keep emission on existing `ProfileStackExtrudeExecutor`/builder routes.+- Explicitly document blind/counterbore migration boundary and required executor evolution for no-hole/overlap spans.++## 12) Risks / guardrails+Risks:+- over-expanding AIR into sketch kernel work,+- conflating AIR model-side expressiveness with current emitter capability.++Guardrails:+- bounded analytic profiles only,+- explicit blocker diagnostics by model-side vs emitter-side,+- no production route changes in EVT.++## 13) Confidence ratings+- Minimal IR adequacy for through/stepped: High.+- Mapping recommendation quality: Medium-High.+- Blind/counterbore generalized migration readiness: Medium (emitter contract constraints remain explicit).