Skip to content

Next Gen STEP AP242 Native-ish BREP Geometric Modeling Kernel

Add AIR-X4 top-face loop chamfer BRepPlan roles

Yuechen Li70a4e54f5c7f
diff --git a/Aetheris.Kernel.Core.Tests/Air/AirBRepPlanTests.cs b/Aetheris.Kernel.Core.Tests/Air/AirBRepPlanTests.cs
index 8887524a..60385d63 100644
--- a/Aetheris.Kernel.Core.Tests/Air/AirBRepPlanTests.cs
+++ b/Aetheris.Kernel.Core.Tests/Air/AirBRepPlanTests.cs
@@ -1,3 +1,4 @@
+using Aetheris.Kernel.Core.Air;
using Aetheris.Kernel.Core.Air.BRepPlan;
using Aetheris.Kernel.Core.Brep.Prismatic;
@@ -38,7 +39,7 @@ public sealed class AirBRepPlanTests
var b = AirPrismaticSectionTransitionBRepPlanner.Plan(CanonicalRequest()).Plan!;
Assert.Equal(a.Elements.Select(e => e.Id.Value), b.Elements.Select(e => e.Id.Value));
Assert.Equal(a.Elements.Select(e => (e.Kind, e.Role)), b.Elements.Select(e => (e.Kind, e.Role)));
- Assert.Equal(a.Summary with { Diagnostics = [], Guarantees = [] }, b.Summary with { Diagnostics = [], Guarantees = [] });
+ Assert.Equal((a.Summary.PlanKind, a.Summary.SourceAirNodeId, a.Summary.VertexCount, a.Summary.CurveCount, a.Summary.EdgeCount, a.Summary.CoedgeCount, a.Summary.LoopCount, a.Summary.SurfaceCount, a.Summary.FaceCount, a.Summary.ShellCount, a.Summary.BodyCount, a.Summary.CapFaceCount, a.Summary.SideFaceCount, a.Summary.TransitionFaceCount, a.Summary.ChamferFaceCount, a.Summary.Bounds, a.Summary.SplitPolicy), (b.Summary.PlanKind, b.Summary.SourceAirNodeId, b.Summary.VertexCount, b.Summary.CurveCount, b.Summary.EdgeCount, b.Summary.CoedgeCount, b.Summary.LoopCount, b.Summary.SurfaceCount, b.Summary.FaceCount, b.Summary.ShellCount, b.Summary.BodyCount, b.Summary.CapFaceCount, b.Summary.SideFaceCount, b.Summary.TransitionFaceCount, b.Summary.ChamferFaceCount, b.Summary.Bounds, b.Summary.SplitPolicy));
Assert.Equal(a.Summary.Diagnostics.Select(d => d.Code), b.Summary.Diagnostics.Select(d => d.Code));
Assert.Equal(a.Summary.Guarantees, b.Summary.Guarantees);
Assert.Equal(a.Diagnostics.Select(d => d.Code), b.Diagnostics.Select(d => d.Code));
@@ -81,6 +82,107 @@ public sealed class AirBRepPlanTests
Assert.Equal(AirBRepPlanKind.Unsupported, result.Validation.ExpectedTopologySummary.PlanKind);
}
+
+ [Fact]
+ public void AirTopFaceLoopChamferBRepPlanner_CanonicalCase_PreservesClassBProvenance()
+ {
+ var result = AirTopFaceLoopChamferBRepPlanner.Plan(CanonicalTopFaceLoopChamferRequest());
+ Assert.True(result.Succeeded);
+ var plan = result.Plan!;
+ Assert.Equal(AirNodeKind.TopFaceLoopChamfer, plan.FeatureContext!.SourceNodeKind);
+ Assert.Equal(AirRouteKind.TopFaceLoopChamferPrismatic, plan.FeatureContext.RouteKind);
+ Assert.Equal(AirSelectionClass.FaceBoundaryLoop, plan.FeatureContext.SelectionClass);
+ Assert.Equal(AirRuleKind.UniformChamfer, plan.FeatureContext.RuleKind);
+ Assert.Equal("SwitchMatch", plan.FeatureContext.RouteSelectionMode);
+ Assert.Contains(plan.Diagnostics, d => d.Code == "air-x4-class-b-face-boundary-loop-provenance");
+ Assert.Contains(plan.Diagnostics, d => d.Code == "air-x4-uniform-chamfer-rule-provenance");
+ Assert.Contains(plan.Diagnostics, d => d.Code == "air-x4-not-four-independent-single-edge-chamfers");
+ }
+
+ [Fact]
+ public void AirTopFaceLoopChamferBRepPlanner_CanonicalCase_MarksUpperTransitionFacesAsChamferFaces()
+ {
+ var plan = AirTopFaceLoopChamferBRepPlanner.Plan(CanonicalTopFaceLoopChamferRequest()).Plan!;
+ Assert.Equal(10, plan.Summary.FaceCount);
+ Assert.Equal(4, plan.Summary.TransitionFaceCount);
+ Assert.Equal(4, plan.Summary.ChamferFaceCount);
+ Assert.Equal(2, plan.Summary.CapFaceCount);
+ Assert.Equal(4, plan.Summary.SideFaceCount);
+ Assert.Equal(10, plan.Summary.SurfaceCount);
+ Assert.Equal(AirPrismaticSectionTransitionBRepPlanner.PreserveSectionSplits, plan.Summary.SplitPolicy);
+ var upperTransitionFaces = plan.Elements.Where(e => e.Kind == AirBRepPlanElementKind.Face && e.IntervalIndex == 1).ToArray();
+ Assert.Equal(4, upperTransitionFaces.Length);
+ Assert.All(upperTransitionFaces, f => Assert.Contains(AirBRepPlanRole.PrismaticTransitionFace, f.SemanticRoles!));
+ Assert.All(upperTransitionFaces, f => Assert.Contains(AirBRepPlanRole.ChamferFace, f.SemanticRoles!));
+ }
+
+ [Fact]
+ public void AirTopFaceLoopChamferBRepPlanner_StableIdsAndRoles_AreDeterministic()
+ {
+ var a = AirTopFaceLoopChamferBRepPlanner.Plan(CanonicalTopFaceLoopChamferRequest()).Plan!;
+ var b = AirTopFaceLoopChamferBRepPlanner.Plan(CanonicalTopFaceLoopChamferRequest()).Plan!;
+ Assert.Equal(a.Elements.Select(e => e.Id.Value), b.Elements.Select(e => e.Id.Value));
+ Assert.Equal(a.Elements.Select(e => (e.Kind, e.Role)), b.Elements.Select(e => (e.Kind, e.Role)));
+ Assert.Equal(a.Elements.Select(e => string.Join(",", e.SemanticRoles ?? [])), b.Elements.Select(e => string.Join(",", e.SemanticRoles ?? [])));
+ Assert.Equal((a.Summary.PlanKind, a.Summary.SourceAirNodeId, a.Summary.VertexCount, a.Summary.CurveCount, a.Summary.EdgeCount, a.Summary.CoedgeCount, a.Summary.LoopCount, a.Summary.SurfaceCount, a.Summary.FaceCount, a.Summary.ShellCount, a.Summary.BodyCount, a.Summary.CapFaceCount, a.Summary.SideFaceCount, a.Summary.TransitionFaceCount, a.Summary.ChamferFaceCount, a.Summary.Bounds, a.Summary.SplitPolicy), (b.Summary.PlanKind, b.Summary.SourceAirNodeId, b.Summary.VertexCount, b.Summary.CurveCount, b.Summary.EdgeCount, b.Summary.CoedgeCount, b.Summary.LoopCount, b.Summary.SurfaceCount, b.Summary.FaceCount, b.Summary.ShellCount, b.Summary.BodyCount, b.Summary.CapFaceCount, b.Summary.SideFaceCount, b.Summary.TransitionFaceCount, b.Summary.ChamferFaceCount, b.Summary.Bounds, b.Summary.SplitPolicy));
+ Assert.Equal(a.Summary.Diagnostics.Select(d => d.Code), b.Summary.Diagnostics.Select(d => d.Code));
+ Assert.Equal(a.Summary.Guarantees, b.Summary.Guarantees);
+ Assert.Equal(a.Diagnostics.Select(d => d.Code), b.Diagnostics.Select(d => d.Code));
+ Assert.Equal(a.Guarantees, b.Guarantees);
+ }
+
+ [Fact]
+ public void AirTopFaceLoopChamferBRepPlanner_PlanMatchesExistingLoopChamferSummary()
+ {
+ var request = CanonicalTopFaceLoopChamferRequest(exportStep: true);
+ var plan = AirTopFaceLoopChamferBRepPlanner.Plan(request).Plan!;
+ var emitted = AirTopFaceLoopChamferWrapper.LowerCanonicalTopFaceLoopChamfer();
+ Assert.True(emitted.Succeeded);
+ Assert.Equal(emitted.TopologySummary.VertexCount, plan.Summary.VertexCount);
+ Assert.Equal(emitted.TopologySummary.EdgeCount, plan.Summary.EdgeCount);
+ Assert.Equal(emitted.TopologySummary.FaceCount, plan.Summary.FaceCount);
+ Assert.Equal(emitted.TopologySummary.PlanarFaceCount, plan.Summary.SurfaceCount);
+ Assert.Equal(emitted.TopologySummary.LoopCount, plan.Summary.LoopCount);
+ Assert.Equal(emitted.TopologySummary.CoedgeCount, plan.Summary.CoedgeCount);
+ Assert.Equal(emitted.TopologySummary.CapFaceCount, plan.Summary.CapFaceCount);
+ Assert.Equal(emitted.TopologySummary.SideFaceCount, plan.Summary.SideFaceCount);
+ Assert.Equal(emitted.TopologySummary.TransitionFaceCount, plan.Summary.TransitionFaceCount);
+ Assert.Equal(emitted.TopologySummary.ChamferFaceCount, plan.Summary.ChamferFaceCount);
+ Assert.Equal(emitted.TopologySummary.Bounds, plan.Summary.Bounds);
+ Assert.True(emitted.StepSmokeSummary.Succeeded);
+ foreach (var guarantee in new[] { "no production route replacement", "no emitter rewrite", "no STEP exporter change", "no BRep topology behavior change", "no coplanar merge", "no AirEdgeSweep", "no BrepBoundedChamfer", "no Boolean", "no topology graft", "not four independent single-edge chamfers" })
+ Assert.Contains(plan.Guarantees, g => g == guarantee);
+ }
+
+ [Theory]
+ [MemberData(nameof(InvalidTopFaceLoopChamferContexts))]
+ public void AirTopFaceLoopChamferBRepPlanner_InvalidFeatureContext_RejectedOrDeferred(object contextObject, string expectedCode)
+ {
+ var context = Assert.IsType<AirBRepPlanFeatureContext>(contextObject);
+ var result = AirTopFaceLoopChamferBRepPlanner.Plan(CanonicalTopFaceLoopChamferRequest(), context);
+ Assert.False(result.Succeeded);
+ Assert.Null(result.Plan);
+ Assert.Contains(result.Validation.Diagnostics, d => d.Code == expectedCode);
+ }
+
+ [Fact]
+ public void AirPrismaticSectionTransitionBRepPlanner_PurePrismatic_DoesNotClaimChamferFaces()
+ {
+ var plan = AirPrismaticSectionTransitionBRepPlanner.Plan(CanonicalRequest()).Plan!;
+ Assert.Equal(0, plan.Summary.ChamferFaceCount);
+ Assert.Equal(4, plan.Summary.TransitionFaceCount);
+ Assert.DoesNotContain(plan.Elements, e => (e.SemanticRoles ?? []).Contains(AirBRepPlanRole.ChamferFace));
+ }
+
+ public static IEnumerable<object[]> InvalidTopFaceLoopChamferContexts()
+ {
+ var canonical = AirTopFaceLoopChamferBRepPlanner.CanonicalFeatureContext();
+ yield return [canonical with { SelectionClass = AirSelectionClass.SingleEdge }, "air-x4-non-face-boundary-loop-rejected"];
+ yield return [canonical with { RuleKind = AirRuleKind.ConstantRadiusFillet }, "air-x4-non-uniform-chamfer-rule-rejected"];
+ yield return [canonical with { RouteKind = AirRouteKind.PrismaticSectionTransitionEmitter }, "air-x4-non-prismatic-lowering-deferred"];
+ yield return [canonical with { SourceNodeKind = AirNodeKind.PrismaticSectionTransition }, "air-x4-missing-loop-chamfer-provenance-rejected"];
+ }
+
public static IEnumerable<object[]> InvalidRequests()
{
yield return [new PrismaticSectionTransitionRequest([new(0, [(-1d, -1d), (1d, -1d), (1d, 1d)])], PrismaticCorrespondenceMap.Identity(3)), "air-x3-invalid-section-count-rejected"];
@@ -91,6 +193,8 @@ public sealed class AirBRepPlanTests
yield return [new PrismaticSectionTransitionRequest([new(0, [(-1d, -1d), (1d, -1d), (1d, 1d)]), new(1, [(-1d, -1d), (1d, -1d), (1d, 1d)]), new(2, [(-1d, -1d), (1d, -1d), (1d, 1d)])], new PrismaticCorrespondenceMap([1, 2, 0])), "air-x3-non-identity-correspondence-deferred"];
}
+ private static PrismaticTopFaceLoopChamferRequest CanonicalTopFaceLoopChamferRequest(bool exportStep = false) => new(10, 8, 6, 1, ExportStep: exportStep);
+
private static PrismaticSectionTransitionRequest CanonicalRequest(bool runStepSmoke = false) => new(
[
new(0, [(-5, -4), (5, -4), (5, 4), (-5, 4)]),
diff --git a/Aetheris.Kernel.Core/Air/AirBRepPlan.cs b/Aetheris.Kernel.Core/Air/AirBRepPlan.cs
index ab2a894b..1a7a9577 100644
--- a/Aetheris.Kernel.Core/Air/AirBRepPlan.cs
+++ b/Aetheris.Kernel.Core/Air/AirBRepPlan.cs
@@ -22,7 +22,8 @@ internal sealed record AirBRepPlanElement(
int? IntervalIndex = null,
int? EdgeIndex = null,
string? FaceRole = null,
- IReadOnlyList<AirDiagnostic>? Diagnostics = null);
+ IReadOnlyList<AirDiagnostic>? Diagnostics = null,
+ IReadOnlyList<AirBRepPlanRole>? SemanticRoles = null);
internal sealed record AirBRepPlanSummary(
AirBRepPlanKind PlanKind,
@@ -43,7 +44,17 @@ internal sealed record AirBRepPlanSummary(
string Bounds,
string SplitPolicy,
IReadOnlyList<AirDiagnostic> Diagnostics,
- IReadOnlyList<string> Guarantees);
+ IReadOnlyList<string> Guarantees,
+ AirBRepPlanFeatureContext? FeatureContext = null);
+
+internal sealed record AirBRepPlanFeatureContext(
+ AirNodeKind SourceNodeKind,
+ AirRouteKind RouteKind,
+ AirSelectionClass SelectionClass,
+ AirRuleKind RuleKind,
+ string ConstructionHistoryKind,
+ string RouteSelectionMode,
+ IReadOnlyList<string> Notes);
internal sealed record AirBRepPlanValidationResult(
bool Succeeded,
@@ -61,7 +72,8 @@ internal sealed record AirBRepPlan(
IReadOnlyList<AirBRepPlanElement> Elements,
AirBRepPlanSummary Summary,
IReadOnlyList<AirDiagnostic> Diagnostics,
- IReadOnlyList<string> Guarantees);
+ IReadOnlyList<string> Guarantees,
+ AirBRepPlanFeatureContext? FeatureContext = null);
internal sealed record AirBRepPlanResult(AirBRepPlan? Plan, AirBRepPlanValidationResult Validation)
{
@@ -150,7 +162,7 @@ internal static class AirPrismaticSectionTransitionBRepPlanner
e.Add(E("body:0", AirBRepPlanElementKind.Body, AirBRepPlanRole.Body)); diagnostics.Add(D("air-x3-body-planned"));
diagnostics.Add(D("air-x3-stable-planned-ids-created"));
return e;
- AirBRepPlanElement E(string id, AirBRepPlanElementKind kind, AirBRepPlanRole role, int? section = null, int? vertex = null, int? interval = null, int? edge = null, string? faceRole = null) => new(new AirBRepPlanId(id), kind, role, sourceAirNodeId, provenance, section, vertex, interval, edge, faceRole, []);
+ AirBRepPlanElement E(string id, AirBRepPlanElementKind kind, AirBRepPlanRole role, int? section = null, int? vertex = null, int? interval = null, int? edge = null, string? faceRole = null) => new(new AirBRepPlanId(id), kind, role, sourceAirNodeId, provenance, section, vertex, interval, edge, faceRole, [], role == AirBRepPlanRole.TransitionFace ? [AirBRepPlanRole.PrismaticTransitionFace] : [role]);
}
private static AirBRepPlanSummary Summary(PrismaticSectionTransitionRequest request, string sourceAirNodeId, IReadOnlyList<AirDiagnostic> diagnostics, IReadOnlyList<string> guarantees)
@@ -174,3 +186,118 @@ internal static class AirPrismaticSectionTransitionBRepPlanner
private static AirDiagnostic D(string code, AirDiagnosticSeverity severity = AirDiagnosticSeverity.Info) => new(code, severity, code);
private static IReadOnlyList<AirDiagnostic> Stable(IEnumerable<AirDiagnostic> d) => d.GroupBy(x => x.Code).Select(g => g.First()).OrderBy(x => x.Code, StringComparer.Ordinal).ToArray();
}
+
+internal static class AirTopFaceLoopChamferBRepPlanner
+{
+ public static AirBRepPlanResult Plan(
+ PrismaticTopFaceLoopChamferRequest request,
+ AirBRepPlanFeatureContext? featureContext = null,
+ string sourceAirNodeId = "air-x4-top-face-loop-chamfer-canonical")
+ {
+ featureContext ??= CanonicalFeatureContext();
+ var diagnostics = new List<AirDiagnostic> { D("air-x4-top-face-loop-chamfer-brep-plan-created") };
+ var rejected = ValidateFeatureContext(featureContext);
+ if (rejected is not null)
+ return Reject(sourceAirNodeId, diagnostics, rejected);
+
+ var selection = request.Selection ?? new FaceLoopChamferSelection();
+ rejected = ValidateRequest(request, selection);
+ if (rejected is not null)
+ return Reject(sourceAirNodeId, diagnostics, rejected);
+
+ var provenance = new AirProvenance(
+ "AIR-X4",
+ "Constructive AIR BRepPlan feature role overlay",
+ "canonical-top-face-loop-chamfer",
+ sourceAirNodeId,
+ nameof(AirRouteKind.TopFaceLoopChamferPrismatic),
+ AirSelectionClass.FaceBoundaryLoop,
+ AirRuleKind.UniformChamfer,
+ "generated/history-known",
+ false,
+ ["Class B face-boundary loop uniform chamfer lowered through the prismatic section-transition plan.", "not-four-independent-single-edge-chamfers"]);
+
+ var prismatic = AirPrismaticSectionTransitionBRepPlanner.Plan(
+ new PrismaticSectionTransitionRequest(PrismaticTopFaceLoopChamferPrototype.CreateSectionStack(request), PrismaticCorrespondenceMap.Identity(4), new PrismaticSectionTransitionOptions(RunStepSmoke: request.ExportStep, TraceLabel: "air-x4-top-face-loop-chamfer-brep-plan")),
+ sourceAirNodeId,
+ provenance);
+ if (!prismatic.Succeeded || prismatic.Plan is null)
+ return prismatic;
+
+ diagnostics.AddRange(prismatic.Diagnostics());
+ diagnostics.AddRange(new[]
+ {
+ D("air-x4-feature-role-overlay-applied"),
+ D("air-x4-class-b-face-boundary-loop-provenance"),
+ D("air-x4-uniform-chamfer-rule-provenance"),
+ D("air-x4-upper-transition-faces-marked-chamfer"),
+ D("air-x4-not-four-independent-single-edge-chamfers"),
+ D("air-x4-prismatic-plan-reused"),
+ D("air-x4-plan-matches-existing-loop-chamfer-emitter"),
+ D("air-x4-split-preserving-plan"),
+ D("air-x4-no-production-route-replacement"),
+ D("air-x4-no-emitter-rewrite"),
+ D("air-x4-no-step-exporter-change"),
+ D("air-x4-no-brep-topology-change"),
+ D("air-x4-no-coplanar-merge"),
+ D("air-x4-no-air-edge-sweep"),
+ D("air-x4-no-brep-bounded-chamfer"),
+ D("air-x4-no-boolean"),
+ D("air-x4-no-topology-graft"),
+ });
+
+ var elements = prismatic.Plan.Elements.Select(e =>
+ e.Kind == AirBRepPlanElementKind.Face && e.IntervalIndex == 1 && e.Role == AirBRepPlanRole.TransitionFace
+ ? e with { SemanticRoles = StableRoles((e.SemanticRoles ?? []).Concat([AirBRepPlanRole.PrismaticTransitionFace, AirBRepPlanRole.ChamferFace])), FaceRole = "top-face-loop-chamfer" }
+ : e).ToArray();
+ var chamferFaceCount = elements.Count(e => e.Kind == AirBRepPlanElementKind.Face && (e.SemanticRoles ?? []).Contains(AirBRepPlanRole.ChamferFace));
+ if (chamferFaceCount != 4)
+ return Reject(sourceAirNodeId, diagnostics, D("air-x4-plan-overlay-mismatch-rejected", AirDiagnosticSeverity.Error));
+
+ var guarantees = StableStrings(prismatic.Plan.Guarantees.Concat(["no BrepBoundedChamfer", "not four independent single-edge chamfers"])).ToArray();
+ diagnostics = StableDiagnostics(diagnostics).ToList();
+ var summary = prismatic.Plan.Summary with { ChamferFaceCount = chamferFaceCount, Diagnostics = diagnostics, Guarantees = guarantees, FeatureContext = featureContext };
+ var plan = prismatic.Plan with { Elements = elements, Summary = summary, Diagnostics = diagnostics, Guarantees = guarantees, FeatureContext = featureContext };
+ return new AirBRepPlanResult(plan, new AirBRepPlanValidationResult(true, diagnostics, [], [], summary));
+ }
+
+ public static AirBRepPlanFeatureContext CanonicalFeatureContext() => new(
+ AirNodeKind.TopFaceLoopChamfer,
+ AirRouteKind.TopFaceLoopChamferPrismatic,
+ AirSelectionClass.FaceBoundaryLoop,
+ AirRuleKind.UniformChamfer,
+ "generated/history-known",
+ "SwitchMatch",
+ ["not-four-independent-single-edge-chamfers"]);
+
+ private static AirDiagnostic? ValidateFeatureContext(AirBRepPlanFeatureContext context)
+ {
+ if (context.SourceNodeKind != AirNodeKind.TopFaceLoopChamfer) return D("air-x4-missing-loop-chamfer-provenance-rejected", AirDiagnosticSeverity.Error);
+ if (context.SelectionClass != AirSelectionClass.FaceBoundaryLoop) return D("air-x4-non-face-boundary-loop-rejected", AirDiagnosticSeverity.Error);
+ if (context.RuleKind != AirRuleKind.UniformChamfer) return D("air-x4-non-uniform-chamfer-rule-rejected", AirDiagnosticSeverity.Error);
+ if (context.RouteKind != AirRouteKind.TopFaceLoopChamferPrismatic) return D("air-x4-non-prismatic-lowering-deferred", AirDiagnosticSeverity.Warning);
+ return null;
+ }
+
+ private static AirDiagnostic? ValidateRequest(PrismaticTopFaceLoopChamferRequest request, FaceLoopChamferSelection selection)
+ {
+ if (selection.SelectionKind != FaceLoopChamferSelectionKind.FaceBoundaryLoop) return D("air-x4-non-face-boundary-loop-rejected", AirDiagnosticSeverity.Error);
+ if (request.Rule != FaceLoopChamferRuleKind.UniformSymmetric) return D("air-x4-non-uniform-chamfer-rule-rejected", AirDiagnosticSeverity.Error);
+ if (selection.OwningFace != FaceLoopChamferOwningFaceKind.TopCap || selection.LoopKind != FaceLoopChamferLoopKind.Outer) return D("air-x4-non-top-face-loop-deferred", AirDiagnosticSeverity.Warning);
+ return null;
+ }
+
+ private static AirBRepPlanResult Reject(string sourceAirNodeId, List<AirDiagnostic> diagnostics, AirDiagnostic error)
+ {
+ diagnostics.Add(error);
+ diagnostics = StableDiagnostics(diagnostics).ToList();
+ var summary = new AirBRepPlanSummary(AirBRepPlanKind.Unsupported, sourceAirNodeId, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "none", AirPrismaticSectionTransitionBRepPlanner.PreserveSectionSplits, diagnostics, []);
+ return new AirBRepPlanResult(null, new AirBRepPlanValidationResult(false, diagnostics, error.Severity == AirDiagnosticSeverity.Error ? [error] : [], error.Severity == AirDiagnosticSeverity.Warning ? [error] : [], summary));
+ }
+
+ private static AirDiagnostic D(string code, AirDiagnosticSeverity severity = AirDiagnosticSeverity.Info) => new(code, severity, code);
+ private static IReadOnlyList<AirDiagnostic> StableDiagnostics(IEnumerable<AirDiagnostic> d) => d.GroupBy(x => x.Code).Select(g => g.First()).OrderBy(x => x.Code, StringComparer.Ordinal).ToArray();
+ private static IReadOnlyList<AirBRepPlanRole> StableRoles(IEnumerable<AirBRepPlanRole> roles) => roles.Distinct().OrderBy(r => r.ToString(), StringComparer.Ordinal).ToArray();
+ private static IEnumerable<string> StableStrings(IEnumerable<string> values) => values.Distinct(StringComparer.Ordinal).OrderBy(x => x, StringComparer.Ordinal);
+ private static IEnumerable<AirDiagnostic> Diagnostics(this AirBRepPlanResult result) => result.Plan?.Diagnostics ?? result.Validation.Diagnostics;
+}
diff --git a/docs/air-a0-aetheris-v2-compiler-ir-constitution.md b/docs/air-a0-aetheris-v2-compiler-ir-constitution.md
index d7732b9b..c06c8a7a 100644
--- a/docs/air-a0-aetheris-v2-compiler-ir-constitution.md
+++ b/docs/air-a0-aetheris-v2-compiler-ir-constitution.md
@@ -748,3 +748,8 @@ AIR-X2 adds an internal route-selection/admissibility layer ahead of AIR-X1 wrap
## AIR-X3 status note
AIR-X3 adds the first minimal internal BRepPlan proof for `AirPrismaticSectionTransition`. The plan sits between Constructive AIR and the existing prismatic BRep emitter, records deterministic planned IDs, topology roles, expected counts, split policy, provenance, diagnostics, and guarantees, and does not change production routes, BRep topology behavior, CIR authority, Firmament lowering, or STEP/export authority.
+
+
+## AIR-X4 status note
+
+AIR-X4 adds feature-role-aware BRepPlan evidence for the Class B top-face loop chamfer lane. It preserves AIR-A0 authority boundaries: AIR remains constructive MIR, BRepPlan remains a non-materializing backend plan, BRep remains explicit topology/export authority, CIR remains a side-channel, and STEP remains serialization.
diff --git a/docs/air-x1-minimal-air-wrappers-for-proven-lanes.md b/docs/air-x1-minimal-air-wrappers-for-proven-lanes.md
index 567fd45d..45b5ef20 100644
--- a/docs/air-x1-minimal-air-wrappers-for-proven-lanes.md
+++ b/docs/air-x1-minimal-air-wrappers-for-proven-lanes.md
@@ -79,3 +79,8 @@ AIR-X2 now records deterministic route decisions for the AIR-X1 wrapper lanes. P
## AIR-X3 BRepPlan note
AIR-X1 wrappers remain thin envelopes around proven lanes. AIR-X3 adds a non-production, internal/test-visible BRepPlan for the canonical prismatic section transition lane, but it does not replace the AIR-X1 wrapper or the existing emitter path.
+
+
+## AIR-X4 top-face loop chamfer BRepPlan role note
+
+The AIR-X1 top-face loop chamfer wrapper remains the existing proven lane. AIR-X4 adds a non-production BRepPlan wrapper that reuses the prismatic plan and records Class B provenance plus chamfer semantic roles for upper transition faces without replacing this wrapper.
diff --git a/docs/air-x2-route-selection-and-admissibility.md b/docs/air-x2-route-selection-and-admissibility.md
index 7714c996..62991754 100644
--- a/docs/air-x2-route-selection-and-admissibility.md
+++ b/docs/air-x2-route-selection-and-admissibility.md
@@ -68,3 +68,8 @@ Recommended next milestone: AIR-X3 JudgmentUtility integration for one contested
## AIR-X3 direct-route BRepPlan proof
AIR-X3 proves that the direct `AirPrismaticSectionTransition` route can produce a planned topology summary before invoking the existing emitter. Route selection behavior is unchanged: direct selection remains appropriate for this named constructive route, and JudgmentUtility remains deferred.
+
+
+## AIR-X4 evidence note
+
+The AIR-X2 switch/match-selected `TopFaceLoopChamferPrismatic` route now has AIR-X4 BRepPlan evidence carrying `FaceBoundaryLoop`, `UniformChamfer`, `SwitchMatch`, and not-four-independent-single-edge-chamfers provenance. Route selection and JudgmentUtility behavior are unchanged.
diff --git a/docs/air-x3-brep-plan-prismatic-section-transition.md b/docs/air-x3-brep-plan-prismatic-section-transition.md
index f75c26a3..1230f0dd 100644
--- a/docs/air-x3-brep-plan-prismatic-section-transition.md
+++ b/docs/air-x3-brep-plan-prismatic-section-transition.md
@@ -88,3 +88,8 @@ Focused AIR-X3 tests validate canonical plan counts and diagnostics, determinist
## Recommended next milestone
Recommended next milestone: **AIR-X4 — BRepPlan roles/provenance for top-face loop chamfer**. AIR-X3 showed that the pure prismatic transition can preserve structural roles and match emitted topology without production changes; the next useful increment is preserving Class B `FaceBoundaryLoop` / `UniformChamfer` provenance and marking the four upper transition faces as `ChamferFace` in a similarly non-production plan.
+
+
+## AIR-X4 extension note
+
+AIR-X4 extends this prismatic BRepPlan through a feature role overlay rather than duplicating the planner. The top-face loop chamfer wrapper preserves primary prismatic transition roles and adds `ChamferFace` semantic roles to upper transition faces only when the feature context is the Class B top-face loop chamfer.
diff --git a/docs/air-x4-brep-plan-top-face-loop-chamfer-roles.md b/docs/air-x4-brep-plan-top-face-loop-chamfer-roles.md
new file mode 100644
index 00000000..e15af13e
--- /dev/null
+++ b/docs/air-x4-brep-plan-top-face-loop-chamfer-roles.md
@@ -0,0 +1,97 @@
+# AIR-X4 — BRepPlan roles/provenance for top-face loop chamfer
+
+## Purpose and scope
+
+AIR-X4 extends the AIR-X3 BRepPlan layer so the proven Class B top-face boundary-loop uniform chamfer lane can preserve feature-specific roles and provenance while still reusing the prismatic section-transition plan and existing emitter path.
+
+This is a planning/provenance milestone only. It is not a production route replacement, geometry rewrite, new emitter, STEP exporter milestone, topology rewrite, CIR mirror change, Firmament lowering change, Boolean change, AirEdgeSweep change, or BrepBoundedChamfer/BrepBoundedFillet change.
+
+## Relationship to AIR-A0/AIR-X1/AIR-X2/AIR-X3
+
+AIR-A0 defines Aetheris as a compiler for BRep: Firmament is source intent, AIR is constructive geometry MIR, BRepPlan is the backend topology emission plan, BRep is explicit topology/export authority, CIR is an evaluation side-channel, and STEP is serialization rather than construction truth.
+
+AIR-X1 introduced thin AIR wrappers around proven lanes, including top-face loop chamfer, without replacing production routes.
+
+AIR-X2 selected the top-face loop chamfer route by switch/match classification as a Class B `FaceBoundaryLoop` `UniformChamfer` routed to `TopFaceLoopChamferPrismatic`.
+
+AIR-X3 introduced the prismatic section-transition BRepPlan for planned topology IDs, roles, provenance, summaries, validation, diagnostics, and guarantees without materializing BRep.
+
+AIR-X4 layers feature role/provenance information over that prismatic BRepPlan rather than duplicating the whole planner.
+
+## Why feature roles matter
+
+A pure prismatic section transition and a top-face loop chamfer can have the same topology count family. That does not make them the same feature. The upper interval faces in the chamfer lane are simultaneously prismatic transition faces and chamfer faces, and the plan must not collapse the feature into four independent single-edge chamfers.
+
+## Top-face loop chamfer feature context
+
+The AIR-X4 feature context records:
+
+- source AIR node kind: `TopFaceLoopChamfer`;
+- route: `TopFaceLoopChamferPrismatic`;
+- route selection mode: `SwitchMatch`;
+- selection class: `FaceBoundaryLoop`;
+- rule kind: `UniformChamfer`;
+- construction history: `generated/history-known`;
+- note: `not-four-independent-single-edge-chamfers`.
+
+## BRepPlan role overlay / wrapper design
+
+AIR-X4 adds a dedicated `AirTopFaceLoopChamferBRepPlanner` wrapper around `AirPrismaticSectionTransitionBRepPlanner`. The wrapper validates the feature context, builds the canonical prismatic section stack through the existing top-face loop chamfer prototype helper, obtains the AIR-X3 prismatic BRepPlan, and applies a minimal semantic role overlay to the upper transition face elements.
+
+The existing primary role remains `TransitionFace`. The semantic role list records both `PrismaticTransitionFace` and `ChamferFace` on upper transition faces. This avoids a broad role-inference engine while preserving both topology-family and feature meaning.
+
+## Canonical geometry and expected planned topology
+
+Canonical dimensions are width `10`, depth `8`, height `6`, and chamfer distance `1`.
+
+The section stack is:
+
+- `z0 = 0`: `(-5,-4)`, `(5,-4)`, `(5,4)`, `(-5,4)`;
+- `z1 = 5`: `(-5,-4)`, `(5,-4)`, `(5,4)`, `(-5,4)`;
+- `z2 = 6`: `(-4,-3)`, `(4,-3)`, `(4,3)`, `(-4,3)`.
+
+Expected planned topology is the AIR-X3 canonical count family: 12 vertices, 12 section edges, 8 transition edges, 20 total edges, 10 faces, 2 cap faces, 4 lower side faces, 4 upper transition/chamfer faces, 10 loops, 40 coedges, one shell, one body, 10 planar faces, no cylindrical faces, bounds `[-5,-4,0]..[5,4,6]`, and split policy `preserve-section-splits`.
+
+## Chamfer-face role assignment
+
+Only feature-context-backed top-face loop chamfer planning marks upper transition faces as chamfer faces. Pure prismatic planning continues to report zero chamfer faces.
+
+## Provenance and guarantees
+
+The AIR-X4 plan records the not-four-independent-single-edge-chamfers guarantee and route exclusions:
+
+- no AirEdgeSweep;
+- no BrepBoundedChamfer;
+- no Boolean;
+- no topology graft;
+- no coplanar merge;
+- no production route replacement;
+- no emitter rewrite;
+- no STEP exporter change;
+- no BRep topology behavior change.
+
+## Comparison against existing loop chamfer wrapper/prototype
+
+The focused tests compare the AIR-X4 plan summary against the existing AIR-X1 wrapper/prototype summary. Counts, bounds, chamfer transition face count, and STEP smoke remain supplied by the existing wrapper/emitter path rather than by BRepPlan materialization.
+
+## Invalid/rejected/deferred feature contexts
+
+The wrapper rejects or defers deterministic invalid contexts:
+
+- missing/non-top-face-loop provenance: `air-x4-missing-loop-chamfer-provenance-rejected`;
+- non-`FaceBoundaryLoop` selection: `air-x4-non-face-boundary-loop-rejected`;
+- non-`UniformChamfer` rule: `air-x4-non-uniform-chamfer-rule-rejected`;
+- non-`TopFaceLoopChamferPrismatic` route: `air-x4-non-prismatic-lowering-deferred`;
+- non-top-face loop requests when representable: `air-x4-non-top-face-loop-deferred`.
+
+## Non-goals
+
+AIR-X4 does not change production routing, emitters, STEP exporter/importer, BRep topology behavior, route selection/JudgmentUtility behavior, CIR mirror behavior, Firmament lowering, Boolean behavior, AirEdgeSweep behavior, BrepBoundedChamfer/BrepBoundedFillet behavior, chamfer/fillet/shell geometry, arbitrary graph support, import/recovery, triangle migration, or NURBS/freeform behavior.
+
+## Tests run
+
+- `dotnet test Aetheris.Kernel.Core.Tests/Aetheris.Kernel.Core.Tests.csproj --filter "AirTopFaceLoopChamferBRepPlanner|AirPrismaticSectionTransitionBRepPlanner_PurePrismatic" -v:minimal`
+
+## Recommended next milestone
+
+Recommended: **AIR-X5 — BRepPlan materialization adapter for prismatic transition, still non-production**. AIR-X4 showed that roles/provenance can be layered without changing production emitters; the next useful evidence is a non-production adapter that consumes these plans while preserving BRep as topology authority and keeping production routes untouched.
diff --git a/docs/edge-a3-edge-finish-selection-taxonomy.md b/docs/edge-a3-edge-finish-selection-taxonomy.md
index 00dac57c..5851bffc 100644
--- a/docs/edge-a3-edge-finish-selection-taxonomy.md
+++ b/docs/edge-a3-edge-finish-selection-taxonomy.md
@@ -365,3 +365,8 @@ AIR-X1 records the top-face outer-loop chamfer proof as internal AIR metadata wi
## AIR-X2 evidence note
AIR-X2 provides route-selection evidence for Class B face-boundary-loop uniform chamfer by admitting the `TopFaceLoopChamferPrismatic` AIR-X1 wrapper through switch/match classification. It also records stable rejection for arbitrary-graph uniform chamfer as unsupported in AIR-X2.
+
+
+## AIR-X4 Class B planning note
+
+For Class B top-face boundary-loop uniform chamfers, AIR-X4 preserves selection metadata into BRepPlan feature context and marks upper transition faces with chamfer semantic roles. This does not change edge-finish selection or production routing.
diff --git a/docs/frictionlab/edge-loop-x2-top-face-loop-chamfer-corpus.md b/docs/frictionlab/edge-loop-x2-top-face-loop-chamfer-corpus.md
index e19a2203..f2778db3 100644
--- a/docs/frictionlab/edge-loop-x2-top-face-loop-chamfer-corpus.md
+++ b/docs/frictionlab/edge-loop-x2-top-face-loop-chamfer-corpus.md
@@ -218,3 +218,8 @@ AIR-X1 adds an internal `TopFaceLoopChamfer` AIR wrapper around the existing `Pr
## AIR-X2 route-selection note
AIR-X2 can select the top-face loop chamfer wrapper through deterministic switch/match policy for `FaceBoundaryLoop + UniformChamfer + history-known top-face loop`. This is route-decision evidence only; it does not change the corpus writer or production geometry routes.
+
+
+## AIR-X4 BRepPlan mapping note
+
+AIR-X4 maps the corpus chamfer transition faces into BRepPlan `ChamferFace` semantic roles while preserving the existing prismatic/top-face loop chamfer emitter summaries and corpus expectations.