Skip to content

Next Gen STEP AP242 Native-ish BREP Geometric Modeling Kernel

Implement Firmament M2a document coherence validation

Yuechen Li6ae36b10917f
diff --git a/Aetheris.Kernel.Firmament.Tests/FirmamentBooleanRequiredFieldValidationTests.cs b/Aetheris.Kernel.Firmament.Tests/FirmamentBooleanRequiredFieldValidationTests.cs
index 0f89c040..d3ec9734 100644
--- a/Aetheris.Kernel.Firmament.Tests/FirmamentBooleanRequiredFieldValidationTests.cs
+++ b/Aetheris.Kernel.Firmament.Tests/FirmamentBooleanRequiredFieldValidationTests.cs
@@ -11,6 +11,7 @@ public sealed class FirmamentBooleanRequiredFieldValidationTests
"firmament": { "version": "1" },
"model": { "name": "demo", "units": "mm" },
"ops": [
+ { "op": "box", "id": "base", "size": [1, 2, 3] },
{ "op": "add", "id": "add1", "to": "base", "with": { "op": "box" }, "place": "ignored-for-now" }
]
}
@@ -23,6 +24,7 @@ public sealed class FirmamentBooleanRequiredFieldValidationTests
"firmament": { "version": "1" },
"model": { "name": "demo", "units": "mm" },
"ops": [
+ { "op": "box", "id": "base", "size": [1, 2, 3] },
{ "op": "subtract", "id": "sub1", "from": "base", "with": { "op": "cylinder" } }
]
}
@@ -35,6 +37,7 @@ public sealed class FirmamentBooleanRequiredFieldValidationTests
"firmament": { "version": "1" },
"model": { "name": "demo", "units": "mm" },
"ops": [
+ { "op": "box", "id": "base", "size": [1, 2, 3] },
{ "op": "intersect", "id": "int1", "left": "base", "with": { "op": "sphere" } }
]
}
diff --git a/Aetheris.Kernel.Firmament.Tests/FirmamentDocumentCoherenceValidationTests.cs b/Aetheris.Kernel.Firmament.Tests/FirmamentDocumentCoherenceValidationTests.cs
new file mode 100644
index 00000000..39a4ffe2
--- /dev/null
+++ b/Aetheris.Kernel.Firmament.Tests/FirmamentDocumentCoherenceValidationTests.cs
@@ -0,0 +1,83 @@
+using Aetheris.Kernel.Firmament.Diagnostics;
+
+namespace Aetheris.Kernel.Firmament.Tests;
+
+public sealed class FirmamentDocumentCoherenceValidationTests
+{
+ [Fact]
+ public void Compiler_Accepts_UniqueFeatureIds()
+ {
+ var result = CompileFixture("testdata/firmament/fixtures/m2a-valid-two-primitives-distinct-ids.firmament");
+ Assert.True(result.Compilation.IsSuccess);
+ }
+
+ [Fact]
+ public void Compiler_Rejects_DuplicateFeatureId_Deterministically()
+ {
+ var fixturePath = "testdata/firmament/fixtures/m2a-invalid-duplicate-id-across-primitive-boolean.firmament";
+ var first = CompileFixture(fixturePath);
+ var second = CompileFixture(fixturePath);
+
+ Assert.False(first.Compilation.IsSuccess);
+ Assert.False(second.Compilation.IsSuccess);
+
+ var firstDiagnostic = Assert.Single(first.Compilation.Diagnostics);
+ var secondDiagnostic = Assert.Single(second.Compilation.Diagnostics);
+
+ Assert.Equal($"[{FirmamentDiagnosticCodes.ReferenceDuplicateFeatureId.Value}] Feature-producing op 'add' at index 1 reuses duplicate feature id 'base'.", firstDiagnostic.Message);
+ Assert.Equal(firstDiagnostic.Message, secondDiagnostic.Message);
+ Assert.Equal(firstDiagnostic.Code, secondDiagnostic.Code);
+ Assert.Equal(firstDiagnostic.Source, secondDiagnostic.Source);
+ }
+
+ [Fact]
+ public void Compiler_Accepts_BooleanReferencesToPriorFeatures()
+ {
+ var result = CompileFixture("testdata/firmament/fixtures/m2a-valid-chained-features.firmament");
+ Assert.True(result.Compilation.IsSuccess);
+ }
+
+ [Theory]
+ [InlineData("testdata/firmament/fixtures/m2a-invalid-add-to-missing-id.firmament", "add", "to", "missing")]
+ [InlineData("testdata/firmament/fixtures/m2a-invalid-subtract-from-missing-id.firmament", "subtract", "from", "missing")]
+ [InlineData("testdata/firmament/fixtures/m2a-invalid-intersect-left-missing-id.firmament", "intersect", "left", "missing")]
+ [InlineData("testdata/firmament/fixtures/m2a-invalid-forward-reference.firmament", "add", "to", "later")]
+ public void Compiler_Rejects_BooleanReference_ToUnknownOrForwardFeatureId(string fixturePath, string opName, string fieldName, string refId)
+ {
+ var result = CompileFixture(fixturePath);
+
+ Assert.False(result.Compilation.IsSuccess);
+ var diagnostic = Assert.Single(result.Compilation.Diagnostics);
+ Assert.Equal(
+ $"[{FirmamentDiagnosticCodes.ReferenceUnknownFeatureId.Value}] Boolean op '{opName}' at index 0 references unknown feature id '{refId}' via field '{fieldName}'.",
+ diagnostic.Message);
+ }
+
+ [Fact]
+ public void Compiler_Leaves_ValidationTargets_Unresolved()
+ {
+ const string source = """
+ {
+ "firmament": { "version": "1" },
+ "model": { "name": "demo", "units": "mm" },
+ "ops": [
+ { "op": "box", "id": "base", "size": [1, 2, 3] },
+ { "op": "expect_exists", "target": "future_feature.top_face" },
+ { "op": "expect_selectable", "target": "ghost_feature", "count": 1 }
+ ]
+ }
+ """;
+
+ var compiler = new FirmamentCompiler();
+ var result = compiler.Compile(new FirmamentCompileRequest(new FirmamentSourceDocument(source)));
+
+ Assert.True(result.Compilation.IsSuccess);
+ }
+
+ private static FirmamentCompileResult CompileFixture(string fixturePath)
+ {
+ var fixtureText = FirmamentCorpusHarness.ReadFixtureText(fixturePath);
+ var compiler = new FirmamentCompiler();
+ return compiler.Compile(new FirmamentCompileRequest(new FirmamentSourceDocument(fixtureText)));
+ }
+}
diff --git a/Aetheris.Kernel.Firmament.Tests/FirmamentScaffoldTests.cs b/Aetheris.Kernel.Firmament.Tests/FirmamentScaffoldTests.cs
index abbb8a46..0b50a9c8 100644
--- a/Aetheris.Kernel.Firmament.Tests/FirmamentScaffoldTests.cs
+++ b/Aetheris.Kernel.Firmament.Tests/FirmamentScaffoldTests.cs
@@ -34,7 +34,7 @@ public sealed class FirmamentScaffoldTests
Assert.True(result.Compilation.IsSuccess);
var artifact = result.Compilation.Value;
- Assert.Equal("firmament-ops-primitive-boolean-and-validation-required-fields-validated", artifact.ArtifactKind);
+ Assert.Equal("firmament-ops-document-coherence-validated", artifact.ArtifactKind);
Assert.NotNull(artifact.ParsedDocument);
Assert.Equal("1", artifact.ParsedDocument!.Firmament.Version);
Assert.Equal("demo", artifact.ParsedDocument.Model.Name);
@@ -65,7 +65,7 @@ public sealed class FirmamentScaffoldTests
"model": { "name": "demo", "units": "mm" },
"ops": [
{ "op": "box", "id": "b1", "size": [2, 3, 4] },
- { "op": "subtract", "id": "cut1", "from": "a", "with": { "op": "box" } }
+ { "op": "subtract", "id": "cut1", "from": "b1", "with": { "op": "box" } }
]
}
""",
@@ -144,11 +144,12 @@ public sealed class FirmamentScaffoldTests
"firmament": { "version": "1" },
"model": { "name": "demo", "units": "mm" },
"ops": [
+ { "op": "box", "id": "b1", "size": [1, 2, 3] },
{ "op": "add", "id": "add1", "to": "b1", "with": { "op": "sphere" } }
]
}
""",
- 1);
+ 2);
[Fact]
public void Compiler_Accepts_KnownValidationOp() =>
@@ -584,7 +585,8 @@ public sealed class FirmamentScaffoldTests
Assert.StartsWith("FIRM-STRUCT", FirmamentDiagnosticCodes.PrimitiveInvalidFieldValue.Value);
Assert.StartsWith("FIRM-STRUCT", FirmamentDiagnosticCodes.BooleanMissingRequiredField.Value);
Assert.StartsWith("FIRM-STRUCT", FirmamentDiagnosticCodes.BooleanInvalidFieldTypeOrShape.Value);
- Assert.StartsWith("FIRM-REF", FirmamentDiagnosticCodes.ReferencePlaceholder.Value);
+ Assert.StartsWith("FIRM-REF", FirmamentDiagnosticCodes.ReferenceDuplicateFeatureId.Value);
+ Assert.StartsWith("FIRM-REF", FirmamentDiagnosticCodes.ReferenceUnknownFeatureId.Value);
Assert.StartsWith("FIRM-SEL", FirmamentDiagnosticCodes.SelectorPlaceholder.Value);
Assert.StartsWith("FIRM-SCHEMA", FirmamentDiagnosticCodes.SchemaPlaceholder.Value);
Assert.StartsWith("FIRM-LOWER", FirmamentDiagnosticCodes.LoweringPlaceholder.Value);
@@ -620,9 +622,9 @@ public sealed class FirmamentScaffoldTests
"box" => "{ \"op\": \"box\", \"id\": \"b1\", \"size\": [1, 1, 1] }",
"cylinder" => "{ \"op\": \"cylinder\", \"id\": \"c1\", \"radius\": 1, \"height\": 2 }",
"sphere" => "{ \"op\": \"sphere\", \"id\": \"s1\", \"radius\": 1 }",
- "add" => "{ \"op\": \"add\", \"id\": \"a1\", \"to\": \"b1\", \"with\": { \"op\": \"sphere\" } }",
- "subtract" => "{ \"op\": \"subtract\", \"id\": \"s1\", \"from\": \"b1\", \"with\": { \"op\": \"sphere\" } }",
- "intersect" => "{ \"op\": \"intersect\", \"id\": \"i1\", \"left\": \"b1\", \"with\": { \"op\": \"sphere\" } }",
+ "add" => "{ \"op\": \"box\", \"id\": \"b1\", \"size\": [1, 1, 1] }, { \"op\": \"add\", \"id\": \"a1\", \"to\": \"b1\", \"with\": { \"op\": \"sphere\" } }",
+ "subtract" => "{ \"op\": \"box\", \"id\": \"b1\", \"size\": [1, 1, 1] }, { \"op\": \"subtract\", \"id\": \"s1\", \"from\": \"b1\", \"with\": { \"op\": \"sphere\" } }",
+ "intersect" => "{ \"op\": \"box\", \"id\": \"b1\", \"size\": [1, 1, 1] }, { \"op\": \"intersect\", \"id\": \"i1\", \"left\": \"b1\", \"with\": { \"op\": \"sphere\" } }",
"expect_exists" => "{ \"op\": \"expect_exists\", \"target\": \"b1\" }",
"expect_selectable" => "{ \"op\": \"expect_selectable\", \"target\": \"b1\", \"count\": 1 }",
"expect_manifold" => "{ \"op\": \"expect_manifold\" }",
@@ -642,7 +644,8 @@ public sealed class FirmamentScaffoldTests
var result = compiler.Compile(new FirmamentCompileRequest(new FirmamentSourceDocument(source)));
Assert.True(result.Compilation.IsSuccess);
- var op = Assert.Single(result.Compilation.Value.ParsedDocument!.Ops.Entries);
+ var ops = result.Compilation.Value.ParsedDocument!.Ops.Entries;
+ var op = ops[^1];
Assert.Equal(expectedFamily, op.Family);
}
diff --git a/Aetheris.Kernel.Firmament/Diagnostics/FirmamentDiagnosticCodes.cs b/Aetheris.Kernel.Firmament/Diagnostics/FirmamentDiagnosticCodes.cs
index ce65ef85..70553999 100644
--- a/Aetheris.Kernel.Firmament/Diagnostics/FirmamentDiagnosticCodes.cs
+++ b/Aetheris.Kernel.Firmament/Diagnostics/FirmamentDiagnosticCodes.cs
@@ -22,7 +22,8 @@ public static class FirmamentDiagnosticCodes
public static readonly FirmamentDiagnosticCode ValidationInvalidFieldTypeOrShape = new($"{FirmamentDiagnosticConventions.StructurePrefix}-0015");
public static readonly FirmamentDiagnosticCode ValidationInvalidFieldValue = new($"{FirmamentDiagnosticConventions.StructurePrefix}-0016");
- public static readonly FirmamentDiagnosticCode ReferencePlaceholder = new($"{FirmamentDiagnosticConventions.ReferencePrefix}-0001");
+ public static readonly FirmamentDiagnosticCode ReferenceDuplicateFeatureId = new($"{FirmamentDiagnosticConventions.ReferencePrefix}-0001");
+ public static readonly FirmamentDiagnosticCode ReferenceUnknownFeatureId = new($"{FirmamentDiagnosticConventions.ReferencePrefix}-0002");
public static readonly FirmamentDiagnosticCode SelectorPlaceholder = new($"{FirmamentDiagnosticConventions.SelectorPrefix}-0001");
public static readonly FirmamentDiagnosticCode SchemaPlaceholder = new($"{FirmamentDiagnosticConventions.SchemaPrefix}-0001");
public static readonly FirmamentDiagnosticCode LoweringPlaceholder = new($"{FirmamentDiagnosticConventions.LoweringPrefix}-0001");
diff --git a/Aetheris.Kernel.Firmament/FirmamentCompilationArtifact.cs b/Aetheris.Kernel.Firmament/FirmamentCompilationArtifact.cs
index d13b6890..77de5a32 100644
--- a/Aetheris.Kernel.Firmament/FirmamentCompilationArtifact.cs
+++ b/Aetheris.Kernel.Firmament/FirmamentCompilationArtifact.cs
@@ -3,5 +3,5 @@ using Aetheris.Kernel.Firmament.ParsedModel;
namespace Aetheris.Kernel.Firmament;
public sealed record FirmamentCompilationArtifact(
- string ArtifactKind = "firmament-ops-primitive-boolean-and-validation-required-fields-validated",
+ string ArtifactKind = "firmament-ops-document-coherence-validated",
FirmamentParsedDocument? ParsedDocument = null);
diff --git a/Aetheris.Kernel.Firmament/FirmamentCompiler.cs b/Aetheris.Kernel.Firmament/FirmamentCompiler.cs
index 2a7875ca..38458c60 100644
--- a/Aetheris.Kernel.Firmament/FirmamentCompiler.cs
+++ b/Aetheris.Kernel.Firmament/FirmamentCompiler.cs
@@ -38,10 +38,17 @@ public sealed class FirmamentCompiler
KernelResult<FirmamentCompilationArtifact>.Failure(validationValidationResult.Diagnostics));
}
+ var documentCoherenceValidationResult = FirmamentDocumentCoherenceValidator.Validate(parseResult.Value);
+ if (!documentCoherenceValidationResult.IsSuccess)
+ {
+ return new FirmamentCompileResult(
+ KernelResult<FirmamentCompilationArtifact>.Failure(documentCoherenceValidationResult.Diagnostics));
+ }
+
return new FirmamentCompileResult(
KernelResult<FirmamentCompilationArtifact>.Success(
new FirmamentCompilationArtifact(
- ArtifactKind: "firmament-ops-primitive-boolean-and-validation-required-fields-validated",
+ ArtifactKind: "firmament-ops-document-coherence-validated",
ParsedDocument: parseResult.Value)));
}
}
diff --git a/Aetheris.Kernel.Firmament/Validation/FirmamentDocumentCoherenceValidator.cs b/Aetheris.Kernel.Firmament/Validation/FirmamentDocumentCoherenceValidator.cs
new file mode 100644
index 00000000..60b4dc9e
--- /dev/null
+++ b/Aetheris.Kernel.Firmament/Validation/FirmamentDocumentCoherenceValidator.cs
@@ -0,0 +1,68 @@
+using Aetheris.Kernel.Core.Diagnostics;
+using Aetheris.Kernel.Core.Results;
+using Aetheris.Kernel.Firmament.Diagnostics;
+using Aetheris.Kernel.Firmament.ParsedModel;
+
+namespace Aetheris.Kernel.Firmament.Validation;
+
+internal static class FirmamentDocumentCoherenceValidator
+{
+ public static KernelResult<bool> Validate(FirmamentParsedDocument parsedDocument)
+ {
+ ArgumentNullException.ThrowIfNull(parsedDocument);
+
+ var featureIds = new HashSet<string>(StringComparer.Ordinal);
+
+ for (var index = 0; index < parsedDocument.Ops.Entries.Count; index++)
+ {
+ var entry = parsedDocument.Ops.Entries[index];
+
+ if (entry.Family == FirmamentOpFamily.Validation)
+ {
+ continue;
+ }
+
+ var featureId = entry.RawFields["id"];
+ if (entry.Family == FirmamentOpFamily.Boolean)
+ {
+ var referenceFieldName = GetReferenceFieldName(entry.KnownKind);
+ var referenceId = entry.RawFields[referenceFieldName];
+ if (!featureIds.Contains(referenceId))
+ {
+ return KernelResult<bool>.Failure([
+ CreateDiagnostic(
+ FirmamentDiagnosticCodes.ReferenceUnknownFeatureId,
+ $"Boolean op '{entry.OpName}' at index {index} references unknown feature id '{referenceId}' via field '{referenceFieldName}'.")
+ ]);
+ }
+ }
+
+ if (!featureIds.Add(featureId))
+ {
+ return KernelResult<bool>.Failure([
+ CreateDiagnostic(
+ FirmamentDiagnosticCodes.ReferenceDuplicateFeatureId,
+ $"Feature-producing op '{entry.OpName}' at index {index} reuses duplicate feature id '{featureId}'.")
+ ]);
+ }
+ }
+
+ return KernelResult<bool>.Success(true);
+ }
+
+ private static string GetReferenceFieldName(FirmamentKnownOpKind kind) =>
+ kind switch
+ {
+ FirmamentKnownOpKind.Add => "to",
+ FirmamentKnownOpKind.Subtract => "from",
+ FirmamentKnownOpKind.Intersect => "left",
+ _ => throw new ArgumentOutOfRangeException(nameof(kind), kind, "Boolean op kind must map to a feature reference field.")
+ };
+
+ private static KernelDiagnostic CreateDiagnostic(FirmamentDiagnosticCode code, string message) =>
+ new(
+ KernelDiagnosticCode.ValidationFailed,
+ KernelDiagnosticSeverity.Error,
+ $"[{code.Value}] {message}",
+ FirmamentDiagnosticConventions.Source);
+}
diff --git a/testdata/firmament/fixtures/m0c-valid-known-boolean-op.firmament b/testdata/firmament/fixtures/m0c-valid-known-boolean-op.firmament
index 07c34965..a60a60aa 100644
--- a/testdata/firmament/fixtures/m0c-valid-known-boolean-op.firmament
+++ b/testdata/firmament/fixtures/m0c-valid-known-boolean-op.firmament
@@ -5,7 +5,11 @@ model:
name: demo
units: mm
-ops[1]:
+ops[2]:
+ -
+ op: box
+ id: base
+ size: [1, 2, 3]
-
op: add
id: add1
diff --git a/testdata/firmament/fixtures/m1b-valid-add.firmament b/testdata/firmament/fixtures/m1b-valid-add.firmament
index 11849a89..27b9d217 100644
--- a/testdata/firmament/fixtures/m1b-valid-add.firmament
+++ b/testdata/firmament/fixtures/m1b-valid-add.firmament
@@ -5,7 +5,11 @@ model:
name: demo
units: mm
-ops[1]:
+ops[2]:
+ -
+ op: box
+ id: base
+ size: [1, 2, 3]
-
op: add
id: add1
diff --git a/testdata/firmament/fixtures/m1b-valid-intersect.firmament b/testdata/firmament/fixtures/m1b-valid-intersect.firmament
index 142589d7..e9985e23 100644
--- a/testdata/firmament/fixtures/m1b-valid-intersect.firmament
+++ b/testdata/firmament/fixtures/m1b-valid-intersect.firmament
@@ -5,7 +5,11 @@ model:
name: demo
units: mm
-ops[1]:
+ops[2]:
+ -
+ op: box
+ id: base
+ size: [1, 2, 3]
-
op: intersect
id: int1
diff --git a/testdata/firmament/fixtures/m1b-valid-subtract.firmament b/testdata/firmament/fixtures/m1b-valid-subtract.firmament
index 65eaaeb6..b557b133 100644
--- a/testdata/firmament/fixtures/m1b-valid-subtract.firmament
+++ b/testdata/firmament/fixtures/m1b-valid-subtract.firmament
@@ -5,7 +5,11 @@ model:
name: demo
units: mm
-ops[1]:
+ops[2]:
+ -
+ op: box
+ id: base
+ size: [1, 2, 3]
-
op: subtract
id: sub1
diff --git a/testdata/firmament/fixtures/m2a-invalid-add-to-missing-id.firmament b/testdata/firmament/fixtures/m2a-invalid-add-to-missing-id.firmament
new file mode 100644
index 00000000..0c0f781c
--- /dev/null
+++ b/testdata/firmament/fixtures/m2a-invalid-add-to-missing-id.firmament
@@ -0,0 +1,13 @@
+firmament:
+ version: 1
+
+model:
+ name: demo
+ units: mm
+
+ops[1]:
+ -
+ op: add
+ id: fused
+ to: missing
+ with: { op: box }
diff --git a/testdata/firmament/fixtures/m2a-invalid-duplicate-id-across-primitive-boolean.firmament b/testdata/firmament/fixtures/m2a-invalid-duplicate-id-across-primitive-boolean.firmament
new file mode 100644
index 00000000..499d0870
--- /dev/null
+++ b/testdata/firmament/fixtures/m2a-invalid-duplicate-id-across-primitive-boolean.firmament
@@ -0,0 +1,18 @@
+firmament:
+ version: 1
+
+model:
+ name: demo
+ units: mm
+
+ops[2]:
+ -
+ op: box
+ id: base
+ size: [10, 20, 30]
+
+ -
+ op: add
+ id: base
+ to: base
+ with: { op: sphere }
diff --git a/testdata/firmament/fixtures/m2a-invalid-duplicate-primitive-id.firmament b/testdata/firmament/fixtures/m2a-invalid-duplicate-primitive-id.firmament
new file mode 100644
index 00000000..5384a098
--- /dev/null
+++ b/testdata/firmament/fixtures/m2a-invalid-duplicate-primitive-id.firmament
@@ -0,0 +1,17 @@
+firmament:
+ version: 1
+
+model:
+ name: demo
+ units: mm
+
+ops[2]:
+ -
+ op: box
+ id: base
+ size: [10, 20, 30]
+
+ -
+ op: sphere
+ id: base
+ radius: 3
diff --git a/testdata/firmament/fixtures/m2a-invalid-forward-reference.firmament b/testdata/firmament/fixtures/m2a-invalid-forward-reference.firmament
new file mode 100644
index 00000000..4e1cb5d3
--- /dev/null
+++ b/testdata/firmament/fixtures/m2a-invalid-forward-reference.firmament
@@ -0,0 +1,18 @@
+firmament:
+ version: 1
+
+model:
+ name: demo
+ units: mm
+
+ops[2]:
+ -
+ op: add
+ id: fused
+ to: later
+ with: { op: box }
+
+ -
+ op: box
+ id: later
+ size: [10, 20, 30]
diff --git a/testdata/firmament/fixtures/m2a-invalid-intersect-left-missing-id.firmament b/testdata/firmament/fixtures/m2a-invalid-intersect-left-missing-id.firmament
new file mode 100644
index 00000000..6560400c
--- /dev/null
+++ b/testdata/firmament/fixtures/m2a-invalid-intersect-left-missing-id.firmament
@@ -0,0 +1,13 @@
+firmament:
+ version: 1
+
+model:
+ name: demo
+ units: mm
+
+ops[1]:
+ -
+ op: intersect
+ id: clip1
+ left: missing
+ with: { op: sphere }
diff --git a/testdata/firmament/fixtures/m2a-invalid-subtract-from-missing-id.firmament b/testdata/firmament/fixtures/m2a-invalid-subtract-from-missing-id.firmament
new file mode 100644
index 00000000..0d3a223a
--- /dev/null
+++ b/testdata/firmament/fixtures/m2a-invalid-subtract-from-missing-id.firmament
@@ -0,0 +1,13 @@
+firmament:
+ version: 1
+
+model:
+ name: demo
+ units: mm
+
+ops[1]:
+ -
+ op: subtract
+ id: cut1
+ from: missing
+ with: { op: cylinder }
diff --git a/testdata/firmament/fixtures/m2a-valid-boolean-references-earlier-id.firmament b/testdata/firmament/fixtures/m2a-valid-boolean-references-earlier-id.firmament
new file mode 100644
index 00000000..5f9adec1
--- /dev/null
+++ b/testdata/firmament/fixtures/m2a-valid-boolean-references-earlier-id.firmament
@@ -0,0 +1,18 @@
+firmament:
+ version: 1
+
+model:
+ name: demo
+ units: mm
+
+ops[2]:
+ -
+ op: box
+ id: base
+ size: [10, 20, 30]
+
+ -
+ op: add
+ id: fused
+ to: base
+ with: { op: cylinder }
diff --git a/testdata/firmament/fixtures/m2a-valid-chained-features.firmament b/testdata/firmament/fixtures/m2a-valid-chained-features.firmament
new file mode 100644
index 00000000..bd7d1f21
--- /dev/null
+++ b/testdata/firmament/fixtures/m2a-valid-chained-features.firmament
@@ -0,0 +1,30 @@
+firmament:
+ version: 1
+
+model:
+ name: demo
+ units: mm
+
+ops[4]:
+ -
+ op: box
+ id: base
+ size: [10, 20, 30]
+
+ -
+ op: subtract
+ id: cut1
+ from: base
+ with: { op: cylinder }
+
+ -
+ op: intersect
+ id: clipped
+ left: cut1
+ with: { op: sphere }
+
+ -
+ op: add
+ id: merged
+ to: clipped
+ with: { op: box }
diff --git a/testdata/firmament/fixtures/m2a-valid-two-primitives-distinct-ids.firmament b/testdata/firmament/fixtures/m2a-valid-two-primitives-distinct-ids.firmament
new file mode 100644
index 00000000..2c8e0bb9
--- /dev/null
+++ b/testdata/firmament/fixtures/m2a-valid-two-primitives-distinct-ids.firmament
@@ -0,0 +1,17 @@
+firmament:
+ version: 1
+
+model:
+ name: demo
+ units: mm
+
+ops[2]:
+ -
+ op: box
+ id: base
+ size: [10, 20, 30]
+
+ -
+ op: sphere
+ id: cap
+ radius: 5
diff --git a/testdata/firmament/manifests/m0c.corpus.json b/testdata/firmament/manifests/m0c.corpus.json
index e96291a2..4a4f8fb5 100644
--- a/testdata/firmament/manifests/m0c.corpus.json
+++ b/testdata/firmament/manifests/m0c.corpus.json
@@ -187,22 +187,15 @@
"expectedOutcome": "success"
},
{
- "id": "m1b-valid-add",
- "name": "Valid add boolean required fields",
- "fixturePath": "testdata/firmament/fixtures/m1b-valid-add.firmament",
- "expectedOutcome": "success"
- },
- {
- "id": "m1b-valid-subtract",
- "name": "Valid subtract boolean required fields",
- "fixturePath": "testdata/firmament/fixtures/m1b-valid-subtract.firmament",
- "expectedOutcome": "success"
- },
- {
- "id": "m1b-valid-intersect",
- "name": "Valid intersect boolean required fields",
- "fixturePath": "testdata/firmament/fixtures/m1b-valid-intersect.firmament",
- "expectedOutcome": "success"
+ "id": "m1b-invalid-add-invalid-with-shape",
+ "name": "Invalid add invalid with shape",
+ "fixturePath": "testdata/firmament/fixtures/m1b-invalid-add-invalid-with-shape.firmament",
+ "expectedOutcome": "failure",
+ "expectedDiagnostic": {
+ "source": "firmament",
+ "kernelCode": "ValidationFailed",
+ "firmamentCode": "FIRM-STRUCT-0013"
+ }
},
{
"id": "m1b-invalid-add-missing-id",
@@ -238,9 +231,9 @@
}
},
{
- "id": "m1b-invalid-add-invalid-with-shape",
- "name": "Invalid add invalid with shape",
- "fixturePath": "testdata/firmament/fixtures/m1b-invalid-add-invalid-with-shape.firmament",
+ "id": "m1b-invalid-add-missing-with-op",
+ "name": "Invalid add missing with.op",
+ "fixturePath": "testdata/firmament/fixtures/m1b-invalid-add-missing-with-op.firmament",
"expectedOutcome": "failure",
"expectedDiagnostic": {
"source": "firmament",
@@ -249,9 +242,9 @@
}
},
{
- "id": "m1b-invalid-add-missing-with-op",
- "name": "Invalid add missing with.op",
- "fixturePath": "testdata/firmament/fixtures/m1b-invalid-add-missing-with-op.firmament",
+ "id": "m1b-invalid-intersect-invalid-with-shape",
+ "name": "Invalid intersect invalid with shape",
+ "fixturePath": "testdata/firmament/fixtures/m1b-invalid-intersect-invalid-with-shape.firmament",
"expectedOutcome": "failure",
"expectedDiagnostic": {
"source": "firmament",
@@ -260,9 +253,9 @@
}
},
{
- "id": "m1b-invalid-subtract-missing-id",
- "name": "Invalid subtract missing id",
- "fixturePath": "testdata/firmament/fixtures/m1b-invalid-subtract-missing-id.firmament",
+ "id": "m1b-invalid-intersect-missing-id",
+ "name": "Invalid intersect missing id",
+ "fixturePath": "testdata/firmament/fixtures/m1b-invalid-intersect-missing-id.firmament",
"expectedOutcome": "failure",
"expectedDiagnostic": {
"source": "firmament",
@@ -271,9 +264,9 @@
}
},
{
- "id": "m1b-invalid-subtract-missing-from",
- "name": "Invalid subtract missing from",
- "fixturePath": "testdata/firmament/fixtures/m1b-invalid-subtract-missing-from.firmament",
+ "id": "m1b-invalid-intersect-missing-left",
+ "name": "Invalid intersect missing left",
+ "fixturePath": "testdata/firmament/fixtures/m1b-invalid-intersect-missing-left.firmament",
"expectedOutcome": "failure",
"expectedDiagnostic": {
"source": "firmament",
@@ -282,9 +275,9 @@
}
},
{
- "id": "m1b-invalid-subtract-missing-with",
- "name": "Invalid subtract missing with",
- "fixturePath": "testdata/firmament/fixtures/m1b-invalid-subtract-missing-with.firmament",
+ "id": "m1b-invalid-intersect-missing-with",
+ "name": "Invalid intersect missing with",
+ "fixturePath": "testdata/firmament/fixtures/m1b-invalid-intersect-missing-with.firmament",
"expectedOutcome": "failure",
"expectedDiagnostic": {
"source": "firmament",
@@ -293,9 +286,9 @@
}
},
{
- "id": "m1b-invalid-subtract-invalid-with-shape",
- "name": "Invalid subtract invalid with shape",
- "fixturePath": "testdata/firmament/fixtures/m1b-invalid-subtract-invalid-with-shape.firmament",
+ "id": "m1b-invalid-intersect-missing-with-op",
+ "name": "Invalid intersect missing with.op",
+ "fixturePath": "testdata/firmament/fixtures/m1b-invalid-intersect-missing-with-op.firmament",
"expectedOutcome": "failure",
"expectedDiagnostic": {
"source": "firmament",
@@ -304,9 +297,9 @@
}
},
{
- "id": "m1b-invalid-subtract-missing-with-op",
- "name": "Invalid subtract missing with.op",
- "fixturePath": "testdata/firmament/fixtures/m1b-invalid-subtract-missing-with-op.firmament",
+ "id": "m1b-invalid-subtract-invalid-with-shape",
+ "name": "Invalid subtract invalid with shape",
+ "fixturePath": "testdata/firmament/fixtures/m1b-invalid-subtract-invalid-with-shape.firmament",
"expectedOutcome": "failure",
"expectedDiagnostic": {
"source": "firmament",
@@ -315,9 +308,9 @@
}
},
{
- "id": "m1b-invalid-intersect-missing-id",
- "name": "Invalid intersect missing id",
- "fixturePath": "testdata/firmament/fixtures/m1b-invalid-intersect-missing-id.firmament",
+ "id": "m1b-invalid-subtract-missing-from",
+ "name": "Invalid subtract missing from",
+ "fixturePath": "testdata/firmament/fixtures/m1b-invalid-subtract-missing-from.firmament",
"expectedOutcome": "failure",
"expectedDiagnostic": {
"source": "firmament",
@@ -326,9 +319,9 @@
}
},
{
- "id": "m1b-invalid-intersect-missing-left",
- "name": "Invalid intersect missing left",
- "fixturePath": "testdata/firmament/fixtures/m1b-invalid-intersect-missing-left.firmament",
+ "id": "m1b-invalid-subtract-missing-id",
+ "name": "Invalid subtract missing id",
+ "fixturePath": "testdata/firmament/fixtures/m1b-invalid-subtract-missing-id.firmament",
"expectedOutcome": "failure",
"expectedDiagnostic": {
"source": "firmament",
@@ -337,9 +330,9 @@
}
},
{
- "id": "m1b-invalid-intersect-missing-with",
- "name": "Invalid intersect missing with",
- "fixturePath": "testdata/firmament/fixtures/m1b-invalid-intersect-missing-with.firmament",
+ "id": "m1b-invalid-subtract-missing-with",
+ "name": "Invalid subtract missing with",
+ "fixturePath": "testdata/firmament/fixtures/m1b-invalid-subtract-missing-with.firmament",
"expectedOutcome": "failure",
"expectedDiagnostic": {
"source": "firmament",
@@ -348,20 +341,9 @@
}
},
{
- "id": "m1b-invalid-intersect-invalid-with-shape",
- "name": "Invalid intersect invalid with shape",
- "fixturePath": "testdata/firmament/fixtures/m1b-invalid-intersect-invalid-with-shape.firmament",
- "expectedOutcome": "failure",
- "expectedDiagnostic": {
- "source": "firmament",
- "kernelCode": "ValidationFailed",
- "firmamentCode": "FIRM-STRUCT-0013"
- }
- },
- {
- "id": "m1b-invalid-intersect-missing-with-op",
- "name": "Invalid intersect missing with.op",
- "fixturePath": "testdata/firmament/fixtures/m1b-invalid-intersect-missing-with-op.firmament",
+ "id": "m1b-invalid-subtract-missing-with-op",
+ "name": "Invalid subtract missing with.op",
+ "fixturePath": "testdata/firmament/fixtures/m1b-invalid-subtract-missing-with-op.firmament",
"expectedOutcome": "failure",
"expectedDiagnostic": {
"source": "firmament",
@@ -370,21 +352,21 @@
}
},
{
- "id": "m1c-valid-expect-exists",
- "name": "Valid expect_exists validation required fields",
- "fixturePath": "testdata/firmament/fixtures/m1c-valid-expect-exists.firmament",
+ "id": "m1b-valid-add",
+ "name": "Valid add boolean required fields",
+ "fixturePath": "testdata/firmament/fixtures/m1b-valid-add.firmament",
"expectedOutcome": "success"
},
{
- "id": "m1c-valid-expect-selectable",
- "name": "Valid expect_selectable validation required fields",
- "fixturePath": "testdata/firmament/fixtures/m1c-valid-expect-selectable.firmament",
+ "id": "m1b-valid-intersect",
+ "name": "Valid intersect boolean required fields",
+ "fixturePath": "testdata/firmament/fixtures/m1b-valid-intersect.firmament",
"expectedOutcome": "success"
},
{
- "id": "m1c-valid-expect-manifold",
- "name": "Valid expect_manifold validation required fields",
- "fixturePath": "testdata/firmament/fixtures/m1c-valid-expect-manifold.firmament",
+ "id": "m1b-valid-subtract",
+ "name": "Valid subtract boolean required fields",
+ "fixturePath": "testdata/firmament/fixtures/m1b-valid-subtract.firmament",
"expectedOutcome": "success"
},
{
@@ -398,6 +380,17 @@
"firmamentCode": "FIRM-STRUCT-0014"
}
},
+ {
+ "id": "m1c-invalid-expect-selectable-missing-count",
+ "name": "Invalid expect_selectable missing count",
+ "fixturePath": "testdata/firmament/fixtures/m1c-invalid-expect-selectable-missing-count.firmament",
+ "expectedOutcome": "failure",
+ "expectedDiagnostic": {
+ "source": "firmament",
+ "kernelCode": "ValidationFailed",
+ "firmamentCode": "FIRM-STRUCT-0014"
+ }
+ },
{
"id": "m1c-invalid-expect-selectable-missing-target",
"name": "Invalid expect_selectable missing target",
@@ -410,14 +403,14 @@
}
},
{
- "id": "m1c-invalid-expect-selectable-missing-count",
- "name": "Invalid expect_selectable missing count",
- "fixturePath": "testdata/firmament/fixtures/m1c-invalid-expect-selectable-missing-count.firmament",
+ "id": "m1c-invalid-expect-selectable-non-integer-count",
+ "name": "Invalid expect_selectable non-integer count",
+ "fixturePath": "testdata/firmament/fixtures/m1c-invalid-expect-selectable-non-integer-count.firmament",
"expectedOutcome": "failure",
"expectedDiagnostic": {
"source": "firmament",
"kernelCode": "ValidationFailed",
- "firmamentCode": "FIRM-STRUCT-0014"
+ "firmamentCode": "FIRM-STRUCT-0016"
}
},
{
@@ -432,9 +425,9 @@
}
},
{
- "id": "m1c-invalid-expect-selectable-non-integer-count",
- "name": "Invalid expect_selectable non-integer count",
- "fixturePath": "testdata/firmament/fixtures/m1c-invalid-expect-selectable-non-integer-count.firmament",
+ "id": "m1c-invalid-expect-selectable-non-positive-count",
+ "name": "Invalid expect_selectable non-positive count",
+ "fixturePath": "testdata/firmament/fixtures/m1c-invalid-expect-selectable-non-positive-count.firmament",
"expectedOutcome": "failure",
"expectedDiagnostic": {
"source": "firmament",
@@ -443,15 +436,106 @@
}
},
{
- "id": "m1c-invalid-expect-selectable-non-positive-count",
- "name": "Invalid expect_selectable non-positive count",
- "fixturePath": "testdata/firmament/fixtures/m1c-invalid-expect-selectable-non-positive-count.firmament",
+ "id": "m1c-valid-expect-exists",
+ "name": "Valid expect_exists validation required fields",
+ "fixturePath": "testdata/firmament/fixtures/m1c-valid-expect-exists.firmament",
+ "expectedOutcome": "success"
+ },
+ {
+ "id": "m1c-valid-expect-manifold",
+ "name": "Valid expect_manifold validation required fields",
+ "fixturePath": "testdata/firmament/fixtures/m1c-valid-expect-manifold.firmament",
+ "expectedOutcome": "success"
+ },
+ {
+ "id": "m1c-valid-expect-selectable",
+ "name": "Valid expect_selectable validation required fields",
+ "fixturePath": "testdata/firmament/fixtures/m1c-valid-expect-selectable.firmament",
+ "expectedOutcome": "success"
+ },
+ {
+ "id": "m2a-invalid-add-to-missing-id",
+ "name": "Invalid M2a add.to references missing feature",
+ "fixturePath": "testdata/firmament/fixtures/m2a-invalid-add-to-missing-id.firmament",
"expectedOutcome": "failure",
"expectedDiagnostic": {
"source": "firmament",
"kernelCode": "ValidationFailed",
- "firmamentCode": "FIRM-STRUCT-0016"
+ "firmamentCode": "FIRM-REF-0002"
+ }
+ },
+ {
+ "id": "m2a-invalid-duplicate-id-across-primitive-boolean",
+ "name": "Invalid M2a duplicate id across primitive and boolean",
+ "fixturePath": "testdata/firmament/fixtures/m2a-invalid-duplicate-id-across-primitive-boolean.firmament",
+ "expectedOutcome": "failure",
+ "expectedDiagnostic": {
+ "source": "firmament",
+ "kernelCode": "ValidationFailed",
+ "firmamentCode": "FIRM-REF-0001"
+ }
+ },
+ {
+ "id": "m2a-invalid-duplicate-primitive-id",
+ "name": "Invalid M2a duplicate primitive id",
+ "fixturePath": "testdata/firmament/fixtures/m2a-invalid-duplicate-primitive-id.firmament",
+ "expectedOutcome": "failure",
+ "expectedDiagnostic": {
+ "source": "firmament",
+ "kernelCode": "ValidationFailed",
+ "firmamentCode": "FIRM-REF-0001"
+ }
+ },
+ {
+ "id": "m2a-invalid-forward-reference",
+ "name": "Invalid M2a boolean forward reference",
+ "fixturePath": "testdata/firmament/fixtures/m2a-invalid-forward-reference.firmament",
+ "expectedOutcome": "failure",
+ "expectedDiagnostic": {
+ "source": "firmament",
+ "kernelCode": "ValidationFailed",
+ "firmamentCode": "FIRM-REF-0002"
+ }
+ },
+ {
+ "id": "m2a-invalid-intersect-left-missing-id",
+ "name": "Invalid M2a intersect.left references missing feature",
+ "fixturePath": "testdata/firmament/fixtures/m2a-invalid-intersect-left-missing-id.firmament",
+ "expectedOutcome": "failure",
+ "expectedDiagnostic": {
+ "source": "firmament",
+ "kernelCode": "ValidationFailed",
+ "firmamentCode": "FIRM-REF-0002"
+ }
+ },
+ {
+ "id": "m2a-invalid-subtract-from-missing-id",
+ "name": "Invalid M2a subtract.from references missing feature",
+ "fixturePath": "testdata/firmament/fixtures/m2a-invalid-subtract-from-missing-id.firmament",
+ "expectedOutcome": "failure",
+ "expectedDiagnostic": {
+ "source": "firmament",
+ "kernelCode": "ValidationFailed",
+ "firmamentCode": "FIRM-REF-0002"
}
+ },
+ {
+ "id": "m2a-valid-boolean-references-earlier-id",
+ "name": "Valid M2a boolean references earlier feature id",
+ "fixturePath": "testdata/firmament/fixtures/m2a-valid-boolean-references-earlier-id.firmament",
+ "expectedOutcome": "success"
+ },
+ {
+ "id": "m2a-valid-chained-features",
+ "name": "Valid M2a chained feature ids and references",
+ "fixturePath": "testdata/firmament/fixtures/m2a-valid-chained-features.firmament",
+ "expectedOutcome": "success"
+ },
+ {
+ "id": "m2a-valid-two-primitives-distinct-ids",
+ "name": "Valid M2a two primitives with distinct ids",
+ "fixturePath": "testdata/firmament/fixtures/m2a-valid-two-primitives-distinct-ids.firmament",
+ "expectedOutcome": "success"
}
]
}