Next Gen STEP AP242 Native-ish BREP Geometric Modeling Kernel
Integrate module graphs into assembly parsing and validation
Yuechen Li96aa41ca58f4
diff --git a/Aetheris.CLI.Tests/FirmamentInventoryCliTests.cs b/Aetheris.CLI.Tests/FirmamentInventoryCliTests.csnew file mode 100644index 00000000..4d78b1d1--- /dev/null+++ b/Aetheris.CLI.Tests/FirmamentInventoryCliTests.cs@@ -0,0 +1,51 @@+using System.Text.Json;++namespace Aetheris.CLI.Tests;++public sealed class FirmamentInventoryCliTests+{+ private static string Fixture(string name) => Path.GetFullPath(Path.Combine(AppContext.BaseDirectory,"../../../../fixtures/Regression/Inventory",name));++ [Theory]+ [InlineData("machine.firmasm")]+ [InlineData("factory.firmament")]+ public void NormalValidationBuildsAndAdmitsTheModuleGraph(string name)+ {+ var stdout=new StringWriter(); var stderr=new StringWriter();+ Assert.Equal(0,CliRunner.Run(["validate",Fixture(name),"--json"],stdout,stderr));+ using var json=JsonDocument.Parse(stdout.ToString());+ Assert.True(json.RootElement.GetProperty("success").GetBoolean());+ Assert.Equal("Built",json.RootElement.GetProperty("validationLevel").GetString());+ }++ [Fact]+ public void InventoryLookupErrorIsLocatedAndNeitherValidateNorBuildProducesSuccess()+ {+ var path=Fixture("missing-member.invalid.firmament"); var stdout=new StringWriter();+ Assert.Equal(1,CliRunner.Run(["validate",path,"--json"],stdout,new StringWriter()));+ using var json=JsonDocument.Parse(stdout.ToString());+ var error=Assert.Single(json.RootElement.GetProperty("diagnostics").EnumerateArray(),d => d.GetProperty("code").GetString()=="firmament-inventory-member-unresolved");+ Assert.Equal(path,error.GetProperty("sourceSpan").GetProperty("source").GetString());+ Assert.True(error.GetProperty("sourceSpan").GetProperty("start").GetInt32()>0);+ var directory=Path.GetFullPath(Path.Combine(AppContext.BaseDirectory,"../../../../artifacts/local/firmament-inventory/cli-"+Guid.NewGuid().ToString("N")));+ Directory.CreateDirectory(directory);+ try+ {+ var step=Path.Combine(directory,"rejected.step");+ Assert.Equal(1,CliRunner.Run(["build",path,"--output",step,"--json"],new StringWriter(),new StringWriter()));+ Assert.False(File.Exists(step));+ }+ finally { Directory.Delete(directory,true); }+ }++ [Fact]+ public void InspectionRetainsTypedInventoryBindingsAndSourceDependencyHashes()+ {+ var stdout=new StringWriter();+ Assert.Equal(0,CliRunner.Run(["asm","inspect",Fixture("machine.firmasm"),"--json"],stdout,new StringWriter()));+ using var json=JsonDocument.Parse(stdout.ToString());+ var ir=json.RootElement.GetProperty("assemblyIr");+ Assert.Contains(ir.GetProperty("inventoryBindings").EnumerateArray(),b => b.GetProperty("name").GetString()=="Components.drive" && b.GetProperty("kind").GetString()=="Subassembly");+ Assert.Equal(4,ir.GetProperty("sourceDependencies").GetArrayLength());+ }+}diff --git a/Aetheris.CLI/CliRunner.cs b/Aetheris.CLI/CliRunner.csindex 010f233b..03b8c59b 100644--- a/Aetheris.CLI/CliRunner.cs+++ b/Aetheris.CLI/CliRunner.cs@@ -2367,13 +2367,27 @@ Model CanonicalPanel {if (Aetheris.Kernel.Firmament.Garment.GarmentAuthoring.HasRoot(validationSource)|| frontend.Schema == FirmamentFrontendSchema.Garment)return GarmentCommand.Run(["inspect", sourcePath, .. (json ? new[] { "--json" } : Array.Empty<string>())], stdout, stderr);+ if (FirmamentLanguageAnalysisService.HasAssemblyRoot(validationSource))+ {+ var parsedAssembly = parseOnly ? new AssemblyM0Parser().ParseFile(sourcePath) : null;+ var builtAssembly = parseOnly ? null : new AssemblyM1Pipeline().CompileFile(sourcePath);+ var validAssembly = parsedAssembly?.IsSuccess ?? builtAssembly!.IsSuccess;+ var payload = new { success=validAssembly, domain="Assembly", validationLevel=!validAssembly ? "BuildRejected" : parseOnly ? "ParsedNotBuilt" : "Built",+ diagnostics=parsedAssembly?.Diagnostics ?? builtAssembly!.Diagnostics };+ if (json) stdout.WriteLine(JsonSerializer.Serialize(payload,JsonOptions));+ else { stdout.WriteLine(validAssembly ? "Assembly admitted." : "Assembly rejected."); foreach(var d in payload.diagnostics) stderr.WriteLine(d.Code+": "+d.Message); }+ return validAssembly ? 0 : 1;+ }if (Aetheris.Kernel.Firmament.Scene.SceneAuthoring.HasRoot(validationSource)){- var scene = Aetheris.Kernel.Firmament.Scene.SceneAuthoring.Parse(validationSource,Path.GetFullPath(sourcePath));- var payload = new { success=scene.IsSuccess, domain="Scene", diagnostics=scene.Diagnostics };+ using var sceneSession = new Aetheris.Kernel.Firmament.Scene.FirmamentSceneSession();+ var parsedScene = parseOnly ? Aetheris.Kernel.Firmament.Scene.SceneAuthoring.Parse(validationSource,Path.GetFullPath(sourcePath)) : null;+ var scene = parseOnly ? null : sceneSession.CompileFile(sourcePath);+ var sceneValid=parsedScene?.IsSuccess ?? scene!.IsSuccess;+ var payload = new { success=sceneValid, domain="Scene", validationLevel=!sceneValid ? "BuildRejected" : parseOnly ? "ParsedNotBuilt" : "Built", diagnostics=parsedScene?.Diagnostics ?? scene!.Diagnostics };if (json) stdout.WriteLine(JsonSerializer.Serialize(payload,JsonOptions));- else { stdout.WriteLine(scene.IsSuccess ? "Scene source valid; engineering definitions are checked by scene inspect/export." : "Scene source invalid."); foreach(var d in scene.Diagnostics) stderr.WriteLine(d.Code+": "+d.Message); }- return scene.IsSuccess ? 0 : 1;+ else { stdout.WriteLine(sceneValid ? "Scene admitted." : "Scene rejected."); foreach(var d in payload.diagnostics) stderr.WriteLine(d.Code+": "+d.Message); }+ return sceneValid ? 0 : 1;}validationSource = frontend.Source;if (PlasticShellFirmament.LooksLikePlasticShell(validationSource))@@ -4038,8 +4052,8 @@ Model CanonicalPanel {if (!File.Exists(path)) { stderr.WriteLine($"Assembly source '{path}' was not found."); return 1; }var sourceText = File.ReadAllText(path);var usesTemplateInstances = Regex.IsMatch(sourceText, @"<Part\s+[A-Za-z_]\w*\s*=\s*[A-Za-z_]\w*\s*<", RegexOptions.CultureInvariant);- if (!usesTemplateInstances && !Path.GetExtension(path).Equals(".firmasm", StringComparison.OrdinalIgnoreCase) && FirmamentSourceSpelling.Normalize(sourceText).Contains("Include", StringComparison.Ordinal))- usesTemplateInstances = new AssemblyM0Parser().ParseFile(path).Source is { } imported && NeedsMaterialization(imported.Root);+ if (!usesTemplateInstances && !Path.GetExtension(path).Equals(".firmasm", StringComparison.OrdinalIgnoreCase) && (FirmamentSourceSpelling.Normalize(sourceText).Contains("Include", StringComparison.Ordinal) || sourceText.Contains("Inventory", StringComparison.Ordinal)))+ usesTemplateInstances = new AssemblyM0Parser().ParseFile(path).Source is { } imported && (imported.HasModuleBindings || NeedsMaterialization(imported.Root));static bool NeedsMaterialization(AssemblyMemberSource member) => member.Kind == AssemblyInstanceKind.Part && member.DefinitionIdentity.Contains('<')|| member.Children.Any(NeedsMaterialization);var usesGearParts = GearAuthoring.ParseDefinitions(sourceText).Gears.Count > 0;diff --git a/Aetheris.Kernel.Firmament.Tests/Assembly/AssemblyUnifiedFrontendTests.cs b/Aetheris.Kernel.Firmament.Tests/Assembly/AssemblyUnifiedFrontendTests.csindex 16bd1ef1..3f9c3994 100644--- a/Aetheris.Kernel.Firmament.Tests/Assembly/AssemblyUnifiedFrontendTests.cs+++ b/Aetheris.Kernel.Firmament.Tests/Assembly/AssemblyUnifiedFrontendTests.cs@@ -10,7 +10,7 @@ public sealed class AssemblyUnifiedFrontendTestsprivate static string Source => Read("Regression/FrontendX1/assembly-modern-contract.firmament");[Fact]- public void IncludedSyntaxErrorsDiscloseTheExpandedScopeInsteadOfInventingRootFileOffsets()+ public void IncludedSyntaxErrorsRetainTheOriginalDocumentAndPreciseOffset(){var project = new FirmamentProjectSnapshot("root.firmasm", new Dictionary<string, string>{@@ -20,8 +20,9 @@ public sealed class AssemblyUnifiedFrontendTestsvar result = new AssemblyM0Parser().ParseProject(project);Assert.False(result.IsSuccess);var diagnostic = Assert.Single(result.Diagnostics);- Assert.EndsWith("#expanded-includes", diagnostic.SourceSpan!.Source);- Assert.Contains("original included-file mapping", diagnostic.LocationNote);+ Assert.Equal("bad.firmament", diagnostic.SourceSpan!.Source);+ Assert.Equal(project.Documents["bad.firmament"].IndexOf(';'), diagnostic.SourceSpan.Start);+ Assert.Null(diagnostic.LocationNote);Assert.Contains("identifier", diagnostic.Message);}diff --git a/Aetheris.Kernel.Firmament.Tests/FirmamentInventoryTests.cs b/Aetheris.Kernel.Firmament.Tests/FirmamentInventoryTests.csnew file mode 100644index 00000000..c0961cf0--- /dev/null+++ b/Aetheris.Kernel.Firmament.Tests/FirmamentInventoryTests.cs@@ -0,0 +1,300 @@+using Aetheris.Kernel.Firmament.Assembly;+using Aetheris.Kernel.Firmament.Scene;++namespace Aetheris.Kernel.Firmament.Tests;++public sealed class FirmamentInventoryTests+{+ private const string Bracket = "Record Spec { width: Length } Static spec: Spec = Spec { width: 30mm } Model Bracket { units: mm Box stock { size: [spec.width,20mm,6mm] } }";+ private const string Root = """+ Inventory Record Components { bracket: Part = Firmament("parts/bracket").Bracket }+ Assembly Machine {+ <Assembly Machine>+ <Part Left = Components.bracket> Placement { from: Origin; to: World; } </Part>+ <Part Right = Components.bracket> Placement { from: Origin; to: World; translateLocal: [50mm,0mm,0mm]; } </Part>+ </Assembly>+ Anchor: Machine;+ }+ """;+ private static FirmamentProjectSnapshot Project(string root = Root, params KeyValuePair<string,string>[] extra) =>+ new("main.firmasm", new[] { KeyValuePair.Create("main.firmasm",root),KeyValuePair.Create("parts/bracket.firmament",Bracket) }.Concat(extra));+ private static void Accepted(AssemblyM1CompilationResult result) => Assert.True(result.IsSuccess,string.Join("\n",result.Diagnostics.Select(d => d.Code+": "+d.Message)));++ [Fact]+ public void ExtensionlessPartUsesOneDefinitionAndPreservesConcreteGeometry()+ {+ var result=new AssemblyM1Pipeline().CompileProject(Project()); Accepted(result);+ var bodies=result.Geometry!.InstanceBodies.Values.ToArray(); Assert.Equal(2,bodies.Length);+ Assert.Single(result.Geometry.DefinitionBodies);+ var metric=Assert.Single(result.Geometry.Artifact.Definitions).Metrics;+ Assert.Equal(new[] { -15d,-10,0 },metric.Minimum);+ Assert.Equal(new[] { 15d,10,6 },metric.Maximum);+ Assert.Contains(result.Ir!.SourceDependencies!,d => d.Path=="parts/bracket.firmament");+ }++ [Fact]+ public void IdenticallyNamedExportsKeepTheirModuleSchemasAndPrivateValues()+ {+ var root=Root.Replace("bracket: Part = Firmament(\"parts/bracket\").Bracket", "bracket: Part = Firmament(\"parts/bracket\").Bracket other: Part = Firmament(\"parts/other\").Bracket")+ .Replace("Right = Components.bracket","Right = Components.other");+ var result=new AssemblyM1Pipeline().CompileProject(Project(root,+ KeyValuePair.Create("parts/other.firmament","Record Spec { width: Length thickness: Length } Static spec: Spec = Spec { width: 40mm thickness: 9mm } Model Bracket { units: mm Box stock { size: [spec.width,20mm,spec.thickness] } }")));+ Accepted(result); Assert.Equal(2,result.Geometry!.DefinitionBodies.Count);+ Assert.Contains(result.Geometry.Artifact.Definitions,d => d.Metrics.Maximum[0]==20 && d.Metrics.Maximum[2]==9);+ }++ [Theory]+ [InlineData("bracket: Scene = Firmament(\"parts/bracket\").Bracket","firmament-inventory-kind-mismatch")]+ [InlineData("bracket: Part = Firmament(\"parts/bracket\").Missing","firmament-inventory-export-unresolved")]+ [InlineData("bracket: Part = Firmament(\"parts/missing\").Bracket","assembly-include-file-not-found")]+ [InlineData("bracket: Part = Unknown(\"parts/bracket\")","firmament-inventory-resource-invalid")]+ [InlineData("bracket: Part = Step(\"bearing\")","assembly-profile-external-resource-unsupported")]+ [InlineData("bracket: Part = Firmament(\"parts/bracket\").Bracket bracket: Part = Firmament(\"parts/bracket\").Bracket","firmament-inventory-duplicate-field")]+ public void InvalidEntriesRejectAtTheirAuthoredField(string field,string code)+ {+ var source="Inventory Record Components { "+field+" } Assembly Machine { <Assembly Machine></Assembly> Anchor: Machine; }";+ var result=new AssemblyM1Pipeline().CompileProject(Project(source));+ Assert.False(result.IsSuccess); Assert.Null(result.Geometry);+ Assert.Contains(result.Diagnostics,d => d.Code==code && d.SourceSpan?.Source=="main.firmasm" && d.SourceSpan.Length>0);+ }++ [Fact]+ public void AmbiguousExtensionlessLocatorRejectsRatherThanChoosingAFile()+ {+ var result=new AssemblyM1Pipeline().CompileProject(Project(Root,KeyValuePair.Create("parts/bracket.firmasm",Bracket)));+ Assert.False(result.IsSuccess); Assert.Contains(result.Diagnostics,d => d.Code=="firmament-module-locator-ambiguous");+ }++ [Fact]+ public void SubassemblyAndAssemblyImportsRetainTheirLocallySolvedProductTrees()+ {+ foreach(var kind in new[] {"Subassembly","Assembly"})+ {+ var child=Root.Replace("parts/bracket","bracket").Replace("Machine","Drive");+ if(kind=="Subassembly") child=child.Replace("Assembly Drive {", "Subassembly Drive {");+ var root=$$"""+ Inventory Record Components { drive: {{kind}} = Firmament("parts/drive").Drive }+ Assembly Machine { <Assembly Machine><Assembly Unit = Components.drive></Assembly></Assembly> Anchor: Machine.Unit; }+ """;+ var result=new AssemblyM1Pipeline().CompileProject(Project(root,KeyValuePair.Create("parts/drive.firmament",child)));+ Accepted(result); Assert.Equal(2,result.Geometry!.InstanceBodies.Count);+ Assert.Contains(result.Ir!.Instances,i => i.Path.ToString()=="Machine.Unit.Left");+ }+ }++ [Fact]+ public void SceneImportsPartAssemblyAndNestedSceneWithWorldPlacement()+ {+ const string child="Scene Workcell { units: mm <Part plate = Components.bracket> Placement { from: Origin; to: World; translateLocal: [20mm,0mm,0mm]; } </Part> }";+ const string root="""+ Inventory Record Library {+ part: Part = Firmament("parts/bracket").Bracket+ machine: Assembly = Firmament("machine").Machine+ cell: Scene = Firmament("cell").Workcell+ }+ Scene Factory { units: mm+ <Part stock = Library.part> Placement { from: Origin; to: World; } </Part>+ <Assembly machine = Library.machine> Placement { from: Origin; to: World; translateLocal: [100mm,0mm,0mm]; } </Assembly>+ <Scene cell = Library.cell> Placement { from: Origin; to: World; translateLocal: [200mm,0mm,0mm]; } </Scene>+ }+ """;+ var project=new FirmamentProjectSnapshot("scene.firmament",[+ KeyValuePair.Create("scene.firmament",root),KeyValuePair.Create("parts/bracket.firmament",Bracket),+ KeyValuePair.Create("machine.firmament",Root),KeyValuePair.Create("cell.firmament","Inventory Record Components { bracket: Part = Firmament(\"parts/bracket\").Bracket } "+child)]);+ using var session=new FirmamentSceneSession(); var result=session.CompileProject(project);+ Assert.True(result.IsSuccess,string.Join("\n",result.Diagnostics));+ Assert.Equal(-15,result.Scene!.MinimumMm[0]); Assert.Equal(235,result.Scene.MaximumMm[0]);+ Assert.Contains(result.Scene.Nodes,n => n.Path=="Factory.cell.plate" && n.Span.Source=="cell.firmament");+ }+ [Fact]+ public void RetainedPartCacheReusesAndInvalidatesTheActualModuleSource()+ {+ using var session=new FirmamentCompilationSession();+ var first=session.CompileProject(Project()); Accepted(first);+ var second=session.CompileProject(Project()); Accepted(second);+ Assert.True(Assert.Single(second.Reuse!.Definitions).Reused);+ var changed=new FirmamentProjectSnapshot("main.firmasm",[+ KeyValuePair.Create("main.firmasm",Root),KeyValuePair.Create("parts/bracket.firmament",Bracket.Replace("30mm","40mm"))]);+ var third=session.CompileProject(changed); Accepted(third);+ Assert.False(Assert.Single(third.Reuse!.Definitions).Reused);+ Assert.Equal(20,Assert.Single(third.Geometry!.Artifact.Definitions).Metrics.Maximum[0]);+ }++ [Fact]+ public void PublishedModulePortsParticipateInTheExistingMateSolver()+ {+ var part=Bracket.Replace(" } }", " } expose { Semantic Mount { DatumFrame Frame = [0,0,0] x [1,0,0] y [0,1,0] z [0,0,1]; } } }");+ var root=Root[..Root.IndexOf("Assembly Machine",StringComparison.Ordinal)]+"""+ Assembly Machine {+ <Assembly Machine><Part Left = Components.bracket></Part><Part Right = Components.bracket></Part></Assembly>+ Anchor: Machine.Left.Mount;+ Interface<Fixed> Installation { A: Machine.Left.Mount.Frame; B: Machine.Right.Mount.Frame; gap: 10mm; }+ }+ """;+ var project=new FirmamentProjectSnapshot("main.firmasm",[KeyValuePair.Create("main.firmasm",root),KeyValuePair.Create("parts/bracket.firmament",part)]);+ var result=new AssemblyM1Pipeline().CompileProject(project); Accepted(result);+ Assert.Equal(2,result.Geometry!.InstanceBodies.Count); Assert.Single(result.Ir!.Mates);+ }++ [Fact]+ public void InventoryShadowingIsLexicalAndSiblingInventoriesRemainPrivate()+ {+ var declaration="Inventory Record Components { bracket: Part = Firmament(\"parts/bracket\").Bracket }";+ var local="Inventory Record Components { bracket: Part = Firmament(\"parts/other\").Bracket }";+ var source=Root.Replace("Assembly Machine {", "Assembly Machine { "+local);+ var result=new AssemblyM1Pipeline().CompileProject(Project(source,KeyValuePair.Create("parts/other.firmament",Bracket.Replace("30mm","40mm"))));+ Accepted(result); Assert.Equal(20,Assert.Single(result.Geometry!.Artifact.Definitions).Metrics.Maximum[0]);+ var hidden="Subassembly Private { "+declaration+" <Assembly Private></Assembly> Anchor: Private; }\n"+Root.Replace(declaration,"");+ var rejected=new AssemblyM1Pipeline().CompileProject(Project(hidden));+ Assert.False(rejected.IsSuccess); Assert.Null(rejected.Geometry);+ Assert.Contains(rejected.Diagnostics,d => d.Code=="firmament-inventory-not-visible");+ }++ [Fact]+ public void InventoryDependencyCyclesAndIncludedSyntaxErrorsRetainTheirSourceFile()+ {+ var cyclic=Project(Root,KeyValuePair.Create("parts/other.firmament","Inventory Record Loop { root: Assembly = Firmament(\"../main\").Machine } Model Other { units: mm Box stock { size: [1mm,1mm,1mm] } }"));+ var root=Root.Replace("parts/bracket", "parts/other").Replace(".Bracket", ".Other");+ var result=new AssemblyM1Pipeline().CompileProject(new("main.firmasm",cyclic.Documents.Select(p => p.Key=="main.firmasm" ? KeyValuePair.Create(p.Key,root) : p)));+ Assert.Contains(result.Diagnostics,d => d.Code=="firmament-module-cycle" && d.SourceSpan?.Source=="parts/other.firmament");+ var invalid=new FirmamentProjectSnapshot("main.firmasm",[+ KeyValuePair.Create("main.firmasm","include \"parts/broken\";\nAssembly Root { <Assembly Root></Assembly> Anchor: Root; }"),+ KeyValuePair.Create("parts/broken.firmament","Record Broken { width: }")]);+ var syntax=new AssemblyM0Parser().ParseProject(invalid);+ Assert.False(syntax.IsSuccess); Assert.Contains(syntax.Diagnostics,d => d.SourceSpan?.Source=="parts/broken.firmament" && d.SourceSpan.Start>0);+ }++ [Theory]+ [InlineData("Inventory Things { }")]+ [InlineData("Inventory Record Things() { }")]+ [InlineData("Inventory<> Record Things { }")]+ [InlineData("Inventory Record Things<> { }")]+ [InlineData("Inventory Record Things { typo: Part = Step(\"anything\") extra: 3 }")]+ public void MalformedInventoriesCannotDisappear(string inventory)+ {+ var result=new AssemblyM1Pipeline().CompileProject(Project(inventory+"\nAssembly Root { <Assembly Root></Assembly> Anchor: Root; }"));+ Assert.False(result.IsSuccess); Assert.NotEmpty(result.Diagnostics);+ }++ [Fact]+ public void ATemplateMustBeSpecializedInsideItsDefiningModuleBeforeInventoryExport()+ {+ var library="Template<width: Length> Struct Bracket { Box stock { size: [width,20mm,6mm] } }";+ var project=new FirmamentProjectSnapshot("main.firmasm",[KeyValuePair.Create("main.firmasm",Root),KeyValuePair.Create("parts/bracket.firmament",library)]);+ var rejected=new AssemblyM1Pipeline().CompileProject(project);+ Assert.False(rejected.IsSuccess); Assert.Contains(rejected.Diagnostics,d => d.Code=="firmament-inventory-specialization-required");+ library=library.Replace("Struct Bracket", "Struct Family")+"\nStruct Bracket = Family<width: 30mm>";+ var accepted=new AssemblyM1Pipeline().CompileProject(new("main.firmasm",[KeyValuePair.Create("main.firmasm",Root),KeyValuePair.Create("parts/bracket.firmament",library)]));+ Accepted(accepted); Assert.Equal(15,Assert.Single(accepted.Geometry!.Artifact.Definitions).Metrics.Maximum[0]);+ }++ [Fact]+ public void FileBackedStepUsesTheExistingExactImporterAndContributesAHashedDependency()+ {+ var directory=Path.GetFullPath(Path.Combine(AppContext.BaseDirectory,"../../../../artifacts/local/firmament-inventory/step-"+Guid.NewGuid().ToString("N")));+ Directory.CreateDirectory(directory);+ try+ {+ // This adapter witness intentionally exports its own asymmetric Part, then+ // imports that exact artifact; it is not a second import of the shared corpus.+ var original=FirmamentBuildAndExport.CompileSource(Bracket); Assert.True(original.IsSuccess);+ File.WriteAllText(Path.Combine(directory,"bearing.step"),original.Value!.StepText);+ var source=Root.Replace("Firmament(\"parts/bracket\").Bracket", "Step(\"bearing\")");+ var path=Path.Combine(directory,"main.firmament"); File.WriteAllText(path,source);+ var built=new AssemblyM1Pipeline().CompileFile(path); Accepted(built);+ Assert.Equal(15,Assert.Single(built.Geometry!.Artifact.Definitions).Metrics.Maximum[0]);+ Assert.Contains(built.Ir!.SourceDependencies!,d => d.Path.EndsWith("bearing.step",StringComparison.Ordinal) && d.Sha256.Length==64);+ }+ finally { Directory.Delete(directory,true); }+ }++ [Fact]+ public void FileAndSnapshotProjectsHaveTheSameDefinitionIdentitiesAndGeometry()+ {+ var root=FirmamentCorpusHarness.ResolveFixtureFullPath("fixtures/Regression/Inventory/machine.firmasm");+ var file=new AssemblyM1Pipeline().CompileFile(root); Accepted(file);+ var directory=Path.GetDirectoryName(root)!;+ var names=new[] {"machine.firmasm","drive.firmament","parts/bracket.firmament","parts/wide-bracket.firmament"};+ var snapshot=new AssemblyM1Pipeline().CompileProject(new("machine.firmasm",names.Select(name => KeyValuePair.Create(name,File.ReadAllText(Path.Combine(directory,name))))));+ Accepted(snapshot);+ // The overall artifact digest includes intentionally different file/snapshot+ // provenance. Compare the actual definition bytes and world geometry instead.+ Assert.Equal(file.Geometry!.DefinitionBodies.Keys.Order(),snapshot.Geometry!.DefinitionBodies.Keys.Order());+ Assert.Equal(file.Geometry.Artifact.Definitions.Select(d => d.StepSha256),snapshot.Geometry.Artifact.Definitions.Select(d => d.StepSha256));+ Assert.Equal(file.Geometry.Artifact.Instances.Select(i => string.Join(",",i.WorldTransform.Matrix)),snapshot.Geometry.Artifact.Instances.Select(i => string.Join(",",i.WorldTransform.Matrix)));+ Assert.Equal(4,file.Geometry.InstanceBodies.Count);+ Assert.Contains(file.Ir!.InventoryBindings,b => b.Name=="Components.drive" && b.Kind=="Subassembly");+ }++ [Fact]+ public void InvalidLocatorEscapesAreDiagnosticsRatherThanReaderExceptions()+ {+ var source=Root.Replace("parts/bracket",@"parts\q");+ var result=new AssemblyM1Pipeline().CompileProject(Project(source));+ Assert.False(result.IsSuccess); Assert.Contains(result.Diagnostics,d => d.Code=="firmament-module-locator-invalid");+ }++ [Fact]+ public void SnapshotCannotBypassTheBinaryAssetBoundaryThroughAnImportedPart()+ {+ const string part="Model Bracket { units: mm InlineStep source { file: \"C:/unavailable.step\" } }";+ var result=new AssemblyM1Pipeline().CompileProject(new("main.firmasm",[KeyValuePair.Create("main.firmasm",Root),KeyValuePair.Create("parts/bracket.firmament",part)]));+ Assert.False(result.IsSuccess);+ Assert.Contains(result.Diagnostics,d => d.Code=="assembly-profile-external-resource-unsupported" && d.SourceSpan?.Source=="parts/bracket.firmament");+ }++ [Fact]+ public void ShortIncludesComposeConcreteAndLegacyTemplatePartsWithoutCatalogAliases()+ {+ var path=FirmamentCorpusHarness.ResolveFixtureFullPath("fixtures/Regression/Inventory/include-simple.firmament");+ var result=new AssemblyM1Pipeline().CompileFile(path); Accepted(result);+ Assert.Equal(2,result.Geometry!.InstanceBodies.Count); Assert.Equal(2,result.Geometry.DefinitionBodies.Count);+ }++ [Fact]+ public void ADeclarationOnlyInventoryModuleNamesItsRequiredConsumerRatherThanARecordHeaderError()+ {+ var source=File.ReadAllText(FirmamentCorpusHarness.ResolveFixtureFullPath("fixtures/Regression/Inventory/drive.firmament"));+ var parsed=Aetheris.Kernel.Firmament.FirmamentV2.FirmamentV2Parser.Parse(source);+ Assert.False(parsed.IsSuccess);+ Assert.Contains(parsed.SyntaxDiagnostics,d => d.Code=="firmament-module-context-required" && d.SourceSpan is not null && d.Stage=="Module binding");+ Assert.False(FirmamentBuildAndExport.CompileSource(source).IsSuccess);+ }++ [Fact]+ public void AlreadyResolvedSourceRetainsItsExplicitProjectContext()+ {+ const string source="Assembly Root { <Assembly Root><Part Shade = SectionChainFile<\"shade.firmament\">></Part></Assembly> Anchor: Root.Shade; }";+ var project=new FirmamentProjectSnapshot("main.firmasm",[KeyValuePair.Create("main.firmasm",source),KeyValuePair.Create("shade.firmament",Bracket)]);+ var result=new AssemblyM0Parser().Parse(source,"main.firmasm",project);+ Assert.True(result.IsSuccess,string.Join("\n",result.Diagnostics));+ Assert.Contains(result.Source!.SourceDependencies!,d => d.Path=="shade.firmament");+ }++ [Fact]+ public void PatternOccurrencesBindInventoryBeforeExpansionAndProtectTheIterationName()+ {+ const string source="""+ Inventory Record Parts { bracket: Part = Firmament("parts/bracket").Bracket }+ Linear Sites Seats { keys: [Left,Right]; start: [0mm,0mm,0mm]; step: [50mm,0mm,0mm]; }+ Assembly Machine {+ <Assembly Machine>+ Pattern Mounts over Seats {+ site => <Part Item = Parts.bracket>+ Placement { from: Origin; to: World; translateLocal: [site.X,site.Y,site.Z]; }+ </Part>+ }+ </Assembly>+ Anchor: Machine;+ }+ """;+ var result=new AssemblyM1Pipeline().CompileProject(Project(source)); Accepted(result);+ Assert.Equal(2,result.Geometry!.InstanceBodies.Count); Assert.Single(result.Geometry.DefinitionBodies);+ Assert.Contains(result.Ir!.Instances,i => i.Path.ToString()=="Machine.Mounts.Left.Item");+ var shadowed=source.Replace("site =>","Parts =>").Replace("site.X","Parts.X").Replace("site.Y","Parts.Y").Replace("site.Z","Parts.Z");+ var rejected=new AssemblyM1Pipeline().CompileProject(Project(shadowed));+ Assert.False(rejected.IsSuccess); Assert.Null(rejected.Geometry);+ Assert.Contains(rejected.Diagnostics,d => d.Code=="firmament-inventory-not-visible");+ }++}diff --git a/Aetheris.Kernel.Firmament.Tests/FirmamentSemanticSchemaTests.cs b/Aetheris.Kernel.Firmament.Tests/FirmamentSemanticSchemaTests.csindex f15c01d8..5242ef38 100644--- a/Aetheris.Kernel.Firmament.Tests/FirmamentSemanticSchemaTests.cs+++ b/Aetheris.Kernel.Firmament.Tests/FirmamentSemanticSchemaTests.cs@@ -13,7 +13,7 @@ public sealed class FirmamentSemanticSchemaTests"Appearance", "FrameTransform", "Placement", "Pmi", "Note", "Provenance","Box", "Concept", "Points", "Door", "Drape", "Fabric", "FigureFit", "Fitting", "Garment","Helix", "Hole", "Interface<Fixed>", "Interface<Prismatic>", "Interface<Revolute>",- "Interface<Stitch>", "Joint", "Loft", "Panel", "Perforation", "Material", "Linear", "Series", "Pose", "PoseTransition",+ "Interface<Stitch>", "Inventory", "Joint", "Loft", "Panel", "Perforation", "Material", "Linear", "Series", "Pose", "PoseTransition","Room", "Scene", "Camera", "Section", "Thread", "Window", "Follow", "WireRoute",];Assert.Equal(expectedNames, FirmamentSemanticSchemas.All.Select(schema => schema.Name));diff --git a/Aetheris.Kernel.Firmament/Assembly/AssemblyM0Compiler.cs b/Aetheris.Kernel.Firmament/Assembly/AssemblyM0Compiler.csindex d4c9ca89..460772f8 100644--- a/Aetheris.Kernel.Firmament/Assembly/AssemblyM0Compiler.cs+++ b/Aetheris.Kernel.Firmament/Assembly/AssemblyM0Compiler.cs@@ -81,7 +81,7 @@ public sealed class AssemblyM0CompilerAssemblyPmiAuthoring.Validate(source.Annotations, instances, diagnostics);var ir = new AssemblyIr("aetheris/assembly-ir/m0", $"assembly:{source.Name}", source.Name,instances.Single(x => x.ParentStableId is null).StableId, instances, source.Interfaces, mates,- constraints, placements, relations, stackups, fits, diagnostics, assemblyDefinitions, panelMateEvidence, datums, datumSolutions, source.SourceDependencies, joints, source.Patterns, ConceptPoints: source.ConceptPoints, Annotations: source.Annotations);+ constraints, placements, relations, stackups, fits, diagnostics, assemblyDefinitions, panelMateEvidence, datums, datumSolutions, source.SourceDependencies, joints, source.Patterns, ConceptPoints: source.ConceptPoints, Annotations: source.Annotations) { InventoryBindings = source.ModuleGraph?.InventoryBindings.ToArray() ?? [] };ir = ir with { AxisSeats = AssemblyDatumAuthoring.ValidateAxisSeats(source, ir, diagnostics) };ir = AssemblyAppearanceAuthoring.Bind(ir, source.AppearanceCatalog, diagnostics);return new(ir, diagnostics, perf);diff --git a/Aetheris.Kernel.Firmament/Assembly/AssemblyM0Models.cs b/Aetheris.Kernel.Firmament/Assembly/AssemblyM0Models.csindex 7b0874da..b06a54d9 100644--- a/Aetheris.Kernel.Firmament/Assembly/AssemblyM0Models.cs+++ b/Aetheris.Kernel.Firmament/Assembly/AssemblyM0Models.cs@@ -97,7 +97,10 @@ public sealed record AssemblyDefinitionSource(IReadOnlyList<ToleranceStackupAssertSource>? LocalStackupAsserts = null,IReadOnlyList<AssemblyExposedRelationSource>? ExposedRelations = null,string? ClaimedConcept = null,- IReadOnlyList<AssemblyFrameTransformSource>? FrameTransforms = null);+ IReadOnlyList<AssemblyFrameTransformSource>? FrameTransforms = null)+{+ internal IReadOnlyList<InterfaceDefinition>? LocalInterfaces { get; init; }+}public sealed record AssemblyExposedRelationSource(string Name, string PublicFrom, string PublicTo, AssemblyPath InternalFrom, AssemblyPath InternalTo);@@ -119,7 +122,11 @@ public sealed record AssemblySource(IReadOnlyList<FirmamentV2CanonicalPatternDecl>? Patterns = null,IReadOnlyList<ConceptIrKeyedPointSetValue>? ConceptPoints = null,AssemblyAppearanceCatalog? AppearanceCatalog = null,- AssemblyAnnotations? Annotations = null);+ AssemblyAnnotations? Annotations = null)+{+ internal Aetheris.Kernel.Firmament.Modules.FirmamentModuleGraph? ModuleGraph { get; init; }+ public bool HasModuleBindings => ModuleGraph?.HasModuleBindings == true;+}public sealed record AssemblySourceDependencyIr(string Path, string Sha256, bool IsRoot);@@ -237,7 +244,10 @@ public sealed record AssemblyIr(IReadOnlyList<AssemblyAxisSeatEvidence>? AxisSeats = null,IReadOnlyList<ConceptIrKeyedPointSetValue>? ConceptPoints = null,IReadOnlyList<AssemblyRouteBindingEvidence>? RouteBindings = null,- AssemblyAnnotations? Annotations = null);+ AssemblyAnnotations? Annotations = null)+{+ public IReadOnlyList<Aetheris.Kernel.Firmament.Modules.FirmamentInventoryBinding> InventoryBindings { get; init; } = [];+}public sealed record AssemblyCompilationResult(AssemblyIr? Ir, IReadOnlyList<AssemblyDiagnostic> Diagnostics, AssemblyPerformanceIr? Performance = null){diff --git a/Aetheris.Kernel.Firmament/Assembly/AssemblyM0Parser.cs b/Aetheris.Kernel.Firmament/Assembly/AssemblyM0Parser.csindex af7c07c9..55781b74 100644--- a/Aetheris.Kernel.Firmament/Assembly/AssemblyM0Parser.cs+++ b/Aetheris.Kernel.Firmament/Assembly/AssemblyM0Parser.cs@@ -5,6 +5,7 @@ using System.Numerics;using Aetheris.Kernel.Firmament.FirmamentV2;using Aetheris.Kernel.Firmament.FirmamentV2.Syntax;using Aetheris.Semantics;+using Aetheris.Kernel.Firmament.Modules;namespace Aetheris.Kernel.Firmament.Assembly;@@ -19,74 +20,26 @@ public sealed class AssemblyM0Parserpublic ParseResult ParseFile(string path){var fullPath = Path.GetFullPath(path);- var loadDiagnostics = new List<AssemblyDiagnostic>();- var dependencies = new List<AssemblySourceDependencyIr>();- var allowedRoot = FindAllowedSourceRoot(fullPath);- var source = LoadSourceGraph(fullPath, allowedRoot, [], dependencies, loadDiagnostics);- if (source is null) return new(null, loadDiagnostics, 0);- var parsed = Parse(source, fullPath);- var diagnostics = loadDiagnostics.Concat(GraphDiagnostics(parsed.Diagnostics, fullPath, dependencies.Count)).ToArray();- return new(parsed.Source is null ? null : parsed.Source with { SourceDependencies = dependencies.Concat(parsed.Source.SourceDependencies ?? []).DistinctBy(d => d.Path).ToArray() }, diagnostics, parsed.ElapsedMilliseconds);+ if (!File.Exists(fullPath)) return new(null, [new("assembly-include-file-not-found", $"Module '{fullPath}' was not found.")], 0);+ var graph = FirmamentModuleGraph.Load(File.ReadAllText(fullPath), fullPath);+ return ParseGraph(graph);}public ParseResult ParseProject(FirmamentProjectSnapshot project){ArgumentNullException.ThrowIfNull(project);- var diagnostics = new List<AssemblyDiagnostic>();- var dependencies = new List<AssemblySourceDependencyIr>();- var source = LoadProjectSource(project.RootDocument, project, [], dependencies, diagnostics);- if (source is null) return new(null, diagnostics, 0);- var parsed = Parse(source, project.RootDocument, project);- return new(parsed.Source is null ? null : parsed.Source with { SourceDependencies = dependencies.Concat(parsed.Source.SourceDependencies ?? []).DistinctBy(d => d.Path).ToArray() },- [.. diagnostics, .. GraphDiagnostics(parsed.Diagnostics, project.RootDocument, dependencies.Count)], parsed.ElapsedMilliseconds);+ if (!project.TryResolve(project.RootDocument, out var text))+ return new(null, [new("assembly-include-file-not-found", $"Project document '{project.RootDocument}' was not found.")], 0);+ return ParseGraph(FirmamentModuleGraph.Load(text, project.RootDocument, project));}- private static IEnumerable<AssemblyDiagnostic> GraphDiagnostics(IEnumerable<AssemblyDiagnostic> diagnostics, string root, int documents)- => documents <= 1 ? diagnostics : diagnostics.Select(d => d.SourceSpan is { } span && span.Source == root- ? d with { SourceSpan = span with { Source = root + "#expanded-includes" },- LocationNote = "Location is in the expanded include graph; original included-file mapping is unavailable." } : d);-- private static string? LoadProjectSource(string path, FirmamentProjectSnapshot project,- IReadOnlyList<string> stack, List<AssemblySourceDependencyIr> dependencies, List<AssemblyDiagnostic> diagnostics)+ private ParseResult ParseGraph(FirmamentModuleGraph graph){- var cycleAt = stack.ToList().FindIndex(item => string.Equals(item, path, StringComparison.Ordinal));- if (cycleAt >= 0)- {- diagnostics.Add(new("assembly-include-cycle", $"Compile-time Include cycle: {string.Join(" -> ", stack.Skip(cycleAt).Append(path))}."));- return null;- }- if (!project.TryResolve(path, out var text))- {- diagnostics.Add(new("assembly-include-file-not-found", $"Project document '{path}' was not found."));- return null;- }- if (stack.Count > 0 && !path.EndsWith(".firmament", StringComparison.OrdinalIgnoreCase))- {- diagnostics.Add(new("assembly-include-extension-invalid", $"Compile-time Include '{path}' must reference a .firmament semantic source file."));- return null;- }- if (dependencies.Any(item => string.Equals(item.Path, path, StringComparison.Ordinal))) return string.Empty;- var hash = Convert.ToHexString(System.Security.Cryptography.SHA256.HashData(System.Text.Encoding.UTF8.GetBytes(text)));- dependencies.Add(new(path, hash, stack.Count == 0));- var declarations = new List<string>();- foreach (Match include in Regex.Matches(text, @"^[ \t]*(?:Include|include)\s+""(?<path>[^""]+)""\s*;", RegexOptions.CultureInvariant | RegexOptions.Multiline))- {- string childPath;- try- {- childPath = FirmamentProjectSnapshot.NormalizePath(include.Groups["path"].Value);- }- catch (ArgumentException)- {- diagnostics.Add(new("assembly-include-outside-root", $"Include '{include.Groups["path"].Value}' in '{path}' escapes the project root or uses an invalid path."));- return null;- }- var child = LoadProjectSource(childPath, project, [.. stack, path], dependencies, diagnostics);- if (child is null) return null;- declarations.Add(child);- }- declarations.Add(Regex.Replace(text, @"^[ \t]*(?:Include|include)\s+""[^""]+""\s*;[ \t]*(?:\r?\n)?", string.Empty, RegexOptions.CultureInvariant | RegexOptions.Multiline));- return string.Join(Environment.NewLine, declarations);+ if (graph.Diagnostics.Count > 0) return new(null, graph.Diagnostics, 0);+ var projection = graph.ProjectSource(graph.Root);+ var parsed = ParseBound(projection.Text, graph.Root.Path, graph, graph.Root, projection);+ return parsed with { Source = parsed.Source is null ? null : parsed.Source with+ { SourceDependencies = graph.Dependencies.Concat(parsed.Source.SourceDependencies ?? []).DistinctBy(d => d.Path).ToArray() } };}internal static string FindAllowedSourceRoot(string path)@@ -102,11 +55,34 @@ public sealed class AssemblyM0Parserinternal static string? LoadResource(string path, FirmamentProjectSnapshot? project,List<AssemblySourceDependencyIr> dependencies, List<AssemblyDiagnostic> diagnostics)- => project is not null ? LoadProjectSource(path, project, [], dependencies, diagnostics)- : LoadSourceGraph(Path.GetFullPath(path), FindAllowedSourceRoot(Path.GetFullPath(path)), [], dependencies, diagnostics);+ {+ string text;+ if (project is not null)+ {+ if (!project.TryResolve(path, out text!)) { diagnostics.Add(new("assembly-include-file-not-found", path)); return null; }+ }+ else+ {+ if (!File.Exists(path)) { diagnostics.Add(new("assembly-include-file-not-found", $"Module '{path}' was not found.")); return null; }+ text = File.ReadAllText(path);+ }+ var graph = FirmamentModuleGraph.Load(text, path, project);+ diagnostics.AddRange(graph.Diagnostics);+ if (graph.Diagnostics.Count > 0) return null;+ dependencies.AddRange(graph.Dependencies);+ return graph.ProjectSource(graph.Root).Text;+ }public ParseResult Parse(string input, string sourceIdentity = "<memory>", FirmamentProjectSnapshot? project = null){+ if (FirmamentModuleGraph.HasImports(input)) return ParseGraph(FirmamentModuleGraph.Load(input, sourceIdentity, project));+ return ParseBound(input, sourceIdentity, null, null, null, projectContext: project);+ }++ internal ParseResult ParseBound(string input, string sourceIdentity, FirmamentModuleGraph? graph,+ FirmamentModuleGraph.Module? module, FirmamentModuleGraph.Projection? projection, DeclarationSyntax? exported = null, FirmamentProjectSnapshot? projectContext = null)+ {+ var project = graph?.Project ?? projectContext;var watch = Stopwatch.StartNew();var diagnostics = new List<AssemblyDiagnostic>();var syntax = FirmamentSyntaxParser.Parse(input, sourceIdentity);@@ -166,13 +142,15 @@ public sealed class AssemblyM0Parservar portCache = new Dictionary<string, IReadOnlyList<SemanticValue>>(StringComparer.Ordinal);IReadOnlyList<SemanticValue> Ports(string identity){+ if (graph?.TryReference(identity, out var imported) == true)+ return graph.Ports(imported, identity, diagnostics, PortCache);if (!portCache.TryGetValue(identity, out var ports))using (var portsPhase = Aetheris.Kernel.Core.Diagnostics.BuildPerfTrace.Phase("m0.ports")) portCache[identity] = ports = AssemblyPublishedPorts.BindAuthored(identity, definitionSource, sourceIdentity, diagnostics, project, portDependencies, PortCache);return ports;}var templateRanges = new List<(int Start, int Length)>();var assemblydefinitionsPhase = Aetheris.Kernel.Core.Diagnostics.BuildPerfTrace.Phase("m0.assembly-definitions");- var assemblyDefinitions = ParseAssemblyDefinitions(source, sourceIdentity, interfaces, concepts, gearAuthorities, diagnostics, templateRanges, Ports, layout);+ var assemblyDefinitions = ParseAssemblyDefinitions(source, sourceIdentity, interfaces, concepts, gearAuthorities, diagnostics, templateRanges, Ports, layout, graph);assemblydefinitionsPhase.Dispose();// Template-produced Assembly bodies are declarations, not exported roots.// Blank them without changing offsets, then locate the single root Assembly.@@ -186,9 +164,14 @@ public sealed class AssemblyM0Parserif (body is null) return Done(null);var specializationCache = new Dictionary<string, AssemblyMemberSource>(StringComparer.Ordinal);var treePhase = Aetheris.Kernel.Core.Diagnostics.BuildPerfTrace.Phase("m0.tree");- var tree = ParseTree(body, sourceIdentity, diagnostics, assemblyDefinitions, interfaces, specializationCache, gearAuthorities, Ports);+ var tree = ParseTree(body, sourceIdentity, diagnostics, assemblyDefinitions, interfaces, specializationCache, gearAuthorities, Ports, graph);treePhase.Dispose();if (tree is null) return Done(null);+ if (exported is not null)+ {+ tree = tree with { ExposedSemantics = ParseAssemblyExposes(body, tree, sourceIdentity, diagnostics) };+ tree = graph!.QualifyParts(module!, tree);+ }var mates = ParseMates(body, sourceIdentity, diagnostics);var relations = ParseRelations(body, diagnostics);var asserts = ParseAsserts(body, sourceIdentity, diagnostics);@@ -199,10 +182,11 @@ public sealed class AssemblyM0Parsertree = AssemblyDatumAuthoring.Bind(body, tree, layout, interfaces, diagnostics, out var datumFrames, Ports);datumbindPhase.Dispose();frames = frames.Concat(datumFrames).ToArray();- var result = new AssemblySource(assemblyHeader.Groups["name"].Value, tree, interfaces, mates, anchor, relations, asserts, sourceIdentity, definitionSource, assemblyDefinitions, SourceDependencies: portDependencies, FrameTransforms: frames, Patterns: expandedPatterns.Document?.Patterns, ConceptPoints: expandedPatterns.Document?.ConceptPoints, AppearanceCatalog: appearanceCatalog, Annotations: annotations);+ var result = new AssemblySource(assemblyHeader.Groups["name"].Value, tree, interfaces, mates, anchor, relations, asserts, sourceIdentity, definitionSource, assemblyDefinitions, SourceDependencies: portDependencies, FrameTransforms: frames, Patterns: expandedPatterns.Document?.Patterns, ConceptPoints: expandedPatterns.Document?.ConceptPoints, AppearanceCatalog: appearanceCatalog, Annotations: annotations) { ModuleGraph = graph };return Done(result);- ParseResult Done(AssemblySource? value) { watch.Stop(); return new(value, diagnostics, watch.Elapsed.TotalMilliseconds); }+ ParseResult Done(AssemblySource? value) { watch.Stop(); return new(value,+ projection is null ? diagnostics : diagnostics.Select(projection.Map).ToArray(), watch.Elapsed.TotalMilliseconds); }}private static IReadOnlyList<AssemblyFrameTransformSource> ParseFrameTransforms(string body, string sourceIdentity, List<AssemblyDiagnostic> diagnostics)@@ -217,42 +201,6 @@ public sealed class AssemblyM0Parserreturn frames;}- private static string? LoadSourceGraph(string path, string allowedRoot, IReadOnlyList<string> stack,- List<AssemblySourceDependencyIr> dependencies, List<AssemblyDiagnostic> diagnostics)- {- var fullPath = Path.GetFullPath(path);- var rootPrefix = Path.TrimEndingDirectorySeparator(Path.GetFullPath(allowedRoot)) + Path.DirectorySeparatorChar;- if (!fullPath.StartsWith(rootPrefix, StringComparison.OrdinalIgnoreCase) && !string.Equals(fullPath, Path.TrimEndingDirectorySeparator(Path.GetFullPath(allowedRoot)), StringComparison.OrdinalIgnoreCase))- { diagnostics.Add(new("assembly-include-outside-root", $"Include '{path}' resolves outside allowed root '{allowedRoot}'.")); return null; }- var cycleAt = stack.ToList().FindIndex(item => string.Equals(item, fullPath, StringComparison.OrdinalIgnoreCase));- if (cycleAt >= 0)- {- var cycle = stack.Skip(cycleAt).Append(fullPath).Select(Path.GetFileName);- diagnostics.Add(new("assembly-include-cycle", $"Compile-time Include cycle: {string.Join(" -> ", cycle)}."));- return null;- }- if (!File.Exists(fullPath))- { diagnostics.Add(new("assembly-include-file-not-found", $"Included Firmament source '{fullPath}' was not found.")); return null; }- if (stack.Count > 0 && !string.Equals(Path.GetExtension(fullPath), ".firmament", StringComparison.OrdinalIgnoreCase))- { diagnostics.Add(new("assembly-include-extension-invalid", $"Compile-time Include '{fullPath}' must reference a .firmament semantic source file.")); return null; }- var text = File.ReadAllText(fullPath);- var hash = Convert.ToHexString(System.Security.Cryptography.SHA256.HashData(System.Text.Encoding.UTF8.GetBytes(text)));- if (dependencies.Any(item => string.Equals(item.Path, fullPath, StringComparison.OrdinalIgnoreCase))) return string.Empty;- dependencies.Add(new(fullPath, hash, stack.Count == 0));- var declarations = new List<string>();- foreach (Match include in Regex.Matches(text, @"^[ \t]*(?:Include|include)\s+""(?<path>[^""]+)""\s*;", RegexOptions.CultureInvariant | RegexOptions.Multiline))- {- var relative = include.Groups["path"].Value;- var childPath = Path.GetFullPath(Path.Combine(Path.GetDirectoryName(fullPath)!, relative));- var child = LoadSourceGraph(childPath, allowedRoot, [.. stack, fullPath], dependencies, diagnostics);- if (child is null) return null;- declarations.Add(child);- }- var local = Regex.Replace(text, @"^[ \t]*(?:Include|include)\s+""[^""]+""\s*;[ \t]*(?:\r?\n)?", string.Empty, RegexOptions.CultureInvariant | RegexOptions.Multiline);- declarations.Add(local);- return string.Join(Environment.NewLine, declarations);- }-private static IReadOnlyList<AssemblyConceptDefinition> ParseAssemblyConcepts(string source, string sourceIdentity, List<AssemblyDiagnostic> diagnostics){var result = new List<AssemblyConceptDefinition>();@@ -379,7 +327,7 @@ public sealed class AssemblyM0ParserIReadOnlyDictionary<string, GearAir> gearAuthorities,List<AssemblyDiagnostic> diagnostics, List<(int Start, int Length)> ranges,Func<string, IReadOnlyList<SemanticValue>>? publishedPorts = null,- IReadOnlyList<AssemblyLayoutDatum>? layout = null)+ IReadOnlyList<AssemblyLayoutDatum>? layout = null, FirmamentModuleGraph? graph = null){var result = new List<AssemblyDefinitionSource>();foreach (Match template in Regex.Matches(source,@@ -390,7 +338,7 @@ public sealed class AssemblyM0Parserif (body is null) continue;var close = template.Index + template.Length + body.Length + 1;ranges.Add((template.Index, close - template.Index));- var root = ParseTree(body, sourceIdentity, diagnostics, result, interfaces, new Dictionary<string, AssemblyMemberSource>(StringComparer.Ordinal), gearAuthorities, publishedPorts);+ var root = ParseTree(body, sourceIdentity, diagnostics, result, interfaces, new Dictionary<string, AssemblyMemberSource>(StringComparer.Ordinal), gearAuthorities, publishedPorts, graph);if (root is null) continue;root = AssemblyDatumAuthoring.Bind(body, root, layout ?? [], interfaces, diagnostics, out var datumFrames, publishedPorts);if (root.Children.Any(c => c.FramePlacement?.JointFamily == MechanicalInterfaceFamily.Revolute))@@ -530,7 +478,7 @@ public sealed class AssemblyM0ParserIsEncapsulatedDefinition = item.IsEncapsulatedDefinition};var specializedRoot = Replace(definition.LocalRoot) with { IsEncapsulatedDefinition = false };- var localSource = new AssemblySource(definition.Name, specializedRoot, interfaces, definition.LocalMates ?? [], definition.LocalAnchor ?? new([definition.Name]),+ var localSource = new AssemblySource(definition.Name, specializedRoot, definition.LocalInterfaces ?? interfaces, definition.LocalMates ?? [], definition.LocalAnchor ?? new([definition.Name]),definition.LocalDimensionalRelations ?? [], definition.LocalStackupAsserts ?? [], sourceIdentity, FrameTransforms: definition.FrameTransforms);var watch = Stopwatch.StartNew();var local = new AssemblyM0Compiler().Compile(localSource);@@ -662,7 +610,7 @@ public sealed class AssemblyM0ParserIReadOnlyList<AssemblyDefinitionSource>? definitions = null, IReadOnlyList<InterfaceDefinition>? interfaces = null,IDictionary<string, AssemblyMemberSource>? specializationCache = null,IReadOnlyDictionary<string, GearAir>? gearAuthorities = null,- Func<string, IReadOnlyList<SemanticValue>>? publishedPorts = null)+ Func<string, IReadOnlyList<SemanticValue>>? publishedPorts = null, FirmamentModuleGraph? graph = null){// One bounded generic argument list is admitted in a Part definition. The// inner '>' belongs to the Firmament Template application, not the XML-like tag.@@ -685,7 +633,23 @@ public sealed class AssemblyM0Parserkind == "Assembly" ? (nodeMatch.Groups["definition"].Success ? NormalizeIdentity(nodeMatch.Groups["definition"].Value) : nodeMatch.Groups["name"].Value) : nodeMatch.Groups["definition"].Value);if (kind == "Assembly" && nodeMatch.Groups["definition"].Success){- var instantiated = InstantiateAssemblyDefinition(node.Name, node.Definition, definitions ?? [], interfaces ?? [], specializationCache ?? new Dictionary<string, AssemblyMemberSource>(StringComparer.Ordinal), sourceIdentity, diagnostics);+ AssemblyMemberSource? instantiated;+ if (graph?.TryReference(node.Definition, out var imported) == true)+ {+ var external = graph.ParseAssembly(imported);+ diagnostics.AddRange(external.Diagnostics);+ if (external.Source is { } unit && external.IsSuccess)+ {+ var definition = new AssemblyDefinitionSource(imported.Identity, "__Unit", "__Unit", unit.Root,+ imported.Identity, [new("inventory-module", imported.Path, imported.Definition, imported.Origin)],+ unit.Anchor, unit.Mates, unit.DimensionalRelations, unit.StackupAsserts, FrameTransforms: unit.FrameTransforms)+ { LocalInterfaces = unit.Interfaces };+ instantiated = InstantiateAssemblyDefinition(node.Name, imported.Identity, [definition], unit.Interfaces,+ specializationCache ?? new Dictionary<string, AssemblyMemberSource>(StringComparer.Ordinal), imported.Path, diagnostics);+ }+ else instantiated = null;+ }+ else instantiated = InstantiateAssemblyDefinition(node.Name, node.Definition, definitions ?? [], interfaces ?? [], specializationCache ?? new Dictionary<string, AssemblyMemberSource>(StringComparer.Ordinal), sourceIdentity, diagnostics);if (instantiated is not null){node.Children.AddRange(instantiated.Children.Select(ToMutable));diff --git a/Aetheris.Kernel.Firmament/Assembly/AssemblyM1Execution.cs b/Aetheris.Kernel.Firmament/Assembly/AssemblyM1Execution.csindex ee377ea5..44f623dc 100644--- a/Aetheris.Kernel.Firmament/Assembly/AssemblyM1Execution.cs+++ b/Aetheris.Kernel.Firmament/Assembly/AssemblyM1Execution.cs@@ -70,7 +70,7 @@ internal sealed record MaterializedAssemblyDefinition(/// M1's definition seam: specialize through the ordinary Firmament compiler, then/// reimport its canonical AP242 exact body. Assembly has no second part generator./// </summary>-internal static class AssemblyDefinitionMaterializer+internal static partial class AssemblyDefinitionMaterializer{public static MaterializedAssemblyDefinition? TryMaterialize(string definitionIdentity, string? definitionSource, string sourceIdentity, List<AssemblyDiagnostic> diagnostics, FirmamentProjectSnapshot? project = null,Func<string, KernelResult<BrepBody>>? importBody = null)@@ -407,6 +407,10 @@ public sealed class AssemblyM1Pipelinereturn CompileParsed(parsed, domainMaterializer);}+ internal AssemblyM1CompilationResult CompileModule(Aetheris.Kernel.Firmament.Modules.FirmamentModuleGraph graph,+ Aetheris.Kernel.Firmament.Modules.FirmamentModuleGraph.Reference reference)+ => CompileParsed(graph.ParseAssembly(reference), null, graph.Project);+public AssemblyM1CompilationResult CompileProject(FirmamentProjectSnapshot project){ArgumentNullException.ThrowIfNull(project);@@ -437,7 +441,10 @@ public sealed class AssemblyM1Pipelinevar materializationWatch = Stopwatch.StartNew();var definitions = parsed.Source.Root.Flatten().Where(member => member.Kind == AssemblyInstanceKind.Part).Select(member => member.DefinitionIdentity).Distinct(StringComparer.Ordinal).Order(StringComparer.Ordinal)- .Select(identity => { using var definitionPhase = BuildPerfTrace.Phase("assembly.definition"); return cache is null+ .Select(identity => { using var definitionPhase = BuildPerfTrace.Phase("assembly.definition");+ if (parsed.Source.ModuleGraph?.TryReference(identity, out var imported) == true)+ return AssemblyDefinitionMaterializer.MaterializeModule(parsed.Source.ModuleGraph, imported, identity, diagnostics, cache);+ return cache is null? Materialize(identity, parsed.Source.DefinitionSource, parsed.Source.SourceIdentity, diagnostics, domainMaterializer, project): cache.Materialize(identity, parsed.Source.DefinitionSource, parsed.Source.SourceIdentity, diagnostics, project,() => Materialize(identity, parsed.Source.DefinitionSource, parsed.Source.SourceIdentity, diagnostics, domainMaterializer, project, cache.ImportCanonical)); })diff --git a/Aetheris.Kernel.Firmament/Assembly/AssemblyModuleMaterialization.cs b/Aetheris.Kernel.Firmament/Assembly/AssemblyModuleMaterialization.csnew file mode 100644index 00000000..28031504--- /dev/null+++ b/Aetheris.Kernel.Firmament/Assembly/AssemblyModuleMaterialization.cs@@ -0,0 +1,76 @@+using System.Security.Cryptography;+using System.Text;+using Aetheris.Kernel.Core.Step242;+using Aetheris.Kernel.Firmament.Modules;+using Aetheris.Kernel.Firmament.FirmamentV2.Syntax;+using Aetheris.Semantics;++namespace Aetheris.Kernel.Firmament.Assembly;++internal static partial class AssemblyDefinitionMaterializer+{+ internal static MaterializedAssemblyDefinition? MaterializeModule(FirmamentModuleGraph graph,+ FirmamentModuleGraph.Reference reference, string identity, List<AssemblyDiagnostic> diagnostics,+ AssemblyDefinitionCache? cache = null)+ {+ var projection = reference.Module is null ? null : graph.ProjectSource(reference.Module, reference.Export, partContext: true);+ if (graph.Project is not null && reference.Module is { } module)+ {+ var inline = FirmamentSyntaxTraversal.Declarations(module.Syntax).FirstOrDefault(d => d.Type.Name.Text == "InlineStep");+ if (inline is not null)+ {+ diagnostics.Add(new("assembly-profile-external-resource-unsupported", "InlineStep requires a binary asset, which a source-only project snapshot cannot supply.")+ { SourceSpan = new(module.Path,inline.Span.Start,inline.Span.Length) });+ return null;+ }+ if (reference.Export is not null)+ {+ var resource = FirmamentSyntaxTraversal.Expressions(module.Syntax).OfType<SpecializationSyntax>()+ .FirstOrDefault(s => s.Target is ReferenceSyntax r && r.Name.Text is "LoftFile" or "SectionChainFile" or "ExternalStep");+ if (resource is not null)+ {+ diagnostics.Add(new("firmament-module-resource-context-unsupported", "This concrete Part uses a file-resource adapter that has no source-snapshot context. Use a file-backed project or the existing project-aware Assembly resource definition.")+ { SourceSpan = new(module.Path,resource.Span.Start,resource.Span.Length) });+ return null;+ }+ }+ }+ var localIdentity = reference.Module is null ? "ExternalStep<\"" + reference.Path.Replace('\\', '/') + "\">" : graph.PartIdentity(reference, identity);+ MaterializedAssemblyDefinition? Build()+ {+ MaterializedAssemblyDefinition? result;+ if (reference.Module is null || reference.Export is null || reference.Export.Modifiers.Any(m => m.Name.Text == "Template"))+ result = TryMaterialize(localIdentity, projection?.Text, reference.Path, diagnostics, graph.Project, cache is null ? null : cache.ImportCanonical);+ else+ {+ var source = AssemblyPublishedPorts.Strip(projection!.Text, diagnostics);+ var compiled = FirmamentBuildAndExport.CompileSource(source, graph.Project is null ? Path.GetDirectoryName(reference.Path) : null);+ if (!compiled.IsSuccess || compiled.Value is null)+ {+ foreach (var error in compiled.Diagnostics)+ diagnostics.Add(new("assembly-definition-materialization-failed", error.Message)+ { SourceSpan = reference.DeclarationOrigin,+ LocationNote = "Enclosing exported Part; the engineering lowerer supplied no precise original expression location." });+ return null;+ }+ var imported = cache is null ? Step242Importer.ImportBody(compiled.Value.StepText) : cache.ImportCanonical(compiled.Value.StepText);+ if (!imported.IsSuccess || imported.Value is null)+ {+ diagnostics.AddRange(imported.Diagnostics.Select(d => new AssemblyDiagnostic("assembly-definition-reimport-failed", d.Message) { SourceSpan = reference.Origin }));+ return null;+ }+ var provenance = new[] { new SemanticProvenance("Firmament-definition", reference.Path, reference.Definition,+ reference.DeclarationOrigin) };+ result = new(identity, "module:" + reference.Definition, imported.Value,+ graph.Ports(reference, identity, diagnostics), new("", identity, "module:" + reference.Definition,+ Convert.ToHexString(SHA256.HashData(Encoding.UTF8.GetBytes(compiled.Value.StepText))), Metrics(imported.Value), provenance),+ compiled.Value.StepText, compiled.Value.Cir);+ }+ if (result is null) return null;+ var stableId = "assembly-definition:" + Convert.ToHexString(SHA256.HashData(Encoding.UTF8.GetBytes(identity)))[..16];+ return result with { DefinitionIdentity = identity, DeclarationScope = null,+ Artifact = result.Artifact with { DefinitionIdentity = identity, StableId = stableId } };+ }+ return cache is null ? Build() : cache.Materialize(identity, projection?.Text, reference.Path, diagnostics, graph.Project, Build);+ }+}diff --git a/Aetheris.Kernel.Firmament/Assembly/FirmamentAssemblyDocumentProfile.cs b/Aetheris.Kernel.Firmament/Assembly/FirmamentAssemblyDocumentProfile.csindex b85f73a9..ee2c4a97 100644--- a/Aetheris.Kernel.Firmament/Assembly/FirmamentAssemblyDocumentProfile.cs+++ b/Aetheris.Kernel.Firmament/Assembly/FirmamentAssemblyDocumentProfile.cs@@ -78,11 +78,12 @@ public sealed class FirmamentAssemblyDocumentCompilerpublic static IReadOnlyList<AssemblyDiagnostic> ValidateProfile(string source, FirmamentDocumentProfile profile){if (profile == FirmamentDocumentProfile.General) return [];- var assemblies = Regex.Matches(source, @"(?m)^\s*Assembly\s+[A-Za-z_]\w*\s*\{", RegexOptions.CultureInvariant).Count;- // A Template-produced Assembly is a reusable definition, not an exported- // product root. It intentionally shares the existing Template keyword.- var templateAssemblies = Regex.Matches(source, @"\bTemplate\s*<[^>]+>\s*Assembly\s+[A-Za-z_]\w*\s*\{", RegexOptions.CultureInvariant).Count;- var roots = assemblies - templateAssemblies;+ var syntax = Aetheris.Kernel.Firmament.FirmamentV2.Syntax.FirmamentSyntaxParser.Parse(source);+ // The syntax owner reports malformed source; root counting must not hide+ // its diagnostic behind a line-oriented profile guess.+ if (!syntax.IsSuccess) return [];+ var roots = syntax.Document.Statements.OfType<Aetheris.Kernel.Firmament.FirmamentV2.Syntax.DeclarationSyntax>()+ .Count(d => d.Type.Name.Text == "Assembly" && !d.Occurrence && !d.Modifiers.Any(m => m.Name.Text == "Template"));return roots switch{0 => [new("assembly-profile-no-root", ".firmasm requires exactly one exported/root Assembly product; none was found.")],diff --git a/Aetheris.Kernel.Firmament/Assembly/FirmamentCompilationSession.cs b/Aetheris.Kernel.Firmament/Assembly/FirmamentCompilationSession.csindex f6f47035..d46c37f7 100644--- a/Aetheris.Kernel.Firmament/Assembly/FirmamentCompilationSession.cs+++ b/Aetheris.Kernel.Firmament/Assembly/FirmamentCompilationSession.cs@@ -35,6 +35,8 @@ public sealed class FirmamentCompilationSession : IDisposable}public AssemblyM1CompilationResult CompileFile(string path) => Run(() => pipeline.CompileFile(path));+ internal AssemblyM1CompilationResult CompileModule(Aetheris.Kernel.Firmament.Modules.FirmamentModuleGraph graph,+ Aetheris.Kernel.Firmament.Modules.FirmamentModuleGraph.Reference reference) => Run(() => pipeline.CompileModule(graph, reference));public AssemblyM1CompilationResult Compile(string source, string sourceIdentity = "<memory>") => Run(() => pipeline.Compile(source, sourceIdentity));public AssemblyM1CompilationResult CompileProject(FirmamentProjectSnapshot project) => Run(() => pipeline.CompileProject(project));diff --git a/Aetheris.Kernel.Firmament/FirmamentV2/Syntax/FirmamentDataBinding.cs b/Aetheris.Kernel.Firmament/FirmamentV2/Syntax/FirmamentDataBinding.csindex 391cb352..9f1452b8 100644--- a/Aetheris.Kernel.Firmament/FirmamentV2/Syntax/FirmamentDataBinding.cs+++ b/Aetheris.Kernel.Firmament/FirmamentV2/Syntax/FirmamentDataBinding.cs@@ -77,6 +77,11 @@ internal sealed class FirmamentDataBinding{scopes[statement] = scope;if (statement is not DeclarationSyntax { Name: { } name } d) continue;+ if (d.Type.Name.Text == "Record" && d.Modifiers.Any(m => m.Name.Text == "Inventory"))+ {+ Error("firmament-module-context-required", $"Inventory Record '{name.Text}' requires an Assembly or Scene project loader. Reference this module from a consuming project; it is not an ordinary data Record.", d.Span, name.Text, "Module binding");+ continue;+ }var space = d.Type.Name.Text is "Record" or "Enum" ? "type": d.Type.Name.Text == "Static" || d.Type.Name.Text == "Table" && d.Modifiers.Any(m => m.Name.Text == "Static") ? "value" : null;if (space is null) { scope.Values.Add(name.Text); continue; }@@ -198,8 +203,8 @@ internal sealed class FirmamentDataBinding{if (name.Text != text && !edits.Any(e => e.Span == name.Span)) edits.Add(new(name.Span, text));}- void Error(string code, string message, FirmamentV2SourceSpan span, string name) => errors.Add(new(code, "fatal", message, Target: name)- { SourceSpan = span, IsOriginalSource = true, Stage = "Data binding" });+ void Error(string code, string message, FirmamentV2SourceSpan span, string name, string stage = "Data binding") => errors.Add(new(code, "fatal", message, Target: name)+ { SourceSpan = span, IsOriginalSource = true, Stage = stage });}internal string DisplayName(string identity) => identities.TryGetValue(identity, out var symbol) ? symbol.Name : identity;diff --git a/Aetheris.Kernel.Firmament/FirmamentV2/Syntax/FirmamentSyntaxParser.cs b/Aetheris.Kernel.Firmament/FirmamentV2/Syntax/FirmamentSyntaxParser.csindex 612fbb28..9f236b08 100644--- a/Aetheris.Kernel.Firmament/FirmamentV2/Syntax/FirmamentSyntaxParser.cs+++ b/Aetheris.Kernel.Firmament/FirmamentV2/Syntax/FirmamentSyntaxParser.cs@@ -168,6 +168,7 @@ public static class FirmamentSyntaxParserwhile ((type.Name.Text is "Template" or "Concept" or "Construction" or "Radial" or "Linear" or "Mirror" or "Mirrored" or "Semantic"&& Current.Kind == SyntaxTokenKind.Identifier && (Peek(1).Kind == SyntaxTokenKind.Identifier || Peek(1).Text == "<"))|| type.Name.Text == "Static" && Is("Table")+ || type.Name.Text == "Inventory" && Is("Record")|| type.Name.Text is "Assert" or "Analysis" or "analysis" or "Construct" or "Extend" or "Comptime" or "proposes" or "manufacturing" && Current.Kind == SyntaxTokenKind.Identifier){modifiers.Add(type); type = Type(qualified: type.Name.Text == "Construct");@@ -485,6 +486,10 @@ public static class FirmamentSyntaxParser|| left is LiteralSyntax { Kind: LiteralKind.Number } && Current.Span.Start == left.Span.Start + left.Span.Length)&& left is LiteralSyntax or SequenceSyntax or ReferenceSyntax){ left = new QuantitySyntax(left, Identifier(), Span(start)); continue; }+ // A product-tree tag starts the next statement, including after+ // a newline-terminated field such as units: mm. It is not '<'+ // arithmetic or a generic argument list on the preceding value.+ if (Pair("<", "/") || Is("<") && Peek(1).Kind == SyntaxTokenKind.Identifier && Peek(2).Kind == SyntaxTokenKind.Identifier) break;if (!Operator(out var binary, out var precedence, out var width) || precedence < minimum || stopGreater && Is(">")) break;at += width;left = new BinarySyntax(left, binary, Expression(precedence + (binary == BinaryOperator.Power ? 0 : 1), allowObject, stopGreater), Span(start));diff --git a/Aetheris.Kernel.Firmament/Modules/FirmamentModuleGraph.cs b/Aetheris.Kernel.Firmament/Modules/FirmamentModuleGraph.csnew file mode 100644index 00000000..d79e8df9--- /dev/null+++ b/Aetheris.Kernel.Firmament/Modules/FirmamentModuleGraph.cs@@ -0,0 +1,365 @@+using System.Security.Cryptography;+using System.Text;+using Aetheris.Kernel.Firmament.Assembly;+using Aetheris.Kernel.Firmament.FirmamentV2;+using Aetheris.Kernel.Firmament.FirmamentV2.Syntax;+using Aetheris.Semantics;++namespace Aetheris.Kernel.Firmament.Modules;++public sealed record FirmamentInventoryBinding(string Name, string Kind, string SourceFile, string Export,+ string DefinitionIdentity, SemanticSourceSpan SourceSpan);++/// <summary>Per-compilation dependency and export authority. Inventories bind module+/// references, never inject imported declarations into the caller. Legacy includes+/// retain their existing declaration composition through an explicitly mapped projection.</summary>+[FirmamentConstruct("Inventory", "Inventory", Context = "Document", Entry = "Inventory Record Components { }",+ Description = "Compile-time catalog of typed Part, Subassembly, Assembly and Scene module references.")]+internal sealed class FirmamentModuleGraph+{+ internal sealed class Module(string path, string text, DocumentSyntax syntax)+ {+ internal string Path { get; } = path;+ internal string Text { get; } = text;+ internal DocumentSyntax Syntax { get; } = syntax;+ internal List<Module> Includes { get; } = [];+ internal List<Edit> Edits { get; } = [];+ }+ internal sealed record Reference(string Identity, string Kind, string Path, Module? Module,+ DeclarationSyntax? Export, string Definition, SemanticSourceSpan Origin)+ {+ internal SemanticSourceSpan DeclarationOrigin { get; init; } = Export is null ? Origin : new(Path,Export.Span.Start,Export.Span.Length);+ }+ internal sealed record Edit(FirmamentV2SourceSpan Span, string Text);+ internal sealed record Segment(int Start, int Length, SemanticSourceSpan Origin, bool Exact);+ internal sealed record Projection(string Text, IReadOnlyList<Segment> Segments, string SourceIdentity)+ {+ internal SemanticSourceSpan? Original(FirmamentV2SourceSpan span) => Segments+ .Where(s => span.Start >= s.Start && span.Start + span.Length <= s.Start + s.Length)+ .OrderBy(s => s.Length).Select(s => s.Exact+ ? new SemanticSourceSpan(s.Origin.Source, s.Origin.Start + span.Start - s.Start, span.Length) : s.Origin).FirstOrDefault();+ internal AssemblyDiagnostic Map(AssemblyDiagnostic diagnostic) => diagnostic.SourceSpan is { Length: > 0 } span && span.Source == SourceIdentity+ && Original(new(span.Start, span.Length)) is { } original ? diagnostic with { SourceSpan = original } : diagnostic;+ }+ private sealed class Scope(Scope? parent)+ {+ internal readonly Dictionary<string, Dictionary<string, Reference>> Inventories = new(StringComparer.Ordinal);+ internal readonly HashSet<string> Values = new(StringComparer.Ordinal);+ internal Dictionary<string, Reference>? Resolve(string name) => Inventories.GetValueOrDefault(name)+ ?? (Values.Contains(name) ? null : parent?.Resolve(name));+ }+ private readonly Dictionary<string, Module> modules;+ private readonly Dictionary<string, Reference> references = new(StringComparer.Ordinal);+ private readonly List<string> active = [];+ private readonly string allowedRoot;+ private readonly string identityRoot;+ internal FirmamentProjectSnapshot? Project { get; }+ internal List<AssemblyDiagnostic> Diagnostics { get; } = [];+ internal Module Root { get; private set; } = null!;+ internal bool HasModuleBindings => references.Count > 0;+ internal List<FirmamentInventoryBinding> InventoryBindings { get; } = [];+ internal IReadOnlyList<AssemblySourceDependencyIr> Dependencies => modules.Values.Select(m =>+ new AssemblySourceDependencyIr(m.Path, Hash(m.Text), ReferenceEquals(m, Root))).Concat(references.Values+ .Where(r => r.Module is null && File.Exists(r.Path)).Select(r => new AssemblySourceDependencyIr(r.Path,+ Convert.ToHexString(SHA256.HashData(File.ReadAllBytes(r.Path))), false))).DistinctBy(d => d.Path).ToArray();++ private FirmamentModuleGraph(string root, FirmamentProjectSnapshot? project)+ {+ Project = project;+ allowedRoot = project is null ? (!root.StartsWith('<') ? AssemblyM0Parser.FindAllowedSourceRoot(Path.GetFullPath(root)) : "") : "";+ identityRoot = project is null ? (!root.StartsWith('<') ? Path.GetDirectoryName(Path.GetFullPath(root))! : "")+ : (root.Contains('/') ? root[..root.LastIndexOf('/')] : "");+ modules = new(project is null ? StringComparer.OrdinalIgnoreCase : StringComparer.Ordinal);+ }+ internal static FirmamentModuleGraph Load(string text, string identity, FirmamentProjectSnapshot? project = null)+ {+ var graph = new FirmamentModuleGraph(identity, project);+ graph.Root = graph.Read(identity, text, null)!;+ return graph;+ }+ internal static bool HasImports(string source) => FirmamentLanguageAnalysisService.Lex(source)+ .Any(t => t.Shape == "identifier" && (t.Text.Equals("Inventory", StringComparison.OrdinalIgnoreCase) || t.Text is "Include" or "include"));+ internal bool TryReference(string identity, out Reference reference) => references.TryGetValue(Base(identity), out reference!);+ private static string Base(string identity) => identity.Contains('<') ? identity[..identity.IndexOf('<')].Trim() : identity.Trim();+ private static string Hash(string text) => Convert.ToHexString(SHA256.HashData(Encoding.UTF8.GetBytes(text)));++ private Module? Read(string path, string? supplied, SemanticSourceSpan? use, bool include = false)+ {+ var cycleAt=active.FindIndex(p => modules.Comparer.Equals(p,path));+ if (cycleAt >= 0)+ {+ var chain=active.Skip(cycleAt).Append(path);+ if (include && Project is null) chain=chain.Select(p => Path.GetFileName(p));+ Error(include ? "assembly-include-cycle" : "firmament-module-cycle", "Module dependency cycle: " + string.Join(" -> ",chain),use);+ return null;+ }+ if (modules.TryGetValue(path, out var existing)) return existing;+ if (active.Count >= 64 || modules.Count >= 1024)+ { Error("firmament-module-limit", "A project supports at most 64 dependency levels and 1024 source modules.", use); return null; }+ string text;+ if (supplied is not null) text = supplied;+ else if (Project is not null && Project.TryResolve(path, out var document)) text = document;+ else if (Project is null && File.Exists(path)) text = File.ReadAllText(path);+ else { Error("assembly-include-file-not-found", $"Module '{path}' was not found.", use); return null; }+ var parsed = FirmamentSyntaxParser.Parse(text, path);+ var module = new Module(path, text, parsed.Document); modules.Add(path, module);+ if (!parsed.IsSuccess)+ {+ Diagnostics.AddRange(parsed.Diagnostics.Select(d => new AssemblyDiagnostic(d.Code, d.Message)+ { SourceSpan = d.SourceSpan is { } span ? new(path, span.Start, span.Length) : use }));+ return module;+ }+ active.Add(path);+ Bind(module, module.Syntax.Statements, new(null));+ active.RemoveAt(active.Count - 1);+ return module;+ }++ private void Bind(Module module, IReadOnlyList<StatementSyntax> statements, Scope scope)+ {+ foreach (var declaration in statements.OfType<DeclarationSyntax>().Where(d => !IsInventory(d) && d.Name is not null))+ scope.Values.Add(declaration.Name!.Text);+ foreach (var malformed in statements.OfType<DeclarationSyntax>().Where(d => d.Type.Name.Text == "Inventory"+ || d.Modifiers.Any(m => m.Name.Text == "Inventory") && !IsInventory(d)))+ Error("firmament-inventory-header-invalid", "Inventory must qualify a Record: Inventory Record Name { ... }.", At(module, malformed.Span));+ foreach (var directive in statements.OfType<DirectiveSyntax>().Where(d => d.Kind == DirectiveKind.Include))+ {+ if (directive.Value is not LiteralSyntax { Kind: LiteralKind.String })+ { Error("firmament-module-include-invalid", "include requires a quoted Firmament locator.", At(module, directive.Span)); continue; }+ var locator = Locator(module,(LiteralSyntax)directive.Value);+ if (locator is null) continue;+ var childPath = Resolve(module, locator, "Firmament", At(module, directive.Span), include: true);+ if (childPath is not null && Read(childPath, null, At(module, directive.Span), include: true) is { } child) module.Includes.Add(child);+ module.Edits.Add(new(directive.Span, Blank(module.Text, directive.Span)));+ }+ foreach (var inventory in statements.OfType<DeclarationSyntax>().Where(IsInventory))+ {+ if (inventory.Name is null || inventory.Body is null || inventory.HasParameterList || inventory.Occurrence+ || inventory.Annotation is not null || inventory.Initializer is not null || inventory.ResultType is not null+ || inventory.Clauses.Count > 0 || inventory.Modifiers.Count != 1 || inventory.Type.Span.Length != inventory.Type.Name.Span.Length+ || inventory.Modifiers[0].Span.Length != inventory.Modifiers[0].Name.Span.Length)+ { Error("firmament-inventory-header-invalid", "Use Inventory Record Name { member: Kind = Adapter(\"locator\").Export }.", At(module, inventory.Span)); continue; }+ var fields = new Dictionary<string, Reference>(StringComparer.Ordinal);+ if (!scope.Inventories.TryAdd(inventory.Name.Text, fields)+ || statements.OfType<DeclarationSyntax>().Any(d => !IsInventory(d) && d.Name?.Text == inventory.Name.Text))+ Error("firmament-inventory-duplicate-name", $"Inventory '{inventory.Name.Text}' conflicts with another declaration in this scope.", At(module, inventory.Name.Span));+ foreach (var statement in inventory.Body.Statements)+ {+ if (statement is not FieldSyntax { Value: TypedValueSyntax typed } field+ || typed.Type is not ReferenceSyntax kind || kind.Name.Text is not ("Part" or "Subassembly" or "Assembly" or "Scene"))+ { Error("firmament-inventory-field-invalid", "Inventory members require an explicit Part, Subassembly, Assembly or Scene type and one resource binding.", At(module, statement.Span)); continue; }+ var origin = At(module, field.Span);+ var export = typed.Value is MemberSyntax member ? member.Member.Text : null;+ var value = typed.Value is MemberSyntax selected ? selected.Target : typed.Value;+ if (value is not CallSyntax { Target: ReferenceSyntax adapter } call || adapter.Name.Text is not ("Firmament" or "Step")+ || call.Arguments.Count != 1 || call.Arguments[0].Name is not null+ || call.Arguments[0].Value is not LiteralSyntax { Kind: LiteralKind.String })+ { Error("firmament-inventory-resource-invalid", "Use Firmament(\"locator\").Export or Step(\"locator\").", origin); continue; }+ if (adapter.Name.Text == "Firmament" && export is null || adapter.Name.Text == "Step" && (export is not null || kind.Name.Text != "Part"))+ { Error("firmament-inventory-kind-mismatch", "Firmament requires a named export. Step currently supplies one Part, with no member selector.", origin); continue; }+ var locator = Locator(module,(LiteralSyntax)call.Arguments[0].Value);+ if (locator is null) continue;+ var path = Resolve(module, locator, adapter.Name.Text, origin);+ if (path is null) continue;+ Module? child = null; DeclarationSyntax? declaration = null;+ if (adapter.Name.Text == "Firmament")+ {+ child = Read(path, null, origin);+ if (child is null) continue;+ var candidates = Exports(child).Where(d => d.Name?.Text == export).ToArray();+ if (candidates.Length != 1)+ { Error("firmament-inventory-export-unresolved", $"Module '{locator}' must export exactly one declaration named '{export}'; found {candidates.Length}.", origin); continue; }+ declaration = candidates[0];+ var actual = declaration.Type.Name.Text;+ if (!(kind.Name.Text == "Part" ? actual is "Model" or "Struct" or "Part" : actual == kind.Name.Text))+ { Error("firmament-inventory-kind-mismatch", $"'{locator}.{export}' is {actual}, but '{field.Name.Text}' requires {kind.Name.Text}.", origin); continue; }+ if (declaration.Modifiers.Any(m => m.Name.Text == "Template"))+ { Error("firmament-inventory-specialization-required", "Specialize this Template in its defining module and export its concrete Part, Subassembly, Assembly or Scene result.", origin); continue; }+ }+ var identity = "__Module_" + Hash(IdentityPath(path) + "\0" + kind.Name.Text + "\0" + export)[..20];+ var reference = new Reference(identity, kind.Name.Text, path, child, declaration, export ?? "", origin)+ { DeclarationOrigin = declaration is null ? origin : DeclarationOrigin(declaration) };+ references.TryAdd(identity, reference);+ InventoryBindings.Add(new(inventory.Name.Text+"."+field.Name.Text,kind.Name.Text,path,export ?? "",identity,origin));+ if (!fields.TryAdd(field.Name.Text, reference)) Error("firmament-inventory-duplicate-field", $"Inventory member '{field.Name.Text}' is repeated.", origin);+ }+ module.Edits.Add(new(inventory.Span, Blank(module.Text, inventory.Span)));+ }+ foreach (var declaration in statements.OfType<DeclarationSyntax>().Where(d => !IsInventory(d)))+ {+ if (declaration.Initializer is { } initializer)+ {+ // Concise includes also expose concrete Parts under their authored+ // names. Existing Template applications keep their established owner.+ if (module.Includes.Count > 0 && declaration.Occurrence && declaration.Type.Name.Text == "Part" && initializer is ReferenceSyntax bare)+ {+ var candidates = Exports(module).Where(d => d.Name?.Text == bare.Name.Text && d.Type.Name.Text is "Model" or "Struct" or "Part"+ && !d.Modifiers.Any(m => m.Name.Text is "Template" or "Concept")).ToArray();+ if (candidates.Length > 1)+ Error("firmament-module-export-ambiguous", $"Included Part '{bare.Name.Text}' is ambiguous. Use an Inventory Record to qualify its source.", At(module,bare.Span));+ else if (candidates.Length == 1)+ {+ var identity = "__Module_" + Hash(IdentityPath(module.Path)+"\0included-part\0"+bare.Name.Text)[..20];+ references.TryAdd(identity,new Reference(identity,"Part",module.Path,module,candidates[0],bare.Name.Text,At(module,bare.Span))+ { DeclarationOrigin = DeclarationOrigin(candidates[0]) });+ module.Edits.Add(new(bare.Span,identity));+ }+ }+ var target = initializer is SpecializationSyntax specialization ? specialization.Target : initializer;+ if (target is MemberSyntax { Target: ReferenceSyntax owner } member)+ {+ var fields = scope.Resolve(owner.Name.Text);+ if (fields is null)+ {+ if (FirmamentSyntaxTraversal.Declarations(module.Syntax).Any(d => IsInventory(d) && d.Name?.Text == owner.Name.Text))+ Error("firmament-inventory-not-visible", $"Inventory '{owner.Name.Text}' is shadowed or not visible in this scope.", At(module, target.Span));+ continue;+ }+ if (!declaration.Occurrence)+ Error("firmament-inventory-use-unsupported", "Use an Inventory module reference as a Part, Assembly or Scene occurrence definition.", At(module, target.Span));+ else if (!fields.TryGetValue(member.Member.Text, out var reference))+ Error("firmament-inventory-member-unresolved", $"Inventory '{owner.Name.Text}' has no member '{member.Member.Text}'.", At(module, member.Span));+ else if (!(declaration.Type.Name.Text == "Assembly" ? reference.Kind is "Assembly" or "Subassembly" : declaration.Type.Name.Text == reference.Kind))+ Error("firmament-inventory-kind-mismatch", $"A {declaration.Type.Name.Text} occurrence cannot use {reference.Kind} '{owner.Name.Text}.{member.Member.Text}'.", At(module, target.Span));+ else if (initializer is SpecializationSyntax)+ Error("firmament-inventory-specialization-required", "Inventory entries reference concrete modules. Specialize Templates in the defining module before exporting them.", At(module, initializer.Span));+ else module.Edits.Add(new(target.Span, reference.Identity));+ }+ }+ if (declaration.Body is not null)+ {+ var bodyScope=new Scope(scope);+ foreach (var parameter in declaration.Parameters.Concat(declaration.Modifiers.Where(m => m.Name.Text == "Template").SelectMany(m => m.Arguments)))+ if (parameter.Name is not null) bodyScope.Values.Add(parameter.Name.Text);+ Bind(module,declaration.Body.Statements,bodyScope);+ }+ }+ foreach (var mapping in statements.OfType<MappingSyntax>())+ {+ var bodyScope=new Scope(scope); bodyScope.Values.Add(mapping.Key.Text);+ Bind(module,[mapping.Value],bodyScope);+ }+ }+ private SemanticSourceSpan DeclarationOrigin(DeclarationSyntax declaration)+ {+ var owner=modules.Values.First(m => m.Syntax.Statements.Any(d => ReferenceEquals(d,declaration)));+ return At(owner,declaration.Span);+ }+ private string IdentityPath(string path) => Project is null ? Path.GetRelativePath(identityRoot,path).Replace('\\','/')+ : identityRoot.Length == 0 ? path : Path.GetRelativePath(identityRoot,path).Replace('\\','/');+ private string? Locator(Module module,LiteralSyntax literal)+ {+ try { return FirmamentSyntaxValues.Reference(literal); }+ catch (System.Text.Json.JsonException)+ { Error("firmament-module-locator-invalid", "Invalid quoted locator. Use / between path segments and valid string escapes.",At(module,literal.Span)); return null; }+ }+ private static bool IsInventory(DeclarationSyntax d) => d.Type.Name.Text == "Record" && d.Modifiers.Any(m => m.Name.Text == "Inventory");+ private static SemanticSourceSpan At(Module module, FirmamentV2SourceSpan span) => new(module.Path, span.Start, span.Length);+ private static string Blank(string text, FirmamentV2SourceSpan span) => new(text.Substring(span.Start, span.Length).Select(c => c is '\r' or '\n' ? c : ' ').ToArray());+ private static IEnumerable<DeclarationSyntax> Exports(Module module) => module.Includes.SelectMany(Exports)+ .Concat(module.Syntax.Statements.OfType<DeclarationSyntax>().Where(d => !IsInventory(d))).Distinct<DeclarationSyntax>(ReferenceEqualityComparer.Instance);+ private void Error(string code, string message, SemanticSourceSpan? span) => Diagnostics.Add(new(code, message) { SourceSpan = span });++ private string? Resolve(Module owner, string locator, string adapter, SemanticSourceSpan origin, bool include = false)+ {+ if (Project is null && owner.Path.StartsWith('<'))+ { Error("firmament-module-context-required", "Resource binding requires a source file identity or a project snapshot.", origin); return null; }+ string path;+ try+ {+ if (string.IsNullOrWhiteSpace(locator) || (!include || Project is not null) && (Path.IsPathRooted(locator) || locator.Contains(':')) || locator.Contains('#') || locator.Contains('?')) throw new ArgumentException();+ path = Project is null ? Path.GetFullPath(Path.Combine(Path.GetDirectoryName(owner.Path)!, locator.Replace('/', Path.DirectorySeparatorChar)))+ : FirmamentProjectSnapshot.NormalizePath((owner.Path.Contains('/') ? owner.Path[..(owner.Path.LastIndexOf('/') + 1)] : "") + locator);+ if (Project is null && !path.StartsWith(Path.TrimEndingDirectorySeparator(allowedRoot) + Path.DirectorySeparatorChar, StringComparison.OrdinalIgnoreCase)) throw new ArgumentException();+ }+ catch (ArgumentException) { Error("assembly-include-outside-root", $"Resource '{locator}' escapes the project root or has an invalid path.", origin); return null; }+ var extensions = adapter == "Step" ? new[] { ".step", ".stp" } : new[] { ".firmament", ".firmasm" };+ var extension = Path.GetExtension(path);+ // Preserve the historical snapshot Include spelling when its document-relative target is absent.+ if (include && Project is not null && !Project.TryResolve(path, out _))+ {+ try { var legacy = FirmamentProjectSnapshot.NormalizePath(locator); if (Project.TryResolve(legacy, out _)) path = legacy; }+ catch (ArgumentException) { /* The enclosing path check owns rejection. */ }+ }+ if (extension.Length > 0 && !extensions.Contains(extension, StringComparer.OrdinalIgnoreCase))+ { Error(include ? "assembly-include-extension-invalid" : "firmament-inventory-extension-invalid", $"{adapter} resource '{locator}' requires {string.Join(" or ", extensions)}.", origin); return null; }+ if (adapter == "Step" && Project is not null)+ { Error("assembly-profile-external-resource-unsupported", "This project snapshot contains source documents only; provide STEP through a file-backed project.", origin); return null; }+ bool Exists(string candidate) => Project is null ? File.Exists(candidate) : Project.TryResolve(candidate, out _);+ var matches = extension.Length == 0 ? extensions.Select(e => path + e).Where(Exists).ToArray() : Exists(path) ? [path] : Array.Empty<string>();+ if (matches.Length != 1)+ { Error(matches.Length == 0 ? "assembly-include-file-not-found" : "firmament-module-locator-ambiguous", $"Resource '{locator}' matched {matches.Length} files. " + (matches.Length == 0 ? "Check its path." : "Specify its extension to select one."), origin); return null; }+ return matches[0];+ }++ internal Projection ProjectSource(Module module, DeclarationSyntax? selected = null, bool assemblyRoot = false, bool partContext = false)+ {+ var text = new StringBuilder(); var segments = new List<Segment>(); var emitted = new HashSet<Module>();+ void Append(Module node)+ {+ if (!emitted.Add(node)) return;+ foreach (var include in node.Includes) Append(include);+ var edits = node.Edits.ToList();+ if (partContext)+ foreach (var d in node.Syntax.Statements.OfType<DeclarationSyntax>().Where(d => d.Type.Name.Text is "Assembly" or "Subassembly" or "Scene"))+ edits.Add(new(d.Span, Blank(node.Text, d.Span)));+ if (selected is not null)+ {+ foreach (var d in node.Syntax.Statements.OfType<DeclarationSyntax>().Where(d => d != selected && !IsInventory(d)+ && !d.Modifiers.Any(m => m.Name.Text is "Template" or "Concept") && d.Type.Name.Text is "Model" or "Struct" or "Part" or "Assembly" or "Subassembly" or "Scene"))+ edits.Add(new(d.Span, Blank(node.Text, d.Span)));+ if (node.Syntax.Statements.Contains(selected) && assemblyRoot && selected.Type.Name.Text == "Subassembly") edits.Add(new(selected.Type.Name.Span, "Assembly"));+ if (node.Syntax.Statements.Contains(selected) && selected.Type.Name.Text == "Part") edits.Add(new(selected.Type.Name.Span, "Struct"));+ }+ var cursor = 0;+ foreach (var edit in edits.OrderBy(e => e.Span.Start).ThenByDescending(e => e.Span.Length))+ {+ if (edit.Span.Start < cursor) continue; // an erased enclosing Inventory/root owns its entire span+ Copy(cursor, edit.Span.Start - cursor);+ segments.Add(new(text.Length, edit.Text.Length, At(node, edit.Span), edit.Text.Length == edit.Span.Length)); text.Append(edit.Text);+ cursor = edit.Span.Start + edit.Span.Length;+ }+ Copy(cursor, node.Text.Length - cursor); text.AppendLine();+ void Copy(int start, int length) { if (length == 0) return; segments.Add(new(text.Length, length, new(node.Path, start, length), true)); text.Append(node.Text, start, length); }+ }+ // Keep the established include transport order and newline spelling for geometry identities.+ if (module.Includes.Count == 0 && module.Edits.Count == 0 && selected is null && !partContext)+ return new(module.Text, [new(0, module.Text.Length, new(module.Path, 0, module.Text.Length), true)], module.Path);+ Append(module);+ return new(text.ToString(), segments, module.Path);+ }++ internal Reference LocalPart(Module module, string definition)+ {+ if (TryReference(definition, out var existing)) return existing;+ var identity = "__Module_" + Hash(IdentityPath(module.Path) + "\0local-part\0" + definition)[..20];+ var reference = new Reference(identity, "Part", module.Path, module, null, definition, new(module.Path, 0, 0));+ references.TryAdd(identity, reference); return reference;+ }++ internal AssemblyM0Parser.ParseResult ParseAssembly(Reference reference)+ {+ var projection = ProjectSource(reference.Module!, reference.Export, assemblyRoot: true);+ return new AssemblyM0Parser().ParseBound(projection.Text, reference.Path, this, reference.Module!, projection, reference.Export);+ }+ internal AssemblyMemberSource QualifyParts(Module module, AssemblyMemberSource root) => root with+ {+ DefinitionIdentity = root.Kind == AssemblyInstanceKind.Part ? LocalPart(module, root.DefinitionIdentity).Identity : root.DefinitionIdentity,+ Children = root.Children.Select(child => QualifyParts(module, child)).ToArray()+ };+ internal IReadOnlyList<SemanticValue> Ports(Reference reference, string use, List<AssemblyDiagnostic> diagnostics,+ DerivedValueCache<PublishedPortBinding>? cache = null)+ {+ if (reference.Module is null || reference.Kind != "Part") return [];+ var projection = ProjectSource(reference.Module, reference.Export, partContext: true);+ var identity = PartIdentity(reference, use);+ return reference.Export is null || reference.Export.Modifiers.Any(m => m.Name.Text == "Template")+ ? AssemblyPublishedPorts.BindAuthored(identity, projection.Text, reference.Path, diagnostics, Project, [], cache)+ : AssemblyPublishedPorts.Read(projection.Text, reference.Definition, use, reference.Path, diagnostics);+ }+ internal string PartIdentity(Reference reference, string use)+ {+ var suffix = use.Contains('<') ? use[use.IndexOf('<')..] : "";+ return reference.Definition + (suffix.Length > 0 ? suffix : reference.Export?.Modifiers.Any(m => m.Name.Text == "Template") == true ? "<>" : "");+ }+}diff --git a/Aetheris.Kernel.Firmament/Scene/SceneAuthoring.cs b/Aetheris.Kernel.Firmament/Scene/SceneAuthoring.csindex 0e47ae65..14ecc03b 100644--- a/Aetheris.Kernel.Firmament/Scene/SceneAuthoring.cs+++ b/Aetheris.Kernel.Firmament/Scene/SceneAuthoring.cs@@ -74,7 +74,11 @@ public sealed record SceneLayoutFrame(string Identity, AssemblyFrameTransformSoupublic sealed record SceneSource(string Name, string Units, string DefinitionSource, string SourceIdentity,IReadOnlyList<SceneRoom> Rooms, IReadOnlyList<SceneOpening> Openings, IReadOnlyList<SceneCamera> Cameras,IReadOnlyList<SceneOccurrenceSource> Occurrences, AssemblyAppearanceCatalog Looks,- IReadOnlyList<FirmamentV2CanonicalPatternDecl> Patterns, IReadOnlyList<SceneLayoutFrame> LayoutFrames);+ IReadOnlyList<FirmamentV2CanonicalPatternDecl> Patterns, IReadOnlyList<SceneLayoutFrame> LayoutFrames)+{+ public IReadOnlyList<Aetheris.Kernel.Firmament.Modules.FirmamentInventoryBinding> InventoryBindings { get; init; } = [];+ public IReadOnlyList<AssemblySourceDependencyIr> SourceDependencies { get; init; } = [];+}public sealed record SceneParseResult(SceneSource? Source, IReadOnlyList<AssemblyDiagnostic> Diagnostics){ public bool IsSuccess => Source is not null && Diagnostics.All(d => d.Severity != AssemblyDiagnosticSeverity.Error); }@@ -96,10 +100,41 @@ public static class SceneAuthoringpublic static SceneParseResult Parse(string input, string sourceIdentity = "<memory>"){var diagnostics = new List<AssemblyDiagnostic>();- try { return ParseCore(input, sourceIdentity, diagnostics); }+ try+ {+ if (Aetheris.Kernel.Firmament.Modules.FirmamentModuleGraph.HasImports(input))+ {+ var graph=Aetheris.Kernel.Firmament.Modules.FirmamentModuleGraph.Load(input,sourceIdentity);+ if (graph.Diagnostics.Count > 0) return new(null,graph.Diagnostics);+ var projection=graph.ProjectSource(graph.Root);+ var parsed=ParseCore(projection.Text,sourceIdentity,diagnostics);+ return ApplyModuleContext(parsed,graph,projection);+ }+ return ParseCore(input, sourceIdentity, diagnostics);+ }catch (SceneSyntaxException ex) { diagnostics.Add(new(ex.Code, ex.Message)); return new(null, diagnostics); }}+ internal static SceneParseResult ApplyModuleContext(SceneParseResult parsed,+ Aetheris.Kernel.Firmament.Modules.FirmamentModuleGraph graph,+ Aetheris.Kernel.Firmament.Modules.FirmamentModuleGraph.Projection projection)+ {+ SemanticSourceSpan Original(SemanticSourceSpan span) => span.Source == projection.SourceIdentity+ ? projection.Original(new(span.Start,span.Length)) ?? span : span;+ return parsed with+ {+ Diagnostics=parsed.Diagnostics.Select(projection.Map).ToArray(),+ Source=parsed.Source is not { } source ? null : source with+ {+ InventoryBindings=graph.InventoryBindings.ToArray(), SourceDependencies=graph.Dependencies,+ Occurrences=source.Occurrences.Select(o => o with { Span=Original(o.Span) }).ToArray(),+ Rooms=source.Rooms.Select(o => o with { Span=Original(o.Span) }).ToArray(),+ Openings=source.Openings.Select(o => o with { Span=Original(o.Span) }).ToArray(),+ Cameras=source.Cameras.Select(o => o with { Span=Original(o.Span) }).ToArray()+ }+ };+ }+private static SceneParseResult ParseCore(string input, string identity, List<AssemblyDiagnostic> diagnostics){var normalized = FirmamentSourceSpelling.Normalize(input);@@ -243,7 +278,7 @@ public static class SceneAuthoringwhile (!(r.Peek == "<" && r.Next == "/")) ReadOccurrence(r,group);r.Expect("<"); r.Expect("/"); r.Expect("Group"); r.Expect(">"); return;}- if (kind is not ("Part" or "Assembly")) Fail("scene-occurrence-kind-invalid", "Scene occurrences are Part or Assembly.");+ if (kind is not ("Part" or "Assembly" or "Scene")) Fail("scene-occurrence-kind-invalid", "Scene occurrences are Part, Assembly or Scene.");r.Expect("="); var definition = r.UntilTagEnd(); var content = r.UntilClosing(kind);var prefix=$"<{kind} {id}>"; var suffix=$"</{kind}>";var occurrenceBody=FirmamentSourceSpelling.Normalize(prefix+content.Text+suffix)[prefix.Length..^suffix.Length];diff --git a/Aetheris.Kernel.Firmament/Scene/SceneCompilation.cs b/Aetheris.Kernel.Firmament/Scene/SceneCompilation.csindex 2d30d957..230eed2a 100644--- a/Aetheris.Kernel.Firmament/Scene/SceneCompilation.cs+++ b/Aetheris.Kernel.Firmament/Scene/SceneCompilation.cs@@ -6,6 +6,8 @@ using System.Text.RegularExpressions;using Aetheris.Kernel.Core.Math;using Aetheris.Kernel.Firmament.Assembly;using Aetheris.Semantics;+using Aetheris.Kernel.Firmament.Modules;+using Aetheris.Kernel.Firmament.FirmamentV2.Syntax;namespace Aetheris.Kernel.Firmament.Scene;@@ -35,6 +37,7 @@ public sealed class FirmamentSceneSession : IDisposable// identity is what lets the web runtime send unchanged definitions as retained stubs.private readonly DerivedValueCache<AssemblyDisplayMeshDefinition> sceneDefinitions = new();private readonly DerivedValueCache<(AssemblyDisplayMeshDefinition Source,AssemblyDisplayMeshDefinition Derived)> assemblyDefinitions = new();+ private readonly Dictionary<string,FirmamentSceneSession> nestedScenes = new(StringComparer.Ordinal);private bool disposed;public SceneCompilationResult CompileFile(string path) => Compile(File.ReadAllText(path),Path.GetFullPath(path));public SceneCompilationResult CompileProject(FirmamentProjectSnapshot project) => project.TryResolve(project.RootDocument, out var source)@@ -42,23 +45,63 @@ public sealed class FirmamentSceneSession : IDisposable: new(null, [new("scene-project-root-missing", project.RootDocument)]);public SceneCompilationResult Compile(string source, string sourceIdentity = "<memory>", FirmamentProjectSnapshot? project = null){+ FirmamentModuleGraph? graph = null;+ if (FirmamentModuleGraph.HasImports(source))+ {+ graph = FirmamentModuleGraph.Load(source, sourceIdentity, project);+ if (graph.Diagnostics.Count > 0) return new(null,graph.Diagnostics);+ }+ return CompileBound(source,sourceIdentity,project,graph,graph?.Root);+ }+ private SceneCompilationResult CompileBound(string source,string sourceIdentity,FirmamentProjectSnapshot? project,+ FirmamentModuleGraph? graph,FirmamentModuleGraph.Module? module,DeclarationSyntax? selected = null)+ {+ var projection = graph is null ? null : graph.ProjectSource(module!,selected);+ source = projection?.Text ?? source;lock (gate){ObjectDisposedException.ThrowIf(disposed,this);var watch = Stopwatch.StartNew(); var parsed = SceneAuthoring.Parse(source,sourceIdentity);+ if (projection is not null) parsed=SceneAuthoring.ApplyModuleContext(parsed,graph!,projection);if (!parsed.IsSuccess) return new(null,parsed.Diagnostics);var bindMs=watch.Elapsed.TotalMilliseconds; watch.Restart(); parts.BeginBuild(); sceneDefinitions.BeginBuild(); assemblyDefinitions.BeginBuild();var s=parsed.Source!; var diagnostics=parsed.Diagnostics.ToList();var definitions=new Dictionary<string,AssemblyDisplayMeshDefinition>(StringComparer.Ordinal);var occurrences=new List<AssemblyDisplayMeshOccurrence>(); var nodes=new List<SceneNode>();var looks=new Dictionary<string,AssemblyAppearanceBinding>(StringComparer.Ordinal);+ var compiledScenes=new Dictionary<string,CompiledScene>(StringComparer.Ordinal);var compiledAssemblies=new Dictionary<string,AssemblyM1CompilationResult>(StringComparer.OrdinalIgnoreCase);var preparedAssemblies=new Dictionary<string,AssemblyDisplayMeshDocument>(StringComparer.OrdinalIgnoreCase);double displayMs=0;var materializedParts=new Dictionary<string,MaterializedAssemblyDefinition>(StringComparer.Ordinal);foreach (var item in s.Occurrences){- if (item.Kind == "Assembly")+ if (graph?.TryReference(item.Definition,out var imported) == true && item.Kind == "Scene")+ {+ if (!nestedScenes.TryGetValue(imported.Identity,out var session))+ {+ if (nestedScenes.Count >= 256) { Error("scene-definition-session-capacity-exceeded","At most 256 imported Scene definitions can be retained."); continue; }+ nestedScenes[imported.Identity]=session=new();+ }+ var child=session.CompileBound(imported.Module!.Text,imported.Path,project,graph,imported.Module,imported.Export);+ diagnostics.AddRange(child.Diagnostics);+ if (child.Scene is not null) compiledScenes[imported.Identity]=child.Scene;+ }+ else if (graph?.TryReference(item.Definition,out imported) == true && item.Kind == "Assembly")+ {+ if (!assemblies.TryGetValue(imported.Identity,out var session))+ {+ if (assemblies.Count >= 256) { Error("scene-definition-session-capacity-exceeded","At most 256 imported Assembly definitions can be retained."); continue; }+ assemblies[imported.Identity]=session=new();+ }+ if (!compiledAssemblies.ContainsKey(imported.Identity))+ {+ var child=session.CompileModule(graph,imported);+ compiledAssemblies[imported.Identity]=child;+ diagnostics.AddRange(child.Diagnostics);+ }+ }+ else if (item.Kind == "Assembly"){var match=Regex.Match(item.Definition,"^AssemblyFile<\\s*\"(?<path>[^\"]+)\"\\s*>$");if (!match.Success) { Error("scene-assembly-definition-invalid","X0 assembly occurrences require AssemblyFile<\"relative.firmament\">; their document compiles independently."); continue; }@@ -84,10 +127,14 @@ public sealed class FirmamentSceneSession : IDisposablediagnostics.AddRange(assembly.Diagnostics);}}+ else if (item.Kind == "Scene")+ Error("scene-definition-unresolved", "A Scene occurrence requires a bound Inventory Scene entry.");else if (!materializedParts.ContainsKey(item.Definition)){- var part=parts.Materialize(item.Definition,s.DefinitionSource,sourceIdentity,diagnostics,project,- () => AssemblyDefinitionMaterializer.TryMaterialize(item.Definition,s.DefinitionSource,sourceIdentity,diagnostics,project));+ var part=graph?.TryReference(item.Definition,out var importedPart) == true+ ? AssemblyDefinitionMaterializer.MaterializeModule(graph,importedPart,item.Definition,diagnostics,parts)+ : parts.Materialize(item.Definition,s.DefinitionSource,sourceIdentity,diagnostics,project,+ () => AssemblyDefinitionMaterializer.TryMaterialize(item.Definition,s.DefinitionSource,sourceIdentity,diagnostics,project));if (part is not null) materializedParts.Add(item.Definition,part);}}@@ -176,10 +223,34 @@ public sealed class FirmamentSceneSession : IDisposable}AddNode(item.Path,"Part",item.Definition,parent,world.ToRowMajor(),id,item.Span,item.PatternKey); ApplyLook(item.Path,item.Appearance);}+ else if (item.Kind == "Scene")+ {+ if (item.From != "Origin") { Error("scene-source-frame-unresolved","An imported Scene is placed from Origin."); continue; }+ if (!compiledScenes.TryGetValue(item.Definition,out var child)) { Error("scene-definition-unresolved",item.Definition); continue; }+ var prefix=Id(item.Definition);+ foreach (var d in child.Display.Definitions)+ {+ var id=prefix+":"+d.Id;+ definitions.TryAdd(id,Derive(d,id,item.Definition));+ }+ var childRoot=child.Source.Name;+ foreach (var o in child.Display.Occurrences)+ {+ var scenePath=item.Path+o.Path[childRoot.Length..];+ var parentPath=o.ParentId is null ? parent : item.Path+child.Display.Occurrences.Single(p => p.Id == o.ParentId).Path[childRoot.Length..];+ var childNode=child.Nodes.Single(n => n.Path == o.Path);+ AddNode(scenePath,childNode.Kind,childNode.DefinitionIdentity,parentPath,+ (Transform3D.FromRowMajor(o.Transform)*world).ToRowMajor(),o.DefinitionId is null ? null : prefix+":"+o.DefinitionId,childNode.Span,item.PatternKey);+ if (child.Appearances.TryGetValue(o.Id,out var look)) looks[Id(scenePath)]=look;+ ApplyLook(scenePath,item.Appearance);+ }+ boundaries=boundaries.Concat(child.Boundaries.Select(b => b with { Path=item.Path+"."+b.Path,Room=item.Path+"."+b.Room,+ Frame=(Transform3D.FromRowMajor(b.Frame)*world).ToRowMajor(),Openings=b.Openings.Select(o => item.Path+"."+o).ToArray() })).ToArray();+ }else{var match=Regex.Match(item.Definition,"\"(?<path>[^\"]+)\"");- var path=AssemblyPathFor(match.Groups["path"].Value)!;+ var path=graph?.TryReference(item.Definition,out _) == true ? item.Definition : AssemblyPathFor(match.Groups["path"].Value)!;var assembly=compiledAssemblies[path];if (!preparedAssemblies.TryGetValue(path,out var mesh)){ var preparation=Stopwatch.StartNew(); preparedAssemblies[path]=mesh=assemblies[path].ExportDisplayMesh(assembly); displayMs+=preparation.Elapsed.TotalMilliseconds; }@@ -253,7 +324,7 @@ public sealed class FirmamentSceneSession : IDisposable{ if (look is not null) looks[Id(path)]=new("","",look,s.Looks.Appearances[look].Preview,"scene-appearance"); }}}- public void Dispose() { lock(gate) { foreach (var session in assemblies.Values) session.Dispose(); assemblies.Clear(); parts.Clear(); sceneDefinitions.Clear(); assemblyDefinitions.Clear(); disposed=true; } }+ public void Dispose() { lock(gate) { foreach (var session in assemblies.Values) session.Dispose(); assemblies.Clear(); foreach(var child in nestedScenes.Values) child.Dispose(); nestedScenes.Clear(); parts.Clear(); sceneDefinitions.Clear(); assemblyDefinitions.Clear(); disposed=true; } }// The shader DisplayProjection would attach; attached once here so the cached object is final.private static AssemblyDisplayMeshDefinition WithShader(AssemblyDisplayMeshDefinition d) =>d.Shader is null ? d with { Shader = CirShaderArtifactProvider.Resolve(d.Cir) } : d;diff --git a/docs/development/FIRMAMENT-LANGUAGE-DECISIONS-2026-10.md b/docs/development/FIRMAMENT-LANGUAGE-DECISIONS-2026-10.mdindex cee10943..36018159 100644--- a/docs/development/FIRMAMENT-LANGUAGE-DECISIONS-2026-10.md+++ b/docs/development/FIRMAMENT-LANGUAGE-DECISIONS-2026-10.md@@ -289,3 +289,26 @@ Complete include-file/module provenance and remaining collection/domain sourceadapters remain X2 work. No general Let, runtime scripting, new units doctrine orgeometry capability was introduced. All 24 original recommendations and rationaleremain in the register above; no syntax policy decision is awaiting the user.+++### Inventory and module graph continuation++[Inventory Records](../public/firmament/inventory.md) bind typed references to+concrete Part, Subassembly, Assembly and Scene exports. PascalCase catalogs and+camelCase members retain the current casing policy. Adapter-typed locators normally+omit extensions; ambiguous matches reject, with explicit extensions as the repair.+`include` remains available for short unqualified compositions; no size threshold+is enforced. Both forms use the AST-owned dependency graph.++Inventory imports remain separate source modules. Existing include composition+uses a mapped compatibility projection. Resource, Inventory and original syntax+errors carry declaring-file spans; downstream generated/native errors still disclose+an enclosing-export limitation where precise producer locations are unavailable.+Definition identities use project-relative resource paths, not machine directories.+Source-only snapshots reject STEP dependencies explicitly. Templates specialize in+the defining module before Inventory export; general cross-module value arguments+are deferred to the remaining typed module contract, without implicit capture.++Recommendations 3, 4, 8, 15, 19, 22 and 23 advance. The full X2 domain/value/source-map+migration is still open; no new parser route, geometry engine or runtime module+system is introduced. Qualification is recorded in the Inventory release report.diff --git a/docs/public/firmament/assemblies.md b/docs/public/firmament/assemblies.mdindex 99c836fe..43cd19a8 100644--- a/docs/public/firmament/assemblies.md+++ b/docs/public/firmament/assemblies.md@@ -87,7 +87,8 @@ Interface<Custom> CarryLink {## Multi-file subassemblies-`Include` is compile-time semantic composition. Paths resolve relative to the including file and must remain under the repository source root (or, outside a checkout, the root document directory). Missing files and include cycles are typed errors. Duplicate Interface or Subassembly definitions are rejected; aliasing is not admitted in X1.+For organized, qualified dependencies, prefer [Inventory Records](inventory.md).+`include` remains compile-time semantic composition for concise shared declarations. Paths resolve relative to the including file and must remain under the repository source root (or, outside a checkout, the root document directory). Missing files and include cycles are typed errors. Duplicate Interface or Subassembly definitions in one include-composed module reject. Inventory members bind checked aliases to named exports without pooling imported definitions into that namespace.```firmamentInclude "digit-module.firmament";diff --git a/docs/public/firmament/inventory.md b/docs/public/firmament/inventory.mdnew file mode 100644index 00000000..a3649ed1--- /dev/null+++ b/docs/public/firmament/inventory.md@@ -0,0 +1,115 @@+# Inventory Records and module references++Use `include` for a short composition whose declarations can share names in one+module. Use an `Inventory Record` when named, qualified dependencies make a larger+Assembly or Scene easier to organize. Neither form has a one- or two-part limit.++Firmament's importable module kinds are Part, Subassembly, Assembly and Scene.+Inventory references inside occurrence Patterns bind before expansion.+An Inventory member is a reference to a concrete definition. Adding it to a catalog+does not place geometry or establish a Mate; occurrences and relationships do that.++## A typed catalog++```firmament+Inventory Record Components {+ bracket: Part = Firmament("parts/bracket").Bracket+ drive: Subassembly = Firmament("assemblies/drive").Drive+ machine: Assembly = Firmament("assemblies/machine").Machine+ laboratory: Scene = Firmament("scenes/laboratory").Laboratory+ bearing: Part = Step("vendor/bearing")+}+```++This is a declaration fragment: provide the named files and exports in your project.+`Firmament(...)` selects a named root declaration; `Step(...)` supplies one exact+Part through the existing STEP importer. Missing or ambiguous exports and kind+mismatches reject. STEP assemblies and multi-body assets must satisfy the existing+single-Part importer contract; there is no implicit first-body selection.++The normal spelling omits the extension. `Firmament("parts/bracket")` resolves+`.firmament` or `.firmasm`; `Step("vendor/bearing")` resolves `.step` or `.stp`.+Exactly one candidate must exist. An explicit extension is also accepted and is+the repair when both candidates exist. No search path, directory scan or global+package registry chooses a resource behind the author's back.++Locators resolve relative to the document containing the declaration and must+stay inside the existing allowed source root. Source snapshots resolve from their+provided document map, without reading files from disk. Snapshots currently hold+Firmament source only; a STEP Inventory entry requires a file-backed project.++## Place the referenced definitions++Given the catalog above, an Assembly can place its Part and Subassembly entries+through the existing product tree:++```firmament+Assembly Machine {+ <Assembly Machine>+ <Part Bracket = Components.bracket>+ Placement { from: Origin; to: World; }+ </Part>+ <Assembly Drive = Components.drive>+ Placement { from: Origin; to: World; translateLocal: [100mm, 0mm, 0mm]; }+ </Assembly>+ </Assembly>+ Anchor: Machine;+}+```++Use `<Assembly ...>` for both Assembly and Subassembly entries. They retain their+own locally solved product tree and published semantic contracts. Definition-owned+ports participate in the ordinary Interface/Mate solver. Tree nesting supplies no+mechanical relationship by itself. Existing interference checks still apply.++A Scene can place Part, Assembly/Subassembly or Scene entries. A nested Scene uses+its own units, rooms, definitions and placements, composed into its parent's world+frame. Its cameras remain private to that Scene; they do not replace parent cameras.+Nested Scene placement currently starts at `Origin`. For example, inside a Scene:++```firmament+<Scene laboratory = Components.laboratory>+ Placement { from: Origin; to: World; translateLocal: [10m, 0m, 0m]; }+</Scene>+```++Complete executable projects are [the machine](../../../fixtures/Regression/Inventory/machine.firmasm)+and [the factory Scene](../../../fixtures/Regression/Inventory/factory.firmament).++## Scope, exports and compatibility++Inventory names use PascalCase; member names use camelCase. Imported export names+and other domain/user symbols retain their authored spelling. Names resolve in+lexical scopes: a local Inventory shadows an outer Inventory, and sibling catalogs+remain private. Parameters, local values and Pattern iteration names protect their+own names from an enclosing catalog. Members are qualified, such as `Components.bracket`. Unknown+members, repeated names, invalid headers and unsupported adapters produce errors.++Root Model, Struct and Part declarations can satisfy a Part entry. Model and+Struct retain their existing geometry meanings inside the defining source; the+import does not redesign those frontends. Other root products in that file are+excluded from the selected Part's engineering compilation. Supporting Records,+Statics, Features, Templates and Concept scaffolding remain in their owning module.+Identical export or Record names in different imported modules do not collide.++The first pass imports concrete modules. Specialize a Template in its defining+module and export that concrete result, rather than passing caller values across+the Inventory boundary. This preserves definition-scope binding and prevents a+caller value from being captured by an unrelated private Static of the same name.++`include "parts/bolt";` remains admitted, including the established explicit+`.firmament` spelling. Includes share declarations in the consuming module. The+existing snapshot-only project-root-relative include spelling remains accepted+when a document-relative target is absent. Inventory always uses document-relative+locators. New code should use that rule for both forms.++The graph retains source files, dependency hashes, selected exports and Inventory+binding receipts in Assembly IR and the compiled Scene source model. Syntax, resource and Inventory lookup errors+retain original spans. Existing engineering lowerers still have bounded source+adapters; when they cannot provide a precise expression location, errors identify+the enclosing exported Part and disclose that limitation. This pass does not+claim complete generated-source provenance across every domain lowerer.++Unused Inventory entries are resolved and kind-checked; engineering geometry is+constructed for placed occurrences. Inventory availability does not imply an+occurrence count or a bill of materials.diff --git a/docs/public/firmament/project-snapshots.md b/docs/public/firmament/project-snapshots.mdindex 077223dc..2fcd9c36 100644--- a/docs/public/firmament/project-snapshots.md+++ b/docs/public/firmament/project-snapshots.md@@ -4,6 +4,6 @@This compiler entry point can materialize the canonical Cartesian lamp assembly and its shade from two in-memory source strings. The browser SDK now accepts `projectDocuments` beside `sourceName` for Assembly and Scene compilation, routing to the existing retained compilation owners. Helios's local showcase uses that path for the canonical ATLAS, guitar and house projects. Browser language analysis also accepts `projectRoot` and `projectDocuments` for Assembly project context. This source-snapshot API does not introduce multi-file cloud persistence.-Assembly `Include` syntax currently accepts `.firmament` documents only, so nested `.firmasm` project documents are not supported. `ExternalStep` and `InlineStep` are rejected for snapshot compilation because the snapshot contains source documents, not binary STEP assets.+The module graph resolves `.firmament` and `.firmasm` dependencies, including extensionless locators and typed [Inventory Records](inventory.md). Inventory locators resolve relative to the declaring document. Existing snapshot project-root-relative include spellings remain a fallback when the document-relative target is absent. `ExternalStep` and `InlineStep` are rejected for snapshot compilation because the snapshot contains source documents, not binary STEP assets.-The assembly parser currently combines included declarations into the root source before binding. Dependency hashes identify included documents, but construct source ranges within those declarations do not yet retain their original document path. Multi-document source navigation requires that provenance work before an IDE can claim accurate cross-file selection.+An AST-owned dependency graph replaces regex include discovery. Legacy includes retain declaration composition through a source-mapped adapter; Inventory imports bind named exports in separate modules. Dependency hashes identify all resolved source documents, and Inventory/resource/syntax diagnostics retain their declaring file and span. Downstream engineering readers still contain source adapters, so complete generated-source navigation across every lowerer is not yet qualified.diff --git a/docs/public/firmament/scenes.md b/docs/public/firmament/scenes.mdindex 66b52ca5..20bf3c0d 100644--- a/docs/public/firmament/scenes.md+++ b/docs/public/firmament/scenes.md@@ -185,3 +185,18 @@ resources from a virtual/browser project is deferred.Nested Scenes, BIM/IFC, general walls, zones, lights, logistics, collisionavoidance, path planning, physics and robotics control are outside X0.++## Inventory module composition++[Inventory Records](inventory.md) organize typed dependencies without injecting+imported definitions into the Scene's source namespace. Use extensionless locators+such as `Firmament("machine").Machine` and place the member as an ordinary Assembly+occurrence. Part and Subassembly entries use their existing engineering owners.+A Scene entry can be placed with `<Scene cell = Library.cell> ... </Scene>`.++Nested Scenes retain their units, geometry, occurrence hierarchy, appearances and+source anchors. Their world transforms compose with the parent's Placement exactly+once. Place them from `Origin`; child cameras remain local to the child Scene.+The compiled Scene source model retains Inventory binding and source-dependency+receipts; CLI inspection exposes the composed nodes and their source anchors. A complete+multi-file witness is [the Inventory factory](../../../fixtures/Regression/Inventory/factory.firmament).diff --git a/docs/public/firmament/syntax.md b/docs/public/firmament/syntax.mdindex 86c03b32..26af09fc 100644--- a/docs/public/firmament/syntax.md+++ b/docs/public/firmament/syntax.md@@ -745,6 +745,32 @@ Do not invent `schema Assembly` or wrap arbitrary domain declarations in a Model| Engineering annotations | [PMI](pmi.md). || File-backed modules and source-only projects | [Project snapshots](project-snapshots.md), [Concept derivation](concept-derivation.md). |+### Inventory: organize module dependencies++Use a short `include "parts/bolt";` when shared declarations are convenient. For+larger compositions, give Part, Subassembly, Assembly and Scene dependencies typed+names in an Inventory Record:++```firmament+Inventory Record Components {+ bracket: Part = Firmament("parts/bracket").Bracket+ drive: Subassembly = Firmament("assemblies/drive").Drive+ bearing: Part = Step("vendor/bearing")+}+```++This fragment requires the named resources. Locators normally omit the extension;+ambiguous matches reject. Place `Components.bracket` through a Part occurrence,+`Components.drive` through an Assembly occurrence, or a Scene entry through a+Scene occurrence. The catalog makes definitions available; occurrences determine+quantity and placement. Entries reference concrete modules; specialize Templates+in the defining module before exporting their results.++Inventory follows lexical scope and retains imported file identity. Existing+`include` remains the concise, unqualified composition form. See+[Inventory Records](inventory.md) for complete projects, source snapshots, STEP+boundaries and extension resolution.+Assembly occurrence trees use `<Assembly>` / `<Part>` tags as well as bracebodies. Tree nesting does not create a Mate. Inclusion is owned by the consumingproject/domain; `include` is **not** a universal mechanical preprocessor.diff --git a/docs/release/FIRMAMENT-FRONTEND-X2.md b/docs/release/FIRMAMENT-FRONTEND-X2.mdindex 9bf68e60..c505be3f 100644--- a/docs/release/FIRMAMENT-FRONTEND-X2.md+++ b/docs/release/FIRMAMENT-FRONTEND-X2.md@@ -4,7 +4,12 @@ Date: 2026-10-15. Base: `e6468b03c6bd4a6b2bfd40329de1381c16968512`.**Verdict: Meaningful progression. X2 is not Accepted.**-Latest continuation: Record, Static and Table names now bind through lexical+The later [Inventory module pass](FIRMAMENT-INVENTORY-MODULES.md) replaces regex+include discovery with the AST-owned dependency graph, adds typed module imports+and retains original imported syntax locations. Its fresh gates are recorded in+that report. The data-pass measurements below remain their original evidence.++Previous qualified continuation: Record, Static and Table names now bind through lexicalproduction AST identities and a shared typed data catalog. The Spec schema-capturewitness builds its intended 30 × 20 × 6 mm geometry. Final gates: **5,018 tests**,**1,276 classified sources**, **26/26 byte-identical STEP baselines**. Complete@@ -153,8 +158,10 @@ Malformed Template prefixes cannot disappear if syntax recovery fails to producea declaration node: the existing lexer/token stream retains the failed prefix.Complete provenance and value scoping still have concrete blockers.-`AssemblyM0Parser.LoadProjectSource` and `LoadSourceGraph` return concatenated-strings without per-declaration file identity. Template bodies still cross the+The previous `AssemblyM0Parser.LoadProjectSource` and `LoadSourceGraph` returned+concatenated strings without per-declaration file identity. The Inventory pass+removes those readers in favor of the module graph. Legacy include transport now+has source segments; typed imports keep their defining modules separate. Template bodies still cross theexisting Match/PMI and domain lowerers as source slices. No claim is madethat the Template body substitution or every domain reader has migrated.@@ -188,9 +195,9 @@ document and single-Model container compatibility. Public Record/type names remaauthored names; nested host Record markers resolve the selected nominal schema.Unambiguous existing engineering identities remain unchanged.-The next X2 boundary is complete module/original-file provenance and the remaining-collection, expansion and domain source adapters. Included documents are still-concatenated by the Assembly source loader. Record/data lexical lookup no longer+The remaining X2 boundary is complete generated-source provenance and the+collection, expansion and domain source adapters. Inventory now owns module lookup;+legacy includes retain an explicit mapped declaration-composition adapter. Record/data lexical lookup no longerrequires that handoff to be flattened into an unqualified registry, but this passdoes not claim that all original include locations or domain bodies have migrated.@@ -208,7 +215,7 @@ all downstream semantics.| Mechanical / unified binders | AST admission with bounded semantic adapters | Profile, Compose, selection/PMI and compatibility readers remain in parts of the lowerer chain. || Panel, Plateau, Revolve, Loft/SectionChain | AST admission with bounded semantic adapters | Profile resolution, preprocessing and specialized source projections remain. || Assembly contracts / `AssemblyInterfaceSyntax` | AST-owned migrated contracts/mates | Existing engineering placement and relationship lowerers preserved. |-| Assembly tree / `AssemblyM0Parser` | Legacy source reader still authoritative after structural admission | Includes, product tree, parts, frames, appearances, ports and source specialization. |+| Assembly tree / `AssemblyM0Parser` | AST module graph and structural admission; existing product lowerers retained | Product tree, frames, appearances, ports and remaining source specialization. Includes use the module graph's mapped compatibility projection. || Scene / `SceneAuthoring.Reader` | Legacy source reader still authoritative | Room/opening/camera/placement binding and module interpretation; numeric service and occurrence mapping now shared. || SheetMetal / SheetMetalFirmament, AuthoredSheetMetalCompiler | Legacy source reader still authoritative after structural admission | Manufacturing source fields and expansion remain to migrate. || WireForm / `WireFormAuthoring` | Legacy source reader still authoritative | Field/route interpretation and source-based specialization remain. |@@ -486,7 +493,8 @@ use production AST identities and the common typed catalog. The schema-capturewitness builds its intended geometry, inaccessible/incorrect data rejects, andscoped tolerance requirements project through the real AP242 path.-X2 remains open for complete include-file/module provenance and remaining-collection, expansion and domain readers. No language-policy decision is awaiting+X2 remains open for complete generated-source provenance and remaining collection,+expansion and domain readers. The later Inventory module report records the new+module-binding and original syntax-location qualification. No language-policy decision is awaitingthe user. The next work is the module syntax/provenance handoff and removal ofthose remaining source owners as each family is qualified.diff --git a/docs/release/FIRMAMENT-INVENTORY-MODULES.evidence.json b/docs/release/FIRMAMENT-INVENTORY-MODULES.evidence.jsonnew file mode 100644index 00000000..f0606f22--- /dev/null+++ b/docs/release/FIRMAMENT-INVENTORY-MODULES.evidence.json@@ -0,0 +1,1372 @@+{+ "schemaVersion": 1,+ "implementationBase": "263f0128",+ "verdict": "Success for the Inventory module first pass; X2 remains open",+ "tests": {+ "failed": 0,+ "passed": 5051,+ "skipped": 0,+ "total": 5051,+ "executingAssemblies": 20+ },+ "focusedCompiler": {+ "failed": 0,+ "passed": 76,+ "skipped": 0,+ "total": 76,+ "executingAssemblies": 1+ },+ "focusedCli": {+ "failed": 0,+ "passed": 4,+ "skipped": 0,+ "total": 4,+ "executingAssemblies": 1+ },+ "fastLane": {+ "failed": 0,+ "passed": 1068,+ "skipped": 0,+ "total": 1068,+ "executingAssemblies": 1+ },+ "documentationTests": {+ "failed": 0,+ "passed": 13,+ "skipped": 0,+ "total": 13,+ "executingAssemblies": 1+ },+ "buildWarnings": 10,+ "corpus": {+ "schemaVersion": 1,+ "sourceCount": 1285,+ "canonicalSourceCount": 327,+ "canonicalStructurallyParsed": 327,+ "structurallyParsed": 921,+ "standaloneProductionAccepted": 516,+ "inventorySha256": "8F76A0EE96B4912DA5CD6DE8AAA11358DF2378800DFCCF1A7CE8CB00A327925F",+ "unresolvedMismatchCount": 0,+ "universalSemanticParityQualified": false,+ "classifications": {+ "Admitted": 499,+ "AdmittedGeometryWithDfmFindings": 1,+ "AdmittedInConsumerContext": 36,+ "DeclarationModuleRequiresConsumer": 5,+ "ExpectedNegativeRejection": 286,+ "ExperimentalAdmitted": 9,+ "ExperimentalRejected": 31,+ "LegacySerializationAdmitted": 5,+ "LegacySerializationRejected": 324,+ "MalformedOrUnsupportedSourceRejected": 6,+ "MisfiledPositiveFixture": 1,+ "RejectedAtSolveStage": 1,+ "SourceAdmissionRejected": 81+ },+ "canonicalClassifications": {+ "Admitted": 285,+ "AdmittedInConsumerContext": 33,+ "SourceAdmissionRejected": 9+ }+ },+ "previousCorpus": {+ "path": "docs/release/FIRMAMENT-FRONTEND-X2.evidence.json",+ "sha256": "A89C8456036ED1DA3F7B53F86867BE465EBD980E9DE9A84B93A483AC19DB4CB6",+ "sourcesCompared": 1276,+ "differences": []+ },+ "newSources": [+ {+ "source": "Regression/Inventory/cell.firmament",+ "sha256": "B0CFC003461261C4D1C901099C426B5BC453EEB9503A289708C879B5459DED9E",+ "structuralSuccess": true,+ "syntaxFingerprint": "760AAA1773B82874BC363A42C6902F6B3C703B1085F52371D730504F0C203AE2",+ "syntaxDiagnosticCodes": [],+ "owner": "Scene",+ "productionLevel": "SceneCompiled",+ "standaloneProductionExit": 0,+ "productionDiagnosticCodes": [],+ "productionDiagnosticMessages": [],+ "sourceIntent": "Unspecified",+ "classification": "Admitted",+ "reason": "Structural parse and domain production owner both succeed at the recorded production level.",+ "consumerContexts": [],+ "downstreamEvidence": null+ },+ {+ "source": "Regression/Inventory/drive.firmament",+ "sha256": "DF1A495641F61331997B500BB4B8B10937C1B84D86F9AEED90CC8E438176E74F",+ "structuralSuccess": true,+ "syntaxFingerprint": "EA7865CC745C67950BF0DFD44F3FF1374AF4385018300DA9EA927D5C7CCB6A22",+ "syntaxDiagnosticCodes": [],+ "owner": "ValidateDomainDispatch",+ "productionLevel": "OwnerReported",+ "standaloneProductionExit": 1,+ "productionDiagnosticCodes": [+ "firmament-module-context-required",+ "firmament-v2-parse-failed"+ ],+ "productionDiagnosticMessages": [],+ "sourceIntent": "Unspecified",+ "classification": "AdmittedInConsumerContext",+ "reason": "Successful production dependency receipts match this exact source hash. The standalone outcome is retained; no claim about every possible Template specialization.",+ "consumerContexts": [+ {+ "consumer": "Regression/Inventory/machine.firmasm",+ "owner": "Assembly",+ "level": "AssemblyInspected"+ }+ ],+ "downstreamEvidence": null+ },+ {+ "source": "Regression/Inventory/factory.firmament",+ "sha256": "487B8E15635DA818A390046F0B6169753F19FF3D4EFBE01E2FF69565E5328702",+ "structuralSuccess": true,+ "syntaxFingerprint": "86A814CED1C546039C29F41C762D49A96D3271838F79E7CE298AF3A7E00FD8BE",+ "syntaxDiagnosticCodes": [],+ "owner": "Scene",+ "productionLevel": "SceneCompiled",+ "standaloneProductionExit": 0,+ "productionDiagnosticCodes": [],+ "productionDiagnosticMessages": [],+ "sourceIntent": "Unspecified",+ "classification": "Admitted",+ "reason": "Structural parse and domain production owner both succeed at the recorded production level.",+ "consumerContexts": [],+ "downstreamEvidence": null+ },+ {+ "source": "Regression/Inventory/include-simple.firmament",+ "sha256": "20D4B8F0E784112382BE7047F357821E0C0077E05E0E0CD84E1DD82B9EAC573B",+ "structuralSuccess": true,+ "syntaxFingerprint": "3867A3DED4350B3DC9BCFB9F4C8A3A38CB8E35FF6A4BA2B6353606A735CCEC98",+ "syntaxDiagnosticCodes": [],+ "owner": "Assembly",+ "productionLevel": "AssemblyInspected",+ "standaloneProductionExit": 0,+ "productionDiagnosticCodes": [],+ "productionDiagnosticMessages": [],+ "sourceIntent": "Unspecified",+ "classification": "Admitted",+ "reason": "Structural parse and domain production owner both succeed at the recorded production level.",+ "consumerContexts": [],+ "downstreamEvidence": null+ },+ {+ "source": "Regression/Inventory/machine.firmasm",+ "sha256": "CEC185D445B0327794D69FA59AAE17EAF460340C0A2F510C20D98C7C83007E1B",+ "structuralSuccess": true,+ "syntaxFingerprint": "C2195180C744B61FCA2C603FBC07C9FCD82AC29258B601DA575A885595F5A463",+ "syntaxDiagnosticCodes": [],+ "owner": "Assembly",+ "productionLevel": "AssemblyInspected",+ "standaloneProductionExit": 0,+ "productionDiagnosticCodes": [],+ "productionDiagnosticMessages": [],+ "sourceIntent": "Unspecified",+ "classification": "Admitted",+ "reason": "Structural parse and domain production owner both succeed at the recorded production level.",+ "consumerContexts": [],+ "downstreamEvidence": null+ },+ {+ "source": "Regression/Inventory/missing-member.invalid.firmament",+ "sha256": "312CCEB6BB1A1DB4985F70A11A8AD9EB017375B7CA13311F50D04C1F8785FADA",+ "structuralSuccess": true,+ "syntaxFingerprint": "AC939F13F1D4B4A10E4AC1587242537722154AA38EBFD2F8196B533DFEEAEF09",+ "syntaxDiagnosticCodes": [],+ "owner": "Assembly",+ "productionLevel": "AssemblyInspected",+ "standaloneProductionExit": 1,+ "productionDiagnosticCodes": [+ "firmament-inventory-member-unresolved"+ ],+ "productionDiagnosticMessages": [],+ "sourceIntent": "Negative",+ "classification": "ExpectedNegativeRejection",+ "reason": "Negative fixture intent is explicit in its path; acceptance requires review rather than being silently counted as success. Owner diagnostic: Inventory 'Parts' has no member 'braket'.",+ "consumerContexts": [],+ "downstreamEvidence": null+ },+ {+ "source": "Regression/Inventory/parts/bolt.firmament",+ "sha256": "8E8B53E38D76328E5BF5BEE4F072446289F523BC7B086445A45E8E33AD96F5BF",+ "structuralSuccess": true,+ "syntaxFingerprint": "54EB1A7D75FDE53232DE3583335BDC2067B8D41A340FF79C19C9175CF2E5C2EA",+ "syntaxDiagnosticCodes": [],+ "owner": "ValidateDomainDispatch",+ "productionLevel": "OwnerReported",+ "standaloneProductionExit": 1,+ "productionDiagnosticCodes": [+ "firmament-v2-missing-model",+ "firmament-v2-missing-solid",+ "firmament-v2-missing-units",+ "firmament-v2-parse-failed"+ ],+ "productionDiagnosticMessages": [],+ "sourceIntent": "Unspecified",+ "classification": "AdmittedInConsumerContext",+ "reason": "Successful production dependency receipts match this exact source hash. The standalone outcome is retained; no claim about every possible Template specialization.",+ "consumerContexts": [+ {+ "consumer": "Regression/Inventory/include-simple.firmament",+ "owner": "Assembly",+ "level": "AssemblyInspected"+ }+ ],+ "downstreamEvidence": null+ },+ {+ "source": "Regression/Inventory/parts/bracket.firmament",+ "sha256": "D6778E69948710530427045863A10C2507B48606D7988668188BA6A6B47DF1A9",+ "structuralSuccess": true,+ "syntaxFingerprint": "704C8D3318748455C75CB6DB689ED07EEB1CEF0FE8FD5BD3ADB8F01513B1D303",+ "syntaxDiagnosticCodes": [],+ "owner": "ValidateDomainDispatch",+ "productionLevel": "OwnerReported",+ "standaloneProductionExit": 0,+ "productionDiagnosticCodes": [],+ "productionDiagnosticMessages": [],+ "sourceIntent": "Unspecified",+ "classification": "Admitted",+ "reason": "Structural parse and domain production owner both succeed at the recorded production level.",+ "consumerContexts": [+ {+ "consumer": "Regression/Inventory/include-simple.firmament",+ "owner": "Assembly",+ "level": "AssemblyInspected"+ },+ {+ "consumer": "Regression/Inventory/machine.firmasm",+ "owner": "Assembly",+ "level": "AssemblyInspected"+ }+ ],+ "downstreamEvidence": null+ },+ {+ "source": "Regression/Inventory/parts/wide-bracket.firmament",+ "sha256": "D512765667C283C3FC2F0D7AF004D1DBC61D535682325C39A65414199C45E7DF",+ "structuralSuccess": true,+ "syntaxFingerprint": "EAB36751FDF02831B625A60882E4FEB8F2375F25E4A6C2C3B139D329089B5D53",+ "syntaxDiagnosticCodes": [],+ "owner": "ValidateDomainDispatch",+ "productionLevel": "OwnerReported",+ "standaloneProductionExit": 0,+ "productionDiagnosticCodes": [],+ "productionDiagnosticMessages": [],+ "sourceIntent": "Unspecified",+ "classification": "Admitted",+ "reason": "Structural parse and domain production owner both succeed at the recorded production level.",+ "consumerContexts": [+ {+ "consumer": "Regression/Inventory/machine.firmasm",+ "owner": "Assembly",+ "level": "AssemblyInspected"+ }+ ],+ "downstreamEvidence": null+ }+ ],+ "geometryParity": [+ {+ "source": "fixtures/Canonical/Symmetry/radial-bolt-circle.firmament",+ "sourceSha256": "19DAA47DC20CA092A6DDA1CC49AF0B74E7E016F5E4A143AA4C00B7230B81C3CE",+ "expectedSha256": "4B4F8FD69D10E73BB403F1538C6FC13995F895E4C1C17E0605A3E4A008E5356E",+ "actualSha256": "4B4F8FD69D10E73BB403F1538C6FC13995F895E4C1C17E0605A3E4A008E5356E",+ "exitCode": 0,+ "byteIdentical": true+ },+ {+ "source": "fixtures/Canonical/Symmetry/partial-radial-pattern.firmament",+ "sourceSha256": "258427029AA0882653801833109AD9FE04542C7448DE1D126291215FC016DE7D",+ "expectedSha256": "7D708B30209B6A03010D9C647F762E453C705BC8F656882BE4F18785B2F08D87",+ "actualSha256": "7D708B30209B6A03010D9C647F762E453C705BC8F656882BE4F18785B2F08D87",+ "exitCode": 0,+ "byteIdentical": true+ },+ {+ "source": "fixtures/Canonical/Symmetry/mirrored-revolve.firmament",+ "sourceSha256": "B955033028F838A3A3D7D265BD4EB04A9AAD89E83D95D5EA1C640ECB0953FA6C",+ "expectedSha256": "C44AE2A5B6CFC978AFB24041F0B5C43A4554161FE5880FC6E2D59ADB1B7CAB4A",+ "actualSha256": "C44AE2A5B6CFC978AFB24041F0B5C43A4554161FE5880FC6E2D59ADB1B7CAB4A",+ "exitCode": 0,+ "byteIdentical": true+ },+ {+ "source": "fixtures/Canonical/Symmetry/mirrored-profile.firmament",+ "sourceSha256": "1F41E7EBE426306205E01226C36410261798418C385E5E284BD0A4216CAF98BF",+ "expectedSha256": "30D1F927A7295A5B553453BA2D6E936564140839E4497B0C5B46A1682A18F6A1",+ "actualSha256": "30D1F927A7295A5B553453BA2D6E936564140839E4497B0C5B46A1682A18F6A1",+ "exitCode": 0,+ "byteIdentical": true+ },+ {+ "source": "fixtures/Canonical/Symmetry/mirrored-hole.firmament",+ "sourceSha256": "39B62FB47C0C42BDF7CD3DE7FCA2E78E785BCD693412FC052628F470F3261EB0",+ "expectedSha256": "4A0DA2E67DA153B38DD7E6389CB329B4BBB6939FEC88541936DF705F49BE62FE",+ "actualSha256": "4A0DA2E67DA153B38DD7E6389CB329B4BBB6939FEC88541936DF705F49BE62FE",+ "exitCode": 0,+ "byteIdentical": true+ },+ {+ "source": "fixtures/Canonical/Symmetry/mirrored-feature-with-override.firmament",+ "sourceSha256": "DEBDCE6974743DCBCED725B9FF6B8ED833EF64DBE69A4B94256515E6CDF24B4E",+ "expectedSha256": "052F9FC96919130FA11D2FDE5BEF302BCBE42BA6441A61F7164D43E25EAF8FBB",+ "actualSha256": "052F9FC96919130FA11D2FDE5BEF302BCBE42BA6441A61F7164D43E25EAF8FBB",+ "exitCode": 0,+ "byteIdentical": true+ },+ {+ "source": "fixtures/Regression/FrontendMigration/preferred-profile-links.firmament",+ "sourceSha256": "41ACDC508CDB714BC0409C864708FD968BB812A83E4FD406B7AA0818670C6C4B",+ "expectedSha256": "E43449262ECDD3DD05EFB73DB821D2E09226637EC1FB1EAF73E07821CD46AA57",+ "actualSha256": "E43449262ECDD3DD05EFB73DB821D2E09226637EC1FB1EAF73E07821CD46AA57",+ "exitCode": 0,+ "byteIdentical": true+ },+ {+ "source": "fixtures/Canonical/Features/Holes/through-hole.firmament",+ "sourceSha256": "38E8188DB1BB7C75406570BBCEC9A09DAFA9D4D33A0EDEB746A6C04A973B265C",+ "expectedSha256": "5999F127E5A1477E5825AFA656DCEB7F89241D8F85312B0E6BCD793639A0F548",+ "actualSha256": "5999F127E5A1477E5825AFA656DCEB7F89241D8F85312B0E6BCD793639A0F548",+ "exitCode": 0,+ "byteIdentical": true+ },+ {+ "source": "fixtures/Canonical/Templates/generic-mounting-plate.firmament",+ "sourceSha256": "91B69697F5E777438F688FA2D1F0330FEF5C430D064FCA0A7FFF886252567C92",+ "expectedSha256": "B0FF1D05D82135A3630C5E165C09B6C2C467B3FAF98A0825A9AF86B2E1CE76A3",+ "actualSha256": "B0FF1D05D82135A3630C5E165C09B6C2C467B3FAF98A0825A9AF86B2E1CE76A3",+ "exitCode": 0,+ "byteIdentical": true+ },+ {+ "source": "fixtures/Canonical/Set/pattern-feature-map.firmament",+ "sourceSha256": "7BF1BA1E508CAE2548EC429724A895F2E50FFDAD057084F17B506C4362A34E40",+ "expectedSha256": "08D4EA1F1336C06A380E30806C02AEE3F08535CAD1592929470EBD64B9882FC2",+ "actualSha256": "08D4EA1F1336C06A380E30806C02AEE3F08535CAD1592929470EBD64B9882FC2",+ "exitCode": 0,+ "byteIdentical": true+ },+ {+ "source": "fixtures/Canonical/PMI/hole-diameter-and-datum.firmament",+ "sourceSha256": "B105A5535F53189938CBA6C9E8644FC9D8C6683F8BB97B04167FA48C411ABBFD",+ "expectedSha256": "9F2F24975267BF425D16A2ECDF863F4A94C0FAD172C932F9868BBB836BD46F5D",+ "actualSha256": "9F2F24975267BF425D16A2ECDF863F4A94C0FAD172C932F9868BBB836BD46F5D",+ "exitCode": 0,+ "byteIdentical": true+ },+ {+ "source": "fixtures/Canonical/PMI/typed-tolerance.firmament",+ "sourceSha256": "7C928F862D443904E87EAD137DB7D55E4D69E03A12F918F3319ECED947245EC9",+ "expectedSha256": "098B515124D46220AAB85F6DBE1568E6B5969FEB55B537BA91AD3DDA587509A5",+ "actualSha256": "098B515124D46220AAB85F6DBE1568E6B5969FEB55B537BA91AD3DDA587509A5",+ "exitCode": 0,+ "byteIdentical": true+ },+ {+ "source": "fixtures/Canonical/PMI/record-template-feature-tolerance.firmament",+ "sourceSha256": "6F88543F7E0D544F460709EE85521620101DCB053CF3C5C7C90F05A96CA63B8D",+ "expectedSha256": "300023D4A6CC156F9224F4937F990926523372C8BF0AB11D8C15851FA256BB18",+ "actualSha256": "300023D4A6CC156F9224F4937F990926523372C8BF0AB11D8C15851FA256BB18",+ "exitCode": 0,+ "byteIdentical": true+ },+ {+ "source": "fixtures/Canonical/AssemblyInterfaces/executable-machine.firmament",+ "sourceSha256": "9CEDEDC63C8EEF28A51F58E0E1E0D85E70104C9014C94508C44F1E9320B42F72",+ "expectedSha256": "912FCCCDF607E0EB9437423BEA0D2E6EB74D9BEDE4D4758D9DF6BF5364C66391",+ "actualSha256": "912FCCCDF607E0EB9437423BEA0D2E6EB74D9BEDE4D4758D9DF6BF5364C66391",+ "exitCode": 0,+ "byteIdentical": true+ },+ {+ "source": "fixtures/Canonical/Assembly/template-block-pair.firmament",+ "sourceSha256": "3530A14F1156C588EA5747EE65B338162AEC803243FBBB379D7C11D5265EF211",+ "expectedSha256": "17E1DABEA787334BE13DA18E9771B69927CE46D754CA35783693C2FD76847B24",+ "actualSha256": "17E1DABEA787334BE13DA18E9771B69927CE46D754CA35783693C2FD76847B24",+ "exitCode": 0,+ "byteIdentical": true+ },+ {+ "source": "fixtures/Canonical/Assembly/coil-on-stem.firmament",+ "sourceSha256": "056E6354C85B0E54AC6B4E1B79C1E9ED5CBE7A97648748F1C55923B76C85E485",+ "expectedSha256": "9C21BE66AA885DF21DE349169C4E3D14282C2384E661372EC4034E627A5E0A1A",+ "actualSha256": "9C21BE66AA885DF21DE349169C4E3D14282C2384E661372EC4034E627A5E0A1A",+ "exitCode": 0,+ "byteIdentical": true+ },+ {+ "source": "fixtures/Canonical/AssemblyInterfaces/GuitarX0/guitar.firmasm",+ "sourceSha256": "10C11DD2FA4361C87D14E22D318348CE18BE0925119496184E846A603B1CA2DB",+ "expectedSha256": "469E42D07EC1BB3FFDB88D5B0149DA50C21F39631EDC7441C2B3DCF11C41681C",+ "actualSha256": "469E42D07EC1BB3FFDB88D5B0149DA50C21F39631EDC7441C2B3DCF11C41681C",+ "exitCode": 0,+ "byteIdentical": true+ },+ {+ "source": "fixtures/Canonical/Sculpting/sculpt-branch-variants.firmament",+ "sourceSha256": "CEFCA8936656C4947A5D434FD75EF6AA23B94D8A3DBB808B340DD376842B9240",+ "expectedSha256": "DDC7B5C388058035E1B6A5FC8D5AC6701FBA3057508448EF00351312D766EF07",+ "actualSha256": "DDC7B5C388058035E1B6A5FC8D5AC6701FBA3057508448EF00351312D766EF07",+ "exitCode": 0,+ "byteIdentical": true+ },+ {+ "source": "fixtures/Canonical/Sculpting/sculpt-offset-region.firmament",+ "sourceSha256": "2FB5300A60902B01916B7D2D0C72A83156E365674BA0A5F249BC5D0B7EF00EE7",+ "expectedSha256": "EB310460850C1153C5C1813F2863DCD16595755359E8545558140BBA5F632F05",+ "actualSha256": "EB310460850C1153C5C1813F2863DCD16595755359E8545558140BBA5F632F05",+ "exitCode": 0,+ "byteIdentical": true+ },+ {+ "source": "fixtures/Canonical/Sculpting/sculpt-preserve-interface.firmament",+ "sourceSha256": "C2310DAB5E3F591E1260EDA82852F53EE7842B284914D030231C15DA72D50AF4",+ "expectedSha256": "67D5F7D6316FA53F63CEE95C08F45AFEC71E2AA2B89060A41F7F88D29319AD79",+ "actualSha256": "67D5F7D6316FA53F63CEE95C08F45AFEC71E2AA2B89060A41F7F88D29319AD79",+ "exitCode": 0,+ "byteIdentical": true+ },+ {+ "source": "fixtures/Canonical/Sculpting/sculpted-housing.firmament",+ "sourceSha256": "CD6647031A073A140C93CE7DBC14C08D801B84C24F0C15816D3C446464CF1D48",+ "expectedSha256": "27136BC65CACE501B84E6EC81BCC186F1F48262ABB2CC9F76D2208951092396F",+ "actualSha256": "27136BC65CACE501B84E6EC81BCC186F1F48262ABB2CC9F76D2208951092396F",+ "exitCode": 0,+ "byteIdentical": true+ },+ {+ "source": "fixtures/Canonical/Sculpting/surf-x1-freeform-housing.firmament",+ "sourceSha256": "36CCD4855AC3F8574854AA2499CB7B5BFFE4A892852AE9DDC452714962457B38",+ "expectedSha256": "F509AA95D3B223F876790A755DF0052900E07598A1CB8266D63EA2408EF2DB07",+ "actualSha256": "F509AA95D3B223F876790A755DF0052900E07598A1CB8266D63EA2408EF2DB07",+ "exitCode": 0,+ "byteIdentical": true+ },+ {+ "source": "fixtures/Canonical/Sculpting/surf-x1a-trimmed-freeform-housing.firmament",+ "sourceSha256": "990DC7389DBCB4E330B2A316AF4946297B5CA8F13C5BD9A693497792852ABD46",+ "expectedSha256": "5717FD937D9FE93EACF3B49190BB967028C574121AE8850F2D82EA8FC7C1B9B4",+ "actualSha256": "5717FD937D9FE93EACF3B49190BB967028C574121AE8850F2D82EA8FC7C1B9B4",+ "exitCode": 0,+ "byteIdentical": true+ },+ {+ "source": "fixtures/Canonical/Sculpting/surf-x2-g1-blend.firmament",+ "sourceSha256": "1BB2EE58823B87D5CF65D227CC7163D36D92E670B43D33B8D6A9DCDB9F6288F9",+ "expectedSha256": "73C2D486D3CED015EBEFA984C41063C54D86BF81E5A575179CA9098EBE23EF22",+ "actualSha256": "73C2D486D3CED015EBEFA984C41063C54D86BF81E5A575179CA9098EBE23EF22",+ "exitCode": 0,+ "byteIdentical": true+ },+ {+ "source": "fixtures/Canonical/Sculpting/surf-x2-judged-housing.firmament",+ "sourceSha256": "96BEDCA540DD454F27DA530E9B58E3E4C3DA21F4AEE0CA5422E56372D32EDE8C",+ "expectedSha256": "0BC71E45EE37D7B523063A59E5060610048FBE7DAC227D82CB24B4A8186FDB2A",+ "actualSha256": "0BC71E45EE37D7B523063A59E5060610048FBE7DAC227D82CB24B4A8186FDB2A",+ "exitCode": 0,+ "byteIdentical": true+ },+ {+ "source": "fixtures/Canonical/Sculpting/surf-x2-manual-candidate.firmament",+ "sourceSha256": "CFBA24141D578B8049C61FA491B5978D40E873DA149373D287F5DB5488F40056",+ "expectedSha256": "1B32DB8AFF518EAA86ADBEC212047641B48C5CCD9F57736F9C807D897AFA70B2",+ "actualSha256": "1B32DB8AFF518EAA86ADBEC212047641B48C5CCD9F57736F9C807D897AFA70B2",+ "exitCode": 0,+ "byteIdentical": true+ }+ ],+ "moduleReplay": [+ {+ "source": "fixtures/Regression/Inventory/machine.firmasm",+ "expectedAccepted": true,+ "validationExit": 0,+ "buildExit": 0,+ "sha256": "8D3D79045B5181394162D52BA1744CB38778D0906427425974FC2CF680BCBC76",+ "sourceSha256": "CEC185D445B0327794D69FA59AAE17EAF460340C0A2F510C20D98C7C83007E1B",+ "physicalWitness": {+ "assemblyName": "Machine",+ "definitionCount": 2,+ "occurrenceCount": 5,+ "subassemblyCount": 1,+ "bodyCount": 4,+ "maxHierarchyDepth": 2,+ "assemblyBoundingBox": {+ "minimum": [+ -15,+ -10,+ 0+ ],+ "maximum": [+ 155,+ 10,+ 9+ ]+ },+ "lengthUnit": "mm"+ },+ "nativeInstanceTopology": {+ "bodies": 4,+ "faces": 24,+ "edges": 48,+ "vertices": 32+ },+ "inventoryBindings": [+ {+ "name": "Components.bracket",+ "kind": "Part",+ "export": "Bracket",+ "definitionIdentity": "__Module_941122D9F9C1C27BBD62"+ },+ {+ "name": "Components.wideBracket",+ "kind": "Part",+ "export": "Bracket",+ "definitionIdentity": "__Module_6686FAF072AB5D457FE9"+ },+ {+ "name": "Parts.bracket",+ "kind": "Part",+ "export": "Bracket",+ "definitionIdentity": "__Module_941122D9F9C1C27BBD62"+ },+ {+ "name": "Components.drive",+ "kind": "Subassembly",+ "export": "Drive",+ "definitionIdentity": "__Module_7CC766621641D26E8501"+ }+ ],+ "retainedReuse": {+ "definitions": [+ {+ "definitionIdentity": "__Module_6686FAF072AB5D457FE9",+ "reused": true,+ "reason": "unchanged-definition-inputs"+ },+ {+ "definitionIdentity": "__Module_941122D9F9C1C27BBD62",+ "reused": true,+ "reason": "unchanged-definition-inputs"+ }+ ],+ "reusedDefinitions": 2,+ "rebuiltDefinitions": 0+ }+ },+ {+ "source": "fixtures/Regression/Inventory/include-simple.firmament",+ "expectedAccepted": true,+ "validationExit": 0,+ "buildExit": 0,+ "sha256": "25656CB962143A0333316A273AAE984E48FB6F08729FA9BB2DE6A0BE714AFB8D",+ "sourceSha256": "20D4B8F0E784112382BE7047F357821E0C0077E05E0E0CD84E1DD82B9EAC573B",+ "physicalWitness": {+ "assemblyName": "Fastener",+ "definitionCount": 2,+ "occurrenceCount": 2,+ "subassemblyCount": 0,+ "bodyCount": 2,+ "maxHierarchyDepth": 1,+ "assemblyBoundingBox": {+ "minimum": [+ -15,+ -10,+ 0+ ],+ "maximum": [+ 32,+ 10,+ 8+ ]+ },+ "lengthUnit": "mm"+ },+ "nativeInstanceTopology": {+ "bodies": 2,+ "faces": 12,+ "edges": 24,+ "vertices": 16+ },+ "inventoryBindings": [],+ "retainedReuse": {+ "definitions": [+ {+ "definitionIdentity": "Bolt<length: 8mm>",+ "reused": true,+ "reason": "unchanged-definition-inputs"+ },+ {+ "definitionIdentity": "__Module_4438AB2077743E373C6A",+ "reused": true,+ "reason": "unchanged-definition-inputs"+ }+ ],+ "reusedDefinitions": 2,+ "rebuiltDefinitions": 0+ }+ },+ {+ "source": "fixtures/Regression/Inventory/factory.firmament",+ "expectedAccepted": true,+ "validationExit": 0,+ "sceneExportExit": 0,+ "sha256": "53D63BC647E0EC608495BCA5B884AE977B79ACEA36771AA522A4EC3005E6663A",+ "sourceSha256": "487B8E15635DA818A390046F0B6169753F19FF3D4EFBE01E2FF69565E5328702",+ "physicalWitness": {+ "scene": "Factory",+ "internalUnits": "mm",+ "definitions": 4,+ "occurrences": 10,+ "bounds": {+ "minimumMm": [+ -15,+ -10,+ 0+ ],+ "maximumMm": [+ 515,+ 10,+ 9+ ]+ }+ },+ "glbBytes": 8260,+ "retainedPerformance": {+ "bindMilliseconds": 0.6589,+ "definitionCompilationMilliseconds": 3.0397,+ "compositionMilliseconds": 0.09440000000000001,+ "uniqueEngineeringDefinitions": 3,+ "reusedEngineeringDefinitions": 3,+ "rebuiltEngineeringDefinitions": 0,+ "displayPreparationMilliseconds": 0.023999999999999997+ }+ },+ {+ "source": "fixtures/Regression/Inventory/cell.firmament",+ "expectedAccepted": true,+ "validationExit": 0,+ "sceneExportExit": 0,+ "sha256": "CCC4131D0BD32382B5BBA447E3E798B6BBDA8ADFA499F6FD68B82F3A5A732E94",+ "sourceSha256": "B0CFC003461261C4D1C901099C426B5BC453EEB9503A289708C879B5459DED9E",+ "physicalWitness": {+ "scene": "Workcell",+ "internalUnits": "mm",+ "definitions": 1,+ "occurrences": 2,+ "bounds": {+ "minimumMm": [+ 5,+ -10,+ 0+ ],+ "maximumMm": [+ 35,+ 10,+ 6+ ]+ }+ },+ "glbBytes": 2256,+ "retainedPerformance": {+ "bindMilliseconds": 0.5192,+ "definitionCompilationMilliseconds": 0.1809,+ "compositionMilliseconds": 0.0724,+ "uniqueEngineeringDefinitions": 1,+ "reusedEngineeringDefinitions": 1,+ "rebuiltEngineeringDefinitions": 0,+ "displayPreparationMilliseconds": 0.0067+ }+ },+ {+ "source": "fixtures/Regression/Inventory/missing-member.invalid.firmament",+ "expectedAccepted": false,+ "validationExit": 1,+ "buildExit": 1,+ "artifactExists": false,+ "sourceSha256": "312CCEB6BB1A1DB4985F70A11A8AD9EB017375B7CA13311F50D04C1F8785FADA"+ }+ ],+ "retainedGuitar": {+ "builds": [+ {+ "index": 0,+ "elapsedMilliseconds": 10241.4298,+ "success": true,+ "reuse": {+ "definitions": [+ {+ "definitionIdentity": "Board<H:2mm>",+ "reused": false,+ "reason": "first-build-or-evicted"+ },+ {+ "definitionIdentity": "Board<H:5mm>",+ "reused": false,+ "reason": "first-build-or-evicted"+ },+ {+ "definitionIdentity": "Drum<R:12mm,H:3mm>",+ "reused": false,+ "reason": "first-build-or-evicted"+ },+ {+ "definitionIdentity": "Drum<R:16mm,H:1.5mm>",+ "reused": false,+ "reason": "first-build-or-evicted"+ },+ {+ "definitionIdentity": "Drum<R:2.5mm,H:12mm>",+ "reused": false,+ "reason": "first-build-or-evicted"+ },+ {+ "definitionIdentity": "Drum<R:2.5mm,H:16mm>",+ "reused": false,+ "reason": "first-build-or-evicted"+ },+ {+ "definitionIdentity": "Drum<R:24mm,H:1mm>",+ "reused": false,+ "reason": "first-build-or-evicted"+ },+ {+ "definitionIdentity": "Drum<R:4mm,H:7mm>",+ "reused": false,+ "reason": "first-build-or-evicted"+ },+ {+ "definitionIdentity": "Drum<R:4mm,H:8mm,EntryHeight:5mm>",+ "reused": false,+ "reason": "first-build-or-evicted"+ },+ {+ "definitionIdentity": "Drum<R:5mm,H:1mm>",+ "reused": false,+ "reason": "first-build-or-evicted"+ },+ {+ "definitionIdentity": "Drum<R:7mm,H:1.5mm>",+ "reused": false,+ "reason": "first-build-or-evicted"+ },+ {+ "definitionIdentity": "Drum<R:9mm,H:9mm>",+ "reused": false,+ "reason": "first-build-or-evicted"+ },+ {+ "definitionIdentity": "GuitarString<D:0.28mm,Tail:Point3(-25.5mm,-75mm,65mm),Nut:Point3(-18mm,658mm,65mm),Post:Point3(-27mm,721.012484844421mm,54.4402401437605mm)>",+ "reused": false,+ "reason": "first-build-or-evicted"+ },+ {+ "definitionIdentity": "GuitarString<D:0.36mm,Tail:Point3(-15.3mm,-75mm,65mm),Nut:Point3(-10.8mm,658mm,65mm),Post:Point3(-27mm,756.089807176689mm,46.3420021873814mm)>",+ "reused": false,+ "reason": "first-build-or-evicted"+ },+ {+ "definitionIdentity": "GuitarString<D:0.44mm,Tail:Point3(-5.1mm,-75mm,65mm),Nut:Point3(-3.6mm,658mm,65mm),Post:Point3(-27mm,791.167129508958mm,38.2437642310023mm)>",+ "reused": false,+ "reason": "first-build-or-evicted"+ },+ {+ "definitionIdentity": "GuitarString<D:0.52mm,Tail:Point3(5.1mm,-75mm,65mm),Nut:Point3(3.6mm,658mm,65mm),Post:Point3(27mm,791.167129508958mm,38.2437642310023mm)>",+ "reused": false,+ "reason": "first-build-or-evicted"+ },+ {+ "definitionIdentity": "GuitarString<D:0.68mm,Tail:Point3(25.5mm,-75mm,65mm),Nut:Point3(18mm,658mm,65mm),Post:Point3(27mm,721.012484844421mm,54.4402401437605mm)>",+ "reused": false,+ "reason": "first-build-or-evicted"+ },+ {+ "definitionIdentity": "GuitarString<D:0.6mm,Tail:Point3(15.3mm,-75mm,65mm),Nut:Point3(10.8mm,658mm,65mm),Post:Point3(27mm,756.089807176689mm,46.3420021873814mm)>",+ "reused": false,+ "reason": "first-build-or-evicted"+ },+ {+ "definitionIdentity": "Head<H:14mm,RootStart:16mm,RootHalfWidth:26.5mm,RootWidth:53mm>",+ "reused": false,+ "reason": "first-build-or-evicted"+ },+ {+ "definitionIdentity": "Head<H:1mm>",+ "reused": false,+ "reason": "first-build-or-evicted"+ },+ {+ "definitionIdentity": "HeadstockScarf<L:43mm>",+ "reused": false,+ "reason": "first-build-or-evicted"+ },+ {+ "definitionIdentity": "Humbucker<Spec: StandardPickup>",+ "reused": false,+ "reason": "first-build-or-evicted"+ },+ {+ "definitionIdentity": "Panel<L:15mm,W:19mm,H:6mm,R:5mm>",+ "reused": false,+ "reason": "first-build-or-evicted"+ },+ {+ "definitionIdentity": "Panel<L:25mm,W:12mm,H:0.3mm,R:1mm>",+ "reused": false,+ "reason": "first-build-or-evicted"+ },+ {+ "definitionIdentity": "Panel<L:42.89668539123454mm,W:1.2mm,H:1mm,R:0.5mm>",+ "reused": false,+ "reason": "first-build-or-evicted"+ },+ {+ "definitionIdentity": "Panel<L:43.697597898337534mm,W:1.2mm,H:1mm,R:0.5mm>",+ "reused": false,+ "reason": "first-build-or-evicted"+ },+ {+ "definitionIdentity": "Panel<L:44.45355864049755mm,W:1.2mm,H:1mm,R:0.5mm>",+ "reused": false,+ "reason": "first-build-or-evicted"+ },+ {+ "definitionIdentity": "Panel<L:44mm,W:4mm,H:3mm,R:1mm>",+ "reused": false,+ "reason": "first-build-or-evicted"+ },+ {+ "definitionIdentity": "Panel<L:45.16709056641817mm,W:1.2mm,H:1mm,R:0.5mm>",+ "reused": false,+ "reason": "first-build-or-evicted"+ },+ {+ "definitionIdentity": "Panel<L:45.840575022572935mm,W:1.2mm,H:1mm,R:0.5mm>",+ "reused": false,+ "reason": "first-build-or-evicted"+ },+ {+ "definitionIdentity": "Panel<L:46.47625970072782mm,W:1.2mm,H:1mm,R:0.5mm>",+ "reused": false,+ "reason": "first-build-or-evicted"+ },+ {+ "definitionIdentity": "Panel<L:47.07626613940356mm,W:1.2mm,H:1mm,R:0.5mm>",+ "reused": false,+ "reason": "first-build-or-evicted"+ },+ {+ "definitionIdentity": "Panel<L:47.6425968043132mm,W:1.2mm,H:1mm,R:0.5mm>",+ "reused": false,+ "reason": "first-build-or-evicted"+ },+ {+ "definitionIdentity": "Panel<L:48.17714177140536mm,W:1.2mm,H:1mm,R:0.5mm>",+ "reused": false,+ "reason": "first-build-or-evicted"+ },+ {+ "definitionIdentity": "Panel<L:48.68168503481692mm,W:1.2mm,H:1mm,R:0.5mm>",+ "reused": false,+ "reason": "first-build-or-evicted"+ },+ {+ "definitionIdentity": "Panel<L:49.1579104607877mm,W:1.2mm,H:1mm,R:0.5mm>",+ "reused": false,+ "reason": "first-build-or-evicted"+ },+ {+ "definitionIdentity": "Panel<L:49.60740740740741mm,W:1.2mm,H:1mm,R:0.5mm>",+ "reused": false,+ "reason": "first-build-or-evicted"+ },+ {+ "definitionIdentity": "Panel<L:50.031676028950606mm,W:1.2mm,H:1mm,R:0.5mm>",+ "reused": false,+ "reason": "first-build-or-evicted"+ },+ {+ "definitionIdentity": "Panel<L:50.4321322825021mm,W:1.2mm,H:1mm,R:0.5mm>",+ "reused": false,+ "reason": "first-build-or-evicted"+ },+ {+ "definitionIdentity": "Panel<L:50.81011265358211mm,W:1.2mm,H:1mm,R:0.5mm>",+ "reused": false,+ "reason": "first-build-or-evicted"+ },+ {+ "definitionIdentity": "Panel<L:51.16687861654242mm,W:1.2mm,H:1mm,R:0.5mm>",+ "reused": false,+ "reason": "first-build-or-evicted"+ },+ {+ "definitionIdentity": "Panel<L:51.5036208446198mm,W:1.2mm,H:1mm,R:0.5mm>",+ "reused": false,+ "reason": "first-build-or-evicted"+ },+ {+ "definitionIdentity": "Panel<L:51.82146318369725mm,W:1.2mm,H:1mm,R:0.5mm>",+ "reused": false,+ "reason": "first-build-or-evicted"+ },+ {+ "definitionIdentity": "Panel<L:52.121466403035114mm,W:1.2mm,H:1mm,R:0.5mm>",+ "reused": false,+ "reason": "first-build-or-evicted"+ },+ {+ "definitionIdentity": "Panel<L:52.40463173548993mm,W:1.2mm,H:1mm,R:0.5mm>",+ "reused": false,+ "reason": "first-build-or-evicted"+ },+ {+ "definitionIdentity": "Panel<L:52.67190421903601mm,W:1.2mm,H:1mm,R:0.5mm>",+ "reused": false,+ "reason": "first-build-or-evicted"+ },+ {+ "definitionIdentity": "Panel<L:52.9241758507418mm,W:1.2mm,H:1mm,R:0.5mm>",+ "reused": false,+ "reason": "first-build-or-evicted"+ },+ {+ "definitionIdentity": "Panel<L:63mm,W:93mm,H:1mm,R:15mm>",+ "reused": false,+ "reason": "first-build-or-evicted"+ },+ {+ "definitionIdentity": "Panel<L:7mm,W:9mm,H:2mm,R:1mm>",+ "reused": false,+ "reason": "first-build-or-evicted"+ },+ {+ "definitionIdentity": "Panel<L:82mm,W:12mm,H:10mm,R:5mm>",+ "reused": false,+ "reason": "first-build-or-evicted"+ },+ {+ "definitionIdentity": "Panel<L:88mm,W:15mm,H:7mm,R:6mm>",+ "reused": false,+ "reason": "first-build-or-evicted"+ },+ {+ "definitionIdentity": "SectionChainFile<\"CarvedMaple.firmament\">",+ "reused": false,+ "reason": "first-build-or-evicted"+ },+ {+ "definitionIdentity": "SectionChainFile<\"IvoryBinding.firmament\">",+ "reused": false,+ "reason": "first-build-or-evicted"+ },+ {+ "definitionIdentity": "SectionChainFile<\"MahoganyBack.firmament\">",+ "reused": false,+ "reason": "first-build-or-evicted"+ },+ {+ "definitionIdentity": "SectionChainFile<\"Neck.firmament\">",+ "reused": false,+ "reason": "first-build-or-evicted"+ },+ {+ "definitionIdentity": "TailpieceRail<L:76mm,R:5mm>",+ "reused": false,+ "reason": "first-build-or-evicted"+ }+ ],+ "reusedDefinitions": 0,+ "rebuiltDefinitions": 56+ }+ },+ {+ "index": 1,+ "elapsedMilliseconds": 137.6584,+ "success": true,+ "reuse": {+ "definitions": [+ {+ "definitionIdentity": "Board<H:2mm>",+ "reused": true,+ "reason": "unchanged-definition-inputs"+ },+ {+ "definitionIdentity": "Board<H:5mm>",+ "reused": true,+ "reason": "unchanged-definition-inputs"+ },+ {+ "definitionIdentity": "Drum<R:12mm,H:3mm>",+ "reused": true,+ "reason": "unchanged-definition-inputs"+ },+ {+ "definitionIdentity": "Drum<R:16mm,H:1.5mm>",+ "reused": true,+ "reason": "unchanged-definition-inputs"+ },+ {+ "definitionIdentity": "Drum<R:2.5mm,H:12mm>",+ "reused": true,+ "reason": "unchanged-definition-inputs"+ },+ {+ "definitionIdentity": "Drum<R:2.5mm,H:16mm>",+ "reused": true,+ "reason": "unchanged-definition-inputs"+ },+ {+ "definitionIdentity": "Drum<R:24mm,H:1mm>",+ "reused": true,+ "reason": "unchanged-definition-inputs"+ },+ {+ "definitionIdentity": "Drum<R:4mm,H:7mm>",+ "reused": true,+ "reason": "unchanged-definition-inputs"+ },+ {+ "definitionIdentity": "Drum<R:4mm,H:8mm,EntryHeight:5mm>",+ "reused": true,+ "reason": "unchanged-definition-inputs"+ },+ {+ "definitionIdentity": "Drum<R:5mm,H:1mm>",+ "reused": true,+ "reason": "unchanged-definition-inputs"+ },+ {+ "definitionIdentity": "Drum<R:7mm,H:1.5mm>",+ "reused": true,+ "reason": "unchanged-definition-inputs"+ },+ {+ "definitionIdentity": "Drum<R:9mm,H:9mm>",+ "reused": true,+ "reason": "unchanged-definition-inputs"+ },+ {+ "definitionIdentity": "GuitarString<D:0.28mm,Tail:Point3(-25.5mm,-75mm,65mm),Nut:Point3(-18mm,658mm,65mm),Post:Point3(-27mm,721.012484844421mm,54.4402401437605mm)>",+ "reused": true,+ "reason": "unchanged-definition-inputs"+ },+ {+ "definitionIdentity": "GuitarString<D:0.36mm,Tail:Point3(-15.3mm,-75mm,65mm),Nut:Point3(-10.8mm,658mm,65mm),Post:Point3(-27mm,756.089807176689mm,46.3420021873814mm)>",+ "reused": true,+ "reason": "unchanged-definition-inputs"+ },+ {+ "definitionIdentity": "GuitarString<D:0.44mm,Tail:Point3(-5.1mm,-75mm,65mm),Nut:Point3(-3.6mm,658mm,65mm),Post:Point3(-27mm,791.167129508958mm,38.2437642310023mm)>",+ "reused": true,+ "reason": "unchanged-definition-inputs"+ },+ {+ "definitionIdentity": "GuitarString<D:0.52mm,Tail:Point3(5.1mm,-75mm,65mm),Nut:Point3(3.6mm,658mm,65mm),Post:Point3(27mm,791.167129508958mm,38.2437642310023mm)>",+ "reused": true,+ "reason": "unchanged-definition-inputs"+ },+ {+ "definitionIdentity": "GuitarString<D:0.68mm,Tail:Point3(25.5mm,-75mm,65mm),Nut:Point3(18mm,658mm,65mm),Post:Point3(27mm,721.012484844421mm,54.4402401437605mm)>",+ "reused": true,+ "reason": "unchanged-definition-inputs"+ },+ {+ "definitionIdentity": "GuitarString<D:0.6mm,Tail:Point3(15.3mm,-75mm,65mm),Nut:Point3(10.8mm,658mm,65mm),Post:Point3(27mm,756.089807176689mm,46.3420021873814mm)>",+ "reused": true,+ "reason": "unchanged-definition-inputs"+ },+ {+ "definitionIdentity": "Head<H:14mm,RootStart:16mm,RootHalfWidth:26.5mm,RootWidth:53mm>",+ "reused": true,+ "reason": "unchanged-definition-inputs"+ },+ {+ "definitionIdentity": "Head<H:1mm>",+ "reused": true,+ "reason": "unchanged-definition-inputs"+ },+ {+ "definitionIdentity": "HeadstockScarf<L:43mm>",+ "reused": true,+ "reason": "unchanged-definition-inputs"+ },+ {+ "definitionIdentity": "Humbucker<Spec: StandardPickup>",+ "reused": true,+ "reason": "unchanged-definition-inputs"+ },+ {+ "definitionIdentity": "Panel<L:15mm,W:19mm,H:6mm,R:5mm>",+ "reused": true,+ "reason": "unchanged-definition-inputs"+ },+ {+ "definitionIdentity": "Panel<L:25mm,W:12mm,H:0.3mm,R:1mm>",+ "reused": true,+ "reason": "unchanged-definition-inputs"+ },+ {+ "definitionIdentity": "Panel<L:42.89668539123454mm,W:1.2mm,H:1mm,R:0.5mm>",+ "reused": true,+ "reason": "unchanged-definition-inputs"+ },+ {+ "definitionIdentity": "Panel<L:43.697597898337534mm,W:1.2mm,H:1mm,R:0.5mm>",+ "reused": true,+ "reason": "unchanged-definition-inputs"+ },+ {+ "definitionIdentity": "Panel<L:44.45355864049755mm,W:1.2mm,H:1mm,R:0.5mm>",+ "reused": true,+ "reason": "unchanged-definition-inputs"+ },+ {+ "definitionIdentity": "Panel<L:44mm,W:4mm,H:3mm,R:1mm>",+ "reused": true,+ "reason": "unchanged-definition-inputs"+ },+ {+ "definitionIdentity": "Panel<L:45.16709056641817mm,W:1.2mm,H:1mm,R:0.5mm>",+ "reused": true,+ "reason": "unchanged-definition-inputs"+ },+ {+ "definitionIdentity": "Panel<L:45.840575022572935mm,W:1.2mm,H:1mm,R:0.5mm>",+ "reused": true,+ "reason": "unchanged-definition-inputs"+ },+ {+ "definitionIdentity": "Panel<L:46.47625970072782mm,W:1.2mm,H:1mm,R:0.5mm>",+ "reused": true,+ "reason": "unchanged-definition-inputs"+ },+ {+ "definitionIdentity": "Panel<L:47.07626613940356mm,W:1.2mm,H:1mm,R:0.5mm>",+ "reused": true,+ "reason": "unchanged-definition-inputs"+ },+ {+ "definitionIdentity": "Panel<L:47.6425968043132mm,W:1.2mm,H:1mm,R:0.5mm>",+ "reused": true,+ "reason": "unchanged-definition-inputs"+ },+ {+ "definitionIdentity": "Panel<L:48.17714177140536mm,W:1.2mm,H:1mm,R:0.5mm>",+ "reused": true,+ "reason": "unchanged-definition-inputs"+ },+ {+ "definitionIdentity": "Panel<L:48.68168503481692mm,W:1.2mm,H:1mm,R:0.5mm>",+ "reused": true,+ "reason": "unchanged-definition-inputs"+ },+ {+ "definitionIdentity": "Panel<L:49.1579104607877mm,W:1.2mm,H:1mm,R:0.5mm>",+ "reused": true,+ "reason": "unchanged-definition-inputs"+ },+ {+ "definitionIdentity": "Panel<L:49.60740740740741mm,W:1.2mm,H:1mm,R:0.5mm>",+ "reused": true,+ "reason": "unchanged-definition-inputs"+ },+ {+ "definitionIdentity": "Panel<L:50.031676028950606mm,W:1.2mm,H:1mm,R:0.5mm>",+ "reused": true,+ "reason": "unchanged-definition-inputs"+ },+ {+ "definitionIdentity": "Panel<L:50.4321322825021mm,W:1.2mm,H:1mm,R:0.5mm>",+ "reused": true,+ "reason": "unchanged-definition-inputs"+ },+ {+ "definitionIdentity": "Panel<L:50.81011265358211mm,W:1.2mm,H:1mm,R:0.5mm>",+ "reused": true,+ "reason": "unchanged-definition-inputs"+ },+ {+ "definitionIdentity": "Panel<L:51.16687861654242mm,W:1.2mm,H:1mm,R:0.5mm>",+ "reused": true,+ "reason": "unchanged-definition-inputs"+ },+ {+ "definitionIdentity": "Panel<L:51.5036208446198mm,W:1.2mm,H:1mm,R:0.5mm>",+ "reused": true,+ "reason": "unchanged-definition-inputs"+ },+ {+ "definitionIdentity": "Panel<L:51.82146318369725mm,W:1.2mm,H:1mm,R:0.5mm>",+ "reused": true,+ "reason": "unchanged-definition-inputs"+ },+ {+ "definitionIdentity": "Panel<L:52.121466403035114mm,W:1.2mm,H:1mm,R:0.5mm>",+ "reused": true,+ "reason": "unchanged-definition-inputs"+ },+ {+ "definitionIdentity": "Panel<L:52.40463173548993mm,W:1.2mm,H:1mm,R:0.5mm>",+ "reused": true,+ "reason": "unchanged-definition-inputs"+ },+ {+ "definitionIdentity": "Panel<L:52.67190421903601mm,W:1.2mm,H:1mm,R:0.5mm>",+ "reused": true,+ "reason": "unchanged-definition-inputs"+ },+ {+ "definitionIdentity": "Panel<L:52.9241758507418mm,W:1.2mm,H:1mm,R:0.5mm>",+ "reused": true,+ "reason": "unchanged-definition-inputs"+ },+ {+ "definitionIdentity": "Panel<L:63mm,W:93mm,H:1mm,R:15mm>",+ "reused": true,+ "reason": "unchanged-definition-inputs"+ },+ {+ "definitionIdentity": "Panel<L:7mm,W:9mm,H:2mm,R:1mm>",+ "reused": true,+ "reason": "unchanged-definition-inputs"+ },+ {+ "definitionIdentity": "Panel<L:82mm,W:12mm,H:10mm,R:5mm>",+ "reused": true,+ "reason": "unchanged-definition-inputs"+ },+ {+ "definitionIdentity": "Panel<L:88mm,W:15mm,H:7mm,R:6mm>",+ "reused": true,+ "reason": "unchanged-definition-inputs"+ },+ {+ "definitionIdentity": "SectionChainFile<\"CarvedMaple.firmament\">",+ "reused": true,+ "reason": "unchanged-definition-inputs"+ },+ {+ "definitionIdentity": "SectionChainFile<\"IvoryBinding.firmament\">",+ "reused": true,+ "reason": "unchanged-definition-inputs"+ },+ {+ "definitionIdentity": "SectionChainFile<\"MahoganyBack.firmament\">",+ "reused": true,+ "reason": "unchanged-definition-inputs"+ },+ {+ "definitionIdentity": "SectionChainFile<\"Neck.firmament\">",+ "reused": true,+ "reason": "unchanged-definition-inputs"+ },+ {+ "definitionIdentity": "TailpieceRail<L:76mm,R:5mm>",+ "reused": true,+ "reason": "unchanged-definition-inputs"+ }+ ],+ "reusedDefinitions": 56,+ "rebuiltDefinitions": 0+ }+ }+ ]+ },+ "runtimeSnapshot": {+ "capturedUtc": "2026-10-15T18:09:43.4416386Z",+ "remainingHosts": 0,+ "taskOwnedHostsReaped": 0,+ "freePhysicalMemoryGiB": 11.031,+ "freeDiskGiB": 91.933,+ "qualification": "Post-run snapshot, not a sustained leak test"+ },+ "sourceAndBinaryHashes": [+ {+ "path": "Aetheris.CLI.Tests/FirmamentInventoryCliTests.cs",+ "sha256": "5406E719DC0B3A3B3316EDA89B6F3A72BC4A5E4016FD2973D7DE55412A5C5865"+ },+ {+ "path": "Aetheris.CLI/CliRunner.cs",+ "sha256": "3699D11CBB9125787E8B68249C60B8A473FF16C06A54C0652C8372916D8C3A1E"+ },+ {+ "path": "Aetheris.Kernel.Firmament.Tests/Assembly/AssemblyUnifiedFrontendTests.cs",+ "sha256": "D6E3F9B04B11496E5B782D644CFBC83FAB0A90C44CA7D7935DC7868E069E49BA"+ },+ {+ "path": "Aetheris.Kernel.Firmament.Tests/FirmamentInventoryTests.cs",+ "sha256": "848E39261EA549A1670B7B54B1827239B45046569080D0516D04B5F122AD5E87"+ },+ {+ "path": "Aetheris.Kernel.Firmament.Tests/FirmamentSemanticSchemaTests.cs",+ "sha256": "FA423228F308C7B57173CE6227A347CAA4B599FA59627F6F7DD792BE53D4B888"+ },+ {+ "path": "Aetheris.Kernel.Firmament/Assembly/AssemblyM0Compiler.cs",+ "sha256": "D677EDD45657B50D61FCBFE92774C740CFBC9CBF1861E52F3EAB261C782EDFD9"+ },+ {+ "path": "Aetheris.Kernel.Firmament/Assembly/AssemblyM0Models.cs",+ "sha256": "836878BE48643C03BAAC65CC9D9D7866E8CB478B8BF4055D6F05B0E5223CAC6E"+ },+ {+ "path": "Aetheris.Kernel.Firmament/Assembly/AssemblyM0Parser.cs",+ "sha256": "8E98A5A2138BB79310726D85D85DFA5AC4AABEA596C81BD10042EE226232508D"+ },+ {+ "path": "Aetheris.Kernel.Firmament/Assembly/AssemblyM1Execution.cs",+ "sha256": "D5E68C08A1CA10E4656E769B01C8ED10B2FFB4326F800F114C85DB3000C72CFE"+ },+ {+ "path": "Aetheris.Kernel.Firmament/Assembly/AssemblyModuleMaterialization.cs",+ "sha256": "7826AF618F2B03F9B51022C423707481A08B7E3ABA9A865AFF2798EFDCEBD712"+ },+ {+ "path": "Aetheris.Kernel.Firmament/Assembly/FirmamentAssemblyDocumentProfile.cs",+ "sha256": "BCBD43F8B74D51FC517404AAADF58345C8E1E7815B4074690367CAAC80A046A5"+ },+ {+ "path": "Aetheris.Kernel.Firmament/Assembly/FirmamentCompilationSession.cs",+ "sha256": "E92AF2803DCA2843ADCA17223DF7519F274F3965087CFC91DFFB1CEDB86863B9"+ },+ {+ "path": "Aetheris.Kernel.Firmament/FirmamentV2/Syntax/FirmamentDataBinding.cs",+ "sha256": "B742BFEDC1416ABD4D7FA50F3107D300241116FFFF8DA342788892D5DE87604E"+ },+ {+ "path": "Aetheris.Kernel.Firmament/FirmamentV2/Syntax/FirmamentSyntaxParser.cs",+ "sha256": "19735311FEF57EB38D6D95500E9137113F40E60A96F1C85A26B58870B4F73B72"+ },+ {+ "path": "Aetheris.Kernel.Firmament/Modules/FirmamentModuleGraph.cs",+ "sha256": "70DED5D8D2D8B20A6F0C50D972F71235961301A46F165E4337BE7B49110EC979"+ },+ {+ "path": "Aetheris.Kernel.Firmament/Scene/SceneAuthoring.cs",+ "sha256": "BEF6F5ACDE0CCC38A9B07525FC885EF79FB7D8989DDF2DD52957E697B0ADD8DE"+ },+ {+ "path": "Aetheris.Kernel.Firmament/Scene/SceneCompilation.cs",+ "sha256": "D09E7CA2760F856F9A5388962B320E409F488FC5C7C60C19D4B03A1495C2CBB9"+ },+ {+ "path": "Aetheris.CLI/bin/Release/net10.0/aetheris.dll",+ "sha256": "FE1A395CC58028F480C05C4758BE6929808E77810F6ED8F13074BCDB25B96A61"+ },+ {+ "path": "Aetheris.Kernel.Firmament/bin/Release/net10.0/Aetheris.Kernel.Firmament.dll",+ "sha256": "5ABE723289A6580A959DFFB449F69D7191BCFA828BC7C451FE7C86270CD26334"+ }+ ],+ "remainingBoundaries": [+ "Concrete modules only; specialize Templates in their defining module before export.",+ "Source snapshots contain source documents, not STEP assets; concrete Part file-resource adapters without snapshot context reject explicitly.",+ "Legacy include composition and engineering domain lowerers retain mapped/bounded source transport; complete generated-source maps remain X2 work.",+ "Scene source-model binding/dependency receipts are retained in the compiler API; CLI Scene inspection currently projects nodes and original anchors.",+ "No new live Helios or browser interaction qualification is claimed."+ ]+}diff --git a/docs/release/FIRMAMENT-INVENTORY-MODULES.md b/docs/release/FIRMAMENT-INVENTORY-MODULES.mdnew file mode 100644index 00000000..04b1d88a--- /dev/null+++ b/docs/release/FIRMAMENT-INVENTORY-MODULES.md@@ -0,0 +1,178 @@+# Firmament Inventory Records — module binding first pass++Date: 2026-10-15. Implementation base: `263f0128`.++**Success for the Inventory module first pass. X2 remains open for the stated+semantic and source-adapter boundaries.**++## Authoring decisions++`Inventory Record Components { bracket: Part = Firmament("parts/bracket").Bracket }`+provides qualified, checked names for concrete Part, Subassembly, Assembly and Scene+modules. Inventory availability creates no occurrence or quantity. Existing+`include` remains a short unqualified composition, including concrete Parts and+legacy Template applications. There is no enforced catalog-size threshold.++Constructs, types, adapters and catalog names use PascalCase; catalog members use+camelCase. Exported/domain/user names keep their spelling. Locators normally omit+extensions: Firmament resolves `.firmament` / `.firmasm`, Step resolves `.step` /+`.stp`. Ambiguity rejects; explicit extensions remain the repair. Paths resolve+relative to their declaring document. The established snapshot-only root-relative+include spelling remains a fallback when the document-relative target is absent.++Entries import concrete modules. Templates specialize within their defining source+and export the resulting product. Cross-module Template value arguments are not+admitted by this first pass, preventing caller values from being captured by a+private Static in the imported module. Source snapshots still contain source only:+STEP/InlineStep assets reject, and concrete Part resource adapters without a+project-aware context reject explicitly rather than accessing the filesystem.++## Ownership and repairs++`FirmamentModuleGraph` uses the existing recursive-descent AST for dependencies,+Inventory fields, export-kind checks, lexical catalogs and occurrence reference+binding. Each original source has its own node. Mapping bodies bind module+references before Pattern expansion; iteration symbols and parameters shadow outer+catalogs. The existing already-resolved parser API retains its supplied project+context, including source-backed published-port dependencies. Inventory imports do not inject+foreign declarations into a global Record/Template catalog. Legacy includes retain+an explicitly source-mapped declaration projection into their consuming scope.+The two regex include-discovery implementations are removed.++Native Parts use the existing Firmament build and exact AP242 importer. Imported+Assemblies/Subassemblies use the existing local solve, published ports, Interface+and Mate owners. Scene composition reuses those engineering products and composes+nested Scene geometry, hierarchy, appearances and frames. Child cameras remain+private. No geometry operation or placement solver was added.++The shared grammar now recognizes the Inventory modifier and a product-tree tag+following a newline-terminated field. The `.firmasm` profile counts actual root+AST declarations instead of guessing from line starts. Inventory is registered+with the existing generated schema/completion metadata.++Module identities derive from project-relative paths, kind and export. Native file+and source-snapshot builds retain the same definition identities, definition STEP+hashes and world transforms. Their overall artifact digest can differ because it+also contains intentionally different original-source provenance.++`validate` uses ordinary Assembly/Scene engineering admission unless parse-only is+requested. Parse-only reports `ParsedNotBuilt`; it does not promise geometry.+Unknown adapters/members, invalid headers, duplicate names, private-scope references,+kind mismatches, missing exports/resources, cycles and ambiguous locators reject.+No fallback frontend interprets those failures as a different language.++## Diagnostics and provenance++Inventory/resource/syntax diagnostics retain their original source file and span.+The included-syntax regression now checks the original `bad.firmament` offset rather+than accepting a synthetic `#expanded-includes` location. Source projections map+only diagnostics belonging to their own producer document; imported diagnostics+are not remapped through the caller's offsets.++Engineering lowerers retain bounded source adapters. A lowerer that cannot provide+a precise expression span reports the enclosing exported Part and discloses that+limitation. Complete per-node generated-source and expansion maps remain X2 work.+Ordinary Assembly IR and the compiled Scene source model retain Inventory binding+receipts and source dependency hashes. CLI Scene inspection exposes the composed+nodes and their source anchors; its existing report does not yet project those+additional source-model receipt collections. No product-specific validator was introduced.++## Regression and geometry qualification++The final serial solution gate passed **5,051 tests across 20 executing+assemblies**, with zero failures/skips. The release solution build has zero errors+and 10 existing warnings. Focused compiler tests: 76; focused CLI+tests: 4; required Core fast lane: 1,068; public documentation+qualification: 13. Focused/fast counts are not added to the full total.++The complete corpus contains **1,285 sources**, including **327/327 canonical+structural successes**, with zero unresolved classification mismatches. All 1,276+inherited sources retain their hashes, AST fingerprints, owners, production+levels/exits, diagnostic codes and dispositions. Nine new module sources account+for the entire inventory change. Six are directly admitted, two declaration modules+are proved in actual consuming Assemblies, and the explicit negative rejects.+The standalone Subassembly's module-context diagnostic does not claim it is a+runnable mechanical data Record. Canonical classifications remain 285 direct+admissions, 33 actual consumer contexts and nine existing domain limitations.++**All 26 established STEP/AP242 baselines are byte-identical.** The replay checks+source hashes before comparing artifacts, including guitar, assemblies, symmetry,+Sculpting and typed-tolerance/PMI examples. The second retained guitar compile+reuses its tracked definitions; detailed counts are retained in the compact record.++Real CLI replay validates/builds/reimports assembly STEP for the machine and short-include+Assembly, validates/inspects/exports GLB for the factory and child Scene, and proves+that unknown members fail both validate and build without a STEP artifact. Native+component tests also compare source-snapshot definition identities, STEP definition+hashes and world transforms against disk compilation.++Post-run snapshot: **0 remaining .NET/test/build hosts**, 11.03 GiB free RAM,+91.93 GiB free disk. This is not a long-duration leak or browser-interaction claim.++Current source inventory SHA-256: `8F76A0EE96B4912DA5CD6DE8AAA11358DF2378800DFCCF1A7CE8CB00A327925F`.++Raw outputs stay under ignored `artifacts/local/firmament-inventory/`. Final gates+are `final-build.log`, `final-focused.log`, `final-cli.log`, `final-fast.log`,+`final-full.log` and `final-docs.log`; complete corpus output is `corpus/report.json`+and `classified.json`. STEP replay is `geometry-parity.json`, module replay is+`module-replay.json`, and host state is `runtime-summary.json`. Earlier intermediate+runs remain reproduction evidence and are not substituted for the final gate.++Portable record: [Inventory compact evidence](FIRMAMENT-INVENTORY-MODULES.evidence.json).+++The complete fixtures are [the machine](../../fixtures/Regression/Inventory/machine.firmasm),+[the factory](../../fixtures/Regression/Inventory/factory.firmament),+[short includes](../../fixtures/Regression/Inventory/include-simple.firmament) and+[missing-member rejection](../../fixtures/Regression/Inventory/missing-member.invalid.firmament).+Component tests cover private schemas, catalog/Pattern shadowing, source/snapshot geometry,+retained cache reuse/invalidation, STEP import, published ports through the real+Mate solver, source-only resource rejection and original syntax locations.++## Code-quality review and remaining boundaries++The modified seam is a module-binding owner, not another whole-document parser,+expression evaluator or text macro system. Private transport identifiers replace+only AST-bound occurrence reference spans. Original engineering lowerers remain the+source of geometry and capability admission. There is no compiler-global mutable+module registry or background service. Graph traversal and retained sessions have+explicit finite bounds; cycles reject rather than truncating expansion.++This pass does not complete all X2 semantic migration. Remaining collection/domain+readers, generated-source maps and the general typed cross-module specialization+contract remain explicit work. Unused Inventory entries resolve and kind-check;+placed occurrences request engineering materialization. STEP supplies one Part+through the existing strict importer; importing STEP assemblies as Inventory+Assemblies is not introduced here.++## Replay++```powershell+dotnet build Aetheris.slnx -c Release -m:1 -nr:false -p:UseSharedCompilation=false+dotnet test Aetheris.Kernel.Core.Tests -c Release --no-build --filter "Category!=SlowCorpus"+dotnet test Aetheris.slnx -c Release --no-build -m:1 -nr:false -- RunConfiguration.MaxCpuCount=1+dotnet Aetheris.CLI/bin/Release/net10.0/aetheris.dll validate fixtures/Regression/Inventory/machine.firmasm --json+dotnet Aetheris.CLI/bin/Release/net10.0/aetheris.dll asm export-ap242 fixtures/Regression/Inventory/machine.firmasm --out artifacts/local/firmament-inventory/machine.step --json+dotnet Aetheris.CLI/bin/Release/net10.0/aetheris.dll scene inspect fixtures/Regression/Inventory/factory.firmament --json+```++Language reference: [syntax.md](../public/firmament/syntax.md),+[Inventory guide](../public/firmament/inventory.md),+[decision register](../development/FIRMAMENT-LANGUAGE-DECISIONS-2026-10.md).++## Measured artifact witnesses++All bounds are in millimetres. Occurrence totals include product-tree containers;+body totals count physical Parts.++| Fixture | Export and reimport | Physical bodies | World minimum | World maximum |+| --- | --- | ---: | --- | --- |+| Machine | AP242 assembly, reimported | 4 | `[-15, -10, 0]` | `[155, 10, 9]` |+| Short includes | AP242 assembly, reimported | 2 | `[-15, -10, 0]` | `[32, 10, 8]` |+| Factory | GLB, Scene inspection | — | `[-15, -10, 0]` | `[515, 10, 9]` |+| Workcell | GLB, Scene inspection | — | `[5, -10, 0]` | `[35, 10, 6]` |++The native Assembly instance bounds and body counts match the exported STEP+reimport. Scene bounds come from ordinary composed Scene inspection, with a+successful GLB export. The compact record retains definition/occurrence counts,+artifact hashes and retained-session reuse measurements.diff --git a/fixtures/Regression/Inventory/README.md b/fixtures/Regression/Inventory/README.mdnew file mode 100644index 00000000..2b2fdbcd--- /dev/null+++ b/fixtures/Regression/Inventory/README.md@@ -0,0 +1,18 @@+# Inventory module qualification++The four module kinds use one AST-owned dependency graph. Locators are relative+to the declaring document. `machine.firmasm` composes Parts and a Subassembly;+`factory.firmament` composes that Assembly, a nested Scene and another Part.+The two Bracket exports belong to separate files and retain separate schemas.+`include-simple.firmament` retains the short, unqualified include form.+`missing-member.invalid.firmament` must reject without producing geometry.++The component tests also qualify STEP through an explicitly generated asymmetric+Part artifact, source snapshots, ambiguity, cycles, private scopes, cache reuse,+source locations and published ports through the ordinary Mate solver.++```powershell+dotnet Aetheris.CLI/bin/Release/net10.0/aetheris.dll validate fixtures/Regression/Inventory/machine.firmasm --json+dotnet Aetheris.CLI/bin/Release/net10.0/aetheris.dll asm export-ap242 fixtures/Regression/Inventory/machine.firmasm --out artifacts/local/firmament-inventory/machine.step --json+dotnet Aetheris.CLI/bin/Release/net10.0/aetheris.dll scene inspect fixtures/Regression/Inventory/factory.firmament --json+```diff --git a/fixtures/Regression/Inventory/cell.firmament b/fixtures/Regression/Inventory/cell.firmamentnew file mode 100644index 00000000..454960ab--- /dev/null+++ b/fixtures/Regression/Inventory/cell.firmament@@ -0,0 +1,9 @@+Inventory Record Parts {+ bracket: Part = Firmament("parts/bracket").Bracket+}+Scene Workcell {+ units: mm+ <Part bracket = Parts.bracket>+ Placement { from: Origin; to: World; translateLocal: [20mm, 0mm, 0mm]; }+ </Part>+}diff --git a/fixtures/Regression/Inventory/drive.firmament b/fixtures/Regression/Inventory/drive.firmamentnew file mode 100644index 00000000..fc0ffafa--- /dev/null+++ b/fixtures/Regression/Inventory/drive.firmament@@ -0,0 +1,10 @@+Inventory Record Parts {+ bracket: Part = Firmament("parts/bracket").Bracket+}+Subassembly Drive {+ <Assembly Drive>+ <Part Left = Parts.bracket> Placement { from: Origin; to: World; } </Part>+ <Part Right = Parts.bracket> Placement { from: Origin; to: World; translateLocal: [50mm, 0mm, 0mm]; } </Part>+ </Assembly>+ Anchor: Drive;+}diff --git a/fixtures/Regression/Inventory/factory.firmament b/fixtures/Regression/Inventory/factory.firmamentnew file mode 100644index 00000000..c504a525--- /dev/null+++ b/fixtures/Regression/Inventory/factory.firmament@@ -0,0 +1,17 @@+Inventory Record Library {+ machine: Assembly = Firmament("machine").Machine+ cell: Scene = Firmament("cell").Workcell+ bracket: Part = Firmament("parts/bracket").Bracket+}+Scene Factory {+ units: mm+ <Assembly machine = Library.machine>+ Placement { from: Origin; to: World; }+ </Assembly>+ <Scene cell = Library.cell>+ Placement { from: Origin; to: World; translateLocal: [300mm, 0mm, 0mm]; }+ </Scene>+ <Part stock = Library.bracket>+ Placement { from: Origin; to: World; translateLocal: [500mm, 0mm, 0mm]; }+ </Part>+}diff --git a/fixtures/Regression/Inventory/include-simple.firmament b/fixtures/Regression/Inventory/include-simple.firmamentnew file mode 100644index 00000000..b18dae3d--- /dev/null+++ b/fixtures/Regression/Inventory/include-simple.firmament@@ -0,0 +1,9 @@+include "parts/bracket";+include "parts/bolt";+Assembly Fastener {+ <Assembly Fastener>+ <Part Bracket = Bracket> Placement { from: Origin; to: World; } </Part>+ <Part Bolt = Bolt<length: 8mm>> Placement { from: Origin; to: World; translateLocal: [30mm, 0mm, 0mm]; } </Part>+ </Assembly>+ Anchor: Fastener;+}diff --git a/fixtures/Regression/Inventory/machine.firmasm b/fixtures/Regression/Inventory/machine.firmasmnew file mode 100644index 00000000..b859aa81--- /dev/null+++ b/fixtures/Regression/Inventory/machine.firmasm@@ -0,0 +1,13 @@+Inventory Record Components {+ bracket: Part = Firmament("parts/bracket").Bracket+ wideBracket: Part = Firmament("parts/wide-bracket").Bracket+ drive: Subassembly = Firmament("drive").Drive+}+Assembly Machine {+ <Assembly Machine>+ <Part Stock = Components.bracket> Placement { from: Origin; to: World; } </Part>+ <Part Wide = Components.wideBracket> Placement { from: Origin; to: World; translateLocal: [50mm, 0mm, 0mm]; } </Part>+ <Assembly Drive = Components.drive> Placement { from: Origin; to: World; translateLocal: [90mm, 0mm, 0mm]; } </Assembly>+ </Assembly>+ Anchor: Machine;+}diff --git a/fixtures/Regression/Inventory/missing-member.invalid.firmament b/fixtures/Regression/Inventory/missing-member.invalid.firmamentnew file mode 100644index 00000000..ab40b8a0--- /dev/null+++ b/fixtures/Regression/Inventory/missing-member.invalid.firmament@@ -0,0 +1,7 @@+Inventory Record Parts {+ bracket: Part = Firmament("parts/bracket").Bracket+}+Assembly Broken {+ <Assembly Broken><Part Stock = Parts.braket></Part></Assembly>+ Anchor: Broken.Stock;+}diff --git a/fixtures/Regression/Inventory/parts/bolt.firmament b/fixtures/Regression/Inventory/parts/bolt.firmamentnew file mode 100644index 00000000..4403659b--- /dev/null+++ b/fixtures/Regression/Inventory/parts/bolt.firmament@@ -0,0 +1,3 @@+Template<length: Length = 8mm> Struct Bolt {+ Box stock { size: [4mm, 4mm, length] }+}diff --git a/fixtures/Regression/Inventory/parts/bracket.firmament b/fixtures/Regression/Inventory/parts/bracket.firmamentnew file mode 100644index 00000000..e5ac2471--- /dev/null+++ b/fixtures/Regression/Inventory/parts/bracket.firmament@@ -0,0 +1,6 @@+Record Spec { width: Length }+Static spec: Spec = Spec { width: 30mm }+Model Bracket {+ units: mm+ Box stock { size: [spec.width, 20mm, 6mm] }+}diff --git a/fixtures/Regression/Inventory/parts/wide-bracket.firmament b/fixtures/Regression/Inventory/parts/wide-bracket.firmamentnew file mode 100644index 00000000..f163e300--- /dev/null+++ b/fixtures/Regression/Inventory/parts/wide-bracket.firmament@@ -0,0 +1,6 @@+Record Spec { width: Length thickness: Length }+Static spec: Spec = Spec { width: 40mm thickness: 9mm }+Model Bracket {+ units: mm+ Box stock { size: [spec.width, 20mm, spec.thickness] }+}