Skip to content

Next Gen STEP AP242 Native-ish BREP Geometric Modeling Kernel

Implement Firmament V2 primitive let declarations

Yuechen Lib30ac761f898
diff --git a/Aetheris.Kernel.Firmament.Tests/FirmamentV2ParserTests.cs b/Aetheris.Kernel.Firmament.Tests/FirmamentV2ParserTests.cs
index 06f73c59..7f0f5537 100644
--- a/Aetheris.Kernel.Firmament.Tests/FirmamentV2ParserTests.cs
+++ b/Aetheris.Kernel.Firmament.Tests/FirmamentV2ParserTests.cs
@@ -867,4 +867,72 @@ model BadPmiDiameter {
var bodyStart = Array.FindIndex(lines, line => !string.IsNullOrWhiteSpace(line) && !line.TrimStart().StartsWith("//", StringComparison.Ordinal));
return string.Join(Environment.NewLine, lines.Skip(Math.Max(0, bodyStart)));
}
+ [Fact]
+ public void FirmamentV2Parser_LetPrimitiveLiterals_ParsesAndBinds()
+ {
+ var result = FirmamentV2Parser.Parse(Source("Language/valid/let-primitive-literals.valid.firmfixture"));
+
+ Assert.True(result.IsSuccess, string.Join(", ", result.Diagnostics));
+ var lets = result.Document!.Lets!;
+ var boundLets = result.Document!.BoundLets!;
+ Assert.Equal(6, lets.Count);
+ Assert.Equal(6, boundLets.Count);
+ AssertLet(boundLets[0], "holeCount", FirmamentV2PrimitiveType.Int, 4, null);
+ AssertLet(boundLets[1], "scale", FirmamentV2PrimitiveType.Float, 1.25d, null);
+ AssertLet(boundLets[2], "holeDiameter", FirmamentV2PrimitiveType.Length, 6.0d, "mm");
+ AssertLet(boundLets[3], "draftAngle", FirmamentV2PrimitiveType.Angle, 3.0d, "deg");
+ AssertLet(boundLets[4], "materialName", FirmamentV2PrimitiveType.String, "Aluminum6061", null);
+ AssertLet(boundLets[5], "inspectionRequired", FirmamentV2PrimitiveType.Bool, true, null);
+ }
+
+ [Theory]
+ [InlineData("let holeCount: int = 4.0", FirmamentV2Parser.LetTypeMismatch)]
+ [InlineData("let holeDiameter: length = 6.0", FirmamentV2Parser.LetTypeMismatch)]
+ [InlineData("let draftAngle: angle = 3mm", FirmamentV2Parser.LetUnitMismatch)]
+ [InlineData("let scale: float = 1.25mm", FirmamentV2Parser.LetUnitMismatch)]
+ [InlineData("let unknownThing: banana = 1", FirmamentV2Parser.LetUnknownType)]
+ [InlineData("let radius: length = holeDiameter / 2", FirmamentV2Parser.LetLiteralOnly)]
+ [InlineData("let holeDiameter: length = 6.0mm tol 0.05mm", FirmamentV2Parser.LetInvalidLiteral)]
+ public void FirmamentV2Parser_LetPrimitiveLiterals_InvalidCasesAreDiagnostics(string letSource, string expectedDiagnostic)
+ {
+ var result = FirmamentV2Parser.Parse($$"""
+ model LetInvalidExample {
+ units mm
+ solid base: Box {
+ size: [10, 8, 6]
+ }
+ {{letSource}}
+ }
+ """);
+
+ Assert.False(result.IsSuccess);
+ Assert.Contains(expectedDiagnostic, result.Diagnostics);
+ }
+
+ [Fact]
+ public void FirmamentV2Parser_LetPrimitiveLiterals_DuplicateNameIsDiagnostic()
+ {
+ var result = FirmamentV2Parser.Parse("""
+ model LetDuplicateExample {
+ units mm
+ solid base: Box {
+ size: [10, 8, 6]
+ }
+ let holeCount: int = 4
+ let holeCount: int = 5
+ }
+ """);
+
+ Assert.False(result.IsSuccess);
+ Assert.Contains(FirmamentV2Parser.LetDuplicateName, result.Diagnostics);
+ }
+
+ private static void AssertLet(FirmamentV2BoundLet actual, string name, FirmamentV2PrimitiveType type, object value, string? unit)
+ {
+ Assert.Equal(name, actual.Name);
+ Assert.Equal(type, actual.Type);
+ Assert.Equal(value, actual.Value.Value);
+ Assert.Equal(unit, actual.Value.Unit);
+ }
+
}
diff --git a/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2Ast.cs b/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2Ast.cs
index f1b2f09a..997a9a6a 100644
--- a/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2Ast.cs
+++ b/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2Ast.cs
@@ -1,6 +1,6 @@
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)
+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)
{
public FirmamentV2SolidBinding Solid => Solids[^1];
public FirmamentV2SideHoleIntent? SideHoleIntent => ModifyBlocks?.SelectMany(m => m.Regions.Select(r =>
@@ -11,6 +11,12 @@ public sealed record FirmamentV2Document(string ModelName, string Units, IReadOn
})).SingleOrDefault();
}
+public sealed record FirmamentV2SourceSpan(int Start, int Length);
+public enum FirmamentV2PrimitiveType { Int, Float, Length, Angle, String, Bool }
+public sealed record FirmamentV2LiteralValue(FirmamentV2PrimitiveType Type, object Value, double? NumericValue = null, string? Unit = null, string? Raw = null);
+public sealed record FirmamentV2LetDeclaration(string Name, FirmamentV2PrimitiveType DeclaredType, FirmamentV2LiteralValue LiteralValue, FirmamentV2SourceSpan SourceSpan);
+public sealed record FirmamentV2BoundLet(string Name, FirmamentV2PrimitiveType Type, FirmamentV2LiteralValue Value, FirmamentV2SourceSpan SourceSpan);
+
public sealed record FirmamentV2SolidBinding(string Name, string RecordType, FirmamentV2PrimitiveRecord Primitive, string? DerivedFrom = null, IReadOnlyDictionary<string, IReadOnlyList<double>>? Overrides = null)
{
public bool IsDerived => !string.IsNullOrWhiteSpace(DerivedFrom);
diff --git a/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2Parser.cs b/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2Parser.cs
index f0abc148..ce820025 100644
--- a/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2Parser.cs
+++ b/Aetheris.Kernel.Firmament/FirmamentV2/FirmamentV2Parser.cs
@@ -39,6 +39,13 @@ public static class FirmamentV2Parser
public const string DfmConceptUnitMismatch = "firmament-v2-dfm-concept-unit-mismatch";
public const string DfmMinimumToolRadiusViolation = "firmament-v2-dfm-minimum-tool-radius-violation";
+ public const string LetDuplicateName = "firmament-v2-let-duplicate-name";
+ public const string LetUnknownType = "firmament-v2-let-unknown-type";
+ public const string LetTypeMismatch = "firmament-v2-let-type-mismatch";
+ public const string LetInvalidLiteral = "firmament-v2-let-invalid-literal";
+ public const string LetUnitMismatch = "firmament-v2-let-unit-mismatch";
+ public const string LetLiteralOnly = "firmament-v2-let-literal-only";
+
public const string ModifyTargetUnresolved = "firmament-v2-modify-target-unresolved";
public const string ModifyTargetNotSolid = "firmament-v2-modify-target-not-solid";
public const string RegionUnsupported = "firmament-v2-region-unsupported";
@@ -110,6 +117,8 @@ public static class FirmamentV2Parser
private static readonly Regex ModelRegex = new(@"\bmodel\s+(?<name>[A-Za-z_][A-Za-z0-9_]*)\s*\{", RegexOptions.CultureInvariant);
private static readonly Regex UnitsRegex = new(@"\bunits\s+(?<units>[A-Za-z_][A-Za-z0-9_]*)\b", RegexOptions.CultureInvariant);
+ private static readonly HashSet<string> ReservedWords = new(StringComparer.Ordinal) { "let", "model", "units", "solid", "modify", "region", "cut", "template", "concept", "pmi", "recognize", "replace", "with", "true", "false", "int", "float", "length", "angle", "string", "bool" };
+ private static readonly Regex LetRegex = new(@"\blet\s+(?<name>[A-Za-z_][A-Za-z0-9_]*)\s*:\s*(?<type>[A-Za-z_][A-Za-z0-9_]*)\s*=\s*(?<literal>[^\r\n{}]+)", RegexOptions.CultureInvariant);
private static readonly Regex SolidHeaderRegex = new(@"\bsolid\s+(?<name>[A-Za-z_][A-Za-z0-9_]*)\s*:\s*(?<target>[A-Za-z_][A-Za-z0-9_]*)(?<with>\s+with)?\s*\{", RegexOptions.CultureInvariant);
private static readonly Regex LegacyEqualsSolidRegex = new(@"\bsolid\s+(?<name>[A-Za-z_][A-Za-z0-9_]*)\s*=\s*(?<target>[A-Za-z_][A-Za-z0-9_]*)(?<with>\s+with)?\s*\{(?<body>.*?)\}", RegexOptions.CultureInvariant | RegexOptions.Singleline);
private static readonly Regex SizeRegex = new(@"\bsize\s*:\s*\[(?<values>[^\]]*)\]", RegexOptions.CultureInvariant | RegexOptions.Singleline);
@@ -194,6 +203,8 @@ public static class FirmamentV2Parser
}
}
+ var lets = ParseLets(source, byName.Keys, diagnostics);
+
var modifyBlocks = ParseModifyBlocks(source, byName, diagnostics);
var templates = ParseTemplates(source, diagnostics);
var recognizedRegions = ParseRecognizedRegions(source, byName, diagnostics);
@@ -202,13 +213,80 @@ public static class FirmamentV2Parser
FirmamentV2Document? document = null;
if (modelMatch.Success && unitsMatch.Success && solids.Count > 0 && !diagnostics.Any(IsFatalDiagnostic))
- document = new FirmamentV2Document(modelMatch.Groups["name"].Value, unitsMatch.Groups["units"].Value, solids, modifyBlocks, templates, pmi, recognizedRegions, replacements);
+ document = new FirmamentV2Document(modelMatch.Groups["name"].Value, unitsMatch.Groups["units"].Value, solids, modifyBlocks, templates, pmi, recognizedRegions, replacements, lets, lets.Select(l => new FirmamentV2BoundLet(l.Name, l.DeclaredType, l.LiteralValue, l.SourceSpan)).ToArray());
diagnostics.Add(document is null ? "firmament-v2-parse-failed" : "firmament-v2-parse-succeeded");
diagnostics.Sort(StringComparer.Ordinal);
return document is null ? FirmamentV2ParseResult.Failure(diagnostics) : FirmamentV2ParseResult.Success(document, diagnostics);
}
+ private static IReadOnlyList<FirmamentV2LetDeclaration> ParseLets(string source, IEnumerable<string> topLevelNames, List<string> diagnostics)
+ {
+ var lets = new List<FirmamentV2LetDeclaration>();
+ var names = new HashSet<string>(topLevelNames, StringComparer.Ordinal);
+ foreach (Match match in LetRegex.Matches(source))
+ {
+ var name = match.Groups["name"].Value;
+ if (names.Contains(name) || ReservedWords.Contains(name)) { diagnostics.Add(LetDuplicateName); continue; }
+ names.Add(name);
+ if (!TryParseLetType(match.Groups["type"].Value, out var type)) { diagnostics.Add(LetUnknownType); continue; }
+ var literal = match.Groups["literal"].Value.Trim();
+ var value = ParseLetLiteral(type, literal, diagnostics);
+ if (value is not null) lets.Add(new FirmamentV2LetDeclaration(name, type, value, new FirmamentV2SourceSpan(match.Index, match.Length)));
+ }
+ return lets;
+ }
+
+ private static bool TryParseLetType(string text, out FirmamentV2PrimitiveType type)
+ {
+ type = text switch
+ {
+ "int" => FirmamentV2PrimitiveType.Int,
+ "float" => FirmamentV2PrimitiveType.Float,
+ "length" => FirmamentV2PrimitiveType.Length,
+ "angle" => FirmamentV2PrimitiveType.Angle,
+ "string" => FirmamentV2PrimitiveType.String,
+ "bool" => FirmamentV2PrimitiveType.Bool,
+ _ => default
+ };
+ return text is "int" or "float" or "length" or "angle" or "string" or "bool";
+ }
+
+ private static FirmamentV2LiteralValue? ParseLetLiteral(FirmamentV2PrimitiveType type, string literal, List<string> diagnostics)
+ {
+ if (literal.Contains('/') || Regex.IsMatch(literal, @"^[A-Za-z_][A-Za-z0-9_]*\b", RegexOptions.CultureInvariant) && type is not FirmamentV2PrimitiveType.Bool)
+ { diagnostics.Add(LetLiteralOnly); return null; }
+ var m = Regex.Match(literal, @"^(?<num>[-+]?\d+(?:\.\d+)?)(?<unit>[A-Za-z_][A-Za-z0-9_]*)?$", RegexOptions.CultureInvariant);
+ switch (type)
+ {
+ case FirmamentV2PrimitiveType.Int:
+ if (!Regex.IsMatch(literal, @"^[-+]?\d+$", RegexOptions.CultureInvariant)) { diagnostics.Add(LetTypeMismatch); return null; }
+ return new(type, int.Parse(literal, CultureInfo.InvariantCulture), int.Parse(literal, CultureInfo.InvariantCulture), null, literal);
+ case FirmamentV2PrimitiveType.Float:
+ if (!m.Success) { diagnostics.Add(LetInvalidLiteral); return null; }
+ if (m.Groups["unit"].Success) { diagnostics.Add(LetUnitMismatch); return null; }
+ var f = double.Parse(m.Groups["num"].Value, CultureInfo.InvariantCulture);
+ return new(type, f, f, null, literal);
+ case FirmamentV2PrimitiveType.Length:
+ if (!m.Success) { diagnostics.Add(LetInvalidLiteral); return null; }
+ if (m.Groups["unit"].Value != "mm") { diagnostics.Add(m.Groups["unit"].Success ? LetUnitMismatch : LetTypeMismatch); return null; }
+ var length = double.Parse(m.Groups["num"].Value, CultureInfo.InvariantCulture);
+ return new(type, length, length, "mm", literal);
+ case FirmamentV2PrimitiveType.Angle:
+ if (!m.Success) { diagnostics.Add(LetInvalidLiteral); return null; }
+ if (m.Groups["unit"].Value != "deg") { diagnostics.Add(m.Groups["unit"].Success ? LetUnitMismatch : LetTypeMismatch); return null; }
+ var angle = double.Parse(m.Groups["num"].Value, CultureInfo.InvariantCulture);
+ return new(type, angle, angle, "deg", literal);
+ case FirmamentV2PrimitiveType.String:
+ if (!Regex.IsMatch(literal, "^\\\"[^\\\"]*\\\"$", RegexOptions.CultureInvariant)) { diagnostics.Add(LetInvalidLiteral); return null; }
+ return new(type, literal[1..^1], null, null, literal);
+ case FirmamentV2PrimitiveType.Bool:
+ if (literal is not ("true" or "false")) { diagnostics.Add(LetInvalidLiteral); return null; }
+ return new(type, literal == "true", null, null, literal);
+ default: return null;
+ }
+ }
+
private static FirmamentV2SolidBinding? ParseDirect(string name, string recordType, string body, List<string> diagnostics, string? sourceDirectory)
{
if (string.Equals(recordType, "Box", StringComparison.Ordinal))
@@ -316,7 +394,7 @@ public static class FirmamentV2Parser
return new(name, "Box", new FirmamentV2BoxRecord(values, []), baseName, new Dictionary<string, IReadOnlyList<double>>(StringComparer.Ordinal) { ["size"] = values });
}
- private static bool IsFatalDiagnostic(string code) => code is 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 RecognitionEvidenceRadiusInvalid or RecognitionEvidenceSurfaceFamilyUnknown or RecognitionEvidenceAxisInvalid or SemanticProposalKindMismatch or SemanticProposalRadiusInvalid or SemanticProposalTargetUnresolved or SemanticProposalEndUnsupported;
+ private static bool IsFatalDiagnostic(string code) => code is 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 LetTypeMismatch or LetInvalidLiteral or LetUnitMismatch or LetLiteralOnly or RecognitionEvidenceRadiusInvalid or RecognitionEvidenceSurfaceFamilyUnknown or RecognitionEvidenceAxisInvalid or SemanticProposalKindMismatch or SemanticProposalRadiusInvalid or SemanticProposalTargetUnresolved or SemanticProposalEndUnsupported;
private static IReadOnlyList<FirmamentV2Exposure> ParseExposures(string body, List<string> diagnostics)
{
diff --git a/docs/implementation/firmament-v2-l1-let-primitive-literals.md b/docs/implementation/firmament-v2-l1-let-primitive-literals.md
new file mode 100644
index 00000000..830e13b7
--- /dev/null
+++ b/docs/implementation/firmament-v2-l1-let-primitive-literals.md
@@ -0,0 +1,54 @@
+# Firmament V2 L1 `let` primitive literals
+
+Milestone: **V2-PHASE1-L1**
+
+Firmament V2 L1 supports immutable top-level primitive `let` declarations as typed manufacturing-intent data. These declarations are parsed into the V2 document and bound into a semantic let list for later milestones to reference.
+
+## Supported syntax
+
+```firmament
+let name: type = literal
+```
+
+Supported primitive type names are lowercase:
+
+- `int`
+- `float`
+- `length`
+- `angle`
+- `string`
+- `bool`
+
+## Literal rules
+
+- `int`: integer literal only, with no decimal point and no unit.
+- `float`: numeric literal with no unit; integer-looking values are allowed.
+- `length`: numeric literal with the currently supported length unit, `mm`.
+- `angle`: numeric literal with the currently supported angle unit, `deg`.
+- `string`: quoted literal.
+- `bool`: `true` or `false`.
+
+The bound value preserves the declared primitive type, the canonical value, and the unit where applicable.
+
+## Diagnostics
+
+L1 let validation reports deterministic diagnostics for unsupported or invalid input:
+
+- `firmament-v2-let-duplicate-name`
+- `firmament-v2-let-unknown-type`
+- `firmament-v2-let-type-mismatch`
+- `firmament-v2-let-invalid-literal`
+- `firmament-v2-let-unit-mismatch`
+- `firmament-v2-let-literal-only`
+
+## Explicit non-scope
+
+This milestone intentionally does **not** implement:
+
+- records or grouped `let` blocks;
+- references between `let` declarations;
+- arithmetic or expression graphs;
+- tolerance syntax;
+- conditionals, loops, user functions, mutation, hidden behavior, or logic.
+
+`let` declarations are not wired into STEP/AP242 behavior, PMI output, Forge descriptors, demo packets, or modeling behavior in L1.
diff --git a/docs/v2/aetheris-v2-phase1-scope-contract.md b/docs/v2/aetheris-v2-phase1-scope-contract.md
index 2b8055fe..87c6c7da 100644
--- a/docs/v2/aetheris-v2-phase1-scope-contract.md
+++ b/docs/v2/aetheris-v2-phase1-scope-contract.md
@@ -416,7 +416,7 @@ pmi {
Recommended post-L0 order:
```text
-L1: let declarations + primitive typed literals
+L1: let declarations + primitive typed literals — implemented as top-level immutable primitive literals (`int`, `float`, `length`, `angle`, `string`, `bool`) with records, references, arithmetic, and tolerances still deferred to later L-levels.
L2: let record groups + dotted references
L3: arithmetic expression graph + acyclic validation
L4: tolerance syntax and tolerant dimension values
diff --git a/fixtures/FirmamentV2/Language/valid/let-primitive-literals.valid.firmfixture b/fixtures/FirmamentV2/Language/valid/let-primitive-literals.valid.firmfixture
new file mode 100644
index 00000000..806c3342
--- /dev/null
+++ b/fixtures/FirmamentV2/Language/valid/let-primitive-literals.valid.firmfixture
@@ -0,0 +1,23 @@
+// fixture-id: let-primitive-literals
+// case: firmament-v2-l1-let-primitive-literals
+// category: Language
+// syntax-version: FirmamentV2
+// validity: valid
+// implementation: parser-backed
+// expected: valid
+// notes: L1 immutable primitive typed let bindings only; not referenced by PMI/features.
+
+model LetPrimitiveLiteralsExample {
+ units mm
+
+ solid base: Box {
+ size: [10, 8, 6]
+ }
+
+ let holeCount: int = 4
+ let scale: float = 1.25
+ let holeDiameter: length = 6.0mm
+ let draftAngle: angle = 3deg
+ let materialName: string = "Aluminum6061"
+ let inspectionRequired: bool = true
+}