Next Gen STEP AP242 Native-ish BREP Geometric Modeling Kernel
EDGE-X4 add convex planar AirChamfer topology-plan lab
Yuechen Li3b226073bff9
diff --git a/Aetheris.Firmament.FrictionLab/CIRLab/AirChamferTopologyPlanLab.cs b/Aetheris.Firmament.FrictionLab/CIRLab/AirChamferTopologyPlanLab.csnew file mode 100644index 00000000..f427981f--- /dev/null+++ b/Aetheris.Firmament.FrictionLab/CIRLab/AirChamferTopologyPlanLab.cs@@ -0,0 +1,152 @@+using System.Numerics;++namespace Aetheris.Firmament.FrictionLab.CIRLab;++public sealed record AirChamferTopologyPlanCase(string CaseName, AirChamferPolicyRequest Request, string ExpectedDecision);+public sealed record AirChamferTopologyPlan(+ string ReplacementMode,+ Vector3 TargetEdgeStart,+ Vector3 TargetEdgeEnd,+ Vector3 EdgeDirection,+ Vector3 FaceANormal,+ Vector3 FaceBNormal,+ double ChamferDistance,+ string ConvexityClassification,+ string FaceADescriptor,+ string FaceBDescriptor,+ int OriginalTargetEdgeCount,+ int OffsetCurveCount,+ int NewChamferFaceCount,+ int NewTransitionEdgeCount,+ int AdjacentFaceAffectedCount,+ int CornerPatchCount,+ bool CornerPatchesDeferred,+ bool OriginalEdgeMarkedForReplacement,+ bool FaceATrimPlanned,+ bool FaceBTrimPlanned,+ bool GeometryEmissionPerformed);++public sealed record AirChamferTopologyPlanResult(+ AirChamferTopologyPlanCase Case,+ AirChamferPolicyResult Policy,+ AirChamferTopologyPlan? Plan,+ string Decision,+ string Recommendation,+ IReadOnlyList<string> Diagnostics);++public sealed record AirChamferTopologyPlanRow(+ string CaseName,+ string Decision,+ string Recommendation,+ bool PlanProduced,+ int OffsetCurveCount,+ int NewChamferFaceCount,+ int AdjacentFaceAffectedCount,+ int NewTransitionEdgeCount,+ int CornerPatchCount,+ bool GeometryEmissionPerformed,+ IReadOnlyList<string> Diagnostics);++public static class AirChamferTopologyPlanLab+{+ public static readonly IReadOnlySet<string> AllowedRecommendations = new HashSet<string>(StringComparer.Ordinal)+ {+ "air-chamfer-topology-plan-ready-for-geometry-lab",+ "air-chamfer-topology-plan-needs-policy-hardening",+ "air-chamfer-topology-plan-rejected-invalid",+ "air-chamfer-topology-plan-deferred-chain-or-corner",+ "air-chamfer-topology-plan-keep-legacy-route"+ };++ public static IReadOnlyList<AirChamferTopologyPlanCase> Cases() =>+ [+ new("canonical-orthogonal-convex-planar-single-edge", new(new(0,0,-5),new(0,0,5),new(1,0,0),new(0,1,0),1d,AirChamferFaceFamily.Planar,false,false,false,AirChamferRoutePreference.Auto,AirChamferClassificationExpectation.Convex,true,10d), "plan-convex-replacement-topology"),+ new("nonorthogonal-convex-planar-single-edge", new(new(0,0,-5),new(0,0,5),new(1,0,0),Vector3.Normalize(new Vector3(1,1,0)),1d,AirChamferFaceFamily.Planar,false,false,false,AirChamferRoutePreference.Auto,AirChamferClassificationExpectation.Convex,false,10d), "plan-convex-replacement-topology"),+ new("convex-planar-unsafe-envelope", new(new(0,0,-5),new(0,0,5),new(1,0,0),new(0,1,0),8d,AirChamferFaceFamily.Planar,false,false,false,AirChamferRoutePreference.Auto,AirChamferClassificationExpectation.Convex,true,6d), "reject-unsafe-offset-envelope"),+ new("invalid-distance", new(new(0,0,-5),new(0,0,5),new(1,0,0),new(0,1,0),0d,AirChamferFaceFamily.Planar,false,false,false,AirChamferRoutePreference.Auto,AirChamferClassificationExpectation.Convex,true,10d), "reject-invalid-distance"),+ new("invalid-edge", new(new(0,0,0),new(0,0,0),new(1,0,0),new(0,1,0),1d,AirChamferFaceFamily.Planar,false,false,false,AirChamferRoutePreference.Auto,AirChamferClassificationExpectation.Convex,true,10d), "reject-invalid-edge"),+ new("invalid-face-adjacency", new(new(0,0,-5),new(0,0,5),new(1,0,0),null,1d,AirChamferFaceFamily.Planar,false,false,false,AirChamferRoutePreference.Auto,AirChamferClassificationExpectation.Convex,true,10d), "reject-invalid-face-adjacency"),+ new("ambiguous-classification", new(new(0,0,-5),new(0,0,5),new(1,0,0),new(0,1,0),1d,AirChamferFaceFamily.Planar,false,false,false,AirChamferRoutePreference.Auto,AirChamferClassificationExpectation.Ambiguous,true,10d), "reject-ambiguous-classification"),+ new("edge-chain", new(new(0,0,-5),new(0,0,5),new(1,0,0),new(0,1,0),1d,AirChamferFaceFamily.Planar,true,false,false,AirChamferRoutePreference.Auto,AirChamferClassificationExpectation.Concave,true,10d), "defer-edge-chain-policy"),+ new("corner-chain", new(new(0,0,-5),new(0,0,5),new(1,0,0),new(0,1,0),1d,AirChamferFaceFamily.Planar,false,true,false,AirChamferRoutePreference.Auto,AirChamferClassificationExpectation.Concave,true,10d), "defer-corner-policy"),+ new("triangle-legacy-dependent", new(new(0,0,-5),new(0,0,5),new(1,0,0),new(0,1,0),1d,AirChamferFaceFamily.Planar,false,false,true,AirChamferRoutePreference.Legacy,AirChamferClassificationExpectation.Concave,true,10d), "fallback-legacy-chamfer")+ ];++ public static IReadOnlyList<AirChamferTopologyPlanRow> RunAll() => Cases().Select(Evaluate).Select(ToRow).ToArray();++ public static AirChamferTopologyPlanResult Evaluate(AirChamferTopologyPlanCase c)+ {+ var diagnostics = new List<string> { "edge-x4-topology-plan-lab-started", "edge-x4-judgment-engine-used", "edge-x4-no-geometry-emission", "edge-x4-no-production-behavior-changed", "edge-x4-no-3d-boolean-used" };+ var policyCase = new AirChamferPolicyCase(c.CaseName, c.Request, c.ExpectedDecision);+ var policy = AirChamferPolicyLab.Evaluate(policyCase);+ diagnostics.AddRange(policy.Diagnostics.Where(d => d.Contains("judgment", StringComparison.Ordinal)));++ AirChamferTopologyPlan? plan = null;+ var decision = policy.Decision.Decision;+ if (decision == "defer-convex-replacement-geometry")+ {+ diagnostics.Add("edge-x4-policy-admitted-convex-plan");+ plan = CreatePlan(c.Request, diagnostics);+ decision = "plan-convex-replacement-topology";+ diagnostics.Add("edge-x4-topology-plan-created");+ }+ else if (decision.StartsWith("reject-", StringComparison.Ordinal))+ {+ diagnostics.Add($"edge-x4-policy-rejected-before-plan:{decision}");+ }+ else+ {+ diagnostics.Add($"edge-x4-policy-deferred-before-plan:{decision}");+ }++ var recommendation = decision switch+ {+ "plan-convex-replacement-topology" => "air-chamfer-topology-plan-ready-for-geometry-lab",+ "defer-edge-chain-policy" or "defer-corner-policy" => "air-chamfer-topology-plan-deferred-chain-or-corner",+ "fallback-legacy-chamfer" or "defer-legacy-dependent-topology" => "air-chamfer-topology-plan-keep-legacy-route",+ var d when d.StartsWith("reject-", StringComparison.Ordinal) => "air-chamfer-topology-plan-rejected-invalid",+ _ => "air-chamfer-topology-plan-needs-policy-hardening"+ };++ return new(c, policy, plan, decision, recommendation, diagnostics.Distinct().OrderBy(x => x, StringComparer.Ordinal).ToArray());+ }++ private static AirChamferTopologyPlan CreatePlan(AirChamferPolicyRequest request, List<string> diagnostics)+ {+ var edgeDirection = Vector3.Normalize(request.EdgeEnd - request.EdgeStart);+ diagnostics.Add("edge-x4-offset-curve-a-planned");+ diagnostics.Add("edge-x4-offset-curve-b-planned");+ diagnostics.Add("edge-x4-original-edge-marked-for-replacement");+ diagnostics.Add("edge-x4-adjacent-face-a-trim-planned");+ diagnostics.Add("edge-x4-adjacent-face-b-trim-planned");+ diagnostics.Add("edge-x4-chamfer-face-planned");+ diagnostics.Add("edge-x4-transition-edges-planned");+ diagnostics.Add("edge-x4-corner-patches-deferred");++ return new(+ "single-edge-convex-planar",+ request.EdgeStart,+ request.EdgeEnd,+ edgeDirection,+ Vector3.Normalize(request.FaceANormal!.Value),+ Vector3.Normalize(request.FaceBNormal!.Value),+ request.ChamferDistance,+ "convex",+ "adjacent-face-a-planar",+ "adjacent-face-b-planar",+ 1,+ 2,+ 1,+ 2,+ 2,+ 0,+ true,+ true,+ true,+ true,+ false);+ }++ private static AirChamferTopologyPlanRow ToRow(AirChamferTopologyPlanResult r) =>+ new(r.Case.CaseName, r.Decision, r.Recommendation, r.Plan is not null, r.Plan?.OffsetCurveCount ?? 0, r.Plan?.NewChamferFaceCount ?? 0, r.Plan?.AdjacentFaceAffectedCount ?? 0, r.Plan?.NewTransitionEdgeCount ?? 0, r.Plan?.CornerPatchCount ?? 0, r.Plan?.GeometryEmissionPerformed ?? false, r.Diagnostics);+}diff --git a/Aetheris.FrictionLab.Tests/CIRLab/AirChamferTopologyPlanLabTests.cs b/Aetheris.FrictionLab.Tests/CIRLab/AirChamferTopologyPlanLabTests.csnew file mode 100644index 00000000..f677b9a2--- /dev/null+++ b/Aetheris.FrictionLab.Tests/CIRLab/AirChamferTopologyPlanLabTests.cs@@ -0,0 +1,70 @@+using System.Text.Json;+using Aetheris.Firmament.FrictionLab.CIRLab;++namespace Aetheris.FrictionLab.Tests.CIRLab;++public sealed class AirChamferTopologyPlanLabTests+{+ [Fact]+ public void RunAll_IsDeterministic()+ {+ var a = AirChamferTopologyPlanLab.RunAll();+ var b = AirChamferTopologyPlanLab.RunAll();+ Assert.Equal(JsonSerializer.Serialize(a), JsonSerializer.Serialize(b));+ }++ [Fact]+ public void Diagnostics_IncludeJudgmentEngineUsage()+ {+ var row = AirChamferTopologyPlanLab.Evaluate(AirChamferTopologyPlanLab.Cases().Single(x => x.CaseName == "canonical-orthogonal-convex-planar-single-edge"));+ Assert.Contains("edge-x4-judgment-engine-used", row.Diagnostics);+ }++ [Fact]+ public void CanonicalConvexPlanar_ProducesTopologyPlanWithExpectedCounts()+ {+ var result = AirChamferTopologyPlanLab.Evaluate(AirChamferTopologyPlanLab.Cases().Single(x => x.CaseName == "canonical-orthogonal-convex-planar-single-edge"));+ Assert.Equal("plan-convex-replacement-topology", result.Decision);+ Assert.NotNull(result.Plan);+ Assert.Equal(2, result.Plan!.OffsetCurveCount);+ Assert.Equal(1, result.Plan.NewChamferFaceCount);+ Assert.Equal(2, result.Plan.AdjacentFaceAffectedCount);+ Assert.True(result.Plan.OriginalEdgeMarkedForReplacement);+ Assert.Equal(2, result.Plan.NewTransitionEdgeCount);+ Assert.Equal(0, result.Plan.CornerPatchCount);+ Assert.True(result.Plan.CornerPatchesDeferred);+ Assert.False(result.Plan.GeometryEmissionPerformed);+ Assert.DoesNotContain(result.Diagnostics, d => d.Contains("3d-boolean", StringComparison.OrdinalIgnoreCase) && !d.Contains("no-3d-boolean-used", StringComparison.Ordinal));+ }++ [Theory]+ [InlineData("convex-planar-unsafe-envelope", "reject-unsafe-offset-envelope")]+ [InlineData("invalid-distance", "reject-invalid-distance")]+ [InlineData("invalid-edge", "reject-invalid-edge")]+ [InlineData("invalid-face-adjacency", "reject-invalid-face-adjacency")]+ [InlineData("ambiguous-classification", "reject-ambiguous-classification")]+ [InlineData("edge-chain", "defer-edge-chain-policy")]+ [InlineData("corner-chain", "defer-corner-policy")]+ [InlineData("triangle-legacy-dependent", "fallback-legacy-chamfer")]+ public void InvalidOrDeferredCases_StopBeforePlan(string caseName, string expectedDecision)+ {+ var result = AirChamferTopologyPlanLab.Evaluate(AirChamferTopologyPlanLab.Cases().Single(x => x.CaseName == caseName));+ Assert.Equal(expectedDecision, result.Decision);+ Assert.Null(result.Plan);+ }++ [Fact]+ public void ConcaveCasesRemainAcceptedByPolicy()+ {+ var concave = AirChamferPolicyLab.Evaluate(AirChamferPolicyLab.Cases().Single(x => x.CaseName == "canonical-concave-planar"));+ Assert.Equal("accept-air-chamfer-patch", concave.Decision.Decision);+ }++ [Fact]+ public void Recommendations_AreFiniteAndDeterministic()+ {+ var rows = AirChamferTopologyPlanLab.RunAll();+ foreach (var row in rows)+ Assert.Contains(row.Recommendation, AirChamferTopologyPlanLab.AllowedRecommendations);+ }+}diff --git a/docs/edge-a0-air-edge-sweep-fillet-chamfer-audit.md b/docs/edge-a0-air-edge-sweep-fillet-chamfer-audit.mdindex 4875be19..27c5fb93 100644--- a/docs/edge-a0-air-edge-sweep-fillet-chamfer-audit.md+++ b/docs/edge-a0-air-edge-sweep-fillet-chamfer-audit.md@@ -263,3 +263,5 @@ Each future `AirEdgeSweep` PR should include:A lab-only constructive concave planar AirChamfer patch proof was added in EDGE-X2 (`docs/frictionlab/edge-x2-concave-planar-chamfer-patch-lab.md`) without production chamfer/fillet migration.- EDGE-X2.1 introduces a lab-only AirChamfer policy scaffold to gate admissibility/route decisions before broader geometry work.++- EDGE-X4 update: convex planar single-edge requests can now produce a lab-only replacement topology plan after Judgment admission; production geometry emission remains deferred.diff --git a/docs/frictionlab/edge-x3-convex-planar-air-chamfer-judgment-policy-lab.md b/docs/frictionlab/edge-x3-convex-planar-air-chamfer-judgment-policy-lab.mdindex 604ef346..1e4e5457 100644--- a/docs/frictionlab/edge-x3-convex-planar-air-chamfer-judgment-policy-lab.md+++ b/docs/frictionlab/edge-x3-convex-planar-air-chamfer-judgment-policy-lab.md@@ -53,3 +53,6 @@ No production route changes, no public API changes, no STEP/Boolean changes, no## Next milestoneImplement bounded convex replacement topology planning lane (still policy-gated), then wire geometry emission only after admissibility and replacement-plan diagnostics are stable.++## EDGE-X4 follow-on note+EDGE-X4 extends this policy lab by reusing the same Judgment admission path and allowing admitted convex planar single-edge requests to produce a lab-only replacement topology plan (still no production geometry emission).diff --git a/docs/frictionlab/edge-x4-convex-planar-air-chamfer-topology-plan-lab.md b/docs/frictionlab/edge-x4-convex-planar-air-chamfer-topology-plan-lab.mdnew file mode 100644index 00000000..edcef71b--- /dev/null+++ b/docs/frictionlab/edge-x4-convex-planar-air-chamfer-topology-plan-lab.md@@ -0,0 +1,92 @@+# EDGE-X4 — Convex Planar AirChamfer Replacement Topology-Plan Lab++## Purpose and scope+EDGE-X4 adds a lab-only topology planning stage for convex planar single-edge AirChamfer requests after Judgment-backed policy admission. It deliberately stops before production BRep mutation and before convex geometry emission.++## References+- `docs/edge-a0-air-edge-sweep-fillet-chamfer-audit.md`+- `docs/frictionlab/edge-x1-chamfer-fillet-capability-matrix.md`+- `docs/frictionlab/edge-x2-concave-planar-chamfer-patch-lab.md`+- `docs/frictionlab/edge-x2-1-air-chamfer-policy-scaffold-lab.md`+- `docs/frictionlab/edge-x2-2-nonorthogonal-concave-air-chamfer-policy-patch-lab.md`+- `docs/frictionlab/edge-x3-convex-planar-air-chamfer-judgment-policy-lab.md`++## Why topology planning comes before geometry emission+Convex replacement requires coordinated edge reclassification, adjacent-face trimming, chamfer-face insertion, and endpoint transition edges. EDGE-X4 proves that this replacement intent can be modeled deterministically first, so EDGE-X5 can focus on geometry construction against a stable topology contract.++## Judgment-backed policy flow+EDGE-X4 reuses the EDGE-X3 `JudgmentEngine` policy evaluator (`AirChamferPolicyLab`). Convex requests admitted by policy previously deferred on geometry now advance to a plan decision (`plan-convex-replacement-topology`) while still preserving no-geometry-emission guarantees.++## Supported convex scope+- convex planar single edge,+- two adjacent planar faces,+- finite nonzero edge,+- finite positive distance,+- deterministic classification,+- no edge/corner chain,+- no legacy-dependent topology.++## Topology replacement plan model+`AirChamferTopologyPlan` captures:+- input entities (edge endpoints, normals, direction, distance, classification),+- replacement entities (two offset curves, one chamfer face, two transition edges),+- operation intent (trim both adjacent faces, mark original edge for replacement),+- invariant counts for single-edge convex planar replacement mode.++Expected artifact:+- target edges: 1+- offset curves: 2+- chamfer faces: 1+- transition edges: 2+- adjacent faces affected: 2+- corner patches: 0 (deferred)+- replacement mode: `single-edge-convex-planar`++## Fixture cases and outcomes+Accepted/planned:+1. canonical orthogonal convex planar single-edge case -> topology plan created.+2. non-orthogonal convex planar single-edge case -> topology plan created when policy admits.++Rejected/deferred before plan:+- unsafe offset envelope,+- invalid distance,+- invalid edge,+- invalid or missing face adjacency,+- ambiguous classification,+- edge chain,+- corner chain,+- legacy-dependent triangle/legacy route preference.++## Diagnostics contract+EDGE-X4 emits deterministic diagnostics including:+- `edge-x4-topology-plan-lab-started`+- `edge-x4-judgment-engine-used`+- `edge-x4-policy-admitted-convex-plan`+- `edge-x4-policy-rejected-before-plan:<reason>`+- `edge-x4-policy-deferred-before-plan:<reason>`+- `edge-x4-offset-curve-a-planned`+- `edge-x4-offset-curve-b-planned`+- `edge-x4-original-edge-marked-for-replacement`+- `edge-x4-adjacent-face-a-trim-planned`+- `edge-x4-adjacent-face-b-trim-planned`+- `edge-x4-chamfer-face-planned`+- `edge-x4-transition-edges-planned`+- `edge-x4-corner-patches-deferred`+- `edge-x4-topology-plan-created`+- `edge-x4-no-geometry-emission`+- `edge-x4-no-production-behavior-changed`+- `edge-x4-no-3d-boolean-used`++## Guarantees and non-goals+- No production behavior changes.+- No convex geometry emission.+- No fillet geometry.+- No edge-chain/corner-chain implementation.+- No STEP importer/exporter changes.+- No Boolean core changes.+- No triangle migration retry.+- No sketch solver/clipping/NURBS/freeform.++## Recommended next milestone+- EDGE-X5: convex planar chamfer replacement geometry artifact lab.+- If blockers appear, topology-plan hardening and policy refinement before geometry work.