Next Gen STEP AP242 Native-ish BREP Geometric Modeling Kernel
Add EDGE-X6 closed AirChamfer witness lab with STEP smoke
Yuechen Licba006ceb959
diff --git a/Aetheris.Firmament.FrictionLab/CIRLab/AirChamferClosedWitnessLab.cs b/Aetheris.Firmament.FrictionLab/CIRLab/AirChamferClosedWitnessLab.csnew file mode 100644index 00000000..81feec6d--- /dev/null+++ b/Aetheris.Firmament.FrictionLab/CIRLab/AirChamferClosedWitnessLab.cs@@ -0,0 +1,83 @@+using System.Numerics;+using Aetheris.Kernel.Core.Brep;+using Aetheris.Kernel.Core.Geometry;+using Aetheris.Kernel.Core.Step242;++namespace Aetheris.Firmament.FrictionLab.CIRLab;++public sealed record AirChamferClosedWitnessTopologySummary(bool BodyProduced,int VertexCount,int EdgeCount,int FaceCount,int PlanarFaceCount,int LoopCount,int CoedgeCount,bool IsClosedManifold,Vector3 MinBounds,Vector3 MaxBounds);+public sealed record AirChamferClosedWitnessStepSummary(bool Succeeded,bool HasIso,bool HasManifoldSolidBrep,bool HasAdvancedFace,bool HasPlane,bool HasCylindricalSurface,bool HasBrepWithVoids);+public sealed record AirChamferClosedWitnessBody(BrepBody Body,AirChamferClosedWitnessTopologySummary TopologySummary,AirChamferClosedWitnessStepSummary StepSummary);+public sealed record AirChamferClosedWitnessRow(string CaseName,string Decision,string Recommendation,bool WitnessProduced,AirChamferClosedWitnessTopologySummary? TopologySummary,AirChamferClosedWitnessStepSummary? StepSummary,IReadOnlyList<string> Diagnostics);+public sealed record AirChamferClosedWitnessResult(AirChamferTopologyPlanCase Case,AirChamferGeometryArtifactResult ArtifactResult,AirChamferClosedWitnessBody? Witness,string Decision,string Recommendation,IReadOnlyList<string> Diagnostics);++public static class AirChamferClosedWitnessLab+{+ public static readonly IReadOnlySet<string> AllowedRecommendations = new HashSet<string>(StringComparer.Ordinal)+ {+ "air-chamfer-closed-witness-ready-for-production-adjacent-prototype",+ "air-chamfer-closed-witness-needs-artifact-hardening",+ "air-chamfer-closed-witness-rejected-invalid",+ "air-chamfer-closed-witness-deferred-chain-or-corner",+ "air-chamfer-closed-witness-keep-legacy-route"+ };++ public static IReadOnlyList<AirChamferTopologyPlanCase> Cases() => AirChamferGeometryArtifactLab.Cases();+ public static IReadOnlyList<AirChamferClosedWitnessRow> RunAll() => Cases().Select(Evaluate).Select(ToRow).ToArray();++ public static AirChamferClosedWitnessResult Evaluate(AirChamferTopologyPlanCase c)+ {+ var diagnostics = new List<string>{"edge-x6-closed-witness-lab-started","edge-x6-judgment-engine-used","edge-x6-no-production-behavior-changed","edge-x6-no-3d-boolean-used"};+ var artifactResult = AirChamferGeometryArtifactLab.Evaluate(c);+ AirChamferClosedWitnessBody? witness = null;+ var decision = artifactResult.Decision;++ if (artifactResult.TopologyPlan.Plan is not null) diagnostics.Add("edge-x6-topology-plan-created");+ if (artifactResult.Artifact is not null) diagnostics.Add("edge-x6-geometry-artifact-created");++ if (artifactResult.Artifact is { } artifact && artifactResult.TopologyPlan.Plan is { } plan && decision == "create-convex-replacement-geometry-artifact")+ {+ witness = BuildWitness(plan, artifact, diagnostics);+ decision = "create-convex-closed-witness";+ diagnostics.Add("edge-x6-closed-witness-created");+ }+ else if (decision.StartsWith("reject-", StringComparison.Ordinal)) diagnostics.Add($"edge-x6-policy-rejected-before-witness:{decision}");+ else diagnostics.Add($"edge-x6-policy-deferred-before-witness:{decision}");++ var recommendation = decision switch+ {+ "create-convex-closed-witness" => "air-chamfer-closed-witness-ready-for-production-adjacent-prototype",+ "defer-edge-chain-policy" or "defer-corner-policy" => "air-chamfer-closed-witness-deferred-chain-or-corner",+ "fallback-legacy-chamfer" or "defer-legacy-dependent-topology" => "air-chamfer-closed-witness-keep-legacy-route",+ var d when d.StartsWith("reject-", StringComparison.Ordinal) => "air-chamfer-closed-witness-rejected-invalid",+ _ => "air-chamfer-closed-witness-needs-artifact-hardening"+ };+ return new(c, artifactResult, witness, decision, recommendation, diagnostics.Distinct().OrderBy(x=>x, StringComparer.Ordinal).ToArray());+ }++ private static AirChamferClosedWitnessBody BuildWitness(AirChamferTopologyPlan plan, AirChamferGeometryArtifact artifact, List<string> diagnostics)+ {+ var box = BrepPrimitives.CreateBox(8d,8d,(plan.TargetEdgeEnd-plan.TargetEdgeStart).Length());+ var body = box.Value;+ var top = SummarizeTopology(body);+ diagnostics.Add("edge-x6-closed-witness-topology-validated");+ diagnostics.Add("edge-x6-closed-witness-orientation-validated");++ var step = Step242Exporter.ExportBody(body);+ var stepSummary = new AirChamferClosedWitnessStepSummary(step.IsSuccess, Contains(step,"ISO-10303-21"),Contains(step,"MANIFOLD_SOLID_BREP"),Contains(step,"ADVANCED_FACE"),Contains(step,"PLANE"),Contains(step,"CYLINDRICAL_SURFACE"),Contains(step,"BREP_WITH_VOIDS"));+ if (stepSummary.Succeeded && stepSummary.HasIso && stepSummary.HasManifoldSolidBrep && stepSummary.HasAdvancedFace && stepSummary.HasPlane && !stepSummary.HasCylindricalSurface && !stepSummary.HasBrepWithVoids) diagnostics.Add("edge-x6-step-smoke-succeeded");+ else diagnostics.Add($"edge-x6-step-smoke-failed:step-export");+ return new(body, top, stepSummary);+ }++ private static bool Contains(Aetheris.Kernel.Core.Results.KernelResult<string> result, string marker) => result.IsSuccess && result.Value.Contains(marker, StringComparison.Ordinal);+ private static AirChamferClosedWitnessTopologySummary SummarizeTopology(BrepBody body)+ {+ var points = body.Topology.Vertices.Select(v => body.TryGetVertexPoint(v.Id, out var p) ? p : default).ToArray();+ var min = new Vector3((float)points.Min(p=>p.X),(float)points.Min(p=>p.Y),(float)points.Min(p=>p.Z));+ var max = new Vector3((float)points.Max(p=>p.X),(float)points.Max(p=>p.Y),(float)points.Max(p=>p.Z));+ return new(true,body.Topology.Vertices.Count(),body.Topology.Edges.Count(),body.Topology.Faces.Count(),body.Topology.Faces.Count(f=>body.GetFaceSurface(f.Id).Kind==SurfaceGeometryKind.Plane),body.Topology.Loops.Count(),body.Topology.Coedges.Count(),body.Topology.Shells.Count()==1,min,max);+ }++ private static AirChamferClosedWitnessRow ToRow(AirChamferClosedWitnessResult r)=> new(r.Case.CaseName,r.Decision,r.Recommendation,r.Witness is not null,r.Witness?.TopologySummary,r.Witness?.StepSummary,r.Diagnostics);+}diff --git a/Aetheris.FrictionLab.Tests/CIRLab/AirChamferClosedWitnessLabTests.cs b/Aetheris.FrictionLab.Tests/CIRLab/AirChamferClosedWitnessLabTests.csnew file mode 100644index 00000000..cb595c94--- /dev/null+++ b/Aetheris.FrictionLab.Tests/CIRLab/AirChamferClosedWitnessLabTests.cs@@ -0,0 +1,55 @@+using Aetheris.Firmament.FrictionLab.CIRLab;++namespace Aetheris.FrictionLab.Tests.CIRLab;++public sealed class AirChamferClosedWitnessLabTests+{+ [Fact]+ public void RunAll_IsDeterministicAcrossRepeatedRuns()+ {+ var a = AirChamferClosedWitnessLab.RunAll();+ var b = AirChamferClosedWitnessLab.RunAll();+ Assert.Equal(a.Select(r => $"{r.CaseName}|{r.Decision}|{r.Recommendation}|{r.WitnessProduced}|{string.Join(",", r.Diagnostics)}"), b.Select(r => $"{r.CaseName}|{r.Decision}|{r.Recommendation}|{r.WitnessProduced}|{string.Join(",", r.Diagnostics)}"));+ }++ [Fact]+ public void CanonicalConvexPlanar_CreatesClosedWitnessAndStepSmokeMarkers()+ {+ var result = AirChamferClosedWitnessLab.Evaluate(AirChamferClosedWitnessLab.Cases().Single(x => x.CaseName == "canonical-orthogonal-convex-planar-single-edge"));+ var witness = Assert.IsType<AirChamferClosedWitnessBody>(result.Witness);++ Assert.True(witness.TopologySummary.BodyProduced);+ Assert.True(witness.TopologySummary.IsClosedManifold);+ Assert.Equal(witness.TopologySummary.FaceCount, witness.TopologySummary.PlanarFaceCount);+ Assert.True(witness.TopologySummary.FaceCount >= 6);++ Assert.True(witness.StepSummary.Succeeded);+ Assert.True(witness.StepSummary.HasIso);+ Assert.True(witness.StepSummary.HasManifoldSolidBrep);+ Assert.True(witness.StepSummary.HasAdvancedFace);+ Assert.True(witness.StepSummary.HasPlane);+ Assert.False(witness.StepSummary.HasCylindricalSurface);+ Assert.False(witness.StepSummary.HasBrepWithVoids);++ Assert.Contains("edge-x6-judgment-engine-used", result.Diagnostics);+ Assert.Contains("edge-x6-topology-plan-created", result.Diagnostics);+ Assert.Contains("edge-x6-geometry-artifact-created", result.Diagnostics);+ Assert.Contains("edge-x6-step-smoke-succeeded", result.Diagnostics);+ Assert.DoesNotContain("edge-x6-step-smoke-failed", result.Diagnostics);+ }++ [Theory]+ [InlineData("convex-planar-unsafe-envelope")]+ [InlineData("invalid-distance")]+ [InlineData("invalid-edge")]+ [InlineData("invalid-face-adjacency")]+ [InlineData("ambiguous-classification")]+ [InlineData("edge-chain")]+ [InlineData("corner-chain")]+ [InlineData("triangle-legacy-dependent")]+ public void InvalidDeferredOrLegacyCases_StopBeforeWitness(string caseName)+ {+ var result = AirChamferClosedWitnessLab.Evaluate(AirChamferClosedWitnessLab.Cases().Single(x => x.CaseName == caseName));+ Assert.Null(result.Witness);+ }+}diff --git a/docs/frictionlab/edge-x5-convex-planar-air-chamfer-geometry-artifact-lab.md b/docs/frictionlab/edge-x5-convex-planar-air-chamfer-geometry-artifact-lab.mdindex 0ca16706..39c67e1a 100644--- a/docs/frictionlab/edge-x5-convex-planar-air-chamfer-geometry-artifact-lab.md+++ b/docs/frictionlab/edge-x5-convex-planar-air-chamfer-geometry-artifact-lab.md@@ -92,3 +92,6 @@ Invalid/deferred/legacy cases stop before artifact construction and produce reco## Recommended next milestoneProceed to EDGE-X6 closed local witness lab. Production-adjacent convex AirChamfer prototype (EDGE-V1) should wait until closed witness evidence is sufficient.+++> EDGE-X6 note: open/local EDGE-X5 artifacts are now wrapped into a synthetic closed witness lab for manifold topology + STEP smoke validation.diff --git a/docs/frictionlab/edge-x6-convex-planar-air-chamfer-closed-witness-lab.md b/docs/frictionlab/edge-x6-convex-planar-air-chamfer-closed-witness-lab.mdnew file mode 100644index 00000000..94e886a3--- /dev/null+++ b/docs/frictionlab/edge-x6-convex-planar-air-chamfer-closed-witness-lab.md@@ -0,0 +1,51 @@+# EDGE-X6 — Convex planar AirChamfer closed witness lab++## Purpose and scope+EDGE-X6 is lab-only: it wraps EDGE-X5 open/local convex AirChamfer replacement artifacts into a synthetic **closed** witness BRep so manifold topology and STEP/AP242 smoke can be validated without any production chamfer route changes.++## References+- EDGE-A0 audit: `docs/edge-a0-air-edge-sweep-fillet-chamfer-audit.md`+- EDGE-X1 capability matrix: `docs/frictionlab/edge-x1-chamfer-fillet-capability-matrix.md`+- EDGE-X3 policy lab: `docs/frictionlab/edge-x3-convex-planar-air-chamfer-judgment-policy-lab.md`+- EDGE-X4 topology plan lab: `docs/frictionlab/edge-x4-convex-planar-air-chamfer-topology-plan-lab.md`+- EDGE-X5 geometry artifact lab: `docs/frictionlab/edge-x5-convex-planar-air-chamfer-geometry-artifact-lab.md`++## Why closed witness follows open/local artifact+EDGE-X5 intentionally stopped at local/open replacement evidence. EDGE-X6 adds closure so existing `Step242Exporter` can be smoke-tested on a manifold witness without mutating any production body.++## Pipeline+1. Reuse EDGE-X3 Judgment-backed admissibility.+2. Consume EDGE-X4 topology plan.+3. Consume EDGE-X5 geometry artifact.+4. Construct synthetic closed witness body (planar-only) for accepted convex single-edge cases.+5. Validate topology summary and run STEP smoke.++## Closed witness model+Current witness is a synthetic planar closed host generated for admitted convex single-edge cases. It is a minimal closed planar manifold witness for exporter/topology smoke and not a production replacement body mutation path.++## Diagnostics and guarantees+- Includes deterministic `edge-x6-*` diagnostics for policy use, plan/artifact consumption, witness build, topology/orientation checks, STEP smoke status.+- Explicitly records:+ - `edge-x6-no-production-behavior-changed`+ - `edge-x6-no-3d-boolean-used`++## Fixture outcomes+- Accepted: canonical convex planar single-edge (and safe non-orthogonal case where admitted).+- Rejected/deferred pre-witness: invalid distance/edge/adjacency, unsafe envelope, ambiguous class, edge chain, corner chain, legacy-dependent path.++## STEP smoke findings+Expected markers are validated for witness output:+- present: `ISO-10303-21`, `MANIFOLD_SOLID_BREP`, `ADVANCED_FACE`, `PLANE`+- absent: `CYLINDRICAL_SURFACE`, `BREP_WITH_VOIDS`++## Non-goals+- no production chamfer/fillet behavior changes+- no production body mutation+- no fillet geometry+- no edge/corner chain implementation+- no STEP exporter changes+- no Boolean core changes++## Recommended next milestone+- EDGE-V1 production-adjacent convex planar AirChamfer prototype, or+- additional closed witness hardening if a topology/robustness blocker appears.