Next Gen STEP AP242 Native-ish BREP Geometric Modeling Kernel
Add generated field projectors and construct completion entries
Yuechen Li7249f6f087da
diff --git a/Aetheris.Firmament.SchemaGenerator/SemanticSchemaGenerator.cs b/Aetheris.Firmament.SchemaGenerator/SemanticSchemaGenerator.csindex 9c866910..e82a47be 100644--- a/Aetheris.Firmament.SchemaGenerator/SemanticSchemaGenerator.cs+++ b/Aetheris.Firmament.SchemaGenerator/SemanticSchemaGenerator.cs@@ -56,7 +56,18 @@ public sealed class SemanticSchemaGenerator : IIncrementalGenerator|| kind == "Length" && unit != "Length" || kind == "Angle" && unit != "Angle"|| kind is not ("Length" or "Angle" or "Vector" or "Point") && unit != "None"){ Error(output, symbol, $"field '{fieldName}' in {name} has a duplicate/missing ID, unsupported kind, or invalid choices"); continue; }- fields.Add(new(fieldId, fieldName, kind, unit, Bool(attribute, "Required"), Str(attribute, "Default"), Str(attribute, "Description"), choices));+ var editable = Bool(attribute, "SourceEditable");+ var projectorName = Str(attribute, "ProjectionMember");+ IMethodSymbol? projector = null;+ if (projectorName is not null)+ projector = symbol.GetMembers(projectorName).OfType<IMethodSymbol>().SingleOrDefault(method =>+ method.IsStatic && method.DeclaredAccessibility == Accessibility.Public &&+ method.Parameters.Length == 1 && method.ReturnType.SpecialType == SpecialType.System_Double);+ if (editable != (projector is not null) || projectorName is not null && projector is null)+ { Error(output, symbol, $"source-editable field '{fieldName}' in {name} requires one public static double projector with one semantic-instance parameter"); continue; }+ fields.Add(new(fieldId, fieldName, kind, unit, Bool(attribute, "Required"), Str(attribute, "Default"), Str(attribute, "Description"), choices,+ editable, projectorName, projector?.Parameters[0].Type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat),+ symbol.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat)));}else if (attribute.AttributeClass?.Name == "FirmamentOutputAttribute"){@@ -77,14 +88,20 @@ public sealed class SemanticSchemaGenerator : IIncrementalGeneratorsource.Append(" new(new FirmamentConstructId(").Append(Q(entry.Id)).Append("), ").Append(Q(entry.Name)).Append(", ").Append(Q(entry.Context)).Append(", ").Append(Q(entry.Snippet)).Append(", ").Append(Q(entry.Description)).Append(", ").Append(Q(entry.Alias)).Append(",\n System.Array.AsReadOnly(new FirmamentFieldSchema[] {\n");foreach (var field in entry.Fields){- source.Append(" new(new FirmamentFieldId(").Append(Q(entry.Id + "." + field.Id)).Append("), ").Append(Q(field.Name)).Append(", FirmamentSchemaValueKind.").Append(field.Kind).Append(", FirmamentUnitKind.").Append(field.Unit).Append(", ").Append(field.Required ? "true" : "false").Append(", ").Append(Q(field.Default)).Append(", System.Array.AsReadOnly(new string[] { ").Append(string.Join(", ", field.Choices.Select(Q))).Append(" }), ").Append(Q(field.Description)).Append(", true),\n");+ source.Append(" new(new FirmamentFieldId(").Append(Q(entry.Id + "." + field.Id)).Append("), ").Append(Q(field.Name)).Append(", FirmamentSchemaValueKind.").Append(field.Kind).Append(", FirmamentUnitKind.").Append(field.Unit).Append(", ").Append(field.Required ? "true" : "false").Append(", ").Append(Q(field.Default)).Append(", System.Array.AsReadOnly(new string[] { ").Append(string.Join(", ", field.Choices.Select(Q))).Append(" }), ").Append(Q(field.Description)).Append(", ").Append(field.Editable ? "true" : "false").Append("),\n");}source.Append(" }), System.Array.AsReadOnly(new FirmamentOutputSchema[] {\n");foreach (var item in entry.Outputs)source.Append(" new(new FirmamentOutputId(").Append(Q(entry.Id + "." + item.Id)).Append("), ").Append(Q(item.Name)).Append(", ").Append(Q(item.Kind)).Append(", ").Append(item.Addressable ? "true" : "false").Append(", ").Append(Q(item.Role)).Append("),\n");source.Append(" })),\n");}- source.Append(" });\n public static FirmamentConstructSchema? Get(string name) => System.Linq.Enumerable.FirstOrDefault(All, x => x.Name == name);\n}\n");+ source.Append(" });\n public static FirmamentConstructSchema? Get(string name) => System.Linq.Enumerable.FirstOrDefault(All, x => x.Name == name);\n");+ foreach (var entry in entries)+ foreach (var field in entry.Fields.Where(field => field.Editable))+ source.Append(" public static double Project").Append(entry.Id).Append(field.Id).Append("(")+ .Append(field.ProjectorType).Append(" instance) => ").Append(field.ProjectorOwner).Append(".")+ .Append(field.ProjectorName).Append("(instance);\n");+ source.Append("}\n");output.AddSource("FirmamentSemanticSchemas.g.cs", source.ToString());}@@ -98,7 +115,8 @@ public sealed class SemanticSchemaGenerator : IIncrementalGeneratorprivate static void Error(SourceProductionContext output, INamedTypeSymbol symbol, string message) => output.ReportDiagnostic(Diagnostic.Create(Invalid, symbol.Locations.FirstOrDefault(), message));private sealed record Entry(string Id, string Name, string? Context, string? Snippet, string? Description, string? Alias, Field[] Fields, Output[] Outputs);- private sealed record Field(string Id, string Name, string Kind, string Unit, bool Required, string? Default, string? Description, string[] Choices);+ private sealed record Field(string Id, string Name, string Kind, string Unit, bool Required, string? Default, string? Description, string[] Choices,+ bool Editable, string? ProjectorName, string? ProjectorType, string ProjectorOwner);private sealed record Output(string Id, string Name, string Kind, bool Addressable, string? Role);}diff --git a/Aetheris.Kernel.Firmament.Tests/FirmamentFieldProjectionTests.cs b/Aetheris.Kernel.Firmament.Tests/FirmamentFieldProjectionTests.csnew file mode 100644index 00000000..2d847804--- /dev/null+++ b/Aetheris.Kernel.Firmament.Tests/FirmamentFieldProjectionTests.cs@@ -0,0 +1,124 @@+using Aetheris.Kernel.Firmament.FirmamentV2;+using Aetheris.Kernel.Firmament.Materializer;++namespace Aetheris.Kernel.Firmament.Tests;++public sealed class FirmamentFieldProjectionTests+{+ private const string Source = """+ Model Witness {+ Units: mm+ Box Body { Size: [30mm, 20mm, 10mm] }+ Modify Body {+ Hole<Shaft> H {+ On: +Z Center: Point2(0mm, 0mm)+ Diameter: 10mm /* keep this comment */ End: ThroughAll+ }+ }+ }+ """;++ [Fact]+ public void CanonicalBoxAndHoleExposeParserOwnedValuesAndRanges()+ {+ var projections = Project(Source);+ var box = Assert.Single(projections, item => item.SemanticId == "Body");+ var size = Assert.Single(box.Fields, item => item.FieldId.Value == "Box.Size");+ Assert.Equal("[30mm, 20mm, 10mm]", size.AuthoredValue);+ Assert.Equal([30d, 20d, 10d], size.EffectiveValue!.Components);+ Assert.False(size.Editable);+ Assert.Equal(size.AuthoredValue, Source.Substring(size.ValueSpan!.Start, size.ValueSpan.Length));++ var hole = Assert.Single(projections, item => item.SemanticId == "Body.H");+ var diameter = Assert.Single(hole.Fields, item => item.FieldId.Value == "Hole.Diameter");+ Assert.Equal("10mm", diameter.AuthoredValue);+ Assert.Equal(10d, diameter.EffectiveValue!.Number);+ Assert.Equal("Authored", diameter.Origin);+ Assert.True(diameter.Editable);+ Assert.Equal("10mm", Source.Substring(diameter.ValueSpan!.Start, diameter.ValueSpan.Length));+ }++ [Fact]+ public void RewriteOnlyChangesBoundLiteralAndRejectsStaleOrInvalidInputs()+ {+ var hole = Assert.Single(Project(Source), item => item.SemanticId == "Body.H");+ var next = new FirmamentProjectedValue("Length", "12 mm", 12, Unit: "mm");+ var changed = FirmamentFieldProjector.Rewrite(Source, hole.SourceRevision, hole, new("Hole.Diameter"), next);+ Assert.True(changed.Success);+ Assert.Equal(Source.Replace("Diameter: 10mm", "Diameter: 12mm", StringComparison.Ordinal), changed.NewSource);+ Assert.Contains("/* keep this comment */", changed.NewSource);+ Assert.Equal("stale_revision", FirmamentFieldProjector.Rewrite(Source + " ", hole.SourceRevision, hole, new("Hole.Diameter"), next).Code);+ Assert.Equal("invalid_value", FirmamentFieldProjector.Rewrite(Source, hole.SourceRevision, hole, new("Hole.Diameter"), next with { Number = -1 }).Code);+ Assert.Equal("field_readonly", FirmamentFieldProjector.Rewrite(Source, hole.SourceRevision, hole, new("Hole.On"), next).Code);+ }++ [Fact]+ public void HelixProjectsAuthoredAndDefaultedValuesFromWireFormAir()+ {+ const string source = """+ Model W {+ Units: mm+ WireForm Spring {+ Diameter: 1mm+ Origin: [0mm, 0mm, 0mm]+ Tangent: [0, 0, 1]+ Up: [0, 1, 0]+ Helix Winding {+ Radius: 5mm+ Turns: 4+ Pitch: 2mm+ }+ }+ }+ """;+ var parsed = WireFormAuthoring.Parse(source);+ Assert.True(parsed.IsSuccess);+ var helix = Assert.Single(FirmamentFieldProjector.ProjectWireForm(parsed.Value, source, "helix.firmament", 2));+ var radius = Assert.Single(helix.Fields, item => item.FieldId.Value == "Helix.Radius");+ Assert.Equal("5mm", radius.AuthoredValue);+ Assert.Equal(5d, radius.EffectiveValue!.Number);+ Assert.Equal("Authored", radius.Origin);+ var height = Assert.Single(helix.Fields, item => item.FieldId.Value == "Helix.Height");+ Assert.Equal("Derived", height.Origin);+ Assert.Equal(8d, height.EffectiveValue!.Number);+ var hand = Assert.Single(helix.Fields, item => item.FieldId.Value == "Helix.Handedness");+ Assert.Equal("Defaulted", hand.Origin);+ Assert.Null(hand.ValueSpan);++ var expression = source.Replace("Radius: 5mm", "Radius: 2mm + 3mm", StringComparison.Ordinal);+ var expressionAir = WireFormAuthoring.Parse(expression);+ Assert.True(expressionAir.IsSuccess);+ var expressionHelix = Assert.Single(FirmamentFieldProjector.ProjectWireForm(expressionAir.Value, expression, "helix.firmament", 3));+ var expressionRadius = Assert.Single(expressionHelix.Fields, item => item.FieldId.Value == "Helix.Radius");+ Assert.Equal("2mm + 3mm", expressionRadius.AuthoredValue);+ Assert.Equal(5d, expressionRadius.EffectiveValue!.Number);+ Assert.False(expressionRadius.Editable);+ }++ [Fact]+ public void LoftProjectsBoundNamesAndDefaultTwist()+ {+ var directory = new DirectoryInfo(AppContext.BaseDirectory);+ while (directory is not null && !File.Exists(Path.Combine(directory.FullName, "Aetheris.slnx"))) directory = directory.Parent;+ Assert.NotNull(directory);+ var source = File.ReadAllText(Path.Combine(directory.FullName, "fixtures", "Canonical", "SectionChain", "solid-loft-common-ray.firmament"));+ var bound = LoftAuthoringParser.Compile(source, materialize: false);+ Assert.True(bound.IsSuccess, string.Join("; ", bound.Diagnostics));+ var loft = Assert.IsType<FirmamentConstructProjection>(FirmamentFieldProjector.ProjectLoft(bound, source, "loft.firmament", 1));+ Assert.Equal("Body", loft.SemanticId);+ var rear = Assert.Single(loft.Fields, item => item.FieldId.Value == "Loft.RearProfile");+ Assert.Equal("LowerOutline", rear.EffectiveValue!.Text);+ Assert.Equal("LowerOutline", rear.AuthoredValue);+ Assert.Equal("Authored", rear.Origin);+ var twist = Assert.Single(loft.Fields, item => item.FieldId.Value == "Loft.Twist");+ Assert.Equal("Defaulted", twist.Origin);+ Assert.Null(twist.ValueSpan);+ }++ private static IReadOnlyList<FirmamentConstructProjection> Project(string source)+ {+ var parsed = FirmamentV2Parser.Parse(source);+ Assert.NotNull(parsed.Document);+ return FirmamentFieldProjector.Project(parsed.Document, source, "witness.firmament", 4);+ }+}diff --git a/Aetheris.Kernel.Firmament.Tests/FirmamentSemanticSchemaTests.cs b/Aetheris.Kernel.Firmament.Tests/FirmamentSemanticSchemaTests.csindex 449948d6..73d11ac0 100644--- a/Aetheris.Kernel.Firmament.Tests/FirmamentSemanticSchemaTests.cs+++ b/Aetheris.Kernel.Firmament.Tests/FirmamentSemanticSchemaTests.cs@@ -46,6 +46,29 @@ public sealed class FirmamentSemanticSchemaTestsAssert.All(box.Fields, f => Assert.False(f.Required)); // Size or Bounds is required, not either field alone.}+ [Theory]+ [InlineData("Helix", "WireForm Spring")]+ [InlineData("Loft", "Construction Plane LowerFrame")]+ public void BareConstructSearchReturnsGeneratedLegalEntry(string name, string requiredContext)+ {+ var source = $"Model Draft {{ Units: mm\n {name}";+ var completion = FirmamentLanguageService.Complete(source, "draft.firmament", "1", source.Length);+ Assert.Equal("ConstructEntry", completion.Context);+ var entry = Assert.Single(completion.Entries!);+ Assert.Equal(name, entry.Name);+ Assert.Contains(requiredContext, entry.Source);+ Assert.Equal(FirmamentSemanticSchemas.Get(name)!.Entry, entry.Source);+ }++ [Theory]+ [InlineData("Helix")]+ [InlineData("Loft")]+ public void GeneratedEntryIsBuildable(string name)+ {+ var result = FirmamentBuildAndExport.CompileSource(FirmamentSemanticSchemas.Get(name)!.Entry!);+ Assert.True(result.IsSuccess, string.Join("; ", result.Diagnostics.Select(item => item.Message)));+ }+private static FirmamentLanguageCompletion LoftOrHelixCompletion(string source, string expected){var result = FirmamentLanguageService.Complete(source, "draft.firmament", "1", source.Length);diff --git a/Aetheris.Kernel.Firmament.Tests/SemanticSchemaGeneratorTests.cs b/Aetheris.Kernel.Firmament.Tests/SemanticSchemaGeneratorTests.csindex f690cbb9..f3ea928f 100644--- a/Aetheris.Kernel.Firmament.Tests/SemanticSchemaGeneratorTests.cs+++ b/Aetheris.Kernel.Firmament.Tests/SemanticSchemaGeneratorTests.cs@@ -10,7 +10,7 @@ public sealed class FirmamentSchemaGeneratorTestsusing System;namespace Aetheris.Kernel.Firmament.FirmamentV2 {[AttributeUsage(AttributeTargets.Class)] public sealed class FirmamentConstructAttribute(string id, string name) : Attribute { }- [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)] public sealed class FirmamentFieldAttribute(string id, string name, FirmamentSchemaValueKind kind) : Attribute { }+ [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)] public sealed class FirmamentFieldAttribute(string id, string name, FirmamentSchemaValueKind kind) : Attribute { public bool SourceEditable { get; init; } public string? ProjectionMember { get; init; } }public enum FirmamentSchemaValueKind { Length, Angle, Scalar, Count, Boolean, String, Choice, Vector, Point, Profile, ConstructionPlane, FaceSelector, BodySelector, ConstructReference, Box3, TypeRequirement }}""";@@ -47,6 +47,31 @@ public sealed class FirmamentSchemaGeneratorTestsAssert.Contains(Generate(Prelude + source).Diagnostics, d => d.Id == "FMS001" && d.Severity == DiagnosticSeverity.Error);}+ [Fact]+ public void SourceEditableFieldWithoutStaticProjector_IsCompileTimeError()+ {+ const string source = """+ [Aetheris.Kernel.Firmament.FirmamentV2.FirmamentConstruct("Hole", "Hole")]+ [Aetheris.Kernel.Firmament.FirmamentV2.FirmamentField("Diameter", "Diameter", Aetheris.Kernel.Firmament.FirmamentV2.FirmamentSchemaValueKind.Length, SourceEditable = true)]+ public class HoleSpec { }+ """;+ Assert.Contains(Generate(Prelude + source).Diagnostics, d => d.Id == "FMS001" && d.Severity == DiagnosticSeverity.Error);+ }++ [Fact]+ public void StaticProjectorEmitsTypedGeneratedGetter()+ {+ const string source = """+ public sealed class HoleInstance { public double Diameter { get; init; } }+ [Aetheris.Kernel.Firmament.FirmamentV2.FirmamentConstruct("Hole", "Hole")]+ [Aetheris.Kernel.Firmament.FirmamentV2.FirmamentField("Diameter", "Diameter", Aetheris.Kernel.Firmament.FirmamentV2.FirmamentSchemaValueKind.Length, SourceEditable = true, ProjectionMember = nameof(ProjectDiameter))]+ public class HoleSpec { public static double ProjectDiameter(HoleInstance instance) => instance.Diameter; }+ """;+ var generated = Generate(Prelude + source);+ Assert.DoesNotContain(generated.Diagnostics, d => d.Severity == DiagnosticSeverity.Error);+ Assert.Contains("ProjectHoleDiameter(global::HoleInstance instance)", generated.Source);+ }+private static (string Source, IReadOnlyList<Diagnostic> Diagnostics) Generate(string source){var references = ((string)AppContext.GetData("TRUSTED_PLATFORM_ASSEMBLIES")!).Split(Path.PathSeparator)diff --git a/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentFieldProjection.cs b/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentFieldProjection.csnew file mode 100644index 00000000..06f6b3c7--- /dev/null+++ b/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentFieldProjection.cs@@ -0,0 +1,188 @@+using System.Globalization;+using System.Security.Cryptography;+using System.Text;+using Aetheris.Kernel.Firmament.Materializer;++namespace Aetheris.Kernel.Firmament.FirmamentV2;++public sealed record FirmamentProjectedValue(string ValueKind, string Text, double? Number = null,+ IReadOnlyList<double>? Components = null, string? Unit = null);+public sealed record FirmamentFieldProjection(FirmamentFieldId FieldId, string Name, FirmamentSchemaValueKind Kind,+ FirmamentUnitKind Unit, FirmamentProjectedValue? EffectiveValue, string? AuthoredValue,+ string Origin, FirmamentV2SourceSpan? DeclarationSpan, FirmamentV2SourceSpan? ValueSpan,+ bool Editable, string? ReadOnlyReason);+public sealed record FirmamentConstructProjection(FirmamentConstructId ConstructId, string SemanticId,+ string SourceDocument, string SourceRevision, int BuildRevision, FirmamentV2SourceSpan? ConstructSpan,+ IReadOnlyList<FirmamentFieldProjection> Fields);+public sealed record FirmamentFieldRewrite(bool Success, string? NewSource, string? NewSourceRevision,+ FirmamentV2SourceSpan? ReplacedSpan, string? Replacement, string? Code, string? Message);++/// <summary>Static, typed projection of canonical bound Box/Hole values. Parser-owned spans are the+/// only rewrite authority; compatibility and noncanonical forms remain source-only.</summary>+public static class FirmamentFieldProjector+{+ public const string Version = "firmament-field-projection/1";+ public static string RevisionOf(string source)+ => Convert.ToHexString(SHA256.HashData(Encoding.UTF8.GetBytes(source))).ToLowerInvariant();++ public static IReadOnlyList<FirmamentConstructProjection> Project(FirmamentV2Document document,+ string source, string sourceDocument, int buildRevision)+ {+ var revision = RevisionOf(source);+ var result = new List<FirmamentConstructProjection>();+ foreach (var solid in document.Solids)+ {+ if (solid.Box is not { } box || solid.SourceSpan is null) continue;+ var schema = FirmamentSemanticSchemas.Get("Box")!;+ result.Add(new(schema.Id, solid.Name, sourceDocument, revision, buildRevision, solid.SourceSpan,+ schema.Fields.Select(field => ProjectBoxField(field, box, solid.AuthoredFields, source)).ToArray()));+ }+ foreach (var block in document.ModifyBlocks ?? [])+ foreach (var hole in block.SemanticHoles)+ {+ if (hole.SourceSpan is null) continue;+ var schema = FirmamentSemanticSchemas.Get("Hole")!;+ result.Add(new(schema.Id, $"{block.TargetSolid}.{hole.Name}", sourceDocument, revision, buildRevision, hole.SourceSpan,+ schema.Fields.Select(field => ProjectHoleField(field, hole, source)).ToArray()));+ }+ return result;+ }++ public static IReadOnlyList<FirmamentConstructProjection> ProjectWireForm(WireFormFeatureAir feature,+ string source, string sourceDocument, int buildRevision)+ {+ var schema = FirmamentSemanticSchemas.Get("Helix")!;+ var revision = RevisionOf(source);+ var result = new List<FirmamentConstructProjection>();+ foreach (var coil in feature.Operations.OfType<WireAxisCoilAir>())+ {+ var provenance = feature.AuthoredOperations?.ElementAtOrDefault(coil.Ordinal - 1);+ if (provenance is null || provenance.Name != coil.Name) continue;+ result.Add(new(schema.Id, coil.StableId(feature.Name), sourceDocument, revision, buildRevision, provenance.ConstructSpan,+ schema.Fields.Select(field => ProjectHelixField(field, coil, provenance.Fields, source)).ToArray()));+ }+ return result;+ }++ public static FirmamentConstructProjection? ProjectLoft(SectionChainAuthoringResult result,+ string source, string sourceDocument, int buildRevision)+ {+ if (!result.IsSuccess || result.LoftBinding is not { } binding) return null;+ var schema = FirmamentSemanticSchemas.Get("Loft")!;+ return new(schema.Id, binding.Name, sourceDocument, RevisionOf(source), buildRevision,+ binding.ConstructSpan,+ schema.Fields.Select(field => ProjectLoftField(field, binding, source)).ToArray());+ }++ public static FirmamentFieldRewrite Rewrite(string source, string sourceRevision,+ FirmamentConstructProjection construct, FirmamentFieldId fieldId, FirmamentProjectedValue next)+ {+ if (sourceRevision != RevisionOf(source) || construct.SourceRevision != sourceRevision)+ return Refuse("stale_revision", "The source changed since this field was projected.");+ var field = construct.Fields.SingleOrDefault(item => item.FieldId == fieldId);+ if (field is null) return Refuse("field_not_found", "The selected semantic field was not projected.");+ if (!field.Editable || field.ValueSpan is null)+ return Refuse("field_readonly", field.ReadOnlyReason ?? "This field has no safe source literal.");+ if (construct.ConstructId.Value != "Hole" || fieldId.Value != "Hole.Diameter")+ return Refuse("field_readonly", "This field has no supported source rewrite.");+ if (next.ValueKind != "Length" || next.Unit != "mm" || next.Number is not { } value ||+ !double.IsFinite(value) || value <= 0d)+ return Refuse("invalid_value", "Diameter requires a positive finite length in mm.");+ var span = field.ValueSpan;+ if (span.Start < 0 || span.Length <= 0 || span.Start + span.Length > source.Length ||+ source.Substring(span.Start, span.Length) != field.AuthoredValue)+ return Refuse("stale_revision", "The projected literal no longer matches the source.");+ var replacement = value.ToString("R", CultureInfo.InvariantCulture) + "mm";+ var rewritten = source[..span.Start] + replacement + source[(span.Start + span.Length)..];+ return new(true, rewritten, RevisionOf(rewritten), span, replacement, null, null);+ }++ private static FirmamentFieldProjection ProjectBoxField(FirmamentFieldSchema field,+ FirmamentV2BoxRecord box, IReadOnlyList<FirmamentV2AuthoredField>? fields, string source)+ {+ var effective = field.Id.Value == "Box.Size"+ ? new FirmamentProjectedValue("Vector", string.Join(" × ", box.Size.Select(Format)) + " mm", Components: box.Size, Unit: "mm")+ : null;+ return Make(field, effective, fields, source, false, "Aggregate Box values are source-only in X1.");+ }++ private static FirmamentFieldProjection ProjectHoleField(FirmamentFieldSchema field,+ FirmamentV2SemanticHoleDecl hole, string source)+ {+ FirmamentProjectedValue? effective = field.Id.Value switch+ {+ "Hole.On" => new("FaceSelector", hole.EntryFace.Source),+ "Hole.Center" => new("Point", $"Point2({Format(hole.Center.U)}mm, {Format(hole.Center.V)}mm)"),+ "Hole.Diameter" => new("Length", Format(FirmamentSemanticSchemas.ProjectHoleDiameter(hole)) + " mm",+ FirmamentSemanticSchemas.ProjectHoleDiameter(hole), Unit: "mm"),+ "Hole.End" => new("String", hole.EndCondition.Kind == FirmamentV2SemanticHoleEndKind.ThroughAll+ ? "ThroughAll" : $"{hole.EndCondition.Kind} {Format(hole.EndCondition.Depth ?? 0)} mm"),+ _ => null+ };+ return Make(field, effective, hole.AuthoredFields, source, field.Id.Value == "Hole.Diameter",+ field.Id.Value == "Hole.Diameter" ? "No direct diameter literal." : "This field is source-only in X1.");+ }++ private static FirmamentFieldProjection ProjectHelixField(FirmamentFieldSchema field,+ WireAxisCoilAir coil, IReadOnlyList<FirmamentV2AuthoredField> fields, string source)+ {+ FirmamentProjectedValue? effective = field.Id.Value switch+ {+ "Helix.Radius" => new("Length", Format(coil.RadiusMm) + " mm", coil.RadiusMm, Unit: "mm"),+ "Helix.Turns" => new("Scalar", Format(coil.Turns), coil.Turns),+ "Helix.Pitch" => new("Length", Format(coil.PitchMm) + " mm", coil.PitchMm, Unit: "mm"),+ "Helix.Height" => new("Length", Format(coil.HeightMm) + " mm", coil.HeightMm, Unit: "mm"),+ "Helix.Handedness" => new("Choice", coil.Handedness.ToString()),+ "Helix.StartPhase" => new("Angle", Format(coil.StartPhaseRadians * 180d / Math.PI) + " deg",+ coil.StartPhaseRadians * 180d / Math.PI, Unit: "deg"),+ _ => null+ };+ var projected = Make(field, effective, fields, source, false, "Helix fields are source-only in X1.");+ return projected.AuthoredValue is null && effective is not null+ ? projected with { Origin = field.Default is null ? "Derived" : "Defaulted" } : projected;+ }++ private static FirmamentFieldProjection ProjectLoftField(FirmamentFieldSchema field,+ LoftAuthoredBinding binding, string source)+ {+ FirmamentProjectedValue? effective = field.Id.Value switch+ {+ "Loft.RearProfile" => new("Profile", binding.RearProfile),+ "Loft.RearFrame" => new("ConstructionPlane", binding.RearFrame),+ "Loft.FrontProfile" => new("Profile", binding.FrontProfile),+ "Loft.FrontFrame" => new("ConstructionPlane", binding.FrontFrame),+ "Loft.Rule" => new("Choice", "Ruled"),+ "Loft.Correspondence" => new("Choice", "CommonRay"),+ "Loft.Reference" => new("Vector", "[" + string.Join(", ", binding.Reference.Select(Format)) + "]",+ Components: binding.Reference),+ "Loft.Twist" => new("Angle", Format(binding.TwistDegrees) + " deg", binding.TwistDegrees, Unit: "deg"),+ _ => null+ };+ var projected = Make(field, effective, binding.Fields, source, false, "Loft fields are source-only in X1.");+ return projected.AuthoredValue is null && effective is not null && field.Default is not null+ ? projected with { Origin = "Defaulted" } : projected;+ }++ private static FirmamentFieldProjection Make(FirmamentFieldSchema schema, FirmamentProjectedValue? effective,+ IReadOnlyList<FirmamentV2AuthoredField>? fields, string source, bool allowRewrite, string reason)+ {+ var matches = fields?.Where(item => item.Name == schema.Name).ToArray() ?? [];+ var authored = matches.Length == 1 && InRange(matches[0].ValueSpan, source)+ ? source.Substring(matches[0].ValueSpan.Start, matches[0].ValueSpan.Length) : null;+ var literal = allowRewrite && effective?.Number is { } number && authored is not null &&+ authored.EndsWith("mm", StringComparison.Ordinal) &&+ double.TryParse(authored[..^2], NumberStyles.Float, CultureInfo.InvariantCulture, out var parsed) && parsed == number;+ var editable = literal && matches.Length == 1;+ var origin = authored is not null ? "Authored" : effective is not null ? "Derived" : "Unavailable";+ return new(schema.Id, schema.Name, schema.Kind, schema.Unit, effective, authored, origin,+ authored is null ? null : matches[0].DeclarationSpan,+ authored is null ? null : matches[0].ValueSpan, editable,+ editable ? null : matches.Length > 1 ? "Duplicate field declarations cannot be edited safely." :+ authored is not null && allowRewrite ? "Authored expression is not a direct matching literal." : reason);+ }++ private static bool InRange(FirmamentV2SourceSpan span, string source)+ => span.Start >= 0 && span.Length > 0 && span.Start + span.Length <= source.Length;+ private static string Format(double value) => value.ToString("R", CultureInfo.InvariantCulture);+ private static FirmamentFieldRewrite Refuse(string code, string message) => new(false, null, null, null, null, code, message);+}diff --git a/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentLanguageService.cs b/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentLanguageService.csindex 72a9aaa6..ac1f6637 100644--- a/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentLanguageService.cs+++ b/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentLanguageService.cs@@ -6,7 +6,9 @@ namespace Aetheris.Kernel.Firmament.FirmamentV2;public sealed record FirmamentLanguageCompletion(string Document, string Revision, string Context, int ReplaceStart, int ReplaceLength,IReadOnlyList<FirmamentAuthoringField> Fields,- IReadOnlyList<string> MissingRequiredFields);+ IReadOnlyList<string> MissingRequiredFields,+ IReadOnlyList<FirmamentLanguageEntry>? Entries = null);+public sealed record FirmamentLanguageEntry(string ConstructId, string Name, string Context, string Source);/// <summary>Bounded authoring help from construct owners; no BRep or export work.</summary>public static class FirmamentLanguageService@@ -30,7 +32,14 @@ public static class FirmamentLanguageServicecontext = "Helix";}else if (LoftAuthoringParser.TryGetAuthoringFields(source, offset, out fields)) context = "Loft";- else return new(document, revision, "Unsupported", prefixStart, prefix.Length, [], []);+ else+ {+ var entries = FirmamentSemanticSchemas.All+ .Where(item => item.Name is "Helix" or "Loft" && item.Name.StartsWith(prefix, StringComparison.OrdinalIgnoreCase) && item.Entry is not null)+ .Select(item => new FirmamentLanguageEntry(item.Id.Value, item.Name, item.Context ?? string.Empty, item.Entry!)).ToArray();+ return new(document, revision, entries.Length > 0 ? "ConstructEntry" : "Unsupported",+ prefixStart, prefix.Length, [], [], entries);+ }var open = source.LastIndexOf('{', Math.Max(0, offset - 1));var body = open >= 0 ? source[(open + 1)..offset] : string.Empty;diff --git a/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2Ast.cs b/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2Ast.csindex 8a45b99a..a8fe3cc3 100644--- a/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2Ast.cs+++ b/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2Ast.cs@@ -15,6 +15,7 @@ public sealed record FirmamentV2Document(string ModelName, string Units, IReadOn}public sealed record FirmamentV2SourceSpan(int Start, int Length);+public sealed record FirmamentV2AuthoredField(string Name, FirmamentV2SourceSpan DeclarationSpan, FirmamentV2SourceSpan ValueSpan);public enum FirmamentV2PrimitiveType { Int, Float, Length, Angle, String, Bool }public enum FirmamentV2ToleranceKind { Bilateral, Asymmetric }public sealed record FirmamentV2Tolerance(FirmamentV2ToleranceKind Kind, double Plus, double Minus, string Unit, FirmamentV2PrimitiveType Type, FirmamentV2SourceSpan SourceSpan);@@ -48,7 +49,7 @@ public enum FirmamentV2ConstructionPolicy { Solid, Hollow }/// <summary>Source-owned hollow intent. This is deliberately not a Boolean tool description.</summary>public sealed record FirmamentV2HollowIntent(double WallThickness, IReadOnlyList<string> Openings, FirmamentV2SourceSpan SourceSpan);-public sealed record FirmamentV2SolidBinding(string Name, string RecordType, FirmamentV2PrimitiveRecord Primitive, string? DerivedFrom = null, IReadOnlyDictionary<string, IReadOnlyList<double>>? Overrides = null, IReadOnlyDictionary<string, string>? Provenance = null, FirmamentV2ConstructionPolicy ConstructionPolicy = FirmamentV2ConstructionPolicy.Solid, FirmamentV2HollowIntent? Hollow = null, FirmamentV2SourceSpan? SourceSpan = null)+public sealed record FirmamentV2SolidBinding(string Name, string RecordType, FirmamentV2PrimitiveRecord Primitive, string? DerivedFrom = null, IReadOnlyDictionary<string, IReadOnlyList<double>>? Overrides = null, IReadOnlyDictionary<string, string>? Provenance = null, FirmamentV2ConstructionPolicy ConstructionPolicy = FirmamentV2ConstructionPolicy.Solid, FirmamentV2HollowIntent? Hollow = null, FirmamentV2SourceSpan? SourceSpan = null, IReadOnlyList<FirmamentV2AuthoredField>? AuthoredFields = null){public bool IsDerived => !string.IsNullOrWhiteSpace(DerivedFrom);public FirmamentV2BoxRecord? Box => Primitive as FirmamentV2BoxRecord;@@ -247,7 +248,8 @@ public sealed record FirmamentV2SemanticHoleDecl(FirmamentV2ResolvedPoint3? ResolvedCenter = null,FirmamentV2SourceSpan? SourceSpan = null,FirmamentV2BoundHolePlacement? Placement = null,- FirmamentV2SemanticHoleTermination? Termination = null);+ FirmamentV2SemanticHoleTermination? Termination = null,+ IReadOnlyList<FirmamentV2AuthoredField>? AuthoredFields = null);public enum FirmamentV2PmiKind { HoleDiameter, DatumPlane, Distance, Flatness, Parallel, Perpendicular, Coplanar }public sealed record FirmamentV2PmiDecl(string Name, FirmamentV2PmiKind Kind, string Target, double? Value = null);public sealed record FirmamentV2PmiBlock(IReadOnlyList<FirmamentV2PmiRecord> Records, FirmamentV2SourceSpan SourceSpan);diff --git a/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2Parser.cs b/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2Parser.csindex a5c0c6c1..0fc4ec0e 100644--- a/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2Parser.cs+++ b/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2Parser.cs@@ -1469,7 +1469,8 @@ public static class FirmamentV2Parservar record = ParseCanonicalPrimitive(primitive.Groups["type"].Value, primitiveBody, diagnostics);if (record is null) return CanonicalFailure(diagnostics, CanonicalPrimitiveMalformed);var solid = new FirmamentV2SolidBinding(name, primitive.Groups["type"].Value, record,- SourceSpan: new FirmamentV2SourceSpan(rootOpen + 1 + primitive.Index, close - primitive.Index + 1));+ SourceSpan: new FirmamentV2SourceSpan(rootOpen + 1 + primitive.Index, close - primitive.Index + 1),+ AuthoredFields: ReadAuthoredFields(primitiveBody, rootOpen + 1 + open + 1));byName[name] = solid;solids.Add(solid);}@@ -1518,6 +1519,69 @@ public static class FirmamentV2Parserreturn FirmamentV2ParseResult.Success(new FirmamentV2Document(model.Groups["name"].Value, "mm", solids, modifies, Pmi: pmi, RecognizedRegions: recognizedRegions, Replacements: replacements, PmiBlock: pmiBlock, BoundPmi: boundPmi), diagnostics.Distinct(StringComparer.Ordinal).ToArray());}+ // Source provenance is read from lexical field boundaries, independently of the legacy+ // recognition expressions. A duplicate or unbound field is never a rewrite target.+ internal static IReadOnlyList<FirmamentV2AuthoredField> ReadAuthoredFields(string body, int baseOffset)+ {+ var result = new List<FirmamentV2AuthoredField>();+ string? name = null;+ var declarationStart = -1;+ var valueStart = -1;+ var valueEnd = -1;+ var depth = 0;+ void Finish()+ {+ if (name is not null && valueEnd >= valueStart)+ result.Add(new FirmamentV2AuthoredField(name,+ new FirmamentV2SourceSpan(baseOffset + declarationStart, valueEnd - declarationStart + 1),+ new FirmamentV2SourceSpan(baseOffset + valueStart, valueEnd - valueStart + 1)));+ }+ for (var i = 0; i < body.Length; i++)+ {+ if (body[i] == '/' && i + 1 < body.Length && body[i + 1] == '/')+ {+ i = body.IndexOf('\n', i + 2) is var lineEnd && lineEnd >= 0 ? lineEnd : body.Length;+ continue;+ }+ if (body[i] == '/' && i + 1 < body.Length && body[i + 1] == '*')+ {+ var commentEnd = body.IndexOf("*/", i + 2, StringComparison.Ordinal);+ i = commentEnd >= 0 ? commentEnd + 1 : body.Length;+ continue;+ }+ if (body[i] == '"')+ {+ var start = i++;+ while (i < body.Length && (body[i] != '"' || body[i - 1] == '\\')) i++;+ if (name is not null) valueEnd = Math.Min(i, body.Length - 1);+ continue;+ }+ if (depth == 0 && (char.IsLetter(body[i]) || body[i] == '_'))+ {+ var start = i;+ while (i + 1 < body.Length && (char.IsLetterOrDigit(body[i + 1]) || body[i + 1] == '_')) i++;+ var afterName = i + 1;+ while (afterName < body.Length && char.IsWhiteSpace(body[afterName])) afterName++;+ if (afterName < body.Length && body[afterName] == ':')+ {+ Finish();+ name = body[start..(i + 1)];+ declarationStart = start;+ valueStart = afterName + 1;+ while (valueStart < body.Length && char.IsWhiteSpace(body[valueStart])) valueStart++;+ valueEnd = valueStart - 1;+ i = afterName;+ continue;+ }+ }+ if (body[i] is '(' or '[' or '{') depth++;+ else if (body[i] is ')' or ']' or '}') depth--;+ if (name is not null && !char.IsWhiteSpace(body[i]) && body[i] != ';') valueEnd = i;+ }+ Finish();+ return result;+ }+private static FirmamentV2PrimitiveRecord? ParseCanonicalPrimitive(string type, string body, List<string> diagnostics){double Number(string field, bool allowZero = false)@@ -1586,12 +1650,13 @@ public static class FirmamentV2Parsercontinue;}- var knownFields = variant switch+ var variantFields = variant switch{- FirmamentV2SemanticHoleVariant.Counterbore => new[] { "On", "Center", "Diameter", "CounterboreDiameter", "CounterboreDepth", "End", "PatternIdentity" },- FirmamentV2SemanticHoleVariant.Countersink => new[] { "On", "Center", "Diameter", "CountersinkDiameter", "CountersinkAngle", "End", "PatternIdentity" },- _ => new[] { "On", "Center", "Diameter", "End", "PatternIdentity" }+ FirmamentV2SemanticHoleVariant.Counterbore => new[] { "CounterboreDiameter", "CounterboreDepth" },+ FirmamentV2SemanticHoleVariant.Countersink => new[] { "CountersinkDiameter", "CountersinkAngle" },+ _ => []};+ var knownFields = FirmamentSemanticSchemas.Get("Hole")!.Fields.Select(field => field.Name).Concat(variantFields).ToArray();if (CanonicalBodyHasUnknownField(holeBody, knownFields)){diagnostics.Add(CanonicalFieldUnknown);@@ -1642,7 +1707,8 @@ public static class FirmamentV2Parservar face = FirmamentV2FaceTarget.Direct(on.Groups["face"].Value);holes.Add(new(hole.Groups["name"].Value, variant, face, new FirmamentV2FaceLocalPoint2D(u, v, FirmamentV2FaceLocalPoint2D.ConventionFor(face.Axis)), shaft, endValue,counterboreDiameter, counterboreDepth, countersinkDiameter, countersinkAngle,- SourceSpan: new FirmamentV2SourceSpan(bodyOffset + hole.Index, close - hole.Index + 1)));+ SourceSpan: new FirmamentV2SourceSpan(bodyOffset + hole.Index, close - hole.Index + 1),+ AuthoredFields: ReadAuthoredFields(holeBody, bodyOffset + open + 1)));}return holes;}diff --git a/Aetheris.Kernel.Firmament/FirmamentV2/LoftAuthoringParser.cs b/Aetheris.Kernel.Firmament/FirmamentV2/LoftAuthoringParser.csindex 8215c251..9f334a6c 100644--- a/Aetheris.Kernel.Firmament/FirmamentV2/LoftAuthoringParser.cs+++ b/Aetheris.Kernel.Firmament/FirmamentV2/LoftAuthoringParser.cs@@ -117,10 +117,14 @@ public static class LoftAuthoringParservar chain = new SectionChain(name,[new Section("Rear", rearSectionFrame, rearProfile), new Section("Front", frontSectionFrame, frontProfile)],[], SectionTransitionPolicy.Ruled, SectionTermination.Cap, SectionTermination.Cap, SectionChainContinuity.G0);- if (!materialize) return new(true, chain, null, []);+ var binding = new LoftAuthoredBinding(name, rearProfileName!, rearFrameName!, frontProfileName!, frontFrameName!,+ [reference.X, reference.Y, reference.Z], twistDegrees,+ new FirmamentV2SourceSpan(declaration.Index, close - declaration.Index + 1),+ FirmamentV2Parser.ReadAuthoredFields(body, open + 1));+ if (!materialize) return new(true, chain, null, [], binding);var result = SectionChainMaterializer.Materialize(chain);if (!result.IsSuccess) diagnostics.AddRange(result.Diagnostics.Select(item => $"{item.Code}:{item.Message}"));- return new(result.IsSuccess, chain, result, diagnostics);+ return new(result.IsSuccess, chain, result, diagnostics, result.IsSuccess ? binding : null);SectionChainAuthoringResult Fail(params string[] messages) => new(false, null, null,diagnostics.Concat(messages).Distinct(StringComparer.Ordinal).ToArray());diff --git a/Aetheris.Kernel.Firmament/FirmamentV2/SectionChainAuthoringParser.cs b/Aetheris.Kernel.Firmament/FirmamentV2/SectionChainAuthoringParser.csindex c99bc8a6..07f1aaeb 100644--- a/Aetheris.Kernel.Firmament/FirmamentV2/SectionChainAuthoringParser.cs+++ b/Aetheris.Kernel.Firmament/FirmamentV2/SectionChainAuthoringParser.cs@@ -8,7 +8,12 @@ public sealed record SectionChainAuthoringResult(bool IsSuccess,SectionChain? Chain,SectionChainMaterializationResult? Materialization,- IReadOnlyList<string> Diagnostics);+ IReadOnlyList<string> Diagnostics,+ LoftAuthoredBinding? LoftBinding = null);++public sealed record LoftAuthoredBinding(string Name, string RearProfile, string RearFrame,+ string FrontProfile, string FrontFrame, IReadOnlyList<double> Reference, double TwistDegrees,+ FirmamentV2SourceSpan ConstructSpan, IReadOnlyList<FirmamentV2AuthoredField> Fields);/// <summary>/// Domain binder for Firmament SectionChain declarations. Profiles remain ordinarydiff --git a/Aetheris.Kernel.Firmament/FirmamentV2/SemanticConstructDeclarations.cs b/Aetheris.Kernel.Firmament/FirmamentV2/SemanticConstructDeclarations.csindex 25538b5e..cd61a864 100644--- a/Aetheris.Kernel.Firmament/FirmamentV2/SemanticConstructDeclarations.cs+++ b/Aetheris.Kernel.Firmament/FirmamentV2/SemanticConstructDeclarations.cs@@ -9,13 +9,16 @@ public static class BoxSemanticDeclaration { }[FirmamentConstruct("Hole", "Hole", Context = "Modify body", Entry = "Modify Body { Hole<Shaft> H { On: +Z; Center: Point2(0mm, 0mm); Diameter: 6mm; End: ThroughAll } }", Description = "Semantic drilled hole.")][FirmamentField("On", "On", FirmamentSchemaValueKind.FaceSelector, Required = true, Description = "Entry face of the hole.")][FirmamentField("Center", "Center", FirmamentSchemaValueKind.Point, Required = true, Description = "Center in the support face.")]-[FirmamentField("Diameter", "Diameter", FirmamentSchemaValueKind.Length, Required = true, Description = "Shaft diameter.")]+[FirmamentField("Diameter", "Diameter", FirmamentSchemaValueKind.Length, Required = true, Description = "Shaft diameter.", SourceEditable = true, ProjectionMember = nameof(ProjectDiameter))][FirmamentField("End", "End", FirmamentSchemaValueKind.String, Required = true, Description = "ThroughAll or a blind termination expression.")][FirmamentField("PatternIdentity", "PatternIdentity", FirmamentSchemaValueKind.String, Description = "Optional pattern identity.")][FirmamentOutput("Wall", "Wall", "Face", SourceAddressable = true, SourceRole = nameof(Materializer.SemanticTopologyRole.HoleWallFace))]-public static class HoleSemanticDeclaration { }+public static class HoleSemanticDeclaration+{+ public static double ProjectDiameter(FirmamentV2SemanticHoleDecl instance) => instance.ShaftDiameter;+}-[FirmamentConstruct("Helix", "Helix", Context = "WireForm", Entry = "WireForm Spring { Diameter: 1mm; Origin: [0mm, 0mm, 0mm]; Tangent: [0, 0, 1]; Up: [0, 1, 0]; Helix Winding { Radius: 5mm; Turns: 4; Pitch: 2mm } }", CompatibilityAlias = "AxisCoil", Description = "WireForm centerline helix.")]+[FirmamentConstruct("Helix", "Helix", Context = "WireForm", Entry = "Model HelixWitness {\n Units: mm\n WireForm Spring {\n Diameter: 2mm\n Material: Standard.Materials.StainlessSteel.304_Annealed\n StartFrame { Origin: [0mm, 0mm, 0mm]; Tangent: [1, 0, 0]; Up: [0, 0, 1] }\n Helix Winding { Radius: 6mm; Turns: 1; Pitch: 5mm; Handedness: RightHanded; StartPhase: 0deg }\n }\n}\n", CompatibilityAlias = "AxisCoil", Description = "WireForm centerline helix.")][FirmamentField("Radius", "Radius", FirmamentSchemaValueKind.Length, Required = true, Description = "Centerline radius.")][FirmamentField("Turns", "Turns", FirmamentSchemaValueKind.Scalar, Required = true, Description = "Number of winding turns.")][FirmamentField("Pitch", "Pitch", FirmamentSchemaValueKind.Length, Description = "Axial distance per turn; supply Pitch or Height.")]@@ -24,7 +27,7 @@ public static class HoleSemanticDeclaration { }[FirmamentField("StartPhase", "StartPhase", FirmamentSchemaValueKind.Angle, Default = "0deg", Description = "Starting radial rotation.")]public static class HelixSemanticDeclaration { }-[FirmamentConstruct("Loft", "Loft", Context = "Model with two authored profiles and frames", Entry = "Loft Body { RearProfile: Rear; RearFrame: RearPlane; FrontProfile: Front; FrontFrame: FrontPlane; Rule: Ruled; Correspondence: CommonRay; Reference: [1, 0, 0] }", Description = "Two-section ruled loft.")]+[FirmamentConstruct("Loft", "Loft", Context = "Model with two authored profiles and frames", Entry = "schema SectionChain\nModel RuledSolidLoft {\n Units: mm\n Concept Struct Stations {\n Lower: Plane { Origin: [0mm, 0mm, 0mm]; Normal: [0, 0, 1]; Up: [0, 1, 0] }\n Upper: Plane { Origin: [0mm, 0mm, 50mm]; Normal: [0, 0, 1]; Up: [0, 1, 0] }\n }\n Construction Plane LowerFrame { Trace: Stations.Lower }\n Construction Plane UpperFrame { Trace: Stations.Upper }\n Circle2 LowerCircle { Center: [0mm, 0mm] Radius: 25mm }\n Ellipse2 UpperEllipse { Center: [0mm, 0mm] AxisLengths: [60mm, 40mm] Rotation: 25deg }\n Profile LowerOutline { Loop Outer { LowerCircle |> TraceLoop } }\n Profile UpperOutline { Loop Outer { UpperEllipse |> TraceLoop } }\n Loft Body {\n RearProfile: LowerOutline\n RearFrame: LowerFrame\n FrontProfile: UpperOutline\n FrontFrame: UpperFrame\n Rule: Ruled\n Correspondence: CommonRay\n Reference: [1, 0, 0]\n }\n}\n", Description = "Two-section ruled loft.")][FirmamentField("RearProfile", "RearProfile", FirmamentSchemaValueKind.Profile, Required = true, Description = "Closed rear section profile.")][FirmamentField("RearFrame", "RearFrame", FirmamentSchemaValueKind.ConstructionPlane, Required = true, Description = "Placement of the rear section.")][FirmamentField("FrontProfile", "FrontProfile", FirmamentSchemaValueKind.Profile, Required = true, Description = "Closed front section profile.")]diff --git a/Aetheris.Kernel.Firmament/FirmamentV2/SemanticSchema.cs b/Aetheris.Kernel.Firmament/FirmamentV2/SemanticSchema.csindex 60f7afc0..b7caeb1e 100644--- a/Aetheris.Kernel.Firmament/FirmamentV2/SemanticSchema.cs+++ b/Aetheris.Kernel.Firmament/FirmamentV2/SemanticSchema.cs@@ -26,6 +26,8 @@ public sealed class FirmamentFieldAttribute(string stableId, string name, Firmampublic string? Default { get; init; }public string? Description { get; init; }public string[]? Choices { get; init; }+ public bool SourceEditable { get; init; }+ public string? ProjectionMember { get; init; }}[AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]diff --git a/Aetheris.Kernel.Firmament/Materializer/WireForm.cs b/Aetheris.Kernel.Firmament/Materializer/WireForm.csindex 153493b4..7491523e 100644--- a/Aetheris.Kernel.Firmament/Materializer/WireForm.cs+++ b/Aetheris.Kernel.Firmament/Materializer/WireForm.cs@@ -89,7 +89,8 @@ public sealed record WireSurfaceCoilAir(string Name, int Ordinal, string Support/// <summary>WireForm semantic AIR. Bend radii are centerline radii.</summary>public sealed record WireFormFeatureAir(string Name, double DiameterMm, string MaterialReference, ResolvedMaterial Material,- WireState StartState, IReadOnlyList<WireFormOperationAir> Operations, string FrameTransportPolicy)+ WireState StartState, IReadOnlyList<WireFormOperationAir> Operations, string FrameTransportPolicy,+ IReadOnlyList<WireFormOperationProvenance>? AuthoredOperations = null){public double WireRadiusMm => DiameterMm / 2d;public double TotalStraightLengthMm => Operations.OfType<WireStraightAir>().Sum(x => x.LengthMm);@@ -99,6 +100,9 @@ public sealed record WireFormFeatureAir(string Name, double DiameterMm, string Mpublic WireState EndState => Operations.Count == 0 ? StartState : Operations[^1].Output;}+public sealed record WireFormOperationProvenance(string Name, FirmamentV2SourceSpan ConstructSpan,+ IReadOnlyList<FirmamentV2AuthoredField> Fields);+public sealed record WireFormBuildResult(WireFormFeatureAir Feature, BrepBody Body, double VolumeMm3,double MassKilograms, IReadOnlyList<double> Bounds, IReadOnlyList<string> ValidationEvidence);@@ -163,6 +167,7 @@ public static class WireFormAuthoringvar state = new WireState(new(origin.X, origin.Y, origin.Z), tangent, up, 0d);var operations = new List<WireFormOperationAir>();+ var provenance = new List<WireFormOperationProvenance>();foreach (Match match in Operation.Matches(body)){var operationOpen = body.IndexOf('{', match.Index);@@ -170,6 +175,9 @@ public static class WireFormAuthoringif (operationClose < 0) return Fail("wireform-operation-malformed", $"Operation '{match.Groups["name"].Value}' has no closing brace.");var operationBody = body[(operationOpen + 1)..operationClose];var operationName = match.Groups["name"].Value;+ provenance.Add(new(operationName,+ new FirmamentV2SourceSpan(open + 1 + match.Index, operationClose - match.Index + 1),+ FirmamentV2Parser.ReadAuthoredFields(operationBody, open + 1 + operationOpen + 1)));var ordinal = operations.Count + 1;if (match.Groups["kind"].Value == "Straight"){@@ -228,7 +236,7 @@ public static class WireFormAuthoringvar authoredStart = new WireState(new(origin.X, origin.Y, origin.Z), tangent, up, 0d);return KernelResult<WireFormFeatureAir>.Success(new(name, diameter, materialReference, material.Material,operations[0] is WireKnotPathAir ? operations[0].Input : authoredStart, operations,- operations[0] is WireKnotPathAir knot ? knot.FrameClosure.Policy : FrameTransportPolicy));+ operations[0] is WireKnotPathAir knot ? knot.FrameClosure.Policy : FrameTransportPolicy, provenance));}internal static string? Property(string body, string name)diff --git a/Aetheris.Web.Runtime/Program.cs b/Aetheris.Web.Runtime/Program.csindex 5031d7bd..0804eb1e 100644--- a/Aetheris.Web.Runtime/Program.cs+++ b/Aetheris.Web.Runtime/Program.cs@@ -11,6 +11,7 @@ using Aetheris.Kernel.Core.Step242;using Aetheris.Kernel.Firmament;using Aetheris.Kernel.Firmament.Assembly;using Aetheris.Kernel.Firmament.FirmamentV2;+using Aetheris.Kernel.Firmament.Materializer;namespace Aetheris.Web.Runtime;@@ -36,6 +37,8 @@ public static partial class Program"compile" => Compile(request),"languageComplete" => LanguageComplete(request),"languageSchema" => LanguageSchema(),+ "describeConstruct" => DescribeConstruct(request),+ "rewriteField" => RewriteField(request),"snapshot" => Session(request).Snapshot,"setProperty" => SetProperty(request),"setSource" => SetSource(request),@@ -94,6 +97,7 @@ public static partial class Programprivate static object LanguageSchema() => new{version = FirmamentSemanticSchemas.Version,+ projectionVersion = FirmamentFieldProjector.Version,constructs = FirmamentSemanticSchemas.All.Select(construct => new{id = construct.Id.Value, construct.Name, construct.Context, construct.Entry,@@ -127,6 +131,22 @@ public static partial class Programreturn new { accepted = true, revision = session.Revision, dirty = true };}+ private static object DescribeConstruct(WebRequest request)+ {+ if (string.IsNullOrWhiteSpace(request.ConstructSemanticId))+ throw new WebRuntimeException("construct-required", "describeConstruct requires a semantic ID.");+ return Session(request).DescribeConstruct(request.ConstructSemanticId);+ }++ private static object RewriteField(WebRequest request)+ {+ if (request.Source is null || string.IsNullOrWhiteSpace(request.SourceRevision) ||+ string.IsNullOrWhiteSpace(request.ConstructSemanticId) || string.IsNullOrWhiteSpace(request.FieldId) ||+ request.FieldValue is null || request.BuildRevision is null)+ throw new WebRuntimeException("rewrite-input-required", "rewriteField requires source, revisions, semantic ID, field ID, and a typed value.");+ return Session(request).RewriteField(request);+ }+private static object Rebuild(WebRequest request) => Session(request).Rebuild();private static object ExportStep(WebRequest request)@@ -154,7 +174,8 @@ public static partial class Programprivate sealed record WebRequest(string Operation, string? SessionId = null, string? Source = null,string? SourceName = null, string? PropertyId = null, WebPropertyValue? Value = null,- string? SourceRevision = null, int? Offset = null);+ string? SourceRevision = null, int? Offset = null, string? ConstructSemanticId = null,+ string? FieldId = null, FirmamentProjectedValue? FieldValue = null, int? BuildRevision = null);private sealed class WebRuntimeException(string code, string message) : Exception(message){@@ -166,6 +187,7 @@ public static partial class Programprivate string _source = source;private string _sourceName = sourceName;private IReadOnlyList<WebProperty> _properties = [];+ private IReadOnlyList<FirmamentConstructProjection> _projections = [];private readonly Dictionary<string, WebPropertyValue> _overrides = new(StringComparer.Ordinal);private object? _lastSnapshot;public string Id { get; } = id;@@ -179,6 +201,46 @@ public static partial class Program_source = nextSource;if (!string.IsNullOrWhiteSpace(nextSourceName)) _sourceName = nextSourceName;_overrides.Clear();+ _projections = [];+ }++ public object DescribeConstruct(string semanticId)+ {+ var projection = _projections.SingleOrDefault(item => item.SemanticId == semanticId);+ if (projection is null) throw new WebRuntimeException("construct-not-projected", $"No current field projection exists for '{semanticId}'.");+ return new+ {+ version = FirmamentFieldProjector.Version,+ constructId = projection.ConstructId.Value, semanticId = projection.SemanticId,+ sourceRevision = projection.SourceRevision, buildRevision = projection.BuildRevision,+ source = projection.ConstructSpan is { } span ? SourceRefAt(projection.SourceDocument, _source, span.Start, span.Length) : null,+ outputs = FirmamentSemanticSchemas.Get(projection.ConstructId.Value)!.Outputs.Select(item => new+ {+ id = item.Id.Value, item.Name, item.Kind, item.SourceAddressable, item.SourceRole+ }),+ fields = projection.Fields.Select(field => new+ {+ fieldId = field.FieldId.Value, name = field.Name, kind = field.Kind.ToString(), unit = field.Unit.ToString(),+ effectiveValue = field.EffectiveValue, authoredValue = field.AuthoredValue, origin = field.Origin,+ declaration = field.DeclarationSpan is { } declaration ? SourceRefAt(projection.SourceDocument, _source, declaration.Start, declaration.Length) : null,+ source = field.ValueSpan is { } value ? SourceRefAt(projection.SourceDocument, _source, value.Start, value.Length) : null,+ field.Editable, field.ReadOnlyReason+ })+ };+ }++ public object RewriteField(WebRequest request)+ {+ if (request.Source != _source || request.BuildRevision != Revision)+ throw new WebRuntimeException("stale_revision", "The requested source or build revision is stale.");+ var construct = _projections.SingleOrDefault(item => item.SemanticId == request.ConstructSemanticId);+ if (construct is null) throw new WebRuntimeException("construct-not-projected", "The construct has no current field projection.");+ var result = FirmamentFieldProjector.Rewrite(_source, request.SourceRevision!, construct,+ new FirmamentFieldId(request.FieldId!), request.FieldValue!);+ if (!result.Success) throw new WebRuntimeException(result.Code!, result.Message!);+ return new { source = result.NewSource, sourceRevision = result.NewSourceRevision,+ replaced = SourceRefAt(_sourceName, _source, result.ReplacedSpan!.Start, result.ReplacedSpan.Length),+ replacement = result.Replacement };}public void SetProperty(string propertyId, WebPropertyValue value)@@ -211,6 +273,7 @@ public static partial class ProgramRevision++;_properties = nextProperties;+ _projections = compiled.Projections ?? [];StepText = compiled.StepText;var changes = new{@@ -257,19 +320,40 @@ public static partial class Program? SourceRefAt(_sourceName, effective, span.Start, span.Length) : null;var boxSource = CompilerSource(entityId);// Preserve the exported body category in Kind; report the authored construct separately.- var semanticConstruct = boxSource is null ? null : FirmamentV2Parser.Parse(effective).Document?.Solids+ var parsed = FirmamentV2Parser.Parse(effective);+ var semanticConstruct = boxSource is null ? null : parsed.Document?.Solids.FirstOrDefault(solid => string.Equals(solid.Name, entityId, StringComparison.Ordinal))?.RecordType;+ IReadOnlyList<FirmamentConstructProjection> projections = _overrides.Count == 0 && parsed.Document is { } document+ ? FirmamentFieldProjector.Project(document, effective, _sourceName, Revision + 1) : [];+ if (_overrides.Count == 0 && build.Value.WireForm is not null)+ {+ var wire = WireFormAuthoring.Parse(effective);+ if (wire.IsSuccess && wire.Value is not null)+ projections = [.. projections, .. FirmamentFieldProjector.ProjectWireForm(wire.Value, effective, _sourceName, Revision + 1)];+ }+ if (_overrides.Count == 0 && build.Value.ExportedBodyCategory == "section-chain" && LoftAuthoringParser.IsLoftSource(effective))+ {+ var loft = LoftAuthoringParser.Compile(effective, materialize: false);+ if (FirmamentFieldProjector.ProjectLoft(loft, effective, _sourceName, Revision + 1) is { } projection)+ projections = [.. projections, projection];+ }+ semanticConstruct ??= projections.FirstOrDefault(item => item.SemanticId == entityId)?.ConstructId.Value;var featureSources = (build.Value.Features ?? []).ToDictionary(feature => feature.FeatureId,feature => CompilerSource(feature.FeatureId), StringComparer.Ordinal);var mesh = WebMeshBuilder.Build(Name, definitionId, entityId, displayBody,build.Value.RuntimeCorrespondence, boxSource, Revision + 1, featureSources);var meshMs = watch.Elapsed.TotalMilliseconds;- var featureNodes = (build.Value.EngineeringFeatures ?? []).Select(feature => new WebTreeNode(feature.FeatureId, feature.Kind, feature.Name, entityId, [], true, null))+ var featureNodes = (build.Value.EngineeringFeatures ?? []).Select(feature => new WebTreeNode(feature.FeatureId, feature.Kind, feature.Name, entityId, [], true,+ projections.FirstOrDefault(item => item.SemanticId == feature.FeatureId)?.ConstructSpan is { } span+ ? SourceRefAt(_sourceName, effective, span.Start, span.Length) : null)).Concat((build.Value.Features ?? []).Select(feature => new WebTreeNode(feature.FeatureId, feature.Kind, feature.Name, entityId, [], true, featureSources[feature.FeatureId], feature.Diameter))).ToArray();- var body = new WebTreeNode(entityId, build.Value.ExportedBodyCategory, Name, Id, featureNodes.Select(item => item.Id).ToArray(), true, boxSource ?? SourceRef(_sourceName, 0, effective.Length), SemanticConstruct: semanticConstruct);+ var projectedBodySource = projections.FirstOrDefault(item => item.SemanticId == entityId)?.ConstructSpan is { } bodySpan+ ? SourceRefAt(_sourceName, effective, bodySpan.Start, bodySpan.Length) : null;+ var body = new WebTreeNode(entityId, build.Value.ExportedBodyCategory, Name, Id, featureNodes.Select(item => item.Id).ToArray(), true,+ boxSource ?? projectedBodySource ?? SourceRef(_sourceName, 0, effective.Length), SemanticConstruct: semanticConstruct);var root = new WebTreeNode(Id, "Model", Name, null, [body.Id], true, SourceRef(_sourceName, 0, effective.Length));var tree = new { rootId = root.Id, nodes = new[] { root, body }.Concat(featureNodes).ToArray() };- return WebBuildResult.Passed(step, tree, mesh, [Id, entityId, .. featureNodes.Select(item => item.Id)], compileMs, meshMs);+ return WebBuildResult.Passed(step, tree, mesh, [Id, entityId, .. featureNodes.Select(item => item.Id)], compileMs, meshMs) with { Projections = projections };}private WebBuildResult CompileAssembly(string effective, List<WebProperty> properties)@@ -443,7 +527,8 @@ internal sealed record WebProperty(string Id, string OwnerEntityId, string Name,internal sealed record WebTreeNode(string Id, string Kind, string Name, string? ParentId, IReadOnlyList<string> Children, bool Visible, WebSourceRef? Source, double? HoleDiameterMm = null, string? SemanticConstruct = null);internal sealed record WebDiagnostic(string Severity, string Code, string Message, WebSourceRef? Source = null, string? Details = null);internal sealed record WebBuildResult(bool Success, int Revision, object? Model, IReadOnlyList<WebDiagnostic> Diagnostics, bool RetainedPreviousGeometry,- object? Tree = null, object? Mesh = null, IReadOnlyList<string>? EntityIds = null, object? Timings = null, object? Changes = null, string? StepText = null)+ object? Tree = null, object? Mesh = null, IReadOnlyList<string>? EntityIds = null, object? Timings = null, object? Changes = null, string? StepText = null,+ IReadOnlyList<FirmamentConstructProjection>? Projections = null){public static WebBuildResult Failed(IReadOnlyList<WebDiagnostic> diagnostics, double compileMs) => new(false, 0, null, diagnostics, false, Timings: new { compileMilliseconds = compileMs });public static WebBuildResult Passed(string step, object tree, object mesh, IReadOnlyList<string> ids, double compileMs, double meshMs) => new(true, 0, null, [], false, tree, mesh, ids, new { compileMilliseconds = compileMs, meshMilliseconds = meshMs }, StepText: step);diff --git a/Aetheris.Web.Runtime/sdk/src/index.d.ts b/Aetheris.Web.Runtime/sdk/src/index.d.tsindex 2ec78b61..a253e86f 100644--- a/Aetheris.Web.Runtime/sdk/src/index.d.ts+++ b/Aetheris.Web.Runtime/sdk/src/index.d.ts@@ -21,11 +21,16 @@ export interface OperationOptions { readonly signal?: AbortSignal }export interface CompileOptions extends OperationOptions { readonly sourceName?: string }export interface LanguageOptions { readonly sourceName?: string; readonly sourceRevision: string }export interface LanguageField { readonly name: string; readonly type: string; readonly required: boolean; readonly meaning: string; readonly default?: string | null; readonly choices?: readonly string[] | null }-export interface LanguageCompletion { readonly document: string; readonly revision: string; readonly context: string; readonly replaceStart: number; readonly replaceLength: number; readonly fields: readonly LanguageField[]; readonly missingRequiredFields: readonly string[] }+export interface LanguageEntry { readonly constructId: string; readonly name: string; readonly context: string; readonly source: string }+export interface LanguageCompletion { readonly document: string; readonly revision: string; readonly context: string; readonly replaceStart: number; readonly replaceLength: number; readonly fields: readonly LanguageField[]; readonly missingRequiredFields: readonly string[]; readonly entries?: readonly LanguageEntry[] | null }export interface SemanticFieldSchema { readonly id: string; readonly name: string; readonly kind: string; readonly unit: 'None' | 'Length' | 'Angle'; readonly required: boolean; readonly default: string | null; readonly choices: readonly string[]; readonly description: string | null; readonly sourceEditable: boolean }export interface SemanticOutputSchema { readonly id: string; readonly name: string; readonly kind: string; readonly sourceAddressable: boolean; readonly sourceRole: string | null }export interface SemanticConstructSchema { readonly id: string; readonly name: string; readonly context: string | null; readonly entry: string | null; readonly description: string | null; readonly compatibilityAlias: string | null; readonly fields: readonly SemanticFieldSchema[]; readonly outputs: readonly SemanticOutputSchema[] }-export interface SemanticSchema { readonly version: 'firmament-semantic-schema/1'; readonly constructs: readonly SemanticConstructSchema[] }+export interface SemanticSchema { readonly version: 'firmament-semantic-schema/1'; readonly projectionVersion: 'firmament-field-projection/1'; readonly constructs: readonly SemanticConstructSchema[] }+export interface ProjectedValue { readonly valueKind: string; readonly text: string; readonly number?: number | null; readonly components?: readonly number[] | null; readonly unit?: string | null }+export interface FieldProjection { readonly fieldId: string; readonly name: string; readonly kind: string; readonly unit: string; readonly effectiveValue: ProjectedValue | null; readonly authoredValue: string | null; readonly origin: 'Authored' | 'Defaulted' | 'Derived' | 'Inherited' | 'Unavailable'; readonly declaration: SourceReference | null; readonly source: SourceReference | null; readonly editable: boolean; readonly readOnlyReason: string | null }+export interface ConstructProjection { readonly version: 'firmament-field-projection/1'; readonly constructId: string; readonly semanticId: string; readonly sourceRevision: string; readonly buildRevision: number; readonly source: SourceReference | null; readonly fields: readonly FieldProjection[]; readonly outputs: readonly SemanticOutputSchema[] }+export interface FieldRewrite { readonly source: string; readonly sourceRevision: string; readonly replaced: SourceReference; readonly replacement: string }export interface SelectorCandidate { readonly selector: string; readonly kind: string; readonly semanticKey: string | null; readonly outputRole: string | null; readonly source: SourceReference; readonly qualification: SourceAddressability; readonly buildRevision: number }export interface AetherisOptions { readonly worker?: boolean; readonly wasmUrl?: string | URL; readonly diagnostics?: (diagnostics: readonly Diagnostic[]) => void }export class AetherisError extends Error { readonly code: string; readonly details?: string }@@ -45,6 +50,8 @@ export class ModelSession {property(id: string): EditableProperty | undefined;setProperty(propertyId: string, value: UnitValue, options?: OperationOptions): Promise<RebuildResult>;setSource(source: string, options?: CompileOptions): Promise<RebuildResult>;+ describeConstruct(semanticId: string, options?: OperationOptions): Promise<ConstructProjection>;+ rewriteField(source: string, projection: ConstructProjection, fieldId: string, value: ProjectedValue, options?: OperationOptions): Promise<FieldRewrite>;rebuild(options?: OperationOptions): Promise<RebuildResult>;resolveSelection(definitionId: string, triangleIndex: number, occurrenceId?: string): Omit<SelectionDescription, 'sourceAddressable'> | null;describeSelection(definitionId: string, triangleIndex: number, occurrenceId?: string): SelectionDescription | null;diff --git a/Aetheris.Web.Runtime/sdk/src/index.js b/Aetheris.Web.Runtime/sdk/src/index.jsindex f4424eee..d78f72f0 100644--- a/Aetheris.Web.Runtime/sdk/src/index.js+++ b/Aetheris.Web.Runtime/sdk/src/index.js@@ -106,6 +106,16 @@ export class ModelSession {async setSource(source, options = {}) {return this.serial(async () => { throwIfAborted(options.signal); await this.transport.request({ operation: 'setSource', sessionId: this.id, source, sourceName: options.sourceName }); return this.rebuild(options); });}+ async describeConstruct(semanticId, options = {}) {+ throwIfAborted(options.signal);+ return this.transport.request({ operation: 'describeConstruct', sessionId: this.id, constructSemanticId: semanticId });+ }+ async rewriteField(source, projection, fieldId, value, options = {}) {+ throwIfAborted(options.signal);+ return this.transport.request({ operation: 'rewriteField', sessionId: this.id, source,+ sourceRevision: projection.sourceRevision, buildRevision: projection.buildRevision,+ constructSemanticId: projection.semanticId, fieldId, fieldValue: value });+ }async rebuild(options = {}) {throwIfAborted(options.signal);const result = await this.transport.request({ operation: 'rebuild', sessionId: this.id });diff --git a/docs/architecture/Compile-Time Semantic Introspection.md b/docs/architecture/Compile-Time Semantic Introspection.mdindex 4688df88..dddfc74f 100644--- a/docs/architecture/Compile-Time Semantic Introspection.md+++ b/docs/architecture/Compile-Time Semantic Introspection.md@@ -8,6 +8,12 @@ The generated registry contains read-only `FirmamentConstructSchema`, `FirmamentThe schema is available to the browser through versioned `language.schema()` transport. Its JSON uses semantic strings for kinds and units. The existing `language.complete()` path takes Helix and solid Loft fields from the generated descriptors. It still uses parser-owned context detection. The Web tree preserves its existing body `kind` and separately projects the parser's `semanticConstruct` for schema lookup. Helios shows generic field and output metadata for a selected construct when that identity matches a schema; it never edits the compiled object through schema metadata.-This first slice has a deliberate boundary. Box and Hole descriptors are informational, while their parser rules remain separately implemented. Concept requirements are user-defined members, so Concept has a construct descriptor but no fixed field list. The current Web session does not provide a general semantic-instance-to-authored-field projection or per-field source span. Helios therefore labels unavailable values explicitly and only links fields to source when the existing SDK property supplies a range. Generic Inspector editing from the schema is disabled. The pre-existing experimental effective override editor remains separate and is not schema authority.+X1 adds `FirmamentFieldProjector` as a typed, read-only companion to the generated schema. It reads bound canonical Box and Hole instances, `WireAxisCoilAir`, and bound Loft authoring data. The generated registry emits a typed `ProjectHoleDiameter(FirmamentV2SemanticHoleDecl)` getter and reports a compile-time `FMS001` error if a field advertises source editing without a matching public static projector. All other schema fields are marked source-only. Field projections carry schema and semantic IDs, effective and authored values, origin, exact parser-owned declaration and value spans, source document, source hash, build revision, editability, and refusal reason. The Web contract exposes `firmament-field-projection/1` through `describeConstruct`.-The schema path uses ordinary generated C# and static collection access. It does not scan assemblies, use `PropertyInfo`, call `MethodInfo`, invoke `dynamic`, or require runtime reflection metadata preservation. The existing Web host's JSON transport still uses reflection-enabled serialization; that broader host has IL2026 trim warnings. NativeAOT compatibility of the broader runtime still requires its normal qualification path; the schema introduces no reflection-specific preservation requirement.+Canonical Box/Hole and WireForm/Loft parsers retain lexical field boundaries while recognizing declarations. The range scanner ignores comments and nested values; it does not search the completed document for a label to edit. The canonical Hole parser now takes its common legal field inventory from the generated schema and keeps Counterbore/Countersink additions local. Other Box/Hole validation and semantic rules still live in the parser and binder.++`rewriteField` is bounded to an already-authored canonical `Hole.Diameter` literal in mm. It requires the exact source hash and successful build revision, checks the projected literal against source, validates a positive finite typed Length, and replaces only the value span. It returns source text and a replacement edit without mutating the session or compiled object. Helios applies that edit through Monaco, marks the document dirty, and uses its normal `setSource` rebuild. Monaco undo and Telos save/reopen retain the source edit. Omitted values have no synthetic span and remain read-only. Expression-backed Helix values show both expression text and effective typed value and remain source-only.++The generated schema also carries buildable full-document Helix and Loft entry templates. `language.complete` exposes them for bare construct searches, and Helios palette commands open the same schema entries. Concept requirements remain user-defined members, so there is no fixed Concept field projection to expose without a separate member-schema design. The pre-existing experimental effective override editor remains distinct from X1 field editing and is not used by the source rewrite path.++The schema, typed projector, and span rewrite paths use ordinary generated C# and static collection access. They do not scan assemblies, use `PropertyInfo`, call `MethodInfo`, invoke `dynamic`, or require runtime reflection metadata preservation. The existing Web host's JSON transport still has IL2026 trim warnings. NativeAOT compatibility of the broader runtime still requires its normal qualification path; this projection introduces no reflection-specific preservation requirement.diff --git a/docs/release/FIRMAMENT-SCHEMA-X1.md b/docs/release/FIRMAMENT-SCHEMA-X1.mdnew file mode 100644index 00000000..7d8147da--- /dev/null+++ b/docs/release/FIRMAMENT-SCHEMA-X1.md@@ -0,0 +1,38 @@+# FIRMAMENT-SCHEMA-X1 — Authored field projection and safe source rewrite++## Executive verdict: Accepted++Aetheris now projects typed semantic values, authored source text, origin, and exact parser-owned spans through the generated schema. Helios uses the Web SDK to show those values and to change an authored canonical Hole Diameter by replacing only its Firmament literal, then rebuilding normally. The browser witness changed 10 mm to 12 mm, retained the adjacent comment, refreshed the Inspector and Hole wall selector, passed Monaco undo/redo, and persisted through Telos save/reopen.++## Compiler and Web contract++`FirmamentFieldProjector` exposes version `firmament-field-projection/1`. Each construct projection has a semantic ID, source document and hash, build revision, construct span, and schema-ordered fields. Each field contains effective typed value, authored text, origin, declaration/value spans, editability, and a read-only reason. Values travel as explicit kind, text, optional number/components, and unit rather than arbitrary CLR objects. Source ranges are recorded while the canonical Box/Hole and WireForm/Loft authoring parsers bind declarations. The lexical range scanner skips comments and nested delimiters; no post-build text search chooses a rewrite target.++The generated registry now emits a typed `ProjectHoleDiameter(FirmamentV2SemanticHoleDecl)` getter. A declaration advertising `SourceEditable` without a public static numeric projector raises `FMS001`. Only Hole Diameter advertises direct editing. The Web SDK adds `describeConstruct` and `rewriteField`; the latter checks source hash, build revision, semantic ID, field ID, the old literal, and a positive finite Length in mm. Refusals return stable codes including `stale_revision`, `field_readonly`, and `invalid_value`. It returns a Monaco replacement and new source but never changes compiled state itself.++| Construct | X1 value coverage | Editing |+| --- | --- | --- |+| Box | Bound Size vector, authored aggregate and exact range; Bounds unavailable when omitted | Source-only aggregate |+| Hole | Bound On, Center, Diameter, End; exact authored ranges; Wall remains a separate semantic output | Authored literal Diameter in mm |+| Helix | Typed Radius, Turns, Pitch, Height, Handedness, StartPhase from `WireAxisCoilAir`; omitted Height derived, Handedness/StartPhase defaulted | Source-only; expressions retain authored text |+| Loft | Bound profile/frame names, Rule, Correspondence, Reference, Twist; omitted Twist defaulted | Source-only complex fields |+| Concept | No fixed fields: members and their types are authored per Concept declaration | No fixed-schema projection |++The Inspector maps generated schema IDs to projection fields without Box/Hole-specific field rendering. It displays effective value, origin, type/unit, authored text, source link, editability, and refusal reason. Stale source disables the editor. The current experimental effective override section is a pre-existing separate UI; the X1 path uses only source rewrite and normal rebuild.++## Entry discovery and parser convergence++Generated schema entries now hold buildable full-document Helix and Loft templates. Bare Helix/Loft LX searches return those entries and legal owner context. Helios palette commands open the same schema entries. The canonical Hole parser takes common legal field names from generated schema, leaving variant-only additions local. This removes one duplicate common-field name list. Box recognition, Hole variant fields, cross-field rules, variant validation, and legacy syntax remain parser/binder-owned; the generator does not emit a parser. Binder values and schema descriptors still meet in the bounded static projection switch; documentation examples still spell source field names. Helios has no separate Box/Hole field table for these Inspector values.++## Qualification++- Focused generator, schema, and projection tests: 15 passed. They cover typed generated getter emission, invalid editable declarations, Box/Hole/Helix/Loft values, default/derived origins, expression preservation, exact rewrite, stale/invalid/read-only refusal, and buildable entry templates.+- Aetheris solution build passed with 7 existing Web/WASM warnings and no errors. The complete solution test run passed serially (`dotnet test Aetheris.slnx --no-build --no-restore -m:1 -v:q`), including Firmament 1,614, Kernel.Core 1,099, Server 59, SheetMetal 99, FEA 43, and EditableV8 3 tests.+- The final Web SDK was rebuilt and installed into Helios. Helios production build and 27 unit tests passed. The full Chrome Playwright suite passed serially, 7/7 tests, including Hole Inspector rewrite with undo/redo, save/reopen and 12 mm Hole wall reference; Box/Hole selector and PMI correspondence; buildable Loft/Helix palette entries; LX completion; and Telos reopen/STEP export.+- An independent UI-only pass selected a Hole and read its authored fields, edited 10 mm to 12 mm in Inspector with zero rebuild diagnostics, saved/reopened the result, opened the schema Helix and Loft templates, observed derived Helix Height and defaulted Loft Twist, and stopped its temporary servers without code changes.+- Aetheris CLI `inspect` recognized the canonical Hole and `build` produced STEP for both 10 mm and 12 mm sources under ignored `artifacts/local/schema-x1/`. The compiled feature reports changed from cylindrical shaft radius 5 mm to 6 mm; both STEP files reimported successfully and have different SHA-256 hashes.+- Parallel test runs showed resource contention in the .NET solution. The first full parallel browser run also exposed three older ambiguous `Go to Source` test locators after field source links were added; those tests now target the Inspector action button, and the complete serial browser run passes.++## Limits++Only the canonical Hole Diameter mm literal has a direct edit operation. Expressions, aggregate vectors, selectors, strings, profiles, frames, omitted/default insertion, and arbitrary units remain source-only. Helix and Loft values are projected but not edited from Inspector. Concept requires a separate member-schema design before generic field projection is meaningful. Parser/schema duplication remains in syntax recognition and semantic cross-field checks. The Helix entry compiled in 51.3 seconds during the independent UI pass, leaving the page temporarily unresponsive; this is a remaining UX/performance gap. The Helix and Loft palette entries replace the current single source buffer and mark it unsaved. The static schema/projector/rewrite path has no reflection; the broader Web JSON host still emits existing IL2026 trimming warnings and WASM sqlite varargs warnings, so this release does not claim full Web NativeAOT cleanliness.