Skip to content

Next Gen STEP AP242 Native-ish BREP Geometric Modeling Kernel

Add volume assertion parsing and export validation

Yuechen Li3fa90731cdbc
diff --git a/Aetheris.CLI/CliRunner.cs b/Aetheris.CLI/CliRunner.cs
index 04dbb55c..cc1d1922 100644
--- a/Aetheris.CLI/CliRunner.cs
+++ b/Aetheris.CLI/CliRunner.cs
@@ -392,6 +392,7 @@ public static class CliRunner
hollow = build.Value.Export.Hollow,
lattice = build.Value.Export.Lattice,
combined = build.Value.Export.Combined,
+ assertions = build.Value.Export.Assertions,
features = build.Value.Export.Features,
inlineStepMigration = build.Value.Export.InlineStepMigration,
inlineStepReplacementAssist = build.Value.Export.InlineStepReplacementAssist,
diff --git a/Aetheris.Kernel.Firmament.Tests/FirmamentV2VolumeAssertionTests.cs b/Aetheris.Kernel.Firmament.Tests/FirmamentV2VolumeAssertionTests.cs
new file mode 100644
index 00000000..d050e488
--- /dev/null
+++ b/Aetheris.Kernel.Firmament.Tests/FirmamentV2VolumeAssertionTests.cs
@@ -0,0 +1,112 @@
+using Aetheris.Kernel.Firmament.FirmamentV2;
+using Aetheris.Kernel.Firmament;
+
+namespace Aetheris.Kernel.Firmament.Tests;
+
+public sealed class FirmamentV2VolumeAssertionTests
+{
+ [Fact]
+ public void ParsesLiteralVolumeAssertionAndBindsMaterialBody()
+ {
+ const string source = """
+ Model AssertBox {
+ Units: mm
+ Box Body { Size: [10mm, 8mm, 6mm] }
+ Assert Volume Body {
+ Expected: 480mm^3
+ Tolerance: 0mm^3
+ Note: "box"
+ }
+ }
+ """;
+ var parsed = FirmamentV2Parser.Parse(source);
+
+ Assert.True(parsed.IsSuccess, string.Join(Environment.NewLine, parsed.Diagnostics));
+ var assertion = Assert.Single(parsed.Document!.VolumeAssertions!);
+ Assert.Equal("Body", assertion.TargetBodyId);
+ Assert.Equal(480d, assertion.ExpectedMm3);
+ Assert.Equal(0d, assertion.ToleranceMm3);
+ Assert.Equal("box", assertion.Note);
+ Assert.Contains(parsed.Document.SymbolTable!.Bindings, binding => binding.Relation == "Target" && binding.TargetCanonicalId == "Body:Body");
+ }
+
+ [Theory]
+ [InlineData("10mm", FirmamentV2Parser.AssertVolumeExpectedDimensionMismatch)]
+ [InlineData("10mm^2", FirmamentV2Parser.AssertVolumeExpectedDimensionMismatch)]
+ public void RejectsNonVolumeExpectedValue(string expected, string diagnostic)
+ {
+ var parsed = FirmamentV2Parser.Parse(Source(expected, "0mm^3"));
+ Assert.False(parsed.IsSuccess);
+ Assert.Contains(parsed.Diagnostics, item => item.StartsWith(diagnostic, StringComparison.Ordinal));
+ }
+
+ [Fact]
+ public void RejectsNegativeToleranceAndUnknownBody()
+ {
+ var negative = FirmamentV2Parser.Parse(Source("480mm^3", "-1mm^3"));
+ Assert.False(negative.IsSuccess);
+ Assert.Contains(negative.Diagnostics, item => item.StartsWith(FirmamentV2Parser.AssertVolumeToleranceNegative, StringComparison.Ordinal));
+
+ var unknown = FirmamentV2Parser.Parse(Source("480mm^3", "0mm^3").Replace("Assert Volume Body", "Assert Volume Missing", StringComparison.Ordinal));
+ Assert.False(unknown.IsSuccess);
+ Assert.Contains(unknown.Diagnostics, item => item.StartsWith("firmament-v2-assert-volume-target-unknown:Missing", StringComparison.Ordinal));
+ }
+
+ [Fact]
+ public void BuildEvaluatesDeclaredAssertionWithoutChangingStep()
+ {
+ var directory = Path.Combine(Path.GetTempPath(), "aetheris-assert-volume-" + Guid.NewGuid().ToString("N"));
+ Directory.CreateDirectory(directory);
+ try
+ {
+ var withAssertion = Path.Combine(directory, "with.firmament");
+ var withoutAssertion = Path.Combine(directory, "without.firmament");
+ File.WriteAllText(withAssertion, Source("480mm^3", "0mm^3"));
+ File.WriteAllText(withoutAssertion, Source("480mm^3", "0mm^3").Replace(" Assert Volume Body {\n Expected: 480mm^3\n Tolerance: 0mm^3\n Note: \"box\"\n }\n", string.Empty, StringComparison.Ordinal));
+ var asserted = FirmamentBuildAndExport.Run(withAssertion, Path.Combine(directory, "with.step"));
+ var plain = FirmamentBuildAndExport.Run(withoutAssertion, Path.Combine(directory, "without.step"));
+ Assert.True(asserted.IsSuccess, string.Join(Environment.NewLine, asserted.Diagnostics.Select(diagnostic => diagnostic.Message)));
+ Assert.True(plain.IsSuccess, string.Join(Environment.NewLine, plain.Diagnostics.Select(diagnostic => diagnostic.Message)));
+ var result = Assert.Single(asserted.Value.Export.Assertions!);
+ Assert.True(result.Passed, result.Diagnostic);
+ Assert.Equal(File.ReadAllText(plain.Value.OutputPath), File.ReadAllText(asserted.Value.OutputPath));
+ }
+ finally
+ {
+ if (Directory.Exists(directory)) Directory.Delete(directory, recursive: true);
+ }
+ }
+
+ [Fact]
+ public void BuildReportsExpectedMeasuredDeltaAndToleranceForMismatch()
+ {
+ var path = Path.Combine(Path.GetTempPath(), "aetheris-assert-volume-" + Guid.NewGuid().ToString("N") + ".firmament");
+ try
+ {
+ File.WriteAllText(path, Source("479mm^3", "0mm^3"));
+ var build = FirmamentBuildAndExport.Run(path, Path.ChangeExtension(path, ".step"));
+ Assert.False(build.IsSuccess);
+ var diagnostic = Assert.Single(build.Diagnostics).Message;
+ Assert.StartsWith("firmament-v2-assert-volume-failed:", diagnostic, StringComparison.Ordinal);
+ Assert.Contains("expectedMm3=479", diagnostic, StringComparison.Ordinal);
+ Assert.Contains("measuredMm3=480", diagnostic, StringComparison.Ordinal);
+ Assert.Contains("toleranceMm3=0", diagnostic, StringComparison.Ordinal);
+ }
+ finally
+ {
+ if (File.Exists(path)) File.Delete(path);
+ }
+ }
+
+ private static string Source(string expected, string tolerance) => $$"""
+ Model AssertBox {
+ Units: mm
+ Box Body { Size: [10mm, 8mm, 6mm] }
+ Assert Volume Body {
+ Expected: {{expected}}
+ Tolerance: {{tolerance}}
+ Note: "box"
+ }
+ }
+ """;
+}
diff --git a/Aetheris.Kernel.Firmament/FirmamentBuildAndExport.cs b/Aetheris.Kernel.Firmament/FirmamentBuildAndExport.cs
index 3be472c4..7a70e7a3 100644
--- a/Aetheris.Kernel.Firmament/FirmamentBuildAndExport.cs
+++ b/Aetheris.Kernel.Firmament/FirmamentBuildAndExport.cs
@@ -42,18 +42,45 @@ public static class FirmamentBuildAndExport
return KernelResult<FirmamentBuildAndExportResult>.Failure(exportResult.Diagnostics);
}
+ var assertions = EvaluateVolumeAssertions(sourceText, Path.GetDirectoryName(fullSourcePath), exportResult.Value);
+ if (!assertions.IsSuccess)
+ {
+ return KernelResult<FirmamentBuildAndExportResult>.Failure(assertions.Diagnostics);
+ }
+ var export = exportResult.Value with { Assertions = assertions.Value };
var resolvedOutputPath = string.IsNullOrWhiteSpace(outputPath)
? ResolveDefaultOutputPath(fullSourcePath)
: Path.GetFullPath(outputPath);
Directory.CreateDirectory(Path.GetDirectoryName(resolvedOutputPath)!);
- File.WriteAllText(resolvedOutputPath, exportResult.Value.StepText, new UTF8Encoding(false));
+ File.WriteAllText(resolvedOutputPath, export.StepText, new UTF8Encoding(false));
return KernelResult<FirmamentBuildAndExportResult>.Success(
new FirmamentBuildAndExportResult(
fullSourcePath,
resolvedOutputPath,
- exportResult.Value));
+ export));
+ }
+
+ private static KernelResult<IReadOnlyList<FirmamentV2VolumeAssertionResult>> EvaluateVolumeAssertions(string source, string? sourceDirectory, FirmamentStepExportResult export)
+ {
+ var parsed = FirmamentV2Parser.Parse(source, sourceDirectory);
+ if (!parsed.IsSuccess || parsed.Document?.VolumeAssertions is not { Count: > 0 } assertions) return KernelResult<IReadOnlyList<FirmamentV2VolumeAssertionResult>>.Success([]);
+ var imported = Step242Importer.ImportBody(export.StepText);
+ if (!imported.IsSuccess || imported.Value is null)
+ {
+ return KernelResult<IReadOnlyList<FirmamentV2VolumeAssertionResult>>.Failure([new Kernel.Core.Diagnostics.KernelDiagnostic(
+ Kernel.Core.Diagnostics.KernelDiagnosticCode.ValidationFailed, Kernel.Core.Diagnostics.KernelDiagnosticSeverity.Error,
+ "firmament-v2-assert-volume-measurement-unavailable: STEP reimport failed", "FirmamentV2.AssertVolume")]);
+ }
+ var mass = BrepMassProperties.Evaluate(imported.Value);
+ var results = assertions.Select(assertion => FirmamentV2VolumeAssertionComparer.Compare(assertion, mass)).ToArray();
+ var failures = results.Where(result => !result.Passed).Select(result => new Kernel.Core.Diagnostics.KernelDiagnostic(
+ Kernel.Core.Diagnostics.KernelDiagnosticCode.ValidationFailed, Kernel.Core.Diagnostics.KernelDiagnosticSeverity.Error,
+ result.Diagnostic ?? "firmament-v2-assert-volume-failed", "FirmamentV2.AssertVolume")).ToArray();
+ return failures.Length == 0
+ ? KernelResult<IReadOnlyList<FirmamentV2VolumeAssertionResult>>.Success(results)
+ : KernelResult<IReadOnlyList<FirmamentV2VolumeAssertionResult>>.Failure(failures);
}
diff --git a/Aetheris.Kernel.Firmament/FirmamentStepExportResult.cs b/Aetheris.Kernel.Firmament/FirmamentStepExportResult.cs
index f75e6d7e..907e7669 100644
--- a/Aetheris.Kernel.Firmament/FirmamentStepExportResult.cs
+++ b/Aetheris.Kernel.Firmament/FirmamentStepExportResult.cs
@@ -18,7 +18,8 @@ public sealed record FirmamentStepExportResult(
FirmamentRoundedBoxReport? RoundedBox = null,
FirmamentHollowBodyReport? Hollow = null,
FirmamentStandaloneLatticeReport? Lattice = null,
- FirmamentCombinedFeaturePlanReport? Combined = null);
+ FirmamentCombinedFeaturePlanReport? Combined = null,
+ IReadOnlyList<Aetheris.Kernel.Firmament.FirmamentV2.FirmamentV2VolumeAssertionResult>? Assertions = null);
/// <summary>Compact inspection evidence for the bounded X1 composed feature route.</summary>
public sealed record FirmamentCombinedFeaturePlanReport(
diff --git a/Aetheris.Kernel.Firmament/FirmamentV2/CanonicalSymbolTable.cs b/Aetheris.Kernel.Firmament/FirmamentV2/CanonicalSymbolTable.cs
index fca72d26..44537567 100644
--- a/Aetheris.Kernel.Firmament/FirmamentV2/CanonicalSymbolTable.cs
+++ b/Aetheris.Kernel.Firmament/FirmamentV2/CanonicalSymbolTable.cs
@@ -16,7 +16,8 @@ public enum FirmamentV2CanonicalSymbolKind
Compose,
Hole,
Slot,
- Selection
+ Selection,
+ Body
}
public sealed record FirmamentV2CanonicalSymbol(
@@ -60,6 +61,9 @@ internal static class FirmamentV2CanonicalSymbolBinder
{
if (byName.TryGetValue(name, out var previous))
{
+ if (kind == FirmamentV2CanonicalSymbolKind.Body
+ && previous.Kind is FirmamentV2CanonicalSymbolKind.Profile or FirmamentV2CanonicalSymbolKind.Compose)
+ return;
diagnostics.Add($"{Duplicate}:{name}:{previous.Kind}:{kind}");
return;
}
@@ -79,6 +83,9 @@ internal static class FirmamentV2CanonicalSymbolBinder
foreach (var profile in document.Profiles ?? []) Add(profile.Name, FirmamentV2CanonicalSymbolKind.Profile, profile.SourceSpan);
foreach (var compose in document.Composes ?? []) Add(compose.Name, FirmamentV2CanonicalSymbolKind.Compose, compose.SourceSpan);
+ var profileOrComposeNames = (document.Profiles ?? []).Select(profile => profile.Name).Concat((document.Composes ?? []).Select(compose => compose.Name)).ToHashSet(StringComparer.Ordinal);
+ foreach (var solid in document.Solids.Where(solid => !profileOrComposeNames.Contains(solid.Name))) Add(solid.Name, FirmamentV2CanonicalSymbolKind.Body, new(0, 0));
+ foreach (Match body in Regex.Matches(source, @"(?<!Concept\s)\bStruct\s+(?<name>[A-Za-z_]\w*)\s*\{", RegexOptions.CultureInvariant)) Add(body.Groups["name"].Value, FirmamentV2CanonicalSymbolKind.Body, new(body.Index, body.Length));
foreach (Match feature in Regex.Matches(source, @"\b(?<kind>Hole|Slot)\s*<[^>]+>\s+(?<name>[A-Za-z_]\w*)\s*\{", RegexOptions.CultureInvariant))
{
Add(feature.Groups["name"].Value,
@@ -102,6 +109,12 @@ internal static class FirmamentV2CanonicalSymbolBinder
}
bindings.Add(new($"{FirmamentV2CanonicalSymbolKind.Selection}:{selection.Name}", "Source", target.CanonicalId, selection.SourceSpan));
}
+ foreach (var assertion in document.VolumeAssertions ?? [])
+ {
+ if (!byName.TryGetValue(assertion.TargetBodyId, out var target)) diagnostics.Add($"firmament-v2-assert-volume-target-unknown:{assertion.TargetBodyId}");
+ else if (target.Kind is not (FirmamentV2CanonicalSymbolKind.Body or FirmamentV2CanonicalSymbolKind.Compose)) diagnostics.Add($"firmament-v2-assert-volume-target-not-material-body:{assertion.TargetBodyId}:{target.Kind}");
+ else bindings.Add(new($"AssertVolume:{assertion.Id}", "Target", target.CanonicalId, assertion.SourceSpan));
+ }
return new(new(symbols, bindings), diagnostics.Distinct(StringComparer.Ordinal).Order(StringComparer.Ordinal).ToArray());
}
diff --git a/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2Ast.cs b/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2Ast.cs
index 703380b9..d2af06d1 100644
--- a/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2Ast.cs
+++ b/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2Ast.cs
@@ -2,7 +2,7 @@ using Aetheris.Kernel.Firmament.Materializer;
namespace Aetheris.Kernel.Firmament.FirmamentV2;
-public sealed record FirmamentV2Document(string ModelName, string Units, IReadOnlyList<FirmamentV2SolidBinding> Solids, IReadOnlyList<FirmamentV2ModifyBlock>? ModifyBlocks = null, IReadOnlyList<FirmamentV2TemplateDecl>? Templates = null, IReadOnlyList<FirmamentV2PmiDecl>? Pmi = null, IReadOnlyList<FirmamentV2RecognizedRegion>? RecognizedRegions = null, IReadOnlyList<FirmamentV2ReplacementDecl>? Replacements = null, IReadOnlyList<FirmamentV2LetDeclaration>? Lets = null, IReadOnlyList<FirmamentV2BoundLet>? BoundLets = null, IReadOnlyList<FirmamentV2LetRecordDeclaration>? LetRecords = null, IReadOnlyList<FirmamentV2BoundLetRecord>? BoundLetRecords = null, IReadOnlyList<FirmamentV2ManufacturingConceptDeclaration>? ManufacturingConcepts = null, IReadOnlyList<FirmamentV2FeatureConceptDeclaration>? FeatureConcepts = null, FirmamentV2PmiBlock? PmiBlock = null, FirmamentV2BoundPmiBlock? BoundPmi = null, ConceptIrDocument? ConceptIr = null, IReadOnlyList<FirmamentV2LatticeFillDecl>? LatticeFills = null, IReadOnlyList<FirmamentV2StandaloneLatticeFillDecl>? StandaloneLatticeFills = null, IReadOnlyList<FirmamentV2ProfileDecl>? Profiles = null, IReadOnlyList<FirmamentV2ComposeDecl>? Composes = null, IReadOnlyList<FirmamentV2SelectionDecl>? Selections = null, FirmamentV2StaticAuthoringDocument? StaticAuthoring = null, FirmamentV2CanonicalSymbolTable? SymbolTable = null)
+public sealed record FirmamentV2Document(string ModelName, string Units, IReadOnlyList<FirmamentV2SolidBinding> Solids, IReadOnlyList<FirmamentV2ModifyBlock>? ModifyBlocks = null, IReadOnlyList<FirmamentV2TemplateDecl>? Templates = null, IReadOnlyList<FirmamentV2PmiDecl>? Pmi = null, IReadOnlyList<FirmamentV2RecognizedRegion>? RecognizedRegions = null, IReadOnlyList<FirmamentV2ReplacementDecl>? Replacements = null, IReadOnlyList<FirmamentV2LetDeclaration>? Lets = null, IReadOnlyList<FirmamentV2BoundLet>? BoundLets = null, IReadOnlyList<FirmamentV2LetRecordDeclaration>? LetRecords = null, IReadOnlyList<FirmamentV2BoundLetRecord>? BoundLetRecords = null, IReadOnlyList<FirmamentV2ManufacturingConceptDeclaration>? ManufacturingConcepts = null, IReadOnlyList<FirmamentV2FeatureConceptDeclaration>? FeatureConcepts = null, FirmamentV2PmiBlock? PmiBlock = null, FirmamentV2BoundPmiBlock? BoundPmi = null, ConceptIrDocument? ConceptIr = null, IReadOnlyList<FirmamentV2LatticeFillDecl>? LatticeFills = null, IReadOnlyList<FirmamentV2StandaloneLatticeFillDecl>? StandaloneLatticeFills = null, IReadOnlyList<FirmamentV2ProfileDecl>? Profiles = null, IReadOnlyList<FirmamentV2ComposeDecl>? Composes = null, IReadOnlyList<FirmamentV2SelectionDecl>? Selections = null, FirmamentV2StaticAuthoringDocument? StaticAuthoring = null, FirmamentV2CanonicalSymbolTable? SymbolTable = null, IReadOnlyList<FirmamentV2VolumeAssertion>? VolumeAssertions = null)
{
public FirmamentV2SolidBinding Solid => Solids[^1];
public FirmamentV2SideHoleIntent? SideHoleIntent => ModifyBlocks?.SelectMany(m => m.Regions.Select(r =>
diff --git a/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2Parser.cs b/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2Parser.cs
index d5e89a9a..104b3025 100644
--- a/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2Parser.cs
+++ b/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2Parser.cs
@@ -69,6 +69,11 @@ public static class FirmamentV2Parser
public const string CanonicalModifyMalformed = "firmament-v2-canonical-modify-malformed";
public const string CanonicalDeclarationUnrecognized = "firmament-v2-canonical-declaration-unrecognized";
public const string CanonicalDeclarationUnknown = "firmament-v2-canonical-declaration-unknown";
+ public const string AssertVolumeMalformed = "firmament-v2-assert-volume-malformed";
+ public const string AssertVolumeKindUnsupported = "firmament-v2-assert-kind-unsupported";
+ public const string AssertVolumeExpectedDimensionMismatch = "firmament-v2-assert-volume-expected-dimension-mismatch";
+ public const string AssertVolumeToleranceDimensionMismatch = "firmament-v2-assert-volume-tolerance-dimension-mismatch";
+ public const string AssertVolumeToleranceNegative = "firmament-v2-assert-volume-tolerance-negative";
public const string CanonicalConstructNotYetSupported = "firmament-v2-canonical-construct-not-yet-supported";
public const string EdgeFinishProfileComposeBoundaryUnsupported = "EdgeFinishProfileComposeBoundaryUnsupported";
public const string CanonicalFieldUnknown = "firmament-v2-canonical-field-unknown";
@@ -329,20 +334,7 @@ public static class FirmamentV2Parser
: ParseCanonicalDocument(source, diagnostics, sourceDirectory));
if (parsed.Document is null) return parsed;
- var normalized = parsed.Document with { StaticAuthoring = canonicalStaticExpansion.Document };
- var symbolBinding = FirmamentV2CanonicalSymbolBinder.Bind(normalized, source);
- if (symbolBinding.Diagnostics.Count > 0)
- {
- return FirmamentV2ParseResult.Failure(
- parsed.Diagnostics.Concat(symbolBinding.Diagnostics).Distinct(StringComparer.Ordinal).Order().ToArray(),
- FirmamentV2ParseDisposition.RecognizedInvalid);
- }
-
- return parsed with
- {
- Document = normalized with { SymbolTable = symbolBinding.Table },
- Diagnostics = parsed.Diagnostics.Append("firmament-v2-unified-canonical-symbols-bound").Distinct(StringComparer.Ordinal).Order().ToArray()
- };
+ return AttachVolumeAssertionsAndSymbols(parsed, source, canonicalStaticExpansion.Document, diagnostics);
}
if (Regex.IsMatch(source, @"\b(?:RoundedBox|Frustum|Box)\s*<\s*[A-Za-z_][A-Za-z0-9_]*\s*>\s+[A-Za-z_]", RegexOptions.CultureInvariant))
@@ -353,7 +345,7 @@ public static class FirmamentV2Parser
if (Regex.IsMatch(source, @"\bConcept\s+(?:Struct\s+)?[A-Za-z_]", RegexOptions.CultureInvariant)
|| Regex.IsMatch(source, @"\b(?:Struct|Model)\s+[A-Za-z_][A-Za-z0-9_]*\s*(?::\s*[A-Za-z_][A-Za-z0-9_]*)?\s*\{", RegexOptions.CultureInvariant))
- return Recognized(ParseConceptModelingDocument(source, diagnostics, templateExpansion.Instantiations));
+ return Recognized(AttachVolumeAssertionsAndSymbols(ParseConceptModelingDocument(RemoveCanonicalVolumeAssertions(source), diagnostics, templateExpansion.Instantiations), source, canonicalStaticExpansion.Document, diagnostics));
if (Regex.IsMatch(source, @"^\s*Model\b", RegexOptions.CultureInvariant))
return Recognized(ParsePhase3ModelingDocument(source, diagnostics));
@@ -885,7 +877,7 @@ public static class FirmamentV2Parser
var known = new HashSet<string>(StringComparer.Ordinal)
{
"Box", "Cylinder", "RoundedBox", "Frustum", "Concept", "Struct", "Construction", "Profile", "Compose", "EdgeFinish",
- "Record", "Static", "Template", "Selection", "InlineStep", "Recognize", "Replace", "Pmi", "Modify", "Match", "Require"
+ "Record", "Static", "Template", "Selection", "InlineStep", "Recognize", "Replace", "Pmi", "Modify", "Match", "Require", "Assert"
};
var compatibilityOnly = new HashSet<string>(StringComparer.Ordinal)
{
@@ -1091,6 +1083,97 @@ public static class FirmamentV2Parser
return selections;
}
+ private static IReadOnlyList<FirmamentV2VolumeAssertion> ParseCanonicalVolumeAssertions(string source, List<string> diagnostics)
+ {
+ var assertions = new List<FirmamentV2VolumeAssertion>();
+ foreach (Match header in Regex.Matches(source, @"\bAssert\s+(?<kind>[A-Za-z_]\w*)\s+(?<target>[A-Za-z_]\w*)\s*\{", RegexOptions.CultureInvariant))
+ {
+ var kind = header.Groups["kind"].Value;
+ var target = header.Groups["target"].Value;
+ var open = source.IndexOf('{', header.Index);
+ var close = FindMatchingBrace(source, open);
+ if (close < 0) { diagnostics.Add($"{AssertVolumeMalformed}:{target}"); continue; }
+ if (!string.Equals(kind, "Volume", StringComparison.Ordinal)) { diagnostics.Add($"{AssertVolumeKindUnsupported}:{kind}:{target}"); continue; }
+
+ var fields = new Dictionary<string, string>(StringComparer.Ordinal);
+ foreach (Match field in Regex.Matches(source[(open + 1)..close], @"(?m)^\s*(?<name>[A-Za-z_]\w*)\s*:\s*(?<value>[^\r\n]+?)\s*$", RegexOptions.CultureInvariant))
+ {
+ var name = field.Groups["name"].Value;
+ if (!fields.TryAdd(name, field.Groups["value"].Value.Trim())) diagnostics.Add($"{AssertVolumeMalformed}:{target}:duplicate-{name}");
+ }
+ if (fields.Keys.Any(name => name is not "Expected" and not "Tolerance" and not "Note") || !fields.TryGetValue("Expected", out var expectedRaw) || !fields.TryGetValue("Tolerance", out var toleranceRaw))
+ {
+ diagnostics.Add($"{AssertVolumeMalformed}:{target}");
+ continue;
+ }
+ if (!TryParseCubicMillimeters(expectedRaw, out var expected))
+ {
+ diagnostics.Add($"{AssertVolumeExpectedDimensionMismatch}:{target}:Volume:{DimensionName(expectedRaw)}");
+ continue;
+ }
+ if (!TryParseCubicMillimeters(toleranceRaw, out var tolerance))
+ {
+ diagnostics.Add($"{AssertVolumeToleranceDimensionMismatch}:{target}:Volume:{DimensionName(toleranceRaw)}");
+ continue;
+ }
+ if (tolerance < 0d) { diagnostics.Add($"{AssertVolumeToleranceNegative}:{target}"); continue; }
+ if (!double.IsFinite(expected) || !double.IsFinite(tolerance)) { diagnostics.Add($"{AssertVolumeMalformed}:{target}:non-finite"); continue; }
+ string? note = null;
+ if (fields.TryGetValue("Note", out var noteRaw))
+ {
+ if (noteRaw.Length < 2 || noteRaw[0] != '"' || noteRaw[^1] != '"') { diagnostics.Add($"{AssertVolumeMalformed}:{target}:Note"); continue; }
+ note = noteRaw[1..^1];
+ }
+ var span = new FirmamentV2SourceSpan(header.Index, close - header.Index + 1);
+ assertions.Add(new($"volume:{target}:{header.Index}", target, expected, tolerance, note, span));
+ }
+ return assertions;
+ }
+
+ private static string RemoveCanonicalVolumeAssertions(string source)
+ {
+ var removals = Regex.Matches(source, @"\bAssert\s+[A-Za-z_]\w*\s+[A-Za-z_]\w*\s*\{", RegexOptions.CultureInvariant)
+ .Cast<Match>()
+ .Select(header => new { header.Index, Close = FindMatchingBrace(source, source.IndexOf('{', header.Index)) })
+ .Where(match => match.Close >= 0)
+ .OrderByDescending(match => match.Index)
+ .ToArray();
+ foreach (var removal in removals) source = source.Remove(removal.Index, removal.Close - removal.Index + 1);
+ return source;
+ }
+
+ private static FirmamentV2ParseResult AttachVolumeAssertionsAndSymbols(FirmamentV2ParseResult parsed, string source, FirmamentV2StaticAuthoringDocument? staticAuthoring, List<string> diagnostics)
+ {
+ if (parsed.Document is null) return parsed;
+ var normalized = parsed.Document with { StaticAuthoring = staticAuthoring, VolumeAssertions = ParseCanonicalVolumeAssertions(source, diagnostics) };
+ if (diagnostics.Any(IsFatalDiagnosticCode))
+ return FirmamentV2ParseResult.Failure(parsed.Diagnostics.Concat(diagnostics).Distinct(StringComparer.Ordinal).Order().ToArray(), FirmamentV2ParseDisposition.RecognizedInvalid);
+ var symbolBinding = FirmamentV2CanonicalSymbolBinder.Bind(normalized, source);
+ if (symbolBinding.Diagnostics.Count > 0)
+ return FirmamentV2ParseResult.Failure(parsed.Diagnostics.Concat(symbolBinding.Diagnostics).Distinct(StringComparer.Ordinal).Order().ToArray(), FirmamentV2ParseDisposition.RecognizedInvalid);
+ return parsed with
+ {
+ Document = normalized with { SymbolTable = symbolBinding.Table },
+ Diagnostics = parsed.Diagnostics.Append("firmament-v2-unified-canonical-symbols-bound").Distinct(StringComparer.Ordinal).Order().ToArray()
+ };
+ }
+
+ private static bool TryParseCubicMillimeters(string raw, out double value)
+ {
+ value = double.NaN;
+ var match = Regex.Match(raw, @"^(?<value>[-+0-9.eE]+)mm\^3$", RegexOptions.CultureInvariant);
+ return match.Success && double.TryParse(match.Groups["value"].Value, NumberStyles.Float, CultureInfo.InvariantCulture, out value);
+ }
+
+ private static string DimensionName(string raw)
+ {
+ if (raw.EndsWith("mm^3", StringComparison.Ordinal)) return "InvalidVolume";
+ if (raw.EndsWith("mm^2", StringComparison.Ordinal)) return "Area";
+ if (raw.EndsWith("mm", StringComparison.Ordinal)) return "Length";
+ if (raw.EndsWith("deg", StringComparison.Ordinal)) return "Angle";
+ return "ScalarOrUnsupported";
+ }
+
private static void ValidateCanonicalSelectionSources(
string body,
IReadOnlyList<FirmamentV2SelectionDecl> selections,
@@ -1727,7 +1810,7 @@ public static class FirmamentV2Parser
|| code.StartsWith(ConceptIrResolver.PointProjectionUnsupported, StringComparison.Ordinal)
|| code.StartsWith("firmament-static-", StringComparison.Ordinal);
- public static bool IsFatalDiagnosticCode(string code) => code.StartsWith(CanonicalDeclarationUnknown + ":", StringComparison.Ordinal) || code.StartsWith(CanonicalConstructNotYetSupported + ":", StringComparison.Ordinal) || code.StartsWith(EdgeFinishProfileComposeBoundaryUnsupported, StringComparison.Ordinal) || IsConceptFatalDiagnostic(code) || code is UnknownConstructionPolicy or PrimitiveDoesNotSatisfyHollowConstructible or WallThicknessRequired or WallThicknessMustBePositive or UnsupportedOpening or MultipleOpeningsNotSupported or Phase3EdgeFinishSyntaxInvalid or PrimitiveFieldMissing or PrimitiveFieldUnknown or PrimitiveFieldInvalid or MissingModel or MissingUnits or MissingSolid or UnsupportedConstruct or UnknownRecordType or BoxMissingSize or BoxSizeArity or DegenerateDimension or NameUnresolved or DuplicateName or WithRequiresRecord or WithRequiresBoxRecord or WithFieldNotFound or WithFieldTypeMismatch or WithForwardReference or WithDerivedRecordInvalid or ExposeBlockUnsupported or ExposeRequiresBoxRecord or ExposeAliasDuplicate or ExposeAliasInvalid or SelectorUnsupported or SelectorAxisInvalid or SelectorSubselectorUnsupported or FatArrowOutsideExpose or RawBackendIdReferenceForbidden or ModifyTargetUnresolved or ModifyTargetNotSolid or RegionUnsupported or RegionAttachmentSelectorUnsupported or CutUnsupported or CutToolUnsupported or CylinderRadiusMissing or CylinderRadiusInvalid or CylinderRadiusNotFinite or ThroughSelectorUnsupported or AliasUnresolved or AliasRefTypeUnsupported or SideHoleAliasMustResolveToFace or SideHoleAliasResolvesToUnsupportedFace or SideHoleOnlyPlusXMinusXSupported or SideHoleRouteUnsupported or SideHoleSameFaceUnsupported or SideHoleAxisNotYetSupported or SideHoleRadiusExceedsClearance or CylinderCenterInvalid or CylinderCenterArityInvalid or CylinderCenterNotFinite or SideHoleCenterExceedsClearance or HoleVariantUnknown or HoleEntryFaceMissing or HoleCenterMissing or HoleShaftMissing or HoleEndMissing or HoleDiameterInvalid or HoleDepthInvalid or HoleCounterboreInvalid or HoleCountersinkInvalid or PmiKindUnknown or PmiTargetMissing or PmiTargetUnresolved or PmiDiameterInvalid or PmiDuplicateName or InlineStepUnknownBody or InlineStepUnknownFace or PmiImportedTargetNotFace or PmiImportedTargetRequiresCanonicalStep or PmiInvalidImportedTarget or InlineStepPathMissing or InlineStepPathInvalid or InlineStepFileMissing or InlineStepRequiresCanonical or UnknownRecognitionBody or UnknownRecognitionFace or DuplicateRegion or UnknownRecognitionRegion or InvalidRecognitionKind or InvalidRecognitionConfidence or PmiRecognizedRegionKindMismatch or UnknownReplacementBody or UnknownReplacementRegion or ReplacementKindMismatch or ReplacementFaceUnresolved or ReplacementUnsupportedKind or ReplacementVerificationFailed or ReplacementRadiusInvalid or ReplacementEndUnsupported or LetDuplicateName or LetUnknownType or LetMismatch or LetInvalidLiteral or LetUnitMismatch or LetLiteralOnly or LetRecordDuplicateName or LetRecordDuplicateField or LetReferenceUnknownRecord or LetReferenceUnknownField or LetReferenceNonRecord or LetReferenceRecordUsedAsValue or ExpressionUnknownSymbol or ExpressionUnknownRecord or ExpressionUnknownField or ExpressionRecordUsedAsValue or ExpressionScalarUsedAsRecord or ExpressionTypeMismatch or ExpressionInvalidOperator or ExpressionDivisionByZero or ExpressionCycle or ExpressionUnsupported or ToleranceInvalidType or ToleranceUnitMismatch or ToleranceInvalidLiteral or ToleranceNegativeBilateral or ToleranceMissingMinus or ToleranceMissingPlus or ToleranceUnsupported or RecognitionEvidenceRadiusInvalid or RecognitionEvidenceSurfaceFamilyUnknown or RecognitionEvidenceAxisInvalid or SemanticProposalKindMismatch or SemanticProposalRadiusInvalid or SemanticProposalTargetUnresolved or SemanticProposalEndUnsupported or ConceptUnknownFamily or ConceptUnknownConcept or ConceptMissingRequiredField or ConceptUnknownField or ConceptDuplicateField or ConceptFieldTypeMismatch or ConceptInvalidTarget or ConceptDescriptorUnavailable or PmiDuplicateBlock or PmiDuplicateRecord or PmiDuplicateDatum or PmiUnknownRecordKind or PmiMissingRequiredField or PmiUnknownField or PmiDuplicateField or PmiInvalidTarget or PmiUnknownDatum or PmiDimensionTypeMismatch or PmiDimensionMissingTolerance or PmiToleranceTypeMismatch or StandaloneFillRegionRequired or UnsupportedStandaloneFillPattern or InvalidCellCount or CellSizeMustBePositive or StrutRadiusMustBePositive or NodeRadiusMustBePositive or MaterialBoundsMismatch or StandaloneFillMultipleUnsupported;
+public static bool IsFatalDiagnosticCode(string code) => code.StartsWith("firmament-v2-assert-volume-", StringComparison.Ordinal) || code.StartsWith(AssertVolumeKindUnsupported, StringComparison.Ordinal) || code.StartsWith(CanonicalDeclarationUnknown + ":", StringComparison.Ordinal) || code.StartsWith(CanonicalConstructNotYetSupported + ":", StringComparison.Ordinal) || code.StartsWith(EdgeFinishProfileComposeBoundaryUnsupported, StringComparison.Ordinal) || IsConceptFatalDiagnostic(code) || code is UnknownConstructionPolicy or PrimitiveDoesNotSatisfyHollowConstructible or WallThicknessRequired or WallThicknessMustBePositive or UnsupportedOpening or MultipleOpeningsNotSupported or Phase3EdgeFinishSyntaxInvalid or PrimitiveFieldMissing or PrimitiveFieldUnknown or PrimitiveFieldInvalid or MissingModel or MissingUnits or MissingSolid or UnsupportedConstruct or UnknownRecordType or BoxMissingSize or BoxSizeArity or DegenerateDimension or NameUnresolved or DuplicateName or WithRequiresRecord or WithRequiresBoxRecord or WithFieldNotFound or WithFieldTypeMismatch or WithForwardReference or WithDerivedRecordInvalid or ExposeBlockUnsupported or ExposeRequiresBoxRecord or ExposeAliasDuplicate or ExposeAliasInvalid or SelectorUnsupported or SelectorAxisInvalid or SelectorSubselectorUnsupported or FatArrowOutsideExpose or RawBackendIdReferenceForbidden or ModifyTargetUnresolved or ModifyTargetNotSolid or RegionUnsupported or RegionAttachmentSelectorUnsupported or CutUnsupported or CutToolUnsupported or CylinderRadiusMissing or CylinderRadiusInvalid or CylinderRadiusNotFinite or ThroughSelectorUnsupported or AliasUnresolved or AliasRefTypeUnsupported or SideHoleAliasMustResolveToFace or SideHoleAliasResolvesToUnsupportedFace or SideHoleOnlyPlusXMinusXSupported or SideHoleRouteUnsupported or SideHoleSameFaceUnsupported or SideHoleAxisNotYetSupported or SideHoleRadiusExceedsClearance or CylinderCenterInvalid or CylinderCenterArityInvalid or CylinderCenterNotFinite or SideHoleCenterExceedsClearance or HoleVariantUnknown or HoleEntryFaceMissing or HoleCenterMissing or HoleShaftMissing or HoleEndMissing or HoleDiameterInvalid or HoleDepthInvalid or HoleCounterboreInvalid or HoleCountersinkInvalid or PmiKindUnknown or PmiTargetMissing or PmiTargetUnresolved or PmiDiameterInvalid or PmiDuplicateName or InlineStepUnknownBody or InlineStepUnknownFace or PmiImportedTargetNotFace or PmiImportedTargetRequiresCanonicalStep or PmiInvalidImportedTarget or InlineStepPathMissing or InlineStepPathInvalid or InlineStepFileMissing or InlineStepRequiresCanonical or UnknownRecognitionBody or UnknownRecognitionFace or DuplicateRegion or UnknownRecognitionRegion or InvalidRecognitionKind or InvalidRecognitionConfidence or PmiRecognizedRegionKindMismatch or UnknownReplacementBody or UnknownReplacementRegion or ReplacementKindMismatch or ReplacementFaceUnresolved or ReplacementUnsupportedKind or ReplacementVerificationFailed or ReplacementRadiusInvalid or ReplacementEndUnsupported or LetDuplicateName or LetUnknownType or LetMismatch or LetInvalidLiteral or LetUnitMismatch or LetLiteralOnly or LetRecordDuplicateName or LetRecordDuplicateField or LetReferenceUnknownRecord or LetReferenceUnknownField or LetReferenceNonRecord or LetReferenceRecordUsedAsValue or ExpressionUnknownSymbol or ExpressionUnknownRecord or ExpressionUnknownField or ExpressionRecordUsedAsValue or ExpressionScalarUsedAsRecord or ExpressionTypeMismatch or ExpressionInvalidOperator or ExpressionDivisionByZero or ExpressionCycle or ExpressionUnsupported or ToleranceInvalidType or ToleranceUnitMismatch or ToleranceInvalidLiteral or ToleranceNegativeBilateral or ToleranceMissingMinus or ToleranceMissingPlus or ToleranceUnsupported or RecognitionEvidenceRadiusInvalid or RecognitionEvidenceSurfaceFamilyUnknown or RecognitionEvidenceAxisInvalid or SemanticProposalKindMismatch or SemanticProposalRadiusInvalid or SemanticProposalTargetUnresolved or SemanticProposalEndUnsupported or ConceptUnknownFamily or ConceptUnknownConcept or ConceptMissingRequiredField or ConceptUnknownField or ConceptDuplicateField or ConceptFieldTypeMismatch or ConceptInvalidTarget or ConceptDescriptorUnavailable or PmiDuplicateBlock or PmiDuplicateRecord or PmiDuplicateDatum or PmiUnknownRecordKind or PmiMissingRequiredField or PmiUnknownField or PmiDuplicateField or PmiInvalidTarget or PmiUnknownDatum or PmiDimensionTypeMismatch or PmiDimensionMissingTolerance or PmiToleranceTypeMismatch or StandaloneFillRegionRequired or UnsupportedStandaloneFillPattern or InvalidCellCount or CellSizeMustBePositive or StrutRadiusMustBePositive or NodeRadiusMustBePositive or MaterialBoundsMismatch or StandaloneFillMultipleUnsupported;
private static IReadOnlyList<FirmamentV2Exposure> ParseExposures(string body, List<string> diagnostics)
{
diff --git a/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2VolumeAssertions.cs b/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2VolumeAssertions.cs
new file mode 100644
index 00000000..93864f7d
--- /dev/null
+++ b/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2VolumeAssertions.cs
@@ -0,0 +1,51 @@
+using Aetheris.Kernel.Core.Brep.Verification;
+
+namespace Aetheris.Kernel.Firmament.FirmamentV2;
+
+/// <summary>Source-level verification contract. It is never geometry or PMI input.</summary>
+public sealed record FirmamentV2VolumeAssertion(
+ string Id,
+ string TargetBodyId,
+ double ExpectedMm3,
+ double ToleranceMm3,
+ string? Note,
+ FirmamentV2SourceSpan SourceSpan,
+ string Provenance = "FirmamentSource");
+
+public sealed record FirmamentV2VolumeAssertionResult(
+ string AssertionId,
+ string TargetBodyId,
+ double ExpectedMm3,
+ double? MeasuredMm3,
+ double? DeltaMm3,
+ double? AbsoluteDeltaMm3,
+ double ToleranceMm3,
+ bool Passed,
+ string? Note,
+ string MeasurementMethod,
+ double? MeasurementErrorBoundMm3,
+ string? Diagnostic,
+ FirmamentV2SourceSpan SourceSpan,
+ string Provenance);
+
+public static class FirmamentV2VolumeAssertionComparer
+{
+ public static FirmamentV2VolumeAssertionResult Compare(FirmamentV2VolumeAssertion assertion, BrepMassPropertiesResult mass)
+ {
+ ArgumentNullException.ThrowIfNull(assertion);
+ ArgumentNullException.ThrowIfNull(mass);
+ if (mass.Status == BrepMassPropertiesStatus.Unavailable)
+ {
+ return new(assertion.Id, assertion.TargetBodyId, assertion.ExpectedMm3, null, null, null, assertion.ToleranceMm3, false,
+ assertion.Note, mass.EvaluationMethod, mass.ErrorBound,
+ $"firmament-v2-assert-volume-measurement-unavailable:{assertion.TargetBodyId}:{assertion.Id}", assertion.SourceSpan, assertion.Provenance);
+ }
+
+ var delta = mass.AbsoluteVolume - assertion.ExpectedMm3;
+ var absoluteDelta = double.Abs(delta);
+ var passed = absoluteDelta <= assertion.ToleranceMm3;
+ var diagnostic = passed ? null : $"firmament-v2-assert-volume-failed:target={assertion.TargetBodyId}:expectedMm3={assertion.ExpectedMm3:G17}:measuredMm3={mass.AbsoluteVolume:G17}:deltaMm3={delta:G17}:toleranceMm3={assertion.ToleranceMm3:G17}:method={mass.EvaluationMethod}:errorBoundMm3={mass.ErrorBound?.ToString("G17", System.Globalization.CultureInfo.InvariantCulture) ?? "unavailable"}";
+ return new(assertion.Id, assertion.TargetBodyId, assertion.ExpectedMm3, mass.AbsoluteVolume, delta, absoluteDelta, assertion.ToleranceMm3,
+ passed, assertion.Note, mass.EvaluationMethod, mass.ErrorBound, diagnostic, assertion.SourceSpan, assertion.Provenance);
+ }
+}
diff --git a/docs/firmament/assert-volume-comptime-csharp-m1.md b/docs/firmament/assert-volume-comptime-csharp-m1.md
new file mode 100644
index 00000000..18bb0a7e
--- /dev/null
+++ b/docs/firmament/assert-volume-comptime-csharp-m1.md
@@ -0,0 +1,7 @@
+# Assert Volume M1 scope update
+
+The earlier compile-time-C# proposal is deferred: this checkout has no bounded
+embedded-C# host, and the trusted Forge DLL loader is intentionally unsuitable
+for source execution. M1 therefore uses literal, typed volume values only.
+
+See [Assert Volume M1](assert-volume-m1.md) for the implemented contract.
diff --git a/docs/firmament/assert-volume-m1.md b/docs/firmament/assert-volume-m1.md
new file mode 100644
index 00000000..a5699966
--- /dev/null
+++ b/docs/firmament/assert-volume-m1.md
@@ -0,0 +1,35 @@
+# Assert Volume M1
+
+`Assert Volume` is a source-level verification contract, not geometry, PMI, or
+a calculator language.
+
+```firmament
+Assert Volume Body {
+ Expected: 1587.982297150257mm^3
+ Tolerance: 5mm^3
+ Note: "Finite-span quarter-cylinder straight Profile edge fillet"
+}
+```
+
+`Expected` and `Tolerance` are required finite literal `mm^3` quantities;
+`Tolerance` is absolute and non-negative. `Note` is optional. The target must
+bind to one canonical material-body symbol. Lengths, areas, angles, scalars,
+unknown targets, duplicate/unknown fields, and malformed notes are rejected at
+parse/bind time.
+
+Builds materialize normally, reimport the just-produced STEP, and evaluate its
+body through `BrepMassProperties.Evaluate`. The shared
+`FirmamentV2VolumeAssertionComparer` records expected, measured, signed and
+absolute deltas, tolerance, note, source provenance, method, and error bound.
+It passes only when `abs(measured - expected) <= tolerance`; unavailable mass
+properties are a distinct failure. Failed assertions fail `build`; `validate`
+only performs source checks. `build --json` exposes successful records under
+`assertions`. Artifact-only `verify` cannot recover source contracts from a
+STEP file and deliberately does not infer them.
+
+Assertions never affect materialization, feature routing, selections, topology,
+or STEP/PMI export. The test suite verifies identical STEP text for equivalent
+sources with and without an assertion.
+
+M1 intentionally has no formulas, expressions, relative tolerance, Area,
+Centroid, topology assertions, embedded C#, or C# execution.
diff --git a/docs/firmament/profile-straight-edge-fillet-m1.md b/docs/firmament/profile-straight-edge-fillet-m1.md
index 81ee9457..2c479d7e 100644
--- a/docs/firmament/profile-straight-edge-fillet-m1.md
+++ b/docs/firmament/profile-straight-edge-fillet-m1.md
@@ -52,6 +52,10 @@ For span `S` and radius `r`, the exact removed volume is
at the span ends; they add no further removed volume. The cylindrical area is
`S * pi * r / 2`.
+The canonical top fixture now declares that analytic oracle directly with
+`Assert Volume Body`; M1 compares it after normal materialization and never
+uses the assertion to change the fillet route.
+
Current limitations: no adjacent-junction continuation, convex/reflex patch,
whole-loop or chain finish, inner loop, curve source, variable radius, imported
edge, cavity interaction, or composed Profile host is supported.
diff --git a/docs/firmament/v2-canonical-authoring.md b/docs/firmament/v2-canonical-authoring.md
index 66073c2b..dcc5c07b 100644
--- a/docs/firmament/v2-canonical-authoring.md
+++ b/docs/firmament/v2-canonical-authoring.md
@@ -26,6 +26,12 @@ Model Bracket {
Size: [80mm, 50mm, 25mm]
}
+ Assert Volume Base {
+ Expected: 100000mm^3
+ Tolerance: 0mm^3
+ Note: "Rectangular stock"
+ }
+
Modify Base {
Hole<Shaft> Mount {
On: +Z
diff --git a/fixtures/FirmamentV2/Canonical/valid/bare-box.firmament b/fixtures/FirmamentV2/Canonical/valid/bare-box.firmament
index 5b9c6b20..8b58b750 100644
--- a/fixtures/FirmamentV2/Canonical/valid/bare-box.firmament
+++ b/fixtures/FirmamentV2/Canonical/valid/bare-box.firmament
@@ -4,4 +4,9 @@ Model BareBox {
Box Base {
Size: [80mm, 50mm, 25mm]
}
+ Assert Volume Base {
+ Expected: 100000mm^3
+ Tolerance: 0mm^3
+ Note: "Rectangular stock"
+ }
}
diff --git a/fixtures/FirmamentV2/Canonical/valid/profile-compose-l-bracket.firmament b/fixtures/FirmamentV2/Canonical/valid/profile-compose-l-bracket.firmament
index fcaf65aa..8ecd3f66 100644
--- a/fixtures/FirmamentV2/Canonical/valid/profile-compose-l-bracket.firmament
+++ b/fixtures/FirmamentV2/Canonical/valid/profile-compose-l-bracket.firmament
@@ -23,4 +23,9 @@ Model ProfileComposeLBracket {
Base Stock { Profile: Bracket; From: 0mm; To: 12mm; Role: Stock }
}
}
+ Assert Volume BracketBody {
+ Expected: 28800mm^3
+ Tolerance: 0mm^3
+ Note: "Union of 80x20 and 20x60 rectangles, extruded 12mm"
+ }
}
diff --git a/fixtures/FirmamentV2/Canonical/valid/profile-straight-edge-fillet-top.firmament b/fixtures/FirmamentV2/Canonical/valid/profile-straight-edge-fillet-top.firmament
index 2e76e01a..5386edcb 100644
--- a/fixtures/FirmamentV2/Canonical/valid/profile-straight-edge-fillet-top.firmament
+++ b/fixtures/FirmamentV2/Canonical/valid/profile-straight-edge-fillet-top.firmament
@@ -1,3 +1,5 @@
+Model ProfileStraightEdgeFilletTop {
+Units: mm
Concept Struct RectangleLayout On XY {
Point2 A { Position: [0mm, 0mm] } Point2 B { Position: [20mm, 0mm] }
Point2 C { Position: [20mm, 10mm] } Point2 D { Position: [0mm, 10mm] }
@@ -10,3 +12,9 @@ Profile Bracket Using RectangleLayout { Loop Outer {
} }
Struct Body { Extrude Bracket { Profile: Bracket; From: 0mm; To: 8mm } }
Modify Body { EdgeFinish SouthTopRound { Target: Bracket.Outer.South On: Top Kind: Fillet Radius: 2mm EndClearance: 3mm } }
+Assert Volume Body {
+ Expected: 1587.982297150257mm^3
+ Tolerance: 5mm^3
+ Note: "Finite-span quarter-cylinder straight Profile edge fillet"
+}
+}