🔤 DomainForge™ DSL Language Reference

The semantic modeling language for SEA™ Forge.


Overview

DomainForge™ DSL is a declarative semantic modeling language that defines the single source of truth for SEA™ Forge, driving code generation, governance, and documentation.


Core Primitives

Primitive Purpose Projection Targets
Entity Business actors & objects CALM nodes, KG triples
Resource Quantifiable assets CALM nodes, unit-aware values
Flow Movement between entities CALM relationships, KG edges
Policy Constraints & rules SBVR rules, SHACL shapes

File-Level Metadata

@namespace "com.acme.finance"
@version "2.2.0"
@owner "team-payments"
@collation "en-US:ci"  // optional, case-insensitive

Dimensions & Units

Declaring Dimensions

Dimension "Currency"
Dimension "Mass"
Dimension "Time"

Declaring Units

Unit "USD" of "Currency" factor 1 base "USD"
Unit "EUR" of "Currency" factor 1.07 base "USD"
Unit "kg" of "Mass" factor 1
Unit "lb" of "Mass" factor 0.45359237

Unit Rules


Entity Declarations

Entity "Warehouse.A" in logistics
Entity "AP" in finance
Entity "Vendor.X" in suppliers
Entity "Customer.Premium" in sales

Resource Declarations

Resource "Money" unit "USD" in finance
Resource "Steel" unit "kg" in manufacturing
Resource "ElectricPower" unit "kWh" in energy

Flow Declarations

Flow "Payment" from "AP" to "Vendor.X" quantity 1_500 "USD"
Flow "SteelShipment" from "Plant.B" to "Warehouse.A" quantity 200 "kg"
Flow "Invoice" from "Vendor.X" to "AP" quantity 1_500 "USD"

Policy Declarations

Basic Structure

Policy <name> per <kind> <modality> priority <1-10>
  @rationale "<explanation>"
  @tags ["tag1", "tag2"]
as:
  <boolean expression>

Policy Kinds

Kind Description
Constraint Must be true at all times
Derivation Computed value
Obligation Required action

Modalities

Modality SBVR Form
Obligation “It is obligatory that…”
Prohibition “It is prohibited that…”
Permission “It is permitted that…”

Example Policies

// Vendor payment cap
Policy vendor_cap per Constraint Obligation priority 5
  @rationale "Limit vendor exposure per SOX requirements"
  @tags ["sox", "payments"]
as:
  sum(f in flows where f.resource = "Money" and f.to.name = "Vendor.X": 
      f.quantity as "USD") <= 5_000 "USD"

// Unique warehouse names
Policy unique_names per Constraint Obligation priority 3 as:
  forall e1 in entities:
    forall e2 in entities:
      (e1 != e2 and e1.namespace = e2.namespace) implies (e1.name != e2.name)

Quantifiers

Quantifier SBVR Form Example
forall Universal forall e in entities: e.name != ""
exists Existential exists f in flows: f.quantity > 0
exists_unique Exactly one exists_unique e in entities: e.role = "Primary"

Aggregation Comprehensions

// Sum with predicate and unit coercion
sum(f in flows where f.resource = "Money": f.quantity as "USD")

// Count with predicate
count(e in entities where e.domain = "logistics")

// Min/Max/Avg
min(f in flows where f.resource = "Steel": f.quantity)
max(f in flows where f.resource = "Steel": f.quantity)
avg(f in flows where f.resource = "Money": f.quantity as "USD")

Operators

Precedence (Highest to Lowest)

Precedence Operators
1 Unary: not, -
2 Multiplicative: *, /
3 Additive: +, -
4 Comparison: =, !=, <, <=, >, >=
5 Logical AND: and
6 Logical OR: or
7 Implication: implies

String Operators

Operator Behavior
contains Case-sensitive
startswith Case-sensitive
endswith Case-sensitive
icontains Case-insensitive

Type System

Type Description
Number<Unit> Numeric with unit annotation
String Text value
Bool Boolean
Id<Entity\|Resource\|Flow> Reference identifier
Collection<T> Iterable set

Error Types

Error Description
SyntaxError Grammar/parsing issues
TypeError Type mismatch
UnitError Dimension mismatch
ScopeError Unknown identifier
DeterminismError Side-effect detected