Next Gen STEP AP242 Native-ish BREP Geometric Modeling Kernel
Anchor Firmament Box stock and hole features to bottom Z=0
Yuechen Lib560994ea1f6
diff --git a/Aetheris.CLI.Tests/ChamferM6FixturePipelineTests.cs b/Aetheris.CLI.Tests/ChamferM6FixturePipelineTests.csindex a055aa94..594b9cf8 100644--- a/Aetheris.CLI.Tests/ChamferM6FixturePipelineTests.cs+++ b/Aetheris.CLI.Tests/ChamferM6FixturePipelineTests.cs@@ -53,8 +53,9 @@ public sealed class ChamferM6FixturePipelineTests}[Theory]- [InlineData("air-hole-entry-chamfer.valid.firmament", 6, 5)]- [InlineData("air-hole-entry-chamfer-variant.valid.firmament", 4.5, 4.25)]+ // Entry geometry is expressed in the Box stock frame: Bottom=Z0 and Top=Z12.+ [InlineData("air-hole-entry-chamfer.valid.firmament", 6, 11)]+ [InlineData("air-hole-entry-chamfer-variant.valid.firmament", 4.5, 9.25)]public void InternalHoleEntryFixture_UsesProfileStackAndContainsRealConeAndShaft(string fixture, double shaftDiameter, double transitionZ){var built = BuildFixture(fixture);diff --git a/Aetheris.CLI/CliRunner.cs b/Aetheris.CLI/CliRunner.csindex edcbcecc..db85fe99 100644--- a/Aetheris.CLI/CliRunner.cs+++ b/Aetheris.CLI/CliRunner.cs@@ -1792,6 +1792,7 @@ Model CanonicalPanel {sourceDeclaration = new { kind = "Hole<Shaft>", featureId = hole.HoleId, sourceSpan = hole.Evidence?.SourceSpan },boundPlacement = hole.Evidence is null ? null : new { kind = hole.Evidence.PlacementKind, hole.Evidence.ConstructionPlaneId, hole.Evidence.SourceConceptPlaneId, hole.Evidence.LocalCenter },airPlacement = hole.Evidence is null ? null : new { kind = hole.Evidence.PlacementKind == "ConstructionPlane" ? "AirConstructionPlaneHolePlacement" : "AirFaceLocalHolePlacement", featureId = hole.Evidence.FeatureId, hole.Evidence.ConstructionPlaneId, hole.Evidence.LocalCenter },+ stockFrame = hole.Evidence?.StockFrame,plan = hole.Evidence?.PlanId is null ? null : new { kind = "LocalFrameHoleBRepPlan", stableId = hole.Evidence.PlanId, hostInterval = hole.Evidence.HostInterval },holeContract = hole.Evidence?.Contract is null ? null : new{diff --git a/Aetheris.Kernel.Firmament.Tests/FirmamentV2SemanticHoleTests.cs b/Aetheris.Kernel.Firmament.Tests/FirmamentV2SemanticHoleTests.csindex 433fdfba..610da444 100644--- a/Aetheris.Kernel.Firmament.Tests/FirmamentV2SemanticHoleTests.cs+++ b/Aetheris.Kernel.Firmament.Tests/FirmamentV2SemanticHoleTests.cs@@ -6,6 +6,38 @@ namespace Aetheris.Kernel.Firmament.Tests;public sealed class FirmamentV2SemanticHoleTests{+ [Fact]+ public void CounterboreStockFrame_IsBottomAnchored()+ {+ const string source = """+ Model Mount {+ Units: mm+ Box Body { Size: [60mm,40mm,12mm] }+ Modify Body { Hole<Counterbore> Mount { On: +Z; Center: Point2(0mm,0mm); Diameter: 6mm; CounterboreDiameter: 12mm; CounterboreDepth: 4mm; End: ThroughAll } }+ }+ """;+ var parsed = FirmamentV2Parser.Parse(source);+ Assert.True(parsed.IsSuccess, string.Join(" | ", parsed.Diagnostics));++ var frame = FirmamentStockFrame.ForBox(60, 40, 12);+ var feature = Assert.Single(FirmamentV2SemanticHoleLowering.LowerSemanticHoles(parsed.Document!));+ var materialized = AirHoleSimpleShaftMaterializer.Execute(feature, frame.CreateHoleHost());++ Assert.True(materialized.Succeeded, string.Join(" | ", materialized.Diagnostics));+ Assert.Equal(0d, materialized.Plan!.Host.ZMin, 9);+ Assert.Equal(12d, materialized.Plan.Host.ZMax, 9);+ Assert.Equal("FirmamentBoxBottomAnchoredV2", frame.Authority);+ Assert.Equal(0d, frame.ZMin, 9);+ Assert.Equal(12d, frame.ZMax, 9);+ var z = materialized.Body!.Topology.Vertices.Select(vertex =>+ {+ Assert.True(materialized.Body.TryGetVertexPoint(vertex.Id, out var point));+ return point.Z;+ }).ToArray();+ Assert.Equal(0d, z.Min(), 9);+ Assert.Equal(12d, z.Max(), 9);+ }+[Fact]public void FirmamentV2SemanticHole_ParsesShaftCounterboreCountersink(){diff --git a/Aetheris.Kernel.Firmament/Execution/FirmamentPrimitiveExecutor.cs b/Aetheris.Kernel.Firmament/Execution/FirmamentPrimitiveExecutor.csindex b7039248..c632f482 100644--- a/Aetheris.Kernel.Firmament/Execution/FirmamentPrimitiveExecutor.cs+++ b/Aetheris.Kernel.Firmament/Execution/FirmamentPrimitiveExecutor.cs@@ -612,7 +612,10 @@ internal static class FirmamentPrimitiveExecutor{return primitive.Kind switch{- FirmamentLoweredPrimitiveKind.Box => TranslateBody(body, new Vector3D(0d, 0d, ((FirmamentLoweredBoxParameters)primitive.Parameters).SizeZ * 0.5d)),+ FirmamentLoweredPrimitiveKind.Box => TranslateBody(body, new Vector3D(0d, 0d, FirmamentStockFrame.ForBox(+ ((FirmamentLoweredBoxParameters)primitive.Parameters).SizeX,+ ((FirmamentLoweredBoxParameters)primitive.Parameters).SizeY,+ ((FirmamentLoweredBoxParameters)primitive.Parameters).SizeZ).KernelCenteredToStockZ)),FirmamentLoweredPrimitiveKind.Cylinder => TranslateBody(body, new Vector3D(0d, 0d, ((FirmamentLoweredCylinderParameters)primitive.Parameters).Height * 0.5d)),FirmamentLoweredPrimitiveKind.Cone => TranslateBody(body, new Vector3D(0d, 0d, ((FirmamentLoweredConeParameters)primitive.Parameters).Height * 0.5d)),FirmamentLoweredPrimitiveKind.TriangularPrism => TranslateBody(body, new Vector3D(0d, 0d, ((FirmamentLoweredTriangularPrismParameters)primitive.Parameters).Height * 0.5d)),diff --git a/Aetheris.Kernel.Firmament/FirmamentBuildAndExport.cs b/Aetheris.Kernel.Firmament/FirmamentBuildAndExport.csindex 139230c6..05f36f26 100644--- a/Aetheris.Kernel.Firmament/FirmamentBuildAndExport.cs+++ b/Aetheris.Kernel.Firmament/FirmamentBuildAndExport.cs@@ -976,9 +976,7 @@ public static class FirmamentBuildAndExport// Hole is intentionally the first construction stage. Existing materialization// is used as the semantic/host proof; the bounded final plan below then consumes// its same source intent alongside the admitted outer-boundary finish.- var host = document.ConceptIr is null- ? new AirHoleSimpleShaftHost(box.Size[0], box.Size[1], -box.Size[2] / 2d, box.Size[2] / 2d)- : new AirHoleSimpleShaftHost(box.Size[0], box.Size[1], 0d, box.Size[2]);+ var host = FirmamentStockFrame.ForBox(box.Size[0], box.Size[1], box.Size[2]).CreateHoleHost();var holeStages = holes.Select(h => AirHoleSimpleShaftMaterializer.Execute(h, host)).ToArray();if (holeStages.Any(stage => !stage.Succeeded || stage.Plan is null)){@@ -1708,7 +1706,7 @@ public static class FirmamentBuildAndExportvar semanticHoles = FirmamentV2SemanticHoleLowering.LowerSemanticHoles(syntheticDocument);var feature = semanticHoles[0];- var host = new AirHoleSimpleShaftHost(size[0], size[1], -size[2] / 2d, size[2] / 2d);+ var host = FirmamentStockFrame.ForBox(size[0], size[1], size[2]).CreateHoleHost();var materialized = AirHoleSimpleShaftMaterializer.Execute(feature, host);if (!materialized.Succeeded || materialized.Body is null) return SemanticHoleFailure(materialized.Diagnostics);@@ -1927,11 +1925,8 @@ public static class FirmamentBuildAndExport}var feature = semanticHoles[0];- // Concept Box3 uses an XY-centered frame with Z in [0, height]. Preserve that frame for- // Concept-driven holes so the materialized face and resolved Point3 share coordinates.- var host = document.ConceptIr is null- ? new AirHoleSimpleShaftHost(box.Size[0], box.Size[1], -box.Size[2] / 2d, box.Size[2] / 2d)- : new AirHoleSimpleShaftHost(box.Size[0], box.Size[1], 0d, box.Size[2]);+ // The stock frame is authored by the Box, never inferred from ConceptIr presence.+ var host = FirmamentStockFrame.ForBox(box.Size[0], box.Size[1], box.Size[2]).CreateHoleHost();Aetheris.Kernel.Core.Brep.BrepBody? body;IReadOnlyList<string> diagnostics;if (semanticHoles.Count == 1)diff --git a/Aetheris.Kernel.Firmament/FirmamentStockFrame.cs b/Aetheris.Kernel.Firmament/FirmamentStockFrame.csnew file mode 100644index 00000000..64249831--- /dev/null+++ b/Aetheris.Kernel.Firmament/FirmamentStockFrame.cs@@ -0,0 +1,32 @@+using Aetheris.Kernel.Firmament.Materializer;++namespace Aetheris.Kernel.Firmament;++/// <summary>+/// Semantic placement authority for an authored stock primitive. Kernel primitives remain+/// mathematically centered; Firmament stock is bottom-anchored in its authored body frame.+/// </summary>+public sealed record FirmamentStockFrame(+ string Authority,+ double OriginX,+ double OriginY,+ double OriginZ,+ double SizeX,+ double SizeY,+ double SizeZ)+{+ public double XMin => OriginX - SizeX / 2d;+ public double XMax => OriginX + SizeX / 2d;+ public double YMin => OriginY - SizeY / 2d;+ public double YMax => OriginY + SizeY / 2d;+ public double ZMin => OriginZ;+ public double ZMax => OriginZ + SizeZ;+ public double KernelCenteredToStockZ => OriginZ + SizeZ / 2d;++ /// <summary>Current Firmament Box law: XY-centered, Bottom at local Z=0, Top at local Z=Height.</summary>+ public static FirmamentStockFrame ForBox(double width, double depth, double height) =>+ new("FirmamentBoxBottomAnchoredV2", 0d, 0d, 0d, width, depth, height);++ internal AirHoleSimpleShaftHost CreateHoleHost() =>+ new(SizeX, SizeY, ZMin, ZMax, StockFrame: this);+}diff --git a/Aetheris.Kernel.Firmament/Lowering/FirmamentCirLowerer.cs b/Aetheris.Kernel.Firmament/Lowering/FirmamentCirLowerer.csindex 25a55d4c..b046fd25 100644--- a/Aetheris.Kernel.Firmament/Lowering/FirmamentCirLowerer.cs+++ b/Aetheris.Kernel.Firmament/Lowering/FirmamentCirLowerer.cs@@ -139,7 +139,7 @@ internal static class FirmamentCirLowerer{var zShift = primitive switch{- { Kind: FirmamentLoweredPrimitiveKind.Box, Parameters: FirmamentLoweredBoxParameters box } => box.SizeZ * 0.5d,+ { Kind: FirmamentLoweredPrimitiveKind.Box, Parameters: FirmamentLoweredBoxParameters box } => FirmamentStockFrame.ForBox(box.SizeX, box.SizeY, box.SizeZ).KernelCenteredToStockZ,{ Kind: FirmamentLoweredPrimitiveKind.Cylinder, Parameters: FirmamentLoweredCylinderParameters cylinder } => cylinder.Height * 0.5d,{ Kind: FirmamentLoweredPrimitiveKind.Cone, Parameters: FirmamentLoweredConeParameters cone } => cone.Height * 0.5d,{ Kind: FirmamentLoweredPrimitiveKind.TriangularPrism, Parameters: FirmamentLoweredTriangularPrismParameters prism } => prism.Height * 0.5d,diff --git a/Aetheris.Kernel.Firmament/Materializer/AirHoleSimpleShaftMaterializer.cs b/Aetheris.Kernel.Firmament/Materializer/AirHoleSimpleShaftMaterializer.csindex bf3bc196..f637ba09 100644--- a/Aetheris.Kernel.Firmament/Materializer/AirHoleSimpleShaftMaterializer.cs+++ b/Aetheris.Kernel.Firmament/Materializer/AirHoleSimpleShaftMaterializer.cs@@ -14,7 +14,8 @@ public sealed record SemanticHoleSourceInspectionEvidence(double[] LocalCenter, double[]? WorldMouthCenter, double Diameter, double Radius,string Extent, double[]? HostInterval, string? PlanId, string? SourceSpan,double? DeclaredDepth = null, double? ShaftDepth = null, double? TipLength = null, double? TotalDepth = null, double? PointAngle = null,- HoleHostTraversalEvidence? HostTraversal = null, HoleEndConditionContractEvidence? Contract = null);+ HoleHostTraversalEvidence? HostTraversal = null, HoleEndConditionContractEvidence? Contract = null,+ FirmamentStockFrame? StockFrame = null);public sealed record SemanticHoleInspectionResult(bool Succeeded, string? HoleId, BrepBody? Body, SemanticTopologyCorrespondence? Correspondence, IReadOnlyList<string> Diagnostics, SemanticHoleSourceInspectionEvidence? Evidence = null);public static class SemanticHoleInspection{@@ -23,7 +24,7 @@ public static class SemanticHoleInspectionvar holes = FirmamentV2SemanticHoleLowering.LowerSemanticHoles(document);var binding = document.Solids.FirstOrDefault();if (holes.Count != 1 || binding?.Primitive is not FirmamentV2BoxRecord box || box.Size.Count != 3) return new(false, null, null, null, ["MissingCorrespondenceEvidence: bounded inspection requires one shaft hole in one Box host."]);- var host = document.ConceptIr is null ? new AirHoleSimpleShaftHost(box.Size[0], box.Size[1], -box.Size[2] / 2d, box.Size[2] / 2d) : new AirHoleSimpleShaftHost(box.Size[0], box.Size[1], 0d, box.Size[2]);+ var host = FirmamentStockFrame.ForBox(box.Size[0], box.Size[1], box.Size[2]).CreateHoleHost();var result = AirHoleSimpleShaftMaterializer.Execute(holes[0], host);var feature = holes[0]; var placement = feature.ConstructionPlanePlacement;var drill = feature.Termination as AirHoleTermination.DrillPoint;@@ -40,7 +41,7 @@ public static class SemanticHoleInspection[placement.LocalCenterX, placement.LocalCenterY], [placement.WorldMouthCenter.X, placement.WorldMouthCenter.Y, placement.WorldMouthCenter.Z],feature.Shaft.Diameter, feature.Shaft.Radius, feature.EndCondition.Kind.ToString(), result.Plan?.HoleBRepPlan is { } plan ? [plan.HostMaterialInterval.Start, plan.HostMaterialInterval.End] : null,result.Plan?.HoleBRepPlan?.StableId, placement.SourceSpan, declaredDepth, shaftDepth, tipLength, totalDepth, drill?.PointAngleDegrees,- result.Plan?.HoleBRepPlan?.TraversalEvidence, result.Plan?.HoleBRepPlan?.ContractEvidence);+ result.Plan?.HoleBRepPlan?.TraversalEvidence, result.Plan?.HoleBRepPlan?.ContractEvidence, host.StockFrame);return new(result.Succeeded && result.Correspondence is not null, feature.FeatureId, result.Body, result.Correspondence, result.Diagnostics, evidence);}}@@ -59,7 +60,8 @@ internal sealed record AirHoleSimpleShaftHost(double ZMin,double ZMax,string TopFaceName = "top",- string BottomFaceName = "bottom")+ string BottomFaceName = "bottom",+ FirmamentStockFrame? StockFrame = null){public double Thickness => ZMax - ZMin;}diff --git a/docs/public/firmament/syntax.md b/docs/public/firmament/syntax.mdindex 402fef67..9628286c 100644--- a/docs/public/firmament/syntax.md+++ b/docs/public/firmament/syntax.md@@ -20,4 +20,6 @@ Canonical fields use a colon between name and value. Braces delimit declarationsFirmament V1 is compatibility history rather than canonical V2 authoring. Bodies embedded in `.firmfixture` entries marked future, not implemented, or invalid are corpus evidence and do not define the public language.+An untransformed `Box` stock is centered in X/Y with `Bottom` at Z=0 and `Top` at Z=`Height`. Its local feature coordinates use that same stock frame: adding holes or edge finishes does not translate the stock.+Use `aetheris validate file.firmament --json` before building. Diagnostics are codes intended for automation plus short corrective messages. See [diagnostics](../reference/diagnostics.md).diff --git a/docs/release/LANG-STOCK-FRAME-X1.md b/docs/release/LANG-STOCK-FRAME-X1.mdnew file mode 100644index 00000000..94f641ca--- /dev/null+++ b/docs/release/LANG-STOCK-FRAME-X1.md@@ -0,0 +1,48 @@+# LANG-STOCK-FRAME-X1 — stock-frame authority++## Verdict++**Accepted.** Authored native `Box` stock now has one explicit placement authority: `FirmamentStockFrame.ForBox`. Its origin is XY-centered at Bottom (`0,0,0`); `Bottom` is Z=0 and `Top` is Z=Height. Features use the same body-local XY coordinates and consume that frame's host interval. An explicit authored transform, where admitted by its owning route, applies to this complete frame.++## Authority audit and migration++| Route | Before | After | Compatibility impact |+|---|---|---|---|+| Primitive Box | Kernel-centered Box translated to Z=0..H | unchanged; kernel-to-stock adapter remains explicit | none |+| Counterbore / semantic Hole | `ConceptIr == null` chose -H/2..+H/2 | consumes `FirmamentStockFrame.ForBox` (0..H) | none for current V2 |+| Hole + EdgeFinish | repeated the same conditional host construction | consumes the same frame | none for current V2 |+| Profile / Compose | own authored support planes | unchanged; Base.Top remains its existing semantic authority | none |+| Concept-backed Box | 0..H incidentally | 0..H by the same explicit authority | parity is now intentional |+| Non-Concept Box | -H/2..+H/2 in feature routes | 0..H by the same explicit authority | removes accidental current-route divergence |++The previous defect was not a STEP problem: primitive execution already placed a Box at Z=0..H, while `SemanticHoleInspection`, semantic-hole export, and the combined hole/finish route independently constructed a centered host only when `ConceptIr` was absent. The BRep and STEP were therefore internally valid but in the wrong world frame. STEP still serializes the realized BRep without corrective translation.++`FirmamentStockFrame` is the semantic adapter between the centered kernel primitive and authored stock. It carries the stock origin, dimensions, bounds, and Bottom/Top support planes; AIR hole materializers receive its host rather than deriving placement from dimensions, feature kind, or Concept IR. Structured hole inspection includes `stockFrame` for diagnostics.++## Burn-in evidence++| Witness | Before world Z bounds | X1 world Z bounds | Result |+|---|---:|---:|---|+| stock-block | 0..12 | 0..12 | unchanged |+| mount-counterbore | -6..6 | 0..12 | fixed |+| hole-finish | -6..6 | 0..12 | fixed |+| finish-hole | -6..6 | 0..12 | fixed |+| explicit Compose boss-stack | 0..21 | 0..21 | preserved (separate Compose authority) |++The four Box witnesses are built, reimported, and analyzed under `artifacts/local/stock-frame-x1/`; each reports X=-30..30, Y=-20..20, Z=0..12 and an enclosed manifold. The counterbore retains its center axis at X=0/Y=0, top entry at Z=12, and counterbore floor at Z=8. Repeated counterbore export is byte-identical under the current deterministic exporter policy.++## Bounded related audit++Cylinder, cone, sphere, and torus still use their existing primitive-local conventions. This X1 change does not alter mathematical sweep cylinders or those primitives' specialized realizers. Their generic primitive execution already has an explicit default-local-frame adapter; no ConceptIr-dependent branch analogous to the Box-hole defect was found in the audited current native V2 feature routes.++Legacy V1 remains a compatibility dialect with its own lowering and fixture contracts. No legacy centered behavior was silently preserved in current Firmament V2; legacy routes were not changed by this focused repair.++## Reproduction++```powershell+dotnet run --project Aetheris.CLI -c Release -- build fixtures/Regression/LanguageBurnIn/mount-counterbore/mount-counterbore.firmament --output artifacts/local/stock-frame-x1/stock-frame-x1-counterbore.step --json+dotnet run --project Aetheris.CLI -c Release -- analyze artifacts/local/stock-frame-x1/stock-frame-x1-counterbore.step --json+dotnet run --project Aetheris.CLI -c Release -- wireframe artifacts/local/stock-frame-x1/stock-frame-x1-counterbore.step --out artifacts/local/stock-frame-x1/stock-frame-x1-counterbore.wireframe.svg --view iso --density 8+```++The same directory holds the requested Box, counterbore-chamfer, and boss-stack STEP/wireframe evidence. Validation also includes the Release solution build, focused Firmament tests, burn-in replay, and `git diff --check`.