Skip to content

Next Gen STEP AP242 Native-ish BREP Geometric Modeling Kernel

finish cleaning up A1/A2 from phase 2.

Yuechen Lic1787eb2f9fb
diff --git a/Aetheris.Kernel.Firmament.Tests/ForgeCsA2StandardConceptTests.cs b/Aetheris.Kernel.Firmament.Tests/ForgeCsA2StandardConceptTests.cs
new file mode 100644
index 00000000..b9ecd63b
--- /dev/null
+++ b/Aetheris.Kernel.Firmament.Tests/ForgeCsA2StandardConceptTests.cs
@@ -0,0 +1,189 @@
+using Aetheris.Forge.Abstractions.FirmamentInterop;
+using Aetheris.Forge.Standard;
+using Aetheris.Kernel.Firmament.FirmamentV2;
+
+namespace Aetheris.Kernel.Firmament.Tests;
+
+public sealed class ForgeCsA2StandardConceptTests
+{
+ [Fact]
+ public void ForgeCsA2_StandardRuntimeConceptPack_RegistersAllBuiltInsDeterministically()
+ {
+ var pack = new StandardForgeRuntimeConceptPack();
+ var registry = new InspectableForgeRegistry();
+
+ pack.Register(registry);
+
+ Assert.Equal(
+ [
+ new ConceptId("hole", "Counterbore"),
+ new ConceptId("hole", "Countersink"),
+ new ConceptId("hole", "Shaft"),
+ new ConceptId("process", "CNC")
+ ],
+ registry.RegisteredIds.OrderBy(id => id.Family, StringComparer.Ordinal).ThenBy(id => id.Concept, StringComparer.Ordinal).ToArray());
+
+ Assert.True(registry.TryResolve(new ConceptId("process", "CNC"), out var process));
+ Assert.IsType<CncProcessConcept>(process);
+ Assert.True(registry.TryResolve(new ConceptId("hole", "Shaft"), out var shaft));
+ Assert.IsType<ShaftHoleConcept>(shaft);
+ Assert.True(registry.TryResolve(new ConceptId("hole", "Counterbore"), out var counterbore));
+ Assert.IsType<CounterboreHoleConcept>(counterbore);
+ Assert.True(registry.TryResolve(new ConceptId("hole", "Countersink"), out var countersink));
+ Assert.IsType<CountersinkHoleConcept>(countersink);
+
+ var duplicate = Assert.Throws<InvalidOperationException>(() => pack.Register(registry));
+ Assert.Equal("Forge concept 'process<CNC>' is already registered.", duplicate.Message);
+ }
+
+ [Fact]
+ public void ForgeCsA2_CSharpSchemas_MatchExpectedFields()
+ {
+ AssertSchema(
+ new CncProcessConcept(),
+ ("material", ConceptSchemaValueKind.Material, true, false),
+ ("minimumToolRadius", ConceptSchemaValueKind.Length, true, false));
+
+ AssertSchema(
+ new ShaftHoleConcept(),
+ ("diameter", ConceptSchemaValueKind.Length, true, false),
+ ("target", ConceptSchemaValueKind.Target, true, false));
+
+ AssertSchema(
+ new CounterboreHoleConcept(),
+ ("counterboreDepth", ConceptSchemaValueKind.Length, true, false),
+ ("counterboreDiameter", ConceptSchemaValueKind.Length, true, false),
+ ("diameter", ConceptSchemaValueKind.Length, true, false),
+ ("target", ConceptSchemaValueKind.Target, true, false));
+
+ AssertSchema(
+ new CountersinkHoleConcept(),
+ ("angle", ConceptSchemaValueKind.Angle, true, false),
+ ("countersinkDiameter", ConceptSchemaValueKind.Length, true, false),
+ ("diameter", ConceptSchemaValueKind.Length, true, false),
+ ("target", ConceptSchemaValueKind.Target, true, false));
+ }
+
+ [Fact]
+ public void ForgeCsA2_CSharpSchemas_MatchCurrentPhase1Registry()
+ {
+ var runtimeRegistry = new InspectableForgeRegistry();
+ new StandardForgeRuntimeConceptPack().Register(runtimeRegistry);
+
+ var phase1Descriptors = FirmamentV2ForgeConceptRegistry.EnumerateDescriptors();
+ Assert.Equal(4, phase1Descriptors.Count);
+
+ foreach (var phase1Descriptor in phase1Descriptors)
+ {
+ var conceptId = new ConceptId(phase1Descriptor.FamilyName, phase1Descriptor.ConceptName);
+ Assert.True(runtimeRegistry.TryResolve(conceptId, out var concept));
+
+ var schema = BuildSchema(concept);
+ var expectedFields = phase1Descriptor.Fields.Values
+ .OrderBy(field => field.Name, StringComparer.Ordinal)
+ .Select(field => new ConceptSchemaField(field.Name, Map(field.Kind), field.Required, false))
+ .ToArray();
+
+ Assert.Equal(expectedFields, schema.Fields);
+ }
+ }
+
+ [Fact]
+ public void ForgeCsA2_ExistingFirmamentV2ConceptFixtures_StillPassWithoutBehaviorChange()
+ {
+ var conceptFixture = ParseFixture("Language/valid/concept-applications-forge.valid.firmfixture");
+ Assert.True(conceptFixture.IsSuccess, string.Join(", ", conceptFixture.Diagnostics));
+ var conceptReport = FirmamentV2ValidationReportBuilder.Build(conceptFixture, "concept-applications-forge.valid.firmfixture");
+ Assert.Equal("valid", conceptReport.Status);
+ Assert.All(conceptReport.Concepts, concept => Assert.Equal("valid", concept.Status));
+ Assert.All(conceptReport.Concepts, concept => Assert.Equal("not-run", concept.DfmStatus));
+ Assert.All(conceptReport.Concepts, concept =>
+ {
+ Assert.NotNull(concept.RuntimeValidation);
+ Assert.Equal("Aetheris.Standard", concept.RuntimeValidation!.Provider);
+ Assert.Equal("valid", concept.RuntimeValidation.Status);
+ });
+
+ var reportFixture = ParseFixture("Language/valid/v2-phase1-validation-report.valid.firmfixture");
+ Assert.True(reportFixture.IsSuccess, string.Join(", ", reportFixture.Diagnostics));
+ var report = FirmamentV2ValidationReportBuilder.Build(reportFixture, "v2-phase1-validation-report.valid.firmfixture");
+ Assert.Equal("valid-with-deferred-export", report.Status);
+ Assert.Equal(2, report.Summary.ConceptCount);
+ }
+
+ private static ConceptSchemaBuilder BuildSchema(IForgeConcept concept)
+ {
+ var schema = new ConceptSchemaBuilder();
+ concept.Define(schema);
+ return schema;
+ }
+
+ private static void AssertSchema(IForgeConcept concept, params (string Name, ConceptSchemaValueKind Kind, bool Required, bool RequiresTolerance)[] expectedFields)
+ {
+ var schema = BuildSchema(concept);
+ Assert.Equal(
+ expectedFields.Select(field => new ConceptSchemaField(field.Name, field.Kind, field.Required, field.RequiresTolerance)).OrderBy(field => field.Name, StringComparer.Ordinal).ToArray(),
+ schema.Fields);
+ }
+
+ private static ConceptSchemaValueKind Map(FirmamentV2ForgeFieldKind fieldKind) => fieldKind switch
+ {
+ FirmamentV2ForgeFieldKind.Target => ConceptSchemaValueKind.Target,
+ FirmamentV2ForgeFieldKind.Length => ConceptSchemaValueKind.Length,
+ FirmamentV2ForgeFieldKind.Angle => ConceptSchemaValueKind.Angle,
+ FirmamentV2ForgeFieldKind.Material => ConceptSchemaValueKind.Material,
+ _ => throw new ArgumentOutOfRangeException(nameof(fieldKind), fieldKind, "Unexpected Phase 1 Forge field kind.")
+ };
+
+ private static FirmamentV2ParseResult ParseFixture(string relative)
+ {
+ var path = Path.Combine(FindRepoRoot(), "fixtures", "FirmamentV2", relative);
+ return FirmamentV2Parser.Parse(File.ReadAllText(path));
+ }
+
+ private static string FindRepoRoot()
+ {
+ var dir = new DirectoryInfo(AppContext.BaseDirectory);
+ while (dir is not null && !File.Exists(Path.Combine(dir.FullName, "Aetheris.slnx")))
+ {
+ dir = dir.Parent;
+ }
+
+ return dir?.FullName ?? throw new InvalidOperationException("Could not find repo root.");
+ }
+
+ private sealed class InspectableForgeRegistry : IForgeRegistry
+ {
+ private readonly Dictionary<ConceptId, IForgeConcept> concepts = new();
+
+ public IReadOnlyList<ConceptId> RegisteredIds => concepts.Keys.ToArray();
+
+ public void Register(IForgeConcept concept)
+ {
+ ArgumentNullException.ThrowIfNull(concept);
+ if (concepts.ContainsKey(concept.Id))
+ {
+ throw new InvalidOperationException($"Forge concept '{concept.Id}' is already registered.");
+ }
+
+ concepts.Add(concept.Id, concept);
+ }
+
+ public bool TryResolve(ConceptId id, out IForgeConcept concept) => concepts.TryGetValue(id, out concept!);
+ }
+
+ private sealed class EmptyVariables : IFirmamentVariables
+ {
+ public static EmptyVariables Instance { get; } = new();
+
+ public IReadOnlyList<FirmamentVariable> All => [];
+
+ public FirmamentValue GetRequired(string name) => throw new KeyNotFoundException($"Firmament variable '{name}' was not found.");
+
+ public bool TryGet(string name, out FirmamentValue value)
+ {
+ value = null!;
+ return false;
+ }
+ }
+}
diff --git a/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2ForgeConceptRegistry.cs b/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2ForgeConceptRegistry.cs
index c32e1fdc..f824bd5d 100644
--- a/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2ForgeConceptRegistry.cs
+++ b/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2ForgeConceptRegistry.cs
@@ -35,6 +35,13 @@ public static class FirmamentV2ForgeConceptRegistry
return concepts.TryGetValue(conceptName, out descriptor!);
}
+ internal static IReadOnlyList<FirmamentV2ForgeConceptDescriptor> EnumerateDescriptors() =>
+ Families.Values
+ .SelectMany(concepts => concepts.Values)
+ .OrderBy(descriptor => descriptor.FamilyName, StringComparer.Ordinal)
+ .ThenBy(descriptor => descriptor.ConceptName, StringComparer.Ordinal)
+ .ToArray();
+
private static IReadOnlyDictionary<string, IReadOnlyDictionary<string, FirmamentV2ForgeConceptDescriptor>> Build()
{
var process = new Dictionary<string, FirmamentV2ForgeConceptDescriptor>(StringComparer.Ordinal)
diff --git a/docs/implementation/forge-cs-a1-readonly-interop-facades.md b/docs/implementation/forge-cs-a1-readonly-interop-facades.md
index 2fb872b6..8c1efdd9 100644
--- a/docs/implementation/forge-cs-a1-readonly-interop-facades.md
+++ b/docs/implementation/forge-cs-a1-readonly-interop-facades.md
@@ -155,6 +155,8 @@ The tests cover:
- in-process registry registration, resolution, and deterministic duplicate behavior;
- diagnostic facade metadata and serialization basics.
+Follow-on milestone: [`forge-cs-a2-standard-concept-descriptors.md`](forge-cs-a2-standard-concept-descriptors.md) mirrors the built-in Phase 1 Forge concepts as runtime C# `IForgeConcept` descriptors while keeping parser/CLI/report/export behavior unchanged.
+
## Explicit non-scope
A1 intentionally does not add:
diff --git a/docs/implementation/forge-cs-a2-standard-concept-descriptors.md b/docs/implementation/forge-cs-a2-standard-concept-descriptors.md
new file mode 100644
index 00000000..89b757aa
--- /dev/null
+++ b/docs/implementation/forge-cs-a2-standard-concept-descriptors.md
@@ -0,0 +1,119 @@
+# FORGE-CS-A2 standard concept descriptors
+
+Milestone: **FORGE-CS-A2**
+
+Phase 2 doctrine remains:
+
+```text
+Firmament remains data.
+C# owns logic.
+Forge is the interop boundary.
+```
+
+## Purpose
+
+FORGE-CS-A2 mirrors the built-in Phase 1 Forge concepts as C# `IForgeConcept` descriptors using the A1 interop contracts.
+
+This milestone proves schema/descriptor parity only. It does not replace the current `FirmamentV2ForgeConceptRegistry`, does not invoke C# validators through `aetheris validate`, and does not change Firmament syntax, parser behavior, binder behavior, validation-report behavior, or AP242 export behavior.
+
+## Types added
+
+Runtime concept classes now live in:
+
+```text
+Aetheris.Forge/Standard/
+```
+
+Added runtime concept types:
+
+- `CncProcessConcept`
+- `ShaftHoleConcept`
+- `CounterboreHoleConcept`
+- `CountersinkHoleConcept`
+- `StandardForgeRuntimeConceptPack`
+
+These are distinct from the existing descriptor-only `Aetheris.Forge.Standard.StandardConceptPack`, which remains metadata-oriented and is not the Firmament V2 runtime concept registry.
+
+## Runtime pack
+
+`StandardForgeRuntimeConceptPack` is an in-process `IForgeConceptPack` that registers:
+
+- `process<CNC>`
+- `hole<Shaft>`
+- `hole<Counterbore>`
+- `hole<Countersink>`
+
+Registration stays deterministic through the existing `IForgeRegistry` duplicate-registration behavior. No plugin loading, external assembly loading, or Roslyn compilation was added.
+
+## Schema parity
+
+The runtime C# concepts mirror the current Phase 1 registry fields exactly:
+
+- `process<CNC>`
+ - `material`: required `material`
+ - `minimumToolRadius`: required `length`
+- `hole<Shaft>`
+ - `target`: required `target`
+ - `diameter`: required `length`
+- `hole<Counterbore>`
+ - `target`: required `target`
+ - `diameter`: required `length`
+ - `counterboreDiameter`: required `length`
+ - `counterboreDepth`: required `length`
+- `hole<Countersink>`
+ - `target`: required `target`
+ - `diameter`: required `length`
+ - `countersinkDiameter`: required `length`
+ - `angle`: required `angle`
+
+To express `process<CNC>.material` parity more faithfully, A2 extends `ConceptSchemaBuilder` with `RequiredMaterial(...)` and `ConceptSchemaValueKind.Material`.
+
+Material remains string-compatible at the current parser/binder layer because the existing Phase 1 registry accepts `FirmamentV2PrimitiveType.String` for `Material` fields. A2 records that distinction as schema metadata only; it does not introduce a new parser-level value kind.
+
+## No-op validator policy
+
+Each built-in runtime concept implements `Validate(ConceptValidationContext)` as an intentional no-op for A2:
+
+- no DFM checks;
+- no PMI obligation generation;
+- no mutation;
+- no report contribution;
+- no AP242 export interaction.
+
+This keeps A2 at descriptor/schema parity. Runtime validation/report integration is deferred to A3.
+
+## Registry relationship
+
+`FirmamentV2ForgeConceptRegistry` remains the active Phase 1 parser registry.
+
+A2 adds an internal descriptor-enumeration helper so tests can compare the new C# schemas against the current Phase 1 registry catalog without widening the production runtime surface unnecessarily.
+
+## Tests
+
+Focused tests in `Aetheris.Kernel.Firmament.Tests/ForgeCsA2StandardConceptTests.cs` cover:
+
+- runtime pack registration and deterministic duplicate behavior;
+- exact per-concept schema metadata;
+- parity between C# schemas and `FirmamentV2ForgeConceptRegistry`;
+- no-op `Validate(...)` behavior;
+- unchanged parsing/report behavior for existing Phase 1 concept fixtures.
+
+Follow-on milestone: [`forge-cs-a3-runtime-concept-validation.md`](forge-cs-a3-runtime-concept-validation.md) wires these built-in runtime descriptors into `aetheris validate` and the R1 validation report path.
+
+## Explicit non-scope
+
+A2 intentionally does not add:
+
+- CLI invocation of C# concept validators;
+- parser registry replacement;
+- parser changes;
+- binder changes;
+- R1 validation-report behavior changes;
+- DFM checks;
+- PMI obligation generation;
+- plugin loading;
+- external assembly loading;
+- Roslyn compilation;
+- template generation;
+- Firmament document mutation;
+- AP242 export changes.